Merge "SO refactor II - refactor VnfEBBLoader.java"
authorByung-Woo Jun <byung-woo.jun@est.tech>
Fri, 19 Mar 2021 11:26:09 +0000 (11:26 +0000)
committerGerrit Code Review <gerrit@onap.org>
Fri, 19 Mar 2021 11:26:09 +0000 (11:26 +0000)
21 files changed:
adapters/mso-openstack-adapters/pom.xml
adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/cloudregion/CloudRegionRestV1.java
adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/openstack/CXFConfiguration.java
adapters/mso-requests-db-adapter/pom.xml
adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/application/CXFConfiguration.java
adapters/mso-sdnc-adapter/pom.xml
adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/CXFConfiguration.java
asdc-controller/pom.xml
asdc-controller/src/main/java/org/onap/so/asdc/JerseyConfiguration.java
bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSIandNSSI.groovy
bpmn/so-bpmn-infrastructure-flows/pom.xml
bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/CreateVcpeResCustServiceSimplifiedTest.java
bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/GenericPnfSoftwareUpgradeTest.java
bpmn/so-bpmn-tasks/pom.xml
bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/UserParamsServiceTraversal.java
common/src/main/java/org/onap/so/beans/nsmf/AllocateTnNssi.java
common/src/main/java/org/onap/so/logger/MaskLogStatements.java [new file with mode: 0644]
common/src/test/java/org/onap/so/logging/MaskLogStatementsTest.java [new file with mode: 0644]
common/src/test/resources/__files/logging/openstack-payload.json [new file with mode: 0644]
graph-inventory/fluent-builder-maven-plugin/pom.xml
pom.xml

index 32448d3..6dcc1a4 100644 (file)
     </dependency>
     <dependency>
       <groupId>org.apache.cxf</groupId>
-      <artifactId>cxf-rt-rs-service-description-swagger</artifactId>
+      <artifactId>cxf-rt-rs-service-description-openapi-v3</artifactId>
     </dependency>
     <dependency>
       <groupId>org.springframework.boot</groupId>
index 6cf42e1..49cc019 100644 (file)
@@ -39,15 +39,18 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import io.swagger.annotations.ApiParam;
-import io.swagger.annotations.ApiResponse;
-import io.swagger.annotations.ApiResponses;
+import io.swagger.v3.oas.annotations.OpenAPIDefinition;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.info.Info;
+import io.swagger.v3.oas.annotations.media.Content;
+import io.swagger.v3.oas.annotations.media.Schema;
+import io.swagger.v3.oas.annotations.responses.ApiResponse;
+import io.swagger.v3.oas.annotations.responses.ApiResponses;
 
 
 @Path("/v1/cloud-region")
-@Api(value = "/v1/cloud-region", description = "root of cloud region adapter")
+@OpenAPIDefinition(info = @Info(title = "/v1/cloud-region", description = "root of cloud region adapter"))
 @Component
 public class CloudRegionRestV1 {
     private static Logger logger = LoggerFactory.getLogger(CloudRegionRestV1.class);
@@ -58,13 +61,12 @@ public class CloudRegionRestV1 {
     @POST
     @Consumes({MediaType.APPLICATION_JSON})
     @Produces({MediaType.APPLICATION_JSON})
-    @ApiOperation(value = "CreateCloudRegion", response = Response.class,
-            notes = "Create a cloud site in MSO and Region In AAI")
-    @ApiResponses({@ApiResponse(code = 201, message = "Cloud Region has been created"),
-            @ApiResponse(code = 500, message = "Create Cloud Region has failed")})
+    @Operation(description = "CreateCloudRegion", summary = "Create a cloud site in MSO and Region In AAI")
+    @ApiResponses({@ApiResponse(responseCode = "201", description = "Cloud Region has been created"),
+            @ApiResponse(responseCode = "500", description = "Create Cloud Region has failed")})
     public Response createCloudRegion(
-            @ApiParam(value = "cloud-region-id", required = true) @PathParam("cloud-region-id") String cloudRegionId,
-            @ApiParam(value = "CloudSite", required = true) final CloudSite cloudSite) {
+            @Parameter(name = "cloud-region-id", required = true) @PathParam("cloud-region-id") String cloudRegionId,
+            @Parameter(name = "CloudSite", required = true) final CloudSite cloudSite) {
         cloudRestImpl.createCloudRegion(cloudSite);
         return Response.status(HttpStatus.SC_CREATED).build();
     }
@@ -73,12 +75,12 @@ public class CloudRegionRestV1 {
     @Path("{cloud-region-id}/{cloud-owner}")
     @Consumes({MediaType.APPLICATION_JSON})
     @Produces({MediaType.APPLICATION_JSON})
-    @ApiOperation(value = "CreateCloudRegion", response = Response.class, notes = "Delete an cloud Region in SO")
-    @ApiResponses({@ApiResponse(code = 204, message = "cloud Region has been deleted"),
-            @ApiResponse(code = 500, message = "Cloud Region delete has failed")})
+    @Operation(description = "CreateCloudRegion", summary = "Delete an cloud Region in SO")
+    @ApiResponses({@ApiResponse(responseCode = "204", description = "cloud Region has been deleted"),
+            @ApiResponse(responseCode = "500", description = "Cloud Region delete has failed")})
     public Response deleteCloudRegion(
-            @ApiParam(value = "cloud-region-id", required = true) @PathParam("cloud-region-id") String cloudRegionId,
-            @ApiParam(value = "cloud-owner", required = true) @PathParam("cloud-owner") String cloudOwner) {
+            @Parameter(name = "cloud-region-id", required = true) @PathParam("cloud-region-id") String cloudRegionId,
+            @Parameter(name = "cloud-owner", required = true) @PathParam("cloud-owner") String cloudOwner) {
         cloudRestImpl.deleteCloudRegion(cloudRegionId);
         return Response.status(HttpStatus.SC_NO_CONTENT).build();
     }
@@ -87,13 +89,13 @@ public class CloudRegionRestV1 {
     @Path("{cloud-region-id}/{cloud-owner}")
     @Consumes({MediaType.APPLICATION_JSON})
     @Produces({MediaType.APPLICATION_JSON})
-    @ApiOperation(value = "CreateCloudRegion", response = Response.class, notes = "Update an existing Cloud Region")
-    @ApiResponses({@ApiResponse(code = 200, message = "Cloud Region has been updated"),
-            @ApiResponse(code = 500, message = "Update Cloud Region has failed examine entity object for details")})
+    @Operation(description = "CreateCloudRegion", summary = "Update an existing Cloud Region")
+    @ApiResponses({@ApiResponse(responseCode = "200", description = "Cloud Region has been updated"), @ApiResponse(
+            responseCode = "500", description = "Update Cloud Region has failed examine entity object for details")})
     public Response updateCloudRegion(
-            @ApiParam(value = "cloud-region-id", required = true) @PathParam("cloud-region-id") String cloudRegionId,
-            @ApiParam(value = "cloud-owner", required = true) @PathParam("cloud-owner") String cloudOwner,
-            @ApiParam(value = "CloudSite", required = true) final CloudSite cloudSite) {
+            @Parameter(name = "cloud-region-id", required = true) @PathParam("cloud-region-id") String cloudRegionId,
+            @Parameter(name = "cloud-owner", required = true) @PathParam("cloud-owner") String cloudOwner,
+            @Parameter(name = "CloudSite", required = true) final CloudSite cloudSite) {
         cloudRestImpl.updateCloudRegion(cloudSite);
         return Response.status(HttpStatus.SC_OK).build();
     }
index 1446047..942da29 100644 (file)
 package org.onap.so.adapters.openstack;
 
 import java.util.Arrays;
+import java.util.HashSet;
 import javax.xml.ws.Endpoint;
 import org.apache.cxf.Bus;
 import org.apache.cxf.bus.spring.SpringBus;
 import org.apache.cxf.endpoint.Server;
 import org.apache.cxf.feature.LoggingFeature;
 import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
-import org.apache.cxf.jaxrs.swagger.Swagger2Feature;
+import org.apache.cxf.jaxrs.openapi.OpenApiFeature;
 import org.apache.cxf.jaxws.EndpointImpl;
 import org.apache.cxf.transport.servlet.CXFServlet;
 import org.onap.so.adapters.cloudregion.CloudRegionRestV1;
@@ -101,18 +102,17 @@ public class CXFConfiguration {
         return endpoint.create();
     }
 
-
     @Bean
-    public Swagger2Feature createSwaggerFeature() {
-        Swagger2Feature swagger2Feature = new Swagger2Feature();
-        swagger2Feature.setPrettyPrint(true);
-        swagger2Feature.setTitle("SO Orchestration Application");
-        swagger2Feature.setContact("The ONAP SO team");
-        swagger2Feature.setDescription("This project is the SO Orchestration Engine");
-        swagger2Feature.setVersion("1.0.0");
-        swagger2Feature.setResourcePackage(
-                "org.onap.so.adapters.network,org.onap.so.adapters.tenant,org.onap.so.adapters.vnf");
-        swagger2Feature.setScan(true);
-        return swagger2Feature;
+    public OpenApiFeature createSwaggerFeature() {
+        OpenApiFeature openApiFeature = new OpenApiFeature();
+        openApiFeature.setPrettyPrint(true);
+        openApiFeature.setTitle("SO Orchestration Application");
+        openApiFeature.setContactName("The ONAP SO team");
+        openApiFeature.setDescription("This project is the SO Orchestration Engine");
+        openApiFeature.setVersion("1.0.0");
+        openApiFeature.setResourcePackages(
+                new HashSet<String>(Arrays.asList("org.onap.so.adapters.network,org.onap.so.adapters.vnf")));
+        openApiFeature.setScan(true);
+        return openApiFeature;
     }
 }
index 09e2cc2..45acf24 100644 (file)
@@ -19,7 +19,7 @@
     </dependency>
     <dependency>
       <groupId>org.apache.cxf</groupId>
-      <artifactId>cxf-rt-rs-service-description-swagger</artifactId>
+      <artifactId>cxf-rt-rs-service-description-openapi-v3</artifactId>
     </dependency>
     <dependency>
       <groupId>org.springframework.boot</groupId>
index 06d75be..2325ffa 100644 (file)
 
 package org.onap.so.adapters.requestsdb.application;
 
+import java.util.Arrays;
+import java.util.HashSet;
 import javax.xml.ws.Endpoint;
 import org.apache.cxf.Bus;
 import org.apache.cxf.feature.LoggingFeature;
-import org.apache.cxf.jaxrs.swagger.Swagger2Feature;
+import org.apache.cxf.jaxrs.openapi.OpenApiFeature;
 import org.apache.cxf.jaxws.EndpointImpl;
 import org.apache.cxf.transport.servlet.CXFServlet;
 import org.onap.so.adapters.requestsdb.MsoRequestsDbAdapter;
@@ -65,16 +67,16 @@ public class CXFConfiguration {
     }
 
     @Bean
-    public Swagger2Feature createSwaggerFeature() {
-        Swagger2Feature swagger2Feature = new Swagger2Feature();
-        swagger2Feature.setPrettyPrint(true);
-        swagger2Feature.setTitle("SO Request Adapter");
-        swagger2Feature.setContact("The ONAP SO team");
-        swagger2Feature.setDescription("This project is the SO Orchestration Engine");
-        swagger2Feature.setVersion("1.0.0");
-        swagger2Feature.setResourcePackage("org.onap.so.adapters.requestdb");
-        swagger2Feature.setScan(true);
-        return swagger2Feature;
+    public OpenApiFeature createSwaggerFeature() {
+        OpenApiFeature openApiFeature = new OpenApiFeature();
+        openApiFeature.setPrettyPrint(true);
+        openApiFeature.setTitle("SO Request Adapter");
+        openApiFeature.setContactName("The ONAP SO team");
+        openApiFeature.setDescription("This project is the SO Orchestration Engine");
+        openApiFeature.setVersion("1.0.0");
+        openApiFeature.setResourcePackages(new HashSet<String>(Arrays.asList("org.onap.so.adapters.requestdb")));
+        openApiFeature.setScan(true);
+        return openApiFeature;
     }
 
 }
index 358b14e..62ba731 100644 (file)
   </dependencyManagement>
   <dependencies>
     <dependency>
-      <groupId>io.swagger</groupId>
-      <artifactId>swagger-jersey2-jaxrs</artifactId>
+      <groupId>io.swagger.core.v3</groupId>
+      <artifactId>swagger-jaxrs2</artifactId>
     </dependency>
     <dependency>
       <groupId>org.springframework.boot</groupId>
     </dependency>
     <dependency>
       <groupId>org.apache.cxf</groupId>
-      <artifactId>cxf-rt-rs-service-description-swagger</artifactId>
+      <artifactId>cxf-rt-rs-service-description-openapi-v3</artifactId>
     </dependency>
     <dependency>
       <groupId>org.springframework.boot</groupId>
index dd1da98..65eb39d 100644 (file)
 package org.onap.so.adapters.sdnc;
 
 import java.util.Arrays;
+import java.util.HashSet;
 import javax.xml.ws.Endpoint;
 import org.apache.cxf.Bus;
 import org.apache.cxf.endpoint.Server;
 import org.apache.cxf.feature.LoggingFeature;
 import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
-import org.apache.cxf.jaxrs.swagger.Swagger2Feature;
+import org.apache.cxf.jaxrs.openapi.OpenApiFeature;
 import org.apache.cxf.jaxws.EndpointImpl;
 import org.apache.cxf.transport.servlet.CXFServlet;
 import org.onap.so.adapters.sdnc.sdncrest.SNIROResponse;
@@ -91,16 +92,15 @@ public class CXFConfiguration {
 
 
     @Bean
-    public Swagger2Feature createSwaggerFeature() {
-        Swagger2Feature swagger2Feature = new Swagger2Feature();
-        swagger2Feature.setBasePath("/services/rest");
-        swagger2Feature.setPrettyPrint(true);
-        swagger2Feature.setTitle("SO Orchestration Application");
-        swagger2Feature.setContact("The ONAP SO team");
-        swagger2Feature.setDescription("This project is the SO Orchestration Engine");
-        swagger2Feature.setVersion("1.0.0");
-        swagger2Feature.setResourcePackage("org.onap.so.adapters.sdnc");
-        swagger2Feature.setScan(true);
-        return swagger2Feature;
+    public OpenApiFeature createSwaggerFeature() {
+        OpenApiFeature openApiFeature = new OpenApiFeature();
+        openApiFeature.setPrettyPrint(true);
+        openApiFeature.setTitle("SO Orchestration Application");
+        openApiFeature.setContactName("The ONAP SO team");
+        openApiFeature.setDescription("This project is the SO Orchestration Engine");
+        openApiFeature.setVersion("1.0.0");
+        openApiFeature.setResourcePackages(new HashSet<String>(Arrays.asList("org.onap.so.adapters.sdnc")));
+        openApiFeature.setScan(true);
+        return openApiFeature;
     }
 }
index 4d17f55..0eef01d 100644 (file)
   </build>
   <dependencies>
     <dependency>
-      <groupId>io.swagger</groupId>
-      <artifactId>swagger-jersey2-jaxrs</artifactId>
+      <groupId>io.swagger.core.v3</groupId>
+      <artifactId>swagger-jaxrs2</artifactId>
     </dependency>
     <dependency>
       <groupId>org.springframework.boot</groupId>
index 22265a0..9929262 100644 (file)
 
 package org.onap.so.asdc;
 
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
 import javax.annotation.PostConstruct;
 import javax.ws.rs.ApplicationPath;
 import org.glassfish.jersey.server.ResourceConfig;
 import org.onap.so.asdc.client.test.rest.ASDCRestInterface;
-import org.springframework.beans.factory.annotation.Autowired;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.context.annotation.Configuration;
-import org.springframework.core.env.Environment;
-import io.swagger.jaxrs.config.BeanConfig;
-import io.swagger.jaxrs.listing.ApiListingResource;
-import io.swagger.jaxrs.listing.SwaggerSerializers;
+import io.swagger.v3.jaxrs2.SwaggerSerializers;
+import io.swagger.v3.jaxrs2.integration.JaxrsOpenApiContextBuilder;
+import io.swagger.v3.jaxrs2.integration.resources.OpenApiResource;
+import io.swagger.v3.oas.integration.OpenApiConfigurationException;
+import io.swagger.v3.oas.integration.SwaggerConfiguration;
+import io.swagger.v3.oas.models.OpenAPI;
+import io.swagger.v3.oas.models.info.Info;
 
 @Configuration
 @ApplicationPath("/test")
 public class JerseyConfiguration extends ResourceConfig {
 
-    private Environment environment;
-
-    @Autowired
-    public JerseyConfiguration(final Environment environment) {
-        this.environment = environment;
-    }
+    private static final Logger logger = LoggerFactory.getLogger(JerseyConfiguration.class);
 
     @PostConstruct
     public void setUp() {
         register(ASDCRestInterface.class);
-        register(ApiListingResource.class);
+        register(OpenApiResource.class);
         register(SwaggerSerializers.class);
 
-        final BeanConfig beanConfig = new BeanConfig();
-        beanConfig.setVersion("1.0.2");
-        beanConfig.setSchemes(new String[] {"http"});
-        beanConfig.setHost("localhost:" + environment.getProperty("server.port"));
-        beanConfig.setBasePath("/mso");
-        beanConfig.setResourcePackage("org.onap.so.apihandlerinfra");
-        beanConfig.setPrettyPrint(true);
-        beanConfig.setScan(true);
+        final OpenAPI openApi = new OpenAPI();
+        Info info = new Info();
+        info.setVersion("1.0.2");
+        info.setTitle("Swagger asdc-controller code");
+        openApi.setInfo(info);
+
+        SwaggerConfiguration swaggerConfig = new SwaggerConfiguration().openAPI(openApi).prettyPrint(true)
+                .resourcePackages(Stream.of("org.onap.so.asdc").collect(Collectors.toSet()));
+
+        try {
+            JaxrsOpenApiContextBuilder jaxrsConfig = new JaxrsOpenApiContextBuilder();
+            jaxrsConfig.application(this).openApiConfiguration(swaggerConfig).buildContext(true);
+        } catch (OpenApiConfigurationException e) {
+            logger.error("Error during jersey configuration", e);
+            throw new RuntimeException(e.getMessage(), e);
+        }
+
     }
 }
index 276b6f0..59decb5 100644 (file)
@@ -669,6 +669,7 @@ class DoAllocateNSIandNSSI extends AbstractServiceTaskProcessor{
         NssmfAdapterNBIRequest nbiRequest = new NssmfAdapterNBIRequest()
 
         AllocateTnNssi allocateTnNssi = new AllocateTnNssi()
+        allocateTnNssi.setNssiId(sliceTaskInfo.suggestNssiId)
         //todo: AllocateTnNssi
         //todo: endPointId -> set into tn
         List<TransportSliceNetwork> transportSliceNetworks = new ArrayList<>()
index 9f78182..d094424 100644 (file)
     <dependency>
       <groupId>org.apache.cxf</groupId>
       <artifactId>cxf-rt-rs-service-description-openapi-v3</artifactId>
-      <version>3.4.2</version>
     </dependency>
     <dependency>
       <groupId>com.h2database</groupId>
index 786ee1e..f93492b 100644 (file)
@@ -116,6 +116,8 @@ public class CreateVcpeResCustServiceSimplifiedTest extends BaseBPMNTest {
         mockAai();
         mockDmaapForPnf();
 
+        grpcNettyServer.resetList();
+
         final String msoRequestId = UUID.randomUUID().toString();
         executionVariables.put("mso-request-id", msoRequestId);
 
index 1c00f36..35853a3 100644 (file)
@@ -107,6 +107,8 @@ public class GenericPnfSoftwareUpgradeTest extends BaseBPMNTest {
         mockRequestDb();
         mockAai();
 
+        grpcNettyServer.resetList();
+
         final String msoRequestId = UUID.randomUUID().toString();
         executionVariables.put(ExecutionVariableNames.MSO_REQUEST_ID, msoRequestId);
 
@@ -146,7 +148,6 @@ public class GenericPnfSoftwareUpgradeTest extends BaseBPMNTest {
             fail("GenericPnfSoftwareUpgrade request exception", e);
         }
         assertTrue(count == actionNames.length);
-        grpcNettyServer.resetList();
     }
 
     private boolean isProcessInstanceEnded() {
index 881cb30..9f7d095 100644 (file)
               <pluginExecutions>
                 <pluginExecution>
                   <pluginExecutionFilter>
-                    <groupId>io.swagger</groupId>
+                    <groupId>io.swagger.codegen.v3</groupId>
                     <artifactId>swagger-codegen-maven-plugin</artifactId>
                     <goals>
                       <goal>generate</goal>
index 6c6bd61..3a7dd57 100644 (file)
@@ -44,6 +44,7 @@ import org.slf4j.LoggerFactory;
 import org.springframework.stereotype.Component;
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
 import java.util.Map;
 import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.CREATE_INSTANCE;
@@ -58,6 +59,9 @@ public class UserParamsServiceTraversal {
 
     private final CatalogDbClient catalogDbClient;
     private final ExceptionBuilder exceptionBuilder;
+    private boolean foundVfModuleOrVG;
+    private String vnfCustomizationUUID;
+    private String vfModuleCustomizationUUID;
 
     UserParamsServiceTraversal(CatalogDbClient catalogDbClient, ExceptionBuilder exceptionBuilder) {
         this.catalogDbClient = catalogDbClient;
@@ -67,131 +71,170 @@ public class UserParamsServiceTraversal {
     protected List<Resource> getResourceListFromUserParams(DelegateExecution execution,
             List<Map<String, Object>> userParams, String serviceModelVersionId, String requestAction)
             throws IOException {
-        List<Resource> resourceList = new ArrayList<>();
-        boolean foundVfModuleOrVG = false;
-        String vnfCustomizationUUID = "";
-        String vfModuleCustomizationUUID = "";
         if (userParams != null) {
             for (Map<String, Object> params : userParams) {
                 if (params.containsKey(USER_PARAM_SERVICE)) {
                     ObjectMapper obj = new ObjectMapper();
                     String input = obj.writeValueAsString(params.get(USER_PARAM_SERVICE));
                     Service validate = obj.readValue(input, Service.class);
-                    resourceList.add(
-                            new Resource(WorkflowType.SERVICE, validate.getModelInfo().getModelVersionId(), false));
-                    if (validate.getResources().getVnfs() != null) {
-                        for (Vnfs vnf : validate.getResources().getVnfs()) {
-                            resourceList.add(new Resource(WorkflowType.VNF,
-                                    vnf.getModelInfo().getModelCustomizationId(), false));
-                            if (vnf.getModelInfo() != null && vnf.getModelInfo().getModelCustomizationUuid() != null) {
-                                vnfCustomizationUUID = vnf.getModelInfo().getModelCustomizationUuid();
-                            }
-                            if (vnf.getVfModules() != null) {
-                                for (VfModules vfModule : vnf.getVfModules()) {
-                                    VfModuleCustomization vfModuleCustomization =
-                                            catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID(
-                                                    vfModule.getModelInfo().getModelCustomizationUuid());
-                                    if (vfModuleCustomization != null) {
-
-                                        if (vfModuleCustomization.getVfModule() != null
-                                                && vfModuleCustomization.getVfModule().getVolumeHeatTemplate() != null
-                                                && vfModuleCustomization.getVolumeHeatEnv() != null) {
-                                            resourceList.add(new Resource(WorkflowType.VOLUMEGROUP,
-                                                    vfModuleCustomization.getModelCustomizationUUID(), false));
-                                            foundVfModuleOrVG = true;
-                                        }
-
-                                        if ((vfModuleCustomization.getVfModule() != null)
-                                                && ((vfModuleCustomization.getVfModule().getModuleHeatTemplate() != null
-                                                        && vfModuleCustomization.getHeatEnvironment() != null))
-                                                || (vfModuleCustomization.getVfModule() != null
-                                                        && vfModuleCustomization.getVfModule().getModelName() != null
-                                                        && vfModuleCustomization.getVfModule().getModelName()
-                                                                .contains("helm"))) {
-                                            foundVfModuleOrVG = true;
-                                            Resource resource = new Resource(WorkflowType.VFMODULE,
-                                                    vfModuleCustomization.getModelCustomizationUUID(), false);
-                                            resource.setBaseVfModule(
-                                                    vfModuleCustomization.getVfModule().getIsBase() != null
-                                                            && vfModuleCustomization.getVfModule().getIsBase());
-                                            resourceList.add(resource);
-                                            if (vfModule.getModelInfo() != null
-                                                    && vfModule.getModelInfo().getModelCustomizationUuid() != null) {
-                                                vfModuleCustomizationUUID =
-                                                        vfModule.getModelInfo().getModelCustomizationUuid();
-                                            }
-                                            if (!vnfCustomizationUUID.isEmpty()
-                                                    && !vfModuleCustomizationUUID.isEmpty()) {
-                                                List<CvnfcConfigurationCustomization> configs =
-                                                        traverseCatalogDbForConfiguration(
-                                                                validate.getModelInfo().getModelVersionId(),
-                                                                vnfCustomizationUUID, vfModuleCustomizationUUID);
-                                                for (CvnfcConfigurationCustomization config : configs) {
-                                                    Resource configResource = new Resource(WorkflowType.CONFIGURATION,
-                                                            config.getConfigurationResource().getModelUUID(), false);
-                                                    resource.setVnfCustomizationId(
-                                                            vnf.getModelInfo().getModelCustomizationId());
-                                                    resource.setVfModuleCustomizationId(
-                                                            vfModule.getModelInfo().getModelCustomizationId());
-                                                    resourceList.add(configResource);
-                                                }
-                                            }
-                                        }
-                                        if (!foundVfModuleOrVG) {
-                                            buildAndThrowException(execution,
-                                                    "Could not determine if vfModule was a vfModule or volume group. Heat template and Heat env are null");
-                                        }
-                                    }
-                                }
-                            }
-                        }
-                    }
-                    if (validate.getResources().getPnfs() != null) {
-                        for (Pnfs pnf : validate.getResources().getPnfs()) {
-                            resourceList.add(new Resource(WorkflowType.PNF,
-                                    pnf.getModelInfo().getModelCustomizationId(), false));
-                        }
-                    }
-                    if (validate.getResources().getNetworks() != null) {
-                        for (Networks network : validate.getResources().getNetworks()) {
-                            resourceList.add(new Resource(WorkflowType.NETWORK,
-                                    network.getModelInfo().getModelCustomizationId(), false));
-                        }
-                        if (requestAction.equals(CREATE_INSTANCE)) {
-                            String networkColCustId =
-                                    queryCatalogDbForNetworkCollection(execution, serviceModelVersionId);
-                            if (networkColCustId != null) {
-                                resourceList.add(new Resource(WorkflowType.NETWORKCOLLECTION, networkColCustId, false));
-                            }
-                        }
-                    }
-                    break;
+                    return getResourceList(execution, serviceModelVersionId, requestAction, validate);
                 }
             }
         }
+        return Collections.emptyList();
+    }
+
+    private List<Resource> getResourceList(DelegateExecution execution, String serviceModelVersionId,
+            String requestAction, Service validate) {
+        List<Resource> resourceList = new ArrayList<>();
+        resourceList.add(new Resource(WorkflowType.SERVICE, validate.getModelInfo().getModelVersionId(), false));
+        if (validate.getResources().getVnfs() != null) {
+            setResourceListForVnfs(execution, resourceList, validate);
+        }
+        if (validate.getResources().getPnfs() != null) {
+            setResourceListForPnfs(resourceList, validate);
+        }
+        if (validate.getResources().getNetworks() != null) {
+            setResourceListForNetworks(execution, serviceModelVersionId, requestAction, resourceList, validate);
+        }
         return resourceList;
     }
 
+    private void setResourceListForVnfs(DelegateExecution execution, List<Resource> resourceList, Service validate) {
+        for (Vnfs vnf : validate.getResources().getVnfs()) {
+            setVnfCustomizationUUID(vnf);
+            resourceList.add(new Resource(WorkflowType.VNF, vnf.getModelInfo().getModelCustomizationId(), false));
+            setResourceListForVfModules(execution, resourceList, validate, vnf);
+        }
+    }
 
-    private List<CvnfcConfigurationCustomization> traverseCatalogDbForConfiguration(String serviceModelUUID,
-            String vnfCustomizationUUID, String vfModuleCustomizationUUID) {
-        List<CvnfcConfigurationCustomization> configurations = new ArrayList<>();
-        try {
-            List<CvnfcCustomization> cvnfcCustomizations = catalogDbClient.getCvnfcCustomization(serviceModelUUID,
-                    vnfCustomizationUUID, vfModuleCustomizationUUID);
-            for (CvnfcCustomization cvnfc : cvnfcCustomizations) {
-                for (CvnfcConfigurationCustomization customization : cvnfc.getCvnfcConfigurationCustomization()) {
-                    if (customization.getConfigurationResource().getToscaNodeType().contains(FABRIC_CONFIGURATION)) {
-                        configurations.add(customization);
+    private void setResourceListForVfModules(DelegateExecution execution, List<Resource> resourceList, Service validate,
+            Vnfs vnf) {
+        if (vnf.getVfModules() != null) {
+            for (VfModules vfModule : vnf.getVfModules()) {
+                setVfModuleCustomizationUUID(vfModule);
+                VfModuleCustomization vfModuleCustomization =
+                        catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID(vfModuleCustomizationUUID);
+                if (vfModuleCustomization != null && vfModuleCustomization.getVfModule() != null) {
+                    setVolumeGroupWorkFlowTypeToResourceList(resourceList, vfModuleCustomization);
+                    setVfModuleAndConfigurationWorkFlowTypeToResourceList(resourceList, validate, vnf, vfModule,
+                            vfModuleCustomization);
+                    if (!foundVfModuleOrVG) {
+                        buildAndThrowException(execution,
+                                "Could not determine if vfModule was a vfModule or volume group. Heat template and Heat env are null");
                     }
                 }
             }
-            logger.debug("found {} fabric configuration(s)", configurations.size());
-            return configurations;
+        }
+    }
+
+    private void setVolumeGroupWorkFlowTypeToResourceList(List<Resource> resourceList,
+            VfModuleCustomization vfModuleCustomization) {
+        if (vfModuleCustomization.getVfModule().getVolumeHeatTemplate() != null
+                && vfModuleCustomization.getVolumeHeatEnv() != null) {
+            foundVfModuleOrVG = true;
+            resourceList.add(
+                    new Resource(WorkflowType.VOLUMEGROUP, vfModuleCustomization.getModelCustomizationUUID(), false));
+        }
+    }
+
+    private void setVfModuleAndConfigurationWorkFlowTypeToResourceList(List<Resource> resourceList, Service validate,
+            Vnfs vnf, VfModules vfModule, VfModuleCustomization vfModuleCustomization) {
+        if ((vfModuleCustomization.getVfModule().getModuleHeatTemplate() != null
+                && vfModuleCustomization.getHeatEnvironment() != null)
+                || (vfModuleCustomization.getVfModule().getModelName() != null
+                        && vfModuleCustomization.getVfModule().getModelName().contains("helm"))) {
+            foundVfModuleOrVG = true;
+            Resource resource = setVfModuleWorkFlowTypeToResourceList(resourceList, vfModuleCustomization);
+            setConfigurationWorkFlowTypeToResourceList(resourceList, validate, vnf, vfModule, resource);
+        }
+    }
+
+    private Resource setVfModuleWorkFlowTypeToResourceList(List<Resource> resourceList,
+            VfModuleCustomization vfModuleCustomization) {
+        Resource resource =
+                new Resource(WorkflowType.VFMODULE, vfModuleCustomization.getModelCustomizationUUID(), false);
+        resource.setBaseVfModule(vfModuleCustomization.getVfModule().getIsBase() != null
+                && vfModuleCustomization.getVfModule().getIsBase());
+        resourceList.add(resource);
+        return resource;
+    }
+
+    private void setConfigurationWorkFlowTypeToResourceList(List<Resource> resourceList, Service validate, Vnfs vnf,
+            VfModules vfModule, Resource resource) {
+        if (!vnfCustomizationUUID.isEmpty() && !vfModuleCustomizationUUID.isEmpty()) {
+            List<CvnfcConfigurationCustomization> configs =
+                    traverseCatalogDbForConfiguration(validate.getModelInfo().getModelVersionId());
+            for (CvnfcConfigurationCustomization config : configs) {
+                Resource configResource = new Resource(WorkflowType.CONFIGURATION,
+                        config.getConfigurationResource().getModelUUID(), false);
+                resource.setVnfCustomizationId(vnf.getModelInfo().getModelCustomizationId());
+                resource.setVfModuleCustomizationId(vfModule.getModelInfo().getModelCustomizationId());
+                resourceList.add(configResource);
+            }
+        }
+    }
+
+    private void setVfModuleCustomizationUUID(VfModules vfModule) {
+        if (vfModule.getModelInfo() != null && vfModule.getModelInfo().getModelCustomizationUuid() != null) {
+            vfModuleCustomizationUUID = vfModule.getModelInfo().getModelCustomizationUuid();
+        } else {
+            vfModuleCustomizationUUID = "";
+        }
+    }
+
+    private void setVnfCustomizationUUID(Vnfs vnf) {
+        if (vnf.getModelInfo() != null && vnf.getModelInfo().getModelCustomizationUuid() != null) {
+            vnfCustomizationUUID = vnf.getModelInfo().getModelCustomizationUuid();
+        } else {
+            vnfCustomizationUUID = "";
+        }
+    }
+
+    private void setResourceListForPnfs(List<Resource> resourceList, Service validate) {
+        for (Pnfs pnf : validate.getResources().getPnfs()) {
+            resourceList.add(new Resource(WorkflowType.PNF, pnf.getModelInfo().getModelCustomizationId(), false));
+        }
+    }
+
+    private void setResourceListForNetworks(DelegateExecution execution, String serviceModelVersionId,
+            String requestAction, List<Resource> resourceList, Service validate) {
+        for (Networks network : validate.getResources().getNetworks()) {
+            resourceList
+                    .add(new Resource(WorkflowType.NETWORK, network.getModelInfo().getModelCustomizationId(), false));
+        }
+        if (requestAction.equals(CREATE_INSTANCE)) {
+            String networkColCustId = queryCatalogDbForNetworkCollection(execution, serviceModelVersionId);
+            if (networkColCustId != null) {
+                resourceList.add(new Resource(WorkflowType.NETWORKCOLLECTION, networkColCustId, false));
+            }
+        }
+    }
+
+
+    private List<CvnfcConfigurationCustomization> traverseCatalogDbForConfiguration(String serviceModelUUID) {
+        try {
+            List<CvnfcCustomization> cvnfcCustomizations = catalogDbClient.getCvnfcCustomization(serviceModelUUID,
+                    vnfCustomizationUUID, vfModuleCustomizationUUID);
+            return getCvnfcConfigurationCustomizations(cvnfcCustomizations);
         } catch (Exception ex) {
             logger.error("Error in finding configurations", ex);
-            return configurations;
+            return Collections.emptyList();
+        }
+    }
+
+    private List<CvnfcConfigurationCustomization> getCvnfcConfigurationCustomizations(
+            List<CvnfcCustomization> cvnfcCustomizations) {
+        List<CvnfcConfigurationCustomization> configurations = new ArrayList<>();
+        for (CvnfcCustomization cvnfc : cvnfcCustomizations) {
+            for (CvnfcConfigurationCustomization customization : cvnfc.getCvnfcConfigurationCustomization()) {
+                if (customization.getConfigurationResource().getToscaNodeType().contains(FABRIC_CONFIGURATION)) {
+                    configurations.add(customization);
+                }
+            }
         }
+        logger.debug("found {} fabric configuration(s)", configurations.size());
+        return configurations;
     }
 
     private String queryCatalogDbForNetworkCollection(DelegateExecution execution, String serviceModelVersionId) {
@@ -216,9 +259,7 @@ public class UserParamsServiceTraversal {
                 count++;
             }
         }
-        if (count == 0) {
-            return null;
-        } else if (count > 1) {
+        if (count > 1) {
             buildAndThrowException(execution,
                     "Found multiple Network Collections in the Service model, only one per Service is supported.");
         }
index 1b0986c..3d25ef1 100644 (file)
@@ -39,4 +39,6 @@ public class AllocateTnNssi implements Serializable {
     private NsiInfo nsiInfo;
 
     private String scriptName;
+
+    private String nssiId;
 }
diff --git a/common/src/main/java/org/onap/so/logger/MaskLogStatements.java b/common/src/main/java/org/onap/so/logger/MaskLogStatements.java
new file mode 100644 (file)
index 0000000..cadadcf
--- /dev/null
@@ -0,0 +1,71 @@
+package org.onap.so.logger;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+import java.util.Optional;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import ch.qos.logback.classic.PatternLayout;
+import ch.qos.logback.classic.spi.ILoggingEvent;
+
+public class MaskLogStatements extends PatternLayout {
+
+    private String patternsProperty;
+    private String maskChar = "*";
+    private Optional<Pattern> pattern = Optional.empty();
+    private static final Pattern authPattern =
+            Pattern.compile("Authorization(?:\\:|=)\\s?(?:\"|\\[)(?:Basic|Bearer) (.*?)(?:\"|\\])");
+    private static final Pattern openstackPattern = Pattern.compile("\"password\"\\s?:\\s?\"(.*?)\"");
+
+    public String getPatternsProperty() {
+        return patternsProperty;
+    }
+
+    public void setPatternsProperty(String patternsProperty) {
+        this.patternsProperty = patternsProperty;
+        if (this.patternsProperty != null) {
+            this.pattern = Optional.of(Pattern.compile(patternsProperty, Pattern.MULTILINE));
+        }
+    }
+
+    public String getMaskChar() {
+        return maskChar;
+    }
+
+    public void setMaskChar(String maskChar) {
+        this.maskChar = maskChar;
+    }
+
+
+    protected Collection<Pattern> getPatterns() {
+        return Arrays.asList(authPattern, openstackPattern);
+    }
+
+    @Override
+    public String doLayout(ILoggingEvent event) {
+
+        final StringBuilder message = new StringBuilder(super.doLayout(event));
+        List<Pattern> patterns = new ArrayList<>(getPatterns());
+        if (pattern.isPresent()) {
+            patterns.add(pattern.get());
+        }
+        patterns.forEach(p -> {
+            Matcher matcher = p.matcher(message);
+            while (matcher.find()) {
+                int group = 1;
+                while (group <= matcher.groupCount()) {
+                    if (matcher.group(group) != null) {
+                        for (int i = matcher.start(group); i < matcher.end(group); i++) {
+                            message.setCharAt(i, maskChar.charAt(0));
+                        }
+                    }
+                    group++;
+                }
+            }
+        });
+        return message.toString();
+    }
+
+}
diff --git a/common/src/test/java/org/onap/so/logging/MaskLogStatementsTest.java b/common/src/test/java/org/onap/so/logging/MaskLogStatementsTest.java
new file mode 100644 (file)
index 0000000..ba5aeb5
--- /dev/null
@@ -0,0 +1,90 @@
+package org.onap.so.logging;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import org.junit.Test;
+import org.onap.so.logger.MaskLogStatements;
+import ch.qos.logback.classic.Level;
+import ch.qos.logback.classic.Logger;
+import ch.qos.logback.classic.LoggerContext;
+import ch.qos.logback.classic.spi.ILoggingEvent;
+import ch.qos.logback.classic.spi.LoggingEvent;
+
+public class MaskLogStatementsTest {
+
+    private LoggerContext lc = new LoggerContext();
+    private Logger logger = lc.getLogger(MaskLogStatementsTest.class);
+
+    @Test
+    public void verifyOpenStackPayload() throws IOException {
+        String payload =
+                new String(Files.readAllBytes(Paths.get("src/test/resources/__files/logging/openstack-payload.json")));
+
+        ILoggingEvent event = makeLoggingEvent(payload);
+
+        MaskLogStatements mask = new MaskLogStatements();
+
+        mask.setContext(lc);
+        mask.setPattern("%m");
+        mask.start();
+        String result = mask.doLayout(event);
+
+        assertTrue(result.matches("(?s).*?\"password\"\\s?:\\s?\"\\*+\".*"));
+
+    }
+
+    @Test
+    public void maskAuthHeaderTest() {
+        String msg = "Headers     : [Accept:\"application/json\", Authorization:\"Basic dklfjeaklfjdkalf\","
+                + "Content-Type:\"application/json\", Content-Length:\"10\","
+                + "X-RequestID:\"db2a0462-69d0-499f-93ec-e2a064ef1f59\", X-TransactionID:\"db2a0462-69d0-499f-93ec-e2a064ef1f59\","
+                + "X-ECOMP-RequestID:\"db2a0462-69d0-499f-93ec-e2a064ef1f59\", X-ONAP-PartnerName:\"SO.APIH\","
+                + "X-InvocationID:\"885e4f99-6f24-4f17-ab1b-584b37715b49\"]";
+
+        String expected = "Headers     : [Accept:\"application/json\", Authorization:\"Basic ****************\","
+                + "Content-Type:\"application/json\", Content-Length:\"10\","
+                + "X-RequestID:\"db2a0462-69d0-499f-93ec-e2a064ef1f59\", X-TransactionID:\"db2a0462-69d0-499f-93ec-e2a064ef1f59\","
+                + "X-ECOMP-RequestID:\"db2a0462-69d0-499f-93ec-e2a064ef1f59\", X-ONAP-PartnerName:\"SO.APIH\","
+                + "X-InvocationID:\"885e4f99-6f24-4f17-ab1b-584b37715b49\"]";
+        ILoggingEvent event = makeLoggingEvent(msg);
+
+        MaskLogStatements mask = new MaskLogStatements();
+
+        mask.setContext(lc);
+        mask.setPattern("%m");
+        mask.start();
+        String result = mask.doLayout(event);
+
+        assertEquals(expected, result);
+    }
+
+    @Test
+    public void maskAuthHeaderObjectStringTest() {
+        String msg = "Headers: {Accept=[text/plain, application/json, application/*+json, */*],"
+                + "Authorization=[Basic aaaaa],"
+                + "connection=[keep-alive], Content-Length=[217], content-type=[application/xml],"
+                + "host=[mso-bpmn-infra-svc:9200], user-agent=[Java/11.0.6]}";
+        String expected = "Headers: {Accept=[text/plain, application/json, application/*+json, */*],"
+                + "Authorization=[Basic -----],"
+                + "connection=[keep-alive], Content-Length=[217], content-type=[application/xml],"
+                + "host=[mso-bpmn-infra-svc:9200], user-agent=[Java/11.0.6]}";
+        ILoggingEvent event = makeLoggingEvent(msg);
+
+        MaskLogStatements mask = new MaskLogStatements();
+
+        mask.setContext(lc);
+        mask.setPattern("%m");
+        mask.setMaskChar("-");
+        mask.start();
+        String result = mask.doLayout(event);
+
+        assertEquals(expected, result);
+    }
+
+    private ILoggingEvent makeLoggingEvent(String message) {
+        return new LoggingEvent(MaskLogStatementsTest.class.getName(), logger, Level.INFO, message, null, null);
+    }
+}
diff --git a/common/src/test/resources/__files/logging/openstack-payload.json b/common/src/test/resources/__files/logging/openstack-payload.json
new file mode 100644 (file)
index 0000000..ac4d163
--- /dev/null
@@ -0,0 +1,26 @@
+{
+    "auth": {
+        "identity": {
+            "password": {
+                "user": {
+                    "name": "j0000",
+                    "domain": {
+                        "name": "name"
+                    },
+                    "password": "my-password-wow"
+                }
+            },
+            "methods": [
+                "password"
+            ]
+        },
+        "scope": {
+            "project": {
+                "id": "ad299b37da30413391e9c28138f0b0dd",
+                "domain": {
+                    "name": "name"
+                }
+            }
+        }
+    }
+}
index 6b3fd0f..bcc04ef 100644 (file)
@@ -68,9 +68,9 @@
       <version>2.2.1</version>
     </dependency>
     <dependency>
-      <groupId>io.swagger</groupId>
+      <groupId>io.swagger.parser.v3</groupId>
       <artifactId>swagger-parser</artifactId>
-      <version>1.0.50</version>
+      <version>2.0.24</version>
     </dependency>
     <dependency>
       <groupId>com.squareup</groupId>
diff --git a/pom.xml b/pom.xml
index 407d692..198ffbb 100644 (file)
--- a/pom.xml
+++ b/pom.xml
           </exclusion>
         </exclusions>
       </dependency>
-      <dependency>
-        <groupId>org.apache.cxf</groupId>
-        <artifactId>cxf-rt-rs-service-description-swagger</artifactId>
-        <version>${cxf.version}</version>
-        <exclusions>
-          <exclusion>
-            <groupId>org.jboss.spec.javax.rmi</groupId>
-            <artifactId>jboss-rmi-api_1.0_spec</artifactId>
-          </exclusion>
-        </exclusions>
-      </dependency>
       <dependency>
         <groupId>org.apache.cxf</groupId>
         <artifactId>cxf-rt-rs-service-description-openapi-v3</artifactId>
         <artifactId>aaf-misc-rosetta</artifactId>
         <version>${aaf.version}</version>
         <scope>runtime</scope>
-      </dependency>
-         <dependency>
-       <groupId>io.swagger</groupId>
-       <artifactId>swagger-jersey2-jaxrs</artifactId>
-       <version>1.6.2</version>
       </dependency>
       <dependency>
        <groupId>ch.vorburger.mariaDB4j</groupId>