use of org.onap.so.client.sdnc.beans.SDNCRequest in project so by onap.
the class SDNCUnassignTasks method unassignVnf.
/**
* This method is used to prepare a SDNC request and set it to the execution Object.
*
* Which is used for unassign the Vnf.
*
* @param execution
*/
public void unassignVnf(BuildingBlockExecution execution) {
try {
GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
RequestContext requestContext = gBBInput.getRequestContext();
Customer customer = gBBInput.getCustomer();
CloudRegion cloudRegion = gBBInput.getCloudRegion();
SDNCRequest sdncRequest = new SDNCRequest();
GenericResourceApiVnfOperationInformation req = sdncVnfResources.unassignVnf(vnf, serviceInstance, customer, cloudRegion, requestContext, buildCallbackURI(sdncRequest));
sdncRequest.setSDNCPayload(req);
sdncRequest.setTopology(SDNCTopology.VNF);
execution.setVariable(SDNC_REQUEST, sdncRequest);
} catch (Exception ex) {
logger.error("Exception occurred in SDNCUnassignTasks unassignVnf", ex);
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
}
}
use of org.onap.so.client.sdnc.beans.SDNCRequest in project so by onap.
the class SDNCUnassignTasks method unassignVfModule.
/**
* This method is used to prepare a SDNC request and set it to the execution Object.
*
* Which is used for unassign the VfModule.
*
* @param execution
*/
public void unassignVfModule(BuildingBlockExecution execution) {
try {
GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
RequestContext requestContext = gBBInput.getRequestContext();
VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
SDNCRequest sdncRequest = new SDNCRequest();
GenericResourceApiVfModuleOperationInformation req = sdncVfModuleResources.unassignVfModule(vfModule, vnf, serviceInstance, requestContext, buildCallbackURI(sdncRequest));
sdncRequest.setSDNCPayload(req);
sdncRequest.setTopology(SDNCTopology.VFMODULE);
execution.setVariable(SDNC_REQUEST, sdncRequest);
} catch (Exception ex) {
logger.error("Exception occurred in SDNCUnassignTasks unassignVfModule", ex);
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
}
}
use of org.onap.so.client.sdnc.beans.SDNCRequest in project so by onap.
the class SDNCDeactivateTasks method deactivateVnf.
/**
* BPMN access method to perform Service Topology Deactivate action on SDNC for Vnf
*
* @param execution
* @throws Exception
*/
public void deactivateVnf(BuildingBlockExecution execution) throws Exception {
try {
GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
RequestContext requestContext = gBBInput.getRequestContext();
ServiceInstance serviceInstance = null;
GenericVnf vnf = null;
serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
CloudRegion cloudRegion = gBBInput.getCloudRegion();
Customer customer = gBBInput.getCustomer();
SDNCRequest sdncRequest = new SDNCRequest();
GenericResourceApiVnfOperationInformation req = sdncVnfResources.deactivateVnf(vnf, serviceInstance, customer, cloudRegion, requestContext, buildCallbackURI(sdncRequest));
sdncRequest.setSDNCPayload(req);
sdncRequest.setTopology(SDNCTopology.VNF);
execution.setVariable(SDNC_REQUEST, sdncRequest);
} catch (Exception ex) {
logger.error("Exception occurred in SDNCDeactivateTasks deactivateVnf", ex);
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
}
}
use of org.onap.so.client.sdnc.beans.SDNCRequest in project so by onap.
the class SDNCDeactivateTasks method deactivateNetwork.
/**
* BPMN access method to invoke deactivate on a L3Network object
*
* @param execution
*/
public void deactivateNetwork(BuildingBlockExecution execution) {
try {
GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
L3Network l3Network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
Customer customer = gBBInput.getCustomer();
RequestContext requestContext = gBBInput.getRequestContext();
CloudRegion cloudRegion = gBBInput.getCloudRegion();
GenericResourceApiNetworkOperationInformation req = sdncNetworkResources.deactivateNetwork(l3Network, serviceInstance, customer, requestContext, cloudRegion);
SDNCRequest sdncRequest = new SDNCRequest();
sdncRequest.setSDNCPayload(req);
sdncRequest.setTopology(SDNCTopology.NETWORK);
execution.setVariable(SDNC_REQUEST, sdncRequest);
} catch (Exception ex) {
logger.error("Exception occurred in SDNCDeactivateTasks deactivateNetwork", ex);
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
}
}
use of org.onap.so.client.sdnc.beans.SDNCRequest in project so by onap.
the class SDNCRequestTasks method processCallback.
public void processCallback(DelegateExecution execution) {
try {
SDNCRequest request = (SDNCRequest) execution.getVariable(SDNC_REQUEST);
String asyncRequest = (String) execution.getVariable(request.getCorrelationName() + MESSAGE);
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setFeature("http://xml.org/sax/features/external-general-entities", false);
dbf.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
dbf.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
DocumentBuilder db = dbf.newDocumentBuilder();
Document doc = db.parse(new InputSource(new StringReader(asyncRequest)));
String finalMessageIndicator = getXmlElement(doc, "/input/ack-final-indicator");
boolean isCallbackCompleted = convertIndicatorToBoolean(finalMessageIndicator);
execution.setVariable(IS_CALLBACK_COMPLETED, isCallbackCompleted);
if (isCallbackCompleted) {
String responseCode = getXmlElement(doc, "/input/response-code");
if (!SDNC_SUCCESS.equalsIgnoreCase(responseCode)) {
String responseMessage;
try {
responseMessage = getXmlElement(doc, "/input/response-message");
} catch (Exception e) {
responseMessage = "Unknown Error in SDNC";
}
throw new SDNCErrorResponseException(responseMessage);
}
}
} catch (SDNCErrorResponseException e) {
logger.error("SDNC error response - " + e.getMessage());
exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, e.getMessage(), ONAPComponents.SDNC);
} catch (Exception e) {
logger.error("Error processing SDNC callback", e);
exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, "Error processing SDNC callback", ONAPComponents.SO);
}
}
Aggregations