private static final String SDC_SERVICE_URL_PROPERTY_NAME = "sdc.serviceUrl";\r
private static final String SDC_INSTANCE_ID_CLAMP = "CLAMP-Tool";\r
private static final String RESOURCE_URL_PREFIX = "resources";\r
+ private static final LoggingUtils utils = new LoggingUtils (logger);\r
@Autowired\r
private ClampProperties refProp;\r
\r
Date startTime = new Date();\r
String baseUrl = refProp.getStringValue(SDC_SERVICE_URL_PROPERTY_NAME);\r
String basicAuth = getSdcBasicAuth();\r
- LoggingUtils.setTargetContext("SDC", "getSdcServicesInformation");\r
try {\r
String url = baseUrl;\r
if (uuid != null && !uuid.isEmpty()) {\r
}\r
URL urlObj = new URL(url);\r
HttpURLConnection conn = (HttpURLConnection) urlObj.openConnection();\r
+ conn = utils.invoke(conn,"SDC", "getSdcServicesInformation");\r
conn.setRequestProperty(refProp.getStringValue(SDC_INSTANCE_ID_PROPERTY_NAME), SDC_INSTANCE_ID_CLAMP);\r
conn.setRequestProperty(HttpHeaders.AUTHORIZATION, basicAuth);\r
conn.setRequestProperty(HttpHeaders.CONTENT_TYPE, "application/json;charset=UTF-8");\r
conn.setRequestMethod("GET");\r
String resp = getResponse(conn);\r
logger.debug("Services list received from SDC:" + resp);\r
- // metrics log\r
- LoggingUtils.setResponseContext("0", "Get sdc services success", this.getClass().getName());\r
+ utils.invokeReturn();\r
return resp;\r
} catch (IOException e) {\r
LoggingUtils.setResponseContext("900", "Get sdc services failed", this.getClass().getName());\r
LoggingUtils.setTimeContext(startTime, new Date());\r
metricsLogger.info("getSdcServicesInformation complete");\r
}\r
+ utils.invokeReturn();\r
return "";\r
}\r
\r
byte[] postData = formattedSdcReq.getBytes(StandardCharsets.UTF_8);\r
int postDataLength = postData.length;\r
HttpURLConnection conn = getSdcHttpUrlConnection(userid, postDataLength, url, formattedSdcReq);\r
+ conn = utils.invoke(conn,"SDC", "uploadArtifact");\r
try (DataOutputStream wr = new DataOutputStream(conn.getOutputStream())) {\r
wr.write(postData);\r
}\r
String responseStr = getResponse(conn);\r
if (responseStr != null && requestFailed) {\r
logger.error("requestFailed - responseStr=" + responseStr);\r
+ utils.invokeReturn();\r
throw new BadRequestException(responseStr);\r
}\r
+ utils.invokeReturn();\r
return responseStr;\r
} catch (IOException e) {\r
logger.error("Exception when attempting to communicate with SDC", e);\r
+ utils.invokeReturn();\r
throw new SdcCommunicationException("Exception when attempting to communicate with SDC", e);\r
}\r
}\r
String urlReworked = removeUnwantedBracesFromString(url);\r
URL urlObj = new URL(urlReworked);\r
HttpURLConnection conn = (HttpURLConnection) urlObj.openConnection();\r
+ conn = utils.invoke(conn,"SDC", "getSdcResources");\r
String basicAuth = getSdcBasicAuth();\r
conn.setRequestProperty(refProp.getStringValue(SDC_INSTANCE_ID_PROPERTY_NAME), SDC_INSTANCE_ID_CLAMP);\r
conn.setRequestProperty(HttpHeaders.AUTHORIZATION, basicAuth);\r
logger.info("Sdc resource url - " + urlReworked + " , responseCode=" + responseCode);\r
try (BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()))) {\r
String response = IOUtils.toString(in);\r
- LoggingUtils.setResponseContext("0", "Get sdc resources success", this.getClass().getName());\r
return response;\r
}\r
} catch (IOException e) {\r
- LoggingUtils.setResponseContext("900", "Get sdc resources failed", this.getClass().getName());\r
LoggingUtils.setErrorContext("900", "Get sdc resources error");\r
logger.error("Exception occurred during query to SDC", e);\r
return "";\r
} catch (DecoderException e) {\r
- LoggingUtils.setResponseContext("900", "Get sdc resources failed", this.getClass().getName());\r
LoggingUtils.setErrorContext("900", "Get sdc resources error");\r
logger.error("Exception when attempting to decode the Hex string", e);\r
throw new SdcCommunicationException("Exception when attempting to decode the Hex string", e);\r
} catch (GeneralSecurityException e) {\r
- LoggingUtils.setResponseContext("900", "Get sdc resources failed", this.getClass().getName());\r
LoggingUtils.setErrorContext("900", "Get sdc resources error");\r
logger.error("Exception when attempting to decrypt the encrypted password", e);\r
throw new SdcCommunicationException("Exception when attempting to decrypt the encrypted password", e);\r
} finally {\r
LoggingUtils.setTimeContext(startTime, new Date());\r
metricsLogger.info("getCldsServicesOrResourcesBasedOnURL completed");\r
+ utils.invokeReturn();\r
}\r
}\r
\r
url = url + "/" + uploadedArtifactUuid;\r
URL urlObj = new URL(url);\r
HttpURLConnection conn = (HttpURLConnection) urlObj.openConnection();\r
+ conn = utils.invoke(conn,"SDC", "deleteArtifact");\r
conn.setDoOutput(true);\r
conn.setRequestProperty(refProp.getStringValue(SDC_INSTANCE_ID_PROPERTY_NAME), sdcXonapInstanceId);\r
conn.setRequestProperty(HttpHeaders.AUTHORIZATION, basicAuth);\r
responseStr = getResponse(conn);\r
if (responseStr != null && requestFailed) {\r
logger.error("requestFailed - responseStr=" + responseStr);\r
+ utils.invokeReturn();\r
throw new BadRequestException(responseStr);\r
}\r
}\r
+ utils.invokeReturn();\r
return responseStr;\r
} catch (IOException | DecoderException | GeneralSecurityException e) {\r
logger.error("Exception when attempting to communicate with SDC", e);\r
+ utils.invokeReturn();\r
throw new SdcCommunicationException("Exception when attempting to communicate with SDC", e);\r
}\r
}\r