Statically register ObjectMapper Part 2 11/141511/4 1.15.6
authorFiete Ostkamp <Fiete.Ostkamp@telekom.de>
Thu, 10 Jul 2025 08:09:33 +0000 (10:09 +0200)
committerFiete Ostkamp <Fiete.Ostkamp@telekom.de>
Thu, 10 Jul 2025 12:41:44 +0000 (14:41 +0200)
Issue-ID: SO-4187
Change-Id: I2a4f2fece1dfeaff9aeb6c9334e52062682e2f79
Signed-off-by: Fiete Ostkamp <Fiete.Ostkamp@telekom.de>
61 files changed:
adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/tasks/SDNCService.java
bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CNFAdapterAsync.groovy
bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/AnNssmfutils.groovy
bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactory.java
bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/AbstractSdncOperationTask.java
bpmn/so-bpmn-moi/src/main/java/org/onap/so/bpmn/moi/tasks/AssignRANNssiBBTasks.java
bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivity.java
bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnf/tasks/CnfAdapterCreateTasks.java
bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnf/tasks/CnfAdapterUpgradeTasks.java
bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnf/tasks/CnfHealthCheckTasks.java
bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/AbstractInputParametersProvider.java
bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcOrchestratorPreProcessor.java
bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SDNCLcmPayloadBuilder.java
bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SdncControllerDE.java
bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigAssignVnf.java
bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigurationScaleOut.java
bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/GeneralTopologyObjectMapper.java
bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/VfModuleTopologyOperationRequestMapper.java
bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/composition/ChildServiceRequestBuilder.java
bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java
bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java
bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/UserParamsServiceTraversal.java
bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/validators/UpgradePreWorkflowValidator.java
bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterObjectMapper.java
bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingClientResponseValidator.java
common/src/main/java/org/onap/so/beans/nsmf/SliceTaskParams.java
common/src/main/java/org/onap/so/client/policy/CommonObjectMapperProvider.java
common/src/main/java/org/onap/so/client/policy/PolicyClientImpl.java
graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIClientResponseExceptionMapper.java
graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAISingleTransactionClient.java
graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAITransactionalClient.java
graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/HttpLookupUri.java
graph-inventory/fluent-builder-maven-plugin/src/main/java/org/onap/graphinventory/generate/SwaggerConverter.java
mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/camundabeans/CamundaMacroRequestSerializer.java
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/ResponseHandler.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/E2EServiceInstances.java
mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ManagedObject3gppServiceInstances.java
mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ManualTasks.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/Onap3gppServiceInstances.java
mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java
mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationTasks.java
mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java
mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceIntentApiHandler.java
mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/TasksHandler.java
mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/WorkflowSpecificationsHandler.java
mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/BpmnRequestBuilder.java
mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/handler/NetworkRestHandler.java
mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/handler/ServiceInstanceRestHandler.java
mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/handler/VFModuleRestHandler.java
mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/handler/VnfRestHandler.java
mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/handler/VolumeRestHandler.java
mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/CloudOrchestration.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/ModelDistributionRequest.java
mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/TenantIsolationRequest.java
mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/dmaap/DmaapOperationalEnvClient.java
mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateVnfOperationalEnvironment.java

index e5b7049..9343c96 100644 (file)
@@ -48,7 +48,7 @@ public class SDNCService extends ExternalTaskUtils {
     @Autowired
     private Environment env;
 
-    private ObjectMapper objMapper = new ObjectMapper();
+    private static final ObjectMapper objMapper = new ObjectMapper();
 
     public SDNCService() {
         super(RetrySequenceLevel.SHORT);
index 9de40b4..7c50eb9 100755 (executable)
@@ -19,7 +19,7 @@ public class CNFAdapterAsync extends AbstractServiceTaskProcessor {
        private static final Logger logger = LoggerFactory.getLogger(CNFAdapterAsync.class)
 
        ExceptionUtil exceptionUtil = new ExceptionUtil()
-       ObjectMapper mapper = new ObjectMapper();
+       private static final ObjectMapper mapper = new ObjectMapper();
 
        @Override
        public void preProcessRequest(DelegateExecution execution) {
index b89e831..f73c939 100644 (file)
@@ -60,7 +60,7 @@ import com.google.gson.Gson
 class AnNssmfUtils {
 
        private static final Logger logger = LoggerFactory.getLogger(AnNssmfUtils.class)
-       private static final ObjectMapper objectMapper = new ObjectMapper();
+       private static final ObjectMapper objectMapper = new ObjectMapper()
        ExceptionUtil exceptionUtil = new ExceptionUtil()
        JsonUtils jsonUtil = new JsonUtils()
        public String buildSelectRANNSSIRequest(String requestId, String messageType, String UUID,String invariantUUID,
index d1fc0a6..212cd60 100644 (file)
@@ -77,6 +77,9 @@ import com.fasterxml.jackson.databind.SerializationFeature;
 
 public class ServicePluginFactory {
 
+    private static final Logger logger = LoggerFactory.getLogger(ServicePluginFactory.class);
+    private static final ObjectMapper wrapMapper;
+    private static final ObjectMapper nonWrapMapper;
     private static String OOF_DEFAULT_ENDPOINT;
     private static String THIRD_SP_DEFAULT_ENDPOINT;
     private static String INVENTORY_OSS_DEFAULT_ENDPOINT;
@@ -84,7 +87,13 @@ public class ServicePluginFactory {
 
     static JsonUtils jsonUtil = new JsonUtils();
 
-    private static Logger logger = LoggerFactory.getLogger(ServicePluginFactory.class);
+    static {
+        wrapMapper = new ObjectMapper();
+        wrapMapper.configure(SerializationFeature.WRAP_ROOT_VALUE, true);
+        nonWrapMapper = new ObjectMapper();
+        nonWrapMapper.configure(SerializationFeature.WRAP_ROOT_VALUE, false);
+    }
+
 
     private static ServicePluginFactory instance;
 
@@ -845,10 +854,9 @@ public class ServicePluginFactory {
     }
 
     private static <T> T getJsonObject(String jsonstr, Class<T> type) {
-        ObjectMapper mapper = new ObjectMapper();
-        mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, true);
+
         try {
-            return mapper.readValue(jsonstr, type);
+            return wrapMapper.readValue(jsonstr, type);
         } catch (IOException e) {
             logger.error("{} {} fail to unMarshal json", MessageEnum.RA_NS_EXC.toString(),
                     ErrorCode.BusinessProcessError.getValue(), e);
@@ -857,11 +865,9 @@ public class ServicePluginFactory {
     }
 
     public static String getJsonString(Object srcObj) {
-        ObjectMapper mapper = new ObjectMapper();
-        mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, false);
         String jsonStr = null;
         try {
-            jsonStr = mapper.writeValueAsString(srcObj);
+            jsonStr = nonWrapMapper.writeValueAsString(srcObj);
         } catch (JsonProcessingException e) {
             logger.debug("SdcToscaParserException", e);
         }
index e614ddd..aa16664 100644 (file)
@@ -59,6 +59,12 @@ import com.fasterxml.jackson.databind.ObjectMapper;
 public abstract class AbstractSdncOperationTask implements JavaDelegate {
 
     private static final Logger logger = LoggerFactory.getLogger(AbstractSdncOperationTask.class);
+    private static final ObjectMapper objectMapper;
+
+    static {
+        objectMapper = new ObjectMapper();
+        objectMapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY);
+    }
 
     @Autowired
     private Environment env;
@@ -103,10 +109,8 @@ public abstract class AbstractSdncOperationTask implements JavaDelegate {
     }
 
     protected String getPostbody(Object inputEntity) {
-        ObjectMapper objectMapper = new ObjectMapper();
         String postBody = null;
         try {
-            objectMapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY);
             postBody = objectMapper.writeValueAsString(inputEntity);
         } catch (JsonProcessingException e) {
             logger.error("JsonProcessingException in getPostbody", e);
index 1ef073c..6c22a16 100644 (file)
@@ -49,7 +49,7 @@ public class AssignRANNssiBBTasks {
     @Autowired
     private InjectionHelper injectionHelper;
 
-    private ObjectMapper mapper = new ObjectMapper();
+    private static final ObjectMapper mapper = new ObjectMapper();
 
     private AAIRestClientImpl aaiRestClient = new AAIRestClientImpl();
 
index 415d461..545ecf7 100644 (file)
@@ -76,7 +76,7 @@ public class ExecuteActivity implements JavaDelegate {
     private static final String ACTIVITY_PREFIX = "activity:";
     private static final String EXECUTE_ACTIVITY_ERROR_MESSAGE = "ExecuteActivityErrorMessage";
 
-    private ObjectMapper mapper = new ObjectMapper();
+    private static final ObjectMapper mapper = new ObjectMapper();
 
     @Autowired
     private RuntimeService runtimeService;
index 5e3b781..810b8ea 100644 (file)
@@ -69,7 +69,7 @@ public class CnfAdapterCreateTasks {
     @Autowired
     private VnfAdapterVfModuleObjectMapper vfModuleMapper;
 
-    private ObjectMapper mapper = new ObjectMapper();
+    private static final ObjectMapper mapper = new ObjectMapper();
 
     /**
      * This method is used for creating the request for an Instance in Multicloud K8s Plugin.
index 4fd0aab..c19beb1 100644 (file)
@@ -66,7 +66,7 @@ public class CnfAdapterUpgradeTasks {
     @Autowired
     private VnfAdapterVfModuleObjectMapper vfModuleMapper;
 
-    private ObjectMapper mapper = new ObjectMapper();
+    private static final ObjectMapper mapper = new ObjectMapper();
 
     /**
      * This method is used for updating the request for an Instance in Multicloud K8s Plugin.
index e6545cb..d583aa1 100755 (executable)
@@ -37,7 +37,7 @@ public class CnfHealthCheckTasks {
     @Autowired
     private ExceptionBuilder exceptionUtil;
 
-    private ObjectMapper mapper = new ObjectMapper();
+    private static final ObjectMapper mapper = new ObjectMapper();
 
     public void prepareCnfAdaperRequest(BuildingBlockExecution execution) {
         GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
index 854f848..9764db7 100644 (file)
@@ -5,15 +5,15 @@
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
- * 
+ *
  * SPDX-License-Identifier: Apache-2.0
  * ============LICENSE_END=========================================================
  */
@@ -37,10 +37,10 @@ import com.fasterxml.jackson.databind.ObjectMapper;
 public abstract class AbstractInputParametersProvider<T> implements InputParametersProvider<T> {
 
     private static final Logger LOGGER = LoggerFactory.getLogger(AbstractInputParametersProvider.class);
+    private static final ObjectMapper mapper = new ObjectMapper();
 
     protected Map<String, String> parseAdditionalParameters(final String additionalParamsString) {
         try {
-            final ObjectMapper mapper = new ObjectMapper();
             final TypeReference<Map<String, String>> typeRef = new TypeReference<Map<String, String>>() {};
             return mapper.readValue(additionalParamsString, typeRef);
         } catch (final Exception exception) {
@@ -52,7 +52,6 @@ public abstract class AbstractInputParametersProvider<T> implements InputParamet
 
     protected List<ExternalVirtualLink> parseExternalVirtualLinks(final String extVirtualLinksString) {
         try {
-            final ObjectMapper mapper = new ObjectMapper();
             final TypeReference<List<ExternalVirtualLink>> extVirtualLinksStringTypeRef =
                     new TypeReference<List<ExternalVirtualLink>>() {};
             return mapper.readValue(extVirtualLinksString, extVirtualLinksStringTypeRef);
index 2644ae1..224924d 100644 (file)
@@ -39,6 +39,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
 public class AppcOrchestratorPreProcessor {
     private static final Logger logger = LoggerFactory.getLogger(AppcOrchestratorPreProcessor.class);
     public static final String CONTROLLER_TYPE_DEFAULT = "APPC";
+    private static final ObjectMapper objectMapper = new ObjectMapper();
 
     @Autowired
     private ExceptionBuilder exceptionUtil;
@@ -94,7 +95,6 @@ public class AppcOrchestratorPreProcessor {
                 appcTaskRequest.setOperationsTimeout(operationsTimeout);
 
                 Map<String, String> configMap = new HashMap<>();
-                ObjectMapper objectMapper = new ObjectMapper();
                 String configParamsStr = JsonUtils.getJsonValue(payload, "configuration_parameters");
                 if (configParamsStr != null) {
                     configMap =
index b29009f..63c2d1d 100644 (file)
@@ -7,9 +7,9 @@
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -34,6 +34,7 @@ import org.onap.so.bpmn.infrastructure.decisionpoint.impl.camunda.controller.com
 public class SDNCLcmPayloadBuilder {
 
     private static Logger logger = LoggerFactory.getLogger(SDNCLcmPayloadBuilder.class);
+    private static final ObjectMapper mapper = new ObjectMapper();
 
     public static ActivateNESwPayload buildActivateNESwPayload(DelegateExecution execution) {
         String requestPayload = String.valueOf(execution.getVariable(REQUEST_PAYLOAD));
@@ -68,7 +69,6 @@ public class SDNCLcmPayloadBuilder {
         String swToBeDownloadedString = JsonUtils.getJsonValue(requestPayload, "swToBeDownloaded");
         SwToBeDownloadedElement[] swToBeDownloadedArray;
 
-        ObjectMapper mapper = new ObjectMapper();
         try {
             swToBeDownloadedArray = mapper.readValue(swToBeDownloadedString, SwToBeDownloadedElement[].class);
             downloadNESwPayload.setSwToBeDownloaded(Arrays.asList(swToBeDownloadedArray));
@@ -147,7 +147,6 @@ public class SDNCLcmPayloadBuilder {
     }
 
     public static String convertToSting(Object msgObject) throws JsonProcessingException {
-        ObjectMapper mapper = new ObjectMapper();
         return mapper.writeValueAsString(msgObject);
     }
 }
index ea3405d..dfe77ca 100644 (file)
@@ -43,6 +43,7 @@ import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableName
 public class SdncControllerDE extends LcmControllerDE {
 
     private static final int SDNC_DELEGATE_EXECUTION_ERROR_CODE = 1103;
+    private static final ObjectMapper mapper = new ObjectMapper();
 
     @Override
     public Boolean understand(ControllerContext<DelegateExecution> context) {
@@ -221,7 +222,6 @@ public class SdncControllerDE extends LcmControllerDE {
         LcmInput lcmInput =
                 SDNCLcmMessageBuilder.buildLcmInputForPnf(requestId, subRequestId, pnfName, lcmAction, lcmPayload);
 
-        ObjectMapper mapper = new ObjectMapper();
         try {
             String lcmInputMsg = mapper.writeValueAsString(lcmInput);
             logger.debug("SDNC input message for {}: {}", lcmAction, lcmInputMsg);
index 3a69d27..4aa9c11 100644 (file)
@@ -55,6 +55,7 @@ public class ConfigAssignVnf {
     private static final String ORIGINATOR_ID = "SO";
     private static final String ACTION_NAME = "config-assign";
     private static final String MODE = "sync";
+    private static final ObjectMapper objectMapper = new ObjectMapper();
 
     private final ExtractPojosForBB extractPojosForBB;
     private final ExceptionBuilder exceptionBuilder;
@@ -130,7 +131,6 @@ public class ConfigAssignVnf {
     }
 
     private Service getServiceObjectFromServiceMap(Map<String, Object> serviceMap) throws IOException {
-        ObjectMapper objectMapper = new ObjectMapper();
         String serviceFromJson = objectMapper.writeValueAsString(serviceMap.get("service"));
         try {
             return objectMapper.readValue(serviceFromJson, Service.class);
index 7930a33..6f492b7 100644 (file)
@@ -9,9 +9,9 @@
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -67,6 +67,7 @@ public class ConfigurationScaleOut {
     private static final String VFMODULE_ID = "vfModuleId";
     private static final String CONTROLLER_TYPE = "controllerType";
     private static final String PAYLOAD = "payload";
+    private static final ObjectMapper mapper = new ObjectMapper();
 
     public void setParamsForConfigurationScaleOut(BuildingBlockExecution execution) {
 
@@ -76,7 +77,6 @@ public class ConfigurationScaleOut {
             List<Map<String, String>> jsonPathForCfgParams = gBBInput.getRequestContext().getConfigurationParameters();
             String key = null;
             String paramValue = null;
-            ObjectMapper mapper = new ObjectMapper();
             String configScaleOutPayloadString = null;
             ControllerSelectionReference controllerSelectionReference;
             ConfigScaleOutPayload configPayload = new ConfigScaleOutPayload();
index 48a384c..8273df2 100644 (file)
@@ -53,7 +53,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
 public class GeneralTopologyObjectMapper {
 
     private static final Logger logger = LoggerFactory.getLogger(GeneralTopologyObjectMapper.class);
-    private ObjectMapper mapper = new ObjectMapper();
+    private static final ObjectMapper mapper = new ObjectMapper();
 
     /*
      * Build GenericResourceApiRequestinformationRequestInformation
@@ -204,7 +204,7 @@ public class GeneralTopologyObjectMapper {
 
     /**
      * Build ConfigurationInformation
-     * 
+     *
      * @param configuration
      * @param includeModelInformation
      * @return
@@ -231,7 +231,7 @@ public class GeneralTopologyObjectMapper {
 
     /**
      * Build GcRequestInformation
-     * 
+     *
      * @param vnf
      * @param genericResourceApiParam
      * @return
index 5852767..151d212 100644 (file)
@@ -9,9 +9,9 @@
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -59,6 +59,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
 @Component
 public class VfModuleTopologyOperationRequestMapper {
     private static final Logger logger = LoggerFactory.getLogger(VfModuleTopologyOperationRequestMapper.class);
+    private static final ObjectMapper mapper = new ObjectMapper();
 
     @Autowired
     private GeneralTopologyObjectMapper generalTopologyObjectMapper;
@@ -187,7 +188,6 @@ public class VfModuleTopologyOperationRequestMapper {
     public String buildObjectPath(String sdncAssignResponse) {
         String objectPath = null;
         if (sdncAssignResponse != null) {
-            ObjectMapper mapper = new ObjectMapper();
             try {
                 GenericResourceApiVfModuleResponseInformation assignResponseInfo =
                         mapper.readValue(sdncAssignResponse, GenericResourceApiVfModuleResponseInformation.class);
index 2a008e3..30af5c7 100644 (file)
@@ -21,6 +21,7 @@ import java.io.IOException;
 import java.util.Map;
 
 public class ChildServiceRequestBuilder {
+    private static final ObjectMapper mapper = new ObjectMapper();
     private final BuildingBlockExecution buildingBlockExecution;
     private Service parent;
     private Service child;
@@ -47,9 +48,8 @@ public class ChildServiceRequestBuilder {
             for (Map<String, Object> params : buildingBlockExecution.getGeneralBuildingBlock().getRequestContext()
                     .getRequestParameters().getUserParams()) {
                 if (params.containsKey(USERPARAMSERVICE)) {
-                    ObjectMapper obj = new ObjectMapper();
-                    String input = obj.writeValueAsString(params.get(USERPARAMSERVICE));
-                    parent = obj.readValue(input, Service.class);
+                    String input = mapper.writeValueAsString(params.get(USERPARAMSERVICE));
+                    parent = mapper.readValue(input, Service.class);
                     if (parent.getResources().getServices() != null) {
                         for (Service service : parent.getResources().getServices()) {
                             if (service.getInstanceName().equals(childSvcInstanceName)) {
index 3e4e2d1..0c30c5e 100755 (executable)
@@ -107,6 +107,7 @@ import org.onap.so.serviceinstancebeans.InstanceDirection;
 public class WorkflowAction {
 
     private static final Logger logger = LoggerFactory.getLogger(WorkflowAction.class);
+    private static final ObjectMapper mapper = new ObjectMapper();
 
     private static final String SERVICE_INSTANCES = "serviceInstances";
     private static final String VF_MODULES = "vfModules";
@@ -160,8 +161,7 @@ public class WorkflowAction {
         try {
             fillExecutionDefault(execution);
             final String bpmnRequest = (String) execution.getVariable(BBConstants.G_BPMN_REQUEST);
-            ServiceInstancesRequest sIRequest =
-                    new ObjectMapper().readValue(bpmnRequest, ServiceInstancesRequest.class);
+            ServiceInstancesRequest sIRequest = mapper.readValue(bpmnRequest, ServiceInstancesRequest.class);
 
             final String requestId = (String) execution.getVariable(BBConstants.G_REQUEST_ID);
 
index 22d78bb..fc38182 100644 (file)
@@ -77,6 +77,8 @@ import static org.onap.so.bpmn.infrastructure.service.composition.ServiceComposi
 @Component
 public class WorkflowActionBBTasks {
 
+    private static final Logger logger = LoggerFactory.getLogger(WorkflowActionBBTasks.class);
+    private static final ObjectMapper mapper = new ObjectMapper();
     private static final String RETRY_COUNT = "retryCount";
     private static final String FABRIC_CONFIGURATION = "FabricConfiguration";
     private static final String ADD_FABRIC_CONFIGURATION_BB = "AddFabricConfigurationBB";
@@ -91,7 +93,6 @@ public class WorkflowActionBBTasks {
     private static final String ROLLBACK_TO_ASSIGNED = "RollbackToAssigned";
     private static final String UNASSIGN = "Unassign";
     private static final String DELETE = "Delete";
-    private static final Logger logger = LoggerFactory.getLogger(WorkflowActionBBTasks.class);
 
     @Autowired
     private RequestsDbClient requestDbclient;
@@ -189,7 +190,7 @@ public class WorkflowActionBBTasks {
         requestRef.setInstanceId(resourceId);
         requestRef.setRequestId(requestId);
         serviceInstancesResponse.setRequestReferences(requestRef);
-        ObjectMapper mapper = new ObjectMapper();
+
         String jsonRequest = "";
         try {
             jsonRequest = mapper.writeValueAsString(serviceInstancesResponse);
index 466b496..85be6a3 100644 (file)
@@ -61,6 +61,7 @@ import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConst
 public class UserParamsServiceTraversal {
 
     private static final Logger logger = LoggerFactory.getLogger(UserParamsServiceTraversal.class);
+    private static final ObjectMapper mapper = new ObjectMapper();
 
     private final CatalogDbClient catalogDbClient;
     private final ExceptionBuilder exceptionBuilder;
@@ -79,9 +80,8 @@ public class UserParamsServiceTraversal {
         if (userParams != null) {
             for (Map<String, Object> params : userParams) {
                 if (params.containsKey(USER_PARAM_SERVICE)) {
-                    ObjectMapper obj = new ObjectMapper();
-                    String input = obj.writeValueAsString(params.get(USER_PARAM_SERVICE));
-                    Service validate = obj.readValue(input, Service.class);
+                    String input = mapper.writeValueAsString(params.get(USER_PARAM_SERVICE));
+                    Service validate = mapper.readValue(input, Service.class);
                     return getResourceList(execution, serviceModelVersionId, requestAction, validate);
                 }
             }
index 5e82b4f..04ee1bc 100644 (file)
@@ -29,6 +29,7 @@ public class UpgradePreWorkflowValidator implements PreWorkflowValidator {
             "Existing vnfs in AAI are not supported by service model. Unsupported vnfCustomizationIds: %s";
 
     private final CatalogDbClient catalogDbClient;
+    private static final ObjectMapper mapper = new ObjectMapper();
 
     private static final Function<WorkflowType, Predicate<Resource>> resourceType =
             workflowType -> resource -> resource.getResourceType() == workflowType;
@@ -76,7 +77,7 @@ public class UpgradePreWorkflowValidator implements PreWorkflowValidator {
 
     private Optional<ServiceInstancesRequest> parseBpmnRequest(String bpmnRequest) {
         try {
-            return Optional.of(new ObjectMapper().readValue(bpmnRequest, ServiceInstancesRequest.class));
+            return Optional.of(mapper.readValue(bpmnRequest, ServiceInstancesRequest.class));
         } catch (IOException e) {
             return Optional.empty();
         }
index 293bcf9..a7206d5 100644 (file)
@@ -7,9 +7,9 @@
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -51,7 +51,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
 
 @Component
 public class VnfAdapterObjectMapper {
-    private ObjectMapper mapper = new ObjectMapper();
+    private static final ObjectMapper mapper = new ObjectMapper();
     private static final String ENABLE_BRIDGE = "mso.bridgeEnabled";
 
     @PostConstruct
index dd9ecbe..2228da0 100644 (file)
@@ -9,9 +9,9 @@
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -50,6 +50,7 @@ public class NamingClientResponseValidator {
     private static final String NULL_RESPONSE_FROM_NAMING_SERVICE =
             "Error received a null response from Naming Service.";
     private static final String NAMING_SERVICE_ERROR = "Error from Naming Service: %s";
+    private static final ObjectMapper mapper = new ObjectMapper();
 
     public String validateNameGenResponse(ResponseEntity<NameGenResponse> response) throws BadResponseException {
         if (response == null) {
@@ -139,7 +140,6 @@ public class NamingClientResponseValidator {
     }
 
     protected String formatError(HttpStatusCodeException e) throws IOException {
-        ObjectMapper mapper = new ObjectMapper();
         NameGenResponse errorResponse = mapper.readValue(e.getResponseBodyAsString(), NameGenResponse.class);
         NameGenResponseError error = errorResponse.getError();
 
index 4aa5671..690a296 100644 (file)
@@ -38,6 +38,7 @@ import java.util.Map;
 public class SliceTaskParams implements Serializable {
 
     private static final long serialVersionUID = -4389946152970978423L;
+    private static final ObjectMapper mapper = new ObjectMapper();
 
     private String serviceId;
 
@@ -138,7 +139,6 @@ public class SliceTaskParams implements Serializable {
     }
 
     public void convertFromJson(String jsonString) throws IOException {
-        ObjectMapper mapper = new ObjectMapper();
         Map<String, String> paramMap = (Map<String, String>) mapper.readValue(jsonString, Map.class);
         this.setServiceId(paramMap.get("ServiceId"));
         this.setServiceName(paramMap.get("ServiceName"));
@@ -194,4 +194,3 @@ public class SliceTaskParams implements Serializable {
         this.setAnStatusDescription(paramMap.get("AN.statusDescription"));
     }
 }
-
index 334e0f7..b9897d9 100644 (file)
@@ -7,9 +7,9 @@
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -31,7 +31,7 @@ import com.fasterxml.jackson.databind.SerializationFeature;
 @Provider
 public class CommonObjectMapperProvider implements ContextResolver<ObjectMapper> {
 
-    protected ObjectMapper mapper;
+    protected static ObjectMapper mapper;
 
     public CommonObjectMapperProvider() {
 
index 72c5a7d..f933465 100644 (file)
@@ -7,9 +7,9 @@
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -51,7 +51,7 @@ public class PolicyClientImpl implements PolicyClient {
 
     private static Logger logger = LoggerFactory.getLogger(PolicyClientImpl.class);
     private PolicyRestProperties props;
-    private ObjectMapper mapper = new ObjectMapper();
+    private static final ObjectMapper mapper = new ObjectMapper();
 
     public PolicyClientImpl() {
         props = RestPropertiesLoader.getInstance().getNewImpl(PolicyRestProperties.class);
index 24a4ba8..0dbf36f 100644 (file)
@@ -7,9 +7,9 @@
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -34,6 +34,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
 @Priority(Integer.MIN_VALUE)
 public class AAIClientResponseExceptionMapper extends ResponseExceptionMapper {
 
+    private static final ObjectMapper mapper = new ObjectMapper();
     private final String requestId;
 
     public AAIClientResponseExceptionMapper() {
@@ -45,7 +46,7 @@ public class AAIClientResponseExceptionMapper extends ResponseExceptionMapper {
 
         String errorString = "Error calling A&AI. Request-Id=" + this.getRequestId() + " ";
         try {
-            AAIError error = new ObjectMapper().readValue(entity, AAIError.class);
+            AAIError error = mapper.readValue(entity, AAIError.class);
             AAIErrorFormatter formatter = new AAIErrorFormatter(error);
             return Optional.of(errorString + formatter.getMessage());
         } catch (IOException e) {
index 8df505e..4a56652 100644 (file)
@@ -7,9 +7,9 @@
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -45,6 +45,7 @@ import com.google.common.base.Joiner;
 public class AAISingleTransactionClient extends
         GraphInventoryTransactionClient<AAISingleTransactionClient, AAIBaseResourceUri<?, ?>, AAIResourceUri, AAIEdgeLabel> {
 
+    private static final ObjectMapper mapper = new ObjectMapper();
     private final SingleTransactionRequest request;
     private AAIResourcesClient resourcesClient;
     private AAIClient aaiClient;
@@ -58,7 +59,7 @@ public class AAISingleTransactionClient extends
 
     /*
      * (non-Javadoc)
-     * 
+     *
      * @see org.onap.aaiclient.client.aai.GraphInventoryTransactionClient#execute()
      */
     @Override
@@ -88,7 +89,6 @@ public class AAISingleTransactionClient extends
 
     @Override
     public void execute(boolean dryRun) throws BulkProcessFailed {
-        final ObjectMapper mapper = new ObjectMapper();
         if (dryRun) {
             try {
                 if (logger.isDebugEnabled()) {
@@ -104,7 +104,6 @@ public class AAISingleTransactionClient extends
 
     protected Optional<String> locateErrorMessages(SingleTransactionResponse response) {
         final List<String> errorMessages = new ArrayList<>();
-        final ObjectMapper mapper = new ObjectMapper();
 
         for (OperationBodyResponse body : response.getOperationResponses()) {
             if (Optional.ofNullable(body.getResponseStatusCode()).orElse(400) > 300) {
index 66fa503..60ec58e 100644 (file)
@@ -7,9 +7,9 @@
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -50,6 +50,7 @@ import com.google.common.base.Joiner;
 public class AAITransactionalClient extends
         GraphInventoryTransactionClient<AAITransactionalClient, AAIBaseResourceUri<?, ?>, AAIResourceUri, AAIEdgeLabel> {
 
+    private static final ObjectMapper mapper = new ObjectMapper();
     private final Transactions transactions;
     private Transaction currentTransaction;
 
@@ -72,7 +73,7 @@ public class AAITransactionalClient extends
 
     /*
      * (non-Javadoc)
-     * 
+     *
      * @see org.onap.aaiclient.client.aai.GraphInventoryTransactionalClient#beginNewTransaction()
      */
     public AAITransactionalClient beginNewTransaction() {
@@ -82,7 +83,7 @@ public class AAITransactionalClient extends
 
     /*
      * (non-Javadoc)
-     * 
+     *
      * @see org.onap.aaiclient.client.aai.GraphInventoryTransactionalClient#execute()
      */
     @Override
@@ -112,7 +113,6 @@ public class AAITransactionalClient extends
 
     @Override
     public void execute(boolean dryRun) throws BulkProcessFailed {
-        final ObjectMapper mapper = new ObjectMapper();
         if (dryRun) {
             try {
                 if (logger.isDebugEnabled()) {
@@ -129,7 +129,6 @@ public class AAITransactionalClient extends
     protected Optional<String> locateErrorMessages(String response) {
         final List<String> errorMessages = new ArrayList<>();
         final List<String> results = JsonPathUtil.getInstance().locateResultList(response, "$..body");
-        final ObjectMapper mapper = new ObjectMapper();
         if (!results.isEmpty()) {
             List<Map<String, Object>> parsed = new ArrayList<>();
             try {
index 42f5256..d7352c3 100644 (file)
@@ -7,9 +7,9 @@
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -44,6 +44,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
 
 public abstract class HttpLookupUri extends AAISimpleUri implements HttpAwareUri {
 
+    private static final ObjectMapper mapper = new ObjectMapper();
     private transient Optional<String> cachedValue = Optional.empty();
     protected final AAIObjectType aaiType;
 
@@ -85,7 +86,6 @@ public abstract class HttpLookupUri extends AAISimpleUri implements HttpAwareUri
 
     protected Optional<String> extractRelatedLink(String jsonString) throws IOException {
         Optional<String> result;
-        ObjectMapper mapper = new ObjectMapper();
 
         Results<Pathed> results = mapper.readValue(jsonString, new TypeReference<Results<Pathed>>() {});
         if (results.getResult().size() == 1) {
index fc42d9c..4f636f9 100644 (file)
@@ -24,6 +24,7 @@ import io.swagger.parser.SwaggerParser;
 public class SwaggerConverter {
 
     private final Log log;
+    private static final ObjectMapper mapper = new ObjectMapper();
 
     public SwaggerConverter(Log log) {
         this.log = log;
@@ -117,7 +118,6 @@ public class SwaggerConverter {
             }
 
         }
-        ObjectMapper mapper = new ObjectMapper();
 
         for (ObjectType item : output.values()) {
             for (String path : item.getPaths()) {
index 82077a8..292fe16 100644 (file)
@@ -7,9 +7,9 @@
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -29,6 +29,13 @@ import com.fasterxml.jackson.databind.SerializationFeature;
  */
 public class CamundaMacroRequestSerializer {
 
+    private static final ObjectMapper mapper;
+
+    static {
+        mapper = new ObjectMapper();
+        mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, true);
+    }
+
     private CamundaMacroRequestSerializer() {}
 
     public static String getJsonRequest(String requestId, String action, String serviceInstanceId)
@@ -37,8 +44,6 @@ public class CamundaMacroRequestSerializer {
         macroRequest.setAction(getCamundaInput(action));
         macroRequest.setRequestId(getCamundaInput(requestId));
         macroRequest.setServiceInstanceId(getCamundaInput(serviceInstanceId));
-        ObjectMapper mapper = new ObjectMapper();
-        mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, true);
         return mapper.writeValueAsString(macroRequest);
     }
 
index 4bbfa1d..5eefa44 100644 (file)
@@ -10,9 +10,9 @@
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -60,6 +60,13 @@ import com.fasterxml.jackson.databind.SerializationFeature;
 public class CamundaClient {
     private static Logger logger = LoggerFactory.getLogger(CamundaClient.class);
     private static final String BASIC = "Basic ";
+    private static final ObjectMapper mapper = new ObjectMapper();
+    private static final ObjectMapper wrapMapper;
+
+    static {
+        wrapMapper = new ObjectMapper();
+        wrapMapper.configure(SerializationFeature.WRAP_ROOT_VALUE, true);
+    }
 
     @Autowired
     private RestTemplate restTemplate;
@@ -151,11 +158,8 @@ public class CamundaClient {
             camundaRequest.setSvcid(svcid);
             camundaRequest.setSchema(schema);
             camundaRequest.setTimeout(timeout);
-            ObjectMapper mapper = new ObjectMapper();
 
-            mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, true);
-
-            jsonReq = mapper.writeValueAsString(camundaRequest);
+            jsonReq = wrapMapper.writeValueAsString(camundaRequest);
             logger.trace("request body is {}", jsonReq);
         } catch (Exception e) {
             logger.error("Error in APIH Wrap request", e);
@@ -248,10 +252,7 @@ public class CamundaClient {
             camundaRequest.setInstanceGroupId(instanceGroupIdInput);
             camundaRequest.setGenerateIds(generateIds);
 
-            ObjectMapper mapper = new ObjectMapper();
-            mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, true);
-
-            jsonReq = mapper.writeValueAsString(camundaRequest);
+            jsonReq = wrapMapper.writeValueAsString(camundaRequest);
             logger.trace("request body is {}", jsonReq);
         } catch (Exception e) {
             logger.error("Error in wrapVIDRequest", e);
@@ -284,7 +285,6 @@ public class CamundaClient {
     }
 
     protected BPMNFailureException createBPMNFailureException(HttpStatusCodeException e) {
-        ObjectMapper mapper = new ObjectMapper();
         String responseText = null;
         String message = null;
         try {
index 65e8b43..ee0b54e 100644 (file)
@@ -9,9 +9,9 @@
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -39,12 +39,17 @@ import com.fasterxml.jackson.databind.ObjectMapper;
 @Component
 public class ResponseHandler {
     private static Logger logger = LoggerFactory.getLogger(ResponseHandler.class);
+    private static final ObjectMapper mapper;
+
+    static {
+        mapper = new ObjectMapper();
+        mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
+    }
 
     public CamundaResponse getCamundaResponse(ResponseEntity<String> camundaResponse) throws ValidateException {
         String responseBody = camundaResponse.getBody();
         CamundaResponse response = null;
-        ObjectMapper mapper = new ObjectMapper();
-        mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
+
         try {
             response = mapper.readValue(responseBody, CamundaResponse.class);
         } catch (IOException | NullPointerException e) {
index b81ee58..e9714df 100644 (file)
@@ -7,9 +7,9 @@
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -46,6 +46,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
 public class RequestIdFilter implements ContainerRequestFilter {
 
     private static Logger logger = LoggerFactory.getLogger(RequestIdFilter.class);
+    private static final ObjectMapper mapper = new ObjectMapper();
 
     @Autowired
     private RequestsDbClient infraActiveRequestsClient;
@@ -71,7 +72,6 @@ public class RequestIdFilter implements ContainerRequestFilter {
     }
 
     protected String createRequestError(String requestId, String requestTable) {
-        ObjectMapper mapper = new ObjectMapper();
         RequestError error = new RequestError();
         ServiceException serviceException = new ServiceException();
         serviceException.setMessageId(ErrorNumbers.SVC_BAD_PARAMETER);
index 696a518..a2c7bce 100644 (file)
@@ -9,9 +9,9 @@
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -42,7 +42,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
 public class ApiExceptionMapper implements ExceptionMapper<ApiException> {
 
     private static Logger logger = LoggerFactory.getLogger(ApiExceptionMapper.class);
-
+    private static final ObjectMapper mapper = new ObjectMapper();
 
     private final JAXBContext context;
     private final Marshaller marshaller;
@@ -103,7 +103,7 @@ public class ApiExceptionMapper implements ExceptionMapper<ApiException> {
     }
 
     public ObjectMapper createObjectMapper() {
-        return new ObjectMapper();
+        return mapper;
     }
 
     public Marshaller getMarshaller() {
index 7ed6038..1f8768a 100644 (file)
@@ -9,9 +9,9 @@
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -101,6 +101,7 @@ public class E2EServiceInstances {
 
     private HashMap<String, String> instanceIdMap = new HashMap<>();
     private static final Logger logger = LoggerFactory.getLogger(E2EServiceInstances.class);
+    private static final ObjectMapper mapper = new ObjectMapper();
 
     private static final String MSO_PROP_APIHANDLER_INFRA = "MSO_PROP_APIHANDLER_INFRA";
 
@@ -128,7 +129,7 @@ public class E2EServiceInstances {
 
     /**
      * POST Requests for E2E Service create Instance on a version provided
-     * 
+     *
      * @throws ApiException
      */
 
@@ -145,7 +146,7 @@ public class E2EServiceInstances {
 
     /**
      * PUT Requests for E2E Service update Instance on a version provided
-     * 
+     *
      * @throws ApiException
      */
 
@@ -166,7 +167,7 @@ public class E2EServiceInstances {
 
     /**
      * DELETE Requests for E2E Service delete Instance on a specified version and serviceId
-     * 
+     *
      * @throws ApiException
      */
 
@@ -222,7 +223,7 @@ public class E2EServiceInstances {
 
     /**
      * Scale Requests for E2E Service scale Instance on a specified version
-     * 
+     *
      * @throws ApiException
      */
 
@@ -242,7 +243,7 @@ public class E2EServiceInstances {
 
     /**
      * GET Requests for Comparing model of service instance with target version
-     * 
+     *
      * @throws ApiException
      */
 
@@ -269,7 +270,6 @@ public class E2EServiceInstances {
 
         CompareModelsRequest e2eCompareModelReq;
 
-        ObjectMapper mapper = new ObjectMapper();
         try {
             e2eCompareModelReq = mapper.readValue(requestJSON, CompareModelsRequest.class);
 
@@ -363,7 +363,6 @@ public class E2EServiceInstances {
         // TODO should be a new one or the same service instance Id
         E2ESliceServiceActivateRequest e2eActReq;
 
-        ObjectMapper mapper = new ObjectMapper();
         try {
             e2eActReq = mapper.readValue(requestJSON, E2ESliceServiceActivateRequest.class);
 
@@ -453,7 +452,6 @@ public class E2EServiceInstances {
         // TODO should be a new one or the same service instance Id
         E2EServiceInstanceDeleteRequest e2eDelReq;
 
-        ObjectMapper mapper = new ObjectMapper();
         try {
             e2eDelReq = mapper.readValue(requestJSON, E2EServiceInstanceDeleteRequest.class);
 
@@ -542,7 +540,6 @@ public class E2EServiceInstances {
         E2EServiceInstanceRequest e2eSir;
         String serviceId = instanceIdMap.get(SERVICE_ID);
 
-        ObjectMapper mapper = new ObjectMapper();
         try {
             e2eSir = mapper.readValue(requestJSON, E2EServiceInstanceRequest.class);
 
@@ -620,7 +617,7 @@ public class E2EServiceInstances {
         E2EServiceInstanceRequest e2eSir;
 
         MsoRequest msoRequest = new MsoRequest();
-        ObjectMapper mapper = new ObjectMapper();
+
         try {
             e2eSir = mapper.readValue(requestJSON, E2EServiceInstanceRequest.class);
 
@@ -695,7 +692,6 @@ public class E2EServiceInstances {
         String requestId = UUID.randomUUID().toString();
         E2EServiceInstanceScaleRequest e2eScaleReq;
 
-        ObjectMapper mapper = new ObjectMapper();
         try {
             e2eScaleReq = mapper.readValue(requestJSON, E2EServiceInstanceScaleRequest.class);
 
@@ -806,7 +802,7 @@ public class E2EServiceInstances {
 
     /**
      * Getting recipes from catalogDb
-     * 
+     *
      * @param serviceModelUUID the service model version uuid
      * @param action the action for the service
      * @return the service recipe result
@@ -826,7 +822,7 @@ public class E2EServiceInstances {
 
     /**
      * Getting recipes from catalogDb If Service recipe is not set, use default recipe, if set , use special recipe.
-     * 
+     *
      * @param serviceModelUUID the service version uuid
      * @param action the action of the service.
      * @return the service recipe result.
@@ -859,7 +855,7 @@ public class E2EServiceInstances {
 
     /**
      * Converting E2EServiceInstanceRequest to ServiceInstanceRequest and passing it to camunda engine.
-     * 
+     *
      * @param e2eSir
      * @return
      */
@@ -967,7 +963,6 @@ public class E2EServiceInstances {
     private String convertToString(ServiceInstancesRequest sir) {
         String returnString = null;
         // converting to string
-        ObjectMapper mapper = new ObjectMapper();
         try {
             returnString = mapper.writeValueAsString(sir);
         } catch (IOException e) {
index 605e2a8..4a4f8d8 100644 (file)
@@ -88,6 +88,7 @@ public class ManagedObject3gppServiceInstances {
     private static final String SAVE_TO_DB = "save instance to db";
 
     private static final String URI_PREFIX = "/moi/api/rest/";
+    private static final ObjectMapper mapper = new ObjectMapper();
 
     @Autowired
     private MsoRequest msoRequest;
@@ -233,7 +234,6 @@ public class ManagedObject3gppServiceInstances {
 
             attributes.setSliceProfileList(sliceProfileList);
             mOIResponse.setAttributes(attributes);
-            ObjectMapper mapper = new ObjectMapper();
             try {
                 response = mapper.writeValueAsString(mOIResponse);
             } catch (Exception exception) {
@@ -310,7 +310,7 @@ public class ManagedObject3gppServiceInstances {
         ServiceInstancesRequest sir = createServiceInstanceRequest(request, requestId);
         String requestDetails = null;
         try {
-            requestDetails = new ObjectMapper().writeValueAsString(sir);
+            requestDetails = mapper.writeValueAsString(sir);
             LOGGER.debug(">>> sir: {}", sir);
         } catch (JsonProcessingException e) {
             e.printStackTrace();
@@ -496,7 +496,6 @@ public class ManagedObject3gppServiceInstances {
     }
 
     Function<Object, String> toString = serviceRequest -> {
-        ObjectMapper mapper = new ObjectMapper();
         String requestAsString = null;
         try {
             requestAsString = mapper.writeValueAsString(serviceRequest);
index b01bbec..7c90052 100644 (file)
@@ -10,9 +10,9 @@
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -68,6 +68,13 @@ import io.swagger.v3.oas.annotations.responses.ApiResponse;
 @Component
 public class ManualTasks {
     private static Logger logger = LoggerFactory.getLogger(ManualTasks.class);
+    private static final ObjectMapper mapper = new ObjectMapper();
+    private static final ObjectMapper wrapMapper;
+
+    static {
+        wrapMapper = new ObjectMapper();
+        wrapMapper.configure(SerializationFeature.WRAP_ROOT_VALUE, true);
+    }
 
 
     @org.springframework.beans.factory.annotation.Value("${mso.camunda.rest.task.uri}")
@@ -99,7 +106,6 @@ public class ManualTasks {
         String apiVersion = version.substring(1);
 
         try {
-            ObjectMapper mapper = new ObjectMapper();
             taskRequest = mapper.readValue(request, TasksRequest.class);
 
             if (taskRequest.getRequestDetails() == null) {
@@ -155,9 +161,7 @@ public class ManualTasks {
 
         String camundaJsonReq;
         try {
-            ObjectMapper mapper = new ObjectMapper();
-            mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, true);
-            camundaJsonReq = mapper.writeValueAsString(variablesForComplete);
+            camundaJsonReq = wrapMapper.writeValueAsString(variablesForComplete);
         } catch (JsonProcessingException e) {
             logger.error("Mapping of JSON object to Camunda request failed");
             ValidateException validateException =
@@ -177,9 +181,7 @@ public class ManualTasks {
         trr.setTaskId(taskId);
         String completeResp = null;
         try {
-            ObjectMapper mapper = new ObjectMapper();
-            mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, true);
-            completeResp = mapper.writeValueAsString(trr);
+            completeResp = wrapMapper.writeValueAsString(trr);
         } catch (JsonProcessingException e) {
             logger.error("Unable to map response from Camunda");
             ValidateException validateException =
index af507c6..7e5bb56 100644 (file)
@@ -101,6 +101,15 @@ import com.fasterxml.jackson.databind.ObjectMapper;
 
 @Component
 public class MsoRequest {
+    private static Logger logger = LoggerFactory.getLogger(MsoRequest.class);
+    private static final ObjectMapper mapper = new ObjectMapper();
+    private static final ObjectMapper nonNullMapper;
+
+    static {
+        nonNullMapper = new ObjectMapper();
+        nonNullMapper.setSerializationInclusion(Include.NON_NULL);
+
+    }
 
     @Autowired
     private RequestsDbClient requestsDbClient;
@@ -114,7 +123,6 @@ public class MsoRequest {
     @Value("${mso.enforceDLP:false}")
     private boolean enforceDLP;
 
-    private static Logger logger = LoggerFactory.getLogger(MsoRequest.class);
 
     public Response buildServiceErrorResponse(int httpResponseCode, MsoException exceptionType, String errorText,
             String messageId, List<String> variables, String version) {
@@ -196,9 +204,8 @@ public class MsoRequest {
         if (reqVersion >= 7 && requestParameters != null && requestParameters.getUserParams() != null) {
             for (Map<String, Object> params : requestParameters.getUserParams()) {
                 if (params.containsKey("service")) {
-                    ObjectMapper obj = new ObjectMapper();
-                    String input = obj.writeValueAsString(params.get("service"));
-                    Service validate = obj.readValue(input, Service.class);
+                    String input = mapper.writeValueAsString(params.get("service"));
+                    Service validate = mapper.readValue(input, Service.class);
                     info.setUserParams(validate);
                     rules.add(new UserParamsValidation());
                     break;
@@ -585,11 +592,9 @@ public class MsoRequest {
 
     public String getRequestJSON(ServiceInstancesRequest sir)
             throws JsonGenerationException, JsonMappingException, IOException {
-        ObjectMapper mapper = new ObjectMapper();
-        mapper.setSerializationInclusion(Include.NON_NULL);
 
         logger.debug("building sir from object {}", sir);
-        String requestJSON = mapper.writeValueAsString(sir);
+        String requestJSON = nonNullMapper.writeValueAsString(sir);
 
         // Perform mapping from VID-style modelInfo fields to ASDC-style modelInfo fields
 
index a25a140..96019ea 100644 (file)
@@ -98,7 +98,7 @@ import org.onap.so.db.request.client.RequestsDbClient;
 public class Onap3gppServiceInstances {
 
     private static final Logger logger = LoggerFactory.getLogger(Onap3gppServiceInstances.class);
-
+    private static final ObjectMapper mapper = new ObjectMapper();
     private static final String MSO_PROP_APIHANDLER_INFRA = "MSO_PROP_APIHANDLER_INFRA";
 
     private static final String END_OF_THE_TRANSACTION = "End of the transaction, the final response is: ";
@@ -591,7 +591,6 @@ public class Onap3gppServiceInstances {
     }
 
     private Response getSubnetCapabilities(List<SubnetTypes> subnetTypes, String version) throws ApiException {
-        ObjectMapper oMapper = new ObjectMapper();
         String inputFileString = "";
         Map<String, Object> subnetCapability = new HashMap<>();
         BufferedReader br = null;
@@ -606,7 +605,7 @@ public class Onap3gppServiceInstances {
                 line = br.readLine();
             }
             inputFileString = sb.toString();
-            subnetCapability = oMapper.readValue(inputFileString, Map.class);
+            subnetCapability = mapper.readValue(inputFileString, Map.class);
         } catch (Exception e) {
             logger.debug("Exception while reading subnet capability value from json", e);
         }
@@ -618,7 +617,7 @@ public class Onap3gppServiceInstances {
         }
         String response = null;
         try {
-            response = oMapper.writeValueAsString(responseMap);
+            response = mapper.writeValueAsString(responseMap);
         } catch (JsonProcessingException e) {
             logger.debug("Exception while converting subnet capability object to String {}", e);
         }
@@ -680,7 +679,6 @@ public class Onap3gppServiceInstances {
     }
 
     Function<Object, String> toString = serviceRequest -> {
-        ObjectMapper mapper = new ObjectMapper();
         String requestAsString = null;
         try {
             requestAsString = mapper.writeValueAsString(serviceRequest);
@@ -772,5 +770,3 @@ public class Onap3gppServiceInstances {
                 parameter.getApiVersion());
     }
 }
-
-
index 8c919f0..dff68cc 100644 (file)
@@ -94,6 +94,7 @@ public class OrchestrationRequests {
 
     private static Logger logger = LoggerFactory.getLogger(OrchestrationRequests.class);
     private static final String ERROR_MESSAGE_PREFIX = "Error Source: %s, Error Message: %s";
+    private static final ObjectMapper mapper = new ObjectMapper();
 
     @Autowired
     private RequestsDbClient requestsDbClient;
@@ -243,7 +244,6 @@ public class OrchestrationRequests {
         ServiceInstancesRequest sir;
 
         try {
-            ObjectMapper mapper = new ObjectMapper();
             sir = mapper.readValue(requestJSON, ServiceInstancesRequest.class);
         } catch (IOException e) {
             logger.error("Exception occurred", e);
@@ -300,8 +300,6 @@ public class OrchestrationRequests {
         String requestBody = iar.getRequestBody();
         Request request = new Request();
 
-        ObjectMapper mapper = new ObjectMapper();
-
         request.setRequestId(iar.getRequestId());
         request.setRequestScope(iar.getRequestScope());
         request.setRequestType(iar.getRequestAction());
index 836f08a..ba9b3ad 100644 (file)
@@ -72,7 +72,7 @@ public class OrchestrationTasks {
     @Autowired
     private ResponseBuilder builder;
 
-    private ObjectMapper mapper = new ObjectMapper();
+    private static final ObjectMapper mapper = new ObjectMapper();
 
     @GET
     @Path("/{version:[vV][4-7]}/")
index 4338e61..583a684 100644 (file)
@@ -106,6 +106,13 @@ import com.fasterxml.jackson.databind.ObjectMapper;
 public class RequestHandlerUtils extends AbstractRestHandler {
 
     private static Logger logger = LoggerFactory.getLogger(RequestHandlerUtils.class);
+    private static final ObjectMapper mapper = new ObjectMapper();
+    private static final ObjectMapper nonNullMapper;
+
+    static {
+        nonNullMapper = new ObjectMapper();
+        nonNullMapper.setSerializationInclusion(Include.NON_NULL);
+    }
 
     protected static final String SAVE_TO_DB = "save instance to db";
     private static final String NAME = "name";
@@ -144,7 +151,6 @@ public class RequestHandlerUtils extends AbstractRestHandler {
 
     public Response postBPELRequest(InfraActiveRequests currentActiveReq, RequestClientParameter requestClientParameter,
             String orchestrationUri, String requestScope) throws ApiException {
-        ObjectMapper mapper = new ObjectMapper();
         ResponseEntity<String> response = postRequest(currentActiveReq, requestClientParameter, orchestrationUri);
         ServiceInstancesResponse jsonResponse = null;
         int bpelStatus = responseHandler.setStatus(response.getStatusCodeValue());
@@ -314,7 +320,6 @@ public class RequestHandlerUtils extends AbstractRestHandler {
     public ServiceInstancesRequest convertJsonToServiceInstanceRequest(String requestJSON, Actions action,
             String requestId, String requestUri) throws ApiException {
         try {
-            ObjectMapper mapper = new ObjectMapper();
             return mapper.readValue(requestJSON, ServiceInstancesRequest.class);
 
         } catch (IOException e) {
@@ -450,10 +455,8 @@ public class RequestHandlerUtils extends AbstractRestHandler {
 
     public String mapJSONtoMSOStyle(String msoRawRequest, ServiceInstancesRequest serviceInstRequest,
             boolean isAlaCarte, Actions action) throws IOException {
-        ObjectMapper mapper = new ObjectMapper();
-        mapper.setSerializationInclusion(Include.NON_NULL);
         if (serviceInstRequest != null) {
-            return mapper.writeValueAsString(serviceInstRequest);
+            return nonNullMapper.writeValueAsString(serviceInstRequest);
         } else {
             return msoRawRequest;
         }
@@ -833,9 +836,8 @@ public class RequestHandlerUtils extends AbstractRestHandler {
     }
 
     private Service serviceMapper(Map<String, Object> params) throws IOException {
-        ObjectMapper obj = new ObjectMapper();
-        String input = obj.writeValueAsString(params.get("service"));
-        return obj.readValue(input, Service.class);
+        String input = mapper.writeValueAsString(params.get("service"));
+        return mapper.readValue(input, Service.class);
     }
 
     private void addUserParams(Map<String, Object> targetUserParams, List<Map<String, String>> sourceUserParams) {
index be63c5f..3c84be3 100644 (file)
@@ -97,6 +97,7 @@ import java.util.function.Function;
 public class ServiceIntentApiHandler {
 
     private static final Logger logger = LoggerFactory.getLogger(ServiceIntentApiHandler.class);
+    private static final ObjectMapper mapper = new ObjectMapper();
 
     private static final String MSO_PROP_APIHANDLER_INFRA = "MSO_PROP_APIHANDLER_INFRA";
 
@@ -351,7 +352,6 @@ public class ServiceIntentApiHandler {
     }
 
     Function<Object, String> toString = serviceRequest -> {
-        ObjectMapper mapper = new ObjectMapper();
         String requestAsString = null;
         try {
             requestAsString = mapper.writeValueAsString(serviceRequest);
index dadb7c7..6464aca 100644 (file)
@@ -9,9 +9,9 @@
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -72,6 +72,7 @@ public class TasksHandler {
 
 
     private static Logger logger = LoggerFactory.getLogger(TasksHandler.class);
+    private static final ObjectMapper mapper = new ObjectMapper();
 
     @Value("${mso.camunda.rest.task.uri}")
     private String requestUrl;
@@ -153,7 +154,6 @@ public class TasksHandler {
         String camundaJsonReq = null;
 
         try {
-            ObjectMapper mapper = new ObjectMapper();
             camundaJsonReq = mapper.writeValueAsString(tv);
         } catch (JsonProcessingException e) {
             ErrorLoggerInfo errorLoggerInfo =
@@ -201,7 +201,6 @@ public class TasksHandler {
 
         String jsonResponse = null;
         try {
-            ObjectMapper mapper = new ObjectMapper();
             jsonResponse = mapper.writeValueAsString(trr);
         } catch (JsonProcessingException e) {
             ErrorLoggerInfo errorLoggerInfo =
index 0f7cf5f..4bd7163 100644 (file)
@@ -63,6 +63,8 @@ import java.util.stream.Collectors;
 @Component
 public class WorkflowSpecificationsHandler {
 
+    private static final ObjectMapper mapper = new ObjectMapper();
+
     @Autowired
     private ResponseBuilder builder;
 
@@ -145,9 +147,6 @@ public class WorkflowSpecificationsHandler {
         final String pnf_resource = "pnf";
         String apiVersion = version.substring(1);
 
-        ObjectMapper mapper = new ObjectMapper();
-        mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
-
         List<Workflow> workflows = queryWorkflowsForResourceTarget(pnf_resource);
 
         Optional<String> optional = getResponseByWorkflowSpec(workflows);
@@ -179,7 +178,6 @@ public class WorkflowSpecificationsHandler {
         WorkflowSpecifications workflowSpecifications = mapWorkflowsToWorkflowSpecifications(workflows);
 
         try {
-            ObjectMapper mapper = new ObjectMapper();
             return Optional.of(mapper.writeValueAsString(workflowSpecifications));
         } catch (JsonProcessingException e) {
             catchAndThrowValidationEx(e);
index edf17f3..b1e50b5 100644 (file)
@@ -7,9 +7,9 @@
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -71,7 +71,7 @@ public class BpmnRequestBuilder {
     @Autowired
     private AAIDataRetrieval aaiDataRet;
 
-    private ObjectMapper mapper = new ObjectMapper();
+    private static final ObjectMapper mapper = new ObjectMapper();
 
 
     public ServiceInstancesRequest buildVFModuleDeleteRequest(String vnfId, String vfModuleId, ModelType modelType)
index a6d2fa2..42d4a17 100644 (file)
@@ -7,9 +7,9 @@
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -45,6 +45,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
 public class NetworkRestHandler extends AbstractRestHandler {
 
     private static final Logger logger = LoggerFactory.getLogger(NetworkRestHandler.class);
+    private static final ObjectMapper mapper = new ObjectMapper();
 
     public InfraActiveRequests mapInfraActiveRequestForDelete(String requestId, String serviceInstanceId,
             String networkId, String requestorId, String source, String requestURL) {
@@ -75,7 +76,6 @@ public class NetworkRestHandler extends AbstractRestHandler {
 
     public RequestClientParameter buildRequestParams(ServiceInstancesRequest request, String requestURI,
             String requestId, String serviceInstanceId, String networkId) throws JsonProcessingException {
-        ObjectMapper mapper = new ObjectMapper();
         return new RequestClientParameter.Builder().setRequestId(requestId).setServiceInstanceId(serviceInstanceId)
                 .setNetworkId(networkId).setALaCarte(true).setRequestDetails(mapper.writeValueAsString(request))
                 .setRequestAction(Action.deleteInstance.toString()).setRequestUri(requestURI).setApiVersion("v8")
index 36e7b7c..d918fd0 100644 (file)
@@ -7,9 +7,9 @@
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -45,9 +45,10 @@ import com.fasterxml.jackson.databind.ObjectMapper;
 @Component
 public class ServiceInstanceRestHandler extends AbstractRestHandler {
 
+    private static final Logger logger = LoggerFactory.getLogger(ServiceInstanceRestHandler.class);
+    private static final ObjectMapper mapper = new ObjectMapper();
     private static final String DEFAULT_VF_MODULE_UUID = "d88da85c-d9e8-4f73-b837-3a72a431622b";
 
-    private static final Logger logger = LoggerFactory.getLogger(ServiceInstanceRestHandler.class);
 
     public InfraActiveRequests mapInfraActiveRequestForDelete(String requestId, String serviceInstanceId,
             String requestorId, String source, String requestURL) {
@@ -77,7 +78,6 @@ public class ServiceInstanceRestHandler extends AbstractRestHandler {
 
     public RequestClientParameter buildRequestParams(ServiceInstancesRequest request, String requestURI,
             String requestId, String serviceInstanceId) throws JsonProcessingException {
-        ObjectMapper mapper = new ObjectMapper();
         return new RequestClientParameter.Builder().setRequestId(requestId).setServiceInstanceId(serviceInstanceId)
                 .setALaCarte(true).setRequestDetails(mapper.writeValueAsString(request))
                 .setRequestAction(Action.deleteInstance.toString()).setRequestUri(requestURI).setApiVersion("v8")
index 380649a..543a1d1 100644 (file)
@@ -7,9 +7,9 @@
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -45,6 +45,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
 public class VFModuleRestHandler extends AbstractRestHandler {
 
     private static final Logger logger = LoggerFactory.getLogger(VFModuleRestHandler.class);
+    private static final ObjectMapper mapper = new ObjectMapper();
 
     public InfraActiveRequests mapInfraActiveRequestForDelete(String requestId, String vfModuleId,
             String serviceInstanceId, String vnfId, String requestorId, String source, String requestURL) {
@@ -78,7 +79,6 @@ public class VFModuleRestHandler extends AbstractRestHandler {
     public RequestClientParameter buildRequestParams(ServiceInstancesRequest request, String requestURI,
             String requestId, String serviceInstanceId, String vnfId, String vfModuleId)
             throws JsonProcessingException {
-        ObjectMapper mapper = new ObjectMapper();
         return new RequestClientParameter.Builder().setRequestId(requestId).setServiceInstanceId(serviceInstanceId)
                 .setVnfId(vnfId).setVfModuleId(vfModuleId).setALaCarte(true)
                 .setRequestDetails(mapper.writeValueAsString(request))
index c11ae56..a5c16c7 100644 (file)
@@ -8,9 +8,9 @@
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -45,6 +45,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
 public class VnfRestHandler extends AbstractRestHandler {
 
     private static final Logger logger = LoggerFactory.getLogger(VnfRestHandler.class);
+    private static final ObjectMapper mapper = new ObjectMapper();
 
     public InfraActiveRequests mapInfraActiveRequestForDelete(String requestId, String serviceInstanceId, String vnfId,
             String requestorId, String source, String requestURL) {
@@ -75,7 +76,6 @@ public class VnfRestHandler extends AbstractRestHandler {
 
     public RequestClientParameter buildRequestParams(ServiceInstancesRequest request, String requestURI,
             String requestId, String serviceInstanceId, String vnfId) throws JsonProcessingException {
-        ObjectMapper mapper = new ObjectMapper();
         return new RequestClientParameter.Builder().setRequestId(requestId).setServiceInstanceId(serviceInstanceId)
                 .setVnfId(vnfId).setALaCarte(true).setRequestDetails(mapper.writeValueAsString(request))
                 .setRequestAction(Action.deleteInstance.toString()).setRequestUri(requestURI).setApiVersion("v8")
index 15aa71f..c5a15cb 100644 (file)
@@ -7,9 +7,9 @@
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -42,6 +42,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
 public class VolumeRestHandler extends AbstractRestHandler {
 
     private static final Logger logger = LoggerFactory.getLogger(VolumeRestHandler.class);
+    private static final ObjectMapper mapper = new ObjectMapper();
 
     public InfraActiveRequests mapInfraActiveRequestForDelete(String requestId, String volumeGroupId,
             String serviceInstanceId, String vnfId, String requestorId, String source, String requestURL) {
@@ -74,7 +75,6 @@ public class VolumeRestHandler extends AbstractRestHandler {
     public RequestClientParameter buildRequestParams(ServiceInstancesRequest request, String requestURI,
             String requestId, String serviceInstanceId, String vnfId, String volumeGroupId)
             throws JsonProcessingException {
-        ObjectMapper mapper = new ObjectMapper();
         return new RequestClientParameter.Builder().setRequestId(requestId).setServiceInstanceId(serviceInstanceId)
                 .setVnfId(vnfId).setVolumeGroupId(volumeGroupId).setALaCarte(true)
                 .setRequestDetails(mapper.writeValueAsString(request))
index bb2b89c..674ff3c 100644 (file)
@@ -76,6 +76,7 @@ import io.swagger.v3.oas.annotations.responses.ApiResponse;
 public class CloudOrchestration {
 
     private static Logger logger = LoggerFactory.getLogger(CloudOrchestration.class);
+    private static final ObjectMapper mapper = new ObjectMapper();
     private static final String ENVIRONMENT_ID_KEY = "operationalEnvironmentId";
 
     @Autowired
@@ -241,7 +242,6 @@ public class CloudOrchestration {
             long startTime, CloudOrchestrationRequest cor) throws ApiException {
         try {
             logger.debug("Converting incoming JSON request to Object");
-            ObjectMapper mapper = new ObjectMapper();
             return mapper.readValue(requestJSON, CloudOrchestrationRequest.class);
         } catch (IOException e) {
 
index 59c0694..74741fb 100644 (file)
@@ -9,9 +9,9 @@
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -77,6 +77,7 @@ import io.swagger.v3.oas.annotations.responses.ApiResponse;
 public class CloudResourcesOrchestration {
 
     private static Logger logger = LoggerFactory.getLogger(CloudResourcesOrchestration.class);
+    private static final ObjectMapper mapper = new ObjectMapper();
 
     @Autowired
     RequestsDbClient requestDbClient;
@@ -100,7 +101,6 @@ public class CloudResourcesOrchestration {
         logger.debug("requestId is: {}", requestId);
 
         try {
-            ObjectMapper mapper = new ObjectMapper();
             cor = mapper.readValue(requestJSON, CloudOrchestrationRequest.class);
         } catch (IOException e) {
             ErrorLoggerInfo errorLoggerInfo =
@@ -275,7 +275,6 @@ public class CloudResourcesOrchestration {
 
         if (requestBody != null) {
             try {
-                ObjectMapper mapper = new ObjectMapper();
                 requestDetails = mapper.readValue(requestBody, RequestDetails.class);
             } catch (IOException e) {
                 ErrorLoggerInfo errorLoggerInfo =
index e116353..98eabb9 100644 (file)
@@ -9,9 +9,9 @@
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -70,6 +70,8 @@ import io.swagger.v3.oas.annotations.responses.ApiResponse;
 public class ModelDistributionRequest {
 
     private static Logger logger = LoggerFactory.getLogger(ModelDistributionRequest.class);
+    private static final ObjectMapper mapper = new ObjectMapper();
+
     @Autowired
     private Provider<TenantIsolationRunnable> tenantIsolationRunnable;
 
@@ -85,7 +87,6 @@ public class ModelDistributionRequest {
         Distribution distributionRequest;
 
         try {
-            ObjectMapper mapper = new ObjectMapper();
             distributionRequest = mapper.readValue(requestJSON, Distribution.class);
         } catch (IOException e) {
             ErrorLoggerInfo errorLoggerInfo =
index b1eb71e..a71ce1d 100644 (file)
@@ -9,9 +9,9 @@
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -58,6 +58,8 @@ import com.fasterxml.jackson.databind.ObjectMapper;
 @Scope("prototype")
 public class TenantIsolationRequest {
 
+    private static final ObjectMapper mapper = new ObjectMapper();
+
     private String requestId;
     private String requestJSON;
     private RequestInfo requestInfo;
@@ -88,9 +90,7 @@ public class TenantIsolationRequest {
         this.requestInfo = request.getRequestDetails().getRequestInfo();
 
         try {
-            ObjectMapper mapper = new ObjectMapper();
             requestJSON = mapper.writeValueAsString(request.getRequestDetails());
-
         } catch (JsonProcessingException e) {
             logger.error("Exception in JSON processing", e);
             throw new ValidationException("Parse ServiceInstanceRequest to JSON string", true);
@@ -238,7 +238,6 @@ public class TenantIsolationRequest {
         this.cor = cor;
 
         try {
-            ObjectMapper mapper = new ObjectMapper();
             requestJSON = mapper.writeValueAsString(cor.getRequestDetails());
 
         } catch (JsonProcessingException e) {
index 2df0a1f..cd58bbb 100644 (file)
@@ -7,9 +7,9 @@
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -37,6 +37,8 @@ import com.fasterxml.jackson.databind.ObjectMapper;
 @Component
 public class DmaapOperationalEnvClient {
 
+    private static final ObjectMapper mapper = new ObjectMapper();
+
     @Autowired
     private Provider<OperationalEnvironmentPublisher> dmaapPublisher;
 
@@ -64,8 +66,6 @@ public class DmaapOperationalEnvClient {
     }
 
     protected String getJson(CreateEcompOperationEnvironmentBean obj) throws JsonProcessingException {
-
-        final ObjectMapper mapper = new ObjectMapper();
         return mapper.writeValueAsString(obj);
 
     }
index 23537a7..c527b9e 100644 (file)
@@ -9,9 +9,9 @@
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -58,6 +58,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
 public class CreateVnfOperationalEnvironment {
 
     private static Logger logger = LoggerFactory.getLogger(CreateVnfOperationalEnvironment.class);
+    private static final ObjectMapper mapper = new ObjectMapper();
     protected CloudOrchestrationRequest request;
 
     @Autowired
@@ -71,7 +72,6 @@ public class CreateVnfOperationalEnvironment {
     public void execute(String requestId, CloudOrchestrationRequest request) throws ApiException {
         try {
             setRequest(request);
-            ObjectMapper objectMapper = new ObjectMapper();
             AAIResultWrapper aaiResultWrapper = aaiHelper.getAaiOperationalEnvironment(getEcompManagingEnvironmentId());
             if (aaiResultWrapper.isEmpty()) {
                 throw new NotFoundException(getEcompManagingEnvironmentId() + " not found in A&AI");
@@ -83,7 +83,7 @@ public class CreateVnfOperationalEnvironment {
             String searchKey = getSearchKey(aaiEnv);
             String tenantContext = getTenantContext().toUpperCase();
             String jsonResponse = getGrmClient().findRunningServicesAsString(searchKey, 1, tenantContext);
-            ServiceEndPointList sel = objectMapper.readValue(jsonResponse, ServiceEndPointList.class);
+            ServiceEndPointList sel = mapper.readValue(jsonResponse, ServiceEndPointList.class);
             if (sel.getServiceEndPointList().size() == 0) {
                 throw new TenantIsolationException(
                         "GRM did not find any matches for " + searchKey + " in " + tenantContext);