SO catalogDB updates
[so.git] / bpmn / MSOCommonBPMN / src / main / groovy / org / onap / so / bpmn / common / scripts / ConfirmVolumeGroupTenant.groovy
index 011fcb6..fce9286 100644 (file)
 
 package org.onap.so.bpmn.common.scripts
 
-import com.google.common.base.Strings
 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.client.aai.AAIObjectType
-import org.onap.so.client.aai.entities.AAIResultWrapper
-import org.onap.so.client.aai.entities.Relationships
-import org.onap.so.client.aai.entities.uri.AAIResourceUri
-import org.onap.so.client.aai.entities.uri.AAIUriFactory
+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.generated.fluentbuilders.AAIFluentTypeBuilder.Types
+import org.onap.logging.filter.base.ErrorCode
 import org.onap.so.constants.Defaults
-import org.onap.so.logger.ErrorCode
+import org.onap.so.logger.LoggingAnchor
 import org.onap.so.logger.MessageEnum
 import org.slf4j.Logger
 import org.slf4j.LoggerFactory
@@ -61,7 +63,7 @@ class ConfirmVolumeGroupTenant extends AbstractServiceTaskProcessor{
                        String incomingGroupName = execution.getVariable("volumeGroupName")
                        String incomingTenantId = execution.getVariable("tenantId")
                        String aicCloudRegion = execution.getVariable("aicCloudRegion")
-                       AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, Defaults.CLOUD_OWNER.toString(), aicCloudRegion, volumeGroupId)
+                       AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(Defaults.CLOUD_OWNER.toString(), aicCloudRegion).volumeGroup(volumeGroupId))
                        AAIResultWrapper wrapper = getAAIClient().get(uri);
                        Optional<VolumeGroup> volumeGroup = wrapper.asBean(VolumeGroup.class)
                        Optional<Relationships> relationships = wrapper.getRelationships()
@@ -69,9 +71,9 @@ class ConfirmVolumeGroupTenant extends AbstractServiceTaskProcessor{
                                execution.setVariable("queryAAIVolumeGroupResponse", volumeGroup.get())
                                String volumeGroupTenantId = ""
                                if(relationships.isPresent()){
-                                       List<AAIResourceUri> tenantUris = relationships.get().getRelatedAAIUris(AAIObjectType.TENANT)
+                                       List<AAIResourceUri> tenantUris = relationships.get().getRelatedUris(Types.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
@@ -106,7 +108,7 @@ class ConfirmVolumeGroupTenant extends AbstractServiceTaskProcessor{
                }catch(BpmnError b){
                        throw b
                }catch(Exception e){
-                       logger.error(Strings.repeat("{} ", 5), MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
+                       logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
                                        "Exception Occured Processing queryAAIForVolumeGroup.", "BPMN",
                                        ErrorCode.UnknownError.getValue(), e.getMessage());
                        exceptionUtil.buildAndThrowWorkflowException(execution, 5000, "Internal Error - Occured in preProcessRequest.")
@@ -128,7 +130,7 @@ class ConfirmVolumeGroupTenant extends AbstractServiceTaskProcessor{
                        logger.debug("Volume Heat Stack Id is: " + heatStackId)
 
                }catch(Exception e){
-               logger.error(Strings.repeat("{} ", 5), MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
+               logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
                                "Exception Occured Processing assignVolumeHeatId.", "BPMN",
                                ErrorCode.UnknownError.getValue(), e);
                exceptionUtil.buildAndThrowWorkflowException(execution, 5000, "Internal Error - Occured in assignVolumeHeatId.")
@@ -148,7 +150,7 @@ class ConfirmVolumeGroupTenant extends AbstractServiceTaskProcessor{
 
                        exceptionUtil.buildWorkflowException(execution, errorCode, errorMessage)
                }catch(Exception e){
-                       logger.error(Strings.repeat("{} ", 5), MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
+                       logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
                                        "Exception Occured Processing assignWorkflowException.", "BPMN",
                                        ErrorCode.UnknownError.getValue(), e);
                }