diff options
5 files changed, 518 insertions, 509 deletions
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSliceSubnet.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSliceSubnet.groovy index c7fe7e36a6..eabe58488e 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSliceSubnet.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSliceSubnet.groovy @@ -32,150 +32,148 @@ import org.slf4j.LoggerFactory import static org.apache.commons.lang3.StringUtils.isBlank class ActivateSliceSubnet extends AbstractServiceTaskProcessor { - String Prefix="ActSS" - ExceptionUtil exceptionUtil = new ExceptionUtil() - JsonUtils jsonUtil = new JsonUtils() - RequestDBUtil requestDBUtil = new RequestDBUtil() - - private static final Logger logger = LoggerFactory.getLogger(ActivateSliceSubnet.class) - - @Override - void preProcessRequest(DelegateExecution execution) { - logger.debug(Prefix + "preProcessRequest Start") - execution.setVariable("prefix", Prefix) - execution.setVariable("startTime", System.currentTimeMillis()) - def msg - try { - // get request input - String subnetInstanceReq = execution.getVariable("bpmnRequest") - logger.debug(subnetInstanceReq) - - String requestId = execution.getVariable("mso-request-id") - execution.setVariable("msoRequestId", requestId) - logger.debug("Input Request:" + subnetInstanceReq + " reqId:" + requestId) - - //subscriberInfo - String globalSubscriberId = jsonUtil.getJsonValue(subnetInstanceReq, "globalSubscriberId") - if (isBlank(globalSubscriberId)) { - msg = "Input globalSubscriberId' is null" - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } else { - execution.setVariable("globalSubscriberId", globalSubscriberId) - } - - //NSSI ID - String serviceInstanceID = jsonUtil.getJsonValue(subnetInstanceReq, "serviceInstanceID") - if (isBlank(serviceInstanceID)) { - msg = "Input serviceInstanceID is null" - logger.debug(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } else - { - execution.setVariable("serviceInstanceID", serviceInstanceID) - } - - String nsiId = jsonUtil.getJsonValue(subnetInstanceReq, "additionalProperties.nsiId") - if (isBlank(nsiId)) { - msg = "Input nsiId is null" - logger.debug(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } else - { - execution.setVariable("nsiId", nsiId) - } - String networkType = jsonUtil.getJsonValue(subnetInstanceReq, "networkType") - if (isBlank(networkType)) { - msg = "Input networkType is null" - logger.debug(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } else - { - execution.setVariable("networkType", networkType.toUpperCase()) - } - - //requestParameters, subscriptionServiceType is 5G - String subscriptionServiceType = jsonUtil.getJsonValue(subnetInstanceReq, "subscriptionServiceType") - if (isBlank(subscriptionServiceType)) { - msg = "Input subscriptionServiceType is null" - logger.debug(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } else { - execution.setVariable("subscriptionServiceType", subscriptionServiceType) - } - - //operationType = deactivateInstance/activateInstance - String operationType = execution.getVariable("requestAction") - if (isBlank(operationType)) { - msg = "Input operationType is null" - logger.debug(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } else { - execution.setVariable("operationType", operationType) - } - - String jobId = UUID.randomUUID().toString() - execution.setVariable("jobId", jobId) - - String sliceParams = jsonUtil.getJsonValue(subnetInstanceReq, "additionalProperties") - execution.setVariable("sliceParams", sliceParams) - - } catch(BpmnError e) { - throw e - } catch(Exception ex) { - msg = "Exception in ActivateSliceSubnet.preProcessRequest " + ex.getMessage() - logger.debug(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - logger.debug(Prefix + "preProcessRequest Exit") - } - - - /** - * create operation status in request db - * - * Init the Operation Status - */ - def prepareInitOperationStatus = { DelegateExecution execution -> - logger.debug(Prefix + "prepareInitOperationStatus Start") - - String serviceId = execution.getVariable("serviceInstanceID") - String jobId = execution.getVariable("jobId") - String nsiId = execution.getVariable("nsiId") - String operationType = execution.getVariable("operationType") - logger.debug("Generated new job for Service Instance serviceId:" + serviceId + " jobId:" + jobId) - - ResourceOperationStatus initStatus = new ResourceOperationStatus() - initStatus.setServiceId(serviceId) - initStatus.setOperationId(jobId) - initStatus.setResourceTemplateUUID(nsiId) - initStatus.setOperType(operationType) - requestDBUtil.prepareInitResourceOperationStatus(execution, initStatus) - - logger.debug(Prefix + "prepareInitOperationStatus Exit") - } - - - - /** - * return sync response - */ - def sendSyncResponse = { DelegateExecution execution -> - logger.debug(Prefix + "sendSyncResponse Start") - try { - String jobId = execution.getVariable("jobId") - String activateSyncResponse = """{"jobId": "${jobId}","status": "processing"}""" - .trim().replaceAll(" ", "") - - logger.debug("sendSyncResponse to APIH:" + "\n" + activateSyncResponse) - sendWorkflowResponse(execution, 202, activateSyncResponse) - - execution.setVariable("sentSyncResponse", true) - } catch (Exception ex) { - String msg = "Exception in sendSyncResponse:" + ex.getMessage() - logger.debug(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - logger.debug(Prefix + "sendSyncResponse Exit") - } - + String Prefix="ActivateSliceSubnet_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + RequestDBUtil requestDBUtil = new RequestDBUtil() + + private static final Logger logger = LoggerFactory.getLogger(ActivateSliceSubnet.class) + + @Override + void preProcessRequest(DelegateExecution execution) { + logger.debug(Prefix + "preProcessRequest Start") + execution.setVariable("prefix", Prefix) + execution.setVariable("startTime", System.currentTimeMillis()) + def msg + try { + // get request input + String subnetInstanceReq = execution.getVariable("bpmnRequest") + logger.debug(subnetInstanceReq) + + String requestId = execution.getVariable("mso-request-id") + execution.setVariable("msoRequestId", requestId) + logger.debug("Input Request:" + subnetInstanceReq + " reqId:" + requestId) + + //subscriberInfo + String globalSubscriberId = jsonUtil.getJsonValue(subnetInstanceReq, "globalSubscriberId") + if (isBlank(globalSubscriberId)) { + msg = "Input globalSubscriberId' is null" + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else { + execution.setVariable("globalSubscriberId", globalSubscriberId) + } + + //NSSI ID + String serviceInstanceID = jsonUtil.getJsonValue(subnetInstanceReq, "serviceInstanceID") + if (isBlank(serviceInstanceID)) { + msg = "Input serviceInstanceID is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else + { + execution.setVariable("serviceInstanceID", serviceInstanceID) + } + String nsiId = jsonUtil.getJsonValue(subnetInstanceReq, "additionalProperties.nsiId") + if (isBlank(nsiId)) { + msg = "Input nsiId is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else + { + execution.setVariable("nsiId", nsiId) + } + String networkType = jsonUtil.getJsonValue(subnetInstanceReq, "networkType") + if (isBlank(networkType)) { + msg = "Input networkType is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else + { + execution.setVariable("networkType", networkType.toUpperCase()) + } + //requestParameters, subscriptionServiceType is 5G + String subscriptionServiceType = jsonUtil.getJsonValue(subnetInstanceReq, "subscriptionServiceType") + if (isBlank(subscriptionServiceType)) { + msg = "Input subscriptionServiceType is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else { + execution.setVariable("subscriptionServiceType", subscriptionServiceType) + } + + //operationType = deactivateInstance/activateInstance + String operationType = execution.getVariable("requestAction") + if (isBlank(operationType)) { + msg = "Input operationType is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else { + execution.setVariable("operationType", operationType) + } + + String jobId = UUID.randomUUID().toString() + execution.setVariable("jobId", jobId) + + String sliceParams = jsonUtil.getJsonValue(subnetInstanceReq, "additionalProperties") + execution.setVariable("sliceParams", sliceParams) + + } catch(BpmnError e) { + throw e + } catch(Exception ex) { + msg = "Exception in ActivateSliceSubnet.preProcessRequest " + ex.getMessage() + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.debug(Prefix + "preProcessRequest Exit") + } + + + /** + * create operation status in request db + * + * Init the Operation Status + */ + def prepareInitOperationStatus = { DelegateExecution execution -> + logger.debug(Prefix + "prepareInitOperationStatus Start") + + String serviceId = execution.getVariable("serviceInstanceID") + String jobId = execution.getVariable("jobId") + String nsiId = execution.getVariable("nsiId") + String operationType = execution.getVariable("operationType") + logger.debug("Generated new job for Service Instance serviceId:" + serviceId + " jobId:" + jobId) + + ResourceOperationStatus initStatus = new ResourceOperationStatus() + initStatus.setServiceId(serviceId) + initStatus.setOperationId(jobId) + initStatus.setResourceTemplateUUID(nsiId) + initStatus.setOperType(operationType) + requestDBUtil.prepareInitResourceOperationStatus(execution, initStatus) + + logger.debug(Prefix + "prepareInitOperationStatus Exit") + } + + + + /** + * return sync response + */ + def sendSyncResponse = { DelegateExecution execution -> + logger.debug(Prefix + "sendSyncResponse Start") + try { + String jobId = execution.getVariable("jobId") + String activateSyncResponse = """{"jobId": "${jobId}","status": "processing"}""" + .trim().replaceAll(" ", "") + + logger.debug("sendSyncResponse to APIH:" + "\n" + activateSyncResponse) + sendWorkflowResponse(execution, 202, activateSyncResponse) + + execution.setVariable("sentSyncResponse", true) + } catch (Exception ex) { + String msg = "Exception in sendSyncResponse:" + ex.getMessage() + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.debug(Prefix + "sendSyncResponse Exit") + } + } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/AllocateSliceSubnet.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/AllocateSliceSubnet.groovy index 5a7722d679..9100f2773b 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/AllocateSliceSubnet.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/AllocateSliceSubnet.groovy @@ -33,158 +33,158 @@ import static org.apache.commons.lang3.StringUtils.isBlank class AllocateSliceSubnet extends AbstractServiceTaskProcessor { - String Prefix="ASS_" - ExceptionUtil exceptionUtil = new ExceptionUtil() - RequestDBUtil requestDBUtil = new RequestDBUtil() - JsonUtils jsonUtil = new JsonUtils() - private static final Logger logger = LoggerFactory.getLogger(AllocateSliceSubnet.class) - - @Override - void preProcessRequest(DelegateExecution execution) { - logger.debug(Prefix + "preProcessRequest Start") - execution.setVariable("prefix", Prefix) - execution.setVariable("startTime", System.currentTimeMillis()) - def msg - try { - // get request input - String subnetInstanceReq = execution.getVariable("bpmnRequest") - logger.debug(subnetInstanceReq) - - String requestId = execution.getVariable("mso-request-id") - execution.setVariable("msoRequestId", requestId) - logger.debug("Input Request:" + subnetInstanceReq + " reqId:" + requestId) - - //modelInfo - String modelInvariantUuid = jsonUtil.getJsonValue(subnetInstanceReq, "modelInvariantUuid") - if (isBlank(modelInvariantUuid)) { - msg = "Input modelInvariantUuid is null" - logger.debug(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } else - { - execution.setVariable("modelInvariantUuid", modelInvariantUuid) - } - - logger.debug("modelInvariantUuid: " + modelInvariantUuid) - - String modelUuid = jsonUtil.getJsonValue(subnetInstanceReq, "modelUuid") - if (isBlank(modelUuid)) { - msg = "Input modelUuid is null" - logger.debug(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } else - { - execution.setVariable("modelUuid", modelUuid) - } - - logger.debug("modelUuid: " + modelUuid) - - - //subscriberInfo - String globalSubscriberId = jsonUtil.getJsonValue(subnetInstanceReq, "globalSubscriberId") - if (isBlank(globalSubscriberId)) { - msg = "Input globalSubscriberId' is null" - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } else { - execution.setVariable("globalSubscriberId", globalSubscriberId) - } - String dummyServiceId = new UUID(0,0).toString(); - execution.setVariable("dummyServiceId", dummyServiceId) - logger.debug("dummyServiceId: " + dummyServiceId) - String servicename = jsonUtil.getJsonValue(subnetInstanceReq, "name") - execution.setVariable("servicename", servicename) - - String nsiId = jsonUtil.getJsonValue(subnetInstanceReq, "additionalProperties.nsiInfo.nsiId") - if (isBlank(nsiId)) { - msg = "Input nsiId is null" - logger.debug(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } else - { - execution.setVariable("nsiId", nsiId) - } - - String networkType = jsonUtil.getJsonValue(subnetInstanceReq, "networkType") - if (isBlank(networkType)) { - msg = "Input networkType is null" - logger.debug(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } else - { - execution.setVariable("networkType", networkType.toUpperCase()) - } - - //requestParameters, subscriptionServiceType is 5G - String subscriptionServiceType = jsonUtil.getJsonValue(subnetInstanceReq, "subscriptionServiceType") - if (isBlank(subscriptionServiceType)) { - msg = "Input subscriptionServiceType is null" - logger.debug(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } else { - execution.setVariable("subscriptionServiceType", subscriptionServiceType) - } - - String jobId = UUID.randomUUID().toString() - execution.setVariable("jobId", jobId) - - String sliceParams = jsonUtil.getJsonValue(subnetInstanceReq, "additionalProperties") - execution.setVariable("sliceParams", sliceParams) - - } catch(BpmnError e) { - throw e - } catch(Exception ex) { - msg = "Exception in AllocateSliceSubnet.preProcessRequest " + ex.getMessage() - logger.debug(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - logger.debug(Prefix + "preProcessRequest Exit") - } - - - /** - * create operation status in request db - * - * Init the Operation Status - */ - def prepareInitOperationStatus = { DelegateExecution execution -> - logger.debug(Prefix + "prepareInitOperationStatus Start") - - String serviceId = execution.getVariable("dummyServiceId") - String jobId = execution.getVariable("jobId") - String nsiId = execution.getVariable("nsiId") - logger.debug("Generated new job for Service Instance serviceId:" + serviceId + " jobId:" + jobId) - - ResourceOperationStatus initStatus = new ResourceOperationStatus() - initStatus.setServiceId(serviceId) - initStatus.setOperationId(jobId) - initStatus.setResourceTemplateUUID(nsiId) - initStatus.setOperType("Allocate") - requestDBUtil.prepareInitResourceOperationStatus(execution, initStatus) - - logger.debug(Prefix + "prepareInitOperationStatus Exit") - } - - - /** - * return sync response - */ - def sendSyncResponse = { DelegateExecution execution -> - logger.debug(Prefix + "sendSyncResponse Start") - try { - String jobId = execution.getVariable("jobId") - String allocateSyncResponse = """{"jobId": "${jobId}","status": "processing"}""" - .trim().replaceAll(" ", "").trim().replaceAll(" ", "") - - logger.debug("sendSyncResponse to APIH:" + "\n" + allocateSyncResponse) - sendWorkflowResponse(execution, 202, allocateSyncResponse) - - execution.setVariable("sentSyncResponse", true) - } catch (Exception ex) { - String msg = "Exception in sendSyncResponse:" + ex.getMessage() - logger.debug(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - logger.debug(Prefix + "sendSyncResponse Exit") - } - + String Prefix="AllocateSliceSubnet_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + RequestDBUtil requestDBUtil = new RequestDBUtil() + JsonUtils jsonUtil = new JsonUtils() + private static final Logger logger = LoggerFactory.getLogger(AllocateSliceSubnet.class) + + @Override + void preProcessRequest(DelegateExecution execution) { + logger.debug(Prefix + "preProcessRequest Start") + execution.setVariable("prefix", Prefix) + execution.setVariable("startTime", System.currentTimeMillis()) + def msg + try { + // get request input + String subnetInstanceReq = execution.getVariable("bpmnRequest") + logger.debug(subnetInstanceReq) + + String requestId = execution.getVariable("mso-request-id") + execution.setVariable("msoRequestId", requestId) + logger.debug("Input Request:" + subnetInstanceReq + " reqId:" + requestId) + + //modelInfo + String modelInvariantUuid = jsonUtil.getJsonValue(subnetInstanceReq, "modelInvariantUuid") + if (isBlank(modelInvariantUuid)) { + msg = "Input modelInvariantUuid is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else + { + execution.setVariable("modelInvariantUuid", modelInvariantUuid) + } + + logger.debug("modelInvariantUuid: " + modelInvariantUuid) + + String modelUuid = jsonUtil.getJsonValue(subnetInstanceReq, "modelUuid") + if (isBlank(modelUuid)) { + msg = "Input modelUuid is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else + { + execution.setVariable("modelUuid", modelUuid) + } + + logger.debug("modelUuid: " + modelUuid) + + + //subscriberInfo + String globalSubscriberId = jsonUtil.getJsonValue(subnetInstanceReq, "globalSubscriberId") + if (isBlank(globalSubscriberId)) { + msg = "Input globalSubscriberId' is null" + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else { + execution.setVariable("globalSubscriberId", globalSubscriberId) + } + String dummyServiceId = new UUID(0,0).toString(); + execution.setVariable("dummyServiceId", dummyServiceId) + logger.debug("dummyServiceId: " + dummyServiceId) + String servicename = jsonUtil.getJsonValue(subnetInstanceReq, "name") + execution.setVariable("servicename", servicename) + + String nsiId = jsonUtil.getJsonValue(subnetInstanceReq, "additionalProperties.nsiInfo.nsiId") + if (isBlank(nsiId)) { + msg = "Input nsiId is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else + { + execution.setVariable("nsiId", nsiId) + } + + String networkType = jsonUtil.getJsonValue(subnetInstanceReq, "networkType") + if (isBlank(networkType)) { + msg = "Input networkType is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else + { + execution.setVariable("networkType", networkType.toUpperCase()) + } + + //requestParameters, subscriptionServiceType is 5G + String subscriptionServiceType = jsonUtil.getJsonValue(subnetInstanceReq, "subscriptionServiceType") + if (isBlank(subscriptionServiceType)) { + msg = "Input subscriptionServiceType is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else { + execution.setVariable("subscriptionServiceType", subscriptionServiceType) + } + + String jobId = UUID.randomUUID().toString() + execution.setVariable("jobId", jobId) + + String sliceParams = jsonUtil.getJsonValue(subnetInstanceReq, "additionalProperties") + execution.setVariable("sliceParams", sliceParams) + + } catch(BpmnError e) { + throw e + } catch(Exception ex) { + msg = "Exception in AllocateSliceSubnet.preProcessRequest " + ex.getMessage() + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.debug(Prefix + "preProcessRequest Exit") + } + + + /** + * create operation status in request db + * + * Init the Operation Status + */ + def prepareInitOperationStatus = { DelegateExecution execution -> + logger.debug(Prefix + "prepareInitOperationStatus Start") + + String serviceId = execution.getVariable("dummyServiceId") + String jobId = execution.getVariable("jobId") + String nsiId = execution.getVariable("nsiId") + logger.debug("Generated new job for Service Instance serviceId:" + serviceId + " jobId:" + jobId) + + ResourceOperationStatus initStatus = new ResourceOperationStatus() + initStatus.setServiceId(serviceId) + initStatus.setOperationId(jobId) + initStatus.setResourceTemplateUUID(nsiId) + initStatus.setOperType("Allocate") + requestDBUtil.prepareInitResourceOperationStatus(execution, initStatus) + + logger.debug(Prefix + "prepareInitOperationStatus Exit") + } + + + /** + * return sync response + */ + def sendSyncResponse = { DelegateExecution execution -> + logger.debug(Prefix + "sendSyncResponse Start") + try { + String jobId = execution.getVariable("jobId") + String allocateSyncResponse = """{"jobId": "${jobId}","status": "processing"}""" + .trim().replaceAll(" ", "").trim().replaceAll(" ", "") + + logger.debug("sendSyncResponse to APIH:" + "\n" + allocateSyncResponse) + sendWorkflowResponse(execution, 202, allocateSyncResponse) + + execution.setVariable("sentSyncResponse", true) + } catch (Exception ex) { + String msg = "Exception in sendSyncResponse:" + ex.getMessage() + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.debug(Prefix + "sendSyncResponse Exit") + } + } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeAllocateSliceSubnet.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeAllocateSliceSubnet.groovy index 964baa7a9d..65885f3516 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeAllocateSliceSubnet.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeAllocateSliceSubnet.groovy @@ -32,14 +32,13 @@ import org.slf4j.LoggerFactory import static org.apache.commons.lang3.StringUtils.isBlank class DeAllocateSliceSubnet extends AbstractServiceTaskProcessor { - String Prefix="DeASS_" - ExceptionUtil exceptionUtil = new ExceptionUtil() - JsonUtils jsonUtil = new JsonUtils() - RequestDBUtil requestDBUtil = new RequestDBUtil() - - private static final Logger logger = LoggerFactory.getLogger(DeAllocateSliceSubnet.class) - - @Override + String Prefix="DeAllocateSliceSubnet_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + RequestDBUtil requestDBUtil = new RequestDBUtil() + private static final Logger logger = LoggerFactory.getLogger(DeAllocateSliceSubnet.class) + + @Override void preProcessRequest(DelegateExecution execution) { logger.debug(Prefix + "preProcessRequest Start") execution.setVariable("prefix", Prefix) @@ -62,8 +61,8 @@ class DeAllocateSliceSubnet extends AbstractServiceTaskProcessor { } else { execution.setVariable("globalSubscriberId", globalSubscriberId) } - - //NSSI ID + + //NSSI ID String serviceInstanceID = jsonUtil.getJsonValue(subnetInstanceReq, "serviceInstanceID") if (isBlank(serviceInstanceID)) { msg = "Input serviceInstanceID is null" @@ -73,27 +72,27 @@ class DeAllocateSliceSubnet extends AbstractServiceTaskProcessor { { execution.setVariable("serviceInstanceID", serviceInstanceID) } - - String nsiId = jsonUtil.getJsonValue(subnetInstanceReq, "additionalProperties.nsiId") - if (isBlank(nsiId)) { - msg = "Input nsiId is null" - logger.debug(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } else - { - execution.setVariable("nsiId", nsiId) - } - - String networkType = jsonUtil.getJsonValue(subnetInstanceReq, "networkType") - if (isBlank(networkType)) { - msg = "Input networkType is null" - logger.debug(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } else - { - execution.setVariable("networkType", networkType.toUpperCase()) - } - + + String nsiId = jsonUtil.getJsonValue(subnetInstanceReq, "additionalProperties.nsiId") + if (isBlank(nsiId)) { + msg = "Input nsiId is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else + { + execution.setVariable("nsiId", nsiId) + } + + String networkType = jsonUtil.getJsonValue(subnetInstanceReq, "networkType") + if (isBlank(networkType)) { + msg = "Input networkType is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else + { + execution.setVariable("networkType", networkType.toUpperCase()) + } + //requestParameters, subscriptionServiceType is 5G String subscriptionServiceType = jsonUtil.getJsonValue(subnetInstanceReq, "subscriptionServiceType") if (isBlank(subscriptionServiceType)) { @@ -106,9 +105,9 @@ class DeAllocateSliceSubnet extends AbstractServiceTaskProcessor { String jobId = UUID.randomUUID().toString() execution.setVariable("jobId", jobId) - - String sliceParams = jsonUtil.getJsonValue(subnetInstanceReq, "additionalProperties") - execution.setVariable("sliceParams", sliceParams) + + String sliceParams = jsonUtil.getJsonValue(subnetInstanceReq, "additionalProperties") + execution.setVariable("sliceParams", sliceParams) } catch(BpmnError e) { throw e @@ -131,13 +130,13 @@ class DeAllocateSliceSubnet extends AbstractServiceTaskProcessor { String serviceId = execution.getVariable("serviceInstanceID") String jobId = execution.getVariable("jobId") - String nsiId = execution.getVariable("nsiId") + String nsiId = execution.getVariable("nsiId") logger.debug("Generated new job for Service Instance serviceId:" + serviceId + " jobId:" + jobId) ResourceOperationStatus initStatus = new ResourceOperationStatus() initStatus.setServiceId(serviceId) initStatus.setOperationId(jobId) - initStatus.setResourceTemplateUUID(nsiId) + initStatus.setResourceTemplateUUID(nsiId) initStatus.setOperType("Deallocate") requestDBUtil.prepareInitResourceOperationStatus(execution, initStatus) @@ -145,26 +144,26 @@ class DeAllocateSliceSubnet extends AbstractServiceTaskProcessor { } - - /** - * return sync response - */ - def sendSyncResponse = { DelegateExecution execution -> - logger.debug(Prefix + "sendSyncResponse Start") - try { - String jobId = execution.getVariable("jobId") - String deAllocateSyncResponse = """{"jobId": "${jobId}","status": "processing"}""".trim().replaceAll(" ", "") - - logger.debug("sendSyncResponse to APIH:" + "\n" + deAllocateSyncResponse) - sendWorkflowResponse(execution, 202, deAllocateSyncResponse) - - execution.setVariable("sentSyncResponse", true) - } catch (Exception ex) { - String msg = "Exception in sendSyncResponse:" + ex.getMessage() - logger.debug(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - logger.debug(Prefix + "sendSyncResponse Exit") - } + + /** + * return sync response + */ + def sendSyncResponse = { DelegateExecution execution -> + logger.debug(Prefix + "sendSyncResponse Start") + try { + String jobId = execution.getVariable("jobId") + String deAllocateSyncResponse = """{"jobId": "${jobId}","status": "processing"}""".trim().replaceAll(" ", "") + + logger.debug("sendSyncResponse to APIH:" + "\n" + deAllocateSyncResponse) + sendWorkflowResponse(execution, 202, deAllocateSyncResponse) + + execution.setVariable("sentSyncResponse", true) + } catch (Exception ex) { + String msg = "Exception in sendSyncResponse:" + ex.getMessage() + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.debug(Prefix + "sendSyncResponse Exit") + } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ModifySliceSubnet.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ModifySliceSubnet.groovy index 47489b7b84..0465a433eb 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ModifySliceSubnet.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ModifySliceSubnet.groovy @@ -32,142 +32,142 @@ import org.slf4j.LoggerFactory import static org.apache.commons.lang3.StringUtils.isBlank class ModifySliceSubnet extends AbstractServiceTaskProcessor { - String Prefix="MSS_" - ExceptionUtil exceptionUtil = new ExceptionUtil() - JsonUtils jsonUtil = new JsonUtils() - RequestDBUtil requestDBUtil = new RequestDBUtil() - - private static final Logger logger = LoggerFactory.getLogger(ModifySliceSubnet.class) - - @Override - void preProcessRequest(DelegateExecution execution) { - logger.debug(Prefix + "preProcessRequest Start") - execution.setVariable("prefix", Prefix) - execution.setVariable("startTime", System.currentTimeMillis()) - def msg - try { - // get request input - String subnetInstanceReq = execution.getVariable("bpmnRequest") - logger.debug(subnetInstanceReq) - - String requestId = execution.getVariable("mso-request-id") - execution.setVariable("msoRequestId", requestId) - logger.debug("Input Request:" + subnetInstanceReq + " reqId:" + requestId) - - //subscriberInfo - String globalSubscriberId = jsonUtil.getJsonValue(subnetInstanceReq, "globalSubscriberId") - if (isBlank(globalSubscriberId)) { - msg = "Input globalSubscriberId' is null" - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } else { - execution.setVariable("globalSubscriberId", globalSubscriberId) - } - - //NSSI Info - String serviceInstanceID = jsonUtil.getJsonValue(subnetInstanceReq, "serviceInstanceID") - if (isBlank(serviceInstanceID)) { - msg = "Input serviceInstanceID is null" - logger.debug(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } else - { - execution.setVariable("serviceInstanceID", serviceInstanceID) - } - - String servicename = jsonUtil.getJsonValue(subnetInstanceReq, "name") - execution.setVariable("servicename", servicename) - - String nsiId = jsonUtil.getJsonValue(subnetInstanceReq, "additionalProperties.nsiInfo.nsiId") - if (isBlank(nsiId)) { - msg = "Input nsiId is null" - logger.debug(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } else - { - execution.setVariable("nsiId", nsiId) - } - - String networkType = jsonUtil.getJsonValue(subnetInstanceReq, "networkType") - if (isBlank(networkType)) { - msg = "Input networkType is null" - logger.debug(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } else - { - execution.setVariable("networkType", networkType.toUpperCase()) - } - - //requestParameters, subscriptionServiceType is 5G - String subscriptionServiceType = jsonUtil.getJsonValue(subnetInstanceReq, "subscriptionServiceType") - if (isBlank(subscriptionServiceType)) { - msg = "Input subscriptionServiceType is null" - logger.debug(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } else { - execution.setVariable("subscriptionServiceType", subscriptionServiceType) - } - - String jobId = UUID.randomUUID().toString() - execution.setVariable("jobId", jobId) - - String sliceParams = jsonUtil.getJsonValue(subnetInstanceReq, "additionalProperties") - execution.setVariable("sliceParams", sliceParams) - - } catch(BpmnError e) { - throw e - } catch(Exception ex) { - msg = "Exception in ModifySliceSubnet.preProcessRequest " + ex.getMessage() - logger.debug(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - logger.debug(Prefix + "preProcessRequest Exit") - } - - - /** - * create operation status in request db - * - * Init the Operation Status - */ - def prepareInitOperationStatus = { DelegateExecution execution -> - logger.debug(Prefix + "prepareInitOperationStatus Start") - - String serviceId = execution.getVariable("serviceInstanceID") - String jobId = execution.getVariable("jobId") - String nsiId = execution.getVariable("nsiId") - logger.debug("Generated new job for Service Instance serviceId:" + serviceId + "jobId:" + jobId) - - ResourceOperationStatus initStatus = new ResourceOperationStatus() - initStatus.setServiceId(serviceId) - initStatus.setOperationId(jobId) - initStatus.setResourceTemplateUUID(nsiId) - initStatus.setOperType("Modify") - requestDBUtil.prepareInitResourceOperationStatus(execution, initStatus) - - logger.debug(Prefix + "prepareInitOperationStatus Exit") - } - - - - /** - * return sync response - */ - def sendSyncResponse = { DelegateExecution execution -> - logger.debug(Prefix + "sendSyncResponse Start") - try { - String jobId = execution.getVariable("jobId") - String modifySyncResponse = """{"jobId": "${jobId}","status": "processing"}""" - .trim().replaceAll(" ", "") - logger.debug("sendSyncResponse to APIH:" + "\n" + modifySyncResponse) - sendWorkflowResponse(execution, 202, modifySyncResponse) - - execution.setVariable("sentSyncResponse", true) - } catch (Exception ex) { - String msg = "Exception in sendSyncResponse:" + ex.getMessage() - logger.debug(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - logger.debug(Prefix + "sendSyncResponse Exit") - } + String Prefix="ModifySliceSubnet_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + RequestDBUtil requestDBUtil = new RequestDBUtil() + + private static final Logger logger = LoggerFactory.getLogger(ModifySliceSubnet.class) + + @Override + void preProcessRequest(DelegateExecution execution) { + logger.debug(Prefix + "preProcessRequest Start") + execution.setVariable("prefix", Prefix) + execution.setVariable("startTime", System.currentTimeMillis()) + def msg + try { + // get request input + String subnetInstanceReq = execution.getVariable("bpmnRequest") + logger.debug(subnetInstanceReq) + + String requestId = execution.getVariable("mso-request-id") + execution.setVariable("msoRequestId", requestId) + logger.debug("Input Request:" + subnetInstanceReq + " reqId:" + requestId) + + //subscriberInfo + String globalSubscriberId = jsonUtil.getJsonValue(subnetInstanceReq, "globalSubscriberId") + if (isBlank(globalSubscriberId)) { + msg = "Input globalSubscriberId' is null" + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else { + execution.setVariable("globalSubscriberId", globalSubscriberId) + } + + //NSSI Info + String serviceInstanceID = jsonUtil.getJsonValue(subnetInstanceReq, "serviceInstanceID") + if (isBlank(serviceInstanceID)) { + msg = "Input serviceInstanceID is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else + { + execution.setVariable("serviceInstanceID", serviceInstanceID) + } + + String servicename = jsonUtil.getJsonValue(subnetInstanceReq, "name") + execution.setVariable("servicename", servicename) + + String nsiId = jsonUtil.getJsonValue(subnetInstanceReq, "additionalProperties.nsiInfo.nsiId") + if (isBlank(nsiId)) { + msg = "Input nsiId is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else + { + execution.setVariable("nsiId", nsiId) + } + + String networkType = jsonUtil.getJsonValue(subnetInstanceReq, "networkType") + if (isBlank(networkType)) { + msg = "Input networkType is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else + { + execution.setVariable("networkType", networkType.toUpperCase()) + } + + //requestParameters, subscriptionServiceType is 5G + String subscriptionServiceType = jsonUtil.getJsonValue(subnetInstanceReq, "subscriptionServiceType") + if (isBlank(subscriptionServiceType)) { + msg = "Input subscriptionServiceType is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else { + execution.setVariable("subscriptionServiceType", subscriptionServiceType) + } + + String jobId = UUID.randomUUID().toString() + execution.setVariable("jobId", jobId) + + String sliceParams = jsonUtil.getJsonValue(subnetInstanceReq, "additionalProperties") + execution.setVariable("sliceParams", sliceParams) + + } catch(BpmnError e) { + throw e + } catch(Exception ex) { + msg = "Exception in ModifySliceSubnet.preProcessRequest " + ex.getMessage() + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.debug(Prefix + "preProcessRequest Exit") + } + + + /** + * create operation status in request db + * + * Init the Operation Status + */ + def prepareInitOperationStatus = { DelegateExecution execution -> + logger.debug(Prefix + "prepareInitOperationStatus Start") + + String serviceId = execution.getVariable("serviceInstanceID") + String jobId = execution.getVariable("jobId") + String nsiId = execution.getVariable("nsiId") + logger.debug("Generated new job for Service Instance serviceId:" + serviceId + "jobId:" + jobId) + + ResourceOperationStatus initStatus = new ResourceOperationStatus() + initStatus.setServiceId(serviceId) + initStatus.setOperationId(jobId) + initStatus.setResourceTemplateUUID(nsiId) + initStatus.setOperType("Modify") + requestDBUtil.prepareInitResourceOperationStatus(execution, initStatus) + + logger.debug(Prefix + "prepareInitOperationStatus Exit") + } + + + + /** + * return sync response + */ + def sendSyncResponse = { DelegateExecution execution -> + logger.debug(Prefix + "sendSyncResponse Start") + try { + String jobId = execution.getVariable("jobId") + String modifySyncResponse = """{"jobId": "${jobId}","status": "processing"}""" + .trim().replaceAll(" ", "") + logger.debug("sendSyncResponse to APIH:" + "\n" + modifySyncResponse) + sendWorkflowResponse(execution, 202, modifySyncResponse) + + execution.setVariable("sentSyncResponse", true) + } catch (Exception ex) { + String msg = "Exception in sendSyncResponse:" + ex.getMessage() + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.debug(Prefix + "sendSyncResponse Exit") + } } diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/AllocateSliceSubnet.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/AllocateSliceSubnet.bpmn index 450faaebca..29f024991d 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/AllocateSliceSubnet.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/AllocateSliceSubnet.bpmn @@ -91,13 +91,6 @@ nss.prepareInitOperationStatus(execution)</bpmn:script> </bpmn:scriptTask> <bpmn:sequenceFlow id="Flow_0ou7wr9" sourceRef="Activity_1hyt0pb" targetRef="Activity_1ydx2rx" /> <bpmn:sequenceFlow id="Flow_18cgkru" sourceRef="Activity_1ydx2rx" targetRef="Activity_0qlstj2" /> - <bpmn:callActivity id="CallDoAllocateTransportNSSI" name="Call TNAllocateNSSI" calledElement="DoAllocateTransportNSSI"> - <bpmn:extensionElements> - <camunda:in source="servicename" target="servicename" /> - </bpmn:extensionElements> - <bpmn:incoming>Flow_0g7721r</bpmn:incoming> - <bpmn:outgoing>Flow_189zwjw</bpmn:outgoing> - </bpmn:callActivity> <bpmn:sequenceFlow id="Flow_189zwjw" sourceRef="CallDoAllocateTransportNSSI" targetRef="Event_18u424w" /> <bpmn:callActivity id="CallDoAllocateCoreNSSI" name="Call CNAllocateNSSI" calledElement="DoAllocateCoreNSSI"> <bpmn:extensionElements> @@ -118,6 +111,24 @@ nss.prepareInitOperationStatus(execution)</bpmn:script> <bpmn:outgoing>Flow_1coedjo</bpmn:outgoing> </bpmn:callActivity> <bpmn:sequenceFlow id="Flow_1coedjo" sourceRef="CallDoAllocateCoreNSSI" targetRef="Event_18u424w" /> + <bpmn:callActivity id="CallDoAllocateTransportNSSI" name="Call TNAllocateNSSI" calledElement="DoAllocateTransportNSSI"> + <bpmn:extensionElements> + <camunda:in source="msoRequestId" target="msoRequestId" /> + <camunda:in source="modelInvariantUuid" target="modelInvariantUuid" /> + <camunda:in source="modelUuid" target="modelUuid" /> + <camunda:in source="globalSubscriberId" target="globalSubscriberId" /> + <camunda:in source="dummyServiceId" target="dummyServiceId" /> + <camunda:in source="nsiId" target="nsiId" /> + <camunda:in source="networkType" target="networkType" /> + <camunda:in source="subscriptionServiceType" target="subscriptionServiceType" /> + <camunda:in source="jobId" target="jobId" /> + <camunda:in source="sliceParams" target="sliceParams" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:in source="servicename" target="servicename" /> + </bpmn:extensionElements> + <bpmn:incoming>Flow_0g7721r</bpmn:incoming> + <bpmn:outgoing>Flow_189zwjw</bpmn:outgoing> + </bpmn:callActivity> </bpmn:process> <bpmndi:BPMNDiagram id="BPMNDiagram_1"> <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="AllocateSliceSubnet"> @@ -126,8 +137,8 @@ nss.prepareInitOperationStatus(execution)</bpmn:script> <di:waypoint x="1152" y="190" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="Flow_189zwjw_di" bpmnElement="Flow_189zwjw"> - <di:waypoint x="1080" y="300" /> - <di:waypoint x="1170" y="300" /> + <di:waypoint x="1080" y="290" /> + <di:waypoint x="1170" y="290" /> <di:waypoint x="1170" y="208" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="Flow_18cgkru_di" bpmnElement="Flow_18cgkru"> @@ -153,10 +164,10 @@ nss.prepareInitOperationStatus(execution)</bpmn:script> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="Flow_0g7721r_di" bpmnElement="Flow_0g7721r"> <di:waypoint x="890" y="215" /> - <di:waypoint x="890" y="300" /> - <di:waypoint x="980" y="300" /> + <di:waypoint x="890" y="290" /> + <di:waypoint x="980" y="290" /> <bpmndi:BPMNLabel> - <dc:Bounds x="912" y="273" width="36" height="14" /> + <dc:Bounds x="912" y="263" width="36" height="14" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="Flow_1fij4ds_di" bpmnElement="Flow_1fij4ds"> @@ -208,12 +219,13 @@ nss.prepareInitOperationStatus(execution)</bpmn:script> <bpmndi:BPMNShape id="Activity_1ydx2rx_di" bpmnElement="Activity_1ydx2rx"> <dc:Bounds x="380" y="150" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="Activity_008nbm9_di" bpmnElement="CallDoAllocateTransportNSSI"> - <dc:Bounds x="980" y="260" width="100" height="80" /> - </bpmndi:BPMNShape> <bpmndi:BPMNShape id="Activity_01669p4_di" bpmnElement="CallDoAllocateCoreNSSI"> <dc:Bounds x="980" y="150" width="100" height="80" /> </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_00awuik_di" bpmnElement="CallDoAllocateTransportNSSI"> + <dc:Bounds x="980" y="250" width="100" height="80" /> + </bpmndi:BPMNShape> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> </bpmn:definitions> + |