diff options
Diffstat (limited to 'bpmn/so-bpmn-infrastructure-common')
2 files changed, 18 insertions, 55 deletions
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRG.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRG.groovy index 3c08779513..1be4989490 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRG.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRG.groovy @@ -240,11 +240,9 @@ public class DoCreateAllottedResourceBRG extends AbstractServiceTaskProcessor{ if(obj.has("result-data")){ JSONObject ob = obj.getJSONArray("result-data").getJSONObject(0) String resourceLink = ob.getString("resource-link") + AAIResourceUri siUri = AAIUriFactory.createResourceFromExistingURI(AAIObjectType.SERVICE_INSTANCE, new URI(resourceLink)) - String[] split = resourceLink.split("/aai/") - String siRelatedLink = "/aai/" + split[1] - - execution.setVariable("PSI_resourceLink", resourceLink) + execution.setVariable("PSI_resourceLink", siUri) }else{ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service instance was not found in aai") } @@ -277,26 +275,9 @@ public class DoCreateAllottedResourceBRG extends AbstractServiceTaskProcessor{ //AAI PUT AaiUtil aaiUriUtil = new AaiUtil(this) - String aaiEndpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) - String siResourceLink= execution.getVariable("PSI_resourceLink") - - String siUri = "" - msoLogger.debug("PSI_resourceLink:" + siResourceLink) - - if(!isBlank(siResourceLink)) { - msoLogger.debug("Incoming PSI Resource Link is: " + siResourceLink) - String[] split = siResourceLink.split("/aai/") - siUri = "/aai/" + split[1] - } - else - { - msg = "Parent Service Link in AAI is null" - msoLogger.debug(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } - - arUrl = "${aaiEndpoint}${siUri}" + "/allotted-resources/allotted-resource/" + UriUtils.encode(allottedResourceId,"UTF-8") - execution.setVariable("aaiARPath", arUrl) + AAIResourceUri siResourceLink= execution.getVariable("PSI_resourceLink") + AllottedResourceUtils arUtils = new AllottedResourceUtils(this) + execution.setVariable("aaiARPath", arUtils.createARUrl(execution, siResourceLink, allottedResourceId)) msoLogger.debug("GET AllottedResource AAI URL is:\n" + arUrl) String namespace = aaiUriUtil.getNamespaceFromUri(execution, arUrl) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXC.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXC.groovy index 5f9b4b8ecd..48eb1c85f9 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXC.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXC.groovy @@ -20,23 +20,22 @@ package org.onap.so.bpmn.vcpe.scripts; +import static org.apache.commons.lang3.StringUtils.* + +import org.apache.commons.lang3.* +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.so.bpmn.common.scripts.*; -import org.onap.so.bpmn.common.scripts.AaiUtil import org.onap.so.bpmn.core.RollbackData -import org.onap.so.bpmn.core.WorkflowException import org.onap.so.bpmn.core.UrnPropertiesReader +import org.onap.so.bpmn.core.WorkflowException import org.onap.so.bpmn.core.json.JsonUtils -import org.onap.so.rest.APIResponse - -import java.util.UUID; -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.delegate.DelegateExecution -import org.apache.commons.lang3.* -import org.springframework.web.util.UriUtils; -import static org.apache.commons.lang3.StringUtils.* - +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.logger.MessageEnum import org.onap.so.logger.MsoLogger +import org.onap.so.rest.APIResponse /** * This groovy class supports the <class>DoCreateAllottedResourceTXC.bpmn</class> process. @@ -204,26 +203,9 @@ public class DoCreateAllottedResourceTXC extends AbstractServiceTaskProcessor{ //AAI PUT AaiUtil aaiUriUtil = new AaiUtil(this) - String aaiEndpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) - String siResourceLink= execution.getVariable("PSI_resourceLink") - - String siUri = "" - msoLogger.debug("PSI_resourceLink:" + siResourceLink) - - if(!isBlank(siResourceLink)) { - msoLogger.debug("Incoming PSI Resource Link is: " + siResourceLink) - String[] split = siResourceLink.split("/aai/") - siUri = "/aai/" + split[1] - } - else - { - msg = "Parent Service Link in AAI is null" - msoLogger.debug(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } - - arUrl = "${aaiEndpoint}${siUri}" + "/allotted-resources/allotted-resource/" + UriUtils.encode(allottedResourceId,"UTF-8") - execution.setVariable("aaiARPath", arUrl) + AAIResourceUri siResourceLink= execution.getVariable("PSI_resourceLink") + AllottedResourceUtils arUtils = new AllottedResourceUtils(this) + execution.setVariable("aaiARPath", arUtils.createARUrl(execution, siResourceLink, allottedResourceId)) msoLogger.debug("GET AllottedResource AAI URL is:\n" + arUrl) String namespace = aaiUriUtil.getNamespaceFromUri(execution, arUrl) |