diff options
Diffstat (limited to 'bpmn')
38 files changed, 2827 insertions, 1687 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV1.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV1.groovy index 55f1187d69..6377d77d19 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV1.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV1.groovy @@ -56,349 +56,363 @@ class SDNCAdapterRestV1 extends AbstractServiceTaskProcessor { private static final Logger logger = LoggerFactory.getLogger( SDNCAdapterRestV1.class) - ExceptionUtil exceptionUtil = new ExceptionUtil() - JsonUtils jsonUtil = new JsonUtils() - - /** - * Processes the incoming request. - */ - public void preProcessRequest (DelegateExecution execution) { - def method = getClass().getSimpleName() + '.preProcessRequest(' + - 'execution=' + execution.getId() + - ')' - logger.trace('Entered ' + method) - - def prefix="SDNCREST_" - execution.setVariable("prefix", prefix) - setSuccessIndicator(execution, false) - - try { - // Determine the request type and log the request - - String request = validateRequest(execution, "mso-request-id") - String requestType = jsonUtil.getJsonRootProperty(request) - execution.setVariable(prefix + 'requestType', requestType) - logger.debug(getProcessKey(execution) + ': ' + prefix + 'requestType = ' + requestType) - - // Determine the SDNCAdapter endpoint - - String sdncAdapterEndpoint = UrnPropertiesReader.getVariable("mso.adapters.sdnc.rest.endpoint", execution) - - if (sdncAdapterEndpoint == null || sdncAdapterEndpoint.isEmpty()) { - String msg = getProcessKey(execution) + ': mso:adapters:sdnc:rest:endpoint URN mapping is not defined' - logger.debug(msg) - logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", - ErrorCode.UnknownError.getValue()) - exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) - } - - while (sdncAdapterEndpoint.endsWith('/')) { - sdncAdapterEndpoint = sdncAdapterEndpoint.substring(0, sdncAdapterEndpoint.length()-1) - } - - String sdncAdapterMethod = null - String sdncAdapterUrl = null - String sdncAdapterRequest = request - - if ('SDNCServiceRequest'.equals(requestType)) { - // Get the sdncRequestId from the request - - String sdncRequestId = jsonUtil.getJsonValue(request, requestType + ".sdncRequestId") - - if (sdncRequestId == null || sdncRequestId.isEmpty()) { - String msg = getProcessKey(execution) + ': no sdncRequestId in ' + requestType - logger.debug(msg) - logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", - ErrorCode.UnknownError.getValue()) - exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) - } - - execution.setVariable('SDNCAResponse_CORRELATOR', sdncRequestId) - logger.debug(getProcessKey(execution) + ': SDNCAResponse_CORRELATOR = ' + sdncRequestId) - - // Get the bpNotificationUrl from the request (just to make sure it's there) - - String bpNotificationUrl = jsonUtil.getJsonValue(request, requestType + ".bpNotificationUrl") - - if (bpNotificationUrl == null || bpNotificationUrl.isEmpty()) { - String msg = getProcessKey(execution) + ': no bpNotificationUrl in ' + requestType - logger.debug(msg) - logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", - ErrorCode.UnknownError.getValue()) - exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) - } - - sdncAdapterMethod = 'POST' - sdncAdapterUrl = sdncAdapterEndpoint - - RollbackData rollbackData = new RollbackData() - rollbackData.setRequestId(sdncRequestId) - rollbackData.getAdditionalData().put("service", jsonUtil.getJsonValue(request, requestType + ".sdncService")) - rollbackData.getAdditionalData().put("operation", jsonUtil.getJsonValue(request, requestType + ".sdncOperation")) - execution.setVariable("RollbackData", rollbackData) - - } else { - String msg = getProcessKey(execution) + ': Unsupported request type: ' + requestType - logger.debug(msg) - logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", - ErrorCode.UnknownError.getValue()) - exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) - } - - execution.setVariable(prefix + 'sdncAdapterMethod', sdncAdapterMethod) - execution.setVariable(prefix + 'sdncAdapterUrl', sdncAdapterUrl) - execution.setVariable(prefix + 'sdncAdapterRequest', sdncAdapterRequest) - - // Get the Basic Auth credentials for the SDNCAdapter (yes... we ARE using the PO adapters credentials) - - String basicAuthValue = UrnPropertiesReader.getVariable("mso.adapters.po.auth", execution) - - if (basicAuthValue == null || basicAuthValue.isEmpty()) { - logger.debug(getProcessKey(execution) + ": mso:adapters:po:auth URN mapping is not defined") - logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), - getProcessKey(execution) + ": mso:adapters:po:auth URN mapping is not defined", "BPMN", - ErrorCode.UnknownError.getValue()) - } else { - try { - def encodedString = utils.getBasicAuth(basicAuthValue, UrnPropertiesReader.getVariable("mso.msoKey", execution)) - execution.setVariable(prefix + 'basicAuthHeaderValue', encodedString) - } catch (IOException ex) { - logger.debug(getProcessKey(execution) + ": Unable to encode BasicAuth credentials for SDNCAdapter") - logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), - getProcessKey(execution) + ": Unable to encode BasicAuth credentials for SDNCAdapter", - "BPMN", ErrorCode.UnknownError.getValue(), ex) - } - } - - // Set the timeout value, e.g. PT5M. It may be specified in the request as the - // bpTimeout value. If it's not in the request, use the URN mapping value. - - String timeout = jsonUtil.getJsonValue(request, requestType + ".bpTimeout") - - // in addition to null/empty, also need to verify that the timer value is a valid duration "P[n]T[n]H|M|S" - String timerRegex = "PT[0-9]+[HMS]" - if (timeout == null || timeout.isEmpty() || !timeout.matches(timerRegex)) { - logger.debug(getProcessKey(execution) + ': preProcessRequest(): null/empty/invalid bpTimeout value. Using "mso.adapters.sdnc.timeout"') - timeout = UrnPropertiesReader.getVariable("mso.adapters.sdnc.timeout", execution) - } - - // the timeout could still be null at this point if the config parm is missing/undefined - // forced to log (so OPs can fix the config) and temporarily use a hard coded value of 10 seconds - if (timeout == null) { - msoLogger.warnSimple('preProcessRequest()', 'property "mso.adapters.sdnc.timeout" is missing/undefined. Using "PT10S"') - timeout = "PT10S" - } - - execution.setVariable(prefix + 'timeout', timeout) - logger.debug(getProcessKey(execution) + ': ' + prefix + 'timeout = ' + timeout) - } catch (BpmnError e) { - throw e - } catch (Exception e) { - String msg = 'Caught exception in ' + method + ": " + e - logger.debug(msg) - logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", - ErrorCode.UnknownError.getValue()) - exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) - } - } - - /** - * Sends the request to the SDNC adapter. - */ - public void sendRequestToSDNCAdapter(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.sendRequestToSDNCAdapter(' + - 'execution=' + execution.getId() + - ')' - logger.trace('Entered ' + method) - - String prefix = execution.getVariable('prefix') - - try { - String sdncAdapterMethod = execution.getVariable(prefix + 'sdncAdapterMethod') - logger.debug("SDNC Method is: " + sdncAdapterMethod) - String sdncAdapterUrl = execution.getVariable(prefix + 'sdncAdapterUrl') - logger.debug("SDNC Url is: " + sdncAdapterUrl) - String sdncAdapterRequest = execution.getVariable(prefix + 'sdncAdapterRequest') - logger.debug("SDNC Rest Request is: " + sdncAdapterRequest) - - URL url = new URL(sdncAdapterUrl) - - HttpClient httpClient = new HttpClientFactory().newJsonClient(url, ONAPComponents.SDNC_ADAPTER) - httpClient.addAdditionalHeader("mso-request-id", execution.getVariable("mso-request-id")) - httpClient.addAdditionalHeader("mso-service-instance-id", execution.getVariable("mso-service-instance-id")) - httpClient.addAdditionalHeader("Authorization", execution.getVariable(prefix + "basicAuthHeaderValue")) - - Response response - - if ("GET".equals(sdncAdapterMethod)) { - response = httpClient.get() - } else if ("PUT".equals(sdncAdapterMethod)) { - response = httpClient.put(sdncAdapterRequest) - } else if ("POST".equals(sdncAdapterMethod)) { - response = httpClient.post(sdncAdapterRequest) - } else if ("DELETE".equals(sdncAdapterMethod)) { - response = httpClient.delete(sdncAdapterRequest) - } else { - String msg = 'Unsupported HTTP method "' + sdncAdapterMethod + '" in ' + method + ": " + e - logger.debug(msg) - logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", - ErrorCode.UnknownError.getValue()) - exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) - } - - execution.setVariable(prefix + "sdncAdapterStatusCode", response.getStatus()) - if(response.hasEntity()){ - execution.setVariable(prefix + "sdncAdapterResponse", response.readEntity(String.class)) - } - } catch (BpmnError e) { - throw e - } catch (Exception e) { - String msg = 'Caught exception in ' + method + ": " + e - logger.debug(msg, e) - logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", - ErrorCode.UnknownError.getValue()) - exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) - } - } - - /** - * Processes a callback. - */ - public void processCallback(DelegateExecution execution){ - def method = getClass().getSimpleName() + '.processCallback(' + - 'execution=' + execution.getId() + - ')' - logger.trace('Entered ' + method) - - String prefix = execution.getVariable('prefix') - String callback = execution.getVariable('SDNCAResponse_MESSAGE') - logger.debug("Incoming SDNC Rest Callback is: " + callback) - - try { - int callbackNumber = 1 - while (execution.getVariable(prefix + 'callback' + callbackNumber) != null) { - ++callbackNumber - } - - execution.setVariable(prefix + 'callback' + callbackNumber, callback) - execution.removeVariable('SDNCAResponse_MESSAGE') - - String responseType = jsonUtil.getJsonRootProperty(callback) - - // Get the ackFinalIndicator and make sure it's either Y or N. Default to Y. - String ackFinalIndicator = jsonUtil.getJsonValue(callback, responseType + ".ackFinalIndicator") - - if (!'N'.equals(ackFinalIndicator)) { - ackFinalIndicator = 'Y' - } - - execution.setVariable(prefix + "ackFinalIndicator", ackFinalIndicator) - - if (responseType.endsWith('Error')) { - sdncAdapterBuildWorkflowException(execution, callback) - } - } catch (Exception e) { - callback = callback == null || String.valueOf(callback).isEmpty() ? "NONE" : callback - String msg = "Received error from SDNCAdapter: " + callback - logger.debug(getProcessKey(execution) + ': ' + msg) - exceptionUtil.buildWorkflowException(execution, 5300, msg) - } - } - - /** - * Tries to parse the response as XML to extract the information to create - * a WorkflowException. If the response cannot be parsed, a more generic - * WorkflowException is created. - */ - public void sdncAdapterBuildWorkflowException(DelegateExecution execution, String response) { - try { - String responseType = jsonUtil.getJsonRootProperty(response) - String responseCode = jsonUtil.getJsonValue(response, responseType + ".responseCode") - String responseMessage = jsonUtil.getJsonValue(response, responseType + ".responseMessage") - - String info = "" - - if (responseCode != null && !responseCode.isEmpty()) { - info += " responseCode='" + responseCode + "'" - } - - if (responseMessage != null && !responseMessage.isEmpty()) { - info += " responseMessage='" + responseMessage + "'" - } - - // Note: the mapping function handles a null or empty responseCode - int mappedResponseCode = Integer.parseInt(exceptionUtil.MapSDNCResponseCodeToErrorCode(responseCode)) - exceptionUtil.buildWorkflowException(execution, mappedResponseCode, "Received " + responseType + - " from SDNCAdapter:" + info) - } catch (Exception e) { - response = response == null || String.valueOf(response).isEmpty() ? "NONE" : response - exceptionUtil.buildWorkflowException(execution, 5300, "Received error from SDNCAdapter: " + response) - } - } - - /** - * Gets the last callback request from the execution, or null if there was no callback. - */ - public String getLastCallback(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.getLastCallback(' + - 'execution=' + execution.getId() + - ')' - logger.trace('Entered ' + method) - - String prefix = execution.getVariable('prefix') - - try { - int callbackNumber = 1 - String callback = null - - while (true) { - String thisCallback = (String) execution.getVariable(prefix + 'callback' + callbackNumber) - - if (thisCallback == null) { - break - } - - callback = thisCallback - ++callbackNumber - } - - return callback - } catch (Exception e) { - String msg = 'Caught exception in ' + method + ": " + e - logger.debug(msg) - logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", - ErrorCode.UnknownError.getValue()) - exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) - } - } - - /** - * Sets the timeout value to wait for the next notification. - */ - public void setTimeoutValue(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.setTimeoutValue(' + - 'execution=' + execution.getId() + - ')' - logger.trace('Entered ' + method) - - String prefix = execution.getVariable('prefix') - - try { - def timeoutValue = UrnPropertiesReader.getVariable("mso.adapters.sdnc.timeout", execution) - - if (execution.getVariable(prefix + 'callback1') != null) { - // Waiting for subsequent notifications - } - } catch (Exception e) { - String msg = 'Caught exception in ' + method + ": " + e - logger.debug(msg) - logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", - ErrorCode.UnknownError.getValue()) - exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) - } - } - - public Logger getLogger() { - return logger - } + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + + /** + * Processes the incoming request. + */ + public void preProcessRequest (DelegateExecution execution) { + def method = getClass().getSimpleName() + '.preProcessRequest(' + + 'execution=' + execution.getId() + + ')' + logger.trace('Entered ' + method) + + def prefix="SDNCREST_" + execution.setVariable("prefix", prefix) + setSuccessIndicator(execution, false) + + try { + // Determine the request type and log the request + + String request = validateRequest(execution, "mso-request-id") + String requestType = jsonUtil.getJsonRootProperty(request) + execution.setVariable(prefix + 'requestType', requestType) + logger.debug(getProcessKey(execution) + ': ' + prefix + 'requestType = ' + requestType) + + // Determine the SDNCAdapter endpoint + + String sdncAdapterEndpoint = UrnPropertiesReader.getVariable("mso.adapters.sdnc.rest.endpoint", execution) + + if (sdncAdapterEndpoint == null || sdncAdapterEndpoint.isEmpty()) { + String msg = getProcessKey(execution) + ': mso:adapters:sdnc:rest:endpoint URN mapping is not defined' + logger.debug(msg) + logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", + ErrorCode.UnknownError.getValue()) + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) + } + + while (sdncAdapterEndpoint.endsWith('/')) { + sdncAdapterEndpoint = sdncAdapterEndpoint.substring(0, sdncAdapterEndpoint.length()-1) + } + + String sdncAdapterMethod = null + String sdncAdapterUrl = null + String sdncAdapterRequest = request + + if ('SDNCServiceRequest'.equals(requestType)) { + // Get the sdncRequestId from the request + + String sdncRequestId = jsonUtil.getJsonValue(request, requestType + ".sdncRequestId") + + if (sdncRequestId == null || sdncRequestId.isEmpty()) { + String msg = getProcessKey(execution) + ': no sdncRequestId in ' + requestType + logger.debug(msg) + logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", + ErrorCode.UnknownError.getValue()) + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) + } + + execution.setVariable('SDNCAResponse_CORRELATOR', sdncRequestId) + logger.debug(getProcessKey(execution) + ': SDNCAResponse_CORRELATOR = ' + sdncRequestId) + + // Get the bpNotificationUrl from the request (just to make sure it's there) + + String bpNotificationUrl = jsonUtil.getJsonValue(request, requestType + ".bpNotificationUrl") + + if (bpNotificationUrl == null || bpNotificationUrl.isEmpty()) { + String msg = getProcessKey(execution) + ': no bpNotificationUrl in ' + requestType + logger.debug(msg) + logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", + ErrorCode.UnknownError.getValue()) + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) + } + + sdncAdapterMethod = 'POST' + sdncAdapterUrl = sdncAdapterEndpoint + + RollbackData rollbackData = new RollbackData() + rollbackData.setRequestId(sdncRequestId) + rollbackData.getAdditionalData().put("service", jsonUtil.getJsonValue(request, requestType + ".sdncService")) + rollbackData.getAdditionalData().put("operation", jsonUtil.getJsonValue(request, requestType + ".sdncOperation")) + execution.setVariable("RollbackData", rollbackData) + + } else { + String msg = getProcessKey(execution) + ': Unsupported request type: ' + requestType + logger.debug(msg) + logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", + ErrorCode.UnknownError.getValue()) + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) + } + + execution.setVariable(prefix + 'sdncAdapterMethod', sdncAdapterMethod) + execution.setVariable(prefix + 'sdncAdapterUrl', sdncAdapterUrl) + execution.setVariable(prefix + 'sdncAdapterRequest', sdncAdapterRequest) + + // Get the Basic Auth credentials for the SDNCAdapter (yes... we ARE using the PO adapters credentials) + + String basicAuthValue = UrnPropertiesReader.getVariable("mso.adapters.po.auth", execution) + + if (basicAuthValue == null || basicAuthValue.isEmpty()) { + logger.debug(getProcessKey(execution) + ": mso:adapters:po:auth URN mapping is not defined") + logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + getProcessKey(execution) + ": mso:adapters:po:auth URN mapping is not defined", "BPMN", + ErrorCode.UnknownError.getValue()) + } else { + try { + def encodedString = utils.getBasicAuth(basicAuthValue, UrnPropertiesReader.getVariable("mso.msoKey", execution)) + execution.setVariable(prefix + 'basicAuthHeaderValue', encodedString) + } catch (IOException ex) { + logger.debug(getProcessKey(execution) + ": Unable to encode BasicAuth credentials for SDNCAdapter") + logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + getProcessKey(execution) + ": Unable to encode BasicAuth credentials for SDNCAdapter", + "BPMN", ErrorCode.UnknownError.getValue(), ex) + } + } + + // Set the timeout value, e.g. PT5M. It may be specified in the request as the + // bpTimeout value. If it's not in the request, use the URN mapping value. + + String timeout = jsonUtil.getJsonValue(request, requestType + ".bpTimeout") + + // in addition to null/empty, also need to verify that the timer value is a valid duration "P[n]T[n]H|M|S" + String timerRegex = "PT[0-9]+[HMS]" + if (timeout == null || timeout.isEmpty() || !timeout.matches(timerRegex)) { + logger.debug(getProcessKey(execution) + ': preProcessRequest(): null/empty/invalid bpTimeout value. Using "mso.adapters.sdnc.timeout"') + timeout = UrnPropertiesReader.getVariable("mso.adapters.sdnc.timeout", execution) + } + + // the timeout could still be null at this point if the config parm is missing/undefined + // forced to log (so OPs can fix the config) and temporarily use a hard coded value of 10 seconds + if (timeout == null) { + msoLogger.warnSimple('preProcessRequest()', 'property "mso.adapters.sdnc.timeout" is missing/undefined. Using "PT10S"') + timeout = "PT10S" + } + + execution.setVariable(prefix + 'timeout', timeout) + + Boolean failOnCallbackError = execution.getVariable("failOnCallbackError") + if(failOnCallbackError == null) { + execution.setVariable("failOnCallbackError", true) + } + + logger.debug(getProcessKey(execution) + ': ' + prefix + 'timeout = ' + timeout) + } catch (BpmnError e) { + throw e + } catch (Exception e) { + String msg = 'Caught exception in ' + method + ": " + e + logger.debug(msg) + logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", + ErrorCode.UnknownError.getValue()) + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) + } + } + + /** + * Sends the request to the SDNC adapter. + */ + public void sendRequestToSDNCAdapter(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.sendRequestToSDNCAdapter(' + + 'execution=' + execution.getId() + + ')' + logger.trace('Entered ' + method) + + String prefix = execution.getVariable('prefix') + + try { + String sdncAdapterMethod = execution.getVariable(prefix + 'sdncAdapterMethod') + logger.debug("SDNC Method is: " + sdncAdapterMethod) + String sdncAdapterUrl = execution.getVariable(prefix + 'sdncAdapterUrl') + logger.debug("SDNC Url is: " + sdncAdapterUrl) + String sdncAdapterRequest = execution.getVariable(prefix + 'sdncAdapterRequest') + logger.debug("SDNC Rest Request is: " + sdncAdapterRequest) + + URL url = new URL(sdncAdapterUrl) + + HttpClient httpClient = new HttpClientFactory().newJsonClient(url, ONAPComponents.SDNC_ADAPTER) + httpClient.addAdditionalHeader("mso-request-id", execution.getVariable("mso-request-id")) + httpClient.addAdditionalHeader("mso-service-instance-id", execution.getVariable("mso-service-instance-id")) + httpClient.addAdditionalHeader("Authorization", execution.getVariable(prefix + "basicAuthHeaderValue")) + + Response response + + if ("GET".equals(sdncAdapterMethod)) { + response = httpClient.get() + } else if ("PUT".equals(sdncAdapterMethod)) { + response = httpClient.put(sdncAdapterRequest) + } else if ("POST".equals(sdncAdapterMethod)) { + response = httpClient.post(sdncAdapterRequest) + } else if ("DELETE".equals(sdncAdapterMethod)) { + response = httpClient.delete(sdncAdapterRequest) + } else { + String msg = 'Unsupported HTTP method "' + sdncAdapterMethod + '" in ' + method + ": " + e + logger.debug(msg) + logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", + ErrorCode.UnknownError.getValue()) + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) + } + + execution.setVariable(prefix + "sdncAdapterStatusCode", response.getStatus()) + if(response.hasEntity()){ + execution.setVariable(prefix + "sdncAdapterResponse", response.readEntity(String.class)) + } + } catch (BpmnError e) { + throw e + } catch (Exception e) { + String msg = 'Caught exception in ' + method + ": " + e + logger.debug(msg, e) + logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", + ErrorCode.UnknownError.getValue()) + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) + } + } + + /** + * Processes a callback. + */ + public void processCallback(DelegateExecution execution){ + def method = getClass().getSimpleName() + '.processCallback(' + + 'execution=' + execution.getId() + + ')' + logger.trace('Entered ' + method) + + String prefix = execution.getVariable('prefix') + String callback = execution.getVariable('SDNCAResponse_MESSAGE') + logger.debug("Incoming SDNC Rest Callback is: " + callback) + + try { + int callbackNumber = 1 + while (execution.getVariable(prefix + 'callback' + callbackNumber) != null) { + ++callbackNumber + } + + execution.setVariable(prefix + 'callback' + callbackNumber, callback) + execution.removeVariable('SDNCAResponse_MESSAGE') + + String responseType = jsonUtil.getJsonRootProperty(callback) + + // Get the ackFinalIndicator and make sure it's either Y or N. Default to Y. + String ackFinalIndicator = jsonUtil.getJsonValue(callback, responseType + ".ackFinalIndicator") + + if (!'N'.equals(ackFinalIndicator)) { + ackFinalIndicator = 'Y' + } + + execution.setVariable(prefix + "ackFinalIndicator", ackFinalIndicator) + + if (responseType.endsWith('Error')) { + Boolean failOnCallbackError = execution.getVariable("failOnCallbackError") + if(failOnCallbackError) { + sdncAdapterBuildWorkflowException(execution, callback) + }else { + if(ackFinalIndicator.equals('Y')) { + sdncAdapterBuildWorkflowException(execution, callback) + } + } + } + + } catch (Exception e) { + callback = callback == null || String.valueOf(callback).isEmpty() ? "NONE" : callback + String msg = "Received error from SDNCAdapter: " + callback + logger.debug(getProcessKey(execution) + ': ' + msg) + exceptionUtil.buildWorkflowException(execution, 5300, msg) + } + } + + /** + * Tries to parse the response as XML to extract the information to create + * a WorkflowException. If the response cannot be parsed, a more generic + * WorkflowException is created. + */ + public void sdncAdapterBuildWorkflowException(DelegateExecution execution, String response) { + try { + String responseType = jsonUtil.getJsonRootProperty(response) + String responseCode = jsonUtil.getJsonValue(response, responseType + ".responseCode") + String responseMessage = jsonUtil.getJsonValue(response, responseType + ".responseMessage") + + String info = "" + + if (responseCode != null && !responseCode.isEmpty()) { + info += " responseCode='" + responseCode + "'" + } + + if (responseMessage != null && !responseMessage.isEmpty()) { + info += " responseMessage='" + responseMessage + "'" + } + + // Note: the mapping function handles a null or empty responseCode + int mappedResponseCode = Integer.parseInt(exceptionUtil.MapSDNCResponseCodeToErrorCode(responseCode)) + exceptionUtil.buildWorkflowException(execution, mappedResponseCode, "Received " + responseType + + " from SDNCAdapter:" + info) + } catch (Exception e) { + response = response == null || String.valueOf(response).isEmpty() ? "NONE" : response + exceptionUtil.buildWorkflowException(execution, 5300, "Received error from SDNCAdapter: " + response) + } + } + + /** + * Gets the last callback request from the execution, or null if there was no callback. + */ + public String getLastCallback(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.getLastCallback(' + + 'execution=' + execution.getId() + + ')' + logger.trace('Entered ' + method) + + String prefix = execution.getVariable('prefix') + + try { + int callbackNumber = 1 + String callback = null + + while (true) { + String thisCallback = (String) execution.getVariable(prefix + 'callback' + callbackNumber) + + if (thisCallback == null) { + break + } + + callback = thisCallback + ++callbackNumber + } + + return callback + } catch (Exception e) { + String msg = 'Caught exception in ' + method + ": " + e + logger.debug(msg) + logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", + ErrorCode.UnknownError.getValue()) + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) + } + } + + /** + * Sets the timeout value to wait for the next notification. + */ + public void setTimeoutValue(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.setTimeoutValue(' + + 'execution=' + execution.getId() + + ')' + logger.trace('Entered ' + method) + + String prefix = execution.getVariable('prefix') + + try { + def timeoutValue = UrnPropertiesReader.getVariable("mso.adapters.sdnc.timeout", execution) + + if (execution.getVariable(prefix + 'callback1') != null) { + // Waiting for subsequent notifications + } + } catch (Exception e) { + String msg = 'Caught exception in ' + method + ": " + e + logger.debug(msg) + logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", + ErrorCode.UnknownError.getValue()) + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) + } + } + + public Logger getLogger() { + return logger + } } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildingBlockRainyDay.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildingBlockRainyDay.java index 4206596c94..3b84b150e0 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildingBlockRainyDay.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildingBlockRainyDay.java @@ -213,7 +213,8 @@ public class ExecuteBuildingBlockRainyDay { String targetState = ""; if ("RollbackToAssigned".equalsIgnoreCase(handlingCode)) { targetState = Status.ROLLED_BACK_TO_ASSIGNED.toString(); - } else if ("RollbackToCreated".equalsIgnoreCase(handlingCode)) { + } else if ("RollbackToCreated".equalsIgnoreCase(handlingCode) + || "RollbackToCreatedNoConfiguration".equalsIgnoreCase(handlingCode)) { targetState = Status.ROLLED_BACK_TO_CREATED.toString(); } else { targetState = Status.ROLLED_BACK.toString(); diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/ExceptionBuilder.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/ExceptionBuilder.java index 843cca0848..43db27917e 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/ExceptionBuilder.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/ExceptionBuilder.java @@ -232,6 +232,20 @@ public class ExceptionBuilder { throw new BpmnError("MSOWorkflowException"); } + public void buildAndThrowWorkflowException(DelegateExecution execution, int errorCode, String errorMessage, + ONAPComponentsList extSystemErrorSource, String workStep) { + String processKey = getProcessKey(execution); + logger.info("Building a WorkflowException for Subflow"); + + WorkflowException exception = + new WorkflowException(processKey, errorCode, errorMessage, workStep, extSystemErrorSource); + execution.setVariable("WorkflowException", exception); + execution.setVariable("WorkflowExceptionErrorMessage", errorMessage); + logger.info("Outgoing WorkflowException is {}", exception); + logger.info("Throwing MSOWorkflowException"); + throw new BpmnError("MSOWorkflowException"); + } + public WorkflowException buildWorkflowException(DelegateExecution execution, int errorCode, String errorMessage, ONAPComponentsList extSystemErrorSource) { String processKey = getProcessKey(execution); diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildingBlockRainyDayTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildingBlockRainyDayTest.java index ee47b514d1..b34d9dce9c 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildingBlockRainyDayTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildingBlockRainyDayTest.java @@ -259,6 +259,35 @@ public class ExecuteBuildingBlockRainyDayTest extends BaseTest { assertEquals(Status.ROLLED_BACK_TO_CREATED.toString(), delegateExecution.getVariable("rollbackTargetState")); } + @Test + public void queryRainyDayTableRollbackToCreatedNoConfiguration() throws Exception { + customer.getServiceSubscription().getServiceInstances().add(serviceInstance); + serviceInstance.getModelInfoServiceInstance().setServiceType("st1"); + vnf.setVnfType("vnft1"); + BuildingBlock buildingBlock = new BuildingBlock().setBpmnFlowName("AddFabricConfigurationBB"); + ExecuteBuildingBlock executeBuildingBlock = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock); + delegateExecution.setVariable("buildingBlock", executeBuildingBlock); + delegateExecution.setVariable("aLaCarte", true); + delegateExecution.setVariable("suppressRollback", false); + delegateExecution.setVariable("WorkflowExceptionCode", "7000"); + RainyDayHandlerStatus rainyDayHandlerStatus = new RainyDayHandlerStatus(); + rainyDayHandlerStatus.setErrorCode("7000"); + rainyDayHandlerStatus.setFlowName("AddFabricConfigurationBB"); + rainyDayHandlerStatus.setServiceType("st1"); + rainyDayHandlerStatus.setVnfType("vnft1"); + rainyDayHandlerStatus.setPolicy("RollbackToCreatedNoConfiguration"); + rainyDayHandlerStatus.setWorkStep(ASTERISK); + rainyDayHandlerStatus.setSecondaryPolicy("Abort"); + + doReturn(rainyDayHandlerStatus).when(MOCK_catalogDbClient).getRainyDayHandlerStatus("AddFabricConfigurationBB", + "st1", "vnft1", "7000", "*", "errorMessage", "*"); + + executeBuildingBlockRainyDay.queryRainyDayTable(delegateExecution, true); + + assertEquals("RollbackToCreatedNoConfiguration", delegateExecution.getVariable("handlingCode")); + assertEquals(Status.ROLLED_BACK_TO_CREATED.toString(), delegateExecution.getVariable("rollbackTargetState")); + } + @Test public void suppressRollbackTest() throws Exception { diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/exception/ExceptionBuilderUnitTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/exception/ExceptionBuilderUnitTest.java index 5baafbba67..b7e4dd98d8 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/exception/ExceptionBuilderUnitTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/exception/ExceptionBuilderUnitTest.java @@ -22,6 +22,7 @@ package org.onap.so.client.exception; +import static org.junit.Assert.assertEquals; import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.times; @@ -39,6 +40,7 @@ import org.mockito.Mock; import org.mockito.Spy; import org.mockito.junit.MockitoJUnitRunner; import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.core.WorkflowException; import org.onap.logging.filter.base.ONAPComponents; @RunWith(MockitoJUnitRunner.class) @@ -95,4 +97,17 @@ public class ExceptionBuilderUnitTest { thrown.expect(BpmnError.class); exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, e.getMessage(), ONAPComponents.SDNC); } + + @Test + public void buildAndThrowWorkflowExceptionWithWorkStepTest() { + doReturn("Process key").when(exceptionBuilder).getProcessKey(execution); + + try { + exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, e.getMessage(), ONAPComponents.SDNC, + "WORKSTEP"); + } catch (BpmnError e) { + } + WorkflowException workflowException = (WorkflowException) execution.getVariable("WorkflowException"); + assertEquals("WORKSTEP", workflowException.getWorkStep()); + } } diff --git a/bpmn/mso-infrastructure-bpmn/src/main/resources/org.onap.so.p12 b/bpmn/mso-infrastructure-bpmn/src/main/resources/org.onap.so.p12 Binary files differindex 79631bf344..50602dde95 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/resources/org.onap.so.p12 +++ b/bpmn/mso-infrastructure-bpmn/src/main/resources/org.onap.so.p12 diff --git a/bpmn/mso-infrastructure-bpmn/src/main/resources/org.onap.so.trust.jks b/bpmn/mso-infrastructure-bpmn/src/main/resources/org.onap.so.trust.jks Binary files differindex 6f8168d896..7b67a40bb9 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/resources/org.onap.so.trust.jks +++ b/bpmn/mso-infrastructure-bpmn/src/main/resources/org.onap.so.trust.jks diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/WorkflowActionBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/WorkflowActionBB.bpmn index f2e0ce29ff..5fd9701880 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/WorkflowActionBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/WorkflowActionBB.bpmn @@ -95,7 +95,7 @@ </bpmn:serviceTask> </bpmn:subProcess> <bpmn:sequenceFlow id="SequenceFlow_0v588sm" name="Rollback = true" sourceRef="ExclusiveGateway_Finished" targetRef="Task_RollbackExecutionPath"> - <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${execution.getVariable("handlingCode")=="Rollback"||execution.getVariable("handlingCode")=="RollbackToAssigned"||execution.getVariable("handlingCode")=="RollbackToCreated"}</bpmn:conditionExpression> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${execution.getVariable("handlingCode")=="Rollback"||execution.getVariable("handlingCode")=="RollbackToAssigned"||execution.getVariable("handlingCode")=="RollbackToCreated"||execution.getVariable("handlingCode")=="RollbackToCreatedNoConfiguration"}</bpmn:conditionExpression> </bpmn:sequenceFlow> <bpmn:sequenceFlow id="SequenceFlow_1atzsgn" sourceRef="Task_RollbackExecutionPath" targetRef="Task_SelectBB"> <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${execution.getVariable("isRollbackNeeded")==true}</bpmn:conditionExpression> diff --git a/bpmn/so-bpmn-infrastructure-common/pom.xml b/bpmn/so-bpmn-infrastructure-common/pom.xml index 5dad9b8687..ebc0264c7e 100644 --- a/bpmn/so-bpmn-infrastructure-common/pom.xml +++ b/bpmn/so-bpmn-infrastructure-common/pom.xml @@ -143,17 +143,14 @@ <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-spring-boot-starter-jaxws</artifactId> - <version>${cxf.version}</version> </dependency> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-spring-boot-starter-jaxrs</artifactId> - <version>${cxf.version}</version> </dependency> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-rs-service-description-swagger</artifactId> - <version>${cxf.version}</version> </dependency> <dependency> <groupId>com.h2database</groupId> 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/CreateSliceService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSliceService.groovy index c5f77ff172..72fd052f31 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSliceService.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSliceService.groovy @@ -20,6 +20,8 @@ package org.onap.so.bpmn.infrastructure.scripts +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder + import static org.apache.commons.lang3.StringUtils.* import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution @@ -52,11 +54,15 @@ public class CreateSliceService extends AbstractServiceTaskProcessor { String Prefix = "CRESS_" ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + JsonSlurper jsonSlurper = new JsonSlurper() + ObjectMapper objectMapper = new ObjectMapper() + OofUtils oofUtils = new OofUtils() - NssmfAdapterUtils nssmfAdapterUtils = new NssmfAdapterUtils(httpClientFactory, jsonUtil) + AAIResourcesClient client = getAAIClient() private static final Logger logger = LoggerFactory.getLogger(CreateSliceService.class) @@ -266,10 +272,8 @@ public class CreateSliceService extends AbstractServiceTaskProcessor { execution.setVariable("sliceTaskParams", sliceTaskParams) - //todo:---------------------------------------- -// String paramJson = sliceTaskParams.convertToJson() -// execution.setVariable("CSSOT_paramJson", paramJson) - /*-------------------------------------------*/ + String paramJson = sliceTaskParams.convertToJson() + execution.setVariable("CSSOT_paramJson", paramJson) logger.debug("Finish createOrchestrationTask") } @@ -359,7 +363,8 @@ public class CreateSliceService extends AbstractServiceTaskProcessor { logger.debug("Start prepareUpdateOrchestrationTask") String requestMethod = "PUT" String taskStatus = execution.getVariable("taskStatus") - SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams") + SliceTaskParamsAdapter sliceTaskParams = + execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter String paramJson = sliceTaskParams.convertToJson() execution.setVariable("CSSOT_status", taskStatus) execution.setVariable("CSSOT_paramJson", paramJson) @@ -389,7 +394,7 @@ public class CreateSliceService extends AbstractServiceTaskProcessor { OrchestrationTask orchestrationTask = objectMapper.readValue(response, OrchestrationTask.class) String paramJson = orchestrationTask.getParams() logger.debug("paramJson: " + paramJson) - SliceTaskParams sliceTaskParams = new SliceTaskParams() + SliceTaskParamsAdapter sliceTaskParams = new SliceTaskParamsAdapter() sliceTaskParams.convertFromJson(paramJson) execution.setVariable("sliceTaskParams", sliceTaskParams) logger.debug("Finish processUserOptions") @@ -403,7 +408,7 @@ public class CreateSliceService extends AbstractServiceTaskProcessor { try { ServiceInstance si = new ServiceInstance() si.setOrchestrationStatus(orchStatus) - AAIResourcesClient client = new AAIResourcesClient() + AAIResourceUri uri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(serviceInstanceId)) client.update(uri, si) } catch (BpmnError e) { 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/DoActivateTnNssi.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateTnNssi.groovy index 0900863a62..e5c9514fa5 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateTnNssi.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateTnNssi.groovy @@ -158,7 +158,7 @@ public class DoActivateTnNssi extends AbstractServiceTaskProcessor { roStatus.setProgress(progress) roStatus.setStatus(status) roStatus.setStatusDescription(statusDescription) - requestDBUtil.prepareUpdateResourceOperationStatus(execution, status) + requestDBUtil.prepareUpdateResourceOperationStatus(execution, roStatus) } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSSI.groovy index 88014e7b54..3e834fa7bb 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSSI.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSSI.groovy @@ -4,6 +4,7 @@ import com.fasterxml.jackson.databind.ObjectMapper import org.apache.commons.lang3.StringUtils import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.so.beans.nsmf.EsrInfo +import org.onap.so.beans.nsmf.JobStatusResponse import org.onap.so.beans.nsmf.NssiResponse import org.onap.so.beans.nsmf.NssmfAdapterNBIRequest import org.onap.so.beans.nsmf.ResponseDescriptor @@ -17,7 +18,6 @@ import org.onap.so.bpmn.common.scripts.NssmfAdapterUtils import org.onap.so.bpmn.core.json.JsonUtils import org.slf4j.Logger import org.slf4j.LoggerFactory -import org.springframework.http.ResponseEntity class DoAllocateNSSI extends AbstractServiceTaskProcessor { @@ -34,7 +34,7 @@ class DoAllocateNSSI extends AbstractServiceTaskProcessor { private static final NSSMF_ALLOCATE_URL = "/api/rest/provMns/v1/NSS/SliceProfiles" - private static final NSSMF_QUERY_JOB_STATUS_URL = "/NSS/jobs/%s" + private static final NSSMF_QUERY_JOB_STATUS_URL = "/api/rest/provMns/v1/NSS/jobs/%s" @Override void preProcessRequest(DelegateExecution execution) { @@ -64,11 +64,12 @@ class DoAllocateNSSI extends AbstractServiceTaskProcessor { NssmfAdapterNBIRequest nbiRequest = execution.getVariable("nbiRequest") as NssmfAdapterNBIRequest String response = nssmfAdapterUtils.sendPostRequestNSSMF(execution, NSSMF_ALLOCATE_URL, objectMapper.writeValueAsString(nbiRequest)) - ResponseEntity responseEntity = objectMapper.readValue(response, ResponseEntity.class) - String respBody = responseEntity.getBody() - NssiResponse result = objectMapper.readValue(respBody, NssiResponse.class) - //todo: if success - //todo: + + if (response != null) { + NssiResponse nssiResponse = objectMapper.readValue(response, NssiResponse.class) + execution.setVariable("nssiAllocateResult", nssiResponse) + } + execution.setVariable("serviceInfo", nbiRequest.getServiceInfo()) execution.setVariable("esrInfo", nbiRequest.getEsrInfo()) } @@ -96,13 +97,14 @@ class DoAllocateNSSI extends AbstractServiceTaskProcessor { String response = nssmfAdapterUtils.sendPostRequestNSSMF(execution, endpoint, objectMapper.writeValueAsString(nbiRequest)) - ResponseEntity responseEntity = objectMapper.readValue(response, ResponseEntity.class) - String result = responseEntity.getBody() - //todo;if success - ResponseDescriptor responseDescriptor = objectMapper.readValue(result, ResponseDescriptor.class) + if (response != null) { + JobStatusResponse jobStatusResponse = objectMapper.readValue(response, JobStatusResponse.class) + execution.setVariable("nssiAllocateStatus", jobStatusResponse) - //todo: handle status - execution.setVariable("nssiAllocateResult", responseDescriptor) + if (jobStatusResponse.getResponseDescriptor().getProgress() == 100) { + execution.setVariable("jobFinished", true) + } + } } void prepareUpdateOrchestrationTask(DelegateExecution execution) { @@ -111,10 +113,10 @@ class DoAllocateNSSI extends AbstractServiceTaskProcessor { SliceTaskParamsAdapter sliceParams = execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter - ResponseDescriptor response = execution.getVariable("nssiAllocateResult") as ResponseDescriptor + JobStatusResponse jobStatusResponse = execution.getVariable("nssiAllocateStatus") as JobStatusResponse + ResponseDescriptor response = jobStatusResponse.getResponseDescriptor() SubnetType subnetType = execution.getVariable("subnetType") as SubnetType - SliceTaskInfo sliceTaskInfo = execution.getVariable("sliceTaskInfo") as SliceTaskInfo sliceTaskInfo.progress = response.getProgress() sliceTaskInfo.status = response.getStatus() @@ -127,6 +129,7 @@ class DoAllocateNSSI extends AbstractServiceTaskProcessor { execution.setVariable("sliceTaskParams", sliceParams) execution.setVariable("sliceTaskInfo", sliceTaskInfo) + logger.debug("Finish prepareUpdateOrchestrationTask progress") } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCommonCoreNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCommonCoreNSSI.groovy index e225c360ed..646861a6a0 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCommonCoreNSSI.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCommonCoreNSSI.groovy @@ -22,15 +22,9 @@ package org.onap.so.bpmn.infrastructure.scripts import com.fasterxml.jackson.databind.ObjectMapper import org.camunda.bpm.engine.delegate.DelegateExecution -import org.onap.aai.domain.yang.CloudRegion -import org.onap.aai.domain.yang.GenericVnf -import org.onap.aai.domain.yang.ModelVer -import org.onap.aai.domain.yang.ServiceInstance -import org.onap.aai.domain.yang.ServiceSubscription -import org.onap.aai.domain.yang.SliceProfile -import org.onap.aai.domain.yang.Tenant -import org.onap.aai.domain.yang.VfModule -import org.onap.aaiclient.client.aai.AAIObjectType +import org.json.JSONArray +import org.json.JSONObject +import org.onap.aai.domain.yang.v19.* import org.onap.aaiclient.client.aai.AAIResourcesClient import org.onap.aaiclient.client.aai.entities.AAIResultWrapper import org.onap.aaiclient.client.aai.entities.Relationships @@ -39,35 +33,20 @@ import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types import org.onap.logging.filter.base.ONAPComponents -import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor -import org.onap.so.bpmn.common.scripts.ExceptionUtil -import org.onap.so.bpmn.common.scripts.RequestDBUtil +import org.onap.so.bpmn.common.scripts.* import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.bpmn.core.json.JsonUtils import org.onap.so.client.HttpClient -import org.onap.so.db.request.beans.OperationStatus -import org.onap.so.requestsdb.RequestsDbConstant -import org.onap.so.serviceinstancebeans.CloudConfiguration -import org.onap.so.serviceinstancebeans.LineOfBusiness -import org.onap.so.serviceinstancebeans.ModelInfo -import org.onap.so.serviceinstancebeans.ModelType -import org.onap.so.serviceinstancebeans.OwningEntity -import org.onap.so.serviceinstancebeans.Project -import org.onap.so.serviceinstancebeans.RequestDetails -import org.onap.so.serviceinstancebeans.RequestInfo -import org.onap.so.serviceinstancebeans.RequestParameters -import org.onap.so.serviceinstancebeans.Resources -import org.onap.so.serviceinstancebeans.Service -import org.onap.so.serviceinstancebeans.SubscriberInfo -import org.onap.so.serviceinstancebeans.VfModules -import org.onap.so.serviceinstancebeans.Vnfs +import org.onap.so.db.request.beans.ResourceOperationStatus +import org.onap.so.serviceinstancebeans.* import org.slf4j.Logger import org.slf4j.LoggerFactory import javax.ws.rs.core.Response +import static org.apache.commons.lang3.StringUtils.isBlank - class DoCommonCoreNSSI extends AbstractServiceTaskProcessor { +class DoCommonCoreNSSI extends AbstractServiceTaskProcessor { private final String PREFIX ="DoCommonCoreNSSI" @@ -83,10 +62,54 @@ import javax.ws.rs.core.Response def currentNSSI = execution.getVariable("currentNSSI") if (!currentNSSI) { - String msg = "currentNSSI is null" + currentNSSI = [:] + } + + // NSSI ID + String nssiId = execution.getVariable("serviceInstanceID") + if (isBlank(nssiId)) { + String msg = "NSSI service instance id is null" + LOGGER.error(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + else { + currentNSSI['nssiId'] = nssiId + } + + // NSI ID + String nsiId = execution.getVariable("nsiId") + if (isBlank(nsiId)) { + String msg = "nsiId is null" LOGGER.error(msg) exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) } + else { + currentNSSI['nsiId'] = nsiId + } + + + // Slice Profile + String sliceProfile = jsonUtil.getJsonValue(execution.getVariable("sliceParams"), "sliceProfile") + if (isBlank(sliceProfile)) { + String msg = "Slice Profile is null" + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else { + currentNSSI['sliceProfile'] = sliceProfile + } + + // S-NSSAI + def snssaiList = jsonUtil.StringArrayToList(jsonUtil.getJsonValue(sliceProfile, "snssaiList")) + + String sNssai = snssaiList.get(0) + currentNSSI['S-NSSAI'] = sNssai + + + // Slice Profile id + String sliceProfileId = jsonUtil.getJsonValue(sliceProfile, "sliceProfileId") + currentNSSI['sliceProfileId'] = sliceProfileId + + execution.setVariable("currentNSSI", currentNSSI) + LOGGER.trace("***** ${getPrefix()} Exit preProcessRequest") } @@ -223,11 +246,61 @@ import javax.ws.rs.core.Response void getNSSIAssociatedProfiles(DelegateExecution execution) { LOGGER.trace("${getPrefix()} Start getNSSIAssociatedProfiles") + List<SliceProfile> associatedProfiles = new ArrayList<>() + + AAIResourcesClient client = getAAIClient() + def currentNSSI = execution.getVariable("currentNSSI") ServiceInstance nssi = (ServiceInstance)currentNSSI['nssi'] - List<SliceProfile> associatedProfiles = nssi.getSliceProfiles().getSliceProfile() + String nssiId = currentNSSI['nssiId'] + + // NSSI + AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nssiId)) + AAIResultWrapper nssiWrapper = client.get(nssiUri) + Optional<Relationships> nssiRelationships = nssiWrapper.getRelationships() + + if (nssiRelationships.isPresent()) { + // Allotted Resource + for (AAIResourceUri allottedResourceUri : nssiRelationships.get().getRelatedUris(Types.ALLOTTED_RESOURCE)) { + AAIResultWrapper arWrapper = client.get(allottedResourceUri) + Optional<Relationships> arRelationships = arWrapper.getRelationships() + + boolean isFound = false + if(arRelationships.isPresent()) { + // Slice Profile Instance + for (AAIResourceUri sliceProfileInstanceUri : arRelationships.get().getRelatedUris(Types.SERVICE_INSTANCE)) { + Optional<ServiceInstance> sliceProfileInstanceOpt = client.get(ServiceInstance.class, sliceProfileInstanceUri) + + if (sliceProfileInstanceOpt.isPresent()) { + ServiceInstance sliceProfileInstance = sliceProfileInstanceOpt.get() + if(sliceProfileInstance.getServiceRole().equals("slice-profile-instance")) { // Service instance as a Slice Profile Instance + associatedProfiles = sliceProfileInstance.getSliceProfiles()?.getSliceProfile() + + currentNSSI['sliceProfileInstanceUri'] = sliceProfileInstanceUri + + isFound = true + break // Should be only one + } + } + else { + exceptionUtil.buildAndThrowWorkflowException(execution, 500, "No Slice Profile Instance found") + } + } + } + else { + exceptionUtil.buildAndThrowWorkflowException(execution, 500, "No relationships found for Allotted Resource") + } + + if(isFound) { + break + } + } + } + else { + exceptionUtil.buildAndThrowWorkflowException(execution, 500, "No relationships found for nssi id = " + nssiId) + } if(associatedProfiles.isEmpty()) { String msg = String.format("No associated profiles found for NSSI %s in AAI", nssi.getServiceInstanceId()) @@ -257,7 +330,7 @@ import javax.ws.rs.core.Response List<String> snssais = new ArrayList<>() - String isCreateSliceProfileInstanceVar = execution.getVariable("isCreateSliceProfileInstance" ) + String isCreateSliceProfileInstanceVar = execution.getVariable("isCreateSliceProfileInstance" ) // Not exist in case of Deallocate boolean isCreateSliceProfileInstance = Boolean.parseBoolean(isCreateSliceProfileInstanceVar) @@ -294,14 +367,14 @@ import javax.ws.rs.core.Response def currentNSSI = execution.getVariable("currentNSSI") try { - //url:/onap/so/infra/serviceInstantiation/v7/serviceInstances/{serviceInstanceId}/vnfs/{vnfId}" - def nsmfЕndpoint = UrnPropertiesReader.getVariable("mso.infra.endpoint.url", execution) // ??? + //url:/onap/so/infra/serviceInstantiation/v7/serviceInstances/{serviceInstanceId}" + def nsmfЕndPoint = UrnPropertiesReader.getVariable("mso.infra.endpoint.url", execution) // ??? ServiceInstance networkServiceInstance = (ServiceInstance)currentNSSI['networkServiceInstance'] - GenericVnf constituteVnf = (GenericVnf)currentNSSI['constituteVnf'] + String url = String.format("${nsmfЕndPoint}/serviceInstantiation/v7/serviceInstances/%s", networkServiceInstance.getServiceInstanceId()) - String url = String.format("${nsmfЕndpoint}/serviceInstantiation/v7/serviceInstances/%s/vnfs/%s", networkServiceInstance.getServiceInstanceId(), constituteVnf.getVnfId()) + currentNSSI['putServiceInstanceURL'] = url String msoKey = UrnPropertiesReader.getVariable("mso.msoKey", execution) String basicAuth = UrnPropertiesReader.getVariable("mso.infra.endpoint.auth", execution) @@ -332,7 +405,7 @@ import javax.ws.rs.core.Response String putServiceInstanceResponse = "" if(errorCode == null || errorCode.isEmpty()) { // No error - putServiceInstanceResponse = callPUTServiceInstanceResponse // check the response ??? + putServiceInstanceResponse = callPUTServiceInstanceResponse } else { LOGGER.error(jsonUtil.getJsonValue(callPUTServiceInstanceResponse, "errorMessage")) @@ -430,9 +503,9 @@ import javax.ws.rs.core.Response SubscriberInfo prepareSubscriberInfo(DelegateExecution execution) { def currentNSSI = execution.getVariable("currentNSSI") - String globalSubscriberId = currentNSSI['globalSubscriberId'] + String globalSubscriberId = execution.getVariable("globalSubscriberId") - String subscriberName = currentNSSI['subscriberName'] + String subscriberName = execution.getVariable("subscriberName") SubscriberInfo subscriberInfo = new SubscriberInfo() subscriberInfo.setGlobalSubscriberId(globalSubscriberId) @@ -484,13 +557,13 @@ import javax.ws.rs.core.Response RequestInfo prepareRequestInfo(DelegateExecution execution, ServiceInstance networkServiceInstance) { def currentNSSI = execution.getVariable("currentNSSI") - String serviceId = currentNSSI['serviceId'] + String productFamilyId = execution.getVariable("productFamilyId") RequestInfo requestInfo = new RequestInfo() requestInfo.setInstanceName(networkServiceInstance.getServiceInstanceName()) requestInfo.setSource("VID") - requestInfo.setProductFamilyId(serviceId) + requestInfo.setProductFamilyId(productFamilyId) requestInfo.setRequestorId("NBI") return requestInfo @@ -564,13 +637,13 @@ import javax.ws.rs.core.Response * @param constituteVnf * @return List<VfModules> */ - List<VfModules> prepareVfModules(DelegateExecution execution, GenericVnf constituteVnf) { + List<org.onap.so.serviceinstancebeans.VfModules> prepareVfModules(DelegateExecution execution, GenericVnf constituteVnf) { AAIResourcesClient client = getAAIClient() - List<VfModules> vfModuless = new ArrayList<>() + List<org.onap.so.serviceinstancebeans.VfModules> vfModuless = new ArrayList<>() for (VfModule vfModule : constituteVnf.getVfModules().getVfModule()) { - VfModules vfmodules = new VfModules() + org.onap.so.serviceinstancebeans.VfModules vfmodules = new org.onap.so.serviceinstancebeans.VfModules() ModelInfo vfModuleModelInfo = new ModelInfo() vfModuleModelInfo.setModelInvariantUuid(vfModule.getModelInvariantId()) @@ -680,7 +753,7 @@ import javax.ws.rs.core.Response Vnfs vnf = new Vnfs() // Line of Business - LineOfBusiness lob = new LineOfBusiness() + org.onap.so.serviceinstancebeans.LineOfBusiness lob = new org.onap.so.serviceinstancebeans.LineOfBusiness() lob.setLineOfBusinessName("VNF") vnf.setLineOfBusiness(lob) @@ -716,8 +789,8 @@ import javax.ws.rs.core.Response * Prepare Service * @return Service */ - Service prepareService(DelegateExecution execution, ServiceInstance networkServiceInstance, ModelInfo modelInfo) { - Service service = new Service() + org.onap.so.serviceinstancebeans.Service prepareService(DelegateExecution execution, ServiceInstance networkServiceInstance, ModelInfo modelInfo) { + org.onap.so.serviceinstancebeans.Service service = new org.onap.so.serviceinstancebeans.Service() // Model Info service.setModelInfo(prepareServiceModelInfo(networkServiceInstance, modelInfo)) @@ -770,21 +843,21 @@ import javax.ws.rs.core.Response * @param execution * @return OwningEntity */ - OwningEntity prepareOwningEntity(DelegateExecution execution) { + org.onap.so.serviceinstancebeans.OwningEntity prepareOwningEntity(DelegateExecution execution) { def currentNSSI = execution.getVariable("currentNSSI") AAIResourcesClient client = getAAIClient() AAIResourceUri networkServiceInstanceUri = (AAIResourceUri)currentNSSI['networkServiceInstanceUri'] - OwningEntity owningEntity = new OwningEntity() + org.onap.so.serviceinstancebeans.OwningEntity owningEntity = new org.onap.so.serviceinstancebeans.OwningEntity() AAIResultWrapper wrapper = client.get(networkServiceInstanceUri) Optional<Relationships> owningEntityRelationshipsOps = wrapper.getRelationships() if (owningEntityRelationshipsOps.isPresent()) { List<AAIResourceUri> owningEntityRelatedAAIUris = owningEntityRelationshipsOps.get().getRelatedUris(Types.OWNING_ENTITY) if (!(owningEntityRelatedAAIUris == null || owningEntityRelatedAAIUris.isEmpty())) { - Optional<org.onap.aai.domain.yang.OwningEntity> owningEntityOpt = client.get(org.onap.aai.domain.yang.OwningEntity.class, owningEntityRelatedAAIUris.get(0)) // Many-To-One relation + Optional<org.onap.aai.domain.yang.OwningEntity> owningEntityOpt = client.get(org.onap.aai.domain.yang.v19.OwningEntity.class, owningEntityRelatedAAIUris.get(0)) // Many-To-One relation if (owningEntityOpt.isPresent()) { owningEntity.setOwningEntityId(owningEntityOpt.get().getOwningEntityId()) owningEntity.setOwningEntityName(owningEntityOpt.get().getOwningEntityName()) @@ -802,12 +875,12 @@ import javax.ws.rs.core.Response * @param execution * @return Project */ - Project prepareProject(DelegateExecution execution) { + org.onap.so.serviceinstancebeans.Project prepareProject(DelegateExecution execution) { def currentNSSI = execution.getVariable("currentNSSI") AAIResourcesClient client = getAAIClient() - Project project = new Project() + org.onap.so.serviceinstancebeans.Project project = new org.onap.so.serviceinstancebeans.Project() AAIResourceUri cloudRegionRelatedAAIUri = (AAIResourceUri)currentNSSI['cloudRegionRelatedAAIUri'] @@ -817,7 +890,7 @@ import javax.ws.rs.core.Response if (cloudRegionOps.isPresent()) { List<AAIResourceUri> projectAAIUris = cloudRegionOps.get().getRelatedUris(Types.PROJECT) if (!(projectAAIUris == null || projectAAIUris.isEmpty())) { - Optional<org.onap.aai.domain.yang.Project> projectOpt = client.get(org.onap.aai.domain.yang.Project.class, projectAAIUris.get(0)) + Optional<org.onap.aai.domain.yang.Project> projectOpt = client.get(org.onap.aai.domain.yang.v19.Project.class, projectAAIUris.get(0)) if (projectOpt.isPresent()) { project.setProjectName(projectOpt.get().getProjectName()) } @@ -927,22 +1000,48 @@ import javax.ws.rs.core.Response def currentNSSI = execution.getVariable("currentNSSI") - ServiceInstance nssi = (ServiceInstance)currentNSSI['nssi'] - String nssiId = currentNSSI['nssiId'] AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nssiId)) - List<SliceProfile> associatedProfiles = nssi.getSliceProfiles().getSliceProfile() + AAIResourceUri sliceProfileInstanceUri = (AAIResourceUri)currentNSSI['sliceProfileInstanceUri'] - String currentSNSSAI = currentNSSI['S-NSSAI'] + Optional<ServiceInstance> sliceProfileInstanceOpt = client.get(ServiceInstance.class, sliceProfileInstanceUri) + if (sliceProfileInstanceOpt.isPresent()) { + ServiceInstance sliceProfileInstance = sliceProfileInstanceOpt.get() + + List<SliceProfile> associatedProfiles = sliceProfileInstance.getSliceProfiles()?.getSliceProfile() + + String currentSNSSAI = currentNSSI['S-NSSAI'] + + if(!(associatedProfiles == null || associatedProfiles.isEmpty())) { + // Removes slice profile which contains given S-NSSAI and updates Slice Profile Instance + associatedProfiles.removeIf({ associatedProfile -> (associatedProfile.getSNssai().equals(currentSNSSAI)) }) + + try { + client.update(sliceProfileInstanceUri, sliceProfileInstance) + + currentNSSI['sliceProfileInstance'] = sliceProfileInstance + } catch (Exception e) { + exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occured while Slice Profile association with NSSI update call: " + e.getMessage()) + } + } + else { + exceptionUtil.buildAndThrowWorkflowException(execution, 500, "No slice profiles found") + } - associatedProfiles.removeIf({ associatedProfile -> (associatedProfile.getSNssai().equals(currentSNSSAI)) }) + } + else { + exceptionUtil.buildAndThrowWorkflowException(execution, 500, "No slice profile instance found") + } + // Removes SLice Profile Instance association with NSSI try { - getAAIClient().update(nssiUri, nssi) - }catch(Exception e){ - exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occured while Slice Profile association with NSSI update call: " + e.getMessage()) + client.disconnect(nssiUri, sliceProfileInstanceUri) } + catch (Exception e) { + exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occured while Slice Profile Instance association with NSSI dosconnect call: " + e.getMessage()) + } + LOGGER.trace("${getPrefix()} Exit removeSPAssociationWithNSSI") } @@ -959,17 +1058,10 @@ import javax.ws.rs.core.Response def currentNSSI = execution.getVariable("currentNSSI") - SliceProfile sliceProfileContainsSNSSAI = (SliceProfile)currentNSSI['sliceProfileS-NSSAI'] - - String globalSubscriberId = currentNSSI['globalSubscriberId'] - String serviceType = currentNSSI['serviceType'] - String nssiId = currentNSSI['nssiId'] - - // global-customer-id, service-type, service-instance-id, profile-id - AAIResourceUri sliceProfileUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(serviceType).serviceInstance(nssiId).sliceProfile(sliceProfileContainsSNSSAI.getProfileId())) + AAIResourceUri sliceProfileInstanceURI = (AAIResourceUri)currentNSSI['sliceProfileInstanceUri'] try { - getAAIClient().delete(sliceProfileUri) + client.delete(sliceProfileInstanceURI) }catch(Exception e){ exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occured while Slice Profile Instance delete call: " + e.getMessage()) } @@ -979,27 +1071,180 @@ import javax.ws.rs.core.Response /** - * Updates operation status + * Prepares update resource operation status * @param execution */ - void updateServiceOperationStatus(DelegateExecution execution) { + void prepareUpdateResourceOperationStatus(DelegateExecution execution) { LOGGER.trace("${getPrefix()} Start updateServiceOperationStatus") def currentNSSI = execution.getVariable("currentNSSI") - OperationStatus operationStatus = new OperationStatus() - operationStatus.setServiceId(currentNSSI['e2eServiceInstanceId'] as String) - operationStatus.setOperationId(currentNSSI['operationId'] as String) - operationStatus.setOperation(currentNSSI['operationType'] as String) - operationStatus.setResult(RequestsDbConstant.Status.FINISHED) + //Prepare Update Status for PUT failure and success + String isTimeOutVar = execution.getVariable("isTimeOut") + if(!isBlank(isTimeOutVar) && isTimeOutVar.equals("YES")) { + LOGGER.error("TIMEOUT - SO PUT Failure") + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "SO PUT Failure") + } else { + execution.setVariable("progress", "100") + execution.setVariable("status", "finished") + execution.setVariable("operationContent", "${getAction()} Core NSSI successful.") + } - requestDBUtil.prepareUpdateOperationStatus(execution, operationStatus) + setResourceOperationStatus(execution, "finished", "100", "Core NSSI ${getAction()} successful") LOGGER.trace("${getPrefix()} Exit updateServiceOperationStatus") } /** + * Prepares ResourceOperation status + * @param execution + * @param operationType + */ + void setResourceOperationStatus(DelegateExecution execution, String status, String progress, String statusDesc) { + LOGGER.trace("${getPrefix()} Start setResourceOperationStatus") + + def currentNSSI = execution.getVariable("currentNSSI") + + String serviceId = currentNSSI['nssiId'] + String jobId = execution.getVariable("jobId") + String nsiId = currentNSSI['nsiId'] + String operationType = execution.getVariable("operationType") + + ResourceOperationStatus resourceOperationStatus = new ResourceOperationStatus() + resourceOperationStatus.setServiceId(serviceId) + resourceOperationStatus.setOperationId(jobId) + resourceOperationStatus.setResourceTemplateUUID(nsiId) + resourceOperationStatus.setOperType(operationType) + resourceOperationStatus.setStatus(status) + resourceOperationStatus.setProgress(progress) + resourceOperationStatus.setStatusDescription(statusDesc) + requestDBUtil.prepareUpdateResourceOperationStatus(execution, resourceOperationStatus) + + LOGGER.trace("${getPrefix()} Exit setResourceOperationStatus") + } + + + /** + * Prepares failed operation status update + * @param execution + */ + void prepareFailedOperationStatusUpdate(DelegateExecution execution) { + LOGGER.trace("${getPrefix()} Start prepareFailedOperationStatusUpdate") + + setResourceOperationStatus(execution, "failed", "0", "Core NSSI ${getAction()} Failed") + + LOGGER.trace("${getPrefix()} Exit prepareFailedOperationStatusUpdate") + } + + + /** + * Gets progress status of ServiceInstance PUT operation + * @param execution + */ + public void getPUTServiceInstanceProgress(DelegateExecution execution) { + LOGGER.trace("${getPrefix()} Start getPUTServiceInstanceProgress") + + def currentNSSI = execution.getVariable("currentNSSI") + + String url = currentNSSI['putServiceInstanceURL'] + + getProgress(execution, url, "putStatus") + + LOGGER.trace("${getPrefix()} Exit getPUTServiceInstanceProgress") + } + + + void getProgress(DelegateExecution execution, String url, String statusVariableName) { + String msg="" + try { + + ExternalAPIUtil externalAPIUtil = getExternalAPIUtilFactory().create() + Response response = externalAPIUtil.executeExternalAPIGetCall(execution, url) + int responseCode = response.getStatus() + execution.setVariable("GetServiceOrderResponseCode", responseCode) + LOGGER.debug("Get ServiceOrder response code is: " + responseCode) + + String extApiResponse = response.readEntity(String.class) + JSONObject responseObj = new JSONObject(extApiResponse) + execution.setVariable("GetServiceOrderResponse", extApiResponse) + LOGGER.debug("Create response body is: " + extApiResponse) + //Process Response //200 OK 201 CREATED 202 ACCEPTED + if(responseCode == 200 || responseCode == 201 || responseCode == 202 ) + { + LOGGER.debug("Get Create ServiceOrder Received a Good Response") + String orderState = responseObj.get("state") + if("REJECTED".equalsIgnoreCase(orderState)) { + prepareFailedOperationStatusUpdate(execution) + return + } + + JSONArray items = responseObj.getJSONArray("orderItem") + JSONObject item = items.get(0) + JSONObject service = item.get("service") + String networkServiceId = service.get("id") + if (networkServiceId == null || networkServiceId.equals("null")) { + prepareFailedOperationStatusUpdate(execution) + return + } + + execution.setVariable("networkServiceId", networkServiceId) + String serviceOrderState = item.get("state") + execution.setVariable("ServiceOrderState", serviceOrderState) + // Get serviceOrder State and process progress + if("ACKNOWLEDGED".equalsIgnoreCase(serviceOrderState)) { + execution.setVariable(statusVariableName, "processing") + } + else if("INPROGRESS".equalsIgnoreCase(serviceOrderState)) { + execution.setVariable(statusVariableName, "processing") + } + else if("COMPLETED".equalsIgnoreCase(serviceOrderState)) { + execution.setVariable(statusVariableName, "completed") + } + else if("FAILED".equalsIgnoreCase(serviceOrderState)) { + msg = "ServiceOrder failed" + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + else { + msg = "ServiceOrder failed" + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + } + else{ + msg = "Get ServiceOrder Received a Bad Response Code. Response Code is: " + responseCode + prepareFailedOperationStatusUpdate(execution) + } + + }catch(Exception e){ + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, e.getMessage()) + } + + } + + + + /** + * Delays 5 sec + * @param execution + */ + void timeDelay(DelegateExecution execution) { + LOGGER.trace("${getPrefix()} Start timeDelay") + + try { + LOGGER.debug("${getPrefix()} timeDelay going to sleep for 5 sec") + + Thread.sleep(5000) + + LOGGER.debug("${getPrefix()} ::: timeDelay wakeup after 5 sec") + } catch(InterruptedException e) { + LOGGER.error("${getPrefix()} ::: timeDelay exception" + e) + } + + LOGGER.trace("${getPrefix()} Exit timeDelay") + } + + + /** * Returns AAI client * @return AAI client */ @@ -1008,7 +1253,16 @@ import javax.ws.rs.core.Response } + ExternalAPIUtilFactory getExternalAPIUtilFactory() { + return new ExternalAPIUtilFactory() + } + + String getPrefix() { return PREFIX } + + String getAction() { + return "" + } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceOption.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceOption.groovy index 8993127dbc..1d5232f3c5 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceOption.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceOption.groovy @@ -95,7 +95,7 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{ List<TemplateInfo> nsstInfos = new ArrayList<>() ServiceDecomposition nstServiceDecomposition = execution.getVariable("nstServiceDecomposition") as ServiceDecomposition - //todo: + List<AllottedResource> allottedResources = nstServiceDecomposition.getAllottedResources() for (AllottedResource allottedResource : allottedResources) { TemplateInfo nsstInfo = new TemplateInfo() @@ -150,9 +150,6 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{ execution.setVariable("nsstServiceDecompositions", nsstServiceDecompositions) - - - int num = execution.getVariable("maxNsstIndex") as Integer int index = execution.getVariable("currentNsstIndex") as Integer @@ -180,8 +177,6 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{ List<SubnetCapability> subnetCapabilities = new ArrayList<>() - - for (ServiceDecomposition serviceDecomposition : nsstServiceDecompositions) { SubnetCapability subnetCapability = new SubnetCapability() handleByType(execution, serviceDecomposition, sliceParams, subnetCapability) @@ -206,7 +201,6 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{ sliceParams.tnBHSliceTaskInfo.NSSTInfo.UUID = modelInfo.getModelUuid() sliceParams.tnBHSliceTaskInfo.NSSTInfo.invariantUUID = modelInfo.getModelInvariantUuid() sliceParams.tnBHSliceTaskInfo.NSSTInfo.name = modelInfo.getModelName() - break case SubnetType.TN_MH: sliceParams.tnMHSliceTaskInfo.vendor = vendor @@ -215,7 +209,6 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{ sliceParams.tnMHSliceTaskInfo.NSSTInfo.UUID = modelInfo.getModelUuid() sliceParams.tnMHSliceTaskInfo.NSSTInfo.invariantUUID = modelInfo.getModelInvariantUuid() sliceParams.tnMHSliceTaskInfo.NSSTInfo.name = modelInfo.getModelName() - break case SubnetType.AN_NF: sliceParams.anSliceTaskInfo.vendor = vendor @@ -236,9 +229,6 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{ default: subnetType = null break - - //todo - } if (null == subnetType) { def msg = "Get subnetType failed, modelUUId=" + modelInfo.getModelUuid() @@ -297,17 +287,16 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{ private static String buildQuerySubnetCapRequest(String vendor, SubnetType subnetType) { NssmfAdapterNBIRequest request = new NssmfAdapterNBIRequest() - List<String> subnetTypes = new ArrayList<>() - subnetTypes.add(subnetType.subnetType) +// List<String> subnetTypes = new ArrayList<>() +// subnetTypes.add(subnetType.subnetType) Map<String, Object> paramMap = new HashMap() - paramMap.put("subnetTypes", subnetTypes) + paramMap.put("subnetType", subnetType.subnetType) request.setSubnetCapabilityQuery(objectMapper.writeValueAsString(paramMap)) EsrInfo esrInfo = new EsrInfo() esrInfo.setVendor(vendor) esrInfo.setNetworkType(subnetType.networkType) - request.setEsrInfo(esrInfo) String strRequest = objectMapper.writeValueAsString(request) @@ -320,7 +309,8 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{ * prepare select nsi request * @param execution */ - public void preNSIRequest(DelegateExecution execution, boolean preferReuse) { + public void preNSIRequest(DelegateExecution execution) { + boolean preferReuse = execution.getVariable("needQuerySliceProfile") ? false : true String urlString = UrnPropertiesReader.getVariable("mso.oof.endpoint", execution) logger.debug( "get NSI option OOF Url: " + urlString) @@ -378,8 +368,9 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{ if (isSharable && solution.get("existingNSI")) { //sharedNSISolution processSharedNSI(solution, sliceTaskParams) + execution.setVariable("needQuerySliceProfile", true) } - else if(solution.containsKey("newNSISolution")) { + else { processNewNSI(solution, sliceTaskParams) } } @@ -395,6 +386,7 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{ String nsiName = sharedNSISolution.get("NSIName") sliceParams.setSuggestNsiId(nsiId) sliceParams.setSuggestNsiName(nsiName) + } private void processNewNSI(Map<String, Object> solution, SliceTaskParamsAdapter sliceParams) { diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateTnNssiInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateTnNssiInstance.groovy index 0f1bf0d8b4..7beafefc28 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateTnNssiInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateTnNssiInstance.groovy @@ -23,12 +23,10 @@ package org.onap.so.bpmn.infrastructure.scripts import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.aai.domain.yang.SliceProfile -import org.onap.aaiclient.client.aai.AAIObjectType import org.onap.aaiclient.client.aai.AAIResourcesClient import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder -import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.core.json.JsonUtils @@ -38,6 +36,7 @@ import org.slf4j.LoggerFactory class DoCreateTnNssiInstance extends AbstractServiceTaskProcessor { private static final Logger logger = LoggerFactory.getLogger(DoCreateTnNssiInstance.class); + final String AAI_VERSION = "v21" JsonUtils jsonUtil = new JsonUtils() TnNssmfUtils tnNssmfUtils = new TnNssmfUtils() ExceptionUtil exceptionUtil = new ExceptionUtil() @@ -67,23 +66,26 @@ class DoCreateTnNssiInstance extends AbstractServiceTaskProcessor { void createSliceProfile(DelegateExecution execution) { - String sliceserviceInstanceId = execution.getVariable("sliceServiceInstanceId") + String ssInstanceId = execution.getVariable("sliceServiceInstanceId") String sliceProfileStr = execution.getVariable("sliceProfile") String sliceProfileId = UUID.randomUUID().toString() SliceProfile sliceProfile = new SliceProfile(); sliceProfile.setProfileId(sliceProfileId) sliceProfile.setLatency(Integer.parseInt(jsonUtil.getJsonValue(sliceProfileStr, "latency"))) sliceProfile.setResourceSharingLevel(jsonUtil.getJsonValue(sliceProfileStr, "resourceSharingLevel")) - sliceProfile.setSNssai(tnNssmfUtils.getFirstSnssaiFromSliceProfile(sliceProfileStr)) //TODO: should be list + //sliceProfile.setSNssai(tnNssmfUtils.getFirstSnssaiFromSliceProfile(sliceProfileStr)) - sliceProfile.setE2ELatency(Integer.parseInt(jsonUtil.getJsonValue(sliceProfileStr, "latency"))) sliceProfile.setMaxBandwidth(Integer.parseInt(jsonUtil.getJsonValue(sliceProfileStr, "maxBandwidth"))) - //TODO: new API - sliceProfile.setReliability(new Object()) + //sliceProfile.setReliability(new Object()) try { AAIResourcesClient client = getAAIClient() - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(sliceserviceInstanceId).sliceProfile(sliceProfileId)) + AAIResourceUri uri = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business() + .customer(execution.getVariable("globalSubscriberId")) + .serviceSubscription(execution.getVariable("subscriptionServiceType")) + .serviceInstance(ssInstanceId) + .sliceProfile(sliceProfileId)) client.create(uri, sliceProfile) } catch (BpmnError e) { @@ -112,20 +114,25 @@ class DoCreateTnNssiInstance extends AbstractServiceTaskProcessor { ss.setOrchestrationStatus(serviceStatus) String modelInvariantUuid = execution.getVariable("modelInvariantUuid") String modelUuid = execution.getVariable("modelUuid") - ss.setModelInvariantId(modelInvariantUuid) - ss.setModelVersionId(modelUuid) + //TODO: need valid model ID from the caller, as AAI does not accept invalid IDs + //ss.setModelInvariantId(modelInvariantUuid) + //ss.setModelVersionId(modelUuid) String serviceInstanceLocationid = tnNssmfUtils.getFirstPlmnIdFromSliceProfile(sliceProfileStr) ss.setServiceInstanceLocationId(serviceInstanceLocationid) String snssai = tnNssmfUtils.getFirstSnssaiFromSliceProfile(sliceProfileStr) ss.setEnvironmentContext(snssai) ss.setServiceRole(serviceRole) AAIResourcesClient client = getAAIClient() - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(ssInstanceId)) + AAIResourceUri uri = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business() + .customer(execution.getVariable("globalSubscriberId")) + .serviceSubscription(execution.getVariable("subscriptionServiceType")) + .serviceInstance(ssInstanceId)) client.create(uri, ss) } catch (BpmnError e) { throw e } catch (Exception ex) { - String msg = "Exception in DoCreateTnNssiInstance.createServiceInstance. " + ex.getMessage() + String msg = "Exception in DoCreateTnNssiInstance.createServiceInstance: " + ex.getMessage() logger.info(msg) exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) } @@ -133,17 +140,19 @@ class DoCreateTnNssiInstance extends AbstractServiceTaskProcessor { void createAllottedResource(DelegateExecution execution) { - String serviceInstanceId = execution.getVariable('sliceServiceInstanceId') - - AAIResourcesClient resourceClient = getAAIClient() - AAIResourceUri ssServiceuri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(serviceInstanceId)) + String ssInstanceId = execution.getVariable('sliceServiceInstanceId') try { List<String> networkStrList = jsonUtil.StringArrayToList(execution.getVariable("transportSliceNetworks")) for (String networkStr : networkStrList) { String allottedResourceId = UUID.randomUUID().toString() - AAIResourceUri allottedResourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(execution.getVariable("sliceserviceInstanceId")).allottedResource(allottedResourceId)) + AAIResourceUri allottedResourceUri = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business() + .customer(execution.getVariable("globalSubscriberId")) + .serviceSubscription(execution.getVariable("subscriptionServiceType")) + .serviceInstance(execution.getVariable("sliceServiceInstanceId")) + .allottedResource(allottedResourceId)) execution.setVariable("allottedResourceUri", allottedResourceUri) String modelInvariantId = execution.getVariable("modelInvariantUuid") String modelVersionId = execution.getVariable("modelUuid") @@ -152,27 +161,37 @@ class DoCreateTnNssiInstance extends AbstractServiceTaskProcessor { resource.setId(allottedResourceId) resource.setType("TsciNetwork") resource.setAllottedResourceName("network_" + execution.getVariable("sliceServiceInstanceName")) - resource.setModelInvariantId(modelInvariantId) - resource.setModelVersionId(modelVersionId) getAAIClient().create(allottedResourceUri, resource) - //AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceFromExistingURI(Types.SERVICE_INSTANCE, UriBuilder.fromPath(ssServiceuri).build()) - //getAAIClient().connect(allottedResourceUri,ssServiceuri) - //execution.setVariable("aaiARPath", allottedResourceUri.build().toString()); String linkArrayStr = jsonUtil.getJsonValue(networkStr, "connectionLinks") - createLogicalLinksForAllocatedResource(execution, linkArrayStr, serviceInstanceId, allottedResourceId) + createLogicalLinksForAllocatedResource(execution, linkArrayStr, ssInstanceId, allottedResourceId) } - + } catch (BpmnError e) { + throw e } catch (Exception ex) { - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Exception in createAaiAR " + ex.getMessage()) + String msg = "Exception in DoCreateTnNssiInstance.createAllottedResource: " + ex.getMessage() + logger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) } } void createLogicalLinksForAllocatedResource(DelegateExecution execution, - String linkArrayStr, String serviceInstanceId, + String linkArrayStr, String ssInstanceId, String allottedResourceId) { - try { + AAIResourceUri allottedResourceUri = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business() + .customer(execution.getVariable("globalSubscriberId")) + .serviceSubscription(execution.getVariable("subscriptionServiceType")) + .serviceInstance(ssInstanceId) + .allottedResource(allottedResourceId)) + + if (!getAAIClient().exists(allottedResourceUri)) { + logger.info("ERROR: createLogicalLinksForAllocatedResource: allottedResource not exist: uri={}", + allottedResourceUri) + return + } + List<String> linkStrList = jsonUtil.StringArrayToList(linkArrayStr) for (String linkStr : linkStrList) { @@ -186,15 +205,22 @@ class DoCreateTnNssiInstance extends AbstractServiceTaskProcessor { resource.setLinkId(logicalLinkId) resource.setLinkName(epA) resource.setLinkName2(epB) - resource.setModelInvariantId(modelInvariantId) - resource.setModelVersionId(modelVersionId) + resource.setLinkType("TsciConnectionLink") + resource.setInMaint(false) - AAIResourceUri logicalLinkUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().logicalLink(logicalLinkId)) + //epA is link-name + AAIResourceUri logicalLinkUri = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().logicalLink(epA)) getAAIClient().create(logicalLinkUri, resource) + + tnNssmfUtils.attachLogicalLinkToAllottedResource(execution, AAI_VERSION, allottedResourceUri, epA); } + } catch (BpmnError e) { + throw e } catch (Exception ex) { - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, - "Exception in createLogicalLinksForAllocatedResource" + ex.getMessage()) + String msg = "Exception in DoCreateTnNssiInstance.createLogicalLinksForAllocatedResource: " + ex.getMessage() + logger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateCoreNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateCoreNSSI.groovy index c94e2dd67d..fe881eb888 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateCoreNSSI.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateCoreNSSI.groovy @@ -20,19 +20,10 @@ package org.onap.so.bpmn.infrastructure.scripts -import com.fasterxml.jackson.databind.ObjectMapper + import org.camunda.bpm.engine.delegate.DelegateExecution -import org.onap.aai.domain.yang.CloudRegion -import org.onap.aai.domain.yang.Customer -import org.onap.aai.domain.yang.ModelVer -import org.onap.aai.domain.yang.OwningEntities -import org.onap.aai.domain.yang.ServiceSubscription -import org.onap.aai.domain.yang.SliceProfile -import org.onap.aai.domain.yang.GenericVnf -import org.onap.aai.domain.yang.ServiceInstance -import org.onap.aai.domain.yang.Tenant -import org.onap.aai.domain.yang.VfModule -import org.onap.aaiclient.client.aai.AAIClient +import org.onap.aai.domain.yang.v19.AllottedResource +import org.onap.aai.domain.yang.v19.ServiceInstance import org.onap.aaiclient.client.aai.AAIResourcesClient import org.onap.aaiclient.client.aai.entities.AAIResultWrapper import org.onap.aaiclient.client.aai.entities.Relationships @@ -41,7 +32,6 @@ import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types import org.onap.logging.filter.base.ONAPComponents -import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.common.scripts.MsoUtils import org.onap.so.bpmn.common.scripts.RequestDBUtil @@ -49,22 +39,6 @@ import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.bpmn.core.json.JsonUtils import org.onap.so.client.HttpClient import org.onap.so.client.HttpClientFactory -import org.onap.so.db.request.beans.OperationStatus -import org.onap.so.requestsdb.RequestsDbConstant -import org.onap.so.serviceinstancebeans.CloudConfiguration -import org.onap.so.serviceinstancebeans.LineOfBusiness -import org.onap.so.serviceinstancebeans.ModelInfo -import org.onap.so.serviceinstancebeans.ModelType -import org.onap.so.serviceinstancebeans.OwningEntity -import org.onap.so.serviceinstancebeans.Project -import org.onap.so.serviceinstancebeans.RequestDetails -import org.onap.so.serviceinstancebeans.RequestInfo -import org.onap.so.serviceinstancebeans.RequestParameters -import org.onap.so.serviceinstancebeans.Resources -import org.onap.so.serviceinstancebeans.Service -import org.onap.so.serviceinstancebeans.SubscriberInfo -import org.onap.so.serviceinstancebeans.VfModules -import org.onap.so.serviceinstancebeans.Vnfs import org.slf4j.Logger import org.slf4j.LoggerFactory @@ -72,6 +46,7 @@ import javax.ws.rs.core.Response class DoDeallocateCoreNSSI extends DoCommonCoreNSSI { private final String PREFIX ="DoDeallocateCoreNSSI" + private final String ACTION = "Deallocate" private ExceptionUtil exceptionUtil = new ExceptionUtil() private RequestDBUtil requestDBUtil = new RequestDBUtil() @@ -80,7 +55,7 @@ class DoDeallocateCoreNSSI extends DoCommonCoreNSSI { private static final Logger LOGGER = LoggerFactory.getLogger( DoDeallocateCoreNSSI.class) -/** + /** * Queries OOF for NSSI termination * @param execution */ @@ -191,36 +166,6 @@ class DoDeallocateCoreNSSI extends DoCommonCoreNSSI { } - String encryptBasicAuth(String basicAuth, String msoKey) { - return utils.encrypt(basicAuth, msoKey) - } - - - String getAuthHeader(DelegateExecution execution, String basicAuthValue, String msokey) { - String response = "" - String errorCode = "" - String errorMessage = "" - - LOGGER.debug("Obtained BasicAuth username and password for OOF: " + basicAuthValue) - try { - response = utils.getBasicAuth(basicAuthValue, msokey) - } catch (Exception ex) { - LOGGER.error("Unable to encode username and password string: ", ex) - - errorCode = "401" - errorMessage = "Internal Error - Unable to encode username and password string" - - response = "{\n" + - " \"errorCode\": \"${errorCode}\",\n" + - " \"errorMessage\": \"${errorMessage}\"\n" + - "}" - } - - return response - } - - - /** * Builds OOF request * @param execution @@ -263,7 +208,9 @@ class DoDeallocateCoreNSSI extends DoCommonCoreNSSI { ServiceInstance networkServiceInstance = (ServiceInstance)currentNSSI['networkServiceInstance'] - String url = String.format("${nbiEndpointUrl}/api/v4/serviceOrder/%s", networkServiceInstance.getServiceInstanceId()) // Service Order ID = Network Service Instance ID + String url = String.format("${nbiEndpointUrl}/api/v4/serviceOrder/%s", networkServiceInstance.getServiceInstanceId()) + + currentNSSI['deleteServiceOrderURL'] = url String msoKey = UrnPropertiesReader.getVariable("mso.msoKey", execution) String basicAuth = UrnPropertiesReader.getVariable("mso.infra.endpoint.auth", execution) @@ -356,12 +303,38 @@ class DoDeallocateCoreNSSI extends DoCommonCoreNSSI { String nssiId = currentNSSI['nssiId'] String nsiId = currentNSSI['nsiId'] + String globalSubscriberId = execution.getVariable("globalSubscriberId") + String subscriptionServiceType = execution.getVariable("subscriptionServiceType") + // NSSI AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nssiId)) + ServiceInstance nssi = currentNSSI['nssi'] + + String allottedResourceId = null + + // Removes Allotted resource + List<AllottedResource> allottedResources = nssi.getAllottedResources()?.getAllottedResource() + if(allottedResources != null && allottedResources.size() == 1) { // Shouldn contain one allotted resource + allottedResourceId = allottedResources.get(0).getId() + allottedResources.remove(0) + } + else { + exceptionUtil.buildAndThrowWorkflowException(execution, 500, "No allotted resource found for NSSI id = " + nssiId) + } + + try { + client.update(nssiUri, nssi) + }catch(Exception e){ + exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occured while NSSI association with NSI disconnect call: " + e.getMessage()) + } + + + // Remove association between NSI and Allotted Resource AAIResourceUri nsiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nsiId)) + AAIResourceUri allottedResourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(nssiId).allottedResource(allottedResourceId)) try { - client.disconnect(nssiUri, nsiUri) + client.disconnect(nsiUri, allottedResourceUri) }catch(Exception e){ exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occured while NSSI association with NSI disconnect call: " + e.getMessage()) } @@ -387,17 +360,36 @@ class DoDeallocateCoreNSSI extends DoCommonCoreNSSI { try { getAAIClient().delete(nssiUri) }catch(Exception e){ - exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occured while NSSI Service Instance delete call: " + e.getMessage()) + exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occurred while NSSI Service Instance delete call: " + e.getMessage()) } LOGGER.trace("${PREFIX} Exit deleteNSSIServiceInstance") } + /** + * Gets Delete Service Order progress + * @param execution + */ + void getDeleteServiceOrderProgress(DelegateExecution execution) { + LOGGER.trace("${getPrefix()} Start getDeleteServiceOrderProgress") + + def currentNSSI = execution.getVariable("currentNSSI") + + String url = currentNSSI['deleteServiceOrderURL'] + + getProgress(execution, url, "deleteStatus") + + } + @Override String getPrefix() { return PREFIX } + @Override + String getAction() { + return ACTION + } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateNSSI.groovy index 9d6c4a1b2a..75ef7d347c 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateNSSI.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateNSSI.groovy @@ -19,8 +19,8 @@ */ package org.onap.so.bpmn.infrastructure.scripts +import com.fasterxml.jackson.databind.ObjectMapper import org.camunda.bpm.engine.delegate.DelegateExecution -import org.json.JSONObject import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder @@ -47,6 +47,7 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor private ExceptionUtil exceptionUtil = new ExceptionUtil() private JsonUtils jsonUtil = new JsonUtils() + ObjectMapper objectMapper = new ObjectMapper() private RequestDBUtil requestDBUtil = new RequestDBUtil() private NssmfAdapterUtils nssmfAdapterUtils = new NssmfAdapterUtils(httpClientFactory, jsonUtil) @@ -133,10 +134,9 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor String nssiId = currentNSSI['nssiServiceInstanceId'] String nsiId = currentNSSI['nsiServiceInstanceId'] String scriptName = execution.getVariable("scriptName") - boolean modifyAction = execution.getVariable("terminateNSI") String serviceInvariantUuid = currentNSSI['modelInvariantId'] - String serviceUuid = currentNSSI['modelVersionId'] + String serviceUuid = currentNSSI['modelId'] String globalSubscriberId = currentNSSI['globalSubscriberId'] String subscriptionServiceType = execution.getVariable("serviceType") @@ -146,37 +146,37 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor deAllocateNssi.setTerminateNssiOption(0) deAllocateNssi.setSnssaiList(Arrays.asList(snssai)) deAllocateNssi.setScriptName(scriptName) - deAllocateNssi.setSliceProfileId(profileId) - deAllocateNssi.setModifyAction(modifyAction) ServiceInfo serviceInfo = new ServiceInfo() serviceInfo.setServiceInvariantUuid(serviceInvariantUuid) serviceInfo.setServiceUuid(serviceUuid) + serviceInfo.setNsiId(nsiId) serviceInfo.setGlobalSubscriberId(globalSubscriberId) serviceInfo.setSubscriptionServiceType(subscriptionServiceType) + String serviceInfoString = objectMapper.writeValueAsString(serviceInfo) EsrInfo esrInfo = getEsrInfo(currentNSSI) + String esrInfoString = objectMapper.writeValueAsString(esrInfo) execution.setVariable("deAllocateNssi",deAllocateNssi) - execution.setVariable("esrInfo",esrInfo) - execution.setVariable("serviceInfo",serviceInfo) + execution.setVariable("esrInfo", esrInfoString) + execution.setVariable("serviceInfo", serviceInfoString) String nssmfRequest = """ { - "deAllocateNssi": "${execution.getVariable("deAllocateNssi") as JSONObject}", - "esrInfo": ${execution.getVariable("esrInfo") as JSONObject}, - "serviceInfo": ${execution.getVariable("serviceInfo") as JSONObject} + "deAllocateNssi": ${objectMapper.writeValueAsString(deAllocateNssi)}, + "esrInfo": ${esrInfoString}, + "serviceInfo": ${serviceInfoString} } """ - String urlStr = String.format("/api/rest/provMns/v1/NSS/nssi/%s",nssiId) + String urlStr = String.format("/api/rest/provMns/v1/NSS/SliceProfiles/%s", profileId) NssiResponse nssmfResponse = nssmfAdapterUtils.sendPostRequestNSSMF(execution, urlStr, nssmfRequest, NssiResponse.class) if (nssmfResponse != null) { currentNSSI['jobId']= nssmfResponse.getJobId() ?: "" currentNSSI['jobProgress'] = 0 execution.setVariable("currentNSSI", currentNSSI) - } - else { + } else { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Received a Bad Response from NSSMF.") } LOGGER.debug("*****${PREFIX} Exit sendRequestToNSSMF *****") @@ -190,32 +190,9 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor { def currentNSSI = execution.getVariable("currentNSSI") String jobId = currentNSSI['jobId'] - String nssiId = currentNSSI['nssiServiceInstanceId'] - String nsiId = currentNSSI['nsiServiceInstanceId'] - String serviceInvariantUuid = currentNSSI['modelInvariantId'] - String serviceUuid = currentNSSI['modelVersionId'] - String globalSubscriberId = currentNSSI['globalSubscriberId'] - String subscriptionServiceType = execution.getVariable("serviceType") - String sST = currentNSSI['sST'] - String PLMNIdList = currentNSSI['PLMNIdList'] - String nssiName = currentNSSI['nssiName'] - + execution.setVariable("responseId", "3") - execution.setVariable("esrInfo", getEsrInfo(currentNSSI)) execution.setVariable("jobId", jobId) - - Map<String, ?> serviceInfoMap = new HashMap<>() - serviceInfoMap.put("nssiId", nssiId) - serviceInfoMap.put("nsiId", nsiId) - serviceInfoMap.put("nssiName", nssiName) - serviceInfoMap.put("sST", sST) - serviceInfoMap.put("PLMNIdList", PLMNIdList) - serviceInfoMap.put("globalSubscriberId", globalSubscriberId) - serviceInfoMap.put("subscriptionServiceType", subscriptionServiceType) - serviceInfoMap.put("serviceInvariantUuid", serviceInvariantUuid) - serviceInfoMap.put("serviceUuid", serviceUuid) - - execution.setVariable("serviceInfo", serviceInfoMap) } @@ -238,8 +215,9 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor LOGGER.error("job progress is null or empty!") exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Received a Bad Job progress from NSSMF.") } + def currentNSSI = execution.getVariable("currentNSSI") int oldProgress = currentNSSI['jobProgress'] - int currentProgress = progress + int currentProgress = Integer.parseInt(progress) execution.setVariable("isNSSIDeAllocated", (currentProgress == 100)) execution.setVariable("isNeedUpdateDB", (oldProgress != currentProgress)) @@ -247,6 +225,8 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor currentNSSI['status'] = status currentNSSI['statusDescription'] = statusDescription + String nssiId = currentNSSI['nssiServiceInstanceId'] + String nsiId = currentNSSI['nsiServiceInstanceId'] LOGGER.debug("job status result: nsiId = ${nsiId}, nssiId=${nssiId}, oldProgress=${oldProgress}, progress = ${currentProgress}" ) } else { @@ -256,7 +236,7 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor } catch (any) { - String msg = "Received a Bad Response from NSSMF." cause-"+any.getCause()" + String msg = "Received a Bad Response from NSSMF. cause-"+any.getCause() LOGGER.error(any.printStackTrace()) exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) } @@ -309,7 +289,7 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor String nssiServiceInstanceId = currentNSSI['nssiServiceInstanceId'] String profileId = currentNSSI['profileId'] String globalSubscriberId = currentNSSI["globalSubscriberId"] - String serviceType = currentNSSI["serviceType"] + String serviceType = execution.getVariable("serviceType") try { diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateTnNssi.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateTnNssi.groovy index a410b93d16..baf0333a19 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateTnNssi.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateTnNssi.groovy @@ -162,7 +162,7 @@ class DoDeallocateTnNssi extends AbstractServiceTaskProcessor { roStatus.setProgress(progress) roStatus.setStatus(status) roStatus.setStatusDescription(statusDescription) - requestDBUtil.prepareUpdateResourceOperationStatus(execution, status) + requestDBUtil.prepareUpdateResourceOperationStatus(execution, roStatus) } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyCoreNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyCoreNSSI.groovy index ebeab3eb7d..ff16184f02 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyCoreNSSI.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyCoreNSSI.groovy @@ -21,57 +21,32 @@ package org.onap.so.bpmn.infrastructure.scripts import com.fasterxml.jackson.databind.ObjectMapper -import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution -import org.onap.aai.domain.yang.CloudRegion -import org.onap.aai.domain.yang.Customer -import org.onap.aai.domain.yang.GenericVnf -import org.onap.aai.domain.yang.ModelVer -import org.onap.aai.domain.yang.ServiceInstance -import org.onap.aai.domain.yang.ServiceSubscription -import org.onap.aai.domain.yang.SliceProfile -import org.onap.aai.domain.yang.Tenant -import org.onap.aai.domain.yang.VfModule -import org.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aai.domain.yang.v19.AllottedResource +import org.onap.aai.domain.yang.v19.AllottedResources +import org.onap.aai.domain.yang.v19.ServiceInstance +import org.onap.aai.domain.yang.v19.SliceProfile +import org.onap.aai.domain.yang.v19.SliceProfiles import org.onap.aaiclient.client.aai.AAIResourcesClient import org.onap.aaiclient.client.aai.entities.AAIEdgeLabel -import org.onap.aaiclient.client.aai.entities.AAIResultWrapper -import org.onap.aaiclient.client.aai.entities.Relationships import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types -import org.onap.logging.filter.base.ONAPComponents -import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.common.scripts.MsoUtils import org.onap.so.bpmn.common.scripts.RequestDBUtil -import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.bpmn.core.json.JsonUtils -import org.onap.so.client.HttpClient -import org.onap.so.db.request.beans.OperationStatus -import org.onap.so.requestsdb.RequestsDbConstant -import org.onap.so.serviceinstancebeans.CloudConfiguration -import org.onap.so.serviceinstancebeans.ModelInfo -import org.onap.so.serviceinstancebeans.ModelType -import org.onap.so.serviceinstancebeans.OwningEntity -import org.onap.so.serviceinstancebeans.Project -import org.onap.so.serviceinstancebeans.RequestDetails -import org.onap.so.serviceinstancebeans.RequestInfo -import org.onap.so.serviceinstancebeans.RequestParameters -import org.onap.so.serviceinstancebeans.Resources -import org.onap.so.serviceinstancebeans.Service -import org.onap.so.serviceinstancebeans.SubscriberInfo -import org.onap.so.serviceinstancebeans.VfModules -import org.onap.so.serviceinstancebeans.Vnfs import org.slf4j.Logger import org.slf4j.LoggerFactory -import javax.ws.rs.core.Response +import static org.apache.commons.lang3.StringUtils.isAllLowerCase +import static org.apache.commons.lang3.StringUtils.isBlank class DoModifyCoreNSSI extends DoCommonCoreNSSI { private final String PREFIX ="DoModifyCoreNSSI" + private final String ACTION = "Modify" private ExceptionUtil exceptionUtil = new ExceptionUtil() private RequestDBUtil requestDBUtil = new RequestDBUtil() @@ -80,22 +55,17 @@ class DoModifyCoreNSSI extends DoCommonCoreNSSI { private static final Logger LOGGER = LoggerFactory.getLogger( DoModifyCoreNSSI.class) + /** - * Creates Slice Profile Instance + * Prepares Slice Profile * @param execution + * @return SLice Profile */ - void createSliceProfileInstance(DelegateExecution execution) { - LOGGER.trace("${PREFIX} Start createSliceProfileInstance") - + SliceProfile prepareSliceProfile(DelegateExecution execution) { def currentNSSI = execution.getVariable("currentNSSI") - String sliceProfileID = execution.getVariable("sliceProfileID") - Map<String, Object> sliceProfileMap = execution.getVariable("sliceProfileCn") - Map<String, Object> serviceProfileMap = execution.getVariable("serviceProfile") - - String globalSubscriberId = currentNSSI['globalSubscriberId'] - String serviceType = currentNSSI['serviceType'] - String nssiId = currentNSSI['nssiId'] + String sliceProfileID = currentNSSI['sliceProfileId'] + Map<String,Object> sliceProfileMap = new ObjectMapper().readValue(currentNSSI['sliceProfile'], Map.class) SliceProfile sliceProfile = new SliceProfile() sliceProfile.setServiceAreaDimension("") @@ -105,26 +75,117 @@ class DoModifyCoreNSSI extends DoCommonCoreNSSI { sliceProfile.setExpDataRate(0) sliceProfile.setTrafficDensity(0) sliceProfile.setConnDensity(0) - sliceProfile.setSNssai(sliceProfileMap.get("sNSSAI").toString()) - sliceProfile.setExpDataRateUL(Integer.parseInt(sliceProfileMap.get("expDataRateUL").toString())) - sliceProfile.setExpDataRateDL(Integer.parseInt(sliceProfileMap.get("expDataRateDL").toString())) - sliceProfile.setActivityFactor(Integer.parseInt(sliceProfileMap.get("activityFactor").toString())) - sliceProfile.setResourceSharingLevel(sliceProfileMap.get("activityFactor").toString()) - sliceProfile.setUeMobilityLevel(serviceProfileMap.get("uEMobilityLevel").toString()) - sliceProfile.setCoverageAreaTAList(serviceProfileMap.get("coverageAreaTAList").toString()) - sliceProfile.setMaxNumberOfUEs(Integer.parseInt(sliceProfileMap.get("activityFactor").toString())) - sliceProfile.setLatency(Integer.parseInt(sliceProfileMap.get("latency").toString())) + sliceProfile.setSNssai(currentNSSI['S-NSSAI']) + + if(!isBlank(sliceProfileMap.get("expDataRateUL"))) { + sliceProfile.setExpDataRateUL(Integer.parseInt(sliceProfileMap.get("expDataRateUL").toString())) + } + + if(!isBlank(sliceProfileMap.get("expDataRateDL"))) { + sliceProfile.setExpDataRateDL(Integer.parseInt(sliceProfileMap.get("expDataRateDL").toString())) + } + + if(!isBlank(sliceProfileMap.get("activityFactor"))) { + sliceProfile.setActivityFactor(Integer.parseInt(sliceProfileMap.get("activityFactor").toString())) + } + + if(!isBlank(sliceProfileMap.get("resourceSharingLevel"))) { + sliceProfile.setResourceSharingLevel(sliceProfileMap.get("resourceSharingLevel").toString()) + } + + if(!isBlank(sliceProfileMap.get("uEMobilityLevel"))) { + sliceProfile.setUeMobilityLevel(sliceProfileMap.get("uEMobilityLevel").toString()) + } + + if(!isBlank(sliceProfileMap.get("coverageAreaTAList"))) { + sliceProfile.setCoverageAreaTAList(sliceProfileMap.get("coverageAreaTAList").toString()) + } + + if(!isBlank(sliceProfileMap.get("maxNumberofUEs"))) { + sliceProfile.setMaxNumberOfUEs(Integer.parseInt(sliceProfileMap.get("maxNumberofUEs").toString())) + } + + if(!isBlank(sliceProfileMap.get("latency"))) { + sliceProfile.setLatency(Integer.parseInt(sliceProfileMap.get("latency").toString())) + } + sliceProfile.setProfileId(sliceProfileID) sliceProfile.setE2ELatency(0) + return sliceProfile + } + + + /** + * Prepares Slice Profile Instance + * @param execution + * @return Slice Profile Instance + */ + ServiceInstance prepareSliceProfileInstance(DelegateExecution execution) { + + def currentNSSI = execution.getVariable("currentNSSI") + + ServiceInstance sliceProfileInstance = new ServiceInstance() + String sliceProfileInstanceId = UUID.randomUUID().toString() + sliceProfileInstance.setServiceInstanceId(sliceProfileInstanceId) + + + String sliceInstanceName = "sliceprofile_" + sliceProfileInstanceId + sliceProfileInstance.setServiceInstanceName(sliceInstanceName) + + String serviceType = jsonUtil.getJsonValue(currentNSSI['sliceProfile'], "sST") + sliceProfileInstance.setServiceType(serviceType) + + String serviceStatus = "deactivated" + sliceProfileInstance.setOrchestrationStatus(serviceStatus) + + String serviceInstanceLocationid = jsonUtil.getJsonValue(currentNSSI['sliceProfile'], "plmnIdList") + sliceProfileInstance.setServiceInstanceLocationId(serviceInstanceLocationid) + + String serviceRole = "slice-profile-instance" + sliceProfileInstance.setServiceRole(serviceRole) + List<String> snssaiList = (List<String>)currentNSSI['S-NSSAIs'] + String snssai = snssaiList.get(0) + + sliceProfileInstance.setEnvironmentContext(snssai) + sliceProfileInstance.setWorkloadContext("CN-NF") + + // TO DO: Model info + + return sliceProfileInstance + } + + + + /** + * Creates Slice Profile Instance + * @param execution + */ + void createSliceProfileInstance(DelegateExecution execution) { + LOGGER.trace("${PREFIX} Start createSliceProfileInstance") + + def currentNSSI = execution.getVariable("currentNSSI") + + String globalSubscriberId = execution.getVariable("globalSubscriberId") + String subscriptionServiceType = execution.getVariable("subscriptionServiceType") + + SliceProfile sliceProfile = prepareSliceProfile(execution) + + ServiceInstance sliceProfileInstance = prepareSliceProfileInstance(execution) + + SliceProfiles sliceProfiles = new SliceProfiles() + sliceProfiles.getSliceProfile().add(sliceProfile) + sliceProfileInstance.setSliceProfiles(sliceProfiles) + try { AAIResourcesClient client = getAAIClient() - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(serviceType).serviceInstance(nssiId).sliceProfile(sliceProfileID)) - client.create(uri, sliceProfile) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType). + serviceInstance(sliceProfileInstance.getServiceInstanceId())) + client.create(uri, sliceProfileInstance) - currentNSSI['createdSliceProfile'] = sliceProfile + currentNSSI['createdSliceProfileInstanceId'] = sliceProfileInstance.getServiceInstanceId() } catch (Exception ex) { - exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occured while Slice Profile create call:" + ex.getMessage()) + exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occurred while Slice Profile create call:" + ex.getMessage()) } LOGGER.trace("${PREFIX} Exit createSliceProfileInstance") @@ -132,34 +193,92 @@ class DoModifyCoreNSSI extends DoCommonCoreNSSI { /** + * Creates Allotted Resource + * @param execution + * @return AllottedResource + */ + AllottedResource createAllottedResource(DelegateExecution execution) { + def currentNSSI = execution.getVariable("currentNSSI") + + String globalSubscriberId = execution.getVariable("globalSubscriberId") + String subscriptionServiceType = execution.getVariable("subscriptionServiceType") + String sliceProfileInstanceId = currentNSSI['createdSliceProfileInstanceId'] + + AllottedResource allottedResource = new AllottedResource() + + String allottedResourceId = UUID.randomUUID().toString() + + allottedResource.setId(allottedResourceId) + + // TO DO: No other info + + try { + AAIResourcesClient client = getAAIClient() + AAIResourceUri allottedResourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(sliceProfileInstanceId).allottedResource(allottedResourceId)) + + client.create(allottedResourceUri, allottedResource) + + currentNSSI['allottedResourceUri'] = allottedResourceUri + } catch (Exception ex) { + exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occurred while Allotted Resource create call:" + ex.getMessage()) + } + + return allottedResource + } + + + + /** * Creates Slice Profile association with NSSI * @param execution */ void associateSliceProfileInstanceWithNSSI(DelegateExecution execution) { LOGGER.trace("${PREFIX} Start associateSliceProfileInstanceWithNSSI") - String sliceProfileID = execution.getVariable("sliceProfileID") - def currentNSSI = execution.getVariable("currentNSSI") - String globalSubscriberId = currentNSSI['globalSubscriberId'] - String serviceType = currentNSSI['serviceType'] String nssiId = currentNSSI['nssiId'] - AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nssiId)) - AAIResourceUri sliceProfileUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(serviceType).serviceInstance(nssiId).sliceProfile(sliceProfileID)) + String sliceProfileInstanceId = currentNSSI['createdSliceProfileInstanceId'] + AAIResourcesClient client = getAAIClient() + + // Creates Allotted Resource + AllottedResource allottedResource = createAllottedResource(execution) + AAIResourceUri allottedResourceUri = (AAIResourceUri)currentNSSI['allottedResourceUri'] + + // Updates Slice Profile Instance with Allotted Resource try { - SliceProfile createdSliceProfile = (SliceProfile)currentNSSI['createdSliceProfile'] - ServiceInstance nssi = (ServiceInstance)currentNSSI['nssi'] - List<SliceProfile> associatedProfiles = nssi.getSliceProfiles().getSliceProfile() - associatedProfiles.add(createdSliceProfile) + AAIResourceUri sliceProfileInstanceUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(sliceProfileInstanceId)) + Optional<ServiceInstance> sliceProfileInstanceOpt = client.get(ServiceInstance.class, sliceProfileInstanceUri) + if (sliceProfileInstanceOpt.isPresent()) { + ServiceInstance sliceProfileInstance = sliceProfileInstanceOpt.get() + + AllottedResources allottedResources = sliceProfileInstance.getAllottedResources() + if(allottedResources == null) { + allottedResources = new AllottedResources() + } - getAAIClient().update(nssiUri, nssi) + allottedResources.getAllottedResource().add(allottedResource) + sliceProfileInstance.setAllottedResources(allottedResources) - getAAIClient().connect(sliceProfileUri, nssiUri, AAIEdgeLabel.BELONGS_TO) - }catch(Exception e){ - exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occured while Slice Profile association with NSSI disconnect call: " + e.getMessage()) + client.update(sliceProfileInstanceUri, sliceProfileInstance) + } + else { + exceptionUtil.buildAndThrowWorkflowException(execution, 500, "No slice profile instance found with id = " + sliceProfileInstanceId) + } + + } catch(Exception e){ + exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occured while Slice Profile Instance update call: " + e.getMessage()) + } + + + // Associates NSSI with Allotted Resource + try { + AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nssiId)) + client.connect(nssiUri, allottedResourceUri, AAIEdgeLabel.USES) + } catch(Exception e){ + exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occured while NSSI with Allotted Resource connect call: " + e.getMessage()) } LOGGER.trace("${PREFIX} Exit associateSliceProfileInstanceWithNSSI") @@ -171,4 +290,9 @@ class DoModifyCoreNSSI extends DoCommonCoreNSSI { return PREFIX } + + @Override + String getAction() { + return ACTION + } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyTnNssi.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyTnNssi.groovy index 03a726c52c..4ff15a58c5 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyTnNssi.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyTnNssi.groovy @@ -387,7 +387,7 @@ public class DoModifyTnNssi extends AbstractServiceTaskProcessor { roStatus.setProgress(progress) roStatus.setStatus(status) roStatus.setStatusDescription(statusDescription) - requestDBUtil.prepareUpdateResourceOperationStatus(execution, status) + requestDBUtil.prepareUpdateResourceOperationStatus(execution, roStatus) } } 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-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnAllocateNssi.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnAllocateNssi.groovy index 7d2e536af9..e856522fca 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnAllocateNssi.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnAllocateNssi.groovy @@ -27,11 +27,9 @@ import groovy.json.JsonSlurper import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.aai.domain.yang.ServiceInstance -import org.onap.aaiclient.client.aai.AAIObjectType import org.onap.aaiclient.client.aai.AAIResourcesClient import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory -import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil @@ -155,7 +153,7 @@ class TnAllocateNssi extends AbstractServiceTaskProcessor { "modelUuid":"${modelUuid}", "modelVersion":"" }""" - execution.setVariable("ssServiceModelInfo", serviceModelInfo) + execution.setVariable("serviceModelInfo", serviceModelInfo) logger.debug("Finish prepareDecomposeService") } @@ -186,13 +184,14 @@ class TnAllocateNssi extends AbstractServiceTaskProcessor { if (maxIndex < 1) { String msg = "Exception in TN NSST processDecomposition. There is no NSST associated with TN NSST " logger.info(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + //exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } else { + execution.setVariable("tnNsstInfoList", nsstInfoList) + execution.setVariable("tnModelVersion", tnModelVersion) + execution.setVariable("tnModelName", tnModelName) + execution.setVariable("currentIndex", currentIndex) + execution.setVariable("maxIndex", maxIndex) } - execution.setVariable("tnNsstInfoList", nsstInfoList) - execution.setVariable("tnModelVersion", tnModelVersion) - execution.setVariable("tnModelName", tnModelName) - execution.setVariable("currentIndex", currentIndex) - execution.setVariable("maxIndex", maxIndex) logger.debug("End processDecomposition") } @@ -334,7 +333,7 @@ class TnAllocateNssi extends AbstractServiceTaskProcessor { roStatus.setProgress(progress) roStatus.setStatus(status) roStatus.setStatusDescription(statusDescription) - requestDBUtil.prepareUpdateResourceOperationStatus(execution, status) + requestDBUtil.prepareUpdateResourceOperationStatus(execution, roStatus) } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnNssmfUtils.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnNssmfUtils.groovy index a1b883c34e..1bb0e8aca7 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnNssmfUtils.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnNssmfUtils.groovy @@ -20,8 +20,11 @@ package org.onap.so.bpmn.infrastructure.scripts - +import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.aai.domain.yang.Relationship +import org.onap.aaiclient.client.aai.AAIResourcesClient +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.common.scripts.MsoUtils import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils @@ -241,4 +244,40 @@ class TnNssmfUtils { return res } + + void createRelationShipInAAI(DelegateExecution execution, AAIResourceUri uri, Relationship relationship) { + logger.debug("createRelationShipInAAI Start") + String msg + AAIResourcesClient client = new AAIResourcesClient() + try { + if (!client.exists(uri)) { + logger.info("ERROR: createRelationShipInAAI: not exist: uri={}", uri) + return + } + AAIResourceUri from = ((AAIResourceUri) (uri.clone())).relationshipAPI() + client.create(from, relationship) + + } catch (BpmnError e) { + throw e + } catch (Exception ex) { + msg = "Exception in createRelationShipInAAI. " + ex.getMessage() + logger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.debug("createRelationShipInAAI Exit") + } + + void attachLogicalLinkToAllottedResource(DelegateExecution execution, String aaiVersion, AAIResourceUri arUri, + String logicalLinkId) { + + + String toLink = "aai/${aaiVersion}/network/logical-links/logical-link/${logicalLinkId}" + + Relationship relationship = new Relationship() + relationship.setRelatedLink(toLink) + relationship.setRelatedTo("logical-link") + relationship.setRelationshipLabel("org.onap.relationships.inventory.ComposedOf") + + createRelationShipInAAI(execution, arUri, relationship) + } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCommonCoreNSSITest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCommonCoreNSSITest.groovy index 2c943ffc7c..9707dd2242 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCommonCoreNSSITest.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCommonCoreNSSITest.groovy @@ -24,19 +24,24 @@ import com.fasterxml.jackson.databind.ObjectMapper import org.junit.Before import org.junit.Test import org.mockito.Mockito -import org.onap.aai.domain.yang.* -import org.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aai.domain.yang.v19.* import org.onap.aaiclient.client.aai.entities.AAIResultWrapper import org.onap.aaiclient.client.aai.entities.Relationships import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri import org.onap.aaiclient.client.aai.entities.uri.AAISimpleUri import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory +import org.onap.aaiclient.client.aai.entities.uri.ServiceInstanceUri import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types -import org.onap.aaiclient.client.aai.entities.uri.ServiceInstanceUri +import org.onap.so.bpmn.common.scripts.ExternalAPIUtil +import org.onap.so.bpmn.common.scripts.ExternalAPIUtilFactory import org.onap.so.bpmn.common.scripts.MsoGroovyTest +import org.onap.so.bpmn.core.json.JsonUtils import org.onap.so.serviceinstancebeans.RequestDetails +import javax.ws.rs.core.Response +import java.time.Instant + import static org.junit.Assert.assertNotNull import static org.junit.Assert.assertTrue import static org.mockito.Mockito.* @@ -50,13 +55,32 @@ class DoCommonCoreNSSITest extends MsoGroovyTest { @Test void testPreProcessRequest() { - def currentNSSI = [:] - currentNSSI.put("nssiId","5G-999") - when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI) + + String nssiId = "5G-999" + when(mockExecution.getVariable("serviceInstanceID")).thenReturn(nssiId) + + String nsiId = "5G-777" + when(mockExecution.getVariable("nsiId")).thenReturn(nsiId) + + String snssai = "S-NSSAI" + String snssaiList = "[ \"${snssai}\" ]" + String sliceProfileId = "slice-profile-id" + String sliceParams = "{\n" + + "\"sliceProfile\":{\"sliceProfileId\":\"${sliceProfileId}\",\"snssaiList\":${snssaiList}}\n" + + "}" + when(mockExecution.getVariable("sliceParams")).thenReturn(sliceParams) DoCommonCoreNSSI dcnssi = new DoCommonCoreNSSI() dcnssi.preProcessRequest(mockExecution) - Mockito.verify(mockExecution,times(1)).getVariable("currentNSSI") + + def currentNSSI = [:] + currentNSSI.put("nssiId", nssiId) + currentNSSI.put("nsiId", nsiId) + currentNSSI.put("sliceProfile", "{\"sliceProfileId\":\"slice-profile-id\",\"snssaiList\":[\"S-NSSAI\"]}") + currentNSSI.put("S-NSSAI", snssai) + currentNSSI.put("sliceProfileId", sliceProfileId) + Mockito.verify(mockExecution,times(1)).setVariable("currentNSSI", currentNSSI) + } @@ -90,13 +114,13 @@ class DoCommonCoreNSSITest extends MsoGroovyTest { Relationships rsMock = mock(Relationships.class) Optional<Relationships> orsMock = Optional.of(rsMock) List<AAIResourceUri> arus = new ArrayList<>() - AAIResourceUri aru = new ServiceInstanceUri(networkServiceInstanceUri) + AAIResourceUri aru = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(networkServiceInstance.getServiceInstanceId())) arus.add(aru) when(client.get(nssiUri)).thenReturn(wrapperMock) when(wrapperMock.getRelationships()).thenReturn(orsMock) - when(rsMockgetRelatedUris(Types.SERVICE_INSTANCE)).thenReturn(arus) + when(rsMock.getRelatedUris(Types.SERVICE_INSTANCE)).thenReturn(arus) when(client.get(ServiceInstance.class, aru)).thenReturn(networkServiceInstaneOpt) spy.getNetworkServiceInstance(mockExecution) @@ -145,7 +169,7 @@ class DoCommonCoreNSSITest extends MsoGroovyTest { when(client.get(networkServiceInstanceUri)).thenReturn(wrapperMock) when(wrapperMock.getRelationships()).thenReturn(orsMock) - when(rsMockgetRelatedUris(Types.GENERIC_VNF)).thenReturn(arus) + when(rsMock.getRelatedUris(Types.GENERIC_VNF)).thenReturn(arus) when(client.get(GenericVnf.class, genericVNFUri)).thenReturn(genericVnfOpt) spy.getConstituteVNFFromNetworkServiceInst(mockExecution) @@ -162,8 +186,10 @@ class DoCommonCoreNSSITest extends MsoGroovyTest { def currentNSSI = [:] when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI) + String nssiId = "5G-999" ServiceInstance nssi = new ServiceInstance() - nssi.setServiceInstanceId("5G-999") + nssi.setServiceInstanceId(nssiId) + currentNSSI.put("nssiId", nssiId) SliceProfiles sliceProfiles = new SliceProfiles() @@ -171,13 +197,49 @@ class DoCommonCoreNSSITest extends MsoGroovyTest { slProfiles.add(new SliceProfile()) slProfiles.add(new SliceProfile()) - nssi.setSliceProfiles(sliceProfiles) + //nssi.setSliceProfiles(sliceProfiles) currentNSSI.put("nssi", nssi) - DoCommonCoreNSSI obj = new DoCommonCoreNSSI() - obj.getNSSIAssociatedProfiles(mockExecution) + DoCommonCoreNSSI spy = spy(DoCommonCoreNSSI.class) + when(spy.getAAIClient()).thenReturn(client) + + AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nssiId)) + + AAIResultWrapper wrapperMock = mock(AAIResultWrapper.class) //new AAIResultWrapper(json) + Relationships rsMock = mock(Relationships.class) + Optional<Relationships> orsMock = Optional.of(rsMock) + List<AAIResourceUri> allottedUris = new ArrayList<>() + AAIResourceUri allottedUri = AAIUriFactory.createResourceUri(Types.ALLOTTED_RESOURCE.getFragment("allotted-id")) + allottedUris.add(allottedUri) + + when(client.get(nssiUri)).thenReturn(wrapperMock) + when(wrapperMock.getRelationships()).thenReturn(orsMock) + when(rsMock.getRelatedUris(Types.ALLOTTED_RESOURCE)).thenReturn(allottedUris) + + String sliceProfileInstanceId = "slice-profile-instance-id" + ServiceInstance sliceProfileInstance = new ServiceInstance() + sliceProfileInstance.setServiceInstanceId(sliceProfileInstanceId) + sliceProfileInstance.setServiceRole("slice-profile-instance") + + List<AAIResourceUri> sliceProfileInstanceUris = new ArrayList<>() + AAIResourceUri sliceProfileInstanceUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(sliceProfileInstance.getServiceInstanceId())) + sliceProfileInstanceUris.add(sliceProfileInstanceUri) + + Optional<ServiceInstance> sliceProfileInstanceOpt = Optional.of(sliceProfileInstance) + + when(client.get(allottedUri)).thenReturn(wrapperMock) + when(rsMock.getRelatedUris(Types.SERVICE_INSTANCE)).thenReturn(sliceProfileInstanceUris) + when(client.get(ServiceInstance.class, sliceProfileInstanceUri)).thenReturn(sliceProfileInstanceOpt) + + + SliceProfiles sps = new SliceProfiles() + sps.getSliceProfile().addAll(slProfiles) + sliceProfileInstance.setSliceProfiles(sps) + + spy.getNSSIAssociatedProfiles(mockExecution) List<SliceProfile> associatedProfiles = (List<SliceProfile>)currentNSSI.get("associatedProfiles") + assertTrue("sliceProfileInstanceUri not found in contect Map", currentNSSI.get("sliceProfileInstanceUri") != null) assertTrue("Either associatedProfiles doesn't exist or size is incorrect", (associatedProfiles != null && associatedProfiles.size() == 2)) } @@ -190,13 +252,9 @@ class DoCommonCoreNSSITest extends MsoGroovyTest { networkServiceInstance.setServiceInstanceId("NS-777") networkServiceInstance.setServiceRole("Network Service") - GenericVnf constituteVnf = new GenericVnf() - constituteVnf.setVnfId("VNF-1") - when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI) currentNSSI.put("networkServiceInstance", networkServiceInstance) - currentNSSI.put("constituteVnf", constituteVnf) when(mockExecution.getVariable("mso.infra.endpoint.url")).thenReturn("http://mso.onap:8088") when(mockExecution.getVariable("mso.msoKey")).thenReturn("mso.msoKey") @@ -211,7 +269,7 @@ class DoCommonCoreNSSITest extends MsoGroovyTest { when(spy.getAuthHeader(mockExecution, "auth-value", "mso.msoKey")).thenReturn(authHeaderResponse) - String urlString = String.format("http://mso.onap:8088/serviceInstantiation/v7/serviceInstances/%s/vnfs/%s", networkServiceInstance.getServiceInstanceId(), constituteVnf.getVnfId()) + String urlString = String.format("http://mso.onap:8088/serviceInstantiation/v7/serviceInstances/%s", networkServiceInstance.getServiceInstanceId()) String callPUTServiceInstanceResponse = "put" @@ -243,6 +301,20 @@ class DoCommonCoreNSSITest extends MsoGroovyTest { AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nssiId)) + AAIResourceUri sliceProfileInstanceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer("global-subscriber-id").serviceSubscription("subscription-service-type"). + serviceInstance("slice-profile-instance-id")) + + String sliceProfileInstanceId = "slice-profile-instance-id" + ServiceInstance sliceProfileInstance = new ServiceInstance() + sliceProfileInstance.setServiceInstanceId(sliceProfileInstanceId) + sliceProfileInstance.setServiceRole("slice-profile-instance") + + Optional<ServiceInstance> sliceProfileInstanceOpt = Optional.of(sliceProfileInstance) + + when(client.get(ServiceInstance.class, sliceProfileInstanceUri)).thenReturn(sliceProfileInstanceOpt) + + currentNSSI.put("sliceProfileInstanceUri", sliceProfileInstanceUri) + DoCommonCoreNSSI spy = spy(DoCommonCoreNSSI.class) when(spy.getAAIClient()).thenReturn(client) @@ -265,13 +337,19 @@ class DoCommonCoreNSSITest extends MsoGroovyTest { associatedProfiles.add(sliceProfile2) associatedProfiles.add(sliceProfile3) + SliceProfiles sps = new SliceProfiles() + sps.getSliceProfile().addAll(associatedProfiles) + sliceProfileInstance.setSliceProfiles(sps) + int sizeBefore = associatedProfiles.size() - doNothing().when(client).update(nssiUri, nssi) + doNothing().when(client).update(sliceProfileInstanceUri, sliceProfileInstance) + + doNothing().when(client). disconnect(nssiUri, sliceProfileInstanceUri) spy.removeSPAssociationWithNSSI(mockExecution) - assertTrue("Association between slice profile and NSSI wasn't removed", ((ServiceInstance)currentNSSI.get("nssi")).getSliceProfiles().getSliceProfile().size() == (sizeBefore - 1)) + assertTrue("Association between slice profile and NSSI wasn't removed", ((ServiceInstance)currentNSSI.get("sliceProfileInstance")).getSliceProfiles().getSliceProfile().size() == (sizeBefore - 1)) } @@ -281,29 +359,16 @@ class DoCommonCoreNSSITest extends MsoGroovyTest { when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI) - String globalSubscriberId = "global-id" - String serviceType = "service" - String nssiId = "5G-999" + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer("global-subscriber-id").serviceSubscription("subscription-service-type"). + serviceInstance("slice-profile-instance-id")) - currentNSSI.put("globalSubscriberId", globalSubscriberId) - currentNSSI.put("serviceType", serviceType) - currentNSSI.put("nssiId", nssiId) - - String theSNSSAI = "theS-NSSAI" - - SliceProfile sliceProfile = new SliceProfile() - sliceProfile.setSNssai(theSNSSAI) - sliceProfile.setProfileId("prof-id") - - AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nssiId)) - - currentNSSI.put("sliceProfileS-NSSAI", sliceProfile) + currentNSSI.put("sliceProfileInstanceUri", uri) DoCommonCoreNSSI spy = spy(DoCommonCoreNSSI.class) when(spy.getAAIClient()).thenReturn(client) - doNothing().when(client).delete(nssiUri) + doNothing().when(client).delete(uri) spy.deleteSliceProfileInstance(mockExecution) @@ -311,26 +376,6 @@ class DoCommonCoreNSSITest extends MsoGroovyTest { @Test - void testUpdateServiceOperationStatus() { - def currentNSSI = [:] - - when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI) - - String nssiId = "5G-999" - - currentNSSI.put("nssiId", nssiId) - currentNSSI.put("e2eServiceInstanceId", "e2eServiceInstanceId") - currentNSSI.put("operationId", "operationId") - currentNSSI.put("operationType", "operationType") - - DoCommonCoreNSSI spy = spy(DoCommonCoreNSSI.class) - - spy.updateServiceOperationStatus(mockExecution) - - } - - - @Test void testPrepareRequestDetails() { def currentNSSI = [:] @@ -426,7 +471,130 @@ class DoCommonCoreNSSITest extends MsoGroovyTest { prepareProject(cloudRegionAAIUri) - String requestDetails = spy.prepareRequestDetails(mockExecution) + String prepareRequestDetailsResponse = spy.prepareRequestDetails(mockExecution) + + JsonUtils jsonUtil = new JsonUtils() + String errorCode = jsonUtil.getJsonValue(prepareRequestDetailsResponse, "errorCode") + String errMsg = jsonUtil.getJsonValue(prepareRequestDetailsResponse, "errorMessage") + + assertTrue(errMsg, errorCode == null || errorCode.isEmpty()) + } + + + @Test + void testPrepareFailedOperationStatusUpdate() { + def currentNSSI = [:] + + when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI) + when(mockExecution.getVariable("jobId")).thenReturn("job-id") + when(mockExecution.getVariable("operationType")).thenReturn("operation-type") + + String nssiId = "5G-999" + String nsiId = "5G-777" + + currentNSSI.put("nssiId", nssiId) + currentNSSI.put("nsiId", nsiId) + currentNSSI.put("e2eServiceInstanceId", "e2eServiceInstanceId") + currentNSSI.put("operationId", "operationId") + currentNSSI.put("operationType", "operationType") + + DoCommonCoreNSSI spy = spy(DoCommonCoreNSSI.class) + + spy.prepareFailedOperationStatusUpdate(mockExecution) + } + + + @Test + void testPrepareUpdateResourceOperationStatus() { + def currentNSSI = [:] + + when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI) + when(mockExecution.getVariable("jobId")).thenReturn("job-id") + when(mockExecution.getVariable("operationType")).thenReturn("operation-type") + + String nssiId = "5G-999" + String nsiId = "5G-777" + + currentNSSI.put("nssiId", nssiId) + currentNSSI.put("nsiId", nsiId) + currentNSSI.put("e2eServiceInstanceId", "e2eServiceInstanceId") + currentNSSI.put("operationId", "operationId") + currentNSSI.put("operationType", "operationType") + + DoCommonCoreNSSI spy = spy(DoCommonCoreNSSI.class) + + spy.prepareUpdateResourceOperationStatus(mockExecution) + + } + + + @Test + void testGetPUTServiceInstanceProgressAcknowledged() { + + executePUTServiceInstanceProgress("ACKNOWLEDGED") + Mockito.verify(mockExecution,times(1)).setVariable("putStatus", "processing") + } + + + @Test + void testGetPUTServiceInstanceProgressInProgress() { + + executePUTServiceInstanceProgress("INPROGRESS") + Mockito.verify(mockExecution,times(1)).setVariable("putStatus", "processing") + } + + + @Test + void testGetPUTServiceInstanceProgressCompleted() { + + executePUTServiceInstanceProgress("COMPLETED") + Mockito.verify(mockExecution,times(1)).setVariable("putStatus", "completed") + } + + + @Test + void testTimeDelay() { + DoCommonCoreNSSI obj = spy(DoCommonCoreNSSI.class) + + long before = Instant.now().toEpochMilli() + obj.timeDelay(mockExecution) + + long after = Instant.now().toEpochMilli() + + long delay = 5L + + assertTrue(String.format("Didn't wait %d sec", delay), ((after - before) >= delay)) + } + + + void executePUTServiceInstanceProgress(String state) { + + def currentNSSI = [:] + + when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI) + + String url = "http://mso.onap:8088/serviceInstantiation/v7/serviceInstances/5G-777" + + currentNSSI.put("putServiceInstanceURL", url) + + DoCommonCoreNSSI spy = spy(DoCommonCoreNSSI.class) + + ExternalAPIUtilFactory externalAPIUtilFactoryMock = mock(ExternalAPIUtilFactory.class) + when(spy.getExternalAPIUtilFactory()).thenReturn(externalAPIUtilFactoryMock) + + ExternalAPIUtil externalAPIUtilMock = mock(ExternalAPIUtil.class) + + when(externalAPIUtilFactoryMock.create()).thenReturn(externalAPIUtilMock) + + Response responseMock = mock(Response.class) + when(externalAPIUtilMock.executeExternalAPIGetCall(mockExecution, url)).thenReturn(responseMock) + + when(responseMock.getStatus()).thenReturn(200) + + String entity = "{\"state\":\"ACCEPTED\",\"orderItem\":[{\"service\":{\"id\":\"5G-999\"},\"state\":\"${state}\"}]}" + when(responseMock.readEntity(String.class)).thenReturn(entity) + + spy.getPUTServiceInstanceProgress(mockExecution) } @@ -446,7 +614,7 @@ class DoCommonCoreNSSITest extends MsoGroovyTest { AAIResourceUri aru = new AAISimpleUri(cloudRegionAAIUri) arus.add(aru) - when(rsMockgetRelatedUris(Types.PROJECT)).thenReturn(arus) + when(rsMock.getRelatedUris(Types.PROJECT)).thenReturn(arus) Optional<Project> projectOpt = Optional.of(project) @@ -472,7 +640,7 @@ class DoCommonCoreNSSITest extends MsoGroovyTest { AAIResourceUri aru = new AAISimpleUri(networkServiceInstanceUri) arus.add(aru) - when(rsMockgetRelatedUris(Types.OWNING_ENTITY)).thenReturn(arus) + when(rsMock.getRelatedUris(Types.OWNING_ENTITY)).thenReturn(arus) Optional<OwningEntity> owningEntityOpt = Optional.of(owningEntity) @@ -494,7 +662,7 @@ class DoCommonCoreNSSITest extends MsoGroovyTest { AAIResourceUri aru = new AAISimpleUri(cloudRegionAAIUri) arus.add(aru) - when(rsMockgetRelatedUris(Types.CLOUD_REGION)).thenReturn(arus) + when(rsMock.getRelatedUris(Types.CLOUD_REGION)).thenReturn(arus) CloudRegion cloudRegion = new CloudRegion() cloudRegion.setCloudRegionId("cloud-region-id") @@ -527,7 +695,7 @@ class DoCommonCoreNSSITest extends MsoGroovyTest { arus.add(serviceSubscriptionUri) - when(rsMockgetRelatedUris(Types.SERVICE_SUBSCRIPTION)).thenReturn(arus) + when(rsMock.getRelatedUris(Types.SERVICE_SUBSCRIPTION)).thenReturn(arus) ServiceSubscription serviceSubscription = new ServiceSubscription() serviceSubscription.setServiceType("service-type") @@ -537,7 +705,7 @@ class DoCommonCoreNSSITest extends MsoGroovyTest { when(client.get(networkServiceInstanceUri)).thenReturn(wrapperMock) - when(rsMockgetRelatedUris(Types.CUSTOMER)).thenReturn(arus) + when(rsMock.getRelatedUris(Types.CUSTOMER)).thenReturn(arus) Customer customer = new Customer() customer.setSubscriberName("subscriber-name") diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateCoreNSSITest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateCoreNSSITest.groovy index eae788666d..26b96a0a4a 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateCoreNSSITest.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateCoreNSSITest.groovy @@ -20,19 +20,20 @@ package org.onap.so.bpmn.infrastructure.scripts - import org.junit.Before import org.junit.Test -import org.onap.aai.domain.yang.ServiceInstance -import org.onap.aai.domain.yang.SliceProfile -import org.onap.aai.domain.yang.SliceProfiles -import org.onap.aaiclient.client.aai.AAIObjectType +import org.mockito.Mockito +import org.onap.aai.domain.yang.v19.* import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types +import org.onap.so.bpmn.common.scripts.ExternalAPIUtil +import org.onap.so.bpmn.common.scripts.ExternalAPIUtilFactory import org.onap.so.bpmn.common.scripts.MsoGroovyTest +import javax.ws.rs.core.Response + import static org.junit.Assert.assertNotNull import static org.junit.Assert.assertTrue import static org.mockito.Mockito.* @@ -153,31 +154,6 @@ class DoDeallocateCoreNSSITest extends MsoGroovyTest { @Test - void testGetNSSIAssociatedProfiles() { - def currentNSSI = [:] - when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI) - - ServiceInstance nssi = new ServiceInstance() - nssi.setServiceInstanceId("5G-999") - - SliceProfiles sliceProfiles = new SliceProfiles() - - List<SliceProfile> slProfiles = sliceProfiles.getSliceProfile() - slProfiles.add(new SliceProfile()) - slProfiles.add(new SliceProfile()) - - nssi.setSliceProfiles(sliceProfiles) - currentNSSI.put("nssi", nssi) - - DoDeallocateCoreNSSI obj = new DoDeallocateCoreNSSI() - obj.getNSSIAssociatedProfiles(mockExecution) - - List<SliceProfile> associatedProfiles = (List<SliceProfile>)currentNSSI.get("associatedProfiles") - assertTrue("Either associatedProfiles doesn't exist or size is incorrect", (associatedProfiles != null && associatedProfiles.size() == 2)) - } - - - @Test void testCalculateSNSSAI() { def currentNSSI = [:] when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI) @@ -232,9 +208,30 @@ class DoDeallocateCoreNSSITest extends MsoGroovyTest { currentNSSI.put("nsiId", nsiId) AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nssiId)) + + ServiceInstance nssi = new ServiceInstance() + nssi.setServiceInstanceId(nssiId) + + AllottedResources allottedResources = new AllottedResources() + AllottedResource allottedResource = new AllottedResource() + allottedResource.setId(UUID.randomUUID().toString()) + allottedResources.getAllottedResource().add(allottedResource) + nssi.setAllottedResources(allottedResources) + + currentNSSI.put("nssi", nssi) + AAIResourceUri nsiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nsiId)) - doNothing().when(client).disconnect(nssiUri, nsiUri) + doNothing().when(client).update(nssiUri, nssi) + + String globalSubscriberId = "globalSubscriberId" + String subscriptionServiceType = "subscription-service-type" + when(mockExecution.getVariable("globalSubscriberId")).thenReturn(globalSubscriberId) + when(mockExecution.getVariable("subscriptionServiceType")).thenReturn(subscriptionServiceType) + + AAIResourceUri allottedResourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(nssiId).allottedResource(allottedResource.getId())) + + doNothing().when(client).disconnect(nsiUri, allottedResourceUri) spy.removeNSSIAssociationWithNSI(mockExecution) @@ -263,4 +260,56 @@ class DoDeallocateCoreNSSITest extends MsoGroovyTest { } + @Test + void testDeleteServiceOrderProgressAcknowledged() { + + executeDeleteServiceOrderProgress("ACKNOWLEDGED") + Mockito.verify(mockExecution,times(1)).setVariable("deleteStatus", "processing") + } + + @Test + void testDeleteServiceOrderProgressInProgress() { + + executeDeleteServiceOrderProgress("INPROGRESS") + Mockito.verify(mockExecution,times(1)).setVariable("deleteStatus", "processing") + } + + + @Test + void testDeleteServiceOrderProgressCompleted() { + + executeDeleteServiceOrderProgress("COMPLETED") + Mockito.verify(mockExecution,times(1)).setVariable("deleteStatus", "completed") + } + + + void executeDeleteServiceOrderProgress(String state) { + def currentNSSI = [:] + + when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI) + + String url = "http://nbi.onap:8088/api/v4/serviceOrder/NS-777" + + currentNSSI.put("deleteServiceOrderURL", url) + + DoDeallocateCoreNSSI spy = spy(DoDeallocateCoreNSSI.class) + + ExternalAPIUtilFactory externalAPIUtilFactoryMock = mock(ExternalAPIUtilFactory.class) + when(spy.getExternalAPIUtilFactory()).thenReturn(externalAPIUtilFactoryMock) + + ExternalAPIUtil externalAPIUtilMock = mock(ExternalAPIUtil.class) + + when(externalAPIUtilFactoryMock.create()).thenReturn(externalAPIUtilMock) + + Response responseMock = mock(Response.class) + when(externalAPIUtilMock.executeExternalAPIGetCall(mockExecution, url)).thenReturn(responseMock) + + when(responseMock.getStatus()).thenReturn(200) + + String entity = "{\"state\":\"ACCEPTED\",\"orderItem\":[{\"service\":{\"id\":\"5G-999\"},\"state\":\"${state}\"}]}" + when(responseMock.readEntity(String.class)).thenReturn(entity) + + spy.getDeleteServiceOrderProgress(mockExecution) + } + } diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyCoreNSSITest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyCoreNSSITest.groovy index bbc237f1f9..ac6f897dfa 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyCoreNSSITest.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyCoreNSSITest.groovy @@ -20,13 +20,14 @@ package org.onap.so.bpmn.infrastructure.scripts - +import com.fasterxml.jackson.databind.ObjectMapper import org.junit.Before import org.junit.Test -import org.onap.aai.domain.yang.ServiceInstance -import org.onap.aai.domain.yang.SliceProfile -import org.onap.aai.domain.yang.SliceProfiles -import org.onap.aaiclient.client.aai.AAIObjectType +import org.mockito.Mockito +import org.onap.aai.domain.yang.v19.AllottedResource +import org.onap.aai.domain.yang.v19.ServiceInstance +import org.onap.aai.domain.yang.v19.SliceProfile +import org.onap.aai.domain.yang.v19.SliceProfiles import org.onap.aaiclient.client.aai.entities.AAIEdgeLabel import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory @@ -47,31 +48,6 @@ class DoModifyCoreNSSITest extends MsoGroovyTest { @Test - void testGetNSSIAssociatedProfiles() { - def currentNSSI = [:] - when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI) - - ServiceInstance nssi = new ServiceInstance() - nssi.setServiceInstanceId("5G-999") - - SliceProfiles sliceProfiles = new SliceProfiles() - - List<SliceProfile> slProfiles = sliceProfiles.getSliceProfile() - slProfiles.add(new SliceProfile()) - slProfiles.add(new SliceProfile()) - - nssi.setSliceProfiles(sliceProfiles) - currentNSSI.put("nssi", nssi) - - DoModifyCoreNSSI obj = new DoModifyCoreNSSI() - obj.getNSSIAssociatedProfiles(mockExecution) - - List<SliceProfile> associatedProfiles = (List<SliceProfile>)currentNSSI.get("associatedProfiles") - assertTrue("Either associatedProfiles doesn't exist or size is incorrect", (associatedProfiles != null && associatedProfiles.size() == 2)) - } - - - @Test void testCalculateSNSSAISliceProfileInstanceHasToBeDeleted() { def currentNSSI = [:] when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI) @@ -155,44 +131,42 @@ class DoModifyCoreNSSITest extends MsoGroovyTest { String sliceProfileId = "sliceProfileId" - when(mockExecution.getVariable("sliceProfileID")).thenReturn(sliceProfileId) - - Map<String, Object> sliceProfileMap = new HashMap<>() - sliceProfileMap.put("expDataRateUL", "12") - sliceProfileMap.put("expDataRateDL", 5) - sliceProfileMap.put("activityFactor", 2) - sliceProfileMap.put("latency", 10) - - when(mockExecution.getVariable("sliceProfileCn")).thenReturn(sliceProfileMap) - - - Map<String, Object> serviceProfileMap = new HashMap<>() - when(mockExecution.getVariable("serviceProfile")).thenReturn(serviceProfileMap) + currentNSSI.put("sliceProfile", "{\"sliceProfileId\":\"slice-profile-id\",\"snssaiList\":[\"S-NSSAI\"],\"expDataRateUL\":\"12\",\"expDataRateDL\":\"5\"," + + "\"activityFactor\":\"2\",\"resourceSharingLevel\":\"resource-sharing-level\",\"uEMobilityLevel\":\"ue-mobility-level\",\"coverageAreaTAList\":\"coverage-area-ta-list\"," + + "\"maxNumberofUEs\":\"10000\",\"latency\":\"7\"}") + currentNSSI.put("sliceProfileId", sliceProfileId) + List<String> snssais = new ArrayList<>() + snssais.add("s-nssai") + currentNSSI.put("S-NSSAIs", snssais) DoModifyCoreNSSI spy = spy(DoModifyCoreNSSI.class) when(spy.getAAIClient()).thenReturn(client) String globalSubscriberId = "globalSubscriberId" - String serviceType = "serviceType" + String subscriptionServiceType = "subscription-service-type" String nssiId = "nssiId" - currentNSSI.put("globalSubscriberId", globalSubscriberId) - currentNSSI.put("serviceType", serviceType) + when(mockExecution.getVariable("globalSubscriberId")).thenReturn(globalSubscriberId) + when(mockExecution.getVariable("subscriptionServiceType")).thenReturn(subscriptionServiceType) + currentNSSI.put("nssiId", nssiId) - currentNSSI.put("sliceProfileId", sliceProfileId) - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(serviceType).serviceInstance(nssiId).sliceProfile(sliceProfileId)) + ServiceInstance sliceProfileInstance = new ServiceInstance() + sliceProfileInstance.setServiceInstanceId(UUID.randomUUID().toString()) + + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType). + serviceInstance(sliceProfileInstance.getServiceInstanceId())) SliceProfile sliceProfile = new SliceProfile() sliceProfile.setProfileId(sliceProfileId) - doNothing().when(client).create(uri, sliceProfile) + doNothing().when(client).create(uri, sliceProfileInstance) spy.createSliceProfileInstance(mockExecution) - assertNotNull("Slice Profile doesn't exist", currentNSSI.get("createdSliceProfile")) - assertTrue("Unexpected Slice Profile Id", ((SliceProfile)currentNSSI.get("createdSliceProfile")).getProfileId().equals(sliceProfile.getProfileId())) + assertTrue("Slice Profile Instance Id doesn't exist", (currentNSSI.get("createdSliceProfileInstanceId")) != null) + } @@ -213,32 +187,50 @@ class DoModifyCoreNSSITest extends MsoGroovyTest { currentNSSI.put("nssiId", nssiId) String globalSubscriberId = "globalSubscriberId" - String serviceType = "serviceType" + String subscriptionServiceType = "subscriptionServiceType" - AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nssiId)) - AAIResourceUri sliceProfileUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(serviceType).serviceInstance(nssiId).sliceProfile(sliceProfileId)) + String sliceProfileInstanceId = "slice-rpofile-instance-id" + currentNSSI.put("createdSliceProfileInstanceId", sliceProfileInstanceId) + + AllottedResource allottedResource = new AllottedResource() + + String allottedResourceId = UUID.randomUUID().toString() + + allottedResource.setId(allottedResourceId) + + AAIResourceUri allottedResourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(sliceProfileInstanceId).allottedResource(allottedResourceId)) + doNothing().when(client).create(allottedResourceUri, allottedResource) + + currentNSSI.put("allottedResourceUri", allottedResourceUri) + + when(mockExecution.getVariable("globalSubscriberId")).thenReturn(globalSubscriberId) + when(mockExecution.getVariable("subscriptionServiceType")).thenReturn(subscriptionServiceType) - currentNSSI.put("globalSubscriberId", globalSubscriberId) - currentNSSI.put("serviceType", serviceType) currentNSSI.put("sliceProfileId", sliceProfileId) SliceProfile sliceProfile = new SliceProfile() currentNSSI.put("createdSliceProfile", sliceProfile) + AAIResourceUri sliceProfileInstanceUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(sliceProfileInstanceId)) + + AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nssiId)) + + ServiceInstance sliceProfileInstance = new ServiceInstance() + sliceProfileInstance.setServiceInstanceId(sliceProfileInstanceId) + Optional<ServiceInstance> sliceProfileInstanceOpt = Optional.of(sliceProfileInstance) + + when(client.get(ServiceInstance.class, sliceProfileInstanceUri)).thenReturn(sliceProfileInstanceOpt) + doNothing().when(client).update(sliceProfileInstanceUri, sliceProfileInstance) + ServiceInstance nssi = new ServiceInstance() nssi.setServiceInstanceId(nssiId) nssi.setSliceProfiles(new SliceProfiles()) currentNSSI.put("nssi", nssi) - int sizeBelore = nssi.getSliceProfiles().getSliceProfile().size() - - doNothing().when(client).update(nssiUri, nssi) - doNothing().when(client).connect(sliceProfileUri, nssiUri, AAIEdgeLabel.BELONGS_TO) + doNothing().when(client).connect(nssiUri, sliceProfileInstanceUri, AAIEdgeLabel.USES) spy.associateSliceProfileInstanceWithNSSI(mockExecution) - assertTrue("Wrong number of associated slice profiles", ((ServiceInstance)currentNSSI.get("nssi")).getSliceProfiles().getSliceProfile().size() == (sizeBelore + 1)) } - } diff --git a/bpmn/so-bpmn-infrastructure-flows/pom.xml b/bpmn/so-bpmn-infrastructure-flows/pom.xml index e6eb284199..a8f35986e7 100644 --- a/bpmn/so-bpmn-infrastructure-flows/pom.xml +++ b/bpmn/so-bpmn-infrastructure-flows/pom.xml @@ -195,17 +195,14 @@ <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-spring-boot-starter-jaxws</artifactId> - <version>${cxf.version}</version> </dependency> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-spring-boot-starter-jaxrs</artifactId> - <version>${cxf.version}</version> </dependency> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-rs-service-description-swagger</artifactId> - <version>${cxf.version}</version> </dependency> <dependency> <groupId>com.h2database</groupId> 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> + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateTransportNSSI.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateTransportNSSI.bpmn index f4886322c2..12632dec72 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateTransportNSSI.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateTransportNSSI.bpmn @@ -68,12 +68,12 @@ ex.processJavaException(execution)</bpmn:script> <bpmn:incoming>SequenceFlow_07e12rt</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0t094g7</bpmn:outgoing> <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* -def rupScript = new TnAllocateNssi() +def runScript = new TnAllocateNssi() runScript.prepareUpdateJobStatus(execution,"progress","10","Allocate TN NSSI started")</bpmn:script> </bpmn:scriptTask> <bpmn:intermediateThrowEvent id="IntermediateThrowEvent_1ex8ke9" name="Goto OOF TN NSSI Selection"> <bpmn:incoming>SequenceFlow_0jrclmc</bpmn:incoming> - <bpmn:linkEventDefinition id="LinkEventDefinition_0de65en" name="OofTnNssiSelect" /> + <bpmn:linkEventDefinition id="LinkEventDefinition_0de65en" name="TnAllocateNssi" /> </bpmn:intermediateThrowEvent> <bpmn:scriptTask id="ScriptTask_1ssh2l9" name="Prepare Update Resource Oper Status((finish)" scriptFormat="groovy"> <bpmn:incoming>SequenceFlow_0kixzdj</bpmn:incoming> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateSliceServiceOption.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateSliceServiceOption.bpmn index 1bda596c6a..7699e804b4 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateSliceServiceOption.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateSliceServiceOption.bpmn @@ -160,10 +160,11 @@ dcso.processNSIResp(execution)</bpmn:script> </bpmn:scriptTask> <bpmn:scriptTask id="ScriptTask_0bgvphs" name="Prepare OOF Select NSI options request" scriptFormat="groovy"> <bpmn:incoming>SequenceFlow_1iawj3m</bpmn:incoming> + <bpmn:incoming>SequenceFlow_1e7iqkm</bpmn:incoming> <bpmn:outgoing>SequenceFlow_14o0fxe</bpmn:outgoing> <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* def dcso = new DoCreateSliceServiceOption() -dcso.preNSIRequest(execution,true)</bpmn:script> +dcso.preNSIRequest(execution)</bpmn:script> </bpmn:scriptTask> <bpmn:intermediateCatchEvent id="IntermediateCatchEvent_00uke3g" name=" Select NSSI "> <bpmn:outgoing>SequenceFlow_1iawj3m</bpmn:outgoing> @@ -190,7 +191,7 @@ dcso.handleNssiSelect(execution)</bpmn:script> <bpmn:sequenceFlow id="SequenceFlow_103oxyw" sourceRef="CallActivity_0melx8d" targetRef="ParallelGateway_06a2n9u" /> <bpmn:sequenceFlow id="SequenceFlow_14rhmx9" sourceRef="CallActivity_1vzxvna" targetRef="ParallelGateway_06a2n9u" /> <bpmn:parallelGateway id="ParallelGateway_05zg916"> - <bpmn:incoming>SequenceFlow_1h3kdce</bpmn:incoming> + <bpmn:incoming>SequenceFlow_0vfe8hp</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0il5j01</bpmn:outgoing> <bpmn:outgoing>SequenceFlow_0euwvgf</bpmn:outgoing> <bpmn:outgoing>SequenceFlow_05250mp</bpmn:outgoing> @@ -198,7 +199,7 @@ dcso.handleNssiSelect(execution)</bpmn:script> <bpmn:sequenceFlow id="SequenceFlow_0il5j01" sourceRef="ParallelGateway_05zg916" targetRef="CallActivity_0otry7e" /> <bpmn:sequenceFlow id="SequenceFlow_0euwvgf" sourceRef="ParallelGateway_05zg916" targetRef="CallActivity_0melx8d" /> <bpmn:sequenceFlow id="SequenceFlow_05250mp" sourceRef="ParallelGateway_05zg916" targetRef="CallActivity_1vzxvna" /> - <bpmn:sequenceFlow id="SequenceFlow_1h3kdce" sourceRef="ScriptTask_12t6v71" targetRef="ParallelGateway_05zg916" /> + <bpmn:sequenceFlow id="SequenceFlow_1h3kdce" sourceRef="ScriptTask_12t6v71" targetRef="ExclusiveGateway_015qbbq" /> <bpmn:sequenceFlow id="SequenceFlow_1tqg26p" sourceRef="CallActivity_0tzazs0" targetRef="Task_00nfg5x" /> <bpmn:sequenceFlow id="SequenceFlow_1tey3hz" sourceRef="Task_1jyj2vs" targetRef="ExclusiveGateway_0b52m39" /> <bpmn:sequenceFlow id="SequenceFlow_0abqxa1" sourceRef="Task_1m9qoo3" targetRef="CallActivity_0tzazs0" /> @@ -216,212 +217,234 @@ dcso.handleNssiSelect(execution)</bpmn:script> </bpmn:endEvent> <bpmn:sequenceFlow id="SequenceFlow_1nrfy6i" sourceRef="ExclusiveGateway_0b52m39" targetRef="EndEvent_0p0cjhl" /> <bpmn:sequenceFlow id="SequenceFlow_1ezi1oi" sourceRef="Task_00nfg5x" targetRef="ExclusiveGateway_0b52m39" /> + <bpmn:exclusiveGateway id="ExclusiveGateway_015qbbq" default="SequenceFlow_0vfe8hp"> + <bpmn:incoming>SequenceFlow_1h3kdce</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0vfe8hp</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_1e7iqkm</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:sequenceFlow id="SequenceFlow_0vfe8hp" sourceRef="ExclusiveGateway_015qbbq" targetRef="ParallelGateway_05zg916" /> + <bpmn:sequenceFlow id="SequenceFlow_1e7iqkm" sourceRef="ExclusiveGateway_015qbbq" targetRef="ScriptTask_0bgvphs"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("needQuerySliceProfile") == true}</bpmn:conditionExpression> + </bpmn:sequenceFlow> </bpmn:process> <bpmndi:BPMNDiagram id="BPMNDiagram_1"> <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="DoCreateSliceServiceOption"> <bpmndi:BPMNShape id="ScriptTask_11rb2ju_di" bpmnElement="ScriptTask_11rb2ju"> - <dc:Bounds x="400" y="140" width="100" height="80" /> + <dc:Bounds x="470" y="140" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="CallActivity_0c567r4_di" bpmnElement="CallActivity_0c567r4"> - <dc:Bounds x="560" y="140" width="100" height="80" /> + <dc:Bounds x="630" y="140" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ScriptTask_0z0dwk2_di" bpmnElement="ScriptTask_0z0dwk2"> - <dc:Bounds x="710" y="140" width="100" height="80" /> + <dc:Bounds x="780" y="140" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_1kzy63m_di" bpmnElement="SequenceFlow_1kzy63m"> - <di:waypoint x="500" y="180" /> - <di:waypoint x="560" y="180" /> + <di:waypoint x="570" y="180" /> + <di:waypoint x="630" y="180" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_1t317y2_di" bpmnElement="SequenceFlow_1t317y2"> - <di:waypoint x="660" y="180" /> - <di:waypoint x="710" y="180" /> + <di:waypoint x="730" y="180" /> + <di:waypoint x="780" y="180" /> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="CallActivity_0tzazs0_di" bpmnElement="CallActivity_0tzazs0"> - <dc:Bounds x="1410" y="320" width="100" height="80" /> + <dc:Bounds x="1560" y="320" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="StartEvent_0mwlirs_di" bpmnElement="StartEvent_0mwlirs"> - <dc:Bounds x="162" y="162" width="36" height="36" /> + <dc:Bounds x="232" y="162" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="169" y="198" width="25" height="14" /> + <dc:Bounds x="239" y="198" width="25" height="14" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ScriptTask_0w34e57_di" bpmnElement="ScriptTask_0w34e57"> - <dc:Bounds x="230" y="140" width="100" height="80" /> + <dc:Bounds x="300" y="140" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_1fuwy35_di" bpmnElement="SequenceFlow_1fuwy35"> - <di:waypoint x="198" y="180" /> - <di:waypoint x="230" y="180" /> + <di:waypoint x="268" y="180" /> + <di:waypoint x="300" y="180" /> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ScriptTask_1anc3ln_di" bpmnElement="CallActivity_1vzxvna"> - <dc:Bounds x="740" y="320" width="100" height="80" /> + <dc:Bounds x="950" y="330" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ScriptTask_1xgkaqi_di" bpmnElement="CallActivity_0melx8d"> - <dc:Bounds x="740" y="460" width="100" height="80" /> + <dc:Bounds x="950" y="460" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ScriptTask_11y7ba5_di" bpmnElement="CallActivity_0otry7e"> - <dc:Bounds x="740" y="580" width="100" height="80" /> + <dc:Bounds x="950" y="580" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ScriptTask_1icyh1a_di" bpmnElement="Task_1m9qoo3"> - <dc:Bounds x="1410" y="460" width="100" height="80" /> + <dc:Bounds x="1560" y="460" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ScriptTask_0aqbm7t_di" bpmnElement="Task_00nfg5x"> - <dc:Bounds x="1210" y="320" width="100" height="80" /> + <dc:Bounds x="1360" y="320" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ScriptTask_12sydez_di" bpmnElement="ScriptTask_12sydez"> - <dc:Bounds x="860" y="140" width="100" height="80" /> + <dc:Bounds x="930" y="140" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="CallActivity_0hfiogq_di" bpmnElement="CallActivity_0hfiogq"> - <dc:Bounds x="1010" y="140" width="100" height="80" /> + <dc:Bounds x="1080" y="140" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ScriptTask_14j28c2_di" bpmnElement="ScriptTask_14j28c2"> - <dc:Bounds x="1170" y="140" width="100" height="80" /> + <dc:Bounds x="1240" y="140" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_12pvazb_di" bpmnElement="SequenceFlow_12pvazb"> - <di:waypoint x="960" y="180" /> - <di:waypoint x="1010" y="180" /> + <di:waypoint x="1030" y="180" /> + <di:waypoint x="1080" y="180" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_1inonqp_di" bpmnElement="SequenceFlow_1inonqp"> - <di:waypoint x="1110" y="180" /> - <di:waypoint x="1170" y="180" /> + <di:waypoint x="1180" y="180" /> + <di:waypoint x="1240" y="180" /> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="IntermediateThrowEvent_1bxdugq_di" bpmnElement="IntermediateThrowEvent_1bxdugq"> - <dc:Bounds x="1482" y="162" width="36" height="36" /> + <dc:Bounds x="1552" y="162" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1459" y="205" width="87" height="14" /> + <dc:Bounds x="1529" y="205" width="87" height="14" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_067xdx1_di" bpmnElement="SequenceFlow_067xdx1"> - <di:waypoint x="330" y="180" /> <di:waypoint x="400" y="180" /> + <di:waypoint x="470" y="180" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_049glzl_di" bpmnElement="SequenceFlow_049glzl"> - <di:waypoint x="1270" y="180" /> - <di:waypoint x="1320" y="180" /> + <di:waypoint x="1340" y="180" /> + <di:waypoint x="1390" y="180" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0zglfyw_di" bpmnElement="SequenceFlow_0zglfyw"> - <di:waypoint x="1230" y="140" /> - <di:waypoint x="1230" y="80" /> - <di:waypoint x="910" y="80" /> - <di:waypoint x="910" y="140" /> + <di:waypoint x="1300" y="140" /> + <di:waypoint x="1300" y="80" /> + <di:waypoint x="980" y="80" /> + <di:waypoint x="980" y="140" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0t4gmix_di" bpmnElement="SequenceFlow_0t4gmix"> - <di:waypoint x="810" y="180" /> - <di:waypoint x="860" y="180" /> + <di:waypoint x="880" y="180" /> + <di:waypoint x="930" y="180" /> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ScriptTask_1tx9eou_di" bpmnElement="Task_1xqjkqx"> - <dc:Bounds x="1320" y="140" width="100" height="80" /> + <dc:Bounds x="1390" y="140" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_16akt81_di" bpmnElement="SequenceFlow_16akt81"> - <di:waypoint x="1420" y="180" /> - <di:waypoint x="1482" y="180" /> + <di:waypoint x="1490" y="180" /> + <di:waypoint x="1552" y="180" /> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="CallActivity_0vs5jgq_di" bpmnElement="CallActivity_0vs5jgq"> - <dc:Bounds x="360" y="460" width="100" height="80" /> + <dc:Bounds x="410" y="460" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ScriptTask_12t6v71_di" bpmnElement="ScriptTask_12t6v71"> - <dc:Bounds x="490" y="460" width="100" height="80" /> + <dc:Bounds x="580" y="460" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ScriptTask_0bgvphs_di" bpmnElement="ScriptTask_0bgvphs"> - <dc:Bounds x="210" y="460" width="100" height="80" /> + <dc:Bounds x="250" y="460" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="IntermediateCatchEvent_00uke3g_di" bpmnElement="IntermediateCatchEvent_00uke3g"> - <dc:Bounds x="142" y="482" width="36" height="36" /> + <dc:Bounds x="162" y="482" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="135" y="525" width="60" height="14" /> + <dc:Bounds x="155" y="525" width="60" height="14" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_14o0fxe_di" bpmnElement="SequenceFlow_14o0fxe"> - <di:waypoint x="310" y="500" /> - <di:waypoint x="360" y="500" /> + <di:waypoint x="350" y="500" /> + <di:waypoint x="410" y="500" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0nwt0ci_di" bpmnElement="SequenceFlow_0nwt0ci"> - <di:waypoint x="460" y="500" /> - <di:waypoint x="490" y="500" /> + <di:waypoint x="510" y="500" /> + <di:waypoint x="580" y="500" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_1iawj3m_di" bpmnElement="SequenceFlow_1iawj3m"> - <di:waypoint x="178" y="500" /> - <di:waypoint x="210" y="500" /> + <di:waypoint x="198" y="500" /> + <di:waypoint x="250" y="500" /> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ScriptTask_0h3fsja_di" bpmnElement="Task_1jyj2vs"> - <dc:Bounds x="1010" y="460" width="100" height="80" /> + <dc:Bounds x="1220" y="460" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ParallelGateway_06a2n9u_di" bpmnElement="ParallelGateway_06a2n9u"> - <dc:Bounds x="905" y="475" width="50" height="50" /> + <dc:Bounds x="1105" y="475" width="50" height="50" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_1tr3i9d_di" bpmnElement="SequenceFlow_1tr3i9d"> - <di:waypoint x="955" y="500" /> - <di:waypoint x="1010" y="500" /> + <di:waypoint x="1155" y="500" /> + <di:waypoint x="1220" y="500" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0aasemn_di" bpmnElement="SequenceFlow_0aasemn"> - <di:waypoint x="840" y="620" /> - <di:waypoint x="930" y="620" /> - <di:waypoint x="930" y="525" /> + <di:waypoint x="1050" y="620" /> + <di:waypoint x="1130" y="620" /> + <di:waypoint x="1130" y="525" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_103oxyw_di" bpmnElement="SequenceFlow_103oxyw"> - <di:waypoint x="840" y="500" /> - <di:waypoint x="905" y="500" /> + <di:waypoint x="1050" y="500" /> + <di:waypoint x="1105" y="500" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_14rhmx9_di" bpmnElement="SequenceFlow_14rhmx9"> - <di:waypoint x="840" y="360" /> - <di:waypoint x="930" y="360" /> - <di:waypoint x="930" y="475" /> + <di:waypoint x="1050" y="370" /> + <di:waypoint x="1130" y="370" /> + <di:waypoint x="1130" y="475" /> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ParallelGateway_05zg916_di" bpmnElement="ParallelGateway_05zg916"> - <dc:Bounds x="635" y="475" width="50" height="50" /> + <dc:Bounds x="825" y="475" width="50" height="50" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0il5j01_di" bpmnElement="SequenceFlow_0il5j01"> - <di:waypoint x="660" y="525" /> - <di:waypoint x="660" y="620" /> - <di:waypoint x="740" y="620" /> + <di:waypoint x="850" y="525" /> + <di:waypoint x="850" y="620" /> + <di:waypoint x="950" y="620" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0euwvgf_di" bpmnElement="SequenceFlow_0euwvgf"> - <di:waypoint x="685" y="500" /> - <di:waypoint x="740" y="500" /> + <di:waypoint x="875" y="500" /> + <di:waypoint x="950" y="500" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_05250mp_di" bpmnElement="SequenceFlow_05250mp"> - <di:waypoint x="660" y="475" /> - <di:waypoint x="660" y="360" /> - <di:waypoint x="740" y="360" /> + <di:waypoint x="850" y="475" /> + <di:waypoint x="850" y="370" /> + <di:waypoint x="950" y="370" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_1h3kdce_di" bpmnElement="SequenceFlow_1h3kdce"> - <di:waypoint x="590" y="500" /> - <di:waypoint x="635" y="500" /> + <di:waypoint x="680" y="500" /> + <di:waypoint x="725" y="500" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_1tqg26p_di" bpmnElement="SequenceFlow_1tqg26p"> - <di:waypoint x="1410" y="360" /> - <di:waypoint x="1310" y="360" /> + <di:waypoint x="1560" y="360" /> + <di:waypoint x="1460" y="360" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_1tey3hz_di" bpmnElement="SequenceFlow_1tey3hz"> - <di:waypoint x="1110" y="500" /> - <di:waypoint x="1235" y="500" /> + <di:waypoint x="1320" y="500" /> + <di:waypoint x="1385" y="500" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0abqxa1_di" bpmnElement="SequenceFlow_0abqxa1"> - <di:waypoint x="1460" y="460" /> - <di:waypoint x="1460" y="400" /> + <di:waypoint x="1610" y="460" /> + <di:waypoint x="1610" y="400" /> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ExclusiveGateway_0b52m39_di" bpmnElement="ExclusiveGateway_0b52m39" isMarkerVisible="true"> - <dc:Bounds x="1235" y="475" width="50" height="50" /> + <dc:Bounds x="1385" y="475" width="50" height="50" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1218" y="463" width="85" height="14" /> + <dc:Bounds x="1367" y="535" width="86" height="14" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_126j77n_di" bpmnElement="SequenceFlow_126j77n"> - <di:waypoint x="1285" y="500" /> - <di:waypoint x="1410" y="500" /> + <di:waypoint x="1435" y="500" /> + <di:waypoint x="1560" y="500" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1339" y="482" width="17" height="14" /> + <dc:Bounds x="1489" y="482" width="17" height="14" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="EndEvent_0p0cjhl_di" bpmnElement="EndEvent_0p0cjhl"> - <dc:Bounds x="1242" y="632" width="36" height="36" /> + <dc:Bounds x="1392" y="632" width="36" height="36" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_1nrfy6i_di" bpmnElement="SequenceFlow_1nrfy6i"> - <di:waypoint x="1260" y="525" /> - <di:waypoint x="1260" y="632" /> + <di:waypoint x="1410" y="525" /> + <di:waypoint x="1410" y="632" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_1ezi1oi_di" bpmnElement="SequenceFlow_1ezi1oi"> - <di:waypoint x="1260" y="400" /> - <di:waypoint x="1260" y="475" /> + <di:waypoint x="1410" y="400" /> + <di:waypoint x="1410" y="475" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ExclusiveGateway_015qbbq_di" bpmnElement="ExclusiveGateway_015qbbq" isMarkerVisible="true"> + <dc:Bounds x="725" y="475" width="50" height="50" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0vfe8hp_di" bpmnElement="SequenceFlow_0vfe8hp"> + <di:waypoint x="775" y="500" /> + <di:waypoint x="825" y="500" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1e7iqkm_di" bpmnElement="SequenceFlow_1e7iqkm"> + <di:waypoint x="750" y="525" /> + <di:waypoint x="750" y="620" /> + <di:waypoint x="300" y="620" /> + <di:waypoint x="300" y="540" /> </bpmndi:BPMNEdge> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeallocateCoreNSSI.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeallocateCoreNSSI.bpmn index 81ed921a5f..b55b7c41f0 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeallocateCoreNSSI.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeallocateCoreNSSI.bpmn @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1v4vnwb" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.1.1"> +<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" id="Definitions_1v4vnwb" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.1.1"> <bpmn:process id="Process_02hqnsq" isExecutable="true"> <bpmn:startEvent id="StartEvent_1" name="Deallocate Core NSSI Flow"> <bpmn:outgoing>Flow_0xxq2h8</bpmn:outgoing> @@ -83,11 +83,11 @@ def dcnssi= new DoDeallocateCoreNSSI() </bpmn:scriptTask> <bpmn:exclusiveGateway id="Gateway_07ygtxz" name="Is terminateNSSI=true?" default="Flow_12nxpx6"> <bpmn:incoming>Flow_009x8vn</bpmn:incoming> - <bpmn:outgoing>Flow_1r39237</bpmn:outgoing> <bpmn:outgoing>Flow_12nxpx6</bpmn:outgoing> + <bpmn:outgoing>Flow_1r39237</bpmn:outgoing> </bpmn:exclusiveGateway> <bpmn:endEvent id="Event_1vgebg2" name="End"> - <bpmn:incoming>Flow_15rk73d</bpmn:incoming> + <bpmn:incoming>Flow_095vvrk</bpmn:incoming> </bpmn:endEvent> <bpmn:scriptTask id="Activity_1gcmlps" name=" Delete the NSSI service instance
" scriptFormat="groovy"> <bpmn:incoming>Flow_1r39237</bpmn:incoming> @@ -96,18 +96,15 @@ def dcnssi= new DoDeallocateCoreNSSI() def dcnssi= new DoDeallocateCoreNSSI() dcnssi.deleteNSSIServiceInstance(execution)</bpmn:script> </bpmn:scriptTask> - <bpmn:sequenceFlow id="Flow_1r39237" name="yes" sourceRef="Gateway_07ygtxz" targetRef="Activity_1gcmlps"> - <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{(execution.getVariable("isTerminateNSSI" ) == true)}</bpmn:conditionExpression> - </bpmn:sequenceFlow> - <bpmn:scriptTask id="Activity_0gs71qq" name="Update Service Operation Status" scriptFormat="groovy"> - <bpmn:incoming>Flow_12nxpx6</bpmn:incoming> + <bpmn:scriptTask id="Activity_0gs71qq" name="Prepare Update Operation Status" scriptFormat="groovy"> <bpmn:incoming>Flow_04hswb4</bpmn:incoming> + <bpmn:incoming>Flow_12nxpx6</bpmn:incoming> <bpmn:outgoing>Flow_15rk73d</bpmn:outgoing> <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* def dcnssi= new DoDeallocateCoreNSSI() - dcnssi.updateServiceOperationStatus(execution)</bpmn:script> + dcnssi.prepareUpdateResourceOperationStatus(execution)</bpmn:script> </bpmn:scriptTask> - <bpmn:intermediateThrowEvent id="Event_016dxue" name="Goto no terminate NSSI Subflow"> + <bpmn:intermediateThrowEvent id="Event_016dxue" name="Goto No terminate NSSI Subflow"> <bpmn:incoming>Flow_0e3yvck</bpmn:incoming> <bpmn:linkEventDefinition id="LinkEventDefinition_0l191e1" name="NoTerminateNSSISubflow" /> </bpmn:intermediateThrowEvent> @@ -125,12 +122,12 @@ def dcnssi= new DoDeallocateCoreNSSI() <bpmn:sequenceFlow id="Flow_1qwi2ka" sourceRef="Activity_0es9or8" targetRef="Activity_0mnkgd6" /> <bpmn:sequenceFlow id="Flow_0e3yvck" name="no" sourceRef="Gateway_1dqw1bg" targetRef="Event_016dxue" /> <bpmn:intermediateThrowEvent id="Event_062ulql" name="Goto Common Subflow"> - <bpmn:incoming>Flow_178myd8</bpmn:incoming> - <bpmn:incoming>Flow_1b14can</bpmn:incoming> + <bpmn:incoming>Flow_1mrr969</bpmn:incoming> + <bpmn:incoming>Flow_1gxcve5</bpmn:incoming> <bpmn:linkEventDefinition id="LinkEventDefinition_017h179" name="CommonSubflow" /> </bpmn:intermediateThrowEvent> - <bpmn:sequenceFlow id="Flow_178myd8" sourceRef="Activity_0mnkgd6" targetRef="Event_062ulql" /> - <bpmn:sequenceFlow id="Flow_1b14can" sourceRef="Activity_1kne6ot" targetRef="Event_062ulql" /> + <bpmn:sequenceFlow id="Flow_178myd8" sourceRef="Activity_0mnkgd6" targetRef="Activity_07qrjro" /> + <bpmn:sequenceFlow id="Flow_1b14can" sourceRef="Activity_1kne6ot" targetRef="Activity_1a5fd5v" /> <bpmn:intermediateCatchEvent id="Event_027jirg" name="Common Subflow"> <bpmn:outgoing>Flow_16j7pjk</bpmn:outgoing> <bpmn:linkEventDefinition id="LinkEventDefinition_1fn4t8h" name="CommonSubflow" /> @@ -139,8 +136,7 @@ def dcnssi= new DoDeallocateCoreNSSI() <bpmn:sequenceFlow id="Flow_0j8gu83" sourceRef="Activity_1mbtpe6" targetRef="Activity_0tanqh5" /> <bpmn:sequenceFlow id="Flow_009x8vn" sourceRef="Activity_0tanqh5" targetRef="Gateway_07ygtxz" /> <bpmn:sequenceFlow id="Flow_12nxpx6" name="no" sourceRef="Gateway_07ygtxz" targetRef="Activity_0gs71qq" /> - <bpmn:sequenceFlow id="Flow_04hswb4" sourceRef="Activity_1gcmlps" targetRef="Activity_0gs71qq" /> - <bpmn:sequenceFlow id="Flow_15rk73d" sourceRef="Activity_0gs71qq" targetRef="Event_1vgebg2" /> + <bpmn:sequenceFlow id="Flow_15rk73d" sourceRef="Activity_0gs71qq" targetRef="Activity_1npwfvi" /> <bpmn:scriptTask id="Activity_13qnpcn" name="Execute terminate NSSI query" scriptFormat="groovy"> <bpmn:incoming>Flow_0g84uy5</bpmn:incoming> <bpmn:outgoing>Flow_189j30m</bpmn:outgoing> @@ -150,46 +146,180 @@ def dcnssi= new DoDeallocateCoreNSSI() </bpmn:scriptTask> <bpmn:sequenceFlow id="Flow_0g84uy5" sourceRef="Activity_0u06qij" targetRef="Activity_13qnpcn" /> <bpmn:sequenceFlow id="Flow_189j30m" sourceRef="Activity_13qnpcn" targetRef="Activity_0wswwhj" /> + <bpmn:subProcess id="Activity_14l5j2f" name="Sub-process for FalloutHandler and Rollback" triggeredByEvent="true"> + <bpmn:startEvent id="Event_1blx2tk"> + <bpmn:outgoing>Flow_0z51qfz</bpmn:outgoing> + <bpmn:errorEventDefinition id="ErrorEventDefinition_06njwcg" /> + </bpmn:startEvent> + <bpmn:endEvent id="Event_1umlj38"> + <bpmn:incoming>Flow_139pcs3</bpmn:incoming> + </bpmn:endEvent> + <bpmn:scriptTask id="Activity_1hh3qh1" name="Handle Unexpected Error" scriptFormat="groovy"> + <bpmn:incoming>Flow_1vq4jz8</bpmn:incoming> + <bpmn:outgoing>Flow_139pcs3</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.common.scripts.* +ExceptionUtil ex = new ExceptionUtil() +ex.processJavaException(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="Activity_009mpgu" name="Prepare Resource Operation Status Update" scriptFormat="groovy"> + <bpmn:incoming>Flow_0z51qfz</bpmn:incoming> + <bpmn:outgoing>Flow_1cl22g1</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcnssi = new DoDeallocateCoreNSSI() +dcnssi.prepareFailedOperationStatusUpdate(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:serviceTask id="Activity_0ckr2ke" name="Update Resource Operation Status"> + <bpmn:extensionElements> + <camunda:connector> + <camunda:inputOutput> + <camunda:inputParameter name="url">${dbAdapterEndpoint}</camunda:inputParameter> + <camunda:inputParameter name="headers"> + <camunda:map> + <camunda:entry key="content-type">application/soap+xml</camunda:entry> + <camunda:entry key="Authorization">Basic YnBlbDpwYXNzd29yZDEk</camunda:entry> + </camunda:map> + </camunda:inputParameter> + <camunda:inputParameter name="payload">${updateResourceOperationStatus}</camunda:inputParameter> + <camunda:inputParameter name="method">POST</camunda:inputParameter> + <camunda:outputParameter name="NSSMF_dbResponseCode">${statusCode}</camunda:outputParameter> + <camunda:outputParameter name="NSSMF_dbResponse">${response}</camunda:outputParameter> + </camunda:inputOutput> + <camunda:connectorId>http-connector</camunda:connectorId> + </camunda:connector> + </bpmn:extensionElements> + <bpmn:incoming>Flow_1cl22g1</bpmn:incoming> + <bpmn:outgoing>Flow_1vq4jz8</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="Flow_1vq4jz8" sourceRef="Activity_0ckr2ke" targetRef="Activity_1hh3qh1" /> + <bpmn:sequenceFlow id="Flow_1cl22g1" sourceRef="Activity_009mpgu" targetRef="Activity_0ckr2ke" /> + <bpmn:sequenceFlow id="Flow_0z51qfz" sourceRef="Event_1blx2tk" targetRef="Activity_009mpgu" /> + <bpmn:sequenceFlow id="Flow_139pcs3" sourceRef="Activity_1hh3qh1" targetRef="Event_1umlj38" /> + </bpmn:subProcess> + <bpmn:serviceTask id="Activity_1npwfvi" name="Update Resource Operation Status"> + <bpmn:extensionElements> + <camunda:connector> + <camunda:inputOutput> + <camunda:inputParameter name="url">${dbAdapterEndpoint}</camunda:inputParameter> + <camunda:inputParameter name="headers"> + <camunda:map> + <camunda:entry key="content-type">application/soap+xml</camunda:entry> + <camunda:entry key="Authorization">Basic YnBlbDpwYXNzd29yZDEk</camunda:entry> + </camunda:map> + </camunda:inputParameter> + <camunda:inputParameter name="payload">${updateResourceOperationStatus}</camunda:inputParameter> + <camunda:inputParameter name="method">POST</camunda:inputParameter> + <camunda:outputParameter name="NSSMF_dbResponseCode">${statusCode}</camunda:outputParameter> + <camunda:outputParameter name="NSSMF_dbResponse">${response}</camunda:outputParameter> + </camunda:inputOutput> + <camunda:connectorId>http-connector</camunda:connectorId> + </camunda:connector> + </bpmn:extensionElements> + <bpmn:incoming>Flow_15rk73d</bpmn:incoming> + <bpmn:outgoing>Flow_095vvrk</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="Flow_095vvrk" sourceRef="Activity_1npwfvi" targetRef="Event_1vgebg2" /> + <bpmn:scriptTask id="Activity_1a5fd5v" name="Call Get Delete ServiceOrder Progress" scriptFormat="groovy"> + <bpmn:incoming>Flow_1b14can</bpmn:incoming> + <bpmn:incoming>Flow_1qej57v</bpmn:incoming> + <bpmn:outgoing>Flow_1h8q1h1</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcnssi= new DoDeallocateCoreNSSI() +dcnssi.getDeleteServiceOrderProgress(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_1h8q1h1" sourceRef="Activity_1a5fd5v" targetRef="Gateway_13cwisg" /> + <bpmn:exclusiveGateway id="Gateway_13cwisg" name="Status = processing" default="Flow_1mrr969"> + <bpmn:incoming>Flow_1h8q1h1</bpmn:incoming> + <bpmn:outgoing>Flow_1mrr969</bpmn:outgoing> + <bpmn:outgoing>Flow_1j1en2h</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:sequenceFlow id="Flow_1mrr969" name="No" sourceRef="Gateway_13cwisg" targetRef="Event_062ulql" /> + <bpmn:scriptTask id="Activity_1ym1op6" name="Time Delay" scriptFormat="groovy"> + <bpmn:incoming>Flow_1j1en2h</bpmn:incoming> + <bpmn:outgoing>Flow_1qej57v</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcnssi= new DoDeallocateCoreNSSI() +dcnssi.timeDelay(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_1j1en2h" name="Yes" sourceRef="Gateway_13cwisg" targetRef="Activity_1ym1op6"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{(execution.getVariable("deleteStatus" ) == "processing" )}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="Flow_1qej57v" sourceRef="Activity_1ym1op6" targetRef="Activity_1a5fd5v" /> + <bpmn:scriptTask id="Activity_07qrjro" name="Call Get PUT Service Instance Progress" scriptFormat="groovy"> + <bpmn:incoming>Flow_178myd8</bpmn:incoming> + <bpmn:incoming>Flow_0att74c</bpmn:incoming> + <bpmn:outgoing>Flow_0pvh1x9</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcnssi= new DoDeallocateCoreNSSI() +dcnssi.getPUTServiceInstanceProgress(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_0pvh1x9" sourceRef="Activity_07qrjro" targetRef="Gateway_1yftwt8" /> + <bpmn:sequenceFlow id="Flow_04hswb4" sourceRef="Activity_1gcmlps" targetRef="Activity_0gs71qq" /> + <bpmn:sequenceFlow id="Flow_1r39237" name="yes" sourceRef="Gateway_07ygtxz" targetRef="Activity_1gcmlps"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{(execution.getVariable("isTerminateNSSI" ) == true)}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:exclusiveGateway id="Gateway_1yftwt8" name="Status = processing" default="Flow_1gxcve5"> + <bpmn:incoming>Flow_0pvh1x9</bpmn:incoming> + <bpmn:outgoing>Flow_1gxcve5</bpmn:outgoing> + <bpmn:outgoing>Flow_0afgah7</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:sequenceFlow id="Flow_1gxcve5" name="No" sourceRef="Gateway_1yftwt8" targetRef="Event_062ulql" /> + <bpmn:scriptTask id="Activity_1lafl76" name="Time Delay" scriptFormat="groovy"> + <bpmn:incoming>Flow_0afgah7</bpmn:incoming> + <bpmn:outgoing>Flow_0att74c</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcnssi= new DoDeallocateCoreNSSI() +dcnssi.timeDelay(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_0afgah7" name="Yes" sourceRef="Gateway_1yftwt8" targetRef="Activity_1lafl76"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{(execution.getVariable("putStatus" ) == "processing" )}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="Flow_0att74c" sourceRef="Activity_1lafl76" targetRef="Activity_07qrjro" /> </bpmn:process> <bpmndi:BPMNDiagram id="BPMNDiagram_1"> <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_02hqnsq"> + <bpmndi:BPMNEdge id="Flow_189j30m_di" bpmnElement="Flow_189j30m"> + <di:waypoint x="510" y="117" /> + <di:waypoint x="580" y="117" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0g84uy5_di" bpmnElement="Flow_0g84uy5"> + <di:waypoint x="360" y="117" /> + <di:waypoint x="410" y="117" /> + </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="Flow_15rk73d_di" bpmnElement="Flow_15rk73d"> - <di:waypoint x="1220" y="600" /> - <di:waypoint x="1282" y="600" /> + <di:waypoint x="1220" y="670" /> + <di:waypoint x="1270" y="670" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="Flow_04hswb4_di" bpmnElement="Flow_04hswb4"> - <di:waypoint x="980" y="600" /> - <di:waypoint x="1120" y="600" /> + <di:waypoint x="980" y="750" /> + <di:waypoint x="1170" y="750" /> + <di:waypoint x="1170" y="710" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="Flow_12nxpx6_di" bpmnElement="Flow_12nxpx6"> - <di:waypoint x="790" y="625" /> - <di:waypoint x="790" y="680" /> - <di:waypoint x="1170" y="680" /> - <di:waypoint x="1170" y="640" /> + <di:waypoint x="795" y="670" /> + <di:waypoint x="1120" y="670" /> <bpmndi:BPMNLabel> <dc:Bounds x="814" y="663" width="13" height="14" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="Flow_009x8vn_di" bpmnElement="Flow_009x8vn"> - <di:waypoint x="680" y="600" /> - <di:waypoint x="765" y="600" /> + <di:waypoint x="670" y="670" /> + <di:waypoint x="745" y="670" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="Flow_0j8gu83_di" bpmnElement="Flow_0j8gu83"> - <di:waypoint x="510" y="600" /> - <di:waypoint x="580" y="600" /> + <di:waypoint x="510" y="670" /> + <di:waypoint x="570" y="670" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="Flow_16j7pjk_di" bpmnElement="Flow_16j7pjk"> - <di:waypoint x="208" y="600" /> - <di:waypoint x="260" y="600" /> + <di:waypoint x="215" y="670" /> + <di:waypoint x="260" y="670" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="Flow_1b14can_di" bpmnElement="Flow_1b14can"> <di:waypoint x="800" y="240" /> - <di:waypoint x="975" y="240" /> - <di:waypoint x="975" y="382" /> + <di:waypoint x="910" y="240" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="Flow_178myd8_di" bpmnElement="Flow_178myd8"> - <di:waypoint x="840" y="400" /> - <di:waypoint x="957" y="400" /> + <di:waypoint x="820" y="450" /> + <di:waypoint x="880" y="450" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="Flow_0e3yvck_di" bpmnElement="Flow_0e3yvck"> <di:waypoint x="775" y="117" /> @@ -199,20 +329,20 @@ def dcnssi= new DoDeallocateCoreNSSI() </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="Flow_1qwi2ka_di" bpmnElement="Flow_1qwi2ka"> - <di:waypoint x="680" y="400" /> - <di:waypoint x="740" y="400" /> + <di:waypoint x="680" y="450" /> + <di:waypoint x="720" y="450" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="Flow_0xrq94a_di" bpmnElement="Flow_0xrq94a"> - <di:waypoint x="510" y="400" /> - <di:waypoint x="580" y="400" /> + <di:waypoint x="510" y="450" /> + <di:waypoint x="580" y="450" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="Flow_1eev81t_di" bpmnElement="Flow_1eev81t"> - <di:waypoint x="360" y="400" /> - <di:waypoint x="410" y="400" /> + <di:waypoint x="360" y="450" /> + <di:waypoint x="410" y="450" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="Flow_1v68jns_di" bpmnElement="Flow_1v68jns"> - <di:waypoint x="208" y="400" /> - <di:waypoint x="260" y="400" /> + <di:waypoint x="215" y="450" /> + <di:waypoint x="260" y="450" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="Flow_15ew9rs_di" bpmnElement="Flow_15ew9rs"> <di:waypoint x="750" y="142" /> @@ -222,14 +352,15 @@ def dcnssi= new DoDeallocateCoreNSSI() </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="Flow_0nvtepd_di" bpmnElement="Flow_0nvtepd"> - <di:waypoint x="360" y="600" /> - <di:waypoint x="410" y="600" /> + <di:waypoint x="360" y="670" /> + <di:waypoint x="410" y="670" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="Flow_1r39237_di" bpmnElement="Flow_1r39237"> - <di:waypoint x="815" y="600" /> - <di:waypoint x="880" y="600" /> + <di:waypoint x="770" y="695" /> + <di:waypoint x="770" y="750" /> + <di:waypoint x="880" y="750" /> <bpmndi:BPMNLabel> - <dc:Bounds x="823" y="582" width="17" height="14" /> + <dc:Bounds x="772" y="701" width="17" height="14" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="Flow_16192dm_di" bpmnElement="Flow_16192dm"> @@ -240,13 +371,55 @@ def dcnssi= new DoDeallocateCoreNSSI() <di:waypoint x="215" y="117" /> <di:waypoint x="260" y="117" /> </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="Flow_0g84uy5_di" bpmnElement="Flow_0g84uy5"> - <di:waypoint x="360" y="117" /> - <di:waypoint x="410" y="117" /> + <bpmndi:BPMNEdge id="Flow_095vvrk_di" bpmnElement="Flow_095vvrk"> + <di:waypoint x="1370" y="670" /> + <di:waypoint x="1432" y="670" /> </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="Flow_189j30m_di" bpmnElement="Flow_189j30m"> - <di:waypoint x="510" y="117" /> - <di:waypoint x="580" y="117" /> + <bpmndi:BPMNEdge id="Flow_1h8q1h1_di" bpmnElement="Flow_1h8q1h1"> + <di:waypoint x="1010" y="240" /> + <di:waypoint x="1130" y="240" /> + <di:waypoint x="1130" y="325" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1mrr969_di" bpmnElement="Flow_1mrr969"> + <di:waypoint x="1130" y="375" /> + <di:waypoint x="1130" y="432" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1138" y="393" width="15" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1j1en2h_di" bpmnElement="Flow_1j1en2h"> + <di:waypoint x="1105" y="350" /> + <di:waypoint x="1010" y="350" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1026" y="352" width="18" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1qej57v_di" bpmnElement="Flow_1qej57v"> + <di:waypoint x="960" y="310" /> + <di:waypoint x="960" y="280" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0pvh1x9_di" bpmnElement="Flow_0pvh1x9"> + <di:waypoint x="980" y="450" /> + <di:waypoint x="1015" y="450" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1gxcve5_di" bpmnElement="Flow_1gxcve5"> + <di:waypoint x="1065" y="450" /> + <di:waypoint x="1112" y="450" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1083" y="432" width="15" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0afgah7_di" bpmnElement="Flow_0afgah7"> + <di:waypoint x="1040" y="475" /> + <di:waypoint x="1040" y="520" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1046" y="482" width="18" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0att74c_di" bpmnElement="Flow_0att74c"> + <di:waypoint x="990" y="560" /> + <di:waypoint x="930" y="560" /> + <di:waypoint x="930" y="490" /> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1"> <dc:Bounds x="179" y="99" width="36" height="36" /> @@ -257,83 +430,144 @@ def dcnssi= new DoDeallocateCoreNSSI() <bpmndi:BPMNShape id="Activity_0u06qij_di" bpmnElement="Activity_0u06qij"> <dc:Bounds x="260" y="77" width="100" height="80" /> </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0wswwhj_di" bpmnElement="Activity_0wswwhj"> + <dc:Bounds x="580" y="77" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Gateway_1dqw1bg_di" bpmnElement="Gateway_1dqw1bg" isMarkerVisible="true"> + <dc:Bounds x="725" y="92" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="708" y="53" width="85" height="40" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> <bpmndi:BPMNShape id="Activity_1kne6ot_di" bpmnElement="Activity_1kne6ot"> <dc:Bounds x="700" y="200" width="100" height="80" /> </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_016dxue_di" bpmnElement="Event_016dxue"> + <dc:Bounds x="832" y="99" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="821" y="140" width="74" height="40" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_13qnpcn_di" bpmnElement="Activity_13qnpcn"> + <dc:Bounds x="410" y="77" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_1mk9pgp_di" bpmnElement="Event_1mk9pgp"> + <dc:Bounds x="179" y="432" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="169" y="475" width="69" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> <bpmndi:BPMNShape id="Activity_1anr9ry_di" bpmnElement="Activity_1anr9ry"> - <dc:Bounds x="260" y="360" width="100" height="80" /> + <dc:Bounds x="260" y="410" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="Activity_16wfqhu_di" bpmnElement="Activity_16wfqhu"> - <dc:Bounds x="410" y="360" width="100" height="80" /> + <dc:Bounds x="410" y="410" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="Activity_0es9or8_di" bpmnElement="Activity_0es9or8"> - <dc:Bounds x="580" y="360" width="100" height="80" /> + <dc:Bounds x="580" y="410" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="Activity_0mnkgd6_di" bpmnElement="Activity_0mnkgd6"> - <dc:Bounds x="740" y="360" width="100" height="80" /> + <dc:Bounds x="720" y="410" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1a5fd5v_di" bpmnElement="Activity_1a5fd5v"> + <dc:Bounds x="910" y="200" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1ym1op6_di" bpmnElement="Activity_1ym1op6"> + <dc:Bounds x="910" y="310" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_07qrjro_di" bpmnElement="Activity_07qrjro"> + <dc:Bounds x="880" y="410" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_027jirg_di" bpmnElement="Event_027jirg"> + <dc:Bounds x="179" y="652" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="160" y="695" width="88" height="14" /> + </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="Activity_19z90sm_di" bpmnElement="Activity_19z90sm"> - <dc:Bounds x="260" y="560" width="100" height="80" /> + <dc:Bounds x="260" y="630" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="Activity_1mbtpe6_di" bpmnElement="Activity_1mbtpe6"> - <dc:Bounds x="410" y="560" width="100" height="80" /> + <dc:Bounds x="410" y="630" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="Activity_0tanqh5_di" bpmnElement="Activity_0tanqh5"> - <dc:Bounds x="580" y="560" width="100" height="80" /> + <dc:Bounds x="570" y="630" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="Gateway_07ygtxz_di" bpmnElement="Gateway_07ygtxz" isMarkerVisible="true"> - <dc:Bounds x="765" y="575" width="50" height="50" /> + <dc:Bounds x="745" y="645" width="50" height="50" /> <bpmndi:BPMNLabel> - <dc:Bounds x="737" y="529" width="86" height="40" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="Event_1vgebg2_di" bpmnElement="Event_1vgebg2"> - <dc:Bounds x="1282" y="582" width="36" height="36" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="1290" y="558" width="20" height="14" /> + <dc:Bounds x="717" y="599" width="86" height="40" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="Activity_1gcmlps_di" bpmnElement="Activity_1gcmlps"> - <dc:Bounds x="880" y="560" width="100" height="80" /> + <dc:Bounds x="880" y="710" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="Activity_0gs71qq_di" bpmnElement="Activity_0gs71qq"> - <dc:Bounds x="1120" y="560" width="100" height="80" /> + <dc:Bounds x="1120" y="630" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="Event_1mk9pgp_di" bpmnElement="Event_1mk9pgp"> - <dc:Bounds x="172" y="382" width="36" height="36" /> + <bpmndi:BPMNShape id="Activity_1npwfvi_di" bpmnElement="Activity_1npwfvi"> + <dc:Bounds x="1270" y="630" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_1vgebg2_di" bpmnElement="Event_1vgebg2"> + <dc:Bounds x="1432" y="652" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="162" y="425" width="69" height="27" /> + <dc:Bounds x="1440" y="698" width="20" height="14" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="Event_062ulql_di" bpmnElement="Event_062ulql"> - <dc:Bounds x="957" y="382" width="36" height="36" /> + <dc:Bounds x="1112" y="432" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="947" y="423" width="72" height="27" /> + <dc:Bounds x="1102" y="473" width="72" height="27" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="Event_027jirg_di" bpmnElement="Event_027jirg"> - <dc:Bounds x="172" y="582" width="36" height="36" /> + <bpmndi:BPMNShape id="Gateway_13cwisg_di" bpmnElement="Gateway_13cwisg" isMarkerVisible="true"> + <dc:Bounds x="1105" y="325" width="50" height="50" /> <bpmndi:BPMNLabel> - <dc:Bounds x="153" y="625" width="88" height="14" /> + <dc:Bounds x="1165" y="336" width="54" height="27" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="Activity_13qnpcn_di" bpmnElement="Activity_13qnpcn"> - <dc:Bounds x="410" y="77" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="Activity_0wswwhj_di" bpmnElement="Activity_0wswwhj"> - <dc:Bounds x="580" y="77" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="Gateway_1dqw1bg_di" bpmnElement="Gateway_1dqw1bg" isMarkerVisible="true"> - <dc:Bounds x="725" y="92" width="50" height="50" /> + <bpmndi:BPMNShape id="Gateway_1yftwt8_di" bpmnElement="Gateway_1yftwt8" isMarkerVisible="true"> + <dc:Bounds x="1015" y="425" width="50" height="50" /> <bpmndi:BPMNLabel> - <dc:Bounds x="708" y="53" width="85" height="40" /> + <dc:Bounds x="1028" y="396" width="54" height="27" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="Event_016dxue_di" bpmnElement="Event_016dxue"> - <dc:Bounds x="832" y="99" width="36" height="36" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="820" y="140" width="74" height="40" /> - </bpmndi:BPMNLabel> + <bpmndi:BPMNShape id="Activity_1lafl76_di" bpmnElement="Activity_1lafl76"> + <dc:Bounds x="990" y="520" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_14l5j2f_di" bpmnElement="Activity_14l5j2f" isExpanded="true"> + <dc:Bounds x="250" y="910" width="781" height="196" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="Flow_1vq4jz8_di" bpmnElement="Flow_1vq4jz8"> + <di:waypoint x="640" y="1014" /> + <di:waypoint x="710" y="1014" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1cl22g1_di" bpmnElement="Flow_1cl22g1"> + <di:waypoint x="480" y="1014" /> + <di:waypoint x="540" y="1014" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0z51qfz_di" bpmnElement="Flow_0z51qfz"> + <di:waypoint x="316" y="1014" /> + <di:waypoint x="380" y="1014" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_139pcs3_di" bpmnElement="Flow_139pcs3"> + <di:waypoint x="810" y="1014" /> + <di:waypoint x="918" y="1014" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="Event_1blx2tk_di" bpmnElement="Event_1blx2tk"> + <dc:Bounds x="280" y="996" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_1umlj38_di" bpmnElement="Event_1umlj38"> + <dc:Bounds x="918" y="996" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1hh3qh1_di" bpmnElement="Activity_1hh3qh1"> + <dc:Bounds x="710" y="974" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_009mpgu_di" bpmnElement="Activity_009mpgu"> + <dc:Bounds x="380" y="974" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0ckr2ke_di" bpmnElement="Activity_0ckr2ke"> + <dc:Bounds x="540" y="974" width="100" height="80" /> </bpmndi:BPMNShape> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeallocateNSSI.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeallocateNSSI.bpmn index c107cfb53a..a745f7c50d 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeallocateNSSI.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeallocateNSSI.bpmn @@ -99,10 +99,11 @@ dnssi.prepareUpdateOperationStatus(execution)</bpmn:script> <bpmn:callActivity id="Task_1x3et9h" name="Query Job Status" calledElement="QueryJobStatus"> <bpmn:extensionElements> <camunda:in source="msoRequestId" target="msoRequestId" /> - <camunda:in source="serviceInstanceId" target="serviceInstanceId" /> - <camunda:in source="serviceModelInfo" target="serviceModelInfo" /> - <camunda:out source="serviceDecomposition" target="serviceDecomposition" /> - <camunda:out source="serviceDecompositionString" target="serviceDecompositionString" /> + <camunda:in source="esrInfo" target="esrInfo" /> + <camunda:in source="serviceInfo" target="serviceInfo" /> + <camunda:in source="jobId" target="jobId" /> + <camunda:in source="responseId" target="responseId" /> + <camunda:out source="responseDescriptor" target="responseDescriptor" /> </bpmn:extensionElements> <bpmn:incoming>SequenceFlow_0w01l14</bpmn:incoming> <bpmn:outgoing>SequenceFlow_10nogqz</bpmn:outgoing> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoModifyCoreNSSI.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoModifyCoreNSSI.bpmn index 1f1fe4e735..e0c0b9a994 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoModifyCoreNSSI.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoModifyCoreNSSI.bpmn @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_1ejx57e" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.1.1"> +<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" id="Definitions_1ejx57e" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.1.1"> <bpmn:process id="Process_1nmtzzp" isExecutable="true"> <bpmn:startEvent id="Event_0fbqt56" name="Modify Core NSSI Flow"> <bpmn:outgoing>Flow_0e007rx</bpmn:outgoing> @@ -28,11 +28,11 @@ def mcnssi= new DoModifyCoreNSSI() </bpmn:scriptTask> <bpmn:sequenceFlow id="Flow_184tfp7" sourceRef="Activity_1ce41n6" targetRef="Activity_02skgkj" /> <bpmn:exclusiveGateway id="Gateway_1hadnun" name="Is Slice Profile Instance has to be created" default="Flow_03gf14v"> - <bpmn:incoming>Flow_0s31teg</bpmn:incoming> + <bpmn:incoming>Flow_1hm2xps</bpmn:incoming> <bpmn:outgoing>Flow_1pls2hu</bpmn:outgoing> <bpmn:outgoing>Flow_03gf14v</bpmn:outgoing> </bpmn:exclusiveGateway> - <bpmn:sequenceFlow id="Flow_0s31teg" sourceRef="Activity_02skgkj" targetRef="Gateway_1hadnun" /> + <bpmn:sequenceFlow id="Flow_0s31teg" sourceRef="Activity_02skgkj" targetRef="Activity_0wdaul0" /> <bpmn:intermediateThrowEvent id="Event_1243wg1" name="Goto Slice Profile Instance has to be created"> <bpmn:incoming>Flow_1pls2hu</bpmn:incoming> <bpmn:linkEventDefinition id="LinkEventDefinition_14qnw6y" name="SliceProfileInstanceHasToBeCreated" /> @@ -45,87 +45,54 @@ def mcnssi= new DoModifyCoreNSSI() <bpmn:linkEventDefinition id="LinkEventDefinition_0ecwvhj" name="SliceProfileInstanceHasToBeDeleted" /> </bpmn:intermediateThrowEvent> <bpmn:sequenceFlow id="Flow_03gf14v" name="no" sourceRef="Gateway_1hadnun" targetRef="Event_1gjhrcq" /> - <bpmn:scriptTask id="Activity_0oph5am" name="Update Service Operation Status" scriptFormat="groovy"> + <bpmn:scriptTask id="Activity_0oph5am" name="Prepare Update Operation Status" scriptFormat="groovy"> <bpmn:incoming>Flow_0l7hcnf</bpmn:incoming> <bpmn:incoming>Flow_0lrenyo</bpmn:incoming> <bpmn:outgoing>Flow_0yq24um</bpmn:outgoing> <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* -def mcnssi= new DoDeallocateCoreNSSI() - mcnssi.updateServiceOperationStatus(execution)</bpmn:script> +def mcnssi= new DoModifyCoreNSSI() + mcnssi.prepareUpdateResourceOperationStatus(execution)</bpmn:script> </bpmn:scriptTask> <bpmn:endEvent id="Event_1p0mogo" name="End"> - <bpmn:incoming>Flow_0yq24um</bpmn:incoming> + <bpmn:incoming>Flow_1yphs5r</bpmn:incoming> </bpmn:endEvent> - <bpmn:sequenceFlow id="Flow_0yq24um" sourceRef="Activity_0oph5am" targetRef="Event_1p0mogo" /> + <bpmn:sequenceFlow id="Flow_0yq24um" sourceRef="Activity_0oph5am" targetRef="Activity_0d1kk7f" /> <bpmn:intermediateCatchEvent id="Event_0z9mer1" name="Slice Profile Instance has to be created"> - <bpmn:outgoing>Flow_1xysykm</bpmn:outgoing> + <bpmn:outgoing>Flow_1twqfsc</bpmn:outgoing> <bpmn:linkEventDefinition id="LinkEventDefinition_0fbskyk" name="SliceProfileInstanceHasToBeCreated" /> </bpmn:intermediateCatchEvent> <bpmn:intermediateCatchEvent id="Event_0m2jn7c" name="Slice profile instance has to be deleted"> <bpmn:outgoing>Flow_11vf6ik</bpmn:outgoing> <bpmn:linkEventDefinition id="LinkEventDefinition_1lptuqv" name="SliceProfileInstanceHasToBeDeleted" /> </bpmn:intermediateCatchEvent> - <bpmn:scriptTask id="Activity_0ouov98" name="Calculate S-NSSAI" scriptFormat="groovy"> - <bpmn:incoming>Flow_1xysykm</bpmn:incoming> - <bpmn:outgoing>Flow_1nxaeez</bpmn:outgoing> - <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* -def mcnssi= new DoModifyCoreNSSI() - mcnssi.calculateSNSSAI(execution)</bpmn:script> - </bpmn:scriptTask> - <bpmn:sequenceFlow id="Flow_1xysykm" sourceRef="Event_0z9mer1" targetRef="Activity_0ouov98" /> - <bpmn:scriptTask id="Activity_00t4mmi" name="Invoke PUT Service Instance API" scriptFormat="groovy"> - <bpmn:incoming>Flow_1nxaeez</bpmn:incoming> - <bpmn:outgoing>Flow_0ccqmju</bpmn:outgoing> - <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* -def mcnssi= new ModifyCoreNSSI() - mcnssi.invokePUTServiceInstance(execution)</bpmn:script> - </bpmn:scriptTask> - <bpmn:sequenceFlow id="Flow_1nxaeez" sourceRef="Activity_0ouov98" targetRef="Activity_00t4mmi" /> <bpmn:scriptTask id="Activity_1q02wiz" name="Create a slice profile instance
" scriptFormat="groovy"> - <bpmn:incoming>Flow_0ccqmju</bpmn:incoming> + <bpmn:incoming>Flow_1twqfsc</bpmn:incoming> <bpmn:outgoing>Flow_1fdpbsx</bpmn:outgoing> <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* -def mcnssi= new ModifyCoreNSSI() +def mcnssi= new DoModifyCoreNSSI() mcnssi.createSliceProfileInstance(execution)</bpmn:script> </bpmn:scriptTask> - <bpmn:sequenceFlow id="Flow_0ccqmju" sourceRef="Activity_00t4mmi" targetRef="Activity_1q02wiz" /> <bpmn:scriptTask id="Activity_1josmor" name="Associate slice profile instance the same with the NSSI
" scriptFormat="groovy"> <bpmn:incoming>Flow_1fdpbsx</bpmn:incoming> <bpmn:outgoing>Flow_0l7hcnf</bpmn:outgoing> <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* -def mcnssi= new ModifyCoreNSSI() +def mcnssi= new DoModifyCoreNSSI() mcnssi.associateSliceProfileInstanceWithNSSI(execution)</bpmn:script> </bpmn:scriptTask> <bpmn:sequenceFlow id="Flow_1fdpbsx" sourceRef="Activity_1q02wiz" targetRef="Activity_1josmor" /> - <bpmn:scriptTask id="Activity_0j4c22q" name="Calculate S-NSSAI" scriptFormat="groovy"> - <bpmn:incoming>Flow_11vf6ik</bpmn:incoming> - <bpmn:outgoing>Flow_1oeokwy</bpmn:outgoing> - <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* -def mcnssi= new DoModifyCoreNSSI() - mcnssi.calculateSNSSAI(execution)</bpmn:script> - </bpmn:scriptTask> - <bpmn:sequenceFlow id="Flow_11vf6ik" sourceRef="Event_0m2jn7c" targetRef="Activity_0j4c22q" /> - <bpmn:scriptTask id="Activity_0c4wmiz" name="Invoke PUT Service Instance API" scriptFormat="groovy"> - <bpmn:incoming>Flow_1oeokwy</bpmn:incoming> - <bpmn:outgoing>Flow_15fi92t</bpmn:outgoing> - <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* -def mcnssi= new ModifyCoreNSSI() - mcnssi.invokePUTServiceInstance(execution)</bpmn:script> - </bpmn:scriptTask> - <bpmn:sequenceFlow id="Flow_1oeokwy" sourceRef="Activity_0j4c22q" targetRef="Activity_0c4wmiz" /> + <bpmn:sequenceFlow id="Flow_11vf6ik" sourceRef="Event_0m2jn7c" targetRef="Activity_1iegufd" /> <bpmn:scriptTask id="Activity_1iegufd" name="Remove the NSSI to slice instance association
" scriptFormat="groovy"> - <bpmn:incoming>Flow_15fi92t</bpmn:incoming> + <bpmn:incoming>Flow_11vf6ik</bpmn:incoming> <bpmn:outgoing>Flow_1wtv1zj</bpmn:outgoing> <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* -def mcnssi= new ModifyCoreNSSI() +def mcnssi= new DoModifyCoreNSSI() mcnssi.removeSPAssociationWithNSSI(execution)</bpmn:script> </bpmn:scriptTask> - <bpmn:sequenceFlow id="Flow_15fi92t" sourceRef="Activity_0c4wmiz" targetRef="Activity_1iegufd" /> <bpmn:scriptTask id="Activity_010nkjp" name="Delete the slice profile instance
" scriptFormat="groovy"> <bpmn:incoming>Flow_1wtv1zj</bpmn:incoming> <bpmn:outgoing>Flow_0lrenyo</bpmn:outgoing> <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* -def mcnssi= new ModifyCoreNSSI() +def mcnssi= new DoModifyCoreNSSI() mcnssi.deleteSliceProfileInstance(execution)</bpmn:script> </bpmn:scriptTask> <bpmn:sequenceFlow id="Flow_1wtv1zj" sourceRef="Activity_1iegufd" targetRef="Activity_010nkjp" /> @@ -140,90 +107,223 @@ def mcnssi= new ModifyCoreNSSI() </bpmn:scriptTask> <bpmn:sequenceFlow id="Flow_0e007rx" sourceRef="Event_0fbqt56" targetRef="Activity_0klj7y1" /> <bpmn:sequenceFlow id="Flow_06j2avj" sourceRef="Activity_0klj7y1" targetRef="Activity_0tf735w" /> + <bpmn:subProcess id="Activity_1u4xfuz" name="Sub-process for FalloutHandler and Rollback" triggeredByEvent="true"> + <bpmn:startEvent id="Event_0xhp6c7"> + <bpmn:outgoing>Flow_1i9kph3</bpmn:outgoing> + <bpmn:errorEventDefinition id="ErrorEventDefinition_0auvylm" /> + </bpmn:startEvent> + <bpmn:endEvent id="Event_05xctbx"> + <bpmn:incoming>Flow_00tfsrn</bpmn:incoming> + </bpmn:endEvent> + <bpmn:scriptTask id="Activity_0opij79" name="Handle Unexpected Error" scriptFormat="groovy"> + <bpmn:incoming>Flow_07ftouz</bpmn:incoming> + <bpmn:outgoing>Flow_00tfsrn</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.common.scripts.* +ExceptionUtil ex = new ExceptionUtil() +ex.processJavaException(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="Activity_099prfj" name="Prepare Resource Operation Status Update" scriptFormat="groovy"> + <bpmn:incoming>Flow_1i9kph3</bpmn:incoming> + <bpmn:outgoing>Flow_14kgrjc</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def mcnssi = new DoModifyCoreNSSI() +mcnssi.prepareFailedOperationStatusUpdate(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:serviceTask id="Activity_1feavwd" name="Update Resource Operation Status"> + <bpmn:extensionElements> + <camunda:connector> + <camunda:inputOutput> + <camunda:inputParameter name="url">${dbAdapterEndpoint}</camunda:inputParameter> + <camunda:inputParameter name="headers"> + <camunda:map> + <camunda:entry key="content-type">application/soap+xml</camunda:entry> + <camunda:entry key="Authorization">Basic YnBlbDpwYXNzd29yZDEk</camunda:entry> + </camunda:map> + </camunda:inputParameter> + <camunda:inputParameter name="payload">${updateResourceOperationStatus}</camunda:inputParameter> + <camunda:inputParameter name="method">POST</camunda:inputParameter> + <camunda:outputParameter name="NSSMF_dbResponseCode">${statusCode}</camunda:outputParameter> + <camunda:outputParameter name="NSSMF_dbResponse">${response}</camunda:outputParameter> + </camunda:inputOutput> + <camunda:connectorId>http-connector</camunda:connectorId> + </camunda:connector> + </bpmn:extensionElements> + <bpmn:incoming>Flow_14kgrjc</bpmn:incoming> + <bpmn:outgoing>Flow_07ftouz</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="Flow_07ftouz" sourceRef="Activity_1feavwd" targetRef="Activity_0opij79" /> + <bpmn:sequenceFlow id="Flow_14kgrjc" sourceRef="Activity_099prfj" targetRef="Activity_1feavwd" /> + <bpmn:sequenceFlow id="Flow_1i9kph3" sourceRef="Event_0xhp6c7" targetRef="Activity_099prfj" /> + <bpmn:sequenceFlow id="Flow_00tfsrn" sourceRef="Activity_0opij79" targetRef="Event_05xctbx" /> + </bpmn:subProcess> + <bpmn:serviceTask id="Activity_0d1kk7f" name="Update Resource Operation Status"> + <bpmn:extensionElements> + <camunda:connector> + <camunda:inputOutput> + <camunda:inputParameter name="url">${dbAdapterEndpoint}</camunda:inputParameter> + <camunda:inputParameter name="headers"> + <camunda:map> + <camunda:entry key="content-type">application/soap+xml</camunda:entry> + <camunda:entry key="Authorization">Basic YnBlbDpwYXNzd29yZDEk</camunda:entry> + </camunda:map> + </camunda:inputParameter> + <camunda:inputParameter name="payload">${updateResourceOperationStatus}</camunda:inputParameter> + <camunda:inputParameter name="method">POST</camunda:inputParameter> + <camunda:outputParameter name="NSSMF_dbResponseCode">${statusCode}</camunda:outputParameter> + <camunda:outputParameter name="NSSMF_dbResponse">${response}</camunda:outputParameter> + </camunda:inputOutput> + <camunda:connectorId>http-connector</camunda:connectorId> + </camunda:connector> + </bpmn:extensionElements> + <bpmn:incoming>Flow_0yq24um</bpmn:incoming> + <bpmn:outgoing>Flow_1yphs5r</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="Flow_1yphs5r" sourceRef="Activity_0d1kk7f" targetRef="Event_1p0mogo" /> + <bpmn:scriptTask id="Activity_0wdaul0" name="Calculate S-NSSAI" scriptFormat="groovy"> + <bpmn:incoming>Flow_0s31teg</bpmn:incoming> + <bpmn:outgoing>Flow_0fj4doc</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def mcnssi= new DoModifyCoreNSSI() + mcnssi.calculateSNSSAI(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_0fj4doc" sourceRef="Activity_0wdaul0" targetRef="Activity_0rvt126" /> + <bpmn:scriptTask id="Activity_0rvt126" name="Invoke PUT Service Instance API" scriptFormat="groovy"> + <bpmn:incoming>Flow_0fj4doc</bpmn:incoming> + <bpmn:outgoing>Flow_1y0m22h</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def mcnssi= new DoModifyCoreNSSI() + mcnssi.invokePUTServiceInstance(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_1y0m22h" sourceRef="Activity_0rvt126" targetRef="Activity_1gojm1c" /> + <bpmn:scriptTask id="Activity_1gojm1c" name="Call Get PUT Service Instance Progress" scriptFormat="groovy"> + <bpmn:incoming>Flow_1y0m22h</bpmn:incoming> + <bpmn:incoming>Flow_1jm7045</bpmn:incoming> + <bpmn:outgoing>Flow_0nxwq7b</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def mcnssi= new DoModifyCoreNSSI() +mcnssi.getPUTServiceInstanceProgress(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:exclusiveGateway id="Gateway_13w96z9" name="Status = processing" default="Flow_1hm2xps"> + <bpmn:incoming>Flow_0nxwq7b</bpmn:incoming> + <bpmn:outgoing>Flow_1hm2xps</bpmn:outgoing> + <bpmn:outgoing>Flow_06or8oz</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:sequenceFlow id="Flow_0nxwq7b" sourceRef="Activity_1gojm1c" targetRef="Gateway_13w96z9" /> + <bpmn:sequenceFlow id="Flow_1hm2xps" name="No" sourceRef="Gateway_13w96z9" targetRef="Gateway_1hadnun" /> + <bpmn:scriptTask id="Activity_15kjs2a" name="Time Delay" scriptFormat="groovy"> + <bpmn:incoming>Flow_06or8oz</bpmn:incoming> + <bpmn:outgoing>Flow_1jm7045</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def mcnssi= new DoModifyCoreNSSI() +mcnssi.timeDelay(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_1jm7045" sourceRef="Activity_15kjs2a" targetRef="Activity_1gojm1c" /> + <bpmn:sequenceFlow id="Flow_06or8oz" name="Yes" sourceRef="Gateway_13w96z9" targetRef="Activity_15kjs2a"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{(execution.getVariable("putStatus" ) == "processing" )}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="Flow_1twqfsc" sourceRef="Event_0z9mer1" targetRef="Activity_1q02wiz" /> </bpmn:process> <bpmndi:BPMNDiagram id="BPMNDiagram_1"> <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1nmtzzp"> <bpmndi:BPMNEdge id="Flow_06j2avj_di" bpmnElement="Flow_06j2avj"> - <di:waypoint x="380" y="150" /> - <di:waypoint x="440" y="150" /> + <di:waypoint x="360" y="150" /> + <di:waypoint x="400" y="150" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="Flow_0e007rx_di" bpmnElement="Flow_0e007rx"> <di:waypoint x="218" y="150" /> - <di:waypoint x="280" y="150" /> + <di:waypoint x="260" y="150" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="Flow_0lrenyo_di" bpmnElement="Flow_0lrenyo"> - <di:waypoint x="890" y="600" /> - <di:waypoint x="930" y="600" /> - <di:waypoint x="930" y="540" /> - <di:waypoint x="970" y="540" /> + <di:waypoint x="540" y="570" /> + <di:waypoint x="540" y="530" /> + <di:waypoint x="660" y="530" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="Flow_0l7hcnf_di" bpmnElement="Flow_0l7hcnf"> - <di:waypoint x="890" y="430" /> - <di:waypoint x="930" y="430" /> - <di:waypoint x="930" y="500" /> - <di:waypoint x="970" y="500" /> + <di:waypoint x="530" y="470" /> + <di:waypoint x="530" y="490" /> + <di:waypoint x="660" y="490" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="Flow_1wtv1zj_di" bpmnElement="Flow_1wtv1zj"> - <di:waypoint x="730" y="600" /> - <di:waypoint x="790" y="600" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="Flow_15fi92t_di" bpmnElement="Flow_15fi92t"> - <di:waypoint x="560" y="600" /> - <di:waypoint x="630" y="600" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="Flow_1oeokwy_di" bpmnElement="Flow_1oeokwy"> - <di:waypoint x="380" y="600" /> - <di:waypoint x="460" y="600" /> + <di:waypoint x="430" y="610" /> + <di:waypoint x="490" y="610" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="Flow_11vf6ik_di" bpmnElement="Flow_11vf6ik"> - <di:waypoint x="218" y="600" /> - <di:waypoint x="280" y="600" /> + <di:waypoint x="248" y="610" /> + <di:waypoint x="330" y="610" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="Flow_1fdpbsx_di" bpmnElement="Flow_1fdpbsx"> - <di:waypoint x="730" y="430" /> - <di:waypoint x="790" y="430" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="Flow_0ccqmju_di" bpmnElement="Flow_0ccqmju"> - <di:waypoint x="560" y="430" /> - <di:waypoint x="630" y="430" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="Flow_1nxaeez_di" bpmnElement="Flow_1nxaeez"> - <di:waypoint x="390" y="430" /> - <di:waypoint x="460" y="430" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="Flow_1xysykm_di" bpmnElement="Flow_1xysykm"> - <di:waypoint x="218" y="430" /> - <di:waypoint x="290" y="430" /> + <di:waypoint x="430" y="430" /> + <di:waypoint x="480" y="430" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="Flow_0yq24um_di" bpmnElement="Flow_0yq24um"> - <di:waypoint x="1070" y="520" /> - <di:waypoint x="1132" y="520" /> + <di:waypoint x="760" y="510" /> + <di:waypoint x="820" y="510" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="Flow_03gf14v_di" bpmnElement="Flow_03gf14v"> - <di:waypoint x="1010" y="175" /> - <di:waypoint x="1010" y="252" /> + <di:waypoint x="1430" y="235" /> + <di:waypoint x="1430" y="282" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1019" y="190" width="13" height="14" /> + <dc:Bounds x="1439" y="254" width="13" height="14" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="Flow_1pls2hu_di" bpmnElement="Flow_1pls2hu"> - <di:waypoint x="1035" y="150" /> - <di:waypoint x="1132" y="150" /> + <di:waypoint x="1455" y="210" /> + <di:waypoint x="1622" y="210" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1049" y="132" width="17" height="14" /> + <dc:Bounds x="1458" y="182" width="17" height="14" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="Flow_0s31teg_di" bpmnElement="Flow_0s31teg"> - <di:waypoint x="910" y="150" /> - <di:waypoint x="985" y="150" /> + <di:waypoint x="780" y="150" /> + <di:waypoint x="810" y="150" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="Flow_184tfp7_di" bpmnElement="Flow_184tfp7"> - <di:waypoint x="720" y="150" /> - <di:waypoint x="810" y="150" /> + <di:waypoint x="640" y="150" /> + <di:waypoint x="680" y="150" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="Flow_1mqjtfk_di" bpmnElement="Flow_1mqjtfk"> + <di:waypoint x="500" y="150" /> <di:waypoint x="540" y="150" /> - <di:waypoint x="620" y="150" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1yphs5r_di" bpmnElement="Flow_1yphs5r"> + <di:waypoint x="920" y="510" /> + <di:waypoint x="962" y="510" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0fj4doc_di" bpmnElement="Flow_0fj4doc"> + <di:waypoint x="910" y="150" /> + <di:waypoint x="940" y="150" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1y0m22h_di" bpmnElement="Flow_1y0m22h"> + <di:waypoint x="1040" y="150" /> + <di:waypoint x="1070" y="150" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0nxwq7b_di" bpmnElement="Flow_0nxwq7b"> + <di:waypoint x="1170" y="150" /> + <di:waypoint x="1215" y="150" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1hm2xps_di" bpmnElement="Flow_1hm2xps"> + <di:waypoint x="1265" y="150" /> + <di:waypoint x="1430" y="150" /> + <di:waypoint x="1430" y="185" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1273" y="130" width="15" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1jm7045_di" bpmnElement="Flow_1jm7045"> + <di:waypoint x="1120" y="240" /> + <di:waypoint x="1120" y="190" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_06or8oz_di" bpmnElement="Flow_06or8oz"> + <di:waypoint x="1240" y="175" /> + <di:waypoint x="1240" y="280" /> + <di:waypoint x="1170" y="280" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1246" y="225" width="18" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1twqfsc_di" bpmnElement="Flow_1twqfsc"> + <di:waypoint x="248" y="430" /> + <di:waypoint x="330" y="430" /> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="Event_0fbqt56_di" bpmnElement="Event_0fbqt56"> <dc:Bounds x="182" y="132" width="36" height="36" /> @@ -231,80 +331,123 @@ def mcnssi= new ModifyCoreNSSI() <dc:Bounds x="158" y="175" width="89" height="27" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0klj7y1_di" bpmnElement="Activity_0klj7y1"> + <dc:Bounds x="260" y="110" width="100" height="80" /> + </bpmndi:BPMNShape> <bpmndi:BPMNShape id="Activity_0tf735w_di" bpmnElement="Activity_0tf735w"> - <dc:Bounds x="440" y="110" width="100" height="80" /> + <dc:Bounds x="400" y="110" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="Activity_1ce41n6_di" bpmnElement="Activity_1ce41n6"> - <dc:Bounds x="620" y="110" width="100" height="80" /> + <dc:Bounds x="540" y="110" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="Activity_02skgkj_di" bpmnElement="Activity_02skgkj"> + <dc:Bounds x="680" y="110" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0wdaul0_di" bpmnElement="Activity_0wdaul0"> <dc:Bounds x="810" y="110" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="Gateway_1hadnun_di" bpmnElement="Gateway_1hadnun" isMarkerVisible="true"> - <dc:Bounds x="985" y="125" width="50" height="50" /> + <bpmndi:BPMNShape id="Activity_0rvt126_di" bpmnElement="Activity_0rvt126"> + <dc:Bounds x="940" y="110" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1gojm1c_di" bpmnElement="Activity_1gojm1c"> + <dc:Bounds x="1070" y="110" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Gateway_13w96z9_di" bpmnElement="Gateway_13w96z9" isMarkerVisible="true"> + <dc:Bounds x="1215" y="125" width="50" height="50" /> <bpmndi:BPMNLabel> - <dc:Bounds x="974" y="86" width="75" height="40" /> + <dc:Bounds x="1213" y="87" width="54" height="27" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="Event_1243wg1_di" bpmnElement="Event_1243wg1"> - <dc:Bounds x="1132" y="132" width="36" height="36" /> + <dc:Bounds x="1622" y="192" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1113" y="173" width="90" height="40" /> + <dc:Bounds x="1603" y="233" width="90" height="40" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="Event_1gjhrcq_di" bpmnElement="Event_1gjhrcq"> - <dc:Bounds x="992" y="252" width="36" height="36" /> + <bpmndi:BPMNShape id="Gateway_1hadnun_di" bpmnElement="Gateway_1hadnun" isMarkerVisible="true"> + <dc:Bounds x="1405" y="185" width="50" height="50" /> <bpmndi:BPMNLabel> - <dc:Bounds x="973" y="293" width="90" height="40" /> + <dc:Bounds x="1305" y="190" width="90" height="40" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="Activity_0oph5am_di" bpmnElement="Activity_0oph5am"> - <dc:Bounds x="970" y="480" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="Event_1p0mogo_di" bpmnElement="Event_1p0mogo"> - <dc:Bounds x="1132" y="502" width="36" height="36" /> + <bpmndi:BPMNShape id="Event_1gjhrcq_di" bpmnElement="Event_1gjhrcq"> + <dc:Bounds x="1412" y="282" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1140" y="478" width="20" height="14" /> + <dc:Bounds x="1393" y="323" width="90" height="40" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_15kjs2a_di" bpmnElement="Activity_15kjs2a"> + <dc:Bounds x="1070" y="240" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1q02wiz_di" bpmnElement="Activity_1q02wiz"> + <dc:Bounds x="330" y="390" width="100" height="80" /> + </bpmndi:BPMNShape> <bpmndi:BPMNShape id="Event_0z9mer1_di" bpmnElement="Event_0z9mer1"> - <dc:Bounds x="182" y="412" width="36" height="36" /> + <dc:Bounds x="212" y="412" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="162" y="455" width="90" height="40" /> + <dc:Bounds x="192" y="455" width="90" height="40" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0oph5am_di" bpmnElement="Activity_0oph5am"> + <dc:Bounds x="660" y="470" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1iegufd_di" bpmnElement="Activity_1iegufd"> + <dc:Bounds x="330" y="570" width="100" height="80" /> + </bpmndi:BPMNShape> <bpmndi:BPMNShape id="Event_0m2jn7c_di" bpmnElement="Event_0m2jn7c"> - <dc:Bounds x="182" y="582" width="36" height="36" /> + <dc:Bounds x="212" y="592" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="155" y="625" width="90" height="40" /> + <dc:Bounds x="185" y="635" width="90" height="40" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="Activity_0ouov98_di" bpmnElement="Activity_0ouov98"> - <dc:Bounds x="290" y="390" width="100" height="80" /> + <bpmndi:BPMNShape id="Activity_010nkjp_di" bpmnElement="Activity_010nkjp"> + <dc:Bounds x="490" y="570" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="Activity_00t4mmi_di" bpmnElement="Activity_00t4mmi"> - <dc:Bounds x="460" y="390" width="100" height="80" /> + <bpmndi:BPMNShape id="Activity_1josmor_di" bpmnElement="Activity_1josmor"> + <dc:Bounds x="480" y="390" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="Activity_1q02wiz_di" bpmnElement="Activity_1q02wiz"> - <dc:Bounds x="630" y="390" width="100" height="80" /> + <bpmndi:BPMNShape id="Activity_0d1kk7f_di" bpmnElement="Activity_0d1kk7f"> + <dc:Bounds x="820" y="470" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="Activity_1josmor_di" bpmnElement="Activity_1josmor"> - <dc:Bounds x="790" y="390" width="100" height="80" /> + <bpmndi:BPMNShape id="Event_1p0mogo_di" bpmnElement="Event_1p0mogo"> + <dc:Bounds x="962" y="492" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="970" y="538" width="20" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1u4xfuz_di" bpmnElement="Activity_1u4xfuz" isExpanded="true"> + <dc:Bounds x="190" y="790" width="781" height="196" /> </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="Activity_0j4c22q_di" bpmnElement="Activity_0j4c22q"> - <dc:Bounds x="280" y="560" width="100" height="80" /> + <bpmndi:BPMNEdge id="Flow_07ftouz_di" bpmnElement="Flow_07ftouz"> + <di:waypoint x="580" y="894" /> + <di:waypoint x="650" y="894" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_14kgrjc_di" bpmnElement="Flow_14kgrjc"> + <di:waypoint x="420" y="894" /> + <di:waypoint x="480" y="894" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1i9kph3_di" bpmnElement="Flow_1i9kph3"> + <di:waypoint x="256" y="894" /> + <di:waypoint x="320" y="894" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_00tfsrn_di" bpmnElement="Flow_00tfsrn"> + <di:waypoint x="750" y="894" /> + <di:waypoint x="858" y="894" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="Event_0xhp6c7_di" bpmnElement="Event_0xhp6c7"> + <dc:Bounds x="220" y="876" width="36" height="36" /> </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="Activity_0c4wmiz_di" bpmnElement="Activity_0c4wmiz"> - <dc:Bounds x="460" y="560" width="100" height="80" /> + <bpmndi:BPMNShape id="Event_05xctbx_di" bpmnElement="Event_05xctbx"> + <dc:Bounds x="858" y="876" width="36" height="36" /> </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="Activity_1iegufd_di" bpmnElement="Activity_1iegufd"> - <dc:Bounds x="630" y="560" width="100" height="80" /> + <bpmndi:BPMNShape id="Activity_0opij79_di" bpmnElement="Activity_0opij79"> + <dc:Bounds x="650" y="854" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="Activity_010nkjp_di" bpmnElement="Activity_010nkjp"> - <dc:Bounds x="790" y="560" width="100" height="80" /> + <bpmndi:BPMNShape id="Activity_099prfj_di" bpmnElement="Activity_099prfj"> + <dc:Bounds x="320" y="854" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="Activity_0klj7y1_di" bpmnElement="Activity_0klj7y1"> - <dc:Bounds x="280" y="110" width="100" height="80" /> + <bpmndi:BPMNShape id="Activity_1feavwd_di" bpmnElement="Activity_1feavwd"> + <dc:Bounds x="480" y="854" width="100" height="80" /> </bpmndi:BPMNShape> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java index 5425b2a725..f0898ace81 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java @@ -75,6 +75,7 @@ public class WorkflowActionBBTasks { private static final String COMPLETED = "completed"; private static final String HANDLINGCODE = "handlingCode"; private static final String ROLLBACKTOCREATED = "RollbackToCreated"; + private static final String ROLLBACKTOCREATEDNOCONFIGURATION = "RollbackToCreatedNoConfiguration"; private static final String REPLACEINSTANCE = "replaceInstance"; private static final String VFMODULE = "VfModule"; protected String maxRetries = "mso.rainyDay.maxRetries"; @@ -334,14 +335,19 @@ public class WorkflowActionBBTasks { String handlingCode = (String) execution.getVariable(HANDLINGCODE); List<ExecuteBuildingBlock> rollbackFlowsFiltered = new ArrayList<>(rollbackFlows); - if ("RollbackToAssigned".equals(handlingCode) || ROLLBACKTOCREATED.equals(handlingCode)) { + if ("RollbackToAssigned".equals(handlingCode) || ROLLBACKTOCREATED.equals(handlingCode) + || ROLLBACKTOCREATEDNOCONFIGURATION.equals(handlingCode)) { for (ExecuteBuildingBlock rollbackFlow : rollbackFlows) { if (rollbackFlow.getBuildingBlock().getBpmnFlowName().contains("Unassign") && !rollbackFlow.getBuildingBlock().getBpmnFlowName().contains("FabricConfiguration")) { rollbackFlowsFiltered.remove(rollbackFlow); } else if (rollbackFlow.getBuildingBlock().getBpmnFlowName().contains("Delete") - && !rollbackFlow.getBuildingBlock().getBpmnFlowName().contains("FabricConfiguration") - && ROLLBACKTOCREATED.equals(handlingCode)) { + && ((!rollbackFlow.getBuildingBlock().getBpmnFlowName().contains("FabricConfiguration") + && (ROLLBACKTOCREATED.equals(handlingCode) + || ROLLBACKTOCREATEDNOCONFIGURATION.equals(handlingCode))) + || (rollbackFlow.getBuildingBlock().getBpmnFlowName() + .contains("FabricConfiguration") + && ROLLBACKTOCREATEDNOCONFIGURATION.equals(handlingCode)))) { rollbackFlowsFiltered.remove(rollbackFlow); } } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java index a7ee89f073..3290bb3dce 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java @@ -436,6 +436,40 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest { } @Test + public void rollbackExecutionRollbackToCreatedNoConfigurationWithFabricTest() { + execution.setVariable("isRollback", false); + execution.setVariable("handlingCode", "RollbackToCreatedNoConfiguration"); + execution.setVariable("requestAction", EMPTY_STRING); + execution.setVariable("resourceName", EMPTY_STRING); + List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>(); + + BuildingBlock buildingBlock1 = new BuildingBlock().setBpmnFlowName("AssignVfModuleBB"); + ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock1); + flowsToExecute.add(ebb1); + + BuildingBlock buildingBlock2 = new BuildingBlock().setBpmnFlowName("CreateVfModuleBB"); + ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock2); + flowsToExecute.add(ebb2); + + BuildingBlock buildingBlock3 = new BuildingBlock().setBpmnFlowName("ActivateVfModuleBB"); + ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock3); + flowsToExecute.add(ebb3); + + BuildingBlock buildingBlock4 = new BuildingBlock().setBpmnFlowName("AddFabricConfigurationBB"); + ExecuteBuildingBlock ebb4 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock4); + flowsToExecute.add(ebb4); + + execution.setVariable("flowsToExecute", flowsToExecute); + execution.setVariable("gCurrentSequence", 4); + + workflowActionBBTasks.rollbackExecutionPath(execution); + List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute"); + assertEquals(0, execution.getVariable("gCurrentSequence")); + assertEquals(1, ebbs.size()); + assertEquals("DeactivateVfModuleBB", ebbs.get(0).getBuildingBlock().getBpmnFlowName()); + } + + @Test public void rollbackExecutionRollbackToCreatedTest() { execution.setVariable("isRollback", false); execution.setVariable("handlingCode", "RollbackToCreated"); |