Update the license for 2017-2018 license
[aai/aai-common.git] / aai-core / src / main / java / org / onap / aai / logging / LoggingContext.java
index 7d9dcce..8b8cb17 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * org.onap.aai
  * ================================================================================
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,8 +16,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  * ============LICENSE_END=========================================================
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
  */
 package org.onap.aai.logging;
 
@@ -58,6 +56,12 @@ public class LoggingContext {
        public static final String BUSINESS_PROCESS_ERROR = "500";
        public static final String UNKNOWN_ERROR = "900";
        
+       public static final Map<String, String> responseMap = new HashMap();
+        
+    static {
+        responseMap.put(SUCCESS, "Success");
+        responseMap.put(UNKNOWN_ERROR, "Unknown error");
+    }
        //ECOMP Specific Log Event Fields
        public static enum LoggingField {
                START_TIME("startTime"),
@@ -126,9 +130,6 @@ public class LoggingContext {
 
        public static void requestId(String requestId) {
                try {
-                       if(requestId == null){
-                               throw new IllegalArgumentException();
-                       }
                        if (requestId.contains(":")) {
                                String[] uuidParts = requestId.split(":");
                                requestId = uuidParts[0];
@@ -138,12 +139,13 @@ public class LoggingContext {
                        final UUID generatedRequestUuid = UUID.randomUUID();
                        MDC.put(LoggingField.REQUEST_ID.toString(), generatedRequestUuid.toString());
                        LoggingContext.save();
-                       AAIException ex = new AAIException("AAI_7405", e);
-                       String responseCode = Integer.toString(ex.getErrorObject().getHTTPResponseCode().getStatusCode());
+                       // set response code to 0 since we don't know what the outcome of this request is yet
+                       String responseCode = LoggingContext.DATA_ERROR;
                        LoggingContext.responseCode(responseCode);
-
-                       LOGGER.warn("Unable to use UUID " + requestId + " (Not formatted properly). Using generated UUID="
-                                       + generatedRequestUuid);
+                       LoggingContext.responseDescription("Unable to use UUID " + requestId + " (Not formatted properly) ");
+                       LoggingContext.statusCode(StatusCode.ERROR);
+                       
+                       LOGGER.warn("Using generated UUID=" + generatedRequestUuid);
                        LoggingContext.restore();
 
                }
@@ -196,6 +198,7 @@ public class LoggingContext {
        public static void successStatusFields() {
                responseCode(SUCCESS);
                statusCode(LoggingContext.StatusCode.COMPLETE);
+               responseDescription("Success");
        }
        private static void serverIpAddress() {
                try {