\r
protected static final EELFLogger logger = EELFManager.getInstance().getLogger(DcaeDispatcherServices.class);\r
protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger();\r
- @Autowired\r
- private ClampProperties refProp;\r
+ private final ClampProperties refProp;\r
+ private final DcaeHttpConnectionManager dcaeHttpConnectionManager;\r
private static final String STATUS_URL_LOG = "Status URL extracted: ";\r
private static final String DCAE_URL_PREFIX = "/dcae-deployments/";\r
private static final String DCAE_URL_PROPERTY_NAME = "dcae.dispatcher.url";\r
private static final String DCAE_LINK_FIELD = "links";\r
private static final String DCAE_STATUS_FIELD = "status";\r
\r
- /**\r
- * Delete the deployment on DCAE.\r
- * \r
- * @param deploymentId\r
- * The deployment ID\r
- * @return Return the URL Status\r
- */\r
- public String deleteDeployment(String deploymentId) {\r
- Date startTime = new Date();\r
- LoggingUtils.setTargetContext("DCAE", "deleteDeployment");\r
- try {\r
- String url = refProp.getStringValue(DCAE_URL_PROPERTY_NAME) + DCAE_URL_PREFIX + deploymentId;\r
- String statusUrl = getDcaeResponse(url, "DELETE", null, null, DCAE_LINK_FIELD, DCAE_STATUS_FIELD);\r
- logger.info(STATUS_URL_LOG + statusUrl);\r
- LoggingUtils.setResponseContext("0", "Delete deployments success", this.getClass().getName());\r
- return statusUrl;\r
- } catch (Exception e) {\r
- LoggingUtils.setResponseContext("900", "Delete deployments failed", this.getClass().getName());\r
- LoggingUtils.setErrorContext("900", "Delete deployments error");\r
- logger.error("Exception occurred during Delete Deployment Operation with DCAE", e);\r
- throw new DcaeDeploymentException("Exception occurred during Delete Deployment Operation with DCAE", e);\r
- } finally {\r
- LoggingUtils.setTimeContext(startTime, new Date());\r
- metricsLogger.info("deleteDeployment complete");\r
- }\r
+ @Autowired\r
+ public DcaeDispatcherServices(ClampProperties refProp, DcaeHttpConnectionManager dcaeHttpConnectionManager) {\r
+ this.refProp = refProp;\r
+ this.dcaeHttpConnectionManager = dcaeHttpConnectionManager;\r
}\r
\r
+\r
public String getOperationStatusWithRetry(String operationStatusUrl) throws InterruptedException {\r
String operationStatus = "";\r
for (int i = 0; i < Integer.valueOf(refProp.getStringValue("dcae.dispatcher.retry.limit")); i++) {\r
Date startTime = new Date();\r
LoggingUtils.setTargetContext("DCAE", "getOperationStatus");\r
try {\r
- String responseStr = DcaeHttpConnectionManager.doDcaeHttpQuery(statusUrl, "GET", null, null);\r
+ String responseStr = dcaeHttpConnectionManager.doDcaeHttpQuery(statusUrl, "GET", null, null);\r
JSONObject jsonObj = parseResponse(responseStr);\r
String operationType = (String) jsonObj.get("operationType");\r
String status = (String) jsonObj.get(DCAE_STATUS_FIELD);\r
LoggingUtils.setTargetContext("DCAE", "getDeployments");\r
try {\r
String url = refProp.getStringValue(DCAE_URL_PROPERTY_NAME) + DCAE_URL_PREFIX;\r
- DcaeHttpConnectionManager.doDcaeHttpQuery(url, "GET", null, null);\r
+ dcaeHttpConnectionManager.doDcaeHttpQuery(url, "GET", null, null);\r
LoggingUtils.setResponseContext("0", "Get deployments success", this.getClass().getName());\r
} catch (Exception e) {\r
LoggingUtils.setResponseContext("900", "Get deployments failed", this.getClass().getName());\r
String nodeAttr) throws IOException, ParseException {\r
Date startTime = new Date();\r
try {\r
- String responseStr = DcaeHttpConnectionManager.doDcaeHttpQuery(url, requestMethod, payload, contentType);\r
+ String responseStr = dcaeHttpConnectionManager.doDcaeHttpQuery(url, requestMethod, payload, contentType);\r
JSONObject jsonObj = parseResponse(responseStr);\r
JSONObject linksObj = (JSONObject) jsonObj.get(node);\r
String statusUrl = (String) linksObj.get(nodeAttr);\r