update logger statements in apih 05/89705/1
authorBhatt, Prema <prema.bhatt@att.com>
Tue, 11 Jun 2019 14:21:56 +0000 (10:21 -0400)
committerBenjamin, Max (mb388a) <mb388a@us.att.com>
Tue, 11 Jun 2019 14:22:02 +0000 (10:22 -0400)
Corrected arguments to logger methods
only log exception in catch blocks

Change-Id: I0657b00ce45ac543d5e900db6ce5c24ba34e345d
Issue-ID: SO-2007
Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/CamundaClient.java
mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/PathResourceResolver.java
mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/XMLValidator.java
mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/filters/RequestIdFilter.java
mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/exceptions/ApiExceptionMapper.java
mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java
mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/CloudResourcesOrchestration.java
mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/TenantIsolationRequest.java

index ae44398..5dd99f5 100644 (file)
@@ -27,7 +27,6 @@ package org.onap.so.apihandler.common;
 import java.io.IOException;
 import java.util.UUID;
 import javax.xml.bind.DatatypeConverter;
-import org.onap.so.logger.LoggingAnchor;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.http.HttpResponse;
 import org.apache.http.client.methods.HttpPost;
@@ -38,8 +37,6 @@ import org.onap.so.apihandler.camundabeans.CamundaInput;
 import org.onap.so.apihandler.camundabeans.CamundaIntegerInput;
 import org.onap.so.apihandler.camundabeans.CamundaRequest;
 import org.onap.so.apihandler.camundabeans.CamundaVIDRequest;
-import org.onap.so.logger.ErrorCode;
-import org.onap.so.logger.MessageEnum;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.MDC;
@@ -162,8 +159,7 @@ public class CamundaClient extends RequestClient {
             jsonReq = mapper.writeValueAsString(camundaRequest);
             logger.trace("request body is {}", jsonReq);
         } catch (Exception e) {
-            logger.error(LoggingAnchor.FIVE, MessageEnum.APIH_WARP_REQUEST.toString(), "Camunda", "wrapRequest",
-                    ErrorCode.BusinessProcesssError.getValue(), "Error in APIH Warp request", e);
+            logger.error("Error in APIH Warp request", e);
         }
         return jsonReq;
     }
@@ -253,8 +249,7 @@ public class CamundaClient extends RequestClient {
             jsonReq = mapper.writeValueAsString(camundaRequest);
             logger.trace("request body is {}", jsonReq);
         } catch (Exception e) {
-            logger.error(LoggingAnchor.FIVE, MessageEnum.APIH_WARP_REQUEST.toString(), "Camunda", "wrapVIDRequest",
-                    ErrorCode.BusinessProcesssError.getValue(), "Error in APIH Warp request", e);
+            logger.error("Error in APIH Warp request", e);
         }
         return jsonReq;
     }
index ad8cc3f..e2ea021 100644 (file)
@@ -52,7 +52,7 @@ public class PathResourceResolver implements LSResourceResolver {
         try {
             stream = new FileInputStream(path + systemId);
         } catch (FileNotFoundException e) {
-            logger.debug("Could not resolve resource based on file: {}", path + systemId, e);
+            logger.debug("Could not resolve resource based on file: ", e);
         }
 
         input.setPublicId(publicId);
index 34077e6..2b08d11 100644 (file)
@@ -31,10 +31,7 @@ import javax.xml.transform.stream.StreamSource;
 import javax.xml.validation.Schema;
 import javax.xml.validation.SchemaFactory;
 import javax.xml.validation.Validator;
-import org.onap.so.logger.LoggingAnchor;
 import org.apache.commons.io.IOUtils;
-import org.onap.so.logger.ErrorCode;
-import org.onap.so.logger.MessageEnum;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.xml.sax.SAXException;
@@ -95,8 +92,7 @@ public class XMLValidator {
             return "ErrorDetails: " + e.getMessage();
 
         } catch (Exception e) {
-            logger.error(LoggingAnchor.THREE, MessageEnum.APIH_CANNOT_READ_SCHEMA.toString(),
-                    ErrorCode.SchemaError.getValue(), "APIH cannot read schema file", e);
+            logger.error("APIH cannot read schema file", e);
 
             return "ErrorDetails: " + "Unable to read the schema file";
         }
index 399e065..a1c1dd1 100644 (file)
@@ -52,7 +52,7 @@ public class RequestIdFilter implements ContainerRequestFilter {
 
         if (infraActiveRequests != null) {
             MDC.put(ONAPLogConstants.MDCs.RESPONSE_CODE, String.valueOf(HttpStatus.SC_BAD_REQUEST));
-            logger.error("RequestID exists in RequestDB.InfraActiveRequests : " + requestId);
+            logger.error("RequestID exists in RequestDB.InfraActiveRequests : {}", requestId);
         }
     }
 }
index 0d928cb..66b86a6 100644 (file)
@@ -36,18 +36,15 @@ import javax.ws.rs.ext.Provider;
 import javax.xml.bind.JAXBContext;
 import javax.xml.bind.JAXBException;
 import javax.xml.bind.Marshaller;
-import org.onap.so.logger.LoggingAnchor;
 import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo;
-import org.onap.so.logger.ErrorCode;
-import org.onap.so.logger.MessageEnum;
 import org.onap.so.serviceinstancebeans.RequestError;
 import org.onap.so.serviceinstancebeans.ServiceException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import com.fasterxml.jackson.annotation.JsonInclude;
 import com.fasterxml.jackson.core.JsonProcessingException;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.databind.SerializationFeature;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 @Provider
 public class ApiExceptionMapper implements ExceptionMapper<ApiException> {
@@ -135,8 +132,7 @@ public class ApiExceptionMapper implements ExceptionMapper<ApiException> {
         } catch (JsonProcessingException | JAXBException e) {
             String errorMsg =
                     "Exception in buildServiceErrorResponse writing exceptionType to string " + e.getMessage();
-            logger.error(LoggingAnchor.FOUR, MessageEnum.GENERAL_EXCEPTION.toString(), "BuildServiceErrorResponse",
-                    ErrorCode.DataError.getValue(), errorMsg, e);
+            logger.error("BuildServiceErrorResponse", e);
             return errorMsg;
         }
 
index 243fa80..45b521d 100644 (file)
@@ -42,16 +42,15 @@ import javax.xml.transform.Transformer;
 import javax.xml.transform.TransformerFactory;
 import javax.xml.transform.dom.DOMSource;
 import javax.xml.transform.stream.StreamResult;
-import org.onap.so.logger.LoggingAnchor;
 import org.onap.so.apihandler.common.ResponseBuilder;
 import org.onap.so.apihandlerinfra.tasksbeans.TasksRequest;
-import org.onap.so.apihandlerinfra.validation.MembersValidation;
 import org.onap.so.apihandlerinfra.validation.ApplyUpdatedConfigValidation;
 import org.onap.so.apihandlerinfra.validation.CloudConfigurationValidation;
 import org.onap.so.apihandlerinfra.validation.ConfigurationParametersValidation;
 import org.onap.so.apihandlerinfra.validation.CustomWorkflowValidation;
 import org.onap.so.apihandlerinfra.validation.InPlaceSoftwareUpdateValidation;
 import org.onap.so.apihandlerinfra.validation.InstanceIdMapValidation;
+import org.onap.so.apihandlerinfra.validation.MembersValidation;
 import org.onap.so.apihandlerinfra.validation.ModelInfoValidation;
 import org.onap.so.apihandlerinfra.validation.PlatformLOBValidation;
 import org.onap.so.apihandlerinfra.validation.ProjectOwningEntityValidation;
@@ -69,9 +68,7 @@ import org.onap.so.apihandlerinfra.vnfbeans.VnfRequest;
 import org.onap.so.db.request.beans.InfraActiveRequests;
 import org.onap.so.db.request.client.RequestsDbClient;
 import org.onap.so.exceptions.ValidationException;
-import org.onap.so.logger.ErrorCode;
 import org.onap.so.logger.LogConstants;
-import org.onap.so.logger.MessageEnum;
 import org.onap.so.serviceinstancebeans.CloudConfiguration;
 import org.onap.so.serviceinstancebeans.InstanceDirection;
 import org.onap.so.serviceinstancebeans.ModelInfo;
@@ -152,9 +149,7 @@ public class MsoRequest {
             mapper.setSerializationInclusion(Include.NON_DEFAULT);
             requestErrorStr = mapper.writeValueAsString(re);
         } catch (Exception e) {
-            logger.error(LoggingAnchor.THREE, MessageEnum.APIH_VALIDATION_ERROR.toString(),
-                    ErrorCode.DataError.getValue(),
-                    "Exception in buildServiceErrorResponse writing exceptionType to string ", e);
+            logger.error("Exception in buildServiceErrorResponse writing exceptionType to string ", e);
         }
 
         return builder.buildResponse(httpResponseCode, null, requestErrorStr, version);
@@ -398,8 +393,7 @@ public class MsoRequest {
             aq.setRequestStatus(status.toString());
             aq.setLastModifiedBy(Constants.MODIFIED_BY_APIHANDLER);
         } catch (Exception e) {
-            logger.error(LoggingAnchor.THREE, MessageEnum.APIH_DB_INSERT_EXC.toString(), ErrorCode.DataError.getValue(),
-                    "Exception when creation record request", e);
+            logger.error("Exception when creation record request", e);
 
             if (!status.equals(Status.FAILED)) {
                 throw e;
@@ -439,8 +433,7 @@ public class MsoRequest {
             aq.setLastModifiedBy(Constants.MODIFIED_BY_APIHANDLER);
 
         } catch (Exception e) {
-            logger.error(LoggingAnchor.THREE, MessageEnum.APIH_DB_INSERT_EXC.toString(), ErrorCode.DataError.getValue(),
-                    "Exception when creation record request", e);
+            logger.error("Exception when creation record request", e);
 
             if (!status.equals(Status.FAILED)) {
                 throw e;
@@ -467,8 +460,7 @@ public class MsoRequest {
             request.setRequestUrl(MDC.get(LogConstants.HTTP_URL));
             requestsDbClient.save(request);
         } catch (Exception e) {
-            logger.error(LoggingAnchor.FOUR, MessageEnum.APIH_DB_UPDATE_EXC.toString(), e.getMessage(),
-                    ErrorCode.DataError.getValue(), "Exception when updating record in DB");
+            logger.error("Exception when updating record in DB", e);
             logger.debug("Exception: ", e);
         }
     }
@@ -549,8 +541,7 @@ public class MsoRequest {
             return null;
 
         } catch (Exception e) {
-            logger.error(LoggingAnchor.THREE, MessageEnum.APIH_DOM2STR_ERROR.toString(), ErrorCode.DataError.getValue(),
-                    "Exception in domToStr", e);
+            logger.error("Exception in domToStr", e);
         }
         return null;
     }
index be6d5b0..20e8fed 100644 (file)
@@ -92,7 +92,7 @@ public class CloudResourcesOrchestration {
 
         CloudOrchestrationRequest cor = null;
 
-        logger.debug("requestId is: " + requestId);
+        logger.debug("requestId is: {}", requestId);
 
         try {
             ObjectMapper mapper = new ObjectMapper();
index a8d4f8b..007ea93 100644 (file)
@@ -28,7 +28,6 @@ import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
 import javax.ws.rs.core.MultivaluedMap;
-import org.onap.so.logger.LoggingAnchor;
 import org.apache.commons.lang3.StringUtils;
 import org.onap.so.apihandlerinfra.Constants;
 import org.onap.so.apihandlerinfra.Status;
@@ -46,8 +45,6 @@ import org.onap.so.apihandlerinfra.vnfbeans.RequestStatusType;
 import org.onap.so.db.request.beans.InfraActiveRequests;
 import org.onap.so.db.request.client.RequestsDbClient;
 import org.onap.so.exceptions.ValidationException;
-import org.onap.so.logger.ErrorCode;
-import org.onap.so.logger.MessageEnum;
 import org.onap.so.utils.UUIDChecker;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -357,8 +354,7 @@ public class TenantIsolationRequest {
             request.setLastModifiedBy(Constants.MODIFIED_BY_APIHANDLER);
             requestsDbClient.save(request);
         } catch (Exception e) {
-            logger.error(LoggingAnchor.FOUR, MessageEnum.APIH_DB_UPDATE_EXC.toString(), e.getMessage(),
-                    ErrorCode.DataError.getValue(), "Exception when updating record in DB");
+            logger.error("Exception when updating record in DB", e);
             logger.debug("Exception: ", e);
         }
     }