From 18c1c6853450e0aa1383f42bf76cb85578260c7f Mon Sep 17 00:00:00 2001 From: c00149107 Date: Tue, 16 Jan 2018 11:30:24 +0800 Subject: Add Generic Workflow for E2E ServiceInstance Add Generic Workflow for E2E ServiceInstance Change-Id: I078d7b74b16c670927ca4aebba2fbe4aa1c0d542 Issue-ID: SO-379 Signed-off-by: c00149107 --- .../scripts/DoCreateE2EServiceInstanceV2.groovy | 1082 ++++++++++++++++++ .../DoCustomDeleteE2EServiceInstanceV2.groovy | 1187 ++++++++++++++++++++ .../subprocess/DoCreateE2EServiceInstanceV2.bpmn | 1051 +++++++++++++++++ .../DoCustomDeleteE2EServiceInstanceV2.bpmn | 956 ++++++++++++++++ 4 files changed, 4276 insertions(+) create mode 100644 bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateE2EServiceInstanceV2.groovy create mode 100644 bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstanceV2.groovy create mode 100644 bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateE2EServiceInstanceV2.bpmn create mode 100644 bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCustomDeleteE2EServiceInstanceV2.bpmn (limited to 'bpmn') diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateE2EServiceInstanceV2.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateE2EServiceInstanceV2.groovy new file mode 100644 index 0000000000..cc34b03c64 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateE2EServiceInstanceV2.groovy @@ -0,0 +1,1082 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. + * ================================================================================ + * 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.openecomp.mso.bpmn.infrastructure.scripts; + +import static org.apache.commons.lang3.StringUtils.*; +import groovy.xml.XmlUtil +import groovy.json.* + +import org.openecomp.mso.bpmn.core.domain.ServiceDecomposition +import org.openecomp.mso.bpmn.core.domain.ServiceInstance +import org.openecomp.mso.bpmn.core.domain.ModelInfo +import org.openecomp.mso.bpmn.core.json.JsonUtils +import org.openecomp.mso.bpmn.common.scripts.AaiUtil +import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil +import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils +import org.openecomp.mso.bpmn.core.RollbackData +import org.openecomp.mso.bpmn.core.WorkflowException +import org.openecomp.mso.rest.APIResponse; +import org.openecomp.mso.rest.RESTClient +import org.openecomp.mso.rest.RESTConfig + +import java.util.UUID; + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.runtime.Execution +import org.json.JSONObject; +import org.json.JSONArray; +import org.apache.commons.lang3.* +import org.apache.commons.codec.binary.Base64; +import org.springframework.web.util.UriUtils; + +/** + * This groovy class supports the DoCreateServiceInstance.bpmn process. + * + * Inputs: + * @param - msoRequestId + * @param - globalSubscriberId + * @param - subscriptionServiceType + * @param - serviceInstanceId + * @param - serviceInstanceName - O + * @param - serviceModelInfo + * @param - productFamilyId + * @param - disableRollback + * @param - failExists - TODO + * @param - serviceInputParams (should contain aic_zone for serviceTypes TRANSPORT,ATM) + * @param - sdncVersion ("1610") + * @param - serviceDecomposition - Decomposition for R1710 + * (if macro provides serviceDecompsition then serviceModelInfo, serviceInstanceId & serviceInstanceName will be ignored) + * + * Outputs: + * @param - rollbackData (localRB->null) + * @param - rolledBack (no localRB->null, localRB F->false, localRB S->true) + * @param - WorkflowException + * @param - serviceInstanceName - (GET from AAI if null in input) + * + */ +public class DoCreateE2EServiceInstanceV2 extends AbstractServiceTaskProcessor { + + String Prefix="DCRESI_" + private static final String DebugFlag = "isDebugEnabled" + + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + + public void preProcessRequest (Execution execution) { + //only for dug + execution.setVariable("isDebugLogEnabled","true") + execution.setVariable("unit_test", "true") + execution.setVariable("skipVFC", "true") + + def method = getClass().getSimpleName() + '.preProcessRequest(' +'execution=' + execution.getId() +')' + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + utils.log("INFO","Entered " + method, isDebugEnabled) + String msg = "" + utils.log("INFO"," ***** Enter DoCreateE2EServiceInstanceV2 preProcessRequest *****", isDebugEnabled) + + utils.log("INFO"," unit test : " + execution.getVariable("unit_test"), isDebugEnabled) + + try { + execution.setVariable("prefix", Prefix) + //Inputs + //requestDetails.subscriberInfo. for AAI GET & PUT & SDNC assignToplology + String globalSubscriberId = execution.getVariable("globalSubscriberId") //globalCustomerId + utils.log("INFO"," ***** globalSubscriberId *****" + globalSubscriberId, isDebugEnabled) + + //requestDetails.requestParameters. for AAI PUT & SDNC assignTopology + String serviceType = execution.getVariable("serviceType") + utils.log("INFO"," ***** serviceType *****" + serviceType, isDebugEnabled) + + //requestDetails.requestParameters. for SDNC assignTopology + String productFamilyId = execution.getVariable("productFamilyId") //AAI productFamilyId + + if (isBlank(globalSubscriberId)) { + msg = "Input globalSubscriberId is null" + utils.log("INFO", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + + if (isBlank(serviceType)) { + msg = "Input serviceType is null" + utils.log("INFO", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + + if (productFamilyId == null) { + execution.setVariable("productFamilyId", "") + } + + String sdncCallbackUrl = execution.getVariable('URN_mso_workflow_sdncadapter_callback') + if (isBlank(sdncCallbackUrl)) { + msg = "URN_mso_workflow_sdncadapter_callback is null" + utils.log("INFO", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + execution.setVariable("sdncCallbackUrl", sdncCallbackUrl) + utils.log("INFO","SDNC Callback URL: " + sdncCallbackUrl, isDebugEnabled) + + //requestDetails.modelInfo.for AAI PUT servieInstanceData + //requestDetails.requestInfo. for AAI GET/PUT serviceInstanceData + String serviceInstanceName = execution.getVariable("serviceInstanceName") + String serviceInstanceId = execution.getVariable("serviceInstanceId") + String uuiRequest = execution.getVariable("uuiRequest") + utils.log("INFO","uuiRequest: " + uuiRequest, isDebugEnabled) + + String modelInvariantUuid = jsonUtil.getJsonValue(uuiRequest, "service.serviceDefId") + utils.log("INFO","modelInvariantUuid: " + modelInvariantUuid, isDebugEnabled) + + String modelUuid = jsonUtil.getJsonValue(uuiRequest, "service.templateId") + utils.log("INFO","modelUuid: " + modelUuid, isDebugEnabled) + + String serviceModelName = jsonUtil.getJsonValue(uuiRequest, "service.parameters.templateName") + utils.log("INFO","serviceModelName: " + serviceModelName, isDebugEnabled) + execution.setVariable("serviceModelName", serviceModelName) + + //aai serviceType and Role can be setted as fixed value now. + String aaiServiceType = serviceType + String aaiServiceRole = serviceType+"Role" + + execution.setVariable("modelInvariantUuid", modelInvariantUuid) + execution.setVariable("modelUuid", modelUuid) + + //AAI PUT + String oStatus = execution.getVariable("initialStatus") ?: "" + utils.log("INFO","oStatus: " + oStatus, isDebugEnabled) + if ("TRANSPORT".equalsIgnoreCase(serviceType)) + { + oStatus = "Created" + } + + + + String statusLine = isBlank(oStatus) ? "" : "${oStatus}" + utils.log("INFO","statusLine: " + statusLine, isDebugEnabled) + AaiUtil aaiUriUtil = new AaiUtil(this) + utils.log("INFO","start create aai uri: " + aaiUriUtil, isDebugEnabled) + String aai_uri = aaiUriUtil.getBusinessCustomerUri(execution) + utils.log("INFO","aai_uri: " + aai_uri, isDebugEnabled) + String namespace = aaiUriUtil.getNamespaceFromUri(aai_uri) + utils.log("INFO","namespace: " + namespace, isDebugEnabled) + /* + String serviceInstanceData = + """ + ${serviceInstanceId} + ${serviceInstanceName} + ${aaiServiceType} + ${aaiServiceRole} + ${statusLine} + ${modelInvariantUuid} + ${modelUuid} + """.trim() + */ + //begin only for test + String serviceInstanceData = + """ + ${serviceInstanceId} + ${serviceInstanceName} + ${aaiServiceType} + ${aaiServiceRole} + ${statusLine} + """.trim() + //end only for test + execution.setVariable("serviceInstanceData", serviceInstanceData) + utils.log("INFO","serviceInstanceData: " + serviceInstanceData, isDebugEnabled) + utils.logAudit(serviceInstanceData) + utils.log("INFO", " aai_uri " + aai_uri + " namespace:" + namespace, isDebugEnabled) + utils.log("INFO", " 'payload' to create Service Instance in AAI - " + "\n" + serviceInstanceData, isDebugEnabled) + + execution.setVariable("serviceSDNCCreate", "false") + execution.setVariable("operationStatus", "Waiting deploy resource...") + + } catch (BpmnError e) { + throw e; + } catch (Exception ex){ + msg = "Exception in preProcessRequest " + ex.getMessage() + utils.log("INFO", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + utils.log("INFO", "Exited " + method, isDebugEnabled) + } + + public void postProcessAAIGET(Execution execution) { + def method = getClass().getSimpleName() + '.postProcessAAIGET(' +'execution=' + execution.getId() +')' + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + utils.log("INFO","Entered " + method, isDebugEnabled) + utils.log("INFO"," ***** Enter DoCreateE2EServiceInstanceV2 postProcessAAIGET ***** ", isDebugEnabled) + String msg = "" + + try { + String serviceInstanceName = execution.getVariable("serviceInstanceName") + boolean succInAAI = execution.getVariable("GENGS_SuccessIndicator") + if(succInAAI != true){ + utils.log("INFO","Error getting Service-instance from AAI", + serviceInstanceName, isDebugEnabled) + WorkflowException workflowException = execution.getVariable("WorkflowException") + utils.logAudit("workflowException: " + workflowException) + if(workflowException != null){ + exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage()) + } + else + { + msg = "Failure in postProcessAAIGET GENGS_SuccessIndicator:" + succInAAI + utils.log("INFO", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg) + } + } + else + { + boolean foundInAAI = execution.getVariable("GENGS_FoundIndicator") + if(foundInAAI == true){ + utils.log("INFO","Found Service-instance in AAI", isDebugEnabled) + msg = "ServiceInstance already exists in AAI:" + serviceInstanceName + utils.log("INFO", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg) + } + } + } catch (BpmnError e) { + throw e; + } catch (Exception ex) { + msg = "Exception in DoCreateServiceInstance.postProcessAAIGET. " + ex.getMessage() + utils.log("INFO", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + utils.log("INFO", "Exited " + method, isDebugEnabled) + } + + public void postProcessAAIPUT(Execution execution) { + def method = getClass().getSimpleName() + '.postProcessAAIPUT(' +'execution=' + execution.getId() +')' + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + utils.log("INFO","Entered " + method, isDebugEnabled) + utils.log("INFO"," ***** Enter DoCreateE2EServiceInstanceV2 postProcessAAIPUT ***** ", isDebugEnabled) + String msg = "" + try { + String serviceInstanceId = execution.getVariable("serviceInstanceId") + boolean succInAAI = execution.getVariable("GENPS_SuccessIndicator") + if(succInAAI != true){ + utils.log("INFO","Error putting Service-instance in AAI", + serviceInstanceId, isDebugEnabled) + WorkflowException workflowException = execution.getVariable("WorkflowException") + utils.logAudit("workflowException: " + workflowException) + if(workflowException != null){ + exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage()) + } + } + else + { + //start rollback set up + RollbackData rollbackData = new RollbackData() + def disableRollback = execution.getVariable("disableRollback") + rollbackData.put("SERVICEINSTANCE", "disableRollback", disableRollback.toString()) + rollbackData.put("SERVICEINSTANCE", "rollbackAAI", "true") + rollbackData.put("SERVICEINSTANCE", "serviceInstanceId", serviceInstanceId) + rollbackData.put("SERVICEINSTANCE", "subscriptionServiceType", execution.getVariable("subscriptionServiceType")) + rollbackData.put("SERVICEINSTANCE", "globalSubscriberId", execution.getVariable("globalSubscriberId")) + execution.setVariable("rollbackData", rollbackData) + } + + } catch (BpmnError e) { + throw e; + } catch (Exception ex) { + msg = "Exception in DoCreateServiceInstance.postProcessAAIDEL. " + ex.getMessage() + utils.log("INFO", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + utils.log("INFO", "Exited " + method, isDebugEnabled) + } + + public void postProcessAAIGET2(Execution execution) { + def method = getClass().getSimpleName() + '.postProcessAAIGET2(' +'execution=' + execution.getId() +')' + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + utils.log("INFO","Entered " + method, isDebugEnabled) + utils.log("INFO"," ***** Enter DoCreateE2EServiceInstanceV2 postProcessAAIGET2 ***** ", isDebugEnabled) + String msg = "" + + try { + String serviceInstanceName = execution.getVariable("serviceInstanceName") + boolean succInAAI = execution.getVariable("GENGS_SuccessIndicator") + if(succInAAI != true){ + utils.log("INFO","Error getting Service-instance from AAI in postProcessAAIGET2", + serviceInstanceName, isDebugEnabled) + WorkflowException workflowException = execution.getVariable("WorkflowException") + utils.logAudit("workflowException: " + workflowException) + if(workflowException != null){ + exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage()) + } + else + { + msg = "Failure in postProcessAAIGET2 GENGS_SuccessIndicator:" + succInAAI + utils.log("INFO", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg) + } + } + else + { + boolean foundInAAI = execution.getVariable("GENGS_FoundIndicator") + if(foundInAAI == true){ + String aaiService = execution.getVariable("GENGS_service") + if (!isBlank(aaiService) && (utils.nodeExists(aaiService, "service-instance-name"))) { + execution.setVariable("serviceInstanceName", utils.getNodeText1(aaiService, "service-instance-name")) + utils.log("INFO","Found Service-instance in AAI.serviceInstanceName:" + execution.getVariable("serviceInstanceName"), isDebugEnabled) + } + } + } + } catch (BpmnError e) { + throw e; + } catch (Exception ex) { + msg = "Exception in DoCreateServiceInstance.postProcessAAIGET2 " + ex.getMessage() + utils.log("INFO", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + utils.log("INFO", "Exited " + method, isDebugEnabled) + } + + public void preProcessRollback (Execution execution) { + def method = getClass().getSimpleName() + '.preProcessRollback(' +'execution=' + execution.getId() +')' + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + utils.log("INFO","Entered " + method, isDebugEnabled) + utils.log("INFO"," ***** Enter DoCreateE2EServiceInstanceV2 preProcessRollback ***** ", isDebugEnabled) + try { + + Object workflowException = execution.getVariable("WorkflowException"); + + if (workflowException instanceof WorkflowException) { + utils.log("INFO", "Prev workflowException: " + workflowException.getErrorMessage(), isDebugEnabled) + execution.setVariable("prevWorkflowException", workflowException); + //execution.setVariable("WorkflowException", null); + } + } catch (BpmnError e) { + utils.log("INFO", "BPMN Error during preProcessRollback", isDebugEnabled) + } catch(Exception ex) { + String msg = "Exception in preProcessRollback. " + ex.getMessage() + utils.log("INFO", msg, isDebugEnabled) + } + utils.log("INFO", "Exited " + method, isDebugEnabled) + } + + public void postProcessRollback (Execution execution) { + def method = getClass().getSimpleName() + '.postProcessRollback(' +'execution=' + execution.getId() +')' + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + utils.log("INFO","Entered " + method, isDebugEnabled) + utils.log("INFO"," ***** Enter DoCreateE2EServiceInstanceV2 postProcessRollback ***** ", isDebugEnabled) + String msg = "" + try { + Object workflowException = execution.getVariable("prevWorkflowException"); + if (workflowException instanceof WorkflowException) { + utils.log("INFO", "Setting prevException to WorkflowException: ", isDebugEnabled) + execution.setVariable("WorkflowException", workflowException); + } + execution.setVariable("rollbackData", null) + } catch (BpmnError b) { + utils.log("INFO", "BPMN Error during postProcessRollback", isDebugEnabled) + throw b; + } catch(Exception ex) { + msg = "Exception in postProcessRollback. " + ex.getMessage() + utils.log("INFO", msg, isDebugEnabled) + } + utils.log("INFO", "Exited " + method, isDebugEnabled) + } + + /** + * Init the service Operation Status + */ + public void preUpdateServiceOperationStatus(Execution execution){ + def method = getClass().getSimpleName() + '.preUpdateServiceOperationStatus(' +'execution=' + execution.getId() +')' + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + utils.log("INFO","Entered " + method, isDebugEnabled) + + try{ + String serviceId = execution.getVariable("serviceInstanceId") + String operationId = execution.getVariable("operationId") + String serviceName = execution.getVariable("serviceInstanceName") + String operationType = "CREATE" + String userId = "" + String result = "processing" + String progress = execution.getVariable("progress") + utils.log("INFO", "progress: " + progress , isDebugEnabled) + if ("100".equalsIgnoreCase(progress)) + { + result = "finished" + } + String reason = "" + String operationContent = "Prepare service creation : " + execution.getVariable("operationStatus") + + utils.log("INFO", "Generated new operation for Service Instance serviceId:" + serviceId + " operationId:" + operationId, isDebugEnabled) + serviceId = UriUtils.encode(serviceId,"UTF-8") + execution.setVariable("serviceInstanceId", serviceId) + execution.setVariable("operationId", operationId) + execution.setVariable("operationType", operationType) + + def dbAdapterEndpoint = "http://mso.mso.testlab.openecomp.org:8080/dbadapters/RequestsDbAdapter" + execution.setVariable("CVFMI_dbAdapterEndpoint", dbAdapterEndpoint) + utils.log("INFO", "DB Adapter Endpoint is: " + dbAdapterEndpoint, isDebugEnabled) + + execution.setVariable("URN_mso_openecomp_adapters_db_endpoint","http://mso.mso.testlab.openecomp.org:8080/dbadapters/RequestsDbAdapter") + String payload = + """ + + + + ${serviceId} + ${operationId} + ${serviceName} + ${operationType} + ${userId} + ${result} + ${operationContent} + ${progress} + ${reason} + + + """ + + payload = utils.formatXml(payload) + execution.setVariable("CVFMI_updateServiceOperStatusRequest", payload) + utils.log("INFO", "Outgoing preUpdateServiceOperationStatus: \n" + payload, isDebugEnabled) + + + }catch(Exception e){ + utils.log("ERROR", "Exception Occured Processing preUpdateServiceOperationStatus. Exception is:\n" + e, isDebugEnabled) + execution.setVariable("CVFMI_ErrorResponse", "Error Occurred during preUpdateServiceOperationStatus Method:\n" + e.getMessage()) + } + utils.log("INFO", "======== COMPLETED preUpdateServiceOperationStatus Process ======== ", isDebugEnabled) + utils.log("INFO", "Exited " + method, isDebugEnabled) + } + + + public void preInitResourcesOperStatus(Execution execution){ + def method = getClass().getSimpleName() + '.preInitResourcesOperStatus(' +'execution=' + execution.getId() +')' + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + utils.log("INFO","Entered " + method, isDebugEnabled) + + utils.log("INFO", " ======== Enter DoCreateE2EServiceInstanceV2 preInitResourcesOperStatus Process ======== ", isDebugEnabled) + try{ + String serviceId = execution.getVariable("serviceInstanceId") + String operationId = execution.getVariable("operationId") + String operationType = execution.getVariable("operationType") + String resourceTemplateUUIDs = "" + String result = "processing" + String progress = "0" + String reason = "" + String operationContent = "Prepare service creation" + utils.log("INFO", "Generated new operation for Service Instance serviceId:" + serviceId + " operationId:" + operationId + " operationType:" + operationType, isDebugEnabled) + serviceId = UriUtils.encode(serviceId,"UTF-8") + execution.setVariable("serviceInstanceId", serviceId) + execution.setVariable("operationId", operationId) + execution.setVariable("operationType", operationType) + String incomingRequest = execution.getVariable("uuiRequest") + String resourcesStr = jsonUtil.getJsonValue(incomingRequest, "service.parameters.resources") + List resourceList = jsonUtil.StringArrayToList(execution, resourcesStr) + for(String resource : resourceList){ + resourceTemplateUUIDs = resourceTemplateUUIDs + jsonUtil.getJsonValue(resource, "resourceId") + ":" + } + + def dbAdapterEndpoint = "http://mso.mso.testlab.openecomp.org:8080/dbadapters/RequestsDbAdapter" + execution.setVariable("CVFMI_dbAdapterEndpoint", dbAdapterEndpoint) + utils.log("INFO", "DB Adapter Endpoint is: " + dbAdapterEndpoint, isDebugEnabled) + + String payload = + """ + + + + ${serviceId} + ${operationId} + ${operationType} + ${resourceTemplateUUIDs} + + + """ + + payload = utils.formatXml(payload) + execution.setVariable("CVFMI_initResOperStatusRequest", payload) + utils.log("INFO", "Outgoing initResourceOperationStatus: \n" + payload, isDebugEnabled) + utils.logAudit("DoCustomDeleteE2EServiceInstanceV2 Outgoing initResourceOperationStatus Request: " + payload) + + }catch(Exception e){ + utils.log("ERROR", "Exception Occured Processing preInitResourcesOperStatus. Exception is:\n" + e, isDebugEnabled) + execution.setVariable("CVFMI_ErrorResponse", "Error Occurred during preInitResourcesOperStatus Method:\n" + e.getMessage()) + } + utils.log("INFO", "Exited " + method, isDebugEnabled) + } + + /** + * prepare resource create request + */ + public void preResourceRequest(execution){ + def method = getClass().getSimpleName() + '.preResourceRequest(' +'execution=' + execution.getId() +')' + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + utils.log("INFO","Entered " + method, isDebugEnabled) + + utils.log("INFO", " ======== Enter DoCreateE2EServiceInstanceV2 preResourceRequest Process ======== ", isDebugEnabled) + try { + String resourceType = execution.getVariable("resourceType") + String serviceInstanceName = execution.getVariable("serviceInstanceName") + String nsServiceName = resourceType + "_" + serviceInstanceName + execution.setVariable("nsServiceName", nsServiceName) + utils.log("INFO", "Prepare VFC Request nsServiceName:" + nsServiceName, isDebugEnabled) + String globalSubscriberId = execution.getVariable("globalSubscriberId") + String serviceType = execution.getVariable("serviceType") + String serviceId = execution.getVariable("serviceInstanceId") + execution.setVariable("serviceId", serviceId) + String operationId = execution.getVariable("operationId") + String incomingRequest = execution.getVariable("uuiRequest") + String resourcesStr = jsonUtil.getJsonValue(incomingRequest, "service.parameters.resources") + String nsServiceDescription = jsonUtil.getJsonValue(incomingRequest, "service.description") + execution.setVariable("nsServiceDescription", nsServiceDescription) + utils.log("INFO", "Prepare VFC Request nsServiceDescription:" + nsServiceDescription, isDebugEnabled) + List resourceList = jsonUtil.StringArrayToList(execution, resourcesStr) + for(String resource : resourceList){ + String resourceName = jsonUtil.getJsonValue(resource, "resourceName") + if(StringUtils.containsIgnoreCase(resourceName, resourceType)){ + String resourceUUID = jsonUtil.getJsonValue(resource, "resourceId") + String resourceInvariantUUID = jsonUtil.getJsonValue(resource, "resourceDefId") + String resourceParameters = jsonUtil.getJsonValue(resource, "nsParameters") + execution.setVariable("resourceUUID", resourceUUID) + execution.setVariable("resourceInvariantUUID", resourceInvariantUUID) + execution.setVariable("resourceParameters", resourceParameters) + utils.log("INFO", "Prepare VFC Request resourceType:" + resourceType, isDebugEnabled) + utils.log("INFO", "Prepare VFC Request resourceUUID:" + resourceUUID, isDebugEnabled) + utils.log("INFO", "Prepare VFC Request resourceParameters:" + resourceParameters, isDebugEnabled) + } + } + } catch (BpmnError b) { + utils.log("INFO", "BPMN Error during preResourceRequest", isDebugEnabled) + throw b; + } catch(Exception ex) { + msg = "Exception in preResourceRequest. " + ex.getMessage() + utils.log("INFO", msg, isDebugEnabled) + } + utils.log("INFO", "Exited " + method, isDebugEnabled) + } + + /** + * post config request. + */ + public void postConfigRequest(execution){ + //now do noting + } + + /***********************************************************************************************/ + + private void loadResourcesProperties(Execution execution) { + def method = getClass().getSimpleName() + '.loadResourcesProperties(' +'execution=' + execution.getId() +')' + def isDebugEnabled = execution.getVariable("isDebugEnabled") + utils.log("INFO","Entered " + method, isDebugEnabled) + String loadFilePath = "/etc/mso/config.d/reources.json" + try{ + def jsonPayload = new File(loadFilePath).text + utils.log("INFO","jsonPayload: " + jsonPayload, isDebugEnabled) + + String resourcesProperties = jsonUtil.prettyJson(jsonPayload.toString()) + utils.log("INFO","resourcesProperties: " + resourcesProperties, isDebugEnabled) + + String createResourceSort = jsonUtil.getJsonValue(resourcesProperties, "CreateResourceSort") + //utils.log("INFO","createResourceSort: " + createResourceSort, isDebugEnabled) + execution.setVariable("createResourceSort", createResourceSort) + + String deleteResourceSort = jsonUtil.getJsonValue(resourcesProperties, "DeleteResourceSort") + //utils.log("INFO","deleteResourceSort: " + deleteResourceSort, isDebugEnabled) + execution.setVariable("deleteResourceSort", deleteResourceSort) + + + String resourceControllerType = jsonUtil.getJsonValue(resourcesProperties, "ResourceControllerType") + //utils.log("INFO","resourceControllerType: " + resourceControllerType, isDebugEnabled) + execution.setVariable("resourceControllerType", resourceControllerType) + + + }catch(Exception ex){ + // try error in method block + String exceptionMessage = "Bpmn error encountered in " + method + " - " + ex.getMessage() + utils.log("DEBUG", exceptionMessage, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + utils.log("INFO", "Exited " + method, isDebugEnabled) + } + private sortCreateResource(Execution execution) { + def method = getClass().getSimpleName() + '.sortCreateResource(' +'execution=' + execution.getId() +')' + def isDebugEnabled = execution.getVariable("isDebugEnabled") + utils.log("INFO","Entered " + method, isDebugEnabled) + String createResourceSortDef = """[ + { + "resourceType":"vEPC" + }, + { + "resourceType":"vIMS" + }, + { + "resourceType":"vCPE" + }, + { + "resourceType":"vFW" + }, + { + "resourceType":"Underlay" + }, + { + "resourceType":"Overlay" + }, + { + "resourceType":"GRE_AAR" + }, + { + "resourceType":"APN_AAR" + }, + { + "resourceType":"VPN_SAR" + }, + { + "resourceType":"GRE_SAR" + } + + ]""".trim() + + try{ + + loadResourcesProperties(execution) + String createResourceSort = execution.getVariable("createResourceSort") + if (isBlank(createResourceSort)) { + createResourceSort = createResourceSortDef; + } + + List sortResourceList = jsonUtil.StringArrayToList(execution, createResourceSort) + utils.log("INFO", "sortResourceList : " + sortResourceList, isDebugEnabled) + + JSONArray newResourceList = new JSONArray() + int resSortCount = sortResourceList.size() + + + for ( int currentResource = 0 ; currentResource < resSortCount ; currentResource++ ) { + String sortResource = sortResourceList[currentResource] + String resourceType = jsonUtil.getJsonValue(sortResource, "resourceType") + List resourceList = execution.getVariable(Prefix+"resourceList") + + for (String resource : resourceList) { + //utils.log("INFO", "resource : " + resource, isDebugEnabled) + String resourceName = jsonUtil.getJsonValue(resource, "resourceName") + //utils.log("INFO", "resource Name : " + resourceName, isDebugEnabled) + String[] split = resourceName.split("_") + + utils.log("INFO", "split : " + split, isDebugEnabled) + int strLen = split.size() + String allottedResourceType = "" + + if (strLen <2) { + allottedResourceType = split[0] + } + else { + allottedResourceType = split[0] + "_" + split[1] + } + + if (StringUtils.containsIgnoreCase(allottedResourceType, resourceType)) { + utils.log("INFO", "allottedResourceType : " + allottedResourceType + " resourceType : " + resourceType, isDebugEnabled) + utils.log("INFO", "resource : " + resource , isDebugEnabled) + JSONObject jsonObj = new JSONObject(resource) + newResourceList.put(jsonObj) + + } + utils.log("INFO", "Get next sort type " , isDebugEnabled) + } + } + utils.log("INFO", "newResourceList : " + newResourceList, isDebugEnabled) + String newResourceStr = newResourceList.toString() + List newResourceListStr = jsonUtil.StringArrayToList(execution, newResourceStr) + + execution.setVariable(Prefix+"resourceList", newResourceListStr) + utils.log("INFO", "newResourceList : " + newResourceListStr, isDebugEnabled) + + }catch(Exception ex){ + // try error in method block + String exceptionMessage = "Bpmn error encountered in " + method + " - " + ex.getMessage() + utils.log("DEBUG", exceptionMessage, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + utils.log("INFO", "Exited " + method, isDebugEnabled) + + } + /** + * get service resources + */ + public void getServiceResources(Execution execution){ + def method = getClass().getSimpleName() + '.getServiceResources(' +'execution=' + execution.getId() +')' + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + utils.log("INFO","Entered " + method, isDebugEnabled) + utils.log("INFO", " ======== Enter DoCreateE2EServiceInstanceV2 getServiceResources Process ======== ", isDebugEnabled) + try{ + execution.setVariable(Prefix+"resourceCount", 0) + execution.setVariable(Prefix+"nextResource", 0) + + String incomingRequest = execution.getVariable("uuiRequest") + String resourcesStr = jsonUtil.getJsonValue(incomingRequest, "service.parameters.resources") + utils.log("INFO", "Resources String : " + resourcesStr, isDebugEnabled) + if (!isBlank(resourcesStr)) { + List resourceList = jsonUtil.StringArrayToList(execution, resourcesStr) + utils.log("INFO", "Resource List : " + resourceList, isDebugEnabled) + execution.setVariable(Prefix+"resourceList", resourceList) + execution.setVariable(Prefix+"resourceCount", resourceList.size()) + execution.setVariable(Prefix+"nextResource", 0) + } + + int resourceNum = execution.getVariable(Prefix+"nextResource") + utils.log("DEBUG", "Current Resource count:"+ execution.getVariable(Prefix+"nextResource"), isDebugEnabled) + + int resourceCount = execution.getVariable(Prefix+"resourceCount") + utils.log("DEBUG", "Total Resource count:"+ execution.getVariable(Prefix+"resourceCount"), isDebugEnabled) + + if (resourceNum < resourceCount) { + execution.setVariable(Prefix+"resourceFinish", false) + } + else { + execution.setVariable(Prefix+"resourceFinish", true) + } + sortCreateResource(execution) + + }catch(Exception e){ + utils.log("ERROR", "Exception Occured Processing getServiceResources. Exception is:\n" + e, isDebugEnabled) + execution.setVariable(Prefix+"ErrorResponse", "Error Occurred during getServiceResources Method:\n" + e.getMessage()) + } + utils.log("INFO", "Exited " + method, isDebugEnabled) + } + + /** + * prepare Decompose next resource to create request + */ + public void preProcessDecomposeNextResource(Execution execution){ + def method = getClass().getSimpleName() + '.preProcessDecomposeNextResource(' +'execution=' + execution.getId() +')' + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + utils.log("INFO","Entered " + method, isDebugEnabled) + utils.log("INFO", " ======== Enter DoCreateE2EServiceInstanceV2 preProcessDecomposeNextResource Process ======== ", isDebugEnabled) + try{ + int resourceNum = execution.getVariable(Prefix+"nextResource") + List resourceList = execution.getVariable(Prefix+"resourceList") + utils.log("INFO", "Resource List : " + resourceList, isDebugEnabled) + + String resource = resourceList[resourceNum] + execution.setVariable(Prefix+"resource", resource) + utils.log("INFO", "Current Resource : " + resource, isDebugEnabled) + + String resourceName = jsonUtil.getJsonValue(resource, "resourceName") + execution.setVariable(Prefix+"resourceName", resourceName) + utils.log("INFO", "resource Name : " + resourceName, isDebugEnabled) + + String resourceUUID = jsonUtil.getJsonValue(resource, "resourceId") + execution.setVariable("resourceUUID", resourceUUID) + utils.log("INFO", "resource UUID : " + resourceUUID, isDebugEnabled) + + String resourceInvariantUUID = jsonUtil.getJsonValue(resource, "resourceDefId") + execution.setVariable("resourceInvariantUUID", resourceInvariantUUID) + + + String resourceParameters = jsonUtil.getJsonValue(resource, "nsParameters") + execution.setVariable("resourceParameters", resourceParameters) + utils.log("INFO", "resource Parameters : " + resourceParameters, isDebugEnabled) + + execution.setVariable(Prefix+"nextResource", resourceNum + 1) + utils.log("INFO", "next Resource num : " + execution.getVariable(Prefix+"nextResource"), isDebugEnabled) + + int resourceCount = execution.getVariable(Prefix+"resourceCount") + if (resourceCount >0 ){ + int progress = (resourceNum*100) / resourceCount + execution.setVariable("progress", progress.toString() ) + } + + execution.setVariable("operationStatus", resourceName ) + + }catch(Exception e){ + utils.log("ERROR", "Exception Occured Processing preProcessDecomposeNextResource. Exception is:\n" + e, isDebugEnabled) + execution.setVariable(Prefix+"ErrorResponse", "Error Occurred during preProcessDecomposeNextResource Method:\n" + e.getMessage()) + } + utils.log("INFO", "Exited " + method, isDebugEnabled) + } + /** + * post Decompose next resource to create request + */ + public void postProcessDecomposeNextResource(Execution execution){ + def method = getClass().getSimpleName() + '.postProcessDecomposeNextResource(' +'execution=' + execution.getId() +')' + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + utils.log("INFO","Entered " + method, isDebugEnabled) + utils.log("INFO", " ======== STARTED DoCreateE2EServiceInstanceV2 postProcessDecomposeNextResource Process ======== ", isDebugEnabled) + try{ + String resourceName = execution.getVariable(Prefix+"resourceName") + + int resourceNum = execution.getVariable(Prefix+"nextResource") + utils.log("DEBUG", "Current Resource count:"+ execution.getVariable(Prefix+"nextResource"), isDebugEnabled) + + int resourceCount = execution.getVariable(Prefix+"resourceCount") + utils.log("DEBUG", "Total Resource count:"+ execution.getVariable(Prefix+"resourceCount"), isDebugEnabled) + + if (resourceNum < resourceCount) { + execution.setVariable(Prefix+"resourceFinish", false) + } + else { + execution.setVariable(Prefix+"resourceFinish", true) + } + + utils.log("DEBUG", "Resource Finished:"+ execution.getVariable(Prefix+"resourceFinish"), isDebugEnabled) + + if (resourceCount >0 ){ + int progress = (resourceNum*100) / resourceCount + execution.setVariable("progress", progress.toString() ) + utils.log("DEBUG", "progress :"+ execution.getVariable("progress"), isDebugEnabled) + } + execution.setVariable("operationStatus", resourceName ) + + }catch(Exception e){ + // try error in method block + String exceptionMessage = "Bpmn error encountered in "+method + "- " + e.getMessage() + utils.log("DEBUG", exceptionMessage, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + utils.log("INFO", "Exited " + method, isDebugEnabled) + } + /** + * prepare check Resource Type + */ + public void checkResourceType(Execution execution){ + def method = getClass().getSimpleName() + '.checkResourceType(' +'execution=' + execution.getId() +')' + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + utils.log("INFO","Entered " + method, isDebugEnabled) + String resourceControllerTypeDef = """[ + { + "resourceType":"vEPC", + "controllerType":"VFC" + }, + { + "resourceType":"vIMS", + "controllerType":"VFC" + }, + { + "resourceType":"vCPE", + "controllerType":"VFC" + }, + { + "resourceType":"vFW", + "controllerType":"VFC" + }, + { + "resourceType":"Underlay", + "controllerType":"SDNC" + }, + { + "resourceType":"Overlay", + "controllerType":"SDNC" + }, + { + "resourceType":"VPN_SAR", + "controllerType":"SDNC" + }, + { + "resourceType":"GRE_AAR", + "controllerType":"APPC" + }, + { + "resourceType":"GRE_SAR", + "controllerType":"SDNC" + } , + { + "resourceType":"APN_AAR", + "controllerType":"APPC" + } + + ]""".trim() + + try{ + + String resourceName = execution.getVariable(Prefix+"resourceName") + utils.log("INFO", "resourceName : " + resourceName, isDebugEnabled) + execution.setVariable("resourceName", resourceName) + + String[] split = resourceName.split("_") + + utils.log("INFO", "split : " + split, isDebugEnabled) + int strLen = split.size() + String allottedResourceType = "" + + if (strLen <2) { + allottedResourceType = split[0] + } + else { + allottedResourceType = split[0] + "_" + split[1] + } + + loadResourcesProperties(execution) + String resourceControllerType= execution.getVariable("resourceControllerType") + if (isBlank(resourceControllerType)) { + resourceControllerType = resourceControllerTypeDef; + } + utils.log("INFO", "resourceControllerType: " + resourceControllerType, isDebugEnabled) + + List ResourceTypeList = jsonUtil.StringArrayToList(execution, resourceControllerType) + utils.log("INFO", "ResourceTypeList : " + ResourceTypeList, isDebugEnabled) + execution.setVariable("controllerType", "Other") + execution.setVariable(Prefix+"resourceType", "") + for (String resourceMap : ResourceTypeList) { + String resourceType = jsonUtil.getJsonValue(resourceMap, "resourceType") + String controllerType = jsonUtil.getJsonValue(resourceMap, "controllerType") + //utils.log("INFO", "resourceMap.resourceType : " + resourceType, isDebugEnabled) + //utils.log("INFO", "resourceMap.controllerType : " + controllerType, isDebugEnabled) + //utils.log("INFO", "resourceName : " + resourceName, isDebugEnabled) + //utils.log("INFO", "allottedResourceType : " + allottedResourceType, isDebugEnabled ) + + if (StringUtils.containsIgnoreCase(allottedResourceType, resourceType)) { + execution.setVariable("controllerType", controllerType) + execution.setVariable(Prefix+"resourceType", resourceType) + utils.log("INFO", "found controller type : " + controllerType, isDebugEnabled) + break + } + } + utils.log("INFO", "controller Type : " + execution.getVariable("controllerType"), isDebugEnabled) + utils.log("INFO", "resource Type : " + execution.getVariable(Prefix+"resourceType"), isDebugEnabled) + + if (execution.getVariable("controllerType") == "") { + String exceptionMessage = "Resource name can not find controller type,please check the resource Name: "+ resourceName + utils.log("DEBUG", exceptionMessage, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + if (execution.getVariable(Prefix+"resourceType") == "vCPE") { + execution.setVariable("skipVFC", "false") + utils.log("INFO", "vCPE will deploy ", isDebugEnabled) + } + + }catch(Exception e){ + // try error in method block + String exceptionMessage = "Bpmn error encountered in "+ method + " - " + e.getMessage() + utils.log("DEBUG", exceptionMessage, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + utils.log("INFO", "Exited " + method, isDebugEnabled) + } + /** + * prepare post Unkown Resource Type + */ + public void postOtherControllerType(Execution execution){ + def method = getClass().getSimpleName() + '.postOtherControllerType(' +'execution=' + execution.getId() +')' + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + utils.log("INFO","Entered " + method, isDebugEnabled) + + utils.log("INFO", " ======== Enter DoCreateE2EServiceInstanceV2 postOtherControllerType Process ======== ", isDebugEnabled) + try{ + + String resourceName = execution.getVariable(Prefix+"resourceName") + String resourceType = execution.getVariable(Prefix+"resourceType") + String controllerType = execution.getVariable("controllerType") + + String msg = "Resource name: "+ resourceName + " resource Type: " + resourceType+ " controller Type: " + controllerType + " can not be processed n the workflow" + utils.log("DEBUG", msg, isDebugEnabled) + + }catch(Exception e){ + // try error in method block + String exceptionMessage = "Bpmn error encountered in "+ method + " - " + e.getMessage() + utils.log("DEBUG", exceptionMessage, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + utils.log("INFO", "Exited " + method, isDebugEnabled) + } + + /** + * prepare Controller resource create request + */ + public void preProcessResourceRequestForController(execution){ + def method = getClass().getSimpleName() + '.preProcessResourceRequestForController(' +'execution=' + execution.getId() +')' + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + utils.log("INFO","Entered " + method, isDebugEnabled) + utils.log("INFO", " ======== Enter DoCreateE2EServiceInstanceV2 preProcessResourceRequestForController Process ======== ", isDebugEnabled) + try{ + String resourceName = execution.getVariable(Prefix+"resourceName") + String resourceType = execution.getVariable(Prefix+"resourceType") + String serviceInstanceName =execution.getVariable("serviceInstanceName") + String nsServiceName = resourceType + "_" + serviceInstanceName + execution.setVariable("nsServiceName", nsServiceName) + utils.log("INFO", "Prepare Controller Request nsServiceName:" + nsServiceName, isDebugEnabled) + + String serviceId = execution.getVariable("serviceInstanceId") + execution.setVariable("serviceId", serviceId) + utils.log("INFO", "Prepare Controller Request serviceId:" + serviceId, isDebugEnabled) + + String globalSubscriberId = execution.getVariable("globalSubscriberId") + utils.log("INFO", "Prepare Controller Request globalSubscriberId:" + globalSubscriberId, isDebugEnabled) + + String incomingRequest = execution.getVariable("uuiRequest") + String nsServiceDescription = jsonUtil.getJsonValue(incomingRequest, "service.description") + execution.setVariable("nsServiceDescription", nsServiceDescription) + utils.log("INFO", "Prepare Controller Request nsServiceDescription:" + nsServiceDescription, isDebugEnabled) + + String resourceUUID = execution.getVariable("resourceUUID") + + utils.log("INFO", "Prepare Controller Request resourceUUID:" + resourceUUID, isDebugEnabled) + + String resourceInvariantUUID = execution.getVariable("resourceInvariantUUID") + utils.log("INFO", "Prepare Controller Request resourceInvariantUUID:" + resourceInvariantUUID, isDebugEnabled) + + String resourceParameters = execution.getVariable("resourceParameters") + execution.setVariable("resourceParameters", resourceParameters) + utils.log("INFO", "Prepare Controller Request resourceParameters:" + resourceParameters, isDebugEnabled) + + + + }catch(Exception e){ + String exceptionMessage = "Bpmn error encountered in "+ method + " - " + e.getMessage() + utils.log("ERROR", exceptionMessage, isDebugEnabled) + execution.setVariable(Prefix+"ErrorResponse", exceptionMessage) + } + utils.log("INFO", "Exited " + method, isDebugEnabled) + } + /** + * post process VFC resource create request + */ + public void postProcessResourceRequestForVFC(execution){ + def method = getClass().getSimpleName() + '.postProcessResourceRequestForVFC(' +'execution=' + execution.getId() +')' + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + utils.log("INFO","Entered " + method, isDebugEnabled) + utils.log("INFO", " ======== Enter DoCreateE2EServiceInstanceV2 postProcessResourceRequestForVFC Process ======== ", isDebugEnabled) + try{ + + + }catch(Exception e){ + utils.log("ERROR", "Exception Occured Processing postProcessResourceRequestForVFC. Exception is:\n" + e, isDebugEnabled) + execution.setVariable(Prefix+"ErrorResponse", "Error Occurred during postProcessResourceRequestForVFC Method:\n" + e.getMessage()) + } + utils.log("INFO", "Exited " + method, isDebugEnabled) + } + + + /** + * post process SDNC resource create request + */ + public void postProcessResourceRequestForSDNC(execution){ + def method = getClass().getSimpleName() + '.postProcessResourceRequestForSDNC(' +'execution=' + execution.getId() +')' + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + utils.log("INFO","Entered " + method, isDebugEnabled) + utils.log("INFO", " ======== Enter DoCreateE2EServiceInstanceV2 postProcessResourceRequestForSDNC Process ======== ", isDebugEnabled) + try{ + + execution.setVariable("serviceSDNCCreate", "true") + + }catch(Exception e){ + utils.log("ERROR", "Exception Occured Processing postProcessResourceRequestForSDNC. Exception is:\n" + e, isDebugEnabled) + execution.setVariable(Prefix+"ErrorResponse", "Error Occurred during postProcessResourceRequestForSDNC Method:\n" + e.getMessage()) + } + utils.log("INFO", "Exited " + method, isDebugEnabled) + } + + + +} + diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstanceV2.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstanceV2.groovy new file mode 100644 index 0000000000..7de0ed0b02 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstanceV2.groovy @@ -0,0 +1,1187 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. + * ================================================================================ + * 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.openecomp.mso.bpmn.infrastructure.scripts + +import org.json.JSONArray; + +import static org.apache.commons.lang3.StringUtils.*; +import groovy.xml.XmlUtil +import groovy.json.* + +import org.openecomp.mso.bpmn.core.json.JsonUtils +import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil +import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils +import org.openecomp.mso.bpmn.core.WorkflowException +import org.openecomp.mso.rest.APIResponse; +import org.openecomp.mso.rest.RESTClient +import org.openecomp.mso.rest.RESTConfig + +import org.openecomp.mso.bpmn.common.scripts.AaiUtil + +import java.util.UUID; +import javax.xml.parsers.DocumentBuilder +import javax.xml.parsers.DocumentBuilderFactory + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.runtime.Execution +import org.json.JSONObject; +import org.apache.commons.lang3.* +import org.apache.commons.codec.binary.Base64; +import org.springframework.web.util.UriUtils; +import org.w3c.dom.Document +import org.w3c.dom.Element +import org.w3c.dom.Node +import org.w3c.dom.NodeList +import org.xml.sax.InputSource + +import com.fasterxml.jackson.jaxrs.json.annotation.JSONP.Def; + +/** + * This groovy class supports the DoDeleteE2EServiceInstance.bpmn process. + * + * Inputs: + * @param - msoRequestId + * @param - globalSubscriberId - O + * @param - subscriptionServiceType - O + * @param - serviceInstanceId + * @param - serviceInstanceName - O + * @param - serviceInputParams (should contain aic_zone for serviceTypes TRANSPORT,ATM) + * @param - sdncVersion + * @param - failNotFound - TODO + * @param - serviceInputParams - TODO + * + * Outputs: + * @param - WorkflowException + * + * Rollback - Deferred + */ +public class DoCustomDeleteE2EServiceInstanceV2 extends AbstractServiceTaskProcessor { + + String Prefix="DDELSI_" + private static final String DebugFlag = "isDebugEnabled" + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + + public void preProcessRequest (Execution execution) { + + def method = getClass().getSimpleName() + '.buildAPPCRequest(' +'execution=' + execution.getId() +')' + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + utils.log("INFO","Entered " + method, isDebugEnabled) + utils.log("INFO"," ***** preProcessRequest *****", isDebugEnabled) + String msg = "" + + try { + String requestId = execution.getVariable("msoRequestId") + execution.setVariable("prefix",Prefix) + + //Inputs + //requestDetails.subscriberInfo. for AAI GET & PUT & SDNC assignToplology + String globalSubscriberId = execution.getVariable("globalSubscriberId") //globalCustomerId + if (globalSubscriberId == null) + { + execution.setVariable("globalSubscriberId", "") + } + + //requestDetails.requestParameters. for AAI PUT & SDNC assignTopology + String serviceType = execution.getVariable("serviceType") + if (serviceType == null) + { + execution.setVariable("serviceType", "") + } + + //Generated in parent for AAI PUT + String serviceInstanceId = execution.getVariable("serviceInstanceId") + if (isBlank(serviceInstanceId)){ + msg = "Input serviceInstanceId is null" + utils.log("INFO", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + + String sdncCallbackUrl = execution.getVariable('URN_mso_workflow_sdncadapter_callback') + if (isBlank(sdncCallbackUrl)) { + msg = "URN_mso_workflow_sdncadapter_callback is null" + utils.log("INFO", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + execution.setVariable("sdncCallbackUrl", sdncCallbackUrl) + utils.log("INFO","SDNC Callback URL: " + sdncCallbackUrl, isDebugEnabled) + + StringBuilder sbParams = new StringBuilder() + Map paramsMap = execution.getVariable("serviceInputParams") + if (paramsMap != null) + { + sbParams.append("") + for (Map.Entry entry : paramsMap.entrySet()) { + String paramsXml + String paramName = entry.getKey() + String paramValue = entry.getValue() + paramsXml = + """ + ${paramName} + ${paramValue} + + """ + sbParams.append(paramsXml) + } + sbParams.append("") + } + String siParamsXml = sbParams.toString() + if (siParamsXml == null) + siParamsXml = "" + execution.setVariable("siParamsXml", siParamsXml) + execution.setVariable("operationStatus", "Waiting delete resource...") + execution.setVariable("progress", "0") + + } catch (BpmnError e) { + throw e; + } catch (Exception ex){ + msg = "Exception in preProcessRequest " + ex.getMessage() + utils.log("INFO", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + utils.log("INFO", "Exited " + method, isDebugEnabled) + } + + + + public void postProcessAAIGET(Execution execution) { + def method = getClass().getSimpleName() + '.postProcessAAIGET(' +'execution=' + execution.getId() +')' + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + utils.log("INFO","Entered " + method, isDebugEnabled) + + String msg = "" + + try { + String serviceInstanceId = execution.getVariable("serviceInstanceId") + utils.log("INFO","serviceInstanceId: "+serviceInstanceId, isDebugEnabled) + + boolean foundInAAI = execution.getVariable("GENGS_FoundIndicator") + utils.log("INFO","foundInAAI: "+foundInAAI, isDebugEnabled) + + String serviceType = "" + + + if(foundInAAI == true){ + utils.log("INFO","Found Service-instance in AAI", isDebugEnabled) + + String siData = execution.getVariable("GENGS_service") + utils.log("INFO", "SI Data", isDebugEnabled) + if (isBlank(siData)) + { + msg = "Could not retrive ServiceInstance data from AAI to delete id:" + serviceInstanceId + utils.log("INFO", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + + }else{ + boolean succInAAI = execution.getVariable("GENGS_SuccessIndicator") + if(succInAAI != true){ + utils.log("INFO","Error getting Service-instance from AAI", + serviceInstanceId, isDebugEnabled) + WorkflowException workflowException = execution.getVariable("WorkflowException") + utils.logAudit("workflowException: " + workflowException) + if(workflowException != null){ + exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage()) + } + else + { + msg = "Failure in postProcessAAIGET GENGS_SuccessIndicator:" + succInAAI + utils.log("INFO", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg) + } + } + + utils.log("INFO","Service-instance NOT found in AAI. Silent Success", isDebugEnabled) + } + }catch (BpmnError e) { + throw e; + } catch (Exception ex) { + msg = "Bpmn error encountered in " + method + "--" + ex.getMessage() + utils.log("INFO", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + utils.log("INFO", "Exited " + method, isDebugEnabled) + } + + private void loadResourcesProperties(Execution execution) { + def method = getClass().getSimpleName() + '.loadResourcesProperties(' +'execution=' + execution.getId() +')' + def isDebugEnabled = execution.getVariable("isDebugEnabled") + utils.log("INFO","Entered " + method, isDebugEnabled) + String loadFilePath = "/etc/mso/config.d/reources.json" + try{ + def jsonPayload = new File(loadFilePath).text + utils.log("INFO","jsonPayload: " + jsonPayload, isDebugEnabled) + + String resourcesProperties = jsonUtil.prettyJson(jsonPayload.toString()) + utils.log("INFO","resourcesProperties: " + resourcesProperties, isDebugEnabled) + + String createResourceSort = jsonUtil.getJsonValue(resourcesProperties, "CreateResourceSort") + //utils.log("INFO","createResourceSort: " + createResourceSort, isDebugEnabled) + execution.setVariable("createResourceSort", createResourceSort) + + String deleteResourceSort = jsonUtil.getJsonValue(resourcesProperties, "DeleteResourceSort") + //utils.log("INFO","deleteResourceSort: " + deleteResourceSort, isDebugEnabled) + execution.setVariable("deleteResourceSort", deleteResourceSort) + + + String resourceControllerType = jsonUtil.getJsonValue(resourcesProperties, "ResourceControllerType") + //utils.log("INFO","resourceControllerType: " + resourceControllerType, isDebugEnabled) + execution.setVariable("resourceControllerType", resourceControllerType) + + + }catch(Exception ex){ + // try error in method block + String exceptionMessage = "Bpmn error encountered in " + method + " - " + ex.getMessage() + utils.log("DEBUG", exceptionMessage, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + utils.log("INFO", "Exited " + method, isDebugEnabled) + } + private void sortDeleteResource(Execution execution) { + def method = getClass().getSimpleName() + '.sortDeleteResource(' +'execution=' + execution.getId() +')' + def isDebugEnabled = execution.getVariable("isDebugEnabled") + utils.log("INFO","Entered " + method, isDebugEnabled) + String deleteResourceSortDef = """[ + { + "resourceType":"GRE_SAR" + }, + { + "resourceType":"VPN_SAR" + }, + { + "resourceType":"APN_AAR" + }, + { + "resourceType":"GRE_AAR" + }, + { + "resourceType":"Overlay" + }, + { + "resourceType":"Underlay" + }, + { + "resourceType":"vIMS" + }, + { + "resourceType":"vCPE" + }, + { + "resourceType":"vFW" + }, + { + "resourceType":"vEPC" + } + + + ]""".trim() + + try{ + loadResourcesProperties(execution) + String deleteResourceSort = execution.getVariable("deleteResourceSort") + if (isBlank(deleteResourceSort)) { + deleteResourceSort = deleteResourceSortDef; + } + + List sortResourceList = jsonUtil.StringArrayToList(execution, deleteResourceSort) + utils.log("INFO", "sortResourceList : " + sortResourceList, isDebugEnabled) + + JSONArray newResourceList = new JSONArray() + int resSortCount = sortResourceList.size() + + for ( int currentResource = 0 ; currentResource < resSortCount ; currentResource++ ) { + String currentSortResource = sortResourceList[currentResource] + String sortResourceType = jsonUtil.getJsonValue(currentSortResource, "resourceType") + List resourceList = execution.getVariable(Prefix+"resourceList") + + for (String resource : resourceList) { + //utils.log("INFO", "resource : " + resource, isDebugEnabled) + String resourceType = jsonUtil.getJsonValue(resource, "resourceType") + + if (StringUtils.containsIgnoreCase(resourceType, sortResourceType)) { + JSONObject jsonObj = new JSONObject(resource) + newResourceList.put(jsonObj) + } + utils.log("INFO", "Get next sort type " , isDebugEnabled) + } + } + + String newResourceStr = newResourceList.toString() + List newResourceListStr = jsonUtil.StringArrayToList(execution, newResourceStr) + + execution.setVariable(Prefix+"resourceList", newResourceListStr) + utils.log("INFO", "newResourceList : " + newResourceListStr, isDebugEnabled) + + }catch(Exception ex){ + // try error in method block + String exceptionMessage = "Bpmn error encountered in " + method + " - " + ex.getMessage() + utils.log("DEBUG", exceptionMessage, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + utils.log("INFO", "Exited " + method, isDebugEnabled) + + } + public void prepareServiceDeleteResource(Execution execution) { + def method = getClass().getSimpleName() + '.prepareServiceDeleteResource(' +'execution=' + execution.getId() +')' + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + utils.log("INFO","Entered " + method, isDebugEnabled) + + try { + + String serviceInstanceId = execution.getVariable("serviceInstanceId") + + // confirm if ServiceInstance was found + if ( !execution.getVariable("GENGS_FoundIndicator") ) + { + String exceptionMessage = "Bpmn error encountered in DeleteMobileAPNCustService flow. Service Instance was not found in AAI by id: " + serviceInstanceId + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + + execution.setVariable(Prefix+"resourceList", "") + execution.setVariable(Prefix+"resourceCount", 0) + execution.setVariable(Prefix+"nextResource", 0) + execution.setVariable(Prefix+"resourceFinish", true) + + // get SI extracted by GenericGetService + String serviceInstanceAaiRecord = execution.getVariable("GENGS_service"); + utils.log("INFO", "serviceInstanceAaiRecord: " +serviceInstanceAaiRecord, isDebugEnabled) + + String aaiJsonRecord = jsonUtil.xml2json(serviceInstanceAaiRecord) + + //utils.log("INFO", "aaiJsonRecord: " +aaiJsonRecord, isDebugEnabled) + def serviceInstanceName = jsonUtil.getJsonValue(aaiJsonRecord, "service-instance.service-instance-name") + execution.setVariable("serviceInstanceName",serviceInstanceName) + + def serviceType = jsonUtil.getJsonValue(aaiJsonRecord, "service-instance.service-type") + execution.setVariable("serviceType",serviceType) + + + String relationshipList = jsonUtil.getJsonValue(aaiJsonRecord, "service-instance.relationship-list") + //utils.log("INFO", "relationship-list:" + relationshipList, isDebugEnabled) + if (! isBlank(relationshipList)){ + utils.log("INFO", "relationship-list exists" , isDebugEnabled) + String relationShip = jsonUtil.getJsonValue(relationshipList, "relationship") + utils.log("INFO", "relationship: " + relationShip, isDebugEnabled) + JSONArray allResources = new JSONArray() + JSONArray serviceResources = new JSONArray() + JSONArray networkResources = new JSONArray() + JSONArray allottedResources = new JSONArray() + + + if (! isBlank(relationShip)){ + JSONArray jsonArray = new JSONArray(); + if (relationShip.startsWith("{") && relationShip.endsWith("}")) { + JSONObject jsonObject = new JSONObject(relationShip); + jsonArray.put(jsonObject); + } else if (relationShip.startsWith("[") && relationShip.endsWith("]")) { + jsonArray = new JSONArray(relationShip); + } else { + utils.log("INFO", "The relationShip fomart is error" , isDebugEnabled) + } + + List relationList = jsonUtil.StringArrayToList(execution, jsonArray.toString()) + + utils.log("INFO", "relationList: " + relationList, isDebugEnabled) + + int relationNum =relationList.size() + utils.log("INFO", "**************relationList size: " + relationNum, isDebugEnabled) + + for ( int currentRelation = 0 ; currentRelation < relationNum ; currentRelation++ ) { + utils.log("INFO", "current Relation num: " + currentRelation, isDebugEnabled) + String relation = relationList[currentRelation] + utils.log("INFO", "relation: " + relation, isDebugEnabled) + + String relatedTo = jsonUtil.getJsonValue(relation, "related-to") + utils.log("INFO", "relatedTo: " + relatedTo, isDebugEnabled) + + String relatedLink = jsonUtil.getJsonValue(relation, "related-link") + utils.log("INFO", "relatedLink: " + relatedLink, isDebugEnabled) + + if (StringUtils.equalsIgnoreCase(relatedTo, "allotted-resource")) { + utils.log("INFO", "allotted-resource exists ", isDebugEnabled) + + String aaiArRsp = getAaiAr(execution, relatedLink) + utils.log("INFO", "aaiArRsp: " + aaiArRsp, isDebugEnabled) + if (! isBlank(aaiArRsp)) { + def type = utils.getNodeText1(aaiArRsp, "type") + def id = utils.getNodeText1(aaiArRsp, "id") + def role = utils.getNodeText1(aaiArRsp, "role") + def resourceVersion = utils.getNodeText1(aaiArRsp, "resource-version") + + JSONObject jObject = new JSONObject() + jObject.put("resourceType", type) + jObject.put("resourceInstanceId", id) + jObject.put("resourceRole", role) + jObject.put("resourceVersion", resourceVersion) + + allResources.put(jObject) + utils.log("INFO", "allResources: " + allResources, isDebugEnabled) + allottedResources.put(jObject) + utils.log("INFO", "allottedResources: " + allottedResources, isDebugEnabled) + } + } + else if (StringUtils.equalsIgnoreCase(relatedTo, "service-instance")){ + utils.log("INFO", "service-instance exists ", isDebugEnabled) + JSONObject jObject = new JSONObject() + + //relationship-data + String rsDataStr = jsonUtil.getJsonValue(relation, "relationship-data") + utils.log("INFO", "rsDataStr: " + rsDataStr, isDebugEnabled) + List rsDataList = jsonUtil.StringArrayToList(execution, rsDataStr) + utils.log("INFO", "rsDataList: " + rsDataList, isDebugEnabled) + for(String rsData : rsDataList){ + utils.log("INFO", "rsData: " + rsData, isDebugEnabled) + def eKey = jsonUtil.getJsonValue(rsData, "relationship-key") + def eValue = jsonUtil.getJsonValue(rsData, "relationship-value") + if(eKey.equals("service-instance.service-instance-id")){ + jObject.put("resourceInstanceId", eValue) + } + if(eKey.equals("service-subscription.service-type")){ + jObject.put("resourceType", eValue) + } + } + + //related-to-property + String rPropertyStr = jsonUtil.getJsonValue(relation, "related-to-property") + utils.log("INFO", "related-to-property: " + rPropertyStr, isDebugEnabled) + if (rPropertyStr instanceof JSONArray){ + List rPropertyList = jsonUtil.StringArrayToList(execution, rPropertyStr) + for (String rProperty : rPropertyList) { + utils.log("INFO", "rProperty: " + rProperty, isDebugEnabled) + def eKey = jsonUtil.getJsonValue(rProperty, "property-key") + def eValue = jsonUtil.getJsonValue(rProperty, "property-value") + if(eKey.equals("service-instance.service-instance-name")){ + jObject.put("resourceName", eValue) + } + } + } + else { + String rProperty = rPropertyStr + utils.log("INFO", "rProperty: " + rProperty, isDebugEnabled) + def eKey = jsonUtil.getJsonValue(rProperty, "property-key") + def eValue = jsonUtil.getJsonValue(rProperty, "property-value") + if (eKey.equals("service-instance.service-instance-name")) { + jObject.put("resourceName", eValue) + } + } + + allResources.put(jObject) + utils.log("INFO", "allResources: " + allResources, isDebugEnabled) + + serviceResources.put(jObject) + utils.log("INFO", "serviceResources: " + serviceResources, isDebugEnabled) + } + else if (StringUtils.equalsIgnoreCase(relatedTo, "configuration")) { + utils.log("INFO", "configuration ", isDebugEnabled) + JSONObject jObject = new JSONObject() + + //relationship-data + String rsDataStr = jsonUtil.getJsonValue(relation, "relationship-data") + utils.log("INFO", "rsDataStr: " + rsDataStr, isDebugEnabled) + List rsDataList = jsonUtil.StringArrayToList(execution, rsDataStr) + utils.log("INFO", "rsDataList: " + rsDataList, isDebugEnabled) + for (String rsData : rsDataList) { + utils.log("INFO", "rsData: " + rsData, isDebugEnabled) + def eKey = jsonUtil.getJsonValue(rsData, "relationship-key") + def eValue = jsonUtil.getJsonValue(rsData, "relationship-value") + if(eKey.equals("configuration.configuration-id")){ + jObject.put("resourceInstanceId", eValue) + } + } + + + //related-to-property + String rPropertyStr = jsonUtil.getJsonValue(relation, "related-to-property") + utils.log("INFO", "related-to-property: " + rPropertyStr, isDebugEnabled) + if (rPropertyStr instanceof JSONArray){ + List rPropertyList = jsonUtil.StringArrayToList(execution, rPropertyStr) + for(String rProperty : rPropertyList){ + utils.log("INFO", "rProperty: " + rProperty, isDebugEnabled) + def eKey = jsonUtil.getJsonValue(rProperty, "property-key") + def eValue = jsonUtil.getJsonValue(rProperty, "property-value") + if(eKey.equals("configuration.configuration-type")){ + jObject.put("resourceType", eValue) + } + } + } + else { + String rProperty = rPropertyStr + utils.log("INFO", "rProperty: " + rProperty, isDebugEnabled) + def eKey = jsonUtil.getJsonValue(rProperty, "property-key") + def eValue = jsonUtil.getJsonValue(rProperty, "property-value") + if(eKey.equals("configuration.configuration-type")){ + jObject.put("resourceType", eValue) + } + } + allResources.put(jObject) + utils.log("INFO", "allResources: " + allResources, isDebugEnabled) + + networkResources.put(jObject) + utils.log("INFO", "networkResources: " + networkResources, isDebugEnabled) + } + utils.log("INFO", "Get Next releation resource " , isDebugEnabled) + + } + utils.log("INFO", "Get releation finished. " , isDebugEnabled) + } + + execution.setVariable("serviceRelationShip", allResources.toString()) + utils.log("INFO", "allResources: " + allResources.toString(), isDebugEnabled) + String serviceRelationShip = execution.getVariable("serviceRelationShip") + utils.log("INFO", "serviceRelationShip: " + serviceRelationShip, isDebugEnabled) + if ((! isBlank(serviceRelationShip)) && (! serviceRelationShip.isEmpty())) { + + List relationShipList = jsonUtil.StringArrayToList(execution, serviceRelationShip) + utils.log("INFO", "relationShipList: " + relationShipList, isDebugEnabled) + execution.setVariable(Prefix+"resourceList", relationShipList) + + int resourceCount = relationShipList.size() + utils.log("INFO", "resourceCount: " + resourceCount, isDebugEnabled) + execution.setVariable(Prefix+"resourceCount",resourceCount ) + + int resourceNum = 0 + execution.setVariable(Prefix+"nextResource", resourceNum) + utils.log("INFO", "start sort delete resource: ", isDebugEnabled) + sortDeleteResource(execution) + + + if (resourceNum < resourceCount) { + execution.setVariable(Prefix+"resourceFinish", false) + } + else { + execution.setVariable(Prefix+"resourceFinish", true) + } + utils.log("INFO", "Resource list set end : " + resourceCount, isDebugEnabled) + } + + execution.setVariable("serviceResources", serviceResources.toString()) + utils.log("INFO", "serviceResources: " + serviceResources, isDebugEnabled) + String serviceResourcesShip = execution.getVariable("serviceResources") + utils.log("INFO", "serviceResourcesShip: " + serviceResourcesShip, isDebugEnabled) + + if ((! isBlank(serviceResourcesShip)) && (! serviceResourcesShip.isEmpty())) { + List serviceResourcesList = jsonUtil.StringArrayToList(execution, serviceResourcesShip) + utils.log("INFO", "serviceResourcesList: " + serviceResourcesList, isDebugEnabled) + execution.setVariable(Prefix+"serviceResourceList", serviceResourcesList) + execution.setVariable(Prefix+"serviceResourceCount", serviceResourcesList.size()) + execution.setVariable(Prefix+"nextServiceResource", 0) + utils.log("INFO", "Service Resource list set end : " + serviceResourcesList.size(), isDebugEnabled) + + } + + execution.setVariable("allottedResources", allottedResources.toString()) + utils.log("INFO", "allottedResources: " + allottedResources, isDebugEnabled) + String allottedResourcesShip = execution.getVariable("allottedResources") + utils.log("INFO", "allottedResourcesShip: " + allottedResourcesShip, isDebugEnabled) + if ((! isBlank(allottedResourcesShip)) && (! allottedResourcesShip.isEmpty())) { + List allottedResourcesList = jsonUtil.StringArrayToList(execution, allottedResourcesShip) + utils.log("INFO", "allottedResourcesList: " + allottedResourcesList, isDebugEnabled) + execution.setVariable(Prefix+"allottedResourcesList", allottedResourcesList) + execution.setVariable(Prefix+"allottedResourcesListCount", allottedResourcesList.size()) + execution.setVariable(Prefix+"nextAllottedResourcesList", 0) + utils.log("INFO", "Allotted Resource list set end : " + allottedResourcesList.size(), isDebugEnabled) + + } + execution.setVariable("networkResources", networkResources.toString()) + utils.log("INFO", "networkResources: " + networkResources, isDebugEnabled) + String networkResourcesShip = execution.getVariable("networkResources") + utils.log("INFO", "networkResourcesShip: " + networkResourcesShip, isDebugEnabled) + if ((! isBlank(networkResourcesShip)) && (! networkResourcesShip.isEmpty())) { + List networkResourcesList = jsonUtil.StringArrayToList(execution, networkResourcesShip) + utils.log("INFO", "networkResourcesList: " + networkResourcesList, isDebugEnabled) + execution.setVariable(Prefix+"networkResourcesList", networkResourcesList) + execution.setVariable(Prefix+"networkResourcesListCount", networkResourcesList.size()) + execution.setVariable(Prefix+"nextNetworkResourcesList", 0) + utils.log("INFO", "Network Resource list set end : " + networkResourcesList.size(), isDebugEnabled) + + } + } + } catch (BpmnError e){ + throw e; + } catch (Exception ex) { + String exceptionMessage = "Bpmn error encountered in DeleteMobileAPNCustService flow. prepareServiceDeleteResource() - " + ex.getMessage() + utils.log("DEBUG", exceptionMessage, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + utils.log("INFO", "Exited " + method, isDebugEnabled) + } + + private String getAaiAr(Execution execution, String relink) { + def method = getClass().getSimpleName() + '.getAaiAr(' +'execution=' + execution.getId() +')' + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + utils.log("INFO","Entered " + method, isDebugEnabled) + AaiUtil aaiUtil = new AaiUtil(this) + String aaiEndpoint = execution.getVariable("URN_aai_endpoint") + relink + + utils.log("DEBUG", "get AR info " + aaiEndpoint, isDebugEnabled) + APIResponse response = aaiUtil.executeAAIGetCall(execution, aaiEndpoint) + + int responseCode = response.getStatusCode() + utils.log("DEBUG", "get AR info responseCode:" + responseCode, isDebugEnabled) + + String aaiResponse = response.getResponseBodyAsString() + utils.log("DEBUG", "get AR info " + aaiResponse, isDebugEnabled) + + if(responseCode < 200 || responseCode >= 300 || isBlank(aaiResponse)) { + return null + } + + utils.log("INFO", "Exited " + method, isDebugEnabled) + return aaiResponse + } + /** + * prepare Decompose next resource to create request + */ + public void preProcessDecomposeNextResource(Execution execution){ + def method = getClass().getSimpleName() + '.getAaiAr(' +'execution=' + execution.getId() +')' + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + utils.log("INFO","Entered " + method, isDebugEnabled) + utils.log("INFO", " ======== STARTED preProcessDecomposeNextResource Process ======== ", isDebugEnabled) + try{ + int resourceNum = execution.getVariable(Prefix+"nextServiceResource") + List serviceResourceList = execution.getVariable(Prefix+"serviceResourceList") + utils.log("INFO", "Service Resource List : " + serviceResourceList, isDebugEnabled) + + String serviceResource = serviceResourceList[resourceNum] + execution.setVariable(Prefix+"serviceResource", serviceResource) + utils.log("INFO", "Current Service Resource : " + serviceResource, isDebugEnabled) + + String resourceType = jsonUtil.getJsonValue(serviceResource, "resourceType") + execution.setVariable("resourceType", resourceType) + utils.log("INFO", "resourceType : " + resourceType, isDebugEnabled) + + String resourceInstanceId = jsonUtil.getJsonValue(serviceResource, "resourceInstanceId") + execution.setVariable("resourceInstanceId", resourceInstanceId) + utils.log("INFO", "resourceInstanceId : " + resourceInstanceId, isDebugEnabled) + + String resourceRole = jsonUtil.getJsonValue(serviceResource, "resourceRole") + execution.setVariable("resourceRole", resourceRole) + utils.log("INFO", "resourceRole : " + resourceRole, isDebugEnabled) + + String resourceVersion = jsonUtil.getJsonValue(serviceResource, "resourceVersion") + execution.setVariable("resourceVersion", resourceVersion) + utils.log("INFO", "resourceVersion : " + resourceVersion, isDebugEnabled) + + String resourceName = jsonUtil.getJsonValue(serviceResource, "resourceName") + if (isBlank(resourceName)){ + resourceName = resourceInstanceId + } + execution.setVariable(Prefix+"resourceName", resourceName) + utils.log("INFO", "resource Name : " + resourceName, isDebugEnabled) + + + execution.setVariable(Prefix+"nextServiceResource", resourceNum + 1) + + int serviceResourceCount = execution.getVariable(Prefix+"serviceResourceCount") + if (serviceResourceCount >0 ){ + int progress = (resourceNum*100) / serviceResourceCount + execution.setVariable("progress", progress.toString() ) + } + execution.setVariable("operationStatus", resourceName ) + + }catch(Exception e){ + // try error in method block + String exceptionMessage = "Bpmn error encountered in CreateMobileAPNCustService flow. Unexpected Error from method preProcessDecomposeNextResource() - " + ex.getMessage() + utils.log("DEBUG", exceptionMessage, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + utils.log("INFO", "Exited " + method, isDebugEnabled) + } + /** + * post Decompose next resource to create request + */ + public void postProcessDecomposeNextResource(Execution execution){ + def method = getClass().getSimpleName() + '.postProcessDecomposeNextResource(' +'execution=' + execution.getId() +')' + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + utils.log("INFO","Entered " + method, isDebugEnabled) + utils.log("INFO", " ======== STARTED postProcessDecomposeNextResource Process ======== ", isDebugEnabled) + try{ + String resourceName = execution.getVariable(Prefix+"resourceName") + int resourceNum = execution.getVariable(Prefix+"nextServiceResource") + utils.log("DEBUG", "Current Resource count:"+ execution.getVariable(Prefix+"nextServiceResource"), isDebugEnabled) + + int resourceCount = execution.getVariable(Prefix+"serviceResourceCount") + utils.log("DEBUG", "Total Resource count:"+ execution.getVariable(Prefix+"serviceResourceCount"), isDebugEnabled) + + if (resourceNum < resourceCount) { + execution.setVariable(Prefix+"resourceFinish", false) + } + else { + execution.setVariable(Prefix+"resourceFinish", true) + } + + utils.log("DEBUG", "Resource Finished:"+ execution.getVariable(Prefix+"resourceFinish"), isDebugEnabled) + + if (resourceCount >0 ){ + int progress = (resourceNum*100) / resourceCount + + execution.setVariable("progress", progress.toString() ) + utils.log("DEBUG", "progress :"+ execution.getVariable("progress"), isDebugEnabled) + } + execution.setVariable("operationStatus", resourceName ) + + + }catch(Exception e){ + // try error in method block + String exceptionMessage = "Bpmn error encountered in CreateMobileAPNCustService flow. Unexpected Error from method postProcessDecomposeNextResource() - " + ex.getMessage() + utils.log("DEBUG", exceptionMessage, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + utils.log("INFO", "Exited " + method, isDebugEnabled) + } + /** + * prepare post Unkown Resource Type + */ + public void postOtherControllerType(Execution execution){ + def method = getClass().getSimpleName() + '.postOtherControllerType(' +'execution=' + execution.getId() +')' + def isDebugEnabled = execution.getVariable("isDebugEnabled") + utils.log("INFO","Entered " + method, isDebugEnabled) + + try{ + + String resourceName = execution.getVariable(Prefix+"resourceName") + String resourceType = execution.getVariable(Prefix+"resourceType") + String controllerType = execution.getVariable("controllerType") + + String msg = "Resource name: "+ resourceName + " resource Type: " + resourceType+ " controller Type: " + controllerType + " can not be processed n the workflow" + utils.log("DEBUG", msg, isDebugEnabled) + + }catch(Exception e){ + // try error in method block + String exceptionMessage = "Bpmn error encountered in DoCreateMobileAPNServiceInstance flow. Unexpected Error from method postOtherControllerType() - " + ex.getMessage() + utils.log("DEBUG", exceptionMessage, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + utils.log("INFO", "Exited " + method, isDebugEnabled) + } + + /** + * prepare delete parameters + */ + public void preSDNCResourceDelete(execution, resourceName){ + // we use resource instance ids for delete flow as resourceTemplateUUIDs + + def method = getClass().getSimpleName() + '.preSDNCResourceDelete(' +'execution=' + execution.getId() +')' + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + utils.log("INFO","Entered " + method, isDebugEnabled) + + utils.log("INFO", " ======== STARTED preSDNCResourceDelete Process ======== ", isDebugEnabled) + String networkResources = execution.getVariable("networkResources") + + + execution.setVariable("foundResource", false) + if (networkResources != null) { + def jsonSlurper = new JsonSlurper() + List relationShipList = jsonSlurper.parseText(networkResources) + relationShipList.each { + if(StringUtils.containsIgnoreCase(it.resourceType, resourceName)) { + String resourceInstanceUUID = it.resourceInstanceId + String resourceTemplateUUID = it.resourceInstanceId + execution.setVariable("resourceTemplateId", resourceTemplateUUID) + execution.setVariable("resourceInstanceId", resourceInstanceUUID) + execution.setVariable("resourceType", resourceName) + execution.setVariable("foundResource", true) + utils.log("INFO", "Delete Resource Info resourceTemplate Id :" + resourceTemplateUUID + " resourceInstanceId: " + resourceInstanceUUID + " resourceType: " + resourceName, isDebugEnabled) + } + } + } + utils.log("INFO", "Exited " + method, isDebugEnabled) + } + public void preProcessSDNCDelete (Execution execution) { + def method = getClass().getSimpleName() + '.preProcessSDNCDelete(' +'execution=' + execution.getId() +')' + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + utils.log("INFO","Entered " + method, isDebugEnabled) + utils.log("INFO"," ***** preProcessSDNCDelete *****", isDebugEnabled) + String msg = "" + + try { + def serviceInstanceId = execution.getVariable("serviceInstanceId") + def serviceInstanceName = execution.getVariable("serviceInstanceName") + def callbackURL = execution.getVariable("sdncCallbackUrl") + def requestId = execution.getVariable("msoRequestId") + def serviceId = execution.getVariable("productFamilyId") + def subscriptionServiceType = execution.getVariable("subscriptionServiceType") + def globalSubscriberId = execution.getVariable("globalSubscriberId") //globalCustomerId + + String serviceModelInfo = execution.getVariable("serviceModelInfo") + def modelInvariantUuid = "" + def modelVersion = "" + def modelUuid = "" + def modelName = "" + if (!isBlank(serviceModelInfo)) + { + modelInvariantUuid = jsonUtil.getJsonValue(serviceModelInfo, "modelInvariantUuid") + modelVersion = jsonUtil.getJsonValue(serviceModelInfo, "modelVersion") + modelUuid = jsonUtil.getJsonValue(serviceModelInfo, "modelUuid") + modelName = jsonUtil.getJsonValue(serviceModelInfo, "modelName") + + if (modelInvariantUuid == null) { + modelInvariantUuid = "" + } + if (modelVersion == null) { + modelVersion = "" + } + if (modelUuid == null) { + modelUuid = "" + } + if (modelName == null) { + modelName = "" + } + } + if (serviceInstanceName == null) { + serviceInstanceName = "" + } + if (serviceId == null) { + serviceId = "" + } + + def siParamsXml = execution.getVariable("siParamsXml") + def serviceType = execution.getVariable("serviceType") + if (serviceType == null) + { + serviceType = "" + } + + def sdncRequestId = UUID.randomUUID().toString() + + String sdncDelete = + """ + + ${sdncRequestId} + ${serviceInstanceId} + delete + service-topology-operation + ${callbackURL} + ${serviceType} + + + + ${requestId} + MSO + + + + DeleteServiceInstance + + + ${serviceId} + ${subscriptionServiceType} + + ${modelInvariantUuid} + ${modelUuid} + ${modelVersion} + ${modelName} + + ${serviceInstanceId} + + ${globalSubscriberId} + + + ${serviceInstanceName} + ${siParamsXml} + + + """ + + sdncDelete = utils.formatXml(sdncDelete) + def sdncRequestId2 = UUID.randomUUID().toString() + String sdncDeactivate = sdncDelete.replace(">delete<", ">deactivate<").replace(">${sdncRequestId}<", ">${sdncRequestId2}<") + execution.setVariable("sdncDelete", sdncDelete) + execution.setVariable("sdncDeactivate", sdncDeactivate) + utils.log("INFO","sdncDeactivate:\n" + sdncDeactivate, isDebugEnabled) + utils.log("INFO","sdncDelete:\n" + sdncDelete, isDebugEnabled) + + } catch (BpmnError e) { + throw e; + } catch(Exception ex) { + msg = "Exception in preProcessSDNCDelete. " + ex.getMessage() + utils.log("INFO", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Exception Occured in preProcessSDNCDelete.\n" + ex.getMessage()) + } + utils.log("INFO", "Exited " + method, isDebugEnabled) + } + + public void postProcessSDNCDelete(Execution execution, String response, String action) { + + def method = getClass().getSimpleName() + '.postProcessSDNCDelete(' +'execution=' + execution.getId() +')' + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + utils.log("INFO","Entered " + method, isDebugEnabled) + utils.log("INFO"," ***** postProcessSDNC " + action + " *****", isDebugEnabled) + String msg = "" + + /*try { + WorkflowException workflowException = execution.getVariable("WorkflowException") + boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") + utils.log("INFO", "SDNCResponse: " + response, isDebugEnabled) + utils.log("INFO", "workflowException: " + workflowException, isDebugEnabled) + + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) + sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) + if(execution.getVariable(Prefix + 'sdncResponseSuccess') == "true"){ + utils.log("INFO","Good response from SDNC Adapter for service-instance " + action + "response:\n" + response, isDebugEnabled) + + }else{ + msg = "Bad Response from SDNC Adapter for service-instance " + action + utils.log("INFO", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 3500, msg) + } + } catch (BpmnError e) { + throw e; + } catch(Exception ex) { + msg = "Exception in postProcessSDNC " + action + " Exception:" + ex.getMessage() + utils.log("INFO", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + }*/ + utils.log("INFO", "Exited " + method, isDebugEnabled) + } + + public void postProcessAAIDEL(Execution execution) { + def method = getClass().getSimpleName() + '.postProcessAAIDEL(' +'execution=' + execution.getId() +')' + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + utils.log("INFO","Entered " + method, isDebugEnabled) + utils.log("INFO"," ***** postProcessAAIDEL ***** ", isDebugEnabled) + String msg = "" + try { + String serviceInstanceId = execution.getVariable("serviceInstanceId") + boolean succInAAI = execution.getVariable("GENDS_SuccessIndicator") + if(succInAAI != true){ + msg = "Error deleting Service-instance in AAI" + serviceInstanceId + utils.log("INFO", msg, isDebugEnabled) + WorkflowException workflowException = execution.getVariable("WorkflowException") + utils.logAudit("workflowException: " + workflowException) + if(workflowException != null){ + exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage()) + } + else + { + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg) + } + } + } catch (BpmnError e) { + throw e; + } catch (Exception ex) { + msg = "Exception in DoDeleteE2EServiceInstance.postProcessAAIDEL. " + ex.getMessage() + utils.log("INFO", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + utils.log("INFO", "Exited " + method, isDebugEnabled) + } + /** + * Init the service Operation Status + */ + public void preUpdateServiceOperationStatus(Execution execution){ + def method = getClass().getSimpleName() + '.preUpdateServiceOperationStatus(' +'execution=' + execution.getId() +')' + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + utils.log("INFO","Entered " + method, isDebugEnabled) + + try{ + String serviceId = execution.getVariable("serviceInstanceId") + String operationId = execution.getVariable("operationId") + String serviceName = execution.getVariable("serviceInstanceName") + String operationType = "DELETE" + String userId = "" + String result = "processing" + String progress = execution.getVariable("progress") + utils.log("INFO", "progress: " + progress , isDebugEnabled) + if ("100".equalsIgnoreCase(progress)) + { + result = "finished" + } + String reason = "" + String operationContent = "Prepare service delete: " + execution.getVariable("operationStatus") + utils.log("INFO", "Generated new operation for Service Instance serviceId:" + serviceId + " operationId:" + operationId, isDebugEnabled) + serviceId = UriUtils.encode(serviceId,"UTF-8") + execution.setVariable("serviceInstanceId", serviceId) + execution.setVariable("operationId", operationId) + execution.setVariable("operationType", operationType) + + def dbAdapterEndpoint = execution.getVariable("URN_mso_adapters_openecomp_db_endpoint") + execution.setVariable("CVFMI_dbAdapterEndpoint", dbAdapterEndpoint) + utils.log("INFO", "DB Adapter Endpoint is: " + dbAdapterEndpoint, isDebugEnabled) + + execution.setVariable("URN_mso_openecomp_adapters_db_endpoint","http://mso.mso.testlab.openecomp.org:8080/dbadapters/RequestsDbAdapter") + + String payload = + """ + + + + ${serviceId} + ${operationId} + ${serviceName} + ${operationType} + ${userId} + ${result} + ${operationContent} + ${progress} + ${reason} + + + """ + + payload = utils.formatXml(payload) + execution.setVariable("CVFMI_updateServiceOperStatusRequest", payload) + utils.log("INFO", "Outgoing preUpdateServiceOperationStatus: \n" + payload, isDebugEnabled) + + + }catch(Exception e){ + utils.log("ERROR", "Exception Occured Processing preUpdateServiceOperationStatus. Exception is:\n" + e, isDebugEnabled) + execution.setVariable("CVFMI_ErrorResponse", "Error Occurred during preUpdateServiceOperationStatus Method:\n" + e.getMessage()) + } + utils.log("INFO", "======== COMPLETED preUpdateServiceOperationStatus Process ======== ", isDebugEnabled) + utils.log("INFO", "Exited " + method, isDebugEnabled) + } + + public void preInitResourcesOperStatus(Execution execution){ + def method = getClass().getSimpleName() + '.preInitResourcesOperStatus(' +'execution=' + execution.getId() +')' + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + utils.log("INFO","Entered " + method, isDebugEnabled) + + utils.log("INFO", " ======== STARTED preInitResourcesOperStatus Process ======== ", isDebugEnabled) + String msg="" + try{ + String serviceId = execution.getVariable("serviceInstanceId") + String operationId = execution.getVariable("operationId") + String operationType = "DELETE" + String resourceTemplateUUIDs = "" + String result = "processing" + String progress = "0" + String reason = "" + String operationContent = "Prepare service delete" + utils.log("INFO", "Generated new operation for Service Instance serviceId:" + serviceId + " operationId:" + operationId + " operationType:" + operationType, isDebugEnabled) + serviceId = UriUtils.encode(serviceId,"UTF-8") + execution.setVariable("serviceInstanceId", serviceId) + execution.setVariable("operationId", operationId) + execution.setVariable("operationType", operationType) + + String serviceRelationShip = execution.getVariable("serviceRelationShip") + utils.log("INFO", "serviceRelationShip: " + serviceRelationShip, isDebugEnabled) + if (! isBlank(serviceRelationShip)) { + def jsonSlurper = new JsonSlurper() + def jsonOutput = new JsonOutput() + List relationShipList = jsonSlurper.parseText(serviceRelationShip) + + if (relationShipList != null) { + relationShipList.each { + resourceTemplateUUIDs = resourceTemplateUUIDs + it.resourceInstanceId + ":" + } + } + } + def dbAdapterEndpoint = "http://mso.mso.testlab.openecomp.org:8080/dbadapters/RequestsDbAdapter" + execution.setVariable("CVFMI_dbAdapterEndpoint", dbAdapterEndpoint) + utils.log("INFO", "DB Adapter Endpoint is: " + dbAdapterEndpoint, isDebugEnabled) + + String payload = + """ + + + + ${serviceId} + ${operationId} + ${operationType} + ${resourceTemplateUUIDs} + + + """ + + payload = utils.formatXml(payload) + execution.setVariable("CVFMI_initResOperStatusRequest", payload) + utils.log("INFO", "Outgoing initResourceOperationStatus: \n" + payload, isDebugEnabled) + utils.logAudit("DoCustomDeleteE2EServiceInstanceV2 Outgoing initResourceOperationStatus Request: " + payload) + + }catch (BpmnError e) { + throw e; + } catch (Exception ex) { + msg = "Exception in DoCustomDeleteE2EServiceInstanceV2.preInitResourcesOperStatus. " + ex.getMessage() + utils.log("INFO", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + utils.log("INFO", "Exited " + method, isDebugEnabled) + } + + + + /** + * prepare delete parameters + */ + public void preProcessVFCResourceDelete(execution){ + // we use resource instance ids for delete flow as resourceTemplateUUIDs + + def method = getClass().getSimpleName() + '.preProcessVFCResourceDelete(' +'execution=' + execution.getId() +')' + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + utils.log("INFO","Entered " + method, isDebugEnabled) + + utils.log("INFO", " ======== STARTED preProcessVFCResourceDelete Process ======== ", isDebugEnabled) + try{ + String serviceResource = execution.getVariable("serviceResource") + utils.log("INFO", "serviceResource : " + serviceResource, isDebugEnabled) + + String resourceInstanceId = execution.getVariable("resourceInstanceId") + utils.log("INFO", "resourceInstanceId : " + resourceInstanceId, isDebugEnabled) + + execution.setVariable("resourceTemplateId", resourceInstanceId) + utils.log("INFO", "resourceTemplateId : " + resourceInstanceId, isDebugEnabled) + + String resourceType = execution.getVariable("resourceType") + utils.log("INFO", "resourceType : " + resourceType, isDebugEnabled) + + + String resourceName = execution.getVariable(Prefix+"resourceName") + if (isBlank(resourceName)){ + resourceName = resourceInstanceId + } + execution.setVariable("resourceName", resourceName) + utils.log("INFO", "resource Name : " + resourceName, isDebugEnabled) + + utils.log("INFO", "Delete Resource Info: resourceInstanceId :" + resourceInstanceId + " resourceTemplateId: " + resourceInstanceId + " resourceType: " + resourceType, isDebugEnabled) + }catch (BpmnError e) { + throw e; + } catch (Exception ex) { + msg = "Exception in DoDeleteE2EServiceInstance.preProcessVFCResourceDelete. " + ex.getMessage() + utils.log("INFO", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + utils.log("INFO", "Exited " + method, isDebugEnabled) + } + + public void postProcessVFCDelete(Execution execution, String response, String action) { + def method = getClass().getSimpleName() + '.postProcessVFCDelete(' +'execution=' + execution.getId() +')' + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + utils.log("INFO","Entered " + method, isDebugEnabled) + + utils.log("INFO", " ======== STARTED postProcessVFCDelete Process ======== ", isDebugEnabled) + try{ + + }catch (BpmnError e) { + throw e; + } catch (Exception ex) { + msg = "Exception in DoDeleteE2EServiceInstance.postProcessVFCDelete. " + ex.getMessage() + utils.log("INFO", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + utils.log("INFO", "Exited " + method, isDebugEnabled) + } +} + \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateE2EServiceInstanceV2.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateE2EServiceInstanceV2.bpmn new file mode 100644 index 0000000000..90636f61fb --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateE2EServiceInstanceV2.bpmn @@ -0,0 +1,1051 @@ + + + + + SequenceFlow_1 + + + + SequenceFlow_1 + SequenceFlow_2 + + + + + + + + + + + + + + + SequenceFlow_2 + SequenceFlow_4 + + + + + + + + + + + + + SequenceFlow_0zmz5am + SequenceFlow_129ih1g + + + + + SequenceFlow_0tgrn11 + + + + SequenceFlow_1xzgv5k + + + + + + + + + + SequenceFlow_1lqktwf + SequenceFlow_0eumzpf + + + + + SequenceFlow_0tgrn11 + SequenceFlow_1lqktwf + + + + + SequenceFlow_0eumzpf + SequenceFlow_1xzgv5k + + + + + + SequenceFlow_4 + SequenceFlow_10aubhh + + + + SequenceFlow_129ih1g + SequenceFlow_03fabby + + + + + + SequenceFlow_13l7ffp + SequenceFlow_0gorww6 + + + + SequenceFlow_1wf52w6 + SequenceFlow_1t9tmp4 + SequenceFlow_14ef6wp + SequenceFlow_163tmnq + + + + + + + SequenceFlow_1t9tmp4 + SequenceFlow_1t4cc7w + + + + + + + + + + + + + + + + + SequenceFlow_1a1du22 + SequenceFlow_1p99k36 + + + + SequenceFlow_0cyffv0 + SequenceFlow_07q8ra0 + + + + SequenceFlow_06byir6 + SequenceFlow_0ylmq2b + + + + SequenceFlow_0vey6x4 + SequenceFlow_0br9juy + + + + SequenceFlow_0ylmq2b + SequenceFlow_07q8ra0 + SequenceFlow_0gxsqsa + SequenceFlow_1yhd9dp + + + + + SequenceFlow_1rhn48b + SequenceFlow_1mbrbsc + SequenceFlow_13l7ffp + SequenceFlow_1fq4qzy + + + + SequenceFlow_1r1hl23 + SequenceFlow_1ct6u3o + + + + SequenceFlow_1vio1tn + SequenceFlow_07pkpa0 + + + SequenceFlow_0br9juy + SequenceFlow_06byir6 + + + SequenceFlow_0cnuo36 + SequenceFlow_1lkpfe2 + + + + SequenceFlow_1t4cc7w + SequenceFlow_1a1du22 + SequenceFlow_14jy44g + + + + SequenceFlow_1p99k36 + SequenceFlow_14jy44g + SequenceFlow_0cyffv0 + + + + + + + + + + SequenceFlow_14ef6wp + SequenceFlow_0gxsqsa + + + + + + SequenceFlow_10aubhh + + + + SequenceFlow_0zmz5am + + + + + + SequenceFlow_1rhn48b + + + + + SequenceFlow_1ct6u3o + + + + + SequenceFlow_1rebkae + + + + SequenceFlow_1lkpfe2 + + + + + + + SequenceFlow_1fq4qzy + + + + SequenceFlow_10jgs3j + SequenceFlow_1wf52w6 + + + + + SequenceFlow_1yhd9dp + SequenceFlow_0uj9myy + + + + + + SequenceFlow_03fabby + + + + SequenceFlow_0e8oxe4 + + + + + SequenceFlow_07pkpa0 + SequenceFlow_01zluif + SequenceFlow_0vey6x4 + + + + + + + + SequenceFlow_163tmnq + SequenceFlow_01zluif + SequenceFlow_1vio1tn + + + + + + + SequenceFlow_0e8oxe4 + SequenceFlow_1sata7n + + + + + + + ${URN_mso_openecomp_adapters_db_endpoint} + + + application/soap+xml + Basic QlBFTENsaWVudDpwYXNzd29yZDEk + + + ${CVFMI_updateServiceOperStatusRequest} + POST + ${statusCode} + ${response} + + http-connector + + + SequenceFlow_1sata7n + SequenceFlow_0x0jvs1 + + + + + SequenceFlow_1rebkae + SequenceFlow_0gr3l25 + + + + + + + ${URN_mso_openecomp_adapters_db_endpoint} + + + application/soap+xml + Basic QlBFTENsaWVudDpwYXNzd29yZDEk + + + ${CVFMI_updateServiceOperStatusRequest} + POST + ${statusCode} + ${response} + + http-connector + + + SequenceFlow_0gr3l25 + SequenceFlow_0cnuo36 + + + + + SequenceFlow_0uj9myy + SequenceFlow_037rvnb + + + + + + + + ${URN_mso_openecomp_adapters_db_endpoint} + + + application/soap+xml + Basic QlBFTENsaWVudDpwYXNzd29yZDEk + + + ${CVFMI_updateServiceOperStatusRequest} + POST + ${statusCode} + ${response} + + http-connector + + + SequenceFlow_037rvnb + SequenceFlow_1mbrbsc + + + + SequenceFlow_0x0jvs1 + SequenceFlow_0aylb6e + + + + + + + + ${CVFMI_dbAdapterEndpoint} + + + application/soap+xml + Basic QlBFTENsaWVudDpwYXNzd29yZDEk + + + ${CVFMI_initResOperStatusRequest} + POST + ${statusCode} + ${response} + + http-connector + + + SequenceFlow_0aylb6e + SequenceFlow_1r1hl23 + + + + + + + ${URN_mso_openecomp_adapters_db_endpoint} + + + application/soap+xml + Basic QlBFTENsaWVudDpwYXNzd29yZDEk + + + ${CVFMI_updateServiceOperStatusRequest} + POST + ${statusCode} + ${response} + + http-connector + + + SequenceFlow_01oo8ar + SequenceFlow_10jgs3j + + + + SequenceFlow_0gorww6 + SequenceFlow_01oo8ar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCustomDeleteE2EServiceInstanceV2.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCustomDeleteE2EServiceInstanceV2.bpmn new file mode 100644 index 0000000000..f66a3c6a42 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCustomDeleteE2EServiceInstanceV2.bpmn @@ -0,0 +1,956 @@ + + + + + SequenceFlow_0vz7cd9 + + + SequenceFlow_0vz7cd9 + SequenceFlow_11e6bfy + + + + SequenceFlow_06tonva + + + + + + + + + + + + + SequenceFlow_0t5f2dt + SequenceFlow_0g6bxqw + + + SequenceFlow_188ejvu + SequenceFlow_00a3ijv + + + + SequenceFlow_0g6bxqw + SequenceFlow_0e7inkl + + + + + SequenceFlow_1921mo3 + + + + SequenceFlow_18vlzfo + + + SequenceFlow_1921mo3 + SequenceFlow_18vlzfo + + + + + + + + + + + SequenceFlow_1931m8u + SequenceFlow_17b01zs + + + + SequenceFlow_1w2n8dn + SequenceFlow_09z6zl7 + + + + SequenceFlow_1jfyo1x + SequenceFlow_1t1mg6y + + + + + + + SequenceFlow_1bx4es4 + SequenceFlow_1wnkgpx + + + + + + + + + + + + + + SequenceFlow_1wnkgpx + SequenceFlow_1931m8u + + + SequenceFlow_0a1q5fw + SequenceFlow_0rpu756 + + + + + SequenceFlow_1lv9vmb + SequenceFlow_16r9z75 + + + + SequenceFlow_0m7ks9t + SequenceFlow_1g4djgh + + + SequenceFlow_0akcnw7 + SequenceFlow_0uc2beq + + + + + + + + + + + + + + SequenceFlow_11e6bfy + SequenceFlow_188ejvu + + + + SequenceFlow_1qzxy2i + + + + SequenceFlow_1jfyo1x + + + + + + SequenceFlow_09z6zl7 + + + + + SequenceFlow_0homduu + + + + + SequenceFlow_0t5f2dt + + + + + SequenceFlow_0homduu + SequenceFlow_0eoibq3 + SequenceFlow_0n7qeqt + SequenceFlow_13c2v9z + + + + SequenceFlow_0n7qeqt + SequenceFlow_1a5ki3p + + + + + SequenceFlow_17b01zs + SequenceFlow_0gxv0wp + + + + + SequenceFlow_13c2v9z + + + + + + + SequenceFlow_1t1mg6y + SequenceFlow_0a1q5fw + SequenceFlow_1fac57w + + + + + + + SequenceFlow_0rpu756 + SequenceFlow_1fac57w + SequenceFlow_1lv9vmb + + + + + SequenceFlow_16r9z75 + SequenceFlow_0m7ks9t + SequenceFlow_00knko8 + + + + + + + SequenceFlow_1g4djgh + SequenceFlow_00knko8 + SequenceFlow_0akcnw7 + SequenceFlow_15pzf5n + + + + + + + SequenceFlow_033eqeg + + + + + SequenceFlow_00a3ijv + + + + + SequenceFlow_18wibmi + SequenceFlow_11405m9 + + + + + SequenceFlow_033eqeg + SequenceFlow_1sm5x5e + + + + + + + ${URN_mso_openecomp_adapters_db_endpoint} + + + application/soap+xml + Basic QlBFTENsaWVudDpwYXNzd29yZDEk + + + ${CVFMI_updateServiceOperStatusRequest} + POST + ${statusCode} + ${response} + + http-connector + + + SequenceFlow_1sm5x5e + SequenceFlow_18wibmi + + + + + SequenceFlow_0e7inkl + SequenceFlow_0l4qcge + + + + + + + ${URN_mso_openecomp_adapters_db_endpoint} + + + application/soap+xml + Basic QlBFTENsaWVudDpwYXNzd29yZDEk + + + ${CVFMI_updateServiceOperStatusRequest} + POST + ${statusCode} + ${response} + + http-connector + + + SequenceFlow_0l4qcge + SequenceFlow_06tonva + + + + + SequenceFlow_0gxv0wp + SequenceFlow_1i96ytk + + + + + + + + ${URN_mso_openecomp_adapters_db_endpoint} + + + application/soap+xml + Basic QlBFTENsaWVudDpwYXNzd29yZDEk + + + ${CVFMI_updateServiceOperStatusRequest} + POST + ${statusCode} + ${response} + + http-connector + + + SequenceFlow_1i96ytk + SequenceFlow_0eoibq3 + + + + SequenceFlow_1a5ki3p + SequenceFlow_1oo4g4h + + + + + SequenceFlow_0uc2beq + SequenceFlow_15pzf5n + SequenceFlow_1w2n8dn + + + + + + + + ${URN_mso_openecomp_adapters_db_endpoint} + + + application/soap+xml + Basic QlBFTENsaWVudDpwYXNzd29yZDEk + + + ${CVFMI_updateServiceOperStatusRequest} + POST + ${statusCode} + ${response} + + http-connector + + + SequenceFlow_1oo4g4h + SequenceFlow_1bx4es4 + + + + SequenceFlow_11405m9 + SequenceFlow_15d5odq + + + + + + + + ${CVFMI_dbAdapterEndpoint} + + + application/soap+xml + Basic QlBFTENsaWVudDpwYXNzd29yZDEk + + + ${CVFMI_initResOperStatusRequest} + POST + ${statusCode} + ${response} + + http-connector + + + SequenceFlow_15d5odq + SequenceFlow_1qzxy2i + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit 1.2.3-korg