diff options
Diffstat (limited to 'bpmn/so-bpmn-infrastructure-common/src/main')
84 files changed, 2356 insertions, 1508 deletions
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateNetworkInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateNetworkInstance.groovy index 19fe018e13..d588da38b0 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateNetworkInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateNetworkInstance.groovy @@ -416,7 +416,7 @@ public class CreateNetworkInstance extends AbstractServiceTaskProcessor { } catch (Exception ex) { String errorException = " Bpmn error encountered in CreateNetworkInstance flow. FalloutHandlerRequest, buildErrorResponse()" - logger.debug("Exception error in CreateNetworkInstance flow, buildErrorResponse(): " + ex.getMessage()) + logger.debug("Exception error in CreateNetworkInstance flow, buildErrorResponse(): {}", ex.getMessage(), ex) falloutHandlerRequest = """<aetgt:FalloutHandlerRequest xmlns:aetgt="http://org.onap/so/workflow/schema/v1" xmlns:ns="http://org.onap/so/request/types/v1" diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy index bb2116acb9..65fa0511ac 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy @@ -441,7 +441,6 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor { } String sndcTopologyCreateRequesAsString = utils.formatXml(sdncTopologyCreateRequest) - utils.logAudit(sndcTopologyCreateRequesAsString) execution.setVariable("sdncAdapterWorkflowRequest", sndcTopologyCreateRequesAsString) logger.debug("sdncAdapterWorkflowRequest - " + "\n" + sndcTopologyCreateRequesAsString) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleInfra.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleInfra.groovy index 712512fdc9..fa9fe62df4 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleInfra.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleInfra.groovy @@ -268,7 +268,7 @@ public class CreateVfModuleInfra extends AbstractServiceTaskProcessor { */ public void validateWorkflowResponse(DelegateExecution execution, String responseVar, String responseCodeVar, String errorResponseVar) { - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() sdncAdapterUtils.validateSDNCResponse(execution, responseVar, responseCodeVar, errorResponseVar) } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVnfInfra.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVnfInfra.groovy index c0e8d5a6ba..e941d50155 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVnfInfra.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVnfInfra.groovy @@ -349,7 +349,7 @@ class CreateVnfInfra extends AbstractServiceTaskProcessor { logger.debug("workflowException: " + workflowException) - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) logger.debug("SDNCResponse: " + response) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeActivateSDNCNetworkResource.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeActivateSDNCNetworkResource.groovy index ccdb5d77cd..4233147f83 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeActivateSDNCNetworkResource.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeActivateSDNCNetworkResource.groovy @@ -328,7 +328,6 @@ public class DeActivateSDNCNetworkResource extends AbstractServiceTaskProcessor } String sdncTopologyDeleteRequesAsString = utils.formatXml(sdncTopologyDeleteRequest) - utils.logAudit(sdncTopologyDeleteRequesAsString) execution.setVariable("sdncAdapterWorkflowRequest", sdncTopologyDeleteRequesAsString) logger.info("sdncAdapterWorkflowRequest - " + "\n" + sdncTopologyDeleteRequesAsString) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSDNCNetworkResource.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSDNCNetworkResource.groovy index 0dc86632e2..20134a77a9 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSDNCNetworkResource.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSDNCNetworkResource.groovy @@ -354,7 +354,6 @@ public class DeleteSDNCNetworkResource extends AbstractServiceTaskProcessor { } String sdncTopologyDeleteRequesAsString = utils.formatXml(sdncTopologyDeleteRequest) - utils.logAudit(sdncTopologyDeleteRequesAsString) execution.setVariable("sdncAdapterWorkflowRequest", sdncTopologyDeleteRequesAsString) logger.info("sdncAdapterWorkflowRequest - " + "\n" + sdncTopologyDeleteRequesAsString) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1.groovy index ccd9f9bd02..cf53aff878 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1.groovy @@ -68,6 +68,7 @@ public class DeleteVfModuleVolumeInfraV1 extends AbstractServiceTaskProcessor { execution.setVariable('DELVfModVol_vnfType', null) execution.setVariable('DELVfModVol_serviceId', null) execution.setVariable('DELVfModVol_cloudRegion', null) + execution.setVariable('DELVfModVol_cloudOwner', null) execution.setVariable('DELVfModVol_tenantId', null) execution.setVariable('DELVfModVol_volumeParams', null) execution.setVariable('DELVfModVol_volumeGroupHeatStackId', null) @@ -141,6 +142,7 @@ public class DeleteVfModuleVolumeInfraV1 extends AbstractServiceTaskProcessor { execution.setVariable('DELVfModVol_volumeOutputs', utils.getNodeXml(request, 'volume-outputs', false)) execution.setVariable('DELVfModVol_volumeParams', utils.getNodeXml(request, 'volume-params')) execution.setVariable('DELVfModVol_cloudRegion', utils.getNodeText(request, 'aic-cloud-region')) + execution.setVariable('DELVfModVol_cloudOwner', utils.getNodeText(request, 'cloud-owner')) setBasicDBAuthHeader(execution, isDebugLogEnabled) @@ -308,6 +310,7 @@ public class DeleteVfModuleVolumeInfraV1 extends AbstractServiceTaskProcessor { public void prepareVnfAdapterDeleteRequest(DelegateExecution execution, isDebugLogEnabled) { def cloudRegion = execution.getVariable('DELVfModVol_cloudRegion') + def cloudOwner = execution.getVariable('DELVfModVol_cloudOwner') def tenantId = execution.getVariable('DELVfModVol_tenantId') def volumeGroupId = execution.getVariable('DELVfModVol_volumeGroupId') def volumeGroupHeatStackId = execution.getVariable('DELVfModVol_volumeGroupHeatStackId') @@ -324,6 +327,7 @@ public class DeleteVfModuleVolumeInfraV1 extends AbstractServiceTaskProcessor { String vnfAdapterRestRequest = """ <deleteVolumeGroupRequest> <cloudSiteId>${MsoUtils.xmlEscape(cloudRegion)}</cloudSiteId> + <cloudOwner>${MsoUtils.xmlEscape(cloudOwner)}</cloudOwner> <tenantId>${MsoUtils.xmlEscape(tenantId)}</tenantId> <volumeGroupId>${MsoUtils.xmlEscape(volumeGroupId)}</volumeGroupId> <volumeGroupStackId>${MsoUtils.xmlEscape(volumeGroupHeatStackId)}</volumeGroupStackId> diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCompareServiceInstanceData.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCompareServiceInstanceData.groovy new file mode 100644 index 0000000000..a1f68f9b06 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCompareServiceInstanceData.groovy @@ -0,0 +1,270 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.onap.so.bpmn.infrastructure.scripts + +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.aai.domain.yang.ServiceInstance +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.core.domain.Resource +import org.onap.so.bpmn.core.domain.ServiceDecomposition +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.bpmn.infrastructure.workflow.service.ServicePluginFactory +import org.slf4j.Logger +import org.slf4j.LoggerFactory +/** + * This groovy class supports the <class>DoCompareServiceInstanceData.bpmn</class> process. + * + * Inputs: + * @param - serviceInstanceData-original + * @param - serviceInstanceId + * @param - uuiRequest + * @param - model-invariant-id-original + * @param - model-version-id-original + * @param - msoRequestId + * @param - isDebugLogEnabled + * + * Outputs: + * @param - addResourceList + * @param - delResourceList + * @param - uuiRequest-add + * @param - uuiRequest-del + * + */ +public class DoCompareServiceInstanceData extends AbstractServiceTaskProcessor { + + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + private static final Logger logger = LoggerFactory.getLogger( DoCompareServiceInstanceData.class); + + public void preProcessRequest (DelegateExecution execution) { + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + logger.info("INFO"," ***** preProcessRequest *****", isDebugEnabled) + try { + checkInput("serviceInstanceData-original", execution, isDebugEnabled) + checkInput("serviceInstanceId", execution, isDebugEnabled) + checkInput("uuiRequest", execution, isDebugEnabled) + checkInput("model-invariant-id-original", execution, isDebugEnabled) + checkInput("model-version-id-original", execution, isDebugEnabled) + checkInput("msoRequestId", execution, isDebugEnabled) + } catch (Exception ex){ + String msg = "Exception in preProcessRequest " + ex.getMessage() + logger.info("INFO", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.info("INFO"," ***** Exit preProcessRequest *****", isDebugEnabled) + } + + private void checkInput(String inputName, DelegateExecution execution, isDebugEnabled) { + String msg + Object inputValue = execution.getVariable(inputName) + if (inputValue == null) { + msg = "Input" + inputName + "is null" + logger.info("INFO", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + } + + + public void prepareDecomposeService_Original(DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + + try { + logger.debug( " ***** Inside prepareDecomposeService_Original of update generic e2e service ***** ") + String modelInvariantUuid = execution.getVariable("model-invariant-id-original") + String modelUuid = execution.getVariable("model-version-id-original") + //here modelVersion is not set, we use modelUuid to decompose the service. + String serviceModelInfo = """{ + "modelInvariantUuid":"${modelInvariantUuid}", + "modelUuid":"${modelUuid}", + "modelVersion":"" + }""" + + execution.setVariable("serviceModelInfo_Original", serviceModelInfo) + + logger.debug( " ***** Completed prepareDecomposeService_Original of update generic e2e service ***** ") + } catch (Exception ex) { + // try error in method block + String exceptionMessage = "Bpmn error encountered in update generic e2e service flow. Unexpected Error from method prepareDecomposeService_Original() - " + ex.getMessage() + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + } + + public void processDecomposition_Original(DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + + logger.debug( " ***** Inside processDecomposition_Original() of update generic e2e service flow ***** ") + try { + ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") + execution.setVariable("serviceDecomposition_Original", serviceDecomposition) + } catch (Exception ex) { + String exceptionMessage = "Bpmn error encountered in update generic e2e service flow. processDecomposition_Original() - " + ex.getMessage() + logger.debug( exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + } + + public void doCompareUuiRquestInput(DelegateExecution execution) { + + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + logger.info("INFO", "======== Start doCompareUuiRquestInput Process ======== ", isDebugEnabled) + + String uuiRequest_Target = execution.getVariable("uuiRequest") + Map<String, Object> serviceParametersObject_Target = getServiceParametersObject(uuiRequest_Target) + Map<String, Object> serviceRequestInputs_Target = (Map<String, Object>) serviceParametersObject_Target.get("requestInputs") + List<Object> resources_Target = (List<Object>) serviceParametersObject_Target.get("resources") + + String uuiRequest_Original = ((ServiceInstance) execution.getVariable("serviceInstanceData-original")).getInputParameters() + Map<String, Object> serviceParametersObject_Original = getServiceParametersObject(uuiRequest_Original) + Map<String, Object> serviceRequestInputs_Original = (Map<String, Object>) serviceParametersObject_Original.get("requestInputs") + List<Object> resources_Original = (List<Object>) serviceParametersObject_Original.get("resources") + + logger.info("INFO", "uuiRequest is: " + uuiRequest_Target, isDebugEnabled) + + //the resources which are included by resources_Target but resources_Original are the resources going to be added + ArrayList<Object> resourceList_Add = findResourceListIncluded(resources_Target, resources_Original) + HashMap<String, Object> serviceRequestInputs_Add = getServiceRequestInputsIncluded(resourceList_Add, serviceRequestInputs_Target, serviceParametersObject_Target) + String uuiRequest_add = loadUuiRequestJsonString(uuiRequest_Target, resourceList_Add, serviceRequestInputs_Add) + execution.setVariable("uuiRequest", uuiRequest_add) + logger.info("INFO", "uuiRequest will be changed to: " + uuiRequest_add, isDebugEnabled) + + //the resources which are included by resources_Original but resources_Target are the resources going to be deleted + ArrayList<Object> resourceList_Del = findResourceListIncluded(resources_Original, resources_Target) + HashMap<String, Object> serviceRequestInputs_Del = getServiceRequestInputsIncluded(resourceList_Del, serviceRequestInputs_Original, serviceParametersObject_Original) + String uuiRequest_del = loadUuiRequestJsonString(uuiRequest_Original, resourceList_Del, serviceRequestInputs_Del) + execution.setVariable("uuiRequest-del", uuiRequest_del) + logger.info("INFO", "uuiRequest-del: " + uuiRequest_del, isDebugEnabled) + + List<Resource> addResourceList = findResourceList(resourceList_Add, execution) + execution.setVariable("addResourceList", addResourceList) + logger.info("INFO", "addResourceList: " + addResourceList, isDebugEnabled) + + List<Resource> delResourceList = findResourceList(resourceList_Del, execution) + execution.setVariable("delResourceList", delResourceList) + logger.info("INFO", "delResourceList: " + delResourceList, isDebugEnabled) + + logger.info("INFO", "======== COMPLETED doCompareUuiRquestInput Process ======== ", isDebugEnabled) + } + + private List<Resource> findResourceList(ArrayList<Object> uuiResourceList, DelegateExecution execution) { + HashSet<String> addResourceCustomizationUuidSet = getCustomizationUuidSet(uuiResourceList) + Set<Resource> resourceSet = new HashSet<>() + ServiceDecomposition serviceDecomposition_Original = execution.getVariable("serviceDecomposition_Original") + List<Resource> allSR_original = serviceDecomposition_Original.getServiceResources() + for (Resource resource : allSR_original) { + if (addResourceCustomizationUuidSet.contains(resource.getModelInfo().getModelCustomizationUuid())) { + resourceSet.add(resource) + } + } + List<Resource> resourceList = new ArrayList<String>(resourceSet) + resourceList + } + + private HashSet<String> getCustomizationUuidSet(ArrayList<Object> resourceList_Add) { + Set<String> addRsourceCustomizationUuidSet = new HashSet<>() + for (Map<String, Object> resourceAdded : resourceList_Add) { + addRsourceCustomizationUuidSet.add(resourceAdded.get("rsourceCustomizationUuid")) + } + addRsourceCustomizationUuidSet + } + + private String loadUuiRequestJsonString(String uuiRequest_Target, ArrayList<Object> resourceList_Add, HashMap<String, Object> serviceRequestInputs_Add) { + Map<String, Object> uuiObject = ServicePluginFactory.getInstance().getJsonObject(uuiRequest_Target, Map.class) + Map<String, Object> serviceObject = (Map<String, Object>) uuiObject.get("service") + Map<String, Object> serviceParametersObject = (Map<String, Object>) serviceObject.get("parameters") + serviceParametersObject.put("resources", resourceList_Add) + serviceParametersObject.put("requestInputs", serviceRequestInputs_Add) + String uuiRequest_add = ServicePluginFactory.getInstance().getJsonString(serviceObject) + uuiRequest_add + } + + private HashMap<String, Object> getServiceRequestInputsIncluded(ArrayList<Object> resourceList_Add, Map<String, Object> serviceRequestInputs_Target, Map<String, Object> serviceParametersObject_Target) { + ArrayList<String> newResourceNames = getNewResourceNames(resourceList_Add) + Map<String, Object> serviceRequestInputs_Add = new HashMap<String, Object>() + for (String inputKey : serviceRequestInputs_Target.keySet()) { + String resourceName = (inputKey.split("_"))[0] + if (newResourceNames.contains(resourceName)) { + serviceRequestInputs_Add.put(inputKey, serviceParametersObject_Target.get(inputKey)) + } + } + serviceRequestInputs_Add + } + + private ArrayList<String> getNewResourceNames(ArrayList<Object> addResourceList) { + Set<String> newResourceNames = new ArrayList<String>() + for (Object resourceObject : addResourceList) { + Map<String, Object> resourceAdded = (Map<String, Object>) resourceObject + String resName = new String(resourceAdded.get("resourceName")) + normalizeName(resName) + newResourceNames.add(resName) + } + newResourceNames + } + + private void normalizeName(String resName) { + resName.replaceAll("_", "") + resName.replaceAll(" ", "") + resName.toLowerCase() + } + + private ArrayList<Object> findResourceListIncluded(List<Object> resources_Target, List<Object> resources_Original) { + List<Object> addResourceList = new ArrayList<Object>() + for (Object resource_Target : resources_Target) { + Map<String, Object> resourceObject_Target = (Map<String, Object>) resource_Target + boolean isNewResourceInstance = isNewResourceInstance(resourceObject_Target, resources_Original) + if (isNewResourceInstance) { + addResourceList.add(resource_Target) + } + } + addResourceList + } + + private boolean isNewResourceInstance(Map<String, Object> resourceObject_Target, List<Object> resources_Original) { + String resourceIndex_Target = null + if (resourceObject_Target.keySet().contains("resourceIndex")) { + resourceIndex_Target = resourceObject_Target.get("resourceIndex") + } + String resourceName_Target = resourceObject_Target.get("resourceName") + boolean isNewResourceInstance = true + for (Object resource_Original : resources_Original) { + Map<String, Object> resourceObject_Original = (Map<String, Object>) resource_Original + String resourceIndex_Original = null + if (resourceObject_Original.keySet().contains("resourceIndex")) { + resourceIndex_Original = resourceObject_Original.get("resourceIndex") + } + String resourceName_Original = resourceObject_Original.get("resourceName") + if (resourceName_Target.equals(resourceName_Original)) { + if (resourceIndex_Target != null && resourceIndex_Original != null) { + if (resourceIndex_Target.equals(resourceIndex_Original)) { + isNewResourceInstance = false + } + } else { + isNewResourceInstance = false + } + } + } + isNewResourceInstance + } + + private Map<String, Object> getServiceParametersObject(String uuiRequest_Target) { + Map<String, Object> uuiObject = ServicePluginFactory.getInstance().getJsonObject(uuiRequest_Target, Map.class) + Map<String, Object> serviceObject = (Map<String, Object>) uuiObject.get("service") + Map<String, Object> serviceParametersObject = (Map<String, Object>) serviceObject.get("parameters") + serviceParametersObject + } + +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstanceRollback.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstanceRollback.groovy index ce9df87799..a12c2f4b85 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstanceRollback.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstanceRollback.groovy @@ -156,7 +156,7 @@ public class DoCreateE2EServiceInstanceRollback extends AbstractServiceTaskProce logger.debug("SDNCResponse: " + response) logger.debug("workflowException: " + workflowException) - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){ diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstance.groovy index 41bae326a5..22c8a11fae 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstance.groovy @@ -1081,7 +1081,7 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") WorkflowException workflowException = execution.getVariable("WorkflowException") - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) // reset variable String assignSDNCResponseDecodeXml = execution.getVariable(Prefix + "assignSDNCResponse") @@ -1109,7 +1109,7 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") WorkflowException workflowException = execution.getVariable("WorkflowException") - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) // reset variable String assignSDNCResponseDecodeXml = execution.getVariable(Prefix + "activateSDNCResponse") diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstanceRollback.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstanceRollback.groovy index c144dc0f46..41a302f5f1 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstanceRollback.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstanceRollback.groovy @@ -244,7 +244,7 @@ public class DoCreateNetworkInstanceRollback extends AbstractServiceTaskProcesso rollbackSDNCReturnCode = execution.getVariable(Prefix + "rollbackSDNCReturnCode") String rollbackSDNCResponse = execution.getVariable(Prefix + "rollbackSDNCResponse") String rollbackSDNCReturnInnerCode = "" - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() rollbackSDNCResponse = rollbackSDNCResponse rollbackSDNCResponse = rollbackSDNCResponse.replace('$', '').replace('<?xml version="1.0" encoding="UTF-8"?>', "") if (rollbackSDNCReturnCode == "200") { diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstance.groovy index 163bd0f583..bf52b11de2 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstance.groovy @@ -491,7 +491,7 @@ public class DoCreateServiceInstance extends AbstractServiceTaskProcessor { String response = execution.getVariable("sdncAdapterResponse") logger.debug("SDNCResponse: " + response) - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){ diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstanceRollback.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstanceRollback.groovy index a337087105..1eeba493f4 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstanceRollback.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstanceRollback.groovy @@ -149,7 +149,7 @@ public class DoCreateServiceInstanceRollback extends AbstractServiceTaskProcesso logger.debug("SDNCResponse: " + response) logger.debug("workflowException: " + workflowException) - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){ diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModule.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModule.groovy index c03f9f9c95..6b4fc840f7 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModule.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModule.groovy @@ -84,7 +84,7 @@ public class DoCreateVfModule extends VfModuleBase { String Prefix="DCVFM_" ExceptionUtil exceptionUtil = new ExceptionUtil() JsonUtils jsonUtil = new JsonUtils() - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() OofInfraUtils oofInfraUtils = new OofInfraUtils() CatalogDbUtils catalogDbUtils = new CatalogDbUtilsFactory().create() DecomposeJsonUtil decomposeJsonUtils = new DecomposeJsonUtil() @@ -598,7 +598,7 @@ public class DoCreateVfModule extends VfModuleBase { */ public void validateWorkflowResponse(DelegateExecution execution, String responseVar, String responseCodeVar, String errorResponseVar) { - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() sdncAdapterUtils.validateSDNCResponse(execution, responseVar, responseCodeVar, errorResponseVar) } @@ -668,8 +668,7 @@ public class DoCreateVfModule extends VfModuleBase { rollbackData.put("VFMODULE", "rollbackPrepareUpdateVfModule", "true") execution.setVariable("rollbackData", rollbackData) } catch (Exception ex) { - ex.printStackTrace() - logger.debug('Exception occurred while postProcessing CreateAAIVfModule request:' + ex.getMessage()) + logger.debug('Exception occurred while postProcessing CreateAAIVfModule request: {}', ex.getMessage(), ex) exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Bad response from CreateAAIVfModule' + ex.getMessage()) } logger.trace('Exited ' + method) @@ -741,8 +740,7 @@ public class DoCreateVfModule extends VfModuleBase { } } } catch (Exception ex) { - ex.printStackTrace() - logger.debug('Exception occurred while executing AAI GET:' + ex.getMessage()) + logger.debug('Exception occurred while executing AAI GET: {}', ex.getMessage(), ex) exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'AAI GET Failed:' + ex.getMessage()) } logger.trace('Exited ' + method) @@ -822,17 +820,16 @@ public class DoCreateVfModule extends VfModuleBase { } } } catch (Exception ex) { - ex.printStackTrace() - logger.debug('Exception occurred while executing AAI GET:' + ex.getMessage()) + logger.debug('Exception occurred while executing AAI GET: {}', ex.getMessage(), ex) exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'AAI GET Failed:' + ex.getMessage()) } logger.trace('Exited ' + method) } catch (BpmnError e) { throw e; } catch (Exception e) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error("{} {} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in ' + method, "BPMN", - ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); + ErrorCode.UnknownError.getValue(), "Exception is:\n" + e, e); exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in queryAAIVfModuleForStatus(): ' + e.getMessage()) } } @@ -982,6 +979,8 @@ public class DoCreateVfModule extends VfModuleBase { //Get variables //cloudSiteId def cloudSiteId = execution.getVariable("DCVFM_cloudSiteId") + //cloudOwner + def cloudOwner = execution.getVariable("DCVFM_cloudOwner") //tenantId def tenantId = execution.getVariable("DCVFM_tenantId") //vnfType @@ -1070,6 +1069,7 @@ public class DoCreateVfModule extends VfModuleBase { String createVnfARequest = """ <createVfModuleRequest> <cloudSiteId>${MsoUtils.xmlEscape(cloudSiteId)}</cloudSiteId> + <cloudOwner>${MsoUtils.xmlEscape(cloudOwner)}</cloudOwner> <tenantId>${MsoUtils.xmlEscape(tenantId)}</tenantId> <vnfId>${MsoUtils.xmlEscape(vnfId)}</vnfId> <vnfName>${MsoUtils.xmlEscape(vnfName)}</vnfName> @@ -1233,6 +1233,7 @@ public class DoCreateVfModule extends VfModuleBase { def vfModuleModelName = execution.getVariable("DCVFM_vfModuleModelName") def vnfId = execution.getVariable("DCVFM_vnfId") def cloudSiteId = execution.getVariable("DCVFM_cloudSiteId") + def cloudOwner = execution.getVariable("DCVFM_cloudOwner") def sdncVersion = execution.getVariable("DCVFM_sdncVersion") def serviceModelInfo = execution.getVariable("serviceModelInfo") def vnfModelInfo = execution.getVariable("vnfModelInfo") @@ -1634,7 +1635,7 @@ public class DoCreateVfModule extends VfModuleBase { logger.debug("workflowException: " + workflowException) - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) String sdncResponse = response diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleRollback.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleRollback.groovy index a6040ac290..65f6f76a21 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleRollback.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleRollback.groovy @@ -92,6 +92,8 @@ public class DoCreateVfModuleRollback extends AbstractServiceTaskProcessor{ execution.setVariable("DCVFMR_vfModuleModelName", vfModuleModelName) String cloudSiteId = rollbackData.get("VFMODULE", "aiccloudregion") execution.setVariable("DCVFMR_cloudSiteId", cloudSiteId) + String cloudOwner = rollbackData.get("VFMODULE", "cloudowner") + execution.setVariable("DCVFMR_cloudOwner", cloudOwner) String heatStackId = rollbackData.get("VFMODULE", "heatstackid") execution.setVariable("DCVFMR_heatStackId", heatStackId) String requestId = rollbackData.get("VFMODULE", "msorequestid") @@ -358,6 +360,7 @@ public class DoCreateVfModuleRollback extends AbstractServiceTaskProcessor{ String origRequestId = execution.getVariable("DCVFMR_requestId") String srvInstId = execution.getVariable("DCVFMR_serviceInstanceId") String aicCloudRegion = execution.getVariable("DCVFMR_cloudSiteId") + String cloudOwner = execution.getVariable("DCVFMR_cloudOwner") String vnfId = execution.getVariable("DCVFMR_vnfId") String vfModuleId = execution.getVariable("DCVFMR_vfModuleId") String vfModuleStackId = execution.getVariable("DCVFMR_heatStackId") @@ -373,6 +376,7 @@ public class DoCreateVfModuleRollback extends AbstractServiceTaskProcessor{ String request = """ <deleteVfModuleRequest> <cloudSiteId>${MsoUtils.xmlEscape(aicCloudRegion)}</cloudSiteId> + <cloudOwner>${MsoUtils.xmlEscape(cloudOwner)}</cloudOwner> <tenantId>${MsoUtils.xmlEscape(tenantId)}</tenantId> <vnfId>${MsoUtils.xmlEscape(vnfId)}</vnfId> <vfModuleId>${MsoUtils.xmlEscape(vfModuleId)}</vfModuleId> @@ -459,7 +463,7 @@ public class DoCreateVfModuleRollback extends AbstractServiceTaskProcessor{ WorkflowException workflowException = execution.getVariable("WorkflowException") boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){ diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnf.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnf.groovy index 5f160bb068..fb5c0fa0aa 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnf.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnf.groovy @@ -61,7 +61,7 @@ class DoCreateVnf extends AbstractServiceTaskProcessor { ExceptionUtil exceptionUtil = new ExceptionUtil() JsonUtils jsonUtil = new JsonUtils() VidUtils vidUtils = new VidUtils(this) - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() OofInfraUtils oofInfraUtils = new OofInfraUtils() /** @@ -362,7 +362,7 @@ class DoCreateVnf extends AbstractServiceTaskProcessor { resourceClient.connect(uri, siUri) }catch(Exception ex) { - logger.debug("Error Occured in DoCreateVnf CreateGenericVnf Process ", ex) + logger.debug("Error Occured in DoCreateVnf CreateGenericVnf Process: {}", ex.getMessage(), ex) exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoCreateVnf CreateGenericVnf Process") } logger.trace("COMPLETED DoCreateVnf CreateGenericVnf Process") @@ -530,7 +530,7 @@ class DoCreateVnf extends AbstractServiceTaskProcessor { logger.debug("workflowException: " + workflowException) - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) logger.debug("SDNCResponse: " + response) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnfAndModulesRollback.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnfAndModulesRollback.groovy index 3209f52fef..7ea32d2a60 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnfAndModulesRollback.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnfAndModulesRollback.groovy @@ -315,7 +315,7 @@ class DoCreateVnfAndModulesRollback extends AbstractServiceTaskProcessor { logger.debug("workflowException: " + workflowException) - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) String sdncResponse = response diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstance.groovy index a54d90b2bf..2558f7eff5 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstance.groovy @@ -691,7 +691,7 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") WorkflowException workflowException = execution.getVariable("WorkflowException") - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) // reset variable String deleteSDNCResponseDecodeXml = execution.getVariable(Prefix + "deleteSDNCResponse") @@ -719,7 +719,7 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") WorkflowException workflowException = execution.getVariable("WorkflowException") - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) // reset variable String assignSDNCResponseDecodeXml = execution.getVariable(Prefix + "deactivateSDNCResponse") diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstanceRollback.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstanceRollback.groovy index d09fb03445..36c145b0e0 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstanceRollback.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstanceRollback.groovy @@ -220,7 +220,7 @@ public class DoDeleteNetworkInstanceRollback extends AbstractServiceTaskProcesso rollbackSDNCReturnCode = execution.getVariable(Prefix + "rollbackSDNCReturnCode") String rollbackSDNCResponse = execution.getVariable(Prefix + "rollbackSDNCResponse") String rollbackSDNCReturnInnerCode = "" - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() rollbackSDNCResponse = rollbackSDNCResponse.replace('$', '').replace('<?xml version="1.0" encoding="UTF-8"?>', "") if (rollbackSDNCReturnCode == "200") { if (utils.nodeExists(rollbackSDNCResponse, "response-code")) { diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteServiceInstance.groovy index 2e1cca54a6..0c676b5589 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteServiceInstance.groovy @@ -258,7 +258,7 @@ public class DoDeleteServiceInstance extends AbstractServiceTaskProcessor { logger.debug("SDNCResponse: " + response) logger.debug("workflowException: " + workflowException) - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){ diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModule.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModule.groovy index bedf5e0948..b21dcf3433 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModule.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModule.groovy @@ -111,6 +111,8 @@ public class DoDeleteVfModule extends AbstractServiceTaskProcessor{ execution.setVariable("tenantId", tenantId) String cloudSiteId = jsonUtil.getJsonValue(cloudConfiguration, "lcpCloudRegionId") execution.setVariable("cloudSiteId", cloudSiteId) + String cloudOwner = jsonUtil.getJsonValue(cloudConfiguration, "cloudOwner") + execution.setVariable("cloudOwner", cloudOwner) // Source is HARDCODED String source = "VID" execution.setVariable("source", source) @@ -176,6 +178,8 @@ public class DoDeleteVfModule extends AbstractServiceTaskProcessor{ execution.setVariable("vfModuleModelName", vfModuleModelName) String cloudSiteId = utils.getNodeText(xml, "aic-cloud-region") execution.setVariable("cloudSiteId", cloudSiteId) + String cloudOwner = utils.getNodeText(xml, "cloud-owner") + execution.setVariable("cloudOwner", cloudOwner) } // formulate the request for PrepareUpdateAAIVfModule @@ -281,6 +285,7 @@ public class DoDeleteVfModule extends AbstractServiceTaskProcessor{ def origRequestId = execution.getVariable('requestId') def srvInstId = execution.getVariable("serviceInstanceId") def aicCloudRegion = execution.getVariable("cloudSiteId") + def cloudOwner = execution.getVariable("cloudOwner") def vnfId = execution.getVariable("vnfId") def vfModuleId = execution.getVariable("vfModuleId") def vfModuleStackId = execution.getVariable('DoDVfMod_heatStackId') @@ -296,6 +301,7 @@ public class DoDeleteVfModule extends AbstractServiceTaskProcessor{ String request = """ <deleteVfModuleRequest> <cloudSiteId>${MsoUtils.xmlEscape(aicCloudRegion)}</cloudSiteId> + <cloudOwner>${MsoUtils.xmlEscape(cloudOwner)}</cloudOwner> <tenantId>${MsoUtils.xmlEscape(tenantId)}</tenantId> <vnfId>${MsoUtils.xmlEscape(vnfId)}</vnfId> <vfModuleId>${MsoUtils.xmlEscape(vfModuleId)}</vfModuleId> @@ -369,7 +375,7 @@ public class DoDeleteVfModule extends AbstractServiceTaskProcessor{ WorkflowException workflowException = execution.getVariable("WorkflowException") boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){ @@ -615,8 +621,7 @@ public class DoDeleteVfModule extends AbstractServiceTaskProcessor{ logger.debug("Received orchestration status from A&AI: " + orchestrationStatus) } } catch (Exception ex) { - ex.printStackTrace() - logger.debug('Exception occurred while executing AAI GET:' + ex.getMessage()) + logger.debug('Exception occurred while executing AAI GET: {}', ex.getMessage(), ex) exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'AAI GET Failed:' + ex.getMessage()) } logger.trace('Exited ' + method) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnf.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnf.groovy index 3be52f50f7..e5306c40de 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnf.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnf.groovy @@ -50,7 +50,7 @@ import org.slf4j.LoggerFactory public class DoDeleteVfModuleFromVnf extends VfModuleBase { private static final Logger logger = LoggerFactory.getLogger( DoDeleteVfModuleFromVnf.class); - + def Prefix="DDVFMV_" ExceptionUtil exceptionUtil = new ExceptionUtil() JsonUtils jsonUtil = new JsonUtils() @@ -66,7 +66,7 @@ public class DoDeleteVfModuleFromVnf extends VfModuleBase { initProcessVariables(execution) try { - + // Building Block-type request // Set mso-request-id to request-id for VNF Adapter interface @@ -75,10 +75,13 @@ public class DoDeleteVfModuleFromVnf extends VfModuleBase { execution.setVariable("requestId", requestId) logger.debug("msoRequestId: " + requestId) String tenantId = execution.getVariable("tenantId") - logger.debug("tenantId: " + tenantId) + logger.debug("tenantId: " + tenantId) String cloudSiteId = execution.getVariable("lcpCloudRegionId") execution.setVariable("cloudSiteId", cloudSiteId) logger.debug("cloudSiteId: " + cloudSiteId) + String cloudOwner = execution.getVariable("cloudOwner") + execution.setVariable("cloudOwner", cloudOwner) + logger.debug("cloudOwner: " + cloudOwner) // Source is HARDCODED String source = "VID" execution.setVariable("source", source) @@ -99,15 +102,15 @@ public class DoDeleteVfModuleFromVnf extends VfModuleBase { } else { execution.setVariable(Prefix + "serviceInstanceIdToSdnc", serviceInstanceId) - } + } String sdncVersion = execution.getVariable("sdncVersion") if (sdncVersion == null) { sdncVersion = "1707" } execution.setVariable(Prefix + "sdncVersion", sdncVersion) - logger.debug("Incoming Sdnc Version is: " + sdncVersion) - + logger.debug("Incoming Sdnc Version is: " + sdncVersion) + String sdncCallbackUrl = (String) UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution) if (sdncCallbackUrl == null || sdncCallbackUrl.trim().isEmpty()) { def msg = 'Required variable \'mso.workflow.sdncadapter.callback\' is missing' @@ -119,8 +122,6 @@ public class DoDeleteVfModuleFromVnf extends VfModuleBase { logger.debug("SDNC Callback URL: " + sdncCallbackUrl) logger.debug("SDNC Callback URL is: " + sdncCallbackUrl) - - }catch(BpmnError b){ throw b }catch(Exception e){ @@ -128,7 +129,7 @@ public class DoDeleteVfModuleFromVnf extends VfModuleBase { exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error encountered in PreProcess method!") } } - + public void queryAAIForVfModule(DelegateExecution execution) { def method = getClass().getSimpleName() + '.queryAAIForVfModule(' + 'execution=' + execution.getId() + @@ -151,8 +152,7 @@ public class DoDeleteVfModuleFromVnf extends VfModuleBase { execution.setVariable('DDVMFV_getVnfResponse', "Generic Vnf not found!") } } catch (Exception ex) { - ex.printStackTrace() - logger.debug('Exception occurred while executing AAI GET:' + ex.getMessage()) + logger.debug('Exception occurred while executing AAI GET: {}', ex.getMessage(), ex) execution.setVariable('DDVMFV_getVnfResponseCode', 500) execution.setVariable('DDVFMV_getVnfResponse', 'AAI GET Failed:' + ex.getMessage()) } @@ -166,7 +166,7 @@ public class DoDeleteVfModuleFromVnf extends VfModuleBase { exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in queryAAIForVfModule(): ' + e.getMessage()) } } - + /** * Validate the VF Module. That is, confirm that a VF Module with the input VF Module ID * exists in the retrieved Generic VNF. Then, check to make sure that if that VF Module @@ -339,7 +339,7 @@ public class DoDeleteVfModuleFromVnf extends VfModuleBase { logger.debug("workflowException: " + workflowException) - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) logger.debug("SDNCResponse: " + response) @@ -363,6 +363,7 @@ public class DoDeleteVfModuleFromVnf extends VfModuleBase { def origRequestId = execution.getVariable('requestId') def srvInstId = execution.getVariable("serviceInstanceId") def aicCloudRegion = execution.getVariable("cloudSiteId") + def cloudOwner = execution.getVariable("cloudOwner") def vnfId = execution.getVariable("vnfId") def vfModuleId = execution.getVariable("vfModuleId") def vfModuleStackId = execution.getVariable('DDVMFV_heatStackId') @@ -378,6 +379,7 @@ public class DoDeleteVfModuleFromVnf extends VfModuleBase { String request = """ <deleteVfModuleRequest> <cloudSiteId>${MsoUtils.xmlEscape(aicCloudRegion)}</cloudSiteId> + <cloudOwner>${MsoUtils.xmlEscape(cloudOwner)}</cloudOwner> <tenantId>${MsoUtils.xmlEscape(tenantId)}</tenantId> <vnfId>${MsoUtils.xmlEscape(vnfId)}</vnfId> <vfModuleId>${MsoUtils.xmlEscape(vfModuleId)}</vfModuleId> diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleVolumeV2.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleVolumeV2.groovy index 787b582808..c419f0dc7d 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleVolumeV2.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleVolumeV2.groovy @@ -170,7 +170,7 @@ class DoDeleteVfModuleVolumeV2 extends AbstractServiceTaskProcessor{ execution.setVariable(prefix+'volumeGroupHeatStackId', heatStackId) logger.debug('Heat stack id from AAI response: ' + heatStackId) - AAIResultWrapper wrapper = getAAIClient().get(uri); + AAIResultWrapper wrapper = getAAIClient().get(resourceUri); Optional<Relationships> relationships = wrapper.getRelationships() String volumeGroupTenantId = null @@ -217,6 +217,7 @@ class DoDeleteVfModuleVolumeV2 extends AbstractServiceTaskProcessor{ */ public void prepareVnfAdapterDeleteRequest(DelegateExecution execution, isDebugLogEnabled) { def cloudRegion = execution.getVariable(prefix+'aicCloudRegion') + def cloudOwner = execution.getVariable(prefix+'cloudOwner') def tenantId = execution.getVariable('tenantId') // input parameter (optional) - see preProcessRequest def volumeGroupId = execution.getVariable('volumeGroupId') // input parameter (required) def volumeGroupHeatStackId = execution.getVariable(prefix+'volumeGroupHeatStackId') // from AAI query volume group @@ -233,6 +234,7 @@ class DoDeleteVfModuleVolumeV2 extends AbstractServiceTaskProcessor{ String vnfAdapterRestRequest = """ <deleteVolumeGroupRequest> <cloudSiteId>${MsoUtils.xmlEscape(cloudRegion)}</cloudSiteId> + <cloudOwner>${MsoUtils.xmlEscape(cloudOwner)}</cloudOwner> <tenantId>${MsoUtils.xmlEscape(tenantId)}</tenantId> <volumeGroupId>${MsoUtils.xmlEscape(volumeGroupId)}</volumeGroupId> <volumeGroupStackId>${MsoUtils.xmlEscape(volumeGroupHeatStackId)}</volumeGroupStackId> diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnfAndModules.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnfAndModules.groovy index fb62babae9..9bd3388b79 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnfAndModules.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnfAndModules.groovy @@ -60,7 +60,7 @@ class DoDeleteVnfAndModules extends AbstractServiceTaskProcessor { ExceptionUtil exceptionUtil = new ExceptionUtil() JsonUtils jsonUtil = new JsonUtils() VidUtils vidUtils = new VidUtils(this) - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() /** * This method gets and validates the incoming @@ -322,7 +322,7 @@ class DoDeleteVnfAndModules extends AbstractServiceTaskProcessor { } if (vfModuleBaseEntry != null) { vfModulesList.add(vfModuleBaseEntry) - } + } } }else{ execution.setVariable('DCVFM_queryAAIVfModuleResponseCode', 404) @@ -331,8 +331,7 @@ class DoDeleteVnfAndModules extends AbstractServiceTaskProcessor { } execution.setVariable("DDVAM_vfModules", vfModulesList) } catch (Exception ex) { - ex.printStackTrace() - logger.debug('Exception occurred while executing AAI GET:' + ex.getMessage()) + logger.debug('Exception occurred while executing AAI GET: {}', ex.getMessage(), ex) exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'AAI GET Failed:' + ex.getMessage()) } logger.trace('Exited ' + method) @@ -501,7 +500,7 @@ class DoDeleteVnfAndModules extends AbstractServiceTaskProcessor { logger.debug("workflowException: " + workflowException) - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) logger.debug("SDNCResponse: " + response) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateE2EServiceInstance.groovy index 4fe30803c4..508131279a 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateE2EServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateE2EServiceInstance.groovy @@ -195,7 +195,6 @@ public class DoUpdateE2EServiceInstance extends AbstractServiceTaskProcessor { payload = utils.formatXml(payload) execution.setVariable("CVFMI_initResOperStatusRequest", payload) logger.info( "Outgoing initResourceOperationStatus: \n" + payload) - utils.logAudit("CreateVfModuleInfra Outgoing initResourceOperationStatus Request: " + payload) }catch(Exception e){ logger.info( "Exception Occured Processing preInitResourcesOperStatus. Exception is:\n" + e) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstance.groovy index ce61595680..6162780b27 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstance.groovy @@ -782,7 +782,7 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor { String source = execution.getVariable(Prefix + "source") String requestInput = execution.getVariable(Prefix + "networkRequest") - String queryIdResponse = execution.getVariable(Prefix + "requeryIdAAIResponse") + L3Network queryIdResponse = execution.getVariable(Prefix + "requeryIdAAIResponse") String cloudRegionId = execution.getVariable(Prefix + "cloudRegionPo") String backoutOnFailure = execution.getVariable(Prefix + "rollbackEnabled") @@ -946,7 +946,7 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor { boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) // reset variable String changeAssignSDNCResponseDecodeXml = execution.getVariable(Prefix + "changeAssignSDNCResponse") diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstanceRollback.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstanceRollback.groovy index 1b98451fbe..371e54ca75 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstanceRollback.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstanceRollback.groovy @@ -204,7 +204,7 @@ public class DoUpdateNetworkInstanceRollback extends AbstractServiceTaskProcesso rollbackSDNCReturnCode = execution.getVariable(Prefix + "rollbackSDNCReturnCode") String rollbackSDNCResponse = execution.getVariable(Prefix + "rollbackSDNCResponse") String rollbackSDNCReturnInnerCode = "" - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() rollbackSDNCResponse = rollbackSDNCResponse.replace('$', '').replace('<?xml version="1.0" encoding="UTF-8"?>', "") if (rollbackSDNCReturnCode == "200") { if (utils.nodeExists(rollbackSDNCResponse, "response-code")) { diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVfModule.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVfModule.groovy index a17dc9d7fe..abbcf66323 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVfModule.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVfModule.groovy @@ -143,6 +143,12 @@ public class DoUpdateVfModule extends VfModuleBase { execution.setVariable("DOUPVfMod_aicCloudRegion", cloudSiteId) logger.debug("cloudSiteId: " + cloudSiteId) + + //cloudOwner + def cloudOwner = execution.getVariable("cloudOwner") + execution.setVariable("DOUPVfMod_cloudOwner", cloudOwner) + logger.debug("cloudOwner: " + cloudOwner) + //vnfType def vnfType = execution.getVariable("vnfType") execution.setVariable("DOUPVfMod_vnfType", vnfType) @@ -304,6 +310,7 @@ public class DoUpdateVfModule extends VfModuleBase { execution.setVariable('DOUPVfMod_modelCustomizationUuid', getNodeTextForce(vnfInputs, 'model-customization-id')) execution.setVariable('DOUPVfMod_serviceId', getRequiredNodeText(execution, vnfInputs, 'service-id')) execution.setVariable('DOUPVfMod_aicCloudRegion', getRequiredNodeText(execution, vnfInputs, 'aic-cloud-region')) + execution.setVariable('DOUPVfMod_cloudOwner', getRequiredNodeText(execution, vnfInputs, 'cloud-owner')) execution.setVariable('DOUPVfMod_tenantId', getRequiredNodeText(execution, vnfInputs, 'tenant-id')) //isBaseVfModule def isBaseVfModule = "false" @@ -640,6 +647,7 @@ public class DoUpdateVfModule extends VfModuleBase { heatStackId = vfModule.getHeatStackId() } def cloudId = execution.getVariable('DOUPVfMod_aicCloudRegion') + def cloudOwner = execution.getVariable('DOUPVfMod_cloudOwner') def vnfType = execution.getVariable('DOUPVfMod_vnfType') def vnfName = execution.getVariable('DOUPVfMod_vnfName') def vfModuleModelName = execution.getVariable('DOUPVfMod_vfModuleModelName') @@ -672,6 +680,7 @@ public class DoUpdateVfModule extends VfModuleBase { String vnfAdapterRestRequest = """ <updateVfModuleRequest> <cloudSiteId>${MsoUtils.xmlEscape(cloudId)}</cloudSiteId> + <cloudOwner>${MsoUtils.xmlEscape(cloudOwner)}</cloudOwner> <tenantId>${MsoUtils.xmlEscape(tenantId)}</tenantId> <vnfId>${MsoUtils.xmlEscape(vnfId)}</vnfId> <vfModuleId>${MsoUtils.xmlEscape(vfModuleId)}</vfModuleId> @@ -979,7 +988,7 @@ public class DoUpdateVfModule extends VfModuleBase { logger.debug("workflowException: " + workflowException) - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) logger.debug("SDNCResponse: " + response) @@ -1032,8 +1041,7 @@ public class DoUpdateVfModule extends VfModuleBase { } } } catch (Exception ex) { - ex.printStackTrace() - logger.debug('Exception occurred while executing AAI GET:' + ex.getMessage()) + logger.debug('Exception occurred while executing AAI GET: {}', ex.getMessage(), ex) exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'AAI GET Failed:' + ex.getMessage()) } logger.trace('Exited ' + method) @@ -1042,7 +1050,7 @@ public class DoUpdateVfModule extends VfModuleBase { } catch (Exception e) { logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in ' + method, "BPMN", - ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); + ErrorCode.UnknownError.getValue(), "Exception is:\n" + e, e); exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in queryAAIVfModule(): ' + e.getMessage()) } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVnfAndModules.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVnfAndModules.groovy index 3dd5e61246..eb788a85b7 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVnfAndModules.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVnfAndModules.groovy @@ -265,8 +265,7 @@ class DoUpdateVnfAndModules extends AbstractServiceTaskProcessor { } execution.setVariable("DUVAM_vfModules", vfModulesList) } catch (Exception ex) { - ex.printStackTrace() - logger.debug('Exception occurred while executing AAI GET:' + ex.getMessage()) + logger.debug('Exception occurred while executing AAI GET: {}', ex.getMessage(), ex) exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'AAI GET Failed:' + ex.getMessage()) } logger.trace('Exited ' + method) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateCustomE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateCustomE2EServiceInstance.groovy index 4e3517e5b5..8e554e286d 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateCustomE2EServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateCustomE2EServiceInstance.groovy @@ -72,7 +72,6 @@ public class UpdateCustomE2EServiceInstance extends AbstractServiceTaskProcessor try { String siRequest = execution.getVariable("bpmnRequest") - utils.logAudit(siRequest) String requestId = execution.getVariable("mso-request-id") execution.setVariable("msoRequestId", requestId) @@ -190,6 +189,7 @@ public class UpdateCustomE2EServiceInstance extends AbstractServiceTaskProcessor JSONObject ob = new JSONObject(wrapper.getJson()) JSONArray ar = ob.getJSONObject("relationship-list").getJSONArray("relationship") + execution.setVariable("serviceInstanceData-original", si.get()) execution.setVariable("serviceRelationShip", ar.toString()) @@ -277,7 +277,6 @@ public class UpdateCustomE2EServiceInstance extends AbstractServiceTaskProcessor payload = utils.formatXml(payload) execution.setVariable("CVFMI_updateServiceOperStatusRequest", payload) logger.error( "Outgoing updateServiceOperStatusRequest: \n" + payload) - utils.logAudit("CreateVfModuleInfra Outgoing updateServiceOperStatusRequest Request: " + payload) }catch(Exception e){ logger.debug( "Exception Occured Processing prepareInitServiceOperationStatus. Exception is:\n" + e) @@ -398,7 +397,6 @@ public class UpdateCustomE2EServiceInstance extends AbstractServiceTaskProcessor <aetgt:ErrorCode>${MsoUtils.xmlEscape(errorCode)}</aetgt:ErrorCode> </aetgt:WorkflowException>""" - utils.logAudit(buildworkflowException) sendWorkflowResponse(execution, 500, buildworkflowException) } catch (Exception ex) { diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateNetworkInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateNetworkInstance.groovy index 0b46a5a849..b12da9f959 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateNetworkInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateNetworkInstance.groovy @@ -362,7 +362,7 @@ public class UpdateNetworkInstance extends AbstractServiceTaskProcessor { } catch (Exception ex) { String errorException = " Bpmn error encountered in UpdateNetworkInstance flow. FalloutHandlerRequest, buildErrorResponse() - " - logger.debug("Exception error in UpdateNetworkInstance flow, buildErrorResponse(): " + ex.getMessage()) + logger.debug("Exception error in UpdateNetworkInstance flow, buildErrorResponse(): {}", ex.getMessage(), ex) falloutHandlerRequest = """<aetgt:FalloutHandlerRequest xmlns:aetgt="http://org.onap/so/workflow/schema/v1" xmlns:ns="http://org.onap/so/request/types/v1" diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolume.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolume.groovy index 0c3294778a..3e9b934a2e 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolume.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolume.groovy @@ -100,6 +100,7 @@ class UpdateVfModuleVolume extends VfModuleBase { execution.setVariable('UPDVfModVol_vnfType', getRequiredNodeText(execution, volumeInputs, 'vnf-type')) execution.setVariable('UPDVfModVol_serviceId', getRequiredNodeText(execution, volumeInputs, 'service-id')) execution.setVariable('UPDVfModVol_aicCloudRegion', getRequiredNodeText(execution, volumeInputs, 'aic-cloud-region')) + execution.setVariable('UPDVfModVol_cloudOwner', getRequiredNodeText(execution, volumeInputs, 'cloud-owner')) execution.setVariable('UPDVfModVol_tenantId', getRequiredNodeText(execution, volumeInputs, 'tenant-id')) def volumeParams = utils.getNodeXml(request, 'volume-params') @@ -255,6 +256,7 @@ class UpdateVfModuleVolume extends VfModuleBase { String vnfAdapterRestRequest = """ <updateVolumeGroupRequest> <cloudSiteId>${MsoUtils.xmlEscape(aicCloudRegion)}</cloudSiteId> + <cloudOwner>${MsoUtils.xmlEscape(cloudOwner)}</cloudOwner> <tenantId>${MsoUtils.xmlEscape(tenantId)}</tenantId> <volumeGroupId>${MsoUtils.xmlEscape(volumeGroupId)}</volumeGroupId> <volumeGroupStackId>${MsoUtils.xmlEscape(volumeGroupHeatStackId)}</volumeGroupStackId> diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1.groovy index 361d6a2173..0344206145 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1.groovy @@ -135,6 +135,7 @@ class UpdateVfModuleVolumeInfraV1 extends VfModuleBase { execution.setVariable('UPDVfModVol_vnfVersion', getRequiredNodeText(execution, volumeInputs, 'asdc-service-model-version')) execution.setVariable('UPDVfModVol_serviceId', utils.getNodeText(volumeInputs, 'service-id')) execution.setVariable('UPDVfModVol_aicCloudRegion', getRequiredNodeText(execution, volumeInputs, 'aic-cloud-region')) + execution.setVariable('UPDVfModVol_cloudRegion', getRequiredNodeText(execution, volumeInputs, 'cloud-owner')) execution.setVariable('UPDVfModVol_tenantId', getRequiredNodeText(execution, volumeInputs, 'tenant-id')) //execution.setVariable('UPDVfModVol_modelCustomizationId', getRequiredNodeText(execution, volumeInputs, 'model-customization-id')) @@ -296,6 +297,7 @@ class UpdateVfModuleVolumeInfraV1 extends VfModuleBase { public void prepVnfAdapterRest(DelegateExecution execution, isDebugLogEnabled) { def aicCloudRegion = execution.getVariable('UPDVfModVol_aicCloudRegion') + def cloudOwner = execution.getVariable("UPDVfModVol_cloudRegion") def tenantId = execution.getVariable('UPDVfModVol_tenantId') def volumeGroupId = execution.getVariable('UPDVfModVol_volumeGroupId') @@ -328,6 +330,7 @@ class UpdateVfModuleVolumeInfraV1 extends VfModuleBase { String vnfAdapterRestRequest = """ <updateVolumeGroupRequest> <cloudSiteId>${MsoUtils.xmlEscape(aicCloudRegion)}</cloudSiteId> + <cloudOwner>${MsoUtils.xmlEscape(cloudOwner)}</cloudOwner> <tenantId>${MsoUtils.xmlEscape(tenantId)}</tenantId> <vnfId>${MsoUtils.xmlEscape(vnfId)}</vnfId> <vnfName>${MsoUtils.xmlEscape(vnfName)}</vnfName> diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRG.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRG.groovy index 24589a0893..2c5b6430e6 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRG.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRG.groovy @@ -511,7 +511,7 @@ public class DoCreateAllottedResourceBRG extends AbstractServiceTaskProcessor{ boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") logger.debug("SDNCResponse: " + response) - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){ diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGRollback.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGRollback.groovy index f27b3d94b1..58c0ef2dcf 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGRollback.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGRollback.groovy @@ -167,7 +167,7 @@ public class DoCreateAllottedResourceBRGRollback extends AbstractServiceTaskProc boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") logger.debug("SDNCResponse: " + response) - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){ diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXC.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXC.groovy index b6e7470834..61dd13b4e2 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXC.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXC.groovy @@ -446,7 +446,7 @@ public class DoCreateAllottedResourceTXC extends AbstractServiceTaskProcessor{ boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") logger.debug("SDNCResponse: " + response) - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){ diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCRollback.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCRollback.groovy index ad2c9e155d..44e27d99cf 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCRollback.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCRollback.groovy @@ -168,7 +168,7 @@ public class DoCreateAllottedResourceTXCRollback extends AbstractServiceTaskProc boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") logger.debug("SDNCResponse: " + response) - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){ diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceBRG.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceBRG.groovy index ca1b2ded2a..9dcee3dfb2 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceBRG.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceBRG.groovy @@ -302,7 +302,7 @@ public class DoDeleteAllottedResourceBRG extends AbstractServiceTaskProcessor{ boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") logger.debug("SDNCResponse: " + response) - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){ diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceTXC.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceTXC.groovy index 0da6fd26f4..43e095859e 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceTXC.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceTXC.groovy @@ -306,7 +306,7 @@ public class DoDeleteAllottedResourceTXC extends AbstractServiceTaskProcessor{ boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") logger.debug("SDNCResponse: " + response) - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){ diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/AAICreateResources.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/AAICreateResources.java index a47b16fc33..d401522800 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/AAICreateResources.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/AAICreateResources.java @@ -23,7 +23,6 @@ package org.onap.so.bpmn.infrastructure.aai; import java.util.HashMap; import java.util.Map; import java.util.Optional; - import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.client.aai.AAIObjectType; import org.onap.so.client.aai.AAIResourcesClient; @@ -34,57 +33,64 @@ import org.onap.so.client.aai.entities.uri.AAIUriFactory; public class AAICreateResources extends AAIResource { - public void createAAIProject (String projectName, String serviceInstance){ - AAIResourceUri projectURI = AAIUriFactory.createResourceUri(AAIObjectType.PROJECT, projectName); - AAIResourceUri serviceInstanceURI = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstance); - getAaiClient().createIfNotExists(projectURI, Optional.empty()).connect(projectURI, serviceInstanceURI); - - } - - public void createAAIOwningEntity(String owningEntityId, String owningEntityName,String serviceInstance){ - AAIResourceUri owningEntityURI = AAIUriFactory.createResourceUri(AAIObjectType.OWNING_ENTITY, owningEntityId); - AAIResourceUri serviceInstanceURI = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstance); - Map<String, String> hashMap= new HashMap<>(); - hashMap.put("owning-entity-name", owningEntityName); - getAaiClient().createIfNotExists(owningEntityURI, Optional.of(hashMap)).connect(owningEntityURI, serviceInstanceURI); - } + public void createAAIProject(String projectName, String serviceInstance) { + AAIResourceUri projectURI = AAIUriFactory.createResourceUri(AAIObjectType.PROJECT, projectName); + AAIResourceUri serviceInstanceURI = + AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstance); + getAaiClient().createIfNotExists(projectURI, Optional.empty()).connect(projectURI, serviceInstanceURI); + + } + + public void createAAIOwningEntity(String owningEntityId, String owningEntityName, String serviceInstance) { + AAIResourceUri owningEntityURI = AAIUriFactory.createResourceUri(AAIObjectType.OWNING_ENTITY, owningEntityId); + AAIResourceUri serviceInstanceURI = + AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstance); + Map<String, String> hashMap = new HashMap<>(); + hashMap.put("owning-entity-name", owningEntityName); + getAaiClient().createIfNotExists(owningEntityURI, Optional.of(hashMap)).connect(owningEntityURI, + serviceInstanceURI); + } + + public boolean existsOwningEntity(String owningEntityId) { + AAIResourceUri owningEntityURI = AAIUriFactory.createResourceUri(AAIObjectType.OWNING_ENTITY, owningEntityId); + return getAaiClient().exists(owningEntityURI); + } + + public void connectOwningEntityandServiceInstance(String owningEntityId, String serviceInstance) { + AAIResourceUri owningEntityURI = AAIUriFactory.createResourceUri(AAIObjectType.OWNING_ENTITY, owningEntityId); + AAIResourceUri serviceInstanceURI = + AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstance); + getAaiClient().connect(owningEntityURI, serviceInstanceURI); + } + + public void createAAIPlatform(String platformName, String vnfId) { + AAIResourceUri platformURI = AAIUriFactory.createResourceUri(AAIObjectType.PLATFORM, platformName); + AAIResourceUri genericVnfURI = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId); + getAaiClient().createIfNotExists(platformURI, Optional.empty()).connect(platformURI, genericVnfURI); + } + + public void createAAILineOfBusiness(String lineOfBusiness, String vnfId) { + AAIResourceUri lineOfBusinessURI = + AAIUriFactory.createResourceUri(AAIObjectType.LINE_OF_BUSINESS, lineOfBusiness); + AAIResourceUri genericVnfURI = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId); + getAaiClient().createIfNotExists(lineOfBusinessURI, Optional.empty()).connect(lineOfBusinessURI, genericVnfURI); + } + + public void createAAIServiceInstance(String globalCustomerId, String serviceType, String serviceInstanceId) { + AAIResourceUri serviceInstanceURI = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, + globalCustomerId, serviceType, serviceInstanceId); + getAaiClient().createIfNotExists(serviceInstanceURI, Optional.empty()); + } + + public Optional<GenericVnf> getVnfInstance(String vnfId) { + try { + AAIResourceUri vnfURI = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId); + AAIResultWrapper aaiResponse = getAaiClient().get(vnfURI); + Optional<GenericVnf> vnf = aaiResponse.asBean(GenericVnf.class); + return vnf; + } catch (Exception ex) { + return Optional.empty(); + } + } - public boolean existsOwningEntity(String owningEntityId){ - AAIResourceUri owningEntityURI = AAIUriFactory.createResourceUri(AAIObjectType.OWNING_ENTITY, owningEntityId); - return getAaiClient().exists(owningEntityURI); - } - - public void connectOwningEntityandServiceInstance (String owningEntityId, String serviceInstance){ - AAIResourceUri owningEntityURI = AAIUriFactory.createResourceUri(AAIObjectType.OWNING_ENTITY, owningEntityId); - AAIResourceUri serviceInstanceURI = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstance); - getAaiClient().connect(owningEntityURI, serviceInstanceURI); - } - - public void createAAIPlatform(String platformName,String vnfId){ - AAIResourceUri platformURI = AAIUriFactory.createResourceUri(AAIObjectType.PLATFORM, platformName); - AAIResourceUri genericVnfURI = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF,vnfId); - getAaiClient().createIfNotExists(platformURI, Optional.empty()).connect(platformURI, genericVnfURI); - } - - public void createAAILineOfBusiness(String lineOfBusiness,String vnfId){ - AAIResourceUri lineOfBusinessURI = AAIUriFactory.createResourceUri(AAIObjectType.LINE_OF_BUSINESS, lineOfBusiness); - AAIResourceUri genericVnfURI = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF,vnfId); - getAaiClient().createIfNotExists(lineOfBusinessURI, Optional.empty()).connect(lineOfBusinessURI, genericVnfURI); - } - public void createAAIServiceInstance(String globalCustomerId, String serviceType, String serviceInstanceId){ - AAIResourceUri serviceInstanceURI = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, globalCustomerId,serviceType,serviceInstanceId); - getAaiClient().createIfNotExists(serviceInstanceURI, Optional.empty()); - } - - public Optional<GenericVnf> getVnfInstance(String vnfId){ - try{ - AAIResourceUri vnfURI = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId); - AAIResultWrapper aaiResponse = getAaiClient().get(vnfURI); - Optional<GenericVnf> vnf = aaiResponse.asBean(GenericVnf.class); - return vnf; - } catch (Exception ex){ - return Optional.empty(); - } - } - } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/AAIDeleteServiceInstance.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/AAIDeleteServiceInstance.java index cea6fe740d..2526ca5c25 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/AAIDeleteServiceInstance.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/AAIDeleteServiceInstance.java @@ -29,21 +29,23 @@ import org.onap.so.client.aai.entities.uri.AAIResourceUri; import org.onap.so.client.aai.entities.uri.AAIUriFactory; import org.springframework.stereotype.Component; -public class AAIDeleteServiceInstance extends AAIResource implements JavaDelegate{ +public class AAIDeleteServiceInstance extends AAIResource implements JavaDelegate { + + ExceptionUtil exceptionUtil = new ExceptionUtil(); + + public void execute(DelegateExecution execution) throws Exception { + try { + String serviceInstanceId = (String) execution.getVariable("serviceInstanceId"); + AAIResourceUri serviceInstanceURI = + AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId); + getAaiClient().delete(serviceInstanceURI); + execution.setVariable("GENDS_SuccessIndicator", true); + } catch (Exception ex) { + String msg = "Exception in Delete Serivce Instance. Service Instance could not be deleted in AAI." + + ex.getMessage(); + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg); + } + + } - ExceptionUtil exceptionUtil = new ExceptionUtil(); - public void execute(DelegateExecution execution) throws Exception { - try{ - String serviceInstanceId = (String) execution.getVariable("serviceInstanceId"); - AAIResourceUri serviceInstanceURI = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, - serviceInstanceId); - getAaiClient().delete(serviceInstanceURI); - execution.setVariable("GENDS_SuccessIndicator",true); - } catch(Exception ex){ - String msg = "Exception in Delete Serivce Instance. Service Instance could not be deleted in AAI." + ex.getMessage(); - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg); - } - - } - } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/AAIResource.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/AAIResource.java index 3bc02be476..1410752f76 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/AAIResource.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/AAIResource.java @@ -24,17 +24,17 @@ import org.onap.so.client.aai.AAIResourcesClient; import org.springframework.stereotype.Component; @Component -public abstract class AAIResource { - private AAIResourcesClient aaiClient; +public abstract class AAIResource { + private AAIResourcesClient aaiClient; - public AAIResourcesClient getAaiClient() { - if(aaiClient == null) - return new AAIResourcesClient(); - else - return aaiClient; - } + public AAIResourcesClient getAaiClient() { + if (aaiClient == null) + return new AAIResourcesClient(); + else + return aaiClient; + } - public void setAaiClient(AAIResourcesClient aaiClient) { - this.aaiClient = aaiClient; - } + public void setAaiClient(AAIResourcesClient aaiClient) { + this.aaiClient = aaiClient; + } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/AAIServiceInstance.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/AAIServiceInstance.java index 67ba155336..376ca4dbdb 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/AAIServiceInstance.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/AAIServiceInstance.java @@ -21,74 +21,144 @@ package org.onap.so.bpmn.infrastructure.aai; public class AAIServiceInstance { - String serviceInstanceName; - String serviceType; - String serviceRole; - String orchestrationStatus; - String modelInvariantUuid; - String modelVersionId; - String environmentContext; - String workloadContext; - public AAIServiceInstance(String serviceInstanceName, String serviceType, String serviceRole, - String orchestrationStatus, String modelInvariantUuid, String modelVersionId, String environmentContext, - String workloadContext) { - this.serviceInstanceName = serviceInstanceName; - this.serviceType = serviceType; - this.serviceRole = serviceRole; - this.orchestrationStatus = orchestrationStatus; - this.modelInvariantUuid = modelInvariantUuid; - this.modelVersionId = modelVersionId; - this.environmentContext = environmentContext; - this.workloadContext = workloadContext; - } - public String getServiceInstanceName() { - return serviceInstanceName; - } - public void setServiceInstanceName(String serviceInstanceName) { - this.serviceInstanceName = serviceInstanceName; - } - public String getServiceType() { - return serviceType; - } - public void setServiceType(String serviceType) { - this.serviceType = serviceType; - } - public String getServiceRole() { - return serviceRole; - } - public void setServiceRole(String serviceRole) { - this.serviceRole = serviceRole; - } - public String getOrchestrationStatus() { - return orchestrationStatus; - } - public void setOrchestrationStatus(String orchestrationStatus) { - this.orchestrationStatus = orchestrationStatus; - } - public String getModelInvariantUuid() { - return modelInvariantUuid; - } - public void setModelInvariantUuid(String modelInvariantUuid) { - this.modelInvariantUuid = modelInvariantUuid; - } - public String getModelVersionId() { - return modelVersionId; - } - public void setModelVersionId(String modelVersionId) { - this.modelVersionId = modelVersionId; - } - public String getEnvironmentContext() { - return environmentContext; - } - public void setEnvironmentContext(String environmentContext) { - this.environmentContext = environmentContext; - } - public String getWorkloadContext() { - return workloadContext; - } - public void setWorkloadContext(String workloadContext) { - this.workloadContext = workloadContext; - } - + String serviceInstanceName; + String serviceType; + String serviceRole; + String orchestrationStatus; + String modelInvariantUuid; + String modelVersionId; + String environmentContext; + String workloadContext; + + public static class AAIServiceInstanceBuilder { + private String serviceInstanceName; + private String serviceType; + private String serviceRole; + private String orchestrationStatus; + private String modelInvariantUuid; + private String modelVersionId; + private String environmentContext; + private String workloadContext; + + public AAIServiceInstanceBuilder setServiceInstanceName(String serviceInstanceName) { + this.serviceInstanceName = serviceInstanceName; + return this; + } + + public AAIServiceInstanceBuilder setServiceType(String serviceType) { + this.serviceType = serviceType; + return this; + } + + public AAIServiceInstanceBuilder setServiceRole(String serviceRole) { + this.serviceRole = serviceRole; + return this; + } + + public AAIServiceInstanceBuilder setOrchestrationStatus(String orchestrationStatus) { + this.orchestrationStatus = orchestrationStatus; + return this; + } + + public AAIServiceInstanceBuilder setModelInvariantUuid(String modelInvariantUuid) { + this.modelInvariantUuid = modelInvariantUuid; + return this; + } + + public AAIServiceInstanceBuilder setModelVersionId(String modelVersionId) { + this.modelVersionId = modelVersionId; + return this; + } + + public AAIServiceInstanceBuilder setEnvironmentContext(String environmentContext) { + this.environmentContext = environmentContext; + return this; + } + + public AAIServiceInstanceBuilder setWorkloadContext(String workloadContext) { + this.workloadContext = workloadContext; + return this; + } + + public AAIServiceInstance createAAIServiceInstance() { + return new AAIServiceInstance(this); + } + } + + public AAIServiceInstance(AAIServiceInstanceBuilder aaiServiceInstanceBuilder) { + this.serviceInstanceName = aaiServiceInstanceBuilder.serviceInstanceName; + this.serviceType = aaiServiceInstanceBuilder.serviceType; + this.serviceRole = aaiServiceInstanceBuilder.serviceRole; + this.orchestrationStatus = aaiServiceInstanceBuilder.orchestrationStatus; + this.modelInvariantUuid = aaiServiceInstanceBuilder.modelInvariantUuid; + this.modelVersionId = aaiServiceInstanceBuilder.modelVersionId; + this.environmentContext = aaiServiceInstanceBuilder.environmentContext; + this.workloadContext = aaiServiceInstanceBuilder.workloadContext; + } + + public String getServiceInstanceName() { + return serviceInstanceName; + } + + public void setServiceInstanceName(String serviceInstanceName) { + this.serviceInstanceName = serviceInstanceName; + } + + public String getServiceType() { + return serviceType; + } + + public void setServiceType(String serviceType) { + this.serviceType = serviceType; + } + + public String getServiceRole() { + return serviceRole; + } + + public void setServiceRole(String serviceRole) { + this.serviceRole = serviceRole; + } + + public String getOrchestrationStatus() { + return orchestrationStatus; + } + + public void setOrchestrationStatus(String orchestrationStatus) { + this.orchestrationStatus = orchestrationStatus; + } + + public String getModelInvariantUuid() { + return modelInvariantUuid; + } + + public void setModelInvariantUuid(String modelInvariantUuid) { + this.modelInvariantUuid = modelInvariantUuid; + } + + public String getModelVersionId() { + return modelVersionId; + } + + public void setModelVersionId(String modelVersionId) { + this.modelVersionId = modelVersionId; + } + + public String getEnvironmentContext() { + return environmentContext; + } + + public void setEnvironmentContext(String environmentContext) { + this.environmentContext = environmentContext; + } + + public String getWorkloadContext() { + return workloadContext; + } + + public void setWorkloadContext(String workloadContext) { + this.workloadContext = workloadContext; + } + } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/groovyflows/AAICreateResources.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/groovyflows/AAICreateResources.java index 0c519ef29f..bbca10be0f 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/groovyflows/AAICreateResources.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/groovyflows/AAICreateResources.java @@ -25,7 +25,6 @@ package org.onap.so.bpmn.infrastructure.aai.groovyflows; import java.util.HashMap; import java.util.Map; import java.util.Optional; - import org.onap.aai.domain.yang.OwningEntities; import org.onap.aai.domain.yang.OwningEntity; import org.onap.so.client.aai.AAIObjectPlurals; @@ -37,85 +36,88 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class AAICreateResources { - - private static final Logger logger = LoggerFactory.getLogger(AAICreateResources.class); - - public void createAAIProject (String projectName, String serviceInstance){ - AAIResourceUri projectURI = AAIUriFactory.createResourceUri(AAIObjectType.PROJECT, projectName); - AAIResourceUri serviceInstanceURI = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstance); - AAIResourcesClient aaiRC = new AAIResourcesClient(); - aaiRC.createIfNotExists(projectURI, Optional.empty()).connect(projectURI, serviceInstanceURI); - - } - - public void createAAIOwningEntity(String owningEntityId, String owningEntityName,String serviceInstance){ - AAIResourceUri owningEntityURI = AAIUriFactory.createResourceUri(AAIObjectType.OWNING_ENTITY, owningEntityId); - AAIResourceUri serviceInstanceURI = AAIUriFactory.createNodesUri(AAIObjectType.SERVICE_INSTANCE, serviceInstance); - Map<String, String> hashMap= new HashMap<>(); - hashMap.put("owning-entity-name", owningEntityName); - AAIResourcesClient aaiRC = new AAIResourcesClient(); - aaiRC.createIfNotExists(owningEntityURI, Optional.of(hashMap)).connect(owningEntityURI, serviceInstanceURI); - } - - public boolean existsOwningEntity(String owningEntityId){ - AAIResourceUri owningEntityURI = AAIUriFactory.createResourceUri(AAIObjectType.OWNING_ENTITY, owningEntityId); - AAIResourcesClient aaiRC = new AAIResourcesClient(); - return aaiRC.exists(owningEntityURI); - } - - protected OwningEntities getOwningEntityName(String owningEntityName){ - - AAIResourcesClient aaiRC = new AAIResourcesClient(); - return aaiRC.get(OwningEntities.class, - AAIUriFactory - .createResourceUri(AAIObjectPlurals.OWNING_ENTITY) - .queryParam("owning-entity-name", owningEntityName)) - .orElseGet(() -> { - logger.debug("No Owning Entity matched by name"); - return null; - }); - - } - - public Optional<OwningEntity> getOwningEntityNames(String owningEntityName) throws Exception{ - OwningEntity owningEntity = null; - OwningEntities owningEntities = null; - owningEntities = getOwningEntityName(owningEntityName); - - if (owningEntities == null) { - return Optional.empty(); - } else if (owningEntities.getOwningEntity().size() > 1) { - throw new Exception("Multiple OwningEntities Returned"); - } else { - owningEntity = owningEntities.getOwningEntity().get(0); - } - return Optional.of(owningEntity); - } - - public void connectOwningEntityandServiceInstance (String owningEntityId, String serviceInstance){ - AAIResourceUri owningEntityURI = AAIUriFactory.createResourceUri(AAIObjectType.OWNING_ENTITY, owningEntityId); - AAIResourceUri serviceInstanceURI = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstance); - AAIResourcesClient aaiRC = new AAIResourcesClient(); - aaiRC.connect(owningEntityURI, serviceInstanceURI); - } - - public void createAAIPlatform(String platformName,String vnfId){ - AAIResourceUri platformURI = AAIUriFactory.createResourceUri(AAIObjectType.PLATFORM, platformName); - AAIResourceUri genericVnfURI = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF,vnfId); - AAIResourcesClient aaiRC = new AAIResourcesClient(); - aaiRC.createIfNotExists(platformURI, Optional.empty()).connect(platformURI, genericVnfURI); - } - - public void createAAILineOfBusiness(String lineOfBusiness,String vnfId){ - AAIResourceUri lineOfBusinessURI = AAIUriFactory.createResourceUri(AAIObjectType.LINE_OF_BUSINESS, lineOfBusiness); - AAIResourceUri genericVnfURI = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF,vnfId); - AAIResourcesClient aaiRC = new AAIResourcesClient(); - aaiRC.createIfNotExists(lineOfBusinessURI, Optional.empty()).connect(lineOfBusinessURI, genericVnfURI); - } - public void createAAIServiceInstance(String globalCustomerId, String serviceType, String serviceInstanceId){ - AAIResourceUri serviceInstanceURI = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, globalCustomerId,serviceType,serviceInstanceId); - AAIResourcesClient aaiRC = new AAIResourcesClient(); - aaiRC.createIfNotExists(serviceInstanceURI, Optional.empty()); - } - + + private static final Logger logger = LoggerFactory.getLogger(AAICreateResources.class); + + public void createAAIProject(String projectName, String serviceInstance) { + AAIResourceUri projectURI = AAIUriFactory.createResourceUri(AAIObjectType.PROJECT, projectName); + AAIResourceUri serviceInstanceURI = + AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstance); + AAIResourcesClient aaiRC = new AAIResourcesClient(); + aaiRC.createIfNotExists(projectURI, Optional.empty()).connect(projectURI, serviceInstanceURI); + + } + + public void createAAIOwningEntity(String owningEntityId, String owningEntityName, String serviceInstance) { + AAIResourceUri owningEntityURI = AAIUriFactory.createResourceUri(AAIObjectType.OWNING_ENTITY, owningEntityId); + AAIResourceUri serviceInstanceURI = + AAIUriFactory.createNodesUri(AAIObjectType.SERVICE_INSTANCE, serviceInstance); + Map<String, String> hashMap = new HashMap<>(); + hashMap.put("owning-entity-name", owningEntityName); + AAIResourcesClient aaiRC = new AAIResourcesClient(); + aaiRC.createIfNotExists(owningEntityURI, Optional.of(hashMap)).connect(owningEntityURI, serviceInstanceURI); + } + + public boolean existsOwningEntity(String owningEntityId) { + AAIResourceUri owningEntityURI = AAIUriFactory.createResourceUri(AAIObjectType.OWNING_ENTITY, owningEntityId); + AAIResourcesClient aaiRC = new AAIResourcesClient(); + return aaiRC.exists(owningEntityURI); + } + + protected OwningEntities getOwningEntityName(String owningEntityName) { + + AAIResourcesClient aaiRC = new AAIResourcesClient(); + return aaiRC.get(OwningEntities.class, AAIUriFactory.createResourceUri(AAIObjectPlurals.OWNING_ENTITY) + .queryParam("owning-entity-name", owningEntityName)).orElseGet(() -> { + logger.debug("No Owning Entity matched by name"); + return null; + }); + + } + + public Optional<OwningEntity> getOwningEntityNames(String owningEntityName) throws Exception { + OwningEntity owningEntity = null; + OwningEntities owningEntities = null; + owningEntities = getOwningEntityName(owningEntityName); + + if (owningEntities == null) { + return Optional.empty(); + } else if (owningEntities.getOwningEntity().size() > 1) { + throw new Exception("Multiple OwningEntities Returned"); + } else { + owningEntity = owningEntities.getOwningEntity().get(0); + } + return Optional.of(owningEntity); + } + + public void connectOwningEntityandServiceInstance(String owningEntityId, String serviceInstance) { + AAIResourceUri owningEntityURI = AAIUriFactory.createResourceUri(AAIObjectType.OWNING_ENTITY, owningEntityId); + AAIResourceUri serviceInstanceURI = + AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstance); + AAIResourcesClient aaiRC = new AAIResourcesClient(); + aaiRC.connect(owningEntityURI, serviceInstanceURI); + } + + public void createAAIPlatform(String platformName, String vnfId) { + AAIResourceUri platformURI = AAIUriFactory.createResourceUri(AAIObjectType.PLATFORM, platformName); + AAIResourceUri genericVnfURI = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId); + AAIResourcesClient aaiRC = new AAIResourcesClient(); + aaiRC.createIfNotExists(platformURI, Optional.empty()).connect(platformURI, genericVnfURI); + } + + public void createAAILineOfBusiness(String lineOfBusiness, String vnfId) { + AAIResourceUri lineOfBusinessURI = + AAIUriFactory.createResourceUri(AAIObjectType.LINE_OF_BUSINESS, lineOfBusiness); + AAIResourceUri genericVnfURI = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId); + AAIResourcesClient aaiRC = new AAIResourcesClient(); + aaiRC.createIfNotExists(lineOfBusinessURI, Optional.empty()).connect(lineOfBusinessURI, genericVnfURI); + } + + public void createAAIServiceInstance(String globalCustomerId, String serviceType, String serviceInstanceId) { + AAIResourceUri serviceInstanceURI = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, + globalCustomerId, serviceType, serviceInstanceId); + AAIResourcesClient aaiRC = new AAIResourcesClient(); + aaiRC.createIfNotExists(serviceInstanceURI, Optional.empty()); + } + } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/groovyflows/AAIDeleteServiceInstance.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/groovyflows/AAIDeleteServiceInstance.java index 495c77255d..fb95ae3993 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/groovyflows/AAIDeleteServiceInstance.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/groovyflows/AAIDeleteServiceInstance.java @@ -28,22 +28,24 @@ import org.onap.so.client.aai.AAIResourcesClient; import org.onap.so.client.aai.entities.uri.AAIResourceUri; import org.onap.so.client.aai.entities.uri.AAIUriFactory; -public class AAIDeleteServiceInstance implements JavaDelegate{ +public class AAIDeleteServiceInstance implements JavaDelegate { + + ExceptionUtil exceptionUtil = new ExceptionUtil(); + + public void execute(DelegateExecution execution) throws Exception { + try { + String serviceInstanceId = (String) execution.getVariable("serviceInstanceId"); + AAIResourceUri serviceInstanceURI = + AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId); + AAIResourcesClient aaiRC = new AAIResourcesClient(); + aaiRC.delete(serviceInstanceURI); + execution.setVariable("GENDS_SuccessIndicator", true); + } catch (Exception ex) { + String msg = "Exception in Delete Serivce Instance. Service Instance could not be deleted in AAI." + + ex.getMessage(); + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg); + } + + } - ExceptionUtil exceptionUtil = new ExceptionUtil(); - public void execute(DelegateExecution execution) throws Exception { - try{ - String serviceInstanceId = (String) execution.getVariable("serviceInstanceId"); - AAIResourceUri serviceInstanceURI = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, - serviceInstanceId); - AAIResourcesClient aaiRC = new AAIResourcesClient(); - aaiRC.delete(serviceInstanceURI); - execution.setVariable("GENDS_SuccessIndicator",true); - } catch(Exception ex){ - String msg = "Exception in Delete Serivce Instance. Service Instance could not be deleted in AAI." + ex.getMessage(); - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg); - } - - } - } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/groovyflows/AAIServiceInstance.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/groovyflows/AAIServiceInstance.java index 805ece9de8..2d69351744 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/groovyflows/AAIServiceInstance.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/groovyflows/AAIServiceInstance.java @@ -21,74 +21,91 @@ package org.onap.so.bpmn.infrastructure.aai.groovyflows; public class AAIServiceInstance { - String serviceInstanceName; - String serviceType; - String serviceRole; - String orchestrationStatus; - String modelInvariantUuid; - String modelVersionId; - String environmentContext; - String workloadContext; - public AAIServiceInstance(String serviceInstanceName, String serviceType, String serviceRole, - String orchestrationStatus, String modelInvariantUuid, String modelVersionId, String environmentContext, - String workloadContext) { - this.serviceInstanceName = serviceInstanceName; - this.serviceType = serviceType; - this.serviceRole = serviceRole; - this.orchestrationStatus = orchestrationStatus; - this.modelInvariantUuid = modelInvariantUuid; - this.modelVersionId = modelVersionId; - this.environmentContext = environmentContext; - this.workloadContext = workloadContext; - } - public String getServiceInstanceName() { - return serviceInstanceName; - } - public void setServiceInstanceName(String serviceInstanceName) { - this.serviceInstanceName = serviceInstanceName; - } - public String getServiceType() { - return serviceType; - } - public void setServiceType(String serviceType) { - this.serviceType = serviceType; - } - public String getServiceRole() { - return serviceRole; - } - public void setServiceRole(String serviceRole) { - this.serviceRole = serviceRole; - } - public String getOrchestrationStatus() { - return orchestrationStatus; - } - public void setOrchestrationStatus(String orchestrationStatus) { - this.orchestrationStatus = orchestrationStatus; - } - public String getModelInvariantUuid() { - return modelInvariantUuid; - } - public void setModelInvariantUuid(String modelInvariantUuid) { - this.modelInvariantUuid = modelInvariantUuid; - } - public String getModelVersionId() { - return modelVersionId; - } - public void setModelVersionId(String modelVersionId) { - this.modelVersionId = modelVersionId; - } - public String getEnvironmentContext() { - return environmentContext; - } - public void setEnvironmentContext(String environmentContext) { - this.environmentContext = environmentContext; - } - public String getWorkloadContext() { - return workloadContext; - } - public void setWorkloadContext(String workloadContext) { - this.workloadContext = workloadContext; - } - + String serviceInstanceName; + String serviceType; + String serviceRole; + String orchestrationStatus; + String modelInvariantUuid; + String modelVersionId; + String environmentContext; + String workloadContext; + + public AAIServiceInstance(String serviceInstanceName, String serviceType, String serviceRole, + String orchestrationStatus, String modelInvariantUuid, String modelVersionId, String environmentContext, + String workloadContext) { + this.serviceInstanceName = serviceInstanceName; + this.serviceType = serviceType; + this.serviceRole = serviceRole; + this.orchestrationStatus = orchestrationStatus; + this.modelInvariantUuid = modelInvariantUuid; + this.modelVersionId = modelVersionId; + this.environmentContext = environmentContext; + this.workloadContext = workloadContext; + } + + public String getServiceInstanceName() { + return serviceInstanceName; + } + + public void setServiceInstanceName(String serviceInstanceName) { + this.serviceInstanceName = serviceInstanceName; + } + + public String getServiceType() { + return serviceType; + } + + public void setServiceType(String serviceType) { + this.serviceType = serviceType; + } + + public String getServiceRole() { + return serviceRole; + } + + public void setServiceRole(String serviceRole) { + this.serviceRole = serviceRole; + } + + public String getOrchestrationStatus() { + return orchestrationStatus; + } + + public void setOrchestrationStatus(String orchestrationStatus) { + this.orchestrationStatus = orchestrationStatus; + } + + public String getModelInvariantUuid() { + return modelInvariantUuid; + } + + public void setModelInvariantUuid(String modelInvariantUuid) { + this.modelInvariantUuid = modelInvariantUuid; + } + + public String getModelVersionId() { + return modelVersionId; + } + + public void setModelVersionId(String modelVersionId) { + this.modelVersionId = modelVersionId; + } + + public String getEnvironmentContext() { + return environmentContext; + } + + public void setEnvironmentContext(String environmentContext) { + this.environmentContext = environmentContext; + } + + public String getWorkloadContext() { + return workloadContext; + } + + public void setWorkloadContext(String workloadContext) { + this.workloadContext = workloadContext; + } + } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/common/name/generation/AAIObjectInstanceNameGenerator.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/common/name/generation/AAIObjectInstanceNameGenerator.java index 3b443cbaf2..55387d6a3d 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/common/name/generation/AAIObjectInstanceNameGenerator.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/common/name/generation/AAIObjectInstanceNameGenerator.java @@ -27,14 +27,15 @@ import org.springframework.stereotype.Component; @Component public class AAIObjectInstanceNameGenerator { - public String generateInstanceGroupName(InstanceGroup instanceGroup, GenericVnf vnf) { - if(vnf.getVnfName() != null && instanceGroup.getModelInfoInstanceGroup().getFunction() != null) { - return vnf.getVnfName() + "_" + instanceGroup.getModelInfoInstanceGroup().getFunction(); - } else { - throw new IllegalArgumentException("Cannot generate instance group name because either one or both fields are null: " - + " Vnf Instance Name: " + vnf.getVnfName() - + ", Instance Group Function: " + instanceGroup.getModelInfoInstanceGroup().getFunction()); - } - } - + public String generateInstanceGroupName(InstanceGroup instanceGroup, GenericVnf vnf) { + if (vnf.getVnfName() != null && instanceGroup.getModelInfoInstanceGroup().getFunction() != null) { + return vnf.getVnfName() + "_" + instanceGroup.getModelInfoInstanceGroup().getFunction(); + } else { + throw new IllegalArgumentException( + "Cannot generate instance group name because either one or both fields are null: " + + " Vnf Instance Name: " + vnf.getVnfName() + ", Instance Group Function: " + + instanceGroup.getModelInfoInstanceGroup().getFunction()); + } + } + } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/PnfNotificationEvent.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/PnfNotificationEvent.java new file mode 100644 index 0000000000..267ddbf6a7 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/PnfNotificationEvent.java @@ -0,0 +1,42 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.pnf; + +import org.springframework.context.ApplicationEvent; + +public class PnfNotificationEvent extends ApplicationEvent { + + private String pnfCorrelationId; + + /** + * Create a new ApplicationEvent. + * + * @param source the object on which the event initially occurred (never {@code null}) + */ + public PnfNotificationEvent(Object source, String pnfCorrelationId) { + super(source); + this.pnfCorrelationId = pnfCorrelationId; + } + + public String getPnfCorrelationId() { + return pnfCorrelationId; + } +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CheckAaiForPnfCorrelationIdDelegate.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CheckAaiForPnfCorrelationIdDelegate.java index e0fa41b7a1..493340c9ef 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CheckAaiForPnfCorrelationIdDelegate.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CheckAaiForPnfCorrelationIdDelegate.java @@ -22,9 +22,7 @@ package org.onap.so.bpmn.infrastructure.pnf.delegate; import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.AAI_CONTAINS_INFO_ABOUT_PNF; import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_CORRELATION_ID; - import java.io.IOException; - import org.camunda.bpm.engine.delegate.DelegateExecution; import org.camunda.bpm.engine.delegate.JavaDelegate; import org.onap.so.bpmn.common.scripts.ExceptionUtil; diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/ConfigCheckerDelegate.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/ConfigCheckerDelegate.java new file mode 100644 index 0000000000..d67e6ef0db --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/ConfigCheckerDelegate.java @@ -0,0 +1,90 @@ +/* + * ============LICENSE_START======================================================= Copyright (C) 2019 Nordix + * Foundation. ================================================================================ Licensed under the + * Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may + * obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and limitations under the + * License. + * + * SPDX-License-Identifier: Apache-2.0 ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.pnf.delegate; + +import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.MODEL_UUID; +import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PRC_BLUEPRINT_NAME; +import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PRC_BLUEPRINT_VERSION; +import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PRC_CUSTOMIZATION_UUID; +import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PRC_INSTANCE_NAME; +import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.SERVICE_MODEL_INFO; +import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.SKIP_POST_INSTANTIATION_CONFIGURATION; +import java.util.List; +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.engine.delegate.JavaDelegate; +import org.onap.so.bpmn.core.json.JsonUtils; +import org.onap.so.client.exception.ExceptionBuilder; +import org.onap.so.db.catalog.beans.PnfResourceCustomization; +import org.onap.so.db.catalog.client.CatalogDbClient; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * This implementation of {@link JavaDelegate} is used to check the SO catalogdb for PNF config flag. + * + * It queries the PNF resource customization table for the skip_post_instantiation_configuration for required PNF model + * UUID. + */ +@Component +public class ConfigCheckerDelegate implements JavaDelegate { + + private Logger logger = LoggerFactory.getLogger(ConfigCheckerDelegate.class); + + // ERROR CODE for variable not found in the delegation Context + private static int ERROR_CODE = 601; + + @Autowired + protected ExceptionBuilder exceptionUtil; + + @Autowired + protected CatalogDbClient catalogDbClient; + + @Override + public void execute(DelegateExecution delegateExecution) throws Exception { + + logger.debug("Running execute block for activity id:{}, name:{}", delegateExecution.getCurrentActivityId(), + delegateExecution.getCurrentActivityName()); + + if (delegateExecution.hasVariable(SERVICE_MODEL_INFO)) { + String serviceModelInfo = (String) delegateExecution.getVariable(SERVICE_MODEL_INFO); + String serviceModelUuid = JsonUtils.getJsonValue(serviceModelInfo, MODEL_UUID); + delegateExecution.setVariable(MODEL_UUID, serviceModelUuid); + List<PnfResourceCustomization> pnfCustomizations = + catalogDbClient.getPnfResourceCustomizationByModelUuid(serviceModelUuid); + if (pnfCustomizations != null && pnfCustomizations.size() >= 1) { + PnfResourceCustomization pnfResourceCustomization = pnfCustomizations.get(0); + boolean skipPostInstantiationConfiguration = pnfResourceCustomization.isSkipPostInstConf(); + delegateExecution.setVariable(SKIP_POST_INSTANTIATION_CONFIGURATION, + skipPostInstantiationConfiguration); + delegateExecution.setVariable(PRC_BLUEPRINT_NAME, pnfResourceCustomization.getBlueprintName()); + delegateExecution.setVariable(PRC_BLUEPRINT_VERSION, pnfResourceCustomization.getBlueprintVersion()); + delegateExecution.setVariable(PRC_CUSTOMIZATION_UUID, + pnfResourceCustomization.getModelCustomizationUUID()); + delegateExecution.setVariable(PRC_INSTANCE_NAME, pnfResourceCustomization.getModelInstanceName()); + } else { + logger.warn("Unable to find the PNF resource customizations of model service UUID: {}", + serviceModelUuid); + exceptionUtil.buildAndThrowWorkflowException(delegateExecution, ERROR_CODE, + "Unable to find the PNF resource customizations of model service UUID: " + serviceModelUuid); + } + } else { + logger.warn("Unable to find the parameter: {} in the execution context", SERVICE_MODEL_INFO); + exceptionUtil.buildAndThrowWorkflowException(delegateExecution, ERROR_CODE, + "Unable to find parameter " + SERVICE_MODEL_INFO); + } + } +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreatePnfEntryInAaiDelegate.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreatePnfEntryInAaiDelegate.java index e56cb83119..cb06085ee8 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreatePnfEntryInAaiDelegate.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreatePnfEntryInAaiDelegate.java @@ -24,7 +24,6 @@ package org.onap.so.bpmn.infrastructure.pnf.delegate; import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_CORRELATION_ID; import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_UUID; - import org.camunda.bpm.engine.delegate.DelegateExecution; import org.camunda.bpm.engine.delegate.JavaDelegate; import org.onap.aai.domain.yang.Pnf; @@ -37,9 +36,7 @@ import org.springframework.stereotype.Component; /** * Implementation of "Create Pnf entry in AAI" task in CreateAndActivatePnfResource.bpmn * - * Inputs: - * - pnfCorrelationId - String - * - pnfUuid - String + * Inputs: - pnfCorrelationId - String - pnfUuid - String */ @Component public class CreatePnfEntryInAaiDelegate implements JavaDelegate { diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateRelation.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateRelation.java index a367bada02..6d73b61ab2 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateRelation.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateRelation.java @@ -51,8 +51,8 @@ public class CreateRelation implements JavaDelegate { new ExceptionUtil().buildAndThrowWorkflowException(delegateExecution, 9999, "An exception occurred when making service and pnf relation. Exception: " + e.getMessage()); } - logger.debug("The relation has been made between service with id: {} and pnf with name: {}", - serviceInstanceId, pnfName); + logger.debug("The relation has been made between service with id: {} and pnf with name: {}", serviceInstanceId, + pnfName); } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/ExecutionVariableNames.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/ExecutionVariableNames.java index 7d449e72a8..c16175b8e2 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/ExecutionVariableNames.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/ExecutionVariableNames.java @@ -34,4 +34,26 @@ public class ExecutionVariableNames { public final static String TIMEOUT_FOR_NOTIFICATION = "timeoutForPnfEntryNotification"; public final static String PNF_UUID = "pnfUuid"; public final static String SERVICE_INSTANCE_ID = "serviceInstanceId"; + public final static String MSO_REQUEST_ID = "msoRequestId"; + public final static String MODEL_UUID = "modelUuid"; + + public final static String SERVICE_MODEL_INFO = "serviceModelInfo"; + + /** + * Variable used to contain the {@link org.onap.so.client.cds.beans.AbstractCDSPropertiesBean} json value. + */ + public static final String EXECUTION_OBJECT = "executionObject"; + + /** + * Variables used to contain the {@link org.onap.so.db.catalog.beans.PnfResourceCustomization} fields. + */ + public static final String PRC_BLUEPRINT_NAME = "PRC_blueprintName"; + public static final String PRC_BLUEPRINT_VERSION = "PRC_blueprintVersion"; + public static final String PRC_CUSTOMIZATION_UUID = "PRC_customizationUuid"; + public static final String PRC_INSTANCE_NAME = "PRC_instanceName"; + + /** + * Variable used to contain skipPostInstantiationConfiguration flag. + */ + public static final String SKIP_POST_INSTANTIATION_CONFIGURATION = "SkipPostInstantiationConfiguration"; } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/GeneratePnfUuidDelegate.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/GeneratePnfUuidDelegate.java index f5483e489e..852ca4fcef 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/GeneratePnfUuidDelegate.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/GeneratePnfUuidDelegate.java @@ -21,7 +21,6 @@ package org.onap.so.bpmn.infrastructure.pnf.delegate; import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_UUID; - import java.util.UUID; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.camunda.bpm.engine.delegate.JavaDelegate; @@ -35,7 +34,7 @@ public class GeneratePnfUuidDelegate implements JavaDelegate { private static final Logger logger = LoggerFactory.getLogger(GeneratePnfUuidDelegate.class); @Override - public void execute(DelegateExecution delegateExecution){ + public void execute(DelegateExecution delegateExecution) { UUID uuid = UUID.randomUUID(); logger.debug("Generated UUID for pnf: {}, version: {}, variant: {}", uuid, uuid.version(), uuid.variant()); delegateExecution.setVariable(PNF_UUID, uuid.toString()); diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClient.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClient.java index 96455acb84..e2dc375cd1 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClient.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClient.java @@ -23,29 +23,40 @@ package org.onap.so.bpmn.infrastructure.pnf.delegate; import org.camunda.bpm.engine.RuntimeService; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.camunda.bpm.engine.delegate.JavaDelegate; +import org.onap.so.bpmn.infrastructure.pnf.PnfNotificationEvent; import org.onap.so.bpmn.infrastructure.pnf.dmaap.DmaapClient; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationListener; import org.springframework.stereotype.Component; @Component -public class InformDmaapClient implements JavaDelegate { +public class InformDmaapClient implements JavaDelegate, ApplicationListener<PnfNotificationEvent> { + private Logger logger = LoggerFactory.getLogger(getClass()); private DmaapClient dmaapClient; + private DelegateExecution execution; @Override public void execute(DelegateExecution execution) { String pnfCorrelationId = (String) execution.getVariable(ExecutionVariableNames.PNF_CORRELATION_ID); RuntimeService runtimeService = execution.getProcessEngineServices().getRuntimeService(); - dmaapClient.registerForUpdate(pnfCorrelationId, () -> - runtimeService - .createMessageCorrelation("WorkflowMessage") - .processInstanceBusinessKey(execution.getProcessBusinessKey()) - .correlateWithResult() - ); + dmaapClient.registerForUpdate(pnfCorrelationId, () -> runtimeService.createMessageCorrelation("WorkflowMessage") + .processInstanceBusinessKey(execution.getProcessBusinessKey()).correlateWithResult()); + this.execution = execution; } @Autowired public void setDmaapClient(DmaapClient dmaapClient) { this.dmaapClient = dmaapClient; } + + @Override + public void onApplicationEvent(PnfNotificationEvent event) { + logger.info("Received application event for pnfCorrelationId: {}", event.getPnfCorrelationId()); + RuntimeService runtimeService = execution.getProcessEngineServices().getRuntimeService(); + runtimeService.createMessageCorrelation("WorkflowMessage") + .processInstanceBusinessKey(execution.getProcessBusinessKey()).correlateWithResult(); + } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfCheckInputs.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfCheckInputs.java index 1caadea0de..b52110ea82 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfCheckInputs.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfCheckInputs.java @@ -26,7 +26,6 @@ import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableName import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_UUID; import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.SERVICE_INSTANCE_ID; import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.TIMEOUT_FOR_NOTIFICATION; - import com.google.common.base.Strings; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.camunda.bpm.engine.delegate.JavaDelegate; @@ -38,7 +37,8 @@ import org.springframework.stereotype.Component; @Component public class PnfCheckInputs implements JavaDelegate { - public static final String UUID_REGEX = "(?i)^[0-9a-f]{8}-[0-9a-f]{4}-[1-5]{1}[0-9a-f]{3}-[89ab]{1}[0-9a-f]{3}-[0-9a-f]{12}$"; + public static final String UUID_REGEX = + "(?i)^[0-9a-f]{8}-[0-9a-f]{4}-[1-5]{1}[0-9a-f]{3}-[89ab]{1}[0-9a-f]{3}-[0-9a-f]{12}$"; private String pnfEntryNotificationTimeout; @@ -58,7 +58,8 @@ public class PnfCheckInputs implements JavaDelegate { private void validatePnfCorrelationId(DelegateExecution execution) { String pnfCorrelationId = (String) execution.getVariable(PNF_CORRELATION_ID); if (Strings.isNullOrEmpty(pnfCorrelationId)) { - new ExceptionUtil().buildAndThrowWorkflowException(execution, 9999, "pnfCorrelationId variable not defined"); + new ExceptionUtil().buildAndThrowWorkflowException(execution, 9999, + "pnfCorrelationId variable not defined"); } } @@ -83,7 +84,8 @@ public class PnfCheckInputs implements JavaDelegate { private void validateServiceInstanceId(DelegateExecution execution) { String serviceInstanceId = (String) execution.getVariable(SERVICE_INSTANCE_ID); if (Strings.isNullOrEmpty(serviceInstanceId)) { - new ExceptionUtil().buildAndThrowWorkflowException(execution, 9999, "serviceInstanceId variable not defined"); + new ExceptionUtil().buildAndThrowWorkflowException(execution, 9999, + "serviceInstanceId variable not defined"); } } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PrepareCdsCallDelegate.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PrepareCdsCallDelegate.java new file mode 100644 index 0000000000..c4c299d4b6 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PrepareCdsCallDelegate.java @@ -0,0 +1,78 @@ +/* + * ============LICENSE_START======================================================= Copyright (C) 2019 Nordix + * Foundation. ================================================================================ Licensed under the + * Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may + * obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and limitations under the + * License. + * + * SPDX-License-Identifier: Apache-2.0 ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.pnf.delegate; + +import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.EXECUTION_OBJECT; +import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.MSO_REQUEST_ID; +import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_UUID; +import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PRC_BLUEPRINT_NAME; +import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PRC_BLUEPRINT_VERSION; +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.engine.delegate.JavaDelegate; +import org.onap.so.client.cds.beans.AbstractCDSPropertiesBean; +import org.onap.so.client.exception.ExceptionBuilder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; + +/** + * Abstract class for preparing CDS call. + */ +public abstract class PrepareCdsCallDelegate implements JavaDelegate { + + protected Logger logger = LoggerFactory.getLogger(this.getClass()); + + protected static final String ORIGINATOR_ID = "SO"; + protected static final int ERROR_CODE = 7010; + + protected String actionName; + protected String mode; + + @Autowired + protected ExceptionBuilder exceptionUtil; + + @Override + public void execute(DelegateExecution delegateExecution) { + + logger.debug("Running execute block for activity:{}", delegateExecution.getCurrentActivityId()); + AbstractCDSPropertiesBean cdsPropertiesBean = new AbstractCDSPropertiesBean(); + cdsPropertiesBean.setBlueprintName((String) delegateExecution.getVariable(PRC_BLUEPRINT_NAME)); + cdsPropertiesBean.setBlueprintVersion((String) delegateExecution.getVariable(PRC_BLUEPRINT_VERSION)); + cdsPropertiesBean.setOriginatorId(ORIGINATOR_ID); + cdsPropertiesBean.setActionName(getActionName()); + cdsPropertiesBean.setMode(getMode()); + cdsPropertiesBean.setRequestId((String) delegateExecution.getVariable(MSO_REQUEST_ID)); + cdsPropertiesBean.setSubRequestId((String) delegateExecution.getVariable(PNF_UUID)); + cdsPropertiesBean.setRequestObject(getRequestObject(delegateExecution)); + delegateExecution.setVariable(EXECUTION_OBJECT, cdsPropertiesBean); + } + + /** + * Return the request object sent to CDS call. + * + * @param delegateExecution BPMN delegateExecution context + * @return string value of the request object + */ + protected abstract String getRequestObject(final DelegateExecution delegateExecution); + + public String getActionName() { + return actionName; + } + + public String getMode() { + return mode; + } + +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PrepareConfigAssignDelegate.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PrepareConfigAssignDelegate.java new file mode 100644 index 0000000000..dd2601f0d0 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PrepareConfigAssignDelegate.java @@ -0,0 +1,73 @@ +/* + * ============LICENSE_START======================================================= Copyright (C) 2019 Nordix + * Foundation. ================================================================================ Licensed under the + * Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may + * obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and limitations under the + * License. + * + * SPDX-License-Identifier: Apache-2.0 ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.pnf.delegate; + +import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.MODEL_UUID; +import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_CORRELATION_ID; +import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_UUID; +import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PRC_CUSTOMIZATION_UUID; +import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PRC_INSTANCE_NAME; +import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.SERVICE_INSTANCE_ID; +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.engine.delegate.JavaDelegate; +import org.onap.so.client.cds.beans.AbstractCDSPropertiesBean; +import org.onap.so.client.cds.beans.ConfigAssignPropertiesForPnf; +import org.onap.so.client.cds.beans.ConfigAssignRequestPnf; +import org.springframework.stereotype.Component; + +/** + * This implementation of {@link JavaDelegate} is used to prepare for config Assign. + * + * It queries the PNF resource customization table and construct the {@link AbstractCDSPropertiesBean} as + * executionObject. + */ +@Component +public class PrepareConfigAssignDelegate extends PrepareCdsCallDelegate { + + public PrepareConfigAssignDelegate() { + this.actionName = "config-assign"; + this.mode = "sync"; + } + + @Override + protected String getRequestObject(final DelegateExecution delegateExecution) { + + ConfigAssignPropertiesForPnf configAssignProperties = new ConfigAssignPropertiesForPnf(); + configAssignProperties.setServiceInstanceId((String) delegateExecution.getVariable(SERVICE_INSTANCE_ID)); + + /** + * PNF Name matches the name in AAI, i.e., correlationID as in customized workflow. + */ + configAssignProperties.setPnfName((String) delegateExecution.getVariable(PNF_CORRELATION_ID)); + + /** + * PNF id match AAI entry, i.e, PNF UUID. + */ + configAssignProperties.setPnfId((String) delegateExecution.getVariable(PNF_UUID)); + configAssignProperties.setPnfCustomizationUuid((String) delegateExecution.getVariable(PRC_CUSTOMIZATION_UUID)); + configAssignProperties.setServiceModelUuid((String) delegateExecution.getVariable(MODEL_UUID)); + + ConfigAssignRequestPnf configAssignRequest = new ConfigAssignRequestPnf(); + configAssignRequest.setConfigAssignPropertiesForPnf(configAssignProperties); + + /** + * resolution key is the same as PNF name. + */ + configAssignRequest.setResolutionKey((String) delegateExecution.getVariable(PNF_CORRELATION_ID)); + + return configAssignRequest.toString(); + } + +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PrepareConfigDeployDelegate.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PrepareConfigDeployDelegate.java new file mode 100644 index 0000000000..16f712fa66 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PrepareConfigDeployDelegate.java @@ -0,0 +1,110 @@ +/* + * ============LICENSE_START======================================================= Copyright (C) 2019 Nordix + * Foundation. ================================================================================ Licensed under the + * Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may + * obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and limitations under the + * License. + * + * SPDX-License-Identifier: Apache-2.0 ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.pnf.delegate; + +import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.MODEL_UUID; +import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_CORRELATION_ID; +import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_UUID; +import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PRC_CUSTOMIZATION_UUID; +import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.SERVICE_INSTANCE_ID; +import java.io.IOException; +import java.util.Optional; +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.engine.delegate.JavaDelegate; +import org.onap.aai.domain.yang.Pnf; +import org.onap.so.bpmn.infrastructure.pnf.management.PnfManagement; +import org.onap.so.client.cds.beans.AbstractCDSPropertiesBean; +import org.onap.so.client.cds.beans.ConfigDeployPropertiesForPnf; +import org.onap.so.client.cds.beans.ConfigDeployRequestPnf; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * This implementation of {@link JavaDelegate} is used to prepare for config Deploy. + * + * It queries the PNF resource customization table and construct the {@link AbstractCDSPropertiesBean} as + * executionObject. + */ +@Component +public class PrepareConfigDeployDelegate extends PrepareCdsCallDelegate { + + @Autowired + private PnfManagement pnfManagement; + + public PrepareConfigDeployDelegate() { + this.actionName = "config-deploy"; + this.mode = "async"; + } + + @Override + protected String getRequestObject(DelegateExecution delegateExecution) { + + ConfigDeployPropertiesForPnf configDeployProperties = new ConfigDeployPropertiesForPnf(); + + configDeployProperties.setServiceInstanceId((String) delegateExecution.getVariable(SERVICE_INSTANCE_ID)); + + /** + * PNF Name matches the name in AAI, i.e., correlationID as in customized workflow. + */ + configDeployProperties.setPnfName((String) delegateExecution.getVariable(PNF_CORRELATION_ID)); + + /** + * PNF id match AAI entry, i.e, PNF UUID. + */ + configDeployProperties.setPnfId((String) delegateExecution.getVariable(PNF_UUID)); + configDeployProperties.setPnfCustomizationUuid((String) delegateExecution.getVariable(PRC_CUSTOMIZATION_UUID)); + configDeployProperties.setServiceModelUuid((String) delegateExecution.getVariable(MODEL_UUID)); + setIpAddress(configDeployProperties, delegateExecution); + + ConfigDeployRequestPnf configDeployRequest = new ConfigDeployRequestPnf(); + configDeployRequest.setConfigDeployPropertiesForPnf(configDeployProperties); + + /** + * Resolution key is the same as PNF name. + */ + configDeployRequest.setResolutionKey((String) delegateExecution.getVariable(PNF_CORRELATION_ID)); + + return configDeployRequest.toString(); + } + + private void setIpAddress(ConfigDeployPropertiesForPnf configDeployProperties, + DelegateExecution delegateExecution) { + + /** + * Retrieve PNF entry from AAI. + */ + try { + String pnfName = (String) delegateExecution.getVariable(PNF_CORRELATION_ID); + Optional<Pnf> pnfOptional = pnfManagement.getEntryFor(pnfName); + if (pnfOptional.isPresent()) { + Pnf pnf = pnfOptional.get(); + + /** + * PRH patches the AAI with oam address. Use ipaddress-v4-oam and ipaddress-v6-oam for the config deploy + * request. + */ + configDeployProperties.setPnfIpV4Address(pnf.getIpaddressV4Oam()); + configDeployProperties.setPnfIpV6Address(pnf.getIpaddressV6Oam()); + } else { + exceptionUtil.buildAndThrowWorkflowException(delegateExecution, ERROR_CODE, + "AAI entry for PNF: " + pnfName + " does not exist"); + } + } catch (IOException e) { + logger.warn(e.getMessage(), e); + exceptionUtil.buildAndThrowWorkflowException(delegateExecution, ERROR_CODE, + "Unable to fetch from AAI" + e.getMessage()); + } + } +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/JsonUtilForPnfCorrelationId.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/JsonUtilForPnfCorrelationId.java index fb5d04328f..7cb78a10e5 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/JsonUtilForPnfCorrelationId.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/JsonUtilForPnfCorrelationId.java @@ -41,9 +41,8 @@ public final class JsonUtilForPnfCorrelationId { List<String> list = new ArrayList<>(); Spliterator<JsonElement> spliterator = array.spliterator(); spliterator.forEachRemaining(jsonElement -> { - handleEscapedCharacters(jsonElement) - .ifPresent(jsonObject -> getPnfCorrelationId(jsonObject) - .ifPresent(pnfCorrelationId -> list.add(pnfCorrelationId))); + handleEscapedCharacters(jsonElement).ifPresent(jsonObject -> getPnfCorrelationId(jsonObject) + .ifPresent(pnfCorrelationId -> list.add(pnfCorrelationId))); }); return list; } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClient.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClient.java index 1b7a69eec8..2869111485 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClient.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClient.java @@ -35,9 +35,11 @@ import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.util.EntityUtils; +import org.onap.so.bpmn.infrastructure.pnf.PnfNotificationEvent; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationEventPublisher; import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; @@ -53,19 +55,20 @@ public class PnfEventReadyDmaapClient implements DmaapClient { private volatile ScheduledThreadPoolExecutor executor; private volatile boolean dmaapThreadListenerIsRunning; + private ApplicationEventPublisher applicationEventPublisher; + @Autowired - public PnfEventReadyDmaapClient(Environment env) { + public PnfEventReadyDmaapClient(Environment env, ApplicationEventPublisher applicationEventPublisher) { + this.applicationEventPublisher = applicationEventPublisher; httpClient = HttpClientBuilder.create().build(); pnfCorrelationIdToThreadMap = new ConcurrentHashMap<>(); topicListenerDelayInSeconds = env.getProperty("pnf.dmaap.topicListenerDelayInSeconds", Integer.class); executor = null; getRequest = new HttpGet(UriBuilder.fromUri(env.getProperty("pnf.dmaap.uriPathPrefix")) - .scheme(env.getProperty("pnf.dmaap.protocol")) - .host(env.getProperty("pnf.dmaap.host")) - .port(env.getProperty("pnf.dmaap.port", Integer.class)) - .path(env.getProperty("pnf.dmaap.topicName")) - .path(env.getProperty("pnf.dmaap.consumerGroup")) - .path(env.getProperty("pnf.dmaap.consumerId")).build()); + .scheme(env.getProperty("pnf.dmaap.protocol")).host(env.getProperty("pnf.dmaap.host")) + .port(env.getProperty("pnf.dmaap.port", Integer.class)).path(env.getProperty("pnf.dmaap.topicName")) + .path(env.getProperty("pnf.dmaap.consumerGroup")).path(env.getProperty("pnf.dmaap.consumerId")) + .build()); } @Override @@ -92,8 +95,8 @@ public class PnfEventReadyDmaapClient implements DmaapClient { executor = new ScheduledThreadPoolExecutor(1); executor.setContinueExistingPeriodicTasksAfterShutdownPolicy(false); executor.setExecuteExistingDelayedTasksAfterShutdownPolicy(false); - executor.scheduleWithFixedDelay(new DmaapTopicListenerThread(), 0, - topicListenerDelayInSeconds, TimeUnit.SECONDS); + executor.scheduleWithFixedDelay(new DmaapTopicListenerThread(), 0, topicListenerDelayInSeconds, + TimeUnit.SECONDS); dmaapThreadListenerIsRunning = true; } } @@ -116,8 +119,7 @@ public class PnfEventReadyDmaapClient implements DmaapClient { getPnfCorrelationIdListFromResponse(response).forEach(this::informAboutPnfReadyIfPnfCorrelationIdFound); } catch (IOException e) { logger.error("Exception caught during sending rest request to dmaap for listening event topic", e); - } - finally { + } finally { getRequest.reset(); } } @@ -133,12 +135,9 @@ public class PnfEventReadyDmaapClient implements DmaapClient { } private void informAboutPnfReadyIfPnfCorrelationIdFound(String pnfCorrelationId) { - Runnable runnable = unregister(pnfCorrelationId); - if (runnable != null) { - logger.debug("dmaap listener gets pnf ready event for pnfCorrelationId: {}", pnfCorrelationId); - runnable.run(); - } + unregister(pnfCorrelationId); + PnfNotificationEvent pnfNotificationEvent = new PnfNotificationEvent(this, pnfCorrelationId); + applicationEventPublisher.publishEvent(pnfNotificationEvent); } } - } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/management/PnfManagementImpl.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/management/PnfManagementImpl.java index 32ea357817..b1af8b1e0b 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/management/PnfManagementImpl.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/management/PnfManagementImpl.java @@ -46,8 +46,8 @@ public class PnfManagementImpl implements PnfManagement { @Override public void createRelation(String serviceInstanceId, String pnfName) { - AAIResourceUri serviceInstanceURI = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, - serviceInstanceId); + AAIResourceUri serviceInstanceURI = + AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId); AAIResourceUri pnfUri = AAIUriFactory.createResourceUri(AAIObjectType.PNF, pnfName); new AAIResourcesClient().connect(serviceInstanceURI, pnfUri); } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/properties/BPMNProperties.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/properties/BPMNProperties.java index ee8743f846..8b2bb9a8de 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/properties/BPMNProperties.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/properties/BPMNProperties.java @@ -22,22 +22,22 @@ package org.onap.so.bpmn.infrastructure.properties; import java.util.Arrays; import java.util.List; import org.onap.so.bpmn.core.UrnPropertiesReader; - import org.onap.so.bpmn.core.UrnPropertiesReader; public class BPMNProperties { public static String getProperty(String key, String defaultValue) { - String value = UrnPropertiesReader.getVariable(key); - if (value == null) { - return defaultValue; - } else { - return value; - } + String value = UrnPropertiesReader.getVariable(key); + if (value == null) { + return defaultValue; + } else { + return value; + } } public static List<String> getResourceSequenceProp(String input) { - String resourceSequence = UrnPropertiesReader.getVariable("mso.workflow.custom."+ input + ".resource.sequence"); + String resourceSequence = + UrnPropertiesReader.getVariable("mso.workflow.custom." + input + ".resource.sequence"); if (resourceSequence != null) { return Arrays.asList(resourceSequence.split(",")); } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/vfcmodel/NSResourceInputParameter.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/vfcmodel/NSResourceInputParameter.java index 292f6ef575..2995e24c00 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/vfcmodel/NSResourceInputParameter.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/vfcmodel/NSResourceInputParameter.java @@ -22,7 +22,6 @@ package org.onap.so.bpmn.infrastructure.vfcmodel; - /** * NS Create Input Parameter For VFC Adapter<br> * <p> @@ -44,7 +43,6 @@ public class NSResourceInputParameter { - /** * @return Returns the nsServiceName. */ diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/vfcmodel/NsOperationKey.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/vfcmodel/NsOperationKey.java index 81826a27eb..3e35952a9e 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/vfcmodel/NsOperationKey.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/vfcmodel/NsOperationKey.java @@ -21,8 +21,7 @@ package org.onap.so.bpmn.infrastructure.vfcmodel; /** - * The operation key object for NS - * <br> + * The operation key object for NS <br> * <p> * </p> * diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/vfcmodel/NsParameters.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/vfcmodel/NsParameters.java index 0d8f2fcbd7..ad388feffc 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/vfcmodel/NsParameters.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/vfcmodel/NsParameters.java @@ -37,7 +37,8 @@ public class NsParameters { private List<LocationConstraint> locationConstraints; - private Map<String, Object> additionalParamForNs = new HashMap<String,Object>(); + private Map<String, Object> additionalParamForNs = new HashMap<String, Object>(); + /** * @return Returns the locationConstraints. */ diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/vfcmodel/VimLocation.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/vfcmodel/VimLocation.java index 970fa43d9f..8b9295b44f 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/vfcmodel/VimLocation.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/vfcmodel/VimLocation.java @@ -28,7 +28,7 @@ package org.onap.so.bpmn.infrastructure.vfcmodel; * </p> * * @author - * @version ONAP Amsterdam Release 2017-10-18 + * @version ONAP Amsterdam Release 2017-10-18 */ public class VimLocation { private String vimId; diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactory.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactory.java index 113f05d3ca..896a8bd98c 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactory.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactory.java @@ -22,15 +22,18 @@ package org.onap.so.bpmn.infrastructure.workflow.service; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; import java.io.IOException; import java.net.SocketTimeoutException; import java.util.ArrayList; +import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Optional; - import org.apache.commons.lang3.StringUtils; import org.apache.http.HttpResponse; import org.apache.http.ParseException; @@ -68,716 +71,734 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.web.util.UriUtils; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializationFeature; - public class ServicePluginFactory { - // SOTN calculate route - public static final String OOF_DEFAULT_ENDPOINT = "http://192.168.1.223:8443/oof/sotncalc"; - - public static final String THIRD_SP_DEFAULT_ENDPOINT = "http://192.168.1.223:8443/sp/resourcemgr/querytps"; - - public static final String INVENTORY_OSS_DEFAULT_ENDPOINT = "http://192.168.1.199:8443/oss/inventory"; - - private static final int DEFAULT_TIME_OUT = 60000; - - static JsonUtils jsonUtil = new JsonUtils(); - - private static Logger logger = LoggerFactory.getLogger(ServicePluginFactory.class); - - private static ServicePluginFactory instance; - - - public static synchronized ServicePluginFactory getInstance() { - if (null == instance) { - instance = new ServicePluginFactory(); - } - return instance; - } - - private ServicePluginFactory() { - - } - - private String getInventoryOSSEndPoint(){ - return UrnPropertiesReader.getVariable("mso.service-plugin.inventory-oss-endpoint", INVENTORY_OSS_DEFAULT_ENDPOINT); - } - - private String getThirdSPEndPoint(){ - return UrnPropertiesReader.getVariable("mso.service-plugin.third-sp-endpoint", THIRD_SP_DEFAULT_ENDPOINT); - } - - private String getOOFCalcEndPoint(){ - return UrnPropertiesReader.getVariable("mso.service-plugin.oof-calc-endpoint", OOF_DEFAULT_ENDPOINT); - } - - @SuppressWarnings("unchecked") - public String doProcessSiteLocation(ServiceDecomposition serviceDecomposition, String uuiRequest) { - if(!isNeedProcessSite(uuiRequest)) { - return uuiRequest; - } - - Map<String, Object> uuiObject = getJsonObject(uuiRequest, Map.class); - Map<String, Object> serviceObject = (Map<String, Object>) uuiObject.get("service"); - Map<String, Object> serviceParametersObject = (Map<String, Object>) serviceObject.get("parameters"); - Map<String, Object> serviceRequestInputs = (Map<String, Object>) serviceParametersObject.get("requestInputs"); - List<Object> resources = (List<Object>) serviceParametersObject.get("resources"); - - if (isSiteLocationLocal(serviceRequestInputs, resources)) { - // resources changed : added TP info - String newRequest = getJsonString(uuiObject); - return newRequest; - } - - List<Resource> addResourceList = new ArrayList<>(); - addResourceList.addAll(serviceDecomposition.getServiceResources()); - - serviceDecomposition.setVnfResources(null); - serviceDecomposition.setAllottedResources(null); - serviceDecomposition.setNetworkResources(null); - serviceDecomposition.setConfigResources(null); - for (Resource resource : addResourceList) { - String resourcemodelName = resource.getModelInfo().getModelName(); - if (StringUtils.containsIgnoreCase(resourcemodelName, "sppartner")) { - // change serviceDecomposition - serviceDecomposition.addResource(resource); - break; - } - } - - return uuiRequest; - } - - private boolean isNeedProcessSite(String uuiRequest) { - return uuiRequest.toLowerCase().contains("site_address") && uuiRequest.toLowerCase().contains("sotncondition_clientsignal"); - } - - @SuppressWarnings("unchecked") - private boolean isSiteLocationLocal(Map<String, Object> serviceRequestInputs, List<Object> resources) { - Map<String, Object> tpInfoMap = getTPforVPNAttachment(serviceRequestInputs); - - if(tpInfoMap.isEmpty()) { - return true; - } - String host = (String) tpInfoMap.get("host"); - // host is empty means TP is in local, not empty means TP is in remote ONAP - if (!host.isEmpty()) { - return false; - } - - Map<String, Object> accessTPInfo = new HashMap<String, Object>(); - accessTPInfo.put("access-provider-id", tpInfoMap.get("access-provider-id")); - accessTPInfo.put("access-client-id", tpInfoMap.get("access-client-id")); - accessTPInfo.put("access-topology-id", tpInfoMap.get("access-topology-id")); - accessTPInfo.put("access-node-id", tpInfoMap.get("access-node-id")); - accessTPInfo.put("access-ltp-id", tpInfoMap.get("access-ltp-id")); - - // change resources - String resourceName = (String) tpInfoMap.get("resourceName"); - for(Object curResource : resources) { - Map<String, Object> resource = (Map<String, Object>)curResource; - String curResourceName = (String) resource.get("resourceName"); - curResourceName = curResourceName.replaceAll(" ", ""); - if(resourceName.equalsIgnoreCase(curResourceName)) { - putResourceRequestInputs(resource, accessTPInfo); - break; - } - } - - return true; - } - - @SuppressWarnings("unchecked") - private Map<String, Object> getTPforVPNAttachment(Map<String, Object> serviceRequestInputs) { - Object location = null; - Object clientSignal = null; - String vpnAttachmentResourceName = null; - - // support R2 uuiReq and R1 uuiReq - // logic for R2 uuiRequest params in service level - for (Entry<String, Object> entry : serviceRequestInputs.entrySet()) { - String key = entry.getKey(); - if (key.toLowerCase().contains("site_address")) { - location = entry.getValue(); - } - if (key.toLowerCase().contains("sotncondition_clientsignal")) { - clientSignal = entry.getValue(); - vpnAttachmentResourceName = key.substring(0, key.indexOf("_")); - } - } - - Map<String, Object> tpInfoMap = new HashMap<String, Object>(); - - // Site resource has location param and SOTNAttachment resource has clientSignal param - if(location == null || clientSignal == null ) { - return tpInfoMap; - } - - // Query terminal points from InventoryOSS system by location. - String locationAddress = (String) location; - List<Object> locationTPList = queryAccessTPbyLocationFromInventoryOSS(locationAddress); - if(locationTPList != null && !locationTPList.isEmpty()) { - for(Object tp: locationTPList) { - Map<String, Object> tpJson = (Map<String, Object>) tp; - String loc = (String)tpJson.get ("location"); - if(StringUtils.equalsIgnoreCase (locationAddress, loc)) { - tpInfoMap = tpJson; - // add resourceName - tpInfoMap.put("resourceName", vpnAttachmentResourceName); - break; - } - } - logger.debug("Get Terminal TP from InventoryOSS"); - return tpInfoMap; - } - - return tpInfoMap; - } - - @SuppressWarnings("unchecked") - private List<Object> queryAccessTPbyLocationFromInventoryOSS(String locationAddress) { - String url = getInventoryOSSEndPoint(); - url += "/oss/inventory?location=" + UriUtils.encode(locationAddress,"UTF-8"); - String responseContent = sendRequest(url, "GET", ""); - List<Object> accessTPs = new ArrayList<>(); - if (null != responseContent) { - accessTPs = getJsonObject(responseContent, List.class); - } - return accessTPs; - } - - @SuppressWarnings("unchecked") - private void putResourceRequestInputs(Map<String, Object> resource, Map<String, Object> resourceInputs) { - Map<String, Object> resourceParametersObject = new HashMap<>(); - Map<String, Object> resourceRequestInputs = new HashMap<>(); - resourceRequestInputs.put("requestInputs", resourceInputs); - resourceParametersObject.put("parameters", resourceRequestInputs); - - if(resource.containsKey("parameters")) { - Map<String, Object> resParametersObject = (Map<String, Object>) resource.get("parameters"); - if(resParametersObject.containsKey("requestInputs")) { - Map<String, Object> resRequestInputs = (Map<String, Object>) resourceRequestInputs.get("requestInputs"); - Map<String, Object> oldRequestInputs = (Map<String, Object>) resParametersObject.get("requestInputs"); - if(oldRequestInputs != null) { - oldRequestInputs.putAll(resRequestInputs); - } - else { - resParametersObject.put("requestInputs", resRequestInputs); - } - } - else { - resParametersObject.putAll(resourceRequestInputs); - } - } - else { - resource.putAll(resourceParametersObject); - } - - return; - } - - - - @SuppressWarnings("unchecked") - public String doTPResourcesAllocation(DelegateExecution execution, String uuiRequest) { - Map<String, Object> uuiObject = getJsonObject(uuiRequest, Map.class); - Map<String, Object> serviceObject = (Map<String, Object>) uuiObject.get("service"); - Map<String, Object> serviceParametersObject = (Map<String, Object>) serviceObject.get("parameters"); - Map<String, Object> serviceRequestInputs = (Map<String, Object>) serviceParametersObject.get("requestInputs"); - - if(!isNeedAllocateCrossTPResources(serviceRequestInputs)) { - return uuiRequest; - } - - allocateCrossTPResources(execution, serviceRequestInputs); - String newRequest = getJsonString(uuiObject); - return newRequest; - } - - @SuppressWarnings("unchecked") - private boolean isNeedAllocateCrossTPResources(Map<String, Object> serviceRequestInputs) { - if(serviceRequestInputs.containsKey("CallSource")) - { - String callSource = (String) serviceRequestInputs.get("CallSource"); - if("ExternalAPI".equalsIgnoreCase(callSource)) { - return false; - } - } - for (String input : serviceRequestInputs.keySet()) - { - if(input.toLowerCase().contains("sotnconnectivity")) { - return true; - } - } - return false; - } - - @SuppressWarnings("unchecked") - private void allocateCrossTPResources(DelegateExecution execution, Map<String, Object> serviceRequestInputs) { - - Map<String, Object> crossTPs = this.getTPsfromAAI(); - - if(crossTPs == null || crossTPs.isEmpty()) { - serviceRequestInputs.put("local-access-provider-id", ""); - serviceRequestInputs.put("local-access-client-id", ""); - serviceRequestInputs.put("local-access-topology-id", ""); - serviceRequestInputs.put("local-access-node-id", ""); - serviceRequestInputs.put("local-access-ltp-id", ""); - serviceRequestInputs.put("remote-access-provider-id", ""); - serviceRequestInputs.put("remote-access-client-id", ""); - serviceRequestInputs.put("remote-access-topology-id", ""); - serviceRequestInputs.put("remote-access-node-id", ""); - serviceRequestInputs.put("remote-access-ltp-id", ""); - } - else { - serviceRequestInputs.put("local-access-provider-id", crossTPs.get("local-access-provider-id")); - serviceRequestInputs.put("local-access-client-id", crossTPs.get("local-access-client-id")); - serviceRequestInputs.put("local-access-topology-id", crossTPs.get("local-access-topology-id")); - serviceRequestInputs.put("local-access-node-id", crossTPs.get("local-access-node-id")); - serviceRequestInputs.put("local-access-ltp-id", crossTPs.get("local-access-ltp-id")); - serviceRequestInputs.put("remote-access-provider-id", crossTPs.get("remote-access-provider-id")); - serviceRequestInputs.put("remote-access-client-id", crossTPs.get("remote-client-id")); - serviceRequestInputs.put("remote-access-topology-id", crossTPs.get("remote-topology-id")); - serviceRequestInputs.put("remote-access-node-id", crossTPs.get("remote-node-id")); - serviceRequestInputs.put("remote-access-ltp-id", crossTPs.get("remote-ltp-id")); - } - - return; - } - - // This method returns Local and remote TPs information from AAI - public Map getTPsfromAAI() { - Map<String, Object> tpInfo = new HashMap<>(); - - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.LOGICAL_LINK); - AAIResourcesClient client = new AAIResourcesClient(); - Optional<LogicalLinks> result = client.get(LogicalLinks.class, uri); - - if (result.isPresent()) { - LogicalLinks links = result.get(); - boolean isRemoteLink = false; - - links.getLogicalLink(); - - for (LogicalLink link : links.getLogicalLink()) { - AAIResultWrapper wrapper = new AAIResultWrapper(link); - Optional<Relationships> optRelationships = wrapper.getRelationships(); - List<AAIResourceUri> pInterfaces = new ArrayList<>(); - if (optRelationships.isPresent()) { - Relationships relationships = optRelationships.get(); - if (!relationships.getRelatedAAIUris(AAIObjectType.EXT_AAI_NETWORK).isEmpty()) { - isRemoteLink = true; - } - pInterfaces.addAll(relationships.getRelatedAAIUris(AAIObjectType.P_INTERFACE)); - } - - if (isRemoteLink) { - // find remote p interface - AAIResourceUri localTP = null; - AAIResourceUri remoteTP = null; - - AAIResourceUri pInterface0 = pInterfaces.get(0); - - if (isRemotePInterface(client, pInterface0)) { - remoteTP = pInterfaces.get(0); - localTP = pInterfaces.get(1); - } else { - localTP = pInterfaces.get(0); - remoteTP = pInterfaces.get(1); - } - - if (localTP != null && remoteTP != null) { - // give local tp - String tpUrl = localTP.build().toString(); - PInterface intfLocal = client.get(PInterface.class, localTP).get(); - tpInfo.put("local-access-node-id", tpUrl.split("/")[6]); - - String[] networkRef = intfLocal.getNetworkRef().split("/"); - if (networkRef.length == 6) { - tpInfo.put("local-access-provider-id", networkRef[1]); - tpInfo.put("local-access-client-id", networkRef[3]); - tpInfo.put("local-access-topology-id", networkRef[5]); - } - String ltpIdStr = tpUrl.substring(tpUrl.lastIndexOf("/") + 1); - if (ltpIdStr.contains("-")) { - tpInfo.put("local-access-ltp-id", ltpIdStr.substring(ltpIdStr.lastIndexOf("-") + 1)); - } - - // give remote tp - tpUrl = remoteTP.build().toString(); - PInterface intfRemote = client.get(PInterface.class, remoteTP).get(); - tpInfo.put("remote-access-node-id", tpUrl.split("/")[6]); - - String[] networkRefRemote = intfRemote.getNetworkRef().split("/"); - - if (networkRefRemote.length == 6) { - tpInfo.put("remote-access-provider-id", networkRefRemote[1]); - tpInfo.put("remote-access-client-id", networkRefRemote[3]); - tpInfo.put("remote-access-topology-id", networkRefRemote[5]); - } - String ltpIdStrR = tpUrl.substring(tpUrl.lastIndexOf("/") + 1); - if (ltpIdStrR.contains("-")) { - tpInfo.put("remote-access-ltp-id", ltpIdStrR.substring(ltpIdStr.lastIndexOf("-") + 1)); - } - return tpInfo; - } - } - } - } - return tpInfo; - } - - // this method check if pInterface is remote - private boolean isRemotePInterface(AAIResourcesClient client, AAIResourceUri uri) { - - String uriString = uri.build().toString(); - - if (uriString != null) { - // get the pnfname - String[] token = uriString.split("/"); - AAIResourceUri parent = AAIUriFactory.createResourceUri(AAIObjectType.PNF, token[4]); - - AAIResultWrapper wrapper = client.get(parent); - Optional<Relationships> optRelationships = wrapper.getRelationships(); - if (optRelationships.isPresent()) { - Relationships relationships = optRelationships.get(); - - return !relationships.getRelatedAAIUris(AAIObjectType.EXT_AAI_NETWORK).isEmpty(); - } - } - - return false; - } - - public String preProcessService(ServiceDecomposition serviceDecomposition, String uuiRequest) { - - // now only for sotn - if (isSOTN(serviceDecomposition, uuiRequest)) { - // We Need to query the terminalpoint of the VPN by site location - // info - return preProcessSOTNService(serviceDecomposition, uuiRequest); - } - return uuiRequest; - } - - public String doServiceHoming(ServiceDecomposition serviceDecomposition, String uuiRequest) { - // now only for sotn - if (isSOTN(serviceDecomposition, uuiRequest)) { - return doSOTNServiceHoming(serviceDecomposition, uuiRequest); - } - return uuiRequest; - } - - private boolean isSOTN(ServiceDecomposition serviceDecomposition, String uuiRequest) { - // there should be a register platform , we check it very simple here. - return uuiRequest.contains("clientSignal") && uuiRequest.contains("vpnType"); - } - - private String preProcessSOTNService(ServiceDecomposition serviceDecomposition, String uuiRequest) { - Map<String, Object> uuiObject = getJsonObject(uuiRequest, Map.class); - Map<String, Object> serviceObject = (Map<String, Object>) uuiObject.get("service"); - Map<String, Object> serviceParametersObject = (Map<String, Object>) serviceObject.get("parameters"); - Map<String, Object> serviceRequestInputs = (Map<String, Object>) serviceParametersObject.get("requestInputs"); - List<Object> resources = (List<Object>) serviceParametersObject.get("resources"); - // This is a logic for demo , it could not be finalized to community. - String srcLocation = ""; - String dstLocation = ""; - String srcClientSignal = ""; - String dstClientSignal = ""; - // support R2 uuiReq and R1 uuiReq - // logic for R2 uuiRequest params in service level - for (Entry<String, Object> entry : serviceRequestInputs.entrySet()) { - if (entry.getKey().toLowerCase().contains("location")) { - if ("".equals(srcLocation)) { - srcLocation = (String) entry.getValue(); - } else if ("".equals(dstLocation)) { - dstLocation = (String) entry.getValue(); - } - } - if (entry.getKey().toLowerCase().contains("clientsignal")) { - if ("".equals(srcClientSignal)) { - srcClientSignal = (String) entry.getValue(); - } else if ("".equals(dstClientSignal)) { - dstClientSignal = (String) entry.getValue(); - } - } - } - - // logic for R1 uuiRequest, params in resource level - for (Object resource : resources) { - Map<String, Object> resourceObject = (Map<String, Object>) resource; - Map<String, Object> resourceParametersObject = (Map<String, Object>) resourceObject.get("parameters"); - Map<String, Object> resourceRequestInputs = (Map<String, Object>) resourceParametersObject.get("requestInputs"); - for (Entry<String, Object> entry : resourceRequestInputs.entrySet()) { - if (entry.getKey().toLowerCase().contains("location")) { - if ("".equals(srcLocation)) { - srcLocation = (String) entry.getValue(); - } else if ("".equals(dstLocation)) { - dstLocation = (String) entry.getValue(); - } - } - if (entry.getKey().toLowerCase().contains("clientsignal")) { - if ("".equals(srcClientSignal)) { - srcClientSignal = (String) entry.getValue(); - } else if ("".equals(dstClientSignal)) { - dstClientSignal = (String) entry.getValue(); - } - } - } - } - - Map<String, Object> vpnRequestInputs = getVPNResourceRequestInputs(resources); - // here we put client signal to vpn resource inputs - if(null!=vpnRequestInputs) { - vpnRequestInputs.put("src-client-signal", srcClientSignal); - vpnRequestInputs.put("dst-client-signal", dstClientSignal); - } - - - // Now we need to query terminal points from SP resourcemgr system. - List<Object> locationTerminalPointList = queryTerminalPointsFromServiceProviderSystem(srcLocation, dstLocation); - Map<String, Object> tpInfoMap = (Map<String, Object>) locationTerminalPointList.get(0); - - serviceRequestInputs.put("inner-src-access-provider-id", tpInfoMap.get("access-provider-id")); - serviceRequestInputs.put("inner-src-access-client-id", tpInfoMap.get("access-client-id")); - serviceRequestInputs.put("inner-src-access-topology-id", tpInfoMap.get("access-topology-id")); - serviceRequestInputs.put("inner-src-access-node-id", tpInfoMap.get("access-node-id")); - serviceRequestInputs.put("inner-src-access-ltp-id", tpInfoMap.get("access-ltp-id")); - tpInfoMap = (Map<String, Object>) locationTerminalPointList.get(1); - - serviceRequestInputs.put("inner-dst-access-provider-id", tpInfoMap.get("access-provider-id")); - serviceRequestInputs.put("inner-dst-access-client-id", tpInfoMap.get("access-client-id")); - serviceRequestInputs.put("inner-dst-access-topology-id", tpInfoMap.get("access-topology-id")); - serviceRequestInputs.put("inner-dst-access-node-id", tpInfoMap.get("access-node-id")); - serviceRequestInputs.put("inner-dst-access-ltp-id", tpInfoMap.get("access-ltp-id")); - - String newRequest = getJsonString(uuiObject); - return newRequest; - } - - private List<Object> queryTerminalPointsFromServiceProviderSystem(String srcLocation, String dstLocation) { - Map<String, String> locationSrc = new HashMap<>(); - locationSrc.put("location", srcLocation); - Map<String, String> locationDst = new HashMap<>(); - locationDst.put("location", dstLocation); - List<Map<String, String>> locations = new ArrayList<>(); - locations.add(locationSrc); - locations.add(locationDst); - List<Object> returnList = new ArrayList<>(); - String reqContent = getJsonString(locations); - String url = getThirdSPEndPoint(); - String responseContent = sendRequest(url, "POST", reqContent); - if (null != responseContent) { - returnList = getJsonObject(responseContent, List.class); - } - return returnList; - } - - @SuppressWarnings("unchecked") - private Map<String, Object> getVPNResourceRequestInputs(List<Object> resources) { - for (Object resource : resources) { - Map<String, Object> resourceObject = (Map<String, Object>) resource; - Map<String, Object> resourceParametersObject = (Map<String, Object>) resourceObject.get("parameters"); - Map<String, Object> resourceRequestInputs = (Map<String, Object>) resourceParametersObject.get("requestInputs"); - for (Entry<String, Object> entry : resourceRequestInputs.entrySet()) { - if (entry.getKey().toLowerCase().contains("vpntype")) { - return resourceRequestInputs; - } - } - } - return null; - } - - public static void main(String args[]){ - String str = "restconf/config/GENERIC-RESOURCE-API:services/service/eca7e542-12ba-48de-8544-fac59303b14e/service-data/networks/network/aec07806-1671-4af2-b722-53c8e320a633/network-data/"; - - int index1 = str.indexOf("/network/"); - int index2 = str.indexOf("/network-data"); - - String str1 = str.substring(index1 + "/network/".length(), index2); - System.out.println(str1); - - } - - private String doSOTNServiceHoming(ServiceDecomposition serviceDecomposition, String uuiRequest) { - // query the route for the service. - Map<String, Object> uuiObject = getJsonObject(uuiRequest, Map.class); - Map<String, Object> serviceObject = (Map<String, Object>) uuiObject.get("service"); - Map<String, Object> serviceParametersObject = (Map<String, Object>) serviceObject.get("parameters"); - Map<String, Object> serviceRequestInputs = (Map<String, Object>) serviceParametersObject.get("requestInputs"); - Map<String, Object> oofQueryObject = new HashMap<>(); - List<Object> resources = (List<Object>) serviceParametersObject.get("resources"); - oofQueryObject.put("src-access-provider-id", serviceRequestInputs.get("inner-src-access-provider-id")); - oofQueryObject.put("src-access-client-id", serviceRequestInputs.get("inner-src-access-client-id")); - oofQueryObject.put("src-access-topology-id", serviceRequestInputs.get("inner-src-access-topology-id")); - oofQueryObject.put("src-access-node-id", serviceRequestInputs.get("inner-src-access-node-id")); - oofQueryObject.put("src-access-ltp-id", serviceRequestInputs.get("inner-src-access-ltp-id")); - oofQueryObject.put("dst-access-provider-id", serviceRequestInputs.get("inner-dst-access-provider-id")); - oofQueryObject.put("dst-access-client-id", serviceRequestInputs.get("inner-dst-access-client-id")); - oofQueryObject.put("dst-access-topology-id", serviceRequestInputs.get("inner-dst-access-topology-id")); - oofQueryObject.put("dst-access-node-id", serviceRequestInputs.get("inner-dst-access-node-id")); - oofQueryObject.put("dst-access-ltp-id", serviceRequestInputs.get("inner-dst-access-ltp-id")); - String oofRequestReq = getJsonString(oofQueryObject); - String url = getOOFCalcEndPoint(); - String responseContent = sendRequest(url, "POST", oofRequestReq); - - List<Object> returnList = new ArrayList<>(); - if (null != responseContent) { - returnList = getJsonObject(responseContent, List.class); - } - // in demo we have only one VPN. no cross VPNs, so get first item. - Map<String, Object> returnRoute = getReturnRoute(returnList); - Map<String, Object> vpnRequestInputs = getVPNResourceRequestInputs(resources); - if(null!=vpnRequestInputs) { - vpnRequestInputs.putAll(returnRoute); - } - String newRequest = getJsonString(uuiObject); - return newRequest; - } - - private Map<String, Object> getReturnRoute(List<Object> returnList){ - Map<String, Object> returnRoute = new HashMap<>(); - for(Object returnVpn :returnList){ - Map<String, Object> returnVpnInfo = (Map<String, Object>) returnVpn; - String accessTopoId = (String)returnVpnInfo.get("access-topology-id"); - if("100".equals(accessTopoId)){ - returnRoute.putAll(returnVpnInfo); - } - else if("101".equals(accessTopoId)){ - for(String key : returnVpnInfo.keySet()){ - returnRoute.put("domain1-" + key, returnVpnInfo.get(key)); - } - } - else if("102".equals(accessTopoId)){ - for(String key : returnVpnInfo.keySet()){ - returnRoute.put("domain2-" + key, returnVpnInfo.get(key)); - } - } - else{ - for(String key : returnVpnInfo.keySet()){ - returnRoute.put("domain" + accessTopoId +"-" + key, returnVpnInfo.get(key)); - } - } - } - return returnRoute; - } - - private Map<String, Object> getResourceParams(Execution execution, String resourceCustomizationUuid, - String serviceParameters) { - List<String> resourceList = jsonUtil.StringArrayToList(execution, - JsonUtils.getJsonValue(serviceParameters, "resources")); - // Get the right location str for resource. default is an empty array. - String resourceInputsFromUui = ""; - for (String resource : resourceList) { - String resCusUuid = JsonUtils.getJsonValue(resource, "resourceCustomizationUuid"); - if (resourceCustomizationUuid.equals(resCusUuid)) { - String resourceParameters = JsonUtils.getJsonValue(resource, "parameters"); - resourceInputsFromUui = JsonUtils.getJsonValue(resourceParameters, "requestInputs"); - } - } - Map<String, Object> resourceInputsFromUuiMap = getJsonObject(resourceInputsFromUui, Map.class); - return resourceInputsFromUuiMap; - } - - 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); - } catch (IOException e) { - logger.error("{} {} fail to unMarshal json", MessageEnum.RA_NS_EXC.toString(), - ErrorCode.BusinessProcesssError.getValue(), e); - } - return null; - } - - 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); - } catch (JsonProcessingException e) { - logger.debug("SdcToscaParserException", e); - } - return jsonStr; - } - - private static String sendRequest(String url, String methodType, String content) { - - String msbUrl = url; - HttpRequestBase method = null; - HttpResponse httpResponse = null; - - try { - int timeout = DEFAULT_TIME_OUT; - - RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(timeout).setConnectTimeout(timeout) - .setConnectionRequestTimeout(timeout).build(); - - HttpClient client = HttpClientBuilder.create().build(); - - if ("POST".equals(methodType.toUpperCase())) { - HttpPost httpPost = new HttpPost(msbUrl); - httpPost.setConfig(requestConfig); - httpPost.setEntity(new StringEntity(content, ContentType.APPLICATION_JSON)); - method = httpPost; - } else if ("PUT".equals(methodType.toUpperCase())) { - HttpPut httpPut = new HttpPut(msbUrl); - httpPut.setConfig(requestConfig); - httpPut.setEntity(new StringEntity(content, ContentType.APPLICATION_JSON)); - method = httpPut; - } else if ("GET".equals(methodType.toUpperCase())) { - HttpGet httpGet = new HttpGet(msbUrl); - httpGet.setConfig(requestConfig); - httpGet.addHeader("X-FromAppId", "MSO"); - httpGet.addHeader("Accept","application/json"); - method = httpGet; - } else if ("DELETE".equals(methodType.toUpperCase())) { - HttpDelete httpDelete = new HttpDelete(msbUrl); - httpDelete.setConfig(requestConfig); - method = httpDelete; - } - - httpResponse = client.execute(method); - String responseContent = null; - if (null != httpResponse && httpResponse.getEntity() != null) { - try { - responseContent = EntityUtils.toString(httpResponse.getEntity(), "UTF-8"); - } catch (ParseException e) { - logger.debug("ParseException in sendrequest", e); - } catch (IOException e) { - logger.debug("IOException in sendrequest", e); - } - } - if (null != method) { - method.reset(); - } - method = null; - return responseContent; - - } catch (SocketTimeoutException | ConnectTimeoutException e) { - return null; - - } catch (Exception e) { - return null; - - } finally { - if (httpResponse != null) { - try { - EntityUtils.consume(httpResponse.getEntity()); - } catch (Exception e) { - } - } - if (method != null) { - try { - method.reset(); - } catch (Exception e) { - - } - } - } - } + // SOTN calculate route + public static final String OOF_DEFAULT_ENDPOINT = "http://192.168.1.223:8443/oof/sotncalc"; + + public static final String THIRD_SP_DEFAULT_ENDPOINT = "http://192.168.1.223:8443/sp/resourcemgr/querytps"; + + public static final String INVENTORY_OSS_DEFAULT_ENDPOINT = "http://192.168.1.199:8443/oss/inventory"; + + private static final int DEFAULT_TIME_OUT = 60000; + + static JsonUtils jsonUtil = new JsonUtils(); + + private static Logger logger = LoggerFactory.getLogger(ServicePluginFactory.class); + + private static ServicePluginFactory instance; + + + public static synchronized ServicePluginFactory getInstance() { + if (null == instance) { + instance = new ServicePluginFactory(); + } + return instance; + } + + private ServicePluginFactory() { + + } + + private String getInventoryOSSEndPoint() { + return UrnPropertiesReader.getVariable("mso.service-plugin.inventory-oss-endpoint", + INVENTORY_OSS_DEFAULT_ENDPOINT); + } + + private String getThirdSPEndPoint() { + return UrnPropertiesReader.getVariable("mso.service-plugin.third-sp-endpoint", THIRD_SP_DEFAULT_ENDPOINT); + } + + private String getOOFCalcEndPoint() { + return UrnPropertiesReader.getVariable("mso.service-plugin.oof-calc-endpoint", OOF_DEFAULT_ENDPOINT); + } + + @SuppressWarnings("unchecked") + public String doProcessSiteLocation(ServiceDecomposition serviceDecomposition, String uuiRequest) { + if (!isNeedProcessSite(uuiRequest)) { + return uuiRequest; + } + + Map<String, Object> uuiObject = getJsonObject(uuiRequest, Map.class); + if (uuiObject == null) { + return uuiRequest; + } + Map<String, Object> serviceObject = + (Map<String, Object>) uuiObject.getOrDefault("service", Collections.emptyMap()); + Map<String, Object> serviceParametersObject = + (Map<String, Object>) serviceObject.getOrDefault("parameters", Collections.emptyMap()); + Map<String, Object> serviceRequestInputs = + (Map<String, Object>) serviceParametersObject.getOrDefault("requestInputs", Collections.emptyMap()); + List<Object> resources = + (List<Object>) serviceParametersObject.getOrDefault("resources", Collections.emptyList()); + + if (isSiteLocationLocal(serviceRequestInputs, resources)) { + // resources changed : added TP info + return getJsonString(uuiObject); + } + + List<Resource> addResourceList = new ArrayList<>(); + addResourceList.addAll(serviceDecomposition.getServiceResources()); + + serviceDecomposition.setVnfResources(null); + serviceDecomposition.setAllottedResources(null); + serviceDecomposition.setNetworkResources(null); + serviceDecomposition.setConfigResources(null); + for (Resource resource : addResourceList) { + String resourcemodelName = resource.getModelInfo().getModelName(); + if (StringUtils.containsIgnoreCase(resourcemodelName, "sppartner")) { + // change serviceDecomposition + serviceDecomposition.addResource(resource); + break; + } + } + + return uuiRequest; + } + + private boolean isNeedProcessSite(String uuiRequest) { + return uuiRequest.toLowerCase().contains("site_address") + && uuiRequest.toLowerCase().contains("sotncondition_clientsignal"); + } + + @SuppressWarnings("unchecked") + private boolean isSiteLocationLocal(Map<String, Object> serviceRequestInputs, List<Object> resources) { + Map<String, Object> tpInfoMap = getTPforVPNAttachment(serviceRequestInputs); + + if (tpInfoMap.isEmpty()) { + return true; + } + String host = (String) tpInfoMap.get("host"); + // host is empty means TP is in local, not empty means TP is in remote ONAP + if (!host.isEmpty()) { + return false; + } + + Map<String, Object> accessTPInfo = new HashMap<String, Object>(); + accessTPInfo.put("access-provider-id", tpInfoMap.get("access-provider-id")); + accessTPInfo.put("access-client-id", tpInfoMap.get("access-client-id")); + accessTPInfo.put("access-topology-id", tpInfoMap.get("access-topology-id")); + accessTPInfo.put("access-node-id", tpInfoMap.get("access-node-id")); + accessTPInfo.put("access-ltp-id", tpInfoMap.get("access-ltp-id")); + + // change resources + String resourceName = (String) tpInfoMap.get("resourceName"); + for (Object curResource : resources) { + Map<String, Object> resource = (Map<String, Object>) curResource; + String curResourceName = (String) resource.get("resourceName"); + curResourceName = curResourceName.replaceAll(" ", ""); + if (resourceName.equalsIgnoreCase(curResourceName)) { + putResourceRequestInputs(resource, accessTPInfo); + break; + } + } + + return true; + } + + @SuppressWarnings("unchecked") + private Map<String, Object> getTPforVPNAttachment(Map<String, Object> serviceRequestInputs) { + Object location = null; + Object clientSignal = null; + String vpnAttachmentResourceName = null; + + // support R2 uuiReq and R1 uuiReq + // logic for R2 uuiRequest params in service level + for (Entry<String, Object> entry : serviceRequestInputs.entrySet()) { + String key = entry.getKey(); + if (key.toLowerCase().contains("site_address")) { + location = entry.getValue(); + } + if (key.toLowerCase().contains("sotncondition_clientsignal")) { + clientSignal = entry.getValue(); + vpnAttachmentResourceName = key.substring(0, key.indexOf("_")); + } + } + + Map<String, Object> tpInfoMap = new HashMap<String, Object>(); + + // Site resource has location param and SOTNAttachment resource has clientSignal param + if (location == null || clientSignal == null) { + return tpInfoMap; + } + + // Query terminal points from InventoryOSS system by location. + String locationAddress = (String) location; + List<Object> locationTPList = queryAccessTPbyLocationFromInventoryOSS(locationAddress); + if (locationTPList != null && !locationTPList.isEmpty()) { + for (Object tp : locationTPList) { + Map<String, Object> tpJson = (Map<String, Object>) tp; + String loc = (String) tpJson.get("location"); + if (StringUtils.equalsIgnoreCase(locationAddress, loc)) { + tpInfoMap = tpJson; + // add resourceName + tpInfoMap.put("resourceName", vpnAttachmentResourceName); + break; + } + } + logger.debug("Get Terminal TP from InventoryOSS"); + return tpInfoMap; + } + + return tpInfoMap; + } + + @SuppressWarnings("unchecked") + private List<Object> queryAccessTPbyLocationFromInventoryOSS(String locationAddress) { + String url = getInventoryOSSEndPoint(); + url += "/oss/inventory?location=" + UriUtils.encode(locationAddress, "UTF-8"); + String responseContent = sendRequest(url, "GET", ""); + List<Object> accessTPs = new ArrayList<>(); + if (null != responseContent) { + accessTPs = getJsonObject(responseContent, List.class); + } + return accessTPs; + } + + @SuppressWarnings("unchecked") + private void putResourceRequestInputs(Map<String, Object> resource, Map<String, Object> resourceInputs) { + Map<String, Object> resourceParametersObject = new HashMap<>(); + Map<String, Object> resourceRequestInputs = new HashMap<>(); + resourceRequestInputs.put("requestInputs", resourceInputs); + resourceParametersObject.put("parameters", resourceRequestInputs); + + if (resource.containsKey("parameters")) { + Map<String, Object> resParametersObject = (Map<String, Object>) resource.get("parameters"); + if (resParametersObject.containsKey("requestInputs")) { + Map<String, Object> resRequestInputs = (Map<String, Object>) resourceRequestInputs.get("requestInputs"); + Map<String, Object> oldRequestInputs = (Map<String, Object>) resParametersObject.get("requestInputs"); + if (oldRequestInputs != null) { + oldRequestInputs.putAll(resRequestInputs); + } else { + resParametersObject.put("requestInputs", resRequestInputs); + } + } else { + resParametersObject.putAll(resourceRequestInputs); + } + } else { + resource.putAll(resourceParametersObject); + } + + return; + } + + + + @SuppressWarnings("unchecked") + public String doTPResourcesAllocation(DelegateExecution execution, String uuiRequest) { + Map<String, Object> uuiObject = getJsonObject(uuiRequest, Map.class); + if (uuiObject == null) { + return uuiRequest; + } + Map<String, Object> serviceObject = + (Map<String, Object>) uuiObject.getOrDefault("service", Collections.emptyMap()); + Map<String, Object> serviceParametersObject = + (Map<String, Object>) serviceObject.getOrDefault("parameters", Collections.emptyMap()); + Map<String, Object> serviceRequestInputs = + (Map<String, Object>) serviceParametersObject.getOrDefault("requestInputs", Collections.emptyMap()); + + if (!isNeedAllocateCrossTPResources(serviceRequestInputs)) { + return uuiRequest; + } + + allocateCrossTPResources(execution, serviceRequestInputs); + return getJsonString(uuiObject); + } + + @SuppressWarnings("unchecked") + private boolean isNeedAllocateCrossTPResources(Map<String, Object> serviceRequestInputs) { + if (serviceRequestInputs.containsKey("CallSource")) { + String callSource = (String) serviceRequestInputs.get("CallSource"); + if ("ExternalAPI".equalsIgnoreCase(callSource)) { + return false; + } + } + for (String input : serviceRequestInputs.keySet()) { + if (input.toLowerCase().contains("sotnconnectivity")) { + return true; + } + } + return false; + } + + @SuppressWarnings("unchecked") + private void allocateCrossTPResources(DelegateExecution execution, Map<String, Object> serviceRequestInputs) { + + Map<String, Object> crossTPs = this.getTPsfromAAI(); + + if (crossTPs == null || crossTPs.isEmpty()) { + serviceRequestInputs.put("local-access-provider-id", ""); + serviceRequestInputs.put("local-access-client-id", ""); + serviceRequestInputs.put("local-access-topology-id", ""); + serviceRequestInputs.put("local-access-node-id", ""); + serviceRequestInputs.put("local-access-ltp-id", ""); + serviceRequestInputs.put("remote-access-provider-id", ""); + serviceRequestInputs.put("remote-access-client-id", ""); + serviceRequestInputs.put("remote-access-topology-id", ""); + serviceRequestInputs.put("remote-access-node-id", ""); + serviceRequestInputs.put("remote-access-ltp-id", ""); + } else { + serviceRequestInputs.put("local-access-provider-id", crossTPs.get("local-access-provider-id")); + serviceRequestInputs.put("local-access-client-id", crossTPs.get("local-access-client-id")); + serviceRequestInputs.put("local-access-topology-id", crossTPs.get("local-access-topology-id")); + serviceRequestInputs.put("local-access-node-id", crossTPs.get("local-access-node-id")); + serviceRequestInputs.put("local-access-ltp-id", crossTPs.get("local-access-ltp-id")); + serviceRequestInputs.put("remote-access-provider-id", crossTPs.get("remote-access-provider-id")); + serviceRequestInputs.put("remote-access-client-id", crossTPs.get("remote-client-id")); + serviceRequestInputs.put("remote-access-topology-id", crossTPs.get("remote-topology-id")); + serviceRequestInputs.put("remote-access-node-id", crossTPs.get("remote-node-id")); + serviceRequestInputs.put("remote-access-ltp-id", crossTPs.get("remote-ltp-id")); + } + + return; + } + + // This method returns Local and remote TPs information from AAI + public Map getTPsfromAAI() { + Map<String, Object> tpInfo = new HashMap<>(); + + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.LOGICAL_LINK); + AAIResourcesClient client = new AAIResourcesClient(); + Optional<LogicalLinks> result = client.get(LogicalLinks.class, uri); + + if (result.isPresent()) { + LogicalLinks links = result.get(); + boolean isRemoteLink = false; + + links.getLogicalLink(); + + for (LogicalLink link : links.getLogicalLink()) { + AAIResultWrapper wrapper = new AAIResultWrapper(link); + Optional<Relationships> optRelationships = wrapper.getRelationships(); + List<AAIResourceUri> pInterfaces = new ArrayList<>(); + if (optRelationships.isPresent()) { + Relationships relationships = optRelationships.get(); + if (!relationships.getRelatedAAIUris(AAIObjectType.EXT_AAI_NETWORK).isEmpty()) { + isRemoteLink = true; + } + pInterfaces.addAll(relationships.getRelatedAAIUris(AAIObjectType.P_INTERFACE)); + } + + if (isRemoteLink) { + // find remote p interface + AAIResourceUri localTP = null; + AAIResourceUri remoteTP = null; + + AAIResourceUri pInterface0 = pInterfaces.get(0); + + if (isRemotePInterface(client, pInterface0)) { + remoteTP = pInterfaces.get(0); + localTP = pInterfaces.get(1); + } else { + localTP = pInterfaces.get(0); + remoteTP = pInterfaces.get(1); + } + + if (localTP != null && remoteTP != null) { + // give local tp + String tpUrl = localTP.build().toString(); + PInterface intfLocal = client.get(PInterface.class, localTP).get(); + tpInfo.put("local-access-node-id", tpUrl.split("/")[6]); + + String[] networkRef = intfLocal.getNetworkRef().split("/"); + if (networkRef.length == 6) { + tpInfo.put("local-access-provider-id", networkRef[1]); + tpInfo.put("local-access-client-id", networkRef[3]); + tpInfo.put("local-access-topology-id", networkRef[5]); + } + String ltpIdStr = tpUrl.substring(tpUrl.lastIndexOf("/") + 1); + if (ltpIdStr.contains("-")) { + tpInfo.put("local-access-ltp-id", ltpIdStr.substring(ltpIdStr.lastIndexOf("-") + 1)); + } + + // give remote tp + tpUrl = remoteTP.build().toString(); + PInterface intfRemote = client.get(PInterface.class, remoteTP).get(); + tpInfo.put("remote-access-node-id", tpUrl.split("/")[6]); + + String[] networkRefRemote = intfRemote.getNetworkRef().split("/"); + + if (networkRefRemote.length == 6) { + tpInfo.put("remote-access-provider-id", networkRefRemote[1]); + tpInfo.put("remote-access-client-id", networkRefRemote[3]); + tpInfo.put("remote-access-topology-id", networkRefRemote[5]); + } + String ltpIdStrR = tpUrl.substring(tpUrl.lastIndexOf("/") + 1); + if (ltpIdStrR.contains("-")) { + tpInfo.put("remote-access-ltp-id", ltpIdStrR.substring(ltpIdStr.lastIndexOf("-") + 1)); + } + return tpInfo; + } + } + } + } + return tpInfo; + } + + // this method check if pInterface is remote + private boolean isRemotePInterface(AAIResourcesClient client, AAIResourceUri uri) { + + String uriString = uri.build().toString(); + + if (uriString != null) { + // get the pnfname + String[] token = uriString.split("/"); + AAIResourceUri parent = AAIUriFactory.createResourceUri(AAIObjectType.PNF, token[4]); + + AAIResultWrapper wrapper = client.get(parent); + Optional<Relationships> optRelationships = wrapper.getRelationships(); + if (optRelationships.isPresent()) { + Relationships relationships = optRelationships.get(); + + return !relationships.getRelatedAAIUris(AAIObjectType.EXT_AAI_NETWORK).isEmpty(); + } + } + + return false; + } + + public String preProcessService(ServiceDecomposition serviceDecomposition, String uuiRequest) { + + // now only for sotn + if (isSOTN(serviceDecomposition, uuiRequest)) { + // We Need to query the terminalpoint of the VPN by site location + // info + return preProcessSOTNService(serviceDecomposition, uuiRequest); + } + return uuiRequest; + } + + public String doServiceHoming(ServiceDecomposition serviceDecomposition, String uuiRequest) { + // now only for sotn + if (isSOTN(serviceDecomposition, uuiRequest)) { + return doSOTNServiceHoming(serviceDecomposition, uuiRequest); + } + return uuiRequest; + } + + private boolean isSOTN(ServiceDecomposition serviceDecomposition, String uuiRequest) { + // there should be a register platform , we check it very simple here. + return uuiRequest.contains("clientSignal") && uuiRequest.contains("vpnType"); + } + + @SuppressWarnings("unchecked") + private String preProcessSOTNService(ServiceDecomposition serviceDecomposition, String uuiRequest) { + Map<String, Object> uuiObject = getJsonObject(uuiRequest, Map.class); + if (uuiObject == null) { + return uuiRequest; + } + Map<String, Object> serviceObject = + (Map<String, Object>) uuiObject.getOrDefault("service", Collections.emptyMap()); + Map<String, Object> serviceParametersObject = + (Map<String, Object>) serviceObject.getOrDefault("parameters", Collections.emptyMap()); + Map<String, Object> serviceRequestInputs = + (Map<String, Object>) serviceParametersObject.getOrDefault("requestInputs", Collections.emptyMap()); + List<Object> resources = + (List<Object>) serviceParametersObject.getOrDefault("resources", Collections.emptyList()); + // This is a logic for demo , it could not be finalized to community. + String srcLocation = ""; + String dstLocation = ""; + String srcClientSignal = ""; + String dstClientSignal = ""; + // support R2 uuiReq and R1 uuiReq + // logic for R2 uuiRequest params in service level + for (Entry<String, Object> entry : serviceRequestInputs.entrySet()) { + if (entry.getKey().toLowerCase().contains("location")) { + if ("".equals(srcLocation)) { + srcLocation = (String) entry.getValue(); + } else if ("".equals(dstLocation)) { + dstLocation = (String) entry.getValue(); + } + } + if (entry.getKey().toLowerCase().contains("clientsignal")) { + if ("".equals(srcClientSignal)) { + srcClientSignal = (String) entry.getValue(); + } else if ("".equals(dstClientSignal)) { + dstClientSignal = (String) entry.getValue(); + } + } + } + + // logic for R1 uuiRequest, params in resource level + for (Object resource : resources) { + Map<String, Object> resourceObject = (Map<String, Object>) resource; + Map<String, Object> resourceParametersObject = (Map<String, Object>) resourceObject.get("parameters"); + Map<String, Object> resourceRequestInputs = + (Map<String, Object>) resourceParametersObject.get("requestInputs"); + for (Entry<String, Object> entry : resourceRequestInputs.entrySet()) { + if (entry.getKey().toLowerCase().contains("location")) { + if ("".equals(srcLocation)) { + srcLocation = (String) entry.getValue(); + } else if ("".equals(dstLocation)) { + dstLocation = (String) entry.getValue(); + } + } + if (entry.getKey().toLowerCase().contains("clientsignal")) { + if ("".equals(srcClientSignal)) { + srcClientSignal = (String) entry.getValue(); + } else if ("".equals(dstClientSignal)) { + dstClientSignal = (String) entry.getValue(); + } + } + } + } + + Map<String, Object> vpnRequestInputs = getVPNResourceRequestInputs(resources); + // here we put client signal to vpn resource inputs + if (null != vpnRequestInputs) { + vpnRequestInputs.put("src-client-signal", srcClientSignal); + vpnRequestInputs.put("dst-client-signal", dstClientSignal); + } + + + // Now we need to query terminal points from SP resourcemgr system. + List<Object> locationTerminalPointList = queryTerminalPointsFromServiceProviderSystem(srcLocation, dstLocation); + Map<String, Object> tpInfoMap = (Map<String, Object>) locationTerminalPointList.get(0); + + serviceRequestInputs.put("inner-src-access-provider-id", tpInfoMap.get("access-provider-id")); + serviceRequestInputs.put("inner-src-access-client-id", tpInfoMap.get("access-client-id")); + serviceRequestInputs.put("inner-src-access-topology-id", tpInfoMap.get("access-topology-id")); + serviceRequestInputs.put("inner-src-access-node-id", tpInfoMap.get("access-node-id")); + serviceRequestInputs.put("inner-src-access-ltp-id", tpInfoMap.get("access-ltp-id")); + tpInfoMap = (Map<String, Object>) locationTerminalPointList.get(1); + + serviceRequestInputs.put("inner-dst-access-provider-id", tpInfoMap.get("access-provider-id")); + serviceRequestInputs.put("inner-dst-access-client-id", tpInfoMap.get("access-client-id")); + serviceRequestInputs.put("inner-dst-access-topology-id", tpInfoMap.get("access-topology-id")); + serviceRequestInputs.put("inner-dst-access-node-id", tpInfoMap.get("access-node-id")); + serviceRequestInputs.put("inner-dst-access-ltp-id", tpInfoMap.get("access-ltp-id")); + + String newRequest = getJsonString(uuiObject); + return newRequest; + } + + private List<Object> queryTerminalPointsFromServiceProviderSystem(String srcLocation, String dstLocation) { + Map<String, String> locationSrc = new HashMap<>(); + locationSrc.put("location", srcLocation); + Map<String, String> locationDst = new HashMap<>(); + locationDst.put("location", dstLocation); + List<Map<String, String>> locations = new ArrayList<>(); + locations.add(locationSrc); + locations.add(locationDst); + List<Object> returnList = new ArrayList<>(); + String reqContent = getJsonString(locations); + String url = getThirdSPEndPoint(); + String responseContent = sendRequest(url, "POST", reqContent); + if (null != responseContent) { + returnList = getJsonObject(responseContent, List.class); + } + return returnList; + } + + @SuppressWarnings("unchecked") + private Map<String, Object> getVPNResourceRequestInputs(List<Object> resources) { + for (Object resource : resources) { + Map<String, Object> resourceObject = (Map<String, Object>) resource; + Map<String, Object> resourceParametersObject = (Map<String, Object>) resourceObject.get("parameters"); + Map<String, Object> resourceRequestInputs = + (Map<String, Object>) resourceParametersObject.get("requestInputs"); + for (Entry<String, Object> entry : resourceRequestInputs.entrySet()) { + if (entry.getKey().toLowerCase().contains("vpntype")) { + return resourceRequestInputs; + } + } + } + return null; + } + + public static void main(String args[]) { + String str = + "restconf/config/GENERIC-RESOURCE-API:services/service/eca7e542-12ba-48de-8544-fac59303b14e/service-data/networks/network/aec07806-1671-4af2-b722-53c8e320a633/network-data/"; + + int index1 = str.indexOf("/network/"); + int index2 = str.indexOf("/network-data"); + + String str1 = str.substring(index1 + "/network/".length(), index2); + System.out.println(str1); + + } + + @SuppressWarnings("unchecked") + private String doSOTNServiceHoming(ServiceDecomposition serviceDecomposition, String uuiRequest) { + // query the route for the service. + Map<String, Object> uuiObject = getJsonObject(uuiRequest, Map.class); + if (uuiObject == null) { + return uuiRequest; + } + Map<String, Object> serviceObject = + (Map<String, Object>) uuiObject.getOrDefault("service", Collections.emptyMap()); + Map<String, Object> serviceParametersObject = + (Map<String, Object>) serviceObject.getOrDefault("parameters", Collections.emptyMap()); + Map<String, Object> serviceRequestInputs = + (Map<String, Object>) serviceParametersObject.getOrDefault("requestInputs", Collections.emptyMap()); + Map<String, Object> oofQueryObject = new HashMap<>(); + List<Object> resources = + (List<Object>) serviceParametersObject.getOrDefault("resources", Collections.emptyList()); + oofQueryObject.put("src-access-provider-id", serviceRequestInputs.get("inner-src-access-provider-id")); + oofQueryObject.put("src-access-client-id", serviceRequestInputs.get("inner-src-access-client-id")); + oofQueryObject.put("src-access-topology-id", serviceRequestInputs.get("inner-src-access-topology-id")); + oofQueryObject.put("src-access-node-id", serviceRequestInputs.get("inner-src-access-node-id")); + oofQueryObject.put("src-access-ltp-id", serviceRequestInputs.get("inner-src-access-ltp-id")); + oofQueryObject.put("dst-access-provider-id", serviceRequestInputs.get("inner-dst-access-provider-id")); + oofQueryObject.put("dst-access-client-id", serviceRequestInputs.get("inner-dst-access-client-id")); + oofQueryObject.put("dst-access-topology-id", serviceRequestInputs.get("inner-dst-access-topology-id")); + oofQueryObject.put("dst-access-node-id", serviceRequestInputs.get("inner-dst-access-node-id")); + oofQueryObject.put("dst-access-ltp-id", serviceRequestInputs.get("inner-dst-access-ltp-id")); + String oofRequestReq = getJsonString(oofQueryObject); + String url = getOOFCalcEndPoint(); + String responseContent = sendRequest(url, "POST", oofRequestReq); + + List<Object> returnList = new ArrayList<>(); + if (null != responseContent) { + returnList = getJsonObject(responseContent, List.class); + } + // in demo we have only one VPN. no cross VPNs, so get first item. + Map<String, Object> returnRoute = getReturnRoute(returnList); + Map<String, Object> vpnRequestInputs = getVPNResourceRequestInputs(resources); + if (null != vpnRequestInputs) { + vpnRequestInputs.putAll(returnRoute); + } + return getJsonString(uuiObject); + } + + private Map<String, Object> getReturnRoute(List<Object> returnList) { + Map<String, Object> returnRoute = new HashMap<>(); + for (Object returnVpn : returnList) { + Map<String, Object> returnVpnInfo = (Map<String, Object>) returnVpn; + String accessTopoId = (String) returnVpnInfo.get("access-topology-id"); + if ("100".equals(accessTopoId)) { + returnRoute.putAll(returnVpnInfo); + } else if ("101".equals(accessTopoId)) { + for (String key : returnVpnInfo.keySet()) { + returnRoute.put("domain1-" + key, returnVpnInfo.get(key)); + } + } else if ("102".equals(accessTopoId)) { + for (String key : returnVpnInfo.keySet()) { + returnRoute.put("domain2-" + key, returnVpnInfo.get(key)); + } + } else { + for (String key : returnVpnInfo.keySet()) { + returnRoute.put("domain" + accessTopoId + "-" + key, returnVpnInfo.get(key)); + } + } + } + return returnRoute; + } + + private Map<String, Object> getResourceParams(Execution execution, String resourceCustomizationUuid, + String serviceParameters) { + List<String> resourceList = + jsonUtil.StringArrayToList(execution, JsonUtils.getJsonValue(serviceParameters, "resources")); + // Get the right location str for resource. default is an empty array. + String resourceInputsFromUui = ""; + for (String resource : resourceList) { + String resCusUuid = JsonUtils.getJsonValue(resource, "resourceCustomizationUuid"); + if (resourceCustomizationUuid.equals(resCusUuid)) { + String resourceParameters = JsonUtils.getJsonValue(resource, "parameters"); + resourceInputsFromUui = JsonUtils.getJsonValue(resourceParameters, "requestInputs"); + } + } + Map<String, Object> resourceInputsFromUuiMap = getJsonObject(resourceInputsFromUui, Map.class); + return resourceInputsFromUuiMap; + } + + 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) { + logger.error("{} {} fail to unMarshal json", MessageEnum.RA_NS_EXC.toString(), + ErrorCode.BusinessProcesssError.getValue(), e); + } + return null; + } + + 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); + } catch (JsonProcessingException e) { + logger.debug("SdcToscaParserException", e); + } + return jsonStr; + } + + private static String sendRequest(String url, String methodType, String content) { + + String msbUrl = url; + HttpRequestBase method = null; + HttpResponse httpResponse = null; + + try { + int timeout = DEFAULT_TIME_OUT; + + RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(timeout).setConnectTimeout(timeout) + .setConnectionRequestTimeout(timeout).build(); + + HttpClient client = HttpClientBuilder.create().build(); + + if ("POST".equals(methodType.toUpperCase())) { + HttpPost httpPost = new HttpPost(msbUrl); + httpPost.setConfig(requestConfig); + httpPost.setEntity(new StringEntity(content, ContentType.APPLICATION_JSON)); + method = httpPost; + } else if ("PUT".equals(methodType.toUpperCase())) { + HttpPut httpPut = new HttpPut(msbUrl); + httpPut.setConfig(requestConfig); + httpPut.setEntity(new StringEntity(content, ContentType.APPLICATION_JSON)); + method = httpPut; + } else if ("GET".equals(methodType.toUpperCase())) { + HttpGet httpGet = new HttpGet(msbUrl); + httpGet.setConfig(requestConfig); + httpGet.addHeader("X-FromAppId", "MSO"); + httpGet.addHeader("Accept", "application/json"); + method = httpGet; + } else if ("DELETE".equals(methodType.toUpperCase())) { + HttpDelete httpDelete = new HttpDelete(msbUrl); + httpDelete.setConfig(requestConfig); + method = httpDelete; + } + + httpResponse = client.execute(method); + String responseContent = null; + if (null != httpResponse && httpResponse.getEntity() != null) { + try { + responseContent = EntityUtils.toString(httpResponse.getEntity(), "UTF-8"); + } catch (ParseException e) { + logger.debug("ParseException in sendrequest", e); + } catch (IOException e) { + logger.debug("IOException in sendrequest", e); + } + } + if (null != method) { + method.reset(); + } + method = null; + return responseContent; + + } catch (SocketTimeoutException | ConnectTimeoutException e) { + return null; + + } catch (Exception e) { + return null; + + } finally { + if (httpResponse != null) { + try { + EntityUtils.consume(httpResponse.getEntity()); + } catch (Exception e) { + } + } + if (method != null) { + try { + method.reset(); + } catch (Exception e) { + + } + } + } + } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/AbstractSdncOperationTask.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/AbstractSdncOperationTask.java index 4c9bb4259e..5451f9ff57 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/AbstractSdncOperationTask.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/AbstractSdncOperationTask.java @@ -27,7 +27,6 @@ import java.util.Arrays; import java.util.HashMap; import java.util.Iterator; import java.util.Map; - import org.apache.commons.lang3.StringUtils; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpPost; @@ -52,7 +51,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.env.Environment; - import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; @@ -69,30 +67,31 @@ public abstract class AbstractSdncOperationTask extends BaseTask { private static final String TOPOLOGY_PROPERTIES = "topology.properties"; public static final String ONAP_IP = "ONAP_IP"; - private static final String POST_BODY_TEMPLATE = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:ns=\"http://org.onap.so/requestsdb\"><soapenv:Header/><soapenv:Body>\n"+ - " <ns:updateResourceOperationStatus>\n"+ - " <errorCode>$errorCode</errorCode>\n"+ - " <jobId>$jobId</jobId>\n"+ - " <operType>$operType</operType>\n"+ - " <operationId>$operationId</operationId>\n"+ - " <progress>$progress</progress>\n"+ - " <resourceTemplateUUID>$resourceTemplateUUID</resourceTemplateUUID>\n"+ - " <serviceId>$serviceId</serviceId>\n"+ - " <status>$status</status>\n"+ - " <statusDescription>$statusDescription</statusDescription>\n"+ - " </ns:updateResourceOperationStatus></soapenv:Body></soapenv:Envelope>"; - - private static final String GET_BODY_TEMPLATE = " <soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:ns=\"http://org.onap.so/requestsdb\"><soapenv:Header/><soapenv:Body>\n" + - " <ns:getResourceOperationStatus>\n" + - " <operationId>$operationId</operationId>\n" + - " <resourceTemplateUUID>$resourceTemplateUUID</resourceTemplateUUID>\n" + - " <serviceId>$serviceId</serviceId>\n" + - " </ns:getResourceOperationStatus></soapenv:Body></soapenv:Envelope>"; + private static final String POST_BODY_TEMPLATE = + "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:ns=\"http://org.onap.so/requestsdb\"><soapenv:Header/><soapenv:Body>\n" + + " <ns:updateResourceOperationStatus>\n" + + " <errorCode>$errorCode</errorCode>\n" + " <jobId>$jobId</jobId>\n" + + " <operType>$operType</operType>\n" + + " <operationId>$operationId</operationId>\n" + + " <progress>$progress</progress>\n" + + " <resourceTemplateUUID>$resourceTemplateUUID</resourceTemplateUUID>\n" + + " <serviceId>$serviceId</serviceId>\n" + + " <status>$status</status>\n" + + " <statusDescription>$statusDescription</statusDescription>\n" + + " </ns:updateResourceOperationStatus></soapenv:Body></soapenv:Envelope>"; + + private static final String GET_BODY_TEMPLATE = + " <soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:ns=\"http://org.onap.so/requestsdb\"><soapenv:Header/><soapenv:Body>\n" + + " <ns:getResourceOperationStatus>\n" + + " <operationId>$operationId</operationId>\n" + + " <resourceTemplateUUID>$resourceTemplateUUID</resourceTemplateUUID>\n" + + " <serviceId>$serviceId</serviceId>\n" + + " </ns:getResourceOperationStatus></soapenv:Body></soapenv:Envelope>"; private void updateResOperStatus(ResourceOperationStatus resourceOperationStatus) throws RouteException { logger.info("AbstractSdncOperationTask.updateResOperStatus begin!"); - String requestsdbEndPoint = env.getProperty("mso.adapters.openecomp.db.endpoint"); + String requestsdbEndPoint = env.getProperty("mso.adapters.openecomp.db.endpoint"); HttpPost httpPost = new HttpPost(requestsdbEndPoint); httpPost.addHeader("Authorization", "Basic YnBlbDpwYXNzd29yZDEk"); httpPost.addHeader("Content-type", "application/soap+xml"); @@ -119,12 +118,13 @@ public abstract class AbstractSdncOperationTask extends BaseTask { String result = null; String errorMsg; - try(CloseableHttpClient httpClient = HttpClients.createDefault()) { + try (CloseableHttpClient httpClient = HttpClients.createDefault()) { CloseableHttpResponse closeableHttpResponse = httpClient.execute(httpPost); result = EntityUtils.toString(closeableHttpResponse.getEntity()); logger.info("result = {}", result); - if(closeableHttpResponse.getStatusLine().getStatusCode() != 200) { - logger.info("exception: fail for status code = {}", closeableHttpResponse.getStatusLine().getStatusCode()); + if (closeableHttpResponse.getStatusLine().getStatusCode() != 200) { + logger.info("exception: fail for status code = {}", + closeableHttpResponse.getStatusLine().getStatusCode()); throw new RouteException(result, "SERVICE_GET_ERR"); } @@ -171,9 +171,10 @@ public abstract class AbstractSdncOperationTask extends BaseTask { return getBody; } - private ResourceOperationStatus getResourceOperationStatus(String serviceId, String operationId, String resourceTemplateUUID) throws RouteException { + private ResourceOperationStatus getResourceOperationStatus(String serviceId, String operationId, + String resourceTemplateUUID) throws RouteException { logger.info("AbstractSdncOperationTask.getResourceOperationStatus begin!"); - String requestsdbEndPoint = env.getProperty("mso.adapters.openecomp.db.endpoint"); + String requestsdbEndPoint = env.getProperty("mso.adapters.openecomp.db.endpoint"); HttpPost httpPost = new HttpPost(requestsdbEndPoint); httpPost.addHeader("Authorization", "Basic YnBlbDpwYXNzd29yZDEk"); httpPost.addHeader("Content-type", "application/soap+xml"); @@ -224,7 +225,8 @@ public abstract class AbstractSdncOperationTask extends BaseTask { logger.error("exception: AbstractSdncOperationTask.fail!:", e); logger.error(Arrays.toString(e.getStackTrace())); execution.setVariable("SDNCA_SuccessIndicator", false); - updateProgress(execution, RequestsDbConstant.Status.ERROR, null, "100", "sendRestrequestAndHandleResponse finished!"); + updateProgress(execution, RequestsDbConstant.Status.ERROR, null, "100", + "sendRestrequestAndHandleResponse finished!"); } logger.info("AbstractSdncOperationTask.execute end!"); @@ -247,15 +249,11 @@ public abstract class AbstractSdncOperationTask extends BaseTask { return inputs; } - public abstract void sendRestrequestAndHandleResponse(DelegateExecution execution, - Map<String, String> inputs, - GenericResourceApi genericResourceApiClient) throws Exception; + public abstract void sendRestrequestAndHandleResponse(DelegateExecution execution, Map<String, String> inputs, + GenericResourceApi genericResourceApiClient) throws Exception; - public void updateProgress(DelegateExecution execution, - String status, - String errorCode, - String progress, - String statusDescription) { + public void updateProgress(DelegateExecution execution, String status, String errorCode, String progress, + String statusDescription) { logger.info("AbstractSdncOperationTask.updateProgress begin!"); String serviceId = (String) execution.getVariable("serviceId"); serviceId = StringUtils.isBlank(serviceId) ? (String) execution.getVariable("serviceInstanceId") : serviceId; @@ -265,7 +263,8 @@ public abstract class AbstractSdncOperationTask extends BaseTask { resourceTemplateId = StringUtils.isBlank(resourceTemplateId) ? "" : resourceTemplateUUID; resourceTemplateUUID = StringUtils.isBlank(resourceTemplateUUID) ? resourceTemplateId : resourceTemplateUUID; try { - ResourceOperationStatus resourceOperationStatus = getResourceOperationStatus(serviceId, operationId, resourceTemplateUUID); + ResourceOperationStatus resourceOperationStatus = + getResourceOperationStatus(serviceId, operationId, resourceTemplateUUID); if (!StringUtils.isBlank(status)) { resourceOperationStatus.setStatus(status); } @@ -284,8 +283,8 @@ public abstract class AbstractSdncOperationTask extends BaseTask { logger.info("exception: AbstractSdncOperationTask.updateProgress fail!"); logger.error("exception: AbstractSdncOperationTask.updateProgress fail:", exception); logger.error("{} {} {} {} {}", MessageEnum.GENERAL_EXCEPTION.toString(), - " updateProgress catch exception: ", this.getTaskName(), - ErrorCode.UnknownError.getValue(), exception.getClass().toString()); + " updateProgress catch exception: ", this.getTaskName(), ErrorCode.UnknownError.getValue(), + exception.getClass().toString()); } } @@ -293,11 +292,11 @@ public abstract class AbstractSdncOperationTask extends BaseTask { protected boolean isSend2SdncDirectly() { logger.info("AbstractSdncOperationTask.isSend2SdncDirectly begin!"); String sdncHost = UrnPropertiesReader.getVariable("sdnc.host"); - if (!StringUtils.isBlank(sdncHost)) { - logger.info("AbstractSdncOperationTask.isSend2SdncDirectly = true."); - return true; - } - + if (!StringUtils.isBlank(sdncHost)) { + logger.info("AbstractSdncOperationTask.isSend2SdncDirectly = true."); + return true; + } + logger.info("AbstractSdncOperationTask.isSend2SdncDirectly = false."); return false; } @@ -305,7 +304,7 @@ public abstract class AbstractSdncOperationTask extends BaseTask { protected String getSdncIp() { logger.info("AbstractSdncOperationTask.getSdncIp begin."); String sdncIp = null; - sdncIp = UrnPropertiesReader.getVariable("sdnc-ip"); + sdncIp = UrnPropertiesReader.getVariable("sdnc-ip"); String returnIp = StringUtils.isBlank(sdncIp) || !isIp(sdncIp) ? null : sdncIp; logger.info("AbstractSdncOperationTask.getSdncIp: sdncIp = {}", returnIp); return returnIp; @@ -340,7 +339,7 @@ public abstract class AbstractSdncOperationTask extends BaseTask { strMsbPort = env.getProperty("msb.port", String.valueOf(DEFAULT_MSB_PORT)); } msbPort = Integer.valueOf(strMsbPort); - + logger.info("AbstractSdncOperationTask.getGenericResourceApiClient msbIp = " + msbIp + " msbPort = " + msbPort); MSBServiceClient msbClient = new MSBServiceClient(msbIp, msbPort); RestServiceCreater restServiceCreater = new RestServiceCreater(msbClient); @@ -353,6 +352,7 @@ public abstract class AbstractSdncOperationTask extends BaseTask { } public String getProcessKey(DelegateExecution execution) { - return execution.getProcessEngineServices().getRepositoryService().getProcessDefinition(execution.getProcessDefinitionId()).getKey(); + return execution.getProcessEngineServices().getRepositoryService() + .getProcessDefinition(execution.getProcessDefinitionId()).getKey(); } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/SdncNetworkTopologyOperationTask.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/SdncNetworkTopologyOperationTask.java index a5c609dc2a..4d58439fda 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/SdncNetworkTopologyOperationTask.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/SdncNetworkTopologyOperationTask.java @@ -23,7 +23,6 @@ package org.onap.so.bpmn.infrastructure.workflow.serviceTask; import java.util.Map; - import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.ContentType; import org.apache.http.entity.StringEntity; @@ -49,29 +48,30 @@ public class SdncNetworkTopologyOperationTask extends AbstractSdncOperationTask private static final String URL = "/restconf/operations/GENERIC-RESOURCE-API:network-topology-operation"; @Override - public void sendRestrequestAndHandleResponse(DelegateExecution execution, - Map<String, String> inputs, - GenericResourceApi genericResourceApiClient) throws Exception { + public void sendRestrequestAndHandleResponse(DelegateExecution execution, Map<String, String> inputs, + GenericResourceApi genericResourceApiClient) throws Exception { logger.info("SdncNetworkTopologyOperationTask.sendRestrequestAndHandleResponse begin!"); - updateProgress(execution, RequestsDbConstant.Status.PROCESSING, null, "40", "sendRestrequestAndHandleResponse begin!"); + updateProgress(execution, RequestsDbConstant.Status.PROCESSING, null, "40", + "sendRestrequestAndHandleResponse begin!"); NetworkRpcInputEntityBuilder builder = new NetworkRpcInputEntityBuilder(); RpcNetworkTopologyOperationInputEntity inputEntity = builder.build(execution, inputs); updateProgress(execution, RequestsDbConstant.Status.PROCESSING, null, "50", "RequestBody build finished!"); RpcNetworkTopologyOperationOutputEntity outputEntity; if (!isSend2SdncDirectly()) { - outputEntity = genericResourceApiClient.postNetworkTopologyOperation - (HeaderUtil.DefaulAuth, inputEntity).execute().body(); - updateProgress(execution, null, null, "90", "sendRestrequestAndHandleResponse finished!"); - saveOutput(execution, outputEntity); + outputEntity = genericResourceApiClient.postNetworkTopologyOperation(HeaderUtil.DefaulAuth, inputEntity) + .execute().body(); + updateProgress(execution, null, null, "90", "sendRestrequestAndHandleResponse finished!"); + saveOutput(execution, outputEntity); } else { send2SdncDirectly(HeaderUtil.DefaulAuth, inputEntity); } - updateProgress(execution, RequestsDbConstant.Status.FINISHED, null, RequestsDbConstant.Progress.ONE_HUNDRED, "execute finished!"); + updateProgress(execution, RequestsDbConstant.Status.FINISHED, null, RequestsDbConstant.Progress.ONE_HUNDRED, + "execute finished!"); logger.info("SdncNetworkTopologyOperationTask.sendRestrequestAndHandleResponse end!"); } - private void send2SdncDirectly(String defaulAuth, - RpcNetworkTopologyOperationInputEntity inputEntity) throws RouteException { + private void send2SdncDirectly(String defaulAuth, RpcNetworkTopologyOperationInputEntity inputEntity) + throws RouteException { logger.info("SdncNetworkTopologyOperationTask.send2SdncDirectly begin!"); String url = "http://" + getSdncIp() + ":" + getSdncPort() + URL; HttpPost httpPost = new HttpPost(url); @@ -84,7 +84,8 @@ public class SdncNetworkTopologyOperationTask extends AbstractSdncOperationTask logger.info("SdncNetworkTopologyOperationTask.send2SdncDirectly end!"); } - private void saveOutput(DelegateExecution execution, RpcNetworkTopologyOperationOutputEntity output) throws RouteException { + private void saveOutput(DelegateExecution execution, RpcNetworkTopologyOperationOutputEntity output) + throws RouteException { logger.info("SdncNetworkTopologyOperationTask.saveOutput begin!"); String responseCode = output.getOutput().getResponseCode(); if (!"200".equals(responseCode)) { diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/SdncServiceTopologyOperationTask.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/SdncServiceTopologyOperationTask.java index 2fd550dbb8..4fb6817a39 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/SdncServiceTopologyOperationTask.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/SdncServiceTopologyOperationTask.java @@ -24,7 +24,6 @@ package org.onap.so.bpmn.infrastructure.workflow.serviceTask; import java.util.Map; - import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.ContentType; import org.apache.http.entity.StringEntity; @@ -50,9 +49,8 @@ public class SdncServiceTopologyOperationTask extends AbstractSdncOperationTask private static final String URL = "/restconf/operations/GENERIC-RESOURCE-API:service-topology-operation"; @Override - public void sendRestrequestAndHandleResponse(DelegateExecution execution, - Map<String, String> inputs, - GenericResourceApi genericResourceApiClient) throws Exception { + public void sendRestrequestAndHandleResponse(DelegateExecution execution, Map<String, String> inputs, + GenericResourceApi genericResourceApiClient) throws Exception { logger.info("SdncServiceTopologyOperationTask.sendRestrequestAndHandleResponse begin!"); updateProgress(execution, null, null, "40", "sendRestrequestAndHandleResponse begin!"); ServiceRpcInputEntityBuilder builder = new ServiceRpcInputEntityBuilder(); @@ -60,10 +58,10 @@ public class SdncServiceTopologyOperationTask extends AbstractSdncOperationTask updateProgress(execution, null, null, "50", "RequestBody build finished!"); RpcServiceTopologyOperationOutputEntity outputEntity; if (!isSend2SdncDirectly()) { - outputEntity = genericResourceApiClient.postServiceTopologyOperation - (HeaderUtil.DefaulAuth, inputEntity).execute().body(); - updateProgress(execution, null, null, "90", "sendRestrequestAndHandleResponse finished!"); - saveOutput(execution, outputEntity); + outputEntity = genericResourceApiClient.postServiceTopologyOperation(HeaderUtil.DefaulAuth, inputEntity) + .execute().body(); + updateProgress(execution, null, null, "90", "sendRestrequestAndHandleResponse finished!"); + saveOutput(execution, outputEntity); } else { send2SdncDirectly(HeaderUtil.DefaulAuth, inputEntity); } @@ -71,8 +69,8 @@ public class SdncServiceTopologyOperationTask extends AbstractSdncOperationTask } - private void send2SdncDirectly(String defaulAuth, - RpcServiceTopologyOperationInputEntity inputEntity) throws RouteException { + private void send2SdncDirectly(String defaulAuth, RpcServiceTopologyOperationInputEntity inputEntity) + throws RouteException { logger.info("SdncServiceTopologyOperationTask.send2SdncDirectly begin!"); String url = getSdncHost() + URL; HttpPost httpPost = new HttpPost(url); @@ -85,7 +83,8 @@ public class SdncServiceTopologyOperationTask extends AbstractSdncOperationTask logger.info("SdncServiceTopologyOperationTask.send2SdncDirectly end!"); } - private void saveOutput(DelegateExecution execution, RpcServiceTopologyOperationOutputEntity output) throws Exception { + private void saveOutput(DelegateExecution execution, RpcServiceTopologyOperationOutputEntity output) + throws Exception { logger.info("SdncServiceTopologyOperationTask.saveOutput begin!"); String responseCode = output.getOutput().getResponseCode(); if (!"200".equals(responseCode)) { diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/SdncUnderlayVpnOperationClient.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/SdncUnderlayVpnOperationClient.java index f54d6692d6..001d8fb6c0 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/SdncUnderlayVpnOperationClient.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/SdncUnderlayVpnOperationClient.java @@ -23,7 +23,6 @@ package org.onap.so.bpmn.infrastructure.workflow.serviceTask; import java.util.Map; - import org.apache.commons.lang3.StringUtils; import org.onap.msb.sdk.httpclient.RestServiceCreater; import org.onap.msb.sdk.httpclient.msb.MSBServiceClient; @@ -46,33 +45,32 @@ public class SdncUnderlayVpnOperationClient { private static Logger logger = LoggerFactory.getLogger(SdncUnderlayVpnOperationClient.class); - public boolean excute(String msbIp, - int msbPort, - Map<String, String> inputs, - String iServiceID, - String iOperationID, - String resourceTemplateUUID_i){ - ResourceOperationStatusId id = new ResourceOperationStatusId(iServiceID, iOperationID, resourceTemplateUUID_i); + public boolean excute(String msbIp, int msbPort, Map<String, String> inputs, String iServiceID, String iOperationID, + String resourceTemplateUUID_i) { + ResourceOperationStatusId id = new ResourceOperationStatusId(iServiceID, iOperationID, resourceTemplateUUID_i); GenericResourceApi genericResourceApiClient = getGenericResourceApiClient(msbIp, msbPort); updateProgress(id, RequestsDbConstant.Status.PROCESSING, null, "10", "execute begin!"); return sendRestrequestAndHandleResponse(id, inputs, genericResourceApiClient); } - public boolean sendRestrequestAndHandleResponse(ResourceOperationStatusId id, Map<String, String> inputs, GenericResourceApi genericResourceApiClient){ + public boolean sendRestrequestAndHandleResponse(ResourceOperationStatusId id, Map<String, String> inputs, + GenericResourceApi genericResourceApiClient) { updateProgress(id, null, null, "40", "sendRestrequestAndHandleResponse begin!"); NetworkRpcInputEntityBuilder builder = new NetworkRpcInputEntityBuilder(); RpcNetworkTopologyOperationInputEntity body = builder.build(null, inputs); updateProgress(id, null, null, "50", "RequestBody build finished!"); - //RpcNetworkTopologyOperationOutputEntity networkRpcOutputEntiy = null; + // RpcNetworkTopologyOperationOutputEntity networkRpcOutputEntiy = null; try { - genericResourceApiClient.postNetworkTopologyOperation(HeaderUtil.DefaulAuth ,body).execute().body(); + genericResourceApiClient.postNetworkTopologyOperation(HeaderUtil.DefaulAuth, body).execute().body(); } catch (Exception e) { logger.debug("Exception: ", e); - updateProgress(id, RequestsDbConstant.Status.ERROR, null, null, "sendRestrequestAndHandleResponse exception:" + e.getMessage()); + updateProgress(id, RequestsDbConstant.Status.ERROR, null, null, + "sendRestrequestAndHandleResponse exception:" + e.getMessage()); return false; } updateProgress(id, null, null, "90", "sendRestrequestAndHandleResponse finished!"); - updateProgress(id, RequestsDbConstant.Status.FINISHED, null, RequestsDbConstant.Progress.ONE_HUNDRED, "execute finished!"); + updateProgress(id, RequestsDbConstant.Status.FINISHED, null, RequestsDbConstant.Progress.ONE_HUNDRED, + "execute finished!"); return true; } @@ -88,13 +86,11 @@ public class SdncUnderlayVpnOperationClient { return restServiceCreater.createService(GenericResourceApi.class); } - public void updateProgress(ResourceOperationStatusId id, String status, - String errorCode, - String progress, - String statusDescription) { - - - ResourceOperationStatus resourceOperationStatus = new ResourceOperationStatus();//rosRepo.getOne(id); + public void updateProgress(ResourceOperationStatusId id, String status, String errorCode, String progress, + String statusDescription) { + + + ResourceOperationStatus resourceOperationStatus = new ResourceOperationStatus();// rosRepo.getOne(id); if (!StringUtils.isBlank(status)) { resourceOperationStatus.setStatus(status); } @@ -107,7 +103,7 @@ public class SdncUnderlayVpnOperationClient { if (!StringUtils.isBlank(statusDescription)) { resourceOperationStatus.setStatusDescription(statusDescription); } - //rosRepo.save(resourceOperationStatus); + // rosRepo.save(resourceOperationStatus); } private void saveOutput() { diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/SdncUnderlayVpnPreprocessTask.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/SdncUnderlayVpnPreprocessTask.java index 8bc9dce966..5b7f3bb432 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/SdncUnderlayVpnPreprocessTask.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/SdncUnderlayVpnPreprocessTask.java @@ -41,8 +41,13 @@ public class SdncUnderlayVpnPreprocessTask extends BaseTask { serviceId = StringUtils.isBlank(serviceId) ? (String) execution.getVariable("serviceInstanceId") : serviceId; String operationId = (String) execution.getVariable("operationId"); String resourceTemplateUUID = (String) execution.getVariable("resourceTemplateUUID"); - resourceTemplateUUID = StringUtils.isBlank(resourceTemplateUUID) ? (String) execution.getVariable("resourceTemplateId") : resourceTemplateUUID; - ResourceOperationStatus resourceOperationStatus = new ResourceOperationStatus();//rosRepo.getOne(new ResourceOperationStatusId(serviceId, operationId, resourceTemplateUUID)); + resourceTemplateUUID = + StringUtils.isBlank(resourceTemplateUUID) ? (String) execution.getVariable("resourceTemplateId") + : resourceTemplateUUID; + ResourceOperationStatus resourceOperationStatus = new ResourceOperationStatus();// rosRepo.getOne(new + // ResourceOperationStatusId(serviceId, + // operationId, + // resourceTemplateUUID)); return resourceOperationStatus.getOperType(); } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/client/GenericResourceApi.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/client/GenericResourceApi.java index a837782a2c..ca9269242c 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/client/GenericResourceApi.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/client/GenericResourceApi.java @@ -34,15 +34,15 @@ public interface GenericResourceApi { @POST("/restconf/operations/GENERIC-RESOURCE-API:network-topology-operation") Call<ResponseBody> postNetworkTopologyOperation(@Header("Authorization") String authorization, - @Body RequestBody input); + @Body RequestBody input); @POST("/restconf/operations/GENERIC-RESOURCE-API:network-topology-operation") - Call<RpcNetworkTopologyOperationOutputEntity> postNetworkTopologyOperation(@Header("Authorization") String authorization, - @Body RpcNetworkTopologyOperationInputEntity input); + Call<RpcNetworkTopologyOperationOutputEntity> postNetworkTopologyOperation( + @Header("Authorization") String authorization, @Body RpcNetworkTopologyOperationInputEntity input); @POST("/restconf/operations/GENERIC-RESOURCE-API:service-topology-operation") - Call<RpcServiceTopologyOperationOutputEntity> postServiceTopologyOperation(@Header("Authorization") String authorization, - @Body RpcServiceTopologyOperationInputEntity input); + Call<RpcServiceTopologyOperationOutputEntity> postServiceTopologyOperation( + @Header("Authorization") String authorization, @Body RpcServiceTopologyOperationInputEntity input); } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/client/HeaderUtil.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/client/HeaderUtil.java index 696be02809..3da5b0de70 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/client/HeaderUtil.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/client/HeaderUtil.java @@ -36,8 +36,7 @@ public class HeaderUtil { private static String base64Encode(String str) { String base64 = str; try { - base64 = Base64.getEncoder() - .encodeToString(str.getBytes("utf-8")); + base64 = Base64.getEncoder().encodeToString(str.getBytes("utf-8")); } catch (Exception ex) { } return base64; diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/client/builder/AbstractBuilder.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/client/builder/AbstractBuilder.java index 961b846ace..21b14c35f9 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/client/builder/AbstractBuilder.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/client/builder/AbstractBuilder.java @@ -24,7 +24,6 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.UUID; - import org.apache.commons.lang3.StringUtils; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.onap.so.bpmn.infrastructure.workflow.serviceTask.client.entity.OnapModelInformationEntity; @@ -35,205 +34,206 @@ import org.onap.so.requestsdb.RequestsDbConstant; public abstract class AbstractBuilder<I, O> { - public static final String OPERATION_TYPE = "operationType"; - public static final String RESOURCE_TYPE = "resourceType"; - - public enum RequestAction { - CREATE_NETWORK_INSTANCE(0, "CreateNetworkInstance"), - ACTIVATE_NETWORK_INSTANCE(1, "ActivateNetworkInstance"), - CREATE_SERVICE_INSTANCE(2, "CreateServiceInstance"), - DELETE_SERVICE_INSTANCE(3, "DeleteServiceInstance"), - DELETE_NETWORK_INSTANCE(4, "DeleteNetworkInstance"), - CREATE_VNF_INSTANCE(5, "CreateVnfInstance"), - ACTIVATE_VNF_INSTANCE(6, "ActivateVnfInstance"), - DELETE_VNF_INSTANCE(7, "DeleteVnfInstance"), - CREATE_VF_MODULE_INSTANCE(8, "CreateVfModuleInstance"), - ACTIVATE_VF_MODULE_INSTANCE(9, "ActivateVfModuleInstance"), - DELETE_VF_MODULE_INSTANCE(10, "DeleteVfModuleInstance"), - CREATE_CONTRAIL_ROUTE_INSTANCE(11, "CreateContrailRouteInstance"), - DELETE_CONTRAIL_ROUTE_INSTANCE(12, "DeleteContrailRouteInstance"), - CREATE_SECURITY_ZONE_INSTANCE(13, "CreateSecurityZoneInstance"), - DELETE_SECURITY_ZONE_INSTANCE(14, "DeleteSecurityZoneInstance"), - ACTIVATE_DCI_NETWORK_INSTANCE(15, "ActivateDCINetworkInstance"), - DEACTIVATE_DCI_NETWORK_INSTANCE(16, "DeActivateDCINetworkInstance"); - - String name; - int value; - - private RequestAction(int value, String name) { - this.value = value; - this.name = name; - } - - public String getName() { - return this.name; - } - - public int getIntValue() { - return this.value; - } - } - - public enum SvcAction { - RESERVE(0, "reserve"), - ASSIGN(1, "assign"), - ACTIVATE(2, "activate"), - DELETE(3, "delete"), - CHANGEASSIGN(4, "changeassign"), - CHANGEDELETE(5, "changedelete"), - ROLLBACK(6, "rollback"), - DEACTIVATE(7, "deactivate"), - UNASSIGN(8, "unassign"), - CREATE(9, "create"); - - String name; - int value; - - private SvcAction(int value, String name) { - this.value = value; - this.name = name; - } - - public String getName() { - return this.name; - } - - public int getIntValue() { - return this.value; - } - } - - protected String requestId = null; - - abstract O build(DelegateExecution execution, I input) throws Exception; - - protected String getRequestAction(DelegateExecution execution) { - String action = /*RequestInformation.*/RequestAction.CREATE_NETWORK_INSTANCE.getName(); - String operType = (String) execution.getVariable(OPERATION_TYPE); - String resourceType = (String)execution.getVariable(RESOURCE_TYPE); - if (!StringUtils.isBlank(operType)) { - if (RequestsDbConstant.OperationType.DELETE.equalsIgnoreCase(operType)) { - if (isOverlay(resourceType)) { - action = /*RequestInformation.*/RequestAction.DEACTIVATE_DCI_NETWORK_INSTANCE.getName(); - } else if (isUnderlay(resourceType)) { - action = /*RequestInformation.*/RequestAction.DELETE_NETWORK_INSTANCE.getName(); - } else { - action = /*RequestInformation.*/RequestAction.DELETE_SERVICE_INSTANCE.getName(); - } - } else if (RequestsDbConstant.OperationType.CREATE.equalsIgnoreCase(operType)) { - if (isOverlay(resourceType)) { - action = /*RequestInformation.*/RequestAction.ACTIVATE_DCI_NETWORK_INSTANCE.getName(); - } else if (isUnderlay(resourceType)) { - action = /*RequestInformation.*/RequestAction.CREATE_NETWORK_INSTANCE.getName(); - } else { - action = /*RequestInformation.*/RequestAction.CREATE_SERVICE_INSTANCE.getName(); - } - } - } - return action; - } - - private boolean isOverlay(String resourceType) { - return !StringUtils.isBlank(resourceType) && resourceType.toLowerCase().contains("overlay"); - } - - private boolean isUnderlay(String resourceType) { - return !StringUtils.isBlank(resourceType) && resourceType.toLowerCase().contains("underlay"); - } - - protected String getSvcAction(DelegateExecution execution) { - String action = /*SdncRequestHeader.*/SvcAction.CREATE.getName(); - String operType = (String) execution.getVariable(OPERATION_TYPE); - String resourceType = (String)execution.getVariable(RESOURCE_TYPE); - if (!StringUtils.isBlank(operType)) { - if (RequestsDbConstant.OperationType.DELETE.equalsIgnoreCase(operType)) { - if (isOverlay(resourceType)) { - action = /*SdncRequestHeader.*/SvcAction.DEACTIVATE.getName(); - } else if (isUnderlay(resourceType)) { - action = /*SdncRequestHeader.*/SvcAction.DELETE.getName(); - } else { - action = /*SdncRequestHeader.*/SvcAction.UNASSIGN.getName(); - } - } else if (RequestsDbConstant.OperationType.CREATE.equalsIgnoreCase(operType)) { - if (isOverlay(resourceType)) { - action = /*SdncRequestHeader.*/SvcAction.ACTIVATE.getName(); - } else if (isUnderlay(resourceType)) { - action = /*SdncRequestHeader.*/SvcAction.CREATE.getName(); - } else { - action = /*SdncRequestHeader.*/SvcAction.ASSIGN.getName(); - } - } - } - return action; - } - - protected synchronized String getRequestId(DelegateExecution execution) { - if (StringUtils.isBlank(requestId)) { - requestId = (String) execution.getVariable("msoRequestId"); - if (StringUtils.isBlank(requestId)) { - requestId = UUID.randomUUID().toString(); - } - } - return requestId; - } - - protected OnapModelInformationEntity getOnapServiceModelInformationEntity(DelegateExecution execution) { - OnapModelInformationEntity onapModelInformationEntity = new OnapModelInformationEntity(); - String modelInvariantUuid = (String) execution.getVariable("modelInvariantUuid"); - String modelVersion = (String) execution.getVariable("modelVersion"); - String modelUuid = (String) execution.getVariable("modelUuid"); - String modelName = (String) execution.getVariable("serviceModelName"); - onapModelInformationEntity.setModelInvariantUuid(modelInvariantUuid); - onapModelInformationEntity.setModelVersion(modelVersion); - onapModelInformationEntity.setModelUuid(modelUuid); - onapModelInformationEntity.setModelName(modelName); - return onapModelInformationEntity; - } - - protected OnapModelInformationEntity getOnapNetworkModelInformationEntity(DelegateExecution execution) { - OnapModelInformationEntity onapModelInformationEntity = new OnapModelInformationEntity(); - String modelInvariantUuid = (String) execution.getVariable("resourceInvariantUUID"); - String modelVersion = (String) execution.getVariable("modelVersion"); - String modelUuid = (String) execution.getVariable("resourceUUID"); - String modelName = (String) execution.getVariable(RESOURCE_TYPE); - onapModelInformationEntity.setModelInvariantUuid(modelInvariantUuid); - onapModelInformationEntity.setModelVersion(modelVersion); - onapModelInformationEntity.setModelUuid(modelUuid); - onapModelInformationEntity.setModelName(modelName); - return onapModelInformationEntity; + public static final String OPERATION_TYPE = "operationType"; + public static final String RESOURCE_TYPE = "resourceType"; + + public enum RequestAction { + CREATE_NETWORK_INSTANCE(0, "CreateNetworkInstance"), ACTIVATE_NETWORK_INSTANCE(1, + "ActivateNetworkInstance"), CREATE_SERVICE_INSTANCE(2, + "CreateServiceInstance"), DELETE_SERVICE_INSTANCE(3, + "DeleteServiceInstance"), DELETE_NETWORK_INSTANCE(4, + "DeleteNetworkInstance"), CREATE_VNF_INSTANCE(5, + "CreateVnfInstance"), ACTIVATE_VNF_INSTANCE(6, + "ActivateVnfInstance"), DELETE_VNF_INSTANCE(7, + "DeleteVnfInstance"), CREATE_VF_MODULE_INSTANCE(8, + "CreateVfModuleInstance"), ACTIVATE_VF_MODULE_INSTANCE( + 9, + "ActivateVfModuleInstance"), DELETE_VF_MODULE_INSTANCE( + 10, + "DeleteVfModuleInstance"), CREATE_CONTRAIL_ROUTE_INSTANCE( + 11, + "CreateContrailRouteInstance"), DELETE_CONTRAIL_ROUTE_INSTANCE( + 12, + "DeleteContrailRouteInstance"), CREATE_SECURITY_ZONE_INSTANCE( + 13, + "CreateSecurityZoneInstance"), DELETE_SECURITY_ZONE_INSTANCE( + 14, + "DeleteSecurityZoneInstance"), ACTIVATE_DCI_NETWORK_INSTANCE( + 15, + "ActivateDCINetworkInstance"), DEACTIVATE_DCI_NETWORK_INSTANCE( + 16, + "DeActivateDCINetworkInstance"); + + String name; + int value; + + private RequestAction(int value, String name) { + this.value = value; + this.name = name; + } + + public String getName() { + return this.name; + } + + public int getIntValue() { + return this.value; + } + } + + public enum SvcAction { + RESERVE(0, "reserve"), ASSIGN(1, "assign"), ACTIVATE(2, "activate"), DELETE(3, "delete"), CHANGEASSIGN(4, + "changeassign"), CHANGEDELETE(5, "changedelete"), ROLLBACK(6, + "rollback"), DEACTIVATE(7, "deactivate"), UNASSIGN(8, "unassign"), CREATE(9, "create"); + + String name; + int value; + + private SvcAction(int value, String name) { + this.value = value; + this.name = name; + } + + public String getName() { + return this.name; + } + + public int getIntValue() { + return this.value; + } + } + + protected String requestId = null; + + abstract O build(DelegateExecution execution, I input) throws Exception; + + protected String getRequestAction(DelegateExecution execution) { + String action = /* RequestInformation. */RequestAction.CREATE_NETWORK_INSTANCE.getName(); + String operType = (String) execution.getVariable(OPERATION_TYPE); + String resourceType = (String) execution.getVariable(RESOURCE_TYPE); + if (!StringUtils.isBlank(operType)) { + if (RequestsDbConstant.OperationType.DELETE.equalsIgnoreCase(operType)) { + if (isOverlay(resourceType)) { + action = /* RequestInformation. */RequestAction.DEACTIVATE_DCI_NETWORK_INSTANCE.getName(); + } else if (isUnderlay(resourceType)) { + action = /* RequestInformation. */RequestAction.DELETE_NETWORK_INSTANCE.getName(); + } else { + action = /* RequestInformation. */RequestAction.DELETE_SERVICE_INSTANCE.getName(); + } + } else if (RequestsDbConstant.OperationType.CREATE.equalsIgnoreCase(operType)) { + if (isOverlay(resourceType)) { + action = /* RequestInformation. */RequestAction.ACTIVATE_DCI_NETWORK_INSTANCE.getName(); + } else if (isUnderlay(resourceType)) { + action = /* RequestInformation. */RequestAction.CREATE_NETWORK_INSTANCE.getName(); + } else { + action = /* RequestInformation. */RequestAction.CREATE_SERVICE_INSTANCE.getName(); + } + } + } + return action; + } + + private boolean isOverlay(String resourceType) { + return !StringUtils.isBlank(resourceType) && resourceType.toLowerCase().contains("overlay"); + } + + private boolean isUnderlay(String resourceType) { + return !StringUtils.isBlank(resourceType) && resourceType.toLowerCase().contains("underlay"); + } + + protected String getSvcAction(DelegateExecution execution) { + String action = /* SdncRequestHeader. */SvcAction.CREATE.getName(); + String operType = (String) execution.getVariable(OPERATION_TYPE); + String resourceType = (String) execution.getVariable(RESOURCE_TYPE); + if (!StringUtils.isBlank(operType)) { + if (RequestsDbConstant.OperationType.DELETE.equalsIgnoreCase(operType)) { + if (isOverlay(resourceType)) { + action = /* SdncRequestHeader. */SvcAction.DEACTIVATE.getName(); + } else if (isUnderlay(resourceType)) { + action = /* SdncRequestHeader. */SvcAction.DELETE.getName(); + } else { + action = /* SdncRequestHeader. */SvcAction.UNASSIGN.getName(); + } + } else if (RequestsDbConstant.OperationType.CREATE.equalsIgnoreCase(operType)) { + if (isOverlay(resourceType)) { + action = /* SdncRequestHeader. */SvcAction.ACTIVATE.getName(); + } else if (isUnderlay(resourceType)) { + action = /* SdncRequestHeader. */SvcAction.CREATE.getName(); + } else { + action = /* SdncRequestHeader. */SvcAction.ASSIGN.getName(); + } + } + } + return action; + } + + protected synchronized String getRequestId(DelegateExecution execution) { + if (StringUtils.isBlank(requestId)) { + requestId = (String) execution.getVariable("msoRequestId"); + if (StringUtils.isBlank(requestId)) { + requestId = UUID.randomUUID().toString(); + } + } + return requestId; + } + + protected OnapModelInformationEntity getOnapServiceModelInformationEntity(DelegateExecution execution) { + OnapModelInformationEntity onapModelInformationEntity = new OnapModelInformationEntity(); + String modelInvariantUuid = (String) execution.getVariable("modelInvariantUuid"); + String modelVersion = (String) execution.getVariable("modelVersion"); + String modelUuid = (String) execution.getVariable("modelUuid"); + String modelName = (String) execution.getVariable("serviceModelName"); + onapModelInformationEntity.setModelInvariantUuid(modelInvariantUuid); + onapModelInformationEntity.setModelVersion(modelVersion); + onapModelInformationEntity.setModelUuid(modelUuid); + onapModelInformationEntity.setModelName(modelName); + return onapModelInformationEntity; + } + + protected OnapModelInformationEntity getOnapNetworkModelInformationEntity(DelegateExecution execution) { + OnapModelInformationEntity onapModelInformationEntity = new OnapModelInformationEntity(); + String modelInvariantUuid = (String) execution.getVariable("resourceInvariantUUID"); + String modelVersion = (String) execution.getVariable("modelVersion"); + String modelUuid = (String) execution.getVariable("resourceUUID"); + String modelName = (String) execution.getVariable(RESOURCE_TYPE); + onapModelInformationEntity.setModelInvariantUuid(modelInvariantUuid); + onapModelInformationEntity.setModelVersion(modelVersion); + onapModelInformationEntity.setModelUuid(modelUuid); + onapModelInformationEntity.setModelName(modelName); + return onapModelInformationEntity; } - protected List<ParamEntity> getParamEntities(Map<String, String> inputs) { - List<ParamEntity> paramEntityList = new ArrayList<>(); - if (inputs != null && !inputs.isEmpty()) { - inputs.keySet().forEach(key -> { - ParamEntity paramEntity = new ParamEntity(); - paramEntity.setName(key); - paramEntity.setValue(inputs.get(key)); - paramEntityList.add(paramEntity); - }); - } - return paramEntityList; - } - - protected RequestInformationEntity getRequestInformationEntity(DelegateExecution execution) { - RequestInformationEntity requestInformationEntity = new RequestInformationEntity(); - requestInformationEntity.setRequestId(getRequestId(execution)); - requestInformationEntity.setRequestAction(getRequestAction(execution)); - return requestInformationEntity; - } - - protected ServiceInformationEntity getServiceInformationEntity(DelegateExecution execution) { - ServiceInformationEntity serviceInformationEntity = new ServiceInformationEntity(); - serviceInformationEntity.setServiceId((String) execution.getVariable("serviceInstanceId")); - serviceInformationEntity.setSubscriptionServiceType((String) execution.getVariable("serviceType")); - serviceInformationEntity.setOnapModelInformation(getOnapServiceModelInformationEntity(execution)); - serviceInformationEntity.setServiceInstanceId((String) execution.getVariable("serviceInstanceId")); - serviceInformationEntity.setGlobalCustomerId((String) execution.getVariable("globalSubscriberId")); - return serviceInformationEntity; - } - - protected String getServiceInstanceName(DelegateExecution execution) { - return (String) execution.getVariable("serviceInstanceName"); - } + protected List<ParamEntity> getParamEntities(Map<String, String> inputs) { + List<ParamEntity> paramEntityList = new ArrayList<>(); + if (inputs != null && !inputs.isEmpty()) { + inputs.keySet().forEach(key -> { + ParamEntity paramEntity = new ParamEntity(); + paramEntity.setName(key); + paramEntity.setValue(inputs.get(key)); + paramEntityList.add(paramEntity); + }); + } + return paramEntityList; + } + + protected RequestInformationEntity getRequestInformationEntity(DelegateExecution execution) { + RequestInformationEntity requestInformationEntity = new RequestInformationEntity(); + requestInformationEntity.setRequestId(getRequestId(execution)); + requestInformationEntity.setRequestAction(getRequestAction(execution)); + return requestInformationEntity; + } + + protected ServiceInformationEntity getServiceInformationEntity(DelegateExecution execution) { + ServiceInformationEntity serviceInformationEntity = new ServiceInformationEntity(); + serviceInformationEntity.setServiceId((String) execution.getVariable("serviceInstanceId")); + serviceInformationEntity.setSubscriptionServiceType((String) execution.getVariable("serviceType")); + serviceInformationEntity.setOnapModelInformation(getOnapServiceModelInformationEntity(execution)); + serviceInformationEntity.setServiceInstanceId((String) execution.getVariable("serviceInstanceId")); + serviceInformationEntity.setGlobalCustomerId((String) execution.getVariable("globalSubscriberId")); + return serviceInformationEntity; + } + + protected String getServiceInstanceName(DelegateExecution execution) { + return (String) execution.getVariable("serviceInstanceName"); + } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/client/builder/NetworkRpcInputEntityBuilder.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/client/builder/NetworkRpcInputEntityBuilder.java index 547df2bb3a..4a2194ed3d 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/client/builder/NetworkRpcInputEntityBuilder.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/client/builder/NetworkRpcInputEntityBuilder.java @@ -22,7 +22,6 @@ package org.onap.so.bpmn.infrastructure.workflow.serviceTask.client.builder; import java.util.List; import java.util.Map; - import org.camunda.bpm.engine.delegate.DelegateExecution; import org.onap.so.bpmn.infrastructure.workflow.serviceTask.client.entity.NetworkInformationEntity; import org.onap.so.bpmn.infrastructure.workflow.serviceTask.client.entity.NetworkInputParametersEntity; @@ -35,44 +34,53 @@ import org.onap.so.bpmn.infrastructure.workflow.serviceTask.client.entity.RpcNet import org.onap.so.bpmn.infrastructure.workflow.serviceTask.client.entity.SdncRequestHeaderEntity; import org.onap.so.bpmn.infrastructure.workflow.serviceTask.client.entity.ServiceInformationEntity; -public class NetworkRpcInputEntityBuilder extends AbstractBuilder<Map<String, String>, RpcNetworkTopologyOperationInputEntity> { +public class NetworkRpcInputEntityBuilder + extends AbstractBuilder<Map<String, String>, RpcNetworkTopologyOperationInputEntity> { @Override public RpcNetworkTopologyOperationInputEntity build(DelegateExecution execution, Map<String, String> inputs) { - RpcNetworkTopologyOperationInputEntity rpcNetworkTopologyOperationInputEntity = new RpcNetworkTopologyOperationInputEntity(); - NetworkTopologyOperationInputEntity networkTopologyOperationInputEntity = getNetworkTopologyOperationInputEntity(execution, inputs); + RpcNetworkTopologyOperationInputEntity rpcNetworkTopologyOperationInputEntity = + new RpcNetworkTopologyOperationInputEntity(); + NetworkTopologyOperationInputEntity networkTopologyOperationInputEntity = + getNetworkTopologyOperationInputEntity(execution, inputs); rpcNetworkTopologyOperationInputEntity.setInput(networkTopologyOperationInputEntity); return rpcNetworkTopologyOperationInputEntity; } - private void loadNetwrokRequestInputEntity(Map<String, String> inputs, NetworkTopologyOperationInputEntity networkTopologyOperationInputEntity) { + private void loadNetwrokRequestInputEntity(Map<String, String> inputs, + NetworkTopologyOperationInputEntity networkTopologyOperationInputEntity) { NetworkRequestInputEntity networkRequestInputEntity = new NetworkRequestInputEntity(); - NetworkInputParametersEntity networkInputParametersEntity = new NetworkInputParametersEntity(); + NetworkInputParametersEntity networkInputParametersEntity = new NetworkInputParametersEntity(); List<ParamEntity> paramEntityList = getParamEntities(inputs); networkInputParametersEntity.setParamList(paramEntityList); - networkRequestInputEntity.setNetworkInputPaarameters(networkInputParametersEntity); + networkRequestInputEntity.setNetworkInputPaarameters(networkInputParametersEntity); networkTopologyOperationInputEntity.setNetworkRequestInput(networkRequestInputEntity); } - private void loadRequestInformationEntity(NetworkTopologyOperationInputEntity networkTopologyOperationInputEntity, DelegateExecution execution) { + private void loadRequestInformationEntity(NetworkTopologyOperationInputEntity networkTopologyOperationInputEntity, + DelegateExecution execution) { RequestInformationEntity requestInformationEntity = getRequestInformationEntity(execution); networkTopologyOperationInputEntity.setRequestInformation(requestInformationEntity); } - private void loadSdncRequestHeaderEntity(NetworkTopologyOperationInputEntity networkTopologyOperationInputEntity, DelegateExecution execution) { + private void loadSdncRequestHeaderEntity(NetworkTopologyOperationInputEntity networkTopologyOperationInputEntity, + DelegateExecution execution) { SdncRequestHeaderEntity sdncRequestHeaderEntity = new SdncRequestHeaderEntity(); sdncRequestHeaderEntity.setSvcRequestId(getRequestId(execution)); sdncRequestHeaderEntity.setSvcAction(getSvcAction(execution)); networkTopologyOperationInputEntity.setSdncRequestHeader(sdncRequestHeaderEntity); } - private void loadServiceInformation(NetworkTopologyOperationInputEntity networkTopologyOperationInputEntity, DelegateExecution execution) { + private void loadServiceInformation(NetworkTopologyOperationInputEntity networkTopologyOperationInputEntity, + DelegateExecution execution) { ServiceInformationEntity serviceInformationEntity = getServiceInformationEntity(execution); networkTopologyOperationInputEntity.setServiceInformation(serviceInformationEntity); } - private NetworkTopologyOperationInputEntity getNetworkTopologyOperationInputEntity(DelegateExecution execution, Map<String, String> inputs) { - NetworkTopologyOperationInputEntity networkTopologyOperationInputEntity = new NetworkTopologyOperationInputEntity(); + private NetworkTopologyOperationInputEntity getNetworkTopologyOperationInputEntity(DelegateExecution execution, + Map<String, String> inputs) { + NetworkTopologyOperationInputEntity networkTopologyOperationInputEntity = + new NetworkTopologyOperationInputEntity(); loadSdncRequestHeaderEntity(networkTopologyOperationInputEntity, execution); loadRequestInformationEntity(networkTopologyOperationInputEntity, execution); loadServiceInformation(networkTopologyOperationInputEntity, execution); @@ -81,7 +89,8 @@ public class NetworkRpcInputEntityBuilder extends AbstractBuilder<Map<String, St return networkTopologyOperationInputEntity; } - private void loadNetworkInformationEntity(DelegateExecution execution, NetworkTopologyOperationInputEntity networkTopologyOperationInputEntity) { + private void loadNetworkInformationEntity(DelegateExecution execution, + NetworkTopologyOperationInputEntity networkTopologyOperationInputEntity) { NetworkInformationEntity networkInformationEntity = new NetworkInformationEntity(); OnapModelInformationEntity onapModelInformationEntity = getOnapNetworkModelInformationEntity(execution); networkInformationEntity.setOnapModelInformation(onapModelInformationEntity); diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/client/builder/ServiceRpcInputEntityBuilder.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/client/builder/ServiceRpcInputEntityBuilder.java index 466652edff..944802372b 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/client/builder/ServiceRpcInputEntityBuilder.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/client/builder/ServiceRpcInputEntityBuilder.java @@ -21,7 +21,6 @@ package org.onap.so.bpmn.infrastructure.workflow.serviceTask.client.builder; import java.util.Map; - import org.camunda.bpm.engine.delegate.DelegateExecution; import org.onap.so.bpmn.infrastructure.workflow.serviceTask.client.entity.RequestInformationEntity; import org.onap.so.bpmn.infrastructure.workflow.serviceTask.client.entity.RpcServiceTopologyOperationInputEntity; @@ -30,20 +29,26 @@ import org.onap.so.bpmn.infrastructure.workflow.serviceTask.client.entity.Servic import org.onap.so.bpmn.infrastructure.workflow.serviceTask.client.entity.ServiceRequestInputEntity; import org.onap.so.bpmn.infrastructure.workflow.serviceTask.client.entity.ServiceTopologyOperationInputEntity; -public class ServiceRpcInputEntityBuilder extends AbstractBuilder<Map<String, String>, RpcServiceTopologyOperationInputEntity> { +public class ServiceRpcInputEntityBuilder + extends AbstractBuilder<Map<String, String>, RpcServiceTopologyOperationInputEntity> { @Override - public RpcServiceTopologyOperationInputEntity build(DelegateExecution execution, Map<String, String> inputs) throws Exception { - RpcServiceTopologyOperationInputEntity rpcServiceTopologyOperationInputEntity = new RpcServiceTopologyOperationInputEntity(); - ServiceTopologyOperationInputEntity serviceTopologyOperationInputEntity = new ServiceTopologyOperationInputEntity(); + public RpcServiceTopologyOperationInputEntity build(DelegateExecution execution, Map<String, String> inputs) + throws Exception { + RpcServiceTopologyOperationInputEntity rpcServiceTopologyOperationInputEntity = + new RpcServiceTopologyOperationInputEntity(); + ServiceTopologyOperationInputEntity serviceTopologyOperationInputEntity = + new ServiceTopologyOperationInputEntity(); loadSdncRequestHeaderEntity(serviceTopologyOperationInputEntity, execution); loadRequestInformationEntity(serviceTopologyOperationInputEntity, execution); loadServiceInformation(serviceTopologyOperationInputEntity, execution); loadServiceRequestInputEntity(serviceTopologyOperationInputEntity, execution); - rpcServiceTopologyOperationInputEntity.setServiceTopologyOperationInputEntity(serviceTopologyOperationInputEntity); + rpcServiceTopologyOperationInputEntity + .setServiceTopologyOperationInputEntity(serviceTopologyOperationInputEntity); return rpcServiceTopologyOperationInputEntity; } - private void loadServiceRequestInputEntity(ServiceTopologyOperationInputEntity serviceTopologyOperationInputEntity, DelegateExecution execution) { + private void loadServiceRequestInputEntity(ServiceTopologyOperationInputEntity serviceTopologyOperationInputEntity, + DelegateExecution execution) { ServiceRequestInputEntity serviceRequestInputEntity = getServiceRequestInputEntity(execution); serviceTopologyOperationInputEntity.setServiceRequestInput(serviceRequestInputEntity); } @@ -54,17 +59,20 @@ public class ServiceRpcInputEntityBuilder extends AbstractBuilder<Map<String, St return serviceRequestInputEntity; } - private void loadServiceInformation(ServiceTopologyOperationInputEntity serviceTopologyOperationInputEntity, DelegateExecution execution) { + private void loadServiceInformation(ServiceTopologyOperationInputEntity serviceTopologyOperationInputEntity, + DelegateExecution execution) { ServiceInformationEntity serviceInformationEntity = getServiceInformationEntity(execution); serviceTopologyOperationInputEntity.setServiceInformation(serviceInformationEntity); } - private void loadRequestInformationEntity(ServiceTopologyOperationInputEntity serviceTopologyOperationInputEntity, DelegateExecution execution) { + private void loadRequestInformationEntity(ServiceTopologyOperationInputEntity serviceTopologyOperationInputEntity, + DelegateExecution execution) { RequestInformationEntity requestInformationEntity = getRequestInformationEntity(execution); serviceTopologyOperationInputEntity.setRequestInformation(requestInformationEntity); } - private void loadSdncRequestHeaderEntity(ServiceTopologyOperationInputEntity serviceTopologyOperationInputEntity, DelegateExecution execution) { + private void loadSdncRequestHeaderEntity(ServiceTopologyOperationInputEntity serviceTopologyOperationInputEntity, + DelegateExecution execution) { SdncRequestHeaderEntity sdncRequestHeaderEntity = new SdncRequestHeaderEntity(); sdncRequestHeaderEntity.setSvcRequestId(getRequestId(execution)); sdncRequestHeaderEntity.setSvcAction(getSvcAction(execution)); diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/client/entity/NetworkInputParametersEntity.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/client/entity/NetworkInputParametersEntity.java index 0863917f21..847aa72469 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/client/entity/NetworkInputParametersEntity.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/client/entity/NetworkInputParametersEntity.java @@ -21,13 +21,12 @@ package org.onap.so.bpmn.infrastructure.workflow.serviceTask.client.entity; import com.fasterxml.jackson.annotation.JsonProperty; - import java.util.List; public class NetworkInputParametersEntity { - @JsonProperty("GENERIC-RESOURCE-API:param") + @JsonProperty("GENERIC-RESOURCE-API:param") private List<ParamEntity> paramList; - + public List<ParamEntity> getParamList() { return paramList; } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/client/entity/RequestInformationEntity.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/client/entity/RequestInformationEntity.java index af448942cc..238a4f32c0 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/client/entity/RequestInformationEntity.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/client/entity/RequestInformationEntity.java @@ -23,7 +23,7 @@ package org.onap.so.bpmn.infrastructure.workflow.serviceTask.client.entity; import com.fasterxml.jackson.annotation.JsonProperty; public class RequestInformationEntity { - @JsonProperty("GENERIC-RESOURCE-API:request-id") + @JsonProperty("GENERIC-RESOURCE-API:request-id") private String requestId; @JsonProperty("GENERIC-RESOURCE-API:request-action") @@ -40,7 +40,7 @@ public class RequestInformationEntity { @JsonProperty("GENERIC-RESOURCE-API:order-version") private String orerVersion; - + public String getRequestId() { return requestId; } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/client/entity/RpcNetworkTopologyOperationInputEntity.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/client/entity/RpcNetworkTopologyOperationInputEntity.java index 4e58a61750..76494f5585 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/client/entity/RpcNetworkTopologyOperationInputEntity.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/client/entity/RpcNetworkTopologyOperationInputEntity.java @@ -23,9 +23,9 @@ package org.onap.so.bpmn.infrastructure.workflow.serviceTask.client.entity; import com.fasterxml.jackson.annotation.JsonProperty; public class RpcNetworkTopologyOperationInputEntity { - @JsonProperty("GENERIC-RESOURCE-API:input") + @JsonProperty("GENERIC-RESOURCE-API:input") private NetworkTopologyOperationInputEntity input = null; - + public NetworkTopologyOperationInputEntity getInput() { return input; } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/client/entity/RpcNetworkTopologyOperationOutputEntity.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/client/entity/RpcNetworkTopologyOperationOutputEntity.java index 915a8a5e39..c93b3f2ad9 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/client/entity/RpcNetworkTopologyOperationOutputEntity.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/client/entity/RpcNetworkTopologyOperationOutputEntity.java @@ -23,9 +23,9 @@ package org.onap.so.bpmn.infrastructure.workflow.serviceTask.client.entity; import com.fasterxml.jackson.annotation.JsonProperty; public class RpcNetworkTopologyOperationOutputEntity { - @JsonProperty("GENERIC-RESOURCE-API:output") + @JsonProperty("GENERIC-RESOURCE-API:output") private NetworkTopologyOperationOutputEntity output; - + public NetworkTopologyOperationOutputEntity getOutput() { return output; } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/client/entity/RpcServiceTopologyOperationInputEntity.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/client/entity/RpcServiceTopologyOperationInputEntity.java index 145759e190..dbca00ae24 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/client/entity/RpcServiceTopologyOperationInputEntity.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/client/entity/RpcServiceTopologyOperationInputEntity.java @@ -23,14 +23,15 @@ package org.onap.so.bpmn.infrastructure.workflow.serviceTask.client.entity; import com.fasterxml.jackson.annotation.JsonProperty; public class RpcServiceTopologyOperationInputEntity { - @JsonProperty("GENERIC-RESOURCE-API:input") + @JsonProperty("GENERIC-RESOURCE-API:input") private ServiceTopologyOperationInputEntity serviceTopologyOperationInputEntity; - + public ServiceTopologyOperationInputEntity getServiceTopologyOperationInputEntity() { return serviceTopologyOperationInputEntity; } - public void setServiceTopologyOperationInputEntity(ServiceTopologyOperationInputEntity serviceTopologyOperationInputEntity) { + public void setServiceTopologyOperationInputEntity( + ServiceTopologyOperationInputEntity serviceTopologyOperationInputEntity) { this.serviceTopologyOperationInputEntity = serviceTopologyOperationInputEntity; } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/client/entity/ServiceInputParametersEntity.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/client/entity/ServiceInputParametersEntity.java index c1ba7dc614..5c199bd413 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/client/entity/ServiceInputParametersEntity.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/client/entity/ServiceInputParametersEntity.java @@ -21,13 +21,12 @@ package org.onap.so.bpmn.infrastructure.workflow.serviceTask.client.entity; import com.fasterxml.jackson.annotation.JsonProperty; - import java.util.List; public class ServiceInputParametersEntity { - @JsonProperty("GENERIC-RESOURCE-API:param") + @JsonProperty("GENERIC-RESOURCE-API:param") private List<ParamEntity> paramList; - + public List<ParamEntity> getParamList() { return paramList; } |