+\r
+ /**\r
+ * Method to delete blueprint and location json artifacts from sdc\r
+ * \r
+ * @param prop\r
+ * @param userid\r
+ * @param sdcReqUrlsList\r
+ * @param artifactName\r
+ * @param locationArtifactName\r
+ * @throws GeneralSecurityException\r
+ * @throws DecoderException\r
+ */\r
+ public void deleteArtifactsFromSdc(ModelProperties prop, String userid, List<String> sdcReqUrlsList,\r
+ String artifactName, String locationArtifactName) throws GeneralSecurityException, DecoderException {\r
+ String serviceInvariantUuid = getServiceInvariantUuidFromProps(prop);\r
+ for (String url : sdcReqUrlsList) {\r
+ String originalServiceUuid = getServiceUuidFromServiceInvariantId(serviceInvariantUuid);\r
+ logger.info("ServiceUUID used before deleting in url:" + originalServiceUuid);\r
+ String sdcServicesInformation = getSdcServicesInformation(originalServiceUuid);\r
+ SdcServiceDetail cldsSdcServiceDetail = decodeCldsSdcServiceDetailFromJson(sdcServicesInformation);\r
+ String uploadedArtifactUuid = getArtifactIdIfArtifactAlreadyExists(cldsSdcServiceDetail, artifactName);\r
+ String responseStr = deleteArtifact(userid, url, uploadedArtifactUuid);\r
+ logger.info("value of sdc Response of deleting blueprint from sdc :" + responseStr);\r
+ String updatedServiceUuid = getServiceUuidFromServiceInvariantId(serviceInvariantUuid);\r
+ if (!originalServiceUuid.equalsIgnoreCase(updatedServiceUuid)) {\r
+ url = url.replace(originalServiceUuid, updatedServiceUuid);\r
+ }\r
+ logger.info("ServiceUUID used after delete in ulr:" + updatedServiceUuid);\r
+ sdcServicesInformation = getSdcServicesInformation(updatedServiceUuid);\r
+ cldsSdcServiceDetail = decodeCldsSdcServiceDetailFromJson(sdcServicesInformation);\r
+ uploadedArtifactUuid = getArtifactIdIfArtifactAlreadyExists(cldsSdcServiceDetail, locationArtifactName);\r
+ responseStr = deleteArtifact(userid, url, uploadedArtifactUuid);\r
+ logger.info("value of sdc Response of deleting location json from sdc :" + responseStr);\r
+ }\r
+ }\r
+\r
+ private String deleteArtifact(String userid, String url, String uploadedArtifactUuid) {\r
+ try {\r
+ String responseStr = "";\r
+ if (uploadedArtifactUuid != null && !uploadedArtifactUuid.isEmpty()) {\r
+ logger.info("userid=" + userid);\r
+ String basicAuth = getSdcBasicAuth();\r
+ String sdcXonapInstanceId = refProp.getStringValue("sdc.sdcX-InstanceID");\r
+ url = url + "/" + uploadedArtifactUuid;\r
+ URL urlObj = new URL(url);\r
+ HttpURLConnection conn = (HttpURLConnection) urlObj.openConnection();\r
+ conn.setDoOutput(true);\r
+ conn.setRequestProperty(refProp.getStringValue(SDC_INSTANCE_ID_PROPERTY_NAME), sdcXonapInstanceId);\r
+ conn.setRequestProperty(HttpHeaders.AUTHORIZATION, basicAuth);\r
+ conn.setRequestProperty("USER_ID", userid);\r
+ conn.setRequestMethod("DELETE");\r
+ conn.setRequestProperty("charset", "utf-8");\r
+ conn.setUseCaches(false);\r
+ conn.setRequestProperty(refProp.getStringValue(SDC_REQUESTID_PROPERTY_NAME),\r
+ LoggingUtils.getRequestId());\r
+ boolean requestFailed = true;\r
+ int responseCode = conn.getResponseCode();\r
+ logger.info("responseCode=" + responseCode);\r
+ if (responseCode == 200) {\r
+ requestFailed = false;\r
+ }\r
+ responseStr = getResponse(conn);\r
+ if (responseStr != null && requestFailed) {\r
+ logger.error("requestFailed - responseStr=" + responseStr);\r
+ throw new BadRequestException(responseStr);\r
+ }\r
+ }\r
+ return responseStr;\r
+ } catch (IOException | DecoderException | GeneralSecurityException e) {\r
+ logger.error("Exception when attempting to communicate with SDC", e);\r
+ throw new SdcCommunicationException("Exception when attempting to communicate with SDC", e);\r
+ }\r
+ }\r