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";
int timeoutMinutes, String environment, Map<String, Object> files, Map<String, Object> heatFiles) {
// force entire stackInput object to generic Map<String, Object> for openstack compatibility
- ObjectMapper mapper = new ObjectMapper();
+
Map<String, Object> normalized = new HashMap<>();
try {
normalized = mapper.readValue(mapper.writeValueAsString(stackInputs),
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);
package org.onap.so.openstack.utils;
-
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
logger.debug("Ready to Update Stack ({}) with input params: {}", canonicalName, stackInputs);
// force entire stackInput object to generic Map<String, Object> for openstack compatibility
- ObjectMapper mapper = new ObjectMapper();
Map<String, Object> normalized = new HashMap<>();
try {
- normalized = mapper.readValue(mapper.writeValueAsString(stackInputs),
+ normalized = JSON_MAPPER.readValue(JSON_MAPPER.writeValueAsString(stackInputs),
new TypeReference<HashMap<String, Object>>() {});
} catch (IOException e1) {
logger.debug("could not map json", e1);
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);
}
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);
}
@Component
public class NovaClientImpl extends MsoCommonUtils {
+ private static final ObjectMapper mapper = new ObjectMapper();
/** The logger. */
private static final Logger logger = LoggerFactory.getLogger(NovaClientImpl.class);
/**
* Query Networks
*
- *
+ *
* @param cloudSiteId the cloud site id
* @param tenantId the tenant id
* @param limit limits the number of records returned
/**
* Query Networks
*
- *
+ *
* @param cloudSiteId the cloud site id
* @param tenantId the tenant id
* @param id of the network
/**
* Query Host Aggregates
*
- *
+ *
* @param cloudSiteId the cloud site id
* @param tenantId the tenant id
* @param limit limits the number of records returned
/**
* Query Host Aggregate
*
- *
+ *
* @param cloudSiteId the cloud site id
* @param tenantId the tenant id
* @param limit limits the number of records returned
/**
* Query OS Quota Set
*
- *
+ *
* @param cloudSiteId the cloud site id
* @param tenantId the tenant id
* @param limit limits the number of records returned
/**
* 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
public void postActionToServer(String cloudSiteId, String tenantId, String id, String request)
throws IOException, MsoException {
- ObjectMapper mapper = new ObjectMapper();
+
JsonNode actualObj = mapper.readTree(request);
Entity<JsonNode> openstackEntity = new Entity<>(actualObj, "application/json");
CharSequence actionPath = "/servers/" + id + "/action";
* 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.
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;
}
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);
* 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.
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;
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);
* 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.
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;
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);
* 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.
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;
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);
* 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.
* 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;
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);
* 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.
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) {
* 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.
*/
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() {
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) {
* 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.
public class MapElements {
private static final Logger logger = LoggerFactory.getLogger(MapElements.class);
+ private static final ObjectMapper mapper = new ObjectMapper();
+
@XmlElement
public String key;
@XmlElement
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();
*/
@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;
}
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();
}
}
-
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;
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);
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);
if (jsonInString == null) {
return false;
}
- ObjectMapper mapper = new ObjectMapper();
mapper.readTree(jsonInString);
return true;
} catch (IOException e) {
* 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.
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;
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) {
* 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.
* serivce csar query support <br>
* <p>
* </p>
- *
+ *
* @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;
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);
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;
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);
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);
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);
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
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
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);
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
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);
}
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();
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;
private IDistributionClient distributionClient;
- private static final String UUID_PARAM = "(UUID:";
-
- protected static final String MSO = "SO";
@Autowired
private WatchdogDistribution wd;
}
private Optional<String> 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<String> returnValue = Optional.empty();
try {
returnValue = Optional.of(mapper.writeValueAsString(iNotif));
public class JsonStatusData implements IStatusData {
@JsonIgnore
- private static ObjectMapper mapper = new ObjectMapper();
+ private static final ObjectMapper mapper = new ObjectMapper();
@JsonIgnore
private Map<String, Object> attributesMap = new HashMap<>();
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.
public List<VfModuleMetaData> decodeVfModuleArtifact(byte[] arg0) {
try {
- return new ObjectMapper().readValue(arg0, new TypeReference<List<VfModuleMetaData>>() {});
+ return mapper.readValue(arg0, new TypeReference<List<VfModuleMetaData>>() {});
} catch (JsonParseException e) {
logger.debug("JsonParseException : ", e);
* 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.
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;
}
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);
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);
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: "
private String getServiceProperties(ToscaResourceStructure toscaResourceStruct) {
String propertiesJson = null;
- ObjectMapper objectMapper = new ObjectMapper();
ISdcCsarHelper helper = toscaResourceStruct.getSdcCsarHelper();
String typeName = helper.getServiceSubstitutionMappingsTypeName();
Optional<NodeTemplate> nodeTemplate = helper.getServiceNodeTemplates().stream().findAny();
List<Object> 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);
return serviceProperties;
}
}
-
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) {
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);
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")
exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from OOF.")
}
}
-
+
}
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()
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" +
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" +
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" +
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
JsonObject json = new JsonObject()
json.addProperty("type", nxlType)
json.addProperty("NxIId", nxlId)
-
+
//Prepare requestInfo object
JsonObject requestInfo = new JsonObject()
requestInfo.addProperty("transactionId", transactionId)
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<TemplateInfo> nsstInfo,
* the inputs for the resource recipe <br>
* <p>
* </p>
- *
+ *
* @author
* @version ONAP Beijing Release 2018-03-08
*/
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;
@Override
public String toString() {
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, false);
String jsonStr = "";
try {
jsonStr = mapper.writeValueAsString(this);
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;
@Override
public String toString() {
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, true);
String jsonStr = "ResourceRecipeRequest";
try {
jsonStr = mapper.writeValueAsString(this);
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();
String value = apiResponse.readEntity(String.class);
- ObjectMapper objectMapper = new ObjectMapper();
- HashMap<String, Object> map = objectMapper.readValue(value, HashMap.class);
+ HashMap<String, Object> map = mapper.readValue(value, HashMap.class);
return map;
}
public static <T> T getJsonObject(String jsonstr, Class<T> type) {
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, true);
try {
- return mapper.readValue(jsonstr, type);
+ return mapperWithWrap.readValue(jsonstr, type);
} catch (IOException e) {
logger.error("fail to unMarshal json {}", e.getMessage());
}
}
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);
}
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")
@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);
@Autowired
private ExceptionBuilder exceptionUtil;
- private ObjectMapper mapper = new ObjectMapper();
+ private static final ObjectMapper mapper = new ObjectMapper();
public BBInputSetupUtils getBbInputSetupUtils() {
return bbInputSetupUtils;
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);
}
private org.onap.so.serviceinstancebeans.Service serviceMapper(Map<String, Object> 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) {
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;
if (requestId != null) {
List<String> 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);
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);
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;
}
@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<String> payload,
Map<String, String> payloadInfo, String controllerType) {
Status appcStatus = null;
String vmId = "";
String vserverId = "";
- ObjectMapper mapper = new ObjectMapper();
List<String> vmIdJsonList = mapper.readValue(vmIds, new TypeReference<List<String>>() {});
List<String> vserverIdJsonList = mapper.readValue(vserverIds, new TypeReference<List<String>>() {});
int i = 0;
* 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.
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";
}
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);
* 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.
public class DmaapPropertiesClient {
private static final Logger logger = LoggerFactory.getLogger(DmaapPropertiesClient.class);
+ private static final ObjectMapper mapper = new ObjectMapper();
@Autowired
private Provider<GlobalDmaapPublisher> dmaapPublisher;
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());
* 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.
public class SDNCLcmDmaapClient {
private static Logger logger = LoggerFactory.getLogger(SDNCLcmDmaapClient.class);
+ private static final ObjectMapper mapper = new ObjectMapper();
private RestPublisher dmaapPublisher;
private RestConsumer dmaapConsumer;
}
public void sendRequest(LcmDmaapRequest lcmDmaapRequest) throws Exception {
- ObjectMapper mapper = new ObjectMapper();
String lcmRestRequestString = mapper.writeValueAsString(lcmDmaapRequest);
dmaapPublisher.send(lcmRestRequestString);
public List<LcmDmaapResponse> getResponse() {
List<LcmDmaapResponse> responseList = new ArrayList<>();
- ObjectMapper mapper = new ObjectMapper();
Iterable<String> itrString = dmaapConsumer.fetch();
for (String message : itrString) {
LcmDmaapResponse lcmDmaapResponse;
* 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.
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);
@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));
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);
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);
* 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.
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);
}
/**
* 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
/**
* 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
/**
* 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
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,
return response.toString()
}
public void createDomainWiseSliceProfiles(List<String> ranConstituentSliceProfiles, DelegateExecution execution) {
-
+
for(String profile : ranConstituentSliceProfiles) {
String domainType = jsonUtil.getJsonValue(profile, "domainType")
switch(domainType) {
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();
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
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
String serviceFunctionTnMH = jsonUtil.getJsonValue(execution.getVariable("tnMhSliceProfile"), "resourceSharingLevel")
TNMH_sliceProfileInstance.setServiceFunction(serviceFunctionTnMH)
logger.debug("completed TNMH sliceprofileinstance build : "+TNMH_sliceProfileInstance)
-
+
String msg = ""
try {
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"))
logger.debug("createRelationShipInAAI Exit")
}
-
+
public void processRanNfModifyRsp(DelegateExecution execution) {
String status = execution.getVariable("ranNfStatus")
if(status.equals("success")) {
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")
response.add("allocateTnNssi", allocateTnNssi)
return response.toString()
}
-
+
public String buildDeallocateNssiRequest(DelegateExecution execution,String domainType) {
String globalSubscriberId = execution.getVariable("globalSubscriberId")
String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
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)
json.add("esrInfo", esrInfo)
json.add("serviceInfo", serviceInfo)
return json.toString()
-
+
}
public String getModelUuid(DelegateExecution execution, String instanceId) {
}
AAIResultWrapper wrapper = client.get(uri, NotFoundException.class)
Optional<ServiceInstance> si = wrapper.asBean(ServiceInstance.class)
-
+
if(si.isPresent()) {
serviceInstance = si.get()
}
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")
}
}
-
public class DeleteVFCNSResource extends AbstractServiceTaskProcessor {
+ private static final ObjectMapper mapper = new ObjectMapper()
String Prefix = "DCUSE_"
ExceptionUtil exceptionUtil = new ExceptionUtil()
JsonUtils jsonUtil = new JsonUtils()
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")
*
*/
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"
private static final String VENDOR_ONAP = "ONAP_internal"
- enum orchStatusMap {
+ enum orchStatusMap {
activateInstance("activated"),
deactivateInstance("deactivated")
private orchStatusMap(String value) {
this.value = value;
- }
+ }
}
logger.debug("${Prefix} - Preprocessing completed with sliceProfileId : ${anSliceProfileId} , nsiId : ${nsiId} , nssiId : ${anNssiId}")
}
-
+
/**
* Method to fetch AN NSSI Constituents and Slice Profile constituents
* @param execution
}
logger.trace("${Prefix} - Exit Get Related instances")
}
-
+
/**
* Method to check Slice profile orchestration status
* @param execution
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
}
logger.debug("${Prefix} processed SdnrResponse")
}
-
+
/**
* Update AN NF - NSSI and SP Instance status
* @param execution
updateOrchStatus(execution, anNfNssiId)
logger.debug("${Prefix}Exit updateAnNfStatus")
}
-
+
/**
* Method to check AN NF's Slice profile instance orchestration status
* @param execution
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)
String urlOpType = operationType.equalsIgnoreCase(ACTIVATE) ? "activation":"deactivation"
List<String> 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) {
}
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)
String urlOpType = operationType.equalsIgnoreCase(ACTIVATE) ? "activation":"deactivation"
List<String> 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)
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
updateOrchStatus(execution, tnFhNssiId)
logger.debug("${Prefix} Exit updateTNFHStatus")
-
+
}
-
+
/**
* Update TN MH - NSSI and SP Instance status
* @param execution
logger.debug("${Prefix} Exit updateTNMHStatus")
}
-
+
/**
* Update AN - NSSI and SP Instance status
* @param execution
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"
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")
execution.setVariable("isSuccess", false)
}
}
-
-
+
+
private void updateOrchStatus(DelegateExecution execution,String serviceId) {
logger.debug("${Prefix} Start updateOrchStatus : ${serviceId}")
String globalSubscriberId = execution.getVariable("globalSubscriberId")
}
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")
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)
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<String,ServiceInstance> relatedInstances = new HashMap<>()
-
+
AAIResourcesClient client = getAAIClient()
AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(instanceId))
if (!client.exists(uri)) {
logger.debug("Found ${relatedInstances.size()} ${role} related to ${instanceId} ")
return relatedInstances
}
-
+
private ServiceInstance getInstanceByWorkloadContext(Map<String,ServiceInstance> instances,String workloadContext ) {
ServiceInstance instance = instances.get(workloadContext)
if(instance == null) {
}
return instance
}
-
+
private String getInstanceIdByWorkloadContext(Map<String,ServiceInstance> instances,String workloadContext ) {
String instanceId = instances.get(workloadContext).getServiceInstanceId()
if(instanceId == null) {
}
return instanceId
}
-
-
+
+
/**
* Method to handle deallocation of RAN NSSI constituents(TN_FH/TN_MH)
* @param execution
json.add("esrInfo", esrInfo)
json.add("serviceInfo", jsonConverter.toJsonTree(serviceInfo))
return json.toString()
-
+
}
-
+
}
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()
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()
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)
}
}
-
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)
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)
}
/* process the decompose service(RAN NSST) response
- *
+ *
*/
def processDecomposition = { DelegateExecution execution ->
logger.debug(Prefix+"processDecomposition method start")
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")
initStatus.setOperType("Modify")
requestDBUtil.prepareInitResourceOperationStatus(execution, initStatus)
}
-
+
def createModifyNssiQueryJobStatus = { DelegateExecution execution ->
logger.debug(Prefix+"createModifyNssiQueryJobStatus method start")
JsonObject esrInfo = new JsonObject()
String nsstInfo = nsstInfoList.get(currentIndex)
String modelInvariantUuid = jsonUtil.getJsonValue(nsstInfo, "invariantUUID")
String modelUuid = jsonUtil.getJsonValue(nsstInfo, "UUID")
-
+
String serviceModelInfo = """{
"modelInvariantUuid":"${modelInvariantUuid}",
"modelUuid":"${modelUuid}",
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)
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()
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")
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"))
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) {
//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")
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")
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<String> snssaiList = jsonUtil.StringArrayToList(execution.getVariable("snssaiList") as String)
String snssai = snssaiList.get(0)
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) {
}
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")
execution.setVariable("serviceInfo", serviceInfo.toString())
execution.setVariable("responseId", "")
}
-
+
def processFhAllocateNssiJobStatusRsp = { DelegateExecution execution ->
logger.debug(Prefix+"processJobStatusRsp method start")
String jobResponse = execution.getVariable("TNFH_jobResponse")
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")
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")
}
}
}
-
+
/**
* update operation status in request db
*
def prepareFailedOperationStatusUpdate = { DelegateExecution execution ->
logger.debug(Prefix + "prepareFailedOperationStatusUpdate Start")
-
+
String jobId = execution.getVariable("jobId")
String nsiId = execution.getVariable("nsiId")
String modelUuid = execution.getVariable("modelUuid")
updateStatus.setStatus("failed")
requestDBUtil.prepareUpdateResourceOperationStatus(execution, updateStatus)
}
-
+
private String buildSdnrAllocateRequest(DelegateExecution execution, String action, String rpcName, String callbackUrl) {
-
+
String requestId = execution.getVariable("msoRequestId")
Map<String,Object> sliceProfile = objectMapper.readValue(execution.getVariable("ranNfSliceProfile"), Map.class)
sliceProfile.put("sliceProfileId", execution.getVariable("ANNF_sliceProfileInstanceId"))
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"))
response.addProperty("type", "request")
return response.toString()
}
-
+
private void createEndPointsInAai(DelegateExecution execution) {
String type = "endpoint"
String function = "transport_EP"
//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")
}
}
}
-
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 ****")
requestDBUtil.prepareUpdateResourceOperationStatus(execution, resourceOperationStatus)
logger.debug(Prefix + " **** Exit DoAllocateCoreNSSI ::: prepareFailedOperationStatusUpdate ****")
}
-}
\ No newline at end of file
+}
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()
//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<String, Object> serviceOrder = new LinkedHashMap()
//ExternalId
serviceOrder.put("externalId", "ONAP001")
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<String, Object> serviceCharacteristicsObject = new LinkedHashMap()
for (Map.Entry<String, Integer> entry : serviceCharacteristics.entrySet()) {
requestDBUtil.prepareUpdateResourceOperationStatus(execution, resourceOperationStatus)
logger.debug(Prefix + " **** Exit DoAllocateCoreNonSharedSlice ::: prepareFailedOperationStatusUpdate ****")
}
-}
\ No newline at end of file
+}
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
logger.debug(Prefix + " **** Exit DoAllocateCoreSharedSlice ::: prepareFailedOperationStatusUpdate ****")
}
}
-
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()")
*/
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)
}
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)
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)
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()
// Slice Profile
String sliceProfile = execution.getVariable("sliceParams")
-
+
/* if(jsonUtil.jsonValueExists(execution.getVariable("sliceParams"), "sliceProfile")) {
sliceProfile = jsonUtil.getJsonValue(execution.getVariable("sliceParams"), "sliceProfile")
}
serviceVnfs = jsonUtil.getJsonValue(json, "serviceResources.serviceVnfs") ?: ""
- ObjectMapper mapper = new ObjectMapper()
-
List<Object> vnfList = mapper.readValue(serviceVnfs, List.class)
LOGGER.debug("vnfList: "+vnfList)
snssaiList.add(snssaisMap)
}
- // Map<String, List<Map<String, String>>> supportedNssaiDetails = new HashMap<>()
- // supportedNssaiDetails.put("sNssai", supportedNssaiDetails)
-
- ObjectMapper mapper = new ObjectMapper()
-
- Map<String, Object> nSsai= new LinkedHashMap<>()
+ Map<String, Object> nSsai = new LinkedHashMap<>()
nSsai.put("sNssai", snssaiList)
// String supportedsNssaiJson = mapper.writeValueAsString(snssaiList)
Map<String, Object> requestDetailsMap = new LinkedHashMap<>()
requestDetailsMap.put("requestDetails", requestDetails)
- ObjectMapper mapper = new ObjectMapper()
-
response = mapper.writeValueAsString(requestDetailsMap)
}
catch (any) {
*
*/
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_"
}
private static <T> T getJsonObject(String jsonstr, Class<T> type) {
- ObjectMapper mapper = new ObjectMapper()
- mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, true)
try {
return mapper.readValue(jsonstr, type)
} catch (IOException e) {
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()
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.
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
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"
execution.setVariable("IsRANNfAlonePresent", true)
}
}
-
+
/**
* @param execution
logger.debug("Finish prepareOOFTerminationRequest")
}
-
+
void performOofAnNSSITerminationCall(DelegateExecution execution) {
boolean terminateAnNSSI = callOofAdapter(execution,execution.getVariable("oofAnNssiPayload"))
execution.setVariable("terminateAnNSSI", terminateAnNSSI)
}
-
+
/**
* @param execution
*/
execution.setVariable("modifyAction","deallocate")
}
}
-
+
void prepareSdnrRequest(DelegateExecution execution) {
String anNfNssiId = execution.getVariable("anNfNssiId")
execution.setVariable("SDNR_timeout", "PT10M")
}
-
+
void processSdnrResponse(DelegateExecution execution) {
logger.debug("${Prefix} processing SdnrResponse")
Map<String, Object> resMap = objectMapper.readValue(execution.getVariable("SDNR_Response"),Map.class)
}
logger.debug("${Prefix} processed SdnrResponse")
}
-
+
/**
* @param execution
* @param oofRequest - Request payload to be sent to adapter
return terminateResponse
}
}
-
+
void deallocateAnNfNssi(DelegateExecution execution) {
logger.debug("${Prefix} - call deallocateAnNfNssi ")
String anNfNssiId = getInstanceIdByWorkloadContext(execution.getVariable("relatedNssis"), AN_NF)
client.delete(uri)
}
}
-
+
/**
* Removes relationship between AN NSSI and AN_NF NSSI
* @param execution
client.delete(uri)
}
}
-
+
/**
* Method to prepare request for AN NSSI modification
* Call Modify AN NSSI in case OOF sends Terminate NSSI=False
execution.setVariable("isSuccess", false)
}
}
-
+
void prepareUpdateJobStatus(DelegateExecution execution,String status,String progress,String statusDescription) {
String nssiId = execution.getVariable("anNssiId")
String jobId = execution.getVariable("jobId")
roStatus.setStatusDescription(statusDescription)
requestDBUtil.prepareUpdateResourceOperationStatus(execution, roStatus)
}
-
+
void terminateTNFHNssi(DelegateExecution execution) {
logger.debug("Start terminateTNFHNssi in ${Prefix}")
String nssmfRequest = buildDeallocateNssiRequest(execution, TN_FH)
}
logger.debug("Exit terminateTNFHNssi in ${Prefix}")
}
-
+
void terminateTNMHNssi(DelegateExecution execution) {
logger.debug("Start terminateTNMHNssi in ${Prefix}")
String nssmfRequest = buildDeallocateNssiRequest(execution, TN_MH)
}
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)
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)
logger.debug("Found ${relatedInstances.size()} ${role} related to ${instanceId} ")
return relatedInstances
}
-
+
private String getInstanceIdByWorkloadContext(Map<String,ServiceInstance> instances,String workloadContext ) {
String instanceId = instances.get(workloadContext).getServiceInstanceId()
if(instanceId == null) {
}
return instanceId
}
-
+
/**
* Method to handle deallocation of RAN NSSI constituents(TN_FH/TN_MH)
* @param execution
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")
json.add("esrInfo", esrInfo)
json.add("serviceInfo", jsonConverter.toJsonTree(serviceInfo))
return json.toString()
-
+
}
-
+
private void deleteServiceInstanceInAAI(DelegateExecution execution,String instanceId) {
try {
AAIResourcesClient client = getAAIClient()
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"
private MsoUtils utils = new MsoUtils()
private JsonUtils jsonUtil = new JsonUtils()
- private static final Logger LOGGER = LoggerFactory.getLogger( DoDeallocateCoreNSSI.class)
@Override
//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<String, Object> serviceOrder = new LinkedHashMap()
//ExternalId
serviceOrder.put("externalId", "ONAP001")
List<Map<String, String>> 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)
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) {
}
return null
}
-
+
/**
* send deallocate request to nssmf
* @param execution
String serviceUuid = currentNSSI['modelVersionId']
String globalSubscriberId = currentNSSI['globalSubscriberId']
String subscriptionServiceType = currentNSSI['serviceType']
-
+
DeAllocateNssi deAllocateNssi = new DeAllocateNssi()
deAllocateNssi.setNsiId(nsiId)
deAllocateNssi.setNssiId(nssiId)
deAllocateNssi.setSnssaiList(Arrays.asList(snssai))
deAllocateNssi.setScriptName(scriptName)
deAllocateNssi.setSliceProfileId(profileId)
-
+
ServiceInfo serviceInfo = new ServiceInfo()
serviceInfo.setServiceInvariantUuid(serviceInvariantUuid)
serviceInfo.setServiceUuid(serviceUuid)
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}
}
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.")
}
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")
{
NetworkType domainType = currentNSSI['domainType']
String vendor = currentNSSI['vendor']
-
+
EsrInfo info = new EsrInfo()
info.setNetworkType(domainType)
info.setVendor(vendor)
requestDBUtil.prepareUpdateOperationStatus(execution, operationStatus)
LOGGER.debug("update operation, currentProgress=${currentProgress}, proportion=${proportion}, progress = ${progress}" )
}
-
+
/**
* delete slice profile from aai
* @param execution
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()
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) {
*
*/
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) {
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)
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)
if(responseCode != 200){
exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from OOF.")
- }
+ }
try {
Map<String, String> resMap = httpResponse.readEntity(Map.class)
boolean terminateResponse = resMap.get("terminateResponse")
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) {
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<String> snssaiList = jsonUtil.StringArrayToList(jsonUtil.getJsonValue(sliceParams, "snssaiList"))
String sliceProfileId = jsonUtil.getJsonValue(sliceParams, "sliceProfileId")
if (isBlank(sliceProfileId) || (snssaiList.empty)) {
}
logger.debug(Prefix + "preProcessRequest Exit")
}
-
+
def getSliceProfile = { DelegateExecution execution ->
logger.debug(Prefix + "getSliceProfiles Start")
String instanceId = execution.getVariable("sliceProfileId")
.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<SliceProfiles> 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
*/
}
}
-
+
/*
* prepare OOF request for RAN NSSI selection
*/
boolean ranNssiPreferReuse = execution.getVariable("ranNssiPreferReuse");
String requestId = execution.getVariable("msoRequestId")
String messageType = "NSISelectionResponse"
- Map<String, Object> 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<PerfReqEmbb> 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<String, Object> 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<PerfReqEmbb> 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<String> nsstInfoList = new ArrayList<>()
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))
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
*/
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<String> 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)
String instanceId = execution.getVariable("serviceInstanceID")
String role = "nssi"
Map<String,ServiceInstance> 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())
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<AllottedResource> AllottedResourceList = allottedResources.getAllottedResource()
- for(AllottedResource allottedResource : AllottedResourceList) {
- List<Relationship> 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<org.onap.aai.domain.yang.LogicalLink> 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<AllottedResource> AllottedResourceList = allottedResources.getAllottedResource()
+ for(AllottedResource allottedResource : AllottedResourceList) {
+ List<Relationship> 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<org.onap.aai.domain.yang.LogicalLink> 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")
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")
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)
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")
}
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")) {
execution.setVariable("serviceInfo", serviceInfo.toString())
execution.setVariable("responseId", "")
}
-
+
def processFhAllocateNssiJobStatusRsp = { DelegateExecution execution ->
logger.debug(Prefix+"processJobStatusRsp method start")
String jobResponse = execution.getVariable("TNFH_jobResponse")
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")
}
}
}
-
+
def prepareTnFhDeallocateRequest = { DelegateExecution execution ->
logger.debug(Prefix+"prepareTnFhDeallocateRequest method start")
String nssmfRequest = anNssmfUtils.buildDeallocateNssiRequest(execution, "TN_FH")
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")
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")
}
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")
updateStatus.setStatus("failed")
requestDBUtil.prepareUpdateResourceOperationStatus(execution, updateStatus)
}
-
+
/**
* @param execution
* @param role - nssi/slice profile instance
logger.debug("${Prefix} - Fetching related ${role} from AAI")
String globalSubscriberId = execution.getVariable("globalSubscriberId")
String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
-
+
Map<String,ServiceInstance> relatedInstances = new HashMap<>()
-
+
AAIResourcesClient client = new AAIResourcesClient()
AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(instanceId))
if (!client.exists(uri)) {
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")
}
AAIResultWrapper wrapper = client.get(uri, NotFoundException.class)
Optional<ServiceInstance> si = wrapper.asBean(ServiceInstance.class)
-
+
if(si.isPresent()) {
serviceInstance = si.get()
}
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"
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")
def currentNSSI = execution.getVariable("currentNSSI")
String givenSliceProfileId = currentNSSI['sliceProfileId'] //UUID.randomUUID().toString()
- Map<String,Object> sliceProfileMap = new ObjectMapper().readValue(currentNSSI['sliceProfile'], Map.class)
+ Map<String,Object> sliceProfileMap = mapper.readValue(currentNSSI['sliceProfile'], Map.class)
SliceProfile sliceProfile = new SliceProfile()
sliceProfile.setServiceAreaDimension("")
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) {
execution.setVariable("snssaiList", snssaiList)
execution.setVariable("snssai", snssaiList.get(0))
}
-
+
} catch(BpmnError e) {
throw e
} catch(Exception ex) {
}
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")
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")
}
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<String,Object> sliceProfile = new HashMap<>()
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"))
response.addProperty("type", "request")
return response.toString()
}
-
+
}
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()
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) {
return logicalLinkNameList.contains(linkName)
}
}
-
* 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"
* @return
*/
private String objectToJsonStr(Object obj) {
- ObjectMapper mapper = new ObjectMapper()
String jsonStr = null
try {
jsonStr = mapper.writeValueAsString(obj)
return nsResourceInputParameterList
}
}
-
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"]
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)
}
}
}
-
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")
String requestId = execution.getVariable("msoRequestId")
String messageType = "NSSISelectionResponse"
- Map<String, Object> profileInfo = (Map<String, Object>) objectMapper.readValue(execution.getVariable("tnNfSliceProfile"), Map.class)
+ Map<String, Object> profileInfo = (Map<String, Object>) mapper.readValue(execution.getVariable("tnNfSliceProfile"), Map.class)
String modelUuid = execution.getVariable("modelUuid")
String modelInvariantUuid = execution.getVariable("modelInvariantUuid")
String modelName = execution.getVariable("tnModelName")
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)
}
}
-