* ============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{
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
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)
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())
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())
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
"/?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()
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
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) {
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
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)
}
execution.getVariable("DAAIVfMod_deleteGenericVnfResponse"))
execution.setVariable("WorkflowException", exception)
}
-}
+}
\ No newline at end of file