Merge "Reorder modifiers"
[so.git] / bpmn / MSOInfrastructureBPMN / src / main / groovy / org / openecomp / mso / bpmn / infrastructure / scripts / DoDeleteVnf.groovy
index fe98b70..5e6fff2 100644 (file)
-/*-
- * ============LICENSE_START=======================================================
- * OPENECOMP - MSO
- * ================================================================================
- * 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 javax.xml.parsers.DocumentBuilder
-import javax.xml.parsers.DocumentBuilderFactory
-
-import org.apache.commons.lang3.*
-import org.camunda.bpm.engine.delegate.BpmnError
-import org.camunda.bpm.engine.runtime.Execution
-import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor
-import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil
-import org.openecomp.mso.bpmn.common.scripts.VidUtils
-import org.openecomp.mso.bpmn.core.json.JsonUtils
-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 class supports the DoDeleteVnf subFlow
- * with the Deletion of a generic vnf for
- * infrastructure.
- *
- */
-class DoDeleteVnf extends AbstractServiceTaskProcessor {
-
-       String Prefix="DoDVNF_"
-       ExceptionUtil exceptionUtil = new ExceptionUtil()
-       JsonUtils jsonUtil = new JsonUtils()
-       VidUtils vidUtils = new VidUtils(this)
-
-       /**
-        * This method gets and validates the incoming
-        * request.
-        *
-        * @param - execution
-        *
-        */
-       public void preProcessRequest(Execution execution) {
-               def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
-               execution.setVariable("prefix",Prefix)
-               utils.log("DEBUG", " *** STARTED DoDeleteVnf PreProcessRequest Process*** ", isDebugEnabled)
-
-               execution.setVariable("DoDVNF_SuccessIndicator", false)
-               execution.setVariable("DoDVNF_vnfInUse", false)
-
-               try{
-                       // Get Variables
-
-                       String vnfId = execution.getVariable("vnfId")
-                       execution.setVariable("DoDVNF_vnfId", vnfId)
-                       utils.log("DEBUG", "Incoming Vnf(Instance) Id is: " + vnfId, isDebugEnabled)
-
-                       // Setting for sub flow calls
-                       execution.setVariable("DoDVNF_type", "generic-vnf")
-               }catch(BpmnError b){
-                       utils.log("DEBUG", "Rethrowing MSOWorkflowException", isDebugEnabled)
-                       throw b
-               }catch(Exception e){
-                       utils.log("DEBUG", " Error Occured in DoDeleteVnf PreProcessRequest method!" + e, isDebugEnabled)
-                       exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoDeleteVnf PreProcessRequest")
-
-               }
-               utils.log("DEBUG", "*** COMPLETED DoDeleteVnf PreProcessRequest Process ***", isDebugEnabled)
-       }
-
-
-       public void processGetVnfResponse(Execution execution){
-               def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
-               execution.setVariable("prefix",Prefix)
-               utils.log("DEBUG", " *** STARTED DoDeleteVnf processGetVnfResponse Process *** ", isDebugEnabled)
-               try {
-                       String vnf = execution.getVariable("DoDVNF_genericVnf")
-                       String resourceVersion = utils.getNodeText1(vnf, "resource-version")
-                       execution.setVariable("DoDVNF_resourceVersion", resourceVersion)
-
-                       if(utils.nodeExists(vnf, "relationship")){
-                               InputSource source = new InputSource(new StringReader(vnf));
-                               DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
-                               DocumentBuilder docBuilder = docFactory.newDocumentBuilder()
-                               Document vnfXml = docBuilder.parse(source)
-
-                               NodeList nodeList = vnfXml.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("volume-group") || e.equals("l3-network")){
-                                                       utils.log("DEBUG", "Generic Vnf still has relationship to OpenStack.", isDebugEnabled)
-                                                       execution.setVariable("DoDVNF_vnfInUse", true)
-                                               }else{
-                                                       utils.log("DEBUG", "Relationship NOT related to OpenStack", isDebugEnabled)
-                                               }
-                                       }
-                               }
-                       }
-
-                       if(utils.nodeExists(vnf, "vf-module")){
-                               execution.setVariable("DoDVNF_vnfInUse", true)
-                               utils.log("DEBUG", "Generic Vnf still has vf-modules.", isDebugEnabled)
-                       }
-
-
-               } catch (Exception ex) {
-                       utils.log("DEBUG", "Error Occured in DoDeleteVnf processGetVnfResponse Process " + ex.getMessage(), isDebugEnabled)
-                       exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoDeleteVnf processGetVnfResponse Process")
-
-               }
-               utils.log("DEBUG", "*** COMPLETED DoDeleteVnf processGetVnfResponse Process ***", isDebugEnabled)
-       }
-
-
-
-}
+/*-\r
+ * ============LICENSE_START=======================================================\r
+ * ONAP - SO\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
+\r
+import javax.xml.parsers.DocumentBuilder\r
+import javax.xml.parsers.DocumentBuilderFactory\r
+\r
+import org.apache.commons.lang3.*\r
+import org.camunda.bpm.engine.delegate.BpmnError\r
+import org.camunda.bpm.engine.delegate.DelegateExecution\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.VidUtils\r
+import org.openecomp.mso.bpmn.core.json.JsonUtils\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
+/**\r
+ * This class supports the DoDeleteVnf subFlow\r
+ * with the Deletion of a generic vnf for\r
+ * infrastructure.\r
+ *\r
+ */\r
+class DoDeleteVnf extends AbstractServiceTaskProcessor {\r
+\r
+       String Prefix="DoDVNF_"\r
+       ExceptionUtil exceptionUtil = new ExceptionUtil()\r
+       JsonUtils jsonUtil = new JsonUtils()\r
+       VidUtils vidUtils = new VidUtils(this)\r
+\r
+       /**\r
+        * This method gets and validates the incoming\r
+        * request.\r
+        *\r
+        * @param - execution\r
+        *\r
+        */\r
+       public void preProcessRequest(DelegateExecution execution) {\r
+               def isDebugEnabled = execution.getVariable("isDebugLogEnabled")\r
+               execution.setVariable("prefix",Prefix)\r
+               utils.log("DEBUG", " *** STARTED DoDeleteVnf PreProcessRequest Process*** ", isDebugEnabled)\r
+\r
+               execution.setVariable("DoDVNF_SuccessIndicator", false)\r
+               execution.setVariable("DoDVNF_vnfInUse", false)\r
+\r
+               try{\r
+                       // Get Variables\r
+\r
+                       String vnfId = execution.getVariable("vnfId")\r
+                       execution.setVariable("DoDVNF_vnfId", vnfId)\r
+                       utils.log("DEBUG", "Incoming Vnf(Instance) Id is: " + vnfId, isDebugEnabled)\r
+\r
+                       // Setting for sub flow calls\r
+                       execution.setVariable("DoDVNF_type", "generic-vnf")\r
+               }catch(BpmnError b){\r
+                       utils.log("DEBUG", "Rethrowing MSOWorkflowException", isDebugEnabled)\r
+                       throw b\r
+               }catch(Exception e){\r
+                       utils.log("DEBUG", " Error Occured in DoDeleteVnf PreProcessRequest method!" + e, isDebugEnabled)\r
+                       exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoDeleteVnf PreProcessRequest")\r
+\r
+               }\r
+               utils.log("DEBUG", "*** COMPLETED DoDeleteVnf PreProcessRequest Process ***", isDebugEnabled)\r
+       }\r
+\r
+\r
+       public void processGetVnfResponse(DelegateExecution execution){\r
+               def isDebugEnabled=execution.getVariable("isDebugLogEnabled")\r
+               execution.setVariable("prefix",Prefix)\r
+               utils.log("DEBUG", " *** STARTED DoDeleteVnf processGetVnfResponse Process *** ", isDebugEnabled)\r
+               try {\r
+                       String vnf = execution.getVariable("DoDVNF_genericVnf")\r
+                       String resourceVersion = utils.getNodeText1(vnf, "resource-version")\r
+                       execution.setVariable("DoDVNF_resourceVersion", resourceVersion)\r
+\r
+                       if(utils.nodeExists(vnf, "relationship")){\r
+                               InputSource source = new InputSource(new StringReader(vnf));\r
+                               DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();\r
+                               DocumentBuilder docBuilder = docFactory.newDocumentBuilder()\r
+                               Document vnfXml = docBuilder.parse(source)\r
+\r
+                               NodeList nodeList = vnfXml.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("volume-group") || e.equals("l3-network")){\r
+                                                       utils.log("DEBUG", "Generic Vnf still has relationship to OpenStack.", isDebugEnabled)\r
+                                                       execution.setVariable("DoDVNF_vnfInUse", true)\r
+                                               }else{\r
+                                                       utils.log("DEBUG", "Relationship NOT related to OpenStack", isDebugEnabled)\r
+                                               }\r
+                                       }\r
+                               }\r
+                       }\r
+\r
+                       if(utils.nodeExists(vnf, "vf-module")){\r
+                               execution.setVariable("DoDVNF_vnfInUse", true)\r
+                               utils.log("DEBUG", "Generic Vnf still has vf-modules.", isDebugEnabled)\r
+                       }\r
+\r
+\r
+               } catch (Exception ex) {\r
+                       utils.log("DEBUG", "Error Occured in DoDeleteVnf processGetVnfResponse Process " + ex.getMessage(), isDebugEnabled)\r
+                       exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoDeleteVnf processGetVnfResponse Process")\r
+\r
+               }\r
+               utils.log("DEBUG", "*** COMPLETED DoDeleteVnf processGetVnfResponse Process ***", isDebugEnabled)\r
+       }\r
+\r
+\r
+\r
+}\r