Add nssiId for AllocateTNNSSI request
[so.git] / bpmn / so-bpmn-infrastructure-common / src / main / groovy / org / onap / so / bpmn / infrastructure / scripts / DoCreateVFCNetworkServiceInstance.groovy
index 418a1bd..8eded75 100644 (file)
 
 package org.onap.so.bpmn.infrastructure.scripts
 
+import org.onap.so.logger.LoggingAnchor
 import org.onap.so.client.HttpClientFactory
-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.aaiclient.client.aai.AAIObjectType
+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.camunda.bpm.engine.delegate.BpmnError
 import org.camunda.bpm.engine.delegate.DelegateExecution
 import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
 import org.onap.so.bpmn.common.scripts.ExceptionUtil
 import org.onap.so.bpmn.core.json.JsonUtils
 import org.onap.so.client.HttpClient
+import org.onap.logging.filter.base.ErrorCode
 import org.onap.so.logger.MessageEnum
-import org.onap.so.logger.MsoLogger
 import org.slf4j.Logger
 import org.slf4j.LoggerFactory
 import org.onap.so.bpmn.core.UrnPropertiesReader
 
-import org.onap.so.utils.TargetEntity
+import org.onap.logging.filter.base.ONAPComponents;
 
 import javax.ws.rs.core.Response
 
@@ -60,7 +63,7 @@ public class DoCreateVFCNetworkServiceInstance extends AbstractServiceTaskProces
      * generate the nsOperationKey
      * generate the nsParameters
      */
-    public void preProcessRequest (DelegateExecution execution) {
+    void preProcessRequest (DelegateExecution execution) {
        String msg = ""
        logger.trace("preProcessRequest()")
        try {
@@ -129,7 +132,7 @@ public class DoCreateVFCNetworkServiceInstance extends AbstractServiceTaskProces
     /**
      * create NS task
      */
-    public void createNetworkService(DelegateExecution execution) {
+    void createNetworkService(DelegateExecution execution) {
         logger.trace("createNetworkService")
         String vfcAdapterUrl = execution.getVariable("vfcAdapterUrl")
         String nsOperationKey = execution.getVariable("nsOperationKey");
@@ -156,7 +159,7 @@ public class DoCreateVFCNetworkServiceInstance extends AbstractServiceTaskProces
     /**
      * instantiate NS task
      */
-    public void instantiateNetworkService(DelegateExecution execution) {
+    void instantiateNetworkService(DelegateExecution execution) {
         logger.trace("instantiateNetworkService")
         String vfcAdapterUrl = execution.getVariable("vfcAdapterUrl")
         String nsOperationKey = execution.getVariable("nsOperationKey");
@@ -185,7 +188,7 @@ public class DoCreateVFCNetworkServiceInstance extends AbstractServiceTaskProces
     /**
      * query NS task
      */
-    public void queryNSProgress(DelegateExecution execution) {
+    void queryNSProgress(DelegateExecution execution) {
         logger.trace("queryNSProgress")
         String vfcAdapterUrl = execution.getVariable("vfcAdapterUrl")
         String jobId = execution.getVariable("jobId")
@@ -205,7 +208,7 @@ public class DoCreateVFCNetworkServiceInstance extends AbstractServiceTaskProces
     /**
      * delay 5 sec
      */
-    public void timeDelay(DelegateExecution execution) {
+    void timeDelay(DelegateExecution execution) {
         try {
             Thread.sleep(5000);
         } catch(InterruptedException e) {
@@ -216,7 +219,7 @@ public class DoCreateVFCNetworkServiceInstance extends AbstractServiceTaskProces
     /**
      * finish NS task
      */
-    public void addNSRelationship(DelegateExecution execution) {
+    void addNSRelationship(DelegateExecution execution) {
         logger.trace("addNSRelationship")
         String nsInstanceId = execution.getVariable("nsInstanceId")
         if(nsInstanceId == null || nsInstanceId == ""){
@@ -227,16 +230,16 @@ public class DoCreateVFCNetworkServiceInstance extends AbstractServiceTaskProces
         String serviceType = execution.getVariable("serviceType")
         String serviceId = execution.getVariable("serviceId")
 
-        AAIResourceUri nsUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE,globalSubscriberId,serviceType,nsInstanceId)
-        AAIResourceUri relatedServiceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE,globalSubscriberId,serviceType,serviceId)
+        AAIResourceUri nsUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(serviceType).serviceInstance(nsInstanceId))
+        AAIResourceUri relatedServiceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(serviceType).serviceInstance(serviceId))
 
         try{
             getAAIClient().connect(nsUri,relatedServiceUri)
             logger.info("NS relationship to Service added successfully")
         }catch(Exception e){
-            logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
+            logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
                     "Exception occured while executing AAI Put Call", "BPMN",
-                    MsoLogger.ErrorCode.UnknownError.getValue(), "Exception is:\n" + e);
+                    ErrorCode.UnknownError.getValue(), "Exception is:\n" + e);
             throw new BpmnError("MSOWorkflowException")
         }
     }
@@ -257,7 +260,7 @@ public class DoCreateVFCNetworkServiceInstance extends AbstractServiceTaskProces
             // Get the Basic Auth credentials for the VFCAdapter, username is 'bpel', auth is '07a7159d3bf51a0e53be7a8f89699be7'
             // user 'bepl' authHeader is the same with mso.db.auth
             String basicAuthValuedb =  UrnPropertiesReader.getVariable("mso.db.auth", execution)
-            HttpClient httpClient = new HttpClientFactory().newJsonClient(url, TargetEntity.VNF_ADAPTER)
+            HttpClient httpClient = new HttpClientFactory().newJsonClient(url, ONAPComponents.VNF_ADAPTER)
             httpClient.addAdditionalHeader("Accept", "application/json")
             httpClient.addAdditionalHeader("Authorization", basicAuthValuedb)