diff options
Diffstat (limited to 'appc-dg/appc-dg-shared/appc-dg-mdsal-store/src/main/java/org/openecomp/appc/mdsal/operation/ConfigOperation.java')
-rw-r--r-- | appc-dg/appc-dg-shared/appc-dg-mdsal-store/src/main/java/org/openecomp/appc/mdsal/operation/ConfigOperation.java | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/appc-dg/appc-dg-shared/appc-dg-mdsal-store/src/main/java/org/openecomp/appc/mdsal/operation/ConfigOperation.java b/appc-dg/appc-dg-shared/appc-dg-mdsal-store/src/main/java/org/openecomp/appc/mdsal/operation/ConfigOperation.java index dbb82468c..5c5a1bb34 100644 --- a/appc-dg/appc-dg-shared/appc-dg-mdsal-store/src/main/java/org/openecomp/appc/mdsal/operation/ConfigOperation.java +++ b/appc-dg/appc-dg-shared/appc-dg-mdsal-store/src/main/java/org/openecomp/appc/mdsal/operation/ConfigOperation.java @@ -67,7 +67,7 @@ import org.apache.commons.io.IOUtils; /** * Provides method to store configuration to MD-SAL store. It also exposes doPut operation which can be used to invoke REST Put operation. -*/ + */ public class ConfigOperation { private static final EELFLogger LOG = EELFManager.getInstance().getLogger(ConfigOperation.class); @@ -100,7 +100,7 @@ public class ConfigOperation { int httpCode; String respBody ; try { - String path = requestFormatter.buildPath(url, module, containerName, subModules); + String path = requestFormatter.buildPath(module, containerName, subModules); LOG.debug("Configuration Path : " + path); URL serviceUrl = new URL(url.getProtocol(), url.getHost(), url.getPort(), path); HttpResponse response = doPut(serviceUrl , configJson); @@ -111,22 +111,25 @@ public class ConfigOperation { throw new APPCException(e); } - if (httpCode != 200 ) { + if (httpCode < 200 || httpCode >= 300 ) { try { + LOG.debug("Config operation Error response code: " + httpCode); ArrayList<String> errorMessage = new ArrayList<>(); JsonNode responseJson = toJsonNodeFromJsonString(respBody); if(responseJson!=null && responseJson.get("errors")!=null) { JsonNode errors = responseJson.get("errors").get("error"); - for (Iterator<JsonNode> i = errors.elements();i.hasNext();){ - JsonNode error = i.next(); - errorMessage.add(error.get("error-message").textValue()); - } + for (Iterator<JsonNode> i = errors.elements();i.hasNext();){ + JsonNode error = i.next(); + errorMessage.add(error.get("error-message").textValue()); + } } - throw new APPCException("Failed to load config JSON to MD SAL store. Error Message:" + errorMessage.toString()); + throw new APPCException("Failed to load config JSON to MD SAL store. Error code:" + httpCode +" Error Message:" + errorMessage.toString()); } catch (Exception e) { - LOG.error("Error while loading config JSON to MD SAL store. "+e.getMessage(), e); - throw new APPCException("Error while loading config JSON to MD SAL store. "+ e.getMessage(),e); + LOG.error("Error while loading config JSON to MD SAL store. Error code:" + httpCode +" Error Message:" + e.getMessage(), e); + throw new APPCException("Error while loading config JSON to MD SAL store. Error code:" + httpCode +" Error Message:" + e.getMessage(),e); } + }else{ + LOG.debug("Config operation successful. Response code: " + httpCode); } } |