try {\r
String url = refProp.getStringValue("DCAE_DISPATCHER_URL") + "/dcae-deployments/" + deploymentId;\r
logger.info("Dcae Dispatcher url - " + url);\r
URL obj = new URL(url);\r
HttpsURLConnection conn = (HttpsURLConnection) obj.openConnection();\r
try {\r
String url = refProp.getStringValue("DCAE_DISPATCHER_URL") + "/dcae-deployments/" + deploymentId;\r
logger.info("Dcae Dispatcher url - " + url);\r
URL obj = new URL(url);\r
HttpsURLConnection conn = (HttpsURLConnection) obj.openConnection();\r
if (inStream != null) {\r
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inStream));\r
String inputLine = null;\r
if (inStream != null) {\r
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inStream));\r
String inputLine = null;\r
while ((inputLine = bufferedReader.readLine()) != null) {\r
response.append(inputLine);\r
}\r
responseStr = response.toString();\r
}\r
\r
while ((inputLine = bufferedReader.readLine()) != null) {\r
response.append(inputLine);\r
}\r
responseStr = response.toString();\r
}\r
\r
- if (responseStr != null) {\r
- if (requestFailed) {\r
- logger.error("requestFailed - responseStr=" + responseStr);\r
- throw new Exception(responseStr);\r
- }\r
+ if (responseStr != null && requestFailed) {\r
+ logger.error("requestFailed - responseStr=" + responseStr);\r
+ throw new BadRequestException(responseStr);\r
- logger.error(e.getClass().getName() + " " + e.getMessage());\r
- throw e;\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
try {\r
URL obj = new URL(statusUrl);\r
HttpsURLConnection conn = (HttpsURLConnection) obj.openConnection();\r
conn.setRequestMethod("GET");\r
try {\r
URL obj = new URL(statusUrl);\r
HttpsURLConnection conn = (HttpsURLConnection) obj.openConnection();\r
conn.setRequestMethod("GET");\r
int responseCode = conn.getResponseCode();\r
logger.debug("Deployment operation status response code - " + responseCode);\r
int responseCode = conn.getResponseCode();\r
logger.debug("Deployment operation status response code - " + responseCode);\r
in = conn.getInputStream();\r
String res = new BufferedReader(new InputStreamReader(in)).lines().collect(Collectors.joining("\n"));\r
JSONParser parser = new JSONParser();\r
in = conn.getInputStream();\r
String res = new BufferedReader(new InputStreamReader(in)).lines().collect(Collectors.joining("\n"));\r
JSONParser parser = new JSONParser();\r
logger.debug(e.getMessage()\r
+ " : got exception while retrieving status, trying again until we get 200 response code");\r
} finally {\r
if (in != null) {\r
in.close();\r
}\r
logger.debug(e.getMessage()\r
+ " : got exception while retrieving status, trying again until we get 200 response code");\r
} finally {\r
if (in != null) {\r
in.close();\r
}\r
try {\r
String url = refProp.getStringValue("DCAE_DISPATCHER_URL") + "/dcae-deployments";\r
logger.info("Dcae Dispatcher deployments url - " + url);\r
URL obj = new URL(url);\r
HttpsURLConnection conn = (HttpsURLConnection) obj.openConnection();\r
conn.setRequestMethod("GET");\r
try {\r
String url = refProp.getStringValue("DCAE_DISPATCHER_URL") + "/dcae-deployments";\r
logger.info("Dcae Dispatcher deployments url - " + url);\r
URL obj = new URL(url);\r
HttpsURLConnection conn = (HttpsURLConnection) obj.openConnection();\r
conn.setRequestMethod("GET");\r
int responseCode = conn.getResponseCode();\r
logger.debug("response code " + responseCode);\r
in = conn.getInputStream();\r
String res = new BufferedReader(new InputStreamReader(in)).lines().collect(Collectors.joining("\n"));\r
logger.debug("res:" + res);\r
} catch (Exception e) {\r
int responseCode = conn.getResponseCode();\r
logger.debug("response code " + responseCode);\r
in = conn.getInputStream();\r
String res = new BufferedReader(new InputStreamReader(in)).lines().collect(Collectors.joining("\n"));\r
logger.debug("res:" + res);\r
} catch (Exception e) {\r
- logger.error("Exception occurred during DCAE communication", e);\r
- throw e;\r
+ logger.error("Exception occurred during getDeployments Operation with DCAE", e);\r
+ throw new DcaeDeploymentException("Exception occurred during getDeployments Operation with DCAE", e);\r
\r
String statusUrl = null;\r
InputStream inStream = null;\r
BufferedReader in = null;\r
\r
String statusUrl = null;\r
InputStream inStream = null;\r
BufferedReader in = null;\r
- String apiBodyString = "{\"serviceTypeId\": \"" + serviceTypeId + "\"}";\r
+ ObjectNode rootNode = (ObjectNode) refProp.getJsonTemplate("dcae.deployment.template");\r
+ ((ObjectNode) rootNode).put("serviceTypeId", serviceTypeId);\r
+ String apiBodyString = rootNode.toString();\r
+\r
logger.info("Dcae api Body String - " + apiBodyString);\r
String url = refProp.getStringValue("DCAE_DISPATCHER_URL") + "/dcae-deployments/" + deploymentId;\r
logger.info("Dcae Dispatcher Service url - " + url);\r
URL obj = new URL(url);\r
HttpsURLConnection conn = (HttpsURLConnection) obj.openConnection();\r
conn.setRequestMethod("PUT");\r
logger.info("Dcae api Body String - " + apiBodyString);\r
String url = refProp.getStringValue("DCAE_DISPATCHER_URL") + "/dcae-deployments/" + deploymentId;\r
logger.info("Dcae Dispatcher Service url - " + url);\r
URL obj = new URL(url);\r
HttpsURLConnection conn = (HttpsURLConnection) obj.openConnection();\r
conn.setRequestMethod("PUT");\r
conn.setRequestProperty("Content-Type", "application/json");\r
conn.setDoOutput(true);\r
try (DataOutputStream wr = new DataOutputStream(conn.getOutputStream())) {\r
conn.setRequestProperty("Content-Type", "application/json");\r
conn.setDoOutput(true);\r
try (DataOutputStream wr = new DataOutputStream(conn.getOutputStream())) {\r
- if (responseStr != null) {\r
- if (requestFailed) {\r
- logger.error("requestFailed - responseStr=" + responseStr);\r
- throw new Exception(responseStr);\r
- }\r
+ if (responseStr != null && requestFailed) {\r
+ logger.error("requestFailed - responseStr=" + responseStr);\r
+ throw new BadRequestException(responseStr);\r
statusUrl = (String) linksObj.get("status");\r
logger.debug("Status URL: " + statusUrl);\r
} catch (Exception e) {\r
statusUrl = (String) linksObj.get("status");\r
logger.debug("Status URL: " + statusUrl);\r
} catch (Exception e) {\r
- logger.error("Exception occurred during the DCAE communication", e);\r
- throw e;\r
+ logger.error("Exception occurred during createNewDeployment Operation with DCAE", e);\r
+ throw new DcaeDeploymentException("Exception occurred during createNewDeployment Operation with DCAE", e);\r
try {\r
String apiBodyString = "{\"serviceTypeId\": \"" + serviceTypeId + "\"}";\r
logger.debug(apiBodyString);\r
try {\r
String apiBodyString = "{\"serviceTypeId\": \"" + serviceTypeId + "\"}";\r
logger.debug(apiBodyString);\r
URL obj = new URL(url);\r
HttpsURLConnection conn = (HttpsURLConnection) obj.openConnection();\r
conn.setRequestMethod("DELETE");\r
URL obj = new URL(url);\r
HttpsURLConnection conn = (HttpsURLConnection) obj.openConnection();\r
conn.setRequestMethod("DELETE");\r
conn.setRequestProperty("Content-Type", "application/json");\r
conn.setDoOutput(true);\r
DataOutputStream wr = new DataOutputStream(conn.getOutputStream());\r
conn.setRequestProperty("Content-Type", "application/json");\r
conn.setDoOutput(true);\r
DataOutputStream wr = new DataOutputStream(conn.getOutputStream());\r
statusUrl = (String) linksObj.get("status");\r
logger.debug("Status URL: " + statusUrl);\r
} catch (Exception e) {\r
statusUrl = (String) linksObj.get("status");\r
logger.debug("Status URL: " + statusUrl);\r
} catch (Exception e) {\r
- logger.error("Exception occurred during DCAE communication", e);\r
- throw e;\r
+ logger.error("Exception occurred during deleteExistingDeployment Operation with DCAE", e);\r
+ throw new DcaeDeploymentException("Exception occurred during deleteExistingDeployment Operation with DCAE",\r
+ e);\r