X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=bpmn%2FMSOCommonBPMN%2Fsrc%2Fmain%2Fgroovy%2Forg%2Fopenecomp%2Fmso%2Fbpmn%2Fcommon%2Fscripts%2FDeleteAAIVfModule.groovy;fp=bpmn%2FMSOGammaBPMN%2Fsrc%2Fmain%2Fgroovy%2Fcom%2Fatt%2Fbpm%2Fscripts%2FDeleteAAIVfModule.groovy;h=ca9a2e08499c401480bc2716c4baadeeb306056b;hb=b6b7bef8bdcad15af01ac88a038dd763ce59f68f;hp=0e5360de7f156c30ab83faf135667e86703c30c7;hpb=19340cad94eeaa1b580f7c0c99531de499e8ca14;p=so.git diff --git a/bpmn/MSOGammaBPMN/src/main/groovy/com/att/bpm/scripts/DeleteAAIVfModule.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/DeleteAAIVfModule.groovy similarity index 90% rename from bpmn/MSOGammaBPMN/src/main/groovy/com/att/bpm/scripts/DeleteAAIVfModule.groovy rename to bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/DeleteAAIVfModule.groovy index 0e5360de7f..ca9a2e0849 100644 --- a/bpmn/MSOGammaBPMN/src/main/groovy/com/att/bpm/scripts/DeleteAAIVfModule.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/DeleteAAIVfModule.groovy @@ -18,16 +18,10 @@ * ============LICENSE_END========================================================= */ -package com.att.bpm.scripts -import java.io.Serializable; - +package org.openecomp.mso.bpmn.common.scripts import org.camunda.bpm.engine.runtime.Execution - -import org.openecomp.mso.rest.APIResponse -import org.openecomp.mso.rest.RESTClient -import org.openecomp.mso.rest.RESTConfig -import org.openecomp.mso.bpmn.core.RollbackData import org.openecomp.mso.bpmn.core.WorkflowException +import org.openecomp.mso.rest.APIResponse public class DeleteAAIVfModule extends AbstractServiceTaskProcessor{ @@ -56,7 +50,7 @@ public class DeleteAAIVfModule extends AbstractServiceTaskProcessor{ execution.setVariable("DAAIVfMod_deleteVfModuleResponseCode",null) execution.setVariable("DAAIVfMod_deleteVfModuleResponse","") - } + } // parse the incoming DELETE_VF_MODULE request and store the Generic Vnf // and Vf Module Ids in the flow Execution @@ -68,7 +62,7 @@ public class DeleteAAIVfModule extends AbstractServiceTaskProcessor{ initProcessVariables(execution) def vnfId = utils.getNodeText(xml,"vnf-id") def vfModuleId = utils.getNodeText(xml,"vf-module-id") - execution.setVariable("DAAIVfMod_vnfId", vnfId) + execution.setVariable("DAAIVfMod_vnfId", vnfId) execution.setVariable("DAAIVfMod_vfModuleId", vfModuleId) AaiUtil aaiUriUtil = new AaiUtil(this) @@ -85,24 +79,18 @@ public class DeleteAAIVfModule extends AbstractServiceTaskProcessor{ public void queryAAIForGenericVnf(Execution execution) { def isDebugEnabled=execution.getVariable("isDebugLogEnabled") def delModuleId = execution.getVariable("DAAIVfMod_vfModuleId") - def endPoint = execution.getVariable("URN_aai_endpoint") + execution.getVariable("DAAIVfMod_genericVnfEndpoint") + def endPoint = execution.getVariable("URN_aai_endpoint") + execution.getVariable("DAAIVfMod_genericVnfEndpoint") + "?depth=1" utils.logAudit("DeleteAAIVfModule endPoint: " + endPoint) def aaiRequestId = UUID.randomUUID().toString() - String basicAuthCred = utils.getBasicAuth(execution.getVariable("URN_aai_auth"),execution.getVariable("URN_mso_msoKey")) - - RESTConfig config = new RESTConfig(endPoint); utils.log("DEBUG","queryAAIForGenericVnf() endpoint-" + endPoint, isDebugEnabled) def responseData = "" try { - RESTClient client = new RESTClient(config).addHeader("X-TransactionId", aaiRequestId).addHeader("X-FromAppId", "MSO"). - addHeader("Accept","application/xml"); - if (basicAuthCred != null && !"".equals(basicAuthCred)) { - client.addAuthorizationHeader(basicAuthCred) - } utils.log("DEBUG", "invoking GET call to AAI endpoint :"+System.lineSeparator()+endPoint,isDebugEnabled) - APIResponse response = client.httpGet() utils.logAudit("DeleteAAIVfModule - invoking httpGet to AAI") + + AaiUtil aaiUtil = new AaiUtil(this) + APIResponse response = aaiUtil.executeAAIGetCall(execution, endPoint) responseData = response.getResponseBodyAsString() execution.setVariable("DAAIVfMod_queryGenericVnfResponseCode", response.getStatusCode()) @@ -126,19 +114,11 @@ public class DeleteAAIVfModule extends AbstractServiceTaskProcessor{ def endPoint = execution.getVariable("URN_aai_endpoint") + execution.getVariable("DAAIVfMod_genericVnfEndpoint") + "/?resource-version=" + execution.getVariable("DAAIVfMod_genVnfRsrcVer") utils.logAudit("AAI endPoint: " + endPoint) - - String basicAuthCred = utils.getBasicAuth(execution.getVariable("URN_aai_auth"),execution.getVariable("URN_mso_msoKey")) - - RESTConfig config = new RESTConfig(endPoint); utils.log("DEBUG","deleteGenericVnf() endpoint-" + endPoint, isDebugEnabled) def responseData = "" try { - RESTClient client = new RESTClient(config).addHeader("X-TransactionId", aaiRequestId).addHeader("X-FromAppId", "MSO"). - addHeader("Accept","application/xml"); - if (basicAuthCred != null && !"".equals(basicAuthCred)) { - client.addAuthorizationHeader(basicAuthCred) - } - APIResponse response = client.httpDelete() + AaiUtil aaiUtil = new AaiUtil(this) + APIResponse response = aaiUtil.executeAAIDeleteCall(execution, endPoint) responseData = response.getResponseBodyAsString() execution.setVariable("DAAIVfMod_deleteGenericVnfResponseCode", response.getStatusCode()) @@ -150,7 +130,7 @@ public class DeleteAAIVfModule extends AbstractServiceTaskProcessor{ utils.log("DEBUG", "Exception occurred while executing AAI DELETE:" + ex.getMessage(),isDebugEnabled) execution.setVariable("DAAIVfMod_deleteGenericVnfResponseCode", 500) execution.setVariable("DAAIVfMod_deleteGenericVnfResponse", "AAI DELETE Failed:" + ex.getMessage()) - } + } } // construct and send a DELETE request to A&AI to delete the Base or Add-on Vf Module @@ -160,18 +140,12 @@ public class DeleteAAIVfModule extends AbstractServiceTaskProcessor{ "/?resource-version=" + execution.getVariable("DAAIVfMod_vfModRsrcVer") def aaiRequestId = UUID.randomUUID().toString() - String basicAuthCred = utils.getBasicAuth(execution.getVariable("URN_aai_auth"),execution.getVariable("URN_mso_msoKey")) - - RESTConfig config = new RESTConfig(endPoint); utils.log("DEBUG","deleteVfModule() endpoint-" + endPoint, isDebugEnabled) def responseData = "" try { - RESTClient client = new RESTClient(config).addHeader("X-TransactionId", aaiRequestId).addHeader("X-FromAppId", "MSO"). - addHeader("Accept","application/xml"); - if (basicAuthCred != null && !"".equals(basicAuthCred)) { - client.addAuthorizationHeader(basicAuthCred) - } - APIResponse response = client.httpDelete() + AaiUtil aaiUtil = new AaiUtil(this) + APIResponse response = aaiUtil.executeAAIDeleteCall(execution, endPoint) + utils.logAudit("DeleteAAIVfModule - invoking httpDelete to AAI") responseData = response.getResponseBodyAsString() @@ -186,7 +160,7 @@ public class DeleteAAIVfModule extends AbstractServiceTaskProcessor{ utils.log("DEBUG", "Exception occurred while executing AAI PUT:" + ex.getMessage(),isDebugEnabled) execution.setVariable("DAAIVfMod_deleteVfModuleResponseCode", 500) execution.setVariable("DAAIVfMod_deleteVfModuleResponse", "AAI PUT Failed:" + ex.getMessage()) - } + } } // parses the output from the result from queryAAIForGenericVnf() to determine if the Vf Module @@ -205,7 +179,7 @@ public class DeleteAAIVfModule extends AbstractServiceTaskProcessor{ execution.setVariable("DAAIVfMod_moduleExists", false) execution.setVariable("DAAIVfMod_isBaseModule", false) execution.setVariable("DAAIVfMod_isLastModule", false) - // + // def isBaseVfModule = "false" // loop through the Vf Module Ids looking for a match if (qryModuleIdList != null && !qryModuleIdList.empty) { @@ -267,7 +241,7 @@ public class DeleteAAIVfModule extends AbstractServiceTaskProcessor{ execution.setVariable("DAAIVfMod_parseModuleResponse", "Vf Module Id " + delModuleId + " does not exist for Generic Vnf Id " + execution.getVariable("DAAIVfMod_vnfName")) - } + } } // parses the output from the result from queryAAIForGenericVnf() to determine if the Vf Module @@ -279,7 +253,7 @@ public class DeleteAAIVfModule extends AbstractServiceTaskProcessor{ utils.logAudit("DeleteAAIVfModule - queryGenericVnfResponse" + xml) String resourceVer = utils.getNodeText1(xml, "resource-version") execution.setVariable("DAAIVfMod_genVnfRsrcVer", resourceVer) - utils.log("DEBUG", "Latest Generic VNF Resource Version: " + resourceVer) + utils.log("DEBUG", "Latest Generic VNF Resource Version: " + resourceVer) } @@ -357,4 +331,4 @@ public class DeleteAAIVfModule extends AbstractServiceTaskProcessor{ execution.getVariable("DAAIVfMod_deleteGenericVnfResponse")) execution.setVariable("WorkflowException", exception) } -} +} \ No newline at end of file