Merge "Adding Junit"
[so.git] / mso-api-handlers / mso-api-handler-infra / src / main / java / org / openecomp / mso / apihandlerinfra / ManualTasks.java
index d1e60a1..e268c65 100644 (file)
@@ -1,8 +1,9 @@
 /*-\r
  * ============LICENSE_START=======================================================\r
- * OPENECOMP - MSO\r
+ * ONAP - SO\r
  * ================================================================================\r
  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.\r
  * ================================================================================\r
  * Licensed under the Apache License, Version 2.0 (the "License");\r
  * you may not use this file except in compliance with the License.\r
@@ -43,15 +44,14 @@ import javax.ws.rs.Produces;
 import javax.ws.rs.core.MediaType;\r
 import javax.ws.rs.core.Response;\r
 \r
-import org.codehaus.jackson.map.ObjectMapper;\r
-import org.codehaus.jackson.map.SerializationConfig;\r
+import com.fasterxml.jackson.databind.ObjectMapper;\r
+import com.fasterxml.jackson.databind.SerializationFeature;\r
 \r
 \r
 @Path("/tasks")\r
 public class ManualTasks {\r
        private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH);\r
        private static MsoAlarmLogger alarmLogger = new MsoAlarmLogger ();\r
-       public final static String MSO_PROP_APIHANDLER_INFRA = "MSO_PROP_APIHANDLER_INFRA";     \r
        \r
        @POST\r
        @Path("/{version:[vV]1}/{taskId}/complete")\r
@@ -90,7 +90,7 @@ public class ManualTasks {
                                        "Mapping of request to JSON object failed.  " + e.getMessage(),\r
                                        ErrorNumbers.SVC_BAD_PARAMETER, null);\r
                        \r
-                       msoLogger.error (MessageEnum.APIH_REQUEST_VALIDATION_ERROR, MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.SchemaError, request, e);\r
+                       msoLogger.error (MessageEnum.APIH_REQUEST_VALIDATION_ERROR, Constants.MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.SchemaError, request, e);\r
                        msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.SchemaError, "Mapping of request to JSON object failed");\r
                        msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ());\r
                        return response;\r
@@ -111,7 +111,7 @@ public class ManualTasks {
                String camundaJsonReq = null;\r
                try {\r
                        ObjectMapper mapper = new ObjectMapper();\r
-                       mapper.configure(SerializationConfig.Feature.WRAP_ROOT_VALUE, true);\r
+                       mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, true);\r
                        camundaJsonReq = mapper.writeValueAsString(variablesForComplete);\r
                        msoLogger.debug("Camunda Json Request: " + camundaJsonReq);\r
                } catch(Exception e){\r
@@ -120,7 +120,7 @@ public class ManualTasks {
                                "Mapping of JSON object to Camunda Request failed.  " + e.getMessage(),\r
                                ErrorNumbers.SVC_GENERAL_SERVICE_ERROR, null);\r
                \r
-                       msoLogger.error (MessageEnum.APIH_GENERAL_EXCEPTION, MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.UnknownError, request, e);\r
+                       msoLogger.error (MessageEnum.APIH_GENERAL_EXCEPTION, Constants.MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.UnknownError, request, e);\r
                        msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError, "Mapping of JSON object to Camunda request failed");\r
                        msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ());\r
                        return response;\r
@@ -142,6 +142,7 @@ public class ManualTasks {
 \r
                        msoLogger.recordMetricEvent (subStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from BPMN engine", "BPMN", requestUrl, null);\r
                } catch (Exception e) {\r
+                   msoLogger.debug ("Exception:", e);\r
                        msoLogger.recordMetricEvent (subStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while communicate with BPMN engine", "BPMN", requestUrl, null);\r
                        msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED);\r
                        Response resp = msoRequest.buildServiceErrorResponse (HttpStatus.SC_BAD_GATEWAY,\r
@@ -153,7 +154,7 @@ public class ManualTasks {
                                        MsoAlarmLogger.CRITICAL,\r
                                        Messages.errors.get (ErrorNumbers.NO_COMMUNICATION_TO_BPEL));\r
                        msoRequest.updateFinalStatus (Status.FAILED);\r
-                       msoLogger.error (MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.AvailabilityError, "Exception while communicate with BPMN engine");\r
+                       msoLogger.error (MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, Constants.MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.AvailabilityError, "Exception while communicate with BPMN engine");\r
                        msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while communicate with BPMN engine");\r
                        msoLogger.debug ("End of the transaction, the final response is: " + (String) resp.getEntity ());\r
                        return resp;\r
@@ -167,7 +168,7 @@ public class ManualTasks {
                                        ErrorNumbers.SVC_NO_SERVER_RESOURCES,\r
                                        null);\r
                        msoRequest.updateFinalStatus (Status.FAILED);\r
-                       msoLogger.error (MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Null response from BPEL");\r
+                       msoLogger.error (MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, Constants.MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Null response from BPEL");\r
                        msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError, "Null response from BPMN");\r
                        msoLogger.debug ("End of the transaction, the final response is: " + (String) resp.getEntity ());\r
                        return resp;\r
@@ -186,11 +187,11 @@ public class ManualTasks {
                        String completeResp = null;\r
                        try {\r
                                ObjectMapper mapper = new ObjectMapper();\r
-                               mapper.configure(SerializationConfig.Feature.WRAP_ROOT_VALUE, true);\r
+                               mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, true);\r
                                completeResp = mapper.writeValueAsString(trr);\r
                        }\r
                        catch (Exception e) {\r
-                               msoLogger.debug("Unable to format response");\r
+                               msoLogger.debug("Unable to format response",e);\r
                                Response resp = msoRequest.buildServiceErrorResponse(bpelStatus,\r
                                                MsoException.ServiceException,\r
                                                "Request Failed due to bad response format" ,\r