diff options
29 files changed, 371 insertions, 289 deletions
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/GlanceClientImpl.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/GlanceClientImpl.java index 687afeda40..9d6bf65dce 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/GlanceClientImpl.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/GlanceClientImpl.java @@ -30,6 +30,7 @@ import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; import com.woorea.openstack.base.client.OpenStackRequest; import com.woorea.openstack.glance.Glance; +import com.woorea.openstack.glance.model.Image; import com.woorea.openstack.glance.model.Images; @Component @@ -93,4 +94,17 @@ public class GlanceClientImpl extends MsoCommonUtils { } } + public Image queryImage(String cloudSiteId, String tenantId, String imageId) + throws MsoCloudSiteNotFound, GlanceClientException { + try { + Glance glanceClient = getGlanceClient(cloudSiteId, tenantId); + // list is set to false, otherwise an invalid URL is appended + OpenStackRequest<Image> request = glanceClient.images().show(imageId); + return executeAndRecordOpenstackRequest(request, false); + } catch (MsoException e) { + logger.error("Error building Glance Client", e); + throw new GlanceClientException("Error building Glance Client", e); + } + } + } diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupTenant.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupTenant.groovy index 83be39c264..f5cf541076 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupTenant.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupTenant.groovy @@ -22,7 +22,6 @@ package org.onap.so.bpmn.common.scripts -import org.onap.so.logger.LoggingAnchor import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.aai.domain.yang.VolumeGroup @@ -31,8 +30,10 @@ import org.onap.aaiclient.client.aai.entities.AAIResultWrapper import org.onap.aaiclient.client.aai.entities.Relationships import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory -import org.onap.so.constants.Defaults +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder import org.onap.logging.filter.base.ErrorCode +import org.onap.so.constants.Defaults +import org.onap.so.logger.LoggingAnchor import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory @@ -71,7 +72,7 @@ class ConfirmVolumeGroupTenant extends AbstractServiceTaskProcessor{ if(relationships.isPresent()){ List<AAIResourceUri> tenantUris = relationships.get().getRelatedAAIUris(AAIObjectType.TENANT) for (AAIResourceUri tenantURI: tenantUris){ - volumeGroupTenantId = tenantURI.getURIKeys().get("tenant-id") + volumeGroupTenantId = tenantURI.getURIKeys().get(AAIFluentTypeBuilder.Types.TENANT.getUriParams().tenantId) } } //Determine if Tenant Ids match diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java index 0fd38badad..bfa77212c4 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java @@ -34,14 +34,36 @@ import java.util.UUID; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.camunda.bpm.engine.delegate.JavaDelegate; import org.javatuples.Pair; +import org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider; +import org.onap.aaiclient.client.aai.AAIObjectType; +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper; +import org.onap.aaiclient.client.aai.entities.Relationships; +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri; +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory; +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.common.DelegateExecutionImpl; -import org.onap.so.bpmn.servicedecomposition.bbobjects.*; +import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.Collection; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; +import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; +import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup; +import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; import org.onap.so.bpmn.servicedecomposition.bbobjects.LineOfBusiness; +import org.onap.so.bpmn.servicedecomposition.bbobjects.NetworkPolicy; import org.onap.so.bpmn.servicedecomposition.bbobjects.OwningEntity; import org.onap.so.bpmn.servicedecomposition.bbobjects.Platform; import org.onap.so.bpmn.servicedecomposition.bbobjects.Project; +import org.onap.so.bpmn.servicedecomposition.bbobjects.RouteTableReference; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceProxy; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Tenant; +import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Vnfc; +import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup; +import org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBinding; import org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys; import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock; @@ -52,12 +74,6 @@ import org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; import org.onap.so.bpmn.servicedecomposition.tasks.exceptions.NoServiceInstanceFoundException; import org.onap.so.bpmn.servicedecomposition.tasks.exceptions.ServiceModelNotFoundException; -import org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider; -import org.onap.aaiclient.client.aai.AAIObjectType; -import org.onap.aaiclient.client.aai.entities.AAIResultWrapper; -import org.onap.aaiclient.client.aai.entities.Relationships; -import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri; -import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory; import org.onap.so.client.exception.ExceptionBuilder; import org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization; import org.onap.so.db.catalog.beans.CollectionResource; @@ -1044,7 +1060,8 @@ public class BBInputSetup implements JavaDelegate { protected ServiceSubscription getServiceSubscriptionFromURI(String resourceId, Customer customer) { Map<String, String> uriKeys = bbInputSetupUtils.getURIKeysFromServiceInstance(resourceId); - String subscriptionServiceType = uriKeys.get("service-type"); + String subscriptionServiceType = + uriKeys.get(AAIFluentTypeBuilder.Types.SERVICE_SUBSCRIPTION.getUriParams().serviceType); org.onap.aai.domain.yang.ServiceSubscription serviceSubscriptionAAI = bbInputSetupUtils.getAAIServiceSubscription(customer.getGlobalCustomerId(), subscriptionServiceType); if (serviceSubscriptionAAI != null) { @@ -1056,7 +1073,7 @@ public class BBInputSetup implements JavaDelegate { protected Customer getCustomerFromURI(String resourceId) { Map<String, String> uriKeys = bbInputSetupUtils.getURIKeysFromServiceInstance(resourceId); - String globalCustomerId = uriKeys.get("global-customer-id"); + String globalCustomerId = uriKeys.get(AAIFluentTypeBuilder.Types.CUSTOMER.getUriParams().globalCustomerId); org.onap.aai.domain.yang.Customer customerAAI = this.bbInputSetupUtils.getAAICustomer(globalCustomerId); if (customerAAI != null) { return mapperLayer.mapAAICustomer(customerAAI); @@ -1085,8 +1102,9 @@ public class BBInputSetup implements JavaDelegate { if (customer == null) { Map<String, String> uriKeys = bbInputSetupUtils .getURIKeysFromServiceInstance(parameter.getServiceInstance().getServiceInstanceId()); - String globalCustomerId = uriKeys.get("global-customer-id"); - String subscriptionServiceType = uriKeys.get("service-type"); + String globalCustomerId = uriKeys.get(AAIFluentTypeBuilder.Types.CUSTOMER.getUriParams().globalCustomerId); + String subscriptionServiceType = + uriKeys.get(AAIFluentTypeBuilder.Types.SERVICE_SUBSCRIPTION.getUriParams().serviceType); customer = mapCustomer(globalCustomerId, subscriptionServiceType); } outputBB.setServiceInstance(parameter.getServiceInstance()); diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java index b327847c11..458919c48e 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java @@ -58,6 +58,12 @@ import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.Spy; import org.mockito.junit.MockitoJUnitRunner; +import org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider; +import org.onap.aaiclient.client.aai.AAIObjectType; +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper; +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri; +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory; +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.Collection; import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; @@ -94,11 +100,6 @@ import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceProxy; import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule; import org.onap.so.bpmn.servicedecomposition.tasks.exceptions.NoServiceInstanceFoundException; import org.onap.so.bpmn.servicedecomposition.tasks.exceptions.ServiceModelNotFoundException; -import org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider; -import org.onap.aaiclient.client.aai.AAIObjectType; -import org.onap.aaiclient.client.aai.entities.AAIResultWrapper; -import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri; -import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory; import org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization; import org.onap.so.db.catalog.beans.CollectionResource; import org.onap.so.db.catalog.beans.CollectionResourceCustomization; @@ -944,8 +945,8 @@ public class BBInputSetupTest { cloudRegion.setTenantId("tenantId"); Map<String, String> uriKeys = new HashMap<>(); - uriKeys.put("global-customer-id", "global-customer-id"); - uriKeys.put("service-type", "service-type"); + uriKeys.put(AAIFluentTypeBuilder.Types.CUSTOMER.getUriParams().globalCustomerId, "global-customer-id"); + uriKeys.put(AAIFluentTypeBuilder.Types.SERVICE_SUBSCRIPTION.getUriParams().serviceType, "service-type"); Customer customer = new Customer(); ServiceSubscription serviceSubscription = new ServiceSubscription(); diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1.groovy index bc118791a3..005f0f3c6b 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1.groovy @@ -22,10 +22,16 @@ package org.onap.so.bpmn.infrastructure.scripts -import org.onap.so.logger.LoggingAnchor +import javax.ws.rs.NotFoundException import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.aai.domain.yang.VolumeGroup +import org.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder +import org.onap.logging.filter.base.ErrorCode import org.onap.so.bpmn.common.scripts.AaiUtil; import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor; import org.onap.so.bpmn.common.scripts.ExceptionUtil; @@ -33,19 +39,13 @@ import org.onap.so.bpmn.common.scripts.MsoUtils import org.onap.so.bpmn.common.scripts.VidUtils; import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.bpmn.core.WorkflowException -import org.onap.aaiclient.client.aai.AAIObjectType -import org.onap.aaiclient.client.aai.entities.AAIResultWrapper -import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri -import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory import org.onap.so.constants.Defaults -import org.onap.logging.filter.base.ErrorCode +import org.onap.so.logger.LoggingAnchor import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory import groovy.json.JsonSlurper -import javax.ws.rs.NotFoundException - /** * This groovy class supports the <class>DeleteVfModuleVolume.bpmn</class> process. */ @@ -285,7 +285,7 @@ public class DeleteVfModuleVolumeInfraV1 extends AbstractServiceTaskProcessor { if(wrapper.getRelationships().isPresent()) { List<AAIResourceUri> tenantURIList = wrapper.getRelationships().get().getRelatedAAIUris(AAIObjectType.TENANT) if(!tenantURIList.isEmpty()){ - return tenantURIList.get(0).getURIKeys().get("tenant-id") + return tenantURIList.get(0).getURIKeys().get(AAIFluentTypeBuilder.Types.TENANT.getUriParams().tenantId) } } return null diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstance.groovy index 00242b27f6..22e5819068 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstance.groovy @@ -22,12 +22,27 @@ package org.onap.so.bpmn.infrastructure.scripts; -import javax.ws.rs.core.UriBuilder -import javax.xml.parsers.DocumentBuilder -import javax.xml.parsers.DocumentBuilderFactory +import javax.ws.rs.NotFoundException import org.apache.commons.lang3.* import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.aai.domain.yang.L3Network +import org.onap.aai.domain.yang.L3Networks +import org.onap.aai.domain.yang.NetworkPolicy +import org.onap.aai.domain.yang.RouteTableReference +import org.onap.aai.domain.yang.RouteTarget +import org.onap.aai.domain.yang.Subnet +import org.onap.aai.domain.yang.VpnBinding +import org.onap.aaiclient.client.aai.AAIObjectPlurals +import org.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.AAIResourcesClient +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper +import org.onap.aaiclient.client.aai.entities.Relationships +import org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder +import org.onap.aaiclient.client.graphinventory.entities.uri.Depth import org.onap.so.bpmn.common.scripts.AaiUtil import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil @@ -38,38 +53,10 @@ import org.onap.so.bpmn.common.scripts.VidUtils 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.aaiclient.client.aai.AAIObjectPlurals -import org.onap.aaiclient.client.aai.AAIObjectType -import org.onap.aaiclient.client.aai.AAIResourcesClient -import org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri -import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri -import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory -import org.onap.aaiclient.client.aai.entities.AAIResultWrapper -import org.onap.aaiclient.client.aai.entities.Relationships -import org.onap.aaiclient.client.graphinventory.entities.uri.Depth import org.onap.so.constants.Defaults import org.slf4j.Logger import org.slf4j.LoggerFactory -import org.springframework.web.util.UriUtils -import org.w3c.dom.Document -import org.w3c.dom.Element -import org.w3c.dom.NamedNodeMap -import org.w3c.dom.Node -import org.w3c.dom.NodeList; -import org.xml.sax.InputSource -import org.onap.aai.domain.yang.VpnBinding -import org.onap.aai.domain.yang.L3Network -import org.onap.aai.domain.yang.L3Networks -import org.onap.aai.domain.yang.NetworkPolicy -import org.onap.aai.domain.yang.RouteTableReference -import org.onap.aai.domain.yang.RouteTarget -import org.onap.aai.domain.yang.Subnet -import com.fasterxml.jackson.jaxrs.util.EndpointAsBeanProperty - -import javax.ws.rs.NotFoundException - import groovy.json.* -import groovy.xml.XmlUtil /** * This groovy class supports the <class>DoCreateNetworkInstance.bpmn</class> process. @@ -354,8 +341,8 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service instance was not found in aai") }else{ Map<String, String> keys = uri.getURIKeys() - execution.setVariable("serviceType", keys.get("service-type")) - execution.setVariable("subscriberName", keys.get("global-customer-id")) + execution.setVariable("serviceType", keys.get(AAIFluentTypeBuilder.Types.SERVICE_SUBSCRIPTION.getUriParams().serviceType)) + execution.setVariable("subscriberName", keys.get(AAIFluentTypeBuilder.Types.CUSTOMER.getUriParams().globalCustomerId)) } }catch(BpmnError e) { diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnf.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnf.groovy index 9a584224ff..488f2d85ac 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnf.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnf.groovy @@ -22,14 +22,15 @@ package org.onap.so.bpmn.infrastructure.scripts -import org.onap.so.logger.LoggingAnchor -import org.onap.so.db.catalog.beans.HomingInstance -import org.onap.logging.filter.base.ErrorCode - import static org.apache.commons.lang3.StringUtils.* - import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.aaiclient.client.aai.AAIObjectType; +import org.onap.aaiclient.client.aai.AAIResourcesClient +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder +import org.onap.logging.filter.base.ErrorCode import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.common.scripts.MsoUtils @@ -41,13 +42,11 @@ import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.bpmn.core.WorkflowException import org.onap.so.bpmn.core.domain.VnfResource import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.db.catalog.beans.HomingInstance +import org.onap.so.logger.LoggingAnchor import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory -import org.onap.aaiclient.client.aai.AAIObjectType; -import org.onap.aaiclient.client.aai.AAIResourcesClient -import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri -import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory /** * This class supports the DoCreateVnf building block subflow @@ -286,8 +285,8 @@ class DoCreateVnf extends AbstractServiceTaskProcessor { if(resourceClient.exists(uri)){ Map<String, String> keys = uri.getURIKeys() - execution.setVariable("globalCustomerId", keys.get("global-customer-id")) - execution.setVariable("serviceType", keys.get("service-type")) + execution.setVariable("globalCustomerId", keys.get(AAIFluentTypeBuilder.Types.CUSTOMER.getUriParams().globalCustomerId)) + execution.setVariable("serviceType", keys.get(AAIFluentTypeBuilder.Types.SERVICE_SUBSCRIPTION.getUriParams().serviceType)) execution.setVariable("GENGS_siResourceLink", uri.build().toString()) }else{ diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstance.groovy index 51be632f47..bee9ad260b 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstance.groovy @@ -22,10 +22,19 @@ package org.onap.so.bpmn.infrastructure.scripts -import org.onap.so.logger.LoggingAnchor +import javax.ws.rs.core.Response import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.aai.domain.yang.L3Network +import org.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper +import org.onap.aaiclient.client.aai.entities.Relationships +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder +import org.onap.aaiclient.client.graphinventory.entities.uri.Depth +import org.onap.logging.filter.base.ErrorCode +import org.onap.logging.filter.base.ONAPComponents; import org.onap.so.bpmn.common.scripts.AaiUtil import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil @@ -38,23 +47,13 @@ import org.onap.so.bpmn.core.WorkflowException import org.onap.so.bpmn.core.json.JsonUtils import org.onap.so.client.HttpClient import org.onap.so.client.HttpClientFactory -import org.onap.aaiclient.client.aai.AAIObjectType -import org.onap.aaiclient.client.aai.entities.AAIResultWrapper -import org.onap.aaiclient.client.aai.entities.Relationships -import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri -import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory -import org.onap.aaiclient.client.graphinventory.entities.uri.Depth import org.onap.so.constants.Defaults -import org.onap.logging.filter.base.ErrorCode +import org.onap.so.logger.LoggingAnchor import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory - import org.springframework.web.util.UriUtils -import org.onap.logging.filter.base.ONAPComponents; - import groovy.json.JsonOutput -import javax.ws.rs.core.Response public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { private static final Logger logger = LoggerFactory.getLogger( DoDeleteNetworkInstance.class); @@ -276,7 +275,7 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { List<AAIResourceUri> tenantURIList = relationships.get().getRelatedAAIUris(AAIObjectType.TENANT) for(AAIResourceUri tenantURI: tenantURIList){ if(execution.getVariable(Prefix + "tenantId") == null) { - String tenantId = tenantURI.getURIKeys().get("tenant-id") + String tenantId = tenantURI.getURIKeys().get(AAIFluentTypeBuilder.Types.TENANT.getUriParams().tenantId) execution.setVariable(Prefix + "tenantId", tenantId) logger.debug(" Get AAI getTenantId() : " + tenantId) } @@ -284,7 +283,7 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { List<AAIResourceUri> cloudRegionURIList = relationships.get().getRelatedAAIUris(AAIObjectType.CLOUD_REGION) for(AAIResourceUri tenantURI: cloudRegionURIList){ if(execution.getVariable(Prefix + "lcpCloudRegion") == null) { - String lcpCloudRegion = tenantURI.getURIKeys().get("cloud-region-id") + String lcpCloudRegion = tenantURI.getURIKeys().get(AAIFluentTypeBuilder.Types.CLOUD_REGION.getUriParams().cloudRegionId) execution.setVariable(Prefix + "lcpCloudRegion", lcpCloudRegion) logger.debug(" Get AAI getCloudRegion() : " + lcpCloudRegion) } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteServiceInstance.groovy index a55381b295..cda7c321ac 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteServiceInstance.groovy @@ -23,11 +23,15 @@ package org.onap.so.bpmn.infrastructure.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.aai.domain.yang.ServiceInstance +import org.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.AAIResourcesClient +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.common.scripts.MsoUtils @@ -35,17 +39,10 @@ import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils 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.aaiclient.client.aai.AAIObjectType -import org.onap.aaiclient.client.aai.AAIResourcesClient -import org.onap.aaiclient.client.aai.entities.AAIResultWrapper -import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri -import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory import org.slf4j.Logger import org.slf4j.LoggerFactory import org.springframework.web.util.UriUtils; -import groovy.json.* - /** * This groovy class supports the <class>DoDeleteServiceInstance.bpmn</class> process. * @@ -294,7 +291,7 @@ public class DoDeleteServiceInstance extends AbstractServiceTaskProcessor { execution.setVariable("GENGS_FoundIndicator", true) execution.setVariable("GENGS_siResourceLink", uri.build().toString()) Map<String, String> keys = uri.getURIKeys() - String globalSubscriberId = execution.getVariable("globalSubscriberId") + String globalSubscriberId = execution.getVariable(AAIFluentTypeBuilder.Types.CUSTOMER.getUriParams().globalCustomerId) if(isBlank(globalSubscriberId)){ globalSubscriberId = keys.get("global-customer-id") execution.setVariable("globalSubscriberId", globalSubscriberId) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleVolumeV2.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleVolumeV2.groovy index db90cd0d7b..355b5f77c0 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleVolumeV2.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleVolumeV2.groovy @@ -22,12 +22,16 @@ package org.onap.so.bpmn.infrastructure.scripts -import org.apache.commons.lang3.StringUtils +import javax.ws.rs.NotFoundException import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution -import org.onap.aai.domain.yang.Relationship -import org.onap.aai.domain.yang.RelationshipData import org.onap.aai.domain.yang.VolumeGroup +import org.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper +import org.onap.aaiclient.client.aai.entities.Relationships +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder import org.onap.so.bpmn.common.scripts.AaiUtil import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil @@ -35,15 +39,9 @@ import org.onap.so.bpmn.common.scripts.MsoUtils 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.aaiclient.client.aai.AAIObjectType -import org.onap.aaiclient.client.aai.entities.AAIResultWrapper -import org.onap.aaiclient.client.aai.entities.Relationships -import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri -import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory import org.onap.so.constants.Defaults import org.slf4j.Logger import org.slf4j.LoggerFactory -import javax.ws.rs.NotFoundException class DoDeleteVfModuleVolumeV2 extends AbstractServiceTaskProcessor{ private static final Logger logger = LoggerFactory.getLogger( DoDeleteVfModuleVolumeV2.class); @@ -180,7 +178,7 @@ class DoDeleteVfModuleVolumeV2 extends AbstractServiceTaskProcessor{ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Volume Group ${volumeGroupId} currently in use - found vf-module relationship.") } for(AAIResourceUri aaiResourceUri: relationships.get().getRelatedAAIUris(AAIObjectType.TENANT)){ - volumeGroupTenantId = aaiResourceUri.getURIKeys().get("tenant-id") + volumeGroupTenantId = aaiResourceUri.getURIKeys().get(AAIFluentTypeBuilder.Types.TENANT.getUriParams().tenantId) } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstance.groovy index 868ed214be..cf7bb22442 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstance.groovy @@ -22,12 +22,22 @@ package org.onap.so.bpmn.infrastructure.scripts; -import javax.ws.rs.core.UriBuilder -import javax.xml.parsers.DocumentBuilder -import javax.xml.parsers.DocumentBuilderFactory -import org.apache.commons.lang3.* +import javax.ws.rs.NotFoundException import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.aai.domain.yang.L3Network +import org.onap.aai.domain.yang.NetworkPolicy +import org.onap.aai.domain.yang.RouteTableReference +import org.onap.aai.domain.yang.RouteTarget +import org.onap.aai.domain.yang.Subnet +import org.onap.aai.domain.yang.VpnBinding +import org.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.AAIResourcesClient +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder +import org.onap.aaiclient.client.graphinventory.entities.uri.Depth import org.onap.so.bpmn.common.scripts.AaiUtil import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil @@ -38,33 +48,10 @@ import org.onap.so.bpmn.common.scripts.VidUtils 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.aaiclient.client.aai.AAIObjectType -import org.onap.aaiclient.client.aai.AAIResourcesClient -import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri -import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory -import org.onap.aaiclient.client.aai.entities.AAIResultWrapper -import org.onap.aaiclient.client.graphinventory.entities.uri.Depth import org.onap.so.constants.Defaults import org.slf4j.Logger import org.slf4j.LoggerFactory - -import org.springframework.web.util.UriUtils -import org.w3c.dom.Document -import org.w3c.dom.Element -import org.w3c.dom.NamedNodeMap -import org.w3c.dom.Node -import org.w3c.dom.NodeList; -import org.xml.sax.InputSource -import org.onap.aai.domain.yang.VpnBinding -import org.onap.aai.domain.yang.L3Network -import org.onap.aai.domain.yang.NetworkPolicy -import org.onap.aai.domain.yang.RouteTableReference -import org.onap.aai.domain.yang.RouteTarget -import org.onap.aai.domain.yang.Subnet -import javax.ws.rs.NotFoundException - import groovy.json.* -import groovy.xml.XmlUtil /** * This groovy class supports the <class>DoUpdateNetworkInstance.bpmn</class> process. @@ -347,8 +334,8 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Service Instance not found in aai") }else{ Map<String, String> keys = uri.getURIKeys() - execution.setVariable("serviceType", keys.get("service-type")) - execution.setVariable("subscriberName", keys.get("global-customer-id")) + execution.setVariable("serviceType", keys.get(AAIFluentTypeBuilder.Types.SERVICE_SUBSCRIPTION.getUriParams().serviceType)) + execution.setVariable("subscriberName", keys.get(AAIFluentTypeBuilder.Types.CUSTOMER.getUriParams().globalCustomerId)) } }catch(BpmnError e) { diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolume.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolume.groovy index 3928747e17..148ab1898f 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolume.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolume.groovy @@ -22,28 +22,28 @@ package org.onap.so.bpmn.infrastructure.scripts +import static org.apache.commons.lang.StringUtils.isEmpty import org.apache.commons.collections.CollectionUtils import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.aai.domain.yang.VolumeGroup -import org.onap.so.bpmn.common.scripts.ExceptionUtil -import org.onap.so.bpmn.common.scripts.MsoUtils -import org.onap.so.bpmn.common.scripts.VfModuleBase -import org.onap.so.bpmn.core.UrnPropertiesReader -import org.onap.so.bpmn.core.WorkflowException import org.onap.aaiclient.client.aai.AAIObjectType import org.onap.aaiclient.client.aai.entities.AAIResultWrapper import org.onap.aaiclient.client.aai.entities.Relationships import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory -import org.onap.so.constants.Defaults +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder import org.onap.logging.filter.base.ErrorCode +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.MsoUtils +import org.onap.so.bpmn.common.scripts.VfModuleBase +import org.onap.so.bpmn.core.UrnPropertiesReader +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.constants.Defaults import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory -import static org.apache.commons.lang.StringUtils.isEmpty - class UpdateVfModuleVolume extends VfModuleBase { private static final Logger logger = LoggerFactory.getLogger(UpdateVfModuleVolume.class) @@ -196,7 +196,7 @@ class UpdateVfModuleVolume extends VfModuleBase { List<AAIResourceUri> resourceUriList = relationships.get().getRelatedAAIUris(AAIObjectType.TENANT) if(CollectionUtils.isNotEmpty(resourceUriList)){ AAIResourceUri tenantUri = resourceUriList.get(0) - String volumeGroupTenantId = tenantUri.getURIKeys().get("tenant-id") + String volumeGroupTenantId = tenantUri.getURIKeys().get(AAIFluentTypeBuilder.Types.TENANT.getUriParams().tenantId) if( isEmpty(volumeGroupTenantId)){ exceptionUtil.buildAndThrowWorkflowException(execution,2500,"Could not find Tenant Id element in Volume Group with Volume Group Id" + volumeGroupId + ", AIC Cloud Region" + aicCloudRegion) } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1.groovy index a89ea5925b..b6873a19fe 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1.groovy @@ -22,34 +22,33 @@ package org.onap.so.bpmn.infrastructure.scripts -import org.onap.so.logger.LoggingAnchor -import groovy.json.JsonException -import groovy.json.JsonSlurper +import static org.apache.cxf.common.util.CollectionUtils.isEmpty +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.aai.domain.yang.VfModule import org.onap.aai.domain.yang.VolumeGroup +import org.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper +import org.onap.aaiclient.client.aai.entities.Relationships +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder +import org.onap.logging.filter.base.ErrorCode import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.common.scripts.MsoUtils import org.onap.so.bpmn.common.scripts.VfModuleBase import org.onap.so.bpmn.common.scripts.VidUtils import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.bpmn.core.WorkflowException -import org.onap.aaiclient.client.aai.AAIObjectType -import org.onap.aaiclient.client.aai.entities.AAIResultWrapper -import org.onap.aaiclient.client.aai.entities.Relationships -import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri -import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory import org.onap.so.constants.Defaults -import org.onap.logging.filter.base.ErrorCode +import org.onap.so.logger.LoggingAnchor import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory - -import javax.ws.rs.core.UriBuilder - -import static org.apache.cxf.common.util.CollectionUtils.isEmpty +import groovy.json.JsonException +import groovy.json.JsonSlurper class UpdateVfModuleVolumeInfraV1 extends VfModuleBase { private static final Logger logger = LoggerFactory.getLogger(UpdateVfModuleVolumeInfraV1.class) @@ -217,7 +216,7 @@ class UpdateVfModuleVolumeInfraV1 extends VfModuleBase { if (relationships.isPresent()) { List<AAIResourceUri> tenantURIList = relationships.get().getRelatedAAIUris(AAIObjectType.TENANT) if (!isEmpty(tenantURIList)) { - String volumeGroupTenantId = tenantURIList.get(0).getURIKeys().get("tenant-id") + String volumeGroupTenantId = tenantURIList.get(0).getURIKeys().get(AAIFluentTypeBuilder.Types.TENANT.getUriParams().tenantId) execution.setVariable('UPDVfModVol_volumeGroupTenantId', volumeGroupTenantId) logger.debug("Received Tenant Id {} from AAI for Volume Group with Volume Group Id {}, AIC Cloud Region ", volumeGroupTenantId, volumeGroupId, aicCloudRegion) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfCmBase.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfCmBase.groovy index c2da495bff..aa3512379a 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfCmBase.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfCmBase.groovy @@ -26,6 +26,12 @@ import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.json.JSONArray import org.json.JSONObject +import org.onap.aaiclient.client.aai.* +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper +import org.onap.aaiclient.client.aai.entities.Relationships +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder import org.onap.appc.client.lcm.model.Action import org.onap.appc.client.lcm.model.ActionIdentifiers import org.onap.appc.client.lcm.model.Flags @@ -39,11 +45,6 @@ import org.onap.so.bpmn.core.domain.ModelInfo import org.onap.so.bpmn.core.domain.ServiceDecomposition import org.onap.so.bpmn.core.domain.VnfResource import org.onap.so.bpmn.core.json.JsonUtils -import org.onap.aaiclient.client.aai.* -import org.onap.aaiclient.client.aai.entities.AAIResultWrapper -import org.onap.aaiclient.client.aai.entities.Relationships -import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri -import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory import org.onap.so.client.appc.ApplicationControllerClient import org.onap.so.client.appc.ApplicationControllerSupport import org.onap.so.logger.MessageEnum @@ -248,7 +249,7 @@ public abstract class VnfCmBase extends AbstractServiceTaskProcessor { for (AAIResourceUri j in vserverUris) { - String vserverId = j.getURIKeys().get('vserver-id') + String vserverId = j.getURIKeys().get(AAIFluentTypeBuilder.Types.VSERVER.getUriParams().vserverId) String vserverJson = client.get(j).getJson() logger.debug("Retrieved vserverJson from AAI: {}", vserverJson) String vserverSelfLink = jsonUtils.getJsonValue(vserverJson, "vserver-selflink") diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DeleteVcpeResCustService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DeleteVcpeResCustService.groovy index 8b67790ffc..dd1dae6edd 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DeleteVcpeResCustService.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DeleteVcpeResCustService.groovy @@ -21,9 +21,17 @@ */ package org.onap.so.bpmn.vcpe.scripts -import org.onap.so.logger.LoggingAnchor +import javax.ws.rs.NotFoundException import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.AAIResourcesClient +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper +import org.onap.aaiclient.client.aai.entities.Relationships +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder +import org.onap.logging.filter.base.ErrorCode import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.common.scripts.MsoUtils @@ -31,19 +39,11 @@ import org.onap.so.bpmn.common.scripts.NetworkUtils import org.onap.so.bpmn.common.scripts.VidUtils import org.onap.so.bpmn.core.WorkflowException import org.onap.so.bpmn.core.json.JsonUtils -import org.onap.logging.filter.base.ErrorCode +import org.onap.so.logger.LoggingAnchor import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory -import org.onap.aaiclient.client.aai.AAIResourcesClient -import org.onap.aaiclient.client.aai.AAIObjectType -import org.onap.aaiclient.client.aai.entities.AAIResultWrapper -import org.onap.aaiclient.client.aai.entities.Relationships -import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri -import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory -import javax.ws.rs.NotFoundException - /** * This groovy class supports the <class>DeleteVcpeResCustService.bpmn</class> process. * @@ -220,7 +220,7 @@ public class DeleteVcpeResCustService extends AbstractServiceTaskProcessor { List<AAIResourceUri> vnfUris = relationships.get().getRelatedAAIUris(AAIObjectType.GENERIC_VNF) for(AAIResourceUri u:vnfUris){ Map<String, String> keys = u.getURIKeys() - String vnfId = keys.get("vnf-id") + String vnfId = keys.get(AAIFluentTypeBuilder.Types.GENERIC_VNF.getUriParams().vnfId) relatedVnfIdList.add(vnfId) } List<AAIResourceUri> arUris = relationships.get().getRelatedAAIUris(AAIObjectType.ALLOTTED_RESOURCE) diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcOrchestratorPreProcessor.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcOrchestratorPreProcessor.java index 2668357f63..b337564dab 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcOrchestratorPreProcessor.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcOrchestratorPreProcessor.java @@ -6,6 +6,11 @@ import java.util.List; import java.util.Map; import java.util.Optional; import org.onap.aai.domain.yang.Vserver; +import org.onap.aaiclient.client.aai.AAIObjectType; +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper; +import org.onap.aaiclient.client.aai.entities.Relationships; +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri; +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder; import org.onap.appc.client.lcm.model.Action; import org.onap.so.appc.orchestrator.service.beans.ApplicationControllerTaskRequest; import org.onap.so.appc.orchestrator.service.beans.ApplicationControllerVm; @@ -17,10 +22,6 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock; import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB; -import org.onap.aaiclient.client.aai.AAIObjectType; -import org.onap.aaiclient.client.aai.entities.AAIResultWrapper; -import org.onap.aaiclient.client.aai.entities.Relationships; -import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri; import org.onap.so.client.exception.BBObjectNotFoundException; import org.onap.so.client.exception.ExceptionBuilder; import org.onap.so.client.orchestration.AAIVnfResources; @@ -186,7 +187,7 @@ public class AppcOrchestratorPreProcessor { ArrayList<String> vserverIds = new ArrayList<String>(); ArrayList<String> vserverSelfLinks = new ArrayList<String>(); for (AAIResourceUri j : vserverUris) { - String vserverId = j.getURIKeys().get("vserver-id"); + String vserverId = j.getURIKeys().get(AAIFluentTypeBuilder.Types.VSERVER.getUriParams().vserverId); vserverIds.add(vserverId); Optional<Vserver> oVserver = aaiVnfResources.getVserver(j); if (oVserver.isPresent()) { diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasks.java index 52edacc29d..70edc375c4 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasks.java @@ -28,10 +28,15 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Optional; -import org.onap.so.logger.LoggingAnchor; import org.json.JSONArray; import org.json.JSONObject; +import org.onap.aaiclient.client.aai.AAIObjectType; +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper; +import org.onap.aaiclient.client.aai.entities.Relationships; +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri; +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder; import org.onap.appc.client.lcm.model.Action; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.core.json.JsonUtils; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; @@ -40,17 +45,13 @@ import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock; import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestParameters; import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB; -import org.onap.aaiclient.client.aai.AAIObjectType; -import org.onap.aaiclient.client.aai.entities.AAIResultWrapper; -import org.onap.aaiclient.client.aai.entities.Relationships; -import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri; import org.onap.so.client.appc.ApplicationControllerAction; import org.onap.so.client.exception.BBObjectNotFoundException; import org.onap.so.client.exception.ExceptionBuilder; import org.onap.so.client.orchestration.AAIVnfResources; import org.onap.so.db.catalog.beans.ControllerSelectionReference; import org.onap.so.db.catalog.client.CatalogDbClient; -import org.onap.logging.filter.base.ErrorCode; +import org.onap.so.logger.LoggingAnchor; import org.onap.so.logger.MessageEnum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -257,7 +258,8 @@ public class AppcRunTasks { for (AAIResourceUri j : vserverUris) { if (j != null) { if (j.getURIKeys() != null) { - String vserverId = j.getURIKeys().get("vserver-id"); + String vserverId = + j.getURIKeys().get(AAIFluentTypeBuilder.Types.VSERVER.getUriParams().vserverId); vserverIds.put(vserverId); } aaiVnfResources.getVserver(j).ifPresent((vserver) -> { diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java index 677100cfc1..b4eb97a187 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java @@ -48,6 +48,13 @@ import org.onap.aai.domain.yang.ServiceInstances; import org.onap.aai.domain.yang.Vnfc; import org.onap.aai.domain.yang.VolumeGroup; import org.onap.aai.domain.yang.VpnBinding; +import org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider; +import org.onap.aaiclient.client.aai.AAIObjectType; +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper; +import org.onap.aaiclient.client.aai.entities.Relationships; +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri; +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory; +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder; import org.onap.so.bpmn.common.BBConstants; import org.onap.so.bpmn.infrastructure.workflow.tasks.utils.WorkflowResourceIdsUtils; import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; @@ -60,12 +67,6 @@ import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetup; import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetupUtils; import org.onap.so.bpmn.servicedecomposition.tasks.exceptions.DuplicateNameException; import org.onap.so.bpmn.servicedecomposition.tasks.exceptions.MultipleObjectsFoundException; -import org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider; -import org.onap.aaiclient.client.aai.AAIObjectType; -import org.onap.aaiclient.client.aai.entities.AAIResultWrapper; -import org.onap.aaiclient.client.aai.entities.Relationships; -import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri; -import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory; import org.onap.so.client.exception.ExceptionBuilder; import org.onap.so.client.orchestration.AAIConfigurationResources; import org.onap.so.client.orchestration.AAIEntityNotFoundException; @@ -94,9 +95,9 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; -import org.springframework.util.CollectionUtils; @Component public class WorkflowAction { @@ -1547,10 +1548,12 @@ public class WorkflowAction { Map<String, String> keys = bbInputSetupUtils.getURIKeysFromServiceInstance(si.getServiceInstanceId()); - throw new DuplicateNameException(SERVICE_INSTANCE, - String.format(NAME_EXISTS_WITH_DIFF_COMBINATION, instanceName, - keys.get("global-customer-id"), keys.get("service-type"), - si.getModelVersionId())); + throw new DuplicateNameException(SERVICE_INSTANCE, String.format( + NAME_EXISTS_WITH_DIFF_COMBINATION, instanceName, + keys.get(AAIFluentTypeBuilder.Types.CUSTOMER.getUriParams().globalCustomerId), + keys.get( + AAIFluentTypeBuilder.Types.SERVICE_SUBSCRIPTION.getUriParams().serviceType), + si.getModelVersionId())); } } } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java index c1107a4df8..e24eaf0581 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java @@ -34,14 +34,14 @@ import static org.junit.Assert.assertNull; import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyObject; import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.isA; +import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.doThrow; -import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.when; import com.fasterxml.jackson.databind.ObjectMapper; import java.io.IOException; @@ -77,6 +77,12 @@ import org.onap.aai.domain.yang.ServiceInstances; import org.onap.aai.domain.yang.VfModule; import org.onap.aai.domain.yang.VfModules; import org.onap.aai.domain.yang.VolumeGroup; +import org.onap.aaiclient.client.aai.AAIObjectType; +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper; +import org.onap.aaiclient.client.aai.entities.Relationships; +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri; +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory; +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder; import org.onap.so.bpmn.BaseTaskTest; import org.onap.so.bpmn.servicedecomposition.bbobjects.Collection; import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; @@ -84,11 +90,6 @@ import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock; import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; import org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds; import org.onap.so.bpmn.servicedecomposition.tasks.exceptions.DuplicateNameException; -import org.onap.aaiclient.client.aai.AAIObjectType; -import org.onap.aaiclient.client.aai.entities.AAIResultWrapper; -import org.onap.aaiclient.client.aai.entities.Relationships; -import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri; -import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory; import org.onap.so.client.orchestration.AAIEntityNotFoundException; import org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization; import org.onap.so.db.catalog.beans.CollectionResource; @@ -2423,8 +2424,8 @@ public class WorkflowActionTest extends BaseTaskTest { when(bbSetupUtils.getAAIServiceInstancesGloballyByName("siName123")).thenReturn(serviceInstances); Map<String, String> uriKeys = new HashMap<>(); - uriKeys.put("global-customer-id", "globalCustomerId"); - uriKeys.put("service-type", "serviceType"); + uriKeys.put(AAIFluentTypeBuilder.Types.CUSTOMER.getUriParams().globalCustomerId, "globalCustomerId"); + uriKeys.put(AAIFluentTypeBuilder.Types.SERVICE_SUBSCRIPTION.getUriParams().serviceType, "serviceType"); when(bbSetupUtils.getURIKeysFromServiceInstance("siId123")).thenReturn(uriKeys); diff --git a/docs/architecture/SO Internal Arc.pptx b/docs/architecture/SO Internal Arc.pptx Binary files differindex ee4b112b3b..3472b92a73 100644 --- a/docs/architecture/SO Internal Arc.pptx +++ b/docs/architecture/SO Internal Arc.pptx diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIObjectName.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIObjectName.java index 180a99e88b..d2b2300ee9 100644 --- a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIObjectName.java +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIObjectName.java @@ -1,23 +1,7 @@ package org.onap.aaiclient.client.aai; import org.onap.aaiclient.client.graphinventory.GraphInventoryObjectName; -import com.google.common.base.CaseFormat; -public class AAIObjectName implements GraphInventoryObjectName { +public interface AAIObjectName extends GraphInventoryObjectName { - private final String name; - - public AAIObjectName(String name) { - this.name = name; - } - - @Override - public String typeName() { - return name; - } - - @Override - public String typeName(CaseFormat format) { - return CaseFormat.LOWER_HYPHEN.to(format, this.name); - } } diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/AAIFluentSingleType.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/AAIFluentSingleType.java index 9310933499..519e49335d 100644 --- a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/AAIFluentSingleType.java +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/AAIFluentSingleType.java @@ -1,12 +1,25 @@ package org.onap.aaiclient.client.aai.entities.uri; +import org.onap.aaiclient.client.aai.AAIObjectName; import org.onap.aaiclient.client.aai.AAIObjectType; import org.onap.aaiclient.client.graphinventory.GraphInventoryFluentType; +import com.google.common.base.CaseFormat; public interface AAIFluentSingleType extends GraphInventoryFluentType<AAIObjectType> { - public interface Info extends GraphInventoryFluentType.Info { + public interface Info extends GraphInventoryFluentType.Info, AAIObjectName { + public default String typeName() { + return this.getName(); + } + + public default String typeName(CaseFormat format) { + return CaseFormat.LOWER_HYPHEN.to(format, this.getName()); + } + + public interface UriParams extends GraphInventoryFluentType.Info.UriParams { + + } } } diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryFluentType.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryFluentType.java index 94fa240244..5741bf36eb 100644 --- a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryFluentType.java +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryFluentType.java @@ -4,6 +4,12 @@ public interface GraphInventoryFluentType<T> extends GraphInventoryFluentTypeBas public interface Info extends GraphInventoryFluentTypeBase.Info { String getName(); + + UriParams getUriParams(); + + public interface UriParams { + + } } T build(); diff --git a/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/AAIObjectTypeTest.java b/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/AAIObjectTypeTest.java index 829ef1d646..000521bdf6 100644 --- a/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/AAIObjectTypeTest.java +++ b/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/AAIObjectTypeTest.java @@ -24,10 +24,10 @@ import static org.junit.Assert.assertEquals; import org.junit.Test; import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri; import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory; +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder; public class AAIObjectTypeTest { - @Test public void fromTypeNameTest() throws IllegalArgumentException, IllegalAccessException, InstantiationException { AAIObjectType type = AAIObjectType.fromTypeName("allotted-resource"); @@ -88,4 +88,27 @@ public class AAIObjectTypeTest { AAIResourceUri aaiUri = AAIUriFactory.createResourceUri(AAIObjectType.NETWORK_POLICY, id); assertEquals("/network/network-policies/network-policy/test1", aaiUri.build().toString()); } + + @Test + public void equalityTest() { + + AAIObjectType genericVnf = AAIFluentTypeBuilder.network().genericVnf("test").build(); + + assertEquals(AAIObjectType.GENERIC_VNF, genericVnf); + + } + + @Test + public void uriParamTest() { + + assertEquals("vnf-id", AAIFluentTypeBuilder.Types.GENERIC_VNF.getUriParams().vnfId); + + assertEquals("l-interface.interface-name", AAIFluentTypeBuilder.Types.L_INTERFACE.getUriParams().interfaceName); + + assertEquals("cloud-owner", AAIFluentTypeBuilder.Types.CLOUD_REGION.getUriParams().cloudOwner); + + assertEquals("cloud-region-id", AAIFluentTypeBuilder.Types.CLOUD_REGION.getUriParams().cloudRegionId); + + + } } diff --git a/graph-inventory/fluent-builder-maven-plugin/src/main/java/org/onap/graphinventory/generate/FluentGenerator.java b/graph-inventory/fluent-builder-maven-plugin/src/main/java/org/onap/graphinventory/generate/FluentGenerator.java index f9c664389b..23a1a812df 100644 --- a/graph-inventory/fluent-builder-maven-plugin/src/main/java/org/onap/graphinventory/generate/FluentGenerator.java +++ b/graph-inventory/fluent-builder-maven-plugin/src/main/java/org/onap/graphinventory/generate/FluentGenerator.java @@ -8,6 +8,7 @@ import java.util.Comparator; import java.util.List; import java.util.Map; import java.util.Map.Entry; +import java.util.regex.Matcher; import java.util.stream.Collectors; import javax.lang.model.element.Modifier; import org.apache.commons.lang3.ArrayUtils; @@ -240,19 +241,17 @@ public class FluentGenerator { } protected TypeSpec createTypes() { - Pair<String, String> path = splitClasspath(this.nameClass); - ClassName nameType = ClassName.get(path.getLeft(), path.getRight()); - - List<FieldSpec> params = - doc.values().stream().filter(item -> item.getType().equals("singular")) - .sorted(Comparator - .comparing(item -> item.getName())) - .map(item -> FieldSpec - .builder(nameType, - CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_UNDERSCORE, item.getName()), - Modifier.PUBLIC, Modifier.STATIC, Modifier.FINAL) - .initializer("new $T($S)", nameType, item.getName()).build()) - .collect(Collectors.toList()); + List<FieldSpec> params = doc.values().stream().filter(item -> item.getType().equals("singular")) + .sorted(Comparator.comparing(item -> item.getName())).map(item -> { + ClassName nameType = + ClassName.get(CLASSPATH, CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_CAMEL, item.getName())) + .nestedClass("Info"); + FieldSpec field = FieldSpec + .builder(nameType, CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_UNDERSCORE, item.getName()), + Modifier.PUBLIC, Modifier.STATIC, Modifier.FINAL) + .initializer("new $T()", nameType).build(); + return field; + }).collect(Collectors.toList()); TypeSpec type = TypeSpec.classBuilder("Types").addModifiers(Modifier.PUBLIC, Modifier.FINAL, Modifier.STATIC) .addFields(params).build(); @@ -276,30 +275,71 @@ public class FluentGenerator { .build()); ClassName superInterface; + String name; if (oType.getType().equals("plural")) { - classFields.add(FieldSpec.builder(String.class, "name") - .addModifiers(Modifier.PRIVATE, Modifier.FINAL, Modifier.STATIC) - .initializer("$S", oType.getAdditionalName()).build()); - superInterface = ClassName.get(this.pluralBuilderClass, "Info"); + Pair<String, String> path = splitClasspath(this.pluralBuilderClass); + superInterface = ClassName.get(path.getLeft(), path.getRight()); + name = oType.getAdditionalName(); } else if (oType.getType().equals("singular")) { - classFields.add(FieldSpec.builder(String.class, "name") - .addModifiers(Modifier.PRIVATE, Modifier.FINAL, Modifier.STATIC).initializer("$S", oType.getName()) - .build()); - superInterface = ClassName.get(this.singularBuilderClass, "Info"); + Pair<String, String> path = splitClasspath(this.singularBuilderClass); + superInterface = ClassName.get(path.getLeft(), path.getRight()); + name = oType.getName(); } else { - superInterface = ClassName.get(this.topLevelBuilderClass, "Info"); + Pair<String, String> path = splitClasspath(this.topLevelBuilderClass); + superInterface = ClassName.get(path.getLeft(), path.getRight()); + name = oType.getName(); } + superInterface = superInterface.nestedClass("Info"); methods.add(MethodSpec.methodBuilder("getPaths").returns(ParameterizedTypeName.get(List.class, String.class)) .addModifiers(Modifier.PUBLIC).addAnnotation(Override.class).addStatement("return Info.paths").build()); methods.add(MethodSpec.methodBuilder("getPartialUri").returns(String.class).addModifiers(Modifier.PUBLIC) .addAnnotation(Override.class).addStatement("return Info.partialUri").build()); if (!oType.getType().equals("top level")) { + classFields.add(FieldSpec.builder(String.class, "name") + .addModifiers(Modifier.PRIVATE, Modifier.FINAL, Modifier.STATIC).initializer("$S", name).build()); + classFields.add(FieldSpec.builder(ClassName.get("", "UriParams"), "uriParams") + .addModifiers(Modifier.PRIVATE, Modifier.FINAL, Modifier.STATIC) + .initializer("new $T()", ClassName.get("", "UriParams")).build()); methods.add(MethodSpec.methodBuilder("getName").returns(String.class).addModifiers(Modifier.PUBLIC) .addAnnotation(Override.class).addStatement("return Info.name").build()); + + methods.add(MethodSpec.methodBuilder("getUriParams").returns(ClassName.get("", "UriParams")) + .addModifiers(Modifier.PUBLIC).addAnnotation(Override.class).addStatement("return Info.uriParams") + .build()); + } + TypeSpec.Builder returnTypeSpec = TypeSpec.classBuilder("Info").addModifiers(Modifier.PUBLIC, Modifier.STATIC) + .addSuperinterface(superInterface).addFields(classFields).addMethods(methods); + if (!oType.getType().equals("top level")) { + returnTypeSpec.addType(createUriParamsClass(superInterface, oType)); + } + return returnTypeSpec.build(); + + } + + protected TypeSpec createUriParamsClass(ClassName parent, ObjectType oType) { + + List<FieldSpec> classFields = new ArrayList<>(); + Matcher params = Patterns.urlTemplatePattern.matcher(oType.getPartialUri()); + + while (params.find()) { + String value; + String name; + + if (params.group(2) != null) { + name = params.group(2); + } else { + name = params.group(1); + } + value = params.group(1); + + name = CaseFormat.LOWER_HYPHEN.to(CaseFormat.LOWER_CAMEL, name); + + classFields.add(FieldSpec.builder(String.class, name, Modifier.PUBLIC, Modifier.FINAL) + .initializer("$S", value).build()); } - return TypeSpec.classBuilder("Info").addModifiers(Modifier.PUBLIC, Modifier.STATIC) - .addSuperinterface(superInterface).addFields(classFields).addMethods(methods).build(); + return TypeSpec.classBuilder("UriParams").addModifiers(Modifier.PUBLIC, Modifier.STATIC, Modifier.FINAL) + .addFields(classFields).addSuperinterface(parent.nestedClass("UriParams")).build(); } protected String makeValidJavaVariable(String name) { diff --git a/graph-inventory/fluent-builder-maven-plugin/src/main/java/org/onap/graphinventory/generate/Patterns.java b/graph-inventory/fluent-builder-maven-plugin/src/main/java/org/onap/graphinventory/generate/Patterns.java new file mode 100644 index 0000000000..8be22e1dcc --- /dev/null +++ b/graph-inventory/fluent-builder-maven-plugin/src/main/java/org/onap/graphinventory/generate/Patterns.java @@ -0,0 +1,11 @@ +package org.onap.graphinventory.generate; + +import java.util.regex.Pattern; + +public class Patterns { + + public static final Pattern pluralPattern = Pattern.compile(".*(?<partial>/(?<name>[^{]*$))"); + public static final Pattern singularPattern = Pattern.compile(".*(?<partial>/(?<name>[^/{}]*)/\\{.*$)"); + public static final Pattern topLevelPattern = Pattern.compile("^/([^/]+)/.*"); + public static final Pattern urlTemplatePattern = Pattern.compile("\\{([^}.]+(?:\\.([^}]+))?)\\}"); +} diff --git a/graph-inventory/fluent-builder-maven-plugin/src/main/java/org/onap/graphinventory/generate/SwaggerConverter.java b/graph-inventory/fluent-builder-maven-plugin/src/main/java/org/onap/graphinventory/generate/SwaggerConverter.java index b3ced65390..42305488bc 100644 --- a/graph-inventory/fluent-builder-maven-plugin/src/main/java/org/onap/graphinventory/generate/SwaggerConverter.java +++ b/graph-inventory/fluent-builder-maven-plugin/src/main/java/org/onap/graphinventory/generate/SwaggerConverter.java @@ -7,7 +7,6 @@ import java.util.List; import java.util.Map; import java.util.Set; import java.util.regex.Matcher; -import java.util.regex.Pattern; import java.util.stream.Collectors; import org.apache.maven.plugin.logging.Log; import com.fasterxml.jackson.core.JsonProcessingException; @@ -33,10 +32,6 @@ public class SwaggerConverter { .filter(item -> !item.getKey().endsWith("/relationship-list/relationship")) .collect(Collectors.toMap(item -> item.getKey(), item -> item.getValue())); - Pattern pluralPattern = Pattern.compile(".*(?<partial>/(?<name>[^{]*$))"); - Pattern singularPattern = Pattern.compile(".*(?<partial>/(?<name>[^/{}]*)/\\{.*$)"); - Pattern topLevelPattern = Pattern.compile("^/([^/]+)/.*"); - Pattern urlTemplatePattern = Pattern.compile("\\{([^}]+)\\}"); Matcher pluralMatcher; Matcher singularMatcher; Matcher topLevelMatcher; @@ -44,9 +39,9 @@ public class SwaggerConverter { Map<String, ObjectType> output = new HashMap<>(); for (Map.Entry<String, Path> entry : paths.entrySet()) { - pluralMatcher = pluralPattern.matcher(entry.getKey()); - singularMatcher = singularPattern.matcher(entry.getKey()); - topLevelMatcher = topLevelPattern.matcher(entry.getKey()); + pluralMatcher = Patterns.pluralPattern.matcher(entry.getKey()); + singularMatcher = Patterns.singularPattern.matcher(entry.getKey()); + topLevelMatcher = Patterns.topLevelPattern.matcher(entry.getKey()); ObjectType item; if (pluralMatcher.matches()) { if (!output.containsKey(pluralMatcher.group("name"))) { @@ -158,7 +153,7 @@ public class SwaggerConverter { } if (!item.getValue().getFields().isEmpty()) { - Matcher templates = urlTemplatePattern.matcher(item.getValue().getPartialUri()); + Matcher templates = Patterns.urlTemplatePattern.matcher(item.getValue().getPartialUri()); List<String> localFields = new ArrayList<>(); while (templates.find()) { localFields.add(templates.group(1)); diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/BpmnRequestBuilder.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/BpmnRequestBuilder.java index 8b270f8d5a..e8046a2cd9 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/BpmnRequestBuilder.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/BpmnRequestBuilder.java @@ -29,11 +29,12 @@ import org.onap.aai.domain.yang.L3Network; import org.onap.aai.domain.yang.ServiceInstance; import org.onap.aai.domain.yang.VfModule; import org.onap.aai.domain.yang.VolumeGroup; +import org.onap.aaiclient.client.aai.AAIObjectType; +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper; +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder; import org.onap.logging.ref.slf4j.ONAPLogConstants; import org.onap.so.apihandlerinfra.infra.rest.exception.AAIEntityNotFound; import org.onap.so.apihandlerinfra.infra.rest.exception.CloudConfigurationNotFoundException; -import org.onap.aaiclient.client.aai.AAIObjectType; -import org.onap.aaiclient.client.aai.entities.AAIResultWrapper; import org.onap.so.constants.Status; import org.onap.so.db.request.beans.InfraActiveRequests; import org.onap.so.db.request.client.RequestsDbClient; @@ -56,12 +57,6 @@ public class BpmnRequestBuilder { private static final String CLOUD_CONFIGURATION_COULD_NOT_BE_FOUND = "Cloud Configuration could not be found"; - private static final String CLOUD_REGION_ID = "cloud-region-id"; - - private static final String CLOUD_OWNER = "cloud-owner"; - - private static final String TENANT_ID = "tenant-id"; - private static final String GENERIC_VNF_NOT_FOUND_IN_INVENTORY_VNF_ID = "Generic Vnf Not Found In Inventory, VnfId: "; @@ -283,11 +278,14 @@ public class BpmnRequestBuilder { String lcpRegionId = null; if (relationshipsOpt.isPresent()) { tenantId = relationshipsOpt.get().getRelatedUris(AAIObjectType.TENANT).stream().findFirst() - .map(item -> item.getURIKeys().get(TENANT_ID)).orElse(null); - cloudOwner = relationshipsOpt.get().getRelatedUris(AAIObjectType.TENANT).stream().findFirst() - .map(item -> item.getURIKeys().get(CLOUD_OWNER)).orElse(null); - lcpRegionId = relationshipsOpt.get().getRelatedUris(AAIObjectType.TENANT).stream().findFirst() - .map(item -> item.getURIKeys().get(CLOUD_REGION_ID)).orElse(null); + .map(item -> item.getURIKeys().get(AAIFluentTypeBuilder.Types.TENANT.getUriParams().tenantId)) + .orElse(null); + cloudOwner = relationshipsOpt.get().getRelatedUris(AAIObjectType.TENANT).stream().findFirst().map( + item -> item.getURIKeys().get(AAIFluentTypeBuilder.Types.CLOUD_REGION.getUriParams().cloudOwner)) + .orElse(null); + lcpRegionId = relationshipsOpt.get().getRelatedUris(AAIObjectType.TENANT).stream().findFirst().map( + item -> item.getURIKeys().get(AAIFluentTypeBuilder.Types.CLOUD_REGION.getUriParams().cloudRegionId)) + .orElse(null); } if (tenantId == null || cloudOwner == null || lcpRegionId == null) { @@ -325,11 +323,14 @@ public class BpmnRequestBuilder { String lcpRegionId = null; if (relationshipsOpt.isPresent()) { tenantId = relationshipsOpt.get().getRelatedUris(AAIObjectType.TENANT).stream().findFirst() - .map(item -> item.getURIKeys().get(TENANT_ID)).orElse(null); - cloudOwner = relationshipsOpt.get().getRelatedUris(AAIObjectType.TENANT).stream().findFirst() - .map(item -> item.getURIKeys().get(CLOUD_OWNER)).orElse(null); - lcpRegionId = relationshipsOpt.get().getRelatedUris(AAIObjectType.TENANT).stream().findFirst() - .map(item -> item.getURIKeys().get(CLOUD_REGION_ID)).orElse(null); + .map(item -> item.getURIKeys().get(AAIFluentTypeBuilder.Types.TENANT.getUriParams().tenantId)) + .orElse(null); + cloudOwner = relationshipsOpt.get().getRelatedUris(AAIObjectType.TENANT).stream().findFirst().map( + item -> item.getURIKeys().get(AAIFluentTypeBuilder.Types.CLOUD_REGION.getUriParams().cloudOwner)) + .orElse(null); + lcpRegionId = relationshipsOpt.get().getRelatedUris(AAIObjectType.TENANT).stream().findFirst().map( + item -> item.getURIKeys().get(AAIFluentTypeBuilder.Types.CLOUD_REGION.getUriParams().cloudRegionId)) + .orElse(null); } if (tenantId == null || cloudOwner == null || lcpRegionId == null) { diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironment.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironment.java index 4a244a6a7b..d4c66f62e4 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironment.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironment.java @@ -26,8 +26,13 @@ import javax.ws.rs.core.Response; import org.apache.http.HttpStatus; import org.json.JSONObject; import org.onap.aai.domain.yang.OperationalEnvironment; +import org.onap.aaiclient.client.aai.AAIObjectType; +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper; +import org.onap.aaiclient.client.aai.entities.Relationships; +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri; +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.apihandler.common.ErrorNumbers; -import org.onap.so.db.request.client.RequestsDbClient; import org.onap.so.apihandlerinfra.exceptions.ApiException; import org.onap.so.apihandlerinfra.exceptions.ValidateException; import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo; @@ -36,13 +41,9 @@ import org.onap.so.apihandlerinfra.tenantisolation.helpers.AAIClientHelper; import org.onap.so.apihandlerinfra.tenantisolation.helpers.ActivateVnfDBHelper; import org.onap.so.apihandlerinfra.tenantisolation.helpers.SDCClientHelper; import org.onap.so.apihandlerinfra.tenantisolationbeans.ServiceModelList; -import org.onap.aaiclient.client.aai.AAIObjectType; -import org.onap.aaiclient.client.aai.entities.AAIResultWrapper; -import org.onap.aaiclient.client.aai.entities.Relationships; -import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri; import org.onap.so.db.request.beans.OperationalEnvDistributionStatus; import org.onap.so.db.request.beans.OperationalEnvServiceModelStatus; -import org.onap.logging.filter.base.ErrorCode; +import org.onap.so.db.request.client.RequestsDbClient; import org.onap.so.logger.MessageEnum; import org.onap.so.requestsdb.RequestsDBHelper; import org.slf4j.Logger; @@ -58,7 +59,6 @@ public class ActivateVnfOperationalEnvironment { private static final Logger logger = LoggerFactory.getLogger(ActivateVnfOperationalEnvironment.class); private static final int DEFAULT_ACTIVATE_RETRY_COUNT = 3; private static final String DISTRIBUTION_STATUS_SENT = "SENT"; - private static final String OPER_ENVIRONMENT_ID_KEY = "operational-environment-id"; @Autowired private ActivateVnfDBHelper dbHelper; @@ -97,8 +97,8 @@ public class ActivateVnfOperationalEnvironment { List<AAIResourceUri> operationalEnvironments = relationships.getRelatedAAIUris(AAIObjectType.OPERATIONAL_ENVIRONMENT); if (!operationalEnvironments.isEmpty()) { - ecompOperationalEnvironmentId = - operationalEnvironments.get(0).getURIKeys().get(OPER_ENVIRONMENT_ID_KEY); + ecompOperationalEnvironmentId = operationalEnvironments.get(0).getURIKeys().get( + AAIFluentTypeBuilder.Types.OPERATIONAL_ENVIRONMENT.getUriParams().operationalEnvironmentId); } } logger.debug(" vnfOperationalEnvironmentId : {}", vnfOperationalEnvironmentId); @@ -123,7 +123,8 @@ public class ActivateVnfOperationalEnvironment { .build(); throw new ValidateException.Builder( " The ECOMP OE was not in aai record; the value of relationship.relationship-data key: " - + OPER_ENVIRONMENT_ID_KEY, + + AAIFluentTypeBuilder.Types.OPERATIONAL_ENVIRONMENT + .getUriParams().operationalEnvironmentId, HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).errorInfo(errorLoggerInfo) .build(); } |