diff options
author | xg353y <xg353y@intl.att.com> | 2017-04-11 13:30:42 +0200 |
---|---|---|
committer | xg353y <xg353y@intl.att.com> | 2017-04-11 15:34:19 +0200 |
commit | b6b7bef8bdcad15af01ac88a038dd763ce59f68f (patch) | |
tree | 399d39da23aaa37701e487df064e3e0c27709ef3 /bpmn/MSOCommonBPMN/src | |
parent | 19340cad94eeaa1b580f7c0c99531de499e8ca14 (diff) |
[MSO-8] Update the maven dependency
Update the maven depenency for sdc-distribution-client to cooperate with the sdc changes.
Change-Id: I2da936e5c40cb68c7181bb78307192dd5655b5dc
Signed-off-by: xg353y <xg353y@intl.att.com>
Diffstat (limited to 'bpmn/MSOCommonBPMN/src')
213 files changed, 42467 insertions, 0 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/AaiUtil.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/AaiUtil.groovy new file mode 100644 index 0000000000..01e25a5741 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/AaiUtil.groovy @@ -0,0 +1,483 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common.scripts +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.runtime.Execution +import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor; +import org.openecomp.mso.rest.APIResponse; +import org.openecomp.mso.rest.RESTClient +import org.openecomp.mso.rest.RESTConfig + +class AaiUtil { + + public MsoUtils utils = new MsoUtils() + public static final String AAI_NAMESPACE_STRING = 'http://org.openecomp.aai.inventory/' + public static final String DEFAULT_VERSION_KEY = 'URN_mso_workflow_global_default_aai_version' + + private AbstractServiceTaskProcessor taskProcessor + + public AaiUtil(AbstractServiceTaskProcessor taskProcessor) { + this.taskProcessor = taskProcessor + } + + public String getNetworkGenericVnfEndpoint(Execution execution) { + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + String endpoint = execution.getVariable("URN_aai_endpoint") + def uri = getNetworkGenericVnfUri(execution) + taskProcessor.logDebug('AaiUtil.getNetworkGenericVnfEndpoint() - AAI endpoint: ' + endpoint + uri, isDebugLogEnabled) + return endpoint + uri + } + + public String getNetworkGenericVnfUri(Execution execution) { + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + def uri = getUri(execution, 'generic_vnf') + taskProcessor.logDebug('AaiUtil.getNetworkGenericVnfUri() - AAI URI: ' + uri, isDebugLogEnabled) + return uri + } + + public String getNetworkVpnBindingUri(Execution execution) { + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + def uri = getUri(execution, 'vpn_binding') + taskProcessor.logDebug('AaiUtil.getNetworkVpnBindingUri() - AAI URI: ' + uri, isDebugLogEnabled) + return uri + } + + public String getNetworkPolicyUri(Execution execution) { + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + def uri = getUri(execution, 'network_policy') + taskProcessor.logDebug('AaiUtil.getNetworkPolicyUri() - AAI URI: ' + uri, isDebugLogEnabled) + return uri + } + + public String getNetworkTableReferencesUri(Execution execution) { + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + def uri = getUri(execution, 'route_table_reference') + taskProcessor.logDebug('AaiUtil.getNetworkTableReferencesUri() - AAI URI: ' + uri, isDebugLogEnabled) + return uri + } + + public String getNetworkVceUri(Execution execution) { + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + def uri = getUri(execution, 'vce') + taskProcessor.logDebug('AaiUtil.getNetworkVceUri() - AAI URI: ' + uri, isDebugLogEnabled) + return uri + } + + public String getNetworkL3NetworkUri(Execution execution) { + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + def uri = getUri(execution, 'l3_network') + taskProcessor.logDebug('AaiUtil.getNetworkL3NetworkUri() - AAI URI: ' + uri, isDebugLogEnabled) + return uri + } + + public String getBusinessCustomerUri(Execution execution) { + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + def uri = getUri(execution, 'customer') + taskProcessor.logDebug('AaiUtil.getBusinessCustomerUri() - AAI URI: ' + uri, isDebugLogEnabled) + return uri + } + + //public String getBusinessCustomerUriv7(Execution execution) { + // def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + // //def uri = getUri(execution, BUSINESS_CUSTOMERV7) + // def uri = getUri(execution, 'Customer') + // taskProcessor.logDebug('AaiUtil.getBusinessCustomerUriv7() - AAI URI: ' + uri, isDebugLogEnabled) + // return uri + //} + + public String getCloudInfrastructureCloudRegionEndpoint(Execution execution) { + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + String endpoint = execution.getVariable("URN_aai_endpoint") + def uri = getCloudInfrastructureCloudRegionUri(execution) + taskProcessor.logDebug('AaiUtil.getCloudInfrastructureCloudRegionEndpoint() - AAI endpoint: ' + endpoint + uri, isDebugLogEnabled) + return endpoint + uri + } + + public String getCloudInfrastructureCloudRegionUri(Execution execution) { + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + def uri = getUri(execution, 'cloud_region') + taskProcessor.logDebug('AaiUtil.getCloudInfrastructureCloudRegionUri() - AAI URI: ' + uri, isDebugLogEnabled) + return uri + } + + public String getCloudInfrastructureVolumeGroupUri(Execution execution) { + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + def uri = getUri(execution, 'volume_group') + taskProcessor.logDebug('AaiUtil.getCloudInfrastructureVolumeGroupUri() - AAI URI: ' + uri, isDebugLogEnabled) + return uri + } + + public String getCloudInfrastructureTenantUri(Execution execution) { + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + def uri = getUri(execution, 'tenant') + taskProcessor.logDebug('AaiUtil.getCloudInfrastructureTenantUri() - AAI URI: ' + uri, isDebugLogEnabled) + return uri + } + + public String getSearchNodesQueryUri(Execution execution) { + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + def uri = getUri(execution, 'nodes_query') + taskProcessor.logDebug('AaiUtil.getSearchNodesQueryUri() - AAI URI: ' + uri, isDebugLogEnabled) + return uri + } + + public String getSearchNodesQueryEndpoint(Execution execution) { + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + String endpoint = execution.getVariable("URN_aai_endpoint") + def uri = getSearchNodesQueryUri(execution) + taskProcessor.logDebug('AaiUtil.getSearchNodesQueryEndpoint() - AAI endpoint: ' + endpoint + uri, isDebugLogEnabled) + return endpoint + uri + } + + public String getSearchGenericQueryUri(Execution execution) { + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + def uri = getUri(execution, 'generic_query') + taskProcessor.logDebug('AaiUtil.getSearchGenericQueryUri() - AAI URI: ' + uri, isDebugLogEnabled) + return uri + } + + public String getVersion(Execution execution, resourceName, processKey) { + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + + resourceName = resourceName.replaceAll('-', '_') + + def versionWithResourceKey = "URN_mso_workflow_default_aai_${resourceName}_version" + def versionWithProcessKey = "URN_mso_workflow_custom_${processKey}_aai_version" + + def version = execution.getVariable(versionWithProcessKey) + if (version) { + taskProcessor.logDebug("AaiUtil.getVersion() - using flow specific ${versionWithProcessKey}=${version}", isDebugLogEnabled) + return version + } + + version = execution.getVariable(versionWithResourceKey) + if (version) { + taskProcessor.logDebug("AaiUtil.getVersion() - using resource specific ${versionWithResourceKey}=${version}", isDebugLogEnabled) + return version + } + + version = execution.getVariable(DEFAULT_VERSION_KEY) + if (version) { + taskProcessor.logDebug("AaiUtil.getVersion() - using default version ${DEFAULT_VERSION_KEY}=${version}", isDebugLogEnabled) + return version + } + + (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 9999, "Internal Error: One of the following should be defined in MSO URN properties file: ${versionWithResourceKey}, ${versionWithProcessKey}, ${DEFAULT_VERSION_KEY}") + } + + public String getUri(Execution execution, resourceName) { + + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + def processKey = taskProcessor.getMainProcessKey(execution) + + resourceName = resourceName.replaceAll('-', '_') + + // Check for flow+resource specific first + def key = "URN_mso_workflow_${processKey}_aai_${resourceName}_uri" + def uri = execution.getVariable(key) + if(uri) { + taskProcessor.logDebug("AaiUtil.getUri() - using flow+resource specific key: ${key}=${uri}", isDebugLogEnabled) + return uri + } + + // Check for versioned key + def version = getVersion(execution, resourceName, processKey) + key = "URN_mso_workflow_default_aai_v${version}_${resourceName}_uri" + uri = execution.getVariable(key) + + if(uri) { + taskProcessor.logDebug("AaiUtil.getUri() - using versioned URI key: ${key}=${uri}", isDebugLogEnabled) + return uri + } + + (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 9999, 'Internal Error: AAI URI entry for ' + key + ' not defined in the MSO URN properties file') + } + + public String getNamespaceFromUri(String uri) { + String namespace = AAI_NAMESPACE_STRING + if(uri!=null){ + return namespace + uri.substring(uri.indexOf("v"), uri.indexOf("v")+2) + }else{ + return namespace + } + } + + + + /** + * This reusable method can be used for making AAI Get Calls. The url should + * be passed as a parameter along with the execution. The method will + * return an APIResponse. + * + * @param execution + * @param url + * + * @return APIResponse + */ + public APIResponse executeAAIGetCall(Execution execution, String url){ + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + taskProcessor.logDebug(" ======== STARTED Execute AAI Get Process ======== ", isDebugEnabled) + try{ + String uuid = UUID.randomUUID() + taskProcessor.logDebug( "Generated uuid is: " + uuid, isDebugEnabled) + taskProcessor.logDebug( "URL to be used is: " + url, isDebugEnabled) + + String basicAuthCred = utils.getBasicAuth(execution.getVariable("URN_aai_auth"),execution.getVariable("URN_mso_msoKey")) + + RESTConfig config = new RESTConfig(url); + RESTClient client = new RESTClient(config).addHeader("X-FromAppId", "MSO").addHeader("X-TransactionId", uuid).addHeader("Accept","application/xml"); + + if (basicAuthCred != null && !"".equals(basicAuthCred)) { + client.addAuthorizationHeader(basicAuthCred) + } + + APIResponse apiResponse = client.get() + return apiResponse + + }catch(Exception e){ + taskProcessor.logDebug("Exception occured while executing AAI Get Call. Exception is: \n" + e, isDebugEnabled) + return e + } + taskProcessor.logDebug( "======== COMPLETED Execute AAI Get Process ======== ", isDebugEnabled) + } + + /** + * This reusable method can be used for making AAI httpPut Calls. The url should + * be passed as a parameter along with the execution and payload. The method will + * return an APIResponse. + * + * @param execution + * @param url + * @param payload + * + * @return APIResponse + */ + public APIResponse executeAAIPutCall(Execution execution, String url, String payload){ + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + taskProcessor.logDebug( " ======== Started Execute AAI Put Process ======== ", isDebugEnabled) + try{ + String uuid = UUID.randomUUID() + taskProcessor.logDebug( "Generated uuid is: " + uuid, isDebugEnabled) + taskProcessor.logDebug( "URL to be used is: " + url, isDebugEnabled) + + String basicAuthCred = utils.getBasicAuth(execution.getVariable("URN_aai_auth"),execution.getVariable("URN_mso_msoKey")) + + RESTConfig config = new RESTConfig(url); + RESTClient client = new RESTClient(config).addHeader("X-FromAppId", "MSO").addHeader("X-TransactionId", uuid).addHeader("Content-Type", "application/xml").addHeader("Accept","application/xml"); + if (basicAuthCred != null && !"".equals(basicAuthCred)) { + client.addAuthorizationHeader(basicAuthCred) + } + APIResponse apiResponse = client.httpPut(payload) + + return apiResponse + }catch(Exception e){ + taskProcessor.utils.log("ERROR", "Exception occured while executing AAI Put Call. Exception is: \n" + e, isDebugEnabled) + return e + } + taskProcessor.logDebug( "======== Completed Execute AAI Put Process ======== ", isDebugEnabled) + } + + + /** + * This reusable method can be used for making AAI Delete Calls. The url should + * be passed as a parameter along with the execution. The method will + * return an APIResponse. + * + * @param execution + * @param url + * + * @return APIResponse + */ + public APIResponse executeAAIDeleteCall(Execution execution, String url){ + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + taskProcessor.logDebug( " ======== Started Execute AAI Delete Process ======== ", isDebugEnabled) + try{ + String uuid = UUID.randomUUID() + taskProcessor.logDebug( "Generated uuid is: " + uuid, isDebugEnabled) + taskProcessor.logDebug( "URL to be used is: " + url, isDebugEnabled) + + String basicAuthCred = utils.getBasicAuth(execution.getVariable("URN_aai_auth"),execution.getVariable("URN_mso_msoKey")) + + RESTConfig config = new RESTConfig(url); + RESTClient client = new RESTClient(config).addHeader("X-FromAppId", "MSO").addHeader("X-TransactionId", uuid).addHeader("Accept","application/xml"); + if (basicAuthCred != null && !"".equals(basicAuthCred)) { + client.addAuthorizationHeader(basicAuthCred) + } + APIResponse apiResponse = client.delete() + + return apiResponse + + }catch(Exception e){ + taskProcessor.utils.log("ERROR", "Exception occured while executing AAI Delete Call. Exception is: \n" + e, isDebugEnabled) + return e + } + taskProcessor.logDebug( "======== Completed Execute AAI Delete Process ======== ", isDebugEnabled) + } + + /** + * This reusable method can be used for making AAI Delete Calls. The url should + * be passed as a parameter along with the execution. The method will + * return an APIResponse. + * + * @param execution + * @param url + * @param payload + * + * @return APIResponse + */ + public APIResponse executeAAIDeleteCall(Execution execution, String url, String payload, String authHeader){ + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + taskProcessor.logDebug( " ======== Started Execute AAI Delete Process ======== ", isDebugEnabled) + try{ + String uuid = UUID.randomUUID() + taskProcessor.logDebug( "Generated uuid is: " + uuid, isDebugEnabled) + taskProcessor.logDebug( "URL to be used is: " + url, isDebugEnabled) + + String basicAuthCred = utils.getBasicAuth(execution.getVariable("URN_aai_auth"),execution.getVariable("URN_mso_msoKey")) + RESTConfig config = new RESTConfig(url); + RESTClient client = new RESTClient(config).addHeader("X-FromAppId", "MSO").addHeader("X-TransactionId", uuid).addHeader("Accept","application/xml").addAuthorizationHeader(authHeader); + if (basicAuthCred != null && !"".equals(basicAuthCred)) { + client.addAuthorizationHeader(basicAuthCred) + } + + APIResponse apiResponse = client.httpDelete(payload) + + return apiResponse + + }catch(Exception e){ + taskProcessor.utils.log("ERROR", "Exception occured while executing AAI Delete Call. Exception is: \n" + e, isDebugEnabled) + return e + } + taskProcessor.logDebug( "======== Completed Execute AAI Delete Process ======== ", isDebugEnabled) + } + + /** + * This reusable method can be used for making AAI Post Calls. The url should + * be passed as a parameter along with the execution. The method will + * return an APIResponse. + * + * @param execution + * @param url + * @param payload + * + * @return APIResponse + */ + public APIResponse executeAAIPostCall(Execution execution, String url, String payload){ + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + taskProcessor.logDebug( " ======== Started Execute AAI Post Process ======== ", isDebugEnabled) + try{ + String uuid = UUID.randomUUID() + taskProcessor.logDebug( "Generated uuid is: " + uuid, isDebugEnabled) + taskProcessor.logDebug( "URL to be used is: " + url, isDebugEnabled) + + String basicAuthCred = utils.getBasicAuth(execution.getVariable("URN_aai_auth"),execution.getVariable("URN_mso_msoKey")) + RESTConfig config = new RESTConfig(url); + RESTClient client = new RESTClient(config).addHeader("X-FromAppId", "MSO").addHeader("X-TransactionId", uuid).addHeader("Accept","application/xml"); + if (basicAuthCred != null && !"".equals(basicAuthCred)) { + client.addAuthorizationHeader(basicAuthCred) + } + APIResponse apiResponse = client.httpPost(payload) + + return apiResponse + + }catch(Exception e){ + taskProcessor.utils.log("ERROR", "Exception occured while executing AAI Post Call. Exception is: \n" + e, isDebugEnabled) + return e + } + taskProcessor.logDebug( "======== Completed Execute AAI Post Process ======== ", isDebugEnabled) + } + + /** Utilitty to get the Cloud Region from AAI + * Returns String cloud region id, (ie, cloud-region-id) + * @param execution + * @param url - url for AAI get cloud region + * @param backend - "PO" - real region, or "SDNC" - v2.5 (fake region). + */ + + //TODO: We should refactor this method to return WorkflowException instead of Error. Also to throw MSOWorkflowException which the calling flow will then catch. + + public String getAAICloudReqion(Execution execution, String url, String backend, inputCloudRegion){ + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + + try { + APIResponse apiResponse = executeAAIGetCall(execution, url) + String returnCode = apiResponse.getStatusCode() + String aaiResponseAsString = apiResponse.getResponseBodyAsString() + taskProcessor.utils.log("DEBUG", "Call AAI Cloud Region Return code: " + returnCode, isDebugEnabled) + execution.setVariable(execution.getVariable("prefix")+"queryCloudRegionReturnCode", returnCode) + //taskProcessor.utils.log("DEBUG", "Call AAI Cloud Region Response: " + aaiResponseAsString, isDebugEnabled) + //execution.setVariable(execution.getVariable("prefix")+"queryCloudRegionResponse", aaiResponseAsString) + String regionId = "" + if (returnCode == "200") { + taskProcessor.utils.log("DEBUG", "Call AAI Cloud Region is Successful.", isDebugEnabled) + try { + String regionVersion = taskProcessor.utils.getNodeText(aaiResponseAsString, "cloud-region-version") + taskProcessor.utils.log("DEBUG", "Cloud Region Version from AAI for " + backend + " is: " + regionVersion, isDebugEnabled) + if (backend == "PO") { + regionId = taskProcessor.utils.getNodeText(aaiResponseAsString, "cloud-region-id") + } else { // backend not "PO" + if (regionVersion == "2.5" ) { + regionId = "AAIAIC25" + } else { + regionId = taskProcessor.utils.getNodeText(aaiResponseAsString, "cloud-region-id") + } + } + + taskProcessor.utils.log("DEBUG", "Cloud Region Id from AAI " + backend + " is: " + regionId, isDebugEnabled) + return regionId + + } catch (Exception e) { + taskProcessor.utils.log("ERROR", "Exception occured while getting the Cloud Reqion. Exception is: \n" + e, isDebugEnabled) + return "ERROR" + } + } else { // not 200 + if (returnCode == "404") { + if (backend == "PO") { + regionId = inputCloudRegion + } else { // backend not "PO" + regionId = "AAIAIC25" + } + taskProcessor.utils.log("DEBUG", "Cloud Region value for code='404' of " + backend + " is: " + regionId, isDebugEnabled) + return regionId + } else { + taskProcessor.utils.log("ERROR", "Call AAI Cloud Region is NOT Successful.", isDebugEnabled) + return "ERROR" + } + } + }catch(Exception e) { + taskProcessor.utils.log("ERROR", "Exception occured while getting the Cloud Reqion. Exception is: \n" + e, isDebugEnabled) + return "ERROR" + } + } + + /* returns xml Node with service-type of searchValue */ + def searchServiceType(xmlInput, searchValue){ + def fxml= new XmlSlurper().parseText(xmlInput) + def ret = fxml.'**'.find {it.'service-type' == searchValue} + return ret + } + + /* returns xml Node with service-instance-id of searchValue */ + def searchServiceInstanceId(xmlInput, searchValue){ + def ret = xmlInput.'**'.find {it.'service-instance-id' == searchValue} + return ret + } +}
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/AbstractServiceTaskProcessor.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/AbstractServiceTaskProcessor.groovy new file mode 100644 index 0000000000..5a23d17da0 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/AbstractServiceTaskProcessor.groovy @@ -0,0 +1,964 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common.scripts; + +import groovy.json.JsonSlurper + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.runtime.Execution +import org.camunda.bpm.engine.variable.VariableMap +import org.camunda.bpm.engine.variable.Variables +import org.camunda.bpm.engine.variable.Variables.SerializationDataFormats +import org.camunda.bpm.engine.variable.impl.value.ObjectValueImpl +import org.openecomp.mso.bpmn.common.workflow.service.WorkflowCallbackResponse +import org.openecomp.mso.bpmn.common.workflow.service.WorkflowContextHolder +import org.openecomp.mso.bpmn.core.WorkflowException +import org.springframework.web.util.UriUtils + +public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcessor { + public MsoUtils utils = new MsoUtils() + + + /** + * Logs a message at the ERROR level. + * @param message the message + */ + public void logError(String message) { + log('ERROR', message, null, "true") + } + + /** + * Logs a message at the ERROR level. + * @param message the message + * @param cause the cause (stracktrace will be included in the output) + */ + public void logError(String message, Throwable cause) { + log('ERROR', message, cause, "true") + } + + /** + * Logs a message at the WARN level. + * @param message the message + */ + public void logWarn(String message) { + log('WARN', message, null, "true") + } + + /** + * Logs a message at the WARN level. + * @param message the message + * @param cause the cause (stracktrace will be included in the output) + */ + public void logWarn(String message, Throwable cause) { + log('WARN', message, cause, "true") + } + + /** + * Logs a message at the INFO level. + * @param message the message + */ + public void logInfo(String message) { + log('INFO', message, null, "true") + } + + /** + * Logs a message at the INFO level. + * @param message the message + * @param cause the cause (stracktrace will be included in the output) + */ + public void logInfo(String message, Throwable cause) { + log('INFO', message, cause, "true") + } + + /** + * Logs a message at the DEBUG level. + * @param message the message + * @param isDebugLogEnabled a flag indicating if DEBUG level is enabled + */ + public void logDebug(String message, String isDebugLogEnabled) { + log('DEBUG', message, null, isDebugLogEnabled) + } + + /** + * Logs a message at the DEBUG level. + * @param message the message + * @param cause the cause (stracktrace will be included in the output) + * @param isDebugLogEnabled a flag indicating if DEBUG level is enabled + */ + public void logDebug(String message, Throwable cause, String isDebugLogEnabled) { + log('DEBUG', message, cause, isDebugLogEnabled) + } + + /** + * Logs a message at the specified level. + * @param level the level (DEBUG, INFO, WARN, ERROR) + * @param message the message + * @param isLevelEnabled a flag indicating if the level is enabled + * (used only at the DEBUG level) + */ + public void log(String level, String message, String isLevelEnabled) { + log(level, message, null, isLevelEnabled) + } + + /** + * Logs a message at the specified level. + * @param level the level (DEBUG, INFO, WARN, ERROR) + * @param message the message + * @param cause the cause (stracktrace will be included in the output) + * @param isLevelEnabled a flag indicating if the level is enabled + * (used only at the DEBUG level) + */ + public void log(String level, String message, Throwable cause, String isLevelEnabled) { + if (cause == null) { + utils.log(level, message, isLevelEnabled); + } else { + StringWriter stringWriter = new StringWriter(); + PrintWriter printWriter = new PrintWriter(stringWriter); + printWriter.println(message); + cause.printStackTrace(printWriter); + utils.log(level, stringWriter.toString(), isLevelEnabled); + printWriter.close(); + } + } + + /** + * Logs a WorkflowException at the ERROR level with the specified message. + * @param execution the execution + */ + public void logWorkflowException(Execution execution, String message) { + def workflowException = execution.getVariable("WorkflowException") + + if (workflowException == null) { + logError(message); + } else { + logError(message + ": " + workflowException) + } + } + + /** + * Saves the WorkflowException in the execution to the specified variable, + * clearing the WorkflowException variable so the workflow can continue + * processing (perhaps catching another WorkflowException). + * @param execution the execution + * @return the name of the destination variable + */ + public saveWorkflowException(Execution execution, String variable) { + if (variable == null) { + throw new NullPointerException(); + } + + execution.setVariable(variable, execution.getVariable("WorkflowException")) + execution.setVariable("WorkflowException", null) + } + + /** + * Builds a success response from the specified message content and numeric + * response code. The response code may be an integer or a string representation + * of an integer. The response is stored in the execution where it may be + * picked up by the Workflow service. + * <p> + * IMPORTANT: the activity that executes this method should have an + * asynchronous continuation after it to ensure the execution variables + * are persisted to the database. + * @param execution the execution + * @param content the message content + * @param responseCode the message response code + */ + @Deprecated + public void buildResponse(Execution execution, String content, Object responseCode) { + buildResponse(execution, content, responseCode, true) + } + + /** + * Builds a standard error response containing the specified error message and + * numeric response code. The response code may be an integer or a string + * representation of an integer. The response is stored in the execution where + * it may be picked up by the Workflow service. + * <p> + * IMPORTANT: the activity that executes this method should have an + * asynchronous continuation after it to ensure the execution variables + * are persisted to the database. + * @param execution the execution + * @param content the message content + * @param errorCode the message response code + */ + @Deprecated + public void buildErrorResponse(Execution execution, String errorMessage, Object errorCode) { + + def encErrorMessage = errorMessage.replace("&", "&").replace("<", "<").replace(">", ">") + + def content = """ + <aetgt:WorkflowException xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"> + <aetgt:ErrorMessage>${encErrorMessage}</aetgt:ErrorMessage> + <aetgt:ErrorCode>${errorCode}</aetgt:ErrorCode> + </aetgt:WorkflowException> + """ + + buildResponse(execution, content, errorCode, false) + } + + // BEGIN LEGACY SUPPORT. TODO: REMOVE THIS CODE + /** + * Builds a standard error response containing the specified error message + * and a numeric response code. The response code is obtained from the + * prefix+"ResponseCode" execution variable. The response is stored in the + * execution where it may be picked up by the Workflow service. + * <p> + * IMPORTANT: the activity that executes this method should have an + * asynchronous continuation after it to ensure the execution variables + * are persisted to the database. + * <p> + * This method is deprecated. Methods that accept a response code should + * be used instead. + * @param execution the execution + * @param errorMessage the error message for the error response + */ + @Deprecated + public void buildErrorResponse(Execution execution, String errorMessage) { + buildErrorResponse(execution, errorMessage, null) + } + // END LEGACY SUPPORT. TODO: REMOVE THIS CODE + + /** + * Builds a response from the specified message content and numeric response + * code. The response code may be an integer or a string representation of + * an integer. The response is stored in the execution where it may be + * picked up by the Workflow service. + * <p> + * IMPORTANT: the activity that executes this method should have an + * asynchronous continuation after it to ensure the execution variables + * are persisted to the database. + * @param execution the execution + * @param content the message content + * @param responseCode the message response code + * @param isSuccess true if this is a success response + */ + @Deprecated + protected void buildResponse(Execution execution, String content, Object responseCode, + boolean isSuccess) { + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + + String processKey = getProcessKey(execution); + logDebug("Building " + processKey + " response", isDebugLogEnabled) + + Map<String, Object> responseMap = new HashMap<String, Object>() + + if (isSuccess) { + responseMap.put("Status", "Success") + } else { + responseMap.put("Status", "Fail") + } + + // BEGIN LEGACY SUPPORT. TODO: REMOVE THIS CODE + def prefix = execution.getVariable("prefix") + + if (responseCode == null) { + responseCode = execution.getVariable(prefix+"ResponseCode") + } else { + execution.setVariable(prefix+"ResponseCode", String.valueOf(responseCode)) + } + // END LEGACY SUPPORT. TODO: REMOVE THIS CODE + + responseMap.put("ResponseCode", String.valueOf(responseCode)) + + if (isSuccess) { + responseMap.put("Status", "Success") + // TODO: Should deprecate use of processKey+Response variable for the response. Will use "WorkflowResponse" instead + execution.setVariable("WorkflowResponse", content) + // BEGIN LEGACY SUPPORT. TODO: REMOVE THIS CODE + execution.setVariable(processKey+"Response", content) + execution.setVariable(prefix+"ErrorResponse", null) + // END LEGACY SUPPORT. TODO: REMOVE THIS CODE + } else { + responseMap.put("Status", "Fail") + // BEGIN LEGACY SUPPORT. TODO: REMOVE THIS CODE + execution.setVariable(prefix+"ErrorResponse", content) + execution.setVariable(prefix+"Response", null) + // END LEGACY SUPPORT. TODO: REMOVE THIS CODE + } + + responseMap.put("Response", content) + + logDebug(processKey + + " ResponseCode=" + responseMap.get("ResponseCode") + + " Status=" + responseMap.get("Status") + + " Response=\n" + responseMap.get("Response"), + isDebugLogEnabled) + + execution.setVariable(processKey + "ResponseMap", responseMap) + } + + /** + * Builds an error response (if one has not already been built) and throws + * a BpmnError of type "MSOWorkflowException" that can be caught as a + * boundary event. + * @param execution the execution + * @param errorMessage the error message for the error response + * @param responseCode the message response code + */ + @Deprecated + public void workflowException(Execution execution, String errorMessage, Object responseCode) { + String processKey = getProcessKey(execution); + + buildErrorResponse(execution, errorMessage, responseCode) + throw new BpmnError("MSOWorkflowException") + } + + /** + * Puts a WorkflowException into the execution + * @param execution the execution + * @param errorCode the error code (normally a 4-digit number) + * @param errorMessage the error message + */ + @Deprecated + public void newWorkflowException(Execution execution, int errorCode, String errorMessage) { + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + String processKey = getProcessKey(execution); + logDebug("Building a " + processKey + " WorkflowException", isDebugLogEnabled) + + if (errorCode < 1000) { + throw new IllegalArgumentException("ErrorCode must be a number greater than 1000"); + } + + WorkflowException exception = new WorkflowException(processKey, errorCode, errorMessage); + execution.setVariable("WorkflowException", exception); + } + + /** + * Puts a WorkflowException into the execution and throws an MSOWorkflowException event. + * @param execution the execution + * @param errorCode the error code (normally a 4-digit number) + * @param errorMessage the error message + */ + // TODO: rename this method to be throwWorkflowException + @Deprecated + public void createWorkflowException(Execution execution, int errorCode, String errorMessage) { + newWorkflowException(execution, errorCode, errorMessage) + throw new BpmnError("MSOWorkflowException", "errorCode:" + errorCode + ", errorMessage:" + errorMessage) + } + + /** + * Puts a WorkflowException into the execution and throws an MSOWorkflowException event. + * @param execution the execution + * @param errorCode the error code (normally a 4-digit number) + * @param errorMessage the error message + */ + @Deprecated + public void commonWorkflowException(Execution execution, int errorCode, String errorMessage) { + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + String processKey = getProcessKey(execution); + logDebug("Building a " + processKey + " WorkflowException", isDebugLogEnabled) + logError(errorMessage) + WorkflowException exception = new WorkflowException(processKey, errorCode, errorMessage); + execution.setVariable("WorkflowException", exception); + throw new BpmnError("MSOWorkflowException","errorCode:" + errorCode + ",errorMessage:" + errorMessage) + } + + /** + * Puts a WorkflowException into the execution and throws an MSOWorkflowException event. + * @param execution the execution + * @param errorCode the error code (normally a 4-digit number) + * @param errorMessage the error message + */ + @Deprecated + public void commonWorkflowException(Execution execution, String errorCode, String errorMessage) { + int intRespCode + try{ + intRespCode = Integer.parseInt(errorCode) + }catch (Exception e){ + intRespCode = 400 + } + commonWorkflowException(execution, intRespCode, errorMessage) + } + + + + /** + * Validates that the request exists and that the mso-request-id variable is set. + * Additional required variables may be checked by specifying their names. + * NOTE: services requiring mso-service-instance-id must specify it explicitly! + * If a problem is found, buildAndThrowWorkflowException builds a WorkflowException + * and throws an MSOWorkflowException. This method also sets up the log context for + * the workflow. + * + * @param execution the execution + * @return the validated request + */ + public String validateRequest(Execution execution, String... requiredVariables) { + ExceptionUtil exceptionUtil = new ExceptionUtil() + def method = getClass().getSimpleName() + '.validateRequest(' + + 'execution=' + execution.getId() + + ', requredVariables=' + requiredVariables + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logDebug('Entered ' + method, isDebugLogEnabled) + + String processKey = getProcessKey(execution) + def prefix = execution.getVariable("prefix") + + if (prefix == null) { + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, processKey + " prefix is null") + } + + try { + def request = execution.getVariable(prefix + 'Request') + + if (request == null) { + request = execution.getVariable(processKey + 'Request') + + if (request == null) { + request = execution.getVariable('bpmnRequest') + } + + setVariable(execution, processKey + 'Request', null) + setVariable(execution, 'bpmnRequest', null) + setVariable(execution, prefix + 'Request', request) + } + + if (request == null) { + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, processKey + " request is null") + } + + // All requests must have a request ID. + // Some requests (e.g. SDN-MOBILITY) do not have a service instance ID. + + String requestId = null + String serviceInstanceId = null + + List<String> allRequiredVariables = new ArrayList<String>() + allRequiredVariables.add("mso-request-id") + + if (requiredVariables != null) { + for (String variable : requiredVariables) { + if (!allRequiredVariables.contains(variable)) { + allRequiredVariables.add(variable) + } + } + } + + for (String variable : allRequiredVariables) { + def value = execution.getVariable(variable) + if (value == null || ((value instanceof CharSequence) && value.length() == 0)) { + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, processKey + + " request was received with no '" + variable + "' variable") + } + + if ("mso-request-id".equals(variable)) { + requestId = (String) value + } else if ("mso-service-instance-id".equals(variable)) { + serviceInstanceId = (String) value + } + } + + if (serviceInstanceId == null) { + serviceInstanceId = (String) execution.getVariable("mso-service-instance-id") + } + + utils.logContext(requestId, serviceInstanceId) + logDebug('Incoming message: ' + System.lineSeparator() + request, isDebugLogEnabled) + logDebug('Exited ' + method, isDebugLogEnabled) + return request + } catch (BpmnError e) { + throw e + } catch (Exception e) { + logError('Caught exception in ' + method, e) + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Invalid Message") + } + } + + /** + * gets vars stored in a JSON object in prefix+Request and returns as a LazyMap + * setting log context here too + * @param execution the execution + * @return the inputVars + */ + public Map validateJSONReq(Execution execution) { + def method = getClass().getSimpleName() + '.validateJSONReq(' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logDebug('Entered ' + method, isDebugLogEnabled) + + String processKey = getProcessKey(execution); + def prefix = execution.getVariable("prefix") + + def requestId =getVariable(execution, "mso-request-id") + def serviceInstanceId = getVariable(execution, "mso-service-instance-id") + if(requestId!=null && serviceInstanceId!=null){ + utils.logContext(requestId, serviceInstanceId) + } + + + def request = getVariable(execution, prefix + 'Request') + + if (request == null) { + request = getVariable(execution, processKey + 'Request') + + if (request == null) { + request = getVariable(execution, 'bpmnRequest') + } + execution.setVariable(prefix + 'Request', request) + } + + def jsonSlurper = new JsonSlurper() + def parsed = jsonSlurper.parseText(request) + + + logDebug('Incoming message: ' + System.lineSeparator() + request, isDebugLogEnabled) + logDebug('Exited ' + method, isDebugLogEnabled) + return parsed + + } + + + + + /** + * Sends a response to the workflow service that invoked the process. This method + * may only be used by top-level processes that were directly invoked by the + * asynchronous workflow service. + * @param execution the execution + * @param responseCode the response code + * @param content the message content + * @throws IllegalArgumentException if the response code is invalid + * by HTTP standards + * @throws UnsupportedOperationException if not invoked by an asynchronous, + * top-level process + * @throws IllegalStateException if a response has already been sent + */ + protected void sendWorkflowResponse(Execution execution, Object responseCode, String response) { + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + try { + String processKey = getProcessKey(execution); + + // isAsyncProcess is injected by the workflow service that started the flow + if (!String.valueOf(execution.getVariable("isAsyncProcess")).equals("true")) { + throw new UnsupportedOperationException(processKey + ": " + + "sendWorkflowResponse is valid only in asynchronous workflows"); + } + + if (String.valueOf(execution.getVariable(processKey + "WorkflowResponseSent")).equals("true")) { + logDebug("Sync response has already been sent for " + processKey, isDebugLogEnabled) + }else{ + + logDebug("Building " + processKey + " response ", isDebugLogEnabled) + + int intResponseCode; + + try { + intResponseCode = Integer.parseInt(String.valueOf(responseCode)); + + if (intResponseCode < 100 || intResponseCode > 599) { + throw new NumberFormatException(String.valueOf(responseCode)); + } + } catch (NumberFormatException e) { + throw new IllegalArgumentException("Process " + processKey + + " provided an invalid HTTP response code: " + responseCode); + } + + // Only 2XX responses are considered "Success" + String status = (intResponseCode >= 200 && intResponseCode <= 299) ? + "Success" : "Fail"; + + // TODO: Should deprecate use of processKey+Response variable for the response. Will use "WorkflowResponse" instead + execution.setVariable(processKey + "ResponseCode", String.valueOf(intResponseCode)) + execution.setVariable(processKey + "Response", response); + execution.setVariable(processKey + "Status", status); + execution.setVariable("WorkflowResponse", response) + + logDebug("Sending response for " + processKey + + " ResponseCode=" + intResponseCode + + " Status=" + status + + " Response=\n" + response, + isDebugLogEnabled) + + // TODO: ensure that this flow was invoked asynchronously? + + WorkflowCallbackResponse callbackResponse = new WorkflowCallbackResponse() + callbackResponse.setStatusCode(intResponseCode) + callbackResponse.setMessage(status) + callbackResponse.setResponse(response) + + // TODO: send this data with HTTP POST + + WorkflowContextHolder.getInstance().processCallback( + processKey, + execution.getProcessInstanceId(), + execution.getVariable("mso-request-id"), + callbackResponse) + + execution.setVariable(processKey + "WorkflowResponseSent", "true"); + } + + } catch (Exception ex) { + logError("Unable to send workflow response to client ....", ex) + } + } + + /** + * Returns true if a workflow response has already been sent. + * @param execution the execution + */ + protected boolean isWorkflowResponseSent(Execution execution) { + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + String processKey = getProcessKey(execution); + return String.valueOf(execution.getVariable(processKey + "WorkflowResponseSent")).equals("true"); + } + + /** + * Returns the process definition key (i.e. the process name) of the + * current process. + * + * @param execution the execution + */ + public String getProcessKey(Execution execution) { + def testKey = execution.getVariable("testProcessKey") + if(testKey!=null){ + return testKey + } + return execution.getProcessEngineServices().getRepositoryService() + .getProcessDefinition(execution.getProcessDefinitionId()).getKey() + } + + /** + * Returns the process definition key (i.e. the process name) of the + * top-level process. + * @param execution the execution + */ + public String getMainProcessKey(Execution execution) { + Execution exec = execution + + while (true) { + Execution parent = exec.getSuperExecution() + + if (parent == null) { + parent = exec.getParent() + + if (parent == null) { + break + } + } + + exec = parent + } + + return execution.getProcessEngineServices().getRepositoryService() + .getProcessDefinition(exec.getProcessDefinitionId()).getKey() + } + + /** + * Gets the node for the named element from the given xml. If the element + * does not exist in the xml or is empty, a WorkflowException is created + * (and as a result, a MSOWorkflowException event is thrown). + * + * @param execution The flow's execution. + * @param xml Xml to search. + * @param elementName Name of element to search for. + * @return The element node, if found in the xml. + */ + protected String getRequiredNodeXml(Execution execution, String xml, String elementName) { + def element = utils.getNodeXml(xml, elementName, false) + if (element.trim().isEmpty()) { + def msg = 'Required element \'' + elementName + '\' is missing or empty' + logError(msg) + createWorkflowException(execution, 2000, msg) + } else { + return element + } + } + + /** + * Gets the value of the named element from the given xml. If the element + * does not exist in the xml or is empty, a WorkflowException is created + * (and as a result, a MSOWorkflowException event is thrown). + * + * @param execution The flow's execution. + * @param xml Xml to search. + * @param elementName Name of element to whose value to get. + * @return The value of the element, if found in the xml. + */ + protected String getRequiredNodeText(Execution execution, String xml, String elementName) { + def elementText = utils.getNodeText1(xml, elementName) + if (elementText == null) { + def msg = 'Required element \'' + elementName + '\' is missing or empty' + logError(msg) + createWorkflowException(execution, 2000, msg) + } else { + return elementText + } + } + + /** + * Get the text for the specified element from the specified xml. If + * the element does not exist, return an empty string. + * + * @param xml Xml from which to get the element's text. + * @param elementName Name of element whose text to get. + * @return the element's text or an empty string if the element does not + * exist in the given xml. + */ + protected String getNodeTextForce(String xml, String elementName) { + def nodeText = utils.getNodeText1(xml, elementName) + return (nodeText == null) ? '' : nodeText + } + + /** + * Sends the empty, synchronous response back to the API Handler. + * @param execution the execution + */ + @Deprecated + public void sendResponse(Execution execution) { + def method = getClass().getSimpleName() + '.sendResponse(' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logDebug('Entered ' + method, isDebugLogEnabled) + + try { + buildResponse(execution, "", 200) + logDebug('Exited ' + method, isDebugLogEnabled) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + logError('Caught exception in ' + method, e) + workflowException(execution, 'Internal Error', 9999) // TODO: what message and error code? + } + } + + /** + *Store the variable as typed with java serialization type + *@param execution + *@param name + *@param value + */ + public void setVariable(Execution execution, String name, Object value) { + VariableMap variables = Variables.createVariables() + variables.putValueTyped('payload', Variables.objectValue(value) + .serializationDataFormat(SerializationDataFormats.JAVA) // tells the engine to use java serialization for persisting the value + .create()) + execution.setVariable(name,variables) + } + + //TODO not sure how this will look in Cockpit + + /** + * Returns the variable map + *@param execution + *@param name + *@return + **/ + public String getVariable(Execution execution, String name) { + def myObj = execution.getVariable(name) + if(myObj instanceof VariableMap){ + VariableMap serializedObjectMap = (VariableMap) myObj + ObjectValueImpl payloadObj = serializedObjectMap.getValueTyped('payload') + return payloadObj.getValue() + }else{ + return myObj + } + } + + + /** + * Returns true if a value equals one of the provided set. Equality is + * determined by using the equals method if the value object and the + * object in the provided set have the same class. Otherwise, the objects + * are converted to strings and then compared. Nulls are permitted for + * the value as well as in the provided set + * Example: + * <pre> + * def statusCode = getStatusCode() + * isOneOf(statusCode, 200, 201, 204) + * </pre> + * @param value the value to test + * @param these a set of permissable values + * @return true if the value is in the provided set + */ + public boolean isOneOf(Object value, Object... these) { + for (Object thisOne : these) { + if (thisOne == null) { + if (value == null) { + return true + } + } else { + if (value != null) { + if (value.getClass() == thisOne.getClass()) { + if (value.equals(thisOne)) { + return true + } + } else { + if (String.valueOf(value).equals(String.valueOf(thisOne))) { + return true + } + } + } + } + } + + return false + } + + public void setSuccessIndicator(Execution execution, boolean isSuccess) { + String prefix = execution.getVariable('prefix') + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + + logDebug('Entered SetSuccessIndicator Method', isDebugLogEnabled) + execution.setVariable(prefix+'SuccessIndicator', isSuccess) + logDebug('Outgoing SuccessIndicator is: ' + execution.getVariable(prefix+'SuccessIndicator') + '', isDebugLogEnabled) + } + + + public void sendSyncError(Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + String requestId = execution.getVariable("mso-request-id") + logDebug('sendSyncError, requestId: ' + requestId, isDebugEnabled) + WorkflowException workflowExceptionObj = execution.getVariable("WorkflowException") + if (workflowExceptionObj != null) { + String errorMessage = workflowExceptionObj.getErrorMessage() + def errorCode = workflowExceptionObj.getErrorCode() + logDebug('sendSyncError, requestId: ' + requestId + ' | errorMessage: ' + errorMessage + ' | errorCode: ' + errorCode, isDebugEnabled) + sendWorkflowResponse(execution, errorCode, errorMessage) + } + } + + /** + * Create a WorkflowException - uses ExceptionUtil to build a WorkflowException + * @param execution + * @param errorCode + * @param errorMessage + * @param isDebugEnabled + */ + public void buildWorkflowException(Execution execution, int errorCode, String errorMessage, boolean isDebugEnabled) { + (new ExceptionUtil()).buildWorkflowException(execution, errorCode, errorMessage) + } + + /** + * Executes a named groovy script method in the current object + */ + public void executeMethod(String methodName, Object... args) { + + if (args != null && args.size() > 0) { + + // First argument of method to call is always the execution object + Execution execution = (Execution) args[0] + + def classAndMethod = getClass().getSimpleName() + '.' + methodName + '(execution=' + execution.getId() + ')' + def isDebugEnabled = execution.getVariable('isDebugLogEnabled') + + logDebug('Entered ' + classAndMethod, isDebugEnabled) + logDebug('Received parameters: ' + args, isDebugEnabled) + + try{ + def methodToCall = this.metaClass.getMetaMethod(methodName, args) + logDebug('Method to call: ' + methodToCall, isDebugEnabled) + methodToCall?.invoke(this, args) + } + catch(BpmnError bpmnError) { + logDebug('Rethrowing BpmnError ' + bpmnError.getMessage(), isDebugEnabled) + throw bpmnError + } + catch(Exception e) { + e.printStackTrace() + logDebug('Unexpected error encountered - ' + e.getMessage(), isDebugEnabled) + (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 9999, e.getMessage()) + } + finally { + logDebug('Exited ' + classAndMethod, isDebugEnabled) + } + } + } + + /** + *This method determines and adds the appropriate ending to come + *after a number (-st, -nd, -rd, or -th) + * + *@param int n + * + *@return String ending - number with suffix + */ + + public static String labelMaker(Object n) { + Integer num + if(n instanceof String){ + num = Integer.parseInt(n) + }else{ + num = n + } + + String ending = ""; //the end to be added to the number + if(num != null){ + if ((num % 10 == 1) && (num != 11)) { + ending = num + "st"; + } else if ((num % 10 == 2) && (num != 12)) { + ending = num + "nd"; + } else if ((num % 10 == 3) && (num != 13)) { + ending = num + "rd"; + } else { + ending = num + "th"; + } + } + return ending + } + + /** + * + *This method gets and decodes SDNC Response's "RequestData". + * + *@param response - the sdnc response + * + *@return data - the response "RequestData" decoded + * + */ + public String getRequestDataDecoded(String response){ + String data = utils.getNodeText1(response, "RequestData") + if(data != null){ + data = data.replaceAll("<", "<") + data = data.replaceAll(">", ">") + } + + return data + } + + + /** + * Constructs a workflow message callback URL for the specified message type and correlator. + * @param messageType the message type (e.g. SDNCAResponse or VNFAResponse) + * @param correlator the correlator value (e.g. a request ID) + */ + public String createCallbackURL(Execution execution, String messageType, String correlator) { + String endpoint = (String) execution.getVariable('URN_mso_workflow_message_endpoint') + + if (endpoint == null || endpoint.isEmpty()) { + ExceptionUtil exceptionUtil = new ExceptionUtil() + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, + 'mso:workflow:message:endpoint URN mapping is not set') + } + + while (endpoint.endsWith('/')) { + endpoint = endpoint.substring(0, endpoint.length()-1) + } + + return endpoint + + '/' + UriUtils.encodePathSegment(messageType, 'UTF-8') + + '/' + UriUtils.encodePathSegment(correlator, 'UTF-8') + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/CatalogDbUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/CatalogDbUtils.groovy new file mode 100644 index 0000000000..f74717b510 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/CatalogDbUtils.groovy @@ -0,0 +1,550 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common.scripts + +import org.json.JSONObject; +import org.json.JSONArray; +import org.json.XML; +import org.springframework.web.util.UriUtils; + +import org.openecomp.mso.bpmn.core.json.JsonUtils + + +import groovy.json.JsonBuilder +import groovy.json.JsonSlurper +import groovy.util.slurpersupport.GPathResult +import groovy.xml.QName; + +import org.openecomp.mso.logger.MsoLogger; +import org.openecomp.mso.rest.APIResponse; +import org.openecomp.mso.rest.RESTClient +import org.openecomp.mso.rest.RESTConfig + + +/*** + * Utilities for accessing Catalog DB Adapter to retrieve Networks, VNF/VFModules, AllottedResources and complete ServiceResources information + * + */ + +class CatalogDbUtils { + + MsoUtils utils = new MsoUtils() + JsonUtils jsonUtils = new JsonUtils() + MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL); + + public JSONArray getAllNetworksByServiceModelUuid(String catalogDbEndpoint, String serviceModelUuid) { + JSONArray networksList = null + String endPoint = catalogDbEndpoint + "/v1/serviceNetworks?serviceModelUuid=" + UriUtils.encode(serviceModelUuid, "UTF-8") + try { + String catalogDbResponse = getResponseFromCatalogDb(endPoint) + + if (catalogDbResponse != null) { + networksList = parseNetworksJson(catalogDbResponse, "serviceNetworks") + } + + } + catch (Exception e) { + utils.log("ERROR", "Exception in Querying Catalog DB: " + e.message) + } + + return networksList + } + + public JSONArray getAllNetworksByServiceModelInvariantUuid(String catalogDbEndpoint, String serviceModelInvariantUuid) { + JSONArray networksList = null + String endPoint = catalogDbEndpoint + "/v1/serviceNetworks?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8") + try { + String catalogDbResponse = getResponseFromCatalogDb(endPoint) + + if (catalogDbResponse != null) { + networksList = parseNetworksJson(catalogDbResponse, "serviceNetworks") + } + + } + catch (Exception e) { + utils.log("ERROR", "Exception in Querying Catalog DB: " + e.message) + } + + return networksList + } + + public JSONArray getAllNetworksByServiceModelInvariantUuidAndServiceModelVersion(String catalogDbEndpoint, String serviceModelInvariantUuid, String serviceModelVersion) { + JSONArray networksList = null + String endPoint = catalogDbEndpoint + "/v1/serviceNetworks?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8") + "&serviceModelVersion=" + UriUtils.encode(serviceModelVersion, "UTF-8") + try { + String catalogDbResponse = getResponseFromCatalogDb(endPoint) + + if (catalogDbResponse != null) { + networksList = parseNetworksJson(catalogDbResponse, "serviceNetworks") + } + + } + catch (Exception e) { + utils.log("ERROR", "Exception in Querying Catalog DB: " + e.message) + } + + return networksList + } + + public JSONArray getAllNetworksByNetworkModelCustomizationUuid(String catalogDbEndpoint, String networkModelCustomizationUuid) { + JSONArray networksList = null + String endPoint = catalogDbEndpoint + "/v1/serviceNetworks?networkModelCustomizationUuid=" + UriUtils.encode(networkModelCustomizationUuid, "UTF-8") + try { + String catalogDbResponse = getResponseFromCatalogDb(endPoint) + + if (catalogDbResponse != null) { + networksList = parseNetworksJson(catalogDbResponse, "serviceNetworks") + } + + } + catch (Exception e) { + utils.log("ERROR", "Exception in Querying Catalog DB: " + e.message) + } + + return networksList + } + + public JSONArray getAllNetworksByNetworkType(String catalogDbEndpoint, String networkType) { + JSONArray networksList = null + String endPoint = catalogDbEndpoint + "/v1/serviceNetworks?networkType=" + UriUtils.encode(networkType, "UTF-8") + try { + String catalogDbResponse = getResponseFromCatalogDb(endPoint) + + if (catalogDbResponse != null) { + networksList = parseNetworksJson(catalogDbResponse, "serviceNetworks") + } + + } + catch (Exception e) { + utils.log("ERROR", "Exception in Querying Catalog DB: " + e.message) + } + + return networksList + } + + + public JSONArray getAllVnfsByServiceModelUuid(String catalogDbEndpoint, String serviceModelUuid) { + JSONArray vnfsList = null + String endPoint = catalogDbEndpoint + "/v1/serviceVnfs?serviceModelUuid=" + UriUtils.encode(serviceModelUuid, "UTF-8") + try { + msoLogger.debug("ENDPOINT: " + endPoint) + String catalogDbResponse = getResponseFromCatalogDb(endPoint) + + if (catalogDbResponse != null) { + vnfsList = parseVnfsJson(catalogDbResponse, "serviceVnfs") + } + + } + catch (Exception e) { + utils.log("ERROR", "Exception in Querying Catalog DB: " + e.message) + } + + return vnfsList + } + + public JSONArray getAllVnfsByServiceModelInvariantUuid(String catalogDbEndpoint, String serviceModelInvariantUuid) { + JSONArray vnfsList = null + String endPoint = catalogDbEndpoint + "/v1/serviceVnfs?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8") + try { + msoLogger.debug("ENDPOINT: " + endPoint) + String catalogDbResponse = getResponseFromCatalogDb(endPoint) + + if (catalogDbResponse != null) { + vnfsList = parseVnfsJson(catalogDbResponse, "serviceVnfs") + } + + } + catch (Exception e) { + utils.log("ERROR", "Exception in Querying Catalog DB: " + e.message) + } + + return vnfsList + } + + public JSONArray getAllVnfsByServiceModelInvariantUuidAndServiceModelVersion(String catalogDbEndpoint, String serviceModelInvariantUuid, String serviceModelVersion) { + JSONArray vnfsList = null + String endPoint = catalogDbEndpoint + "/v1/serviceVnfs?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8") + "&serviceModelVersion=" + UriUtils.encode(serviceModelVersion, "UTF-8") + try { + msoLogger.debug("ENDPOINT: " + endPoint) + String catalogDbResponse = getResponseFromCatalogDb(endPoint) + + if (catalogDbResponse != null) { + vnfsList = parseVnfsJson(catalogDbResponse, "serviceVnfs") + } + + } + catch (Exception e) { + utils.log("ERROR", "Exception in Querying Catalog DB: " + e.message) + } + + return vnfsList + } + + public JSONArray getAllVnfsByVnfModelCustomizationUuid(String catalogDbEndpoint, String vnfModelCustomizationUuid) { + JSONArray vnfsList = null + String endPoint = catalogDbEndpoint + "/v1/serviceVnfs?vnfModelCustomizationUuid=" + UriUtils.encode(vnfModelCustomizationUuid, "UTF-8") + try { + msoLogger.debug("ENDPOINT: " + endPoint) + String catalogDbResponse = getResponseFromCatalogDb(endPoint) + + if (catalogDbResponse != null) { + vnfsList = parseVnfsJson(catalogDbResponse, "serviceVnfs") + } + + } + catch (Exception e) { + utils.log("ERROR", "Exception in Querying Catalog DB: " + e.message) + } + + return vnfsList + } + + + public JSONArray getAllottedResourcesByServiceModelUuid(String catalogDbEndpoint, String serviceModelUuid) { + JSONArray vnfsList = null + String endPoint = catalogDbEndpoint + "/v1/ServiceAllottedResources?serviceModelUuid=" + UriUtils.encode(serviceModelUuid, "UTF-8") + try { + String catalogDbResponse = getResponseFromCatalogDb(endPoint) + + if (catalogDbResponse != null) { + vnfsList = parseAllottedResourcesJson(catalogDbResponse, "serviceAllottedResources") + } + + } + catch (Exception e) { + utils.log("ERROR", "Exception in Querying Catalog DB: " + e.message) + } + + return vnfsList + } + + public JSONArray getAllottedResourcesByServiceModelInvariantUuid(String catalogDbEndpoint, String serviceModelInvariantUuid) { + JSONArray vnfsList = null + String endPoint = catalogDbEndpoint + "/v1/serviceAllottedResources?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8") + try { + String catalogDbResponse = getResponseFromCatalogDb(endPoint) + + if (catalogDbResponse != null) { + vnfsList = parseAllottedResourcesJson(catalogDbResponse, "serviceAllottedResources") + } + + } + catch (Exception e) { + utils.log("ERROR", "Exception in Querying Catalog DB: " + e.message) + } + + return vnfsList + } + + public JSONArray getAllottedResourcesByServiceModelInvariantUuidAndServiceModelVersion(String catalogDbEndpoint, String serviceModelInvariantUuid, String serviceModelVersion) { + JSONArray vnfsList = null + String endPoint = catalogDbEndpoint + "/v1/serviceAllottedResources?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8") + "&serviceModelVersion=" + UriUtils.encode(serviceModelVersion, "UTF-8") + try { + String catalogDbResponse = getResponseFromCatalogDb(endPoint) + + if (catalogDbResponse != null) { + vnfsList = parseAllottedResourcesJson(catalogDbResponse, "serviceAllottedResources") + } + + } + catch (Exception e) { + utils.log("ERROR", "Exception in Querying Catalog DB: " + e.message) + } + + return vnfsList + } + + public JSONArray getAllottedResourcesByArModelCustomizationUuid(String catalogDbEndpoint, String arModelCustomizationUuid) { + JSONArray vnfsList = null + String endPoint = catalogDbEndpoint + "/v1/serviceAllottedResources?serviceModelCustomizationUuid=" + UriUtils.encode(arModelCustomizationUuid, "UTF-8") + try { + String catalogDbResponse = getResponseFromCatalogDb(endPoint) + + if (catalogDbResponse != null) { + vnfsList = parseAllottedResourcesJson(catalogDbResponse, "serviceAllottedResources") + } + + } + catch (Exception e) { + utils.log("ERROR", "Exception in Querying Catalog DB: " + e.message) + } + + return vnfsList + } + + public JSONObject getServiceResourcesByServiceModelInvariantUuid(String catalogDbEndpoint, String serviceModelInvariantUuid) { + JSONObject resources = null + String endPoint = catalogDbEndpoint + "/v1/serviceResources?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8") + try { + String catalogDbResponse = getResponseFromCatalogDb(endPoint) + + if (catalogDbResponse != null) { + resources = parseServiceResourcesJson(catalogDbResponse) + } + + } + catch (Exception e) { + utils.log("ERROR", "Exception in Querying Catalog DB: " + e.message) + } + + return resources + } + + public JSONObject getServiceResourcesByServiceModelInvariantUuidAndServiceModelVersion(String catalogDbEndpoint, String serviceModelInvariantUuid, String serviceModelVersion) { + JSONObject resources = null + String endPoint = catalogDbEndpoint + "/v1/serviceResources?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8") + "&serviceModelVersion=" + UriUtils.encode(serviceModelVersion, "UTF-8") + try { + String catalogDbResponse = getResponseFromCatalogDb(endPoint) + + if (catalogDbResponse != null) { + resources = parseServiceResourcesJson(catalogDbResponse) + } + + } + catch (Exception e) { + utils.log("ERROR", "Exception in Querying Catalog DB: " + e.message) + } + + return resources + } + + + + private JSONArray parseNetworksJson (String catalogDbResponse, String arrayName) { + JSONArray modelInfos = null + + try { + // Create array of jsons + + JSONObject responseJson = new JSONObject(catalogDbResponse) + JSONArray networks = responseJson.getJSONArray(arrayName) + modelInfos = new JSONArray() + + for (int i = 0; i < networks.length(); i++) { + + JSONObject network = networks.getJSONObject(i) + JSONObject modelInfo = buildModelInfo("network", network) + JSONObject modelJson = new JSONObject() + modelJson.put("modelInfo", modelInfo) + String networkType = jsonUtils.getJsonValueForKey(network, "networkType") + modelJson.put("networkType", networkType) + modelInfos.put(modelJson) + } + + String modelInfosString = modelInfos.toString() + msoLogger.debug("Returning networks JSON: " + modelInfosString) + + } catch (Exception e) { + utils.log("ERROR", "Exception in parsing Catalog DB Response: " + e.message) + } + + return modelInfos + } + + private JSONArray parseVnfsJson (String catalogDbResponse, String arrayName) { + JSONArray modelInfos = null + + try { + // Create array of jsons + + JSONObject responseJson = new JSONObject(catalogDbResponse) + JSONArray vnfs = responseJson.getJSONArray(arrayName) + modelInfos = new JSONArray() + + for (int i = 0; i < vnfs.length(); i++) { + JSONObject vnf = vnfs.getJSONObject(i) + + msoLogger.debug(vnf.toString(2)) + JSONObject modelInfo = buildModelInfo("vnf", vnf) + JSONObject modelJson = new JSONObject() + modelJson.put("modelInfo", modelInfo) + + JSONArray vfModules = null + try { + vfModules = vnf.getJSONArray("vfModules") + } catch (Exception e) + { + msoLogger.debug("Cannot find VF MODULE ARRAY: " + i + ", exception is " + e.message) + } + + if (vfModules != null) { + JSONArray vfModuleInfo = new JSONArray() + for (int j = 0; j < vfModules.length(); j++) { + JSONObject vfModule = vfModules.getJSONObject(j) + JSONObject vfModuleModelInfo = buildModelInfo("vfModule", vfModule) + JSONObject vfModuleModelJson = new JSONObject() + vfModuleModelJson.put("modelInfo", vfModuleModelInfo) + String vfModuleType = jsonUtils.getJsonValueForKey(vfModule, "type") + vfModuleModelJson.put("vfModuleType", vfModuleType) + Integer isBase = jsonUtils.getJsonIntValueForKey(vfModule, "isBase") + if (isBase.intValue() == 1) { + vfModuleModelJson.put("isBase", "true") + } + else { + vfModuleModelJson.put("isBase", "false") + } + String vfModuleLabel = jsonUtils.getJsonValueForKey(vfModule, "label") + vfModuleModelJson.put("vfModuleLabel", vfModuleLabel) + Integer initialCount = jsonUtils.getJsonIntValueForKey(vfModule, "initialCount") + vfModuleModelJson.put("initialCount", initialCount.intValue()) + vfModuleInfo.put(vfModuleModelJson) + } + modelJson.put("vfModules", vfModuleInfo) + } + modelInfos.put(modelJson) + } + + String modelInfosString = modelInfos.toString() + msoLogger.debug("Returning vnfs JSON: " + modelInfosString) + + } catch (Exception e) { + utils.log("ERROR", "Exception in parsing Catalog DB Response: " + e.message) + } + + return modelInfos + } + + private JSONArray parseAllottedResourcesJson (String catalogDbResponse, String arrayName) { + JSONArray modelInfos = null + + try { + // Create array of jsons + + JSONObject responseJson = new JSONObject(catalogDbResponse) + JSONArray allottedResources = responseJson.getJSONArray(arrayName) + modelInfos = new JSONArray() + + for (int i = 0; i < allottedResources.length(); i++) { + JSONObject allottedResource = allottedResources.getJSONObject(i) + JSONObject modelInfo = buildModelInfo("allottedResource", allottedResource) + JSONObject modelJson = new JSONObject() + modelJson.put("modelInfo", modelInfo) + modelInfos.put(modelJson) + } + + String modelInfosString = modelInfos.toString() + msoLogger.debug("Returning allottedResources JSON: " + modelInfosString) + + } catch (Exception e) { + utils.log("ERROR", "Exception in parsing Catalog DB Response: " + e.message) + } + + return modelInfos + } + + private JSONObject parseServiceResourcesJson (String catalogDbResponse) { + JSONObject serviceResources = new JSONObject() + + try { + // Create array of jsons + + JSONObject responseJson = new JSONObject(catalogDbResponse) + JSONObject serviceResourcesRoot = responseJson.getJSONObject("serviceResources") + JSONArray vnfsArray = parseVnfsJson(serviceResourcesRoot.toString(), "vnfResources") + serviceResources.put("vnfs", vnfsArray) + JSONArray networksArray = parseNetworksJson(serviceResourcesRoot.toString(), "networkResourceCustomization") + serviceResources.put("networks", networksArray) + JSONArray allottedResourcesArray = parseAllottedResourcesJson(serviceResourcesRoot.toString(), "allottedResourceCustomization") + serviceResources.put("allottedResources", allottedResourcesArray) + + String serviceResourcesString = serviceResources.toString() + msoLogger.debug("Returning serviceResources JSON: " + serviceResourcesString) + + } catch (Exception e) { + utils.log("ERROR", "Exception in parsing Catalog DB Response: " + e.message) + } + + return serviceResources + } + + private JSONObject buildModelInfo(String modelType, JSONObject modelFromDb) { + JSONObject modelInfo = null + try { + modelInfo = new JSONObject() + modelInfo.put("modelType", modelType) + String modelInvariantId = jsonUtils.getJsonValueForKey(modelFromDb, "modelInvariantUuid") + modelInfo.put("modelInvariantId", modelInvariantId) + if(modelType.equalsIgnoreCase("allottedResource")){ + String modelInstanceName = jsonUtils.getJsonValueForKey(modelFromDb, "modelInstanceName") + modelInfo.put("modelInstanceName", modelInstanceName) + } + if (!"vfModule".equals(modelType) && !"vnf".equals(modelType)) { + String modelVersionId = jsonUtils.getJsonValueForKey(modelFromDb, "modelUuid") + modelInfo.put("modelVersionId", modelVersionId) + } + else { + String modelVersionId = jsonUtils.getJsonValueForKey(modelFromDb, "asdcUuid") + modelInfo.put("modelVersionId", modelVersionId) + } + String modelName = jsonUtils.getJsonValueForKey(modelFromDb, "modelName") + modelInfo.put("modelName", modelName) + String modelVersion = jsonUtils.getJsonValueForKey(modelFromDb, "modelVersion") + modelInfo.put("modelVersion", modelVersion) + if (!"vfModule".equals(modelType)) { + String modelCustomizationName = jsonUtils.getJsonValueForKey(modelFromDb, "modelCustomizationName") + modelInfo.put("modelCustomizationName", modelCustomizationName) + } + String modelCustomizationId = jsonUtils.getJsonValueForKey(modelFromDb, "modelCustomizationUuid") + modelInfo.put("modelCustomizationId", modelCustomizationId) + JSONObject modelJson = new JSONObject() + modelJson.put("modelInfo", modelInfo) + } + catch (Exception e) { + utils.log("ERROR", "Exception while parsing model information: " + e.message) + } + return modelInfo + } + + private String getResponseFromCatalogDb (String endPoint) { + try { + RESTConfig config = new RESTConfig(endPoint); + def responseData = '' + def bpmnRequestId = UUID.randomUUID().toString() + RESTClient client = new RESTClient(config). + addHeader('X-TransactionId', bpmnRequestId). + addHeader('X-FromAppId', 'BPMN'). + addHeader('Content-Type', 'application/json'). + addHeader('Accept','application/json'); + msoLogger.debug('sending GET to Catalog DB endpoint' + endPoint) + APIResponse response = client.httpGet() + + responseData = response.getResponseBodyAsString() + if (responseData != null) { + msoLogger.debug("Received data from Catalog DB: " + responseData) + } + + msoLogger.debug('Response code:' + response.getStatusCode()) + msoLogger.debug('Response:' + System.lineSeparator() + responseData) + if (response.getStatusCode() == 200) { + // parse response as needed + return responseData + } + else { + return null + } + } + catch (Exception e) { + msoLogger.debug("ERROR WHILE QUERYING CATALOG DB: " + e.message) + return null + } + + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/CommonExceptionUtil.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/CommonExceptionUtil.groovy new file mode 100644 index 0000000000..cce05feca8 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/CommonExceptionUtil.groovy @@ -0,0 +1,382 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common.scripts + +import org.camunda.bpm.engine.runtime.Execution +import org.apache.commons.lang3.* + +class CommonExceptionUtil { + + + + public static enum Error { + SVC_GENERAL_SERVICE_ERROR("SVC0001","Internal Error"), + SVC_BAD_PARAMETER("SVC0002", "Invalid input value for message part %1"), + SVC_NO_SERVER_RESOURCES("SVC1000", "No server resources available to process the request"), + SVC_DETAILED_SERVICE_ERROR("SVC2000", "The following service error occurred: %1. Error code is %2."), + POL_GENERAL_POLICY_ERROR("POL0001", "A policy error occurred."), + POL_USER_NOT_PROVISIONED("POL1009", "User has not been provisioned for service"), + POL_USER_SUSPENDED("POL1010", "User has been suspended from service"), + POL_DETAILED_POLICY_ERROR("POL2000", "The following policy error occurred: %1. Error code is %2."), + POL_MSG_SIZE_EXCEEDS_LIMIT("POL9003", "Message content size exceeds the allowable limit") + + + private final String msgId + private final String msgTxt + + private Error(String msgId, String msgTxt) { + this.msgId = msgId + this.msgTxt = msgTxt + } + + public String getMsgId() { + return msgId + } + + public String getMsgTxt() { + return msgTxt + } + + } + + + + + String mapAdapterExecptionToCommonException(String response, Execution execution) + { + def utils=new MsoUtils() + def method = getClass().getSimpleName() + '.mapAdapterExecptionToCommonException(' + + 'execution=' + execution.getId() + + ')' + + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + utils.log("DEBUG",'Entered ' + method, isDebugLogEnabled) + + + def errorCode + + + try { + errorCode = MapCategoryToErrorCode(utils.getNodeText(response, "category")) + execution.setVariable(prefix+"err",errorCode) + String message = buildException(response, execution) + utils.log("DEBUG","=========== End MapAdapterExecptionToWorkflowException ===========",isDebugLogEnabled) + return message + }catch (Exception ex) { + //Ignore the exception - cases include non xml payload + utils.log("DEBUG","error mapping error, ignoring: " + ex,isDebugLogEnabled) + utils.log("DEBUG","=========== End MapAdapterExecptionToWorkflowException ===========",isDebugLogEnabled) + return buildException(response, execution) + } + } + + /** + * @param response + * @param execution + * @return mapped exception + */ + String mapAOTSExecptionToCommonException(String response, Execution execution) + { + def utils=new MsoUtils() + + def prefix=execution.getVariable("prefix") + def method = getClass().getSimpleName() + '.mapAOTSExecptionToCommonException(' + + 'execution=' + execution.getId() + + ')' + + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + utils.log("DEBUG",'Entered ' + method, isDebugLogEnabled) + + + try { + def errorCode = utils.getNodeText(response,"code") + def descr = utils.getNodeText(response, "description") + def mappedErr = mapErrorCodetoError(errorCode, descr) + if(mappedErr == Error.SVC_DETAILED_SERVICE_ERROR || mappedError == Error.POL_DETAILED_POLICY_ERROR){ + ArrayList myVars = new ArrayList() + myVars.add(descr) + myVars.add(errorCode) + execution.setVariable(prefix+"errVariables", myVars) + } + execution.setVariable(prefix+"err",mappedErr) + def message = buildException("Received error from AOTS: " + descr, execution) + utils.log("DEBUG","=========== End MapAOTSExecptionToCommonException ===========",isDebugLogEnabled) + return message + }catch (Exception ex) { + //Ignore the exception - cases include non xml payload + utils.log("DEBUG","error mapping error, ignoring: " + ex,isDebugLogEnabled) + utils.log("DEBUG","=========== End MapAOTSExecptionToCommonException ===========",isDebugLogEnabled) + return buildException(response, execution) + } + } + + String mapSDNCAdapterExceptionToErrorResponse(String sdncAdapterCallbackRequest, Execution execution) { + def utils=new MsoUtils() + def prefix=execution.getVariable("prefix") + def method = getClass().getSimpleName() + '.mapSDNCAdapterExceptionToErrorResponse(' + + 'execution=' + execution.getId() + + ')' + + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + utils.log("DEBUG",'Entered ' + method, isDebugLogEnabled) + + def sdncResponseCode + String responseCode = execution.getVariable(prefix+"ResponseCode") + utils.log("DEBUG",'responseCode to map: ' + responseCode, isDebugLogEnabled) + def errorMessage + + try { + + if(utils.nodeExists(sdncAdapterCallbackRequest, "RequestData")) { + def reqDataXml = StringEscapeUtils.unescapeXml(utils.getNodeXml(sdncAdapterCallbackRequest, "RequestData")) + errorMessage = utils.getNodeText(reqDataXml, "response-message") + sdncResponseCode = utils.getNodeText(reqDataXml, "response-code") + }else{ + errorMessage = utils.getNodeText(sdncAdapterCallbackRequest, "ResponseMessage") + sdncResponseCode = responseCode + } + def mappedErr = mapErrorCodetoError(responseCode, errorMessage) + errorMessage = errorMessage.replace("&", "&").replace("<", "<").replace(">", ">") + def modifiedErrorMessage = "Received error from SDN-C: " + errorMessage + if(mappedErr == Error.SVC_DETAILED_SERVICE_ERROR || mappedErr == Error.POL_DETAILED_POLICY_ERROR){ + ArrayList myVars = new ArrayList() + myVars.add(errorMessage) + myVars.add(sdncResponseCode) + execution.setVariable(prefix+"errVariables", myVars) + } + execution.setVariable(prefix+"err",mappedErr) + def message = buildException(modifiedErrorMessage, execution) + + + utils.log("DEBUG","=========== End MapSDNCAdapterException ===========",isDebugLogEnabled) + return message + }catch (Exception ex) { + //Ignore the exception - cases include non xml payload + utils.log("DEBUG","error mapping sdnc error, ignoring: " + ex,isDebugLogEnabled) + utils.log("DEBUG","=========== End MapSDNCAdapterException ===========",isDebugLogEnabled) + return null + } + + } + + /** + * @param response message from called component (ex: AAI) + * @param execution + * @return an error response conforming to the common + */ + String mapAAIExceptionTCommonException(String response, Execution execution) + { + def utils=new MsoUtils() + def isDebugLogEnabled=execution.getVariable("isDebugLogEnabled") + def prefix=execution.getVariable("prefix") + def method = getClass().getSimpleName() + '.mapAAIExceptionTCommonException(' + + 'execution=' + execution.getId() + + ')' + + utils.log("DEBUG",'Entered ' + method, isDebugLogEnabled) + def variables + def message + String errorCode = 'SVC0001' + utils.log("DEBUG","response: " + response, isDebugLogEnabled) + //they use the same format we do, pass their error along + //TODO add Received error from A&AI at beg of text + try { + message = utils.getNodeXml(response, "requestError") + message = utils.removeXmlNamespaces(message) + } catch (Exception ex) { + //Ignore the exception - cases include non xml payload + message = buildException("Received error from A&AI, unable to parse",execution) + utils.log("DEBUG","error mapping error, ignoring: " + ex,isDebugLogEnabled) + } + + if(message != null) { + execution.setVariable(prefix+"ErrorResponse",message) + utils.log("ERROR","Fault:"+ execution.getVariable(prefix+"ErrorResponse")) + return message + } else { + + return null + + } + } + + /** + * @param execution + * @return an error response conforming to the common API with default text msg + */ + String buildException(execution){ + return buildException(null, execution) + } + + /** + * @param response message from called component (ex: AAI) + * @param execution + * @return an error response conforming to the common + */ + String buildException(response, execution){ + def utils=new MsoUtils() + def method = getClass().getSimpleName() + '.buildException(' + + 'execution=' + execution.getId() + + ')' + + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + utils.log("DEBUG",'Entered ' + method, isDebugLogEnabled) + def prefix=execution.getVariable("prefix") + def responseCode = String.valueOf(execution.getVariable(prefix+"ResponseCode")) + def variables + utils.log("DEBUG","response: " + response, isDebugLogEnabled) + + try { + utils.log("DEBUG","formatting error message" ,isDebugLogEnabled) + def msgVars = execution.getVariable(prefix+"errVariables") + def myErr = execution.getVariable(prefix+"err") + def messageTxt = execution.getVariable(prefix+"errTxt") + def messageId = null + + if(myErr == null){ + utils.log("DEBUG","mapping response code: " + responseCode, isDebugLogEnabled) + myErr = mapErrorCodetoError(responseCode, response) + if(myErr == null){ + //not a service or policy error, just return error code + return "" + } + } + messageId = myErr.getMsgId() + + if(messageTxt == null){ + if(myErr!=null){ + messageTxt = myErr.getMsgTxt() + }else{ + messageTxt = response + } + } + + if(msgVars==null && (myErr == Error.SVC_DETAILED_SERVICE_ERROR || myErr == Error.POL_DETAILED_POLICY_ERROR)){ + msgVars = new ArrayList() + msgVars.add(response) + msgVars.add(responseCode) + } + + def msgVarsXML="" + StringBuffer msgVarsBuff = new StringBuffer() + if(msgVars!=null){ + for(String msgVar : msgVars){ + msgVarsBuff.append( + """ + <tns:variables>${msgVar}</tns:variables>""") + } + + } + def message = "" + if(messageId.startsWith("SVC")){ + message = """<tns:requestError xmlns:tns="http://org.openecomp/mso/request/types/v1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://org.openecomp/mso/request/types/v1 MsoServiceInstanceTypesV1.xsd"> + <tns:serviceException> + <tns:messageId>${messageId}</tns:messageId> + <tns:text>${messageTxt}</tns:text>${msgVarsBuff} + </tns:serviceException> +</tns:requestError>""" + }else{ + message ="""<tns:requestError xmlns:tns="http://org.openecomp/mso/request/types/v1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://org.openecomp/mso/request/types/v1 MsoServiceInstanceTypesV1.xsd"> + <tns:policyException> + <tns:messageId>${messageId}</tns:messageId> + <tns:text>${messageTxt}</tns:text>${msgVarsBuff} + </tns:policyException> +</tns:requestError>""" + } + utils.log("DEBUG", "message " + message, isDebugLogEnabled) + execution.setVariable(prefix+"ErrorResponse",message) + execution.setVariable(prefix+"err", myErr) + execution.setVariable(prefix+"errTxt", messageTxt) + execution.setVariable(prefix+"errVariables", msgVars) + utils.log("ERROR","Fault:"+ execution.getVariable(prefix+"ErrorResponse")) + return message + }catch(Exception ex) { + utils.log("DEBUG","error mapping error, return null: " + ex,isDebugLogEnabled) + return null + } + + } + + String parseError(Execution execution){ + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + def utils=new MsoUtils() + def prefix=execution.getVariable("prefix") + def text = execution.getVariable(prefix+"errTxt") + def msgVars = execution.getVariable(prefix+"errVariables") + utils.log("DEBUG",'parsing message: ' + text, isDebugLogEnabled) + if(text == null){ + return 'failed' + } + if(msgVars!=null && !msgVars.isEmpty()){ + for(int i=0; i<msgVars.size(); i++){ + text = text.replaceFirst("%"+(i+1), msgVars[i]) + } + } + utils.log("DEBUG",'parsed message is: ' + text, isDebugLogEnabled) + return text + } + + + + Error mapErrorCodetoError(responseCode, descr) + { + + if(responseCode==null || responseCode=='0' || responseCode=='500' || responseCode =='408'){ + return Error.SVC_NO_SERVER_RESOURCES + }else if(responseCode == '401' || responseCode == '405' || responseCode == '409' || responseCode == '503'){ + return null + }else if(responseCode == '400'){ + if(descr==null){ + return Error.SVC_GENERAL_SERVICE_ERROR + }else{ + return Error.SVC_DETAILED_SERVICE_ERROR + } + }else if(responseCode == '401'){ + if(descr==null){ + return Error.POL_GENERAL_POLICY_ERROR + }else{ + return Error.POL_DETAILED_POLICY_ERROR + } + }else{ + return Error.SVC_NO_SERVER_RESOURCES + } + } + + String mapCategoryToErrorCode(String errorCategory) + { + if(errorCategory.equals('OPENSTACK')) + return Error.SVC_NO_SERVER_RESOURCES + else if (errorCategory.equals('IO')) + return Error.SVC_NO_SERVER_RESOURCES + else if (errorCategory.equals('INTERNAL')) + return Error.SVC_NO_SERVER_RESOURCES + else if (errorCategory.equals('USERDATA')) + return Error.SVC_GENERAL_SERVICE_ERROR + else + return Error.SVC_GENERAL_SERVICE_ERROR + } + + + + + + +} diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/CompleteMsoProcess.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/CompleteMsoProcess.groovy new file mode 100644 index 0000000000..e7277b602b --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/CompleteMsoProcess.groovy @@ -0,0 +1,361 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common.scripts + +import org.apache.commons.lang3.* +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.runtime.Execution + + +public class CompleteMsoProcess extends AbstractServiceTaskProcessor { + + String Prefix="CMSO_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + + // Complete MSO Request processing + public initializeProcessVariables(Execution execution){ + + def method = getClass().getSimpleName() + '.initializeProcessVariables(' +'execution=' + execution.getId() +')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logDebug('Entered ' + method, isDebugLogEnabled) + try { + + /* Initialize all the process request variables in this block */ + execution.setVariable("prefix",Prefix) + execution.setVariable("CMSO_request_id","") + execution.setVariable("CMSO_notification-url","") + execution.setVariable("CMSO_mso-bpel-name","") + execution.setVariable("CMSO_request_action","") + execution.setVariable("CMSO_notification-url-Ok", false) + execution.setVariable("CMSO_request_id-Ok", false) + + //updateRequest Adapter process variables + execution.setVariable("CMSO_updateRequestResponse", "") + execution.setVariable("CMSO_updateRequestResponseCode", "") + execution.setVariable("CMSO_updateFinalNotifyAckStatusFailedPayload", "") + + //Set DB adapter variables here + execution.setVariable("CMSO_updateDBStatusToSuccessPayload", "") + execution.setVariable("CMSO_updateInfraRequestDBPayload", "") + execution.setVariable("CMSO_setUpdateDBstatustoSuccessPayload", "") + + //Auth variables + execution.setVariable("BasicAuthHeaderValue","") + + //Response variables + execution.setVariable("CompletionHandlerResponse","") + execution.setVariable("CMSO_ErrorResponse", null) + execution.setVariable("CMSO_ResponseCode", "") + + setSuccessIndicator(execution, false) + + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + logError('Caught exception in ' + method, e) + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error - Occured in" + method) + } + + } + + public void preProcessRequest (Execution execution) { + + initializeProcessVariables(execution) + def method = getClass().getSimpleName() + '.preProcessRequest(' +'execution=' + execution.getId() +')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') +// utils.log("DEBUG", "*** Started CompleteMsoProcess preProcessRequest Method ***", isDebugLogEnabled); + logDebug('Entered ' + method, isDebugLogEnabled) + try { + def xml = execution.getVariable("CompleteMsoProcessRequest") + + utils.logAudit("CompleteMsoProcess Request: " + xml) + utils.log("DEBUG", "Incoming Request is: "+ xml, isDebugLogEnabled) + + //mso-bpel-name from the incoming request + def msoBpelName = utils.getNodeText1(xml,"mso-bpel-name") + execution.setVariable("CMSO_mso-bpel-name",msoBpelName) + + //Check the incoming request type + //Incoming request can be ACTIVE_REQUESTS (request-information node) or INFRA_ACTIVE_REQUESTS (request-info node) + if (utils.nodeExists(xml, "request-information")) { + execution.setVariable("CMSO_request_id-Ok", true) // Incoming request is for ACTIVE_REQUESTS + } + + //Check notification-url for the incoming request type + //ACTIVE_REQUESTS may have notificationurl node + //INFRA_ACTIVE_REQUESTS notificationurl node does not exist + def notificationurl = "" + if (utils.nodeExists(xml, "notification-url")) { + notificationurl = utils.getNodeText(xml,"notification-url") + if(notificationurl != null && !notificationurl.isEmpty()) { + execution.setVariable("CMSO_notification-url-Ok", true) + execution.setVariable("CMSO_notification-url",notificationurl) + } + } + + //Check request_id for the incoming request type + //For INFRA_ACTIVE_REQUESTS payload request-id IS optional (Not sure why this is option since req id is primary key ... also tried exe through SOAP UI to check if MSO code handles null like auto generated seq not it does not) + //For ACTIVE_REQUESTS payload request-id is NOT optional + def request_id = "" + if (utils.nodeExists(xml, "request-id")) { + execution.setVariable("CMSO_request_id",utils.getNodeText(xml,"request-id")) + } + + + // INFRA_ACTIVE_REQUESTS have "action" element ... mandatory + // ACTIVE_REQUEST have "request-action" ... mandatory + if (utils.nodeExists(xml, "request-action")) { + execution.setVariable("CMSO_request_action",utils.getNodeText(xml,"request-action")) + } else if (utils.nodeExists(xml, "action")) { + execution.setVariable("CMSO_request_action",utils.getNodeText(xml,"action")) + } + + //Check source for the incoming request type + //For INFRA_ACTIVE_REQUESTS payload source IS optional + //For ACTIVE_REQUESTS payload source is NOT optional + def source = "" + if (utils.nodeExists(xml, "source")) { + execution.setVariable("CMSO_source",utils.getNodeText(xml,"source")) + } + + utils.log("DEBUG", "CMSO_notification-url-Ok --> " + execution.getVariable("CMSO_notification-url-Ok"), isDebugLogEnabled) + utils.log("DEBUG", "CMSO_request_id-Ok --> " + execution.getVariable("CMSO_request_id-Ok"), isDebugLogEnabled) + + // set the DHV/Service Instantiation values if specified in the request + execution.setVariable("CMSO_is_srv_inst_req", String.valueOf("true".equals(utils.getNodeText1(xml, "is-srv-inst-req")))) + utils.log("DEBUG", "CMSO_is_srv_inst_req --> " + execution.getVariable("CMSO_is_srv_inst_req"), isDebugLogEnabled) + execution.setVariable("CMSO_is_json_content", String.valueOf("JSON".equals(utils.getNodeText1(xml, "resp-content-type")))) + utils.log("DEBUG", "CMSO_is_json_content --> " + execution.getVariable("CMSO_is_json_content"), isDebugLogEnabled) + execution.setVariable("CMSO_service_inst_id", utils.getNodeText1(xml, "service-instance-id")) + utils.log("DEBUG", "CMSO_service_inst_id --> " + execution.getVariable("CMSO_service_inst_id"), isDebugLogEnabled) + execution.setVariable("CMSO_start_time", utils.getNodeText1(xml, "start-time")) + utils.log("DEBUG", "CMSO_start_time --> " + execution.getVariable("CMSO_start_time"), isDebugLogEnabled) + // this variable is used by the camunda flow to set the Content-Type for the async response + if (execution.getVariable("CMSO_is_srv_inst_req").equals("true") && + execution.getVariable("CMSO_is_json_content").equals("true")) { + execution.setVariable("CMSO_content_type", "application/json") + } else { + execution.setVariable("CMSO_content_type", "text/xml") + } + + logDebug('Exited ' + method, isDebugLogEnabled) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + utils.log("DEBUG", "Exception Occured During PreProcessRequest: " + e, isDebugLogEnabled); + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error - Occured in " + method) + } + +// utils.log("DEBUG", "*** Completed CompleteMsoProcess preProcessRequest Method ***", isDebugLogEnabled); + } + + public void postProcessResponse (Execution execution) { + + def method = getClass().getSimpleName() + '.postProcessResponse(' +'execution=' + execution.getId() +')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logDebug('Entered ' + method, isDebugLogEnabled) +// utils.log("DEBUG", "*** Started CompleteMsoProcess PostProcessRequest Method ***", isDebugLogEnabled); + try { + + def msoCompletionResponse = """ + <sdncadapterworkflow:MsoCompletionResponse xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"> + <sdncadapterworkflow:out>BPEL ${execution.getVariable("CMSO_mso-bpel-name")} completed</sdncadapterworkflow:out> + </sdncadapterworkflow:MsoCompletionResponse> + """.trim() + + // Format Response + def xmlMsoCompletionResponse = utils.formatXML(msoCompletionResponse) + String buildMsoCompletionResponseAsString = xmlMsoCompletionResponse.drop(38).trim() + // TODO: Should deprecate use of processKey+Response variable for the response. Will use "WorkflowResponse" instead + execution.setVariable("WorkflowResponse", buildMsoCompletionResponseAsString) + utils.logAudit("CompleteMsoProcess Response: " + buildMsoCompletionResponseAsString) + execution.setVariable("CompleteMsoProcessResponse", buildMsoCompletionResponseAsString) + execution.setVariable("CMSO_ResponseCode", "200") + + setSuccessIndicator(execution, true) + + utils.log("DEBUG", "@@ CompleteMsoProcess Response @@ " + "\n" + execution.getVariable("CompleteMsoProcessResponse"), isDebugLogEnabled) + + logDebug('Exited ' + method, isDebugLogEnabled) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + logError('Caught exception in ' + method, e) + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error - Occured in" + method) + } +// utils.log("DEBUG", "*** Completed CompleteMsoProcess PostProcessRequest Method ***", isDebugLogEnabled); + + } + + public void updateDBStatusToSuccessPayload (Execution execution){ + def method = getClass().getSimpleName() + '.updateDBStatusToSuccessPayload(' +'execution=' + execution.getId() +')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logDebug('Entered ' + method, isDebugLogEnabled) + + try { + // Catalog DB headers Authorization + String basicAuthValueDB = execution.getVariable("URN_mso_adapters_db_auth") + utils.log("DEBUG", " Obtained BasicAuth userid password for Catalog DB adapter: " + basicAuthValueDB, isDebugLogEnabled) + + def encodedString = utils.getBasicAuth(basicAuthValueDB, execution.getVariable("URN_mso_msoKey")) + execution.setVariable("BasicAuthHeaderValueDB",encodedString) + } catch (IOException ex) { + String dataErrorMessage = " Unable to encode Catalog DB user/password string - " + ex.getMessage() + utils.log("DEBUG", dataErrorMessage, isDebugLogEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + } + + try { + + String payload = """ + <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:req="http://org.openecomp.mso/requestsdb"> + <soapenv:Header/> + <soapenv:Body> + <req:updateStatus> + <requestId>${execution.getVariable("CMSO_request_id")}</requestId> + <lastModifiedBy>BPEL</lastModifiedBy> + <status>COMPLETED</status> + </req:updateStatus> + </soapenv:Body> + </soapenv:Envelope> + """ + execution.setVariable("CMSO_updateDBStatusToSuccessPayload", payload) + utils.logAudit("updateDBStatusToSuccessPayload: " + payload) + logDebug('Exited ' + method, isDebugLogEnabled) + //println("CMSO_updateDBStatusToSuccessPayload --> " + execution.getVariable("CMSO_updateDBStatusToSuccessPayload")) + + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + logError('Caught exception in ' + method, e) + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error - Occured in" + method) + } + } + + public void setUpdateDBstatustoSuccessPayload (Execution execution){ + + def method = getClass().getSimpleName() + '.setUpdateDBstatustoSuccessPayload(' +'execution=' + execution.getId() +')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logDebug('Entered ' + method, isDebugLogEnabled) + + try { + String basicAuthValueDB = execution.getVariable("URN_mso_adapters_db_auth") + utils.log("DEBUG", " Obtained BasicAuth userid password for Catalog DB adapter: " + basicAuthValueDB, isDebugLogEnabled) + + def encodedString = utils.getBasicAuth(basicAuthValueDB, execution.getVariable("URN_mso_msoKey")) + execution.setVariable("BasicAuthHeaderValueDB",encodedString) + } catch (IOException ex) { + String dataErrorMessage = " Unable to encode Catalog DB user/password string - " + ex.getMessage() + utils.log("DEBUG", dataErrorMessage, isDebugLogEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + } + + try { + + def xml = execution.getVariable("CompleteMsoProcessRequest") + + //Get statusMessage if exists + def statusMessage + if(utils.nodeExists(xml, "status-message")){ + statusMessage = utils.getNodeText1(xml, "status-message") + }else{ + statusMessage = "Resource Completed Successfully" + } + + //Get instance Id if exist + String idXml = "" + if(utils.nodeExists(xml, "vnfId")){ + idXml = utils.getNodeXml(xml, "vnfId") + }else if(utils.nodeExists(xml, "networkId")){ + idXml = utils.getNodeXml(xml, "networkId") + }else if(utils.nodeExists(xml, "serviceInstanceId")){ + idXml = utils.getNodeXml(xml, "serviceInstanceId") + }else if(utils.nodeExists(xml, "vfModuleId")){ + idXml = utils.getNodeXml(xml, "vfModuleId") + }else if(utils.nodeExists(xml, "volumeGroupId")){ + idXml = utils.getNodeXml(xml, "volumeGroupId") + }else{ + idXml = "" + } + idXml = utils.removeXmlPreamble(idXml) + utils.log("DEBUG", "Incoming Instance Id Xml: " + idXml, isDebugLogEnabled) + + String payload = """ + <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:req="http://org.openecomp.mso/requestsdb"> + <soapenv:Header/> + <soapenv:Body> + <req:updateInfraRequest> + <requestId>${execution.getVariable("CMSO_request_id")}</requestId> + <lastModifiedBy>${execution.getVariable("CMSO_mso-bpel-name")}</lastModifiedBy> + <statusMessage>${statusMessage}</statusMessage> + <requestStatus>COMPLETE</requestStatus> + <progress>100</progress> + ${idXml} + </req:updateInfraRequest> + </soapenv:Body> + </soapenv:Envelope>""" + + execution.setVariable("CMSO_setUpdateDBstatustoSuccessPayload", payload) + utils.log("DEBUG", "Outgoing Update Mso Request Payload is: " + payload, isDebugLogEnabled) + utils.logAudit("setUpdateDBstatustoSuccessPayload: " + payload) + + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + logError('Caught exception in ' + method, e) + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error - Occured in" + method) + } + logDebug('Exited ' + method, isDebugLogEnabled) + } + + public void buildDataError (Execution execution, String message) { + + def method = getClass().getSimpleName() + '.buildDataError(' +'execution=' + execution.getId() +')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logDebug('Entered ' + method, isDebugLogEnabled) + try { + + def msoCompletionResponse = """ + <sdncadapterworkflow:MsoCompletionResponse xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"> + <sdncadapterworkflow:out>BPEL ${execution.getVariable("CMSO_mso-bpel-name")} FAILED</sdncadapterworkflow:out> + </sdncadapterworkflow:MsoCompletionResponse> + """.trim() + + // Format Response + def xmlMsoCompletionResponse = utils.formatXml(msoCompletionResponse) + String buildMsoCompletionResponseAsString = xmlMsoCompletionResponse.drop(38).trim() + utils.logAudit("CompleteMsoProcess Response: " + buildMsoCompletionResponseAsString) + execution.setVariable("CompleteMsoProcessResponse", buildMsoCompletionResponseAsString) + utils.log("DEBUG", "@@ CompleteMsoProcess Response @@ " + "\n" + execution.getVariable("CompletionHandlerResponse"), isDebugLogEnabled) + + exceptionUtil.buildAndThrowWorkflowException(execution, 500, message) + + } catch (BpmnError e) { + utils.log("DEBUG", "Rethrowing MSOWorkflowException", isDebugLogEnabled) + throw e; + } catch (Exception e) { + logError('Caught exception in ' + method, e) + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error - Occured in" + method) + } + + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/ConfirmVolumeGroupName.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/ConfirmVolumeGroupName.groovy new file mode 100644 index 0000000000..0a6f251653 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/ConfirmVolumeGroupName.groovy @@ -0,0 +1,157 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common.scripts +import org.camunda.bpm.engine.runtime.Execution +import org.openecomp.mso.rest.APIResponse + + +public class ConfirmVolumeGroupName extends AbstractServiceTaskProcessor{ + + def Prefix="CVGN_" + + public void initProcessVariables(Execution execution) { + execution.setVariable("prefix",Prefix) + execution.setVariable("CVGN_volumeGroupId",null) + execution.setVariable("CVGN_volumeGroupName",null) + execution.setVariable("CVGN_aicCloudRegion", null) + execution.setVariable("CVGN_volumeGroupGetEndpoint",null) + + // ConfirmVolumeGroupName workflow response variable placeholders + execution.setVariable("CVGN_volumeGroupNameMatches", false) + execution.setVariable("CVGN_queryVolumeGroupResponseCode",null) + execution.setVariable("CVGN_queryVolumeGroupResponse","") + execution.setVariable("CVGN_ResponseCode",null) +// execution.setVariable("CVGN_ErrorResponse","") + execution.setVariable("RollbackData", null) + } + + // store the incoming data in the flow Execution + public void preProcessRequest(Execution execution) { + def isDebugLogEnabled=execution.getVariable("isDebugLogEnabled") + def volumeGroupId = execution.getVariable("ConfirmVolumeGroupName_volumeGroupId") + def volumeGroupName= execution.getVariable("ConfirmVolumeGroupName_volumeGroupName") + def aicCloudRegion = execution.getVariable("ConfirmVolumeGroupName_aicCloudRegion") + + initProcessVariables(execution) + execution.setVariable("CVGN_volumeGroupId", volumeGroupId) + execution.setVariable("CVGN_volumeGroupName", volumeGroupName) + execution.setVariable("CVGN_aicCloudRegion", aicCloudRegion) + + AaiUtil aaiUriUtil = new AaiUtil(this) + def aai_uri = aaiUriUtil.getCloudInfrastructureCloudRegionUri(execution) + logDebug('AAI URI is: ' + aai_uri, isDebugLogEnabled) + utils.logAudit("AAI URI: " + aai_uri) + execution.setVariable("CVGN_volumeGroupGetEndpoint","${aai_uri}/${aicCloudRegion}/volume-groups/volume-group/" + + volumeGroupId) + } + + // send a GET request to AA&I to retrieve the Volume information based on volume-group-id + // expect a 200 response with the information in the response body or a 404 if the volume group id does not exist + public void queryAAIForVolumeGroupId(Execution execution) { + def isDebugLogEnabled=execution.getVariable("isDebugLogEnabled") + def endPoint = execution.getVariable("URN_aai_endpoint") + execution.getVariable("CVGN_volumeGroupGetEndpoint") + + try { + logDebug("invoking GET call to AAI endpoint :"+System.lineSeparator()+endPoint,isDebugLogEnabled) + utils.log("DEBUG","queryAAIForVolumeGroupId() endpoint-" + endPoint, isDebugLogEnabled) + utils.logAudit("ConfirmVolumeGroup sending GET call to AAI Endpoint: " + endPoint) + + AaiUtil aaiUtil = new AaiUtil(this) + APIResponse response = aaiUtil.executeAAIGetCall(execution, endPoint) + def responseData = response.getResponseBodyAsString() + def responseStatusCode = response.getStatusCode() + execution.setVariable("CVGN_queryVolumeGroupResponseCode", responseStatusCode) + execution.setVariable("CVGN_queryVolumeGroupResponse", responseData) + + utils.logAudit("Response code:" + responseStatusCode) + utils.logAudit("Response:" + responseData) + logDebug("Response code:" + responseStatusCode, isDebugLogEnabled) + logDebug("Response:" + System.lineSeparator()+responseData,isDebugLogEnabled) + } catch (Exception ex) { + ex.printStackTrace() + logDebug("Exception occurred while executing AAI GET:" + ex.getMessage(),isDebugLogEnabled) + execution.setVariable("CVGN_queryVolumeGroupResponseCode", 500) + execution.setVariable("CVGN_queryVolumeGroupResponse", "AAI GET Failed:" + ex.getMessage()) + } + } + + // process the result from queryAAIVolumeGroupId() + + public void checkAAIQueryResult(Execution execution) { + def isDebugLogEnabled=execution.getVariable("isDebugLogEnabled") + def result = execution.getVariable("CVGN_queryVolumeGroupResponse") + + if (execution.getVariable("CVGN_queryVolumeGroupResponseCode") == 404) { + logDebug('volumeGroupId does not exist in AAI', isDebugLogEnabled) + } + else if (execution.getVariable("CVGN_queryVolumeGroupResponseCode") == 200) { + logDebug("volumeGroupId exists in AAI", isDebugLogEnabled) + } + def xml = execution.getVariable("CVGN_queryVolumeGroupResponse") + def actualVolumeGroupName = "" + if (utils.nodeExists(xml, "volume-group-name")) { + actualVolumeGroupName = utils.getNodeText(xml, "volume-group-name") + } + execution.setVariable("CVGN_volumeGroupNameMatches", false) + def volumeGroupName = execution.getVariable("CVGN_volumeGroupName") + + if (volumeGroupName.equals(actualVolumeGroupName)) { + logDebug('Volume Group Name Matches AAI records', isDebugLogEnabled) + execution.setVariable("CVGN_volumeGroupNameMatches", true) + } + } + + + // generates a WorkflowException if the A&AI query returns a response code other than 200/404 + public void handleAAIQueryFailure(Execution execution) { + def isDebugLogEnabled=execution.getVariable("isDebugLogEnabled") + + logError("Error occurred attempting to query AAI, Response Code " + + execution.getVariable("CVGN_queryVolumeGroupResponseCode") + ", Error Response " + + execution.getVariable("CVGN_queryVolumeGroupResponse")) + //String processKey = getProcessKey(execution); + //WorkflowException exception = new WorkflowException(processKey, 5000, + //execution.getVariable("CVGN_queryVolumeGroupResponse")) + //execution.setVariable("WorkflowException", exception) + } + + // generates a WorkflowException if the volume group name does not match AAI record for this volume group + public void handleVolumeGroupNameNoMatch(Execution execution) { + def isDebugLogEnabled=execution.getVariable("isDebugLogEnabled") + + def errorNotAssociated = "Error occurred - volume group id " + execution.getVariable("CVGN_volumeGroupId") + + " is not associated with " + execution.getVariable("CVGN_volumeGroupName") + logError(errorNotAssociated) + createWorkflowException(execution, 1002, errorNotAssociated) + //String processKey = getProcessKey(execution); + //WorkflowException exception = new WorkflowException(processKey, 1002, + // errorNotAssociated) + //execution.setVariable("WorkflowException", exception) + } + + // sends a successful WorkflowResponse + public void reportSuccess(Execution execution) { + def isDebugLogEnabled=execution.getVariable("isDebugLogEnabled") + logDebug("Sending 200 back to the caller", isDebugLogEnabled) + def responseXML = "" + execution.setVariable("WorkflowResponse", responseXML) + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/ConfirmVolumeGroupTenant.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/ConfirmVolumeGroupTenant.groovy new file mode 100644 index 0000000000..bca2475a2f --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/ConfirmVolumeGroupTenant.groovy @@ -0,0 +1,195 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common.scripts + +import javax.xml.parsers.DocumentBuilder +import javax.xml.parsers.DocumentBuilderFactory + +import org.apache.commons.lang3.* +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.runtime.Execution +import org.openecomp.mso.bpmn.core.WorkflowException +import org.openecomp.mso.rest.APIResponse +import org.w3c.dom.Document +import org.w3c.dom.Element +import org.w3c.dom.Node +import org.w3c.dom.NodeList +import org.xml.sax.InputSource + + +/** + * Vnf Module Subflow for confirming the volume group belongs + * to the tenant + * + * @param tenantId + * @param volumeGroupId + * + */ +class ConfirmVolumeGroupTenant extends AbstractServiceTaskProcessor{ + + String Prefix="CVGT_" + + public void preProcessRequest(Execution execution){ + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix", Prefix) + utils.log("DEBUG", " ======== STARTED Confirm Volume Group Tenant Subflow ======== ", isDebugEnabled) + String processKey = getProcessKey(execution); + try{ + utils.log("DEBUG", " === Started QueryAAIForVolumeGroup Process === ", isDebugEnabled) + + String volumeGroupId = execution.getVariable("volumeGroupId") + String incomingGroupName = execution.getVariable("volumeGroupName") + String incomingTenantId = execution.getVariable("tenantId") + def aicCloudRegion = execution.getVariable("aicCloudRegion") + String aai = execution.getVariable("URN_aai_endpoint") + + AaiUtil aaiUriUtil = new AaiUtil(this) + def aai_uri = aaiUriUtil.getCloudInfrastructureCloudRegionUri(execution) + logDebug('AAI URI is: ' + aai_uri, isDebugEnabled) + + String path = aai + "${aai_uri}/${aicCloudRegion}/volume-groups/volume-group/" + volumeGroupId + + APIResponse queryAAIForVolumeGroupResponse = aaiUriUtil.executeAAIGetCall(execution, path) + + def responseCode = queryAAIForVolumeGroupResponse.getStatusCode() + execution.setVariable("queryVolumeGroupResponseCode", responseCode) + String response = queryAAIForVolumeGroupResponse.getResponseBodyAsString() + response = StringEscapeUtils.unescapeXml(response) + + utils.logAudit("ConfirmVolumeGroup Response: " + response) + utils.logAudit("ConfirmVolumeGroup Response Code: " + responseCode) + + if(responseCode == 200 && response != null){ + execution.setVariable("queryAAIVolumeGroupResponse", response) + utils.log("DEBUG", "QueryAAIForVolumeGroup Received a Good REST Response is: \n" + response, isDebugEnabled) + + String volumeGroupTenantId = "" + InputSource source = new InputSource(new StringReader(response)); + DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); + docFactory.setNamespaceAware(true) + DocumentBuilder docBuilder = docFactory.newDocumentBuilder() + Document createVCERequestXml = docBuilder.parse(source) + NodeList nodeList = createVCERequestXml.getElementsByTagNameNS("*", "relationship") + for (int x = 0; x < nodeList.getLength(); x++) { + Node node = nodeList.item(x) + if (node.getNodeType() == Node.ELEMENT_NODE) { + Element eElement = (Element) node + String e = eElement.getElementsByTagNameNS("*", "related-to").item(0).getTextContent() + if(e.equals("tenant")){ + NodeList relationDataList = eElement.getElementsByTagNameNS("*", "relationship-data") + for (int d = 0; d < relationDataList.getLength(); d++) { + Node dataNode = relationDataList.item(d) + if (dataNode.getNodeType() == Node.ELEMENT_NODE) { + Element dElement = (Element) dataNode + String key = dElement.getElementsByTagNameNS("*", "relationship-key").item(0).getTextContent() + if(key.equals("tenant.tenant-id")){ + volumeGroupTenantId = dElement.getElementsByTagNameNS("*", "relationship-value").item(0).getTextContent() + } + } + } + } + } + } + + //Determine if Tenant Ids match + if(incomingTenantId.equals(volumeGroupTenantId)){ + utils.log("DEBUG", "Tenant Ids Match", isDebugEnabled) + execution.setVariable("tenantIdsMatch", true) + }else{ + utils.log("DEBUG", "Tenant Ids DO NOT Match", isDebugEnabled) + execution.setVariable("tenantIdsMatch", false) + } + + //Determine if Volume Group Names match + String volumeGroupName = utils.getNodeText1(response, "volume-group-name") + if(incomingGroupName == null || incomingGroupName.length() < 1){ + utils.log("DEBUG", "Incoming Volume Group Name is NOT Provided.", isDebugEnabled) + execution.setVariable("groupNamesMatch", true) + }else{ + utils.log("DEBUG", "Incoming Volume Group Name is: " + incomingGroupName, isDebugEnabled) + if(volumeGroupName.equals(incomingGroupName)){ + utils.log("DEBUG", "Volume Group Names Match.", isDebugEnabled) + execution.setVariable("groupNamesMatch", true) + }else{ + utils.log("DEBUG", "Volume Group Names DO NOT Match.", isDebugEnabled) + execution.setVariable("groupNamesMatch", false) + } + } + }else{ + utils.log("DEBUG", "QueryAAIForVolumeGroup Bad REST Response!", isDebugEnabled) + WorkflowException exception = new WorkflowException(processKey, 1, "Error Searching AAI for Volume Group. Received a Bad Response.") + execution.setVariable("WorkflowException", exception) + throw new BpmnError("MSOWorkflowException") + } + + }catch(Exception e){ + utils.log("ERROR", "Exception Occured Processing queryAAIForVolumeGroup. Exception is:\n" + e, isDebugEnabled) + throw new BpmnError("MSOWorkflowException") + } + utils.log("DEBUG", "=== COMPLETED queryAAIForVolumeGroup Process === ", isDebugEnabled) + } + + public void assignVolumeHeatId(Execution execution){ + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix", Prefix) + try{ + utils.log("DEBUG", " === Started assignVolumeHeatId Process === ", isDebugEnabled) + + String response = execution.getVariable("queryAAIVolumeGroupResponse") + String heatStackId = utils.getNodeText1(response, "heat-stack-id") + execution.setVariable("volumeHeatStackId", heatStackId) + execution.setVariable("ConfirmVolumeGroupTenantResponse", heatStackId) + // TODO: Should deprecate use of processKey+Response variable for the response. Will use "WorkflowResponse" instead + execution.setVariable("WorkflowResponse", heatStackId) + utils.log("DEBUG", "Volume Heat Stack Id is: " + heatStackId, isDebugEnabled) + + }catch(Exception e){ + utils.log("ERROR", "Exception Occured Processing assignVolumeHeatId. Exception is:\n" + e, isDebugEnabled) + throw new BpmnError("MSOWorkflowException") + } + utils.log("DEBUG", "=== COMPLETED assignVolumeHeatId Process === ", isDebugEnabled) + utils.log("DEBUG", "======== COMPLETED Confirm Volume Group Tenant Subflow ======== ", isDebugEnabled) +} + + public void assignWorkflowException(Execution execution, String message){ + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix", Prefix) + String processKey = getProcessKey(execution); + utils.log("DEBUG", " === STARTED Assign Workflow Exception === ", isDebugEnabled) + try{ + String volumeGroupId = execution.getVariable("volumeGroupId") + int errorCode = 1 + String errorMessage = "Volume Group " + volumeGroupId + " " + message + + WorkflowException exception = new WorkflowException(processKey, errorCode, errorMessage) + execution.setVariable("WorkflowException", exception) + execution.setVariable("CVGT_ErrorResponse", "") // Setting for Unit Testing Purposes + + }catch(Exception e){ + utils.log("ERROR", "Exception Occured Processing assignWorkflowException. Exception is:\n" + e, isDebugEnabled) + } + utils.log("DEBUG", "=== COMPLETED Assign Workflow Exception ==== ", isDebugEnabled) + } + + + +} + diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/CreateAAIVfModule.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/CreateAAIVfModule.groovy new file mode 100644 index 0000000000..39383609c8 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/CreateAAIVfModule.groovy @@ -0,0 +1,619 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common.scripts +import org.camunda.bpm.engine.runtime.Execution +import org.openecomp.mso.bpmn.core.RollbackData +import org.openecomp.mso.bpmn.core.WorkflowException +import org.openecomp.mso.rest.APIResponse +import org.springframework.web.util.UriUtils + + +public class CreateAAIVfModule extends AbstractServiceTaskProcessor{ + + def Prefix="CAAIVfMod_" + + public void initProcessVariables(Execution execution) { + execution.setVariable("prefix",Prefix) + execution.setVariable("CAAIVfMod_vnfId",null) + execution.setVariable("CAAIVfMod_vnfName",null) + execution.setVariable("CAAIVfMod_vnfType",null) + execution.setVariable("CAAIVfMod_serviceId",null) + execution.setVariable("CAAIVfMod_personaId",null) + execution.setVariable("CAAIVfMod_personaVer",null) + execution.setVariable("CAAIVfMod_modelCustomizationId",null) + execution.setVariable("CAAIVfMod_vnfPersonaId",null) + execution.setVariable("CAAIVfMod_vnfPersonaVer",null) + execution.setVariable("CAAIVfMod_isBaseVfModule", false) + execution.setVariable("CAAIVfMod_moduleName",null) + execution.setVariable("CAAIVfMod_moduleModelName",null) + execution.setVariable("CAAIVfMod_newGenericVnf",false) + execution.setVariable("CAAIVfMod_genericVnfGetEndpoint",null) + execution.setVariable("CAAIVfMod_genericVnfPutEndpoint",null) + execution.setVariable("CAAIVfMod_aaiNamespace",null) + execution.setVariable("CAAIVfMod_moduleExists",false) + execution.setVariable("CAAIVfMod_baseModuleConflict", false) + execution.setVariable("CAAIVfMod_vnfNameFromAAI", null) + + + // CreateAAIVfModule workflow response variable placeholders + execution.setVariable("CAAIVfMod_queryGenericVnfResponseCode",null) + execution.setVariable("CAAIVfMod_queryGenericVnfResponse","") + execution.setVariable("CAAIVfMod_createGenericVnfResponseCode",null) + execution.setVariable("CAAIVfMod_createGenericVnfResponse","") + execution.setVariable("CAAIVfMod_createVfModuleResponseCode",null) + execution.setVariable("CAAIVfMod_createVfModuleResponse","") + execution.setVariable("CAAIVfMod_parseModuleResponse","") + execution.setVariable("CAAIVfMod_deleteGenericVnfResponseCode",null) + execution.setVariable("CAAIVfMod_deleteGenericVnfResponse","") + execution.setVariable("CAAIVfMod_deleteVfModuleResponseCode",null) + execution.setVariable("CAAIVfMod_deleteVfModuleResponse","") +// execution.setVariable("CAAIVfMod_ResponseCode",null) +// execution.setVariable("CAAIVfMod_ErrorResponse","") + execution.setVariable("CreateAAIVfModuleResponse","") + execution.setVariable("RollbackData", null) + + } + + // parse the incoming CREATE_VF_MODULE request and store the Generic VNF + // and VF Module data in the flow Execution + public void preProcessRequest(Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + initProcessVariables(execution) + + def vnfId = execution.getVariable("vnfId") + if (vnfId == null || vnfId.isEmpty()) { + execution.setVariable("CAAIVfMod_newGenericVnf", true) + execution.setVariable("CAAIVfMod_vnfId","") + } + else { + execution.setVariable("CAAIVfMod_vnfId",vnfId) + } + + def vnfName = execution.getVariable("vnfName") + execution.setVariable("CAAIVfMod_vnfName", vnfName) + + String vnfType = execution.getVariable("vnfType") + if (vnfType != null && !vnfType.isEmpty()) { + execution.setVariable("CAAIVfMod_vnfType", vnfType) + } else { + execution.setVariable("CAAIVfMod_vnfType","") + } + + execution.setVariable("CAAIVfMod_serviceId", execution.getVariable("serviceId")) + + String personaModelId = execution.getVariable("personaModelId") + + if (personaModelId != null && !personaModelId.isEmpty()) { + execution.setVariable("CAAIVfMod_personaId",personaModelId) + } else { + execution.setVariable("CAAIVfMod_personaId","") + } + + String personaModelVersion = execution.getVariable("personaModelVersion") + + if (personaModelVersion != null && !personaModelVersion.isEmpty()) { + execution.setVariable("CAAIVfMod_personaVer", personaModelVersion) + } else { + execution.setVariable("CAAIVfMod_personaVer","") + } + + + String modelCustomizationId = execution.getVariable("modelCustomizationId") + + if (modelCustomizationId != null && !modelCustomizationId.isEmpty()) { + execution.setVariable("CAAIVfMod_modelCustomizationId",modelCustomizationId) + } else { + execution.setVariable("CAAIVfMod_modelCustomizationId","") + } + + String vnfPersonaModelId = execution.getVariable("vnfPersonaModelId") + + if (vnfPersonaModelId != null && !vnfPersonaModelId.isEmpty()) { + execution.setVariable("CAAIVfMod_vnfPersonaId",vnfPersonaModelId) + } else { + execution.setVariable("CAAIVfMod_vnfPersonaId","") + } + + String vnfPersonaModelVersion = execution.getVariable("vnfPersonaModelVersion") + + if (vnfPersonaModelVersion != null && !vnfPersonaModelVersion.isEmpty()) { + execution.setVariable("CAAIVfMod_vnfPersonaVer",vnfPersonaModelVersion) + } else { + execution.setVariable("CAAIVfMod_vnfPersonaVer","") + } + + //isBaseVfModule + Boolean isBaseVfModule = false + String isBaseVfModuleString = execution.getVariable("isBaseVfModule") + if (isBaseVfModuleString != null && isBaseVfModuleString.equals("true")) { + isBaseVfModule = true + } + execution.setVariable("CAAIVfMod_isBaseVfModule", isBaseVfModule) + + String isVidRequest = execution.getVariable("isVidRequest") + if (isVidRequest != null && "true".equals(isVidRequest)) { + logDebug("VID Request received", isDebugEnabled) + } + + execution.setVariable("CAAIVfMod_moduleName",execution.getVariable("vfModuleName")) + execution.setVariable("CAAIVfMod_moduleModelName",execution.getVariable("vfModuleModelName")) + + AaiUtil aaiUriUtil = new AaiUtil(this) + def aai_uri = aaiUriUtil.getNetworkGenericVnfUri(execution) + logDebug('AAI URI is: ' + aai_uri, isDebugEnabled) + String aaiNamespace = aaiUriUtil.getNamespaceFromUri(aai_uri) + logDebug('AAI namespace is: ' + aaiNamespace, isDebugEnabled) + + execution.setVariable("CAAIVfMod_aaiNamespace","${aaiNamespace}") + + if (vnfId == null || vnfId.isEmpty()) { + // TBD - assert that the vnfName is not empty + execution.setVariable("CAAIVfMod_genericVnfGetEndpoint", + "${aai_uri}/?vnf-name=" + + UriUtils.encode(vnfName,"UTF-8") + "&depth=1") + } else { + execution.setVariable("CAAIVfMod_genericVnfGetEndpoint", + "${aai_uri}/" + UriUtils.encode(vnfId,"UTF-8") + "?depth=1") + } + + utils.logAudit("CreateAAIVfModule VNF PUT Endpoint: ${aai_uri}/") + execution.setVariable("CAAIVfMod_genericVnfPutEndpoint","${aai_uri}/") + } + + // send a GET request to AA&I to retrieve the Generic VNF/VF Module information based on a Vnf Name + // expect a 200 response with the information in the response body or a 404 if the Generic VNF does not exist + public void queryAAIForGenericVnf(Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + def endPoint = execution.getVariable("URN_aai_endpoint") + execution.getVariable("CAAIVfMod_genericVnfGetEndpoint") + + try { + utils.log("DEBUG","queryAAIForGenericVnf() endpoint-" + endPoint, isDebugEnabled) + utils.log("DEBUG", "invoking GET call to AAI endpoint :"+System.lineSeparator()+endPoint,isDebugEnabled) + utils.logAudit("CreateAAIVfModule sending GET call to AAI Endpoint: " + endPoint) + + AaiUtil aaiUtil = new AaiUtil(this) + APIResponse response = aaiUtil.executeAAIGetCall(execution, endPoint) + def responseData = response.getResponseBodyAsString() + def statusCode = response.getStatusCode() + execution.setVariable("CAAIVfMod_queryGenericVnfResponseCode", statusCode) + execution.setVariable("CAAIVfMod_queryGenericVnfResponse", responseData) + + utils.logAudit("CreateAAIVfModule Response Code: " + statusCode) + utils.logAudit("CreateAAIVfModule Response data: " + responseData) + utils.log("DEBUG", "Response code:" + statusCode, isDebugEnabled) + utils.log("DEBUG", "Response:" + System.lineSeparator()+responseData,isDebugEnabled) + } catch (Exception ex) { + ex.printStackTrace() + utils.log("DEBUG", "Exception occurred while executing AAI GET:" + ex.getMessage(),isDebugEnabled) + execution.setVariable("CAAIVfMod_queryGenericVnfResponseCode", 500) + execution.setVariable("CAAIVfMod_queryGenericVnfResponse", "AAI GET Failed:" + ex.getMessage()) + } + } + + // process the result from queryAAIForGenericVnf() + // note: this method is primarily for logging as the actual decision logic is embedded in the bpmn flow + public void processAAIGenericVnfQuery(Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + def result = execution.getVariable("CAAIVfMod_queryGenericVnfResponse") + + if (execution.getVariable("CAAIVfMod_queryGenericVnfResponseCode") == 404 && + execution.getVariable("CAAIVfMod_vnfId").isEmpty()) { + utils.log("DEBUG", "New Generic VNF requested and it does not already exist", isDebugEnabled) + } else if (execution.getVariable("CAAIVfMod_queryGenericVnfResponseCode") == 200 && + !execution.getVariable("CAAIVfMod_vnfId").isEmpty()) { + utils.log("DEBUG", "Adding module to existing Generic VNF", isDebugEnabled) + } else if (execution.getVariable("CAAIVfMod_queryGenericVnfResponseCode") == 200 && + execution.getVariable("CAAIVfMod_vnfId").isEmpty()) { + utils.log("DEBUG", "Invalid request for new Generic VNF which already exists", isDebugEnabled) + execution.setVariable("CAAIVfMod_queryGenericVnfResponse", + "Invalid request for new Generic VNF which already exists, Vnf Name=" + + execution.getVariable("CAAIVfMod_vnfName")) + } else { // execution.getVariable("CAAIVfMod_queryGenericVnfResponseCode") == 404 && + // !execution.getVariable("CAAIVfMod_vnfId").isEmpty()) + utils.log("DEBUG", "Invalid request for Add-on Module requested for non-existant Generic VNF", isDebugEnabled) + execution.setVariable("CAAIVfMod_createVfModuleResponse", + "Invalid request for Add-on Module requested for non-existant Generic VNF, VNF Id=" + + execution.getVariable("CAAIVfMod_vnfId")) + } + } + + // construct and send a PUT request to A&AI to create a new Generic VNF + // note: to get here, the vnf-id in the original CREATE_VF_MODULE request was absent or "" + public void createGenericVnf(Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + // TBD - is this how we want to generate the Id for the new Generic VNF? + def newVnfId = UUID.randomUUID().toString() + def endPoint = execution.getVariable("URN_aai_endpoint") + + execution.getVariable("CAAIVfMod_genericVnfPutEndpoint") + newVnfId + // update the flow execution with the new Vnf Id + execution.setVariable("CAAIVfMod_vnfId",newVnfId) + + // AaiUriUtil aaiUriUtil = new AaiUriUtil(this) + // def aai_uri = aaiUriUtil.getNetworkGenericVnfUri(execution) + // logDebug('AAI URI is: ' + aai_uri, isDebugEnabled) + // String namespace = aaiUriUtil.getNamespaceFromUri(aai_uri) + // logDebug('AAI namespace is: ' + namespace, isDebugEnabled) + + + String payload = """<generic-vnf xmlns="${execution.getVariable("CAAIVfMod_aaiNamespace")}"> + <vnf-id>${newVnfId}</vnf-id> + <vnf-name>${execution.getVariable("CAAIVfMod_vnfName")}</vnf-name> + <vnf-type>${execution.getVariable("CAAIVfMod_vnfType")}</vnf-type> + <service-id>${execution.getVariable("CAAIVfMod_serviceId")}</service-id> + <orchestration-status>active</orchestration-status> + <persona-model-id>${execution.getVariable("CAAIVfMod_vnfPersonaId")}</persona-model-id> + <persona-model-version>${execution.getVariable("CAAIVfMod_vnfPersonaVer")}</persona-model-version> + </generic-vnf>""" as String + execution.setVariable("CAAIVfMod_createGenericVnfPayload", payload) + + try { + utils.log("DEBUG","createGenericVnf() endpoint-" + endPoint, isDebugEnabled) + utils.log("DEBUG", "invoking PUT call to AAI with payload:"+System.lineSeparator()+payload,isDebugEnabled) + utils.logAudit("Sending PUT call to AAI with Endpoint /n" + endPoint + " with payload /n" + payload) + + AaiUtil aaiUtil = new AaiUtil(this); + APIResponse response = aaiUtil.executeAAIPutCall(execution, endPoint, payload); + def responseData = response.getResponseBodyAsString() + def responseStatusCode = response.getStatusCode() + execution.setVariable("CAAIVfMod_createGenericVnfResponseCode", responseStatusCode) + execution.setVariable("CAAIVfMod_createGenericVnfResponse", responseData) + + utils.logAudit("Response Code: " + responseStatusCode) + utils.logAudit("Response Data: " + responseData) + utils.log("DEBUG", "Response code:" + responseStatusCode, isDebugEnabled) + utils.log("DEBUG", "Response:" + System.lineSeparator()+responseData,isDebugEnabled) + } catch (Exception ex) { + ex.printStackTrace() + utils.log("DEBUG", "Exception occurred while executing AAI PUT:" + ex.getMessage(),isDebugEnabled) + execution.setVariable("CAAIVfMod_createGenericVnfResponseCode", 500) + execution.setVariable("CAAIVfMod_createGenericVnfResponse", "AAI PUT Failed:" + ex.getMessage()) + } + } + + // construct and send a PUT request to A&AI to create a Base or Add-on VF Module + public void createVfModule(Execution execution, Boolean isBaseModule) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + // TBD - is this how we want to generate the Id for the new (Base) VF Module? + + // Generate the new VF Module ID here if it has not been provided by the parent process + def newModuleId = execution.getVariable('newVfModuleId') + if (newModuleId == null || newModuleId.isEmpty()) { + newModuleId = UUID.randomUUID().toString() + } + def endPoint = execution.getVariable("URN_aai_endpoint") + execution.getVariable("CAAIVfMod_genericVnfPutEndpoint") + // need to append the existing Vnf Id or the one generated in createGenericVnf() to the url + endPoint = endPoint + UriUtils.encode(execution.getVariable("CAAIVfMod_vnfId"), "UTF-8") + + "/vf-modules/vf-module/" + newModuleId; + + // if we get to this point, we may be about to create the Vf Module, + // add rollback information about the Generic VNF for this base/add-on module + def rollbackData = execution.getVariable("RollbackData") + if (rollbackData == null) { + rollbackData = new RollbackData(); + } + rollbackData.put("VFMODULE", "vnfId", execution.getVariable("CAAIVfMod_vnfId")) + rollbackData.put("VFMODULE", "vnfName", execution.getVariable("CAAIVfMod_vnfName")) + rollbackData.put("VFMODULE", "isBaseModule", isBaseModule.toString()) + execution.setVariable("RollbackData", rollbackData) + utils.log("DEBUG", "RollbackData:" + rollbackData, isDebugEnabled) + String payload = """<vf-module xmlns="${execution.getVariable("CAAIVfMod_aaiNamespace")}"> + <vf-module-id>${newModuleId}</vf-module-id> + <vf-module-name>${execution.getVariable("CAAIVfMod_moduleName")}</vf-module-name> + <persona-model-id>${execution.getVariable("CAAIVfMod_personaId")}</persona-model-id> + <persona-model-version>${execution.getVariable("CAAIVfMod_personaVer")}</persona-model-version> + <persona-model-customization-id>${execution.getVariable("CAAIVfMod_modelCustomizationId")}</persona-model-customization-id> + <is-base-vf-module>${isBaseModule}</is-base-vf-module> + <orchestration-status>pending-create</orchestration-status> + </vf-module>""" as String + execution.setVariable("CAAIVfMod_createVfModulePayload", payload) + + try { + utils.log("DEBUG","createVfModule() endpoint-" + endPoint, isDebugEnabled) + utils.log("DEBUG", "invoking PUT call to AAI with payload:"+System.lineSeparator()+payload,isDebugEnabled) + utils.logAudit("CreateAAIVfModule sending PUT call to AAI with endpoint /n" + endPoint + " with payload /n " + payload) + + AaiUtil aaiUtil = new AaiUtil(this) + APIResponse response = aaiUtil.executeAAIPutCall(execution, endPoint, payload) + def responseData = response.getResponseBodyAsString() + def statusCode = response.getStatusCode() + execution.setVariable("CAAIVfMod_createVfModuleResponseCode", statusCode) + execution.setVariable("CAAIVfMod_createVfModuleResponse", responseData) + + utils.log("DEBUG", "Response code:" + statusCode, isDebugEnabled) + utils.log("DEBUG", "Response:" + System.lineSeparator()+responseData,isDebugEnabled) + utils.logAudit("Response Code: " + statusCode) + utils.logAudit("Response data: " + responseData) + // the base or add-on VF Module was successfully created, + // add the module name to the rollback data and the response + if (isOneOf(statusCode, 200, 201)) { + rollbackData.put("VFMODULE", "vfModuleId", newModuleId) + rollbackData.put("VFMODULE", "vfModuleName", execution.getVariable("CAAIVfMod_moduleName")) + execution.setVariable("RollbackData", rollbackData) + utils.log("DEBUG", "RollbackData:" + rollbackData, isDebugEnabled) + + String responseOut = "" + + String isVidRequest = execution.getVariable("isVidRequest") + + if (isBaseModule && (isVidRequest == null || "false".equals(isVidRequest))) { + + responseOut = """<CreateAAIVfModuleResponse> + <vnf-id>${execution.getVariable("CAAIVfMod_vnfId")}</vnf-id> + <vf-module-id>${newModuleId}</vf-module-id> + </CreateAAIVfModuleResponse>""" as String + } + else { + responseOut = """<CreateAAIVfModuleResponse> + <vnf-name>${execution.getVariable("CAAIVfMod_vnfNameFromAAI")}</vnf-name> + <vnf-id>${execution.getVariable("CAAIVfMod_vnfId")}</vnf-id> + <vf-module-id>${newModuleId}</vf-module-id> + </CreateAAIVfModuleResponse>""" as String + } + + execution.setVariable("CreateAAIVfModuleResponse", responseOut) + utils.log("DEBUG", "CreateAAIVfModuleResponse:" + System.lineSeparator()+responseOut,isDebugEnabled) + utils.logAudit("CreateAAIVfModule Response /n " + responseOut) + } + } catch (Exception ex) { + ex.printStackTrace() + utils.log("DEBUG", "Exception occurred while executing AAI PUT:" + ex.getMessage(),isDebugEnabled) + execution.setVariable("CAAIVfMod_createVfModuleResponseCode", 500) + execution.setVariable("CAAIVfMod_createVfModuleResponse", "AAI PUT Failed:" + ex.getMessage()) + } + } + + // parses the output from the result from queryAAIForGenericVnf() to determine if the vf-module-name + // requested for an Add-on VF Module does not already exist for the specified Generic VNF + // also retrieves VNF name from AAI response for existing VNF + public void parseForAddOnModule(Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + def xml = execution.getVariable("CAAIVfMod_queryGenericVnfResponse") + def vnfNameFromAAI = utils.getNodeText1(xml, "vnf-name") + execution.setVariable("CAAIVfMod_vnfNameFromAAI", vnfNameFromAAI) + utils.log("DEBUG", "Obtained vnf-name from AAI for existing VNF: " + vnfNameFromAAI) + def newModuleName = execution.getVariable("CAAIVfMod_moduleName") + utils.log("DEBUG", "VF Module to be added: " + newModuleName, isDebugEnabled) + def qryModuleNameList = utils.getMultNodes(xml, "vf-module-name") + execution.setVariable("CAAIVfMod_moduleExists", false) + if (qryModuleNameList != null) { + utils.log("DEBUG", "Existing VF Module List: " + qryModuleNameList, isDebugEnabled) + for (String qryModuleName : qryModuleNameList) { + if (newModuleName.equals(qryModuleName)) { + // a module with the requested name already exists - failure + utils.log("DEBUG", "VF Module " + qryModuleName + " already exists for Generic VNF " + + execution.getVariable("CAAIVfMod_vnfNameFromAAI"), isDebugEnabled) + execution.setVariable("CAAIVfMod_moduleExists", true) + execution.setVariable("CAAIVfMod_parseModuleResponse", + "VF Module " + qryModuleName + " already exists for Generic VNF " + + execution.getVariable("CAAIVfMod_vnfNameFromAAI")) + break + } + } + } + if (execution.getVariable("CAAIVfMod_moduleExists") == false) { + utils.log("DEBUG", "VF Module " + execution.getVariable("CAAIVfMod_moduleName") + + " does not exist for Generic VNF " + execution.getVariable("CAAIVfMod_vnfNameFromAAI"), isDebugEnabled) + execution.setVariable("CAAIVfMod_parseModuleResponse", + "VF Module " + newModuleName + " does not exist for Generic VNF " + + execution.getVariable("CAAIVfMod_vnfNameFromAAI")) + } + } + + // parses the output from the result from queryAAIForGenericVnf() to determine if the vf-module-name + // requested for an Add-on VF Module does not already exist for the specified Generic VNF; + // also retrieves VNF name from AAI response for existing VNF + public void parseForBaseModule(Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + def xml = execution.getVariable("CAAIVfMod_queryGenericVnfResponse") + def vnfNameFromAAI = utils.getNodeText1(xml, "vnf-name") + execution.setVariable("CAAIVfMod_vnfNameFromAAI", vnfNameFromAAI) + utils.log("DEBUG", "Obtained vnf-name from AAI for existing VNF: " + vnfNameFromAAI) + def newModuleName = execution.getVariable("CAAIVfMod_moduleName") + utils.log("DEBUG", "VF Module to be added: " + newModuleName, isDebugEnabled) + def qryModuleNameList = utils.getMultNodes(xml, "vf-module-name") + execution.setVariable("CAAIVfMod_moduleExists", false) + if (qryModuleNameList != null) { + utils.log("DEBUG", "Existing VF Module List: " + qryModuleNameList, isDebugEnabled) + for (String qryModuleName : qryModuleNameList) { + if (newModuleName.equals(qryModuleName)) { + // a module with the requested name already exists - failure + utils.log("DEBUG", "VF Module " + qryModuleName + " already exists for Generic VNF " + + execution.getVariable("CAAIVfMod_vnfNameFromAAI"), isDebugEnabled) + execution.setVariable("CAAIVfMod_baseModuleConflict", true) + execution.setVariable("CAAIVfMod_parseModuleResponse", + "VF Module " + qryModuleName + " already exists for Generic VNF " + + execution.getVariable("CAAIVfMod_vnfNameFromAAI")) + break + } + } + } + def isBaseVfModuleList = utils.getMultNodes(xml, "is-base-vf-module") + if (isBaseVfModuleList != null && !execution.getVariable("CAAIVfMod_baseModuleConflict")) { + + for (String baseValue : isBaseVfModuleList) { + if (baseValue.equals("true")) { + // a base module already exists in this VNF - failure + utils.log("DEBUG", "Base VF Module already exists for Generic VNF " + + execution.getVariable("CAAIVfMod_vnfNameFromAAI"), isDebugEnabled) + execution.setVariable("CAAIVfMod_baseModuleConflict", true) + execution.setVariable("CAAIVfMod_parseModuleResponse", + "Base VF Module already exists for Generic VNF " + + execution.getVariable("CAAIVfMod_vnfNameFromAAI")) + break + } + } + + } + if (execution.getVariable("CAAIVfMod_moduleExists") == false && execution.getVariable("CAAIVfMod_baseModuleConflict") == false) { + utils.log("DEBUG", "VF Module " + execution.getVariable("CAAIVfMod_moduleName") + + " does not exist for Generic VNF " + execution.getVariable("CAAIVfMod_vnfNameFromAAI"), isDebugEnabled) + execution.setVariable("CAAIVfMod_parseModuleResponse", + "VF Module " + newModuleName + " does not exist for Generic VNF " + + execution.getVariable("CAAIVfMod_vnfNameFromAAI")) + } + } + + // generates a WorkflowException when the A&AI query returns a response code other than 200 or 404 + public void handleAAIQueryFailure(Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + + utils.log("ERROR", "Error occurred attempting to query AAI, Response Code " + + execution.getVariable("CAAIVfMod_queryGenericVnfResponseCode") + ", Error Response " + + execution.getVariable("CAAIVfMod_queryGenericVnfResponse"), isDebugEnabled) + String processKey = getProcessKey(execution); + WorkflowException exception = new WorkflowException(processKey, 5000, + execution.getVariable("CAAIVfMod_queryGenericVnfResponse")) + execution.setVariable("WorkflowException", exception) + } + + // generates a WorkflowException if + // - the A&AI Generic VNF PUT returns a response code other than 200 or 201 + // - the requested Generic VNF already exists but vnf-id == null + // - the requested Generic VNF does not exist but vnf-id != null + // - the A&AI VF Module PUT returns a response code other than 200 or 201 + // - the requested VF Module already exists for the Generic VNF + public void handleCreateVfModuleFailure(Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + + def errorCode + def errorResponse + if (execution.getVariable("CAAIVfMod_createGenericVnfResponseCode") != null && + !isOneOf(execution.getVariable("CAAIVfMod_createGenericVnfResponseCode"), 200, 201)) { + utils.log("DEBUG", "Failure creating Generic VNF: " + + execution.getVariable("CAAIVfMod_createGenericVnfResponse"), isDebugEnabled) + errorResponse = execution.getVariable("CAAIVfMod_createGenericVnfResponse") + errorCode = 5000 + } else if (execution.getVariable("CAAIVfMod_queryGenericVnfResponse") != null && + execution.getVariable("CAAIVfMod_newGenericVnf") == true) { + // attempted to create a Generic VNF that already exists but vnf-id == null + utils.log("DEBUG", execution.getVariable("CAAIVfMod_queryGenericVnfResponse"), isDebugEnabled) + errorResponse = execution.getVariable("CAAIVfMod_queryGenericVnfResponse") + errorCode = 1002 + } else if (execution.getVariable("CAAIVfMod_queryGenericVnfResponseCode") == 404 && + execution.getVariable("CAAIVfMod_newGenericVnf") == false) { + // attempted to create a Generic VNF where vnf-name does not exist but vnf-id != null + utils.log("DEBUG", execution.getVariable("CAAIVfMod_queryGenericVnfResponse"), isDebugEnabled) + errorResponse = execution.getVariable("CAAIVfMod_queryGenericVnfResponse") + errorCode = 1002 + } else if (execution.getVariable("CAAIVfMod_createVfModuleResponseCode") != null) { + utils.log("DEBUG", "Failed to add VF Module: " + + execution.getVariable("CAAIVfMod_createVfModuleResponse"), isDebugEnabled) + errorResponse = execution.getVariable("CAAIVfMod_createVfModuleResponse") + errorCode = 5000 + } else if (execution.getVariable("CAAIVfMod_moduleExists") == true) { + utils.log("DEBUG", "Attempting to add VF Module that already exists: " + + execution.getVariable("CAAIVfMod_parseModuleResponse"), isDebugEnabled) + errorResponse = execution.getVariable("CAAIVfMod_parseModuleResponse") + errorCode = 1002 + } else if (execution.getVariable("CAAIVfMod_baseModuleConflict") == true) { + utils.log("DEBUG", "Attempting to add Base VF Module to VNF that already has a Base VF Module: " + + execution.getVariable("CAAIVfMod_parseModuleResponse"), isDebugEnabled) + errorResponse = execution.getVariable("CAAIVfMod_parseModuleResponse") + errorCode = 1002 + } else { + // if the responses get populated corerctly, we should never get here + errorResponse = "Unknown error occurred during CreateAAIVfModule flow" + errorCode = 2000 + } + + utils.log("ERROR", "Error occurred during CreateAAIVfModule flow: " + errorResponse, isDebugEnabled) + String processKey = getProcessKey(execution); + WorkflowException exception = new WorkflowException(processKey, errorCode, errorResponse) + execution.setVariable("WorkflowException", exception) + utils.logAudit("Workflow exception occurred in CreateAAIVfModule: " + errorResponse) + } + + /** + * Performs a rollback. + * TBD: This method requires additional testing once integrated with the + * main CreateVfModule flow. + * @param execution the execution + */ + public void rollback(Execution execution) { + def method = getClass().getSimpleName() + ".rollback(" + + "execution=" + execution.getId() + + ")" + def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled") + logDebug("Entered " + method, isDebugLogEnabled) + + try { + RollbackData rollbackData = (RollbackData) execution.getVariable("RollbackData") + logDebug("RollbackData:" + rollbackData, isDebugLogEnabled) + + AaiUtil aaiUriUtil = new AaiUtil(this) + def aai_uri = aaiUriUtil.getNetworkGenericVnfUri(execution) + logDebug('AAI URI is: ' + aai_uri, isDebugLogEnabled) + utils.logAudit("CreateAAIVfModule rollback AAI URI: " + aai_uri) + + if (rollbackData != null) { + if (rollbackData.hasType("VFMODULE")) { + // use the DeleteAAIVfModule groovy methods for the rollback + def vnfId = rollbackData.get("VFMODULE", "vnfId") + def vfModuleId = rollbackData.get("VFMODULE", "vfModuleId") + def isBaseModule = rollbackData.get("VFMODULE", "isBaseModule") + execution.setVariable("DAAIVfMod_vnfId", vnfId) + execution.setVariable("DAAIVfMod_vfModuleId", vfModuleId) + execution.setVariable("DAAIVfMod_genericVnfEndpoint", "${aai_uri}/" + vnfId) + execution.setVariable("DAAIVfMod_vfModuleEndpoint", "${aai_uri}/" + vnfId + + "/vf-modules/vf-module/" + vfModuleId) + DeleteAAIVfModule dvm = new DeleteAAIVfModule() + // query A&AI to get the needed information for the delete(s) + dvm.queryAAIForGenericVnf(execution) + dvm.parseForVfModule(execution) + + // roll back the base or add-on module + dvm.deleteVfModule(execution) + def responseCode = execution.getVariable("DAAIVfMod_deleteVfModuleResponseCode") + def response = execution.getVariable("DAAIVfMod_deleteVfModuleResponseCode") + + if (isOneOf(responseCode, 200, 204)) { + logDebug("Received " + responseCode + " to VF Module rollback request", isDebugLogEnabled) +// execution.setVariable("RollbackResult", "SUCCESS") + } else { + logError("Received " + responseCode + " to VF Module rollback request: " + rollbackData + + System.lineSeparator() + "Response: " + response) + } + + // a new Generic VNF was created that needs to be rolled back + if (isBaseModule.equals("true")) { + dvm.deleteGenericVnf(execution) + responseCode = execution.getVariable("DAAIVfMod_deleteGenericVnfResponseCode") + response = execution.getVariable("DAAIVfMod_deleteGenericVnfResponse") + + if (isOneOf(responseCode, 200, 204)) { + logDebug("Received " + responseCode + " to Generic VNF rollback request", isDebugLogEnabled) + execution.setVariable("RollbackResult", "SUCCESS") + } else { + logError("Received " + responseCode + " to Generic VNF rollback request: " + rollbackData + + System.lineSeparator() + "Response: " + response) + } + } else { + execution.setVariable("RollbackResult", "SUCCESS") + } + } + } + + logDebug("Exited " + method, isDebugLogEnabled) + } catch (Exception e) { + logError("Caught exception in " + method, e) + } + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/CreateAAIVfModuleVolumeGroup.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/CreateAAIVfModuleVolumeGroup.groovy new file mode 100644 index 0000000000..03a8596f20 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/CreateAAIVfModuleVolumeGroup.groovy @@ -0,0 +1,332 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common.scripts + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.runtime.Execution +import org.openecomp.mso.rest.APIResponse + + +public class CreateAAIVfModuleVolumeGroup extends AbstractServiceTaskProcessor { + + private XmlParser xmlParser = new XmlParser() + + /** + * Initialize the flow's variables. + * + * @param execution The flow's execution instance. + */ + public void initProcessVariables(Execution execution) { + execution.setVariable('prefix', 'CAAIVfModVG_') + execution.setVariable('CAAIVfModVG_vnfId', null) + execution.setVariable('CAAIVfModVG_vfModuleId', null) + execution.setVariable('CAAIVfModVG_aicCloudRegion', null) + execution.setVariable('CAAIVfModVG_volumeGroupId', null) + execution.setVariable('CAAIVfModVG_getVfModuleResponseCode' ,null) + execution.setVariable('CAAIVfModVG_getVfModuleResponse', '') + execution.setVariable('CAAIVfModVG_updateVfModuleResponseCode', null) + execution.setVariable('CAAIVfModVG_updateVfModuleResponse', '') + } + + /** + * Check for missing elements in the received request. + * + * @param execution The flow's execution instance. + */ + public void preProcessRequest(Execution execution) { + def method = getClass().getSimpleName() + '.preProcessRequest(' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logDebug('Entered ' + method, isDebugLogEnabled) + + try { + def xml = execution.getVariable('CreateAAIVfModuleVolumeGroupRequest') + logDebug('Received request xml:\n' + xml, isDebugLogEnabled) + utils.logAudit("CreateAAIVfModuleVolume Received Request XML: " + xml) + initProcessVariables(execution) + + def vnfId = getRequiredNodeText(execution, xml,'vnf-id') + execution.setVariable('CAAIVfModVG_vnfId', vnfId) + + def vfModuleId = getRequiredNodeText(execution, xml,'vf-module-id') + execution.setVariable('CAAIVfModVG_vfModuleId', vfModuleId) + + def aicCloudRegion = getRequiredNodeText(execution, xml,'aic-cloud-region') + execution.setVariable('CAAIVfModVG_aicCloudRegion', aicCloudRegion) + + def volumeGroupId = getRequiredNodeText(execution, xml,'volume-group-id') + execution.setVariable('CAAIVfModVG_volumeGroupId', volumeGroupId) + + logDebug('Exited ' + method, isDebugLogEnabled) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + logError('Caught exception in ' + method, e) + createWorkflowException(execution, 1002, 'Error in preProcessRequest(): ' + e.getMessage()) + } + } + + /** + * Using the received vnfId and vfModuleId, query AAI to get the corresponding VF Module. + * A 200 response is expected with the VF Module in the response body. + * + * @param execution The flow's execution instance. + */ + public void getVfModule(Execution execution) { + def method = getClass().getSimpleName() + '.getVfModule(' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logDebug('Entered ' + method, isDebugLogEnabled) + + try { + def vnfId = execution.getVariable('CAAIVfModVG_vnfId') + def vfModuleId = execution.getVariable('CAAIVfModVG_vfModuleId') + + // Construct endpoint + AaiUtil aaiUtil = new AaiUtil(this) + def aai_uri = aaiUtil.getNetworkGenericVnfUri(execution) + logDebug('AAI URI is: ' + aai_uri, isDebugLogEnabled) + String endPoint = execution.getVariable('URN_aai_endpoint') + aai_uri + '/' + URLEncoder.encode(vnfId, "UTF-8") + '/vf-modules/vf-module/' + URLEncoder.encode(vfModuleId, "UTF-8") + + try { + logDebug('sending GET to AAI endpoint \'' + endPoint + '\'', isDebugLogEnabled) + utils.logAudit("aaiResponse GET TO AAI Endpoint: " + endPoint) + APIResponse response = aaiUtil.executeAAIGetCall(execution, endPoint) + def responseData = response.getResponseBodyAsString() + execution.setVariable('CAAIVfModVG_getVfModuleResponseCode', response.getStatusCode()) + execution.setVariable('CAAIVfModVG_getVfModuleResponse', responseData) + + utils.logAudit("CreateAAIVfModule Response Code: " + response.getStatusCode()) + utils.logAudit("CreateAAIVfModule Response: " + response) + logDebug('Response code:' + response.getStatusCode(), isDebugLogEnabled) + logDebug('Response:' + System.lineSeparator() + responseData, isDebugLogEnabled) + } catch (Exception ex) { + ex.printStackTrace() + logDebug('Exception occurred while executing AAI GET:' + ex.getMessage(),isDebugLogEnabled) + execution.setVariable('CAAIVfModVG_getVfModuleResponseCode', 500) + execution.setVariable('CAAIVfModVG_getVfModuleResponse', 'AAI GET Failed:' + ex.getMessage()) + } + logDebug('Exited ' + method, isDebugLogEnabled) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + logError('Caught exception in ' + method, e) + createWorkflowException(execution, 1002, 'Error in getVfModule(): ' + e.getMessage()) + } + } + + /** + * Construct and send a PUT request to AAI to update the VF Module with the + * created Volume Group relationship. + * + * @param execution The flow's execution instance. + */ + public void updateVfModule(Execution execution) { + def method = getClass().getSimpleName() + '.updateVfModule(' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logDebug('Entered ' + method, isDebugLogEnabled) + + try { + def vnfId = execution.getVariable('CAAIVfModVG_vnfId') + def vfModuleId = execution.getVariable('CAAIVfModVG_vfModuleId') + def vfModule = execution.getVariable('CAAIVfModVG_getVfModuleResponse') + def origRequest = execution.getVariable('CreateAAIVfModuleVolumeGroupRequest') + def Node vfModuleNode = xmlParser.parseText(vfModule) + + // Confirm resource-version is in retrieved VF Module + if (utils.getChildNode(vfModuleNode, 'resource-version') == null) { + def msg = 'Can\'t update VF Module ' + vfModuleId + ' since \'resource-version\' is missing' + logError(msg) + throw new Exception(msg) + } + + // Construct payload by creating a Volume Group relationhip and inserting it into the VF Module + def aicCloudRegion = execution.getVariable('CAAIVfModVG_aicCloudRegion') + def volumeGroupId = execution.getVariable('CAAIVfModVG_volumeGroupId') + def Node vgRelationshipNode = createVolumeGroupRelationshipNode(aicCloudRegion, volumeGroupId) + insertVolumeGroupRelationshipNode(vfModuleNode, vgRelationshipNode) + def payload = utils.nodeToString(vfModuleNode) + + // Construct endpoint + AaiUtil aaiUtil = new AaiUtil(this) + def aai_uri = aaiUtil.getNetworkGenericVnfUri(execution) + logDebug('AAI URI is: ' + aai_uri, isDebugLogEnabled) + String endPoint = execution.getVariable('URN_aai_endpoint') + aai_uri + '/' + URLEncoder.encode(vnfId, "UTF-8") + '/vf-modules/vf-module/' + URLEncoder.encode(vfModuleId, "UTF-8") + + try { + utils.logAudit("CreateAAIVfModuleVolume Sendind PUT to AAI Endpoint \n " + endPoint + " with payload \n " + payload) + logDebug('sending PUT to AAI endpoint \'' + endPoint + '\'' + 'with payload \n' + payload, isDebugLogEnabled) + APIResponse response = aaiUtil.executeAAIPutCall(execution, endPoint, payload) + def responseData = response.getResponseBodyAsString() + execution.setVariable('CAAIVfModVG_updateVfModuleResponseCode', response.getStatusCode()) + execution.setVariable('CAAIVfModVG_updateVfModuleResponse', responseData) + + utils.logAudit("CreateAAIVfModule Response code: " + response.getStatusCode()) + utils.logAudit("CreateAAIVfModule Response: " + responseData) + logDebug('Response code:' + response.getStatusCode(), isDebugLogEnabled) + logDebug('Response:' + System.lineSeparator() + responseData, isDebugLogEnabled) + } catch (Exception ex) { + ex.printStackTrace() + logDebug('Exception occurred while executing AAI PUT:' + ex.getMessage(),isDebugLogEnabled) + execution.setVariable('CAAIVfModVG_updateVfModuleResponseCode', 500) + execution.setVariable('CAAIVfModVG_updateVfModuleResponse', 'AAI PUT Failed:' + ex.getMessage()) + } + logDebug('Exited ' + method, isDebugLogEnabled) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + logError('Caught exception in ' + method, e) + createWorkflowException(execution, 1002, 'Error in updateVfModule(): ' + e.getMessage()) + } + } + + /** + * Construct a Volume Group relationship Node with the given AIC Cloud Region and + * Volume Group ID for insertion into a VF Module. + * + * @param aicCloudRegion Cloud Region ID to use in the Volume Group relationship + * @param volumeGroupId Volume Group ID to use in the Volume Group relationship + * @return a Node representing the new Volume Group relationship + */ + private Node createVolumeGroupRelationshipNode(String aicCloudRegion, String volumeGroupId) { + + def Node relatedTo = new Node(null, 'related-to', 'volume-group') + + def Node relationshipKeyCO = new Node(null, 'relationship-key', 'cloud-region.cloud-owner') + def Node relationshipValueCO = new Node(null, 'relationship-value', 'att-aic') + def Node relationshipDataCO = new Node(null, 'relationship-data') + relationshipDataCO.append(relationshipKeyCO) + relationshipDataCO.append(relationshipValueCO) + + def Node relationshipKeyCRI = new Node(null, 'relationship-key', 'cloud-region.cloud-region-id') + def Node relationshipValueCRI = new Node(null, 'relationship-value', aicCloudRegion) + def Node relationshipDataCRI = new Node(null, 'relationship-data') + relationshipDataCRI.append(relationshipKeyCRI) + relationshipDataCRI.append(relationshipValueCRI) + + def Node relationshipKeyVGI = new Node(null, 'relationship-key', 'volume-group.volume-group-id') + def Node relationshipValueVGI = new Node(null, 'relationship-value', volumeGroupId) + def Node relationshipDataVGI = new Node(null, 'relationship-data') + relationshipDataVGI.append(relationshipKeyVGI) + relationshipDataVGI.append(relationshipValueVGI) + + def Node volumeGroupRelationship = new Node(null, 'relationship') + volumeGroupRelationship.append(relatedTo) + volumeGroupRelationship.append(relationshipDataCO) + volumeGroupRelationship.append(relationshipDataCRI) + volumeGroupRelationship.append(relationshipDataVGI) + + return volumeGroupRelationship; + } + + /** + * Insert the given Volume Group relationship Node into the given VF Module. + * If the VF Module does NOT contain a relationship list: + * - Create a relationship list containing the Volume Group relationship and insert it into the VF Module + * If the VF Module contains a relationship list but not a Volume Group relationship: + * - Insert the the Volume Group relationship into the relationship lsit + * If the VF Module contains a relationship list and has a Volume Group relationship: + * - Replace the existing Volume Group relationship with the new one + * @param vfModuleNode + * @param volumeGroupRelationshipNode + */ + private void insertVolumeGroupRelationshipNode(Node vfModuleNode, Node volumeGroupRelationshipNode) { + def Node relationshipList = utils.getChildNode(vfModuleNode, 'relationship-list') + if (relationshipList == null) { + relationshipList = new Node(null, 'relationship-list') + relationshipList.append(volumeGroupRelationshipNode) + vfModuleNode.append(relationshipList) + } else { + def Node currVolumeGroupRelationshipNode = getCurrVolumeGroupRelationshipNode(relationshipList) + if (currVolumeGroupRelationshipNode == null) { + relationshipList.append(volumeGroupRelationshipNode) + } else { + currVolumeGroupRelationshipNode.replaceNode(volumeGroupRelationshipNode) + } + } + } + + /** + * Find and return the value of the Volume Group ID for the specified VF Module. If + * the value of the Volume Group ID cannot be found for any reason, 'null' is returned. + * + * @param vfModuleNode VF Module (as a Node) retrieved from AAI. + * @return the value of the Volume Group ID for the specified VF Module. If the + * value of the Volume Group ID cannot be found for any reason, 'null' is returned. + */ + private Node getCurrVolumeGroupRelationshipNode(Node relationshipList) { + def Node currVolumeGroupRelationshipNode = null + def NodeList relationships = utils.getIdenticalChildren(relationshipList, 'relationship') + for (Node relationshipNode in relationships) { + def String relatedTo = utils.getChildNodeText(relationshipNode, 'related-to') + if ((relatedTo != null) && relatedTo.equals('volume-group')) { + currVolumeGroupRelationshipNode = relationshipNode + } + } + return currVolumeGroupRelationshipNode + } + + /** + * Generates a WorkflowException if the AAI query returns a response code other than 200. + * + * @param execution The flow's execution instance. + */ + public void handleAAIQueryFailure(Execution execution) { + def method = getClass().getSimpleName() + '.handleAAIQueryFailure(' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logDebug('Entered ' + method, isDebugLogEnabled) + + logError('Error occurred attempting to query AAI, Response Code ' + + execution.getVariable('CAAIVfModVG_getVfModuleResponseCode') + ', Error Response ' + + execution.getVariable('CAAIVfModVG_getVfModuleResponse')) + ExceptionUtil exceptionUtil = new ExceptionUtil() + exceptionUtil.buildWorkflowException(execution, 5000, execution.getVariable('CAAIVfModVG_getVfModuleResponse')) + + logDebug('Exited ' + method, isDebugLogEnabled) + } + + /** + * Generates a WorkflowException if updating a VF Module in AAI returns a response code other than 200. + * + * @param execution The flow's execution instance. + */ + public void handleUpdateVfModuleFailure(Execution execution) { + def method = getClass().getSimpleName() + '.handleUpdateVfModuleFailure(' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logDebug('Entered ' + method, isDebugLogEnabled) + + logError('Error occurred attempting to update VF Module in AAI, Response Code ' + + execution.getVariable('CAAIVfModVG_updateVfModuleResponseCode') + ', Error Response ' + + execution.getVariable('CAAIVfModVG_updateVfModuleResponse')) + ExceptionUtil exceptionUtil = new ExceptionUtil() + exceptionUtil.buildWorkflowException(execution, 5000, execution.getVariable('CAAIVfModVG_updateVfModuleResponse')) + + logDebug('Exited ' + method, isDebugLogEnabled) + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/CreateGenericVNFUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/CreateGenericVNFUtils.groovy new file mode 100644 index 0000000000..ffc706d263 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/CreateGenericVNFUtils.groovy @@ -0,0 +1,280 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.openecomp.mso.bpmn.common.scripts + +import org.openecomp.mso.bpmn.core.WorkflowException +import org.openecomp.mso.rest.APIResponse; + +import org.camunda.bpm.engine.runtime.Execution; +import org.camunda.bpm.engine.delegate.BpmnError + +/** + * Please describe the CreateGenericVNFUtils.groovy class + * + */ +class CreateGenericVNFUtils{ + + String Prefix="CRTGVNF_" + + def utils=new MsoUtils() + + private AbstractServiceTaskProcessor taskProcessor + + public CreateGenericVNFUtils(AbstractServiceTaskProcessor taskProcessor) { + this.taskProcessor = taskProcessor + } + + /** + * This method is executed during the Initialization task of the process. + * + * @param execution + * + */ + + public APIResponse queryAAI(Execution execution, String path){ + + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix", Prefix) + utils.log("DEBUG", " ======== STARTED queryAAI Process ======== ", isDebugEnabled) + + def uuid = execution.getVariable("CRTGVNF_uuid") + utils.log("DEBUG", "UUID is: " + uuid, isDebugEnabled) + + //Setting request path + String queryAAIRequestPath = execution.getVariable("URN_aai_endpoint")+path +// execution.setVariable("CRTGVNF_queryAAIRequestPath", queryAAIRequestPath) + utils.log("DEBUG", "QueryAAIRequest Path is: " + "\n" + queryAAIRequestPath, isDebugEnabled) + + try { + AaiUtil aaiUtil = new AaiUtil(taskProcessor) + return aaiUtil.executeAAIGetCall(execution, queryAAIRequestPath) + }catch(Exception e){ + utils.log("ERROR", "Exception Occured Processing queryAAI. Exception is:\n" + e, isDebugEnabled) + execution.setVariable("CRTGVNF_dataValidationFlag", false) + execution.setVariable("CRTGVNF_ErrorResponse", "Error Occured during queryAAI Method:\n" + e.getMessage()) + } + utils.log("DEBUG", "======== COMPLETED queryAAI Process ======== ", isDebugEnabled) +} + + public String buildSDNCRequest(Execution execution, String svcInstId, String action){ + + String uuid = execution.getVariable('testReqId') // for junits + if(uuid==null){ + uuid = execution.getVariable("att-mso-request-id") + "-" + System.currentTimeMillis() + } + def callbackURL = execution.getVariable("CRTGVNF_sdncCallbackUrl") + def requestId = execution.getVariable("CRTGVNF_requestId") + def serviceType = execution.getVariable("CRTGVNF_serviceType") + def vnfType = execution.getVariable("CRTGVNF_vnfType") + def vnfName = execution.getVariable("CRTGVNF_vnfName") + def tenantId = execution.getVariable("CRTGVNF_tenantId") + def source = execution.getVariable("CRTGVNF_source") + String vnfId = svcInstId + String sdncVNFParamsXml = "" + + if(execution.getVariable("CRTGVNF_vnfParamsExistFlag") == true){ + sdncVNFParamsXml = buildSDNCParamsXml(execution) + }else{ + sdncVNFParamsXml = "" + } + + String sdncRequest = + """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://ecomp.att.com/mso/request/types/v1" + xmlns:sdncadapterworkflow="http://ecomp.att.com/mso/workflow/schema/v1" + xmlns:sdncadapter="http://domain2.att.com/workflow/sdnc/adapter/schema/v1"> + <sdncadapter:RequestHeader> + <sdncadapter:RequestId>${uuid}</sdncadapter:RequestId> + <sdncadapter:SvcInstanceId>${svcInstId}</sdncadapter:SvcInstanceId> + <sdncadapter:SvcAction>${action}</sdncadapter:SvcAction> + <sdncadapter:SvcOperation>vnf-topology-operation</sdncadapter:SvcOperation> + <sdncadapter:CallbackUrl>${callbackURL}</sdncadapter:CallbackUrl> + </sdncadapter:RequestHeader> + <sdncadapterworkflow:SDNCRequestData> + <request-information> + <request-id>${requestId}</request-id> + <request-action>VNFActivateRequest</request-action> + <source>${source}</source> + </request-information> + <service-information> + <service-type>${serviceType}</service-type> + <service-instance-id>${vnfId}</service-instance-id> + <subscriber-name>notsurewecare</subscriber-name> + </service-information> + <vnf-request-information> + <vnf-id>${vnfId}</vnf-id> + <vnf-type>${vnfType}</vnf-type> + <vnf-name>${vnfName}</vnf-name> + <tenant>${tenantId}</tenant> +${sdncVNFParamsXml} + </vnf-request-information> + </sdncadapterworkflow:SDNCRequestData> + </sdncadapterworkflow:SDNCAdapterWorkflowRequest>""" + + return sdncRequest + + } + + public String buildSDNCParamsXml(Execution execution){ + + String params = "" + StringBuilder sb = new StringBuilder() + Map<String, String> paramsMap = execution.getVariable("CRTGVNF_vnfParamsMap") + + for (Map.Entry<String, String> entry : paramsMap.entrySet()) { + String paramsXml + String key = entry.getKey(); + if(key.endsWith("_network")){ + String requestKey = key.substring(0, key.indexOf("_network")) + String requestValue = entry.getValue() + paramsXml = +"""<vnf-networks> + <network-role>{ functx:substring-before-match(data($param/@name), '_network') }</network-role> + <network-name>{ $param/text() }</network-name> +</vnf-networks>""" + }else{ + paramsXml = "" + } + params = sb.append(paramsXml) + } + return params + } + + /** + * Builds a "CompletionHandler" request and stores it in the specified + * execution variable. + * @param execution the execution + */ + public void buildCompletionHandlerRequest(Execution execution, String flowName) { + def method = getClass().getSimpleName() + '.completionHandlerPrep(' + + 'execution=' + execution.getId() + + ')' + def prefix = execution.getVariable('prefix') + def resultVar = prefix + "CompletionHandlerRequest" + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + taskProcessor.logDebug('Entered ' + method, isDebugLogEnabled) + + try { + def request = taskProcessor.getVariable(execution, prefix+'Request') + def requestInformation = taskProcessor.utils.getNodeXml(request, 'request-information', false) + if (requestInformation == null || requestInformation == ""){ + requestInformation = taskProcessor.utils.getNodeXml(request, 'request-info', false) + } + + String content = """ + <sdncadapterworkflow:MsoCompletionRequest xmlns:sdncadapterworkflow="http://ecomp.att.com/mso/workflow/schema/v1" + xmlns:reqtype="http://ecomp.att.com/mso/request/types/v1"> + ${requestInformation} + <sdncadapterworkflow:mso-bpel-name>${flowName}</sdncadapterworkflow:mso-bpel-name> + </sdncadapterworkflow:MsoCompletionRequest> + """ + + content = taskProcessor.utils.removeXmlPreamble(taskProcessor.utils.formatXML(content)) + taskProcessor.logDebug(resultVar + ' = ' + System.lineSeparator() + content, isDebugLogEnabled) + execution.setVariable(resultVar, content) + + taskProcessor.logDebug('Exited ' + method, isDebugLogEnabled) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + taskProcessor.logError('Caught exception in ' + method, e) + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error Occured during completion handler request") + } + } + + /** + * Builds a "FalloutHandler" request and stores it in the specified + * execution variable. + * @param execution the execution + */ + public void buildfalloutHandlerRequest(Execution execution) { + def method = getClass().getSimpleName() + '.falloutHandlerPrep(' + + 'execution=' + execution.getId() + + ')' + def prefix = execution.getVariable('prefix') + def resultVar = prefix + "FalloutHandlerRequest" + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + taskProcessor.logDebug('Entered ' + method, isDebugLogEnabled) + try { + def request = taskProcessor.getVariable(execution, prefix+'Request') + + def requestInformation = "" + if (request != null){ + requestInformation = taskProcessor.utils.getNodeXml(request, 'request-information', false) + if (requestInformation == null || requestInformation == ""){ + requestInformation = taskProcessor.utils.getNodeXml(request, 'request-info', false) + } + } + def errorInformation = "" + def encErrorResponseMsg = "" + def errorResponseCode = "" + String content = "" + + def WorkflowException workflowException + def exception = execution.getVariable("WorkflowException") + + if (exception instanceof WorkflowException) + { + workflowException = execution.getVariable("WorkflowException") + } + + if (workflowException != null){ + errorResponseCode = workflowException.getErrorCode() + def errorResponseMsg = workflowException.getErrorMessage() + + if (errorResponseMsg != null) { + encErrorResponseMsg = errorResponseMsg.replace("&", "&").replace("<", "<").replace(">", ">") + } + + errorInformation = """<aetgt:WorkflowException xmlns:aetgt="http://ecomp.att.com/mso/workflow/schema/v1"> + <aetgt:ErrorMessage>${encErrorResponseMsg}</aetgt:ErrorMessage> + <aetgt:ErrorCode>${errorResponseCode}</aetgt:ErrorCode> + </aetgt:WorkflowException>""" + } + else { + errorInformation = execution.getVariable(prefix+'ErrorResponse') + + if (errorInformation == null) errorInformation = "" + } + + content = """ + <wfsch:FalloutHandlerRequest xmlns:wfsch="http://ecomp.att.com/mso/workflow/schema/v1" + xmlns:reqtype="http://ecomp.att.com/mso/request/types/v1"> + ${requestInformation} + ${errorInformation} + </wfsch:FalloutHandlerRequest> + """ + + content = taskProcessor.utils.removeXmlPreamble(taskProcessor.utils.formatXML(content)) + + taskProcessor.logDebug(resultVar + ' = ' + System.lineSeparator() + content, isDebugLogEnabled) + execution.setVariable(resultVar, content) + taskProcessor.logDebug('Exited ' + method, isDebugLogEnabled) + } catch (Exception e) { + taskProcessor.logError('Caught exception in ' + method, e) + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error in buildfalloutHandlerRequest") + } + } + +} + + + + + diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/DeleteAAIVfModule.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/DeleteAAIVfModule.groovy new file mode 100644 index 0000000000..ca9a2e0849 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/DeleteAAIVfModule.groovy @@ -0,0 +1,334 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common.scripts +import org.camunda.bpm.engine.runtime.Execution +import org.openecomp.mso.bpmn.core.WorkflowException +import org.openecomp.mso.rest.APIResponse + + +public class DeleteAAIVfModule extends AbstractServiceTaskProcessor{ + + def Prefix="DAAIVfMod_" + + public void initProcessVariables(Execution execution) { + execution.setVariable("prefix",Prefix) + execution.setVariable("DAAIVfMod_vnfId",null) + execution.setVariable("DAAIVfMod_vnfName",null) + execution.setVariable("DAAIVfMod_genVnfRsrcVer",null) + execution.setVariable("DAAIVfMod_vfModuleId",null) + execution.setVariable("DAAIVfMod_vfModRsrcVer",null) + execution.setVariable("DAAIVfMod_genericVnfEndpoint",null) + execution.setVariable("DAAIVfMod_vfModuleEndpoint",null) + execution.setVariable("DAAIVfMod_moduleExists",false) + execution.setVariable("DAAIVfMod_isBaseModule", false) + execution.setVariable("DAAIVfMod_isLastModule", false) + + // DeleteAAIVfModule workflow response variable placeholders + execution.setVariable("DAAIVfMod_queryGenericVnfResponseCode",null) + execution.setVariable("DAAIVfMod_queryGenericVnfResponse","") + execution.setVariable("DAAIVfMod_parseModuleResponse","") + execution.setVariable("DAAIVfMod_deleteGenericVnfResponseCode",null) + execution.setVariable("DAAIVfMod_deleteGenericVnfResponse","") + execution.setVariable("DAAIVfMod_deleteVfModuleResponseCode",null) + execution.setVariable("DAAIVfMod_deleteVfModuleResponse","") + + } + + // parse the incoming DELETE_VF_MODULE request and store the Generic Vnf + // and Vf Module Ids in the flow Execution + public void preProcessRequest(Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + def xml = execution.getVariable("DeleteAAIVfModuleRequest") + utils.logAudit("DeleteAAIVfModule Request: " + xml) + utils.log("DEBUG", "input request xml:" + xml, isDebugEnabled) + initProcessVariables(execution) + def vnfId = utils.getNodeText(xml,"vnf-id") + def vfModuleId = utils.getNodeText(xml,"vf-module-id") + execution.setVariable("DAAIVfMod_vnfId", vnfId) + execution.setVariable("DAAIVfMod_vfModuleId", vfModuleId) + + AaiUtil aaiUriUtil = new AaiUtil(this) + def aai_uri = aaiUriUtil.getNetworkGenericVnfUri(execution) + logDebug('AAI URI is: ' + aai_uri, isDebugEnabled) + + execution.setVariable("DAAIVfMod_genericVnfEndpoint", "${aai_uri}/" + vnfId) + execution.setVariable("DAAIVfMod_vfModuleEndpoint", "${aai_uri}/" + vnfId + + "/vf-modules/vf-module/" + vfModuleId) + } + + // send a GET request to AA&I to retrieve the Generic Vnf/Vf Module information based on a Vnf Id + // expect a 200 response with the information in the response body or a 404 if the Generic Vnf does not exist + public void queryAAIForGenericVnf(Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + def delModuleId = execution.getVariable("DAAIVfMod_vfModuleId") + def endPoint = execution.getVariable("URN_aai_endpoint") + execution.getVariable("DAAIVfMod_genericVnfEndpoint") + "?depth=1" + utils.logAudit("DeleteAAIVfModule endPoint: " + endPoint) + def aaiRequestId = UUID.randomUUID().toString() + + utils.log("DEBUG","queryAAIForGenericVnf() endpoint-" + endPoint, isDebugEnabled) + def responseData = "" + try { + utils.log("DEBUG", "invoking GET call to AAI endpoint :"+System.lineSeparator()+endPoint,isDebugEnabled) + utils.logAudit("DeleteAAIVfModule - invoking httpGet to AAI") + + AaiUtil aaiUtil = new AaiUtil(this) + APIResponse response = aaiUtil.executeAAIGetCall(execution, endPoint) + + responseData = response.getResponseBodyAsString() + execution.setVariable("DAAIVfMod_queryGenericVnfResponseCode", response.getStatusCode()) + execution.setVariable("DAAIVfMod_queryGenericVnfResponse", responseData) + utils.logAudit("AAI Response: " + responseData) + utils.log("DEBUG", "Response code:" + response.getStatusCode(), isDebugEnabled) + utils.log("DEBUG", "Response:" + System.lineSeparator()+responseData,isDebugEnabled) + } catch (Exception ex) { + ex.printStackTrace() + utils.log("DEBUG", "Exception occurred while executing AAI GET:" + ex.getMessage(),isDebugEnabled) + execution.setVariable("DAAIVfMod_queryGenericVnfResponseCode", 500) + execution.setVariable("DAAIVfMod_queryGenericVnfResponse", "AAI GET Failed:" + ex.getMessage()) + } + } + + // construct and send a DELETE request to A&AI to delete a Generic Vnf + // note: to get here, all the modules associated with the Generic Vnf must already be deleted + public void deleteGenericVnf(Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + def aaiRequestId = UUID.randomUUID().toString() + def endPoint = execution.getVariable("URN_aai_endpoint") + execution.getVariable("DAAIVfMod_genericVnfEndpoint") + + "/?resource-version=" + execution.getVariable("DAAIVfMod_genVnfRsrcVer") + utils.logAudit("AAI endPoint: " + endPoint) + utils.log("DEBUG","deleteGenericVnf() endpoint-" + endPoint, isDebugEnabled) + def responseData = "" + try { + AaiUtil aaiUtil = new AaiUtil(this) + APIResponse response = aaiUtil.executeAAIDeleteCall(execution, endPoint) + + responseData = response.getResponseBodyAsString() + execution.setVariable("DAAIVfMod_deleteGenericVnfResponseCode", response.getStatusCode()) + execution.setVariable("DAAIVfMod_deleteGenericVnfResponse", responseData) + utils.log("DEBUG", "Response code:" + response.getStatusCode(), isDebugEnabled) + utils.log("DEBUG", "Response:" + System.lineSeparator()+responseData,isDebugEnabled) + } catch (Exception ex) { + ex.printStackTrace() + utils.log("DEBUG", "Exception occurred while executing AAI DELETE:" + ex.getMessage(),isDebugEnabled) + execution.setVariable("DAAIVfMod_deleteGenericVnfResponseCode", 500) + execution.setVariable("DAAIVfMod_deleteGenericVnfResponse", "AAI DELETE Failed:" + ex.getMessage()) + } + } + + // construct and send a DELETE request to A&AI to delete the Base or Add-on Vf Module + public void deleteVfModule(Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + def endPoint = execution.getVariable("URN_aai_endpoint") + execution.getVariable("DAAIVfMod_vfModuleEndpoint") + + "/?resource-version=" + execution.getVariable("DAAIVfMod_vfModRsrcVer") + def aaiRequestId = UUID.randomUUID().toString() + + utils.log("DEBUG","deleteVfModule() endpoint-" + endPoint, isDebugEnabled) + def responseData = "" + try { + AaiUtil aaiUtil = new AaiUtil(this) + APIResponse response = aaiUtil.executeAAIDeleteCall(execution, endPoint) + + utils.logAudit("DeleteAAIVfModule - invoking httpDelete to AAI") + + responseData = response.getResponseBodyAsString() + execution.setVariable("DAAIVfMod_deleteVfModuleResponseCode", response.getStatusCode()) + execution.setVariable("DAAIVfMod_deleteVfModuleResponse", responseData) + utils.logAudit("DeleteAAIVfModule - AAI Response" + responseData) + utils.log("DEBUG", "Response code:" + response.getStatusCode(), isDebugEnabled) + utils.log("DEBUG", "Response:" + System.lineSeparator()+responseData,isDebugEnabled) + + } catch (Exception ex) { + ex.printStackTrace() + utils.log("DEBUG", "Exception occurred while executing AAI PUT:" + ex.getMessage(),isDebugEnabled) + execution.setVariable("DAAIVfMod_deleteVfModuleResponseCode", 500) + execution.setVariable("DAAIVfMod_deleteVfModuleResponse", "AAI PUT Failed:" + ex.getMessage()) + } + } + + // parses the output from the result from queryAAIForGenericVnf() to determine if the Vf Module + // to be deleted exists for the specified Generic Vnf and if it is the Base Module, + // there are no Add-on Modules present + public void parseForVfModule(Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + def xml = execution.getVariable("DAAIVfMod_queryGenericVnfResponse") + utils.logAudit("DeleteAAIVfModule - queryGenericVnfResponse" + xml) + + def delModuleId = execution.getVariable("DAAIVfMod_vfModuleId") + utils.log("DEBUG", "Vf Module to be deleted: " + delModuleId, isDebugEnabled) + List <String> qryModuleIdList = utils.getMultNodes(xml, "vf-module-id") + List <String> qryBaseModuleList = utils.getMultNodes(xml, "is-base-vf-module") + List <String> qryResourceVerList = utils.getMultNodes(xml, "resource-version") + execution.setVariable("DAAIVfMod_moduleExists", false) + execution.setVariable("DAAIVfMod_isBaseModule", false) + execution.setVariable("DAAIVfMod_isLastModule", false) + // + def isBaseVfModule = "false" + // loop through the Vf Module Ids looking for a match + if (qryModuleIdList != null && !qryModuleIdList.empty) { + utils.log("DEBUG", "Existing Vf Module Id List: " + qryModuleIdList, isDebugEnabled) + utils.log("DEBUG", "Existing Vf Module Resource Version List: " + qryResourceVerList, isDebugEnabled) + def moduleCntr = 0 + // the Generic Vnf resource-version in the 1st entry in the query response + execution.setVariable("DAAIVfMod_genVnfRsrcVer", qryResourceVerList[moduleCntr]) + for (String qryModuleId : qryModuleIdList) { + if (delModuleId.equals(qryModuleId)) { + // a Vf Module with the requested Id exists + execution.setVariable("DAAIVfMod_moduleExists", true) + // find the corresponding value for the is-base-vf-module field + isBaseVfModule = qryBaseModuleList[moduleCntr] + // find the corresponding value for the resource-version field + // note: the Generic Vnf entry also has a resource-version field, so + // add 1 to the index to get the corresponding Vf Module value + execution.setVariable("DAAIVfMod_vfModRsrcVer", qryResourceVerList[moduleCntr+1]) + utils.log("DEBUG", "Match found for Vf Module Id " + qryModuleId + " for Generic Vnf Id " + + execution.getVariable("DAAIVfMod_vnfId") + ", Base Module is " + isBaseVfModule + + ", Resource Version is " + execution.getVariable("vfModRsrcVer"), isDebugEnabled) + break + } + moduleCntr++ + } + } + + // determine if the module to be deleted is a Base Module and/or the Last Module + if (execution.getVariable("DAAIVfMod_moduleExists") == true) { + if (isBaseVfModule.equals("true") && qryModuleIdList.size() != 1) { + execution.setVariable("DAAIVfMod_parseModuleResponse", + "Found Vf Module Id " + delModuleId + " for Generic Vnf Id " + + execution.getVariable("DAAIVfMod_vnfId") + ": is Base Module, not Last Module") + execution.setVariable("DAAIVfMod_isBaseModule", true) + } else { + if (isBaseVfModule.equals("true") && qryModuleIdList.size() == 1) { + execution.setVariable("DAAIVfMod_parseModuleResponse", + "Found Vf Module Id " + delModuleId + " for Generic Vnf Id " + + execution.getVariable("DAAIVfMod_vnfId") + ": is Base Module and Last Module") + execution.setVariable("DAAIVfMod_isBaseModule", true) + execution.setVariable("DAAIVfMod_isLastModule", true) + } else { + if (qryModuleIdList.size() == 1) { + execution.setVariable("DAAIVfMod_parseModuleResponse", + "Found Vf Module Id " + delModuleId + " for Generic Vnf Id " + + execution.getVariable("DAAIVfMod_vnfId") + ": is Not Base Module, is Last Module") + execution.setVariable("DAAIVfMod_isLastModule", true) + } else { + execution.setVariable("DAAIVfMod_parseModuleResponse", + "Found Vf Module Id " + delModuleId + " for Generic Vnf Id " + + execution.getVariable("DAAIVfMod_vnfId") + ": is Not Base Module and Not Last Module") + } + } + } + utils.log("DEBUG", execution.getVariable("DAAIVfMod_parseModuleResponse"), isDebugEnabled) + } else { // (execution.getVariable("DAAIVfMod_moduleExists") == false) + utils.log("DEBUG", "Vf Module Id " + delModuleId + " does not exist for Generic Vnf Id " + + execution.getVariable("DAAIVfMod_vnfId"), isDebugEnabled) + execution.setVariable("DAAIVfMod_parseModuleResponse", + "Vf Module Id " + delModuleId + " does not exist for Generic Vnf Id " + + execution.getVariable("DAAIVfMod_vnfName")) + } + } + + // parses the output from the result from queryAAIForGenericVnf() to determine if the Vf Module + // to be deleted exists for the specified Generic Vnf and if it is the Base Module, + // there are no Add-on Modules present + public void parseForResourceVersion(Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + def xml = execution.getVariable("DAAIVfMod_queryGenericVnfResponse") + utils.logAudit("DeleteAAIVfModule - queryGenericVnfResponse" + xml) + String resourceVer = utils.getNodeText1(xml, "resource-version") + execution.setVariable("DAAIVfMod_genVnfRsrcVer", resourceVer) + utils.log("DEBUG", "Latest Generic VNF Resource Version: " + resourceVer) + } + + + // generates a WorkflowException if the A&AI query returns a response code other than 200 + public void handleAAIQueryFailure(Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + + utils.log("ERROR", "Error occurred attempting to query AAI, Response Code " + + execution.getVariable("DAAIVfMod_queryGenericVnfResponseCode") + ", Error Response " + + execution.getVariable("DAAIVfMod_queryGenericVnfResponse"), isDebugEnabled) + def errorCode = 5000 + // set the errorCode to distinguish between a A&AI failure + // and the Generic Vnf Id not found + if (execution.getVariable("DAAIVfMod_queryGenericVnfResponseCode") == 404) { + errorCode = 1002 + } + String processKey = getProcessKey(execution); + WorkflowException exception = new WorkflowException(processKey, errorCode, + execution.getVariable("DAAIVfMod_queryGenericVnfResponse")) + execution.setVariable("WorkflowException", exception) + } + + // generates a WorkflowException if + // - the A&AI Vf Module DELETE returns a response code other than 200 + // - the Vf Module is a Base Module that is not the last Vf Module + // - the Vf Module does not exist for the Generic Vnf + public void handleDeleteVfModuleFailure(Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + + def errorCode = 2000 + def errorResponse = "" + if (execution.getVariable("DAAIVfMod_deleteVfModuleResponseCode") != null && + execution.getVariable("DAAIVfMod_deleteVfModuleResponseCode") != 200) { + utils.log("DEBUG", "AAI failure deleting a Vf Module: " + + execution.getVariable("DAAIVfMod_deleteVfModuleResponse"), isDebugEnabled) + errorResponse = execution.getVariable("DAAIVfMod_deleteVfModuleResponse") + utils.logAudit("DeleteAAIVfModule - deleteVfModuleResponse" + errorResponse) + errorCode = 5000 + } else { + if (execution.getVariable("DAAIVfMod_isBaseModule", true) == true && + execution.getVariable("DAAIVfMod_isLastModule") == false) { + // attempt to delete a Base Module that is not the last Vf Module + utils.log("DEBUG", execution.getVariable("DAAIVfMod_parseModuleResponse"), isDebugEnabled) + errorResponse = execution.getVariable("DAAIVfMod_parseModuleResponse") + utils.logAudit("DeleteAAIVfModule - parseModuleResponse" + errorResponse) + errorCode = 1002 + } else { + // attempt to delete a non-existant Vf Module + if (execution.getVariable("DAAIVfMod_moduleExists") == false) { + utils.log("DEBUG", execution.getVariable("DAAIVfMod_parseModuleResponse"), isDebugEnabled) + errorResponse = execution.getVariable("DAAIVfMod_parseModuleResponse") + utils.logAudit("DeleteAAIVfModule - parseModuleResponse" + errorResponse) + errorCode = 1002 + } else { + // if the responses get populated corerctly, we should never get here + errorResponse = "Unknown error occurred during DeleteAAIVfModule flow" + } + } + } + + utils.log("ERROR", "Error occurred during DeleteAAIVfModule flow: " + errorResponse, isDebugEnabled) + String processKey = getProcessKey(execution); + WorkflowException exception = new WorkflowException(processKey, errorCode, errorResponse) + execution.setVariable("WorkflowException", exception) + } + + // generates a WorkflowException if + // - the A&AI Generic Vnf DELETE returns a response code other than 200 + public void handleDeleteGenericVnfFailure(Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + utils.log("ERROR", "AAI error occurred deleting the Generic Vnf: " + + execution.getVariable("DAAIVfMod_deleteGenericVnfResponse"), isDebugEnabled) + String processKey = getProcessKey(execution); + WorkflowException exception = new WorkflowException(processKey, 5000, + execution.getVariable("DAAIVfMod_deleteGenericVnfResponse")) + execution.setVariable("WorkflowException", exception) + } +}
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/ExceptionUtil.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/ExceptionUtil.groovy new file mode 100644 index 0000000000..fb68f4efe9 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/ExceptionUtil.groovy @@ -0,0 +1,599 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common.scripts + +import static org.apache.commons.lang3.StringUtils.* + +import org.apache.commons.lang3.* +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.runtime.Execution +import org.openecomp.mso.bpmn.core.WorkflowException + +/** + * @version 1.0 + */ +class ExceptionUtil extends AbstractServiceTaskProcessor { + + /** + * + * @Deprecated + * + * Instead use <method>MapAAIExceptionToWorkflowException</method> + * + * To Be Removed Once Refactoring Main Flow Error Handling Is Complete + * + * + */ + @Deprecated + String MapAAIExceptionToWorkflowExceptionOld(String response, Execution execution) + { + def utils=new MsoUtils() + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + def prefix=execution.getVariable("prefix") + def errorMsg = execution.getVariable(prefix+"ErrorResponse") + utils.log("DEBUG","=========== Begin MapAAIExceptionToWorkflowException ===========",isDebugEnabled) + String text = null + def variables + String errorCode = '5000' + utils.log("DEBUG","response: " + response, isDebugEnabled) + try { + //String msg = utils.getNodeXml(response, "Fault") + variables = utils.getMultNodes(response, "variable") + text = utils.getNodeText1(response, "text") + } catch (Exception ex) { + //Ignore the exception - cases include non xml payload + utils.log("DEBUG","error mapping error, ignoring: " + ex,isDebugEnabled) + } + + if(text != null) { + if(variables.size()>=4){ + text = text.replaceFirst("%1", variables[0]) + text = text.replaceFirst("%2", variables[1]) + text = text.replaceFirst("%3", variables[2]) + text = text.replaceFirst("%4", variables[3]) + } + String modifiedErrorMessage = 'Received error from A&AI (' + text +')' + utils.log("DEBUG", "ModifiedErrorMessage " + modifiedErrorMessage, isDebugEnabled) + // let $ModifiedErrorMessage := concat( 'Received error from A',$exceptionaai:ampersand,'AI (' ,functx:replace-multi($ErrorMessage,$from,$Variables ),')') + String message = """<aetgt:WorkflowException xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"> + <aetgt:ErrorMessage>$modifiedErrorMessage</aetgt:ErrorMessage> + <aetgt:ErrorCode>$errorCode</aetgt:ErrorCode> + </aetgt:WorkflowException>""" + execution.setVariable(prefix+"ErrorResponse",message) + utils.log("ERROR","Fault:"+ execution.getVariable(prefix+"ErrorResponse")) + return message + } else { + try { + errorCode = MapErrorCode(errorMsg) + String mappedErrorMessage = MapErrorMessage(errorMsg, errorCode) + + String message = """<aetgt:WorkflowException xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"> + <aetgt:ErrorMessage>$mappedErrorMessage</aetgt:ErrorMessage> + <aetgt:ErrorCode>$errorCode</aetgt:ErrorCode> + </aetgt:WorkflowException>""" + utils.log("DEBUG", "mappedErrorMessage " + mappedErrorMessage, isDebugEnabled) + execution.setVariable(prefix+"ErrorResponse",message) + utils.log("ERROR","Fault:"+ execution.getVariable(prefix+"ErrorResponse")) + return message + } catch(Exception ex) { + utils.log("DEBUG","error mapping error, return null: " + ex,isDebugEnabled) + return null + + } + } + } + + /** + * This error handling method maps an AAI Exception response to a + * WorkflowException Object. It then sets the WorkflowException Object + * on the execution as "WorkflowException". + * + * This method formats the exception from AAI into the WorkflowException's + * errorMessage that CCD expects. + * + * @param execution the execution + * @param response the aai exception + */ + WorkflowException MapAAIExceptionToWorkflowException(String response, Execution execution) + { + def utils=new MsoUtils() + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + def prefix=execution.getVariable("prefix") + def errorMsg = execution.getVariable(prefix+"ErrorResponse") + utils.log("DEBUG","=========== Begin MapAAIExceptionToWorkflowException ===========",isDebugEnabled) + String text = null + def variables + String errorCode = '5000' + WorkflowException wfex + utils.log("DEBUG","response: " + response, isDebugEnabled) + try { + //String msg = utils.getNodeXml(response, "Fault") + variables = utils.getMultNodes(response, "variable") + text = utils.getNodeText1(response, "text") + } catch (Exception ex) { + //Ignore the exception - cases include non xml payload + utils.log("DEBUG","error mapping error, ignoring: " + ex,isDebugEnabled) + } + + if(text != null) { + if(variables.size()>=4){ + text = text.replaceFirst("%1", variables[0]) + text = text.replaceFirst("%2", variables[1]) + text = text.replaceFirst("%3", variables[2]) + text = text.replaceFirst("%4", variables[3]) + } + String modifiedErrorMessage = 'Received error from A&AI (' + text +')' + utils.log("DEBUG", "ModifiedErrorMessage " + modifiedErrorMessage, isDebugEnabled) + // let $ModifiedErrorMessage := concat( 'Received error from A',$exceptionaai:ampersand,'AI (' ,functx:replace-multi($ErrorMessage,$from,$Variables ),')') + buildWorkflowException(execution, 5000, modifiedErrorMessage) + + wfex = execution.getVariable("WorkflowException") + utils.log("ERROR","Fault:"+ wfex) + return wfex + } else { + try { + errorCode = MapErrorCode(errorMsg) + String mappedErrorMessage = MapErrorMessage(errorMsg, errorCode) + + int errorCodeInt = Integer.parseInt(errorCode) + buildWorkflowException(execution, errorCodeInt, mappedErrorMessage) + + utils.log("DEBUG", "mappedErrorMessage " + mappedErrorMessage, isDebugEnabled) + wfex = execution.getVariable("WorkflowException") + utils.log("ERROR","Fault:"+ wfex, isDebugEnabled) + return wfex + } catch(Exception ex) { + utils.log("DEBUG","error mapping error, return null: " + ex, isDebugEnabled) + return null + + } + } + } + + /** + * This error handling method maps an AAI Exception response to a + * WorkflowException Object. It then sets the WorkflowException Object + * on the execution as "WorkflowException". + * + * This method takes the exact exception inside the <Fault> tags from AAI Response + * and puts it into the WorkflowException's errorMessage. + * + * @param execution the execution + * @param response the aai exception + */ + WorkflowException MapAAIExceptionToWorkflowExceptionGeneric(Execution execution, String response, int resCode){ + def utils=new MsoUtils() + def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled") + utils.log("DEBUG", "Start MapAAIExceptionToWorkflowExceptionGeneric Process", isDebugLogEnabled) + + WorkflowException wfex + try { + if(utils.nodeExists(response, "Fault")){ + String fault = utils.getNodeXml(response, "Fault") + fault = utils.removeXmlPreamble(fault) + fault = fault.replace("<Fault>", "").replace("</Fault>", "") + fault = fault.replaceAll("\\s+\\s+", "") // Removes extra white spaces + buildWorkflowException(execution, resCode, fault) + }else if(utils.nodeExists(response, "RESTFault")){ + String rFault = utils.getNodeXml(response, "RESTFault") + buildWorkflowException(execution, resCode, rFault) + }else{ + buildWorkflowException(execution, resCode, "Received a bad response from AAI") + } + } catch (Exception ex) { + utils.log("DEBUG", "Exception Occured during MapAAIExceptionToWorkflowExceptionGeneric: " + ex, isDebugLogEnabled) + buildWorkflowException(execution, resCode, "Internal Error - Occured in MapAAIExceptionToWorkflowExceptionGeneric") + + } + utils.log("DEBUG", "Outgoing WorkflowException is: " + execution.getVariable("WorkflowException"), isDebugLogEnabled) + utils.log("DEBUG", "Completed MapAAIExceptionToWorkflowExceptionGeneric Process", isDebugLogEnabled) + } + + /** + * + *This method build a WorkflowException using the adapters response. + * + *@param String response + *@param String adapter + * + *@return WorkflowException wfex + */ + WorkflowException MapAdapterExecptionToWorkflowException(String response, Execution execution, String adapter){ + def utils=new MsoUtils() + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + def prefix=execution.getVariable("prefix") + utils.log("DEBUG","=========== Start MapAdapterExecptionToWorkflowException Process ===========",isDebugEnabled) + + String errorCode + def errorMessage + WorkflowException wfex + try { + errorCode = MapCategoryToErrorCode(utils.getNodeText(response, "category")) + errorMessage = MapAdapterErrorMessage(utils.getNodeText(response, "message"), errorCode, adapter) + + int errorCodeInt = Integer.parseInt(errorCode) + buildWorkflowException(execution, errorCodeInt, errorMessage) + }catch (Exception ex) { + utils.log("DEBUG", "Exception Occured during MapAdapterExecptionToWorkflowException: " + ex, isDebugEnabled) + buildWorkflowException(execution, 2500, "Internal Error - Occured in MapAdapterExecptionToWorkflowException") + } + wfex = execution.getVariable("WorkflowException") + return wfex + utils.log("DEBUG","=========== Completed MapAdapterExecptionToWorkflowException Process ===========",isDebugEnabled) + } + + + /** + * + * @Deprecated + * + * Instead use <method>buildWorkflowException(Execution execution, int errorCode, String errorMessage)</method> method below + * + * To Be Removed Once Refactoring Of Main Flow Error Handling Is Complete + * + */ + @Deprecated + String buildWorkflowExceptionXml(String errorCode, String errorMessage) { + return """<aetgt:WorkflowException xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"> + <aetgt:ErrorMessage>${errorMessage}</aetgt:ErrorMessage> + <aetgt:ErrorCode>${errorCode}</aetgt:ErrorCode> + </aetgt:WorkflowException>""" + } + + /** + * This method takes a WorkflowException Object and builds + * WorkflowException Xml. This method should only be used + * for the purpose of sending an error response. + * + *@param - WorkflowException Object + * + *@return - String WorkflowException Xml + * + * + */ + String buildErrorResponseXml(WorkflowException wfex) { + String xml + if(wfex != null){ + String mes = wfex.getErrorMessage() + int code = wfex.getErrorCode() + xml = + """<aetgt:WorkflowException xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"> + <aetgt:ErrorMessage>${mes}</aetgt:ErrorMessage> + <aetgt:ErrorCode>${code}</aetgt:ErrorCode> + </aetgt:WorkflowException>""" + + }else{ + xml = + """<aetgt:WorkflowException xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"> + <aetgt:ErrorMessage>Internal Error</aetgt:ErrorMessage> + <aetgt:ErrorCode>2500</aetgt:ErrorCode> + </aetgt:WorkflowException>""" + } + return xml + } + + /* + 5000 Received error from A&AI ($A&AI_ERROR) Asynchronous During orchestration of the recipe, A&AI returned an error. The error returned by A&AI is passed through in $A&AI_ERROR. + 5010 Could not communicate with A&AI Asynchronous During orchestration of the recipe, a connection with A&AI could not be established. + 5020 No response from A&AI Asynchronous During orchestration of the recipe, communication was established with A&AI, but no response was received within the configured timeout. + */ + String MapErrorCode(String errorMessage) + { + if(errorMessage==null){ + return '5000' + } + errorMessage = errorMessage.toLowerCase(); + if(errorMessage.contains('timed out') || errorMessage.contains('timeout')) + return '5020' + else if (errorMessage.contains('connection')) + return '5010' + else + return '5000' + } + + String MapErrorMessage(String errorMessage, String errorCode) + { + if(errorMessage == null){ + errorMessage="" + } + if( errorCode.equals('5010')) { + return 'Could not communicate with A&AI' + } else if (errorCode.equals('5020')) { + return 'No response from A&AI' + } else { + errorMessage = errorMessage.replace("&", "&").replace("<", "<").replace(">", ">") + return 'Received error from A&AI (' +errorMessage +')' + } + } + + String MapCategoryToErrorCode(String errorCategory) + { + if(errorCategory.equals('OPENSTACK')) + return '5100' + else if (errorCategory.equals('IO')) + return '5110' + else if (errorCategory.equals('INTERNAL')) + return '7020' + else if (errorCategory.equals('USERDATA')) + return '7020' + else + return '7020' + } + + + String MapAdapterErrorMessage(String errorMessage, String errorCode, String adapter) + { + if(errorCode.equals('5100')) + return 'Received error from Platform Orchestrator: ' + errorMessage + else if(errorCode.equals('5110')) + return 'Could not communicate with Platform Orchestrator' + else + return 'Received error from ' + adapter + ': ' + errorMessage + } + + String MapSDNCResponseCodeToErrorCode(String sdncResponseCode) + { + if (sdncResponseCode == '500') { + return '5310' + } else if ( sdncResponseCode == '408') { + return '5320' + } else if ( sdncResponseCode == '60010') { + return '5350' + } else { + return '5300' + } + } + + /** + * This error handling method builds a WorkflowException Object. It sets it on + * the execution as "WorkflowException". + * + * @param execution the execution + * @param errorCode the error code + * @param errorMessage the error message + */ + public void buildWorkflowException(Execution execution, int errorCode, String errorMessage) { + MsoUtils utils = new MsoUtils() + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + String processKey = getProcessKey(execution); + utils.log("DEBUG", "Building a WorkflowException for " + processKey, isDebugLogEnabled) + + WorkflowException exception = new WorkflowException(processKey, errorCode, errorMessage); + execution.setVariable("WorkflowException", exception); + utils.log("DEBUG", "Outgoing WorkflowException is " + exception, isDebugLogEnabled) + } + + /** + * This error handling method builds a WorkflowException Object and throws a + * MSOWorkflowException. It throws a "MSOWorkflowException" BpmnError after + * setting the WorkflowException Object on the execution as "WorkflowException". + * + * @param execution the execution + * @param errorCode the error code + * @param errorMessage the error message + */ + public void buildAndThrowWorkflowException(Execution execution, int errorCode, String errorMessage) { + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + String processKey = getProcessKey(execution); + utils.log("Building a WorkflowException for Subflow " + processKey, isDebugLogEnabled) + + WorkflowException exception = new WorkflowException(processKey, errorCode, errorMessage); + execution.setVariable("WorkflowException", exception); + utils.log("DEBUG", "Outgoing WorkflowException is " + exception, isDebugLogEnabled) + utils.log("DEBUG", "Throwing MSOWorkflowException", isDebugLogEnabled) + throw new BpmnError("MSOWorkflowException") + } + + /** + * This method is executed after an MSOWorkflowException is caught by a + * subflow (during subflows "Error Handling Sub Process"). + * It ensures the WorkflowException variable is populated before ending the + * subflow and also logs the subflows outgoing WorkflowException Variable. + * + * @param - execution + * + */ + public void processSubflowsBPMNException(Execution execution){ + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + String processKey = getProcessKey(execution) + try{ + utils.log("DEBUG", "Started ProcessSubflowsBPMNException Method", isDebugEnabled) + if(execution.getVariable("WorkflowException") == null){ + buildWorkflowException(execution, 2500, "Internal Error - Occured During " + processKey) + } + + utils.log("DEBUG", processKey + " Outgoing WorkflowException is: " + execution.getVariable("WorkflowException"), isDebugEnabled) + }catch(Exception e){ + utils.log("DEBUG", "Caught Exception during ProcessSubflowsBPMNException Method: " + e, isDebugEnabled) + } + utils.log("DEBUG", "Completed ProcessSubflowsBPMNException Method", isDebugEnabled) + } + + /** + * This method is executed after an MSOWorkflowException is caught by a + * Mainflow. It builds and returns a FalloutHandler Request. It also + * verifies the WorkflowException variable is populated. + * + * @param - execution + * @param - requestInfo + * + * @return - falloutHandlerRequest + * + */ + public String processMainflowsBPMNException(Execution execution, String requestInfo){ + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + String processKey = getProcessKey(execution) + try{ + utils.log("DEBUG", "Started ProcessMainflowBPMNException Method", isDebugEnabled) + if(execution.getVariable("WorkflowException") == null || isBlank(requestInfo)){ + buildWorkflowException(execution, 2500, "Internal Error - WorkflowException Object and/or RequestInfo is null! " + processKey) + } + requestInfo = utils.removeXmlPreamble(requestInfo) + WorkflowException wfex = execution.getVariable("WorkflowException") + String errorMessage = wfex.getErrorMessage() + int errorCode = wfex.getErrorCode() + + String falloutHandlerRequest = + """<aetgt:FalloutHandlerRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1" + xmlns:ns="http://org.openecomp/mso/request/types/v1" + xmlns:wfsch="http://org.openecomp/mso/workflow/schema/v1"> + ${requestInfo} + <aetgt:WorkflowException xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"> + <aetgt:ErrorMessage>${errorMessage}</aetgt:ErrorMessage> + <aetgt:ErrorCode>${errorCode}</aetgt:ErrorCode> + </aetgt:WorkflowException> + </aetgt:FalloutHandlerRequest>""" + + utils.log("DEBUG", processKey + " Outgoing WorkflowException is: " + execution.getVariable("WorkflowException"), isDebugEnabled) + utils.log("DEBUG", processKey + " Outgoing FalloutHandler Request is: " + falloutHandlerRequest, isDebugEnabled) + + return falloutHandlerRequest + + }catch(Exception e){ + utils.log("DEBUG", "Caught Exception during ProcessMainflowBPMNException Method: " + e, isDebugEnabled) + return null + } + utils.log("DEBUG", "Completed ProcessMainflowBPMNException Method", isDebugEnabled) + } + + /** + * + * This method should only be used by DHV Flows. This method is + * executed after an MSOWorkflowException is caught by a Mainflow. + * It builds and returns a FalloutHandler Request. It also + * verifies the WorkflowException variable is populated. + * + * @param - execution + * @param - requestInfo + * + * @return - falloutHandlerRequest + * + */ + public String processMainflowsBPMNExceptionDHV(Execution execution, String requestId, def source, def action, def notificationUrl, def serviceInstanceId, def startTime){ + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + String processKey = getProcessKey(execution) + try{ + utils.log("DEBUG", "Started ProcessMainflowBPMNExceptionDHV Method", isDebugEnabled) + + def WorkflowException workflowException = execution.getVariable("WorkflowException") + int errorResponseCode = 0 + def errorResponseMsg = "" + if(workflowException != null){ + errorResponseCode = workflowException.getErrorCode() + def errorMsg = workflowException.getErrorMessage() + if (errorMsg != null) { + errorResponseMsg = errorMsg.replace("&", "&").replace("<", "<").replace(">", ">") + } + }else{ + errorResponseCode = 2500 + errorResponseMsg = "Internal Error occured during " + action + ", unable to retrieve error information." + } + + + String request = + """<FalloutHandlerRequest xmlns="http://org.openecomp/mso/workflow/schema/v1"> + <request-information xmlns="http://org.openecomp/mso/request/types/v1"> + <request-id>${requestId}</request-id> + <request-action>${action}</request-action> + <source>${source}</source> + <notification-url>${notificationUrl}</notification-url> + </request-information> + <mso-bpel-name>BPMN</mso-bpel-name> + <is-srv-inst-req>true</is-srv-inst-req> + <resp-content-type>JSON</resp-content-type> + <service-instance-id>${serviceInstanceId}</service-instance-id> + <start-time>${startTime}</start-time> + <WorkflowException> + <ErrorMessage>${errorResponseMsg}</ErrorMessage> + <ErrorCode>${errorResponseCode}</ErrorCode> + </WorkflowException> + </FalloutHandlerRequest>""" + + + request = utils.formatXml(request) + utils.log("DEBUG", processKey + " Outgoing WorkflowException is: " + execution.getVariable("WorkflowException"), isDebugEnabled) + utils.log("DEBUG", processKey + " Outgoing FalloutHandler Request is: " + request, isDebugEnabled) + + return request + + }catch(Exception e){ + utils.log("DEBUG", "Caught Exception during ProcessMainflowBPMNException Method: " + e, isDebugEnabled) + return null + } + utils.log("DEBUG", "Completed ProcessMainflowBPMNExceptionDHV Method", isDebugEnabled) + } + + /** + * This method is executed after an Java Exception is caught. + * It sets the WorkflowException variable and throws an MSOWorkflowException. + * + * @param - execution + * + */ + @Deprecated + public void processSubflowsJavaException(Execution execution){ + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + String processKey = getProcessKey(execution) + try{ + utils.log("DEBUG", "Caught a Java Exception in " + processKey, isDebugEnabled) + utils.log("DEBUG", "Started processJavaException Method", isDebugEnabled) + buildAndThrowWorkflowException(execution, 2500, "Catch a Java Lang Exception in " + processKey) + + }catch(BpmnError b){ + throw b + }catch(Exception e){ + utils.log("DEBUG", "Caught Exception during processJavaException Method: " + e, isDebugEnabled) + buildAndThrowWorkflowException(execution, 2500, "Internal Error - During Process Java Exception") + } + utils.log("DEBUG", "Completed processJavaException Method", isDebugEnabled) + } + + /** + * + * This method is executed after an Java Exception is caught + * It sets the WorkflowException variable. The method can be used in either mainflow or subflows. + * + * @param - execution + * + */ + public void processJavaException(Execution execution){ + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + String processKey = getProcessKey(execution) + try{ + utils.log("DEBUG", "Caught a Java Exception in " + processKey, isDebugEnabled) + utils.log("DEBUG", "Started processJavaException Method", isDebugEnabled) + buildWorkflowException(execution, 2500, "Catch a Java Lang Exception in " + processKey) + + }catch(BpmnError b){ + throw b + }catch(Exception e){ + utils.log("DEBUG", "Caught Exception during processJavaException Method: " + e, isDebugEnabled) + buildWorkflowException(execution, 2500, "Internal Error - During Process Java Exception") + } + utils.log("DEBUG", "Completed processJavaException Method", isDebugEnabled) + } + + + public void preProcessRequest(Execution execution) { + // TODO Auto-generated method stub + + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/FalloutHandler.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/FalloutHandler.groovy new file mode 100644 index 0000000000..62bf7be5ec --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/FalloutHandler.groovy @@ -0,0 +1,390 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common.scripts + +import java.text.SimpleDateFormat + +import org.apache.commons.lang3.* +import org.camunda.bpm.engine.runtime.Execution + +public class FalloutHandler extends AbstractServiceTaskProcessor { + String Prefix="FH_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + + public initializeProcessVariables(Execution execution){ + def method = getClass().getSimpleName() + '.initializeProcessVariables(' +'execution=' + execution.getId() +')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logDebug('Entered ' + method, isDebugLogEnabled) + + try { + execution.setVariable("prefix",Prefix) + + //These variables are form the input Message to the BPMN + execution.setVariable("FH_request_id","") + execution.setVariable("FH_request_action","") + execution.setVariable("FH_notification-url","") + execution.setVariable("FH_mso-bpel-name","") + execution.setVariable("FH_ErrorCode", "") + execution.setVariable("FH_ErrorMessage", "") + + execution.setVariable("FH_notification-url-Ok", false) + execution.setVariable("FH_request_id-Ok", false) + + //These variables are for Get Mso Aai Password Adapter + execution.setVariable("FH_deliveryStatus", true) + + //update Response Status to pending ...Adapter variables + execution.setVariable("FH_updateResponseStatusPayload", null) + execution.setVariable("FH_updateResponseStatusResponse", null) + + //update Request Gamma ...Adapter variables + execution.setVariable("FH_updateRequestGammaPayload", "") + execution.setVariable("FH_updateRequestGammaResponse", null) + execution.setVariable("FH_updateRequestGammaResponseCode", null) + + //update Request Infra ...Adapter variables + execution.setVariable("FH_updateRequestInfraPayload", "") + execution.setVariable("FH_updateRequestInfraResponse", null) + execution.setVariable("FH_updateRequestInfraResponseCode", null) + + //assign True to success variable + execution.setVariable("FH_success", true) + + //Set notify status to Failed variable + execution.setVariable("FH_NOTIFY_STATUS", "SUCCESS") + + //Set DB update variable + execution.setVariable("FH_updateRequestPayload", "") + execution.setVariable("FH_updateRequestResponse", null) + execution.setVariable("FH_updateRequestResponseCode", null) + + //Auth variables + execution.setVariable("BasicAuthHeaderValue","") + + //Parameter list + execution.setVariable("FH_parameterList", "") + + //Response variables + execution.setVariable("FalloutHandlerResponse","") + execution.setVariable("FH_ErrorResponse", null) + execution.setVariable("FH_ResponseCode", "") + + } catch (Exception e) { + logError('Caught exception in ' + method, e) + // exceptionUtil.buildWorkflowException(execution, 2000, "Internal Error - Occured in " + method) + } + } + + public void preProcessRequest (Execution execution) { + def method = getClass().getSimpleName() + '.preProcessRequest(' +'execution=' + execution.getId() +')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logDebug('Entered ' + method, isDebugLogEnabled) + + // Initialize flow variables + initializeProcessVariables(execution) + setSuccessIndicator(execution, false) + + try { + String basicAuthValueDB = execution.getVariable("URN_mso_adapters_db_auth") + utils.log("DEBUG", " Obtained BasicAuth userid password for Catalog DB adapter: " + basicAuthValueDB, isDebugLogEnabled) + + def encodedString = utils.getBasicAuth(basicAuthValueDB, execution.getVariable("URN_mso_msoKey")) + execution.setVariable("BasicAuthHeaderValueDB",encodedString) + } catch (IOException ex) { + String dataErrorMessage = " Unable to encode Catalog DB user/password string - " + ex.getMessage() + utils.log("DEBUG", dataErrorMessage, isDebugLogEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + } + + try { + def xml = execution.getVariable("FalloutHandlerRequest") + utils.log("DEBUG", " XML --> " + xml, isDebugLogEnabled) + utils.logAudit("FalloutHandler request: " + xml) + + //Check the incoming request type + //Incoming request can be ACTIVE_REQUESTS (request-information node) or INFRA_ACTIVE_REQUESTS (request-info node) + if (utils.nodeExists(xml, "request-information")) { + execution.setVariable("FH_request_id-Ok", true) // Incoming request is for ACTIVE_REQUESTS + } + + //Check notification-url for the incoming request type + //ACTIVE_REQUESTS may have notificationurl node + //INFRA_ACTIVE_REQUESTS notificationurl node does not exist + def notificationurl = "" + if (utils.nodeExists(xml, "notification-url")) { + notificationurl = utils.getNodeText(xml,"notification-url") + if(notificationurl != null && !notificationurl.isEmpty()) { + utils.log("DEBUG", "********** Incoming notification Url is: " + notificationurl,isDebugLogEnabled); + execution.setVariable("FH_notification-url-Ok", true) + execution.setVariable("FH_notification-url",notificationurl) + } + } + + //Check request_id for the incoming request type + //For INFRA_ACTIVE_REQUESTS payload request-id IS optional (Not sure why this is option since req id is primary key ... also tried exe through SOAP UI to check if MSO code handles null like auto generated seq not it does not) + //For ACTIVE_REQUESTS payload request-id is NOT optional + def request_id = "" + if (utils.nodeExists(xml, "request-id")) { + execution.setVariable("FH_request_id",utils.getNodeText(xml,"request-id")) + } + utils.logAudit("FH_request_id: " + execution.getVariable("FH_request_id")) + + // INFRA_ACTIVE_REQUESTS have "action" element ... mandatory + // ACTIVE_REQUEST have "request-action" ... mandatory + if (utils.nodeExists(xml, "request-action")) { + execution.setVariable("FH_request_action",utils.getNodeText(xml,"request-action")) + } else if (utils.nodeExists(xml, "action")) { + execution.setVariable("FH_request_action",utils.getNodeText(xml,"action")) + } + + + //Check source for the incoming request type + //For INFRA_ACTIVE_REQUESTS payload source IS optional + //For ACTIVE_REQUESTS payload source is NOT optional + def source = "" + if (utils.nodeExists(xml, "source")) { + execution.setVariable("FH_source",utils.getNodeText(xml,"source")) + } + + //Check if ErrorCode node exists. If yes, initialize it from request xml, if no, it will stay with defaulf value already set in initializeProcessVariables() method above. + def errorCode = "" + if (utils.nodeExists(xml, "ErrorCode")) { + errorCode = utils.getNodeText(xml,"ErrorCode") + if(errorCode != null && !errorCode.isEmpty()) { + execution.setVariable("FH_ErrorCode", errorCode) + } + } + utils.logAudit("FH_ErrorCode: " + errorCode) + + //Check if ErrorMessage node exists. If yes, initialize it from request xml, if no, it will stay with defaulf value already set in initializeProcessVariables() method above. + def errorMessage = "" + if (utils.nodeExists(xml, "ErrorMessage")) { + errorCode = utils.getNodeText(xml,"ErrorMessage") + if(errorCode != null && !errorCode.isEmpty()) { + errorCode = errorCode.replace("&", "&").replace("<", "<").replace(">", ">") + execution.setVariable("FH_ErrorMessage", errorCode) + } + } + + //Check for Parameter List + if (utils.nodeExists(xml, "parameter-list")) { + def parameterList = utils.getNodeXml(xml, "parameter-list", false) + execution.setVariable("FH_parameterList", parameterList) + } + + utils.log("DEBUG","FH_notification-url-Ok --> " + execution.getVariable("FH_notification-url-Ok"),isDebugLogEnabled) + utils.log("DEBUG","FH_request_id-OK --> " + execution.getVariable("FH_request_id-Ok"),isDebugLogEnabled) + + // set the DHV/Service Instantiation values if specified in the request + execution.setVariable("FH_is_srv_inst_req", String.valueOf("true".equals(utils.getNodeText1(xml, "is-srv-inst-req")))) + utils.log("DEBUG", "FH_is_srv_inst_req --> " + execution.getVariable("FH_is_srv_inst_req"), isDebugLogEnabled) + execution.setVariable("FH_is_json_content", String.valueOf("JSON".equals(utils.getNodeText1(xml, "resp-content-type")))) + utils.log("DEBUG", "FH_is_json_content --> " + execution.getVariable("FH_is_json_content"), isDebugLogEnabled) + execution.setVariable("FH_service_inst_id", utils.getNodeText1(xml, "service-instance-id")) + utils.log("DEBUG", "FH_service_inst_id --> " + execution.getVariable("FH_service_inst_id"), isDebugLogEnabled) + execution.setVariable("FH_start_time", utils.getNodeText1(xml, "start-time")) + utils.log("DEBUG", "FH_start_time --> " + execution.getVariable("FH_start_time"), isDebugLogEnabled) + // this variable is used by the camunda flow to set the Content-Type for the async response + if (execution.getVariable("FH_is_srv_inst_req").equals("true") && + execution.getVariable("FH_is_json_content").equals("true")) { + execution.setVariable("FH_content_type", "application/json") + } else { + execution.setVariable("FH_content_type", "text/xml") + } + } catch (Exception e) { + logError('Caught exception in ' + method, e) + // exceptionUtil.buildWorkflowException(execution, 2000, "Internal Error - Occured in" + method) + } + + utils.log("DEBUG","OUTOF --> Initialize Variables Fallout Handler #########",isDebugLogEnabled); + } + + public String updateRequestPayload (Execution execution){ + def method = getClass().getSimpleName() + '.updateRequestPayload(' +'execution=' + execution.getId() +')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logDebug('Entered ' + method, isDebugLogEnabled) + + try { + String payload = """ + <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:req="http://org.openecomp.mso/requestsdb"> + <soapenv:Header/> + <soapenv:Body> + <req:updateRequest> + <requestId>${execution.getVariable("FH_request_id")}</requestId> + <lastModifiedBy>BPEL</lastModifiedBy> + <finalErrorMessage>${execution.getVariable("FH_ErrorMessage")}</finalErrorMessage> + <finalErrorCode>${execution.getVariable("FH_ErrorCode")}</finalErrorCode> + <status>FAILED</status> + <responseStatus>${execution.getVariable("FH_NOTIFY_STATUS")}</responseStatus> + </req:updateRequest> + </soapenv:Body> + </soapenv:Envelope> + """ + + utils.logAudit("updateRequestPayload: " + payload) + execution.setVariable("FH_updateRequestPayload", payload) + return execution.getVariable("FH_updateRequestPayload") + } catch (Exception e) { + logError('Caught exception in ' + method, e) + // exceptionUtil.buildWorkflowException(execution, 2000, "Internal Error - Occured in " + method) + } + } + + public String updateRequestInfraPayload (Execution execution){ + def method = getClass().getSimpleName() + '.updateRequestInfraPayload(' +'execution=' + execution.getId() +')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logDebug('Entered ' + method, isDebugLogEnabled) + + try { + String payload = """ + <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:req="http://org.openecomp.mso/requestsdb"> + <soapenv:Header/> + <soapenv:Body> + <req:updateInfraRequest> + <requestId>${execution.getVariable("FH_request_id")}</requestId> + <lastModifiedBy>BPEL</lastModifiedBy> + <statusMessage>${execution.getVariable("FH_ErrorMessage")}</statusMessage> + <requestStatus>FAILED</requestStatus> + <progress>100</progress> + </req:updateInfraRequest> + </soapenv:Body> + </soapenv:Envelope> + """ + + execution.setVariable("FH_updateRequestInfraPayload", payload) + utils.logAudit("updateRequestInfraPayload: " + payload) + return execution.getVariable("FH_updateRequestInfraPayload") + } catch (Exception e) { + logError('Caught exception in ' + method, e) + // exceptionUtil.buildWorkflowException(execution, 2000, "Internal Error - Occured in " + method) + } + } + + public String updateRequestGammaPayload (Execution execution){ + def method = getClass().getSimpleName() + '.updateRequestGammaPayload(' +'execution=' + execution.getId() +')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logDebug('Entered ' + method, isDebugLogEnabled) + + try { + String payload = """ + <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:req="http://org.openecomp.mso/requestsdb"> + <soapenv:Header/> + <soapenv:Body> + <req:updateRequest> + <requestId>${execution.getVariable("FH_request_id")}</requestId> + <lastModifiedBy>BPEL</lastModifiedBy> + <finalErrorMessage>${execution.getVariable("FH_ErrorMessage")}</finalErrorMessage> + <finalErrorCode>${execution.getVariable("FH_ErrorCode")}</finalErrorCode> + <status>FAILED</status> + </req:updateRequest> + </soapenv:Body> + </soapenv:Envelope> + """ + + execution.setVariable("FH_updateRequestGammaPayload", payload) + utils.logAudit("updateRequestGammaPayload: " + payload) + return execution.getVariable("FH_updateRequestGammaPayload") + } catch (Exception e) { + logError('Caught exception in ' + method, e) + // exceptionUtil.buildWorkflowException(execution, 2000, "Internal Error - Occured in " + method) + } + } + + public String updateResponseStatusPayload (Execution execution){ + def method = getClass().getSimpleName() + '.updateResponseStatusPayload(' +'execution=' + execution.getId() +')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logDebug('Entered ' + method, isDebugLogEnabled) + + try { + String payload = """ + <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:req="http://org.openecomp.mso/requestsdb"> + <soapenv:Header/> + <soapenv:Body> + <req:updateResponseStatus> + <requestId>${execution.getVariable("FH_request_id")}</requestId> + <lastModifiedBy>BPEL</lastModifiedBy> + <responseStatus>SENDING_FINAL_NOTIFY</responseStatus> + </req:updateResponseStatus> + </soapenv:Body> + </soapenv:Envelope> + """ + + execution.setVariable("FH_updateResponseStatusPayload", payload) + utils.logAudit("updateResponseStatusPayload: " + payload) + return execution.getVariable("FH_updateResponseStatusPayload") + } catch (Exception e) { + logError('Caught exception in ' + method, e) + // exceptionUtil.buildWorkflowException(execution, 2000, "Internal Error - Occured in " + method) + } + } + + public void buildDBWorkflowException(Execution execution, String responseCodeVariable) { + def method = getClass().getSimpleName() + '.buildDBWorkflowException(' + + 'execution=' + execution.getId() + + ', responseCodeVariable=' + responseCodeVariable + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logDebug('Entered ' + method, isDebugLogEnabled) + + try { + def responseCode = execution.getVariable(responseCodeVariable) + // If the HTTP response code was null, it means a connection fault occurred (a java exception) + def errorMessage = responseCode == null ? "Could not connect to DB Adapter" : "DB Adapter returned ${responseCode} response" + def errorCode = responseCode == null ? 7000 : 7020 + // exceptionUtil.buildWorkflowException(execution, errorCode, errorMessage) + } catch (Exception e) { + logError('Caught exception in ' + method, e) + // exceptionUtil.buildWorkflowException(execution, 2000, "Internal Error - Occured in " + method) + } + } + + /** + * Used to create a workflow response in success and failure cases. + */ + public void postProcessResponse (Execution execution) { + def method = getClass().getSimpleName() + '.postProcessResponse(' +'execution=' + execution.getId() +')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logDebug('Entered ' + method, isDebugLogEnabled) + + try { + Boolean success = (Boolean) execution.getVariable("FH_success") + String out = success ? "Fallout Handler Succeeded" : "Fallout Handler Failed"; + + def falloutHandlerResponse = """ + <workflow:FalloutHandlerResponse xmlns:workflow="http://org.openecomp/mso/workflow/schema/v1"> + <workflow:out>${out}</workflow:out> + </workflow:FalloutHandlerResponse> + """ + + falloutHandlerResponse = utils.formatXml(falloutHandlerResponse) + utils.logAudit("FalloutHandler Response: " + falloutHandlerResponse); + + execution.setVariable("FalloutHandlerResponse", falloutHandlerResponse) + execution.setVariable("WorkflowResponse", falloutHandlerResponse) + execution.setVariable("FH_ResponseCode", success ? "200" : "500") + setSuccessIndicator(execution, success) + + logDebug("FalloutHandlerResponse =\n" + falloutHandlerResponse, isDebugLogEnabled) + } catch (Exception e) { + // Do NOT throw WorkflowException! + logError('Caught exception in ' + method, e) + } + } +}
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenerateVfModuleName.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenerateVfModuleName.groovy new file mode 100644 index 0000000000..8001931525 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenerateVfModuleName.groovy @@ -0,0 +1,166 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.openecomp.mso.bpmn.common.scripts +import java.io.Serializable; + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.runtime.Execution +import org.springframework.web.util.UriUtils + +import org.openecomp.mso.bpmn.core.json.JsonUtils +import org.openecomp.mso.bpmn.core.WorkflowException +import org.openecomp.mso.rest.APIResponse; +import org.openecomp.mso.rest.RESTClient +import org.openecomp.mso.rest.RESTConfig + +public class GenerateVfModuleName extends AbstractServiceTaskProcessor{ + + def Prefix="GVFMN_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + + + + public void preProcessRequest(Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + + try { + def vnfId = execution.getVariable("vnfId") + utils.log("DEBUG", "vnfId is " + vnfId, isDebugEnabled) + def vnfName = execution.getVariable("vnfName") + utils.log("DEBUG", "vnfName is " + vnfName, isDebugEnabled) + def vfModuleLabel = execution.getVariable("vfModuleLabel") + utils.log("DEBUG", "vfModuleLabel is " + vfModuleLabel, isDebugEnabled) + def personaModelId = execution.getVariable("personaModelId") + utils.log("DEBUG", "personaModelId is " + personaModelId, isDebugEnabled) + execution.setVariable("GVFMN_vfModuleXml", "") + }catch(BpmnError b){ + throw b + }catch(Exception e){ + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error encountered in initVariables method!") + } + } + + + public void queryAAI(Execution execution) { + def isDebugLogEnabled=execution.getVariable("isDebugLogEnabled") + def method = getClass().getSimpleName() + '.queryAAI(' + + 'execution=' + execution.getId() + + ')' + logDebug('Entered ' + method, isDebugLogEnabled) + + try { + def vnfId = execution.getVariable('vnfId') + def personaModelId = execution.getVariable('personaModelId') + + AaiUtil aaiUriUtil = new AaiUtil(this) + String aai_uri = aaiUriUtil.getNetworkGenericVnfUri(execution) + logDebug('AAI URI is: ' + aai_uri, isDebugLogEnabled) + + String endPoint = execution.getVariable("URN_aai_endpoint") + "${aai_uri}/" + UriUtils.encode(vnfId, "UTF-8") + "?depth=1" + utils.logAudit("AAI endPoint: " + endPoint) + + try { + RESTConfig config = new RESTConfig(endPoint); + def responseData = '' + def aaiRequestId = UUID.randomUUID().toString() + RESTClient client = new RESTClient(config). + addHeader('X-TransactionId', aaiRequestId). + addHeader('X-FromAppId', 'MSO'). + addHeader('Content-Type', 'application/xml'). + addHeader('Accept','application/xml'); + logDebug('sending GET to AAI endpoint \'' + endPoint + '\'', isDebugLogEnabled) + APIResponse response = client.httpGet() + utils.logAudit("GenerateVfModuleName - invoking httpGet() to AAI") + + responseData = response.getResponseBodyAsString() + if (responseData != null) { + logDebug("Received generic VNF data: " + responseData, isDebugLogEnabled) + + } + + utils.logAudit("GenerateVfModuleName - queryAAIVfModule Response: " + responseData) + utils.logAudit("GenerateVfModuleName - queryAAIVfModule ResponseCode: " + response.getStatusCode()) + + execution.setVariable('GVFMN_queryAAIVfModuleResponseCode', response.getStatusCode()) + execution.setVariable('GVFMN_queryAAIVfModuleResponse', responseData) + logDebug('Response code:' + response.getStatusCode(), isDebugLogEnabled) + logDebug('Response:' + System.lineSeparator() + responseData, isDebugLogEnabled) + if (response.getStatusCode() == 200) { + // Set the VfModuleXML + if (responseData != null) { + String vfModulesText = utils.getNodeXml(responseData, "vf-modules") + if (vfModulesText == null || vfModulesText.isEmpty()) { + logDebug("There are no VF modules in this VNF yet", isDebugLogEnabled) + execution.setVariable("GVFMN_vfModuleXml", null) + } + else { + def xmlVfModules= new XmlSlurper().parseText(vfModulesText) + def vfModules = xmlVfModules.'**'.findAll {it.name() == "vf-module"} + int vfModulesSize = 0 + if (vfModules != null) { + vfModulesSize = vfModules.size() + } + String matchingVfModules = "<vfModules>" + for (i in 0..vfModulesSize-1) { + def vfModuleXml = groovy.xml.XmlUtil.serialize(vfModules[i]) + def personaModelIdFromAAI = utils.getNodeText(vfModuleXml, "persona-model-id") + if (personaModelIdFromAAI != null && personaModelIdFromAAI.equals(personaModelId)) { + matchingVfModules = matchingVfModules + utils.removeXmlPreamble(vfModuleXml) + } + } + matchingVfModules = matchingVfModules + "</vfModules>" + logDebug("Matching VF Modules: " + matchingVfModules, isDebugLogEnabled) + execution.setVariable("GVFMN_vfModuleXml", matchingVfModules) + } + } + } + } catch (Exception ex) { + ex.printStackTrace() + logDebug('Exception occurred while executing AAI GET:' + ex.getMessage(),isDebugLogEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'AAI GET Failed:' + ex.getMessage()) + } + logDebug('Exited ' + method, isDebugLogEnabled) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + logError('Caught exception in ' + method, e) + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in queryAAI(): ' + e.getMessage()) + } + + } + + public void generateName (Execution execution) { + def isDebugLogEnabled=execution.getVariable("isDebugLogEnabled") + def method = getClass().getSimpleName() + '.generateName() ' + + 'execution=' + execution.getId() + + ')' + logDebug('Entered ' + method, isDebugLogEnabled) + + String vfModuleXml = execution.getVariable("GVFMN_vfModuleXml") + + String moduleIndex = utils.getLowestUnusedIndex(vfModuleXml) + logDebug("moduleIndex is: " + moduleIndex, isDebugLogEnabled) + def vnfName = execution.getVariable("vnfName") + def vfModuleLabel = execution.getVariable("vfModuleLabel") + def vfModuleName = vnfName + "_" + vfModuleLabel + "_" + moduleIndex + logDebug("vfModuleName is: " + vfModuleName, isDebugLogEnabled) + execution.setVariable("vfModuleName", vfModuleName) + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericDeleteService.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericDeleteService.groovy new file mode 100644 index 0000000000..2db3d97853 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericDeleteService.groovy @@ -0,0 +1,303 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common.scripts + +import static org.apache.commons.lang3.StringUtils.* + +import org.apache.commons.lang3.* +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.runtime.Execution +import org.openecomp.mso.rest.APIResponse +import org.springframework.web.util.UriUtils + + +/** + * This class supports the GenericDeleteService Sub Flow. + * This Generic sub flow can be used by any flow for the + * goal of deleting a Service-Instance or Service-Subscription. + * The calling flow must set the GENDS_type variable as "service-instance" + * or "service-subscription". + * + * If the resource-version is not provided by the calling flow + * then this sub flow will query the service-instance or + * service-subscription, prior to deleting it, in order to + * obtain this resource version. Upon successful completion of + * this sub flow the GENDS_SuccessIndicator will be true. A + * MSOWorkflowException will be thrown if an error occurs within this flow. + * + * Please map variables to the corresponding variable names + * below. + * + * Note - if this sub flow receives a Not Found (404) response + * from AAI at any time this will be considered an acceptable + * response. + * + * Incoming Variables (Service-Instance): + * @param - GENDS_serviceInstanceId + * @param - GENDS_serviceType + * @param - GENDS_globalCustomerId + * @param - GENDS_type + * @param (Optional) - GENDS_resourceVersion + * + * Incoming Variables (Service-Subscription): + * @param - GENDS_serviceType + * @param - GENDS_globalCustomerId + * @param - GENDS_type + * @param (Optional) - GENDS_resourceVersion + * + * + * Outgoing Variables: + * @param - GENDS_SuccessIndicator + * @param - GENDS_FoundIndicator + * @param - WorkflowException + */ +class GenericDeleteService extends AbstractServiceTaskProcessor{ + + String Prefix = "GENDS_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + + /** + * This method validates the incoming variables and + * determines if the resource version was provided + * + * @param - execution + */ + public void preProcessRequest(Execution execution) { + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix",Prefix) + utils.log("DEBUG", " *** STARTED GenericDeleteService PreProcessRequest Process*** ", isDebugEnabled) + + execution.setVariable("GENDS_resourceVersionProvidedFlag", true) + execution.setVariable("GENDS_SuccessIndicator", false) + execution.setVariable("GENDS_FoundIndicator", false) + + try{ + // Get Variables + String globalCustomerId = execution.getVariable("GENDS_globalCustomerId") + String serviceInstanceId = execution.getVariable("GENDS_serviceInstanceId") + String serviceType = execution.getVariable("GENDS_serviceType") + String type = execution.getVariable("GENDS_type") + + if(type != null){ + utils.log("DEBUG", "Incoming GENDS_type is: " + type, isDebugEnabled) + if(isBlank(globalCustomerId) || isBlank(serviceType)){ + utils.log("DEBUG", "Incoming Required Variable is null!", isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Incoming Required Variable is Missing or Null!") + }else{ + utils.log("DEBUG", "Incoming Global Customer Id is: " + globalCustomerId, isDebugEnabled) + utils.log("DEBUG", "Incoming Service Type is: " + serviceType, isDebugEnabled) + if(type.equalsIgnoreCase("service-instance")){ + if(isBlank(serviceInstanceId)){ + utils.log("DEBUG", "Incoming Required Variable is null!", isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Incoming Required Variable is Missing or Null!") + }else{ + utils.log("DEBUG", "Incoming Service Instance Id is: " + serviceInstanceId, isDebugEnabled) + utils.log("DEBUG", "Preparing Delete Service-Instance Process", isDebugEnabled) + } + }else if(type.equalsIgnoreCase("service-subscription")){ + utils.log("DEBUG", "Preparing Delete Service-Subscription Process", isDebugEnabled) + }else{ + exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Incoming Type is Invalid. Please Specify Type as service-instance or service-subscription") + } + } + + String resourceVersion = execution.getVariable('GENDS_resourceVersion') + if(isBlank(resourceVersion)){ + utils.log("DEBUG", "Service Instance Resource Version is NOT Provided", isDebugEnabled) + execution.setVariable("GENDS_resourceVersionProvidedFlag", false) + }else{ + utils.log("DEBUG", "Incoming SI Resource Version is: " + resourceVersion, isDebugEnabled) + } + + }else{ + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Incoming GENDS_type is null. Variable is Required.") + } + }catch(BpmnError b){ + utils.log("DEBUG", "Rethrowing MSOWorkflowException", isDebugEnabled) + throw b + }catch(Exception e){ + utils.log("ERROR", " Error encountered within GenericDeleteService PreProcessRequest method!" + e, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in GenericDeleteService PreProcessRequest") + + } + utils.log("DEBUG", "*** COMPLETED GenericDeleteService PreProcessRequest Process ***", isDebugEnabled) + } + + /** + * This method executes a GET call to AAI for the service instance + * or service-subscription so that the objects's resource-version + * can be obtained. + * + * @param - execution + */ + public void getServiceResourceVersion(Execution execution){ + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix",Prefix) + utils.log("DEBUG", " *** STARTED GenericDeleteService GetServiceResourceVersion Process*** ", isDebugEnabled) + try { + String serviceType = execution.getVariable("GENDS_serviceType") + utils.log("DEBUG", " Incoming GENDS_serviceType is: " + serviceType, isDebugEnabled) + String globalCustomerId = execution.getVariable("GENDS_globalCustomerId") + utils.log("DEBUG", "Incoming Global Customer Id is: " + globalCustomerId, isDebugEnabled) + String type = execution.getVariable("GENDS_type") + String serviceEndpoint = "" + + if(type.equalsIgnoreCase("service-instance")){ + String serviceInstanceId = execution.getVariable("GENDS_serviceInstanceId") + utils.log("DEBUG", " Incoming GENDS_serviceInstanceId is: " + serviceInstanceId, isDebugEnabled) + serviceEndpoint = UriUtils.encode(globalCustomerId,"UTF-8") + "/service-subscriptions/service-subscription/" + UriUtils.encode(serviceType,"UTF-8") + "/service-instances/service-instance/" + UriUtils.encode(serviceInstanceId,"UTF-8") + + }else if(type.equalsIgnoreCase("service-subscription")){ + serviceEndpoint = UriUtils.encode(globalCustomerId,"UTF-8") + "/service-subscriptions/service-subscription/" + UriUtils.encode(serviceType,"UTF-8") + } + + String aai_endpoint = execution.getVariable("URN_aai_endpoint") + AaiUtil aaiUriUtil = new AaiUtil(this) + String aai_uri = aaiUriUtil.getBusinessCustomerUri(execution) + logDebug('AAI URI is: ' + aai_uri, isDebugEnabled) + + String serviceAaiPath = "${aai_endpoint}${aai_uri}/" + serviceEndpoint + + execution.setVariable("GENDS_serviceAaiPath", serviceAaiPath) + utils.log("DEBUG", "GET Service Instance AAI Path is: " + "\n" + serviceAaiPath, isDebugEnabled) + utils.logAudit("GenericDeleteService GET AAI Path: " + serviceAaiPath) + + APIResponse response = aaiUriUtil.executeAAIGetCall(execution, serviceAaiPath) + int responseCode = response.getStatusCode() + execution.setVariable("GENDS_getServiceResponseCode", responseCode) + utils.log("DEBUG", " GET Service Instance response code is: " + responseCode, isDebugEnabled) + utils.logAudit("GET Service Instance response code: " + responseCode) + + String aaiResponse = response.getResponseBodyAsString() + aaiResponse = StringEscapeUtils.unescapeXml(aaiResponse) + execution.setVariable("GENDS_getServiceResponse", aaiResponse) + + utils.logAudit("GET Service Instance response : " + aaiResponse) + //Process Response + if(responseCode == 200 || responseCode == 202){ + utils.log("DEBUG", "GET Service Received a Good Response: \n" + aaiResponse, isDebugEnabled) + execution.setVariable("GENDS_SuccessIndicator", true) + execution.setVariable("GENDS_FoundIndicator", true) + String resourceVersion = utils.getNodeText1(aaiResponse, "resource-version") + execution.setVariable("GENDS_resourceVersion", resourceVersion) + utils.log("DEBUG", type + " Resource Version is: " + resourceVersion, isDebugEnabled) + + }else if(responseCode == 404){ + utils.log("DEBUG", "GET Service Received a Not Found (404) Response", isDebugEnabled) + execution.setVariable("GENDS_SuccessIndicator", true) + execution.setVariable("WorkflowResponse", " ") // for junits + } + else{ + utils.log("DEBUG", " GET Service Received a Bad Response: \n" + aaiResponse, isDebugEnabled) + exceptionUtil.MapAAIExceptionToWorkflowExceptionGeneric(execution, aaiResponse, responseCode) + throw new BpmnError("MSOWorkflowException") + } + }catch(BpmnError b){ + utils.log("DEBUG", "Rethrowing MSOWorkflowException", isDebugEnabled) + throw b + }catch(Exception e){ + utils.log("DEBUG", " Error encountered within GenericDeleteService GetServiceResourceVersion method!" + e, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured During GetServiceResourceVersion") + } + utils.log("DEBUG", " *** COMPLETED GenericDeleteService GetServiceResourceVersion Process*** ", isDebugEnabled) + } + + /** + * This method executes a DELETE call to AAI for the provided + * service-instance or service-subscription. + * + * @param - execution + */ + public void deleteServiceObject(Execution execution){ + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix",Prefix) + utils.log("DEBUG", " *** STARTED GenericDeleteService DeleteServiceObject Process*** ", isDebugEnabled) + try { + AaiUtil aaiUriUtil = new AaiUtil(this) + String type = execution.getVariable("GENDS_type") + String serviceAaiPath = execution.getVariable("GENDS_serviceAaiPath") + String serviceEndpoint = "" + + if(isEmpty(serviceAaiPath)){ + String serviceType = execution.getVariable("GENDS_serviceType") + utils.log("DEBUG", " Incoming GENDS_serviceType is: " + serviceType, isDebugEnabled) + String globalCustomerId = execution.getVariable("GENDS_globalCustomerId") + utils.log("DEBUG", "Incoming Global Customer Id is: " + globalCustomerId, isDebugEnabled) + if(type.equalsIgnoreCase("service-instance")){ + String serviceInstanceId = execution.getVariable("GENDS_serviceInstanceId") + utils.log("DEBUG", " Incoming GENDS_serviceInstanceId is: " + serviceInstanceId, isDebugEnabled) + serviceEndpoint = UriUtils.encode(globalCustomerId,"UTF-8") + "/service-subscriptions/service-subscription/" + UriUtils.encode(serviceType,"UTF-8") + "/service-instances/service-instance/" + UriUtils.encode(serviceInstanceId,"UTF-8") + + }else if(type.equalsIgnoreCase("service-subscription")){ + serviceEndpoint = UriUtils.encode(globalCustomerId,"UTF-8") + "/service-subscriptions/service-subscription/" + UriUtils.encode(serviceType,"UTF-8") + } + + String aai_endpoint = execution.getVariable("URN_aai_endpoint") + String aai_uri = aaiUriUtil.getBusinessCustomerUri(execution) + logDebug('AAI URI is: ' + aai_uri, isDebugEnabled) + + serviceAaiPath = "${aai_endpoint}${aai_uri}/" + serviceEndpoint + } + + String resourceVersion = execution.getVariable("GENDS_resourceVersion") + utils.log("DEBUG", "Incoming Resource Version is: " + resourceVersion, isDebugEnabled) + if(resourceVersion !=null){ + serviceAaiPath = serviceAaiPath +'?resource-version=' + UriUtils.encode(resourceVersion,"UTF-8") + } + + execution.setVariable("GENDS_deleteServiceAaiPath", serviceAaiPath) + utils.log("DEBUG", "DELETE Service AAI Path is: " + "\n" + serviceAaiPath, isDebugEnabled) + utils.logAudit("DELETE Service AAI Path: " + serviceAaiPath) + + APIResponse response = aaiUriUtil.executeAAIDeleteCall(execution, serviceAaiPath) + int responseCode = response.getStatusCode() + execution.setVariable("GENDS_deleteServiceResponseCode", responseCode) + utils.log("DEBUG", " DELETE Service response code is: " + responseCode, isDebugEnabled) + utils.logAudit("DELETE Service Response Code: " + responseCode) + + String aaiResponse = response.getResponseBodyAsString() + aaiResponse = StringEscapeUtils.unescapeXml(aaiResponse) + execution.setVariable("GENDS_deleteServiceResponse", aaiResponse) + utils.logAudit("DELETE Service Response: " + aaiResponse) + + //Process Response + if(responseCode == 200 || responseCode == 204){ + utils.log("DEBUG", " DELETE Service Received a Good Response", isDebugEnabled) + execution.setVariable("GENDS_FoundIndicator", true) + }else if(responseCode == 404){ + utils.log("DEBUG", " DELETE Service Received a Not Found (404) Response", isDebugEnabled) + execution.setVariable("GENDS_FoundIndicator", false) + }else{ + utils.log("DEBUG", "DELETE Service Received a BAD REST Response: \n" + aaiResponse, isDebugEnabled) + exceptionUtil.MapAAIExceptionToWorkflowExceptionGeneric(execution, aaiResponse, responseCode) + throw new BpmnError("MSOWorkflowException") + } + }catch(BpmnError b){ + utils.log("DEBUG", "Rethrowing MSOWorkflowException", isDebugEnabled) + throw b + }catch(Exception e){ + utils.log("DEBUG", " Error encountered within GenericDeleteService DeleteServiceObject method!" + e, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured During Delete Service Object") + } + utils.log("DEBUG", " *** COMPLETED GenericDeleteService DeleteServiceObject Process*** ", isDebugEnabled) + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericDeleteVnf.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericDeleteVnf.groovy new file mode 100644 index 0000000000..979083377e --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericDeleteVnf.groovy @@ -0,0 +1,274 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common.scripts + +import static org.apache.commons.lang3.StringUtils.* + +import org.apache.commons.lang3.* +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.runtime.Execution +import org.openecomp.mso.rest.APIResponse +import org.springframework.web.util.UriUtils + + +/** + * TODO: Support getting vnf type = vpe + * + * This class supports the GenericGetVnf Sub Flow. + * This Generic sub flow can be used by any flow for accomplishing + * the goal of getting a Vnf Object (from AAI). The flow currently + * supports the querying of 2 types of Vnfs, generic-vnf and vce. The + * type must be provided by the calling flow and the type should + * be mapped to the variable GENDV_type. The type should either be + * "generic-vnf" or "vce". If the Vnf Id is not provided by the calling + * flow then this sub flow will execute the query to get the + * Vnf using the Vnf Name. Therefore, the calling flow must provide + * either the Vnf Id or Vnf Name. + * + * Upon successful completion of this sub flow the + * GENDV_SuccessIndicator will be true and the query response payload + * will be set to GENDV_vnf. An MSOWorkflowException will + * be thrown upon unsuccessful completion or if an error occurs + * at any time during this sub flow. Please map variables + * to the corresponding variable names below. + * + * Note - if this sub flow receives a Not Found (404) response + * from AAI at any time this will be considered an acceptable + * successful response however the GENDV_FoundIndicator + * set to false. This will allow the calling flow to distinguish + * between the two success scenarios, "Success where Vnf is found" + * and "Success where Vnf is NOT found". + * + * + * Incoming Variables: + * @param - GENDV_vnfId + * @param - GENDV_type + * @param (Optional) - GENDV_resourceVersion + * + * + * Outgoing Variables: + * @param - GENDV_vnf + * @param - GENDV_SuccessIndicator + * @param - GENDV_FoundIndicator + * @param - WorkflowException + */ +class GenericDeleteVnf extends AbstractServiceTaskProcessor{ + + String Prefix = "GENDV_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + + /** + * This method validates the incoming variables and + * determines if the resource version was provided + * + * @param - execution + */ + public void preProcessRequest(Execution execution) { + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix",Prefix) + utils.log("DEBUG", " *** STARTED GenericDeleteVnf PreProcessRequest Process*** ", isDebugEnabled) + + execution.setVariable("GENDV_resourceVersionProvided", true) + execution.setVariable("GENDV_SuccessIndicator", false) + execution.setVariable("GENDV_FoundIndicator", false) + + try{ + // Get Variables + String vnfId = execution.getVariable("GENDV_vnfId") + String type = execution.getVariable("GENDV_type") + + if(isBlank(type) || isBlank(vnfId)){ + utils.log("ERROR", "Incoming Required Variable is null!", isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Incoming Required Variable is Missing or Null!") + }else{ + utils.log("DEBUG", "Incoming Vnf Id is: " + vnfId, isDebugEnabled) + + String resourceVersion = execution.getVariable("GENDV_resourceVersion") + if(isBlank(resourceVersion)){ + utils.log("DEBUG", "Vnf Resource Version is NOT Provided", isDebugEnabled) + execution.setVariable("GENDV_resourceVersionProvided", false) + }else{ + utils.log("DEBUG", "Incoming Vnf Resource Version is: " + resourceVersion, isDebugEnabled) + } + } + }catch(BpmnError b){ + utils.log("DEBUG", "Rethrowing MSOWorkflowException", isDebugEnabled) + throw b + }catch(Exception e){ + utils.log("ERROR", " Error encountered within GenericDeleteVnf PreProcessRequest method!" + e, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in GenericDeleteVnf PreProcessRequest") + + } + utils.log("DEBUG", "*** COMPLETED GenericDeleteVnf PreProcessRequest Process ***", isDebugEnabled) + } + + /** + * This method executes a GET call to AAI for the Vnf + * so that the Vnf's resource-version can be + * obtained. + * + * @param - execution + */ + public void getVnfResourceVersion(Execution execution){ + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix",Prefix) + utils.log("DEBUG", " *** STARTED GenericDeleteVnf GetVnfResourceVersion Process*** ", isDebugEnabled) + try { + String vnfId = execution.getVariable("GENDV_vnfId") + String type = execution.getVariable("GENDV_type") + utils.log("DEBUG", "Type of Vnf Getting is: " + type, isDebugEnabled) + + String aai_endpoint = execution.getVariable("URN_aai_endpoint") + AaiUtil aaiUriUtil = new AaiUtil(this) + + //Determine Type of Vnf Querying For + def aai_uri = "" + if(type.equals("generic-vnf")){ + aai_uri = aaiUriUtil.getNetworkGenericVnfUri(execution) + }else if(type.equals("vce")){ + aai_uri = aaiUriUtil.getNetworkVceUri(execution) + }else{ + utils.log("DEBUG", "Invalid Incoming GENDV_type", isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Invalid Incoming GENDV_type") + } + + String getVnfPath = "${aai_endpoint}${aai_uri}/" + UriUtils.encode(vnfId, "UTF-8") + + execution.setVariable("GENDV_getVnfPath", getVnfPath) + utils.logAudit("Get Vnf Resource Version Url is: " + getVnfPath) + + APIResponse response = aaiUriUtil.executeAAIGetCall(execution, getVnfPath) + int responseCode = response.getStatusCode() + execution.setVariable("GENDV_getVnfResponseCode", responseCode) + utils.log("DEBUG", " GET Vnf response code is: " + responseCode, isDebugEnabled) + + utils.logAudit("GenericDeleteVnf Get VNF Response Code: " + responseCode) + String aaiResponse = response.getResponseBodyAsString() + aaiResponse = StringEscapeUtils.unescapeXml(aaiResponse) + execution.setVariable("GENDV_getVnfResponse", aaiResponse) + + utils.logAudit("GenericDeleteVnf Get VNF Response: " + aaiResponse) + //Process Response + if(responseCode == 200 || responseCode == 202){ + utils.log("DEBUG", "GET Vnf Received a Good Response: \n" + aaiResponse, isDebugEnabled) + execution.setVariable("GENDV_FoundIndicator", true) + if(utils.nodeExists(aaiResponse, "resource-version")){ + String resourceVersion = utils.getNodeText1(aaiResponse, "resource-version") + execution.setVariable("GENDV_resourceVersion", resourceVersion) + utils.log("DEBUG", "SI Resource Version is: " + resourceVersion, isDebugEnabled) + }else{ + utils.log("DEBUG", "GET Vnf for Resource Version Response Does NOT Contain a resource-version", isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 400, "Unable to obtain Vnf resource-version. GET Vnf Response Does NOT Contain a resource-version") + } + + }else if(responseCode == 404){ + utils.log("DEBUG", "GET Vnf Received a Not Found (404) Response", isDebugEnabled) + execution.setVariable("GENDV_SuccessIndicator", true) + execution.setVariable("WorkflowResponse", " ") // for junits + } + else{ + utils.log("DEBUG", " GET Vnf Received a Bad Response: \n" + aaiResponse, isDebugEnabled) + exceptionUtil.MapAAIExceptionToWorkflowExceptionGeneric(execution, aaiResponse, responseCode) + throw new BpmnError("MSOWorkflowException") + } + }catch(BpmnError b){ + utils.log("DEBUG", "Rethrowing MSOWorkflowException", isDebugEnabled) + throw b + }catch(Exception e){ + utils.log("DEBUG", " Error encountered within GenericDeleteVnf GetVnfResourceVersion method!" + e, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured During GetVnfResourceVersion") + } + utils.log("DEBUG", " *** COMPLETED GenericDeleteVnf GetVnfResourceVersion Process*** ", isDebugEnabled) + } + + /** + * This method executes a DELETE call to AAI for the provided + * Vnf. + * + * @param - execution + */ + public void deleteVnf(Execution execution){ + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix",Prefix) + utils.log("DEBUG", " *** STARTED GenericDeleteVnf DeleteVnf Process*** ", isDebugEnabled) + try { + String vnfId = execution.getVariable("GENDV_vnfId") + String type = execution.getVariable("GENDV_type") + utils.log("DEBUG", "Type of Vnf Getting is: " + type, isDebugEnabled) + String resourceVersion = execution.getVariable("GENDV_resourceVersion") + utils.log("DEBUG", "Incoming Vnf Resource Version is: " + resourceVersion, isDebugEnabled) + + String aai_endpoint = execution.getVariable("URN_aai_endpoint") + AaiUtil aaiUriUtil = new AaiUtil(this) + + //Determine Type of Vnf Querying For + def aai_uri = "" + if(type.equals("generic-vnf")){ + aai_uri = aaiUriUtil.getNetworkGenericVnfUri(execution) + }else if(type.equals("vce")){ + aai_uri = aaiUriUtil.getNetworkVceUri(execution) + }else{ + utils.log("DEBUG", "Invalid Incoming GENDV_type", isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Invalid Incoming GENDV_type") + } + + String deleteVnfPath = "${aai_endpoint}${aai_uri}/" + UriUtils.encode(vnfId, "UTF-8") +'?resource-version=' + UriUtils.encode(resourceVersion,"UTF-8") + + execution.setVariable("GENDV_deleteVnfPath", deleteVnfPath) + utils.logAudit("Delete Vnf Url is: " + deleteVnfPath) + + APIResponse response = aaiUriUtil.executeAAIDeleteCall(execution, deleteVnfPath) + int responseCode = response.getStatusCode() + execution.setVariable("GENDV_deleteVnfResponseCode", responseCode) + utils.log("DEBUG", " DELETE Vnf response code is: " + responseCode, isDebugEnabled) + + utils.logAudit("GenericDeleteVnf Delete VNF Response Code: " + responseCode) + String aaiResponse = response.getResponseBodyAsString() + aaiResponse = StringEscapeUtils.unescapeXml(aaiResponse) + execution.setVariable("GENDV_deleteVnfResponse", aaiResponse) + + utils.logAudit("GenericDeleteVnf Delete VNF Response: " + aaiResponse) + //Process Response + if(responseCode == 204){ + utils.log("DEBUG", " DELETE Vnf Received a Good Response", isDebugEnabled) + execution.setVariable("GENDV_FoundIndicator", true) + }else if(responseCode == 404){ + utils.log("DEBUG", " DELETE Vnf Received a Not Found (404) Response", isDebugEnabled) + }else if(responseCode == 412){ + utils.log("DEBUG", "DELETE Vnf Received a Resource Version Mismatch Error: \n" + aaiResponse, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 412, "Delete Vnf Received a resource-version Mismatch Error Response from AAI") + }else{ + utils.log("DEBUG", "DELETE Vnf Received a BAD REST Response: \n" + aaiResponse, isDebugEnabled) + exceptionUtil.MapAAIExceptionToWorkflowExceptionGeneric(execution, aaiResponse, responseCode) + throw new BpmnError("MSOWorkflowException") + } + }catch(BpmnError b){ + utils.log("DEBUG", "Rethrowing MSOWorkflowException", isDebugEnabled) + throw b + }catch(Exception e){ + utils.log("DEBUG", " Error encountered within GenericDeleteVnf DeleteVnf method!" + e, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured During Delete Vnf") + } + utils.log("DEBUG", " *** COMPLETED GenericDeleteVnf DeleteVnf Process*** ", isDebugEnabled) + } + + +} diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericGetService.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericGetService.groovy new file mode 100644 index 0000000000..304f33edcc --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericGetService.groovy @@ -0,0 +1,381 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common.scripts + +import static org.apache.commons.lang3.StringUtils.* + +import org.apache.commons.lang3.* +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.runtime.Execution +import org.openecomp.mso.rest.APIResponse +import org.springframework.web.util.UriUtils + + +/** + * This class supports the GenericGetService Sub Flow. + * This Generic sub flow can be used by any flow for accomplishing + * the goal of getting a Service-Instance or Service-Subscription (from AAI). + * The calling flow must set the GENGS_type variable as "service-instance" + * or "service-subscription". + * + * When using to Get a Service-Instance: + * If the global-customer-id and service-type are not provided + * this flow executes a query to get the service- Url using the + * Service Id or Name (whichever is provided). + * + * When using to Get a Service-Subscription: + * The global-customer-id and service-type must be + * provided. + * + * Upon successful completion of this sub flow the + * GENGS_SuccessIndicator will be true and the query response payload + * will be set to GENGS_service. An MSOWorkflowException will + * be thrown upon unsuccessful completion or if an error occurs + * at any time during this sub flow. Please map variables + * to the corresponding variable names below. + * + * Note - If this sub flow receives a Not Found (404) response + * from AAI at any time this will be considered an acceptable + * successful response however the GENGS_FoundIndicator + * will be set to false. This variable will allow the calling flow + * to distinguish between the two Success scenarios, + * "Success where service- is found" and + * "Success where service- is NOT found". + * + * + * Incoming Variables (Service-Instance): + * @param - GENGS_serviceInstanceId or @param - GENGS_serviceInstanceName + * @param - GENGS_type + * @param (Optional) - GENGS_serviceType + * @param (Optional) - GENGS_globalCustomerId + * + * Incoming Variables (Service-Subscription): + * @param - GENGS_type + * @param - GENGS_serviceType + * @param - GENGS_globalCustomerId + * + * + * Outgoing Variables: + * @param - GENGS_service + * @param - GENGS_SuccessIndicator + * @param - GENGS_FoundIndicator + * @param - WorkflowException + */ +class GenericGetService extends AbstractServiceTaskProcessor{ + + String Prefix = "GENGS_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + + /** + * This method validates the incoming variables and + * determines the subsequent event based on which + * variables the calling flow provided. + * + * @param - execution + */ + public void preProcessRequest(Execution execution) { + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix",Prefix) + utils.log("DEBUG", " *** STARTED GenericGetService PreProcessRequest Process*** ", isDebugEnabled) + + execution.setVariable("GENGS_obtainServiceInstanceUrl", false) + execution.setVariable("GENGS_obtainServiceInstanceUrlByName", false) + execution.setVariable("GENGS_SuccessIndicator", false) + execution.setVariable("GENGS_FoundIndicator", false) + execution.setVariable("GENGS_siResourceLink", null) + + try{ + // Get Variables + String serviceInstanceId = execution.getVariable("GENGS_serviceInstanceId") + String serviceInstanceName = execution.getVariable("GENGS_serviceInstanceName") + String serviceType = execution.getVariable("GENGS_serviceType") + String globalCustomerId = execution.getVariable("GENGS_globalCustomerId") + String type = execution.getVariable("GENGS_type") + + if(type != null){ + utils.log("DEBUG", "Incoming GENGS_type is: " + type, isDebugEnabled) + if(type.equalsIgnoreCase("service-instance")){ + if(isBlank(serviceInstanceId) && isBlank(serviceInstanceName)){ + utils.log("DEBUG", "Incoming serviceInstanceId and serviceInstanceName are null. ServiceInstanceId or ServiceInstanceName is required to Get a service-instance.", isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Incoming serviceInstanceId and serviceInstanceName are null. ServiceInstanceId or ServiceInstanceName is required to Get a service-instance.") + }else{ + utils.log("DEBUG", "Incoming Service Instance Id is: " + serviceInstanceId, isDebugEnabled) + utils.log("DEBUG", "Incoming Service Instance Name is: " + serviceInstanceName, isDebugEnabled) + if(isBlank(globalCustomerId) || isBlank(serviceType)){ + execution.setVariable("GENGS_obtainServiceInstanceUrl", true) + if(isBlank(serviceInstanceId)){ + execution.setVariable("GENGS_obtainServiceInstanceUrlByName", true) + } + }else{ + utils.log("DEBUG", "Incoming Global Customer Id is: " + globalCustomerId, isDebugEnabled) + utils.log("DEBUG", "Incoming Service Type is: " + serviceType, isDebugEnabled) + } + } + }else if(type.equalsIgnoreCase("service-subscription")){ + if(isBlank(serviceType) || isBlank(globalCustomerId)){ + utils.log("DEBUG", "Incoming ServiceType or GlobalCustomerId is null. These variables are required to Get a service-subscription.", isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Incoming ServiceType or GlobalCustomerId is null. These variables are required to Get a service-subscription.") + }else{ + utils.log("DEBUG", "Incoming Service Type is: " + serviceType, isDebugEnabled) + utils.log("DEBUG", "Incoming Global Customer Id is: " + globalCustomerId, isDebugEnabled) + } + }else{ + exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Incoming Type is Invalid. Please Specify Type as service-instance or service-subscription") + } + }else{ + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Incoming GENGS_type is null. Variable is Required.") + } + + }catch(BpmnError b){ + utils.log("DEBUG", "Rethrowing MSOWorkflowException", isDebugEnabled) + throw b + }catch(Exception e){ + utils.log("DEBUG", "Internal Error encountered within GenericGetService PreProcessRequest method!" + e, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in GenericGetService PreProcessRequest") + + } + utils.log("DEBUG", "*** COMPLETED GenericGetService PreProcessRequest Process ***", isDebugEnabled) + } + + /** + * This method obtains the Url to the provided service instance + * using the Service Instance Id. + * + * @param - execution + */ + public void obtainServiceInstanceUrlById(Execution execution){ + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix",Prefix) + utils.log("DEBUG", " *** STARTED GenericGetService ObtainServiceInstanceUrlById Process*** ", isDebugEnabled) + try { + String serviceInstanceId = execution.getVariable("GENGS_serviceInstanceId") + utils.log("DEBUG", " Querying Node for Service-Instance URL by using Service-Instance Id: " + serviceInstanceId, isDebugEnabled) + + AaiUtil aaiUriUtil = new AaiUtil(this) + String aai_uri = aaiUriUtil.getSearchNodesQueryEndpoint(execution) + String aai_endpoint = execution.getVariable("URN_aai_endpoint") + + utils.logAudit("GenericGetService AAI Endpoint: " + aai_endpoint) + String path = "${aai_uri}?search-node-type=service-instance&filter=service-instance-id:EQUALS:${serviceInstanceId}" + + //String url = "${aai_endpoint}${path}" host name needs to be removed from property + String url = "${path}" + execution.setVariable("GENGS_obtainSIUrlPath", url) + + APIResponse response = aaiUriUtil.executeAAIGetCall(execution, url) + int responseCode = response.getStatusCode() + execution.setVariable("GENGS_obtainSIUrlResponseCode", responseCode) + utils.log("DEBUG", " GET Service Instance response code is: " + responseCode, isDebugEnabled) + utils.logAudit("GenericGetService AAI GET Response Code: " + responseCode) + + String aaiResponse = response.getResponseBodyAsString() + aaiResponse = StringEscapeUtils.unescapeXml(aaiResponse) + execution.setVariable("GENGS_obtainSIUrlResponse", aaiResponse) + utils.logAudit("GenericGetService AAI Response: " + aaiResponse) + //Process Response + if(responseCode == 200){ + utils.log("DEBUG", " Query for Service Instance Url Received a Good Response Code", isDebugEnabled) + execution.setVariable("GENGS_SuccessIndicator", true) + if(utils.nodeExists(aaiResponse, "result-data")){ + utils.log("DEBUG", "Query for Service Instance Url Response Does Contain Data" , isDebugEnabled) + execution.setVariable("GENGS_FoundIndicator", true) + String resourceLink = utils.getNodeText1(aaiResponse, "resource-link") + execution.setVariable("GENGS_siResourceLink", resourceLink) + }else{ + utils.log("DEBUG", "Query for Service Instance Url Response Does NOT Contains Data" , isDebugEnabled) + execution.setVariable("WorkflowResponse", " ") //for junits + } + }else if(responseCode == 404){ + utils.log("DEBUG", " Query for Service Instance Received a Not Found (404) Response", isDebugEnabled) + execution.setVariable("GENGS_SuccessIndicator", true) + execution.setVariable("WorkflowResponse", " ") //for junits + }else{ + utils.log("DEBUG", "Query for Service Instance Received a BAD REST Response: \n" + aaiResponse, isDebugEnabled) + exceptionUtil.MapAAIExceptionToWorkflowExceptionGeneric(execution, aaiResponse, responseCode) + throw new BpmnError("MSOWorkflowException") + } + }catch(BpmnError b){ + utils.log("DEBUG", "Rethrowing MSOWorkflowException", isDebugEnabled) + throw b + }catch(Exception e){ + utils.log("ERROR", " Error encountered within GenericGetService ObtainServiceInstanceUrlById method!" + e, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured During ObtainServiceInstanceUrlById") + } + utils.log("DEBUG", " *** COMPLETED GenericGetService ObtainServiceInstanceUrlById Process*** ", isDebugEnabled) + } + + /** + * This method obtains the Url to the provided service instance + * using the Service Instance Name. + * + * @param - execution + */ + public void obtainServiceInstanceUrlByName(Execution execution){ + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix",Prefix) + utils.log("DEBUG", " *** STARTED GenericGetService ObtainServiceInstanceUrlByName Process*** ", isDebugEnabled) + try { + String serviceInstanceName = execution.getVariable("GENGS_serviceInstanceName") + utils.log("DEBUG", " Querying Node for Service-Instance URL by using Service-Instance Name " + serviceInstanceName, isDebugEnabled) + + AaiUtil aaiUriUtil = new AaiUtil(this) + String aai_uri = aaiUriUtil.getSearchNodesQueryEndpoint(execution) + String aai_endpoint = execution.getVariable("URN_aai_endpoint") + String path = "${aai_uri}?search-node-type=service-instance&filter=service-instance-name:EQUALS:${serviceInstanceName}" + + //String url = "${aai_endpoint}${path}" host name needs to be removed from property + String url = "${path}" + execution.setVariable("GENGS_obtainSIUrlPath", url) + + utils.logAudit("GenericGetService AAI Endpoint: " + aai_endpoint) + APIResponse response = aaiUriUtil.executeAAIGetCall(execution, url) + int responseCode = response.getStatusCode() + execution.setVariable("GENGS_obtainSIUrlResponseCode", responseCode) + utils.log("DEBUG", " GET Service Instance response code is: " + responseCode, isDebugEnabled) + utils.logAudit("GenericGetService AAI Response Code: " + responseCode) + + String aaiResponse = response.getResponseBodyAsString() + aaiResponse = StringEscapeUtils.unescapeXml(aaiResponse) + execution.setVariable("GENGS_obtainSIUrlResponse", aaiResponse) + utils.logAudit("GenericGetService AAI Response: " + aaiResponse) + //Process Response + if(responseCode == 200){ + utils.log("DEBUG", " Query for Service Instance Url Received a Good Response Code", isDebugEnabled) + execution.setVariable("GENGS_SuccessIndicator", true) + if(utils.nodeExists(aaiResponse, "result-data")){ + utils.log("DEBUG", "Query for Service Instance Url Response Does Contain Data" , isDebugEnabled) + execution.setVariable("GENGS_FoundIndicator", true) + String resourceLink = utils.getNodeText1(aaiResponse, "resource-link") + execution.setVariable("GENGS_siResourceLink", resourceLink) + }else{ + utils.log("DEBUG", "Query for Service Instance Url Response Does NOT Contains Data" , isDebugEnabled) + execution.setVariable("WorkflowResponse", " ") //for junits + } + }else if(responseCode == 404){ + utils.log("DEBUG", " Query for Service Instance Received a Not Found (404) Response", isDebugEnabled) + execution.setVariable("GENGS_SuccessIndicator", true) + execution.setVariable("WorkflowResponse", " ") //for junits + }else{ + utils.log("DEBUG", "Query for Service Instance Received a BAD REST Response: \n" + aaiResponse, isDebugEnabled) + exceptionUtil.MapAAIExceptionToWorkflowExceptionGeneric(execution, aaiResponse, responseCode) + throw new BpmnError("MSOWorkflowException") + } + }catch(BpmnError b){ + utils.log("DEBUG", "Rethrowing MSOWorkflowException", isDebugEnabled) + throw b + }catch(Exception e){ + utils.log("ERROR", " Error encountered within GenericGetService ObtainServiceInstanceUrlByName method!" + e, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured During ObtainServiceInstanceUrlByName") + } + utils.log("DEBUG", " *** COMPLETED GenericGetService ObtainServiceInstanceUrlByName Process*** ", isDebugEnabled) + } + + + /** + * This method executes a GET call to AAI to obtain the + * service-instance or service-subscription + * + * @param - execution + */ + public void getServiceObject(Execution execution){ + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix",Prefix) + utils.log("DEBUG", " *** STARTED GenericGetService GetServiceObject Process*** ", isDebugEnabled) + try { + String type = execution.getVariable("GENGS_type") + AaiUtil aaiUriUtil = new AaiUtil(this) + String aai_endpoint = execution.getVariable("URN_aai_endpoint") + String serviceEndpoint = "" + + utils.logAudit("GenericGetService getServiceObject AAI Endpoint: " + aai_endpoint) + if(type.equalsIgnoreCase("service-instance")){ + String siResourceLink = execution.getVariable("GENGS_siResourceLink") + if(isBlank(siResourceLink)){ + String serviceInstanceId = execution.getVariable("GENGS_serviceInstanceId") + utils.log("DEBUG", " Incoming GENGS_serviceInstanceId is: " + serviceInstanceId, isDebugEnabled) + String serviceType = execution.getVariable("GENGS_serviceType") + utils.log("DEBUG", " Incoming GENGS_serviceType is: " + serviceType, isDebugEnabled) + String globalCustomerId = execution.getVariable("GENGS_globalCustomerId") + utils.log("DEBUG", "Incoming Global Customer Id is: " + globalCustomerId, isDebugEnabled) + + String aai_uri = aaiUriUtil.getBusinessCustomerUri(execution) + logDebug('AAI URI is: ' + aai_uri, isDebugEnabled) + serviceEndpoint = "${aai_uri}/" + UriUtils.encode(globalCustomerId,"UTF-8") + "/service-subscriptions/service-subscription/" + UriUtils.encode(serviceType,"UTF-8") + "/service-instances/service-instance/" + UriUtils.encode(serviceInstanceId,"UTF-8") + }else{ + utils.log("DEBUG", "Incoming Service Instance Resource Link is: " + siResourceLink, isDebugEnabled) + String[] split = siResourceLink.split("/aai/") + serviceEndpoint = "/aai/" + split[1] + } + }else if(type.equalsIgnoreCase("service-subscription")){ + String aai_uri = aaiUriUtil.getBusinessCustomerUri(execution) + String globalCustomerId = execution.getVariable("GENGS_globalCustomerId") + String serviceType = execution.getVariable("GENGS_serviceType") + serviceEndpoint = "${aai_uri}/" + UriUtils.encode(globalCustomerId,"UTF-8") + "/service-subscriptions/service-subscription/" + UriUtils.encode(serviceType,"UTF-8") + } + + String serviceUrl = "${aai_endpoint}" + serviceEndpoint + + execution.setVariable("GENGS_getServiceUrl", serviceUrl) + utils.log("DEBUG", "GET Service AAI Path is: \n" + serviceUrl, isDebugEnabled) + + APIResponse response = aaiUriUtil.executeAAIGetCall(execution, serviceUrl) + int responseCode = response.getStatusCode() + execution.setVariable("GENGS_getServiceResponseCode", responseCode) + utils.log("DEBUG", " GET Service response code is: " + responseCode, isDebugEnabled) + utils.logAudit("GenericGetService AAI Response Code: " + responseCode) + + String aaiResponse = response.getResponseBodyAsString() + aaiResponse = StringEscapeUtils.unescapeXml(aaiResponse) + execution.setVariable("GENGS_getServiceResponse", aaiResponse) + utils.logAudit("GenericGetService AAI Response: " + aaiResponse) + + //Process Response + if(responseCode == 200 || responseCode == 202){ + utils.log("DEBUG", "GET Service Received a Good Response Code", isDebugEnabled) + if(utils.nodeExists(aaiResponse, "service-instance") || utils.nodeExists(aaiResponse, "service-subscription")){ + utils.log("DEBUG", "GET Service Response Contains a service-instance" , isDebugEnabled) + execution.setVariable("GENGS_FoundIndicator", true) + execution.setVariable("GENGS_service", aaiResponse) + execution.setVariable("WorkflowResponse", aaiResponse) + + }else{ + utils.log("DEBUG", "GET Service Response Does NOT Contain Data" , isDebugEnabled) + } + }else if(responseCode == 404){ + utils.log("DEBUG", "GET Service Received a Not Found (404) Response", isDebugEnabled) + execution.setVariable("WorkflowResponse", " ") //for junits + } + else{ + utils.log("DEBUG", " GET Service Received a Bad Response: \n" + aaiResponse, isDebugEnabled) + exceptionUtil.MapAAIExceptionToWorkflowExceptionGeneric(execution, aaiResponse, responseCode) + throw new BpmnError("MSOWorkflowException") + } + }catch(BpmnError b){ + utils.log("DEBUG", "Rethrowing MSOWorkflowException", isDebugEnabled) + throw b + }catch(Exception e){ + utils.log("DEBUG", " Error encountered within GenericGetService GetServiceObject method!" + e, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured During GenericGetService") + } + utils.log("DEBUG", " *** COMPLETED GenericGetService GetServiceObject Process*** ", isDebugEnabled) + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericGetVnf.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericGetVnf.groovy new file mode 100644 index 0000000000..5f03786180 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericGetVnf.groovy @@ -0,0 +1,270 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common.scripts + +import static org.apache.commons.lang3.StringUtils.* + +import org.apache.commons.lang3.* +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.runtime.Execution +import org.openecomp.mso.rest.APIResponse +import org.springframework.web.util.UriUtils + + +/** + * TODO: Support getting vnf type = vpe + * + * This class supports the GenericGetVnf Sub Flow. + * This Generic sub flow can be used by any flow for accomplishing + * the goal of getting a Vnf Object (from AAI). The flow currently + * supports the querying of 2 types of Vnfs, generic-vnf and vce. The + * type must be provided by the calling flow and the type should + * be mapped to the variable GENGV_type. The type should either be + * "generic-vnf" or "vce". If the Vnf Id is not provided by the calling + * flow then this sub flow will execute the query to get the + * Vnf using the Vnf Name. Therefore, the calling flow must provide + * either the Vnf Id or Vnf Name. + * + * Upon successful completion of this sub flow the + * GENGV_SuccessIndicator will be true and the query response payload + * will be set to GENGV_vnf. An MSOWorkflowException will + * be thrown upon unsuccessful completion or if an error occurs + * at any time during this sub flow. Please map variables + * to the corresponding variable names below. + * + * Note - if this sub flow receives a Not Found (404) response + * from AAI at any time this will be considered an acceptable + * successful response however the GENGV_FoundIndicator + * set to false. This will allow the calling flow to distinguish + * between the two success scenarios, "Success where Vnf is found" + * and "Success where Vnf is NOT found". + * + * + * Incoming Required Variables: + * @param - GENGV_vnfId or @param - GENGV_vnfName + * @param - GENGV_type + * + * + * Outgoing Variables: + * @param - GENGV_vnf + * @param - GENGV_SuccessIndicator + * @param - GENGV_FoundIndicator + * @param - WorkflowException + */ +class GenericGetVnf extends AbstractServiceTaskProcessor{ + + String Prefix = "GENGV_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + + /** + * This method validates the incoming variables and + * determines the subsequent event based on which + * variables the calling flow provided. + * + * @param - execution + */ + public void preProcessRequest(Execution execution) { + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix",Prefix) + utils.log("DEBUG", " *** STARTED GenericGetVnf PreProcessRequest Process*** ", isDebugEnabled) + + execution.setVariable("GENGV_getVnfByName", false) + execution.setVariable("GENGV_SuccessIndicator", false) + execution.setVariable("GENGV_FoundIndicator", false) + + try{ + // Get Variables + String vnfId = execution.getVariable("GENGV_vnfId") + utils.log("DEBUG", "Incoming Vnf Id is: " + vnfId, isDebugEnabled) + String vnfName = execution.getVariable("GENGV_vnfName") + utils.log("DEBUG", "Incoming Vnf Name is: " + vnfName, isDebugEnabled) + + if(isBlank(vnfId) && isBlank(vnfName)){ + utils.log("DEBUG", "Incoming Vnf Name and Vnf Id are null. At least one is required!", isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Incoming Vnf Name and Vnf Id are null. At least one is required.") + }else{ + if(isBlank(vnfId)){ + execution.setVariable("GENGV_getVnfByName", true) + } + } + + }catch(BpmnError b){ + utils.log("DEBUG", "Rethrowing MSOWorkflowException", isDebugEnabled) + throw b + }catch(Exception e){ + utils.log("DEBUG", " Error encountered within GenericGetVnf PreProcessRequest method!" + e, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in GenericGetVnf PreProcessRequest") + + } + utils.log("DEBUG", "*** COMPLETED GenericGetVnf PreProcessRequest Process ***", isDebugEnabled) + } + + /** + * This method executes a GET call to AAI to obtain the + * Vnf using the Vnf Name + * + * @param - execution + */ + public void getVnfByName(Execution execution){ + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix",Prefix) + utils.log("DEBUG", " *** STARTED GenericGetVnf GetVnfByName Process*** ", isDebugEnabled) + try { + String vnfName = execution.getVariable("GENGV_vnfName") + utils.log("DEBUG", "Getting Vnf by Vnf Name: " + vnfName, isDebugEnabled) + String type = execution.getVariable("GENGV_type") + utils.log("DEBUG", "Type of Vnf Getting is: " + type, isDebugEnabled) + + String aai_endpoint = execution.getVariable("URN_aai_endpoint") + AaiUtil aaiUriUtil = new AaiUtil(this) + + //Determine Type of Vnf Querying For. + def aai_uri = "" + if(type.equals("generic-vnf")){ + aai_uri = aaiUriUtil.getNetworkGenericVnfUri(execution) + }else if(type.equals("vce")){ + aai_uri = aaiUriUtil.getNetworkVceUri(execution) + }else{ + utils.log("DEBUG", "Invalid Incoming GENGV_type", isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Invalid Incoming GENGV_type") + } + + String getVnfPath = "${aai_endpoint}${aai_uri}?vnf-name=" + UriUtils.encode(vnfName, "UTF-8") + "&depth=1" + + execution.setVariable("GENGV_getVnfPath", getVnfPath) + utils.logAudit("Get Vnf Url is: " + getVnfPath) + + APIResponse response = aaiUriUtil.executeAAIGetCall(execution, getVnfPath) + int responseCode = response.getStatusCode() + execution.setVariable("GENGV_getVnfResponseCode", responseCode) + utils.log("DEBUG", " GET Vnf response code is: " + responseCode, isDebugEnabled) + + String aaiResponse = response.getResponseBodyAsString() + aaiResponse = StringEscapeUtils.unescapeXml(aaiResponse) + execution.setVariable("GENGV_getVnfResponse", aaiResponse) + + //Process Response + if(responseCode == 200){ + utils.log("DEBUG", "GET Vnf Received a Good Response", isDebugEnabled) + if(utils.nodeExists(aaiResponse, type)){ + utils.log("DEBUG", "GET Vnf Response Contains a Vnf", isDebugEnabled) + execution.setVariable("GENGV_FoundIndicator", true) + execution.setVariable("GENGV_vnf", aaiResponse) + execution.setVariable("WorkflowResponse", aaiResponse) + }else{ + utils.log("DEBUG", "GET Vnf Response Does NOT Contain a Vnf", isDebugEnabled) + } + + }else if(responseCode == 404){ + utils.log("DEBUG", "GET Vnf Received a Not Found (404) Response", isDebugEnabled) + }else{ + utils.log("DEBUG", "GET Vnf Received a Bad Response: \n" + aaiResponse, isDebugEnabled) + exceptionUtil.MapAAIExceptionToWorkflowExceptionGeneric(execution, aaiResponse, responseCode) + throw new BpmnError("MSOWorkflowException") + } + }catch(BpmnError b){ + utils.log("DEBUG", "Rethrowing MSOWorkflowException", isDebugEnabled) + throw b + }catch(Exception e){ + utils.log("ERROR", " Error encountered within GenericGetVnf GetVnfByName method!" + e, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured During GetVnfByName") + } + utils.log("DEBUG", " *** COMPLETED GenericGetVnf GetVnfByName Process*** ", isDebugEnabled) + } + + /** + * This method executes a GET call to AAI to obtain the + * Vnf using the Vnf Id + * + * @param - execution + */ + public void getVnfById(Execution execution){ + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix",Prefix) + utils.log("DEBUG", " *** STARTED GenericGetVnf GetVnfById Process*** ", isDebugEnabled) + try { + String vnfId = execution.getVariable("GENGV_vnfId") + utils.log("DEBUG", "Getting Vnf by Vnf Id: " + vnfId, isDebugEnabled) + String type = execution.getVariable("GENGV_type") + utils.log("DEBUG", "Type of Vnf Getting is: " + type, isDebugEnabled) + + String aai_endpoint = execution.getVariable("URN_aai_endpoint") + AaiUtil aaiUriUtil = new AaiUtil(this) + + //Determine Type of Vnf Querying For. + def aai_uri = "" + if(type.equals("generic-vnf")){ + aai_uri = aaiUriUtil.getNetworkGenericVnfUri(execution) + }else if(type.equals("vce")){ + aai_uri = aaiUriUtil.getNetworkVceUri(execution) + }else if(type.equals("vpe")){ + exceptionUtil.buildAndThrowWorkflowException(execution, 500, "GenericGetVnf does not yet support getting type of vnf = vpe") + }else{ + utils.log("DEBUG", "Invalid Incoming GENGV_type", isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Invalid Incoming GENGV_type") + } + utils.log("DEBUG", "Using AAI Uri: " + aai_uri, isDebugEnabled) + + String getVnfPath = "${aai_endpoint}${aai_uri}/" + UriUtils.encode(vnfId, "UTF-8") + "?depth=1" + utils.log("DEBUG", "GET Vnf Endpoint is: " + getVnfPath, isDebugEnabled) + + execution.setVariable("GENGV_getVnfPath", getVnfPath) + utils.logAudit("Get Vnf Url is: " + getVnfPath) + + APIResponse response = aaiUriUtil.executeAAIGetCall(execution, getVnfPath) + int responseCode = response.getStatusCode() + execution.setVariable("GENGV_getVnfResponseCode", responseCode) + utils.log("DEBUG", " GET Vnf response code is: " + responseCode, isDebugEnabled) + + String aaiResponse = response.getResponseBodyAsString() + aaiResponse = StringEscapeUtils.unescapeXml(aaiResponse) + execution.setVariable("GENGV_getVnfResponse", aaiResponse) + + //Process Response + if(responseCode == 200){ + utils.log("DEBUG", "GET Vnf Received a Good Response", isDebugEnabled) + if(utils.nodeExists(aaiResponse, type)){ + utils.log("DEBUG", "GET Vnf Response Contains a Vnf", isDebugEnabled) + execution.setVariable("GENGV_FoundIndicator", true) + execution.setVariable("GENGV_vnf", aaiResponse) + execution.setVariable("WorkflowResponse", aaiResponse) + }else{ + utils.log("DEBUG", "GET Vnf Response Does NOT Contain a Vnf", isDebugEnabled) + } + + }else if(responseCode == 404){ + utils.log("DEBUG", "GET Vnf Received a Not Found (404) Response", isDebugEnabled) + }else{ + utils.log("DEBUG", "GET Vnf Received a BAD REST Response: \n" + aaiResponse, isDebugEnabled) + exceptionUtil.MapAAIExceptionToWorkflowExceptionGeneric(execution, aaiResponse, responseCode) + throw new BpmnError("MSOWorkflowException") + } + }catch(BpmnError b){ + utils.log("DEBUG", "Rethrowing MSOWorkflowException", isDebugEnabled) + throw b + }catch(Exception e){ + utils.log("ERROR", " Error encountered within GenericGetVnf GetVnfById method!" + e, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured During GetVnfById") + } + utils.log("DEBUG", " *** COMPLETED GenericGetVnf GetVnfById Process*** ", isDebugEnabled) + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericPutService.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericPutService.groovy new file mode 100644 index 0000000000..9609103228 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericPutService.groovy @@ -0,0 +1,280 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.openecomp.mso.bpmn.common.scripts + +import static org.apache.commons.lang3.StringUtils.*; + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.runtime.Execution; +import org.apache.commons.codec.binary.Base64 +import org.apache.commons.lang3.* + +import org.openecomp.mso.bpmn.core.json.JsonUtils +import org.openecomp.mso.bpmn.core.WorkflowException +import org.openecomp.mso.rest.APIResponse; +import org.openecomp.mso.rest.RESTClient +import org.openecomp.mso.rest.RESTConfig + +import java.net.URLEncoder; +import org.springframework.web.util.UriUtils + +/** + * This class supports the GenericPutService Sub Flow. + * This Generic sub flow can be used by any flow for the + * goal of creating a Service Instance or Service-Subscription in AAI. Upon successful completion of + * this sub flow the GENPS_SuccessIndicator will be true. + * The calling flow must set the GENPS_type variable as "service-instance" + * or "service-subscription". + * A MSOWorkflowException will be thrown Upon unsuccessful + * completion or if an error occurs within this flow. + * Please map variables to the corresponding variable names + * below. + * + * + * Incoming Required Variables: + * @param - GENPS_type - Required field. This will be required field populated as service-instance or service-subscription + * @param - GENPS_globalSubscriberId - Required field + * @param - GENPS_serviceType - Required Field + * @param - GENPS_payload - Required Field This will be the payload that needs to be sent. + * + * @param - GENPS_serviceInstanceId - Conditional Field. Required for service-instance. + * @param - GENPS_allottedResourceId - Conditional Field. Required for allotted-resource. + * @param - GENPS_tunnelXconnectId - Conditional Field. Required for tunnel-xconnect. + * + * @param - GENPS_requestId to trace the request id + * @param - GENPS_serviceResourceVersion optional needs to be provided only in case of update for both service-instance and service subscription. The calling flows + * should check if a service-instance or servic-subscription exists by calling the subflow GenericGetService. if it exists then resourceversion should be + * obtained from aai and sent as an input parameter. + * + * Outgoing Variables: + * @param - GENPS_SuccessIndicator + * @param - WorkflowException + * + * + */ + + +class GenericPutService extends AbstractServiceTaskProcessor{ + + String Prefix = "GENPS_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + + + public void preProcessRequest(Execution execution) { + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix",Prefix) + utils.log("DEBUG", " *** STARTED GenericPutService PreProcessRequest Process*** ", isDebugEnabled) + + execution.setVariable("GENPS_SuccessIndicator", false) + + try{ + // Get Variables + String requestId = execution.getVariable("GENPS_requestId") + utils.log("DEBUG", "Incoming GENPS_requestId is: " + requestId, isDebugEnabled) + + String globalSubscriberId = execution.getVariable("GENPS_globalSubscriberId") + String serviceInstanceId = execution.getVariable("GENPS_serviceInstanceId") + String serviceType = execution.getVariable("GENPS_serviceType") + String allottedResourceId = execution.getVariable("GENPS_allottedResourceId") + String tunnelXconnectId = execution.getVariable("GENPS_tunnelXconnectId") + String type = execution.getVariable("GENPS_type") + + if(type != null){ + utils.log("DEBUG", "Incoming GENPS_type is: " + type, isDebugEnabled) + if(type.equalsIgnoreCase("service-instance")){ + if(isBlank(globalSubscriberId) || isBlank(serviceType) || isBlank(serviceInstanceId)){ + utils.log("DEBUG", "Incoming Required Variable is missing or null!", isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Incoming Required Variable is Missing or Null!") + }else{ + utils.log("DEBUG", "Incoming Global Subscriber Id is: " + globalSubscriberId, isDebugEnabled) + utils.log("DEBUG", "Incoming Service Instance Id is: " + serviceInstanceId, isDebugEnabled) + utils.log("DEBUG", "Incoming Service Type is: " + serviceType, isDebugEnabled) + } + }else if(type.equalsIgnoreCase("service-subscription")){ + if(isBlank(serviceType) || isBlank(globalSubscriberId)){ + utils.log("DEBUG", "Incoming ServiceType or GlobalSubscriberId is null. These variables are required to create a service-subscription.", isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Incoming ServiceType or GlobalCustomerId is null. These variables are required to Get a service-subscription.") + }else{ + utils.log("DEBUG", "Incoming Service Type is: " + serviceType, isDebugEnabled) + utils.log("DEBUG", "Incoming Global Subscriber Id is: " + globalSubscriberId, isDebugEnabled) + } + }else if(type.equalsIgnoreCase("allotted-resource")){ + if(isBlank(globalSubscriberId) || isBlank(serviceType) || isBlank(serviceInstanceId) || isBlank(allottedResourceId)){ + utils.log("DEBUG", "Incoming Global Subscriber Id is: " + globalSubscriberId, isDebugEnabled) + utils.log("DEBUG", "Incoming Service Instance Id is: " + serviceInstanceId, isDebugEnabled) + utils.log("DEBUG", "Incoming Service Type is: " + serviceType, isDebugEnabled) + utils.log("DEBUG", "Incoming Allotted Resource Id is: " + allottedResourceId, isDebugEnabled) + utils.log("DEBUG", "Incoming Required Variable is missing or null!", isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Incoming Required Variable is Missing or Null!") + }else{ + utils.log("DEBUG", "Incoming Global Subscriber Id is: " + globalSubscriberId, isDebugEnabled) + utils.log("DEBUG", "Incoming Service Instance Id is: " + serviceInstanceId, isDebugEnabled) + utils.log("DEBUG", "Incoming Service Type is: " + serviceType, isDebugEnabled) + utils.log("DEBUG", "Incoming Allotted Resource Id is: " + allottedResourceId, isDebugEnabled) + } + }else if(type.equalsIgnoreCase("tunnel-xconnect")){ + if(isBlank(globalSubscriberId) || isBlank(serviceType) || isBlank(serviceInstanceId) || isBlank(allottedResourceId) || isBlank(tunnelXconnectId)){ + utils.log("DEBUG", "Incoming Global Subscriber Id is: " + globalSubscriberId, isDebugEnabled) + utils.log("DEBUG", "Incoming Service Instance Id is: " + serviceInstanceId, isDebugEnabled) + utils.log("DEBUG", "Incoming Service Type is: " + serviceType, isDebugEnabled) + utils.log("DEBUG", "Incoming Allotted Resource Id is: " + allottedResourceId, isDebugEnabled) + utils.log("DEBUG", "Incoming Tunnel Xconnect Id is: " + tunnelXconnectId, isDebugEnabled) + utils.log("DEBUG", "Incoming Required Variable is missing or null!", isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Incoming Required Variable is Missing or Null!") + }else{ + utils.log("DEBUG", "Incoming Global Subscriber Id is: " + globalSubscriberId, isDebugEnabled) + utils.log("DEBUG", "Incoming Service Instance Id is: " + serviceInstanceId, isDebugEnabled) + utils.log("DEBUG", "Incoming Service Type is: " + serviceType, isDebugEnabled) + utils.log("DEBUG", "Incoming Allotted Resource Id is: " + allottedResourceId, isDebugEnabled) + utils.log("DEBUG", "Incoming Tunnel Xconnect Id is: " + tunnelXconnectId, isDebugEnabled) + } + }else{ + exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Incoming Type is Invalid. Please Specify Type as service-instance or service-subscription") + } + }else{ + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Incoming GENPS_type is null. Variable is Required.") + } + + }catch(BpmnError b){ + utils.log("DEBUG", "Rethrowing MSOWorkflowException", isDebugEnabled) + throw b + }catch(Exception e){ + utils.log("ERROR", " Error encountered within GenericPutService PreProcessRequest method!" + e, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in GenericPutService PreProcessRequest") + + } + utils.log("DEBUG", "*** COMPLETED GenericPutService PreProcessRequest Process ***", isDebugEnabled) + + } + + + + /** + * This method executes a Put call to AAI for the provided + * service instance. + * + * @param - execution + * + */ + public void putServiceInstance(Execution execution){ + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix",Prefix) + utils.log("DEBUG", " *** STARTED GenericPutService PutServiceInstance method*** ", isDebugEnabled) + try { + String type = execution.getVariable("GENPS_type") + + AaiUtil aaiUriUtil = new AaiUtil(this) + String aai_uri = aaiUriUtil.getBusinessCustomerUri(execution) + logDebug('AAI URI is: ' + aai_uri, isDebugEnabled) + String namespace = aaiUriUtil.getNamespaceFromUri(aai_uri) + logDebug('AAI namespace is: ' + namespace, isDebugEnabled) + + String aai_endpoint = execution.getVariable("URN_aai_endpoint") + String serviceAaiPath = "" + String payload = execution.getVariable("GENPS_payload") + execution.setVariable("GENPS_payload", payload) + utils.log("DEBUG", "Incoming GENPS_payload is: " + payload, isDebugEnabled) + utils.logAudit(payload) + + String serviceType = execution.getVariable("GENPS_serviceType") + utils.log("DEBUG", " Incoming GENPS_serviceType is: " + serviceType, isDebugEnabled) + String globalSubscriberId = execution.getVariable("GENPS_globalSubscriberId") + utils.log("DEBUG", "Incoming Global Subscriber Id is: " + globalSubscriberId, isDebugEnabled) + + // This IF clause is if we need to create a new Service Instance + if(type.equalsIgnoreCase("service-instance")){ + + String serviceInstanceId = execution.getVariable("GENPS_serviceInstanceId") + utils.log("DEBUG", " Incoming GENPS_serviceInstanceId is: " + serviceInstanceId, isDebugEnabled) + + // serviceAaiPath = "${aai_endpoint}${aai_uri}/" + URLEncoder.encode(globalSubscriberId,"UTF-8") + "/service-subscriptions/service-subscription/" + URLEncoder.encode(serviceType,"UTF-8") + "/service-instances/service-instance/" + URLEncoder.encode(serviceInstanceId,"UTF-8") + serviceAaiPath = "${aai_endpoint}${aai_uri}/" + UriUtils.encode(globalSubscriberId,"UTF-8") + "/service-subscriptions/service-subscription/" + UriUtils.encode(serviceType,"UTF-8") + "/service-instances/service-instance/" + UriUtils.encode(serviceInstanceId,"UTF-8") + + }else if(type.equalsIgnoreCase("service-subscription")){ + + // serviceAaiPath = "${aai_endpoint}${aai_uri}/" + URLEncoder.encode(globalSubscriberId,"UTF-8") + "/service-subscriptions/service-subscription/" + URLEncoder.encode(serviceType,"UTF-8") + serviceAaiPath = "${aai_endpoint}${aai_uri}/" + UriUtils.encode(globalSubscriberId,"UTF-8") + "/service-subscriptions/service-subscription/" + UriUtils.encode(serviceType,"UTF-8") + }else if(type.equalsIgnoreCase("allotted-resource")){ + + String serviceInstanceId = execution.getVariable("GENPS_serviceInstanceId") + utils.log("DEBUG", " Incoming GENPS_serviceInstanceId is: " + serviceInstanceId, isDebugEnabled) + String allottedResourceId = execution.getVariable("GENPS_allottedResourceId") + utils.log("DEBUG", " Incoming GENPS_allottedResourceId is: " + allottedResourceId, isDebugEnabled) + + // serviceAaiPath = "${aai_endpoint}${aai_uri}/" + URLEncoder.encode(globalSubscriberId,"UTF-8") + "/service-subscriptions/service-subscription/" + URLEncoder.encode(serviceType,"UTF-8") + serviceAaiPath = "${aai_endpoint}${aai_uri}/" + UriUtils.encode(globalSubscriberId,"UTF-8") + "/service-subscriptions/service-subscription/" + UriUtils.encode(serviceType,"UTF-8") + "/service-instances/service-instance/" + UriUtils.encode(serviceInstanceId,"UTF-8") + "/allotted-resources/allotted-resource/" + UriUtils.encode(allottedResourceId,"UTF-8") + }else if(type.equalsIgnoreCase("tunnel-xconnect")){ + + String serviceInstanceId = execution.getVariable("GENPS_serviceInstanceId") + utils.log("DEBUG", " Incoming GENPS_serviceInstanceId is: " + serviceInstanceId, isDebugEnabled) + String allottedResourceId = execution.getVariable("GENPS_allottedResourceId") + utils.log("DEBUG", " Incoming GENPS_allottedResourceId is: " + allottedResourceId, isDebugEnabled) + String tunnelXconnectId = execution.getVariable("GENPS_tunnelXconnectId") + utils.log("DEBUG", " Incoming GENPS_tunnelXconnectId is: " + tunnelXconnectId, isDebugEnabled) + + // serviceAaiPath = "${aai_endpoint}${aai_uri}/" + URLEncoder.encode(globalSubscriberId,"UTF-8") + "/service-subscriptions/service-subscription/" + URLEncoder.encode(serviceType,"UTF-8") + serviceAaiPath = "${aai_endpoint}${aai_uri}/" + UriUtils.encode(globalSubscriberId,"UTF-8") + "/service-subscriptions/service-subscription/" + UriUtils.encode(serviceType,"UTF-8") + "/service-instances/service-instance/" + UriUtils.encode(serviceInstanceId,"UTF-8") + "/allotted-resources/allotted-resource/" + UriUtils.encode(allottedResourceId,"UTF-8") + "/tunnel-xconnects/tunnel-xconnect/" + UriUtils.encode(tunnelXconnectId,"UTF-8") + } + + String resourceVersion = execution.getVariable("GENPS_serviceResourceVersion") + utils.log("DEBUG", "Incoming Resource Version is: " + resourceVersion, isDebugEnabled) + if(resourceVersion !=null){ + serviceAaiPath = serviceAaiPath +'?resource-version=' + UriUtils.encode(resourceVersion,"UTF-8") + } + + execution.setVariable("GENPS_putServiceInstanceAaiPath", serviceAaiPath) + utils.log("DEBUG", "PUT Service Instance AAI Path is: " + "\n" + serviceAaiPath, isDebugEnabled) + + APIResponse response = aaiUriUtil.executeAAIPutCall(execution, serviceAaiPath, payload) + int responseCode = response.getStatusCode() + execution.setVariable("GENPS_putServiceInstanceResponseCode", responseCode) + utils.log("DEBUG", " Put Service Instance response code is: " + responseCode, isDebugEnabled) + + String aaiResponse = response.getResponseBodyAsString() + aaiResponse = StringEscapeUtils.unescapeXml(aaiResponse) + execution.setVariable("GENPS_putServiceInstanceResponse", aaiResponse) + + + //Process Response + if(responseCode == 200 || responseCode == 201 || responseCode == 202 ) + //200 OK 201 CREATED 202 ACCEPTED + { + utils.log("DEBUG", "PUT Service Instance Received a Good Response", isDebugEnabled) + execution.setVariable("GENPS_SuccessIndicator", true) + } + + else{ + utils.log("DEBUG", "Put Generic Service Instance Received a Bad Response Code. Response Code is: " + responseCode, isDebugEnabled) + exceptionUtil.MapAAIExceptionToWorkflowExceptionGeneric(execution, aaiResponse, responseCode) + throw new BpmnError("MSOWorkflowException") + } + }catch(BpmnError b){ + utils.log("DEBUG", "Rethrowing MSOWorkflowException", isDebugEnabled) + throw b + }catch(Exception e){ + utils.log("ERROR", " Error encountered within GenericPutService PutServiceInstance method!" + e, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured During Put Service Instance") + } + utils.log("DEBUG", " *** COMPLETED GenericPutService PutServiceInstance Process*** ", isDebugEnabled) + } + + + +} diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericPutVnf.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericPutVnf.groovy new file mode 100644 index 0000000000..9a7aa5ab9f --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericPutVnf.groovy @@ -0,0 +1,172 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common.scripts + +import static org.apache.commons.lang3.StringUtils.* + +import org.apache.commons.lang3.* +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.runtime.Execution +import org.openecomp.mso.rest.APIResponse +import org.springframework.web.util.UriUtils + +/** + * TODO: Support Putting vnf type = vpe and vce + * + * This class supports the GenericPutVnf Sub Flow. + * This Generic sub flow can be used by any flow for accomplishing + * the goal of Creating/Updating(PUT) a Vnf Object (in AAI). The flow + * supports the Creating/Updating of 3 types of Vnfs (generic-vnf, vce, and vpe). + * The "type" must be provided by the calling flow and this type should + * be mapped to the variable GENPV_type. The type should either be + * "generic-vnf", "vce", or "vpe". In addition, the Vnf Id and + * payload should be provided. + * + * Upon successful completion of this sub flow the + * GENPV_SuccessIndicator. An MSOWorkflowException will + * be thrown if an error occurs at any time during this + * sub flow. Please map input variables to the corresponding + * variable names below. + * + * + * Incoming Required Variables: + * @param - GENPV_vnfId + * @param - GENPV_vnfPayload + * @param - GENPV_type + * + * + * Outgoing Variables: + * @param - GENPV_SuccessIndicator + * @param - WorkflowException + */ +class GenericPutVnf extends AbstractServiceTaskProcessor{ + + String Prefix = "GENPV_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + + /** + * This method validates the incoming variables and + * generates a Vnf Id if one is not provided. + * + * @param - execution + */ + public void preProcessRequest(Execution execution) { + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix",Prefix) + utils.log("DEBUG", " *** STARTED GenericPutVnf PreProcessRequest Process*** ", isDebugEnabled) + + execution.setVariable("GENPV_SuccessIndicator", false) + execution.setVariable("GENPV_FoundIndicator", false) + + try{ + // Get Variables + String payload = execution.getVariable("GENPV_vnfPayload") + utils.log("DEBUG", "Incoming Vnf Payload is: " + payload, isDebugEnabled) + String type = execution.getVariable("GENPV_type") + utils.log("DEBUG", "Incoming Type of Vnf is: " + type, isDebugEnabled) + + if(isBlank(payload) || isBlank(type)){ + utils.log("ERROR", "Incoming Vnf Payload and/or Type is null. These Variables are required!", isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Incoming Vnf Payload and/or Type is null. These Variables are required!") + }else{ + String vnfId = execution.getVariable("GENPV_vnfId") + if(isBlank(vnfId)){ + vnfId = UUID.randomUUID().toString() + utils.log("DEBUG", "Generated Vnf Id is: " + vnfId, isDebugEnabled) + execution.setVariable("GENPV_vnfId", vnfId) + }else{ + utils.log("DEBUG", "Incoming Vnf Id is: " + vnfId, isDebugEnabled) + } + } + }catch(BpmnError b){ + utils.log("DEBUG", "Rethrowing MSOWorkflowException", isDebugEnabled) + throw b + }catch(Exception e){ + utils.log("ERROR", " Error encountered within GenericPutVnf PreProcessRequest method!" + e, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in GenericPutVnf PreProcessRequest") + + } + utils.log("DEBUG", "*** COMPLETED GenericPutVnf PreProcessRequest Process ***", isDebugEnabled) + } + + /** + * This method executes a Put call to AAI to create + * or update a Vnf Object using the provided payload + * + * @param - execution + */ + public void putVnf(Execution execution){ + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix",Prefix) + utils.log("DEBUG", " *** STARTED GenericPutVnf PutVnf Process*** ", isDebugEnabled) + try { + String vnfId = execution.getVariable("GENPV_vnfId") + String payload = execution.getVariable("GENPV_vnfPayload") + String type = execution.getVariable("GENPV_type") + + AaiUtil aaiUtil = new AaiUtil(this) + def aai_uri = "" + if(type.equals("generic-vnf")){ + aai_uri = aaiUtil.getNetworkGenericVnfUri(execution) + }else if(type.equals("vce")){ + aai_uri = aaiUtil.getNetworkVceUri(execution) + }else if(type.equals("vpe")){ + exceptionUtil.buildAndThrowWorkflowException(execution, 500, "GenericPutVnf does not yet support getting type of vnf = vpe") + }else{ + utils.log("DEBUG", "Invalid Incoming GENGV_type", isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Invalid Incoming GENPV_type") + } + utils.log("DEBUG", "Using AAI Uri: " + aai_uri, isDebugEnabled) + + String path = "${aai_uri}/" + UriUtils.encode(vnfId, "UTF-8") + utils.log("DEBUG", "PUT Vnf Endpoint is: " + path, isDebugEnabled) + + String putVnfAAIPath = execution.getVariable("URN_aai_endpoint") + path + execution.setVariable("GENPV_putVnfAAIPath", putVnfAAIPath) + utils.logAudit("PUT Vnf Url is: " + putVnfAAIPath) + + APIResponse apiResponse = aaiUtil.executeAAIPutCall(execution, putVnfAAIPath, payload) + int responseCode = apiResponse.getStatusCode() + execution.setVariable("GENPV_putVnfResponseCode", responseCode) + utils.logAudit("AAI Response Code: " + responseCode) + String aaiResponse = apiResponse.getResponseBodyAsString() + aaiResponse = StringEscapeUtils.unescapeXml(aaiResponse) + execution.setVariable("GENPV_putVnfResponse", aaiResponse) + utils.logAudit("AAI Response: " + aaiResponse) + + if(responseCode == 200 || responseCode == 201){ + utils.log("DEBUG", "PUT Vnf Received a Good Response Code.", isDebugEnabled) + }else{ + utils.log("DEBUG", "PUT Vnf Received a Bad Response Code. Response Code is: " + responseCode, isDebugEnabled) + exceptionUtil.MapAAIExceptionToWorkflowExceptionGeneric(execution, aaiResponse, responseCode) + throw new BpmnError("MSOWorkflowException") + } + }catch(BpmnError b){ + utils.log("DEBUG", "Rethrowing MSOWorkflowException", isDebugEnabled) + throw b + }catch(Exception e){ + utils.log("ERROR", " Error encountered within GenericPutVnf PutVnf method!" + e, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured During PutVnf") + } + utils.log("DEBUG", " *** COMPLETED GenericPutVnf PutVnf Process*** ", isDebugEnabled) + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/MsoUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/MsoUtils.groovy new file mode 100644 index 0000000000..6796fb1a95 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/MsoUtils.groovy @@ -0,0 +1,944 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common.scripts + +import groovy.xml.XmlUtil + +import java.text.SimpleDateFormat + +import org.apache.commons.codec.binary.Base64 +import org.openecomp.mso.bpmn.core.BPMNLogger +import org.openecomp.mso.bpmn.core.xml.XmlTool +import org.openecomp.mso.logger.MessageEnum +import org.openecomp.mso.logger.MsoLogger +import org.openecomp.mso.utils.CryptoUtils +import org.w3c.dom.Element + +class MsoUtils { + def initializeEndPoints(execution){ + // use this placeholder to initialize end points, if called independently, this need to be set + execution.setVariable("AAIEndPoint","http://localhost:28080/SoapUIMocks") + } + def getNodeText(xmlInput,element){ + def rtn=null + if(xmlInput!=null){ + def xml= new XmlSlurper().parseText(xmlInput) + rtn= xml.'**'.find{node->node.name()==element}.text() + } + return rtn + } + def getMultNodes(xmlInput, element){ + def nodes=null + if(xmlInput!=null){ + def xml= new XmlSlurper().parseText(xmlInput) + nodes = xml.'**'.findAll{ node-> node.name() == element }*.text() + } + return nodes + } + def getNodeText1(xmlInput,element){ + def rtn=null + if(xmlInput!=null){ + def xml= new XmlSlurper().parseText(xmlInput) + rtn= xml.'**'.find{node->node.name()==element} + if (rtn != null){ + rtn=rtn.text() + } + } + return rtn + } + def getNodeXml(xmlInput,element){ + return getNodeXml(xmlInput, element, true) + } + def getNodeXml(xmlInput,element,incPreamble){ + def fxml= new XmlSlurper().parseText(xmlInput) + def nodeToSerialize = fxml.'**'.find {it.name() == element} + if(nodeToSerialize==null){ + return "" + } + def nodeAsText = XmlUtil.serialize(nodeToSerialize) + if (!incPreamble) { + nodeAsText = removeXmlPreamble(nodeAsText) + } + return nodeAsText + } + def nodeExists(xmlInput,element){ + try { + def fxml= new XmlSlurper().parseText(xmlInput) + def nodeToSerialize = fxml.'**'.find {it.name() == element} + return nodeToSerialize!=null + } catch(Exception e) { + return false + } + } + + + /***** Utilities when using XmlParser *****/ + + /** + * Convert a Node into a String by deserializing it and formatting it. + * + * @param node Node to be converted. + * @return the Node as a String. + */ + def String nodeToString(Node node) { + def String nodeAsString = groovy.xml.XmlUtil.serialize(node) + nodeAsString = removeXmlPreamble(nodeAsString) + return formatXml(nodeAsString) + } + + /** + * Get the specified child Node of the specified parent. If there are + * multiple children of the same name, only the first one is returned. + * If there are no children with the specified name, 'null' is returned. + * + * @param parent Parent Node in which to find a child. + * @param childNodeName Name of the child Node to get. + * @return the (first) child Node with the specified name or 'null' + * if a child Node with the specified name does not exist. + */ + def Node getChildNode(Node parent, String childNodeName) { + def NodeList nodeList = getIdenticalChildren(parent, childNodeName) + if (nodeList.size() == 0) { + return null + } else { + return nodeList.get(0) + } + } + + /** + * Get the textual value of the specified child Node of the specified parent. + * If there are no children with the specified name, 'null' is returned. + * + * @param parent Parent Node in which to find a child. + * @param childNodeName Name of the child Node whose value to get. + * @return the textual value of child Node with the specified name or 'null' + * if a child Node with the specified name does not exist. + */ + def String getChildNodeText(Node parent, String childNodeName) { + def Node childNode = getChildNode(parent, childNodeName) + if (childNode == null) { + return null + } else { + return childNode.text() + } + } + + /** + * Get all of the child nodes from the specified parent that have the + * specified name. The returned NodeList could be empty. + * + * @param parent Parent Node in which to find children. + * @param childNodeName Name of the children to get. + * @return a NodeList of all the children from the parent with the specified + * name. The list could be empty. + */ + def NodeList getIdenticalChildren(Node parent, String childNodeName) { + return (NodeList) parent.get(childNodeName) + } + + /***** End of Utilities when using XmlParser *****/ + + + /** these are covered under the common function above**/ + def getSubscriberName(xmlInput,element){ + def rtn=null + if(xmlInput!=null){ + def xml= new XmlSlurper().parseText(xmlInput) + rtn= xml.'**'.find{node->node.name()==element}.text() + } + return rtn + } + def getTenantInformation(xmlInput,element){ + def xml= new XmlSlurper().parseText(xmlInput) + def nodeToSerialize = xml.'**'.find {it.name() == 'service-information'} + def nodeAsText = XmlUtil.serialize(nodeToSerialize) + return nodeAsText + } + def getServiceInstanceId(xmlInput,element){ + def xml= new XmlSlurper().parseText(xmlInput) + return ( xml.'**'.find{node->node.name()==element}.text() ) + } + //for aai tenant url + def searchResourceLink(xmlInput, resourceType){ + def fxml= new XmlSlurper().parseText(xmlInput) + def element = fxml.'**'.find {it.'resource-type' == resourceType} + return (element == null) ? null : element.'resource-link'.text() + } + + def searchMetaData(xmlInput, searchName, searchValue){ + def fxml= new XmlSlurper().parseText(xmlInput) + def ret = fxml.'**'.find {it.metaname.text() == searchName && it.metaval.text() == searchValue} + if(ret != null){ + return ret.parent().parent() + } + return ret + } + + def searchMetaDataNode(fxml, searchName, searchValue){ + def ret = fxml.'**'.find {it.metaname.text() == searchName && it.metaval.text() == searchValue} + if(ret != null){ + return ret.parent().parent() + } + return ret + } + + // for Trinity L3 add/delete bonding + def getPBGFList(isDebugLogEnabled, xmlInput){ + xmlInput = xmlInput.replaceAll("&", "&") + xmlInput = xmlInput.replaceAll("<", "<") + xmlInput = xmlInput.replaceAll(">", ">") + log("DEBUG", "getPBGFList: xmlInput " + xmlInput,isDebugLogEnabled) + ArrayList myNodes = new ArrayList() + if(nodeExists(xmlInput,"nbnc-response-information")){ + def respInfo=getNodeXml(xmlInput,"nbnc-response-information", false) + if(respInfo!=null){ + def fxml= new XmlSlurper().parseText(respInfo) + fxml.'virtual-datacenter-list'.each { vdc -> + //we only want to add two BGF per VDC, BGF1 and BGF2 + def routerList = vdc.'router-list'.first() + routerList.each{ myList -> + def physNodes = myList.'**'.findAll {it.'border-element-tangibility'.text() =~ /PHYSICAL/} + def nodeToAdd + physNodes.each{ + if(nodeToAdd==null){ + nodeToAdd = it + }else{ + def beid = nodeToAdd.'border-element-id'.text() + + " " + nodeToAdd.'border-element-type'.text() + + " and " + + it.'border-element-id'.text() + + " " + it.'border-element-type'.text() + def mytag = nodeToAdd.'border-element-id' + mytag[0].replaceBody(beid) + } + } + def mytag = nodeToAdd.'vlan-id' + def ind = mytag.text().indexOf('.') + if(ind >= 0){ + def vlan = mytag.text().substring(0,ind) + mytag[0].replaceBody(vlan) + } + myNodes.add(XmlUtil.serialize(nodeToAdd)) + } + + } + } + + return myNodes + }else{ + return null + } + } + + def getPBGFList(xmlInput){ + getPBGFList("false", xmlInput) + } + + def String decodeXML(xml) { + def String decodedXml = xml.replaceAll("&", "&") + decodedXml = decodedXml.replaceAll("<", "<") + decodedXml = decodedXml.replaceAll(">", ">") + } + + def getMetaVal(node, name){ + try{ + return node.'**'.find {it.metaname.text() == name}.metaval.text() + }catch(Exception e){ + return null + } + } + def getRelationshipVal(node, name){ + try{ + return node.'**'.find {it.'relationship-key'.text() == name}.'relationship-value'.text() + }catch(Exception e){ + return null + } + } + + + def log(logmode,logtxt,isDebugLogEnabled="false"){ + MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL); + if ("INFO"==logmode) { + msoLogger.info(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, logtxt); + } else if ("WARN"==logmode) { + msoLogger.warn (MessageEnum.BPMN_GENERAL_WARNING, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, logtxt); + } else if ("ERROR"==logmode) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, logtxt); + + } else { + BPMNLogger.debug(isDebugLogEnabled, logtxt); + } + } + + def logContext(requestId, serviceInstanceId){ + MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL); + msoLogger.setLogContext(requestId, serviceInstanceId); + } + + def logMetrics(elapsedTime, logtxt){ + MsoLogger metricsLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL); + + metricsLogger.recordMetricEvent (elapsedTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, + logtxt, "BPMN", MsoLogger.getServiceName(), null); + } + + def logAudit(logtxt){ + MsoLogger auditLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL); + long startTime = System.currentTimeMillis(); + + auditLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, logtxt); + } + + // headers: header - name-value + def getHeaderNameValue(xmlInput, nameAttribute){ + def rtn=null + if(xmlInput!=null){ + def xml= new XmlSlurper().parseText(xmlInput) + rtn= xml.'**'.find {header->header.'@name'.text() == nameAttribute}.'@value' + } + return rtn + } + + /** + * Gets the children of the specified element. + */ + public String getChildNodes(xmlInput, element) { + def xml= new XmlSlurper().parseText(xmlInput) + def thisElement = xml.'**'.find {it.name() == element} + StringBuilder out = new StringBuilder() + if (thisElement != null) { + thisElement.children().each() { + String nodeAsText = removeXmlPreamble(XmlUtil.serialize(it)) + if (out.length() > 0) { + out.append(System.lineSeparator()) + } + out.append(nodeAsText) + } + } + return out.toString(); + } + + /** + * Encodes a value so it can be used inside an XML text element. + * @param s the string to encode + * @return the encoded string + */ + public String xmlEncode(Object value) { + return XmlTool.encode(value) + } + + /** + * Encodes a value so it can be used inside an XML attribute. + * @param s the string to encode + * @return the encoded string + */ + public String xmlEncodeAttr(Object value) { + return XmlTool.encodeAttr(value) + } + + /** + * Decodes XML entities in a string value + * @param value a value with embedded XML entities + * @return the decoded string + */ + public String xmlDecode(Object value) { + return XmlTool.decode(value) + } + + /** + * Removes the preamble, if present, from an XML document. + * Also, for historical reasons, this also trims leading and trailing + * whitespace from the resulting document. TODO: remove the trimming + * and fix unit tests that depend on EXACT xml format. + * @param xml the XML document + * @return a possibly modified document + */ + public String removeXmlPreamble(def xml) { + if (xml == null) { + return null + } + + return XmlTool.removePreamble(xml).trim() + } + + /** + * Removes namespaces and namespace declarations from an XML document. + * @param xml the XML document + * @return a possibly modified document + */ + public String removeXmlNamespaces(def xml) { + return XmlTool.removeNamespaces(xml); + } + + /** + * Use formatXml instead. Note: this method inserts an XML preamble. + */ + @Deprecated + def formatXML(xmlInput) { + def parseXml = null + def formatXml = null + if (xmlInput !=null) { + parseXml = new XmlParser().parseText(xmlInput) + formatXml = XmlUtil.serialize(parseXml) + } + } + + /** + * Reformats an XML document. The result will not contain an XML preamble + * or a trailing newline. + * @param xml the XML document + * @return a reformatted document + */ + public String formatXml(def xml) { + return XmlTool.normalize(xml); + } + + // build single elements + def buildElements(xmlInput, elementList, parentName) { + String var = "" + def xmlBuild = "" + if (parentName != "") { + xmlBuild += "<tns2:"+parentName+">" + } + if (xmlInput != null) { + for (element in elementList) { + def xml= new XmlSlurper().parseText(xmlInput) + var = xml.'**'.find {it.name() == element} + if (var != null) { + xmlBuild += "<tns2:"+element+">"+var.toString()+"</tns2:"+element+">" + } + } + } + if (parentName != "") { + xmlBuild += "</tns2:"+parentName+">" + } + return xmlBuild + } + + // build the Unbounded elements + def buildElementsUnbounded(xmlInput, elementList, parentName) { + def varParents = "" + def var = "" + def xmlBuildUnbounded = "" + if (xmlInput != null) { + def xml= new XmlSlurper().parseText(xmlInput) + varParents = xml.'**'.findAll {it.name() == parentName} + //println " Unbounded ${parentName} - varParent.Size() - " + varParents.size() + for (i in 0..varParents.size()-1) { + if (parentName != "") { + xmlBuildUnbounded += "<tns2:"+parentName+">" + } + for (element in elementList) { + var = varParents[i].'*'.find {it.name() == element} + if (var != null) { + xmlBuildUnbounded += "<tns2:"+element+">"+var.toString()+"</tns2:"+element+">" + //println " i = " + i + ", element: " + element + " = " + var.toString() + } + } + if (parentName != "") { + xmlBuildUnbounded += "</tns2:"+parentName+">" + } + } + } + return xmlBuildUnbounded + } + + // Build l2-homing-information + def buildL2HomingInformation(xmlInput) { + def elementsL2HomingList = ["evc-name", "topology", "preferred-aic-clli"] + def rebuildL2Home = '' + if (xmlInput != null) { + rebuildL2Home = buildElements(xmlInput, elementsL2HomingList, "l2-homing-information") + } + return rebuildL2Home + } + + // Build internet-evc-access-information + def buildInternetEvcAccessInformation(xmlInput) { + def elementsInternetEvcAccessInformationList = ["internet-evc-speed-value", "internet-evc-speed-units", "ip-version"] + def rebuildInternetEvcAccess = '' + if (xmlInput != null) { + rebuildInternetEvcAccess = buildElements(xmlInput, elementsInternetEvcAccessInformationList, "internet-evc-access-information") + } + return rebuildInternetEvcAccess + } + + // Build ucpe-vms-service-information + def buildUcpeVmsServiceInformation(xmlInput) { + def rebuildUcpeVmsServiceInformation = '' + if (xmlInput != null) { + def ucpeVmsServiceInformation = getNodeXml(xmlInput, "ucpe-vms-service-information").drop(38).trim() + rebuildUcpeVmsServiceInformation = "<tns2:ucpe-vms-service-information>" + // transport-service-information + rebuildUcpeVmsServiceInformation += "<tns2:transport-service-information>" + def transportServiceInformation = getNodeXml(ucpeVmsServiceInformation, "transport-service-information").drop(38).trim() + def elementsTransportServiceInformationList = ["transport-service-type"] + rebuildUcpeVmsServiceInformation += buildElements(transportServiceInformation, elementsTransportServiceInformationList, "") + try { // optional + def accessCircuitInfoList = ["access-circuit-id", "dual-mode"] + rebuildUcpeVmsServiceInformation += buildElementsUnbounded(transportServiceInformation, accessCircuitInfoList, "access-circuit-info") + } catch (Exception e) { + log("ERROR", " Optional - Exception ACCESS-CIRCUIT-INFO - 'access-circuit-info' ") + } + rebuildUcpeVmsServiceInformation += "</tns2:transport-service-information>" + // ucpe-information + def elementsUcpeInformationList = ["ucpe-host-name", "ucpe-activation-code", "out-of-band-management-modem" ] + rebuildUcpeVmsServiceInformation += buildElements(ucpeVmsServiceInformation, elementsUcpeInformationList, "ucpe-information") + // vnf-list + rebuildUcpeVmsServiceInformation += "<tns2:vnf-list>" + def vnfListList = ["vnf-instance-id", "vnf-sequence-number", "vnf-type", "vnf-vendor", "vnf-model", "vnf-id", "prov-status", "operational-state", "orchestration-status", "equipment-role" ] + rebuildUcpeVmsServiceInformation += buildElementsUnbounded(ucpeVmsServiceInformation, vnfListList, "vnf-information") + rebuildUcpeVmsServiceInformation += "</tns2:vnf-list>" + rebuildUcpeVmsServiceInformation += "</tns2:ucpe-vms-service-information>" + } + log("DEBUG", " rebuildUcpeVmsServiceInformation - " + rebuildUcpeVmsServiceInformation) + return rebuildUcpeVmsServiceInformation + } + + // Build internet-service-change-details + def buildInternetServiceChangeDetails(xmlInput) { + def rebuildInternetServiceChangeDetails = "" + if (xmlInput != null) { + try { // optional + def internetServiceChangeDetails = getNodeXml(xmlInput, "internet-service-change-details").drop(38).trim() + rebuildInternetServiceChangeDetails = "<tns:internet-service-change-details>" + rebuildInternetServiceChangeDetails += buildElements(internetServiceChangeDetails, ["internet-evc-speed-value"], "") + rebuildInternetServiceChangeDetails += buildElements(internetServiceChangeDetails, ["internet-evc-speed-units"], "") + try { // optional + def tProvidedV4LanPublicPrefixesChangesList = ["request-index", "v4-next-hop-address", "v4-lan-public-prefix", "v4-lan-public-prefix-length"] + rebuildInternetServiceChangeDetails += buildElementsUnbounded(internetServiceChangeDetails, tProvidedV4LanPublicPrefixesChangesList, "t-provided-v4-lan-public-prefixes") + } catch (Exception e) { + log("ERROR"," Optional - Exception in INTERNET-SERVICE-CHANGE-DETAILS 't-provided-v4-lan-public-prefixes ") + } + try { // optional + def tProvidedV6LanPublicPrefixesChangesList = ["request-index", "v6-next-hop-address", "v6-lan-public-prefix", "v6-lan-public-prefix-length"] + rebuildInternetServiceChangeDetails += buildElementsUnbounded(internetServiceChangeDetails, tProvidedV6LanPublicPrefixesChangesList, "t-provided-v6-lan-public-prefixes") + } catch (Exception e) { + log("ERROR"," Optional - Exception INTERNET-SERVICE-CHANGE-DETAILS 't-provided-v6-lan-public-prefixes ") + } + rebuildInternetServiceChangeDetails += "</tns:internet-service-change-details>" + } catch (Exception e) { + log("ERROR", " Optional - Exception INTERNET-SERVICE-CHANGE-DETAILS 'internet-service-change-details' ") + } + } + return rebuildInternetServiceChangeDetails + } + + // Build vr-lan + def buildVrLan(xmlInput) { + + def rebuildVrLan = '' + if (xmlInput != null) { + + rebuildVrLan = "<tns2:vr-lan>" + def vrLan = getNodeXml(xmlInput, "vr-lan").drop(38).trim() + rebuildVrLan += buildElements(vrLan, ["routing-protocol"], "") + + // vr-lan-interface + def rebuildVrLanInterface = "<tns2:vr-lan-interface>" + def vrLanInterface = getNodeXml(vrLan, "vr-lan-interface").drop(38).trim() + rebuildVrLanInterface += buildVrLanInterfacePartial(vrLanInterface) + + // dhcp + def dhcp = getNodeXml(vrLan, "dhcp").drop(38).trim() + def rebuildDhcp = buildDhcp(dhcp) + rebuildVrLanInterface += rebuildDhcp + + // pat + def pat = getNodeXml(vrLan, "pat").drop(38).trim() + def rebuildPat = buildPat(pat) + rebuildVrLanInterface += rebuildPat + + // nat + def rebuildNat = "" + try { // optional + def nat = getNodeXml(vrLan, "nat").drop(38).trim() + rebuildNat = buildNat(nat) + } catch (Exception e) { + log("ERROR", " Optional - Exception 'nat' ") + } + rebuildVrLanInterface += rebuildNat + + // firewall-lite + def firewallLite = getNodeXml(vrLan, "firewall-lite").drop(38).trim() + def rebuildFirewallLite = buildFirewallLite(firewallLite) + rebuildVrLanInterface += rebuildFirewallLite + + // static-routes + def rebuildStaticRoutes = "" + try { // optional + def staticRoutes = getNodeXml(vrLan, "static-routes").drop(38).trim() + rebuildStaticRoutes = buildStaticRoutes(staticRoutes) + } catch (Exception e) { + log("ERROR", " Optional - Exception 'static-routes' ") + } + rebuildVrLanInterface += rebuildStaticRoutes + + rebuildVrLan += rebuildVrLanInterface + rebuildVrLan += "</tns2:vr-lan-interface>" + rebuildVrLan += "</tns2:vr-lan>" + + } + log("DEBUG", " rebuildVrLan - " + rebuildVrLan) + return rebuildVrLan + } + + // Build vr-lan-interface + def buildVrLanInterfacePartial(xmlInput) { + def rebuildingVrLanInterface = '' + if (xmlInput != null) { + def vrLanInterfaceList = ["vr-designation", "v4-vr-lan-prefix", "v4-vr-lan-address", "v4-vr-lan-prefix-length", "v6-vr-lan-prefix", "v6-vr-lan-address", "v6-vr-lan-prefix-length", "v4-vce-loopback-address", "v6-vce-wan-address"] + rebuildingVrLanInterface += buildElements(xmlInput, vrLanInterfaceList, "") + rebuildingVrLanInterface += "<tns2:v4-public-lan-prefixes>" + try { // optional + def tProvidedV4LanPublicPrefixes = getNodeXml(xmlInput, "v4-public-lan-prefixes").drop(38).trim() + def tProvidedV4LanPublicPrefixesList = ["request-index", "v4-next-hop-address", "v4-lan-public-prefix", "v4-lan-public-prefix-length" ] + rebuildingVrLanInterface += buildElementsUnbounded(xmlInput, tProvidedV4LanPublicPrefixesList, "t-provided-v4-lan-public-prefixes") + } catch (Exception ex) { + log("ERROR", " Optional - Exception VR-LAN INTERFACE 'v4-public-lan-prefixes' ") + } + rebuildingVrLanInterface += "</tns2:v4-public-lan-prefixes>" + rebuildingVrLanInterface += "<tns2:v6-public-lan-prefixes>" + try { // optional + def tProvidedV6LanPublicPrefixes = getNodeXml(xmlInput, "v6-public-lan-prefixes").drop(38).trim() + def tProvidedV6LanPublicPrefixesList = ["request-index", "v6-next-hop-address", "v6-lan-public-prefix", "v6-lan-public-prefix-length" ] + rebuildingVrLanInterface += buildElementsUnbounded(xmlInput, tProvidedV6LanPublicPrefixesList, "t-provided-v6-lan-public-prefixes") + } catch (Exception e) { + log("ERROR", " Optional - Exception VR-LAN INTERFACE 'v6-public-lan-prefixes' ") + } + rebuildingVrLanInterface += "</tns2:v6-public-lan-prefixes>" + } + log("DEBUG", " rebuildingVrLanInterface - " + rebuildingVrLanInterface) + return rebuildingVrLanInterface + } + + // Build dhcp + def buildDhcp(xmlInput) { + def rebuildingDhcp = '' + if (xmlInput != null) { + def dhcpData = new XmlSlurper().parseText(xmlInput) + rebuildingDhcp = "<tns2:dhcp>" + def dhcpList1 = ["v4-dhcp-server-enabled", "v6-dhcp-server-enabled", "use-v4-default-pool", "v4-dhcp-default-pool-prefix", "v4-dhcp-default-pool-prefix-length"] + rebuildingDhcp += buildElements(xmlInput, dhcpList1, "") + try { // optional + def excludedV4DhcpAddressesFromDefaultPoolList = ["excluded-v4-address"] + rebuildingDhcp += buildElementsUnbounded(xmlInput, excludedV4DhcpAddressesFromDefaultPoolList, "excluded-v4-dhcp-addresses-from-default-pool") + } catch (Exception e) { + log("ERROR", " Optional - Exception DHCP 'excluded-v4-dhcp-addresses-from-default-pool' ") + } + try { // optional + def v4DhcpPools = dhcpData.'**'.findAll {it.name() == "v4-dhcp-pools"} + def v4DhcpPoolsSize = v4DhcpPools.size() + // println " v4DhcpPoolsSize = " + v4DhcpPools.size() + for (i in 0..v4DhcpPoolsSize-1) { + def v4DhcpPool = v4DhcpPools[i] + def v4DhcpPoolXml = XmlUtil.serialize(v4DhcpPool) + rebuildingDhcp += "<tns2:v4-dhcp-pools>" + def v4DhcpPoolsList1 = ["v4-dhcp-pool-prefix", "v4-dhcp-pool-prefix-length" ] + rebuildingDhcp += buildElements(v4DhcpPoolXml, v4DhcpPoolsList1, "") + try { // optional + def excludedV4AddressesList = ["excluded-v4-address"] + rebuildingDhcp += buildElementsUnbounded(v4DhcpPoolXml, excludedV4AddressesList, "excluded-v4-addresses") + } catch (Exception e) { + log("ERROR", " Optional - Exception DHCP 'excluded-v4-addresses' ") + } + def v4DhcpPoolsList2 = ["v4-dhcp-relay-gateway-address", "v4-dhcp-relay-next-hop-address"] + rebuildingDhcp += buildElements(v4DhcpPoolXml, v4DhcpPoolsList2, "") + rebuildingDhcp += "</tns2:v4-dhcp-pools>" + } + } catch (Exception e) { + log("ERROR"," Optional - Exception DHCP 'v4-dhcp-pools' ") + } + def dhcpList2 = ["use-v6-default-pool", "v6-dhcp-default-pool-prefix", "v6-dhcp-default-pool-prefix-length"] + rebuildingDhcp += buildElements(xmlInput, dhcpList2, "") + try { // optional + def excludedV6DhcpAddressesFromDdefaultPoolList = ["excluded-v6-address"] + rebuildingDhcp += buildElementsUnbounded(xmlInput, excludedV6DhcpAddressesFromDdefaultPoolList, "excluded-v6-dhcp-addresses-from-default-pool") + } catch (Exception e) { + log("ERROR", " Optional - Exception DHCP 'excluded-v6-dhcp-addresses-from-default-pool' ") + } + try { // optional + def v6DhcpPools = dhcpData.'**'.findAll {it.name() == "v6-dhcp-pools"} + def v6DhcpPoolsSize = v6DhcpPools.size() + //println " v6DhcpPoolsSize = " + v6DhcpPools.size() + for (i in 0..v6DhcpPoolsSize-1) { + def v6DhcpPool = v6DhcpPools[i] + def v6DhcpPoolXml = XmlUtil.serialize(v6DhcpPool) + rebuildingDhcp += "<tns2:v6-dhcp-pools>" + def v6DhcpPoolsList1 = ["v6-dhcp-pool-prefix", "v6-dhcp-pool-prefix-length"] + rebuildingDhcp += buildElements(v6DhcpPoolXml, v6DhcpPoolsList1, "") + try { // optional + def excludedV6AddressesList = ["excluded-v6-address"] + rebuildingDhcp += buildElementsUnbounded(v6DhcpPoolXml, excludedV6AddressesList, "excluded-v6-addresses") + } catch (Exception e) { + log("ERROR", " Optional - Exception DHCP 'excluded-v6-addresses' ") + } + def v6DhcpPoolsList2 = ["v6-dhcp-relay-gateway-address", "v6-dhcp-relay-next-hop-address"] + rebuildingDhcp += buildElements(v6DhcpPoolXml, v6DhcpPoolsList2, "") + rebuildingDhcp += "</tns2:v6-dhcp-pools>" + } + } catch (Exception e) { + log("ERROR", " Optional - Exception DHCP 'v6-dhcp-pools' ") + } + rebuildingDhcp += "</tns2:dhcp>" + } + log("DEBUG", " rebuildingDhcp - " + rebuildingDhcp) + return rebuildingDhcp + } + + // Build pat + def buildPat(xmlInput) { + def rebuildingPat = '' + if (xmlInput != null) { + rebuildingPat = "<tns2:pat>" + def patList = ["v4-pat-enabled", "use-v4-default-pool", "v4-pat-default-pool-prefix", "v4-pat-default-pool-prefix-length"] + rebuildingPat += buildElements(xmlInput, patList, "") + try { // optional + def v4PatPools = getNodeXml(xmlInput, "v4-pat-pools").drop(38).trim() + def v4PatPoolsList = ["v4-pat-pool-prefix", "v4-pat-pool-prefix-length", "v4-pat-pool-next-hop-address"] + rebuildingPat += buildElementsUnbounded(xmlInput, v4PatPoolsList, "v4-pat-pools") + } catch (Exception e) { + log("ERROR", " Optional - Exception 'v4-pat-pool-next-hop-address' ") + } + rebuildingPat += "</tns2:pat>" + } + log("DEBUG", " rebuildingPat - " + rebuildingPat) + return rebuildingPat + } + + // Build nat + def buildNat(xmlInput) { + def rebuildingNat = '' + if (xmlInput != null) { + rebuildingNat = "<tns2:nat>" + rebuildingNat += buildElements(xmlInput, ["v4-nat-enabled"], "") + try { // optional + def v4NatMappingEntries = getNodeXml(xmlInput, "v4-nat-mapping-entries").drop(38).trim() + def v4NatMappingEntriesList = ["v4-nat-internal", "v4-nat-next-hop-address", "v4-nat-external"] + rebuildingNat += buildElementsUnbounded(xmlInput, v4NatMappingEntriesList, "v4-nat-mapping-entries") + } catch (Exception e) { + log("ERROR", " Optional - Exception 'v4-nat-external' ") + } + rebuildingNat += "</tns2:nat>" + } + log("DEBUG", " rebuildingNat - " + rebuildingNat) + return rebuildingNat + } + + // Build firewall-lite + def buildFirewallLite(xmlInput) { + def rebuildingFirewallLite = '' + + if (xmlInput != null) { + + def firewallLiteData = new XmlSlurper().parseText(xmlInput) + rebuildingFirewallLite = "<tns2:firewall-lite>" + def firewallLiteList = ["stateful-firewall-lite-v4-enabled", "stateful-firewall-lite-v6-enabled"] + rebuildingFirewallLite += buildElements(xmlInput, firewallLiteList, "") + + try { // optional + def v4FirewallPacketFilters = firewallLiteData.'**'.findAll {it.name() == "v4-firewall-packet-filters"} + def v4FirewallPacketFiltersSize = v4FirewallPacketFilters.size() + //println " v4FirewallPacketFiltersSize = " + v4FirewallPacketFilters.size() + for (i in 0..v4FirewallPacketFiltersSize-1) { + def v4FirewallPacketFilter = v4FirewallPacketFilters[i] + def v4FirewallPacketFilterXml = XmlUtil.serialize(v4FirewallPacketFilter) + rebuildingFirewallLite += "<tns2:v4-firewall-packet-filters>" + def v4FirewallPacketFiltersList = ["v4-firewall-prefix", "v4-firewall-prefix-length", "allow-icmp-ping"] + rebuildingFirewallLite += buildElements(v4FirewallPacketFilterXml, v4FirewallPacketFiltersList, "") + try { // optional + def udpPortsList = ["port-number"] + rebuildingFirewallLite += buildElementsUnbounded(v4FirewallPacketFilterXml, udpPortsList, "udp-ports") + } catch (Exception e) { + log("ERROR", " Optional - Exception FIREWALL-LITE v4 'udp-ports' ") + } + try { // optional + def tcpPortsList = ["port-number"] + rebuildingFirewallLite += buildElementsUnbounded(v4FirewallPacketFilterXml, tcpPortsList, "tcp-ports") + } catch (Exception e) { + log("ERROR", " Optional - Exception FIREWALL-LITE v4 'tcp-ports' ") + } + rebuildingFirewallLite += "</tns2:v4-firewall-packet-filters>" + } + } catch (Exception e) { + log("ERROR", " Optional - Exception FIREWALL-LITE 'v4-firewall-packet-filters' ") + } + + try { // optional + def v6FirewallPacketFilters = firewallLiteData.'**'.findAll {it.name() == "v6-firewall-packet-filters"} + def v6FirewallPacketFiltersSize = v6FirewallPacketFilters.size() + //println " v6FirewallPacketFiltersSize = " + v6FirewallPacketFilters.size() + for (i in 0..v6FirewallPacketFiltersSize-1) { + def v6FirewallPacketFilter = v6FirewallPacketFilters[i] + def v6FirewallPacketFilterXml = XmlUtil.serialize(v6FirewallPacketFilter) + rebuildingFirewallLite += "<tns2:v6-firewall-packet-filters>" + def v6FirewallPacketFiltersList = ["v6-firewall-prefix", "v6-firewall-prefix-length", "allow-icmp-ping"] + rebuildingFirewallLite += buildElements(v6FirewallPacketFilterXml, v6FirewallPacketFiltersList, "") + try { // optional + def udpPortsList = ["port-number"] + rebuildingFirewallLite += buildElementsUnbounded(v6FirewallPacketFilterXml, udpPortsList, "udp-ports") + } catch (Exception e) { + log("ERROR", " Optional - Exception FIREWALL-LITE v6 'udp-ports' ") + } + try { // optional + def tcpPortsList = ["port-number"] + rebuildingFirewallLite += buildElementsUnbounded(v6FirewallPacketFilterXml, tcpPortsList, "tcp-ports") + } catch (Exception e) { + log("ERROR", " Optional - Exception FIREWALL-LITE v6 'tcp-ports' ") + } + rebuildingFirewallLite += "</tns2:v6-firewall-packet-filters>" + } + } catch (Exception e) { + log("ERROR", " Optional - Exception FIREWALL-LITE 'v6-firewall-packet-filters' ") + } + rebuildingFirewallLite+= "</tns2:firewall-lite>" + } + log("DEBUG", " rebuildingFirewallLite - " + rebuildingFirewallLite) + return rebuildingFirewallLite + } + + def buildStaticRoutes(xmlInput) { + def rebuildingStaticRoutes = '' + if (xmlInput != null) { + rebuildingStaticRoutes = "<tns2:static-routes>" + def v4StaticRouteslist = ["v4-static-route-prefix","v4-static-route-prefix-length", "v4-next-hop-address"] + rebuildingStaticRoutes += buildElementsUnbounded(xmlInput, v4StaticRouteslist, "v4-static-routes") + def v6StaticRouteslist = ["v6-static-route-prefix","v6-static-route-prefix-length", "v6-next-hop-address"] + rebuildingStaticRoutes += buildElementsUnbounded(xmlInput, v6StaticRouteslist, "v6-static-routes") + rebuildingStaticRoutes += "</tns2:static-routes>" + } + log("DEBUG", " rebuildingStaticRoutes - " + rebuildingStaticRoutes) + return rebuildingStaticRoutes + } + + public String generateCurrentTimeInUtc(){ + final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); + sdf.setTimeZone(TimeZone.getTimeZone("UTC")); + final String utcTime = sdf.format(new Date()); + return utcTime; + } + + public String generateCurrentTimeInGMT(){ + final SimpleDateFormat sdf = new SimpleDateFormat("E, d MMM yyyy h:m:s z"); + sdf.setTimeZone(TimeZone.getTimeZone("GMT")); + final String utcTime = sdf.format(new Date()); + return utcTime; + } + + + /** + * @param encryptedAuth: encrypted credentials from urn properties + * @param msoKey: key to use to decrypt from urn properties + * @return base 64 encoded basic auth credentials + */ + def getBasicAuth(encryptedAuth, msoKey){ + try { + def auth = decrypt(encryptedAuth, msoKey) + byte[] encoded = Base64.encodeBase64(auth.getBytes()) + String encodedString = new String(encoded) + encodedString = "Basic " + encodedString + return encodedString + } catch (Exception ex) { + log("ERROR", "Unable to encode basic auth") + throw ex + } + } + + def encrypt(toEncrypt, msokey){ + try { + String result = CryptoUtils.encrypt(toEncrypt, msokey); + return result + } + catch (Exception e) { + log("ERROR", "Failed to encrypt credentials") + } + } + + def decrypt(toDecrypt, msokey){ + try { + String result = CryptoUtils.decrypt(toDecrypt, msokey); + return result + } + catch (Exception e) { + log("ERROR", "Failed to decrypt credentials") + throw e + } + } + + /** + * Return URL with qualified host name (if any) or urn mapping + * @param String url from urn mapping + * @return String url with qualified host name + */ + public String getQualifiedHostNameForCallback(String urnCallbackUrl) { + def callbackUrlToUse = urnCallbackUrl + try{ + //swap host name with qualified host name from the jboss properties + def qualifiedHostName = System.getProperty("jboss.qualified.host.name") + if(qualifiedHostName!=null){ + log("DEBUG", "qualifiedHostName:\n" + qualifiedHostName) + callbackUrlToUse = callbackUrlToUse.replaceAll("(http://)(.*)(:28080*)", {orig, first, torepl, last -> "${first}${qualifiedHostName}${last}"}) + } + }catch(Exception e){ + log("DEBUG", "unable to grab qualified host name, using what's in urn properties for callbackurl. Exception was: " + e.printStackTrace()) + } + return callbackUrlToUse + + } + + /** + * Retrieves text context of the element if the element exists, returns empty string otherwise + * @param com.sun.org.apache.xerces.internal.dom.DeferredElementNSImpl element to parse + * param String tagName tagName + * @return String text content of the element + */ + public String getElementText(Element element, String tagName) { + String text = "" + org.w3c.dom.NodeList nodeList = element.getElementsByTagNameNS("*", tagName) + if (nodeList != null && nodeList.length > 0) { + text = nodeList.item(0).getTextContent() + } + return text + } + + /** + * + * Find the lowest unused module-index value in a given xml + */ + public String getLowestUnusedIndex(String xml) { + if (xml == null || xml.isEmpty()) { + return "0" + } + def moduleIndexList = getMultNodes(xml, "module-index") + if (moduleIndexList == null || moduleIndexList.size() == 0) { + return "0" + } + def sortedModuleIndexList = moduleIndexList.sort { a, b -> a.compareTo b } + + for (i in 0..sortedModuleIndexList.size()-1) { + if (Integer.parseInt(sortedModuleIndexList[i]) != i) { + return i.toString() + } + } + return sortedModuleIndexList.size().toString() + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/NetworkUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/NetworkUtils.groovy new file mode 100644 index 0000000000..c9e243dd54 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/NetworkUtils.groovy @@ -0,0 +1,1445 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common.scripts; + +import org.apache.commons.lang3.* + +import groovy.xml.XmlUtil + +import javax.xml.parsers.DocumentBuilder +import javax.xml.parsers.DocumentBuilderFactory +import javax.xml.transform.Transformer +import javax.xml.transform.TransformerFactory +import javax.xml.transform.TransformerException +import javax.xml.transform.dom.DOMSource +import javax.xml.transform.stream.StreamResult + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.runtime.Execution +import org.w3c.dom.Document +import org.w3c.dom.Element + +import org.w3c.dom.NamedNodeMap +import org.w3c.dom.Node +import org.w3c.dom.NodeList; +import org.xml.sax.InputSource + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.runtime.Execution +import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor; +import org.w3c.dom.Document +import org.w3c.dom.Element +import org.w3c.dom.NamedNodeMap +import org.w3c.dom.Node +import org.w3c.dom.NodeList; +import org.xml.sax.InputSource + + +/** + * This groovy class supports the any Network processes that need the methods defined here. + */ +class NetworkUtils { + + public MsoUtils utils = new MsoUtils() + private AbstractServiceTaskProcessor taskProcessor + + public NetworkUtils(AbstractServiceTaskProcessor taskProcessor) { + this.taskProcessor = taskProcessor + } + + /** + * This method returns the string for Network request + * V2 for Contrail 3.x will populate cloud-region data in same cloudSiteId filed + * Network adapter will handle it properly + * @param requestId either 'request-id' or 'openecomp-mso-request-id' + * @param requestInput the request in the process + * @param queryIdResponse the response of REST AAI query by Id + * @param routeCollection the collection + * @param policyFqdns the policy + * @param tableCollection the collection + * @param cloudRegionId the cloud-region-region + * @return String request + */ + def CreateNetworkRequestV2(execution, requestId, messageId, requestInput, queryIdResponse, routeCollection, policyFqdns, tableCollection, cloudRegionId, backoutOnFailure, source) { + String createNetworkRequest = null + if(requestInput!=null && queryIdResponse!=null) { + String serviceInstanceId = "" + String sharedValue = "" + String externalValue = "" + + if (source == "VID") { + sharedValue = utils.getNodeText1(queryIdResponse, "is-shared-network") != null ? utils.getNodeText1(queryIdResponse, "is-shared-network") : "false" + externalValue = utils.getNodeText1(queryIdResponse, "is-external-network") != null ? utils.getNodeText1(queryIdResponse, "is-external-network") : "false" + serviceInstanceId = utils.getNodeText1(requestInput, "service-instance-id") + + } else { // source = 'PORTAL' + sharedValue = getParameterValue(requestInput, "shared") + externalValue = getParameterValue(requestInput, "external") + serviceInstanceId = utils.getNodeText1(requestInput, "service-instance-id") != null ? utils.getNodeText1(requestInput, "service-instance-id") : "" + } + + String networkParams = "" + if (utils.nodeExists(requestInput, "network-params")) { + String netParams = utils.getNodeXml(requestInput, "network-params", false).replace("tag0:","").replace(":tag0","") + networkParams = buildParams(netParams) + } + + String failIfExists = "false" + // requestInput + String cloudRegion = cloudRegionId + String tenantId = utils.getNodeText1(requestInput, "tenant-id") + String networkType = "" + if (utils.nodeExists(requestInput, "networkModelInfo")) { + String networkModelInfo = utils.getNodeXml(requestInput, "networkModelInfo", false).replace("tag0:","").replace(":tag0","") + networkType = utils.getNodeText1(networkModelInfo, "modelName") + } else { + networkType = utils.getNodeText1(queryIdResponse, "network-type") + } + + // queryIdResponse + String networkName = utils.getNodeText1(queryIdResponse, "network-name") + String networkId = utils.getNodeText1(queryIdResponse, "network-id") + String networkTechnology = utils.getNodeText1(queryIdResponse, "network-technology") + + // contrailNetwork - networkTechnology = 'Contrail' vs. 'AIC_SR_IOV') + String contrailNetwork = "" + if (networkTechnology.contains('Contrail') || networkTechnology.contains('contrail') || networkTechnology.contains('CONTRAIL')) { + contrailNetwork = """<contrailNetwork> + <shared>${sharedValue}</shared> + <external>${externalValue}</external> + ${routeCollection} + ${policyFqdns} + ${tableCollection} + </contrailNetwork>""" + networkTechnology = "CONTRAIL" // replace + } + + // rebuild subnets + String subnets = "" + if (utils.nodeExists(queryIdResponse, "subnets")) { + def subnetsGroup = utils.getNodeXml(queryIdResponse, "subnets", false) + subnets = buildSubnets(subnetsGroup) + } + + String physicalNetworkName = "" + physicalNetworkName = utils.getNodeText1(queryIdResponse, "physical-network-name") + + String vlansCollection = buildVlans(queryIdResponse) + + String notificationUrl = "" //TODO - is this coming from URN? What variable/value to use? + //String notificationUrl = execution.getVariable("URN_?????") //TODO - is this coming from URN? What variable/value to use? + + createNetworkRequest = """ + <createNetworkRequest> + <cloudSiteId>${cloudRegion}</cloudSiteId> + <tenantId>${tenantId}</tenantId> + <networkId>${networkId}</networkId> + <networkName>${networkName}</networkName> + <networkType>${networkType}</networkType> + <networkTechnology>${networkTechnology}</networkTechnology> + <providerVlanNetwork> + <physicalNetworkName>${physicalNetworkName}</physicalNetworkName > + ${vlansCollection} + </providerVlanNetwork> + ${contrailNetwork} + ${subnets} + <skipAAI>true</skipAAI> + <backout>${backoutOnFailure}</backout> + <failIfExists>${failIfExists}</failIfExists> + ${networkParams} + <msoRequest> + <requestId>${requestId}</requestId> + <serviceInstanceId>${serviceInstanceId}</serviceInstanceId> + </msoRequest> + <messageId>${messageId}</messageId> + <notificationUrl>${notificationUrl}</notificationUrl> + </createNetworkRequest> + """.trim() + } + return createNetworkRequest + + } + + /** + * This method returns the string for Network request + * V2 for Contrail 3.x will populate cloud-region data in same cloudSiteId filed + * Network adapter will handle it properly + * @param requestId either 'request-id' or 'openecomp-mso-request-id' + * @param requestInput the request in the process + * @param queryIdResponse the response of REST AAI query by Id + * @param routeCollection the collection + * @param policyFqdns the policy + * @param cloudRegionId the cloud-region-region + * @return String request + */ + def UpdateNetworkRequestV2(execution, requestId, messageId, requestInput, queryIdResponse, routeCollection, policyFqdns, tableCollection, cloudRegionId, backoutOnFailure, source) { + String updateNetworkRequest = null + if(requestInput!=null && queryIdResponse!=null) { + String serviceInstanceId = "" + String sharedValue = "" + String externalValue = "" + + if (source == "VID") { + sharedValue = utils.getNodeText1(queryIdResponse, "is-shared-network") != null ? utils.getNodeText1(queryIdResponse, "is-shared-network") : "false" + externalValue = utils.getNodeText1(queryIdResponse, "is-external-network") != null ? utils.getNodeText1(queryIdResponse, "is-external-network") : "false" + serviceInstanceId = utils.getNodeText1(requestInput, "service-instance-id") + + } else { // source = 'PORTAL' + sharedValue = getParameterValue(requestInput, "shared") + externalValue = getParameterValue(requestInput, "external") + serviceInstanceId = utils.getNodeText1(requestInput, "service-instance-id") != null ? utils.getNodeText1(requestInput, "service-instance-id") : "" + } + + String failIfExists = "false" + // requestInput + String cloudRegion = cloudRegionId + String tenantId = utils.getNodeText1(requestInput, "tenant-id") + + // queryIdResponse + String networkName = utils.getNodeText1(queryIdResponse, "network-name") + String networkId = utils.getNodeText1(queryIdResponse, "network-id") + String networkType = utils.getNodeText1(queryIdResponse, "network-type") + + // rebuild subnets + String subnets = "" + if (utils.nodeExists(queryIdResponse, "subnets")) { + def subnetsGroup = utils.getNodeXml(queryIdResponse, "subnets", false) + subnets = buildSubnets(subnetsGroup) + } + + String networkParams = "" + if (utils.nodeExists(requestInput, "network-params")) { + String netParams = utils.getNodeXml(requestInput, "network-params", false).replace("tag0:","").replace(":tag0","") + networkParams = buildParams(netParams) + } + + String networkStackId = utils.getNodeText1(queryIdResponse, "heat-stack-id") + if (networkStackId == 'null' || networkStackId == "" || networkStackId == null) { + networkStackId = "force_update" + } + + String physicalNetworkName = utils.getNodeText1(queryIdResponse, "physical-network-name") + String vlansCollection = buildVlans(queryIdResponse) + + updateNetworkRequest = + """<updateNetworkRequest> + <cloudSiteId>${cloudRegion}</cloudSiteId> + <tenantId>${tenantId}</tenantId> + <networkId>${networkId}</networkId> + <networkStackId>${networkStackId}</networkStackId> + <networkName>${networkName}</networkName> + <networkType>${networkType}</networkType> + <networkTypeVersion/> + <networkTechnology>CONTRAIL</networkTechnology> + <providerVlanNetwork> + <physicalNetworkName>${physicalNetworkName}</physicalNetworkName> + ${vlansCollection} + </providerVlanNetwork> + <contrailNetwork> + <shared>${sharedValue}</shared> + <external>${externalValue}</external> + ${routeCollection} + ${policyFqdns} + ${tableCollection} + </contrailNetwork> + ${subnets} + <skipAAI>true</skipAAI> + <backout>${backoutOnFailure}</backout> + <failIfExists>${failIfExists}</failIfExists> + ${networkParams} + + <msoRequest> + <requestId>${requestId}</requestId> + <serviceInstanceId>${serviceInstanceId}</serviceInstanceId> + </msoRequest> + <messageId>${messageId}</messageId> + <notificationUrl></notificationUrl> + </updateNetworkRequest>""".trim() + + } + return updateNetworkRequest + + } + + /** + * This method returns the string for Create Volume Request payload + * @param groupId the volume-group-id + * @param volumeName the volume-group-name + * @param vnfType the vnf-type + * @param tenantId the value of relationship-key 'tenant.tenant-id' + * @return String request payload + */ + def String CreateNetworkVolumeRequest(groupId, volumeName, vnfType, tenantId) { + + String requestPayload = + """<volume-group xmlns="http://org.openecomp.mso/v6"> + <volume-group-id>${groupId}</volume-group-id> + <volume-group-name>${volumeName}</volume-group-name> + <heat-stack-id></heat-stack-id> + <vnf-type>${vnfType}</vnf-type> + <orchestration-status>Pending</orchestration-status> + <relationship-list> + <relationship> + <related-to>tenant</related-to> + <relationship-data> + <relationship-key>tenant.tenant-id</relationship-key> + <relationship-value>${tenantId}</relationship-value> + </relationship-data> + </relationship> + </relationship-list> + </volume-group>""" + + return requestPayload + } + + def String createCloudRegionVolumeRequest(groupId, volumeName, vnfType, tenantId, cloudRegion, namespace, modelCustomizationId) { + + String requestPayload = + """<volume-group xmlns="${namespace}"> + <volume-group-id>${groupId}</volume-group-id> + <volume-group-name>${volumeName}</volume-group-name> + <heat-stack-id></heat-stack-id> + <vnf-type>${vnfType}</vnf-type> + <orchestration-status>Pending</orchestration-status> + <vf-module-persona-model-customization-id>${modelCustomizationId}</vf-module-persona-model-customization-id> + <relationship-list> + <relationship> + <related-to>tenant</related-to> + <relationship-data> + <relationship-key>tenant.tenant-id</relationship-key> + <relationship-value>${tenantId}</relationship-value> + </relationship-data> + <relationship-data> + <relationship-key>cloud-region.cloud-owner</relationship-key> + <relationship-value>openecomp-aic</relationship-value> + </relationship-data> + <relationship-data> + <relationship-key>cloud-region.cloud-region-id</relationship-key> + <relationship-value>${cloudRegion}</relationship-value> + </relationship-data> + </relationship> + </relationship-list> + </volume-group>""" + + return requestPayload + } + + def String createCloudRegionVolumeRequest(groupId, volumeName, vnfType, vnfId, tenantId, cloudRegion, namespace, modelCustomizationId) { + + String requestPayload = + """<volume-group xmlns="${namespace}"> + <volume-group-id>${groupId}</volume-group-id> + <volume-group-name>${volumeName}</volume-group-name> + <heat-stack-id></heat-stack-id> + <vnf-type>${vnfType}</vnf-type> + <orchestration-status>Pending</orchestration-status> + <vf-module-persona-model-customization-id>${modelCustomizationId}</vf-module-persona-model-customization-id> + <relationship-list> + <relationship> + <related-to>generic-vnf</related-to> + <relationship-data> + <relationship-key>generic-vnf.vnf-id</relationship-key> + <relationship-value>${vnfId}</relationship-value> + </relationship-data> + </relationship> + <relationship> + <related-to>tenant</related-to> + <relationship-data> + <relationship-key>tenant.tenant-id</relationship-key> + <relationship-value>${tenantId}</relationship-value> + </relationship-data> + <relationship-data> + <relationship-key>cloud-region.cloud-owner</relationship-key> + <relationship-value>openecomp-aic</relationship-value> + </relationship-data> + <relationship-data> + <relationship-key>cloud-region.cloud-region-id</relationship-key> + <relationship-value>${cloudRegion}</relationship-value> + </relationship-data> + </relationship> + </relationship-list> + </volume-group>""" + + return requestPayload + } + + + /** + * This method returns the string for Update Volume Request payload + * @param requeryAAIVolGrpNameResponse the response of query volume group name (in AAI) + * @param heatStackId the value of heat stack id + * @return String request payload + */ + def String updateCloudRegionVolumeRequest(requeryAAIVolGrpNameResponse, heatStackId, namespace, modelCustomizationId) { + String requestPayload = "" + if (requeryAAIVolGrpNameResponse != null) { + def groupId = utils.getNodeText(requeryAAIVolGrpNameResponse, "volume-group-id") + def volumeName = utils.getNodeText(requeryAAIVolGrpNameResponse, "volume-group-name") + def vnfType = utils.getNodeText(requeryAAIVolGrpNameResponse, "vnf-type") + def resourceVersion = utils.getNodeText(requeryAAIVolGrpNameResponse, "resource-version") + def relationshipList = "" + if (utils.nodeExists(requeryAAIVolGrpNameResponse, "relationship")) { + relationshipList = rebuildRelationship(requeryAAIVolGrpNameResponse) + } + + requestPayload = + """<volume-group xmlns="${namespace}"> + <volume-group-id>${groupId}</volume-group-id> + <volume-group-name>${volumeName}</volume-group-name> + <heat-stack-id>${heatStackId}</heat-stack-id> + <vnf-type>${vnfType}</vnf-type> + <orchestration-status>Active</orchestration-status> + <resource-version>${resourceVersion}</resource-version> + <vf-module-persona-model-customization-id>${modelCustomizationId}</vf-module-persona-model-customization-id> + ${relationshipList} + </volume-group>""" + } + + return requestPayload + } + + + /** + * This method returns the string for Update Volume Request payload + * @param requeryAAIVolGrpNameResponse the response of query volume group name (in AAI) + * @param heatStackId the value of heat stack id + * @return String request payload + */ + def String UpdateNetworkVolumeRequest(requeryAAIVolGrpNameResponse, heatStackId) { + String requestPayload = "" + if (requeryAAIVolGrpNameResponse != null) { + def groupId = utils.getNodeText(requeryAAIVolGrpNameResponse, "volume-group-id") + def volumeName = utils.getNodeText(requeryAAIVolGrpNameResponse, "volume-group-name") + def vnfType = utils.getNodeText(requeryAAIVolGrpNameResponse, "vnf-type") + def resourceVersion = utils.getNodeText(requeryAAIVolGrpNameResponse, "resource-version") + def relationshipList = "" + if (utils.nodeExists(requeryAAIVolGrpNameResponse, "relationship")) { + relationshipList = rebuildRelationship(requeryAAIVolGrpNameResponse) + } + + requestPayload = + """<volume-group xmlns="http://org.openecomp.mso/v6"> + <volume-group-id>${groupId}</volume-group-id> + <volume-group-name>${volumeName}</volume-group-name> + <heat-stack-id>${heatStackId}</heat-stack-id> + <vnf-type>${vnfType}</vnf-type> + <orchestration-status>Active</orchestration-status> + <resource-version>${resourceVersion}</resource-version> + ${relationshipList} + </volume-group>""" + } + + return requestPayload + } + + /** + * This method returns the string for Create Contrail Network payload + * @param requeryIdAAIResponse the response from AAI query by id + * @param createNetworkResponse the response of create network + * @return String contrailNetworkCreatedUpdate + */ + def ContrailNetworkCreatedUpdate(requeryIdAAIResponse, createNetworkResponse, schemaVersion) { + + String contrailNetworkCreatedUpdate = "" + if(requeryIdAAIResponse!=null && createNetworkResponse!=null) { + + def l3Network = utils.getNodeXml(requeryIdAAIResponse, "l3-network", false).replace("tag0:","").replace(":tag0","") + def createNetworkContrailResponse = "" + if (utils.nodeExists(createNetworkResponse, 'createNetworkResponse')) { + createNetworkContrailResponse = utils.getNodeXml(createNetworkResponse, "createNetworkResponse", false).replace("tag0:","").replace(":tag0","") + } else { + createNetworkContrailResponse = utils.getNodeXml(createNetworkResponse, "updateNetworkContrailResponse", false).replace("tag0:","").replace(":tag0","") + } + + // rebuild network + def networkList = ["network-id", "network-name", "network-type", "network-role", "network-technology", "neutron-network-id", "is-bound-to-vpn", "service-id", "network-role-instance", "resource-version", "resource-model-uuid", "orchestration-status", "heat-stack-id", "mso-catalog-key", "contrail-network-fqdn", + "physical-network-name", "is-provider-network", "is-shared-network", "is-external-network"] + String rebuildNetworkElements = buildNetworkElements(l3Network, createNetworkContrailResponse, networkList) + + // rebuild 'subnets' + def rebuildSubnetList = "" + if (utils.nodeExists(requeryIdAAIResponse, 'subnet')) { + rebuildSubnetList = buildSubnets(requeryIdAAIResponse, createNetworkResponse) + } + + // rebuild 'segmentation-assignments' + def rebuildSegmentationAssignments = "" + if (utils.nodeExists(requeryIdAAIResponse, 'segmentation-assignments')) { + List elementList = ["segmentation-id"] + rebuildSegmentationAssignments = buildXMLElements(requeryIdAAIResponse, "", "segmentation-assignments", elementList) + } + + // rebuild 'ctag-assignments' / rebuildCtagAssignments + def rebuildCtagAssignmentsList = "" + if (utils.nodeExists(requeryIdAAIResponse, 'ctag-assignment')) { + rebuildCtagAssignmentsList = rebuildCtagAssignments(requeryIdAAIResponse) + } + + // rebuild 'relationship' + def relationshipList = "" + if (utils.nodeExists(requeryIdAAIResponse, 'relationship-list')) { + String rootRelationshipData = getFirstNodeXml(requeryIdAAIResponse, "relationship-list").drop(38).trim().replace("tag0:","").replace(":tag0","") + if (utils.nodeExists(rootRelationshipData, 'relationship')) { + relationshipList = rebuildRelationship(rootRelationshipData) + } + } + + //Check for optional contrail network fqdn within CreateNetworkResponse + String contrailNetworkFQDN + if(utils.nodeExists(createNetworkResponse, "contrail-network-fqdn")){ + contrailNetworkFQDN = utils.getNodeXml(createNetworkResponse, "contrail-network-fqdn") + contrailNetworkFQDN = utils.removeXmlNamespaces(contrailNetworkFQDN) + contrailNetworkFQDN = utils.removeXmlPreamble(contrailNetworkFQDN) + }else{ + contrailNetworkFQDN = "" + } + + contrailNetworkCreatedUpdate = + """<l3-network xmlns="${schemaVersion}"> + ${rebuildNetworkElements} + ${rebuildSubnetList} + ${rebuildSegmentationAssignments} + ${rebuildCtagAssignmentsList} + ${relationshipList} + ${contrailNetworkFQDN} + </l3-network>""".trim() + + } + return contrailNetworkCreatedUpdate + } + + + + /** + * This method returns the value for the name paramName. + * Ex: <network-params> + * <param name="shared">1</param> + * <param name="external">0</external> + * </network-params> + * + * @param xmlInput the XML document + * @param paramName the param name (ex: 'shared') + * @return a param value for 'shared' (ex: '1') + */ + def getParameterValue(xmlInput, paramName) { + def rtn="" + if(xmlInput!=null){ + def xml= new XmlSlurper().parseText(xmlInput) + rtn= xml.'**'.find {param->param.'@name'.text() == paramName} + } + if (rtn==null) { + return "" + } else { + return rtn + } + } + + /** + * This method returns the name of param if found/match with paramName. + * Ex: <network-params> + * <param name="shared">1</param> + * <param name="external">0</external> + * </network-params> + * + * @param xmlInput the XML document + * @param paramName the param name (ex: 'shared', ) + * @return a param name for 'shared' (ex: 'shared' if found) + */ + def getParameterName(xmlInput, paramName) { + def rtn="" + if(xmlInput!=null){ + def xml= new XmlSlurper().parseText(xmlInput) + try { + rtn= xml.'**'.find {param->param.'@name' == paramName}.'@name' + } catch (Exception ex) { + rtn="" + } + } + if (rtn==null || rtn=="") { + return "" + } else { + return rtn + } + } + + /** + * This method returns the networkParams xml string. + * Ex: input: + * <network-params> + * <param name="shared">1</param> + * <param name="external">0</external> + * </network-params> + * + * Sample result: + * <networkParams> + * <shared>1</shared> + * <external>0</external> + * </networkParams> + * + */ + + def buildParams(networkParams) { + def build = "" + def netParams = new XmlParser().parseText(networkParams) + try { + def paramsList = netParams.'**'.findAll {param->param.'@name'}.'@name' + if (paramsList.size() > 0) { + build += "<networkParams>" + for (i in 0..paramsList.size()-1) { + def name = netParams.'**'.find {param->param.'@name' == paramsList[i]}.'@name' + def value= netParams.'**'.find {param->param.'@name' == paramsList[i]}.text() + build += "<${name}>${value}</${name}>" + } + build += "</networkParams>" + } + + } catch (Exception ex) { + println ' buildParams error - ' + ex.getMessage() + build = "" + } + return build + } + + def getVlans(xmlInput) { + def rtn = "" + if (xmlInput!=null) { + def vlansList = getListWithElements(xmlInput, 'vlans') + def vlansListSize = vlansList.size() + if (vlansListSize > 0) { + for (i in 0..vlansListSize-1) { + rtn += '<vlans>'+vlansList[i]+'</vlans>' + } + } + } + return rtn + + + } + + /** + * This method returns the uri value for the vpn bindings. + * Return the a list of value of vpn binding in the <related-link> string. + * Ex. + * <relationship-list> + * <relationship> + * <related-to>vpn-binding</related-to> + * <related-link>https://aai-app-e2e.test.openecomp.com:8443/aai/v6/network/vpn-bindings/vpn-binding/85f015d0-2e32-4c30-96d2-87a1a27f8017/</related-link> + * <relationship-data> + * <relationship-key>vpn-binding.vpn-id</relationship-key> + * <relationship-value>85f015d0-2e32-4c30-96d2-87a1a27f8017</relationship-value> + * </relationship-data> + * </relationship> + * <relationship> + * <related-to>vpn-binding</related-to> + * <related-link>https://aai-ext1.test.openecomp.com:8443/aai/v6/network/vpn-bindings/vpn-binding/24a4b507-853a-4a38-99aa-05fcc54be24d/</related-link> + * <relationship-data> + * <relationship-key>vpn-binding.vpn-id</relationship-key> + * <relationship-value>24a4b507-853a-4a38-99aa-05fcc54be24d</relationship-value> + * </relationship-data> + * <related-to-property> + * <property-key>vpn-binding.vpn-name</property-key> + * <property-value>oam_protected_net_6_MTN5_msotest1</property-value> + * </related-to-property> + * </relationship> + * @param xmlInput the XML document + * @return a list of vpn binding values + * ex: ['aai/v6/network/vpn-bindings/vpn-binding/85f015d0-2e32-4c30-96d2-87a1a27f8017/', 'aai/v6/network/vpn-bindings/vpn-binding/c980a6ef-3b88-49f0-9751-dbad8608d0a6/'] + * + **/ + def getVnfBindingObject(xmlInput) { + //def rtn = null + List rtn = [] + if (xmlInput!=null) { + def relationshipList = getListWithElements(xmlInput, 'relationship') + def relationshipListSize = relationshipList.size() + if (relationshipListSize > 0) { + for (i in 0..relationshipListSize-1) { + def relationshipXml = XmlUtil.serialize(relationshipList[i]) + if (utils.getNodeText(relationshipXml, 'related-to') == "vpn-binding") { + def relatedLink = utils.getNodeText(relationshipXml, 'related-link') + if (relatedLink != null || relatedLink != "") { + rtn.add(relatedLink.substring(relatedLink.indexOf("/aai/"), relatedLink.length())) + } + } + } + } + } + return rtn + } + /** + * similar to VNF bindings method + * @param xmlInput the XML document + * @return a list of network policy values + * ex: ['aai/v$/network/network-policies/network-policy/cee6d136-e378-4678-a024-2cd15f0ee0cg', 'aai/v$/network/network-policies/network-policy/cee6d136-e378-4678-a024-2cd15f0ee0cg'] + * + **/ + def getNetworkPolicyObject(xmlInput) { + //def rtn = null + List rtn = [] + if (xmlInput!=null) { + def relationshipList = getListWithElements(xmlInput, 'relationship') + def relationshipListSize = relationshipList.size() + if (relationshipListSize > 0) { + for (i in 0..relationshipListSize-1) { + def relationshipXml = XmlUtil.serialize(relationshipList[i]) + if (utils.getNodeText(relationshipXml, 'related-to') == "network-policy") { + def relatedLink = utils.getNodeText(relationshipXml, 'related-link') + if (relatedLink != null || relatedLink != "") { + rtn.add(relatedLink.substring(relatedLink.indexOf("/aai/"), relatedLink.length())) + } + } + } + } + } + return rtn + } + + /** + * similar to network policymethod + * @param xmlInput the XML document + * @return a list of network policy values + * ex: ['aai/v$/network/route-table-references/route-table-reference/refFQDN1', 'aai/v$/network/route-table-references/route-table-reference/refFQDN2'] + * + **/ + def getNetworkTableRefObject(xmlInput) { + //def rtn = null + List rtn = [] + if (xmlInput!=null) { + def relationshipList = getListWithElements(xmlInput, 'relationship') + def relationshipListSize = relationshipList.size() + if (relationshipListSize > 0) { + for (i in 0..relationshipListSize-1) { + def relationshipXml = XmlUtil.serialize(relationshipList[i]) + if (utils.getNodeText(relationshipXml, 'related-to') == "route-table-reference") { + def relatedLink = utils.getNodeText1(relationshipXml, 'related-link') + if (relatedLink != null || relatedLink != "") { + rtn.add(relatedLink.substring(relatedLink.indexOf("/aai/"), relatedLink.length())) + } + } + } + } + } + return rtn + } + + /** + * similar to network policymethod + * @param xmlInput the XML document + * @return a list of IDs for related VNF instances + * + **/ + def getRelatedVnfIdList(xmlInput) { + //def rtn = null + List rtn = [] + if (xmlInput!=null) { + def relationshipList = getListWithElements(xmlInput, 'relationship') + def relationshipListSize = relationshipList.size() + if (relationshipListSize > 0) { + for (i in 0..relationshipListSize-1) { + def relationshipXml = XmlUtil.serialize(relationshipList[i]) + if (utils.getNodeText(relationshipXml, 'related-to') == "generic-vnf") { + def relatedLink = utils.getNodeText1(relationshipXml, 'related-link') + if (relatedLink != null || relatedLink != "") { + rtn.add(relatedLink.substring(relatedLink.indexOf("/generic-vnf/")+13, relatedLink.length())) + } + } + } + } + } + return rtn + } + + /** + * similar to network policymethod + * @param xmlInput the XML document + * @return a list of IDs for related Network instances + * + **/ + def getRelatedNetworkIdList(xmlInput) { + //def rtn = null + List rtn = [] + if (xmlInput!=null) { + def relationshipList = getListWithElements(xmlInput, 'relationship') + def relationshipListSize = relationshipList.size() + if (relationshipListSize > 0) { + for (i in 0..relationshipListSize-1) { + def relationshipXml = XmlUtil.serialize(relationshipList[i]) + if (utils.getNodeText(relationshipXml, 'related-to') == "l3-network") { + def relatedLink = utils.getNodeText1(relationshipXml, 'related-link') + if (relatedLink != null || relatedLink != "") { + rtn.add(relatedLink.substring(relatedLink.indexOf("/l3-network/")+12, relatedLink.length())) + } + } + } + } + } + return rtn + } + + def isVfRelationshipExist(xmlInput) { + Boolean rtn = false + if (xmlInput!=null) { + def relationshipList = getListWithElements(xmlInput, 'relationship') + def relationshipListSize = relationshipList.size() + if (relationshipListSize > 0) { + for (i in 0..relationshipListSize-1) { + def relationshipXml = XmlUtil.serialize(relationshipList[i]) + if (utils.getNodeText(relationshipXml, 'related-to') == "vf-module") { + rtn = true + } + } + } + } + return rtn + + } + + def getCloudRegion(xmlInput) { + String lcpCloudRegion = "" + if (xmlInput!=null) { + def relationshipList = getListWithElements(xmlInput, 'relationship') + def relationshipListSize = relationshipList.size() + if (relationshipListSize > 0) { + for (i in 0..relationshipListSize-1) { + def relationshipXml = XmlUtil.serialize(relationshipList[i]) + if (utils.getNodeText(relationshipXml, 'related-to') == "cloud-region") { + def relatedLink = utils.getNodeText1(relationshipXml, 'related-link') + if (relatedLink != null || relatedLink != "") { + lcpCloudRegion = relatedLink.substring(relatedLink.indexOf("/openecomp-aic/")+9, relatedLink.length()) + if (lcpCloudRegion.contains('/')) { + lcpCloudRegion = relatedLink.substring(relatedLink.indexOf("/openecomp-aic/")+9, relatedLink.length()-1) + } + } + } + } + } + } + return lcpCloudRegion + } + + def getTenantId(xmlInput) { + String tenantId = "" + if (xmlInput!=null) { + def relationshipList = getListWithElements(xmlInput, 'relationship') + def relationshipListSize = relationshipList.size() + if (relationshipListSize > 0) { + for (i in 0..relationshipListSize-1) { + def relationshipXml = XmlUtil.serialize(relationshipList[i]) + if (utils.getNodeText(relationshipXml, 'related-to') == "tenant") { + def relatedLink = utils.getNodeText1(relationshipXml, 'related-link') + if (relatedLink != null || relatedLink != "") { + tenantId = relatedLink.substring(relatedLink.indexOf("/tenant/")+8, relatedLink.length()) + if (tenantId.contains('/')) { + tenantId = relatedLink.substring(relatedLink.indexOf("/tenant/")+8, relatedLink.length()-1) + } + } + } + } + } + } + return tenantId + } + + def isInstanceValueMatch(linkResource, globalSubscriberId, serviceType) { + Boolean rtn = false + try { + String globalSubscriberIdLink = linkResource.substring(linkResource.indexOf("/customer/")+10, linkResource.indexOf("/service-subscriptions")) + String serviceTypeLink = linkResource.substring(linkResource.indexOf("/service-subscription/")+22, linkResource.indexOf("/service-instances")) + if (globalSubscriberIdLink == globalSubscriberId) { + rtn = true + } else { + if (serviceTypeLink == serviceType) { + rtn = true + } + } + + } catch (Exception ex) { + println 'Exception - ' + ex.getMessage() + return false + } + return rtn + } + + def getListWithElements(xmlInput, groupName) { + def rtn = "" + if (xmlInput != null) { + def relationshipData = new XmlSlurper().parseText(xmlInput) + rtn = relationshipData.'**'.findAll {it.name() == groupName} + } + return rtn + + } + + // build network single elements + def buildNetworkElements(l3Network, createNetworkContrailResponse, networkList) { + def replaceNetworkId = "" + def replaceNeutronNetworkId = "" + def replaceContrailNetworkFqdn = "" + if (l3Network != null && createNetworkContrailResponse != null) { + if (utils.nodeExists(l3Network, 'heat-stack-id')) { + replaceNetworkId = utils.getNodeText(l3Network, 'heat-stack-id') + } else { + if (utils.nodeExists(createNetworkContrailResponse, 'networkStackId')) { + replaceNetworkId = utils.getNodeText(createNetworkContrailResponse, 'networkStackId') + } + } + if (utils.nodeExists(l3Network, 'neutron-network-id')) { + replaceNeutronNetworkId = utils.getNodeText(l3Network, 'neutron-network-id') + } else { + if (utils.nodeExists(createNetworkContrailResponse, 'neutronNetworkId')) { + replaceNeutronNetworkId = utils.getNodeText(createNetworkContrailResponse, 'neutronNetworkId') + } + } + if (utils.nodeExists(l3Network, 'contrail-network-fqdn')) { + replaceContrailNetworkFqdn = utils.getNodeText(l3Network, 'contrail-network-fqdn') + } else { + if (utils.nodeExists(createNetworkContrailResponse, 'networkFqdn')) { + replaceContrailNetworkFqdn = utils.getNodeText(createNetworkContrailResponse, 'networkFqdn') + } + } + } + + String var = "" + def xmlNetwork = "" + if (l3Network != null) { + for (element in networkList) { + def xml= new XmlSlurper().parseText(l3Network) + var = xml.'**'.find {it.name() == element} + if (var == null) { + if (element=="orchestration-status") { + xmlNetwork += "<"+element+">"+"active"+"</"+element+">" + } + if (element=="heat-stack-id") { + if (replaceNetworkId != "") { + xmlNetwork += "<"+element+">"+replaceNetworkId+"</"+element+">" + } + } + if (element=="neutron-network-id") { + if (replaceNeutronNetworkId != "") { + xmlNetwork += "<"+element+">"+replaceNeutronNetworkId+"</"+element+">" + } + } + if (element=="contrail-network-fqdn") { + if (replaceContrailNetworkFqdn != "") { + xmlNetwork += "<"+element+">"+replaceContrailNetworkFqdn+"</"+element+">" + } + } + + } else { + if (element=="orchestration-status") { + xmlNetwork += "<"+element+">"+"active"+"</"+element+">" + } else { + xmlNetwork += "<"+element+">"+var.toString()+"</"+element+">" + } + } + + } + } + return xmlNetwork + } + + def buildSubnets(requeryIdAAIResponse, createNetworkResponse) { + def rebuildingSubnets = "" + if (requeryIdAAIResponse != null && utils.nodeExists(requeryIdAAIResponse, 'subnets')) { + def subnetIdMapValue = "" + def subnetsGroup = utils.getNodeXml(requeryIdAAIResponse, "subnets", false) + def subnetsData = new XmlSlurper().parseText(subnetsGroup) + rebuildingSubnets += "<subnets>" + try { + def subnets = subnetsData.'**'.findAll {it.name() == "subnet"} + def subnetsSize = subnets.size() + for (i in 0..subnetsSize-1) { + def subnet = subnets[i] + def subnetXml = XmlUtil.serialize(subnet) + def subnetList = ["subnet-id", "neutron-subnet-id", "gateway-address", "network-start-address", "cidr-mask", "ip-version", "orchestration-status", "dhcp-enabled", "dhcp-start", "dhcp-end", "resource-version", "subnet-name"] + rebuildingSubnets += buildSubNetworkElements(subnetXml, createNetworkResponse, subnetList, "subnet") + } + if (utils.nodeExists(subnetsData, 'relationship')) { + rebuildingSubnets = rebuildRelationship(requeryIdAAIResponse) + } + + } catch (Exception ex) { + // error + } finally { + rebuildingSubnets += "</subnets>" + } + } + return rebuildingSubnets + } + + def buildSubnets(queryIdResponse) { + def rebuildingSubnets = "" + def subnetsData = new XmlSlurper().parseText(queryIdResponse) + //rebuildingSubnets += "<subnets>" + try { + def subnets = subnetsData.'**'.findAll {it.name() == "subnet"} + def subnetsSize = subnets.size() + for (i in 0..subnetsSize-1) { + def subnet = subnets[i] + def subnetXml = XmlUtil.serialize(subnet) + def subnetList = ["dhcp-start", "dhcp-end", "network-start-address", "cidr-mask", "dhcp-enabled", "gateway-address", "ip-version", "subnet-id", "subnet-name"] + rebuildingSubnets += buildSubNetworkElements(subnetXml, subnetList, "subnets") + //rebuildingSubnets += buildSubNetworkElements(subnetXml, subnetList, "") + } + } catch (Exception ex) { + // + } finally { + //rebuildingSubnets += "</subnets>" + } + return rebuildingSubnets + } + + + // build subnet sub-network single elements + def buildSubNetworkElements(subnetXml, createNetworkResponse, elementList, parentName) { + String var = "" + def xmlBuild = "" + if (parentName != "") { + xmlBuild += "<"+parentName+">" + } + if (subnetXml != null) { + for (element in elementList) { + def xml= new XmlSlurper().parseText(subnetXml) + var = xml.'**'.find {it.name() == element} + if (var != null) { + if (element=="orchestration-status") { + xmlBuild += "<"+element+">"+"active"+"</"+element+">" + } else { // "subnet-id", "neutron-subnet-id" + if (element=="subnet-id") { + if (utils.nodeExists(createNetworkResponse, "subnetMap")) { + xmlBuild += "<"+element+">"+var.toString()+"</"+element+">" + String neutronSubnetId = extractNeutSubId(createNetworkResponse, var.toString()) + xmlBuild += "<neutron-subnet-id>"+neutronSubnetId+"</neutron-subnet-id>" + } + } else { + if (element=="neutron-subnet-id") { + // skip + } else { + xmlBuild += "<"+element+">"+var.toString()+"</"+element+">" + } + } + } + } + } + + } + if (parentName != "") { + xmlBuild += "</"+parentName+">" + } + return xmlBuild + } + + // build subnet sub-network single elements + def buildSubNetworkElements(subnetXml, elementList, parentName) { + def var = "" + def xmlBuild = "" + if (parentName != "") { + xmlBuild += "<"+parentName+">" + } + if (subnetXml != null) { + def networkStartAddress = "" + for (element in elementList) { + def xml= new XmlSlurper().parseText(subnetXml) + var = xml.'**'.find {it.name() == element} + if (element == "dhcp-start") { + xmlBuild += "<allocationPools>" + if (var.toString() == 'null') { + xmlBuild += "<start>"+""+"</start>" + } else { + xmlBuild += "<start>"+var.toString()+"</start>" + } + } + if (element == "dhcp-end") { + if (var.toString() == 'null') { + xmlBuild += "<end>"+""+"</end>" + } else { + xmlBuild += "<end>"+var.toString()+"</end>" + } + xmlBuild += "</allocationPools>" + } + if (element == "network-start-address" || element == "cidr-mask") { + if (element == "network-start-address") { + networkStartAddress = var.toString() + } + if (element == "cidr-mask") { + xmlBuild += "<cidr>"+networkStartAddress+"/"+var.toString()+"</cidr>" + } + } + if (element == "dhcp-enabled") { + xmlBuild += "<enableDHCP>"+var.toString()+"</enableDHCP>" + } + if (element == "gateway-address") { + xmlBuild += "<gatewayIp>"+var.toString()+"</gatewayIp>" + } + if (element == "ip-version") { + xmlBuild += "<ipVersion>"+var.toString()+"</ipVersion>" + } + if (element == "subnet-id") { + xmlBuild += "<subnetId>"+var.toString()+"</subnetId>" + } + if ((element == "subnet-name") && (var != null)) { + xmlBuild += "<subnetName>"+var.toString()+"</subnetName>" + } + } + } + if (parentName != "") { + xmlBuild += "</"+parentName+">" + } + return xmlBuild + } + + // rebuild ctag-assignments + def rebuildCtagAssignments(xmlInput) { + def rebuildingCtagAssignments = "" + if (xmlInput!=null) { + def ctagAssignmentsData = new XmlSlurper().parseText(xmlInput) + rebuildingCtagAssignments += "<ctag-assignments>" + def ctagAssignments = ctagAssignmentsData.'**'.findAll {it.name() == "ctag-assignment"} + def ctagAssignmentsSize = ctagAssignments.size() + for (i in 0..ctagAssignmentsSize-1) { + def ctagAssignment = ctagAssignments[i] + def ctagAssignmentXml = XmlUtil.serialize(ctagAssignment) + rebuildingCtagAssignments += "<ctag-assignment>" + List elementList = ["vlan-id-inner", "resource-version"] + rebuildingCtagAssignments += buildXMLElements(ctagAssignmentXml, "" , "", elementList) + if (utils.nodeExists(ctagAssignmentXml, 'relationship')) { + rebuildingCtagAssignments += rebuildRelationship(ctagAssignmentXml) + } + rebuildingCtagAssignments += "</ctag-assignment>" + } + rebuildingCtagAssignments += "</ctag-assignments>" + } + return rebuildingCtagAssignments + } + + // rebuild 'relationship-list' + def rebuildRelationship(xmlInput) { + def rebuildingSubnets = "" + if (xmlInput!=null) { + def subnetsData = new XmlSlurper().parseText(xmlInput) + rebuildingSubnets += "<relationship-list>" + def relationships = subnetsData.'**'.findAll {it.name() == "relationship"} + def relationshipsSize = relationships.size() + for (i in 0..relationshipsSize-1) { + def relationship = relationships[i] + def relationshipXml = XmlUtil.serialize(relationship) + rebuildingSubnets += "<relationship>" + def relationshipList = ["related-to", "related-link"] + rebuildingSubnets += buildSubNetworkElements(relationshipXml, "", relationshipList, "") + if (utils.nodeExists(relationshipXml, 'relationship-data')) { + def relationshipDataXmlData = new XmlSlurper().parseText(relationshipXml) + def relationshipsData = relationshipDataXmlData.'**'.findAll {it.name() == "relationship-data"} + def relationshipsDataSize = relationshipsData.size() + for (j in 0..relationshipsDataSize-1) { + def relationshipData = relationshipsData[j] + def relationshipDataXml = XmlUtil.serialize(relationshipData) + def relationshipDataList = ["relationship-key", "relationship-value"] + rebuildingSubnets += buildXMLElements(relationshipDataXml, "", "relationship-data", relationshipDataList) + } + } + if (utils.nodeExists(relationshipXml, 'related-to-property')) { + def relationshipDataXmlData = new XmlSlurper().parseText(relationshipXml) + def relationshipsData = relationshipDataXmlData.'**'.findAll {it.name() == "related-to-property"} + def relationshipsDataSize = relationshipsData.size() + for (j in 0..relationshipsDataSize-1) { + def relationshipData = relationshipsData[j] + def relationshipDataXml = XmlUtil.serialize(relationshipData) + def relationshipDataList = ["property-key", "property-value"] + rebuildingSubnets += buildXMLElements(relationshipDataXml, "", "related-to-property", relationshipDataList) + } + } + + rebuildingSubnets += "</relationship>" + } + rebuildingSubnets += "</relationship-list>" + } + return rebuildingSubnets + } + + def buildVlans(queryIdResponse) { + def rebuildingSubnets = "<vlans>" + def subnetsData = new XmlSlurper().parseText(queryIdResponse) + + try { + def subnets = subnetsData.'**'.findAll {it.name() == "segmentation-assignments"} + def subnetsSize = subnets.size() + for (i in 0..subnetsSize-1) { + def subnet = subnets[i] + def subnetXml = XmlUtil.serialize(subnet) + + String vlan = utils.getNodeText1(subnetXml, "segmentation-id") + if (i>0){ + rebuildingSubnets += "," + } + rebuildingSubnets += vlan + } + } catch (Exception ex) { + // + } finally { + //rebuildingSubnets += "</subnets>" + rebuildingSubnets += "</vlans>" + } + return rebuildingSubnets + } + + /* Utility code to rebuild xml/elements in a list: + * rebuild xml with 1) unbounded groups of elements; or + * 2) one group of elements; or + * 3) just one or more elements (in a list as argument) + * @param xmlInput the XML document + * @param parentName the parent name (ex: 'inputs') + * @param childrenName the chilrendName (ex: 'entry' as unbounded/occurs>1) + * @param elementList the element list of children (ex: 'key', 'value') + * @return a string of rebuild xml + * + * Ex 1: xmlInput: + * <ws:inputs> + * <ws:entry> + * <ws:key>name</ws:key> + * <ws:value>Edward</ws:value> + * </ws:entry> + * <ws:entry> + * <ws:key>age</ws:key> + * <ws:value>30</ws:value> + * </ws:entry> + * <ws:entry> + * <ws:key>age</ws:key> + * <ws:value>30</ws:value> + * </ws:entry> + * <ws:/inputs> + * Usage: + * List elementList = ["key", "value"] + * String rebuild = buildXMLElements(xmlInput, "inputs", "entry", elementList) + * + * Ex 2: xmlInput // no parent tag + * <ws:sdnc-request-header> + * <ws:svc-request-id>fec8ec88-151a-45c9-ad60-8233e0fc8ff2</ws:svc-request-id> + * <ws:svc-notification-url>https://msojra.mtsnj.aic.cip.openecomp.com:8443/adapters/rest/SDNCNotify</ws:svc-notification-url> + * <ws:svc-action>assign</ws:svc-action> + * </ws:sdnc-request-header> + * Usage: + * List elementList = ["svc-request-id", "svc-notification-url", "svc-action"] + * String rebuild = buildXMLElements(xmlInput, "" , "sdnc-request-header", elementList) // no parent tag + * + * Ex 3: xmlInput // elements one after another (with no parent & children tag) + * <ws:test-id>myTestid</ws:test-id> + * <ws:test-user>myUser</ws:test-user> + * Usage: + * List elementList = ["test-id", "test-user"] + * String rebuild = buildXMLElements(xmlInput, "" , "", elementList) + * + */ + def buildXMLElements(xmlInput, parentName, childrenName, elementList) { + def varChildren = "" + def var = "" + def xmlBuildUnbounded = "" + if (parentName!="") {xmlBuildUnbounded += "<"+parentName+">" +'\n'} + if (xmlInput != null) { + def xml= new XmlSlurper().parseText(xmlInput) + if (childrenName!="") { + varChildren = xml.'**'.findAll {it.name() == childrenName} + for (i in 0..varChildren.size()-1) { + xmlBuildUnbounded += "<"+childrenName+">" +'\n' + for (element in elementList) { + var = varChildren[i].'*'.find {it.name() == element} + if (var != null) { + xmlBuildUnbounded += "<"+element+">"+var.toString()+"</"+element+">" +'\n' + } + } + xmlBuildUnbounded += "</"+childrenName+">" +'\n' + } + } else { + for (element in elementList) { + var = xml.'*'.find {it.name() == element} + if (var != null) { + xmlBuildUnbounded += "<"+element+">"+var.toString()+"</"+element+">" +'\n' + } + } + } + + } + if (parentName!="") {xmlBuildUnbounded += "</"+parentName+">" +'\n'} + return xmlBuildUnbounded + } + + def getFirstNodeXml(xmlInput, element){ + def nodeAsText = "" + def nodeToSerialize = "" + if (xmlInput != null) { + def fxml= new XmlSlurper().parseText(xmlInput) + if (utils.nodeExists(xmlInput, "payload")) { + nodeToSerialize = fxml.'payload'.'l3-network'.'*'.find {it.name() == element} + if (nodeToSerialize!=null) { + nodeAsText = XmlUtil.serialize(nodeToSerialize) + } else { + nodeAsText = "" + } + + } else { + nodeToSerialize = fxml.'*'.find {it.name() == element} + if (nodeToSerialize!=null) { + nodeAsText = XmlUtil.serialize(nodeToSerialize) + } else { + nodeAsText = "" + } + + } + } + return nodeAsText + + } + +//TODO: This method still needs to be tested before using. + /** + * + * This method is similar to the gennetwork:ContrailNetworUpdateCompletedObject + * BPEL method. It extracts all of the required subnet information + * for each subnet listed with an orch status equal to the one provided + * and puts the corresponding infomation with the appropriate node for + * updating aai. The method sets the orch status for each subnet to active + * + * @param subnetsXml the entire subnets xml + * @param requestInput the request in the process + * @param queryIdResponse the response of REST AAI query by Id + * @param queryVpnBindingResponse the response of REST AAI query by vpn binding + * @param routeCollection the collection of vpnBinding's 'global-route-target' + * @return String request + */ + public String networkUpdateSubnetInfo(String subnetsXml, String networkResponseXml){ + + String subnets = "" + StringBuilder sb = new StringBuilder() + InputSource source = new InputSource(new StringReader(subnetsXml)); + DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); + docFactory.setNamespaceAware(true) + DocumentBuilder docBuilder = docFactory.newDocumentBuilder() + Document xml = docBuilder.parse(source) + NodeList nodeList = xml.getElementsByTagNameNS("*", "subnet") + for (int x = 0; x < nodeList.getLength(); x++) { + Node node = nodeList.item(x) + String subnet = "" + if (node.getNodeType() == Node.ELEMENT_NODE) { + Element eElement = (Element) node + String subnetOrchStatus = eElement.getElementsByTagNameNS("*", "orchestration-status").item(0).getTextContent() + if(subnetOrchStatus.equals("pending-create")){ + + String subnetId = eElement.getElementsByTagNameNS("*", "subnet-id").item(0).getTextContent() + def netAddress = eElement.getElementsByTagNameNS("*", "network-start-address").item(0).getTextContent() + def mask = eElement.getElementsByTagNameNS("*", "cidr-mask").item(0).getTextContent() + def dhcpEnabledSubnet = eElement.getElementsByTagNameNS("*", "dhcp-enabled").item(0).getTextContent() + def gatewayAddress = eElement.getElementsByTagNameNS("*", "gateway-address").item(0).getTextContent() + def ipVersion = eElement.getElementsByTagNameNS("*", "ip-version").item(0).getTextContent() + def relationshipList = eElement.getElementsByTagNameNS("*", "relationship-list").item(0).getTextContent() //TODO: test this + String neutronSubnetId = extractNeutSubId(networkResponseXml, subnetId) + subnet = + """<subnet> + <subnetId>${subnetId}</subnetId> + <neutron-subnet-id>${neutronSubnetId}</neutron-subnet-id> + <gateway-address>${gatewayAddress}</gateway-address> + <network-start-address>${netAddress}</network-start-address> + <cidr-mask>${mask}</cidr-mask> + <ip-Version>${ipVersion}</ip-Version> + <orchestration-status>active</orchestration-status> + <dhcp-enabled>${dhcpEnabledSubnet}</dhcp-enabled> + <relationship-list>${relationshipList}</relationship-list> + </subnet>""" + + }else if(subnetOrchStatus.equals("pending-delete")){ + StringWriter writer = new StringWriter() + Transformer transformer = TransformerFactory.newInstance().newTransformer() + transformer.transform(new DOMSource(node), new StreamResult(writer)) + subnet = writer.toString() + + }else{ + subnet = "" + } + } + subnets = sb.append(subnet) + } + + subnets = utils.removeXmlPreamble(subnets) + + String subnetsList = + """<subnets> + ${subnets} + </subnets>""" + + return subnetsList + } + + + /** + * + * This method extracts the "value" node text for the the given subnet Id. + * + * @param String inputSource - xml that contains the subnet id key and value + * @param String subnetId - for which you want the value of + + * @return String value - node text of node named value associated with the given subnet id + */ + public String extractNeutSubId(String inputSource, String subnetId){ + + String value = "" + InputSource source = new InputSource(new StringReader(inputSource)); + DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); + docFactory.setNamespaceAware(true) + DocumentBuilder docBuilder = docFactory.newDocumentBuilder() + Document xml = docBuilder.parse(source) + NodeList nodeList = xml.getElementsByTagNameNS("*", "entry") + for (int x = 0; x < nodeList.getLength(); x++) { + Node node = nodeList.item(x) + String subnet = "" + if (node.getNodeType() == Node.ELEMENT_NODE) { + Element eElement = (Element) node + String key = eElement.getElementsByTagNameNS("*", "key").item(0).getTextContent() + if(key.equals(subnetId)){ + value = eElement.getElementsByTagNameNS("*", "value").item(0).getTextContent() + } + } + } + return value + } + + public boolean isRollbackEnabled (Execution execution, String payloadXml) { + + def rollbackEnabled = false + def rollbackValueSet = false + if (utils.nodeExists(payloadXml, "backout-on-failure")) { + String backoutValue = utils.getNodeText1(payloadXml, "backout-on-failure") + if (backoutValue != null && !backoutValue.isEmpty()) { + if (backoutValue.equalsIgnoreCase("false")) { + rollbackEnabled = false + } + else { + rollbackEnabled = true + } + rollbackValueSet = true; + } + } + + if (!rollbackValueSet) { + if (execution.getVariable("URN_mso_rollback") != null) { + rollbackEnabled = execution.getVariable("URN_mso_rollback").toBoolean() + } + } + return rollbackEnabled + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/PrepareUpdateAAIVfModule.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/PrepareUpdateAAIVfModule.groovy new file mode 100644 index 0000000000..e64fda6356 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/PrepareUpdateAAIVfModule.groovy @@ -0,0 +1,368 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common.scripts + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.runtime.Execution +import org.openecomp.mso.bpmn.core.WorkflowException +import org.openecomp.mso.rest.APIResponse +import org.openecomp.mso.rest.RESTClient +import org.openecomp.mso.rest.RESTConfig +import org.springframework.web.util.UriUtils + +public class PrepareUpdateAAIVfModule extends VfModuleBase { + + /** + * Initialize the flow's variables. + * + * @param execution The flow's execution instance. + */ + public void initProcessVariables(Execution execution) { + execution.setVariable('prefix', 'PUAAIVfMod_') + execution.setVariable('PUAAIVfMod_vnfId', null) + execution.setVariable('PUAAIVfMod_vfModuleId', null) + execution.setVariable('PUAAIVfMod_vnfName', null) + execution.setVariable('PUAAIVfMod_orchestrationStatus', null) + execution.setVariable('PUAAIVfMod_vfModule', null) + execution.setVariable('PUAAIVfMod_vfModuleOK', false) + execution.setVariable('PUAAIVfMod_vfModuleValidationError', null) + execution.setVariable('PUAAIVfMod_getVnfResponseCode' ,null) + execution.setVariable('PUAAIVfMod_getVnfResponse', '') + execution.setVariable('PUAAIVfMod_updateVfModuleResponseCode', null) + execution.setVariable('PUAAIVfMod_updateVfModuleResponse', '') + execution.setVariable('PUAAIVfMod_outVfModule', null) + } + + /** + * Check for missing elements in the received request. + * + * @param execution The flow's execution instance. + */ + public void preProcessRequest(Execution execution) { + def method = getClass().getSimpleName() + '.preProcessRequest(' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logDebug('Entered ' + method, isDebugLogEnabled) + + try { + def xml = execution.getVariable('PrepareUpdateAAIVfModuleRequest') + logDebug('Received request xml:\n' + xml, isDebugLogEnabled) + utils.logAudit("PrepareUpdateAAIVfModule Request : " + xml) + + initProcessVariables(execution) + + def vnfId = getRequiredNodeText(execution, xml,'vnf-id') + execution.setVariable('PUAAIVfMod_vnfId', vnfId) + + def vfModuleId = getRequiredNodeText(execution, xml,'vf-module-id') + execution.setVariable('PUAAIVfMod_vfModuleId', vfModuleId) + + def orchestrationStatus = getRequiredNodeText(execution, xml,'orchestration-status') + execution.setVariable('PUAAIVfMod_orchestrationStatus', orchestrationStatus) + + logDebug('Exited ' + method, isDebugLogEnabled) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + logError('Caught exception in ' + method, e) + createWorkflowException(execution, 1002, 'Error in preProcessRequest(): ' + e.getMessage()) + } + } + + /** + * Using the received vnfId, query AAI to get the corresponding Generic VNF. + * A 200 response is expected with the Generic VNF in the response body. + * + * @param execution The flow's execution instance. + */ + public void getGenericVnf(Execution execution) { + def method = getClass().getSimpleName() + '.getGenericVnf(' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logDebug('Entered ' + method, isDebugLogEnabled) + + try { + def vnfId = execution.getVariable('PUAAIVfMod_vnfId') + + AaiUtil aaiUriUtil = new AaiUtil(this) + def aai_uri = aaiUriUtil.getNetworkGenericVnfUri(execution) + logDebug('AAI URI is: ' + aai_uri, isDebugLogEnabled) + + String endPoint = execution.getVariable("URN_aai_endpoint") + "${aai_uri}/" + UriUtils.encode(vnfId, "UTF-8") + "?depth=1" + + utils.logAudit("PrepareUpdateAAIVfModule: AAI endPoint : " + endPoint) + String basicAuthCred = utils.getBasicAuth(execution.getVariable("URN_aai_auth"),execution.getVariable("URN_mso_msoKey")) + try { + RESTConfig config = new RESTConfig(endPoint); + def responseData = '' + def aaiRequestId = UUID.randomUUID().toString() + RESTClient client = new RESTClient(config). + addHeader('X-TransactionId', aaiRequestId). + addHeader('X-FromAppId', 'MSO'). + addHeader('Content-Type', 'application/xml'). + addHeader('Accept','application/xml'); + if (basicAuthCred != null && !"".equals(basicAuthCred)) { + client.addAuthorizationHeader(basicAuthCred) + } + logDebug('sending GET to AAI endpoint \'' + endPoint + '\'', isDebugLogEnabled) + APIResponse response = client.httpGet() + utils.logAudit("PrepareUpdateAAIVfModule: - invoking httpGet to AAI") + + responseData = response.getResponseBodyAsString() + execution.setVariable('PUAAIVfMod_getVnfResponseCode', response.getStatusCode()) + execution.setVariable('PUAAIVfMod_getVnfResponse', responseData) + + utils.logAudit("PrepareUpdateAAIVfModule: AAI Response : " + responseData) + utils.logAudit("PrepareUpdateAAIVfModule: AAI ResponseCode : " + response.getStatusCode()) + + logDebug('Response code:' + response.getStatusCode(), isDebugLogEnabled) + logDebug('Response:' + System.lineSeparator() + responseData, isDebugLogEnabled) + } catch (Exception ex) { + ex.printStackTrace() + logDebug('Exception occurred while executing AAI GET:' + ex.getMessage(), isDebugLogEnabled) + execution.setVariable('PUAAIVfMod_getVnfResponseCode', 500) + execution.setVariable('PUAAIVfMod_getVnfResponse', 'AAI GET Failed:' + ex.getMessage()) + } + logDebug('Exited ' + method, isDebugLogEnabled) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + logError('Caught exception in ' + method, e) + createWorkflowException(execution, 1002, 'Error in getGenericVnf(): ' + e.getMessage()) + } + } + + /** + * Validate the VF Module. That is, confirm that a VF Module with the input VF Module ID + * exists in the retrieved Generic VNF. Then, check to make sure that if that VF Module + * is the base VF Module and it's not the only VF Module for this Generic VNF, that we're not + * attempting to delete it. + * + * @param execution The flow's execution instance. + */ + public void validateVfModule(Execution execution) { + def method = getClass().getSimpleName() + '.validateVfModule(' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logDebug('Entered ' + method, isDebugLogEnabled) + + try { + def genericVnf = execution.getVariable('PUAAIVfMod_getVnfResponse') + def vnfId = execution.getVariable('PUAAIVfMod_vnfId') + def vfModuleId = execution.getVariable('PUAAIVfMod_vfModuleId') + def vnfName = getNodeTextForce(genericVnf, 'vnf-name') + execution.setVariable('PUAAIVfMod_vnfName', vnfName) + def VfModule vfModule = findVfModule(genericVnf, vfModuleId) + if (vfModule == null) { + def String msg = 'VF Module \'' + vfModuleId + '\' does not exist in Generic VNF \'' + vnfId + '\'' + execution.setVariable('PUAAIVfMod_vfModuleValidationError', msg) + execution.setVariable('PUAAIVfMod_vfModuleOK', false) + } else { + def orchestrationStatus = execution.getVariable('PUAAIVfMod_orchestrationStatus') + if (isDebugLogEnabled) { + logDebug('VF Module \'' + vfModuleId + '\': isBaseVfModule=' + vfModule.isBaseVfModule() + + ', isOnlyVfModule=' + vfModule.isOnlyVfModule() + ', new orchestration-status=' + orchestrationStatus, + isDebugLogEnabled) + } + if (vfModule.isBaseVfModule() && !vfModule.isOnlyVfModule() && orchestrationStatus.equals('pending-delete')) { + def String msg = 'Orchestration status for VF Module \'' + vfModuleId + + '\' cannot be set to \'pending-delete\' since it is the base VF Module and it\'s not the only VF Module in Generic VNF \'' + vnfId + '\'' + execution.setVariable('PUAAIVfMod_vfModuleValidationError', msg) + execution.setVariable('PUAAIVfMod_vfModuleOK', false) + } else { + execution.setVariable('PUAAIVfMod_vfModule', vfModule) + execution.setVariable('PUAAIVfMod_vfModuleOK', true) + } + } + + logDebug('Exited ' + method, isDebugLogEnabled) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + logError('Caught exception in ' + method, e) + createWorkflowException(execution, 1002, 'Error in validateVfModule(): ' + e.getMessage()) + } + } + + /** + * Construct and send a PUT request to AAI to update the VF Module. + * + * @param execution The flow's execution instance. + */ + public void updateVfModule(Execution execution) { + def method = getClass().getSimpleName() + '.updateVfModule(' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logDebug('Entered ' + method, isDebugLogEnabled) + + try { + // Construct payload + def VfModule vfModule = (VfModule) execution.getVariable('PUAAIVfMod_vfModule') + def Node newVfModuleNode = vfModule.getNode().clone() + def orchestrationStatus = execution.getVariable('PUAAIVfMod_orchestrationStatus') + def Node orchestrationStatusNode = utils.getChildNode(newVfModuleNode, 'orchestration-status') + if (orchestrationStatusNode == null) { + // Node doesn't exist, this should never happen, right? + new Node(newVfModuleNode, 'orchestration-status', orchestrationStatus) + } else { + // Node already exists, just give it a new value + orchestrationStatusNode.setValue(orchestrationStatus) + } + def VfModule newVfModule = new VfModule(newVfModuleNode, vfModule.isOnlyVfModule()) + def payload = utils.nodeToString(newVfModuleNode) + + utils.logAudit("VfModule payload : " + payload) + + // Construct endpoint + def vnfId = execution.getVariable('PUAAIVfMod_vnfId') + def vfModuleId = execution.getVariable('PUAAIVfMod_vfModuleId') + + + AaiUtil aaiUriUtil = new AaiUtil(this) + def aai_uri = aaiUriUtil.getNetworkGenericVnfUri(execution) + logDebug('AAI URI is: ' + aai_uri, isDebugLogEnabled) + + String endPoint = execution.getVariable("URN_aai_endpoint") + "${aai_uri}/" + UriUtils.encode(vnfId, "UTF-8") + "/vf-modules/vf-module/" + UriUtils.encode(vfModuleId, "UTF-8") + utils.logAudit("PrepareUpdateAAIVfModule: AAI endPoint : " + endPoint) + String basicAuthCred = utils.getBasicAuth(execution.getVariable("URN_aai_auth"),execution.getVariable("URN_mso_msoKey")) + try { + RESTConfig config = new RESTConfig(endPoint); + def responseData = '' + def aaiRequestId = UUID.randomUUID().toString() + RESTClient client = new RESTClient(config). + addHeader('X-TransactionId', aaiRequestId). + addHeader('X-FromAppId', 'MSO'). + addHeader('Content-Type', 'application/xml'). + addHeader('Accept','application/xml'); + if (basicAuthCred != null && !"".equals(basicAuthCred)) { + client.addAuthorizationHeader(basicAuthCred) + } + logDebug('sending PUT to AAI endpoint \'' + endPoint + '\'' + 'with payload \n' + payload, isDebugLogEnabled) + APIResponse response = client.httpPut(payload) + utils.logAudit("PrepareUpdateAAIVfModule: - invoking httpPut to AAI") + + responseData = response.getResponseBodyAsString() + execution.setVariable('PUAAIVfMod_updateVfModuleResponseCode', response.getStatusCode()) + execution.setVariable('PUAAIVfMod_updateVfModuleResponse', responseData) + logDebug('Response code:' + response.getStatusCode(), isDebugLogEnabled) + logDebug('Response:' + System.lineSeparator() + responseData, isDebugLogEnabled) + utils.logAudit("PrepareUpdateAAIVfModule: AAI Response : " + responseData) + utils.logAudit("PrepareUpdateAAIVfModule: AAI ResponseCode : " + response.getStatusCode()) + + // Set the output for this flow. The updated VfModule is an output, the generic VNF name, and for + // backward compatibilty, the heat-stack-id is an output + execution.setVariable('PUAAIVfMod_outVfModule', newVfModule) + def vnfName = execution.getVariable('PUAAIVfMod_vnfName') + logDebug('Output PUAAIVfMod_vnfName set to ' + vnfName, isDebugLogEnabled) + // TODO: Should deprecate use of processKey+Response variable for the response. Will use "WorkflowResponse" instead + execution.setVariable('WorkflowResponse', newVfModule) + logDebug('Output PUAAIVfMod_outVfModule set for VF Module Id \'' + newVfModule.getElementText('vf-module-id') + '\'', isDebugLogEnabled) + def heatStackId = newVfModule.getElementText('heat-stack-id') + execution.setVariable('PUAAIVfMod_heatStackId', heatStackId) + logDebug('Output PUAAIVfMod_heatStackId set to \'' + heatStackId + '\'', isDebugLogEnabled) + } catch (Exception ex) { + ex.printStackTrace() + logDebug('Exception occurred while executing AAI PUT:' + ex.getMessage(), isDebugLogEnabled) + execution.setVariable('PUAAIVfMod_updateVfModuleResponseCode', 500) + execution.setVariable('PUAAIVfMod_updateVfModuleResponse', 'AAI PUT Failed:' + ex.getMessage()) + } + logDebug('Exited ' + method, isDebugLogEnabled) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + logError('Caught exception in ' + method, e) + createWorkflowException(execution, 1002, 'Error in updateVfModule(): ' + e.getMessage()) + } + } + + /** + * Generates a WorkflowException if the AAI query returns a response code other than 200. + * + * @param execution The flow's execution instance. + */ + public void handleVnfNotFound(Execution execution) { + def method = getClass().getSimpleName() + '.handleVnfNotFound(' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logDebug('Entered ' + method, isDebugLogEnabled) + + logError('Error occurred attempting to query AAI, Response Code ' + + execution.getVariable('PUAAIVfMod_getVnfResponseCode') + ', Error Response ' + + execution.getVariable('PUAAIVfMod_getVnfResponse')) + String processKey = getProcessKey(execution); + WorkflowException exception = new WorkflowException(processKey, 5000, + execution.getVariable('PUAAIVfMod_getVnfResponse')) + execution.setVariable('WorkflowException', exception) + + logDebug('Exited ' + method, isDebugLogEnabled) + } + + /** + * Generates a WorkflowException if the VF Module does not pass validation. + * + * @param execution The flow's execution instance. + */ + public void handleVfModuleValidationError(Execution execution) { + def method = getClass().getSimpleName() + '.handleVfModuleValidationError(' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logDebug('Entered ' + method, isDebugLogEnabled) + + def String errorMsg = 'VF Module validation error: ' + execution.getVariable('PUAAIVfMod_vfModuleValidationError') + logError(errorMsg) + utils.logAudit("PrepareUpdateAAIVfModule: Error Message : " + errorMsg) + + String processKey = getProcessKey(execution); + WorkflowException exception = new WorkflowException(processKey, 5000, errorMsg) + execution.setVariable('WorkflowException', exception) + + logDebug('Exited ' + method, isDebugLogEnabled) + } + + /** + * Generates a WorkflowException if updating a VF Module in AAI returns a response code other than 200. + * + * @param execution The flow's execution instance. + */ + public void handleUpdateVfModuleFailure(Execution execution) { + def method = getClass().getSimpleName() + '.handleUpdateVfModuleFailure(' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logDebug('Entered ' + method, isDebugLogEnabled) + + logError('Error occurred attempting to update VF Module in AAI, Response Code ' + + execution.getVariable('PUAAIVfMod_updateVfModuleResponseCode') + ', Error Response ' + + execution.getVariable('PUAAIVfMod_updateVfModuleResponse')) + String processKey = getProcessKey(execution); + WorkflowException exception = new WorkflowException(processKey, 5000, + execution.getVariable('PUAAIVfMod_updateVfModuleResponse')) + execution.setVariable('WorkflowException', exception) + + logDebug('Exited ' + method, isDebugLogEnabled) + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/SDNCAdapter.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/SDNCAdapter.groovy new file mode 100644 index 0000000000..d83f46e85f --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/SDNCAdapter.groovy @@ -0,0 +1,326 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common.scripts; + +import java.text.SimpleDateFormat + +import org.camunda.bpm.engine.runtime.Execution +import org.openecomp.mso.bpmn.core.WorkflowException + + +// SDNC Adapter Request/Response processing + +public class SDNCAdapter extends AbstractServiceTaskProcessor { + + def Prefix="SDNCA_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + + // Script Task: Process SDNC Workflow Request + // Params: Workflow Execution + // Assume: Received SDNCAdapterWorkflowRequest is in variable 'sdncAdapterWorkflowRequest' + // Put created SDNCAdapterRequest in variable 'sdncAdapterRequest' + public void preProcessRequest (Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + try{ + + utils.log("DEBUG", "=========== Begin PreProcess SDNCAdapterRequestScript ===========", isDebugEnabled) + utils.log("DEBUG", "Incoming sdncAdapterWorkflowRequest:\n" + execution.getVariable("sdncAdapterWorkflowRequest"), isDebugEnabled) + + // Initialize some variables used throughout the flow + execution.setVariable("prefix", Prefix) + execution.setVariable("sdncAdapterResponse", "") + execution.setVariable("asynchronousResponseTimeout", false) + execution.setVariable("continueListening", false) + execution.setVariable("SDNCA_SuccessIndicator", false) + + // Authorization Info + String basicAuthValue = execution.getVariable("URN_mso_adapters_po_auth") + utils.log("DEBUG", "Obtained BasicAuth userid password for sdnc adapter:" + basicAuthValue, isDebugEnabled) + try { + def encodedString = utils.getBasicAuth(basicAuthValue, execution.getVariable("URN_mso_msoKey")) + execution.setVariable("BasicAuthHeaderValue",encodedString) + } catch (IOException ex) { + utils.log("ERROR", "Unable to encode username password string") + } + + // TODO Use variables instead of passing xml request - Huh? + + // Get original RequestHeader + def sdncwfreq= execution.getVariable("sdncAdapterWorkflowRequest") + def requestHeader = utils.getNodeXml(sdncwfreq, "RequestHeader") + requestHeader = requestHeader.replace("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n", "") + utils.log("DEBUG", "RequestHeader:\n" + requestHeader, isDebugEnabled) + + // Set Callback URL to use from URN Mapping or jBoss Property + def origCallbackUrl = utils.getNodeText(requestHeader, "CallbackUrl") + def callbackUrlToUse = execution.getVariable("URN_mso_workflow_sdncadapter_callback") + MsoUtils msoUtil = new MsoUtils() + def useQualifiedHostName = execution.getVariable("URN_mso_use_qualified_host") + if((useQualifiedHostName!=null) && (useQualifiedHostName.equals("true"))){ + callbackUrlToUse = msoUtil.getQualifiedHostNameForCallback(callbackUrlToUse) + } + utils.log("DEBUG", "Callback URL to use:\n" + callbackUrlToUse, isDebugEnabled) + requestHeader = requestHeader.replace(origCallbackUrl, callbackUrlToUse) + + // Get parameters from request header + def sdnca_svcInstanceId = utils.getNodeText1(requestHeader, "SvcInstanceId") // optional + utils.log("DEBUG", "SvcInstanceId: " + sdnca_svcInstanceId, isDebugEnabled) + def sdnca_msoAction = utils.getNodeText1(requestHeader, "MsoAction") // optional + utils.log("DEBUG", "MsoAction: " + sdnca_msoAction, isDebugEnabled) + def sdnca_svcAction = utils.getNodeText(requestHeader, "SvcAction") + utils.log("DEBUG", "SvcAction: " + sdnca_svcAction, isDebugEnabled) + def sdnca_svcOperation = utils.getNodeText(requestHeader, "SvcOperation") + utils.log("DEBUG", "SvcOperation: " + sdnca_svcOperation, isDebugEnabled) + def sdncRequestData = utils.getChildNodes(sdncwfreq, "SDNCRequestData") + sdncRequestData = sdncRequestData.replace("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n", "") + sdncRequestData = sdncRequestData.replaceAll('tag0:', '').replaceAll(':tag0', '') + utils.log("DEBUG", "SDNCRequestData:\n" + sdncRequestData, isDebugEnabled) + def sdnca_serviceType = "" + if (utils.nodeExists(sdncwfreq, "service-type")) { + sdnca_serviceType = utils.getNodeText(sdncwfreq, "service-type") + } + utils.log("DEBUG", "service-type: " + sdnca_serviceType, isDebugEnabled) + def serviceConfigActivate = false + def source = '' + if ((sdnca_svcAction == 'activate') && (sdnca_svcOperation == 'service-configuration-operation') && (sdnca_serviceType == 'uCPE-VMS')) { + serviceConfigActivate = true + if (utils.nodeExists(sdncwfreq, 'source')) { + source = utils.getNodeText(sdncwfreq, 'source') + } + } + execution.setVariable("serviceConfigActivate", serviceConfigActivate) + utils.log("DEBUG", "serviceConfigActivate: " + serviceConfigActivate, isDebugEnabled) + execution.setVariable("source", source) + utils.log("DEBUG", "source: " + source, isDebugEnabled) + + //calling process should pass a generated uuid if sending multiple sdnc requests + def requestId = utils.getNodeText(requestHeader, "RequestId") + execution.setVariable(Prefix + "requestId", requestId) + + // Prepare SDNC Request to the SDNC Adapter + String sdncAdapterRequest = """ + <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"> + <SOAP-ENV:Body> + <aetgt:SDNCAdapterRequest xmlns:aetgt="http://org.openecomp/workflow/sdnc/adapter/schema/v1" xmlns:sdncadaptersc="http://org.openecomp/workflow/sdnc/adapter/schema/v1"> + <sdncadapter:RequestHeader xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1"> + <sdncadapter:RequestId>${requestId}</sdncadapter:RequestId>""" + + if (sdnca_svcInstanceId != null) { + sdncAdapterRequest += """ + <sdncadapter:SvcInstanceId>${sdnca_svcInstanceId}</sdncadapter:SvcInstanceId>""" + } + + sdncAdapterRequest += """ + <sdncadapter:SvcAction>${sdnca_svcAction}</sdncadapter:SvcAction> + <sdncadapter:SvcOperation>${sdnca_svcOperation}</sdncadapter:SvcOperation> + <sdncadapter:CallbackUrl>${callbackUrlToUse}</sdncadapter:CallbackUrl>""" + + if (sdnca_msoAction != null) { + sdncAdapterRequest += """ + <sdncadapter:MsoAction>${sdnca_msoAction}</sdncadapter:MsoAction>""" + } + + sdncAdapterRequest += """ + </sdncadapter:RequestHeader> + <sdncadaptersc:RequestData>${sdncRequestData}</sdncadaptersc:RequestData></aetgt:SDNCAdapterRequest></SOAP-ENV:Body></SOAP-ENV:Envelope>""" + + utils.logAudit("Outgoing SDNCAdapterRequest:\n" + sdncAdapterRequest) + execution.setVariable("sdncAdapterRequest", sdncAdapterRequest) + + utils.log("DEBUG", execution.getVariable("sdncAdapterRequest"), isDebugEnabled) + utils.log("DEBUG", execution.getVariable("URN_mso_adapters_sdnc_endpoint"), isDebugEnabled) + }catch(Exception e){ + utils.log("DEBUG", 'Internal Error occured during PreProcess Method: ' + e, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 9999, 'Internal Error occured during PreProcess Method') // TODO: what message and error code? + } + utils.log("DEBUG","=========== End pre Process SDNCRequestScript ===========", isDebugEnabled) + } + + public void postProcessResponse (Execution execution) { + + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + try{ + utils.log("DEBUG","=========== Begin POSTProcess SDNCAdapter ===========", isDebugEnabled) + utils.log("DEBUG","Incoming sdncAdapterCallbackRequest:\n" + execution.getVariable("sdncAdapterCallbackRequest"), isDebugEnabled) + + // Check the sdnccallback request and get the responsecode + def sdnccallbackreq = execution.getVariable("sdncAdapterCallbackRequest") + def callbackRequestData = "" + def callbackHeader = "" + utils.logAudit("SDNCAdapterCallback Request :" + sdnccallbackreq) + + if(sdnccallbackreq != null){ + callbackHeader = utils.getNodeXml(sdnccallbackreq, "CallbackHeader") + callbackRequestData = utils.getNodeXml(sdnccallbackreq, "RequestData") + + callbackHeader = callbackHeader.replace("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n", "") + utils.log("DEBUG","SDNCCallbackHeader is:\n" + callbackHeader, isDebugEnabled) + + callbackRequestData = callbackRequestData.replace("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n", "") + utils.log("DEBUG","DECODED SDNCCallback RequestData is:\n" + callbackRequestData, isDebugEnabled) + + String sdncAdapterWorkflowResponse =""" + <sdncadapterworkflow:SDNCAdapterWorkflowResponse xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"> + <sdncadapterworkflow:response-data> + ${callbackHeader} + ${callbackRequestData} + </sdncadapterworkflow:response-data> + </sdncadapterworkflow:SDNCAdapterWorkflowResponse>""" + + + utils.log("DEBUG","Outgoing sdncAdapterWorkflowResponse:\n" + sdncAdapterWorkflowResponse, isDebugEnabled) + sdncAdapterWorkflowResponse = utils.formatXml(sdncAdapterWorkflowResponse) + utils.logAudit("sdncAdapterWorkflowResponse :" + sdncAdapterWorkflowResponse) + execution.setVariable("sdncAdapterResponse", sdncAdapterWorkflowResponse) + // TODO: Should deprecate use of processKey+Response variable for the response. Will use "WorkflowResponse" instead + execution.setVariable("WorkflowResponse", sdncAdapterWorkflowResponse) + + // Check final indicator to determine if we are to continue listening or not + def String enhancedCallbackRequestData = callbackRequestData.replaceAll("&", "&") + enhancedCallbackRequestData = enhancedCallbackRequestData.replaceAll("<", "<") + enhancedCallbackRequestData = enhancedCallbackRequestData.replaceAll(">", ">") + // replace the data with '&' (ex: subscriber-name= 'FOUR SEASONS HEATING & COOLING' + enhancedCallbackRequestData = enhancedCallbackRequestData.replace("&", "&") + utils.log("DEBUG","EnhancedCallbackRequestData:\n" + enhancedCallbackRequestData, isDebugEnabled) + execution.setVariable("enhancedCallbackRequestData", enhancedCallbackRequestData) + def continueListening = false + if (utils.nodeExists(enhancedCallbackRequestData, "ack-final-indicator")) { + if (utils.getNodeText(enhancedCallbackRequestData, "ack-final-indicator") == 'N') { + continueListening = true + } + } + execution.setVariable("continueListening", continueListening) + utils.log("DEBUG", "Continue Listening: " + continueListening, isDebugEnabled) + }else{ + // Timed out waiting for asynchronous message, build error response + exceptionUtil.buildWorkflowException(execution, 500, "SDNC Callback Timeout Error") + execution.setVariable("asynchronousResponseTimeout", true) + utils.log("DEBUG", "Timed out waiting for asynchronous message", isDebugEnabled) + } + }catch(Exception e){ + utils.log("DEBUG", 'Internal Error occured during PostProcess Method: ' + e, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 9999, 'Internal Error occured during PostProcess Method') // TODO: what message and error code? + } + utils.log("DEBUG","=========== End POSTProcess SDNCAdapter ===========", isDebugEnabled) + } + + public void callbackResponsecheck(Execution execution){ + + def sdnccallbackreq=execution.getVariable("sdncAdapterCallbackRequest") + utils.logAudit("sdncAdapterCallbackRequest :" + sdnccallbackreq) + if (sdnccallbackreq==null){ + execution.setVariable("callbackResponseReceived",false); + }else{ + execution.setVariable("callbackResponseReceived",true); + } + } + + public void resetCallbackRequest(Execution execution) { + + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + + utils.log("DEBUG","=========== Begin Reset Callback Info SDNCAdapter ===========", isDebugEnabled) + + // Clear sdncAdapterCallbackRequest variable + execution.removeVariable("sdncAdapterCallbackRequest") + + // Determine and set SDNC Timeout Value + def enhancedCallbackRequestData = execution.getVariable("enhancedCallbackRequestData") + utils.logAudit("sdncAdapter - enhancedCallbackRequestData :" + enhancedCallbackRequestData) + def interim = false + if (enhancedCallbackRequestData != null) { + if (utils.nodeExists(enhancedCallbackRequestData, "ack-final-indicator")) { + if (utils.getNodeText(enhancedCallbackRequestData, "ack-final-indicator") == 'N') { + interim = true + } + } + } + def timeoutValue = execution.getVariable("URN_mso_sdnc_timeout") + def sdncAdapterWorkflowRequest = execution.getVariable("sdncAdapterWorkflowRequest") + if (interim && utils.nodeExists(sdncAdapterWorkflowRequest, "InterimSDNCTimeOutValueInHours")) { + timeoutValue = "PT" + utils.getNodeText(sdncAdapterWorkflowRequest, "InterimSDNCTimeOutValueInHours") + "H" + } else if (utils.nodeExists(sdncAdapterWorkflowRequest, "SDNCTimeOutValueInMinutes")) { + timeoutValue = "PT" + utils.getNodeText(sdncAdapterWorkflowRequest, "SDNCTimeOutValueInMinutes") + "M" + } + execution.setVariable("sdncTimeoutValue", timeoutValue) + utils.log("DEBUG", "Setting SDNC Timeout Value to " + timeoutValue, isDebugEnabled) + + utils.log("DEBUG","=========== End Reset Callback Info SDNCAdapter ===========", isDebugEnabled) + } + + + public void prepareDBMessage(Execution execution) { + + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + + utils.log("DEBUG","=========== Begin Prepare DB Message SDNCAdapter ===========", isDebugEnabled) + + // Create DB Message + def dbRequestId = execution.getVariable("mso-request-id") + String dbUpdateInterimStageCompletion = """ + <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"> + <SOAP-ENV:Body> + <DBAdapter:updateInterimStageCompletion xmlns:DBAdapter="http://org.openecomp.mso/requestsdb"> + <requestId>${dbRequestId}</requestId> + <interimStageCompletion>1</interimStageCompletion> + <lastModifiedBy>BPEL</lastModifiedBy> + </DBAdapter:updateInterimStageCompletion> + </SOAP-ENV:Body> + </SOAP-ENV:Envelope> + """ + + execution.setVariable("dbUpdateInterimStageCompletion", dbUpdateInterimStageCompletion) + utils.logAudit("sdncAdapter - dbUpdateInterimStageCompletion :" + dbUpdateInterimStageCompletion) + utils.log("DEBUG","DB UpdateInterimStageCompletion:\n" + dbUpdateInterimStageCompletion, isDebugEnabled) + utils.log("DEBUG","=========== End Prepare DB Message SDNCAdapter ===========", isDebugEnabled) + } + + + + public String generateCurrentTimeInUtc(){ + final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); + sdf.setTimeZone(TimeZone.getTimeZone("UTC")); + final String utcTime = sdf.format(new Date()); + return utcTime; + } + + public void toggleSuccessIndicator(Execution execution){ + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + execution.setVariable("SDNCA_SuccessIndicator", true) + utils.log("DEBUG","Setting SDNCA Success Indicator to True", isDebugEnabled) + } + + public void assignError(Execution execution){ + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + utils.log("DEBUG","=========== Started Assign Error ===========", isDebugEnabled) + WorkflowException wf = execution.getVariable("WorkflowException") + if(wf == null){ + exceptionUtil.buildWorkflowException(execution, 5000, "SDNCAdapter Encountered an Internal Error") // TODO: Not sure what message and error code we want here..... + }else{ + execution.setVariable("WorkflowException", wf) + } + + utils.log("DEBUG","Outgoing WorkflowException is: " + execution.getVariable("WorkflowException"), isDebugEnabled) + utils.log("DEBUG","=========== End Assign Error ===========", isDebugEnabled) + } + +} + diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/SDNCAdapterUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/SDNCAdapterUtils.groovy new file mode 100644 index 0000000000..5c01bb9c4d --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/SDNCAdapterUtils.groovy @@ -0,0 +1,925 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common.scripts; + +import org.apache.commons.lang3.* +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.runtime.Execution +import org.openecomp.mso.bpmn.core.WorkflowException +import org.springframework.web.util.UriUtils + + +/** + * @version 1.0 + * + */ +class SDNCAdapterUtils { + + ExceptionUtil exceptionUtil = new ExceptionUtil() + + private AbstractServiceTaskProcessor taskProcessor + + public SDNCAdapterUtils(AbstractServiceTaskProcessor taskProcessor) { + this.taskProcessor = taskProcessor + } + + String SDNCAdapterFeatureRequest(Execution execution, String requestName, String action, String callbackURL, String serviceOperation, String timeoutValueInMinutes) { + def utils=new MsoUtils() + + def prefix = execution.getVariable('prefix') + def request = taskProcessor.getVariable(execution, requestName) + def requestInformation = utils.getNodeXml(request, 'request-information', false) + def serviceInformation = utils.getNodeXml(request, 'service-information', false) + def featureInformation = utils.getNodeXml(request, 'feature-information', false) + def featureParameters = utils.getNodeXml(request, 'feature-parameters', false) + + def requestId = execution.getVariable('testReqId') // for junits + if(requestId==null){ + requestId = execution.getVariable("openecomp-mso-request-id") + "-" + System.currentTimeMillis() + } + + def svcInstanceId = execution.getVariable("openecomp-mso-service-instance-id") + + def nnsRequestInformation = utils.removeXmlNamespaces(requestInformation) + def nnsServiceInformation = utils.removeXmlNamespaces(serviceInformation) + def nnsFeatureInformation = utils.removeXmlNamespaces(featureInformation) + def nnsFeatureParameters = utils.removeXmlNamespaces(featureParameters) + + String sdncAdapterFeatureRequest = """ + <sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:sdncadapterworkflow="http://openecomp.com/mso/workflow/schema/v1" + xmlns:sdncadapter="http://domain2.openecomp.com/workflow/sdnc/adapter/schema/v1"> + <sdncadapter:RequestHeader> + <sdncadapter:RequestId>${requestId}</sdncadapter:RequestId> + <sdncadapter:SvcInstanceId>${svcInstanceId}</sdncadapter:SvcInstanceId> + <sdncadapter:SvcAction>${action}</sdncadapter:SvcAction> + <sdncadapter:SvcOperation>${serviceOperation}</sdncadapter:SvcOperation> + <sdncadapter:CallbackUrl>${callbackURL}</sdncadapter:CallbackUrl> + </sdncadapter:RequestHeader> + <sdncadapterworkflow:SDNCRequestData> + ${nnsRequestInformation} + ${nnsServiceInformation} + ${nnsFeatureInformation} + ${nnsFeatureParameters} + </sdncadapterworkflow:SDNCRequestData> + <sdncadapterworkflow:SDNCTimeOutValueInMinutes>${timeoutValueInMinutes}</sdncadapterworkflow:SDNCTimeOutValueInMinutes> + </sdncadapterworkflow:SDNCAdapterWorkflowRequest> + """ + sdncAdapterFeatureRequest = utils.removeXmlPreamble(utils.formatXML(sdncAdapterFeatureRequest)) + return sdncAdapterFeatureRequest + } + + String SDNCAdapterActivateVnfRequest(Execution execution, String action, String callbackURL, String serviceOperation, String msoAction, String timeoutValueInMinutes) { + def utils=new MsoUtils() + + def prefix = execution.getVariable('prefix') + def request = taskProcessor.getVariable(execution, prefix+'Request') + def requestInformation = utils.getNodeXml(request, 'request-information', false) + def serviceInformation = utils.getNodeXml(request, 'service-information', false) + def vnfInformationList = utils.getNodeXml(request, 'vnf-information-list', false) + + def requestId = execution.getVariable('testReqId') // for junits + if(requestId==null){ + requestId = execution.getVariable("openecomp-mso-request-id") + "-" + System.currentTimeMillis() + } + + def svcInstanceId = execution.getVariable("openecomp-mso-service-instance-id") + + def nnsRequestInformation = utils.removeXmlNamespaces(requestInformation) + def nnsServiceInformation = utils.removeXmlNamespaces(serviceInformation) + def nnsVnfInformationList = utils.removeXmlNamespaces(vnfInformationList) + + String sdncAdapterActivateVnfRequest = """ + <sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:sdncadapterworkflow="http://openecomp.com/mso/workflow/schema/v1" + xmlns:sdncadapter="http://domain2.openecomp.com/workflow/sdnc/adapter/schema/v1"> + <sdncadapter:RequestHeader> + <sdncadapter:RequestId>${requestId}</sdncadapter:RequestId> + <sdncadapter:SvcInstanceId>${svcInstanceId}</sdncadapter:SvcInstanceId> + <sdncadapter:SvcAction>${action}</sdncadapter:SvcAction> + <sdncadapter:SvcOperation>${serviceOperation}</sdncadapter:SvcOperation> + <sdncadapter:CallbackUrl>${callbackURL}</sdncadapter:CallbackUrl> + <sdncadapter:MsoAction>${msoAction}</sdncadapter:MsoAction> + </sdncadapter:RequestHeader> + <sdncadapterworkflow:SDNCRequestData> + ${nnsRequestInformation} + ${nnsServiceInformation} + ${nnsVnfInformationList} + </sdncadapterworkflow:SDNCRequestData> + <sdncadapterworkflow:SDNCTimeOutValueInMinutes>${timeoutValueInMinutes}</sdncadapterworkflow:SDNCTimeOutValueInMinutes> + </sdncadapterworkflow:SDNCAdapterWorkflowRequest> + """ + sdncAdapterActivateVnfRequest = utils.removeXmlPreamble(utils.formatXML(sdncAdapterActivateVnfRequest)) + return sdncAdapterActivateVnfRequest + } + + String SDNCAdapterL3ToHigherLayerRequest(Execution execution, String action, String callbackURL, String serviceOperation, String timeoutValueInMinutes) { + def utils=new MsoUtils() + + def prefix = execution.getVariable('prefix') + def request = taskProcessor.getVariable(execution, prefix+'Request') + + def requestInformation = """<request-information> + <request-id>${execution.getVariable("openecomp-mso-request-id")}</request-id> + <request-action>torepl</request-action> + <source>${execution.getVariable(prefix+"source")}</source> + <notification-url>${execution.getVariable(prefix+"notificationUrl")}</notification-url> + </request-information>""" + + // Change the value of the 'request-information'.'request-action' element + def xml = new XmlSlurper().parseText(requestInformation) + if("assign".equalsIgnoreCase(action)){ + xml.'request-action'.replaceBody('createTrinityBonding') + }else if("activate".equalsIgnoreCase(action)){ + xml.'request-action'.replaceBody('activateTrinityBonding') + }else if("delete".equalsIgnoreCase(action)){ + xml.'request-action'.replaceBody('deleteTrinityBonding') + } + requestInformation = utils.removeXmlPreamble(groovy.xml.XmlUtil.serialize(xml)) + def nnsRequestInformation = utils.removeXmlNamespaces(requestInformation) + + def requestId = execution.getVariable('testReqId') // for junits + if(requestId==null){ + requestId = execution.getVariable("openecomp-mso-request-id") + "-" + System.currentTimeMillis() + } + + def svcInstanceId = execution.getVariable("openecomp-mso-service-instance-id") + + //Build Service Information + // Send serviceName from CANOPI to sdnc for service-type + def serviceInformation = """<service-information> + <service-type>${execution.getVariable(prefix+"serviceName")}</service-type> + <service-instance-id>${svcInstanceId}</service-instance-id> + <subscriber-name>${execution.getVariable(prefix+"subscriberName")}</subscriber-name> + <subscriber-global-id>${execution.getVariable(prefix+"subscriberGlobalId")}</subscriber-global-id> + </service-information>""" + + //Build Additional Information - vpn or vni + // Send serviceType from CANOPI to SDNC for nbnc-request-information service-type + def service = execution.getVariable(prefix+"serviceType") + def customerId = execution.getVariable(prefix+"customerId") + def vpnId = execution.getVariable(prefix+"vpnId") + def vpnRt = execution.getVariable(prefix+"vpnRt") + def vpnService = execution.getVariable(prefix+"vpnService") + def vpnRegion = execution.getVariable(prefix+"vpnRegion") + def additionalInfo = "" + if("assign".equalsIgnoreCase(action)){ + additionalInfo = """<vpn-data-list> + <vpn-id>${vpnId}</vpn-id> + <vpn-rt>${vpnRt}</vpn-rt> + <vpn-service>${vpnService}</vpn-service> + <vpn-region>${vpnRegion}</vpn-region> + </vpn-data-list>""" + }else if("activate".equalsIgnoreCase(action) || "delete".equalsIgnoreCase(action)){ + def vniId = execution.getVariable(prefix+'vniId') + additionalInfo = "<vni-id>${vniId}</vni-id>" + } + + //Set Interface Status + def interfaceStatus = "DISABLE" + if("activate".equalsIgnoreCase(action)){ + interfaceStatus = "ENABLE" + } + + //Build SDNC Adapter Request + String sdncAdapterL3ToHLRequest = """ + <sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:sdncadapterworkflow="http://openecomp.com/mso/workflow/schema/v1" + xmlns:sdncadapter="http://domain2.openecomp.com/workflow/sdnc/adapter/schema/v1"> + <sdncadapter:RequestHeader> + <sdncadapter:RequestId>${requestId}</sdncadapter:RequestId> + <sdncadapter:SvcInstanceId>${svcInstanceId}</sdncadapter:SvcInstanceId> + <sdncadapter:SvcAction>${action}</sdncadapter:SvcAction> + <sdncadapter:SvcOperation>${serviceOperation}</sdncadapter:SvcOperation> + <sdncadapter:CallbackUrl>${callbackURL}</sdncadapter:CallbackUrl> + </sdncadapter:RequestHeader> + <sdncadapterworkflow:SDNCRequestData> + ${nnsRequestInformation} + ${serviceInformation} + <nbnc-request-information> + <service-type>${service}</service-type> + <customer-id>${customerId}</customer-id> + <interface-status>${interfaceStatus}</interface-status> + ${additionalInfo} + </nbnc-request-information> + </sdncadapterworkflow:SDNCRequestData> + <sdncadapterworkflow:SDNCTimeOutValueInMinutes>${timeoutValueInMinutes}</sdncadapterworkflow:SDNCTimeOutValueInMinutes> + </sdncadapterworkflow:SDNCAdapterWorkflowRequest> + """ + sdncAdapterL3ToHLRequest = utils.removeXmlPreamble(utils.formatXML(sdncAdapterL3ToHLRequest)) + + return sdncAdapterL3ToHLRequest + } + + + + private void SDNCAdapterActivateRequest(Execution execution, String resultVar, String svcAction, + String svcOperation, String additionalData) { + def utils=new MsoUtils() + + def prefix = execution.getVariable('prefix') + def request = taskProcessor.getVariable(execution, prefix+'Request') + def requestInformation = utils.getNodeXml(request, 'request-information', false) + def serviceInformation = utils.getNodeXml(request, 'service-information', false) + def serviceParameters = utils.getNodeXml(request, 'service-parameters', false) + + def requestId = execution.getVariable('testReqId') // for junits + if(requestId==null){ + requestId = execution.getVariable("openecomp-mso-request-id") + "-" + System.currentTimeMillis() + } + + def svcInstanceId = execution.getVariable("openecomp-mso-service-instance-id") + def msoAction = 'gammainternet' + + def timeoutInMinutes = execution.getVariable('URN_mso_sdnc_timeout_firewall_minutes') + + def callbackUrl = (String) execution.getVariable('URN_mso_workflow_sdncadapter_callback') + if (callbackUrl == null || callbackUrl.trim() == "") { + logError('mso:workflow:sdncadapter:callback URN is not set') + workflowException(execution, 'Internal Error', 9999) // TODO: what message and error code? + } + + def l2HomingInformation = utils.getNodeXml(serviceParameters, 'l2-homing-information', false) + def internetEvcAccessInformation = utils.getNodeXml(serviceParameters, 'internet-evc-access-information', false) + def vrLan = utils.getNodeXml(serviceParameters, 'vr-lan', false) + def upceVmsServiceInformation = utils.getNodeXml(serviceParameters, 'ucpe-vms-service-information', false) + + + def nnsRequestInformation = utils.removeXmlNamespaces(requestInformation) + def nnsServiceInformation = utils.removeXmlNamespaces(serviceInformation) + def nnsl2HomingInformation = utils.removeXmlNamespaces(l2HomingInformation) + def nnsInternetEvcAccessInformation = utils.removeXmlNamespaces(internetEvcAccessInformation) + def nnsVrLan = utils.removeXmlNamespaces(vrLan) + def nnsUpceVmsServiceInformation = utils.removeXmlNamespaces(upceVmsServiceInformation) + + if (additionalData == null) { + additionalData = "" + } + + String content = """ + <sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:sdncadapterworkflow="http://openecomp.com/mso/workflow/schema/v1" + xmlns:sdncadapter="http://domain2.openecomp.com/workflow/sdnc/adapter/schema/v1"> + <sdncadapter:RequestHeader> + <sdncadapter:RequestId>${requestId}</sdncadapter:RequestId> + <sdncadapter:SvcInstanceId>${svcInstanceId}</sdncadapter:SvcInstanceId> + <sdncadapter:SvcAction>${svcAction}</sdncadapter:SvcAction> + <sdncadapter:SvcOperation>${svcOperation}</sdncadapter:SvcOperation> + <sdncadapter:CallbackUrl>${callbackUrl}</sdncadapter:CallbackUrl> + <sdncadapter:MsoAction>${msoAction}</sdncadapter:MsoAction> + </sdncadapter:RequestHeader> + <sdncadapterworkflow:SDNCRequestData> + ${additionalData} + ${nnsRequestInformation} + ${nnsServiceInformation} + ${nnsl2HomingInformation} + ${nnsInternetEvcAccessInformation} + ${nnsVrLan} + ${nnsUpceVmsServiceInformation} + </sdncadapterworkflow:SDNCRequestData> + <sdncadapterworkflow:SDNCTimeOutValueInMinutes>${timeoutInMinutes}</sdncadapterworkflow:SDNCTimeOutValueInMinutes> + </sdncadapterworkflow:SDNCAdapterWorkflowRequest> + """ + + content = utils.removeXmlPreamble(utils.formatXML(content)) + execution.setVariable(resultVar, content) + } + + /** + * Builds an SDNC "reserve" request and stores it in the specified execution + * variable. + * @param execution the execution + * @param resultVar the execution variable in which the result will be stored + */ + public void sdncReservePrep(Execution execution, String action, String resultVar) { + sdncPrep(execution, resultVar, action , 'service-configuration-operation', null, this.taskProcessor) + } + + /** + * Builds a basic SDNC request and stores it in the specified execution variable. + * @param execution the execution + * @param resultVar the execution variable in which the result will be stored + * @param svcAction the svcAction element value + * @param svcOperation the svcOperation element value + * @param additionalData additional XML content to be inserted into the + * RequestData element (may be null) + */ + public void sdncPrep(Execution execution, String resultVar, String svcAction, + String svcOperation, String additionalData, AbstractServiceTaskProcessor taskProcessor) { + def method = getClass().getSimpleName() + '.sdncPrep(' + + 'execution=' + execution.getId() + + ', resultVar=' + resultVar + + ', svcAction=' + svcAction + + ', svcOperation=' + svcOperation + + ', additionalData=' + (additionalData == null ? "no" : "yes") + + ')' + + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + taskProcessor.logDebug('Entered ' + method, isDebugLogEnabled) + MsoUtils utils = taskProcessor.utils + try { + def prefix = execution.getVariable('prefix') + def request = taskProcessor.getVariable(execution, prefix+'Request') + def requestInformation = utils.getNodeXml(request, 'request-information', false) + def serviceInformation = utils.getNodeXml(request, 'service-information', false) + def serviceParameters = utils.getChildNodes(request, 'service-parameters') + def requestAction = utils.getNodeText1(request, 'request-action') + + def timeoutInMinutes = execution.getVariable('URN_mso_sdnc_timeout_firewall_minutes') + + def requestId = execution.getVariable('testReqId') // for junits + if(requestId==null){ + requestId = execution.getVariable("openecomp-mso-request-id") + "-" + System.currentTimeMillis() + } + + def svcInstanceId = execution.getVariable("openecomp-mso-service-instance-id") + def msoAction = 'gammainternet' + + def callbackUrl = (String) execution.getVariable('URN_mso_workflow_sdncadapter_callback') + if (callbackUrl == null || callbackUrl.trim() == "") { + taskProcessor.logError('mso:workflow:sdncadapter:callback URN is not set') + taskProcessor.workflowException(execution, 'Internal Error', 9999) // TODO: what message and error code? + } + + def l2HomingInformation = utils.getNodeXml(request, 'l2-homing-information', false) + def internetEvcAccessInformation = utils.getNodeXml(request, 'internet-evc-access-information', false) + def vrLan = utils.getNodeXml(request, 'vr-lan', false) + def upceVmsServiceInfo = utils.getNodeXml(request, 'ucpe-vms-service-information', false) + def vnfInformationList = utils.getNodeXml(request, 'vnf-information-list', false) + + def nnsRequestInformation = utils.removeXmlNamespaces(requestInformation) + def nnsServiceInformation = utils.removeXmlNamespaces(serviceInformation) + def nnsl2HomingInformation = utils.removeXmlNamespaces(l2HomingInformation) + def nnsInternetEvcAccessInformation = utils.removeXmlNamespaces(internetEvcAccessInformation) + def nnsVrLan = utils.removeXmlNamespaces(vrLan) + def nnsUpceVmsServiceInfo = utils.removeXmlNamespaces(upceVmsServiceInfo) + def nnsVnfInformationList = utils.removeXmlNamespaces(vrLan) + def nnsinternetSvcChangeDetails = "" + + if(requestAction!=null && requestAction.equals("ChangeLayer3ServiceProvRequest")){ + def internetSvcChangeDetails = utils.removeXmlNamespaces(serviceParameters) + nnsinternetSvcChangeDetails = """<internet-service-change-details> + ${internetSvcChangeDetails} + </internet-service-change-details>""" + } + + if (additionalData == null) { + additionalData = "" + } + + String content = """ + <sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:sdncadapterworkflow="http://openecomp.com/mso/workflow/schema/v1" + xmlns:sdncadapter="http://domain2.openecomp.com/workflow/sdnc/adapter/schema/v1"> + <sdncadapter:RequestHeader> + <sdncadapter:RequestId>${requestId}</sdncadapter:RequestId> + <sdncadapter:SvcInstanceId>${svcInstanceId}</sdncadapter:SvcInstanceId> + <sdncadapter:SvcAction>${svcAction}</sdncadapter:SvcAction> + <sdncadapter:SvcOperation>${svcOperation}</sdncadapter:SvcOperation> + <sdncadapter:CallbackUrl>${callbackUrl}</sdncadapter:CallbackUrl> + <sdncadapter:MsoAction>${msoAction}</sdncadapter:MsoAction> + </sdncadapter:RequestHeader> + <sdncadapterworkflow:SDNCRequestData> + ${additionalData} + ${nnsRequestInformation} + ${nnsServiceInformation} + ${nnsl2HomingInformation} + ${nnsInternetEvcAccessInformation} + ${nnsVrLan} + ${nnsUpceVmsServiceInfo} + ${nnsVnfInformationList} + ${nnsinternetSvcChangeDetails} + </sdncadapterworkflow:SDNCRequestData> + </sdncadapterworkflow:SDNCAdapterWorkflowRequest> + """ + + content = utils.removeXmlPreamble(utils.formatXML(content)) + execution.setVariable(resultVar, content) + taskProcessor.logDebug(resultVar + ' = ' + System.lineSeparator() + content, isDebugLogEnabled) + + taskProcessor.logDebug('Exited ' + method, isDebugLogEnabled) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + taskProcessor.logError('Caught exception in ' + method, e) + taskProcessor.workflowException(execution, 'Internal Error', 9999) // TODO: what message and error code? + } + } + + /** + * Builds a topology SDNC request and return String request. + * As V2 will use 1607-style request, region instead of aic clli code + * @param execution, the execution + * @param requestXML, the incoming request for the flow + * @param serviceInstanceId, the serviceIntance (if available) + * @param callbackUrl, the call back url + * @param action, the action element value + * @param requestAction the svcOperation element value + * @param cloudRegionId the aai's cloud-region-id + * @param networkId the aai's network-id + * @param additionalData additional XML content to be inserted into the + * RequestData element (may be null) + */ + public String sdncTopologyRequestV2 (Execution execution, String requestXML, String serviceInstanceId, String callbackUrl, String action, String requestAction, String cloudRegionId, networkId, String queryAAIResponse, String additionalData) { + def utils=new MsoUtils() + + String requestId = "" + try { + requestId = execution.getVariable("openecomp-mso-request-id") + } catch (Exception ex) { + requestId = utils.getNodeText1(requestXML, "request-id") + } + + String aicCloudRegion = cloudRegionId + String tenantId = "" + if (utils.nodeExists(requestXML, "tenant-id")) { + tenantId = utils.getNodeText1(requestXML, "tenant-id") + } + String networkType = "" + if (utils.nodeExists(requestXML, "network-type")) { + networkType = utils.getNodeText1(requestXML, "network-type") + } + + // Replace/Use the value of network-type from aai query (vs input) during Delete Network flows. + if (queryAAIResponse != null) { + networkType = utils.getNodeText1(queryAAIResponse, "network-type") + } + + String serviceId = "" + if (utils.nodeExists(requestXML, "service-id")) { + serviceId = utils.getNodeText1(requestXML, "service-id") + } + String networkName = "" + if (utils.nodeExists(requestXML, "network-name")) { + networkName = utils.getNodeText1(requestXML, "network-name") + } + String source = "" + if (utils.nodeExists(requestXML, "source")) { + source = utils.getNodeText1(requestXML, "source") + } + + // get resourceLink from subflow execution variable + String serviceType = "" + String subscriberName = "" + String siRelatedLink = execution.getVariable("GENGSI_siResourceLink") + if (siRelatedLink != null) { + // get service type + int serviceStart = siRelatedLink.indexOf("service-subscription/") + int serviceEnd = siRelatedLink.indexOf("/service-instances/") + serviceType = siRelatedLink.substring(serviceStart + 21, serviceEnd) + serviceType = UriUtils.decode(serviceType,"UTF-8") + // get subscriber name + int subscriberNameStart = siRelatedLink.indexOf("customers/customer/") + int subscriberNameEnd = siRelatedLink.indexOf("/service-subscriptions/") + subscriberName = siRelatedLink.substring(subscriberNameStart + 19, subscriberNameEnd) + subscriberName = UriUtils.decode(subscriberName,"UTF-8") + } + + String content = + """<aetgt:SDNCAdapterWorkflowRequest xmlns:aetgt="http://openecomp.com/mso/workflow/schema/v1" + xmlns:sdncadapterworkflow="http://openecomp.com/mso/workflow/schema/v1" + xmlns:sdncadapter="http://domain2.openecomp.com/workflow/sdnc/adapter/schema/v1" + xmlns:ns5="http://openecomp.com/mso/request/types/v1"> + <sdncadapter:RequestHeader> + <sdncadapter:RequestId>${requestId}</sdncadapter:RequestId> + <sdncadapter:SvcInstanceId>${serviceInstanceId}</sdncadapter:SvcInstanceId> + <sdncadapter:SvcAction>${action}</sdncadapter:SvcAction> + <sdncadapter:SvcOperation>network-topology-operation</sdncadapter:SvcOperation> + <sdncadapter:CallbackUrl>sdncCallback</sdncadapter:CallbackUrl> + </sdncadapter:RequestHeader> + <sdncadapterworkflow:SDNCRequestData> + <request-information> + <request-id>${requestId}</request-id> + <request-action>${requestAction}</request-action> + <source>${source}</source> + <notification-url></notification-url> + <order-number></order-number> + <order-version></order-version> + </request-information> + <service-information> + <service-id>${serviceId}</service-id> + <service-type>${serviceType}</service-type> + <service-instance-id>${serviceInstanceId}</service-instance-id> + <subscriber-name>${subscriberName}</subscriber-name> + </service-information> + <network-request-information> + <network-id>${networkId}</network-id> + <network-type>${networkType}</network-type> + <network-name>${networkName}</network-name> + <tenant>${tenantId}</tenant> + <aic-cloud-region>${aicCloudRegion}</aic-cloud-region> + </network-request-information> + </sdncadapterworkflow:SDNCRequestData> + </aetgt:SDNCAdapterWorkflowRequest>""".trim() + + return content + } + + /** + * Builds a topology SDNC request and return String request. + * As V2 will use 1607-style request, region instead of aic clli code + * @param execution, the execution + * @param requestXML, the incoming request for the flow + * @param serviceInstanceId, the serviceIntance (if available) + * @param callbackUrl, the call back url + * @param action, the action element value + * @param requestAction the svcOperation element value + * @param cloudRegionId the aai's cloud-region-id + * @param networkId the aai's network-id + * @param additionalData additional XML content to be inserted into the + * RequestData element (may be null) + */ + public String sdncTopologyRequestRsrc (Execution execution, String requestXML, String serviceInstanceId, String callbackUrl, String action, String requestAction, String cloudRegionId, networkId, String additionalData) { + def utils=new MsoUtils() + + // SNDC is expecting requestId as unique each call. + String requestId = "" + String testRequestId = execution.getVariable("testMessageId") // for test purposes. + if (testRequestId == null) { + requestId = UUID.randomUUID() // generate unique + } else { + requestId = testRequestId + } + + String aicCloudRegion = cloudRegionId + String tenantId = "" + if (utils.nodeExists(requestXML, "tenant-id")) { + tenantId = utils.getNodeText1(requestXML, "tenant-id") + } + String networkType = "" + if (utils.nodeExists(requestXML, "network-type")) { + networkType = utils.getNodeText1(requestXML, "network-type") + } + + String subscriptionServiceType = "" + if (utils.nodeExists(requestXML, "subscription-service-type")) { + subscriptionServiceType = utils.getNodeText1(requestXML, "subscription-service-type") + } + + String globalCustomerId = "" + if (utils.nodeExists(requestXML, "global-customer-id")) { + globalCustomerId = utils.getNodeText1(requestXML, "global-customer-id") + } + + String serviceId = "" + if (utils.nodeExists(requestXML, "service-id")) { + serviceId = utils.getNodeText1(requestXML, "service-id") + } + String networkName = "" + if (utils.nodeExists(requestXML, "network-name")) { + networkName = utils.getNodeText1(requestXML, "network-name") + } + String source = "" + if (utils.nodeExists(requestXML, "source")) { + source = utils.getNodeText1(requestXML, "source") + } + + // get resourceLink from subflow execution variable + String serviceType = "" + String subscriberName = "" + String siRelatedLink = execution.getVariable("GENGSI_siResourceLink") + if (siRelatedLink != null) { + // get service type + int serviceStart = siRelatedLink.indexOf("service-subscription/") + int serviceEnd = siRelatedLink.indexOf("/service-instances/") + serviceType = siRelatedLink.substring(serviceStart + 21, serviceEnd) + serviceType = UriUtils.decode(serviceType,"UTF-8") + // get subscriber name + int subscriberNameStart = siRelatedLink.indexOf("customers/customer/") + int subscriberNameEnd = siRelatedLink.indexOf("/service-subscriptions/") + subscriberName = siRelatedLink.substring(subscriberNameStart + 19, subscriberNameEnd) + subscriberName = UriUtils.decode(subscriberName,"UTF-8") + } + + // network-information from 'networkModelInfo' // verify the DB Catalog response + String networkModelInfo = utils.getNodeXml(requestXML, "networkModelInfo", false).replace("tag0:","").replace(":tag0","") + String modelInvariantUuid = utils.getNodeText1(networkModelInfo, "modelInvariantUuid") !=null ? + utils.getNodeText1(networkModelInfo, "modelInvariantUuid") : "" + String modelCustomizationUuid = utils.getNodeText1(networkModelInfo, "modelCustomizationUuid") !=null ? + utils.getNodeText1(networkModelInfo, "modelCustomizationUuid") : "" + String modelUuid = utils.getNodeText1(networkModelInfo, "modelUuid") !=null ? + utils.getNodeText1(networkModelInfo, "modelUuid") : "" + String modelVersion = utils.getNodeText1(networkModelInfo, "modelVersion") !=null ? + utils.getNodeText1(networkModelInfo, "modelVersion") : "" + String modelName = utils.getNodeText1(networkModelInfo, "modelName") !=null ? + utils.getNodeText1(networkModelInfo, "modelName") : "" + + // service-information from 'networkModelInfo' // verify the DB Catalog response + String serviceModelInfo = utils.getNodeXml(requestXML, "serviceModelInfo", false).replace("tag0:","").replace(":tag0","") + String serviceModelInvariantUuid = utils.getNodeText1(serviceModelInfo, "modelInvariantUuid") !=null ? + utils.getNodeText1(serviceModelInfo, "modelInvariantUuid") : "" + String serviceModelUuid = utils.getNodeText1(serviceModelInfo, "modelUuid") !=null ? + utils.getNodeText1(serviceModelInfo, "modelUuid") : "" + String serviceModelVersion = utils.getNodeText1(serviceModelInfo, "modelVersion") !=null ? + utils.getNodeText1(serviceModelInfo, "modelVersion") : "" + String serviceModelName = utils.getNodeText1(serviceModelInfo, "modelName") !=null ? + utils.getNodeText1(serviceModelInfo, "modelName") : "" + + + String content = + """<aetgt:SDNCAdapterWorkflowRequest xmlns:aetgt="http://openecomp.com/mso/workflow/schema/v1" + xmlns:sdncadapter="http://domain2.openecomp.com/workflow/sdnc/adapter/schema/v1" + xmlns:sdncadapterworkflow="http://openecomp.com/mso/workflow/schema/v1"> + <sdncadapter:RequestHeader> + <sdncadapter:RequestId>${requestId}</sdncadapter:RequestId> + <sdncadapter:SvcInstanceId>${serviceInstanceId}</sdncadapter:SvcInstanceId> + <sdncadapter:SvcAction>${action}</sdncadapter:SvcAction> + <sdncadapter:SvcOperation>network-topology-operation</sdncadapter:SvcOperation> + <sdncadapter:CallbackUrl>sdncCallback</sdncadapter:CallbackUrl> + <sdncadapter:MsoAction>generic-resource</sdncadapter:MsoAction> + </sdncadapter:RequestHeader> + <sdncadapterworkflow:SDNCRequestData> + <request-information> + <request-id>${requestId}</request-id> + <request-action>${requestAction}</request-action> + <source>${source}</source> + <notification-url></notification-url> + <order-number></order-number> + <order-version></order-version> + </request-information> + <service-information> + <service-id>${serviceId}</service-id> + <subscription-service-type>${subscriptionServiceType}</subscription-service-type> + <ecomp-model-information> + <model-invariant-uuid>${serviceModelInvariantUuid}</model-invariant-uuid> + <model-uuid>${serviceModelUuid}</model-uuid> + <model-version>${serviceModelVersion}</model-version> + <model-name>${serviceModelName}</model-name> + </ecomp-model-information> + <service-instance-id>${serviceInstanceId}</service-instance-id> + <global-customer-id>${globalCustomerId}</global-customer-id> + <subscriber-name>${subscriberName}</subscriber-name> + </service-information> + <network-information> + <network-id>${networkId}</network-id> + <network-type>${networkType}</network-type> + <ecomp-model-information> + <model-invariant-uuid>${modelInvariantUuid}</model-invariant-uuid> + <model-customization-uuid>${modelCustomizationUuid}</model-customization-uuid> + <model-uuid>${modelUuid}</model-uuid> + <model-version>${modelVersion}</model-version> + <model-name>${modelName}</model-name> + </ecomp-model-information> + </network-information> + <network-request-input> + <network-name>${networkName}</network-name> + <tenant>${tenantId}</tenant> + <aic-cloud-region>${aicCloudRegion}</aic-cloud-region> + <aic-clli></aic-clli> + <network-input-parameters/> + </network-request-input> + </sdncadapterworkflow:SDNCRequestData> + </aetgt:SDNCAdapterWorkflowRequest>""".trim() + + return content + } + + /** + * Validates a workflow response. + * @param execution the execution + * @param responseVar the execution variable in which the response is stored + * @param workflowException the WorkflowException Object returned from sdnc call + */ + public void validateSDNCResponse(Execution execution, String response, WorkflowException workflowException, boolean successIndicator){ + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + taskProcessor.utils.log("DEBUG", "SDNC Response is: " + response, isDebugLogEnabled) + taskProcessor.utils.log("DEBUG", "SuccessIndicator is: " + successIndicator, isDebugLogEnabled) + + try { + def prefix = execution.getVariable('prefix') + execution.setVariable(prefix+'sdncResponseSuccess', false) + taskProcessor.utils.log("DEBUG", "Response" + ' = ' + (response == null ? "" : System.lineSeparator()) + response, isDebugLogEnabled) + + if (successIndicator == true){ + if (response == null || response.trim().equals("")) { + taskProcessor.utils.log("DEBUG", response + ' is empty'); + exceptionUtil.buildAndThrowWorkflowException(execution, 500, "SDNCAdapter Workflow Response is Empty") + }else{ + + // we need to peer into the request data for error + def String sdncAdapterWorkflowResponse = taskProcessor.utils.getNodeXml(response, 'response-data', false) + def String decodedXml = decodeXML(sdncAdapterWorkflowResponse).replace('<?xml version="1.0" encoding="UTF-8"?>', "") + + // change '&' to "& (if present as data, ex: subscriber-name = 'FOUR SEASONS HEATING & COOLING_8310006378683' + decodedXml = decodedXml.replace("&", "&") + + taskProcessor.utils.log("DEBUG","decodedXml:\n" + decodedXml, isDebugLogEnabled) + + int requestDataResponseCode = 200 + def String requestDataResponseMessage = '' + + try{ + if (taskProcessor.utils.nodeExists(decodedXml, "response-message")) { + requestDataResponseMessage = taskProcessor.utils.getNodeText(decodedXml, "response-message") + } else if (taskProcessor.utils.nodeExists(decodedXml, "ResponseMessage")) { + requestDataResponseMessage = taskProcessor.utils.getNodeText(decodedXml, "ResponseMessage") + } + }catch(Exception e){ + taskProcessor.utils.log("DEBUG", 'Error caught while decoding resposne ' + e.getMessage(), isDebugLogEnabled) + } + + if(taskProcessor.utils.nodeExists(decodedXml, "response-code")) { + taskProcessor.utils.log("DEBUG","response-code node Exist ", isDebugLogEnabled) + String code = taskProcessor.utils.getNodeText1(decodedXml, "response-code") + if(code.isEmpty() || code.equals("")){ + // if response-code is blank then Success + taskProcessor.utils.log("DEBUG","response-code node is empty", isDebugLogEnabled) + requestDataResponseCode = 0 + }else{ + requestDataResponseCode = code.toInteger() + taskProcessor.utils.log("DEBUG","response-code is: " + requestDataResponseCode, isDebugLogEnabled) + } + }else if(taskProcessor.utils.nodeExists(decodedXml, "ResponseCode")){ + taskProcessor.utils.log("DEBUG","ResponseCode node Exist ", isDebugLogEnabled) + String code = taskProcessor.utils.getNodeText1(decodedXml, "ResponseCode") + if(code.isEmpty() || code.equals("")){ + // if ResponseCode blank then Success + taskProcessor.utils.log("DEBUG","ResponseCode node is empty", isDebugLogEnabled) + requestDataResponseCode = 0 + }else{ + requestDataResponseCode = code.toInteger() + taskProcessor.utils.log("DEBUG","ResponseCode is: " + requestDataResponseCode, isDebugLogEnabled) + } + }else{ + taskProcessor.utils.log("DEBUG","A Response Code DOES NOT Exist.", isDebugLogEnabled) + // if a response code does not exist then Success + requestDataResponseCode = 0 + } + try{ + + // if a response code is 0 or 200 then Success + if (requestDataResponseCode == 200 || requestDataResponseCode == 0) { + execution.setVariable(prefix+'sdncResponseSuccess', true) + taskProcessor.utils.log("DEBUG", "Setting sdncResponseSuccess to True ", isDebugLogEnabled) + taskProcessor.utils.log("DEBUG", "Exited ValidateSDNCResponse Method", isDebugLogEnabled) + }else{ + ExceptionUtil exceptionUtil = new ExceptionUtil() + String convertedCode = exceptionUtil.MapSDNCResponseCodeToErrorCode(requestDataResponseCode.toString()) + int convertedCodeInt = Integer.parseInt(convertedCode) + exceptionUtil.buildAndThrowWorkflowException(execution, convertedCodeInt, "Received error from SDN-C: " + requestDataResponseMessage) + } + + }catch(Exception e){ + //TODO proper handling of new, non numerical response codes in 1607 and new error handling for common API + requestDataResponseCode = 500 + } + + taskProcessor.utils.log("DEBUG", "SDNC callback response-code: " + requestDataResponseCode, isDebugLogEnabled) + taskProcessor.utils.log("DEBUG", "SDNC callback response-message: " + requestDataResponseMessage, isDebugLogEnabled) + } + + }else { + taskProcessor.utils.log("DEBUG", 'SDNCAdapter Subflow did NOT complete Successfully. SuccessIndicator is False. ') + if(workflowException != null){ + exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage()) + }else{ + //TODO : what error code and error message use here + exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Internal Error - SDNCAdapter Subflow did NOT complete successfully.") + } + } + + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + taskProcessor.utils.log("DEBUG", 'END of Validate SDNC Response', isDebugLogEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, 'Internal Error- Unable to validate SDNC Response '); + } + } + + /** + * Validates a workflow response. + * @param execution the execution + * @param responseVar the execution variable in which the response is stored + * @param responseCodeVar the execution variable in which the response code is stored + * @param errorResponseVar the execution variable in which the error response is stored + */ + public void validateL3BondingSDNCResp(Execution execution, String response, WorkflowException workflowException, boolean success) { + def method = getClass().getSimpleName() + '.validateL3BondingSDNCResp(' + + 'execution=' + execution.getId() + + ', response=' + response + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + taskProcessor.logDebug('Entered ' + method, isDebugLogEnabled) + def prefix = execution.getVariable('prefix') + CommonExceptionUtil commonExceptionUtil = new CommonExceptionUtil() + + try { + execution.setVariable(prefix+'sdncResponseSuccess', false) + + taskProcessor.utils.log("sdncAdapter Success Indicator is: " + success, isDebugLogEnabled) + if (success == true) { + + // we need to look inside the request data for error + def String callbackRequestData = taskProcessor.utils.getNodeXml(response, 'RequestData', false) + def String decodedXml = decodeXML(callbackRequestData) + taskProcessor.utils.log("DEBUG","decodedXml:\n" + decodedXml, isDebugLogEnabled) + + def requestDataResponseCode = '200' + def requestDataResponseMessage = '' + int intDataResponseCode = 200 + + if (taskProcessor.utils.nodeExists(decodedXml, "response-code")) { + + requestDataResponseCode = ((String) taskProcessor.utils.getNodeText(decodedXml, "response-code")) + if (taskProcessor.utils.nodeExists(decodedXml, "response-message")) { + requestDataResponseMessage = taskProcessor.utils.getNodeText(decodedXml, "response-message") + } + }else if(taskProcessor.utils.nodeExists(decodedXml, "ResponseCode")){ + requestDataResponseCode = ((String) taskProcessor.utils.getNodeText1(decodedXml, "ResponseCode")).toInteger() + }else if(taskProcessor.utils.nodeExists(response, "ResponseCode")){ + requestDataResponseCode = ((String) taskProcessor.utils.getNodeText1(response, "ResponseCode")).toInteger() + requestDataResponseMessage = taskProcessor.utils.getNodeText(response, "ResponseMessage") + } + + taskProcessor.utils.log("DEBUG", "SDNC callback response-code: " + requestDataResponseCode, isDebugLogEnabled) + taskProcessor.utils.log("DEBUG", "SDNC callback response-message: " + requestDataResponseMessage, isDebugLogEnabled) + + // Get the AAI Status to determine if rollback is needed on ASSIGN + def aai_status = '' + if (taskProcessor.utils.nodeExists(decodedXml, "aai-status")) { + aai_status = ((String) taskProcessor.utils.getNodeText(decodedXml, "aai-status")) + taskProcessor.utils.log("DEBUG", "SDNC sent AAI STATUS code: " + aai_status, isDebugLogEnabled) + } + if (aai_status != null && !aai_status.equals("")) { + execution.setVariable(prefix+"AaiStatus",aai_status) + taskProcessor.utils.log("DEBUG", "Set variable " + prefix + "AaiStatus: " + execution.getVariable(prefix+"AaiStatus"), isDebugLogEnabled) + } + + // Get the result string to determine if rollback is needed on ASSIGN in Add Bonding flow only + def sdncResult = '' + if (taskProcessor.utils.nodeExists(decodedXml, "result")) { + sdncResult = ((String) taskProcessor.utils.getNodeText(decodedXml, "result")) + taskProcessor.utils.log("DEBUG", "SDNC sent result: " + sdncResult, isDebugLogEnabled) + } + if (sdncResult != null && !sdncResult.equals("")) { + execution.setVariable(prefix+"SdncResult",sdncResult) + taskProcessor.utils.log("DEBUG", "Set variable " + prefix + "SdncResult: " + execution.getVariable(prefix+"SdncResult"), isDebugLogEnabled) + } + + try{ + intDataResponseCode = Integer.parseInt(String.valueOf(requestDataResponseCode)) + }catch(Exception e){ + intDataResponseCode = 400 + } + + taskProcessor.utils.log("DEBUG", "intDataResponseCode " + intDataResponseCode , isDebugLogEnabled) + + // if response-code is not Success (200, 201, etc) we need to throw an exception + if (intDataResponseCode != 200 && intDataResponseCode != 0) { + execution.setVariable(prefix+'ResponseCode', intDataResponseCode) + execution.setVariable("L3HLAB_rollback", true) + def msg = commonExceptionUtil.mapSDNCAdapterExceptionToErrorResponse(response, execution) + taskProcessor.commonWorkflowException(execution, intDataResponseCode, "Received error from SDN-C: " + msg) + + } + }else { + taskProcessor.logWarn('sdncAdapter did not complete successfully, sdncAdapter Success Indicator was false ') + execution.setVariable("L3HLAB_rollback", true) + def msg = commonExceptionUtil.mapSDNCAdapterExceptionToErrorResponse(response, execution) + taskProcessor.commonWorkflowException(execution, responseCode, msg) + } + + if (response == null || response.trim().equals("")) { + taskProcessor.logWarn('sdncAdapter workflow response is empty'); + execution.setVariable("L3HLAB_rollback", true) + def msg = commonExceptionUtil.buildException("Exception occurred while validating SDNC response " , execution) + taskProcessor.commonWorkflowException(execution, intResponseCode, msg) + } + + execution.setVariable(prefix+'sdncResponseSuccess', true) + taskProcessor.logDebug('Exited ' + method, isDebugLogEnabled) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + taskProcessor.logError('Caught exception in ' + method, e) + execution.setVariable(prefix+"ResponseCode",400) + execution.setVariable("L3HLAB_rollback", true) + def msg = commonExceptionUtil.buildException("Exception occurred while validating SDNC response: " + e.getMessage(), execution) + taskProcessor.commonWorkflowException(execution, 400, msg) + } + } + + /** + * Decode XML - replace & < and > with '&', '<' and '>' + * @param xml - the xml to be decoded + */ + private String decodeXML(String xml) { + def String decodedXml = xml.replaceAll("&", "&") + decodedXml = decodedXml.replaceAll("<", "<") + decodedXml = decodedXml.replaceAll(">", ">") + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/ServiceTaskProcessor.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/ServiceTaskProcessor.groovy new file mode 100644 index 0000000000..ef21818f81 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/ServiceTaskProcessor.groovy @@ -0,0 +1,32 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common.scripts; + +import org.camunda.bpm.engine.runtime.Execution + + +/** + * @version 1.0 + * + */ +public interface ServiceTaskProcessor { + public void preProcessRequest(Execution execution); +} diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/UpdateAAIGenericVnf.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/UpdateAAIGenericVnf.groovy new file mode 100644 index 0000000000..2a13fb7d25 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/UpdateAAIGenericVnf.groovy @@ -0,0 +1,335 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common.scripts + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.runtime.Execution +import org.openecomp.mso.bpmn.core.WorkflowException +import org.openecomp.mso.rest.APIResponse +import org.springframework.web.util.UriUtils + + +public class UpdateAAIGenericVnf extends AbstractServiceTaskProcessor { + + private XmlParser xmlParser = new XmlParser() + + /** + * Initialize the flow's variables. + * + * @param execution The flow's execution instance. + */ + public void initProcessVariables(Execution execution) { + execution.setVariable('prefix', 'UAAIGenVnf_') + execution.setVariable('UAAIGenVnf_vnfId', null) + execution.setVariable('UAAIGenVnf_personaModelId', null) + execution.setVariable('UAAIGenVnf_personaModelVersion', null) + execution.setVariable("UAAIGenVnf_ipv4OamAddress", null) + execution.setVariable('UAAIGenVnf_managementV6Address', null) + execution.setVariable('UAAIGenVnf_getGenericVnfResponseCode' ,null) + execution.setVariable('UAAIGenVnf_getGenericVnfResponse', '') + execution.setVariable('UAAIGenVnf_updateGenericVnfResponseCode', null) + execution.setVariable('UAAIGenVnf_updateGenericVnfResponse', '') + } + + /** + * Check for missing elements in the received request. + * + * @param execution The flow's execution instance. + */ + public void preProcessRequest(Execution execution) { + def method = getClass().getSimpleName() + '.preProcessRequest(' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logDebug('Entered ' + method, isDebugLogEnabled) + + try { + def xml = execution.getVariable('UpdateAAIGenericVnfRequest') + logDebug('Received request xml:\n' + xml, isDebugLogEnabled) + utils.logAudit("UpdateAAIGenericVnf Request XML: " + xml) + initProcessVariables(execution) + + def vnfId = getRequiredNodeText(execution, xml,'vnf-id') + execution.setVariable('UAAIGenVnf_vnfId', vnfId) + + def personaModelId = getNodeTextForce(xml,'persona-model-id') + if (personaModelId != null && !personaModelId.isEmpty()) { + execution.setVariable('UAAIGenVnf_personaModelId', personaModelId) + } + + def personaModelVersion = getNodeTextForce(xml,'persona-model-version') + if (personaModelVersion != null && !personaModelVersion.isEmpty()) { + execution.setVariable('UAAIGenVnf_personaModelVersion', personaModelVersion) + } + + def ipv4OamAddress = getNodeTextForce(xml, 'ipv4-oam-address') + if (ipv4OamAddress != null && !ipv4OamAddress.isEmpty()) { + execution.setVariable('UAAIGenVnf_ipv4OamAddress', ipv4OamAddress) + } + + def managementV6Address = getNodeTextForce(xml, 'management-v6-address') + if (managementV6Address != null && !managementV6Address.isEmpty()) { + execution.setVariable('UAAIGenVnf_managementV6Address', managementV6Address) + } + + logDebug('Exited ' + method, isDebugLogEnabled) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + logError('Caught exception in ' + method, e) + createWorkflowException(execution, 1002, 'Error in preProcessRequest(): ' + e.getMessage()) + } + } + + /** + * Using the received vnfId, query AAI to get the corresponding Generic VNF. + * A 200 response is expected with the VF Module in the response body. + * + * @param execution The flow's execution instance. + */ + public void getGenericVnf(Execution execution) { + def method = getClass().getSimpleName() + '.getGenericVnf(' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logDebug('Entered ' + method, isDebugLogEnabled) + + try { + def vnfId = execution.getVariable('UAAIGenVnf_vnfId') + + // Construct endpoint + AaiUtil aaiUriUtil = new AaiUtil(this) + def aai_uri = aaiUriUtil.getNetworkGenericVnfUri(execution) + logDebug('AAI URI is: ' + aai_uri, isDebugLogEnabled) + String endPoint = execution.getVariable('URN_aai_endpoint') + aai_uri + '/' + UriUtils.encode(vnfId, "UTF-8") + "?depth=1" + + try { + logDebug('sending GET to AAI endpoint \'' + endPoint + '\'', isDebugLogEnabled) + utils.logAudit("Sending GET to AAI endpoint: " + endPoint) + + APIResponse response = aaiUriUtil.executeAAIGetCall(execution, endPoint) + def responseData = response.getResponseBodyAsString() + execution.setVariable('UAAIGenVnf_getGenericVnfResponseCode', response.getStatusCode()) + execution.setVariable('UAAIGenVnf_getGenericVnfResponse', responseData) + utils.logAudit("UpdateAAIGenericVnf Response data: " + responseData) + logDebug('Response code:' + response.getStatusCode(), isDebugLogEnabled) + logDebug('Response:' + System.lineSeparator() + responseData, isDebugLogEnabled) + } catch (Exception ex) { + ex.printStackTrace() + logDebug('Exception occurred while executing AAI GET:' + ex.getMessage(),isDebugLogEnabled) + execution.setVariable('UAAIGenVnf_getGenericVnfResponseCode', 500) + execution.setVariable('UAAIGenVnf_getGenericVnfResponse', 'AAI GET Failed:' + ex.getMessage()) + } + logDebug('Exited ' + method, isDebugLogEnabled) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + logError('Caught exception in ' + method, e) + createWorkflowException(execution, 1002, 'Error in getGenericVnf(): ' + e.getMessage()) + } + } + + /** + * Construct and send a PUT request to AAI to update the Generic VNF. + * + * @param execution The flow's execution instance. + */ + public void updateGenericVnf(Execution execution) { + def method = getClass().getSimpleName() + '.updateGenericVnf(' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logDebug('Entered ' + method, isDebugLogEnabled) + + try { + def vnfId = execution.getVariable('UAAIGenVnf_vnfId') + def genericVnf = execution.getVariable('UAAIGenVnf_getGenericVnfResponse') + def origRequest = execution.getVariable('UpdateAAIGenericVnfRequest') + + utils.logAudit("UpdateGenericVnf Request: " + origRequest) + // Confirm resource-version is in retrieved Generic VNF + def Node genericVnfNode = xmlParser.parseText(genericVnf) + if (utils.getChildNode(genericVnfNode, 'resource-version') == null) { + def msg = 'Can\'t update Generic VNF ' + vnfId + ' since \'resource-version\' is missing' + logError(msg) + throw new Exception(msg) + } + + // Handle persona-model-id/persona-model-version + + def String newPersonaModelId = execution.getVariable('UAAIGenVnf_personaModelId') + def String newPersonaModelVersion = execution.getVariable('UAAIGenVnf_personaModelVersion') + if (newPersonaModelId != null || newPersonaModelVersion != null) { + + // Confirm "new" persona-model-id is same as "current" persona-model-id + def Node currPersonaModelIdNode = utils.getChildNode(genericVnfNode, 'persona-model-id') + def String currPersonaModelId = '' + if (currPersonaModelIdNode != null) { + currPersonaModelId = currPersonaModelIdNode.text() + } + if (!newPersonaModelId.equals(currPersonaModelId)) { + def msg = 'Can\'t update Generic VNF ' + vnfId + ' since there is \'persona-model-id\' mismatch between the current and new values' + logError(msg) + throw new Exception(msg) + } + + // Construct payload + updateGenericVnfNode(origRequest, genericVnfNode, 'persona-model-version') + } + + // Handle ipv4-oam-address + def String ipv4OamAddress = execution.getVariable('UAAIGenVnf_ipv4OamAddress') + if (ipv4OamAddress != null) { + // Construct payload + updateGenericVnfNode(origRequest, genericVnfNode, 'ipv4-oam-address') + } + + // Handle management-v6-address + def String managementV6Address = execution.getVariable('UAAIGenVnf_managementV6Address') + if (managementV6Address != null) { + // Construct payload + updateGenericVnfNode(origRequest, genericVnfNode, 'management-v6-address') + } + + def payload = utils.nodeToString(genericVnfNode) + + // Construct endpoint + AaiUtil aaiUriUtil = new AaiUtil(this) + def aai_uri = aaiUriUtil.getNetworkGenericVnfUri(execution) + logDebug('AAI URI is: ' + aai_uri, isDebugLogEnabled) + String endPoint = execution.getVariable('URN_aai_endpoint') + aai_uri + '/' + UriUtils.encode(vnfId, "UTF-8") + + try { + logDebug('sending PUT to AAI endpoint \'' + endPoint + '\'' + 'with payload \n' + payload, isDebugLogEnabled) + utils.logAudit("Sending PUT to AAI endpoint: " + endPoint) + + APIResponse response = aaiUriUtil.executeAAIPutCall(execution, endPoint, payload) + def responseData = response.getResponseBodyAsString() + execution.setVariable('UAAIGenVnf_updateGenericVnfResponseCode', response.getStatusCode()) + execution.setVariable('UAAIGenVnf_updateGenericVnfResponse', responseData) + utils.logAudit("UpdateAAIGenericVnf Response Data: " + responseData) + logDebug('Response code:' + response.getStatusCode(), isDebugLogEnabled) + logDebug('Response:' + System.lineSeparator() + responseData, isDebugLogEnabled) + } catch (Exception ex) { + ex.printStackTrace() + logDebug('Exception occurred while executing AAI PUT:' + ex.getMessage(),isDebugLogEnabled) + execution.setVariable('UAAIGenVnf_updateGenericVnfResponseCode', 500) + execution.setVariable('UAAIGenVnf_updateGenericVnfResponse', 'AAI PUT Failed:' + ex.getMessage()) + } + logDebug('Exited ' + method, isDebugLogEnabled) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + logError('Caught exception in ' + method, e) + createWorkflowException(execution, 1002, 'Error in updateGenericVnf(): ' + e.getMessage()) + } + } + + /** + * Insert a new Node, replace the value of an existing Node, or delete an existing Node in the current + * Generic VNF Node, as necessary. + * + * If the Node with the same name already exists in current Generic VNF, but is not being updated, then do + * nothing. If the element is being updated and it already exists in the current Generic VNF, then check + * the value specified in the original request. If the value is 'DELETE', remove that Node from the + * current Generic VNF. Otherwise, change the value to the specified new value. If the element is + * being updated but doesn't exist in the current Generic VNF, and the new value is not 'DELETE', then + * create an appropriate new node and add it to the Generic VNF. + * + * @param origRequest Incoming update request with Generic VNF element(s) to be updated. + * @param genericVnf Current Generic VNF retrieved from AAI. + * @param element Name of element to be inserted. + */ + public void updateGenericVnfNode(String origRequest, Node genericVnfNode, String elementName) { + + if (!utils.nodeExists(origRequest, elementName)) { + return + } + def elementValue = utils.getNodeText(origRequest, elementName) + + def Node childNode = utils.getChildNode(genericVnfNode, elementName) + if (childNode == null) { + if (elementValue.equals('DELETE')) { + // Element doesn't exist but is being deleted, so do nothing + return + } + // Node doesn't exist, create a new Node as a child + new Node(genericVnfNode, elementName, elementValue) + } else { + if (elementValue.equals('DELETE')) { + // Node exists, but should be deleted + genericVnfNode.remove(childNode) + } else { + // Node already exists, just give it a new value + childNode.setValue(elementValue) + } + } + } + + /** + * Generates a WorkflowException if the AAI query returns a response code other than 200. + * + * @param execution The flow's execution instance. + */ + public void handleAAIQueryFailure(Execution execution) { + def method = getClass().getSimpleName() + '.handleAAIQueryFailure(' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logDebug('Entered ' + method, isDebugLogEnabled) + + logError('Error occurred attempting to query AAI, Response Code ' + + execution.getVariable('UAAIGenVnf_getGenericVnfResponseCode') + ', Error Response ' + + execution.getVariable('UAAIGenVnf_getGenericVnfResponse')) + String processKey = getProcessKey(execution); + WorkflowException exception = new WorkflowException(processKey, 5000, + execution.getVariable('UAAIGenVnf_getGenericVnfResponse')) + execution.setVariable('WorkflowException', exception) + + utils.logAudit("Workflow Exception occurred when handling Quering AAI: " + exception.getErrorMessage()) + logDebug('Exited ' + method, isDebugLogEnabled) + } + + /** + * Generates a WorkflowException if updating a VF Module in AAI returns a response code other than 200. + * + * @param execution The flow's execution instance. + */ + public void handleUpdateGenericVnfFailure(Execution execution) { + def method = getClass().getSimpleName() + '.handleUpdateGenericVnfFailure(' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logDebug('Entered ' + method, isDebugLogEnabled) + + logError('Error occurred attempting to update Generic VNF in AAI, Response Code ' + + execution.getVariable('UAAIGenVnf_updateGenericVnfResponseCode') + ', Error Response ' + + execution.getVariable('UAAIGenVnf_updateGenericVnfResponse')) + + String processKey = getProcessKey(execution); + WorkflowException exception = new WorkflowException(processKey, 5000, + execution.getVariable('UAAIGenVnf_updateGenericVnfResponse')) + execution.setVariable('WorkflowException', exception) + + utils.logAudit("Workflow Exception occurred when Updating GenericVnf: " + exception.getErrorMessage()) + logDebug('Exited ' + method, isDebugLogEnabled) + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/UpdateAAIVfModule.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/UpdateAAIVfModule.groovy new file mode 100644 index 0000000000..e1949d981d --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/UpdateAAIVfModule.groovy @@ -0,0 +1,385 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common.scripts + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.runtime.Execution +import org.openecomp.mso.bpmn.core.WorkflowException +import org.openecomp.mso.rest.APIResponse +import org.springframework.web.util.UriUtils + + +public class UpdateAAIVfModule extends AbstractServiceTaskProcessor { + + private XmlParser xmlParser = new XmlParser() + + /** + * Initialize the flow's variables. + * + * @param execution The flow's execution instance. + */ + public void initProcessVariables(Execution execution) { + execution.setVariable('prefix', 'UAAIVfMod_') + execution.setVariable('UAAIVfMod_vnfId', null) + execution.setVariable('UAAIVfMod_vfModuleId', null) + execution.setVariable('UAAIVfMod_orchestrationStatus', null) + execution.setVariable('UAAIVfMod_heatStackId', null) + execution.setVariable('UAAIVfMod_volumeGroupId', null) + execution.setVariable('UAAIVfMod_getVfModuleResponseCode' ,null) + execution.setVariable('UAAIVfMod_getVfModuleResponse', '') + execution.setVariable('UAAIVfMod_updateVfModuleResponseCode', null) + execution.setVariable('UAAIVfMod_updateVfModuleResponse', '') + } + + /** + * Check for missing elements in the received request. + * + * @param execution The flow's execution instance. + */ + public void preProcessRequest(Execution execution) { + def method = getClass().getSimpleName() + '.preProcessRequest(' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logDebug('Entered ' + method, isDebugLogEnabled) + + try { + def xml = execution.getVariable('UpdateAAIVfModuleRequest') + logDebug('Received request xml:\n' + xml, isDebugLogEnabled) + utils.logAudit("UpdateAAIVfModule Request XML: " + xml) + initProcessVariables(execution) + + def vnfId = getRequiredNodeText(execution, xml,'vnf-id') + execution.setVariable('UAAIVfMod_vnfId', vnfId) + + def vfModuleId = getRequiredNodeText(execution, xml,'vf-module-id') + execution.setVariable('UAAIVfMod_vfModuleId', vfModuleId) + + logDebug('Exited ' + method, isDebugLogEnabled) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + logError('Caught exception in ' + method, e) + createWorkflowException(execution, 1002, 'Error in preProcessRequest(): ' + e.getMessage()) + } + } + + /** + * Using the received vnfId and vfModuleId, query AAI to get the corresponding VF Module. + * A 200 response is expected with the VF Module in the response body. + * + * @param execution The flow's execution instance. + */ + public void getVfModule(Execution execution) { + def method = getClass().getSimpleName() + '.getVfModule(' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logDebug('Entered ' + method, isDebugLogEnabled) + + try { + def vnfId = execution.getVariable('UAAIVfMod_vnfId') + def vfModuleId = execution.getVariable('UAAIVfMod_vfModuleId') + + // Construct endpoint + AaiUtil aaiUriUtil = new AaiUtil(this) + def aai_uri = aaiUriUtil.getNetworkGenericVnfUri(execution) + logDebug('AAI URI is: ' + aai_uri, isDebugLogEnabled) + String endPoint = execution.getVariable('URN_aai_endpoint') + aai_uri + '/' + UriUtils.encode(vnfId, "UTF-8") + '/vf-modules/vf-module/' + UriUtils.encode(vfModuleId, "UTF-8") + + try { + logDebug('sending GET to AAI endpoint \'' + endPoint + '\'', isDebugLogEnabled) + utils.logAudit("UpdateAAIVfModule sending GET to AAI endpoint: " + endPoint) + + APIResponse response = aaiUriUtil.executeAAIGetCall(execution, endPoint) + def responseData = response.getResponseBodyAsString() + execution.setVariable('UAAIVfMod_getVfModuleResponseCode', response.getStatusCode()) + execution.setVariable('UAAIVfMod_getVfModuleResponse', responseData) + logDebug('Response code:' + response.getStatusCode(), isDebugLogEnabled) + logDebug('Response:' + System.lineSeparator() + responseData, isDebugLogEnabled) + utils.logAudit("UpdateAAIVfModule response data: " + responseData) + } catch (Exception ex) { + ex.printStackTrace() + logDebug('Exception occurred while executing AAI GET:' + ex.getMessage(),isDebugLogEnabled) + execution.setVariable('UAAIVfMod_getVfModuleResponseCode', 500) + execution.setVariable('UAAIVfMod_getVfModuleResponse', 'AAI GET Failed:' + ex.getMessage()) + } + logDebug('Exited ' + method, isDebugLogEnabled) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + logError('Caught exception in ' + method, e) + createWorkflowException(execution, 1002, 'Error in getVfModule(): ' + e.getMessage()) + } + } + + /** + * Construct and send a PUT request to AAI to update the VF Module. + * + * @param execution The flow's execution instance. + */ + public void updateVfModule(Execution execution) { + def method = getClass().getSimpleName() + '.updateVfModule(' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logDebug('Entered ' + method, isDebugLogEnabled) + + try { + def vnfId = execution.getVariable('UAAIVfMod_vnfId') + def vfModuleId = execution.getVariable('UAAIVfMod_vfModuleId') + def vfModule = execution.getVariable('UAAIVfMod_getVfModuleResponse') + def origRequest = execution.getVariable('UpdateAAIVfModuleRequest') + def Node vfModuleNode = xmlParser.parseText(vfModule) + + utils.logAudit("UpdateAAIVfModule request: " + origRequest) + // Confirm resource-version is in retrieved VF Module + if (utils.getChildNode(vfModuleNode, 'resource-version') == null) { + def msg = 'Can\'t update VF Module ' + vfModuleId + ' since \'resource-version\' is missing' + logError(msg) + throw new Exception(msg) + } + + // TEMPORARY!!! Disable Volume Group Check + // Check volume-group-id conditions + //def checkVgiResult = checkVolumeGroupId(origRequest, vfModuleNode, isDebugLogEnabled) + //if (checkVgiResult != null) { + // def msg = 'Can\'t update VF Module ' + vfModuleId + ': ' + checkVgiResult + // logError(msg) + // throw new Exception(msg) + //} + + // Handle persona-model-id/persona-model-version + def boolean doPersonaModelVersion = true + def String newPersonaModelId = utils.getNodeText1(origRequest, 'persona-model-id') + def String newPersonaModelVersion = utils.getNodeText1(origRequest, 'persona-model-version') + if ((newPersonaModelId == null) || (newPersonaModelVersion == null)) { + doPersonaModelVersion = false + } else { + // Confirm "new" persona-model-id is same as "current" persona-model-id + def String currPersonaModelId = utils.getChildNodeText(vfModuleNode, 'persona-model-id') + if (currPersonaModelId == null) { + currPersonaModelId = '' + } + if (!newPersonaModelId.equals(currPersonaModelId)) { + def msg = 'Can\'t update VF Module ' + vfModuleId + ' since there is \'persona-model-id\' mismatch between the current and new values' + logError(msg) + throw new Exception(msg) + } + } + + // Construct payload + updateVfModuleNode(origRequest, vfModuleNode, 'orchestration-status') + updateVfModuleNode(origRequest, vfModuleNode, 'heat-stack-id') + if (doPersonaModelVersion) { + updateVfModuleNode(origRequest, vfModuleNode, 'persona-model-version') + } + updateVfModuleNode(origRequest, vfModuleNode, 'contrail-service-instance-fqdn') + def payload = utils.nodeToString(vfModuleNode) + + // Construct endpoint + AaiUtil aaiUriUtil = new AaiUtil(this) + def aai_uri = aaiUriUtil.getNetworkGenericVnfUri(execution) + logDebug('AAI URI is: ' + aai_uri, isDebugLogEnabled) + String endPoint = execution.getVariable('URN_aai_endpoint') + aai_uri + '/' + UriUtils.encode(vnfId, "UTF-8") + '/vf-modules/vf-module/' + UriUtils.encode(vfModuleId, "UTF-8") + + try { + logDebug('sending PUT to AAI endpoint \'' + endPoint + '\'' + 'with payload \n' + payload, isDebugLogEnabled) + utils.logAudit("Sending PUT to AAI endpoint: " + endPoint) + + APIResponse response = aaiUriUtil.executeAAIPutCall(execution, endPoint, payload) + def responseData = response.getResponseBodyAsString() + execution.setVariable('UAAIVfMod_updateVfModuleResponseCode', response.getStatusCode()) + execution.setVariable('UAAIVfMod_updateVfModuleResponse', responseData) + utils.logAudit("UpdateAAIVfModule Response data: " + responseData) + logDebug('Response code:' + response.getStatusCode(), isDebugLogEnabled) + logDebug('Response:' + System.lineSeparator() + responseData, isDebugLogEnabled) + } catch (Exception ex) { + ex.printStackTrace() + logDebug('Exception occurred while executing AAI PUT:' + ex.getMessage(),isDebugLogEnabled) + execution.setVariable('UAAIVfMod_updateVfModuleResponseCode', 500) + execution.setVariable('UAAIVfMod_updateVfModuleResponse', 'AAI PUT Failed:' + ex.getMessage()) + } + logDebug('Exited ' + method, isDebugLogEnabled) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + logError('Caught exception in ' + method, e) + createWorkflowException(execution, 1002, 'Error in updateVfModule(): ' + e.getMessage()) + } + } + + /** + * Insert a new Node, replace the value of an existing Node, or delete an existing Node in the current + * VF Module Node, as necessary. + * + * If the Node with the same name already exists in current VF Module, but is not being updated, then do + * nothing. If the element is being updated and it already exists in the current VF Module, then check + * the value specified in the original request. If the value is 'DELETE', remove that Node from the + * current VF Module. Otherwise, change the value to the specified new value. If the element is + * being updated but doesn't exist in the current VF Module, and the new value is not 'DELETE', then + * create an appropriate new node and add it to the VF Module. + * + * @param origRequest Incoming update request with VF Module elements to be updated. + * @param vfModule Current VF Module retrieved from AAI. + * @param element Name of element to be inserted. + */ + private void updateVfModuleNode(String origRequest, Node vfModuleNode, String elementName) { + + if (!utils.nodeExists(origRequest, elementName)) { + return + } + def elementValue = utils.getNodeText(origRequest, elementName) + + def Node childNode = utils.getChildNode(vfModuleNode, elementName) + if (childNode == null) { + if (elementValue.equals('DELETE')) { + // Element doesn't exist but is being deleted, so do nothing + return + } + // Node doesn't exist, create a new Node as a child + new Node(vfModuleNode, elementName, elementValue) + } else { + if (elementValue.equals('DELETE')) { + // Node exists, but should be deleted + vfModuleNode.remove(childNode) + } else { + // Node already exists, just give it a new value + childNode.setValue(elementValue) + } + } + } + + /** + * Check the Volume Group ID from the incoming update request against the Volume Group ID from the + * given VF Module. If they are equal or if they are both 'null', then that is acceptable and 'null' + * is returned. Otherwise a message describing how the values are unacceptable/incompatible is returned. + * + * @param origRequest Incoming update request with VF Module elements to be updated. + * @param vfModuleNode VF Module (as a Node) retrieved from AAI. + * @param isDebugLogEnabled Is DEBUG log enabled? + * @return 'null' if the Volume Group IDs are acceptable. Otherwise return a message describing how the + * values are unacceptable/incompatible. + */ + private String checkVolumeGroupId(String origRequest, Node vfModuleNode, String isDebugLogEnabled) { + def requestVolumeGroupId = utils.getNodeText1(origRequest, 'volume-group-id') + def currVolumeGroupId = getCurrVolumeGroupId(vfModuleNode) + + logDebug('Check volume-group-id: volume-group-id in original request is \'' + requestVolumeGroupId + + '\', volume-group-id from VF Module is \'' + currVolumeGroupId + '\'', isDebugLogEnabled) + + def result = null + + if (requestVolumeGroupId == null) { + if (currVolumeGroupId == null) { + // This is OK + } else { + result = 'Cannot detach a volume group from an existing VF Module' + } + } else { + if (currVolumeGroupId == null) { + result = 'Cannot add a volume gruop to an existing VF Module' + } else { + if (!requestVolumeGroupId.equals(currVolumeGroupId)) { + result = 'Cannot change the volume group on an existing VF Module' + } + } + } + + return result + } + + /** + * Find and return the value of the Volume Group ID for the specified VF Module. If + * the value of the Volume Group ID cannot be found for any reason, 'null' is returned. + * + * @param vfModuleNode VF Module (as a Node) retrieved from AAI. + * @return the value of the Volume Group ID for the specified VF Module. If the + * value of the Volume Group ID cannot be found for any reason, 'null' is returned. + */ + private String getCurrVolumeGroupId(Node vfModuleNode) { + def Node relationshipList = utils.getChildNode(vfModuleNode, 'relationship-list') + if (relationshipList == null) { + return null + } + def NodeList relationships = utils.getIdenticalChildren(relationshipList, 'relationship') + for (Node relationshipNode in relationships) { + def String relatedTo = utils.getChildNodeText(relationshipNode, 'related-to') + if ((relatedTo != null) && relatedTo.equals('volume-group')) { + def NodeList relationshipDataList = utils.getIdenticalChildren(relationshipNode, 'relationship-data') + for (Node relationshipDataNode in relationshipDataList) { + def String relationshipKey = utils.getChildNodeText(relationshipDataNode, 'relationship-key') + if ((relationshipKey != null) && relationshipKey.equals('volume-group.volume-group-id')) { + return utils.getChildNodeText(relationshipDataNode, 'relationship-value') + } + } + } + } + return null + } + + /** + * Generates a WorkflowException if the AAI query returns a response code other than 200. + * + * @param execution The flow's execution instance. + */ + public void handleAAIQueryFailure(Execution execution) { + def method = getClass().getSimpleName() + '.handleAAIQueryFailure(' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logDebug('Entered ' + method, isDebugLogEnabled) + + logError('Error occurred attempting to query AAI, Response Code ' + + execution.getVariable('UAAIVfMod_getVfModuleResponseCode') + ', Error Response ' + + execution.getVariable('UAAIVfMod_getVfModuleResponse')) + String processKey = getProcessKey(execution); + WorkflowException exception = new WorkflowException(processKey, 5000, + execution.getVariable('UAAIVfMod_getVfModuleResponse')) + execution.setVariable('WorkflowException', exception) + utils.logAudit("UpdateAAIVfModule query failure: " + exception.getErrorMessage()) + logDebug('Exited ' + method, isDebugLogEnabled) + } + + /** + * Generates a WorkflowException if updating a VF Module in AAI returns a response code other than 200. + * + * @param execution The flow's execution instance. + */ + public void handleUpdateVfModuleFailure(Execution execution) { + def method = getClass().getSimpleName() + '.handleUpdateVfModuleFailure(' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logDebug('Entered ' + method, isDebugLogEnabled) + + logError('Error occurred attempting to update VF Module in AAI, Response Code ' + + execution.getVariable('UAAIVfMod_updateVfModuleResponseCode') + ', Error Response ' + + execution.getVariable('UAAIVfMod_updateVfModuleResponse')) + String processKey = getProcessKey(execution); + WorkflowException exception = new WorkflowException(processKey, 5000, + execution.getVariable('UAAIVfMod_updateVfModuleResponse')) + execution.setVariable('WorkflowException', exception) + + utils.logAudit("UpdateAAIVfModule failure: " + exception.getErrorMessage()) + logDebug('Exited ' + method, isDebugLogEnabled) + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/VfModule.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/VfModule.groovy new file mode 100644 index 0000000000..f52d21513d --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/VfModule.groovy @@ -0,0 +1,87 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common.scripts; + +import org.apache.commons.lang3.* + +public class VfModule implements Serializable { + + /** + * Class representing a VF Module Node. Fields of this class include indicators + * as to whether the VF Module is the only VF Module in its containing Generic VNF + * and whether the VF Module is the base VF Module in its containing Generic VNF. + */ + + private Node node + private Boolean onlyVfModule + private Boolean baseVfModule + + /** + * Constructor. + * + * @param node Node representing the VF Module xml. + * @param onlyVfModule Is this VF Module the only VF Module in its containing Generic VNF? + */ + public VfModule(Node node, boolean onlyVfModule) { + this.node = node + this.onlyVfModule = onlyVfModule + this.baseVfModule = getElementText('is-base-vf-module').equals('true') + } + + /** + * Get the Node representing the VF Module xml. + * + * @return the Node representing the VF Module xml. + */ + public Node getNode() { + return node + } + + public String getElementText(String childNodeName) { + def Node childNode = (new MsoUtils()).getChildNode(node, childNodeName) + if (childNode == null) { + return '' + } else { + return childNode.text() + } + } + + /** + * Is this VF Module the only VF Module in its containing Generic VNF? + * + * @return true if this VF Module is the only VF Module in its containing Generic VNF; + * false otherwise. + */ + public boolean isOnlyVfModule() { + return onlyVfModule + } + + /** + * Is this VF Module the base VF Module in its containing Generic VNF? + * + * @return true if this VF Module is the base VF Module in its containing Generic VNF; + * false otherwise. + */ + public boolean isBaseVfModule() { + return baseVfModule + } +} + diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/VfModuleBase.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/VfModuleBase.groovy new file mode 100644 index 0000000000..b4d3c6f4d8 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/VfModuleBase.groovy @@ -0,0 +1,609 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common.scripts; + +//import groovy.util.Node; + +import javax.xml.parsers.DocumentBuilder +import javax.xml.parsers.DocumentBuilderFactory + +import org.apache.commons.lang3.* +import org.camunda.bpm.engine.runtime.Execution +import org.w3c.dom.Document +import org.w3c.dom.Element +import org.w3c.dom.Node +import org.w3c.dom.NodeList +import org.xml.sax.InputSource + + +public abstract class VfModuleBase extends AbstractServiceTaskProcessor { + + protected XmlParser xmlParser = new XmlParser() + + /** + * Get the XmlParser. + * + * @return the XmlParser. + */ + protected XmlParser getXmlParser() { + return xmlParser + } + + /** + * Find the VF Module with specified ID in the specified Generic VF. If no such + * VF Module is found, null is returned. + * + * @param genericVnf The Generic VNF in which to search for the specified VF Moduel. + * @param vfModuleId The ID of the VF Module for which to search. + * @return a VFModule object for the found VF Module or null if no VF Module is found. + */ + protected VfModule findVfModule(String genericVnf, String vfModuleId) { + + def genericVnfNode = xmlParser.parseText(genericVnf) + def vfModulesNode = utils.getChildNode(genericVnfNode, 'vf-modules') + if (vfModulesNode == null) { + return null + } + def vfModuleList = utils.getIdenticalChildren(vfModulesNode, 'vf-module') + for (vfModuleNode in vfModuleList) { + def vfModuleIdNode = utils.getChildNode(vfModuleNode, 'vf-module-id') + if ((vfModuleIdNode != null) && (vfModuleIdNode.text().equals(vfModuleId))) { + return new VfModule(vfModuleNode, (vfModuleList.size() == 1)) + } + } + return null + } + + /** + * Transform all '*_network' parameter specifications from the incoming '*-params' root + * element to a corresponding list of 'vnf-networks' specifications (typically used when + * invoking the VNF Rest Adpater). Each element in '*-params' whose name attribute ends + * with '_network' is used to create an 'vnf-networks' element. + * + * @param paramsNode A Node representing a '*-params' element. + * @return a String of 'vnf-networks' elements, one for each 'param' element whose name + * attribute ends with '_network'. + */ + protected String transformNetworkParamsToVnfNetworks(String paramsRootXml) { + if ((paramsRootXml == null) || (paramsRootXml.isEmpty())) { + return '' + } + def String vnfNetworks = '' + try { + paramsRootXml = utils.removeXmlNamespaces(paramsRootXml) + def paramsNode = xmlParser.parseText(paramsRootXml) + def params = utils.getIdenticalChildren(paramsNode, 'param') + for (param in params) { + def String attrName = (String) param.attribute('name') + if (attrName.endsWith('_network')) { + def networkRole = attrName.substring(0, (attrName.length()-'_network'.length())) + def networkName = param.text() + String vnfNetwork = """ + <vnf-networks> + <network-role>${networkRole}</network-role> + <network-name>${networkName}</network-name> + </vnf-networks> + """ + vnfNetworks = vnfNetworks + vnfNetwork + } + } + } catch (Exception e) { + logWarn('Exception transforming \'_network\' params to vnfNetworks', e) + } + return vnfNetworks + } + + /** + * Transform the parameter specifications from the incoming '*-params' root element to + * a corresponding list of 'entry's (typically used when invoking the VNF Rest Adpater). + * Each element in '*-params' is used to create an 'entry' element. + * + * @param paramsNode A Node representing a '*-params' element. + * @return a String of 'entry' elements, one for each 'param' element. + */ + protected String transformParamsToEntries(String paramsRootXml) { + if ((paramsRootXml == null) || (paramsRootXml.isEmpty())) { + return '' + } + def String entries = '' + try { + paramsRootXml = utils.removeXmlNamespaces(paramsRootXml) + def paramsNode = xmlParser.parseText(paramsRootXml) + def params = utils.getIdenticalChildren(paramsNode, 'param') + for (param in params) { + def key = (String) param.attribute('name') + if (key == null) { + key = '' + } + def value = (String) param.text() + String entry = """ + <entry> + <key>${key}</key> + <value>${value}</value> + </entry> + """ + entries = entries + entry + } + } catch (Exception e) { + logWarn('Exception transforming params to entries', e) + } + return entries + } + + /** + * Transform the parameter specifications from the incoming '*-params' root element to + * a corresponding list of 'entry's (typically used when invoking the VNF Rest Adpater). + * Each element in '*-params' is used to create an 'entry' element. + * + * @param paramsNode A Node representing a '*-params' element. + * @return a String of 'entry' elements, one for each 'param' element. + */ + protected String transformVolumeParamsToEntries(String paramsRootXml) { + if ((paramsRootXml == null) || (paramsRootXml.isEmpty())) { + return '' + } + def String entries = '' + try { + paramsRootXml = utils.removeXmlNamespaces(paramsRootXml) + def paramsNode = xmlParser.parseText(paramsRootXml) + def params = utils.getIdenticalChildren(paramsNode, 'param') + for (param in params) { + def key = (String) param.attribute('name') + if (key == null) { + key = '' + } + if ( !(key in ['vnf_id', 'vnf_name', 'vf_module_id', 'vf_module_name'])) { + def value = (String) param.text() + String entry = """ + <entry> + <key>${key}</key> + <value>${value}</value> + </entry> + """ + entries = entries + entry + } + } + } catch (Exception e) { + logWarn('Exception transforming params to entries', e) + } + return entries + } + + /** + * Extract the Tenant Id from the Volume Group information returned by AAI. + * + * @param volumeGroupXml Volume Group XML returned by AAI. + * @return the Tenant Id extracted from the Volume Group information. 'null' is returned if + * the Tenant Id is missing or could not otherwise be extracted. + */ + protected String getTenantIdFromVolumeGroup(String volumeGroupXml) { + def groovy.util.Node volumeGroupNode = xmlParser.parseText(volumeGroupXml) + def groovy.util.Node relationshipList = utils.getChildNode(volumeGroupNode, 'relationship-list') + if (relationshipList != null) { + def groovy.util.NodeList relationships = utils.getIdenticalChildren(relationshipList, 'relationship') + for (groovy.util.Node relationship in relationships) { + def groovy.util.Node relatedTo = utils.getChildNode(relationship, 'related-to') + if ((relatedTo != null) && (relatedTo.text().equals('tenant'))) { + def groovy.util.NodeList relationshipDataList = utils.getIdenticalChildren(relationship, 'relationship-data') + for (groovy.util.Node relationshipData in relationshipDataList) { + def groovy.util.Node relationshipKey = utils.getChildNode(relationshipData, 'relationship-key') + if ((relationshipKey != null) && (relationshipKey.text().equals('tenant.tenant-id'))) { + def groovy.util.Node relationshipValue = utils.getChildNode(relationshipData, 'relationship-value') + if (relationshipValue != null) { + return relationshipValue.text() + } + } + } + } + } + } + return null + } + + + /* + * Parses VNF parameters passed in on the incoming requests and SDNC parameters returned from SDNC get response + * and puts them into the format expected by VNF adapter. + * @param vnfParamsMap - map of VNF parameters passed in the request body + * @param sdncGetResponse - response string from SDNC GET topology request + * @param vnfId + * @param vnfName + * @param vfModuleId + * @param vfModuleName + * @return a String of key/value entries for vfModuleParams + */ + + + protected String buildVfModuleParams(String vnfParams, String sdncGetResponse, String vnfId, String vnfName, + String vfModuleId, String vfModuleName) { + + //Get SDNC Response Data + + String data = utils.getNodeXml(sdncGetResponse, "response-data") + data = data.replaceAll("<", "<") + data = data.replaceAll(">", ">") + + String serviceData = utils.getNodeXml(data, "service-data") + serviceData = utils.removeXmlPreamble(serviceData) + serviceData = utils.removeXmlNamespaces(serviceData) + String vnfRequestInfo = utils.getNodeXml(serviceData, "vnf-request-information") + String oldVnfId = utils.getNodeXml(vnfRequestInfo, "vnf-id") + oldVnfId = utils.removeXmlPreamble(oldVnfId) + oldVnfId = utils.removeXmlNamespaces(oldVnfId) + serviceData = serviceData.replace(oldVnfId, "") + def vnfId1 = utils.getNodeText1(serviceData, "vnf-id") + + // Add-on data + String vnfInfo = + """<entry> + <key>vnf_id</key> + <value>${vnfId}</value> + </entry> + <entry> + <key>vnf_name</key> + <value>${vnfName}</value> + </entry> + <entry> + <key>vf_module_id</key> + <value>${vfModuleId}</value> + </entry> + <entry> + <key>vf_module_name</key> + <value>${vfModuleName}</value> + </entry>""" + + utils.logAudit("vnfInfo: " + vnfInfo) + InputSource source = new InputSource(new StringReader(data)); + DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); + docFactory.setNamespaceAware(true) + DocumentBuilder docBuilder = docFactory.newDocumentBuilder() + Document responseXml = docBuilder.parse(source) + + + // Availability Zones Data + String aZones = "" + StringBuilder sbAZone = new StringBuilder() + NodeList aZonesList = responseXml.getElementsByTagNameNS("*", "availability-zones") + String aZonePosition = "0" + for (int z = 0; z < aZonesList.getLength(); z++) { + Node node = aZonesList.item(z) + if (node.getNodeType() == Node.ELEMENT_NODE) { + Element eElement = (Element) node + String aZoneValue = utils.getElementText(eElement, "availability-zone") + aZonePosition = z.toString() + String aZoneXml = + """<entry> + <key>availability_zone_${aZonePosition}</key> + <value>${aZoneValue}</value> + </entry>""" + aZones = sbAZone.append(aZoneXml) + } + } + + // VNF Networks Data + String vnfNetworkNetId = "" + String vnfNetworkNetName = "" + String vnfNetworkSubNetId = "" + String vnfNetworkV6SubNetId = "" + String vnfNetworkNetFqdn = "" + String vnfNetworksSriovVlanFilters = "" + StringBuilder sbNet = new StringBuilder() + StringBuilder sbNet2 = new StringBuilder() + StringBuilder sbNet3 = new StringBuilder() + StringBuilder sbNet4 = new StringBuilder() + StringBuilder sbNet5 = new StringBuilder() + StringBuilder sbNet6 = new StringBuilder() + NodeList vnfNetworkList = responseXml.getElementsByTagNameNS("*", "vnf-networks") + for (int x = 0; x < vnfNetworkList.getLength(); x++) { + Node node = vnfNetworkList.item(x) + if (node.getNodeType() == Node.ELEMENT_NODE) { + Element eElement = (Element) node + String vnfNetworkKey = utils.getElementText(eElement, "network-role") + String vnfNetworkNeutronIdValue = utils.getElementText(eElement, "neutron-id") + String vnfNetworkNetNameValue = utils.getElementText(eElement, "network-name") + String vnfNetworkSubNetIdValue = utils.getElementText(eElement, "subnet-id") + String vnfNetworkV6SubNetIdValue = utils.getElementText(eElement, "ipv6-subnet-id") + String vnfNetworkNetFqdnValue = utils.getElementText(eElement, "contrail-network-fqdn") + String vnfNetworkNetIdXml = + """<entry> + <key>${vnfNetworkKey}_net_id</key> + <value>${vnfNetworkNeutronIdValue}</value> + </entry>""" + vnfNetworkNetId = sbNet.append(vnfNetworkNetIdXml) + String vnfNetworkNetNameXml = + """<entry> + <key>${vnfNetworkKey}_net_name</key> + <value>${vnfNetworkNetNameValue}</value> + </entry>""" + vnfNetworkNetName = sbNet2.append(vnfNetworkNetNameXml) + String vnfNetworkSubNetIdXml = + """<entry> + <key>${vnfNetworkKey}_subnet_id</key> + <value>${vnfNetworkSubNetIdValue}</value> + </entry>""" + vnfNetworkSubNetId = sbNet3.append(vnfNetworkSubNetIdXml) + String vnfNetworkV6SubNetIdXml = + """<entry> + <key>${vnfNetworkKey}_v6_subnet_id</key> + <value>${vnfNetworkV6SubNetIdValue}</value> + </entry>""" + vnfNetworkV6SubNetId = sbNet5.append(vnfNetworkV6SubNetIdXml) + String vnfNetworkNetFqdnXml = + """<entry> + <key>${vnfNetworkKey}_net_fqdn</key> + <value>${vnfNetworkNetFqdnValue}</value> + </entry>""" + vnfNetworkNetFqdn = sbNet4.append(vnfNetworkNetFqdnXml) + + NodeList sriovVlanFilterList = eElement.getElementsByTagNameNS("*","sriov-vlan-filter-list") + StringBuffer sriovFilterBuf = new StringBuffer() + String values = "" + for(int i = 0; i < sriovVlanFilterList.getLength(); i++){ + Node node1 = sriovVlanFilterList.item(i) + if (node1.getNodeType() == Node.ELEMENT_NODE) { + Element eElement1 = (Element) node1 + String value = utils.getElementText(eElement1, "sriov-vlan-filter") + if (i != sriovVlanFilterList.getLength() - 1) { + values = sriovFilterBuf.append(value + ",") + } + else { + values = sriovFilterBuf.append(value); + } + } + } + if (!values.isEmpty()) { + String vnfNetworkSriovVlanFilterXml = + """<entry> + <key>${vnfNetworkKey}_ATT_VF_VLAN_FILTER</key> + <value>${values}</value> + </entry>""" + vnfNetworksSriovVlanFilters = sbNet6.append(vnfNetworkSriovVlanFilterXml) + } + } + } + + // VNF-VMS Data + String vnfVMS = "" + String vnfVMSPositions = "" + String vmNetworks = "" + String vmNetworksPositions = "" + String vmNetworksPositionsV6 = "" + String interfaceRoutePrefixes = "" + def key + def value + def networkKey + def networkValue + def floatingIPKey + def floatingIPKeyValue + def floatingIPV6Key + def floatingIPV6KeyValue + StringBuilder sb = new StringBuilder() + StringBuilder sbPositions = new StringBuilder() + StringBuilder sbVmNetworks = new StringBuilder() + StringBuilder sbNetworksPositions = new StringBuilder() + StringBuilder sbInterfaceRoutePrefixes = new StringBuilder() + StringBuilder sbNetworksPositionsV6 = new StringBuilder() + + NodeList vmsList = responseXml.getElementsByTagNameNS("*","vnf-vms") + for (int x = 0; x < vmsList.getLength(); x++) { + Node node = vmsList.item(x) + if (node.getNodeType() == Node.ELEMENT_NODE) { + Element eElement = (Element) node + key = utils.getElementText(eElement, "vm-type") + String values + String position = "0" + StringBuilder sb1 = new StringBuilder() + NodeList valueList = eElement.getElementsByTagNameNS("*","vm-names") + NodeList vmNetworksList = eElement.getElementsByTagNameNS("*","vm-networks") + for(int i = 0; i < valueList.getLength(); i++){ + Node node1 = valueList.item(i) + if (node1.getNodeType() == Node.ELEMENT_NODE) { + Element eElement1 = (Element) node1 + value = utils.getElementText(eElement1, "vm-name") + if (i != valueList.getLength() - 1) { + values = sb1.append(value + ",") + } + else { + values = sb1.append(value); + } + position = i.toString() + String vnfPositionXml = + """<entry> + <key>${key}_name_${position}</key> + <value>${value}</value> + </entry>""" + vnfVMSPositions = sbPositions.append(vnfPositionXml) + } + } + for(int n = 0; n < vmNetworksList.getLength(); n++){ + String floatingIpKeyValueStr = "" + String floatingIpV6KeyValueStr = "" + Node nodeNetworkKey = vmNetworksList.item(n) + if (nodeNetworkKey.getNodeType() == Node.ELEMENT_NODE) { + Element eElementNetworkKey = (Element) nodeNetworkKey + String ipAddressValues + String ipV6AddressValues + String networkPosition = "0" + StringBuilder sb2 = new StringBuilder() + StringBuilder sb3 = new StringBuilder() + StringBuilder sb4 = new StringBuilder() + networkKey = utils.getElementText(eElementNetworkKey, "network-role") + floatingIPKey = key + '_' + networkKey + '_floating_ip' + floatingIPKeyValue = utils.getElementText(eElementNetworkKey, "floating-ip") + if(!floatingIPKeyValue.isEmpty()){ + floatingIpKeyValueStr = """<entry> + <key>$floatingIPKey</key> + <value>$floatingIPKeyValue</value> + </entry>""" + } + floatingIPV6Key = key + '_' + networkKey + '_floating_v6_ip' + floatingIPV6KeyValue = utils.getElementText(eElementNetworkKey, "floating-ip-v6") + if(!floatingIPV6KeyValue.isEmpty()){ + floatingIpV6KeyValueStr = """<entry> + <key>$floatingIPV6Key</key> + <value>$floatingIPV6KeyValue</value> + </entry>""" + } + NodeList networkIpsList = eElementNetworkKey.getElementsByTagNameNS("*","network-ips") + for(int a = 0; a < networkIpsList.getLength(); a++){ + Node ipAddress = networkIpsList.item(a) + if (ipAddress.getNodeType() == Node.ELEMENT_NODE) { + Element eElementIpAddress = (Element) ipAddress + String ipAddressValue = utils.getElementText(eElementIpAddress, "ip-address") + if (a != networkIpsList.getLength() - 1) { + ipAddressValues = sb2.append(ipAddressValue + ",") + } + else { + ipAddressValues = sb2.append(ipAddressValue); + } + networkPosition = a.toString() + String vmNetworksPositionsXml = + """<entry> + <key>${key}_${networkKey}_ip_${networkPosition}</key> + <value>${ipAddressValue}</value> + </entry>""" + vmNetworksPositions = sbNetworksPositions.append(vmNetworksPositionsXml) + } + } + vmNetworksPositions = sbNetworksPositions.append(floatingIpKeyValueStr).append(floatingIpV6KeyValueStr) + + String vmNetworksXml = + """<entry> + <key>${key}_${networkKey}_ips</key> + <value>${ipAddressValues}</value> + </entry>""" + vmNetworks = sbVmNetworks.append(vmNetworksXml) + + NodeList interfaceRoutePrefixesList = eElementNetworkKey.getElementsByTagNameNS("*","interface-route-prefixes") + String interfaceRoutePrefixValues = sb3.append("[") + + for(int a = 0; a < interfaceRoutePrefixesList.getLength(); a++){ + Node interfaceRoutePrefix = interfaceRoutePrefixesList.item(a) + if (interfaceRoutePrefix.getNodeType() == Node.ELEMENT_NODE) { + Element eElementInterfaceRoutePrefix = (Element) interfaceRoutePrefix + String interfaceRoutePrefixValue = utils.getElementText(eElementInterfaceRoutePrefix, "interface-route-prefix-cidr") + if (interfaceRoutePrefixValue == null || interfaceRoutePrefixValue.isEmpty()) { + interfaceRoutePrefixValue = utils.getElementText(eElementInterfaceRoutePrefix, "interface-route-prefix") + } + if (a != interfaceRoutePrefixesList.getLength() - 1) { + interfaceRoutePrefixValues = sb3.append("{\"interface_route_table_routes_route_prefix\": \"" + interfaceRoutePrefixValue + "\"}" + ",") + } + else { + interfaceRoutePrefixValues = sb3.append("{\"interface_route_table_routes_route_prefix\": \"" + interfaceRoutePrefixValue + "\"}") + } + } + } + interfaceRoutePrefixValues = sb3.append("]") + if (interfaceRoutePrefixesList.getLength() > 0) { + String interfaceRoutePrefixesXml = + """<entry> + <key>${key}_${networkKey}_route_prefixes</key> + <value>${interfaceRoutePrefixValues}</value> + </entry>""" + interfaceRoutePrefixes = sbInterfaceRoutePrefixes.append(interfaceRoutePrefixesXml) + } + + NodeList networkIpsV6List = eElementNetworkKey.getElementsByTagNameNS("*","network-ips-v6") + for(int a = 0; a < networkIpsV6List.getLength(); a++){ + Node ipV6Address = networkIpsV6List.item(a) + if (ipV6Address.getNodeType() == Node.ELEMENT_NODE) { + Element eElementIpV6Address = (Element) ipV6Address + String ipV6AddressValue = utils.getElementText(eElementIpV6Address, "ip-address-ipv6") + if (a != networkIpsV6List.getLength() - 1) { + ipV6AddressValues = sb4.append(ipV6AddressValue + ",") + } + else { + ipV6AddressValues = sb4.append(ipV6AddressValue); + } + networkPosition = a.toString() + String vmNetworksPositionsV6Xml = + """<entry> + <key>${key}_${networkKey}_v6_ip_${networkPosition}</key> + <value>${ipV6AddressValue}</value> + </entry>""" + vmNetworksPositionsV6 = sbNetworksPositionsV6.append(vmNetworksPositionsV6Xml) + } + } + String vmNetworksV6Xml = + """<entry> + <key>${key}_${networkKey}_v6_ips</key> + <value>${ipV6AddressValues}</value> + </entry>""" + vmNetworks = sbVmNetworks.append(vmNetworksV6Xml) + } + } + String vnfXml = + """<entry> + <key>${key}_names</key> + <value>${values}</value> + </entry>""" + vnfVMS = sb.append(vnfXml) + } + } + //SDNC Response Params + String sdncResponseParams = "" + List<String> sdncResponseParamsToSkip = ["vnf_id", "vf_module_id", "vnf_name", "vf_module_name"] + String vnfParamsChildNodes = utils.getChildNodes(data, "vnf-parameters") + if(vnfParamsChildNodes == null || vnfParamsChildNodes.length() < 1){ + // No SDNC params + }else{ + NodeList paramsList = responseXml.getElementsByTagNameNS("*", "vnf-parameters") + for (int z = 0; z < paramsList.getLength(); z++) { + Node node = paramsList.item(z) + Element eElement = (Element) node + String vnfParameterName = utils.getElementText(eElement, "vnf-parameter-name") + if (!sdncResponseParamsToSkip.contains(vnfParameterName)) { + String vnfParameterValue = utils.getElementText(eElement, "vnf-parameter-value") + String paraEntry = + """<entry> + <key>${vnfParameterName}</key> + <value>${vnfParameterValue}</value> + </entry>""" + sdncResponseParams = sb.append(paraEntry) + } + } + } + + + def vfModuleParams = """ + ${vnfInfo} + ${aZones} + ${vnfNetworkNetId} + ${vnfNetworkNetName} + ${vnfNetworkSubNetId} + ${vnfNetworkV6SubNetId} + ${vnfNetworkNetFqdn} + ${vnfNetworksSriovVlanFilters} + ${vnfVMS} + ${vnfVMSPositions} + ${vmNetworks} + ${vmNetworksPositions} + ${vmNetworksPositionsV6} + ${interfaceRoutePrefixes} + ${vnfParams} + ${sdncResponseParams}""" + + return vfModuleParams + + } + + +} diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/VidUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/VidUtils.groovy new file mode 100644 index 0000000000..de59c68a7d --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/VidUtils.groovy @@ -0,0 +1,550 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common.scripts + +import groovy.json.JsonBuilder +import groovy.json.JsonSlurper + +import org.json.JSONObject +import org.json.XML +import org.openecomp.mso.bpmn.core.xml.XmlTool + +class VidUtils { + + public MsoUtils utils = new MsoUtils() + private AbstractServiceTaskProcessor taskProcessor + + public VidUtils(AbstractServiceTaskProcessor taskProcessor) { + this.taskProcessor = taskProcessor + } + + /** + * Create a volume-request XML using a JSON string + * @param jsonReq - JSON request from VID + * @param action + * @return + */ + public String createXmlVolumeRequest(String jsonReq, String action, String serviceInstanceId) { + def jsonSlurper = new JsonSlurper() + try{ + Map reqMap = jsonSlurper.parseText(jsonReq) + return createXmlVolumeRequest(reqMap, action, serviceInstanceId) + } + catch(Exception e) { + throw e + } + } + + /** + * Create a volume-request XML using a map + * @param requestMap - map created from VID JSON + * @param action + * @param serviceInstanceId + * @return + */ + public String createXmlVolumeRequest(Map requestMap, String action, String serviceInstanceId) { + createXmlVolumeRequest(requestMap, action, serviceInstanceId, '') + } + + + /** + * Create a volume-request XML using a map + * @param requestMap + * @param action + * @param serviceInstanceId + * @param volumeGroupId + * @return + */ + public String createXmlVolumeRequest(Map requestMap, String action, String serviceInstanceId, String volumeGroupId) { + def vnfType = '' + def serviceName = '' + def modelCustomizationName = '' + def asdcServiceModelVersion = '' + + def suppressRollback = requestMap.requestDetails.requestInfo.suppressRollback + + def backoutOnFailure = "" + if(suppressRollback != null){ + if ( suppressRollback == true) { + backoutOnFailure = "false" + } else if ( suppressRollback == false) { + backoutOnFailure = "true" + } + } + + def volGrpName = requestMap.requestDetails.requestInfo?.instanceName ?: '' + def serviceId = requestMap.requestDetails.requestParameters?.serviceId ?: '' + def relatedInstanceList = requestMap.requestDetails.relatedInstanceList + relatedInstanceList.each { + if (it.relatedInstance.modelInfo?.modelType == 'service') { + serviceName = it.relatedInstance.modelInfo?.modelName + asdcServiceModelVersion = it.relatedInstance.modelInfo?.modelVersion + } + if (it.relatedInstance.modelInfo?.modelType == 'vnf') { + modelCustomizationName = it.relatedInstance.modelInfo?.modelCustomizationName + } + } + + vnfType = serviceName + '/' + modelCustomizationName + + def userParams = requestMap.requestDetails?.requestParameters?.userParams + def userParamsNode = '' + if(userParams != null) { + userParamsNode = buildUserParams(userParams) + } + def modelCustomizationId = requestMap.requestDetails?.modelInfo?.modelCustomizationId ?: '' + + def xmlReq = """ + <volume-request xmlns="http://www.w3.org/2001/XMLSchema"> + <request-info> + <action>${action}</action> + <source>${requestMap.requestDetails.requestInfo.source}</source> + <service-instance-id>${serviceInstanceId}</service-instance-id> + </request-info> + <volume-inputs> + <volume-group-id>${volumeGroupId}</volume-group-id> + <volume-group-name>${volGrpName}</volume-group-name> + <vnf-type>${vnfType}</vnf-type> + <vf-module-model-name>${requestMap.requestDetails.modelInfo.modelName}</vf-module-model-name> + <asdc-service-model-version>${asdcServiceModelVersion}</asdc-service-model-version> + <aic-cloud-region>${requestMap.requestDetails.cloudConfiguration.lcpCloudRegionId}</aic-cloud-region> + <tenant-id>${requestMap.requestDetails.cloudConfiguration.tenantId}</tenant-id> + <service-id>${serviceId}</service-id> + <backout-on-failure>${backoutOnFailure}</backout-on-failure> + <model-customization-id>${modelCustomizationId}</model-customization-id> + </volume-inputs> + <volume-params> + $userParamsNode + </volume-params> + </volume-request> + """ + // return a pretty-print of the volume-request xml without the preamble + return groovy.xml.XmlUtil.serialize(xmlReq.normalize().replaceAll("\t", "").replaceAll("\n", "")).replaceAll("(<\\?[^<]*\\?>\\s*[\\r\\n]*)?", "") + } + + /** + * A common method that can be used to build volume-params node from a map. + * @param Map userParams + * @return + */ + public String buildUserParams(userParams) { + if (userParams == null) return "" + def xml = "" + def key = "" + def value = "" + userParams.each {it -> + key = it.name.replaceAll(/\B[A-Z]/) { '_' + it }.toLowerCase() + value = it.value + xml += "<param name=\"${key}\">${value}</param>" + } + + return xml + } + + /** + * A common method that can be used to extract 'requestDetails' + * @param String json + * @return String json requestDetails + */ + @Deprecated + public getJsonRequestDetails(String jsonInput) { + String rtn = "" + if (jsonInput.isEmpty() || jsonInput == null) { + return rtn + } else { + def jsonMapObject = new JsonSlurper().parseText(jsonInput) + if (jsonMapObject instanceof Map) { + String jsonString = new JsonBuilder(jsonMapObject.requestDetails) + rtn = '{'+"requestDetails"+":"+jsonString+'}' + return rtn + } else { + return rtn + } + } + } + + /** + * A common method that can be used to extract 'requestDetails' in Xml + * @param String json + * @return String xml requestDetails + */ + @Deprecated + public getJsonRequestDetailstoXml(String jsonInput) { + String rtn = null + def jsonString = getJsonRequestDetails(jsonInput) + if (jsonString == null) { + return rtn + } else { + JSONObject jsonObj = new JSONObject(jsonString) + return XmlTool.normalize(XML.toString(jsonObj)) + } + } + + /** + * Create a network-request XML using a map + * @param execution + * @param xmlRequestDetails - requestDetails in xml + * @return + * Note: See latest version: createXmlNetworkRequestInstance() + */ + public String createXmlNetworkRequestInfra(execution, def networkJsonIncoming) { + + def requestId = execution.getVariable("requestId") + def serviceInstanceId = execution.getVariable("serviceInstanceId") + def requestAction = execution.getVariable("requestAction") + def networkId = (execution.getVariable("networkId")) != null ? execution.getVariable("networkId") : "" + + def jsonSlurper = new JsonSlurper() + try { + Map reqMap = jsonSlurper.parseText(networkJsonIncoming) + def instanceName = reqMap.requestDetails.requestInfo.instanceName + def modelName = reqMap.requestDetails.modelInfo.modelName + def lcpCloudRegionId = reqMap.requestDetails.cloudConfiguration.lcpCloudRegionId + def tenantId = reqMap.requestDetails.cloudConfiguration.tenantId + def serviceId = reqMap.requestDetails.requestInfo.productFamilyId + def suppressRollback = reqMap.requestDetails.requestInfo.suppressRollback.toString() + def backoutOnFailure = "" + if(suppressRollback != null){ + if (suppressRollback == true || suppressRollback == "true") { + backoutOnFailure = "false" + } else if (suppressRollback == false || suppressRollback == "false") { + backoutOnFailure = "true" + } + } + + //def userParams = reqMap.requestDetails.requestParameters.userParams + //def userParamsNode = buildUserParams(userParams) + def userParams = reqMap.requestDetails?.requestParameters?.userParams + def userParamsNode = '' + if(userParams != null) { + userParamsNode = buildUserParams(userParams) + } + + //'sdncVersion' = current, '1610' (non-RPC SDNC) or '1702' (RPC SDNC) + def sdncVersion = execution.getVariable("sdncVersion") + + def xmlReq = """ + <network-request xmlns="http://www.w3.org/2001/XMLSchema"> + <request-info> + <request-id>${requestId}</request-id> + <action>${requestAction}</action> + <source>VID</source> + <service-instance-id>${serviceInstanceId}</service-instance-id> + </request-info> + <network-inputs> + <network-id>${networkId}</network-id> + <network-name>${instanceName}</network-name> + <network-type>${modelName}</network-type> + <aic-cloud-region>${lcpCloudRegionId}</aic-cloud-region> + <tenant-id>${tenantId}</tenant-id> + <service-id>${serviceId}</service-id> + <backout-on-failure>${backoutOnFailure}</backout-on-failure> + <sdncVersion>${sdncVersion}</sdncVersion> + </network-inputs> + <network-params> + ${userParamsNode} + </network-params> + </network-request> + """ + // return a pretty-print of the volume-request xml without the preamble + return groovy.xml.XmlUtil.serialize(xmlReq.normalize().replaceAll("\t", "").replaceAll("\n", "")).replaceAll("(<\\?[^<]*\\?>\\s*[\\r\\n]*)?", "") + + } catch(Exception e) { + throw e + } + } + + /** + * Create a network-request XML using a map, + * @param execution + * @return + */ + public String createXmlNetworkRequestInstance(execution) { + + def networkModelVersionId = "" + def networkModelName = "" + def networkModelType = "" + def networkModelVersion = "" + def networkModelCustomizationId = "" + def networkModelInvariantId = "" + + // verify the DB Catalog response JSON structure + def networkModelInfo = execution.getVariable("networkModelInfo") + def jsonSlurper = new JsonSlurper() + if (networkModelInfo != null) { + try { + Map modelMap = jsonSlurper.parseText(networkModelInfo) + if (modelMap != null) { + if (networkModelInfo.contains("modelVersionId")) { + networkModelVersionId = modelMap.modelVersionId !=null ? modelMap.modelVersionId : "" + } + if (networkModelInfo.contains("modelName")) { + networkModelName = modelMap.modelName !=null ? modelMap.modelName : "" + } + if (networkModelInfo.contains("modelType")) { + networkModelType = modelMap.modelType !=null ? modelMap.modelType : "" + } + if (networkModelInfo.contains("modelVersion")) { + networkModelVersion = modelMap.modelVersion !=null ? modelMap.modelVersion : "" + } + if (networkModelInfo.contains("modelCustomizationId")) { + networkModelCustomizationId = modelMap.modelCustomizationId !=null ? modelMap.modelCustomizationId : "" + } + if (networkModelInfo.contains("modelInvariantId")) { + networkModelInvariantId = modelMap.modelInvariantId !=null ? modelMap.modelInvariantId : "" + } + } + } catch (Exception ex) { + throw ex + } + } + + def serviceModelVersionId = "" + def serviceModelName = "" + def serviceModelType = "" + def serviceModelVersion = "" + def serviceModelCustomizationId = "" + def serviceModelInvariantId = "" + + // verify the DB Catalog response JSON structure + def serviceModelInfo = execution.getVariable("serviceModelInfo") + def jsonServiceSlurper = new JsonSlurper() + if (serviceModelInfo != null) { + try { + Map modelMap = jsonServiceSlurper.parseText(serviceModelInfo) + if (modelMap != null) { + if (serviceModelInfo.contains("modelVersionId")) { + serviceModelVersionId = modelMap.modelVersionId !=null ? modelMap.modelVersionId : "" + } + if (serviceModelInfo.contains("modelName")) { + serviceModelName = modelMap.modelName !=null ? modelMap.modelName : "" + } + if (serviceModelInfo.contains("modelType")) { + serviceModelType = modelMap.modelType !=null ? modelMap.modelType : "" + } + if (serviceModelInfo.contains("modelVersion")) { + serviceModelVersion = modelMap.modelVersion !=null ? modelMap.modelVersion : "" + } + if (serviceModelInfo.contains("modelCustomizationId")) { + serviceModelCustomizationId = modelMap.modelCustomizationId !=null ? modelMap.modelCustomizationId : "" + } + if (serviceModelInfo.contains("modelInvariantId")) { + serviceModelInvariantId = modelMap.modelInvariantId !=null ? modelMap.modelInvariantId : "" + } + } + } catch (Exception ex) { + throw ex + } + } + + + def subscriptionServiceType = execution.getVariable("subscriptionServiceType") != null ? execution.getVariable("subscriptionServiceType") : "" + def globalSubscriberId = execution.getVariable("globalSubscriberId") != null ? execution.getVariable("globalSubscriberId") : "" + def requestId = execution.getVariable("msoRequestId") + def serviceInstanceId = execution.getVariable("serviceInstanceId") != null ? execution.getVariable("serviceInstanceId") : "" + def networkId = (execution.getVariable("networkId")) != null ? execution.getVariable("networkId") : "" // optional + def networkName = execution.getVariable("networkName") != null ? execution.getVariable("networkName") : "" // optional + def aicCloudReqion = execution.getVariable("lcpCloudRegionId") != null ? execution.getVariable("lcpCloudRegionId") : "" + def tenantId = execution.getVariable("tenantId") != null ? execution.getVariable("tenantId") : "" + def serviceId = execution.getVariable("productFamilyId") != null ? execution.getVariable("productFamilyId") : "" + def failIfExist = execution.getVariable("failIfExists") != null ? execution.getVariable("failIfExists") : "" + def suppressRollback = execution.getVariable("disableRollback") + def backoutOnFailure = "" + if(suppressRollback != null){ + if (suppressRollback == true || suppressRollback == "true") { + backoutOnFailure = "false" + } else if (suppressRollback == false || suppressRollback == "'false") { + backoutOnFailure = "true" + } + } + + //'sdncVersion' = current, '1610' (non-RPC SDNC) or '1702' (RPC SDNC) + def sdncVersion = execution.getVariable("sdncVersion") + + def source = "VID" + def action = execution.getVariable("action") + + def userParamsNode = "" + def userParams = execution.getVariable("networkInputParams") + if(userParams != null) { + userParamsNode = buildUserParams(userParams) + } + + def xmlReq = """ + <network-request xmlns="http://www.w3.org/2001/XMLSchema"> + <request-info> + <request-id>${requestId}</request-id> + <action>${action}</action> + <source>${source}</source> + <service-instance-id>${serviceInstanceId}</service-instance-id> + </request-info> + <network-inputs> + <network-id>${networkId}</network-id> + <network-name>${networkName}</network-name> + <network-type>${networkModelType}</network-type> + <subscription-service-type>${subscriptionServiceType}</subscription-service-type> + <global-customer-id>${globalSubscriberId}</global-customer-id> + <aic-cloud-region>${aicCloudReqion}</aic-cloud-region> + <tenant-id>${tenantId}</tenant-id> + <service-id>${serviceId}</service-id> + <backout-on-failure>${backoutOnFailure}</backout-on-failure> + <failIfExist>${failIfExist}</failIfExist> + <networkModelInfo> + <modelName>${networkModelName}</modelName> + <modelUuid>${networkModelVersionId}</modelUuid> + <modelInvariantUuid>${networkModelInvariantId}</modelInvariantUuid> + <modelVersion>${networkModelVersion}</modelVersion> + <modelCustomizationUuid>${networkModelCustomizationId}</modelCustomizationUuid> + <modelType>${networkModelType}</modelType> + </networkModelInfo> + <serviceModelInfo> + <modelName>${serviceModelName}</modelName> + <modelUuid>${serviceModelVersionId}</modelUuid> + <modelInvariantUuid>${serviceModelInvariantId}</modelInvariantUuid> + <modelVersion>${serviceModelVersion}</modelVersion> + <modelCustomizationUuid>${serviceModelCustomizationId}</modelCustomizationUuid> + <modelType>${serviceModelType}</modelType> + </serviceModelInfo> + <sdncVersion>${sdncVersion}</sdncVersion> + </network-inputs> + <network-params> + ${userParamsNode} + </network-params> + </network-request> + """ + // return a pretty-print of the volume-request xml without the preamble + return groovy.xml.XmlUtil.serialize(xmlReq.normalize().replaceAll("\t", "").replaceAll("\n", "")).replaceAll("(<\\?[^<]*\\?>\\s*[\\r\\n]*)?", "") + + } + + /** + * Create a vnf-request XML using a map + * @param requestMap - map created from VID JSON + * @param action + * @return + */ + public String createXmlVfModuleRequest(execution, Map requestMap, String action, String serviceInstanceId) { + + //def relatedInstanceList = requestMap.requestDetails.relatedInstanceList + + //relatedInstanceList.each { + // if (it.relatedInstance.modelInfo.modelType == 'vnf') { + // vnfType = it.relatedInstance.modelInfo.modelName + // vnfId = it.relatedInstance.modelInfo.modelInvariantId + // } + //} + + def vnfName = '' + def asdcServiceModelInfo = '' + + def relatedInstanceList = requestMap.requestDetails?.relatedInstanceList + + + if (relatedInstanceList != null) { + relatedInstanceList.each { + if (it.relatedInstance.modelInfo?.modelType == 'service') { + asdcServiceModelInfo = it.relatedInstance.modelInfo?.modelVersion + } + if (it.relatedInstance.modelInfo.modelType == 'vnf') { + vnfName = it.relatedInstance.instanceName ?: '' + } + } + } + + def vnfType = execution.getVariable('vnfType') + def vnfId = execution.getVariable('vnfId') + + def vfModuleId = execution.getVariable('vfModuleId') + def volumeGroupId = execution.getVariable('volumeGroupId') + def userParams = requestMap.requestDetails?.requestParameters?.userParams + + + def userParamsNode = '' + if(userParams != null) { + userParamsNode = buildUserParams(userParams) + } + + def isBaseVfModule = "false" + if (execution.getVariable('isBaseVfModule') == true) { + isBaseVfModule = "true" + } + + def requestId = execution.getVariable("mso-request-id") + def vfModuleName = requestMap.requestDetails?.requestInfo?.instanceName ?: '' + def vfModuleModelName = requestMap.requestDetails?.modelInfo?.modelName ?: '' + def suppressRollback = requestMap.requestDetails?.requestInfo?.suppressRollback + + def backoutOnFailure = "" + if(suppressRollback != null){ + if ( suppressRollback == true) { + backoutOnFailure = "false" + } else if ( suppressRollback == false) { + backoutOnFailure = "true" + } + } + + def serviceId = requestMap.requestDetails?.requestParameters?.serviceId ?: '' + def aicCloudRegion = requestMap.requestDetails?.cloudConfiguration?.lcpCloudRegionId ?: '' + def tenantId = requestMap.requestDetails?.cloudConfiguration?.tenantId ?: '' + def personaModelId = requestMap.requestDetails?.modelInfo?.modelInvariantId ?: '' + def personaModelVersion = requestMap.requestDetails?.modelInfo?.modelVersion ?: '' + def modelCustomizationId = requestMap.requestDetails?.modelInfo?.modelCustomizationId ?: '' + + def xmlReq = """ + <vnf-request> + <request-info> + <request-id>${requestId}</request-id> + <action>${action}</action> + <source>VID</source> + <!-- new 1610 field --> + <service-instance-id>${serviceInstanceId}</service-instance-id> + </request-info> + <vnf-inputs> + <!-- not in use in 1610 --> + <vnf-name>${vnfName}</vnf-name> + <vnf-type>${vnfType}</vnf-type> + <vnf-id>${vnfId}</vnf-id> + <volume-group-id>${volumeGroupId}</volume-group-id> + <vf-module-id>${vfModuleId}</vf-module-id> + <vf-module-name>${vfModuleName}</vf-module-name> + <vf-module-model-name>${vfModuleModelName}</vf-module-model-name> + <model-customization-id>${modelCustomizationId}</model-customization-id> + <is-base-vf-module>${isBaseVfModule}</is-base-vf-module> + <asdc-service-model-version>${asdcServiceModelInfo}</asdc-service-model-version> + <aic-cloud-region>${aicCloudRegion}</aic-cloud-region> + <tenant-id>${tenantId}</tenant-id> + <service-id>${serviceId}</service-id> + <backout-on-failure>${backoutOnFailure}</backout-on-failure> + <persona-model-id>${personaModelId}</persona-model-id> + <persona-model-version>${personaModelVersion}</persona-model-version> + </vnf-inputs> + <vnf-params> + $userParamsNode + </vnf-params> + </vnf-request> + """ + + // return a pretty-print of the volume-request xml without the preamble + return groovy.xml.XmlUtil.serialize(xmlReq.normalize().replaceAll("\t", "").replaceAll("\n", "")).replaceAll("(<\\?[^<]*\\?>\\s*[\\r\\n]*)?", "") + } + + +} diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/VnfAdapterRestV1.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/VnfAdapterRestV1.groovy new file mode 100644 index 0000000000..31c5596cbb --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/VnfAdapterRestV1.groovy @@ -0,0 +1,404 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common.scripts + +import org.apache.commons.lang3.* +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.runtime.Execution +import org.openecomp.mso.rest.APIResponse +import org.openecomp.mso.rest.RESTClient +import org.openecomp.mso.rest.RESTConfig + +class VnfAdapterRestV1 extends AbstractServiceTaskProcessor { + + ExceptionUtil exceptionUtil = new ExceptionUtil() + + // VNF Response Processing + public void preProcessRequest (Execution execution) { + def method = getClass().getSimpleName() + '.preProcessRequest(' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logDebug('Entered ' + method, isDebugLogEnabled) + + def prefix="VNFREST_" + execution.setVariable("prefix", prefix) + setSuccessIndicator(execution, false) + + try { + String request = validateRequest(execution, "mso-request-id") + + // Get the request type (the name of the root element) from the request + + Node root = new XmlParser().parseText(request) + String requestType = root.name() + execution.setVariable(prefix + 'requestType', requestType) + logDebug(getProcessKey(execution) + ': ' + prefix + 'requestType = ' + requestType, isDebugLogEnabled) + + utils.logAudit('VnfAdapterRestV1, request: ' + request) + // Get the messageId from the request + + String messageId = getChildText(root, 'messageId') + + if (messageId == null || messageId.isEmpty()) { + String msg = getProcessKey(execution) + ': no messageId in ' + requestType + logError(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) + } + + execution.setVariable('VNFAResponse_CORRELATOR', messageId) + logDebug(getProcessKey(execution) + ': VNFAResponse_CORRELATOR = ' + messageId, isDebugLogEnabled) + + // Get the notificationUrl from the request + + String notificationUrl = getChildText(root, 'notificationUrl') + + if (notificationUrl == null || notificationUrl.isEmpty()) { + String msg = getProcessKey(execution) + ': no notificationUrl in ' + requestType + logError(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) + } + + execution.setVariable(prefix + 'notificationUrl', notificationUrl) + logDebug(getProcessKey(execution) + ': ' + prefix + 'notificationUrl = ' + notificationUrl, isDebugLogEnabled) + + // Determine the VnfAdapter endpoint + + String vnfAdapterEndpoint = execution.getVariable("URN_mso_adapters_vnf_rest_endpoint") + + if (vnfAdapterEndpoint == null || vnfAdapterEndpoint.isEmpty()) { + String msg = getProcessKey(execution) + ': mso:adapters:vnf:rest:endpoint URN mapping is not defined' + logError(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) + } + + while (vnfAdapterEndpoint.endsWith('/')) { + vnfAdapterEndpoint = vnfAdapterEndpoint.substring(0, vnfAdapterEndpoint.length()-1) + } + + String vnfAdapterMethod = null + String vnfAdapterUrl = null + String vnfAdapterRequest = request + + if ('createVfModuleRequest'.equals(requestType)) { + String vnfId = getChildText(root, 'vnfId') + + if (vnfId == null || vnfId.isEmpty()) { + String msg = getProcessKey(execution) + ': no vnfId in ' + requestType + logError(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) + } + + vnfAdapterMethod = 'POST' + vnfAdapterUrl = vnfAdapterEndpoint + '/' + URLEncoder.encode(vnfId, 'UTF-8') + '/vf-modules' + + } else if ('updateVfModuleRequest'.equals(requestType)) { + String vnfId = getChildText(root, 'vnfId') + + if (vnfId == null || vnfId.isEmpty()) { + String msg = getProcessKey(execution) + ': no vnfId in ' + requestType + logError(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) + } + + String vfModuleId = getChildText(root, 'vfModuleId') + + if (vfModuleId == null || vfModuleId.isEmpty()) { + String msg = getProcessKey(execution) + ': no vfModuleId in ' + requestType + logError(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) + } + + vnfAdapterMethod = 'PUT' + vnfAdapterUrl = vnfAdapterEndpoint + '/' + URLEncoder.encode(vnfId, 'UTF-8') + + '/vf-modules/' + URLEncoder.encode(vfModuleId, 'UTF-8') + + } else if ('deleteVfModuleRequest'.equals(requestType)) { + String vnfId = getChildText(root, 'vnfId') + + if (vnfId == null || vnfId.isEmpty()) { + String msg = getProcessKey(execution) + ': no vnfId in ' + requestType + logError(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) + } + + String vfModuleId = getChildText(root, 'vfModuleId') + + if (vfModuleId == null || vfModuleId.isEmpty()) { + String msg = getProcessKey(execution) + ': no vfModuleId in ' + requestType + logError(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) + } + + vnfAdapterMethod = 'DELETE' + vnfAdapterUrl = vnfAdapterEndpoint + '/' + URLEncoder.encode(vnfId, 'UTF-8') + + '/vf-modules/' + URLEncoder.encode(vfModuleId, 'UTF-8') + + } else if ('rollbackVfModuleRequest'.equals(requestType)) { + Node vfModuleRollbackNode = getChild(root, 'vfModuleRollback') + + if (vfModuleRollbackNode == null) { + String msg = getProcessKey(execution) + ': no vfModuleRollback in ' + requestType + logError(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) + } + + String vnfId = getChildText(vfModuleRollbackNode, 'vnfId') + + if (vnfId == null || vnfId.isEmpty()) { + String msg = getProcessKey(execution) + ': no vnfId in ' + requestType + logError(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) + } + + String vfModuleId = getChildText(vfModuleRollbackNode, 'vfModuleId') + + if (vfModuleId == null || vfModuleId.isEmpty()) { + String msg = getProcessKey(execution) + ': no vfModuleId in ' + requestType + logError(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) + } + + vnfAdapterMethod = 'DELETE' + vnfAdapterUrl = vnfAdapterEndpoint + '/' + URLEncoder.encode(vnfId, 'UTF-8') + + '/vf-modules/' + URLEncoder.encode(vfModuleId, 'UTF-8') + '/rollback' + + } else if ('createVolumeGroupRequest'.equals(requestType)) { + vnfAdapterMethod = 'POST' + if (vnfAdapterEndpoint.endsWith('v1/vnfs')) { + vnfAdapterEndpoint = vnfAdapterEndpoint.substring(0, (vnfAdapterEndpoint.length()-'/vnfs'.length())) + } + vnfAdapterUrl = vnfAdapterEndpoint + '/volume-groups' + + } else if ('updateVolumeGroupRequest'.equals(requestType)) { + String volumeGroupId = getChildText(root, 'volumeGroupId') + + if (volumeGroupId == null || volumeGroupId.isEmpty()) { + String msg = getProcessKey(execution) + ': no volumeGroupId in ' + requestType + logError(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) + } + + vnfAdapterMethod = 'PUT' + if (vnfAdapterEndpoint.endsWith('v1/vnfs')) { + vnfAdapterEndpoint = vnfAdapterEndpoint.substring(0, (vnfAdapterEndpoint.length()-'/vnfs'.length())) + } + vnfAdapterUrl = vnfAdapterEndpoint + '/volume-groups/' + URLEncoder.encode(volumeGroupId, 'UTF-8') + + } else if ('deleteVolumeGroupRequest'.equals(requestType)) { + String volumeGroupId = getChildText(root, 'volumeGroupId') + + if (volumeGroupId == null || volumeGroupId.isEmpty()) { + String msg = getProcessKey(execution) + ': no volumeGroupId in ' + requestType + logError(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) + } + + vnfAdapterMethod = 'DELETE' + if (vnfAdapterEndpoint.endsWith('v1/vnfs')) { + vnfAdapterEndpoint = vnfAdapterEndpoint.substring(0, (vnfAdapterEndpoint.length()-'/vnfs'.length())) + } + vnfAdapterUrl = vnfAdapterEndpoint + '/volume-groups/' + URLEncoder.encode(volumeGroupId, 'UTF-8') + + } else if ('rollbackVolumeGroupRequest'.equals(requestType)) { + String volumeGroupId = getChildText(root, 'volumeGroupId') + + if (volumeGroupId == null || volumeGroupId.isEmpty()) { + String msg = getProcessKey(execution) + ': no volumeGroupId in ' + requestType + logError(msg) + createWorkflowException(execution, 2000, msg) + } + + vnfAdapterMethod = 'DELETE' + if (vnfAdapterEndpoint.endsWith('v1/vnfs')) { + vnfAdapterEndpoint = vnfAdapterEndpoint.substring(0, (vnfAdapterEndpoint.length()-'/vnfs'.length())) + } + vnfAdapterUrl = vnfAdapterEndpoint + '/volume-groups/' + URLEncoder.encode(volumeGroupId, 'UTF-8') + '/rollback' + + } else { + String msg = getProcessKey(execution) + ': Unsupported request type: ' + requestType + logError(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) + } + + execution.setVariable(prefix + 'vnfAdapterMethod', vnfAdapterMethod) + logDebug(getProcessKey(execution) + ': ' + prefix + 'vnfAdapterMethod = ' + vnfAdapterMethod, isDebugLogEnabled) + execution.setVariable(prefix + 'vnfAdapterUrl', vnfAdapterUrl) + logDebug(getProcessKey(execution) + ': ' + prefix + 'vnfAdapterUrl = ' + vnfAdapterUrl, isDebugLogEnabled) + execution.setVariable(prefix + 'vnfAdapterRequest', vnfAdapterRequest) + logDebug(getProcessKey(execution) + ': ' + prefix + 'vnfAdapterRequest = \n' + vnfAdapterRequest, isDebugLogEnabled) + + // Get the Basic Auth credentials for the VnfAdapter + + String basicAuthValue = execution.getVariable("URN_mso_adapters_po_auth") + + if (basicAuthValue == null || basicAuthValue.isEmpty()) { + logError(getProcessKey(execution) + ": mso:adapters:po:auth URN mapping is not defined") + } else { + logDebug(getProcessKey(execution) + ": Obtained BasicAuth credentials for VnfAdapter:" + + basicAuthValue, isDebugLogEnabled) + try { + def encodedString = utils.getBasicAuth(basicAuthValue, execution.getVariable("URN_mso_msoKey")) + execution.setVariable(prefix + 'basicAuthHeaderValue', encodedString) + } catch (IOException ex) { + logError(getProcessKey(execution) + ": Unable to encode BasicAuth credentials for VnfAdapter") + } + } + + } catch (BpmnError e) { + logDebug(" Rethrowing MSOWorkflowException", isDebugLogEnabled) + throw e + } catch (Exception e) { + String msg = 'Caught exception in ' + method + ": " + e + logError(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) + } + } + + /** + * This method is used instead of an HTTP Connector task because the + * connector does not allow DELETE with a body. + */ + public void sendRequestToVnfAdapter(Execution execution) { + def method = getClass().getSimpleName() + '.sendRequestToVnfAdapter(' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logDebug('Entered ' + method, isDebugLogEnabled) + + String prefix = execution.getVariable('prefix') + + try { + String vnfAdapterMethod = execution.getVariable(prefix + 'vnfAdapterMethod') + String vnfAdapterUrl = execution.getVariable(prefix + 'vnfAdapterUrl') + String vnfAdapterRequest = execution.getVariable(prefix + 'vnfAdapterRequest') + + RESTConfig config = new RESTConfig(vnfAdapterUrl) + RESTClient client = new RESTClient(config). + addHeader("Content-Type", "application/xml"). + addAuthorizationHeader(execution.getVariable(prefix + "basicAuthHeaderValue")); + + APIResponse response; + + if ("GET".equals(vnfAdapterMethod)) { + response = client.httpGet() + } else if ("PUT".equals(vnfAdapterMethod)) { + response = client.httpPut(vnfAdapterRequest) + } else if ("POST".equals(vnfAdapterMethod)) { + response = client.httpPost(vnfAdapterRequest) + } else if ("DELETE".equals(vnfAdapterMethod)) { + response = client.httpDelete(vnfAdapterRequest) + } else { + String msg = 'Unsupported HTTP method "' + vnfAdapterMethod + '" in ' + method + ": " + e + logError(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) + } + + execution.setVariable(prefix + "vnfAdapterStatusCode", response.getStatusCode()) + execution.setVariable(prefix + "vnfAdapterResponse", response.getResponseBodyAsString()) + } catch (BpmnError e) { + throw e + } catch (Exception e) { + String msg = 'Caught exception in ' + method + ": " + e + logError(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) + } + } + + public void processCallback(Execution execution){ + def method = getClass().getSimpleName() + '.processCallback(' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logDebug('Entered ' + method, isDebugLogEnabled) + + String callback = execution.getVariable('VNFAResponse_MESSAGE') + + try { + logDebug(getProcessKey(execution) + ": received callback:\n" + callback, isDebugLogEnabled) + + // The XML callback is available to the calling flow in any case, + // even if a WorkflowException is generated. + execution.setVariable(getProcessKey(execution) + 'Response', callback) + // TODO: Should deprecate use of processKey+Response variable for the response. Will use "WorkflowResponse" instead. + execution.setVariable("WorkflowResponse", callback) + + Node root = new XmlParser().parseText(callback) + if (root.name().endsWith('Exception')) { + vnfAdapterWorkflowException(execution, callback) + } + } catch (Exception e) { + e.printStackTrace() + callback = callback == null || String.valueOf(callback).isEmpty() ? "NONE" : callback + String msg = "Received error from VnfAdapter: " + callback + logDebug(getProcessKey(execution) + ': ' + msg, isDebugLogEnabled) + exceptionUtil.buildWorkflowException(execution, 7020, 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 vnfAdapterWorkflowException(Execution execution, Object response) { + try { + Node root = new XmlParser().parseText(response) + String category = getChildText(root, "category") + category = category == null || category.isEmpty() ? "" : " category='" + category + "'" + String message = getChildText(root, "message") + message = message == null || message.isEmpty() ? "" : " message='" + message + "'" + String rolledBack = getChildText(root, "rolledBack") + rolledBack = rolledBack == null || rolledBack.isEmpty() ? "" : " rolledBack='" + rolledBack + "'" + exceptionUtil.buildWorkflowException(execution, 7020, "Received " + root.name() + + " from VnfAdapter:" + category + message + rolledBack); + } catch (Exception e) { + response = response == null || String.valueOf(response).isEmpty() ? "NONE" : response + exceptionUtil.buildWorkflowException(execution, 7020, "Received error from VnfAdapter: " + response) + } + } + + /** + * Gets the named child of the specified node. + * @param node the node + * @param name the child name + * @return the child node, or null if no such child exists + */ + private Node getChild(Node node, String name) { + for (Node child : node.children()) { + if (child.name() == name) { + return child + } + } + return null + } + + /** + * Gets the text of the named child of the specified node. + * @param node the node + * @param name the child name + * @return the child node text, or null if no such child exists + */ + private String getChildText(Node node, String name) { + Node child = getChild(node, name) + return child == null ? null : child.text() + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/VnfAdapterUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/VnfAdapterUtils.groovy new file mode 100644 index 0000000000..cd8d2a3374 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/VnfAdapterUtils.groovy @@ -0,0 +1,78 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.openecomp.mso.bpmn.common.scripts + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.runtime.Execution; +import org.openecomp.mso.bpmn.core.WorkflowException + +class VnfAdapterUtils { + + private AbstractServiceTaskProcessor taskProcessor + + public VnfAdapterUtils(AbstractServiceTaskProcessor taskProcessor) { + this.taskProcessor = taskProcessor + } + + ExceptionUtil exceptionUtil = new ExceptionUtil() + + public void validateVnfResponse(Execution execution, String responseVar, String responseCodeVar, String errorResponseVar) { + def method = getClass().getSimpleName() + '.validateVnfResponse(' + + 'execution=' + execution.getId() + + ', responseVar=' + responseVar + + ', responseCodeVar=' + responseCodeVar + + ', errorResponseVar=' + errorResponseVar + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + taskProcessor.logDebug('Entered ' + method, isDebugLogEnabled) + + try { + def prefix = execution.getVariable('prefix') + + def response = execution.getVariable(responseVar) + def responseCode = execution.getVariable(responseCodeVar) + def errorResponse = execution.getVariable(errorResponseVar) + + // The following if statement never appears to be true as any VNF Adapter error seems to be stored in 'errorResponse'. + // Also, the value is stored as a WorkflowException object, not a String. Added the else if to provide the proper + // functionality but leaving the original code in case it is hit under some circumstances. + if (response.contains("WorkflowException")) { + execution.setVariable(prefix + "ErrorResponse", response) + //execution.setVariable(prefix + "ResponseCode", responseCode) + taskProcessor.logDebug(" Sub Vnf flow Error WorkflowException Response - " + "\n" + response, isDebugLogEnabled) + throw new BpmnError("MSOWorkflowException") + } else if (errorResponse != null && errorResponse instanceof WorkflowException) { + // Not sure the variables with the associated prefix are still used + execution.setVariable(prefix + "ErrorResponse", errorResponse.getErrorMessage()) + execution.setVariable(prefix + "ResponseCode", errorResponse.getErrorCode()) + taskProcessor.logDebug("Sub Vnf flow Error WorkflowException " + prefix + "ErrorResponse" + " - " + + errorResponse.getErrorMessage(), isDebugLogEnabled) + // this is the important part to ensure we hit the Fallout Handler + throw new BpmnError("MSOWorkflowException") + } + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + taskProcessor.logError('Caught exception in ' + method, e) + taskProcessor.workflowException(execution, 'Internal Error- Unable to validate VNF Response ' + e.getMessage(), 500) + } + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/MSOCommonApplication.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/MSOCommonApplication.java new file mode 100644 index 0000000000..9931247885 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/MSOCommonApplication.java @@ -0,0 +1,59 @@ +package org.openecomp.mso.bpmn.common; +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + + + +import java.util.List; + +import org.camunda.bpm.application.PostDeploy; +import org.camunda.bpm.application.PreUndeploy; +import org.camunda.bpm.application.ProcessApplication; +import org.camunda.bpm.application.ProcessApplicationInfo; +import org.camunda.bpm.application.impl.ServletProcessApplication; +import org.camunda.bpm.engine.ProcessEngine; + +import org.openecomp.mso.logger.MsoLogger; + +/** + * @since Version 1.0 + * + */ +@ProcessApplication("MSO Common Application") +public class MSOCommonApplication extends ServletProcessApplication { + + private MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL); + + @PostDeploy + public void postDeploy(ProcessEngine processEngineInstance) { + long startTime = System.currentTimeMillis(); + + msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Post deployment complete..."); + } + + @PreUndeploy + public void cleanup(ProcessEngine processEngine, ProcessApplicationInfo processApplicationInfo, List<ProcessEngine> processEngines) { + long startTime = System.currentTimeMillis(); + + msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Pre Undeploy complete..."); + + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/sdnc/CallbackHeader.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/sdnc/CallbackHeader.java new file mode 100644 index 0000000000..031d963ff4 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/sdnc/CallbackHeader.java @@ -0,0 +1,139 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common.adapter.sdnc; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + + +/** + * <p>Java class for anonymous complex type. + * + * <p>The following schema fragment specifies the expected content contained within this class. + * + * <pre> + * <complexType> + * <complexContent> + * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> + * <sequence> + * <element name="RequestId" type="{http://www.w3.org/2001/XMLSchema}string"/> + * <element name="ResponseCode" type="{http://www.w3.org/2001/XMLSchema}string"/> + * <element name="ResponseMessage" type="{http://www.w3.org/2001/XMLSchema}string"/> + * </sequence> + * </restriction> + * </complexContent> + * </complexType> + * </pre> + * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "requestId", + "responseCode", + "responseMessage" +}, namespace="http://org.openecomp/workflow/sdnc/adapter/schema/v1") +@XmlRootElement(name = "CallbackHeader") +public class CallbackHeader { + + @XmlElement(name = "RequestId", required = true, namespace="http://org.openecomp/workflow/sdnc/adapter/schema/v1") + protected String requestId; + @XmlElement(name = "ResponseCode", required = true,namespace="http://org.openecomp/workflow/sdnc/adapter/schema/v1") + protected String responseCode; + @XmlElement(name = "ResponseMessage", required = true,namespace="http://org.openecomp/workflow/sdnc/adapter/schema/v1") + protected String responseMessage; + + /** + * Gets the value of the requestId property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getRequestId() { + return requestId; + } + + /** + * Sets the value of the requestId property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setRequestId(String value) { + this.requestId = value; + } + + /** + * Gets the value of the responseCode property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getResponseCode() { + return responseCode; + } + + /** + * Sets the value of the responseCode property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setResponseCode(String value) { + this.responseCode = value; + } + + /** + * Gets the value of the responseMessage property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getResponseMessage() { + return responseMessage; + } + + /** + * Sets the value of the responseMessage property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setResponseMessage(String value) { + this.responseMessage = value; + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/sdnc/ObjectFactory.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/sdnc/ObjectFactory.java new file mode 100644 index 0000000000..2e0ae1b930 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/sdnc/ObjectFactory.java @@ -0,0 +1,91 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common.adapter.sdnc; + +import javax.xml.bind.annotation.XmlRegistry; + + +/** + * This object contains factory methods for each + * Java content interface and Java element interface + * generated in the org.openecomp.domain2.workflow.sdnc.adapter.schema.v1 package. + * <p>An ObjectFactory allows you to programatically + * construct new instances of the Java representation + * for XML content. The Java representation of XML + * content can consist of schema derived interfaces + * and classes representing the binding of schema + * type definitions, element declarations and model + * groups. Factory methods for each of these are + * provided in this class. + * + */ +@XmlRegistry +public class ObjectFactory { + + + /** + * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: org.openecomp.domain2.workflow.sdnc.adapter.schema.v1 + * + */ + public ObjectFactory() { + } + + /** + * Create an instance of {@link RequestHeader } + * + */ + public RequestHeader createRequestHeader() { + return new RequestHeader(); + } + + /** + * Create an instance of {@link SDNCAdapterResponse } + * + */ + public SDNCAdapterResponse createSDNCAdapterResponse() { + return new SDNCAdapterResponse(); + } + + /** + * Create an instance of {@link SDNCAdapterCallbackRequest } + * + */ + public SDNCAdapterCallbackRequest createSDNCAdapterCallbackRequest() { + return new SDNCAdapterCallbackRequest(); + } + + /** + * Create an instance of {@link CallbackHeader } + * + */ + public CallbackHeader createCallbackHeader() { + return new CallbackHeader(); + } + + /** + * Create an instance of {@link SDNCAdapterRequest } + * + */ + public SDNCAdapterRequest createSDNCAdapterRequest() { + return new SDNCAdapterRequest(); + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/sdnc/RequestHeader.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/sdnc/RequestHeader.java new file mode 100644 index 0000000000..27b1245856 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/sdnc/RequestHeader.java @@ -0,0 +1,223 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common.adapter.sdnc; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + + +/** + * <p>Java class for anonymous complex type. + * + * <p>The following schema fragment specifies the expected content contained within this class. + * + * <pre> + * <complexType> + * <complexContent> + * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> + * <sequence> + * <element name="RequestId" type="{http://www.w3.org/2001/XMLSchema}string"/> + * <element name="SvcInstanceId" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> + * <element name="SvcAction" type="{http://www.w3.org/2001/XMLSchema}string"/> + * <element name="SvcOperation" type="{http://www.w3.org/2001/XMLSchema}string"/> + * <element name="CallbackUrl" type="{http://www.w3.org/2001/XMLSchema}string"/> + * <element name="MsoAction" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> + * </sequence> + * </restriction> + * </complexContent> + * </complexType> + * </pre> + * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "requestId", + "svcInstanceId", + "svcAction", + "svcOperation", + "callbackUrl", + "msoAction" +}) +@XmlRootElement(name = "RequestHeader") +public class RequestHeader { + + @XmlElement(name = "RequestId", required = true) + protected String requestId; + @XmlElement(name = "SvcInstanceId") + protected String svcInstanceId; + @XmlElement(name = "SvcAction", required = true) + protected String svcAction; + @XmlElement(name = "SvcOperation", required = true) + protected String svcOperation; + @XmlElement(name = "CallbackUrl", required = true) + protected String callbackUrl; + @XmlElement(name = "MsoAction") + protected String msoAction; + + /** + * Gets the value of the requestId property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getRequestId() { + return requestId; + } + + /** + * Sets the value of the requestId property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setRequestId(String value) { + this.requestId = value; + } + + /** + * Gets the value of the svcInstanceId property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getSvcInstanceId() { + return svcInstanceId; + } + + /** + * Sets the value of the svcInstanceId property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setSvcInstanceId(String value) { + this.svcInstanceId = value; + } + + /** + * Gets the value of the svcAction property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getSvcAction() { + return svcAction; + } + + /** + * Sets the value of the svcAction property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setSvcAction(String value) { + this.svcAction = value; + } + + /** + * Gets the value of the svcOperation property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getSvcOperation() { + return svcOperation; + } + + /** + * Sets the value of the svcOperation property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setSvcOperation(String value) { + this.svcOperation = value; + } + + /** + * Gets the value of the callbackUrl property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getCallbackUrl() { + return callbackUrl; + } + + /** + * Sets the value of the callbackUrl property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setCallbackUrl(String value) { + this.callbackUrl = value; + } + + /** + * Gets the value of the msoAction property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getMsoAction() { + return msoAction; + } + + /** + * Sets the value of the msoAction property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setMsoAction(String value) { + this.msoAction = value; + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/sdnc/SDNCAdapterCallbackRequest.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/sdnc/SDNCAdapterCallbackRequest.java new file mode 100644 index 0000000000..5abdbd667c --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/sdnc/SDNCAdapterCallbackRequest.java @@ -0,0 +1,129 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common.adapter.sdnc; + +import java.io.StringWriter; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Marshaller; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + + +/** + * <p>Java class for anonymous complex type. + * + * <p>The following schema fragment specifies the expected content contained within this class. + * + * <pre> + * <complexType> + * <complexContent> + * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> + * <sequence> + * <element ref="{http://org.openecomp/workflow/sdnc/adapter/schema/v1}CallbackHeader"/> + * <element name="RequestData" type="{http://www.w3.org/2001/XMLSchema}anyType" minOccurs="0"/> + * </sequence> + * </restriction> + * </complexContent> + * </complexType> + * </pre> + * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", namespace="http://org.openecomp/workflow/sdnc/adapter/schema/v1", propOrder = { + "callbackHeader", + "requestData" +}) +@XmlRootElement(name = "SDNCAdapterCallbackRequest", namespace="http://org.openecomp/workflow/sdnc/adapter/schema/v1") +public class SDNCAdapterCallbackRequest { + + @XmlElement(name = "CallbackHeader", required = true, namespace="http://org.openecomp/workflow/sdnc/adapter/schema/v1") + protected CallbackHeader callbackHeader; + @XmlElement(name = "RequestData", required=false, namespace="http://org.openecomp/workflow/sdnc/adapter/schema/v1") + protected Object requestData; + + /** + * Gets the value of the callbackHeader property. + * + * @return + * possible object is + * {@link CallbackHeader } + * + */ + public CallbackHeader getCallbackHeader() { + return callbackHeader; + } + + /** + * Sets the value of the callbackHeader property. + * + * @param value + * allowed object is + * {@link CallbackHeader } + * + */ + public void setCallbackHeader(CallbackHeader value) { + this.callbackHeader = value; + } + + /** + * Gets the value of the requestData property. + * + * @return + * possible object is + * {@link Object } + * + */ + public Object getRequestData() { + return requestData; + } + + /** + * Sets the value of the requestData property. + * + * @param value + * allowed object is + * {@link Object } + * + */ + public void setRequestData(Object value) { + this.requestData = value; + } + + public String toString() { + StringWriter writer = new StringWriter(); + try { + JAXBContext context = JAXBContext + .newInstance(SDNCAdapterCallbackRequest.class); + Marshaller m = context.createMarshaller(); + m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); + m.marshal(this, writer); + return writer.getBuffer().toString(); + } catch (JAXBException e) { + return ""; + } + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/sdnc/SDNCAdapterRequest.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/sdnc/SDNCAdapterRequest.java new file mode 100644 index 0000000000..1bcd053631 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/sdnc/SDNCAdapterRequest.java @@ -0,0 +1,111 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common.adapter.sdnc; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + + +/** + * <p>Java class for anonymous complex type. + * + * <p>The following schema fragment specifies the expected content contained within this class. + * + * <pre> + * <complexType> + * <complexContent> + * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> + * <sequence> + * <element ref="{http://org.openecomp/workflow/sdnc/adapter/schema/v1}RequestHeader"/> + * <element name="RequestData" type="{http://www.w3.org/2001/XMLSchema}anyType"/> + * </sequence> + * </restriction> + * </complexContent> + * </complexType> + * </pre> + * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "requestHeader", + "requestData" +}) +@XmlRootElement(name = "SDNCAdapterRequest") +public class SDNCAdapterRequest { + + @XmlElement(name = "RequestHeader", required = true) + protected RequestHeader requestHeader; + @XmlElement(name = "RequestData", required = true) + protected Object requestData; + + /** + * Gets the value of the requestHeader property. + * + * @return + * possible object is + * {@link RequestHeader } + * + */ + public RequestHeader getRequestHeader() { + return requestHeader; + } + + /** + * Sets the value of the requestHeader property. + * + * @param value + * allowed object is + * {@link RequestHeader } + * + */ + public void setRequestHeader(RequestHeader value) { + this.requestHeader = value; + } + + /** + * Gets the value of the requestData property. + * + * @return + * possible object is + * {@link Object } + * + */ + public Object getRequestData() { + return requestData; + } + + /** + * Sets the value of the requestData property. + * + * @param value + * allowed object is + * {@link Object } + * + */ + public void setRequestData(Object value) { + this.requestData = value; + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/sdnc/SDNCAdapterResponse.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/sdnc/SDNCAdapterResponse.java new file mode 100644 index 0000000000..829af2c20b --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/sdnc/SDNCAdapterResponse.java @@ -0,0 +1,51 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common.adapter.sdnc; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + + +/** + * <p>Java class for anonymous complex type. + * + * <p>The following schema fragment specifies the expected content contained within this class. + * + * <pre> + * <complexType> + * <complexContent> + * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> + * </restriction> + * </complexContent> + * </complexType> + * </pre> + * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "") +@XmlRootElement(name = "SDNCAdapterResponse") +public class SDNCAdapterResponse { + + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/sdnc/SDNCCallbackAdapterPortType.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/sdnc/SDNCCallbackAdapterPortType.java new file mode 100644 index 0000000000..6458f4ba9d --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/sdnc/SDNCCallbackAdapterPortType.java @@ -0,0 +1,53 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common.adapter.sdnc; + +import javax.jws.WebMethod; +import javax.jws.WebParam; +import javax.jws.WebResult; +import javax.jws.WebService; +import javax.jws.soap.SOAPBinding; + + +/** + * This class was generated by the JAX-WS RI. + * JAX-WS RI 2.2.4-b01 + * Generated source version: 2.2 + * + */ +@WebService(name = "SDNCCallbackAdapterPortType", targetNamespace = "http://org.openecomp/workflow/sdnc/adapter/callback/wsdl/v1") +@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE) +public interface SDNCCallbackAdapterPortType { + + + /** + * + * @param sdncAdapterCallbackRequest + * @return + * returns org.openecomp.domain2.workflow.sdnc.adapter.schema.v1.SDNCAdapterResponse + */ + @WebMethod(operationName = "SDNCAdapterCallback") + @WebResult(name = "SDNCAdapterResponse", targetNamespace = "http://org.openecomp/workflow/sdnc/adapter/schema/v1", partName = "SDNCAdapterCallbackResponse") + public SDNCAdapterResponse sdncAdapterCallback( + @WebParam(name = "SDNCAdapterCallbackRequest", targetNamespace = "http://org.openecomp/workflow/sdnc/adapter/schema/v1", partName = "SDNCAdapterCallbackRequest") + SDNCAdapterCallbackRequest sdncAdapterCallbackRequest); + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/sdnc/package-info.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/sdnc/package-info.java new file mode 100644 index 0000000000..23ae1aef49 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/sdnc/package-info.java @@ -0,0 +1,22 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +@javax.xml.bind.annotation.XmlSchema(namespace = "http://org.openecomp/workflow/sdnc/adapter/schema/v1", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED) +package org.openecomp.mso.bpmn.common.adapter.sdnc; diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/vnf/CreateVnfNotification.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/vnf/CreateVnfNotification.java new file mode 100644 index 0000000000..c2e610d695 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/vnf/CreateVnfNotification.java @@ -0,0 +1,459 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common.adapter.vnf; + +import java.util.ArrayList; +import java.util.List; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + + +/** + * <p>Java class for createVnfNotification complex type. + * + * <p>The following schema fragment specifies the expected content contained within this class. + * + * <pre> + * <complexType name="createVnfNotification"> + * <complexContent> + * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> + * <sequence> + * <element name="messageId" type="{http://www.w3.org/2001/XMLSchema}string"/> + * <element name="completed" type="{http://www.w3.org/2001/XMLSchema}boolean"/> + * <element name="exception" type="{http://org.openecomp.mso/vnfNotify}msoExceptionCategory" minOccurs="0"/> + * <element name="errorMessage" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> + * <element name="vnfId" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> + * <element name="outputs" minOccurs="0"> + * <complexType> + * <complexContent> + * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> + * <sequence> + * <element name="entry" maxOccurs="unbounded" minOccurs="0"> + * <complexType> + * <complexContent> + * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> + * <sequence> + * <element name="key" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> + * <element name="value" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> + * </sequence> + * </restriction> + * </complexContent> + * </complexType> + * </element> + * </sequence> + * </restriction> + * </complexContent> + * </complexType> + * </element> + * <element name="rollback" type="{http://org.openecomp.mso/vnfNotify}vnfRollback" minOccurs="0"/> + * </sequence> + * </restriction> + * </complexContent> + * </complexType> + * </pre> + * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "createVnfNotification1", propOrder = { + "messageId", + "completed", + "exception", + "errorMessage", + "vnfId", + "outputs", + "rollback" +}) +public class CreateVnfNotification { + + @XmlElement(required = true) + protected String messageId; + protected boolean completed; + protected MsoExceptionCategory exception; + protected String errorMessage; + protected String vnfId; + protected CreateVnfNotification.Outputs outputs; + protected VnfRollback rollback; + + /** + * Gets the value of the messageId property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getMessageId() { + return messageId; + } + + /** + * Sets the value of the messageId property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setMessageId(String value) { + this.messageId = value; + } + + /** + * Gets the value of the completed property. + * + */ + public boolean isCompleted() { + return completed; + } + + /** + * Sets the value of the completed property. + * + */ + public void setCompleted(boolean value) { + this.completed = value; + } + + /** + * Gets the value of the exception property. + * + * @return + * possible object is + * {@link MsoExceptionCategory } + * + */ + public MsoExceptionCategory getException() { + return exception; + } + + /** + * Sets the value of the exception property. + * + * @param value + * allowed object is + * {@link MsoExceptionCategory } + * + */ + public void setException(MsoExceptionCategory value) { + this.exception = value; + } + + /** + * Gets the value of the errorMessage property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getErrorMessage() { + return errorMessage; + } + + /** + * Sets the value of the errorMessage property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setErrorMessage(String value) { + this.errorMessage = value; + } + + /** + * Gets the value of the vnfId property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getVnfId() { + return vnfId; + } + + /** + * Sets the value of the vnfId property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setVnfId(String value) { + this.vnfId = value; + } + + /** + * Gets the value of the outputs property. + * + * @return + * possible object is + * {@link CreateVnfNotification.Outputs } + * + */ + public CreateVnfNotification.Outputs getOutputs() { + return outputs; + } + + /** + * Sets the value of the outputs property. + * + * @param value + * allowed object is + * {@link CreateVnfNotification.Outputs } + * + */ + public void setOutputs(CreateVnfNotification.Outputs value) { + this.outputs = value; + } + + /** + * Gets the value of the rollback property. + * + * @return + * possible object is + * {@link VnfRollback } + * + */ + public VnfRollback getRollback() { + return rollback; + } + + /** + * Sets the value of the rollback property. + * + * @param value + * allowed object is + * {@link VnfRollback } + * + */ + public void setRollback(VnfRollback value) { + this.rollback = value; + } + + + /** + * <p>Java class for anonymous complex type. + * + * <p>The following schema fragment specifies the expected content contained within this class. + * + * <pre> + * <complexType> + * <complexContent> + * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> + * <sequence> + * <element name="entry" maxOccurs="unbounded" minOccurs="0"> + * <complexType> + * <complexContent> + * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> + * <sequence> + * <element name="key" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> + * <element name="value" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> + * </sequence> + * </restriction> + * </complexContent> + * </complexType> + * </element> + * </sequence> + * </restriction> + * </complexContent> + * </complexType> + * </pre> + * + * + */ + @XmlAccessorType(XmlAccessType.FIELD) + @XmlType(name = "", propOrder = { + "entry" + }) + public static class Outputs { + + protected List<CreateVnfNotification.Outputs.Entry> entry; + + /** + * Gets the value of the entry property. + * + * <p> + * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a <CODE>set</CODE> method for the entry property. + * + * <p> + * For example, to add a new item, do as follows: + * <pre> + * getEntry().add(newItem); + * </pre> + * + * + * <p> + * Objects of the following type(s) are allowed in the list + * {@link CreateVnfNotification.Outputs.Entry } + * + * + */ + public List<CreateVnfNotification.Outputs.Entry> getEntry() { + if (entry == null) { + entry = new ArrayList<CreateVnfNotification.Outputs.Entry>(); + } + return this.entry; + } + + // Not a generated method + public String toString() { + StringBuilder out = new StringBuilder(); + out.append("<outputs>\n"); + if (entry != null) { + for (Entry e : entry) { + out.append(e.toString()); + out.append('\n'); + } + } + out.append("</outputs>"); + return out.toString(); + } + + /** + * <p>Java class for anonymous complex type. + * + * <p>The following schema fragment specifies the expected content contained within this class. + * + * <pre> + * <complexType> + * <complexContent> + * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> + * <sequence> + * <element name="key" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> + * <element name="value" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> + * </sequence> + * </restriction> + * </complexContent> + * </complexType> + * </pre> + * + * + */ + @XmlAccessorType(XmlAccessType.FIELD) + @XmlType(name = "", propOrder = { + "key", + "value" + }) + public static class Entry { + + protected String key; + protected String value; + + /** + * Gets the value of the key property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getKey() { + return key; + } + + /** + * Sets the value of the key property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setKey(String value) { + this.key = value; + } + + /** + * Gets the value of the value property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getValue() { + return value; + } + + /** + * Sets the value of the value property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setValue(String value) { + this.value = value; + + } + + // Not a generated method + public String toString() { + String entry = ""; + entry = + "<entry>"+ '\n' + + " <key>"+key+"</key>" + '\n' + + " <value>"+value+"</value>" + '\n' + + "</entry>"; + return entry; + } + + } + + } + + // Not a generated method + public String toString() { + String createVnfNotification = ""; + if (exception==null) { + createVnfNotification = "<ns2:createVnfNotification xmlns:ns2=\"http://org.openecomp.mso/vnfNotify\"" + '\n' + + " xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" + '\n' + + " <messageId>"+messageId+"</messageId>" + '\n' + + " <completed>"+completed+"</completed>" + '\n' + + " <vnfId>"+vnfId+"</vnfId>" + '\n' + + (outputs == null ? "" : outputs.toString() + '\n') + + " <rollback>"+rollback+"</rollback>" + '\n' + + "</ns2:createVnfNotification>"; + } else { + createVnfNotification = "<ns2:createVnfNotification xmlns:ns2=\"http://org.openecomp.mso/vnfNotify\"" + '\n' + + " xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" + '\n' + + " <messageId>"+messageId+"</messageId>" + '\n' + + " <completed>"+completed+"</completed>" + '\n' + + (outputs == null ? "" : outputs.toString() + '\n') + + " <exception>"+exception+"</exception>" + '\n' + + " <errorMessage>"+errorMessage+"</errorMessage>" + '\n' + + "</ns2:createVnfNotification>"; + } + return createVnfNotification; + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/vnf/DeleteVnfNotification.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/vnf/DeleteVnfNotification.java new file mode 100644 index 0000000000..b408184ae3 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/vnf/DeleteVnfNotification.java @@ -0,0 +1,198 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common.adapter.vnf; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + + +/** + * <p>Java class for deleteVnfNotification complex type. + * + * <p>The following schema fragment specifies the expected content contained within this class. + * + * <pre> + * <complexType name="deleteVnfNotification"> + * <complexContent> + * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> + * <sequence> + * <element name="messageId" type="{http://www.w3.org/2001/XMLSchema}string"/> + * <element name="completed" type="{http://www.w3.org/2001/XMLSchema}boolean"/> + * <element name="exception" type="{http://org.openecomp.mso/vnfNotify}msoExceptionCategory" minOccurs="0"/> + * <element name="errorMessage" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> + * </sequence> + * </restriction> + * </complexContent> + * </complexType> + * </pre> + * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "deleteVnfNotification1", propOrder = { + "messageId", + "completed", + "exception", + "errorMessage" +}) +public class DeleteVnfNotification { + + @XmlElement(required = true) + protected String messageId; + protected boolean completed; + protected MsoExceptionCategory exception; + protected String errorMessage; + + /** + * Gets the value of the messageId property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getMessageId() { + return messageId; + } + + /** + * Sets the value of the messageId property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setMessageId(String value) { + this.messageId = value; + } + + /** + * Gets the value of the completed property. + * + */ + public boolean isCompleted() { + return completed; + } + + /** + * Sets the value of the completed property. + * + */ + public void setCompleted(boolean value) { + this.completed = value; + } + + /** + * Gets the value of the exception property. + * + * @return + * possible object is + * {@link MsoExceptionCategory } + * + */ + public MsoExceptionCategory getException() { + return exception; + } + + /** + * Sets the value of the exception property. + * + * @param value + * allowed object is + * {@link MsoExceptionCategory } + * + */ + public void setException(MsoExceptionCategory value) { + this.exception = value; + } + + /** + * Gets the value of the errorMessage property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getErrorMessage() { + return errorMessage; + } + + /** + * Sets the value of the errorMessage property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setErrorMessage(String value) { + this.errorMessage = value; + } + + /** + * Overrides toString() method + * @return String type (deleteVnfNotification) + */ + + + public String toString() { + String deleteVnfNotification = ""; + if (exception==null) { + deleteVnfNotification = "<ns2:deleteVnfNotification xmlns:ns2=\"http://org.openecomp.mso/vnfNotify\"" + '\n' + + " xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" + '\n' + + " <messageId>"+messageId+"</messageId>" + '\n' + + " <completed>"+completed+"</completed>" + '\n' + + "</ns2:deleteVnfNotification>"; + } else { + deleteVnfNotification = "<ns2:deleteVnfNotification xmlns:ns2=\"http://org.openecomp.mso/vnfNotify\"" + '\n' + + " xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" + '\n' + + " <messageId>"+messageId+"</messageId>" + '\n' + + " <completed>"+completed+"</completed>" + '\n' + + " <exception>"+exception+"</exception>" + '\n' + + " <errorMessage>"+errorMessage+"</errorMessage>" + '\n' + + "</ns2:deleteVnfNotification>"; + } + return deleteVnfNotification; + } + +/* + public String toString() { + StringWriter writer = new StringWriter(); + try { + JAXBContext context = JAXBContext + .newInstance(DeleteVnfNotification.class); + Marshaller m = context.createMarshaller(); + m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); + m.marshal(this, writer); + //System.out.println("toString() - " + writer.getBuffer().toString()); + return writer.getBuffer().toString(); + } catch (JAXBException e) { + //System.out.println("JAXBException - " + e.getStackTrace()); + return ""; + } + } +*/ + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/vnf/MsoExceptionCategory.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/vnf/MsoExceptionCategory.java new file mode 100644 index 0000000000..80673a0fb6 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/vnf/MsoExceptionCategory.java @@ -0,0 +1,61 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common.adapter.vnf; + +import javax.xml.bind.annotation.XmlEnum; +import javax.xml.bind.annotation.XmlType; + + +/** + * <p>Java class for msoExceptionCategory. + * + * <p>The following schema fragment specifies the expected content contained within this class. + * <p> + * <pre> + * <simpleType name="msoExceptionCategory"> + * <restriction base="{http://www.w3.org/2001/XMLSchema}string"> + * <enumeration value="OPENSTACK"/> + * <enumeration value="IO"/> + * <enumeration value="INTERNAL"/> + * <enumeration value="USERDATA"/> + * </restriction> + * </simpleType> + * </pre> + * + */ +@XmlType(name = "msoExceptionCategory") +@XmlEnum +public enum MsoExceptionCategory { + + OPENSTACK, + IO, + INTERNAL, + USERDATA; + + public String value() { + return name(); + } + + public static MsoExceptionCategory fromValue(String v) { + return valueOf(v); + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/vnf/MsoRequest.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/vnf/MsoRequest.java new file mode 100644 index 0000000000..f251a31ce8 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/vnf/MsoRequest.java @@ -0,0 +1,114 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common.adapter.vnf; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlType; + + +/** + * <p>Java class for msoRequest complex type. + * + * <p>The following schema fragment specifies the expected content contained within this class. + * + * <pre> + * <complexType name="msoRequest"> + * <complexContent> + * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> + * <sequence> + * <element name="requestId" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> + * <element name="serviceInstanceId" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> + * </sequence> + * </restriction> + * </complexContent> + * </complexType> + * </pre> + * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "msoRequest", propOrder = { + "requestId", + "serviceInstanceId" +}) +public class MsoRequest { + + protected String requestId; + protected String serviceInstanceId; + + /** + * Gets the value of the requestId property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getRequestId() { + return requestId; + } + + /** + * Sets the value of the requestId property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setRequestId(String value) { + this.requestId = value; + } + + /** + * Gets the value of the serviceInstanceId property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getServiceInstanceId() { + return serviceInstanceId; + } + + /** + * Sets the value of the serviceInstanceId property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setServiceInstanceId(String value) { + this.serviceInstanceId = value; + } + + public String toString() { + String request = ""; + request = + "<requestId>"+requestId+"</requestId>" + '\n' + + "<serviceInstanceId>"+serviceInstanceId+"</serviceInstanceId>"; + return request; + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/vnf/ObjectFactory.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/vnf/ObjectFactory.java new file mode 100644 index 0000000000..1a38539f45 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/vnf/ObjectFactory.java @@ -0,0 +1,208 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common.adapter.vnf; + +import javax.xml.bind.JAXBElement; +import javax.xml.bind.annotation.XmlElementDecl; +import javax.xml.bind.annotation.XmlRegistry; +import javax.xml.namespace.QName; + + +/** + * This object contains factory methods for each + * Java content interface and Java element interface + * generated in the org.openecomp.mso.adapters.vnf.async.client package. + * <p>An ObjectFactory allows you to programatically + * construct new instances of the Java representation + * for XML content. The Java representation of XML + * content can consist of schema derived interfaces + * and classes representing the binding of schema + * type definitions, element declarations and model + * groups. Factory methods for each of these are + * provided in this class. + * + */ +@XmlRegistry +public class ObjectFactory { + + private final static QName _RollbackVnfNotification_QNAME = new QName("http://org.openecomp.mso/vnfNotify", "rollbackVnfNotification"); + private final static QName _DeleteVnfNotification_QNAME = new QName("http://org.openecomp.mso/vnfNotify", "deleteVnfNotification"); + private final static QName _CreateVnfNotification_QNAME = new QName("http://org.openecomp.mso/vnfNotify", "createVnfNotification"); + private final static QName _UpdateVnfNotification_QNAME = new QName("http://org.openecomp.mso/vnfNotify", "updateVnfNotification"); + private final static QName _QueryVnfNotification_QNAME = new QName("http://org.openecomp.mso/vnfNotify", "queryVnfNotification"); + + /** + * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: org.openecomp.mso.adapters.vnf.async.client + * + */ + public ObjectFactory() { + } + + /** + * Create an instance of {@link UpdateVnfNotification } + * + */ + public UpdateVnfNotification createUpdateVnfNotification() { + return new UpdateVnfNotification(); + } + + /** + * Create an instance of {@link UpdateVnfNotification.Outputs } + * + */ + public UpdateVnfNotification.Outputs createUpdateVnfNotificationOutputs() { + return new UpdateVnfNotification.Outputs(); + } + + /** + * Create an instance of {@link QueryVnfNotification } + * + */ + public QueryVnfNotification createQueryVnfNotification() { + return new QueryVnfNotification(); + } + + /** + * Create an instance of {@link QueryVnfNotification.Outputs } + * + */ + public QueryVnfNotification.Outputs createQueryVnfNotificationOutputs() { + return new QueryVnfNotification.Outputs(); + } + + /** + * Create an instance of {@link CreateVnfNotification } + * + */ + public CreateVnfNotification createCreateVnfNotification() { + return new CreateVnfNotification(); + } + + /** + * Create an instance of {@link CreateVnfNotification.Outputs } + * + */ + public CreateVnfNotification.Outputs createCreateVnfNotificationOutputs() { + return new CreateVnfNotification.Outputs(); + } + + /** + * Create an instance of {@link DeleteVnfNotification } + * + */ + public DeleteVnfNotification createDeleteVnfNotification() { + return new DeleteVnfNotification(); + } + + /** + * Create an instance of {@link RollbackVnfNotification } + * + */ + public RollbackVnfNotification createRollbackVnfNotification() { + return new RollbackVnfNotification(); + } + + /** + * Create an instance of {@link MsoRequest } + * + */ + public MsoRequest createMsoRequest() { + return new MsoRequest(); + } + + /** + * Create an instance of {@link VnfRollback } + * + */ + public VnfRollback createVnfRollback() { + return new VnfRollback(); + } + + /** + * Create an instance of {@link UpdateVnfNotification.Outputs.Entry } + * + */ + public UpdateVnfNotification.Outputs.Entry createUpdateVnfNotificationOutputsEntry() { + return new UpdateVnfNotification.Outputs.Entry(); + } + + /** + * Create an instance of {@link QueryVnfNotification.Outputs.Entry } + * + */ + public QueryVnfNotification.Outputs.Entry createQueryVnfNotificationOutputsEntry() { + return new QueryVnfNotification.Outputs.Entry(); + } + + /** + * Create an instance of {@link CreateVnfNotification.Outputs.Entry } + * + */ + public CreateVnfNotification.Outputs.Entry createCreateVnfNotificationOutputsEntry() { + return new CreateVnfNotification.Outputs.Entry(); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link RollbackVnfNotification }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://org.openecomp.mso/vnfNotify", name = "rollbackVnfNotification") + public JAXBElement<RollbackVnfNotification> createRollbackVnfNotification(RollbackVnfNotification value) { + return new JAXBElement<RollbackVnfNotification>(_RollbackVnfNotification_QNAME, RollbackVnfNotification.class, null, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link DeleteVnfNotification }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://org.openecomp.mso/vnfNotify", name = "deleteVnfNotification") + public JAXBElement<DeleteVnfNotification> createDeleteVnfNotification(DeleteVnfNotification value) { + return new JAXBElement<DeleteVnfNotification>(_DeleteVnfNotification_QNAME, DeleteVnfNotification.class, null, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link CreateVnfNotification }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://org.openecomp.mso/vnfNotify", name = "createVnfNotification") + public JAXBElement<CreateVnfNotification> createCreateVnfNotification(CreateVnfNotification value) { + return new JAXBElement<CreateVnfNotification>(_CreateVnfNotification_QNAME, CreateVnfNotification.class, null, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link UpdateVnfNotification }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://org.openecomp.mso/vnfNotify", name = "updateVnfNotification") + public JAXBElement<UpdateVnfNotification> createUpdateVnfNotification(UpdateVnfNotification value) { + return new JAXBElement<UpdateVnfNotification>(_UpdateVnfNotification_QNAME, UpdateVnfNotification.class, null, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link QueryVnfNotification }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://org.openecomp.mso/vnfNotify", name = "queryVnfNotification") + public JAXBElement<QueryVnfNotification> createQueryVnfNotification(QueryVnfNotification value) { + return new JAXBElement<QueryVnfNotification>(_QueryVnfNotification_QNAME, QueryVnfNotification.class, null, value); + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/vnf/QueryVnfNotification.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/vnf/QueryVnfNotification.java new file mode 100644 index 0000000000..47ae04577e --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/vnf/QueryVnfNotification.java @@ -0,0 +1,488 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common.adapter.vnf; + +import java.util.ArrayList; +import java.util.List; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + + +/** + * <p>Java class for queryVnfNotification complex type. + * + * <p>The following schema fragment specifies the expected content contained within this class. + * + * <pre> + * <complexType name="queryVnfNotification"> + * <complexContent> + * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> + * <sequence> + * <element name="messageId" type="{http://www.w3.org/2001/XMLSchema}string"/> + * <element name="completed" type="{http://www.w3.org/2001/XMLSchema}boolean"/> + * <element name="exception" type="{http://org.openecomp.mso/vnfNotify}msoExceptionCategory" minOccurs="0"/> + * <element name="errorMessage" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> + * <element name="vnfExists" type="{http://www.w3.org/2001/XMLSchema}boolean" minOccurs="0"/> + * <element name="vnfId" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> + * <element name="status" type="{http://org.openecomp.mso/vnfNotify}vnfStatus" minOccurs="0"/> + * <element name="outputs" minOccurs="0"> + * <complexType> + * <complexContent> + * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> + * <sequence> + * <element name="entry" maxOccurs="unbounded" minOccurs="0"> + * <complexType> + * <complexContent> + * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> + * <sequence> + * <element name="key" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> + * <element name="value" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> + * </sequence> + * </restriction> + * </complexContent> + * </complexType> + * </element> + * </sequence> + * </restriction> + * </complexContent> + * </complexType> + * </element> + * </sequence> + * </restriction> + * </complexContent> + * </complexType> + * </pre> + * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "queryVnfNotification1", propOrder = { + "messageId", + "completed", + "exception", + "errorMessage", + "vnfExists", + "vnfId", + "status", + "outputs" +}) +public class QueryVnfNotification { + + @XmlElement(required = true) + protected String messageId; + protected boolean completed; + protected MsoExceptionCategory exception; + protected String errorMessage; + protected Boolean vnfExists; + protected String vnfId; + protected VnfStatus status; + protected QueryVnfNotification.Outputs outputs; + + /** + * Gets the value of the messageId property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getMessageId() { + return messageId; + } + + /** + * Sets the value of the messageId property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setMessageId(String value) { + this.messageId = value; + } + + /** + * Gets the value of the completed property. + * + */ + public boolean isCompleted() { + return completed; + } + + /** + * Sets the value of the completed property. + * + */ + public void setCompleted(boolean value) { + this.completed = value; + } + + /** + * Gets the value of the exception property. + * + * @return + * possible object is + * {@link MsoExceptionCategory } + * + */ + public MsoExceptionCategory getException() { + return exception; + } + + /** + * Sets the value of the exception property. + * + * @param value + * allowed object is + * {@link MsoExceptionCategory } + * + */ + public void setException(MsoExceptionCategory value) { + this.exception = value; + } + + /** + * Gets the value of the errorMessage property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getErrorMessage() { + return errorMessage; + } + + /** + * Sets the value of the errorMessage property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setErrorMessage(String value) { + this.errorMessage = value; + } + + /** + * Gets the value of the vnfExists property. + * + * @return + * possible object is + * {@link Boolean } + * + */ + public Boolean isVnfExists() { + return vnfExists; + } + + /** + * Sets the value of the vnfExists property. + * + * @param value + * allowed object is + * {@link Boolean } + * + */ + public void setVnfExists(Boolean value) { + this.vnfExists = value; + } + + /** + * Gets the value of the vnfId property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getVnfId() { + return vnfId; + } + + /** + * Sets the value of the vnfId property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setVnfId(String value) { + this.vnfId = value; + } + + /** + * Gets the value of the status property. + * + * @return + * possible object is + * {@link VnfStatus } + * + */ + public VnfStatus getStatus() { + return status; + } + + /** + * Sets the value of the status property. + * + * @param value + * allowed object is + * {@link VnfStatus } + * + */ + public void setStatus(VnfStatus value) { + this.status = value; + } + + /** + * Gets the value of the outputs property. + * + * @return + * possible object is + * {@link QueryVnfNotification.Outputs } + * + */ + public QueryVnfNotification.Outputs getOutputs() { + return outputs; + } + + /** + * Sets the value of the outputs property. + * + * @param value + * allowed object is + * {@link QueryVnfNotification.Outputs } + * + */ + public void setOutputs(QueryVnfNotification.Outputs value) { + this.outputs = value; + } + + + /** + * <p>Java class for anonymous complex type. + * + * <p>The following schema fragment specifies the expected content contained within this class. + * + * <pre> + * <complexType> + * <complexContent> + * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> + * <sequence> + * <element name="entry" maxOccurs="unbounded" minOccurs="0"> + * <complexType> + * <complexContent> + * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> + * <sequence> + * <element name="key" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> + * <element name="value" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> + * </sequence> + * </restriction> + * </complexContent> + * </complexType> + * </element> + * </sequence> + * </restriction> + * </complexContent> + * </complexType> + * </pre> + * + * + */ + @XmlAccessorType(XmlAccessType.FIELD) + @XmlType(name = "", propOrder = { + "entry" + }) + public static class Outputs { + + protected List<QueryVnfNotification.Outputs.Entry> entry; + + /** + * Gets the value of the entry property. + * + * <p> + * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a <CODE>set</CODE> method for the entry property. + * + * <p> + * For example, to add a new item, do as follows: + * <pre> + * getEntry().add(newItem); + * </pre> + * + * + * <p> + * Objects of the following type(s) are allowed in the list + * {@link QueryVnfNotification.Outputs.Entry } + * + * + */ + public List<QueryVnfNotification.Outputs.Entry> getEntry() { + if (entry == null) { + entry = new ArrayList<QueryVnfNotification.Outputs.Entry>(); + } + return this.entry; + } + + // Not a generated method + public String toString() { + StringBuilder out = new StringBuilder(); + out.append("<outputs>\n"); + if (entry != null) { + for (Entry e : entry) { + out.append(e.toString()); + out.append('\n'); + } + } + out.append("</outputs>"); + return out.toString(); + } + + + /** + * <p>Java class for anonymous complex type. + * + * <p>The following schema fragment specifies the expected content contained within this class. + * + * <pre> + * <complexType> + * <complexContent> + * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> + * <sequence> + * <element name="key" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> + * <element name="value" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> + * </sequence> + * </restriction> + * </complexContent> + * </complexType> + * </pre> + * + * + */ + @XmlAccessorType(XmlAccessType.FIELD) + @XmlType(name = "", propOrder = { + "key", + "value" + }) + public static class Entry { + + protected String key; + protected String value; + + /** + * Gets the value of the key property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getKey() { + return key; + } + + /** + * Sets the value of the key property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setKey(String value) { + this.key = value; + } + + /** + * Gets the value of the value property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getValue() { + return value; + } + + /** + * Sets the value of the value property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setValue(String value) { + this.value = value; + } + + // Not a generated method + public String toString() { + String entry = ""; + entry = + "<entry>"+ '\n' + + " <key>"+key+"</key>" + '\n' + + " <value>"+value+"</value>" + '\n' + + "</entry>"; + return entry; + } + + } + + } + + // Not a generated method + public String toString() { + String queryVnfNotification = ""; + if (exception==null) { + queryVnfNotification = "<ns2:queryVnfNotification xmlns:ns2=\"http://org.openecomp.mso/vnfNotify\"" + '\n' + + " xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" + '\n' + + " <messageId>"+messageId+"</messageId>" + '\n' + + " <completed>"+completed+"</completed>" + '\n' + + " <vnfExists>"+vnfExists+"</vnfExists>" + '\n' + + " <vnfId>"+vnfId+"</vnfId>" + '\n' + + " <status>"+status+"</status>" + '\n' + + (outputs == null ? "" : outputs.toString() + '\n') + + "</ns2:queryVnfNotification>"; + } else { + queryVnfNotification = "<ns2:queryVnfNotification xmlns:ns2=\"http://org.openecomp.mso/vnfNotify\"" + '\n' + + " xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" + '\n' + + " <messageId>"+messageId+"</messageId>" + '\n' + + " <completed>"+completed+"</completed>" + '\n' + + (outputs == null ? "" : outputs.toString() + '\n') + + " <exception>"+exception+"</exception>" + '\n' + + " <errorMessage>"+errorMessage+"</errorMessage>" + '\n' + + "</ns2:queryVnfNotification>"; + } + return queryVnfNotification; + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/vnf/RollbackVnfNotification.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/vnf/RollbackVnfNotification.java new file mode 100644 index 0000000000..6c05b4a075 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/vnf/RollbackVnfNotification.java @@ -0,0 +1,175 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common.adapter.vnf; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + + +/** + * <p>Java class for rollbackVnfNotification complex type. + * + * <p>The following schema fragment specifies the expected content contained within this class. + * + * <pre> + * <complexType name="rollbackVnfNotification"> + * <complexContent> + * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> + * <sequence> + * <element name="messageId" type="{http://www.w3.org/2001/XMLSchema}string"/> + * <element name="completed" type="{http://www.w3.org/2001/XMLSchema}boolean"/> + * <element name="exception" type="{http://org.openecomp.mso/vnfNotify}msoExceptionCategory" minOccurs="0"/> + * <element name="errorMessage" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> + * </sequence> + * </restriction> + * </complexContent> + * </complexType> + * </pre> + * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "rollbackVnfNotification1", propOrder = { + "messageId", + "completed", + "exception", + "errorMessage" +}) +public class RollbackVnfNotification { + + @XmlElement(required = true) + protected String messageId; + protected boolean completed; + protected MsoExceptionCategory exception; + protected String errorMessage; + + /** + * Gets the value of the messageId property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getMessageId() { + return messageId; + } + + /** + * Sets the value of the messageId property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setMessageId(String value) { + this.messageId = value; + } + + /** + * Gets the value of the completed property. + * + */ + public boolean isCompleted() { + return completed; + } + + /** + * Sets the value of the completed property. + * + */ + public void setCompleted(boolean value) { + this.completed = value; + } + + /** + * Gets the value of the exception property. + * + * @return + * possible object is + * {@link MsoExceptionCategory } + * + */ + public MsoExceptionCategory getException() { + return exception; + } + + /** + * Sets the value of the exception property. + * + * @param value + * allowed object is + * {@link MsoExceptionCategory } + * + */ + public void setException(MsoExceptionCategory value) { + this.exception = value; + } + + /** + * Gets the value of the errorMessage property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getErrorMessage() { + return errorMessage; + } + + /** + * Sets the value of the errorMessage property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setErrorMessage(String value) { + this.errorMessage = value; + } + + public String toString() { + String rollbackVnfNotification = ""; + if (exception==null) { + rollbackVnfNotification = "<ns2:rollbackVnfNotification xmlns:ns2=\"http://org.openecomp.mso/vnfNotify\"" + '\n' + + " xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" + '\n' + + " <messageId>"+messageId+"</messageId>" + '\n' + + " <completed>"+completed+"</completed>" + '\n' + + "</ns2:rollbackVnfNotification>"; + } else { + rollbackVnfNotification = "<ns2:rollbackVnfNotification xmlns:ns2=\"http://org.openecomp.mso/vnfNotify\"" + '\n' + + " xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" + '\n' + + " <messageId>"+messageId+"</messageId>" + '\n' + + " <completed>"+completed+"</completed>" + '\n' + + " <exception>"+exception+"</exception>" + '\n' + + " <errorMessage>"+errorMessage+"</errorMessage>" + '\n' + + "</ns2:rollbackVnfNotification>"; + } + return rollbackVnfNotification; + + } + + } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/vnf/UpdateVnfNotification.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/vnf/UpdateVnfNotification.java new file mode 100644 index 0000000000..92954800f2 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/vnf/UpdateVnfNotification.java @@ -0,0 +1,412 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common.adapter.vnf; + +import java.util.ArrayList; +import java.util.List; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + + +/** + * <p>Java class for updateVnfNotification complex type. + * + * <p>The following schema fragment specifies the expected content contained within this class. + * + * <pre> + * <complexType name="updateVnfNotification"> + * <complexContent> + * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> + * <sequence> + * <element name="messageId" type="{http://www.w3.org/2001/XMLSchema}string"/> + * <element name="completed" type="{http://www.w3.org/2001/XMLSchema}boolean"/> + * <element name="exception" type="{http://org.openecomp.mso/vnfNotify}msoExceptionCategory" minOccurs="0"/> + * <element name="errorMessage" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> + * <element name="outputs" minOccurs="0"> + * <complexType> + * <complexContent> + * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> + * <sequence> + * <element name="entry" maxOccurs="unbounded" minOccurs="0"> + * <complexType> + * <complexContent> + * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> + * <sequence> + * <element name="key" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> + * <element name="value" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> + * </sequence> + * </restriction> + * </complexContent> + * </complexType> + * </element> + * </sequence> + * </restriction> + * </complexContent> + * </complexType> + * </element> + * <element name="rollback" type="{http://org.openecomp.mso/vnfNotify}vnfRollback" minOccurs="0"/> + * </sequence> + * </restriction> + * </complexContent> + * </complexType> + * </pre> + * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "updateVnfNotification1", propOrder = { + "messageId", + "completed", + "exception", + "errorMessage", + "outputs", + "rollback" +}) +public class UpdateVnfNotification { + + @XmlElement(required = true) + protected String messageId; + protected boolean completed; + protected MsoExceptionCategory exception; + protected String errorMessage; + protected UpdateVnfNotification.Outputs outputs; + protected VnfRollback rollback; + + /** + * Gets the value of the messageId property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getMessageId() { + return messageId; + } + + /** + * Sets the value of the messageId property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setMessageId(String value) { + this.messageId = value; + } + + /** + * Gets the value of the completed property. + * + */ + public boolean isCompleted() { + return completed; + } + + /** + * Sets the value of the completed property. + * + */ + public void setCompleted(boolean value) { + this.completed = value; + } + + /** + * Gets the value of the exception property. + * + * @return + * possible object is + * {@link MsoExceptionCategory } + * + */ + public MsoExceptionCategory getException() { + return exception; + } + + /** + * Sets the value of the exception property. + * + * @param value + * allowed object is + * {@link MsoExceptionCategory } + * + */ + public void setException(MsoExceptionCategory value) { + this.exception = value; + } + + /** + * Gets the value of the errorMessage property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getErrorMessage() { + return errorMessage; + } + + /** + * Sets the value of the errorMessage property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setErrorMessage(String value) { + this.errorMessage = value; + } + + /** + * Gets the value of the outputs property. + * + * @return + * possible object is + * {@link UpdateVnfNotification.Outputs } + * + */ + public UpdateVnfNotification.Outputs getOutputs() { + return outputs; + } + + /** + * Sets the value of the outputs property. + * + * @param value + * allowed object is + * {@link UpdateVnfNotification.Outputs } + * + */ + public void setOutputs(UpdateVnfNotification.Outputs value) { + this.outputs = value; + } + + /** + * Gets the value of the rollback property. + * + * @return + * possible object is + * {@link VnfRollback } + * + */ + public VnfRollback getRollback() { + return rollback; + } + + /** + * Sets the value of the rollback property. + * + * @param value + * allowed object is + * {@link VnfRollback } + * + */ + public void setRollback(VnfRollback value) { + this.rollback = value; + } + + + /** + * <p>Java class for anonymous complex type. + * + * <p>The following schema fragment specifies the expected content contained within this class. + * + * <pre> + * <complexType> + * <complexContent> + * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> + * <sequence> + * <element name="entry" maxOccurs="unbounded" minOccurs="0"> + * <complexType> + * <complexContent> + * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> + * <sequence> + * <element name="key" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> + * <element name="value" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> + * </sequence> + * </restriction> + * </complexContent> + * </complexType> + * </element> + * </sequence> + * </restriction> + * </complexContent> + * </complexType> + * </pre> + * + * + */ + @XmlAccessorType(XmlAccessType.FIELD) + @XmlType(name = "", propOrder = { + "entry" + }) + public static class Outputs { + + protected List<UpdateVnfNotification.Outputs.Entry> entry; + + /** + * Gets the value of the entry property. + * + * <p> + * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a <CODE>set</CODE> method for the entry property. + * + * <p> + * For example, to add a new item, do as follows: + * <pre> + * getEntry().add(newItem); + * </pre> + * + * + * <p> + * Objects of the following type(s) are allowed in the list + * {@link UpdateVnfNotification.Outputs.Entry } + * + * + */ + public List<UpdateVnfNotification.Outputs.Entry> getEntry() { + if (entry == null) { + entry = new ArrayList<UpdateVnfNotification.Outputs.Entry>(); + } + return this.entry; + } + + + /** + * <p>Java class for anonymous complex type. + * + * <p>The following schema fragment specifies the expected content contained within this class. + * + * <pre> + * <complexType> + * <complexContent> + * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> + * <sequence> + * <element name="key" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> + * <element name="value" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> + * </sequence> + * </restriction> + * </complexContent> + * </complexType> + * </pre> + * + * + */ + @XmlAccessorType(XmlAccessType.FIELD) + @XmlType(name = "", propOrder = { + "key", + "value" + }) + public static class Entry { + + protected String key; + protected String value; + + /** + * Gets the value of the key property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getKey() { + return key; + } + + /** + * Sets the value of the key property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setKey(String value) { + this.key = value; + } + + /** + * Gets the value of the value property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getValue() { + return value; + } + + /** + * Sets the value of the value property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setValue(String value) { + this.value = value; + } + + public String toString() { + String entry = ""; + entry = + " <key>"+key+"</key>" + '\n' + + " <value>"+value+"</value>"; + return entry; + } + } + + } + + public String toString(){ + String updateVnfNotification = ""; + if (exception==null) { + updateVnfNotification = "<ns2:updateVnfNotification xmlns:ns2=\"http://org.openecomp.mso/vnfNotify\"" + '\n' + + " xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" + '\n' + + " <messageId>"+messageId+"</messageId>" + '\n' + + " <completed>"+completed+"</completed>" + '\n' + + " <rollback>"+rollback+"</rollback>" + '\n' + + "</ns2:updateVnfNotification>"; + } else { + updateVnfNotification = "<ns2:updateVnfNotification xmlns:ns2=\"http://org.openecomp.mso/vnfNotify\"" + '\n' + + " xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" + '\n' + + " <messageId>"+messageId+"</messageId>" + '\n' + + " <completed>"+completed+"</completed>" + '\n' + + " <exception>"+exception+"</exception>" + '\n' + + " <errorMessage>"+errorMessage+"</errorMessage>" + '\n' + + "</ns2:updateVnfNotification>"; + } + + return updateVnfNotification; + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/vnf/VnfAdapterNotify.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/vnf/VnfAdapterNotify.java new file mode 100644 index 0000000000..b714e528d1 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/vnf/VnfAdapterNotify.java @@ -0,0 +1,177 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common.adapter.vnf; + +import javax.jws.Oneway; +import javax.jws.WebMethod; +import javax.jws.WebParam; +import javax.jws.WebService; +import javax.xml.bind.annotation.XmlSeeAlso; +import javax.xml.ws.Action; +import javax.xml.ws.RequestWrapper; + + +/** + * This class was generated by the JAX-WS RI. + * JAX-WS RI 2.2.8 + * Generated source version: 2.2 + * + */ +@WebService(name = "vnfAdapterNotify", targetNamespace = "http://org.openecomp.mso/vnfNotify") +@XmlSeeAlso({ + ObjectFactory.class +}) +public interface VnfAdapterNotify { + + + /** + * + * @param errorMessage + * @param exception + * @param messageId + * @param completed + */ + @WebMethod + @Oneway + @RequestWrapper(localName = "rollbackVnfNotification", targetNamespace = "http://org.openecomp.mso/vnfNotify", className = "org.openecomp.mso.adapters.vnf.async.client.RollbackVnfNotification") + @Action(input = "http://org.openecomp.mso/notify/adapterNotify/rollbackVnfNotificationRequest") + public void rollbackVnfNotification( + @WebParam(name = "messageId", targetNamespace = "") + String messageId, + @WebParam(name = "completed", targetNamespace = "") + boolean completed, + @WebParam(name = "exception", targetNamespace = "") + MsoExceptionCategory exception, + @WebParam(name = "errorMessage", targetNamespace = "") + String errorMessage); + + /** + * + * @param errorMessage + * @param vnfExists + * @param status + * @param exception + * @param outputs + * @param messageId + * @param vnfId + * @param completed + */ + @WebMethod + @Oneway + @RequestWrapper(localName = "queryVnfNotification", targetNamespace = "http://org.openecomp.mso/vnfNotify", className = "org.openecomp.mso.adapters.vnf.async.client.QueryVnfNotification") + @Action(input = "http://org.openecomp.mso/notify/adapterNotify/queryVnfNotificationRequest") + public void queryVnfNotification( + @WebParam(name = "messageId", targetNamespace = "") + String messageId, + @WebParam(name = "completed", targetNamespace = "") + boolean completed, + @WebParam(name = "exception", targetNamespace = "") + MsoExceptionCategory exception, + @WebParam(name = "errorMessage", targetNamespace = "") + String errorMessage, + @WebParam(name = "vnfExists", targetNamespace = "") + Boolean vnfExists, + @WebParam(name = "vnfId", targetNamespace = "") + String vnfId, + @WebParam(name = "status", targetNamespace = "") + VnfStatus status, + @WebParam(name = "outputs", targetNamespace = "") + org.openecomp.mso.bpmn.common.adapter.vnf.QueryVnfNotification.Outputs outputs); + + /** + * + * @param errorMessage + * @param exception + * @param rollback + * @param outputs + * @param messageId + * @param vnfId + * @param completed + */ + @WebMethod + @Oneway + @RequestWrapper(localName = "createVnfNotification", targetNamespace = "http://org.openecomp.mso/vnfNotify", className = "org.openecomp.mso.adapters.vnf.async.client.CreateVnfNotification") + @Action(input = "http://org.openecomp.mso/notify/adapterNotify/createVnfNotificationRequest") + public void createVnfNotification( + @WebParam(name = "messageId", targetNamespace = "") + String messageId, + @WebParam(name = "completed", targetNamespace = "") + boolean completed, + @WebParam(name = "exception", targetNamespace = "") + MsoExceptionCategory exception, + @WebParam(name = "errorMessage", targetNamespace = "") + String errorMessage, + @WebParam(name = "vnfId", targetNamespace = "") + String vnfId, + @WebParam(name = "outputs", targetNamespace = "") + org.openecomp.mso.bpmn.common.adapter.vnf.CreateVnfNotification.Outputs outputs, + @WebParam(name = "rollback", targetNamespace = "") + VnfRollback rollback); + + /** + * + * @param errorMessage + * @param exception + * @param rollback + * @param outputs + * @param messageId + * @param completed + */ + @WebMethod + @Oneway + @RequestWrapper(localName = "updateVnfNotification", targetNamespace = "http://org.openecomp.mso/vnfNotify", className = "org.openecomp.mso.adapters.vnf.async.client.UpdateVnfNotification") + @Action(input = "http://org.openecomp.mso/notify/adapterNotify/updateVnfNotificationRequest") + public void updateVnfNotification( + @WebParam(name = "messageId", targetNamespace = "") + String messageId, + @WebParam(name = "completed", targetNamespace = "") + boolean completed, + @WebParam(name = "exception", targetNamespace = "") + MsoExceptionCategory exception, + @WebParam(name = "errorMessage", targetNamespace = "") + String errorMessage, + @WebParam(name = "outputs", targetNamespace = "") + org.openecomp.mso.bpmn.common.adapter.vnf.UpdateVnfNotification.Outputs outputs, + @WebParam(name = "rollback", targetNamespace = "") + VnfRollback rollback); + + /** + * + * @param errorMessage + * @param exception + * @param messageId + * @param completed + */ + @WebMethod + @Oneway + @RequestWrapper(localName = "deleteVnfNotification", targetNamespace = "http://org.openecomp.mso/vnfNotify", className = "org.openecomp.mso.adapters.vnf.async.client.DeleteVnfNotification") + @Action(input = "http://org.openecomp.mso/notify/adapterNotify/deleteVnfNotificationRequest") + public void deleteVnfNotification( + @WebParam(name = "messageId", targetNamespace = "") + String messageId, + @WebParam(name = "completed", targetNamespace = "") + boolean completed, + @WebParam(name = "exception", targetNamespace = "") + MsoExceptionCategory exception, + @WebParam(name = "errorMessage", targetNamespace = "") + String errorMessage); + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/vnf/VnfAdapterNotify_Service.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/vnf/VnfAdapterNotify_Service.java new file mode 100644 index 0000000000..f79df76c5d --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/vnf/VnfAdapterNotify_Service.java @@ -0,0 +1,108 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common.adapter.vnf; + +import java.net.URL; +import javax.xml.namespace.QName; +import javax.xml.ws.Service; +import javax.xml.ws.WebEndpoint; +import javax.xml.ws.WebServiceClient; +import javax.xml.ws.WebServiceException; +import javax.xml.ws.WebServiceFeature; + + +/** + * This class was generated by the JAX-WS RI. + * JAX-WS RI 2.2.8 + * Generated source version: 2.2 + * + */ +@WebServiceClient(name = "vnfAdapterNotify", targetNamespace = "http://org.openecomp.mso/vnfNotify", wsdlLocation = "/VnfAdapterNotify.wsdl") +public class VnfAdapterNotify_Service extends Service +{ + + private final static URL VNFADAPTERNOTIFY_WSDL_LOCATION; + private final static WebServiceException VNFADAPTERNOTIFY_EXCEPTION; + private final static QName VNFADAPTERNOTIFY_QNAME = new QName("http://org.openecomp.mso/vnfNotify", "vnfAdapterNotify"); + + static { + VNFADAPTERNOTIFY_WSDL_LOCATION = org.openecomp.mso.bpmn.common.adapter.vnf.VnfAdapterNotify_Service.class.getResource("/VnfAdapterNotify.wsdl"); + WebServiceException e = null; + if (VNFADAPTERNOTIFY_WSDL_LOCATION == null) { + e = new WebServiceException("Cannot find '/VnfAdapterNotify.wsdl' wsdl. Place the resource correctly in the classpath."); + } + VNFADAPTERNOTIFY_EXCEPTION = e; + } + + public VnfAdapterNotify_Service() { + super(__getWsdlLocation(), VNFADAPTERNOTIFY_QNAME); + } + + public VnfAdapterNotify_Service(WebServiceFeature... features) { + super(__getWsdlLocation(), VNFADAPTERNOTIFY_QNAME, features); + } + + public VnfAdapterNotify_Service(URL wsdlLocation) { + super(wsdlLocation, VNFADAPTERNOTIFY_QNAME); + } + + public VnfAdapterNotify_Service(URL wsdlLocation, WebServiceFeature... features) { + super(wsdlLocation, VNFADAPTERNOTIFY_QNAME, features); + } + + public VnfAdapterNotify_Service(URL wsdlLocation, QName serviceName) { + super(wsdlLocation, serviceName); + } + + public VnfAdapterNotify_Service(URL wsdlLocation, QName serviceName, WebServiceFeature... features) { + super(wsdlLocation, serviceName, features); + } + + /** + * + * @return + * returns VnfAdapterNotify + */ + @WebEndpoint(name = "MsoVnfAdapterAsyncImplPort") + public VnfAdapterNotify getMsoVnfAdapterAsyncImplPort() { + return super.getPort(new QName("http://org.openecomp.mso/vnfNotify", "MsoVnfAdapterAsyncImplPort"), VnfAdapterNotify.class); + } + + /** + * + * @param features + * A list of {@link javax.xml.ws.WebServiceFeature} to configure on the proxy. Supported features not in the <code>features</code> parameter will have their default values. + * @return + * returns VnfAdapterNotify + */ + @WebEndpoint(name = "MsoVnfAdapterAsyncImplPort") + public VnfAdapterNotify getMsoVnfAdapterAsyncImplPort(WebServiceFeature... features) { + return super.getPort(new QName("http://org.openecomp.mso/vnfNotify", "MsoVnfAdapterAsyncImplPort"), VnfAdapterNotify.class, features); + } + + private static URL __getWsdlLocation() { + if (VNFADAPTERNOTIFY_EXCEPTION!= null) { + throw VNFADAPTERNOTIFY_EXCEPTION; + } + return VNFADAPTERNOTIFY_WSDL_LOCATION; + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/vnf/VnfRollback.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/vnf/VnfRollback.java new file mode 100644 index 0000000000..b37866cbe1 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/vnf/VnfRollback.java @@ -0,0 +1,210 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common.adapter.vnf; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlType; + + +/** + * <p>Java class for vnfRollback complex type. + * + * <p>The following schema fragment specifies the expected content contained within this class. + * + * <pre> + * <complexType name="vnfRollback"> + * <complexContent> + * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> + * <sequence> + * <element name="cloudSiteId" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> + * <element name="msoRequest" type="{http://org.openecomp.mso/vnfNotify}msoRequest" minOccurs="0"/> + * <element name="tenantCreated" type="{http://www.w3.org/2001/XMLSchema}boolean"/> + * <element name="tenantId" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> + * <element name="vnfCreated" type="{http://www.w3.org/2001/XMLSchema}boolean"/> + * <element name="vnfId" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> + * </sequence> + * </restriction> + * </complexContent> + * </complexType> + * </pre> + * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "vnfRollback", propOrder = { + "cloudSiteId", + "msoRequest", + "tenantCreated", + "tenantId", + "vnfCreated", + "vnfId" +}) +public class VnfRollback { + + protected String cloudSiteId; + protected MsoRequest msoRequest; + protected boolean tenantCreated; + protected String tenantId; + protected boolean vnfCreated; + protected String vnfId; + + /** + * Gets the value of the cloudSiteId property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getCloudSiteId() { + return cloudSiteId; + } + + /** + * Sets the value of the cloudSiteId property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setCloudSiteId(String value) { + this.cloudSiteId = value; + } + + /** + * Gets the value of the msoRequest property. + * + * @return + * possible object is + * {@link MsoRequest } + * + */ + public MsoRequest getMsoRequest() { + return msoRequest; + } + + /** + * Sets the value of the msoRequest property. + * + * @param value + * allowed object is + * {@link MsoRequest } + * + */ + public void setMsoRequest(MsoRequest value) { + this.msoRequest = value; + } + + /** + * Gets the value of the tenantCreated property. + * + */ + public boolean isTenantCreated() { + return tenantCreated; + } + + /** + * Sets the value of the tenantCreated property. + * + */ + public void setTenantCreated(boolean value) { + this.tenantCreated = value; + } + + /** + * Gets the value of the tenantId property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getTenantId() { + return tenantId; + } + + /** + * Sets the value of the tenantId property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setTenantId(String value) { + this.tenantId = value; + } + + /** + * Gets the value of the vnfCreated property. + * + */ + public boolean isVnfCreated() { + return vnfCreated; + } + + /** + * Sets the value of the vnfCreated property. + * + */ + public void setVnfCreated(boolean value) { + this.vnfCreated = value; + } + + /** + * Gets the value of the vnfId property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getVnfId() { + return vnfId; + } + + /** + * Sets the value of the vnfId property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setVnfId(String value) { + this.vnfId = value; + } + + public String toString() { + String msoRequestElement = msoRequest == null ? "" + : "<msoRequest>"+msoRequest+"</msoRequest>" + '\n'; + + return + "<cloudSiteId>"+cloudSiteId+"</cloudSiteId>" + '\n' + + msoRequestElement + + "<tenantCreated>"+tenantCreated+"</tenantCreated>" + '\n' + + "<tenantId>"+tenantId+"</tenantId>" + '\n' + + "<vnfCreated>"+vnfCreated+"</vnfCreated>" + '\n' + + "<vnfId>"+vnfId+"</vnfId>"; + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/vnf/VnfStatus.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/vnf/VnfStatus.java new file mode 100644 index 0000000000..a9b2ee2732 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/vnf/VnfStatus.java @@ -0,0 +1,61 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common.adapter.vnf; + +import javax.xml.bind.annotation.XmlEnum; +import javax.xml.bind.annotation.XmlType; + + +/** + * <p>Java class for vnfStatus. + * + * <p>The following schema fragment specifies the expected content contained within this class. + * <p> + * <pre> + * <simpleType name="vnfStatus"> + * <restriction base="{http://www.w3.org/2001/XMLSchema}string"> + * <enumeration value="ACTIVE"/> + * <enumeration value="FAILED"/> + * <enumeration value="NOTFOUND"/> + * <enumeration value="UNKNOWN"/> + * </restriction> + * </simpleType> + * </pre> + * + */ +@XmlType(name = "vnfStatus") +@XmlEnum +public enum VnfStatus { + + ACTIVE, + FAILED, + NOTFOUND, + UNKNOWN; + + public String value() { + return name(); + } + + public static VnfStatus fromValue(String v) { + return valueOf(v); + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/vnf/package-info.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/vnf/package-info.java new file mode 100644 index 0000000000..6759fda81b --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/vnf/package-info.java @@ -0,0 +1,22 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +@javax.xml.bind.annotation.XmlSchema(namespace = "http://org.openecomp.mso/vnfNotify") +package org.openecomp.mso.bpmn.common.adapter.vnf; diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/util/CryptoHandler.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/util/CryptoHandler.java new file mode 100644 index 0000000000..1759b208b7 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/util/CryptoHandler.java @@ -0,0 +1,57 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common.util; + +import java.security.GeneralSecurityException; + +public class CryptoHandler implements ICryptoHandler { + + private static String msoKey = "aa3871669d893c7fb8abbcda31b88b4f"; + //private static String msoAaiPwd = "mso0206"; + private static String msoAaiEncryptedPwd = "C1FC4A39E16419DD41DFC1212843F440"; + + public String getMsoAaiPassword() { + try { + return CryptoUtils.decrypt(msoAaiEncryptedPwd, msoKey); + } catch (GeneralSecurityException e) { + return null; + } + } + + + public String encryptMsoPassword(String plainMsoPwd) { + try { + return CryptoUtils.encrypt(plainMsoPwd, msoKey); + } catch (GeneralSecurityException e) { + return null; + } + } + + + public String decryptMsoPassword(String encryptedPwd) { + try { + return CryptoUtils.decrypt(encryptedPwd, msoKey); + } catch (GeneralSecurityException e) { + return null; + } + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/util/CryptoUtils.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/util/CryptoUtils.java new file mode 100644 index 0000000000..70aeda01b0 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/util/CryptoUtils.java @@ -0,0 +1,118 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common.util; + + +import java.security.GeneralSecurityException; +import java.security.NoSuchAlgorithmException; + +import javax.crypto.Cipher; +import javax.crypto.spec.SecretKeySpec; + +//Need to add BPM error handler + +/** + * CryptoUtils adapted from RTTP client. + * + */ +public class CryptoUtils { + + public static final String AES = "AES"; + + /** + * encrypt a value and generate a keyfile + * if the keyfile is not found then a new one is created + * @throws GeneralSecurityException + * @throws IOException + */ + public static String encrypt(String value, String keyString) throws GeneralSecurityException + { + SecretKeySpec sks = getSecretKeySpec(keyString); + Cipher cipher = Cipher.getInstance(CryptoUtils.AES); + cipher.init(Cipher.ENCRYPT_MODE, sks, cipher.getParameters()); + byte[] encrypted = cipher.doFinal(value.getBytes()); + return byteArrayToHexString(encrypted); + } + + /** + * decrypt a value + * @throws GeneralSecurityException + * @throws IOException + */ + public static String decrypt(String message, String keyString) throws GeneralSecurityException + { + SecretKeySpec sks = getSecretKeySpec(keyString); + Cipher cipher = Cipher.getInstance(CryptoUtils.AES); + cipher.init(Cipher.DECRYPT_MODE, sks); + byte[] decrypted = cipher.doFinal(hexStringToByteArray(message)); + return new String(decrypted); + } + + private static SecretKeySpec getSecretKeySpec(String keyString) throws NoSuchAlgorithmException + { + byte [] key = hexStringToByteArray(keyString); + SecretKeySpec sks = new SecretKeySpec(key, CryptoUtils.AES); + return sks; + } + + + private static String byteArrayToHexString(byte[] b){ + StringBuffer sb = new StringBuffer(b.length * 2); + for (int i = 0; i < b.length; i++){ + int v = b[i] & 0xff; + if (v < 16) { + sb.append('0'); + } + sb.append(Integer.toHexString(v)); + } + return sb.toString().toUpperCase(); + } + + private static byte[] hexStringToByteArray(String s) { + byte[] b = new byte[s.length() / 2]; + for (int i = 0; i < b.length; i++){ + int index = i * 2; + int v = Integer.parseInt(s.substring(index, index + 2), 16); + b[i] = (byte)v; + } + return b; + } + + /** + * Not Used... + * + * Call Rttp utility jar to encrypt pwd + * @param clearPassword + * @return + * @throws GeneralSecurityException + * @throws Exception + * + public static String encryptRttpPwd(String clearPassword) throws GeneralSecurityException { + try { + return RttpBasicAuth.encrypt(clearPassword); + } catch (Exception e) { + // wrap generic exception + throw new GeneralSecurityException(e); + } + } + */ +} + diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/util/ICryptoHandler.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/util/ICryptoHandler.java new file mode 100644 index 0000000000..8d4f167596 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/util/ICryptoHandler.java @@ -0,0 +1,27 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common.util; + +public interface ICryptoHandler { + public String getMsoAaiPassword(); + public String encryptMsoPassword(String plainPwd); + public String decryptMsoPassword(String encryptedPwd); +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/SDNCAdapterCallbackServiceImpl.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/SDNCAdapterCallbackServiceImpl.java new file mode 100644 index 0000000000..02a471c971 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/SDNCAdapterCallbackServiceImpl.java @@ -0,0 +1,254 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common.workflow.service; + +import java.util.HashMap; +import java.util.Map; + +import javax.jws.WebMethod; +import javax.jws.WebParam; +import javax.jws.WebResult; +import javax.jws.WebService; +import javax.ws.rs.core.Context; +import javax.xml.ws.WebServiceContext; + +import org.camunda.bpm.BpmPlatform; +import org.camunda.bpm.engine.MismatchingMessageCorrelationException; +import org.camunda.bpm.engine.ProcessEngineServices; +import org.camunda.bpm.engine.RuntimeService; +import org.openecomp.mso.bpmn.common.adapter.sdnc.SDNCAdapterCallbackRequest; +import org.openecomp.mso.bpmn.common.adapter.sdnc.SDNCAdapterResponse; +import org.openecomp.mso.bpmn.common.adapter.sdnc.SDNCCallbackAdapterPortType; +import org.openecomp.mso.bpmn.core.PropertyConfiguration; +import org.openecomp.mso.logger.MessageEnum; +import org.openecomp.mso.logger.MsoLogger; +/** + * @version 1.0 + * + */ +@WebService(serviceName="SDNCAdapterCallbackService", targetNamespace="http://org.openecomp/workflow/sdnc/adapter/schema/v1") +public class SDNCAdapterCallbackServiceImpl implements SDNCCallbackAdapterPortType { + + private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL); + private final int DEFAULT_RETRY_ATTEMPTS = 60; + private final int DEFAULT_SLEEP_TIME = 500; + + private final String logMarker = "[SDNC-CALLBACK]"; + + @Context WebServiceContext wsContext; + + private volatile ProcessEngineServices pes4junit = null; + + @WebMethod(operationName = "SDNCAdapterCallback") + @WebResult(name = "SDNCAdapterResponse", targetNamespace = "http://org.openecomp/workflow/sdnc/adapter/schema/v1", partName = "SDNCAdapterCallbackResponse") + public SDNCAdapterResponse sdncAdapterCallback( + @WebParam(name = "SDNCAdapterCallbackRequest", targetNamespace = "http://org.openecomp/workflow/sdnc/adapter/schema/v1", partName = "SDNCAdapterCallbackRequest") + SDNCAdapterCallbackRequest sdncAdapterCallbackRequest) { + + //Callback URL to use http://localhost:28080/mso/SDNCAdapterCallbackService + ProcessEngineServices pes = getProcessEngineServices(); + RuntimeService runtimeService = pes.getRuntimeService(); + String receivedRequestId = sdncAdapterCallbackRequest.getCallbackHeader().getRequestId(); + MsoLogger.setServiceName("MSO." + "sdncAdapter"); + MsoLogger.setLogContext(receivedRequestId, "N/A"); + msoLogger.debug(logMarker + "Received callback response:" + sdncAdapterCallbackRequest.toString()); + SDNCAdapterResponse sdncAdapterResponse; + long startTime = System.currentTimeMillis(); + + /* Check to make sure the process instance is reay for correlation*/ + isReadyforCorrelation(runtimeService, receivedRequestId); + + msoLogger.debug(logMarker + "*** Received MSO sdncAdapterCallbackService ******"); + + msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Call to MSO sdncAdapterCallbackService"); + + msoLogger.debug(logMarker + "Callback response string:\n" + sdncAdapterCallbackRequest.toString()); + + String reqId = receivedRequestId; + Map<String,Object> variables = new HashMap<String,Object>(); + variables.put("SDNCA_requestId", reqId ); + variables.put("sdncAdapterCallbackRequest", sdncAdapterCallbackRequest.toString()); + + /*Correlating the response with the running instance*/ + + // NOTE: the following loop is a workaround for problems we've had + // with reliability of the runtime service. It seems that queries + // sometimes return results, and sometimes they don't. This might + // be a problem in mysql only. We aren't sure if it affects camunda + // on oracle or mariadb. The workaround is to repeat the request + // a number of times until it succeeds. If it doesn't succeed after + // 60 tries, then we give up. + + int maxAttempts = DEFAULT_RETRY_ATTEMPTS; + int attempt = 1; + int sleepTime = DEFAULT_SLEEP_TIME; + + Map<String,String> bpmnProperties = getMSOBPMNURNProperties(); + if (bpmnProperties != null) { + try { + maxAttempts = Integer.parseInt(bpmnProperties.get("mso.callbackRetryAttempts")); + msoLogger.debug(logMarker + "mso.callbackRetryAttempts=" + maxAttempts); + sleepTime = Integer.parseInt(bpmnProperties.get("mso.callbackRetrySleepTime")); + msoLogger.debug(logMarker + "mso.callbackRetrySleepTime:" + sleepTime); + } catch (Exception ex) { + + msoLogger.info (MessageEnum.BPMN_SDNC_CALLBACK_EXCEPTION, "BPMN", logMarker + + "Error parsing mso.callbackRetrySleepTime/mso.callbackRetryAttempts:" + + sleepTime + ":" + + maxAttempts); + + msoLogger.error (MessageEnum.BPMN_SDNC_CALLBACK_EXCEPTION, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, logMarker + + "Error parsing mso.callbackRetrySleepTime/mso.callbackRetryAttempts:" + + sleepTime + ":" + + maxAttempts); + + } + } + + while (true) { + try { + // sdncAdapterCallbackRequest is the message event name (defined in the bpmn process) + runtimeService.createMessageCorrelation("sdncAdapterCallbackRequest") + .setVariables(variables) + .processInstanceVariableEquals("SDNCA_requestId", reqId).correlate(); + sdncAdapterResponse = new SDNCAdapterResponse(); + msoLogger.debug(logMarker + "***** Completed processing of MSO sdncAdapterCallbackService ******"); + + msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, logMarker + + "Completed the execution of MSO SDNCAdapterCallbackService."); + + msoLogger.recordMetricEvent ( startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, + logMarker + "Completed the execution of MSO SDNCAdapterCallbackService.", "BPMN", + MsoLogger.getServiceName(), "sdncAdapterCallback"); + + return sdncAdapterResponse; + } catch(MismatchingMessageCorrelationException e) { + msoLogger.debug(logMarker + "[CORM]correlation id mismatch (attempt " + attempt + "/" + maxAttempts + ")"); + if (attempt == maxAttempts) { + // Couldn't correlate requestId to any active flow + //MsoLogger logger = MsoLogger.getMsoLogger("SDNCAdapterCallbackService"); + String msg = + "SDNC Adapter Callback Service received a SDNC Adapter Callback Request with RequestId '" + + receivedRequestId + + "' but that RequestId could not be correlated to any active process - ignoring the Request"; + sdncAdapterResponse = new SDNCAdapterExceptionResponse(e); + + msoLogger.error (MessageEnum.BPMN_SDNC_CALLBACK_EXCEPTION, "BPMN", MsoLogger.getServiceName(), + MsoLogger.ErrorCode.UnknownError, logMarker + ":" + msg, e); + + msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, logMarker + + "Completed the execution of MSO SDNCAdapterCallbackService." ); + + msoLogger.recordMetricEvent ( startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, + logMarker + "Completed the execution of MSO SDNCAdapterCallbackService.", "BPMN", + MsoLogger.getServiceName(), "sdncAdapterCallback"); + + return sdncAdapterResponse; + } + + try { + Thread.sleep(sleepTime); + } catch (InterruptedException e2) { + String msg = + "SDNC Adapter Callback Service received a SDNC Adapter Callback Request with RequestId '" + + receivedRequestId + + "' but correlation was interrupted"; + sdncAdapterResponse = new SDNCAdapterExceptionResponse(e); + + msoLogger.error (MessageEnum.BPMN_SDNC_CALLBACK_EXCEPTION, "BPMN", MsoLogger.getServiceName(), + MsoLogger.ErrorCode.UnknownError, logMarker + ":" + msg, e); + + msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, logMarker + + "Completed the execution of MSO SDNCAdapterCallbackService."); + + msoLogger.recordMetricEvent ( startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, + logMarker + "Completed the execution of MSO SDNCAdapterCallbackService.", "BPMN", + MsoLogger.getServiceName(), "sdncAdapterCallback"); + + return sdncAdapterResponse; + } + } + + attempt++; + } + } + + + private Map<String,String> getMSOBPMNURNProperties() { + PropertyConfiguration propertyConfiguration = PropertyConfiguration.getInstance(); + Map<String,String> props = propertyConfiguration.getProperties("mso.bpmn.urn.properties"); + return props; + } + + private void isReadyforCorrelation(RuntimeService runtimeService, + String receivedRequestId) { + long waitingInstances = runtimeService.createExecutionQuery() // + .messageEventSubscriptionName("sdncAdapterCallbackRequest") + .processVariableValueEquals("SDNCA_requestId", receivedRequestId).count(); + //Workaround for performance testing, explicit wait for a second for the transactions to be committed + try { + Thread.sleep(1000); + } catch (InterruptedException e1) { + } + + int retries = 50; + while (waitingInstances==0 && retries > 0) { + try { + Thread.sleep(100); + } catch (InterruptedException e) { + + msoLogger.error (MessageEnum.BPMN_SDNC_CALLBACK_EXCEPTION, "BPMN", MsoLogger.getServiceName(), + MsoLogger.ErrorCode.UnknownError, logMarker, e); + + } // you can still play with the numbers + waitingInstances = runtimeService.createExecutionQuery() // + .messageEventSubscriptionName("sdncAdapterCallbackRequest") + .processVariableValueEquals("SDNCA_requestId", receivedRequestId).count(); + retries--; + } + } + + private ProcessEngineServices getProcessEngineServices() { + if (pes4junit == null) { + return BpmPlatform.getDefaultProcessEngine(); + } else { + return pes4junit; + } + } + + @WebMethod(exclude=true) + public void setProcessEngineServices4junit(ProcessEngineServices pes) { + pes4junit = pes; + } + + public class SDNCAdapterExceptionResponse extends SDNCAdapterResponse { + private Exception ex; + + public SDNCAdapterExceptionResponse(Exception ex) { + super(); + this.ex = ex; + } + + public Exception getException() { + return ex; + } + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/VnfAdapterNotifyServiceImpl.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/VnfAdapterNotifyServiceImpl.java new file mode 100644 index 0000000000..457717243a --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/VnfAdapterNotifyServiceImpl.java @@ -0,0 +1,536 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common.workflow.service; + +import java.util.HashMap; +import java.util.Map; + +import javax.jws.Oneway; +import javax.jws.WebMethod; +import javax.jws.WebParam; +import javax.jws.WebService; +import javax.ws.rs.core.Context; +import javax.xml.ws.Action; +import javax.xml.ws.RequestWrapper; +import javax.xml.ws.WebServiceContext; + +import org.camunda.bpm.BpmPlatform; +import org.camunda.bpm.engine.MismatchingMessageCorrelationException; +import org.camunda.bpm.engine.ProcessEngineServices; +import org.camunda.bpm.engine.RuntimeService; +import org.openecomp.mso.bpmn.common.adapter.vnf.CreateVnfNotification; +import org.openecomp.mso.bpmn.common.adapter.vnf.DeleteVnfNotification; +import org.openecomp.mso.bpmn.common.adapter.vnf.MsoExceptionCategory; +import org.openecomp.mso.bpmn.common.adapter.vnf.QueryVnfNotification; +import org.openecomp.mso.bpmn.common.adapter.vnf.RollbackVnfNotification; +import org.openecomp.mso.bpmn.common.adapter.vnf.UpdateVnfNotification; +import org.openecomp.mso.bpmn.common.adapter.vnf.VnfAdapterNotify; +import org.openecomp.mso.bpmn.common.adapter.vnf.VnfRollback; +import org.openecomp.mso.bpmn.common.adapter.vnf.VnfStatus; +import org.openecomp.mso.logger.MessageEnum; +import org.openecomp.mso.logger.MsoLogger; + +/** + * This is the service class for VnfAdapterNotify + * TODO: Add addition VnfAdapterNotify Methods for remaining VnfAdapterNotify operations. + */ + +@WebService(serviceName = "vnfAdapterNotify", targetNamespace = "http://org.openecomp.mso/vnfNotify") +public class VnfAdapterNotifyServiceImpl implements VnfAdapterNotify{ + + private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL); + + private final String logMarker = "[VNF-NOTIFY]"; + + @Context WebServiceContext wsContext; + + private volatile ProcessEngineServices pes4junit = null; + + /** + * + * @param errorMessage + * @param exception + * @param messageId + * @param completed + */ + @WebMethod(operationName = "rollbackVnfNotification") + @Oneway + @RequestWrapper(localName = "rollbackVnfNotification", targetNamespace = "http://org.openecomp.mso/vnfNotify", className = "org.openecomp.mso.adapters.vnf.async.client.RollbackVnfNotification") + @Action(input = "http://org.openecomp.mso/notify/adapterNotify/rollbackVnfNotificationRequest") + public void rollbackVnfNotification( + @WebParam(name = "messageId", targetNamespace = "") + String messageId, + @WebParam(name = "completed", targetNamespace = "") + boolean completed, + @WebParam(name = "exception", targetNamespace = "") + MsoExceptionCategory exception, + @WebParam(name = "errorMessage", targetNamespace = "") + String errorMessage) { + + + + RollbackVnfNotification rollbackVnfNotification = new RollbackVnfNotification(); + + rollbackVnfNotification.setMessageId(messageId); + rollbackVnfNotification.setCompleted(completed); + rollbackVnfNotification.setException(exception); + rollbackVnfNotification.setErrorMessage(errorMessage); + + ProcessEngineServices pes = getProcessEngineServices(); + RuntimeService runtimeService = pes.getRuntimeService(); + + MsoLogger.setServiceName("MSO." + "vnfAdapterRollback"); + MsoLogger.setLogContext(messageId, "N/A"); + msoLogger.debug(logMarker + "Received RollbackVnfNotification" + rollbackVnfNotification.toString()); + + long startTime = System.currentTimeMillis(); + try { + + /* Check to make sure the process instance is ready for correlation*/ + isReadyforCorrelation(runtimeService, messageId, "rollbackVnfNotificationCallback", "VNFRB_messageId"); + + msoLogger.debug(logMarker + "*** Received MSO rollbackVnfNotification Callback ******"); + msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Call to MSO VnfAdapterNotifyService "); + msoLogger.debug(logMarker + "Rollback VNF Notification string:\n" + rollbackVnfNotification.toString()); + + System.out.println("testing ROllbackVnfNotification : " + rollbackVnfNotification.toString()); + + Map<String,Object> variables = new HashMap<String,Object>(); + variables.put("VNFRB_messageId", messageId ); + variables.put("rollbackVnfNotificationCallback", rollbackVnfNotification.toString()); + + /*Correlating the response with the running instance*/ + + runtimeService.createMessageCorrelation("rollbackVnfNotificationCallback").setVariables(variables) + .processInstanceVariableEquals("VNFRB_messageId", messageId).correlate(); + + msoLogger.debug(logMarker + "***** Completed processing of MSO VnfAdapterNotifyService ******"); + } catch(MismatchingMessageCorrelationException e) { + msoLogger.debug(logMarker + "[CORM]correlation id mismatch"); + String msg = + "VNF Adapter Notify Service received a Create VNF Notification request with RequestId '" + + messageId + + "' but that RequestId could not be correlated to any active process - ignoring the request"; + + msoLogger.error (MessageEnum.BPMN_GENERAL_EXCEPTION, "BPMN", MsoLogger.getServiceName(), + MsoLogger.ErrorCode.UnknownError, logMarker + ":" + msg); + + } + msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, + logMarker + "Completed the execution of MSO Vnf Adapter Notify for Rollback VNF Notification."); + + msoLogger.recordMetricEvent ( startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, + logMarker + "Completed the execution of MSO Vnf Adapter Notify for Rollback VNF Notification.", "BPMN", + MsoLogger.getServiceName(), "rollbackVnfNotification"); + + return; + } + + + + /** + * + * @param errorMessage + * @param vnfExists + * @param status + * @param exception + * @param outputs + * @param messageId + * @param vnfId + * @param completed + */ + @WebMethod(operationName = "queryVnfNotification") + @Oneway + @RequestWrapper(localName = "queryVnfNotification", targetNamespace = "http://org.openecomp.mso/vnfNotify", className = "org.openecomp.mso.adapters.vnf.async.client.QueryVnfNotification") + @Action(input = "http://org.openecomp.mso/notify/adapterNotify/queryVnfNotificationRequest") + public void queryVnfNotification( + @WebParam(name = "messageId", targetNamespace = "") + String messageId, + @WebParam(name = "completed", targetNamespace = "") + boolean completed, + @WebParam(name = "exception", targetNamespace = "") + MsoExceptionCategory exception, + @WebParam(name = "errorMessage", targetNamespace = "") + String errorMessage, + @WebParam(name = "vnfExists", targetNamespace = "") + Boolean vnfExists, + @WebParam(name = "vnfId", targetNamespace = "") + String vnfId, + @WebParam(name = "status", targetNamespace = "") + VnfStatus status, + @WebParam(name = "outputs", targetNamespace = "") + org.openecomp.mso.bpmn.common.adapter.vnf.QueryVnfNotification.Outputs outputs){ + + QueryVnfNotification queryVnfNotification = new QueryVnfNotification(); + + queryVnfNotification.setMessageId(messageId); + queryVnfNotification.setCompleted(completed); + queryVnfNotification.setException(exception); + queryVnfNotification.setErrorMessage(errorMessage); + queryVnfNotification.setVnfExists(vnfExists); + queryVnfNotification.setVnfId(vnfId); + queryVnfNotification.setStatus(status); + queryVnfNotification.setOutputs(outputs); + + + ProcessEngineServices pes = getProcessEngineServices(); + RuntimeService runtimeService = pes.getRuntimeService(); + + MsoLogger.setServiceName("MSO." + "vnf Adapter Query"); + MsoLogger.setLogContext(messageId, "N/A"); + msoLogger.debug(logMarker + "Received QueryVnfNotification" + queryVnfNotification.toString()); + + System.out.println("Received QueryVnfNotification : " + queryVnfNotification.toString()); + + long startTime = System.currentTimeMillis(); + try { + + /* Check to make sure the process instance is ready for correlation*/ + isReadyforCorrelation(runtimeService, messageId, "queryVnfNotificationCallback", "VNFQ_messageId"); + + msoLogger.debug(logMarker + "*** Received MSO queryVnfNotification Callback ******"); + msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Call to MSO VnfAdapterNotifyService "); + msoLogger.debug(logMarker + "Query VNF Notification string:\n" + queryVnfNotification.toString()); + + Map<String,Object> variables = new HashMap<String,Object>(); + variables.put("VNFQ_messageId", messageId ); + variables.put("queryVnfNotificationCallback", queryVnfNotification.toString()); + + /*Correlating the response with the running instance*/ + + runtimeService.createMessageCorrelation("queryVnfNotificationCallback").setVariables(variables) + .processInstanceVariableEquals("VNFQ_messageId", messageId).correlate(); + + msoLogger.debug(logMarker + "***** Completed processing of MSO VnfAdapterNotifyService ******"); + } catch(MismatchingMessageCorrelationException e) { + msoLogger.debug(logMarker + "[CORM]correlation id mismatch"); + String msg = + "VNF Adapter Notify Service received a Query VNF Notification request with RequestId '" + + messageId + + "' but that RequestId could not be correlated to any active process - ignoring the request"; + + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION, "BPMN", MsoLogger.getServiceName(), + MsoLogger.ErrorCode.UnknownError, logMarker + ":" + msg, e); + } + + msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, + logMarker + "Completed the execution of MSO Vnf Adapter Notify for Query VNF Notification."); + + return; + } + + + + + /** + * + * @param errorMessage + * @param exception + * @param rollback + * @param outputs + * @param messageId + * @param vnfId + * @param completed + */ + @WebMethod(operationName = "createVnfNotification") + @Oneway + @RequestWrapper(localName = "createVnfNotification", targetNamespace = "http://org.openecomp.mso/vnfNotify", className = "org.openecomp.mso.adapters.vnf.async.client.CreateVnfNotification") + @Action(input = "http://org.openecomp.mso/notify/adapterNotify/createVnfNotificationRequest") + public void createVnfNotification( + @WebParam(name = "messageId", targetNamespace = "") + String messageId, + @WebParam(name = "completed", targetNamespace = "") + boolean completed, + @WebParam(name = "exception", targetNamespace = "") + MsoExceptionCategory exception, + @WebParam(name = "errorMessage", targetNamespace = "") + String errorMessage, + @WebParam(name = "vnfId", targetNamespace = "") + String vnfId, + @WebParam(name = "outputs", targetNamespace = "") + org.openecomp.mso.bpmn.common.adapter.vnf.CreateVnfNotification.Outputs outputs, + @WebParam(name = "rollback", targetNamespace = "") + VnfRollback rollback){ + + CreateVnfNotification createVnfNotification = new CreateVnfNotification(); + + createVnfNotification.setMessageId(messageId); + createVnfNotification.setCompleted(completed); + createVnfNotification.setException(exception); + createVnfNotification.setErrorMessage(errorMessage); + createVnfNotification.setVnfId(vnfId); + createVnfNotification.setOutputs(outputs); + createVnfNotification.setRollback(rollback); + + ProcessEngineServices pes = getProcessEngineServices(); + RuntimeService runtimeService = pes.getRuntimeService(); + + MsoLogger.setServiceName("MSO." + "vnf Adapter Create"); + MsoLogger.setLogContext(messageId, "N/A"); + msoLogger.debug(logMarker + "Received CreateVnfNotification - " + createVnfNotification.toString()); + + long startTime = System.currentTimeMillis(); + try { + + /* Check to make sure the process instance is ready for correlation*/ + isReadyforCorrelation(runtimeService, messageId, "createVnfNotificationCallback", "VNFC_messageId"); + + msoLogger.debug(logMarker + "*** Received MSO createVnfNotification Callback ******"); + msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Call to MSO VnfAdapterNotifyService "); + + msoLogger.debug(logMarker + "Create VNF Notification string:\n" + createVnfNotification.toString()); + + Map<String,Object> variables = new HashMap<String,Object>(); + variables.put("VNFC_messageId", messageId ); + variables.put("createVnfNotificationCallback", createVnfNotification.toString()); + + /*Correlating the response with the running instance*/ + + runtimeService.createMessageCorrelation("createVnfNotificationCallback").setVariables(variables) + .processInstanceVariableEquals("VNFC_messageId", messageId).correlate(); + + msoLogger.debug(logMarker + "***** Completed processing of MSO VnfAdapterNotifyService ******"); + } catch(MismatchingMessageCorrelationException e) { + msoLogger.debug(logMarker + "[CORM]correlation id mismatch"); + String msg = + "VNF Adapter Notify Service received a Create VNF Notification request with RequestId '" + + messageId + + "' but that RequestId could not be correlated to any active process - ignoring the request"; + + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION, "BPMN", MsoLogger.getServiceName(), + MsoLogger.ErrorCode.UnknownError, logMarker + ":" + msg, e); + + } + msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, + logMarker + "Completed the execution of MSO Vnf Adapter Notify for Query VNF Notification."); + + msoLogger.recordMetricEvent ( startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, + logMarker + "Completed the execution of MSO Vnf Adapter Notify for Query VNF Notification.", "BPMN", + MsoLogger.getServiceName(), "createVnfNotification"); + + return; + } + + /** + * + * @param errorMessage + * @param exception + * @param rollback + * @param outputs + * @param messageId + * @param completed + */ + @WebMethod(operationName = "updateVnfNotification") + @Oneway + @RequestWrapper(localName = "updateVnfNotification", targetNamespace = "http://org.openecomp.mso/vnfNotify", className = "org.openecomp.mso.adapters.vnf.async.client.UpdateVnfNotification") + @Action(input = "http://org.openecomp.mso/notify/adapterNotify/updateVnfNotificationRequest") + public void updateVnfNotification( + @WebParam(name = "messageId", targetNamespace = "") + String messageId, + @WebParam(name = "completed", targetNamespace = "") + boolean completed, + @WebParam(name = "exception", targetNamespace = "") + MsoExceptionCategory exception, + @WebParam(name = "errorMessage", targetNamespace = "") + String errorMessage, + @WebParam(name = "outputs", targetNamespace = "") + org.openecomp.mso.bpmn.common.adapter.vnf.UpdateVnfNotification.Outputs outputs, + @WebParam(name = "rollback", targetNamespace = "") + VnfRollback rollback){ + + UpdateVnfNotification updateVnfNotification = new UpdateVnfNotification(); + + updateVnfNotification.setMessageId(messageId); + updateVnfNotification.setCompleted(completed); + updateVnfNotification.setException(exception); + updateVnfNotification.setErrorMessage(errorMessage); + updateVnfNotification.setOutputs(outputs); + updateVnfNotification.setRollback(rollback); + + ProcessEngineServices pes = getProcessEngineServices(); + RuntimeService runtimeService = pes.getRuntimeService(); + + MsoLogger.setServiceName("MSO." + "vnf Adapter Update"); + MsoLogger.setLogContext(messageId, "N/A"); + msoLogger.debug(logMarker + "Received UpdateVnfNotification - " + updateVnfNotification.toString()); + + long startTime = System.currentTimeMillis(); + try { + + // Check to make sure the process instance is ready for correlation + isReadyforCorrelation(runtimeService, messageId, "updateVnfNotificationCallback", "VNFU_messageId"); + + msoLogger.debug(logMarker + "*** Received MSO updateVnfNotification Callback ******"); + msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Call to MSO VnfAdapterNotifyService "); + + msoLogger.debug(logMarker + "Update VNF Notification string:\n" + updateVnfNotification.toString()); + + Map<String,Object> variables = new HashMap<String,Object>(); + variables.put("VNFU_messageId", messageId ); + variables.put("updateVnfNotificationCallback", updateVnfNotification.toString()); + + //Correlating the response with the running instance + runtimeService.createMessageCorrelation("updateVnfNotificationCallback").setVariables(variables) + .processInstanceVariableEquals("VNFU_messageId", messageId).correlate(); + + msoLogger.debug(logMarker + "***** Completed processing of MSO VnfAdapterNotifyService ******"); + + } catch(MismatchingMessageCorrelationException e) { + msoLogger.debug(logMarker + "[CORM]correlation id mismatch"); + String msg = + "VNF Adapter Notify Service received a Update VNF Notification request with RequestId '" + + messageId + + "' but that RequestId could not be correlated to any active process - ignoring the request"; + + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION, "BPMN", MsoLogger.getServiceName(), + MsoLogger.ErrorCode.UnknownError, logMarker + ":" + msg, e); + + } + msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, + logMarker + "Completed the execution of MSO Vnf Adapter Notify for Update VNF Notification."); + + msoLogger.recordMetricEvent ( startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, + logMarker + "Completed the execution of MSO Vnf Adapter Notify for Update VNF Notification.", "BPMN", + MsoLogger.getServiceName(), "updateVnfNotification"); + + return; + } + + /** + * + * @param errorMessage + * @param exception + * @param messageId + * @param completed + */ + + //@WebService(serviceName="VNFAdapterDeleteCallbackV1", targetNamespace="http://org.openecomp.mso/vnfNotify") + @WebMethod(operationName = "deleteVnfNotification") + @Oneway + @RequestWrapper(localName = "deleteVnfNotification", targetNamespace = "http://org.openecomp.mso/vnfNotify", className = "org.openecomp.mso.adapters.vnf.async.client.DeleteVnfNotification") + @Action(input = "http://org.openecomp.mso/notify/adapterNotify/deleteVnfNotificationRequest") + public void deleteVnfNotification( + @WebParam(name = "messageId", targetNamespace = "") + String messageId, + @WebParam(name = "completed", targetNamespace = "") + boolean completed, + @WebParam(name = "exception", targetNamespace = "") + MsoExceptionCategory exception, + @WebParam(name = "errorMessage", targetNamespace = "") + String errorMessage) { + + //Callback URL to use http://localhost:28080/mso/services/VNFAdapterDeleteCallbackV1 + + //DeleteVnfNotification Class + DeleteVnfNotification deleteVnfNotification = new DeleteVnfNotification(); + deleteVnfNotification.setMessageId(messageId); + deleteVnfNotification.setCompleted(completed); + deleteVnfNotification.setException(exception); + deleteVnfNotification.setErrorMessage(errorMessage); + + ProcessEngineServices pes = getProcessEngineServices(); + RuntimeService runtimeService = pes.getRuntimeService(); + + MsoLogger.setServiceName("MSO." + "vnfAdapterDelete"); + MsoLogger.setLogContext(messageId, "N/A"); + msoLogger.debug(logMarker + "Received DeleteVnfNotification callback: " + deleteVnfNotification.toString()); + + long startTime = System.currentTimeMillis(); + try { + + /* Check to make sure the process instance is ready for correlation*/ + //isReadyforCorrelation(runtimeService, messageId, "deleteVnfACallback", "VNFDEL_uuid"); + + msoLogger.debug(logMarker + " *** Received MSO deleteVnfACallback ******"); + msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Call to MSO deleteVnfACallback "); + msoLogger.debug(logMarker + " Callback response string:\n" + deleteVnfNotification.toString()); + + Map<String,Object> variables = new HashMap<String,Object>(); + variables.put("VNFDEL_uuid", messageId); + variables.put("deleteVnfACallback", deleteVnfNotification.toString()); + + /*Correlating the response with the running instance*/ + + runtimeService.createMessageCorrelation("deleteVnfACallback") + .setVariables(variables) + .processInstanceVariableEquals("VNFDEL_uuid", messageId).correlate(); + + msoLogger.debug(logMarker + "***** Completed processing of MSO deleteVnfACallback ******"); + + } catch(MismatchingMessageCorrelationException e) { + + msoLogger.debug(logMarker + " [CORM]correlation id mismatch"); + // Couldn't correlate requestId to any active flow + //MsoLogger logger = MsoLogger.getMsoLogger("SDNCAdapterCallbackService"); + + String msg = + "Vnf Adapter Callback Service received a Vnf Adapter Callback with messageId '" + + messageId + + "' but that messageId could not be correlated to any active process - ignoring the Request"; + + msoLogger.error(MessageEnum.BPMN_SDNC_CALLBACK_EXCEPTION, "BPMN", MsoLogger.getServiceName(), + MsoLogger.ErrorCode.UnknownError, logMarker + ":" + msg, e); + + } + msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, + logMarker + "Completed the execution of MSO VNFAdapterDeleteCallbackV1."); + + msoLogger.recordMetricEvent ( startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, + logMarker + "Completed the execution of MSO VNFAdapterDeleteCallbackV1.", "BPMN", + MsoLogger.getServiceName(), "deleteVnfNotification"); + + return; + } + + private void isReadyforCorrelation(RuntimeService runtimeService, String requestId, String responseName, String correlationValue) { + + long waitingInstances = runtimeService.createExecutionQuery().messageEventSubscriptionName(responseName).processVariableValueEquals(correlationValue, requestId).count(); + int retries = 50; + while (waitingInstances==0 && retries > 0) { + try { + Thread.sleep(100); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + // should I add new exception Message to MessageEnum??? + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, logMarker, e); + + } // you can still play with the numbers + waitingInstances = runtimeService.createExecutionQuery() // + .messageEventSubscriptionName(responseName) + .processVariableValueEquals(correlationValue, requestId).count(); + retries--; + } + } + + + private ProcessEngineServices getProcessEngineServices() { + if (pes4junit == null) { + return BpmPlatform.getDefaultProcessEngine(); + } else { + return pes4junit; + } + } + + @WebMethod(exclude=true) + public void setProcessEngineServices4junit(ProcessEngineServices pes) { + pes4junit = pes; + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowAsyncCommonResource.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowAsyncCommonResource.java new file mode 100644 index 0000000000..5abd4e91da --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowAsyncCommonResource.java @@ -0,0 +1,36 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common.workflow.service; + +import org.camunda.bpm.engine.ProcessEngineServices; +import org.camunda.bpm.engine.ProcessEngines; + + +public class WorkflowAsyncCommonResource extends WorkflowAsyncResource { + + protected ProcessEngineServices getProcessEngineServices() { + if (pes4junit == null) { + return ProcessEngines.getProcessEngine("common"); + } else { + return pes4junit; + } + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowAsyncResource.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowAsyncResource.java new file mode 100644 index 0000000000..28541930ab --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowAsyncResource.java @@ -0,0 +1,293 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.openecomp.mso.bpmn.common.workflow.service; + +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +import javax.ws.rs.Consumes; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Response; + +import org.camunda.bpm.engine.ProcessEngineServices; +import org.camunda.bpm.engine.ProcessEngines; +import org.camunda.bpm.engine.RuntimeService; +import org.camunda.bpm.engine.runtime.ProcessInstance; +import org.camunda.bpm.engine.variable.impl.VariableMapImpl; +import org.jboss.resteasy.annotations.Suspend; +import org.jboss.resteasy.spi.AsynchronousResponse; +import org.openecomp.mso.logger.MessageEnum; +import org.openecomp.mso.logger.MsoLogger; +import org.slf4j.MDC; + +/** + * + * @version 1.0 + * Asynchronous Workflow processing using JAX RS RESTeasy implementation + * Both Synchronous and Asynchronous BPMN process can benefit from this implementation since the workflow gets executed in the background + * and the server thread is freed up, server scales better to process more incoming requests + * + * Usage: For synchronous process, when you are ready to send the response invoke the callback to write the response + * For asynchronous process - the activity may send a acknowledgement response and then proceed further on executing the process + */ +@Path("/async") +public abstract class WorkflowAsyncResource { + + private WorkflowContextHolder contextHolder = WorkflowContextHolder.getInstance(); + protected ProcessEngineServices pes4junit = null; + + private MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL); + + private static final String logMarker = "[WRKFLOW-RESOURCE]"; + private static final int DEFAULT_WAIT_TIME = 30000; //default wait time + + /** + * Asynchronous JAX-RS method that starts a process instance. + * @param asyncResponse an object that will receive the asynchronous response + * @param processKey the process key + * @param variableMap input variables to the process + */ + @POST + @Path("/services/{processKey}") + @Produces("application/json") + @Consumes("application/json") + public void startProcessInstanceByKey(final @Suspend(180000) AsynchronousResponse asyncResponse, + @PathParam("processKey") String processKey, VariableMapImpl variableMap) { + + WorkflowResponse response = new WorkflowResponse(); + long startTime = System.currentTimeMillis(); + Map<String, Object> inputVariables = null; + WorkflowContext workflowContext = null; + + try { + inputVariables = getInputVariables(variableMap); + setLogContext(processKey, inputVariables); + + // This variable indicates that the flow was invoked asynchronously + inputVariables.put("isAsyncProcess", "true"); + + workflowContext = new WorkflowContext(processKey, getRequestId(inputVariables), + asyncResponse, getWaitTime(inputVariables)); + + msoLogger.debug("Adding the workflow context into holder: " + + workflowContext.getProcessKey() + ":" + + workflowContext.getRequestId() + ":" + + workflowContext.getTimeout()); + + contextHolder.put(workflowContext); + + ProcessThread processThread = new ProcessThread(processKey, inputVariables); + processThread.start(); + } catch (Exception e) { + setLogContext(processKey, inputVariables); + + if (workflowContext != null) { + contextHolder.remove(workflowContext); + } + + msoLogger.debug(logMarker + "Exception in startProcessInstance by key"); + response.setMessage("Fail" ); + response.setResponse("Error occurred while executing the process: " + e); + response.setMessageCode(500); + recordEvents(processKey, response, startTime); + + msoLogger.error (MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, logMarker + + response.getMessage() + " for processKey: " + + processKey + " with response: " + response.getResponse()); + + Response errorResponse = Response.serverError().entity(response).build(); + asyncResponse.setResponse(errorResponse); + } + } + + /** + * + * @version 1.0 + * + */ + class ProcessThread extends Thread { + private final String processKey; + private final Map<String,Object> inputVariables; + + public ProcessThread(String processKey, Map<String, Object> inputVariables) { + this.processKey = processKey; + this.inputVariables = inputVariables; + } + + public void run() { + + String processInstanceId = null; + long startTime = System.currentTimeMillis(); + + try { + setLogContext(processKey, inputVariables); + + // Note: this creates a random businessKey if it wasn't specified. + String businessKey = getBusinessKey(inputVariables); + + msoLogger.debug(logMarker + "***Received MSO startProcessInstanceByKey with processKey: " + + processKey + " and variables: " + inputVariables); + + msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, logMarker + + "Call to MSO workflow/services in Camunda. Received MSO startProcessInstanceByKey with processKey:" + + processKey + " and variables: " + inputVariables); + + RuntimeService runtimeService = getProcessEngineServices().getRuntimeService(); + ProcessInstance processInstance = runtimeService.startProcessInstanceByKey( + processKey, businessKey, inputVariables); + processInstanceId = processInstance.getId(); + + msoLogger.debug(logMarker + "Process " + processKey + ":" + processInstanceId + " " + + (processInstance.isEnded() ? "ENDED" : "RUNNING")); + } catch (Exception e) { + + msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError, + logMarker + "Error in starting the process: "+ e.getMessage()); + + WorkflowCallbackResponse callbackResponse = new WorkflowCallbackResponse(); + callbackResponse.setStatusCode(500); + callbackResponse.setMessage("Fail"); + callbackResponse.setResponse("Error occurred while executing the process: " + e); + + // TODO: is the processInstanceId used by the API handler? I don't think so. + // It may be null here. + WorkflowContextHolder.getInstance().processCallback( + processKey, processInstanceId, + getRequestId(inputVariables), + callbackResponse); + } + } + } + + + /** + * Callback resource which is invoked from BPMN to process to send the workflow response + * + * @param processKey + * @param processInstanceId + * @param requestId + * @param callbackResponse + * @return + */ + @POST + @Path("/services/callback/{processKey}/{processInstanceId}/{requestId}") + @Produces("application/json") + @Consumes("application/json") + public Response processWorkflowCallback( + @PathParam("processKey") String processKey, + @PathParam("processInstanceId") String processInstanceId, + @PathParam("requestId")String requestId, + WorkflowCallbackResponse callbackResponse) { + + msoLogger.debug(logMarker + "Process instance ID:" + processInstanceId + ":" + requestId + ":" + processKey + ":" + isProcessEnded(processInstanceId)); + msoLogger.debug(logMarker + "About to process the callback request:" + callbackResponse.getResponse() + ":" + callbackResponse.getMessage() + ":" + callbackResponse.getStatusCode()); + return contextHolder.processCallback(processKey, processInstanceId, requestId, callbackResponse); + } + + // Note: the business key is used to identify the process in unit tests + private String getBusinessKey(Map<String, Object> inputVariables) { + Object businessKey = inputVariables.get("mso-business-key"); + if (businessKey == null ) { + businessKey = UUID.randomUUID().toString(); + inputVariables.put("mso-business-key", businessKey); + } + return businessKey.toString(); + } + + private String getRequestId(Map<String, Object> inputVariables) { + Object requestId = inputVariables.get("mso-request-id"); + if (requestId == null ) { + requestId = UUID.randomUUID().toString(); + inputVariables.put("mso-request-id", requestId); + } + return requestId.toString(); + } + + private long getWaitTime(Map<String, Object> inputVariables) + { + String timeout = inputVariables.get("mso-service-request-timeout") == null + ? null : inputVariables.get("mso-service-request-timeout").toString(); + + if (timeout != null) { + try { + return Long.parseLong(timeout)*1000; + } catch (NumberFormatException nex) { + msoLogger.debug("Invalid input for mso-service-request-timeout"); + } + } + + return DEFAULT_WAIT_TIME; + } + + private void recordEvents(String processKey, WorkflowResponse response, + long startTime) { + + msoLogger.recordMetricEvent ( startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, + logMarker + response.getMessage() + " for processKey: " + + processKey + " with response: " + response.getResponse(), "BPMN", MDC.get(processKey), null); + + msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, + logMarker + response.getMessage() + "for processKey: " + processKey + " with response: " + response.getResponse()); + + } + + private void setLogContext(String processKey, + Map<String, Object> inputVariables) { + MsoLogger.setServiceName("MSO." + processKey); + if (inputVariables != null) { + MsoLogger.setLogContext(getKeyValueFromInputVariables(inputVariables,"mso-request-id"), getKeyValueFromInputVariables(inputVariables,"mso-service-instance-id")); + } + } + + private String getKeyValueFromInputVariables(Map<String,Object> inputVariables, String key) { + if (inputVariables == null) return ""; + Object requestId = inputVariables.get(key); + if (requestId != null) return requestId.toString(); + return "N/A"; + } + + private boolean isProcessEnded(String processInstanceId) { + ProcessEngineServices pes = getProcessEngineServices(); + return pes.getRuntimeService().createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult() == null ? true : false ; + } + + + protected abstract ProcessEngineServices getProcessEngineServices(); + + public void setProcessEngineServices4junit(ProcessEngineServices pes) { + pes4junit = pes; + } + + private Map<String, Object> getInputVariables(VariableMapImpl variableMap) { + Map<String, Object> inputVariables = new HashMap<String,Object>(); + @SuppressWarnings("unchecked") + Map<String, Object> vMap = (Map<String, Object>) variableMap.get("variables"); + for (String vName : vMap.keySet()) { + @SuppressWarnings("unchecked") + Map<String, Object> valueMap = (Map<String,Object>)vMap.get(vName); // value, type + inputVariables.put(vName, valueMap.get("value")); + } + return inputVariables; + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowCallbackResponse.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowCallbackResponse.java new file mode 100644 index 0000000000..b3e5ad1c58 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowCallbackResponse.java @@ -0,0 +1,52 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common.workflow.service; + +/** + * @version 1.0 + * Workflow Response bean to generate workflow response in JSON format + */ +public class WorkflowCallbackResponse { + + private String response; + private int statusCode; + private String message; + + public String getResponse() { + return response; + } + public void setResponse(String response) { + this.response = response; + } + public int getStatusCode() { + return statusCode; + } + public void setStatusCode(int statusCode) { + this.statusCode = statusCode; + } + public String getMessage() { + return message; + } + public void setMessage(String message) { + this.message = message; + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowContext.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowContext.java new file mode 100644 index 0000000000..867226c02a --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowContext.java @@ -0,0 +1,96 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common.workflow.service; + +import java.util.concurrent.Delayed; +import java.util.concurrent.TimeUnit; + +import org.jboss.resteasy.spi.AsynchronousResponse; + +/** + * @version 1.0 + * Workflow context object used to send timeout response, if workflow instance does not write the response in time + */ +public class WorkflowContext implements Delayed { + private final String processKey; + private final String requestId; + private final AsynchronousResponse asynchronousResponse; + private final long startTime; + private final long timeout; + + public WorkflowContext(String processKey, String requestId, + AsynchronousResponse asynchronousResponse, long timeout) { + this.processKey = processKey; + this.requestId = requestId; + this.asynchronousResponse = asynchronousResponse; + this.timeout = timeout; + this.startTime = System.currentTimeMillis(); + } + + public String getRequestId() { + return requestId; + } + + public String getProcessKey() { + return processKey; + } + + public AsynchronousResponse getAsynchronousResponse() { + return asynchronousResponse; + } + + public long getTimeout() { + return timeout; + } + + public long getStartTime() { + return startTime; + } + + /** + * Required implementation by Delay queue + * Returns the elapsed time for this context + */ + @Override + public long getDelay(TimeUnit unit) { + // 0 or negative means this object is considered to be expired + return unit.convert(startTime + timeout - System.currentTimeMillis(), unit); + } + + /** + * Required implementation by Delay queue + * Compares the object to determine whether the object can be marked as expired + */ + @Override + public int compareTo(Delayed object) { + WorkflowContext that = (WorkflowContext) object; + long thisEndTime = startTime + timeout; + long thatEndTime = that.startTime + that.timeout; + + if (thisEndTime < thatEndTime) { + return -1; + } else if (thisEndTime > thatEndTime) { + return 1; + } else { + return 0; + } + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowContextHolder.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowContextHolder.java new file mode 100644 index 0000000000..1c48e7173a --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowContextHolder.java @@ -0,0 +1,188 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common.workflow.service; + +import java.util.concurrent.DelayQueue; +import java.util.concurrent.TimeUnit; + +import javax.ws.rs.core.Response; + +import org.jboss.resteasy.spi.AsynchronousResponse; +import org.slf4j.MDC; + +import org.openecomp.mso.logger.MessageEnum; +import org.openecomp.mso.logger.MsoLogger; + +/** + * Workflow Context Holder instance which can be accessed elsewhere either in groovy scripts or Java + * @version 1.0 + * + */ +public class WorkflowContextHolder { + + private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL); + private static final String logMarker = "[WORKFLOW-CONTEXT-HOLDER]"; + private static WorkflowContextHolder instance = null; + + /** + * Delay Queue which holds workflow context holder objects + */ + private final DelayQueue<WorkflowContext> responseQueue = new DelayQueue<WorkflowContext>(); + private final TimeoutThread timeoutThread = new TimeoutThread(); + + private WorkflowContextHolder() { + timeoutThread.start(); + } + + /** + * Singleton holder which eliminates hot lock + * Since the JVM synchronizes static method there is no synchronization needed for this method + * @return + */ + public static synchronized WorkflowContextHolder getInstance() { + if (instance == null) { + instance = new WorkflowContextHolder(); + } + return instance; + } + + public void put(WorkflowContext context) { + msoLogger.debug(logMarker + " Adding context to the queue: " + + context.getRequestId()); + responseQueue.put(context); + } + + public void remove(WorkflowContext context) { + msoLogger.debug(logMarker + " Removing context from the queue: " + + context.getRequestId()); + responseQueue.remove(context); + } + + public WorkflowContext getWorkflowContext(String requestId) { + // Note: DelayQueue interator is threadsafe + for (WorkflowContext context : responseQueue) { + if (requestId.equals(context.getRequestId())) { + msoLogger.debug("Found context for request id: " + requestId); + return context; + } + } + + msoLogger.debug("Unable to find context for request id: " + requestId); + return null; + } + + /** + * Builds the callback response object to respond to client + * @param processKey + * @param processInstanceId + * @param requestId + * @param callbackResponse + * @return + */ + public Response processCallback(String processKey, String processInstanceId, + String requestId, WorkflowCallbackResponse callbackResponse) { + WorkflowResponse workflowResponse = new WorkflowResponse(); + WorkflowContext workflowContext = getWorkflowContext(requestId); + + if (workflowContext == null) { + msoLogger.debug("Unable to correlate workflow context for request id: " + requestId + + ":processInstance Id:" + processInstanceId + + ":process key:" + processKey); + workflowResponse.setMessage("Fail"); + workflowResponse.setMessageCode(400); + workflowResponse.setResponse("Unable to correlate workflow context, bad request. Request Id: " + requestId); + return Response.serverError().entity(workflowResponse).build(); + } + + responseQueue.remove(workflowContext); + + msoLogger.debug("Using callback response for request id: " + requestId); + workflowResponse.setResponse(callbackResponse.getResponse()); + workflowResponse.setProcessInstanceID(processInstanceId); + workflowResponse.setMessageCode(callbackResponse.getStatusCode()); + workflowResponse.setMessage(callbackResponse.getMessage()); + sendWorkflowResponseToClient(processKey, workflowContext, workflowResponse); + return Response.ok().entity(workflowResponse).build(); + } + + /** + * Send the response to client asynchronously when invoked by the BPMN process + * @param processKey + * @param workflowContext + * @param workflowResponse + */ + private void sendWorkflowResponseToClient(String processKey, WorkflowContext workflowContext, + WorkflowResponse workflowResponse) { + msoLogger.debug(logMarker + "Sending the response for request id: " + workflowContext.getRequestId()); + recordEvents(processKey, workflowResponse, workflowContext.getStartTime()); + Response response = Response.status(workflowResponse.getMessageCode()).entity(workflowResponse).build(); + AsynchronousResponse asyncResp = workflowContext.getAsynchronousResponse(); + asyncResp.setResponse(response); + } + + /** + * Timeout thread which monitors the delay queue for expired context and send timeout response + * to client + * + * */ + private class TimeoutThread extends Thread { + public void run() { + while (!isInterrupted()) { + try { + WorkflowContext requestObject = responseQueue.take(); + msoLogger.debug("Time remaining for request id: " + requestObject.getRequestId() + ":" + requestObject.getDelay(TimeUnit.MILLISECONDS)); + msoLogger.debug("Preparing timeout response for " + requestObject.getProcessKey() + ":" + ":" + requestObject.getRequestId()); + WorkflowResponse response = new WorkflowResponse(); + response.setMessage("Fail"); + response.setResponse("Request timedout, request id:" + requestObject.getRequestId()); + //response.setProcessInstanceID(requestObject.getProcessInstance().getProcessInstanceId()); + recordEvents(requestObject.getProcessKey(), response, requestObject.getStartTime()); + response.setMessageCode(500); + Response result = Response.status(500).entity(response).build(); + requestObject.getAsynchronousResponse().setResponse(result); + msoLogger.debug("Sending timeout response for request id:" + requestObject.getRequestId() + ":response:" + response); + } catch (InterruptedException e) { + break; + } catch (Exception e) { + msoLogger.debug("WorkflowContextHolder timeout thread caught exception: " + e); + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION, "BPMN", MsoLogger.getServiceName(), + MsoLogger.ErrorCode.UnknownError, "Error in WorkflowContextHolder timeout thread"); + + } + } + + msoLogger.debug("WorkflowContextHolder timeout thread interrupted, quitting"); + } + } + + private static void recordEvents(String processKey, WorkflowResponse response, + long startTime) { + + msoLogger.recordMetricEvent ( startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, + logMarker + response.getMessage() + " for processKey: " + + processKey + " with response: " + response.getResponse(), "BPMN", MDC.get(processKey), null); + + msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, logMarker + + response.getMessage() + " for processKey: " + + processKey + " with response: " + response.getResponse()); + + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowMessageResource.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowMessageResource.java new file mode 100644 index 0000000000..da9376ddc0 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowMessageResource.java @@ -0,0 +1,141 @@ +package org.openecomp.mso.bpmn.common.workflow.service; + +import java.util.HashMap; +import java.util.Map; + +import javax.ws.rs.Consumes; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +import org.camunda.bpm.BpmPlatform; +import org.camunda.bpm.engine.ProcessEngineServices; +import org.camunda.bpm.engine.RuntimeService; + +import org.openecomp.mso.logger.MessageEnum; +import org.openecomp.mso.logger.MsoLogger; + +/** + * Generalized REST interface that injects a message event into a waiting BPMN process. + * Examples: + * <pre> + * /WorkflowMessage/SDNCAResponse/6d10d075-100c-42d0-9d84-a52432681cae-1478486185286 + * /WorkflowMessage/SDNCAEvent/USOSTCDALTX0101UJZZ01 + * </pre> + */ +@Path("/") +public class WorkflowMessageResource { + private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL); + private static final String LOGMARKER = "[WORKFLOW-MESSAGE]"; + + private ProcessEngineServices pes4junit = null; + + @POST + @Path("/WorkflowMessage/{messageType}/{correlator}") + @Consumes("*/*") + @Produces(MediaType.TEXT_PLAIN) + public Response deliver(@PathParam("messageType") String messageType, + @PathParam("correlator") String correlator, String message) { + + LOGGER.debug(LOGMARKER + " Received workflow message" + + " type='" + messageType + "'" + + " correlator='" + correlator + "'" + + System.lineSeparator() + message); + + MsoLogger.setServiceName("MSO." + "WorkflowMessage"); + + if (messageType == null || messageType.isEmpty()) { + String msg = "Missing message type"; + LOGGER.debug(LOGMARKER + " " + msg); + LOGGER.error(MessageEnum.BPMN_GENERAL_EXCEPTION, "BPMN", MsoLogger.getServiceName(), + MsoLogger.ErrorCode.DataError, LOGMARKER + ":" + msg); + return Response.status(400).entity(msg).build(); + } + + if (correlator == null || correlator.isEmpty()) { + String msg = "Missing correlator"; + LOGGER.debug(LOGMARKER + " " + msg); + LOGGER.error(MessageEnum.BPMN_GENERAL_EXCEPTION, "BPMN", MsoLogger.getServiceName(), + MsoLogger.ErrorCode.DataError, LOGMARKER + ":" + msg); + return Response.status(400).entity(msg).build(); + } + + String correlatorVariable = messageType + "_CORRELATOR"; + String messageVariable = messageType + "_MESSAGE"; + + long startTime = System.currentTimeMillis(); + + try { + RuntimeService runtimeService = getProcessEngineServices().getRuntimeService(); + + if (!isReadyforCorrelation(runtimeService, correlatorVariable, correlator)) { + String msg = "No process is waiting to receive '" + messageType + "' WorkflowMessage with correlator '" + correlator + "'"; + LOGGER.debug(LOGMARKER + " " + msg); + LOGGER.error(MessageEnum.BPMN_GENERAL_EXCEPTION, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, LOGMARKER + ":" + msg); + LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BusinessProcesssError, msg, "BPMN", MsoLogger.getServiceName(), messageType); + LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BusinessProcesssError, msg); + return Response.status(500).entity(msg).build(); + } + + Map<String, Object> variables = new HashMap<String, Object>(); + variables.put(correlatorVariable, correlator); + variables.put(messageVariable, message); + + runtimeService.createMessageCorrelation("WorkflowMessage").setVariables(variables) + .processInstanceVariableEquals(correlatorVariable, correlator).correlate(); + + String msg = "Completed delivery of '" + messageType + "' WorkflowMessage with correlator '" + correlator + "'"; + LOGGER.debug(LOGMARKER + msg); + LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, msg, "BPMN", MsoLogger.getServiceName(), messageType); + LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, msg); + return Response.status(204).build(); + } catch (Exception e) { + // For example: MismatchingMessageCorrelationException + String msg = "Caught " + e.getClass().getSimpleName() + " processing '" + messageType + "' WorkflowMessage with " + correlatorVariable + "='" + correlator + "'"; + LOGGER.debug(LOGMARKER + " " + msg); + LOGGER.error(MessageEnum.BPMN_GENERAL_EXCEPTION, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, LOGMARKER + ":" + msg, e); + LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.UnknownError, msg, "BPMN", MsoLogger.getServiceName(), messageType); + LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.UnknownError, msg); + return Response.status(500).entity(msg).build(); + } + } + + private boolean isReadyforCorrelation(RuntimeService runtimeService, + String correlationVariable, String correlationValue) + throws InterruptedException { + + long waitingInstances = runtimeService.createExecutionQuery() + .messageEventSubscriptionName("WorkflowMessage") + .processVariableValueEquals(correlationVariable, correlationValue) + .count(); + + int retries = 50; + while (waitingInstances == 0 && retries > 0) { + Thread.sleep(100); + + waitingInstances = runtimeService.createExecutionQuery() + .messageEventSubscriptionName("WorkflowMessage") + .processVariableValueEquals(correlationVariable, correlationValue) + .count(); + + retries--; + } + + return waitingInstances != 0; + } + + private ProcessEngineServices getProcessEngineServices() { + if (pes4junit == null) { + return BpmPlatform.getDefaultProcessEngine(); + } else { + return pes4junit; + } + } + + public void setProcessEngineServices4junit(ProcessEngineServices pes) { + pes4junit = pes; + } +}
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowResource.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowResource.java new file mode 100644 index 0000000000..d15bc31625 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowResource.java @@ -0,0 +1,609 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common.workflow.service; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import java.util.concurrent.atomic.AtomicLong; + +import javax.ws.rs.Consumes; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.UriInfo; + +import org.camunda.bpm.engine.HistoryService; +import org.camunda.bpm.engine.ProcessEngineException; +import org.camunda.bpm.engine.ProcessEngineServices; +import org.camunda.bpm.engine.ProcessEngines; +import org.camunda.bpm.engine.RuntimeService; +import org.camunda.bpm.engine.history.HistoricVariableInstance; +import org.camunda.bpm.engine.runtime.ProcessInstance; +import org.camunda.bpm.engine.variable.VariableMap; +import org.camunda.bpm.engine.variable.Variables; +import org.camunda.bpm.engine.variable.Variables.SerializationDataFormats; +import org.camunda.bpm.engine.variable.impl.VariableMapImpl; +import org.openecomp.mso.bpmn.core.WorkflowException; +import org.openecomp.mso.logger.MessageEnum; +import org.openecomp.mso.logger.MsoLogger; +import org.slf4j.MDC; + +@Path("/workflow") +public class WorkflowResource { + + private ProcessEngineServices pes4junit = null; + + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL); + private static final String LOGMARKER = "[WRKFLOW-RESOURCE]"; + + private static final int DEFAULT_WAIT_TIME = 30000; + + @Context + private UriInfo uriInfo = null; + + /** + * Starts the process instance and responds to client synchronously + * If the request does not contain mso-service-request-timeout then it waits for the value specified in DEFAULT_WAIT_TIME + * Note: value specified in mso-service-request-timeout is in seconds + * During polling time, if there is an exception encountered in the process execution then polling is stopped and the error response is + * returned to the client + * @param processKey + * @param variableMap + * @return + */ + @POST + @Path("/services/{processKey}") + @Produces("application/json") + @Consumes("application/json") + public Response startProcessInstanceByKey(@PathParam("processKey") String processKey, + VariableMapImpl variableMap) { + + Map<String, Object> inputVariables = getInputVariables(variableMap); + setLogContext(processKey, inputVariables); + + WorkflowResponse workflowResponse = new WorkflowResponse(); + long startTime = System.currentTimeMillis(); + ProcessInstance processInstance = null; + + try { + //Kickoff the process + ProcessThread thread = new ProcessThread(inputVariables,processKey,msoLogger); + thread.start(); + + Map<String, Object> responseMap = null; + + //wait for process to be completed + long waitTime = getWaitTime(inputVariables); + long now = System.currentTimeMillis(); + long start = now; + long endTime = start + waitTime; + long pollingInterval = 500; + + // TEMPORARY LOGIC FOR UNIT TEST REFACTORING + // If this is a unit test (method is invoked directly), wait a max + // of 5 seconds after process ended for a result. In production, + // wait up to 60 seconds. + long timeToWaitAfterProcessEnded = uriInfo == null ? 5000 : 60000; + AtomicLong timeProcessEnded = new AtomicLong(0); + boolean endedWithNoResponse = false; + + while (now <= endTime) { + Thread.sleep(pollingInterval); + + now = System.currentTimeMillis(); + + // Increase the polling interval over time + + long elapsed = now - start; + + if (elapsed > 60000) { + pollingInterval = 5000; + } else if (elapsed > 10000) { + pollingInterval = 1000; + } + Exception exception = thread.getException(); + if (exception != null) { + throw new Exception(exception); + } + + processInstance = thread.getProcessInstance(); + + if (processInstance == null) { + msoLogger.debug(LOGMARKER + processKey + " process has not been created yet"); + continue; + } + + String processInstanceId = processInstance.getId(); + workflowResponse.setProcessInstanceID(processInstanceId); + + responseMap = getResponseMap(processInstance, processKey, timeProcessEnded); + + if (responseMap == null) { + msoLogger.debug(LOGMARKER + processKey + " has not produced a response yet"); + + if (timeProcessEnded.longValue() != 0) { + long elapsedSinceEnded = System.currentTimeMillis() - timeProcessEnded.longValue(); + + if (elapsedSinceEnded > timeToWaitAfterProcessEnded) { + endedWithNoResponse = true; + break; + } + } + } else { + processResponseMap(workflowResponse, responseMap); + recordEvents(processKey, workflowResponse, startTime); + return Response.status(workflowResponse.getMessageCode()).entity(workflowResponse).build(); + } + } + + //if we dont get response after waiting then send timeout response + + String state; + String processInstanceId; + + if (processInstance == null) { + processInstanceId = "N/A"; + state = "NOT STARTED"; + } else { + processInstanceId = processInstance.getProcessInstanceId(); + state = isProcessEnded(processInstanceId) ? "ENDED" : "NOT ENDED"; + } + + workflowResponse.setMessage("Fail"); + if (endedWithNoResponse) { + workflowResponse.setResponse("Process ended without producing a response"); + } else { + workflowResponse.setResponse("Request timed out, process state: " + state); + } + workflowResponse.setProcessInstanceID(processInstanceId); + recordEvents(processKey, workflowResponse, startTime); + workflowResponse.setMessageCode(500); + return Response.status(500).entity(workflowResponse).build(); + } catch (Exception ex) { + msoLogger.debug(LOGMARKER + "Exception in startProcessInstance by key"); + ex.printStackTrace(); + workflowResponse.setMessage("Fail" ); + workflowResponse.setResponse("Error occurred while executing the process: " + ex.getMessage()); + if (processInstance != null) workflowResponse.setProcessInstanceID(processInstance.getId()); + + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "BPMN", MDC.get(processKey), + MsoLogger.ErrorCode.UnknownError, LOGMARKER + workflowResponse.getMessage() + + " for processKey: " + processKey + " with response: " + workflowResponse.getResponse()); + + workflowResponse.setMessageCode(500); + recordEvents(processKey, workflowResponse, startTime); + return Response.status(500).entity(workflowResponse).build(); + } + } + + /** + * Returns the wait time, this is used by the resource on how long it should wait to send a response + * If none specified DEFAULT_WAIT_TIME is used + * @param inputVariables + * @return + */ + private int getWaitTime(Map<String, Object> inputVariables) + { + String timeout = inputVariables.get("mso-service-request-timeout") == null + ? null : inputVariables.get("mso-service-request-timeout").toString(); + + if (timeout != null) { + try { + return Integer.parseInt(timeout)*1000; + } catch (NumberFormatException nex) { + msoLogger.debug("Invalid input for mso-service-request-timeout"); + } + } + return DEFAULT_WAIT_TIME; + } + + private void recordEvents(String processKey, WorkflowResponse response, long startTime) { + + msoLogger.recordMetricEvent ( startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, + LOGMARKER + response.getMessage() + " for processKey: " + + processKey + " with response: " + response.getResponse(), "BPMN", MDC.get(processKey), null); + + msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, + LOGMARKER + response.getMessage() + " for processKey: " + + processKey + " with response: " + response.getResponse()); + } + + private void setLogContext(String processKey, Map<String, Object> inputVariables) { + MsoLogger.setServiceName("MSO." + processKey); + if (inputVariables != null) { + MsoLogger.setLogContext(getValueFromInputVariables(inputVariables, "mso-request-id"), + getValueFromInputVariables(inputVariables, "mso-service-instance-id")); + } + } + + private String getValueFromInputVariables(Map<String,Object> inputVariables, String key) { + Object value = inputVariables.get(key); + if (value == null) { + return "N/A"; + } else { + return value.toString(); + } + } + + /** + * Checks to see if the specified process is ended. + * @param processInstanceId the process instance ID + * @return true if the process is ended + */ + private boolean isProcessEnded(String processInstanceId) { + ProcessEngineServices pes = getProcessEngineServices(); + return pes.getRuntimeService().createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult() == null ? true : false ; + } + + private void processResponseMap(WorkflowResponse workflowResponse, Map<String, Object> responseMap) { + Object object = responseMap.get("Response"); + String response = object == null ? null : String.valueOf(object); + if(response == null){ + object = responseMap.get("WorkflowResponse"); + response = object == null ? null : String.valueOf(object); + } + + workflowResponse.setResponse(response); + + object = responseMap.get("ResponseCode"); + String responseCode = object == null ? null : String.valueOf(object); + + try { + workflowResponse.setMessageCode(Integer.parseInt(responseCode)); + } catch(NumberFormatException nex) { + msoLogger.debug(LOGMARKER + "Failed to parse ResponseCode: " + responseCode); + workflowResponse.setMessageCode(-1); + } + + Object status = responseMap.get("Status"); + + if ("Success".equalsIgnoreCase(String.valueOf(status))) { + workflowResponse.setMessage("Success"); + } else if ("Fail".equalsIgnoreCase(String.valueOf(status))) { + workflowResponse.setMessage("Fail"); + } else { + msoLogger.debug(LOGMARKER + "Unrecognized Status: " + responseCode); + workflowResponse.setMessage("Fail"); + } + } + + /** + * @version 1.0 + * Triggers the workflow in a separate thread + */ + private class ProcessThread extends Thread { + private final Map<String,Object> inputVariables; + private final String processKey; + private final MsoLogger msoLogger; + private final String businessKey; + private ProcessInstance processInstance = null; + private Exception exception = null; + + public ProcessThread(Map<String, Object> inputVariables, String processKey, MsoLogger msoLogger) { + this.inputVariables = inputVariables; + this.processKey = processKey; + this.msoLogger = msoLogger; + this.businessKey = UUID.randomUUID().toString(); + } + + /** + * If an exception occurs when starting the process instance, it may + * be obtained by calling this method. Note that exceptions are only + * recorded while the process is executing in its original thread. + * Once a process is suspended, exception recording stops. + * @return the exception, or null if none has occurred + */ + public Exception getException() { + return exception; + } + + + public ProcessInstance getProcessInstance() { + return this.processInstance; + } + + /** + * Sets the process instance exception. + * @param exception the exception + */ + private void setException(Exception exception) { + this.exception = exception; + } + + public void run() { + setLogContext(processKey, inputVariables); + + long startTime = System.currentTimeMillis(); + + try { + msoLogger.debug(LOGMARKER + "***Received MSO startProcessInstanceByKey with processKey:" + + processKey + " and variables: " + inputVariables); + + msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, LOGMARKER + + "Call to MSO workflow/services in Camunda. Received MSO startProcessInstanceByKey with" + + " processKey:" + processKey + + " businessKey:" + businessKey + + " variables: " + inputVariables); + + RuntimeService runtimeService = getProcessEngineServices().getRuntimeService(); + + // Note that this method doesn't return until the process suspends + // itself or finishes. We provide a business key so we can identify + // the process instance immediately. + processInstance = runtimeService.startProcessInstanceByKey( + processKey, inputVariables); + + } catch (Exception e) { + msoLogger.debug(LOGMARKER + "ProcessThread caught an exception executing " + + processKey + ": " + e); + setException(e); + } + } + + } + + private Map<String, Object> getInputVariables(VariableMapImpl variableMap) { + VariableMap inputVariables = Variables.createVariables(); + @SuppressWarnings("unchecked") + Map<String, Object> vMap = (Map<String, Object>) variableMap.get("variables"); + for (String key : vMap.keySet()) { //variabe name vn + @SuppressWarnings("unchecked") + Map<String, Object> valueMap = (Map<String,Object>)vMap.get(key); //value, type + inputVariables.putValueTyped(key, Variables + .objectValue(valueMap.get("value")) + .serializationDataFormat(SerializationDataFormats.JAVA) // tells the engine to use java serialization for persisting the value + .create()); + } + return inputVariables; + } + + /** + * Attempts to get a response map from the specified process instance. + * @return the response map, or null if it is unavailable + */ + private Map<String, Object> getResponseMap(ProcessInstance processInstance, + String processKey, AtomicLong timeProcessEnded) { + + String responseMapVariable = processKey + "ResponseMap"; + String processInstanceId = processInstance.getId(); + + // Query the runtime service to see if a response map is ready. + +/* RuntimeService runtimeService = getProcessEngineServices().getRuntimeService(); + List<Execution> executions = runtimeService.createExecutionQuery() + .processInstanceId(processInstanceId).list(); + + for (Execution execution : executions) { + @SuppressWarnings("unchecked") + Map<String, Object> responseMap = (Map<String, Object>) + getVariableFromExecution(runtimeService, execution.getId(), + responseMapVariable); + + if (responseMap != null) { + msoLogger.debug(LOGMARKER + "Obtained " + responseMapVariable + + " from process " + processInstanceId + " execution " + + execution.getId()); + return responseMap; + } + } +*/ + //Querying history seem to return consistent results compared to querying the runtime service + + boolean alreadyEnded = timeProcessEnded.longValue() != 0; + + if (alreadyEnded || isProcessEnded(processInstance.getId())) { + if (!alreadyEnded) { + timeProcessEnded.set(System.currentTimeMillis()); + } + + // Query the history service to see if a response map exists. + + HistoryService historyService = getProcessEngineServices().getHistoryService(); + @SuppressWarnings("unchecked") + Map<String, Object> responseMap = (Map<String, Object>) + getVariableFromHistory(historyService, processInstance.getId(), + responseMapVariable); + + if (responseMap != null) { + msoLogger.debug(LOGMARKER + "Obtained " + responseMapVariable + + " from process " + processInstanceId + " history"); + return responseMap; + } + + // Query the history service for old-style response variables. + + String prefix = (String) getVariableFromHistory(historyService, processInstanceId, "prefix"); + + if (prefix != null) { + + // Check for 'WorkflowResponse' variable + Object workflowResponseObject = getVariableFromHistory(historyService, processInstanceId, "WorkflowResponse"); + String workflowResponse = workflowResponseObject == null ? null : String.valueOf(workflowResponseObject); + msoLogger.debug(LOGMARKER + "WorkflowResponse: " + workflowResponse); + + if (workflowResponse != null) { + Object responseCodeObject = getVariableFromHistory(historyService, processInstanceId, prefix + "ResponseCode"); + String responseCode = responseCodeObject == null ? null : String.valueOf(responseCodeObject); + msoLogger.debug(LOGMARKER + prefix + "ResponseCode: " + responseCode); + responseMap = new HashMap<String, Object>(); + responseMap.put("WorkflowResponse", workflowResponse); + responseMap.put("ResponseCode", responseCode); + responseMap.put("Status", "Success"); + return responseMap; + } + + + // Check for 'WorkflowException' variable + WorkflowException workflowException = null; + String workflowExceptionText = null; + + Object workflowExceptionObject = getVariableFromHistory(historyService, processInstanceId, "WorkflowException"); + if(workflowExceptionObject != null) { + if(workflowExceptionObject instanceof WorkflowException) { + workflowException = (WorkflowException) workflowExceptionObject; + workflowExceptionText = workflowException.toString(); + responseMap = new HashMap<String, Object>(); + responseMap.put("WorkflowException", workflowExceptionText); + responseMap.put("ResponseCode", workflowException.getErrorCode()); + responseMap.put("Status", "Fail"); + return responseMap; + } + else if (workflowExceptionObject instanceof String) { + Object object = getVariableFromHistory(historyService, processInstanceId, prefix + "ResponseCode"); + String responseCode = object == null ? null : String.valueOf(object); + workflowExceptionText = (String) workflowExceptionObject; + responseMap = new HashMap<String, Object>(); + responseMap.put("WorkflowException", workflowExceptionText); + responseMap.put("ResponseCode", responseCode); + responseMap.put("Status", "Fail"); + return responseMap; + } + + } + msoLogger.debug(LOGMARKER + "WorkflowException: " + workflowExceptionText); + + // BEGIN LEGACY SUPPORT. TODO: REMOVE THIS CODE + Object object = getVariableFromHistory(historyService, processInstanceId, processKey + "Response"); + String response = object == null ? null : String.valueOf(object); + msoLogger.debug(LOGMARKER + processKey + "Response: " + response); + + if (response != null) { + object = getVariableFromHistory(historyService, processInstanceId, prefix + "ResponseCode"); + String responseCode = object == null ? null : String.valueOf(object); + msoLogger.debug(LOGMARKER + prefix + "ResponseCode: " + responseCode); + responseMap = new HashMap<String, Object>(); + responseMap.put("Response", response); + responseMap.put("ResponseCode", responseCode); + responseMap.put("Status", "Success"); + return responseMap; + } + + object = getVariableFromHistory(historyService, processInstanceId, prefix + "ErrorResponse"); + String errorResponse = object == null ? null : String.valueOf(object); + msoLogger.debug(LOGMARKER + prefix + "ErrorResponse: " + errorResponse); + + if (errorResponse != null) { + object = getVariableFromHistory(historyService, processInstanceId, prefix + "ResponseCode"); + String responseCode = object == null ? null : String.valueOf(object); + msoLogger.debug(LOGMARKER + prefix + "ResponseCode: " + responseCode); + responseMap = new HashMap<String, Object>(); + responseMap.put("Response", errorResponse); + responseMap.put("ResponseCode", responseCode); + responseMap.put("Status", "Fail"); + return responseMap; + } + // END LEGACY SUPPORT. TODO: REMOVE THIS CODE + } + } + return null; + } + + /** + * Gets a variable value from specified historical process instance. + * @return the variable value, or null if the variable could not be + * obtained + */ + private Object getVariableFromHistory(HistoryService historyService, + String processInstanceId, String variableName) { + try { + HistoricVariableInstance v = historyService.createHistoricVariableInstanceQuery() + .processInstanceId(processInstanceId).variableName(variableName).singleResult(); + return v == null ? null : v.getValue(); + } catch (Exception e) { + msoLogger.debug("Error retrieving process " + processInstanceId + + " variable " + variableName + " from history: " + e); + return null; + } + } + + @POST + @Path("/services/{processKey}/{processInstanceId}") + @Produces("application/json") + @Consumes("application/json") + public WorkflowResponse getProcessVariables(@PathParam("processKey") String processKey, @PathParam("processInstanceId") String processInstanceId) { + //TODO filter only set of variables + WorkflowResponse response = new WorkflowResponse(); + + long startTime = System.currentTimeMillis(); + try { + ProcessEngineServices engine = getProcessEngineServices(); + List<HistoricVariableInstance> variables = engine.getHistoryService().createHistoricVariableInstanceQuery().processInstanceId(processInstanceId).list(); + Map<String,String> variablesMap = new HashMap<String,String>(); + for (HistoricVariableInstance variableInstance: variables) { + variablesMap.put(variableInstance.getName(), variableInstance.getValue().toString()); + } + + msoLogger.debug(LOGMARKER + "***Received MSO getProcessVariables with processKey:" + processKey + " and variables: " + variablesMap.toString()); + + msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, LOGMARKER + + "Call to MSO workflow/services in Camunda. Received MSO getProcessVariables with processKey:" + + processKey + " and variables: " + + variablesMap.toString()); + + + response.setVariables(variablesMap); + response.setMessage("Success"); + response.setResponse("Successfully retrieved the variables"); + response.setProcessInstanceID(processInstanceId); + + msoLogger.debug(LOGMARKER + response.getMessage() + " for processKey: " + processKey + " with response: " + response.getResponse()); + } catch (Exception ex) { + response.setMessage("Fail"); + response.setResponse("Failed to retrieve the variables," + ex.getMessage()); + response.setProcessInstanceID(processInstanceId); + + msoLogger.error (MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "BPMN", MDC.get(processKey), MsoLogger.ErrorCode.UnknownError, LOGMARKER + + response.getMessage() + + " for processKey: " + + processKey + + " with response: " + + response.getResponse()); + + } + + msoLogger.recordMetricEvent ( startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, + LOGMARKER + response.getMessage() + " for processKey: " + + processKey + " with response: " + response.getResponse(), "BPMN", MDC.get(processKey), null); + + msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, + LOGMARKER + response.getMessage() + " for processKey: " + + processKey + " with response: " + response.getResponse()); + + return response; + } + + private ProcessEngineServices getProcessEngineServices() { + if (pes4junit == null) { + return ProcessEngines.getDefaultProcessEngine(); + } else { + return pes4junit; + } + } + + public void setProcessEngineServices4junit(ProcessEngineServices pes) { + pes4junit = pes; + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowResourceApplication.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowResourceApplication.java new file mode 100644 index 0000000000..afc7bdb128 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowResourceApplication.java @@ -0,0 +1,57 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common.workflow.service; + +import java.util.HashSet; +import java.util.Set; + +import javax.ws.rs.ApplicationPath; +import javax.ws.rs.core.Application; + +import org.openecomp.mso.bpmn.common.workflow.service.WorkflowMessageResource; +import org.openecomp.mso.bpmn.common.workflow.service.WorkflowResource; + +/** + * @version 1.0 + * RESTeasy workflow application which wires synchronous and asynchronous response + * + */ +@ApplicationPath("/") +public class WorkflowResourceApplication extends Application { + private Set<Object> singletons = new HashSet<Object>(); + private Set<Class<?>> classes = new HashSet<Class<?>>(); + + public WorkflowResourceApplication() { + singletons.add(new WorkflowResource()); + singletons.add(new WorkflowAsyncCommonResource()); + singletons.add(new WorkflowMessageResource()); + } + + @Override + public Set<Class<?>> getClasses() { + return classes; + } + + @Override + public Set<Object> getSingletons() { + return singletons; + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowResponse.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowResponse.java new file mode 100644 index 0000000000..5da7c8fef4 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowResponse.java @@ -0,0 +1,69 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common.workflow.service; + +import java.util.Map; + +/** + * @version 1.0 + * Synchronous workflow response bean + * + */ +public class WorkflowResponse { + + private String response; + private String message; + private String processInstanceID; + private Map<String,String> variables; + private int messageCode; + + public String getResponse() { + return response; + } + public void setResponse(String response) { + this.response = response; + } + public String getMessage() { + return message; + } + public void setMessage(String message) { + this.message = message; + } + public String getProcessInstanceID() { + return processInstanceID; + } + public void setProcessInstanceID(String pID) { + this.processInstanceID = pID; + } + public Map<String, String> getVariables() { + return variables; + } + public void setVariables(Map<String, String> variables) { + this.variables = variables; + } + public void setMessageCode(int messageCode) { + this.messageCode = messageCode; + } + + public int getMessageCode() { + return messageCode; + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/resources/META-INF/persistence.xml b/bpmn/MSOCommonBPMN/src/main/resources/META-INF/persistence.xml new file mode 100644 index 0000000000..fb027b8ed0 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/resources/META-INF/persistence.xml @@ -0,0 +1,37 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ============LICENSE_START======================================================= + ECOMP MSO + ================================================================================ + Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + ================================================================================ + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ============LICENSE_END========================================================= + --> + +<persistence version="2.0" + xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation=" + http://java.sun.com/xml/ns/persistence + http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"> + + <persistence-unit name="common"> + <jta-data-source>java:jboss/datasources/ProcessEngine</jta-data-source> + <properties> + <!-- Properties for Hibernate --> + <property name="hibernate.hbm2ddl.auto" value="create-drop" /> + <property name="hibernate.show_sql" value="true" /> + </properties> + </persistence-unit> + +</persistence> diff --git a/bpmn/MSOCommonBPMN/src/main/resources/META-INF/processes.xml b/bpmn/MSOCommonBPMN/src/main/resources/META-INF/processes.xml new file mode 100644 index 0000000000..1745af6558 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/resources/META-INF/processes.xml @@ -0,0 +1,81 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!-- + ============LICENSE_START======================================================= + ECOMP MSO + ================================================================================ + Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + ================================================================================ + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ============LICENSE_END========================================================= + --> + + +<process-application + xmlns="http://www.camunda.org/schema/1.0/ProcessApplication" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <process-engine name="common"> + <configuration>org.camunda.bpm.engine.impl.cfg.StandaloneProcessEngineConfiguration</configuration> + <datasource>java:jboss/datasources/ProcessEngine</datasource> + <properties> + <property name="history">full</property> + <property name="databaseSchemaUpdate">true</property> + <property name="authorizationEnabled">true</property> + <property name="jobExecutorDeploymentAware">true</property> + <property name="jobExecutorActivate">true</property> + </properties> + <plugins> + + <!-- plugin enabling Process Application event listener support --> + <plugin> + <class>org.camunda.bpm.application.impl.event.ProcessApplicationEventListenerPlugin</class> + </plugin> + + <!-- plugin enabling integration of camunda Spin --> + <plugin> + <class>org.camunda.spin.plugin.impl.SpinProcessEnginePlugin</class> + </plugin> + + <!-- plugin enabling connect support --> + <plugin> + <class>org.camunda.connect.plugin.impl.ConnectProcessEnginePlugin</class> + </plugin> + + <plugin> + <class>org.openecomp.mso.bpmn.core.plugins.LoggingAndURNMappingPlugin</class> + </plugin> + + <!-- Needed until all subflows generate MSOWorkflowException events --> + <plugin> + <class>org.openecomp.mso.bpmn.core.plugins.WorkflowExceptionPlugin</class> + </plugin> + + <!-- Optional Plugin for Camunda BPM Workbench --> + <!-- <plugin> + <class>org.camunda.bpm.debugger.server.EmbeddableDebugWebsocketBootstrap</class> + <properties> + <property name="httpPort">8088</property> + </properties> + </plugin> --> + </plugins> + </process-engine> + + + <process-archive name="MSOCommonBPMN"> + <process-engine>common</process-engine> + <properties> + <property name="isDeleteUponUndeploy">false</property> + <property name="isScanForProcessDefinitions">true</property> + </properties> + </process-archive> + +</process-application> diff --git a/bpmn/MSOCommonBPMN/src/main/resources/logback.xml b/bpmn/MSOCommonBPMN/src/main/resources/logback.xml new file mode 100644 index 0000000000..133fa54003 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/resources/logback.xml @@ -0,0 +1,159 @@ +<!-- + ============LICENSE_START======================================================= + ECOMP MSO + ================================================================================ + Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + ================================================================================ + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ============LICENSE_END========================================================= + --> + +<configuration scan="true" scanPeriod="3 seconds" debug="true"> + <!--<jmxConfigurator /> --> + <!-- directory path for all other type logs --> + <property name="logDir" value="/var/log/ecomp" /> + + <!-- directory path for debugging type logs --> + <property name="debugDir" value="/var/log/ecomp" /> + + <!-- specify the component name + <ECOMP-component-name>::= "MSO" | "DCAE" | "ASDC " | "AAI" |"Policy" | "SDNC" | "AC" --> + <property name="componentName" value="MSO"></property> + <property name="subComponentName" value="BPMN"></property> + <!-- log file names --> + <property name="errorLogName" value="error" /> + <property name="metricsLogName" value="metrics" /> + <property name="auditLogName" value="audit" /> + <property name="debugLogName" value="debug" /> + + <property name="errorPattern" value="%d{"yyyy-MM-dd'T'HH:mm:ss.SSSXXX", UTC}|%X{RequestId}|%thread|%X{ServiceName}|%X{PartnerName}|%X{TargetEntity}|%X{TargetServiceName}|%.-5level|%X{ErrorCode}|%X{ErrorDesc}|%msg%n" /> + <property name="debugPattern" value="%d{"yyyy-MM-dd'T'HH:mm:ss.SSSXXX", UTC}|%X{RequestId}|%msg%n" /> + + <property name="auditPattern" value="%X{BeginTimestamp}|%X{EndTimestamp}|%X{RequestId}|%X{ServiceInstanceId}|%thread||%X{ServiceName}|%X{PartnerName}|%X{StatusCode}|%X{ResponseCode}|%X{ResponseDesc}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}|%X{ServerIPAddress}|%X{Timer}|%X{ServerFQDN}|%X{RemoteHost}||||||||%msg%n" /> + <property name="metricPattern" value="%X{BeginTimestamp}|%X{EndTimestamp}|%X{RequestId}|%X{ServiceInstanceId}|%thread||%X{ServiceName}|%X{PartnerName}|%X{TargetEntity}|%X{TargetServiceName}|%X{StatusCode}|%X{ResponseCode}|%X{ResponseDesc}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}|%X{ServerIPAddress}|%X{Timer}|%X{ServerFQDN}|%X{RemoteHost}||||%X{TargetVirtualEntity}|||||%msg%n" /> + <property name="logDirectory" value="${logDir}/${componentName}/${subComponentName}" /> + <property name="debugLogDirectory" value="${debugDir}/${componentName}/${subComponentName}" /> + + + <!-- ============================================================================ --> + <!-- EELF Appenders --> + <!-- ============================================================================ --> + + <!-- The EELFAppender is used to record events to the general application + log --> + + <!-- EELF Audit Appender. This appender is used to record audit engine + related logging events. The audit logger and appender are specializations + of the EELF application root logger and appender. This can be used to segregate + Policy engine events from other components, or it can be eliminated to record + these events as part of the application root log. --> + + <appender name="EELFAudit" + class="ch.qos.logback.core.rolling.RollingFileAppender"> + <file>${logDirectory}/${auditLogName}${jboss.server.name}.log</file> + <rollingPolicy + class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> + <fileNamePattern>${logDirectory}/${auditLogName}${jboss.server.name}.log.%d</fileNamePattern> + <!--<maxHistory>30</maxHistory>--> + </rollingPolicy> + <encoder> + <pattern>${auditPattern}</pattern> + </encoder> + </appender> + <appender name="asyncEELFAudit" class="ch.qos.logback.classic.AsyncAppender"> + <queueSize>256</queueSize> + <appender-ref ref="EELFAudit" /> + </appender> + + <appender name="EELFMetrics" + class="ch.qos.logback.core.rolling.RollingFileAppender"> + <file>${logDirectory}/${metricsLogName}${jboss.server.name}.log</file> + <rollingPolicy + class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> + <fileNamePattern>${logDirectory}/${metricsLogName}${jboss.server.name}.log.%d</fileNamePattern> + <!--<maxHistory>30</maxHistory>--> + </rollingPolicy> + <encoder> + <!-- <pattern>"%d{HH:mm:ss.SSS} [%thread] %-5level %logger{1024} - + %msg%n"</pattern> --> + <pattern>${metricPattern}</pattern> + </encoder> + </appender> + + + <appender name="asyncEELFMetrics" class="ch.qos.logback.classic.AsyncAppender"> + <queueSize>256</queueSize> + <appender-ref ref="EELFMetrics"/> + </appender> + + <appender name="EELFError" + class="ch.qos.logback.core.rolling.RollingFileAppender"> + <file>${logDirectory}/${errorLogName}${jboss.server.name}.log</file> + <rollingPolicy + class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> + <fileNamePattern>${logDirectory}/${errorLogName}${jboss.server.name}.log.%d</fileNamePattern> + <!--<maxHistory>30</maxHistory>--> + </rollingPolicy> + <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> + <level>INFO</level> + </filter> + <encoder> + <pattern>${errorPattern}</pattern> + </encoder> + </appender> + + <appender name="asyncEELFError" class="ch.qos.logback.classic.AsyncAppender"> + <queueSize>256</queueSize> + <appender-ref ref="EELFError"/> + </appender> + + <appender name="EELFDebug" + class="ch.qos.logback.core.rolling.RollingFileAppender"> + <file>${debugLogDirectory}/${debugLogName}${jboss.server.name}.log</file> + <rollingPolicy + class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> + <fileNamePattern>${debugLogDirectory}/${debugLogName}${jboss.server.name}.log.%d</fileNamePattern> + <!--<maxHistory>30</maxHistory>--> + </rollingPolicy> + <encoder> + <pattern>${debugPattern}</pattern> + </encoder> + </appender> + + <appender name="asyncEELFDebug" class="ch.qos.logback.classic.AsyncAppender"> + <queueSize>256</queueSize> + <appender-ref ref="EELFDebug" /> + <includeCallerData>true</includeCallerData> + </appender> + + + <!-- ============================================================================ --> + <!-- EELF loggers --> + <!-- ============================================================================ --> + + <logger name="com.att.eelf.audit" level="info" additivity="false"> + <appender-ref ref="asyncEELFAudit" /> + </logger> + + <logger name="com.att.eelf.metrics" level="info" additivity="false"> + <appender-ref ref="asyncEELFMetrics" /> + </logger> + + <logger name="com.att.eelf.error" level="debug" additivity="false"> + <appender-ref ref="asyncEELFError" /> + </logger> + <root level="INFO"> + <appender-ref ref="asyncEELFDebug" /> + </root> + +</configuration> diff --git a/bpmn/MSOCommonBPMN/src/main/resources/processengine.properties b/bpmn/MSOCommonBPMN/src/main/resources/processengine.properties new file mode 100644 index 0000000000..c21925c23f --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/resources/processengine.properties @@ -0,0 +1,20 @@ +### +# ============LICENSE_START======================================================= +# ECOMP MSO +# ================================================================================ +# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= +### +processEngineName=common diff --git a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/CompleteMsoProcess.bpmn b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/CompleteMsoProcess.bpmn new file mode 100644 index 0000000000..caf39010a7 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/CompleteMsoProcess.bpmn @@ -0,0 +1,447 @@ +<?xml version="1.0" encoding="UTF-8"?> +<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="_EsMs0HcuEeW2U_kkOHX1ZQ" targetNamespace="http://camunda.org/schema/1.0/bpmn" exporter="Camunda Modeler" exporterVersion="1.4.0" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd"> + <bpmn2:process id="CompleteMsoProcess" name="CompleteMsoProcess" isExecutable="true"> + <bpmn2:scriptTask id="preProcessRequest" name="Pre-Process Request" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_1s593bx</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_1epmndu</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +def preProcessRequestData = new CompleteMsoProcess() +preProcessRequestData.preProcessRequest(execution) + +]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:startEvent id="StartEvent_1" name="Start With Message "> + <bpmn2:outgoing>SequenceFlow_1s593bx</bpmn2:outgoing> + <bpmn2:messageEventDefinition id="MessageEventDefinition_1" messageRef="Message_2" /> + </bpmn2:startEvent> + <bpmn2:subProcess id="subProcessExceptionCompleteMSO" name="Sub Process Exception Complete MSO" triggeredByEvent="true"> + <bpmn2:endEvent id="endEventExceptionCompleteMSO"> + <bpmn2:extensionElements> + <camunda:connector> + <camunda:inputOutput> + <camunda:outputParameter name="DB_ADAPTER_ERROR">${CMSO_updateRequestResponse}</camunda:outputParameter> + </camunda:inputOutput> + </camunda:connector> + </bpmn2:extensionElements> + <bpmn2:incoming>SequenceFlow_19</bpmn2:incoming> + <bpmn2:terminateEventDefinition id="MessageEventDefinition_3" /> + </bpmn2:endEvent> + <bpmn2:startEvent id="startEventExceptionCompleteMSO"> + <bpmn2:outgoing>SequenceFlow_19</bpmn2:outgoing> + <bpmn2:errorEventDefinition id="ErrorEventDefinition_4" /> + </bpmn2:startEvent> + <bpmn2:sequenceFlow id="SequenceFlow_19" name="" sourceRef="startEventExceptionCompleteMSO" targetRef="endEventExceptionCompleteMSO" /> + </bpmn2:subProcess> + <bpmn2:endEvent id="EndEvent_13"> + <bpmn2:incoming>SequenceFlow_21</bpmn2:incoming> + </bpmn2:endEvent> + <bpmn2:exclusiveGateway id="ParallelGateway_7"> + <bpmn2:incoming>SequenceFlow_7</bpmn2:incoming> + <bpmn2:incoming>SequenceFlow_24</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_0fni7aq</bpmn2:outgoing> + </bpmn2:exclusiveGateway> + <bpmn2:endEvent id="EndEvent_4"> + <bpmn2:incoming>SequenceFlow_9</bpmn2:incoming> + <bpmn2:errorEventDefinition id="ErrorEventDefinition_5" errorRef="Error_3" /> + </bpmn2:endEvent> + <bpmn2:scriptTask id="ScriptTask_3" name="Prepare
Update DB Request" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_72</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_10</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +def completeMsoProcess = new CompleteMsoProcess() +completeMsoProcess.setUpdateDBstatustoSuccessPayload(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_10" name="" sourceRef="ScriptTask_3" targetRef="updateInfraRequest" /> + <bpmn2:endEvent id="EndEvent_5"> + <bpmn2:incoming>SequenceFlow_13</bpmn2:incoming> + <bpmn2:errorEventDefinition id="ErrorEventDefinition_3" errorRef="Error_3" /> + </bpmn2:endEvent> + <bpmn2:exclusiveGateway id="ExclusiveGateway_3" name="Active Request?" default="SequenceFlow_72"> + <bpmn2:incoming>SequenceFlow_1epmndu</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_72</bpmn2:outgoing> + <bpmn2:outgoing>SequenceFlow_81</bpmn2:outgoing> + </bpmn2:exclusiveGateway> + <bpmn2:sequenceFlow id="SequenceFlow_72" name="No" sourceRef="ExclusiveGateway_3" targetRef="ScriptTask_3" /> + <bpmn2:sequenceFlow id="SequenceFlow_81" name="Yes" sourceRef="ExclusiveGateway_3" targetRef="prepareUpdateRequest"> + <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression"><![CDATA[#{execution.getVariable("CMSO_request_id-Ok") ==true}]]></bpmn2:conditionExpression> + </bpmn2:sequenceFlow> + <bpmn2:scriptTask id="BuildErrorMessage1" name="Build Error Message" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_25</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_13</bpmn2:outgoing> + <bpmn2:script><![CDATA[//println "INSIDE --> Build Error Message @@@@" +import org.openecomp.mso.bpmn.common.scripts.* +def buildDataErrorMessage = new CompleteMsoProcess() +buildDataErrorMessage.buildDataError(execution, "Complete --Update DB status to SUCCESS-- Failed")]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_13" name="" sourceRef="BuildErrorMessage1" targetRef="EndEvent_5" /> + <bpmn2:scriptTask id="prepareUpdateRequest" name="Prepare
Update DB Request" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_81</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_49</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +def completeMsoProcess = new CompleteMsoProcess() +completeMsoProcess.updateDBStatusToSuccessPayload(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_49" name="" sourceRef="prepareUpdateRequest" targetRef="updateDBStatus" /> + <bpmn2:serviceTask id="updateInfraRequest" name="Update DB status to SUCCESS"> + <bpmn2:extensionElements> + <camunda:connector> + <camunda:inputOutput> + <camunda:inputParameter name="url">${URN_mso_adapters_db_endpoint}</camunda:inputParameter> + <camunda:inputParameter name="payload"><![CDATA[${execution.getVariable("CMSO_setUpdateDBstatustoSuccessPayload")}]]></camunda:inputParameter> + <camunda:inputParameter name="headers"> + <camunda:map> + <camunda:entry key="content-type">application/soap+xml</camunda:entry> + <camunda:entry key="Authorization">#{BasicAuthHeaderValueDB}</camunda:entry> + </camunda:map> + </camunda:inputParameter> + <camunda:inputParameter name="method">POST</camunda:inputParameter> + <camunda:outputParameter name="CMSO_updateRequestResponse"><![CDATA[${statusCode == null || statusCode == 204 ? "" : response}]]></camunda:outputParameter> + <camunda:outputParameter name="CMSO_updateRequestResponseCode">${statusCode}</camunda:outputParameter> + </camunda:inputOutput> + <camunda:connectorId>soap-http-connector</camunda:connectorId> + </camunda:connector> + </bpmn2:extensionElements> + <bpmn2:incoming>SequenceFlow_10</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_6</bpmn2:outgoing> + </bpmn2:serviceTask> + <bpmn2:sequenceFlow id="SequenceFlow_6" name="" sourceRef="updateInfraRequest" targetRef="ExclusiveGateway_7" /> + <bpmn2:boundaryEvent id="BoundaryEvent_6" name="" attachedToRef="updateDBStatus"> + <bpmn2:outgoing>SequenceFlow_14</bpmn2:outgoing> + <bpmn2:errorEventDefinition id="_ErrorEventDefinition_83" errorRef="Error_1" /> + </bpmn2:boundaryEvent> + <bpmn2:sequenceFlow id="SequenceFlow_14" name="" sourceRef="BoundaryEvent_6" targetRef="EndEvent_12" /> + <bpmn2:scriptTask id="BuildErrorMessage" name="Build Error Message" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_1</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_9</bpmn2:outgoing> + <bpmn2:script><![CDATA[//println "INSIDE --> Build Error Message @@@@" +//println "CMSO_updateRequestResponse IS --> " + execution.getVariable("CMSO_updateRequestResponse") +import org.openecomp.mso.bpmn.common.scripts.* +def buildDataErrorMessage = new CompleteMsoProcess() +buildDataErrorMessage.buildDataError(execution, "Complete MSO -- Update DB status to SUCCESS -- Failed")]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_9" name="" sourceRef="BuildErrorMessage" targetRef="EndEvent_4" /> + <bpmn2:exclusiveGateway id="ExclusiveGateway_10" default="SequenceFlow_25"> + <bpmn2:incoming>SequenceFlow_23</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_24</bpmn2:outgoing> + <bpmn2:outgoing>SequenceFlow_25</bpmn2:outgoing> + </bpmn2:exclusiveGateway> + <bpmn2:sequenceFlow id="SequenceFlow_24" name="" sourceRef="ExclusiveGateway_10" targetRef="ParallelGateway_7"> + <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression"><![CDATA[#{execution.getVariable("CMSO_updateRequestResponseCode")==200}]]></bpmn2:conditionExpression> + </bpmn2:sequenceFlow> + <bpmn2:sequenceFlow id="SequenceFlow_25" name="" sourceRef="ExclusiveGateway_10" targetRef="BuildErrorMessage1" /> + <bpmn2:exclusiveGateway id="ExclusiveGateway_7" default="SequenceFlow_1"> + <bpmn2:incoming>SequenceFlow_6</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_7</bpmn2:outgoing> + <bpmn2:outgoing>SequenceFlow_1</bpmn2:outgoing> + </bpmn2:exclusiveGateway> + <bpmn2:sequenceFlow id="SequenceFlow_7" sourceRef="ExclusiveGateway_7" targetRef="ParallelGateway_7"> + <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression"><![CDATA[#{execution.getVariable("CMSO_updateRequestResponseCode")==200}]]></bpmn2:conditionExpression> + </bpmn2:sequenceFlow> + <bpmn2:sequenceFlow id="SequenceFlow_1" name="" sourceRef="ExclusiveGateway_7" targetRef="BuildErrorMessage" /> + <bpmn2:serviceTask id="updateDBStatus" name="Update DB status to SUCCESS"> + <bpmn2:extensionElements> + <camunda:connector> + <camunda:inputOutput> + <camunda:inputParameter name="url">${URN_mso_adapters_db_endpoint}</camunda:inputParameter> + <camunda:inputParameter name="payload"><![CDATA[${execution.getVariable("CMSO_updateDBStatusToSuccessPayload")}]]></camunda:inputParameter> + <camunda:inputParameter name="headers"> + <camunda:map> + <camunda:entry key="content-type">application/soap+xml</camunda:entry> + <camunda:entry key="Authorization">#{BasicAuthHeaderValueDB}</camunda:entry> + </camunda:map> + </camunda:inputParameter> + <camunda:inputParameter name="method">POST</camunda:inputParameter> + <camunda:outputParameter name="CMSO_updateRequestResponse"><![CDATA[${statusCode == null || statusCode == 204 ? "" : response}]]></camunda:outputParameter> + <camunda:outputParameter name="CMSO_updateRequestResponseCode">${statusCode}</camunda:outputParameter> + </camunda:inputOutput> + <camunda:connectorId>soap-http-connector</camunda:connectorId> + </camunda:connector> + </bpmn2:extensionElements> + <bpmn2:incoming>SequenceFlow_49</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_23</bpmn2:outgoing> + </bpmn2:serviceTask> + <bpmn2:sequenceFlow id="SequenceFlow_23" name="" sourceRef="updateDBStatus" targetRef="ExclusiveGateway_10" /> + <bpmn2:endEvent id="EndEvent_12"> + <bpmn2:incoming>SequenceFlow_14</bpmn2:incoming> + </bpmn2:endEvent> + <bpmn2:boundaryEvent id="BoundaryEvent_7" name="" attachedToRef="updateInfraRequest"> + <bpmn2:outgoing>SequenceFlow_21</bpmn2:outgoing> + <bpmn2:errorEventDefinition id="_ErrorEventDefinition_84" errorRef="Error_1" /> + </bpmn2:boundaryEvent> + <bpmn2:sequenceFlow id="SequenceFlow_21" name="" sourceRef="BoundaryEvent_7" targetRef="EndEvent_13" /> + <bpmn2:scriptTask id="Done" name="Prepare Response" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_0fni7aq</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_17</bpmn2:outgoing> + <bpmn2:script><![CDATA[println "INSIDE --> Complete MSO Process Done SUCCESSFULLY" +import org.openecomp.mso.bpmn.common.scripts.* +def postProcessResponseData = new CompleteMsoProcess() +postProcessResponseData.postProcessResponse(execution) +println "CompleteMsoProcess Response -->" + "\n" + execution.getVariable("CompletionHandlerResponse")]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_17" name="" sourceRef="Done" targetRef="EndEvent_1" /> + <bpmn2:endEvent id="EndEvent_1"> + <bpmn2:incoming>SequenceFlow_17</bpmn2:incoming> + <bpmn2:terminateEventDefinition id="_TerminateEventDefinition_2" /> + </bpmn2:endEvent> + <bpmn2:sequenceFlow id="SequenceFlow_1s593bx" sourceRef="StartEvent_1" targetRef="preProcessRequest" /> + <bpmn2:sequenceFlow id="SequenceFlow_1epmndu" sourceRef="preProcessRequest" targetRef="ExclusiveGateway_3" /> + <bpmn2:sequenceFlow id="SequenceFlow_0fni7aq" sourceRef="ParallelGateway_7" targetRef="Done" /> + </bpmn2:process> + <bpmn2:message id="Message_2" name="CompleteMsoProcessRequest" /> + <bpmn2:error id="Error_3" name="MSOWorkflowException" errorCode="MSOWorkflowException" /> + <bpmn2:error id="Error_1" name="Java Lang Exception" errorCode="java.lang.Exception" /> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="CompleteMsoProcess"> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_41" bpmnElement="StartEvent_1"> + <dc:Bounds x="377" y="1075" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="401" y="1116" width="54" height="24" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_34" bpmnElement="preProcessRequest"> + <dc:Bounds x="543" y="1053" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ExclusiveGateway_60" bpmnElement="ExclusiveGateway_3" isMarkerVisible="true"> + <dc:Bounds x="734" y="1068" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="782" y="1083" width="100" height="22" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ParallelGateway_9" bpmnElement="ParallelGateway_7" isMarkerVisible="true"> + <dc:Bounds x="1214" y="1068" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1239" y="1123" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_51" bpmnElement="updateInfraRequest"> + <dc:Bounds x="973" y="1144" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_52" bpmnElement="updateDBStatus"> + <dc:Bounds x="970" y="963" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_64" bpmnElement="prepareUpdateRequest"> + <dc:Bounds x="822" y="963" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_50" bpmnElement="SequenceFlow_49" sourceElement="_BPMNShape_ScriptTask_64" targetElement="_BPMNShape_ScriptTask_52"> + <di:waypoint xsi:type="dc:Point" x="922" y="1003" /> + <di:waypoint xsi:type="dc:Point" x="970" y="1003" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="937" y="1003" width="6" height="6" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_73" bpmnElement="SequenceFlow_72" sourceElement="_BPMNShape_ExclusiveGateway_60" targetElement="_BPMNShape_ScriptTask_88"> + <di:waypoint xsi:type="dc:Point" x="759" y="1118" /> + <di:waypoint xsi:type="dc:Point" x="759" y="1184" /> + <di:waypoint xsi:type="dc:Point" x="822" y="1184" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="761" y="1141" width="22" height="22" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_82" bpmnElement="SequenceFlow_81" sourceElement="_BPMNShape_ExclusiveGateway_60" targetElement="_BPMNShape_ScriptTask_64"> + <di:waypoint xsi:type="dc:Point" x="759" y="1068" /> + <di:waypoint xsi:type="dc:Point" x="759" y="1003" /> + <di:waypoint xsi:type="dc:Point" x="822" y="1003" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="758" y="1022" width="29" height="22" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_SubProcess_13" bpmnElement="subProcessExceptionCompleteMSO" isExpanded="true"> + <dc:Bounds x="596" y="1416" width="427" height="169" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_EndEvent_110" bpmnElement="endEventExceptionCompleteMSO"> + <dc:Bounds x="896" y="1483" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="914" y="1524" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_51" bpmnElement="startEventExceptionCompleteMSO"> + <dc:Bounds x="692" y="1483" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="710" y="1524" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ExclusiveGateway_63" bpmnElement="ExclusiveGateway_7" isMarkerVisible="true"> + <dc:Bounds x="1132" y="1158" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1157" y="1213" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_6" bpmnElement="SequenceFlow_6" sourceElement="_BPMNShape_ScriptTask_51" targetElement="_BPMNShape_ExclusiveGateway_63"> + <di:waypoint xsi:type="dc:Point" x="1073" y="1184" /> + <di:waypoint xsi:type="dc:Point" x="1132" y="1183" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1255" y="1227" width="6" height="6" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_7" bpmnElement="SequenceFlow_7" sourceElement="_BPMNShape_ExclusiveGateway_63" targetElement="_BPMNShape_ParallelGateway_9"> + <di:waypoint xsi:type="dc:Point" x="1182" y="1183" /> + <di:waypoint xsi:type="dc:Point" x="1239" y="1183" /> + <di:waypoint xsi:type="dc:Point" x="1239" y="1118" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1158" y="1141" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_EndEvent_111" bpmnElement="EndEvent_4"> + <dc:Bounds x="1269" y="1271" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1287" y="1312" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_76" bpmnElement="BuildErrorMessage"> + <dc:Bounds x="1108" y="1249" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_1" bpmnElement="SequenceFlow_1" sourceElement="_BPMNShape_ExclusiveGateway_63" targetElement="_BPMNShape_ScriptTask_76"> + <di:waypoint xsi:type="dc:Point" x="1157" y="1208" /> + <di:waypoint xsi:type="dc:Point" x="1158" y="1249" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1199" y="1035" width="6" height="6" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_9" bpmnElement="SequenceFlow_9" sourceElement="_BPMNShape_ScriptTask_76" targetElement="_BPMNShape_EndEvent_111"> + <di:waypoint xsi:type="dc:Point" x="1208" y="1289" /> + <di:waypoint xsi:type="dc:Point" x="1269" y="1289" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1236" y="1289" width="6" height="6" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_77" bpmnElement="Done"> + <dc:Bounds x="1409" y="1053" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ExclusiveGateway_66" bpmnElement="ExclusiveGateway_10" isMarkerVisible="true"> + <dc:Bounds x="1132" y="977" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1157" y="1032" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_23" bpmnElement="SequenceFlow_23" sourceElement="_BPMNShape_ScriptTask_52" targetElement="_BPMNShape_ExclusiveGateway_66"> + <di:waypoint xsi:type="dc:Point" x="1070" y="1003" /> + <di:waypoint xsi:type="dc:Point" x="1132" y="1002" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1261" y="1003" width="6" height="6" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_25" bpmnElement="SequenceFlow_24" sourceElement="_BPMNShape_ExclusiveGateway_66" targetElement="_BPMNShape_ParallelGateway_9"> + <di:waypoint xsi:type="dc:Point" x="1182" y="1002" /> + <di:waypoint xsi:type="dc:Point" x="1239" y="1002" /> + <di:waypoint xsi:type="dc:Point" x="1239" y="1068" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1348" y="1003" width="6" height="6" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_79" bpmnElement="BuildErrorMessage1"> + <dc:Bounds x="1108" y="856" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_26" bpmnElement="SequenceFlow_25" sourceElement="_BPMNShape_ExclusiveGateway_66" targetElement="_BPMNShape_ScriptTask_79"> + <di:waypoint xsi:type="dc:Point" x="1157" y="977" /> + <di:waypoint xsi:type="dc:Point" x="1158" y="936" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1242" y="957" width="6" height="6" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_EndEvent_113" bpmnElement="EndEvent_5"> + <dc:Bounds x="1269" y="878" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1287" y="919" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_14" bpmnElement="SequenceFlow_13" sourceElement="_BPMNShape_ScriptTask_79" targetElement="_BPMNShape_EndEvent_113"> + <di:waypoint xsi:type="dc:Point" x="1208" y="896" /> + <di:waypoint xsi:type="dc:Point" x="1269" y="896" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1225" y="896" width="6" height="6" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_EndEvent_128" bpmnElement="EndEvent_1"> + <dc:Bounds x="1623" y="1075" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1641" y="1116" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_18" bpmnElement="SequenceFlow_17" sourceElement="_BPMNShape_ScriptTask_77" targetElement="_BPMNShape_EndEvent_128"> + <di:waypoint xsi:type="dc:Point" x="1509" y="1093" /> + <di:waypoint xsi:type="dc:Point" x="1623" y="1093" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1566" y="1078" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_BoundaryEvent_28" bpmnElement="BoundaryEvent_6"> + <dc:Bounds x="1001" y="945" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1016" y="986" width="6" height="6" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_BoundaryEvent_29" bpmnElement="BoundaryEvent_7"> + <dc:Bounds x="1002" y="1206" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1292" y="1088" width="6" height="6" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_EndEvent_218" bpmnElement="EndEvent_12"> + <dc:Bounds x="1001" y="864" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1019" y="905" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_15" bpmnElement="SequenceFlow_14" sourceElement="_BPMNShape_BoundaryEvent_28" targetElement="_BPMNShape_EndEvent_218"> + <di:waypoint xsi:type="dc:Point" x="1019" y="945" /> + <di:waypoint xsi:type="dc:Point" x="1019" y="900" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1180" y="927" width="6" height="6" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_EndEvent_219" bpmnElement="EndEvent_13"> + <dc:Bounds x="1002" y="1292" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1020" y="1333" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_22" bpmnElement="SequenceFlow_21" sourceElement="_BPMNShape_BoundaryEvent_29" targetElement="_BPMNShape_EndEvent_219"> + <di:waypoint xsi:type="dc:Point" x="1020" y="1242" /> + <di:waypoint xsi:type="dc:Point" x="1020" y="1292" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="847" y="747" width="6" height="6" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_88" bpmnElement="ScriptTask_3"> + <dc:Bounds x="822" y="1144" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_11" bpmnElement="SequenceFlow_10" sourceElement="_BPMNShape_ScriptTask_88" targetElement="_BPMNShape_ScriptTask_51"> + <di:waypoint xsi:type="dc:Point" x="922" y="1184" /> + <di:waypoint xsi:type="dc:Point" x="973" y="1184" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="939" y="1208" width="6" height="6" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_21" bpmnElement="SequenceFlow_19" sourceElement="_BPMNShape_StartEvent_51" targetElement="_BPMNShape_EndEvent_110"> + <di:waypoint xsi:type="dc:Point" x="728" y="1501" /> + <di:waypoint xsi:type="dc:Point" x="896" y="1501" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="854" y="1501" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1s593bx_di" bpmnElement="SequenceFlow_1s593bx"> + <di:waypoint xsi:type="dc:Point" x="413" y="1093" /> + <di:waypoint xsi:type="dc:Point" x="543" y="1093" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="478" y="1078" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1epmndu_di" bpmnElement="SequenceFlow_1epmndu"> + <di:waypoint xsi:type="dc:Point" x="643" y="1093" /> + <di:waypoint xsi:type="dc:Point" x="734" y="1093" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="689" y="1078" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0fni7aq_di" bpmnElement="SequenceFlow_0fni7aq"> + <di:waypoint xsi:type="dc:Point" x="1264" y="1093" /> + <di:waypoint xsi:type="dc:Point" x="1319" y="1093" /> + <di:waypoint xsi:type="dc:Point" x="1319" y="1093" /> + <di:waypoint xsi:type="dc:Point" x="1409" y="1093" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1334" y="1093" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn2:definitions> diff --git a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/ConfirmVolumeGroupName.bpmn b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/ConfirmVolumeGroupName.bpmn new file mode 100644 index 0000000000..b190107d5e --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/ConfirmVolumeGroupName.bpmn @@ -0,0 +1,229 @@ +<?xml version="1.0" encoding="UTF-8"?> +<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd" id="_Wblj8GyfEeWUWLTvug7ZOg" exporter="camunda modeler" exporterVersion="2.7.0" targetNamespace="http://camunda.org/schema/1.0/bpmn"> + <bpmn2:process id="ConfirmVolumeGroupName" name="ConfirmVolumeGroupName" isExecutable="true"> + <bpmn2:exclusiveGateway id="ExclusiveGateway_3" default="SequenceFlow_2"> + <bpmn2:incoming>SequenceFlow_39</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_23</bpmn2:outgoing> + <bpmn2:outgoing>SequenceFlow_2</bpmn2:outgoing> + </bpmn2:exclusiveGateway> + <bpmn2:sequenceFlow id="SequenceFlow_23" name="" sourceRef="ExclusiveGateway_3" targetRef="AAIQueryFailure"> + <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression"><![CDATA[#{execution.getVariable("CVGN_queryVolumeGroupResponseCode") != 200 && execution.getVariable("CVGN_queryVolumeGroupResponseCode") != 404}]]></bpmn2:conditionExpression> + </bpmn2:sequenceFlow> + <bpmn2:scriptTask id="AAIQueryFailure" name="AAI Query Failure" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_23</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_18</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +def cvgn= new ConfirmVolumeGroupName() +cvgn.handleAAIQueryFailure(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_18" name="" sourceRef="AAIQueryFailure" targetRef="EndEvent_7"/> + <bpmn2:endEvent id="EndEvent_7"> + <bpmn2:incoming>SequenceFlow_18</bpmn2:incoming> + <bpmn2:errorEventDefinition id="_ErrorEventDefinition_68" errorRef="Error_1"/> + </bpmn2:endEvent> + <bpmn2:scriptTask id="QueryAAIForVolumeGroupId" name="Query AAI for
Volume Group Id" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_38</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_39</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +def cvgn= new ConfirmVolumeGroupName() +cvgn.queryAAIForVolumeGroupId(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_39" name="" sourceRef="QueryAAIForVolumeGroupId" targetRef="ExclusiveGateway_3"/> + <bpmn2:scriptTask id="InitializeVariables" name="Initialize Variables" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_1</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_38</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +def cvgn= new ConfirmVolumeGroupName() +cvgn.preProcessRequest(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_38" name="" sourceRef="InitializeVariables" targetRef="QueryAAIForVolumeGroupId"/> + <bpmn2:sequenceFlow id="SequenceFlow_2" name="" sourceRef="ExclusiveGateway_3" targetRef="CheckAAIQueryResult"/> + <bpmn2:scriptTask id="CheckAAIQueryResult" name="Check AAI Query Result" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_2</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_4</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +def cvgn= new ConfirmVolumeGroupName() +cvgn.checkAAIQueryResult(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_4" name="" sourceRef="CheckAAIQueryResult" targetRef="ExclusiveGateway_1"/> + <bpmn2:scriptTask id="VolumeGroupNotInName" name="Volume Group Not In Name" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_7</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_11</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +def cvgn= new ConfirmVolumeGroupName() +cvgn.handleVolumeGroupNameNoMatch(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:exclusiveGateway id="ExclusiveGateway_1" default="SequenceFlow_7"> + <bpmn2:incoming>SequenceFlow_4</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_5</bpmn2:outgoing> + <bpmn2:outgoing>SequenceFlow_7</bpmn2:outgoing> + </bpmn2:exclusiveGateway> + <bpmn2:sequenceFlow id="SequenceFlow_5" name="" sourceRef="ExclusiveGateway_1" targetRef="EndEvent_4"> + <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression"><![CDATA[#{execution.getVariable("CVGN_volumeGroupNameMatches")==true}]]></bpmn2:conditionExpression> + </bpmn2:sequenceFlow> + <bpmn2:sequenceFlow id="SequenceFlow_7" name="" sourceRef="ExclusiveGateway_1" targetRef="VolumeGroupNotInName"/> + <bpmn2:endEvent id="EndEvent_4"> + <bpmn2:extensionElements> + <camunda:connector> + <camunda:inputOutput> + <camunda:outputParameter name="WorkflowResponse"><![CDATA[<aetgt:CreateVfModuleResponse xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1" xmlns:ns="http://org.openecomp/mso/workflow/schema/v1"> + <ns:response>SUCCESS</ns:response> + </aetgt:CreateVfModuleResponse>]]></camunda:outputParameter> + </camunda:inputOutput> + </camunda:connector> + </bpmn2:extensionElements> + <bpmn2:incoming>SequenceFlow_5</bpmn2:incoming> + <bpmn2:terminateEventDefinition id="_TerminateEventDefinition_2"/> + </bpmn2:endEvent> + <bpmn2:sequenceFlow id="SequenceFlow_11" name="" sourceRef="VolumeGroupNotInName" targetRef="EndEvent_1"/> + <bpmn2:endEvent id="EndEvent_1"> + <bpmn2:incoming>SequenceFlow_11</bpmn2:incoming> + <bpmn2:errorEventDefinition id="_ErrorEventDefinition_70" errorRef="Error_1"/> + </bpmn2:endEvent> + <bpmn2:startEvent id="StartEvent_1"> + <bpmn2:outgoing>SequenceFlow_1</bpmn2:outgoing> + </bpmn2:startEvent> + <bpmn2:sequenceFlow id="SequenceFlow_1" name="" sourceRef="StartEvent_1" targetRef="InitializeVariables"/> + </bpmn2:process> + <bpmn2:message id="Message_1" name="ConfirmVolumeGroupNameRequest"/> + <bpmn2:error id="Error_1" errorCode="MSOWorkflowException" name="MSO Workflow Exception"/> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="CreateAAIVfModule"> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_37" bpmnElement="StartEvent_1"> + <dc:Bounds height="36.0" width="36.0" x="43.0" y="199.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="61.0" y="240.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_22" bpmnElement="InitializeVariables"> + <dc:Bounds height="80.0" width="100.0" x="204.0" y="178.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_1" bpmnElement="SequenceFlow_1" sourceElement="_BPMNShape_StartEvent_37" targetElement="_BPMNShape_ScriptTask_22"> + <di:waypoint xsi:type="dc:Point" x="79.0" y="217.0"/> + <di:waypoint xsi:type="dc:Point" x="120.0" y="217.0"/> + <di:waypoint xsi:type="dc:Point" x="120.0" y="218.0"/> + <di:waypoint xsi:type="dc:Point" x="204.0" y="218.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="101.0" y="217.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_EndEvent_92" bpmnElement="EndEvent_4"> + <dc:Bounds height="36.0" width="36.0" x="912.0" y="199.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="930.0" y="240.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ExclusiveGateway_86" bpmnElement="ExclusiveGateway_3" isMarkerVisible="true"> + <dc:Bounds height="50.0" width="50.0" x="468.0" y="191.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="493.0" y="246.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_155" bpmnElement="AAIQueryFailure"> + <dc:Bounds height="80.0" width="100.0" x="518.0" y="297.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_24" bpmnElement="SequenceFlow_23" sourceElement="_BPMNShape_ExclusiveGateway_86" targetElement="_BPMNShape_ScriptTask_155"> + <di:waypoint xsi:type="dc:Point" x="493.0" y="241.0"/> + <di:waypoint xsi:type="dc:Point" x="493.0" y="259.0"/> + <di:waypoint xsi:type="dc:Point" x="568.0" y="259.0"/> + <di:waypoint xsi:type="dc:Point" x="568.0" y="297.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="547.0" y="259.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_EndEvent_160" bpmnElement="EndEvent_7"> + <dc:Bounds height="36.0" width="36.0" x="550.0" y="416.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="568.0" y="457.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_18" bpmnElement="SequenceFlow_18" sourceElement="_BPMNShape_ScriptTask_155" targetElement="_BPMNShape_EndEvent_160"> + <di:waypoint xsi:type="dc:Point" x="568.0" y="377.0"/> + <di:waypoint xsi:type="dc:Point" x="568.0" y="416.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="565.0" y="388.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_160" bpmnElement="QueryAAIForVolumeGroupId"> + <dc:Bounds height="80.0" width="100.0" x="336.0" y="178.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_38" bpmnElement="SequenceFlow_38" sourceElement="_BPMNShape_ScriptTask_22" targetElement="_BPMNShape_ScriptTask_160"> + <di:waypoint xsi:type="dc:Point" x="304.0" y="218.0"/> + <di:waypoint xsi:type="dc:Point" x="336.0" y="218.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="324.0" y="218.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_39" bpmnElement="SequenceFlow_39" sourceElement="_BPMNShape_ScriptTask_160" targetElement="_BPMNShape_ExclusiveGateway_86"> + <di:waypoint xsi:type="dc:Point" x="436.0" y="218.0"/> + <di:waypoint xsi:type="dc:Point" x="452.0" y="218.0"/> + <di:waypoint xsi:type="dc:Point" x="452.0" y="216.0"/> + <di:waypoint xsi:type="dc:Point" x="468.0" y="216.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="449.0" y="217.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_EndEvent_162" bpmnElement="EndEvent_1"> + <dc:Bounds height="36.0" width="36.0" x="720.0" y="415.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="738.0" y="456.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_177" bpmnElement="CheckAAIQueryResult"> + <dc:Bounds height="80.0" width="100.0" x="624.0" y="177.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_2" bpmnElement="SequenceFlow_2" sourceElement="_BPMNShape_ExclusiveGateway_86" targetElement="_BPMNShape_ScriptTask_177"> + <di:waypoint xsi:type="dc:Point" x="518.0" y="216.0"/> + <di:waypoint xsi:type="dc:Point" x="551.0" y="216.0"/> + <di:waypoint xsi:type="dc:Point" x="551.0" y="217.0"/> + <di:waypoint xsi:type="dc:Point" x="624.0" y="217.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="548.0" y="217.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_ExclusiveGateway_103" bpmnElement="ExclusiveGateway_1" isMarkerVisible="true"> + <dc:Bounds height="50.0" width="50.0" x="801.0" y="191.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="826.0" y="246.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_3" bpmnElement="SequenceFlow_4" sourceElement="_BPMNShape_ScriptTask_177" targetElement="_BPMNShape_ExclusiveGateway_103"> + <di:waypoint xsi:type="dc:Point" x="724.0" y="217.0"/> + <di:waypoint xsi:type="dc:Point" x="762.0" y="217.0"/> + <di:waypoint xsi:type="dc:Point" x="762.0" y="216.0"/> + <di:waypoint xsi:type="dc:Point" x="801.0" y="216.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="735.0" y="217.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_5" bpmnElement="SequenceFlow_5" sourceElement="_BPMNShape_ExclusiveGateway_103" targetElement="_BPMNShape_EndEvent_92"> + <di:waypoint xsi:type="dc:Point" x="851.0" y="216.0"/> + <di:waypoint xsi:type="dc:Point" x="869.0" y="216.0"/> + <di:waypoint xsi:type="dc:Point" x="869.0" y="217.0"/> + <di:waypoint xsi:type="dc:Point" x="912.0" y="217.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="855.0" y="216.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_179" bpmnElement="VolumeGroupNotInName"> + <dc:Bounds height="80.0" width="100.0" x="688.0" y="297.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_8" bpmnElement="SequenceFlow_7" sourceElement="_BPMNShape_ExclusiveGateway_103" targetElement="_BPMNShape_ScriptTask_179"> + <di:waypoint xsi:type="dc:Point" x="826.0" y="241.0"/> + <di:waypoint xsi:type="dc:Point" x="826.0" y="269.0"/> + <di:waypoint xsi:type="dc:Point" x="738.0" y="269.0"/> + <di:waypoint xsi:type="dc:Point" x="738.0" y="297.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="822.0" y="269.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_11" bpmnElement="SequenceFlow_11" sourceElement="_BPMNShape_ScriptTask_179" targetElement="_BPMNShape_EndEvent_162"> + <di:waypoint xsi:type="dc:Point" x="738.0" y="377.0"/> + <di:waypoint xsi:type="dc:Point" x="738.0" y="415.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="735.0" y="391.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn2:definitions>
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/ConfirmVolumeGroupTenant.bpmn b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/ConfirmVolumeGroupTenant.bpmn new file mode 100644 index 0000000000..fee4dbd2d3 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/ConfirmVolumeGroupTenant.bpmn @@ -0,0 +1,190 @@ +<?xml version="1.0" encoding="UTF-8"?> +<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd" id="_jPy0EB7JEeaR94RQz1cKqQ" exporter="camunda modeler" exporterVersion="2.7.0" targetNamespace="http://camunda.org/schema/1.0/bpmn"> + <bpmn2:process id="ConfirmVolumeGroupTenant" name="ConfirmVolumeGroupTenant" isExecutable="true"> + <bpmn2:scriptTask id="queryAAIForVolumeGroup" name="Query AAI Volume Group" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_1</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_2</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +ConfirmVolumeGroupTenant volume = new ConfirmVolumeGroupTenant() +volume.preProcessRequest(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:exclusiveGateway id="tenantIdMatchCheck" name="Tenant Ids
Match?" default="idsMatchNo"> + <bpmn2:incoming>SequenceFlow_2</bpmn2:incoming> + <bpmn2:outgoing>idsMatchNo</bpmn2:outgoing> + <bpmn2:outgoing>idsMatchYes</bpmn2:outgoing> + </bpmn2:exclusiveGateway> + <bpmn2:sequenceFlow id="SequenceFlow_2" name="" sourceRef="queryAAIForVolumeGroup" targetRef="tenantIdMatchCheck"/> + <bpmn2:sequenceFlow id="idsMatchNo" name="No" sourceRef="tenantIdMatchCheck" targetRef="assignError"/> + <bpmn2:sequenceFlow id="idsMatchYes" name="Yes" sourceRef="tenantIdMatchCheck" targetRef="tenantNamesMatchCheck"> + <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression"><![CDATA[#{execution.getVariable("tenantIdsMatch")==true}]]></bpmn2:conditionExpression> + </bpmn2:sequenceFlow> + <bpmn2:endEvent id="EndEvent_1"> + <bpmn2:incoming>SequenceFlow_7</bpmn2:incoming> + <bpmn2:terminateEventDefinition id="_TerminateEventDefinition_2"/> + </bpmn2:endEvent> + <bpmn2:scriptTask id="assignError" name="Assign Workflow Exception" scriptFormat="groovy"> + <bpmn2:incoming>idsMatchNo</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_8</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +ConfirmVolumeGroupTenant volume = new ConfirmVolumeGroupTenant() +volume.assignWorkflowException(execution, "does not belong to your tenant")]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_8" name="" sourceRef="assignError" targetRef="EndEvent_3"/> + <bpmn2:endEvent id="EndEvent_3"> + <bpmn2:incoming>SequenceFlow_8</bpmn2:incoming> + <bpmn2:errorEventDefinition id="_ErrorEventDefinition_75" errorRef="Error_1"/> + </bpmn2:endEvent> + <bpmn2:scriptTask id="assignVolumeHeatId" name="Assign Volume Heat Id" scriptFormat="groovy"> + <bpmn2:incoming>groupNamesMatchYes</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_7</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +ConfirmVolumeGroupTenant volume = new ConfirmVolumeGroupTenant() +volume.assignVolumeHeatId(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_7" name="" sourceRef="assignVolumeHeatId" targetRef="EndEvent_1"/> + <bpmn2:scriptTask id="assignErrorNames" name="Assign Workflow Exception" scriptFormat="groovy"> + <bpmn2:incoming>groupNamesMatchNo</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_9</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +ConfirmVolumeGroupTenant volume = new ConfirmVolumeGroupTenant() +volume.assignWorkflowException(execution, "name does not match")]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_9" name="" sourceRef="assignErrorNames" targetRef="EndEvent_2"/> + <bpmn2:endEvent id="EndEvent_2"> + <bpmn2:incoming>SequenceFlow_9</bpmn2:incoming> + <bpmn2:errorEventDefinition id="_ErrorEventDefinition_74" errorRef="Error_1"/> + </bpmn2:endEvent> + <bpmn2:exclusiveGateway id="tenantNamesMatchCheck" name="Volume Group
Names Match?" default="groupNamesMatchNo"> + <bpmn2:incoming>idsMatchYes</bpmn2:incoming> + <bpmn2:outgoing>groupNamesMatchNo</bpmn2:outgoing> + <bpmn2:outgoing>groupNamesMatchYes</bpmn2:outgoing> + </bpmn2:exclusiveGateway> + <bpmn2:sequenceFlow id="groupNamesMatchNo" name="No" sourceRef="tenantNamesMatchCheck" targetRef="assignErrorNames"/> + <bpmn2:sequenceFlow id="groupNamesMatchYes" name="Yes" sourceRef="tenantNamesMatchCheck" targetRef="assignVolumeHeatId"> + <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression"><![CDATA[#{execution.getVariable("groupNamesMatch")==true}]]></bpmn2:conditionExpression> + </bpmn2:sequenceFlow> + <bpmn2:startEvent id="StartEvent_1"> + <bpmn2:outgoing>SequenceFlow_1</bpmn2:outgoing> + </bpmn2:startEvent> + <bpmn2:sequenceFlow id="SequenceFlow_1" name="" sourceRef="StartEvent_1" targetRef="queryAAIForVolumeGroup"/> + </bpmn2:process> + <bpmn2:error id="Error_1" errorCode="MSOWorkflowException" name="MSO Workflow Exception"/> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="ConfirmVolumeGroupTenant"> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_61" bpmnElement="StartEvent_1"> + <dc:Bounds height="36.0" width="36.0" x="129.0" y="324.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="147.0" y="365.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_237" bpmnElement="queryAAIForVolumeGroup"> + <dc:Bounds height="80.0" width="100.0" x="252.0" y="302.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_1" bpmnElement="SequenceFlow_1" sourceElement="_BPMNShape_StartEvent_61" targetElement="_BPMNShape_ScriptTask_237"> + <di:waypoint xsi:type="dc:Point" x="165.0" y="342.0"/> + <di:waypoint xsi:type="dc:Point" x="252.0" y="342.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="179.0" y="342.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_ExclusiveGateway_209" bpmnElement="tenantIdMatchCheck" isMarkerVisible="true"> + <dc:Bounds height="50.0" width="50.0" x="384.0" y="316.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="38.0" width="76.0" x="414.0" y="347.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_2" bpmnElement="SequenceFlow_2" sourceElement="_BPMNShape_ScriptTask_237" targetElement="_BPMNShape_ExclusiveGateway_209"> + <di:waypoint xsi:type="dc:Point" x="352.0" y="342.0"/> + <di:waypoint xsi:type="dc:Point" x="368.0" y="342.0"/> + <di:waypoint xsi:type="dc:Point" x="368.0" y="341.0"/> + <di:waypoint xsi:type="dc:Point" x="384.0" y="341.0"/> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_ExclusiveGateway_210" bpmnElement="tenantNamesMatchCheck" isMarkerVisible="true"> + <dc:Bounds height="50.0" width="50.0" x="460.0" y="216.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="38.0" width="99.0" x="494.0" y="246.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_238" bpmnElement="assignError"> + <dc:Bounds height="80.0" width="100.0" x="456.0" y="400.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_3" bpmnElement="idsMatchNo" sourceElement="_BPMNShape_ExclusiveGateway_209" targetElement="_BPMNShape_ScriptTask_238"> + <di:waypoint xsi:type="dc:Point" x="409.0" y="366.0"/> + <di:waypoint xsi:type="dc:Point" x="409.0" y="440.0"/> + <di:waypoint xsi:type="dc:Point" x="456.0" y="440.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="22.0" width="22.0" x="414.0" y="400.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_4" bpmnElement="idsMatchYes" sourceElement="_BPMNShape_ExclusiveGateway_209" targetElement="_BPMNShape_ExclusiveGateway_210"> + <di:waypoint xsi:type="dc:Point" x="409.0" y="316.0"/> + <di:waypoint xsi:type="dc:Point" x="409.0" y="241.0"/> + <di:waypoint xsi:type="dc:Point" x="460.0" y="241.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="22.0" width="29.0" x="411.0" y="266.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_239" bpmnElement="assignErrorNames"> + <dc:Bounds height="80.0" width="100.0" x="555.0" y="296.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_5" bpmnElement="groupNamesMatchNo" sourceElement="_BPMNShape_ExclusiveGateway_210" targetElement="_BPMNShape_ScriptTask_239"> + <di:waypoint xsi:type="dc:Point" x="485.0" y="266.0"/> + <di:waypoint xsi:type="dc:Point" x="485.0" y="336.0"/> + <di:waypoint xsi:type="dc:Point" x="555.0" y="336.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="22.0" width="22.0" x="491.0" y="296.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_240" bpmnElement="assignVolumeHeatId"> + <dc:Bounds height="80.0" width="100.0" x="555.0" y="120.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_6" bpmnElement="groupNamesMatchYes" sourceElement="_BPMNShape_ExclusiveGateway_210" targetElement="_BPMNShape_ScriptTask_240"> + <di:waypoint xsi:type="dc:Point" x="485.0" y="216.0"/> + <di:waypoint xsi:type="dc:Point" x="485.0" y="160.0"/> + <di:waypoint xsi:type="dc:Point" x="555.0" y="160.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="22.0" width="29.0" x="487.0" y="173.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_EndEvent_200" bpmnElement="EndEvent_1"> + <dc:Bounds height="36.0" width="36.0" x="738.0" y="142.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="756.0" y="183.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_7" bpmnElement="SequenceFlow_7" sourceElement="_BPMNShape_ScriptTask_240" targetElement="_BPMNShape_EndEvent_200"> + <di:waypoint xsi:type="dc:Point" x="655.0" y="160.0"/> + <di:waypoint xsi:type="dc:Point" x="738.0" y="160.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="692.0" y="160.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_EndEvent_210" bpmnElement="EndEvent_2"> + <dc:Bounds height="36.0" width="36.0" x="709.0" y="318.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="727.0" y="359.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_EndEvent_211" bpmnElement="EndEvent_3"> + <dc:Bounds height="36.0" width="36.0" x="605.0" y="422.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="623.0" y="463.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_8" bpmnElement="SequenceFlow_8" sourceElement="_BPMNShape_ScriptTask_238" targetElement="_BPMNShape_EndEvent_211"> + <di:waypoint xsi:type="dc:Point" x="556.0" y="440.0"/> + <di:waypoint xsi:type="dc:Point" x="605.0" y="440.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="591.0" y="440.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_9" bpmnElement="SequenceFlow_9" sourceElement="_BPMNShape_ScriptTask_239" targetElement="_BPMNShape_EndEvent_210"> + <di:waypoint xsi:type="dc:Point" x="655.0" y="336.0"/> + <di:waypoint xsi:type="dc:Point" x="709.0" y="336.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="680.0" y="336.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn2:definitions>
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/CreateAAIVfModule.bpmn b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/CreateAAIVfModule.bpmn new file mode 100644 index 0000000000..2ca2693b7c --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/CreateAAIVfModule.bpmn @@ -0,0 +1,519 @@ +<?xml version="1.0" encoding="UTF-8"?> +<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd" id="_Wblj8GyfEeWUWLTvug7ZOg" exporter="camunda modeler" exporterVersion="2.7.0" targetNamespace="http://camunda.org/schema/1.0/bpmn"> + <bpmn2:process id="CreateAAIVfModule" name="CreateAAIVfModule" isExecutable="true"> + <bpmn2:exclusiveGateway id="ExclusiveGateway_5" default="SequenceFlow_7"> + <bpmn2:incoming>SequenceFlow_24</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_6</bpmn2:outgoing> + <bpmn2:outgoing>SequenceFlow_7</bpmn2:outgoing> + <bpmn2:outgoing>SequenceFlow_28</bpmn2:outgoing> + </bpmn2:exclusiveGateway> + <bpmn2:sequenceFlow id="SequenceFlow_6" name="" sourceRef="ExclusiveGateway_5" targetRef="ExclusiveGateway_6"> + <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression"><![CDATA[#{(execution.getVariable("CAAIVfMod_newGenericVnf") == true && execution.getVariable("CAAIVfMod_queryGenericVnfResponseCode") == 404) || execution.getVariable("CAAIVfMod_isBaseVfModule") == true}]]></bpmn2:conditionExpression> + </bpmn2:sequenceFlow> + <bpmn2:sequenceFlow id="SequenceFlow_7" name="" sourceRef="ExclusiveGateway_5" targetRef="ScriptTask_2"/> + <bpmn2:exclusiveGateway id="ExclusiveGateway_3" default="SequenceFlow_22"> + <bpmn2:incoming>SequenceFlow_39</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_22</bpmn2:outgoing> + <bpmn2:outgoing>SequenceFlow_23</bpmn2:outgoing> + </bpmn2:exclusiveGateway> + <bpmn2:sequenceFlow id="SequenceFlow_22" name="" sourceRef="ExclusiveGateway_3" targetRef="ProcessAAISearch"/> + <bpmn2:sequenceFlow id="SequenceFlow_23" name="" sourceRef="ExclusiveGateway_3" targetRef="AAIQueryFailure"> + <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression"><![CDATA[#{execution.getVariable("CAAIVfMod_queryGenericVnfResponseCode") != 200 && execution.getVariable("CAAIVfMod_queryGenericVnfResponseCode") != 404}]]></bpmn2:conditionExpression> + </bpmn2:sequenceFlow> + <bpmn2:scriptTask id="AAIQueryFailure" name="AAI Query Failure" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_23</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_18</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +def cvm = new CreateAAIVfModule() +cvm.handleAAIQueryFailure(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_18" name="" sourceRef="AAIQueryFailure" targetRef="EndEvent_7"/> + <bpmn2:endEvent id="EndEvent_7"> + <bpmn2:incoming>SequenceFlow_18</bpmn2:incoming> + <bpmn2:errorEventDefinition id="_ErrorEventDefinition_68" errorRef="Error_1"/> + </bpmn2:endEvent> + <bpmn2:scriptTask id="ProcessAAISearch" name="Process AAI Generic Vnf Query" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_22</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_24</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +def cvm = new CreateAAIVfModule() +cvm.processAAIGenericVnfQuery(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_24" name="" sourceRef="ProcessAAISearch" targetRef="ExclusiveGateway_5"/> + <bpmn2:exclusiveGateway id="ExclusiveGateway_1" default="SequenceFlow_5"> + <bpmn2:incoming>SequenceFlow_8</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_5</bpmn2:outgoing> + <bpmn2:outgoing>SequenceFlow_10</bpmn2:outgoing> + </bpmn2:exclusiveGateway> + <bpmn2:exclusiveGateway id="ExclusiveGateway_7"> + <bpmn2:incoming>SequenceFlow_4</bpmn2:incoming> + <bpmn2:incoming>SequenceFlow_35</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_8</bpmn2:outgoing> + </bpmn2:exclusiveGateway> + <bpmn2:sequenceFlow id="SequenceFlow_28" name="Generic Vnf does not exist
 and Vnf Id != null or
Generic Vnf does exist
and Vnf Id == null" sourceRef="ExclusiveGateway_5" targetRef="CreateGenericVnfFailure"> + <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression"><![CDATA[#{(execution.getVariable("CAAIVfMod_newGenericVnf") == false && execution.getVariable("CAAIVfMod_queryGenericVnfResponseCode") == 404) || (execution.getVariable("CAAIVfMod_newGenericVnf") == true && execution.getVariable("CAAIVfMod_queryGenericVnfResponseCode") == 200)}]]></bpmn2:conditionExpression> + </bpmn2:sequenceFlow> + <bpmn2:scriptTask id="CreateGenericVnfFailure" name="Create Generic Vnf Failure" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_28</bpmn2:incoming> + <bpmn2:incoming>SequenceFlow_26</bpmn2:incoming> + <bpmn2:incoming>SequenceFlow_33</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_29</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +def cvm = new CreateAAIVfModule() +cvm.handleCreateVfModuleFailure(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:endEvent id="EndEvent_8"> + <bpmn2:incoming>SequenceFlow_29</bpmn2:incoming> + <bpmn2:errorEventDefinition id="_ErrorEventDefinition_69" errorRef="Error_1"/> + </bpmn2:endEvent> + <bpmn2:sequenceFlow id="SequenceFlow_29" name="" sourceRef="CreateGenericVnfFailure" targetRef="EndEvent_8"/> + <bpmn2:scriptTask id="ScriptTask_2" name="Parse For Add-on Module" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_7</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_31</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +def cvm = new CreateAAIVfModule() +cvm.parseForAddOnModule(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_31" name="" sourceRef="ScriptTask_2" targetRef="ExclusiveGateway_4"/> + <bpmn2:scriptTask id="ScriptTask_8" name="Create Add-on Module" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_34</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_35</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +def cvm = new CreateAAIVfModule() +cvm.createVfModule(execution, false)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_35" name="" sourceRef="ScriptTask_8" targetRef="ExclusiveGateway_7"/> + <bpmn2:exclusiveGateway id="ExclusiveGateway_4" default="SequenceFlow_33"> + <bpmn2:incoming>SequenceFlow_31</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_33</bpmn2:outgoing> + <bpmn2:outgoing>SequenceFlow_34</bpmn2:outgoing> + </bpmn2:exclusiveGateway> + <bpmn2:sequenceFlow id="SequenceFlow_33" name="Vnf Module Exists
" sourceRef="ExclusiveGateway_4" targetRef="CreateGenericVnfFailure"/> + <bpmn2:sequenceFlow id="SequenceFlow_34" name="" sourceRef="ExclusiveGateway_4" targetRef="ScriptTask_8"> + <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression"><![CDATA[#{execution.getVariable("CAAIVfMod_moduleExists") != true}]]></bpmn2:conditionExpression> + </bpmn2:sequenceFlow> + <bpmn2:scriptTask id="QueryAAIForGenericVnf" name="Query AAI for
Generic Vnf" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_38</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_39</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +def cvm = new CreateAAIVfModule() +cvm.queryAAIForGenericVnf(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_39" name="" sourceRef="QueryAAIForGenericVnf" targetRef="ExclusiveGateway_3"/> + <bpmn2:scriptTask id="InitializeVariables" name="Initialize Variables" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_1</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_38</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +def cvm = new CreateAAIVfModule() +cvm.preProcessRequest(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_38" name="" sourceRef="InitializeVariables" targetRef="QueryAAIForGenericVnf"/> + <bpmn2:endEvent id="EndEvent_2"> + <bpmn2:incoming>SequenceFlow_2</bpmn2:incoming> + <bpmn2:errorEventDefinition id="_ErrorEventDefinition_50" errorRef="Error_1"/> + </bpmn2:endEvent> + <bpmn2:scriptTask id="CreateVfModuleFailure" name="Create Vf Module Failure" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_5</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_2</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +def cvm = new CreateAAIVfModule() +cvm.handleCreateVfModuleFailure(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_2" name="" sourceRef="CreateVfModuleFailure" targetRef="EndEvent_2"/> + <bpmn2:sequenceFlow id="SequenceFlow_5" name="" sourceRef="ExclusiveGateway_1" targetRef="CreateVfModuleFailure"/> + <bpmn2:sequenceFlow id="SequenceFlow_8" name="" sourceRef="ExclusiveGateway_7" targetRef="ExclusiveGateway_1"/> + <bpmn2:endEvent id="EndEvent_1"> + <bpmn2:incoming>SequenceFlow_10</bpmn2:incoming> + </bpmn2:endEvent> + <bpmn2:sequenceFlow id="SequenceFlow_10" name="" sourceRef="ExclusiveGateway_1" targetRef="EndEvent_1"> + <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression"><![CDATA[#{execution.getVariable("CAAIVfMod_createVfModuleResponseCode") == 200 || execution.getVariable("CAAIVfMod_createVfModuleResponseCode") == 201}]]></bpmn2:conditionExpression> + </bpmn2:sequenceFlow> + <bpmn2:exclusiveGateway id="ExclusiveGateway_2" default="SequenceFlow_26"> + <bpmn2:incoming>SequenceFlow_20</bpmn2:incoming> + <bpmn2:incoming>SequenceFlow_13</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_26</bpmn2:outgoing> + <bpmn2:outgoing>SequenceFlow_27</bpmn2:outgoing> + </bpmn2:exclusiveGateway> + <bpmn2:sequenceFlow id="SequenceFlow_26" name="Create Generic Vnf
Failure" sourceRef="ExclusiveGateway_2" targetRef="CreateGenericVnfFailure"/> + <bpmn2:sequenceFlow id="SequenceFlow_27" name="" sourceRef="ExclusiveGateway_2" targetRef="ScriptTask_4"> + <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression"><![CDATA[#{execution.getVariable("CAAIVfMod_createGenericVnfResponseCode") == 200 || execution.getVariable("CAAIVfMod_createGenericVnfResponseCode") == 201}]]></bpmn2:conditionExpression> + </bpmn2:sequenceFlow> + <bpmn2:exclusiveGateway id="ExclusiveGateway_6" name="Is VID Request?" default="SequenceFlow_9"> + <bpmn2:incoming>SequenceFlow_6</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_9</bpmn2:outgoing> + <bpmn2:outgoing>SequenceFlow_11</bpmn2:outgoing> + </bpmn2:exclusiveGateway> + <bpmn2:sequenceFlow id="SequenceFlow_9" name="No" sourceRef="ExclusiveGateway_6" targetRef="ScriptTask_3"/> + <bpmn2:scriptTask id="ScriptTask_3" name="Create Generic Vnf" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_9</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_20</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +def cvm = new CreateAAIVfModule() +cvm.createGenericVnf(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_20" name="" sourceRef="ScriptTask_3" targetRef="ExclusiveGateway_2"/> + <bpmn2:sequenceFlow id="SequenceFlow_11" name="Yes" sourceRef="ExclusiveGateway_6" targetRef="ScriptTask_1"> + <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression"><![CDATA[#{execution.getVariable("isVidRequest") =="true"}]]></bpmn2:conditionExpression> + </bpmn2:sequenceFlow> + <bpmn2:scriptTask id="ScriptTask_4" name="Create Base Module" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_27</bpmn2:incoming> + <bpmn2:incoming>SequenceFlow_12</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_4</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +def cvm = new CreateAAIVfModule() +cvm.createVfModule(execution, true)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_4" name="" sourceRef="ScriptTask_4" targetRef="ExclusiveGateway_7"/> + <bpmn2:startEvent id="StartEvent_1"> + <bpmn2:outgoing>SequenceFlow_1</bpmn2:outgoing> + <bpmn2:messageEventDefinition id="_MessageEventDefinition_6" messageRef="Message_1"/> + </bpmn2:startEvent> + <bpmn2:sequenceFlow id="SequenceFlow_1" name="" sourceRef="StartEvent_1" targetRef="InitializeVariables"/> + <bpmn2:scriptTask id="ScriptTask_1" name="Parse for Base Module" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_11</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_3</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +def cvm = new CreateAAIVfModule() +cvm.parseForBaseModule(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_3" name="" sourceRef="ScriptTask_1" targetRef="ExclusiveGateway_8"/> + <bpmn2:exclusiveGateway id="ExclusiveGateway_8" default="SequenceFlow_13"> + <bpmn2:incoming>SequenceFlow_3</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_12</bpmn2:outgoing> + <bpmn2:outgoing>SequenceFlow_13</bpmn2:outgoing> + </bpmn2:exclusiveGateway> + <bpmn2:sequenceFlow id="SequenceFlow_12" name="" sourceRef="ExclusiveGateway_8" targetRef="ScriptTask_4"> + <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression"><![CDATA[#{(execution.getVariable("CAAIVfMod_baseModuleConflict") != true) && (execution.getVariable("CAAIVfMod_moduleExists") != true)}]]></bpmn2:conditionExpression> + </bpmn2:sequenceFlow> + <bpmn2:sequenceFlow id="SequenceFlow_13" name="Base Module Conflict" sourceRef="ExclusiveGateway_8" targetRef="ExclusiveGateway_2"/> + </bpmn2:process> + <bpmn2:message id="Message_1" name="CreateAAIVfModuleRequest"/> + <bpmn2:error id="Error_1" errorCode="MSOWorkflowException" name="MSO Workflow Exception"/> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="CreateAAIVfModule"> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_37" bpmnElement="StartEvent_1"> + <dc:Bounds height="36.0" width="36.0" x="65.0" y="240.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="83.0" y="281.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_22" bpmnElement="InitializeVariables"> + <dc:Bounds height="80.0" width="100.0" x="204.0" y="216.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_1" bpmnElement="SequenceFlow_1" sourceElement="_BPMNShape_StartEvent_37" targetElement="_BPMNShape_ScriptTask_22"> + <di:waypoint xsi:type="dc:Point" x="101.0" y="258.0"/> + <di:waypoint xsi:type="dc:Point" x="160.0" y="258.0"/> + <di:waypoint xsi:type="dc:Point" x="160.0" y="256.0"/> + <di:waypoint xsi:type="dc:Point" x="204.0" y="256.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="123.0" y="258.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_Task_2" bpmnElement="ProcessAAISearch"> + <dc:Bounds height="80.0" width="100.0" x="518.0" y="117.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ExclusiveGateway_50" bpmnElement="ExclusiveGateway_5" isMarkerVisible="true"> + <dc:Bounds height="50.0" width="50.0" x="630.0" y="230.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="655.0" y="285.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ExclusiveGateway_52" bpmnElement="ExclusiveGateway_7" isMarkerVisible="true"> + <dc:Bounds height="50.0" width="50.0" x="1120.0" y="230.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="1145.0" y="285.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_47" bpmnElement="ScriptTask_3"> + <dc:Bounds height="80.0" width="100.0" x="718.0" y="93.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_7" bpmnElement="SequenceFlow_6" sourceElement="_BPMNShape_ExclusiveGateway_50" targetElement="_BPMNShape_ExclusiveGateway_225"> + <di:waypoint xsi:type="dc:Point" x="655.0" y="230.0"/> + <di:waypoint xsi:type="dc:Point" x="655.0" y="88.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="601.0" y="133.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_48" bpmnElement="ScriptTask_2"> + <dc:Bounds height="80.0" width="100.0" x="695.0" y="391.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_8" bpmnElement="SequenceFlow_7" sourceElement="_BPMNShape_ExclusiveGateway_50" targetElement="_BPMNShape_ScriptTask_48"> + <di:waypoint xsi:type="dc:Point" x="655.0" y="280.0"/> + <di:waypoint xsi:type="dc:Point" x="655.0" y="431.0"/> + <di:waypoint xsi:type="dc:Point" x="695.0" y="431.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="574.0" y="256.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_ExclusiveGateway_54" bpmnElement="ExclusiveGateway_1" isMarkerVisible="true"> + <dc:Bounds height="50.0" width="50.0" x="1216.0" y="230.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="1241.0" y="285.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_EndEvent_120" bpmnElement="EndEvent_2"> + <dc:Bounds height="36.0" width="36.0" x="1224.0" y="454.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="1242.0" y="495.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_115" bpmnElement="ScriptTask_4"> + <dc:Bounds height="80.0" width="100.0" x="996.0" y="24.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_5" bpmnElement="SequenceFlow_4" sourceElement="_BPMNShape_ScriptTask_115" targetElement="_BPMNShape_ExclusiveGateway_52"> + <di:waypoint xsi:type="dc:Point" x="1096.0" y="64.0"/> + <di:waypoint xsi:type="dc:Point" x="1145.0" y="64.0"/> + <di:waypoint xsi:type="dc:Point" x="1145.0" y="177.0"/> + <di:waypoint xsi:type="dc:Point" x="1145.0" y="230.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="1282.0" y="51.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_ExclusiveGateway_86" bpmnElement="ExclusiveGateway_3" isMarkerVisible="true"> + <dc:Bounds height="50.0" width="50.0" x="468.0" y="229.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="493.0" y="284.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_23" bpmnElement="SequenceFlow_22" sourceElement="_BPMNShape_ExclusiveGateway_86" targetElement="_BPMNShape_Task_2"> + <di:waypoint xsi:type="dc:Point" x="493.0" y="229.0"/> + <di:waypoint xsi:type="dc:Point" x="493.0" y="158.0"/> + <di:waypoint xsi:type="dc:Point" x="518.0" y="158.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="490.0" y="192.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_155" bpmnElement="AAIQueryFailure"> + <dc:Bounds height="80.0" width="100.0" x="518.0" y="335.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_24" bpmnElement="SequenceFlow_23" sourceElement="_BPMNShape_ExclusiveGateway_86" targetElement="_BPMNShape_ScriptTask_155"> + <di:waypoint xsi:type="dc:Point" x="493.0" y="279.0"/> + <di:waypoint xsi:type="dc:Point" x="493.0" y="297.0"/> + <di:waypoint xsi:type="dc:Point" x="568.0" y="297.0"/> + <di:waypoint xsi:type="dc:Point" x="568.0" y="335.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="547.0" y="297.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_25" bpmnElement="SequenceFlow_24" sourceElement="_BPMNShape_Task_2" targetElement="_BPMNShape_ExclusiveGateway_50"> + <di:waypoint xsi:type="dc:Point" x="568.0" y="197.0"/> + <di:waypoint xsi:type="dc:Point" x="568.0" y="255.0"/> + <di:waypoint xsi:type="dc:Point" x="630.0" y="255.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="565.0" y="250.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_EndEvent_160" bpmnElement="EndEvent_7"> + <dc:Bounds height="36.0" width="36.0" x="550.0" y="454.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="568.0" y="495.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_18" bpmnElement="SequenceFlow_18" sourceElement="_BPMNShape_ScriptTask_155" targetElement="_BPMNShape_EndEvent_160"> + <di:waypoint xsi:type="dc:Point" x="568.0" y="415.0"/> + <di:waypoint xsi:type="dc:Point" x="568.0" y="454.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="565.0" y="426.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_158" bpmnElement="CreateGenericVnfFailure"> + <dc:Bounds height="80.0" width="100.0" x="837.0" y="213.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ExclusiveGateway_99" bpmnElement="ExclusiveGateway_2" isMarkerVisible="true"> + <dc:Bounds height="50.0" width="50.0" x="861.0" y="107.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="886.0" y="162.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_20" bpmnElement="SequenceFlow_20" sourceElement="_BPMNShape_ScriptTask_47" targetElement="_BPMNShape_ExclusiveGateway_99"> + <di:waypoint xsi:type="dc:Point" x="818.0" y="133.0"/> + <di:waypoint xsi:type="dc:Point" x="839.0" y="133.0"/> + <di:waypoint xsi:type="dc:Point" x="839.0" y="132.0"/> + <di:waypoint xsi:type="dc:Point" x="861.0" y="132.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="839.0" y="132.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_21" bpmnElement="SequenceFlow_26" sourceElement="_BPMNShape_ExclusiveGateway_99" targetElement="_BPMNShape_ScriptTask_158"> + <di:waypoint xsi:type="dc:Point" x="886.0" y="157.0"/> + <di:waypoint xsi:type="dc:Point" x="887.0" y="213.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="38.0" width="126.0" x="899.0" y="162.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_27" bpmnElement="SequenceFlow_27" sourceElement="_BPMNShape_ExclusiveGateway_99" targetElement="_BPMNShape_ScriptTask_115"> + <di:waypoint xsi:type="dc:Point" x="911.0" y="132.0"/> + <di:waypoint xsi:type="dc:Point" x="953.0" y="132.0"/> + <di:waypoint xsi:type="dc:Point" x="1045.0" y="132.0"/> + <di:waypoint xsi:type="dc:Point" x="1045.0" y="104.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="959.0" y="132.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_28" bpmnElement="SequenceFlow_28" sourceElement="_BPMNShape_ExclusiveGateway_50" targetElement="_BPMNShape_ScriptTask_158"> + <di:waypoint xsi:type="dc:Point" x="680.0" y="255.0"/> + <di:waypoint xsi:type="dc:Point" x="758.0" y="255.0"/> + <di:waypoint xsi:type="dc:Point" x="758.0" y="253.0"/> + <di:waypoint xsi:type="dc:Point" x="837.0" y="253.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="38.0" width="170.0" x="669.0" y="260.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_EndEvent_161" bpmnElement="EndEvent_8"> + <dc:Bounds height="36.0" width="36.0" x="987.0" y="235.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_29" bpmnElement="SequenceFlow_29" sourceElement="_BPMNShape_ScriptTask_158" targetElement="_BPMNShape_EndEvent_161"> + <di:waypoint xsi:type="dc:Point" x="937.0" y="253.0"/> + <di:waypoint xsi:type="dc:Point" x="987.0" y="253.0"/> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_ExclusiveGateway_100" bpmnElement="ExclusiveGateway_4" isMarkerVisible="true"> + <dc:Bounds height="50.0" width="50.0" x="863.0" y="403.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="888.0" y="458.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_31" bpmnElement="SequenceFlow_31" sourceElement="_BPMNShape_ScriptTask_48" targetElement="_BPMNShape_ExclusiveGateway_100"> + <di:waypoint xsi:type="dc:Point" x="795.0" y="431.0"/> + <di:waypoint xsi:type="dc:Point" x="822.0" y="431.0"/> + <di:waypoint xsi:type="dc:Point" x="822.0" y="428.0"/> + <di:waypoint xsi:type="dc:Point" x="863.0" y="428.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="817.0" y="431.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_33" bpmnElement="SequenceFlow_33" sourceElement="_BPMNShape_ExclusiveGateway_100" targetElement="_BPMNShape_ScriptTask_158"> + <di:waypoint xsi:type="dc:Point" x="888.0" y="403.0"/> + <di:waypoint xsi:type="dc:Point" x="888.0" y="348.0"/> + <di:waypoint xsi:type="dc:Point" x="887.0" y="348.0"/> + <di:waypoint xsi:type="dc:Point" x="887.0" y="293.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="22.0" width="122.0" x="889.0" y="344.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_159" bpmnElement="ScriptTask_8"> + <dc:Bounds height="80.0" width="100.0" x="996.0" y="389.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_34" bpmnElement="SequenceFlow_34" sourceElement="_BPMNShape_ExclusiveGateway_100" targetElement="_BPMNShape_ScriptTask_159"> + <di:waypoint xsi:type="dc:Point" x="913.0" y="428.0"/> + <di:waypoint xsi:type="dc:Point" x="954.0" y="428.0"/> + <di:waypoint xsi:type="dc:Point" x="954.0" y="429.0"/> + <di:waypoint xsi:type="dc:Point" x="996.0" y="429.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="955.0" y="429.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_35" bpmnElement="SequenceFlow_35" sourceElement="_BPMNShape_ScriptTask_159" targetElement="_BPMNShape_ExclusiveGateway_52"> + <di:waypoint xsi:type="dc:Point" x="1096.0" y="429.0"/> + <di:waypoint xsi:type="dc:Point" x="1108.0" y="429.0"/> + <di:waypoint xsi:type="dc:Point" x="1145.0" y="429.0"/> + <di:waypoint xsi:type="dc:Point" x="1145.0" y="280.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="1142.0" y="379.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_160" bpmnElement="QueryAAIForGenericVnf"> + <dc:Bounds height="80.0" width="100.0" x="336.0" y="216.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_38" bpmnElement="SequenceFlow_38" sourceElement="_BPMNShape_ScriptTask_22" targetElement="_BPMNShape_ScriptTask_160"> + <di:waypoint xsi:type="dc:Point" x="304.0" y="256.0"/> + <di:waypoint xsi:type="dc:Point" x="336.0" y="256.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="324.0" y="256.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_39" bpmnElement="SequenceFlow_39" sourceElement="_BPMNShape_ScriptTask_160" targetElement="_BPMNShape_ExclusiveGateway_86"> + <di:waypoint xsi:type="dc:Point" x="436.0" y="256.0"/> + <di:waypoint xsi:type="dc:Point" x="452.0" y="256.0"/> + <di:waypoint xsi:type="dc:Point" x="452.0" y="254.0"/> + <di:waypoint xsi:type="dc:Point" x="468.0" y="254.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="449.0" y="255.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_161" bpmnElement="CreateVfModuleFailure"> + <dc:Bounds height="80.0" width="100.0" x="1192.0" y="324.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_2" bpmnElement="SequenceFlow_2" sourceElement="_BPMNShape_ScriptTask_161" targetElement="_BPMNShape_EndEvent_120"> + <di:waypoint xsi:type="dc:Point" x="1242.0" y="404.0"/> + <di:waypoint xsi:type="dc:Point" x="1242.0" y="454.0"/> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_3" bpmnElement="SequenceFlow_5" sourceElement="_BPMNShape_ExclusiveGateway_54" targetElement="_BPMNShape_ScriptTask_161"> + <di:waypoint xsi:type="dc:Point" x="1241.0" y="280.0"/> + <di:waypoint xsi:type="dc:Point" x="1241.0" y="302.0"/> + <di:waypoint xsi:type="dc:Point" x="1242.0" y="302.0"/> + <di:waypoint xsi:type="dc:Point" x="1242.0" y="324.0"/> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_6" bpmnElement="SequenceFlow_8" sourceElement="_BPMNShape_ExclusiveGateway_52" targetElement="_BPMNShape_ExclusiveGateway_54"> + <di:waypoint xsi:type="dc:Point" x="1170.0" y="255.0"/> + <di:waypoint xsi:type="dc:Point" x="1216.0" y="255.0"/> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_EndEvent_164" bpmnElement="EndEvent_1"> + <dc:Bounds height="36.0" width="36.0" x="1316.0" y="237.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_10" bpmnElement="SequenceFlow_10" sourceElement="_BPMNShape_ExclusiveGateway_54" targetElement="_BPMNShape_EndEvent_164"> + <di:waypoint xsi:type="dc:Point" x="1266.0" y="255.0"/> + <di:waypoint xsi:type="dc:Point" x="1316.0" y="255.0"/> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_ExclusiveGateway_225" bpmnElement="ExclusiveGateway_6" isMarkerVisible="true"> + <dc:Bounds height="50.0" width="50.0" x="630.0" y="38.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="22.0" width="100.0" x="617.0" y="18.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_9" bpmnElement="SequenceFlow_9" sourceElement="_BPMNShape_ExclusiveGateway_225" targetElement="_BPMNShape_ScriptTask_47"> + <di:waypoint xsi:type="dc:Point" x="680.0" y="64.0"/> + <di:waypoint xsi:type="dc:Point" x="699.0" y="64.0"/> + <di:waypoint xsi:type="dc:Point" x="699.0" y="133.0"/> + <di:waypoint xsi:type="dc:Point" x="718.0" y="133.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="22.0" width="22.0" x="669.0" y="93.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_11" bpmnElement="SequenceFlow_11" sourceElement="_BPMNShape_ExclusiveGateway_225" targetElement="_BPMNShape_ScriptTask_162"> + <di:waypoint xsi:type="dc:Point" x="680.0" y="63.0"/> + <di:waypoint xsi:type="dc:Point" x="702.0" y="63.0"/> + <di:waypoint xsi:type="dc:Point" x="702.0" y="40.0"/> + <di:waypoint xsi:type="dc:Point" x="724.0" y="40.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="22.0" width="29.0" x="688.0" y="54.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_ExclusiveGateway_226" bpmnElement="ExclusiveGateway_8" isMarkerVisible="true"> + <dc:Bounds height="50.0" width="50.0" x="863.0" y="14.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="888.0" y="69.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_162" bpmnElement="ScriptTask_1"> + <dc:Bounds height="80.0" width="100.0" x="724.0" y="0.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_4" bpmnElement="SequenceFlow_3" sourceElement="_BPMNShape_ScriptTask_162" targetElement="_BPMNShape_ExclusiveGateway_226"> + <di:waypoint xsi:type="dc:Point" x="824.0" y="40.0"/> + <di:waypoint xsi:type="dc:Point" x="843.0" y="40.0"/> + <di:waypoint xsi:type="dc:Point" x="843.0" y="39.0"/> + <di:waypoint xsi:type="dc:Point" x="863.0" y="39.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="840.0" y="39.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_12" bpmnElement="SequenceFlow_12" sourceElement="_BPMNShape_ExclusiveGateway_226" targetElement="_BPMNShape_ScriptTask_115"> + <di:waypoint xsi:type="dc:Point" x="913.0" y="39.0"/> + <di:waypoint xsi:type="dc:Point" x="954.0" y="39.0"/> + <di:waypoint xsi:type="dc:Point" x="954.0" y="64.0"/> + <di:waypoint xsi:type="dc:Point" x="996.0" y="64.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="951.0" y="52.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_13" bpmnElement="SequenceFlow_13" sourceElement="_BPMNShape_ExclusiveGateway_226" targetElement="_BPMNShape_ExclusiveGateway_99"> + <di:waypoint xsi:type="dc:Point" x="888.0" y="64.0"/> + <di:waypoint xsi:type="dc:Point" x="888.0" y="85.0"/> + <di:waypoint xsi:type="dc:Point" x="886.0" y="85.0"/> + <di:waypoint xsi:type="dc:Point" x="886.0" y="107.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="884.0" y="85.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn2:definitions>
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/CreateAAIVfModuleVolumeGroup.bpmn b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/CreateAAIVfModuleVolumeGroup.bpmn new file mode 100644 index 0000000000..dc94c898c2 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/CreateAAIVfModuleVolumeGroup.bpmn @@ -0,0 +1,224 @@ +<?xml version="1.0" encoding="UTF-8"?> +<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd" id="_Wblj8GyfEeWUWLTvug7ZOg" exporter="camunda modeler" exporterVersion="2.7.0" targetNamespace="http://camunda.org/schema/1.0/bpmn"> + <bpmn2:process id="CreateAAIVfModuleVolumeGroup" name="CreateAAIVfModuleVolumeGroup" isExecutable="true"> + <bpmn2:documentation>This flow expects its incoming request to be in the variable 'CreateAAIVfModuleVolumeGroupRequest'. This flow produces no output.</bpmn2:documentation> + <bpmn2:scriptTask id="QueryAAIForVfModule" name="Query AAI for VF Module" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_38</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_39</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +def cvfvg = new CreateAAIVfModuleVolumeGroup() +cvfvg.getVfModule(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_39" name="" sourceRef="QueryAAIForVfModule" targetRef="ExclusiveGateway_3"/> + <bpmn2:endEvent id="EndEvent_7"> + <bpmn2:incoming>SequenceFlow_18</bpmn2:incoming> + <bpmn2:errorEventDefinition id="_ErrorEventDefinition_68" errorRef="Error_1"/> + </bpmn2:endEvent> + <bpmn2:scriptTask id="AAIQueryFailure" name="Handle AAI Query Failure" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_23</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_18</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +def cvfvg = new CreateAAIVfModuleVolumeGroup() +cvfvg.handleAAIQueryFailure(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_18" name="" sourceRef="AAIQueryFailure" targetRef="EndEvent_7"/> + <bpmn2:endEvent id="EndEvent_2"> + <bpmn2:incoming>SequenceFlow_8</bpmn2:incoming> + <bpmn2:errorEventDefinition id="_ErrorEventDefinition_50" errorRef="Error_1"/> + </bpmn2:endEvent> + <bpmn2:endEvent id="EndEvent_4" name="TheEnd"> + <bpmn2:extensionElements> + <camunda:connector> + <camunda:inputOutput> + <camunda:outputParameter name="CreateCustomerV1Response"><![CDATA[<aetgt:CreateCustomerResponse xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1" xmlns:ns="http://org.openecomp/mso/workflow/schema/v1"> + <ns:GlobalCustomerId>${CCV1_subscriberglobalid}</ns:GlobalCustomerId> + </aetgt:CreateCustomerResponse>]]></camunda:outputParameter> + </camunda:inputOutput> + </camunda:connector> + </bpmn2:extensionElements> + <bpmn2:incoming>SequenceFlow_13</bpmn2:incoming> + </bpmn2:endEvent> + <bpmn2:exclusiveGateway id="ExclusiveGateway_3" default="SequenceFlow_23"> + <bpmn2:incoming>SequenceFlow_39</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_22</bpmn2:outgoing> + <bpmn2:outgoing>SequenceFlow_23</bpmn2:outgoing> + </bpmn2:exclusiveGateway> + <bpmn2:sequenceFlow id="SequenceFlow_22" name="" sourceRef="ExclusiveGateway_3" targetRef="UpdateVfModule"> + <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression">#{execution.getVariable('CAAIVfModVG_getVfModuleResponseCode') == 200}</bpmn2:conditionExpression> + </bpmn2:sequenceFlow> + <bpmn2:sequenceFlow id="SequenceFlow_23" name="AAI Query failure or
VF Module not found" sourceRef="ExclusiveGateway_3" targetRef="AAIQueryFailure"/> + <bpmn2:scriptTask id="HandleUpdateVfModuleFailure" name="Handle Update VF Module Failure" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_4</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_8</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +def cvfvg = new CreateAAIVfModuleVolumeGroup() +cvfvg.handleUpdateVfModuleFailure(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_8" name="" sourceRef="HandleUpdateVfModuleFailure" targetRef="EndEvent_2"/> + <bpmn2:startEvent id="StartEvent_1" name="Start"> + <bpmn2:outgoing>SequenceFlow_2</bpmn2:outgoing> + </bpmn2:startEvent> + <bpmn2:sequenceFlow id="SequenceFlow_2" name="" sourceRef="StartEvent_1" targetRef="ProcessReceivedRequest"/> + <bpmn2:scriptTask id="ProcessReceivedRequest" name="Process Received Request" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_2</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_38</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +def cvfvg = new CreateAAIVfModuleVolumeGroup() +cvfvg.preProcessRequest(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_38" name="" sourceRef="ProcessReceivedRequest" targetRef="QueryAAIForVfModule"/> + <bpmn2:scriptTask id="UpdateVfModule" name="Update VF Module with Volume Group" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_22</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_14</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +def cvfvg = new CreateAAIVfModuleVolumeGroup() +cvfvg.updateVfModule(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_14" name="" sourceRef="UpdateVfModule" targetRef="ExclusiveGateway_1"/> + <bpmn2:exclusiveGateway id="ExclusiveGateway_1" default="SequenceFlow_4"> + <bpmn2:incoming>SequenceFlow_14</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_13</bpmn2:outgoing> + <bpmn2:outgoing>SequenceFlow_4</bpmn2:outgoing> + </bpmn2:exclusiveGateway> + <bpmn2:sequenceFlow id="SequenceFlow_13" sourceRef="ExclusiveGateway_1" targetRef="EndEvent_4"> + <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression">#{execution.getVariable('CAAIVfModVG_updateVfModuleResponseCode') == 200}</bpmn2:conditionExpression> + </bpmn2:sequenceFlow> + <bpmn2:sequenceFlow id="SequenceFlow_4" name="Update VF Module Failure" sourceRef="ExclusiveGateway_1" targetRef="HandleUpdateVfModuleFailure"/> + </bpmn2:process> + <bpmn2:error id="Error_1" errorCode="MSOWorkflowException" name="MSO Workflow Exception"/> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="CreateAAIVfModuleVolumeGroup"> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_37" bpmnElement="StartEvent_1"> + <dc:Bounds height="36.0" width="36.0" x="60.0" y="212.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="22.0" width="34.0" x="61.0" y="253.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_22" bpmnElement="ProcessReceivedRequest"> + <dc:Bounds height="80.0" width="100.0" x="168.0" y="190.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_Task_2" bpmnElement="UpdateVfModule"> + <dc:Bounds height="80.0" width="100.0" x="672.0" y="190.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_EndEvent_92" bpmnElement="EndEvent_4"> + <dc:Bounds height="36.0" width="36.0" x="1016.0" y="212.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="22.0" width="50.0" x="1009.0" y="253.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ExclusiveGateway_54" bpmnElement="ExclusiveGateway_1" isMarkerVisible="true"> + <dc:Bounds height="50.0" width="50.0" x="841.0" y="204.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="866.0" y="259.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_14" bpmnElement="SequenceFlow_13" sourceElement="_BPMNShape_ExclusiveGateway_54" targetElement="_BPMNShape_EndEvent_92"> + <di:waypoint xsi:type="dc:Point" x="891.0" y="229.0"/> + <di:waypoint xsi:type="dc:Point" x="993.0" y="229.0"/> + <di:waypoint xsi:type="dc:Point" x="993.0" y="230.0"/> + <di:waypoint xsi:type="dc:Point" x="1016.0" y="230.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="929.0" y="229.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_EndEvent_120" bpmnElement="EndEvent_2"> + <dc:Bounds height="36.0" width="36.0" x="848.0" y="0.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="866.0" y="41.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ExclusiveGateway_86" bpmnElement="ExclusiveGateway_3" isMarkerVisible="true"> + <dc:Bounds height="50.0" width="50.0" x="493.0" y="204.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="518.0" y="259.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_23" bpmnElement="SequenceFlow_22" sourceElement="_BPMNShape_ExclusiveGateway_86" targetElement="_BPMNShape_Task_2"> + <di:waypoint xsi:type="dc:Point" x="543.0" y="229.0"/> + <di:waypoint xsi:type="dc:Point" x="607.0" y="229.0"/> + <di:waypoint xsi:type="dc:Point" x="607.0" y="230.0"/> + <di:waypoint xsi:type="dc:Point" x="672.0" y="230.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="558.0" y="229.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_155" bpmnElement="AAIQueryFailure"> + <dc:Bounds height="80.0" width="100.0" x="468.0" y="60.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_24" bpmnElement="SequenceFlow_23" sourceElement="_BPMNShape_ExclusiveGateway_86" targetElement="_BPMNShape_ScriptTask_155"> + <di:waypoint xsi:type="dc:Point" x="518.0" y="204.0"/> + <di:waypoint xsi:type="dc:Point" x="518.0" y="140.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="38.0" width="130.0" x="528.0" y="152.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_EndEvent_160" bpmnElement="EndEvent_7"> + <dc:Bounds height="36.0" width="36.0" x="500.0" y="0.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="518.0" y="41.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_18" bpmnElement="SequenceFlow_18" sourceElement="_BPMNShape_ScriptTask_155" targetElement="_BPMNShape_EndEvent_160"> + <di:waypoint xsi:type="dc:Point" x="518.0" y="60.0"/> + <di:waypoint xsi:type="dc:Point" x="518.0" y="36.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="515.0" y="49.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_160" bpmnElement="QueryAAIForVfModule"> + <dc:Bounds height="80.0" width="100.0" x="336.0" y="190.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_38" bpmnElement="SequenceFlow_38" sourceElement="_BPMNShape_ScriptTask_22" targetElement="_BPMNShape_ScriptTask_160"> + <di:waypoint xsi:type="dc:Point" x="268.0" y="230.0"/> + <di:waypoint xsi:type="dc:Point" x="336.0" y="230.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="288.0" y="230.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_39" bpmnElement="SequenceFlow_39" sourceElement="_BPMNShape_ScriptTask_160" targetElement="_BPMNShape_ExclusiveGateway_86"> + <di:waypoint xsi:type="dc:Point" x="436.0" y="230.0"/> + <di:waypoint xsi:type="dc:Point" x="452.0" y="230.0"/> + <di:waypoint xsi:type="dc:Point" x="452.0" y="229.0"/> + <di:waypoint xsi:type="dc:Point" x="493.0" y="229.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="449.0" y="229.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_161" bpmnElement="HandleUpdateVfModuleFailure"> + <dc:Bounds height="80.0" width="100.0" x="816.0" y="60.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_6" bpmnElement="SequenceFlow_8" sourceElement="_BPMNShape_ScriptTask_161" targetElement="_BPMNShape_EndEvent_120"> + <di:waypoint xsi:type="dc:Point" x="866.0" y="60.0"/> + <di:waypoint xsi:type="dc:Point" x="866.0" y="36.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="863.0" y="51.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_13" bpmnElement="SequenceFlow_14" sourceElement="_BPMNShape_Task_2" targetElement="_BPMNShape_ExclusiveGateway_54"> + <di:waypoint xsi:type="dc:Point" x="772.0" y="230.0"/> + <di:waypoint xsi:type="dc:Point" x="797.0" y="230.0"/> + <di:waypoint xsi:type="dc:Point" x="797.0" y="229.0"/> + <di:waypoint xsi:type="dc:Point" x="841.0" y="229.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="801.0" y="229.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_3" bpmnElement="SequenceFlow_4" sourceElement="_BPMNShape_ExclusiveGateway_54" targetElement="_BPMNShape_ScriptTask_161"> + <di:waypoint xsi:type="dc:Point" x="866.0" y="204.0"/> + <di:waypoint xsi:type="dc:Point" x="865.0" y="172.0"/> + <di:waypoint xsi:type="dc:Point" x="867.0" y="172.0"/> + <di:waypoint xsi:type="dc:Point" x="867.0" y="140.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="22.0" width="157.0" x="883.0" y="158.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_2" bpmnElement="SequenceFlow_2" sourceElement="_BPMNShape_StartEvent_37" targetElement="_BPMNShape_ScriptTask_22"> + <di:waypoint xsi:type="dc:Point" x="96.0" y="230.0"/> + <di:waypoint xsi:type="dc:Point" x="168.0" y="230.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="148.0" y="230.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn2:definitions>
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/DeleteAAIVfModule.bpmn b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/DeleteAAIVfModule.bpmn new file mode 100644 index 0000000000..0fce6d846f --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/DeleteAAIVfModule.bpmn @@ -0,0 +1,482 @@ +<?xml version="1.0" encoding="UTF-8"?> +<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd" id="_Wblj8GyfEeWUWLTvug7ZOg" exporter="camunda modeler" exporterVersion="2.7.0" targetNamespace="http://camunda.org/schema/1.0/bpmn"> + <bpmn2:process id="DeleteAAIVfModule" name="DeleteAAIVfModule" isExecutable="true"> + <bpmn2:exclusiveGateway id="ExclusiveGateway_5" default="SequenceFlow_8"> + <bpmn2:incoming>SequenceFlow_24</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_6</bpmn2:outgoing> + <bpmn2:outgoing>SequenceFlow_8</bpmn2:outgoing> + </bpmn2:exclusiveGateway> + <bpmn2:sequenceFlow id="SequenceFlow_6" name="" sourceRef="ExclusiveGateway_5" targetRef="DeleteVfModule"> + <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression"><![CDATA[#{execution.getVariable("DAAIVfMod_moduleExists") == true && (execution.getVariable("DAAIVfMod_isBaseModule") == false || (execution.getVariable("DAAIVfMod_isBaseModule") == true && execution.getVariable("DAAIVfMod_isLastModule") == true ))}]]></bpmn2:conditionExpression> + </bpmn2:sequenceFlow> + <bpmn2:exclusiveGateway id="ExclusiveGateway_3" default="SequenceFlow_22"> + <bpmn2:incoming>SequenceFlow_39</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_22</bpmn2:outgoing> + <bpmn2:outgoing>SequenceFlow_23</bpmn2:outgoing> + </bpmn2:exclusiveGateway> + <bpmn2:sequenceFlow id="SequenceFlow_22" name="" sourceRef="ExclusiveGateway_3" targetRef="ParseForAddonModule"/> + <bpmn2:sequenceFlow id="SequenceFlow_23" name="" sourceRef="ExclusiveGateway_3" targetRef="AAIQueryFailure"> + <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression"><![CDATA[#{execution.getVariable("DAAIVfMod_queryGenericVnfResponseCode") != 200}]]></bpmn2:conditionExpression> + </bpmn2:sequenceFlow> + <bpmn2:scriptTask id="AAIQueryFailure" name="AAI Query Failure" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_23</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_18</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +def dvm = new DeleteAAIVfModule() +dvm.handleAAIQueryFailure(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_18" name="" sourceRef="AAIQueryFailure" targetRef="EndEvent_7"/> + <bpmn2:endEvent id="EndEvent_7"> + <bpmn2:incoming>SequenceFlow_18</bpmn2:incoming> + <bpmn2:errorEventDefinition id="_ErrorEventDefinition_68" errorRef="Error_1"/> + </bpmn2:endEvent> + <bpmn2:scriptTask id="ParseForAddonModule" name="Parse For Vf Module" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_22</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_24</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +def dvm = new DeleteAAIVfModule() +dvm.parseForVfModule(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_24" name="" sourceRef="ParseForAddonModule" targetRef="ExclusiveGateway_5"/> + <bpmn2:scriptTask id="DeleteVfModule" name="Delete Vf Module" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_6</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_20</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +def dvm = new DeleteAAIVfModule() +dvm.deleteVfModule(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_20" name="" sourceRef="DeleteVfModule" targetRef="ExclusiveGateway_2"/> + <bpmn2:exclusiveGateway id="ExclusiveGateway_2" default="SequenceFlow_26"> + <bpmn2:incoming>SequenceFlow_20</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_26</bpmn2:outgoing> + <bpmn2:outgoing>SequenceFlow_27</bpmn2:outgoing> + <bpmn2:outgoing>SequenceFlow_11</bpmn2:outgoing> + </bpmn2:exclusiveGateway> + <bpmn2:sequenceFlow id="SequenceFlow_26" name="Delete Vf Module
Failure" sourceRef="ExclusiveGateway_2" targetRef="DeleteVfModuleFailure"/> + <bpmn2:sequenceFlow id="SequenceFlow_27" name="" sourceRef="ExclusiveGateway_2" targetRef="ExclusiveGateway_6"> + <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression"><![CDATA[#{(execution.getVariable("DAAIVfMod_deleteVfModuleResponseCode") == 200 || execution.getVariable("DAAIVfMod_deleteVfModuleResponseCode") == 204) && execution.getVariable("DAAIVfMod_isLastModule") == true}]]></bpmn2:conditionExpression> + </bpmn2:sequenceFlow> + <bpmn2:scriptTask id="DeleteVfModuleFailure" name="Delete Vf Module Failure" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_26</bpmn2:incoming> + <bpmn2:incoming>SequenceFlow_8</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_29</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +def dvm = new DeleteAAIVfModule() +dvm.handleDeleteVfModuleFailure(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_29" name="" sourceRef="DeleteVfModuleFailure" targetRef="EndEvent_8"/> + <bpmn2:scriptTask id="QueryAAIForGenericVnf" name="Query AAI for
Generic Vnf" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_38</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_39</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +def dvm = new DeleteAAIVfModule() +dvm.queryAAIForGenericVnf(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_39" name="" sourceRef="QueryAAIForGenericVnf" targetRef="ExclusiveGateway_3"/> + <bpmn2:sequenceFlow id="SequenceFlow_8" name="Vf Module
Does Not Exist or
Base Module is Not
the Last Vf Module" sourceRef="ExclusiveGateway_5" targetRef="DeleteVfModuleFailure"/> + <bpmn2:endEvent id="EndEvent_8"> + <bpmn2:incoming>SequenceFlow_29</bpmn2:incoming> + <bpmn2:errorEventDefinition id="_ErrorEventDefinition_69" errorRef="Error_1"/> + </bpmn2:endEvent> + <bpmn2:sequenceFlow id="SequenceFlow_11" name="" sourceRef="ExclusiveGateway_2" targetRef="ExclusiveGateway_1"> + <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression"><![CDATA[#{(execution.getVariable("DAAIVfMod_deleteVfModuleResponseCode") == 200 || execution.getVariable("DAAIVfMod_deleteVfModuleResponseCode") == 204) && execution.getVariable("DAAIVfMod_isLastModule") == false} ]]></bpmn2:conditionExpression> + </bpmn2:sequenceFlow> + <bpmn2:scriptTask id="QueryAAIForGenericVnf1" name="Query AAI for Generif VNF 1" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_3</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_9</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +def dvm = new DeleteAAIVfModule() +dvm.queryAAIForGenericVnf(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_9" name="" sourceRef="QueryAAIForGenericVnf1" targetRef="ExclusiveGateway_4"/> + <bpmn2:scriptTask id="DeleteGenericVnfFailure" name="Delete Generic Vnf Failure" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_5</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_2</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +def dvm = new DeleteAAIVfModule() +dvm.handleDeleteGenericVnfFailure(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_2" name="" sourceRef="DeleteGenericVnfFailure" targetRef="EndEvent_2"/> + <bpmn2:endEvent id="EndEvent_2"> + <bpmn2:incoming>SequenceFlow_2</bpmn2:incoming> + <bpmn2:errorEventDefinition id="_ErrorEventDefinition_50" errorRef="Error_1"/> + </bpmn2:endEvent> + <bpmn2:exclusiveGateway id="ExclusiveGateway_1" default="SequenceFlow_5"> + <bpmn2:incoming>SequenceFlow_11</bpmn2:incoming> + <bpmn2:incoming>SequenceFlow_4</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_5</bpmn2:outgoing> + <bpmn2:outgoing>SequenceFlow_7</bpmn2:outgoing> + </bpmn2:exclusiveGateway> + <bpmn2:sequenceFlow id="SequenceFlow_5" name="" sourceRef="ExclusiveGateway_1" targetRef="DeleteGenericVnfFailure"/> + <bpmn2:sequenceFlow id="SequenceFlow_7" name="" sourceRef="ExclusiveGateway_1" targetRef="EndEvent_1"> + <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression"><![CDATA[#{((execution.getVariable("DAAIVfMod_deleteVfModuleResponseCode") == 200 || execution.getVariable("DAAIVfMod_deleteVfModuleResponseCode") == 204) && execution.getVariable("DAAIVfMod_isLastModule") == false) || (execution.getVariable("DAAIVfMod_deleteGenericVnfResponseCode") == 200 || execution.getVariable("DAAIVfMod_deleteGenericVnfResponseCode") == 204)}]]></bpmn2:conditionExpression> + </bpmn2:sequenceFlow> + <bpmn2:endEvent id="EndEvent_1"> + <bpmn2:incoming>SequenceFlow_7</bpmn2:incoming> + <bpmn2:incoming>SequenceFlow_15</bpmn2:incoming> + </bpmn2:endEvent> + <bpmn2:scriptTask id="AAIQueryFailure1" name="AAI Query Failure 1" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_10</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_12</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +def dvm = new DeleteAAIVfModule() +dvm.handleAAIQueryFailure(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_12" name="" sourceRef="AAIQueryFailure1" targetRef="EndEvent_3"/> + <bpmn2:endEvent id="EndEvent_3"> + <bpmn2:incoming>SequenceFlow_12</bpmn2:incoming> + <bpmn2:errorEventDefinition id="_ErrorEventDefinition_70" errorRef="Error_1"/> + </bpmn2:endEvent> + <bpmn2:scriptTask id="DeleteGenericVnf" name="Delete Generic Vnf" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_14</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_4</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +def dvm = new DeleteAAIVfModule() +dvm.deleteGenericVnf(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_4" name="" sourceRef="DeleteGenericVnf" targetRef="ExclusiveGateway_1"/> + <bpmn2:scriptTask id="ParseForGenericVNFResourceVersion" name="Parse for Generic VNF Resource Version" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_13</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_14</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +def dvm = new DeleteAAIVfModule() +dvm.parseForResourceVersion(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_14" name="" sourceRef="ParseForGenericVNFResourceVersion" targetRef="DeleteGenericVnf"/> + <bpmn2:exclusiveGateway id="ExclusiveGateway_4" default="SequenceFlow_13"> + <bpmn2:incoming>SequenceFlow_9</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_10</bpmn2:outgoing> + <bpmn2:outgoing>SequenceFlow_13</bpmn2:outgoing> + </bpmn2:exclusiveGateway> + <bpmn2:sequenceFlow id="SequenceFlow_10" name="" sourceRef="ExclusiveGateway_4" targetRef="AAIQueryFailure1"> + <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression"><![CDATA[#{execution.getVariable("DAAIVfMod_queryGenericVnfResponseCode") != 200}]]></bpmn2:conditionExpression> + </bpmn2:sequenceFlow> + <bpmn2:sequenceFlow id="SequenceFlow_13" name="" sourceRef="ExclusiveGateway_4" targetRef="ParseForGenericVNFResourceVersion"/> + <bpmn2:startEvent id="StartEvent_1"> + <bpmn2:outgoing>SequenceFlow_1</bpmn2:outgoing> + <bpmn2:messageEventDefinition id="_MessageEventDefinition_6" messageRef="Message_1"/> + </bpmn2:startEvent> + <bpmn2:sequenceFlow id="SequenceFlow_1" name="" sourceRef="StartEvent_1" targetRef="InitializeVariables"/> + <bpmn2:scriptTask id="InitializeVariables" name="Initialize Variables" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_1</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_38</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +def dvm = new DeleteAAIVfModule() +dvm.preProcessRequest(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_38" name="" sourceRef="InitializeVariables" targetRef="QueryAAIForGenericVnf"/> + <bpmn2:exclusiveGateway id="ExclusiveGateway_6" name="Is VID Request?" default="SequenceFlow_3"> + <bpmn2:incoming>SequenceFlow_27</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_3</bpmn2:outgoing> + <bpmn2:outgoing>SequenceFlow_15</bpmn2:outgoing> + </bpmn2:exclusiveGateway> + <bpmn2:sequenceFlow id="SequenceFlow_3" name="no" sourceRef="ExclusiveGateway_6" targetRef="QueryAAIForGenericVnf1"/> + <bpmn2:sequenceFlow id="SequenceFlow_15" name="yes" sourceRef="ExclusiveGateway_6" targetRef="EndEvent_1"> + <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression"><![CDATA[#{execution.getVariable("isVidRequest") =="true"}]]></bpmn2:conditionExpression> + </bpmn2:sequenceFlow> + </bpmn2:process> + <bpmn2:error id="Error_1" errorCode="MSOWorkflowException" name="MSO Workflow Exception"/> + <bpmn2:message id="Message_1" name="DeleteAAIVfModuleRequest"/> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="DeleteAAIVfModule"> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_37" bpmnElement="StartEvent_1"> + <dc:Bounds height="36.0" width="36.0" x="59.0" y="200.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="77.0" y="241.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_22" bpmnElement="InitializeVariables"> + <dc:Bounds height="80.0" width="100.0" x="192.0" y="178.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_1" bpmnElement="SequenceFlow_1" sourceElement="_BPMNShape_StartEvent_37" targetElement="_BPMNShape_ScriptTask_22"> + <di:waypoint xsi:type="dc:Point" x="95.0" y="218.0"/> + <di:waypoint xsi:type="dc:Point" x="192.0" y="218.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="117.0" y="218.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_Task_2" bpmnElement="ParseForAddonModule"> + <dc:Bounds height="80.0" width="100.0" x="518.0" y="79.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ExclusiveGateway_50" bpmnElement="ExclusiveGateway_5" isMarkerVisible="true"> + <dc:Bounds height="50.0" width="50.0" x="630.0" y="192.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="655.0" y="247.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_47" bpmnElement="DeleteVfModule"> + <dc:Bounds height="80.0" width="100.0" x="695.0" y="0.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_7" bpmnElement="SequenceFlow_6" sourceElement="_BPMNShape_ExclusiveGateway_50" targetElement="_BPMNShape_ScriptTask_47"> + <di:waypoint xsi:type="dc:Point" x="655.0" y="192.0"/> + <di:waypoint xsi:type="dc:Point" x="655.0" y="40.0"/> + <di:waypoint xsi:type="dc:Point" x="695.0" y="40.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="579.0" y="73.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_ExclusiveGateway_54" bpmnElement="ExclusiveGateway_1" isMarkerVisible="true"> + <dc:Bounds height="50.0" width="50.0" x="1681.0" y="297.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="1706.0" y="352.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_EndEvent_120" bpmnElement="EndEvent_2"> + <dc:Bounds height="36.0" width="36.0" x="1689.0" y="564.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="1707.0" y="605.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_115" bpmnElement="DeleteGenericVnf"> + <dc:Bounds height="80.0" width="100.0" x="1582.0" y="0.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ExclusiveGateway_86" bpmnElement="ExclusiveGateway_3" isMarkerVisible="true"> + <dc:Bounds height="50.0" width="50.0" x="468.0" y="191.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="493.0" y="246.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_23" bpmnElement="SequenceFlow_22" sourceElement="_BPMNShape_ExclusiveGateway_86" targetElement="_BPMNShape_Task_2"> + <di:waypoint xsi:type="dc:Point" x="493.0" y="191.0"/> + <di:waypoint xsi:type="dc:Point" x="493.0" y="120.0"/> + <di:waypoint xsi:type="dc:Point" x="518.0" y="120.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="490.0" y="154.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_155" bpmnElement="AAIQueryFailure"> + <dc:Bounds height="80.0" width="100.0" x="518.0" y="297.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_24" bpmnElement="SequenceFlow_23" sourceElement="_BPMNShape_ExclusiveGateway_86" targetElement="_BPMNShape_ScriptTask_155"> + <di:waypoint xsi:type="dc:Point" x="493.0" y="241.0"/> + <di:waypoint xsi:type="dc:Point" x="493.0" y="259.0"/> + <di:waypoint xsi:type="dc:Point" x="568.0" y="259.0"/> + <di:waypoint xsi:type="dc:Point" x="568.0" y="297.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="547.0" y="259.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_25" bpmnElement="SequenceFlow_24" sourceElement="_BPMNShape_Task_2" targetElement="_BPMNShape_ExclusiveGateway_50"> + <di:waypoint xsi:type="dc:Point" x="568.0" y="159.0"/> + <di:waypoint xsi:type="dc:Point" x="568.0" y="217.0"/> + <di:waypoint xsi:type="dc:Point" x="630.0" y="217.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="565.0" y="212.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_EndEvent_160" bpmnElement="EndEvent_7"> + <dc:Bounds height="36.0" width="36.0" x="550.0" y="416.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="568.0" y="457.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_18" bpmnElement="SequenceFlow_18" sourceElement="_BPMNShape_ScriptTask_155" targetElement="_BPMNShape_EndEvent_160"> + <di:waypoint xsi:type="dc:Point" x="568.0" y="377.0"/> + <di:waypoint xsi:type="dc:Point" x="568.0" y="416.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="565.0" y="388.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_158" bpmnElement="DeleteVfModuleFailure"> + <dc:Bounds height="80.0" width="100.0" x="837.0" y="175.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ExclusiveGateway_99" bpmnElement="ExclusiveGateway_2" isMarkerVisible="true"> + <dc:Bounds height="50.0" width="50.0" x="861.0" y="14.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="886.0" y="69.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_20" bpmnElement="SequenceFlow_20" sourceElement="_BPMNShape_ScriptTask_47" targetElement="_BPMNShape_ExclusiveGateway_99"> + <di:waypoint xsi:type="dc:Point" x="795.0" y="40.0"/> + <di:waypoint xsi:type="dc:Point" x="861.0" y="39.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="817.0" y="40.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_21" bpmnElement="SequenceFlow_26" sourceElement="_BPMNShape_ExclusiveGateway_99" targetElement="_BPMNShape_ScriptTask_158"> + <di:waypoint xsi:type="dc:Point" x="886.0" y="64.0"/> + <di:waypoint xsi:type="dc:Point" x="886.0" y="98.0"/> + <di:waypoint xsi:type="dc:Point" x="887.0" y="98.0"/> + <di:waypoint xsi:type="dc:Point" x="887.0" y="175.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="38.0" width="126.0" x="887.0" y="100.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_27" bpmnElement="SequenceFlow_27" sourceElement="_BPMNShape_ExclusiveGateway_99" targetElement="_BPMNShape_ExclusiveGateway_226"> + <di:waypoint xsi:type="dc:Point" x="911.0" y="39.0"/> + <di:waypoint xsi:type="dc:Point" x="1068.0" y="39.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="959.0" y="39.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_EndEvent_161" bpmnElement="EndEvent_8"> + <dc:Bounds height="36.0" width="36.0" x="869.0" y="299.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="887.0" y="340.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_29" bpmnElement="SequenceFlow_29" sourceElement="_BPMNShape_ScriptTask_158" targetElement="_BPMNShape_EndEvent_161"> + <di:waypoint xsi:type="dc:Point" x="887.0" y="255.0"/> + <di:waypoint xsi:type="dc:Point" x="887.0" y="299.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="884.0" y="280.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_160" bpmnElement="QueryAAIForGenericVnf"> + <dc:Bounds height="80.0" width="100.0" x="336.0" y="178.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_38" bpmnElement="SequenceFlow_38" sourceElement="_BPMNShape_ScriptTask_22" targetElement="_BPMNShape_ScriptTask_160"> + <di:waypoint xsi:type="dc:Point" x="292.0" y="218.0"/> + <di:waypoint xsi:type="dc:Point" x="336.0" y="218.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="299.0" y="218.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_39" bpmnElement="SequenceFlow_39" sourceElement="_BPMNShape_ScriptTask_160" targetElement="_BPMNShape_ExclusiveGateway_86"> + <di:waypoint xsi:type="dc:Point" x="436.0" y="218.0"/> + <di:waypoint xsi:type="dc:Point" x="452.0" y="218.0"/> + <di:waypoint xsi:type="dc:Point" x="452.0" y="216.0"/> + <di:waypoint xsi:type="dc:Point" x="468.0" y="216.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="449.0" y="217.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_161" bpmnElement="DeleteGenericVnfFailure"> + <dc:Bounds height="80.0" width="100.0" x="1656.0" y="432.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_2" bpmnElement="SequenceFlow_2" sourceElement="_BPMNShape_ScriptTask_161" targetElement="_BPMNShape_EndEvent_120"> + <di:waypoint xsi:type="dc:Point" x="1706.0" y="512.0"/> + <di:waypoint xsi:type="dc:Point" x="1707.0" y="564.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="1703.0" y="515.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_3" bpmnElement="SequenceFlow_5" sourceElement="_BPMNShape_ExclusiveGateway_54" targetElement="_BPMNShape_ScriptTask_161"> + <di:waypoint xsi:type="dc:Point" x="1706.0" y="347.0"/> + <di:waypoint xsi:type="dc:Point" x="1706.0" y="432.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="1703.0" y="390.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_6" bpmnElement="SequenceFlow_8" sourceElement="_BPMNShape_ExclusiveGateway_50" targetElement="_BPMNShape_ScriptTask_158"> + <di:waypoint xsi:type="dc:Point" x="680.0" y="217.0"/> + <di:waypoint xsi:type="dc:Point" x="758.0" y="217.0"/> + <di:waypoint xsi:type="dc:Point" x="758.0" y="215.0"/> + <di:waypoint xsi:type="dc:Point" x="837.0" y="215.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="38.0" width="94.0" x="708.0" y="231.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_11" bpmnElement="SequenceFlow_11" sourceElement="_BPMNShape_ExclusiveGateway_99" targetElement="_BPMNShape_ExclusiveGateway_54"> + <di:waypoint xsi:type="dc:Point" x="911.0" y="39.0"/> + <di:waypoint xsi:type="dc:Point" x="1008.0" y="39.0"/> + <di:waypoint xsi:type="dc:Point" x="1008.0" y="140.0"/> + <di:waypoint xsi:type="dc:Point" x="1008.0" y="322.0"/> + <di:waypoint xsi:type="dc:Point" x="1681.0" y="322.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="1005.0" y="197.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_5" bpmnElement="SequenceFlow_4" sourceElement="_BPMNShape_ScriptTask_115" targetElement="_BPMNShape_ExclusiveGateway_54"> + <di:waypoint xsi:type="dc:Point" x="1632.0" y="80.0"/> + <di:waypoint xsi:type="dc:Point" x="1632.0" y="322.0"/> + <di:waypoint xsi:type="dc:Point" x="1681.0" y="322.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="1629.0" y="187.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_EndEvent_162" bpmnElement="EndEvent_1"> + <dc:Bounds height="36.0" width="36.0" x="1806.0" y="305.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="1824.0" y="346.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_8" bpmnElement="SequenceFlow_7" sourceElement="_BPMNShape_ExclusiveGateway_54" targetElement="_BPMNShape_EndEvent_162"> + <di:waypoint xsi:type="dc:Point" x="1731.0" y="322.0"/> + <di:waypoint xsi:type="dc:Point" x="1806.0" y="323.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="1753.0" y="322.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_242" bpmnElement="QueryAAIForGenericVnf1"> + <dc:Bounds height="80.0" width="100.0" x="1166.0" y="0.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ExclusiveGateway_213" bpmnElement="ExclusiveGateway_4" isMarkerVisible="true"> + <dc:Bounds height="50.0" width="50.0" x="1325.0" y="15.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="1350.0" y="70.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_9" bpmnElement="SequenceFlow_9" sourceElement="_BPMNShape_ScriptTask_242" targetElement="_BPMNShape_ExclusiveGateway_213"> + <di:waypoint xsi:type="dc:Point" x="1266.0" y="40.0"/> + <di:waypoint xsi:type="dc:Point" x="1325.0" y="40.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="1292.0" y="40.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_243" bpmnElement="AAIQueryFailure1"> + <dc:Bounds height="80.0" width="100.0" x="1300.0" y="117.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_244" bpmnElement="ParseForGenericVNFResourceVersion"> + <dc:Bounds height="80.0" width="100.0" x="1440.0" y="0.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_EndEvent_181" bpmnElement="EndEvent_3"> + <dc:Bounds height="36.0" width="36.0" x="1332.0" y="244.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="1350.0" y="285.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_10" bpmnElement="SequenceFlow_10" sourceElement="_BPMNShape_ExclusiveGateway_213" targetElement="_BPMNShape_ScriptTask_243"> + <di:waypoint xsi:type="dc:Point" x="1350.0" y="65.0"/> + <di:waypoint xsi:type="dc:Point" x="1349.0" y="90.0"/> + <di:waypoint xsi:type="dc:Point" x="1350.0" y="90.0"/> + <di:waypoint xsi:type="dc:Point" x="1350.0" y="117.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="1347.0" y="95.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_12" bpmnElement="SequenceFlow_12" sourceElement="_BPMNShape_ScriptTask_243" targetElement="_BPMNShape_EndEvent_181"> + <di:waypoint xsi:type="dc:Point" x="1350.0" y="197.0"/> + <di:waypoint xsi:type="dc:Point" x="1350.0" y="244.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="1347.0" y="226.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_13" bpmnElement="SequenceFlow_13" sourceElement="_BPMNShape_ExclusiveGateway_213" targetElement="_BPMNShape_ScriptTask_244"> + <di:waypoint xsi:type="dc:Point" x="1375.0" y="40.0"/> + <di:waypoint xsi:type="dc:Point" x="1440.0" y="40.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="1394.0" y="40.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_14" bpmnElement="SequenceFlow_14" sourceElement="_BPMNShape_ScriptTask_244" targetElement="_BPMNShape_ScriptTask_115"> + <di:waypoint xsi:type="dc:Point" x="1540.0" y="40.0"/> + <di:waypoint xsi:type="dc:Point" x="1582.0" y="40.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="1565.0" y="40.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_ExclusiveGateway_226" bpmnElement="ExclusiveGateway_6" isMarkerVisible="true"> + <dc:Bounds height="50.0" width="50.0" x="1068.0" y="14.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="22.0" width="100.0" x="1044.0" y="-6.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_4" bpmnElement="SequenceFlow_3" sourceElement="_BPMNShape_ExclusiveGateway_226" targetElement="_BPMNShape_ScriptTask_242"> + <di:waypoint xsi:type="dc:Point" x="1118.0" y="39.0"/> + <di:waypoint xsi:type="dc:Point" x="1142.0" y="39.0"/> + <di:waypoint xsi:type="dc:Point" x="1142.0" y="40.0"/> + <di:waypoint xsi:type="dc:Point" x="1166.0" y="40.0"/> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_15" bpmnElement="SequenceFlow_15" sourceElement="_BPMNShape_ExclusiveGateway_226" targetElement="_BPMNShape_EndEvent_162"> + <di:waypoint xsi:type="dc:Point" x="1093.0" y="64.0"/> + <di:waypoint xsi:type="dc:Point" x="1093.0" y="289.0"/> + <di:waypoint xsi:type="dc:Point" x="1823.0" y="289.0"/> + <di:waypoint xsi:type="dc:Point" x="1823.0" y="305.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="22.0" width="27.0" x="1104.0" y="146.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn2:definitions>
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/FalloutHandler.bpmn b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/FalloutHandler.bpmn new file mode 100644 index 0000000000..5f5fd3daae --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/FalloutHandler.bpmn @@ -0,0 +1,421 @@ +<?xml version="1.0" encoding="UTF-8"?> +<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="_3SPHsLr9EeWak-hhutJWuQ" targetNamespace="http://camunda.org/schema/1.0/bpmn" exporter="Camunda Modeler" exporterVersion="1.4.0" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd"> + <bpmn2:process id="FalloutHandler" name="Fallout Handler" isExecutable="true"> + <bpmn2:scriptTask id="ScriptTask_8" name="Pre-Process Request" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_10</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_1nn37a8</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +def preProcessRequestData = new FalloutHandler() +preProcessRequestData.preProcessRequest(execution) + +]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:startEvent id="StartEvent_1" name="Start"> + <bpmn2:outgoing>SequenceFlow_10</bpmn2:outgoing> + </bpmn2:startEvent> + <bpmn2:sequenceFlow id="SequenceFlow_10" name="" sourceRef="StartEvent_1" targetRef="ScriptTask_8" /> + <bpmn2:scriptTask id="ScriptTask_2" name="Post Process Response" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_0fg02po</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_0x2jgo4</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +def falloutHandler = new FalloutHandler() +falloutHandler.postProcessResponse(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:exclusiveGateway id="ExclusiveGateway_6" default="SequenceFlow_26"> + <bpmn2:incoming>SequenceFlow_1nn37a8</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_25</bpmn2:outgoing> + <bpmn2:outgoing>SequenceFlow_26</bpmn2:outgoing> + </bpmn2:exclusiveGateway> + <bpmn2:sequenceFlow id="SequenceFlow_25" name="" sourceRef="ExclusiveGateway_6" targetRef="ServiceTask_3"> + <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression"><![CDATA[#{execution.getVariable("FH_request_id-Ok") ==true}]]></bpmn2:conditionExpression> + </bpmn2:sequenceFlow> + <bpmn2:sequenceFlow id="SequenceFlow_26" name="" sourceRef="ExclusiveGateway_6" targetRef="ServiceTask_2" /> + <bpmn2:serviceTask id="ServiceTask_3" name="Update Request Gamma"> + <bpmn2:extensionElements> + <camunda:connector> + <camunda:inputOutput> + <camunda:inputParameter name="url">${URN_mso_adapters_db_endpoint}</camunda:inputParameter> + <camunda:inputParameter name="method">POST</camunda:inputParameter> + <camunda:inputParameter name="headers"> + <camunda:map> + <camunda:entry key="content-type">application/soap+xml</camunda:entry> + <camunda:entry key="Authorization">#{BasicAuthHeaderValueDB}</camunda:entry> + </camunda:map> + </camunda:inputParameter> + <camunda:inputParameter name="payload"> + <camunda:script scriptFormat="groovy"><![CDATA[//println"INSIDE --> update Request Gamma" +import org.openecomp.mso.bpmn.common.scripts.* +def updateRequestGamma= new FalloutHandler() +return updateRequestGamma.updateRequestGammaPayload(execution)]]></camunda:script> + </camunda:inputParameter> + <camunda:outputParameter name="FH_updateRequestGammaResponse"><![CDATA[${statusCode == null || statusCode == 204 ? "" : response}]]></camunda:outputParameter> + <camunda:outputParameter name="FH_updateRequestGammaResponseCode">${statusCode}</camunda:outputParameter> + </camunda:inputOutput> + <camunda:connectorId>soap-http-connector</camunda:connectorId> + </camunda:connector> + </bpmn2:extensionElements> + <bpmn2:incoming>SequenceFlow_25</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_29</bpmn2:outgoing> + </bpmn2:serviceTask> + <bpmn2:sequenceFlow id="SequenceFlow_29" name="" sourceRef="ServiceTask_3" targetRef="ExclusiveGateway_7" /> + <bpmn2:boundaryEvent id="BoundaryEvent_2" name="Connect Fault" attachedToRef="ServiceTask_3"> + <bpmn2:outgoing>SequenceFlow_72</bpmn2:outgoing> + <bpmn2:errorEventDefinition id="_ErrorEventDefinition_89" errorRef="Error_2" /> + </bpmn2:boundaryEvent> + <bpmn2:exclusiveGateway id="ParallelGateway_5"> + <bpmn2:incoming>SequenceFlow_35</bpmn2:incoming> + <bpmn2:incoming>SequenceFlow_36</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_0fg02po</bpmn2:outgoing> + </bpmn2:exclusiveGateway> + <bpmn2:endEvent id="EndEvent_6" name="Normal End"> + <bpmn2:incoming>SequenceFlow_0x2jgo4</bpmn2:incoming> + </bpmn2:endEvent> + <bpmn2:sequenceFlow id="SequenceFlow_72" name="" sourceRef="BoundaryEvent_2" targetRef="ScriptTask_6" /> + <bpmn2:scriptTask id="ScriptTask_6" name="Build Workflow Exception" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_72</bpmn2:incoming> + <bpmn2:incoming>SequenceFlow_31</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_79</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +def falloutHandler = new FalloutHandler() +falloutHandler.buildDBWorkflowException(execution, "FH_updateRequestGammaResponseCode")]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_79" name="" sourceRef="ScriptTask_6" targetRef="EndEvent_13" /> + <bpmn2:exclusiveGateway id="ExclusiveGateway_7" name="Update Success?" default="SequenceFlow_31"> + <bpmn2:incoming>SequenceFlow_29</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_31</bpmn2:outgoing> + <bpmn2:outgoing>SequenceFlow_35</bpmn2:outgoing> + </bpmn2:exclusiveGateway> + <bpmn2:sequenceFlow id="SequenceFlow_31" name="" sourceRef="ExclusiveGateway_7" targetRef="ScriptTask_6" /> + <bpmn2:sequenceFlow id="SequenceFlow_35" name="" sourceRef="ExclusiveGateway_7" targetRef="ParallelGateway_5"> + <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression"><![CDATA[#{execution.getVariable("FH_updateRequestGammaResponseCode")==200}]]></bpmn2:conditionExpression> + </bpmn2:sequenceFlow> + <bpmn2:scriptTask id="ScriptTask_7" name="Build Workflow Exception" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_32</bpmn2:incoming> + <bpmn2:incoming>SequenceFlow_80</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_73</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +def falloutHandler = new FalloutHandler() +falloutHandler.buildDBWorkflowException(execution, "FH_updateRequestInfraResponseCode")]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_73" name="" sourceRef="ScriptTask_7" targetRef="EndEvent_14" /> + <bpmn2:serviceTask id="ServiceTask_2" name="Update Request Infra"> + <bpmn2:extensionElements> + <camunda:connector> + <camunda:inputOutput> + <camunda:inputParameter name="url">${URN_mso_adapters_db_endpoint}</camunda:inputParameter> + <camunda:inputParameter name="method">POST</camunda:inputParameter> + <camunda:inputParameter name="headers"> + <camunda:map> + <camunda:entry key="content-type">application/soap+xml</camunda:entry> + <camunda:entry key="Authorization">#{BasicAuthHeaderValueDB}</camunda:entry> + </camunda:map> + </camunda:inputParameter> + <camunda:inputParameter name="payload"> + <camunda:script scriptFormat="groovy"><![CDATA[//println"INSIDE --> update Request Infra" +import org.openecomp.mso.bpmn.common.scripts.* +def updateRequestInfra= new FalloutHandler() +return updateRequestInfra.updateRequestInfraPayload(execution)]]></camunda:script> + </camunda:inputParameter> + <camunda:outputParameter name="FH_updateRequestInfraResponse"><![CDATA[${statusCode == null || statusCode == 204 ? "" : response}]]></camunda:outputParameter> + <camunda:outputParameter name="FH_updateRequestInfraResponseCode">${statusCode}</camunda:outputParameter> + </camunda:inputOutput> + <camunda:connectorId>soap-http-connector</camunda:connectorId> + </camunda:connector> + </bpmn2:extensionElements> + <bpmn2:incoming>SequenceFlow_26</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_30</bpmn2:outgoing> + </bpmn2:serviceTask> + <bpmn2:sequenceFlow id="SequenceFlow_30" name="" sourceRef="ServiceTask_2" targetRef="ExclusiveGateway_8" /> + <bpmn2:exclusiveGateway id="ExclusiveGateway_8" name="Update Success?" default="SequenceFlow_32"> + <bpmn2:incoming>SequenceFlow_30</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_32</bpmn2:outgoing> + <bpmn2:outgoing>SequenceFlow_36</bpmn2:outgoing> + </bpmn2:exclusiveGateway> + <bpmn2:sequenceFlow id="SequenceFlow_32" name="" sourceRef="ExclusiveGateway_8" targetRef="ScriptTask_7" /> + <bpmn2:sequenceFlow id="SequenceFlow_36" name="" sourceRef="ExclusiveGateway_8" targetRef="ParallelGateway_5"> + <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression"><![CDATA[#{execution.getVariable("FH_updateRequestInfraResponseCode")==200}]]></bpmn2:conditionExpression> + </bpmn2:sequenceFlow> + <bpmn2:boundaryEvent id="BoundaryEvent_3" name="Connect Fault" attachedToRef="ServiceTask_2"> + <bpmn2:outgoing>SequenceFlow_80</bpmn2:outgoing> + <bpmn2:errorEventDefinition id="_ErrorEventDefinition_90" errorRef="Error_2" /> + </bpmn2:boundaryEvent> + <bpmn2:sequenceFlow id="SequenceFlow_80" name="" sourceRef="BoundaryEvent_3" targetRef="ScriptTask_7" /> + <bpmn2:subProcess id="SubProcess_1" name="Event Handler" triggeredByEvent="true"> + <bpmn2:scriptTask id="ScriptTask_4" name="Handle Event" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_1k7it63</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_0celhl1</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +execution.setVariable("FH_success", false) +def falloutHandler = new FalloutHandler() + +// This does not (and cannot) throw exceptions +falloutHandler.postProcessResponse(execution) + +// Clear any WorkflowException object that might be in the execution, but keep a copy in FH_WorkflowException +def wfe = execution.getVariable("WorkflowException") +execution.setVariable("WorkflowException", null) +execution.setVariable("FH_WorkflowException", wfe)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:startEvent id="StartEvent_2"> + <bpmn2:outgoing>SequenceFlow_1k7it63</bpmn2:outgoing> + <bpmn2:errorEventDefinition id="ErrorEventDefinition_8" /> + </bpmn2:startEvent> + <bpmn2:endEvent id="EndEvent_2" name="Error End"> + <bpmn2:incoming>SequenceFlow_0celhl1</bpmn2:incoming> + <bpmn2:terminateEventDefinition /> + </bpmn2:endEvent> + <bpmn2:sequenceFlow id="SequenceFlow_1k7it63" sourceRef="StartEvent_2" targetRef="ScriptTask_4" /> + <bpmn2:sequenceFlow id="SequenceFlow_0celhl1" sourceRef="ScriptTask_4" targetRef="EndEvent_2" /> + </bpmn2:subProcess> + <bpmn2:endEvent id="EndEvent_14"> + <bpmn2:incoming>SequenceFlow_73</bpmn2:incoming> + <bpmn2:terminateEventDefinition /> + </bpmn2:endEvent> + <bpmn2:endEvent id="EndEvent_13"> + <bpmn2:incoming>SequenceFlow_79</bpmn2:incoming> + <bpmn2:terminateEventDefinition /> + </bpmn2:endEvent> + <bpmn2:sequenceFlow id="SequenceFlow_1nn37a8" sourceRef="ScriptTask_8" targetRef="ExclusiveGateway_6" /> + <bpmn2:sequenceFlow id="SequenceFlow_0fg02po" sourceRef="ParallelGateway_5" targetRef="ScriptTask_2" /> + <bpmn2:sequenceFlow id="SequenceFlow_0x2jgo4" sourceRef="ScriptTask_2" targetRef="EndEvent_6" /> + </bpmn2:process> + <bpmn2:error id="Error_1" name="MSOWorkflowException" errorCode="MSOWorkflowException" /> + <bpmn2:error id="Error_2" name="Java Lang Exception" errorCode="java.lang.Exception" /> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="FalloutHandler"> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_52" bpmnElement="StartEvent_1"> + <dc:Bounds x="122" y="1112" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="128" y="1149" width="23" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ExclusiveGateway_79" bpmnElement="ExclusiveGateway_6" isMarkerVisible="true"> + <dc:Bounds x="381" y="1105" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="406" y="1160" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_25" bpmnElement="SequenceFlow_25" sourceElement="_BPMNShape_ExclusiveGateway_79" targetElement="_BPMNShape_ServiceTask_90"> + <di:waypoint xsi:type="dc:Point" x="406" y="1105" /> + <di:waypoint xsi:type="dc:Point" x="406" y="1039" /> + <di:waypoint xsi:type="dc:Point" x="461" y="1039" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="403" y="1081" width="6" height="6" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_26" bpmnElement="SequenceFlow_26" sourceElement="_BPMNShape_ExclusiveGateway_79" targetElement="_BPMNShape_ServiceTask_91"> + <di:waypoint xsi:type="dc:Point" x="406" y="1155" /> + <di:waypoint xsi:type="dc:Point" x="406" y="1287" /> + <di:waypoint xsi:type="dc:Point" x="457" y="1287" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="403" y="1233" width="6" height="6" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_ServiceTask_90" bpmnElement="ServiceTask_3"> + <dc:Bounds x="461" y="999" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ServiceTask_91" bpmnElement="ServiceTask_2"> + <dc:Bounds x="457" y="1247" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ExclusiveGateway_80" bpmnElement="ExclusiveGateway_7" isMarkerVisible="true"> + <dc:Bounds x="644" y="1013" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="615" y="1068" width="109" height="22" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_29" bpmnElement="SequenceFlow_29" sourceElement="_BPMNShape_ServiceTask_90" targetElement="_BPMNShape_ExclusiveGateway_80"> + <di:waypoint xsi:type="dc:Point" x="561" y="1039" /> + <di:waypoint xsi:type="dc:Point" x="644" y="1038" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="598" y="1041" width="6" height="6" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_ExclusiveGateway_81" bpmnElement="ExclusiveGateway_8" isMarkerVisible="true"> + <dc:Bounds x="643" y="1262" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="614" y="1317" width="109" height="22" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_30" bpmnElement="SequenceFlow_30" sourceElement="_BPMNShape_ServiceTask_91" targetElement="_BPMNShape_ExclusiveGateway_81"> + <di:waypoint xsi:type="dc:Point" x="557" y="1287" /> + <di:waypoint xsi:type="dc:Point" x="595" y="1287" /> + <di:waypoint xsi:type="dc:Point" x="595" y="1286" /> + <di:waypoint xsi:type="dc:Point" x="643" y="1287" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="602" y="1288" width="6" height="6" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_31" bpmnElement="SequenceFlow_31" sourceElement="_BPMNShape_ExclusiveGateway_80" targetElement="_BPMNShape_ScriptTask_252"> + <di:waypoint xsi:type="dc:Point" x="669" y="1013" /> + <di:waypoint xsi:type="dc:Point" x="670" y="961" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="673" y="988" width="6" height="6" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_32" bpmnElement="SequenceFlow_32" sourceElement="_BPMNShape_ExclusiveGateway_81" targetElement="_BPMNShape_ScriptTask_253"> + <di:waypoint xsi:type="dc:Point" x="668" y="1262" /> + <di:waypoint xsi:type="dc:Point" x="668" y="1245" /> + <di:waypoint xsi:type="dc:Point" x="668" y="1214" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="675" y="1294" width="6" height="6" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_ParallelGateway_16" bpmnElement="ParallelGateway_5" isMarkerVisible="true"> + <dc:Bounds x="822" y="1105" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="847" y="1160" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_35" bpmnElement="SequenceFlow_35" sourceElement="_BPMNShape_ExclusiveGateway_80" targetElement="_BPMNShape_ParallelGateway_16"> + <di:waypoint xsi:type="dc:Point" x="694" y="1038" /> + <di:waypoint xsi:type="dc:Point" x="847" y="1038" /> + <di:waypoint xsi:type="dc:Point" x="847" y="1105" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="728" y="1029" width="6" height="6" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_36" bpmnElement="SequenceFlow_36" sourceElement="_BPMNShape_ExclusiveGateway_81" targetElement="_BPMNShape_ParallelGateway_16"> + <di:waypoint xsi:type="dc:Point" x="693" y="1287" /> + <di:waypoint xsi:type="dc:Point" x="847" y="1287" /> + <di:waypoint xsi:type="dc:Point" x="847" y="1155" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="844" y="1211" width="6" height="6" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_10" bpmnElement="SequenceFlow_10" sourceElement="_BPMNShape_StartEvent_52" targetElement="_BPMNShape_ScriptTask_99"> + <di:waypoint xsi:type="dc:Point" x="158" y="1130" /> + <di:waypoint xsi:type="dc:Point" x="212" y="1130" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="185" y="1115" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_99" bpmnElement="ScriptTask_8"> + <dc:Bounds x="212" y="1090" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_SubProcess_14" bpmnElement="SubProcess_1" isExpanded="true"> + <dc:Bounds x="115" y="1396" width="329" height="167" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_100" bpmnElement="ScriptTask_4"> + <dc:Bounds x="228" y="1440" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_54" bpmnElement="StartEvent_2"> + <dc:Bounds x="144" y="1462" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="162" y="1506" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_101" bpmnElement="ScriptTask_2"> + <dc:Bounds x="913" y="1090" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_EndEvent_129" bpmnElement="EndEvent_6"> + <dc:Bounds x="1062" y="1112" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1051" y="1153" width="57" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_BoundaryEvent_31" bpmnElement="BoundaryEvent_2"> + <dc:Bounds x="494" y="981" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="522" y="937" width="87" height="22" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_BoundaryEvent_32" bpmnElement="BoundaryEvent_3"> + <dc:Bounds x="490" y="1229" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="522" y="1191" width="87" height="22" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_72" bpmnElement="SequenceFlow_72" sourceElement="_BPMNShape_BoundaryEvent_31" targetElement="_BPMNShape_ScriptTask_252"> + <di:waypoint xsi:type="dc:Point" x="512" y="981" /> + <di:waypoint xsi:type="dc:Point" x="512" y="921" /> + <di:waypoint xsi:type="dc:Point" x="620" y="921" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="509" y="963" width="6" height="6" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_73" bpmnElement="SequenceFlow_73" sourceElement="_BPMNShape_ScriptTask_253"> + <di:waypoint xsi:type="dc:Point" x="719" y="1174" /> + <di:waypoint xsi:type="dc:Point" x="759" y="1174" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="739" y="1159" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_252" bpmnElement="ScriptTask_6"> + <dc:Bounds x="620" y="881" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_253" bpmnElement="ScriptTask_7"> + <dc:Bounds x="619" y="1134" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_79" bpmnElement="SequenceFlow_79" sourceElement="_BPMNShape_ScriptTask_252"> + <di:waypoint xsi:type="dc:Point" x="720" y="921" /> + <di:waypoint xsi:type="dc:Point" x="762" y="921" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="741" y="906" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_80" bpmnElement="SequenceFlow_80" sourceElement="_BPMNShape_BoundaryEvent_32" targetElement="_BPMNShape_ScriptTask_253"> + <di:waypoint xsi:type="dc:Point" x="508" y="1229" /> + <di:waypoint xsi:type="dc:Point" x="508" y="1174" /> + <di:waypoint xsi:type="dc:Point" x="619" y="1174" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="533" y="1174" width="6" height="6" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="EndEvent_0b9vn2u_di" bpmnElement="EndEvent_2"> + <dc:Bounds x="372" y="1462" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="368" y="1506" width="47" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_1fmpj5u_di" bpmnElement="EndEvent_14"> + <dc:Bounds x="759" y="1156" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="777" y="1197" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_0w1puhf_di" bpmnElement="EndEvent_13"> + <dc:Bounds x="762" y="903" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="780" y="944" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1nn37a8_di" bpmnElement="SequenceFlow_1nn37a8"> + <di:waypoint xsi:type="dc:Point" x="312" y="1130" /> + <di:waypoint xsi:type="dc:Point" x="340" y="1130" /> + <di:waypoint xsi:type="dc:Point" x="340" y="1130" /> + <di:waypoint xsi:type="dc:Point" x="381" y="1130" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="355" y="1130" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0fg02po_di" bpmnElement="SequenceFlow_0fg02po"> + <di:waypoint xsi:type="dc:Point" x="872" y="1130" /> + <di:waypoint xsi:type="dc:Point" x="913" y="1130" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="893" y="1115" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0x2jgo4_di" bpmnElement="SequenceFlow_0x2jgo4"> + <di:waypoint xsi:type="dc:Point" x="1013" y="1130" /> + <di:waypoint xsi:type="dc:Point" x="1062" y="1130" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1038" y="1105" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1k7it63_di" bpmnElement="SequenceFlow_1k7it63"> + <di:waypoint xsi:type="dc:Point" x="180" y="1480" /> + <di:waypoint xsi:type="dc:Point" x="228" y="1480" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="204" y="1455" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0celhl1_di" bpmnElement="SequenceFlow_0celhl1"> + <di:waypoint xsi:type="dc:Point" x="328" y="1480" /> + <di:waypoint xsi:type="dc:Point" x="372" y="1480" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="350" y="1455" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn2:definitions> diff --git a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/GenerateVfModuleName.bpmn b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/GenerateVfModuleName.bpmn new file mode 100644 index 0000000000..ab4afdad1c --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/GenerateVfModuleName.bpmn @@ -0,0 +1,87 @@ +<?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:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.4.0"> + <bpmn:process id="GenerateVfModuleName" name="GenerateVfModuleName" isExecutable="true"> + <bpmn:startEvent id="StartEvent_1"> + <bpmn:outgoing>SequenceFlow_1opqmjl</bpmn:outgoing> + </bpmn:startEvent> + <bpmn:scriptTask id="InitializeVariables" name="Initialize Variables" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_1opqmjl</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0aqc89s</bpmn:outgoing> + <bpmn:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +def generateVfModuleName = new GenerateVfModuleName() +generateVfModuleName.preProcessRequest(execution)]]></bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="QueryAAIForIndex" name="Query AAI for Index" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_0aqc89s</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1afb896</bpmn:outgoing> + <bpmn:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +def generateVfModuleName = new GenerateVfModuleName() +generateVfModuleName.queryAAI(execution)]]></bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="SequenceFlow_1opqmjl" sourceRef="StartEvent_1" targetRef="InitializeVariables" /> + <bpmn:sequenceFlow id="SequenceFlow_0aqc89s" sourceRef="InitializeVariables" targetRef="QueryAAIForIndex" /> + <bpmn:sequenceFlow id="SequenceFlow_1afb896" sourceRef="QueryAAIForIndex" targetRef="PostProcessAAIResponse" /> + <bpmn:sequenceFlow id="SequenceFlow_0o6nle0" sourceRef="PostProcessAAIResponse" targetRef="EndEvent_0mj5vyw" /> + <bpmn:endEvent id="EndEvent_0mj5vyw"> + <bpmn:incoming>SequenceFlow_0o6nle0</bpmn:incoming> + <bpmn:terminateEventDefinition /> + </bpmn:endEvent> + <bpmn:scriptTask id="PostProcessAAIResponse" name="Generate Name Based on Lowest Index" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_1afb896</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0o6nle0</bpmn:outgoing> + <bpmn:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +def generateVfModuleName = new GenerateVfModuleName() +generateVfModuleName.generateName(execution)]]></bpmn:script> + </bpmn:scriptTask> + </bpmn:process> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="GenerateVfModuleName"> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1"> + <dc:Bounds x="173" y="102" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_0jnmm07_di" bpmnElement="InitializeVariables"> + <dc:Bounds x="327" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_1pyh00w_di" bpmnElement="QueryAAIForIndex"> + <dc:Bounds x="518" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1opqmjl_di" bpmnElement="SequenceFlow_1opqmjl"> + <di:waypoint xsi:type="dc:Point" x="209" y="120" /> + <di:waypoint xsi:type="dc:Point" x="327" y="120" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="268" y="95" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0aqc89s_di" bpmnElement="SequenceFlow_0aqc89s"> + <di:waypoint xsi:type="dc:Point" x="427" y="120" /> + <di:waypoint xsi:type="dc:Point" x="518" y="120" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="473" y="95" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1afb896_di" bpmnElement="SequenceFlow_1afb896"> + <di:waypoint xsi:type="dc:Point" x="618" y="120" /> + <di:waypoint xsi:type="dc:Point" x="696" y="120" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="657" y="105" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0o6nle0_di" bpmnElement="SequenceFlow_0o6nle0"> + <di:waypoint xsi:type="dc:Point" x="796" y="120" /> + <di:waypoint xsi:type="dc:Point" x="903" y="120" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="850" y="105" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="EndEvent_0dr0y6r_di" bpmnElement="EndEvent_0mj5vyw"> + <dc:Bounds x="903" y="102" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="921" y="138" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_00yhljy_di" bpmnElement="PostProcessAAIResponse"> + <dc:Bounds x="696" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn:definitions> diff --git a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/GenericDeleteService.bpmn b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/GenericDeleteService.bpmn new file mode 100644 index 0000000000..f4edac612c --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/GenericDeleteService.bpmn @@ -0,0 +1,303 @@ +<?xml version="1.0" encoding="UTF-8"?> +<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd" id="_wAtdAGrUEeaJwpcpVN5gXw" exporter="camunda modeler" exporterVersion="2.7.0" targetNamespace="http://camunda.org/schema/1.0/bpmn"> + <bpmn2:process id="GenericDeleteService" name="GenericDeleteService" isExecutable="true"> + <bpmn2:subProcess id="bpmnExceptionHandlingSubProcess" name="Error Handling Sub Process" triggeredByEvent="true"> + <bpmn2:scriptTask id="processError" name="Process Error" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_9</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_10</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* + +ExceptionUtil ex = new ExceptionUtil() +ex.processSubflowsBPMNException(execution) +]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_10" name="" sourceRef="processError" targetRef="EndEvent_3"/> + <bpmn2:startEvent id="StartEvent_2"> + <bpmn2:outgoing>SequenceFlow_9</bpmn2:outgoing> + <bpmn2:errorEventDefinition id="ErrorEventDefinition_1"/> + </bpmn2:startEvent> + <bpmn2:sequenceFlow id="SequenceFlow_9" name="" sourceRef="StartEvent_2" targetRef="processError"/> + <bpmn2:endEvent id="EndEvent_3"> + <bpmn2:incoming>SequenceFlow_10</bpmn2:incoming> + <bpmn2:terminateEventDefinition id="_TerminateEventDefinition_25"/> + </bpmn2:endEvent> + </bpmn2:subProcess> + <bpmn2:subProcess id="javaExceptionSubProcess" name="Java Exception Handling Sub Process" triggeredByEvent="true"> + <bpmn2:endEvent id="EndEvent_2"> + <bpmn2:incoming>SequenceFlow_12</bpmn2:incoming> + </bpmn2:endEvent> + <bpmn2:scriptTask id="processJavaError" name="Process Error"> + <bpmn2:incoming>SequenceFlow_11</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_12</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* + +ExceptionUtil ex = new ExceptionUtil() +ex.processSubflowsJavaException(execution) +]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:startEvent id="StartEvent_3"> + <bpmn2:outgoing>SequenceFlow_11</bpmn2:outgoing> + <bpmn2:errorEventDefinition id="ErrorEventDefinition_2"/> + </bpmn2:startEvent> + <bpmn2:sequenceFlow id="SequenceFlow_11" name="" sourceRef="StartEvent_3" targetRef="processJavaError"/> + <bpmn2:sequenceFlow id="SequenceFlow_12" name="" sourceRef="processJavaError" targetRef="EndEvent_2"/> + </bpmn2:subProcess> + <bpmn2:startEvent id="StartEvent_1"> + <bpmn2:outgoing>SequenceFlow_1</bpmn2:outgoing> + </bpmn2:startEvent> + <bpmn2:sequenceFlow id="SequenceFlow_1" name="" sourceRef="StartEvent_1" targetRef="initialization"/> + <bpmn2:scriptTask id="initialization" name="Initialization" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_1</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_3</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +GenericDeleteService deleteService = new GenericDeleteService() +deleteService.preProcessRequest(execution) +]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_3" name="" sourceRef="initialization" targetRef="resourceVersionCheck"/> + <bpmn2:exclusiveGateway id="resourceVersionCheck" name="Resource Version Provided?" default="yes"> + <bpmn2:incoming>SequenceFlow_3</bpmn2:incoming> + <bpmn2:outgoing>no</bpmn2:outgoing> + <bpmn2:outgoing>yes</bpmn2:outgoing> + </bpmn2:exclusiveGateway> + <bpmn2:sequenceFlow id="no" name="No" sourceRef="resourceVersionCheck" targetRef="queryForResourceVersion"> + <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression"><![CDATA[#{execution.getVariable("GENDS_resourceVersionProvidedFlag" ) == false}]]></bpmn2:conditionExpression> + </bpmn2:sequenceFlow> + <bpmn2:sequenceFlow id="yes" name="Yes" sourceRef="resourceVersionCheck" targetRef="ExclusiveGateway_2"/> + <bpmn2:scriptTask id="toggleSuccess" name="Toggle Success Indicator" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_7</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_4</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +GenericDeleteService deleteService = new GenericDeleteService() +deleteService.setSuccessIndicator(execution, true) + +execution.setVariable("WorkflowResponse", " ") //for junits +]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_4" name="" sourceRef="toggleSuccess" targetRef="EndEvent_1"/> + <bpmn2:exclusiveGateway id="ExclusiveGateway_2"> + <bpmn2:incoming>yes</bpmn2:incoming> + <bpmn2:incoming>siExistYes</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_6</bpmn2:outgoing> + </bpmn2:exclusiveGateway> + <bpmn2:sequenceFlow id="SequenceFlow_6" name="" sourceRef="ExclusiveGateway_2" targetRef="deleteServiceInstance"/> + <bpmn2:endEvent id="EndEvent_1"> + <bpmn2:incoming>SequenceFlow_4</bpmn2:incoming> + <bpmn2:terminateEventDefinition id="_TerminateEventDefinition_24"/> + </bpmn2:endEvent> + <bpmn2:scriptTask id="deleteServiceInstance" name="DELETE
Service Instance" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_6</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_7</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +GenericDeleteService deleteService = new GenericDeleteService() +deleteService.deleteServiceObject(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_7" name="" sourceRef="deleteServiceInstance" targetRef="toggleSuccess"/> + <bpmn2:scriptTask id="queryForResourceVersion" name="Query SI Resource Version" scriptFormat="groovy"> + <bpmn2:incoming>no</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_5</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +GenericDeleteService deleteService = new GenericDeleteService() +deleteService.getServiceResourceVersion(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_5" name="" sourceRef="queryForResourceVersion" targetRef="siExistCheck"/> + <bpmn2:exclusiveGateway id="siExistCheck" name="Service Exist?"> + <bpmn2:incoming>SequenceFlow_5</bpmn2:incoming> + <bpmn2:outgoing>siExistYes</bpmn2:outgoing> + <bpmn2:outgoing>siExistNo</bpmn2:outgoing> + </bpmn2:exclusiveGateway> + <bpmn2:sequenceFlow id="siExistYes" name="Yes" sourceRef="siExistCheck" targetRef="ExclusiveGateway_2"> + <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression"><![CDATA[#{execution.getVariable("GENDS_FoundIndicator" ) == true}]]></bpmn2:conditionExpression> + </bpmn2:sequenceFlow> + <bpmn2:sequenceFlow id="siExistNo" name="No" sourceRef="siExistCheck" targetRef="EndEvent_4"/> + <bpmn2:endEvent id="EndEvent_4"> + <bpmn2:incoming>siExistNo</bpmn2:incoming> + <bpmn2:terminateEventDefinition id="_TerminateEventDefinition_38"/> + </bpmn2:endEvent> + </bpmn2:process> + <bpmn2:error id="Error_1" errorCode="MSOWorkflowException" name="MSO Workflow Exception"/> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="GenericDeleteService"> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_63" bpmnElement="StartEvent_1"> + <dc:Bounds height="36.0" width="36.0" x="84.0" y="221.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="102.0" y="262.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_267" bpmnElement="initialization"> + <dc:Bounds height="80.0" width="100.0" x="216.0" y="199.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ExclusiveGateway_224" bpmnElement="resourceVersionCheck" isMarkerVisible="true"> + <dc:Bounds height="50.0" width="50.0" x="365.0" y="213.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="22.0" width="169.0" x="401.0" y="243.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_268" bpmnElement="queryForResourceVersion"> + <dc:Bounds height="80.0" width="100.0" x="457.0" y="100.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ExclusiveGateway_225" bpmnElement="ExclusiveGateway_2" isMarkerVisible="true"> + <dc:Bounds height="50.0" width="50.0" x="600.0" y="213.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="625.0" y="268.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_269" bpmnElement="deleteServiceInstance"> + <dc:Bounds height="80.0" width="100.0" x="684.0" y="199.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_EndEvent_213" bpmnElement="EndEvent_1"> + <dc:Bounds height="36.0" width="36.0" x="1006.0" y="221.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="1024.0" y="262.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_SubProcess_20" bpmnElement="bpmnExceptionHandlingSubProcess" isExpanded="true"> + <dc:Bounds height="169.0" width="321.0" x="155.0" y="384.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_1" bpmnElement="SequenceFlow_1" sourceElement="_BPMNShape_StartEvent_63" targetElement="_BPMNShape_ScriptTask_267"> + <di:waypoint xsi:type="dc:Point" x="120.0" y="239.0"/> + <di:waypoint xsi:type="dc:Point" x="216.0" y="239.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="147.0" y="239.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_3" bpmnElement="SequenceFlow_3" sourceElement="_BPMNShape_ScriptTask_267" targetElement="_BPMNShape_ExclusiveGateway_224"> + <di:waypoint xsi:type="dc:Point" x="316.0" y="239.0"/> + <di:waypoint xsi:type="dc:Point" x="365.0" y="238.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="217.0" y="238.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_4" bpmnElement="no" sourceElement="_BPMNShape_ExclusiveGateway_224" targetElement="_BPMNShape_ScriptTask_268"> + <di:waypoint xsi:type="dc:Point" x="390.0" y="213.0"/> + <di:waypoint xsi:type="dc:Point" x="390.0" y="140.0"/> + <di:waypoint xsi:type="dc:Point" x="457.0" y="140.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="22.0" width="22.0" x="392.0" y="179.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_5" bpmnElement="SequenceFlow_5" sourceElement="_BPMNShape_ScriptTask_268" targetElement="_BPMNShape_ExclusiveGateway_241"> + <di:waypoint xsi:type="dc:Point" x="557.0" y="140.0"/> + <di:waypoint xsi:type="dc:Point" x="600.0" y="139.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="492.0" y="140.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_6" bpmnElement="SequenceFlow_6" sourceElement="_BPMNShape_ExclusiveGateway_225" targetElement="_BPMNShape_ScriptTask_269"> + <di:waypoint xsi:type="dc:Point" x="650.0" y="238.0"/> + <di:waypoint xsi:type="dc:Point" x="684.0" y="239.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="556.0" y="239.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_7" bpmnElement="SequenceFlow_7" sourceElement="_BPMNShape_ScriptTask_269" targetElement="_BPMNShape_ScriptTask_272"> + <di:waypoint xsi:type="dc:Point" x="784.0" y="239.0"/> + <di:waypoint xsi:type="dc:Point" x="826.0" y="239.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="778.0" y="239.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_8" bpmnElement="yes" sourceElement="_BPMNShape_ExclusiveGateway_224" targetElement="_BPMNShape_ExclusiveGateway_225"> + <di:waypoint xsi:type="dc:Point" x="390.0" y="263.0"/> + <di:waypoint xsi:type="dc:Point" x="390.0" y="310.0"/> + <di:waypoint xsi:type="dc:Point" x="517.0" y="310.0"/> + <di:waypoint xsi:type="dc:Point" x="625.0" y="310.0"/> + <di:waypoint xsi:type="dc:Point" x="625.0" y="263.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="22.0" width="29.0" x="389.0" y="278.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_SubProcess_23" bpmnElement="javaExceptionSubProcess" isExpanded="true"> + <dc:Bounds height="157.0" width="306.0" x="163.0" y="576.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_65" bpmnElement="StartEvent_2"> + <dc:Bounds height="36.0" width="36.0" x="180.0" y="451.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="198.0" y="492.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_66" bpmnElement="StartEvent_3"> + <dc:Bounds height="36.0" width="36.0" x="192.0" y="637.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="210.0" y="678.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_EndEvent_216" bpmnElement="EndEvent_2"> + <dc:Bounds height="36.0" width="36.0" x="408.0" y="637.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="426.0" y="678.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_EndEvent_217" bpmnElement="EndEvent_3"> + <dc:Bounds height="36.0" width="36.0" x="420.0" y="451.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="438.0" y="492.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_270" bpmnElement="processError"> + <dc:Bounds height="80.0" width="100.0" x="266.0" y="429.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_271" bpmnElement="processJavaError"> + <dc:Bounds height="80.0" width="100.0" x="267.0" y="615.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_9" bpmnElement="SequenceFlow_9" sourceElement="_BPMNShape_StartEvent_65" targetElement="_BPMNShape_ScriptTask_270"> + <di:waypoint xsi:type="dc:Point" x="216.0" y="469.0"/> + <di:waypoint xsi:type="dc:Point" x="266.0" y="469.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="232.0" y="469.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_10" bpmnElement="SequenceFlow_10" sourceElement="_BPMNShape_ScriptTask_270" targetElement="_BPMNShape_EndEvent_217"> + <di:waypoint xsi:type="dc:Point" x="366.0" y="469.0"/> + <di:waypoint xsi:type="dc:Point" x="420.0" y="469.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="384.0" y="469.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_11" bpmnElement="SequenceFlow_11" sourceElement="_BPMNShape_StartEvent_66" targetElement="_BPMNShape_ScriptTask_271"> + <di:waypoint xsi:type="dc:Point" x="228.0" y="655.0"/> + <di:waypoint xsi:type="dc:Point" x="267.0" y="655.0"/> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_12" bpmnElement="SequenceFlow_12" sourceElement="_BPMNShape_ScriptTask_271" targetElement="_BPMNShape_EndEvent_216"> + <di:waypoint xsi:type="dc:Point" x="367.0" y="655.0"/> + <di:waypoint xsi:type="dc:Point" x="408.0" y="655.0"/> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_272" bpmnElement="toggleSuccess"> + <dc:Bounds height="80.0" width="100.0" x="826.0" y="199.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_13" bpmnElement="SequenceFlow_4" sourceElement="_BPMNShape_ScriptTask_272" targetElement="_BPMNShape_EndEvent_213"> + <di:waypoint xsi:type="dc:Point" x="926.0" y="239.0"/> + <di:waypoint xsi:type="dc:Point" x="1006.0" y="239.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="828.0" y="239.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_ExclusiveGateway_241" bpmnElement="siExistCheck" isMarkerVisible="true"> + <dc:Bounds height="50.0" width="50.0" x="600.0" y="114.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="22.0" width="59.0" x="596.0" y="94.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_2" bpmnElement="siExistYes" sourceElement="_BPMNShape_ExclusiveGateway_241" targetElement="_BPMNShape_ExclusiveGateway_225"> + <di:waypoint xsi:type="dc:Point" x="625.0" y="164.0"/> + <di:waypoint xsi:type="dc:Point" x="625.0" y="213.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="22.0" width="29.0" x="624.0" y="168.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_15" bpmnElement="siExistNo" sourceElement="_BPMNShape_ExclusiveGateway_241" targetElement="_BPMNShape_EndEvent_241"> + <di:waypoint xsi:type="dc:Point" x="650.0" y="139.0"/> + <di:waypoint xsi:type="dc:Point" x="733.0" y="140.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="22.0" width="22.0" x="664.0" y="140.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_EndEvent_241" bpmnElement="EndEvent_4"> + <dc:Bounds height="36.0" width="36.0" x="733.0" y="122.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="751.0" y="163.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn2:definitions>
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/GenericDeleteVnf.bpmn b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/GenericDeleteVnf.bpmn new file mode 100644 index 0000000000..e68f6ec227 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/GenericDeleteVnf.bpmn @@ -0,0 +1,251 @@ +<?xml version="1.0" encoding="UTF-8"?> +<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="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" id="_oBLSkHqWEea26OhQB97uCQ" targetNamespace="http://camunda.org/schema/1.0/bpmn" exporter="Camunda Modeler" exporterVersion="1.4.0" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd"> + <bpmn2:process id="GenericDeleteVnf" name="GenericDeleteVnf" isExecutable="true"> + <bpmn2:startEvent id="StartEvent_1"> + <bpmn2:outgoing>SequenceFlow_1</bpmn2:outgoing> + </bpmn2:startEvent> + <bpmn2:scriptTask id="initialization" name="Initialization" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_1</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_9</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +GenericDeleteVnf deleteVnf= new GenericDeleteVnf() +deleteVnf.preProcessRequest(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_1" name="" sourceRef="StartEvent_1" targetRef="initialization" /> + <bpmn2:sequenceFlow id="SequenceFlow_9" name="" sourceRef="initialization" targetRef="resourceVersionCheck" /> + <bpmn2:exclusiveGateway id="resourceVersionCheck" name="Resource Version Provided?" default="resourceVersionProvided"> + <bpmn2:incoming>SequenceFlow_9</bpmn2:incoming> + <bpmn2:outgoing>resourceVariableNotProvided</bpmn2:outgoing> + <bpmn2:outgoing>resourceVersionProvided</bpmn2:outgoing> + </bpmn2:exclusiveGateway> + <bpmn2:sequenceFlow id="resourceVariableNotProvided" name="No" sourceRef="resourceVersionCheck" targetRef="queryForResourceVersion"> + <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression"><![CDATA[#{execution.getVariable("GENDV_resourceVersionProvided") == false}]]></bpmn2:conditionExpression> + </bpmn2:sequenceFlow> + <bpmn2:sequenceFlow id="resourceVersionProvided" name="Yes" sourceRef="resourceVersionCheck" targetRef="ExclusiveGateway_2" /> + <bpmn2:subProcess id="bpmnExceptionHandlingSubProcess" name="Error Handling Sub Process" triggeredByEvent="true"> + <bpmn2:scriptTask id="processBPMNError" name="Process Error" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_2</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_3</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* + +ExceptionUtil ex = new ExceptionUtil() +ex.processSubflowsBPMNException(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_3" name="" sourceRef="processBPMNError" targetRef="EndEvent_2" /> + <bpmn2:startEvent id="StartEvent_2"> + <bpmn2:outgoing>SequenceFlow_2</bpmn2:outgoing> + <bpmn2:errorEventDefinition id="ErrorEventDefinition_1" /> + </bpmn2:startEvent> + <bpmn2:sequenceFlow id="SequenceFlow_2" name="" sourceRef="StartEvent_2" targetRef="processBPMNError" /> + <bpmn2:endEvent id="EndEvent_2"> + <bpmn2:incoming>SequenceFlow_3</bpmn2:incoming> + <bpmn2:terminateEventDefinition id="_TerminateEventDefinition_40" /> + </bpmn2:endEvent> + </bpmn2:subProcess> + <bpmn2:scriptTask id="queryForResourceVersion" name="Query SI Resource Version" scriptFormat="groovy"> + <bpmn2:incoming>resourceVariableNotProvided</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_5</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +GenericDeleteVnf deleteVnf= new GenericDeleteVnf() +deleteVnf.getVnfResourceVersion(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_5" name="" sourceRef="queryForResourceVersion" targetRef="vnfFoundCheck" /> + <bpmn2:scriptTask id="toggleSuccess" name="Toggle Success Indicator" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_7</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_8</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +GenericDeleteVnf deleteVnf= new GenericDeleteVnf() +deleteVnf.setSuccessIndicator(execution, true) + +execution.setVariable("WorkflowResponse", " ") //for junits]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_8" name="" sourceRef="toggleSuccess" targetRef="EndEvent_1" /> + <bpmn2:scriptTask id="deleteVnf" name="DELETE + Vnf" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_6</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_7</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +GenericDeleteVnf deleteVnf= new GenericDeleteVnf() +deleteVnf.deleteVnf(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_7" name="" sourceRef="deleteVnf" targetRef="toggleSuccess" /> + <bpmn2:endEvent id="EndEvent_3"> + <bpmn2:incoming>vnfFoundNo</bpmn2:incoming> + <bpmn2:terminateEventDefinition id="_TerminateEventDefinition_41" /> + </bpmn2:endEvent> + <bpmn2:exclusiveGateway id="vnfFoundCheck" name="Vnf Found?" default="vnfFoundNo"> + <bpmn2:incoming>SequenceFlow_5</bpmn2:incoming> + <bpmn2:outgoing>vnfFoundYes</bpmn2:outgoing> + <bpmn2:outgoing>vnfFoundNo</bpmn2:outgoing> + </bpmn2:exclusiveGateway> + <bpmn2:sequenceFlow id="vnfFoundYes" name="Yes" sourceRef="vnfFoundCheck" targetRef="ExclusiveGateway_2"> + <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression"><![CDATA[#{execution.getVariable("GENDV_FoundIndicator") == true}]]></bpmn2:conditionExpression> + </bpmn2:sequenceFlow> + <bpmn2:sequenceFlow id="vnfFoundNo" name="No" sourceRef="vnfFoundCheck" targetRef="EndEvent_3" /> + <bpmn2:exclusiveGateway id="ExclusiveGateway_2"> + <bpmn2:incoming>resourceVersionProvided</bpmn2:incoming> + <bpmn2:incoming>vnfFoundYes</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_6</bpmn2:outgoing> + </bpmn2:exclusiveGateway> + <bpmn2:sequenceFlow id="SequenceFlow_6" name="" sourceRef="ExclusiveGateway_2" targetRef="deleteVnf" /> + <bpmn2:endEvent id="EndEvent_1"> + <bpmn2:incoming>SequenceFlow_8</bpmn2:incoming> + <bpmn2:terminateEventDefinition id="_TerminateEventDefinition_39" /> + </bpmn2:endEvent> + </bpmn2:process> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="GenericDeleteVnf"> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_78" bpmnElement="StartEvent_1"> + <dc:Bounds x="74" y="216" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="92" y="257" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_310" bpmnElement="initialization"> + <dc:Bounds x="192" y="194" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_1" bpmnElement="SequenceFlow_1" sourceElement="_BPMNShape_StartEvent_78" targetElement="_BPMNShape_ScriptTask_310"> + <di:waypoint xsi:type="dc:Point" x="110" y="234" /> + <di:waypoint xsi:type="dc:Point" x="192" y="234" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_ExclusiveGateway_239" bpmnElement="resourceVersionCheck" isMarkerVisible="true"> + <dc:Bounds x="326" y="208" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="360" y="238" width="169" height="22" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_2" bpmnElement="SequenceFlow_2" sourceElement="_BPMNShape_ScriptTask_310" targetElement="_BPMNShape_ExclusiveGateway_239"> + <di:waypoint xsi:type="dc:Point" x="236" y="476" /> + <di:waypoint xsi:type="dc:Point" x="288" y="476" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="262" y="476" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_320" bpmnElement="queryForResourceVersion"> + <dc:Bounds x="408" y="96" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_321" bpmnElement="deleteVnf"> + <dc:Bounds x="658" y="194" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ExclusiveGateway_240" bpmnElement="ExclusiveGateway_2" isMarkerVisible="true"> + <dc:Bounds x="562" y="208" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="587" y="263" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_322" bpmnElement="toggleSuccess"> + <dc:Bounds x="802" y="194" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_EndEvent_240" bpmnElement="EndEvent_1"> + <dc:Bounds x="1001" y="216" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1019" y="257" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_3" bpmnElement="resourceVariableNotProvided" sourceElement="_BPMNShape_ExclusiveGateway_239" targetElement="_BPMNShape_ScriptTask_320"> + <di:waypoint xsi:type="dc:Point" x="351" y="208" /> + <di:waypoint xsi:type="dc:Point" x="351" y="136" /> + <di:waypoint xsi:type="dc:Point" x="408" y="136" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="354" y="165" width="22" height="22" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_4" bpmnElement="resourceVersionProvided" sourceElement="_BPMNShape_ExclusiveGateway_239" targetElement="_BPMNShape_ExclusiveGateway_240"> + <di:waypoint xsi:type="dc:Point" x="351" y="258" /> + <di:waypoint xsi:type="dc:Point" x="351" y="312" /> + <di:waypoint xsi:type="dc:Point" x="459" y="312" /> + <di:waypoint xsi:type="dc:Point" x="587" y="312" /> + <di:waypoint xsi:type="dc:Point" x="587" y="258" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="351" y="276" width="29" height="22" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_5" bpmnElement="SequenceFlow_5" sourceElement="_BPMNShape_ScriptTask_320" targetElement="_BPMNShape_ExclusiveGateway_242"> + <di:waypoint xsi:type="dc:Point" x="508" y="136" /> + <di:waypoint xsi:type="dc:Point" x="562" y="135" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="558" y="135" width="6" height="6" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_6" bpmnElement="SequenceFlow_6" sourceElement="_BPMNShape_ExclusiveGateway_240" targetElement="_BPMNShape_ScriptTask_321"> + <di:waypoint xsi:type="dc:Point" x="612" y="233" /> + <di:waypoint xsi:type="dc:Point" x="658" y="234" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="633" y="234" width="6" height="6" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_7" bpmnElement="SequenceFlow_7" sourceElement="_BPMNShape_ScriptTask_321" targetElement="_BPMNShape_ScriptTask_322"> + <di:waypoint xsi:type="dc:Point" x="758" y="234" /> + <di:waypoint xsi:type="dc:Point" x="802" y="234" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="777" y="234" width="6" height="6" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_8" bpmnElement="SequenceFlow_8" sourceElement="_BPMNShape_ScriptTask_322" targetElement="_BPMNShape_EndEvent_240"> + <di:waypoint xsi:type="dc:Point" x="902" y="234" /> + <di:waypoint xsi:type="dc:Point" x="1001" y="234" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="949" y="234" width="6" height="6" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_9" bpmnElement="SequenceFlow_9" sourceElement="_BPMNShape_ScriptTask_310" targetElement="_BPMNShape_ExclusiveGateway_239"> + <di:waypoint xsi:type="dc:Point" x="292" y="234" /> + <di:waypoint xsi:type="dc:Point" x="326" y="233" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="311" y="233" width="6" height="6" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_SubProcess_36" bpmnElement="bpmnExceptionHandlingSubProcess" isExpanded="true"> + <dc:Bounds x="185" y="397" width="304" height="157" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_82" bpmnElement="StartEvent_2"> + <dc:Bounds x="200" y="458" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="218" y="499" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_EndEvent_242" bpmnElement="EndEvent_2"> + <dc:Bounds x="440" y="458" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="458" y="499" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_323" bpmnElement="processBPMNError"> + <dc:Bounds x="288" y="436" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_10" bpmnElement="SequenceFlow_3" sourceElement="_BPMNShape_ScriptTask_323" targetElement="_BPMNShape_EndEvent_242"> + <di:waypoint xsi:type="dc:Point" x="388" y="476" /> + <di:waypoint xsi:type="dc:Point" x="440" y="476" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="414" y="476" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_ExclusiveGateway_242" bpmnElement="vnfFoundCheck" isMarkerVisible="true"> + <dc:Bounds x="562" y="110" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="552" y="90" width="72" height="22" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_EndEvent_243" bpmnElement="EndEvent_3"> + <dc:Bounds x="708" y="118" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="726" y="159" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_11" bpmnElement="vnfFoundYes" sourceElement="_BPMNShape_ExclusiveGateway_242" targetElement="_BPMNShape_ExclusiveGateway_240"> + <di:waypoint xsi:type="dc:Point" x="587" y="160" /> + <di:waypoint xsi:type="dc:Point" x="587" y="208" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="587" y="165" width="29" height="22" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_12" bpmnElement="vnfFoundNo" sourceElement="_BPMNShape_ExclusiveGateway_242" targetElement="_BPMNShape_EndEvent_243"> + <di:waypoint xsi:type="dc:Point" x="612" y="135" /> + <di:waypoint xsi:type="dc:Point" x="708" y="136" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="637" y="135" width="22" height="22" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn2:definitions>
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/GenericGetService.bpmn b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/GenericGetService.bpmn new file mode 100644 index 0000000000..af615e379d --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/GenericGetService.bpmn @@ -0,0 +1,321 @@ +<?xml version="1.0" encoding="UTF-8"?> +<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="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" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd" id="_D5VzAHElEeaJwpcpVN5gXw" exporter="camunda modeler" exporterVersion="2.7.0" targetNamespace="http://camunda.org/schema/1.0/bpmn"> + <bpmn2:process id="GenericGetService" name="GenericGetService" isExecutable="true"> + <bpmn2:scriptTask id="intialization" name="Initialization" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_1</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_2</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +GenericGetService getService = new GenericGetService() +getService.preProcessRequest(execution) +]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_2" name="" sourceRef="intialization" targetRef="getUrl"/> + <bpmn2:exclusiveGateway id="getUrl" name="Get Url?" default="getUrlNo"> + <bpmn2:incoming>SequenceFlow_2</bpmn2:incoming> + <bpmn2:outgoing>getUrlYes</bpmn2:outgoing> + <bpmn2:outgoing>getUrlNo</bpmn2:outgoing> + </bpmn2:exclusiveGateway> + <bpmn2:sequenceFlow id="getUrlYes" name="Yes" sourceRef="getUrl" targetRef="obtain"> + <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression"><![CDATA[#{execution.getVariable("GENGS_obtainServiceInstanceUrl" ) == true}]]></bpmn2:conditionExpression> + </bpmn2:sequenceFlow> + <bpmn2:sequenceFlow id="getUrlNo" name="No" sourceRef="getUrl" targetRef="ExclusiveGateway_2"/> + <bpmn2:subProcess id="bpmnExceptionHandlingSubProcess" name="Error Handling Sub Process" triggeredByEvent="true"> + <bpmn2:scriptTask id="processBPMNException" name="Process Error" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_7</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_8</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* + +ExceptionUtil ex = new ExceptionUtil() +ex.processSubflowsBPMNException(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_8" name="" sourceRef="processBPMNException" targetRef="EndEvent_2"/> + <bpmn2:startEvent id="StartEvent_2"> + <bpmn2:outgoing>SequenceFlow_7</bpmn2:outgoing> + <bpmn2:errorEventDefinition id="ErrorEventDefinition_1"/> + </bpmn2:startEvent> + <bpmn2:sequenceFlow id="SequenceFlow_7" name="" sourceRef="StartEvent_2" targetRef="processBPMNException"/> + <bpmn2:endEvent id="EndEvent_2"> + <bpmn2:incoming>SequenceFlow_8</bpmn2:incoming> + </bpmn2:endEvent> + </bpmn2:subProcess> + <bpmn2:scriptTask id="toggleSuccess" name="Toggle Success Indicator" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_3</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_6</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +GenericGetService getService = new GenericGetService() +getService.setSuccessIndicator(execution, true) +]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_6" name="" sourceRef="toggleSuccess" targetRef="EndEvent_1"/> + <bpmn2:scriptTask id="getServiceInstance" name="GET
Service Instance" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_5</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_3</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +GenericGetService getService = new GenericGetService() +getService.getServiceObject(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_3" name="" sourceRef="getServiceInstance" targetRef="toggleSuccess"/> + <bpmn2:exclusiveGateway id="ExclusiveGateway_2"> + <bpmn2:incoming>getUrlNo</bpmn2:incoming> + <bpmn2:incoming>foundYes</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_5</bpmn2:outgoing> + </bpmn2:exclusiveGateway> + <bpmn2:sequenceFlow id="SequenceFlow_5" name="" sourceRef="ExclusiveGateway_2" targetRef="getServiceInstance"/> + <bpmn2:scriptTask id="obtainServiceUrlById" name="Obtain Service URL Using
Id" scriptFormat="groovy"> + <bpmn2:incoming>obtainById</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_4</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +GenericGetService getService = new GenericGetService() +getService.obtainServiceInstanceUrlById(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_4" name="" sourceRef="obtainServiceUrlById" targetRef="ExclusiveGateway_3"/> + <bpmn2:scriptTask id="obtainServiceUrlByName" name="Obtain Service Url Using
Name" scriptFormat="groovy"> + <bpmn2:incoming>obtainByName</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_13</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +GenericGetService getService = new GenericGetService() +getService.obtainServiceInstanceUrlByName(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_13" name="" sourceRef="obtainServiceUrlByName" targetRef="ExclusiveGateway_3"/> + <bpmn2:exclusiveGateway id="obtain" name="Obtain By?" default="obtainById"> + <bpmn2:incoming>getUrlYes</bpmn2:incoming> + <bpmn2:outgoing>obtainById</bpmn2:outgoing> + <bpmn2:outgoing>obtainByName</bpmn2:outgoing> + </bpmn2:exclusiveGateway> + <bpmn2:sequenceFlow id="obtainById" name="Id" sourceRef="obtain" targetRef="obtainServiceUrlById"/> + <bpmn2:sequenceFlow id="obtainByName" name="Name" sourceRef="obtain" targetRef="obtainServiceUrlByName"> + <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression"><![CDATA[#{execution.getVariable("GENGS_obtainServiceInstanceUrlByName" ) == true}]]></bpmn2:conditionExpression> + </bpmn2:sequenceFlow> + <bpmn2:exclusiveGateway id="serviceFoundCheck" name="Service Exist?" default="notFound"> + <bpmn2:incoming>SequenceFlow_14</bpmn2:incoming> + <bpmn2:outgoing>foundYes</bpmn2:outgoing> + <bpmn2:outgoing>notFound</bpmn2:outgoing> + </bpmn2:exclusiveGateway> + <bpmn2:sequenceFlow id="foundYes" name="Yes" sourceRef="serviceFoundCheck" targetRef="ExclusiveGateway_2"> + <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression"><![CDATA[#{execution.getVariable("GENGS_FoundIndicator" ) == true}]]></bpmn2:conditionExpression> + </bpmn2:sequenceFlow> + <bpmn2:sequenceFlow id="notFound" name="No" sourceRef="serviceFoundCheck" targetRef="EndEvent_3"/> + <bpmn2:endEvent id="EndEvent_3"> + <bpmn2:incoming>notFound</bpmn2:incoming> + <bpmn2:terminateEventDefinition id="_TerminateEventDefinition_29"/> + </bpmn2:endEvent> + <bpmn2:exclusiveGateway id="ExclusiveGateway_3"> + <bpmn2:incoming>SequenceFlow_4</bpmn2:incoming> + <bpmn2:incoming>SequenceFlow_13</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_14</bpmn2:outgoing> + </bpmn2:exclusiveGateway> + <bpmn2:sequenceFlow id="SequenceFlow_14" name="" sourceRef="ExclusiveGateway_3" targetRef="serviceFoundCheck"/> + <bpmn2:endEvent id="EndEvent_1"> + <bpmn2:incoming>SequenceFlow_6</bpmn2:incoming> + <bpmn2:terminateEventDefinition id="_TerminateEventDefinition_26"/> + </bpmn2:endEvent> + <bpmn2:startEvent id="StartEvent_1"> + <bpmn2:outgoing>SequenceFlow_1</bpmn2:outgoing> + </bpmn2:startEvent> + <bpmn2:sequenceFlow id="SequenceFlow_1" name="" sourceRef="StartEvent_1" targetRef="intialization"/> + </bpmn2:process> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="GenericGetService"> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_69" bpmnElement="StartEvent_1"> + <dc:Bounds height="36.0" width="36.0" x="108.0" y="264.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="126.0" y="305.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_288" bpmnElement="intialization"> + <dc:Bounds height="80.0" width="100.0" x="228.0" y="242.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_1" bpmnElement="SequenceFlow_1" sourceElement="_BPMNShape_StartEvent_69" targetElement="_BPMNShape_ScriptTask_288"> + <di:waypoint xsi:type="dc:Point" x="144.0" y="282.0"/> + <di:waypoint xsi:type="dc:Point" x="228.0" y="282.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="177.0" y="282.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_ExclusiveGateway_227" bpmnElement="getUrl" isMarkerVisible="true"> + <dc:Bounds height="50.0" width="50.0" x="372.0" y="256.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="22.0" width="70.0" x="408.0" y="286.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_2" bpmnElement="SequenceFlow_2" sourceElement="_BPMNShape_ScriptTask_288" targetElement="_BPMNShape_ExclusiveGateway_227"> + <di:waypoint xsi:type="dc:Point" x="328.0" y="282.0"/> + <di:waypoint xsi:type="dc:Point" x="372.0" y="281.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="350.0" y="281.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_289" bpmnElement="obtainServiceUrlById"> + <dc:Bounds height="80.0" width="100.0" x="528.0" y="197.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ExclusiveGateway_228" bpmnElement="ExclusiveGateway_2" isMarkerVisible="true"> + <dc:Bounds height="50.0" width="50.0" x="738.0" y="256.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="763.0" y="311.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_290" bpmnElement="getServiceInstance"> + <dc:Bounds height="80.0" width="100.0" x="820.0" y="242.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_3" bpmnElement="getUrlYes" sourceElement="_BPMNShape_ExclusiveGateway_227" targetElement="_BPMNShape_ExclusiveGateway_233"> + <di:waypoint xsi:type="dc:Point" x="397.0" y="256.0"/> + <di:waypoint xsi:type="dc:Point" x="397.0" y="170.0"/> + <di:waypoint xsi:type="dc:Point" x="446.0" y="170.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="22.0" width="29.0" x="397.0" y="213.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_4" bpmnElement="SequenceFlow_4" sourceElement="_BPMNShape_ScriptTask_289" targetElement="_BPMNShape_ExclusiveGateway_234"> + <di:waypoint xsi:type="dc:Point" x="628.0" y="237.0"/> + <di:waypoint xsi:type="dc:Point" x="671.0" y="237.0"/> + <di:waypoint xsi:type="dc:Point" x="671.0" y="195.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="668.0" y="221.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_5" bpmnElement="SequenceFlow_5" sourceElement="_BPMNShape_ExclusiveGateway_228" targetElement="_BPMNShape_ScriptTask_290"> + <di:waypoint xsi:type="dc:Point" x="788.0" y="281.0"/> + <di:waypoint xsi:type="dc:Point" x="820.0" y="282.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="798.0" y="281.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_6" bpmnElement="getUrlNo" sourceElement="_BPMNShape_ExclusiveGateway_227" targetElement="_BPMNShape_ExclusiveGateway_228"> + <di:waypoint xsi:type="dc:Point" x="397.0" y="306.0"/> + <di:waypoint xsi:type="dc:Point" x="397.0" y="370.0"/> + <di:waypoint xsi:type="dc:Point" x="763.0" y="370.0"/> + <di:waypoint xsi:type="dc:Point" x="763.0" y="306.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="22.0" width="22.0" x="400.0" y="324.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_291" bpmnElement="toggleSuccess"> + <dc:Bounds height="80.0" width="100.0" x="960.0" y="242.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_7" bpmnElement="SequenceFlow_3" sourceElement="_BPMNShape_ScriptTask_290" targetElement="_BPMNShape_ScriptTask_291"> + <di:waypoint xsi:type="dc:Point" x="920.0" y="282.0"/> + <di:waypoint xsi:type="dc:Point" x="960.0" y="282.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="937.0" y="282.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_EndEvent_223" bpmnElement="EndEvent_1"> + <dc:Bounds height="36.0" width="36.0" x="1133.0" y="264.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="1151.0" y="305.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_8" bpmnElement="SequenceFlow_6" sourceElement="_BPMNShape_ScriptTask_291" targetElement="_BPMNShape_EndEvent_223"> + <di:waypoint xsi:type="dc:Point" x="1060.0" y="282.0"/> + <di:waypoint xsi:type="dc:Point" x="1133.0" y="282.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="1100.0" y="282.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_SubProcess_25" bpmnElement="bpmnExceptionHandlingSubProcess" isExpanded="true"> + <dc:Bounds height="169.0" width="325.0" x="152.0" y="468.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_70" bpmnElement="StartEvent_2"> + <dc:Bounds height="36.0" width="36.0" x="176.0" y="535.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="194.0" y="576.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_EndEvent_224" bpmnElement="EndEvent_2"> + <dc:Bounds height="36.0" width="36.0" x="416.0" y="535.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="434.0" y="576.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_292" bpmnElement="processBPMNException"> + <dc:Bounds height="80.0" width="100.0" x="265.0" y="513.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_9" bpmnElement="SequenceFlow_7" sourceElement="_BPMNShape_StartEvent_70" targetElement="_BPMNShape_ScriptTask_292"> + <di:waypoint xsi:type="dc:Point" x="212.0" y="553.0"/> + <di:waypoint xsi:type="dc:Point" x="265.0" y="553.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="233.0" y="553.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_10" bpmnElement="SequenceFlow_8" sourceElement="_BPMNShape_ScriptTask_292" targetElement="_BPMNShape_EndEvent_224"> + <di:waypoint xsi:type="dc:Point" x="365.0" y="553.0"/> + <di:waypoint xsi:type="dc:Point" x="416.0" y="553.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="385.0" y="553.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_301" bpmnElement="obtainServiceUrlByName"> + <dc:Bounds height="80.0" width="100.0" x="528.0" y="59.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ExclusiveGateway_233" bpmnElement="obtain" isMarkerVisible="true"> + <dc:Bounds height="50.0" width="50.0" x="446.0" y="145.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="22.0" width="71.0" x="496.0" y="162.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ExclusiveGateway_234" bpmnElement="ExclusiveGateway_3" isMarkerVisible="true"> + <dc:Bounds height="50.0" width="50.0" x="646.0" y="145.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="671.0" y="200.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_13" bpmnElement="obtainById" sourceElement="_BPMNShape_ExclusiveGateway_233" targetElement="_BPMNShape_ScriptTask_289"> + <di:waypoint xsi:type="dc:Point" x="471.0" y="195.0"/> + <di:waypoint xsi:type="dc:Point" x="471.0" y="236.0"/> + <di:waypoint xsi:type="dc:Point" x="528.0" y="237.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="22.0" width="16.0" x="476.0" y="207.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_14" bpmnElement="obtainByName" sourceElement="_BPMNShape_ExclusiveGateway_233" targetElement="_BPMNShape_ScriptTask_301"> + <di:waypoint xsi:type="dc:Point" x="471.0" y="145.0"/> + <di:waypoint xsi:type="dc:Point" x="471.0" y="99.0"/> + <di:waypoint xsi:type="dc:Point" x="528.0" y="99.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="22.0" width="40.0" x="471.0" y="115.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_15" bpmnElement="SequenceFlow_13" sourceElement="_BPMNShape_ScriptTask_301" targetElement="_BPMNShape_ExclusiveGateway_234"> + <di:waypoint xsi:type="dc:Point" x="628.0" y="99.0"/> + <di:waypoint xsi:type="dc:Point" x="671.0" y="99.0"/> + <di:waypoint xsi:type="dc:Point" x="671.0" y="145.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="665.0" y="99.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_ExclusiveGateway_235" bpmnElement="serviceFoundCheck" isMarkerVisible="true"> + <dc:Bounds height="50.0" width="50.0" x="738.0" y="145.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="22.0" width="59.0" x="735.0" y="125.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_16" bpmnElement="SequenceFlow_14" sourceElement="_BPMNShape_ExclusiveGateway_234" targetElement="_BPMNShape_ExclusiveGateway_235"> + <di:waypoint xsi:type="dc:Point" x="696.0" y="170.0"/> + <di:waypoint xsi:type="dc:Point" x="738.0" y="170.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="704.0" y="170.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_17" bpmnElement="foundYes" sourceElement="_BPMNShape_ExclusiveGateway_235" targetElement="_BPMNShape_ExclusiveGateway_228"> + <di:waypoint xsi:type="dc:Point" x="763.0" y="195.0"/> + <di:waypoint xsi:type="dc:Point" x="763.0" y="256.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="22.0" width="29.0" x="762.0" y="205.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_18" bpmnElement="notFound" sourceElement="_BPMNShape_ExclusiveGateway_235" targetElement="_BPMNShape_EndEvent_229"> + <di:waypoint xsi:type="dc:Point" x="788.0" y="170.0"/> + <di:waypoint xsi:type="dc:Point" x="877.0" y="171.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="22.0" width="22.0" x="798.0" y="170.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_EndEvent_229" bpmnElement="EndEvent_3"> + <dc:Bounds height="36.0" width="36.0" x="877.0" y="153.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="895.0" y="194.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn2:definitions>
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/GenericGetVnf.bpmn b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/GenericGetVnf.bpmn new file mode 100644 index 0000000000..db0d35d9ce --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/GenericGetVnf.bpmn @@ -0,0 +1,212 @@ +<?xml version="1.0" encoding="UTF-8"?> +<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="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" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd" id="_eb5eEHR6EeaJwpcpVN5gXw" exporter="camunda modeler" exporterVersion="2.7.0" targetNamespace="http://camunda.org/schema/1.0/bpmn"> + <bpmn2:process id="GenericGetVnf" name="GenericGetVnf" isExecutable="true"> + <bpmn2:startEvent id="StartEvent_1"> + <bpmn2:outgoing>SequenceFlow_1</bpmn2:outgoing> + </bpmn2:startEvent> + <bpmn2:scriptTask id="intialization" name="Intialization" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_1</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_2</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +GenericGetVnf genericGetVnf = new GenericGetVnf () +genericGetVnf.preProcessRequest(execution) +]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_1" name="" sourceRef="StartEvent_1" targetRef="intialization"/> + <bpmn2:sequenceFlow id="SequenceFlow_2" name="" sourceRef="intialization" targetRef="vnfIdProvided"/> + <bpmn2:exclusiveGateway id="vnfIdProvided" name="Vnf Id Provided?" default="noVnfId"> + <bpmn2:incoming>SequenceFlow_2</bpmn2:incoming> + <bpmn2:outgoing>noVnfId</bpmn2:outgoing> + <bpmn2:outgoing>haveVnfId</bpmn2:outgoing> + </bpmn2:exclusiveGateway> + <bpmn2:sequenceFlow id="noVnfId" name="No" sourceRef="vnfIdProvided" targetRef="getVnfByName"/> + <bpmn2:sequenceFlow id="haveVnfId" name="Yes" sourceRef="vnfIdProvided" targetRef="getGenericVnf"> + <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression"><![CDATA[#{execution.getVariable("GENGV_getVnfByName") == false}]]></bpmn2:conditionExpression> + </bpmn2:sequenceFlow> + <bpmn2:scriptTask id="getVnfByName" name="GET Vnf By Name" scriptFormat="groovy"> + <bpmn2:incoming>noVnfId</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_9</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +GenericGetVnf genericGetVnf = new GenericGetVnf() +genericGetVnf.getVnfByName(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_9" name="" sourceRef="getVnfByName" targetRef="ExclusiveGateway_2"/> + <bpmn2:exclusiveGateway id="ExclusiveGateway_2"> + <bpmn2:incoming>SequenceFlow_9</bpmn2:incoming> + <bpmn2:incoming>SequenceFlow_10</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_7</bpmn2:outgoing> + </bpmn2:exclusiveGateway> + <bpmn2:sequenceFlow id="SequenceFlow_7" name="" sourceRef="ExclusiveGateway_2" targetRef="toggleSuccess"/> + <bpmn2:scriptTask id="getGenericVnf" name="GET Vnf By
Id" scriptFormat="groovy"> + <bpmn2:incoming>haveVnfId</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_10</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +GenericGetVnf genericGetVnf = new GenericGetVnf() +genericGetVnf.getVnfById(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_10" name="" sourceRef="getGenericVnf" targetRef="ExclusiveGateway_2"/> + <bpmn2:subProcess id="bpmnExceptionHandlingSubProcess" name="Error Handling Sub Process" triggeredByEvent="true"> + <bpmn2:endEvent id="EndEvent_3"> + <bpmn2:incoming>SequenceFlow_12</bpmn2:incoming> + <bpmn2:terminateEventDefinition id="_TerminateEventDefinition_31"/> + </bpmn2:endEvent> + <bpmn2:scriptTask id="proccessBPMNError" name="Process Error" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_11</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_12</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* + +ExceptionUtil ex = new ExceptionUtil() +ex.processSubflowsBPMNException(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_12" name="" sourceRef="proccessBPMNError" targetRef="EndEvent_3"/> + <bpmn2:startEvent id="catchMSOWorkflowException"> + <bpmn2:outgoing>SequenceFlow_11</bpmn2:outgoing> + <bpmn2:errorEventDefinition id="ErrorEventDefinition_1"/> + </bpmn2:startEvent> + <bpmn2:sequenceFlow id="SequenceFlow_11" name="" sourceRef="catchMSOWorkflowException" targetRef="proccessBPMNError"/> + </bpmn2:subProcess> + <bpmn2:scriptTask id="toggleSuccess" name="Toggle Success Indicator" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_7</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_8</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +GenericGetVnf genericGetVnf = new GenericGetVnf() +genericGetVnf.setSuccessIndicator(execution, true) +]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_8" name="" sourceRef="toggleSuccess" targetRef="EndEvent_1"/> + <bpmn2:endEvent id="EndEvent_1"> + <bpmn2:incoming>SequenceFlow_8</bpmn2:incoming> + <bpmn2:terminateEventDefinition id="_TerminateEventDefinition_28"/> + </bpmn2:endEvent> + </bpmn2:process> + <bpmn2:error id="Error_1" errorCode="MSOWorkflowException" name="MSO Workflow Exception"/> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="GenericGetVnf"> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_71" bpmnElement="StartEvent_1"> + <dc:Bounds height="36.0" width="36.0" x="110.0" y="271.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="128.0" y="312.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_295" bpmnElement="intialization"> + <dc:Bounds height="80.0" width="100.0" x="228.0" y="249.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ExclusiveGateway_230" bpmnElement="vnfIdProvided" isMarkerVisible="true"> + <dc:Bounds height="50.0" width="50.0" x="372.0" y="263.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="22.0" width="99.0" x="419.0" y="292.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_1" bpmnElement="SequenceFlow_1" sourceElement="_BPMNShape_StartEvent_71" targetElement="_BPMNShape_ScriptTask_295"> + <di:waypoint xsi:type="dc:Point" x="146.0" y="289.0"/> + <di:waypoint xsi:type="dc:Point" x="228.0" y="289.0"/> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_2" bpmnElement="SequenceFlow_2" sourceElement="_BPMNShape_ScriptTask_295" targetElement="_BPMNShape_ExclusiveGateway_230"> + <di:waypoint xsi:type="dc:Point" x="328.0" y="289.0"/> + <di:waypoint xsi:type="dc:Point" x="372.0" y="288.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="347.0" y="288.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_296" bpmnElement="getVnfByName"> + <dc:Bounds height="80.0" width="100.0" x="456.0" y="156.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ExclusiveGateway_231" bpmnElement="ExclusiveGateway_2" isMarkerVisible="true"> + <dc:Bounds height="50.0" width="50.0" x="600.0" y="263.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="625.0" y="318.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_3" bpmnElement="noVnfId" sourceElement="_BPMNShape_ExclusiveGateway_230" targetElement="_BPMNShape_ScriptTask_296"> + <di:waypoint xsi:type="dc:Point" x="397.0" y="263.0"/> + <di:waypoint xsi:type="dc:Point" x="397.0" y="196.0"/> + <di:waypoint xsi:type="dc:Point" x="456.0" y="196.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="22.0" width="22.0" x="399.0" y="219.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_5" bpmnElement="haveVnfId" sourceElement="_BPMNShape_ExclusiveGateway_230" targetElement="_BPMNShape_ScriptTask_297"> + <di:waypoint xsi:type="dc:Point" x="397.0" y="313.0"/> + <di:waypoint xsi:type="dc:Point" x="397.0" y="368.0"/> + <di:waypoint xsi:type="dc:Point" x="456.0" y="368.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="22.0" width="29.0" x="396.0" y="328.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_297" bpmnElement="getGenericVnf"> + <dc:Bounds height="80.0" width="100.0" x="456.0" y="328.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_298" bpmnElement="toggleSuccess"> + <dc:Bounds height="80.0" width="100.0" x="696.0" y="249.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_EndEvent_226" bpmnElement="EndEvent_1"> + <dc:Bounds height="36.0" width="36.0" x="888.0" y="271.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="906.0" y="312.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_7" bpmnElement="SequenceFlow_7" sourceElement="_BPMNShape_ExclusiveGateway_231" targetElement="_BPMNShape_ScriptTask_298"> + <di:waypoint xsi:type="dc:Point" x="650.0" y="288.0"/> + <di:waypoint xsi:type="dc:Point" x="696.0" y="289.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="673.0" y="289.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_8" bpmnElement="SequenceFlow_8" sourceElement="_BPMNShape_ScriptTask_298" targetElement="_BPMNShape_EndEvent_226"> + <di:waypoint xsi:type="dc:Point" x="796.0" y="289.0"/> + <di:waypoint xsi:type="dc:Point" x="888.0" y="289.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="829.0" y="289.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_11" bpmnElement="SequenceFlow_9" sourceElement="_BPMNShape_ScriptTask_296" targetElement="_BPMNShape_ExclusiveGateway_231"> + <di:waypoint xsi:type="dc:Point" x="556.0" y="196.0"/> + <di:waypoint xsi:type="dc:Point" x="625.0" y="196.0"/> + <di:waypoint xsi:type="dc:Point" x="625.0" y="263.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="622.0" y="205.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_12" bpmnElement="SequenceFlow_10" sourceElement="_BPMNShape_ScriptTask_297" targetElement="_BPMNShape_ExclusiveGateway_231"> + <di:waypoint xsi:type="dc:Point" x="556.0" y="368.0"/> + <di:waypoint xsi:type="dc:Point" x="625.0" y="368.0"/> + <di:waypoint xsi:type="dc:Point" x="625.0" y="313.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="621.0" y="368.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_SubProcess_30" bpmnElement="bpmnExceptionHandlingSubProcess" isExpanded="true"> + <dc:Bounds height="169.0" width="313.0" x="168.0" y="468.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_74" bpmnElement="catchMSOWorkflowException"> + <dc:Bounds height="36.0" width="36.0" x="180.0" y="535.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="198.0" y="576.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_302" bpmnElement="proccessBPMNError"> + <dc:Bounds height="80.0" width="100.0" x="275.0" y="513.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_EndEvent_231" bpmnElement="EndEvent_3"> + <dc:Bounds height="36.0" width="36.0" x="432.0" y="535.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="450.0" y="576.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_13" bpmnElement="SequenceFlow_11" sourceElement="_BPMNShape_StartEvent_74" targetElement="_BPMNShape_ScriptTask_302"> + <di:waypoint xsi:type="dc:Point" x="216.0" y="553.0"/> + <di:waypoint xsi:type="dc:Point" x="275.0" y="553.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="238.0" y="553.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_14" bpmnElement="SequenceFlow_12" sourceElement="_BPMNShape_ScriptTask_302" targetElement="_BPMNShape_EndEvent_231"> + <di:waypoint xsi:type="dc:Point" x="375.0" y="553.0"/> + <di:waypoint xsi:type="dc:Point" x="432.0" y="553.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="402.0" y="553.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn2:definitions>
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/GenericPutService.bpmn b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/GenericPutService.bpmn new file mode 100644 index 0000000000..8c8412dcac --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/GenericPutService.bpmn @@ -0,0 +1,201 @@ +<?xml version="1.0" encoding="UTF-8"?> +<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="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" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd" id="_FatVcHn0EeaH6vX1RRdc_w" exporter="camunda modeler" exporterVersion="2.7.0" targetNamespace="http://camunda.org/schema/1.0/bpmn"> + <bpmn2:process id="GenericPutService" name="GenericPutService" isExecutable="true"> + <bpmn2:startEvent id="StartEvent_1"> + <bpmn2:outgoing>SequenceFlow_1</bpmn2:outgoing> + </bpmn2:startEvent> + <bpmn2:sequenceFlow id="SequenceFlow_1" name="" sourceRef="StartEvent_1" targetRef="Initialization"/> + <bpmn2:endEvent id="EndEvent_1"> + <bpmn2:incoming>SequenceFlow_5</bpmn2:incoming> + <bpmn2:terminateEventDefinition id="TerminateEventDefinition_1"/> + </bpmn2:endEvent> + <bpmn2:scriptTask id="toggleSuccess" name="Toggle Success Indicator" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_4</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_5</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* + +def serviceInstance= new GenericPutService() +serviceInstance.setSuccessIndicator(execution, true) + +execution.setVariable("WorkflowResponse", " ") //for junits]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_5" name="" sourceRef="toggleSuccess" targetRef="EndEvent_1"/> + <bpmn2:scriptTask id="putServiceInstance" name="Put Service Instance" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_3</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_4</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* + +def serviceInstance= new GenericPutService() +serviceInstance.putServiceInstance(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_4" name="" sourceRef="putServiceInstance" targetRef="toggleSuccess"/> + <bpmn2:scriptTask id="Initialization" name="Initialization" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_1</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_3</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* + +def serviceInstance= new GenericPutService() +serviceInstance.preProcessRequest(execution) +]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_3" name="" sourceRef="Initialization" targetRef="putServiceInstance"/> + <bpmn2:subProcess id="bpmnExceptionHandlingSubProcess" name="Error Handling Sub Process" triggeredByEvent="true"> + <bpmn2:startEvent id="StartEvent_2"> + <bpmn2:outgoing>SequenceFlow_6</bpmn2:outgoing> + <bpmn2:errorEventDefinition id="ErrorEventDefinition_1"/> + </bpmn2:startEvent> + <bpmn2:sequenceFlow id="SequenceFlow_6" name="" sourceRef="StartEvent_2" targetRef="processError"/> + <bpmn2:endEvent id="EndEvent_2"> + <bpmn2:incoming>SequenceFlow_7</bpmn2:incoming> + </bpmn2:endEvent> + <bpmn2:scriptTask id="processError" name="Process Error" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_6</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_7</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* + +ExceptionUtil ex = new ExceptionUtil() +ex.processSubflowsBPMNException(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_7" name="" sourceRef="processError" targetRef="EndEvent_2"/> + </bpmn2:subProcess> + <bpmn2:subProcess id="javaExceptionSubProcess" name="Java Exception Handling Sub Process" triggeredByEvent="true"> + <bpmn2:startEvent id="catchJavaExcep"> + <bpmn2:outgoing>SequenceFlow_9</bpmn2:outgoing> + <bpmn2:errorEventDefinition id="ErrorEventDefinition_2" errorRef="Error_2"/> + </bpmn2:startEvent> + <bpmn2:sequenceFlow id="SequenceFlow_9" name="" sourceRef="catchJavaExcep" targetRef="processJavaError"/> + <bpmn2:scriptTask id="processJavaError" name="Process Java Error" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_9</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_10</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* + +ExceptionUtil ex = new ExceptionUtil() +ex.processSubflowsJavaException(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:endEvent id="EndEvent_3"> + <bpmn2:incoming>SequenceFlow_10</bpmn2:incoming> + <bpmn2:terminateEventDefinition id="TerminateEventDefinition_2"/> + </bpmn2:endEvent> + <bpmn2:sequenceFlow id="SequenceFlow_10" name="" sourceRef="processJavaError" targetRef="EndEvent_3"/> + </bpmn2:subProcess> + </bpmn2:process> + <bpmn2:error id="Error_1" errorCode="MSOWorkflowException" name="MSO Workflow Exception"/> + <bpmn2:error id="Error_2" errorCode="java.lang.Exception" name="Java Lang Exception"/> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="GenericPutService"> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_71" bpmnElement="StartEvent_1"> + <dc:Bounds height="36.0" width="36.0" x="182.0" y="180.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="200.0" y="221.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_302" bpmnElement="Initialization"> + <dc:Bounds height="80.0" width="100.0" x="324.0" y="158.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_1" bpmnElement="SequenceFlow_1" sourceElement="_BPMNShape_StartEvent_71" targetElement="_BPMNShape_ScriptTask_302"> + <di:waypoint xsi:type="dc:Point" x="218.0" y="198.0"/> + <di:waypoint xsi:type="dc:Point" x="324.0" y="198.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="250.0" y="198.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_304" bpmnElement="putServiceInstance"> + <dc:Bounds height="80.0" width="100.0" x="528.0" y="158.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_3" bpmnElement="SequenceFlow_3" sourceElement="_BPMNShape_ScriptTask_302" targetElement="_BPMNShape_ScriptTask_304"> + <di:waypoint xsi:type="dc:Point" x="424.0" y="198.0"/> + <di:waypoint xsi:type="dc:Point" x="528.0" y="198.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="446.0" y="198.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_305" bpmnElement="toggleSuccess"> + <dc:Bounds height="80.0" width="100.0" x="732.0" y="158.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_4" bpmnElement="SequenceFlow_4" sourceElement="_BPMNShape_ScriptTask_304" targetElement="_BPMNShape_ScriptTask_305"> + <di:waypoint xsi:type="dc:Point" x="628.0" y="198.0"/> + <di:waypoint xsi:type="dc:Point" x="732.0" y="198.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="650.0" y="198.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_EndEvent_230" bpmnElement="EndEvent_1"> + <dc:Bounds height="36.0" width="36.0" x="908.0" y="180.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="926.0" y="221.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_5" bpmnElement="SequenceFlow_5" sourceElement="_BPMNShape_ScriptTask_305" targetElement="_BPMNShape_EndEvent_230"> + <di:waypoint xsi:type="dc:Point" x="832.0" y="198.0"/> + <di:waypoint xsi:type="dc:Point" x="908.0" y="198.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="854.0" y="198.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_SubProcess_27" bpmnElement="bpmnExceptionHandlingSubProcess" isExpanded="true"> + <dc:Bounds height="150.0" width="418.0" x="324.0" y="312.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_72" bpmnElement="StartEvent_2"> + <dc:Bounds height="36.0" width="36.0" x="357.0" y="370.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="375.0" y="411.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_306" bpmnElement="processError"> + <dc:Bounds height="80.0" width="100.0" x="466.0" y="348.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_6" bpmnElement="SequenceFlow_6" sourceElement="_BPMNShape_StartEvent_72" targetElement="_BPMNShape_ScriptTask_306"> + <di:waypoint xsi:type="dc:Point" x="393.0" y="388.0"/> + <di:waypoint xsi:type="dc:Point" x="466.0" y="388.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="415.0" y="388.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_EndEvent_231" bpmnElement="EndEvent_2"> + <dc:Bounds height="36.0" width="36.0" x="615.0" y="370.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="633.0" y="411.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_7" bpmnElement="SequenceFlow_7" sourceElement="_BPMNShape_ScriptTask_306" targetElement="_BPMNShape_EndEvent_231"> + <di:waypoint xsi:type="dc:Point" x="566.0" y="388.0"/> + <di:waypoint xsi:type="dc:Point" x="615.0" y="388.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="588.0" y="388.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_SubProcess_28" bpmnElement="javaExceptionSubProcess" isExpanded="true"> + <dc:Bounds height="150.0" width="419.0" x="323.0" y="486.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_73" bpmnElement="catchJavaExcep"> + <dc:Bounds height="36.0" width="36.0" x="357.0" y="538.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="375.0" y="579.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_308" bpmnElement="processJavaError"> + <dc:Bounds height="80.0" width="100.0" x="465.0" y="516.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_9" bpmnElement="SequenceFlow_9" sourceElement="_BPMNShape_StartEvent_73" targetElement="_BPMNShape_ScriptTask_308"> + <di:waypoint xsi:type="dc:Point" x="393.0" y="556.0"/> + <di:waypoint xsi:type="dc:Point" x="465.0" y="556.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="415.0" y="556.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_EndEvent_232" bpmnElement="EndEvent_3"> + <dc:Bounds height="36.0" width="36.0" x="615.0" y="538.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="633.0" y="579.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_10" bpmnElement="SequenceFlow_10" sourceElement="_BPMNShape_ScriptTask_308" targetElement="_BPMNShape_EndEvent_232"> + <di:waypoint xsi:type="dc:Point" x="565.0" y="556.0"/> + <di:waypoint xsi:type="dc:Point" x="615.0" y="556.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="587.0" y="556.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn2:definitions>
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/GenericPutVnf.bpmn b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/GenericPutVnf.bpmn new file mode 100644 index 0000000000..bb73c09619 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/GenericPutVnf.bpmn @@ -0,0 +1,135 @@ +<?xml version="1.0" encoding="UTF-8"?> +<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="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" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd" id="_ZkRI4HntEea26OhQB97uCQ" exporter="camunda modeler" exporterVersion="2.7.0" targetNamespace="http://camunda.org/schema/1.0/bpmn"> + <bpmn2:process id="GenericPutVnf" name="GenericPutVnf" isExecutable="true"> + <bpmn2:startEvent id="StartEvent_1"> + <bpmn2:outgoing>SequenceFlow_1</bpmn2:outgoing> + </bpmn2:startEvent> + <bpmn2:scriptTask id="intialization" name="Intialization" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_1</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_2</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +GenericPutVnf genericPutVnf = new GenericPutVnf() +genericPutVnf.preProcessRequest(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_1" name="" sourceRef="StartEvent_1" targetRef="intialization"/> + <bpmn2:sequenceFlow id="SequenceFlow_2" name="" sourceRef="intialization" targetRef="putVnf"/> + <bpmn2:subProcess id="processBPMNExceptionSubProcess" name="Error Handling Sub Process" triggeredByEvent="true"> + <bpmn2:endEvent id="EndEvent_2"> + <bpmn2:incoming>SequenceFlow_6</bpmn2:incoming> + <bpmn2:terminateEventDefinition id="_TerminateEventDefinition_43"/> + </bpmn2:endEvent> + <bpmn2:startEvent id="StartEvent_2"> + <bpmn2:outgoing>SequenceFlow_5</bpmn2:outgoing> + <bpmn2:errorEventDefinition id="_ErrorEventDefinition_96"/> + </bpmn2:startEvent> + <bpmn2:scriptTask id="processBPMNException" name="Process Error" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_5</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_6</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* + +ExceptionUtil ex = new ExceptionUtil() +ex.processSubflowsBPMNException(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_5" name="" sourceRef="StartEvent_2" targetRef="processBPMNException"/> + <bpmn2:sequenceFlow id="SequenceFlow_6" name="" sourceRef="processBPMNException" targetRef="EndEvent_2"/> + </bpmn2:subProcess> + <bpmn2:scriptTask id="putVnf" name="PUT Vnf" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_2</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_3</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +GenericPutVnf genericPutVnf = new GenericPutVnf() +genericPutVnf.putVnf(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_3" name="" sourceRef="putVnf" targetRef="toggleSuccess"/> + <bpmn2:scriptTask id="toggleSuccess" name="Toggle Success Indicator" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_3</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_4</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +GenericPutVnf genericPutVnf = new GenericPutVnf() +genericPutVnf.setSuccessIndicator(execution, true) + +execution.setVariable("WorkflowResponse", " ") //for junits]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_4" name="" sourceRef="toggleSuccess" targetRef="EndEvent_1"/> + <bpmn2:endEvent id="EndEvent_1"> + <bpmn2:incoming>SequenceFlow_4</bpmn2:incoming> + <bpmn2:terminateEventDefinition id="_TerminateEventDefinition_42"/> + </bpmn2:endEvent> + </bpmn2:process> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="GenericPutVnf"> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_75" bpmnElement="StartEvent_1"> + <dc:Bounds height="36.0" width="36.0" x="116.0" y="233.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="134.0" y="274.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_305" bpmnElement="intialization"> + <dc:Bounds height="80.0" width="100.0" x="240.0" y="211.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_306" bpmnElement="putVnf"> + <dc:Bounds height="80.0" width="100.0" x="384.0" y="211.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_307" bpmnElement="toggleSuccess"> + <dc:Bounds height="80.0" width="100.0" x="528.0" y="211.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_EndEvent_233" bpmnElement="EndEvent_1"> + <dc:Bounds height="36.0" width="36.0" x="732.0" y="233.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="750.0" y="274.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_1" bpmnElement="SequenceFlow_1" sourceElement="_BPMNShape_StartEvent_75" targetElement="_BPMNShape_ScriptTask_305"> + <di:waypoint xsi:type="dc:Point" x="152.0" y="251.0"/> + <di:waypoint xsi:type="dc:Point" x="240.0" y="251.0"/> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_2" bpmnElement="SequenceFlow_2" sourceElement="_BPMNShape_ScriptTask_305" targetElement="_BPMNShape_ScriptTask_306"> + <di:waypoint xsi:type="dc:Point" x="340.0" y="251.0"/> + <di:waypoint xsi:type="dc:Point" x="384.0" y="251.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="365.0" y="251.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_3" bpmnElement="SequenceFlow_3" sourceElement="_BPMNShape_ScriptTask_306" targetElement="_BPMNShape_ScriptTask_307"> + <di:waypoint xsi:type="dc:Point" x="484.0" y="251.0"/> + <di:waypoint xsi:type="dc:Point" x="528.0" y="251.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="513.0" y="251.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_4" bpmnElement="SequenceFlow_4" sourceElement="_BPMNShape_ScriptTask_307" targetElement="_BPMNShape_EndEvent_233"> + <di:waypoint xsi:type="dc:Point" x="628.0" y="251.0"/> + <di:waypoint xsi:type="dc:Point" x="732.0" y="251.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="678.0" y="251.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_SubProcess_31" bpmnElement="processBPMNExceptionSubProcess" isExpanded="true"> + <dc:Bounds height="169.0" width="322.0" x="174.0" y="396.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_83" bpmnElement="StartEvent_2"> + <dc:Bounds height="36.0" width="36.0" x="204.0" y="463.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="222.0" y="504.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_EndEvent_244" bpmnElement="EndEvent_2"> + <dc:Bounds height="36.0" width="36.0" x="432.0" y="463.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="450.0" y="504.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_324" bpmnElement="processBPMNException"> + <dc:Bounds height="80.0" width="100.0" x="286.0" y="441.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_5" bpmnElement="SequenceFlow_5" sourceElement="_BPMNShape_StartEvent_83" targetElement="_BPMNShape_ScriptTask_324"> + <di:waypoint xsi:type="dc:Point" x="240.0" y="481.0"/> + <di:waypoint xsi:type="dc:Point" x="286.0" y="481.0"/> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_6" bpmnElement="SequenceFlow_6" sourceElement="_BPMNShape_ScriptTask_324" targetElement="_BPMNShape_EndEvent_244"> + <di:waypoint xsi:type="dc:Point" x="386.0" y="481.0"/> + <di:waypoint xsi:type="dc:Point" x="432.0" y="481.0"/> + </bpmndi:BPMNEdge> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn2:definitions>
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/PrepareUpdateAAIVfModule.bpmn b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/PrepareUpdateAAIVfModule.bpmn new file mode 100644 index 0000000000..956192c5af --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/PrepareUpdateAAIVfModule.bpmn @@ -0,0 +1,308 @@ +<?xml version="1.0" encoding="UTF-8"?> +<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd" id="_Wblj8GyfEeWUWLTvug7ZOg" exporter="camunda modeler" exporterVersion="2.7.0" targetNamespace="http://camunda.org/schema/1.0/bpmn"> + <bpmn2:process id="PrepareUpdateAAIVfModule" name="PrepareUpdateAAIVfModule" isExecutable="true"> + <bpmn2:documentation><![CDATA[This flow expects its incoming request to be in the variable 'PrepareUpdateAAIVfModuleRequest'. This flow has 2 outputs: The heat stack ID is placed in the variable 'PUAAIVfMod_heatStackId'. +and the updated VF Module (type=VfModule) is placed in the variable 'PUAAIVfMod_outVfModule'.]]></bpmn2:documentation> + <bpmn2:scriptTask id="QueryAAIForGenericVnf" name="Query AAI for Generic Vnf" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_38</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_39</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +def puvm = new PrepareUpdateAAIVfModule() +puvm.getGenericVnf(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_39" name="" sourceRef="QueryAAIForGenericVnf" targetRef="ExclusiveGateway_3"/> + <bpmn2:exclusiveGateway id="ExclusiveGateway_3" default="SequenceFlow_23"> + <bpmn2:incoming>SequenceFlow_39</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_22</bpmn2:outgoing> + <bpmn2:outgoing>SequenceFlow_23</bpmn2:outgoing> + </bpmn2:exclusiveGateway> + <bpmn2:sequenceFlow id="SequenceFlow_22" name="" sourceRef="ExclusiveGateway_3" targetRef="ScriptTask_1"> + <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression">#{execution.getVariable('PUAAIVfMod_getVnfResponseCode') == 200}</bpmn2:conditionExpression> + </bpmn2:sequenceFlow> + <bpmn2:sequenceFlow id="SequenceFlow_23" name="AAI Query failure or
Generic Vnf not found" sourceRef="ExclusiveGateway_3" targetRef="VnfNotFound"/> + <bpmn2:scriptTask id="ScriptTask_1" name="Validate VF Module" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_22</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_10</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +def puvm= new PrepareUpdateAAIVfModule() +puvm.validateVfModule(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:scriptTask id="VnfNotFound" name="Handle Generic Vnf Not found" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_23</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_18</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +def puvm= new PrepareUpdateAAIVfModule() +puvm.handleVnfNotFound(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_18" name="" sourceRef="VnfNotFound" targetRef="EndEvent_7"/> + <bpmn2:endEvent id="EndEvent_7"> + <bpmn2:incoming>SequenceFlow_18</bpmn2:incoming> + <bpmn2:errorEventDefinition id="_ErrorEventDefinition_68" errorRef="Error_1"/> + </bpmn2:endEvent> + <bpmn2:sequenceFlow id="SequenceFlow_10" name="" sourceRef="ScriptTask_1" targetRef="ExclusiveGateway_2"/> + <bpmn2:exclusiveGateway id="ExclusiveGateway_2" default="SequenceFlow_12"> + <bpmn2:incoming>SequenceFlow_10</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_12</bpmn2:outgoing> + <bpmn2:outgoing>SequenceFlow_16</bpmn2:outgoing> + </bpmn2:exclusiveGateway> + <bpmn2:scriptTask id="ScriptTask_2" name="Handle VF Module Validation Error" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_12</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_15</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +def puvm= new PrepareUpdateAAIVfModule() +puvm.handleVfModuleValidationError(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_12" name="VF Module invalid or
not found" sourceRef="ExclusiveGateway_2" targetRef="ScriptTask_2"/> + <bpmn2:sequenceFlow id="SequenceFlow_15" name="" sourceRef="ScriptTask_2" targetRef="EndEvent_1"/> + <bpmn2:endEvent id="EndEvent_1"> + <bpmn2:incoming>SequenceFlow_15</bpmn2:incoming> + <bpmn2:errorEventDefinition id="_ErrorEventDefinition_69" errorRef="Error_1"/> + </bpmn2:endEvent> + <bpmn2:exclusiveGateway id="ExclusiveGateway_1" default="SequenceFlow_4"> + <bpmn2:incoming>SequenceFlow_14</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_13</bpmn2:outgoing> + <bpmn2:outgoing>SequenceFlow_4</bpmn2:outgoing> + </bpmn2:exclusiveGateway> + <bpmn2:sequenceFlow id="SequenceFlow_13" sourceRef="ExclusiveGateway_1" targetRef="EndEvent_4"> + <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression">#{execution.getVariable('PUAAIVfMod_updateVfModuleResponseCode') == 200}</bpmn2:conditionExpression> + </bpmn2:sequenceFlow> + <bpmn2:sequenceFlow id="SequenceFlow_4" name="Update VF Module Failure" sourceRef="ExclusiveGateway_1" targetRef="HandleUpdateVfModuleFailure"/> + <bpmn2:endEvent id="EndEvent_2"> + <bpmn2:incoming>SequenceFlow_8</bpmn2:incoming> + <bpmn2:errorEventDefinition id="_ErrorEventDefinition_50" errorRef="Error_1"/> + </bpmn2:endEvent> + <bpmn2:endEvent id="EndEvent_4" name="TheEnd"> + <bpmn2:extensionElements> + <camunda:connector> + <camunda:inputOutput> + <camunda:outputParameter name="CreateCustomerV1Response"><![CDATA[<aetgt:CreateCustomerResponse xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1" xmlns:ns="http://org.openecomp/mso/workflow/schema/v1"> + <ns:GlobalCustomerId>${CCV1_subscriberglobalid}</ns:GlobalCustomerId> + </aetgt:CreateCustomerResponse>]]></camunda:outputParameter> + </camunda:inputOutput> + </camunda:connector> + </bpmn2:extensionElements> + <bpmn2:incoming>SequenceFlow_13</bpmn2:incoming> + </bpmn2:endEvent> + <bpmn2:scriptTask id="HandleUpdateVfModuleFailure" name="Handle Update VF Module Failure" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_4</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_8</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +def puvm= new PrepareUpdateAAIVfModule() +puvm.handleUpdateVfModuleFailure(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_8" name="" sourceRef="HandleUpdateVfModuleFailure" targetRef="EndEvent_2"/> + <bpmn2:scriptTask id="UpdateVfModule" name="Update VF Module" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_16</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_14</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +def puvm= new PrepareUpdateAAIVfModule() +puvm.updateVfModule(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_14" name="" sourceRef="UpdateVfModule" targetRef="ExclusiveGateway_1"/> + <bpmn2:sequenceFlow id="SequenceFlow_16" name="" sourceRef="ExclusiveGateway_2" targetRef="UpdateVfModule"> + <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression">#{execution.getVariable('PUAAIVfMod_vfModuleOK')}</bpmn2:conditionExpression> + </bpmn2:sequenceFlow> + <bpmn2:startEvent id="StartEvent_1" name="Start"> + <bpmn2:outgoing>SequenceFlow_1</bpmn2:outgoing> + </bpmn2:startEvent> + <bpmn2:sequenceFlow id="SequenceFlow_1" name="" sourceRef="StartEvent_1" targetRef="ProcessReceivedRequest"/> + <bpmn2:scriptTask id="ProcessReceivedRequest" name="Process Received Request" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_1</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_38</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +def puvm= new PrepareUpdateAAIVfModule() +puvm.preProcessRequest(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_38" name="" sourceRef="ProcessReceivedRequest" targetRef="QueryAAIForGenericVnf"/> + </bpmn2:process> + <bpmn2:error id="Error_1" errorCode="MSOWorkflowException" name="MSO Workflow Exception"/> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="PrepareUpdateAAIVfModule"> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_37" bpmnElement="StartEvent_1"> + <dc:Bounds height="36.0" width="36.0" x="37.0" y="212.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="22.0" width="34.0" x="38.0" y="253.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_22" bpmnElement="ProcessReceivedRequest"> + <dc:Bounds height="80.0" width="100.0" x="181.0" y="190.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_1" bpmnElement="SequenceFlow_1" sourceElement="_BPMNShape_StartEvent_37" targetElement="_BPMNShape_ScriptTask_22"> + <di:waypoint xsi:type="dc:Point" x="73.0" y="230.0"/> + <di:waypoint xsi:type="dc:Point" x="181.0" y="230.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="95.0" y="230.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_Task_2" bpmnElement="UpdateVfModule"> + <dc:Bounds height="80.0" width="100.0" x="81.0" y="540.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_EndEvent_92" bpmnElement="EndEvent_4"> + <dc:Bounds height="36.0" width="36.0" x="425.0" y="560.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="22.0" width="50.0" x="418.0" y="601.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ExclusiveGateway_54" bpmnElement="ExclusiveGateway_1" isMarkerVisible="true"> + <dc:Bounds height="50.0" width="50.0" x="250.0" y="554.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="275.0" y="609.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_14" bpmnElement="SequenceFlow_13" sourceElement="_BPMNShape_ExclusiveGateway_54" targetElement="_BPMNShape_EndEvent_92"> + <di:waypoint xsi:type="dc:Point" x="300.0" y="579.0"/> + <di:waypoint xsi:type="dc:Point" x="402.0" y="579.0"/> + <di:waypoint xsi:type="dc:Point" x="402.0" y="578.0"/> + <di:waypoint xsi:type="dc:Point" x="425.0" y="578.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="338.0" y="579.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_EndEvent_120" bpmnElement="EndEvent_2"> + <dc:Bounds height="36.0" width="36.0" x="257.0" y="348.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="275.0" y="389.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ExclusiveGateway_86" bpmnElement="ExclusiveGateway_3" isMarkerVisible="true"> + <dc:Bounds height="50.0" width="50.0" x="499.0" y="206.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="524.0" y="261.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_23" bpmnElement="SequenceFlow_22" sourceElement="_BPMNShape_ExclusiveGateway_86" targetElement="_BPMNShape_ScriptTask_162"> + <di:waypoint xsi:type="dc:Point" x="549.0" y="231.0"/> + <di:waypoint xsi:type="dc:Point" x="601.0" y="231.0"/> + <di:waypoint xsi:type="dc:Point" x="601.0" y="230.0"/> + <di:waypoint xsi:type="dc:Point" x="661.0" y="230.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="564.0" y="231.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_155" bpmnElement="VnfNotFound"> + <dc:Bounds height="80.0" width="100.0" x="475.0" y="72.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_24" bpmnElement="SequenceFlow_23" sourceElement="_BPMNShape_ExclusiveGateway_86" targetElement="_BPMNShape_ScriptTask_155"> + <di:waypoint xsi:type="dc:Point" x="524.0" y="206.0"/> + <di:waypoint xsi:type="dc:Point" x="524.0" y="173.0"/> + <di:waypoint xsi:type="dc:Point" x="525.0" y="173.0"/> + <di:waypoint xsi:type="dc:Point" x="525.0" y="152.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="38.0" width="135.0" x="526.0" y="160.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_EndEvent_160" bpmnElement="EndEvent_7"> + <dc:Bounds height="36.0" width="36.0" x="507.0" y="5.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="525.0" y="46.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_18" bpmnElement="SequenceFlow_18" sourceElement="_BPMNShape_ScriptTask_155" targetElement="_BPMNShape_EndEvent_160"> + <di:waypoint xsi:type="dc:Point" x="525.0" y="72.0"/> + <di:waypoint xsi:type="dc:Point" x="525.0" y="41.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="522.0" y="61.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_160" bpmnElement="QueryAAIForGenericVnf"> + <dc:Bounds height="80.0" width="100.0" x="336.0" y="190.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_38" bpmnElement="SequenceFlow_38" sourceElement="_BPMNShape_ScriptTask_22" targetElement="_BPMNShape_ScriptTask_160"> + <di:waypoint xsi:type="dc:Point" x="281.0" y="230.0"/> + <di:waypoint xsi:type="dc:Point" x="336.0" y="230.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="301.0" y="230.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_39" bpmnElement="SequenceFlow_39" sourceElement="_BPMNShape_ScriptTask_160" targetElement="_BPMNShape_ExclusiveGateway_86"> + <di:waypoint xsi:type="dc:Point" x="436.0" y="230.0"/> + <di:waypoint xsi:type="dc:Point" x="452.0" y="230.0"/> + <di:waypoint xsi:type="dc:Point" x="452.0" y="231.0"/> + <di:waypoint xsi:type="dc:Point" x="499.0" y="231.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="449.0" y="231.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_161" bpmnElement="HandleUpdateVfModuleFailure"> + <dc:Bounds height="80.0" width="100.0" x="225.0" y="408.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_6" bpmnElement="SequenceFlow_8" sourceElement="_BPMNShape_ScriptTask_161" targetElement="_BPMNShape_EndEvent_120"> + <di:waypoint xsi:type="dc:Point" x="275.0" y="408.0"/> + <di:waypoint xsi:type="dc:Point" x="275.0" y="384.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="300.0" y="740.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_13" bpmnElement="SequenceFlow_14" sourceElement="_BPMNShape_Task_2" targetElement="_BPMNShape_ExclusiveGateway_54"> + <di:waypoint xsi:type="dc:Point" x="181.0" y="580.0"/> + <di:waypoint xsi:type="dc:Point" x="206.0" y="580.0"/> + <di:waypoint xsi:type="dc:Point" x="206.0" y="579.0"/> + <di:waypoint xsi:type="dc:Point" x="250.0" y="579.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="174.0" y="711.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_3" bpmnElement="SequenceFlow_4" sourceElement="_BPMNShape_ExclusiveGateway_54" targetElement="_BPMNShape_ScriptTask_161"> + <di:waypoint xsi:type="dc:Point" x="275.0" y="554.0"/> + <di:waypoint xsi:type="dc:Point" x="275.0" y="520.0"/> + <di:waypoint xsi:type="dc:Point" x="276.0" y="520.0"/> + <di:waypoint xsi:type="dc:Point" x="276.0" y="488.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="22.0" width="157.0" x="280.0" y="504.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_162" bpmnElement="ScriptTask_1"> + <dc:Bounds height="80.0" width="100.0" x="661.0" y="190.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ExclusiveGateway_87" bpmnElement="ExclusiveGateway_2" isMarkerVisible="true"> + <dc:Bounds height="50.0" width="50.0" x="829.0" y="204.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="854.0" y="259.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_10" bpmnElement="SequenceFlow_10" sourceElement="_BPMNShape_ScriptTask_162" targetElement="_BPMNShape_ExclusiveGateway_87"> + <di:waypoint xsi:type="dc:Point" x="761.0" y="230.0"/> + <di:waypoint xsi:type="dc:Point" x="795.0" y="230.0"/> + <di:waypoint xsi:type="dc:Point" x="795.0" y="229.0"/> + <di:waypoint xsi:type="dc:Point" x="829.0" y="229.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="792.0" y="230.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_163" bpmnElement="ScriptTask_2"> + <dc:Bounds height="80.0" width="100.0" x="805.0" y="72.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_EndEvent_161" bpmnElement="EndEvent_1"> + <dc:Bounds height="36.0" width="36.0" x="837.0" y="5.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="855.0" y="46.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_12" bpmnElement="SequenceFlow_12" sourceElement="_BPMNShape_ExclusiveGateway_87" targetElement="_BPMNShape_ScriptTask_163"> + <di:waypoint xsi:type="dc:Point" x="854.0" y="204.0"/> + <di:waypoint xsi:type="dc:Point" x="854.0" y="178.0"/> + <di:waypoint xsi:type="dc:Point" x="855.0" y="178.0"/> + <di:waypoint xsi:type="dc:Point" x="855.0" y="152.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="38.0" width="133.0" x="864.0" y="160.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_15" bpmnElement="SequenceFlow_15" sourceElement="_BPMNShape_ScriptTask_163" targetElement="_BPMNShape_EndEvent_161"> + <di:waypoint xsi:type="dc:Point" x="855.0" y="72.0"/> + <di:waypoint xsi:type="dc:Point" x="855.0" y="41.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="852.0" y="54.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_16" bpmnElement="SequenceFlow_16" sourceElement="_BPMNShape_ExclusiveGateway_87" targetElement="_BPMNShape_Task_2"> + <di:waypoint xsi:type="dc:Point" x="854.0" y="254.0"/> + <di:waypoint xsi:type="dc:Point" x="854.0" y="302.0"/> + <di:waypoint xsi:type="dc:Point" x="131.0" y="302.0"/> + <di:waypoint xsi:type="dc:Point" x="131.0" y="540.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="399.0" y="302.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn2:definitions>
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/SDNCAdapterV1.bpmn b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/SDNCAdapterV1.bpmn new file mode 100644 index 0000000000..c94842382b --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/SDNCAdapterV1.bpmn @@ -0,0 +1,524 @@ +<?xml version="1.0" encoding="UTF-8"?> +<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="_l2hJ8CccEeW3d--PaFJMbg" targetNamespace="http://camunda.org/schema/1.0/bpmn" exporter="Camunda Modeler" exporterVersion="1.4.0" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd"> + <bpmn2:process id="sdncAdapter" name="SDNC Adapter" isExecutable="true"> + <bpmn2:exclusiveGateway id="isResponseOK" name="is Response Ok?" default="badSynchronousResponse"> + <bpmn2:incoming>SequenceFlow_15</bpmn2:incoming> + <bpmn2:outgoing>badSynchronousResponse</bpmn2:outgoing> + <bpmn2:outgoing>goodSynchronousResponse</bpmn2:outgoing> + </bpmn2:exclusiveGateway> + <bpmn2:sequenceFlow id="badSynchronousResponse" name="Bad synchronous response" sourceRef="isResponseOK" targetRef="setBadResponse" /> + <bpmn2:sequenceFlow id="goodSynchronousResponse" name="Good synchronous response" sourceRef="isResponseOK" targetRef="resetCallbackRequest"> + <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression"><![CDATA[#{execution.getVariable("SDNCA_ResponseCode")=='200'}]]></bpmn2:conditionExpression> + </bpmn2:sequenceFlow> + <bpmn2:scriptTask id="setBadResponse" name="Set Bad Response
Exception" scriptFormat="groovy"> + <bpmn2:incoming>badSynchronousResponse</bpmn2:incoming> + <bpmn2:outgoing>Exception</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* + +int responseCode = execution.getVariable("SDNCA_ResponseCode") +ExceptionUtil exceptionUtil = new ExceptionUtil() +exceptionUtil.buildWorkflowException(execution, 7000, "Could not communicate with the SDNC Adapter" )]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="Exception" name="Exception" sourceRef="setBadResponse" targetRef="badResponseEndFlow" /> + <bpmn2:serviceTask id="invokeSDNCAdapter" name="Invoke SDNC Adapter" camunda:class=""> + <bpmn2:extensionElements> + <camunda:connector> + <camunda:inputOutput> + <camunda:inputParameter name="url">${URN_mso_adapters_sdnc_endpoint}</camunda:inputParameter> + <camunda:inputParameter name="method">POST</camunda:inputParameter> + <camunda:inputParameter name="headers"> + <camunda:map> + <camunda:entry key="content-type">application/soap+xml</camunda:entry> + <camunda:entry key="Authorization">#{BasicAuthHeaderValue}</camunda:entry> + </camunda:map> + </camunda:inputParameter> + <camunda:inputParameter name="payload">${sdncAdapterRequest}</camunda:inputParameter> + <camunda:outputParameter name="sdncAdapterWorkflowResponse">${response}</camunda:outputParameter> + <camunda:outputParameter name="SDNCA_ResponseCode">${statusCode}</camunda:outputParameter> + </camunda:inputOutput> + <camunda:connectorId>soap-http-connector</camunda:connectorId> + </camunda:connector> + </bpmn2:extensionElements> + <bpmn2:incoming>SequenceFlow_8</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_15</bpmn2:outgoing> + </bpmn2:serviceTask> + <bpmn2:sequenceFlow id="SequenceFlow_15" sourceRef="invokeSDNCAdapter" targetRef="isResponseOK" /> + <bpmn2:endEvent id="badResponseEndFlow" name="Bad Response End Flow"> + <bpmn2:incoming>Exception</bpmn2:incoming> + <bpmn2:errorEventDefinition id="_ErrorEventDefinition_77" errorRef="Error_3" /> + </bpmn2:endEvent> + <bpmn2:startEvent id="SDNCAdapter_Start" name="Incoming Message"> + <bpmn2:outgoing>SequenceFlow_1</bpmn2:outgoing> + <bpmn2:messageEventDefinition id="_MessageEventDefinition_3" messageRef="Message_1" /> + </bpmn2:startEvent> + <bpmn2:sequenceFlow id="SequenceFlow_1" sourceRef="SDNCAdapter_Start" targetRef="processMessage" /> + <bpmn2:scriptTask id="processMessage" name="Process message" scriptFormat="groovy"> + <bpmn2:extensionElements> + <camunda:inputOutput> + <camunda:inputParameter name="ScriptObject"> + <camunda:map> + <camunda:entry key="MethodName">massageSDNCRequestScript</camunda:entry> + <camunda:entry key="Params" /> + </camunda:map> + </camunda:inputParameter> + </camunda:inputOutput> + </bpmn2:extensionElements> + <bpmn2:incoming>SequenceFlow_1</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_8</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +def sdnc= new SDNCAdapter() +sdnc.preProcessRequest(execution) +]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_8" sourceRef="processMessage" targetRef="invokeSDNCAdapter" /> + <bpmn2:exclusiveGateway id="timeOutCheck"> + <bpmn2:incoming>SequenceFlow_9</bpmn2:incoming> + <bpmn2:incoming>timeOut</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_29</bpmn2:outgoing> + </bpmn2:exclusiveGateway> + <bpmn2:scriptTask id="returnWorkflowResult" name="Return workflow result" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_29</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_14</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +def sdnc= new SDNCAdapter() +sdnc.postProcessResponse(execution) +]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_14" sourceRef="returnWorkflowResult" targetRef="timeoutError" /> + <bpmn2:exclusiveGateway id="timeoutError" name="Did Timeout occur?" default="noTimeoutError"> + <bpmn2:incoming>SequenceFlow_14</bpmn2:incoming> + <bpmn2:outgoing>noTimeoutError</bpmn2:outgoing> + <bpmn2:outgoing>SequenceFlow_19</bpmn2:outgoing> + </bpmn2:exclusiveGateway> + <bpmn2:sequenceFlow id="noTimeoutError" name="No Timeout" sourceRef="timeoutError" targetRef="ExclusiveGateway_1" /> + <bpmn2:sequenceFlow id="SequenceFlow_19" name="Timeout" sourceRef="timeoutError" targetRef="setTimeoutEx"> + <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression"><![CDATA[#{execution.getVariable("asynchronousResponseTimeout")==true}]]></bpmn2:conditionExpression> + </bpmn2:sequenceFlow> + <bpmn2:subProcess id="SubProcess" name="Wait for asynchronous message"> + <bpmn2:incoming>SequenceFlow_2</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_9</bpmn2:outgoing> + <bpmn2:endEvent id="eEndEventSubprocess" name="End Event Subprocess"> + <bpmn2:incoming>SequenceFlow_16</bpmn2:incoming> + <bpmn2:terminateEventDefinition id="_TerminateEventDefinition_2" /> + </bpmn2:endEvent> + <bpmn2:startEvent id="StartEvent" name="Start Event"> + <bpmn2:outgoing>SequenceFlow_18</bpmn2:outgoing> + </bpmn2:startEvent> + <bpmn2:sequenceFlow id="SequenceFlow_18" sourceRef="StartEvent" targetRef="IntermediateCatchEvent" /> + <bpmn2:intermediateCatchEvent id="IntermediateCatchEvent" name="Catch Event"> + <bpmn2:incoming>SequenceFlow_18</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_16</bpmn2:outgoing> + <bpmn2:messageEventDefinition id="MessageEventDefinition_2" messageRef="Message_2" /> + </bpmn2:intermediateCatchEvent> + <bpmn2:sequenceFlow id="SequenceFlow_16" sourceRef="IntermediateCatchEvent" targetRef="eEndEventSubprocess" /> + </bpmn2:subProcess> + <bpmn2:sequenceFlow id="SequenceFlow_9" sourceRef="SubProcess" targetRef="timeOutCheck" /> + <bpmn2:boundaryEvent id="BoundaryEvent_1" name="Boundary Event" attachedToRef="SubProcess"> + <bpmn2:outgoing>timeOut</bpmn2:outgoing> + <bpmn2:timerEventDefinition id="TimerEventDefinition_1"> + <bpmn2:timeDuration xsi:type="bpmn2:tFormalExpression">${sdncTimeoutValue}</bpmn2:timeDuration> + </bpmn2:timerEventDefinition> + </bpmn2:boundaryEvent> + <bpmn2:sequenceFlow id="timeOut" name="Timed out" sourceRef="BoundaryEvent_1" targetRef="timeOutCheck" /> + <bpmn2:scriptTask id="setTimeoutEx" name="Set Timeout
Exception" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_19</bpmn2:incoming> + <bpmn2:outgoing>Error</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +ExceptionUtil exceptionUtil = new ExceptionUtil() +exceptionUtil.buildWorkflowException(execution, 500, "SDNC Callback Timeout Error" ) + +]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="Error" name="Error" sourceRef="setTimeoutEx" targetRef="endEventException" /> + <bpmn2:endEvent id="endEventException" name="Timeout Exception"> + <bpmn2:incoming>Error</bpmn2:incoming> + </bpmn2:endEvent> + <bpmn2:sequenceFlow id="SequenceFlow_29" name="" sourceRef="timeOutCheck" targetRef="returnWorkflowResult" /> + <bpmn2:scriptTask id="resetCallbackRequest" name="Reset callback request and set timer value" scriptFormat="groovy"> + <bpmn2:incoming>goodSynchronousResponse</bpmn2:incoming> + <bpmn2:incoming>SequenceFlow_26</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_2</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +def sdnc= new SDNCAdapter() +sdnc.resetCallbackRequest(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_2" name="" sourceRef="resetCallbackRequest" targetRef="SubProcess" /> + <bpmn2:exclusiveGateway id="ExclusiveGateway_1" name="Check final indicator" default="Done"> + <bpmn2:incoming>noTimeoutError</bpmn2:incoming> + <bpmn2:outgoing>Done</bpmn2:outgoing> + <bpmn2:outgoing>SequenceFlow_30</bpmn2:outgoing> + </bpmn2:exclusiveGateway> + <bpmn2:sequenceFlow id="Done" name="Done" sourceRef="ExclusiveGateway_1" targetRef="toggleSuccessIndicator" /> + <bpmn2:sequenceFlow id="SequenceFlow_30" name="Not Done" sourceRef="ExclusiveGateway_1" targetRef="ParallelGateway_3"> + <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression"><![CDATA[#{execution.getVariable("continueListening")==true}]]></bpmn2:conditionExpression> + </bpmn2:sequenceFlow> + <bpmn2:scriptTask id="toggleSuccessIndicator" name="Toggle Success Indicator" scriptFormat="groovy"> + <bpmn2:incoming>Done</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_17</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +def sdnc= new SDNCAdapter() +sdnc.toggleSuccessIndicator(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_17" name="" sourceRef="toggleSuccessIndicator" targetRef="endEventFlow" /> + <bpmn2:endEvent id="endEventFlow" name="End Event Flow"> + <bpmn2:extensionElements> + <camunda:connector> + <camunda:inputOutput> + <camunda:outputParameter name="sdncAdapterResponse">${sdncAdapterWorkflowResponse}</camunda:outputParameter> + </camunda:inputOutput> + </camunda:connector> + </bpmn2:extensionElements> + <bpmn2:incoming>SequenceFlow_17</bpmn2:incoming> + <bpmn2:messageEventDefinition id="_MessageEventDefinition_6" /> + </bpmn2:endEvent> + <bpmn2:parallelGateway id="ParallelGateway_3"> + <bpmn2:incoming>SequenceFlow_30</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_21</bpmn2:outgoing> + <bpmn2:outgoing>SequenceFlow_26</bpmn2:outgoing> + </bpmn2:parallelGateway> + <bpmn2:sequenceFlow id="SequenceFlow_21" name="" sourceRef="ParallelGateway_3" targetRef="toggleSuccess" /> + <bpmn2:sequenceFlow id="SequenceFlow_26" name="Continue listening for asynchronous message" sourceRef="ParallelGateway_3" targetRef="resetCallbackRequest" /> + <bpmn2:subProcess id="errorHandlingSubProcess" name="Error Handling Sub Process" triggeredByEvent="true"> + <bpmn2:startEvent id="catchErrors" name="Catch"> + <bpmn2:outgoing>SequenceFlow_22</bpmn2:outgoing> + <bpmn2:errorEventDefinition id="_ErrorEventDefinition_78" errorRef="Error_3" /> + </bpmn2:startEvent> + <bpmn2:sequenceFlow id="SequenceFlow_22" name="" sourceRef="catchErrors" targetRef="assignError" /> + <bpmn2:scriptTask id="assignError" name="Assign Error" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_22</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_27</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +def sdnc= new SDNCAdapter() +sdnc.assignError(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_27" name="" sourceRef="assignError" targetRef="EndEvent_5" /> + <bpmn2:endEvent id="EndEvent_5"> + <bpmn2:incoming>SequenceFlow_27</bpmn2:incoming> + </bpmn2:endEvent> + </bpmn2:subProcess> + <bpmn2:scriptTask id="toggleSuccess" name="Toggle Success Indicator" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_21</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_15c4h5f</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +def sdnc= new SDNCAdapter() +sdnc.toggleSuccessIndicator(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:endEvent id="EndEvent_1"> + <bpmn2:incoming>SequenceFlow_15c4h5f</bpmn2:incoming> + </bpmn2:endEvent> + <bpmn2:sequenceFlow id="SequenceFlow_15c4h5f" sourceRef="toggleSuccess" targetRef="EndEvent_1" /> + </bpmn2:process> + <bpmn2:message id="Message_1" name="sdncAdapterWorkflowRequest" /> + <bpmn2:message id="Message_2" name="sdncAdapterCallbackRequest" /> + <bpmn2:error id="Error_3" name="MSO Workflow Exception" errorCode="MSOWorkflowException" /> + <bpmn2:signal id="Signal_1" name="InterimStatus" /> + <bpmn2:error id="Error_2" name="Java Lang Exception" errorCode="java.lang.Exception" /> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="sdncAdapter"> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_33" bpmnElement="SDNCAdapter_Start"> + <dc:Bounds x="111" y="161" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="72" y="202" width="115" height="22" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ServiceTask_62" bpmnElement="invokeSDNCAdapter"> + <dc:Bounds x="342" y="139" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ExclusiveGateway_29" bpmnElement="isResponseOK" isMarkerVisible="true"> + <dc:Bounds x="519" y="153" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="569" y="182" width="106" height="22" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_EndEvent_64" bpmnElement="endEventFlow"> + <dc:Bounds x="1560" y="366" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1595" y="373" width="96" height="22" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_EndEvent_65" bpmnElement="badResponseEndFlow"> + <dc:Bounds x="762" y="104" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="804" y="111" width="149" height="22" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_5" bpmnElement="badSynchronousResponse" sourceElement="_BPMNShape_ExclusiveGateway_29" targetElement="_BPMNShape_ScriptTask_24"> + <di:waypoint xsi:type="dc:Point" x="544" y="153" /> + <di:waypoint xsi:type="dc:Point" x="544" y="122" /> + <di:waypoint xsi:type="dc:Point" x="600" y="122" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="441" y="99" width="164" height="22" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_1" bpmnElement="SequenceFlow_1" sourceElement="_BPMNShape_StartEvent_33" targetElement="_BPMNShape_ScriptTask_3"> + <di:waypoint xsi:type="dc:Point" x="147" y="179" /> + <di:waypoint xsi:type="dc:Point" x="194" y="179" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="171" y="179" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_4" bpmnElement="goodSynchronousResponse" sourceElement="_BPMNShape_ExclusiveGateway_29" targetElement="_BPMNShape_ScriptTask_27"> + <di:waypoint xsi:type="dc:Point" x="544" y="203" /> + <di:waypoint xsi:type="dc:Point" x="544" y="246" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="459" y="208" width="172" height="22" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_ServiceTask_68" bpmnElement="returnWorkflowResult"> + <dc:Bounds x="1104" y="237" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_3" bpmnElement="processMessage"> + <dc:Bounds x="194" y="139" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_8" bpmnElement="SequenceFlow_8" sourceElement="_BPMNShape_ScriptTask_3" targetElement="_BPMNShape_ServiceTask_62"> + <di:waypoint xsi:type="dc:Point" x="294" y="179" /> + <di:waypoint xsi:type="dc:Point" x="342" y="179" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="300" y="153" width="30" height="22" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_14" bpmnElement="SequenceFlow_14" sourceElement="_BPMNShape_ServiceTask_68" targetElement="_BPMNShape_ExclusiveGateway_53"> + <di:waypoint xsi:type="dc:Point" x="1204" y="277" /> + <di:waypoint xsi:type="dc:Point" x="1248" y="276" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1211" y="251" width="37" height="22" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_15" bpmnElement="SequenceFlow_15" sourceElement="_BPMNShape_ServiceTask_62" targetElement="_BPMNShape_ExclusiveGateway_29"> + <di:waypoint xsi:type="dc:Point" x="442" y="179" /> + <di:waypoint xsi:type="dc:Point" x="480" y="179" /> + <di:waypoint xsi:type="dc:Point" x="480" y="178" /> + <di:waypoint xsi:type="dc:Point" x="519" y="178" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="468" y="153" width="37" height="22" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_IntermediateCatchEvent_16" bpmnElement="IntermediateCatchEvent"> + <dc:Bounds x="764" y="259" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="714" y="294" width="76" height="22" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_SubProcess_11" bpmnElement="SubProcess" isExpanded="true"> + <dc:Bounds x="624" y="228" width="314" height="97" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_38" bpmnElement="StartEvent"> + <dc:Bounds x="660" y="259" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="627" y="294" width="70" height="22" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_EndEvent_90" bpmnElement="eEndEventSubprocess"> + <dc:Bounds x="865" y="259" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="805" y="294" width="138" height="22" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_9" bpmnElement="SequenceFlow_9" sourceElement="_BPMNShape_SubProcess_11" targetElement="_BPMNShape_ExclusiveGateway_51"> + <di:waypoint xsi:type="dc:Point" x="938" y="276" /> + <di:waypoint xsi:type="dc:Point" x="996" y="276" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="967" y="254" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_BoundaryEvent_21" bpmnElement="BoundaryEvent_1"> + <dc:Bounds x="781" y="307" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="704" y="340" width="97" height="22" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_EndEvent_91" bpmnElement="endEventException"> + <dc:Bounds x="1488" y="74" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1523" y="81" width="114" height="22" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_2" bpmnElement="timeOut" sourceElement="_BPMNShape_BoundaryEvent_21" targetElement="_BPMNShape_ExclusiveGateway_51"> + <di:waypoint xsi:type="dc:Point" x="799" y="343" /> + <di:waypoint xsi:type="dc:Point" x="799" y="365" /> + <di:waypoint xsi:type="dc:Point" x="1021" y="365" /> + <di:waypoint xsi:type="dc:Point" x="1021" y="301" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="874" y="340" width="63" height="22" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_24" bpmnElement="setBadResponse"> + <dc:Bounds x="600" y="82" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_3" bpmnElement="Exception" sourceElement="_BPMNShape_ScriptTask_24" targetElement="_BPMNShape_EndEvent_65"> + <di:waypoint xsi:type="dc:Point" x="700" y="122" /> + <di:waypoint xsi:type="dc:Point" x="762" y="122" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="699" y="99" width="64" height="22" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_25" bpmnElement="setTimeoutEx"> + <dc:Bounds x="1299" y="52" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_11" bpmnElement="Error" sourceElement="_BPMNShape_ScriptTask_25" targetElement="_BPMNShape_EndEvent_91"> + <di:waypoint xsi:type="dc:Point" x="1399" y="92" /> + <di:waypoint xsi:type="dc:Point" x="1488" y="92" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1416" y="70" width="34" height="22" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_16" bpmnElement="SequenceFlow_16" sourceElement="_BPMNShape_IntermediateCatchEvent_16" targetElement="_BPMNShape_EndEvent_90"> + <di:waypoint xsi:type="dc:Point" x="800" y="277" /> + <di:waypoint xsi:type="dc:Point" x="865" y="277" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="822" y="259" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_18" bpmnElement="SequenceFlow_18" sourceElement="_BPMNShape_StartEvent_38" targetElement="_BPMNShape_IntermediateCatchEvent_16"> + <di:waypoint xsi:type="dc:Point" x="696" y="277" /> + <di:waypoint xsi:type="dc:Point" x="764" y="277" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="718" y="259" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_ExclusiveGateway_51" bpmnElement="timeOutCheck" isMarkerVisible="true"> + <dc:Bounds x="996" y="251" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="982" y="228" width="81" height="22" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ExclusiveGateway_53" bpmnElement="timeoutError" isMarkerVisible="true"> + <dc:Bounds x="1248" y="251" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1300" y="266" width="118" height="22" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_17" bpmnElement="noTimeoutError" sourceElement="_BPMNShape_ExclusiveGateway_53" targetElement="_BPMNShape_ExclusiveGateway_54"> + <di:waypoint xsi:type="dc:Point" x="1273" y="301" /> + <di:waypoint xsi:type="dc:Point" x="1273" y="359" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1280" y="324" width="72" height="22" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_19" bpmnElement="SequenceFlow_19" sourceElement="_BPMNShape_ExclusiveGateway_53" targetElement="_BPMNShape_ScriptTask_25"> + <di:waypoint xsi:type="dc:Point" x="1273" y="251" /> + <di:waypoint xsi:type="dc:Point" x="1273" y="92" /> + <di:waypoint xsi:type="dc:Point" x="1299" y="92" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1280" y="168" width="82" height="22" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_ExclusiveGateway_54" bpmnElement="ExclusiveGateway_1" isMarkerVisible="true"> + <dc:Bounds x="1248" y="359" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1127" y="373" width="123" height="22" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_7" bpmnElement="Done" sourceElement="_BPMNShape_ExclusiveGateway_54" targetElement="_BPMNShape_ScriptTask_247"> + <di:waypoint xsi:type="dc:Point" x="1298" y="384" /> + <di:waypoint xsi:type="dc:Point" x="1383" y="384" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1316" y="384" width="36" height="22" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_27" bpmnElement="resetCallbackRequest"> + <dc:Bounds x="494" y="246" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_12" bpmnElement="SequenceFlow_2" sourceElement="_BPMNShape_ScriptTask_27" targetElement="_BPMNShape_SubProcess_11"> + <di:waypoint xsi:type="dc:Point" x="594" y="286" /> + <di:waypoint xsi:type="dc:Point" x="609" y="286" /> + <di:waypoint xsi:type="dc:Point" x="624" y="285" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="607" y="286" width="6" height="6" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_37" bpmnElement="SequenceFlow_29" sourceElement="_BPMNShape_ExclusiveGateway_51" targetElement="_BPMNShape_ServiceTask_68"> + <di:waypoint xsi:type="dc:Point" x="1046" y="276" /> + <di:waypoint xsi:type="dc:Point" x="1075" y="276" /> + <di:waypoint xsi:type="dc:Point" x="1075" y="277" /> + <di:waypoint xsi:type="dc:Point" x="1104" y="277" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_38" bpmnElement="SequenceFlow_30" sourceElement="_BPMNShape_ExclusiveGateway_54" targetElement="_BPMNShape_ParallelGateway_14"> + <di:waypoint xsi:type="dc:Point" x="1273" y="409" /> + <di:waypoint xsi:type="dc:Point" x="1273" y="467" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1273" y="423" width="60" height="22" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_ParallelGateway_14" bpmnElement="ParallelGateway_3"> + <dc:Bounds x="1248" y="467" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1273" y="522" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_28" bpmnElement="SequenceFlow_21" sourceElement="_BPMNShape_ParallelGateway_14" targetElement="_BPMNShape_ScriptTask_255"> + <di:waypoint xsi:type="dc:Point" x="1273" y="517" /> + <di:waypoint xsi:type="dc:Point" x="1274" y="552" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1270" y="533" width="6" height="6" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_EndEvent_96" bpmnElement="EndEvent_1"> + <dc:Bounds x="1255" y="677" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1273" y="718" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_33" bpmnElement="SequenceFlow_26" sourceElement="_BPMNShape_ParallelGateway_14" targetElement="_BPMNShape_ScriptTask_27"> + <di:waypoint xsi:type="dc:Point" x="1248" y="492" /> + <di:waypoint xsi:type="dc:Point" x="544" y="492" /> + <di:waypoint xsi:type="dc:Point" x="544" y="326" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="684" y="467" width="269" height="22" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_247" bpmnElement="toggleSuccessIndicator"> + <dc:Bounds x="1383" y="344" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_26" bpmnElement="SequenceFlow_17" sourceElement="_BPMNShape_ScriptTask_247" targetElement="_BPMNShape_EndEvent_64"> + <di:waypoint xsi:type="dc:Point" x="1483" y="384" /> + <di:waypoint xsi:type="dc:Point" x="1560" y="384" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1499" y="384" width="6" height="6" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_SubProcess_19" bpmnElement="errorHandlingSubProcess" isExpanded="true"> + <dc:Bounds x="248" y="866" width="353" height="193" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_63" bpmnElement="catchErrors"> + <dc:Bounds x="283" y="945" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="281" y="986" width="40" height="22" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_EndEvent_213" bpmnElement="EndEvent_5"> + <dc:Bounds x="523" y="945" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="541" y="986" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_249" bpmnElement="assignError"> + <dc:Bounds x="367" y="923" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_29" bpmnElement="SequenceFlow_22" sourceElement="_BPMNShape_StartEvent_63" targetElement="_BPMNShape_ScriptTask_249"> + <di:waypoint xsi:type="dc:Point" x="319" y="963" /> + <di:waypoint xsi:type="dc:Point" x="367" y="963" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="346" y="963" width="6" height="6" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_34" bpmnElement="SequenceFlow_27" sourceElement="_BPMNShape_ScriptTask_249" targetElement="_BPMNShape_EndEvent_213"> + <di:waypoint xsi:type="dc:Point" x="467" y="963" /> + <di:waypoint xsi:type="dc:Point" x="523" y="963" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="492" y="963" width="6" height="6" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_255" bpmnElement="toggleSuccess"> + <dc:Bounds x="1224" y="552" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_15c4h5f_di" bpmnElement="SequenceFlow_15c4h5f"> + <di:waypoint xsi:type="dc:Point" x="1274" y="632" /> + <di:waypoint xsi:type="dc:Point" x="1273" y="677" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1274" y="629.5" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn2:definitions> diff --git a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/UpdateAAIGenericVnf.bpmn b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/UpdateAAIGenericVnf.bpmn new file mode 100644 index 0000000000..0932221944 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/UpdateAAIGenericVnf.bpmn @@ -0,0 +1,216 @@ +<?xml version="1.0" encoding="UTF-8"?> +<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd" id="_Wblj8GyfEeWUWLTvug7ZOg" exporter="camunda modeler" exporterVersion="2.7.0" targetNamespace="http://camunda.org/schema/1.0/bpmn"> + <bpmn2:process id="UpdateAAIGenericVnf" name="UpdateAAIGenericVnf" isExecutable="true"> + <bpmn2:documentation>This flow expects its incoming request to be in the variable 'UpdateAAIGenericVnfRequest'. This flow produces no output.</bpmn2:documentation> + <bpmn2:scriptTask id="QueryAAIForGenericVNF" name="Query AAI for Generic VNF" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_38</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_39</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +def ugv = new UpdateAAIGenericVnf() +ugv.getGenericVnf(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_39" name="" sourceRef="QueryAAIForGenericVNF" targetRef="ExclusiveGateway_3"/> + <bpmn2:endEvent id="EndEvent_2"> + <bpmn2:incoming>SequenceFlow_8</bpmn2:incoming> + <bpmn2:errorEventDefinition id="_ErrorEventDefinition_50" errorRef="Error_1"/> + </bpmn2:endEvent> + <bpmn2:exclusiveGateway id="ExclusiveGateway_1" default="SequenceFlow_4"> + <bpmn2:incoming>SequenceFlow_14</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_13</bpmn2:outgoing> + <bpmn2:outgoing>SequenceFlow_4</bpmn2:outgoing> + </bpmn2:exclusiveGateway> + <bpmn2:sequenceFlow id="SequenceFlow_13" sourceRef="ExclusiveGateway_1" targetRef="EndEvent_4"> + <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression">#{execution.getVariable('UAAIGenVnf_updateGenericVnfResponseCode') == 200}</bpmn2:conditionExpression> + </bpmn2:sequenceFlow> + <bpmn2:sequenceFlow id="SequenceFlow_4" name="Update Generic VNF Failure" sourceRef="ExclusiveGateway_1" targetRef="HandleUpdateGenericVNFFailure"/> + <bpmn2:scriptTask id="HandleUpdateGenericVNFFailure" name="Handle Update Generic VNF Failure" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_4</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_8</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +def ugv = new UpdateAAIGenericVnf() +ugv.handleUpdateGenericVnfFailure(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_8" name="" sourceRef="HandleUpdateGenericVNFFailure" targetRef="EndEvent_2"/> + <bpmn2:endEvent id="EndEvent_4" name="TheEnd"> + <bpmn2:extensionElements> + <camunda:connector> + <camunda:inputOutput> + <camunda:outputParameter name="CreateCustomerV1Response"><![CDATA[<aetgt:CreateCustomerResponse xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1" xmlns:ns="http://org.openecomp/mso/workflow/schema/v1"> + <ns:GlobalCustomerId>${CCV1_subscriberglobalid}</ns:GlobalCustomerId> + </aetgt:CreateCustomerResponse>]]></camunda:outputParameter> + </camunda:inputOutput> + </camunda:connector> + </bpmn2:extensionElements> + <bpmn2:incoming>SequenceFlow_13</bpmn2:incoming> + </bpmn2:endEvent> + <bpmn2:scriptTask id="UpdateGenericVNF" name="Update Generic VNF" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_22</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_14</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +def ugv = new UpdateAAIGenericVnf() +ugv.updateGenericVnf(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_14" name="" sourceRef="UpdateGenericVNF" targetRef="ExclusiveGateway_1"/> + <bpmn2:exclusiveGateway id="ExclusiveGateway_3" default="SequenceFlow_23"> + <bpmn2:incoming>SequenceFlow_39</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_22</bpmn2:outgoing> + <bpmn2:outgoing>SequenceFlow_23</bpmn2:outgoing> + </bpmn2:exclusiveGateway> + <bpmn2:sequenceFlow id="SequenceFlow_22" name="" sourceRef="ExclusiveGateway_3" targetRef="UpdateGenericVNF"> + <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression">#{execution.getVariable('UAAIGenVnf_getGenericVnfResponseCode') == 200}</bpmn2:conditionExpression> + </bpmn2:sequenceFlow> + <bpmn2:sequenceFlow id="SequenceFlow_23" name="AAI Query failure or
Generic VNF not found" sourceRef="ExclusiveGateway_3" targetRef="AAIQueryFailure"/> + <bpmn2:scriptTask id="AAIQueryFailure" name="Handle AAI Query Failure" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_23</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_18</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +def ugv = new UpdateAAIGenericVnf() +ugv.handleAAIQueryFailure(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_18" name="" sourceRef="AAIQueryFailure" targetRef="EndEvent_7"/> + <bpmn2:endEvent id="EndEvent_7"> + <bpmn2:incoming>SequenceFlow_18</bpmn2:incoming> + <bpmn2:errorEventDefinition id="_ErrorEventDefinition_68" errorRef="Error_1"/> + </bpmn2:endEvent> + <bpmn2:startEvent id="StartEvent_1" name="Start"> + <bpmn2:outgoing>SequenceFlow_1</bpmn2:outgoing> + </bpmn2:startEvent> + <bpmn2:sequenceFlow id="SequenceFlow_1" name="" sourceRef="StartEvent_1" targetRef="ProcessReceivedRequest"/> + <bpmn2:scriptTask id="ProcessReceivedRequest" name="Process Received Request" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_1</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_38</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +def ugv = new UpdateAAIGenericVnf() +ugv.preProcessRequest(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_38" name="" sourceRef="ProcessReceivedRequest" targetRef="QueryAAIForGenericVNF"/> + </bpmn2:process> + <bpmn2:error id="Error_1" errorCode="MSOWorkflowException" name="MSO Workflow Exception"/> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="UpdateAAIGenericVnf"> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_37" bpmnElement="StartEvent_1"> + <dc:Bounds height="36.0" width="36.0" x="43.0" y="212.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="22.0" width="34.0" x="44.0" y="253.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_22" bpmnElement="ProcessReceivedRequest"> + <dc:Bounds height="80.0" width="100.0" x="168.0" y="190.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_1" bpmnElement="SequenceFlow_1" sourceElement="_BPMNShape_StartEvent_37" targetElement="_BPMNShape_ScriptTask_22"> + <di:waypoint xsi:type="dc:Point" x="79.0" y="230.0"/> + <di:waypoint xsi:type="dc:Point" x="168.0" y="230.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="101.0" y="230.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_Task_2" bpmnElement="UpdateGenericVNF"> + <dc:Bounds height="80.0" width="100.0" x="683.0" y="190.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_EndEvent_92" bpmnElement="EndEvent_4"> + <dc:Bounds height="36.0" width="36.0" x="984.0" y="214.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="22.0" width="50.0" x="977.0" y="255.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ExclusiveGateway_54" bpmnElement="ExclusiveGateway_1" isMarkerVisible="true"> + <dc:Bounds height="50.0" width="50.0" x="840.0" y="206.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="865.0" y="261.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_14" bpmnElement="SequenceFlow_13" sourceElement="_BPMNShape_ExclusiveGateway_54" targetElement="_BPMNShape_EndEvent_92"> + <di:waypoint xsi:type="dc:Point" x="890.0" y="231.0"/> + <di:waypoint xsi:type="dc:Point" x="984.0" y="232.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="904.0" y="231.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_EndEvent_120" bpmnElement="EndEvent_2"> + <dc:Bounds height="36.0" width="36.0" x="848.0" y="0.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="866.0" y="41.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ExclusiveGateway_86" bpmnElement="ExclusiveGateway_3" isMarkerVisible="true"> + <dc:Bounds height="50.0" width="50.0" x="500.0" y="204.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="525.0" y="259.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_23" bpmnElement="SequenceFlow_22" sourceElement="_BPMNShape_ExclusiveGateway_86" targetElement="_BPMNShape_Task_2"> + <di:waypoint xsi:type="dc:Point" x="550.0" y="229.0"/> + <di:waypoint xsi:type="dc:Point" x="683.0" y="230.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="565.0" y="229.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_155" bpmnElement="AAIQueryFailure"> + <dc:Bounds height="80.0" width="100.0" x="476.0" y="60.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_24" bpmnElement="SequenceFlow_23" sourceElement="_BPMNShape_ExclusiveGateway_86" targetElement="_BPMNShape_ScriptTask_155"> + <di:waypoint xsi:type="dc:Point" x="525.0" y="204.0"/> + <di:waypoint xsi:type="dc:Point" x="525.0" y="190.0"/> + <di:waypoint xsi:type="dc:Point" x="526.0" y="190.0"/> + <di:waypoint xsi:type="dc:Point" x="526.0" y="140.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="38.0" width="142.0" x="543.0" y="149.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_EndEvent_160" bpmnElement="EndEvent_7"> + <dc:Bounds height="36.0" width="36.0" x="508.0" y="0.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="526.0" y="41.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_18" bpmnElement="SequenceFlow_18" sourceElement="_BPMNShape_ScriptTask_155" targetElement="_BPMNShape_EndEvent_160"> + <di:waypoint xsi:type="dc:Point" x="526.0" y="60.0"/> + <di:waypoint xsi:type="dc:Point" x="526.0" y="36.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="523.0" y="49.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_160" bpmnElement="QueryAAIForGenericVNF"> + <dc:Bounds height="80.0" width="100.0" x="336.0" y="190.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_38" bpmnElement="SequenceFlow_38" sourceElement="_BPMNShape_ScriptTask_22" targetElement="_BPMNShape_ScriptTask_160"> + <di:waypoint xsi:type="dc:Point" x="268.0" y="230.0"/> + <di:waypoint xsi:type="dc:Point" x="336.0" y="230.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="288.0" y="230.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_39" bpmnElement="SequenceFlow_39" sourceElement="_BPMNShape_ScriptTask_160" targetElement="_BPMNShape_ExclusiveGateway_86"> + <di:waypoint xsi:type="dc:Point" x="436.0" y="230.0"/> + <di:waypoint xsi:type="dc:Point" x="500.0" y="229.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="450.0" y="230.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_161" bpmnElement="HandleUpdateGenericVNFFailure"> + <dc:Bounds height="80.0" width="100.0" x="816.0" y="60.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_6" bpmnElement="SequenceFlow_8" sourceElement="_BPMNShape_ScriptTask_161" targetElement="_BPMNShape_EndEvent_120"> + <di:waypoint xsi:type="dc:Point" x="866.0" y="60.0"/> + <di:waypoint xsi:type="dc:Point" x="866.0" y="36.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="863.0" y="51.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_13" bpmnElement="SequenceFlow_14" sourceElement="_BPMNShape_Task_2" targetElement="_BPMNShape_ExclusiveGateway_54"> + <di:waypoint xsi:type="dc:Point" x="783.0" y="230.0"/> + <di:waypoint xsi:type="dc:Point" x="840.0" y="231.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="813.0" y="231.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_3" bpmnElement="SequenceFlow_4" sourceElement="_BPMNShape_ExclusiveGateway_54" targetElement="_BPMNShape_ScriptTask_161"> + <di:waypoint xsi:type="dc:Point" x="865.0" y="206.0"/> + <di:waypoint xsi:type="dc:Point" x="866.0" y="140.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="22.0" width="169.0" x="867.0" y="157.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn2:definitions>
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/UpdateAAIVfModule.bpmn b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/UpdateAAIVfModule.bpmn new file mode 100644 index 0000000000..6eacaee530 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/UpdateAAIVfModule.bpmn @@ -0,0 +1,224 @@ +<?xml version="1.0" encoding="UTF-8"?> +<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd" id="_Wblj8GyfEeWUWLTvug7ZOg" exporter="camunda modeler" exporterVersion="2.7.0" targetNamespace="http://camunda.org/schema/1.0/bpmn"> + <bpmn2:process id="UpdateAAIVfModule" name="UpdateAAIVfModule" isExecutable="true"> + <bpmn2:documentation>This flow expects its incoming request to be in the variable 'UpdateAAIVfModuleRequest'. This flow produces no output.</bpmn2:documentation> + <bpmn2:scriptTask id="QueryAAIForVfModule" name="Query AAI for VF Module" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_38</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_39</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +def uvm = new UpdateAAIVfModule() +uvm.getVfModule(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_39" name="" sourceRef="QueryAAIForVfModule" targetRef="ExclusiveGateway_3"/> + <bpmn2:endEvent id="EndEvent_7"> + <bpmn2:incoming>SequenceFlow_18</bpmn2:incoming> + <bpmn2:errorEventDefinition id="_ErrorEventDefinition_68" errorRef="Error_1"/> + </bpmn2:endEvent> + <bpmn2:scriptTask id="AAIQueryFailure" name="Handle AAI Query Failure" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_23</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_18</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +def uvm= new UpdateAAIVfModule() +uvm.handleAAIQueryFailure(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_18" name="" sourceRef="AAIQueryFailure" targetRef="EndEvent_7"/> + <bpmn2:endEvent id="EndEvent_2"> + <bpmn2:incoming>SequenceFlow_8</bpmn2:incoming> + <bpmn2:errorEventDefinition id="_ErrorEventDefinition_50" errorRef="Error_1"/> + </bpmn2:endEvent> + <bpmn2:endEvent id="EndEvent_4" name="TheEnd"> + <bpmn2:extensionElements> + <camunda:connector> + <camunda:inputOutput> + <camunda:outputParameter name="CreateCustomerV1Response"><![CDATA[<aetgt:CreateCustomerResponse xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1" xmlns:ns="http://org.openecomp/mso/workflow/schema/v1"> + <ns:GlobalCustomerId>${CCV1_subscriberglobalid}</ns:GlobalCustomerId> + </aetgt:CreateCustomerResponse>]]></camunda:outputParameter> + </camunda:inputOutput> + </camunda:connector> + </bpmn2:extensionElements> + <bpmn2:incoming>SequenceFlow_13</bpmn2:incoming> + </bpmn2:endEvent> + <bpmn2:exclusiveGateway id="ExclusiveGateway_3" default="SequenceFlow_23"> + <bpmn2:incoming>SequenceFlow_39</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_22</bpmn2:outgoing> + <bpmn2:outgoing>SequenceFlow_23</bpmn2:outgoing> + </bpmn2:exclusiveGateway> + <bpmn2:sequenceFlow id="SequenceFlow_22" name="" sourceRef="ExclusiveGateway_3" targetRef="UpdateVfModule"> + <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression">#{execution.getVariable('UAAIVfMod_getVfModuleResponseCode') == 200}</bpmn2:conditionExpression> + </bpmn2:sequenceFlow> + <bpmn2:sequenceFlow id="SequenceFlow_23" name="AAI Query failure or
VF Module not found" sourceRef="ExclusiveGateway_3" targetRef="AAIQueryFailure"/> + <bpmn2:scriptTask id="HandleUpdateVfModuleFailure" name="Handle Update VF Module Failure" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_4</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_8</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +def uvm= new UpdateAAIVfModule() +uvm.handleUpdateVfModuleFailure(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_8" name="" sourceRef="HandleUpdateVfModuleFailure" targetRef="EndEvent_2"/> + <bpmn2:exclusiveGateway id="ExclusiveGateway_1" default="SequenceFlow_4"> + <bpmn2:incoming>SequenceFlow_14</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_13</bpmn2:outgoing> + <bpmn2:outgoing>SequenceFlow_4</bpmn2:outgoing> + </bpmn2:exclusiveGateway> + <bpmn2:sequenceFlow id="SequenceFlow_13" sourceRef="ExclusiveGateway_1" targetRef="EndEvent_4"> + <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression">#{execution.getVariable('UAAIVfMod_updateVfModuleResponseCode') == 200}</bpmn2:conditionExpression> + </bpmn2:sequenceFlow> + <bpmn2:sequenceFlow id="SequenceFlow_4" name="Update VF Module Failure" sourceRef="ExclusiveGateway_1" targetRef="HandleUpdateVfModuleFailure"/> + <bpmn2:scriptTask id="UpdateVfModule" name="Update VF Module" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_22</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_14</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +def uvm= new UpdateAAIVfModule() +uvm.updateVfModule(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_14" name="" sourceRef="UpdateVfModule" targetRef="ExclusiveGateway_1"/> + <bpmn2:startEvent id="StartEvent_1" name="Start"> + <bpmn2:outgoing>SequenceFlow_1</bpmn2:outgoing> + </bpmn2:startEvent> + <bpmn2:sequenceFlow id="SequenceFlow_1" name="" sourceRef="StartEvent_1" targetRef="ProcessReceivedRequest"/> + <bpmn2:scriptTask id="ProcessReceivedRequest" name="Process Received Request" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_1</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_38</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +def uvm= new UpdateAAIVfModule() +uvm.preProcessRequest(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_38" name="" sourceRef="ProcessReceivedRequest" targetRef="QueryAAIForVfModule"/> + </bpmn2:process> + <bpmn2:error id="Error_1" errorCode="MSOWorkflowException" name="MSO Workflow Exception"/> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="UpdateAAIVfModule"> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_37" bpmnElement="StartEvent_1"> + <dc:Bounds height="36.0" width="36.0" x="69.0" y="212.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="22.0" width="34.0" x="70.0" y="253.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_22" bpmnElement="ProcessReceivedRequest"> + <dc:Bounds height="80.0" width="100.0" x="180.0" y="190.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_1" bpmnElement="SequenceFlow_1" sourceElement="_BPMNShape_StartEvent_37" targetElement="_BPMNShape_ScriptTask_22"> + <di:waypoint xsi:type="dc:Point" x="105.0" y="230.0"/> + <di:waypoint xsi:type="dc:Point" x="180.0" y="230.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="127.0" y="230.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_Task_2" bpmnElement="UpdateVfModule"> + <dc:Bounds height="80.0" width="100.0" x="672.0" y="190.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_EndEvent_92" bpmnElement="EndEvent_4"> + <dc:Bounds height="36.0" width="36.0" x="1016.0" y="212.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="22.0" width="50.0" x="1009.0" y="253.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ExclusiveGateway_54" bpmnElement="ExclusiveGateway_1" isMarkerVisible="true"> + <dc:Bounds height="50.0" width="50.0" x="840.0" y="206.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="865.0" y="261.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_14" bpmnElement="SequenceFlow_13" sourceElement="_BPMNShape_ExclusiveGateway_54" targetElement="_BPMNShape_EndEvent_92"> + <di:waypoint xsi:type="dc:Point" x="890.0" y="231.0"/> + <di:waypoint xsi:type="dc:Point" x="993.0" y="231.0"/> + <di:waypoint xsi:type="dc:Point" x="993.0" y="230.0"/> + <di:waypoint xsi:type="dc:Point" x="1016.0" y="230.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="928.0" y="231.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_EndEvent_120" bpmnElement="EndEvent_2"> + <dc:Bounds height="36.0" width="36.0" x="848.0" y="0.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="866.0" y="41.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ExclusiveGateway_86" bpmnElement="ExclusiveGateway_3" isMarkerVisible="true"> + <dc:Bounds height="50.0" width="50.0" x="493.0" y="204.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="518.0" y="259.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_23" bpmnElement="SequenceFlow_22" sourceElement="_BPMNShape_ExclusiveGateway_86" targetElement="_BPMNShape_Task_2"> + <di:waypoint xsi:type="dc:Point" x="543.0" y="229.0"/> + <di:waypoint xsi:type="dc:Point" x="607.0" y="229.0"/> + <di:waypoint xsi:type="dc:Point" x="607.0" y="230.0"/> + <di:waypoint xsi:type="dc:Point" x="672.0" y="230.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="558.0" y="229.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_155" bpmnElement="AAIQueryFailure"> + <dc:Bounds height="80.0" width="100.0" x="468.0" y="60.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_24" bpmnElement="SequenceFlow_23" sourceElement="_BPMNShape_ExclusiveGateway_86" targetElement="_BPMNShape_ScriptTask_155"> + <di:waypoint xsi:type="dc:Point" x="518.0" y="204.0"/> + <di:waypoint xsi:type="dc:Point" x="518.0" y="140.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="38.0" width="130.0" x="528.0" y="152.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_EndEvent_160" bpmnElement="EndEvent_7"> + <dc:Bounds height="36.0" width="36.0" x="500.0" y="0.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="518.0" y="41.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_18" bpmnElement="SequenceFlow_18" sourceElement="_BPMNShape_ScriptTask_155" targetElement="_BPMNShape_EndEvent_160"> + <di:waypoint xsi:type="dc:Point" x="518.0" y="60.0"/> + <di:waypoint xsi:type="dc:Point" x="518.0" y="36.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="515.0" y="49.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_160" bpmnElement="QueryAAIForVfModule"> + <dc:Bounds height="80.0" width="100.0" x="336.0" y="190.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_38" bpmnElement="SequenceFlow_38" sourceElement="_BPMNShape_ScriptTask_22" targetElement="_BPMNShape_ScriptTask_160"> + <di:waypoint xsi:type="dc:Point" x="280.0" y="230.0"/> + <di:waypoint xsi:type="dc:Point" x="336.0" y="230.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="300.0" y="230.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_39" bpmnElement="SequenceFlow_39" sourceElement="_BPMNShape_ScriptTask_160" targetElement="_BPMNShape_ExclusiveGateway_86"> + <di:waypoint xsi:type="dc:Point" x="436.0" y="230.0"/> + <di:waypoint xsi:type="dc:Point" x="452.0" y="230.0"/> + <di:waypoint xsi:type="dc:Point" x="452.0" y="229.0"/> + <di:waypoint xsi:type="dc:Point" x="493.0" y="229.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="449.0" y="229.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_161" bpmnElement="HandleUpdateVfModuleFailure"> + <dc:Bounds height="80.0" width="100.0" x="816.0" y="60.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_6" bpmnElement="SequenceFlow_8" sourceElement="_BPMNShape_ScriptTask_161" targetElement="_BPMNShape_EndEvent_120"> + <di:waypoint xsi:type="dc:Point" x="866.0" y="60.0"/> + <di:waypoint xsi:type="dc:Point" x="866.0" y="36.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="863.0" y="51.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_13" bpmnElement="SequenceFlow_14" sourceElement="_BPMNShape_Task_2" targetElement="_BPMNShape_ExclusiveGateway_54"> + <di:waypoint xsi:type="dc:Point" x="772.0" y="230.0"/> + <di:waypoint xsi:type="dc:Point" x="797.0" y="230.0"/> + <di:waypoint xsi:type="dc:Point" x="797.0" y="231.0"/> + <di:waypoint xsi:type="dc:Point" x="840.0" y="231.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="801.0" y="231.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_3" bpmnElement="SequenceFlow_4" sourceElement="_BPMNShape_ExclusiveGateway_54" targetElement="_BPMNShape_ScriptTask_161"> + <di:waypoint xsi:type="dc:Point" x="865.0" y="206.0"/> + <di:waypoint xsi:type="dc:Point" x="865.0" y="172.0"/> + <di:waypoint xsi:type="dc:Point" x="867.0" y="172.0"/> + <di:waypoint xsi:type="dc:Point" x="867.0" y="140.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="22.0" width="157.0" x="883.0" y="160.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn2:definitions>
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/VnfAdapterRestV1.bpmn b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/VnfAdapterRestV1.bpmn new file mode 100644 index 0000000000..90964e5466 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/VnfAdapterRestV1.bpmn @@ -0,0 +1,442 @@ +<?xml version="1.0" encoding="UTF-8"?> +<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd" id="_GraPIIyxEeWmdMDkx6Uftw" exporter="camunda modeler" exporterVersion="2.7.0" targetNamespace="http://camunda.org/schema/1.0/bpmn"> + <bpmn2:process id="vnfAdapterRestV1" name="vnfAdapterRestV1" isExecutable="true"> + <bpmn2:scriptTask id="ScriptTask_2" name="Log Response" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_3</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_14</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +def vnfAdapterRestV1 = new VnfAdapterRestV1() +def statusCode = execution.getVariable('VNFREST_vnfAdapterStatusCode') +String response = String.valueOf(execution.getVariable('VNFREST_vnfAdapterResponse')) +def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') +def processKey = vnfAdapterRestV1.getProcessKey(execution) +vnfAdapterRestV1.logDebug(processKey + " received response from VnfAdapter: statusCode=" + statusCode + + " response=" + (response.isEmpty() ? "" : "\n") + response, isDebugLogEnabled)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:scriptTask id="ScriptTask_3" name="Workflow Exception (no connection)"> + <bpmn2:incoming>SequenceFlow_17</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_35</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +def exceptionUtil = new ExceptionUtil() +exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Failed to communicate with VnfAdapter")]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:scriptTask id="ScriptTask_4" name="Workflow Exception (bad response)" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_23</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_36</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* + +String res = execution.getVariable(VNFREST_vnfAdapterResponse) + +def vnfAdapterRestV1 = new VnfAdapterRestV1() +vnfAdapterRestV1.vnfAdapterWorkflowException(execution, res)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_14" name="" sourceRef="ScriptTask_2" targetRef="ExclusiveGateway_1"/> + <bpmn2:exclusiveGateway id="ExclusiveGateway_1" default="SequenceFlow_23"> + <bpmn2:incoming>SequenceFlow_14</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_17</bpmn2:outgoing> + <bpmn2:outgoing>SequenceFlow_23</bpmn2:outgoing> + <bpmn2:outgoing>SequenceFlow_24</bpmn2:outgoing> + </bpmn2:exclusiveGateway> + <bpmn2:sequenceFlow id="SequenceFlow_17" name="404" sourceRef="ExclusiveGateway_1" targetRef="ScriptTask_3"> + <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression"><![CDATA[#{execution.getVariable("VNFREST_vnfAdapterStatusCode") == '404'}]]></bpmn2:conditionExpression> + </bpmn2:sequenceFlow> + <bpmn2:sequenceFlow id="SequenceFlow_23" name="other" sourceRef="ExclusiveGateway_1" targetRef="ScriptTask_4"/> + <bpmn2:sequenceFlow id="SequenceFlow_24" name="2xx" sourceRef="ExclusiveGateway_1" targetRef="waitForAsyncMessage"> + <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression"><![CDATA[#{execution.getVariable("VNFREST_vnfAdapterStatusCode") == '200' || execution.getVariable("VNFREST_vnfAdapterStatusCode") == '202'}]]></bpmn2:conditionExpression> + </bpmn2:sequenceFlow> + <bpmn2:boundaryEvent id="BoundaryEvent_1" name="Timeout" attachedToRef="waitForAsyncMessage"> + <bpmn2:outgoing>SequenceFlow_27</bpmn2:outgoing> + <bpmn2:timerEventDefinition id="TimerEventDefinition_1"> + <bpmn2:timeDuration xsi:type="bpmn2:tFormalExpression">${URN_mso_po_timeout}</bpmn2:timeDuration> + </bpmn2:timerEventDefinition> + </bpmn2:boundaryEvent> + <bpmn2:subProcess id="waitForAsyncMessage" name="Wait for Callback"> + <bpmn2:incoming>SequenceFlow_24</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_28</bpmn2:outgoing> + <bpmn2:intermediateCatchEvent id="IntermediateCatchEvent_1" name="Catch Event"> + <bpmn2:incoming>SequenceFlow_25</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_26</bpmn2:outgoing> + <bpmn2:messageEventDefinition id="MessageEventDefinition_1" messageRef="Message_1"/> + </bpmn2:intermediateCatchEvent> + <bpmn2:sequenceFlow id="SequenceFlow_26" name="" sourceRef="IntermediateCatchEvent_1" targetRef="EndEvent_2"/> + <bpmn2:startEvent id="StartEvent_3"> + <bpmn2:outgoing>SequenceFlow_25</bpmn2:outgoing> + </bpmn2:startEvent> + <bpmn2:sequenceFlow id="SequenceFlow_25" name="" sourceRef="StartEvent_3" targetRef="IntermediateCatchEvent_1"/> + <bpmn2:endEvent id="EndEvent_2"> + <bpmn2:incoming>SequenceFlow_26</bpmn2:incoming> + </bpmn2:endEvent> + </bpmn2:subProcess> + <bpmn2:sequenceFlow id="SequenceFlow_27" name="" sourceRef="BoundaryEvent_1" targetRef="ScriptTask_5"/> + <bpmn2:scriptTask id="ScriptTask_5" name="Workflow Exception (timeout)" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_27</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_34</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +def exceptionUtil = new ExceptionUtil() +exceptionUtil.buildAndThrowWorkflowException(execution, 7010, "VnfAdapter Callback Timeout Error")]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_28" name="" sourceRef="waitForAsyncMessage" targetRef="ScriptTask_6"/> + <bpmn2:scriptTask id="ScriptTask_6" name="Process Callback" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_28</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_33</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +def vnfAdapterRestV1 = new VnfAdapterRestV1() +vnfAdapterRestV1.processCallback(execution) +]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_33" name="" sourceRef="ScriptTask_6" targetRef="ExclusiveGateway_2"/> + <bpmn2:sequenceFlow id="SequenceFlow_34" name="" sourceRef="ScriptTask_5" targetRef="EndEvent_8"/> + <bpmn2:endEvent id="EndEvent_8"> + <bpmn2:incoming>SequenceFlow_34</bpmn2:incoming> + <bpmn2:errorEventDefinition id="_ErrorEventDefinition_21" errorRef="Error_1"/> + </bpmn2:endEvent> + <bpmn2:sequenceFlow id="SequenceFlow_35" name="" sourceRef="ScriptTask_3" targetRef="EndEvent_9"/> + <bpmn2:endEvent id="EndEvent_9"> + <bpmn2:incoming>SequenceFlow_35</bpmn2:incoming> + <bpmn2:errorEventDefinition id="_ErrorEventDefinition_22" errorRef="Error_1"/> + </bpmn2:endEvent> + <bpmn2:endEvent id="EndEvent_10"> + <bpmn2:incoming>SequenceFlow_36</bpmn2:incoming> + <bpmn2:errorEventDefinition id="_ErrorEventDefinition_23" errorRef="Error_1"/> + </bpmn2:endEvent> + <bpmn2:sequenceFlow id="SequenceFlow_36" name="" sourceRef="ScriptTask_4" targetRef="EndEvent_10"/> + <bpmn2:endEvent id="EndEvent_7"> + <bpmn2:incoming>SequenceFlow_32</bpmn2:incoming> + <bpmn2:errorEventDefinition id="_ErrorEventDefinition_20" errorRef="Error_1"/> + </bpmn2:endEvent> + <bpmn2:exclusiveGateway id="ExclusiveGateway_2" name="Callback
Exception?" default="SequenceFlow_31"> + <bpmn2:incoming>SequenceFlow_33</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_31</bpmn2:outgoing> + <bpmn2:outgoing>SequenceFlow_32</bpmn2:outgoing> + </bpmn2:exclusiveGateway> + <bpmn2:sequenceFlow id="SequenceFlow_31" name="no" sourceRef="ExclusiveGateway_2" targetRef="ScriptTask_setSuccess"/> + <bpmn2:sequenceFlow id="SequenceFlow_32" name="yes" sourceRef="ExclusiveGateway_2" targetRef="EndEvent_7"> + <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression"><![CDATA[#{execution.getVariable("WorkflowException") != null}]]></bpmn2:conditionExpression> + </bpmn2:sequenceFlow> + <bpmn2:scriptTask id="ScriptTask_setSuccess" name="Set Success Indicator" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_31</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_1</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +def vnfAdapterRestV1 = new VnfAdapterRestV1() +vnfAdapterRestV1.setSuccessIndicator(execution, true)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_1" name="" sourceRef="ScriptTask_setSuccess" targetRef="EndEvent_6"/> + <bpmn2:endEvent id="EndEvent_6" name="End Flow"> + <bpmn2:incoming>SequenceFlow_1</bpmn2:incoming> + </bpmn2:endEvent> + <bpmn2:scriptTask id="ScriptTask_7" name="Send Request to Vnf Adapter" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_2</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_3</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +def vnfAdapterRestV1 = new VnfAdapterRestV1() +vnfAdapterRestV1.sendRequestToVnfAdapter(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_3" name="" sourceRef="ScriptTask_7" targetRef="ScriptTask_2"/> + <bpmn2:subProcess id="SubProcess_1" name="Error Handling Sub Process" triggeredByEvent="true"> + <bpmn2:scriptTask id="ScriptTask_8" name="Process Error" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_4</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_5</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +def exUtil = new ExceptionUtil() +exUtil.processSubflowsBPMNException(execution) +]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_5" name="" sourceRef="ScriptTask_8" targetRef="EndEvent_1"/> + <bpmn2:endEvent id="EndEvent_1"> + <bpmn2:incoming>SequenceFlow_5</bpmn2:incoming> + </bpmn2:endEvent> + <bpmn2:startEvent id="StartEvent_2"> + <bpmn2:outgoing>SequenceFlow_4</bpmn2:outgoing> + <bpmn2:errorEventDefinition id="_ErrorEventDefinition_89"/> + </bpmn2:startEvent> + <bpmn2:sequenceFlow id="SequenceFlow_4" name="" sourceRef="StartEvent_2" targetRef="ScriptTask_8"/> + </bpmn2:subProcess> + <bpmn2:scriptTask id="ScriptTask_1" name="Pre-Process Request" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_9</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_2</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* +def vnfAdapterRestV1 = new VnfAdapterRestV1() +vnfAdapterRestV1.preProcessRequest(execution) +]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_2" name="" sourceRef="ScriptTask_1" targetRef="ScriptTask_7"/> + <bpmn2:startEvent id="StartEvent_1" name="Start"> + <bpmn2:outgoing>SequenceFlow_9</bpmn2:outgoing> + </bpmn2:startEvent> + <bpmn2:sequenceFlow id="SequenceFlow_9" name="" sourceRef="StartEvent_1" targetRef="ScriptTask_1"/> + </bpmn2:process> + <bpmn2:error id="Error_1" errorCode="MSOWorkflowException" name="MSO Workflow Exception"/> + <bpmn2:message id="Message_1" name="WorkflowMessage"/> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="vnfAdapterRestV1"> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_56" bpmnElement="ScriptTask_1"> + <dc:Bounds height="80.0" width="100.0" x="204.0" y="148.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_SubProcess_14" bpmnElement="waitForAsyncMessage" isExpanded="true"> + <dc:Bounds height="154.0" width="265.0" x="744.0" y="275.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_58" bpmnElement="ScriptTask_6"> + <dc:Bounds height="80.0" width="100.0" x="1046.0" y="311.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_59" bpmnElement="ScriptTask_5"> + <dc:Bounds height="80.0" width="100.0" x="827.0" y="492.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_BoundaryEvent_24" bpmnElement="BoundaryEvent_1"> + <dc:Bounds height="36.0" width="36.0" x="859.0" y="411.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="22.0" width="52.0" x="894.0" y="441.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_IntermediateCatchEvent_20" bpmnElement="IntermediateCatchEvent_1"> + <dc:Bounds height="36.0" width="36.0" x="863.0" y="330.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="22.0" width="76.0" x="843.0" y="371.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_78" bpmnElement="ScriptTask_4"> + <dc:Bounds height="80.0" width="97.0" x="744.0" y="148.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_79" bpmnElement="ScriptTask_2"> + <dc:Bounds height="80.0" width="100.0" x="492.0" y="148.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_54" bpmnElement="StartEvent_1"> + <dc:Bounds height="36.0" width="36.0" x="84.0" y="170.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="22.0" width="34.0" x="85.0" y="211.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_168" bpmnElement="ScriptTask_3"> + <dc:Bounds height="80.0" width="97.0" x="744.0" y="24.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_2" bpmnElement="SequenceFlow_9" sourceElement="_BPMNShape_StartEvent_54" targetElement="_BPMNShape_ScriptTask_56"> + <di:waypoint xsi:type="dc:Point" x="120.0" y="188.0"/> + <di:waypoint xsi:type="dc:Point" x="204.0" y="188.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="130.0" y="188.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_ExclusiveGateway_105" bpmnElement="ExclusiveGateway_1" isMarkerVisible="true"> + <dc:Bounds height="50.0" width="50.0" x="624.0" y="162.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="649.0" y="217.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_18" bpmnElement="SequenceFlow_14" sourceElement="_BPMNShape_ScriptTask_79" targetElement="_BPMNShape_ExclusiveGateway_105"> + <di:waypoint xsi:type="dc:Point" x="592.0" y="188.0"/> + <di:waypoint xsi:type="dc:Point" x="624.0" y="187.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="611.0" y="187.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_19" bpmnElement="SequenceFlow_17" sourceElement="_BPMNShape_ExclusiveGateway_105" targetElement="_BPMNShape_ScriptTask_168"> + <di:waypoint xsi:type="dc:Point" x="649.0" y="162.0"/> + <di:waypoint xsi:type="dc:Point" x="649.0" y="64.0"/> + <di:waypoint xsi:type="dc:Point" x="744.0" y="64.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="22.0" width="27.0" x="688.0" y="64.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_20" bpmnElement="SequenceFlow_23" sourceElement="_BPMNShape_ExclusiveGateway_105" targetElement="_BPMNShape_ScriptTask_78"> + <di:waypoint xsi:type="dc:Point" x="674.0" y="187.0"/> + <di:waypoint xsi:type="dc:Point" x="709.0" y="187.0"/> + <di:waypoint xsi:type="dc:Point" x="709.0" y="188.0"/> + <di:waypoint xsi:type="dc:Point" x="744.0" y="188.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="22.0" width="35.0" x="684.0" y="188.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_25" bpmnElement="SequenceFlow_24" sourceElement="_BPMNShape_ExclusiveGateway_105" targetElement="_BPMNShape_SubProcess_14"> + <di:waypoint xsi:type="dc:Point" x="649.0" y="212.0"/> + <di:waypoint xsi:type="dc:Point" x="649.0" y="353.0"/> + <di:waypoint xsi:type="dc:Point" x="708.0" y="353.0"/> + <di:waypoint xsi:type="dc:Point" x="744.0" y="353.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="22.0" width="27.0" x="688.0" y="328.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_55" bpmnElement="StartEvent_3"> + <dc:Bounds height="36.0" width="36.0" x="768.0" y="330.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="786.0" y="371.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_27" bpmnElement="SequenceFlow_25" sourceElement="_BPMNShape_StartEvent_55" targetElement="_BPMNShape_IntermediateCatchEvent_20"> + <di:waypoint xsi:type="dc:Point" x="804.0" y="348.0"/> + <di:waypoint xsi:type="dc:Point" x="863.0" y="348.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="833.0" y="348.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_EndEvent_156" bpmnElement="EndEvent_2"> + <dc:Bounds height="36.0" width="36.0" x="948.0" y="330.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="966.0" y="371.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_28" bpmnElement="SequenceFlow_26" sourceElement="_BPMNShape_IntermediateCatchEvent_20" targetElement="_BPMNShape_EndEvent_156"> + <di:waypoint xsi:type="dc:Point" x="899.0" y="348.0"/> + <di:waypoint xsi:type="dc:Point" x="929.0" y="348.0"/> + <di:waypoint xsi:type="dc:Point" x="929.0" y="347.0"/> + <di:waypoint xsi:type="dc:Point" x="948.0" y="348.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="926.0" y="348.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_29" bpmnElement="SequenceFlow_27" sourceElement="_BPMNShape_BoundaryEvent_24" targetElement="_BPMNShape_ScriptTask_59"> + <di:waypoint xsi:type="dc:Point" x="877.0" y="447.0"/> + <di:waypoint xsi:type="dc:Point" x="877.0" y="492.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="874.0" y="472.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_30" bpmnElement="SequenceFlow_28" sourceElement="_BPMNShape_SubProcess_14" targetElement="_BPMNShape_ScriptTask_58"> + <di:waypoint xsi:type="dc:Point" x="1008.0" y="351.0"/> + <di:waypoint xsi:type="dc:Point" x="1046.0" y="351.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="1023.0" y="351.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_ExclusiveGateway_106" bpmnElement="ExclusiveGateway_2" isMarkerVisible="true"> + <dc:Bounds height="50.0" width="50.0" x="1188.0" y="325.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="38.0" width="71.0" x="1179.0" y="288.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_EndEvent_158" bpmnElement="EndEvent_6"> + <dc:Bounds height="36.0" width="36.0" x="1463.0" y="333.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="22.0" width="60.0" x="1451.0" y="374.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_33" bpmnElement="SequenceFlow_31" sourceElement="_BPMNShape_ExclusiveGateway_106" targetElement="_BPMNShape_ScriptTask_236"> + <di:waypoint xsi:type="dc:Point" x="1238.0" y="350.0"/> + <di:waypoint xsi:type="dc:Point" x="1308.0" y="350.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="22.0" width="20.0" x="1248.0" y="350.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_EndEvent_159" bpmnElement="EndEvent_7"> + <dc:Bounds height="36.0" width="36.0" x="1196.0" y="426.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="1214.0" y="467.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_34" bpmnElement="SequenceFlow_32" sourceElement="_BPMNShape_ExclusiveGateway_106" targetElement="_BPMNShape_EndEvent_159"> + <di:waypoint xsi:type="dc:Point" x="1213.0" y="375.0"/> + <di:waypoint xsi:type="dc:Point" x="1213.0" y="392.0"/> + <di:waypoint xsi:type="dc:Point" x="1214.0" y="392.0"/> + <di:waypoint xsi:type="dc:Point" x="1214.0" y="426.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="22.0" width="27.0" x="1223.0" y="390.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_35" bpmnElement="SequenceFlow_33" sourceElement="_BPMNShape_ScriptTask_58" targetElement="_BPMNShape_ExclusiveGateway_106"> + <di:waypoint xsi:type="dc:Point" x="1146.0" y="351.0"/> + <di:waypoint xsi:type="dc:Point" x="1173.0" y="351.0"/> + <di:waypoint xsi:type="dc:Point" x="1173.0" y="350.0"/> + <di:waypoint xsi:type="dc:Point" x="1188.0" y="350.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="1170.0" y="350.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_EndEvent_160" bpmnElement="EndEvent_8"> + <dc:Bounds height="36.0" width="36.0" x="974.0" y="514.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="992.0" y="555.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_36" bpmnElement="SequenceFlow_34" sourceElement="_BPMNShape_ScriptTask_59" targetElement="_BPMNShape_EndEvent_160"> + <di:waypoint xsi:type="dc:Point" x="927.0" y="532.0"/> + <di:waypoint xsi:type="dc:Point" x="974.0" y="532.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="951.0" y="532.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_EndEvent_161" bpmnElement="EndEvent_9"> + <dc:Bounds height="36.0" width="36.0" x="891.0" y="46.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="909.0" y="87.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_37" bpmnElement="SequenceFlow_35" sourceElement="_BPMNShape_ScriptTask_168" targetElement="_BPMNShape_EndEvent_161"> + <di:waypoint xsi:type="dc:Point" x="840.0" y="64.0"/> + <di:waypoint xsi:type="dc:Point" x="891.0" y="64.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="865.0" y="64.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_EndEvent_162" bpmnElement="EndEvent_10"> + <dc:Bounds height="36.0" width="36.0" x="892.0" y="170.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="910.0" y="211.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_38" bpmnElement="SequenceFlow_36" sourceElement="_BPMNShape_ScriptTask_78" targetElement="_BPMNShape_EndEvent_162"> + <di:waypoint xsi:type="dc:Point" x="840.0" y="188.0"/> + <di:waypoint xsi:type="dc:Point" x="892.0" y="188.0"/> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_236" bpmnElement="ScriptTask_setSuccess"> + <dc:Bounds height="83.0" width="97.0" x="1308.0" y="309.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_1" bpmnElement="SequenceFlow_1" sourceElement="_BPMNShape_ScriptTask_236" targetElement="_BPMNShape_EndEvent_158"> + <di:waypoint xsi:type="dc:Point" x="1404.0" y="350.0"/> + <di:waypoint xsi:type="dc:Point" x="1422.0" y="350.0"/> + <di:waypoint xsi:type="dc:Point" x="1422.0" y="351.0"/> + <di:waypoint xsi:type="dc:Point" x="1463.0" y="351.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="1419.0" y="351.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_237" bpmnElement="ScriptTask_7"> + <dc:Bounds height="83.0" width="97.0" x="360.0" y="146.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_3" bpmnElement="SequenceFlow_2" sourceElement="_BPMNShape_ScriptTask_56" targetElement="_BPMNShape_ScriptTask_237"> + <di:waypoint xsi:type="dc:Point" x="304.0" y="188.0"/> + <di:waypoint xsi:type="dc:Point" x="344.0" y="188.0"/> + <di:waypoint xsi:type="dc:Point" x="344.0" y="187.0"/> + <di:waypoint xsi:type="dc:Point" x="360.0" y="187.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="317.0" y="188.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_4" bpmnElement="SequenceFlow_3" sourceElement="_BPMNShape_ScriptTask_237" targetElement="_BPMNShape_ScriptTask_79"> + <di:waypoint xsi:type="dc:Point" x="456.0" y="187.0"/> + <di:waypoint xsi:type="dc:Point" x="474.0" y="187.0"/> + <di:waypoint xsi:type="dc:Point" x="474.0" y="188.0"/> + <di:waypoint xsi:type="dc:Point" x="492.0" y="188.0"/> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_SubProcess_24" bpmnElement="SubProcess_1" isExpanded="true"> + <dc:Bounds height="181.0" width="382.0" x="180.0" y="532.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_66" bpmnElement="StartEvent_2"> + <dc:Bounds height="36.0" width="36.0" x="225.0" y="605.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="243.0" y="646.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_EndEvent_207" bpmnElement="EndEvent_1"> + <dc:Bounds height="36.0" width="36.0" x="477.0" y="605.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="0.0" width="0.0" x="495.0" y="646.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_266" bpmnElement="ScriptTask_8"> + <dc:Bounds height="83.0" width="97.0" x="323.0" y="581.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_5" bpmnElement="SequenceFlow_4" sourceElement="_BPMNShape_StartEvent_66" targetElement="_BPMNShape_ScriptTask_266"> + <di:waypoint xsi:type="dc:Point" x="261.0" y="623.0"/> + <di:waypoint xsi:type="dc:Point" x="323.0" y="622.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="273.0" y="623.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_6" bpmnElement="SequenceFlow_5" sourceElement="_BPMNShape_ScriptTask_266" targetElement="_BPMNShape_EndEvent_207"> + <di:waypoint xsi:type="dc:Point" x="419.0" y="622.0"/> + <di:waypoint xsi:type="dc:Point" x="477.0" y="623.0"/> + <bpmndi:BPMNLabel> + <dc:Bounds height="6.0" width="6.0" x="445.0" y="623.0"/> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn2:definitions>
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/main/resources/urn.properties b/bpmn/MSOCommonBPMN/src/main/resources/urn.properties new file mode 100644 index 0000000000..5bf8e24815 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/resources/urn.properties @@ -0,0 +1,29 @@ +### +# ============LICENSE_START======================================================= +# ECOMP MSO +# ================================================================================ +# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= +### + +# URN mappings for this project. + +# TODO: Remove all the non-URN stuff that's in here. +# TODO: Implement a real URN mapping capability. + +#AAIEndPoint= http://localhost:28080/SoapUIMocks +AAIEndPoint= http://localhost:28090/ +SDNCEndPoint=http://localhost:28090/SDNCAdapter/ +msoRollback = true diff --git a/bpmn/MSOCommonBPMN/src/main/resources/wsdl/VnfAdapterNotify.wsdl b/bpmn/MSOCommonBPMN/src/main/resources/wsdl/VnfAdapterNotify.wsdl new file mode 100644 index 0000000000..a4f194045a --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/resources/wsdl/VnfAdapterNotify.wsdl @@ -0,0 +1,233 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" + xmlns:wsp="http://www.w3.org/ns/ws-policy" + xmlns:tns="http://org.openecomp.mso/vnfNotify" + xmlns:xsd="http://www.w3.org/2001/XMLSchema" + xmlns:wsp1_2="http://schemas.xmlsoap.org/ws/2004/09/policy" + xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" + xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" + xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" + name="vnfAdapterNotify" + targetNamespace="http://org.openecomp.mso/vnfNotify"> + <types> + <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" + targetNamespace="http://org.openecomp.mso/vnfNotify" + version="1.0"> + + <xs:element name="createVnfNotification" type="tns:createVnfNotification"/> + + <xs:element name="updateVnfNotification" type="tns:updateVnfNotification"/> + + <xs:element name="deleteVnfNotification" type="tns:deleteVnfNotification"/> + + <xs:element name="queryVnfNotification" type="tns:queryVnfNotification"/> + + <xs:element name="rollbackVnfNotification" type="tns:rollbackVnfNotification"/> + + <xs:complexType name="queryVnfNotification"> + <xs:sequence> + <xs:element name="messageId" type="xs:string"/> + <xs:element name="completed" type="xs:boolean"/> + <xs:element minOccurs="0" name="exception" type="tns:msoExceptionCategory"/> + <xs:element minOccurs="0" name="errorMessage" type="xs:string"/> + <xs:element minOccurs="0" name="vnfExists" type="xs:boolean"/> + <xs:element minOccurs="0" name="vnfId" type="xs:string"/> + <xs:element minOccurs="0" name="status" type="tns:vnfStatus"/> + <xs:element minOccurs="0" name="outputs"> + <xs:complexType> + <xs:sequence> + <xs:element maxOccurs="unbounded" minOccurs="0" name="entry"> + <xs:complexType> + <xs:sequence> + <xs:element minOccurs="0" name="key" type="xs:string"/> + <xs:element minOccurs="0" name="value" type="xs:string"/> + </xs:sequence> + </xs:complexType> + </xs:element> + </xs:sequence> + </xs:complexType> + </xs:element> + </xs:sequence> + </xs:complexType> + + <xs:complexType name="deleteVnfNotification"> + <xs:sequence> + <xs:element name="messageId" type="xs:string"/> + <xs:element name="completed" type="xs:boolean"/> + <xs:element minOccurs="0" name="exception" type="tns:msoExceptionCategory"/> + <xs:element minOccurs="0" name="errorMessage" type="xs:string"/> + </xs:sequence> + </xs:complexType> + + <xs:complexType name="rollbackVnfNotification"> + <xs:sequence> + <xs:element name="messageId" type="xs:string"/> + <xs:element name="completed" type="xs:boolean"/> + <xs:element minOccurs="0" name="exception" type="tns:msoExceptionCategory"/> + <xs:element minOccurs="0" name="errorMessage" type="xs:string"/> + </xs:sequence> + </xs:complexType> + + <xs:complexType name="createVnfNotification"> + <xs:sequence> + <xs:element name="messageId" type="xs:string"/> + <xs:element name="completed" type="xs:boolean"/> + <xs:element minOccurs="0" name="exception" type="tns:msoExceptionCategory"/> + <xs:element minOccurs="0" name="errorMessage" type="xs:string"/> + <xs:element minOccurs="0" name="vnfId" type="xs:string"/> + <xs:element minOccurs="0" name="outputs"> + <xs:complexType> + <xs:sequence> + <xs:element maxOccurs="unbounded" minOccurs="0" name="entry"> + <xs:complexType> + <xs:sequence> + <xs:element minOccurs="0" name="key" type="xs:string"/> + <xs:element minOccurs="0" name="value" type="xs:string"/> + </xs:sequence> + </xs:complexType> + </xs:element> + </xs:sequence> + </xs:complexType> + </xs:element> + <xs:element minOccurs="0" name="rollback" type="tns:vnfRollback"/> + </xs:sequence> + </xs:complexType> + + <xs:complexType name="updateVnfNotification"> + <xs:sequence> + <xs:element name="messageId" type="xs:string"/> + <xs:element name="completed" type="xs:boolean"/> + <xs:element minOccurs="0" name="exception" type="tns:msoExceptionCategory"/> + <xs:element minOccurs="0" name="errorMessage" type="xs:string"/> + <xs:element minOccurs="0" name="outputs"> + <xs:complexType> + <xs:sequence> + <xs:element maxOccurs="unbounded" minOccurs="0" name="entry"> + <xs:complexType> + <xs:sequence> + <xs:element minOccurs="0" name="key" type="xs:string"/> + <xs:element minOccurs="0" name="value" type="xs:string"/> + </xs:sequence> + </xs:complexType> + </xs:element> + </xs:sequence> + </xs:complexType> + </xs:element> + <xs:element minOccurs="0" name="rollback" type="tns:vnfRollback"/> + </xs:sequence> + </xs:complexType> + + <xs:complexType name="vnfRollback"> + <xs:sequence> + <xs:element minOccurs="0" name="cloudSiteId" type="xs:string"/> + <xs:element minOccurs="0" name="msoRequest" type="tns:msoRequest"/> + <xs:element name="tenantCreated" type="xs:boolean"/> + <xs:element minOccurs="0" name="tenantId" type="xs:string"/> + <xs:element name="vnfCreated" type="xs:boolean"/> + <xs:element minOccurs="0" name="vnfId" type="xs:string"/> + </xs:sequence> + </xs:complexType> + + <xs:complexType name="msoRequest"> + <xs:sequence> + <xs:element minOccurs="0" name="requestId" type="xs:string"/> + <xs:element minOccurs="0" name="serviceInstanceId" type="xs:string"/> + </xs:sequence> + </xs:complexType> + + <xs:simpleType name="msoExceptionCategory"> + <xs:restriction base="xs:string"> + <xs:enumeration value="OPENSTACK"/> + <xs:enumeration value="IO"/> + <xs:enumeration value="INTERNAL"/> + <xs:enumeration value="USERDATA"/> + </xs:restriction> + </xs:simpleType> + + <xs:simpleType name="vnfStatus"> + <xs:restriction base="xs:string"> + <xs:enumeration value="ACTIVE"/> + <xs:enumeration value="FAILED"/> + <xs:enumeration value="NOTFOUND"/> + <xs:enumeration value="UNKNOWN"/> + </xs:restriction> + </xs:simpleType> + </xs:schema> + </types> + <message name="rollbackVnfNotification"> + <part element="tns:rollbackVnfNotification" name="parameters"/> + </message> + <message name="queryVnfNotification"> + <part element="tns:queryVnfNotification" name="parameters"/> + </message> + <message name="createVnfNotification"> + <part element="tns:createVnfNotification" name="parameters"/> + </message> + <message name="updateVnfNotification"> + <part element="tns:updateVnfNotification" name="parameters"/> + </message> + <message name="deleteVnfNotification"> + <part element="tns:deleteVnfNotification" name="parameters"/> + </message> + <portType name="vnfAdapterNotify"> + <operation name="rollbackVnfNotification"> + <input message="tns:rollbackVnfNotification" + wsam:Action="http://org.openecomp.mso/notify/adapterNotify/rollbackVnfNotificationRequest"/> + </operation> + <operation name="queryVnfNotification"> + <input message="tns:queryVnfNotification" + wsam:Action="http://org.openecomp.mso/notify/adapterNotify/queryVnfNotificationRequest"/> + </operation> + <operation name="createVnfNotification"> + <input message="tns:createVnfNotification" + wsam:Action="http://org.openecomp.mso/notify/adapterNotify/createVnfNotificationRequest"/> + </operation> + <operation name="updateVnfNotification"> + <input message="tns:updateVnfNotification" + wsam:Action="http://org.openecomp.mso/notify/adapterNotify/updateVnfNotificationRequest"/> + </operation> + <operation name="deleteVnfNotification"> + <input message="tns:deleteVnfNotification" + wsam:Action="http://org.openecomp.mso/notify/adapterNotify/deleteVnfNotificationRequest"/> + </operation> + </portType> + <binding name="MsoVnfAdapterAsyncImplPortBinding" type="tns:vnfAdapterNotify"> + <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> + <operation name="rollbackVnfNotification"> + <soap:operation soapAction=""/> + <input> + <soap:body use="literal"/> + </input> + </operation> + <operation name="queryVnfNotification"> + <soap:operation soapAction=""/> + <input> + <soap:body use="literal"/> + </input> + </operation> + <operation name="createVnfNotification"> + <soap:operation soapAction=""/> + <input> + <soap:body use="literal"/> + </input> + </operation> + <operation name="updateVnfNotification"> + <soap:operation soapAction=""/> + <input> + <soap:body use="literal"/> + </input> + </operation> + <operation name="deleteVnfNotification"> + <soap:operation soapAction=""/> + <input> + <soap:body use="literal"/> + </input> + </operation> + </binding> + <service name="vnfAdapterNotify"> + <port binding="tns:MsoVnfAdapterAsyncImplPortBinding" + name="MsoVnfAdapterAsyncImplPort"> + <soap:address location="REPLACE_WITH_ACTUAL_URL"/> + </port> + </service> +</definitions>
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/main/webapp/WEB-INF/jboss-deployment-structure.xml b/bpmn/MSOCommonBPMN/src/main/webapp/WEB-INF/jboss-deployment-structure.xml new file mode 100644 index 0000000000..130f95e171 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/webapp/WEB-INF/jboss-deployment-structure.xml @@ -0,0 +1,31 @@ +<!-- + ============LICENSE_START======================================================= + ECOMP MSO + ================================================================================ + Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + ================================================================================ + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ============LICENSE_END========================================================= + --> + +<jboss-deployment-structure> + <deployment> + <!-- Exclusions allow you to prevent the server from automatically adding some dependencies --> + <exclusions> + <module name="org.apache.log4j" /> + <module name="org.slf4j" /> + <module name="org.slf4j.impl" /> + </exclusions> + </deployment> +</jboss-deployment-structure> + diff --git a/bpmn/MSOCommonBPMN/src/main/webapp/WEB-INF/jboss-web.xml b/bpmn/MSOCommonBPMN/src/main/webapp/WEB-INF/jboss-web.xml new file mode 100644 index 0000000000..f15ade0a70 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/webapp/WEB-INF/jboss-web.xml @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ============LICENSE_START======================================================= + ECOMP MSO + ================================================================================ + Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + ================================================================================ + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ============LICENSE_END========================================================= + --> + +<!DOCTYPE jboss-web PUBLIC "-//JBoss//DTD Web Application 5.0//EN" "http://www.jboss.org/j2ee/dtd/jboss-web_5_0.dtd"> +<jboss-web> + <security-domain>other</security-domain> + <context-root>/mso/common</context-root> +</jboss-web> diff --git a/bpmn/MSOCommonBPMN/src/main/webapp/WEB-INF/web.xml b/bpmn/MSOCommonBPMN/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..0b3e4cf10b --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,74 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ============LICENSE_START======================================================= + ECOMP MSO + ================================================================================ + Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + ================================================================================ + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ============LICENSE_END========================================================= + --> +<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"> + <display-name>MSO Common BPMN Workflow Servlet</display-name> + <servlet> + <servlet-name>resteasy-servlet</servlet-name> + <servlet-class>org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher</servlet-class> + <init-param> + <param-name>javax.ws.rs.Application</param-name> + <param-value>org.openecomp.mso.bpmn.common.workflow.service.WorkflowResourceApplication</param-value> + </init-param> + </servlet> + <servlet-mapping> + <servlet-name>resteasy-servlet</servlet-name> + <url-pattern>/*</url-pattern> + </servlet-mapping> + <context-param> + <param-name>mso.configuration</param-name> + <param-value>MSO_PROP_TOPOLOGY=topology.properties</param-value> + </context-param> + <context-param> + <param-name>log.configuration</param-name> + <param-value>logback.bpmn.xml</param-value> + </context-param> + <context-param> + <param-name>resteasy.resources</param-name> + <param-value>org.openecomp.mso.logger.MsoLoggingServlet,org.openecomp.mso.bpmn.core.HealthCheckHandler</param-value> + </context-param> + <filter> + <filter-name>LogFilter</filter-name> + <filter-class>org.openecomp.mso.logger.LogFilter</filter-class> + </filter> + <filter-mapping> + <filter-name>LogFilter</filter-name> + <url-pattern>/*</url-pattern> + </filter-mapping> + <security-constraint> + <web-resource-collection> + <web-resource-name>HTTPBasicAuth</web-resource-name> + <description>Authentication for Client Apps</description> + <url-pattern>/workflow/*</url-pattern> + <http-method>GET</http-method> + <http-method>POST</http-method> + </web-resource-collection> + <auth-constraint> + <role-name>BPMN-Client</role-name> + </auth-constraint> + </security-constraint> + <login-config> + <auth-method>BASIC</auth-method> + <realm-name>ApplicationRealm</realm-name> + </login-config> + <security-role> + <role-name>BPMN-Client</role-name> + </security-role> +</web-app>
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/openecomp/mso/bpmn/common/scripts/AaiUtilTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/openecomp/mso/bpmn/common/scripts/AaiUtilTest.groovy new file mode 100644 index 0000000000..7d698f8916 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/openecomp/mso/bpmn/common/scripts/AaiUtilTest.groovy @@ -0,0 +1,318 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common.scripts; + +import static org.junit.Assert.*; +import static org.mockito.Mockito.* + +import org.openecomp.mso.rest.HttpHeader +import org.mockito.MockitoAnnotations +import org.mockito.runners.MockitoJUnitRunner +import org.mockito.internal.debugging.MockitoDebuggerImpl +import org.junit.Before +import org.openecomp.mso.bpmn.common.scripts.AaiUtil; +import org.junit.Rule; +import org.junit.Test +import org.junit.Ignore +import org.junit.runner.RunWith +import org.junit.Before; +import org.junit.Test; +import org.camunda.bpm.engine.ProcessEngineServices +import org.camunda.bpm.engine.RepositoryService +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.camunda.bpm.engine.impl.pvm.process.ProcessDefinitionImpl +import org.camunda.bpm.engine.repository.ProcessDefinition + +@RunWith(MockitoJUnitRunner.class) +class AaiUtilTest extends MsoGroovyTest { + + @Test + public void testGetVersionDefault() { + ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') + CreateAAIVfModule myproc = new CreateAAIVfModule() + AaiUtil aaiUtil = new AaiUtil(myproc) + def version = aaiUtil.getVersion(mockExecution, 'l3-network', 'CreateAAIVfModule') + assertEquals('8', version) + } + + @Test + public void testGetVersionResourceSpecific() { + ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') + when(mockExecution.getVariable("URN_mso_workflow_default_aai_l3_network_version")).thenReturn('7') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') + CreateAAIVfModule myproc = new CreateAAIVfModule() + AaiUtil aaiUtil = new AaiUtil(myproc) + def version = aaiUtil.getVersion(mockExecution, 'l3-network', 'CreateAAIVfModule') + assertEquals('7', version) + } + + @Test + public void testGetVersionFlowSpecific() { + ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') + when(mockExecution.getVariable("URN_mso_workflow_custom_CreateAAIVfModule_aai_version")).thenReturn('6') + when(mockExecution.getVariable("URN_mso_workflow_default_aai_l3_network_version")).thenReturn('7') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') + CreateAAIVfModule myproc = new CreateAAIVfModule() + AaiUtil aaiUtil = new AaiUtil(myproc) + def version = aaiUtil.getVersion(mockExecution, 'l3-network', 'CreateAAIVfModule') + assertEquals('6', version) + } + + @Test(expected=java.lang.Exception.class) + public void testGetVersionNotDefined() { + ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') + CreateAAIVfModule myproc = new CreateAAIVfModule() + AaiUtil aaiUtil = new AaiUtil(myproc) + def version = aaiUtil.getVersion(mockExecution, 'l3-network', 'CreateAAIVfModule') + } + + @Test + public void testGetUriDefaultVersion() { + ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_l3_network_uri")).thenReturn('/aai/v8/network/l3-networks/l3-network') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') + + CreateAAIVfModule myproc = new CreateAAIVfModule() + AaiUtil aaiUtil = new AaiUtil(myproc) + def uri = aaiUtil.getUri(mockExecution, 'l3-network') + assertEquals('/aai/v8/network/l3-networks/l3-network', uri) + } + + @Test + public void testGetUriFlowAndResourceSpecific() { + ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') + when(mockExecution.getVariable("URN_mso_workflow_CreateAAIVfModule_aai_l3_network_uri")).thenReturn('/aai/v6/network/l3-networks/l3-network') + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_l3_network_uri")).thenReturn('/aai/v8/network/l3-networks/l3-network') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') + + CreateAAIVfModule myproc = new CreateAAIVfModule() + AaiUtil aaiUtil = new AaiUtil(myproc) + def uri = aaiUtil.getUri(mockExecution, 'l3-network') + assertEquals('/aai/v6/network/l3-networks/l3-network', uri) + } + + @Test + public void testGetNetworkGenericVnfEndpoint() { + ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_generic_vnf_uri")).thenReturn('/aai/v8/network/generic-vnfs/generic-vnf') + when(mockExecution.getVariable('URN_aai_endpoint')).thenReturn('http://localhost:28090') + + CreateAAIVfModule myproc = new CreateAAIVfModule() + AaiUtil aaiUtil = new AaiUtil(myproc) + def endpoint = aaiUtil.getNetworkGenericVnfEndpoint(mockExecution) + assertEquals('http://localhost:28090/aai/v8/network/generic-vnfs/generic-vnf', endpoint) + } + + @Test + public void testGetNetworkGenericVnfUri() { + ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_generic_vnf_uri")).thenReturn('/aai/v8/network/generic-vnfs/generic-vnf') + + CreateAAIVfModule myproc = new CreateAAIVfModule() + AaiUtil aaiUtil = new AaiUtil(myproc) + def uri = aaiUtil.getNetworkGenericVnfUri(mockExecution) + assertEquals('/aai/v8/network/generic-vnfs/generic-vnf', uri) + } + + @Test + public void testGetNetworkVpnBindingUri() { + ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_vpn_binding_uri")).thenReturn('/aai/v8/network/vpn-bindings/vpn-binding') + + CreateAAIVfModule myproc = new CreateAAIVfModule() + AaiUtil aaiUtil = new AaiUtil(myproc) + def uri = aaiUtil.getNetworkVpnBindingUri(mockExecution) + assertEquals('/aai/v8/network/vpn-bindings/vpn-binding', uri) + } + + @Test + public void testGetNetworkPolicyUri() { + ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_network_policy_uri")).thenReturn('/aai/v8/network/network-policies/network-policy') + + CreateAAIVfModule myproc = new CreateAAIVfModule() + AaiUtil aaiUtil = new AaiUtil(myproc) + def uri = aaiUtil.getNetworkPolicyUri(mockExecution) + assertEquals('/aai/v8/network/network-policies/network-policy', uri) + } + + @Test + public void testGetNetworkTableReferencesUri() { + ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_route_table_reference_uri")).thenReturn('/aai/v8/network/route-table-references/route-table-reference') + + CreateAAIVfModule myproc = new CreateAAIVfModule() + AaiUtil aaiUtil = new AaiUtil(myproc) + def uri = aaiUtil.getNetworkTableReferencesUri(mockExecution) + assertEquals('/aai/v8/network/route-table-references/route-table-reference', uri) + } + + @Test + public void testGetNetworkVceUri() { + ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_vce_uri")).thenReturn('/aai/v8/network/vces/vce') + + CreateAAIVfModule myproc = new CreateAAIVfModule() + AaiUtil aaiUtil = new AaiUtil(myproc) + def uri = aaiUtil.getNetworkVceUri(mockExecution) + assertEquals('/aai/v8/network/vces/vce', uri) + } + + @Test + public void testGetNetworkL3NetworkUri() { + ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_l3_network_uri")).thenReturn('/aai/v8/network/l3-networks/l3-network') + CreateAAIVfModule myproc = new CreateAAIVfModule() + AaiUtil aaiUtil = new AaiUtil(myproc) + def uri = aaiUtil.getNetworkL3NetworkUri(mockExecution) + assertEquals('/aai/v8/network/l3-networks/l3-network', uri) + } + + @Test + public void testGetBusinessCustomerUri() { + ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_customer_uri")).thenReturn('/aai/v8/business/customers/customer') + CreateAAIVfModule myproc = new CreateAAIVfModule() + AaiUtil aaiUtil = new AaiUtil(myproc) + def uri = aaiUtil.getBusinessCustomerUri(mockExecution) + assertEquals('/aai/v8/business/customers/customer', uri) + } + + @Test + public void testGetCloudInfrastructureCloudRegionEndpoint() { + ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_cloud_region_uri")).thenReturn('/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic') + when(mockExecution.getVariable('URN_aai_endpoint')).thenReturn('http://localhost:28090') + CreateAAIVfModule myproc = new CreateAAIVfModule() + AaiUtil aaiUtil = new AaiUtil(myproc) + def uri = aaiUtil.getCloudInfrastructureCloudRegionEndpoint(mockExecution) + assertEquals('http://localhost:28090/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic', uri) + } + + @Test + public void testGetCloudInfrastructureCloudRegionUri() { + ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_cloud_region_uri")).thenReturn('/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic') + CreateAAIVfModule myproc = new CreateAAIVfModule() + AaiUtil aaiUtil = new AaiUtil(myproc) + def uri = aaiUtil.getCloudInfrastructureCloudRegionUri(mockExecution) + assertEquals('/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic', uri) + } + + @Test + public void testGetCloudInfrastructureVolumeGroupUri() { + ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_volume_group_uri")).thenReturn('/aai/v8/cloud-infrastructure/volume-groups/volume-group') + CreateAAIVfModule myproc = new CreateAAIVfModule() + AaiUtil aaiUtil = new AaiUtil(myproc) + def uri = aaiUtil.getCloudInfrastructureVolumeGroupUri(mockExecution) + assertEquals('/aai/v8/cloud-infrastructure/volume-groups/volume-group', uri) + } + + @Test + public void testGetCloudInfrastructureTenantUri() { + ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_tenant_uri")).thenReturn('/aai/v8/cloud-infrastructure/tenants/tenant') + CreateAAIVfModule myproc = new CreateAAIVfModule() + AaiUtil aaiUtil = new AaiUtil(myproc) + def uri = aaiUtil.getCloudInfrastructureTenantUri(mockExecution) + assertEquals('/aai/v8/cloud-infrastructure/tenants/tenant', uri) + } + + @Test + public void testGetSearchNodesQueryUri() { + ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_nodes_query_uri")).thenReturn('/aai/v8/search/nodes-query') + CreateAAIVfModule myproc = new CreateAAIVfModule() + AaiUtil aaiUtil = new AaiUtil(myproc) + def uri = aaiUtil.getSearchNodesQueryUri(mockExecution) + assertEquals('/aai/v8/search/nodes-query', uri) + } + + @Test + public void testGetSearchNodesQueryEndpoint() { + ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_nodes_query_uri")).thenReturn('/aai/v8/search/nodes-query') + when(mockExecution.getVariable('URN_aai_endpoint')).thenReturn('http://localhost:28090') + CreateAAIVfModule myproc = new CreateAAIVfModule() + AaiUtil aaiUtil = new AaiUtil(myproc) + def uri = aaiUtil.getSearchNodesQueryEndpoint(mockExecution) + assertEquals('http://localhost:28090/aai/v8/search/nodes-query', uri) + } + + @Test + public void testGetSearchGenericQueryUri() { + ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_generic_query_uri")).thenReturn('/aai/v8/search/generic-query') + CreateAAIVfModule myproc = new CreateAAIVfModule() + AaiUtil aaiUtil = new AaiUtil(myproc) + def uri = aaiUtil.getSearchGenericQueryUri(mockExecution) + assertEquals('/aai/v8/search/generic-query', uri) + } + + @Test + public void testGetNamespaceFromUri() { + ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') + CreateAAIVfModule myproc = new CreateAAIVfModule() + AaiUtil aaiUtil = new AaiUtil(myproc) + def ns = aaiUtil.getNamespaceFromUri('/aai/v6/search/generic-query') + assertEquals('http://org.openecomp.aai.inventory/v6', ns) + } + +} diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/openecomp/mso/bpmn/common/scripts/CommonExceptionUtilTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/openecomp/mso/bpmn/common/scripts/CommonExceptionUtilTest.groovy new file mode 100644 index 0000000000..abb369725e --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/openecomp/mso/bpmn/common/scripts/CommonExceptionUtilTest.groovy @@ -0,0 +1,201 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common.scripts + +import org.junit.Assert +import org.junit.Ignore +import org.junit.runner.RunWith; +import org.mockito.runners.MockitoJUnitRunner; + + + +import static org.mockito.Mockito.* + +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.junit.Before +import org.junit.runner.RunWith +import org.mockito.MockitoAnnotations +import org.mockito.internal.debugging.MockitoDebuggerImpl +import org.mockito.runners.MockitoJUnitRunner +import org.openecomp.mso.bpmn.common.scripts.CommonExceptionUtil; +@RunWith(MockitoJUnitRunner.class) +import org.junit.Test + +class CommonExceptionUtilTest { + + def aotsFault ="""<n1:Fault xmlns:xml="http://www.w3.org/XML/1998/namespace" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:n1="http://csi.cingular.com/CSI/Namespaces/ATTOneTicketingSystem/InfrastructureCommon/Types/Public/SoapFault.xsd" xmlns:cer="http://csi.cingular.com/CSI/Namespaces/ATTOneTicketingSystem/InfrastructureCommon/Types/Public/ErrorResponse.xsd" xsi:schemaLocation="http://csi.cingular.com/CSI/Namespaces/ATTOneTicketingSystem/InfrastructureCommon/Types/Public/SoapFault.xsd SoapFault-CDM.xsd"> + <n1:faultcode>xml:space</n1:faultcode> + <n1:faultstring>String</n1:faultstring> + <n1:faultactor>http://csi.att.com</n1:faultactor> + <n1:detail> + <n1:CSIApplicationException> + <cer:Response> + <cer:code>400</cer:code> + <cer:description>bad stuff</cer:description> + </cer:Response> + <cer:ServiceProviderEntity> + <cer:reportingServiceEntity>String</cer:reportingServiceEntity> + <cer:faultDate>*** ERROR ***</cer:faultDate> + <cer:faultSequenceNumber>String</cer:faultSequenceNumber> + <cer:faultLevel>String</cer:faultLevel> + <cer:faultCode>String</cer:faultCode> + <cer:faultDescription>String</cer:faultDescription> + <cer:ServiceProviderRawError> + <cer:code>String</cer:code> + <cer:description>String</cer:description> + <cer:BISError> + <cer:code>String</cer:code> + <cer:description>String</cer:description> + <cer:origination>String</cer:origination> + <cer:severity>String</cer:severity> + </cer:BISError> + </cer:ServiceProviderRawError> + </cer:ServiceProviderEntity> + </n1:CSIApplicationException> + <n1:CSIInternalException> + <cer:reportingServiceEntity>String</cer:reportingServiceEntity> + <cer:faultDate>*** ERROR ***</cer:faultDate> + <cer:faultSequenceNumber>String</cer:faultSequenceNumber> + <cer:faultLevel>String</cer:faultLevel> + <cer:faultCode>String</cer:faultCode> + <cer:faultDescription>String</cer:faultDescription> + <cer:cingularErrorCode>String</cer:cingularErrorCode> + <cer:cingularErrorDescription>String</cer:cingularErrorDescription> + <cer:cingularErrorCategory>String</cer:cingularErrorCategory> + </n1:CSIInternalException> + </n1:detail> +</n1:Fault>""" + + + @Before + public void init() + { + MockitoAnnotations.initMocks(this) + } + + @Test + @Ignore + public void testMapAAIExceptionTCommonException() { + + + + String restFault = """ + <Fault> +<requestError> +<serviceException> +<messageId>SVC3002</messageId> +<text>Error writing output performing %1 on %2 (msg=%3) (ec=%4)</text> +<variables> +<variable>PUTcustomer</variable> +<variable>SubName01</variable> +<variable>Unexpected error reading/updating database:Adding this property for key [service-instance-id] and value [USSTU2CFCNC0101UJZZ01] violates a uniqueness constraint [service-instance-id]</variable> +<variable>ERR.5.4.5105</variable> +</variables> +</serviceException> +</requestError> +</Fault> + """ + def errorString = """<requestError> +<serviceException> +<messageId>SVC3002</messageId> +<text>Error writing output performing %1 on %2 (msg=%3) (ec=%4)</text> +<variables> +<variable>PUTcustomer</variable> +<variable>SubName01</variable> +<variable>Unexpected error reading/updating database:Adding this property for key [service-instance-id] and value [USSTU2CFCNC0101UJZZ01] violates a uniqueness constraint [service-instance-id]</variable> +<variable>ERR.5.4.5105</variable> +</variables> +</serviceException> +</requestError>""" as String + + + + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + + CommonExceptionUtil util = new CommonExceptionUtil() + Assert.assertEquals(errorString, util.mapAAIExceptionTCommonException(restFault, mockExecution)) + } + + + + + @Test + public void testBuildException() { + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + when(mockExecution.getVariable("prefix")).thenReturn("test_") + when(mockExecution.getVariable("test_ResponseCode")).thenReturn("400") + ArrayList msgVars = new ArrayList() + msgVars.add("var1") + msgVars.add("var2") + when(mockExecution.getVariable("test_errVariables")).thenReturn(msgVars) + + + CommonExceptionUtil util = new CommonExceptionUtil() + String msg = "Bad request" + String errorString = """<tns:requestError xmlns:tns="http://org.openecomp/mso/request/types/v1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://org.openecomp/mso/request/types/v1 MsoServiceInstanceTypesV1.xsd"> + <tns:serviceException> + <tns:messageId>SVC2000</tns:messageId> + <tns:text>The following service error occurred: %1. Error code is %2.</tns:text> + <tns:variables>var1</tns:variables> + <tns:variables>var2</tns:variables> + </tns:serviceException> +</tns:requestError>""" + Assert.assertEquals(errorString, util.buildException(msg, mockExecution)) + } + + @Test + public void testMapAOTSExecptionToCommonException() { + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + when(mockExecution.getVariable("prefix")).thenReturn("test_") + when(mockExecution.getVariable("test_ResponseCode")).thenReturn("400") + + CommonExceptionUtil util = new CommonExceptionUtil() + String errorString = """<tns:requestError xmlns:tns="http://org.openecomp/mso/request/types/v1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://org.openecomp/mso/request/types/v1 MsoServiceInstanceTypesV1.xsd"> + <tns:serviceException> + <tns:messageId>SVC2000</tns:messageId> + <tns:text>The following service error occurred: %1. Error code is %2.</tns:text> + <tns:variables>Received error from AOTS: bad stuff</tns:variables> + <tns:variables>400</tns:variables> + </tns:serviceException> +</tns:requestError>""" + Assert.assertEquals(errorString, util.mapAOTSExecptionToCommonException(aotsFault, mockExecution)) + } + + + @Test + public void testParseError() { + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + String errorString = "The following service error occurred: %1. Error code is %2." + ArrayList msgVars = new ArrayList() + msgVars.add("var1") + msgVars.add("var2") + when(mockExecution.getVariable("prefix")).thenReturn("test_") + when(mockExecution.getVariable("test_errTxt")).thenReturn(errorString) + when(mockExecution.getVariable("test_errVariables")).thenReturn(msgVars) + + CommonExceptionUtil util = new CommonExceptionUtil() + + Assert.assertEquals("The following service error occurred: var1. Error code is var2.", util.parseError(mockExecution)) +} + + + +} diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/openecomp/mso/bpmn/common/scripts/CompleteMsoProcessTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/openecomp/mso/bpmn/common/scripts/CompleteMsoProcessTest.groovy new file mode 100644 index 0000000000..cd70fa9949 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/openecomp/mso/bpmn/common/scripts/CompleteMsoProcessTest.groovy @@ -0,0 +1,219 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common.scripts + +import org.junit.runner.RunWith; +import static org.junit.Assert.* +import static org.mockito.Mockito.* + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.junit.Before +import org.junit.Test +import org.junit.runner.RunWith +import org.mockito.MockitoAnnotations +import org.mockito.runners.MockitoJUnitRunner +import org.openecomp.mso.bpmn.core.WorkflowException + + +@RunWith(MockitoJUnitRunner.class) +class CompleteMsoProcessTest { + @Before + public void init() { + MockitoAnnotations.initMocks(this) + } + + private String completeMsoProcessRequest = """ + <sdncadapterworkflow:MsoCompletionRequest xmlns:ns="http://org.openecomp/mso/request/types/v1" xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"> + <ns:request-information> + <ns:request-id>uCPE1020_STUW105_5002</ns:request-id> + <ns:request-action>Layer3ServiceActivateRequest</ns:request-action> + <ns:request-sub-action>COMPLETE</ns:request-sub-action> + <ns:source>OMX</ns:source> + <ns:notification-url>http://localhost:28090/CCD/StatusNotification</ns:notification-url> + <ns:order-number>10205000</ns:order-number> + <ns:order-version>1</ns:order-version> + </ns:request-information> + <sdncadapterworkflow:mso-bpel-name>UCPELayer3ServiceActivateV1</sdncadapterworkflow:mso-bpel-name> + </sdncadapterworkflow:MsoCompletionRequest> + """ + + + private String completeMsoProcessResponse = """<sdncadapterworkflow:MsoCompletionResponse xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"> + <sdncadapterworkflow:out>BPEL UCPELayer3ServiceActivateV1 completed</sdncadapterworkflow:out> +</sdncadapterworkflow:MsoCompletionResponse>""" + + + @Test + public void testPreProcessRequest() { + + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + when(mockExecution.getVariable("CompleteMsoProcessRequest")).thenReturn(completeMsoProcessRequest) + + CompleteMsoProcess completeMsoProcess = new CompleteMsoProcess() + completeMsoProcess.preProcessRequest(mockExecution) + + /* Initialize all the process request variables in this block */ + verify(mockExecution).setVariable("prefix","CMSO_") + //verify(mockExecution).setVariable("getLayer3ServiceDetailsV1Response","") + verify(mockExecution).setVariable("CMSO_request_id","") + verify(mockExecution).setVariable("CMSO_notification-url","") + verify(mockExecution).setVariable("CMSO_mso-bpel-name","") + verify(mockExecution).setVariable("CMSO_request_action","") + + verify(mockExecution).setVariable("CMSO_notification-url-Ok", false) + verify(mockExecution).setVariable("CMSO_request_id-Ok", false) + + //updateRequest Adapter process variables + verify(mockExecution).setVariable("CMSO_updateRequestResponse", "") + verify(mockExecution).setVariable("CMSO_updateRequestResponseCode", "") + verify(mockExecution).setVariable("CMSO_updateFinalNotifyAckStatusFailedPayload", "") + + //Set DB adapter variables here + verify(mockExecution).setVariable("CMSO_updateDBStatusToSuccessPayload", "") + verify(mockExecution).setVariable("CMSO_updateInfraRequestDBPayload", "") + verify(mockExecution).setVariable("CMSO_setUpdateDBstatustoSuccessPayload", "") + + //Auth variables + verify(mockExecution).setVariable("BasicAuthHeaderValue","") + + //Response variables + verify(mockExecution).setVariable("CompletionHandlerResponse","") + verify(mockExecution).setVariable("CMSO_ErrorResponse", null) + verify(mockExecution).setVariable("CMSO_ResponseCode", "") + + verify(mockExecution).setVariable("CMSO_notification-url-Ok",true) + verify(mockExecution).setVariable("CMSO_request_id-Ok",true) + verify(mockExecution).setVariable("CMSO_notification-url","http://localhost:28090/CCD/StatusNotification") + verify(mockExecution).setVariable("CMSO_request_id","uCPE1020_STUW105_5002") + verify(mockExecution).setVariable("CMSO_request_action","Layer3ServiceActivateRequest") + verify(mockExecution).setVariable("CMSO_source","OMX") + + } + + @Test + public void testpostProcessResponse(){ + + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("CMSO_mso-bpel-name")).thenReturn("UCPELayer3ServiceActivateV1") + + CompleteMsoProcess completeMsoProcess = new CompleteMsoProcess() + completeMsoProcess.postProcessResponse(mockExecution) + + verify(mockExecution).setVariable("CompleteMsoProcessResponse", completeMsoProcessResponse) + verify(mockExecution).setVariable("CMSO_ResponseCode","200") + } + + private String updateDBStatusToSuccessPayload = """ + <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:req="http://org.openecomp.mso/requestsdb"> + <soapenv:Header/> + <soapenv:Body> + <req:updateStatus> + <requestId>testReqId</requestId> + <lastModifiedBy>BPEL</lastModifiedBy> + <status>COMPLETED</status> + </req:updateStatus> + </soapenv:Body> + </soapenv:Envelope> + """ + + @Test + public void testupdateDBStatusToSuccessPayload(){ + + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + when(mockExecution.getVariable("CMSO_request_id")).thenReturn("testReqId") + when(mockExecution.getVariable("URN_mso_adapters_db_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC"); + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7"); + + CompleteMsoProcess completeMsoProcess = new CompleteMsoProcess() + completeMsoProcess.updateDBStatusToSuccessPayload(mockExecution) + + verify(mockExecution).setVariable("CMSO_updateDBStatusToSuccessPayload",updateDBStatusToSuccessPayload) + } + + private String setUpdateDBstatustoSuccessPayload = """ + <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:req="http://org.openecomp.mso/requestsdb"> + <soapenv:Header/> + <soapenv:Body> + <req:updateInfraRequest> + <requestId>testReqId</requestId> + <lastModifiedBy>BPEL</lastModifiedBy> + <statusMessage>Resource Completed Successfully</statusMessage> + <requestStatus>COMPLETE</requestStatus> + <progress>100</progress> + + </req:updateInfraRequest> + </soapenv:Body> + </soapenv:Envelope>""" + + @Test + public void testsetUpdateDBstatustoSuccessPayload(){ + + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + when(mockExecution.getVariable("CMSO_request_id")).thenReturn("testReqId") + when(mockExecution.getVariable("CMSO_mso-bpel-name")).thenReturn("BPEL") + when(mockExecution.getVariable("URN_mso_adapters_db_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC"); + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7"); + + CompleteMsoProcess completeMsoProcess = new CompleteMsoProcess() + completeMsoProcess.setUpdateDBstatustoSuccessPayload(mockExecution) + + verify(mockExecution).setVariable("CMSO_setUpdateDBstatustoSuccessPayload",setUpdateDBstatustoSuccessPayload) + } + + private String msoCompletionResponse = """onse xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"> + <sdncadapterworkflow:out>BPEL BPEL-NAME FAILED</sdncadapterworkflow:out> +</sdncadapterworkflow:MsoCompletionResponse>""" + +/* + private String msoCompletionResponse = """<sdncadapterworkflow:MsoCompletionResponse xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"> + <sdncadapterworkflow:out>BPEL BPEL-NAME FAILED</sdncadapterworkflow:out> +</sdncadapterworkflow:MsoCompletionResponse>""" +*/ + @Test + public void testbuildDataError(){ + + boolean thrown = false; + String msg = "Some-Message"; + + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + when(mockExecution.getVariable("CMSO_mso-bpel-name")).thenReturn("BPEL-NAME") + when(mockExecution.getVariable("testProcessKey")).thenReturn("CompleteMsoProcess") + + WorkflowException exception = new WorkflowException("CompleteMsoProcess", 500, msg); + + try{ + CompleteMsoProcess completeMsoProcess = new CompleteMsoProcess() + completeMsoProcess.buildDataError(mockExecution, msg) + } + catch (BpmnError e){ + thrown = true; + } + + + verify(mockExecution).setVariable("CompleteMsoProcessResponse",msoCompletionResponse) + // Can't seem to figure out how to verify the exception and have spent way too much time on fixing this test case! + //verify(mockExecution).setVariable("WorkflowException",exception) + assertTrue(thrown); + } +}
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/openecomp/mso/bpmn/common/scripts/ExceptionUtilTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/openecomp/mso/bpmn/common/scripts/ExceptionUtilTest.groovy new file mode 100644 index 0000000000..98bbe7181e --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/openecomp/mso/bpmn/common/scripts/ExceptionUtilTest.groovy @@ -0,0 +1,190 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common.scripts + +import org.junit.Assert +import org.junit.runner.RunWith; +import org.mockito.runners.MockitoJUnitRunner; + + +import org.junit.Ignore; + +import static org.mockito.Mockito.* + +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.junit.Before +import org.junit.runner.RunWith +import org.mockito.MockitoAnnotations +import org.mockito.internal.debugging.MockitoDebuggerImpl +import org.mockito.runners.MockitoJUnitRunner +import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil; +@RunWith(MockitoJUnitRunner.class) +import org.junit.Test + + + +class ExceptionUtilTest { + + + @Before + public void init() + { + MockitoAnnotations.initMocks(this) + } + + @Test + public void testErrorMessageDetails() { + + + + String restFault = """ + <Fault> +<requestError> +<serviceException> +<messageId>SVC3002</messageId> +<text>Error writing output performing %1 on %2 (msg=%3) (ec=%4)</text> +<variables> +<variable>PUTcustomer</variable> +<variable>SubName01</variable> +<variable>Unexpected error reading/updating database:Adding this property for key [service-instance-id] and value [USSTU2CFCNC0101UJZZ01] violates a uniqueness constraint [service-instance-id]</variable> +<variable>ERR.5.4.5105</variable> +</variables> +</serviceException> +</requestError> +</Fault> + """ + def errorString = """<aetgt:WorkflowException xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"> + <aetgt:ErrorMessage>Received error from A&AI (Error writing output performing PUTcustomer on SubName01 (msg=Unexpected error reading/updating database:Adding this property for key [service-instance-id] and value [USSTU2CFCNC0101UJZZ01] violates a uniqueness constraint [service-instance-id]) (ec=ERR.5.4.5105))</aetgt:ErrorMessage> + <aetgt:ErrorCode>5000</aetgt:ErrorCode> + </aetgt:WorkflowException>""" as String + + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + + ExceptionUtil util = new ExceptionUtil() + Assert.assertEquals(errorString, util.MapAAIExceptionToWorkflowExceptionOld(restFault, mockExecution)) + } + + + @Test + public void testErrorMessage() { + String restFault = """ + <rest:RESTFault xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd" + errorType="transport"> + <rest:errorCode>500</rest:errorCode> + <rest:message>HTTP method: GET Internal Server Error </rest:message> + </rest:RESTFault> + """ + def errorString = """<aetgt:WorkflowException xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"> + <aetgt:ErrorMessage>Received error from A&AI (HTTP method: GET Internal Server Error)</aetgt:ErrorMessage> + <aetgt:ErrorCode>5000</aetgt:ErrorCode> + </aetgt:WorkflowException>""" as String + + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + when(mockExecution.getVariable("prefix")).thenReturn("test_") + when(mockExecution.getVariable("test_ErrorResponse")).thenReturn("HTTP method: GET Internal Server Error") + + ExceptionUtil util = new ExceptionUtil() + String msg = "HTTP method: GET Internal Server Error" + Assert.assertEquals(errorString, util.MapAAIExceptionToWorkflowExceptionOld(restFault, mockExecution)) + } + + @Test + public void testBadResponseErrorMessage() { + String restFault = "asfafasfasfd" + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + when(mockExecution.getVariable("prefix")).thenReturn("test_") + when(mockExecution.getVariable("test_ErrorResponse")).thenReturn(null) + ExceptionUtil util = new ExceptionUtil() + String expected = "<aetgt:WorkflowException xmlns:aetgt=\"http://org.openecomp/mso/workflow/schema/v1\">"+ + "\n <aetgt:ErrorMessage>Received error from A&AI ()</aetgt:ErrorMessage>"+ + "\n <aetgt:ErrorCode>5000</aetgt:ErrorCode>"+ + "\n </aetgt:WorkflowException>"; + Assert.assertEquals(expected,util.MapAAIExceptionToWorkflowExceptionOld(restFault, mockExecution)) + } + + @Test + public void testMapErrorCode5010(){ + String msg = "Connect to njcdtl20ew2988:8070 failed: Connection refused: connect" + ExceptionUtil util = new ExceptionUtil() + Assert.assertEquals("5010",util.MapErrorCode(msg)) + } + + @Test + public void testMapErrorCode5020(){ + String msg = "Connection timed out" + ExceptionUtil util = new ExceptionUtil() + Assert.assertEquals("5020",util.MapErrorCode(msg)) + } + + @Test + public void testMapCategoryToErrorCode5100 () { + String errorCategory = "OPENSTACK" + ExceptionUtil util = new ExceptionUtil() + Assert.assertEquals('5100', util.MapCategoryToErrorCode(errorCategory)) + } + + @Test + public void testMapCategoryToErrorCode5110 () { + String errorCategory = "IO" + ExceptionUtil util = new ExceptionUtil() + Assert.assertEquals('5110', util.MapCategoryToErrorCode(errorCategory)) + } + + @Test + public void testMapCategoryToErrorCode7020 () { + String errorCategory = "USERDATA" + ExceptionUtil util = new ExceptionUtil() + Assert.assertEquals('7020', util.MapCategoryToErrorCode(errorCategory)) + } + + @Test + @Ignore + public void testMapAdapterExecptionToWorkflowException_UserDataErrorMessage () { + String response = """<ns2:TenantException xmlns:ns2=\"http://org.openecomp.mso/tenant\"><category>USERDATA</category><message>Cloud Site [CHCGILNE001] not found</message></ns2:TenantException>""" as String + String expected = """WorkflowException[processKey=ExceptionUtil,errorCode=7020,errorMessage=Received error from Tenant Adapter: Cloud Site [CHCGILNE001] not found]""" as String + + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + when(mockExecution.getVariable("prefix")).thenReturn("test_") + when(mockExecution.getVariable("testProcessKey")).thenReturn("ExceptionUtil") + + ExceptionUtil util = new ExceptionUtil() + String actual = util.MapAdapterExecptionToWorkflowException(response, mockExecution, "Tenant Adapter") + + verify(mockExecution).setVariable("WorkflowException",expected) + } + + @Test + @Ignore + public void testMapAdapterExecptionToWorkflowException_IOErrorMessage () { + String response = """<ns2:TenantException xmlns:ns2=\"http://org.openecomp.mso/tenant\"><category>IO</category><message>[TokenAuth] Connect to test.aic.cip.att.com:5000 [test.aic.cip.att.com/300.200.100.100] failed: Connection refused</message></ns2:TenantException>""" as String + String expected = """WorkflowException[processKey=ExceptionUtil,errorCode=5110,errorMessage=Could not communicate with Platform Orchestrator]""" as String + + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + when(mockExecution.getVariable("prefix")).thenReturn("test_") + when(mockExecution.getVariable("testProcessKey")).thenReturn("ExceptionUtil") + + ExceptionUtil util = new ExceptionUtil() + String actual = util.MapAdapterExecptionToWorkflowException(response, mockExecution, "Tenant Adapter") + + verify(mockExecution).setVariable("WorkflowException",expected) + } + +} diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/openecomp/mso/bpmn/common/scripts/FalloutHandlerTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/openecomp/mso/bpmn/common/scripts/FalloutHandlerTest.groovy new file mode 100644 index 0000000000..7f691ca1b8 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/openecomp/mso/bpmn/common/scripts/FalloutHandlerTest.groovy @@ -0,0 +1,311 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common.scripts + +import org.junit.runner.RunWith; +import static org.mockito.Mockito.* +import static org.junit.Assert.*; + +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.junit.Before +import org.junit.Test +import org.junit.runner.RunWith +import org.mockito.ArgumentCaptor; +import org.mockito.MockitoAnnotations +import org.mockito.runners.MockitoJUnitRunner +import org.openecomp.mso.bpmn.common.scripts.MsoUtils; +import org.openecomp.mso.bpmn.common.scripts.FalloutHandler; + +@RunWith(MockitoJUnitRunner.class) +class FalloutHandlerTest { + + public MsoUtils utils = new MsoUtils() + + @Before + public void init() { + MockitoAnnotations.initMocks(this) + } + + private String falloutHandlerRequest = """ + <sdncadapterworkflow:FalloutHandlerRequest xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1" xmlns:ns7="http://org.openecomp/mso/request/types/v1"> + <ns7:request-information> + <ns7:request-id>uCPE1020_STUW105_5002</ns7:request-id> + <ns7:request-action>Layer3ServiceActivateRequest</ns7:request-action> + <ns7:request-sub-action>CANCEL</ns7:request-sub-action> + <ns7:source>OMX</ns7:source> + <ns7:order-number>10205000</ns7:order-number> + <ns7:order-version>1</ns7:order-version> + </ns7:request-information> + <sdncadapterworkflow:WorkflowException> + <sdncadapterworkflow:ErrorMessage>Some Error Message - Fallout Handler</sdncadapterworkflow:ErrorMessage> + <sdncadapterworkflow:ErrorCode>Some Error Code - Fallout Handler</sdncadapterworkflow:ErrorCode> + <sdncadapterworkflow:SourceSystemErrorCode>Some Source System Error Code- Fallout Handler</sdncadapterworkflow:SourceSystemErrorCode> + </sdncadapterworkflow:WorkflowException> + </sdncadapterworkflow:FalloutHandlerRequest> + """ + + private String falloutHandlerResponse = """<workflow:FalloutHandlerResponse xmlns:workflow="http://org.openecomp/mso/workflow/schema/v1"> + <workflow:out>Fallout Handler Failed</workflow:out> +</workflow:FalloutHandlerResponse>""" + + @Test + public void testPreProcessRequest() { + + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + + when(mockExecution.getVariable("FalloutHandlerRequest")).thenReturn(falloutHandlerRequest) + when(mockExecution.getVariable("URN_mso_adapters_db_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC"); + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7"); + + FalloutHandler falloutHandler = new FalloutHandler() + falloutHandler.preProcessRequest(mockExecution) + + /* Initialize all the process request variables in this block */ + verify(mockExecution).setVariable("prefix","FH_") + //verify(mockExecution).setVariable("getLayer3ServiceDetailsV1Response","") + + //These variables are form the input Message to the BPMN + verify(mockExecution).setVariable("FH_request_id","") + verify(mockExecution).setVariable("FH_request_action","") + verify(mockExecution).setVariable("FH_notification-url","") + verify(mockExecution).setVariable("FH_mso-bpel-name","") + verify(mockExecution).setVariable("FH_ErrorCode", "") + verify(mockExecution).setVariable("FH_ErrorMessage", "") + + verify(mockExecution).setVariable("FH_notification-url-Ok", false) + verify(mockExecution).setVariable("FH_request_id-Ok", false) + + //These variables are for Get Mso Aai Password Adapter + verify(mockExecution).setVariable("FH_deliveryStatus", true) + + //update Response Status to pending ...Adapter variables + verify(mockExecution).setVariable("FH_updateResponseStatusPayload", null) + verify(mockExecution).setVariable("FH_updateResponseStatusResponse", null) + + //update Request Gamma ...Adapter variables + verify(mockExecution).setVariable("FH_updateRequestGammaPayload", "") + verify(mockExecution).setVariable("FH_updateRequestGammaResponse", null) + verify(mockExecution).setVariable("FH_updateRequestGammaResponseCode", null) + + //update Request Infra ...Adapter variables + verify(mockExecution).setVariable("FH_updateRequestInfraPayload", "") + verify(mockExecution).setVariable("FH_updateRequestInfraResponse", null) + verify(mockExecution).setVariable("FH_updateRequestInfraResponseCode", null) + + //assign False to success variable + verify(mockExecution).setVariable("FH_success", true) + + //Set notify status to Failed variable + verify(mockExecution).setVariable("FH_NOTIFY_STATUS", "SUCCESS") + + //Set DB update variable + verify(mockExecution).setVariable("FH_updateRequestPayload", "") + verify(mockExecution).setVariable("FH_updateRequestResponse", null) + verify(mockExecution).setVariable("FH_updateRequestResponseCode", null) + + //Auth variables + verify(mockExecution).setVariable("BasicAuthHeaderValue","") + + //Response variables + verify(mockExecution).setVariable("FalloutHandlerResponse","") + verify(mockExecution).setVariable("FH_ErrorResponse", null) + verify(mockExecution).setVariable("FH_ResponseCode", "") + + verify(mockExecution).setVariable("FH_request_id-Ok",true) + verify(mockExecution).setVariable("FH_request_id","uCPE1020_STUW105_5002") + verify(mockExecution).setVariable("FH_request_action","Layer3ServiceActivateRequest") + verify(mockExecution).setVariable("FH_source","OMX") + verify(mockExecution).setVariable("FH_ErrorCode","Some Error Code - Fallout Handler") + verify(mockExecution).setVariable("FH_ErrorMessage","Some Error Message - Fallout Handler") + + } + + @Test + public void testpostProcessResponse(){ + + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("FH_success")).thenReturn(false) + + FalloutHandler falloutHandler = new FalloutHandler() + falloutHandler.postProcessResponse(mockExecution) + + // Capture the arguments to setVariable + ArgumentCaptor<String> captor1 = ArgumentCaptor.forClass(String.class); + ArgumentCaptor<String> captor2 = ArgumentCaptor.forClass(String.class); + + verify(mockExecution, times(4)).setVariable(captor1.capture(), captor2.capture()) + List<String> arg2List = captor2.getAllValues() + String payloadResponseActual = arg2List.get(1) + + assertEquals(falloutHandlerResponse.replaceAll("\\s+", ""), payloadResponseActual.replaceAll("\\s+", "")) + + verify(mockExecution).setVariable("FH_ResponseCode","500") + } + + private String updateRequestPayload = """ + <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:req="http://org.openecomp.mso/requestsdb"> + <soapenv:Header/> + <soapenv:Body> + <req:updateRequest> + <requestId>testReqId</requestId> + <lastModifiedBy>BPEL</lastModifiedBy> + <finalErrorMessage>ErrorMessage</finalErrorMessage> + <finalErrorCode>ErrorCode</finalErrorCode> + <status>FAILED</status> + <responseStatus>NotifyStatus</responseStatus> + </req:updateRequest> + </soapenv:Body> + </soapenv:Envelope> + """ + + @Test + public void testupdateRequestPayload(){ + + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + when(mockExecution.getVariable("FH_request_id")).thenReturn("testReqId") + when(mockExecution.getVariable("FH_ErrorMessage")).thenReturn("ErrorMessage") + when(mockExecution.getVariable("FH_ErrorCode")).thenReturn("ErrorCode") + when(mockExecution.getVariable("FH_NOTIFY_STATUS")).thenReturn("NotifyStatus") + + FalloutHandler falloutHandler = new FalloutHandler() + falloutHandler.updateRequestPayload(mockExecution) + + // Capture the arguments to setVariable + ArgumentCaptor<String> captor1 = ArgumentCaptor.forClass(String.class); + ArgumentCaptor<String> captor2 = ArgumentCaptor.forClass(String.class); + + verify(mockExecution, times(1)).setVariable(captor1.capture(), captor2.capture()) + List<String> arg2List = captor2.getAllValues() + String payloadRequestActual = arg2List.get(0) + + assertEquals(updateRequestPayload.replaceAll("\\s+", ""), payloadRequestActual.replaceAll("\\s+", "")) + } + + private String updateRequestInfraPayload = """ + <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:req="http://org.openecomp.mso/requestsdb"> + <soapenv:Header/> + <soapenv:Body> + <req:updateInfraRequest> + <requestId>testReqId</requestId> + <lastModifiedBy>BPEL</lastModifiedBy> + <statusMessage>ErrorMessage</statusMessage> + <requestStatus>FAILED</requestStatus> + <progress>100</progress> + </req:updateInfraRequest> + </soapenv:Body> + </soapenv:Envelope> + """ + + @Test + public void testupdateRequestInfraPayload(){ + + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + when(mockExecution.getVariable("FH_request_id")).thenReturn("testReqId") + when(mockExecution.getVariable("FH_ErrorMessage")).thenReturn("ErrorMessage") + + FalloutHandler falloutHandler = new FalloutHandler() + falloutHandler.updateRequestInfraPayload(mockExecution) + + // Capture the arguments to setVariable + ArgumentCaptor<String> captor1 = ArgumentCaptor.forClass(String.class); + ArgumentCaptor<String> captor2 = ArgumentCaptor.forClass(String.class); + + verify(mockExecution, times(1)).setVariable(captor1.capture(), captor2.capture()) + List<String> arg2List = captor2.getAllValues() + String payloadRequestActual = arg2List.get(0) + + assertEquals(updateRequestInfraPayload.replaceAll("\\s+", ""), payloadRequestActual.replaceAll("\\s+", "")) + } + + private String updateRequestGammaPayload = """ + <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:req="http://org.openecomp.mso/requestsdb"> + <soapenv:Header/> + <soapenv:Body> + <req:updateRequest> + <requestId>testReqId</requestId> + <lastModifiedBy>BPEL</lastModifiedBy> + <finalErrorMessage>ErrorMessage</finalErrorMessage> + <finalErrorCode>ErrorCode</finalErrorCode> + <status>FAILED</status> + </req:updateRequest> + </soapenv:Body> + </soapenv:Envelope> + """ + + @Test + public void testupdateRequestGammaPayload(){ + + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + when(mockExecution.getVariable("FH_request_id")).thenReturn("testReqId") + when(mockExecution.getVariable("FH_ErrorMessage")).thenReturn("ErrorMessage") + when(mockExecution.getVariable("FH_ErrorCode")).thenReturn("ErrorCode") + + FalloutHandler falloutHandler = new FalloutHandler() + falloutHandler.updateRequestGammaPayload(mockExecution) + + // Capture the arguments to setVariable + ArgumentCaptor<String> captor1 = ArgumentCaptor.forClass(String.class); + ArgumentCaptor<String> captor2 = ArgumentCaptor.forClass(String.class); + + verify(mockExecution, times(1)).setVariable(captor1.capture(), captor2.capture()) + List<String> arg2List = captor2.getAllValues() + String payloadRequestActual = arg2List.get(0) + + assertEquals(updateRequestGammaPayload.replaceAll("\\s+", ""), payloadRequestActual.replaceAll("\\s+", "")) + } + + + String updateResponseStatusPayload = """ + <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:req="http://org.openecomp.mso/requestsdb"> + <soapenv:Header/> + <soapenv:Body> + <req:updateResponseStatus> + <requestId>testReqId</requestId> + <lastModifiedBy>BPEL</lastModifiedBy> + <responseStatus>SENDING_FINAL_NOTIFY</responseStatus> + </req:updateResponseStatus> + </soapenv:Body> + </soapenv:Envelope> + """ + + @Test + public void testupdateResponseStatusPayload(){ + + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + when(mockExecution.getVariable("FH_request_id")).thenReturn("testReqId") + + FalloutHandler falloutHandler = new FalloutHandler() + falloutHandler.updateResponseStatusPayload(mockExecution) + + // Capture the arguments to setVariable + ArgumentCaptor<String> captor1 = ArgumentCaptor.forClass(String.class); + ArgumentCaptor<String> captor2 = ArgumentCaptor.forClass(String.class); + + verify(mockExecution, times(1)).setVariable(captor1.capture(), captor2.capture()) + List<String> arg2List = captor2.getAllValues() + String payloadResponseActual = arg2List.get(0) + + assertEquals(updateResponseStatusPayload.replaceAll("\\s+", ""), payloadResponseActual.replaceAll("\\s+", "")) + } + +}
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/openecomp/mso/bpmn/common/scripts/MsoGroovyTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/openecomp/mso/bpmn/common/scripts/MsoGroovyTest.groovy new file mode 100644 index 0000000000..174ca65bfd --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/openecomp/mso/bpmn/common/scripts/MsoGroovyTest.groovy @@ -0,0 +1,72 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common.scripts + +import static org.mockito.Mockito.* + +import org.mockito.MockitoAnnotations +import org.mockito.runners.MockitoJUnitRunner +import org.mockito.internal.debugging.MockitoDebuggerImpl +import org.camunda.bpm.engine.ProcessEngineServices +import org.camunda.bpm.engine.RepositoryService +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.camunda.bpm.engine.impl.pvm.process.ProcessDefinitionImpl +import org.camunda.bpm.engine.repository.ProcessDefinition + +abstract class MsoGroovyTest { + + protected ExecutionEntity setupMock(String procName) { + ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class) + when(mockProcessDefinition.getKey()).thenReturn(procName) + + RepositoryService mockRepositoryService = mock(RepositoryService.class) + when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition) + when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn(procName) + when(mockRepositoryService.getProcessDefinition().getId()).thenReturn("100") + + ProcessEngineServices mockProcessEngineServices = mock(ProcessEngineServices.class) + when(mockProcessEngineServices.getRepositoryService()).thenReturn(mockRepositoryService) + + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices) + + return mockExecution + } + + protected ExecutionEntity setupMockWithPrefix(String procName, String prefix) { + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + + when(mockExecution.getVariable("prefix")).thenReturn(prefix) + + ProcessEngineServices processEngineServices = mock(ProcessEngineServices.class) + RepositoryService repositoryService = mock(RepositoryService.class) + ProcessDefinition processDefinition = mock(ProcessDefinition.class) + + when(mockExecution.getProcessEngineServices()).thenReturn(processEngineServices) + when(processEngineServices.getRepositoryService()).thenReturn(repositoryService) + when(repositoryService.getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(processDefinition) + when(processDefinition.getKey()).thenReturn(procName) + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + return mockExecution + } + + +} diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/openecomp/mso/bpmn/common/scripts/MsoUtilsTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/openecomp/mso/bpmn/common/scripts/MsoUtilsTest.groovy new file mode 100644 index 0000000000..8e109bb6c8 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/openecomp/mso/bpmn/common/scripts/MsoUtilsTest.groovy @@ -0,0 +1,233 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common.scripts + +// JUnit 4 +import org.junit.Test +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Rule; + +import static groovy.test.GroovyAssert.shouldFail +import static groovy.test.GroovyAssert.assertTrue +import static groovy.test.GroovyAssert.assertEquals + +import org.openecomp.mso.bpmn.common.scripts.MsoUtils; +import org.apache.commons.lang3.* + + +class MsoUtilsTest { + + def utils = new MsoUtils() + def origXmlResponse = null + // Expected rebuilds + def expected_buildElements = "<tns2:internet-service-change-details><tns2:internet-evc-speed-value>10</tns2:internet-evc-speed-value><tns2:internet-evc-speed-units>Kbps</tns2:internet-evc-speed-units><tns2:t-provided-v4-lan-public-prefixes><tns2:request-index>1</tns2:request-index><tns2:v4-next-hop-address>192.168.1.15</tns2:v4-next-hop-address><tns2:v4-lan-public-prefix>192.168.1.15</tns2:v4-lan-public-prefix><tns2:v4-lan-public-prefix-length>28</tns2:v4-lan-public-prefix-length></tns2:t-provided-v4-lan-public-prefixes><tns2:t-provided-v4-lan-public-prefixes><tns2:request-index>2</tns2:request-index><tns2:v4-next-hop-address>192.168.1.16</tns2:v4-next-hop-address><tns2:v4-lan-public-prefix>192.168.1.16</tns2:v4-lan-public-prefix><tns2:v4-lan-public-prefix-length>28</tns2:v4-lan-public-prefix-length></tns2:t-provided-v4-lan-public-prefixes></tns2:internet-service-change-details>" + def expected_rebuildDhcp = "<tns2:dhcp><tns2:v4-dhcp-server-enabled>Y</tns2:v4-dhcp-server-enabled><tns2:v6-dhcp-server-enabled>N</tns2:v6-dhcp-server-enabled><tns2:use-v4-default-pool>Y</tns2:use-v4-default-pool><tns2:excluded-v4-dhcp-addresses-from-default-pool><tns2:excluded-v4-address>192.168.1.7</tns2:excluded-v4-address></tns2:excluded-v4-dhcp-addresses-from-default-pool><tns2:excluded-v4-dhcp-addresses-from-default-pool><tns2:excluded-v4-address>192.168.1.8</tns2:excluded-v4-address></tns2:excluded-v4-dhcp-addresses-from-default-pool><tns2:v4-dhcp-pools><tns2:v4-dhcp-pool-prefix>192.155.2.3</tns2:v4-dhcp-pool-prefix><tns2:v4-dhcp-pool-prefix-length>28</tns2:v4-dhcp-pool-prefix-length><tns2:excluded-v4-addresses><tns2:excluded-v4-address>192.168.1.5</tns2:excluded-v4-address></tns2:excluded-v4-addresses><tns2:excluded-v4-addresses><tns2:excluded-v4-address>192.168.1.6</tns2:excluded-v4-address></tns2:excluded-v4-addresses><tns2:v4-dhcp-relay-gateway-address>2.2.2.1</tns2:v4-dhcp-relay-gateway-address><tns2:v4-dhcp-relay-next-hop-address>1.1.1.1</tns2:v4-dhcp-relay-next-hop-address></tns2:v4-dhcp-pools><tns2:v4-dhcp-pools><tns2:v4-dhcp-pool-prefix>192.155.2.4</tns2:v4-dhcp-pool-prefix><tns2:v4-dhcp-pool-prefix-length>28</tns2:v4-dhcp-pool-prefix-length><tns2:excluded-v4-addresses><tns2:excluded-v4-address>192.168.1.6</tns2:excluded-v4-address></tns2:excluded-v4-addresses><tns2:excluded-v4-addresses><tns2:excluded-v4-address>192.168.1.7</tns2:excluded-v4-address></tns2:excluded-v4-addresses><tns2:v4-dhcp-relay-gateway-address>2.2.2.2</tns2:v4-dhcp-relay-gateway-address><tns2:v4-dhcp-relay-next-hop-address>1.1.1.2</tns2:v4-dhcp-relay-next-hop-address></tns2:v4-dhcp-pools><tns2:use-v6-default-pool>N</tns2:use-v6-default-pool><tns2:excluded-v6-dhcp-addresses-from-default-pool><tns2:excluded-v6-address>1:5</tns2:excluded-v6-address></tns2:excluded-v6-dhcp-addresses-from-default-pool><tns2:excluded-v6-dhcp-addresses-from-default-pool><tns2:excluded-v6-address>1:6</tns2:excluded-v6-address></tns2:excluded-v6-dhcp-addresses-from-default-pool><tns2:v6-dhcp-pools><tns2:v6-dhcp-pool-prefix>0:0</tns2:v6-dhcp-pool-prefix><tns2:v6-dhcp-pool-prefix-length>28</tns2:v6-dhcp-pool-prefix-length><tns2:excluded-v6-addresses><tns2:excluded-v6-address>1:1</tns2:excluded-v6-address></tns2:excluded-v6-addresses><tns2:excluded-v6-addresses><tns2:excluded-v6-address>2:2</tns2:excluded-v6-address></tns2:excluded-v6-addresses><tns2:v6-dhcp-relay-gateway-address>3:3</tns2:v6-dhcp-relay-gateway-address><tns2:v6-dhcp-relay-next-hop-address>4:4</tns2:v6-dhcp-relay-next-hop-address></tns2:v6-dhcp-pools><tns2:v6-dhcp-pools><tns2:v6-dhcp-pool-prefix>0:0</tns2:v6-dhcp-pool-prefix><tns2:v6-dhcp-pool-prefix-length>28</tns2:v6-dhcp-pool-prefix-length><tns2:excluded-v6-addresses><tns2:excluded-v6-address>1:1</tns2:excluded-v6-address></tns2:excluded-v6-addresses><tns2:excluded-v6-addresses><tns2:excluded-v6-address>2:2</tns2:excluded-v6-address></tns2:excluded-v6-addresses><tns2:v6-dhcp-relay-gateway-address>3:3</tns2:v6-dhcp-relay-gateway-address><tns2:v6-dhcp-relay-next-hop-address>4:4</tns2:v6-dhcp-relay-next-hop-address></tns2:v6-dhcp-pools></tns2:dhcp>" + def expected_rebuildFirewallLite = "<tns2:firewall-lite><tns2:stateful-firewall-lite-v4-enabled>Y</tns2:stateful-firewall-lite-v4-enabled><tns2:stateful-firewall-lite-v6-enabled>N</tns2:stateful-firewall-lite-v6-enabled><tns2:v4-firewall-packet-filters><tns2:v4-firewall-prefix>0.0.0.1</tns2:v4-firewall-prefix><tns2:v4-firewall-prefix-length>1</tns2:v4-firewall-prefix-length><tns2:allow-icmp-ping>Y</tns2:allow-icmp-ping><tns2:udp-ports><tns2:port-number>1</tns2:port-number></tns2:udp-ports><tns2:tcp-ports><tns2:port-number>1</tns2:port-number></tns2:tcp-ports></tns2:v4-firewall-packet-filters><tns2:v4-firewall-packet-filters><tns2:v4-firewall-prefix>0.0.0.2</tns2:v4-firewall-prefix><tns2:v4-firewall-prefix-length>2</tns2:v4-firewall-prefix-length><tns2:allow-icmp-ping>Y</tns2:allow-icmp-ping><tns2:udp-ports><tns2:port-number>2</tns2:port-number></tns2:udp-ports><tns2:tcp-ports><tns2:port-number>2</tns2:port-number></tns2:tcp-ports></tns2:v4-firewall-packet-filters><tns2:v6-firewall-packet-filters><tns2:v6-firewall-prefix>:</tns2:v6-firewall-prefix><tns2:v6-firewall-prefix-length>0</tns2:v6-firewall-prefix-length><tns2:allow-icmp-ping>Y</tns2:allow-icmp-ping><tns2:udp-ports><tns2:port-number>3</tns2:port-number></tns2:udp-ports><tns2:tcp-ports><tns2:port-number>3</tns2:port-number></tns2:tcp-ports></tns2:v6-firewall-packet-filters><tns2:v6-firewall-packet-filters><tns2:v6-firewall-prefix>:</tns2:v6-firewall-prefix><tns2:v6-firewall-prefix-length>1</tns2:v6-firewall-prefix-length><tns2:allow-icmp-ping>Y</tns2:allow-icmp-ping><tns2:udp-ports><tns2:port-number>4</tns2:port-number></tns2:udp-ports><tns2:tcp-ports><tns2:port-number>4</tns2:port-number></tns2:tcp-ports></tns2:v6-firewall-packet-filters></tns2:firewall-lite>" + def expected_rebuildInternetEvcAccess = "<tns2:internet-evc-access-information><tns2:internet-evc-speed-value>8</tns2:internet-evc-speed-value><tns2:internet-evc-speed-units>Mbps</tns2:internet-evc-speed-units><tns2:ip-version>ds</tns2:ip-version></tns2:internet-evc-access-information>" + def expected_rebuildInternetServiceChangeDetails = "<tns:internet-service-change-details><tns2:internet-evc-speed-value>10</tns2:internet-evc-speed-value><tns2:internet-evc-speed-units>Kbps</tns2:internet-evc-speed-units><tns2:t-provided-v4-lan-public-prefixes><tns2:request-index>1</tns2:request-index><tns2:v4-next-hop-address>192.168.1.15</tns2:v4-next-hop-address><tns2:v4-lan-public-prefix>192.168.1.15</tns2:v4-lan-public-prefix><tns2:v4-lan-public-prefix-length>28</tns2:v4-lan-public-prefix-length></tns2:t-provided-v4-lan-public-prefixes><tns2:t-provided-v4-lan-public-prefixes><tns2:request-index>2</tns2:request-index><tns2:v4-next-hop-address>192.168.1.16</tns2:v4-next-hop-address><tns2:v4-lan-public-prefix>192.168.1.16</tns2:v4-lan-public-prefix><tns2:v4-lan-public-prefix-length>28</tns2:v4-lan-public-prefix-length></tns2:t-provided-v4-lan-public-prefixes><tns2:t-provided-v6-lan-public-prefixes><tns2:request-index>1</tns2:request-index><tns2:v6-next-hop-address>2001:1890:12e3:2da::</tns2:v6-next-hop-address><tns2:v6-lan-public-prefix>2001:1890:12e3:2da::</tns2:v6-lan-public-prefix><tns2:v6-lan-public-prefix-length>28</tns2:v6-lan-public-prefix-length></tns2:t-provided-v6-lan-public-prefixes><tns2:t-provided-v6-lan-public-prefixes><tns2:request-index>1</tns2:request-index><tns2:v6-next-hop-address>2001:1890:12e3:2da::</tns2:v6-next-hop-address><tns2:v6-lan-public-prefix>2001:1890:12e3:2da::</tns2:v6-lan-public-prefix><tns2:v6-lan-public-prefix-length>28</tns2:v6-lan-public-prefix-length></tns2:t-provided-v6-lan-public-prefixes></tns:internet-service-change-details>" + def expected_rebuildL2Home = "<tns2:l2-homing-information><tns2:evc-name>AS/VLXM/003717//SW</tns2:evc-name><tns2:topology>MultiPoint</tns2:topology><tns2:preferred-aic-clli>MTSNJA4LCP1</tns2:preferred-aic-clli></tns2:l2-homing-information>" + def expected_rebuildNat = "<tns2:nat><tns2:v4-nat-enabled>Y</tns2:v4-nat-enabled><tns2:v4-nat-mapping-entries><tns2:v4-nat-internal>0.0.0.0</tns2:v4-nat-internal><tns2:v4-nat-next-hop-address>0.0.0.0</tns2:v4-nat-next-hop-address><tns2:v4-nat-external>0.0.0.0</tns2:v4-nat-external></tns2:v4-nat-mapping-entries><tns2:v4-nat-mapping-entries><tns2:v4-nat-internal>0.0.0.1</tns2:v4-nat-internal><tns2:v4-nat-next-hop-address>0.0.0.1</tns2:v4-nat-next-hop-address><tns2:v4-nat-external>0.0.0.1</tns2:v4-nat-external></tns2:v4-nat-mapping-entries></tns2:nat>" + def expected_rebuildPat = "<tns2:pat><tns2:v4-pat-enabled>N</tns2:v4-pat-enabled><tns2:use-v4-default-pool>Y</tns2:use-v4-default-pool><tns2:v4-pat-pools><tns2:v4-pat-pool-prefix>192.168.1.44</tns2:v4-pat-pool-prefix><tns2:v4-pat-pool-prefix-length>0</tns2:v4-pat-pool-prefix-length><tns2:v4-pat-pool-next-hop-address>192.168.1.5</tns2:v4-pat-pool-next-hop-address></tns2:v4-pat-pools><tns2:v4-pat-pools><tns2:v4-pat-pool-prefix>192.168.1.45</tns2:v4-pat-pool-prefix><tns2:v4-pat-pool-prefix-length>28</tns2:v4-pat-pool-prefix-length><tns2:v4-pat-pool-next-hop-address>192.168.1.6</tns2:v4-pat-pool-next-hop-address></tns2:v4-pat-pools></tns2:pat>" + def expected_rebuildStaticRoutes = "<tns2:static-routes><tns2:v4-static-routes><tns2:v4-static-route-prefix>255.255.252.1</tns2:v4-static-route-prefix><tns2:v4-static-route-prefix-length>28</tns2:v4-static-route-prefix-length><tns2:v4-next-hop-address>192.168.1.15</tns2:v4-next-hop-address></tns2:v4-static-routes><tns2:v4-static-routes><tns2:v4-static-route-prefix>255.255.252.2</tns2:v4-static-route-prefix><tns2:v4-static-route-prefix-length>28</tns2:v4-static-route-prefix-length><tns2:v4-next-hop-address>192.168.1.15</tns2:v4-next-hop-address></tns2:v4-static-routes><tns2:v4-static-routes><tns2:v4-static-route-prefix>255.255.252.3</tns2:v4-static-route-prefix><tns2:v4-static-route-prefix-length>28</tns2:v4-static-route-prefix-length><tns2:v4-next-hop-address>192.168.1.15</tns2:v4-next-hop-address></tns2:v4-static-routes><tns2:v6-static-routes><tns2:v6-static-route-prefix>2001:1890:12e3:2da::</tns2:v6-static-route-prefix><tns2:v6-static-route-prefix-length>28</tns2:v6-static-route-prefix-length><tns2:v6-next-hop-address>2001:1890:12e3:2da::</tns2:v6-next-hop-address></tns2:v6-static-routes><tns2:v6-static-routes><tns2:v6-static-route-prefix>2001:1890:12e3:2da::</tns2:v6-static-route-prefix><tns2:v6-static-route-prefix-length>28</tns2:v6-static-route-prefix-length><tns2:v6-next-hop-address>2001:1890:12e3:2da::</tns2:v6-next-hop-address></tns2:v6-static-routes></tns2:static-routes>" + def expected_rebuildUcpeVmsServiceInformation = "<tns2:ucpe-vms-service-information><tns2:transport-service-information><tns2:transport-service-type>AVPN</tns2:transport-service-type><tns2:access-circuit-info><tns2:access-circuit-id>1</tns2:access-circuit-id><tns2:dual-mode>Active</tns2:dual-mode></tns2:access-circuit-info><tns2:access-circuit-info><tns2:access-circuit-id>2</tns2:access-circuit-id><tns2:dual-mode>Standby</tns2:dual-mode></tns2:access-circuit-info></tns2:transport-service-information><tns2:ucpe-information><tns2:ucpe-host-name>hostname</tns2:ucpe-host-name><tns2:ucpe-activation-code>activecode</tns2:ucpe-activation-code><tns2:out-of-band-management-modem>OOB</tns2:out-of-band-management-modem></tns2:ucpe-information><tns2:vnf-list><tns2:vnf-information><tns2:vnf-instance-id>1</tns2:vnf-instance-id><tns2:vnf-sequence-number>1</tns2:vnf-sequence-number><tns2:vnf-type>ZZ</tns2:vnf-type><tns2:vnf-vendor>JUNIPER</tns2:vnf-vendor><tns2:vnf-model>MODEL1</tns2:vnf-model><tns2:vnf-id>1</tns2:vnf-id><tns2:prov-status>1</tns2:prov-status><tns2:operational-state>1</tns2:operational-state><tns2:orchestration-status>1</tns2:orchestration-status><tns2:equipment-role>1</tns2:equipment-role></tns2:vnf-information><tns2:vnf-information><tns2:vnf-instance-id>2</tns2:vnf-instance-id><tns2:vnf-sequence-number>2</tns2:vnf-sequence-number><tns2:vnf-type>HY</tns2:vnf-type><tns2:vnf-vendor>JUNIPER</tns2:vnf-vendor><tns2:vnf-model>MODEL2</tns2:vnf-model><tns2:vnf-id>2</tns2:vnf-id><tns2:prov-status>2</tns2:prov-status><tns2:operational-state>2</tns2:operational-state><tns2:orchestration-status>2</tns2:orchestration-status><tns2:equipment-role>2</tns2:equipment-role></tns2:vnf-information></tns2:vnf-list></tns2:ucpe-vms-service-information>" + def expected_rebuildVrLan = "<tns2:vr-lan><tns2:routing-protocol>none</tns2:routing-protocol><tns2:vr-lan-interface><tns2:vr-designation>primary</tns2:vr-designation><tns2:v4-vr-lan-prefix>10.192.27.254</tns2:v4-vr-lan-prefix><tns2:v4-vr-lan-prefix-length>24</tns2:v4-vr-lan-prefix-length><tns2:v6-vr-lan-prefix>2620:0:10d0:f:ffff:ffff:ffff:fffe</tns2:v6-vr-lan-prefix><tns2:v6-vr-lan-prefix-length>64</tns2:v6-vr-lan-prefix-length><tns2:v4-vce-loopback-address>162.200.3.144</tns2:v4-vce-loopback-address><tns2:v6-vce-wan-address>2001:1890:12e3:2da::</tns2:v6-vce-wan-address><tns2:v4-public-lan-prefixes><tns2:t-provided-v4-lan-public-prefixes><tns2:request-index>1</tns2:request-index><tns2:v4-next-hop-address>192.168.1.2</tns2:v4-next-hop-address><tns2:v4-lan-public-prefix>192.168.1.1</tns2:v4-lan-public-prefix><tns2:v4-lan-public-prefix-length>28</tns2:v4-lan-public-prefix-length></tns2:t-provided-v4-lan-public-prefixes><tns2:t-provided-v4-lan-public-prefixes><tns2:request-index>1</tns2:request-index><tns2:v4-next-hop-address>192.168.1.72</tns2:v4-next-hop-address><tns2:v4-lan-public-prefix>192.168.1.71</tns2:v4-lan-public-prefix><tns2:v4-lan-public-prefix-length>28</tns2:v4-lan-public-prefix-length></tns2:t-provided-v4-lan-public-prefixes><tns2:t-provided-v4-lan-public-prefixes><tns2:request-index>1</tns2:request-index><tns2:v4-next-hop-address>192.168.1.68</tns2:v4-next-hop-address><tns2:v4-lan-public-prefix>192.168.1.67</tns2:v4-lan-public-prefix><tns2:v4-lan-public-prefix-length>28</tns2:v4-lan-public-prefix-length></tns2:t-provided-v4-lan-public-prefixes></tns2:v4-public-lan-prefixes><tns2:v6-public-lan-prefixes><tns2:t-provided-v6-lan-public-prefixes><tns2:request-index>1</tns2:request-index><tns2:v6-next-hop-address>2001:1890:12e3:2da::</tns2:v6-next-hop-address><tns2:v6-lan-public-prefix>2001:1890:12e3:2da::</tns2:v6-lan-public-prefix><tns2:v6-lan-public-prefix-length>28</tns2:v6-lan-public-prefix-length></tns2:t-provided-v6-lan-public-prefixes><tns2:t-provided-v6-lan-public-prefixes><tns2:request-index>1</tns2:request-index><tns2:v6-next-hop-address>2001:1890:12e3:2da::</tns2:v6-next-hop-address><tns2:v6-lan-public-prefix>2001:1890:12e3:3da::</tns2:v6-lan-public-prefix><tns2:v6-lan-public-prefix-length>28</tns2:v6-lan-public-prefix-length></tns2:t-provided-v6-lan-public-prefixes><tns2:t-provided-v6-lan-public-prefixes><tns2:request-index>1</tns2:request-index><tns2:v6-next-hop-address>2001:1890:12e3:2da::</tns2:v6-next-hop-address><tns2:v6-lan-public-prefix>2001:1890:12e3:4da::</tns2:v6-lan-public-prefix><tns2:v6-lan-public-prefix-length>28</tns2:v6-lan-public-prefix-length></tns2:t-provided-v6-lan-public-prefixes></tns2:v6-public-lan-prefixes><tns2:dhcp><tns2:v4-dhcp-server-enabled>Y</tns2:v4-dhcp-server-enabled><tns2:v6-dhcp-server-enabled>N</tns2:v6-dhcp-server-enabled><tns2:use-v4-default-pool>Y</tns2:use-v4-default-pool><tns2:excluded-v4-dhcp-addresses-from-default-pool><tns2:excluded-v4-address>192.168.1.7</tns2:excluded-v4-address></tns2:excluded-v4-dhcp-addresses-from-default-pool><tns2:excluded-v4-dhcp-addresses-from-default-pool><tns2:excluded-v4-address>192.168.1.8</tns2:excluded-v4-address></tns2:excluded-v4-dhcp-addresses-from-default-pool><tns2:v4-dhcp-pools><tns2:v4-dhcp-pool-prefix>192.155.2.3</tns2:v4-dhcp-pool-prefix><tns2:v4-dhcp-pool-prefix-length>28</tns2:v4-dhcp-pool-prefix-length><tns2:excluded-v4-addresses><tns2:excluded-v4-address>192.168.1.5</tns2:excluded-v4-address></tns2:excluded-v4-addresses><tns2:excluded-v4-addresses><tns2:excluded-v4-address>192.168.1.6</tns2:excluded-v4-address></tns2:excluded-v4-addresses><tns2:v4-dhcp-relay-gateway-address>2.2.2.1</tns2:v4-dhcp-relay-gateway-address><tns2:v4-dhcp-relay-next-hop-address>1.1.1.1</tns2:v4-dhcp-relay-next-hop-address></tns2:v4-dhcp-pools><tns2:v4-dhcp-pools><tns2:v4-dhcp-pool-prefix>192.155.2.4</tns2:v4-dhcp-pool-prefix><tns2:v4-dhcp-pool-prefix-length>28</tns2:v4-dhcp-pool-prefix-length><tns2:excluded-v4-addresses><tns2:excluded-v4-address>192.168.1.6</tns2:excluded-v4-address></tns2:excluded-v4-addresses><tns2:excluded-v4-addresses><tns2:excluded-v4-address>192.168.1.7</tns2:excluded-v4-address></tns2:excluded-v4-addresses><tns2:v4-dhcp-relay-gateway-address>2.2.2.2</tns2:v4-dhcp-relay-gateway-address><tns2:v4-dhcp-relay-next-hop-address>1.1.1.2</tns2:v4-dhcp-relay-next-hop-address></tns2:v4-dhcp-pools><tns2:use-v6-default-pool>N</tns2:use-v6-default-pool><tns2:excluded-v6-dhcp-addresses-from-default-pool><tns2:excluded-v6-address>1:5</tns2:excluded-v6-address></tns2:excluded-v6-dhcp-addresses-from-default-pool><tns2:excluded-v6-dhcp-addresses-from-default-pool><tns2:excluded-v6-address>1:6</tns2:excluded-v6-address></tns2:excluded-v6-dhcp-addresses-from-default-pool><tns2:v6-dhcp-pools><tns2:v6-dhcp-pool-prefix>0:0</tns2:v6-dhcp-pool-prefix><tns2:v6-dhcp-pool-prefix-length>28</tns2:v6-dhcp-pool-prefix-length><tns2:excluded-v6-addresses><tns2:excluded-v6-address>1:1</tns2:excluded-v6-address></tns2:excluded-v6-addresses><tns2:excluded-v6-addresses><tns2:excluded-v6-address>2:2</tns2:excluded-v6-address></tns2:excluded-v6-addresses><tns2:v6-dhcp-relay-gateway-address>3:3</tns2:v6-dhcp-relay-gateway-address><tns2:v6-dhcp-relay-next-hop-address>4:4</tns2:v6-dhcp-relay-next-hop-address></tns2:v6-dhcp-pools><tns2:v6-dhcp-pools><tns2:v6-dhcp-pool-prefix>0:0</tns2:v6-dhcp-pool-prefix><tns2:v6-dhcp-pool-prefix-length>28</tns2:v6-dhcp-pool-prefix-length><tns2:excluded-v6-addresses><tns2:excluded-v6-address>1:1</tns2:excluded-v6-address></tns2:excluded-v6-addresses><tns2:excluded-v6-addresses><tns2:excluded-v6-address>2:2</tns2:excluded-v6-address></tns2:excluded-v6-addresses><tns2:v6-dhcp-relay-gateway-address>3:3</tns2:v6-dhcp-relay-gateway-address><tns2:v6-dhcp-relay-next-hop-address>4:4</tns2:v6-dhcp-relay-next-hop-address></tns2:v6-dhcp-pools></tns2:dhcp><tns2:pat><tns2:v4-pat-enabled>N</tns2:v4-pat-enabled><tns2:use-v4-default-pool>Y</tns2:use-v4-default-pool><tns2:v4-pat-pools><tns2:v4-pat-pool-prefix>192.168.1.44</tns2:v4-pat-pool-prefix><tns2:v4-pat-pool-prefix-length>0</tns2:v4-pat-pool-prefix-length><tns2:v4-pat-pool-next-hop-address>192.168.1.5</tns2:v4-pat-pool-next-hop-address></tns2:v4-pat-pools><tns2:v4-pat-pools><tns2:v4-pat-pool-prefix>192.168.1.45</tns2:v4-pat-pool-prefix><tns2:v4-pat-pool-prefix-length>28</tns2:v4-pat-pool-prefix-length><tns2:v4-pat-pool-next-hop-address>192.168.1.6</tns2:v4-pat-pool-next-hop-address></tns2:v4-pat-pools></tns2:pat><tns2:nat><tns2:v4-nat-enabled>Y</tns2:v4-nat-enabled><tns2:v4-nat-mapping-entries><tns2:v4-nat-internal>0.0.0.0</tns2:v4-nat-internal><tns2:v4-nat-next-hop-address>0.0.0.0</tns2:v4-nat-next-hop-address><tns2:v4-nat-external>0.0.0.0</tns2:v4-nat-external></tns2:v4-nat-mapping-entries><tns2:v4-nat-mapping-entries><tns2:v4-nat-internal>0.0.0.1</tns2:v4-nat-internal><tns2:v4-nat-next-hop-address>0.0.0.1</tns2:v4-nat-next-hop-address><tns2:v4-nat-external>0.0.0.1</tns2:v4-nat-external></tns2:v4-nat-mapping-entries></tns2:nat><tns2:firewall-lite><tns2:stateful-firewall-lite-v4-enabled>Y</tns2:stateful-firewall-lite-v4-enabled><tns2:stateful-firewall-lite-v6-enabled>N</tns2:stateful-firewall-lite-v6-enabled><tns2:v4-firewall-packet-filters><tns2:v4-firewall-prefix>0.0.0.1</tns2:v4-firewall-prefix><tns2:v4-firewall-prefix-length>1</tns2:v4-firewall-prefix-length><tns2:allow-icmp-ping>Y</tns2:allow-icmp-ping><tns2:udp-ports><tns2:port-number>1</tns2:port-number></tns2:udp-ports><tns2:tcp-ports><tns2:port-number>1</tns2:port-number></tns2:tcp-ports></tns2:v4-firewall-packet-filters><tns2:v4-firewall-packet-filters><tns2:v4-firewall-prefix>0.0.0.2</tns2:v4-firewall-prefix><tns2:v4-firewall-prefix-length>2</tns2:v4-firewall-prefix-length><tns2:allow-icmp-ping>Y</tns2:allow-icmp-ping><tns2:udp-ports><tns2:port-number>2</tns2:port-number></tns2:udp-ports><tns2:tcp-ports><tns2:port-number>2</tns2:port-number></tns2:tcp-ports></tns2:v4-firewall-packet-filters><tns2:v6-firewall-packet-filters><tns2:v6-firewall-prefix>:</tns2:v6-firewall-prefix><tns2:v6-firewall-prefix-length>0</tns2:v6-firewall-prefix-length><tns2:allow-icmp-ping>Y</tns2:allow-icmp-ping><tns2:udp-ports><tns2:port-number>3</tns2:port-number></tns2:udp-ports><tns2:tcp-ports><tns2:port-number>3</tns2:port-number></tns2:tcp-ports></tns2:v6-firewall-packet-filters><tns2:v6-firewall-packet-filters><tns2:v6-firewall-prefix>:</tns2:v6-firewall-prefix><tns2:v6-firewall-prefix-length>1</tns2:v6-firewall-prefix-length><tns2:allow-icmp-ping>Y</tns2:allow-icmp-ping><tns2:udp-ports><tns2:port-number>4</tns2:port-number></tns2:udp-ports><tns2:tcp-ports><tns2:port-number>4</tns2:port-number></tns2:tcp-ports></tns2:v6-firewall-packet-filters></tns2:firewall-lite><tns2:static-routes><tns2:v4-static-routes><tns2:v4-static-route-prefix>255.255.252.1</tns2:v4-static-route-prefix><tns2:v4-static-route-prefix-length>28</tns2:v4-static-route-prefix-length><tns2:v4-next-hop-address>192.168.1.15</tns2:v4-next-hop-address></tns2:v4-static-routes><tns2:v4-static-routes><tns2:v4-static-route-prefix>255.255.252.2</tns2:v4-static-route-prefix><tns2:v4-static-route-prefix-length>28</tns2:v4-static-route-prefix-length><tns2:v4-next-hop-address>192.168.1.15</tns2:v4-next-hop-address></tns2:v4-static-routes><tns2:v4-static-routes><tns2:v4-static-route-prefix>255.255.252.3</tns2:v4-static-route-prefix><tns2:v4-static-route-prefix-length>28</tns2:v4-static-route-prefix-length><tns2:v4-next-hop-address>192.168.1.15</tns2:v4-next-hop-address></tns2:v4-static-routes><tns2:v6-static-routes><tns2:v6-static-route-prefix>2001:1890:12e3:2da::</tns2:v6-static-route-prefix><tns2:v6-static-route-prefix-length>28</tns2:v6-static-route-prefix-length><tns2:v6-next-hop-address>2001:1890:12e3:2da::</tns2:v6-next-hop-address></tns2:v6-static-routes><tns2:v6-static-routes><tns2:v6-static-route-prefix>2001:1890:12e3:2da::</tns2:v6-static-route-prefix><tns2:v6-static-route-prefix-length>28</tns2:v6-static-route-prefix-length><tns2:v6-next-hop-address>2001:1890:12e3:2da::</tns2:v6-next-hop-address></tns2:v6-static-routes></tns2:static-routes></tns2:vr-lan-interface></tns2:vr-lan>" + def expected_rebuildVrLanInterfacePartial = "<tns2:vr-designation>primary</tns2:vr-designation><tns2:v4-vr-lan-prefix>10.192.27.254</tns2:v4-vr-lan-prefix><tns2:v4-vr-lan-prefix-length>24</tns2:v4-vr-lan-prefix-length><tns2:v6-vr-lan-prefix>2620:0:10d0:f:ffff:ffff:ffff:fffe</tns2:v6-vr-lan-prefix><tns2:v6-vr-lan-prefix-length>64</tns2:v6-vr-lan-prefix-length><tns2:v4-vce-loopback-address>162.200.3.144</tns2:v4-vce-loopback-address><tns2:v6-vce-wan-address>2001:1890:12e3:2da::</tns2:v6-vce-wan-address><tns2:v4-public-lan-prefixes><tns2:t-provided-v4-lan-public-prefixes><tns2:request-index>1</tns2:request-index><tns2:v4-next-hop-address>192.168.1.2</tns2:v4-next-hop-address><tns2:v4-lan-public-prefix>192.168.1.1</tns2:v4-lan-public-prefix><tns2:v4-lan-public-prefix-length>28</tns2:v4-lan-public-prefix-length></tns2:t-provided-v4-lan-public-prefixes><tns2:t-provided-v4-lan-public-prefixes><tns2:request-index>1</tns2:request-index><tns2:v4-next-hop-address>192.168.1.72</tns2:v4-next-hop-address><tns2:v4-lan-public-prefix>192.168.1.71</tns2:v4-lan-public-prefix><tns2:v4-lan-public-prefix-length>28</tns2:v4-lan-public-prefix-length></tns2:t-provided-v4-lan-public-prefixes><tns2:t-provided-v4-lan-public-prefixes><tns2:request-index>1</tns2:request-index><tns2:v4-next-hop-address>192.168.1.68</tns2:v4-next-hop-address><tns2:v4-lan-public-prefix>192.168.1.67</tns2:v4-lan-public-prefix><tns2:v4-lan-public-prefix-length>28</tns2:v4-lan-public-prefix-length></tns2:t-provided-v4-lan-public-prefixes><tns2:t-provided-v4-lan-public-prefixes><tns2:request-index>1</tns2:request-index><tns2:v4-next-hop-address>192.168.1.15</tns2:v4-next-hop-address><tns2:v4-lan-public-prefix>192.168.1.15</tns2:v4-lan-public-prefix><tns2:v4-lan-public-prefix-length>28</tns2:v4-lan-public-prefix-length></tns2:t-provided-v4-lan-public-prefixes><tns2:t-provided-v4-lan-public-prefixes><tns2:request-index>2</tns2:request-index><tns2:v4-next-hop-address>192.168.1.16</tns2:v4-next-hop-address><tns2:v4-lan-public-prefix>192.168.1.16</tns2:v4-lan-public-prefix><tns2:v4-lan-public-prefix-length>28</tns2:v4-lan-public-prefix-length></tns2:t-provided-v4-lan-public-prefixes></tns2:v4-public-lan-prefixes><tns2:v6-public-lan-prefixes><tns2:t-provided-v6-lan-public-prefixes><tns2:request-index>1</tns2:request-index><tns2:v6-next-hop-address>2001:1890:12e3:2da::</tns2:v6-next-hop-address><tns2:v6-lan-public-prefix>2001:1890:12e3:2da::</tns2:v6-lan-public-prefix><tns2:v6-lan-public-prefix-length>28</tns2:v6-lan-public-prefix-length></tns2:t-provided-v6-lan-public-prefixes><tns2:t-provided-v6-lan-public-prefixes><tns2:request-index>1</tns2:request-index><tns2:v6-next-hop-address>2001:1890:12e3:2da::</tns2:v6-next-hop-address><tns2:v6-lan-public-prefix>2001:1890:12e3:3da::</tns2:v6-lan-public-prefix><tns2:v6-lan-public-prefix-length>28</tns2:v6-lan-public-prefix-length></tns2:t-provided-v6-lan-public-prefixes><tns2:t-provided-v6-lan-public-prefixes><tns2:request-index>1</tns2:request-index><tns2:v6-next-hop-address>2001:1890:12e3:2da::</tns2:v6-next-hop-address><tns2:v6-lan-public-prefix>2001:1890:12e3:4da::</tns2:v6-lan-public-prefix><tns2:v6-lan-public-prefix-length>28</tns2:v6-lan-public-prefix-length></tns2:t-provided-v6-lan-public-prefixes><tns2:t-provided-v6-lan-public-prefixes><tns2:request-index>1</tns2:request-index><tns2:v6-next-hop-address>2001:1890:12e3:2da::</tns2:v6-next-hop-address><tns2:v6-lan-public-prefix>2001:1890:12e3:2da::</tns2:v6-lan-public-prefix><tns2:v6-lan-public-prefix-length>28</tns2:v6-lan-public-prefix-length></tns2:t-provided-v6-lan-public-prefixes><tns2:t-provided-v6-lan-public-prefixes><tns2:request-index>1</tns2:request-index><tns2:v6-next-hop-address>2001:1890:12e3:2da::</tns2:v6-next-hop-address><tns2:v6-lan-public-prefix>2001:1890:12e3:2da::</tns2:v6-lan-public-prefix><tns2:v6-lan-public-prefix-length>28</tns2:v6-lan-public-prefix-length></tns2:t-provided-v6-lan-public-prefixes></tns2:v6-public-lan-prefixes>" + + @Before + public void setUp() { + def responseAsString = getFile("sdncadaptercallbackrequest.xml") + def varrequestData=utils.getNodeText(responseAsString,"RequestData") + //def varResponseListData = StringEscapeUtils.unescapeXml(varrequestData) + def varResponseListData = varrequestData.replace("&", "&") + origXmlResponse = utils.getNodeXml(varResponseListData, "layer3-service-list").drop(38).trim() + + } + + @Test + public void testBuildL2Home() { + def rebuildL2Home = utils.buildL2HomingInformation(origXmlResponse) + println " rebuildL2Home: " + println " actual - " + rebuildL2Home + println " expected - " + expected_rebuildL2Home + assertEquals("rebuildL2Home - expected vs actual", expected_rebuildL2Home, rebuildL2Home) + } + + @Test + public void testBuildInternetEvcAccess() { + def rebuildInternetEvcAccess = utils.buildInternetEvcAccessInformation(origXmlResponse) + println " rebuildInternetEvcAccess: " + println " actual - " + rebuildInternetEvcAccess + println " expected - " + expected_rebuildInternetEvcAccess + assertEquals("rebuildInternetEvcAccess - expected vs actual", expected_rebuildInternetEvcAccess, rebuildInternetEvcAccess) + } + + @Test + public void testBuildInternetServiceChangeDetails() { + def rebuildInternetServiceChangeDetails = utils.buildInternetServiceChangeDetails(origXmlResponse) + println " rebuildInternetServiceChangeDetails: " + println " actual - " + rebuildInternetServiceChangeDetails + println " expected - " + expected_rebuildInternetServiceChangeDetails + assertEquals("rebuildInternetServiceChangeDetails - expected vs actual", expected_rebuildInternetServiceChangeDetails, rebuildInternetServiceChangeDetails) + } + + // Coming v100 + @Test + @Ignore + public void testBuildUcpeVmsServiceInformation() { + def rebuildUcpeVmsServiceInformation = utils.buildUcpeVmsServiceInformation(origXmlResponse) + println " rebuildUcpeVmsServiceInformation: " + println " actual - " + rebuildUcpeVmsServiceInformation + println " expected - " + expected_rebuildUcpeVmsServiceInformation + assertEquals("rebuildUcpeVmsServiceInformation - expected vs actual", expected_rebuildUcpeVmsServiceInformation, rebuildUcpeVmsServiceInformation) + } + + @Test + public void testBuildElements() { + // testing utility codes: buildElements() & buildElementsUnblunded() + def internetServiceChangeDetails = utils.getNodeXml(origXmlResponse, "internet-service-change-details").drop(38).trim() + def buildElements = '' + buildElements = "<tns2:internet-service-change-details>" + buildElements += utils.buildElements(internetServiceChangeDetails, ["internet-evc-speed-value"], "") + buildElements += utils.buildElements(internetServiceChangeDetails, ["internet-evc-speed-units"], "") + def tProvidedV4LanPublicPrefixesChangesList = ["request-index", "v4-next-hop-address", "v4-lan-public-prefix", "v4-lan-public-prefix-length"] + buildElements += utils.buildElementsUnbounded(internetServiceChangeDetails, tProvidedV4LanPublicPrefixesChangesList, "t-provided-v4-lan-public-prefixes") + buildElements += "</tns2:internet-service-change-details>" + println " buildElements: " + println " actual - " + buildElements + println " expected - " + expected_buildElements + assertEquals("buildElements - expected vs actual", expected_buildElements, buildElements) + } + + @Test + public void testBuildVrLan() { + def rebuildVrLan = utils.buildVrLan(origXmlResponse) + println " rebuildVrLans: " + println " actual - " + rebuildVrLan + println " expected - " + expected_rebuildVrLan + assertEquals("rebuildVrLan - expected vs actual", expected_rebuildVrLan, rebuildVrLan) + } + + @Test + public void testBuildVrLanInterfacePartial() { + def rebuildVrLanInterfacePartial = utils.buildVrLanInterfacePartial(origXmlResponse) + println " rebuildVrLanInterfacePartial: " + println " actual - " + rebuildVrLanInterfacePartial + println " expected - " + expected_rebuildVrLanInterfacePartial + assertEquals("rebuildVrLanInterfacePartial - expected vs actual", expected_rebuildVrLanInterfacePartial, rebuildVrLanInterfacePartial) + } + + @Test + public void testBuildDhcp() { + def rebuildDhcp = utils.buildDhcp(origXmlResponse) + println " rebuildDhcp: " + println " actual - " + rebuildDhcp + println " expected - " + expected_rebuildDhcp + assertEquals("rebuildDhcp - expected vs actual", expected_rebuildDhcp, rebuildDhcp) + } + + @Test + public void testBuildPat() { + def rebuildPat = utils.buildPat(origXmlResponse) + println " rebuildPat: " + println " actual - " + rebuildPat + println " expected - " + expected_rebuildPat + assertEquals("rebuildPat - expected vs actual", expected_rebuildPat, rebuildPat) + } + + @Test + public void testBuildNat() { + def rebuildNat = utils.buildNat(origXmlResponse) + println " rebuildNat: " + println " actual - " + rebuildNat + println " expected - " + expected_rebuildNat + assertEquals("rebuildNat - expected vs actual", expected_rebuildNat, rebuildNat) + } + + @Test + public void testBuildFirewallLite() { + def rebuildFirewallLite = utils.buildFirewallLite(origXmlResponse) + println " rebuildFirewallLite: " + println " actual - " + rebuildFirewallLite + println " expected - " + expected_rebuildFirewallLite + assertEquals("rebuildFirewallLite - expected vs actual", expected_rebuildFirewallLite, rebuildFirewallLite) + } + + @Test + public void testBuildStaticRoutes() { + def rebuildStaticRoutes = utils.buildStaticRoutes(origXmlResponse) + println " rebuildStaticRoutes: " + println " actual - " + rebuildStaticRoutes + println " expected - " + expected_rebuildStaticRoutes + assertEquals("rebuildStaticRoutes - expected vs actual", expected_rebuildStaticRoutes, rebuildStaticRoutes) + } + + @Test + public void testGetBasicAuth(){ + def encodedAuth = utils.getBasicAuth("3E3CFA7BE2F6107AAD4AAA65F8976690","07a7159d3bf51a0e53be7a8f89699be7") + assertEquals("Basic bXlTdHJpbmc=", encodedAuth) + } + + @Test + public void testEncrypt(){ + def encrypted = utils.encrypt("myString","07a7159d3bf51a0e53be7a8f89699be7") + assertEquals("3E3CFA7BE2F6107AAD4AAA65F8976690", encrypted) + + //use to get value for urn properties + //println(utils.encrypt("password")) + } + + @Test + public void testDecrypt(){ + def decrypted = utils.decrypt("3E3CFA7BE2F6107AAD4AAA65F8976690", "07a7159d3bf51a0e53be7a8f89699be7") + assertEquals("myString", decrypted) + } + + @Test + public void testGetPBGFList(){ + def responseAsString = getFile("sdncDeleteResponse.xml") + def nodes = utils.getPBGFList("true", responseAsString) + //assertEquals(2, nodes.size()) + while(!nodes.empty){ + def myBGFXML = nodes.remove(0) + def myBGF= new XmlSlurper().parseText(myBGFXML) + println "borderElmtId: " + myBGF.'border-element-id' + println "vlanid: " + myBGF.'vlan-id' +"\n" + } + } + + public String getFile(String fileName) { + def SLASH = File.separator + def pathBase = ' ' + def fileAsString = '' + try { + pathBase = new File(".").getCanonicalPath() + //println "pathBase " + pathBase + "${SLASH}src${SLASH}test${SLASH}resources${SLASH}${fileName}" + fileAsString = new File(pathBase, "${SLASH}src${SLASH}test${SLASH}resources${SLASH}${fileName}").getText() + } catch (Exception ex) { + println " *** getFile error: " + ex.getStackTrace() + } finally { + return fileAsString + } + } + + +}
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/openecomp/mso/bpmn/common/scripts/SDNCAdapterTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/openecomp/mso/bpmn/common/scripts/SDNCAdapterTest.groovy new file mode 100644 index 0000000000..f71e4d2516 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/openecomp/mso/bpmn/common/scripts/SDNCAdapterTest.groovy @@ -0,0 +1,948 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common.scripts; + +import static org.mockito.Mockito.* + +import org.camunda.bpm.engine.ProcessEngineServices +import org.camunda.bpm.engine.RepositoryService +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.camunda.bpm.engine.repository.ProcessDefinition +import org.junit.Before +import org.junit.Test +import org.junit.runner.RunWith +import org.mockito.MockitoAnnotations +import org.mockito.runners.MockitoJUnitRunner +import org.mockito.internal.debugging.MockitoDebuggerImpl +import org.openecomp.mso.bpmn.common.scripts.SDNCAdapter; + +import org.openecomp.mso.bpmn.mock.FileUtil + +@RunWith(MockitoJUnitRunner.class) +public class SDNCAdapterTest { + + @Before + public void init() + { + MockitoAnnotations.initMocks(this) + System.setProperty("jboss.qualified.host.name","myhost.att.com") + } + + + def workflowResponse = """<sdncadapterworkflow:SDNCAdapterWorkflowResponse xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1" + xmlns:tag0="http://org.openecomp/workflow/sdnc/adapter/schema/v1" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <sdncadapterworkflow:response-data> + <tag0:CallbackHeader> + <tag0:RequestId>testRequestId</tag0:RequestId> + <tag0:ResponseCode>200</tag0:ResponseCode> + <tag0:ResponseMessage>OK</tag0:ResponseMessage> + </tag0:CallbackHeader> + <tag0:RequestData xsi:type="xs:string"> <layer3-service-list xmlns="com:att:sdnctl:l3api"> + <service-instance-id>FK/VLXM/003717//SW_INTERNET</service-instance-id> + <service-status> + <rpc-name>service-configuration-operation</rpc-name> + <rpc-action>activate</rpc-action> + <request-status>synccomplete</request-status> + <final-indicator>N</final-indicator> + <l3sdn-action>Layer3ServiceActivateRequest</l3sdn-action> + <l3sdn-subaction>SUPP</l3sdn-subaction> + <response-timestamp>2015-04-28T21:32:11.386Z</response-timestamp> + </service-status> + <service-data> + <internet-evc-access-information> + <ip-version>ds</ip-version> + <internet-evc-speed-value>8</internet-evc-speed-value> + <internet-evc-speed-units>Mbps</internet-evc-speed-units> + </internet-evc-access-information> + <vr-lan xmlns="com:att:sdnctl:l3api"> + <vr-lan-interface> + <static-routes> + <v6-static-routes> + <v6-next-hop-address>2001:1890:12e3:2da::</v6-next-hop-address> + <v6-static-route-prefix>2001:1890:12e3:2da::</v6-static-route-prefix> + <v6-static-route-prefix-length>28</v6-static-route-prefix-length> + </v6-static-routes> + <v4-static-routes> + <v4-static-route-prefix>255.255.252.1</v4-static-route-prefix> + <v4-next-hop-address>192.168.1.15</v4-next-hop-address> + <v4-static-route-prefix-length>28</v4-static-route-prefix-length> + </v4-static-routes> + <v6-static-routes> + <v6-next-hop-address>2001:1890:12e3:2da::</v6-next-hop-address> + <v6-static-route-prefix>2001:1890:12e3:2da::</v6-static-route-prefix> + <v6-static-route-prefix-length>28</v6-static-route-prefix-length> + </v6-static-routes> + <v4-static-routes> + <v4-static-route-prefix>255.255.252.2</v4-static-route-prefix> + <v4-next-hop-address>192.168.1.15</v4-next-hop-address> + <v4-static-route-prefix-length>28</v4-static-route-prefix-length> + </v4-static-routes> + <v4-static-routes> + <v4-static-route-prefix>255.255.252.3</v4-static-route-prefix> + <v4-next-hop-address>192.168.1.15</v4-next-hop-address> + <v4-static-route-prefix-length>28</v4-static-route-prefix-length> + </v4-static-routes> + </static-routes> + <dhcp> + <v6-dhcp-server-enabled>N</v6-dhcp-server-enabled> + <v4-dhcp-server-enabled>Y</v4-dhcp-server-enabled> + <use-v6-default-pool>N</use-v6-default-pool> + <excluded-v4-dhcp-addresses-from-default-pool> + <excluded-v4-address>192.168.1.7</excluded-v4-address> + </excluded-v4-dhcp-addresses-from-default-pool> + <excluded-v4-dhcp-addresses-from-default-pool> + <excluded-v4-address>192.168.1.8</excluded-v4-address> + </excluded-v4-dhcp-addresses-from-default-pool> + <v4-dhcp-pools> + <v4-dhcp-relay-next-hop-address>1.1.1.1</v4-dhcp-relay-next-hop-address> + <v4-dhcp-pool-prefix-length>28</v4-dhcp-pool-prefix-length> + <excluded-v4-addresses> + <excluded-v4-address>192.168.1.5</excluded-v4-address> + </excluded-v4-addresses> + <v4-dhcp-relay-gateway-address>2.2.2.1</v4-dhcp-relay-gateway-address> + <excluded-v4-addresses> + <excluded-v4-address>192.168.1.6</excluded-v4-address> + </excluded-v4-addresses> + <v4-dhcp-pool-prefix>192.155.2.3</v4-dhcp-pool-prefix> + </v4-dhcp-pools> + <v4-dhcp-pools> + <v4-dhcp-relay-next-hop-address>1.1.1.2</v4-dhcp-relay-next-hop-address> + <v4-dhcp-pool-prefix-length>28</v4-dhcp-pool-prefix-length> + <excluded-v4-addresses> + <excluded-v4-address>192.168.1.6</excluded-v4-address> + </excluded-v4-addresses> + <v4-dhcp-relay-gateway-address>2.2.2.2</v4-dhcp-relay-gateway-address> + <excluded-v4-addresses> + <excluded-v4-address>192.168.1.7</excluded-v4-address> + </excluded-v4-addresses> + <v4-dhcp-pool-prefix>192.155.2.4</v4-dhcp-pool-prefix> + </v4-dhcp-pools> + <use-v4-default-pool>Y</use-v4-default-pool> + <excluded-v6-dhcp-addresses-from-default-pool> + <excluded-v6-address>1:5</excluded-v6-address> + </excluded-v6-dhcp-addresses-from-default-pool> + <excluded-v6-dhcp-addresses-from-default-pool> + <excluded-v6-address>1:6</excluded-v6-address> + </excluded-v6-dhcp-addresses-from-default-pool> + <v6-dhcp-pools> + <v6-dhcp-relay-next-hop-address>4:4</v6-dhcp-relay-next-hop-address> + <v6-dhcp-pool-prefix-length>28</v6-dhcp-pool-prefix-length> + <excluded-v6-addresses> + <excluded-v6-address>1:1</excluded-v6-address> + </excluded-v6-addresses> + <v6-dhcp-relay-gateway-address>3:3</v6-dhcp-relay-gateway-address> + <excluded-v6-addresses> + <excluded-v6-address>2:2</excluded-v6-address> + </excluded-v6-addresses> + <v6-dhcp-pool-prefix>0:0</v6-dhcp-pool-prefix> + </v6-dhcp-pools> + <v6-dhcp-pools> + <v6-dhcp-relay-next-hop-address>4:4</v6-dhcp-relay-next-hop-address> + <v6-dhcp-pool-prefix-length>28</v6-dhcp-pool-prefix-length> + <excluded-v6-addresses> + <excluded-v6-address>1:1</excluded-v6-address> + </excluded-v6-addresses> + <v6-dhcp-relay-gateway-address>3:3</v6-dhcp-relay-gateway-address> + <excluded-v6-addresses> + <excluded-v6-address>2:2</excluded-v6-address> + </excluded-v6-addresses> + <v6-dhcp-pool-prefix>0:0</v6-dhcp-pool-prefix> + </v6-dhcp-pools> + </dhcp> + <firewall-lite> + <stateful-firewall-lite-v6-enabled>N</stateful-firewall-lite-v6-enabled> + <stateful-firewall-lite-v4-enabled>Y</stateful-firewall-lite-v4-enabled> + <v4-firewall-packet-filters> + <v4-firewall-prefix>0.0.0.1</v4-firewall-prefix> + <v4-firewall-prefix-length>1</v4-firewall-prefix-length> + <allow-icmp-ping>Y</allow-icmp-ping> + <udp-ports> + <port-number>1</port-number> + </udp-ports> + <tcp-ports> + <port-number>1</port-number> + </tcp-ports> + </v4-firewall-packet-filters> + <v4-firewall-packet-filters> + <v4-firewall-prefix>0.0.0.2</v4-firewall-prefix> + <v4-firewall-prefix-length>2</v4-firewall-prefix-length> + <allow-icmp-ping>Y</allow-icmp-ping> + <udp-ports> + <port-number>2</port-number> + </udp-ports> + <tcp-ports> + <port-number>2</port-number> + </tcp-ports> + </v4-firewall-packet-filters> + <v6-firewall-packet-filters> + <v6-firewall-prefix>:</v6-firewall-prefix> + <v6-firewall-prefix-length>0</v6-firewall-prefix-length> + <allow-icmp-ping>Y</allow-icmp-ping> + <udp-ports> + <port-number>3</port-number> + </udp-ports> + <tcp-ports> + <port-number>3</port-number> + </tcp-ports> + </v6-firewall-packet-filters> + <v6-firewall-packet-filters> + <v6-firewall-prefix>:</v6-firewall-prefix> + <v6-firewall-prefix-length>1</v6-firewall-prefix-length> + <allow-icmp-ping>Y</allow-icmp-ping> + <udp-ports> + <port-number>4</port-number> + </udp-ports> + <tcp-ports> + <port-number>4</port-number> + </tcp-ports> + </v6-firewall-packet-filters> + </firewall-lite> + <pat> + <v4-pat-pools> + <v4-pat-pool-prefix>192.168.1.44</v4-pat-pool-prefix> + <v4-pat-pool-next-hop-address>192.168.1.5</v4-pat-pool-next-hop-address> + <v4-pat-pool-prefix-length>0</v4-pat-pool-prefix-length> + </v4-pat-pools> + <use-v4-default-pool>Y</use-v4-default-pool> + <v4-pat-enabled>N</v4-pat-enabled> + <v4-pat-pools> + <v4-pat-pool-prefix>192.168.1.45</v4-pat-pool-prefix> + <v4-pat-pool-next-hop-address>192.168.1.6</v4-pat-pool-next-hop-address> + <v4-pat-pool-prefix-length>28</v4-pat-pool-prefix-length> + </v4-pat-pools> + </pat> + <nat> + <v4-nat-enabled>Y</v4-nat-enabled> + <v4-nat-mapping-entries> + <v4-nat-internal>0.0.0.0</v4-nat-internal> + <v4-nat-next-hop-address>0.0.0.0</v4-nat-next-hop-address> + <v4-nat-external>0.0.0.0</v4-nat-external> + </v4-nat-mapping-entries> + <v4-nat-mapping-entries> + <v4-nat-internal>0.0.0.1</v4-nat-internal> + <v4-nat-next-hop-address>0.0.0.1</v4-nat-next-hop-address> + <v4-nat-external>0.0.0.1</v4-nat-external> + </v4-nat-mapping-entries> + </nat> + <vr-designation>primary</vr-designation> + <v4-vce-loopback-address>162.200.3.144</v4-vce-loopback-address> + <v6-vr-lan-prefix-length>64</v6-vr-lan-prefix-length> + <v6-vce-wan-address>2001:1890:12e3:2da::</v6-vce-wan-address> + <v6-vr-lan-prefix>2620:0:10d0:f:ffff:ffff:ffff:fffe</v6-vr-lan-prefix> + <v4-vr-lan-prefix-length>24</v4-vr-lan-prefix-length> + <v4-vr-lan-prefix>10.192.27.254</v4-vr-lan-prefix> + <v4-public-lan-prefixes> + <t-provided-v4-lan-public-prefixes> + <request-index>1</request-index> + <v4-next-hop-address>192.168.1.2</v4-next-hop-address> + <v4-lan-public-prefix>192.168.1.1</v4-lan-public-prefix> + <v4-lan-public-prefix-length>28</v4-lan-public-prefix-length> + </t-provided-v4-lan-public-prefixes> + <t-provided-v4-lan-public-prefixes> + <request-index>1</request-index> + <v4-next-hop-address>192.168.1.72</v4-next-hop-address> + <v4-lan-public-prefix>192.168.1.71</v4-lan-public-prefix> + <v4-lan-public-prefix-length>28</v4-lan-public-prefix-length> + </t-provided-v4-lan-public-prefixes> + <t-provided-v4-lan-public-prefixes> + <request-index>1</request-index> + <v4-next-hop-address>192.168.1.68</v4-next-hop-address> + <v4-lan-public-prefix>192.168.1.67</v4-lan-public-prefix> + <v4-lan-public-prefix-length>28</v4-lan-public-prefix-length> + </t-provided-v4-lan-public-prefixes> + </v4-public-lan-prefixes> + <v6-public-lan-prefixes> + <t-provided-v6-lan-public-prefixes> + <request-index>1</request-index> + <v6-next-hop-address>2001:1890:12e3:2da::</v6-next-hop-address> + <v6-lan-public-prefix>2001:1890:12e3:2da::</v6-lan-public-prefix> + <v6-lan-public-prefix-length>28</v6-lan-public-prefix-length> + </t-provided-v6-lan-public-prefixes> + <t-provided-v6-lan-public-prefixes> + <request-index>1</request-index> + <v6-next-hop-address>2001:1890:12e3:2da::</v6-next-hop-address> + <v6-lan-public-prefix>2001:1890:12e3:3da::</v6-lan-public-prefix> + <v6-lan-public-prefix-length>28</v6-lan-public-prefix-length> + </t-provided-v6-lan-public-prefixes> + <t-provided-v6-lan-public-prefixes> + <request-index>1</request-index> + <v6-next-hop-address>2001:1890:12e3:2da::</v6-next-hop-address> + <v6-lan-public-prefix>2001:1890:12e3:4da::</v6-lan-public-prefix> + <v6-lan-public-prefix-length>28</v6-lan-public-prefix-length> + </t-provided-v6-lan-public-prefixes> + </v6-public-lan-prefixes> + </vr-lan-interface> + <routing-protocol>none</routing-protocol> + </vr-lan> +<ucpe-vms-service-information> + <transport-service-information> + <transport-service-type>AVPN</transport-service-type> + <access-circuit-info> + <access-circuit-id>1</access-circuit-id> + <dual-mode>Active</dual-mode> + </access-circuit-info> + <access-circuit-info> + <access-circuit-id>2</access-circuit-id> + <dual-mode>Standby</dual-mode> + </access-circuit-info> + </transport-service-information> + <ucpe-information> + <ucpe-host-name>hostname</ucpe-host-name> + <ucpe-activation-code>activecode</ucpe-activation-code> + <out-of-band-management-modem>OOB</out-of-band-management-modem> + </ucpe-information> + <vnf-list> + <vnf-information> + <vnf-instance-id>1</vnf-instance-id> + <vnf-sequence-number>1</vnf-sequence-number> + <vnf-type>ZZ</vnf-type> + <vnf-vendor>JUNIPER</vnf-vendor> + <vnf-model>MODEL1</vnf-model> + <vnf-id>1</vnf-id> + <prov-status>1</prov-status> + <operational-state>1</operational-state> + <orchestration-status>1</orchestration-status> + <equipment-role>1</equipment-role> + </vnf-information> + <vnf-information> + <vnf-instance-id>2</vnf-instance-id> + <vnf-sequence-number>2</vnf-sequence-number> + <vnf-type>HY</vnf-type> + <vnf-vendor>JUNIPER</vnf-vendor> + <vnf-model>MODEL2</vnf-model> + <vnf-id>2</vnf-id> + <prov-status>2</prov-status> + <operational-state>2</operational-state> + <orchestration-status>2</orchestration-status> + <equipment-role>2</equipment-role> + </vnf-information> + </vnf-list> + </ucpe-vms-service-information> + <request-information> + <request-action>Layer3ServiceActivateRequest</request-action> + <order-number>4281555</order-number> + <request-id>155415ab-b4a7-4382-b4c6-d17d9sm42855</request-id> + <notification-url>https://csi-tst-q22.it.att.com:22443/Services/com/cingular/csi/sdn/SendManagedNetworkStatusNotification.jws</notification-url> + <source>OMX</source> + <order-version>1</order-version> + </request-information> + <sdnc-request-header> + <svc-action>activate</svc-action> + <svc-notification-url>https://msojra.mtsnjdcp1.aic.cip.att.com:8443/adapters/rest/SDNCNotify</svc-notification-url> + <svc-request-id>5b1f3c5d-cdf9-488d-8a4b-d3f1229d7760</svc-request-id> + </sdnc-request-header> + <l2-homing-information> + <topology>MultiPoint</topology> + <preferred-aic-clli>MTSNJA4LCP1</preferred-aic-clli> + <evc-name>AS/VLXM/003717//SW</evc-name> + </l2-homing-information> + <service-information> + <service-instance-id>FK/VLXM/003717//SW_INTERNET</service-instance-id> + <subscriber-name>ST E2E Test42855_1300004281555</subscriber-name> + <service-type>SDN-ETHERNET-INTERNET</service-type> + </service-information> + <internet-service-change-details> + <internet-evc-speed-value>10</internet-evc-speed-value> + <internet-evc-speed-units>Kbps</internet-evc-speed-units> + <t-provided-v4-lan-public-prefixes> + <request-index>1</request-index> + <v4-next-hop-address>192.168.1.15</v4-next-hop-address> + <v4-lan-public-prefix>192.168.1.15</v4-lan-public-prefix> + <v4-lan-public-prefix-length>28</v4-lan-public-prefix-length> + </t-provided-v4-lan-public-prefixes> + <t-provided-v4-lan-public-prefixes> + <request-index>2</request-index> + <v4-next-hop-address>192.168.1.16</v4-next-hop-address> + <v4-lan-public-prefix>192.168.1.16</v4-lan-public-prefix> + <v4-lan-public-prefix-length>28</v4-lan-public-prefix-length> + </t-provided-v4-lan-public-prefixes> + <t-provided-v6-lan-public-prefixes> + <request-index>1</request-index> + <v6-next-hop-address>2001:1890:12e3:2da::</v6-next-hop-address> + <v6-lan-public-prefix>2001:1890:12e3:2da::</v6-lan-public-prefix> + <v6-lan-public-prefix-length>28</v6-lan-public-prefix-length> + </t-provided-v6-lan-public-prefixes> + <t-provided-v6-lan-public-prefixes> + <request-index>1</request-index> + <v6-next-hop-address>2001:1890:12e3:2da::</v6-next-hop-address> + <v6-lan-public-prefix>2001:1890:12e3:2da::</v6-lan-public-prefix> + <v6-lan-public-prefix-length>28</v6-lan-public-prefix-length> + </t-provided-v6-lan-public-prefixes> + </internet-service-change-details> + </service-data> + </layer3-service-list> +</tag0:RequestData> + </sdncadapterworkflow:response-data> +</sdncadapterworkflow:SDNCAdapterWorkflowResponse>""" + + String sdncAdapterRequest = """ + <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"> + <SOAP-ENV:Body> + <aetgt:SDNCAdapterRequest xmlns:aetgt="http://org.openecomp/workflow/sdnc/adapter/schema/v1" xmlns:sdncadaptersc="http://org.openecomp/workflow/sdnc/adapter/schema/v1"> + <sdncadapter:RequestHeader xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1"> + <sdncadapter:RequestId>745b1b50-e39e-4685-9cc8-c71f0bde8bf0</sdncadapter:RequestId> + <sdncadapter:SvcAction>query</sdncadapter:SvcAction> + <sdncadapter:SvcOperation>services/layer3-service-list/AS%2FVLXM%2F000199%2F%2FSB_INTERNET</sdncadapter:SvcOperation> + <sdncadapter:CallbackUrl>http://myhost.att.com:28080/mso/sdncAdapterCallbackServiceImpl</sdncadapter:CallbackUrl> + </sdncadapter:RequestHeader> + <sdncadaptersc:RequestData><rest:payload xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd" + contentType="text/xml"> + <service-request xmlns="http://org.openecomp/mso/request/details/schema/v1"> + <request-information> + <request-id>12570a36-7388-4c0a-bec4-189ce3kg9956</request-id> + <request-action>GetLayer3ServiceDetailsRequest</request-action> + <source>OMX</source> + </request-information> + <service-information> + <service-type>SDN-ETHERNET-INTERNET</service-type> + <service-instance-id>PD/VLXM/003717//SW_INTERNET</service-instance-id> + </service-information> + </service-request> +</rest:payload></sdncadaptersc:RequestData></aetgt:SDNCAdapterRequest></SOAP-ENV:Body></SOAP-ENV:Envelope>""" + +def sdncAdapterResponse = """<sdncadapterworkflow:SDNCAdapterWorkflowResponse xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"> +<sdncadapterworkflow:response-data> +<tag0:CallbackHeader xmlns:tag0="http://org.openecomp/workflow/sdnc/adapter/schema/v1"> + <tag0:RequestId>39542e39-ccc3-4d1a-8b79-04ce88526613</tag0:RequestId> + <tag0:ResponseCode>404</tag0:ResponseCode> + <tag0:ResponseMessage>Error processing request to SDNC. Not Found. + https://sdncodl.us.aic.cip.att.com:8443/restconf/config/L3SDN-API:services/layer3-service-list/MVM%2FVLXP%2F000855%2F%2FShakeout. + SDNC Returned-[error-type:application, error-tag:data-missing, + error-message:Request could not be completed because the relevant + data model content does not exist.]</tag0:ResponseMessage> +</tag0:CallbackHeader> +</sdncadapterworkflow:response-data> +</sdncadapterworkflow:SDNCAdapterWorkflowResponse> +""" + +def workflowErrorResponse = """<aetgt:WorkflowException xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"> + <aetgt:ErrorMessage>Received error from SDN-C: Error processing request to SDNC. Not Found. + https://sdncodl.us.aic.cip.att.com:8443/restconf/config/L3SDN-API:services/layer3-service-list/MVM%2FVLXP%2F000855%2F%2FShakeout. + SDNC Returned-[error-type:application, error-tag:data-missing, + error-message:Request could not be completed because the relevant + data model content does not exist.]</aetgt:ErrorMessage> + <aetgt:ErrorCode>5300</aetgt:ErrorCode> + <aetgt:SourceSystemErrorCode>404</aetgt:SourceSystemErrorCode> + </aetgt:WorkflowException>""" + +def workflowErrorResponse1 = """<aetgt:WorkflowException xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"> + <aetgt:ErrorMessage>Invalid Callback Response from SDNC Adapter</aetgt:ErrorMessage> + <aetgt:ErrorCode>5300</aetgt:ErrorCode> + </aetgt:WorkflowException>""" + +def enhancedCallbackRequestData = + """<tag0:RequestData xmlns:tag0="http://org.openecomp/workflow/sdnc/adapter/schema/v1" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:type="xs:string"> <layer3-service-list xmlns="com:att:sdnctl:l3api"> + <service-instance-id>FK/VLXM/003717//SW_INTERNET</service-instance-id> + <service-status> + <rpc-name>service-configuration-operation</rpc-name> + <rpc-action>activate</rpc-action> + <request-status>synccomplete</request-status> + <final-indicator>N</final-indicator> + <l3sdn-action>Layer3ServiceActivateRequest</l3sdn-action> + <l3sdn-subaction>SUPP</l3sdn-subaction> + <response-timestamp>2015-04-28T21:32:11.386Z</response-timestamp> + </service-status> + <service-data> + <internet-evc-access-information> + <ip-version>ds</ip-version> + <internet-evc-speed-value>8</internet-evc-speed-value> + <internet-evc-speed-units>Mbps</internet-evc-speed-units> + </internet-evc-access-information> + <vr-lan xmlns="com:att:sdnctl:l3api"> + <vr-lan-interface> + <static-routes> + <v6-static-routes> + <v6-next-hop-address>2001:1890:12e3:2da::</v6-next-hop-address> + <v6-static-route-prefix>2001:1890:12e3:2da::</v6-static-route-prefix> + <v6-static-route-prefix-length>28</v6-static-route-prefix-length> + </v6-static-routes> + <v4-static-routes> + <v4-static-route-prefix>255.255.252.1</v4-static-route-prefix> + <v4-next-hop-address>192.168.1.15</v4-next-hop-address> + <v4-static-route-prefix-length>28</v4-static-route-prefix-length> + </v4-static-routes> + <v6-static-routes> + <v6-next-hop-address>2001:1890:12e3:2da::</v6-next-hop-address> + <v6-static-route-prefix>2001:1890:12e3:2da::</v6-static-route-prefix> + <v6-static-route-prefix-length>28</v6-static-route-prefix-length> + </v6-static-routes> + <v4-static-routes> + <v4-static-route-prefix>255.255.252.2</v4-static-route-prefix> + <v4-next-hop-address>192.168.1.15</v4-next-hop-address> + <v4-static-route-prefix-length>28</v4-static-route-prefix-length> + </v4-static-routes> + <v4-static-routes> + <v4-static-route-prefix>255.255.252.3</v4-static-route-prefix> + <v4-next-hop-address>192.168.1.15</v4-next-hop-address> + <v4-static-route-prefix-length>28</v4-static-route-prefix-length> + </v4-static-routes> + </static-routes> + <dhcp> + <v6-dhcp-server-enabled>N</v6-dhcp-server-enabled> + <v4-dhcp-server-enabled>Y</v4-dhcp-server-enabled> + <use-v6-default-pool>N</use-v6-default-pool> + <excluded-v4-dhcp-addresses-from-default-pool> + <excluded-v4-address>192.168.1.7</excluded-v4-address> + </excluded-v4-dhcp-addresses-from-default-pool> + <excluded-v4-dhcp-addresses-from-default-pool> + <excluded-v4-address>192.168.1.8</excluded-v4-address> + </excluded-v4-dhcp-addresses-from-default-pool> + <v4-dhcp-pools> + <v4-dhcp-relay-next-hop-address>1.1.1.1</v4-dhcp-relay-next-hop-address> + <v4-dhcp-pool-prefix-length>28</v4-dhcp-pool-prefix-length> + <excluded-v4-addresses> + <excluded-v4-address>192.168.1.5</excluded-v4-address> + </excluded-v4-addresses> + <v4-dhcp-relay-gateway-address>2.2.2.1</v4-dhcp-relay-gateway-address> + <excluded-v4-addresses> + <excluded-v4-address>192.168.1.6</excluded-v4-address> + </excluded-v4-addresses> + <v4-dhcp-pool-prefix>192.155.2.3</v4-dhcp-pool-prefix> + </v4-dhcp-pools> + <v4-dhcp-pools> + <v4-dhcp-relay-next-hop-address>1.1.1.2</v4-dhcp-relay-next-hop-address> + <v4-dhcp-pool-prefix-length>28</v4-dhcp-pool-prefix-length> + <excluded-v4-addresses> + <excluded-v4-address>192.168.1.6</excluded-v4-address> + </excluded-v4-addresses> + <v4-dhcp-relay-gateway-address>2.2.2.2</v4-dhcp-relay-gateway-address> + <excluded-v4-addresses> + <excluded-v4-address>192.168.1.7</excluded-v4-address> + </excluded-v4-addresses> + <v4-dhcp-pool-prefix>192.155.2.4</v4-dhcp-pool-prefix> + </v4-dhcp-pools> + <use-v4-default-pool>Y</use-v4-default-pool> + <excluded-v6-dhcp-addresses-from-default-pool> + <excluded-v6-address>1:5</excluded-v6-address> + </excluded-v6-dhcp-addresses-from-default-pool> + <excluded-v6-dhcp-addresses-from-default-pool> + <excluded-v6-address>1:6</excluded-v6-address> + </excluded-v6-dhcp-addresses-from-default-pool> + <v6-dhcp-pools> + <v6-dhcp-relay-next-hop-address>4:4</v6-dhcp-relay-next-hop-address> + <v6-dhcp-pool-prefix-length>28</v6-dhcp-pool-prefix-length> + <excluded-v6-addresses> + <excluded-v6-address>1:1</excluded-v6-address> + </excluded-v6-addresses> + <v6-dhcp-relay-gateway-address>3:3</v6-dhcp-relay-gateway-address> + <excluded-v6-addresses> + <excluded-v6-address>2:2</excluded-v6-address> + </excluded-v6-addresses> + <v6-dhcp-pool-prefix>0:0</v6-dhcp-pool-prefix> + </v6-dhcp-pools> + <v6-dhcp-pools> + <v6-dhcp-relay-next-hop-address>4:4</v6-dhcp-relay-next-hop-address> + <v6-dhcp-pool-prefix-length>28</v6-dhcp-pool-prefix-length> + <excluded-v6-addresses> + <excluded-v6-address>1:1</excluded-v6-address> + </excluded-v6-addresses> + <v6-dhcp-relay-gateway-address>3:3</v6-dhcp-relay-gateway-address> + <excluded-v6-addresses> + <excluded-v6-address>2:2</excluded-v6-address> + </excluded-v6-addresses> + <v6-dhcp-pool-prefix>0:0</v6-dhcp-pool-prefix> + </v6-dhcp-pools> + </dhcp> + <firewall-lite> + <stateful-firewall-lite-v6-enabled>N</stateful-firewall-lite-v6-enabled> + <stateful-firewall-lite-v4-enabled>Y</stateful-firewall-lite-v4-enabled> + <v4-firewall-packet-filters> + <v4-firewall-prefix>0.0.0.1</v4-firewall-prefix> + <v4-firewall-prefix-length>1</v4-firewall-prefix-length> + <allow-icmp-ping>Y</allow-icmp-ping> + <udp-ports> + <port-number>1</port-number> + </udp-ports> + <tcp-ports> + <port-number>1</port-number> + </tcp-ports> + </v4-firewall-packet-filters> + <v4-firewall-packet-filters> + <v4-firewall-prefix>0.0.0.2</v4-firewall-prefix> + <v4-firewall-prefix-length>2</v4-firewall-prefix-length> + <allow-icmp-ping>Y</allow-icmp-ping> + <udp-ports> + <port-number>2</port-number> + </udp-ports> + <tcp-ports> + <port-number>2</port-number> + </tcp-ports> + </v4-firewall-packet-filters> + <v6-firewall-packet-filters> + <v6-firewall-prefix>:</v6-firewall-prefix> + <v6-firewall-prefix-length>0</v6-firewall-prefix-length> + <allow-icmp-ping>Y</allow-icmp-ping> + <udp-ports> + <port-number>3</port-number> + </udp-ports> + <tcp-ports> + <port-number>3</port-number> + </tcp-ports> + </v6-firewall-packet-filters> + <v6-firewall-packet-filters> + <v6-firewall-prefix>:</v6-firewall-prefix> + <v6-firewall-prefix-length>1</v6-firewall-prefix-length> + <allow-icmp-ping>Y</allow-icmp-ping> + <udp-ports> + <port-number>4</port-number> + </udp-ports> + <tcp-ports> + <port-number>4</port-number> + </tcp-ports> + </v6-firewall-packet-filters> + </firewall-lite> + <pat> + <v4-pat-pools> + <v4-pat-pool-prefix>192.168.1.44</v4-pat-pool-prefix> + <v4-pat-pool-next-hop-address>192.168.1.5</v4-pat-pool-next-hop-address> + <v4-pat-pool-prefix-length>0</v4-pat-pool-prefix-length> + </v4-pat-pools> + <use-v4-default-pool>Y</use-v4-default-pool> + <v4-pat-enabled>N</v4-pat-enabled> + <v4-pat-pools> + <v4-pat-pool-prefix>192.168.1.45</v4-pat-pool-prefix> + <v4-pat-pool-next-hop-address>192.168.1.6</v4-pat-pool-next-hop-address> + <v4-pat-pool-prefix-length>28</v4-pat-pool-prefix-length> + </v4-pat-pools> + </pat> + <nat> + <v4-nat-enabled>Y</v4-nat-enabled> + <v4-nat-mapping-entries> + <v4-nat-internal>0.0.0.0</v4-nat-internal> + <v4-nat-next-hop-address>0.0.0.0</v4-nat-next-hop-address> + <v4-nat-external>0.0.0.0</v4-nat-external> + </v4-nat-mapping-entries> + <v4-nat-mapping-entries> + <v4-nat-internal>0.0.0.1</v4-nat-internal> + <v4-nat-next-hop-address>0.0.0.1</v4-nat-next-hop-address> + <v4-nat-external>0.0.0.1</v4-nat-external> + </v4-nat-mapping-entries> + </nat> + <vr-designation>primary</vr-designation> + <v4-vce-loopback-address>162.200.3.144</v4-vce-loopback-address> + <v6-vr-lan-prefix-length>64</v6-vr-lan-prefix-length> + <v6-vce-wan-address>2001:1890:12e3:2da::</v6-vce-wan-address> + <v6-vr-lan-prefix>2620:0:10d0:f:ffff:ffff:ffff:fffe</v6-vr-lan-prefix> + <v4-vr-lan-prefix-length>24</v4-vr-lan-prefix-length> + <v4-vr-lan-prefix>10.192.27.254</v4-vr-lan-prefix> + <v4-public-lan-prefixes> + <t-provided-v4-lan-public-prefixes> + <request-index>1</request-index> + <v4-next-hop-address>192.168.1.2</v4-next-hop-address> + <v4-lan-public-prefix>192.168.1.1</v4-lan-public-prefix> + <v4-lan-public-prefix-length>28</v4-lan-public-prefix-length> + </t-provided-v4-lan-public-prefixes> + <t-provided-v4-lan-public-prefixes> + <request-index>1</request-index> + <v4-next-hop-address>192.168.1.72</v4-next-hop-address> + <v4-lan-public-prefix>192.168.1.71</v4-lan-public-prefix> + <v4-lan-public-prefix-length>28</v4-lan-public-prefix-length> + </t-provided-v4-lan-public-prefixes> + <t-provided-v4-lan-public-prefixes> + <request-index>1</request-index> + <v4-next-hop-address>192.168.1.68</v4-next-hop-address> + <v4-lan-public-prefix>192.168.1.67</v4-lan-public-prefix> + <v4-lan-public-prefix-length>28</v4-lan-public-prefix-length> + </t-provided-v4-lan-public-prefixes> + </v4-public-lan-prefixes> + <v6-public-lan-prefixes> + <t-provided-v6-lan-public-prefixes> + <request-index>1</request-index> + <v6-next-hop-address>2001:1890:12e3:2da::</v6-next-hop-address> + <v6-lan-public-prefix>2001:1890:12e3:2da::</v6-lan-public-prefix> + <v6-lan-public-prefix-length>28</v6-lan-public-prefix-length> + </t-provided-v6-lan-public-prefixes> + <t-provided-v6-lan-public-prefixes> + <request-index>1</request-index> + <v6-next-hop-address>2001:1890:12e3:2da::</v6-next-hop-address> + <v6-lan-public-prefix>2001:1890:12e3:3da::</v6-lan-public-prefix> + <v6-lan-public-prefix-length>28</v6-lan-public-prefix-length> + </t-provided-v6-lan-public-prefixes> + <t-provided-v6-lan-public-prefixes> + <request-index>1</request-index> + <v6-next-hop-address>2001:1890:12e3:2da::</v6-next-hop-address> + <v6-lan-public-prefix>2001:1890:12e3:4da::</v6-lan-public-prefix> + <v6-lan-public-prefix-length>28</v6-lan-public-prefix-length> + </t-provided-v6-lan-public-prefixes> + </v6-public-lan-prefixes> + </vr-lan-interface> + <routing-protocol>none</routing-protocol> + </vr-lan> +<ucpe-vms-service-information> + <transport-service-information> + <transport-service-type>AVPN</transport-service-type> + <access-circuit-info> + <access-circuit-id>1</access-circuit-id> + <dual-mode>Active</dual-mode> + </access-circuit-info> + <access-circuit-info> + <access-circuit-id>2</access-circuit-id> + <dual-mode>Standby</dual-mode> + </access-circuit-info> + </transport-service-information> + <ucpe-information> + <ucpe-host-name>hostname</ucpe-host-name> + <ucpe-activation-code>activecode</ucpe-activation-code> + <out-of-band-management-modem>OOB</out-of-band-management-modem> + </ucpe-information> + <vnf-list> + <vnf-information> + <vnf-instance-id>1</vnf-instance-id> + <vnf-sequence-number>1</vnf-sequence-number> + <vnf-type>ZZ</vnf-type> + <vnf-vendor>JUNIPER</vnf-vendor> + <vnf-model>MODEL1</vnf-model> + <vnf-id>1</vnf-id> + <prov-status>1</prov-status> + <operational-state>1</operational-state> + <orchestration-status>1</orchestration-status> + <equipment-role>1</equipment-role> + </vnf-information> + <vnf-information> + <vnf-instance-id>2</vnf-instance-id> + <vnf-sequence-number>2</vnf-sequence-number> + <vnf-type>HY</vnf-type> + <vnf-vendor>JUNIPER</vnf-vendor> + <vnf-model>MODEL2</vnf-model> + <vnf-id>2</vnf-id> + <prov-status>2</prov-status> + <operational-state>2</operational-state> + <orchestration-status>2</orchestration-status> + <equipment-role>2</equipment-role> + </vnf-information> + </vnf-list> + </ucpe-vms-service-information> + <request-information> + <request-action>Layer3ServiceActivateRequest</request-action> + <order-number>4281555</order-number> + <request-id>155415ab-b4a7-4382-b4c6-d17d9sm42855</request-id> + <notification-url>https://csi-tst-q22.it.att.com:22443/Services/com/cingular/csi/sdn/SendManagedNetworkStatusNotification.jws</notification-url> + <source>OMX</source> + <order-version>1</order-version> + </request-information> + <sdnc-request-header> + <svc-action>activate</svc-action> + <svc-notification-url>https://msojra.mtsnjdcp1.aic.cip.att.com:8443/adapters/rest/SDNCNotify</svc-notification-url> + <svc-request-id>5b1f3c5d-cdf9-488d-8a4b-d3f1229d7760</svc-request-id> + </sdnc-request-header> + <l2-homing-information> + <topology>MultiPoint</topology> + <preferred-aic-clli>MTSNJA4LCP1</preferred-aic-clli> + <evc-name>AS/VLXM/003717//SW</evc-name> + </l2-homing-information> + <service-information> + <service-instance-id>FK/VLXM/003717//SW_INTERNET</service-instance-id> + <subscriber-name>ST E2E Test42855_1300004281555</subscriber-name> + <service-type>SDN-ETHERNET-INTERNET</service-type> + </service-information> + <internet-service-change-details> + <internet-evc-speed-value>10</internet-evc-speed-value> + <internet-evc-speed-units>Kbps</internet-evc-speed-units> + <t-provided-v4-lan-public-prefixes> + <request-index>1</request-index> + <v4-next-hop-address>192.168.1.15</v4-next-hop-address> + <v4-lan-public-prefix>192.168.1.15</v4-lan-public-prefix> + <v4-lan-public-prefix-length>28</v4-lan-public-prefix-length> + </t-provided-v4-lan-public-prefixes> + <t-provided-v4-lan-public-prefixes> + <request-index>2</request-index> + <v4-next-hop-address>192.168.1.16</v4-next-hop-address> + <v4-lan-public-prefix>192.168.1.16</v4-lan-public-prefix> + <v4-lan-public-prefix-length>28</v4-lan-public-prefix-length> + </t-provided-v4-lan-public-prefixes> + <t-provided-v6-lan-public-prefixes> + <request-index>1</request-index> + <v6-next-hop-address>2001:1890:12e3:2da::</v6-next-hop-address> + <v6-lan-public-prefix>2001:1890:12e3:2da::</v6-lan-public-prefix> + <v6-lan-public-prefix-length>28</v6-lan-public-prefix-length> + </t-provided-v6-lan-public-prefixes> + <t-provided-v6-lan-public-prefixes> + <request-index>1</request-index> + <v6-next-hop-address>2001:1890:12e3:2da::</v6-next-hop-address> + <v6-lan-public-prefix>2001:1890:12e3:2da::</v6-lan-public-prefix> + <v6-lan-public-prefix-length>28</v6-lan-public-prefix-length> + </t-provided-v6-lan-public-prefixes> + </internet-service-change-details> + </service-data> + </layer3-service-list> +</tag0:RequestData> +""" + +def sdncAdapterResponseEmpty = +"""<sdncadapterworkflow:SDNCAdapterWorkflowResponse xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"> + <sdncadapterworkflow:response-data/> +</sdncadapterworkflow:SDNCAdapterWorkflowResponse>""" + +def sdncAdapterResponseError = +"""<sdncadapterworkflow:SDNCAdapterWorkflowResponse xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1" + xmlns:tag0="http://org.openecomp/workflow/sdnc/adapter/schema/v1"> + <sdncadapterworkflow:response-data> + <tag0:CallbackHeader> + <tag0:RequestId>39542e39-ccc3-4d1a-8b79-04ce88526613</tag0:RequestId> + <tag0:ResponseCode>404</tag0:ResponseCode> + <tag0:ResponseMessage>Error processing request to SDNC. Not Found. + https://sdncodl.us.aic.cip.att.com:8443/restconf/config/L3SDN-API:services/layer3-service-list/MVM%2FVLXP%2F000855%2F%2FShakeout. + SDNC Returned-[error-type:application, error-tag:data-missing, + error-message:Request could not be completed because the relevant + data model content does not exist.]</tag0:ResponseMessage> + </tag0:CallbackHeader> + </sdncadapterworkflow:response-data> +</sdncadapterworkflow:SDNCAdapterWorkflowResponse>""" + + + @Test + public void testPreProcessRequest() { + + String sdncAdapterWorkflowRequest = FileUtil.readResourceFile("__files/SDN-ETHERNET-INTERNET/SDNCAdapterV1/sdncadapterworkflowrequest.xml"); + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + when(mockExecution.getVariable("URN_mso_adapters_po_auth")).thenReturn("3141634BF7E070AA289CF2892C986C0B") + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("sdncAdapterWorkflowRequest")).thenReturn(sdncAdapterWorkflowRequest) + when(mockExecution.getVariable("URN_mso_workflow_sdncadapter_callback")).thenReturn("http://someurl.someting.com:28080/mso/sdncAdapterCallbackServiceImpl") + when(mockExecution.getVariable("URN_mso_use_qualified_host")).thenReturn("true") + when(mockExecution.getProcessInstanceId()).thenReturn("745b1b50-e39e-4685-9cc8-c71f0bde8bf0") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + + + SDNCAdapter sdncAdapter = new SDNCAdapter() + sdncAdapter.preProcessRequest(mockExecution) + + MockitoDebuggerImpl debugger = new MockitoDebuggerImpl() + debugger.printInvocations(mockExecution) + + + verify(mockExecution).setVariable("prefix","SDNCA_") + verify(mockExecution).setVariable("sdncAdapterResponse","") + verify(mockExecution).setVariable("asynchronousResponseTimeout",false) + verify(mockExecution).setVariable("continueListening",false) + verify(mockExecution).setVariable("BasicAuthHeaderValue","Basic cGFzc3dvcmQ=") + verify(mockExecution).setVariable("serviceConfigActivate",false) + verify(mockExecution).setVariable("SDNCA_requestId", "745b1b50-e39e-4685-9cc8-c71f0bde8bf0") + verify(mockExecution).setVariable("SDNCA_SuccessIndicator",false) + verify(mockExecution).setVariable("source","") + verify(mockExecution).setVariable("sdncAdapterRequest", sdncAdapterRequest) + } + + @Test + public void testProcessResponse() + { + String sdncAdapterCallbackResponse = FileUtil.readResourceFile("__files/SDN-ETHERNET-INTERNET/SDNCAdapterV1mock/sdncadaptercallbackrequest.xml"); + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + when(mockExecution.getVariable("sdncAdapterCallbackRequest")).thenReturn(sdncAdapterCallbackResponse) + SDNCAdapter sdncAdapter = new SDNCAdapter() + sdncAdapter.postProcessResponse(mockExecution) + +// MockitoDebuggerImpl debugger = new MockitoDebuggerImpl() +// debugger.printInvocations(mockExecution) + + verify(mockExecution).getVariable("isDebugLogEnabled") + verify(mockExecution,times(2)).getVariable("sdncAdapterCallbackRequest") + verify(mockExecution).setVariable("sdncAdapterResponse",workflowResponse) + verify(mockExecution).setVariable("enhancedCallbackRequestData",enhancedCallbackRequestData) + verify(mockExecution).setVariable("continueListening",false) + + } + + @Test + public void testProcessResponse_ErrorCase_404() + { + String sdncAdapterCallbackErrorResponse = FileUtil.readResourceFile("sdncadaptercallbackrequest_404CallBack.xml"); + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + when(mockExecution.getVariable("sdncAdapterCallbackRequest")).thenReturn(sdncAdapterCallbackErrorResponse) + SDNCAdapter sdncAdapter = new SDNCAdapter() + sdncAdapter.postProcessResponse(mockExecution) + + verify(mockExecution, times(1)).getVariable("isDebugLogEnabled") + verify(mockExecution,times(2)).getVariable("sdncAdapterCallbackRequest") + verify(mockExecution).setVariable("sdncAdapterResponse", sdncAdapterResponseError) + verify(mockExecution).setVariable("enhancedCallbackRequestData", "") + verify(mockExecution).setVariable("continueListening",false) + + } + + @Test + public void testProcessResponse_ErrorCase_InvalidCallback() + { + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + when(mockExecution.getVariable("sdncAdapterCallbackRequest")).thenReturn("<h1>Service Unavailable</h1>") + SDNCAdapter sdncAdapter = new SDNCAdapter() + sdncAdapter.postProcessResponse(mockExecution) + + verify(mockExecution).getVariable("isDebugLogEnabled") + verify(mockExecution,times(2)).getVariable("sdncAdapterCallbackRequest") + verify(mockExecution).setVariable("sdncAdapterResponse", sdncAdapterResponseEmpty) + verify(mockExecution).setVariable("enhancedCallbackRequestData", "") + verify(mockExecution).setVariable("continueListening",false) + + } + + @Test + public void postProcessResponse() + { + + String SDNCAdapterCallbackRequest = + """<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<SDNCAdapterCallbackRequest + xmlns="http://org.openecomp/workflow/sdnc/adapter/schema/v1"> + <CallbackHeader> + <RequestId>3bb02798-b344-4d28-9bca-1f029954d1c9</RequestId> + <ResponseCode>404</ResponseCode> + <ResponseMessage>Error processing request to SDNC. Not Found. + https://sdncodl.us.infra.aic.att.net:8443/restconf/config/L3SDN-API:services/layer3-service-list/85%2FCSIP%2F141203%2FPT_CSI9999998693. + SDNC Returned-[error-type:application, error-tag:data-missing, + error-message:Request could not be completed because the relevant + data model content does not exist ]</ResponseMessage> + </CallbackHeader> +</SDNCAdapterCallbackRequest>""" + + String sdncAdapterResponse = + """<sdncadapterworkflow:SDNCAdapterWorkflowResponse xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1" + xmlns:tag0="http://org.openecomp/workflow/sdnc/adapter/schema/v1"> + <sdncadapterworkflow:response-data> + <tag0:CallbackHeader> + <tag0:RequestId>3bb02798-b344-4d28-9bca-1f029954d1c9</tag0:RequestId> + <tag0:ResponseCode>404</tag0:ResponseCode> + <tag0:ResponseMessage>Error processing request to SDNC. Not Found. + https://sdncodl.us.infra.aic.att.net:8443/restconf/config/L3SDN-API:services/layer3-service-list/85%2FCSIP%2F141203%2FPT_CSI9999998693. + SDNC Returned-[error-type:application, error-tag:data-missing, + error-message:Request could not be completed because the relevant + data model content does not exist ]</tag0:ResponseMessage> + </tag0:CallbackHeader> + </sdncadapterworkflow:response-data> +</sdncadapterworkflow:SDNCAdapterWorkflowResponse>""" + + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + when(mockExecution.getVariable("sdncAdapterCallbackRequest")).thenReturn(SDNCAdapterCallbackRequest) + SDNCAdapter sdncAdapter = new SDNCAdapter() + sdncAdapter.postProcessResponse(mockExecution) + + verify(mockExecution).getVariable("isDebugLogEnabled") + verify(mockExecution,times(2)).getVariable("sdncAdapterCallbackRequest") + verify(mockExecution).setVariable("sdncAdapterResponse", sdncAdapterResponse) + verify(mockExecution).setVariable("enhancedCallbackRequestData", "") + verify(mockExecution).setVariable("continueListening",false) + + } + +}
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/openecomp/mso/bpmn/common/scripts/VidUtilsTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/openecomp/mso/bpmn/common/scripts/VidUtilsTest.groovy new file mode 100644 index 0000000000..645fbe6e8f --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/openecomp/mso/bpmn/common/scripts/VidUtilsTest.groovy @@ -0,0 +1,972 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common.scripts; + +import static org.mockito.Mockito.* + +import org.openecomp.mso.bpmn.common.scripts.VidUtils; +import org.openecomp.mso.bpmn.core.WorkflowException + +import groovy.json.JsonSlurper + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.ProcessEngineServices +import org.camunda.bpm.engine.RepositoryService +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.camunda.bpm.engine.impl.pvm.process.ProcessDefinitionImpl +import org.camunda.bpm.engine.repository.ProcessDefinition +import org.camunda.bpm.engine.runtime.Execution; + +import static org.junit.Assert.*; + +import org.mockito.MockitoAnnotations +import org.mockito.runners.MockitoJUnitRunner +import org.mockito.internal.debugging.MockitoDebuggerImpl +import org.junit.Before +import org.junit.Rule; +import org.junit.Test +import org.junit.Ignore +import org.junit.runner.RunWith +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity; +import org.junit.Before; +import org.junit.Test; + +@RunWith(MockitoJUnitRunner.class) + +class VidUtilsTest { + + def vfModuleReqJson = """ +{ + "requestDetails": { + "modelInfo": { + "modelType": "vfModule", + "modelInvariantId": "ff5256d2-5a33-55df-13ab-12abad84e7ff", + "modelNameVersionId": "fe6478e5-ea33-3346-ac12-ab121484a3fe", + "modelName": "STMTN5MMSC21-MMSC::model-1-0", + "modelVersion": "1", + "modelCustomizationId": "ee6478e5-ea33-3346-ac12-ab121484a3fe" + }, + "cloudConfiguration": { + "lcpCloudRegionId": "MDTWNJ21", + "tenantId": "fba1bd1e195a404cacb9ce17a9b2b421" + }, + "requestInfo": { + "instanceName": "PCRF::module-0-2", + "source": "VID", + "suppressRollback": true + }, + "relatedInstanceList": [ + { + "relatedInstance": { + "instanceId": "17ef4658-bd1f-4ef0-9ca0-ea76e2bf122c", + "instanceName": "MSOTESTVOL103a-vSAMP12_base_module-0_vol", + "modelInfo": { + "modelType": "volumeGroup", + "modelInvariantId": "ff5256d2-5a33-55df-13ab-12abad84e7ff", + "modelNameVersionId": "fe6478e5-ea33-3346-ac12-ab121484a3fe", + "modelName": "vSAMP12..base..module-0", + "modelVersion": "1" + } + } + }, + { + "relatedInstance": { + "instanceId": "123456", + "modelInfo": { + "modelType": "service", + "modelInvariantId": "ff3514e3-5a33-55df-13ab-12abad84e7ff", + "modelNameVersionId": "fe6985cd-ea33-3346-ac12-ab121484a3fe", + "modelName": "SERVICE_MODEL_NAME", + "modelVersion": "1.0" + } + } + }, + { + "relatedInstance": { + "instanceId": "skask", + "instanceName": "skask-test", + "modelInfo": { + "modelType": "vnf", + "modelInvariantId": "skask", + "modelNameVersionId": "fe6478e4-ea33-3346-ac12-ab121484a3fe", + "modelName": "vSAMP12", + "modelVersion": "1.0", + "modelCustomizationName": "vSAMP12 1" + } + } + } + ], + "requestParameters": { + "userParams": [ + { + "name": "vnfName", + "value": "STMTN5MMSC20" + }, + { + "name": "tenantId", + "value": "vpe-tenant-123" + }, + { + "name": "aicCloudRegion", + "value": "MDTWNJ21" + }, + { + "name": "isAvpnService", + "value": "true" + }, + { + "name": "asn", + "value": "asn-1234" + }, + { + "name": "releaseForAero", + "value": "release-for-aero-something" + }, + { + "name": "aicClli", + "value": "MTJWNJA4LCP" + }, + { + "name": "svcProviderPartNumber", + "value": "svc-provide-number-1234" + } + ] + } + } +} +""" + def bpmnReq1 = """ +{ + "requestDetails": { + "modelInfo": { + "modelType": "volumeGroup", + "modelId": "ff5256d2-5a33-55df-13ab-12abad84e7ff", + "modelNameVersionId": "fe6478e5-ea33-3346-ac12-ab121484a3fe", + "modelName": "vSAMP12::base::module-0", + "modelVersion": "1" + }, + "cloudConfiguration": { + "lcpCloudRegionId": "mdt1", + "tenantId": "88a6ca3ee0394ade9403f075db23167e" + }, + "requestInfo": { + "instanceName": "MSOTESTVOL101a-vSAMP12_base_vol_module-0", + "source": "VID", + "suppressRollback": false + }, + "relatedInstanceList": [ + { + "relatedInstance": { + "instanceId": "{service-instance-id}", + "modelInfo": { + "modelType": "service", + "modelId": "ff3514e3-5a33-55df-13ab-12abad84e7ff", + "modelNameVersionId": "fe6985cd-ea33-3346-ac12-ab121484a3fe", + "modelName": "Test", + "modelVersion": "2.0" + } + } + }, { + "relatedInstance": { + "instanceId": "{vnf-instance-id}", + "modelInfo": { + "modelType": "vnf", + "modelId": "ff5256d1-5a33-55df-13ab-12abad84e7ff", + "modelNameVersionId": "fe6478e4-ea33-3346-ac12-ab121484a3fe", + "modelName": "vSAMP12", + "modelVersion": "1", + "modelCustomizationName": "vSAMP12" + } + } + } + ], + "requestParameters": { + "serviceId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", + "userParams": [ + {"name": "vnfName", "value": "STMTN5MMSC20" }, + {"name": "vnfName2", "value": "US1117MTSNJVBR0246" }, + {"name": "vnfNmInformation", "value": "" }, + {"name": "vnfType", "value": "pcrf-capacity" }, + {"name": "vnfId", "value": "skask" }, + {"name": "vnfStackId", "value": "slowburn" }, + {"name": "vnfStatus", "value": "created" }, + {"name": "aicCloudRegion", "value": "MDTWNJ21" }, + {"name": "availabilityZone", "value": "slcp3-esx-az01" }, + {"name": "oamNetworkName", "value": "VLAN-OAM-1323" }, + {"name": "vmName", "value": "slcp34246vbc246ceb" }, + {"name": "ipagNetworkId", "value": "970cd2b9-7f09-4a12-af47-182ea38ba1f0" }, + {"name": "vpeNetworkId", "value": "545cc2c3-1930-4100-b534-5d82d0e12bb6" } + ] + } + } +} +""" + + def vidUtilResp1 = """<volume-request xmlns="http://www.w3.org/2001/XMLSchema"> + <request-info> + <action>CREATE_VF_MODULE_VOL</action> + <source>VID</source> + <service-instance-id>test-service-instance-id-123</service-instance-id> + </request-info> + <volume-inputs> + <volume-group-id/> + <volume-group-name>MSOTESTVOL101a-vSAMP12_base_vol_module-0</volume-group-name> + <vnf-type>Test/vSAMP12</vnf-type> + <vf-module-model-name>vSAMP12::base::module-0</vf-module-model-name> + <asdc-service-model-version>2.0</asdc-service-model-version> + <aic-cloud-region>mdt1</aic-cloud-region> + <tenant-id>88a6ca3ee0394ade9403f075db23167e</tenant-id> + <service-id>a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb</service-id> + <backout-on-failure>true</backout-on-failure> + <model-customization-id/> + </volume-inputs> + <volume-params> + <param name="vnf_name">STMTN5MMSC20</param> + <param name="vnf_name2">US1117MTSNJVBR0246</param> + <param name="vnf_nm_information"/> + <param name="vnf_type">pcrf-capacity</param> + <param name="vnf_id">skask</param> + <param name="vnf_stack_id">slowburn</param> + <param name="vnf_status">created</param> + <param name="aic_cloud_region">MDTWNJ21</param> + <param name="availability_zone">slcp3-esx-az01</param> + <param name="oam_network_name">VLAN-OAM-1323</param> + <param name="vm_name">slcp34246vbc246ceb</param> + <param name="ipag_network_id">970cd2b9-7f09-4a12-af47-182ea38ba1f0</param> + <param name="vpe_network_id">545cc2c3-1930-4100-b534-5d82d0e12bb6</param> + </volume-params> +</volume-request> +""" + + def bpmnReq2 = """ +{ + "requestDetails": { + "modelInfo": { + "modelType": "volumeGroup", + "modelId": "ff5256d2-5a33-55df-13ab-12abad84e7ff", + "modelNameVersionId": "fe6478e5-ea33-3346-ac12-ab121484a3fe", + "modelName": "vSAMP12::base::module-0", + "modelVersion": "1" + }, + "cloudConfiguration": { + "lcpCloudRegionId": "mdt1", + "tenantId": "88a6ca3ee0394ade9403f075db23167e" + }, + "requestInfo": { + "instanceName": "MSOTESTVOL101a-vSAMP12_base_vol_module-0", + "source": "VID", + "suppressRollback": false + }, + "relatedInstanceList": [ + { + "relatedInstance": { + "instanceId": "{service-instance-id}", + "modelInfo": { + "modelType": "service", + "modelId": "ff3514e3-5a33-55df-13ab-12abad84e7ff", + "modelNameVersionId": "fe6985cd-ea33-3346-ac12-ab121484a3fe", + "modelName": "Test", + "modelVersion": "2.0" + } + } + }, { + "relatedInstance": { + "instanceId": "{vnf-instance-id}", + "modelInfo": { + "modelType": "vnf", + "modelId": "ff5256d1-5a33-55df-13ab-12abad84e7ff", + "modelNameVersionId": "fe6478e4-ea33-3346-ac12-ab121484a3fe", + "modelName": "vSAMP12", + "modelVersion": "1", + "modelCustomizationName": "vSAMP12" + } + } + } + ] + } +} +""" + + def bpmnReqJsonVolumeSuppressRollbackTrue = """ +{ + "requestDetails": { + "modelInfo": { + "modelType": "volumeGroup", + "modelId": "ff5256d2-5a33-55df-13ab-12abad84e7ff", + "modelNameVersionId": "fe6478e5-ea33-3346-ac12-ab121484a3fe", + "modelName": "vSAMP12::base::module-0", + "modelVersion": "1" + }, + "cloudConfiguration": { + "lcpCloudRegionId": "mdt1", + "tenantId": "88a6ca3ee0394ade9403f075db23167e" + }, + "requestInfo": { + "instanceName": "MSOTESTVOL101a-vSAMP12_base_vol_module-0", + "source": "VID", + "suppressRollback": true + }, + "relatedInstanceList": [ + { + "relatedInstance": { + "instanceId": "{service-instance-id}", + "modelInfo": { + "modelType": "service", + "modelId": "ff3514e3-5a33-55df-13ab-12abad84e7ff", + "modelNameVersionId": "fe6985cd-ea33-3346-ac12-ab121484a3fe", + "modelName": "Test", + "modelVersion": "2.0" + } + } + }, { + "relatedInstance": { + "instanceId": "{vnf-instance-id}", + "modelInfo": { + "modelType": "vnf", + "modelId": "ff5256d1-5a33-55df-13ab-12abad84e7ff", + "modelNameVersionId": "fe6478e4-ea33-3346-ac12-ab121484a3fe", + "modelName": "vSAMP12", + "modelVersion": "1", + "modelCustomizationName": "vSAMP12" + } + } + } + ] + } +} +""" + +def bpmnReqJsonVolumeSuppressRollbackFalse = """ +{ + "requestDetails": { + "modelInfo": { + "modelType": "volumeGroup", + "modelId": "ff5256d2-5a33-55df-13ab-12abad84e7ff", + "modelNameVersionId": "fe6478e5-ea33-3346-ac12-ab121484a3fe", + "modelName": "vSAMP12::base::module-0", + "modelVersion": "1" + }, + "cloudConfiguration": { + "lcpCloudRegionId": "mdt1", + "tenantId": "88a6ca3ee0394ade9403f075db23167e" + }, + "requestInfo": { + "instanceName": "MSOTESTVOL101a-vSAMP12_base_vol_module-0", + "source": "VID", + "suppressRollback": false + }, + "relatedInstanceList": [ + { + "relatedInstance": { + "instanceId": "{service-instance-id}", + "modelInfo": { + "modelType": "service", + "modelId": "ff3514e3-5a33-55df-13ab-12abad84e7ff", + "modelNameVersionId": "fe6985cd-ea33-3346-ac12-ab121484a3fe", + "modelName": "Test", + "modelVersion": "2.0" + } + } + }, { + "relatedInstance": { + "instanceId": "{vnf-instance-id}", + "modelInfo": { + "modelType": "vnf", + "modelId": "ff5256d1-5a33-55df-13ab-12abad84e7ff", + "modelNameVersionId": "fe6478e4-ea33-3346-ac12-ab121484a3fe", + "modelName": "vSAMP12", + "modelVersion": "1", + "modelCustomizationName": "vSAMP12" + } + } + } + ] + } +} +""" + +def bpmnReqJsonVolumeSuppressRollbackNone = """ +{ + "requestDetails": { + "modelInfo": { + "modelType": "volumeGroup", + "modelId": "ff5256d2-5a33-55df-13ab-12abad84e7ff", + "modelNameVersionId": "fe6478e5-ea33-3346-ac12-ab121484a3fe", + "modelName": "vSAMP12::base::module-0", + "modelVersion": "1" + }, + "cloudConfiguration": { + "lcpCloudRegionId": "mdt1", + "tenantId": "88a6ca3ee0394ade9403f075db23167e" + }, + "requestInfo": { + "instanceName": "MSOTESTVOL101a-vSAMP12_base_vol_module-0", + "source": "VID" + }, + "relatedInstanceList": [ + { + "relatedInstance": { + "instanceId": "{service-instance-id}", + "modelInfo": { + "modelType": "service", + "modelId": "ff3514e3-5a33-55df-13ab-12abad84e7ff", + "modelNameVersionId": "fe6985cd-ea33-3346-ac12-ab121484a3fe", + "modelName": "Test", + "modelVersion": "2.0" + } + } + }, { + "relatedInstance": { + "instanceId": "{vnf-instance-id}", + "modelInfo": { + "modelType": "vnf", + "modelId": "ff5256d1-5a33-55df-13ab-12abad84e7ff", + "modelNameVersionId": "fe6478e4-ea33-3346-ac12-ab121484a3fe", + "modelName": "vSAMP12", + "modelVersion": "1", + "modelCustomizationName": "vSAMP12" + } + } + } + ] + } +} +""" + + def bpmnReqJsonVfModuleSuppressRollbackTrue = """ +{ +"requestDetails": { +"modelInfo": { +"modelType": "vfModule", +"modelInvariantId": "ff5256d2-5a33-55df-13ab-12abad84e7ff", +"modelNameVersionId": "fe6478e5-ea33-3346-ac12-ab121484a3fe", +"modelName": "STMTN5MMSC21-MMSC::model-1-0", +"modelVersion": "1" +}, +"cloudConfiguration": { +"lcpCloudRegionId": "MDTWNJ21", +"tenantId": "fba1bd1e195a404cacb9ce17a9b2b421" +}, +"requestInfo": { +"instanceName": "PCRF::module-0-2", +"source": "VID", +"suppressRollback": true +}, +"relatedInstanceList": [ +{ +"relatedInstance": { +"instanceId": "17ef4658-bd1f-4ef0-9ca0-ea76e2bf122c", +"instanceName": "MSOTESTVOL103a-vSAMP12_base_module-0_vol", +"modelInfo": { +"modelType": "volumeGroup", +"modelInvariantId": "ff5256d2-5a33-55df-13ab-12abad84e7ff", +"modelNameVersionId": "fe6478e5-ea33-3346-ac12-ab121484a3fe", +"modelName": "vSAMP12..base..module-0", +"modelVersion": "1" +} +} +}, +{ +"relatedInstance": { +"instanceId": "123456", +"modelInfo": { +"modelType": "service", +"modelInvariantId": "ff3514e3-5a33-55df-13ab-12abad84e7ff", +"modelNameVersionId": "fe6985cd-ea33-3346-ac12-ab121484a3fe", +"modelName": "SERVICE_MODEL_NAME", +"modelVersion": "1.0" +} +} +}, +{ +"relatedInstance": { +"instanceId": "skask", +"instanceName": "skask-test", +"modelInfo": { +"modelType": "vnf", +"modelInvariantId": "skask", +"modelNameVersionId": "fe6478e4-ea33-3346-ac12-ab121484a3fe", +"modelName": "vSAMP12", +"modelVersion": "1.0", +"modelCustomizationName": "vSAMP12 1" +} +} +} +], +"requestParameters": { +"userParams": {} +} +} +} +""" + +def bpmnReqJsonVfModuleSuppressRollbackFalse = """ +{ +"requestDetails": { +"modelInfo": { +"modelType": "vfModule", +"modelInvariantId": "ff5256d2-5a33-55df-13ab-12abad84e7ff", +"modelNameVersionId": "fe6478e5-ea33-3346-ac12-ab121484a3fe", +"modelName": "STMTN5MMSC21-MMSC::model-1-0", +"modelVersion": "1" +}, +"cloudConfiguration": { +"lcpCloudRegionId": "MDTWNJ21", +"tenantId": "fba1bd1e195a404cacb9ce17a9b2b421" +}, +"requestInfo": { +"instanceName": "PCRF::module-0-2", +"source": "VID", +"suppressRollback": false +}, +"relatedInstanceList": [ +{ +"relatedInstance": { +"instanceId": "17ef4658-bd1f-4ef0-9ca0-ea76e2bf122c", +"instanceName": "MSOTESTVOL103a-vSAMP12_base_module-0_vol", +"modelInfo": { +"modelType": "volumeGroup", +"modelInvariantId": "ff5256d2-5a33-55df-13ab-12abad84e7ff", +"modelNameVersionId": "fe6478e5-ea33-3346-ac12-ab121484a3fe", +"modelName": "vSAMP12..base..module-0", +"modelVersion": "1" +} +} +}, +{ +"relatedInstance": { +"instanceId": "123456", +"modelInfo": { +"modelType": "service", +"modelInvariantId": "ff3514e3-5a33-55df-13ab-12abad84e7ff", +"modelNameVersionId": "fe6985cd-ea33-3346-ac12-ab121484a3fe", +"modelName": "SERVICE_MODEL_NAME", +"modelVersion": "1.0" +} +} +}, +{ +"relatedInstance": { +"instanceId": "skask", +"instanceName": "skask-test", +"modelInfo": { +"modelType": "vnf", +"modelInvariantId": "skask", +"modelNameVersionId": "fe6478e4-ea33-3346-ac12-ab121484a3fe", +"modelName": "vSAMP12", +"modelVersion": "1.0", +"modelCustomizationName": "vSAMP12 1" +} +} +} +], +"requestParameters": { +"userParams": {} +} +} +} +""" + +def bpmnReqJsonVfModuleSuppressRollbackNone = """ +{ +"requestDetails": { +"modelInfo": { +"modelType": "vfModule", +"modelInvariantId": "ff5256d2-5a33-55df-13ab-12abad84e7ff", +"modelNameVersionId": "fe6478e5-ea33-3346-ac12-ab121484a3fe", +"modelName": "STMTN5MMSC21-MMSC::model-1-0", +"modelVersion": "1" +}, +"cloudConfiguration": { +"lcpCloudRegionId": "MDTWNJ21", +"tenantId": "fba1bd1e195a404cacb9ce17a9b2b421" +}, +"requestInfo": { +"instanceName": "PCRF::module-0-2", +"source": "VID" +}, +"relatedInstanceList": [ +{ +"relatedInstance": { +"instanceId": "17ef4658-bd1f-4ef0-9ca0-ea76e2bf122c", +"instanceName": "MSOTESTVOL103a-vSAMP12_base_module-0_vol", +"modelInfo": { +"modelType": "volumeGroup", +"modelInvariantId": "ff5256d2-5a33-55df-13ab-12abad84e7ff", +"modelNameVersionId": "fe6478e5-ea33-3346-ac12-ab121484a3fe", +"modelName": "vSAMP12..base..module-0", +"modelVersion": "1" +} +} +}, +{ +"relatedInstance": { +"instanceId": "123456", +"modelInfo": { +"modelType": "service", +"modelInvariantId": "ff3514e3-5a33-55df-13ab-12abad84e7ff", +"modelNameVersionId": "fe6985cd-ea33-3346-ac12-ab121484a3fe", +"modelName": "SERVICE_MODEL_NAME", +"modelVersion": "1.0" +} +} +}, +{ +"relatedInstance": { +"instanceId": "skask", +"instanceName": "skask-test", +"modelInfo": { +"modelType": "vnf", +"modelInvariantId": "skask", +"modelNameVersionId": "fe6478e4-ea33-3346-ac12-ab121484a3fe", +"modelName": "vSAMP12", +"modelVersion": "1.0", +"modelCustomizationName": "vSAMP12 1" +} +} +} +], +"requestParameters": { +"userParams": {} +} +} +} +""" + def vidUtilResp2 = """<volume-request xmlns="http://www.w3.org/2001/XMLSchema"> + <request-info> + <action>CREATE_VF_MODULE_VOL</action> + <source>VID</source> + <service-instance-id>test-service-instance-id-123</service-instance-id> + </request-info> + <volume-inputs> + <volume-group-id/> + <volume-group-name>MSOTESTVOL101a-vSAMP12_base_vol_module-0</volume-group-name> + <vnf-type>Test/vSAMP12</vnf-type> + <vf-module-model-name>vSAMP12::base::module-0</vf-module-model-name> + <asdc-service-model-version>2.0</asdc-service-model-version> + <aic-cloud-region>mdt1</aic-cloud-region> + <tenant-id>88a6ca3ee0394ade9403f075db23167e</tenant-id> + <service-id/> + <backout-on-failure>true</backout-on-failure> + <model-customization-id/> + </volume-inputs> + <volume-params/> +</volume-request> +""" + +def vidUtilVolumeRespBackoutOnFailureFalse = """<volume-request xmlns="http://www.w3.org/2001/XMLSchema"> + <request-info> + <action>CREATE_VF_MODULE_VOL</action> + <source>VID</source> + <service-instance-id>test-service-instance-id-123</service-instance-id> + </request-info> + <volume-inputs> + <volume-group-id/> + <volume-group-name>MSOTESTVOL101a-vSAMP12_base_vol_module-0</volume-group-name> + <vnf-type>Test/vSAMP12</vnf-type> + <vf-module-model-name>vSAMP12::base::module-0</vf-module-model-name> + <asdc-service-model-version>2.0</asdc-service-model-version> + <aic-cloud-region>mdt1</aic-cloud-region> + <tenant-id>88a6ca3ee0394ade9403f075db23167e</tenant-id> + <service-id/> + <backout-on-failure>false</backout-on-failure> + <model-customization-id/> + </volume-inputs> + <volume-params/> +</volume-request> +""" + +def vidUtilVolumeRespBackoutOnFailureTrue = """<volume-request xmlns="http://www.w3.org/2001/XMLSchema"> + <request-info> + <action>CREATE_VF_MODULE_VOL</action> + <source>VID</source> + <service-instance-id>test-service-instance-id-123</service-instance-id> + </request-info> + <volume-inputs> + <volume-group-id/> + <volume-group-name>MSOTESTVOL101a-vSAMP12_base_vol_module-0</volume-group-name> + <vnf-type>Test/vSAMP12</vnf-type> + <vf-module-model-name>vSAMP12::base::module-0</vf-module-model-name> + <asdc-service-model-version>2.0</asdc-service-model-version> + <aic-cloud-region>mdt1</aic-cloud-region> + <tenant-id>88a6ca3ee0394ade9403f075db23167e</tenant-id> + <service-id/> + <backout-on-failure>true</backout-on-failure> + <model-customization-id/> + </volume-inputs> + <volume-params/> +</volume-request> +""" + +def vidUtilVolumeRespBackoutOnFailureEmpty = """<volume-request xmlns="http://www.w3.org/2001/XMLSchema"> + <request-info> + <action>CREATE_VF_MODULE_VOL</action> + <source>VID</source> + <service-instance-id>test-service-instance-id-123</service-instance-id> + </request-info> + <volume-inputs> + <volume-group-id/> + <volume-group-name>MSOTESTVOL101a-vSAMP12_base_vol_module-0</volume-group-name> + <vnf-type>Test/vSAMP12</vnf-type> + <vf-module-model-name>vSAMP12::base::module-0</vf-module-model-name> + <asdc-service-model-version>2.0</asdc-service-model-version> + <aic-cloud-region>mdt1</aic-cloud-region> + <tenant-id>88a6ca3ee0394ade9403f075db23167e</tenant-id> + <service-id/> + <backout-on-failure/> + <model-customization-id/> + </volume-inputs> + <volume-params/> +</volume-request> +""" + +def vidUtilVfModuleRespBackoutOnFailureFalse = """<vnf-request> + <request-info> + <request-id>test-request-id-123</request-id> + <action>CREATE_VF_MODULE</action> + <source>VID</source> + <!-- new 1610 field --> + <service-instance-id>test-service-instance-id-123</service-instance-id> + </request-info> + <vnf-inputs><!-- not in use in 1610 --> + <vnf-name>skask-test</vnf-name> + <vnf-type>test-vnf-type-123</vnf-type> + <vnf-id>test-vnf-id-123</vnf-id> + <volume-group-id>test-volume-group-id-123</volume-group-id> + <vf-module-id>test-vf-module-id-123</vf-module-id> + <vf-module-name>PCRF::module-0-2</vf-module-name> + <vf-module-model-name>STMTN5MMSC21-MMSC::model-1-0</vf-module-model-name> + <model-customization-id/> + <is-base-vf-module>false</is-base-vf-module> + <asdc-service-model-version>1.0</asdc-service-model-version> + <aic-cloud-region>MDTWNJ21</aic-cloud-region> + <tenant-id>fba1bd1e195a404cacb9ce17a9b2b421</tenant-id> + <service-id/> + <backout-on-failure>false</backout-on-failure> + <persona-model-id>ff5256d2-5a33-55df-13ab-12abad84e7ff</persona-model-id> + <persona-model-version>1</persona-model-version> + </vnf-inputs> + <vnf-params/> +</vnf-request> +""" + +def vidUtilVfModuleRespBackoutOnFailureTrue = """<vnf-request> + <request-info> + <request-id>test-request-id-123</request-id> + <action>CREATE_VF_MODULE</action> + <source>VID</source> + <!-- new 1610 field --> + <service-instance-id>test-service-instance-id-123</service-instance-id> + </request-info> + <vnf-inputs><!-- not in use in 1610 --> + <vnf-name>skask-test</vnf-name> + <vnf-type>test-vnf-type-123</vnf-type> + <vnf-id>test-vnf-id-123</vnf-id> + <volume-group-id>test-volume-group-id-123</volume-group-id> + <vf-module-id>test-vf-module-id-123</vf-module-id> + <vf-module-name>PCRF::module-0-2</vf-module-name> + <vf-module-model-name>STMTN5MMSC21-MMSC::model-1-0</vf-module-model-name> + <model-customization-id/> + <is-base-vf-module>false</is-base-vf-module> + <asdc-service-model-version>1.0</asdc-service-model-version> + <aic-cloud-region>MDTWNJ21</aic-cloud-region> + <tenant-id>fba1bd1e195a404cacb9ce17a9b2b421</tenant-id> + <service-id/> + <backout-on-failure>true</backout-on-failure> + <persona-model-id>ff5256d2-5a33-55df-13ab-12abad84e7ff</persona-model-id> + <persona-model-version>1</persona-model-version> + </vnf-inputs> + <vnf-params/> +</vnf-request> +""" + +def vidUtilVfModuleRespBackoutOnFailureEmpty = """<vnf-request> + <request-info> + <request-id>test-request-id-123</request-id> + <action>CREATE_VF_MODULE</action> + <source>VID</source> + <!-- new 1610 field --> + <service-instance-id>test-service-instance-id-123</service-instance-id> + </request-info> + <vnf-inputs><!-- not in use in 1610 --> + <vnf-name>skask-test</vnf-name> + <vnf-type>test-vnf-type-123</vnf-type> + <vnf-id>test-vnf-id-123</vnf-id> + <volume-group-id>test-volume-group-id-123</volume-group-id> + <vf-module-id>test-vf-module-id-123</vf-module-id> + <vf-module-name>PCRF::module-0-2</vf-module-name> + <vf-module-model-name>STMTN5MMSC21-MMSC::model-1-0</vf-module-model-name> + <model-customization-id/> + <is-base-vf-module>false</is-base-vf-module> + <asdc-service-model-version>1.0</asdc-service-model-version> + <aic-cloud-region>MDTWNJ21</aic-cloud-region> + <tenant-id>fba1bd1e195a404cacb9ce17a9b2b421</tenant-id> + <service-id/> + <backout-on-failure/> + <persona-model-id>ff5256d2-5a33-55df-13ab-12abad84e7ff</persona-model-id> + <persona-model-version>1</persona-model-version> + </vnf-inputs> + <vnf-params/> +</vnf-request> +""" + + @Before + public void init() + { + MockitoAnnotations.initMocks(this) + + } + + @Test + public void test() { + + def jsonSlurper = new JsonSlurper() + Map reqMap = jsonSlurper.parseText(bpmnReq1) + + VidUtils vidUtils = new VidUtils() + def xmlReq = vidUtils.createXmlVolumeRequest(reqMap, 'CREATE_VF_MODULE_VOL', 'test-service-instance-id-123') + print xmlReq + assertEquals(vidUtilResp1, xmlReq) + } + + //@Test + public void testVfModule() { + + def jsonSlurper = new JsonSlurper() + Map reqMap = jsonSlurper.parseText(vfModuleReqJson) + + VidUtils vidUtils = new VidUtils() + def xmlReq = vidUtils.createXmlVfModuleRequest(null, reqMap, "CREATE_VF_MODULE", "test-service-instance-id-123") + print xmlReq + assertTrue(true) + } + + @Test + public void testNoRequestParams() { + + def jsonSlurper = new JsonSlurper() + Map reqMap = jsonSlurper.parseText(bpmnReq2) + + VidUtils vidUtils = new VidUtils() + def xmlReq = vidUtils.createXmlVolumeRequest(reqMap, 'CREATE_VF_MODULE_VOL', 'test-service-instance-id-123') + + assertEquals(vidUtilResp2, xmlReq) + } + + @Test + public void testVfModuleVolumeRollbackTrue() { + + def jsonSlurper = new JsonSlurper() + Map reqMap = jsonSlurper.parseText(bpmnReqJsonVolumeSuppressRollbackTrue) + + VidUtils vidUtils = new VidUtils() + def xmlReq = vidUtils.createXmlVolumeRequest(reqMap, 'CREATE_VF_MODULE_VOL', 'test-service-instance-id-123') + + assertEquals(vidUtilVolumeRespBackoutOnFailureFalse, xmlReq) + } + + @Test + public void testVfModuleVolumeRollbackFalse() { + + def jsonSlurper = new JsonSlurper() + Map reqMap = jsonSlurper.parseText(bpmnReqJsonVolumeSuppressRollbackFalse) + + VidUtils vidUtils = new VidUtils() + def xmlReq = vidUtils.createXmlVolumeRequest(reqMap, 'CREATE_VF_MODULE_VOL', 'test-service-instance-id-123') + + assertEquals(vidUtilVolumeRespBackoutOnFailureTrue, xmlReq) + } + + @Test + public void testVfModuleVolumeRollbackNone() { + + def jsonSlurper = new JsonSlurper() + Map reqMap = jsonSlurper.parseText(bpmnReqJsonVolumeSuppressRollbackNone) + + VidUtils vidUtils = new VidUtils() + def xmlReq = vidUtils.createXmlVolumeRequest(reqMap, 'CREATE_VF_MODULE_VOL', 'test-service-instance-id-123') + + assertEquals(vidUtilVolumeRespBackoutOnFailureEmpty, xmlReq) + } + + @Test + public void testVfModuleRollbackTrue() { + + def jsonSlurper = new JsonSlurper() + Map reqMap = jsonSlurper.parseText(bpmnReqJsonVfModuleSuppressRollbackTrue) + + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + when(mockExecution.getVariable("vnfType")).thenReturn('test-vnf-type-123') + when(mockExecution.getVariable("vnfId")).thenReturn('test-vnf-id-123') + when(mockExecution.getVariable("vfModuleId")).thenReturn('test-vf-module-id-123') + when(mockExecution.getVariable("volumeGroupId")).thenReturn('test-volume-group-id-123') + when(mockExecution.getVariable("isBaseVfModule")).thenReturn('false') + when(mockExecution.getVariable("mso-request-id")).thenReturn('test-request-id-123') + + VidUtils vidUtils = new VidUtils() + def xmlReq = vidUtils.createXmlVfModuleRequest(mockExecution, reqMap, 'CREATE_VF_MODULE', 'test-service-instance-id-123') + + println 'ggg->' + xmlReq + assertEquals(vidUtilVfModuleRespBackoutOnFailureFalse, xmlReq) + } + + @Test + public void testVfModuleRollbackFalse() { + + def jsonSlurper = new JsonSlurper() + Map reqMap = jsonSlurper.parseText(bpmnReqJsonVfModuleSuppressRollbackFalse) + + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + when(mockExecution.getVariable("vnfType")).thenReturn('test-vnf-type-123') + when(mockExecution.getVariable("vnfId")).thenReturn('test-vnf-id-123') + when(mockExecution.getVariable("vfModuleId")).thenReturn('test-vf-module-id-123') + when(mockExecution.getVariable("volumeGroupId")).thenReturn('test-volume-group-id-123') + when(mockExecution.getVariable("isBaseVfModule")).thenReturn('false') + when(mockExecution.getVariable("mso-request-id")).thenReturn('test-request-id-123') + + VidUtils vidUtils = new VidUtils() + def xmlReq = vidUtils.createXmlVfModuleRequest(mockExecution, reqMap, 'CREATE_VF_MODULE', 'test-service-instance-id-123') + + println 'ggg->' + xmlReq + assertEquals(vidUtilVfModuleRespBackoutOnFailureTrue, xmlReq) + } + + @Test + public void testVfModuleRollbackNone() { + + def jsonSlurper = new JsonSlurper() + Map reqMap = jsonSlurper.parseText(bpmnReqJsonVfModuleSuppressRollbackNone) + + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + when(mockExecution.getVariable("vnfType")).thenReturn('test-vnf-type-123') + when(mockExecution.getVariable("vnfId")).thenReturn('test-vnf-id-123') + when(mockExecution.getVariable("vfModuleId")).thenReturn('test-vf-module-id-123') + when(mockExecution.getVariable("volumeGroupId")).thenReturn('test-volume-group-id-123') + when(mockExecution.getVariable("isBaseVfModule")).thenReturn('false') + when(mockExecution.getVariable("mso-request-id")).thenReturn('test-request-id-123') + + VidUtils vidUtils = new VidUtils() + def xmlReq = vidUtils.createXmlVfModuleRequest(mockExecution, reqMap, 'CREATE_VF_MODULE', 'test-service-instance-id-123') + + println 'ggg->' + xmlReq + assertEquals(vidUtilVfModuleRespBackoutOnFailureEmpty, xmlReq) + } +} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/BPMNUtil.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/BPMNUtil.java new file mode 100644 index 0000000000..4e2b1e121a --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/BPMNUtil.java @@ -0,0 +1,214 @@ +package org.openecomp.mso.bpmn.common; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.doAnswer; +import static org.mockito.Mockito.spy; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.ws.rs.core.Response; + +import org.camunda.bpm.engine.ProcessEngineServices; +import org.camunda.bpm.engine.history.HistoricProcessInstance; +import org.camunda.bpm.engine.history.HistoricVariableInstance; +import org.camunda.bpm.engine.variable.impl.VariableMapImpl; +import org.jboss.resteasy.spi.AsynchronousResponse; +import org.mockito.invocation.InvocationOnMock; +import org.mockito.stubbing.Answer; +import org.openecomp.mso.bpmn.common.workflow.service.WorkflowAsyncCommonResource; +import org.openecomp.mso.bpmn.common.workflow.service.WorkflowResource; +import org.openecomp.mso.bpmn.common.workflow.service.WorkflowResponse; + +/** + * Set of utility methods used for Unit testing + * + */ +public class BPMNUtil { + + public static String getVariable(ProcessEngineServices processEngineServices, String processDefinitionID, String name) { + String pID = getProcessInstanceId(processEngineServices, + processDefinitionID); + assertProcessInstanceFinished(processEngineServices, pID); + HistoricVariableInstance responseData = processEngineServices.getHistoryService() + .createHistoricVariableInstanceQuery().processInstanceId(pID) + .variableName(name) + .singleResult(); + + if (responseData != null) { + return (responseData.getValue() != null ? responseData.getValue().toString(): null); + } + return null; + } + + @SuppressWarnings("unchecked") + public static <T extends Object> T getRawVariable(ProcessEngineServices processEngineServices, String processDefinitionID, String name) { + String pID = getProcessInstanceId(processEngineServices, + processDefinitionID); + assertProcessInstanceFinished(processEngineServices, pID); + Object responseData = processEngineServices.getHistoryService() + .createHistoricVariableInstanceQuery().processInstanceId(pID) + .variableName(name) + .singleResult() + .getValue(); + return (T) responseData; + } + + + public static void assertProcessInstanceFinished(ProcessEngineServices processEngineServices, String pid) { + assertEquals(1, processEngineServices.getHistoryService().createHistoricProcessInstanceQuery().processInstanceId(pid).finished().count()); + } + + public static void assertProcessInstanceNotFinished(ProcessEngineServices processEngineServices, String processDefinitionID) { + String pID = getProcessInstanceId(processEngineServices, + processDefinitionID); + assertEquals(0, processEngineServices.getHistoryService().createHistoricProcessInstanceQuery().processInstanceId(pID).finished().count()); + } + + private static String getProcessInstanceId( + ProcessEngineServices processEngineServices, String processDefinitionID) { + List<HistoricProcessInstance> historyList = processEngineServices.getHistoryService().createHistoricProcessInstanceQuery().list(); + String pID = null; + for (HistoricProcessInstance hInstance: historyList) { + if (hInstance.getProcessDefinitionKey().equals(processDefinitionID)) { + pID = hInstance.getId(); + break; + } + } + return pID; + } + + public static boolean isProcessInstanceFinished(ProcessEngineServices processEngineServices, String pid) { + return processEngineServices.getHistoryService().createHistoricProcessInstanceQuery().processInstanceId(pid).finished().count() == 1 ? true: false; + } + + + private static void buildVariable(String key, String value, Map<String,Object> variableValueType) { + Map<String, Object> host = new HashMap<String, Object>(); + host.put("value", value); + host.put("type", "String"); + variableValueType.put(key, host); + } + + public static WorkflowResponse executeWorkFlow(ProcessEngineServices processEngineServices, String processKey, Map<String,String> variables) { + WorkflowResource workflowResource = new WorkflowResource(); + VariableMapImpl variableMap = new VariableMapImpl(); + + Map<String, Object> variableValueType = new HashMap<String, Object>(); + for (String key : variables.keySet()) { + buildVariable(key, variables.get(key), variableValueType); + } + buildVariable("mso-service-request-timeout","600", variableValueType); + variableMap.put("variables", variableValueType); + + workflowResource.setProcessEngineServices4junit(processEngineServices); + Response response = workflowResource.startProcessInstanceByKey( + processKey, variableMap); + WorkflowResponse workflowResponse = (WorkflowResponse) response.getEntity(); + return workflowResponse; + } + + //Check the runtime service to see whether the process is completed + public static void waitForWorkflowToFinish(ProcessEngineServices processEngineServices, String pid) throws InterruptedException { + // Don't wait forever + long waitTime = 120000; + long endTime = System.currentTimeMillis() + waitTime; + + while (true) { + if (processEngineServices.getRuntimeService().createProcessInstanceQuery().processInstanceId(pid).singleResult() == null) { + break; + } + + if (System.currentTimeMillis() >= endTime) { + fail("Process " + pid + " did not finish in " + waitTime + "ms"); + } + + Thread.sleep(200); + } + } + + /** + * Executes the Asynchronous workflow in synchronous fashion and returns the WorkflowResponse object + * @param processEngineServices + * @param processKey + * @param variables + * @return + * @throws InterruptedException + */ + public static WorkflowResponse executeAsyncWorkflow(ProcessEngineServices processEngineServices, String processKey, Map<String,String> variables) throws InterruptedException { + ProcessThread pthread = new ProcessThread(processKey, processEngineServices, variables); + pthread.start(); + BPMNUtil.assertProcessInstanceNotFinished(processEngineServices, processKey); + String pid = getProcessInstanceId(processEngineServices, processKey); + //Caution: If there is a problem with workflow, this may wait for ever + while (true) { + pid = getProcessInstanceId(processEngineServices, processKey); + if (!isProcessInstanceFinished(processEngineServices,pid)) { + Thread.sleep(200); + } else{ + break; + } + } + //need to retrieve for second time ? + pid = getProcessInstanceId(processEngineServices, processKey); + waitForWorkflowToFinish(processEngineServices, pid); + return pthread.workflowResponse; + } + + /** + * Execute workflow using async resource + * @param processEngineServices + * @param processKey + * @param asyncResponse + * @param variables + */ + private static void executeAsyncFlow(ProcessEngineServices processEngineServices, String processKey, AsynchronousResponse asyncResponse, Map<String,String> variables) { + WorkflowAsyncCommonResource workflowResource = new WorkflowAsyncCommonResource(); + VariableMapImpl variableMap = new VariableMapImpl(); + + Map<String, Object> variableValueType = new HashMap<String, Object>(); + for (String key : variables.keySet()) { + buildVariable(key, variables.get(key), variableValueType); + } + buildVariable("mso-service-request-timeout","600", variableValueType); + variableMap.put("variables", variableValueType); + + workflowResource.setProcessEngineServices4junit(processEngineServices); + workflowResource.startProcessInstanceByKey(asyncResponse, processKey, variableMap); + } + + /** + * Helper class which executes workflow in a thread + * + */ + static class ProcessThread extends Thread { + + public WorkflowResponse workflowResponse = null; + public String processKey; + public AsynchronousResponse asyncResponse = spy(AsynchronousResponse.class); + public boolean started; + public ProcessEngineServices processEngineServices; + public Map<String,String> variables; + + public ProcessThread(String processKey, ProcessEngineServices processEngineServices, Map<String,String> variables) { + this.processKey = processKey; + this.processEngineServices = processEngineServices; + this.variables = variables; + } + + public void run() { + started = true; + doAnswer(new Answer<Void>() { + public Void answer(InvocationOnMock invocation) { + Response response = (Response) invocation.getArguments()[0]; + workflowResponse = (WorkflowResponse) response.getEntity(); + return null; + } + }).when(asyncResponse).setResponse(any(Response.class)); + executeAsyncFlow(processEngineServices, processKey, asyncResponse, variables); + } + } +} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/CompleteMsoProcessTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/CompleteMsoProcessTest.java new file mode 100644 index 0000000000..5cd59f38dd --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/CompleteMsoProcessTest.java @@ -0,0 +1,207 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common; + +import static org.openecomp.mso.bpmn.common.BPMNUtil.executeWorkFlow; +import static org.openecomp.mso.bpmn.common.BPMNUtil.waitForWorkflowToFinish; +import static org.openecomp.mso.bpmn.mock.StubResponseDatabase.mockUpdateRequestDB; + +import java.util.HashMap; +import java.util.Map; + +import org.camunda.bpm.engine.test.Deployment; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; +import org.openecomp.mso.bpmn.common.workflow.service.WorkflowResponse; + +/** + * Unit test for CompleteMsoProcess.bpmn. + */ +public class CompleteMsoProcessTest extends WorkflowTest { + + private void executeFlow(String inputRequestFile) throws InterruptedException { + mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); + + //String changeFeatureActivateRequest = FileUtil.readResourceFile("__files/SDN-ETHERNET-INTERNET/ChangeFeatureActivateV1/" + inputRequestFile); + Map<String, String> variables = new HashMap<String, String>(); + variables.put("CompleteMsoProcessRequest",inputRequestFile); + + WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "CompleteMsoProcess", variables); + waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + logEnd(); + } + + @Test + @Deployment(resources = {"subprocess/CompleteMsoProcess.bpmn"}) + public void msoCompletionRequestWithNotificationurl_200() throws Exception { + logStart(); + + //Execute Flow + executeFlow(gMsoCompletionRequestWithNotificationurl()); + + //Verify Error + String CMSO_ResponseCode = BPMNUtil.getVariable(processEngineRule, "CompleteMsoProcess", "CMSO_ResponseCode"); + Assert.assertEquals("200", CMSO_ResponseCode); + Assert.assertTrue((boolean) BPMNUtil.getRawVariable(processEngineRule, "CompleteMsoProcess", "CMSO_SuccessIndicator")); + logEnd(); + } + + @Test + @Ignore // BROKEN TEST + @Deployment(resources = {"subprocess/CompleteMsoProcess.bpmn"}) + public void msoCompletionRequestWithNotificationurl_500() throws Exception { + logStart(); + + //Execute Flow + executeFlow(gMsoCompletionRequestWithNotificationurl()); + + //Verify Error + String CMSO_ResponseCode = BPMNUtil.getVariable(processEngineRule, "CompleteMsoProcess", "CMSO_ResponseCode"); + Assert.assertEquals("500", CMSO_ResponseCode); + Assert.assertFalse((boolean) BPMNUtil.getRawVariable(processEngineRule, "CompleteMsoProcess", "CMSO_SuccessIndicator")); + logEnd(); + } + + @Test + @Deployment(resources = {"subprocess/CompleteMsoProcess.bpmn"}) + public void msoCompletionRequestWithNoNotificationurl() throws Exception { + logStart(); + + //Execute Flow + executeFlow(gMsoCompletionRequestWithNoNotificationurl()); + + //Verify Error + String CMSO_ResponseCode = BPMNUtil.getVariable(processEngineRule, "CompleteMsoProcess", "CMSO_ResponseCode"); + Assert.assertEquals("200", CMSO_ResponseCode); + Assert.assertTrue((boolean) BPMNUtil.getRawVariable(processEngineRule, "CompleteMsoProcess", "CMSO_SuccessIndicator")); + logEnd(); + } + + @Test + @Deployment(resources = {"subprocess/CompleteMsoProcess.bpmn"}) + public void msoCompletionRequestWithNotificationurlNoRequestId() throws Exception { + logStart(); + + //Execute Flow + executeFlow(gMsoCompletionRequestWithNotificationurlNoRequestId()); + + //Verify Error + String CMSO_ResponseCode = BPMNUtil.getVariable(processEngineRule, "CompleteMsoProcess", "CMSO_ResponseCode"); + Assert.assertEquals("200", CMSO_ResponseCode); + Assert.assertTrue((boolean) BPMNUtil.getRawVariable(processEngineRule, "CompleteMsoProcess", "CMSO_SuccessIndicator")); + logEnd(); + } + + @Test + @Deployment(resources = {"subprocess/CompleteMsoProcess.bpmn"}) + public void msoCompletionRequestWithNoNotificationurlNoRequestId() throws Exception { + logStart(); + + //Execute Flow + executeFlow(gMsoCompletionRequestWithNoNotificationurlNoRequestId()); + + //Verify Error + String CMSO_ResponseCode = BPMNUtil.getVariable(processEngineRule, "CompleteMsoProcess", "CMSO_ResponseCode"); + Assert.assertEquals("200", CMSO_ResponseCode); + Assert.assertTrue((boolean) BPMNUtil.getRawVariable(processEngineRule, "CompleteMsoProcess", "CMSO_SuccessIndicator")); + logEnd(); + } + + public String gMsoCompletionRequestWithNotificationurl() { + //Generated the below XML from ActiveVOS moduler ... Using the generate sample XML feature in ActiveVOS + String xml = "" + + "<sdncadapterworkflow:MsoCompletionRequest xmlns:ns=\"http://openecomp.org/mso/request/types/v1\" xmlns:sdncadapterworkflow=\"http://ecomp.openecomp.org.com/mso/workflow/schema/v1\">" + + " <ns:request-information>" + + " <ns:request-id>uCPE1020_STUW105_5002</ns:request-id>" + + " <ns:request-action>Layer3ServiceActivateRequest</ns:request-action>" + + " <ns:request-sub-action>COMPLETE</ns:request-sub-action>" + + " <ns:source>OMX</ns:source>" + + " <ns:notification-url>https://t3nap1a1.snt.bst.bls.com:9004/sdncontroller-sdncontroller-inbound-ws-war/sdncontroller-sdncontroller-inbound-ws.wsdl</ns:notification-url>" + + " <ns:order-number>10205000</ns:order-number>" + + " <ns:order-version>1</ns:order-version>" + + " </ns:request-information>" + + " <sdncadapterworkflow:mso-bpel-name>UCPELayer3ServiceActivateV1</sdncadapterworkflow:mso-bpel-name>" + + "</sdncadapterworkflow:MsoCompletionRequest>"; + + return xml; + } + + + + public String gMsoCompletionRequestWithNoNotificationurl() { + //Generated the below XML from ActiveVOS moduler ... Using the generate sample XML feature in ActiveVOS + String xml = "" + + "<sdncadapterworkflow:MsoCompletionRequest xmlns:ns=\"http://openecomp.org/mso/request/types/v1\" xmlns:sdncadapterworkflow=\"http://openecomp.org/mso/workflow/schema/v1\">" + + " <ns:request-information>" + + " <ns:request-id>uCPE1020_STUW105_5002</ns:request-id>" + + " <ns:request-action>Layer3ServiceActivateRequest</ns:request-action>" + + " <ns:request-sub-action>COMPLETE</ns:request-sub-action>" + + " <ns:source>OMX</ns:source>" + + " <ns:notification-url></ns:notification-url>" + + " <ns:order-number>10205000</ns:order-number>" + + " <ns:order-version>1</ns:order-version>" + + " </ns:request-information>" + + " <sdncadapterworkflow:mso-bpel-name>UCPELayer3ServiceActivateV1</sdncadapterworkflow:mso-bpel-name>" + + "</sdncadapterworkflow:MsoCompletionRequest>"; + + return xml; + } + + public String gMsoCompletionRequestWithNoNotificationurlNoRequestId() { + //Generated the below XML from ActiveVOS moduler ... Using the generate sample XML feature in ActiveVOS + String xml = "" + + "<sdncadapterworkflow:MsoCompletionRequest xmlns:ns=\"http://openecomp.org/mso/request/types/v1\" xmlns:sdncadapterworkflow=\"http://openecomp.org/mso/workflow/schema/v1\">" + + " <ns:request-information>" + + " <ns:request-id></ns:request-id>" + + " <ns:request-action>Layer3ServiceActivateRequest</ns:request-action>" + + " <ns:request-sub-action>COMPLETE</ns:request-sub-action>" + + " <ns:source>OMX</ns:source>" + + " <ns:notification-url></ns:notification-url>" + + " <ns:order-number>10205000</ns:order-number>" + + " <ns:order-version>1</ns:order-version>" + + " </ns:request-information>" + + " <sdncadapterworkflow:mso-bpel-name>UCPELayer3ServiceActivateV1</sdncadapterworkflow:mso-bpel-name>" + + "</sdncadapterworkflow:MsoCompletionRequest>"; + + return xml; + } + + public String gMsoCompletionRequestWithNotificationurlNoRequestId() { + //Generated the below XML from ActiveVOS moduler ... Using the generate sample XML feature in ActiveVOS + String xml = "" + + "<sdncadapterworkflow:MsoCompletionRequest xmlns:ns=\"http://openecomp.org/mso/request/types/v1\" xmlns:sdncadapterworkflow=\"http://openecomp.org/mso/workflow/schema/v1\">" + + " <ns:request-information>" + + " <ns:request-id></ns:request-id>" + + " <ns:request-action>Layer3ServiceActivateRequest</ns:request-action>" + + " <ns:request-sub-action>COMPLETE</ns:request-sub-action>" + + " <ns:source>OMX</ns:source>" + + " <ns:notification-url>https://t3nap1a1.snt.bst.bls.com:9004/sdncontroller-sdncontroller-inbound-ws-war/sdncontroller-sdncontroller-inbound-ws.wsdl</ns:notification-url>" + + " <ns:order-number>10205000</ns:order-number>" + + " <ns:order-version>1</ns:order-version>" + + " </ns:request-information>" + + " <sdncadapterworkflow:mso-bpel-name>UCPELayer3ServiceActivateV1</sdncadapterworkflow:mso-bpel-name>" + + "</sdncadapterworkflow:MsoCompletionRequest>"; + + return xml; + } +} + diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/ConfirmVolumeGroupNameTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/ConfirmVolumeGroupNameTest.java new file mode 100644 index 0000000000..5b10b8b89e --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/ConfirmVolumeGroupNameTest.java @@ -0,0 +1,133 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common; + +import static org.junit.Assert.assertEquals; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetVolumeGroupById; + +import java.util.HashMap; +import java.util.Map; + +import org.camunda.bpm.engine.RuntimeService; +import org.camunda.bpm.engine.test.Deployment; +import org.junit.Test; + +/** + * Unit test cases for ConfirmVolumeGroupName.bpmn + */ +public class ConfirmVolumeGroupNameTest extends WorkflowTest { + /** + * Sunny day scenario. + * + * @throws Exception + */ + @Test + @Deployment(resources = { + "subprocess/ConfirmVolumeGroupName.bpmn" + }) + public void sunnyDay() throws Exception { + + logStart(); + MockGetVolumeGroupById("MDTWNJ21", "VOLUME_GROUP_ID_1", "aai-volume-group-id-info.xml"); + + System.out.println("Before starting process"); + + RuntimeService runtimeService = processEngineRule.getRuntimeService(); + Map<String, Object> variables = new HashMap<String, Object>(); + variables.put("isDebugLogEnabled","true"); + variables.put("ConfirmVolumeGroupName_volumeGroupId", "VOLUME_GROUP_ID_1"); + variables.put("ConfirmVolumeGroupName_volumeGroupName", "VOLUME_GROUP_ID_1_NAME"); + variables.put("ConfirmVolumeGroupName_aicCloudRegion", "MDTWNJ21"); + System.out.println("after setting variables"); + runtimeService.startProcessInstanceByKey("ConfirmVolumeGroupName", variables); + String response = BPMNUtil.getVariable(processEngineRule, "ConfirmVolumeGroupName", "CVGN_queryVolumeGroupResponse"); + String responseCode = BPMNUtil.getVariable(processEngineRule, "ConfirmVolumeGroupName", "CVGN_queryVolumeGroupResponseCode"); + + assertEquals("200", responseCode); + System.out.println(response); + logEnd(); + } + + /** + * Rainy day scenario - nonexisting volume group id. + * + * @throws Exception + */ + @Test + @Deployment(resources = { + "subprocess/ConfirmVolumeGroupName.bpmn" + }) + public void rainyDayNoVolumeGroupId() throws Exception { + + logStart(); + MockGetVolumeGroupById("MDTWNJ21", "VOLUME_GROUP_ID_1", "aai-volume-group-id-info.xml"); + + System.out.println("Before starting process"); + + RuntimeService runtimeService = processEngineRule.getRuntimeService(); + Map<String, Object> variables = new HashMap<String, Object>(); + variables.put("isDebugLogEnabled","true"); + variables.put("ConfirmVolumeGroupName_volumeGroupId", "VOLUME_GROUP_ID_THAT_DOES_NOT_EXIST"); + variables.put("ConfirmVolumeGroupName_volumeGroupName", "cee6d136-e378-4678-a024-2cd15f0ee0cg"); + System.out.println("after setting variables"); + runtimeService.startProcessInstanceByKey("ConfirmVolumeGroupName", variables); + String response = BPMNUtil.getVariable(processEngineRule, "ConfirmVolumeGroupName", "CVGN_queryVolumeGroupResponse"); + String responseCode = BPMNUtil.getVariable(processEngineRule, "ConfirmVolumeGroupName", "CVGN_queryVolumeGroupResponseCode"); + + assertEquals("404", responseCode); + System.out.println(response); + + logEnd(); + } + + /** + * Rainy day scenario - volume group name does not match the name in AAI + * + * + * @throws Exception + */ + @Test + @Deployment(resources = { + "subprocess/ConfirmVolumeGroupName.bpmn" + }) + public void rainyDayNameDoesNotMatch() throws Exception { + + logStart(); + MockGetVolumeGroupById("MDTWNJ21", "VOLUME_GROUP_ID_1", "aai-volume-group-id-info.xml"); + + System.out.println("Before starting process"); + + RuntimeService runtimeService = processEngineRule.getRuntimeService(); + Map<String, Object> variables = new HashMap<String, Object>(); + variables.put("isDebugLogEnabled","true"); + variables.put("ConfirmVolumeGroupName_volumeGroupId", "VOLUME_GROUP_ID_1"); + variables.put("ConfirmVolumeGroupName_volumeGroupName", "BAD_VOLUME_GROUP_NAME"); + System.out.println("after setting variables"); + runtimeService.startProcessInstanceByKey("ConfirmVolumeGroupName", variables); + String response = BPMNUtil.getVariable(processEngineRule, "ConfirmVolumeGroupName", "CVGN_queryVolumeGroupResponse"); + String responseCode = BPMNUtil.getVariable(processEngineRule, "ConfirmVolumeGroupName", "CVGN_queryVolumeGroupResponseCode"); + + assertEquals("404", responseCode); + System.out.println(response); + + logEnd(); + } +} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/ConfirmVolumeGroupTenantTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/ConfirmVolumeGroupTenantTest.java new file mode 100644 index 0000000000..e62742da30 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/ConfirmVolumeGroupTenantTest.java @@ -0,0 +1,91 @@ +/* + * © 2014 AT&T Intellectual Property. All rights reserved. Used under license from AT&T Intellectual Property. + */ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common; + +import static org.junit.Assert.assertEquals; +import static org.openecomp.mso.bpmn.common.BPMNUtil.executeWorkFlow; +import static org.openecomp.mso.bpmn.common.BPMNUtil.waitForWorkflowToFinish; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetVolumeGroupById; + +import java.util.HashMap; +import java.util.Map; + +import org.camunda.bpm.engine.test.Deployment; +import org.junit.Test; +import org.openecomp.mso.bpmn.common.workflow.service.WorkflowResponse; + +/** + * Please describe the ConfirmVolumeGroupTenantTest.java class + * + */ +public class ConfirmVolumeGroupTenantTest extends WorkflowTest { + + @Test + @Deployment(resources = {"subprocess/ConfirmVolumeGroupTenant.bpmn"}) + public void testRemoveLayer3Service_success() throws Exception{ + MockGetVolumeGroupById("MDTWNJ21", "a8399879-31b3-4973-be26-0a0cbe776b58", "CRTGVNF_queryAAIResponseVolume.xml"); + + Map<String, String> variables = new HashMap<String, String>(); + setVariables(variables); + + WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "ConfirmVolumeGroupTenant", variables); + waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + String actualNameMatch = BPMNUtil.getVariable(processEngineRule, "ConfirmVolumeGroupTenant", "groupNamesMatch"); + String actualIdMatch = BPMNUtil.getVariable(processEngineRule, "ConfirmVolumeGroupTenant", "tenantIdsMatch"); + String actualResponse = BPMNUtil.getVariable(processEngineRule, "ConfirmVolumeGroupTenant", "volumeHeatStackId"); + + assertEquals("Response", "true", actualNameMatch); + assertEquals("Response", "true", actualIdMatch); + assertEquals("Response", "MoG_CinderVolumes_2/19387dc6-060f-446e-b41f-dcfd29c73845", actualResponse); + } + + @Test + @Deployment(resources = {"subprocess/ConfirmVolumeGroupTenant.bpmn"}) + public void testRemoveLayer3Service_idsNotMatch() throws Exception{ + MockGetVolumeGroupById("MDTWNJ21", "a8399879-31b3-4973-be26-0a0cbe776b58", "CRTGVNF_queryAAIResponseVolume_idsNotMatch.xml"); + + Map<String, String> variables = new HashMap<String, String>(); + setVariables(variables); + + WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "ConfirmVolumeGroupTenant", variables); + waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + String actualNameMatch = BPMNUtil.getVariable(processEngineRule, "ConfirmVolumeGroupTenant", "groupNamesMatch"); + String actualIdMatch = BPMNUtil.getVariable(processEngineRule, "ConfirmVolumeGroupTenant", "tenantIdsMatch"); + String actualResponse = BPMNUtil.getVariable(processEngineRule, "ConfirmVolumeGroupTenant", "WorkflowException"); + + assertEquals("Response", "true", actualNameMatch); + assertEquals("Response", "false", actualIdMatch); + assertEquals("Response", "WorkflowException[processKey=ConfirmVolumeGroupTenant,errorCode=1,errorMessage=Volume Group a8399879-31b3-4973-be26-0a0cbe776b58 does not belong to your tenant]", actualResponse); + + } + + private void setVariables(Map<String, String> variables) { + variables.put("isDebugLogEnabled", "true"); + variables.put("volumeGroupId","a8399879-31b3-4973-be26-0a0cbe776b58"); + variables.put("tenantId", "7dd5365547234ee8937416c65507d266"); + variables.put("aicCloudRegion", "MDTWNJ21"); + } +} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/CreateAAIVfModuleTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/CreateAAIVfModuleTest.java new file mode 100644 index 0000000000..b41d2d2558 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/CreateAAIVfModuleTest.java @@ -0,0 +1,277 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common; + +import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; +import static com.github.tomakehurst.wiremock.client.WireMock.containing; +import static com.github.tomakehurst.wiremock.client.WireMock.put; +import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; +import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching; +import static org.openecomp.mso.bpmn.common.DeleteAAIVfModuleTest.MockAAIGenericVnfSearch; + +import java.util.HashMap; +import java.util.Map; + +import org.camunda.bpm.engine.RuntimeService; +import org.camunda.bpm.engine.test.Deployment; +import org.junit.Assert; +import org.junit.Test; +import org.openecomp.mso.bpmn.core.WorkflowException; + +/** + * Unit test for CreateAAIVfModule.bpmn. + */ +public class CreateAAIVfModuleTest extends WorkflowTest { + + @Test + @Deployment(resources = { + "subprocess/CreateAAIVfModule.bpmn" + }) + public void TestCreateGenericVnfSuccess_200() { + + MockAAIGenericVnfSearch(); + MockAAICreateGenericVnf(); + MockAAIVfModulePUT(true); + RuntimeService runtimeService = processEngineRule.getRuntimeService(); + Map<String, Object> variables = new HashMap<String, Object>(); + variables.put("isDebugLogEnabled","true"); + variables.put("isVidRequest", "false"); + variables.put("vnfName", "STMTN5MMSC22"); + variables.put("serviceId", "00000000-0000-0000-0000-000000000000"); + variables.put("personaModelId", "973ed047-d251-4fb9-bf1a-65b8949e0a73"); + variables.put("personaModelVersion", "1.0"); + variables.put("vfModuleName", "STMTN5MMSC22-MMSC::module-0-0"); + variables.put("vfModuleModelName", "MMSC::module-0"); + + runtimeService.startProcessInstanceByKey("CreateAAIVfModule", variables); + String response = BPMNUtil.getVariable(processEngineRule, "CreateAAIVfModule", "CAAIVfMod_createVfModuleResponseCode"); + String responseCode = BPMNUtil.getVariable(processEngineRule, "CreateAAIVfModule", "CAAIVfMod_createVfModuleResponseCode"); + Assert.assertEquals("201", responseCode); + System.out.println(response); + } + + @Test + @Deployment(resources = { + "subprocess/CreateAAIVfModule.bpmn" + }) + public void TestCreateVfModuleSuccess_200() { + // create Add-on VF Module for existing Generic VNF + MockAAIGenericVnfSearch(); + MockAAICreateGenericVnf(); + MockAAIVfModulePUT(true); + RuntimeService runtimeService = processEngineRule.getRuntimeService(); + Map<String, Object> variables = new HashMap<String, Object>(); + variables.put("isDebugLogEnabled","true"); + variables.put("isVidRequest", "false"); + variables.put("vnfId", "a27ce5a9-29c4-4c22-a017-6615ac73c721"); + variables.put("serviceId", "00000000-0000-0000-0000-000000000000"); + variables.put("personaModelId", "973ed047-d251-4fb9-bf1a-65b8949e0a73"); + variables.put("personaModelVersion", "1.0"); + variables.put("vfModuleName", "STMTN5MMSC21-MMSC::module-1-0"); + variables.put("vfModuleModelName", "STMTN5MMSC21-MMSC::model-1-0"); + runtimeService.startProcessInstanceByKey("CreateAAIVfModule", variables); + String response = BPMNUtil.getVariable(processEngineRule, "CreateAAIVfModule", "CAAIVfMod_createVfModuleResponseCode"); + String responseCode = BPMNUtil.getVariable(processEngineRule, "CreateAAIVfModule", "CAAIVfMod_createVfModuleResponseCode"); + Assert.assertEquals("201", responseCode); + System.out.println(response); + } + + @Test + @Deployment(resources = { + "subprocess/CreateAAIVfModule.bpmn" + }) + public void TestQueryGenericVnfFailure_5000() { + MockAAIGenericVnfSearch(); + MockAAICreateGenericVnf(); + MockAAIVfModulePUT(true); + RuntimeService runtimeService = processEngineRule.getRuntimeService(); + Map<String, Object> variables = new HashMap<String, Object>(); + variables.put("isDebugLogEnabled","true"); + variables.put("isVidRequest", "false"); + variables.put("vnfName", "STMTN5MMSC23"); + variables.put("serviceId", "00000000-0000-0000-0000-000000000000"); + variables.put("personaModelId", "973ed047-d251-4fb9-bf1a-65b8949e0a73"); + variables.put("personaModelVersion", "1.0"); + variables.put("vfModuleName", "STMTN5MMSC23-MMSC::module-0-0"); + variables.put("vfModuleModelName", "MMSC::module-0"); + runtimeService.startProcessInstanceByKey("CreateAAIVfModule", variables); + WorkflowException exception = BPMNUtil.getRawVariable(processEngineRule, "CreateAAIVfModule", "WorkflowException"); + Assert.assertEquals(5000, exception.getErrorCode()); + Assert.assertEquals(true, exception.getErrorMessage().contains("<messageId>SVC3002</messageId>")); + System.out.println(exception.getErrorMessage()); + } + + @Test + @Deployment(resources = { + "subprocess/CreateAAIVfModule.bpmn" + }) + public void TestCreateDupGenericVnfFailure_1002() { + MockAAIGenericVnfSearch(); + MockAAICreateGenericVnf(); + MockAAIVfModulePUT(true); + RuntimeService runtimeService = processEngineRule.getRuntimeService(); + Map<String, Object> variables = new HashMap<String, Object>(); + variables.put("isDebugLogEnabled","true"); + variables.put("isVidRequest", "false"); + variables.put("vnfName", "STMTN5MMSC21"); + variables.put("serviceId", "00000000-0000-0000-0000-000000000000"); + variables.put("personaModelId", "973ed047-d251-4fb9-bf1a-65b8949e0a73"); + variables.put("personaModelVersion", "1.0"); + variables.put("vfModuleName", "STMTN5MMSC21-MMSC::module-0-0"); + variables.put("vfModuleModelName", "MMSC::module-0"); + runtimeService.startProcessInstanceByKey("CreateAAIVfModule", variables); + WorkflowException exception = BPMNUtil.getRawVariable(processEngineRule, "CreateAAIVfModule", "WorkflowException"); + Assert.assertEquals(1002, exception.getErrorCode()); + Assert.assertEquals(true, exception.getErrorMessage().contains("Invalid request for new Generic VNF which already exists")); + System.out.println(exception.getErrorMessage()); + } + + @Test + @Deployment(resources = { + "subprocess/CreateAAIVfModule.bpmn" + }) + public void TestCreateDupVfModuleFailure_1002() { + MockAAIGenericVnfSearch(); + MockAAICreateGenericVnf(); + MockAAIVfModulePUT(true); + RuntimeService runtimeService = processEngineRule.getRuntimeService(); + Map<String, Object> variables = new HashMap<String, Object>(); + variables.put("isDebugLogEnabled","true"); + variables.put("isVidRequest", "false"); + variables.put("vnfId", "2f6aee38-1e2a-11e6-82d1-ffc7d9ee8aa4"); + variables.put("serviceId", "00000000-0000-0000-0000-000000000000"); + variables.put("personaModelId", "973ed047-d251-4fb9-bf1a-65b8949e0a73"); + variables.put("personaModelVersion", "1.0"); + variables.put("vfModuleName", "STMTN5MMSC20-MMSC::module-1-0"); + variables.put("vfModuleModelName", "STMTN5MMSC20-MMSC::model-1-0"); + runtimeService.startProcessInstanceByKey("CreateAAIVfModule", variables); + WorkflowException exception = BPMNUtil.getRawVariable(processEngineRule, "CreateAAIVfModule", "WorkflowException"); + Assert.assertEquals(1002, exception.getErrorCode()); + Assert.assertEquals(true, exception.getErrorMessage().contains("already exists for Generic VNF")); + System.out.println(exception.getErrorMessage()); + } + + @Test + @Deployment(resources = { + "subprocess/CreateAAIVfModule.bpmn" + }) + public void TestCreateGenericVnfFailure_5000() { + MockAAIGenericVnfSearch(); + MockAAICreateGenericVnf(); + MockAAIVfModulePUT(true); + RuntimeService runtimeService = processEngineRule.getRuntimeService(); + Map<String, Object> variables = new HashMap<String, Object>(); + variables.put("isDebugLogEnabled","true"); + variables.put("isVidRequest", "false"); + variables.put("vnfName", "STMTN5MMSC22"); + variables.put("serviceId", "99999999-9999-9999-9999-999999999999"); + variables.put("personaModelId", "973ed047-d251-4fb9-bf1a-65b8949e0a73"); + variables.put("personaModelVersion", "1.0"); + variables.put("vfModuleName", "STMTN5MMSC22-PCRF::module-1-0"); + variables.put("vfModuleModelName", "PCRF::module-0"); + runtimeService.startProcessInstanceByKey("CreateAAIVfModule", variables); + WorkflowException exception = BPMNUtil.getRawVariable(processEngineRule, "CreateAAIVfModule", "WorkflowException"); + Assert.assertEquals(5000, exception.getErrorCode()); + Assert.assertEquals(true, exception.getErrorMessage().contains("<messageId>SVC3002</messageId>")); + System.out.println(exception.getErrorMessage()); + } + + @Test + @Deployment(resources = { + "subprocess/CreateAAIVfModule.bpmn" + }) + public void TestCreateGenericVnfFailure_1002() { + MockAAIGenericVnfSearch(); + MockAAICreateGenericVnf(); + MockAAIVfModulePUT(true); + RuntimeService runtimeService = processEngineRule.getRuntimeService(); + Map<String, Object> variables = new HashMap<String, Object>(); + variables.put("isDebugLogEnabled","true"); + variables.put("isVidRequest", "false"); + variables.put("vnfId", "768073c7-f41f-4822-9323-b75962763d74"); + variables.put("serviceId", "00000000-0000-0000-0000-000000000000"); + variables.put("personaModelId", "973ed047-d251-4fb9-bf1a-65b8949e0a73"); + variables.put("personaModelVersion", "1.0"); + variables.put("vfModuleName", "STMTN5MMSC22-PCRF::module-1-0"); + variables.put("vfModuleModelName", "PCRF::module-0"); + runtimeService.startProcessInstanceByKey("CreateAAIVfModule", variables); + WorkflowException exception = BPMNUtil.getRawVariable(processEngineRule, "CreateAAIVfModule", "WorkflowException"); + Assert.assertEquals(1002, exception.getErrorCode()); + Assert.assertEquals(true, exception.getErrorMessage().contains("Generic VNF Not Found")); + System.out.println(exception.getErrorMessage()); + } + + @Test + @Deployment(resources = { + "subprocess/CreateAAIVfModule.bpmn" + }) + public void TestCreateVfModuleFailure_5000() { + MockAAIGenericVnfSearch(); + MockAAICreateGenericVnf(); + MockAAIVfModulePUT(true); + RuntimeService runtimeService = processEngineRule.getRuntimeService(); + Map<String, Object> variables = new HashMap<String, Object>(); + variables.put("isDebugLogEnabled","true"); + variables.put("isVidRequest", "false"); + variables.put("vnfId", "a27ce5a9-29c4-4c22-a017-6615ac73c721"); + variables.put("serviceId", "99999999-9999-9999-9999-999999999999"); + variables.put("personaModelId", "973ed047-d251-4fb9-bf1a-65b8949e0a73"); + variables.put("personaModelVersion", "1.0"); + variables.put("vfModuleName", "STMTN5MMSC21-PCRF::module-1-0"); + variables.put("vfModuleModelName", "STMTN5MMSC21-PCRF::model-1-0"); + runtimeService.startProcessInstanceByKey("CreateAAIVfModule", variables); + WorkflowException exception = BPMNUtil.getRawVariable(processEngineRule, "CreateAAIVfModule", "WorkflowException"); + Assert.assertEquals(5000, exception.getErrorCode()); + Assert.assertEquals(true, exception.getErrorMessage().contains("<messageId>SVC3002</messageId>")); + System.out.println(exception.getErrorMessage()); + } + + public static void MockAAICreateGenericVnf(){ + stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/.*")) + .withRequestBody(containing("<service-id>00000000-0000-0000-0000-000000000000</service-id>")) + .willReturn(aResponse() + .withStatus(201))); + stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/.*")) + .withRequestBody(containing("<service-id>99999999-9999-9999-9999-999999999999</service-id>")) + .willReturn(aResponse() + .withStatus(500) + .withHeader("Content-Type", "text/xml") + .withBodyFile("aaiFault.xml"))); + } + + // start of mocks used locally and by other VF Module unit tests + public static void MockAAIVfModulePUT(boolean isCreate){ + stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/.*/vf-modules/vf-module/.*")) + .withRequestBody(containing("MMSC")) + .willReturn(aResponse() + .withStatus(isCreate ? 201 : 200))); + stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/.*/vf-modules/vf-module/.*")) + .withRequestBody(containing("PCRF")) + .willReturn(aResponse() + .withStatus(500) + .withHeader("Content-Type", "text/xml") + .withBodyFile("aaiFault.xml"))); + stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c721")) + .willReturn(aResponse() + .withStatus(200))); + } + +}
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/CreateAAIVfModuleVolumeGroupTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/CreateAAIVfModuleVolumeGroupTest.java new file mode 100644 index 0000000000..f1a2d7b4e2 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/CreateAAIVfModuleVolumeGroupTest.java @@ -0,0 +1,136 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common; + +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfByIdWithPriority; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetVfModuleId; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutVfModuleIdNoResponse; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +import org.camunda.bpm.engine.test.Deployment; +import org.junit.Assert; +import org.junit.Test; +import org.openecomp.mso.bpmn.mock.FileUtil; + +/** + * Unit tests for CreateAAIVfModuleVolumeGroup.bpmn. + */ +public class CreateAAIVfModuleVolumeGroupTest extends WorkflowTest { + + /** + * Test the happy path through the flow. + */ + @Test + @Deployment(resources = { + "subprocess/CreateAAIVfModuleVolumeGroup.bpmn" + }) + public void happyPath() throws IOException { + + logStart(); + + String updateAAIVfModuleRequest = FileUtil.readResourceFile("__files/VfModularity/CreateAAIVfModuleVolumeGroupRequest.xml"); + MockGetGenericVnfByIdWithPriority("skask", "lukewarm", 200, "VfModularity/VfModule-lukewarm.xml", 2); + MockPutVfModuleIdNoResponse("skask", "PCRF", "lukewarm"); + + String businessKey = UUID.randomUUID().toString(); + Map<String, Object> variables = new HashMap<String, Object>(); + variables.put("mso-request-id", "999-99-9999"); + variables.put("isDebugLogEnabled","true"); + variables.put("CreateAAIVfModuleVolumeGroupRequest", updateAAIVfModuleRequest); + invokeSubProcess("CreateAAIVfModuleVolumeGroup", businessKey, variables); + + Assert.assertTrue(isProcessEnded(businessKey)); + String response = (String) getVariableFromHistory(businessKey, "CAAIVfModVG_updateVfModuleResponse"); + Integer responseCode = (Integer) getVariableFromHistory(businessKey, "CAAIVfModVG_updateVfModuleResponseCode"); + System.out.println("Subflow response code: " + responseCode); + System.out.println("Subflow response: " + response); + Assert.assertEquals(200, responseCode.intValue()); + + logEnd(); + } + + /** + * Test the case where the GET to AAI returns a 404. + */ + @Test + @Deployment(resources = { + "subprocess/CreateAAIVfModuleVolumeGroup.bpmn" + }) + public void badGet() throws IOException { + + logStart(); + + String updateAAIVfModuleRequest = FileUtil.readResourceFile("__files/VfModularity/CreateAAIVfModuleVolumeGroupRequest.xml"); + MockGetVfModuleId("skask", ".*", "VfModularity/VfModule-supercool.xml", 404); + + String businessKey = UUID.randomUUID().toString(); + Map<String, Object> variables = new HashMap<String, Object>(); + variables.put("mso-request-id", "999-99-9999"); + variables.put("isDebugLogEnabled","true"); + variables.put("CreateAAIVfModuleVolumeGroupRequest", updateAAIVfModuleRequest); + invokeSubProcess("CreateAAIVfModuleVolumeGroup", businessKey, variables); + + Assert.assertTrue(isProcessEnded(businessKey)); + String response = (String) getVariableFromHistory(businessKey, "CAAIVfModVG_getVfModuleResponse"); + Integer responseCode = (Integer) getVariableFromHistory(businessKey, "CAAIVfModVG_getVfModuleResponseCode"); + System.out.println("Subflow response code: " + responseCode); + System.out.println("Subflow response: " + response); + Assert.assertEquals(404, responseCode.intValue()); + + logEnd(); + } + + /** + * Test the case where the GET to AAI is successful, but he subsequent PUT returns 404. + */ + @Test + @Deployment(resources = { + "subprocess/CreateAAIVfModuleVolumeGroup.bpmn" + }) + public void badPut() throws IOException { + + logStart(); + + String updateAAIVfModuleRequest = FileUtil.readResourceFile("__files/VfModularity/CreateAAIVfModuleVolumeGroupRequest.xml"); + MockGetVfModuleId("skask", "lukewarm", "VfModularity/VfModule-lukewarm.xml", 200); + + String businessKey = UUID.randomUUID().toString(); + Map<String, Object> variables = new HashMap<String, Object>(); + variables.put("mso-request-id", "999-99-9999"); + variables.put("isDebugLogEnabled","true"); + variables.put("CreateAAIVfModuleVolumeGroupRequest", updateAAIVfModuleRequest); + invokeSubProcess("CreateAAIVfModuleVolumeGroup", businessKey, variables); + + Assert.assertTrue(isProcessEnded(businessKey)); + String response = (String) getVariableFromHistory(businessKey, "CAAIVfModVG_updateVfModuleResponse"); + Integer responseCode = (Integer) getVariableFromHistory(businessKey, "CAAIVfModVG_updateVfModuleResponseCode"); + System.out.println("Subflow response code: " + responseCode); + System.out.println("Subflow response: " + response); + Assert.assertEquals(404, responseCode.intValue()); + + logEnd(); + } +} + diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/DeleteAAIVfModuleTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/DeleteAAIVfModuleTest.java new file mode 100644 index 0000000000..0136b675dd --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/DeleteAAIVfModuleTest.java @@ -0,0 +1,643 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common; + +import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; +import static com.github.tomakehurst.wiremock.client.WireMock.delete; +import static com.github.tomakehurst.wiremock.client.WireMock.get; +import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; +import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching; + +import java.util.HashMap; +import java.util.Map; + +import org.camunda.bpm.engine.RuntimeService; +import org.camunda.bpm.engine.test.Deployment; +import org.junit.Assert; +import org.junit.Test; +import org.openecomp.mso.bpmn.core.WorkflowException; + +/** + * Unit test for DeleteAAIVfModule.bpmn. + */ +public class DeleteAAIVfModuleTest extends WorkflowTest { + private static final String EOL = "\n"; + + @Test + @Deployment(resources = { + "subprocess/DeleteAAIVfModule.bpmn" + }) + public void TestDeleteGenericVnfSuccess_200() { + // delete the Base Module and Generic Vnf + // vnf-id=a27ce5a9-29c4-4c22-a017-6615ac73c721, vf-module-id=973ed047-d251-4fb9-bf1a-65b8949e0a73 + MockAAIGenericVnfSearch(); + MockAAIDeleteGenericVnf(); + MockAAIDeleteVfModule(); + RuntimeService runtimeService = processEngineRule.getRuntimeService(); + Map<String, Object> variables = new HashMap<String, Object>(); + variables.put("isDebugLogEnabled","true"); + variables.put("DeleteAAIVfModuleRequest","<vnf-request xmlns=\"http://openecomp.org/mso/infra/vnf-request/v1\"> <request-info> <action>DELETE_VF_MODULE</action> <source>PORTAL</source> </request-info> <vnf-inputs> <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c721</vnf-id> <vnf-name>STMTN5MMSC21</vnf-name> <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a73</vf-module-id> <vf-module-name>STMTN5MMSC21-MMSC::module-0-0</vf-module-name> </vnf-inputs> <vnf-params xmlns:tns=\"http://openecomp.org/mso/infra/vnf-request/v1\"/> </vnf-request>"); + runtimeService.startProcessInstanceByKey("DeleteAAIVfModule", variables); + String response = BPMNUtil.getVariable(processEngineRule, "DeleteAAIVfModule", "DAAIVfMod_deleteGenericVnfResponseCode"); + String responseCode = BPMNUtil.getVariable(processEngineRule, "DeleteAAIVfModule", "DAAIVfMod_deleteGenericVnfResponseCode"); + Assert.assertEquals("200", responseCode); + System.out.println(response); + } + + @Test + @Deployment(resources = { + "subprocess/DeleteAAIVfModule.bpmn" + }) + public void TestDeleteVfModuleSuccess_200() { + // delete Add-on Vf Module for existing Generic Vnf + // vnf-id=a27ce5a9-29c4-4c22-a017-6615ac73c720, vf-module-id=973ed047-d251-4fb9-bf1a-65b8949e0a75 + String request = + "<vnf-request xmlns=\"http://openecomp.org/mso/infra/vnf-request/v1\">" + EOL + + " <request-info>" + EOL + + " <action>DELETE_VF_MODULE</action>" + EOL + + " <source>PORTAL</source>" + EOL + + " </request-info>" + EOL + + " <vnf-inputs>" + EOL + + " <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c720</vnf-id>" + EOL + + " <vnf-name>STMTN5MMSC20</vnf-name>" + EOL + + " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a75</vf-module-id>" + EOL + + " <vf-module-name>STMTN5MMSC20-MMSC::module-1-0</vf-module-name>" + EOL + + " </vnf-inputs>" + EOL + + " <vnf-params xmlns:tns=\"http://openecomp.org/mso/infra/vnf-request/v1\"/>" + EOL + + "</vnf-request>" + EOL; + + MockAAIGenericVnfSearch(); + MockAAIDeleteGenericVnf(); + MockAAIDeleteVfModule(); + RuntimeService runtimeService = processEngineRule.getRuntimeService(); + Map<String, Object> variables = new HashMap<String, Object>(); + variables.put("isDebugLogEnabled","true"); + variables.put("DeleteAAIVfModuleRequest",request); + runtimeService.startProcessInstanceByKey("DeleteAAIVfModule", variables); + String response = BPMNUtil.getVariable(processEngineRule, "DeleteAAIVfModule", "DAAIVfMod_deleteVfModuleResponseCode"); + String responseCode = BPMNUtil.getVariable(processEngineRule, "DeleteAAIVfModule", "DAAIVfMod_deleteVfModuleResponseCode"); + Assert.assertEquals("200", responseCode); + System.out.println(response); + } + + @Test + @Deployment(resources = { + "subprocess/DeleteAAIVfModule.bpmn" + }) + public void TestQueryGenericVnfFailure_5000() { + // query Generic Vnf failure (non-404) with A&AI + // vnf-id=a27ce5a9-29c4-4c22-a017-6615ac73c723, vf-module-id=973ed047-d251-4fb9-bf1a-65b8949e0a71 + String request = + "<vnf-request xmlns=\"http://openecomp.org/mso/infra/vnf-request/v1\">" + EOL + + " <request-info>" + EOL + + " <action>DELETE_VF_MODULE</action>" + EOL + + " <source>PORTAL</source>" + EOL + + " </request-info>" + EOL + + " <vnf-inputs>" + EOL + + " <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c723</vnf-id>" + EOL + + " <vnf-name>STMTN5MMSC23</vnf-name>" + EOL + + " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a71</vf-module-id>" + EOL + + " <vf-module-name>STMTN5MMSC20-MMSC::module-1-0</vf-module-name>" + EOL + + " </vnf-inputs>" + EOL + + " <vnf-params xmlns:tns=\"http://openecomp.org/mso/infra/vnf-request/v1\"/>" + EOL + + "</vnf-request>" + EOL; + MockAAIGenericVnfSearch(); + MockAAIDeleteGenericVnf(); + MockAAIDeleteVfModule(); + RuntimeService runtimeService = processEngineRule.getRuntimeService(); + Map<String, Object> variables = new HashMap<String, Object>(); + variables.put("isDebugLogEnabled","true"); + variables.put("DeleteAAIVfModuleRequest",request); + runtimeService.startProcessInstanceByKey("DeleteAAIVfModule", variables); + WorkflowException exception = BPMNUtil.getRawVariable(processEngineRule, "DeleteAAIVfModule", "WorkflowException"); + Assert.assertEquals(5000, exception.getErrorCode()); + Assert.assertEquals(true, exception.getErrorMessage().contains("<messageId>SVC3002</messageId>")); + System.out.println(exception.getErrorMessage()); + } + + @Test + @Deployment(resources = { + "subprocess/DeleteAAIVfModule.bpmn" + }) + public void TestQueryGenericVnfFailure_1002() { + // attempt to delete Vf Module for Generic Vnf that does not exist (A&AI returns 404) + // vnf-id=a27ce5a9-29c4-4c22-a017-6615ac73c722, vf-module-id=973ed047-d251-4fb9-bf1a-65b8949e0a72 + String request = + "<vnf-request xmlns=\"http://openecomp.org/mso/infra/vnf-request/v1\">" + EOL + + " <request-info>" + EOL + + " <action>DELETE_VF_MODULE</action>" + EOL + + " <source>PORTAL</source>" + EOL + + " </request-info>" + EOL + + " <vnf-inputs>" + EOL + + " <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c722</vnf-id>" + EOL + + " <vnf-name>STMTN5MMSC22</vnf-name>" + EOL + + " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a72</vf-module-id>" + EOL + + " <vf-module-name>STMTN5MMSC22-MMSC::module-1-0</vf-module-name>" + EOL + + " </vnf-inputs>" + EOL + + " <vnf-params xmlns:tns=\"http://openecomp.org/mso/infra/vnf-request/v1\"/>" + EOL + + "</vnf-request>" + EOL; + MockAAIGenericVnfSearch(); + MockAAIDeleteGenericVnf(); + MockAAIDeleteVfModule(); + RuntimeService runtimeService = processEngineRule.getRuntimeService(); + Map<String, Object> variables = new HashMap<String, Object>(); + variables.put("isDebugLogEnabled","true"); + variables.put("DeleteAAIVfModuleRequest",request); + runtimeService.startProcessInstanceByKey("DeleteAAIVfModule", variables); + WorkflowException exception = BPMNUtil.getRawVariable(processEngineRule, "DeleteAAIVfModule", "WorkflowException"); + Assert.assertEquals(1002, exception.getErrorCode()); + Assert.assertEquals(true, exception.getErrorMessage().contains("Generic VNF Not Found")); + System.out.println(exception.getErrorMessage()); + } + + @Test + @Deployment(resources = { + "subprocess/DeleteAAIVfModule.bpmn" + }) + public void TestDeleteGenericVnfFailure_5000() { + // A&AI failure (non-200) when attempting to delete a Generic Vnf + // vnf-id=a27ce5a9-29c4-4c22-a017-6615ac73c718, vf-module-id=973ed047-d251-4fb9-bf1a-65b8949e0a78 + String request = + "<vnf-request xmlns=\"http://openecomp.org/mso/infra/vnf-request/v1\">" + EOL + + " <request-info>" + EOL + + " <action>DELETE_VF_MODULE</action>" + EOL + + " <source>PORTAL</source>" + EOL + + " </request-info>" + EOL + + " <vnf-inputs>" + EOL + + " <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c718</vnf-id>" + EOL + + " <vnf-name>STMTN5MMSC18</vnf-name>" + EOL + + " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a78</vf-module-id>" + EOL + + " <vf-module-name>STMTN5MMSC18-MMSC::module-0-0</vf-module-name>" + EOL + + " </vnf-inputs>" + EOL + + " <vnf-params xmlns:tns=\"http://openecomp.org/mso/infra/vnf-request/v1\"/>" + EOL + + "</vnf-request>" + EOL; + MockAAIGenericVnfSearch(); + MockAAIDeleteGenericVnf(); + MockAAIDeleteVfModule(); + RuntimeService runtimeService = processEngineRule.getRuntimeService(); + Map<String, Object> variables = new HashMap<String, Object>(); + variables.put("isDebugLogEnabled","true"); + variables.put("DeleteAAIVfModuleRequest",request); + runtimeService.startProcessInstanceByKey("DeleteAAIVfModule", variables); + WorkflowException exception = BPMNUtil.getRawVariable(processEngineRule, "DeleteAAIVfModule", "WorkflowException"); + Assert.assertEquals(5000, exception.getErrorCode()); + Assert.assertEquals(true, exception.getErrorMessage().contains("<messageId>SVC3002</messageId>")); + System.out.println(exception.getErrorMessage()); + } + + @Test + @Deployment(resources = { + "subprocess/DeleteAAIVfModule.bpmn" + }) + public void TestDeleteVfModuleFailure_5000() { + // A&AI failure (non-200) when attempting to delete a Vf Module + // vnf-id=a27ce5a9-29c4-4c22-a017-6615ac73c719, vf-module-id=973ed047-d251-4fb9-bf1a-65b8949e0a77 + String request = + "<vnf-request xmlns=\"http://openecomp.org/mso/infra/vnf-request/v1\">" + EOL + + " <request-info>" + EOL + + " <action>DELETE_VF_MODULE</action>" + EOL + + " <source>PORTAL</source>" + EOL + + " </request-info>" + EOL + + " <vnf-inputs>" + EOL + + " <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c719</vnf-id>" + EOL + + " <vnf-name>STMTN5MMSC19</vnf-name>" + EOL + + " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a77</vf-module-id>" + EOL + + " <vf-module-name>STMTN5MMSC19-MMSC::module-1-0</vf-module-name>" + EOL + + " </vnf-inputs>" + EOL + + " <vnf-params xmlns:tns=\"http://openecomp.org/mso/infra/vnf-request/v1\"/>" + EOL + + "</vnf-request>" + EOL; + MockAAIGenericVnfSearch(); + MockAAIDeleteGenericVnf(); + MockAAIDeleteVfModule(); + RuntimeService runtimeService = processEngineRule.getRuntimeService(); + Map<String, Object> variables = new HashMap<String, Object>(); + variables.put("isDebugLogEnabled","true"); + variables.put("DeleteAAIVfModuleRequest",request); + runtimeService.startProcessInstanceByKey("DeleteAAIVfModule", variables); + WorkflowException exception = BPMNUtil.getRawVariable(processEngineRule, "DeleteAAIVfModule", "WorkflowException"); + Assert.assertEquals(5000, exception.getErrorCode()); + Assert.assertEquals(true, exception.getErrorMessage().contains("<messageId>SVC3002</messageId>")); + System.out.println(exception.getErrorMessage()); + } + + @Test + @Deployment(resources = { + "subprocess/DeleteAAIVfModule.bpmn" + }) + public void TestDeleteVfModuleFailure_1002_1() { + // failure attempting to delete Base Module when not the last Vf Module + // vnf-id=a27ce5a9-29c4-4c22-a017-6615ac73c720, vf-module-id=973ed047-d251-4fb9-bf1a-65b8949e0a74 + String request = + "<vnf-request xmlns=\"http://openecomp.org/mso/infra/vnf-request/v1\">" + EOL + + " <request-info>" + EOL + + " <action>DELETE_VF_MODULE</action>" + EOL + + " <source>PORTAL</source>" + EOL + + " </request-info>" + EOL + + " <vnf-inputs>" + EOL + + " <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c720</vnf-id>" + EOL + + " <vnf-name>STMTN5MMSC20</vnf-name>" + EOL + + " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a74</vf-module-id>" + EOL + + " <vf-module-name>STMTN5MMSC20-MMSC::module-0-0</vf-module-name>" + EOL + + " </vnf-inputs>" + EOL + + " <vnf-params xmlns:tns=\"http://openecomp.org/mso/infra/vnf-request/v1\"/>" + EOL + + "</vnf-request>" + EOL; + MockAAIGenericVnfSearch(); + MockAAIDeleteGenericVnf(); + MockAAIDeleteVfModule(); + RuntimeService runtimeService = processEngineRule.getRuntimeService(); + Map<String, Object> variables = new HashMap<String, Object>(); + variables.put("isDebugLogEnabled","true"); + variables.put("DeleteAAIVfModuleRequest",request); + runtimeService.startProcessInstanceByKey("DeleteAAIVfModule", variables); + WorkflowException exception = BPMNUtil.getRawVariable(processEngineRule, "DeleteAAIVfModule", "WorkflowException"); + Assert.assertEquals(1002, exception.getErrorCode()); + Assert.assertEquals(true, exception.getErrorMessage().contains("is Base Module, not Last Module")); + System.out.println(exception.getErrorMessage()); + } + + @Test + @Deployment(resources = { + "subprocess/DeleteAAIVfModule.bpmn" + }) + public void TestDeleteVfModuleFailure_1002_2() { + // failure attempting to delete a Vf Module that does not exist (A&AI returns 404) + // vnf-id=a27ce5a9-29c4-4c22-a017-6615ac73c720, vf-module-id=973ed047-d251-4fb9-bf1a-65b8949e0a76 + MockAAIGenericVnfSearch(); + MockAAIDeleteGenericVnf(); + MockAAIDeleteVfModule(); + RuntimeService runtimeService = processEngineRule.getRuntimeService(); + Map<String, Object> variables = new HashMap<String, Object>(); + variables.put("isDebugLogEnabled","true"); + variables.put("DeleteAAIVfModuleRequest","<vnf-request xmlns=\"http://openecomp.org/mso/infra/vnf-request/v1\"> <request-info> <action>DELETE_VF_MODULE</action> <source>PORTAL</source> </request-info> <vnf-inputs> <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c720</vnf-id> <vnf-name>STMTN5MMSC20</vnf-name> <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a76</vf-module-id> <vf-module-name>STMTN5MMSC20-MMSC::module-2-0</vf-module-name> </vnf-inputs> <vnf-params xmlns:tns=\"http://openecomp.org/mso/infra/vnf-request/v1\"/> </vnf-request>"); + runtimeService.startProcessInstanceByKey("DeleteAAIVfModule", variables); + WorkflowException exception = BPMNUtil.getRawVariable(processEngineRule, "DeleteAAIVfModule", "WorkflowException"); + Assert.assertEquals(1002, exception.getErrorCode()); + Assert.assertEquals(true, exception.getErrorMessage().contains("does not exist for Generic Vnf Id")); + System.out.println(exception.getErrorMessage()); + } + + // Start of VF Modularization A&AI mocks + + public static void MockAAIGenericVnfSearch(){ + String body; + + // The following stubs are for CreateAAIVfModule and UpdateAAIVfModule + + stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/[?]vnf-name=STMTN5MMSC23&depth=1")) + .willReturn(aResponse() + .withStatus(500) + .withHeader("Content-Type", "text/xml") + .withBodyFile("aaiFault.xml"))); + + stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/[?]vnf-name=STMTN5MMSC22&depth=1")) + .willReturn(aResponse() + .withStatus(404) + .withHeader("Content-Type", "text/xml") + .withBody("Generic VNF Not Found"))); + stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/768073c7-f41f-4822-9323-b75962763d74[?]depth=1")) + .willReturn(aResponse() + .withStatus(404) + .withHeader("Content-Type", "text/xml") + .withBody("Generic VNF Not Found"))); + + body = + "<generic-vnf xmlns=\"http://com.att.aai.inventory/v7\">" + EOL + + " <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c721</vnf-id>" + EOL + + " <vnf-name>STMTN5MMSC21</vnf-name>" + EOL + + " <vnf-type>mmsc-capacity</vnf-type>" + EOL + + " <service-id>SDN-MOBILITY</service-id>" + EOL + + " <equipment-role>vMMSC</equipment-role>" + EOL + + " <orchestration-status>pending-create</orchestration-status>" + EOL + + " <in-maint>false</in-maint>" + EOL + + " <is-closed-loop-disabled>false</is-closed-loop-disabled>" + EOL + + " <resource-version>1508691</resource-version>" + EOL + + " <vf-modules>" + EOL + + " <vf-module>" + EOL + + " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a73</vf-module-id>" + EOL + + " <vf-module-name>STMTN5MMSC21-MMSC::module-0-0</vf-module-name>" + EOL + + " <persona-model-id>973ed047-d251-4fb9-bf1a-65b8949e0a73</persona-model-id>" + EOL + + " <persona-model-version>1.0</persona-model-version>" + EOL + + " <is-base-vf-module>true</is-base-vf-module>" + EOL + + " <heat-stack-id>FILLED-IN-BY-MSO</heat-stack-id>" + EOL + + " <orchestration-status>pending-create</orchestration-status>" + EOL + + " <resource-version>1508692</resource-version>" + EOL + + " </vf-module>" + EOL + + " </vf-modules>" + EOL + + " <relationship-list/>" + EOL + + " <l-interfaces/>" + EOL + + " <lag-interfaces/>" + EOL + + "</generic-vnf>" + EOL; + stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/[?]vnf-name=STMTN5MMSC21&depth=1")) + .willReturn(aResponse() + .withStatus(200) + .withHeader("Content-Type", "text/xml") + .withBody(body))); + stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c721[?]depth=1")) + .willReturn(aResponse() + .withStatus(200) + .withHeader("Content-Type", "text/xml") + .withBody(body))); + + body = + "<generic-vnf xmlns=\"http://com.att.aai.inventory/v7\">" + EOL + + " <vnf-id>2f6aee38-1e2a-11e6-82d1-ffc7d9ee8aa4</vnf-id>" + EOL + + " <vnf-name>STMTN5MMSC20</vnf-name>" + EOL + + " <vnf-type>mmsc-capacity</vnf-type>" + EOL + + " <service-id>SDN-MOBILITY</service-id>" + EOL + + " <equipment-role>vMMSC</equipment-role>" + EOL + + " <orchestration-status>pending-create</orchestration-status>" + EOL + + " <in-maint>false</in-maint>" + EOL + + " <is-closed-loop-disabled>false</is-closed-loop-disabled>" + EOL + + " <resource-version>1508691</resource-version>" + EOL + + " <vf-modules>" + EOL + + " <vf-module>" + EOL + + " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a73</vf-module-id>" + EOL + + " <vf-module-name>STMTN5MMSC20-MMSC::module-0-0</vf-module-name>" + EOL + + " <persona-model-id>973ed047-d251-4fb9-bf1a-65b8949e0a73</persona-model-id>" + EOL + + " <persona-model-version>1.0</persona-model-version>" + EOL + + " <is-base-vf-module>true</is-base-vf-module>" + EOL + + " <heat-stack-id>FILLED-IN-BY-MSO</heat-stack-id>" + EOL + + " <orchestration-status>pending-create</orchestration-status>" + EOL + + " <resource-version>1508692</resource-version>" + EOL + + " </vf-module>" + EOL + + " <vf-module>" + EOL + + " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a74</vf-module-id>" + EOL + + " <vf-module-name>STMTN5MMSC20-MMSC::module-1-0</vf-module-name>" + EOL + + " <persona-model-id>973ed047-d251-4fb9-bf1a-65b8949e0a74</persona-model-id>" + EOL + + " <persona-model-version>1.0</persona-model-version>" + EOL + + " <is-base-vf-module>false</is-base-vf-module>" + EOL + + " <heat-stack-id>FILLED-IN-BY-MSO</heat-stack-id>" + EOL + + " <orchestration-status>pending-create</orchestration-status>" + EOL + + " <resource-version>1508692</resource-version>" + EOL + + " </vf-module>" + EOL + + " </vf-modules>" + EOL + + " <relationship-list/>" + EOL + + " <l-interfaces/>" + EOL + + " <lag-interfaces/>" + EOL + + "</generic-vnf>" + EOL; + stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/[?]vnf-name=STMTN5MMSC20&depth=1")) + .willReturn(aResponse() + .withStatus(200) + .withHeader("Content-Type", "text/xml") + .withBody(body))); + stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/2f6aee38-1e2a-11e6-82d1-ffc7d9ee8aa4[?]depth=1")) + .willReturn(aResponse() + .withStatus(200) + .withHeader("Content-Type", "text/xml") + .withBody(body))); + + // The following stubs are for DeleteAAIVfModule + + stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c723[?]depth=1")) + .willReturn(aResponse() + .withStatus(500) + .withHeader("Content-Type", "text/xml") + .withBodyFile("aaiFault.xml"))); + + stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c722[?]depth=1")) + .willReturn(aResponse() + .withStatus(404) + .withHeader("Content-Type", "text/xml") + .withBody("Generic VNF Not Found"))); + + body = + "<generic-vnf xmlns=\"http://com.att.aai.inventory/v7\">" + EOL + + " <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c721</vnf-id>" + EOL + + " <vnf-name>STMTN5MMSC21</vnf-name>" + EOL + + " <vnf-type>mmsc-capacity</vnf-type>" + EOL + + " <service-id>SDN-MOBILITY</service-id>" + EOL + + " <equipment-role>vMMSC</equipment-role>" + EOL + + " <orchestration-status>pending-create</orchestration-status>" + EOL + + " <in-maint>false</in-maint>" + EOL + + " <is-closed-loop-disabled>false</is-closed-loop-disabled>" + EOL + + " <resource-version>0000021</resource-version>" + EOL + + " <vf-modules>" + EOL + + " <vf-module>" + EOL + + " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a73</vf-module-id>" + EOL + + " <vf-module-name>STMTN5MMSC21-MMSC::module-0-0</vf-module-name>" + EOL + + " <persona-model-id>973ed047-d251-4fb9-bf1a-65b8949e0a73</persona-model-id>" + EOL + + " <persona-model-version>1.0</persona-model-version>" + EOL + + " <is-base-vf-module>true</is-base-vf-module>" + EOL + + " <heat-stack-id>FILLED-IN-BY-MSO</heat-stack-id>" + EOL + + " <orchestration-status>pending-create</orchestration-status>" + EOL + + " <resource-version>0000073</resource-version>" + EOL + + " </vf-module>" + EOL + + " </vf-modules>" + EOL + + " <relationship-list/>" + EOL + + " <l-interfaces/>" + EOL + + " <lag-interfaces/>" + EOL + + "</generic-vnf>" + EOL; + stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c721[?]depth=1")) + .willReturn(aResponse() + .withStatus(200) + .withHeader("Content-Type", "text/xml") + .withBody(body))); + + body = + "<generic-vnf xmlns=\"http://com.att.aai.inventory/v7\">" + EOL + + " <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c720</vnf-id>" + EOL + + " <vnf-name>STMTN5MMSC20</vnf-name>" + EOL + + " <vnf-type>mmsc-capacity</vnf-type>" + EOL + + " <service-id>SDN-MOBILITY</service-id>" + EOL + + " <equipment-role>vMMSC</equipment-role>" + EOL + + " <orchestration-status>pending-create</orchestration-status>" + EOL + + " <in-maint>false</in-maint>" + EOL + + " <is-closed-loop-disabled>false</is-closed-loop-disabled>" + EOL + + " <resource-version>0000020</resource-version>" + EOL + + " <vf-modules>" + EOL + + " <vf-module>" + EOL + + " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a74</vf-module-id>" + EOL + + " <vf-module-name>STMTN5MMSC20-MMSC::module-0-0</vf-module-name>" + EOL + + " <persona-model-id>973ed047-d251-4fb9-bf1a-65b8949e0a74</persona-model-id>" + EOL + + " <persona-model-version>1.0</persona-model-version>" + EOL + + " <is-base-vf-module>true</is-base-vf-module>" + EOL + + " <heat-stack-id>FILLED-IN-BY-MSO</heat-stack-id>" + EOL + + " <orchestration-status>pending-create</orchestration-status>" + EOL + + " <resource-version>0000074</resource-version>" + EOL + + " </vf-module>" + EOL + + " <vf-module>" + EOL + + " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a75</vf-module-id>" + EOL + + " <vf-module-name>STMTN5MMSC20-MMSC::module-1-0</vf-module-name>" + EOL + + " <persona-model-id>973ed047-d251-4fb9-bf1a-65b8949e0a75</persona-model-id>" + EOL + + " <persona-model-version>1.0</persona-model-version>" + EOL + + " <is-base-vf-module>false</is-base-vf-module>" + EOL + + " <heat-stack-id>FILLED-IN-BY-MSO</heat-stack-id>" + EOL + + " <orchestration-status>pending-create</orchestration-status>" + EOL + + " <resource-version>0000075</resource-version>" + EOL + + " </vf-module>" + EOL + + " </vf-modules>" + EOL + + " <relationship-list/>" + EOL + + " <l-interfaces/>" + EOL + + " <lag-interfaces/>" + EOL + + "</generic-vnf>" + EOL; + stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c720[?]depth=1")) + .willReturn(aResponse() + .withStatus(200) + .withHeader("Content-Type", "text/xml") + .withBody(body))); + + body = + "<generic-vnf xmlns=\"http://com.att.aai.inventory/v7\">" + EOL + + " <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c719</vnf-id>" + EOL + + " <vnf-name>STMTN5MMSC19</vnf-name>" + EOL + + " <vnf-type>mmsc-capacity</vnf-type>" + EOL + + " <service-id>SDN-MOBILITY</service-id>" + EOL + + " <equipment-role>vMMSC</equipment-role>" + EOL + + " <orchestration-status>pending-create</orchestration-status>" + EOL + + " <in-maint>false</in-maint>" + EOL + + " <is-closed-loop-disabled>false</is-closed-loop-disabled>" + EOL + + " <resource-version>0000019</resource-version>" + EOL + + " <vf-modules>" + EOL + + " <vf-module>" + EOL + + " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a76</vf-module-id>" + EOL + + " <vf-module-name>STMTN5MMSC19-MMSC::module-0-0</vf-module-name>" + EOL + + " <persona-model-id>973ed047-d251-4fb9-bf1a-65b8949e0a76</persona-model-id>" + EOL + + " <persona-model-version>1.0</persona-model-version>" + EOL + + " <is-base-vf-module>true</is-base-vf-module>" + EOL + + " <heat-stack-id>FILLED-IN-BY-MSO</heat-stack-id>" + EOL + + " <orchestration-status>pending-create</orchestration-status>" + EOL + + " <resource-version>0000076</resource-version>" + EOL + + " </vf-module>" + EOL + + " <vf-module>" + EOL + + " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a77</vf-module-id>" + EOL + + " <vf-module-name>STMTN5MMSC19-MMSC::module-1-0</vf-module-name>" + EOL + + " <persona-model-id>973ed047-d251-4fb9-bf1a-65b8949e0a77</persona-model-id>" + EOL + + " <persona-model-version>1.0</persona-model-version>" + EOL + + " <is-base-vf-module>false</is-base-vf-module>" + EOL + + " <heat-stack-id>FILLED-IN-BY-MSO</heat-stack-id>" + EOL + + " <orchestration-status>pending-create</orchestration-status>" + EOL + + " <resource-version>0000077</resource-version>" + EOL + + " </vf-module>" + EOL + + " </vf-modules>" + EOL + + " <relationship-list/>" + EOL + + " <l-interfaces/>" + EOL + + " <lag-interfaces/>" + EOL + + "</generic-vnf>" + EOL; + stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c719[?]depth=1")) + .willReturn(aResponse() + .withStatus(200) + .withHeader("Content-Type", "text/xml") + .withBody(body))); + + body = + "<generic-vnf xmlns=\"http://com.att.aai.inventory/v7\">" + EOL + + " <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c718</vnf-id>" + EOL + + " <vnf-name>STMTN5MMSC18</vnf-name>" + EOL + + " <vnf-type>mmsc-capacity</vnf-type>" + EOL + + " <service-id>SDN-MOBILITY</service-id>" + EOL + + " <equipment-role>vMMSC</equipment-role>" + EOL + + " <orchestration-status>pending-create</orchestration-status>" + EOL + + " <in-maint>false</in-maint>" + EOL + + " <is-closed-loop-disabled>false</is-closed-loop-disabled>" + EOL + + " <resource-version>0000018</resource-version>" + EOL + + " <vf-modules>" + EOL + + " <vf-module>" + EOL + + " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a78</vf-module-id>" + EOL + + " <vf-module-name>STMTN5MMSC18-MMSC::module-0-0</vf-module-name>" + EOL + + " <persona-model-id>973ed047-d251-4fb9-bf1a-65b8949e0a78</persona-model-id>" + EOL + + " <persona-model-version>1.0</persona-model-version>" + EOL + + " <is-base-vf-module>true</is-base-vf-module>" + EOL + + " <heat-stack-id>FILLED-IN-BY-MSO</heat-stack-id>" + EOL + + " <orchestration-status>pending-create</orchestration-status>" + EOL + + " <resource-version>0000078</resource-version>" + EOL + + " </vf-module>" + EOL + + " </vf-modules>" + EOL + + " <relationship-list/>" + EOL + + " <l-interfaces/>" + EOL + + " <lag-interfaces/>" + EOL + + "</generic-vnf>" + EOL; + stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c718[?]depth=1")) + .willReturn(aResponse() + .withStatus(200) + .withHeader("Content-Type", "text/xml") + .withBody(body))); + + body = + "<generic-vnf xmlns=\"http://com.att.aai.inventory/v7\">" + EOL + + " <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c721</vnf-id>" + EOL + + " <vnf-name>STMTN5MMSC21</vnf-name>" + EOL + + " <vnf-type>mmsc-capacity</vnf-type>" + EOL + + " <service-id>SDN-MOBILITY</service-id>" + EOL + + " <equipment-role>vMMSC</equipment-role>" + EOL + + " <orchestration-status>pending-create</orchestration-status>" + EOL + + " <in-maint>false</in-maint>" + EOL + + " <is-closed-loop-disabled>false</is-closed-loop-disabled>" + EOL + + " <resource-version>0000021</resource-version>" + EOL + + " <vf-modules>" + EOL + + " <vf-module>" + EOL + + " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a73</vf-module-id>" + EOL + + " <vf-module-name>STMTN5MMSC21-MMSC::module-0-0</vf-module-name>" + EOL + + " <persona-model-id>973ed047-d251-4fb9-bf1a-65b8949e0a73</persona-model-id>" + EOL + + " <persona-model-version>1.0</persona-model-version>" + EOL + + " <is-base-vf-module>true</is-base-vf-module>" + EOL + + " <heat-stack-id>FILLED-IN-BY-MSO</heat-stack-id>" + EOL + + " <orchestration-status>pending-create</orchestration-status>" + EOL + + " <resource-version>0000073</resource-version>" + EOL + + " </vf-module>" + EOL + + " </vf-modules>" + EOL + + " <relationship-list/>" + EOL + + " <l-interfaces/>" + EOL + + " <lag-interfaces/>" + EOL + + "</generic-vnf>" + EOL; + stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c721/vf-modules/vf-module/973ed047-d251-4fb9-bf1a-65b8949e0a73")) + .willReturn(aResponse() + .withStatus(200) + .withHeader("Content-Type", "text/xml") + .withBody(body))); + } + public static void MockAAIDeleteGenericVnf(){ + stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c721/[?]resource-version=0000021")) + .willReturn(aResponse() + .withStatus(200))); + stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c718/[?]resource-version=0000018")) + .willReturn(aResponse() + .withStatus(500) + .withHeader("Content-Type", "text/xml") + .withBodyFile("aaiFault.xml"))); + } + + public static void MockAAIDeleteVfModule(){ + stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c721/vf-modules/vf-module/973ed047-d251-4fb9-bf1a-65b8949e0a73/[?]resource-version=0000073")) + .willReturn(aResponse() + .withStatus(200))); + stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c720/vf-modules/vf-module/973ed047-d251-4fb9-bf1a-65b8949e0a75/[?]resource-version=0000075")) + .willReturn(aResponse() + .withStatus(200))); + stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c718/vf-modules/vf-module/973ed047-d251-4fb9-bf1a-65b8949e0a78/[?]resource-version=0000078")) + .willReturn(aResponse() + .withStatus(200))); + stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c719/vf-modules/vf-module/973ed047-d251-4fb9-bf1a-65b8949e0a77/[?]resource-version=0000077")) + .willReturn(aResponse() + .withStatus(500) + .withHeader("Content-Type", "text/xml") + .withBodyFile("aaiFault.xml"))); + stubFor(get(urlMatching("/aai/v[0-9]+/network/network-policies/network-policy\\?network-policy-fqdn=.*")) + .willReturn(aResponse() + .withStatus(200) + .withHeader("Content-Type", "text/xml") + .withBodyFile("VfModularity/QueryNetworkPolicy_AAIResponse_Success.xml"))); + + stubFor(delete(urlMatching("/aai/v[0-9]+/network/network-policies/network-policy/.*")) + .willReturn(aResponse() + .withStatus(200))); + } +} + diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/FalloutHandlerTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/FalloutHandlerTest.java new file mode 100644 index 0000000000..77320751ee --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/FalloutHandlerTest.java @@ -0,0 +1,226 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common; + +import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; +import static com.github.tomakehurst.wiremock.client.WireMock.post; +import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; +import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; +import static org.openecomp.mso.bpmn.common.BPMNUtil.executeWorkFlow; +import static org.openecomp.mso.bpmn.common.BPMNUtil.waitForWorkflowToFinish; + +import java.util.HashMap; +import java.util.Map; + +import org.camunda.bpm.engine.test.Deployment; +import org.junit.Assert; +import org.junit.Test; +import org.openecomp.mso.bpmn.common.workflow.service.WorkflowResponse; + +/** + * Unit test for FalloutHandler.bpmn. + */ +public class FalloutHandlerTest extends WorkflowTest { + private void setupMocks() { + stubFor(post(urlEqualTo("/dbadapters/RequestsDbAdapter")) + .willReturn(aResponse() + .withStatus(200) + .withHeader("Content-Type", "text/xml") + .withBody("<DbTag>Notified</DbTag>"))); + } + + private void executeFlow(String inputRequestFile) throws InterruptedException { + String method = getClass().getSimpleName() + "." + new Object() { + }.getClass().getEnclosingMethod().getName(); + System.out.println("STARTED TEST: " + method); + + //String changeFeatureActivateRequest = FileUtil.readResourceFile("__files/SDN-ETHERNET-INTERNET/ChangeFeatureActivateV1/" + inputRequestFile); + Map<String, String> variables = new HashMap<String, String>(); + variables.put("FalloutHandlerRequest",inputRequestFile); + + WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "FalloutHandler", variables); + waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + System.out.println("ENDED TEST: " + method); + } + + @Test + @Deployment(resources = {"subprocess/FalloutHandler.bpmn"}) + public void msoFalloutHandlerWithNotificationurl_200() throws Exception{ + String method = getClass().getSimpleName() + "." + new Object() { + }.getClass().getEnclosingMethod().getName(); + System.out.println("STARTED TEST: " + method); + + //Setup Mocks + setupMocks(); + //Execute Flow + executeFlow(gMsoFalloutHandlerWithNotificationurl()); + //Verify Error + String FH_ResponseCode = BPMNUtil.getVariable(processEngineRule, "FalloutHandler", "FH_ResponseCode"); + Assert.assertEquals("200", FH_ResponseCode); + Assert.assertTrue((boolean) BPMNUtil.getRawVariable(processEngineRule, "FalloutHandler", "FH_SuccessIndicator")); + } + + public String gMsoFalloutHandlerWithNotificationurl() { + //Generated the below XML from ActiveVOS moduler ... Using the generate sample XML feature in ActiveVOS + String xml = "" + + "<sdncadapterworkflow:FalloutHandlerRequest xmlns:sdncadapterworkflow=\"http://org.openecomp/mso/workflow/schema/v1\" xmlns:ns7=\"http://org.openecomp/mso/request/types/v1\">" + + " <ns7:request-information>" + + " <ns7:request-id>uCPE1020_STUW105_5002</ns7:request-id>" + + " <ns7:request-action>Layer3ServiceActivateRequest</ns7:request-action>" + + " <ns7:request-sub-action>CANCEL</ns7:request-sub-action>" + + " <ns7:source>OMX</ns7:source>" + + " <ns7:notification-url>http://localhost:28090/CCD/StatusNotification</ns7:notification-url>" + + " <ns7:order-number>10205000</ns7:order-number>" + + " <ns7:order-version>1</ns7:order-version>" + + " </ns7:request-information>" + + " <sdncadapterworkflow:WorkflowException>" + + " <sdncadapterworkflow:ErrorMessage>Some Error Message - Fallout Handler</sdncadapterworkflow:ErrorMessage>" + + " <sdncadapterworkflow:ErrorCode>Some Error Code - Fallout Handler</sdncadapterworkflow:ErrorCode>" + + " <sdncadapterworkflow:SourceSystemErrorCode>Some Source System Error Code- Fallout Handler</sdncadapterworkflow:SourceSystemErrorCode>" + + " </sdncadapterworkflow:WorkflowException>" + + "</sdncadapterworkflow:FalloutHandlerRequest>"; + + return xml; + + } + + + + + @Test + @Deployment(resources = {"subprocess/FalloutHandler.bpmn"}) + public void msoFalloutHandlerWithNoNotificationurl() throws Exception{ + String method = getClass().getSimpleName() + "." + new Object() { + }.getClass().getEnclosingMethod().getName(); + System.out.println("STARTED TEST: " + method); + //Setup Mocks + setupMocks(); + //Execute Flow + executeFlow(gMsoFalloutHandlerWithNoNotificationurl()); + //Verify Error + String FH_ResponseCode = BPMNUtil.getVariable(processEngineRule, "FalloutHandler", "FH_ResponseCode"); + Assert.assertEquals("200", FH_ResponseCode); + Assert.assertTrue((boolean) BPMNUtil.getRawVariable(processEngineRule, "FalloutHandler", "FH_SuccessIndicator")); + } + + public String gMsoFalloutHandlerWithNoNotificationurl() { + //Generated the below XML from ActiveVOS moduler ... Using the generate sample XML feature in ActiveVOS + String xml = "" + + "<sdncadapterworkflow:FalloutHandlerRequest xmlns:sdncadapterworkflow=\"http://org.openecomp/mso/workflow/schema/v1\" xmlns:ns7=\"http://org.openecomp/mso/request/types/v1\">" + + " <ns7:request-information>" + + " <ns7:request-id>uCPE1020_STUW105_5002</ns7:request-id>" + + " <ns7:request-action>Layer3ServiceActivateRequest</ns7:request-action>" + + " <ns7:request-sub-action>CANCEL</ns7:request-sub-action>" + + " <ns7:source>OMX</ns7:source>" + + " <ns7:notification-url></ns7:notification-url>" + + " <ns7:order-number>10205000</ns7:order-number>" + + " <ns7:order-version>1</ns7:order-version>" + + " </ns7:request-information>" + + " <sdncadapterworkflow:WorkflowException>" + + " <sdncadapterworkflow:ErrorMessage>Some Error Message - Fallout Handler</sdncadapterworkflow:ErrorMessage>" + + " <sdncadapterworkflow:ErrorCode>Some Error Code - Fallout Handler</sdncadapterworkflow:ErrorCode>" + + " <sdncadapterworkflow:SourceSystemErrorCode>Some Source System Error Code- Fallout Handler</sdncadapterworkflow:SourceSystemErrorCode>" + + " </sdncadapterworkflow:WorkflowException>" + + "</sdncadapterworkflow:FalloutHandlerRequest>"; + + return xml; + } + + @Test + @Deployment(resources = {"subprocess/FalloutHandler.bpmn"}) + public void msoFalloutHandlerWithNotificationurlNoRequestId() throws Exception{ + String method = getClass().getSimpleName() + "." + new Object() { + }.getClass().getEnclosingMethod().getName(); + System.out.println("STARTED TEST: " + method); + //Setup Mocks + setupMocks(); + //Execute Flow + executeFlow(gMsoFalloutHandlerWithNotificationurlNoRequestId()); + //Verify Error + String FH_ResponseCode = BPMNUtil.getVariable(processEngineRule, "FalloutHandler", "FH_ResponseCode"); + Assert.assertEquals("200", FH_ResponseCode); + Assert.assertTrue((boolean) BPMNUtil.getRawVariable(processEngineRule, "FalloutHandler", "FH_SuccessIndicator")); + } + + public String gMsoFalloutHandlerWithNotificationurlNoRequestId() { + //Generated the below XML from ActiveVOS moduler ... Using the generate sample XML feature in ActiveVOS + String xml = "" + + "<sdncadapterworkflow:FalloutHandlerRequest xmlns:sdncadapterworkflow=\"http://org.openecomp/mso/workflow/schema/v1\" xmlns:ns7=\"http://org.openecomp/mso/request/types/v1\">" + + " <ns7:request-information>" + + " <ns7:request-id></ns7:request-id>" + + " <ns7:request-action>Layer3ServiceActivateRequest</ns7:request-action>" + + " <ns7:request-sub-action>CANCEL</ns7:request-sub-action>" + + " <ns7:source>OMX</ns7:source>" + + " <ns7:notification-url>www.att.com</ns7:notification-url>" + + " <ns7:order-number>10205000</ns7:order-number>" + + " <ns7:order-version>1</ns7:order-version>" + + " </ns7:request-information>" + + " <sdncadapterworkflow:WorkflowException>" + + " <sdncadapterworkflow:ErrorMessage>Some Error Message - Fallout Handler</sdncadapterworkflow:ErrorMessage>" + + " <sdncadapterworkflow:ErrorCode>Some Error Code - Fallout Handler</sdncadapterworkflow:ErrorCode>" + + " <sdncadapterworkflow:SourceSystemErrorCode>Some Source System Error Code- Fallout Handler</sdncadapterworkflow:SourceSystemErrorCode>" + + " </sdncadapterworkflow:WorkflowException>" + + "</sdncadapterworkflow:FalloutHandlerRequest>"; + + return xml; + } + + @Test + @Deployment(resources = {"subprocess/FalloutHandler.bpmn"}) + public void msoFalloutHandlerWithNoNotificationurlNoRequestId() throws Exception{ + String method = getClass().getSimpleName() + "." + new Object() { + }.getClass().getEnclosingMethod().getName(); + System.out.println("STARTED TEST: " + method); + //Setup Mocks + setupMocks(); + //Execute Flow + executeFlow(gMsoFalloutHandlerWithNoNotificationurlNoRequestId()); + //Verify Error + String FH_ResponseCode = BPMNUtil.getVariable(processEngineRule, "FalloutHandler", "FH_ResponseCode"); + Assert.assertEquals("200", FH_ResponseCode); + Assert.assertTrue((boolean) BPMNUtil.getRawVariable(processEngineRule, "FalloutHandler", "FH_SuccessIndicator")); + } + + public String gMsoFalloutHandlerWithNoNotificationurlNoRequestId() { + //Generated the below XML from ActiveVOS moduler ... Using the generate sample XML feature in ActiveVOS + String xml = "" + + "<sdncadapterworkflow:FalloutHandlerRequest xmlns:sdncadapterworkflow=\"http://org.openecomp/mso/workflow/schema/v1\" xmlns:ns7=\"http://org.openecomp/mso/request/types/v1\">" + + " <ns7:request-information>" + + " <ns7:request-id></ns7:request-id>" + + " <ns7:request-action>Layer3ServiceActivateRequest</ns7:request-action>" + + " <ns7:request-sub-action>CANCEL</ns7:request-sub-action>" + + " <ns7:source>OMX</ns7:source>" + + " <ns7:notification-url></ns7:notification-url>" + + " <ns7:order-number>10205000</ns7:order-number>" + + " <ns7:order-version>1</ns7:order-version>" + + " </ns7:request-information>" + + " <sdncadapterworkflow:WorkflowException>" + + " <sdncadapterworkflow:ErrorMessage>Some Error Message - Fallout Handler</sdncadapterworkflow:ErrorMessage>" + + " <sdncadapterworkflow:ErrorCode>Some Error Code - Fallout Handler</sdncadapterworkflow:ErrorCode>" + + " <sdncadapterworkflow:SourceSystemErrorCode>Some Source System Error Code- Fallout Handler</sdncadapterworkflow:SourceSystemErrorCode>" + + " </sdncadapterworkflow:WorkflowException>" + + "</sdncadapterworkflow:FalloutHandlerRequest>"; + + return xml; + } + +} + diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/GenericDeleteServiceTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/GenericDeleteServiceTest.java new file mode 100644 index 0000000000..e83a644914 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/GenericDeleteServiceTest.java @@ -0,0 +1,279 @@ +/* + * © 2014 AT&T Intellectual Property. All rights reserved. Used under license from AT&T Intellectual Property. + */ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common; + +import static org.junit.Assert.assertEquals; +import static org.openecomp.mso.bpmn.common.BPMNUtil.executeWorkFlow; +import static org.openecomp.mso.bpmn.common.BPMNUtil.waitForWorkflowToFinish; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockDeleteServiceInstance; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockDeleteServiceInstance_404; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetServiceInstance; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetServiceInstance_404; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetServiceInstance_500; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetServiceSubscription; + +import java.util.HashMap; +import java.util.Map; + +import org.camunda.bpm.engine.test.Deployment; +import org.junit.Test; +import org.openecomp.mso.bpmn.common.workflow.service.WorkflowResponse; + + + +/** + * Please describe the GenericDeleteServiceTest.java class + * + */ +public class GenericDeleteServiceTest extends WorkflowTest { + @Test + @Deployment(resources = {"subprocess/GenericDeleteService.bpmn"}) + public void testGenericDeleteService_success_serviceInstance() throws Exception{ + MockDeleteServiceInstance("1604-MVM-26", "SDN-ETHERNET-INTERNET", "MIS%252F1604%252F0026%252FSW_INTERNET", "1234"); + Map<String, String> variables = new HashMap<String, String>(); + setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", "1604-MVM-26", "SDN-ETHERNET-INTERNET", "1234"); + WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericDeleteService", variables); + waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "GENDS_SuccessIndicator"); + String foundIndicator = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "GENDS_FoundIndicator"); + String resourceVersionProvidedFlag = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "GENDS_resourceVersionProvidedFlag"); + String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "WorkflowException"); + assertEquals("true", foundIndicator); + assertEquals("true", successIndicator); + assertEquals("true", resourceVersionProvidedFlag); + assertEquals(null, workflowException); + } + @Test + @Deployment(resources = {"subprocess/GenericDeleteService.bpmn"}) + public void testGenericDeleteService_success_serviceSubscription() throws Exception{ + + MockDeleteServiceInstance("1604-MVM-26", "SDN-ETHERNET-INTERNET", "1234", 204); + + Map<String, String> variables = new HashMap<String, String>(); + setVariablesSubscription(variables, "", "1604-MVM-26", "SDN-ETHERNET-INTERNET", "1234"); + + WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericDeleteService", variables); + waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "GENDS_SuccessIndicator"); + String foundIndicator = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "GENDS_FoundIndicator"); + String resourceVersionProvidedFlag = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "GENDS_resourceVersionProvidedFlag"); + String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "WorkflowException"); + + assertEquals("true", foundIndicator); + assertEquals("true", successIndicator); + assertEquals("true", resourceVersionProvidedFlag); + assertEquals(null, workflowException); + + } + + @Test + @Deployment(resources = {"subprocess/GenericDeleteService.bpmn"}) + public void testGenericDeleteService_success_instanceNoResourceVersion() throws Exception { + MockGetServiceInstance("1604-MVM-26", "SDN-ETHERNET-INTERNET", "MIS%252F1604%252F0026%252FSW_INTERNET", "GenericFlows/getServiceSubscription.xml"); + MockDeleteServiceInstance("1604-MVM-26", "SDN-ETHERNET-INTERNET", "MIS%252F1604%252F0026%252FSW_INTERNET", "1234"); + + Map<String, String> variables = new HashMap<String, String>(); + setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", "1604-MVM-26", "SDN-ETHERNET-INTERNET", null); + + WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericDeleteService", variables); + waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "GENDS_SuccessIndicator"); + String foundIndicator = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "GENDS_FoundIndicator"); + String resourceVersionProvidedFlag = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "GENDS_resourceVersionProvidedFlag"); + String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "WorkflowException"); + + assertEquals("true", foundIndicator); + assertEquals("true", successIndicator); + assertEquals("false", resourceVersionProvidedFlag); + assertEquals(null, workflowException); + + } + + @Test + @Deployment(resources = {"subprocess/GenericDeleteService.bpmn"}) + public void testGenericDeleteService_success_subscriptionNoResourceVersion() throws Exception{ + MockGetServiceSubscription("1604-MVM-26", "SDN-ETHERNET-INTERNET", "GenericFlows/getServiceSubscription.xml"); + MockDeleteServiceInstance("1604-MVM-26", "SDN-ETHERNET-INTERNET", "1234", 204); + + Map<String, String> variables = new HashMap<String, String>(); + setVariablesSubscription(variables, null, "1604-MVM-26", "SDN-ETHERNET-INTERNET", null); + + WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericDeleteService", variables); + waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "GENDS_SuccessIndicator"); + String foundIndicator = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "GENDS_FoundIndicator"); + String resourceVersionProvidedFlag = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "GENDS_resourceVersionProvidedFlag"); + String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "WorkflowException"); + + assertEquals("true", foundIndicator); + assertEquals("true", successIndicator); + assertEquals("false", resourceVersionProvidedFlag); + assertEquals(null, workflowException); + + } + + @Test + @Deployment(resources = {"subprocess/GenericDeleteService.bpmn"}) + public void testGenericDeleteService_success_get404Response() throws Exception{ + + MockGetServiceInstance_404("1604-MVM-26", "SDN-ETHERNET-INTERNET", "MIS%252F1604%252F0026%252FSW_INTERNET"); + + Map<String, String> variables = new HashMap<String, String>(); + setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", "1604-MVM-26", "SDN-ETHERNET-INTERNET", null); + + WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericDeleteService", variables); + waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "GENDS_SuccessIndicator"); + String foundIndicator = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "GENDS_FoundIndicator"); + String resourceVersionProvidedFlag = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "GENDS_resourceVersionProvidedFlag"); + String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "WorkflowException"); + + assertEquals("false", foundIndicator); + assertEquals("true", successIndicator); + assertEquals("false", resourceVersionProvidedFlag); + assertEquals(null, workflowException); + } + + @Test + @Deployment(resources = {"subprocess/GenericDeleteService.bpmn"}) + public void testGenericDeleteService_success_subscriptionGetEmpty200() throws Exception{ + MockGetServiceInstance("1604-MVM-26", "SDN-ETHERNET-INTERNET", "1234", 200); + + Map<String, String> variables = new HashMap<String, String>(); + setVariablesSubscription(variables, "", "1604-MVM-26", "SDN-ETHERNET-INTERNET", ""); + + WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericDeleteService", variables); + waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "GENDS_SuccessIndicator"); + String foundIndicator = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "GENDS_FoundIndicator"); + String resourceVersionProvidedFlag = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "GENDS_resourceVersionProvidedFlag"); + String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "WorkflowException"); + + assertEquals("false", foundIndicator); + assertEquals("true", successIndicator); + assertEquals("false", resourceVersionProvidedFlag); + assertEquals(null, workflowException); + + } + + @Test + @Deployment(resources = {"subprocess/GenericDeleteService.bpmn"}) + public void testGenericDeleteService_success_delete404Response() throws Exception{ + + MockGetServiceInstance("1604-MVM-26", "SDN-ETHERNET-INTERNET", "MIS%252F1604%252F0026%252FSW_INTERNET", "GENDSI_getServiceInstanceResponse.xml"); + MockDeleteServiceInstance_404("1604-MVM-26", "SDN-ETHERNET-INTERNET", "MIS%252F1604%252F0026%252FSW_INTERNET", "1234"); + + Map<String, String> variables = new HashMap<String, String>(); + setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", "1604-MVM-26", "SDN-ETHERNET-INTERNET", "1234"); + + WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericDeleteService", variables); + waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "GENDS_SuccessIndicator"); + String foundIndicator = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "GENDS_FoundIndicator"); + String resourceVersionProvidedFlag = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "GENDS_resourceVersionProvidedFlag"); + String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "WorkflowException"); + + assertEquals("false", foundIndicator); + assertEquals("true", successIndicator); + assertEquals("true", resourceVersionProvidedFlag); + assertEquals(null, workflowException); + } + + @Test + @Deployment(resources = {"subprocess/GenericDeleteService.bpmn"}) + public void testGenericDeleteService_error_invalidVariables() throws Exception{ + + Map<String, String> variables = new HashMap<String, String>(); + setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", null, "SDN-ETHERNET-INTERNET", "1234"); + + WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericDeleteService", variables); + waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "GENDS_SuccessIndicator"); + String foundIndicator = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "GENDS_FoundIndicator"); + String resourceVersionProvidedFlag = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "GENDS_resourceVersionProvidedFlag"); + String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "WorkflowException"); + + String expectedResponse = "WorkflowException[processKey=GenericDeleteService,errorCode=500,errorMessage=Incoming Required Variable is Missing or Null!]"; + + assertEquals("false", foundIndicator); + assertEquals("false", successIndicator); + assertEquals("true", resourceVersionProvidedFlag); + assertEquals(expectedResponse, workflowException); + + } + + @Test + @Deployment(resources = {"subprocess/GenericDeleteService.bpmn"}) + public void testGenericDeleteService_error_getBadAAIResponse() throws Exception{ + + MockGetServiceInstance_500("1604-MVM-26", "SDN-ETHERNET-INTERNET", "MIS%252F1604%252F0026%252FSW_INTERNET", "aaiFault.xml"); + + Map<String, String> variables = new HashMap<String, String>(); + setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", "1604-MVM-26", "SDN-ETHERNET-INTERNET", null); + + WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericDeleteService", variables); + waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "GENDS_SuccessIndicator"); + String foundIndicator = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "GENDS_FoundIndicator"); + String resourceVersionProvidedFlag = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "GENDS_resourceVersionProvidedFlag"); + String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "WorkflowException"); + + String expectedResponse = "WorkflowException[processKey=GenericDeleteService,errorCode=500,errorMessage=<requestError><serviceException><messageId>SVC3002</messageId><text>Error writing output performing %1 on %2 (msg=%3) (ec=%4)</text><variables><variable>PUTcustomer</variable><variable>SubName01</variable><variable>Unexpected error reading/updating database:Adding this property for key [service-instance-id] and value [USSTU2CFCNC0101UJZZ01] violates a uniqueness constraint [service-instance-id]</variable><variable>ERR.5.4.5105</variable></variables></serviceException></requestError>" + "\n" + + "]"; + + assertEquals("false", foundIndicator); + assertEquals("false", successIndicator); + assertEquals("false", resourceVersionProvidedFlag); + assertEquals(expectedResponse, workflowException); + } + + + private void setVariablesInstance(Map<String, String> variables, String siId, String globalCustId, String serviceType, String reVersion) { + variables.put("isDebugLogEnabled", "true"); + variables.put("GENDS_serviceInstanceId", siId); + variables.put("GENDS_globalCustomerId",globalCustId); + variables.put("GENDS_serviceType", serviceType); + variables.put("GENDS_resourceVersion", reVersion); + variables.put("GENDS_type", "service-instance"); + } + + private void setVariablesSubscription(Map<String, String> variables, String siId, String globalCustId, String serviceType, String reVersion) { + variables.put("isDebugLogEnabled", "true"); + variables.put("GENDS_serviceInstanceId", siId); + variables.put("GENDS_globalCustomerId",globalCustId); + variables.put("GENDS_serviceType", serviceType); + variables.put("GENDS_resourceVersion", reVersion); + variables.put("GENDS_type", "service-subscription"); + } + + +} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/GenericDeleteVnfTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/GenericDeleteVnfTest.java new file mode 100644 index 0000000000..dd3fd73afe --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/GenericDeleteVnfTest.java @@ -0,0 +1,221 @@ +/* + * © 2014 AT&T Intellectual Property. All rights reserved. Used under license from AT&T Intellectual Property. + */ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common; + +import static org.junit.Assert.assertEquals; +import static org.openecomp.mso.bpmn.common.BPMNUtil.executeWorkFlow; +import static org.openecomp.mso.bpmn.common.BPMNUtil.waitForWorkflowToFinish; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockDeleteGenericVnf; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockDeleteGenericVnf_500; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockDeleteVce; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfById; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfById_404; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetVceById; + +import java.util.HashMap; +import java.util.Map; + +import org.camunda.bpm.engine.test.Deployment; +import org.junit.Test; +import org.openecomp.mso.bpmn.common.workflow.service.WorkflowResponse; + +/** + * Please describe the GenericDeleteVnfTest.java class + * + */ +public class GenericDeleteVnfTest extends WorkflowTest { + + @Test + @Deployment(resources = {"subprocess/GenericDeleteVnf.bpmn"}) + public void testGenericDeleteVnf_success_genericVnf() throws Exception{ + MockDeleteGenericVnf("testVnfId123", "testReVer123"); + + Map<String, String> variables = new HashMap<String, String>(); + setVariables(variables, "testVnfId123", "generic-vnf", "testReVer123"); + + WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericDeleteVnf", variables); + waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + assertVariables("true", "true", "true", null); + + } + + @Test + @Deployment(resources = {"subprocess/GenericDeleteVnf.bpmn"}) + public void testGenericDeleteVnf_success_vce() throws Exception{ + MockDeleteVce("testVnfId123", "testReVer123", 204); + + Map<String, String> variables = new HashMap<String, String>(); + setVariables(variables, "testVnfId123", "vce", "testReVer123"); + + WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericDeleteVnf", variables); + waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + assertVariables("true", "true", "true", null); + + } + + @Test + @Deployment(resources = {"subprocess/GenericDeleteVnf.bpmn"}) + public void testGenericDeleteVnf_success_genericVnfNoResourceVersion() throws Exception{ + + MockGetGenericVnfById("/testVnfId123", "GenericFlows/getGenericVnfByNameResponse.xml", 200); + MockDeleteGenericVnf("testVnfId123", "testReVer123"); + + Map<String, String> variables = new HashMap<String, String>(); + setVariables(variables, "testVnfId123", "generic-vnf", ""); + + WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericDeleteVnf", variables); + waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + assertVariables("true", "true", "false", null); + + } + + @Test + @Deployment(resources = {"subprocess/GenericDeleteVnf.bpmn"}) + public void testGenericDeleteVnf_success_vceNoResourceVersion() throws Exception{ + MockDeleteVce("testVnfId123", "testReVer123", 204); + MockGetVceById("testVnfId123", "GenericFlows/getVceResponse.xml"); + + Map<String, String> variables = new HashMap<String, String>(); + setVariables(variables, "testVnfId123", "vce", null); + + WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericDeleteVnf", variables); + waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + assertVariables("true", "true", "false", null); + + } + + @Test + @Deployment(resources = {"subprocess/GenericDeleteVnf.bpmn"}) + public void testGenericDeleteVnf_success_genericVnf404() throws Exception{ + MockDeleteGenericVnf("testVnfId123", "testReVer123", 404); + + Map<String, String> variables = new HashMap<String, String>(); + setVariables(variables, "testVnfId123", "generic-vnf", "testReVer123"); + + WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericDeleteVnf", variables); + waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + assertVariables("true", "false", "true", null); + + } + + @Test + @Deployment(resources = {"subprocess/GenericDeleteVnf.bpmn"}) + public void testGenericDeleteVnf_success_vce404() throws Exception{ + MockDeleteVce("testVnfId123", "testReVer123", 404); + + Map<String, String> variables = new HashMap<String, String>(); + setVariables(variables, "testVnfId123", "vce", "testReVer123"); + + WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericDeleteVnf", variables); + waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + assertVariables("true", "false", "true", null); + + } + + @Test + @Deployment(resources = {"subprocess/GenericDeleteVnf.bpmn"}) + public void testGenericDeleteVnf_success_genericVnfNoResourceVersion404() throws Exception{ + MockGetGenericVnfById_404("testVnfId123"); + + Map<String, String> variables = new HashMap<String, String>(); + setVariables(variables, "testVnfId123", "generic-vnf", ""); + + WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericDeleteVnf", variables); + waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + assertVariables("true", "false", "false", null); + + } + + @Test + @Deployment(resources = {"subprocess/GenericDeleteVnf.bpmn"}) + public void testGenericDeleteVnf_error_missingVariables() throws Exception{ + + Map<String, String> variables = new HashMap<String, String>(); + setVariables(variables, "testVnfId123", "", "testReVer123"); + + WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericDeleteVnf", variables); + waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + assertVariables("false", "false", "true", "WorkflowException[processKey=GenericDeleteVnf,errorCode=500,errorMessage=Incoming Required Variable is Missing or Null!]"); + + } + + @Test + @Deployment(resources = {"subprocess/GenericDeleteVnf.bpmn"}) + public void testGenericDeleteVnf_error_genericVnf500() throws Exception{ + + MockDeleteGenericVnf_500("testVnfId123", "testReVer123"); + Map<String, String> variables = new HashMap<String, String>(); + setVariables(variables, "testVnfId123", "generic-vnf", "testReVer123"); + + WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericDeleteVnf", variables); + waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + assertVariables("false", "false", "true", "WorkflowException[processKey=GenericDeleteVnf,errorCode=500,errorMessage=Received a bad response from AAI]"); + + } + + @Test + @Deployment(resources = {"subprocess/GenericDeleteVnf.bpmn"}) + public void testGenericDeleteVnf_error_genericVnf412() throws Exception{ + MockDeleteGenericVnf("testVnfId123", "testReVer123", 412); + + Map<String, String> variables = new HashMap<String, String>(); + setVariables(variables, "testVnfId123", "generic-vnf", "testReVer123"); + + WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericDeleteVnf", variables); + waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + assertVariables("false", "false", "true", "WorkflowException[processKey=GenericDeleteVnf,errorCode=412,errorMessage=Delete Vnf Received a resource-version Mismatch Error Response from AAI]"); + + } + + private void assertVariables(String exSuccessIndicator, String exFound, String exRVProvided, String exWorkflowException) { + + String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericDeleteVnf", "GENDV_SuccessIndicator"); + String found = BPMNUtil.getVariable(processEngineRule, "GenericDeleteVnf", "GENDV_FoundIndicator"); + String rvProvided = BPMNUtil.getVariable(processEngineRule, "GenericDeleteVnf", "GENDV_resourceVersionProvided"); + String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericDeleteVnf", "WorkflowException"); + + assertEquals(exSuccessIndicator, successIndicator); + assertEquals(exFound, found); + assertEquals(exRVProvided, rvProvided); + assertEquals(exWorkflowException, workflowException); + } + + private void setVariables(Map<String, String> variables, String vnfId, String type, String resourceVer) { + variables.put("isDebugLogEnabled", "true"); + variables.put("GENDV_vnfId", vnfId); + variables.put("GENDV_type", type); + variables.put("GENDV_resourceVersion", resourceVer); + } + +} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/GenericGetServiceTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/GenericGetServiceTest.java new file mode 100644 index 0000000000..2af42db574 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/GenericGetServiceTest.java @@ -0,0 +1,505 @@ +/* + * © 2014 AT&T Intellectual Property. All rights reserved. Used under license from AT&T Intellectual Property. + */ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.openecomp.mso.bpmn.common.BPMNUtil.executeWorkFlow; +import static org.openecomp.mso.bpmn.common.BPMNUtil.waitForWorkflowToFinish; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetServiceInstance; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetServiceInstance_404; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetServiceInstance_500; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetServiceSubscription; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockNodeQueryServiceInstanceById; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockNodeQueryServiceInstanceById_404; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockNodeQueryServiceInstanceById_500; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockNodeQueryServiceInstanceByName; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockNodeQueryServiceInstanceByName_404; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockNodeQueryServiceInstanceByName_500; + +import java.util.HashMap; +import java.util.Map; + +import org.camunda.bpm.engine.test.Deployment; +import org.junit.Test; +import org.openecomp.mso.bpmn.common.workflow.service.WorkflowResponse; + + +/** + * Unit Test for the GenericGetService Sub Flow + */ +public class GenericGetServiceTest extends WorkflowTest { + + + @Test + @Deployment(resources = {"subprocess/GenericGetService.bpmn"}) + public void testGenericGetService_success_serviceInstance() throws Exception{ + MockGetServiceInstance("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0026%252FSW_INTERNET", "GenericFlows/getServiceInstance.xml"); + Map<String, String> variables = new HashMap<String, String>(); + setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", null, "SDN-ETHERNET-INTERNET", "123456789"); + WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables); + waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator"); + String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator"); + String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrl"); + String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName"); + String response = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowResponse"); + String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException"); + assertEquals("true", successIndicator); + assertEquals("true", found); + assertEquals("false", obtainUrl); + assertEquals("false", byName); + assertNotNull(response); + assertEquals(null, workflowException); + } + + + @Test + @Deployment(resources = {"subprocess/GenericGetService.bpmn"}) + public void testGenericGetService_success_serviceSubscription() throws Exception{ + + MockGetServiceSubscription("1604-MVM-26", "SDN-ETHERNET-INTERNET", "GenericFlows/getServiceSubscription.xml"); + + Map<String, String> variables = new HashMap<String, String>(); + setVariablesSubscription(variables, "", null , "1604-MVM-26", "SDN-ETHERNET-INTERNET"); + + WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables); + waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator"); + String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator"); + String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrl"); + String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName"); + String response = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowResponse"); + String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException"); + + assertEquals("true", successIndicator); + assertEquals("true", found); + assertEquals("false", obtainUrl); + assertEquals("false", byName); + assertNotNull(response); + assertEquals(null, workflowException); + } + + @Test + @Deployment(resources = {"subprocess/GenericGetService.bpmn"}) + public void testGenericGetService_success_serviceInstance_byName() throws Exception{ + + MockNodeQueryServiceInstanceByName("1604-MVM-26", "GenericFlows/getSIUrlByName.xml"); + MockGetServiceInstance("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0026%252FSW_INTERNET", "GenericFlows/getServiceInstance.xml"); + + Map<String, String> variables = new HashMap<String, String>(); + setVariablesInstance(variables, null, "1604-MVM-26", null, null); + + WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables); + waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator"); + String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator"); + String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrl"); + String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName"); + String response = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowResponse"); + String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException"); + String siUrlResponseCode = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainSIUrlResponseCode"); + + assertEquals("true", successIndicator); + assertEquals("true", found); + assertEquals("true", obtainUrl); + assertEquals("true", byName); + assertNotNull(response); + assertEquals("200", siUrlResponseCode); + assertEquals(null, workflowException); + } + + @Test + @Deployment(resources = {"subprocess/GenericGetService.bpmn"}) + public void testGenericGetService_success_serviceInstance_byId() throws Exception{ + + MockNodeQueryServiceInstanceById("MIS%2F1604%2F0026%2FSW_INTERNET", "GenericFlows/getSIUrlById.xml"); + MockGetServiceInstance("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0026%252FSW_INTERNET", "GenericFlows/getServiceInstance.xml"); + + Map<String, String> variables = new HashMap<String, String>(); + setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", null, null, null); + + WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables); + waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator"); + String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator"); + String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrl"); + String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName"); + String response = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowResponse"); + String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException"); + String siUrlResponseCode = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainSIUrlResponseCode"); + + assertEquals("true", successIndicator); + assertEquals("true", found); + assertEquals("true", obtainUrl); + assertEquals("false", byName); + assertNotNull(response); + assertEquals("200", siUrlResponseCode); + assertEquals(null, workflowException); + } + + @Test + @Deployment(resources = {"subprocess/GenericGetService.bpmn"}) + public void testGenericGetService_success_serviceInstance_404Response() throws Exception{ + + MockGetServiceInstance_404("SDN-ETHERNET-INTERNET", "123456789", "MIS%2F1604%2F0026%2FSW_INTERNET"); + + Map<String, String> variables = new HashMap<String, String>(); + setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", null, "SDN-ETHERNET-INTERNET", "123456789"); + + WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables); + waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator"); + String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator"); + String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrl"); + String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName"); + String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException"); + + assertEquals("true", successIndicator); + assertEquals("false", found); + assertEquals("false", obtainUrl); + assertEquals("false", byName); + assertEquals(null, workflowException); + } + + @Test + @Deployment(resources = {"subprocess/GenericGetService.bpmn"}) + public void testGenericGetService_success_serviceSubscription404() throws Exception{ + MockGetServiceSubscription("1604-MVM-26", "SDN-ETHERNET-INTERNET", 404); + + Map<String, String> variables = new HashMap<String, String>(); + setVariablesSubscription(variables, "", "", "SDN-ETHERNET-INTERNET", "1604-MVM-26"); + + WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables); + waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator"); + String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator"); + String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrl"); + String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName"); + String response = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowResponse"); + String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException"); + + assertEquals("true", successIndicator); + assertEquals("false", found); + assertEquals("false", obtainUrl); + assertEquals("false", byName); + assertNotNull(response); + assertEquals(null, workflowException); + } + + @Test + @Deployment(resources = {"subprocess/GenericGetService.bpmn"}) + public void testGenericGetService_success_serviceInstanceByName404() throws Exception{ + + MockNodeQueryServiceInstanceByName_404("1604-MVM-26"); + + Map<String, String> variables = new HashMap<String, String>(); + setVariablesInstance(variables, "", "1604-MVM-26", null, null); + + WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables); + waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator"); + String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator"); + String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrl"); + String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName"); + String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException"); + String siUrlResponseCode = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainSIUrlResponseCode"); + + assertEquals("true", successIndicator); + assertEquals("false", found); + assertEquals("true", obtainUrl); + assertEquals("true", byName); + assertEquals("404", siUrlResponseCode); + assertEquals(null, workflowException); + } + + @Test + @Deployment(resources = {"subprocess/GenericGetService.bpmn"}) + public void testGenericGetService_success_serviceInstanceById404() throws Exception{ + + MockNodeQueryServiceInstanceById_404("MIS%2F1604%2F0026%2FSW_INTERNET"); + + Map<String, String> variables = new HashMap<String, String>(); + setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", null, null, null); + + WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables); + waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator"); + String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator"); + String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrl"); + String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName"); + String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException"); + String siUrlResponseCode = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainSIUrlResponseCode"); + + assertEquals("true", successIndicator); + assertEquals("false", found); + assertEquals("true", obtainUrl); + assertEquals("false", byName); + assertEquals("404", siUrlResponseCode); + assertEquals(null, workflowException); + } + + @Test + @Deployment(resources = {"subprocess/GenericGetService.bpmn"}) + public void testGenericGetService_success_serviceInstanceEmptyResponse() throws Exception{ + + MockGetServiceInstance("1604-MVM-26", "SDN-ETHERNET-INTERNET", "MIS%252F1604%252F0026%252FSW_INTERNET", " "); + + Map<String, String> variables = new HashMap<String, String>(); + setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", null, "SDN-ETHERNET-INTERNET", "123456789"); + + WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables); + waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator"); + String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator"); + String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrl"); + String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName"); + String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException"); + + assertEquals("true", successIndicator); + assertEquals("false", found); + assertEquals("false", obtainUrl); + assertEquals("false", byName); + assertEquals(null, workflowException); + } + + @Test + @Deployment(resources = {"subprocess/GenericGetService.bpmn"}) + public void testGenericGetService_success_serviceInstanceByNameEmpty() throws Exception{ + MockNodeQueryServiceInstanceByName("1604-MVM-26", ""); + + Map<String, String> variables = new HashMap<String, String>(); + setVariablesInstance(variables, "", "1604-MVM-26", null, null); + + WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables); + waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator"); + String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator"); + String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrl"); + String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName"); + String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException"); + String siUrlResponseCode = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainSIUrlResponseCode"); + + assertEquals("true", successIndicator); + assertEquals("false", found); + assertEquals("true", obtainUrl); + assertEquals("true", byName); + assertEquals("200", siUrlResponseCode); + assertEquals(null, workflowException); + } + + @Test + @Deployment(resources = {"subprocess/GenericGetService.bpmn"}) + public void testGenericGetService_success_serviceInstanceByIdEmpty() throws Exception{ + + MockNodeQueryServiceInstanceById("MIS[%]2F1604[%]2F0026[%]2FSW_INTERNET", ""); + + Map<String, String> variables = new HashMap<String, String>(); + setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", null, null, null); + + WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables); + waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator"); + String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator"); + String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrl"); + String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName"); + String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException"); + String siUrlResponseCode = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainSIUrlResponseCode"); + + assertEquals("true", successIndicator); + assertEquals("false", found); + assertEquals("true", obtainUrl); + assertEquals("false", byName); + assertEquals("200", siUrlResponseCode); + assertEquals(null, workflowException); + } + + + @Test + @Deployment(resources = {"subprocess/GenericGetService.bpmn"}) + public void testGenericGetService_error_serviceInstanceInvalidVariables() throws Exception{ + + Map<String, String> variables = new HashMap<String, String>(); + setVariablesInstance(variables, null, null, "SDN-ETHERNET-INTERNET", null); + + WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables); + waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator"); + String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator"); + String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException"); + String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrl"); + String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName"); + + String expectedWorkflowException = "WorkflowException[processKey=GenericGetService,errorCode=500,errorMessage=Incoming serviceInstanceId and serviceInstanceName are null. ServiceInstanceId or ServiceInstanceName is required to Get a service-instance.]"; + + assertEquals("false", successIndicator); + assertEquals("false", found); + assertEquals("false", obtainUrl); + assertEquals("false", byName); + assertEquals(expectedWorkflowException, workflowException); + } + + @Test + @Deployment(resources = {"subprocess/GenericGetService.bpmn"}) + public void testGenericGetService_success_serviceSubscriptionInvalidVariables() throws Exception{ + + Map<String, String> variables = new HashMap<String, String>(); + setVariablesSubscription(variables, "", "", "SDN-ETHERNET-INTERNET", null); + + WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables); + waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator"); + String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator"); + String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrl"); + String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName"); + String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException"); + + String expectedWorkflowException = "WorkflowException[processKey=GenericGetService,errorCode=500,errorMessage=Incoming ServiceType or GlobalCustomerId is null. These variables are required to Get a service-subscription.]"; + + + assertEquals("false", successIndicator); + assertEquals("false", found); + assertEquals("false", obtainUrl); + assertEquals("false", byName); + assertEquals(expectedWorkflowException, workflowException); + } + + @Test + @Deployment(resources = {"subprocess/GenericGetService.bpmn"}) + public void testGenericGetService_error_serviceInstance_getSIBadResponse() throws Exception{ + + MockGetServiceInstance_500("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0026%252FSW_INTERNET"); + + Map<String, String> variables = new HashMap<String, String>(); + setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", "1604-MVM-26", "SDN-ETHERNET-INTERNET", "123456789"); + + WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables); + waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator"); + String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator"); + String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException"); + String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrl"); + String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName"); + + String expectedWorkflowException = "WorkflowException[processKey=GenericGetService,errorCode=500,errorMessage=Received a bad response from AAI]"; + + assertEquals("false", successIndicator); + assertEquals("false", found); + assertEquals("false", obtainUrl); + assertEquals("false", byName); + assertEquals(expectedWorkflowException, workflowException); + } + + @Test + @Deployment(resources = {"subprocess/GenericGetService.bpmn"}) + public void testGenericGetService_error_serviceInstance_getUrlByIdBadResponse() throws Exception{ + + MockNodeQueryServiceInstanceById_500("MIS%2F1604%2F0026%2FSW_INTERNET"); + + Map<String, String> variables = new HashMap<String, String>(); + setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", null, null, null); + + WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables); + waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator"); + String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator"); + String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException"); + String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrl"); + String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName"); + String siUrlResponseCode = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainSIUrlResponseCode"); + + String expectedWorkflowException = "WorkflowException[processKey=GenericGetService,errorCode=500,errorMessage=Received a bad response from AAI]"; + + assertEquals("false", successIndicator); + assertEquals("false", found); + assertEquals("true", obtainUrl); + assertEquals("false", byName); + assertEquals("500", siUrlResponseCode); + assertEquals(expectedWorkflowException, workflowException); + } + + @Test + @Deployment(resources = {"subprocess/GenericGetService.bpmn"}) + public void testGenericGetService_error_serviceInstance_getUrlByNameBadResponse() throws Exception{ + + MockNodeQueryServiceInstanceByName_500("1604-MVM-26"); + + Map<String, String> variables = new HashMap<String, String>(); + setVariablesInstance(variables, null, "1604-MVM-26", null, null); + + WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables); + waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator"); + String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator"); + String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException"); + String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrl"); + String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName"); + String siUrlResponseCode = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainSIUrlResponseCode"); + + String expectedWorkflowException = "WorkflowException[processKey=GenericGetService,errorCode=500,errorMessage=Received a bad response from AAI]"; + + assertEquals("false", successIndicator); + assertEquals("false", found); + assertEquals("true", obtainUrl); + assertEquals("true", byName); + assertEquals("500", siUrlResponseCode); + assertEquals(expectedWorkflowException, workflowException); + } + + + private void setVariablesInstance(Map<String, String> variables, String siId, String siName, String globalCustId, String serviceType) { + variables.put("isDebugLogEnabled", "true"); + variables.put("GENGS_serviceInstanceId", siId); + variables.put("GENGS_serviceInstanceName", siName); + variables.put("GENGS_globalCustomerId",globalCustId); + variables.put("GENGS_serviceType", serviceType); + variables.put("GENGS_type", "service-instance"); + } + + private void setVariablesSubscription(Map<String, String> variables, String siId, String siName, String globalCustId, String serviceType) { + variables.put("isDebugLogEnabled", "true"); + variables.put("GENGS_serviceInstanceId", siId); + variables.put("GENGS_serviceInstanceName", siName); + variables.put("GENGS_globalCustomerId",globalCustId); + variables.put("GENGS_serviceType", serviceType); + variables.put("GENGS_type", "service-subscription"); + } + + +} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/GenericGetVnfTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/GenericGetVnfTest.java new file mode 100644 index 0000000000..80105bbb99 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/GenericGetVnfTest.java @@ -0,0 +1,191 @@ +/* + * © 2014 AT&T Intellectual Property. All rights reserved. Used under license from AT&T Intellectual Property. + */ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.openecomp.mso.bpmn.common.BPMNUtil.executeWorkFlow; +import static org.openecomp.mso.bpmn.common.BPMNUtil.waitForWorkflowToFinish; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfByIdWithDepth; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfById_500; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfByNameWithDepth; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVceByNameWithDepth; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetVceById; + +import java.util.HashMap; +import java.util.Map; + +import org.camunda.bpm.engine.test.Deployment; +import org.junit.Ignore; +import org.junit.Test; +import org.openecomp.mso.bpmn.common.workflow.service.WorkflowResponse; + +/** + * Please describe the GenericGetVnfTest.java class + * + */ +public class GenericGetVnfTest extends WorkflowTest { + + @Test + @Deployment(resources = {"subprocess/GenericGetVnf.bpmn"}) + public void testGenericGetVnf_success_genericVnf() throws Exception{ + MockGetGenericVnfByIdWithDepth("testVnfId123", 1, "GenericFlows/getGenericVnfByNameResponse.xml"); + + Map<String, String> variables = new HashMap<String, String>(); + setVariables(variables, "testVnfId123", "testVnfName123", "generic-vnf"); + + WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetVnf", variables); + waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetVnf", "GENGV_SuccessIndicator"); + String found = BPMNUtil.getVariable(processEngineRule, "GenericGetVnf", "GENGV_FoundIndicator"); + String vnf = BPMNUtil.getVariable(processEngineRule, "GenericGetVnf", "GENGV_vnf"); + String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetVnf", "GENGV_getVnfByName"); + String response = BPMNUtil.getVariable(processEngineRule, "GenericGetVnf", "WorkflowResponse"); + String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetVnf", "WorkflowException"); + + assertEquals("true", successIndicator); + assertEquals("true", found); + assertEquals("false", byName); + assertNotNull(response); + assertNotNull(vnf); + assertEquals(null, workflowException); + + } + + @Test + @Deployment(resources = {"subprocess/GenericGetVnf.bpmn"}) + public void testGenericGetVnf_success_vce() throws Exception{ + MockGetVceById("testVnfId123[?]depth=1", "GenericFlows/getVceResponse.xml"); + + Map<String, String> variables = new HashMap<String, String>(); + setVariables(variables, "testVnfId123", "testVnfName123", "vce"); + + WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetVnf", variables); + waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetVnf", "GENGV_SuccessIndicator"); + String found = BPMNUtil.getVariable(processEngineRule, "GenericGetVnf", "GENGV_FoundIndicator"); + String vnf = BPMNUtil.getVariable(processEngineRule, "GenericGetVnf", "GENGV_vnf"); + String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetVnf", "GENGV_getVnfByName"); + String response = BPMNUtil.getVariable(processEngineRule, "GenericGetVnf", "WorkflowResponse"); + String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetVnf", "WorkflowException"); + + assertEquals("true", successIndicator); + assertEquals("true", found); + assertEquals("false", byName); + assertNotNull(response); + assertNotNull(vnf); + assertEquals(null, workflowException); + + } + + @Test + @Deployment(resources = {"subprocess/GenericGetVnf.bpmn"}) + public void testGenericGetVnf_success_genericVnfByName() throws Exception{ + MockGetGenericVnfByNameWithDepth("testVnfName123", 1, "GenericFlows/getGenericVnfResponse.xml"); + + Map<String, String> variables = new HashMap<String, String>(); + setVariables(variables, "", "testVnfName123", "generic-vnf"); + + WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetVnf", variables); + waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetVnf", "GENGV_SuccessIndicator"); + String found = BPMNUtil.getVariable(processEngineRule, "GenericGetVnf", "GENGV_FoundIndicator"); + String vnf = BPMNUtil.getVariable(processEngineRule, "GenericGetVnf", "GENGV_vnf"); + String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetVnf", "GENGV_getVnfByName"); + String response = BPMNUtil.getVariable(processEngineRule, "GenericGetVnf", "WorkflowResponse"); + String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetVnf", "WorkflowException"); + + assertEquals("true", successIndicator); + assertEquals("true", found); + assertEquals("true", byName); + assertNotNull(response); + assertNotNull(vnf); + assertEquals(null, workflowException); + + } + + @Test + @Deployment(resources = {"subprocess/GenericGetVnf.bpmn"}) + public void testGenericGetVnf_success_vceByName() throws Exception{ + MockGetGenericVceByNameWithDepth("testVnfName123", 1, "GenericFlows/getVceByNameResponse.xml"); + + Map<String, String> variables = new HashMap<String, String>(); + setVariables(variables, null, "testVnfName123", "vce"); + + WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetVnf", variables); + waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetVnf", "GENGV_SuccessIndicator"); + String found = BPMNUtil.getVariable(processEngineRule, "GenericGetVnf", "GENGV_FoundIndicator"); + String vnf = BPMNUtil.getVariable(processEngineRule, "GenericGetVnf", "GENGV_vnf"); + String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetVnf", "GENGV_getVnfByName"); + String response = BPMNUtil.getVariable(processEngineRule, "GenericGetVnf", "WorkflowResponse"); + String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetVnf", "WorkflowException"); + + assertEquals("true", successIndicator); + assertEquals("true", found); + assertEquals("true", byName); + assertNotNull(response); + assertNotNull(vnf); + assertEquals(null, workflowException); + + } + + @Test + @Ignore // BROKEN TEST (previously ignored) + @Deployment(resources = {"subprocess/GenericGetVnf.bpmn"}) + public void testGenericGetVnf_error_genericVnf500() throws Exception{ + + MockGetGenericVnfById_500("testVnfId123"); + + Map<String, String> variables = new HashMap<String, String>(); + setVariables(variables, "testVnfId123", "testVnfName123", "generic-vnf"); + + WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetVnf", variables); + waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetVnf", "GENGV_SuccessIndicator"); + String found = BPMNUtil.getVariable(processEngineRule, "GenericGetVnf", "GENGV_FoundIndicator"); + String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetVnf", "WorkflowException"); + String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetVnf", "GENGV_getVnfByName"); + + String expectedWorkflowException = "WorkflowException[processKey=GenericGetVnf,errorCode=500,errorMessage=Incoming VnfId and VnfName are null. VnfId or VnfName is required!]"; + + assertEquals("false", successIndicator); + assertEquals("false", found); + assertEquals("false", byName); + + assertEquals(expectedWorkflowException, workflowException); + } + + private void setVariables(Map<String, String> variables, String vnfId, String vnfName, String type) { + variables.put("isDebugLogEnabled", "true"); + variables.put("GENGV_vnfId", vnfId); + variables.put("GENGV_vnfName",vnfName); + variables.put("GENGV_type", type); + } +} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/GenericPutVnfTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/GenericPutVnfTest.java new file mode 100644 index 0000000000..248cb978dc --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/GenericPutVnfTest.java @@ -0,0 +1,182 @@ +/* + * © 2014 AT&T Intellectual Property. All rights reserved. Used under license from AT&T Intellectual Property. + */ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common; + +import static org.junit.Assert.assertEquals; +import static org.openecomp.mso.bpmn.common.BPMNUtil.executeWorkFlow; +import static org.openecomp.mso.bpmn.common.BPMNUtil.waitForWorkflowToFinish; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutGenericVnf; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutVce; + +import java.util.HashMap; +import java.util.Map; + +import org.camunda.bpm.engine.test.Deployment; +import org.junit.Test; +import org.openecomp.mso.bpmn.common.workflow.service.WorkflowResponse; + +/** + * Please describe the GenericPutVnf.java class + * + */ +public class GenericPutVnfTest extends WorkflowTest { + + private String genericVnfPayload = "<generic-vnf><vnf-id>testId</vnf-id></generic-vnf>"; + private String vcePayload = "<vce><vnf-id>testId</vnf-id></vce>"; + + @Test + @Deployment(resources = {"subprocess/GenericPutVnf.bpmn"}) + public void testGenericPutVnf_success_genericVnf() throws Exception{ + + MockPutGenericVnf("testVnfId123"); + + Map<String, String> variables = new HashMap<String, String>(); + setVariables(variables, "testVnfId123", genericVnfPayload, "generic-vnf"); + + WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericPutVnf", variables); + waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericPutVnf", "GENPV_SuccessIndicator"); + String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericPutVnf", "WorkflowException"); + + assertEquals("true", successIndicator); + assertEquals(null, workflowException); + + } + + @Test + @Deployment(resources = {"subprocess/GenericPutVnf.bpmn"}) + public void testGenericPutVnf_success_vce() throws Exception{ + + MockPutVce("testVnfId123"); + + Map<String, String> variables = new HashMap<String, String>(); + setVariables(variables, "testVnfId123", vcePayload, "vce"); + + WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericPutVnf", variables); + waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericPutVnf", "GENPV_SuccessIndicator"); + String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericPutVnf", "WorkflowException"); + + assertEquals("true", successIndicator); + assertEquals(null, workflowException); + + } + + @Test + @Deployment(resources = {"subprocess/GenericPutVnf.bpmn"}) + public void testGenericPutVnf_error_missingType() throws Exception{ + + MockPutGenericVnf("testVnfId123"); + + Map<String, String> variables = new HashMap<String, String>(); + setVariables(variables, "testVnfId123", genericVnfPayload, ""); + + WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericPutVnf", variables); + waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericPutVnf", "GENPV_SuccessIndicator"); + String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericPutVnf", "WorkflowException"); + + String expectedWFEX = "WorkflowException[processKey=GenericPutVnf,errorCode=500,errorMessage=Incoming Vnf Payload and/or Type is null. These Variables are required!]"; + + assertEquals("false", successIndicator); + assertEquals(expectedWFEX, workflowException); + + } + + @Test + @Deployment(resources = {"subprocess/GenericPutVnf.bpmn"}) + public void testGenericPutVnf_error_missingPayload() throws Exception{ + + MockPutGenericVnf("testVnfId123"); + + Map<String, String> variables = new HashMap<String, String>(); + setVariables(variables, "testVnfId123", genericVnfPayload, ""); + + WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericPutVnf", variables); + waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericPutVnf", "GENPV_SuccessIndicator"); + String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericPutVnf", "WorkflowException"); + + String expectedWFEX = "WorkflowException[processKey=GenericPutVnf,errorCode=500,errorMessage=Incoming Vnf Payload and/or Type is null. These Variables are required!]"; + + assertEquals("false", successIndicator); + assertEquals(expectedWFEX, workflowException); + + } + + @Test + @Deployment(resources = {"subprocess/GenericPutVnf.bpmn"}) + public void testGenericPutVnf_error_404() throws Exception{ + + Map<String, String> variables = new HashMap<String, String>(); + setVariables(variables, "testVnfId123", genericVnfPayload, "generic-vnf"); + + WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericPutVnf", variables); + waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericPutVnf", "GENPV_SuccessIndicator"); + String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericPutVnf", "WorkflowException"); + + String expectedWFEX = "WorkflowException[processKey=GenericPutVnf,errorCode=404,errorMessage=Received a bad response from AAI]"; + + assertEquals("false", successIndicator); + assertEquals(expectedWFEX, workflowException); + } + + @Test + @Deployment(resources = {"subprocess/GenericPutVnf.bpmn"}) + public void testGenericPutVnf_error_400() throws Exception{ + + MockPutGenericVnf("/testVnfId123", 400); + + Map<String, String> variables = new HashMap<String, String>(); + setVariables(variables, "testVnfId123", genericVnfPayload, "generic-vnf"); + + WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericPutVnf", variables); + waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericPutVnf", "GENPV_SuccessIndicator"); + String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericPutVnf", "WorkflowException"); + + String expectedWFEX = "WorkflowException[processKey=GenericPutVnf,errorCode=400,errorMessage=Received a bad response from AAI]"; + + assertEquals("false", successIndicator); + assertEquals(expectedWFEX, workflowException); + + + } + + private void setVariables(Map<String, String> variables, String vnfId, String payload, String type) { + variables.put("isDebugLogEnabled", "true"); + variables.put("GENPV_vnfId", vnfId); + variables.put("GENPV_vnfPayload",payload); + variables.put("GENPV_type", type); + } + + +} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/PrepareUpdateAAIVfModuleTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/PrepareUpdateAAIVfModuleTest.java new file mode 100644 index 0000000000..cb5f722a42 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/PrepareUpdateAAIVfModuleTest.java @@ -0,0 +1,208 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common; + +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfByIdWithDepth; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfById_404; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutGenericVnf; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +import org.camunda.bpm.engine.test.Deployment; +import org.junit.Assert; +import org.junit.Test; +import org.openecomp.mso.bpmn.core.WorkflowException; +import org.openecomp.mso.bpmn.mock.FileUtil; + +/** + * Unit tests for PrepareUpdateAAIVfModule.bpmn. + */ +public class PrepareUpdateAAIVfModuleTest extends WorkflowTest { + + /** + * Test the happy path through the flow. + */ + @Test + @Deployment(resources = { + "subprocess/PrepareUpdateAAIVfModule.bpmn" + }) + public void happyPath() throws IOException { + + logStart(); + + String prepareUpdateAAIVfModuleRequest = FileUtil.readResourceFile("__files/VfModularity/PrepareUpdateAAIVfModuleRequest.xml"); + + MockGetGenericVnfByIdWithDepth("skask", 1, "VfModularity/GenericVnf.xml"); + MockPutGenericVnf("/skask/vf-modules/vf-module/supercool", "PCRF", 200); + + String businessKey = UUID.randomUUID().toString(); + Map<String, Object> variables = new HashMap<String, Object>(); + variables.put("mso-request-id", "999-99-9999"); + variables.put("isDebugLogEnabled","true"); + variables.put("PrepareUpdateAAIVfModuleRequest", prepareUpdateAAIVfModuleRequest); + invokeSubProcess("PrepareUpdateAAIVfModule", businessKey, variables); + + Assert.assertTrue(isProcessEnded(businessKey)); + String response = (String) getVariableFromHistory(businessKey, "PUAAIVfMod_updateVfModuleResponse"); + Integer responseCode = (Integer) getVariableFromHistory(businessKey, "PUAAIVfMod_updateVfModuleResponseCode"); + System.out.println("Subflow response code: " + responseCode); + System.out.println("Subflow response: " + response); + Assert.assertEquals(200, responseCode.intValue()); + String heatStackId = (String) getVariableFromHistory(businessKey, "PUAAIVfMod_heatStackId"); + System.out.println("Ouput heat-stack-id:" + heatStackId); + Assert.assertEquals("slowburn", heatStackId); + + logEnd(); + } + + /** + * Test the case where the GET to AAI returns a 404. + */ + @Test + @Deployment(resources = { + "subprocess/PrepareUpdateAAIVfModule.bpmn" + }) + public void badGet() throws IOException { + + logStart(); + + String prepareUpdateAAIVfModuleRequest = FileUtil.readResourceFile("__files/VfModularity/PrepareUpdateAAIVfModuleRequest.xml"); + MockGetGenericVnfById_404("skask[?]depth=1"); + + String businessKey = UUID.randomUUID().toString(); + Map<String, Object> variables = new HashMap<String, Object>(); + variables.put("mso-request-id", "999-99-9999"); + variables.put("isDebugLogEnabled","true"); + variables.put("PrepareUpdateAAIVfModuleRequest", prepareUpdateAAIVfModuleRequest); + invokeSubProcess("PrepareUpdateAAIVfModule", businessKey, variables); + + Assert.assertTrue(isProcessEnded(businessKey)); + String response = (String) getVariableFromHistory(businessKey, "PUAAIVfMod_getVnfResponse"); + Integer responseCode = (Integer) getVariableFromHistory(businessKey, "PUAAIVfMod_getVnfResponseCode"); + WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException"); + System.out.println("Subflow response code: " + responseCode); + System.out.println("Subflow response: " + response); + Assert.assertEquals(404, responseCode.intValue()); + Assert.assertNotNull(workflowException); + System.out.println("Subflow WorkflowException error message: " + workflowException.getErrorMessage()); + + logEnd(); + } + + /** + * Test the case where the validation of the VF Module fails. + */ + @Test + @Deployment(resources = { + "subprocess/PrepareUpdateAAIVfModule.bpmn" + }) + public void failValidation1() throws IOException { + + logStart(); + + String prepareUpdateAAIVfModuleRequest = FileUtil.readResourceFile("__files/VfModularity/PrepareUpdateAAIVfModuleRequest.xml").replaceFirst("supercool", "lukewarm"); + + MockGetGenericVnfByIdWithDepth("skask", 1, "VfModularity/GenericVnf.xml"); + + String businessKey = UUID.randomUUID().toString(); + Map<String, Object> variables = new HashMap<String, Object>(); + variables.put("mso-request-id", "999-99-9999"); + variables.put("isDebugLogEnabled","true"); + variables.put("PrepareUpdateAAIVfModuleRequest", prepareUpdateAAIVfModuleRequest); + invokeSubProcess("PrepareUpdateAAIVfModule", businessKey, variables); + + WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException"); + Assert.assertNotNull(workflowException); + System.out.println("Subflow WorkflowException error message: " + workflowException.getErrorMessage()); + Assert.assertTrue(workflowException.getErrorMessage().startsWith("VF Module validation error: Orchestration")); + + logEnd(); + } + + /** + * Test the case where the validation of the VF Module fails. + */ + @Test + @Deployment(resources = { + "subprocess/PrepareUpdateAAIVfModule.bpmn" + }) + public void failValidation2() throws IOException { + + logStart(); + + String prepareUpdateAAIVfModuleRequest = FileUtil.readResourceFile("__files/VfModularity/PrepareUpdateAAIVfModuleRequest.xml").replaceFirst("supercool", "notsocool"); + + MockGetGenericVnfByIdWithDepth("skask", 1, "VfModularity/GenericVnf.xml"); + + String businessKey = UUID.randomUUID().toString(); + Map<String, Object> variables = new HashMap<String, Object>(); + variables.put("mso-request-id", "999-99-9999"); + variables.put("isDebugLogEnabled","true"); + variables.put("PrepareUpdateAAIVfModuleRequest", prepareUpdateAAIVfModuleRequest); + invokeSubProcess("PrepareUpdateAAIVfModule", businessKey, variables); + + WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException"); + Assert.assertNotNull(workflowException); + System.out.println("Subflow WorkflowException error message: " + workflowException.getErrorMessage()); + Assert.assertTrue(workflowException.getErrorMessage().startsWith("VF Module validation error: VF Module")); + + logEnd(); + } + + /** + * Test the case where the GET to AAI is successful, but the subsequent PUT returns 404. + */ + @Test + @Deployment(resources = { + "subprocess/PrepareUpdateAAIVfModule.bpmn" + }) + public void badPut() throws IOException { + + logStart(); + + String prepareUpdateAAIVfModuleRequest = FileUtil.readResourceFile("__files/VfModularity/PrepareUpdateAAIVfModuleRequest.xml"); + + MockGetGenericVnfByIdWithDepth("skask", 1, "VfModularity/GenericVnf.xml"); + + String businessKey = UUID.randomUUID().toString(); + Map<String, Object> variables = new HashMap<String, Object>(); + variables.put("mso-request-id", "999-99-9999"); + variables.put("isDebugLogEnabled","true"); + variables.put("PrepareUpdateAAIVfModuleRequest", prepareUpdateAAIVfModuleRequest); + invokeSubProcess("PrepareUpdateAAIVfModule", businessKey, variables); + + Assert.assertTrue(isProcessEnded(businessKey)); + String response = (String) getVariableFromHistory(businessKey, "PUAAIVfMod_updateVfModuleResponse"); + Integer responseCode = (Integer) getVariableFromHistory(businessKey, "PUAAIVfMod_updateVfModuleResponseCode"); + WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException"); + System.out.println("Subflow response code: " + responseCode); + System.out.println("Subflow response: " + response); + Assert.assertEquals(404, responseCode.intValue()); + Assert.assertNotNull(workflowException); + System.out.println("Subflow WorkflowException error message: " + workflowException.getErrorMessage()); + + logEnd(); + } +} + diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/SDNCAdapterCallbackRule.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/SDNCAdapterCallbackRule.java new file mode 100644 index 0000000000..f3c3b84d18 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/SDNCAdapterCallbackRule.java @@ -0,0 +1,64 @@ +package org.openecomp.mso.bpmn.common; + +import javax.xml.ws.Endpoint; + +import org.camunda.bpm.engine.ProcessEngineServices; +import org.junit.rules.TestRule; +import org.junit.runner.Description; +import org.junit.runners.model.Statement; +import org.openecomp.mso.bpmn.common.workflow.service.SDNCAdapterCallbackServiceImpl; + +/** + * A JUnit rule that starts the SDNC Adapter Callback Service before + * every test, and tears it down after every test. Example: + * <pre> + * @Rule + * public final SDNCAdapterCallbackRule sdncAdapterCallbackRule = + * new SDNCAdapterCallbackRule(processEngineRule); + * </pre> + */ +public class SDNCAdapterCallbackRule implements TestRule { + public static final String DEFAULT_ENDPOINT_URL = + "http://localhost:28080/mso/SDNCAdapterCallbackService"; + + private final ProcessEngineServices processEngineServices; + private final String endpointUrl; + + public SDNCAdapterCallbackRule(ProcessEngineServices processEngineServices) { + this(processEngineServices, DEFAULT_ENDPOINT_URL); + } + + public SDNCAdapterCallbackRule(ProcessEngineServices processEngineServices, + String endpointUrl) { + this.processEngineServices = processEngineServices; + this.endpointUrl = endpointUrl; + } + + @Override + public Statement apply(final Statement baseStmt, Description description) { + return new Statement() { + @Override + public void evaluate() throws Throwable { + Endpoint endpoint = null; + + try { + SDNCAdapterCallbackServiceImpl sdncCallbackService = new SDNCAdapterCallbackServiceImpl(); + sdncCallbackService.setProcessEngineServices4junit(processEngineServices); + + System.setProperty("com.sun.xml.ws.transport.http.HttpAdapter.dump", "true"); + System.setProperty("com.sun.xml.internal.ws.transport.http.HttpAdapter.dump", "true"); + + System.out.println("Publishing Endpoint - " + endpointUrl); + endpoint = Endpoint.publish(endpointUrl, sdncCallbackService); + + baseStmt.evaluate(); + } finally { + if (endpoint != null) { + System.out.println("Stopping Endpoint - " + endpointUrl); + endpoint.stop(); + } + } + } + }; + } +}
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/SDNCAdapterV1Test.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/SDNCAdapterV1Test.java new file mode 100644 index 0000000000..b0e1dc9afc --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/SDNCAdapterV1Test.java @@ -0,0 +1,389 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.openecomp.mso.bpmn.mock.StubResponseDatabase.mockUpdateRequestDB; +import static org.openecomp.mso.bpmn.mock.StubResponseSDNCAdapter.mockSDNCAdapter; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + +import javax.ws.rs.core.Response; + +import org.camunda.bpm.engine.MismatchingMessageCorrelationException; +import org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl; +import org.camunda.bpm.engine.runtime.Job; +import org.camunda.bpm.engine.test.Deployment; +import org.camunda.bpm.engine.variable.impl.VariableMapImpl; +import org.junit.Assert; +import org.junit.Test; +import org.openecomp.mso.bpmn.common.adapter.sdnc.CallbackHeader; +import org.openecomp.mso.bpmn.common.adapter.sdnc.SDNCAdapterCallbackRequest; +import org.openecomp.mso.bpmn.common.adapter.sdnc.SDNCAdapterResponse; +import org.openecomp.mso.bpmn.common.workflow.service.SDNCAdapterCallbackServiceImpl; +import org.openecomp.mso.bpmn.common.workflow.service.SDNCAdapterCallbackServiceImpl.SDNCAdapterExceptionResponse; +import org.openecomp.mso.bpmn.common.workflow.service.WorkflowResource; +import org.openecomp.mso.bpmn.common.workflow.service.WorkflowResponse; +import org.openecomp.mso.bpmn.mock.FileUtil; + +/** + * Unit test cases for SDNCAdapterV1.bpmn + */ +public class SDNCAdapterV1Test extends WorkflowTest { + + private String sdncAdapterWorkflowRequest; + private String sdncAdapterWorkflowRequestAct; + private String sdncAdapterCallbackRequestData; + private String sdncAdapterCallbackRequestDataNonfinal; + + public SDNCAdapterV1Test() throws IOException { + sdncAdapterWorkflowRequest = FileUtil.readResourceFile("sdncadapterworkflowrequest.xml"); + sdncAdapterWorkflowRequestAct = FileUtil.readResourceFile("sdncadapterworkflowrequest-act.xml"); + sdncAdapterCallbackRequestData = FileUtil.readResourceFile("sdncadaptercallbackrequestdata.text"); + sdncAdapterCallbackRequestDataNonfinal = FileUtil.readResourceFile("sdncadaptercallbackrequestdata-nonfinal.text"); + } + + /** + * End-to-End flow - Unit test for SDNCAdapterV1.bpmn + * - String input & String response + */ + + private WorkflowResponse invokeFlow(String workflowRequest) { + + Map<String, Object>valueMap = new HashMap<String, Object>(); + valueMap.put("value", workflowRequest); + Map<String, Object> variables = new HashMap<String, Object>(); + variables.put("sdncAdapterWorkflowRequest", valueMap); + + Map<String, Object> valueMap2 = new HashMap<String, Object>(); + valueMap2.put("value", "true"); + variables.put("isDebugLogEnabled", valueMap2); + + VariableMapImpl varMap = new VariableMapImpl(); + varMap.put("variables", variables); + + //System.out.println("Invoking the flow"); + + WorkflowResource workflowResource = new WorkflowResource(); + workflowResource.setProcessEngineServices4junit(processEngineRule); + + Response response = workflowResource.startProcessInstanceByKey("sdncAdapter", varMap); + WorkflowResponse workflowResponse = (WorkflowResponse) response.getEntity(); + + //String pid = workflowResponse.getProcessInstanceID(); + //System.out.println("Back from executing process instance with pid=" + pid); + return workflowResponse; + } + + @Test + @Deployment(resources = {"subprocess/SDNCAdapterV1.bpmn"}) + public void sunnyDay() throws InterruptedException { + + mockSDNCAdapter(200); + + //System.out.println("SDNCAdapter sunny day flow Started!"); + + ProcessExecutionThread thread = new ProcessExecutionThread(sdncAdapterWorkflowRequest); + thread.start(); + waitForExecutionToStart("sdncAdapter", 3); + String pid = getPid(); + + assertProcessInstanceNotFinished(pid); + + System.out.println("Injecting SDNC Adapter asynchronous callback message to continue processing"); + String generatedRequestId = (String) processEngineRule.getRuntimeService().getVariable(pid, "SDNCA_requestId"); + CallbackHeader callbackHeader = new CallbackHeader(); + callbackHeader.setRequestId(generatedRequestId); + callbackHeader.setResponseCode("200"); + callbackHeader.setResponseMessage("OK"); + SDNCAdapterCallbackRequest sdncAdapterCallbackRequest = new SDNCAdapterCallbackRequest(); + sdncAdapterCallbackRequest.setCallbackHeader(callbackHeader); + sdncAdapterCallbackRequest.setRequestData(sdncAdapterCallbackRequestData); + SDNCAdapterCallbackServiceImpl callbackService = new SDNCAdapterCallbackServiceImpl(); + callbackService.setProcessEngineServices4junit(processEngineRule); + SDNCAdapterResponse sdncAdapterResponse = callbackService.sdncAdapterCallback(sdncAdapterCallbackRequest); + //System.out.println("Back from executing process again"); + + assertFalse(sdncAdapterResponse instanceof SDNCAdapterExceptionResponse); + assertProcessInstanceFinished(pid); + + //System.out.println("SDNCAdapter sunny day flow Completed!"); + } + + @Test + @Deployment(resources = {"subprocess/SDNCAdapterV1.bpmn"}) + public void nonFinalWithTimeout() throws InterruptedException { + + mockSDNCAdapter(200); + mockUpdateRequestDB(200, "Database/DBAdapter.xml"); + + //System.out.println("SDNCAdapter interim status processing flow Started!"); + + ProcessExecutionThread thread = new ProcessExecutionThread(sdncAdapterWorkflowRequestAct); + thread.start(); + waitForExecutionToStart("sdncAdapter", 3); + String pid = getPid(); + + assertProcessInstanceNotFinished(pid); + + //System.out.println("Injecting SDNC Adapter asynchronous callback message to continue processing"); + String generatedRequestId = (String) processEngineRule.getRuntimeService().getVariable(pid, "SDNCA_requestId"); + CallbackHeader callbackHeader = new CallbackHeader(); + callbackHeader.setRequestId(generatedRequestId); + callbackHeader.setResponseCode("200"); + callbackHeader.setResponseMessage("OK"); + SDNCAdapterCallbackRequest sdncAdapterCallbackRequest = new SDNCAdapterCallbackRequest(); + sdncAdapterCallbackRequest.setCallbackHeader(callbackHeader); + sdncAdapterCallbackRequest.setRequestData(sdncAdapterCallbackRequestDataNonfinal); + SDNCAdapterCallbackServiceImpl callbackService = new SDNCAdapterCallbackServiceImpl(); + callbackService.setProcessEngineServices4junit(processEngineRule); + SDNCAdapterResponse sdncAdapterResponse = callbackService.sdncAdapterCallback(sdncAdapterCallbackRequest); + //System.out.println("Back from executing process again"); + + assertFalse(sdncAdapterResponse instanceof SDNCAdapterExceptionResponse); + assertProcessInstanceNotFinished(pid); + + checkForTimeout(pid); + + assertEquals(true, (Boolean) (getVariable(pid, "continueListening"))); + + + //System.out.println("SDNCAdapter interim status processing flow Completed!"); + } + + @Test + @Deployment(resources = {"subprocess/SDNCAdapterV1.bpmn"}) + public void nonFinalThenFinal() throws InterruptedException { + + mockSDNCAdapter(200); + mockUpdateRequestDB(200, "Database/DBAdapter.xml"); + + //System.out.println("SDNCAdapter non-final then final processing flow Started!"); + + // Start the flow + ProcessExecutionThread thread = new ProcessExecutionThread(sdncAdapterWorkflowRequestAct); + thread.start(); + waitForExecutionToStart("sdncAdapter", 3); + String pid = getPid(); + + assertProcessInstanceNotFinished(pid); + + // Inject a "non-final" SDNC Adapter asynchronous callback message + //System.out.println("Injecting SDNC Adapter asynchronous callback message to continue processing"); + String generatedRequestId = (String) processEngineRule.getRuntimeService().getVariable(pid, "SDNCA_requestId"); + CallbackHeader callbackHeader = new CallbackHeader(); + callbackHeader.setRequestId(generatedRequestId); + callbackHeader.setResponseCode("200"); + callbackHeader.setResponseMessage("OK"); + SDNCAdapterCallbackRequest sdncAdapterCallbackRequest = new SDNCAdapterCallbackRequest(); + sdncAdapterCallbackRequest.setCallbackHeader(callbackHeader); + sdncAdapterCallbackRequest.setRequestData(sdncAdapterCallbackRequestDataNonfinal); + SDNCAdapterCallbackServiceImpl callbackService = new SDNCAdapterCallbackServiceImpl(); + callbackService.setProcessEngineServices4junit(processEngineRule); + SDNCAdapterResponse sdncAdapterResponse = callbackService.sdncAdapterCallback(sdncAdapterCallbackRequest); + //System.out.println("Back from executing process again"); + + assertFalse(sdncAdapterResponse instanceof SDNCAdapterExceptionResponse); + assertProcessInstanceNotFinished(pid); + assertEquals(true, (Boolean) (getVariable(pid, "continueListening"))); + + // Inject a "final" SDNC Adapter asynchronous callback message + sdncAdapterCallbackRequest.setRequestData(sdncAdapterCallbackRequestData); + sdncAdapterResponse = callbackService.sdncAdapterCallback(sdncAdapterCallbackRequest); + //System.out.println("Back from executing process again"); + + assertFalse(sdncAdapterResponse instanceof SDNCAdapterExceptionResponse); + assertProcessInstanceFinished(pid); + assertEquals(false, (Boolean) (getVariable(pid, "continueListening"))); + + //System.out.println("SDNCAdapter non-final then final processing flow Completed!"); + } + + + + private void waitForExecutionToStart(String processDefintion, int count) throws InterruptedException { + //System.out.println(processEngineRule.getRuntimeService().createExecutionQuery().processDefinitionKey(processDefintion).count()); + while (processEngineRule.getRuntimeService().createExecutionQuery().processDefinitionKey(processDefintion).count() != count) { + Thread.sleep(200); + } + } + + @Test + @Deployment(resources = {"subprocess/SDNCAdapterV1.bpmn"}) + public void badCorrelationIdTest() throws InterruptedException { + + mockSDNCAdapter(200); + + //System.out.println("SDNCAdapter bad RequestId test Started!"); + + ProcessExecutionThread thread = new ProcessExecutionThread(sdncAdapterWorkflowRequest); + thread.start(); + waitForExecutionToStart("sdncAdapter", 3); + String pid = getPid(); + assertProcessInstanceNotFinished(pid); + + //System.out.println("Injecting SDNC Adapter asynchronous callback message to continue processing"); + String badRequestId = "This is not the RequestId that was used"; + CallbackHeader callbackHeader = new CallbackHeader(); + callbackHeader.setRequestId(badRequestId); + callbackHeader.setResponseCode("200"); + callbackHeader.setResponseMessage("OK"); + SDNCAdapterCallbackRequest sdncAdapterCallbackRequest = new SDNCAdapterCallbackRequest(); + sdncAdapterCallbackRequest.setCallbackHeader(callbackHeader); + sdncAdapterCallbackRequest.setRequestData(sdncAdapterCallbackRequestData); + SDNCAdapterCallbackServiceImpl callbackService = new SDNCAdapterCallbackServiceImpl(); + callbackService.setProcessEngineServices4junit(processEngineRule); + SDNCAdapterResponse sdncAdapterResponse = callbackService.sdncAdapterCallback(sdncAdapterCallbackRequest); + //System.out.println("Back from executing process again"); + + assertTrue(sdncAdapterResponse instanceof SDNCAdapterExceptionResponse); + assertTrue(((SDNCAdapterExceptionResponse) sdncAdapterResponse).getException() instanceof MismatchingMessageCorrelationException); + assertProcessInstanceNotFinished(pid); + + //System.out.println("SDNCAdapter bad RequestId test Completed!"); + } + + @Test + @Deployment(resources = {"subprocess/SDNCAdapterV1.bpmn"}) + public void badSynchronousResponse() throws IOException, InterruptedException { + + mockSDNCAdapter(404); + + //System.out.println("SDNCAdapter bad synchronous response flow Started!"); + + ProcessExecutionThread thread = new ProcessExecutionThread(sdncAdapterWorkflowRequest); + thread.start(); + while (thread.isAlive()) { + Thread.sleep(200); + } + WorkflowResponse response = thread.workflowResponse; + Assert.assertNotNull(response); + Assert.assertEquals("404 error", response.getMessageCode(),7000); +// assertProcessInstanceFinished(response.getProcessInstanceID()); + //System.out.println("SDNCAdapter bad synchronous response flow Completed!"); + } + + @Test + @Deployment(resources = {"subprocess/SDNCAdapterV1.bpmn"}) + public void sdncNotFound() throws IOException, InterruptedException { + mockSDNCAdapter(200); + mockSDNCAdapter("/sdncAdapterMock/404", 400, "sdncCallbackErrorResponse.xml"); + + ProcessExecutionThread thread = new ProcessExecutionThread(sdncAdapterWorkflowRequest); + thread.start(); + waitForExecutionToStart("sdncAdapter", 3); + String pid = getPid(); + + //System.out.println("Injecting SDNC Adapter asynchronous callback message to continue processing"); + String generatedRequestId = (String) processEngineRule.getRuntimeService().getVariable(pid, "SDNCA_requestId"); + CallbackHeader callbackHeader = new CallbackHeader(); + callbackHeader.setRequestId(generatedRequestId); + callbackHeader.setResponseCode("404"); + callbackHeader.setResponseMessage("Error processing request to SDNC. Not Found. https://sdncodl.it.us.aic.cip.att.com:8443/restconf/config/L3SDN-API:services/layer3-service-list/AS%2FVLXM%2F000199%2F%2FSB_INTERNET. SDNC Returned-[error-type:application, error-tag:data-missing, error-message:Request could not be completed because the relevant data model content does not exist.]"); + SDNCAdapterCallbackRequest sdncAdapterCallbackRequest = new SDNCAdapterCallbackRequest(); + sdncAdapterCallbackRequest.setCallbackHeader(callbackHeader); + SDNCAdapterCallbackServiceImpl callbackService = new SDNCAdapterCallbackServiceImpl(); + callbackService.setProcessEngineServices4junit(processEngineRule); + SDNCAdapterResponse sdncAdapterResponse = callbackService.sdncAdapterCallback(sdncAdapterCallbackRequest); + //System.out.println("Back from executing process again"); + + assertProcessInstanceFinished(pid); + assertNotNull(sdncAdapterResponse); + //TODO query history to see SDNCA_ResponseCode, SDNCA_ErrorResponse + //System.out.println("SDNCAdapter SDNC Notfound test Completed!"); + } + + @Test + @Deployment(resources = {"subprocess/SDNCAdapterV1.bpmn"}) + public void asynchronousMessageTimeout() throws IOException, InterruptedException { + mockSDNCAdapter(200); + //System.out.println("SDNCAdapter asynchronous message timeout flow Started!"); + ProcessExecutionThread thread = new ProcessExecutionThread(sdncAdapterWorkflowRequest); + thread.start(); + waitForExecutionToStart("sdncAdapter", 3); + checkForTimeout(getPid()); + } + + private void checkForTimeout(String pid) throws InterruptedException { + + assertProcessInstanceNotFinished(pid); + + ProcessEngineConfigurationImpl processEngineConfiguration = + (ProcessEngineConfigurationImpl) processEngineRule.getProcessEngine().getProcessEngineConfiguration(); + assertTrue(processEngineConfiguration.getJobExecutor().isActive()); + + Job timerJob = processEngineRule.getManagementService().createJobQuery().processInstanceId(pid).singleResult(); + assertNotNull(timerJob); + + processEngineRule.getManagementService().executeJob(timerJob.getId()); + + assertProcessInstanceFinished(pid); + + //System.out.println("SDNCAdapter asynchronous message timeout flow Completed!"); + } + + class ProcessExecutionThread extends Thread { + + private String workflowRequest; + private WorkflowResponse workflowResponse; + + public ProcessExecutionThread(String workflowRequest) { + this.workflowRequest = workflowRequest; + } + + public void run() { + workflowResponse = invokeFlow(workflowRequest); + workflowResponse.getProcessInstanceID(); + } + } + + private String getPid() { + return processEngineRule.getHistoryService().createHistoricProcessInstanceQuery().list().get(0).getId(); + } + + private Object getVariable(String pid, String variableName) { + try { + return + processEngineRule + .getHistoryService() + .createHistoricVariableInstanceQuery() + .processInstanceId(pid).variableName(variableName) + .singleResult() + .getValue(); + } catch(Exception ex) { + return null; + } + } + + private void assertProcessInstanceFinished(String pid) { + assertEquals(1, processEngineRule.getHistoryService().createHistoricProcessInstanceQuery().processInstanceId(pid).finished().count()); + } + + private void assertProcessInstanceNotFinished(String pid) { + assertEquals(0, processEngineRule.getHistoryService().createHistoricProcessInstanceQuery().processInstanceId(pid).finished().count()); + } + +} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/UpdateAAIGenericVnfTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/UpdateAAIGenericVnfTest.java new file mode 100644 index 0000000000..4ae76206cc --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/UpdateAAIGenericVnfTest.java @@ -0,0 +1,171 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common; + +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfByIdWithDepth; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfById_404; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutGenericVnf; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutGenericVnf_Bad; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +import org.camunda.bpm.engine.test.Deployment; +import org.junit.Assert; +import org.junit.Test; +import org.openecomp.mso.bpmn.core.WorkflowException; +import org.openecomp.mso.bpmn.mock.FileUtil; + +/** + * Unit tests for UpdateAAIGenericVnf bpmn. + */ +public class UpdateAAIGenericVnfTest extends WorkflowTest { + + /** + * Test the happy path through the flow. + */ + @Test + @Deployment(resources = { + "subprocess/UpdateAAIGenericVnf.bpmn" + }) + public void happyPath() throws IOException { + logStart(); + + String updateAAIGenericVnfRequest = FileUtil.readResourceFile("__files/VfModularity/UpdateAAIGenericVnfRequest.xml"); + MockGetGenericVnfByIdWithDepth("skask", 1, "VfModularity/GenericVnf.xml"); + MockPutGenericVnf("/skask", 200); + + String businessKey = UUID.randomUUID().toString(); + Map<String, Object> variables = new HashMap<String, Object>(); + variables.put("mso-request-id", "999-99-9999"); + variables.put("isDebugLogEnabled","true"); + variables.put("UpdateAAIGenericVnfRequest", updateAAIGenericVnfRequest); + invokeSubProcess("UpdateAAIGenericVnf", businessKey, variables); + + Assert.assertTrue(isProcessEnded(businessKey)); + String response = (String) getVariableFromHistory(businessKey, "UAAIGenVnf_updateGenericVnfResponse"); + Integer responseCode = (Integer) getVariableFromHistory(businessKey, "UAAIGenVnf_updateGenericVnfResponseCode"); + System.out.println("Subflow response code: " + responseCode); + System.out.println("Subflow response: " + response); + Assert.assertEquals(200, responseCode.intValue()); + + logEnd(); + } + + /** + * Test the happy path through the flow. + */ + @Test + @Deployment(resources = { + "subprocess/UpdateAAIGenericVnf.bpmn" + }) + public void personaMismatch() throws IOException { + + logStart(); + + String updateAAIGenericVnfRequest = FileUtil.readResourceFile("__files/VfModularity/UpdateAAIGenericVnfRequest.xml"); + updateAAIGenericVnfRequest = updateAAIGenericVnfRequest.replaceFirst("introvert", "extrovert"); + + MockGetGenericVnfByIdWithDepth("skask", 1, "VfModularity/GenericVnf.xml"); + + String businessKey = UUID.randomUUID().toString(); + Map<String, Object> variables = new HashMap<String, Object>(); + variables.put("mso-request-id", "999-99-9999"); + variables.put("isDebugLogEnabled","true"); + variables.put("UpdateAAIGenericVnfRequest", updateAAIGenericVnfRequest); + invokeSubProcess("UpdateAAIGenericVnf", businessKey, variables); + + Assert.assertTrue(isProcessEnded(businessKey)); + WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException"); + System.out.println("Workflow Exception: " + workflowException); + Assert.assertNotNull(workflowException); + + logEnd(); + } + + /** + * Test the case where the GET to AAI returns a 404. + */ + @Test + @Deployment(resources = { + "subprocess/UpdateAAIGenericVnf.bpmn" + }) + public void badGet() throws IOException { + + logStart(); + + String updateAAIGenericVnfRequest = FileUtil.readResourceFile("__files/VfModularity/UpdateAAIGenericVnfRequest.xml"); + + MockGetGenericVnfById_404("skask[?]depth=1"); + + String businessKey = UUID.randomUUID().toString(); + Map<String, Object> variables = new HashMap<String, Object>(); + variables.put("mso-request-id", "999-99-9999"); + variables.put("isDebugLogEnabled","true"); + variables.put("UpdateAAIGenericVnfRequest", updateAAIGenericVnfRequest); + invokeSubProcess("UpdateAAIGenericVnf", businessKey, variables); + + Assert.assertTrue(isProcessEnded(businessKey)); + String response = (String) getVariableFromHistory(businessKey, "UAAIGenVnf_getGenericVnfResponse"); + Integer responseCode = (Integer) getVariableFromHistory(businessKey, "UAAIGenVnf_getGenericVnfResponseCode"); + System.out.println("Subflow response code: " + responseCode); + System.out.println("Subflow response: " + response); + Assert.assertEquals(404, responseCode.intValue()); + + logEnd(); + } + + /** + * Test the case where the GET to AAI is successful, but he subsequent PUT returns 404. + */ + @Test + @Deployment(resources = { + "subprocess/UpdateAAIGenericVnf.bpmn" + }) + public void badPut() throws IOException { + + logStart(); + + String updateAAIGenericVnfRequest = FileUtil.readResourceFile("__files/VfModularity/UpdateAAIGenericVnfRequest.xml"); + + MockGetGenericVnfByIdWithDepth("skask", 1, "VfModularity/GenericVnf.xml"); + MockPutGenericVnf_Bad("skask", 404); + + String businessKey = UUID.randomUUID().toString(); + Map<String, Object> variables = new HashMap<String, Object>(); + variables.put("mso-request-id", "999-99-9999"); + variables.put("isDebugLogEnabled","true"); + variables.put("UpdateAAIGenericVnfRequest", updateAAIGenericVnfRequest); + invokeSubProcess("UpdateAAIGenericVnf", businessKey, variables); + + Assert.assertTrue(isProcessEnded(businessKey)); + String response = (String) getVariableFromHistory(businessKey, "UAAIGenVnf_updateGenericVnfResponse"); + Integer responseCode = (Integer) getVariableFromHistory(businessKey, "UAAIGenVnf_updateGenericVnfResponseCode"); + System.out.println("Subflow response code: " + responseCode); + System.out.println("Subflow response: " + response); + Assert.assertEquals(404, responseCode.intValue()); + + logEnd(); + } +} + diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/UpdateAAIVfModuleTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/UpdateAAIVfModuleTest.java new file mode 100644 index 0000000000..8691ae8e61 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/UpdateAAIVfModuleTest.java @@ -0,0 +1,137 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common; + +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfById; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfByIdWithPriority; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfById_404; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutGenericVnf; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +import org.camunda.bpm.engine.test.Deployment; +import org.junit.Assert; +import org.junit.Test; +import org.openecomp.mso.bpmn.mock.FileUtil; + +/** + * Unit tests for UpdateAAIVfModuleTest.bpmn. + */ +public class UpdateAAIVfModuleTest extends WorkflowTest { + + /** + * Test the happy path through the flow. + */ + @Test + @Deployment(resources = { + "subprocess/UpdateAAIVfModule.bpmn" + }) + public void happyPath() throws IOException { + logStart(); + + String updateAAIVfModuleRequest = FileUtil.readResourceFile("__files/VfModularity/UpdateAAIVfModuleRequest.xml"); + MockGetGenericVnfByIdWithPriority("/skask/vf-modules/vf-module/supercool", 200, "VfModularity/VfModule-supercool.xml"); + MockPutGenericVnf("/skask/vf-modules/vf-module/supercool", "PCRF", 200); + + String businessKey = UUID.randomUUID().toString(); + Map<String, Object> variables = new HashMap<String, Object>(); + variables.put("mso-request-id", "999-99-9999"); + variables.put("isDebugLogEnabled","true"); + variables.put("UpdateAAIVfModuleRequest", updateAAIVfModuleRequest); + invokeSubProcess("UpdateAAIVfModule", businessKey, variables); + + Assert.assertTrue(isProcessEnded(businessKey)); + String response = (String) getVariableFromHistory(businessKey, "UAAIVfMod_updateVfModuleResponse"); + Integer responseCode = (Integer) getVariableFromHistory(businessKey, "UAAIVfMod_updateVfModuleResponseCode"); + System.out.println("Subflow response code: " + responseCode); + System.out.println("Subflow response: " + response); + Assert.assertEquals(200, responseCode.intValue()); + + logEnd(); + } + + /** + * Test the case where the GET to AAI returns a 404. + */ + @Test + @Deployment(resources = { + "subprocess/UpdateAAIVfModule.bpmn" + }) + public void badGet() throws IOException { + + logStart(); + + String updateAAIVfModuleRequest = FileUtil.readResourceFile("__files/VfModularity/UpdateAAIVfModuleRequest.xml"); + MockGetGenericVnfById("/skask/vf-modules/vf-module/.*", "VfModularity/VfModule-supercool.xml", 404); + + String businessKey = UUID.randomUUID().toString(); + Map<String, Object> variables = new HashMap<String, Object>(); + variables.put("mso-request-id", "999-99-9999"); + variables.put("isDebugLogEnabled","true"); + variables.put("UpdateAAIVfModuleRequest", updateAAIVfModuleRequest); + invokeSubProcess("UpdateAAIVfModule", businessKey, variables); + + Assert.assertTrue(isProcessEnded(businessKey)); + String response = (String) getVariableFromHistory(businessKey, "UAAIVfMod_getVfModuleResponse"); + Integer responseCode = (Integer) getVariableFromHistory(businessKey, "UAAIVfMod_getVfModuleResponseCode"); + System.out.println("Subflow response code: " + responseCode); + System.out.println("Subflow response: " + response); + Assert.assertEquals(404, responseCode.intValue()); + + logEnd(); + } + + /** + * Test the case where the GET to AAI is successful, but he subsequent PUT returns 404. + */ + @Test + @Deployment(resources = { + "subprocess/UpdateAAIVfModule.bpmn" + }) + public void badPut() throws IOException { + + logStart(); + + String updateAAIVfModuleRequest = FileUtil.readResourceFile("__files/VfModularity/UpdateAAIVfModuleRequest.xml"); + MockGetGenericVnfById_404("/skask/vf-modules/vf-module/supercool"); + MockGetGenericVnfById("/skask/vf-modules/vf-module/supercool", "VfModularity/VfModule-supercool.xml", 200); + + String businessKey = UUID.randomUUID().toString(); + Map<String, Object> variables = new HashMap<String, Object>(); + variables.put("mso-request-id", "999-99-9999"); + variables.put("isDebugLogEnabled","true"); + variables.put("UpdateAAIVfModuleRequest", updateAAIVfModuleRequest); + invokeSubProcess("UpdateAAIVfModule", businessKey, variables); + + Assert.assertTrue(isProcessEnded(businessKey)); + String response = (String) getVariableFromHistory(businessKey, "UAAIVfMod_updateVfModuleResponse"); + Integer responseCode = (Integer) getVariableFromHistory(businessKey, "UAAIVfMod_updateVfModuleResponseCode"); + System.out.println("Subflow response code: " + responseCode); + System.out.println("Subflow response: " + response); + Assert.assertEquals(404, responseCode.intValue()); + + logEnd(); + } +} + diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/VnfAdapterRestV1Test.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/VnfAdapterRestV1Test.java new file mode 100644 index 0000000000..d2b0e274e9 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/VnfAdapterRestV1Test.java @@ -0,0 +1,389 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.openecomp.mso.bpmn.mock.StubResponseVNFAdapter.mockVNFDelete; +import static org.openecomp.mso.bpmn.mock.StubResponseVNFAdapter.mockVNFPost; +import static org.openecomp.mso.bpmn.mock.StubResponseVNFAdapter.mockVNFPut; +import static org.openecomp.mso.bpmn.mock.StubResponseVNFAdapter.mockVNFRollbackDelete; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +import org.camunda.bpm.engine.test.Deployment; +import org.junit.Test; +import org.openecomp.mso.bpmn.core.WorkflowException; + +/** + * Unit tests for VnfAdapterRestV1. + */ +public class VnfAdapterRestV1Test extends WorkflowTest { + + private static final String EOL = "\n"; + + private final CallbackSet callbacks = new CallbackSet(); + + private final String CREATE_VF_MODULE_REQUEST = + "<createVfModuleRequest>" + EOL + + " <cloudSiteId>cloudSiteId</cloudSiteId>" + EOL + + " <tenantId>tenantId</tenantId>" + EOL + + " <vnfId>vnfId</vnfId>" + EOL + + " <vfModuleName>vfModuleName</vfModuleName>" + EOL + + " <vfModuleId>vfModuleId</vfModuleId>" + EOL + + " <vnfType>vnfType</vnfType>" + EOL + + " <vnfVersion>vnfVersion</vnfVersion>" + EOL + + " <vfModuleType>vfModuleType</vfModuleType>" + EOL + + " <volumeGroupId>volumeGroupId</volumeGroupId>" + EOL + + " <volumeGroupStackId>volumeGroupStackId</volumeGroupStackId>" + EOL + + " <baseVfModuleId>baseVfModuleId</baseVfModuleId>" + EOL + + " <baseVfModuleStackId>baseVfModuleStackId</baseVfModuleStackId>" + EOL + + " <skipAAI>true</skipAAI>" + EOL + + " <backout>false</backout>" + EOL + + " <failIfExists>true</failIfExists>" + EOL + + " <vfModuleParams>" + EOL + + " <entry>" + EOL + + " <key>key1</key>" + EOL + + " <value>value1</value>" + EOL + + " </entry>" + EOL + + " <entry>" + EOL + + " <key>key2</key>" + EOL + + " <value>value2</value>" + EOL + + " </entry>" + EOL + + " </vfModuleParams>" + EOL + + " <msoRequest>" + EOL + + " <requestId>requestId</requestId>" + EOL + + " <serviceInstanceId>serviceInstanceId</serviceInstanceId>" + EOL + + " </msoRequest>" + EOL + + " <messageId>{{MESSAGE-ID}}</messageId>" + EOL + + " <notificationUrl>http://localhost:28080/mso/WorkflowMessage</notificationUrl>" + EOL + + "</createVfModuleRequest>" + EOL; + + private final String UPDATE_VF_MODULE_REQUEST = + "<updateVfModuleRequest>" + EOL + + " <cloudSiteId>cloudSiteId</cloudSiteId>" + EOL + + " <tenantId>tenantId</tenantId>" + EOL + + " <vnfId>vnfId</vnfId>" + EOL + + " <vfModuleName>vfModuleName</vfModuleName>" + EOL + + " <vfModuleId>vfModuleId</vfModuleId>" + EOL + + " <vfModuleStackId>vfModuleStackId</vfModuleStackId>" + EOL + + " <vnfType>vnfType</vnfType>" + EOL + + " <vnfVersion>vnfVersion</vnfVersion>" + EOL + + " <vfModuleType>vfModuleType</vfModuleType>" + EOL + + " <volumeGroupId>volumeGroupId</volumeGroupId>" + EOL + + " <volumeGroupStackId>volumeGroupStackId</volumeGroupStackId>" + EOL + + " <baseVfModuleId>baseVfModuleId</baseVfModuleId>" + EOL + + " <baseVfModuleStackId>baseVfModuleStackId</baseVfModuleStackId>" + EOL + + " <skipAAI>true</skipAAI>" + EOL + + " <backout>false</backout>" + EOL + + " <failIfExists>true</failIfExists>" + EOL + + " <vfModuleParams>" + EOL + + " <entry>" + EOL + + " <key>key1</key>" + EOL + + " <value>value1</value>" + EOL + + " </entry>" + EOL + + " <entry>" + EOL + + " <key>key2</key>" + EOL + + " <value>value2</value>" + EOL + + " </entry>" + EOL + + " </vfModuleParams>" + EOL + + " <msoRequest>" + EOL + + " <requestId>requestId</requestId>" + EOL + + " <serviceInstanceId>serviceInstanceId</serviceInstanceId>" + EOL + + " </msoRequest>" + EOL + + " <messageId>{{MESSAGE-ID}}</messageId>" + EOL + + " <notificationUrl>http://localhost:28080/mso/WorkflowMessage</notificationUrl>" + EOL + + "</updateVfModuleRequest>" + EOL; + + private final String DELETE_VF_MODULE_REQUEST = + "<deleteVfModuleRequest>" + EOL + + " <cloudSiteId>cloudSiteId</cloudSiteId>" + EOL + + " <tenantId>tenantId</tenantId>" + EOL + + " <vnfId>vnfId</vnfId>" + EOL + + " <vfModuleId>vfModuleId</vfModuleId>" + EOL + + " <vfModuleStackId>vfModuleStackId</vfModuleStackId>" + EOL + + " <skipAAI>true</skipAAI>" + EOL + + " <msoRequest>" + EOL + + " <requestId>requestId</requestId>" + EOL + + " <serviceInstanceId>serviceInstanceId</serviceInstanceId>" + EOL + + " </msoRequest>" + EOL + + " <messageId>{{MESSAGE-ID}}</messageId>" + EOL + + " <notificationUrl>http://localhost:28080/mso/WorkflowMessage</notificationUrl>" + EOL + + "</deleteVfModuleRequest>" + EOL; + + private final String ROLLBACK_VF_MODULE_REQUEST = + "<rollbackVfModuleRequest>" + EOL + + " <messageId>{{MESSAGE-ID}}</messageId>" + EOL + + " <notificationUrl>http://localhost:28080/mso/WorkflowMessage</notificationUrl>" + EOL + + " <skipAAI>true</skipAAI>" + EOL + + " <vfModuleRollback>" + EOL + + " <cloudSiteId>cloudSiteId</cloudSiteId>" + EOL + + " <tenantId>tenantId</tenantId>" + EOL + + " <vnfId>vnfId</vnfId>" + EOL + + " <vfModuleId>vfModuleId</vfModuleId>" + EOL + + " <vfModuleStackId>vfModuleStackId</vfModuleStackId>" + EOL + + " <msoRequest>" + EOL + + " <requestId>requestId</requestId>" + EOL + + " <serviceInstanceId>serviceInstanceId</serviceInstanceId>" + EOL + + " </msoRequest>" + EOL + + " <messageId>{{MESSAGE-ID}}</messageId>" + EOL + + " <vfModuleCreated>true</vfModuleCreated>" + EOL + + " </vfModuleRollback>" + EOL + + "</rollbackVfModuleRequest>" + EOL; + + public VnfAdapterRestV1Test() throws IOException { + callbacks.put("createVfModule", + "<createVfModuleResponse>" + EOL + + " <vnfId>vnfId</vnfId>" + EOL + + " <vfModuleId>vfModuleId</vfModuleId>" + EOL + + " <vfModuleStackId>vfModuleStackId</vfModuleStackId>" + EOL + + " <vfModuleCreated>true</vfModuleCreated>" + EOL + + " <vfModuleOutputs>" + EOL + + " <entry>" + EOL + + " <key>key1</key>" + EOL + + " <value>value1</value>" + EOL + + " </entry>" + EOL + + " <entry>" + EOL + + " <key>key2</key>" + EOL + + " <value>value2</value>" + EOL + + " </entry>" + EOL + + " </vfModuleOutputs>" + EOL + + " <rollback>" + EOL + + " <vnfId>vnfId</vnfId>" + EOL + + " <vfModuleId>vfModuleId</vfModuleId>" + EOL + + " <vfModuleStackId>vfModuleStackId</vfModuleStackId>" + EOL + + " <vfModuleCreated>true</vfModuleCreated>" + EOL + + " <tenantId>tenantId</tenantId>" + EOL + + " <cloudSiteId>cloudSiteId</cloudSiteId>" + EOL + + " <msoRequest>" + EOL + + " <requestId>requestId</requestId>" + EOL + + " <serviceInstanceId>serviceInstanceId</serviceInstanceId>" + EOL + + " </msoRequest>" + EOL + + " <messageId>messageId</messageId>" + EOL + + " </rollback>" + EOL + + " <messageId>{{MESSAGE-ID}}</messageId>" + EOL + + "</createVfModuleResponse>" + EOL); + + callbacks.put("updateVfModule", + "<updateVfModuleResponse>" + EOL + + " <vnfId>vnfId</vnfId>" + EOL + + " <vfModuleId>vfModuleId</vfModuleId>" + EOL + + " <vfModuleStackId>vfModuleStackId</vfModuleStackId>" + EOL + + " <vfModuleOutputs>" + EOL + + " <entry>" + EOL + + " <key>key1</key>" + EOL + + " <value>value1</value>" + EOL + + " </entry>" + EOL + + " <entry>" + EOL + + " <key>key2</key>" + EOL + + " <value>value2</value>" + EOL + + " </entry>" + EOL + + " </vfModuleOutputs>" + EOL + + " <messageId>{{MESSAGE-ID}}</messageId>" + EOL + + "</updateVfModuleResponse>" + EOL); + + callbacks.put("deleteVfModule", + "<deleteVfModuleResponse>" + EOL + + " <vnfId>vnfId</vnfId>" + EOL + + " <vfModuleId>vfModuleId</vfModuleId>" + EOL + + " <vfModuleDeleted>true</vfModuleDeleted>" + EOL + + " <messageId>{{MESSAGE-ID}}</messageId>" + EOL + + "</deleteVfModuleResponse>" + EOL); + + callbacks.put("rollbackVfModule", + "<rollbackVfModuleResponse>" + EOL + + " <messageId>{{MESSAGE-ID}}</messageId>" + EOL + + " <vfModuleRolledback>true</vfModuleRolledback>" + EOL + + "</rollbackVfModuleResponse>" + EOL); + + callbacks.put("vfModuleException", + "<vfModuleException>" + EOL + + " <message>message</message>" + EOL + + " <category>category</category>" + EOL + + " <rolledBack>false</rolledBack>" + EOL + + " <messageId>{{MESSAGE-ID}}</messageId>" + EOL + + "</vfModuleException>" + EOL); + } + + @Test + @Deployment(resources = { + "subprocess/VnfAdapterRestV1.bpmn" + }) + public void testCreateVfModuleSuccess() throws Exception { + logStart(); + + mockVNFPost("", 202, "vnfId"); + + String requestId = "dffbae0e-5588-4bd6-9749-b0f0adb52312"; + String messageId = requestId + "-" + System.currentTimeMillis(); + String request = CREATE_VF_MODULE_REQUEST.replace("{{MESSAGE-ID}}", messageId); + + String businessKey = UUID.randomUUID().toString(); + Map<String, Object> variables = new HashMap<String, Object>(); + variables.put("mso-request-id", requestId); + variables.put("isDebugLogEnabled", "true"); + variables.put("vnfAdapterRestV1Request", request); + + invokeSubProcess("vnfAdapterRestV1", businessKey, variables); + injectVNFRestCallbacks(callbacks, "createVfModule"); + waitForProcessEnd(businessKey, 10000); + + String response = (String) getVariableFromHistory(businessKey, "vnfAdapterRestV1Response"); + System.out.println("Response:\n" + response); + assertTrue(response.contains("<createVfModuleResponse>")); + assertTrue((boolean) getVariableFromHistory(businessKey, "VNFREST_SuccessIndicator")); + + logEnd(); + } + + @Test + @Deployment(resources = { + "subprocess/VnfAdapterRestV1.bpmn" + }) + public void testUpdateVfModuleSuccess() throws Exception { + logStart(); + + mockVNFPut("/vfModuleId", 202); + + String requestId = "dffbae0e-5588-4bd6-9749-b0f0adb52312"; + String messageId = requestId + "-" + System.currentTimeMillis(); + String request = UPDATE_VF_MODULE_REQUEST.replace("{{MESSAGE-ID}}", messageId); + + String businessKey = UUID.randomUUID().toString(); + Map<String, Object> variables = new HashMap<String, Object>(); + variables.put("mso-request-id", requestId); + variables.put("isDebugLogEnabled", "true"); + variables.put("vnfAdapterRestV1Request", request); + + invokeSubProcess("vnfAdapterRestV1", businessKey, variables); + injectVNFRestCallbacks(callbacks, "updateVfModule"); + waitForProcessEnd(businessKey, 10000); + + String response = (String) getVariableFromHistory(businessKey, "vnfAdapterRestV1Response"); + System.out.println("Response:\n" + response); + assertTrue(response.contains("<updateVfModuleResponse>")); + assertTrue((boolean) getVariableFromHistory(businessKey, "VNFREST_SuccessIndicator")); + + logEnd(); + } + + @Test + @Deployment(resources = { + "subprocess/VnfAdapterRestV1.bpmn" + }) + public void testDeleteVfModuleSuccess() throws Exception { + logStart(); + + mockVNFDelete("vnfId", "/vfModuleId", 202); + + String requestId = "dffbae0e-5588-4bd6-9749-b0f0adb52312"; + String messageId = requestId + "-" + System.currentTimeMillis(); + String request = DELETE_VF_MODULE_REQUEST.replace("{{MESSAGE-ID}}", messageId); + + String businessKey = UUID.randomUUID().toString(); + Map<String, Object> variables = new HashMap<String, Object>(); + variables.put("mso-request-id", requestId); + variables.put("isDebugLogEnabled", "true"); + variables.put("vnfAdapterRestV1Request", request); + + invokeSubProcess("vnfAdapterRestV1", businessKey, variables); + injectVNFRestCallbacks(callbacks, "deleteVfModule"); + waitForProcessEnd(businessKey, 10000); + + String response = (String) getVariableFromHistory(businessKey, "vnfAdapterRestV1Response"); + System.out.println("Response:\n" + response); + assertTrue(response.contains("<deleteVfModuleResponse>")); + assertTrue((boolean) getVariableFromHistory(businessKey, "VNFREST_SuccessIndicator")); + + logEnd(); + } + + @Test + @Deployment(resources = { + "subprocess/VnfAdapterRestV1.bpmn" + }) + public void testRollbackVfModuleSuccess() throws Exception { + logStart(); + + mockVNFRollbackDelete("/vfModuleId", 202); + + String requestId = "dffbae0e-5588-4bd6-9749-b0f0adb52312"; + String messageId = requestId + "-" + System.currentTimeMillis(); + String request = ROLLBACK_VF_MODULE_REQUEST.replace("{{MESSAGE-ID}}", messageId); + + String businessKey = UUID.randomUUID().toString(); + Map<String, Object> variables = new HashMap<String, Object>(); + variables.put("mso-request-id", requestId); + variables.put("isDebugLogEnabled", "true"); + variables.put("vnfAdapterRestV1Request", request); + + invokeSubProcess("vnfAdapterRestV1", businessKey, variables); + injectVNFRestCallbacks(callbacks, "rollbackVfModule"); + waitForProcessEnd(businessKey, 10000); + + String response = (String) getVariableFromHistory(businessKey, "vnfAdapterRestV1Response"); + System.out.println("Response:\n" + response); + assertTrue(response.contains("<rollbackVfModuleResponse>")); + assertTrue((boolean) getVariableFromHistory(businessKey, "VNFREST_SuccessIndicator")); + + logEnd(); + } + + @Test + @Deployment(resources = { + "subprocess/VnfAdapterRestV1.bpmn" + }) + public void testCreateVfModuleException() throws Exception { + logStart(); + + mockVNFPost("", 202, "vnfId"); + + String requestId = "dffbae0e-5588-4bd6-9749-b0f0adb52312"; + String messageId = requestId + "-" + System.currentTimeMillis(); + String request = CREATE_VF_MODULE_REQUEST.replace("{{MESSAGE-ID}}", messageId); + + String businessKey = UUID.randomUUID().toString(); + Map<String, Object> variables = new HashMap<String, Object>(); + variables.put("mso-request-id", requestId); + variables.put("isDebugLogEnabled", "true"); + variables.put("vnfAdapterRestV1Request", request); + + invokeSubProcess("vnfAdapterRestV1", businessKey, variables); + injectVNFRestCallbacks(callbacks, "vfModuleException"); + waitForProcessEnd(businessKey, 10000); + + WorkflowException wfe = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException"); + assertNotNull(wfe); + System.out.println(wfe.toString()); + + String response = (String) getVariableFromHistory(businessKey, "WorkflowResponse"); + System.out.println("Response:\n" + response); + assertTrue(response.contains("<vfModuleException>")); + assertFalse((boolean) getVariableFromHistory(businessKey, "VNFREST_SuccessIndicator")); + + logEnd(); + } +} + diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/WorkflowAsyncResourceTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/WorkflowAsyncResourceTest.java new file mode 100644 index 0000000000..4ac885fd9d --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/WorkflowAsyncResourceTest.java @@ -0,0 +1,96 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common; + +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.mock; + +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +import org.camunda.bpm.engine.test.Deployment; +import org.camunda.bpm.engine.variable.impl.VariableMapImpl; +import org.jboss.resteasy.spi.AsynchronousResponse; +import org.junit.Test; +import org.openecomp.mso.bpmn.common.workflow.service.WorkflowAsyncCommonResource; +import org.openecomp.mso.bpmn.common.workflow.service.WorkflowResponse; + +public class WorkflowAsyncResourceTest extends WorkflowTest { + + @Test + @Deployment(resources = { "testAsyncResource.bpmn" }) + public void asyncRequestSuccess() throws InterruptedException { + //it can be any request which asynchronously processed by the workflow + String request = "<aetgt:CreateTenantRequest xmlns:aetgt=\"http://org.openecomp/mso/workflow/schema/v1\" xmlns:sdncadapterworkflow=\"http://org.openecomp/mso/workflow/schema/v1\" xmlns:ns5=\"http://org.openecomp/mso/request/types/v1\"> <msoservtypes:service-information xmlns:msoservtypes=\"http://org.openecomp/mso/request/types/v1\"> <msoservtypes:service-type>SDN-ETHERNET-INTERNET</msoservtypes:service-type> <msoservtypes:service-instance-id>HI/VLXM/950604//SW_INTERNET</msoservtypes:service-instance-id> <msoservtypes:subscriber-name>SubName01</msoservtypes:subscriber-name> </msoservtypes:service-information> </aetgt:CreateTenantRequest>"; + + Map<String,String> variables = new HashMap<String,String>(); + variables.put("testAsyncRequestMsg", request); + variables.put("mso-request-id", UUID.randomUUID().toString()); + variables.put("mso-service-request-timeout", "5"); + + WorkflowResponse workflowResponse = BPMNUtil.executeAsyncWorkflow(processEngineRule, "testAsyncProcess", variables); + assertEquals("Received the request, the process is getting executed, request message<aetgt:CreateTenantRequest xmlns:aetgt=\"http://org.openecomp/mso/workflow/schema/v1\" xmlns:sdncadapterworkflow=\"http://org.openecomp/mso/workflow/schema/v1\" xmlns:ns5=\"http://org.openecomp/mso/request/types/v1\"> <msoservtypes:service-information xmlns:msoservtypes=\"http://org.openecomp/mso/request/types/v1\"> <msoservtypes:service-type>SDN-ETHERNET-INTERNET</msoservtypes:service-type> <msoservtypes:service-instance-id>HI/VLXM/950604//SW_INTERNET</msoservtypes:service-instance-id> <msoservtypes:subscriber-name>SubName01</msoservtypes:subscriber-name> </msoservtypes:service-information> </aetgt:CreateTenantRequest>", workflowResponse.getResponse()); + assertEquals(200, workflowResponse.getMessageCode()); + } + + private void executeWorkflow(String request, String requestId, AsynchronousResponse asyncResponse, String processKey) { + WorkflowAsyncCommonResource workflowResource = new WorkflowAsyncCommonResource(); + VariableMapImpl variableMap = new VariableMapImpl(); + + Map<String, Object> variableValueType = new HashMap<String, Object>(); + + Map<String, Object> requestMsg = new HashMap<String, Object>(); + requestMsg.put("value", request); + requestMsg.put("type", "String"); + + Map<String, Object> msorequestId = new HashMap<String, Object>(); + msorequestId.put("type", "String"); + msorequestId.put("value",requestId); + + Map<String, Object> timeout = new HashMap<String, Object>(); + timeout.put("type", "String"); + timeout.put("value","5"); + + variableValueType.put("testAsyncRequestMsg", requestMsg); + variableValueType.put("mso-request-id", msorequestId); + variableValueType.put("mso-service-request-timeout", timeout); + + variableMap.put("variables", variableValueType); + + workflowResource.setProcessEngineServices4junit(processEngineRule); + workflowResource.startProcessInstanceByKey(asyncResponse, processKey, variableMap); + } + + class ProcessThread extends Thread { + + public WorkflowResponse workflowResponse; + public String requestId; + public String processKey; + public AsynchronousResponse asyncResponse = mock(AsynchronousResponse.class); + public String request; + public boolean started; + public void run() { + started = true; + executeWorkflow(request, requestId, asyncResponse, processKey); + } + } +} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/WorkflowContextHolderTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/WorkflowContextHolderTest.java new file mode 100644 index 0000000000..bff193ffdd --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/WorkflowContextHolderTest.java @@ -0,0 +1,97 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common; + +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; + +import java.util.UUID; + +import javax.ws.rs.core.Response; + +import org.jboss.resteasy.spi.AsynchronousResponse; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; +import org.openecomp.mso.bpmn.common.workflow.service.WorkflowCallbackResponse; +import org.openecomp.mso.bpmn.common.workflow.service.WorkflowContext; +import org.openecomp.mso.bpmn.common.workflow.service.WorkflowContextHolder; +import org.openecomp.mso.bpmn.common.workflow.service.WorkflowResponse; + +public class WorkflowContextHolderTest { + + private WorkflowContext createContext(AsynchronousResponse asyncResponse) { + WorkflowContextHolder contextHolder = WorkflowContextHolder.getInstance(); + String requestId = UUID.randomUUID().toString(); + WorkflowContext workflowContext = new WorkflowContext("testAsyncProcess", + requestId, asyncResponse, 1000L); + contextHolder.put(workflowContext); + return workflowContext; + } + + @Test + @Ignore // BROKEN TEST (previously ignored) + public void testContextExpiry() throws InterruptedException { + + WorkflowContextHolder contextHolder = WorkflowContextHolder.getInstance(); + AsynchronousResponse asyncResponse = mock(AsynchronousResponse.class); + WorkflowContext workflowContext = createContext(asyncResponse); + String requestId = workflowContext.getRequestId(); + WorkflowContext context1 = contextHolder.getWorkflowContext(requestId); + + Assert.assertNotNull(context1); + Assert.assertEquals(requestId, context1.getRequestId()); + Assert.assertEquals(workflowContext.getProcessKey(), context1.getProcessKey()); + Assert.assertEquals(workflowContext.getStartTime(), context1.getStartTime()); + + Thread.sleep(1000); + //context should not be available after a second + WorkflowContext context2 = contextHolder.getWorkflowContext(requestId); + Assert.assertNull(context2); + } + + @Test + public void testProcessCallback() { + WorkflowContextHolder contextHolder = WorkflowContextHolder.getInstance(); + AsynchronousResponse asyncResponse = mock(AsynchronousResponse.class); + WorkflowContext workflowContext = createContext(asyncResponse); + + WorkflowCallbackResponse callbackResponse = new WorkflowCallbackResponse(); + callbackResponse.setMessage("Success"); + callbackResponse.setResponse("Successfully processed request"); + callbackResponse.setStatusCode(200); + + Response response = contextHolder.processCallback("testAsyncProcess", + "process-instance-id", workflowContext.getRequestId(), + callbackResponse); + WorkflowResponse response1 = (WorkflowResponse) response.getEntity(); + Assert.assertNotNull(response1.getMessage()); + Assert.assertEquals(200,response1.getMessageCode()); + Assert.assertEquals("Success", response1.getMessage()); + Assert.assertEquals("Successfully processed request", response1.getResponse()); + verify(asyncResponse).setResponse(any(Response.class)); + + WorkflowContext context1 = contextHolder.getWorkflowContext(workflowContext.getRequestId()); + Assert.assertNull(context1); + } + +} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/WorkflowTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/WorkflowTest.java new file mode 100644 index 0000000000..c47521384b --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/WorkflowTest.java @@ -0,0 +1,1796 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +import java.io.IOException; +import java.io.StringReader; +import java.lang.management.ManagementFactory; +import java.lang.management.RuntimeMXBean; +import java.lang.reflect.Field; +import java.lang.reflect.Modifier; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +import javax.ws.rs.core.Response; +import javax.xml.bind.JAXBException; +import javax.xml.namespace.NamespaceContext; +import javax.xml.namespace.QName; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.xpath.XPath; +import javax.xml.xpath.XPathConstants; +import javax.xml.xpath.XPathExpression; +import javax.xml.xpath.XPathExpressionException; +import javax.xml.xpath.XPathFactory; + +import org.camunda.bpm.engine.RuntimeService; +import org.camunda.bpm.engine.history.HistoricProcessInstance; +import org.camunda.bpm.engine.history.HistoricVariableInstance; +import org.camunda.bpm.engine.runtime.ProcessInstance; +import org.camunda.bpm.engine.test.ProcessEngineRule; +import org.camunda.bpm.engine.variable.impl.VariableMapImpl; +import org.custommonkey.xmlunit.DetailedDiff; +import org.custommonkey.xmlunit.XMLUnit; +import org.jboss.resteasy.spi.AsynchronousResponse; +import org.junit.Before; +import org.junit.Rule; +import org.openecomp.mso.bpmn.common.adapter.sdnc.CallbackHeader; +import org.openecomp.mso.bpmn.common.adapter.sdnc.SDNCAdapterCallbackRequest; +import org.openecomp.mso.bpmn.common.adapter.sdnc.SDNCAdapterResponse; +import org.openecomp.mso.bpmn.common.adapter.vnf.CreateVnfNotification; +import org.openecomp.mso.bpmn.common.adapter.vnf.DeleteVnfNotification; +import org.openecomp.mso.bpmn.common.adapter.vnf.MsoExceptionCategory; +import org.openecomp.mso.bpmn.common.adapter.vnf.MsoRequest; +import org.openecomp.mso.bpmn.common.adapter.vnf.UpdateVnfNotification; +import org.openecomp.mso.bpmn.common.adapter.vnf.VnfRollback; +import org.openecomp.mso.bpmn.common.workflow.service.SDNCAdapterCallbackServiceImpl; +import org.openecomp.mso.bpmn.common.workflow.service.VnfAdapterNotifyServiceImpl; +import org.openecomp.mso.bpmn.common.workflow.service.WorkflowAsyncCommonResource; +import org.openecomp.mso.bpmn.common.workflow.service.WorkflowMessageResource; +import org.openecomp.mso.bpmn.common.workflow.service.WorkflowResponse; +import org.openecomp.mso.bpmn.core.CamundaDBSetup; +import org.openecomp.mso.bpmn.core.PropertyConfigurationSetup; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; + +import com.github.tomakehurst.wiremock.core.WireMockConfiguration; +import com.github.tomakehurst.wiremock.extension.ResponseTransformer; +import com.github.tomakehurst.wiremock.junit.WireMockRule; + + + +/** + * A base class for Workflow tests. + * <p> + * WireMock response transformers may be specified by declaring public + * static fields with the @WorkflowTestTransformer annotation. For example: + * <pre> + * @WorkflowTestTransformer + * public static final ResponseTransformer sdncAdapterMockTransformer = + * new SDNCAdapterMockTransformer(); + * </pre> + */ +public class WorkflowTest { + @Rule + public final ProcessEngineRule processEngineRule = new ProcessEngineRule(); + + @Rule + public final WireMockRule wireMockRule; + + /** + * Constructor. + */ + public WorkflowTest() throws RuntimeException { + // Process WorkflowTestTransformer annotations + List<ResponseTransformer> transformerList = new ArrayList<ResponseTransformer>(); + + for (Field field : getClass().getFields()) { + WorkflowTestTransformer annotation = (WorkflowTestTransformer) + field.getAnnotation(WorkflowTestTransformer.class); + + if (annotation == null) { + continue; + } + + if (!Modifier.isStatic(field.getModifiers())) { + throw new RuntimeException(field.getDeclaringClass().getName() + + "#" + field.getName() + " has a @WorkflowTestTransformer " + + " annotation but it is not declared static"); + } + + ResponseTransformer transformer; + + try { + transformer = (ResponseTransformer) field.get(null); + } catch (IllegalAccessException e) { + throw new RuntimeException(field.getDeclaringClass().getName() + + "#" + field.getName() + " is not accessible", e); + } catch (ClassCastException e) { + throw new RuntimeException(field.getDeclaringClass().getName() + + "#" + field.getName() + " is not a ResponseTransformer", e); + } + + if (transformer == null) { + continue; + } + + transformerList.add(transformer); + } + + ResponseTransformer[] transformerArray = + transformerList.toArray(new ResponseTransformer[transformerList.size()]); + + wireMockRule = new WireMockRule(WireMockConfiguration.wireMockConfig() + .port(28090).extensions(transformerArray)); + } + + @Before + public void testSetup() throws Exception { + CamundaDBSetup.configure(); + PropertyConfigurationSetup.init(); + } + + /** + * The current request ID. Normally set when an "invoke" method is called. + */ + protected volatile String msoRequestId = null; + + /** + * The current service instance ID. Normally set when an "invoke" method + * is called. + */ + protected volatile String msoServiceInstanceId = null; + + /** + * Logs a test start method. + */ + protected void logStart() { + StackTraceElement[] st = Thread.currentThread().getStackTrace(); + String method = st[2].getMethodName(); + System.out.println("STARTED TEST: " + method); + } + + /** + * Logs a test end method. + */ + protected void logEnd() { + StackTraceElement[] st = Thread.currentThread().getStackTrace(); + String method = st[2].getMethodName(); + System.out.println("ENDED TEST: " + method); + } + + /** + * Invokes a subprocess. + * @param processKey the process key + * @param businessKey a unique key that will identify the process instance + * @param injectedVariables variables to inject into the process + */ + protected void invokeSubProcess(String processKey, String businessKey, + Map<String, Object> injectedVariables) { + RuntimeMXBean runtimeMxBean = ManagementFactory.getRuntimeMXBean(); + List<String> arguments = runtimeMxBean.getInputArguments(); + System.out.println("JVM args = " + arguments); + + msoRequestId = (String) injectedVariables.get("mso-request-id"); + + if (msoRequestId == null) { + String msg = "mso-request-id variable was not provided"; + System.out.println(msg); + fail(msg); + } + + // Note: some scenarios don't have a service-instance-id, may be null + msoServiceInstanceId = (String) injectedVariables.get("mso-service-instance-id"); + + RuntimeService runtimeService = processEngineRule.getRuntimeService(); + runtimeService.startProcessInstanceByKey(processKey, businessKey, injectedVariables); + } + + /** + * Invokes an asynchronous process. + * Errors are handled with junit assertions and will cause the test to fail. + * @param processKey the process key + * @param schemaVersion the API schema version, e.g. "v1" + * @param businessKey a unique key that will identify the process instance + * @param request the request + * @return a TestAsyncResponse object associated with the test + */ + protected TestAsyncResponse invokeAsyncProcess(String processKey, + String schemaVersion, String businessKey, String request) { + return invokeAsyncProcess(processKey, schemaVersion, businessKey, request, null); + } + + /** + * Invokes an asynchronous process. + * Errors are handled with junit assertions and will cause the test to fail. + * @param processKey the process key + * @param schemaVersion the API schema version, e.g. "v1" + * @param businessKey a unique key that will identify the process instance + * @param request the request + * @param injectedVariables optional variables to inject into the process + * @return a TestAsyncResponse object associated with the test + */ + public TestAsyncResponse invokeAsyncProcess(String processKey, + String schemaVersion, String businessKey, String request, + Map<String, Object> injectedVariables) { + + RuntimeMXBean runtimeMxBean = ManagementFactory.getRuntimeMXBean(); + List<String> arguments = runtimeMxBean.getInputArguments(); + System.out.println("JVM args = " + arguments); + + Map<String, Object> variables = createVariables(schemaVersion, businessKey, + request, injectedVariables, false); + VariableMapImpl variableMapImpl = createVariableMapImpl(variables); + + System.out.println("Sending " + request + " to " + processKey + " process"); + WorkflowAsyncCommonResource workflowResource = new WorkflowAsyncCommonResource(); + workflowResource.setProcessEngineServices4junit(processEngineRule); + + TestAsyncResponse asyncResponse = new TestAsyncResponse(); + workflowResource.startProcessInstanceByKey(asyncResponse, processKey, variableMapImpl); + return asyncResponse; + } + + /** + * Invokes an asynchronous process. + * Errors are handled with junit assertions and will cause the test to fail. + * @param processKey the process key + * @param schemaVersion the API schema version, e.g. "v1" + * @param businessKey a unique key that will identify the process instance + * @param request the request + * @param injectedVariables optional variables to inject into the process + * @param serviceInstantiationModel indicates whether this method is being + * invoked for a flow that is designed using the service instantiation model + * @return a TestAsyncResponse object associated with the test + */ + protected TestAsyncResponse invokeAsyncProcess(String processKey, + String schemaVersion, String businessKey, String request, + Map<String, Object> injectedVariables, boolean serviceInstantiationModel) { + + RuntimeMXBean runtimeMxBean = ManagementFactory.getRuntimeMXBean(); + List<String> arguments = runtimeMxBean.getInputArguments(); + System.out.println("JVM args = " + arguments); + + Map<String, Object> variables = createVariables(schemaVersion, businessKey, + request, injectedVariables, serviceInstantiationModel); + VariableMapImpl variableMapImpl = createVariableMapImpl(variables); + + System.out.println("Sending " + request + " to " + processKey + " process"); + WorkflowAsyncCommonResource workflowResource = new WorkflowAsyncCommonResource(); + workflowResource.setProcessEngineServices4junit(processEngineRule); + + TestAsyncResponse asyncResponse = new TestAsyncResponse(); + workflowResource.startProcessInstanceByKey(asyncResponse, processKey, variableMapImpl); + return asyncResponse; + } + + /** + * Private helper method that creates a variable map for a request. + * Errors are handled with junit assertions and will cause the test to fail. + * @param schemaVersion the API schema version, e.g. "v1" + * @param businessKey a unique key that will identify the process instance + * @param request the request + * @param injectedVariables optional variables to inject into the process + * @param serviceInstantiationModel indicates whether this method is being + * invoked for a flow that is designed using the service instantiation model + * @return a variable map + */ + private Map<String, Object> createVariables(String schemaVersion, + String businessKey, String request, Map<String, Object> injectedVariables, + boolean serviceInstantiationModel) { + + Map<String, Object> variables = new HashMap<String, Object>(); + + // These variables may be overridded by injected variables. + variables.put("mso-service-request-timeout", "180"); + variables.put("isDebugLogEnabled", "true"); + + // These variables may not be overridded by injected variables. + String[] notAllowed = new String[] { + "mso-schema-version", + "mso-business-key", + "bpmnRequest", + "mso-request-id", + "mso-service-instance-id" + }; + + if (injectedVariables != null) { + for (String key : injectedVariables.keySet()) { + for (String var : notAllowed) { + if (var.equals(key)) { + String msg = "Cannot specify " + var + " in injected variables"; + System.out.println(msg); + fail(msg); + } + } + + variables.put(key, injectedVariables.get(key)); + } + } + + variables.put("mso-schema-version", schemaVersion); + variables.put("mso-business-key", businessKey); + variables.put("bpmnRequest", request); + + if (serviceInstantiationModel) { + + /* + * The request ID and the service instance ID are generated for flows + * that follow the service instantiation model unless "requestId" and + * "serviceInstanceId" are injected variables. + */ + + try { + msoRequestId = (String) injectedVariables.get("requestId"); + variables.put("mso-request-id", msoRequestId); + msoServiceInstanceId = (String) injectedVariables.get("serviceInstanceId"); + variables.put("mso-service-instance-id", msoServiceInstanceId); + } + catch(Exception e) { + } + if (msoRequestId == null || msoRequestId.trim().equals("")) { + System.out.println("No requestId element in injectedVariables"); + variables.put("mso-request-id", UUID.randomUUID().toString()); + } + if (msoServiceInstanceId == null || msoServiceInstanceId.trim().equals("")) { + System.out.println("No seviceInstanceId element in injectedVariables"); + variables.put("mso-service-instance-id", UUID.randomUUID().toString()); + } + + } else { + msoRequestId = getXMLTextElement(request, "request-id"); + + if (msoRequestId == null) { + //check in injected variables + try { + msoRequestId = (String) injectedVariables.get("requestId"); + } + catch(Exception e) { + } + if (msoRequestId == null || msoRequestId.trim().equals("")) { + String msg = "No request-id element in " + request; + System.out.println(msg); + fail(msg); + } + } + + variables.put("mso-request-id", msoRequestId); + + // Note: some request types don't have a service-instance-id + msoServiceInstanceId = getXMLTextElement(request, "service-instance-id"); + + if (msoServiceInstanceId != null) { + variables.put("mso-service-instance-id", msoServiceInstanceId); + } + } + + return variables; + } + + /** + * Private helper method that creates a camunda VariableMapImpl from a simple + * variable map. + * @param variables the simple variable map + * @return a VariableMap + */ + private VariableMapImpl createVariableMapImpl(Map<String, Object> variables) { + Map<String, Object> wrappedVariables = new HashMap<String, Object>(); + + for (String key : variables.keySet()) { + Object value = variables.get(key); + wrappedVariables.put(key, wrapVariableValue(value)); + } + + VariableMapImpl variableMapImpl = new VariableMapImpl(); + variableMapImpl.put("variables", wrappedVariables); + return variableMapImpl; + } + + /** + * Private helper method that wraps a variable value for inclusion in a + * camunda VariableMapImpl. + * @param value the variable value + * @return the wrapped variable + */ + private Map<String, Object> wrapVariableValue(Object value) { + HashMap<String, Object> valueMap = new HashMap<String, Object>(); + valueMap.put("value", value); + return valueMap; + } + + /** + * Receives a response from an asynchronous process. + * Errors are handled with junit assertions and will cause the test to fail. + * @param businessKey the process business key + * @param asyncResponse the TestAsyncResponse object associated with the test + * @param timeout the timeout in milliseconds + * @return the WorkflowResponse + */ + public WorkflowResponse receiveResponse(String businessKey, + TestAsyncResponse asyncResponse, long timeout) { + System.out.println("Waiting " + timeout + "ms for process with business key " + businessKey + + " to send a response"); + + long now = System.currentTimeMillis() + timeout; + long endTime = now + timeout; + + while (now <= endTime) { + Response response = asyncResponse.getResponse(); + + if (response != null) { + System.out.println("Received a response from process with business key " + businessKey); + + Object entity = response.getEntity(); + + if (!(entity instanceof WorkflowResponse)) { + String msg = "Response entity is " + + (entity == null ? "null" : entity.getClass().getName()) + + ", expected WorkflowResponse"; + System.out.println(msg); + fail(msg); + return null; // unreachable + } + + return (WorkflowResponse) entity; + } + + try { + Thread.sleep(200); + } catch (InterruptedException e) { + String msg = "Interrupted waiting for a response from process with business key " + + businessKey; + System.out.println(msg); + fail(msg); + return null; // unreachable + } + + now = System.currentTimeMillis(); + } + + String msg = "No response received from process with business key " + businessKey + + " within " + timeout + "ms"; + System.out.println(msg); + fail("Process with business key " + businessKey + " did not end within 10000ms"); + return null; // unreachable + } + + /** + * Runs a program to inject SDNC callback data into the test environment. + * A program is essentially just a list of keys that identify callback data + * to be injected, in sequence. An example program: + * <pre> + * reserve, assign, delete:ERR + * </pre> + * Errors are handled with junit assertions and will cause the test to fail. + * @param callbacks an object containing callback data for the program + * @param program the program to execute + */ + protected void injectSDNCRestCallbacks(CallbackSet callbacks, String program) { + + String[] cmds = program.replaceAll("\\s+", "").split(","); + + for (String cmd : cmds) { + String action = cmd; + String modifier = "STD"; + + if (cmd.contains(":")) { + String[] parts = cmd.split(":"); + action = parts[0]; + modifier = parts[1]; + } + + String content = null; + + if ("STD".equals(modifier)) { + content = callbacks.get(action); + + if (content == null) { + String msg = "No callback defined for '" + action + "' SDNC request"; + System.out.println(msg); + fail(msg); + } + } else if ("ERR".equals(modifier)) { + content = "{\"SDNCServiceError\":{\"sdncRequestId\":\"((REQUEST-ID))\",\"responseCode\":\"500\",\"responseMessage\":\"SIMULATED ERROR FROM SDNC ADAPTER\",\"ackFinalIndicator\":\"Y\"}}"; + } else { + String msg = "Invalid SDNC program modifier: '" + modifier + "'"; + System.out.println(msg); + fail(msg); + } + + if (!injectSDNCRestCallback(content, 10000)) { + fail("Failed to inject SDNC '" + action + "' callback"); + } + + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + fail("Interrupted after injection of SDNC '" + action + "' callback"); + } + } + } + + /** + * Runs a program to inject SDNC events into the test environment. + * A program is essentially just a list of keys that identify event data + * to be injected, in sequence. An example program: + * <pre> + * event1, event2 + * </pre> + * Errors are handled with junit assertions and will cause the test to fail. + * Defaults the Event Type to "SDNCAEvent" for backward compatibility. + * @param callbacks an object containing event data for the program + * @param program the program to execute + */ + protected void injectSDNCEvents(CallbackSet callbacks, String program) { + injectSDNCEvents(callbacks, program, "SDNCAEvent"); + } + + /** + * Runs a program to inject SDNC events into the test environment. + * A program is essentially just a list of keys that identify event data + * to be injected, in sequence. An example program: + * <pre> + * event1, event2 + * </pre> + * Errors are handled with junit assertions and will cause the test to fail. + * @param callbacks an object containing event data for the program + * @param program the program to execute + * @param eventType (i.e. "SDNCAEvent", "SNIROResponse", etc.) + */ + protected void injectSDNCEvents(CallbackSet callbacks, String program, String eventType) { + + String[] cmds = program.replaceAll("\\s+", "").split(","); + + for (String cmd : cmds) { + String action = cmd; + String modifier = "STD"; + + if (cmd.contains(":")) { + String[] parts = cmd.split(":"); + action = parts[0]; + modifier = parts[1]; + } + + String content = null; + + if ("STD".equals(modifier)) { + content = callbacks.get(action); + + if (content == null) { + String msg = "No SDNC event callback defined for '" + action + "'"; + System.out.println(msg); + fail(msg); + } + } else { + String msg = "Invalid SDNC program modifier: '" + modifier + "'"; + System.out.println(msg); + fail(msg); + } + + if (!injectWorkflowMessage(eventType, content, 10000)) { + fail("Failed to inject SDNC '" + action + "' event"); + } + + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + fail("Interrupted after injection of SDNC '" + action + "' event"); + } + } + } + + /** + * Runs a program to inject SDNC callback data into the test environment. + * A program is essentially just a list of keys that identify callback data + * to be injected, in sequence. An example program: + * <pre> + * reserve, assign, delete:ERR + * </pre> + * Errors are handled with junit assertions and will cause the test to fail. + * @param callbacks an object containing callback data for the program + * @param program the program to execute + */ + public void injectSDNCCallbacks(CallbackSet callbacks, String program) { + + String[] cmds = program.replaceAll("\\s+", "").split(","); + + for (String cmd : cmds) { + String action = cmd; + String modifier = "STD"; + + if (cmd.contains(":")) { + String[] parts = cmd.split(":"); + action = parts[0]; + modifier = parts[1]; + } + + String content = null; + int respCode = 200; + String respMsg = "OK"; + + if ("STD".equals(modifier)) { + content = callbacks.get(action); + + if (content == null) { + String msg = "No callback defined for '" + action + "' SDNC request"; + System.out.println(msg); + fail(msg); + } + + respCode = 200; + respMsg = "OK"; + } else if ("ERR".equals(modifier)) { + content = "<svc-request-id>((REQUEST-ID))</svc-request-id><response-code>500</response-code><response-message>SIMULATED ERROR FROM SDNC ADAPTER</response-message>"; + respCode = 500; + respMsg = "SERVER ERROR"; + } else { + String msg = "Invalid SDNC program modifier: '" + modifier + "'"; + System.out.println(msg); + fail(msg); + } + + if (!injectSDNCCallback(respCode, respMsg, content, 10000)) { + fail("Failed to inject SDNC '" + action + "' callback"); + } + + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + fail("Interrupted after injection of SDNC '" + action + "' callback"); + } + } + } + + /** + * Runs a program to inject VNF adapter REST callback data into the test environment. + * A program is essentially just a list of keys that identify callback data + * to be injected, in sequence. An example program: + * <pre> + * create, rollback + * </pre> + * Errors are handled with junit assertions and will cause the test to fail. + * @param callbacks an object containing callback data for the program + * @param program the program to execute + */ + public void injectVNFRestCallbacks(CallbackSet callbacks, String program) { + + String[] cmds = program.replaceAll("\\s+", "").split(","); + + for (String cmd : cmds) { + String action = cmd; + String modifier = "STD"; + + if (cmd.contains(":")) { + String[] parts = cmd.split(":"); + action = parts[0]; + modifier = parts[1]; + } + + String content = null; + + if ("STD".equals(modifier)) { + content = callbacks.get(action); + + if (content == null) { + String msg = "No callback defined for '" + action + "' VNF REST request"; + System.out.println(msg); + fail(msg); + } + } else if ("ERR".equals(modifier)) { + content = "SIMULATED ERROR FROM VNF ADAPTER"; + } else { + String msg = "Invalid VNF REST program modifier: '" + modifier + "'"; + System.out.println(msg); + fail(msg); + } + + if (!injectVnfAdapterRestCallback(content, 10000)) { + fail("Failed to inject VNF REST '" + action + "' callback"); + } + + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + fail("Interrupted after injection of VNF REST '" + action + "' callback"); + } + } + } + + /** + * Runs a program to inject VNF callback data into the test environment. + * A program is essentially just a list of keys that identify callback data + * to be injected, in sequence. An example program: + * <pre> + * createVnf, deleteVnf + * </pre> + * Errors are handled with junit assertions and will cause the test to fail. + * @param callbacks an object containing callback data for the program + * @param program the program to execute + */ + protected void injectVNFCallbacks(CallbackSet callbacks, String program) { + + String[] cmds = program.replaceAll("\\s+", "").split(","); + + for (String cmd : cmds) { + String action = cmd; + String modifier = "STD"; + + if (cmd.contains(":")) { + String[] parts = cmd.split(":"); + action = parts[0]; + modifier = parts[1]; + } + + String content = null; + + if ("STD".equals(modifier)) { + content = callbacks.get(action); + + if (content == null) { + String msg = "No callback defined for '" + action + "' VNF request"; + System.out.println(msg); + fail(msg); + } + + } else if ("ERR".equals(modifier)) { + String msg = "Currently unsupported VNF program modifier: '" + modifier + "'"; + System.out.println(msg); + fail(msg); + } else { + String msg = "Invalid VNF program modifier: '" + modifier + "'"; + System.out.println(msg); + fail(msg); + } + + boolean injected = false; + + if (content.contains("createVnfNotification")) { + injected = injectCreateVNFCallback(content, 10000); + } else if (content.contains("deleteVnfNotification")) { + injected = injectDeleteVNFCallback(content, 10000); + } else if (content.contains("updateVnfNotification")) { + injected = injectUpdateVNFCallback(content, 10000); + } + + if (!injected) { + String msg = "Failed to inject VNF '" + action + "' callback"; + System.out.println(msg); + fail(msg); + } + + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + fail("Interrupted after injection of VNF '" + action + "' callback"); + } + } + } + + /** + * Waits for the number of running processes with the specified process + * definition key to equal a particular count. + * @param processKey the process definition key + * @param count the desired count + * @param timeout the timeout in milliseconds + */ + public void waitForRunningProcessCount(String processKey, int count, long timeout) { + System.out.println("Waiting " + timeout + "ms for there to be " + count + " " + + processKey + " instances"); + + long now = System.currentTimeMillis() + timeout; + long endTime = now + timeout; + int last = -1; + + while (now <= endTime) { + int actual = processEngineRule.getRuntimeService() + .createProcessInstanceQuery() + .processDefinitionKey(processKey) + .list().size(); + + if (actual != last) { + System.out.println("There are now " + actual + " " + + processKey + " instances"); + last = actual; + } + + if (actual == count) { + return; + } + + try { + Thread.sleep(200); + } catch (InterruptedException e) { + String msg = "Interrupted waiting for there to be " + count + " " + + processKey + " instances"; + System.out.println(msg); + fail(msg); + } + + now = System.currentTimeMillis(); + } + + String msg = "Timed out waiting for there to be " + count + " " + + processKey + " instances"; + System.out.println(msg); + fail(msg); + } + + /** + * Waits for the specified process variable to be set. + * @param processKey the process definition key + * @param variable the variable name + * @param timeout the timeout in milliseconds + * @return the variable value, or null if it cannot be obtained + * in the specified time + */ + protected Object getProcessVariable(String processKey, String variable, + long timeout) { + + System.out.println("Waiting " + timeout + "ms for " + + processKey + "." + variable + " to be set"); + + long now = System.currentTimeMillis() + timeout; + long endTime = now + timeout; + + ProcessInstance processInstance = null; + Object value = null; + + while (value == null) { + if (now > endTime) { + if (processInstance == null) { + System.out.println("Timed out waiting for " + + processKey + " to start"); + } else { + System.out.println("Timed out waiting for " + + processKey + "[" + processInstance.getId() + + "]." + variable + " to be set"); + } + + return null; + } + + if (processInstance == null) { + processInstance = processEngineRule.getRuntimeService() + .createProcessInstanceQuery() + .processDefinitionKey(processKey) + .singleResult(); + } + + if (processInstance != null) { + value = processEngineRule.getRuntimeService() + .getVariable(processInstance.getId(), variable); + } + + try { + Thread.sleep(200); + } catch (InterruptedException e) { + System.out.println("Interrupted waiting for " + + processKey + "." + variable + " to be set"); + return null; + } + + now = System.currentTimeMillis(); + } + + System.out.println(processKey + "[" + + processInstance.getId() + "]." + variable + "=" + + value); + + return value; + } + + /** + * Injects a single SDNC adapter callback request. The specified callback data + * may contain the placeholder string ((REQUEST-ID)) which is replaced with + * the actual SDNC request ID. Note: this is not the requestId in the original + * MSO request. + * @param content the content of the callback + * @param timeout the timeout in milliseconds + * @return true if the callback could be injected, false otherwise + */ + protected boolean injectSDNCRestCallback(String content, long timeout) { + String sdncRequestId = (String) getProcessVariable("SDNCAdapterRestV1", + "SDNCAResponse_CORRELATOR", timeout); + + if (sdncRequestId == null) { + return false; + } + + content = content.replace("((REQUEST-ID))", sdncRequestId); + // Deprecated usage. All test code should switch to the (( ... )) syntax. + content = content.replace("{{REQUEST-ID}}", sdncRequestId); + + System.out.println("Injecting SDNC adapter callback"); + WorkflowMessageResource workflowMessageResource = new WorkflowMessageResource(); + workflowMessageResource.setProcessEngineServices4junit(processEngineRule); + Response response = workflowMessageResource.deliver("SDNCAResponse", sdncRequestId, content); + System.out.println("Workflow response to SDNC adapter callback: " + response); + return true; + } + + /** + * Injects a single SDNC adapter callback request. The specified callback data + * may contain the placeholder string ((REQUEST-ID)) which is replaced with + * the actual SDNC request ID. Note: this is not the requestId in the original + * MSO request. + * @param content the content of the callback + * @param respCode the response code (normally 200) + * @param respMsg the response message (normally "OK") + * @param timeout the timeout in milliseconds + * @return true if the callback could be injected, false otherwise + */ + protected boolean injectSDNCCallback(int respCode, String respMsg, + String content, long timeout) { + + String sdncRequestId = (String) getProcessVariable("sdncAdapter", + "SDNCA_requestId", timeout); + + if (sdncRequestId == null) { + return false; + } + + content = content.replace("((REQUEST-ID))", sdncRequestId); + // Deprecated usage. All test code should switch to the (( ... )) syntax. + content = content.replace("{{REQUEST-ID}}", sdncRequestId); + + System.out.println("Injecting SDNC adapter callback"); + CallbackHeader callbackHeader = new CallbackHeader(); + callbackHeader.setRequestId(sdncRequestId); + callbackHeader.setResponseCode(String.valueOf(respCode)); + callbackHeader.setResponseMessage(respMsg); + SDNCAdapterCallbackRequest sdncAdapterCallbackRequest = new SDNCAdapterCallbackRequest(); + sdncAdapterCallbackRequest.setCallbackHeader(callbackHeader); + sdncAdapterCallbackRequest.setRequestData(content); + SDNCAdapterCallbackServiceImpl callbackService = new SDNCAdapterCallbackServiceImpl(); + callbackService.setProcessEngineServices4junit(processEngineRule); + SDNCAdapterResponse sdncAdapterResponse = callbackService.sdncAdapterCallback(sdncAdapterCallbackRequest); + System.out.println("Workflow response to SDNC adapter callback: " + sdncAdapterResponse); + + return true; + } + + /** + * Injects a single VNF adapter callback request. The specified callback data + * may contain the placeholder string ((MESSAGE-ID)) which is replaced with + * the actual message ID. Note: this is not the requestId in the original + * MSO request. + * @param content the content of the callback + * @param timeout the timeout in milliseconds + * @return true if the callback could be injected, false otherwise + */ + protected boolean injectVnfAdapterRestCallback(String content, long timeout) { + String messageId = (String) getProcessVariable("vnfAdapterRestV1", + "VNFAResponse_CORRELATOR", timeout); + + if (messageId == null) { + return false; + } + + content = content.replace("((MESSAGE-ID))", messageId); + // Deprecated usage. All test code should switch to the (( ... )) syntax. + content = content.replace("{{MESSAGE-ID}}", messageId); + + System.out.println("Injecting VNF adapter callback"); + WorkflowMessageResource workflowMessageResource = new WorkflowMessageResource(); + workflowMessageResource.setProcessEngineServices4junit(processEngineRule); + Response response = workflowMessageResource.deliver("VNFAResponse", messageId, content); + System.out.println("Workflow response to VNF adapter callback: " + response); + return true; + } + + /** + * Injects a Create VNF adapter callback request. The specified callback data + * may contain the placeholder string ((MESSAGE-ID)) which is replaced with + * the actual message ID. It may also contain the placeholder string + * ((REQUEST-ID)) which is replaced request ID of the original MSO request. + * @param content the content of the callback + * @param timeout the timeout in milliseconds + * @return true if the callback could be injected, false otherwise + * @throws JAXBException if the content does not adhere to the schema + */ + protected boolean injectCreateVNFCallback(String content, long timeout) { + + String messageId = (String) getProcessVariable("vnfAdapterCreateV1", + "VNFC_messageId", timeout); + + if (messageId == null) { + return false; + } + + content = content.replace("((MESSAGE-ID))", messageId); + // Deprecated usage. All test code should switch to the (( ... )) syntax. + content = content.replace("{{MESSAGE-ID}}", messageId); + + if(content.contains("((REQUEST-ID))")){ + content = content.replace("((REQUEST-ID))", msoRequestId); + // Deprecated usage. All test code should switch to the (( ... )) syntax. + content = content.replace("{{REQUEST-ID}}", msoRequestId); + } + + System.out.println("Injecting VNF adapter callback"); + + // Is it possible to unmarshal this with JAXB? I couldn't. + + CreateVnfNotification createVnfNotification = new CreateVnfNotification(); + XPathTool xpathTool = new VnfNotifyXPathTool(); + xpathTool.setXML(content); + + try { + String completed = xpathTool.evaluate( + "/tns:createVnfNotification/tns:completed/text()"); + createVnfNotification.setCompleted("true".equals(completed)); + + String vnfId = xpathTool.evaluate( + "/tns:createVnfNotification/tns:vnfId/text()"); + createVnfNotification.setVnfId(vnfId); + + NodeList entries = (NodeList) xpathTool.evaluate( + "/tns:createVnfNotification/tns:outputs/tns:entry", + XPathConstants.NODESET); + + CreateVnfNotificationOutputs outputs = new CreateVnfNotificationOutputs(); + + for (int i = 0; i < entries.getLength(); i++) { + Node node = entries.item(i); + + if (node.getNodeType() == Node.ELEMENT_NODE) { + Element entry = (Element) node; + String key = entry.getElementsByTagNameNS("*", "key").item(0).getTextContent(); + String value = entry.getElementsByTagNameNS("*", "value").item(0).getTextContent(); + outputs.add(key, value); + } + } + + createVnfNotification.setOutputs(outputs); + + VnfRollback rollback = new VnfRollback(); + + String cloudSiteId = xpathTool.evaluate( + "/tns:createVnfNotification/tns:rollback/tns:cloudSiteId/text()"); + rollback.setCloudSiteId(cloudSiteId); + + String requestId = xpathTool.evaluate( + "/tns:createVnfNotification/tns:rollback/tns:msoRequest/tns:requestId/text()"); + String serviceInstanceId = xpathTool.evaluate( + "/tns:createVnfNotification/tns:rollback/tns:msoRequest/tns:serviceInstanceId/text()"); + + if (requestId != null || serviceInstanceId != null) { + MsoRequest msoRequest = new MsoRequest(); + msoRequest.setRequestId(requestId); + msoRequest.setServiceInstanceId(serviceInstanceId); + rollback.setMsoRequest(msoRequest); + } + + String tenantCreated = xpathTool.evaluate( + "/tns:createVnfNotification/tns:rollback/tns:tenantCreated/text()"); + rollback.setTenantCreated("true".equals(tenantCreated)); + + String tenantId = xpathTool.evaluate( + "/tns:createVnfNotification/tns:rollback/tns:tenantId/text()"); + rollback.setTenantId(tenantId); + + String vnfCreated = xpathTool.evaluate( + "/tns:createVnfNotification/tns:rollback/tns:vnfCreated/text()"); + rollback.setVnfCreated("true".equals(vnfCreated)); + + String rollbackVnfId = xpathTool.evaluate( + "/tns:createVnfNotification/tns:rollback/tns:vnfId/text()"); + rollback.setVnfId(rollbackVnfId); + + createVnfNotification.setRollback(rollback); + + } catch (Exception e) { + System.out.println("Failed to unmarshal VNF callback content:"); + System.out.println(content); + return false; + } + + VnfAdapterNotifyServiceImpl notifyService = new VnfAdapterNotifyServiceImpl(); + notifyService.setProcessEngineServices4junit(processEngineRule); + + notifyService.createVnfNotification( + messageId, + createVnfNotification.isCompleted(), + createVnfNotification.getException(), + createVnfNotification.getErrorMessage(), + createVnfNotification.getVnfId(), + createVnfNotification.getOutputs(), + createVnfNotification.getRollback()); + + return true; + } + + /** + * Injects a Delete VNF adapter callback request. The specified callback data + * may contain the placeholder string ((MESSAGE-ID)) which is replaced with + * the actual message ID. It may also contain the placeholder string + * ((REQUEST-ID)) which is replaced request ID of the original MSO request. + * @param content the content of the callback + * @param timeout the timeout in milliseconds + * @return true if the callback could be injected, false otherwise + * @throws JAXBException if the content does not adhere to the schema + */ + protected boolean injectDeleteVNFCallback(String content, long timeout) { + + String messageId = (String) getProcessVariable("vnfAdapterDeleteV1", + "VNFDEL_uuid", timeout); + + if (messageId == null) { + return false; + } + + content = content.replace("((MESSAGE-ID))", messageId); + // Deprecated usage. All test code should switch to the (( ... )) syntax. + content = content.replace("{{MESSAGE-ID}}", messageId); + + System.out.println("Injecting VNF adapter delete callback"); + + // Is it possible to unmarshal this with JAXB? I couldn't. + + DeleteVnfNotification deleteVnfNotification = new DeleteVnfNotification(); + XPathTool xpathTool = new VnfNotifyXPathTool(); + xpathTool.setXML(content); + + try { + String completed = xpathTool.evaluate( + "/tns:deleteVnfNotification/tns:completed/text()"); + deleteVnfNotification.setCompleted("true".equals(completed)); + // if notification failure, set the exception and error message + if (deleteVnfNotification.isCompleted() == false) { + deleteVnfNotification.setException(MsoExceptionCategory.INTERNAL); + deleteVnfNotification.setErrorMessage(xpathTool.evaluate( + "/tns:deleteVnfNotification/tns:errorMessage/text()")) ; + } + + } catch (Exception e) { + System.out.println("Failed to unmarshal VNF Delete callback content:"); + System.out.println(content); + return false; + } + + VnfAdapterNotifyServiceImpl notifyService = new VnfAdapterNotifyServiceImpl(); + notifyService.setProcessEngineServices4junit(processEngineRule); + + notifyService.deleteVnfNotification( + messageId, + deleteVnfNotification.isCompleted(), + deleteVnfNotification.getException(), + deleteVnfNotification.getErrorMessage()); + + return true; + } + + /** + * Injects a Update VNF adapter callback request. The specified callback data + * may contain the placeholder string ((MESSAGE-ID)) which is replaced with + * the actual message ID. It may also contain the placeholder string + * ((REQUEST-ID)) which is replaced request ID of the original MSO request. + * @param content the content of the callback + * @param timeout the timeout in milliseconds + * @return true if the callback could be injected, false otherwise + * @throws JAXBException if the content does not adhere to the schema + */ + protected boolean injectUpdateVNFCallback(String content, long timeout) { + + String messageId = (String) getProcessVariable("vnfAdapterUpdate", + "VNFU_messageId", timeout); + + if (messageId == null) { + return false; + } + + content = content.replace("((MESSAGE-ID))", messageId); + // Deprecated usage. All test code should switch to the (( ... )) syntax. + content = content.replace("{{MESSAGE-ID}}", messageId); + + content = content.replace("((REQUEST-ID))", msoRequestId); + // Deprecated usage. All test code should switch to the (( ... )) syntax. + content = content.replace("{{REQUEST-ID}}", msoRequestId); + + System.out.println("Injecting VNF adapter callback"); + + // Is it possible to unmarshal this with JAXB? I couldn't. + + UpdateVnfNotification updateVnfNotification = new UpdateVnfNotification(); + XPathTool xpathTool = new VnfNotifyXPathTool(); + xpathTool.setXML(content); + + try { + String completed = xpathTool.evaluate( + "/tns:updateVnfNotification/tns:completed/text()"); + updateVnfNotification.setCompleted("true".equals(completed)); + + NodeList entries = (NodeList) xpathTool.evaluate( + "/tns:updateVnfNotification/tns:outputs/tns:entry", + XPathConstants.NODESET); + + UpdateVnfNotificationOutputs outputs = new UpdateVnfNotificationOutputs(); + + for (int i = 0; i < entries.getLength(); i++) { + Node node = entries.item(i); + + if (node.getNodeType() == Node.ELEMENT_NODE) { + Element entry = (Element) node; + String key = entry.getElementsByTagNameNS("*", "key").item(0).getTextContent(); + String value = entry.getElementsByTagNameNS("*", "value").item(0).getTextContent(); + outputs.add(key, value); + } + } + + updateVnfNotification.setOutputs(outputs); + + VnfRollback rollback = new VnfRollback(); + + String cloudSiteId = xpathTool.evaluate( + "/tns:updateVnfNotification/tns:rollback/tns:cloudSiteId/text()"); + rollback.setCloudSiteId(cloudSiteId); + + String requestId = xpathTool.evaluate( + "/tns:updateVnfNotification/tns:rollback/tns:msoRequest/tns:requestId/text()"); + String serviceInstanceId = xpathTool.evaluate( + "/tns:updateVnfNotification/tns:rollback/tns:msoRequest/tns:serviceInstanceId/text()"); + + if (requestId != null || serviceInstanceId != null) { + MsoRequest msoRequest = new MsoRequest(); + msoRequest.setRequestId(requestId); + msoRequest.setServiceInstanceId(serviceInstanceId); + rollback.setMsoRequest(msoRequest); + } + + String tenantCreated = xpathTool.evaluate( + "/tns:updateVnfNotification/tns:rollback/tns:tenantCreated/text()"); + rollback.setTenantCreated("true".equals(tenantCreated)); + + String tenantId = xpathTool.evaluate( + "/tns:updateVnfNotification/tns:rollback/tns:tenantId/text()"); + rollback.setTenantId(tenantId); + + String vnfCreated = xpathTool.evaluate( + "/tns:updateVnfNotification/tns:rollback/tns:vnfCreated/text()"); + rollback.setVnfCreated("true".equals(vnfCreated)); + + String rollbackVnfId = xpathTool.evaluate( + "/tns:updateVnfNotification/tns:rollback/tns:vnfId/text()"); + rollback.setVnfId(rollbackVnfId); + + updateVnfNotification.setRollback(rollback); + + } catch (Exception e) { + System.out.println("Failed to unmarshal VNF callback content:"); + System.out.println(content); + return false; + } + + VnfAdapterNotifyServiceImpl notifyService = new VnfAdapterNotifyServiceImpl(); + notifyService.setProcessEngineServices4junit(processEngineRule); + + notifyService.updateVnfNotification( + messageId, + updateVnfNotification.isCompleted(), + updateVnfNotification.getException(), + updateVnfNotification.getErrorMessage(), + updateVnfNotification.getOutputs(), + updateVnfNotification.getRollback()); + + return true; + } + + /** + * Injects a workflow message. The specified callback data may contain the + * placeholder string ((CORRELATOR)) which is replaced with the actual + * correlator value. + * @param content the message type + * @param content the message content + * @param timeout the timeout in milliseconds + * @return true if the event could be injected, false otherwise + */ + protected boolean injectWorkflowMessage(String messageType, String content, long timeout) { + String correlator = (String) getProcessVariable("ReceiveWorkflowMessage", + messageType + "_CORRELATOR", timeout); + + if (correlator == null) { + return false; + } + + content = content.replace("((CORRELATOR))", correlator); + + System.out.println("Injecting " + messageType + " message"); + WorkflowMessageResource workflowMessageResource = new WorkflowMessageResource(); + workflowMessageResource.setProcessEngineServices4junit(processEngineRule); + Response response = workflowMessageResource.deliver(messageType, correlator, content); + System.out.println("Workflow response to " + messageType + " message: " + response); + return true; + } + + /** + * Wait for the process to end. + * @param businessKey the process business key + * @param timeout the amount of time to wait, in milliseconds + */ + public void waitForProcessEnd(String businessKey, long timeout) { + System.out.println("Waiting " + timeout + "ms for process with business key " + + businessKey + " to end"); + + long now = System.currentTimeMillis() + timeout; + long endTime = now + timeout; + + while (now <= endTime) { + if (isProcessEnded(businessKey)) { + System.out.println("Process with business key " + businessKey + " has ended"); + return; + } + + try { + Thread.sleep(200); + } catch (InterruptedException e) { + String msg = "Interrupted waiting for process with business key " + + businessKey + " to end"; + System.out.println(msg); + fail(msg); + } + + now = System.currentTimeMillis(); + } + + String msg = "Process with business key " + businessKey + + " did not end within " + timeout + "ms"; + System.out.println(msg); + fail(msg); + } + + /** + * Verifies that the specified historic process variable has the specified value. + * If the variable does not have the specified value, the test is failed. + * @param businessKey the process business key + * @param variable the variable name + * @param value the expected variable value + */ + public void checkVariable(String businessKey, String variable, Object value) { + if (!isProcessEnded(businessKey)) { + fail("Cannot get historic variable " + variable + " because process with business key " + + businessKey + " has not ended"); + } + + Object variableValue = getVariableFromHistory(businessKey, variable); + assertEquals(value, variableValue); + } + + /** + * Checks to see if the specified process is ended. + * @param businessKey the process business Key + * @return true if the process is ended + */ + protected boolean isProcessEnded(String businessKey) { + HistoricProcessInstance processInstance = processEngineRule.getHistoryService() + .createHistoricProcessInstanceQuery().processInstanceBusinessKey(businessKey).singleResult(); + return processInstance != null && processInstance.getEndTime() != null; + } + + /** + * Gets a variable value from a historical process instance. + * @param businessKey the process business key + * @param variableName the variable name + * @return the variable value, or null if the variable could not be + * obtained + */ + public Object getVariableFromHistory(String businessKey, String variableName) { + try { + HistoricProcessInstance processInstance = processEngineRule.getHistoryService() + .createHistoricProcessInstanceQuery().processInstanceBusinessKey(businessKey).singleResult(); + + if (processInstance == null) { + return null; + } + + HistoricVariableInstance v = processEngineRule.getHistoryService() + .createHistoricVariableInstanceQuery().processInstanceId(processInstance.getId()) + .variableName(variableName).singleResult(); + return v == null ? null : v.getValue(); + } catch (Exception e) { + System.out.println("Error retrieving variable " + variableName + + " from historical process with business key " + businessKey + ": " + e); + return null; + } + } + + /** + * Gets the value of a subflow variable from the specified subflow's + * historical process instance. + * + * @param subflowName - the name of the subflow that contains the variable + * @param variableName the variable name + * + * @return the variable value, or null if the variable could not be obtained + * + */ + protected Object getVariableFromSubflowHistory(String subflowName, String variableName) { + try { + List<HistoricProcessInstance> processInstanceList = processEngineRule.getHistoryService() + .createHistoricProcessInstanceQuery().processDefinitionName(subflowName).list(); + + Collections.sort(processInstanceList, new Comparator<HistoricProcessInstance>() { + public int compare(HistoricProcessInstance m1, HistoricProcessInstance m2) { + return m1.getStartTime().compareTo(m2.getStartTime()); + } + }); + + HistoricProcessInstance processInstance = processInstanceList.get(0); + + if (processInstanceList == null) { + return null; + } + + HistoricVariableInstance v = processEngineRule.getHistoryService() + .createHistoricVariableInstanceQuery().processInstanceId(processInstance.getId()) + .variableName(variableName).singleResult(); + return v == null ? null : v.getValue(); + } catch (Exception e) { + System.out.println("Error retrieving variable " + variableName + + " from sub flow: " + subflowName + ", Exception is: " + e); + return null; + } + } + + /** + * Gets the value of a subflow variable from the subflow's + * historical process x instance. + * + * @param subflowName - the name of the subflow that contains the variable + * @param variableName the variable name + * @param subflowInstanceIndex - the instance of the subflow (use when same subflow is called more than once from mainflow) + * + * @return the variable value, or null if the variable could not be obtained + */ + protected Object getVariableFromSubflowHistory(int subflowInstanceIndex, String subflowName, String variableName) { + try { + List<HistoricProcessInstance> processInstanceList = processEngineRule.getHistoryService() + .createHistoricProcessInstanceQuery().processDefinitionName(subflowName).list(); + + Collections.sort(processInstanceList, new Comparator<HistoricProcessInstance>() { + public int compare(HistoricProcessInstance m1, HistoricProcessInstance m2) { + return m1.getStartTime().compareTo(m2.getStartTime()); + } + }); + + HistoricProcessInstance processInstance = processInstanceList.get(subflowInstanceIndex); + + if (processInstanceList == null) { + return null; + } + + HistoricVariableInstance v = processEngineRule.getHistoryService() + .createHistoricVariableInstanceQuery().processInstanceId(processInstance.getId()) + .variableName(variableName).singleResult(); + return v == null ? null : v.getValue(); + } catch (Exception e) { + System.out.println("Error retrieving variable " + variableName + + " from " + subflowInstanceIndex + " instance index of sub flow: " + subflowName + ", Exception is: " + e); + return null; + } + } + + + /** + * Extracts text from an XML element. This method is not namespace aware + * (namespaces are ignored). The first matching element is selected. + * @param xml the XML document or fragment + * @param tag the desired element, e.g. "<name>" + * @return the element text, or null if the element was not found + */ + protected String getXMLTextElement(String xml, String tag) { + xml = removeXMLNamespaces(xml); + + if (!tag.startsWith("<")) { + tag = "<" + tag + ">"; + } + + int start = xml.indexOf(tag); + + if (start == -1) { + return null; + } + + int end = xml.indexOf('<', start + tag.length()); + + if (end == -1) { + return null; + } + + return xml.substring(start + tag.length(), end); + } + + /** + * Removes namespace definitions and prefixes from XML, if any. + */ + private String removeXMLNamespaces(String xml) { + // remove xmlns declaration + xml = xml.replaceAll("xmlns.*?(\"|\').*?(\"|\')", ""); + + // remove opening tag prefix + xml = xml.replaceAll("(<)(\\w+:)(.*?>)", "$1$3"); + + // remove closing tags prefix + xml = xml.replaceAll("(</)(\\w+:)(.*?>)", "$1$3"); + + // remove extra spaces left when xmlns declarations are removed + xml = xml.replaceAll("\\s+>", ">"); + + return xml; + } + + /** + * Asserts that two XML documents are semantically equivalent. Differences + * in whitespace or in namespace usage do not affect the comparison. + * @param expected the expected XML + * @param actual the XML to test + * @throws SAXException + * @throws IOException + */ + public static void assertXMLEquals(String expected, String actual) + throws SAXException, IOException { + XMLUnit.setIgnoreWhitespace(true); + XMLUnit.setIgnoreAttributeOrder(true); + DetailedDiff diff = new DetailedDiff(XMLUnit.compareXML(expected, actual)); + List<?> allDifferences = diff.getAllDifferences(); + assertEquals("Differences found: " + diff.toString(), 0, allDifferences.size()); + } + + /** + * A test implementation of AsynchronousResponse. + */ + public class TestAsyncResponse implements AsynchronousResponse { + Response response = null; + + /** + * {@inheritDoc} + */ + @Override + public synchronized void setResponse(Response response) { + this.response = response; + } + + /** + * Gets the response. + * @return the response, or null if none has been produced yet + */ + public synchronized Response getResponse() { + return response; + } + } + + /** + * An object that contains callback data for a "program". + */ + public class CallbackSet { + private final Map<String, String> map = new HashMap<String, String>(); + + /** + * Add callback data to the set. + * @param action the action with which the data is associated + * @param content the callback data + */ + public void put(String action, String content) { + map.put(action, content); + } + + /** + * Retrieve callback data from the set. + * @param action the action with which the data is associated + * @return the callback data, or null if there is none for the specified operation + */ + public String get(String action) { + return map.get(action); + } + } + + /** + * A tool for evaluating XPath expressions. + */ + protected class XPathTool { + private final DocumentBuilderFactory factory; + private final SimpleNamespaceContext context = new SimpleNamespaceContext(); + private final XPath xpath = XPathFactory.newInstance().newXPath(); + private String xml = null; + private Document doc = null; + + /** + * Constructor. + */ + public XPathTool() { + factory = DocumentBuilderFactory.newInstance(); + factory.setNamespaceAware(true); + xpath.setNamespaceContext(context); + } + + /** + * Adds a namespace. + * @param prefix the namespace prefix + * @param uri the namespace uri + */ + public synchronized void addNamespace(String prefix, String uri) { + context.add(prefix, uri); + } + + /** + * Sets the XML content to be operated on. + * @param xml the XML content + */ + public synchronized void setXML(String xml) { + this.xml = xml; + this.doc = null; + } + + /** + * Returns the document object. + * @return the document object, or null if XML has not been set + * @throws SAXException + * @throws IOException + * @throws ParserConfigurationException + */ + public synchronized Document getDocument() + throws ParserConfigurationException, IOException, SAXException { + if (xml == null) { + return null; + } + + buildDocument(); + return doc; + } + + /** + * Evaluates the specified XPath expression and returns a string result. + * This method throws exceptions on error. + * @param expression the expression + * @return the result object + * @throws ParserConfigurationException + * @throws IOException + * @throws SAXException + * @throws XPathExpressionException on error + */ + public synchronized String evaluate(String expression) + throws ParserConfigurationException, SAXException, + IOException, XPathExpressionException { + return (String) evaluate(expression, XPathConstants.STRING); + } + + /** + * Evaluates the specified XPath expression. + * This method throws exceptions on error. + * @param expression the expression + * @param returnType the return type + * @return the result object + * @throws ParserConfigurationException + * @throws IOException + * @throws SAXException + * @throws XPathExpressionException on error + */ + public synchronized Object evaluate(String expression, QName returnType) + throws ParserConfigurationException, SAXException, + IOException, XPathExpressionException { + + buildDocument(); + XPathExpression expr = xpath.compile(expression); + return expr.evaluate(doc, returnType); + } + + /** + * Private helper method that builds the document object. + * Assumes the calling method is synchronized. + * @throws ParserConfigurationException + * @throws IOException + * @throws SAXException + */ + private void buildDocument() throws ParserConfigurationException, + IOException, SAXException { + if (doc == null) { + if (xml == null) { + throw new IOException("XML input is null"); + } + + DocumentBuilder builder = factory.newDocumentBuilder(); + InputSource source = new InputSource(new StringReader(xml)); + doc = builder.parse(source); + } + } + } + + /** + * A NamespaceContext class based on a Map. + */ + private class SimpleNamespaceContext implements NamespaceContext { + private Map<String, String> prefixMap = new HashMap<String, String>(); + private Map<String, String> uriMap = new HashMap<String, String>(); + + public synchronized void add(String prefix, String uri) { + prefixMap.put(prefix, uri); + uriMap.put(uri, prefix); + } + + @Override + public synchronized String getNamespaceURI(String prefix) { + return prefixMap.get(prefix); + } + + @Override + public Iterator<String> getPrefixes(String uri) { + List<String> list = new ArrayList<String>(); + String prefix = uriMap.get(uri); + if (prefix != null) { + list.add(prefix); + } + return list.iterator(); + } + + @Override + public String getPrefix(String uri) { + return uriMap.get(uri); + } + } + + /** + * A VnfNotify XPathTool. + */ + protected class VnfNotifyXPathTool extends XPathTool { + public VnfNotifyXPathTool() { + addNamespace("tns", "http://org.openecomp.mso/vnfNotify"); + } + } + + /** + * Helper class to make it easier to create this type. + */ + private static class CreateVnfNotificationOutputs + extends org.openecomp.mso.bpmn.common.adapter.vnf.CreateVnfNotification.Outputs { + public void add(String key, String value) { + Entry entry = new Entry(); + entry.setKey(key); + entry.setValue(value); + getEntry().add(entry); + } + } + + /** + * Helper class to make it easier to create this type. + */ + private static class UpdateVnfNotificationOutputs + extends org.openecomp.mso.bpmn.common.adapter.vnf.UpdateVnfNotification.Outputs { + public void add(String key, String value) { + Entry entry = new Entry(); + entry.setKey(key); + entry.setValue(value); + getEntry().add(entry); + } + } +} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/WorkflowTestTransformer.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/WorkflowTestTransformer.java new file mode 100644 index 0000000000..4aa6fbe0bb --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/WorkflowTestTransformer.java @@ -0,0 +1,21 @@ +package org.openecomp.mso.bpmn.common; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Allows a subclass of WorkflowTest to specify one or more WireMock + * response transformers. A transformer must be declared as a public + * static field in the subclass. For example: + * <pre> + * @WorkflowTestTransformer + * public static final ResponseTransformer sdncAdapterMockTransformer = + * new SDNCAdapterMockTransformer(); + * </pre> + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.FIELD) +public @interface WorkflowTestTransformer { +}
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/CreateNetworkV2mock/sdncCreateNetworkTopologySim500Response.xml b/bpmn/MSOCommonBPMN/src/test/resources/CreateNetworkV2mock/sdncCreateNetworkTopologySim500Response.xml new file mode 100644 index 0000000000..2cf94b2ef2 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/CreateNetworkV2mock/sdncCreateNetworkTopologySim500Response.xml @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" + xmlns:v1="http://org.openecomp/workflow/sdnc/adapter/schema/v1"> + <soapenv:Header /> + <soapenv:Body> + <v1:SDNCAdapterCallback> + <SDNCAdapterCallbackRequest xmlns="http://org.openecomp/workflow/sdnc/adapter/schema/v1"> + <CallbackHeader> + <RequestId>testRequestId</RequestId> + <ResponseCode>200</ResponseCode> + <ResponseMessage>OK</ResponseMessage> + </CallbackHeader> + <RequestData xsi:type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><output + xmlns="com:att:sdnctl:vnf"><response-code>500</response-code><response-message>'Error + retrieving l3-network with network-id=' + + $network-topology-operation-input.network-request-information.network-id + + 'from + AnAI'</response-message><ack-final-indicator>Y</ack-final-indicator><svc-request-id>006927ca-f5a3-47fd-880c-dfcbcd81a093</svc-request-id></output> + </RequestData> + </SDNCAdapterCallbackRequest> + </v1:SDNCAdapterCallback> + </soapenv:Body> +</soapenv:Envelope> + diff --git a/bpmn/MSOCommonBPMN/src/test/resources/CreateNetworkV2mock/sdncCreateNetworkTopologySimResponse_noExtraTag.xml b/bpmn/MSOCommonBPMN/src/test/resources/CreateNetworkV2mock/sdncCreateNetworkTopologySimResponse_noExtraTag.xml new file mode 100644 index 0000000000..57dc2d6f30 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/CreateNetworkV2mock/sdncCreateNetworkTopologySimResponse_noExtraTag.xml @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" + xmlns:v1="http://org.openecomp/workflow/sdnc/adapter/schema/v1"> + <soapenv:Header /> + <soapenv:Body> + <SDNCAdapterCallbackRequest xmlns="http://org.openecomp/workflow/sdnc/adapter/schema/v1"> + <CallbackHeader> + <RequestId>testRequestId</RequestId> + <ResponseCode>200</ResponseCode> + <ResponseMessage>OK</ResponseMessage> + </CallbackHeader> + <RequestData xmlns:xs="http://www.w3.org/2001/XMLSchema" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:type="xs:string"><?xml version="1.0" encoding="UTF-8"?><output xmlns="com:att:sdnctl:vnf"><svc-request-id>19174929-3809-49ca-89eb-17f84a035389</svc-request-id><response-code>200</response-code><ack-final-indicator>Y</ack-final-indicator><network-information><network-id>49c86598-f766-46f8-84f8-8d1c1b10f9b4</network-id></network-information><service-information><service-type>a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb</service-type><service-instance-id>HSL_direct_net_2</service-instance-id><subscriber-name>notsurewecare</subscriber-name></service-information></output></RequestData> + </SDNCAdapterCallbackRequest> + </soapenv:Body> +</soapenv:Envelope> diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/CRTGVNF_queryAAIResponseVolume.xml b/bpmn/MSOCommonBPMN/src/test/resources/__files/CRTGVNF_queryAAIResponseVolume.xml new file mode 100644 index 0000000000..52d2b01201 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/CRTGVNF_queryAAIResponseVolume.xml @@ -0,0 +1,22 @@ + <volume-group xmlns="http://com.att.aai.inventory/v6"> + <volume-group-id>a8399879-31b3-4973-be26-0a0cbe776b58</volume-group-id> + <volume-group-name>MoG_CinderVolumes_2</volume-group-name> + <heat-stack-id>MoG_CinderVolumes_2/19387dc6-060f-446e-b41f-dcfd29c73845</heat-stack-id> + <vnf-type>VmogSvc/moge2e2</vnf-type> + <orchestration-status>Active</orchestration-status> + <resource-version>1458839419</resource-version> + <relationship-list> + <relationship> + <related-to>tenant</related-to> + <related-link>https://aai-app-e2e.test.att.com:8443/aai/v6/cloud-infrastructure/tenants/tenant/7dd5365547234ee8937416c65507d266/</related-link> + <relationship-data> + <relationship-key>tenant.tenant-id</relationship-key> + <relationship-value>7dd5365547234ee8937416c65507d266</relationship-value> + </relationship-data> + <related-to-property> + <property-key>tenant.tenant-name</property-key> + <property-value>MOG-25208-D-01</property-value> + </related-to-property> + </relationship> + </relationship-list> + </volume-group>
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/CRTGVNF_queryAAIResponseVolume_idsNotMatch.xml b/bpmn/MSOCommonBPMN/src/test/resources/__files/CRTGVNF_queryAAIResponseVolume_idsNotMatch.xml new file mode 100644 index 0000000000..79e7d84ed8 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/CRTGVNF_queryAAIResponseVolume_idsNotMatch.xml @@ -0,0 +1,22 @@ + <volume-group xmlns="http://com.att.aai.inventory/v6"> + <volume-group-id>a8399879-31b3-4973-be26-0a0cbe776b58</volume-group-id> + <volume-group-name>MoG_CinderVolumes_2</volume-group-name> + <heat-stack-id>MoG_CinderVolumes_2/19387dc6-060f-446e-b41f-dcfd29c73845</heat-stack-id> + <vnf-type>VmogSvc/moge2e2</vnf-type> + <orchestration-status>Active</orchestration-status> + <resource-version>1458839419</resource-version> + <relationship-list> + <relationship> + <related-to>tenant</related-to> + <related-link>https://aai-app-e2e.test.att.com:8443/aai/v6/cloud-infrastructure/tenants/tenant/7dd5365547234ee8937416c65507d266/</related-link> + <relationship-data> + <relationship-key>tenant.tenant-id</relationship-key> + <relationship-value>83464847234ee8937416c65507d267</relationship-value> + </relationship-data> + <related-to-property> + <property-key>tenant.tenant-name</property-key> + <property-value>MOG-25208-D-01</property-value> + </related-to-property> + </relationship> + </relationship-list> + </volume-group>
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/CamundaDBScripts/Archive/ARCHIVE_CAMUNDA_HISTORY-Default Store Procedure.sql b/bpmn/MSOCommonBPMN/src/test/resources/__files/CamundaDBScripts/Archive/ARCHIVE_CAMUNDA_HISTORY-Default Store Procedure.sql new file mode 100644 index 0000000000..67c139ed31 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/CamundaDBScripts/Archive/ARCHIVE_CAMUNDA_HISTORY-Default Store Procedure.sql @@ -0,0 +1,140 @@ +/* +Camunda Version: 7.5.4-ee; MariaDB tested +Date: 11.30.2016 +Balaji Mudipalli, AJSC Camunda Team + +DOC.: +-------------------------------------------------------------------------------------- +Create ARCHIVE_CAMUNDA_HISTORY StoreProcedure -function for archiving of history camunda tables. +*/ + +/* uncomment below statement and run for your db, e.g. : use camundabpmn; + */ +-- use <db_name>; +use camundabpmn; +DROP PROCEDURE IF EXISTS ARCHIVE_CAMUNDA_HISTORY; + +DELIMITER // + +CREATE PROCEDURE ARCHIVE_CAMUNDA_HISTORY(IN IN_periodInDays INT, IN IN_maxProcessInstances INT) +MODIFIES SQL DATA + +BEGIN + DECLARE P_hiTableCount INT; + DECLARE P_executionId BIGINT; + DECLARE P_piProcessed DOUBLE; + DECLARE P_baProcessed DOUBLE; + DECLARE P_startDate DATE; + DECLARE P_executionDuration double; + + DECLARE not_found INT DEFAULT 0; + DECLARE CONTINUE HANDLER FOR NOT FOUND SET not_found = 1; + + /* START TRANSACTION */ + set P_startDate = sysdate(); + set P_executionId = NextVal('STAT_EXECUTION_SEQ'); + + INSERT INTO TMPLOGTABLE SELECT CONCAT('P_executionId value is ',P_executionId); + + DELETE FROM TMP_ARCHIVING_PROCINST; + DELETE FROM TMP_ARCHIVING_BYTEARRAY; + -- temp table -- + DELETE FROM TMPLOGTABLE; + + + /* 1. Set Default Value for Max Pi's */ + IF IN_maxProcessInstances = 0 THEN SET IN_maxProcessInstances = 1000; END IF; + IF IN_maxProcessInstances > 1000 THEN SET IN_maxProcessInstances = 1000; END IF; + + INSERT INTO TMPLOGTABLE SELECT CONCAT('IN_maxProcessInstances value is: ',IN_maxProcessInstances); + + /* 2. Fill TMP_ARCHIVING_PROCINST with candidates: */ + IF IN_maxProcessInstances = 0 THEN /* all */ + INSERT INTO TMP_ARCHIVING_PROCINST + SELECT hi.PROC_INST_ID_, hi.END_TIME_ + FROM ACT_HI_PROCINST hi + WHERE hi.END_TIME_ IS NOT NULL + AND hi.END_TIME_ <= ( DATE_SUB(SYSDATE(), INTERVAL IN_periodInDays DAY)); + + ELSE /* limit: IN_maxProcessInstances */ + INSERT INTO TMP_ARCHIVING_PROCINST + (PROC_INST_ID_, END_TIME_) ( + SELECT hi2.PROC_INST_ID_, hi2.END_TIME_ + FROM ACT_HI_PROCINST hi2 + WHERE hi2.END_TIME_ IS NOT NULL + AND hi2.END_TIME_ <= ( DATE_SUB(SYSDATE(), INTERVAL IN_periodInDays DAY)) + ) LIMIT IN_maxProcessInstances; + END IF; + + /* 3. Check PI's im TEMP if any found, ready for ACHIVING */ + select count(*) INTO P_piProcessed FROM TMP_ARCHIVING_PROCINST; + + IF P_piProcessed = 0 THEN + INSERT INTO TMPLOGTABLE SELECT CONCAT('P_piProcessed value is: ',P_piProcessed); + ROLLBACK; + /* 4. Move data from history to archive (insert to archive and delete in history) */ + ELSE + SELECT COUNT(*)+1 INTO P_hiTableCount FROM camunda_hi_tables; + INSERT INTO TMPLOGTABLE SELECT CONCAT('P_hiTableCount value is ',P_hiTableCount); + SET @i = 1; + WHILE @i < P_hiTableCount + DO + SELECT TableName_ INTO @P_tableName FROM camunda_hi_tables WHERE id_ = @i; + INSERT INTO TMPLOGTABLE SELECT CONCAT('P_tableName: ', @P_tableName); + + Set @P_archiveTableName = Concat('ARCHIVE_',IFNULL(@P_tableName, '')); + INSERT INTO TMPLOGTABLE SELECT CONCAT('@P_archiveTableName: ', @P_archiveTableName); + + SET @query1 = CONCAT('INSERT INTO ', @P_archiveTableName , + ' SELECT hi3.*, ',P_executionId, ', NOW() FROM ', @P_tableName,' hi3 + WHERE hi3.PROC_INST_ID_ in ( SELECT PROC_INST_ID_ FROM TMP_ARCHIVING_PROCINST)'); + INSERT INTO TMPLOGTABLE SELECT CONCAT('@query1: ', @query1); + + PREPARE stmt1 FROM @query1; + EXECUTE stmt1; + DEALLOCATE PREPARE stmt1; + + SET @query2 = CONCAT ('DELETE ACT FROM ',@P_tableName,' ACT INNER JOIN TMP_ARCHIVING_PROCINST TMP ON ACT.PROC_INST_ID_ = TMP.PROC_INST_ID_'); + INSERT INTO TMPLOGTABLE SELECT CONCAT('@query2: ', @query2); + + PREPARE stmt2 FROM @query2; + EXECUTE stmt2; + DEALLOCATE PREPARE stmt2; + + SET @i = @i+1; + END WHILE; + /* select bytearray_ids */ + INSERT INTO TMP_ARCHIVING_BYTEARRAY + SELECT BYTEARRAY_ID_, PROC_INST_ID_ FROM ARCHIVE_ACT_HI_VARINST archvar + where archvar.PROC_INST_ID_ in (SELECT PROC_INST_ID_ FROM TMP_ARCHIVING_PROCINST) + AND archvar.BYTEARRAY_ID_ is not null; + + INSERT INTO TMP_ARCHIVING_BYTEARRAY + SELECT BYTEARRAY_ID_, PROC_INST_ID_ FROM ARCHIVE_ACT_HI_DETAIL archvar + where archvar.PROC_INST_ID_ in (SELECT PROC_INST_ID_ FROM TMP_ARCHIVING_PROCINST) + AND archvar.BYTEARRAY_ID_ is not null; + + /* 5. Check Bytearrays im TEMP if any found, ready for ACHIVING */ + select count(*) INTO P_baProcessed FROM TMP_ARCHIVING_BYTEARRAY; + + /* INSERT */ + INSERT INTO ARCHIVE_ACT_GE_BYTEARRAY + SELECT hi4.*, P_executionId, NOW() FROM ACT_GE_BYTEARRAY hi4 + WHERE hi4.ID_ in ( SELECT BYTEARRAY_ID_ FROM TMP_ARCHIVING_BYTEARRAY); + + /* DELETE */ + DELETE FROM ACT_GE_BYTEARRAY WHERE ID_ in (select BYTEARRAY_ID_ FROM TMP_ARCHIVING_BYTEARRAY); + + /* COMMIT TRANSACTION */ + COMMIT; + INSERT INTO TMPLOGTABLE SELECT CONCAT('P_executionId is ', P_executionId); + + set P_executionDuration = DATEDIFF(sysdate(), P_startDate); + + INSERT INTO TMPLOGTABLE SELECT CONCAT('SP success and P_executionDuration is ', ifnull((round(P_executionDuration*24*60*60, 1)), ''), ' sec.'); + END IF; + + END; +// + +DELIMITER ;
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/CamundaDBScripts/Archive/ROLLB_ARCHIVE_CAMUNDA_HISTORY-StoreProcedure.sql b/bpmn/MSOCommonBPMN/src/test/resources/__files/CamundaDBScripts/Archive/ROLLB_ARCHIVE_CAMUNDA_HISTORY-StoreProcedure.sql new file mode 100644 index 0000000000..f3ba294dba --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/CamundaDBScripts/Archive/ROLLB_ARCHIVE_CAMUNDA_HISTORY-StoreProcedure.sql @@ -0,0 +1,210 @@ +/* +Camunda Version: 7.5.4-ee; MariaDB tested +Date: 11.30.2016 +Balaji Mudipalli, AJSC Camunda Team + +DOC.: +-------------------------------------------------------------------------------------- +Create ROLLB_ARCHIVE_CAMUNDA_HISTORY StoreProcedure for ROLLBACK (RESTORE) +of archived Camunda history tables. +*/ + +/* uncomment below statement and run for your db, e.g. : use camundabpmn; + */ +-- use <db_name>; +use camundabpmn; + +DROP PROCEDURE IF EXISTS ROLLB_ARCHIVE_CAMUNDA_HISTORY; + +DELIMITER // +CREATE PROCEDURE ROLLB_ARCHIVE_CAMUNDA_HISTORY(IN IN_executionId_from INT, + IN IN_executionId_til INT, + IN IN_maxProcessInstances INT) +MODIFIES SQL DATA + +BEGIN + DECLARE P_hiTableCount INT; + DECLARE P_piProcessed DOUBLE; + DECLARE P_baProcessed DOUBLE; + DECLARE P_query VARCHAR(600); + DECLARE P_startDate DATETIME; + DECLARE P_executionDuration DOUBLE; + DECLARE P_result NVARCHAR(400); +DECLARE not_found INT DEFAULT 0; + DECLARE CONTINUE HANDLER FOR NOT FOUND SET not_found = 1; + + + /* START TRANSACTION */ + SET P_startDate = sysdate(); + DELETE FROM TMPLOGTABLE; + + INSERT INTO TMPLOGTABLE SELECT CONCAT('[ROLLB_ARCHIVE_CAMUNDA_HISTORY]: START EXECUTION: ' , ifnull(date_format(current_timestamp, '%d.%m.%Y %H:%i:%s ..FF3'), '') , + '; PARAMS: IN_executionId_from: ' , IFNULL(IN_executionId_from, '') , + '; IN_executionId_til: ' , IFNULL(IN_executionId_til, '') , + '; IN_maxProcessInstances: ' , IFNULL(IN_maxProcessInstances, '')); + + /* 1. Truncate TMP_ARCHIVING_PROCINST */ + + DELETE FROM TMP_ARCHIVING_PROCINST; + DELETE FROM TMP_ARCHIVING_BYTEARRAY; + + /* 2. Fill TMP_ARCHIVING_PROCINST with candidates: */ + IF IN_executionId_til = -1 THEN /* IN_executionId_from only */ + SET P_query= CONCAT(' WHERE STAT_EXECUTION_ID = ' , IFNULL(IN_executionId_from, '')); + + ELSEIF IN_executionId_til = 0 THEN /* all from IN_executionId_from */ + SET P_query= CONCAT(' WHERE STAT_EXECUTION_ID >= ' , IFNULL(IN_executionId_from, '')); + + ELSE /* between IN_executionId_from AND IN_executionId_til */ + SET P_query= CONCAT(' WHERE STAT_EXECUTION_ID between ', IFNULL(IN_executionId_from, '') , ' AND ' , IFNULL(IN_executionId_til, '')); + END IF; + + IF IN_maxProcessInstances = 0 THEN /* all */ + + SET @P_query1 = CONCAT('INSERT INTO TMP_ARCHIVING_PROCINST ', ifnull(char(13 using ascii), ''),ifnull(char(10 using ascii), ''), + ' SELECT PROC_INST_ID_, END_TIME_ FROM ARCHIVE_ACT_HI_PROCINST ', ifnull(char(13 using ascii), ''),ifnull(char(10 using ascii), ''), + ' ', Ifnull(P_query, '')); + + ELSE /* limit: IN_maxProcessInstances */ + SET @P_query1 = CONCAT('INSERT INTO TMP_ARCHIVING_PROCINST ' ,ifnull(char(13 using ascii), ''),ifnull(char(10 using ascii), ''), + ' (PROC_INST_ID_, END_TIME_ ) ( ' ,ifnull(char(13 using ascii), ''),ifnull(char(10 using ascii), ''), + ' SELECT PROC_INST_ID_, END_TIME_ FROM ARCHIVE_ACT_HI_PROCINST ' ,ifnull(char(13 using ascii), ''),ifnull(char(10 using ascii), ''), + ' ', Ifnull(P_query, '') , ifnull(char(13 using ascii), ''),ifnull(char(10 using ascii), ''), + ') LIMIT ', IFNULL(IN_maxProcessInstances, '')); + END IF; + + INSERT INTO TMPLOGTABLE SELECT CONCAT('QUERY (before execute): /fill temp table with PI candidates/ ' , Ifnull(P_query, '')); + + PREPARE stmt1 FROM @P_query1; + EXECUTE stmt1; + DEALLOCATE PREPARE stmt1; + + INSERT INTO TMPLOGTABLE SELECT CONCAT('.... rows inserted into TMP_ARCHIVING_PROCINST: ' , IFNULL((ROW_COUNT()), '')); + + /* 3. Fill TMP_ARCHIVING_BYTEARRAYS with candidates: */ + INSERT INTO TMP_ARCHIVING_BYTEARRAY + SELECT BYTEARRAY_ID_, PROC_INST_ID_ FROM ARCHIVE_ACT_HI_VARINST archvar + where archvar.PROC_INST_ID_ in (SELECT PROC_INST_ID_ FROM TMP_ARCHIVING_PROCINST) + AND archvar.BYTEARRAY_ID_ is not null; + + INSERT INTO TMP_ARCHIVING_BYTEARRAY + SELECT BYTEARRAY_ID_, PROC_INST_ID_ FROM ARCHIVE_ACT_HI_DETAIL archvar + where archvar.PROC_INST_ID_ in (SELECT PROC_INST_ID_ FROM TMP_ARCHIVING_PROCINST) + AND archvar.BYTEARRAY_ID_ is not null; + + select count(*) INTO P_baProcessed FROM TMP_ARCHIVING_BYTEARRAY; + INSERT INTO TMPLOGTABLE SELECT CONCAT('[ROLLB_ARCHIVE_CAMUNDA_HISTORY]: ', IFNULL(P_baProcessed, '') ,' ByteArray candidates for rollback found!' , ifnull(char(13 using ascii), ''),ifnull(char(10 using ascii), '')); + + + /* 4. Check PI's im TEMP ready for ROLLBACK */ + select count(*) INTO P_piProcessed FROM TMP_ARCHIVING_PROCINST; + + IF P_piProcessed = 0 THEN /* no candidates found */ + INSERT INTO TMPLOGTABLE SELECT CONCAT('[ROLLB_ARCHIVE_CAMUNDA_HISTORY]: NO ProcessInstance-Candidates for archive-Rollback found! '); + INSERT INTO TMPLOGTABLE SELECT CONCAT('Try TA-ROLLBACK ...'); + ROLLBACK; /*-- TMP_ARCHIVING_PROCINST un-Delete */ + INSERT INTO TMPLOGTABLE SELECT CONCAT('TA-ROLLBACK DONE! ...' ,ifnull(char(13 using ascii), ''),ifnull(char(10 using ascii), '')); + + SET P_result = CONCAT('[ROLLB_ARCHIVE_CAMUNDA_HISTORY]: NO ProcessInstance candidates for archive-Rollback found!', ifnull(char(13 using ascii), ''),ifnull(char(10 using ascii), ''), + ifnull(date_format(current_timestamp, '%d.%m.%Y %H:%i:%s ..FF3'), '') , ifnull(char(13 using ascii), ''),ifnull(char(10 using ascii), ''), + ' Used PARAMS: IN_executionId_from: ' , IFNULL(IN_executionId_from, '') , + '; IN_executionId_til: ' , IFNULL(IN_executionId_til, '') , + '; IN_maxProcessInstances: ' , IFNULL(IN_maxProcessInstances, '')); + + INSERT INTO TMPLOGTABLE SELECT CONCAT(P_result); + + ELSE + INSERT INTO TMPLOGTABLE SELECT CONCAT('[ROLLB_ARCHIVE_CAMUNDA_HISTORY]: ', IFNULL(P_piProcessed, '') ,' ProcessInstance candidates for Rollback found!'); + + /* LOOP over tables */ + SELECT COUNT(*)+1 INTO P_hiTableCount FROM camunda_hi_tables; + + INSERT INTO TMPLOGTABLE SELECT CONCAT('P_hiTableCount value is ',P_hiTableCount); + + SET @i = 1; + + WHILE @i < P_hiTableCount + DO + SELECT TableName_ INTO @P_tableName FROM camunda_hi_tables WHERE id_ = @i; + + INSERT INTO TMPLOGTABLE SELECT CONCAT('[ROLLB_ARCHIVE_CAMUNDA_HISTORY]: ####### Start restore from: ARCHIVE_' , IFNULL(@P_tableName, '') ,' ...'); + + SET @P_tableFields = CONCAT(''); + + select GROUP_CONCAT(column_name order by ordinal_position) + INTO @P_tableFields + from information_schema.columns + where table_schema = (select DATABASE()) AND TABLE_NAME = @P_tableName; + + /* INSERT */ + SET @P_query2 = CONCAT('INSERT INTO ', IFNULL(@P_tableName, '') , + ' SELECT ' , @P_tableFields, + ' FROM ARCHIVE_' , IFNULL(@P_tableName, '') , + ' WHERE PROC_INST_ID_ in ( SELECT tmp.PROC_INST_ID_ FROM TMP_ARCHIVING_PROCINST tmp)'); + + INSERT INTO TMPLOGTABLE SELECT CONCAT('QUERY (before execute): /copy back to history table/ ' , Ifnull(@P_query2, '')); + + PREPARE stmt2 FROM @P_query2; + EXECUTE stmt2; + DEALLOCATE PREPARE stmt2; + + INSERT INTO TMPLOGTABLE SELECT Concat('.... rows inserted: ' , IFNULL((ROW_COUNT()), '')); + + /* DELETE */ + INSERT INTO TMPLOGTABLE SELECT CONCAT('[ROLLB_ARCHIVE_CAMUNDA_HISTORY]: Delete in Archive: ARCHIVE_' , IFNULL(@P_tableName, '') ,' ...'); + /* SET @P_query3 = CONCAT(' DELETE FROM ARCHIVE_' , IFNULL(@P_tableName, '') , ' WHERE PROC_INST_ID_ in (select PROC_INST_ID_ FROM TMP_ARCHIVING_PROCINST)'); */ + SET @P_query3 = CONCAT('DELETE ARCH FROM ARCHIVE_' , IFNULL(@P_tableName, '') , + ' ARCH INNER JOIN TMP_ARCHIVING_PROCINST TMP ON ARCH.PROC_INST_ID_ = TMP.PROC_INST_ID_'); + INSERT INTO TMPLOGTABLE SELECT CONCAT('QUERY (before execute): ' , Ifnull(@P_query3, '')); + PREPARE stmt3 FROM @P_query3; + EXECUTE stmt3; + DEALLOCATE PREPARE stmt3; + + INSERT INTO TMPLOGTABLE SELECT Concat('.... rows deleted: ' , IFNULL((ROW_COUNT()), '') , ifnull(char(13 using ascii), ''),ifnull(char(10 using ascii), '')); + + SET @i = @i+1; + END WHILE; + + /* INSERT */ + SET @P_tableFields2 = CONCAT(''); /* reset, becouse had some problems with double columns */ + /* fetch table column names into P_tableFields : */ + select GROUP_CONCAT(COLUMN_NAME order by ordinal_position) + INTO @P_tableFields2 + from information_schema.columns + where table_schema = (select DATABASE()) AND TABLE_NAME = 'ACT_GE_BYTEARRAY'; + + SET @P_query4 = CONCAT('INSERT INTO ACT_GE_BYTEARRAY ' ,ifnull(char(13 using ascii), ''),ifnull(char(10 using ascii), ''), + ' SELECT ' , IFNULL(@P_tableFields2, '') ,ifnull(char(13 using ascii), ''),ifnull(char(10 using ascii), ''), + ' FROM ARCHIVE_ACT_GE_BYTEARRAY' ,ifnull(char(13 using ascii), ''),ifnull(char(10 using ascii), ''), + ' WHERE ID_ in ( SELECT tmp.BYTEARRAY_ID_ FROM TMP_ARCHIVING_BYTEARRAY tmp)'); + INSERT INTO TMPLOGTABLE SELECT CONCAT('QUERY (before execute): /copy back to history table/ ' , Ifnull(@P_query4, '')); + PREPARE stmt4 FROM @P_query4; + EXECUTE stmt4; + DEALLOCATE PREPARE stmt4; + INSERT INTO TMPLOGTABLE SELECT Concat('.... rows inserted: ' , IFNULL((ROW_COUNT()), '')); + + /* DELETE */ + /* DELETE FROM ARCHIVE_ACT_GE_BYTEARRAY WHERE ID_ in (select BYTEARRAY_ID_ FROM TMP_ARCHIVING_BYTEARRAY); */ + DELETE AAGB FROM ARCHIVE_ACT_GE_BYTEARRAY AAGB INNER JOIN TMP_ARCHIVING_BYTEARRAY TMP_B ON AAGB.ID_ = TMP_B.BYTEARRAY_ID_; + INSERT INTO TMPLOGTABLE SELECT Concat('.... rows deleted: ' , IFNULL((ROW_COUNT()), '') , ifnull(char(13 using ascii), ''),ifnull(char(10 using ascii), '')); + + /* COMMIT TRANSACTION */ + INSERT INTO TMPLOGTABLE SELECT CONCAT('[ROLLB_ARCHIVE_CAMUNDA_HISTORY]: PIs processed: ' , IFNULL(P_piProcessed, '')) ; + COMMIT; + INSERT INTO TMPLOGTABLE SELECT CONCAT('TA-COMMIT DONE!' ,ifnull(char(13 using ascii), ''),ifnull(char(10 using ascii), '')); + + SET P_executionDuration = DATEDIFF(sysdate(), P_startDate); + + SET P_result = CONCAT('[ROLLB_ARCHIVE_CAMUNDA_HISTORY]: EXECUTED (commited) successfully! ' , ifnull(char(13 using ascii), ''),ifnull(char(10 using ascii), ''), + ifnull(date_format(current_timestamp, '%d.%m.%Y %H:%i:%s ..FF3'), '') , '; Duration: ' , ifnull((round(P_executionDuration*24*60*60, 1)), ''), ' sec.' , ifnull(char(13 using ascii), ''),ifnull(char(10 using ascii), '') , + ' PIs processed: ' , IFNULL(P_piProcessed, '') , ifnull(char(13 using ascii), ''),ifnull(char(10 using ascii), ''), + ' Used PARAMS: IN_executionId_from: ' , IFNULL(IN_executionId_from, '') , + '; IN_executionId_til: ' , IFNULL(IN_executionId_til, '') , + '; IN_maxProcessInstances: ' , IFNULL(IN_maxProcessInstances, '')); + + INSERT INTO TMPLOGTABLE SELECT CONCAT(P_result); + END IF; + END; +// + +DELIMITER ; diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/CamundaDBScripts/Archive/drop_mariadb_engine_7.5.6.sql b/bpmn/MSOCommonBPMN/src/test/resources/__files/CamundaDBScripts/Archive/drop_mariadb_engine_7.5.6.sql new file mode 100644 index 0000000000..10e9930720 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/CamundaDBScripts/Archive/drop_mariadb_engine_7.5.6.sql @@ -0,0 +1,76 @@ +-- Fix for https://itrack.web.att.com/browse/AJSCCMDA-90 -- +use camundabpmn; +/* +Drop a archive tables +*/ +/*-- TMP_ARCHIVING_PROCINST */ +DROP TABLE IF EXISTS TMP_ARCHIVING_PROCINST; + +/*-- TMP_ARCHIVING_BYTEARRAY */ +DROP TABLE IF EXISTS TMP_ARCHIVING_BYTEARRAY; + +/*-- TMP LOG TABLE */ +DROP TABLE IF EXISTS TMPLOGTABLE; + +/* -- Camunda Hi Tables --*/ +DROP TABLE IF EXISTS Camunda_Hi_Tables; + +/* drop own extentions columns: +alter table ARCHIVE_ACT_HI_PROCINST DROP (STAT_EXECUTION_ID, STAT_EXECUTION_TS); +alter table ARCHIVE_ACT_HI_ACTINST DROP (STAT_EXECUTION_ID, STAT_EXECUTION_TS); +alter table ARCHIVE_ACT_HI_TASKINST DROP (STAT_EXECUTION_ID, STAT_EXECUTION_TS); +alter table ARCHIVE_ACT_HI_VARINST DROP (STAT_EXECUTION_ID, STAT_EXECUTION_TS); +alter table ARCHIVE_ACT_HI_DETAIL DROP (STAT_EXECUTION_ID, STAT_EXECUTION_TS); +alter table ARCHIVE_ACT_HI_COMMENT DROP (STAT_EXECUTION_ID, STAT_EXECUTION_TS); +alter table ARCHIVE_ACT_HI_ATTACHMENT DROP (STAT_EXECUTION_ID, STAT_EXECUTION_TS); +alter table ARCHIVE_ACT_HI_OP_LOG DROP (STAT_EXECUTION_ID, STAT_EXECUTION_TS); +alter table ARCHIVE_ACT_HI_INCIDENT DROP (STAT_EXECUTION_ID, STAT_EXECUTION_TS); +*/ + +/*--#1 */ +DROP TABLE IF EXISTS ARCHIVE_ACT_HI_PROCINST; +/*--#2 */ +DROP TABLE IF EXISTS ARCHIVE_ACT_HI_ACTINST; +/*--#3 */ +DROP TABLE IF EXISTS ARCHIVE_ACT_HI_TASKINST; +/*--#4 */ +DROP TABLE IF EXISTS ARCHIVE_ACT_HI_VARINST; +/*--#5 */ +DROP TABLE IF EXISTS ARCHIVE_ACT_HI_DETAIL; +/*--#6 */ +DROP TABLE IF EXISTS ARCHIVE_ACT_HI_COMMENT; +/*--#7 */ +DROP TABLE IF EXISTS ARCHIVE_ACT_HI_ATTACHMENT; +/*--#8 */ +DROP TABLE IF EXISTS ARCHIVE_ACT_HI_OP_LOG; +/*--#9 */ +DROP TABLE IF EXISTS ARCHIVE_ACT_HI_INCIDENT; +/*--#10 */ +DROP TABLE IF EXISTS ARCHIVE_ACT_GE_BYTEARRAY; + +/* drop PL SQL procedures: */ +DROP PROCEDURE IF EXISTS ARCHIVE_CAMUNDA_HISTORY; +DROP PROCEDURE IF EXISTS ROLLB_ARCHIVE_CAMUNDA_HISTORY; + +/*-- Sequence */ +-- as sequence drop doesn't work automatically in MariaDB, use this procedure to drop sequence + DROP PROCEDURE IF EXISTS DropSequence; + + DELIMITER // + + CREATE PROCEDURE DropSequence (vname VARCHAR(30)) + BEGIN + -- Drop the sequence + DELETE FROM _sequences WHERE name = vname; + END + // + DELIMITER ; + +-- use the above procedure to drop sequence +CALL DropSequence('STAT_EXECUTION_SEQ'); + +/*-- To Drop the MariaDB specific user defined procedures and functions */ +DROP FUNCTION IF EXISTS NextVal; +DROP PROCEDURE IF EXISTS CreateSequence; +DROP PROCEDURE IF EXISTS DropSequence; +DROP TABLE IF EXISTS _sequences;
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/CamundaDBScripts/Archive/mariadb_engine_7.5_patch_7.5.6.sql b/bpmn/MSOCommonBPMN/src/test/resources/__files/CamundaDBScripts/Archive/mariadb_engine_7.5_patch_7.5.6.sql new file mode 100644 index 0000000000..8c7faa0792 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/CamundaDBScripts/Archive/mariadb_engine_7.5_patch_7.5.6.sql @@ -0,0 +1,222 @@ +-- Fix for https://itrack.web.att.com/browse/AJSCCMDA-90 -- +use camundabpmn; +/* + 1. Add some Camunda Indexes to history schema part (for Archiving) +*/ +create INDEX IF NOT EXISTS IDX_ACT_HI_TASKINST_PIID ON ACT_HI_TASKINST (PROC_INST_ID_); +create INDEX IF NOT EXISTS IDX_ACT_HI_COMMENT_PIID ON ACT_HI_COMMENT (PROC_INST_ID_); +create INDEX IF NOT EXISTS IDX_ACT_HI_ATTACHMENT_PIID ON ACT_HI_ATTACHMENT (PROC_INST_ID_); +create INDEX IF NOT EXISTS IDX_ACT_HI_OP_LOG_PIID ON ACT_HI_OP_LOG (PROC_INST_ID_); +create INDEX IF NOT EXISTS IDX_ACT_HI_INCIDENT_PIID ON ACT_HI_INCIDENT (PROC_INST_ID_); +create INDEX IF NOT EXISTS IDX_ACT_HI_ACTINST_PIID ON ACT_HI_ACTINST(PROC_INST_ID_); + + +/* + 2. Create Archiving Tables in current schema +*/ + +/*-- TMP_ARCHIVING_PROCINST */ +CREATE TABLE TMP_ARCHIVING_PROCINST +( PROC_INST_ID_ varchar(64) not null, + END_TIME_ datetime(3) +); +CREATE INDEX AI_TMP_ARCH_PROCINST_PI_ID ON TMP_ARCHIVING_PROCINST(PROC_INST_ID_); + +/*-- TMP_ARCHIVING_BYTEARRAY */ +CREATE TABLE TMP_ARCHIVING_BYTEARRAY +( BYTEARRAY_ID_ varchar(64) not null, + PROC_INST_ID_ varchar(64) +); +CREATE INDEX AI_TMP_ARCH_BYTEARRAY_BAID ON TMP_ARCHIVING_BYTEARRAY(BYTEARRAY_ID_); + + +/*--#1 ARCHIVE_ACT_HI_PROCINST; */ +create TABLE ARCHIVE_ACT_HI_PROCINST +AS ( select * from ACT_HI_PROCINST where 1=0); + +create index AI_HI_PROCINST_END_TIME on ARCHIVE_ACT_HI_PROCINST(END_TIME_); +ALTER TABLE ARCHIVE_ACT_HI_PROCINST ADD CONSTRAINT ARCHIVE_ACT_HI_PROCINST_UQ UNIQUE ( PROC_INST_ID_); + +/*--#2 ARCHIVE_ACT_HI_ACTINST; */ +create TABLE ARCHIVE_ACT_HI_ACTINST +AS ( select * from ACT_HI_ACTINST where 1=0); + +create index AI_HI_ACTINST_PROC_INST_ID on ARCHIVE_ACT_HI_ACTINST(PROC_INST_ID_); +create index AI_HI_ACTINST_END_TIME on ARCHIVE_ACT_HI_ACTINST(END_TIME_); + +/*--#3 ARCHIVE_ACT_HI_TASKINST; */ +create TABLE ARCHIVE_ACT_HI_TASKINST +AS ( select * from ACT_HI_TASKINST where 1=0); + +create index AI_HI_TASKINST_PROC_INST_ID on ARCHIVE_ACT_HI_TASKINST(PROC_INST_ID_); +create index AI_HI_TASKINST_END_TIME on ARCHIVE_ACT_HI_TASKINST(END_TIME_); + +/*--#4 ARCHIVE_ACT_HI_VARINST; */ +create TABLE ARCHIVE_ACT_HI_VARINST +AS ( select * from ACT_HI_VARINST where 1=0); + +create index AI_HI_VARINST_PROC_INST_ID on ARCHIVE_ACT_HI_VARINST(PROC_INST_ID_); + +/*--#5 ARCHIVE_ACT_HI_DETAIL; */ +create TABLE ARCHIVE_ACT_HI_DETAIL +AS ( select * from ACT_HI_DETAIL where 1=0); + +create index AI_HI_DETAIL_PROC_INST_ID on ARCHIVE_ACT_HI_DETAIL(PROC_INST_ID_); +create index AI_HI_DETAIL_TIME on ARCHIVE_ACT_HI_DETAIL(TIME_); + +/*--#6 ARCHIVE_ACT_HI_COMMENT; */ +create TABLE ARCHIVE_ACT_HI_COMMENT +AS ( select * from ACT_HI_COMMENT where 1=0); + +create index AI_HI_COMMENT_PROC_INST_ID on ARCHIVE_ACT_HI_COMMENT(PROC_INST_ID_); +create index AI_HI_COMMENT_TIME on ARCHIVE_ACT_HI_COMMENT(TIME_); + +/*--#7 ARCHIVE_ACT_HI_ATTACHMENT; */ +create TABLE ARCHIVE_ACT_HI_ATTACHMENT +AS ( select * from ACT_HI_ATTACHMENT where 1=0); + +create index AI_HI_ATTACHMENT_PROC_INST_ID on ARCHIVE_ACT_HI_ATTACHMENT(PROC_INST_ID_); + +/*--#8 ARCHIVE_ACT_HI_OP_LOG; */ +create TABLE ARCHIVE_ACT_HI_OP_LOG +AS ( select * from ACT_HI_OP_LOG where 1=0); + +create index AI_HI_OP_LOG_PROC_INST_ID on ARCHIVE_ACT_HI_OP_LOG(PROC_INST_ID_); +create index AI_HI_OP_LOG_TIMESTAMP on ARCHIVE_ACT_HI_OP_LOG(TIMESTAMP_); + +/*--#9 ARCHIVE_ACT_HI_INCIDENT; */ +create TABLE ARCHIVE_ACT_HI_INCIDENT +AS ( select * from ACT_HI_INCIDENT where 1=0); + +create index AI_HI_INCIDENT_PROC_INST_ID on ARCHIVE_ACT_HI_INCIDENT(PROC_INST_ID_); + +/*--#10 ARCHIVE_ACT_GE_BYTEARRAY; */ +create TABLE ARCHIVE_ACT_GE_BYTEARRAY +AS ( select * from ACT_GE_BYTEARRAY where 1=0); + +create index AI_GE_BYTEARRAY_ID_ on ARCHIVE_ACT_GE_BYTEARRAY(ID_); + +/* ----------------------------------------------------------------------------- +Extend a ARCHIVE: Table by two attributes: STAT_EXECUTION_ID, STAT_EXECUTION_TS +*/ + +/* +--TEMPLATE: +alter table ARCHIVE_%TableName% + add (STAT_EXECUTION_ID bigint, STAT_EXECUTION_TS timestamp(0) DEFAULT CURRENT_TIMESTAMP ); +CREATE INDEX AI_%TableName%_EXE_ID ON ARCHIVE_%TableName%(STAT_EXECUTION_ID); +*/ + + +/*--#1 ACT_HI_PROCINST */ +alter table ARCHIVE_ACT_HI_PROCINST + add (STAT_EXECUTION_ID bigint, STAT_EXECUTION_TS timestamp(0) DEFAULT CURRENT_TIMESTAMP ); +CREATE INDEX AI_ACT_HI_PROCINST_EXE_ID ON ARCHIVE_ACT_HI_PROCINST(STAT_EXECUTION_ID); + +/*--#2 ACT_HI_ACTINST */ +alter table ARCHIVE_ACT_HI_ACTINST + add (STAT_EXECUTION_ID bigint, STAT_EXECUTION_TS timestamp(0) DEFAULT CURRENT_TIMESTAMP ); +CREATE INDEX AI_ACT_HI_ACTINST_EXE_ID ON ARCHIVE_ACT_HI_ACTINST(STAT_EXECUTION_ID); + +/*--#3 ACT_HI_TASKINST */ +alter table ARCHIVE_ACT_HI_TASKINST + add (STAT_EXECUTION_ID bigint, STAT_EXECUTION_TS timestamp(0) DEFAULT CURRENT_TIMESTAMP ); +CREATE INDEX AI_ACT_HI_TASKINST_EXE_ID ON ARCHIVE_ACT_HI_TASKINST(STAT_EXECUTION_ID); + +/*--#4 ACT_HI_VARINST */ +alter table ARCHIVE_ACT_HI_VARINST + add (STAT_EXECUTION_ID bigint, STAT_EXECUTION_TS timestamp(0) DEFAULT CURRENT_TIMESTAMP ); +CREATE INDEX AI_ACT_HI_VARINST_EXE_ID ON ARCHIVE_ACT_HI_VARINST(STAT_EXECUTION_ID); + +/*--#5 ACT_HI_DETAIL */ +alter table ARCHIVE_ACT_HI_DETAIL + add (STAT_EXECUTION_ID bigint, STAT_EXECUTION_TS timestamp(0) DEFAULT CURRENT_TIMESTAMP ); +CREATE INDEX AI_ACT_HI_DETAIL_EXE_ID ON ARCHIVE_ACT_HI_DETAIL(STAT_EXECUTION_ID); + +/*--#6 ACT_HI_COMMENT */ +alter table ARCHIVE_ACT_HI_COMMENT + add (STAT_EXECUTION_ID bigint, STAT_EXECUTION_TS timestamp(0) DEFAULT CURRENT_TIMESTAMP ); +CREATE INDEX AI_ACT_HI_COMMENT_EXE_ID ON ARCHIVE_ACT_HI_COMMENT(STAT_EXECUTION_ID); + +/*--#7 ACT_HI_ATTACHMENT */ +alter table ARCHIVE_ACT_HI_ATTACHMENT + add (STAT_EXECUTION_ID bigint, STAT_EXECUTION_TS timestamp(0) DEFAULT CURRENT_TIMESTAMP ); +CREATE INDEX AI_ACT_HI_ATTACHMENT_EXE_ID ON ARCHIVE_ACT_HI_ATTACHMENT(STAT_EXECUTION_ID); + +/*--#8 ACT_HI_OP_LOG */ +alter table ARCHIVE_ACT_HI_OP_LOG + add (STAT_EXECUTION_ID bigint, STAT_EXECUTION_TS timestamp(0) DEFAULT CURRENT_TIMESTAMP ); +CREATE INDEX AI_ACT_HI_OP_LOG_EXE_ID ON ARCHIVE_ACT_HI_OP_LOG(STAT_EXECUTION_ID); + +/*--#9 ACT_HI_INCIDENT */ +alter table ARCHIVE_ACT_HI_INCIDENT + add (STAT_EXECUTION_ID bigint, STAT_EXECUTION_TS timestamp(0) DEFAULT CURRENT_TIMESTAMP ); +CREATE INDEX AI_ACT_HI_INCIDENT_EXE_ID ON ARCHIVE_ACT_HI_INCIDENT(STAT_EXECUTION_ID); + +/*--#10 ACT_GE_BYTEARRAY */ +alter table ARCHIVE_ACT_GE_BYTEARRAY + add (STAT_EXECUTION_ID bigint, STAT_EXECUTION_TS timestamp(0) DEFAULT CURRENT_TIMESTAMP ); +CREATE INDEX AI_ACT_GE_BYTEARRAY_EXE_ID ON ARCHIVE_ACT_GE_BYTEARRAY(STAT_EXECUTION_ID); + + +/* -- Next Val as a user defined function needed only in MariaDB--*/ +DROP FUNCTION IF EXISTS NextVal; + DELIMITER // + CREATE FUNCTION NextVal (vname VARCHAR(30)) + RETURNS INT + BEGIN + -- Retrieve and update in single statement + UPDATE _sequences + SET next = next + 1 + WHERE name = vname; + + RETURN (SELECT next FROM _sequences LIMIT 1); + END + // + DELIMITER ; + +/* -- History tables for use in archive procedure, there is no array type in MariaDB --*/ +Create Table Camunda_Hi_Tables (id_ MEDIUMINT NOT NULL AUTO_INCREMENT, + TableName_ varchar(80) NOT NULL, + PRIMARY KEY (id_)); + +Insert Into Camunda_Hi_Tables(TableName_) Values ('ACT_HI_PROCINST'); +Insert Into Camunda_Hi_Tables(TableName_) Values ('ACT_HI_ACTINST'); +Insert Into Camunda_Hi_Tables(TableName_) Values ('ACT_HI_TASKINST'); +Insert Into Camunda_Hi_Tables(TableName_) Values ('ACT_HI_VARINST'); +Insert Into Camunda_Hi_Tables(TableName_) Values ('ACT_HI_DETAIL'); +Insert Into Camunda_Hi_Tables(TableName_) Values ('ACT_HI_COMMENT'); +Insert Into Camunda_Hi_Tables(TableName_) Values ('ACT_HI_ATTACHMENT'); +Insert Into Camunda_Hi_Tables(TableName_) Values ('ACT_HI_OP_LOG'); +Insert Into Camunda_Hi_Tables(TableName_) Values ('ACT_HI_INCIDENT'); + +/*-- log table --*/ +CREATE TABLE TMPLOGTABLE (LogMessage Varchar(700)); + + +/* -- Below user defined functions and procedures needed only in MariaDB, they are in-built in Oracle --*/ +/*-- Create a sequence SP */ +DROP PROCEDURE IF EXISTS CreateSequence; + DELIMITER // + CREATE PROCEDURE CreateSequence (name VARCHAR(30), start INT, inc INT) + BEGIN + -- Create a table to store sequences + CREATE TABLE IF NOT EXISTS _sequences + ( + name VARCHAR(70) NOT NULL UNIQUE, + next INT NOT NULL, + inc INT NOT NULL + ); + + -- Add the new sequence + INSERT INTO _sequences VALUES (name, start, inc); + END + // + DELIMITER ; + +/*-------------------------------------------------------------------------------------------------- + Add Meta to Archive + -------------------------------------------------------------------------------------------------- */ + +/* Create STAT_EXECUTION_SEQ: each Archive Entry has a same Execution ID during one Archiving Run */ +CALL CreateSequence('STAT_EXECUTION_SEQ', 1, 1); diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/CamundaDBScripts/Cleanup/create_mariadb_camunda7.5.6_ee.sql b/bpmn/MSOCommonBPMN/src/test/resources/__files/CamundaDBScripts/Cleanup/create_mariadb_camunda7.5.6_ee.sql new file mode 100644 index 0000000000..bf866b4878 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/CamundaDBScripts/Cleanup/create_mariadb_camunda7.5.6_ee.sql @@ -0,0 +1,1127 @@ + +# Start of Statements added for MSO +DROP DATABASE IF EXISTS `camundabpmn`; + +CREATE DATABASE /*!32312 IF NOT EXISTS*/ `camundabpmn` /*!40100 DEFAULT CHARACTER SET latin1 */; + +USE `camundabpmn`; + +# DROP USER IF EXISTS 'camunda'; +#delete from mysql.user where User='camunda'; +#CREATE USER 'camunda'; +#GRANT ALL on camundabpmn.* to 'camunda' identified by 'camunda123' with GRANT OPTION; +FLUSH PRIVILEGES; +# End of Statements added for MSO + + +create table ACT_GE_PROPERTY ( + NAME_ varchar(64), + VALUE_ varchar(300), + REV_ integer, + primary key (NAME_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +insert into ACT_GE_PROPERTY +values ('schema.version', 'fox', 1); + +insert into ACT_GE_PROPERTY +values ('schema.history', 'create(fox)', 1); + +insert into ACT_GE_PROPERTY +values ('next.dbid', '1', 1); + +insert into ACT_GE_PROPERTY +values ('deployment.lock', '0', 1); + +create table ACT_GE_BYTEARRAY ( + ID_ varchar(64), + REV_ integer, + NAME_ varchar(255), + DEPLOYMENT_ID_ varchar(64), + BYTES_ LONGBLOB, + GENERATED_ TINYINT, + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_RE_DEPLOYMENT ( + ID_ varchar(64), + NAME_ varchar(255), + DEPLOY_TIME_ timestamp(3), + SOURCE_ varchar(255), + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_RU_EXECUTION ( + ID_ varchar(64), + REV_ integer, + PROC_INST_ID_ varchar(64), + BUSINESS_KEY_ varchar(255), + PARENT_ID_ varchar(64), + PROC_DEF_ID_ varchar(64), + SUPER_EXEC_ varchar(64), + SUPER_CASE_EXEC_ varchar(64), + CASE_INST_ID_ varchar(64), + ACT_ID_ varchar(255), + ACT_INST_ID_ varchar(64), + IS_ACTIVE_ TINYINT, + IS_CONCURRENT_ TINYINT, + IS_SCOPE_ TINYINT, + IS_EVENT_SCOPE_ TINYINT, + SUSPENSION_STATE_ integer, + CACHED_ENT_STATE_ integer, + SEQUENCE_COUNTER_ bigint, + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_RU_JOB ( + ID_ varchar(64) NOT NULL, + REV_ integer, + TYPE_ varchar(255) NOT NULL, + LOCK_EXP_TIME_ timestamp(3) NULL, + LOCK_OWNER_ varchar(255), + EXCLUSIVE_ boolean, + EXECUTION_ID_ varchar(64), + PROCESS_INSTANCE_ID_ varchar(64), + PROCESS_DEF_ID_ varchar(64), + PROCESS_DEF_KEY_ varchar(255), + RETRIES_ integer, + EXCEPTION_STACK_ID_ varchar(64), + EXCEPTION_MSG_ varchar(4000), + DUEDATE_ timestamp(3) NULL, + REPEAT_ varchar(255), + HANDLER_TYPE_ varchar(255), + HANDLER_CFG_ varchar(4000), + DEPLOYMENT_ID_ varchar(64), + SUSPENSION_STATE_ integer NOT NULL DEFAULT 1, + JOB_DEF_ID_ varchar(64), + PRIORITY_ bigint NOT NULL DEFAULT 0, + SEQUENCE_COUNTER_ bigint, + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_RU_JOBDEF ( + ID_ varchar(64) NOT NULL, + REV_ integer, + PROC_DEF_ID_ varchar(64), + PROC_DEF_KEY_ varchar(255), + ACT_ID_ varchar(255), + JOB_TYPE_ varchar(255) NOT NULL, + JOB_CONFIGURATION_ varchar(255), + SUSPENSION_STATE_ integer, + JOB_PRIORITY_ bigint, + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_RE_PROCDEF ( + ID_ varchar(64) not null, + REV_ integer, + CATEGORY_ varchar(255), + NAME_ varchar(255), + KEY_ varchar(255) not null, + VERSION_ integer not null, + DEPLOYMENT_ID_ varchar(64), + RESOURCE_NAME_ varchar(4000), + DGRM_RESOURCE_NAME_ varchar(4000), + HAS_START_FORM_KEY_ TINYINT, + SUSPENSION_STATE_ integer, + TENANT_ID_ varchar(64), + VERSION_TAG_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_RU_TASK ( + ID_ varchar(64), + REV_ integer, + EXECUTION_ID_ varchar(64), + PROC_INST_ID_ varchar(64), + PROC_DEF_ID_ varchar(64), + CASE_EXECUTION_ID_ varchar(64), + CASE_INST_ID_ varchar(64), + CASE_DEF_ID_ varchar(64), + NAME_ varchar(255), + PARENT_TASK_ID_ varchar(64), + DESCRIPTION_ varchar(4000), + TASK_DEF_KEY_ varchar(255), + OWNER_ varchar(255), + ASSIGNEE_ varchar(255), + DELEGATION_ varchar(64), + PRIORITY_ integer, + CREATE_TIME_ timestamp(3), + DUE_DATE_ datetime(3), + FOLLOW_UP_DATE_ datetime(3), + SUSPENSION_STATE_ integer, + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_RU_IDENTITYLINK ( + ID_ varchar(64), + REV_ integer, + GROUP_ID_ varchar(255), + TYPE_ varchar(255), + USER_ID_ varchar(255), + TASK_ID_ varchar(64), + PROC_DEF_ID_ varchar(64), + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_RU_VARIABLE ( + ID_ varchar(64) not null, + REV_ integer, + TYPE_ varchar(255) not null, + NAME_ varchar(255) not null, + EXECUTION_ID_ varchar(64), + PROC_INST_ID_ varchar(64), + CASE_EXECUTION_ID_ varchar(64), + CASE_INST_ID_ varchar(64), + TASK_ID_ varchar(64), + BYTEARRAY_ID_ varchar(64), + DOUBLE_ double, + LONG_ bigint, + TEXT_ LONGBLOB NULL, + TEXT2_ LONGBLOB NULL, + VAR_SCOPE_ varchar(64) not null, + SEQUENCE_COUNTER_ bigint, + IS_CONCURRENT_LOCAL_ TINYINT, + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_RU_EVENT_SUBSCR ( + ID_ varchar(64) not null, + REV_ integer, + EVENT_TYPE_ varchar(255) not null, + EVENT_NAME_ varchar(255), + EXECUTION_ID_ varchar(64), + PROC_INST_ID_ varchar(64), + ACTIVITY_ID_ varchar(64), + CONFIGURATION_ varchar(255), + CREATED_ timestamp(3) not null, + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_RU_INCIDENT ( + ID_ varchar(64) not null, + REV_ integer not null, + INCIDENT_TIMESTAMP_ timestamp(3) not null, + INCIDENT_MSG_ varchar(4000), + INCIDENT_TYPE_ varchar(255) not null, + EXECUTION_ID_ varchar(64), + ACTIVITY_ID_ varchar(255), + PROC_INST_ID_ varchar(64), + PROC_DEF_ID_ varchar(64), + CAUSE_INCIDENT_ID_ varchar(64), + ROOT_CAUSE_INCIDENT_ID_ varchar(64), + CONFIGURATION_ varchar(255), + TENANT_ID_ varchar(64), + JOB_DEF_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_RU_AUTHORIZATION ( + ID_ varchar(64) not null, + REV_ integer not null, + TYPE_ integer not null, + GROUP_ID_ varchar(255), + USER_ID_ varchar(255), + RESOURCE_TYPE_ integer not null, + RESOURCE_ID_ varchar(64), + PERMS_ integer, + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_RU_FILTER ( + ID_ varchar(64) not null, + REV_ integer not null, + RESOURCE_TYPE_ varchar(255) not null, + NAME_ varchar(255) not null, + OWNER_ varchar(255), + QUERY_ LONGTEXT not null, + PROPERTIES_ LONGTEXT, + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_RU_METER_LOG ( + ID_ varchar(64) not null, + NAME_ varchar(64) not null, + REPORTER_ varchar(255), + VALUE_ bigint, + TIMESTAMP_ timestamp(3) not null, + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_RU_EXT_TASK ( + ID_ varchar(64) not null, + REV_ integer not null, + WORKER_ID_ varchar(255), + TOPIC_NAME_ varchar(255), + RETRIES_ integer, + ERROR_MSG_ varchar(4000), + LOCK_EXP_TIME_ timestamp(3) NULL, + SUSPENSION_STATE_ integer, + EXECUTION_ID_ varchar(64), + PROC_INST_ID_ varchar(64), + PROC_DEF_ID_ varchar(64), + PROC_DEF_KEY_ varchar(255), + ACT_ID_ varchar(255), + ACT_INST_ID_ varchar(64), + TENANT_ID_ varchar(64), + PRIORITY_ bigint NOT NULL DEFAULT 0, + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_RU_BATCH ( + ID_ varchar(64) not null, + REV_ integer not null, + TYPE_ varchar(255), + TOTAL_JOBS_ integer, + JOBS_CREATED_ integer, + JOBS_PER_SEED_ integer, + INVOCATIONS_PER_JOB_ integer, + SEED_JOB_DEF_ID_ varchar(64), + BATCH_JOB_DEF_ID_ varchar(64), + MONITOR_JOB_DEF_ID_ varchar(64), + SUSPENSION_STATE_ integer, + CONFIGURATION_ varchar(255), + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create index ACT_IDX_EXEC_BUSKEY on ACT_RU_EXECUTION(BUSINESS_KEY_); +create index ACT_IDX_EXEC_TENANT_ID on ACT_RU_EXECUTION(TENANT_ID_); +create index ACT_IDX_TASK_CREATE on ACT_RU_TASK(CREATE_TIME_); +create index ACT_IDX_TASK_ASSIGNEE on ACT_RU_TASK(ASSIGNEE_); +create index ACT_IDX_TASK_TENANT_ID on ACT_RU_TASK(TENANT_ID_); +create index ACT_IDX_IDENT_LNK_USER on ACT_RU_IDENTITYLINK(USER_ID_); +create index ACT_IDX_IDENT_LNK_GROUP on ACT_RU_IDENTITYLINK(GROUP_ID_); +create index ACT_IDX_EVENT_SUBSCR_CONFIG_ on ACT_RU_EVENT_SUBSCR(CONFIGURATION_); +create index ACT_IDX_EVENT_SUBSCR_TENANT_ID on ACT_RU_EVENT_SUBSCR(TENANT_ID_); +create index ACT_IDX_VARIABLE_TASK_ID on ACT_RU_VARIABLE(TASK_ID_); +create index ACT_IDX_VARIABLE_TENANT_ID on ACT_RU_VARIABLE(TENANT_ID_); +create index ACT_IDX_ATHRZ_PROCEDEF on ACT_RU_IDENTITYLINK(PROC_DEF_ID_); +create index ACT_IDX_INC_CONFIGURATION on ACT_RU_INCIDENT(CONFIGURATION_); +create index ACT_IDX_INC_TENANT_ID on ACT_RU_INCIDENT(TENANT_ID_); +create index ACT_IDX_JOB_PROCINST on ACT_RU_JOB(PROCESS_INSTANCE_ID_); +create index ACT_IDX_JOB_TENANT_ID on ACT_RU_JOB(TENANT_ID_); +create index ACT_IDX_JOBDEF_TENANT_ID on ACT_RU_JOBDEF(TENANT_ID_); +create index ACT_IDX_METER_LOG on ACT_RU_METER_LOG(NAME_,TIMESTAMP_); +create index ACT_IDX_EXT_TASK_TOPIC on ACT_RU_EXT_TASK(TOPIC_NAME_); +create index ACT_IDX_EXT_TASK_TENANT_ID on ACT_RU_EXT_TASK(TENANT_ID_); +create index ACT_IDX_EXT_TASK_PRIORITY ON ACT_RU_EXT_TASK(PRIORITY_); +create index ACT_IDX_AUTH_GROUP_ID ON ACT_RU_AUTHORIZATION(GROUP_ID_); +create index ACT_IDX_JOB_JOB_DEF_ID on ACT_RU_JOB(JOB_DEF_ID_); + +alter table ACT_GE_BYTEARRAY + add constraint ACT_FK_BYTEARR_DEPL + foreign key (DEPLOYMENT_ID_) + references ACT_RE_DEPLOYMENT (ID_); + +alter table ACT_RU_EXECUTION + add constraint ACT_FK_EXE_PROCINST + foreign key (PROC_INST_ID_) + references ACT_RU_EXECUTION (ID_) on delete cascade on update cascade; + +alter table ACT_RU_EXECUTION + add constraint ACT_FK_EXE_PARENT + foreign key (PARENT_ID_) + references ACT_RU_EXECUTION (ID_); + +alter table ACT_RU_EXECUTION + add constraint ACT_FK_EXE_SUPER + foreign key (SUPER_EXEC_) + references ACT_RU_EXECUTION (ID_); + +alter table ACT_RU_EXECUTION + add constraint ACT_FK_EXE_PROCDEF + foreign key (PROC_DEF_ID_) + references ACT_RE_PROCDEF (ID_); + +alter table ACT_RU_IDENTITYLINK + add constraint ACT_FK_TSKASS_TASK + foreign key (TASK_ID_) + references ACT_RU_TASK (ID_); + +alter table ACT_RU_IDENTITYLINK + add constraint ACT_FK_ATHRZ_PROCEDEF + foreign key (PROC_DEF_ID_) + references ACT_RE_PROCDEF(ID_); + +alter table ACT_RU_TASK + add constraint ACT_FK_TASK_EXE + foreign key (EXECUTION_ID_) + references ACT_RU_EXECUTION (ID_); + +alter table ACT_RU_TASK + add constraint ACT_FK_TASK_PROCINST + foreign key (PROC_INST_ID_) + references ACT_RU_EXECUTION (ID_); + +alter table ACT_RU_TASK + add constraint ACT_FK_TASK_PROCDEF + foreign key (PROC_DEF_ID_) + references ACT_RE_PROCDEF (ID_); + +alter table ACT_RU_VARIABLE + add constraint ACT_FK_VAR_EXE + foreign key (EXECUTION_ID_) + references ACT_RU_EXECUTION (ID_); + +alter table ACT_RU_VARIABLE + add constraint ACT_FK_VAR_PROCINST + foreign key (PROC_INST_ID_) + references ACT_RU_EXECUTION(ID_); + +alter table ACT_RU_VARIABLE + add constraint ACT_FK_VAR_BYTEARRAY + foreign key (BYTEARRAY_ID_) + references ACT_GE_BYTEARRAY (ID_); + +alter table ACT_RU_JOB + add constraint ACT_FK_JOB_EXCEPTION + foreign key (EXCEPTION_STACK_ID_) + references ACT_GE_BYTEARRAY (ID_); + +alter table ACT_RU_EVENT_SUBSCR + add constraint ACT_FK_EVENT_EXEC + foreign key (EXECUTION_ID_) + references ACT_RU_EXECUTION(ID_); + +alter table ACT_RU_INCIDENT + add constraint ACT_FK_INC_EXE + foreign key (EXECUTION_ID_) + references ACT_RU_EXECUTION (ID_); + +alter table ACT_RU_INCIDENT + add constraint ACT_FK_INC_PROCINST + foreign key (PROC_INST_ID_) + references ACT_RU_EXECUTION (ID_); + +alter table ACT_RU_INCIDENT + add constraint ACT_FK_INC_PROCDEF + foreign key (PROC_DEF_ID_) + references ACT_RE_PROCDEF (ID_); + +alter table ACT_RU_INCIDENT + add constraint ACT_FK_INC_CAUSE + foreign key (CAUSE_INCIDENT_ID_) + references ACT_RU_INCIDENT (ID_) on delete cascade on update cascade; + +alter table ACT_RU_INCIDENT + add constraint ACT_FK_INC_RCAUSE + foreign key (ROOT_CAUSE_INCIDENT_ID_) + references ACT_RU_INCIDENT (ID_) on delete cascade on update cascade; + +create index ACT_IDX_INC_JOB_DEF on ACT_RU_INCIDENT(JOB_DEF_ID_); +alter table ACT_RU_INCIDENT + add constraint ACT_FK_INC_JOB_DEF + foreign key (JOB_DEF_ID_) + references ACT_RU_JOBDEF (ID_); + +alter table ACT_RU_AUTHORIZATION + add constraint ACT_UNIQ_AUTH_USER + unique (USER_ID_,TYPE_,RESOURCE_TYPE_,RESOURCE_ID_); + +alter table ACT_RU_AUTHORIZATION + add constraint ACT_UNIQ_AUTH_GROUP + unique (GROUP_ID_,TYPE_,RESOURCE_TYPE_,RESOURCE_ID_); + +alter table ACT_RU_VARIABLE + add constraint ACT_UNIQ_VARIABLE + unique (VAR_SCOPE_, NAME_); + +alter table ACT_RU_EXT_TASK + add constraint ACT_FK_EXT_TASK_EXE + foreign key (EXECUTION_ID_) + references ACT_RU_EXECUTION (ID_); + +create index ACT_IDX_BATCH_SEED_JOB_DEF ON ACT_RU_BATCH(SEED_JOB_DEF_ID_); +alter table ACT_RU_BATCH + add constraint ACT_FK_BATCH_SEED_JOB_DEF + foreign key (SEED_JOB_DEF_ID_) + references ACT_RU_JOBDEF (ID_); + +create index ACT_IDX_BATCH_MONITOR_JOB_DEF ON ACT_RU_BATCH(MONITOR_JOB_DEF_ID_); +alter table ACT_RU_BATCH + add constraint ACT_FK_BATCH_MONITOR_JOB_DEF + foreign key (MONITOR_JOB_DEF_ID_) + references ACT_RU_JOBDEF (ID_); + +create index ACT_IDX_BATCH_JOB_DEF ON ACT_RU_BATCH(BATCH_JOB_DEF_ID_); +alter table ACT_RU_BATCH + add constraint ACT_FK_BATCH_JOB_DEF + foreign key (BATCH_JOB_DEF_ID_) + references ACT_RU_JOBDEF (ID_); + +-- indexes for deadlock problems - https://app.camunda.com/jira/browse/CAM-2567 -- +create index ACT_IDX_INC_CAUSEINCID on ACT_RU_INCIDENT(CAUSE_INCIDENT_ID_); +create index ACT_IDX_INC_EXID on ACT_RU_INCIDENT(EXECUTION_ID_); +create index ACT_IDX_INC_PROCDEFID on ACT_RU_INCIDENT(PROC_DEF_ID_); +create index ACT_IDX_INC_PROCINSTID on ACT_RU_INCIDENT(PROC_INST_ID_); +create index ACT_IDX_INC_ROOTCAUSEINCID on ACT_RU_INCIDENT(ROOT_CAUSE_INCIDENT_ID_); +-- index for deadlock problem - https://app.camunda.com/jira/browse/CAM-4440 -- +create index ACT_IDX_AUTH_RESOURCE_ID on ACT_RU_AUTHORIZATION(RESOURCE_ID_); +-- index to prevent deadlock on fk constraint - https://app.camunda.com/jira/browse/CAM-5440 -- +create index ACT_IDX_EXT_TASK_EXEC on ACT_RU_EXT_TASK(EXECUTION_ID_); + +-- indexes to improve deployment +create index ACT_IDX_BYTEARRAY_NAME on ACT_GE_BYTEARRAY(NAME_); +create index ACT_IDX_DEPLOYMENT_NAME on ACT_RE_DEPLOYMENT(NAME_); +create index ACT_IDX_DEPLOYMENT_TENANT_ID on ACT_RE_DEPLOYMENT(TENANT_ID_); +create index ACT_IDX_JOBDEF_PROC_DEF_ID ON ACT_RU_JOBDEF(PROC_DEF_ID_); +create index ACT_IDX_JOB_HANDLER_TYPE ON ACT_RU_JOB(HANDLER_TYPE_); +create index ACT_IDX_EVENT_SUBSCR_EVT_NAME ON ACT_RU_EVENT_SUBSCR(EVENT_NAME_); +create index ACT_IDX_PROCDEF_DEPLOYMENT_ID ON ACT_RE_PROCDEF(DEPLOYMENT_ID_); +create index ACT_IDX_PROCDEF_TENANT_ID ON ACT_RE_PROCDEF(TENANT_ID_); +create index ACT_IDX_PROCDEF_VER_TAG ON ACT_RE_PROCDEF(VERSION_TAG_); +-- create case definition table -- +create table ACT_RE_CASE_DEF ( + ID_ varchar(64) not null, + REV_ integer, + CATEGORY_ varchar(255), + NAME_ varchar(255), + KEY_ varchar(255) not null, + VERSION_ integer not null, + DEPLOYMENT_ID_ varchar(64), + RESOURCE_NAME_ varchar(4000), + DGRM_RESOURCE_NAME_ varchar(4000), + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +-- create case execution table -- +create table ACT_RU_CASE_EXECUTION ( + ID_ varchar(64) NOT NULL, + REV_ integer, + CASE_INST_ID_ varchar(64), + SUPER_CASE_EXEC_ varchar(64), + SUPER_EXEC_ varchar(64), + BUSINESS_KEY_ varchar(255), + PARENT_ID_ varchar(64), + CASE_DEF_ID_ varchar(64), + ACT_ID_ varchar(255), + PREV_STATE_ integer, + CURRENT_STATE_ integer, + REQUIRED_ boolean, + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +-- create case sentry part table -- + +create table ACT_RU_CASE_SENTRY_PART ( + ID_ varchar(64) NOT NULL, + REV_ integer, + CASE_INST_ID_ varchar(64), + CASE_EXEC_ID_ varchar(64), + SENTRY_ID_ varchar(255), + TYPE_ varchar(255), + SOURCE_CASE_EXEC_ID_ varchar(64), + STANDARD_EVENT_ varchar(255), + SOURCE_ varchar(255), + SATISFIED_ boolean, + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +-- create index on business key -- +create index ACT_IDX_CASE_EXEC_BUSKEY on ACT_RU_CASE_EXECUTION(BUSINESS_KEY_); + +-- create foreign key constraints on ACT_RU_CASE_EXECUTION -- +alter table ACT_RU_CASE_EXECUTION + add constraint ACT_FK_CASE_EXE_CASE_INST + foreign key (CASE_INST_ID_) + references ACT_RU_CASE_EXECUTION(ID_) on delete cascade on update cascade; + +alter table ACT_RU_CASE_EXECUTION + add constraint ACT_FK_CASE_EXE_PARENT + foreign key (PARENT_ID_) + references ACT_RU_CASE_EXECUTION(ID_); + +alter table ACT_RU_CASE_EXECUTION + add constraint ACT_FK_CASE_EXE_CASE_DEF + foreign key (CASE_DEF_ID_) + references ACT_RE_CASE_DEF(ID_); + +-- create foreign key constraints on ACT_RU_VARIABLE -- +alter table ACT_RU_VARIABLE + add constraint ACT_FK_VAR_CASE_EXE + foreign key (CASE_EXECUTION_ID_) + references ACT_RU_CASE_EXECUTION(ID_); + +alter table ACT_RU_VARIABLE + add constraint ACT_FK_VAR_CASE_INST + foreign key (CASE_INST_ID_) + references ACT_RU_CASE_EXECUTION(ID_); + +-- create foreign key constraints on ACT_RU_TASK -- +alter table ACT_RU_TASK + add constraint ACT_FK_TASK_CASE_EXE + foreign key (CASE_EXECUTION_ID_) + references ACT_RU_CASE_EXECUTION(ID_); + +alter table ACT_RU_TASK + add constraint ACT_FK_TASK_CASE_DEF + foreign key (CASE_DEF_ID_) + references ACT_RE_CASE_DEF(ID_); + +-- create foreign key constraints on ACT_RU_CASE_SENTRY_PART -- +alter table ACT_RU_CASE_SENTRY_PART + add constraint ACT_FK_CASE_SENTRY_CASE_INST + foreign key (CASE_INST_ID_) + references ACT_RU_CASE_EXECUTION(ID_); + +alter table ACT_RU_CASE_SENTRY_PART + add constraint ACT_FK_CASE_SENTRY_CASE_EXEC + foreign key (CASE_EXEC_ID_) + references ACT_RU_CASE_EXECUTION(ID_); + +create index ACT_IDX_CASE_DEF_TENANT_ID on ACT_RE_CASE_DEF(TENANT_ID_); +create index ACT_IDX_CASE_EXEC_TENANT_ID on ACT_RU_CASE_EXECUTION(TENANT_ID_); +-- create decision definition table -- +create table ACT_RE_DECISION_DEF ( + ID_ varchar(64) not null, + REV_ integer, + CATEGORY_ varchar(255), + NAME_ varchar(255), + KEY_ varchar(255) not null, + VERSION_ integer not null, + DEPLOYMENT_ID_ varchar(64), + RESOURCE_NAME_ varchar(4000), + DGRM_RESOURCE_NAME_ varchar(4000), + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create index ACT_IDX_DEC_DEF_TENANT_ID on ACT_RE_DECISION_DEF(TENANT_ID_); + +create table ACT_HI_PROCINST ( + ID_ varchar(64) not null, + PROC_INST_ID_ varchar(64) not null, + BUSINESS_KEY_ varchar(255), + PROC_DEF_KEY_ varchar(255), + PROC_DEF_ID_ varchar(64) not null, + START_TIME_ datetime(3) not null, + END_TIME_ datetime(3), + DURATION_ bigint, + START_USER_ID_ varchar(255), + START_ACT_ID_ varchar(255), + END_ACT_ID_ varchar(255), + SUPER_PROCESS_INSTANCE_ID_ varchar(64), + SUPER_CASE_INSTANCE_ID_ varchar(64), + CASE_INST_ID_ varchar(64), + DELETE_REASON_ varchar(4000), + TENANT_ID_ varchar(64), + primary key (ID_), + unique (PROC_INST_ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_HI_ACTINST ( + ID_ varchar(64) not null, + PARENT_ACT_INST_ID_ varchar(64), + PROC_DEF_KEY_ varchar(255), + PROC_DEF_ID_ varchar(64) not null, + PROC_INST_ID_ varchar(64) not null, + EXECUTION_ID_ varchar(64) not null, + ACT_ID_ varchar(255) not null, + TASK_ID_ varchar(64), + CALL_PROC_INST_ID_ varchar(64), + CALL_CASE_INST_ID_ varchar(64), + ACT_NAME_ varchar(255), + ACT_TYPE_ varchar(255) not null, + ASSIGNEE_ varchar(64), + START_TIME_ datetime(3) not null, + END_TIME_ datetime(3), + DURATION_ bigint, + ACT_INST_STATE_ integer, + SEQUENCE_COUNTER_ bigint, + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_HI_TASKINST ( + ID_ varchar(64) not null, + TASK_DEF_KEY_ varchar(255), + PROC_DEF_KEY_ varchar(255), + PROC_DEF_ID_ varchar(64), + PROC_INST_ID_ varchar(64), + EXECUTION_ID_ varchar(64), + CASE_DEF_KEY_ varchar(255), + CASE_DEF_ID_ varchar(64), + CASE_INST_ID_ varchar(64), + CASE_EXECUTION_ID_ varchar(64), + ACT_INST_ID_ varchar(64), + NAME_ varchar(255), + PARENT_TASK_ID_ varchar(64), + DESCRIPTION_ varchar(4000), + OWNER_ varchar(255), + ASSIGNEE_ varchar(255), + START_TIME_ datetime(3) not null, + END_TIME_ datetime(3), + DURATION_ bigint, + DELETE_REASON_ varchar(4000), + PRIORITY_ integer, + DUE_DATE_ datetime(3), + FOLLOW_UP_DATE_ datetime(3), + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_HI_VARINST ( + ID_ varchar(64) not null, + PROC_DEF_KEY_ varchar(255), + PROC_DEF_ID_ varchar(64), + PROC_INST_ID_ varchar(64), + EXECUTION_ID_ varchar(64), + ACT_INST_ID_ varchar(64), + CASE_DEF_KEY_ varchar(255), + CASE_DEF_ID_ varchar(64), + CASE_INST_ID_ varchar(64), + CASE_EXECUTION_ID_ varchar(64), + TASK_ID_ varchar(64), + NAME_ varchar(255) not null, + VAR_TYPE_ varchar(100), + REV_ integer, + BYTEARRAY_ID_ varchar(64), + DOUBLE_ double, + LONG_ bigint, + TEXT_ LONGBLOB NULL, + TEXT2_ LONGBLOB NULL, + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_HI_DETAIL ( + ID_ varchar(64) not null, + TYPE_ varchar(255) not null, + PROC_DEF_KEY_ varchar(255), + PROC_DEF_ID_ varchar(64), + PROC_INST_ID_ varchar(64), + EXECUTION_ID_ varchar(64), + CASE_DEF_KEY_ varchar(255), + CASE_DEF_ID_ varchar(64), + CASE_INST_ID_ varchar(64), + CASE_EXECUTION_ID_ varchar(64), + TASK_ID_ varchar(64), + ACT_INST_ID_ varchar(64), + VAR_INST_ID_ varchar(64), + NAME_ varchar(255) not null, + VAR_TYPE_ varchar(255), + REV_ integer, + TIME_ datetime(3) not null, + BYTEARRAY_ID_ varchar(64), + DOUBLE_ double, + LONG_ bigint, + TEXT_ LONGBLOB NULL, + TEXT2_ LONGBLOB NULL, + SEQUENCE_COUNTER_ bigint, + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_HI_IDENTITYLINK ( + ID_ varchar(64) not null, + TIMESTAMP_ timestamp(3) not null, + TYPE_ varchar(255), + USER_ID_ varchar(255), + GROUP_ID_ varchar(255), + TASK_ID_ varchar(64), + PROC_DEF_ID_ varchar(64), + OPERATION_TYPE_ varchar(64), + ASSIGNER_ID_ varchar(64), + PROC_DEF_KEY_ varchar(255), + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_HI_COMMENT ( + ID_ varchar(64) not null, + TYPE_ varchar(255), + TIME_ datetime(3) not null, + USER_ID_ varchar(255), + TASK_ID_ varchar(64), + PROC_INST_ID_ varchar(64), + ACTION_ varchar(255), + MESSAGE_ varchar(4000), + FULL_MSG_ LONGBLOB, + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_HI_ATTACHMENT ( + ID_ varchar(64) not null, + REV_ integer, + USER_ID_ varchar(255), + NAME_ varchar(255), + DESCRIPTION_ varchar(4000), + TYPE_ varchar(255), + TASK_ID_ varchar(64), + PROC_INST_ID_ varchar(64), + URL_ varchar(4000), + CONTENT_ID_ varchar(64), + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_HI_OP_LOG ( + ID_ varchar(64) not null, + DEPLOYMENT_ID_ varchar(64), + PROC_DEF_ID_ varchar(64), + PROC_DEF_KEY_ varchar(255), + PROC_INST_ID_ varchar(64), + EXECUTION_ID_ varchar(64), + CASE_DEF_ID_ varchar(64), + CASE_INST_ID_ varchar(64), + CASE_EXECUTION_ID_ varchar(64), + TASK_ID_ varchar(64), + JOB_ID_ varchar(64), + JOB_DEF_ID_ varchar(64), + BATCH_ID_ varchar(64), + USER_ID_ varchar(255), + TIMESTAMP_ timestamp(3) not null, + OPERATION_TYPE_ varchar(64), + OPERATION_ID_ varchar(64), + ENTITY_TYPE_ varchar(30), + PROPERTY_ varchar(64), + ORG_VALUE_ varchar(4000), + NEW_VALUE_ varchar(4000), + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_HI_INCIDENT ( + ID_ varchar(64) not null, + PROC_DEF_KEY_ varchar(255), + PROC_DEF_ID_ varchar(64), + PROC_INST_ID_ varchar(64), + EXECUTION_ID_ varchar(64), + CREATE_TIME_ timestamp(3) not null, + END_TIME_ timestamp(3) null, + INCIDENT_MSG_ varchar(4000), + INCIDENT_TYPE_ varchar(255) not null, + ACTIVITY_ID_ varchar(255), + CAUSE_INCIDENT_ID_ varchar(64), + ROOT_CAUSE_INCIDENT_ID_ varchar(64), + CONFIGURATION_ varchar(255), + INCIDENT_STATE_ integer, + TENANT_ID_ varchar(64), + JOB_DEF_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_HI_JOB_LOG ( + ID_ varchar(64) not null, + TIMESTAMP_ timestamp(3) not null, + JOB_ID_ varchar(64) not null, + JOB_DUEDATE_ timestamp(3) NULL, + JOB_RETRIES_ integer, + JOB_PRIORITY_ bigint NOT NULL DEFAULT 0, + JOB_EXCEPTION_MSG_ varchar(4000), + JOB_EXCEPTION_STACK_ID_ varchar(64), + JOB_STATE_ integer, + JOB_DEF_ID_ varchar(64), + JOB_DEF_TYPE_ varchar(255), + JOB_DEF_CONFIGURATION_ varchar(255), + ACT_ID_ varchar(255), + EXECUTION_ID_ varchar(64), + PROCESS_INSTANCE_ID_ varchar(64), + PROCESS_DEF_ID_ varchar(64), + PROCESS_DEF_KEY_ varchar(255), + DEPLOYMENT_ID_ varchar(64), + SEQUENCE_COUNTER_ bigint, + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_HI_BATCH ( + ID_ varchar(64) not null, + TYPE_ varchar(255), + TOTAL_JOBS_ integer, + JOBS_PER_SEED_ integer, + INVOCATIONS_PER_JOB_ integer, + SEED_JOB_DEF_ID_ varchar(64), + MONITOR_JOB_DEF_ID_ varchar(64), + BATCH_JOB_DEF_ID_ varchar(64), + TENANT_ID_ varchar(64), + START_TIME_ datetime(3) not null, + END_TIME_ datetime(3), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create index ACT_IDX_HI_PRO_INST_END on ACT_HI_PROCINST(END_TIME_); +create index ACT_IDX_HI_PRO_I_BUSKEY on ACT_HI_PROCINST(BUSINESS_KEY_); +create index ACT_IDX_HI_PRO_INST_TENANT_ID on ACT_HI_PROCINST(TENANT_ID_); + +create index ACT_IDX_HI_ACT_INST_START on ACT_HI_ACTINST(START_TIME_); +create index ACT_IDX_HI_ACT_INST_END on ACT_HI_ACTINST(END_TIME_); +create index ACT_IDX_HI_ACT_INST_PROCINST on ACT_HI_ACTINST(PROC_INST_ID_, ACT_ID_); +create index ACT_IDX_HI_ACT_INST_COMP on ACT_HI_ACTINST(EXECUTION_ID_, ACT_ID_, END_TIME_, ID_); +create index ACT_IDX_HI_ACT_INST_STATS on ACT_HI_ACTINST(PROC_DEF_ID_, ACT_ID_, END_TIME_, ACT_INST_STATE_); +create index ACT_IDX_HI_ACT_INST_TENANT_ID on ACT_HI_ACTINST(TENANT_ID_); + +create index ACT_IDX_HI_TASK_INST_TENANT_ID on ACT_HI_TASKINST(TENANT_ID_); + +create index ACT_IDX_HI_DETAIL_PROC_INST on ACT_HI_DETAIL(PROC_INST_ID_); +create index ACT_IDX_HI_DETAIL_ACT_INST on ACT_HI_DETAIL(ACT_INST_ID_); +create index ACT_IDX_HI_DETAIL_CASE_INST on ACT_HI_DETAIL(CASE_INST_ID_); +create index ACT_IDX_HI_DETAIL_CASE_EXEC on ACT_HI_DETAIL(CASE_EXECUTION_ID_); +create index ACT_IDX_HI_DETAIL_TIME on ACT_HI_DETAIL(TIME_); +create index ACT_IDX_HI_DETAIL_NAME on ACT_HI_DETAIL(NAME_); +create index ACT_IDX_HI_DETAIL_TASK_ID on ACT_HI_DETAIL(TASK_ID_); +create index ACT_IDX_HI_DETAIL_TENANT_ID on ACT_HI_DETAIL(TENANT_ID_); +create index ACT_IDX_HI_IDENT_LNK_USER on ACT_HI_IDENTITYLINK(USER_ID_); +create index ACT_IDX_HI_IDENT_LNK_GROUP on ACT_HI_IDENTITYLINK(GROUP_ID_); +create index ACT_IDX_HI_IDENT_LNK_TENANT_ID on ACT_HI_IDENTITYLINK(TENANT_ID_); +create index ACT_IDX_HI_PROCVAR_PROC_INST on ACT_HI_VARINST(PROC_INST_ID_); +create index ACT_IDX_HI_PROCVAR_NAME_TYPE on ACT_HI_VARINST(NAME_, VAR_TYPE_); +create index ACT_IDX_HI_CASEVAR_CASE_INST on ACT_HI_VARINST(CASE_INST_ID_); +create index ACT_IDX_HI_VAR_INST_TENANT_ID on ACT_HI_VARINST(TENANT_ID_); + +create index ACT_IDX_HI_INCIDENT_TENANT_ID on ACT_HI_INCIDENT(TENANT_ID_); + +create index ACT_IDX_HI_JOB_LOG_PROCINST on ACT_HI_JOB_LOG(PROCESS_INSTANCE_ID_); +create index ACT_IDX_HI_JOB_LOG_PROCDEF on ACT_HI_JOB_LOG(PROCESS_DEF_ID_); +create index ACT_IDX_HI_JOB_LOG_TENANT_ID on ACT_HI_JOB_LOG(TENANT_ID_); +create index ACT_IDX_HI_JOB_LOG_JOB_DEF_ID on ACT_HI_JOB_LOG(JOB_DEF_ID_); + +create index ACT_IDX_HI_OP_LOG_PROCINST on ACT_HI_OP_LOG(PROC_INST_ID_); +create index ACT_IDX_HI_OP_LOG_PROCDEF on ACT_HI_OP_LOG(PROC_DEF_ID_); +create table ACT_HI_CASEINST ( + ID_ varchar(64) not null, + CASE_INST_ID_ varchar(64) not null, + BUSINESS_KEY_ varchar(255), + CASE_DEF_ID_ varchar(64) not null, + CREATE_TIME_ datetime(3) not null, + CLOSE_TIME_ datetime(3), + DURATION_ bigint, + STATE_ integer, + CREATE_USER_ID_ varchar(255), + SUPER_CASE_INSTANCE_ID_ varchar(64), + SUPER_PROCESS_INSTANCE_ID_ varchar(64), + TENANT_ID_ varchar(64), + primary key (ID_), + unique (CASE_INST_ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_HI_CASEACTINST ( + ID_ varchar(64) not null, + PARENT_ACT_INST_ID_ varchar(64), + CASE_DEF_ID_ varchar(64) not null, + CASE_INST_ID_ varchar(64) not null, + CASE_ACT_ID_ varchar(255) not null, + TASK_ID_ varchar(64), + CALL_PROC_INST_ID_ varchar(64), + CALL_CASE_INST_ID_ varchar(64), + CASE_ACT_NAME_ varchar(255), + CASE_ACT_TYPE_ varchar(255), + CREATE_TIME_ datetime(3) not null, + END_TIME_ datetime(3), + DURATION_ bigint, + STATE_ integer, + REQUIRED_ boolean, + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create index ACT_IDX_HI_CAS_I_CLOSE on ACT_HI_CASEINST(CLOSE_TIME_); +create index ACT_IDX_HI_CAS_I_BUSKEY on ACT_HI_CASEINST(BUSINESS_KEY_); +create index ACT_IDX_HI_CAS_I_TENANT_ID on ACT_HI_CASEINST(TENANT_ID_); +create index ACT_IDX_HI_CAS_A_I_CREATE on ACT_HI_CASEACTINST(CREATE_TIME_); +create index ACT_IDX_HI_CAS_A_I_END on ACT_HI_CASEACTINST(END_TIME_); +create index ACT_IDX_HI_CAS_A_I_COMP on ACT_HI_CASEACTINST(CASE_ACT_ID_, END_TIME_, ID_); +create index ACT_IDX_HI_CAS_A_I_CASEINST on ACT_HI_CASEACTINST(CASE_INST_ID_, CASE_ACT_ID_); +create index ACT_IDX_HI_CAS_A_I_TENANT_ID on ACT_HI_CASEACTINST(TENANT_ID_); +-- create history decision instance table -- +create table ACT_HI_DECINST ( + ID_ varchar(64) NOT NULL, + DEC_DEF_ID_ varchar(64) NOT NULL, + DEC_DEF_KEY_ varchar(255) NOT NULL, + DEC_DEF_NAME_ varchar(255), + PROC_DEF_KEY_ varchar(255), + PROC_DEF_ID_ varchar(64), + PROC_INST_ID_ varchar(64), + CASE_DEF_KEY_ varchar(255), + CASE_DEF_ID_ varchar(64), + CASE_INST_ID_ varchar(64), + ACT_INST_ID_ varchar(64), + ACT_ID_ varchar(255), + EVAL_TIME_ datetime(3) not null, + COLLECT_VALUE_ double, + USER_ID_ varchar(255), + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +-- create history decision input table -- +create table ACT_HI_DEC_IN ( + ID_ varchar(64) NOT NULL, + DEC_INST_ID_ varchar(64) NOT NULL, + CLAUSE_ID_ varchar(64) NOT NULL, + CLAUSE_NAME_ varchar(255), + VAR_TYPE_ varchar(100), + BYTEARRAY_ID_ varchar(64), + DOUBLE_ double, + LONG_ bigint, + TEXT_ LONGBLOB NULL, + TEXT2_ LONGBLOB NULL, + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +-- create history decision output table -- +create table ACT_HI_DEC_OUT ( + ID_ varchar(64) NOT NULL, + DEC_INST_ID_ varchar(64) NOT NULL, + CLAUSE_ID_ varchar(64) NOT NULL, + CLAUSE_NAME_ varchar(255), + RULE_ID_ varchar(64) NOT NULL, + RULE_ORDER_ integer, + VAR_NAME_ varchar(255), + VAR_TYPE_ varchar(100), + BYTEARRAY_ID_ varchar(64), + DOUBLE_ double, + LONG_ bigint, + TEXT_ LONGBLOB NULL, + TEXT2_ LONGBLOB NULL, + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + + +create index ACT_IDX_HI_DEC_INST_ID on ACT_HI_DECINST(DEC_DEF_ID_); +create index ACT_IDX_HI_DEC_INST_KEY on ACT_HI_DECINST(DEC_DEF_KEY_); +create index ACT_IDX_HI_DEC_INST_PI on ACT_HI_DECINST(PROC_INST_ID_); +create index ACT_IDX_HI_DEC_INST_CI on ACT_HI_DECINST(CASE_INST_ID_); +create index ACT_IDX_HI_DEC_INST_ACT on ACT_HI_DECINST(ACT_ID_); +create index ACT_IDX_HI_DEC_INST_ACT_INST on ACT_HI_DECINST(ACT_INST_ID_); +create index ACT_IDX_HI_DEC_INST_TIME on ACT_HI_DECINST(EVAL_TIME_); +create index ACT_IDX_HI_DEC_INST_TENANT_ID on ACT_HI_DECINST(TENANT_ID_); + +create index ACT_IDX_HI_DEC_IN_INST on ACT_HI_DEC_IN(DEC_INST_ID_); +create index ACT_IDX_HI_DEC_IN_CLAUSE on ACT_HI_DEC_IN(DEC_INST_ID_, CLAUSE_ID_); + +create index ACT_IDX_HI_DEC_OUT_INST on ACT_HI_DEC_OUT(DEC_INST_ID_); +create index ACT_IDX_HI_DEC_OUT_RULE on ACT_HI_DEC_OUT(RULE_ORDER_, CLAUSE_ID_); + +-- identity file entries + +create table ACT_ID_GROUP ( + ID_ varchar(64), + REV_ integer, + NAME_ varchar(255), + TYPE_ varchar(255), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_ID_MEMBERSHIP ( + USER_ID_ varchar(64), + GROUP_ID_ varchar(64), + primary key (USER_ID_, GROUP_ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_ID_USER ( + ID_ varchar(64), + REV_ integer, + FIRST_ varchar(255), + LAST_ varchar(255), + EMAIL_ varchar(255), + PWD_ varchar(255), + PICTURE_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_ID_INFO ( + ID_ varchar(64), + REV_ integer, + USER_ID_ varchar(64), + TYPE_ varchar(64), + KEY_ varchar(255), + VALUE_ varchar(255), + PASSWORD_ LONGBLOB, + PARENT_ID_ varchar(255), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_ID_TENANT ( + ID_ varchar(64), + REV_ integer, + NAME_ varchar(255), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_ID_TENANT_MEMBER ( + ID_ varchar(64) not null, + TENANT_ID_ varchar(64) not null, + USER_ID_ varchar(64), + GROUP_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +alter table ACT_ID_MEMBERSHIP + add constraint ACT_FK_MEMB_GROUP + foreign key (GROUP_ID_) + references ACT_ID_GROUP (ID_); + +alter table ACT_ID_MEMBERSHIP + add constraint ACT_FK_MEMB_USER + foreign key (USER_ID_) + references ACT_ID_USER (ID_); + +alter table ACT_ID_TENANT_MEMBER + add constraint ACT_UNIQ_TENANT_MEMB_USER + unique (TENANT_ID_, USER_ID_); + +alter table ACT_ID_TENANT_MEMBER + add constraint ACT_UNIQ_TENANT_MEMB_GROUP + unique (TENANT_ID_, GROUP_ID_); + +alter table ACT_ID_TENANT_MEMBER + add constraint ACT_FK_TENANT_MEMB + foreign key (TENANT_ID_) + references ACT_ID_TENANT (ID_); + +alter table ACT_ID_TENANT_MEMBER + add constraint ACT_FK_TENANT_MEMB_USER + foreign key (USER_ID_) + references ACT_ID_USER (ID_); + +alter table ACT_ID_TENANT_MEMBER + add constraint ACT_FK_TENANT_MEMB_GROUP + foreign key (GROUP_ID_) + references ACT_ID_GROUP (ID_); + +CREATE TABLE `mso_urn_mapping` ( +`NAME_` VARCHAR(64) NOT NULL COLLATE 'utf8_bin', +`VALUE_` VARCHAR(300) NULL DEFAULT NULL COLLATE 'utf8_bin', +`REV_` INT(11) NULL DEFAULT NULL +) +COLLATE='latin1_swedish_ci' +ENGINE=InnoDB +; + +INSERT INTO `mso_urn_mapping` (`NAME_`, `VALUE_`, `REV_`) VALUES ('mso:rollback', 'true', 1); +INSERT INTO `mso_urn_mapping` (`NAME_`, `VALUE_`, `REV_`) VALUES ('aai:endpoint', 'http://localhost:28090', 1); +INSERT INTO `mso_urn_mapping` (`NAME_`, `VALUE_`, `REV_`) VALUES ('mso:adapters:tenant:endpoint', 'http://localhost:28090/tenantAdapterMock', 1); +INSERT INTO `mso_urn_mapping` (`NAME_`, `VALUE_`, `REV_`) VALUES ('mso:adapters:sdnc:endpoint', 'http://localhost:28090/sdncAdapterMock', 1); +INSERT INTO `mso_urn_mapping` (`NAME_`, `VALUE_`, `REV_`) VALUES ('mso:workflow:sdncadapter:callback', 'http://localhost:28080/mso/SDNCAdapterCallbackService', 1); +INSERT INTO `mso_urn_mapping` (`NAME_`, `VALUE_`, `REV_`) VALUES ('mso:sdnc:timeout', 'PT5M', 1); +INSERT INTO `mso_urn_mapping` (`NAME_`, `VALUE_`, `REV_`) VALUES ('mso:sdnc:firewall:yang:model', 'http://com/att/svc/mis/firewall-lite-gui', 1); +INSERT INTO `mso_urn_mapping` (`NAME_`, `VALUE_`, `REV_`) VALUES ('mso:sdnc:firewall:yang:model:version', '2015-05-15', 1); +INSERT INTO `mso_urn_mapping` (`NAME_`, `VALUE_`, `REV_`) VALUES ('mso:sdnc:timeout:firewall:minutes', '20', 1); + + +-- add indexes on PROC_DEF_KEY_ columns in history tables CAM-6679 +create index ACT_IDX_HI_ACT_INST_PROC_DEF_KEY on ACT_HI_ACTINST(PROC_DEF_KEY_); +create index ACT_IDX_HI_DETAIL_PROC_DEF_KEY on ACT_HI_DETAIL(PROC_DEF_KEY_); +create index ACT_IDX_HI_IDENT_LNK_PROC_DEF_KEY on ACT_HI_IDENTITYLINK(PROC_DEF_KEY_); +create index ACT_IDX_HI_INCIDENT_PROC_DEF_KEY on ACT_HI_INCIDENT(PROC_DEF_KEY_); +create index ACT_IDX_HI_JOB_LOG_PROC_DEF_KEY on ACT_HI_JOB_LOG(PROCESS_DEF_KEY_); +create index ACT_IDX_HI_PRO_INST_PROC_DEF_KEY on ACT_HI_PROCINST(PROC_DEF_KEY_); +create index ACT_IDX_HI_TASK_INST_PROC_DEF_KEY on ACT_HI_TASKINST(PROC_DEF_KEY_); +create index ACT_IDX_HI_VAR_INST_PROC_DEF_KEY on ACT_HI_VARINST(PROC_DEF_KEY_);
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/CamundaDBScripts/Upgrade/upgrade_mariadb_camunda7.3.7_to_7.5.6_ee.sql b/bpmn/MSOCommonBPMN/src/test/resources/__files/CamundaDBScripts/Upgrade/upgrade_mariadb_camunda7.3.7_to_7.5.6_ee.sql new file mode 100644 index 0000000000..8e118eb638 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/CamundaDBScripts/Upgrade/upgrade_mariadb_camunda7.3.7_to_7.5.6_ee.sql @@ -0,0 +1,602 @@ +-- mariadb_engine_7.3.7_to_7.5.5 upgrade -- + +-- mysql_engine_7.3_to_7.4 +-- metrics -- +USE `camundabpmn`; + +ALTER TABLE ACT_RU_METER_LOG + ADD REPORTER_ varchar(255); + +-- job prioritization -- + +ALTER TABLE ACT_RU_JOB + ADD PRIORITY_ bigint NOT NULL + DEFAULT 0; + +ALTER TABLE ACT_RU_JOBDEF + ADD JOB_PRIORITY_ bigint; + +ALTER TABLE ACT_HI_JOB_LOG + ADD JOB_PRIORITY_ bigint NOT NULL + DEFAULT 0; + +-- create decision definition table -- +create table ACT_RE_DECISION_DEF ( + ID_ varchar(64) not null, + REV_ integer, + CATEGORY_ varchar(255), + NAME_ varchar(255), + KEY_ varchar(255) not null, + VERSION_ integer not null, + DEPLOYMENT_ID_ varchar(64), + RESOURCE_NAME_ varchar(4000), + DGRM_RESOURCE_NAME_ varchar(4000), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +-- create unique constraint on ACT_RE_DECISION_DEF -- +alter table ACT_RE_DECISION_DEF + add constraint ACT_UNIQ_DECISION_DEF + unique (KEY_,VERSION_); + +-- case sentry part source -- + +ALTER TABLE ACT_RU_CASE_SENTRY_PART + ADD SOURCE_ varchar(255); + +-- create history decision instance table -- +create table ACT_HI_DECINST ( + ID_ varchar(64) NOT NULL, + DEC_DEF_ID_ varchar(64) NOT NULL, + DEC_DEF_KEY_ varchar(255) NOT NULL, + DEC_DEF_NAME_ varchar(255), + PROC_DEF_KEY_ varchar(255), + PROC_DEF_ID_ varchar(64), + PROC_INST_ID_ varchar(64), + CASE_DEF_KEY_ varchar(255), + CASE_DEF_ID_ varchar(64), + CASE_INST_ID_ varchar(64), + ACT_INST_ID_ varchar(64), + ACT_ID_ varchar(255), + EVAL_TIME_ datetime not null, + COLLECT_VALUE_ double, + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +-- create history decision input table -- +create table ACT_HI_DEC_IN ( + ID_ varchar(64) NOT NULL, + DEC_INST_ID_ varchar(64) NOT NULL, + CLAUSE_ID_ varchar(64) NOT NULL, + CLAUSE_NAME_ varchar(255), + VAR_TYPE_ varchar(100), + BYTEARRAY_ID_ varchar(64), + DOUBLE_ double, + LONG_ bigint, + TEXT_ LONGBLOB NULL, + TEXT2_ LONGBLOB NULL, + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +-- create history decision output table -- +create table ACT_HI_DEC_OUT ( + ID_ varchar(64) NOT NULL, + DEC_INST_ID_ varchar(64) NOT NULL, + CLAUSE_ID_ varchar(64) NOT NULL, + CLAUSE_NAME_ varchar(255), + RULE_ID_ varchar(64) NOT NULL, + RULE_ORDER_ integer, + VAR_NAME_ varchar(255), + VAR_TYPE_ varchar(100), + BYTEARRAY_ID_ varchar(64), + DOUBLE_ double, + LONG_ bigint, + TEXT_ LONGBLOB NULL, + TEXT2_ LONGBLOB NULL, + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +-- create indexes for historic decision tables +create index ACT_IDX_HI_DEC_INST_ID on ACT_HI_DECINST(DEC_DEF_ID_); +create index ACT_IDX_HI_DEC_INST_KEY on ACT_HI_DECINST(DEC_DEF_KEY_); +create index ACT_IDX_HI_DEC_INST_PI on ACT_HI_DECINST(PROC_INST_ID_); +create index ACT_IDX_HI_DEC_INST_CI on ACT_HI_DECINST(CASE_INST_ID_); +create index ACT_IDX_HI_DEC_INST_ACT on ACT_HI_DECINST(ACT_ID_); +create index ACT_IDX_HI_DEC_INST_ACT_INST on ACT_HI_DECINST(ACT_INST_ID_); +create index ACT_IDX_HI_DEC_INST_TIME on ACT_HI_DECINST(EVAL_TIME_); + +create index ACT_IDX_HI_DEC_IN_INST on ACT_HI_DEC_IN(DEC_INST_ID_); +create index ACT_IDX_HI_DEC_IN_CLAUSE on ACT_HI_DEC_IN(DEC_INST_ID_, CLAUSE_ID_); + +create index ACT_IDX_HI_DEC_OUT_INST on ACT_HI_DEC_OUT(DEC_INST_ID_); +create index ACT_IDX_HI_DEC_OUT_RULE on ACT_HI_DEC_OUT(RULE_ORDER_, CLAUSE_ID_); + +-- add grant authorization for group camunda-admin: +INSERT INTO + ACT_RU_AUTHORIZATION (ID_, TYPE_, GROUP_ID_, RESOURCE_TYPE_, RESOURCE_ID_, PERMS_, REV_) +VALUES + ('camunda-admin-grant-decision-definition', 1, 'camunda-admin', 10, '*', 2147483647, 1); + +-- external tasks -- + +create table ACT_RU_EXT_TASK ( + ID_ varchar(64) not null, + REV_ integer not null, + WORKER_ID_ varchar(255), + TOPIC_NAME_ varchar(255), + RETRIES_ integer, + ERROR_MSG_ varchar(4000), + LOCK_EXP_TIME_ timestamp NULL, + SUSPENSION_STATE_ integer, + EXECUTION_ID_ varchar(64), + PROC_INST_ID_ varchar(64), + PROC_DEF_ID_ varchar(64), + PROC_DEF_KEY_ varchar(255), + ACT_ID_ varchar(255), + ACT_INST_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +alter table ACT_RU_EXT_TASK + add constraint ACT_FK_EXT_TASK_EXE + foreign key (EXECUTION_ID_) + references ACT_RU_EXECUTION (ID_); + +create index ACT_IDX_EXT_TASK_TOPIC on ACT_RU_EXT_TASK(TOPIC_NAME_); + +-- deployment -- + +ALTER TABLE ACT_RE_DEPLOYMENT + ADD SOURCE_ varchar(255); + +ALTER TABLE ACT_HI_OP_LOG + ADD DEPLOYMENT_ID_ varchar(64); + +-- job suspension state + +ALTER TABLE ACT_RU_JOB + MODIFY COLUMN SUSPENSION_STATE_ integer + DEFAULT 1; + + -- relevant for jobs created in Camunda 7.0 +UPDATE ACT_RU_JOB + SET SUSPENSION_STATE_ = 1 + WHERE SUSPENSION_STATE_ IS NULL; + +ALTER TABLE ACT_RU_JOB + MODIFY COLUMN SUSPENSION_STATE_ integer + NOT NULL DEFAULT 1; + + +-- mariadb_engine_7.4_patch_7.4.5_to_7.4.6 +-- INCREASE process def key column size https://app.camunda.com/jira/browse/CAM-4328 -- +alter table ACT_RU_JOB + MODIFY COLUMN PROCESS_DEF_KEY_ varchar(255); + +-- mariadb_engine_7.4_to_7.5 +-- set datetime precision -- + +ALTER TABLE ACT_HI_CASEINST + MODIFY COLUMN CREATE_TIME_ datetime(3) not null; + +ALTER TABLE ACT_HI_CASEINST + MODIFY COLUMN CLOSE_TIME_ datetime(3); + +ALTER TABLE ACT_HI_CASEACTINST + MODIFY COLUMN CREATE_TIME_ datetime(3) not null; + +ALTER TABLE ACT_HI_CASEACTINST + MODIFY COLUMN END_TIME_ datetime(3); + +ALTER TABLE ACT_HI_DECINST + MODIFY COLUMN EVAL_TIME_ datetime(3) not null; + +ALTER TABLE ACT_RU_TASK + MODIFY COLUMN DUE_DATE_ datetime(3); + +ALTER TABLE ACT_RU_TASK + MODIFY COLUMN FOLLOW_UP_DATE_ datetime(3); + +ALTER TABLE ACT_HI_PROCINST + MODIFY COLUMN START_TIME_ datetime(3) not null; + +ALTER TABLE ACT_HI_PROCINST + MODIFY COLUMN END_TIME_ datetime(3); + +ALTER TABLE ACT_HI_ACTINST + MODIFY COLUMN START_TIME_ datetime(3) not null; + +ALTER TABLE ACT_HI_ACTINST + MODIFY COLUMN END_TIME_ datetime(3); + +ALTER TABLE ACT_HI_TASKINST + MODIFY COLUMN START_TIME_ datetime(3) not null; + +ALTER TABLE ACT_HI_TASKINST + MODIFY COLUMN END_TIME_ datetime(3); + +ALTER TABLE ACT_HI_TASKINST + MODIFY COLUMN DUE_DATE_ datetime(3); + +ALTER TABLE ACT_HI_TASKINST + MODIFY COLUMN FOLLOW_UP_DATE_ datetime(3); + +ALTER TABLE ACT_HI_DETAIL + MODIFY COLUMN TIME_ datetime(3) not null; + +ALTER TABLE ACT_HI_COMMENT + MODIFY COLUMN TIME_ datetime(3) not null; + +-- set timestamp precision -- + +ALTER TABLE ACT_RE_DEPLOYMENT + MODIFY COLUMN DEPLOY_TIME_ timestamp(3); + +ALTER TABLE ACT_RU_JOB + MODIFY COLUMN LOCK_EXP_TIME_ timestamp(3) NULL; + +ALTER TABLE ACT_RU_JOB + MODIFY COLUMN DUEDATE_ timestamp(3) NULL; + +ALTER TABLE ACT_RU_TASK + MODIFY COLUMN CREATE_TIME_ timestamp(3); + +ALTER TABLE ACT_RU_EVENT_SUBSCR + MODIFY COLUMN CREATED_ timestamp(3) NOT NULL; + +ALTER TABLE ACT_RU_INCIDENT + MODIFY COLUMN INCIDENT_TIMESTAMP_ timestamp(3) NOT NULL; + +ALTER TABLE ACT_RU_METER_LOG + MODIFY COLUMN TIMESTAMP_ timestamp(3) NOT NULL; + +ALTER TABLE ACT_RU_EXT_TASK + MODIFY COLUMN LOCK_EXP_TIME_ timestamp(3) NULL; + +ALTER TABLE ACT_HI_OP_LOG + MODIFY COLUMN TIMESTAMP_ timestamp(3) NOT NULL; + +ALTER TABLE ACT_HI_INCIDENT + MODIFY COLUMN CREATE_TIME_ timestamp(3) NOT NULL; + +ALTER TABLE ACT_HI_INCIDENT + MODIFY COLUMN END_TIME_ timestamp(3) NULL; + +ALTER TABLE ACT_HI_JOB_LOG + MODIFY COLUMN TIMESTAMP_ timestamp(3) NOT NULL; + +ALTER TABLE ACT_HI_JOB_LOG + MODIFY COLUMN JOB_DUEDATE_ timestamp(3) NULL; + +-- semantic version -- + +ALTER TABLE ACT_RE_PROCDEF + ADD VERSION_TAG_ varchar(64); + +create index ACT_IDX_PROCDEF_VER_TAG on ACT_RE_PROCDEF(VERSION_TAG_); + +-- tenant id -- + +ALTER TABLE ACT_RE_DEPLOYMENT + ADD TENANT_ID_ varchar(64); + +create index ACT_IDX_DEPLOYMENT_TENANT_ID on ACT_RE_DEPLOYMENT(TENANT_ID_); + +ALTER TABLE ACT_RE_PROCDEF + ADD TENANT_ID_ varchar(64); + +ALTER TABLE ACT_RE_PROCDEF + DROP INDEX ACT_UNIQ_PROCDEF; + +create index ACT_IDX_PROCDEF_TENANT_ID ON ACT_RE_PROCDEF(TENANT_ID_); + +ALTER TABLE ACT_RU_EXECUTION + ADD TENANT_ID_ varchar(64); + +create index ACT_IDX_EXEC_TENANT_ID on ACT_RU_EXECUTION(TENANT_ID_); + +ALTER TABLE ACT_RU_TASK + ADD TENANT_ID_ varchar(64); + +create index ACT_IDX_TASK_TENANT_ID on ACT_RU_TASK(TENANT_ID_); + +ALTER TABLE ACT_RU_VARIABLE + ADD TENANT_ID_ varchar(64); + +create index ACT_IDX_VARIABLE_TENANT_ID on ACT_RU_VARIABLE(TENANT_ID_); + +ALTER TABLE ACT_RU_EVENT_SUBSCR + ADD TENANT_ID_ varchar(64); + +create index ACT_IDX_EVENT_SUBSCR_TENANT_ID on ACT_RU_EVENT_SUBSCR(TENANT_ID_); + +ALTER TABLE ACT_RU_JOB + ADD TENANT_ID_ varchar(64); + +create index ACT_IDX_JOB_TENANT_ID on ACT_RU_JOB(TENANT_ID_); + +ALTER TABLE ACT_RU_JOBDEF + ADD TENANT_ID_ varchar(64); + +create index ACT_IDX_JOBDEF_TENANT_ID on ACT_RU_JOBDEF(TENANT_ID_); + +ALTER TABLE ACT_RU_INCIDENT + ADD TENANT_ID_ varchar(64); + +ALTER TABLE ACT_RU_IDENTITYLINK + ADD TENANT_ID_ varchar(64); + +create index ACT_IDX_INC_TENANT_ID on ACT_RU_INCIDENT(TENANT_ID_); + +ALTER TABLE ACT_RU_EXT_TASK + ADD TENANT_ID_ varchar(64); + +create index ACT_IDX_EXT_TASK_TENANT_ID on ACT_RU_EXT_TASK(TENANT_ID_); + +ALTER TABLE ACT_RE_DECISION_DEF + DROP INDEX ACT_UNIQ_DECISION_DEF; + +ALTER TABLE ACT_RE_DECISION_DEF + ADD TENANT_ID_ varchar(64); + +create index ACT_IDX_DEC_DEF_TENANT_ID on ACT_RE_DECISION_DEF(TENANT_ID_); + +ALTER TABLE ACT_RE_CASE_DEF + DROP INDEX ACT_UNIQ_CASE_DEF; + +ALTER TABLE ACT_RE_CASE_DEF + ADD TENANT_ID_ varchar(64); + +create index ACT_IDX_CASE_DEF_TENANT_ID on ACT_RE_CASE_DEF(TENANT_ID_); + +ALTER TABLE ACT_GE_BYTEARRAY + ADD TENANT_ID_ varchar(64); + +ALTER TABLE ACT_RU_CASE_EXECUTION + ADD TENANT_ID_ varchar(64); + +create index ACT_IDX_CASE_EXEC_TENANT_ID on ACT_RU_CASE_EXECUTION(TENANT_ID_); + +ALTER TABLE ACT_RU_CASE_SENTRY_PART + ADD TENANT_ID_ varchar(64); + +-- user on historic decision instance -- + +ALTER TABLE ACT_HI_DECINST + ADD USER_ID_ varchar(255); + +-- tenant id on history -- + +ALTER TABLE ACT_HI_PROCINST + ADD TENANT_ID_ varchar(64); + +create index ACT_IDX_HI_PRO_INST_TENANT_ID on ACT_HI_PROCINST(TENANT_ID_); + +ALTER TABLE ACT_HI_ACTINST + ADD TENANT_ID_ varchar(64); + +create index ACT_IDX_HI_ACT_INST_TENANT_ID on ACT_HI_ACTINST(TENANT_ID_); + +ALTER TABLE ACT_HI_TASKINST + ADD TENANT_ID_ varchar(64); + +create index ACT_IDX_HI_TASK_INST_TENANT_ID on ACT_HI_TASKINST(TENANT_ID_); + +ALTER TABLE ACT_HI_VARINST + ADD TENANT_ID_ varchar(64); + +create index ACT_IDX_HI_VAR_INST_TENANT_ID on ACT_HI_VARINST(TENANT_ID_); + +ALTER TABLE ACT_HI_DETAIL + ADD TENANT_ID_ varchar(64); + +create index ACT_IDX_HI_DETAIL_TENANT_ID on ACT_HI_DETAIL(TENANT_ID_); + +ALTER TABLE ACT_HI_INCIDENT + ADD TENANT_ID_ varchar(64); + +create index ACT_IDX_HI_INCIDENT_TENANT_ID on ACT_HI_INCIDENT(TENANT_ID_); + +ALTER TABLE ACT_HI_JOB_LOG + ADD TENANT_ID_ varchar(64); + +create index ACT_IDX_HI_JOB_LOG_TENANT_ID on ACT_HI_JOB_LOG(TENANT_ID_); + +ALTER TABLE ACT_HI_COMMENT + ADD TENANT_ID_ varchar(64); + +ALTER TABLE ACT_HI_ATTACHMENT + ADD TENANT_ID_ varchar(64); + +ALTER TABLE ACT_HI_OP_LOG + ADD TENANT_ID_ varchar(64); + +ALTER TABLE ACT_HI_DEC_IN + ADD TENANT_ID_ varchar(64); + +ALTER TABLE ACT_HI_DEC_OUT + ADD TENANT_ID_ varchar(64); + +ALTER TABLE ACT_HI_DECINST + ADD TENANT_ID_ varchar(64); + +create index ACT_IDX_HI_DEC_INST_TENANT_ID on ACT_HI_DECINST(TENANT_ID_); + +ALTER TABLE ACT_HI_CASEINST + ADD TENANT_ID_ varchar(64); + +create index ACT_IDX_HI_CAS_I_TENANT_ID on ACT_HI_CASEINST(TENANT_ID_); + +ALTER TABLE ACT_HI_CASEACTINST + ADD TENANT_ID_ varchar(64); + +create index ACT_IDX_HI_CAS_A_I_TENANT_ID on ACT_HI_CASEACTINST(TENANT_ID_); + +-- AUTHORIZATION -- + +-- add grant authorizations for group camunda-admin: +INSERT INTO + ACT_RU_AUTHORIZATION (ID_, TYPE_, GROUP_ID_, RESOURCE_TYPE_, RESOURCE_ID_, PERMS_, REV_) +VALUES + ('camunda-admin-grant-tenant', 1, 'camunda-admin', 11, '*', 2147483647, 1), + ('camunda-admin-grant-tenant-membership', 1, 'camunda-admin', 12, '*', 2147483647, 1), + ('camunda-admin-grant-batch', 1, 'camunda-admin', 13, '*', 2147483647, 1); + +-- tenant table + +create table ACT_ID_TENANT ( + ID_ varchar(64), + REV_ integer, + NAME_ varchar(255), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_ID_TENANT_MEMBER ( + ID_ varchar(64) not null, + TENANT_ID_ varchar(64) not null, + USER_ID_ varchar(64), + GROUP_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +alter table ACT_ID_TENANT_MEMBER + add constraint ACT_UNIQ_TENANT_MEMB_USER + unique (TENANT_ID_, USER_ID_); + +alter table ACT_ID_TENANT_MEMBER + add constraint ACT_UNIQ_TENANT_MEMB_GROUP + unique (TENANT_ID_, GROUP_ID_); + +alter table ACT_ID_TENANT_MEMBER + add constraint ACT_FK_TENANT_MEMB + foreign key (TENANT_ID_) + references ACT_ID_TENANT (ID_); + +alter table ACT_ID_TENANT_MEMBER + add constraint ACT_FK_TENANT_MEMB_USER + foreign key (USER_ID_) + references ACT_ID_USER (ID_); + +alter table ACT_ID_TENANT_MEMBER + add constraint ACT_FK_TENANT_MEMB_GROUP + foreign key (GROUP_ID_) + references ACT_ID_GROUP (ID_); + +-- BATCH -- + +-- remove not null from job definition table -- +alter table ACT_RU_JOBDEF + modify PROC_DEF_ID_ varchar(64), + modify PROC_DEF_KEY_ varchar(255), + modify ACT_ID_ varchar(255); + +create table ACT_RU_BATCH ( + ID_ varchar(64) not null, + REV_ integer not null, + TYPE_ varchar(255), + TOTAL_JOBS_ integer, + JOBS_CREATED_ integer, + JOBS_PER_SEED_ integer, + INVOCATIONS_PER_JOB_ integer, + SEED_JOB_DEF_ID_ varchar(64), + BATCH_JOB_DEF_ID_ varchar(64), + MONITOR_JOB_DEF_ID_ varchar(64), + SUSPENSION_STATE_ integer, + CONFIGURATION_ varchar(255), + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_HI_BATCH ( + ID_ varchar(64) not null, + TYPE_ varchar(255), + TOTAL_JOBS_ integer, + JOBS_PER_SEED_ integer, + INVOCATIONS_PER_JOB_ integer, + SEED_JOB_DEF_ID_ varchar(64), + MONITOR_JOB_DEF_ID_ varchar(64), + BATCH_JOB_DEF_ID_ varchar(64), + TENANT_ID_ varchar(64), + START_TIME_ datetime(3) not null, + END_TIME_ datetime(3), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_HI_IDENTITYLINK ( + ID_ varchar(64) not null, + TIMESTAMP_ timestamp(3) not null, + TYPE_ varchar(255), + USER_ID_ varchar(255), + GROUP_ID_ varchar(255), + TASK_ID_ varchar(64), + PROC_DEF_ID_ varchar(64), + OPERATION_TYPE_ varchar(64), + ASSIGNER_ID_ varchar(64), + PROC_DEF_KEY_ varchar(255), + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create index ACT_IDX_HI_IDENT_LNK_USER on ACT_HI_IDENTITYLINK(USER_ID_); +create index ACT_IDX_HI_IDENT_LNK_GROUP on ACT_HI_IDENTITYLINK(GROUP_ID_); +create index ACT_IDX_HI_IDENT_LNK_TENANT_ID on ACT_HI_IDENTITYLINK(TENANT_ID_); + +create index ACT_IDX_JOB_JOB_DEF_ID on ACT_RU_JOB(JOB_DEF_ID_); +create index ACT_IDX_HI_JOB_LOG_JOB_DEF_ID on ACT_HI_JOB_LOG(JOB_DEF_ID_); + +create index ACT_IDX_BATCH_SEED_JOB_DEF ON ACT_RU_BATCH(SEED_JOB_DEF_ID_); +alter table ACT_RU_BATCH + add constraint ACT_FK_BATCH_SEED_JOB_DEF + foreign key (SEED_JOB_DEF_ID_) + references ACT_RU_JOBDEF (ID_); + +create index ACT_IDX_BATCH_MONITOR_JOB_DEF ON ACT_RU_BATCH(MONITOR_JOB_DEF_ID_); +alter table ACT_RU_BATCH + add constraint ACT_FK_BATCH_MONITOR_JOB_DEF + foreign key (MONITOR_JOB_DEF_ID_) + references ACT_RU_JOBDEF (ID_); + +create index ACT_IDX_BATCH_JOB_DEF ON ACT_RU_BATCH(BATCH_JOB_DEF_ID_); +alter table ACT_RU_BATCH + add constraint ACT_FK_BATCH_JOB_DEF + foreign key (BATCH_JOB_DEF_ID_) + references ACT_RU_JOBDEF (ID_); + +-- TASK PRIORITY -- + +ALTER TABLE ACT_RU_EXT_TASK + ADD PRIORITY_ bigint NOT NULL DEFAULT 0; + +create index ACT_IDX_EXT_TASK_PRIORITY ON ACT_RU_EXT_TASK(PRIORITY_); + +-- HI OP PROC INDECIES -- + +create index ACT_IDX_HI_OP_LOG_PROCINST on ACT_HI_OP_LOG(PROC_INST_ID_); +create index ACT_IDX_HI_OP_LOG_PROCDEF on ACT_HI_OP_LOG(PROC_DEF_ID_); + +-- JOB_DEF_ID_ on INCIDENTS -- +ALTER TABLE ACT_RU_INCIDENT + ADD JOB_DEF_ID_ varchar(64); + +create index ACT_IDX_INC_JOB_DEF on ACT_RU_INCIDENT(JOB_DEF_ID_); +alter table ACT_RU_INCIDENT + add constraint ACT_FK_INC_JOB_DEF + foreign key (JOB_DEF_ID_) + references ACT_RU_JOBDEF (ID_); + +ALTER TABLE ACT_HI_INCIDENT + ADD JOB_DEF_ID_ varchar(64); + +-- BATCH_ID_ on ACT_HI_OP_LOG -- +ALTER TABLE ACT_HI_OP_LOG + ADD BATCH_ID_ varchar(64); + + -- add indexes on PROC_DEF_KEY_ columns in history tables CAM-6679 +create index ACT_IDX_HI_ACT_INST_PROC_DEF_KEY on ACT_HI_ACTINST(PROC_DEF_KEY_); +create index ACT_IDX_HI_DETAIL_PROC_DEF_KEY on ACT_HI_DETAIL(PROC_DEF_KEY_); +create index ACT_IDX_HI_IDENT_LNK_PROC_DEF_KEY on ACT_HI_IDENTITYLINK(PROC_DEF_KEY_); +create index ACT_IDX_HI_INCIDENT_PROC_DEF_KEY on ACT_HI_INCIDENT(PROC_DEF_KEY_); +create index ACT_IDX_HI_JOB_LOG_PROC_DEF_KEY on ACT_HI_JOB_LOG(PROCESS_DEF_KEY_); +create index ACT_IDX_HI_PRO_INST_PROC_DEF_KEY on ACT_HI_PROCINST(PROC_DEF_KEY_); +create index ACT_IDX_HI_TASK_INST_PROC_DEF_KEY on ACT_HI_TASKINST(PROC_DEF_KEY_); +create index ACT_IDX_HI_VAR_INST_PROC_DEF_KEY on ACT_HI_VARINST(PROC_DEF_KEY_); diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/CreateNetworkV2mock/sdncCreateNetworkTopologySimResponse.xml b/bpmn/MSOCommonBPMN/src/test/resources/__files/CreateNetworkV2mock/sdncCreateNetworkTopologySimResponse.xml new file mode 100644 index 0000000000..40bb93bda0 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/CreateNetworkV2mock/sdncCreateNetworkTopologySimResponse.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" + xmlns:v1="http://org.openecomp/workflow/sdnc/adapter/schema/v1"> + <soapenv:Header /> + <soapenv:Body> + <v1:SDNCAdapterCallback> + <SDNCAdapterCallbackRequest xmlns="http://org.openecomp/workflow/sdnc/adapter/schema/v1"> + <CallbackHeader> + <RequestId>testRequestId</RequestId> + <ResponseCode>200</ResponseCode> + <ResponseMessage>OK</ResponseMessage> + </CallbackHeader> + <RequestData xmlns:xs="http://www.w3.org/2001/XMLSchema" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:type="xs:string"><?xml version="1.0" encoding="UTF-8"?><output xmlns="com:att:sdnctl:vnf"><svc-request-id>19174929-3809-49ca-89eb-17f84a035389</svc-request-id><response-code>200</response-code><ack-final-indicator>Y</ack-final-indicator><network-information><network-id>49c86598-f766-46f8-84f8-8d1c1b10f9b4</network-id></network-information><service-information><service-type>a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb</service-type><service-instance-id>HSL_direct_net_2</service-instance-id><subscriber-name>notsurewecare</subscriber-name></service-information></output></RequestData> + </SDNCAdapterCallbackRequest> + </v1:SDNCAdapterCallback> + </soapenv:Body> +</soapenv:Envelope> diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/CreateServiceInstance/createServiceInstance_genericQueryByInstanceName_AAIResponse_200.xml b/bpmn/MSOCommonBPMN/src/test/resources/__files/CreateServiceInstance/createServiceInstance_genericQueryByInstanceName_AAIResponse_200.xml new file mode 100644 index 0000000000..742ec13a04 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/CreateServiceInstance/createServiceInstance_genericQueryByInstanceName_AAIResponse_200.xml @@ -0,0 +1,13 @@ +<search-results xmlns="http://com.att.aai.inventory"> + <service-instances> + <service-instance> + <service-instance-id>f70e927b-6087-4974-9ef8-c5e4d5847ca4</service-instance-id> + <persona-model-id>gg0e927b-6087-5574-9ef8-c5e4d5847db5</persona-model-id> + <persona-model-version>V1.0</persona-model-version> + <service-instance-name>vMOG-AKRON-1234</service-instance-name> + <resource-version>1462561835</resource-version> + <relationship-list/> + <metadata/> + </service-instance> + </service-instances> + </search-results>
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/CreateServiceInstance/createServiceInstance_genericQueryByInstanceName_AAIResponse_Fault.xml b/bpmn/MSOCommonBPMN/src/test/resources/__files/CreateServiceInstance/createServiceInstance_genericQueryByInstanceName_AAIResponse_Fault.xml new file mode 100644 index 0000000000..f33255b8a7 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/CreateServiceInstance/createServiceInstance_genericQueryByInstanceName_AAIResponse_Fault.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<Fault> + <requestError> + <serviceException> + <messageId>SVC3000</messageId> + <text>Invalid input performing %1 on %2 (msg=%3) (ec=%4)</text> + <variables> + <variable>PUT customer</variable> + <variable>global-customer-id=global_subscriber_id </variable> + <variable>Uniqueness constraint violated:Conflicting Key and Alternate-Key values passed for add of nodeType = customer</variable> + <variable>ERR.5.4.6117</variable> + </variables> + </serviceException> + </requestError> +</Fault> diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/CreateVfModuleVolumeGroup_VID_request.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/CreateVfModuleVolumeGroup_VID_request.json new file mode 100644 index 0000000000..c3064fe07c --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/CreateVfModuleVolumeGroup_VID_request.json @@ -0,0 +1,74 @@ +{ +"requestDetails": { +"modelInfo": { +"modelType": "vfModule", +"modelInvariantId": "ff5256d2-5a33-55df-13ab-12abad84e7ff", +"modelNameVersionId": "fe6478e5-ea33-3346-ac12-ab121484a3fe", +"modelName": "STMTN5MMSC21-MMSC::model-1-0", +"modelVersion": "1" +}, +"cloudConfiguration": { +"lcpCloudRegionId": "MDTWNJ21", +"tenantId": "fba1bd1e195a404cacb9ce17a9b2b421" +}, +"requestInfo": { +"instanceName": "PCRF::module-0-2", +"source": "VID", +"suppressRollback": true +}, +"relatedInstanceList": [ +{ +"relatedInstance": { +"instanceId": "17ef4658-bd1f-4ef0-9ca0-ea76e2bf122c", +"instanceName": "MSOTESTVOL103a-vSAMP12_base_module-0_vol", +"modelInfo": { +"modelType": "volumeGroup", +"modelInvariantId": "ff5256d2-5a33-55df-13ab-12abad84e7ff", +"modelNameVersionId": "fe6478e5-ea33-3346-ac12-ab121484a3fe", +"modelName": "vSAMP12..base..module-0", +"modelVersion": "1" +} +} +}, +{ +"relatedInstance": { +"instanceId": "123456", +"modelInfo": { +"modelType": "service", +"modelInvariantId": "ff3514e3-5a33-55df-13ab-12abad84e7ff", +"modelNameVersionId": "fe6985cd-ea33-3346-ac12-ab121484a3fe", +"modelName": "SERVICE_MODEL_NAME", +"modelVersion": "1.0" +} +} +}, +{ +"relatedInstance": { +"instanceId": "skask", +"modelInfo": { +"modelType": "vnf", +"modelInvariantId": "skask", +"modelNameVersionId": "fe6478e4-ea33-3346-ac12-ab121484a3fe", +"modelName": "vSAMP12", +"modelVersion": "1.0", +"modelCustomizationName": "vSAMP12 1" +} +} +}, +{ +"relatedInstance": { +"instanceId": "78987", +"modelInfo": { +"modelType": "volumeGroup", +"modelInvariantId": "skask", +"modelNameVersionId": "fe6478e4-ea33-3346-ac12-ab121484a3fe", +"modelName": "vSAMP12", +"modelVersion": "1.0" +} +} +} +], +"requestParameters": { +"userParams": {} +} +}
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/CreateVfModule_VID_request.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/CreateVfModule_VID_request.json new file mode 100644 index 0000000000..a18ce576b5 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/CreateVfModule_VID_request.json @@ -0,0 +1,64 @@ +{ +"requestDetails": { +"modelInfo": { +"modelType": "vfModule", +"modelInvariantId": "ff5256d2-5a33-55df-13ab-12abad84e7ff", +"modelNameVersionId": "fe6478e5-ea33-3346-ac12-ab121484a3fe", +"modelName": "STMTN5MMSC21-MMSC::model-1-0", +"modelVersion": "1", +"modelCustomizationId": "ee6478e5-ea33-3346-ac12-ab121484a3fe" +}, +"cloudConfiguration": { +"lcpCloudRegionId": "MDTWNJ21", +"tenantId": "fba1bd1e195a404cacb9ce17a9b2b421" +}, +"requestInfo": { +"instanceName": "PCRF::module-0-2", +"source": "VID", +"suppressRollback": true +}, +"relatedInstanceList": [ +{ +"relatedInstance": { +"instanceId": "17ef4658-bd1f-4ef0-9ca0-ea76e2bf122c", +"instanceName": "MSOTESTVOL103a-vSAMP12_base_module-0_vol", +"modelInfo": { +"modelType": "volumeGroup", +"modelInvariantId": "ff5256d2-5a33-55df-13ab-12abad84e7ff", +"modelNameVersionId": "fe6478e5-ea33-3346-ac12-ab121484a3fe", +"modelName": "vSAMP12..base..module-0", +"modelVersion": "1" +} +} +}, +{ +"relatedInstance": { +"instanceId": "123456", +"modelInfo": { +"modelType": "service", +"modelInvariantId": "ff3514e3-5a33-55df-13ab-12abad84e7ff", +"modelNameVersionId": "fe6985cd-ea33-3346-ac12-ab121484a3fe", +"modelName": "SERVICE_MODEL_NAME", +"modelVersion": "1.0" +} +} +}, +{ +"relatedInstance": { +"instanceId": "skask", +"instanceName": "skask-test", +"modelInfo": { +"modelType": "vnf", +"modelInvariantId": "skask", +"modelNameVersionId": "fe6478e4-ea33-3346-ac12-ab121484a3fe", +"modelName": "vSAMP12", +"modelVersion": "1.0", +"modelCustomizationName": "vSAMP12 1" +} +} +} +], +"requestParameters": { +"userParams": {} +} +}
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/Database/DBAdapter.xml b/bpmn/MSOCommonBPMN/src/test/resources/__files/Database/DBAdapter.xml new file mode 100644 index 0000000000..5a36d741d0 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/Database/DBAdapter.xml @@ -0,0 +1 @@ +<DbTag>Notified</DbTag>
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/Database/DBUpdateResponse.xml b/bpmn/MSOCommonBPMN/src/test/resources/__files/Database/DBUpdateResponse.xml new file mode 100644 index 0000000000..7c30f75497 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/Database/DBUpdateResponse.xml @@ -0,0 +1,4 @@ + + +<ns2:updateRequestResponse xmlns:ns2="http://org.openecomp.mso/requestsdb" + xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"/>
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/DeleteNetworkV2mock/sdncDeleteNetworkTopologySimResponse.xml b/bpmn/MSOCommonBPMN/src/test/resources/__files/DeleteNetworkV2mock/sdncDeleteNetworkTopologySimResponse.xml new file mode 100644 index 0000000000..cb5d0001f7 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/DeleteNetworkV2mock/sdncDeleteNetworkTopologySimResponse.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" + xmlns:v1="http://org.openecomp/workflow/sdnc/adapter/schema/v1"> + <soapenv:Header /> + <soapenv:Body> + <v1:SDNCAdapterCallback> + <SDNCAdapterCallbackRequest xmlns="http://org.openecomp/workflow/sdnc/adapter/schema/v1"> + <CallbackHeader> + <RequestId>19174929-3809-49ca-89eb-17f84a035389</RequestId> + <ResponseCode>200</ResponseCode> + <ResponseMessage>OK</ResponseMessage> + </CallbackHeader> + <RequestData xmlns:xs="http://www.w3.org/2001/XMLSchema" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:type="xs:string"><?xml version="1.0" encoding="UTF-8"?><output xmlns="com:att:sdnctl:vnf"><svc-request-id>19174929-3809-49ca-89eb-17f84a035389</svc-request-id><response-code>200</response-code><ack-final-indicator>Y</ack-final-indicator><network-information><network-id>bdc5efe8-404a-409b-85f6-0dcc9eebae30</network-id></network-information><service-information><service-type>a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb</service-type><service-instance-id>HSL_direct_net_2</service-instance-id><subscriber-name>notsurewecare</subscriber-name></service-information></output></RequestData> + </SDNCAdapterCallbackRequest> + </v1:SDNCAdapterCallback> + </soapenv:Body> +</soapenv:Envelope> diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/DeleteVfModule_VID_request.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/DeleteVfModule_VID_request.json new file mode 100644 index 0000000000..c75c32d498 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/DeleteVfModule_VID_request.json @@ -0,0 +1,50 @@ +{ +"requestDetails": { +"modelInfo": { +"modelType": "vfModule", +"modelInvariantId": "973ed047-d251-4fb9-bf1a-65b8949e0a73", +"modelNameVersionId": "973ed047-d251-4fb9-bf1a-65b8949e0a73", +"modelName": "STMTN5MMSC21-MMSC::model-1-0", +"modelVersion": "1" +}, +"cloudConfiguration": { +"lcpCloudRegionId": "MDTWNJ21", +"tenantId": "fba1bd1e195a404cacb9ce17a9b2b421" +}, +"requestInfo": { +"instanceId": "973ed047-d251-4fb9-bf1a-65b8949e0a73", +"source": "VID", +"suppressRollback": true +}, +"relatedInstanceList": [ +{ +"relatedInstance": { +"instanceId": "00000000-0000-0000-0000-000000000000", +"modelInfo": { +"modelType": "service", +"modelInvariantId": "ff3514e3-5a33-55df-13ab-12abad84e7ff", +"modelNameVersionId": "fe6985cd-ea33-3346-ac12-ab121484a3fe", +"modelName": "SERVICE_MODEL_NAME", +"modelVersion": "1.0" +} +} +}, +{ +"relatedInstance": { +"instanceId": "a27ce5a9-29c4-4c22-a017-6615ac73c721", +"modelInfo": { +"modelType": "vnf", +"modelInvariantId": "skask", +"modelNameVersionId": "a27ce5a9-29c4-4c22-a017-6615ac73c721", +"modelName": "vSAMP12", +"modelVersion": "1.0", +"modelCustomizationName": "vSAMP12 1" +} +} +} +], +"requestParameters": { +"userParams": {} +} +} +}
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/GENDSI_getServiceInstanceResponse.xml b/bpmn/MSOCommonBPMN/src/test/resources/__files/GENDSI_getServiceInstanceResponse.xml new file mode 100644 index 0000000000..4aeac5ccb8 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/GENDSI_getServiceInstanceResponse.xml @@ -0,0 +1,35 @@ + <service-subscription xmlns="http://com.att.aai.inventory"> + <service-type>SDN-ETHERNET-INTERNET</service-type> + <resource-version>1234</resource-version> + <service-instances> + <service-instance> + <service-instance-id>MIS/1604/0026/SW_INTERNET</service-instance-id> + <relationship-list> + <relationship> + <related-to>cvlan-tag</related-to> + <related-link>https://aai-ext1.test.att.com:8443/aai/v2/network/vces/vce/832bace2-3fb0-49e0-a6a4-07c47223c535/port-groups/port-group/slcp1447vbc.ipag/cvlan-tags/cvlan-tag/2003/</related-link> + <relationship-data> + <relationship-key>cvlan-tag.cvlan-tag</relationship-key> + <relationship-value>2003</relationship-value> + </relationship-data> + <relationship-data> + <relationship-key>port-group.interface-id</relationship-key> + <relationship-value>slcp1447vbc.ipag</relationship-value> + </relationship-data> + <relationship-data> + <relationship-key>vce.vnf-id</relationship-key> + <relationship-value>832bace2-3fb0-49e0-a6a4-07c47223c535</relationship-value> + </relationship-data> + </relationship> + <relationship> + <related-to>vce</related-to> + <related-link>https://aai-ext1.test.att.com:8443/aai/v2/network/vces/vce/832bace2-3fb0-49e0-a6a4-07c47223c535/</related-link> + <relationship-data> + <relationship-key>vce.vnf-id</relationship-key> + <relationship-value>832bace2-3fb0-49e0-a6a4-07c47223c535</relationship-value> + </relationship-data> + </relationship> + </relationship-list> + </service-instance> + </service-instances> + </service-subscription>
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/GenericFlows/getGenericVnfByNameResponse.xml b/bpmn/MSOCommonBPMN/src/test/resources/__files/GenericFlows/getGenericVnfByNameResponse.xml new file mode 100644 index 0000000000..a397e5bcba --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/GenericFlows/getGenericVnfByNameResponse.xml @@ -0,0 +1,23 @@ +<generic-vnfs xmlns="http://com.att.aai.inventory/v3"> + <generic-vnf> + <vnf-id>2f1cc940-455f-4ee2-9411-a7899cd4f124</vnf-id> + <vnf-name>testVnfName123</vnf-name> + <vnf-type>mmsc-capacity</vnf-type> + <service-id>a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb</service-id> + <equipment-role>vMMSC</equipment-role> + <orchestration-status>pending-create</orchestration-status> + <resource-version>testReVer123</resource-version> + <relationship-list> + <relationship> + <related-to>nothing</related-to> + <related-link>https://aai-app-e2e.test.att.com:8443/aai/v3/network/l3-networks/l3-network/c597ab81-fece-49f4-a4f5-710cebb13c29/</related-link> + <relationship-data> + <relationship-key>l3-network.network-id</relationship-key> + <relationship-value>c597ab81-fece-49f4-a4f5-710cebb13c29</relationship-value> + </relationship-data> + </relationship> + </relationship-list> + <l-interfaces/> + <lag-interfaces/> + </generic-vnf> + </generic-vnfs>
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/GenericFlows/getGenericVnfResponse.xml b/bpmn/MSOCommonBPMN/src/test/resources/__files/GenericFlows/getGenericVnfResponse.xml new file mode 100644 index 0000000000..3227a038af --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/GenericFlows/getGenericVnfResponse.xml @@ -0,0 +1,90 @@ +<generic-vnfs xmlns="http://com.att.aai.inventory/v3"> + <generic-vnf> + <vnf-id>2f1cc940-455f-4ee2-9411-a7899cd4f124</vnf-id> + <vnf-name>testVnfName123</vnf-name> + <vnf-type>mmsc-capacity</vnf-type> + <service-id>a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb</service-id> + <equipment-role>vMMSC</equipment-role> + <orchestration-status>pending-create</orchestration-status> + <relationship-list> + <relationship> + <related-to>l3-network</related-to> + <related-link>https://aai-app-e2e.test.att.com:8443/aai/v3/network/l3-networks/l3-network/c597ab81-fece-49f4-a4f5-710cebb13c29/</related-link> + <relationship-data> + <relationship-key>l3-network.network-id</relationship-key> + <relationship-value>c597ab81-fece-49f4-a4f5-710cebb13c29</relationship-value> + </relationship-data> + </relationship> + <relationship> + <related-to>l3-network</related-to> + <related-link>https://aai-app-e2e.test.att.com:8443/aai/v3/network/l3-networks/l3-network/53956c91-6e5e-49aa-88dd-535f57e66e70/</related-link> + <relationship-data> + <relationship-key>l3-network.network-id</relationship-key> + <relationship-value>53956c91-6e5e-49aa-88dd-535f57e66e70</relationship-value> + </relationship-data> + </relationship> + <relationship> + <related-to>l3-network</related-to> + <related-link>https://aai-app-e2e.test.att.com:8443/aai/v3/network/l3-networks/l3-network/44e0d9e0-9334-4ec6-9344-07a96dac629f/</related-link> + <relationship-data> + <relationship-key>l3-network.network-id</relationship-key> + <relationship-value>44e0d9e0-9334-4ec6-9344-07a96dac629f</relationship-value> + </relationship-data> + </relationship> + <relationship> + <related-to>l3-network</related-to> + <related-link>https://aai-app-e2e.test.att.com:8443/aai/v3/network/l3-networks/l3-network/ac49d99b-5daf-4624-9f8e-188b126ea166/</related-link> + <relationship-data> + <relationship-key>l3-network.network-id</relationship-key> + <relationship-value>ac49d99b-5daf-4624-9f8e-188b126ea166</relationship-value> + </relationship-data> + </relationship> + </relationship-list> + <l-interfaces/> + <lag-interfaces/> + </generic-vnf> + <generic-vnf> + <vnf-id>802767b3-18a6-4432-96db-25522786aee0</vnf-id> + <vnf-name>ZRDM1MMSC03</vnf-name> + <vnf-type>mmsc-capacity</vnf-type> + <service-id>a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb</service-id> + <equipment-role>vMMSC</equipment-role> + <orchestration-status>pending-create</orchestration-status> + <relationship-list> + <relationship> + <related-to>l3-network</related-to> + <related-link>https://aai-app-e2e.test.att.com:8443/aai/v3/network/l3-networks/l3-network/c597ab81-fece-49f4-a4f5-710cebb13c29/</related-link> + <relationship-data> + <relationship-key>l3-network.network-id</relationship-key> + <relationship-value>c597ab81-fece-49f4-a4f5-710cebb13c29</relationship-value> + </relationship-data> + </relationship> + <relationship> + <related-to>l3-network</related-to> + <related-link>https://aai-app-e2e.test.att.com:8443/aai/v3/network/l3-networks/l3-network/53956c91-6e5e-49aa-88dd-535f57e66e70/</related-link> + <relationship-data> + <relationship-key>l3-network.network-id</relationship-key> + <relationship-value>53956c91-6e5e-49aa-88dd-535f57e66e70</relationship-value> + </relationship-data> + </relationship> + <relationship> + <related-to>l3-network</related-to> + <related-link>https://aai-app-e2e.test.att.com:8443/aai/v3/network/l3-networks/l3-network/44e0d9e0-9334-4ec6-9344-07a96dac629f/</related-link> + <relationship-data> + <relationship-key>l3-network.network-id</relationship-key> + <relationship-value>44e0d9e0-9334-4ec6-9344-07a96dac629f</relationship-value> + </relationship-data> + </relationship> + <relationship> + <related-to>l3-network</related-to> + <related-link>https://aai-app-e2e.test.att.com:8443/aai/v3/network/l3-networks/l3-network/ac49d99b-5daf-4624-9f8e-188b126ea166/</related-link> + <relationship-data> + <relationship-key>l3-network.network-id</relationship-key> + <relationship-value>ac49d99b-5daf-4624-9f8e-188b126ea166</relationship-value> + </relationship-data> + </relationship> + </relationship-list> + <l-interfaces/> + <lag-interfaces/> + </generic-vnf> + </generic-vnfs>
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/GenericFlows/getGenericVnfResponse_hasRelationships.xml b/bpmn/MSOCommonBPMN/src/test/resources/__files/GenericFlows/getGenericVnfResponse_hasRelationships.xml new file mode 100644 index 0000000000..3227a038af --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/GenericFlows/getGenericVnfResponse_hasRelationships.xml @@ -0,0 +1,90 @@ +<generic-vnfs xmlns="http://com.att.aai.inventory/v3"> + <generic-vnf> + <vnf-id>2f1cc940-455f-4ee2-9411-a7899cd4f124</vnf-id> + <vnf-name>testVnfName123</vnf-name> + <vnf-type>mmsc-capacity</vnf-type> + <service-id>a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb</service-id> + <equipment-role>vMMSC</equipment-role> + <orchestration-status>pending-create</orchestration-status> + <relationship-list> + <relationship> + <related-to>l3-network</related-to> + <related-link>https://aai-app-e2e.test.att.com:8443/aai/v3/network/l3-networks/l3-network/c597ab81-fece-49f4-a4f5-710cebb13c29/</related-link> + <relationship-data> + <relationship-key>l3-network.network-id</relationship-key> + <relationship-value>c597ab81-fece-49f4-a4f5-710cebb13c29</relationship-value> + </relationship-data> + </relationship> + <relationship> + <related-to>l3-network</related-to> + <related-link>https://aai-app-e2e.test.att.com:8443/aai/v3/network/l3-networks/l3-network/53956c91-6e5e-49aa-88dd-535f57e66e70/</related-link> + <relationship-data> + <relationship-key>l3-network.network-id</relationship-key> + <relationship-value>53956c91-6e5e-49aa-88dd-535f57e66e70</relationship-value> + </relationship-data> + </relationship> + <relationship> + <related-to>l3-network</related-to> + <related-link>https://aai-app-e2e.test.att.com:8443/aai/v3/network/l3-networks/l3-network/44e0d9e0-9334-4ec6-9344-07a96dac629f/</related-link> + <relationship-data> + <relationship-key>l3-network.network-id</relationship-key> + <relationship-value>44e0d9e0-9334-4ec6-9344-07a96dac629f</relationship-value> + </relationship-data> + </relationship> + <relationship> + <related-to>l3-network</related-to> + <related-link>https://aai-app-e2e.test.att.com:8443/aai/v3/network/l3-networks/l3-network/ac49d99b-5daf-4624-9f8e-188b126ea166/</related-link> + <relationship-data> + <relationship-key>l3-network.network-id</relationship-key> + <relationship-value>ac49d99b-5daf-4624-9f8e-188b126ea166</relationship-value> + </relationship-data> + </relationship> + </relationship-list> + <l-interfaces/> + <lag-interfaces/> + </generic-vnf> + <generic-vnf> + <vnf-id>802767b3-18a6-4432-96db-25522786aee0</vnf-id> + <vnf-name>ZRDM1MMSC03</vnf-name> + <vnf-type>mmsc-capacity</vnf-type> + <service-id>a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb</service-id> + <equipment-role>vMMSC</equipment-role> + <orchestration-status>pending-create</orchestration-status> + <relationship-list> + <relationship> + <related-to>l3-network</related-to> + <related-link>https://aai-app-e2e.test.att.com:8443/aai/v3/network/l3-networks/l3-network/c597ab81-fece-49f4-a4f5-710cebb13c29/</related-link> + <relationship-data> + <relationship-key>l3-network.network-id</relationship-key> + <relationship-value>c597ab81-fece-49f4-a4f5-710cebb13c29</relationship-value> + </relationship-data> + </relationship> + <relationship> + <related-to>l3-network</related-to> + <related-link>https://aai-app-e2e.test.att.com:8443/aai/v3/network/l3-networks/l3-network/53956c91-6e5e-49aa-88dd-535f57e66e70/</related-link> + <relationship-data> + <relationship-key>l3-network.network-id</relationship-key> + <relationship-value>53956c91-6e5e-49aa-88dd-535f57e66e70</relationship-value> + </relationship-data> + </relationship> + <relationship> + <related-to>l3-network</related-to> + <related-link>https://aai-app-e2e.test.att.com:8443/aai/v3/network/l3-networks/l3-network/44e0d9e0-9334-4ec6-9344-07a96dac629f/</related-link> + <relationship-data> + <relationship-key>l3-network.network-id</relationship-key> + <relationship-value>44e0d9e0-9334-4ec6-9344-07a96dac629f</relationship-value> + </relationship-data> + </relationship> + <relationship> + <related-to>l3-network</related-to> + <related-link>https://aai-app-e2e.test.att.com:8443/aai/v3/network/l3-networks/l3-network/ac49d99b-5daf-4624-9f8e-188b126ea166/</related-link> + <relationship-data> + <relationship-key>l3-network.network-id</relationship-key> + <relationship-value>ac49d99b-5daf-4624-9f8e-188b126ea166</relationship-value> + </relationship-data> + </relationship> + </relationship-list> + <l-interfaces/> + <lag-interfaces/> + </generic-vnf> + </generic-vnfs>
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/GenericFlows/getSIUrlById.xml b/bpmn/MSOCommonBPMN/src/test/resources/__files/GenericFlows/getSIUrlById.xml new file mode 100644 index 0000000000..28ce8ef1b7 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/GenericFlows/getSIUrlById.xml @@ -0,0 +1,6 @@ + <search-results xmlns="http://com.att.aai.inventory"> + <result-data> + <resource-type>service-instance</resource-type> + <resource-link>https://aai-ext1.test.att.com:8443/aai/v7/business/customers/customer/SDN-ETHERNET-INTERNET/service-subscriptions/service-subscription/123456789/service-instances/service-instance/MIS%252F1604%252F0026%252FSW_INTERNET</resource-link> + </result-data> + </search-results>
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/GenericFlows/getSIUrlByName.xml b/bpmn/MSOCommonBPMN/src/test/resources/__files/GenericFlows/getSIUrlByName.xml new file mode 100644 index 0000000000..28ce8ef1b7 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/GenericFlows/getSIUrlByName.xml @@ -0,0 +1,6 @@ + <search-results xmlns="http://com.att.aai.inventory"> + <result-data> + <resource-type>service-instance</resource-type> + <resource-link>https://aai-ext1.test.att.com:8443/aai/v7/business/customers/customer/SDN-ETHERNET-INTERNET/service-subscriptions/service-subscription/123456789/service-instances/service-instance/MIS%252F1604%252F0026%252FSW_INTERNET</resource-link> + </result-data> + </search-results>
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/GenericFlows/getServiceInstance.xml b/bpmn/MSOCommonBPMN/src/test/resources/__files/GenericFlows/getServiceInstance.xml new file mode 100644 index 0000000000..5ffdda268f --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/GenericFlows/getServiceInstance.xml @@ -0,0 +1,30 @@ +<service-instance> + <service-instance-id>MIS/1604/0026/SW_INTERNET</service-instance-id> + <resource-version>123456789</resource-version> + <relationship-list> + <relationship> + <related-to>cvlan-tag</related-to> + <related-link>https://aai-ext1.test.att.com:8443/aai/v2/network/vces/vce/832bace2-3fb0-49e0-a6a4-07c47223c535/port-groups/port-group/slcp1447vbc.ipag/cvlan-tags/cvlan-tag/2003/</related-link> + <relationship-data> + <relationship-key>cvlan-tag.cvlan-tag</relationship-key> + <relationship-value>2003</relationship-value> + </relationship-data> + <relationship-data> + <relationship-key>port-group.interface-id</relationship-key> + <relationship-value>slcp1447vbc.ipag</relationship-value> + </relationship-data> + <relationship-data> + <relationship-key>vce.vnf-id</relationship-key> + <relationship-value>832bace2-3fb0-49e0-a6a4-07c47223c535</relationship-value> + </relationship-data> + </relationship> + <relationship> + <related-to>vce</related-to> + <related-link>https://aai-ext1.test.att.com:8443/aai/v2/network/vces/vce/832bace2-3fb0-49e0-a6a4-07c47223c535/</related-link> + <relationship-data> + <relationship-key>vce.vnf-id</relationship-key> + <relationship-value>832bace2-3fb0-49e0-a6a4-07c47223c535</relationship-value> + </relationship-data> + </relationship> + </relationship-list> + </service-instance>
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/GenericFlows/getServiceSubscription.xml b/bpmn/MSOCommonBPMN/src/test/resources/__files/GenericFlows/getServiceSubscription.xml new file mode 100644 index 0000000000..41815d46e6 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/GenericFlows/getServiceSubscription.xml @@ -0,0 +1,34 @@ +<service-subscription xmlns="http://com.att.aai.inventory"> + <service-type>SDN-ETHERNET-INTERNET</service-type> + <resource-version>1234</resource-version> + <service-instance> + <service-instance-id>MIS/1604/0026/SW_INTERNET</service-instance-id> + <resource-version>123456789</resource-version> + <relationship-list> + <relationship> + <related-to>cvlan-tag</related-to> + <related-link>https://aai-ext1.test.att.com:8443/aai/v2/network/vces/vce/832bace2-3fb0-49e0-a6a4-07c47223c535/port-groups/port-group/slcp1447vbc.ipag/cvlan-tags/cvlan-tag/2003/</related-link> + <relationship-data> + <relationship-key>cvlan-tag.cvlan-tag</relationship-key> + <relationship-value>2003</relationship-value> + </relationship-data> + <relationship-data> + <relationship-key>port-group.interface-id</relationship-key> + <relationship-value>slcp1447vbc.ipag</relationship-value> + </relationship-data> + <relationship-data> + <relationship-key>vce.vnf-id</relationship-key> + <relationship-value>832bace2-3fb0-49e0-a6a4-07c47223c535</relationship-value> + </relationship-data> + </relationship> + <relationship> + <related-to>vce</related-to> + <related-link>https://aai-ext1.test.att.com:8443/aai/v2/network/vces/vce/832bace2-3fb0-49e0-a6a4-07c47223c535/</related-link> + <relationship-data> + <relationship-key>vce.vnf-id</relationship-key> + <relationship-value>832bace2-3fb0-49e0-a6a4-07c47223c535</relationship-value> + </relationship-data> + </relationship> + </relationship-list> + </service-instance> + </service-subscription>
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/GenericFlows/getVceByNameResponse.xml b/bpmn/MSOCommonBPMN/src/test/resources/__files/GenericFlows/getVceByNameResponse.xml new file mode 100644 index 0000000000..a83e06ee6f --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/GenericFlows/getVceByNameResponse.xml @@ -0,0 +1,97 @@ +<vce xmlns="http://com.att.aai.inventory"> + <vnf-id>1936628a-d22f-4943-8587-a57bab2ece7a</vnf-id> + <vnf-name>testVnfName123</vnf-name> + <vnf-name2>US0112SLCP1VBRT076</vnf-name2> + <vnf-type>esx-vce</vnf-type> + <prov-status>NVTPROV</prov-status> + <orchestration-status>created</orchestration-status> + <resource-version>0000020</resource-version> + <heat-stack-id>slcp1476vbc/94a3c72b-94d5-444b-9a1f-647a36c2181d</heat-stack-id> + <mso-catalog-key/> + <vpe-id>VPESAT-mtanjrsv126</vpe-id> + <ipv4-oam-address>135.21.249.160</ipv4-oam-address> + <port-groups> + <port-group> + <interface-id>slcp1476vbc.vpe</interface-id> + <neutron-network-id>e7568706-a2a9-45f8-aef8-95a0e2910953</neutron-network-id> + <neutron-network-name>dvspg-VCE_VPE-slcp1476vbc</neutron-network-name> + <interface-role>Internet</interface-role> + <port-group-name>dvspg-VCE_VPE-slcp1476vbc</port-group-name> + <resource-version>0000020</resource-version> + <switch-name>dvs-slcp1-01</switch-name> + <orchestration-status>created</orchestration-status> + <heat-stack-id>dvspg-VCE_VPE-slcp1476vbc/c1299f74-da35-4228-b1e0-d2fd07176196</heat-stack-id> + <mso-catalog-key/> + <cvlan-tags> + <cvlan-tag-entry> + <cvlan-tag>3012</cvlan-tag> + <resource-version>0000020</resource-version> + </cvlan-tag-entry> + </cvlan-tags> + </port-group> + <port-group> + <interface-id>slcp1476vbc.ipag</interface-id> + <neutron-network-id>3477ddb6-b925-4971-ab62-c84b69634c49</neutron-network-id> + <neutron-network-name>dvspg-IPAG_VCE-slcp1476vbc</neutron-network-name> + <interface-role>Customer</interface-role> + <port-group-name>dvspg-IPAG_VCE-slcp1476vbc</port-group-name> + <switch-name>dvs-slcp1-01</switch-name> + <resource-version>0000020</resource-version> + <orchestration-status>created</orchestration-status> + <heat-stack-id>dvspg-IPAG_VCE-slcp1476vbc/1e9c033a-2eef-47f5-9d48-98e0b59538e7</heat-stack-id> + <mso-catalog-key/> + <cvlan-tags> + <cvlan-tag-entry> + <cvlan-tag>2003</cvlan-tag> + <resource-version>0000020</resource-version> + </cvlan-tag-entry> + </cvlan-tags> + </port-group> + </port-groups> + <relationship-list> + <relationship> + <related-to>service-instance</related-to> + <related-link>https://aai-ext1.test.att.com:8443/aai/v2/business/customers/customer/011216-1602-SDNC001/service-subscriptions/service-subscription/SDN-ETHERNET-INTERNET/service-instances/service-instance/SDNC%2FVLXM%2F0112001%2F%2FSW_INTERNET/</related-link> + <relationship-data> + <relationship-key>service-instance.service-instance-id</relationship-key> + <relationship-value>SDNC/VLXM/0112001//SW_INTERNET</relationship-value> + </relationship-data> + <relationship-data> + <relationship-key>service-subscription.service-type</relationship-key> + <relationship-value>SDN-ETHERNET-INTERNET</relationship-value> + </relationship-data> + <relationship-data> + <relationship-key>customer.global-customer-id</relationship-key> + <relationship-value>011216-1602-SDNC001</relationship-value> + </relationship-data> + </relationship> + <relationship> + <related-to>vserver</related-to> + <related-link>https://aai-ext1.test.att.com:8443/aai/servers/v2/3d5f3fe23821416fac2b69af65248c74/vservers/ecab47d5-3450-4507-ada9-2b3c58485c51/</related-link> + <relationship-data> + <relationship-key>vserver.vserver-id</relationship-key> + <relationship-value>ecab47d5-3450-4507-ada9-2b3c58485c51</relationship-value> + </relationship-data> + <relationship-data> + <relationship-key>tenant.tenant-id</relationship-key> + <relationship-value>3d5f3fe23821416fac2b69af65248c74</relationship-value> + </relationship-data> + </relationship> + <relationship> + <related-to>complex</related-to> + <related-link>https://aai-ext1.test.att.com:8443/aai/v2/cloud-infrastructure/complexes/complex/MDTWNJ21A4/</related-link> + <relationship-data> + <relationship-key>complex.physical-location-id</relationship-key> + <relationship-value>MDTWNJ21A4</relationship-value> + </relationship-data> + </relationship> + <relationship> + <related-to>availability-zone</related-to> + <related-link>https://aai-ext1.test.att.com:8443/aai/v2/cloud-infrastructure/availability-zones/availability-zone/slcp1-esx-az01/</related-link> + <relationship-data> + <relationship-key>availability-zone.availability-zone-name</relationship-key> + <relationship-value>slcp1-esx-az01</relationship-value> + </relationship-data> + </relationship> + </relationship-list> + </vce>
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/GenericFlows/getVceResponse.xml b/bpmn/MSOCommonBPMN/src/test/resources/__files/GenericFlows/getVceResponse.xml new file mode 100644 index 0000000000..a83e06ee6f --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/GenericFlows/getVceResponse.xml @@ -0,0 +1,97 @@ +<vce xmlns="http://com.att.aai.inventory"> + <vnf-id>1936628a-d22f-4943-8587-a57bab2ece7a</vnf-id> + <vnf-name>testVnfName123</vnf-name> + <vnf-name2>US0112SLCP1VBRT076</vnf-name2> + <vnf-type>esx-vce</vnf-type> + <prov-status>NVTPROV</prov-status> + <orchestration-status>created</orchestration-status> + <resource-version>0000020</resource-version> + <heat-stack-id>slcp1476vbc/94a3c72b-94d5-444b-9a1f-647a36c2181d</heat-stack-id> + <mso-catalog-key/> + <vpe-id>VPESAT-mtanjrsv126</vpe-id> + <ipv4-oam-address>135.21.249.160</ipv4-oam-address> + <port-groups> + <port-group> + <interface-id>slcp1476vbc.vpe</interface-id> + <neutron-network-id>e7568706-a2a9-45f8-aef8-95a0e2910953</neutron-network-id> + <neutron-network-name>dvspg-VCE_VPE-slcp1476vbc</neutron-network-name> + <interface-role>Internet</interface-role> + <port-group-name>dvspg-VCE_VPE-slcp1476vbc</port-group-name> + <resource-version>0000020</resource-version> + <switch-name>dvs-slcp1-01</switch-name> + <orchestration-status>created</orchestration-status> + <heat-stack-id>dvspg-VCE_VPE-slcp1476vbc/c1299f74-da35-4228-b1e0-d2fd07176196</heat-stack-id> + <mso-catalog-key/> + <cvlan-tags> + <cvlan-tag-entry> + <cvlan-tag>3012</cvlan-tag> + <resource-version>0000020</resource-version> + </cvlan-tag-entry> + </cvlan-tags> + </port-group> + <port-group> + <interface-id>slcp1476vbc.ipag</interface-id> + <neutron-network-id>3477ddb6-b925-4971-ab62-c84b69634c49</neutron-network-id> + <neutron-network-name>dvspg-IPAG_VCE-slcp1476vbc</neutron-network-name> + <interface-role>Customer</interface-role> + <port-group-name>dvspg-IPAG_VCE-slcp1476vbc</port-group-name> + <switch-name>dvs-slcp1-01</switch-name> + <resource-version>0000020</resource-version> + <orchestration-status>created</orchestration-status> + <heat-stack-id>dvspg-IPAG_VCE-slcp1476vbc/1e9c033a-2eef-47f5-9d48-98e0b59538e7</heat-stack-id> + <mso-catalog-key/> + <cvlan-tags> + <cvlan-tag-entry> + <cvlan-tag>2003</cvlan-tag> + <resource-version>0000020</resource-version> + </cvlan-tag-entry> + </cvlan-tags> + </port-group> + </port-groups> + <relationship-list> + <relationship> + <related-to>service-instance</related-to> + <related-link>https://aai-ext1.test.att.com:8443/aai/v2/business/customers/customer/011216-1602-SDNC001/service-subscriptions/service-subscription/SDN-ETHERNET-INTERNET/service-instances/service-instance/SDNC%2FVLXM%2F0112001%2F%2FSW_INTERNET/</related-link> + <relationship-data> + <relationship-key>service-instance.service-instance-id</relationship-key> + <relationship-value>SDNC/VLXM/0112001//SW_INTERNET</relationship-value> + </relationship-data> + <relationship-data> + <relationship-key>service-subscription.service-type</relationship-key> + <relationship-value>SDN-ETHERNET-INTERNET</relationship-value> + </relationship-data> + <relationship-data> + <relationship-key>customer.global-customer-id</relationship-key> + <relationship-value>011216-1602-SDNC001</relationship-value> + </relationship-data> + </relationship> + <relationship> + <related-to>vserver</related-to> + <related-link>https://aai-ext1.test.att.com:8443/aai/servers/v2/3d5f3fe23821416fac2b69af65248c74/vservers/ecab47d5-3450-4507-ada9-2b3c58485c51/</related-link> + <relationship-data> + <relationship-key>vserver.vserver-id</relationship-key> + <relationship-value>ecab47d5-3450-4507-ada9-2b3c58485c51</relationship-value> + </relationship-data> + <relationship-data> + <relationship-key>tenant.tenant-id</relationship-key> + <relationship-value>3d5f3fe23821416fac2b69af65248c74</relationship-value> + </relationship-data> + </relationship> + <relationship> + <related-to>complex</related-to> + <related-link>https://aai-ext1.test.att.com:8443/aai/v2/cloud-infrastructure/complexes/complex/MDTWNJ21A4/</related-link> + <relationship-data> + <relationship-key>complex.physical-location-id</relationship-key> + <relationship-value>MDTWNJ21A4</relationship-value> + </relationship-data> + </relationship> + <relationship> + <related-to>availability-zone</related-to> + <related-link>https://aai-ext1.test.att.com:8443/aai/v2/cloud-infrastructure/availability-zones/availability-zone/slcp1-esx-az01/</related-link> + <relationship-data> + <relationship-key>availability-zone.availability-zone-name</relationship-key> + <relationship-value>slcp1-esx-az01</relationship-value> + </relationship-data> + </relationship> + </relationship-list> + </vce>
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/GenericPutServiceInstance/GenericPutServiceInstance_PutServiceInstance_AAIResponse_Success.xml b/bpmn/MSOCommonBPMN/src/test/resources/__files/GenericPutServiceInstance/GenericPutServiceInstance_PutServiceInstance_AAIResponse_Success.xml new file mode 100644 index 0000000000..eedbda9343 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/GenericPutServiceInstance/GenericPutServiceInstance_PutServiceInstance_AAIResponse_Success.xml @@ -0,0 +1,11 @@ +<rest:RESTResponse xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd" + statusCode="200"> + <rest:headers> + <rest:header name="Date" value="Thu,10 Mar 2016 00:01:18 GMT"/> + <rest:header name="Content-Length" value="0"/> + <rest:header name="Expires" value="Thu,01 Jan 1970 00:00:00 UTC"/> + <rest:header name="X-AAI-TXID" value="mtcnjv9aaas03-20160310-00:01:18:551-132672"/> + <rest:header name="Server" value="Apache-Coyote/1.1"/> + <rest:header name="Cache-Control" value="private"/> + </rest:headers> +</rest:RESTResponse>
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/GenericPutServiceInstance/aaiFault.xml b/bpmn/MSOCommonBPMN/src/test/resources/__files/GenericPutServiceInstance/aaiFault.xml new file mode 100644 index 0000000000..66ed8f5758 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/GenericPutServiceInstance/aaiFault.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<Fault> +<requestError> +<serviceException> +<messageId>SVC3002</messageId> +<text>Error writing output performing %1 on %2 (msg=%3) (ec=%4)</text> +<variables> +<variable>PUTcustomer</variable> +<variable>SubName01</variable> +<variable>Unexpected error reading/updating database:Adding this property for key [service-instance-id] and value [USSTU2CFCNC0101UJZZ01] violates a uniqueness constraint [service-instance-id]</variable> +<variable>ERR.5.4.5105</variable> +</variables> +</serviceException> +</requestError> +</Fault>
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/SDN-ETHERNET-INTERNET/SDNCAdapterV1/sdncadapterworkflowrequest.xml b/bpmn/MSOCommonBPMN/src/test/resources/__files/SDN-ETHERNET-INTERNET/SDNCAdapterV1/sdncadapterworkflowrequest.xml new file mode 100644 index 0000000000..f71f529593 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/SDN-ETHERNET-INTERNET/SDNCAdapterV1/sdncadapterworkflowrequest.xml @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="UTF-8"?> +<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" + xmlns:v1="http://org.openecomp/mso/workflow/schema/v1" + xmlns:v11="http://org.openecomp/workflow/sdnc/adapter/schema/v1"> + <soapenv:Header/> + <soapenv:Body> + <v1:SDNCAdapterWorkflowRequest> + <v11:RequestHeader> + <v11:RequestId>745b1b50-e39e-4685-9cc8-c71f0bde8bf0</v11:RequestId> + <v11:SvcAction>query</v11:SvcAction> + <v11:SvcOperation>services/layer3-service-list/AS%2FVLXM%2F000199%2F%2FSB_INTERNET</v11:SvcOperation> + <v11:CallbackUrl>http://127.0.0.1:28080/camunda/services/SDNCAdapterCallback</v11:CallbackUrl> + </v11:RequestHeader> + <v1:SDNCRequestData> + <rest:payload xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd" contentType="text/xml"> + <tag0:service-request xmlns:tag0="http://org.openecomp/mso/request/details/schema/v1"> + <tag0:request-information> + <tag0:request-id>12570a36-7388-4c0a-bec4-189ce3kg9956</tag0:request-id> + <tag0:request-action>GetLayer3ServiceDetailsRequest</tag0:request-action> + <tag0:source>OMX</tag0:source> + </tag0:request-information> + <tag0:service-information> + <tag0:service-type>SDN-ETHERNET-INTERNET</tag0:service-type> + <tag0:service-instance-id>PD/VLXM/003717//SW_INTERNET</tag0:service-instance-id> + </tag0:service-information> + </tag0:service-request> + </rest:payload> + </v1:SDNCRequestData> + <v1:SDNCTimeOutValueInMinutes>1</v1:SDNCTimeOutValueInMinutes> + </v1:SDNCAdapterWorkflowRequest> + </soapenv:Body> +</soapenv:Envelope> diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/SDN-ETHERNET-INTERNET/SDNCAdapterV1mock/sdncadaptercallbackrequest.xml b/bpmn/MSOCommonBPMN/src/test/resources/__files/SDN-ETHERNET-INTERNET/SDNCAdapterV1mock/sdncadaptercallbackrequest.xml new file mode 100644 index 0000000000..b72004778b --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/SDN-ETHERNET-INTERNET/SDNCAdapterV1mock/sdncadaptercallbackrequest.xml @@ -0,0 +1,350 @@ +<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" + xmlns:v1="http://org.openecomp/workflow/sdnc/adapter/schema/v1"> + <soapenv:Header /> + <soapenv:Body> + <v1:SDNCAdapterCallback> +<SDNCAdapterCallbackRequest xmlns="http://org.openecomp/workflow/sdnc/adapter/schema/v1"> + <CallbackHeader> + <RequestId>testRequestId</RequestId> + <ResponseCode>200</ResponseCode> + <ResponseMessage>OK</ResponseMessage> + </CallbackHeader> + <RequestData xsi:type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <layer3-service-list xmlns="com:att:sdnctl:l3api"> + <service-instance-id>FK/VLXM/003717//SW_INTERNET</service-instance-id> + <service-status> + <rpc-name>service-configuration-operation</rpc-name> + <rpc-action>activate</rpc-action> + <request-status>synccomplete</request-status> + <final-indicator>N</final-indicator> + <l3sdn-action>Layer3ServiceActivateRequest</l3sdn-action> + <l3sdn-subaction>SUPP</l3sdn-subaction> + <response-timestamp>2015-04-28T21:32:11.386Z</response-timestamp> + </service-status> + <service-data> + <internet-evc-access-information> + <ip-version>ds</ip-version> + <internet-evc-speed-value>8</internet-evc-speed-value> + <internet-evc-speed-units>Mbps</internet-evc-speed-units> + </internet-evc-access-information> + <vr-lan xmlns="com:att:sdnctl:l3api"> + <vr-lan-interface> + <static-routes> + <v6-static-routes> + <v6-next-hop-address>2001:1890:12e3:2da::</v6-next-hop-address> + <v6-static-route-prefix>2001:1890:12e3:2da::</v6-static-route-prefix> + <v6-static-route-prefix-length>28</v6-static-route-prefix-length> + </v6-static-routes> + <v4-static-routes> + <v4-static-route-prefix>255.255.252.1</v4-static-route-prefix> + <v4-next-hop-address>192.168.1.15</v4-next-hop-address> + <v4-static-route-prefix-length>28</v4-static-route-prefix-length> + </v4-static-routes> + <v6-static-routes> + <v6-next-hop-address>2001:1890:12e3:2da::</v6-next-hop-address> + <v6-static-route-prefix>2001:1890:12e3:2da::</v6-static-route-prefix> + <v6-static-route-prefix-length>28</v6-static-route-prefix-length> + </v6-static-routes> + <v4-static-routes> + <v4-static-route-prefix>255.255.252.2</v4-static-route-prefix> + <v4-next-hop-address>192.168.1.15</v4-next-hop-address> + <v4-static-route-prefix-length>28</v4-static-route-prefix-length> + </v4-static-routes> + <v4-static-routes> + <v4-static-route-prefix>255.255.252.3</v4-static-route-prefix> + <v4-next-hop-address>192.168.1.15</v4-next-hop-address> + <v4-static-route-prefix-length>28</v4-static-route-prefix-length> + </v4-static-routes> + </static-routes> + <dhcp> + <v6-dhcp-server-enabled>N</v6-dhcp-server-enabled> + <v4-dhcp-server-enabled>Y</v4-dhcp-server-enabled> + <use-v6-default-pool>N</use-v6-default-pool> + <excluded-v4-dhcp-addresses-from-default-pool> + <excluded-v4-address>192.168.1.7</excluded-v4-address> + </excluded-v4-dhcp-addresses-from-default-pool> + <excluded-v4-dhcp-addresses-from-default-pool> + <excluded-v4-address>192.168.1.8</excluded-v4-address> + </excluded-v4-dhcp-addresses-from-default-pool> + <v4-dhcp-pools> + <v4-dhcp-relay-next-hop-address>1.1.1.1</v4-dhcp-relay-next-hop-address> + <v4-dhcp-pool-prefix-length>28</v4-dhcp-pool-prefix-length> + <excluded-v4-addresses> + <excluded-v4-address>192.168.1.5</excluded-v4-address> + </excluded-v4-addresses> + <v4-dhcp-relay-gateway-address>2.2.2.1</v4-dhcp-relay-gateway-address> + <excluded-v4-addresses> + <excluded-v4-address>192.168.1.6</excluded-v4-address> + </excluded-v4-addresses> + <v4-dhcp-pool-prefix>192.155.2.3</v4-dhcp-pool-prefix> + </v4-dhcp-pools> + <v4-dhcp-pools> + <v4-dhcp-relay-next-hop-address>1.1.1.2</v4-dhcp-relay-next-hop-address> + <v4-dhcp-pool-prefix-length>28</v4-dhcp-pool-prefix-length> + <excluded-v4-addresses> + <excluded-v4-address>192.168.1.6</excluded-v4-address> + </excluded-v4-addresses> + <v4-dhcp-relay-gateway-address>2.2.2.2</v4-dhcp-relay-gateway-address> + <excluded-v4-addresses> + <excluded-v4-address>192.168.1.7</excluded-v4-address> + </excluded-v4-addresses> + <v4-dhcp-pool-prefix>192.155.2.4</v4-dhcp-pool-prefix> + </v4-dhcp-pools> + <use-v4-default-pool>Y</use-v4-default-pool> + <excluded-v6-dhcp-addresses-from-default-pool> + <excluded-v6-address>1:5</excluded-v6-address> + </excluded-v6-dhcp-addresses-from-default-pool> + <excluded-v6-dhcp-addresses-from-default-pool> + <excluded-v6-address>1:6</excluded-v6-address> + </excluded-v6-dhcp-addresses-from-default-pool> + <v6-dhcp-pools> + <v6-dhcp-relay-next-hop-address>4:4</v6-dhcp-relay-next-hop-address> + <v6-dhcp-pool-prefix-length>28</v6-dhcp-pool-prefix-length> + <excluded-v6-addresses> + <excluded-v6-address>1:1</excluded-v6-address> + </excluded-v6-addresses> + <v6-dhcp-relay-gateway-address>3:3</v6-dhcp-relay-gateway-address> + <excluded-v6-addresses> + <excluded-v6-address>2:2</excluded-v6-address> + </excluded-v6-addresses> + <v6-dhcp-pool-prefix>0:0</v6-dhcp-pool-prefix> + </v6-dhcp-pools> + <v6-dhcp-pools> + <v6-dhcp-relay-next-hop-address>4:4</v6-dhcp-relay-next-hop-address> + <v6-dhcp-pool-prefix-length>28</v6-dhcp-pool-prefix-length> + <excluded-v6-addresses> + <excluded-v6-address>1:1</excluded-v6-address> + </excluded-v6-addresses> + <v6-dhcp-relay-gateway-address>3:3</v6-dhcp-relay-gateway-address> + <excluded-v6-addresses> + <excluded-v6-address>2:2</excluded-v6-address> + </excluded-v6-addresses> + <v6-dhcp-pool-prefix>0:0</v6-dhcp-pool-prefix> + </v6-dhcp-pools> + </dhcp> + <firewall-lite> + <stateful-firewall-lite-v6-enabled>N</stateful-firewall-lite-v6-enabled> + <stateful-firewall-lite-v4-enabled>Y</stateful-firewall-lite-v4-enabled> + <v4-firewall-packet-filters> + <v4-firewall-prefix>0.0.0.1</v4-firewall-prefix> + <v4-firewall-prefix-length>1</v4-firewall-prefix-length> + <allow-icmp-ping>Y</allow-icmp-ping> + <udp-ports> + <port-number>1</port-number> + </udp-ports> + <tcp-ports> + <port-number>1</port-number> + </tcp-ports> + </v4-firewall-packet-filters> + <v4-firewall-packet-filters> + <v4-firewall-prefix>0.0.0.2</v4-firewall-prefix> + <v4-firewall-prefix-length>2</v4-firewall-prefix-length> + <allow-icmp-ping>Y</allow-icmp-ping> + <udp-ports> + <port-number>2</port-number> + </udp-ports> + <tcp-ports> + <port-number>2</port-number> + </tcp-ports> + </v4-firewall-packet-filters> + <v6-firewall-packet-filters> + <v6-firewall-prefix>:</v6-firewall-prefix> + <v6-firewall-prefix-length>0</v6-firewall-prefix-length> + <allow-icmp-ping>Y</allow-icmp-ping> + <udp-ports> + <port-number>3</port-number> + </udp-ports> + <tcp-ports> + <port-number>3</port-number> + </tcp-ports> + </v6-firewall-packet-filters> + <v6-firewall-packet-filters> + <v6-firewall-prefix>:</v6-firewall-prefix> + <v6-firewall-prefix-length>1</v6-firewall-prefix-length> + <allow-icmp-ping>Y</allow-icmp-ping> + <udp-ports> + <port-number>4</port-number> + </udp-ports> + <tcp-ports> + <port-number>4</port-number> + </tcp-ports> + </v6-firewall-packet-filters> + </firewall-lite> + <pat> + <v4-pat-pools> + <v4-pat-pool-prefix>192.168.1.44</v4-pat-pool-prefix> + <v4-pat-pool-next-hop-address>192.168.1.5</v4-pat-pool-next-hop-address> + <v4-pat-pool-prefix-length>0</v4-pat-pool-prefix-length> + </v4-pat-pools> + <use-v4-default-pool>Y</use-v4-default-pool> + <v4-pat-enabled>N</v4-pat-enabled> + <v4-pat-pools> + <v4-pat-pool-prefix>192.168.1.45</v4-pat-pool-prefix> + <v4-pat-pool-next-hop-address>192.168.1.6</v4-pat-pool-next-hop-address> + <v4-pat-pool-prefix-length>28</v4-pat-pool-prefix-length> + </v4-pat-pools> + </pat> + <nat> + <v4-nat-enabled>Y</v4-nat-enabled> + <v4-nat-mapping-entries> + <v4-nat-internal>0.0.0.0</v4-nat-internal> + <v4-nat-next-hop-address>0.0.0.0</v4-nat-next-hop-address> + <v4-nat-external>0.0.0.0</v4-nat-external> + </v4-nat-mapping-entries> + <v4-nat-mapping-entries> + <v4-nat-internal>0.0.0.1</v4-nat-internal> + <v4-nat-next-hop-address>0.0.0.1</v4-nat-next-hop-address> + <v4-nat-external>0.0.0.1</v4-nat-external> + </v4-nat-mapping-entries> + </nat> + <vr-designation>primary</vr-designation> + <v4-vce-loopback-address>162.200.3.144</v4-vce-loopback-address> + <v6-vr-lan-prefix-length>64</v6-vr-lan-prefix-length> + <v6-vce-wan-address>2001:1890:12e3:2da::</v6-vce-wan-address> + <v6-vr-lan-prefix>2620:0:10d0:f:ffff:ffff:ffff:fffe</v6-vr-lan-prefix> + <v4-vr-lan-prefix-length>24</v4-vr-lan-prefix-length> + <v4-vr-lan-prefix>10.192.27.254</v4-vr-lan-prefix> + <v4-public-lan-prefixes> + <t-provided-v4-lan-public-prefixes> + <request-index>1</request-index> + <v4-next-hop-address>192.168.1.2</v4-next-hop-address> + <v4-lan-public-prefix>192.168.1.1</v4-lan-public-prefix> + <v4-lan-public-prefix-length>28</v4-lan-public-prefix-length> + </t-provided-v4-lan-public-prefixes> + <t-provided-v4-lan-public-prefixes> + <request-index>1</request-index> + <v4-next-hop-address>192.168.1.72</v4-next-hop-address> + <v4-lan-public-prefix>192.168.1.71</v4-lan-public-prefix> + <v4-lan-public-prefix-length>28</v4-lan-public-prefix-length> + </t-provided-v4-lan-public-prefixes> + <t-provided-v4-lan-public-prefixes> + <request-index>1</request-index> + <v4-next-hop-address>192.168.1.68</v4-next-hop-address> + <v4-lan-public-prefix>192.168.1.67</v4-lan-public-prefix> + <v4-lan-public-prefix-length>28</v4-lan-public-prefix-length> + </t-provided-v4-lan-public-prefixes> + </v4-public-lan-prefixes> + <v6-public-lan-prefixes> + <t-provided-v6-lan-public-prefixes> + <request-index>1</request-index> + <v6-next-hop-address>2001:1890:12e3:2da::</v6-next-hop-address> + <v6-lan-public-prefix>2001:1890:12e3:2da::</v6-lan-public-prefix> + <v6-lan-public-prefix-length>28</v6-lan-public-prefix-length> + </t-provided-v6-lan-public-prefixes> + <t-provided-v6-lan-public-prefixes> + <request-index>1</request-index> + <v6-next-hop-address>2001:1890:12e3:2da::</v6-next-hop-address> + <v6-lan-public-prefix>2001:1890:12e3:3da::</v6-lan-public-prefix> + <v6-lan-public-prefix-length>28</v6-lan-public-prefix-length> + </t-provided-v6-lan-public-prefixes> + <t-provided-v6-lan-public-prefixes> + <request-index>1</request-index> + <v6-next-hop-address>2001:1890:12e3:2da::</v6-next-hop-address> + <v6-lan-public-prefix>2001:1890:12e3:4da::</v6-lan-public-prefix> + <v6-lan-public-prefix-length>28</v6-lan-public-prefix-length> + </t-provided-v6-lan-public-prefixes> + </v6-public-lan-prefixes> + </vr-lan-interface> + <routing-protocol>none</routing-protocol> + </vr-lan> +<ucpe-vms-service-information> + <transport-service-information> + <transport-service-type>AVPN</transport-service-type> + <access-circuit-info> + <access-circuit-id>1</access-circuit-id> + <dual-mode>Active</dual-mode> + </access-circuit-info> + <access-circuit-info> + <access-circuit-id>2</access-circuit-id> + <dual-mode>Standby</dual-mode> + </access-circuit-info> + </transport-service-information> + <ucpe-information> + <ucpe-host-name>hostname</ucpe-host-name> + <ucpe-activation-code>activecode</ucpe-activation-code> + <out-of-band-management-modem>OOB</out-of-band-management-modem> + </ucpe-information> + <vnf-list> + <vnf-information> + <vnf-instance-id>1</vnf-instance-id> + <vnf-sequence-number>1</vnf-sequence-number> + <vnf-type>ZZ</vnf-type> + <vnf-vendor>JUNIPER</vnf-vendor> + <vnf-model>MODEL1</vnf-model> + <vnf-id>1</vnf-id> + <prov-status>1</prov-status> + <operational-state>1</operational-state> + <orchestration-status>1</orchestration-status> + <equipment-role>1</equipment-role> + </vnf-information> + <vnf-information> + <vnf-instance-id>2</vnf-instance-id> + <vnf-sequence-number>2</vnf-sequence-number> + <vnf-type>HY</vnf-type> + <vnf-vendor>JUNIPER</vnf-vendor> + <vnf-model>MODEL2</vnf-model> + <vnf-id>2</vnf-id> + <prov-status>2</prov-status> + <operational-state>2</operational-state> + <orchestration-status>2</orchestration-status> + <equipment-role>2</equipment-role> + </vnf-information> + </vnf-list> + </ucpe-vms-service-information> + <request-information> + <request-action>Layer3ServiceActivateRequest</request-action> + <order-number>4281555</order-number> + <request-id>155415ab-b4a7-4382-b4c6-d17d9sm42855</request-id> + <notification-url>https://csi-tst-q22.it.att.com:22443/Services/com/cingular/csi/sdn/SendManagedNetworkStatusNotification.jws</notification-url> + <source>OMX</source> + <order-version>1</order-version> + </request-information> + <sdnc-request-header> + <svc-action>activate</svc-action> + <svc-notification-url>https://msojra.mtsnjdcp1.aic.cip.att.com:8443/adapters/rest/SDNCNotify</svc-notification-url> + <svc-request-id>5b1f3c5d-cdf9-488d-8a4b-d3f1229d7760</svc-request-id> + </sdnc-request-header> + <l2-homing-information> + <topology>MultiPoint</topology> + <preferred-aic-clli>MTSNJA4LCP1</preferred-aic-clli> + <evc-name>AS/VLXM/003717//SW</evc-name> + </l2-homing-information> + <service-information> + <service-instance-id>FK/VLXM/003717//SW_INTERNET</service-instance-id> + <subscriber-name>ST E2E Test42855_1300004281555</subscriber-name> + <service-type>SDN-ETHERNET-INTERNET</service-type> + </service-information> + <internet-service-change-details> + <internet-evc-speed-value>10</internet-evc-speed-value> + <internet-evc-speed-units>Kbps</internet-evc-speed-units> + <t-provided-v4-lan-public-prefixes> + <request-index>1</request-index> + <v4-next-hop-address>192.168.1.15</v4-next-hop-address> + <v4-lan-public-prefix>192.168.1.15</v4-lan-public-prefix> + <v4-lan-public-prefix-length>28</v4-lan-public-prefix-length> + </t-provided-v4-lan-public-prefixes> + <t-provided-v4-lan-public-prefixes> + <request-index>2</request-index> + <v4-next-hop-address>192.168.1.16</v4-next-hop-address> + <v4-lan-public-prefix>192.168.1.16</v4-lan-public-prefix> + <v4-lan-public-prefix-length>28</v4-lan-public-prefix-length> + </t-provided-v4-lan-public-prefixes> + <t-provided-v6-lan-public-prefixes> + <request-index>1</request-index> + <v6-next-hop-address>2001:1890:12e3:2da::</v6-next-hop-address> + <v6-lan-public-prefix>2001:1890:12e3:2da::</v6-lan-public-prefix> + <v6-lan-public-prefix-length>28</v6-lan-public-prefix-length> + </t-provided-v6-lan-public-prefixes> + <t-provided-v6-lan-public-prefixes> + <request-index>1</request-index> + <v6-next-hop-address>2001:1890:12e3:2da::</v6-next-hop-address> + <v6-lan-public-prefix>2001:1890:12e3:2da::</v6-lan-public-prefix> + <v6-lan-public-prefix-length>28</v6-lan-public-prefix-length> + </t-provided-v6-lan-public-prefixes> + </internet-service-change-details> + </service-data> + </layer3-service-list> +</RequestData> +</SDNCAdapterCallbackRequest> +</v1:SDNCAdapterCallback> +</soapenv:Body> +</soapenv:Envelope>
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/UpdateNetworkV2/updateNetworkResponse_400.xml b/bpmn/MSOCommonBPMN/src/test/resources/__files/UpdateNetworkV2/updateNetworkResponse_400.xml new file mode 100644 index 0000000000..a5640b2b26 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/UpdateNetworkV2/updateNetworkResponse_400.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<createNetworkError> +<messageId>680bd458-5ec1-4a16-b77c-509022e53450</messageId><category>INTERNAL</category> +<message>400 Bad Request: The server could not comply with the request since it is either malformed or otherwise incorrect., error.type=StackValidationFailed, error.message=Property error: : resources.network.properties: : Unknown Property network_ipam_refs_data</message> +<rolledBack>true</rolledBack> +</createNetworkError> diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/UpdateNetworkV2/updateNetworkResponse_500.xml b/bpmn/MSOCommonBPMN/src/test/resources/__files/UpdateNetworkV2/updateNetworkResponse_500.xml new file mode 100644 index 0000000000..c67e980c63 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/UpdateNetworkV2/updateNetworkResponse_500.xml @@ -0,0 +1,78 @@ +<html> + <head> + <title>JBoss Web/7.2.2.Final-redhat-1 - JBWEB000064: Error report + </title> + <style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} + H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} + H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} + BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} + B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} + P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A + {color : black;}A.name {color : black;}HR {color : #525D76;} --> + </style> + </head> + <body> + <h1>JBWEB000065: HTTP Status 500 - java.lang.NullPointerException</h1> + <HR size="1" noshade="noshade"> + <p> + <b>JBWEB000309: type</b> + JBWEB000066: Exception report + </p> + <p> + <b>JBWEB000068: message</b> + <u>java.lang.NullPointerException</u> + </p> + <p> + <b>JBWEB000069: description</b> + <u>JBWEB000145: The server encountered an internal error that + prevented it from fulfilling this request.</u> + </p> + <p> + <b>JBWEB000070: exception</b> + <pre>org.jboss.resteasy.spi.UnhandledException: + java.lang.NullPointerException + org.jboss.resteasy.core.SynchronousDispatcher.handleApplicationException(SynchronousDispatcher.java:365) + org.jboss.resteasy.core.SynchronousDispatcher.handleException(SynchronousDispatcher.java:233) + org.jboss.resteasy.core.SynchronousDispatcher.handleInvokerException(SynchronousDispatcher.java:209) + org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:557) + org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:524) + org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:126) + org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:208) + org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55) + org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50) + javax.servlet.http.HttpServlet.service(HttpServlet.java:847) + org.openecomp.mso.logger.LogFilter.doFilter(LogFilter.java:35) + </pre> + </p> + <p> + <b>JBWEB000071: root cause</b> + <pre>java.lang.NullPointerException + org.openecomp.mso.adapters.network.NetworkAdapterRest$CreateNetworkVolumesTask.run(NetworkAdapterRest.java:128) + org.openecomp.mso.adapters.network.NetworkAdapterRest.createNetwork(NetworkAdapterRest.java:64) + sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) + sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + java.lang.reflect.Method.invoke(Method.java:606) + org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:167) + org.jboss.resteasy.core.ResourceMethod.invokeOnTarget(ResourceMethod.java:269) + org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:227) + org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:216) + org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:542) + org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:524) + org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:126) + org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:208) + org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55) + org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50) + javax.servlet.http.HttpServlet.service(HttpServlet.java:847) + org.openecomp.mso.logger.LogFilter.doFilter(LogFilter.java:35) + </pre> + </p> + <p> + <b>JBWEB000072: note</b> + <u>JBWEB000073: The full stack trace of the root cause is available + in the JBoss Web/7.2.2.Final-redhat-1 logs.</u> + </p> + <HR size="1" noshade="noshade"> + <h3>JBoss Web/7.2.2.Final-redhat-1</h3> + </body> +</html>
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/UpdateNetworkV2/updateNetworkResponse_Success.xml b/bpmn/MSOCommonBPMN/src/test/resources/__files/UpdateNetworkV2/updateNetworkResponse_Success.xml new file mode 100644 index 0000000000..7a00744103 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/UpdateNetworkV2/updateNetworkResponse_Success.xml @@ -0,0 +1,24 @@ +<ns2:updateNetworkContrailResponse xmlns:ns2="http://org.openecomp.mso/network" + xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> + <networkId>MNS-25180-L-01-dmz_direct_net_1/2c88a3a9-69b9-43a7-ada6-1aca577c3641</networkId> + <neutronNetworkId>c4f4e878-cde0-4b15-ae9a-bda857759cea</neutronNetworkId> + <subnetIdMap> + <entry> + <key>57e9a1ff-d14f-4071-a828-b19ae98eb2fc</key> + <value>bd8e87c6-f4e2-41b8-b0bc-9596aa00cd73</value> + </entry> + </subnetIdMap> + <rollback> + <cloudId>RDM2WAGPLCP</cloudId> + <msoRequest> + <requestId>1ef47428-cade-45bd-a103-0751e8b2deb0</requestId> + <serviceInstanceId/> + </msoRequest> + <networkCreated>true</networkCreated> + <networkId>MNS-25180-L-01-dmz_direct_net_1/2c88a3a9-69b9-43a7-ada6-1aca577c3641</networkId> + <networkType>CONTRAIL_EXTERNAL</networkType> + <networkUpdated>false</networkUpdated> + <neutronNetworkId>c4f4e878-cde0-4b15-ae9a-bda857759cea</neutronNetworkId> + <tenantId>7dd5365547234ee8937416c65507d266</tenantId> + </rollback> +</ns2:updateNetworkContrailResponse> diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/UpdateNetworkV2/updateNetwork_queryInstance_Success.xml b/bpmn/MSOCommonBPMN/src/test/resources/__files/UpdateNetworkV2/updateNetwork_queryInstance_Success.xml new file mode 100644 index 0000000000..a7ac309507 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/UpdateNetworkV2/updateNetwork_queryInstance_Success.xml @@ -0,0 +1,4 @@ +<result-data> + <resource-type>service-instance</resource-type> + <resource-link>https://aai-conexus-e2e.test.att.com:8443/aai/v8/business/customers/customer/8310000058863/service-subscriptions/service-subscription/vMOG/service-instances/service-instance/f70e927b-6087-4974-9ef8-c5e4d5847ca4</resource-link> +</result-data>
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/UpdateNetworkV2/updateNetwork_queryNetworkId_AAIResponse_NoPayload_Success.xml b/bpmn/MSOCommonBPMN/src/test/resources/__files/UpdateNetworkV2/updateNetwork_queryNetworkId_AAIResponse_NoPayload_Success.xml new file mode 100644 index 0000000000..d8d10db65e --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/UpdateNetworkV2/updateNetwork_queryNetworkId_AAIResponse_NoPayload_Success.xml @@ -0,0 +1,73 @@ +<?xml version="1.0" encoding="UTF-8"?> +<l3-network xmlns="http://com.att.aai.inventory/v8"> + <network-id>49c86598-f766-46f8-84f8-8d1c1b10f9b4</network-id> + <network-name>MNS-25180-L-01-dmz_direct_net_1</network-name> + <network-type>CONTRAIL_EXTERNAL</network-type> + <network-role>dmz_direct</network-role> + <network-technology>contrail</network-technology> + <service-id>a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb</service-id> + <network-role-instance>0</network-role-instance> + <orchestration-status>pending-create</orchestration-status> + <physical-network-name>networkName</physical-network-name> + <is-provider-network>false</is-provider-network> + <is-shared-network>true</is-shared-network> + <is-external-network>false</is-external-network> + <subnets> + <subnet> + <subnet-id>57e9a1ff-d14f-4071-a828-b19ae98eb2fc</subnet-id> + <gateway-address>107.239.52.1</gateway-address> + <network-start-address>107.239.52.0</network-start-address> + <cidr-mask>24</cidr-mask> + <ip-version>4</ip-version> + <orchestration-status>pending-create</orchestration-status> + <dhcp-enabled>true</dhcp-enabled> + <subnet-name>subnetName</subnet-name> + <relationship-list/> + </subnet> + </subnets> + <segmentation-assignments> + <segmentation-id>413</segmentation-id> + <resource-version>4132176</resource-version> + </segmentation-assignments> + <relationship-list> + <relationship> + <related-to>vpn-binding</related-to> + <related-link>https://aai-app-e2e.test.att.com:8443/aai/v8/network/vpn-bindings/vpn-binding/85f015d0-2e32-4c30-96d2-87a1a27f8017/</related-link> + <relationship-data> + <relationship-key>vpn-binding.vpn-id</relationship-key> + <relationship-value>85f015d0-2e32-4c30-96d2-87a1a27f8017</relationship-value> + </relationship-data> + </relationship> + <relationship> + <related-to>vpn-binding</related-to> + <related-link>https://aai-app-e2e.test.att.com:8443/aai/v8/network/vpn-bindings/vpn-binding/c980a6ef-3b88-49f0-9751-dbad8608d0a6/</related-link> + <relationship-data> + <relationship-key>vpn-binding.vpn-id</relationship-key> + <relationship-value>c980a6ef-3b88-49f0-9751-dbad8608d0a6</relationship-value> + </relationship-data> + </relationship> + <relationship> + <related-to>tenant</related-to> + <related-link>https://aai-app-e2e.test.att.com:8443/aai/v8/cloud-infrastructure/tenants/tenant/7dd5365547234ee8937416c65507d266/</related-link> + <relationship-data> + <relationship-key>tenant.tenant-id</relationship-key> + <relationship-value>7dd5365547234ee8937416c65507d266</relationship-value> + </relationship-data> + </relationship> + <relationship> + <related-to>network-policy</related-to> + <related-link>https://aai-app-e2e.test.att.com:8443/aai/v8/network/network-policies/network-policy/cee6d136-e378-4678-a024-2cd15f0ee0cg</related-link> + <relationship-data> + <relationship-key>network-policy.network-policy-id</relationship-key> + <relationship-value>cee6d136-e378-4678-a024-2cd15f0ee0cg</relationship-value> + </relationship-data> + </relationship> + <relationship> + <related-to>route-table-reference</related-to> + <relationship-data> + <relationship-key>route-table-reference.route-table-reference-id</relationship-key> + <relationship-value>cee6d136-e378-4678-a024-2cd15f0ee0hi</relationship-value> + </relationship-data> + </relationship> + </relationship-list> +</l3-network> diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/UpdateNetworkV2/updateNetwork_queryNetworkTableRef1_AAIResponse_Success.xml b/bpmn/MSOCommonBPMN/src/test/resources/__files/UpdateNetworkV2/updateNetwork_queryNetworkTableRef1_AAIResponse_Success.xml new file mode 100644 index 0000000000..292b5e8420 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/UpdateNetworkV2/updateNetwork_queryNetworkTableRef1_AAIResponse_Success.xml @@ -0,0 +1,20 @@ +<rest:RESTResponse xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd" + statusCode="200"> + <rest:headers> + <rest:header name="Transfer-Encoding" value="chunked"/> + <rest:header name="Date" value="Mon,14 Mar 2016 20:53:33 GMT"/> + <rest:header name="Expires" value="Thu,01 Jan 1970 00:00:00 UTC"/> + <rest:header name="X-AAI-TXID" + value="mtcnjv9aaas01.mtcnj.aic.cip.att.com-20160314-20:53:33:487-134392"/> + <rest:header name="Content-Type" value="application/xml"/> + <rest:header name="Server" value="Apache-Coyote/1.1"/> + <rest:header name="Cache-Control" value="private"/> + </rest:headers> + <rest:payload contentType="text/xml"> + <route-table-references xmlns="http://com.att.aai.inventory/v8"> + <route-table-reference-id>5938baec-03ca-2bd5-a3f1-d54x123e253a</route-table-reference-id> + <route-table-reference-fqdn>refFQDN1</route-table-reference-fqdn> + <resource-version>12345</resource-version> + </route-table-references> + </rest:payload> +</rest:RESTResponse>
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/UpdateNetworkV2/updateNetwork_queryNetworkTableRef2_AAIResponse_Success.xml b/bpmn/MSOCommonBPMN/src/test/resources/__files/UpdateNetworkV2/updateNetwork_queryNetworkTableRef2_AAIResponse_Success.xml new file mode 100644 index 0000000000..910f7014e4 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/UpdateNetworkV2/updateNetwork_queryNetworkTableRef2_AAIResponse_Success.xml @@ -0,0 +1,20 @@ +<rest:RESTResponse xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd" + statusCode="200"> + <rest:headers> + <rest:header name="Transfer-Encoding" value="chunked"/> + <rest:header name="Date" value="Mon,14 Mar 2016 20:53:33 GMT"/> + <rest:header name="Expires" value="Thu,01 Jan 1970 00:00:00 UTC"/> + <rest:header name="X-AAI-TXID" + value="mtcnjv9aaas01.mtcnj.aic.cip.att.com-20160314-20:53:33:487-134392"/> + <rest:header name="Content-Type" value="application/xml"/> + <rest:header name="Server" value="Apache-Coyote/1.1"/> + <rest:header name="Cache-Control" value="private"/> + </rest:headers> + <rest:payload contentType="text/xml"> + <route-table-references xmlns="http://com.att.aai.inventory/v8"> + <route-table-reference-id>5938baec-03ca-2bd5-a3f1-d54x123e253a</route-table-reference-id> + <route-table-reference-fqdn>refFQDN2</route-table-reference-fqdn> + <resource-version>12345</resource-version> + </route-table-references> + </rest:payload> +</rest:RESTResponse>
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/UpdateNetworkV2mock/sdncUpdateNetworkTopologySim500Response.xml b/bpmn/MSOCommonBPMN/src/test/resources/__files/UpdateNetworkV2mock/sdncUpdateNetworkTopologySim500Response.xml new file mode 100644 index 0000000000..2cf94b2ef2 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/UpdateNetworkV2mock/sdncUpdateNetworkTopologySim500Response.xml @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" + xmlns:v1="http://org.openecomp/workflow/sdnc/adapter/schema/v1"> + <soapenv:Header /> + <soapenv:Body> + <v1:SDNCAdapterCallback> + <SDNCAdapterCallbackRequest xmlns="http://org.openecomp/workflow/sdnc/adapter/schema/v1"> + <CallbackHeader> + <RequestId>testRequestId</RequestId> + <ResponseCode>200</ResponseCode> + <ResponseMessage>OK</ResponseMessage> + </CallbackHeader> + <RequestData xsi:type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><output + xmlns="com:att:sdnctl:vnf"><response-code>500</response-code><response-message>'Error + retrieving l3-network with network-id=' + + $network-topology-operation-input.network-request-information.network-id + + 'from + AnAI'</response-message><ack-final-indicator>Y</ack-final-indicator><svc-request-id>006927ca-f5a3-47fd-880c-dfcbcd81a093</svc-request-id></output> + </RequestData> + </SDNCAdapterCallbackRequest> + </v1:SDNCAdapterCallback> + </soapenv:Body> +</soapenv:Envelope> + diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/UpdateNetworkV2mock/sdncUpdateNetworkTopologySimResponse.xml b/bpmn/MSOCommonBPMN/src/test/resources/__files/UpdateNetworkV2mock/sdncUpdateNetworkTopologySimResponse.xml new file mode 100644 index 0000000000..40bb93bda0 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/UpdateNetworkV2mock/sdncUpdateNetworkTopologySimResponse.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" + xmlns:v1="http://org.openecomp/workflow/sdnc/adapter/schema/v1"> + <soapenv:Header /> + <soapenv:Body> + <v1:SDNCAdapterCallback> + <SDNCAdapterCallbackRequest xmlns="http://org.openecomp/workflow/sdnc/adapter/schema/v1"> + <CallbackHeader> + <RequestId>testRequestId</RequestId> + <ResponseCode>200</ResponseCode> + <ResponseMessage>OK</ResponseMessage> + </CallbackHeader> + <RequestData xmlns:xs="http://www.w3.org/2001/XMLSchema" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:type="xs:string"><?xml version="1.0" encoding="UTF-8"?><output xmlns="com:att:sdnctl:vnf"><svc-request-id>19174929-3809-49ca-89eb-17f84a035389</svc-request-id><response-code>200</response-code><ack-final-indicator>Y</ack-final-indicator><network-information><network-id>49c86598-f766-46f8-84f8-8d1c1b10f9b4</network-id></network-information><service-information><service-type>a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb</service-type><service-instance-id>HSL_direct_net_2</service-instance-id><subscriber-name>notsurewecare</subscriber-name></service-information></output></RequestData> + </SDNCAdapterCallbackRequest> + </v1:SDNCAdapterCallback> + </soapenv:Body> +</soapenv:Envelope> diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/AddNetworkPolicy_AAIResponse_Success.xml b/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/AddNetworkPolicy_AAIResponse_Success.xml new file mode 100644 index 0000000000..d968bcc1fe --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/AddNetworkPolicy_AAIResponse_Success.xml @@ -0,0 +1,21 @@ +<rest:RESTResponse xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd" + statusCode="200"> + <rest:headers> + <rest:header name="Transfer-Encoding" value="chunked"/> + <rest:header name="Date" value="Mon,14 Mar 2016 20:53:33 GMT"/> + <rest:header name="Expires" value="Thu,01 Jan 1970 00:00:00 UTC"/> + <rest:header name="X-AAI-TXID" + value="mtcnjv9aaas01.mtcnj.aic.cip.att.com-20160314-20:53:33:487-134392"/> + <rest:header name="Content-Type" value="application/xml"/> + <rest:header name="Server" value="Apache-Coyote/1.1"/> + <rest:header name="Cache-Control" value="private"/> + </rest:headers> + <rest:payload contentType="text/xml"> + <network-policy xmlns="http://com.att.aai.inventory/v8"> + <network-policy-id>9a7b327d9-287aa00-82c4b0-105757</network-policy-id> + <network-policy-fqdn>fqdn123</network-policy-fqdn> + <heat-stack-id>slowburn</heat-stack-id> + <resource-version>145878989</resource-version> + </network-policy> + </rest:payload> +</rest:RESTResponse>
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/CreateAAIVfModuleVolumeGroupRequest.xml b/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/CreateAAIVfModuleVolumeGroupRequest.xml new file mode 100644 index 0000000000..2126ae7464 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/CreateAAIVfModuleVolumeGroupRequest.xml @@ -0,0 +1,6 @@ +<CreateAAIVfModuleVolumeGroupRequest> + <vnf-id>skask</vnf-id> + <vf-module-id>lukewarm</vf-module-id> + <aic-cloud-region>pdk1</aic-cloud-region> + <volume-group-id>78987</volume-group-id> +</CreateAAIVfModuleVolumeGroupRequest>
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/DoUpdateVfModuleRequest.xml b/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/DoUpdateVfModuleRequest.xml new file mode 100644 index 0000000000..d041565ac7 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/DoUpdateVfModuleRequest.xml @@ -0,0 +1,29 @@ +<vnf-request xmlns="http://org.openecomp/mso/infra/vnf-request/v1"> + <request-info> + <request-id>DEV-VF-0011</request-id> + <action>UPDATE_VF_MODULE</action> + <source>PORTAL</source> + </request-info> + <vnf-inputs> + <vnf-id>skask</vnf-id> <!-- Required --> + <vf-module-id>supercool</vf-module-id> <!-- Required --> + <vnf-type>pcrf-capacity</vnf-type> <!-- Optional --> + <vf-module-model-name>PCRF::module-0</vf-module-model-name> <!-- Required --> + <asdc-service-model-version></asdc-service-model-version> <!-- Optional --> + <service-id>serviceIdUUID</service-id> <!-- Required --> + <aic-cloud-region>MDTWNJ21</aic-cloud-region> <!-- Required --> + <tenant-id>fba1bd1e195a404cacb9ce17a9b2b421</tenant-id> <!-- Required --> + <volume-group-id>78987</volume-group-id> <!-- Optional --> + <persona-model-id>introvert</persona-model-id> <!-- Optional --> + <persona-model-version>3.14</persona-model-version> <!-- Optional --> + <contrail-service-instance-fqdn>myhost.appl.edu</contrail-service-instance-fqdn> <!-- Optional --> + <vnf-persona-model-id>introvert</vnf-persona-model-id> <!-- Optional --> + <vnf-persona-model-version>3.14</vnf-persona-model-version> <!-- Optional --> + </vnf-inputs> + <vnf-params> + <param name="oam_network_name">VLAN-OAM-1323</param> + <param name="vm_name">slcp34246vbc246ceb</param> + <param name="ipag_network">970cd2b9-7f09-4a12-af47-182ea38ba1f0</param> + <param name="vpe_network">545cc2c3-1930-4100-b534-5d82d0e12bb6</param> + </vnf-params> +</vnf-request> diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/GenericVnf.xml b/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/GenericVnf.xml new file mode 100644 index 0000000000..60f3d01cb7 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/GenericVnf.xml @@ -0,0 +1,38 @@ +<generic-vnf xmlns="http://com.att.aai.inventory/v7"> + <vnf-id>skask</vnf-id> + <vnf-name>STMTN5MMSC20</vnf-name> + <vnf-type>pcrf-capacity</vnf-type> + <service-id>SDN-MOBILITY</service-id> + <equipment-role>vPCRF</equipment-role> + <orchestration-status>pending-create</orchestration-status> + <in-maint>false</in-maint> + <is-closed-loop-disabled>false</is-closed-loop-disabled> + <persona-model-id>introvert</persona-model-id> + <persona-model-version>2.0</persona-model-version> + <resource-version>0000020</resource-version> + <vf-modules> + <vf-module> + <vf-module-id>lukewarm</vf-module-id> + <vf-module-name>PCRF::module-0-0</vf-module-name> + <persona-model-id>introvert</persona-model-id> + <persona-model-version>2.0</persona-model-version> + <is-base-vf-module>true</is-base-vf-module> + <heat-stack-id>fastburn</heat-stack-id> + <orchestration-status>pending-create</orchestration-status> + <resource-version>0000074</resource-version> + </vf-module> + <vf-module> + <vf-module-id>supercool</vf-module-id> + <vf-module-name>PCRF::module-1-0</vf-module-name> + <persona-model-id>extrovert</persona-model-id> + <persona-model-version>2.0</persona-model-version> + <is-base-vf-module>false</is-base-vf-module> + <heat-stack-id>slowburn</heat-stack-id> + <orchestration-status>pending-create</orchestration-status> + <resource-version>0000075</resource-version> + </vf-module> + </vf-modules> + <relationship-list/> + <l-interfaces/> + <lag-interfaces/> +</generic-vnf> diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/PrepareUpdateAAIVfModuleRequest.xml b/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/PrepareUpdateAAIVfModuleRequest.xml new file mode 100644 index 0000000000..65f235cf4b --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/PrepareUpdateAAIVfModuleRequest.xml @@ -0,0 +1,5 @@ +<PrepareUpdateAAIVfModuleRequest> + <vnf-id>skask</vnf-id> + <vf-module-id>supercool</vf-module-id> + <orchestration-status>pending-delete</orchestration-status> +</PrepareUpdateAAIVfModuleRequest>
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/QueryNetworkPolicy_AAIResponse_Success.xml b/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/QueryNetworkPolicy_AAIResponse_Success.xml new file mode 100644 index 0000000000..0442afca90 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/QueryNetworkPolicy_AAIResponse_Success.xml @@ -0,0 +1,21 @@ +<rest:RESTResponse xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd" + statusCode="200"> + <rest:headers> + <rest:header name="Transfer-Encoding" value="chunked"/> + <rest:header name="Date" value="Mon,14 Mar 2016 20:53:33 GMT"/> + <rest:header name="Expires" value="Thu,01 Jan 1970 00:00:00 UTC"/> + <rest:header name="X-AAI-TXID" + value="mtcnjv9aaas01.mtcnj.aic.cip.att.com-20160314-20:53:33:487-134392"/> + <rest:header name="Content-Type" value="application/xml"/> + <rest:header name="Server" value="Apache-Coyote/1.1"/> + <rest:header name="Cache-Control" value="private"/> + </rest:headers> + <rest:payload contentType="text/xml"> + <network-policy xmlns="http://com.att.aai.inventory/v8"> + <network-policy-id>9a7b327d9-287aa00-82c4b0-105757</network-policy-id> + <network-policy-fqdn>GN_EVPN_Test</network-policy-fqdn> + <heat-stack-id>195159195</heat-stack-id> + <resource-version>14567890</resource-version> + </network-policy> + </rest:payload> +</rest:RESTResponse>
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/SDNCTopologyActivateCallback.xml b/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/SDNCTopologyActivateCallback.xml new file mode 100644 index 0000000000..4cab6c6615 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/SDNCTopologyActivateCallback.xml @@ -0,0 +1,13 @@ +<output xmlns="com:att:sdnctl:vnf"> + <vnf-information> + <vnf-id>skask</vnf-id> + </vnf-information> + <response-code>200</response-code> + <svc-request-id>{{REQUEST-ID}}</svc-request-id> + <ack-final-indicator>Y</ack-final-indicator> + <service-information> + <subscriber-name>dontcare</subscriber-name> + <service-instance-id>0</service-instance-id> + <service-type>SDN-MOBILITY</service-type> + </service-information> +</output>
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/SDNCTopologyAssignCallback.xml b/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/SDNCTopologyAssignCallback.xml new file mode 100644 index 0000000000..7d3d0e54d1 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/SDNCTopologyAssignCallback.xml @@ -0,0 +1,13 @@ + <output xmlns="com:att:sdnctl:vnf"> + <vnf-information> + <vnf-id>skask</vnf-id> + </vnf-information> + <response-code>200</response-code> + <svc-request-id>{{REQUEST-ID}}</svc-request-id> + <ack-final-indicator>Y</ack-final-indicator> + <service-information> + <subscriber-name>dontcare</subscriber-name> + <service-instance-id>0</service-instance-id> + <service-type>SDN-MOBILITY</service-type> + </service-information> + </output>
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/SDNCTopologyChangeAssignCallback.xml b/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/SDNCTopologyChangeAssignCallback.xml new file mode 100644 index 0000000000..7d3d0e54d1 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/SDNCTopologyChangeAssignCallback.xml @@ -0,0 +1,13 @@ + <output xmlns="com:att:sdnctl:vnf"> + <vnf-information> + <vnf-id>skask</vnf-id> + </vnf-information> + <response-code>200</response-code> + <svc-request-id>{{REQUEST-ID}}</svc-request-id> + <ack-final-indicator>Y</ack-final-indicator> + <service-information> + <subscriber-name>dontcare</subscriber-name> + <service-instance-id>0</service-instance-id> + <service-type>SDN-MOBILITY</service-type> + </service-information> + </output>
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/SDNCTopologyQueryCallback.xml b/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/SDNCTopologyQueryCallback.xml new file mode 100644 index 0000000000..b143e3b17a --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/SDNCTopologyQueryCallback.xml @@ -0,0 +1,315 @@ +<output xmlns="com:att:sdnctl:vnf"> +<vnf-list xmlns="com:att:sdnctl:vnf"> + <vnf-id>bd1b3789-6474-4935-94b2-90b656e035d0</vnf-id> + <service-data> + <vnf-id>bd1b3789-6474-4935-94b2-90b656e035d0</vnf-id> + <sdnc-request-header> + <svc-request-id>9ddf628a-9eca-430e-8974-22d520a31be1</svc-request-id> + <svc-action>assign</svc-action> + <svc-notification-url>https://msojra.infra.aic.att.net:8443/adapters/rest/SDNCNotify</svc-notification-url> + </sdnc-request-header> + <service-information> + <subscriber-name>notsurewecare</subscriber-name> + <service-instance-id>bd1b3789-6474-4935-94b2-90b656e035d0</service-instance-id> + <service-type>a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb</service-type> + <service-id>a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb</service-id> + </service-information> + <oper-status> + <order-status>PendingCreate</order-status> + </oper-status> + <vnf-request-information> + <aic-cloud-region>VNN1CA52LCP</aic-cloud-region> + <vnf-name>ZVNNMOGX01_base</vnf-name> + <generic-vnf-id>afd0f02a-1ddb-43bb-aded-5113e46e82ae</generic-vnf-id> + <generic-vnf-type>ZVNN1MOGX01-SVC/ZVNN1MOGX01 - VF AUG 1 1</generic-vnf-type> + <generic-vnf-name>ZVNN1MOGX01</generic-vnf-name> + <tenant>33d209df14ac4c08ad60747185d2f3e0</tenant> + <vnf-id>bd1b3789-6474-4935-94b2-90b656e035d0</vnf-id> + <vnf-type>ZVNN1MOGX01 - VF AUG 1::module-0</vnf-type> + </vnf-request-information> + <vnf-topology-information> + <vnf-assignments> + <vnf-networks> + <network-role>mog_exn</network-role> + <network-id>03dbd833-785c-40c0-bf32-37594b5334bc</network-id> + <network-name>MNS-25180-P-VNNYCA01_exn_protected_net_1</network-name> + <contrail-network-fqdn/> + <subnet-id/> + <neutron-id>6f82d234-41a4-48e9-a9e8-415667a72929</neutron-id> + <sriov-vlan-filter-list> + <sriov-vlan-filter>filter1</sriov-vlan-filter> + </sriov-vlan-filter-list> + <sriov-vlan-filter-list> + <sriov-vlan-filter>filter2</sriov-vlan-filter> + </sriov-vlan-filter-list> + </vnf-networks> + <vnf-networks> + <network-role>mog_oam</network-role> + <network-id>3f181cde-9380-4c20-9d3a-e1a4ee74f994</network-id> + <network-name>MNS-25180-P-VNNYCA01_oam_protected_net_1</network-name> + <contrail-network-fqdn/> + <subnet-id/> + <neutron-id>713b6770-13fa-4949-8dbb-a1288c5e5932</neutron-id> + </vnf-networks> + <vnf-networks> + <network-role>mog_cor_B</network-role> + <network-id>821a550a-3f50-4725-995b-f212d5caec7c</network-id> + <network-name>MNS-25180-P-VNNYCA01_cor_direct_net_1</network-name> + <contrail-network-fqdn/> + <subnet-id/> + <neutron-id>18926e56-12b6-4a4d-98b6-37e0c05626ee</neutron-id> + </vnf-networks> + <vnf-networks> + <network-role>mog_cor_A</network-role> + <network-id>3dabf5c0-cffb-420c-8960-8499c74eb25f</network-id> + <network-name>MNS-25180-P-VNNYCA01_cor_direct_net_2</network-name> + <contrail-network-fqdn/> + <subnet-id/> + <neutron-id>35530b29-a4de-48ff-a014-111110ccc652</neutron-id> + </vnf-networks> + <vnf-networks> + <network-role>mog_gn</network-role> + <network-id>3ce97321-6e7f-49af-bd12-f833e377c310</network-id> + <network-name>MNS-25180-P-VNNYCA01_gn_direct_net_1</network-name> + <contrail-network-fqdn/> + <subnet-id/> + <neutron-id>32bfdd2c-28e1-4895-87a6-373bf12c3129</neutron-id> + </vnf-networks> + <vnf-networks> + <network-role>mog_dmz</network-role> + <network-id>d43ca910-02a5-47dc-8510-100a68a3c9e0</network-id> + <network-name>MNS-25180-P-VNNYCA01_dmz_protected_net_1</network-name> + <contrail-network-fqdn/> + <subnet-id/> + <neutron-id>cb9500fb-943f-412e-aea6-458711564a75</neutron-id> + </vnf-networks> + <availability-zones> + <availability-zone>nova</availability-zone> + </availability-zones> + <vnf-vms> + <vm-type>ps</vm-type> + <vm-names> + <vm-name>ZVNN1MOGX01MPS001</vm-name> + </vm-names> + <vm-names> + <vm-name>ZVNN1MOGX01MPS002</vm-name> + </vm-names> + <vm-names> + <vm-name>ZVNN1MOGX01MPS003</vm-name> + </vm-names> + <vm-names> + <vm-name>ZVNN1MOGX01MPS004</vm-name> + </vm-names> + <vm-count>4</vm-count> + <vm-networks> + <network-role>mog_cor_B</network-role> + <network-ips> + <ip-address>107.224.36.251</ip-address> + </network-ips> + <network-ips> + <ip-address>107.224.36.252</ip-address> + </network-ips> + <network-ips> + <ip-address>107.224.36.253</ip-address> + </network-ips> + <network-ips> + <ip-address>107.224.36.254</ip-address> + </network-ips> + <use-dhcp>N</use-dhcp> + </vm-networks> + </vnf-vms> + <vnf-vms> + <vm-type>cm</vm-type> + <vm-names> + <vm-name>ZVNN1MOGX01MCM001</vm-name> + </vm-names> + <vm-names> + <vm-name>ZVNN1MOGX01OAM002</vm-name> + </vm-names> + <vm-count>1</vm-count> + <vm-networks> + <network-role>mog_cor_B</network-role> + <network-ips> + <ip-address>107.224.36.249</ip-address> + </network-ips> + <network-ips> + <ip-address>107.224.36.250</ip-address> + </network-ips> + <use-dhcp>N</use-dhcp> + </vm-networks> + <vm-networks> + <network-role>mog_oam</network-role> + <network-ips> + <ip-address>107.239.167.250</ip-address> + </network-ips> + <network-ips> + <ip-address>107.239.167.251</ip-address> + </network-ips> + <use-dhcp>N</use-dhcp> + </vm-networks> + </vnf-vms> + <vnf-vms> + <vm-type>oam</vm-type> + <vm-names> + <vm-name>ZVNN1MOGX01OAM001</vm-name> + </vm-names> + <vm-names> + <vm-name>ZVNN1MOGX01OAM002</vm-name> + </vm-names> + <vm-count>2</vm-count> + <vm-networks> + <network-role>mog_oam</network-role> + <network-ips> + <ip-address>107.239.167.252</ip-address> + </network-ips> + <network-ips> + <ip-address>107.239.167.251</ip-address> + </network-ips> + <use-dhcp>N</use-dhcp> + </vm-networks> + <vm-networks> + <network-role>mog_cor_B</network-role> + <network-ips> + <ip-address>107.224.36.249</ip-address> + </network-ips> + <network-ips> + <ip-address>107.224.36.250</ip-address> + </network-ips> + <use-dhcp>N</use-dhcp> + </vm-networks> + </vnf-vms> + <vnf-vms> + <vm-type>pd</vm-type> + <vm-names> + <vm-name>ZVNN1MOGX01MPD001</vm-name> + </vm-names> + <vm-names> + <vm-name>ZVNN1MOGX01MPD002</vm-name> + </vm-names> + <vm-count>2</vm-count> + <vm-networks> + <network-role>mog_dmz</network-role> + <network-ips> + <ip-address>107.225.25.253</ip-address> + </network-ips> + <network-ips> + <ip-address>107.225.25.254</ip-address> + </network-ips> + <use-dhcp>N</use-dhcp> + <floating-ip>107.225.254.253</floating-ip> + </vm-networks> + <vm-networks> + <network-role>mog_oam</network-role> + <network-ips> + <ip-address>107.239.167.254</ip-address> + </network-ips> + <network-ips> + <ip-address>107.239.167.253</ip-address> + </network-ips> + <use-dhcp>N</use-dhcp> + <floating-ip>107.239.167.249</floating-ip> + </vm-networks> + <vm-networks> + <network-role>mog_exn</network-role> + <network-ips> + <ip-address>107.224.46.253</ip-address> + </network-ips> + <network-ips> + <ip-address>107.224.46.254</ip-address> + </network-ips> + <use-dhcp>N</use-dhcp> + <floating-ip>107.224.46.252</floating-ip> + </vm-networks> + <vm-networks> + <network-role>mog_cor_B</network-role> + <network-ips> + <ip-address>107.224.36.247</ip-address> + </network-ips> + <network-ips> + <ip-address>107.224.36.248</ip-address> + </network-ips> + <use-dhcp>N</use-dhcp> + <floating-ip>107.224.41.252</floating-ip> + </vm-networks> + <vm-networks> + <network-role>mog_gn</network-role> + <network-ips> + <ip-address>107.224.41.253</ip-address> + </network-ips> + <network-ips> + <ip-address>107.224.41.254</ip-address> + </network-ips> + <use-dhcp>N</use-dhcp> + <floating-ip>107.224.41.252</floating-ip> + </vm-networks> + <vm-networks> + <network-role>mog_cor_A</network-role> + <network-ips> + <ip-address>107.224.38.253</ip-address> + </network-ips> + <network-ips> + <ip-address>107.224.38.254</ip-address> + </network-ips> + <use-dhcp>N</use-dhcp> + </vm-networks> + </vnf-vms> + <vnf-vms> + <vm-type>sm</vm-type> + <vm-names> + <vm-name>ZVNN1MOGX01MSM001</vm-name> + </vm-names> + <vm-names> + <vm-name>ZVNN1MOGX01MSM002</vm-name> + </vm-names> + <vm-names> + <vm-name>ZVNN1MOGX01MSM003</vm-name> + </vm-names> + <vm-names> + <vm-name>ZVNN1MOGX01MSM004</vm-name> + </vm-names> + <vm-count>4</vm-count> + <vm-networks> + <network-role>mog_cor_B</network-role> + <network-ips> + <ip-address>107.224.36.243</ip-address> + </network-ips> + <network-ips> + <ip-address>107.224.36.244</ip-address> + </network-ips> + <network-ips> + <ip-address>107.224.36.245</ip-address> + </network-ips> + <network-ips> + <ip-address>107.224.36.246</ip-address> + </network-ips> + <use-dhcp>N</use-dhcp> + </vm-networks> + </vnf-vms> + </vnf-assignments> + <vnf-topology-identifier> + <vnf-name>ZVNNMOGX01_base</vnf-name> + <service-type>SDN-MOBILITY</service-type> + <vnf-type>ZVNN1MOGX01 - VF AUG 1::module-0</vnf-type> + <generic-vnf-type>ZVNN1MOGX01-SVC/ZVNN1MOGX01 - VF AUG 1 1</generic-vnf-type> + <generic-vnf-name>ZVNN1MOGX01</generic-vnf-name> + </vnf-topology-identifier> + </vnf-topology-information> + <request-information> + <request-id>9ddf628a-9eca-430e-8974-22d520a31be1</request-id> + <notification-url/> + <source>PORTAL</source> + <request-action>VNFActivateRequest</request-action> + </request-information> + </service-data> + <service-status> + <response-code>200</response-code> + <final-indicator>Y</final-indicator> + <request-status>synccomplete</request-status> + <response-timestamp>2016-08-05T16:15:19.398Z</response-timestamp> + <rpc-name>vnf-topology-operation</rpc-name> + <vnfsdn-action>VNFActivateRequest</vnfsdn-action> + <rpc-action>assign</rpc-action> + </service-status> +</vnf-list> + +</output> diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/SDNCTopologyQueryCallbackVfModule.xml b/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/SDNCTopologyQueryCallbackVfModule.xml new file mode 100644 index 0000000000..c9f9cf3262 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/SDNCTopologyQueryCallbackVfModule.xml @@ -0,0 +1,141 @@ +<output xmlns="com:att:sdnctl:vnf"> + <vnf-list xmlns="com:att:sdnctl:vnf"> + <vnf-id>28455973-1ee5-4ad1-8d35-c4732679743a</vnf-id> + <service-status> + <response-code>200</response-code> + <final-indicator>Y</final-indicator> + <request-status>synccomplete</request-status> + <response-timestamp>2016-06-08T19:44:59.138Z</response-timestamp> + <rpc-name>vnf-topology-operation</rpc-name> + <vnfsdn-action>VNFActivateRequest</vnfsdn-action> + <rpc-action>assign</rpc-action> + </service-status> + <service-data> + <vnf-id>28455973-1ee5-4ad1-8d35-c4732679743</vnf-id> + <service-information> + <subscriber-name>notsurewecare</subscriber-name> + <service-instance-id>28455973-1ee5-4ad1-8d35-c4732679743a</service-instance-id> + <service-type>a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb</service-type> + <service-id>a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb</service-id> + </service-information> + <sdnc-request-header> + <svc-request-id>5e168556-a5c6-4813-bff3-cc03007afbbc</svc-request-id> + <svc-notification-url>http://mtanjv9moja01-eth1-0.aic.cip.att.com:28080/adapters/rest/SDNCNotify</svc-notification-url> + <svc-action>assign</svc-action> + </sdnc-request-header> + <vnf-request-information> + <aic-cloud-region>AAIAIC25</aic-cloud-region> + <vnf-name>MSOTEST06-vSAMP3::base::module-0</vnf-name> + <generic-vnf-id>91ad7ab0-9ffd-471d-971c-3eb913a2cc75</generic-vnf-id> + <generic-vnf-type>Test/vSAMP3 1</generic-vnf-type> + <generic-vnf-name>MSOTEST06</generic-vnf-name> + <tenant>4ae1d3446a4c48b2bec44b6cfba06d68</tenant> + <vnf-id>28455973-1ee5-4ad1-8d35-c4732679743a</vnf-id> + <vnf-type>vSAMP3::base::module-0</vnf-type> + </vnf-request-information> + <oper-status> + <order-status>PendingCreate</order-status> + </oper-status> + <vnf-topology-information> + <vnf-parameters> + <vnf-parameter-name>image</vnf-parameter-name> + <vnf-parameter-value>Ubuntu_Perf</vnf-parameter-value> + </vnf-parameters> + <vnf-parameters> + <vnf-parameter-name>flavor</vnf-parameter-name> + <vnf-parameter-value>m1.small</vnf-parameter-value> + </vnf-parameters> + <vnf-assignments> + <vnf-networks> + <network-role>int_imbl</network-role> + <network-id>680b7453-0ec4-4d96-b355-280d981d418f</network-id> + <network-name>Nimbus-25193-T-Willows2_int_imbl_net_1</network-name> + <contrail-network-fqdn>default-domain:Nimbus-25193-T-Willows2:Nimbus-25193-T-Willows2_int_imbl_net_1</contrail-network-fqdn> + <subnet-id></subnet-id> + <ipv6-subnet-id>775607fb-e16a-45ef-94a7-82fba0d16eec</ipv6-subnet-id> + <neutron-id>640d07fb-e16a-45ef-94a7-82fba0d169bf</neutron-id> + <sriov-vlan-filter-list> + <sriov-vlan-filter>filter1</sriov-vlan-filter> + </sriov-vlan-filter-list> + <sriov-vlan-filter-list> + <sriov-vlan-filter>filter2</sriov-vlan-filter> + </sriov-vlan-filter-list> + </vnf-networks> + <vnf-networks> + <network-role>sgi_protected</network-role> + <network-id>f9039ce9-e3cf-4716-b2d1-ec7912178ea4</network-id> + <network-name>Nimbus-25193-T-Willows2_sgi_protected_net_1</network-name> + <contrail-network-fqdn>default-domain:Nimbus-25193-T-Willows2:Nimbus-25193-T-Willows2_sgi_protected_net_1</contrail-network-fqdn> + <subnet-id>b9999ce9-e3cf-4716-b2d1-ec791217678c</subnet-id> + <ipv6-subnet-id></ipv6-subnet-id> + <neutron-id>bf11bba8-b971-4ab5-8281-215b3fedcd3c</neutron-id> + </vnf-networks> + <vnf-vms> + <vm-type>cm</vm-type> + <vm-names> + <vm-name>ZVNN1MOGX01MCM001</vm-name> + </vm-names> + <vm-names> + <vm-name>ZVNN1MOGX01OAM002</vm-name> + </vm-names> + <vm-count>1</vm-count> + <vm-networks> + <network-role>mog_cor_B</network-role> + <network-ips> + <ip-address>107.224.36.249</ip-address> + </network-ips> + <network-ips> + <ip-address>107.224.36.250</ip-address> + </network-ips> + <network-ips-v6> + <ip-address-ipv6>2606:ae00:2e01:800::67</ip-address-ipv6> + </network-ips-v6> + <use-dhcp>N</use-dhcp> + <floating-ip>107.224.41.252</floating-ip> + <floating-ip-v6>2001:1890:1001:2B32::29:C</floating-ip-v6> + </vm-networks> + <vm-networks> + <network-role>mog_oam</network-role> + <network-ips> + <ip-address>107.239.167.250</ip-address> + </network-ips> + <network-ips> + <ip-address>107.239.167.251</ip-address> + </network-ips> + <network-ips-v6> + <ip-address-ipv6>aa::aa::aa::aa::aa::aa</ip-address-ipv6> + </network-ips-v6> + <network-ips-v6> + <ip-address-ipv6>bb::bb::bb::bb::bb::bb</ip-address-ipv6> + </network-ips-v6> + <interface-route-prefixes> + <interface-route-prefix-cidr>1.2.3.4/26</interface-route-prefix-cidr> + </interface-route-prefixes> + <interface-route-prefixes> + <interface-route-prefix-cidr>2002::/64</interface-route-prefix-cidr> + </interface-route-prefixes> + <use-dhcp>N</use-dhcp> + <floating-ip-v6>1111:1890:1001:2B32::29:D</floating-ip-v6> + </vm-networks> + </vnf-vms> + <availability-zones> + <availability-zone>nova</availability-zone> + </availability-zones> + </vnf-assignments> + <vnf-topology-identifier> + <vnf-name>MSOTEST06-vSAMP3::base::module-0</vnf-name> + <service-type>SDN-MOBILITY</service-type> + <vnf-type>vSAMP3::base::module-0</vnf-type> + <generic-vnf-type>Test/vSAMP3 1</generic-vnf-type> + <generic-vnf-name>MSOTEST06</generic-vnf-name> + </vnf-topology-identifier> + </vnf-topology-information> + <request-information> + <request-id>5e168556-a5c6-4813-bff3-cc03007afbbc</request-id> + <notification-url></notification-url> + <source>SoapUI-bns-vf-base-vSAMP3-9001</source> + <request-action>VNFActivateRequest</request-action> + </request-information> + </service-data> +</vnf-list> +</output> diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/StandardSDNCSynchResponse.xml b/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/StandardSDNCSynchResponse.xml new file mode 100644 index 0000000000..919ff2c36b --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/StandardSDNCSynchResponse.xml @@ -0,0 +1,5 @@ +<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> + <soap:Body> + <SDNCAdapterResponse xmlns="http://org.openecomp/workflow/sdnc/adapter/schema/v1"/> + </soap:Body> +</soap:Envelope>
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/UpdateAAIGenericVnfRequest.xml b/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/UpdateAAIGenericVnfRequest.xml new file mode 100644 index 0000000000..3e7c6503f4 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/UpdateAAIGenericVnfRequest.xml @@ -0,0 +1,5 @@ +<UpdateAAIGenericVnfRequest> + <vnf-id>skask</vnf-id> + <persona-model-id>introvert</persona-model-id> + <persona-model-version>3.14</persona-model-version> +</UpdateAAIGenericVnfRequest>
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/UpdateAAIVfModuleRequest.xml b/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/UpdateAAIVfModuleRequest.xml new file mode 100644 index 0000000000..8a690403c4 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/UpdateAAIVfModuleRequest.xml @@ -0,0 +1,10 @@ +<UpdateAAIVfModuleRequest> + <vnf-id>skask</vnf-id> + <vf-module-id>supercool</vf-module-id> + <heat-stack-id>slowburn</heat-stack-id> + <orchestration-status>complete</orchestration-status> + <volume-group-id>78987</volume-group-id> + <persona-model-id>introvert</persona-model-id> + <persona-model-version>3.14</persona-model-version> + <contrail-service-instance-fqdn>myhost.appl.com</contrail-service-instance-fqdn> +</UpdateAAIVfModuleRequest>
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/UpdateVfModuleRequest.xml b/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/UpdateVfModuleRequest.xml new file mode 100644 index 0000000000..966ca50b16 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/UpdateVfModuleRequest.xml @@ -0,0 +1,35 @@ +<vnf-request xmlns="http://org.openecomp/mso/infra/vnf-request/v1"> + <request-info> + <request-id>DEV-VF-0011</request-id> + <action>UPDATE_VF_MODULE</action> + <source>PORTAL</source> + </request-info> + <vnf-inputs> + <vnf-id>skask</vnf-id> <!-- Required --> <!-- with vf-module-id, identifies the vf-module to update --> + <vf-module-id>supercool</vf-module-id> <!-- Required --> <!-- with vnf-id, identifies the vf-module to update --> + <vnf-type>pcrf-capacity</vnf-type> <!-- Required --> <!-- not in vf-module; used for recipe selection/filtering; + thus, not used by UpdateVfModule flow --> + <vf-module-model-name>PCRF::module-0</vf-module-model-name> <!-- Required --> <!-- not in vf-module; used for recipe selection/filtering; + thus, not used by UpdateVfModule flow --> + <asdc-service-model-version></asdc-service-model-version> <!-- Optional --> <!-- not in vf-module; used for recipe selection; + thus, not used by UpdateVfModule flow --> + <service-id>serviceIdUUID</service-id> <!-- Required --> <!-- not in vf-module; used for query filtering; + thus, not used by UpdateVfModule flow --> + <aic-cloud-region>MDTWNJ21</aic-cloud-region> <!-- Required --> <!-- in vf-module as part of volume-group relationship; + however, used for query filtering only; not updatable in AAI --> + <tenant-id>fba1bd1e195a404cacb9ce17a9b2b421</tenant-id> <!-- Required --> <!-- not in vf-module; used to confirm volume group tenant --> + <volume-group-id>78987</volume-group-id> <!-- Optional --> <!-- in vf-module as part of volume-group relationship; used + to update VNF adapter; not updatable in AAI --> + <persona-model-id>introvert</persona-model-id> <!-- Optional --> <!-- Not in AID, in vf-module --> + <persona-model-version>3.14</persona-model-version> <!-- Optional --> <!-- Not in AID, in vf-module --> + <contrail-service-instance-fqdn>myhost.appl.edu</contrail-service-instance-fqdn> <!-- Optional --> <!-- Not in AID, in vf-module --> + <vnf-persona-model-id>introvert</vnf-persona-model-id> <!-- Optional --> <!-- Not in AID, in generic-vnf (as persona-model-id) --> + <vnf-persona-model-version>3.14</vnf-persona-model-version> <!-- Optional --> <!-- Not in AID, in generic-vnf (as persona-model-version) --> + </vnf-inputs> + <vnf-params> + <param name="oam_network_name">VLAN-OAM-1323</param> + <param name="vm_name">slcp34246vbc246ceb</param> + <param name="ipag_network">970cd2b9-7f09-4a12-af47-182ea38ba1f0</param> + <param name="vpe_network">545cc2c3-1930-4100-b534-5d82d0e12bb6</param> + </vnf-params> +</vnf-request> diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/VNFAdapterRestCreateCallback.xml b/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/VNFAdapterRestCreateCallback.xml new file mode 100644 index 0000000000..49ecd0bf3f --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/VNFAdapterRestCreateCallback.xml @@ -0,0 +1,55 @@ +<createVfModuleResponse> + <vnfId>skask</vnfId> + <vfModuleId>supercool</vfModuleId> + <vfModuleStackId>slowburn</vfModuleStackId> + <vfModuleCreated>true</vfModuleCreated> + <vfModuleOutputs> + <entry> + <key>key1</key> + <value>value1</value> + </entry> + <entry> + <key>key2</key> + <value>value2</value> + </entry> + <entry> +<key>server1_private_ip</key> +<value>192.168.28.3</value> +</entry> +<entry> +<key>contrail-service-instance-fqdn</key> +<value>default-domain:MSOTest:MsoNW-RA</value> +</entry> +<entry> +<key>policyKey1_contrail_network_policy_fqdn</key> +<value>MSOTest:DefaultPolicyFQDN1</value> +</entry> +<entry> +<key>policyKey2_contrail_network_policy_fqdn</key> +<value>MSOTest:DefaultPolicyFQDN2</value> +</entry> +<entry> +<key>oam_management_v6_address</key> +<value>2000:abc:bce:1111</value> +</entry> +<entry> +<key>oam_management_v4_address</key> +<value>127.0.0.1</value> +</entry> + </vfModuleOutputs> + <rollback> <!-- JC's doc has "vfModuleRollback" --> + <vnfId>skask</vnfId> + <vfModuleId>supercool</vfModuleId> + <vfModuleStackId>slowburn</vfModuleStackId> + <vfModuleCreated>true</vfModuleCreated> + <tenantId>tenantId</tenantId> + <cloudSiteId>cloudSiteId</cloudSiteId> + <msoRequest> + <requestId>requestId</requestId> + <serviceInstanceId>serviceInstanceId</serviceInstanceId> + </msoRequest> + <messageId>{{MESSAGE-ID}}</messageId> <!-- JC's doc does not have this --> + </rollback> + <messageId>{{MESSAGE-ID}}</messageId> +</createVfModuleResponse> + diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/VNFAdapterRestUpdateCallback.xml b/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/VNFAdapterRestUpdateCallback.xml new file mode 100644 index 0000000000..c602dd9667 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/VNFAdapterRestUpdateCallback.xml @@ -0,0 +1,16 @@ +<updateVfModuleResponse> + <vnfId>skask</vnfId> + <vfModuleId>supercool</vfModuleId> + <vfModuleStackId>slowburn</vfModuleStackId> + <vfModuleOutputs> + <entry> + <key>key1</key> + <value>value1</value> + </entry> + <entry> + <key>key2</key> + <value>value2</value> + </entry> + </vfModuleOutputs> + <messageId>{{MESSAGE-ID}}</messageId> +</updateVfModuleResponse> diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/VNFAdapterRestVolumeGroupCallback.xml b/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/VNFAdapterRestVolumeGroupCallback.xml new file mode 100644 index 0000000000..830d2e2237 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/VNFAdapterRestVolumeGroupCallback.xml @@ -0,0 +1,15 @@ +<updateVolumeGroupResponse> + <volumeGroupId>78987</volumeGroupId> + <volumeGroupStackId>slowburn</volumeGroupStackId> + <vfModuleOutputs> + <entry> + <key>key1</key> + <value>value1</value> + </entry> + <entry> + <key>key2</key> + <value>value2</value> + </entry> + </vfModuleOutputs> + <messageId>{{MESSAGE-ID}}</messageId> +</updateVolumeGroupResponse> diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/VfModule-lukewarm.xml b/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/VfModule-lukewarm.xml new file mode 100644 index 0000000000..ad3c3591ed --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/VfModule-lukewarm.xml @@ -0,0 +1,10 @@ +<vf-module xmlns="http://com.att.aai.inventory/v7"> + <vf-module-id>lukewarm</vf-module-id> + <vf-module-name>PCRF::module-1</vf-module-name> + <heat-stack-id>slowburn</heat-stack-id> + <orchestration-status>pending-create</orchestration-status> + <is-base-vf-module>true</is-base-vf-module> + <resource-version>330-90</resource-version> + <persona-model-id>introvert</persona-model-id> + <persona-model-version>2.0</persona-model-version> +</vf-module>
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/VfModule-new.xml b/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/VfModule-new.xml new file mode 100644 index 0000000000..eba91a7a84 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/VfModule-new.xml @@ -0,0 +1,9 @@ +<vf-module xmlns="http://com.att.aai.inventory/v7"> + <vf-module-id>b37d96db-7d2c-47ce-bf61-a6c7b82fe161</vf-module-id> + <vf-module-name>PCRF::module-0-2</vf-module-name> + <persona-model-id>00000000-0000-0000-0000-000000000000</persona-model-id> + <persona-model-version>1.0</persona-model-version> + <is-base-vf-module>false</is-base-vf-module> + <orchestration-status>pending-create</orchestration-status> + <resource-version>330-90</resource-version> +</vf-module>
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/VfModule-supercool.xml b/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/VfModule-supercool.xml new file mode 100644 index 0000000000..6d365f7d51 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/VfModule-supercool.xml @@ -0,0 +1,27 @@ +<vf-module xmlns="http://com.att.aai.inventory/v7"> + <vf-module-id>supercool</vf-module-id> + <vf-module-name>PCRF::module-2</vf-module-name> + <heat-stack-id>fastburn</heat-stack-id> + <orchestration-status>pending-create</orchestration-status> + <is-base-vf-module>false</is-base-vf-module> + <resource-version>330-89</resource-version> + <persona-model-id>introvert</persona-model-id> + <persona-model-version>2.0</persona-model-version> + <relationship-list> + <relationship> + <related-to>volume-group</related-to> + <relationship-data> + <relationship-key>cloud-region.cloud-owner</relationship-key> + <relationship-value>att-aic</relationship-value> + </relationship-data> + <relationship-data> + <relationship-key>cloud-region.cloud-region-id</relationship-key> + <relationship-value>pdk1</relationship-value> + </relationship-data> + <relationship-data> + <relationship-key>volume-group.volume-group-id</relationship-key> + <relationship-value>78987</relationship-value> + </relationship-data> + </relationship> + </relationship-list> +</vf-module>
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/VolumeGroup.xml b/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/VolumeGroup.xml new file mode 100644 index 0000000000..241e5e3e3f --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/VolumeGroup.xml @@ -0,0 +1,25 @@ + <volume-group xmlns="http://com.att.aai.inventory/v7"> + <volume-group-id>78987</volume-group-id> + <volume-group-name>Volume_2</volume-group-name> + <heat-stack-id>slowburn</heat-stack-id> + <vnf-type>pcrf-capacity</vnf-type> + <orchestration-status>Active</orchestration-status> + <resource-version>0000020</resource-version> + <relationship-list> + <relationship> + <related-to>tenant</related-to> + <relationship-data> + <relationship-key>cloud-region.cloud-owner</relationship-key> + <relationship-value>att-aic</relationship-value> + </relationship-data> + <relationship-data> + <relationship-key>cloud-region.cloud-region-id</relationship-key> + <relationship-value>MDTWNJ21</relationship-value> + </relationship-data> + <relationship-data> + <relationship-key>tenant.tenant-id</relationship-key> + <relationship-value>fba1bd1e195a404cacb9ce17a9b2b421</relationship-value> + </relationship-data> + </relationship> + </relationship-list> + </volume-group>
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/aai-volume-group-id-info.xml b/bpmn/MSOCommonBPMN/src/test/resources/__files/aai-volume-group-id-info.xml new file mode 100644 index 0000000000..37c5155c48 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/aai-volume-group-id-info.xml @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<tns:volume-group xmlns:tns="http://com.att.aai.inventory/v6" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://com.att.aai.inventory/v6 aai_schema_v6.xsd "> + <tns:volume-group-id>VOLUME_GROUP_ID_1</tns:volume-group-id> + <tns:volume-group-name>VOLUME_GROUP_ID_1_NAME</tns:volume-group-name> + <tns:heat-stack-id>heat-stack-id</tns:heat-stack-id> + <tns:vnf-type>vnf-type</tns:vnf-type> + <tns:orchestration-status>OK</tns:orchestration-status> + <tns:resource-version>1</tns:resource-version> + <tns:relationship-list> + <tns:relationship> + <tns:related-to>tenant</tns:related-to> + <tns:relationship-data> + <tns:relationship-key>cloud-region.cloud-owner</tns:relationship-key> + <tns:relationship-value>att-aic</tns:relationship-value> + </tns:relationship-data> + <tns:relationship-data> + <tns:relationship-key>cloud-region.cloud-region-id</tns:relationship-key> + <tns:relationship-value>pdk1</tns:relationship-value> + </tns:relationship-data> + <tns:relationship-data> + <tns:relationship-key>tenant.tenant-id</tns:relationship-key> + <tns:relationship-value>cee6d136-e378-4678-a024-2cd15f0ee0cg</tns:relationship-value> + </tns:relationship-data> + </tns:relationship> + </tns:relationship-list> + </tns:volume-group> + + diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/aaiFault.xml b/bpmn/MSOCommonBPMN/src/test/resources/__files/aaiFault.xml new file mode 100644 index 0000000000..66ed8f5758 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/aaiFault.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<Fault> +<requestError> +<serviceException> +<messageId>SVC3002</messageId> +<text>Error writing output performing %1 on %2 (msg=%3) (ec=%4)</text> +<variables> +<variable>PUTcustomer</variable> +<variable>SubName01</variable> +<variable>Unexpected error reading/updating database:Adding this property for key [service-instance-id] and value [USSTU2CFCNC0101UJZZ01] violates a uniqueness constraint [service-instance-id]</variable> +<variable>ERR.5.4.5105</variable> +</variables> +</serviceException> +</requestError> +</Fault>
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/vnfAdapterMocks/vnfCreateSimResponse.xml b/bpmn/MSOCommonBPMN/src/test/resources/__files/vnfAdapterMocks/vnfCreateSimResponse.xml new file mode 100644 index 0000000000..7b5d22a1de --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/vnfAdapterMocks/vnfCreateSimResponse.xml @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="UTF-8"?> +<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" + xmlns:v1="http://org.openecomp.mso/vnfNotify"> + <soapenv:Header /> + <soapenv:Body> + <ns2:createVnfNotification xmlns:ns2="http://org.openecomp.mso/vnfNotify"> + <messageId>edab9ec7-6cf8-47cf-b58c-9ba4ef5d3f70</messageId> + <completed>true</completed> + <vnfId>slcp34248vbc/020a112b-a0c8-4143-87a3-698680ba2efe</vnfId> + <outputs> + <entry> + <key>server_ip</key> + <value>135.21.249.178</value> + </entry> + </outputs> + <rollback> + <cloudSiteId>MTSNJA4LCP1</cloudSiteId> + <msoRequest> + <requestId>1512_1120-BB11-1</requestId> + <serviceInstanceId>BB11/VLXM/003717//SW_INTERNET</serviceInstanceId> + </msoRequest> + <tenantCreated>false</tenantCreated> + <tenantId>e25ac2f1e73d46428de81a6130a6fdad</tenantId> + <vnfCreated>true</vnfCreated> + <vnfId>slcp34248vbc/020a112b-a0c8-4143-87a3-698680ba2efe</vnfId> + </rollback> +</ns2:createVnfNotification> + </soapenv:Body> +</soapenv:Envelope> diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/vnfAdapterMocks/vnfDeleteSimResponse.xml b/bpmn/MSOCommonBPMN/src/test/resources/__files/vnfAdapterMocks/vnfDeleteSimResponse.xml new file mode 100644 index 0000000000..a4b0becee4 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/vnfAdapterMocks/vnfDeleteSimResponse.xml @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="UTF-8"?> +<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" + xmlns:v1="http://org.openecomp.mso/vnfNotify"> + <soapenv:Header /> + <soapenv:Body> + <ns2:deleteVnfNotification xmlns:ns2="http://org.openecomp.mso/vnfNotify" > + <messageId>f5e42814-72c0-4422-b840-e14e757a709b</messageId> + <completed>true</completed> + </ns2:deleteVnfNotification> + </soapenv:Body> +</soapenv:Envelope>
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/vnfAdapterMocks/vnfQuerySimResponse.xml b/bpmn/MSOCommonBPMN/src/test/resources/__files/vnfAdapterMocks/vnfQuerySimResponse.xml new file mode 100644 index 0000000000..3b99363ea8 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/vnfAdapterMocks/vnfQuerySimResponse.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="UTF-8"?> +<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" + xmlns:v1="http://org.openecomp.mso/vnfNotify"> + <soapenv:Header /> + <soapenv:Body> + <ns2:queryVnfNotification xmlns:ns2="http://org.openecomp.mso/vnfNotify"> + <messageId>b1a82ce6-7f5c-45fd-9273-acaf88fc2222</messageId> + <completed>true</completed> + <vnfExists>true</vnfExists> + <vnfId>slcp34248vbc/020a112b-a0c8-4143-87a3-698680ba2efe</vnfId> + <status>ACTIVE</status> + <outputs> + <entry> + <key>server_ip</key> + <value>135.21.249.144</value> + </entry> + </outputs> +</ns2:queryVnfNotification> + </soapenv:Body> +</soapenv:Envelope> diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/vnfAdapterMocks/vnfRollbackSimResponse.xml b/bpmn/MSOCommonBPMN/src/test/resources/__files/vnfAdapterMocks/vnfRollbackSimResponse.xml new file mode 100644 index 0000000000..4fd0b62610 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/vnfAdapterMocks/vnfRollbackSimResponse.xml @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="UTF-8"?> +<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" + xmlns:v1="http://org.openecomp.mso/vnfNotify"> + <soapenv:Header /> + <soapenv:Body> + <ns2:rollbackVnfNotification xmlns:ns2="http://org.openecomp.mso/vnfNotify" > + <messageId>b1a82ce6-7f5c-45fd-9273-acaf88fc2137</messageId> + <completed>true</completed> + </ns2:rollbackVnfNotification> + </soapenv:Body> +</soapenv:Envelope>
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/camunda.cfg.xml b/bpmn/MSOCommonBPMN/src/test/resources/camunda.cfg.xml new file mode 100644 index 0000000000..c94e32e686 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/camunda.cfg.xml @@ -0,0 +1,61 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<beans xmlns="http://www.springframework.org/schema/beans" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> + + <bean id="processEngineConfiguration" class="org.camunda.bpm.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration"> + + <property name="jdbcUrl" value="jdbc:h2:mem:camunda;DB_CLOSE_DELAY=1000" /> + <property name="jdbcDriver" value="org.h2.Driver" /> + <property name="jdbcUsername" value="sa" /> + <property name="jdbcPassword" value="" /> + + <!-- Database configurations --> + <property name="databaseSchemaUpdate" value="true" /> + + <!-- job executor configurations --> + <property name="jobExecutorActivate" value="true" /> + + <property name="history" value="full" /> + + <property name="customPostBPMNParseListeners"> + <list> + <bean class="org.camunda.bpm.engine.impl.bpmn.parser.FoxFailedJobParseListener" /> + </list> + </property> + + <property name="failedJobCommandFactory" ref="foxFailedJobCommandFactory" /> + + <!--<property name="idGenerator" ref="uuidGenerator" />--> + + <!-- engine plugins --> + <property name="processEnginePlugins"> + <list> + <ref bean="connectProcessEnginePlugin" /> + <ref bean="spinProcessEnginePlugin" /> + <ref bean="loggingPlugin" /> + <ref bean="workflowExceptionPlugin" /> + <ref bean="workbenchPlugin" /> + </list> + </property> + </bean> + + <bean id="workbenchPlugin" class="org.camunda.bpm.debugger.server.EmbeddableDebugWebsocketBootstrap"> + <property name="httpPort" value="28088"/> + </bean> + + <bean id="loggingPlugin" class="org.openecomp.mso.bpmn.core.plugins.LoggingAndURNMappingPlugin" /> + + <!-- Needed until all subflows generate MSOWorkflowException events --> + <bean id="workflowExceptionPlugin" class="org.openecomp.mso.bpmn.core.plugins.WorkflowExceptionPlugin" /> + + <bean id="foxFailedJobCommandFactory" class="org.camunda.bpm.engine.impl.jobexecutor.FoxFailedJobCommandFactory" /> + + <!--<bean id="uuidGenerator" class="org.camunda.bpm.engine.impl.persistence.StrongUuidGenerator" />--> + + <!-- engine plugin beans --> + <bean id="connectProcessEnginePlugin" class="org.camunda.connect.plugin.impl.ConnectProcessEnginePlugin" /> + <bean id="spinProcessEnginePlugin" class="org.camunda.spin.plugin.impl.SpinProcessEnginePlugin" /> + +</beans> diff --git a/bpmn/MSOCommonBPMN/src/test/resources/logging.properties b/bpmn/MSOCommonBPMN/src/test/resources/logging.properties new file mode 100644 index 0000000000..4941c55971 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/logging.properties @@ -0,0 +1,2 @@ +#register SLF4JBridgeHandler as handler for the j.u.l. root logger +handlers = org.slf4j.bridge.SLF4JBridgeHandler diff --git a/bpmn/MSOCommonBPMN/src/test/resources/mso.bpmn.properties b/bpmn/MSOCommonBPMN/src/test/resources/mso.bpmn.properties new file mode 100644 index 0000000000..f800d00245 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/mso.bpmn.properties @@ -0,0 +1,3 @@ +# Default BPMN properties for unit tests + +URNMapping.FileSystemLoading.Enabled=true
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/mso.bpmn.urn.properties b/bpmn/MSOCommonBPMN/src/test/resources/mso.bpmn.urn.properties new file mode 100644 index 0000000000..f1a82225ff --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/mso.bpmn.urn.properties @@ -0,0 +1,86 @@ +# Default URN Mappings for unit tests + +mso.rollback=true + +canopi.auth=757A94191D685FD2092AC1490730A4FC +csi.aots.addincidentmanagement.endpoint=http://localhost:28090/AddIncidentManagementTicketRequest +csi.networkstatus.endpoint=http://localhost:28090/SendManagedNetworkStatusNotification +mso.csi.pwd=4EA237303511EFBBC37F17A351562131 +mso.csi.usrname=mso +mso.msoKey=07a7159d3bf51a0e53be7a8f89699be7 + +mso.adapters.completemsoprocess.endpoint=http://localhost:28090/CompleteMsoProcess + +mso.adapters.db.endpoint=http://localhost:28090/dbadapters/RequestsDbAdapter +mso.adapters.db.auth=757A94191D685FD2092AC1490730A4FC + +mso.adapters.network.endpoint=http://localhost:28090/networks/NetworkAdapter +mso.adapters.network.rest.endpoint=http://localhost:28090/networks/NetworkAdapter + +mso.adapters.po.auth=757A94191D685FD2092AC1490730A4FC +mso.adapters.po.password=3141634BF7E070AA289CF2892C986C0B +mso.po.timeout=PT60S + +aai.auth=757A94191D685FD2092AC1490730A4FC + +mso.adapters.sdnc.endpoint=http://localhost:28090/SDNCAdapter +mso.adapters.sdnc.rest.endpoint=http://localhost:28090/SDNCAdapter/v1/sdnc +mso.adapters.sdnc.timeout=PT60S +mso.sdnc.firewall.yang.model=http://com/openecomp/svc/mis/firewall-lite-gui +mso.sdnc.firewall.yang.model.version=2015-05-15 +mso.sdnc.password=3141634BF7E070AA289CF2892C986C0B +mso.sdnc.timeout.firewall.minutes=20 +mso.callbackRetryAttempts=5 +mso.sdnc.timeout=PT10S +mso.sdnc.timeout.ucpe.async.hours=120 +mso.sdnc.timeout.ucpe.async.minutes=5 +mso.workflow.message.endpoint=http://localhost:28080/mso/WorkflowMesssage +mso.workflow.sdncadapter.callback=http://localhost:28080/mso/SDNCAdapterCallbackService + +mso.catalog.db.endpoint=http://localhost:28090/ + +mso.adapters.tenant.endpoint=http://localhost:28090/tenantAdapterMock +mso.adapters.vnf-async.endpoint=http://localhost:28090/vnfs/VnfAdapterAsync +mso.adapters.vnf.endpoint=http://localhost:28090/vnfs/VnfAdapter +mso.adapters.vnf.rest.endpoint=http://localhost:28090/vnfs/v1/vnfs +mso.workflow.vnfadapter.create.callback=http://localhost:28080/mso/vnfAdapterNotify +mso.workflow.vnfadapter.delete.callback=http://localhost:28080/mso/vnfAdapterNotify +mso.workflow.vnfadapter.query.callback=http://localhost:28080/mso/services/VNFAdapterQuerCallbackV1 +mso.workflow.vnfadapter.rollback.callback=http://localhost:28080/mso/vnfAdapterNotify +mso.workflow.createvce.delay.seconds=1 +mso.infra.customer.id=testCustIdInfra + +aai.endpoint=http://localhost:28090 + +# AAI version mappings + +# Example to override default version for a resource: +#mso.workflow.default.aai.vce.version=6 +#mso.workflow.default.aai.v6.vce.uri=/aai/v6/network/vces/vce + +mso.workflow.global.default.aai.version=8 +mso.workflow.default.aai.cloud-region.version=9 +mso.workflow.default.aai.generic-vnf.version=9 + +mso.workflow.default.aai.v9.cloud-region.uri=/aai/v9/cloud-infrastructure/cloud-regions/cloud-region/att-aic +mso.workflow.default.aai.v8.customer.uri=/aai/v8/business/customers/customer +mso.workflow.default.aai.v8.generic-query.uri=/aai/v8/search/generic-query +mso.workflow.default.aai.v9.generic-vnf.uri=/aai/v9/network/generic-vnfs/generic-vnf +mso.workflow.default.aai.v8.l3-network.uri=/aai/v8/network/l3-networks/l3-network +mso.workflow.default.aai.v8.network-policy.uri=/aai/v8/network/network-policies/network-policy +mso.workflow.default.aai.v8.nodes-query.uri=/aai/v8/search/nodes-query +mso.workflow.default.aai.v8.route-table-reference.uri=/aai/v8/network/route-table-references/route-table-reference +mso.workflow.default.aai.v8.tenant.uri=/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25/tenants/tenant +mso.workflow.default.aai.v8.vce.uri=/aai/v8/network/vces/vce +mso.workflow.default.aai.v8.vpn-binding.uri=/aai/v8/network/vpn-bindings/vpn-binding + + +log.debug.CompleteMsoProcess=true +log.debug.CreateNetworkInstanceInfra=true +log.debug.CreateServiceInstanceInfra=true +log.debug.DeleteNetworkInstanceInfra=true +log.debug.FalloutHandler=true +log.debug.GenericGetService=true +log.debug.sdncAdapter=true +log.debug.UpdateNetworkInstanceInfra=true +log.debug.VnfAdapterRestV1=true
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/sdncCallbackErrorResponse.xml b/bpmn/MSOCommonBPMN/src/test/resources/sdncCallbackErrorResponse.xml new file mode 100644 index 0000000000..df3a4c42e5 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/sdncCallbackErrorResponse.xml @@ -0,0 +1 @@ +<SDNCAdapterCallbackRequest xmlns="http://org.openecomp/workflow/sdnc/adapter/schema/v1"><CallbackHeader><RequestId>1a152f97-566e-4f22-b17b-761f807bfedc</RequestId><ResponseCode>404</ResponseCode><ResponseMessage>Error processing request to SDNC. Not Found. https://sdncodl.it.us.aic.cip.att.com:8443/restconf/config/L3SDN-API:services/layer3-service-list/AS%2FVLXM%2F000199%2F%2FSB_INTERNET. SDNC Returned-[error-type:application, error-tag:data-missing, error-message:Request could not be completed because the relevant data model content does not exist.]</ResponseMessage></CallbackHeader></SDNCAdapterCallbackRequest>
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/sdncDeleteResponse.xml b/bpmn/MSOCommonBPMN/src/test/resources/sdncDeleteResponse.xml new file mode 100644 index 0000000000..d656d04187 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/sdncDeleteResponse.xml @@ -0,0 +1,212 @@ +<?xml version="1.0" encoding="UTF-8"?> +<sdncadapterworkflow:SDNCAdapterWorkflowResponse + xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"> + <sdncadapterworkflow:response-data> + <tag0:RequestData + xmlns:tag0="http://org.openecomp/workflow/sdnc/adapter/schema/v1" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xs:string"> + <output xmlns="com:att:sdnctl:nbncapi"> + <ack-final-indicator>Y</ack-final-indicator> + <svc-request-id>SK-2016-10-22-001</svc-request-id> + <nbnc-response-information> + <response-info> + <result>SUCCESS</result> + <aai-status>ERROR</aai-status> + </response-info> + <virtual-datacenter-list> + <vdc-id>15001417</vdc-id> + <router-list> + <router-name>ALPRTR2</router-name> + <ipe-loopback-address>1.1.1.2</ipe-loopback-address> + <vlan-list> + <vlan-id>1255.ae81</vlan-id> + <border-element-type>VDBE</border-element-type> + <border-element-tangibility>VIRTUAL</border-element-tangibility> + <port-id></port-id> + <border-element-id>ALPVDBE1</border-element-id> + <border-element-v4-subnet>3.1.1.0/22</border-element-v4-subnet> + <lag-id>ae81</lag-id> + <border-element-v6-subnet>3:1:1::0/22</border-element-v6-subnet> + </vlan-list> + <vlan-list> + <vlan-id>1995.ae81</vlan-id> + <border-element-type>ASBG</border-element-type> + <border-element-tangibility>VIRTUAL</border-element-tangibility> + <port-id></port-id> + <border-element-id>ALPASBG1</border-element-id> + <border-element-v4-subnet>3.1.1.0/22</border-element-v4-subnet> + <lag-id>ae81</lag-id> + <border-element-v6-subnet>3:1:1::0/22</border-element-v6-subnet> + </vlan-list> + <vlan-list> + <vlan-id>85.xe-10/0/2</vlan-id> + <border-element-type>BGF2</border-element-type> + <border-element-tangibility>PHYSICAL</border-element-tangibility> + <port-id>xe-10/0/2</port-id> + <border-element-id>ALPBGF2</border-element-id> + <border-element-v4-subnet>3.1.2.0/22</border-element-v4-subnet> + <lag-id></lag-id> + <border-element-v6-subnet>3:1:2::0/22</border-element-v6-subnet> + </vlan-list> + <vlan-list> + <vlan-id>85.xe-10/0/1</vlan-id> + <border-element-type>BGF1</border-element-type> + <border-element-tangibility>PHYSICAL</border-element-tangibility> + <port-id>xe-10/0/1</port-id> + <border-element-id>ALPBGF1</border-element-id> + <border-element-v4-subnet>3.1.2.0/22</border-element-v4-subnet> + <lag-id></lag-id> + <border-element-v6-subnet>3:1:2::0/22</border-element-v6-subnet> + </vlan-list> + <ipe-id>2</ipe-id> + </router-list> + <router-list> + <router-name>ALPRTR1</router-name> + <ipe-loopback-address>1.1.1.1</ipe-loopback-address> + <vlan-list> + <vlan-id>1255.ae81</vlan-id> + <border-element-type>VDBE</border-element-type> + <border-element-tangibility>VIRTUAL</border-element-tangibility> + <port-id></port-id> + <border-element-id>ALPVDBE1</border-element-id> + <border-element-v4-subnet>3.1.1.0/22</border-element-v4-subnet> + <lag-id>ae81</lag-id> + <border-element-v6-subnet>3:1:1::0/22</border-element-v6-subnet> + </vlan-list> + <vlan-list> + <vlan-id>1995.ae81</vlan-id> + <border-element-type>ASBG</border-element-type> + <border-element-tangibility>VIRTUAL</border-element-tangibility> + <port-id></port-id> + <border-element-id>ALPASBG1</border-element-id> + <border-element-v4-subnet>3.1.1.0/22</border-element-v4-subnet> + <lag-id>ae81</lag-id> + <border-element-v6-subnet>3:1:1::0/22</border-element-v6-subnet> + </vlan-list> + <vlan-list> + <vlan-id>85.xe-10/0/2</vlan-id> + <border-element-type>BGF2</border-element-type> + <border-element-tangibility>PHYSICAL</border-element-tangibility> + <port-id>xe-10/0/2</port-id> + <border-element-id>ALPBGF2</border-element-id> + <border-element-v4-subnet>3.1.2.0/22</border-element-v4-subnet> + <lag-id></lag-id> + <border-element-v6-subnet>3:1:2::0/22</border-element-v6-subnet> + </vlan-list> + <vlan-list> + <vlan-id>85.xe-10/0/1</vlan-id> + <border-element-type>BGF1</border-element-type> + <border-element-tangibility>PHYSICAL</border-element-tangibility> + <port-id>xe-10/0/1</port-id> + <border-element-id>ALPBGF1</border-element-id> + <border-element-v4-subnet>3.1.2.0/22</border-element-v4-subnet> + <lag-id></lag-id> + <border-element-v6-subnet>3:1:2::0/22</border-element-v6-subnet> + </vlan-list> + <ipe-id>1</ipe-id> + </router-list> + </virtual-datacenter-list> + <virtual-datacenter-list> + <vdc-id>15001418</vdc-id> + <router-list> + <router-name>SANRTR1</router-name> + <ipe-loopback-address>2.1.1.1</ipe-loopback-address> + <vlan-list> + <vlan-id>1255.ae81</vlan-id> + <border-element-type>VDBE</border-element-type> + <border-element-tangibility>VIRTUAL</border-element-tangibility> + <port-id></port-id> + <border-element-id>SANVDBE1</border-element-id> + <border-element-v4-subnet>4.1.1.0/22</border-element-v4-subnet> + <lag-id>ae81</lag-id> + <border-element-v6-subnet>4:1:1::0/22</border-element-v6-subnet> + </vlan-list> + <vlan-list> + <vlan-id>1995.ae81</vlan-id> + <border-element-type>ASBG</border-element-type> + <border-element-tangibility>VIRTUAL</border-element-tangibility> + <port-id></port-id> + <border-element-id>SANASBG1</border-element-id> + <border-element-v4-subnet>4.1.1.0/22</border-element-v4-subnet> + <lag-id>ae81</lag-id> + <border-element-v6-subnet>4:1:1::0/22</border-element-v6-subnet> + </vlan-list> + <vlan-list> + <vlan-id>85.xe-10/0/2</vlan-id> + <border-element-type>BGF2</border-element-type> + <border-element-tangibility>PHYSICAL</border-element-tangibility> + <port-id>xe-10/0/2</port-id> + <border-element-id>SANBGF2</border-element-id> + <border-element-v4-subnet>4.1.2.0/22</border-element-v4-subnet> + <lag-id></lag-id> + <border-element-v6-subnet>4:1:2::0/22</border-element-v6-subnet> + </vlan-list> + <vlan-list> + <vlan-id>85.xe-10/0/1</vlan-id> + <border-element-type>BGF1</border-element-type> + <border-element-tangibility>PHYSICAL</border-element-tangibility> + <port-id>xe-10/0/1</port-id> + <border-element-id>SANBGF1</border-element-id> + <border-element-v4-subnet>4.1.2.0/22</border-element-v4-subnet> + <lag-id></lag-id> + <border-element-v6-subnet>4:1:2::0/22</border-element-v6-subnet> + </vlan-list> + <ipe-id>1</ipe-id> + </router-list> + <router-list> + <router-name>SANRTR2</router-name> + <ipe-loopback-address>2.1.1.2</ipe-loopback-address> + <vlan-list> + <vlan-id>1255.ae81</vlan-id> + <border-element-type>VDBE</border-element-type> + <border-element-tangibility>VIRTUAL</border-element-tangibility> + <port-id></port-id> + <border-element-id>SANVDBE1</border-element-id> + <border-element-v4-subnet>4.1.1.0/22</border-element-v4-subnet> + <lag-id>ae81</lag-id> + <border-element-v6-subnet>4:1:1::0/22</border-element-v6-subnet> + </vlan-list> + <vlan-list> + <vlan-id>1995.ae81</vlan-id> + <border-element-type>ASBG</border-element-type> + <border-element-tangibility>VIRTUAL</border-element-tangibility> + <port-id></port-id> + <border-element-id>SANASBG1</border-element-id> + <border-element-v4-subnet>4.1.1.0/22</border-element-v4-subnet> + <lag-id>ae81</lag-id> + <border-element-v6-subnet>4:1:1::0/22</border-element-v6-subnet> + </vlan-list> + <vlan-list> + <vlan-id>85.xe-10/0/2</vlan-id> + <border-element-type>BGF2</border-element-type> + <border-element-tangibility>PHYSICAL</border-element-tangibility> + <port-id>xe-10/0/2</port-id> + <border-element-id>SANBGF2</border-element-id> + <border-element-v4-subnet>4.1.2.0/22</border-element-v4-subnet> + <lag-id></lag-id> + <border-element-v6-subnet>4:1:2::0/22</border-element-v6-subnet> + </vlan-list> + <vlan-list> + <vlan-id>85.xe-10/0/1</vlan-id> + <border-element-type>BGF1</border-element-type> + <border-element-tangibility>PHYSICAL</border-element-tangibility> + <port-id>xe-10/0/1</port-id> + <border-element-id>SANBGF1</border-element-id> + <border-element-v4-subnet>4.1.2.0/22</border-element-v4-subnet> + <lag-id></lag-id> + <border-element-v6-subnet>4:1:2::0/22</border-element-v6-subnet> + </vlan-list> + <ipe-id>2</ipe-id> + </router-list> + </virtual-datacenter-list> + <service-type>ATT-COLLABORATE</service-type> + <interface-status>DISABLE</interface-status> + <customer-id>custid-888</customer-id> + <service-instance-id>SII-2016-10-22-001</service-instance-id> + <provision-type>CUSTOMER</provision-type> + <vni-id>100668</vni-id> + </nbnc-response-information> + </output> + </tag0:RequestData> + </sdncadapterworkflow:response-data> +</sdncadapterworkflow:SDNCAdapterWorkflowResponse>
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/sdncadaptercallbackrequest.xml b/bpmn/MSOCommonBPMN/src/test/resources/sdncadaptercallbackrequest.xml new file mode 100644 index 0000000000..89e4fef705 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/sdncadaptercallbackrequest.xml @@ -0,0 +1,342 @@ +<SDNCAdapterCallbackRequest xmlns="http://org.openecomp/workflow/sdnc/adapter/schema/v1"> + <CallbackHeader> + <RequestId>2f7d1b38-2b78-4ef2-8ad6-1552d88620fa</RequestId> + <ResponseCode>200</ResponseCode> + <ResponseMessage>OK</ResponseMessage> + </CallbackHeader> + <RequestData xsi:type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <layer3-service-list xmlns="com:att:sdnctl:l3api"> + <service-instance-id>FK/VLXM/003717//SW_INTERNET</service-instance-id> + <service-status> + <rpc-name>service-configuration-operation</rpc-name> + <rpc-action>activate</rpc-action> + <request-status>synccomplete</request-status> + <final-indicator>N</final-indicator> + <l3sdn-action>Layer3ServiceActivateRequest</l3sdn-action> + <l3sdn-subaction>SUPP</l3sdn-subaction> + <response-timestamp>2015-04-28T21:32:11.386Z</response-timestamp> + </service-status> + <service-data> + <internet-evc-access-information> + <ip-version>ds</ip-version> + <internet-evc-speed-value>8</internet-evc-speed-value> + <internet-evc-speed-units>Mbps</internet-evc-speed-units> + </internet-evc-access-information> + <vr-lan xmlns="com:att:sdnctl:l3api"> + <vr-lan-interface> + <static-routes> + <v6-static-routes> + <v6-next-hop-address>2001:1890:12e3:2da::</v6-next-hop-address> + <v6-static-route-prefix>2001:1890:12e3:2da::</v6-static-route-prefix> + <v6-static-route-prefix-length>28</v6-static-route-prefix-length> + </v6-static-routes> + <v4-static-routes> + <v4-static-route-prefix>255.255.252.1</v4-static-route-prefix> + <v4-next-hop-address>192.168.1.15</v4-next-hop-address> + <v4-static-route-prefix-length>28</v4-static-route-prefix-length> + </v4-static-routes> + <v6-static-routes> + <v6-next-hop-address>2001:1890:12e3:2da::</v6-next-hop-address> + <v6-static-route-prefix>2001:1890:12e3:2da::</v6-static-route-prefix> + <v6-static-route-prefix-length>28</v6-static-route-prefix-length> + </v6-static-routes> + <v4-static-routes> + <v4-static-route-prefix>255.255.252.2</v4-static-route-prefix> + <v4-next-hop-address>192.168.1.15</v4-next-hop-address> + <v4-static-route-prefix-length>28</v4-static-route-prefix-length> + </v4-static-routes> + <v4-static-routes> + <v4-static-route-prefix>255.255.252.3</v4-static-route-prefix> + <v4-next-hop-address>192.168.1.15</v4-next-hop-address> + <v4-static-route-prefix-length>28</v4-static-route-prefix-length> + </v4-static-routes> + </static-routes> + <dhcp> + <v6-dhcp-server-enabled>N</v6-dhcp-server-enabled> + <v4-dhcp-server-enabled>Y</v4-dhcp-server-enabled> + <use-v6-default-pool>N</use-v6-default-pool> + <excluded-v4-dhcp-addresses-from-default-pool> + <excluded-v4-address>192.168.1.7</excluded-v4-address> + </excluded-v4-dhcp-addresses-from-default-pool> + <excluded-v4-dhcp-addresses-from-default-pool> + <excluded-v4-address>192.168.1.8</excluded-v4-address> + </excluded-v4-dhcp-addresses-from-default-pool> + <v4-dhcp-pools> + <v4-dhcp-relay-next-hop-address>1.1.1.1</v4-dhcp-relay-next-hop-address> + <v4-dhcp-pool-prefix-length>28</v4-dhcp-pool-prefix-length> + <excluded-v4-addresses> + <excluded-v4-address>192.168.1.5</excluded-v4-address> + </excluded-v4-addresses> + <v4-dhcp-relay-gateway-address>2.2.2.1</v4-dhcp-relay-gateway-address> + <excluded-v4-addresses> + <excluded-v4-address>192.168.1.6</excluded-v4-address> + </excluded-v4-addresses> + <v4-dhcp-pool-prefix>192.155.2.3</v4-dhcp-pool-prefix> + </v4-dhcp-pools> + <v4-dhcp-pools> + <v4-dhcp-relay-next-hop-address>1.1.1.2</v4-dhcp-relay-next-hop-address> + <v4-dhcp-pool-prefix-length>28</v4-dhcp-pool-prefix-length> + <excluded-v4-addresses> + <excluded-v4-address>192.168.1.6</excluded-v4-address> + </excluded-v4-addresses> + <v4-dhcp-relay-gateway-address>2.2.2.2</v4-dhcp-relay-gateway-address> + <excluded-v4-addresses> + <excluded-v4-address>192.168.1.7</excluded-v4-address> + </excluded-v4-addresses> + <v4-dhcp-pool-prefix>192.155.2.4</v4-dhcp-pool-prefix> + </v4-dhcp-pools> + <use-v4-default-pool>Y</use-v4-default-pool> + <excluded-v6-dhcp-addresses-from-default-pool> + <excluded-v6-address>1:5</excluded-v6-address> + </excluded-v6-dhcp-addresses-from-default-pool> + <excluded-v6-dhcp-addresses-from-default-pool> + <excluded-v6-address>1:6</excluded-v6-address> + </excluded-v6-dhcp-addresses-from-default-pool> + <v6-dhcp-pools> + <v6-dhcp-relay-next-hop-address>4:4</v6-dhcp-relay-next-hop-address> + <v6-dhcp-pool-prefix-length>28</v6-dhcp-pool-prefix-length> + <excluded-v6-addresses> + <excluded-v6-address>1:1</excluded-v6-address> + </excluded-v6-addresses> + <v6-dhcp-relay-gateway-address>3:3</v6-dhcp-relay-gateway-address> + <excluded-v6-addresses> + <excluded-v6-address>2:2</excluded-v6-address> + </excluded-v6-addresses> + <v6-dhcp-pool-prefix>0:0</v6-dhcp-pool-prefix> + </v6-dhcp-pools> + <v6-dhcp-pools> + <v6-dhcp-relay-next-hop-address>4:4</v6-dhcp-relay-next-hop-address> + <v6-dhcp-pool-prefix-length>28</v6-dhcp-pool-prefix-length> + <excluded-v6-addresses> + <excluded-v6-address>1:1</excluded-v6-address> + </excluded-v6-addresses> + <v6-dhcp-relay-gateway-address>3:3</v6-dhcp-relay-gateway-address> + <excluded-v6-addresses> + <excluded-v6-address>2:2</excluded-v6-address> + </excluded-v6-addresses> + <v6-dhcp-pool-prefix>0:0</v6-dhcp-pool-prefix> + </v6-dhcp-pools> + </dhcp> + <firewall-lite> + <stateful-firewall-lite-v6-enabled>N</stateful-firewall-lite-v6-enabled> + <stateful-firewall-lite-v4-enabled>Y</stateful-firewall-lite-v4-enabled> + <v4-firewall-packet-filters> + <v4-firewall-prefix>0.0.0.1</v4-firewall-prefix> + <v4-firewall-prefix-length>1</v4-firewall-prefix-length> + <allow-icmp-ping>Y</allow-icmp-ping> + <udp-ports> + <port-number>1</port-number> + </udp-ports> + <tcp-ports> + <port-number>1</port-number> + </tcp-ports> + </v4-firewall-packet-filters> + <v4-firewall-packet-filters> + <v4-firewall-prefix>0.0.0.2</v4-firewall-prefix> + <v4-firewall-prefix-length>2</v4-firewall-prefix-length> + <allow-icmp-ping>Y</allow-icmp-ping> + <udp-ports> + <port-number>2</port-number> + </udp-ports> + <tcp-ports> + <port-number>2</port-number> + </tcp-ports> + </v4-firewall-packet-filters> + <v6-firewall-packet-filters> + <v6-firewall-prefix>:</v6-firewall-prefix> + <v6-firewall-prefix-length>0</v6-firewall-prefix-length> + <allow-icmp-ping>Y</allow-icmp-ping> + <udp-ports> + <port-number>3</port-number> + </udp-ports> + <tcp-ports> + <port-number>3</port-number> + </tcp-ports> + </v6-firewall-packet-filters> + <v6-firewall-packet-filters> + <v6-firewall-prefix>:</v6-firewall-prefix> + <v6-firewall-prefix-length>1</v6-firewall-prefix-length> + <allow-icmp-ping>Y</allow-icmp-ping> + <udp-ports> + <port-number>4</port-number> + </udp-ports> + <tcp-ports> + <port-number>4</port-number> + </tcp-ports> + </v6-firewall-packet-filters> + </firewall-lite> + <pat> + <v4-pat-pools> + <v4-pat-pool-prefix>192.168.1.44</v4-pat-pool-prefix> + <v4-pat-pool-next-hop-address>192.168.1.5</v4-pat-pool-next-hop-address> + <v4-pat-pool-prefix-length>0</v4-pat-pool-prefix-length> + </v4-pat-pools> + <use-v4-default-pool>Y</use-v4-default-pool> + <v4-pat-enabled>N</v4-pat-enabled> + <v4-pat-pools> + <v4-pat-pool-prefix>192.168.1.45</v4-pat-pool-prefix> + <v4-pat-pool-next-hop-address>192.168.1.6</v4-pat-pool-next-hop-address> + <v4-pat-pool-prefix-length>28</v4-pat-pool-prefix-length> + </v4-pat-pools> + </pat> + <nat> + <v4-nat-enabled>Y</v4-nat-enabled> + <v4-nat-mapping-entries> + <v4-nat-internal>0.0.0.0</v4-nat-internal> + <v4-nat-next-hop-address>0.0.0.0</v4-nat-next-hop-address> + <v4-nat-external>0.0.0.0</v4-nat-external> + </v4-nat-mapping-entries> + <v4-nat-mapping-entries> + <v4-nat-internal>0.0.0.1</v4-nat-internal> + <v4-nat-next-hop-address>0.0.0.1</v4-nat-next-hop-address> + <v4-nat-external>0.0.0.1</v4-nat-external> + </v4-nat-mapping-entries> + </nat> + <vr-designation>primary</vr-designation> + <v4-vce-loopback-address>162.200.3.144</v4-vce-loopback-address> + <v6-vr-lan-prefix-length>64</v6-vr-lan-prefix-length> + <v6-vce-wan-address>2001:1890:12e3:2da::</v6-vce-wan-address> + <v6-vr-lan-prefix>2620:0:10d0:f:ffff:ffff:ffff:fffe</v6-vr-lan-prefix> + <v4-vr-lan-prefix-length>24</v4-vr-lan-prefix-length> + <v4-vr-lan-prefix>10.192.27.254</v4-vr-lan-prefix> + <v4-public-lan-prefixes> + <t-provided-v4-lan-public-prefixes> + <request-index>1</request-index> + <v4-next-hop-address>192.168.1.2</v4-next-hop-address> + <v4-lan-public-prefix>192.168.1.1</v4-lan-public-prefix> + <v4-lan-public-prefix-length>28</v4-lan-public-prefix-length> + </t-provided-v4-lan-public-prefixes> + <t-provided-v4-lan-public-prefixes> + <request-index>1</request-index> + <v4-next-hop-address>192.168.1.72</v4-next-hop-address> + <v4-lan-public-prefix>192.168.1.71</v4-lan-public-prefix> + <v4-lan-public-prefix-length>28</v4-lan-public-prefix-length> + </t-provided-v4-lan-public-prefixes> + <t-provided-v4-lan-public-prefixes> + <request-index>1</request-index> + <v4-next-hop-address>192.168.1.68</v4-next-hop-address> + <v4-lan-public-prefix>192.168.1.67</v4-lan-public-prefix> + <v4-lan-public-prefix-length>28</v4-lan-public-prefix-length> + </t-provided-v4-lan-public-prefixes> + </v4-public-lan-prefixes> + <v6-public-lan-prefixes> + <t-provided-v6-lan-public-prefixes> + <request-index>1</request-index> + <v6-next-hop-address>2001:1890:12e3:2da::</v6-next-hop-address> + <v6-lan-public-prefix>2001:1890:12e3:2da::</v6-lan-public-prefix> + <v6-lan-public-prefix-length>28</v6-lan-public-prefix-length> + </t-provided-v6-lan-public-prefixes> + <t-provided-v6-lan-public-prefixes> + <request-index>1</request-index> + <v6-next-hop-address>2001:1890:12e3:2da::</v6-next-hop-address> + <v6-lan-public-prefix>2001:1890:12e3:3da::</v6-lan-public-prefix> + <v6-lan-public-prefix-length>28</v6-lan-public-prefix-length> + </t-provided-v6-lan-public-prefixes> + <t-provided-v6-lan-public-prefixes> + <request-index>1</request-index> + <v6-next-hop-address>2001:1890:12e3:2da::</v6-next-hop-address> + <v6-lan-public-prefix>2001:1890:12e3:4da::</v6-lan-public-prefix> + <v6-lan-public-prefix-length>28</v6-lan-public-prefix-length> + </t-provided-v6-lan-public-prefixes> + </v6-public-lan-prefixes> + </vr-lan-interface> + <routing-protocol>none</routing-protocol> + </vr-lan> +<ucpe-vms-service-information> + <transport-service-information> + <transport-service-type>AVPN</transport-service-type> + <access-circuit-info> + <access-circuit-id>1</access-circuit-id> + <dual-mode>Active</dual-mode> + </access-circuit-info> + <access-circuit-info> + <access-circuit-id>2</access-circuit-id> + <dual-mode>Standby</dual-mode> + </access-circuit-info> + </transport-service-information> + <ucpe-information> + <ucpe-host-name>hostname</ucpe-host-name> + <ucpe-activation-code>activecode</ucpe-activation-code> + <out-of-band-management-modem>OOB</out-of-band-management-modem> + </ucpe-information> + <vnf-list> + <vnf-information> + <vnf-instance-id>1</vnf-instance-id> + <vnf-sequence-number>1</vnf-sequence-number> + <vnf-type>ZZ</vnf-type> + <vnf-vendor>JUNIPER</vnf-vendor> + <vnf-model>MODEL1</vnf-model> + <vnf-id>1</vnf-id> + <prov-status>1</prov-status> + <operational-state>1</operational-state> + <orchestration-status>1</orchestration-status> + <equipment-role>1</equipment-role> + </vnf-information> + <vnf-information> + <vnf-instance-id>2</vnf-instance-id> + <vnf-sequence-number>2</vnf-sequence-number> + <vnf-type>HY</vnf-type> + <vnf-vendor>JUNIPER</vnf-vendor> + <vnf-model>MODEL2</vnf-model> + <vnf-id>2</vnf-id> + <prov-status>2</prov-status> + <operational-state>2</operational-state> + <orchestration-status>2</orchestration-status> + <equipment-role>2</equipment-role> + </vnf-information> + </vnf-list> + </ucpe-vms-service-information> + <request-information> + <request-action>Layer3ServiceActivateRequest</request-action> + <order-number>4281555</order-number> + <request-id>155415ab-b4a7-4382-b4c6-d17d9sm42855</request-id> + <notification-url>https://csi-tst-q22.it.att.com:22443/Services/com/cingular/csi/sdn/SendManagedNetworkStatusNotification.jws</notification-url> + <source>OMX</source> + <order-version>1</order-version> + </request-information> + <sdnc-request-header> + <svc-action>activate</svc-action> + <svc-notification-url>https://msojra.mtsnjdcp1.aic.cip.att.com:8443/adapters/rest/SDNCNotify</svc-notification-url> + <svc-request-id>5b1f3c5d-cdf9-488d-8a4b-d3f1229d7760</svc-request-id> + </sdnc-request-header> + <l2-homing-information> + <topology>MultiPoint</topology> + <preferred-aic-clli>MTSNJA4LCP1</preferred-aic-clli> + <evc-name>AS/VLXM/003717//SW</evc-name> + </l2-homing-information> + <service-information> + <service-instance-id>FK/VLXM/003717//SW_INTERNET</service-instance-id> + <subscriber-name>FOUR SEASONS HEATING & COOLING_8310006378683</subscriber-name> + <service-type>SDN-ETHERNET-INTERNET</service-type> + </service-information> + <internet-service-change-details> + <internet-evc-speed-value>10</internet-evc-speed-value> + <internet-evc-speed-units>Kbps</internet-evc-speed-units> + <t-provided-v4-lan-public-prefixes> + <request-index>1</request-index> + <v4-next-hop-address>192.168.1.15</v4-next-hop-address> + <v4-lan-public-prefix>192.168.1.15</v4-lan-public-prefix> + <v4-lan-public-prefix-length>28</v4-lan-public-prefix-length> + </t-provided-v4-lan-public-prefixes> + <t-provided-v4-lan-public-prefixes> + <request-index>2</request-index> + <v4-next-hop-address>192.168.1.16</v4-next-hop-address> + <v4-lan-public-prefix>192.168.1.16</v4-lan-public-prefix> + <v4-lan-public-prefix-length>28</v4-lan-public-prefix-length> + </t-provided-v4-lan-public-prefixes> + <t-provided-v6-lan-public-prefixes> + <request-index>1</request-index> + <v6-next-hop-address>2001:1890:12e3:2da::</v6-next-hop-address> + <v6-lan-public-prefix>2001:1890:12e3:2da::</v6-lan-public-prefix> + <v6-lan-public-prefix-length>28</v6-lan-public-prefix-length> + </t-provided-v6-lan-public-prefixes> + <t-provided-v6-lan-public-prefixes> + <request-index>1</request-index> + <v6-next-hop-address>2001:1890:12e3:2da::</v6-next-hop-address> + <v6-lan-public-prefix>2001:1890:12e3:2da::</v6-lan-public-prefix> + <v6-lan-public-prefix-length>28</v6-lan-public-prefix-length> + </t-provided-v6-lan-public-prefixes> + </internet-service-change-details> + </service-data> + </layer3-service-list> +</RequestData> +</SDNCAdapterCallbackRequest> diff --git a/bpmn/MSOCommonBPMN/src/test/resources/sdncadaptercallbackrequest_404CallBack.xml b/bpmn/MSOCommonBPMN/src/test/resources/sdncadaptercallbackrequest_404CallBack.xml new file mode 100644 index 0000000000..5808444d12 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/sdncadaptercallbackrequest_404CallBack.xml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<SDNCAdapterCallbackRequest + xmlns="http://org.openecomp/workflow/sdnc/adapter/schema/v1"> + <CallbackHeader> + <RequestId>39542e39-ccc3-4d1a-8b79-04ce88526613</RequestId> + <ResponseCode>404</ResponseCode> + <ResponseMessage>Error processing request to SDNC. Not Found. + https://sdncodl.us.aic.cip.att.com:8443/restconf/config/L3SDN-API:services/layer3-service-list/MVM%2FVLXP%2F000855%2F%2FShakeout. + SDNC Returned-[error-type:application, error-tag:data-missing, + error-message:Request could not be completed because the relevant + data model content does not exist.]</ResponseMessage> + </CallbackHeader> +</SDNCAdapterCallbackRequest>
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/sdncadaptercallbackrequestdata-nonfinal.text b/bpmn/MSOCommonBPMN/src/test/resources/sdncadaptercallbackrequestdata-nonfinal.text new file mode 100644 index 0000000000..fa90fa3510 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/sdncadaptercallbackrequestdata-nonfinal.text @@ -0,0 +1,42 @@ + <output xmlns="com:att:sdnctl:l3api"><ack-final-indicator>N</ack-final-indicator></output> + <layer3-service-list xmlns="com:att:sdnctl:l3api"> + <service-instance-id>FK/VLXM/003717//SW_INTERNET</service-instance-id> + <service-status> + <rpc-name>service-configuration-operation</rpc-name> + <rpc-action>activate</rpc-action> + <request-status>synccomplete</request-status> + <final-indicator>N</final-indicator> + <l3sdn-action>Layer3ServiceActivateRequest</l3sdn-action> + <l3sdn-subaction>SUPP</l3sdn-subaction> + <response-timestamp>2015-04-28T21:32:11.386Z</response-timestamp> + </service-status> + <service-data> + <internet-evc-access-information> + <ip-version>ds</ip-version> + <internet-evc-speed-value>8</internet-evc-speed-value> + <internet-evc-speed-units>Mbps</internet-evc-speed-units> + </internet-evc-access-information> + <request-information> + <request-action>Layer3ServiceActivateRequest</request-action> + <order-number>4281555</order-number> + <request-id>155415ab-b4a7-4382-b4c6-d17d9sm42855</request-id> + <source>mysrc</source> + <order-version>1</order-version> + </request-information> + <sdnc-request-header> + <svc-action>activate</svc-action> + <svc-notification-url>http://localhost:28080/adapters/rest/SDNCNotify</svc-notification-url> + <svc-request-id>5b1f3c5d-cdf9-488d-8a4b-d3f1229d7760</svc-request-id> + </sdnc-request-header> + <l2-homing-information> + <topology>MultiPoint</topology> + <preferred-aic-clli>clli</preferred-aic-clli> + <evc-name>AS/VLXM/003717//SW</evc-name> + </l2-homing-information> + <service-information> + <service-instance-id>FK/VLXM/003717//SW_INTERNET</service-instance-id> + <subscriber-name>ST E2E Test42855_1300004281555</subscriber-name> + <service-type>SDN-ETHERNET-INTERNET</service-type> + </service-information> + </service-data> + </layer3-service-list> diff --git a/bpmn/MSOCommonBPMN/src/test/resources/sdncadaptercallbackrequestdata.text b/bpmn/MSOCommonBPMN/src/test/resources/sdncadaptercallbackrequestdata.text new file mode 100644 index 0000000000..816bef97eb --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/sdncadaptercallbackrequestdata.text @@ -0,0 +1,42 @@ + <output xmlns="com:att:sdnctl:l3api"><ack-final-indicator>Y</ack-final-indicator></output> + <layer3-service-list xmlns="com:att:sdnctl:l3api"> + <service-instance-id>FK/VLXM/003717//SW_INTERNET</service-instance-id> + <service-status> + <rpc-name>service-configuration-operation</rpc-name> + <rpc-action>activate</rpc-action> + <request-status>synccomplete</request-status> + <final-indicator>N</final-indicator> + <l3sdn-action>Layer3ServiceActivateRequest</l3sdn-action> + <l3sdn-subaction>SUPP</l3sdn-subaction> + <response-timestamp>2015-04-28T21:32:11.386Z</response-timestamp> + </service-status> + <service-data> + <internet-evc-access-information> + <ip-version>ds</ip-version> + <internet-evc-speed-value>8</internet-evc-speed-value> + <internet-evc-speed-units>Mbps</internet-evc-speed-units> + </internet-evc-access-information> + <request-information> + <request-action>Layer3ServiceActivateRequest</request-action> + <order-number>4281555</order-number> + <request-id>155415ab-b4a7-4382-b4c6-d17d9sm42855</request-id> + <source>OMX</source> + <order-version>1</order-version> + </request-information> + <sdnc-request-header> + <svc-action>activate</svc-action> + <svc-notification-url>https://localhost:28080/adapters/rest/SDNCNotify</svc-notification-url> + <svc-request-id>5b1f3c5d-cdf9-488d-8a4b-d3f1229d7760</svc-request-id> + </sdnc-request-header> + <l2-homing-information> + <topology>MultiPoint</topology> + <preferred-aic-clli>clli</preferred-aic-clli> + <evc-name>AS/VLXM/003717//SW</evc-name> + </l2-homing-information> + <service-information> + <service-instance-id>FK/VLXM/003717//SW_INTERNET</service-instance-id> + <subscriber-name>test HEATING & COOLING_8310006378683</subscriber-name> + <service-type>SDN-ETHERNET-INTERNET</service-type> + </service-information> + </service-data> + </layer3-service-list> diff --git a/bpmn/MSOCommonBPMN/src/test/resources/sdncadapterworkflowrequest-act.xml b/bpmn/MSOCommonBPMN/src/test/resources/sdncadapterworkflowrequest-act.xml new file mode 100644 index 0000000000..231898adfa --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/sdncadapterworkflowrequest-act.xml @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="UTF-8"?> +<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" + xmlns:v1="http://org.openecomp/mso/workflow/schema/v1" + xmlns:v11="http://org.openecomp/workflow/sdnc/adapter/schema/v1"> + <soapenv:Header/> + <soapenv:Body> + <v1:SDNCAdapterWorkflowRequest> + <v11:RequestHeader> + <v11:RequestId>745b1b50-e39e-4685-9cc8-c71f0bde8bf0</v11:RequestId> + <v11:SvcAction>activate</v11:SvcAction> + <v11:SvcOperation>service-configuration-operation</v11:SvcOperation> + <v11:CallbackUrl>http://127.0.0.1:28080/camunda/services/SDNCAdapterCallback</v11:CallbackUrl> + </v11:RequestHeader> + <v1:SDNCRequestData> + <rest:payload xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd" contentType="text/xml"> + <tag0:service-request xmlns:tag0="http://org.openecomp/mso/request/details/schema/v1"> + <tag0:request-information> + <tag0:request-id>12570a36-7388-4c0a-bec4-189ce3kg9956</tag0:request-id> + <tag0:request-action>Layer3ServiceActivate</tag0:request-action> + <tag0:source>OMX</tag0:source> + </tag0:request-information> + <tag0:service-information> + <tag0:service-type>mysvctype</tag0:service-type> + <tag0:service-instance-id>PD/VLXM/003717//SW_INTERNET</tag0:service-instance-id> + </tag0:service-information> + </tag0:service-request> + </rest:payload> + </v1:SDNCRequestData> + <v1:SDNCTimeOutValueInMinutes>1</v1:SDNCTimeOutValueInMinutes> + <v1:InterimSDNCTimeOutValueInHours>2</v1:InterimSDNCTimeOutValueInHours> + </v1:SDNCAdapterWorkflowRequest> + </soapenv:Body> +</soapenv:Envelope> diff --git a/bpmn/MSOCommonBPMN/src/test/resources/sdncadapterworkflowrequest.xml b/bpmn/MSOCommonBPMN/src/test/resources/sdncadapterworkflowrequest.xml new file mode 100644 index 0000000000..f71f529593 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/sdncadapterworkflowrequest.xml @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="UTF-8"?> +<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" + xmlns:v1="http://org.openecomp/mso/workflow/schema/v1" + xmlns:v11="http://org.openecomp/workflow/sdnc/adapter/schema/v1"> + <soapenv:Header/> + <soapenv:Body> + <v1:SDNCAdapterWorkflowRequest> + <v11:RequestHeader> + <v11:RequestId>745b1b50-e39e-4685-9cc8-c71f0bde8bf0</v11:RequestId> + <v11:SvcAction>query</v11:SvcAction> + <v11:SvcOperation>services/layer3-service-list/AS%2FVLXM%2F000199%2F%2FSB_INTERNET</v11:SvcOperation> + <v11:CallbackUrl>http://127.0.0.1:28080/camunda/services/SDNCAdapterCallback</v11:CallbackUrl> + </v11:RequestHeader> + <v1:SDNCRequestData> + <rest:payload xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd" contentType="text/xml"> + <tag0:service-request xmlns:tag0="http://org.openecomp/mso/request/details/schema/v1"> + <tag0:request-information> + <tag0:request-id>12570a36-7388-4c0a-bec4-189ce3kg9956</tag0:request-id> + <tag0:request-action>GetLayer3ServiceDetailsRequest</tag0:request-action> + <tag0:source>OMX</tag0:source> + </tag0:request-information> + <tag0:service-information> + <tag0:service-type>SDN-ETHERNET-INTERNET</tag0:service-type> + <tag0:service-instance-id>PD/VLXM/003717//SW_INTERNET</tag0:service-instance-id> + </tag0:service-information> + </tag0:service-request> + </rest:payload> + </v1:SDNCRequestData> + <v1:SDNCTimeOutValueInMinutes>1</v1:SDNCTimeOutValueInMinutes> + </v1:SDNCAdapterWorkflowRequest> + </soapenv:Body> +</soapenv:Envelope> diff --git a/bpmn/MSOCommonBPMN/src/test/resources/testAsyncResource.bpmn b/bpmn/MSOCommonBPMN/src/test/resources/testAsyncResource.bpmn new file mode 100644 index 0000000000..e5498e4d2b --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/testAsyncResource.bpmn @@ -0,0 +1,81 @@ +<?xml version="1.0" encoding="UTF-8"?> +<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="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" id="_l2hJ8CccEeW3d--PaFJMbg" targetNamespace="http://camunda.org/schema/1.0/bpmn" exporter="Camunda Modeler" exporterVersion="1.4.0" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd"> + <bpmn2:process id="testAsyncProcess" name="testAsyncProcess" isExecutable="true"> + <bpmn2:startEvent id="ReceiveQueryAAIMessage" name="Receive Message"> + <bpmn2:outgoing>SequenceFlow_1</bpmn2:outgoing> + <bpmn2:messageEventDefinition id="_MessageEventDefinition_3" messageRef="Message_2" /> + </bpmn2:startEvent> + <bpmn2:sequenceFlow id="SequenceFlow_1" name="" sourceRef="ReceiveQueryAAIMessage" targetRef="ScriptTask_5" /> + <bpmn2:scriptTask id="ScriptTask_5" name="Send Response and continue execution" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_1</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_9</bpmn2:outgoing> + <bpmn2:script><![CDATA[//import java.net.InetAddress; +import org.openecomp.mso.bpmn.common.workflow.service.* + +//def hostname = InetAddress.getLocalHost().getCanonicalHostName() +//println ("my host name =================" + hostname) + +WorkflowCallbackResponse callbackResponse = new WorkflowCallbackResponse() +callbackResponse.setStatusCode(200) +callbackResponse.setMessage("Success") +callbackResponse.setResponse("Received the request, the process is getting executed, request message" + execution.getVariable("testAsyncRequestMsg")) + +WorkflowContextHolder.getInstance().processCallback("testAsyncProcess", execution.getProcessInstanceId(), execution.getVariable("mso-request-id"), callbackResponse) + +//def callbackUrl = "http://" + hostname + ":28080/mso/async/services/callback/asyncQueryAAICustomer/"+ execution.getProcessInstanceId() + "/" + execution.getVariable("mso-request-id") +//println "callback url" + callbackUrl +//execution.setVariable("callbackUrl", callbackUrl)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:scriptTask id="ScriptTask_6" name="Wait Script Task" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_9</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_11</bpmn2:outgoing> + <bpmn2:script><![CDATA[//Just sleep for a second +Thread.sleep(1000) +execution.setVariable("completed",true)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_9" name="" sourceRef="ScriptTask_5" targetRef="ScriptTask_6" /> + <bpmn2:endEvent id="EndEvent_4"> + <bpmn2:incoming>SequenceFlow_11</bpmn2:incoming> + </bpmn2:endEvent> + <bpmn2:sequenceFlow id="SequenceFlow_11" name="" sourceRef="ScriptTask_6" targetRef="EndEvent_4" /> + </bpmn2:process> + <bpmn2:error id="Error_1" name="MSO Workflow Exception" errorCode="MSOWorkflowException" /> + <bpmn2:message id="Message_2" name="testAsyncRequestMsg" /> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="testAsyncProcess"> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_33" bpmnElement="ReceiveQueryAAIMessage"> + <dc:Bounds x="182" y="145" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="133" y="186" width="134" height="25" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_EndEvent_88" bpmnElement="EndEvent_4"> + <dc:Bounds x="708" y="145" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="726" y="186" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_76" bpmnElement="ScriptTask_5"> + <dc:Bounds x="372" y="123" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_1" bpmnElement="SequenceFlow_1" sourceElement="_BPMNShape_StartEvent_33" targetElement="_BPMNShape_ScriptTask_76"> + <di:waypoint xsi:type="dc:Point" x="218" y="163" /> + <di:waypoint xsi:type="dc:Point" x="372" y="163" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="268" y="163" width="6" height="6" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_123" bpmnElement="ScriptTask_6"> + <dc:Bounds x="522" y="123" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_9" bpmnElement="SequenceFlow_9" sourceElement="_BPMNShape_ScriptTask_76" targetElement="_BPMNShape_ScriptTask_123"> + <di:waypoint xsi:type="dc:Point" x="472" y="163" /> + <di:waypoint xsi:type="dc:Point" x="522" y="163" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_11" bpmnElement="SequenceFlow_11" sourceElement="_BPMNShape_ScriptTask_123" targetElement="_BPMNShape_EndEvent_88"> + <di:waypoint xsi:type="dc:Point" x="622" y="163" /> + <di:waypoint xsi:type="dc:Point" x="708" y="163" /> + </bpmndi:BPMNEdge> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn2:definitions> diff --git a/bpmn/MSOCommonBPMN/src/test/resources/vnfAdapter/vnfUpdateSimResponse.xml b/bpmn/MSOCommonBPMN/src/test/resources/vnfAdapter/vnfUpdateSimResponse.xml new file mode 100644 index 0000000000..4e7c4ee687 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/vnfAdapter/vnfUpdateSimResponse.xml @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="UTF-8"?> +<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" + xmlns:v1="http://org.openecomp.mso/vnfNotify"> + <soapenv:Header /> + <soapenv:Body> +<ns2:updateVnfNotification xmlns:ns2="http://org.openecomp.mso/vnfNotify"> + <messageId>testRequestId</messageId> + <completed>true</completed> + <rollback> + <cloudSiteId>MTSNJA4LCP1</cloudSiteId> + <msoRequest> + <requestId>1512_1120-BB11-1</requestId> + <serviceInstanceId>BB11/VLXM/003717//SW_INTERNET</serviceInstanceId> + </msoRequest> + <tenantCreated>false</tenantCreated> + <tenantId>e25ac2f1e73d46428de81a6130a6fdad</tenantId> + <vnfCreated>true</vnfCreated> + <vnfId>slcp34248vbc/020a112b-a0c8-4143-87a3-698680ba2efe</vnfId> + </rollback> +</ns2:updateVnfNotification> + </soapenv:Body> +</soapenv:Envelope>
\ No newline at end of file |