From: Fiete Ostkamp Date: Wed, 25 Jun 2025 09:11:25 +0000 (+0200) Subject: Statically register ObjectMapper on class level since it is expensive to instantiate X-Git-Tag: 1.15.6~6 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=e6af7201086287d41e235f399f4a1bce677309f5;p=so.git Statically register ObjectMapper on class level since it is expensive to instantiate - ObjectMapper objects are expensive to instantiate - register them statically on the class level instead of instantiating them for each invocation - improve formatting in some of the groovy classes - change some logger.debug statements to be lazily executed [0] [0] that is, they are not executed when the log level is higher than debug (log.debug(" " + expensiveOperation) vs. log.debug(" {}", expensiveOperation)) Issue-ID: SO-4187 Change-Id: I708c221ff90efb0a27020119253faa549c2ee2fe Signed-off-by: Fiete Ostkamp --- diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoCommonUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoCommonUtils.java index 6800428a62..19ffee456f 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoCommonUtils.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoCommonUtils.java @@ -68,6 +68,7 @@ import com.woorea.openstack.quantum.model.NeutronError; public class MsoCommonUtils { private static Logger logger = LoggerFactory.getLogger(MsoCommonUtils.class); + private static final ObjectMapper mapper = new ObjectMapper(); /** The Constant TOKEN_AUTH. */ protected static final String TOKEN_AUTH = "TokenAuth"; @@ -339,7 +340,7 @@ public class MsoCommonUtils { int timeoutMinutes, String environment, Map files, Map heatFiles) { // force entire stackInput object to generic Map for openstack compatibility - ObjectMapper mapper = new ObjectMapper(); + Map normalized = new HashMap<>(); try { normalized = mapper.readValue(mapper.writeValueAsString(stackInputs), diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java index ba4b30903d..fe060703cc 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java @@ -391,12 +391,11 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin { protected void saveStackRequest(CreateStackParam request, String requestId, String stackName) { try { - ObjectMapper mapper = new ObjectMapper(); InfraActiveRequests foundRequest = requestDBClient.getInfraActiveRequestbyRequestId(requestId); CreateStackRequest createStackRequest = new CreateStackRequest(); createStackRequest.setEnvironment(request.getEnvironment()); createStackRequest.setParameters(request.getParameters()); - String stackRequest = mapper.writeValueAsString(createStackRequest); + String stackRequest = JSON_MAPPER.writeValueAsString(createStackRequest); CloudApiRequests cloudReq = new CloudApiRequests(); cloudReq.setCloudIdentifier(stackName); cloudReq.setRequestBody(stackRequest); diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtilsWithUpdate.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtilsWithUpdate.java index f001565baf..2e7f423453 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtilsWithUpdate.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtilsWithUpdate.java @@ -23,7 +23,6 @@ package org.onap.so.openstack.utils; - import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; @@ -152,10 +151,9 @@ public class MsoHeatUtilsWithUpdate extends MsoHeatUtils { logger.debug("Ready to Update Stack ({}) with input params: {}", canonicalName, stackInputs); // force entire stackInput object to generic Map for openstack compatibility - ObjectMapper mapper = new ObjectMapper(); Map normalized = new HashMap<>(); try { - normalized = mapper.readValue(mapper.writeValueAsString(stackInputs), + normalized = JSON_MAPPER.readValue(JSON_MAPPER.writeValueAsString(stackInputs), new TypeReference>() {}); } catch (IOException e1) { logger.debug("could not map json", e1); diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java index 743abc0177..14f20cab18 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java @@ -767,7 +767,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin { scanner.close(); try { - return new ObjectMapper().readerFor(MulticloudCreateResponse.class).readValue(body); + return JSON_MAPPER.readerFor(MulticloudCreateResponse.class).readValue(body); } catch (Exception e) { logger.debug("Exception retrieving multicloud vfModule POST response body ", e); } @@ -784,7 +784,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin { scanner.close(); try { - return new ObjectMapper().readerFor(MulticloudQueryResponse.class).readValue(body); + return JSON_MAPPER.readerFor(MulticloudQueryResponse.class).readValue(body); } catch (Exception e) { logger.debug("Exception retrieving multicloud workload query response body ", e); } diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/NovaClientImpl.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/NovaClientImpl.java index dc276d9b8f..faae841c42 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/NovaClientImpl.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/NovaClientImpl.java @@ -46,6 +46,7 @@ import com.woorea.openstack.nova.model.VolumeAttachment; @Component public class NovaClientImpl extends MsoCommonUtils { + private static final ObjectMapper mapper = new ObjectMapper(); /** The logger. */ private static final Logger logger = LoggerFactory.getLogger(NovaClientImpl.class); @@ -56,7 +57,7 @@ public class NovaClientImpl extends MsoCommonUtils { /** * Query Networks * - * + * * @param cloudSiteId the cloud site id * @param tenantId the tenant id * @param limit limits the number of records returned @@ -84,7 +85,7 @@ public class NovaClientImpl extends MsoCommonUtils { /** * Query Networks * - * + * * @param cloudSiteId the cloud site id * @param tenantId the tenant id * @param id of the network @@ -107,7 +108,7 @@ public class NovaClientImpl extends MsoCommonUtils { /** * Query Host Aggregates * - * + * * @param cloudSiteId the cloud site id * @param tenantId the tenant id * @param limit limits the number of records returned @@ -132,7 +133,7 @@ public class NovaClientImpl extends MsoCommonUtils { /** * Query Host Aggregate * - * + * * @param cloudSiteId the cloud site id * @param tenantId the tenant id * @param limit limits the number of records returned @@ -156,7 +157,7 @@ public class NovaClientImpl extends MsoCommonUtils { /** * Query OS Quota Set * - * + * * @param cloudSiteId the cloud site id * @param tenantId the tenant id * @param limit limits the number of records returned @@ -180,7 +181,7 @@ public class NovaClientImpl extends MsoCommonUtils { /** * Deletes a keypair inside openstack * - * + * * @param cloudSiteId the cloud site id * @param tenantId the tenant id * @param keyPairName name of the keypair to be deleted @@ -212,7 +213,7 @@ public class NovaClientImpl extends MsoCommonUtils { public void postActionToServer(String cloudSiteId, String tenantId, String id, String request) throws IOException, MsoException { - ObjectMapper mapper = new ObjectMapper(); + JsonNode actualObj = mapper.readTree(request); Entity openstackEntity = new Entity<>(actualObj, "application/json"); CharSequence actionPath = "/servers/" + id + "/action"; diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/nwrest/NetworkRequestCommon.java b/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/nwrest/NetworkRequestCommon.java index 3629b3fda7..2a6be02f5b 100644 --- a/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/nwrest/NetworkRequestCommon.java +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/nwrest/NetworkRequestCommon.java @@ -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. @@ -41,12 +41,20 @@ import org.slf4j.LoggerFactory; public abstract class NetworkRequestCommon implements Serializable { private static final long serialVersionUID = -6732431343649282079L; private static final Logger logger = LoggerFactory.getLogger(NetworkRequestCommon.class); + private static final ObjectMapper mapper; + private Boolean skipAAI = false; private String messageId; private String notificationUrl; + @JsonProperty private boolean synchronous = true; + static { + mapper = new ObjectMapper(); + mapper.enable(SerializationFeature.WRAP_ROOT_VALUE); + } + public Boolean getSkipAAI() { return skipAAI; } @@ -84,8 +92,7 @@ public abstract class NetworkRequestCommon implements Serializable { public String toJsonString() { String jsonString = null; try { - ObjectMapper mapper = new ObjectMapper(); - mapper.enable(SerializationFeature.WRAP_ROOT_VALUE); + jsonString = mapper.writeValueAsString(this); } catch (Exception e) { logger.debug("Exception:", e); diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/nwrest/NetworkResponseCommon.java b/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/nwrest/NetworkResponseCommon.java index 54eccb34e4..e8d5a60ecd 100644 --- a/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/nwrest/NetworkResponseCommon.java +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/nwrest/NetworkResponseCommon.java @@ -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,8 +39,14 @@ import org.slf4j.LoggerFactory; public abstract class NetworkResponseCommon implements Serializable { private static final long serialVersionUID = 1233520856935129726L; - private String messageId; private static final Logger logger = LoggerFactory.getLogger(NetworkResponseCommon.class); + private static final ObjectMapper mapper; + + static { + mapper = new ObjectMapper(); + mapper.enable(SerializationFeature.WRAP_ROOT_VALUE); + } + private String messageId; public NetworkResponseCommon() { messageId = null; @@ -61,8 +67,6 @@ public abstract class NetworkResponseCommon implements Serializable { public String toJsonString() { String jsonString = null; try { - ObjectMapper mapper = new ObjectMapper(); - mapper.enable(SerializationFeature.WRAP_ROOT_VALUE); jsonString = mapper.writeValueAsString(this); } catch (Exception e) { logger.debug("Exception:", e); diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/sdncrest/SDNCEvent.java b/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/sdncrest/SDNCEvent.java index b79102857b..ca04842b53 100644 --- a/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/sdncrest/SDNCEvent.java +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/sdncrest/SDNCEvent.java @@ -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. @@ -54,6 +54,13 @@ public class SDNCEvent implements Serializable { private static final long serialVersionUID = 1L; private static final Logger logger = LoggerFactory.getLogger(SDNCEvent.class); + private static final ObjectMapper mapper; + + static { + mapper = new ObjectMapper(); + mapper.enable(SerializationFeature.WRAP_ROOT_VALUE); + mapper.setSerializationInclusion(Include.NON_NULL); + } // Event type private String eventType; @@ -128,9 +135,6 @@ public class SDNCEvent implements Serializable { public String toJson() { try { - ObjectMapper mapper = new ObjectMapper(); - mapper.enable(SerializationFeature.WRAP_ROOT_VALUE); - mapper.setSerializationInclusion(Include.NON_NULL); return mapper.writeValueAsString(this); } catch (IOException e) { logger.debug("Exception:", e); diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/sdncrest/SDNCRequestCommon.java b/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/sdncrest/SDNCRequestCommon.java index 60e1ce088c..def2d6390c 100644 --- a/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/sdncrest/SDNCRequestCommon.java +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/sdncrest/SDNCRequestCommon.java @@ -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. @@ -40,6 +40,13 @@ public abstract class SDNCRequestCommon implements Serializable { private static final long serialVersionUID = 1L; private static final Logger logger = LoggerFactory.getLogger(SDNCRequestCommon.class); + private static final ObjectMapper mapper; + + static { + mapper = new ObjectMapper(); + mapper.enable(SerializationFeature.WRAP_ROOT_VALUE); + mapper.setSerializationInclusion(Include.NON_NULL); + } // Endpoint on which BPMN can receive notifications from the SDNC adapter. private String bpNotificationUrl; @@ -100,9 +107,6 @@ public abstract class SDNCRequestCommon implements Serializable { public String toJson() { try { - ObjectMapper mapper = new ObjectMapper(); - mapper.enable(SerializationFeature.WRAP_ROOT_VALUE); - mapper.setSerializationInclusion(Include.NON_NULL); return mapper.writeValueAsString(this); } catch (IOException e) { logger.debug("Exception:", e); diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/sdncrest/SDNCResponseCommon.java b/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/sdncrest/SDNCResponseCommon.java index 5851493fea..b72481c873 100644 --- a/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/sdncrest/SDNCResponseCommon.java +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/sdncrest/SDNCResponseCommon.java @@ -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. @@ -36,9 +36,16 @@ import org.slf4j.LoggerFactory; * Base class for all SDNC adapter responses, including errors. */ public abstract class SDNCResponseCommon implements Serializable { + private static final Logger logger = LoggerFactory.getLogger(SDNCResponseCommon.class); private static final long serialVersionUID = 1L; + private static final ObjectMapper mapper; + + static { + mapper = new ObjectMapper(); + mapper.enable(SerializationFeature.WRAP_ROOT_VALUE); + mapper.setSerializationInclusion(Include.NON_NULL); + } - private static final Logger logger = LoggerFactory.getLogger(SDNCResponseCommon.class); // Identifies the MSO transaction with SDNC. private String sdncRequestId; @@ -109,9 +116,6 @@ public abstract class SDNCResponseCommon implements Serializable { public String toJson() { try { - ObjectMapper mapper = new ObjectMapper(); - mapper.enable(SerializationFeature.WRAP_ROOT_VALUE); - mapper.setSerializationInclusion(Include.NON_NULL); return mapper.writeValueAsString(this); } catch (IOException e) { logger.debug("Exception:", e); diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/tenantrest/TenantRequestCommon.java b/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/tenantrest/TenantRequestCommon.java index f35149d1db..3c443c8115 100644 --- a/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/tenantrest/TenantRequestCommon.java +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/tenantrest/TenantRequestCommon.java @@ -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. @@ -35,13 +35,17 @@ import org.slf4j.LoggerFactory; public abstract class TenantRequestCommon implements Serializable { private static final long serialVersionUID = 1486834308868170854L; - private static Logger logger = LoggerFactory.getLogger(TenantRequestCommon.class); + private static final Logger logger = LoggerFactory.getLogger(TenantRequestCommon.class); + private static final ObjectMapper mapper; + + static { + mapper = new ObjectMapper(); + mapper.enable(SerializationFeature.WRAP_ROOT_VALUE); + } public String toJsonString() { try { String jsonString; - ObjectMapper mapper = new ObjectMapper(); - mapper.enable(SerializationFeature.WRAP_ROOT_VALUE); jsonString = mapper.writeValueAsString(this); return jsonString; } catch (Exception e) { diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/vnfrest/VfResponseCommon.java b/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/vnfrest/VfResponseCommon.java index 7a2d4ec3e1..8b2709f5ed 100644 --- a/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/vnfrest/VfResponseCommon.java +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/vnfrest/VfResponseCommon.java @@ -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,6 +39,13 @@ import org.slf4j.LoggerFactory; */ public abstract class VfResponseCommon { private static final Logger logger = LoggerFactory.getLogger(VfResponseCommon.class); + private static final ObjectMapper mapper; + + static { + mapper = new ObjectMapper(); + mapper.enable(SerializationFeature.WRAP_ROOT_VALUE); + } + private String messageId; public VfResponseCommon() { @@ -60,8 +67,6 @@ public abstract class VfResponseCommon { public String toJsonString() { try { String jsonString; - ObjectMapper mapper = new ObjectMapper(); - mapper.enable(SerializationFeature.WRAP_ROOT_VALUE); jsonString = mapper.writeValueAsString(this); return jsonString; } catch (Exception e) { diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/openstack/mappers/MapElements.java b/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/openstack/mappers/MapElements.java index 3dd339dc68..30f0fccc84 100644 --- a/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/openstack/mappers/MapElements.java +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/openstack/mappers/MapElements.java @@ -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. @@ -32,6 +32,8 @@ import com.fasterxml.jackson.databind.ObjectMapper; public class MapElements { private static final Logger logger = LoggerFactory.getLogger(MapElements.class); + private static final ObjectMapper mapper = new ObjectMapper(); + @XmlElement public String key; @XmlElement @@ -48,7 +50,7 @@ public class MapElements { if (value != null) { if (value instanceof List || value instanceof Map) { try { - this.value = new ObjectMapper().writeValueAsString(value); + this.value = mapper.writeValueAsString(value); } catch (JsonProcessingException e) { logger.warn("could not marshal value to json, calling toString", e); this.value = value.toString(); diff --git a/adapters/mso-catalog-db-adapter/src/main/java/db/migration/R__CloudConfigMigration.java b/adapters/mso-catalog-db-adapter/src/main/java/db/migration/R__CloudConfigMigration.java index 86cfa6ee0c..70b0da7e25 100644 --- a/adapters/mso-catalog-db-adapter/src/main/java/db/migration/R__CloudConfigMigration.java +++ b/adapters/mso-catalog-db-adapter/src/main/java/db/migration/R__CloudConfigMigration.java @@ -50,9 +50,10 @@ import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; */ @JsonIgnoreProperties(ignoreUnknown = true) public class R__CloudConfigMigration extends BaseJavaMigration { + private static final Logger logger = LoggerFactory.getLogger(R__CloudConfigMigration.class); + private static final ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); public static final String FLYWAY = "FLYWAY"; - private static final Logger logger = LoggerFactory.getLogger(R__CloudConfigMigration.class); @JsonProperty("cloud_config") private CloudConfig cloudConfig; @@ -105,7 +106,6 @@ public class R__CloudConfigMigration extends BaseJavaMigration { } private CloudConfig loadCloudConfig(InputStream stream) throws IOException { - ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); R__CloudConfigMigration cloudConfigMigration = mapper.readValue(stream, R__CloudConfigMigration.class); CloudConfig cloudConfiguration = cloudConfigMigration.getCloudConfig(); @@ -242,4 +242,3 @@ public class R__CloudConfigMigration extends BaseJavaMigration { } } - diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogQuery.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogQuery.java index e8e3f34f28..8746c6ff12 100644 --- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogQuery.java +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogQuery.java @@ -22,7 +22,6 @@ package org.onap.so.adapters.catalogdb.catalogrest; import com.fasterxml.jackson.databind.ObjectMapper; -import org.apache.commons.lang3.StringEscapeUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.IOException; @@ -32,6 +31,7 @@ import java.util.regex.Pattern; public abstract class CatalogQuery { protected static Logger logger = LoggerFactory.getLogger(CatalogQuery.class); + private static final ObjectMapper mapper = new ObjectMapper(); private static final boolean IS_EMBED = true; public abstract String JSON2(boolean isArray, boolean isEmbed); @@ -72,7 +72,6 @@ public abstract class CatalogQuery { protected String smartToJSON() { String jsonString = null; try { - ObjectMapper mapper = new ObjectMapper(); jsonString = mapper.writeValueAsString(this); } catch (Exception e) { logger.error("Error converting to JSON", e); @@ -103,7 +102,6 @@ public abstract class CatalogQuery { if (jsonInString == null) { return false; } - ObjectMapper mapper = new ObjectMapper(); mapper.readTree(jsonInString); return true; } catch (IOException e) { diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogQueryExceptionCommon.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogQueryExceptionCommon.java index 324ac073a8..6d6b8a9e8d 100644 --- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogQueryExceptionCommon.java +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogQueryExceptionCommon.java @@ -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. @@ -32,8 +32,14 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; public abstract class CatalogQueryExceptionCommon { - private String messageId; protected static Logger logger = LoggerFactory.getLogger(CatalogQueryExceptionCommon.class); + private static final ObjectMapper mapper; + private String messageId; + + static { + mapper = new ObjectMapper(); + mapper.enable(SerializationFeature.WRAP_ROOT_VALUE); + } public CatalogQueryExceptionCommon() { messageId = null; @@ -54,8 +60,6 @@ public abstract class CatalogQueryExceptionCommon { public String toJsonString() { try { String jsonString; - ObjectMapper mapper = new ObjectMapper(); - mapper.enable(SerializationFeature.WRAP_ROOT_VALUE); jsonString = mapper.writeValueAsString(this); return jsonString; } catch (Exception e) { diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryResourceRecipe.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryResourceRecipe.java index ee52abe047..a4c5178390 100644 --- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryResourceRecipe.java +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryResourceRecipe.java @@ -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. @@ -33,12 +33,18 @@ import com.fasterxml.jackson.databind.SerializationFeature; * serivce csar query support
*

*

- * + * * @author * @version ONAP Beijing Release 2018-02-28 */ public class QueryResourceRecipe extends CatalogQuery { protected static Logger logger = LoggerFactory.getLogger(QueryResourceRecipe.class); + private static final ObjectMapper mapper; + + static { + mapper = new ObjectMapper(); + mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, false); + } private Recipe resourceRecipe; @@ -70,8 +76,6 @@ public class QueryResourceRecipe extends CatalogQuery { valueMap.put("description", null == resourceRecipe || null == resourceRecipe.getDescription() ? StringUtils.EMPTY : resourceRecipe.getDescription()); - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, false); String jsonStr = ""; try { jsonStr = mapper.writeValueAsString(valueMap); diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java index cb6a2fac1f..af06542356 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java @@ -99,6 +99,7 @@ public class MsoNetworkAdapterImpl { private static final String NETWORK_DELETED_STATUS_MESSAGE = "The network was successfully deleted in the cloud"; private static final Logger logger = LoggerFactory.getLogger(MsoNetworkAdapterImpl.class); + private static final ObjectMapper mapper = new ObjectMapper(); @Autowired private CloudConfig cloudConfig; @@ -835,7 +836,6 @@ public class MsoNetworkAdapterImpl { JsonNode node = null; try { - ObjectMapper mapper = new ObjectMapper(); node = mapper.convertValue(prlist, JsonNode.class); String jsonString = mapper.writeValueAsString(prlist); logger.debug("Json PolicyRefs Data:{}", jsonString); @@ -912,7 +912,6 @@ public class MsoNetworkAdapterImpl { JsonNode node = null; try { - ObjectMapper mapper = new ObjectMapper(); node = mapper.convertValue(cslist, JsonNode.class); String jsonString = mapper.writeValueAsString(cslist); logger.debug("Json Subnet List:{}", jsonString); @@ -1032,7 +1031,6 @@ public class MsoNetworkAdapterImpl { try { Object obj = outputs.get(key); - ObjectMapper mapper = new ObjectMapper(); String jStr = mapper.writeValueAsString(obj); logger.debug("Subnet_Ipam Output JSON String:{} {}", obj.getClass(), jStr); diff --git a/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/ApplicationControllerSupport.java b/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/ApplicationControllerSupport.java index 90ab24cb86..b94a6b68ee 100644 --- a/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/ApplicationControllerSupport.java +++ b/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/ApplicationControllerSupport.java @@ -37,6 +37,7 @@ import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectWriter; +import com.fasterxml.jackson.databind.SerializationFeature; @Component @@ -52,8 +53,16 @@ public class ApplicationControllerSupport { private static final int PARTIAL_FAILURE_STATUS = PARTIAL_SERIES + 1; private static Logger logger = LoggerFactory.getLogger(ApplicationControllerSupport.class); + private static final ObjectMapper objectMapper; + private static final ObjectWriter writer; private String lcmModelPackage = "org.onap.appc.client.lcm.model"; + static { + objectMapper = new ObjectMapper(); + objectMapper.setSerializationInclusion(Include.NON_NULL); + writer = objectMapper.writerWithDefaultPrettyPrinter(); + } + /** * @param action * @return @@ -186,9 +195,6 @@ public class ApplicationControllerSupport { public void logLCMMessage(Object message) { - ObjectMapper objectMapper = new ObjectMapper(); - objectMapper.setSerializationInclusion(Include.NON_NULL); - ObjectWriter writer = objectMapper.writerWithDefaultPrettyPrinter(); String inputAsJSON; try { inputAsJSON = writer.writeValueAsString(message); diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/activity/ActivitySpecsActions.java b/asdc-controller/src/main/java/org/onap/so/asdc/activity/ActivitySpecsActions.java index a48e1770f0..d3362397e8 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/activity/ActivitySpecsActions.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/activity/ActivitySpecsActions.java @@ -38,6 +38,7 @@ import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; import java.net.URL; @Component @@ -46,6 +47,12 @@ public class ActivitySpecsActions { private static final String ACTIVITY_SPEC_URI = "/v1.0/activity-spec"; private static final String ACTIVITY_SPEC_URI_SUFFIX = "/versions/latest/actions"; private static final String CERTIFY_ACTIVITY_PAYLOAD = "{\"action\": \"CERTIFY\"}"; + private static final ObjectMapper mapper; + + static { + mapper = new ObjectMapper(); + mapper.setSerializationInclusion(Include.NON_NULL); + } private final HttpClientFactory httpClientFactory = new HttpClientFactory(); protected static final Logger logger = LoggerFactory.getLogger(ActivitySpecsActions.class); @@ -56,8 +63,6 @@ public class ActivitySpecsActions { } try { - ObjectMapper mapper = new ObjectMapper(); - mapper.setSerializationInclusion(Include.NON_NULL); String payload = mapper.writer().writeValueAsString(activitySpec); String urlString = UriBuilder.fromUri(hostname).path(ACTIVITY_SPEC_URI).build().toString(); diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java b/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java index 8e3c5f4b7d..a64931777e 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java @@ -87,16 +87,24 @@ import org.springframework.stereotype.Component; public class ASDCController { protected static final Logger logger = LoggerFactory.getLogger(ASDCController.class); - - private static final String UNKNOWN = "Unknown"; - + protected static final String MSO = "SO"; protected boolean isAsdcClientAutoManaged = false; - protected String controllerName; + protected int nbOfNotificationsOngoing = 0; + private static final String UNKNOWN = "Unknown"; + private static final String UUID_PARAM = "(UUID:"; + private static final ObjectMapper mapper; private ASDCControllerStatus controllerStatus = ASDCControllerStatus.STOPPED; - protected int nbOfNotificationsOngoing = 0; + static { + mapper = new ObjectMapper(); + mapper.setSerializationInclusion(Include.NON_NULL); + mapper.setSerializationInclusion(Include.NON_EMPTY); + mapper.setSerializationInclusion(Include.NON_ABSENT); + mapper.enable(MapperFeature.USE_ANNOTATIONS); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + } @Autowired private ToscaResourceInstaller toscaInstaller; @@ -118,9 +126,6 @@ public class ASDCController { private IDistributionClient distributionClient; - private static final String UUID_PARAM = "(UUID:"; - - protected static final String MSO = "SO"; @Autowired private WatchdogDistribution wd; @@ -588,12 +593,6 @@ public class ASDCController { } private Optional getNotificationJson(INotificationData iNotif) { - ObjectMapper mapper = new ObjectMapper(); - mapper.setSerializationInclusion(Include.NON_NULL); - mapper.setSerializationInclusion(Include.NON_EMPTY); - mapper.setSerializationInclusion(Include.NON_ABSENT); - mapper.enable(MapperFeature.USE_ANNOTATIONS); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); Optional returnValue = Optional.empty(); try { returnValue = Optional.of(mapper.writeValueAsString(iNotif)); diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/JsonStatusData.java b/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/JsonStatusData.java index 34f21ab813..30f6a8c578 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/JsonStatusData.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/JsonStatusData.java @@ -36,7 +36,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; public class JsonStatusData implements IStatusData { @JsonIgnore - private static ObjectMapper mapper = new ObjectMapper(); + private static final ObjectMapper mapper = new ObjectMapper(); @JsonIgnore private Map attributesMap = new HashMap<>(); diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/VfResourceStructure.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/VfResourceStructure.java index 8fe01caa46..a9aa19e2a2 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/VfResourceStructure.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/VfResourceStructure.java @@ -59,6 +59,7 @@ import org.slf4j.LoggerFactory; public class VfResourceStructure extends ResourceStructure { protected static final Logger logger = LoggerFactory.getLogger(VfResourceStructure.class); + private static final ObjectMapper mapper = new ObjectMapper(); /** * The list of VfModules defined for this resource. @@ -205,7 +206,7 @@ public class VfResourceStructure extends ResourceStructure { public List decodeVfModuleArtifact(byte[] arg0) { try { - return new ObjectMapper().readValue(arg0, new TypeReference>() {}); + return mapper.readValue(arg0, new TypeReference>() {}); } catch (JsonParseException e) { logger.debug("JsonParseException : ", e); diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java index bc4434a70a..180be2cdf2 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java @@ -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. @@ -157,40 +157,24 @@ import com.fasterxml.jackson.databind.ObjectMapper; public class ToscaResourceInstaller { protected static final String NODES_VRF_ENTRY = "org.openecomp.nodes.VRFEntry"; - protected static final String VLAN_NETWORK_RECEPTOR = "org.openecomp.nodes.VLANNetworkReceptor"; - protected static final String ALLOTTED_RESOURCE = "Allotted Resource"; - protected static final String MULTI_STAGE_DESIGN = "multi_stage_design"; - protected static final String SCALABLE = "scalable"; - protected static final String BASIC = "BASIC"; - protected static final String PROVIDER = "PROVIDER"; - protected static final String HEAT = "HEAT"; - protected static final String MANUAL_RECORD = "MANUAL_RECORD"; - protected static final String MSO = "SO"; - protected static final String SDNC_MODEL_NAME = "sdnc_model_name"; - protected static final String SDNC_MODEL_VERSION = "sdnc_model_version"; - private static String CUSTOMIZATION_UUID = "customizationUUID"; - protected static final String SKIP_POST_INST_CONF = "skip_post_instantiation_configuration"; - private static final String CONTROLLER_ACTOR = "controller_actor"; - private static final String CDS_MODEL_NAME = "cds_model_name"; - private static final String CDS_MODEL_VERSION = "cds_model_version"; - private static final String DEFAULT_SOFTWARE_VERSION = "default_software_version"; + private static final ObjectMapper mapper = new ObjectMapper(); @Autowired protected ServiceRepository serviceRepo; @@ -645,8 +629,7 @@ public class ToscaResourceInstaller { } try { - ObjectMapper objectMapper = new ObjectMapper(); - String jsonStr = objectMapper.writeValueAsString(resouceRequest); + String jsonStr = mapper.writeValueAsString(resouceRequest); jsonStr = jsonStr.replace("\"", "\\\""); logger.debug("resource request for resource customization id {}: {}", resourceCustomizationUuid, jsonStr); @@ -2079,8 +2062,7 @@ public class ToscaResourceInstaller { String jsonStr = null; try { - ObjectMapper objectMapper = new ObjectMapper(); - jsonStr = objectMapper.writeValueAsString(resouceRequest); + jsonStr = mapper.writeValueAsString(resouceRequest); jsonStr = jsonStr.replace("\"", "\\\""); logger.debug("vfcResource request for resource customization id {}: {}", resourceCustomizationUuid, jsonStr); @@ -2956,9 +2938,8 @@ public class ToscaResourceInstaller { serviceInputList.add(serviceInputMap); }); - ObjectMapper objectMapper = new ObjectMapper(); try { - serviceInput = objectMapper.writeValueAsString(serviceInputList); + serviceInput = mapper.writeValueAsString(serviceInputList); serviceInput = serviceInput.replace("\"", "\\\""); } catch (JsonProcessingException e) { logger.error("service input could not be deserialized for service uuid: " @@ -3026,7 +3007,6 @@ public class ToscaResourceInstaller { private String getServiceProperties(ToscaResourceStructure toscaResourceStruct) { String propertiesJson = null; - ObjectMapper objectMapper = new ObjectMapper(); ISdcCsarHelper helper = toscaResourceStruct.getSdcCsarHelper(); String typeName = helper.getServiceSubstitutionMappingsTypeName(); Optional nodeTemplate = helper.getServiceNodeTemplates().stream().findAny(); @@ -3037,7 +3017,7 @@ public class ToscaResourceInstaller { List serviceProperties = getPropertiesFromCustomDef(customDef, typeName); try { - propertiesJson = objectMapper.writeValueAsString(serviceProperties); + propertiesJson = mapper.writeValueAsString(serviceProperties); propertiesJson = propertiesJson.replace("\"", "\\\""); } catch (JsonProcessingException e) { logger.error("serviceProperties could not be deserialized for service uuid: " + serviceUUID); @@ -3093,4 +3073,3 @@ public class ToscaResourceInstaller { return serviceProperties; } } - diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/DoHandleOofRequest.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/DoHandleOofRequest.groovy index b457bdca46..c65d640740 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/DoHandleOofRequest.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/DoHandleOofRequest.groovy @@ -38,10 +38,11 @@ import static org.onap.so.bpmn.common.scripts.GenericUtils.* class DoHandleOofRequest extends AbstractServiceTaskProcessor { - + ExceptionUtil exceptionUtil = new ExceptionUtil() JsonUtils jsonUtil = new JsonUtils() private static final Logger logger = LoggerFactory.getLogger(DoHandleOofRequest.class) + private static final ObjectMapper mapper = new ObjectMapper() @Override public void preProcessRequest(DelegateExecution execution) { @@ -50,21 +51,21 @@ class DoHandleOofRequest extends AbstractServiceTaskProcessor { if (isBlank(apiPath)) { String msg = "Cannot process OOF adapter call : API PATH is null" exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } - + } + //msoRequestId is used for correlation String requestId = execution.getVariable("correlator") if (isBlank(requestId)) { String msg = "Cannot process OOF adapter call : correlator is null" exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) } - + String messageType = execution.getVariable("messageType") if (isBlank(messageType)) { String msg = "Cannot process OOF adapter call : messageType is null" exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) } - + String timeout = execution.getVariable("timeout") if (isBlank(timeout)) { timeout = UrnPropertiesReader.getVariable("mso.adapters.oof.timeout", execution); @@ -73,16 +74,15 @@ class DoHandleOofRequest extends AbstractServiceTaskProcessor { timeout = "PT30M" } } - + Object requestDetails = execution.getVariable("oofRequest") OofRequest oofRequestPayload = new OofRequest() oofRequestPayload.setApiPath(apiPath) oofRequestPayload.setRequestDetails(requestDetails) - ObjectMapper objectMapper = new ObjectMapper() - String requestJson = objectMapper.writeValueAsString(oofRequestPayload) + String requestJson = mapper.writeValueAsString(oofRequestPayload) execution.setVariable("oofRequestPayload", requestJson) } - + void callOofAdapter(DelegateExecution execution) { logger.debug("Start callOofAdapter") String requestId = execution.getVariable("msoRequestId") @@ -99,5 +99,5 @@ class DoHandleOofRequest extends AbstractServiceTaskProcessor { exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from OOF.") } } - + } diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy index 0e6cb64751..fdf7cf6917 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy @@ -55,6 +55,7 @@ import com.fasterxml.jackson.databind.ObjectMapper class OofUtils { private static final Logger logger = LoggerFactory.getLogger( OofUtils.class); + private static final ObjectMapper mapper = new ObjectMapper() ExceptionUtil exceptionUtil = new ExceptionUtil() JsonUtils jsonUtil = new JsonUtils() @@ -529,8 +530,7 @@ class OofUtils { logger.debug( "transactionId is: " + transactionId) String correlator = requestId String callbackUrl = UrnPropertiesReader.getVariable("mso.adapters.oof.callback.endpoint") + "/" + messageType + "/" + correlator - ObjectMapper objectMapper = new ObjectMapper() - String json = objectMapper.writeValueAsString(profileInfo) + String json = mapper.writeValueAsString(profileInfo) StringBuilder response = new StringBuilder() response.append( "{\n" + @@ -552,8 +552,7 @@ class OofUtils { logger.debug( "transactionId is: " + transactionId) String correlator = requestId String callbackUrl = UrnPropertiesReader.getVariable("mso.adapters.oof.callback.endpoint") + "/" + messageType + "/" + correlator - ObjectMapper objectMapper = new ObjectMapper() - String json = objectMapper.writeValueAsString(profileInfo) + String json = mapper.writeValueAsString(profileInfo) StringBuilder response = new StringBuilder() response.append( "{\n" + @@ -577,8 +576,7 @@ class OofUtils { logger.debug( "transactionId is: " + transactionId) String correlator = requestId String callbackUrl = UrnPropertiesReader.getVariable("mso.adapters.oof.callback.endpoint") + "/" + messageType + "/" + correlator - ObjectMapper objectMapper = new ObjectMapper(); - String json = objectMapper.writeValueAsString(profileInfo); + String json = mapper.writeValueAsString(profileInfo); StringBuilder response = new StringBuilder(); response.append( "{\n" + @@ -618,8 +616,7 @@ def transactionId = requestId logger.debug( "transactionId is: " + transactionId) String correlator = requestId String callbackUrl = UrnPropertiesReader.getVariable("mso.adapters.oof.callback.endpoint") + "/" + messageType + "/" + correlator -ObjectMapper objectMapper = new ObjectMapper(); -String profileJson = objectMapper.writeValueAsString(profileInfo); +String profileJson = mapper.writeValueAsString(profileInfo); JsonParser parser = new JsonParser() //Prepare requestInfo object @@ -663,7 +660,7 @@ String callbackUrl = UrnPropertiesReader.getVariable("mso.adapters.oof.callback. JsonObject json = new JsonObject() json.addProperty("type", nxlType) json.addProperty("NxIId", nxlId) - + //Prepare requestInfo object JsonObject requestInfo = new JsonObject() requestInfo.addProperty("transactionId", transactionId) @@ -671,16 +668,16 @@ requestInfo.addProperty("requestId", requestId) requestInfo.addProperty("callbackUrl", callbackUrl) requestInfo.addProperty("sourceId","SO" ) requestInfo.addProperty("timeout", 600) - + //Prepare addtnlArgs object JsonObject addtnlArgs = new JsonObject() addtnlArgs.addProperty("serviceInstanceId", serviceInstanceId) - + requestInfo.add("addtnlArgs", addtnlArgs) json.add("requestInfo", requestInfo) - + return json.toString() - + } public String buildSelectNSIRequest(String requestId, TemplateInfo nstInfo, List nsstInfo, diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/recipe/ResourceInput.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/recipe/ResourceInput.java index 91049a8d0c..bef022a481 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/recipe/ResourceInput.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/recipe/ResourceInput.java @@ -36,7 +36,7 @@ import org.slf4j.LoggerFactory; * the inputs for the resource recipe
*

*

- * + * * @author * @version ONAP Beijing Release 2018-03-08 */ @@ -47,6 +47,12 @@ import org.slf4j.LoggerFactory; public class ResourceInput implements Serializable { private static Logger logger = LoggerFactory.getLogger(ResourceInput.class); + private static final ObjectMapper mapper; + + static { + mapper = new ObjectMapper(); + mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, false); + } @JsonProperty("resourceInstanceName") private String resourceInstanceName; @@ -330,8 +336,6 @@ public class ResourceInput implements Serializable { @Override public String toString() { - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, false); String jsonStr = ""; try { jsonStr = mapper.writeValueAsString(this); diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/recipe/ResourceRecipeRequest.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/recipe/ResourceRecipeRequest.java index 729793893b..d344e87cf1 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/recipe/ResourceRecipeRequest.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/recipe/ResourceRecipeRequest.java @@ -40,6 +40,12 @@ import org.slf4j.LoggerFactory; public class ResourceRecipeRequest { private static Logger logger = LoggerFactory.getLogger(ResourceRecipeRequest.class); + private static final ObjectMapper mapper; + + static { + mapper = new ObjectMapper(); + mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, true); + } @JsonProperty("resourceInput") private BpmnParam resourceInput; @@ -147,8 +153,6 @@ public class ResourceRecipeRequest { @Override public String toString() { - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, true); String jsonStr = "ResourceRecipeRequest"; try { jsonStr = mapper.writeValueAsString(this); diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilder.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilder.java index 8efb6a3e1c..25047079a9 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilder.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilder.java @@ -58,6 +58,16 @@ public class ResourceRequestBuilder { private static String SERVICE_URL_SERVICE_INSTANCE = "/v2/serviceResources"; private static Logger logger = LoggerFactory.getLogger(ResourceRequestBuilder.class); + private static final ObjectMapper mapper = new ObjectMapper(); + private static final ObjectMapper mapperWithWrap; + private static final ObjectMapper mapperWithOutWrap; + + static { + mapperWithWrap = new ObjectMapper(); + mapperWithWrap.configure(SerializationFeature.WRAP_ROOT_VALUE, true); + mapperWithOutWrap = new ObjectMapper(); + mapperWithOutWrap.configure(SerializationFeature.WRAP_ROOT_VALUE, false); + } static JsonUtils jsonUtil = new JsonUtils(); @@ -392,16 +402,13 @@ public class ResourceRequestBuilder { String value = apiResponse.readEntity(String.class); - ObjectMapper objectMapper = new ObjectMapper(); - HashMap map = objectMapper.readValue(value, HashMap.class); + HashMap map = mapper.readValue(value, HashMap.class); return map; } public static T getJsonObject(String jsonstr, Class type) { - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, true); try { - return mapper.readValue(jsonstr, type); + return mapperWithWrap.readValue(jsonstr, type); } catch (IOException e) { logger.error("fail to unMarshal json {}", e.getMessage()); } @@ -409,11 +416,9 @@ public class ResourceRequestBuilder { } 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 = mapperWithOutWrap.writeValueAsString(srcObj); } catch (JsonProcessingException e) { logger.error("SdcToscaParserException", e); } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/generalobjects/RequestParameters.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/generalobjects/RequestParameters.java index ca3f73a176..6eca5312c5 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/generalobjects/RequestParameters.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/generalobjects/RequestParameters.java @@ -40,6 +40,12 @@ import org.slf4j.LoggerFactory; public class RequestParameters implements Serializable { private static final Logger logger = LoggerFactory.getLogger(RequestParameters.class); + private static final ObjectMapper mapper; + + static { + mapper = new ObjectMapper(); + mapper.setSerializationInclusion(Include.NON_NULL); + } private static final long serialVersionUID = -5979049912538894930L; @JsonProperty("subscriptionServiceType") @@ -120,8 +126,6 @@ public class RequestParameters implements Serializable { @JsonInclude(Include.NON_NULL) public String toJsonString() { String json = ""; - ObjectMapper mapper = new ObjectMapper(); - mapper.setSerializationInclusion(Include.NON_NULL); ObjectWriter ow = mapper.writer(); try { json = ow.writeValueAsString(this); diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java index b38bd25c66..02cfddfb01 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java @@ -145,7 +145,7 @@ public class BBInputSetup implements JavaDelegate { @Autowired private ExceptionBuilder exceptionUtil; - private ObjectMapper mapper = new ObjectMapper(); + private static final ObjectMapper mapper = new ObjectMapper(); public BBInputSetupUtils getBbInputSetupUtils() { return bbInputSetupUtils; @@ -197,9 +197,7 @@ public class BBInputSetup implements JavaDelegate { execution.setVariable("homing", false); } - ObjectMapper mapper = new ObjectMapper(); - mapper.enable(SerializationFeature.INDENT_OUTPUT); - logger.debug("GeneralBB: " + mapper.writeValueAsString(outputBB)); + logger.debug("GeneralBB: {}", mapper.writeValueAsString(outputBB)); setHomingFlag(outputBB, homing, lookupKeyMap); @@ -2320,9 +2318,8 @@ public class BBInputSetup implements JavaDelegate { } private org.onap.so.serviceinstancebeans.Service serviceMapper(Map params) throws IOException { - ObjectMapper obj = new ObjectMapper(); - String input = obj.writeValueAsString(params.get("service")); - return obj.readValue(input, org.onap.so.serviceinstancebeans.Service.class); + String input = mapper.writeValueAsString(params.get("service")); + return mapper.readValue(input, org.onap.so.serviceinstancebeans.Service.class); } private void setisHelmforHealthCheckBB(Service service, ServiceInstance serviceInstance, GeneralBuildingBlock gBB) { diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtils.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtils.java index 45361f81c6..a21cd5ad58 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtils.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtils.java @@ -92,6 +92,17 @@ public class BBInputSetupUtils { private static final String DATA_LOAD_ERROR = "Could not process loading data from database"; private static final String DATA_PARSE_ERROR = "Could not parse data"; private static final String PROCESSING_DATA_NAME_EXECUTION_FLOWS = "flowExecutionPath"; + private static final ObjectMapper mapper; + private static final ObjectMapper mapperRootValue; + + static { + mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + mapperRootValue = new ObjectMapper(); + mapperRootValue.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + mapperRootValue.configure(SerializationFeature.WRAP_ROOT_VALUE, true); + mapperRootValue.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true); + } @Autowired protected CatalogDbClient catalogDbClient; @@ -156,10 +167,9 @@ public class BBInputSetupUtils { if (requestId != null) { List flows = new ArrayList<>(); - ObjectMapper om = new ObjectMapper(); try { for (ExecuteBuildingBlock ebb : flowsToExecute) { - flows.add(om.writeValueAsString(ebb)); + flows.add(mapper.writeValueAsString(ebb)); } } catch (JsonProcessingException e) { logger.error(DATA_PARSE_ERROR, e); @@ -189,10 +199,8 @@ public class BBInputSetupUtils { this.requestsDbClient.getRequestProcessingDataBySoRequestIdAndName( request.getOriginalRequestId(), PROCESSING_DATA_NAME_EXECUTION_FLOWS); try { - ObjectMapper om = new ObjectMapper(); - TypeFactory typeFactory = om.getTypeFactory(); - om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - return om.readValue(requestProcessingData.getValue(), + TypeFactory typeFactory = mapper.getTypeFactory(); + return mapper.readValue(requestProcessingData.getValue(), typeFactory.constructCollectionType(List.class, ExecuteBuildingBlock.class)); } catch (Exception e) { logger.error(DATA_LOAD_ERROR, e); @@ -247,11 +255,7 @@ public class BBInputSetupUtils { if (requestId != null && !requestId.isEmpty()) { InfraActiveRequests activeRequest = this.getInfraActiveRequest(requestId); String requestBody = activeRequest.getRequestBody().replaceAll("\\\\", ""); - ObjectMapper objectMapper = new ObjectMapper(); - objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - objectMapper.configure(SerializationFeature.WRAP_ROOT_VALUE, true); - objectMapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true); - return objectMapper.readValue(requestBody, RequestDetails.class); + return mapperRootValue.readValue(requestBody, RequestDetails.class); } else { return null; } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/appc/ApplicationControllerAction.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/appc/ApplicationControllerAction.java index c6a921abb5..31eb01aa2b 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/appc/ApplicationControllerAction.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/appc/ApplicationControllerAction.java @@ -38,11 +38,12 @@ import com.fasterxml.jackson.databind.ObjectMapper; @Component public class ApplicationControllerAction { + private static final Logger logger = LoggerFactory.getLogger(ApplicationControllerAction.class); + private static final String PAYLOAD_NOT_PRESENT_ERROR_MSG = "Payload is not present for "; + private static final ObjectMapper mapper = new ObjectMapper(); protected ApplicationControllerOrchestrator client = new ApplicationControllerOrchestrator(); private String errorCode = "1002"; private String errorMessage = "Unable to reach App C Servers"; - private static final String PAYLOAD_NOT_PRESENT_ERROR_MSG = "Payload is not present for "; - private static Logger logger = LoggerFactory.getLogger(ApplicationControllerAction.class); public void runAppCCommand(Action action, String msoRequestId, String vnfId, Optional payload, Map payloadInfo, String controllerType) { @@ -142,7 +143,6 @@ public class ApplicationControllerAction { Status appcStatus = null; String vmId = ""; String vserverId = ""; - ObjectMapper mapper = new ObjectMapper(); List vmIdJsonList = mapper.readValue(vmIds, new TypeReference>() {}); List vserverIdJsonList = mapper.readValue(vserverIds, new TypeReference>() {}); int i = 0; diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/appc/ApplicationControllerSupport.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/appc/ApplicationControllerSupport.java index 144cb257a6..3c582f0857 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/appc/ApplicationControllerSupport.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/appc/ApplicationControllerSupport.java @@ -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,14 @@ public class ApplicationControllerSupport { private static final int PARTIAL_SERIES = 500; private static final int PARTIAL_SUCCESS_STATUS = PARTIAL_SERIES; private static final int PARTIAL_FAILURE_STATUS = PARTIAL_SERIES + 1; + private static final ObjectMapper mapper; + private static final ObjectWriter writer; + + static { + mapper = new ObjectMapper(); + mapper.setSerializationInclusion(Include.NON_NULL); + writer = mapper.writerWithDefaultPrettyPrinter(); + } private static Logger logger = LoggerFactory.getLogger(ApplicationControllerSupport.class); private String lcmModelPackage = "org.onap.appc.client.lcm.model"; @@ -196,9 +204,6 @@ public class ApplicationControllerSupport { } public void logLCMMessage(Object message) { - ObjectMapper objectMapper = new ObjectMapper(); - objectMapper.setSerializationInclusion(Include.NON_NULL); - ObjectWriter writer = objectMapper.writerWithDefaultPrettyPrinter(); String inputAsJSON; try { inputAsJSON = writer.writeValueAsString(message); diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/dmaapproperties/DmaapPropertiesClient.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/dmaapproperties/DmaapPropertiesClient.java index cc262b250f..b02d1068b9 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/dmaapproperties/DmaapPropertiesClient.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/dmaapproperties/DmaapPropertiesClient.java @@ -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,6 +39,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; public class DmaapPropertiesClient { private static final Logger logger = LoggerFactory.getLogger(DmaapPropertiesClient.class); + private static final ObjectMapper mapper = new ObjectMapper(); @Autowired private Provider dmaapPublisher; @@ -64,7 +65,7 @@ public class DmaapPropertiesClient { private String jsonToString(AVPNDmaapBean dmaapBean) throws JsonProcessingException, MapperException { try { - return new ObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(dmaapBean); + return mapper.writerWithDefaultPrettyPrinter().writeValueAsString(dmaapBean); } catch (JsonProcessingException e) { logger.error("Exception occurred", e); throw new MapperException(e.getMessage()); diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmDmaapClient.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmDmaapClient.java index f6e4ffce59..9ab0aa16fd 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmDmaapClient.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmDmaapClient.java @@ -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.client.dmaap.rest.RestConsumer; public class SDNCLcmDmaapClient { private static Logger logger = LoggerFactory.getLogger(SDNCLcmDmaapClient.class); + private static final ObjectMapper mapper = new ObjectMapper(); private RestPublisher dmaapPublisher; private RestConsumer dmaapConsumer; @@ -58,7 +59,6 @@ public class SDNCLcmDmaapClient { } public void sendRequest(LcmDmaapRequest lcmDmaapRequest) throws Exception { - ObjectMapper mapper = new ObjectMapper(); String lcmRestRequestString = mapper.writeValueAsString(lcmDmaapRequest); dmaapPublisher.send(lcmRestRequestString); @@ -71,7 +71,6 @@ public class SDNCLcmDmaapClient { public List getResponse() { List responseList = new ArrayList<>(); - ObjectMapper mapper = new ObjectMapper(); Iterable itrString = dmaapConsumer.fetch(); for (String message : itrString) { LcmDmaapResponse lcmDmaapResponse; diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/JsonWrapper.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/JsonWrapper.java index bf53c880e9..66e143787b 100644 --- a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/JsonWrapper.java +++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/JsonWrapper.java @@ -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. @@ -48,20 +48,22 @@ public abstract class JsonWrapper implements Serializable { private static final String EXCEPTION = "Exception :"; private static final Logger logger = LoggerFactory.getLogger(JsonWrapper.class); + private static final ObjectMapper mapper; + private static final ObjectWriter writer; + + static { + mapper = new ObjectMapper(); + mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, true); + mapper.setSerializationInclusion(Include.NON_NULL); + writer = mapper.writer().withDefaultPrettyPrinter(); + } @JsonInclude(Include.NON_NULL) public String toJsonString() { String jsonString = ""; - // convert with Jackson - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, true); - - mapper.setSerializationInclusion(Include.NON_NULL); - - ObjectWriter ow = mapper.writer().withDefaultPrettyPrinter(); try { - jsonString = ow.writeValueAsString(this); + jsonString = writer.writeValueAsString(this); } catch (Exception e) { logger.debug(EXCEPTION, e); @@ -71,9 +73,6 @@ public abstract class JsonWrapper implements Serializable { @JsonInclude(Include.NON_NULL) public JSONObject toJsonObject() { - - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, true); JSONObject json = new JSONObject(); try { json = new JSONObject(mapper.writeValueAsString(this)); @@ -85,10 +84,7 @@ public abstract class JsonWrapper implements Serializable { return json; } - public String listToJson(List list) { - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, true); - + public String listToJson(List list) { String jsonString = ""; try { jsonString = mapper.writeValueAsString(list); @@ -104,13 +100,9 @@ public abstract class JsonWrapper implements Serializable { public String toJsonStringNoRootName() { String jsonString = ""; - // convert with Jackson - ObjectMapper mapper = new ObjectMapper(); - mapper.setSerializationInclusion(Include.NON_NULL); - ObjectWriter ow = mapper.writer().withDefaultPrettyPrinter(); try { - jsonString = ow.writeValueAsString(this); + jsonString = writer.writeValueAsString(this); } catch (Exception e) { logger.debug(EXCEPTION, e); diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/json/DecomposeJsonUtil.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/json/DecomposeJsonUtil.java index 93a47ff6b1..514ca4b2d7 100644 --- a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/json/DecomposeJsonUtil.java +++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/json/DecomposeJsonUtil.java @@ -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,33 +39,33 @@ import org.slf4j.LoggerFactory; public class DecomposeJsonUtil implements Serializable { private static final Logger logger = LoggerFactory.getLogger(DecomposeJsonUtil.class); /** - * + * */ private static final long serialVersionUID = 1L; - private static final ObjectMapper OBJECT_MAPPER = createObjectMapper(); - - private DecomposeJsonUtil() {} + private static final ObjectMapper OBJECT_MAPPER; + private static final ObjectMapper mapperUnknown; - private static ObjectMapper createObjectMapper() { - ObjectMapper om = new ObjectMapper(); - om.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true); - return om; + static { + OBJECT_MAPPER = new ObjectMapper(); + OBJECT_MAPPER.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true); + mapperUnknown = new ObjectMapper(); + mapperUnknown.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true); + mapperUnknown.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); } + private DecomposeJsonUtil() {} + /** * Method to construct Service Decomposition object converting JSON structure - * + * * @param jsonString input in JSON format confirming ServiceDecomposition * @return decoded object * @throws JsonDecomposingException thrown when decoding json fails */ public static ServiceDecomposition jsonToServiceDecomposition(String jsonString) throws JsonDecomposingException { try { - ObjectMapper om = new ObjectMapper(); - om.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true); - om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - return om.readValue(jsonString, ServiceDecomposition.class); + return mapperUnknown.readValue(jsonString, ServiceDecomposition.class); } catch (IOException e) { throw new JsonDecomposingException("Exception while converting json to service decomposition", e); } @@ -90,7 +90,7 @@ public class DecomposeJsonUtil implements Serializable { /** * Method to construct Resource Decomposition object converting JSON structure - * + * * @param jsonString input in JSON format confirming ResourceDecomposition * @return decoded object * @throws JsonDecomposingException thrown when decoding json fails @@ -105,7 +105,7 @@ public class DecomposeJsonUtil implements Serializable { /** * Method to construct Resource Decomposition object converting JSON structure - * + * * @param jsonString input in JSON format confirming ResourceDecomposition * @return decoded object * @throws JsonDecomposingException thrown when decoding json fails @@ -120,7 +120,7 @@ public class DecomposeJsonUtil implements Serializable { /** * Method to construct Resource Decomposition object converting JSON structure - * + * * @param jsonString - input in JSON format confirming ResourceDecomposition * @return decoded object * @throws JsonDecomposingException thrown when decoding json fails diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/AnNssmfutils.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/AnNssmfutils.groovy index eb7e89ce54..b89e831376 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/AnNssmfutils.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/AnNssmfutils.groovy @@ -60,7 +60,7 @@ import com.google.gson.Gson class AnNssmfUtils { private static final Logger logger = LoggerFactory.getLogger(AnNssmfUtils.class) - 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, @@ -129,7 +129,7 @@ public String buildCreateANNFNSSMFSubnetCapabilityRequest() { return response.toString() } public void createDomainWiseSliceProfiles(List ranConstituentSliceProfiles, DelegateExecution execution) { - + for(String profile : ranConstituentSliceProfiles) { String domainType = jsonUtil.getJsonValue(profile, "domainType") switch(domainType) { @@ -147,12 +147,12 @@ public void createDomainWiseSliceProfiles(List ranConstituentSliceProfil logger.error("No expected match found for current domainType "+ domainType) exceptionUtil.buildAndThrowWorkflowException(execution, 1000,"No expected match found for current domainType "+ domainType) } - + } } public void createSliceProfilesInAai(DelegateExecution execution) { - + String serviceCategory = execution.getVariable("serviceCategory") if (execution.getVariable("IsRANNfAlonePresent")) { ServiceInstance ANNF_sliceProfileInstance = new ServiceInstance(); @@ -251,7 +251,7 @@ else{ String serviceFunctionAnnf = jsonUtil.getJsonValue(execution.getVariable("ranNfSliceProfile"), "resourceSharingLevel") ANNF_sliceProfileInstance.setServiceFunction(serviceFunctionAnnf) logger.debug("completed ANNF sliceprofileinstance build : "+ ANNF_sliceProfileInstance.toString()) - + //TNFH slice profile instance creation TNFH_sliceProfileInstance.setServiceInstanceId(TNFH_sliceProfileInstanceId) sliceInstanceName = "sliceprofile_"+TNFH_sliceProfileId @@ -268,7 +268,7 @@ else{ String serviceFunctionTnFH = jsonUtil.getJsonValue(execution.getVariable("tnFhSliceProfile"), "resourceSharingLevel") TNFH_sliceProfileInstance.setServiceFunction(serviceFunctionTnFH) logger.debug("completed TNFH sliceprofileinstance build : "+TNFH_sliceProfileInstance) - + //TNMH slice profile instance creation TNMH_sliceProfileInstance.setServiceInstanceId(TNMH_sliceProfileInstanceId) sliceInstanceName = "sliceprofile_"+TNMH_sliceProfileId @@ -285,7 +285,7 @@ else{ String serviceFunctionTnMH = jsonUtil.getJsonValue(execution.getVariable("tnMhSliceProfile"), "resourceSharingLevel") TNMH_sliceProfileInstance.setServiceFunction(serviceFunctionTnMH) logger.debug("completed TNMH sliceprofileinstance build : "+TNMH_sliceProfileInstance) - + String msg = "" try { @@ -330,13 +330,13 @@ private SliceProfile createSliceProfile(String domainType, DelegateExecution exe result.setMaxNumberOfPDUSession(profile.get("maxNumberofPDUSession")) result.setAreaTrafficCapDL(profile.get("areaTrafficCapDL")) result.setAreaTrafficCapUL(profile.get("areaTrafficCapUL")) - result.setOverallUserDensity(profile.get("overallUserDensity")) + result.setOverallUserDensity(profile.get("overallUserDensity")) result.setTransferIntervalTarget(profile.get("transferIntervalTarget")) result.setExpDataRate(profile.get("expDataRate")) result.setProfileId(execution.getVariable("ANNF_sliceProfileId")) break case "TN_FH": - profile = objectMapper.readValue(execution.getVariable("tnFhSliceProfile"), Map.class) + profile = objectMapper.readValue(execution.getVariable("tnFhSliceProfile"), Map.class) result.setJitter(profile.get("jitter")) result.setLatency(profile.get("latency")) result.setMaxBandwidth(profile.get("maxbandwidth")) @@ -380,7 +380,7 @@ private SliceProfile createSliceProfile(String domainType, DelegateExecution exe logger.debug("createRelationShipInAAI Exit") } - + public void processRanNfModifyRsp(DelegateExecution execution) { String status = execution.getVariable("ranNfStatus") if(status.equals("success")) { @@ -391,7 +391,7 @@ private SliceProfile createSliceProfile(String domainType, DelegateExecution exe exceptionUtil.buildAndThrowWorkflowException(execution, 1000, "modify ran nf nssi not successfull") } } - + public String buildCreateNSSMFRequest(DelegateExecution execution, String domainType, String action) { JsonObject esrInfo = new JsonObject() esrInfo.addProperty("networkType", "tn") @@ -481,7 +481,7 @@ private SliceProfile createSliceProfile(String domainType, DelegateExecution exe response.add("allocateTnNssi", allocateTnNssi) return response.toString() } - + public String buildDeallocateNssiRequest(DelegateExecution execution,String domainType) { String globalSubscriberId = execution.getVariable("globalSubscriberId") String subscriptionServiceType = execution.getVariable("subscriptionServiceType") @@ -493,11 +493,11 @@ private SliceProfile createSliceProfile(String domainType, DelegateExecution exe deallocateNssi.setScriptName("TN1") deallocateNssi.setSnssaiList(sNssaiList) deallocateNssi.setTerminateNssiOption(0) - + JsonObject esrInfo = new JsonObject() esrInfo.addProperty("networkType", "tn") esrInfo.addProperty("vendor", "ONAP_internal") - + JsonObject serviceInfo = new JsonObject() serviceInfo.addProperty("globalSubscriberId", globalSubscriberId) serviceInfo.addProperty("subscriptionServiceType", subscriptionServiceType) @@ -519,7 +519,7 @@ private SliceProfile createSliceProfile(String domainType, DelegateExecution exe json.add("esrInfo", esrInfo) json.add("serviceInfo", serviceInfo) return json.toString() - + } public String getModelUuid(DelegateExecution execution, String instanceId) { @@ -533,7 +533,7 @@ private SliceProfile createSliceProfile(String domainType, DelegateExecution exe } AAIResultWrapper wrapper = client.get(uri, NotFoundException.class) Optional si = wrapper.asBean(ServiceInstance.class) - + if(si.isPresent()) { serviceInstance = si.get() } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSliceService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSliceService.groovy index e55ea13938..5bcc9651f4 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSliceService.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSliceService.groovy @@ -52,21 +52,16 @@ import com.fasterxml.jackson.databind.ObjectMapper import groovy.json.JsonSlurper public class CreateSliceService extends AbstractServiceTaskProcessor { - String Prefix = "CRESS_" + private static final Logger logger = LoggerFactory.getLogger(CreateSliceService.class) + private static final ObjectMapper objectMapper = new ObjectMapper() + String Prefix = "CRESS_" ExceptionUtil exceptionUtil = new ExceptionUtil() - JsonUtils jsonUtil = new JsonUtils() - JsonSlurper jsonSlurper = new JsonSlurper() - - ObjectMapper objectMapper = new ObjectMapper() - OofUtils oofUtils = new OofUtils() - AAIResourcesClient client = getAAIClient() - private static final Logger logger = LoggerFactory.getLogger(CreateSliceService.class) public void preProcessRequest(DelegateExecution execution) { logger.debug("Start preProcessRequest") @@ -510,4 +505,3 @@ public class CreateSliceService extends AbstractServiceTaskProcessor { } } - diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVFCNSResource.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVFCNSResource.groovy index 642609a970..c9356a52cd 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVFCNSResource.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVFCNSResource.groovy @@ -34,6 +34,7 @@ import org.slf4j.LoggerFactory public class DeleteVFCNSResource extends AbstractServiceTaskProcessor { + private static final ObjectMapper mapper = new ObjectMapper() String Prefix = "DCUSE_" ExceptionUtil exceptionUtil = new ExceptionUtil() JsonUtils jsonUtil = new JsonUtils() @@ -45,7 +46,7 @@ public class DeleteVFCNSResource extends AbstractServiceTaskProcessor { logger.info(" ***** start preProcessRequest *****") String resourceInputStr = execution.getVariable("resourceInput") - ResourceInput resourceInput = new ObjectMapper().readValue(resourceInputStr, ResourceInput.class) + ResourceInput resourceInput = mapper.readValue(resourceInputStr, ResourceInput.class) String globalSubscriberId = resourceInput.getGlobalSubscriberId() String serviceType = execution.getVariable("serviceType") diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateAccessNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateAccessNSSI.groovy index 42b36f9b0e..fc1e550252 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateAccessNSSI.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateAccessNSSI.groovy @@ -57,15 +57,15 @@ import com.google.gson.Gson * */ class DoActivateAccessNSSI extends AbstractServiceTaskProcessor { - + String Prefix="DoActivateAccessNSSI" ExceptionUtil exceptionUtil = new ExceptionUtil() RequestDBUtil requestDBUtil = new RequestDBUtil() JsonUtils jsonUtil = new JsonUtils() - ObjectMapper objectMapper = new ObjectMapper() AnNssmfUtils anNssmfUtils = new AnNssmfUtils() private NssmfAdapterUtils nssmfAdapterUtils = new NssmfAdapterUtils(httpClientFactory, jsonUtil) + private static final ObjectMapper objectMapper = new ObjectMapper() private static final Logger logger = LoggerFactory.getLogger(DoActivateAccessNSSI.class) private static final String ROLE_SLICE_PROFILE = "slice-profile-instance" private static final String ROLE_NSSI = "nssi" @@ -82,7 +82,7 @@ class DoActivateAccessNSSI extends AbstractServiceTaskProcessor { private static final String VENDOR_ONAP = "ONAP_internal" - enum orchStatusMap { + enum orchStatusMap { activateInstance("activated"), deactivateInstance("deactivated") @@ -90,7 +90,7 @@ class DoActivateAccessNSSI extends AbstractServiceTaskProcessor { private orchStatusMap(String value) { this.value = value; - } + } } @@ -127,7 +127,7 @@ class DoActivateAccessNSSI extends AbstractServiceTaskProcessor { logger.debug("${Prefix} - Preprocessing completed with sliceProfileId : ${anSliceProfileId} , nsiId : ${nsiId} , nssiId : ${anNssiId}") } - + /** * Method to fetch AN NSSI Constituents and Slice Profile constituents * @param execution @@ -148,7 +148,7 @@ class DoActivateAccessNSSI extends AbstractServiceTaskProcessor { } logger.trace("${Prefix} - Exit Get Related instances") } - + /** * Method to check Slice profile orchestration status * @param execution @@ -162,11 +162,11 @@ class DoActivateAccessNSSI extends AbstractServiceTaskProcessor { execution.setVariable("shouldChangeSPStatus", false) }else { execution.setVariable("shouldChangeSPStatus", true) - + } logger.debug("${Prefix} - SPOrchStatus : ${orchStatus}") } - + /** * Method to check AN NF's Slice profile instance orchestration status * @param execution @@ -253,7 +253,7 @@ class DoActivateAccessNSSI extends AbstractServiceTaskProcessor { } logger.debug("${Prefix} processed SdnrResponse") } - + /** * Update AN NF - NSSI and SP Instance status * @param execution @@ -267,7 +267,7 @@ class DoActivateAccessNSSI extends AbstractServiceTaskProcessor { updateOrchStatus(execution, anNfNssiId) logger.debug("${Prefix}Exit updateAnNfStatus") } - + /** * Method to check AN NF's Slice profile instance orchestration status * @param execution @@ -290,7 +290,7 @@ class DoActivateAccessNSSI extends AbstractServiceTaskProcessor { logger.debug("${Prefix} Exit getTnFhSPOrchStatus TN_FH SP ID:${tnFhSPId} : ${orchStatus}") } - + void doTnFhNssiActivation(DelegateExecution execution){ logger.debug("Start doTnFhNssiActivation in ${Prefix}") String nssmfRequest = buildTNActivateNssiRequest(execution, TN_FH) @@ -298,7 +298,7 @@ class DoActivateAccessNSSI extends AbstractServiceTaskProcessor { String urlOpType = operationType.equalsIgnoreCase(ACTIVATE) ? "activation":"deactivation" List sNssaiList = execution.getVariable("sNssaiList") - String snssai = sNssaiList.get(0) + String snssai = sNssaiList.get(0) String urlString = "/api/rest/provMns/v1/NSS/" + snssai + "/" + urlOpType String nssmfResponse = nssmfAdapterUtils.sendPostRequestNSSMF(execution, urlString, nssmfRequest) if (nssmfResponse != null) { @@ -328,7 +328,7 @@ class DoActivateAccessNSSI extends AbstractServiceTaskProcessor { } logger.debug("${Prefix} Exit getTnMhSPOrchStatus TN_MH SP ID:${tnFhSPId} : ${orchStatus}") } - + void doTnMhNssiActivation(DelegateExecution execution){ logger.debug("Start doTnMhNssiActivation in ${Prefix}") String nssmfRequest = buildTNActivateNssiRequest(execution, TN_MH) @@ -336,7 +336,7 @@ class DoActivateAccessNSSI extends AbstractServiceTaskProcessor { String urlOpType = operationType.equalsIgnoreCase(ACTIVATE) ? "activation":"deactivation" List sNssaiList = execution.getVariable("sNssaiList") - String snssai = sNssaiList.get(0) + String snssai = sNssaiList.get(0) String urlString = "/api/rest/provMns/v1/NSS/" + snssai + "/" + urlOpType String nssmfResponse = nssmfAdapterUtils.sendPostRequestNSSMF(execution, urlString, nssmfRequest) @@ -348,9 +348,9 @@ class DoActivateAccessNSSI extends AbstractServiceTaskProcessor { exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"Received a Bad Sync Response from NSSMF.") } logger.debug("Exit doTnMhNssiActivation in ${Prefix}") - + } - + /** * Update TN FH - NSSI and SP Instance status * @param execution @@ -364,9 +364,9 @@ class DoActivateAccessNSSI extends AbstractServiceTaskProcessor { updateOrchStatus(execution, tnFhNssiId) logger.debug("${Prefix} Exit updateTNFHStatus") - + } - + /** * Update TN MH - NSSI and SP Instance status * @param execution @@ -381,7 +381,7 @@ class DoActivateAccessNSSI extends AbstractServiceTaskProcessor { logger.debug("${Prefix} Exit updateTNMHStatus") } - + /** * Update AN - NSSI and SP Instance status * @param execution @@ -394,7 +394,7 @@ class DoActivateAccessNSSI extends AbstractServiceTaskProcessor { updateOrchStatus(execution, anSliceProfileId) logger.debug("${Prefix} Exit updateANStatus") } - + void prepareQueryJobStatus(DelegateExecution execution,String jobId,String networkType,String instanceId) { logger.debug("${Prefix} Start prepareQueryJobStatus : ${jobId}") String responseId = "1" @@ -414,9 +414,9 @@ class DoActivateAccessNSSI extends AbstractServiceTaskProcessor { execution.setVariable("${networkType}_esrInfo", esrInfo.toString()) execution.setVariable("${networkType}_responseId", responseId) execution.setVariable("${networkType}_serviceInfo", serviceInfo.toString()) - + } - + void validateJobStatus(DelegateExecution execution,String responseDescriptor) { logger.debug("validateJobStatus ${responseDescriptor}") String jobResponse = execution.getVariable("tn_responseDescriptor") @@ -429,8 +429,8 @@ class DoActivateAccessNSSI extends AbstractServiceTaskProcessor { execution.setVariable("isSuccess", false) } } - - + + private void updateOrchStatus(DelegateExecution execution,String serviceId) { logger.debug("${Prefix} Start updateOrchStatus : ${serviceId}") String globalSubscriberId = execution.getVariable("globalSubscriberId") @@ -463,7 +463,7 @@ class DoActivateAccessNSSI extends AbstractServiceTaskProcessor { } logger.debug("${Prefix} Exit updateOrchStatus : ${serviceId}") } - + void prepareUpdateJobStatus(DelegateExecution execution,String status,String progress,String statusDescription) { logger.debug("${Prefix} Start prepareUpdateJobStatus : ${statusDescription}") String nssiId = execution.getVariable("anNssiId") @@ -485,9 +485,9 @@ class DoActivateAccessNSSI extends AbstractServiceTaskProcessor { requestDBUtil.prepareUpdateResourceOperationStatus(execution, roStatus) logger.debug("${Prefix} Exit prepareUpdateJobStatus : ${statusDescription}") } - - - + + + /** * Fetches a collection of service instances with the specific role and maps it based on workload context * (AN-NF,TN-FH,TN-MH) @@ -501,13 +501,13 @@ class DoActivateAccessNSSI extends AbstractServiceTaskProcessor { logger.debug("${Prefix} - Fetching related ${role} from AAI") String globalSubscriberId = execution.getVariable("globalSubscriberId") String subscriptionServiceType = execution.getVariable("subscriptionServiceType") - + if( isBlank(role) || isBlank(instanceId)) { exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Role and instanceId are mandatory") } Map relatedInstances = new HashMap<>() - + AAIResourcesClient client = getAAIClient() AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(instanceId)) if (!client.exists(uri)) { @@ -543,7 +543,7 @@ class DoActivateAccessNSSI extends AbstractServiceTaskProcessor { logger.debug("Found ${relatedInstances.size()} ${role} related to ${instanceId} ") return relatedInstances } - + private ServiceInstance getInstanceByWorkloadContext(Map instances,String workloadContext ) { ServiceInstance instance = instances.get(workloadContext) if(instance == null) { @@ -551,7 +551,7 @@ class DoActivateAccessNSSI extends AbstractServiceTaskProcessor { } return instance } - + private String getInstanceIdByWorkloadContext(Map instances,String workloadContext ) { String instanceId = instances.get(workloadContext).getServiceInstanceId() if(instanceId == null) { @@ -559,8 +559,8 @@ class DoActivateAccessNSSI extends AbstractServiceTaskProcessor { } return instanceId } - - + + /** * Method to handle deallocation of RAN NSSI constituents(TN_FH/TN_MH) * @param execution @@ -604,7 +604,7 @@ class DoActivateAccessNSSI extends AbstractServiceTaskProcessor { json.add("esrInfo", esrInfo) json.add("serviceInfo", jsonConverter.toJsonTree(serviceInfo)) return json.toString() - + } - + } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateCoreNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateCoreNSSI.groovy index 44a10a1adc..f08f37d69f 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateCoreNSSI.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateCoreNSSI.groovy @@ -66,7 +66,7 @@ class DoActivateCoreNSSI extends AbstractServiceTaskProcessor { CatalogDbUtils catalogDbUtils = new CatalogDbUtilsFactory().create() private RequestDBUtil requestDBUtil = new RequestDBUtil() ExceptionUtil exceptionUtil = new ExceptionUtil() - ObjectMapper mapper = new ObjectMapper(); + private static final ObjectMapper objectMapper = new ObjectMapper() JsonUtils jsonUtil = new JsonUtils() diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateSliceService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateSliceService.groovy index e54193470d..ca1e09c508 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateSliceService.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateSliceService.groovy @@ -68,13 +68,13 @@ class DoActivateSliceService extends AbstractServiceTaskProcessor { private static final NSSMF_DEACTIVATION_URL = "/api/rest/provMns/v1/NSS/%s/deactivation" private static final NSSMF_QUERY_JOB_STATUS_URL = "/api/rest/provMns/v1/NSS/jobs/%s" + private static final ObjectMapper objectMapper = new ObjectMapper() String Prefix="DoCNSSMF_" ExceptionUtil exceptionUtil = new ExceptionUtil() JsonUtils jsonUtil = new JsonUtils() - ObjectMapper objectMapper = new ObjectMapper() SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateTnNssi.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateTnNssi.groovy index 515990ac1a..fcf36acf86 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateTnNssi.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateTnNssi.groovy @@ -48,7 +48,7 @@ public class DoActivateTnNssi extends AbstractServiceTaskProcessor { RequestDBUtil requestDBUtil = new RequestDBUtil() TnNssmfUtils tnNssmfUtils = new TnNssmfUtils() JsonSlurper jsonSlurper = new JsonSlurper() - ObjectMapper objectMapper = new ObjectMapper() + private static final ObjectMapper objectMapper = new ObjectMapper() private static final Logger logger = LoggerFactory.getLogger(DoActivateTnNssi.class) @@ -182,4 +182,3 @@ public class DoActivateTnNssi extends AbstractServiceTaskProcessor { } } - diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateAccessNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateAccessNSSI.groovy index 54fa2abdd1..0aa0db5681 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateAccessNSSI.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateAccessNSSI.groovy @@ -63,7 +63,7 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { JsonUtils jsonUtil = new JsonUtils() OofUtils oofUtils = new OofUtils() AnNssmfUtils anNssmfUtils = new AnNssmfUtils() - ObjectMapper objectMapper = new ObjectMapper(); + private static final ObjectMapper objectMapper = new ObjectMapper() private NssmfAdapterUtils nssmfAdapterUtils = new NssmfAdapterUtils(httpClientFactory, jsonUtil) private static final Logger logger = LoggerFactory.getLogger(DoAllocateAccessNSSI.class) @@ -132,13 +132,13 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { String RANServiceInstanceId = UUID.randomUUID().toString() String RANNFServiceInstanceId = UUID.randomUUID().toString() logger.debug("RAN serviceInstance Id "+RANServiceInstanceId) - logger.debug("RAN NF serviceInstance Id "+RANNFServiceInstanceId) + logger.debug("RAN NF serviceInstance Id "+RANNFServiceInstanceId) execution.setVariable("RANServiceInstanceId", RANServiceInstanceId) execution.setVariable("RANNFServiceInstanceId", RANNFServiceInstanceId) execution.setVariable("ranNssiPreferReuse", true) execution.setVariable("ranNfNssiPreferReuse", true) execution.setVariable("job_timeout", 10) - + //set BH end point def BH_endPoints = jsonUtil.getJsonValue(sliceParams, "endPoint") logger.debug("BH end points list : "+BH_endPoints) @@ -181,7 +181,7 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { } /* process the decompose service(RAN NSST) response - * + * */ def processDecomposition = { DelegateExecution execution -> logger.debug(Prefix+"processDecomposition method start") @@ -357,19 +357,19 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { def prepareModifyAccessNssiInputs = { DelegateExecution execution -> logger.debug(Prefix+"prepareModifyAccessNssiInputs method start") String jobId = UUID.randomUUID().toString() - execution.setVariable("modifyRanNssiJobId", jobId) + execution.setVariable("modifyRanNssiJobId", jobId) String snssaiList = execution.getVariable("snssaiList") String sliceParams = execution.getVariable("sliceParams") String sliceProfileId = execution.getVariable("sliceProfileId") String nsiInfo = jsonUtil.getJsonValue(sliceParams, "nsiInfo") String scriptName = execution.getVariable("scriptName") - + JsonObject modifySliceParams = new JsonObject() modifySliceParams.addProperty("modifyAction", "allocate") modifySliceParams.addProperty("snssaiList", snssaiList) modifySliceParams.addProperty("sliceProfileId", sliceProfileId) modifySliceParams.addProperty("nsiInfo", nsiInfo) - + execution.setVariable("modifySliceParams", modifySliceParams.toString()) //create operation status in request db String nsiId = execution.getVariable("nsiId") @@ -383,7 +383,7 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { initStatus.setOperType("Modify") requestDBUtil.prepareInitResourceOperationStatus(execution, initStatus) } - + def createModifyNssiQueryJobStatus = { DelegateExecution execution -> logger.debug(Prefix+"createModifyNssiQueryJobStatus method start") JsonObject esrInfo = new JsonObject() @@ -414,7 +414,7 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { String nsstInfo = nsstInfoList.get(currentIndex) String modelInvariantUuid = jsonUtil.getJsonValue(nsstInfo, "invariantUUID") String modelUuid = jsonUtil.getJsonValue(nsstInfo, "UUID") - + String serviceModelInfo = """{ "modelInvariantUuid":"${modelInvariantUuid}", "modelUuid":"${modelUuid}", @@ -429,19 +429,19 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { logger.error("nsstList decomposition error ") exceptionUtil.buildAndThrowWorkflowException(execution, 1000, "nsstList decomposition error ") } - + } def processNsstDecomposition = { DelegateExecution execution -> logger.debug(Prefix+"processNsstDecomposition method start") ServiceDecomposition decomposedNsst = execution.getVariable("nsstServiceDecomposition") logger.debug("decomposedNsst : "+decomposedNsst.toString()) - + String nsstType = decomposedNsst.getServiceCategory() //domainType String modelVersion = decomposedNsst.getModelInfo().getModelVersion() String modelName = decomposedNsst.getModelInfo().getModelName() String modelUuid = decomposedNsst.getModelInfo().getModelUuid() String modelInvariantUuid = decomposedNsst.getModelInfo().getModelInvariantUuid() - + switch(nsstType) { case "AN NF NSST": execution.setVariable("ANNF_modelInvariantUuid", modelInvariantUuid) @@ -521,7 +521,7 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { String solutions = jsonUtil.getJsonValue(oofResponse, "solutions") logger.debug("nssi solutions value : "+solutions) JsonParser parser = new JsonParser() - JsonArray solution = parser.parse(solutions) + JsonArray solution = parser.parse(solutions) if(solution.size()>=1) { JsonObject sol = solution.get(0) String ranNfNssiId = sol.get("NSSIId").getAsString() @@ -533,7 +533,7 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { execution.setVariable("RANNFUUID", uuid) execution.setVariable("RANNFNssiName", nssiName) logger.debug("RANNFServiceInstanceId from OOF "+ranNfNssiId) - + ServiceInstance serviceInstance = new ServiceInstance(); serviceInstance.setInstanceId(ranNfNssiId); ServiceDecomposition serviceDecomposition = execution.getVariable("ANNF_ServiceDecomposition") @@ -559,7 +559,7 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { def processRanNfModifyRsp = { DelegateExecution execution -> logger.debug(Prefix+"processRanNfModifyRsp method start") anNssmfUtils.processRanNfModifyRsp(execution) - //create RAN NSSI + //create RAN NSSI org.onap.aai.domain.yang.ServiceInstance ANServiceInstance = new org.onap.aai.domain.yang.ServiceInstance(); //AN instance creation ANServiceInstance.setServiceInstanceId(execution.getVariable("RANServiceInstanceId")) @@ -582,15 +582,15 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { ANServiceInstance.setModelVersionId(modelUuid) ANServiceInstance.setEnvironmentContext(execution.getVariable("networkType")) //Network Type ANServiceInstance.setWorkloadContext("AN") //domain Type - + logger.debug("completed AN service instance build "+ ANServiceInstance.toString()) String msg = "" try { - + AAIResourcesClient client = new AAIResourcesClient() AAIResourceUri nssiServiceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(execution.getVariable("RANServiceInstanceId"))) client.create(nssiServiceUri, ANServiceInstance) - + } catch (BpmnError e) { throw e } catch (Exception ex) { @@ -601,7 +601,7 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { //end point update createEndPointsInAai(execution) } - + def createSdnrRequest = { DelegateExecution execution -> logger.debug(Prefix+"createSdnrRequest method start") String callbackUrl = UrnPropertiesReader.getVariable("mso.workflow.message.endpoint") + "/AsyncSdnrResponse/"+execution.getVariable("msoRequestId") @@ -629,7 +629,7 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { def updateAaiWithRANInstances = { DelegateExecution execution -> logger.debug(Prefix+"updateAaiWithRANInstances method start") - //create RAN NSSI + //create RAN NSSI org.onap.aai.domain.yang.ServiceInstance ANServiceInstance = new org.onap.aai.domain.yang.ServiceInstance(); org.onap.aai.domain.yang.ServiceInstance ANNFServiceInstance = new org.onap.aai.domain.yang.ServiceInstance(); String serviceCategory = execution.getVariable("serviceCategory") @@ -642,7 +642,7 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { ANServiceInstance.setServiceType(execution.getVariable("sst") as String) ANServiceInstance.setOrchestrationStatus(serviceStatus) String serviceInstanceLocationid = jsonUtil.getJsonValue(execution.getVariable("sliceProfile"), "pLMNIdList") as String - ANServiceInstance.setServiceInstanceLocationId(jsonUtil.StringArrayToList(serviceInstanceLocationid).get(0)) + ANServiceInstance.setServiceInstanceLocationId(jsonUtil.StringArrayToList(serviceInstanceLocationid).get(0)) ANServiceInstance.setServiceRole(serviceRole) List snssaiList = jsonUtil.StringArrayToList(execution.getVariable("snssaiList") as String) String snssai = snssaiList.get(0) @@ -674,17 +674,17 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { String serviceFunctionAnnf = jsonUtil.getJsonValue(execution.getVariable("ranNfSliceProfile") as String, "resourceSharingLevel") ANNFServiceInstance.setServiceFunction(serviceFunctionAnnf) logger.debug("completed AN service instance build "+ ANNFServiceInstance.toString()) - + String msg = "" try { - + AAIResourcesClient client = new AAIResourcesClient() AAIResourceUri nssiServiceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId") as String).serviceSubscription(execution.getVariable("subscriptionServiceType") as String).serviceInstance(execution.getVariable("RANServiceInstanceId") as String)) client.create(nssiServiceUri, ANServiceInstance) - + AAIResourceUri nssiServiceUri1 = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId") as String).serviceSubscription(execution.getVariable("subscriptionServiceType") as String).serviceInstance(execution.getVariable("RANNFServiceInstanceId") as String)) client.create(nssiServiceUri1, ANNFServiceInstance) - + } catch (BpmnError e) { throw e } catch (Exception ex) { @@ -732,17 +732,17 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { } logger.debug("Exit prepareTnMhRequest") } - + def createFhAllocateNssiJobQuery = { DelegateExecution execution -> logger.debug(Prefix+"createFhAllocateNssiJobQuery method start") - createTnAllocateNssiJobQuery(execution, "TN_FH") + createTnAllocateNssiJobQuery(execution, "TN_FH") } - + def createMhAllocateNssiJobQuery = { DelegateExecution execution -> logger.debug(Prefix+"createMhAllocateNssiJobQuery method start") createTnAllocateNssiJobQuery(execution, "TN_MH") } - + private void createTnAllocateNssiJobQuery(DelegateExecution execution, String domainType) { JsonObject esrInfo = new JsonObject() esrInfo.addProperty("networkType", "tn") @@ -766,7 +766,7 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { execution.setVariable("serviceInfo", serviceInfo.toString()) execution.setVariable("responseId", "") } - + def processFhAllocateNssiJobStatusRsp = { DelegateExecution execution -> logger.debug(Prefix+"processJobStatusRsp method start") String jobResponse = execution.getVariable("TNFH_jobResponse") @@ -783,7 +783,7 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"received failed status from job status query for nssi : "+nssi+" with status description : "+ statusDescription) } } - + def processMhAllocateNssiJobStatusRsp = { DelegateExecution execution -> logger.debug(Prefix+"processJobStatusRsp method start") String jobResponse = execution.getVariable("TNMH_jobResponse") @@ -800,7 +800,7 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"received failed status from job status query for nssi : "+nssi+" with status description : "+ statusDescription) } } - + def processModifyJobStatusRsp = { DelegateExecution execution -> logger.debug(Prefix+"processJobStatusRsp method start") String jobResponse = execution.getVariable("jobResponse") @@ -911,7 +911,7 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { } } } - + /** * update operation status in request db * @@ -940,7 +940,7 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { def prepareFailedOperationStatusUpdate = { DelegateExecution execution -> logger.debug(Prefix + "prepareFailedOperationStatusUpdate Start") - + String jobId = execution.getVariable("jobId") String nsiId = execution.getVariable("nsiId") String modelUuid = execution.getVariable("modelUuid") @@ -957,9 +957,9 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { updateStatus.setStatus("failed") requestDBUtil.prepareUpdateResourceOperationStatus(execution, updateStatus) } - + private String buildSdnrAllocateRequest(DelegateExecution execution, String action, String rpcName, String callbackUrl) { - + String requestId = execution.getVariable("msoRequestId") Map sliceProfile = objectMapper.readValue(execution.getVariable("ranNfSliceProfile"), Map.class) sliceProfile.put("sliceProfileId", execution.getVariable("ANNF_sliceProfileInstanceId")) @@ -979,7 +979,7 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { commonHeader.addProperty("request-id", requestId) commonHeader.addProperty("sub-request-id", "1") commonHeader.add("flags", new JsonObject()) - Gson jsonConverter = new Gson() + Gson jsonConverter = new Gson() payloadInput.add("sliceProfile", jsonConverter.toJsonTree(sliceProfile)) payloadInput.addProperty("RANNSSIId", execution.getVariable("RANServiceInstanceId")) payloadInput.addProperty("NSIID", execution.getVariable("nsiId")) @@ -1000,7 +1000,7 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { response.addProperty("type", "request") return response.toString() } - + private void createEndPointsInAai(DelegateExecution execution) { String type = "endpoint" String function = "transport_EP" @@ -1100,7 +1100,7 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { //relationship b/w bh_ep and RAN NSSI def AN_NSSI = execution.getVariable("RANServiceInstanceId") Relationship relationship = new Relationship() - String relatedLink = "aai/v21/network/network-routes/network-route/${bh_routeId}" + String relatedLink = "aai/v21/network/network-routes/network-route/${bh_routeId}" relationship.setRelatedLink(relatedLink) relationship.setRelatedTo("network-route") relationship.setRelationshipLabel("org.onap.relationships.inventory.ComposedOf") @@ -1127,4 +1127,3 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { } } } - diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreNSSI.groovy index 01aefe2054..09df16e51b 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreNSSI.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreNSSI.groovy @@ -50,7 +50,7 @@ class DoAllocateCoreNSSI extends AbstractServiceTaskProcessor { CatalogDbUtils catalogDbUtils = new CatalogDbUtilsFactory().create() JsonUtils jsonUtil = new JsonUtils() RequestDBUtil requestDBUtil = new RequestDBUtil() - ObjectMapper mapper = new ObjectMapper() + private static final ObjectMapper mapper = new ObjectMapper() OofUtils oofUtils = new OofUtils() void preProcessRequest(DelegateExecution execution) { logger.debug(Prefix+" **** Enter DoAllocateCoreNSSI ::: preProcessRequest ****") @@ -157,4 +157,4 @@ class DoAllocateCoreNSSI extends AbstractServiceTaskProcessor { requestDBUtil.prepareUpdateResourceOperationStatus(execution, resourceOperationStatus) logger.debug(Prefix + " **** Exit DoAllocateCoreNSSI ::: prepareFailedOperationStatusUpdate ****") } -} \ No newline at end of file +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreNonSharedSlice.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreNonSharedSlice.groovy index bf3dda6832..d35e21687e 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreNonSharedSlice.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreNonSharedSlice.groovy @@ -71,7 +71,8 @@ import javax.ws.rs.NotFoundException class DoAllocateCoreNonSharedSlice extends AbstractServiceTaskProcessor { String Prefix="DACNSNSSI_" - private static final Logger logger = LoggerFactory.getLogger( DoAllocateCoreNonSharedSlice.class); + private static final Logger logger = LoggerFactory.getLogger( DoAllocateCoreNonSharedSlice.class) + private static final ObjectMapper objectMapper = new ObjectMapper() private CatalogDbUtils catalogDbUtils = new CatalogDbUtilsFactory().create() private RequestDBUtil requestDBUtil = new RequestDBUtil() private ExceptionUtil exceptionUtil = new ExceptionUtil() @@ -153,7 +154,6 @@ class DoAllocateCoreNonSharedSlice extends AbstractServiceTaskProcessor { //extAPI path hardcoded for testing purposes, will be updated in next patch String extAPIPath = "https://nbi.onap:8443/nbi/api/v4" + "/serviceOrder" execution.setVariable("ExternalAPIURL", extAPIPath) - ObjectMapper objectMapper = new ObjectMapper(); Map serviceOrder = new LinkedHashMap() //ExternalId serviceOrder.put("externalId", "ONAP001") @@ -223,7 +223,6 @@ class DoAllocateCoreNonSharedSlice extends AbstractServiceTaskProcessor { private List retrieveServiceCharacteristicsAsKeyValue(DelegateExecution execution, Map serviceCharacteristics) { logger.debug(Prefix+ " **** Enter DoAllocateCoreNonSharedSlice ::: retrieveServiceCharacteristicsAsKeyValue ****") List serviceCharacteristicsList = new ArrayList() - ObjectMapper mapperObj = new ObjectMapper(); String vnfInstanceName = execution.getVariable("vnfInstanceName") Map serviceCharacteristicsObject = new LinkedHashMap() for (Map.Entry entry : serviceCharacteristics.entrySet()) { @@ -503,4 +502,4 @@ class DoAllocateCoreNonSharedSlice extends AbstractServiceTaskProcessor { requestDBUtil.prepareUpdateResourceOperationStatus(execution, resourceOperationStatus) logger.debug(Prefix + " **** Exit DoAllocateCoreNonSharedSlice ::: prepareFailedOperationStatusUpdate ****") } -} \ No newline at end of file +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreSharedSlice.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreSharedSlice.groovy index 61528de793..77bc8e2ea0 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreSharedSlice.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreSharedSlice.groovy @@ -70,7 +70,7 @@ class DoAllocateCoreSharedSlice extends AbstractServiceTaskProcessor { private RequestDBUtil requestDBUtil = new RequestDBUtil() private ExceptionUtil exceptionUtil = new ExceptionUtil() private JsonUtils jsonUtil = new JsonUtils() - ObjectMapper mapper = new ObjectMapper(); + private static final ObjectMapper mapper = new ObjectMapper() private final Long TIMEOUT = 60 * 60 * 1000 @@ -677,4 +677,3 @@ class DoAllocateCoreSharedSlice extends AbstractServiceTaskProcessor { logger.debug(Prefix + " **** Exit DoAllocateCoreSharedSlice ::: prepareFailedOperationStatusUpdate ****") } } - diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSSI.groovy index fc873be28e..f79cdb15e8 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSSI.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSSI.groovy @@ -23,19 +23,16 @@ import org.slf4j.LoggerFactory class DoAllocateNSSI extends AbstractServiceTaskProcessor { private static final Logger logger = LoggerFactory.getLogger(DoAllocateNSSI.class); + private static final ObjectMapper mapper = new ObjectMapper() + private static final NSSMF_ALLOCATE_URL = "/api/rest/provMns/v1/NSS/SliceProfiles" + private static final NSSMF_QUERY_JOB_STATUS_URL = "/api/rest/provMns/v1/NSS/jobs/%s" ExceptionUtil exceptionUtil = new ExceptionUtil() JsonUtils jsonUtil = new JsonUtils() - ObjectMapper objectMapper = new ObjectMapper() - private NssmfAdapterUtils nssmfAdapterUtils = new NssmfAdapterUtils(httpClientFactory, jsonUtil) - private static final NSSMF_ALLOCATE_URL = "/api/rest/provMns/v1/NSS/SliceProfiles" - - private static final NSSMF_QUERY_JOB_STATUS_URL = "/api/rest/provMns/v1/NSS/jobs/%s" - @Override void preProcessRequest(DelegateExecution execution) { logger.trace("Enter preProcessRequest()") @@ -62,13 +59,13 @@ class DoAllocateNSSI extends AbstractServiceTaskProcessor { */ void sendCreateRequestNSSMF(DelegateExecution execution) { NssmfAdapterNBIRequest nbiRequest = execution.getVariable("nbiRequest") as NssmfAdapterNBIRequest - String nssmfRequest = objectMapper.writeValueAsString(nbiRequest) - logger.debug("sendCreateRequestNSSMF: " + nssmfRequest) + String nssmfRequest = mapper.writeValueAsString(nbiRequest) + logger.debug("sendCreateRequestNSSMF: {}", nssmfRequest) String response = nssmfAdapterUtils.sendPostRequestNSSMF(execution, NSSMF_ALLOCATE_URL, nssmfRequest) if (response != null) { - NssiResponse nssiResponse = objectMapper.readValue(response, NssiResponse.class) + NssiResponse nssiResponse = mapper.readValue(response, NssiResponse.class) execution.setVariable("nssiAllocateResult", nssiResponse) } @@ -97,12 +94,12 @@ class DoAllocateNSSI extends AbstractServiceTaskProcessor { String endpoint = String.format(NSSMF_QUERY_JOB_STATUS_URL, jobId) String response = - nssmfAdapterUtils.sendPostRequestNSSMF(execution, endpoint, objectMapper.writeValueAsString(nbiRequest)) + nssmfAdapterUtils.sendPostRequestNSSMF(execution, endpoint, mapper.writeValueAsString(nbiRequest)) - logger.debug("nssmf response nssiAllocateStatus:" + response) + logger.debug("nssmf response nssiAllocateStatus: {}", response) if (response != null) { - JobStatusResponse jobStatusResponse = objectMapper.readValue(response, JobStatusResponse.class) + JobStatusResponse jobStatusResponse = mapper.readValue(response, JobStatusResponse.class) if (StringUtils.isBlank(nssiId)) { nssiAllocateResult.setNssiId(jobStatusResponse.getResponseDescriptor().getNssiId()) execution.setVariable("nssiAllocateResult", nssiAllocateResult) @@ -134,7 +131,7 @@ class DoAllocateNSSI extends AbstractServiceTaskProcessor { sliceTaskInfo.statusDescription = response.getStatusDescription() updateNssiResult(sliceParams, subnetType, sliceTaskInfo) - execution.setVariable("CSSOT_paramJson", objectMapper.writeValueAsString(sliceParams)) + execution.setVariable("CSSOT_paramJson", mapper.writeValueAsString(sliceParams)) execution.setVariable("CSSOT_requestMethod", requestMethod) execution.setVariable("sliceTaskParams", sliceParams) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCommonCoreNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCommonCoreNSSI.groovy index a28dbbf9b1..c351c1a300 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCommonCoreNSSI.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCommonCoreNSSI.groovy @@ -55,6 +55,7 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor { private static final String SLICE_PROFILE_TEMPLATE = "{\"sliceProfileId\": \"%s\"}" private static final Logger LOGGER = LoggerFactory.getLogger( DoCommonCoreNSSI.class) + private static final ObjectMapper mapper = new ObjectMapper() private JsonUtils jsonUtil = new JsonUtils() private ExceptionUtil exceptionUtil = new ExceptionUtil() @@ -94,7 +95,7 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor { // Slice Profile String sliceProfile = execution.getVariable("sliceParams") - + /* if(jsonUtil.jsonValueExists(execution.getVariable("sliceParams"), "sliceProfile")) { sliceProfile = jsonUtil.getJsonValue(execution.getVariable("sliceParams"), "sliceProfile") } @@ -624,8 +625,6 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor { serviceVnfs = jsonUtil.getJsonValue(json, "serviceResources.serviceVnfs") ?: "" - ObjectMapper mapper = new ObjectMapper() - List vnfList = mapper.readValue(serviceVnfs, List.class) LOGGER.debug("vnfList: "+vnfList) @@ -765,12 +764,7 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor { snssaiList.add(snssaisMap) } - // Map>> supportedNssaiDetails = new HashMap<>() - // supportedNssaiDetails.put("sNssai", supportedNssaiDetails) - - ObjectMapper mapper = new ObjectMapper() - - Map nSsai= new LinkedHashMap<>() + Map nSsai = new LinkedHashMap<>() nSsai.put("sNssai", snssaiList) // String supportedsNssaiJson = mapper.writeValueAsString(snssaiList) @@ -1017,8 +1011,6 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor { Map requestDetailsMap = new LinkedHashMap<>() requestDetailsMap.put("requestDetails", requestDetails) - ObjectMapper mapper = new ObjectMapper() - response = mapper.writeValueAsString(requestDetailsMap) } catch (any) { diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy index d1e61ac174..ae504ac3c5 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy @@ -79,7 +79,13 @@ import com.fasterxml.jackson.databind.SerializationFeature * */ public class DoCreateE2EServiceInstance extends AbstractServiceTaskProcessor { - private static final Logger logger = LoggerFactory.getLogger( DoCreateE2EServiceInstance.class) + private static final Logger logger = LoggerFactory.getLogger( DoCreateE2EServiceInstance.class) + private static final ObjectMapper mapper + + static { + mapper = new ObjectMapper() + mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, true) + } String Prefix="DCRESI_" @@ -376,8 +382,6 @@ public class DoCreateE2EServiceInstance extends AbstractServiceTaskProcessor { } private static T getJsonObject(String jsonstr, Class type) { - ObjectMapper mapper = new ObjectMapper() - mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, true) try { return mapper.readValue(jsonstr, type) } catch (IOException e) { diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModule.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModule.groovy index f19d064c8e..8439a636b4 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModule.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModule.groovy @@ -76,7 +76,9 @@ import com.fasterxml.jackson.databind.ObjectMapper public class DoCreateVfModule extends VfModuleBase { - private static final Logger logger = LoggerFactory.getLogger( DoCreateVfModule.class); + private static final Logger logger = LoggerFactory.getLogger(DoCreateVfModule.class) + private static final ObjectMapper mapper = new ObjectMapper() + private final HttpClientFactory httpClientFactory = new HttpClientFactory() String Prefix="DCVFM_" ExceptionUtil exceptionUtil = new ExceptionUtil() @@ -85,7 +87,6 @@ public class DoCreateVfModule extends VfModuleBase { OofInfraUtils oofInfraUtils = new OofInfraUtils() CatalogDbUtils catalogDbUtils = new CatalogDbUtilsFactory().create() DecomposeJsonUtil decomposeJsonUtils = new DecomposeJsonUtil() - private final HttpClientFactory httpClientFactory = new HttpClientFactory() /** * Validates the request message and sets up the workflow. @@ -2095,8 +2096,7 @@ public class DoCreateVfModule extends VfModuleBase { if (vnfObject != null) { String vnfJson = vnfObject.toString() // - ObjectMapper om = new ObjectMapper(); - VnfResource vnf = om.readValue(vnfJson, VnfResource.class); + VnfResource vnf = mapper.readValue(vnfJson, VnfResource.class); // Get multiStageDesign flag diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeAllocateAccessNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeAllocateAccessNSSI.groovy index 5b65e08fe1..c43a961c3c 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeAllocateAccessNSSI.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeAllocateAccessNSSI.groovy @@ -70,9 +70,9 @@ class DoDeAllocateAccessNSSI extends AbstractServiceTaskProcessor { RequestDBUtil requestDBUtil = new RequestDBUtil() JsonUtils jsonUtil = new JsonUtils() OofUtils oofUtils = new OofUtils() - ObjectMapper objectMapper = new ObjectMapper() + private static final ObjectMapper objectMapper = new ObjectMapper() private NssmfAdapterUtils nssmfAdapterUtils = new NssmfAdapterUtils(httpClientFactory, jsonUtil) - + private static final Logger logger = LoggerFactory.getLogger(DoDeAllocateAccessNSSI.class) private static final String ROLE_SLICE_PROFILE = "slice-profile-instance" private static final String ROLE_NSSI = "nssi" @@ -133,7 +133,7 @@ class DoDeAllocateAccessNSSI extends AbstractServiceTaskProcessor { execution.setVariable("IsRANNfAlonePresent", true) } } - + /** * @param execution @@ -150,12 +150,12 @@ class DoDeAllocateAccessNSSI extends AbstractServiceTaskProcessor { logger.debug("Finish prepareOOFTerminationRequest") } - + void performOofAnNSSITerminationCall(DelegateExecution execution) { boolean terminateAnNSSI = callOofAdapter(execution,execution.getVariable("oofAnNssiPayload")) execution.setVariable("terminateAnNSSI", terminateAnNSSI) } - + /** * @param execution */ @@ -182,7 +182,7 @@ class DoDeAllocateAccessNSSI extends AbstractServiceTaskProcessor { execution.setVariable("modifyAction","deallocate") } } - + void prepareSdnrRequest(DelegateExecution execution) { String anNfNssiId = execution.getVariable("anNfNssiId") @@ -234,7 +234,7 @@ class DoDeAllocateAccessNSSI extends AbstractServiceTaskProcessor { execution.setVariable("SDNR_timeout", "PT10M") } - + void processSdnrResponse(DelegateExecution execution) { logger.debug("${Prefix} processing SdnrResponse") Map resMap = objectMapper.readValue(execution.getVariable("SDNR_Response"),Map.class) @@ -248,7 +248,7 @@ class DoDeAllocateAccessNSSI extends AbstractServiceTaskProcessor { } logger.debug("${Prefix} processed SdnrResponse") } - + /** * @param execution * @param oofRequest - Request payload to be sent to adapter @@ -280,7 +280,7 @@ class DoDeAllocateAccessNSSI extends AbstractServiceTaskProcessor { return terminateResponse } } - + void deallocateAnNfNssi(DelegateExecution execution) { logger.debug("${Prefix} - call deallocateAnNfNssi ") String anNfNssiId = getInstanceIdByWorkloadContext(execution.getVariable("relatedNssis"), AN_NF) @@ -295,7 +295,7 @@ class DoDeAllocateAccessNSSI extends AbstractServiceTaskProcessor { client.delete(uri) } } - + /** * Removes relationship between AN NSSI and AN_NF NSSI * @param execution @@ -314,7 +314,7 @@ class DoDeAllocateAccessNSSI extends AbstractServiceTaskProcessor { client.delete(uri) } } - + /** * Method to prepare request for AN NSSI modification * Call Modify AN NSSI in case OOF sends Terminate NSSI=False @@ -380,7 +380,7 @@ class DoDeAllocateAccessNSSI extends AbstractServiceTaskProcessor { execution.setVariable("isSuccess", false) } } - + void prepareUpdateJobStatus(DelegateExecution execution,String status,String progress,String statusDescription) { String nssiId = execution.getVariable("anNssiId") String jobId = execution.getVariable("jobId") @@ -397,7 +397,7 @@ class DoDeAllocateAccessNSSI extends AbstractServiceTaskProcessor { roStatus.setStatusDescription(statusDescription) requestDBUtil.prepareUpdateResourceOperationStatus(execution, roStatus) } - + void terminateTNFHNssi(DelegateExecution execution) { logger.debug("Start terminateTNFHNssi in ${Prefix}") String nssmfRequest = buildDeallocateNssiRequest(execution, TN_FH) @@ -414,7 +414,7 @@ class DoDeAllocateAccessNSSI extends AbstractServiceTaskProcessor { } logger.debug("Exit terminateTNFHNssi in ${Prefix}") } - + void terminateTNMHNssi(DelegateExecution execution) { logger.debug("Start terminateTNMHNssi in ${Prefix}") String nssmfRequest = buildDeallocateNssiRequest(execution, TN_MH) @@ -431,13 +431,13 @@ class DoDeAllocateAccessNSSI extends AbstractServiceTaskProcessor { } logger.debug("Exit terminateTNMHNssi in ${Prefix}") } - + void deleteRanNfSliceProfileInAAI(DelegateExecution execution) { logger.debug("${Prefix} delete Ran NF SliceProfile In AAI") String spId = execution.getVariable("anNfSliceProfileId") deleteServiceInstanceInAAI(execution, spId) } - + void deleteTNSliceProfileInAAI(DelegateExecution execution) { logger.debug("${Prefix} delete TN FH SliceProfile In AAI") String fhSP = getInstanceIdByWorkloadContext(execution.getVariable("relatedSPs"), TN_FH) @@ -446,13 +446,13 @@ class DoDeAllocateAccessNSSI extends AbstractServiceTaskProcessor { String mhSP = getInstanceIdByWorkloadContext(execution.getVariable("relatedSPs"), TN_MH) deleteServiceInstanceInAAI(execution, mhSP) } - + void deleteANNSSI(DelegateExecution execution) { logger.debug("${Prefix} delete AN NSSI") String nssiId = execution.getVariable("anNssiId") deleteServiceInstanceInAAI(execution, nssiId) } - + /** * Fetches a collection of service instances with the specific role and maps it based on workload context * (AN-NF,TN-FH,TN-MH) @@ -506,7 +506,7 @@ class DoDeAllocateAccessNSSI extends AbstractServiceTaskProcessor { logger.debug("Found ${relatedInstances.size()} ${role} related to ${instanceId} ") return relatedInstances } - + private String getInstanceIdByWorkloadContext(Map instances,String workloadContext ) { String instanceId = instances.get(workloadContext).getServiceInstanceId() if(instanceId == null) { @@ -514,7 +514,7 @@ class DoDeAllocateAccessNSSI extends AbstractServiceTaskProcessor { } return instanceId } - + /** * Method to handle deallocation of RAN NSSI constituents(TN_FH/TN_MH) * @param execution @@ -541,7 +541,7 @@ class DoDeAllocateAccessNSSI extends AbstractServiceTaskProcessor { deallocateNssi.setSnssaiList(sNssaiList) deallocateNssi.setSliceProfileId(relatedSPs.get(serviceFunction).getServiceInstanceId()) - JsonObject esrInfo = new JsonObject() + JsonObject esrInfo = new JsonObject() esrInfo.addProperty("networkType", "tn") esrInfo.addProperty("vendor", "ONAP_internal") @@ -559,9 +559,9 @@ class DoDeAllocateAccessNSSI extends AbstractServiceTaskProcessor { json.add("esrInfo", esrInfo) json.add("serviceInfo", jsonConverter.toJsonTree(serviceInfo)) return json.toString() - + } - + private void deleteServiceInstanceInAAI(DelegateExecution execution,String instanceId) { try { AAIResourcesClient client = getAAIClient() diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateCoreNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateCoreNSSI.groovy index e563471d2a..1b252418c7 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateCoreNSSI.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateCoreNSSI.groovy @@ -53,6 +53,8 @@ import javax.ws.rs.core.Response import static org.onap.so.bpmn.common.scripts.GenericUtils.isBlank class DoDeallocateCoreNSSI extends DoCommonCoreNSSI { + private static final Logger LOGGER = LoggerFactory.getLogger( DoDeallocateCoreNSSI.class) + private static final ObjectMapper mapper = new ObjectMapper() private final String PREFIX ="DoDeallocateCoreNSSI" private final String ACTION = "Deallocate" @@ -61,7 +63,6 @@ class DoDeallocateCoreNSSI extends DoCommonCoreNSSI { private MsoUtils utils = new MsoUtils() private JsonUtils jsonUtil = new JsonUtils() - private static final Logger LOGGER = LoggerFactory.getLogger( DoDeallocateCoreNSSI.class) @Override @@ -275,7 +276,7 @@ class DoDeallocateCoreNSSI extends DoCommonCoreNSSI { //extAPI path hardcoded for testing purposes, will be updated in next patch String extAPIPath = "https://nbi.onap:8443/nbi/api/v4" + "/serviceOrder" execution.setVariable("ExternalAPIURL", extAPIPath) - ObjectMapper objectMapper = new ObjectMapper(); + Map serviceOrder = new LinkedHashMap() //ExternalId serviceOrder.put("externalId", "ONAP001") @@ -332,7 +333,7 @@ class DoDeallocateCoreNSSI extends DoCommonCoreNSSI { List> orderItemList = new ArrayList() orderItemList.add(orderItem) serviceOrder.put("orderItem", orderItemList) - String jsonServiceOrder = objectMapper.writeValueAsString(serviceOrder) + String jsonServiceOrder = mapper.writeValueAsString(serviceOrder) LOGGER.debug("******* ServiceOrder :: "+jsonServiceOrder) execution.setVariable("serviceOrderRequest", jsonServiceOrder) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateNSSI.groovy index daf5f460d8..11e3dd2d8f 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateNSSI.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateNSSI.groovy @@ -42,17 +42,16 @@ import org.slf4j.LoggerFactory import javax.ws.rs.NotFoundException -class DoDeallocateNSSI extends AbstractServiceTaskProcessor -{ +class DoDeallocateNSSI extends AbstractServiceTaskProcessor { + private static final Logger LOGGER = LoggerFactory.getLogger( DoDeallocateNSSI.class) + private static final ObjectMapper mapper = new ObjectMapper() private final String PREFIX ="DoDeallocateNSSI" private ExceptionUtil exceptionUtil = new ExceptionUtil() private JsonUtils jsonUtil = new JsonUtils() - ObjectMapper objectMapper = new ObjectMapper() private RequestDBUtil requestDBUtil = new RequestDBUtil() private NssmfAdapterUtils nssmfAdapterUtils = new NssmfAdapterUtils(httpClientFactory, jsonUtil) - private static final Logger LOGGER = LoggerFactory.getLogger( DoDeallocateNSSI.class) @Override void preProcessRequest(DelegateExecution execution) { @@ -143,7 +142,7 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor } return null } - + /** * send deallocate request to nssmf * @param execution @@ -162,7 +161,7 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor String serviceUuid = currentNSSI['modelVersionId'] String globalSubscriberId = currentNSSI['globalSubscriberId'] String subscriptionServiceType = currentNSSI['serviceType'] - + DeAllocateNssi deAllocateNssi = new DeAllocateNssi() deAllocateNssi.setNsiId(nsiId) deAllocateNssi.setNssiId(nssiId) @@ -170,7 +169,7 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor deAllocateNssi.setSnssaiList(Arrays.asList(snssai)) deAllocateNssi.setScriptName(scriptName) deAllocateNssi.setSliceProfileId(profileId) - + ServiceInfo serviceInfo = new ServiceInfo() serviceInfo.setServiceInvariantUuid(serviceInvariantUuid) serviceInfo.setServiceUuid(serviceUuid) @@ -178,17 +177,17 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor serviceInfo.setNssiId(nssiId) serviceInfo.setGlobalSubscriberId(globalSubscriberId) serviceInfo.setSubscriptionServiceType(subscriptionServiceType) - String serviceInfoString = objectMapper.writeValueAsString(serviceInfo) - + String serviceInfoString = mapper.writeValueAsString(serviceInfo) + EsrInfo esrInfo = getEsrInfo(currentNSSI) - String esrInfoString = objectMapper.writeValueAsString(esrInfo) - + String esrInfoString = mapper.writeValueAsString(esrInfo) + execution.setVariable("deAllocateNssi",deAllocateNssi) execution.setVariable("esrInfo", esrInfoString) execution.setVariable("serviceInfo", serviceInfoString) String nssmfRequest = """ { - "deAllocateNssi": ${objectMapper.writeValueAsString(deAllocateNssi)}, + "deAllocateNssi": ${mapper.writeValueAsString(deAllocateNssi)}, "esrInfo": ${esrInfoString}, "serviceInfo": ${serviceInfoString} } @@ -198,9 +197,9 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor NssiResponse nssmfResponse = nssmfAdapterUtils.sendPostRequestNSSMF(execution, urlStr, nssmfRequest, NssiResponse.class) if (nssmfResponse != null) { - currentNSSI['jobId']= nssmfResponse.getJobId() ?: "" - currentNSSI['jobProgress'] = 0 - execution.setVariable("currentNSSI", currentNSSI) + currentNSSI['jobId']= nssmfResponse.getJobId() ?: "" + currentNSSI['jobProgress'] = 0 + execution.setVariable("currentNSSI", currentNSSI) } else { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Received a Bad Response from NSSMF.") } @@ -218,14 +217,14 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor execution.setVariable("jobId", jobId) } - + /** * send to nssmf query progress * @param execution */ void handleJobStatus(DelegateExecution execution) { - try + try { String jobStatusResponse = execution.getVariable("responseDescriptor") String status = jsonUtil.getJsonValue(jobStatusResponse,"status") @@ -269,7 +268,7 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor { NetworkType domainType = currentNSSI['domainType'] String vendor = currentNSSI['vendor'] - + EsrInfo info = new EsrInfo() info.setNetworkType(domainType) info.setVendor(vendor) @@ -300,7 +299,7 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor requestDBUtil.prepareUpdateOperationStatus(execution, operationStatus) LOGGER.debug("update operation, currentProgress=${currentProgress}, proportion=${proportion}, progress = ${progress}" ) } - + /** * delete slice profile from aai * @param execution diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateTnNssi.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateTnNssi.groovy index ea4c29b202..763e644408 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateTnNssi.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateTnNssi.groovy @@ -49,6 +49,8 @@ import static org.apache.commons.lang3.StringUtils.isBlank import static org.apache.commons.lang3.StringUtils.isEmpty class DoDeallocateTnNssi extends AbstractServiceTaskProcessor { + private static final Logger logger = LoggerFactory.getLogger(DoDeallocateTnNssi.class) + private static final ObjectMapper objectMapper = new ObjectMapper() String Prefix = "TNDEALLOC_" ExceptionUtil exceptionUtil = new ExceptionUtil() @@ -57,8 +59,6 @@ class DoDeallocateTnNssi extends AbstractServiceTaskProcessor { TnNssmfUtils tnNssmfUtils = new TnNssmfUtils() OofUtils oofUtils = new OofUtils() JsonSlurper jsonSlurper = new JsonSlurper() - ObjectMapper objectMapper = new ObjectMapper() - private static final Logger logger = LoggerFactory.getLogger(DoDeallocateTnNssi.class) void preProcessRequest(DelegateExecution execution) { diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteSliceService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteSliceService.groovy index 7dc63b61ed..6154d0b168 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteSliceService.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteSliceService.groovy @@ -59,10 +59,11 @@ import static org.apache.commons.lang3.StringUtils.isBlank * */ class DoDeleteSliceService extends AbstractServiceTaskProcessor { + private static final Logger LOGGER = LoggerFactory.getLogger(DoDeleteSliceService.class) + private static final ObjectMapper mapper = new ObjectMapper() private final String PREFIX ="DoDeleteSliceService" ExceptionUtil exceptionUtil = new ExceptionUtil() OofUtils oofUtils = new OofUtils() - private static final Logger LOGGER = LoggerFactory.getLogger( DoDeleteSliceService.class) @Override void preProcessRequest(DelegateExecution execution) { @@ -415,7 +416,7 @@ class DoDeleteSliceService extends AbstractServiceTaskProcessor { String nxlType = "NSI" String messageType = "nsiTerminationResponse" String serviceInstanceId = execution.getVariable("serviceInstanceId") - + def authHeader = "" String basicAuth = UrnPropertiesReader.getVariable("mso.oof.auth", execution) String msokey = UrnPropertiesReader.getVariable("mso.msoKey", execution) @@ -440,10 +441,9 @@ class DoDeleteSliceService extends AbstractServiceTaskProcessor { URL requestUrl = new URL(oofUrl) String oofRequest = oofUtils.buildTerminateNxiRequest(requestId, nxlId, nxlType, messageType, serviceInstanceId) OofRequest oofPayload = new OofRequest() - oofPayload.setApiPath("/api/oof/terminate/nxi/v1") - oofPayload.setRequestDetails(oofRequest) - ObjectMapper objectMapper = new ObjectMapper() - String requestJson = objectMapper.writeValueAsString(oofPayload) + oofPayload.setApiPath("/api/oof/terminate/nxi/v1") + oofPayload.setRequestDetails(oofRequest) + String requestJson = mapper.writeValueAsString(oofPayload) HttpClient httpClient = new HttpClientFactory().newJsonClient(requestUrl, ONAPComponents.OOF) httpClient.addAdditionalHeader("Authorization", authHeader) Response httpResponse = httpClient.post(requestJson) @@ -453,7 +453,7 @@ class DoDeleteSliceService extends AbstractServiceTaskProcessor { if(responseCode != 200){ exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from OOF.") - } + } try { Map resMap = httpResponse.readEntity(Map.class) boolean terminateResponse = resMap.get("terminateResponse") diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyAccessNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyAccessNSSI.groovy index a08eb570c9..d25ffdc38c 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyAccessNSSI.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyAccessNSSI.groovy @@ -65,17 +65,24 @@ import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.T import javax.ws.rs.NotFoundException class DoModifyAccessNSSI extends AbstractServiceTaskProcessor { + private static final Logger logger = LoggerFactory.getLogger(DoModifyAccessNSSI.class) + private static final ObjectMapper mapper = new ObjectMapper() + private static final ObjectMapper loggerMapper + + static { + loggerMapper = new ObjectMapper() + loggerMapper.enable(SerializationFeature.INDENT_OUTPUT) + loggerMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL) + } String Prefix="MASS_" ExceptionUtil exceptionUtil = new ExceptionUtil() RequestDBUtil requestDBUtil = new RequestDBUtil() JsonUtils jsonUtil = new JsonUtils() OofUtils oofUtils = new OofUtils() - ObjectMapper objectMapper = new ObjectMapper(); AnNssmfUtils anNssmfUtils = new AnNssmfUtils() private NssmfAdapterUtils nssmfAdapterUtils = new NssmfAdapterUtils(httpClientFactory, jsonUtil) - private static final Logger logger = LoggerFactory.getLogger(DoModifyAccessNSSI.class) @Override void preProcessRequest(DelegateExecution execution) { @@ -122,11 +129,11 @@ class DoModifyAccessNSSI extends AbstractServiceTaskProcessor { exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Invalid modify Action : "+modifyAction) } } - String modelUuid = execution.getVariable("modelUuid") - if (isBlank(modelUuid)) { - modelUuid = anNssmfUtils.getModelUuid(execution, execution.getVariable("serviceInstanceID")) - } - execution.setVariable("modelUuid",modelUuid) + String modelUuid = execution.getVariable("modelUuid") + if (isBlank(modelUuid)) { + modelUuid = anNssmfUtils.getModelUuid(execution, execution.getVariable("serviceInstanceID")) + } + execution.setVariable("modelUuid",modelUuid) List snssaiList = jsonUtil.StringArrayToList(jsonUtil.getJsonValue(sliceParams, "snssaiList")) String sliceProfileId = jsonUtil.getJsonValue(sliceParams, "sliceProfileId") if (isBlank(sliceProfileId) || (snssaiList.empty)) { @@ -152,7 +159,7 @@ class DoModifyAccessNSSI extends AbstractServiceTaskProcessor { } logger.debug(Prefix + "preProcessRequest Exit") } - + def getSliceProfile = { DelegateExecution execution -> logger.debug(Prefix + "getSliceProfiles Start") String instanceId = execution.getVariable("sliceProfileId") @@ -166,23 +173,22 @@ class DoModifyAccessNSSI extends AbstractServiceTaskProcessor { .serviceSubscription(subscriptionServiceType) .serviceInstance(instanceId) .sliceProfiles()) - - if (!client.exists(uri)) { + + if (!client.exists(uri)) { exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Slice Profiles of service Instance was not found in aai : ${instanceId}") } AAIResultWrapper wrapper = client.get(uri, NotFoundException.class) Optional si = wrapper.asBean(SliceProfiles.class) if(si.isPresent()) { - ranSliceProfile = si.get().getSliceProfile().get(0) + ranSliceProfile = si.get().getSliceProfile().get(0) } - objectMapper.enable(SerializationFeature.INDENT_OUTPUT); - objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL) - logger.debug("RAN slice profile : "+objectMapper.writeValueAsString(ranSliceProfile)) - execution.setVariable("RANSliceProfile", objectMapper.writeValueAsString(ranSliceProfile)) + + logger.debug("RAN slice profile : {}", loggerMapper.writeValueAsString(ranSliceProfile)) + execution.setVariable("RANSliceProfile", loggerMapper.writeValueAsString(ranSliceProfile)) execution.setVariable("ranSliceProfileInstance", sliceProfileInstance) } - + /* * Function to subnet capabilities from nssmf adapter */ @@ -219,7 +225,7 @@ class DoModifyAccessNSSI extends AbstractServiceTaskProcessor { } } - + /* * prepare OOF request for RAN NSSI selection */ @@ -233,33 +239,33 @@ class DoModifyAccessNSSI extends AbstractServiceTaskProcessor { boolean ranNssiPreferReuse = execution.getVariable("ranNssiPreferReuse"); String requestId = execution.getVariable("msoRequestId") String messageType = "NSISelectionResponse" - Map profileInfo = objectMapper.readValue(execution.getVariable("RANSliceProfile"), Map.class) - ServiceInstance ranSliceProfileInstance = execution.getVariable("ranSliceProfileInstance") - profileInfo.put("sST",ranSliceProfileInstance.getServiceType()) - profileInfo.put("snssaiList",execution.getVariable("snssaiList")) - profileInfo.put("pLMNIdList",Arrays.asList(ranSliceProfileInstance.getServiceInstanceLocationId())) - profileInfo.put("uEMobilityLevel",profileInfo.get("ueMobilityLevel")) - profileInfo.put("cSAvailabilityTarget",profileInfo.get("csAvailabilityTarget")) - profileInfo.put("maxNumberofPDUSession",profileInfo.get("maxNumberOfPDUSession")) - profileInfo.put("maxNumberofUEs",profileInfo.get("maxNumberOfUEs")) - - PerfReq perfReq = new PerfReq(); - List perfReqEmbbs = new ArrayList<>(); - PerfReqEmbb perfReqEmbb = new PerfReqEmbb(); - perfReqEmbb.setExpDataRateDL(profileInfo.get("expDataRateDL")); - perfReqEmbb.setExpDataRateUL(profileInfo.get("expDataRateUL")); - perfReqEmbbs.add(perfReqEmbb); - perfReq.setPerfReqEmbbList(perfReqEmbbs); - profileInfo.put("perfReq",perfReq) - - profileInfo.remove("maxNumberOfUEs") - profileInfo.remove("resourceVersion") - profileInfo.remove("csAvailabilityTarget") - profileInfo.remove("ueMobilityLevel") - profileInfo.remove("maxNumberOfPDUSession") - profileInfo.remove("profileId") - String modelUuid = ranSliceProfileInstance.getModelVersionId() - String modelInvariantUuid = ranSliceProfileInstance.getModelInvariantId() + Map profileInfo = mapper.readValue(execution.getVariable("RANSliceProfile"), Map.class) + ServiceInstance ranSliceProfileInstance = execution.getVariable("ranSliceProfileInstance") + profileInfo.put("sST",ranSliceProfileInstance.getServiceType()) + profileInfo.put("snssaiList",execution.getVariable("snssaiList")) + profileInfo.put("pLMNIdList",Arrays.asList(ranSliceProfileInstance.getServiceInstanceLocationId())) + profileInfo.put("uEMobilityLevel",profileInfo.get("ueMobilityLevel")) + profileInfo.put("cSAvailabilityTarget",profileInfo.get("csAvailabilityTarget")) + profileInfo.put("maxNumberofPDUSession",profileInfo.get("maxNumberOfPDUSession")) + profileInfo.put("maxNumberofUEs",profileInfo.get("maxNumberOfUEs")) + + PerfReq perfReq = new PerfReq(); + List perfReqEmbbs = new ArrayList<>(); + PerfReqEmbb perfReqEmbb = new PerfReqEmbb(); + perfReqEmbb.setExpDataRateDL(profileInfo.get("expDataRateDL")); + perfReqEmbb.setExpDataRateUL(profileInfo.get("expDataRateUL")); + perfReqEmbbs.add(perfReqEmbb); + perfReq.setPerfReqEmbbList(perfReqEmbbs); + profileInfo.put("perfReq",perfReq) + + profileInfo.remove("maxNumberOfUEs") + profileInfo.remove("resourceVersion") + profileInfo.remove("csAvailabilityTarget") + profileInfo.remove("ueMobilityLevel") + profileInfo.remove("maxNumberOfPDUSession") + profileInfo.remove("profileId") + String modelUuid = ranSliceProfileInstance.getModelVersionId() + String modelInvariantUuid = ranSliceProfileInstance.getModelInvariantId() String modelName = execution.getVariable("servicename") String timeout = UrnPropertiesReader.getVariable("mso.adapters.oof.timeout", execution); List nsstInfoList = new ArrayList<>() @@ -270,7 +276,7 @@ class DoModifyAccessNSSI extends AbstractServiceTaskProcessor { JsonObject FH = new JsonObject() JsonObject MH = new JsonObject() JsonObject ANNF = new JsonObject() - FH.addProperty("domainType", "TN_FH") + FH.addProperty("domainType", "TN_FH") FH.add("capabilityDetails", (JsonObject) parser.parse(FHCapabilities)) MH.addProperty("domainType", "TN_MH") MH.add("capabilityDetails", (JsonObject) parser.parse(MHCapabilities)) @@ -288,9 +294,9 @@ class DoModifyAccessNSSI extends AbstractServiceTaskProcessor { modelName, profileInfo, nsstInfoList, capabilitiesList, ranNssiPreferReuse) execution.setVariable("nssiSelection_oofRequest",oofRequest) - logger.debug("Sending request to OOF: " + oofRequest) + logger.debug("Sending request to OOF: {}", oofRequest) } - + /* * process OOF response for RAN NSSI selection */ @@ -299,20 +305,20 @@ class DoModifyAccessNSSI extends AbstractServiceTaskProcessor { String oofResponse = execution.getVariable("nssiSelection_asyncCallbackResponse") String requestStatus = jsonUtil.getJsonValue(oofResponse, "requestStatus") if(requestStatus.equals("completed")) { - String solutions = jsonUtil.getJsonValue(oofResponse, "solutions") - logger.debug("solutions value : "+solutions) + String solutions = jsonUtil.getJsonValue(oofResponse, "solutions") + logger.debug("solutions value : {}", solutions) JsonParser parser = new JsonParser() JsonArray solution = parser.parse(solutions) boolean existingNSI = solution.get(0).get("existingNSI").getAsBoolean() - logger.debug("existingNSI value : "+existingNSI) + logger.debug("existingNSI value: {}", existingNSI) if(!existingNSI) { - JsonObject newNSISolution = solution.get(0).get("newNSISolution").getAsJsonObject() + JsonObject newNSISolution = solution.get(0).get("newNSISolution").getAsJsonObject() JsonArray sliceProfiles = newNSISolution.get("sliceProfiles") - logger.debug("sliceProfiles: "+ sliceProfiles.toString()) + logger.debug("sliceProfiles: {}", sliceProfiles.toString()) execution.setVariable("RanConstituentSliceProfiles", sliceProfiles.toString()) List ranConstituentSliceProfiles = jsonUtil.StringArrayToList(sliceProfiles.toString()) anNssmfUtils.createDomainWiseSliceProfiles(ranConstituentSliceProfiles, execution) - logger.debug("RanConstituentSliceProfiles list from OOF "+sliceProfiles) + logger.debug("RanConstituentSliceProfiles list from OOF {}", sliceProfiles) }else { String statusMessage = jsonUtil.getJsonValue(oofResponse, "statusMessage") logger.error("failed to get slice profiles from oof "+ statusMessage) @@ -330,8 +336,8 @@ class DoModifyAccessNSSI extends AbstractServiceTaskProcessor { String instanceId = execution.getVariable("serviceInstanceID") String role = "nssi" Map ranConstituentNssis = getRelatedInstancesByRole(execution, role, instanceId) - logger.debug("getNssisFromAai ranConstituentNssis : "+ranConstituentNssis.toString()) - ranConstituentNssis.each { key, val -> + logger.debug("getNssisFromAai ranConstituentNssis: {}", ranConstituentNssis.toString()) + ranConstituentNssis.each { key, val -> switch(key) { case "AN_NF": execution.setVariable("ANNF_NSSI", val.getServiceInstanceId()) @@ -358,51 +364,48 @@ class DoModifyAccessNSSI extends AbstractServiceTaskProcessor { exceptionUtil.buildAndThrowWorkflowException(execution, 1000,"No expected match found for current domainType "+ key) } } - + } - private void getConnectionLinks(DelegateExecution execution, String domainType, ServiceInstance instance) { - AllottedResources allottedResources = instance.getAllottedResources() - if(allottedResources == null) { - String msg = "AllottedResourceFromAAI doesn't exist. " + instance - logger.debug(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } + private void getConnectionLinks(DelegateExecution execution, String domainType, ServiceInstance instance) { + AllottedResources allottedResources = instance.getAllottedResources() + if(allottedResources == null) { + String msg = "AllottedResourceFromAAI doesn't exist. " + instance + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } - List AllottedResourceList = allottedResources.getAllottedResource() - for(AllottedResource allottedResource : AllottedResourceList) { - List relationshipList = allottedResource.getRelationshipList().getRelationship() - for (Relationship relationship : relationshipList) { - String relatedTo = relationship.getRelatedTo() - if (relatedTo.toLowerCase() == "logical-link") { - String relatioshipurl = relationship.getRelatedLink() - String logicalLinkId= - relatioshipurl.substring(relatioshipurl.lastIndexOf("/") + 1, relatioshipurl.length()) - AAIResourcesClient client = new AAIResourcesClient() - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().logicalLink(logicalLinkId)) - if (!client.exists(uri)) { - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, - "Resource was not found in aai: ${logicalLinkId}") - } - AAIResultWrapper wrapper01 = client.get(uri, NotFoundException.class) - Optional resource = wrapper01.asBean(org.onap.aai.domain.yang.LogicalLink.class) - if (resource.isPresent()) { - org.onap.aai.domain.yang.LogicalLink logicalLinkInstance = resource.get() - if(domainType.equalsIgnoreCase("TN_FH")) - { - execution.setVariable("tranportEp_ID_RU",logicalLinkInstance.getLinkName()) - execution.setVariable("tranportEp_ID_DUIN",logicalLinkInstance.getLinkName2()) - } - else if(domainType.equalsIgnoreCase("TN_MH")) - { - execution.setVariable("tranportEp_ID_DUEG",logicalLinkInstance.getLinkName()) - execution.setVariable("tranportEp_ID_CUIN",logicalLinkInstance.getLinkName2()) - } - } - } - } - } - } + List AllottedResourceList = allottedResources.getAllottedResource() + for(AllottedResource allottedResource : AllottedResourceList) { + List relationshipList = allottedResource.getRelationshipList().getRelationship() + for (Relationship relationship : relationshipList) { + String relatedTo = relationship.getRelatedTo() + if (relatedTo.toLowerCase() == "logical-link") { + String relatioshipurl = relationship.getRelatedLink() + String logicalLinkId= + relatioshipurl.substring(relatioshipurl.lastIndexOf("/") + 1, relatioshipurl.length()) + AAIResourcesClient client = new AAIResourcesClient() + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().logicalLink(logicalLinkId)) + if (!client.exists(uri)) { + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, + "Resource was not found in aai: ${logicalLinkId}") + } + AAIResultWrapper wrapper01 = client.get(uri, NotFoundException.class) + Optional resource = wrapper01.asBean(org.onap.aai.domain.yang.LogicalLink.class) + if (resource.isPresent()) { + org.onap.aai.domain.yang.LogicalLink logicalLinkInstance = resource.get() + if(domainType.equalsIgnoreCase("TN_FH")) { + execution.setVariable("tranportEp_ID_RU",logicalLinkInstance.getLinkName()) + execution.setVariable("tranportEp_ID_DUIN",logicalLinkInstance.getLinkName2()) + } else if(domainType.equalsIgnoreCase("TN_MH")) { + execution.setVariable("tranportEp_ID_DUEG",logicalLinkInstance.getLinkName()) + execution.setVariable("tranportEp_ID_CUIN",logicalLinkInstance.getLinkName2()) + } + } + } + } + } + } def createSliceProfiles = { DelegateExecution execution -> logger.debug(Prefix+"createSliceProfiles method start") @@ -425,11 +428,11 @@ class DoModifyAccessNSSI extends AbstractServiceTaskProcessor { Relationship ANNF_relationship = new Relationship() Relationship TNFH_relationship = new Relationship() Relationship TNMH_relationship = new Relationship() - + String ANNF_relatedLink = "aai/v16/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${subscriptionServiceType}/service-instances/service-instance/${ANNF_profileInstanceId}" String TNFH_relatedLink = "aai/v16/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${subscriptionServiceType}/service-instances/service-instance/${TNFH_profileInstanceId}" String TNMH_relatedLink = "aai/v16/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${subscriptionServiceType}/service-instances/service-instance/${TNMH_profileInstanceId}" - + ANNF_relationship.setRelatedLink(ANNF_relatedLink) ANNF_relationship.setRelatedTo("service-instance") ANNF_relationship.setRelationshipLabel("org.onap.relationships.inventory.ComposedOf") @@ -439,7 +442,7 @@ class DoModifyAccessNSSI extends AbstractServiceTaskProcessor { TNMH_relationship.setRelatedLink(TNMH_relatedLink) TNMH_relationship.setRelatedTo("service-instance") TNMH_relationship.setRelationshipLabel("org.onap.relationships.inventory.ComposedOf") - + // create SliceProfile and NSSI relationship in AAI anNssmfUtils.createRelationShipInAAI(execution, ANNF_relationship,ANNF_serviceInstanceId) anNssmfUtils.createRelationShipInAAI(execution, TNFH_relationship,TNFH_serviceInstanceId) @@ -457,12 +460,12 @@ class DoModifyAccessNSSI extends AbstractServiceTaskProcessor { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) } } - + def processRanNfModifyRsp = { DelegateExecution execution -> logger.debug(Prefix+"processRanNfModifyRsp method start") anNssmfUtils.processRanNfModifyRsp(execution) } - + def prepareTnFhRequest = { DelegateExecution execution -> logger.debug(Prefix+"prepareTnFhRequest method start") @@ -498,26 +501,26 @@ class DoModifyAccessNSSI extends AbstractServiceTaskProcessor { } logger.debug("Exit prepareTnMhRequest") } - + def createFhAllocateNssiJobQuery = { DelegateExecution execution -> logger.debug(Prefix+"createModifyNssiQueryJobStatus method start") createTnAllocateNssiJobQuery(execution, "TN_FH") } - + def createMhAllocateNssiJobQuery = { DelegateExecution execution -> logger.debug(Prefix+"createModifyNssiQueryJobStatus method start") createTnAllocateNssiJobQuery(execution, "TN_MH") } - + private void createTnAllocateNssiJobQuery(DelegateExecution execution, String domainType) { JsonObject esrInfo = new JsonObject() esrInfo.addProperty("networkType", "tn") esrInfo.addProperty("vendor", "ONAP_internal") execution.setVariable("esrInfo", esrInfo.toString()) JsonObject serviceInfo = new JsonObject() - + serviceInfo.addProperty("nsiId", execution.getVariable("nsiId")) - serviceInfo.addProperty("PLMNIdList", objectMapper.writeValueAsString(execution.getVariable("plmnIdList"))) + serviceInfo.addProperty("PLMNIdList", mapper.writeValueAsString(execution.getVariable("plmnIdList"))) serviceInfo.addProperty("globalSubscriberId", execution.getVariable("globalSubscriberId")) serviceInfo.addProperty("subscriptionServiceType", execution.getVariable("subscriptionServiceType")) if(domainType.equals("TN_FH")) { @@ -534,7 +537,7 @@ class DoModifyAccessNSSI extends AbstractServiceTaskProcessor { execution.setVariable("serviceInfo", serviceInfo.toString()) execution.setVariable("responseId", "") } - + def processFhAllocateNssiJobStatusRsp = { DelegateExecution execution -> logger.debug(Prefix+"processJobStatusRsp method start") String jobResponse = execution.getVariable("TNFH_jobResponse") @@ -566,7 +569,7 @@ class DoModifyAccessNSSI extends AbstractServiceTaskProcessor { exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"received failed status from job status query for nssi : "+nssi+" with status description : "+ statusDescription) } } - + def getSliceProfilesFromAai = { DelegateExecution execution -> logger.debug(Prefix+"getSliceProfilesFromAai method start") String instanceId = execution.getVariable("sliceProfileId") @@ -590,7 +593,7 @@ class DoModifyAccessNSSI extends AbstractServiceTaskProcessor { } } } - + def prepareTnFhDeallocateRequest = { DelegateExecution execution -> logger.debug(Prefix+"prepareTnFhDeallocateRequest method start") String nssmfRequest = anNssmfUtils.buildDeallocateNssiRequest(execution, "TN_FH") @@ -606,7 +609,7 @@ class DoModifyAccessNSSI extends AbstractServiceTaskProcessor { exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"Received a Bad Sync Response from NSSMF.") } } - + def prepareTnMhDeallocateRequest = { DelegateExecution execution -> logger.debug(Prefix+"prepareTnFhDeallocateRequest method start") String nssmfRequest = anNssmfUtils.buildDeallocateNssiRequest(execution, "TN_MH") @@ -622,12 +625,12 @@ class DoModifyAccessNSSI extends AbstractServiceTaskProcessor { exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"Received a Bad Sync Response from NSSMF.") } } - + def createFhDeAllocateNssiJobQuery = { DelegateExecution execution -> logger.debug(Prefix+"createModifyNssiQueryJobStatus method start") createTnAllocateNssiJobQuery(execution, "TN_FH") } - + def createMhDeAllocateNssiJobQuery = { DelegateExecution execution -> logger.debug(Prefix+"createModifyNssiQueryJobStatus method start") createTnAllocateNssiJobQuery(execution, "TN_MH") @@ -638,7 +641,7 @@ class DoModifyAccessNSSI extends AbstractServiceTaskProcessor { } def deleteMhSliceProfile = { DelegateExecution execution -> logger.debug(Prefix+"deleteMhSliceProfile method start") - deleteServiceInstanceInAAI(execution,execution.getVariable("TNMH_sliceProfileInstanceId")) + deleteServiceInstanceInAAI(execution,execution.getVariable("TNMH_sliceProfileInstanceId")) } def deleteAnSliceProfile = { DelegateExecution execution -> logger.debug(Prefix+"deleteAnSliceProfile method start") @@ -688,7 +691,7 @@ class DoModifyAccessNSSI extends AbstractServiceTaskProcessor { updateStatus.setStatus("failed") requestDBUtil.prepareUpdateResourceOperationStatus(execution, updateStatus) } - + /** * @param execution * @param role - nssi/slice profile instance @@ -699,9 +702,9 @@ class DoModifyAccessNSSI extends AbstractServiceTaskProcessor { logger.debug("${Prefix} - Fetching related ${role} from AAI") String globalSubscriberId = execution.getVariable("globalSubscriberId") String subscriptionServiceType = execution.getVariable("subscriptionServiceType") - + Map relatedInstances = new HashMap<>() - + AAIResourcesClient client = new AAIResourcesClient() AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(instanceId)) if (!client.exists(uri)) { @@ -738,7 +741,7 @@ class DoModifyAccessNSSI extends AbstractServiceTaskProcessor { logger.debug("Found ${relatedInstances.size()} ${role} related to ${instanceId} ") return relatedInstances } - + private ServiceInstance getServiceInstance(DelegateExecution execution, String instanceId) { String globalSubscriberId = execution.getVariable("globalSubscriberId") String subscriptionServiceType = execution.getVariable("subscriptionServiceType") @@ -750,7 +753,7 @@ class DoModifyAccessNSSI extends AbstractServiceTaskProcessor { } AAIResultWrapper wrapper = client.get(uri, NotFoundException.class) Optional si = wrapper.asBean(ServiceInstance.class) - + if(si.isPresent()) { serviceInstance = si.get() } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyCoreNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyCoreNSSI.groovy index 8ae56a310c..c2854dd24b 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyCoreNSSI.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyCoreNSSI.groovy @@ -47,6 +47,8 @@ import static org.apache.commons.lang3.StringUtils.isBlank class DoModifyCoreNSSI extends DoCommonCoreNSSI { + private static final Logger LOGGER = LoggerFactory.getLogger(DoModifyCoreNSSI.class) + private static final ObjectMapper mapper = new ObjectMapper() private final String PREFIX ="DoModifyCoreNSSI" private final String ACTION = "Modify" @@ -55,9 +57,6 @@ class DoModifyCoreNSSI extends DoCommonCoreNSSI { private MsoUtils utils = new MsoUtils() private JsonUtils jsonUtil = new JsonUtils() - private static final Logger LOGGER = LoggerFactory.getLogger( DoModifyCoreNSSI.class) - - @Override void preProcessRequest(DelegateExecution execution) { LOGGER.debug("${getPrefix()} Start preProcessRequest") @@ -102,7 +101,7 @@ class DoModifyCoreNSSI extends DoCommonCoreNSSI { def currentNSSI = execution.getVariable("currentNSSI") String givenSliceProfileId = currentNSSI['sliceProfileId'] //UUID.randomUUID().toString() - Map sliceProfileMap = new ObjectMapper().readValue(currentNSSI['sliceProfile'], Map.class) + Map sliceProfileMap = mapper.readValue(currentNSSI['sliceProfile'], Map.class) SliceProfile sliceProfile = new SliceProfile() sliceProfile.setServiceAreaDimension("") diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyRanNfNssi.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyRanNfNssi.groovy index 10846d4cfa..7a344f4ca2 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyRanNfNssi.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyRanNfNssi.groovy @@ -38,13 +38,13 @@ import org.onap.so.bpmn.core.UrnPropertiesReader class DoModifyRanNfNssi extends AbstractServiceTaskProcessor { + private static final Logger logger = LoggerFactory.getLogger(DoModifyRanNfNssi.class) + private static final ObjectMapper mapper = new ObjectMapper() String Prefix="MANNFNSS_" ExceptionUtil exceptionUtil = new ExceptionUtil() JsonUtils jsonUtil = new JsonUtils() - ObjectMapper objectMapper = new ObjectMapper(); AnNssmfUtils anNssmfUtils = new AnNssmfUtils() - private static final Logger logger = LoggerFactory.getLogger(DoModifyRanNfNssi.class) @Override void preProcessRequest(DelegateExecution execution) { @@ -100,7 +100,7 @@ class DoModifyRanNfNssi extends AbstractServiceTaskProcessor { execution.setVariable("snssaiList", snssaiList) execution.setVariable("snssai", snssaiList.get(0)) } - + } catch(BpmnError e) { throw e } catch(Exception ex) { @@ -110,7 +110,7 @@ class DoModifyRanNfNssi extends AbstractServiceTaskProcessor { } logger.debug(Prefix + "preProcessRequest Exit") } - + def createSdnrRequest = { DelegateExecution execution -> logger.debug(Prefix+"createSdnrRequest method start") String callbackUrl = UrnPropertiesReader.getVariable("mso.workflow.message.endpoint") + "/AsyncSdnrResponse/"+execution.getVariable("msoRequestId") @@ -121,7 +121,7 @@ class DoModifyRanNfNssi extends AbstractServiceTaskProcessor { execution.setVariable("createNSSI_correlator", execution.getVariable("msoRequestId")) execution.setVariable("createNSSI_messageType", "AsyncSdnrResponse"); } - + def processSdnrResponse = { DelegateExecution execution -> logger.debug(Prefix+"processSdnrResponse method start") String SDNRResponse = execution.getVariable("SDNR_asyncCallbackResponse") @@ -137,9 +137,9 @@ class DoModifyRanNfNssi extends AbstractServiceTaskProcessor { } logger.debug("response from SDNR "+SDNRResponse) } - + private String buildSdnrAllocateRequest(DelegateExecution execution, String action, String rpcName, String callbackUrl) { - + String requestId = execution.getVariable("msoRequestId") Instant time = Instant.now() Map sliceProfile = new HashMap<>() @@ -151,7 +151,7 @@ class DoModifyRanNfNssi extends AbstractServiceTaskProcessor { JsonObject payloadInput = new JsonObject() JsonParser parser = new JsonParser() if(action.equals("allocate")) { - sliceProfile = objectMapper.readValue(execution.getVariable("sliceProfile"), Map.class) + sliceProfile = mapper.readValue(execution.getVariable("sliceProfile"), Map.class) sliceProfile.put("sliceProfileId", execution.getVariable("sliceProfileId")) sliceProfile.put("maxNumberofConns", sliceProfile.get("maxNumberofPDUSession")) sliceProfile.put("uLThptPerSlice", sliceProfile.get("expDataRateUL")) @@ -193,5 +193,5 @@ class DoModifyRanNfNssi extends AbstractServiceTaskProcessor { response.addProperty("type", "request") return response.toString() } - + } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyTnNssi.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyTnNssi.groovy index 25cb2f57f6..0092c2517f 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyTnNssi.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyTnNssi.groovy @@ -47,6 +47,8 @@ import static org.apache.commons.lang3.StringUtils.isEmpty import static org.apache.commons.lang3.StringUtils.isNotBlank public class DoModifyTnNssi extends AbstractServiceTaskProcessor { + private static final Logger logger = LoggerFactory.getLogger(DoModifyTnNssi.class) + private static final ObjectMapper mapper = new ObjectMapper() String Prefix = "TNMOD_" ExceptionUtil exceptionUtil = new ExceptionUtil() @@ -54,8 +56,6 @@ public class DoModifyTnNssi extends AbstractServiceTaskProcessor { RequestDBUtil requestDBUtil = new RequestDBUtil() TnNssmfUtils tnNssmfUtils = new TnNssmfUtils() JsonSlurper jsonSlurper = new JsonSlurper() - ObjectMapper objectMapper = new ObjectMapper() - private static final Logger logger = LoggerFactory.getLogger(DoModifyTnNssi.class) void preProcessRequest(DelegateExecution execution) { @@ -532,4 +532,3 @@ public class DoModifyTnNssi extends AbstractServiceTaskProcessor { return logicalLinkNameList.contains(linkName) } } - diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoScaleVFCNetworkServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoScaleVFCNetworkServiceInstance.groovy index 16e1241750..8ca5d81560 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoScaleVFCNetworkServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoScaleVFCNetworkServiceInstance.groovy @@ -61,7 +61,8 @@ import org.onap.logging.filter.base.ONAPComponents; * flow for VFC Network Service Scale */ public class DoScaleVFCNetworkServiceInstance extends AbstractServiceTaskProcessor { - private static final Logger logger = LoggerFactory.getLogger( DoScaleVFCNetworkServiceInstance.class); + private static final Logger logger = LoggerFactory.getLogger( DoScaleVFCNetworkServiceInstance.class) + private static final ObjectMapper mapper = new ObjectMapper() String host = "http://mso.mso.testlab.openecomp.org:8080" @@ -267,7 +268,6 @@ public class DoScaleVFCNetworkServiceInstance extends AbstractServiceTaskProcess * @return */ private String objectToJsonStr(Object obj) { - ObjectMapper mapper = new ObjectMapper() String jsonStr = null try { jsonStr = mapper.writeValueAsString(obj) @@ -340,4 +340,3 @@ public class DoScaleVFCNetworkServiceInstance extends AbstractServiceTaskProcess return nsResourceInputParameterList } } - diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/HandleOrchestrationTask.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/HandleOrchestrationTask.groovy index 0f15717b3c..9c71fa83b3 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/HandleOrchestrationTask.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/HandleOrchestrationTask.groovy @@ -33,6 +33,7 @@ import org.slf4j.LoggerFactory class HandleOrchestrationTask extends AbstractServiceTaskProcessor { private static final Logger logger = LoggerFactory.getLogger(HandleOrchestrationTask.class) + private static final ObjectMapper mapper = new ObjectMapper() ExceptionUtil exceptionUtil = new ExceptionUtil() def supportedMethod = ["GET", "POST", "PUT"] @@ -105,8 +106,7 @@ class HandleOrchestrationTask extends AbstractServiceTaskProcessor { task.setIsManual(isManual) task.setCreatedTime(new Date()) task.setParams(paramJson) - ObjectMapper objectMapper = new ObjectMapper() - payload = objectMapper.writeValueAsString(task) + payload = mapper.writeValueAsString(task) logger.debug("Outgoing payload is \n" + payload) } execution.setVariable("payload", payload) @@ -125,4 +125,3 @@ class HandleOrchestrationTask extends AbstractServiceTaskProcessor { } } } - diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnAllocateNssi.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnAllocateNssi.groovy index 9debd4011b..9a3ecc8640 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnAllocateNssi.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnAllocateNssi.groovy @@ -52,16 +52,16 @@ import org.springframework.web.util.UriUtils import static org.apache.commons.lang3.StringUtils.isBlank class TnAllocateNssi extends AbstractServiceTaskProcessor { + private static final Logger logger = LoggerFactory.getLogger(TnAllocateNssi.class) + private static final ObjectMapper mapper = new ObjectMapper() String Prefix = "TNALLOC_" ExceptionUtil exceptionUtil = new ExceptionUtil() JsonUtils jsonUtil = new JsonUtils() RequestDBUtil requestDBUtil = new RequestDBUtil() JsonSlurper jsonSlurper = new JsonSlurper() - ObjectMapper objectMapper = new ObjectMapper() OofUtils oofUtils = new OofUtils() TnNssmfUtils tnNssmfUtils = new TnNssmfUtils() - private static final Logger logger = LoggerFactory.getLogger(TnAllocateNssi.class) void preProcessRequest(DelegateExecution execution) { logger.debug("Start preProcessRequest") @@ -230,7 +230,7 @@ class TnAllocateNssi extends AbstractServiceTaskProcessor { String requestId = execution.getVariable("msoRequestId") String messageType = "NSSISelectionResponse" - Map profileInfo = (Map) objectMapper.readValue(execution.getVariable("tnNfSliceProfile"), Map.class) + Map profileInfo = (Map) mapper.readValue(execution.getVariable("tnNfSliceProfile"), Map.class) String modelUuid = execution.getVariable("modelUuid") String modelInvariantUuid = execution.getVariable("modelInvariantUuid") String modelName = execution.getVariable("tnModelName") @@ -325,7 +325,7 @@ class TnAllocateNssi extends AbstractServiceTaskProcessor { serviceInfo.addProperty("nsiId", execution.getVariable("nsiId") as String) serviceInfo.addProperty("nssiName", execution.getVariable("servicename") as String) serviceInfo.addProperty("sST", execution.getVariable("sst") as String) - serviceInfo.addProperty("PLMNIdList", objectMapper.writeValueAsString(execution.getVariable("pLMNIdList"))) + serviceInfo.addProperty("PLMNIdList", mapper.writeValueAsString(execution.getVariable("pLMNIdList"))) serviceInfo.addProperty("globalSubscriberId", execution.getVariable("globalSubscriberId") as String) serviceInfo.addProperty("subscriptionServiceType", execution.getVariable("subscriptionServiceType") as String) serviceInfo.addProperty("serviceInvariantUuid", execution.getVariable("modelInvariantUuid") as String) @@ -395,4 +395,3 @@ class TnAllocateNssi extends AbstractServiceTaskProcessor { } } -