Add nssiId for AllocateTNNSSI request
[so.git] / bpmn / so-bpmn-infrastructure-common / src / main / groovy / org / onap / so / bpmn / infrastructure / scripts / DoUpdateVnfAndModules.groovy
index 3d8205f..0285ae2 100644 (file)
@@ -22,7 +22,9 @@
 
 package org.onap.so.bpmn.infrastructure.scripts
 
+import org.onap.so.logger.LoggingAnchor
 import org.onap.so.client.HttpClientFactory
+import org.onap.logging.filter.base.ErrorCode
 
 import javax.ws.rs.core.Response
 import org.camunda.bpm.engine.delegate.BpmnError
@@ -35,16 +37,17 @@ import org.onap.so.bpmn.core.domain.ModelInfo
 import org.onap.so.bpmn.core.domain.ModuleResource
 import org.onap.so.bpmn.core.domain.VnfResource
 import org.onap.so.bpmn.core.json.JsonUtils
-import org.onap.so.client.graphinventory.entities.uri.Depth
+import org.onap.aaiclient.client.graphinventory.entities.uri.Depth
 import org.onap.so.client.HttpClient
-import org.onap.so.client.aai.AAIObjectType
-import org.onap.so.client.aai.entities.uri.AAIResourceUri
-import org.onap.so.client.aai.entities.uri.AAIUriFactory;
+import org.onap.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.onap.so.logger.MessageEnum
-import org.onap.so.logger.MsoLogger
 import org.slf4j.Logger
 import org.slf4j.LoggerFactory
-import org.onap.so.utils.TargetEntity
+import org.onap.logging.filter.base.ONAPComponents;
 
 /**
  * This class supports the VID Flow
@@ -158,12 +161,12 @@ class DoUpdateVnfAndModules extends AbstractServiceTaskProcessor {
                        def vnfId = execution.getVariable('vnfId')
 
                        AaiUtil aaiUriUtil = new AaiUtil(this)
-                       AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId).depth(Depth.ONE)
+                       AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId)).depth(Depth.ONE)
                        String endPoint = aaiUriUtil.createAaiUri(uri)
                        logger.debug("AAI endPoint: " + endPoint)
 
                        try {
-                               HttpClient client = new HttpClientFactory().newXmlClient(new URL(endPoint), TargetEntity.AAI)
+                               HttpClient client = new HttpClientFactory().newXmlClient(new URL(endPoint), ONAPComponents.AAI)
                                client.addAdditionalHeader('X-TransactionId', UUID.randomUUID().toString())
                                client.addAdditionalHeader('X-FromAppId', 'MSO')
                                client.addAdditionalHeader('Content-Type', 'application/xml')
@@ -265,17 +268,16 @@ class DoUpdateVnfAndModules extends AbstractServiceTaskProcessor {
                                }
                                execution.setVariable("DUVAM_vfModules", vfModulesList)
                        } catch (Exception ex) {
-                               ex.printStackTrace()
-                               logger.debug('Exception occurred while executing AAI GET:' + ex.getMessage())
+                               logger.debug('Exception occurred while executing AAI GET: {}', ex.getMessage(), ex)
                                exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'AAI GET Failed:' + ex.getMessage())
                        }
                        logger.trace('Exited ' + method)
                } catch (BpmnError e) {
                        throw e;
                } catch (Exception e) {
-                       logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
+                       logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
                                        'Caught exception in ' + method, "BPMN",
-                                       MsoLogger.ErrorCode.UnknownError.getValue(), "Exception is:\n" + e);
+                                       ErrorCode.UnknownError.getValue(), "Exception is:\n" + e);
                        exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in queryAAIVfModule(): ' + e.getMessage())
                }
        }
@@ -329,9 +331,9 @@ class DoUpdateVnfAndModules extends AbstractServiceTaskProcessor {
                        }
 
                }catch(Exception e){
-                       logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
+                       logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
                                        "Exception Occured Processing preProcessAddOnModule. Exception is:\n" + e, "BPMN",
-                                       MsoLogger.ErrorCode.UnknownError.getValue(), "Exception is:\n" + e);
+                                       ErrorCode.UnknownError.getValue(), "Exception is:\n" + e);
                        exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during prepareNextModuleToUpdate Method:\n" + e.getMessage())
                }
                logger.trace("COMPLETED prepareNextModuleToUpdate ")
@@ -405,9 +407,9 @@ class DoUpdateVnfAndModules extends AbstractServiceTaskProcessor {
                } catch (BpmnError e) {
                        throw e;
                } catch (Exception e) {
-                       logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
+                       logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
                                        'Caught exception in ' + method, "BPMN",
-                                       MsoLogger.ErrorCode.UnknownError.getValue(), "Exception is:\n" + e);
+                                       ErrorCode.UnknownError.getValue(), "Exception is:\n" + e);
                        exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepUpdateAAIGenericVnf(): ' + e.getMessage())
                }
        }