\r
import com.att.eelf.configuration.EELFLogger;\r
import com.att.eelf.configuration.EELFManager;\r
-import com.fasterxml.jackson.core.JsonProcessingException;\r
\r
import java.io.IOException;\r
import java.util.Date;\r
import org.onap.clamp.clds.model.properties.ModelProperties;\r
import org.onap.clamp.clds.util.JsonUtils;\r
import org.onap.clamp.clds.util.LoggingUtils;\r
+import org.onap.clamp.util.HttpConnectionManager;\r
import org.springframework.beans.factory.annotation.Autowired;\r
import org.springframework.stereotype.Component;\r
\r
public static final String DCAE_INVENTORY_RETRY_LIMIT = "dcae.intentory.retry.limit";\r
private final ClampProperties refProp;\r
private final CldsDao cldsDao;\r
- private final DcaeHttpConnectionManager dcaeHttpConnectionManager;\r
+ private final HttpConnectionManager httpConnectionManager;\r
\r
+ /**\r
+ * Constructor.\r
+ */\r
@Autowired\r
public DcaeInventoryServices(ClampProperties refProp, CldsDao cldsDao,\r
- DcaeHttpConnectionManager dcaeHttpConnectionManager) {\r
+ HttpConnectionManager httpConnectionManager) {\r
this.refProp = refProp;\r
this.cldsDao = cldsDao;\r
- this.dcaeHttpConnectionManager = dcaeHttpConnectionManager;\r
+ this.httpConnectionManager = httpConnectionManager;\r
}\r
\r
/**\r
* @throws ParseException\r
* In case of DCAE Json parse exception\r
*/\r
- public void setEventInventory(CldsModel cldsModel, String userId) throws ParseException, InterruptedException {\r
+ public void setEventInventory(CldsModel cldsModel, String userId) throws InterruptedException {\r
String artifactName = cldsModel.getControlName();\r
DcaeEvent dcaeEvent = new DcaeEvent();\r
DcaeInventoryResponse dcaeResponse = null;\r
}\r
try {\r
// Below are the properties required for calling the dcae inventory\r
- ModelProperties prop = new ModelProperties(cldsModel.getName(), cldsModel.getControlName(), null, false,\r
- "{}", cldsModel.getPropText());\r
+ ModelProperties prop = new ModelProperties(cldsModel.getName(), cldsModel.getControlName(), null,\r
+ false, "{}", cldsModel.getPropText());\r
Global global = prop.getGlobal();\r
String invariantServiceUuid = global.getService();\r
List<String> resourceUuidList = global.getResourceVf();\r
dcaeEvent.setArtifactName(artifactName);\r
dcaeEvent.setEvent(DcaeEvent.EVENT_DISTRIBUTION);\r
LoggingUtils.setResponseContext("0", "Set inventory success", this.getClass().getName());\r
- } catch (JsonProcessingException e) {\r
+ } catch (ParseException e) {\r
LoggingUtils.setResponseContext("900", "Set inventory failed", this.getClass().getName());\r
LoggingUtils.setErrorContext("900", "Set inventory error");\r
logger.error("Error during JSON decoding", e);\r
return totalCount.intValue();\r
}\r
\r
- private DcaeInventoryResponse getItemsFromDcaeInventoryResponse(String responseStr)\r
- throws ParseException {\r
+ private DcaeInventoryResponse getItemsFromDcaeInventoryResponse(String responseStr) throws ParseException {\r
JSONParser parser = new JSONParser();\r
Object obj0 = parser.parse(responseStr);\r
JSONObject jsonObj = (JSONObject) obj0;\r
*/\r
public DcaeInventoryResponse getDcaeInformation(String artifactName, String serviceUuid, String resourceUuid)\r
throws IOException, ParseException, InterruptedException {\r
- Date startTime = new Date();\r
LoggingUtils.setTargetContext("DCAE", "getDcaeInformation");\r
String queryString = "?asdcResourceId=" + resourceUuid + "&asdcServiceId=" + serviceUuid + "&typeName="\r
+ artifactName;\r
logger.info("Dcae Inventory Service full url - " + fullUrl);\r
DcaeInventoryResponse response = queryDcaeInventory(fullUrl);\r
LoggingUtils.setResponseContext("0", "Get Dcae Information success", this.getClass().getName());\r
+ Date startTime = new Date();\r
LoggingUtils.setTimeContext(startTime, new Date());\r
return response;\r
}\r
}\r
for (int i = 0; i < retryLimit; i++) {\r
metricsLogger.info("Attempt n°" + i + " to contact DCAE inventory");\r
- String response = dcaeHttpConnectionManager.doDcaeHttpQuery(fullUrl, "GET", null, null);\r
+ String response = httpConnectionManager.doHttpRequest(fullUrl, "GET", null, null, "DCAE", null, null);\r
int totalCount = getTotalCountFromDcaeInventoryResponse(response);\r
metricsLogger.info("getDcaeInformation complete: totalCount returned=" + totalCount);\r
if (totalCount > 0) {\r