-/*-\r
- * ============LICENSE_START=======================================================\r
- * OPENECOMP - MSO\r
- * ================================================================================\r
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
- * ================================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- * ============LICENSE_END=========================================================\r
- */\r
-package org.openecomp.mso.bpmn.infrastructure.scripts;\r
-\r
-import static org.apache.commons.lang3.StringUtils.*;\r
-import groovy.xml.XmlUtil\r
-import groovy.json.*\r
-\r
-import org.openecomp.mso.bpmn.core.json.JsonUtils\r
-import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor\r
-import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil\r
-import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils\r
-import org.openecomp.mso.bpmn.common.scripts.VidUtils\r
-import org.openecomp.mso.bpmn.core.WorkflowException\r
-import org.openecomp.mso.rest.APIResponse;\r
-import org.openecomp.mso.rest.RESTClient\r
-import org.openecomp.mso.rest.RESTConfig\r
-\r
-import java.util.UUID;\r
-import javax.xml.parsers.DocumentBuilder\r
-import javax.xml.parsers.DocumentBuilderFactory\r
-\r
-import org.camunda.bpm.engine.delegate.BpmnError\r
-import org.camunda.bpm.engine.runtime.Execution\r
-import org.json.JSONObject;\r
-import org.apache.commons.lang3.*\r
-import org.apache.commons.codec.binary.Base64;\r
-import org.springframework.web.util.UriUtils;\r
-import org.w3c.dom.Document\r
-import org.w3c.dom.Element\r
-import org.w3c.dom.Node\r
-import org.w3c.dom.NodeList\r
-import org.xml.sax.InputSource\r
-\r
-/**\r
- * This groovy class supports the <class>DoDeleteServiceInstance.bpmn</class> process.\r
- * \r
- * Inputs:\r
- * @param - msoRequestId\r
- * @param - globalSubscriberId - O\r
- * @param - subscriptionServiceType - O\r
- * @param - serviceInstanceId\r
- * @param - serviceInstanceName - O\r
- * @param - serviceModelInfo - O\r
- * @param - productFamilyId\r
- * @param - sdncVersion \r
- * @param - failNotFound - TODO\r
- * @param - serviceInputParams - TODO\r
- *\r
- * Outputs:\r
- * @param - WorkflowException\r
- * \r
- * Rollback - Deferred\r
- */\r
-public class DoDeleteServiceInstance extends AbstractServiceTaskProcessor {\r
-\r
- String Prefix="DDELSI_"\r
- ExceptionUtil exceptionUtil = new ExceptionUtil()\r
- JsonUtils jsonUtil = new JsonUtils()\r
- VidUtils vidUtils = new VidUtils()\r
-\r
- public void preProcessRequest (Execution execution) {\r
- def isDebugEnabled = execution.getVariable("isDebugLogEnabled")\r
- utils.log("DEBUG"," ***** preProcessRequest *****", isDebugEnabled)\r
- String msg = ""\r
-\r
- try {\r
- String requestId = execution.getVariable("msoRequestId")\r
- execution.setVariable("prefix",Prefix)\r
-\r
- //Inputs\r
- //requestDetails.subscriberInfo. for AAI GET & PUT & SDNC assignToplology\r
- String globalSubscriberId = execution.getVariable("globalSubscriberId") //globalCustomerId\r
- if (globalSubscriberId == null)\r
- {\r
- execution.setVariable("globalSubscriberId", "")\r
- }\r
-\r
- //requestDetails.requestParameters. for AAI PUT & SDNC assignTopology\r
- String subscriptionServiceType = execution.getVariable("subscriptionServiceType")\r
- if (subscriptionServiceType == null)\r
- {\r
- execution.setVariable("subscriptionServiceType", "")\r
- }\r
-\r
- //Generated in parent for AAI PUT\r
- String serviceInstanceId = execution.getVariable("serviceInstanceId")\r
- if (isBlank(serviceInstanceId)){\r
- msg = "Input serviceInstanceId is null"\r
- utils.log("DEBUG", msg, isDebugEnabled)\r
- exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)\r
- }\r
-\r
- String sdncCallbackUrl = execution.getVariable('URN_mso_workflow_sdncadapter_callback')\r
- if (isBlank(sdncCallbackUrl)) {\r
- msg = "URN_mso_workflow_sdncadapter_callback is null"\r
- utils.log("DEBUG", msg, isDebugEnabled)\r
- exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)\r
- }\r
- execution.setVariable("sdncCallbackUrl", sdncCallbackUrl)\r
- utils.log("DEBUG","SDNC Callback URL: " + sdncCallbackUrl, isDebugEnabled)\r
-\r
- } catch (BpmnError e) {\r
- throw e;\r
- } catch (Exception ex){\r
- msg = "Exception in preProcessRequest " + ex.getMessage()\r
- utils.log("DEBUG", msg, isDebugEnabled)\r
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)\r
- }\r
- utils.log("DEBUG"," ***** Exit preProcessRequest *****", isDebugEnabled)\r
- }\r
-\r
- public void preProcessSDNCDelete (Execution execution) {\r
- def isDebugEnabled = execution.getVariable("isDebugLogEnabled")\r
- utils.log("DEBUG"," ***** preProcessSDNCDelete *****", isDebugEnabled)\r
- String msg = ""\r
-\r
- try {\r
- /*\r
- String uuid = execution.getVariable('testReqId') // for junits\r
- if(uuid==null){\r
- uuid = execution.getVariable("msoRequestId") + "-" + System.currentTimeMillis()\r
- }\r
- */\r
- def serviceInstanceId = execution.getVariable("serviceInstanceId")\r
- def serviceInstanceName = execution.getVariable("serviceInstanceName")\r
- def callbackURL = execution.getVariable("sdncCallbackUrl")\r
- def requestId = execution.getVariable("msoRequestId")\r
- def serviceId = execution.getVariable("productFamilyId")\r
- def subscriptionServiceType = execution.getVariable("subscriptionServiceType")\r
- def globalSubscriberId = execution.getVariable("globalSubscriberId") //globalCustomerId\r
-\r
- String serviceModelInfo = execution.getVariable("serviceModelInfo")\r
- def modelInvariantId = ""\r
- def modelVersion = ""\r
- def modelUUId = ""\r
- def modelName = ""\r
- if (!isBlank(serviceModelInfo))\r
- {\r
- modelInvariantId = jsonUtil.getJsonValue(serviceModelInfo, "modelInvariantId")\r
- modelVersion = jsonUtil.getJsonValue(serviceModelInfo, "modelVersion")\r
- modelUUId = jsonUtil.getJsonValue(serviceModelInfo, "modelVersionId")\r
- modelName = jsonUtil.getJsonValue(serviceModelInfo, "modelName")\r
- \r
- if (modelInvariantId == null) {\r
- modelInvariantId = ""\r
- }\r
- if (modelVersion == null) {\r
- modelVersion = ""\r
- }\r
- if (modelUUId == null) {\r
- modelUUId = ""\r
- }\r
- if (modelName == null) {\r
- modelName = ""\r
- }\r
- }\r
- if (serviceInstanceName == null) {\r
- serviceInstanceName = ""\r
- }\r
- if (serviceId == null) {\r
- serviceId = ""\r
- }\r
- \r
- def sdncRequestId = UUID.randomUUID().toString()\r
-\r
- String sdncDelete =\r
- """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.openecomp/mso/request/types/v1"\r
- xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"\r
- xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1">\r
- <sdncadapter:RequestHeader>\r
- <sdncadapter:RequestId>${sdncRequestId}</sdncadapter:RequestId>\r
- <sdncadapter:SvcInstanceId>${serviceInstanceId}</sdncadapter:SvcInstanceId>\r
- <sdncadapter:SvcAction>delete</sdncadapter:SvcAction>\r
- <sdncadapter:SvcOperation>service-topology-operation</sdncadapter:SvcOperation>\r
- <sdncadapter:CallbackUrl>${callbackURL}</sdncadapter:CallbackUrl>\r
- </sdncadapter:RequestHeader>\r
- <sdncadapterworkflow:SDNCRequestData>\r
- <request-information>\r
- <request-id>${requestId}</request-id>\r
- <source>MSO</source>\r
- <notification-url/>\r
- <order-number/>\r
- <order-version/>\r
- <request-action>DeleteServiceInstance</request-action>\r
- </request-information>\r
- <service-information>\r
- <service-id>${serviceId}</service-id>\r
- <subscription-service-type>${subscriptionServiceType}</subscription-service-type>\r
- <ecomp-model-information>\r
- <model-invariant-uuid>${modelInvariantId}</model-invariant-uuid>\r
- <model-uuid>${modelUUId}</model-uuid>\r
- <model-version>${modelVersion}</model-version>\r
- <model-name>${modelName}</model-name>\r
- </ecomp-model-information>\r
- <service-instance-id>${serviceInstanceId}</service-instance-id>\r
- <subscriber-name/>\r
- <global-customer-id>${globalSubscriberId}</global-customer-id>\r
- </service-information>\r
- <service-request-input>\r
- <service-instance-name>${serviceInstanceName}</service-instance-name>\r
- </service-request-input>\r
- </sdncadapterworkflow:SDNCRequestData>\r
- </sdncadapterworkflow:SDNCAdapterWorkflowRequest>"""\r
-\r
- utils.log("DEBUG","sdncDelete:\n" + sdncDelete, isDebugEnabled)\r
- sdncDelete = utils.formatXml(sdncDelete)\r
- execution.setVariable("sdncDelete", sdncDelete)\r
- utils.logAudit("sdncDelete: " + sdncDelete)\r
-\r
-\r
- } catch (BpmnError e) {\r
- throw e;\r
- } catch(Exception ex) {\r
- msg = "Exception in preProcessSDNCDelete. " + ex.getMessage()\r
- utils.log("DEBUG", msg, isDebugEnabled)\r
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Exception Occured in preProcessSDNCDelete.\n" + ex.getMessage())\r
- }\r
- utils.log("DEBUG"," *****Exit preProcessSDNCDelete *****", isDebugEnabled)\r
- }\r
-\r
- public void postProcessSDNCDelete(Execution execution) {\r
-\r
- def isDebugEnabled=execution.getVariable("isDebugLogEnabled")\r
- utils.log("DEBUG"," ***** postProcessSDNCDelete ***** ", isDebugEnabled)\r
- String msg = ""\r
-\r
- try {\r
- WorkflowException workflowException = execution.getVariable("WorkflowException")\r
- utils.logAudit("workflowException: " + workflowException)\r
-\r
- boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator")\r
- String response = execution.getVariable("sdncAdapterResponse")\r
- utils.logAudit("SDNCResponse: " + response)\r
-\r
- SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)\r
- sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)\r
-\r
- if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){\r
- utils.log("DEBUG","Good response from SDNC Adapter for service-instance topology assign: \n" + response, isDebugEnabled)\r
-\r
- }else{\r
- msg = "Bad Response from SDNC Adapter for service-instance delete"\r
- utils.log("DEBUG", msg, isDebugEnabled)\r
- exceptionUtil.buildAndThrowWorkflowException(execution, 3500, msg)\r
- }\r
- } catch (BpmnError e) {\r
- throw e;\r
- } catch(Exception ex) {\r
- msg = "Exception in postProcessSDNCDelete. " + ex.getMessage()\r
- utils.log("DEBUG", msg, isDebugEnabled)\r
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Exception Occured in preProcessSDNCDelete.\n" + ex.getMessage())\r
- }\r
- utils.log("DEBUG"," *** Exit postProcessSDNCDelete *** ", isDebugEnabled)\r
- }\r
-\r
- public void postProcessAAIGET(Execution execution) {\r
- def isDebugEnabled=execution.getVariable("isDebugLogEnabled")\r
- utils.log("DEBUG"," ***** postProcessAAIGET ***** ", isDebugEnabled)\r
- String msg = ""\r
-\r
- try {\r
-\r
- String serviceInstanceId = execution.getVariable("serviceInstanceId")\r
- boolean foundInAAI = execution.getVariable("GENGS_FoundIndicator")\r
-\r
- if(foundInAAI == true){\r
- utils.log("DEBUG","Found Service-instance in AAI", isDebugEnabled)\r
-\r
- //Extract GlobalSubscriberId\r
- String siRelatedLink = execution.getVariable("GENGS_siResourceLink")\r
- if (isBlank(siRelatedLink))\r
- {\r
- msg = "Could not retrive ServiceInstance data from AAI to delete id:" + serviceInstanceId\r
- utils.log("DEBUG", msg, isDebugEnabled)\r
- exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)\r
- }\r
- else\r
- {\r
- utils.log("DEBUG","Found Service-instance in AAI. link: " + siRelatedLink, isDebugEnabled)\r
- String globalSubscriberId = execution.getVariable("globalSubscriberId")\r
- if(isBlank(globalSubscriberId)){\r
- int custStart = siRelatedLink.indexOf("customer/")\r
- int custEnd = siRelatedLink.indexOf("/service-subscriptions")\r
- globalSubscriberId = siRelatedLink.substring(custStart + 9, custEnd)\r
- execution.setVariable("globalSubscriberId", globalSubscriberId)\r
- }\r
-\r
- //Extract Service Type if not provided on request\r
- String serviceType = execution.getVariable("subscriptionServiceType")\r
- if(isBlank(serviceType)){\r
- int serviceStart = siRelatedLink.indexOf("service-subscription/")\r
- int serviceEnd = siRelatedLink.indexOf("/service-instances/")\r
- String serviceTypeEncoded = siRelatedLink.substring(serviceStart + 21, serviceEnd)\r
- serviceType = UriUtils.decode(serviceTypeEncoded, "UTF-8")\r
- execution.setVariable("subscriptionServiceType", serviceType)\r
- }\r
-\r
- if (isBlank(globalSubscriberId) || isBlank(serviceType))\r
- {\r
- msg = "Could not retrive global-customer-id & service-type from AAI to delete id:" + serviceInstanceId\r
- utils.log("DEBUG", msg, isDebugEnabled)\r
- exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)\r
- }\r
- }\r
-\r
- String siData = execution.getVariable("GENGS_service")\r
- utils.log("DEBUG", "SI Data", isDebugEnabled)\r
- if (isBlank(siData))\r
- {\r
- msg = "Could not retrive ServiceInstance data from AAI to delete id:" + serviceInstanceId\r
- utils.log("DEBUG", msg, isDebugEnabled)\r
- exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)\r
- }\r
- else\r
- {\r
- utils.log("DEBUG", "SI Data" + siData, isDebugEnabled)\r
- //Confirm there are no related service instances (vnf/network or volume)\r
- if (utils.nodeExists(siData, "relationship-list")) {\r
- utils.log("DEBUG", "SI Data relationship-list exists:", isDebugEnabled)\r
- InputSource source = new InputSource(new StringReader(siData));\r
- DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();\r
- DocumentBuilder docBuilder = docFactory.newDocumentBuilder()\r
- Document serviceXml = docBuilder.parse(source)\r
-\r
- NodeList nodeList = serviceXml.getElementsByTagName("relationship")\r
- for (int x = 0; x < nodeList.getLength(); x++) {\r
- Node node = nodeList.item(x)\r
- if (node.getNodeType() == Node.ELEMENT_NODE) {\r
- Element eElement = (Element) node\r
- def e = eElement.getElementsByTagName("related-to").item(0).getTextContent()\r
- if(e.equals("generic-vnf") || e.equals("l3-network")){\r
- utils.log("DEBUG", "ServiceInstance still has relationship(s) to generic-vnfs or l3-networks", isDebugEnabled)\r
- execution.setVariable("siInUse", true)\r
- //there are relationship dependencies to this Service Instance\r
- msg = " Stopped deleting Service Instance, it has dependencies. Service instance id: " + serviceInstanceId\r
- utils.log("DEBUG", msg, isDebugEnabled)\r
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg)\r
- }else{\r
- utils.log("DEBUG", "Relationship NOT related to OpenStack", isDebugEnabled)\r
- }\r
- }\r
- }\r
- }\r
- }\r
- }else{\r
- boolean succInAAI = execution.getVariable("GENGS_SuccessIndicator")\r
- if(succInAAI != true){\r
- utils.log("DEBUG","Error getting Service-instance from AAI", + serviceInstanceId, isDebugEnabled)\r
- WorkflowException workflowException = execution.getVariable("WorkflowException")\r
- utils.logAudit("workflowException: " + workflowException)\r
- if(workflowException != null){\r
- exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage())\r
- }\r
- else\r
- {\r
- msg = "Failure in postProcessAAIGET GENGS_SuccessIndicator:" + succInAAI\r
- utils.log("DEBUG", msg, isDebugEnabled)\r
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg)\r
- }\r
- }\r
- utils.log("DEBUG","Service-instance NOT found in AAI. Silent Success", isDebugEnabled)\r
- }\r
- } catch (BpmnError e) {\r
- throw e;\r
- } catch (Exception ex) {\r
- msg = "Exception in DoDeleteServiceInstance.postProcessAAIGET. " + ex.getMessage()\r
- utils.log("DEBUG", msg, isDebugEnabled)\r
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)\r
- }\r
- utils.log("DEBUG"," *** Exit postProcessAAIGET *** ", isDebugEnabled)\r
- }\r
- \r
- public void postProcessAAIDEL(Execution execution) {\r
- def isDebugEnabled=execution.getVariable("isDebugLogEnabled")\r
- utils.log("DEBUG"," ***** postProcessAAIDEL ***** ", isDebugEnabled)\r
- String msg = ""\r
- try {\r
- String serviceInstanceId = execution.getVariable("serviceInstanceId")\r
- boolean succInAAI = execution.getVariable("GENDS_SuccessIndicator")\r
- if(succInAAI != true){\r
- msg = "Error deleting Service-instance in AAI" + serviceInstanceId\r
- utils.log("DEBUG", msg, isDebugEnabled)\r
- WorkflowException workflowException = execution.getVariable("WorkflowException")\r
- utils.logAudit("workflowException: " + workflowException)\r
- if(workflowException != null){\r
- exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage())\r
- }\r
- else\r
- {\r
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg)\r
- }\r
- }\r
- } catch (BpmnError e) {\r
- throw e;\r
- } catch (Exception ex) {\r
- msg = "Exception in DoDeleteServiceInstance.postProcessAAIDEL. " + ex.getMessage()\r
- utils.log("DEBUG", msg, isDebugEnabled)\r
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)\r
- }\r
- utils.log("DEBUG"," *** Exit postProcessAAIDEL *** ", isDebugEnabled)\r
- }\r
-}\r
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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.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 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.delegate.DelegateExecution
+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
+
+/**
+ * This groovy class supports the <class>DoDeleteServiceInstance.bpmn</class> process.
+ *
+ * Inputs:
+ * @param - msoRequestId
+ * @param - globalSubscriberId - O
+ * @param - subscriptionServiceType - O
+ * @param - serviceInstanceId
+ * @param - serviceInstanceName - O
+ * @param - serviceModelInfo - O
+ * @param - productFamilyId
+ * @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 DoDeleteServiceInstance extends AbstractServiceTaskProcessor {
+
+ String Prefix="DDELSI_"
+ ExceptionUtil exceptionUtil = new ExceptionUtil()
+ JsonUtils jsonUtil = new JsonUtils()
+
+ public void preProcessRequest (DelegateExecution execution) {
+ def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
+ utils.log("DEBUG"," ***** 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 subscriptionServiceType = execution.getVariable("subscriptionServiceType")
+ if (subscriptionServiceType == null)
+ {
+ execution.setVariable("subscriptionServiceType", "")
+ }
+
+ //Generated in parent for AAI PUT
+ String serviceInstanceId = execution.getVariable("serviceInstanceId")
+ if (isBlank(serviceInstanceId)){
+ msg = "Input serviceInstanceId is null"
+ utils.log("DEBUG", 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("DEBUG", msg, isDebugEnabled)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
+ }
+ execution.setVariable("sdncCallbackUrl", sdncCallbackUrl)
+ utils.log("DEBUG","SDNC Callback URL: " + sdncCallbackUrl, isDebugEnabled)
+
+ StringBuilder sbParams = new StringBuilder()
+ Map<String, String> paramsMap = execution.getVariable("serviceInputParams")
+ if (paramsMap != null)
+ {
+ sbParams.append("<service-input-parameters>")
+ for (Map.Entry<String, String> entry : paramsMap.entrySet()) {
+ String paramsXml
+ String paramName = entry.getKey()
+ String paramValue = entry.getValue()
+ paramsXml =
+ """ <param>
+ <name>${paramName}</name>
+ <value>${paramValue}</value>
+ </param>
+ """
+ sbParams.append(paramsXml)
+ }
+ sbParams.append("</service-input-parameters>")
+ }
+ String siParamsXml = sbParams.toString()
+ if (siParamsXml == null)
+ siParamsXml = ""
+ execution.setVariable("siParamsXml", siParamsXml)
+
+ } catch (BpmnError e) {
+ throw e;
+ } catch (Exception ex){
+ msg = "Exception in preProcessRequest " + ex.getMessage()
+ utils.log("DEBUG", msg, isDebugEnabled)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ utils.log("DEBUG"," ***** Exit preProcessRequest *****", isDebugEnabled)
+ }
+
+ public void preProcessSDNCDelete (DelegateExecution execution) {
+ def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
+ utils.log("DEBUG"," ***** 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") ?: ""
+
+ }
+
+ def siParamsXml = execution.getVariable("siParamsXml") ?: ""
+ def msoAction = ""
+ // special URL for SDNW, msoAction helps set diff url in SDNCA
+ if("TRANSPORT".equalsIgnoreCase(execution.getVariable("serviceType")))
+ {
+ msoAction = "TRANSPORT"
+ }
+
+ def sdncRequestId = UUID.randomUUID().toString()
+
+ String sdncDelete =
+ """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.openecomp/mso/request/types/v1"
+ xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"
+ xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1">
+ <sdncadapter:RequestHeader>
+ <sdncadapter:RequestId>${sdncRequestId}</sdncadapter:RequestId>
+ <sdncadapter:SvcInstanceId>${serviceInstanceId}</sdncadapter:SvcInstanceId>
+ <sdncadapter:SvcAction>delete</sdncadapter:SvcAction>
+ <sdncadapter:SvcOperation>service-topology-operation</sdncadapter:SvcOperation>
+ <sdncadapter:CallbackUrl>${callbackURL}</sdncadapter:CallbackUrl>
+ <sdncadapter:MsoAction>${msoAction}</sdncadapter:MsoAction>
+ </sdncadapter:RequestHeader>
+ <sdncadapterworkflow:SDNCRequestData>
+ <request-information>
+ <request-id>${requestId}</request-id>
+ <source>MSO</source>
+ <notification-url/>
+ <order-number/>
+ <order-version/>
+ <request-action>DeleteServiceInstance</request-action>
+ </request-information>
+ <service-information>
+ <service-id>${serviceId}</service-id>
+ <subscription-service-type>${subscriptionServiceType}</subscription-service-type>
+ <ecomp-model-information>
+ <model-invariant-uuid>${modelInvariantUuid}</model-invariant-uuid>
+ <model-uuid>${modelUuid}</model-uuid>
+ <model-version>${modelVersion}</model-version>
+ <model-name>${modelName}</model-name>
+ </ecomp-model-information>
+ <service-instance-id>${serviceInstanceId}</service-instance-id>
+ <subscriber-name/>
+ <global-customer-id>${globalSubscriberId}</global-customer-id>
+ </service-information>
+ <service-request-input>
+ <service-instance-name>${serviceInstanceName}</service-instance-name>
+ ${siParamsXml}
+ </service-request-input>
+ </sdncadapterworkflow:SDNCRequestData>
+ </sdncadapterworkflow:SDNCAdapterWorkflowRequest>"""
+
+ 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("DEBUG","sdncDeactivate:\n" + sdncDeactivate, isDebugEnabled)
+ utils.log("DEBUG","sdncDelete:\n" + sdncDelete, isDebugEnabled)
+
+ } catch (BpmnError e) {
+ throw e;
+ } catch(Exception ex) {
+ msg = "Exception in preProcessSDNCDelete. " + ex.getMessage()
+ utils.log("DEBUG", msg, isDebugEnabled)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Exception Occured in preProcessSDNCDelete.\n" + ex.getMessage())
+ }
+ utils.log("DEBUG"," *****Exit preProcessSDNCDelete *****", isDebugEnabled)
+ }
+
+ public void postProcessSDNCDelete(DelegateExecution execution, String response, String method) {
+
+ def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
+ utils.log("DEBUG"," ***** postProcessSDNC " + method + " *****", isDebugEnabled)
+ String msg = ""
+
+ try {
+ WorkflowException workflowException = execution.getVariable("WorkflowException")
+ boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator")
+ utils.log("DEBUG", "SDNCResponse: " + response, isDebugEnabled)
+ utils.log("DEBUG", "workflowException: " + workflowException, isDebugEnabled)
+
+ SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
+ sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)
+
+ if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){
+ utils.log("DEBUG","Good response from SDNC Adapter for service-instance " + method + "response:\n" + response, isDebugEnabled)
+
+ }else{
+ msg = "Bad Response from SDNC Adapter for service-instance " + method
+ utils.log("DEBUG", msg, isDebugEnabled)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 3500, msg)
+ }
+ } catch (BpmnError e) {
+ throw e;
+ } catch(Exception ex) {
+ msg = "Exception in postProcessSDNC " + method + " Exception:" + ex.getMessage()
+ utils.log("DEBUG", msg, isDebugEnabled)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ utils.log("DEBUG"," *** Exit postProcessSDNC " + method + " ***", isDebugEnabled)
+ }
+
+ public void postProcessAAIGET(DelegateExecution execution) {
+ def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
+ utils.log("DEBUG"," ***** postProcessAAIGET ***** ", isDebugEnabled)
+ String msg = ""
+
+ try {
+
+ String serviceInstanceId = execution.getVariable("serviceInstanceId")
+ boolean foundInAAI = execution.getVariable("GENGS_FoundIndicator")
+ String serviceType = ""
+
+ if(foundInAAI){
+ utils.log("DEBUG","Found Service-instance in AAI", isDebugEnabled)
+
+ //Extract GlobalSubscriberId
+ String siRelatedLink = execution.getVariable("GENGS_siResourceLink")
+ if (isBlank(siRelatedLink))
+ {
+ msg = "Could not retrive ServiceInstance data from AAI to delete id:" + serviceInstanceId
+ utils.log("DEBUG", msg, isDebugEnabled)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
+ }
+ else
+ {
+ utils.log("DEBUG","Found Service-instance in AAI. link: " + siRelatedLink, isDebugEnabled)
+ String globalSubscriberId = execution.getVariable("globalSubscriberId")
+ if(isBlank(globalSubscriberId)){
+ int custStart = siRelatedLink.indexOf("customer/")
+ int custEnd = siRelatedLink.indexOf("/service-subscriptions")
+ globalSubscriberId = siRelatedLink.substring(custStart + 9, custEnd)
+ execution.setVariable("globalSubscriberId", globalSubscriberId)
+ }
+
+ //Extract Service Type if not provided on request
+ String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
+ if(isBlank(subscriptionServiceType)){
+ int serviceStart = siRelatedLink.indexOf("service-subscription/")
+ int serviceEnd = siRelatedLink.indexOf("/service-instances/")
+ String serviceTypeEncoded = siRelatedLink.substring(serviceStart + 21, serviceEnd)
+ subscriptionServiceType = UriUtils.decode(serviceTypeEncoded, "UTF-8")
+ execution.setVariable("subscriptionServiceType", subscriptionServiceType)
+ }
+
+ if (isBlank(globalSubscriberId) || isBlank(subscriptionServiceType))
+ {
+ msg = "Could not retrive global-customer-id & subscription-service-type from AAI to delete id:" + serviceInstanceId
+ utils.log("DEBUG", msg, isDebugEnabled)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
+ }
+ }
+
+ String siData = execution.getVariable("GENGS_service")
+ utils.log("DEBUG", "SI Data", isDebugEnabled)
+ if (isBlank(siData))
+ {
+ msg = "Could not retrive ServiceInstance data from AAI to delete id:" + serviceInstanceId
+ utils.log("DEBUG", msg, isDebugEnabled)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
+ }
+ else
+ {
+ utils.log("DEBUG", "SI Data" + siData, isDebugEnabled)
+ serviceType = utils.getNodeText1(siData,"service-type")
+ execution.setVariable("serviceType", serviceType)
+ execution.setVariable("serviceRole", utils.getNodeText1(siData,"service-role"))
+ String orchestrationStatus = utils.getNodeText1(siData,"orchestration-status")
+
+ //Confirm there are no related service instances (vnf/network or volume)
+ if (utils.nodeExists(siData, "relationship-list")) {
+ utils.log("DEBUG", "SI Data relationship-list exists:", isDebugEnabled)
+ InputSource source = new InputSource(new StringReader(siData));
+ DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
+ DocumentBuilder docBuilder = docFactory.newDocumentBuilder()
+ Document serviceXml = docBuilder.parse(source)
+
+ NodeList nodeList = serviceXml.getElementsByTagName("relationship")
+ for (int x = 0; x < nodeList.getLength(); x++) {
+ Node node = nodeList.item(x)
+ if (node.getNodeType() == Node.ELEMENT_NODE) {
+ Element eElement = (Element) node
+ def e = eElement.getElementsByTagName("related-to").item(0).getTextContent()
+ if(e.equals("generic-vnf") || e.equals("l3-network") || e.equals("allotted-resource") ){
+ utils.log("DEBUG", "ServiceInstance still has relationship(s) to generic-vnfs, l3-networks or allotted-resources", isDebugEnabled)
+ execution.setVariable("siInUse", true)
+ //there are relationship dependencies to this Service Instance
+ msg = " Stopped deleting Service Instance, it has dependencies. Service instance id: " + serviceInstanceId
+ utils.log("DEBUG", msg, isDebugEnabled)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg)
+ }else{
+ utils.log("DEBUG", "Relationship NOT related to OpenStack", isDebugEnabled)
+ }
+ }
+ }
+ }
+
+ if ("TRANSPORT".equalsIgnoreCase(serviceType))
+ {
+ if ("PendingDelete".equals(orchestrationStatus))
+ {
+ execution.setVariable("skipDeactivate", true)
+ }
+ else
+ {
+ msg = "ServiceInstance of type TRANSPORT must in PendingDelete status to allow Delete. Orchestration-status:" + orchestrationStatus
+ utils.log("DEBUG", msg, isDebugEnabled)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
+ }
+
+ }
+
+ //alacarte SIs are NOT sent to sdnc. exceptions are listed in config variable
+ String svcTypes = execution.getVariable("URN_sdnc_si_svc_types") ?: ""
+ utils.log("DEBUG", "SDNC SI serviceTypes:" + svcTypes, isDebugEnabled)
+ List<String> svcList = Arrays.asList(svcTypes.split("\\s*,\\s*"));
+ boolean isSdncService= false
+ for (String listEntry : svcList){
+ if (listEntry.equalsIgnoreCase(serviceType)){
+ isSdncService = true
+ break;
+ }
+ }
+
+ //All Macros are sent to SDNC, TRANSPORT(Macro) is sent to SDNW
+ //Alacartes are sent to SDNC if they are listed in config variable above
+ execution.setVariable("sendToSDNC", true)
+ if(execution.getVariable("sdncVersion").equals("1610")) //alacarte
+ {
+ if(!isSdncService){
+ execution.setVariable("sendToSDNC", false)
+ }
+ }
+
+ utils.log("DEBUG", "isSdncService: " + isSdncService, isDebugEnabled)
+ utils.log("DEBUG", "Send To SDNC: " + execution.getVariable("sendToSDNC"), isDebugEnabled)
+ utils.log("DEBUG", "Service Type: " + execution.getVariable("serviceType"), isDebugEnabled)
+
+ }
+ }else{
+ boolean succInAAI = execution.getVariable("GENGS_SuccessIndicator")
+ if(!succInAAI){
+ utils.log("DEBUG","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("DEBUG", msg, isDebugEnabled)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg)
+ }
+ }
+
+ utils.log("DEBUG","Service-instance NOT found in AAI. Silent Success", isDebugEnabled)
+ }
+ } catch (BpmnError e) {
+ throw e;
+ } catch (Exception ex) {
+ msg = "Exception in DoDeleteServiceInstance.postProcessAAIGET. " + ex.getMessage()
+ utils.log("DEBUG", msg, isDebugEnabled)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ utils.log("DEBUG"," *** Exit postProcessAAIGET *** ", isDebugEnabled)
+ }
+
+ public void postProcessAAIDEL(DelegateExecution execution) {
+ def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
+ utils.log("DEBUG"," ***** postProcessAAIDEL ***** ", isDebugEnabled)
+ String msg = ""
+ try {
+ String serviceInstanceId = execution.getVariable("serviceInstanceId")
+ boolean succInAAI = execution.getVariable("GENDS_SuccessIndicator")
+ if(!succInAAI){
+ msg = "Error deleting Service-instance in AAI" + serviceInstanceId
+ utils.log("DEBUG", 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 DoDeleteServiceInstance.postProcessAAIDEL. " + ex.getMessage()
+ utils.log("DEBUG", msg, isDebugEnabled)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ utils.log("DEBUG"," *** Exit postProcessAAIDEL *** ", isDebugEnabled)
+ }
+}