diff options
Diffstat (limited to 'bpmn/MSOCommonBPMN')
25 files changed, 501 insertions, 1171 deletions
diff --git a/bpmn/MSOCommonBPMN/pom.xml b/bpmn/MSOCommonBPMN/pom.xml index a507b1ea0d..c85bcd7522 100644 --- a/bpmn/MSOCommonBPMN/pom.xml +++ b/bpmn/MSOCommonBPMN/pom.xml @@ -159,7 +159,7 @@ </plugins> <pluginManagement> <plugins> - <!--This plugin's configuration is used to store Eclipse m2e settings + <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself. --> <plugin> <groupId>org.eclipse.m2e</groupId> @@ -232,7 +232,7 @@ </dependency> <dependency> <groupId>org.camunda.connect</groupId> - <artifactId>camunda-connect-connectors-all</artifactId> + <artifactId>camunda-connect-connectors-all</artifactId> </dependency> <dependency> <groupId>commons-beanutils</groupId> @@ -278,11 +278,6 @@ <version>${project.version}</version> </dependency> <dependency> - <groupId>org.onap.so</groupId> - <artifactId>MSORESTClient</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> <groupId>org.onap.so.adapters</groupId> <artifactId>mso-adapters-rest-interface</artifactId> <version>${project.version}</version> @@ -358,7 +353,7 @@ </dependency> <dependency> <groupId>org.glassfish.jersey.inject</groupId> - <artifactId>jersey-hk2</artifactId> + <artifactId>jersey-hk2</artifactId> <version>2.26</version> </dependency> <dependency> diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AaiUtil.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AaiUtil.groovy index 8a262251b1..8cc232c2a4 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AaiUtil.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AaiUtil.groovy @@ -22,20 +22,21 @@ package org.onap.so.bpmn.common.scripts import java.util.regex.Matcher import java.util.regex.Pattern +import javax.ws.rs.core.MediaType +import javax.ws.rs.core.Response import javax.ws.rs.core.UriBuilder import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.aai.domain.yang.GenericVnf import org.onap.so.bpmn.core.UrnPropertiesReader; +import org.onap.so.client.HttpClient import org.onap.so.client.aai.AAIVersion import org.onap.so.client.aai.entities.uri.AAIUri import org.onap.so.logger.MessageEnum import org.onap.so.logger.MsoLogger import org.onap.so.openpojo.rules.HasToStringRule -import org.onap.so.rest.APIResponse; -import org.onap.so.rest.RESTClient -import org.onap.so.rest.RESTConfig +import org.onap.so.utils.TargetEntity @Deprecated class AaiUtil { @@ -54,37 +55,6 @@ class AaiUtil { this.taskProcessor = taskProcessor } - public String getBusinessSPPartnerUri(DelegateExecution execution) { - def uri = getUri(execution, 'sp-partner') - msoLogger.debug('AaiUtil.getBusinessSPPartnerUri() - AAI URI: ' + uri) - return uri - } - - public String getVersion(DelegateExecution execution, resourceName, processKey) { - def versionWithResourceKey = "mso.workflow.default.aai.${resourceName}.version" - def versionWithProcessKey = "mso.workflow.custom.${processKey}.aai.version" - - def version = UrnPropertiesReader.getVariable(versionWithProcessKey, execution) - if (version) { - msoLogger.debug("AaiUtil.getVersion() - using flow specific ${versionWithProcessKey}=${version}") - return version - } - - version = UrnPropertiesReader.getVariable(versionWithResourceKey, execution) - if (version) { - msoLogger.debug("AaiUtil.getVersion() - using resource specific ${versionWithResourceKey}=${version}") - return version - } - - version = UrnPropertiesReader.getVariable(DEFAULT_VERSION_KEY, execution) - if (version) { - msoLogger.debug("AaiUtil.getVersion() - using default version ${DEFAULT_VERSION_KEY}=${version}") - 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 createAaiUri(AAIUri uri) { return createAaiUri(AAIVersion.valueOf('V' + UrnPropertiesReader.getVariable(DEFAULT_VERSION_KEY)), uri) } @@ -94,14 +64,6 @@ class AaiUtil { return UriBuilder.fromUri(result + uri.build().toString()).build().toString() } - public String setNamespace(DelegateExecution execution) { - def key = AAI_NAMESPACE_STRING_KEY - aaiNamespace = UrnPropertiesReader.getVariable(key, execution) - if (aaiNamespace == null ) { - (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 9999, 'Internal Error: AAI URI entry for ' + key + ' not defined in the MSO URN properties file') - } - } - public String getNamespace() { return getNamespace(AAIVersion.valueOf('V' + UrnPropertiesReader.getVariable(DEFAULT_VERSION_KEY))) } @@ -114,330 +76,6 @@ class AaiUtil { return namespace + version } - /** - * This method can be used for getting the building namespace out of uri. - * NOTE: A getUri() method needs to be invoked first. - * Alternative method is the getNamespaceFromUri(DelegateExecution execution, String uri) - * return namespace (plus version from uri) - * - * @param url - * - * @return namespace - */ - public String getNamespaceFromUri(String uri) { - String namespace = UrnPropertiesReader.getVariable(AAI_NAMESPACE_STRING_KEY) - if (namespace == null) { - throw new Exception('Internal Error: AAI Namespace has not been set yet. A getUri() method needs to be invoked first.') - } - if(uri!=null){ - String version = getVersionFromUri(uri) - return namespace + "v"+version - }else{ - return namespace - } - } - - /** - * This method can be used for building namespace with aai version out of uri. - * NOTE: 2 arguments: DelegateExecution execution & String uri - * @param execution - * @param url - * - * @return namespace - */ - public String getNamespaceFromUri(DelegateExecution execution, String uri) { - String namespace = UrnPropertiesReader.getVariable(AAI_NAMESPACE_STRING_KEY, execution) - if (namespace == null ) { - (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 9999, 'Internal Error: AAI URI entry for ' + AAI_NAMESPACE_STRING_KEY + ' not defined in the MSO URN properties file') - } - if(uri!=null){ - String version = getVersionFromUri(uri) - return namespace + "v"+version - }else{ - return namespace - } - } - - /** - * This is used to extract the version from uri. - * - * @param uri - * - * @return version - */ - private String getVersionFromUri(String uri) { - - Matcher versionRegEx = Pattern.compile("/v(\\d+)").matcher(uri) - if (versionRegEx.find()) { - return versionRegEx.group(1); - } - - return ""; - } - - - /** - * 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(DelegateExecution execution, String url){ - msoLogger.trace("STARTED Execute AAI Get Process ") - APIResponse apiResponse = null - try{ - String uuid = utils.getRequestID() - msoLogger.debug("Generated uuid is: " + uuid) - msoLogger.debug("URL to be used is: " + url) - - String basicAuthCred = utils.getBasicAuth(UrnPropertiesReader.getVariable("aai.auth", execution),UrnPropertiesReader.getVariable("mso.msoKey", execution)) - - 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 = client.httpGet() - - msoLogger.trace("COMPLETED Execute AAI Get Process ") - }catch(Exception e){ - msoLogger.debug("Exception occured while executing AAI Get Call. Exception is: \n" + e) - (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 9999, e.getMessage()) - } - return apiResponse - } - - - /** - * 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(DelegateExecution execution, String url, String payload){ - msoLogger.trace("Started Execute AAI Put Process ") - APIResponse apiResponse = null - try{ - String uuid = utils.getRequestID() - msoLogger.debug("Generated uuid is: " + uuid) - msoLogger.debug("URL to be used is: " + url) - - String basicAuthCred = utils.getBasicAuth(UrnPropertiesReader.getVariable("aai.auth", execution),UrnPropertiesReader.getVariable("mso.msoKey", execution)) - - 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 = client.httpPut(payload) - - msoLogger.trace("Completed Execute AAI Put Process ") - }catch(Exception e){ - msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception occured while executing AAI Put Call.", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e); - (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 9999, e.getMessage()) - } - return apiResponse - } - - /** - * This reusable method can be used for making AAI httpPatch 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 executeAAIPatchCall(DelegateExecution execution, String url, String payload){ - msoLogger.trace("Started Execute AAI Patch Process ") - APIResponse apiResponse = null - try{ - String uuid = utils.getRequestID() - msoLogger.debug("Generated uuid is: " + uuid) - - msoLogger.debug("URL to be used is: " + url) - - String basicAuthCred = utils.getBasicAuth(UrnPropertiesReader.getVariable("aai.auth", execution),UrnPropertiesReader.getVariable("mso.msoKey", execution)) - - RESTConfig config = new RESTConfig(url); - RESTClient client = new RESTClient(config).addHeader("X-FromAppId", "MSO").addHeader("X-TransactionId", uuid).addHeader("Content-Type", "application/merge-patch+json").addHeader("Accept","application/json"); - if (basicAuthCred != null && !"".equals(basicAuthCred)) { - client.addAuthorizationHeader(basicAuthCred) - } - apiResponse = client.httpPatch(payload) - - msoLogger.trace("Completed Execute AAI Patch Process ") - }catch(Exception e){ - msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception occured while executing AAI Patch Call.", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e); - (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 9999, e.getMessage()) - } - return apiResponse - } - - - /** - * 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(DelegateExecution execution, String url){ - msoLogger.trace("Started Execute AAI Delete Process ") - APIResponse apiResponse = null - try{ - String uuid = utils.getRequestID() - msoLogger.debug("Generated uuid is: " + uuid) - msoLogger.debug("URL to be used is: " + url) - - String basicAuthCred = utils.getBasicAuth(UrnPropertiesReader.getVariable("aai.auth", execution),UrnPropertiesReader.getVariable("mso.msoKey", execution)) - - 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 = client.delete() - - msoLogger.trace("Completed Execute AAI Delete Process ") - }catch(Exception e){ - msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception occured while executing AAI Delete Call.", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e); - (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 9999, e.getMessage()) - } - return apiResponse - } - - /** - * 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(DelegateExecution execution, String url, String payload, String authHeader){ - msoLogger.trace("Started Execute AAI Delete Process ") - APIResponse apiResponse = null - try{ - String uuid = utils.getRequestID() - msoLogger.debug("Generated uuid is: " + uuid) - - msoLogger.debug("URL to be used is: " + url) - - String basicAuthCred = utils.getBasicAuth(UrnPropertiesReader.getVariable("aai.auth", execution),UrnPropertiesReader.getVariable("mso.msoKey", execution)) - 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 = client.httpDelete(payload) - - msoLogger.trace("Completed Execute AAI Delete Process ") - }catch(Exception e){ - msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception occured while executing AAI Delete Call.", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e); - (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 9999, e.getMessage()) - } - return apiResponse - } - - /** - * This reusable method can be used for making AAI Post Calls. The url - * and payload should be passed as a parameters along with the execution. - * The method will return an APIResponse. - * - * @param execution - * @param url - * @param payload - * - * @return APIResponse - * - */ - public APIResponse executeAAIPostCall(DelegateExecution execution, String url, String payload){ - msoLogger.trace("Started Execute AAI Post Process ") - APIResponse apiResponse = null - try{ - String uuid = utils.getRequestID() - msoLogger.debug("Generated uuid is: " + uuid) - msoLogger.debug("URL to be used is: " + url) - - String basicAuthCred = utils.getBasicAuth(UrnPropertiesReader.getVariable("aai.auth", execution),UrnPropertiesReader.getVariable("mso.msoKey", execution)) - 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 = client.httpPost(payload) - - msoLogger.trace("Completed Execute AAI Post Process ") - }catch(Exception e){ - msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception occured while executing AAI Post Call.", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e); - (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 9999, e.getMessage()) - } - return apiResponse - } - - /** - * This reusable method can be used for making AAI Post Calls. The url - * and payload should be passed as a parameters along with the execution. - * The method will return an APIResponse. - * - * @param execution - * @param url - * @param payload - * @param authenticationHeader - addAuthenticationHeader value - * @param headerName - name of header you want to add, i.e. addHeader(headerName, headerValue) - * @param headerValue - the header's value, i.e. addHeader(headerName, headerValue) - * - * @return APIResponse - * - */ - public APIResponse executeAAIPostCall(DelegateExecution execution, String url, String payload, String authenticationHeaderValue, String headerName, String headerValue){ - msoLogger.trace("Started Execute AAI Post Process ") - APIResponse apiResponse = null - try{ - msoLogger.debug("URL to be used is: " + url) - - String basicAuthCred = utils.getBasicAuth(UrnPropertiesReader.getVariable("aai.auth", execution),UrnPropertiesReader.getVariable("mso.msoKey", execution)) - - RESTConfig config = new RESTConfig(url); - RESTClient client = new RESTClient(config).addAuthorizationHeader(authenticationHeaderValue).addHeader(headerName, headerValue) - if (basicAuthCred != null && !"".equals(basicAuthCred)) { - client.addAuthorizationHeader(basicAuthCred) - } - apiResponse = client.httpPost(payload) - - msoLogger.trace("Completed Execute AAI Post Process ") - }catch(Exception e){ - msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception occured while executing AAI Post Call.", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e); - (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 9999, e.getMessage()) - } - return apiResponse - } - /* Utility to get the Cloud Region from AAI * Returns String cloud region id, (ie, cloud-region-id) @@ -449,9 +87,17 @@ class AaiUtil { public String getAAICloudReqion(DelegateExecution execution, String url, String backend, inputCloudRegion){ String regionId = "" try{ - APIResponse apiResponse = executeAAIGetCall(execution, url) - String returnCode = apiResponse.getStatusCode() - String aaiResponseAsString = apiResponse.getResponseBodyAsString() + URL Url = new URL(url) + HttpClient client = new HttpClient(Url, MediaType.APPLICATION_XML, TargetEntity.AAI) + client.addBasicAuthHeader(UrnPropertiesReader.getVariable("aai.auth", execution), UrnPropertiesReader.getVariable("mso.msoKey", execution)) + client.addAdditionalHeader("X-FromAppId", "MSO") + client.addAdditionalHeader("X-TransactionId", utils.getRequestID()) + client.addAdditionalHeader("Accept", MediaType.APPLICATION_XML) + + Response apiResponse = client.get() + + String returnCode = apiResponse.getStatus() + String aaiResponseAsString = apiResponse.readEntity(String.class) msoLogger.debug("Call AAI Cloud Region Return code: " + returnCode) execution.setVariable(execution.getVariable("prefix")+"queryCloudRegionReturnCode", returnCode) @@ -491,19 +137,6 @@ class AaiUtil { return regionId } - /* 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 - } - /** * Get the lowest unused VF Module index from AAI response for a given module type. The criteria for * determining module type is specified by "key" parameter (for example, "persona-model-id"), diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CatalogDbUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CatalogDbUtils.groovy index 9ce29dedb8..d5183ff5bb 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CatalogDbUtils.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CatalogDbUtils.groovy @@ -7,9 +7,9 @@ * 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. @@ -23,23 +23,23 @@ package org.onap.so.bpmn.common.scripts import org.json.JSONObject; import org.json.JSONArray; import org.json.XML +import org.onap.logging.ref.slf4j.ONAPLogConstants import org.onap.so.bpmn.core.UrnPropertiesReader; import org.springframework.web.util.UriUtils; import org.onap.so.bpmn.core.json.JsonUtils - - +import org.onap.so.client.HttpClient import groovy.json.JsonBuilder import groovy.json.JsonSlurper import groovy.util.slurpersupport.GPathResult import groovy.xml.QName; +import javax.ws.rs.core.MediaType +import javax.ws.rs.core.Response import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.so.logger.MsoLogger; -import org.onap.so.rest.APIResponse; -import org.onap.so.rest.RESTClient -import org.onap.so.rest.RESTConfig +import org.onap.so.utils.TargetEntity import org.onap.so.logger.MessageEnum @@ -731,12 +731,12 @@ class CatalogDbUtils { String endPoint = "/serviceResources?serviceModelUuid=" + UriUtils.encode(serviceModelUuid, "UTF-8") try { String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint) - + if (catalogDbResponse != null) { - + resources = parseServiceResourcesJson(catalogDbResponse, "v1") } - + } catch (Exception e) { utils.log("ERROR", "Exception in Querying Catalog DB: " + e.message) @@ -1230,32 +1230,32 @@ class CatalogDbUtils { String catalogDbEndpoint = UrnPropertiesReader.getVariable("mso.catalog.db.endpoint",execution) String queryEndpoint = catalogDbEndpoint + "/" + defaultDbAdapterVersion + endPoint - RESTConfig config = new RESTConfig(queryEndpoint); 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'); + URL url = new URL(queryEndpoint) + HttpClient client = new HttpClient(url, MediaType.APPLICATION_JSON, TargetEntity.CATALOG_DB) + client.addAdditionalHeader(ONAPLogConstants.Headers.REQUEST_ID, bpmnRequestId) + client.addAdditionalHeader('X-FromAppId', "BPMN") + client.addAdditionalHeader('Accept', MediaType.APPLICATION_JSON) String basicAuthCred = execution.getVariable("BasicAuthHeaderValueDB") if (basicAuthCred != null && !"".equals(basicAuthCred)) { - client.addAuthorizationHeader(basicAuthCred) + client.addAdditionalHeader("Authorization", basicAuthCred) }else { - client.addAuthorizationHeader(getBasicDBAuthHeader(execution)) + client.addAdditionalHeader("Authorization", getBasicDBAuthHeader(execution)) } + msoLogger.debug('sending GET to Catalog DB endpoint: ' + endPoint) - APIResponse response = client.httpGet() + Response response = client.get() - responseData = response.getResponseBodyAsString() + responseData = response.readEntity(String.class) if (responseData != null) { msoLogger.debug("Received data from Catalog DB: " + responseData) } - msoLogger.debug('Response code:' + response.getStatusCode()) + msoLogger.debug('Response code:' + response.getStatus()) msoLogger.debug('Response:' + System.lineSeparator() + responseData) - if (response.getStatusCode() == 200) { + if (response.getStatus() == 200) { // parse response as needed return responseData } @@ -1291,14 +1291,14 @@ class CatalogDbUtils { return responseJson } - + private String getBasicDBAuthHeader(DelegateExecution execution) { - + String encodedString = null try { String basicAuthValueDB = UrnPropertiesReader.getVariable("mso.adapters.db.auth", execution) utils.log("DEBUG", " Obtained BasicAuth userid password for Catalog DB adapter: " + basicAuthValueDB) - + encodedString = utils.getBasicAuth(basicAuthValueDB, UrnPropertiesReader.getVariable("mso.msoKey", execution)) execution.setVariable("BasicAuthHeaderValueDB",encodedString) } catch (IOException ex) { @@ -1307,5 +1307,5 @@ class CatalogDbUtils { } return encodedString } - + }
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ExternalAPIUtil.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ExternalAPIUtil.groovy index 3096bedda6..5c935e9081 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ExternalAPIUtil.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ExternalAPIUtil.groovy @@ -22,14 +22,16 @@ package org.onap.so.bpmn.common.scripts import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor; +import org.onap.so.client.HttpClient import org.onap.so.logger.MsoLogger -import org.onap.so.rest.APIResponse -import org.onap.so.rest.RESTClient -import org.onap.so.rest.RESTConfig import org.apache.commons.lang3.StringEscapeUtils import java.util.regex.Matcher import java.util.regex.Pattern +import javax.ws.rs.core.MediaType +import javax.ws.rs.core.Response +import org.onap.so.utils.TargetEntity + class ExternalAPIUtil { String Prefix="EXTAPI_" @@ -127,23 +129,22 @@ class ExternalAPIUtil { * @return APIResponse * */ - public APIResponse executeExternalAPIGetCall(DelegateExecution execution, String url){ + public Response executeExternalAPIGetCall(DelegateExecution execution, String url){ msoLogger.debug(" ======== STARTED Execute ExternalAPI Get Process ======== ") - APIResponse apiResponse = null + Response apiResponse = null try{ String uuid = utils.getRequestID() msoLogger.debug( "Generated uuid is: " + uuid) msoLogger.debug( "URL to be used is: " + url) - String basicAuthCred = utils.getBasicAuth(execution.getVariable("URN_externalapi_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/json"); + URL Url = new URL(url) + HttpClient client = new HttpClient(Url, MediaType.APPLICATION_JSON, TargetEntity.EXTERNAL) + client.addBasicAuthHeader(execution.getVariable("URN_externalapi_auth"), execution.getVariable("URN_mso_msoKey")) + client.addAdditionalHeader("X-FromAppId", "MSO") + client.addAdditionalHeader(ONAPLogConstants.Headers.REQUEST_ID, uuid) + client.addAdditionalHeader("Accept", MediaType.APPLICATION_JSON) - if (basicAuthCred != null && !"".equals(basicAuthCred)) { - client.addAuthorizationHeader(basicAuthCred) - } - apiResponse = client.httpGet() + apiResponse = client.get() msoLogger.debug( "======== COMPLETED Execute ExternalAPI Get Process ======== ") }catch(Exception e){ @@ -162,25 +163,25 @@ class ExternalAPIUtil { * @param url * @param payload * - * @return APIResponse + * @return Response * */ - public APIResponse executeExternalAPIPostCall(DelegateExecution execution, String url, String payload){ + public Response executeExternalAPIPostCall(DelegateExecution execution, String urlString, String payload){ msoLogger.debug( " ======== Started Execute ExternalAPI Post Process ======== ") - APIResponse apiResponse = null + Response apiResponse = null try{ String uuid = utils.getRequestID() msoLogger.debug( "Generated uuid is: " + uuid) - msoLogger.debug( "URL to be used is: " + url) + msoLogger.debug( "URL to be used is: " + urlString) - String basicAuthCred = utils.getBasicAuth(execution.getVariable("URN_externalapi_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/json").addHeader("Accept","application/json"); + URL url = new URL(urlString); - if (basicAuthCred != null && !"".equals(basicAuthCred)) { - client.addAuthorizationHeader(basicAuthCred) - } - apiResponse = client.httpPost(payload) + HttpClient httpClient = new HttpClient(url, "application/json", TargetEntity.AAI) + httpClient.addBasicAuthHeader(execution.getVariable("URN_externalapi_auth"), execution.getVariable("URN_mso_msoKey")) + httpClient.addAdditionalHeader("X-FromAppId", "MSO") + httpClient.addAdditionalHeader("X-TransactionId", uuid) + + apiResponse = httpClient.post(payload) msoLogger.debug( "======== Completed Execute ExternalAPI Post Process ======== ") }catch(Exception e){ @@ -190,42 +191,6 @@ class ExternalAPIUtil { return apiResponse } - /** - * This reusable method can be used for making ExternalAPI Post Calls. The url - * and payload should be passed as a parameters along with the execution. - * The method will return an APIResponse. - * - * @param execution - * @param url - * @param payload - * @param authenticationHeader - addAuthenticationHeader value - * @param headerName - name of header you want to add, i.e. addHeader(headerName, headerValue) - * @param headerValue - the header's value, i.e. addHeader(headerName, headerValue) - * - * @return APIResponse - * - */ - public APIResponse executeExternalAPIPostCall(DelegateExecution execution, String url, String payload, String authenticationHeaderValue, String headerName, String headerValue){ - msoLogger.debug( " ======== Started Execute ExternalAPI Post Process ======== ") - APIResponse apiResponse = null - try{ - msoLogger.debug( "URL to be used is: " + url) - - String basicAuthCred = utils.getBasicAuth(execution.getVariable("URN_externalapi_auth"),execution.getVariable("URN_mso_msoKey")) - - RESTConfig config = new RESTConfig(url); - RESTClient client = new RESTClient(config).addAuthorizationHeader(authenticationHeaderValue).addHeader(headerName, headerValue) - if (basicAuthCred != null && !"".equals(basicAuthCred)) { - client.addAuthorizationHeader(basicAuthCred) - } - apiResponse = client.httpPost(payload) - msoLogger.debug( "======== Completed Execute ExternalAPI Post Process ======== ") - }catch(Exception e){ - msoLogger.error("Exception occured while executing ExternalAPI Post Call. Exception is: \n" + e) - exceptionUtil.buildAndThrowWorkflowException(execution, 9999, e.getMessage()) - } - return apiResponse - } }
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/GenerateVfModuleName.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/GenerateVfModuleName.groovy index 78d147e819..c961dd06eb 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/GenerateVfModuleName.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/GenerateVfModuleName.groovy @@ -7,9 +7,9 @@ * 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. @@ -24,19 +24,20 @@ import org.onap.so.bpmn.core.UrnPropertiesReader import java.io.Serializable; +import javax.ws.rs.core.MediaType +import javax.ws.rs.core.Response import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.springframework.web.util.UriUtils import org.onap.so.bpmn.core.json.JsonUtils import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.client.HttpClient import org.onap.so.client.aai.AAIObjectType import org.onap.so.client.aai.entities.uri.AAIResourceUri import org.onap.so.client.aai.entities.uri.AAIUriFactory import org.onap.so.client.graphinventory.entities.uri.Depth -import org.onap.so.rest.APIResponse; -import org.onap.so.rest.RESTClient -import org.onap.so.rest.RESTConfig +import org.onap.so.utils.TargetEntity import org.onap.so.logger.MessageEnum import org.onap.so.logger.MsoLogger @@ -46,8 +47,8 @@ public class GenerateVfModuleName extends AbstractServiceTaskProcessor{ def Prefix="GVFMN_" ExceptionUtil exceptionUtil = new ExceptionUtil() - - + + public void preProcessRequest(DelegateExecution execution) { try { def vnfId = execution.getVariable("vnfId") @@ -76,7 +77,7 @@ public class GenerateVfModuleName extends AbstractServiceTaskProcessor{ try { def vnfId = execution.getVariable('vnfId') def personaModelId = execution.getVariable('personaModelId') - + AaiUtil aaiUtil = new AaiUtil(this) AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId) uri.depth(Depth.ONE) @@ -85,34 +86,34 @@ public class GenerateVfModuleName extends AbstractServiceTaskProcessor{ msoLogger.debug("AAI endPoint: " + endPoint) try { - RESTConfig config = new RESTConfig(endPoint); + HttpClient client = new HttpClient(new URL(endPoint), MediaType.APPLICATION_XML, TargetEntity.AAI) + client.addAdditionalHeader('X-TransactionId', UUID.randomUUID().toString()) + client.addAdditionalHeader('X-FromAppId', 'MSO') + client.addAdditionalHeader('Content-Type', 'application/xml') + client.addAdditionalHeader('Accept','application/xml') + 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'); + msoLogger.debug('sending GET to AAI endpoint \'' + endPoint + '\'') - APIResponse response = client.httpGet() + Response response = client.get() msoLogger.debug("GenerateVfModuleName - invoking httpGet() to AAI") - responseData = response.getResponseBodyAsString() + responseData = response.readEntity(String.class) if (responseData != null) { msoLogger.debug("Received generic VNF data: " + responseData) } msoLogger.debug("GenerateVfModuleName - queryAAIVfModule Response: " + responseData) - msoLogger.debug("GenerateVfModuleName - queryAAIVfModule ResponseCode: " + response.getStatusCode()) + msoLogger.debug("GenerateVfModuleName - queryAAIVfModule ResponseCode: " + response.getStatus()) - execution.setVariable('GVFMN_queryAAIVfModuleResponseCode', response.getStatusCode()) + execution.setVariable('GVFMN_queryAAIVfModuleResponseCode', response.getStatus()) execution.setVariable('GVFMN_queryAAIVfModuleResponse', responseData) - msoLogger.debug('Response code:' + response.getStatusCode()) + msoLogger.debug('Response code:' + response.getStatus()) msoLogger.debug('Response:' + System.lineSeparator() + responseData) - if (response.getStatusCode() == 200) { - // Set the VfModuleXML - if (responseData != null) { + if (response.getStatus() == 200) { + // Set the VfModuleXML + if (responseData != null) { String vfModulesText = utils.getNodeXml(responseData, "vf-modules") if (vfModulesText == null || vfModulesText.isEmpty()) { msoLogger.debug("There are no VF modules in this VNF yet") @@ -131,18 +132,18 @@ public class GenerateVfModuleName extends AbstractServiceTaskProcessor{ def personaModelIdFromAAI = utils.getNodeText(vfModuleXml, "model-invariant-id") if (!personaModelIdFromAAI) { // check old attribute name - personaModelIdFromAAI = utils.getNodeText(vfModuleXml, "persona-model-id") + personaModelIdFromAAI = utils.getNodeText(vfModuleXml, "persona-model-id") } if (personaModelIdFromAAI != null && personaModelIdFromAAI.equals(personaModelId)) { matchingVfModules = matchingVfModules + utils.removeXmlPreamble(vfModuleXml) - } + } } matchingVfModules = matchingVfModules + "</vfModules>" - msoLogger.debug("Matching VF Modules: " + matchingVfModules) + msoLogger.debug("Matching VF Modules: " + matchingVfModules) execution.setVariable("GVFMN_vfModuleXml", matchingVfModules) } } - } + } } catch (Exception ex) { ex.printStackTrace() msoLogger.debug('Exception occurred while executing AAI GET:' + ex.getMessage()) @@ -155,18 +156,18 @@ public class GenerateVfModuleName extends AbstractServiceTaskProcessor{ msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in queryAAI(): ' + e.getMessage()) } - + } - + public void generateName (DelegateExecution execution) { def method = getClass().getSimpleName() + '.generateName() ' + 'execution=' + execution.getId() + ')' msoLogger.trace('Entered ' + method) - - String vfModuleXml = execution.getVariable("GVFMN_vfModuleXml") - - String moduleIndex = utils.getLowestUnusedIndex(vfModuleXml) + + String vfModuleXml = execution.getVariable("GVFMN_vfModuleXml") + + String moduleIndex = utils.getLowestUnusedIndex(vfModuleXml) msoLogger.debug("moduleIndex is: " + moduleIndex) def vnfName = execution.getVariable("vnfName") def vfModuleLabel = execution.getVariable("vfModuleLabel") diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/NetworkUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/NetworkUtils.groovy index a1e63dc150..27d067dfc1 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/NetworkUtils.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/NetworkUtils.groovy @@ -7,9 +7,9 @@ * 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. @@ -22,6 +22,9 @@ package org.onap.so.bpmn.common.scripts import groovy.xml.XmlUtil import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.aai.domain.yang.L3Network +import org.onap.aai.domain.yang.Subnet +import org.onap.aai.domain.yang.Subnets import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.logger.MsoLogger import org.w3c.dom.Document @@ -64,7 +67,7 @@ class NetworkUtils { * @param cloudRegionId the cloud-region-region * @return String request */ - def CreateNetworkRequestV2(execution, requestId, messageId, requestInput, queryIdResponse, routeCollection, policyFqdns, tableCollection, cloudRegionId, backoutOnFailure, source) { + def CreateNetworkRequestV2(execution, requestId, messageId, requestInput,L3Network queryIdResponse, routeCollection, policyFqdns, tableCollection, cloudRegionId, backoutOnFailure, source) { String createNetworkRequest = null if(requestInput!=null && queryIdResponse!=null) { String serviceInstanceId = "" @@ -72,8 +75,8 @@ class NetworkUtils { String externalValue = "" if (source == "VID") { - sharedValue = utils.getNodeText(queryIdResponse, "is-shared-network") != null ? utils.getNodeText(queryIdResponse, "is-shared-network") : "false" - externalValue = utils.getNodeText(queryIdResponse, "is-external-network") != null ? utils.getNodeText(queryIdResponse, "is-external-network") : "false" + sharedValue = queryIdResponse.isIsSharedNetwork() != null ? queryIdResponse.isIsSharedNetwork() : "false" + externalValue = queryIdResponse.isIsExternalNetwork() != null ? queryIdResponse.isIsExternalNetwork() : "false" serviceInstanceId = utils.getNodeText(requestInput, "service-instance-id") } else { // source = 'PORTAL' @@ -100,14 +103,14 @@ class NetworkUtils { networkType = utils.getNodeText(networkModelInfo, "modelName") modelCustomizationUuid = utils.getNodeText(networkModelInfo, "modelCustomizationUuid") } else { - networkType = utils.getNodeText(queryIdResponse, "network-type") + networkType = queryIdResponse.getNetworkType() modelCustomizationUuid = utils.getNodeText(requestInput, "modelCustomizationId") } // queryIdResponse - String networkName = utils.getNodeText(queryIdResponse, "network-name") - String networkId = utils.getNodeText(queryIdResponse, "network-id") - String networkTechnology = utils.getNodeText(queryIdResponse, "network-technology") + String networkName = queryIdResponse.getNetworkName() + String networkId = queryIdResponse.getNetworkId() + String networkTechnology = queryIdResponse.getNetworkTechnology() // contrailNetwork - networkTechnology = 'Contrail' vs. 'AIC_SR_IOV') String contrailNetwork = "" @@ -124,13 +127,12 @@ class NetworkUtils { // rebuild subnets String subnets = "" - if (utils.nodeExists(queryIdResponse, "subnets")) { - def subnetsGroup = utils.getNodeXml(queryIdResponse, "subnets", false) - subnets = buildSubnets(subnetsGroup) + if (queryIdResponse.getSubnets() != null) { + subnets = buildSubnets(queryIdResponse) } String physicalNetworkName = "" - physicalNetworkName = utils.getNodeText(queryIdResponse, "physical-network-name") + physicalNetworkName = queryIdResponse.getPhysicalNetworkName() String vlansCollection = buildVlans(queryIdResponse) @@ -181,7 +183,7 @@ class NetworkUtils { * @param cloudRegionId the cloud-region-region * @return String request */ - def UpdateNetworkRequestV2(execution, requestId, messageId, requestInput, queryIdResponse, routeCollection, policyFqdns, tableCollection, cloudRegionId, backoutOnFailure, source) { + def UpdateNetworkRequestV2(execution, requestId, messageId, requestInput, L3Network queryIdResponse, routeCollection, policyFqdns, tableCollection, cloudRegionId, backoutOnFailure, source) { String updateNetworkRequest = null if(requestInput!=null && queryIdResponse!=null) { String serviceInstanceId = "" @@ -189,8 +191,8 @@ class NetworkUtils { String externalValue = "" if (source == "VID") { - sharedValue = utils.getNodeText(queryIdResponse, "is-shared-network") != null ? utils.getNodeText(queryIdResponse, "is-shared-network") : "false" - externalValue = utils.getNodeText(queryIdResponse, "is-external-network") != null ? utils.getNodeText(queryIdResponse, "is-external-network") : "false" + sharedValue = queryIdResponse.isIsSharedNetwork() != null ? queryIdResponse.isIsSharedNetwork() : "false" + externalValue = queryIdResponse.isIsExternalNetwork() != null ? queryIdResponse.isIsExternalNetwork() : "false" serviceInstanceId = utils.getNodeText(requestInput, "service-instance-id") } else { // source = 'PORTAL' @@ -205,9 +207,9 @@ class NetworkUtils { String tenantId = utils.getNodeText(requestInput, "tenant-id") // queryIdResponse - String networkName = utils.getNodeText(queryIdResponse, "network-name") - String networkId = utils.getNodeText(queryIdResponse, "network-id") - + String networkName = queryIdResponse.getNetworkName() + String networkId = queryIdResponse.getNetworkId() + String networkType = "" String modelCustomizationUuid = "" if (utils.nodeExists(requestInput, "networkModelInfo")) { @@ -215,15 +217,14 @@ class NetworkUtils { networkType = utils.getNodeText(networkModelInfo, "modelName") modelCustomizationUuid = utils.getNodeText(networkModelInfo, "modelCustomizationUuid") } else { - networkType = utils.getNodeText(queryIdResponse, "network-type") + networkType = queryIdResponse.getNetworkType() modelCustomizationUuid = utils.getNodeText(requestInput, "modelCustomizationId") } // rebuild subnets String subnets = "" - if (utils.nodeExists(queryIdResponse, "subnets")) { - def subnetsGroup = utils.getNodeXml(queryIdResponse, "subnets", false) - subnets = buildSubnets(subnetsGroup) + if (queryIdResponse.getSubnets() != null) { + subnets = buildSubnets(queryIdResponse) } String networkParams = "" @@ -232,12 +233,12 @@ class NetworkUtils { networkParams = buildParams(netParams) } - String networkStackId = utils.getNodeText(queryIdResponse, "heat-stack-id") + String networkStackId = queryIdResponse.getHeatStackId() if (networkStackId == 'null' || networkStackId == "" || networkStackId == null) { networkStackId = "force_update" } - String physicalNetworkName = utils.getNodeText(queryIdResponse, "physical-network-name") + String physicalNetworkName = queryIdResponse.getPhysicalNetworkName() String vlansCollection = buildVlans(queryIdResponse) updateNetworkRequest = @@ -418,7 +419,7 @@ class NetworkUtils { rebuildSegmentationAssignments = buildXMLElements(requeryIdAAIResponse, "segmentation-assignments", "segmentation-assignment", elementList) } else { rebuildSegmentationAssignments = buildXMLElements(requeryIdAAIResponse, "", "segmentation-assignments", elementList) - } + } } // rebuild 'ctag-assignments' / rebuildCtagAssignments @@ -736,7 +737,7 @@ class NetworkUtils { return rtn } - + def isInstanceValueMatch(linkResource, globalSubscriberId, serviceType) { Boolean rtn = false try { @@ -809,7 +810,7 @@ class NetworkUtils { } else { //pending-update or PendingUpdate xmlNetwork += "<"+element+">"+"Active"+"</"+element+">" } - } + } if (element=="heat-stack-id") { if (replaceNetworkId != "") { xmlNetwork += "<"+element+">"+replaceNetworkId+"</"+element+">" @@ -834,11 +835,11 @@ class NetworkUtils { } else { //pending-update or PendingUpdate xmlNetwork += "<"+element+">"+"Active"+"</"+element+">" } - } + } } else { xmlNetwork += "<"+element+">"+var.toString()+"</"+element+">" } - } + } } } return xmlNetwork @@ -863,7 +864,7 @@ class NetworkUtils { } else { def subnetList = ["subnet-id", "neutron-subnet-id", "gateway-address", "network-start-address", "cidr-mask", "ip-version", "orchestration-status", "dhcp-enabled", "dhcp-start", "dhcp-end", "subnet-role", "resource-version", "subnet-name", "ip-assignment-direction", "host-routes"] rebuildingSubnets += buildSubNetworkElements(subnetXml, createNetworkResponse, subnetList, "subnet") - } + } } if (utils.nodeExists(subnetsData, 'relationship')) { rebuildingSubnets = rebuildRelationship(requeryIdAAIResponse) @@ -878,29 +879,24 @@ class NetworkUtils { return rebuildingSubnets } - def buildSubnets(queryIdResponse) { + def buildSubnets(L3Network network) { 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 orchestrationStatus = utils.getNodeText(subnetXml, "orchestration-status") - if (orchestrationStatus == "pending-delete" || orchestrationStatus == "PendingDelete") { - // skip, do not include in processing, remove!!! - } else { - def subnetList = ["dhcp-start", "dhcp-end", "network-start-address", "cidr-mask", "dhcp-enabled", "gateway-address", "ip-version", "subnet-id", "subnet-name", "ip-assignment-direction", "host-routes"] - rebuildingSubnets += buildSubNetworkElements(subnetXml, subnetList, "subnets") - //rebuildingSubnets += buildSubNetworkElements(subnetXml, subnetList, "") - } + Subnets subnets = network.getSubnets() + try{ + for(Subnet s : subnets.getSubnet()){ + def orchestrationStatus = s.getOrchestrationStatus() + if (orchestrationStatus == "pending-delete" || orchestrationStatus == "PendingDelete") { + // skip, do not include in processing, remove!!! + } else { + def subnetList = ["dhcp-start", "dhcp-end", "network-start-address", "cidr-mask", "dhcp-enabled", "gateway-address", "ip-version", "subnet-id", "subnet-name", "ip-assignment-direction", "host-routes"] + rebuildingSubnets += buildSubNetworkElements(s, subnetList, "subnets") + //rebuildingSubnets += buildSubNetworkElements(subnetXml, subnetList, "") + } } } catch (Exception ex) { - // + // } finally { - //rebuildingSubnets += "</subnets>" + //rebuildingSubnets += "</subnets>" } return rebuildingSubnets } @@ -919,7 +915,7 @@ class NetworkUtils { var = xml.'**'.find {it.name() == element} if (var != null) { if (element=="orchestration-status") { - if(var.toString() == 'pending-create' || var.toString() == 'PendingCreate') { + if(var.toString() == 'pending-create' || var.toString() == 'PendingCreate') { xmlBuild += "<"+element+">"+"Created"+"</"+element+">" } else { // pending-update or PendingUpdate' xmlBuild += "<"+element+">"+"Active"+"</"+element+">" @@ -940,9 +936,9 @@ class NetworkUtils { List elementRoute = ["host-route-id", "route-prefix", "next-hop", "next-hop-type", "resource-version"] xmlBuild += buildXMLElements(subnetXml, "host-routes", "host-route", elementRoute) } - } else { + } else { xmlBuild += "<"+element+">"+var.toString()+"</"+element+">" - } + } } } } @@ -957,68 +953,69 @@ class NetworkUtils { } // build subnet sub-network single elements - def buildSubNetworkElements(subnetXml, elementList, parentName) { + def buildSubNetworkElements(Subnet subnet, elementList, parentName) { + def var = "" def xmlBuild = "" if (parentName != "") { xmlBuild += "<"+parentName+">" } - if (subnetXml != null) { + if (subnet != null) { def networkStartAddress = "" for (element in elementList) { - def xml= new XmlSlurper().parseText(subnetXml) - var = xml.'**'.find {it.name() == element} if (element == "dhcp-start") { + var = subnet.getDhcpStart() xmlBuild += "<allocationPools>" - if (var.toString() == 'null') { + if (var == null) { xmlBuild += "<start>"+""+"</start>" } else { - xmlBuild += "<start>"+var.toString()+"</start>" + xmlBuild += "<start>"+var+"</start>" } } if (element == "dhcp-end") { - if (var.toString() == 'null') { + var = subnet.getDhcpEnd() + if (var == null) { xmlBuild += "<end>"+""+"</end>" } else { - xmlBuild += "<end>"+var.toString()+"</end>" + xmlBuild += "<end>"+var+"</end>" } xmlBuild += "</allocationPools>" } if (element == "network-start-address" || element == "cidr-mask") { if (element == "network-start-address") { - networkStartAddress = var.toString() + networkStartAddress = subnet.getNetworkStartAddress() } if (element == "cidr-mask") { - xmlBuild += "<cidr>"+networkStartAddress+"/"+var.toString()+"</cidr>" + xmlBuild += "<cidr>"+networkStartAddress+"/"+var+"</cidr>" } } if (element == "dhcp-enabled") { - xmlBuild += "<enableDHCP>"+var.toString()+"</enableDHCP>" + xmlBuild += "<enableDHCP>"+subnet.isDhcpEnabled()+"</enableDHCP>" } if (element == "gateway-address") { - xmlBuild += "<gatewayIp>"+var.toString()+"</gatewayIp>" + xmlBuild += "<gatewayIp>"+subnet.getGatewayAddress()+"</gatewayIp>" } if (element == "ip-version") { - String ipVersion = getIpvVersion(var.toString()) + String ipVersion = getIpvVersion(subnet.getIpVersion()) xmlBuild += "<ipVersion>"+ipVersion+"</ipVersion>" } if (element == "subnet-id") { - xmlBuild += "<subnetId>"+var.toString()+"</subnetId>" + xmlBuild += "<subnetId>"+subnet.getSubnetId()+"</subnetId>" } - if ((element == "subnet-name") && (var != null)) { - xmlBuild += "<subnetName>"+var.toString()+"</subnetName>" + if ((element == "subnet-name") && (subnet.getSubnetName() != null)) { + xmlBuild += "<subnetName>"+subnet.getSubnetName()+"</subnetName>" } - if ((element == "ip-assignment-direction") && (var != null)) { - xmlBuild += "<addrFromStart>"+var.toString()+"</addrFromStart>" + if ((element == "ip-assignment-direction") && (subnet.getIpAssignmentDirection() != null)) { + xmlBuild += "<addrFromStart>"+subnet.getIpAssignmentDirection()+"</addrFromStart>" } if (element == "host-routes") { def routes = "" - if (subnetXml.contains("host-routes")) { - routes = buildHostRoutes(subnetXml) + if (subnet.getHostRoutes() != null) { + routes = buildHostRoutes(subnet) } - xmlBuild += routes - } - + xmlBuild += routes + } + } } if (parentName != "") { @@ -1053,12 +1050,12 @@ class NetworkUtils { } } buildHostRoutes += "</hostRoutes>" - } - } - return buildHostRoutes - + } + } + return buildHostRoutes + } - + // rebuild ctag-assignments def rebuildCtagAssignments(xmlInput) { def rebuildingCtagAssignments = "" @@ -1396,17 +1393,17 @@ class NetworkUtils { } return rollbackEnabled } - - + + /** * This method extracts the version for the the given ip-version. * * @param String ipvVersion - IP protocols version (ex: ipv4 or ipv6 or 4 or 6) * @return String version - digit version (ex: 4 or 6) */ - + public String getIpvVersion (String ipvVersion) { - + String version = "" try { if (ipvVersion.isNumber()) { @@ -1418,7 +1415,7 @@ class NetworkUtils { } } } catch (Exception ex) { - version = ipvVersion + version = ipvVersion } return version } diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofHoming.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofHoming.groovy index 533df72285..2e937ed134 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofHoming.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofHoming.groovy @@ -32,12 +32,13 @@ import org.onap.so.bpmn.core.domain.ServiceDecomposition import org.onap.so.bpmn.core.domain.Subscriber import org.onap.so.bpmn.core.domain.VnfResource import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.client.HttpClient +import org.onap.so.logger.MsoLogger import org.onap.so.db.catalog.beans.CloudIdentity import org.onap.so.db.catalog.beans.CloudSite -import org.onap.so.rest.APIResponse -import org.onap.so.rest.RESTClient -import org.onap.so.rest.RESTConfig + import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.utils.TargetEntity import org.json.JSONArray import org.json.JSONObject @@ -45,6 +46,8 @@ import org.springframework.web.util.UriUtils import static org.onap.so.bpmn.common.scripts.GenericUtils.* +import javax.ws.rs.core.Response + /** * This class contains the scripts used * by the OOF Homing Subflow building block. The @@ -135,7 +138,7 @@ class OofHoming extends AbstractServiceTaskProcessor { //Prepare Callback String timeout = execution.getVariable("timeout") - if (isBlank(timeout)) { + if (isBlank(timeout)) { timeout = UrnPropertiesReader.getVariable("mso.oof.timeout", execution); if (isBlank(timeout)) { timeout = "PT30M" @@ -153,25 +156,18 @@ class OofHoming extends AbstractServiceTaskProcessor { execution.setVariable("oofRequest", oofRequest) utils.log("DEBUG", "OOF Request is: " + oofRequest, isDebugEnabled) - String url = UrnPropertiesReader.getVariable("mso.oof.endpoint", execution) - utils.log("DEBUG", "Posting to OOF Url: " + url, isDebugEnabled) + String urlString = UrnPropertiesReader.getVariable("mso.oof.endpoint", execution) + utils.log("DEBUG", "Posting to OOF Url: " + urlString, isDebugEnabled) - logDebug("URL to be used is: " + url, isDebugEnabled) - RESTConfig config = new RESTConfig(url) - RESTClient client = new RESTClient(config).addAuthorizationHeader(authHeader). - addHeader("Content-Type", "application/json") - APIResponse response = client.httpPost(oofRequest) + URL url = new URL(urlString); + HttpClient httpClient = new HttpClient(url, "application/json", TargetEntity.SNIRO) + httpClient.addAdditionalHeader("Authorization", authHeader) + Response httpResponse = httpClient.post(oofRequest) - int responseCode = response.getStatusCode() - logDebug("OOF sync response code is: " + responseCode, isDebugEnabled) - String syncResponse = response.getResponseBodyAsString() - execution.setVariable("syncResponse", syncResponse) - logDebug("OOF sync response is: " + syncResponse, isDebugEnabled) + int responseCode = httpResponse.getStatus() + logDebug("OOF sync response code is: " + responseCode, isDebugEnabled) - if(responseCode != 202){ - exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from OOF.") - } utils.log("DEBUG", "*** Completed Homing Call OOF ***", isDebugEnabled) } diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy index 197589efa1..b9bc1c7c00 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy @@ -33,10 +33,9 @@ import org.onap.so.bpmn.core.domain.ServiceInstance import org.onap.so.bpmn.core.domain.Subscriber import org.onap.so.bpmn.core.domain.VnfResource import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.client.HttpClient import org.onap.so.db.catalog.beans.CloudSite -import org.onap.so.rest.APIResponse -import org.onap.so.rest.RESTClient -import org.onap.so.rest.RESTConfig +import org.onap.so.utils.TargetEntity import org.springframework.http.HttpEntity import org.springframework.http.HttpHeaders import org.springframework.http.HttpMethod @@ -504,22 +503,16 @@ class OofUtils { String auth = UrnPropertiesReader.getVariable("mso.db.auth", execution) String uri = "/cloudSite" - HttpHeaders headers = new HttpHeaders() + URL url = new URL(endpoint + uri) + HttpClient client = new HttpClient(url, MediaType.APPLICATION_JSON, TargetEntity.EXTERNAL) + client.addAdditionalHeader(HttpHeaders.AUTHORIZATION, auth) + client.addAdditionalHeader(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON) - headers.set(HttpHeaders.AUTHORIZATION, auth) - headers.set(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON) - headers.set(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + Response response = client.post(request.getBody().toString()) - UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(endpoint + uri) - HttpEntity<CloudSite> request = new HttpEntity<CloudSite>(cloudSite, headers) - RESTConfig config = new RESTConfig(endpoint + uri) - RESTClient client = new RESTClient(config).addAuthorizationHeader(auth). - addHeader(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON).addHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) - APIResponse response = client.httpPost(request.getBody().toString()) - - int responseCode = response.getStatusCode() + int responseCode = response.getStatus() logDebug("CatalogDB response code is: " + responseCode, isDebugEnabled) - String syncResponse = response.getResponseBodyAsString() + String syncResponse = response.readEntity(String.class) logDebug("CatalogDB response is: " + syncResponse, isDebugEnabled) if(responseCode != 202){ diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/PrepareUpdateAAIVfModule.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/PrepareUpdateAAIVfModule.groovy index 1a55bf2a0e..8f0e481c9a 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/PrepareUpdateAAIVfModule.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/PrepareUpdateAAIVfModule.groovy @@ -34,9 +34,6 @@ import org.onap.so.client.aai.entities.AAIResultWrapper import org.onap.so.client.aai.entities.uri.AAIResourceUri import org.onap.so.client.aai.entities.uri.AAIUriFactory import org.onap.so.client.graphinventory.entities.uri.Depth -import org.onap.so.rest.APIResponse -import org.onap.so.rest.RESTClient -import org.onap.so.rest.RESTConfig import org.springframework.web.util.UriUtils import org.onap.so.logger.MessageEnum import org.onap.so.logger.MsoLogger @@ -214,74 +211,31 @@ public class PrepareUpdateAAIVfModule extends VfModuleBase { msoLogger.trace('Entered ' + method) try { - // Construct payload - org.onap.aai.domain.yang.VfModule vfModule = execution.getVariable('PUAAIVfMod_vfModule') - - def orchestrationStatus = execution.getVariable('PUAAIVfMod_orchestrationStatus') - - vfModule.setOrchestrationStatus(orchestrationStatus) - - //def payload = utils.nodeToString(newVfModuleNode) - - // Construct endpoint def vnfId = execution.getVariable('PUAAIVfMod_vnfId') def vfModuleId = execution.getVariable('PUAAIVfMod_vfModuleId') + def orchestrationStatus = execution.getVariable('PUAAIVfMod_orchestrationStatus') - def payload = """{ - "vf-module-id": "${vfModuleId}", - "orchestration-status": "${orchestrationStatus}" - }""" + org.onap.aai.domain.yang.VfModule vfModule = execution.getVariable('PUAAIVfMod_vfModule') - msoLogger.debug("VfModule payload : " + payload) + vfModule.setVfModuleId(vfModuleId) + vfModule.setOrchestrationStatus(orchestrationStatus) - AaiUtil aaiUtil = new AaiUtil(this) + AAIResourcesClient client = new AAIResourcesClient() AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, vfModuleId) - uri.depth(Depth.ONE) - String endPoint = aaiUtil.createAaiUri(uri) + client.update(uri, vfModule) + + // 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', vfModule) + def vnfName = execution.getVariable('PUAAIVfMod_vnfName') + msoLogger.debug('Output PUAAIVfMod_vnfName set to ' + vnfName) + // TODO: Should deprecate use of processKey+Response variable for the response. Will use "WorkflowResponse" instead + execution.setVariable('WorkflowResponse', vfModule) + + def heatStackId = vfModule.getHeatStackId() + execution.setVariable('PUAAIVfMod_heatStackId', heatStackId) + msoLogger.debug('Output PUAAIVfMod_heatStackId set to \'' + heatStackId + '\'') - msoLogger.debug("PrepareUpdateAAIVfModule: AAI endPoint : " + endPoint) - String basicAuthCred = utils.getBasicAuth(UrnPropertiesReader.getVariable("aai.auth", execution),UrnPropertiesReader.getVariable("mso.msoKey", execution)) - try { - RESTConfig config = new RESTConfig(endPoint); - def responseData = '' - def aaiRequestId = utils.getRequestID() - RESTClient client = new RESTClient(config). - addHeader('X-TransactionId', aaiRequestId). - addHeader('X-FromAppId', 'MSO'). - addHeader('Content-Type', 'application/merge-patch+json'). - addHeader('Accept','application/json'); - if (basicAuthCred != null && !"".equals(basicAuthCred)) { - client.addAuthorizationHeader(basicAuthCred) - } - msoLogger.debug('sending PATCH to AAI endpoint \'' + endPoint + '\'' + 'with payload \n' + payload) - APIResponse response = client.httpPatch(payload) - msoLogger.debug("PrepareUpdateAAIVfModule: - invoking httpPatch to AAI") - - responseData = response.getResponseBodyAsString() - execution.setVariable('PUAAIVfMod_updateVfModuleResponseCode', response.getStatusCode()) - execution.setVariable('PUAAIVfMod_updateVfModuleResponse', responseData) - msoLogger.debug('Response code:' + response.getStatusCode()) - msoLogger.debug('Response:' + System.lineSeparator() + responseData) - msoLogger.debug("PrepareUpdateAAIVfModule: AAI Response : " + responseData) - msoLogger.debug("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', vfModule) - def vnfName = execution.getVariable('PUAAIVfMod_vnfName') - msoLogger.debug('Output PUAAIVfMod_vnfName set to ' + vnfName) - // TODO: Should deprecate use of processKey+Response variable for the response. Will use "WorkflowResponse" instead - execution.setVariable('WorkflowResponse', vfModule) - - def heatStackId = vfModule.getHeatStackId() - execution.setVariable('PUAAIVfMod_heatStackId', heatStackId) - msoLogger.debug('Output PUAAIVfMod_heatStackId set to \'' + heatStackId + '\'') - } catch (Exception ex) { - ex.printStackTrace() - msoLogger.debug('Exception occurred while executing AAI PUT:' + ex.getMessage()) - execution.setVariable('PUAAIVfMod_updateVfModuleResponseCode', 500) - execution.setVariable('PUAAIVfMod_updateVfModuleResponse', 'AAI PATCH Failed:' + ex.getMessage()) - } msoLogger.trace('Exited ' + method) } catch (BpmnError e) { throw e; diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV1.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV1.groovy index f610ea4782..d7fc6ac995 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV1.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV1.groovy @@ -21,6 +21,7 @@ package org.onap.so.bpmn.common.scripts import java.text.SimpleDateFormat +import javax.ws.rs.core.Response import java.net.URLEncoder import org.apache.commons.codec.binary.Base64 @@ -36,11 +37,10 @@ import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.bpmn.core.WorkflowException import org.onap.so.bpmn.core.domain.RollbackData import org.onap.so.bpmn.core.json.JsonUtils -import org.onap.so.rest.APIResponse -import org.onap.so.rest.RESTClient -import org.onap.so.rest.RESTConfig +import org.onap.so.client.HttpClient import org.onap.so.logger.MessageEnum import org.onap.so.logger.MsoLogger +import org.onap.so.utils.TargetEntity @@ -205,23 +205,23 @@ class SDNCAdapterRestV1 extends AbstractServiceTaskProcessor { String sdncAdapterRequest = execution.getVariable(prefix + 'sdncAdapterRequest') msoLogger.debug("SDNC Rest Request is: " + sdncAdapterRequest) - RESTConfig config = new RESTConfig(sdncAdapterUrl) - RESTClient client = new RESTClient(config). - addHeader("Content-Type", "application/json") - .addHeader("mso-request-id",execution.getVariable("mso-request-id")) - .addHeader("mso-service-instance-id",execution.getVariable("mso-service-instance-id")) - .addAuthorizationHeader(execution.getVariable(prefix + "basicAuthHeaderValue")) + URL url = new URL(sdncAdapterUrl); - APIResponse response + HttpClient httpClient = new HttpClient(url, "application/json", TargetEntity.SDNC_ADAPTER) + httpClient.addAdditionalHeader("mso-request-id", execution.getVariable("mso-request-id")) + httpClient.addAdditionalHeader("mso-service-instance-id", execution.getVariable("mso-service-instance-id")) + httpClient.addAdditionalHeader("Authorization", execution.getVariable(prefix + "basicAuthHeaderValue")) + + Response response if ("GET".equals(sdncAdapterMethod)) { - response = client.httpGet() + response = httpClient.get() } else if ("PUT".equals(sdncAdapterMethod)) { - response = client.httpPut(sdncAdapterRequest) + response = httpClient.put(sdncAdapterRequest) } else if ("POST".equals(sdncAdapterMethod)) { - response = client.httpPost(sdncAdapterRequest) + response = httpClient.post(sdncAdapterRequest) } else if ("DELETE".equals(sdncAdapterMethod)) { - response = client.httpDelete(sdncAdapterRequest) + response = httpClient.delete(sdncAdapterRequest) } else { String msg = 'Unsupported HTTP method "' + sdncAdapterMethod + '" in ' + method + ": " + e msoLogger.debug(msg) @@ -229,13 +229,15 @@ class SDNCAdapterRestV1 extends AbstractServiceTaskProcessor { exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } - execution.setVariable(prefix + "sdncAdapterStatusCode", response.getStatusCode()) - execution.setVariable(prefix + "sdncAdapterResponse", response.getResponseBodyAsString()) + execution.setVariable(prefix + "sdncAdapterStatusCode", response.getStatus()) + if(response.hasEntity()){ + execution.setVariable(prefix + "sdncAdapterResponse", response.readEntity(String.class)) + } } catch (BpmnError e) { throw e } catch (Exception e) { String msg = 'Caught exception in ' + method + ": " + e - msoLogger.debug(msg) + msoLogger.debug(msg, e) msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, ""); exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV2.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV2.groovy index 967b9fa93f..1a20497bbc 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV2.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV2.groovy @@ -7,9 +7,9 @@ * 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. @@ -34,9 +34,6 @@ import org.json.JSONObject import org.onap.so.bpmn.core.WorkflowException import org.onap.so.bpmn.core.json.JsonUtils -import org.onap.so.rest.APIResponse -import org.onap.so.rest.RESTClient -import org.onap.so.rest.RESTConfig import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.logger.MessageEnum import org.onap.so.logger.MsoLogger @@ -224,7 +221,7 @@ class SDNCAdapterRestV2 extends SDNCAdapterRestV1 { if (responseType.endsWith('Error')) { sdncAdapterBuildWorkflowException(execution, callback) } - + // Check for possible interim notification execution.setVariable(prefix + "interimNotification", null) execution.setVariable(prefix + "doInterimNotification", false) @@ -235,7 +232,7 @@ class SDNCAdapterRestV2 extends SDNCAdapterRestV1 { execution.setVariable(prefix + "doInterimNotification", true) } } - + } catch (Exception e) { callback = callback == null || String.valueOf(callback).isEmpty() ? "NONE" : callback String msg = "Received error from SDNCAdapter: " + callback @@ -243,7 +240,7 @@ class SDNCAdapterRestV2 extends SDNCAdapterRestV1 { exceptionUtil.buildWorkflowException(execution, 5300, msg) } } - + /** * Prepare to send an interim notification by extracting the variable/value definitions * in the interimNotification JSON object and placing them in the execution. These @@ -254,21 +251,21 @@ class SDNCAdapterRestV2 extends SDNCAdapterRestV1 { 'execution=' + execution.getId() + ')' msoLogger.trace('Entered ' + method) - + String prefix = execution.getVariable('prefix') msoLogger.debug("Preparing Interim Notification") try { def interimNotification = execution.getVariable(prefix + "interimNotification") msoLogger.debug("Preparing Interim Notification:\n" + JsonUtils.prettyJson(interimNotification)) - + for (int i = 0; ; i++) { def variable = JsonUtils.getJsonParamValue(interimNotification, 'variableList', 'variable', i) - + if (variable == null) { break } - + def String variableName = JsonUtils.getJsonValue(variable, "name") if ((variableName != null) && !variableName.isEmpty()) { def variableValue = JsonUtils.getJsonValue(variable, "value") @@ -276,7 +273,7 @@ class SDNCAdapterRestV2 extends SDNCAdapterRestV1 { msoLogger.debug("Setting "+ variableName + "=" + variableValue) } } - + } catch (Exception e) { String msg = "Error preparing interim notification" msoLogger.debug(getProcessKey(execution) + ': ' + msg) diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SniroHomingV1.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SniroHomingV1.groovy index 8d14ead6e0..401cac9820 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SniroHomingV1.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SniroHomingV1.groovy @@ -33,15 +33,18 @@ import org.onap.so.bpmn.core.domain.ServiceDecomposition import org.onap.so.bpmn.core.domain.Subscriber import org.onap.so.bpmn.core.domain.VnfResource import org.onap.so.bpmn.core.json.JsonUtils -import org.onap.so.rest.APIResponse -import org.onap.so.rest.RESTClient -import org.onap.so.rest.RESTConfig +import org.onap.so.client.HttpClient +import org.onap.so.utils.TargetEntity import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.json.JSONArray import org.json.JSONObject import static org.onap.so.bpmn.common.scripts.GenericUtils.*; + +import java.net.URL + +import javax.ws.rs.core.Response import org.onap.so.logger.MessageEnum import org.onap.so.logger.MsoLogger @@ -126,20 +129,25 @@ class SniroHomingV1 extends AbstractServiceTaskProcessor{ String endpoint = UrnPropertiesReader.getVariable("sniro.manager.uri.v1", execution) String host = UrnPropertiesReader.getVariable("sniro.manager.host", execution) - String url = host + endpoint - msoLogger.debug("Sniro Url is: " + url) + String urlString = host + endpoint + msoLogger.debug("Sniro Url is: " + urlString) + + URL url = new URL(urlString); + HttpClient httpClient = new HttpClient(url, "application/json", TargetEntity.SNIRO) + httpClient.addAdditionalHeader("Authorization", authHeader) + Response httpResponse = httpClient.post(sniroRequest) - RESTConfig config = new RESTConfig(url); - RESTClient client = new RESTClient(config).addAuthorizationHeader(authHeader).addHeader("Content-Type", "application/json") - APIResponse response = client.httpPost(sniroRequest) + int responseCode = httpResponse.getStatus() - int responseCode = response.getStatusCode() msoLogger.debug("Sniro sync response code is: " + responseCode) - msoLogger.debug("Sniro sync response is: " + response.getResponseBodyAsString()) + if(httpResponse.hasEntity()){ + msoLogger.debug("Sniro sync response is: " + httpResponse.readEntity(String.class)) + } if(responseCode != 202){ exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from Sniro.") } + msoLogger.trace("Completed Sniro Homing Call Sniro") } }catch(BpmnError b){ diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterRestV1.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterRestV1.groovy index 52f45c205c..13cc7f8d11 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterRestV1.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterRestV1.groovy @@ -7,9 +7,9 @@ * 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. @@ -20,15 +20,15 @@ package org.onap.so.bpmn.common.scripts +import javax.ws.rs.core.Response import org.apache.commons.lang3.* import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.so.bpmn.core.UrnPropertiesReader -import org.onap.so.rest.APIResponse -import org.onap.so.rest.RESTClient -import org.onap.so.rest.RESTConfig +import org.onap.so.client.HttpClient import org.onap.so.logger.MessageEnum import org.onap.so.logger.MsoLogger +import org.onap.so.utils.TargetEntity @@ -67,7 +67,7 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor { if ('rollbackVolumeGroupRequest'.equals(requestType)) { messageId = getMessageIdForVolumeGroupRollback(root) } - + if (messageId == null || messageId.isEmpty()) { String msg = getProcessKey(execution) + ': no messageId in ' + requestType msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, ""); @@ -281,7 +281,7 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor { exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } } - + public String getVolumeGroupIdFromRollbackRequest(Node root) { return root.'volumeGroupRollback'.'volumeGroupId'.text() } @@ -289,7 +289,7 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor { public String getMessageIdForVolumeGroupRollback(Node root) { return root.'volumeGroupRollback'.'messageId'.text() } - + /** * This method is used instead of an HTTP Connector task because the * connector does not allow DELETE with a body. @@ -307,29 +307,31 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor { 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")); + URL url = new URL(vnfAdapterUrl); - APIResponse response; + HttpClient httpClient = new HttpClient(url, "application/xml", TargetEntity.VNF_ADAPTER) + httpClient.addAdditionalHeader("Authorization", execution.getVariable(prefix + "basicAuthHeaderValue")) + + Response response; if ("GET".equals(vnfAdapterMethod)) { - response = client.httpGet() + response = httpClient.get() } else if ("PUT".equals(vnfAdapterMethod)) { - response = client.httpPut(vnfAdapterRequest) + response = httpClient.put(vnfAdapterRequest) } else if ("POST".equals(vnfAdapterMethod)) { - response = client.httpPost(vnfAdapterRequest) + response = httpClient.post(vnfAdapterRequest) } else if ("DELETE".equals(vnfAdapterMethod)) { - response = client.httpDelete(vnfAdapterRequest) + response = httpClient.delete(vnfAdapterRequest) } else { String msg = 'Unsupported HTTP method "' + vnfAdapterMethod + '" in ' + method + ": " + e msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, ""); exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } - execution.setVariable(prefix + "vnfAdapterStatusCode", response.getStatusCode()) - execution.setVariable(prefix + "vnfAdapterResponse", response.getResponseBodyAsString()) + execution.setVariable(prefix + "vnfAdapterStatusCode", response.getStatus()) + if(response.hasEntity()){ + execution.setVariable(prefix + "vnfAdapterResponse", response.readEntity(String.class)) + } } catch (BpmnError e) { throw e } catch (Exception e) { diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/workflow/context/WorkflowContextHolder.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/workflow/context/WorkflowContextHolder.java index 39c32de77d..eb7290b685 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/workflow/context/WorkflowContextHolder.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/workflow/context/WorkflowContextHolder.java @@ -81,13 +81,10 @@ public class WorkflowContextHolder { 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); + if (requestId.equals(context.getRequestId())) { return context; } } - - msoLogger.debug("Unable to find context for request id: " + requestId); return null; } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/AggregateRoute.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/AggregateRoute.java new file mode 100644 index 0000000000..cb9c681fd5 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/AggregateRoute.java @@ -0,0 +1,107 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 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.onap.so.bpmn.servicedecomposition.bbobjects; + +import java.io.Serializable; + +import javax.persistence.Id; + +import org.onap.so.bpmn.servicedecomposition.ShallowCopy; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; +import org.apache.commons.lang3.builder.HashCodeBuilder; +import org.apache.commons.lang3.builder.EqualsBuilder; + +@JsonRootName("aggregate-route") +public class AggregateRoute implements Serializable, ShallowCopy<AggregateRoute>{ + + private static final long serialVersionUID = -1059128545462701696L; + + @Id + @JsonProperty("route-id") + private String routeId; + @JsonProperty("route-name") + private String routeName; + @JsonProperty("network-start-address") + private String networkStartAddress; + @JsonProperty("cidr-mask") + private String cidrMask; + @JsonProperty("ip-version") + private String ipVersion; + + + public String getRouteId(){ + return routeId; + } + + public void setRouteId(String routeId){ + this.routeId = routeId; + } + + public String getRouteName(){ + return routeName; + } + + public void setRouteName(String routeName){ + this.routeName = routeName; + } + + public String getNetworkStartAddress(){ + return networkStartAddress; + } + + public void setNetworkStartAddress(String networkStartAddress){ + this.networkStartAddress = networkStartAddress; + } + + public String getCidrMask(){ + return cidrMask; + } + + public void setCidrMask(String cidrMask){ + this.cidrMask = cidrMask; + } + + public String getIpVersion(){ + return ipVersion; + } + + public void setIpVersion(String ipVersion){ + this.ipVersion = ipVersion; + } + + @Override + public boolean equals(final Object other){ + if(!(other instanceof AggregateRoute)){ + return false; + } + AggregateRoute castOther = (AggregateRoute) other; + return new EqualsBuilder().append(routeId, castOther.routeId).isEquals(); + } + + @Override + public int hashCode(){ + return new HashCodeBuilder().append(routeId).toHashCode(); + } + + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/L3Network.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/L3Network.java index 5f43ba076a..343bd95eaa 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/L3Network.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/L3Network.java @@ -7,9 +7,9 @@ * 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. @@ -41,7 +41,7 @@ import com.fasterxml.jackson.annotation.JsonRootName; public class L3Network implements Serializable, ShallowCopy<L3Network> { private static final long serialVersionUID = 4434492567957111317L; - + @Id @JsonProperty("network-id") private String networkId; @@ -99,6 +99,8 @@ public class L3Network implements Serializable, ShallowCopy<L3Network> { private List<SegmentationAssignment> segmentationAssignments = new ArrayList<>(); @JsonProperty("model-info-network") private ModelInfoNetwork modelInfoNetwork; + @JsonProperty("aggregate-routes") + private List<AggregateRoute> aggregateRoutes = new ArrayList<>(); public ModelInfoNetwork getModelInfoNetwork() { return modelInfoNetwork; @@ -254,6 +256,11 @@ public class L3Network implements Serializable, ShallowCopy<L3Network> { public void setCloudParams(Map<String, String> cloudParams) { this.cloudParams = cloudParams; } + + public List<AggregateRoute> getAggregateRoutes(){ + return aggregateRoutes; + } + @Override public boolean equals(final Object other) { if (!(other instanceof L3Network)) { diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildingBlockRainyDay.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildingBlockRainyDay.java index e815051eaa..32540eb996 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildingBlockRainyDay.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildingBlockRainyDay.java @@ -33,6 +33,7 @@ import org.onap.so.db.catalog.beans.macro.RainyDayHandlerStatus; import org.onap.so.db.catalog.client.CatalogDbClient; import org.onap.so.logger.MsoLogger; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; @Component @@ -44,12 +45,17 @@ public class ExecuteBuildingBlockRainyDay { @Autowired private CatalogDbClient catalogDbClient; private static final String ASTERISK = "*"; + + @Autowired + private Environment environment; + protected String retryDurationPath = "mso.rainyDay.retryDurationMultiplier"; public void setRetryTimer(DelegateExecution execution) { try { + int retryDurationMult = Integer.parseInt(this.environment.getProperty(retryDurationPath)); int retryCount = (int) execution.getVariable("retryCount"); - int retryTimeToWait = (int) Math.pow(5, retryCount); - String RetryDuration = "PT" + retryTimeToWait + "M"; + int retryTimeToWait = (int) Math.pow(retryDurationMult, retryCount) * 10; + String RetryDuration = "PT" + retryTimeToWait + "S"; execution.setVariable("RetryDuration", RetryDuration); } catch (Exception e) { msoLogger.error(e); @@ -64,6 +70,7 @@ public class ExecuteBuildingBlockRainyDay { GeneralBuildingBlock gBBInput = (GeneralBuildingBlock) execution.getVariable("gBBInput"); Map<ResourceKey, String> lookupKeyMap = (Map<ResourceKey, String>) execution.getVariable("lookupKeyMap"); String serviceType = ASTERISK; + boolean aLaCarte = (boolean) execution.getVariable("aLaCarte"); try { serviceType = gBBInput.getCustomer().getServiceSubscription().getServiceInstances().get(0).getModelInfoServiceInstance().getServiceType(); } catch (Exception ex) { @@ -115,10 +122,13 @@ public class ExecuteBuildingBlockRainyDay { handlingCode = rainyDayHandlerStatus.getSecondaryPolicy(); } } + if(handlingCode.equals("RollbackToAssigned")&&!aLaCarte){ + handlingCode = "Rollback"; + } msoLogger.debug("RainyDayHandler Status Code is: " + handlingCode); execution.setVariable(HANDLING_CODE, handlingCode); } catch (Exception e) { - msoLogger.debug("RainyDayHandler Status Code is: Abort"); + msoLogger.error("Failed to determine RainyDayHandler Status. Seting handlingCode = Abort"); execution.setVariable(HANDLING_CODE, "Abort"); } } diff --git a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/BuildingBlock/HomingV2.bpmn b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/BuildingBlock/HomingV2.bpmn deleted file mode 100644 index 9481ad892e..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/BuildingBlock/HomingV2.bpmn +++ /dev/null @@ -1,194 +0,0 @@ -<?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:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.10.0"> - <bpmn:process id="HomingV2" name="HomingV2" isExecutable="true"> - <bpmn:startEvent id="start"> - <bpmn:outgoing>SequenceFlow_0gpuwes</bpmn:outgoing> - </bpmn:startEvent> - <bpmn:subProcess id="subprocessBpmnError" name="Error Handling Subprocess" triggeredByEvent="true"> - <bpmn:endEvent id="endBpmnError"> - <bpmn:incoming>SequenceFlow_14dg22y</bpmn:incoming> - <bpmn:terminateEventDefinition /> - </bpmn:endEvent> - <bpmn:startEvent id="catchBpmnError"> - <bpmn:outgoing>SequenceFlow_0g3mn4b</bpmn:outgoing> - <bpmn:errorEventDefinition /> - </bpmn:startEvent> - <bpmn:scriptTask id="processBpmnError" name="Process Error" scriptFormat="groovy"> - <bpmn:incoming>SequenceFlow_0g3mn4b</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_14dg22y</bpmn:outgoing> - <bpmn:script><![CDATA[import org.onap.so.bpmn.common.scripts.* -ExceptionUtil ex = new ExceptionUtil() -ex.processSubflowsBPMNException(execution)]]></bpmn:script> - </bpmn:scriptTask> - <bpmn:sequenceFlow id="SequenceFlow_14dg22y" sourceRef="processBpmnError" targetRef="endBpmnError" /> - <bpmn:sequenceFlow id="SequenceFlow_0g3mn4b" sourceRef="catchBpmnError" targetRef="processBpmnError" /> - </bpmn:subProcess> - <bpmn:subProcess id="subprocessJavaException" triggeredByEvent="true"> - <bpmn:scriptTask id="processJavaException" name="Process Error" scriptFormat="groovy"> - <bpmn:incoming>seq</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_1epbfhx</bpmn:outgoing> - <bpmn:script><![CDATA[import org.onap.so.bpmn.common.scripts.* -ExceptionUtil ex = new ExceptionUtil() -ex.processJavaException(execution)]]></bpmn:script> - </bpmn:scriptTask> - <bpmn:startEvent id="catchJavaException"> - <bpmn:outgoing>seq</bpmn:outgoing> - <bpmn:errorEventDefinition errorRef="Error_0jmwlex" /> - </bpmn:startEvent> - <bpmn:endEvent id="endJavaException"> - <bpmn:incoming>SequenceFlow_1epbfhx</bpmn:incoming> - <bpmn:terminateEventDefinition /> - </bpmn:endEvent> - <bpmn:sequenceFlow id="seq" name="" sourceRef="catchJavaException" targetRef="processJavaException" /> - <bpmn:sequenceFlow id="SequenceFlow_1epbfhx" name="" sourceRef="processJavaException" targetRef="endJavaException" /> - </bpmn:subProcess> - <bpmn:callActivity id="callReceiveAsync" name="Receive Async Callback" camunda:modelerTemplate="receiveWorkflowMessage" calledElement="ReceiveWorkflowMessage"> - <bpmn:extensionElements> - <camunda:in source="true" target="isDebugLogEnabled" /> - <camunda:out source="WorkflowException" target="WorkflowException" /> - <camunda:out source="WorkflowResponse" target="asyncResponse" /> - <camunda:in source="asyncCorrelator" target="RCVWFMSG_correlator" /> - <camunda:in source="asyncMessageType" target="RCVWFMSG_messageType" /> - <camunda:in source="asyncTimeout" target="RCVWFMSG_timeout" /> - </bpmn:extensionElements> - <bpmn:incoming>sequence_2</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_0m9c6gt</bpmn:outgoing> - </bpmn:callActivity> - <bpmn:endEvent id="end"> - <bpmn:incoming>updateExecution</bpmn:incoming> - <bpmn:terminateEventDefinition /> - </bpmn:endEvent> - <bpmn:sequenceFlow id="SequenceFlow_0gpuwes" sourceRef="start" targetRef="callSniro" /> - <bpmn:sequenceFlow id="sequence_2" sourceRef="callSniro" targetRef="callReceiveAsync" /> - <bpmn:sequenceFlow id="SequenceFlow_0m9c6gt" sourceRef="callReceiveAsync" targetRef="processSolution" /> - <bpmn:sequenceFlow id="updateExecution" sourceRef="processSolution" targetRef="end" /> - <bpmn:serviceTask id="callSniro" name=" Call Sniro " camunda:expression="${SniroHoming.callSniro(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> - <bpmn:incoming>SequenceFlow_0gpuwes</bpmn:incoming> - <bpmn:outgoing>sequence_2</bpmn:outgoing> - </bpmn:serviceTask> - <bpmn:serviceTask id="processSolution" name=" Process Solution " camunda:expression="${SniroHoming.processSolution(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")), asyncResponse)}"> - <bpmn:incoming>SequenceFlow_0m9c6gt</bpmn:incoming> - <bpmn:outgoing>updateExecution</bpmn:outgoing> - </bpmn:serviceTask> - </bpmn:process> - <bpmn:error id="Error_0jmwlex" name="Java Exception" errorCode="java.lang.Exception" /> - <bpmndi:BPMNDiagram id="BPMNDiagram_1"> - <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="HomingV2"> - <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="start"> - <dc:Bounds x="135" y="225" width="36" height="36" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="108" y="261" width="90" height="20" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="SubProcess_1se9fyh_di" bpmnElement="subprocessBpmnError" isExpanded="true"> - <dc:Bounds x="246" y="399" width="409" height="168" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="SubProcess_0rphl19_di" bpmnElement="subprocessJavaException" isExpanded="true"> - <dc:Bounds x="276" y="582" width="350" height="159" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="CallActivity_1o5l6xd_di" bpmnElement="callReceiveAsync"> - <dc:Bounds x="447" y="203" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="EndEvent_0jdabkl_di" bpmnElement="end"> - <dc:Bounds x="852" y="225" width="36" height="36" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="824" y="265" width="0" height="12" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_0gpuwes_di" bpmnElement="SequenceFlow_0gpuwes"> - <di:waypoint xsi:type="dc:Point" x="171" y="243" /> - <di:waypoint xsi:type="dc:Point" x="305" y="243" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="238" y="222" width="0" height="12" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_1ohpzke_di" bpmnElement="sequence_2"> - <di:waypoint xsi:type="dc:Point" x="405" y="243" /> - <di:waypoint xsi:type="dc:Point" x="447" y="243" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="426" y="222" width="0" height="12" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_0m9c6gt_di" bpmnElement="SequenceFlow_0m9c6gt"> - <di:waypoint xsi:type="dc:Point" x="547" y="243" /> - <di:waypoint xsi:type="dc:Point" x="589" y="243" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="568" y="222" width="0" height="12" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_0f9pput_di" bpmnElement="updateExecution"> - <di:waypoint xsi:type="dc:Point" x="689" y="243" /> - <di:waypoint xsi:type="dc:Point" x="852" y="243" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="770.5" y="222" width="0" height="12" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="EndEvent_0q9vsib_di" bpmnElement="endBpmnError"> - <dc:Bounds x="571" y="473" width="36" height="36" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="544" y="514" width="0" height="12" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="StartEvent_1p10ecj_di" bpmnElement="catchBpmnError"> - <dc:Bounds x="291" y="473" width="36" height="36" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="264" y="514" width="0" height="12" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="ScriptTask_112ioi2_di" bpmnElement="processBpmnError"> - <dc:Bounds x="398" y="451" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="ScriptTask_0nil5vh_di" bpmnElement="processJavaException"> - <dc:Bounds x="402" y="630" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="StartEvent_0ekzjqo_di" bpmnElement="catchJavaException"> - <dc:Bounds x="310" y="652" width="36" height="36" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="283" y="693" width="0" height="12" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="EndEvent_0mrji6a_di" bpmnElement="endJavaException"> - <dc:Bounds x="559" y="652" width="36" height="36" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="532" y="693" width="0" height="12" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_14dg22y_di" bpmnElement="SequenceFlow_14dg22y"> - <di:waypoint xsi:type="dc:Point" x="498" y="491" /> - <di:waypoint xsi:type="dc:Point" x="571" y="491" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="490.5" y="476" width="0" height="12" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_0g3mn4b_di" bpmnElement="SequenceFlow_0g3mn4b"> - <di:waypoint xsi:type="dc:Point" x="327" y="491" /> - <di:waypoint xsi:type="dc:Point" x="355" y="491" /> - <di:waypoint xsi:type="dc:Point" x="355" y="491" /> - <di:waypoint xsi:type="dc:Point" x="398" y="491" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="325" y="491" width="0" height="12" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_1bsc30u_di" bpmnElement="seq"> - <di:waypoint xsi:type="dc:Point" x="346" y="670" /> - <di:waypoint xsi:type="dc:Point" x="402" y="670" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="329" y="655" width="0" height="12" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_1epbfhx_di" bpmnElement="SequenceFlow_1epbfhx"> - <di:waypoint xsi:type="dc:Point" x="502" y="670" /> - <di:waypoint xsi:type="dc:Point" x="559" y="670" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="486.5" y="655" width="0" height="12" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="ServiceTask_1mclgnq_di" bpmnElement="callSniro"> - <dc:Bounds x="305" y="203" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="ServiceTask_08lua6t_di" bpmnElement="processSolution"> - <dc:Bounds x="589" y="203" width="100" height="80" /> - </bpmndi:BPMNShape> - </bpmndi:BPMNPlane> - </bpmndi:BPMNDiagram> -</bpmn:definitions> diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/AaiUtilTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/AaiUtilTest.groovy deleted file mode 100644 index 1165bbbc71..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/AaiUtilTest.groovy +++ /dev/null @@ -1,168 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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.onap.so.bpmn.common.scripts - -import com.github.tomakehurst.wiremock.junit.WireMockRule - -import static org.junit.Assert.*; -import static org.mockito.Mockito.* - -import org.onap.so.rest.HttpHeader -import org.mockito.MockitoAnnotations -import org.mockito.runners.MockitoJUnitRunner -import org.mockito.internal.debugging.MockitoDebuggerImpl -import org.junit.Before -import org.onap.so.bpmn.common.scripts.AaiUtil; -import org.junit.Rule; -import org.junit.Test -import org.junit.rules.ExpectedException -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 - -class AaiUtilTest extends MsoGroovyTest { - - - @Rule - public WireMockRule wireMockRule = new WireMockRule(8090); - - @Rule - public ExpectedException thrown = ExpectedException.none() - - - def aaiPaylod = "<allotted-resource xmlns=\"http://org.openecomp.aai.inventory/v9\">\n" + - "\t\t\t\t<id>allottedResourceId</id>\n" + - "\t\t\t\t<description></description>\n" + - "\t\t\t\t<type>allottedResourceType</type>\n" + - "\t\t\t\t<role>allottedResourceRole</role>\n" + - "\t\t\t\t<selflink></selflink>\n" + - "\t\t\t\t<model-invariant-id></model-invariant-id>\n" + - "\t\t\t\t<model-version-id></model-version-id>\n" + - "\t\t\t\t<model-customization-id></model-customization-id>\n" + - "\t\t\t\t<orchestration-status>PendingCreate</orchestration-status>\n" + - "\t\t\t\t<operation-status></operation-status>\n" + - "\t\t\t\t<relationship-list>\n" + - "\t\t\t\t\t<relationship>\n" + - " \t\t\t<related-to>service-instance</related-to>\n" + - " \t\t\t<related-link>CSI_resourceLink</related-link>\n" + - "\t\t\t\t\t</relationship>\n" + - "\t\t\t\t</relationship-list>\n" + - "\t\t\t</allotted-resource>"; - - @Test - public void testGetVersionDefault() { - ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - when(mockExecution.getVariable("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("mso.workflow.default.aai.l3-network.version")).thenReturn('7') - when(mockExecution.getVariable("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("mso.workflow.custom.CreateAAIVfModule.aai.version")).thenReturn('6') - when(mockExecution.getVariable("mso.workflow.default.aai.l3-network.version")).thenReturn('7') - - when(mockExecution.getVariable("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 - public void testGetVersionNotDefined() { - thrown.expect(Exception.class) - ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn("") - - def version = aaiUtil.getVersion(mockExecution, 'l3-network', 'CreateAAIVfModule') - - } - - @Test - @Ignore - public void testExecuteAAIGetCall() { - ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - when(mockExecution.getVariable("aai.auth")).thenReturn("9B2278E8B8E95F256A560719055F4DF3") - when(mockExecution.getVariable("mso.msoKey")).thenReturn("aa3871669d893c7fb8abbcda31b88b4f") - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - def uri = aaiUtil.executeAAIGetCall(mockExecution,"http://localhost:8090/aai/v9/business/customers/customer/CUST/service-subscriptions/service-subscription/SVC/service-instances/service-instance/NST/allotted-resources/allotted-resource/allottedResourceId") - } - - - @Test - @Ignore - public void testExecuteAAIPutCall() { - ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - when(mockExecution.getVariable("aai.auth")).thenReturn("9B2278E8B8E95F256A560719055F4DF3") - when(mockExecution.getVariable("mso.msoKey")).thenReturn("aa3871669d893c7fb8abbcda31b88b4f") - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - def uri = aaiUtil.executeAAIPutCall(mockExecution,"http://localhost:8090/aai/v9/business/customers/customer/CUST/service-subscriptions/service-subscription/SVC/service-instances/service-instance/NST/allotted-resources/allotted-resource/allottedResourceId",aaiPaylod) - } - - @Test - public void testGetNamespaceFromUri_twoArguments() { // (execution, uri) - ExecutionEntity mockExecution = setupMock('DeleteVfModuleVolumeInfraV1') - // - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('10') - when(mockExecution.getVariable("mso.workflow.default.aai.v10.l3-network.uri")).thenReturn('/aai/v10/network/l3-networks/l3-network') - when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') - // - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - def ns = aaiUtil.getNamespaceFromUri(mockExecution, '/aai/v10/search/generic-query') - assertEquals('http://org.openecomp.aai.inventory/v10', ns) - } -} diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/AbstractServiceTaskProcessorTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/AbstractServiceTaskProcessorTest.groovy index 459b18b7f1..3c3e4aca91 100644 --- a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/AbstractServiceTaskProcessorTest.groovy +++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/AbstractServiceTaskProcessorTest.groovy @@ -1,22 +1,22 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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========================================================= - */ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.onap.so.bpmn.common.scripts @@ -30,7 +30,6 @@ import org.onap.so.bpmn.core.WorkflowException; import static org.junit.Assert.*; import static org.mockito.Mockito.* -import org.onap.so.rest.HttpHeader import org.mockito.MockitoAnnotations import org.mockito.junit.MockitoJUnitRunner; import org.mockito.internal.debugging.MockitoDebuggerImpl diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildlingBlockRainyDayTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildlingBlockRainyDayTest.java index 8fe20de5f0..fc2de4307b 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildlingBlockRainyDayTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildlingBlockRainyDayTest.java @@ -20,9 +20,7 @@ package org.onap.so.bpmn.servicedecomposition.tasks; -import static org.hamcrest.CoreMatchers.any; import static org.junit.Assert.assertEquals; -import static org.mockito.ArgumentMatchers.any; import static org.mockito.Matchers.eq; import static org.mockito.ArgumentMatchers.isA; import static org.mockito.Mockito.doReturn; @@ -34,13 +32,13 @@ import org.camunda.bpm.engine.delegate.BpmnError; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.junit.Before; import org.junit.Test; +import org.onap.so.BaseTest; import org.onap.so.bpmn.core.WorkflowException; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock; import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; -import org.onap.so.BaseTest; import org.onap.so.db.catalog.beans.macro.RainyDayHandlerStatus; import org.springframework.beans.factory.annotation.Autowired; @@ -77,7 +75,7 @@ public class ExecuteBuildlingBlockRainyDayTest extends BaseTest { public void setRetryTimerTest() throws Exception{ delegateExecution.setVariable("retryCount", 2); executeBuildingBlockRainyDay.setRetryTimer(delegateExecution); - assertEquals("PT25M",delegateExecution.getVariable("RetryDuration")); + assertEquals("PT40S",delegateExecution.getVariable("RetryDuration")); } @Test @@ -93,7 +91,7 @@ public class ExecuteBuildlingBlockRainyDayTest extends BaseTest { customer.getServiceSubscription().getServiceInstances().add(serviceInstance); serviceInstance.getModelInfoServiceInstance().setServiceType("st1"); vnf.setVnfType("vnft1"); - + delegateExecution.setVariable("aLaCarte", true); RainyDayHandlerStatus rainyDayHandlerStatus = new RainyDayHandlerStatus(); rainyDayHandlerStatus.setErrorCode("7000"); rainyDayHandlerStatus.setFlowName("AssignServiceInstanceBB"); @@ -114,7 +112,7 @@ public class ExecuteBuildlingBlockRainyDayTest extends BaseTest { customer.getServiceSubscription().getServiceInstances().add(serviceInstance); serviceInstance.getModelInfoServiceInstance().setServiceType("st1"); vnf.setVnfType("vnft1"); - + delegateExecution.setVariable("aLaCarte", true); RainyDayHandlerStatus rainyDayHandlerStatus = new RainyDayHandlerStatus(); rainyDayHandlerStatus.setErrorCode(ASTERISK); rainyDayHandlerStatus.setFlowName("AssignServiceInstanceBB"); @@ -136,7 +134,7 @@ public class ExecuteBuildlingBlockRainyDayTest extends BaseTest { customer.getServiceSubscription().getServiceInstances().add(serviceInstance); serviceInstance.getModelInfoServiceInstance().setServiceType("st1"); vnf.setVnfType("vnft1"); - + delegateExecution.setVariable("aLaCarte", true); doReturn(null).when(MOCK_catalogDbClient).getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep(isA(String.class), isA(String.class), isA(String.class), isA(String.class), isA(String.class)); executeBuildingBlockRainyDay.queryRainyDayTable(delegateExecution,true); @@ -147,7 +145,7 @@ public class ExecuteBuildlingBlockRainyDayTest extends BaseTest { @Test public void queryRainyDayTableExceptionTest() { doThrow(RuntimeException.class).when(MOCK_catalogDbClient).getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep(isA(String.class), isA(String.class), isA(String.class), isA(String.class), isA(String.class)); - + delegateExecution.setVariable("aLaCarte", true); executeBuildingBlockRainyDay.queryRainyDayTable(delegateExecution,true); assertEquals("Abort", delegateExecution.getVariable("handlingCode")); @@ -158,6 +156,7 @@ public class ExecuteBuildlingBlockRainyDayTest extends BaseTest { customer.getServiceSubscription().getServiceInstances().add(serviceInstance); serviceInstance.getModelInfoServiceInstance().setServiceType("st1"); vnf.setVnfType("vnft1"); + delegateExecution.setVariable("aLaCarte", true); RainyDayHandlerStatus rainyDayHandlerStatus = new RainyDayHandlerStatus(); rainyDayHandlerStatus.setErrorCode("7000"); @@ -175,4 +174,50 @@ public class ExecuteBuildlingBlockRainyDayTest extends BaseTest { assertEquals("Abort", delegateExecution.getVariable("handlingCode")); } + @Test + public void queryRainyDayTableRollbackToAssignedMacro() throws Exception{ + customer.getServiceSubscription().getServiceInstances().add(serviceInstance); + serviceInstance.getModelInfoServiceInstance().setServiceType("st1"); + vnf.setVnfType("vnft1"); + delegateExecution.setVariable("aLaCarte", false); + + RainyDayHandlerStatus rainyDayHandlerStatus = new RainyDayHandlerStatus(); + rainyDayHandlerStatus.setErrorCode("7000"); + rainyDayHandlerStatus.setFlowName("AssignServiceInstanceBB"); + rainyDayHandlerStatus.setServiceType("st1"); + rainyDayHandlerStatus.setVnfType("vnft1"); + rainyDayHandlerStatus.setPolicy("RollbackToAssigned"); + rainyDayHandlerStatus.setWorkStep(ASTERISK); + rainyDayHandlerStatus.setSecondaryPolicy("Abort"); + + doReturn(rainyDayHandlerStatus).when(MOCK_catalogDbClient).getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep("AssignServiceInstanceBB", "st1", "vnft1", "7000", "*"); + + executeBuildingBlockRainyDay.queryRainyDayTable(delegateExecution,true); + + assertEquals("Rollback", delegateExecution.getVariable("handlingCode")); + } + + @Test + public void queryRainyDayTableRollbackToAssignedALaCarte() throws Exception{ + customer.getServiceSubscription().getServiceInstances().add(serviceInstance); + serviceInstance.getModelInfoServiceInstance().setServiceType("st1"); + vnf.setVnfType("vnft1"); + delegateExecution.setVariable("aLaCarte", true); + + RainyDayHandlerStatus rainyDayHandlerStatus = new RainyDayHandlerStatus(); + rainyDayHandlerStatus.setErrorCode("7000"); + rainyDayHandlerStatus.setFlowName("AssignServiceInstanceBB"); + rainyDayHandlerStatus.setServiceType("st1"); + rainyDayHandlerStatus.setVnfType("vnft1"); + rainyDayHandlerStatus.setPolicy("RollbackToAssigned"); + rainyDayHandlerStatus.setWorkStep(ASTERISK); + rainyDayHandlerStatus.setSecondaryPolicy("Abort"); + + doReturn(rainyDayHandlerStatus).when(MOCK_catalogDbClient).getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep("AssignServiceInstanceBB", "st1", "vnft1", "7000", "*"); + + executeBuildingBlockRainyDay.queryRainyDayTable(delegateExecution,true); + + assertEquals("RollbackToAssigned", delegateExecution.getVariable("handlingCode")); + } + } diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest1Vpn.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest1Vpn.json deleted file mode 100644 index f05449a96f..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest1Vpn.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "requestInfo" : {"sourceId":"mso","requestType":"create","requestId":"testRequestId","callbackUrl":"http://localhost:28080/mso/WorkflowMesssage/SNIROResponse/testRequestId","transactionId":"testRequestId","timeout":1800}, - "serviceInfo" : {"modelInfo":{"modelName":"testModelName1","modelVersionId":"testModelUUID1","modelVersion":"testModelVersion1","modelInvariantId":"testModelInvariantUUID1"},"serviceInstanceId":"testServiceInstanceId1","serviceName":"testServiceType1"}, - "placementInfo" : {"subscriberInfo":{"subscriberName":"testCustomerName","globalSubscriberId":"testCustomerId"},"placementDemands":[{"resourceModelInfo":{"modelName":"testProxyModelName1","modelVersionId":"testProxyModelUuid1","modelVersion":"testProxyModelVersion1","modelInvariantId":"testProxyModelInvariantUuid1"},"resourceModuleName":"testProxyModelInstanceName1","serviceResourceId":"testProxyId1"},{"resourceModelInfo":{"modelName":"testProxyModelName2","modelVersionId":"testProxyModelUuid2","modelVersion":"testProxyModelVersion2","modelInvariantId":"testProxyModelInvariantUuid2"},"requiredCandidates":[{"candidateType":{"name":"vnfId"},"candidates":["testVnfId"]}],"resourceModuleName":"testProxyModelInstanceName2","serviceResourceId":"testProxyId2"}],"requestParameters":{"aLaCarte":false,"subscriptionServiceType":"iptollfree"}}, - "licenseInfo" : {"licenseDemands":[]} -}
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest3AR.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest3AR.json deleted file mode 100644 index 6977224ffa..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest3AR.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "requestInfo" : {"sourceId":"mso","requestType":"create","requestId":"testRequestId","callbackUrl":"http://localhost:28080/mso/WorkflowMesssage/SNIROResponse/testRequestId","transactionId":"testRequestId","timeout":1800}, - "serviceInfo" : {"modelInfo":{"modelName":"testModelName1","modelVersionId":"testModelUUID1","modelVersion":"testModelVersion1","modelInvariantId":"testModelInvariantUUID1"},"serviceInstanceId":"testServiceInstanceId1","serviceName":"testServiceType1"}, - "placementInfo" : {"subscriberInfo":{"subscriberName":"testCustomerName","globalSubscriberId":"testCustomerId"},"placementDemands":[{"resourceModelInfo":{"modelName":"testAllottedModelName1","modelVersionId":"testAllottedModelUuid1","modelVersion":"testAllottedModelVersion1","modelInvariantId":"testAllottedModelInvariantUuid1"},"resourceModuleName":"testAllottedModelInstanceName1","serviceResourceId":"testAllottedResourceId1"},{"resourceModelInfo":{"modelName":"testAllottedModelName2","modelVersionId":"testAllottedModelUuid2","modelVersion":"testAllottedModelVersion2","modelInvariantId":"testAllottedModelInvariantUuid2"},"resourceModuleName":"testAllottedModelInstanceName2","serviceResourceId":"testAllottedResourceId2"},{"resourceModelInfo":{"modelName":"testAllottedModelName3","modelVersionId":"testAllottedModelUuid3","modelVersion":"testAllottedModelVersion3","modelInvariantId":"testAllottedModelInvariantUuid3"},"resourceModuleName":"testAllottedModelInstanceName3","serviceResourceId":"testAllottedResourceId3"}],"requestParameters":{"aLaCarte":false,"subscriptionServiceType":"iptollfree"}}, - "licenseInfo" : {"licenseDemands":[]} -}
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest3Vpn.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest3Vpn.json deleted file mode 100644 index 877c6e7e74..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest3Vpn.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "requestInfo" : {"sourceId":"mso","requestType":"create","requestId":"testRequestId","callbackUrl":"http://localhost:28080/mso/WorkflowMesssage/SNIROResponse/testRequestId","transactionId":"testRequestId","timeout":1800}, - "serviceInfo" : {"modelInfo":{"modelName":"testModelName1","modelVersionId":"testModelUUID1","modelVersion":"testModelVersion1","modelInvariantId":"testModelInvariantUUID1"},"serviceInstanceId":"testServiceInstanceId1","serviceName":"testServiceType1"}, - "placementInfo" : {"subscriberInfo":{"subscriberName":"testCustomerName","globalSubscriberId":"testCustomerId"},"placementDemands":[{"resourceModelInfo":{"modelName":"testProxyModelName1","modelVersionId":"testProxyModelUuid1","modelVersion":"testProxyModelVersion1","modelInvariantId":"testProxyModelInvariantUuid1"},"resourceModuleName":"testProxyModelInstanceName1","serviceResourceId":"testProxyId1"},{"resourceModelInfo":{"modelName":"testProxyModelName2","modelVersionId":"testProxyModelUuid2","modelVersion":"testProxyModelVersion2","modelInvariantId":"testProxyModelInvariantUuid2"},"requiredCandidates":[{"candidateType":{"name":"vnfId"},"candidates":["testVnfId"]}],"resourceModuleName":"testProxyModelInstanceName2","serviceResourceId":"testProxyId2"},{"resourceModelInfo":{"modelName":"testProxyModelName1","modelVersionId":"testProxyModelUuid1","modelVersion":"testProxyModelVersion1","modelInvariantId":"testProxyModelInvariantUuid1"},"resourceModuleName":"testProxyModelInstanceName1","serviceResourceId":"testProxyId1"},{"resourceModelInfo":{"modelName":"testProxyModelName2","modelVersionId":"testProxyModelUuid2","modelVersion":"testProxyModelVersion2","modelInvariantId":"testProxyModelInvariantUuid2"},"requiredCandidates":[{"candidateType":{"name":"vnfId"},"candidates":["testVnfId"]}],"resourceModuleName":"testProxyModelInstanceName2","serviceResourceId":"testProxyId2"},{"resourceModelInfo":{"modelName":"testProxyModelName1","modelVersionId":"testProxyModelUuid1","modelVersion":"testProxyModelVersion1","modelInvariantId":"testProxyModelInvariantUuid1"},"resourceModuleName":"testProxyModelInstanceName1","serviceResourceId":"testProxyId1"},{"resourceModelInfo":{"modelName":"testProxyModelName2","modelVersionId":"testProxyModelUuid2","modelVersion":"testProxyModelVersion2","modelInvariantId":"testProxyModelInvariantUuid2"},"requiredCandidates":[{"candidateType":{"name":"vnfId"},"candidates":["testVnfId"]}],"resourceModuleName":"testProxyModelInstanceName2","serviceResourceId":"testProxyId2"}],"requestParameters":{"aLaCarte":false,"subscriptionServiceType":"iptollfree"}}, - "licenseInfo" : {"licenseDemands":[]} -}
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/application-test.yaml b/bpmn/MSOCommonBPMN/src/test/resources/application-test.yaml index 2985505b46..1651f4f1fc 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/application-test.yaml +++ b/bpmn/MSOCommonBPMN/src/test/resources/application-test.yaml @@ -108,6 +108,8 @@ mso: db: endpoint: http://localhost:${wiremock.server.port}/ rollback: 'true' + rainyDay: + retryDurationMultiplier: '2' site-name: localDevEnv workflow: default: |