Merge "License scan fix Issue-ID: SO-2519"
authorByung-Woo Jun <byung-woo.jun@est.tech>
Fri, 21 Feb 2020 13:54:25 +0000 (13:54 +0000)
committerGerrit Code Review <gerrit@onap.org>
Fri, 21 Feb 2020 13:54:25 +0000 (13:54 +0000)
22 files changed:
adapters/mso-requests-db-adapter/src/main/resources/db/migration/V7.2__Add_PNF_Column_Infra_Requests_archive_tables.sql
asdc-controller/src/main/java/org/onap/so/asdc/activity/ActivitySpecsActions.java
asdc-controller/src/main/java/org/onap/so/asdc/activity/DeployActivitySpecs.java
asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java
bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipCDSBuildingBlockListener.java [new file with mode: 0644]
bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipCDSBuildingBlockListenerTest.java [new file with mode: 0644]
common/src/main/java/org/onap/so/serviceinstancebeans/ServiceInstancesRequest.java
mso-api-handlers/mso-api-handler-infra/pom.xml
mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/CamundaRequestHandler.java
mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/InstanceManagement.java
mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/JerseyConfiguration.java
mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java
mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationTasks.java
mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java
mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/CustomWorkflowValidation.java
mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/InstanceManagementTest.java
mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/ExecutePNFCustomWorkflow.json
mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql
mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepositoryImpl.java
mso-api-handlers/mso-requests-db-repositories/src/test/resources/schema.sql
mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/InfraActiveRequests.java
mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/InfraRequests.java

index dbdc925..8c042dc 100644 (file)
@@ -1,4 +1,4 @@
 use requestdb;
 
-ALTER TABLE infra_active_requests ADD COLUMN IF NOT EXISTS PNF_ID varchar(45);
-ALTER TABLE archived_infra_requests ADD COLUMN IF NOT EXISTS PNF_ID varchar(45);
\ No newline at end of file
+ALTER TABLE infra_active_requests ADD COLUMN IF NOT EXISTS PNF_NAME varchar(45);
+ALTER TABLE archived_infra_requests ADD COLUMN IF NOT EXISTS PNF_NAME varchar(45);
index 06887f1..a48e177 100644 (file)
@@ -4,12 +4,15 @@
  * ================================================================================
  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
+ * Modifications Copyright (c) 2020 Nokia
+ * ================================================================================
+ *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -29,7 +32,6 @@ import org.onap.so.asdc.activity.beans.ActivitySpec;
 import org.onap.so.asdc.activity.beans.ActivitySpecCreateResponse;
 import org.onap.so.client.HttpClient;
 import org.onap.so.client.HttpClientFactory;
-import org.onap.so.logger.LoggingAnchor;
 import org.onap.logging.filter.base.ONAPComponents;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -53,8 +55,6 @@ public class ActivitySpecsActions {
             return null;
         }
 
-        String activitySpecId = null;
-
         try {
             ObjectMapper mapper = new ObjectMapper();
             mapper.setSerializationInclusion(Include.NON_NULL);
@@ -71,30 +71,34 @@ public class ActivitySpecsActions {
             int statusCode = response.getStatus();
             if (statusCode == HttpStatus.SC_UNPROCESSABLE_ENTITY) {
                 logger.warn(LoggingAnchor.THREE, "ActivitySpec", activitySpec.getName(), "already exists in SDC");
-            } else if (statusCode != HttpStatus.SC_OK && statusCode != HttpStatus.SC_CREATED) {
+                return null;
+            }
+            if (statusCode != HttpStatus.SC_OK && statusCode != HttpStatus.SC_CREATED) {
                 logger.warn(LoggingAnchor.THREE, "Error creating activity spec", activitySpec.getName(), statusCode);
-            } else {
-                if (response.getEntity() != null) {
-                    ActivitySpecCreateResponse activitySpecCreateResponse =
-                            response.readEntity(ActivitySpecCreateResponse.class);
-                    if (activitySpecCreateResponse != null) {
-                        activitySpecId = activitySpecCreateResponse.getId();
-                    } else {
-                        logger.warn(LoggingAnchor.TWO, "Unable to read activity spec", activitySpec.getName());
-                    }
-                } else {
-                    logger.warn(LoggingAnchor.TWO, "No activity spec response returned", activitySpec.getName());
-                }
+                return null;
+            }
+
+            if (response.getEntity() == null) {
+                logger.warn(LoggingAnchor.TWO, "No activity spec response returned", activitySpec.getName());
+                return null;
             }
+            ActivitySpecCreateResponse activitySpecCreateResponse =
+                    response.readEntity(ActivitySpecCreateResponse.class);
+            if (activitySpecCreateResponse == null) {
+                logger.warn(LoggingAnchor.TWO, "Unable to read activity spec", activitySpec.getName());
+                return null;
+            }
+            return activitySpecCreateResponse.getId();
+
+
         } catch (Exception e) {
             logger.warn(LoggingAnchor.TWO, "Exception creating activitySpec", e);
         }
 
-        return activitySpecId;
+        return null;
     }
 
     public boolean certifyActivitySpec(String hostname, String activitySpecId) {
-        boolean certificationResult = false;
         if (activitySpecId == null) {
             return false;
         }
@@ -114,16 +118,19 @@ public class ActivitySpecsActions {
 
             if (statusCode == HttpStatus.SC_UNPROCESSABLE_ENTITY) {
                 logger.warn(LoggingAnchor.THREE, "ActivitySpec with id", activitySpecId, "is already certified in SDC");
-            } else if (statusCode != HttpStatus.SC_OK) {
+                return false;
+            }
+            if (statusCode != HttpStatus.SC_OK) {
                 logger.warn(LoggingAnchor.THREE, "Error certifying activity", activitySpecId, statusCode);
-            } else {
-                certificationResult = true;
+                return false;
             }
 
+            return true;
+
         } catch (Exception e) {
             logger.warn(LoggingAnchor.TWO, "Exception certifying activitySpec", e);
+            return false;
         }
 
-        return certificationResult;
     }
 }
index e53b792..df8e828 100644 (file)
@@ -4,12 +4,14 @@
  * ================================================================================
  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
+ *  Modifications Copyright (c) 2020 Nokia
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -74,17 +76,19 @@ public class DeployActivitySpecs {
             logger.debug("{} {}", "Attempting to create activity ", activitySpecFromCatalog.getName());
             ActivitySpec activitySpec = mapActivitySpecFromCatalogToSdc(activitySpecFromCatalog);
             String activitySpecId = activitySpecsActions.createActivitySpec(hostname, activitySpec);
-            if (activitySpecId != null) {
-                logger.info(LoggingAnchor.TWO, "Successfully created activitySpec", activitySpec.getName());
-                boolean certificationResult = activitySpecsActions.certifyActivitySpec(hostname, activitySpecId);
-                if (certificationResult) {
-                    logger.info(LoggingAnchor.TWO, "Successfully certified activitySpec", activitySpec.getName());
-                } else {
-                    logger.info(LoggingAnchor.TWO, "Failed to certify activitySpec", activitySpec.getName());
-                }
-            } else {
+            if (activitySpecId == null) {
                 logger.info(LoggingAnchor.TWO, "Failed to create activitySpec", activitySpec.getName());
+                continue;
+            }
+
+            logger.info(LoggingAnchor.TWO, "Successfully created activitySpec", activitySpec.getName());
+            boolean certificationResult = activitySpecsActions.certifyActivitySpec(hostname, activitySpecId);
+            if (!certificationResult) {
+                logger.info(LoggingAnchor.TWO, "Failed to certify activitySpec", activitySpec.getName());
+                continue;
             }
+
+            logger.info(LoggingAnchor.TWO, "Successfully certified activitySpec", activitySpec.getName());
         }
     }
 
@@ -120,46 +124,41 @@ public class DeployActivitySpecs {
         List<Input> inputs = new ArrayList<>();
         List<Output> outputs = new ArrayList<>();
         for (ActivitySpecActivitySpecParameters activitySpecParam : activitySpecActivitySpecParameters) {
-            if (activitySpecParam != null) {
-                if (activitySpecParam.getActivitySpecParameters() != null) {
-                    ActivitySpecParameters activitySpecParameters = activitySpecParam.getActivitySpecParameters();
-                    if (activitySpecParameters != null) {
-                        if (activitySpecParameters.getDirection().equals(DIRECTION_INPUT)) {
-                            Input input = new Input();
-                            input.setName(activitySpecParameters.getName());
-                            input.setType(activitySpecParameters.getType());
-                            inputs.add(input);
-                        } else if (activitySpecParameters.getDirection().equals(DIRECTION_OUTPUT)) {
-                            Output output = new Output();
-                            output.setName(activitySpecParameters.getName());
-                            output.setType(activitySpecParameters.getType());
-                            outputs.add(output);
-                        }
-                    }
-                }
+            if (activitySpecParam == null || activitySpecParam.getActivitySpecParameters() == null) {
+                continue;
+            }
+            ActivitySpecParameters activitySpecParameters = activitySpecParam.getActivitySpecParameters();
+
+            if (activitySpecParameters.getDirection().equals(DIRECTION_INPUT)) {
+                Input input = new Input();
+                input.setName(activitySpecParameters.getName());
+                input.setType(activitySpecParameters.getType());
+                inputs.add(input);
+                continue;
+            }
+            if (activitySpecParameters.getDirection().equals(DIRECTION_OUTPUT)) {
+                Output output = new Output();
+                output.setName(activitySpecParameters.getName());
+                output.setType(activitySpecParameters.getType());
+                outputs.add(output);
             }
         }
         activitySpec.setInputs(inputs);
         activitySpec.setOutputs(outputs);
-        return;
     }
 
     public boolean checkHttpServerUp(String host) {
-        URL url = null;
-        boolean isUp = false;
-
-        int responseCode = 0;
         try {
-            url = new URL(host);
+            URL url = new URL(host);
             HttpURLConnection connection = (HttpURLConnection) url.openConnection();
             connection.setConnectTimeout(5000);
-            responseCode = connection.getResponseCode();
+            int responseCode = connection.getResponseCode();
+            if (responseCode == HttpStatus.SC_OK || responseCode == HttpStatus.SC_NOT_FOUND) {
+                return true;
+            }
         } catch (Exception e) {
             logger.warn("Exception on connecting to SDC WFD endpoint: ", e);
         }
-        if (responseCode == HttpStatus.SC_OK || responseCode == HttpStatus.SC_NOT_FOUND) {
-            isUp = true;
-        }
-        return isUp;
+        return false;
     }
 }
index f64adfd..c9d4f4d 100644 (file)
@@ -7,6 +7,8 @@
  * ================================================================================
  * Modifications Copyright (c) 2019 Samsung
  * ================================================================================
+ * Modifications Copyright (c) 2020 Nokia
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
@@ -33,6 +35,7 @@ import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.UnsupportedEncodingException;
+import java.nio.charset.StandardCharsets;
 import java.nio.file.Paths;
 import java.util.List;
 import java.util.Optional;
@@ -162,12 +165,7 @@ public class ASDCController {
                 break;
 
             case IDLE:
-                if (this.nbOfNotificationsOngoing > 1) {
-                    --this.nbOfNotificationsOngoing;
-                } else {
-                    this.nbOfNotificationsOngoing = 0;
-                    this.controllerStatus = newControllerStatus;
-                }
+                changeOnStatusIDLE(newControllerStatus);
 
                 break;
             default:
@@ -177,6 +175,15 @@ public class ASDCController {
         }
     }
 
+    private void changeOnStatusIDLE(ASDCControllerStatus newControllerStatus) {
+        if (this.nbOfNotificationsOngoing > 1) {
+            --this.nbOfNotificationsOngoing;
+        } else {
+            this.nbOfNotificationsOngoing = 0;
+            this.controllerStatus = newControllerStatus;
+        }
+    }
+
     public ASDCControllerStatus getControllerStatus() {
         return this.controllerStatus;
     }
@@ -296,13 +303,12 @@ public class ASDCController {
     protected void notifyErrorToAsdc(INotificationData iNotif, ToscaResourceStructure toscaResourceStructure,
             DistributionStatusEnum deployStatus, VfResourceStructure resourceStructure, String errorMessage) {
         // do csar lever first
-        this.sendCsarDeployNotification(iNotif, resourceStructure, toscaResourceStructure, deployStatus, errorMessage);
+        this.sendCsarDeployNotification(resourceStructure, toscaResourceStructure, deployStatus, errorMessage);
         // at resource level
         for (IResourceInstance resource : iNotif.getResources()) {
             resourceStructure = new VfResourceStructure(iNotif, resource);
             errorMessage = String.format("Resource with UUID: %s already exists", resource.getResourceUUID());
-            this.sendCsarDeployNotification(iNotif, resourceStructure, toscaResourceStructure, deployStatus,
-                    errorMessage);
+            this.sendCsarDeployNotification(resourceStructure, toscaResourceStructure, deployStatus, errorMessage);
         }
     }
 
@@ -363,8 +369,7 @@ public class ASDCController {
 
         if (DistributionActionResultEnum.SUCCESS.equals(downloadResult.getDistributionActionResult())) {
             logger.info(LoggingAnchor.FOUR, MessageEnum.ASDC_ARTIFACT_DOWNLOAD_SUC.toString(),
-                    artifact.getArtifactURL(), artifact.getArtifactUUID(),
-                    String.valueOf(downloadResult.getArtifactPayload().length));
+                    artifact.getArtifactURL(), artifact.getArtifactUUID(), downloadResult.getArtifactPayload().length);
 
         } else {
             logger.error(LoggingAnchor.SEVEN, MessageEnum.ASDC_ARTIFACT_DOWNLOAD_FAIL.toString(),
@@ -447,7 +452,7 @@ public class ASDCController {
         }
     }
 
-    protected void sendCsarDeployNotification(INotificationData iNotif, ResourceStructure resourceStructure,
+    protected void sendCsarDeployNotification(ResourceStructure resourceStructure,
             ToscaResourceStructure toscaResourceStructure, DistributionStatusEnum statusEnum, String errorReason) {
 
         IArtifactInfo csarArtifact = toscaResourceStructure.getToscaArtifact();
@@ -471,8 +476,8 @@ public class ASDCController {
         } catch (ArtifactInstallerException e) {
             logger.info(LoggingAnchor.SIX, MessageEnum.ASDC_ARTIFACT_DOWNLOAD_FAIL.toString(),
                     resourceStructure.getResourceInstance().getResourceName(),
-                    resourceStructure.getResourceInstance().getResourceUUID(),
-                    String.valueOf(resourceStructure.getNumberOfResources()), "ASDC", "deployResourceStructure");
+                    resourceStructure.getResourceInstance().getResourceUUID(), resourceStructure.getNumberOfResources(),
+                    "ASDC", "deployResourceStructure");
             sendDeployNotificationsForResource(resourceStructure, DistributionStatusEnum.DEPLOY_ERROR, e.getMessage());
             throw e;
         }
@@ -480,8 +485,8 @@ public class ASDCController {
         if (resourceStructure.isDeployedSuccessfully() || toscaResourceStructure.isDeployedSuccessfully()) {
             logger.info(LoggingAnchor.SIX, MessageEnum.ASDC_ARTIFACT_DEPLOY_SUC.toString(),
                     resourceStructure.getResourceInstance().getResourceName(),
-                    resourceStructure.getResourceInstance().getResourceUUID(),
-                    String.valueOf(resourceStructure.getNumberOfResources()), "ASDC", "deployResourceStructure");
+                    resourceStructure.getResourceInstance().getResourceUUID(), resourceStructure.getNumberOfResources(),
+                    "ASDC", "deployResourceStructure");
             sendDeployNotificationsForResource(resourceStructure, DistributionStatusEnum.DEPLOY_OK, null);
         }
 
@@ -509,26 +514,10 @@ public class ASDCController {
         try {
             IDistributionStatusMessage message =
                     new DistributionStatusMessage(artifactURL, consumerID, distributionID, status, timestamp);
-
-            switch (notificationType) {
-                case DOWNLOAD:
-                    if (errorReason != null) {
-                        this.distributionClient.sendDownloadStatus(message, errorReason);
-                    } else {
-                        this.distributionClient.sendDownloadStatus(message);
-                    }
-
-                    break;
-                case DEPLOY:
-                    if (errorReason != null) {
-                        this.distributionClient.sendDeploymentStatus(message, errorReason);
-                    } else {
-                        this.distributionClient.sendDeploymentStatus(message);
-                    }
-
-                    break;
-                default:
-                    break;
+            if (errorReason != null) {
+                sendNotificationWithMessageAndErrorReason(notificationType, errorReason, message);
+            } else {
+                sendNotificationWithMessage(notificationType, message);
             }
         } catch (RuntimeException e) {
             logger.warn(LoggingAnchor.FIVE, MessageEnum.ASDC_SEND_NOTIF_ASDC_EXEC.toString(), "ASDC",
@@ -537,6 +526,33 @@ public class ASDCController {
         }
     }
 
+    private void sendNotificationWithMessage(NotificationType notificationType, IDistributionStatusMessage message) {
+        switch (notificationType) {
+            case DOWNLOAD:
+                this.distributionClient.sendDownloadStatus(message);
+                break;
+            case DEPLOY:
+                this.distributionClient.sendDeploymentStatus(message);
+                break;
+            default:
+                break;
+        }
+    }
+
+    private void sendNotificationWithMessageAndErrorReason(NotificationType notificationType, String errorReason,
+            IDistributionStatusMessage message) {
+        switch (notificationType) {
+            case DOWNLOAD:
+                this.distributionClient.sendDownloadStatus(message, errorReason);
+                break;
+            case DEPLOY:
+                this.distributionClient.sendDeploymentStatus(message, errorReason);
+                break;
+            default:
+                break;
+        }
+    }
+
     protected void sendFinalDistributionStatus(String distributionID, DistributionStatusEnum status,
             String errorReason) {
 
@@ -587,8 +603,8 @@ public class ASDCController {
         for (IResourceInstance resource : iNotif.getResources()) {
             noOfArtifacts += resource.getArtifacts().size();
         }
-        logger.info(LoggingAnchor.FOUR, MessageEnum.ASDC_RECEIVE_CALLBACK_NOTIF.toString(),
-                String.valueOf(noOfArtifacts), iNotif.getServiceUUID(), "ASDC");
+        logger.info(LoggingAnchor.FOUR, MessageEnum.ASDC_RECEIVE_CALLBACK_NOTIF.toString(), noOfArtifacts,
+                iNotif.getServiceUUID(), "ASDC");
         try {
 
             if (iNotif.getDistributionID() != null && !iNotif.getDistributionID().isEmpty()) {
@@ -721,7 +737,6 @@ public class ASDCController {
 
     protected void processResourceNotification(INotificationData iNotif) {
         // For each artifact, create a structure describing the VFModule in a ordered flat level
-        ResourceStructure resourceStructure = null;
         String msoConfigPath = getMsoConfigPath();
         ToscaResourceStructure toscaResourceStructure = new ToscaResourceStructure(msoConfigPath);
         DistributionStatusEnum deployStatus = DistributionStatusEnum.DEPLOY_OK;
@@ -734,6 +749,7 @@ public class ASDCController {
                 return;
             }
 
+            ResourceStructure resourceStructure = null;
             for (IResourceInstance resource : iNotif.getResources()) {
 
                 String resourceType = resource.getResourceType();
@@ -741,21 +757,11 @@ public class ASDCController {
 
                 logger.info("Processing Resource Type: {}, Model UUID: {}", resourceType, resource.getResourceUUID());
 
-                if ("VF".equals(resourceType)) {
-                    resourceStructure = new VfResourceStructure(iNotif, resource);
-                } else if ("PNF".equals(resourceType)) {
-                    resourceStructure = new PnfResourceStructure(iNotif, resource);
-                } else {
-                    // There are cases where the Service has no VF resources, those are handled here
-                    logger.info("No resources found for Service: {}", iNotif.getServiceUUID());
-                    resourceStructure = new VfResourceStructure(iNotif, new ResourceInstance());
-                    resourceStructure.setResourceType(ResourceType.OTHER);
-                }
+                resourceStructure = getResourceStructure(iNotif, resource, resourceType);
 
                 try {
 
                     if (!this.checkResourceAlreadyDeployed(resourceStructure, serviceDeployed)) {
-
                         logger.debug("Processing Resource Type: " + resourceType + " and Model UUID: "
                                 + resourceStructure.getResourceInstance().getResourceUUID());
 
@@ -765,25 +771,27 @@ public class ASDCController {
                             for (IArtifactInfo artifact : resource.getArtifacts()) {
                                 IDistributionClientDownloadResult resultArtifact =
                                         this.downloadTheArtifact(artifact, iNotif.getDistributionID());
-                                if (resultArtifact != null) {
-
-                                    if (ASDCConfiguration.VF_MODULES_METADATA.equals(artifact.getArtifactType())) {
-                                        logger.debug("VF_MODULE_ARTIFACT: "
-                                                + new String(resultArtifact.getArtifactPayload(), "UTF-8"));
-                                        logger.debug(ASDCNotificationLogging
-                                                .dumpVfModuleMetaDataList(((VfResourceStructure) resourceStructure)
-                                                        .decodeVfModuleArtifact(resultArtifact.getArtifactPayload())));
-                                    }
-                                    if (!ASDCConfiguration.WORKFLOW.equals(artifact.getArtifactType())) {
-                                        resourceStructure.addArtifactToStructure(distributionClient, artifact,
-                                                resultArtifact);
-                                    } else {
-                                        writeArtifactToFile(artifact, resultArtifact);
-                                        logger.debug(
-                                                "Adding workflow artifact to structure: " + artifact.getArtifactName());
-                                        resourceStructure.addWorkflowArtifactToStructure(artifact, resultArtifact);
-                                    }
+                                if (resultArtifact == null) {
+                                    continue;
                                 }
+
+                                if (ASDCConfiguration.VF_MODULES_METADATA.equals(artifact.getArtifactType())) {
+                                    logger.debug("VF_MODULE_ARTIFACT: "
+                                            + new String(resultArtifact.getArtifactPayload(), StandardCharsets.UTF_8));
+                                    logger.debug(ASDCNotificationLogging
+                                            .dumpVfModuleMetaDataList(((VfResourceStructure) resourceStructure)
+                                                    .decodeVfModuleArtifact(resultArtifact.getArtifactPayload())));
+                                }
+                                if (!ASDCConfiguration.WORKFLOW.equals(artifact.getArtifactType())) {
+                                    resourceStructure.addArtifactToStructure(distributionClient, artifact,
+                                            resultArtifact);
+                                } else {
+                                    writeArtifactToFile(artifact, resultArtifact);
+                                    logger.debug(
+                                            "Adding workflow artifact to structure: " + artifact.getArtifactName());
+                                    resourceStructure.addWorkflowArtifactToStructure(artifact, resultArtifact);
+                                }
+
                             }
 
                             // Deploy VF resource and artifacts
@@ -817,8 +825,7 @@ public class ASDCController {
                 }
             }
 
-            this.sendCsarDeployNotification(iNotif, resourceStructure, toscaResourceStructure, deployStatus,
-                    errorMessage);
+            this.sendCsarDeployNotification(resourceStructure, toscaResourceStructure, deployStatus, errorMessage);
 
         } catch (ASDCDownloadException | UnsupportedEncodingException e) {
             logger.error(LoggingAnchor.SIX, MessageEnum.ASDC_GENERAL_EXCEPTION_ARG.toString(),
@@ -827,6 +834,20 @@ public class ASDCController {
         }
     }
 
+    private ResourceStructure getResourceStructure(INotificationData iNotif, IResourceInstance resource,
+            String resourceType) {
+        if ("VF".equals(resourceType)) {
+            return new VfResourceStructure(iNotif, resource);
+        }
+        if ("PNF".equals(resourceType)) {
+            return new PnfResourceStructure(iNotif, resource);
+        }
+        logger.info("No resources found for Service: {}", iNotif.getServiceUUID());
+        ResourceStructure resourceStructure = new VfResourceStructure(iNotif, new ResourceInstance());
+        resourceStructure.setResourceType(ResourceType.OTHER);
+        return resourceStructure;
+    }
+
     private String getMsoConfigPath() {
         String msoConfigPath = System.getProperty("mso.config.path");
         if (msoConfigPath == null) {
@@ -900,7 +921,6 @@ public class ASDCController {
     }
 
 
-
     /**
      * @return the address of the ASDC we are connected to.
      */
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipCDSBuildingBlockListener.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipCDSBuildingBlockListener.java
new file mode 100644 (file)
index 0000000..682a047
--- /dev/null
@@ -0,0 +1,116 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2020  Tech Mahindra
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.infrastructure.workflow.tasks.listeners;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import org.apache.logging.log4j.util.Strings;
+import org.onap.so.bpmn.common.BBConstants;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.so.bpmn.common.listener.flowmanipulator.FlowManipulator;
+import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock;
+import org.onap.so.db.catalog.beans.VfModuleCustomization;
+import org.onap.so.db.catalog.beans.VnfResourceCustomization;
+import org.onap.so.db.catalog.client.CatalogDbClient;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import org.springframework.util.CollectionUtils;
+
+@Component
+public class SkipCDSBuildingBlockListener implements FlowManipulator {
+
+    @Autowired
+    private CatalogDbClient catalogDbClient;
+
+    private Set<String> vnfActions =
+            new HashSet<String>(Arrays.asList("config-assign", "config-deploy", "VnfConfigAssign", "VnfConfigDeploy"));
+
+    private Set<String> vFModuleAction =
+            new HashSet<String>(Arrays.asList("VfModuleConfigAssign", "VfModuleConfigDeploy"));
+
+    @Override
+    public boolean shouldRunFor(String currentBBName, boolean isFirst, BuildingBlockExecution execution) {
+
+        return "ControllerExecutionBB".equals(currentBBName);
+    }
+
+    /**
+     * Skip the CDS Building block according to the Skip Flag.
+     *
+     * @param flowsToExecute - List of ExecuteBuildingBlock object.
+     * @param execution - BuildingBlockExecution object
+     * @param currentBB - ExecuteBuildingBlock object
+     *
+     */
+    @Override
+    public void run(List<ExecuteBuildingBlock> flowsToExecute, ExecuteBuildingBlock currentBB,
+            BuildingBlockExecution execution) {
+        String customizationUUID = currentBB.getBuildingBlock().getKey();
+
+        if (Strings.isEmpty(customizationUUID)) {
+            return;
+        }
+
+        if (currentBB.getBuildingBlock().getBpmnScope().equalsIgnoreCase("VNF")
+                && containsIgnoreCaseAction(currentBB, vnfActions)) {
+            List<VnfResourceCustomization> vnfResourceCustomizations =
+                    catalogDbClient.getVnfResourceCustomizationByModelUuid(
+                            currentBB.getRequestDetails().getModelInfo().getModelUuid());
+            if (!CollectionUtils.isEmpty(vnfResourceCustomizations)) {
+                VnfResourceCustomization vrc = catalogDbClient.findVnfResourceCustomizationInList(customizationUUID,
+                        vnfResourceCustomizations);
+                if (null != vrc) {
+                    boolean skipConfigVNF = vrc.isSkipPostInstConf();
+                    currentSequenceSkipCheck(execution, skipConfigVNF);
+                }
+
+            }
+        } else if (currentBB.getBuildingBlock().getBpmnScope().equalsIgnoreCase("VFModule")
+                && containsIgnoreCaseAction(currentBB, vFModuleAction)) {
+
+            VfModuleCustomization vfc =
+                    catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID(customizationUUID);
+
+            if (null != vfc) {
+                boolean skipVfModule = vfc.isSkipPostInstConf();
+                currentSequenceSkipCheck(execution, skipVfModule);
+            }
+        }
+
+
+    }
+
+    private boolean containsIgnoreCaseAction(ExecuteBuildingBlock currentBB, Set<String> actions) {
+        return actions.stream().filter(action -> action.equalsIgnoreCase(currentBB.getBuildingBlock().getBpmnAction()))
+                .findFirst().isPresent();
+    }
+
+
+    private void currentSequenceSkipCheck(BuildingBlockExecution execution, boolean skipModule) {
+        if (skipModule) {
+            int currentSequence = execution.getVariable(BBConstants.G_CURRENT_SEQUENCE);
+            execution.setVariable(BBConstants.G_CURRENT_SEQUENCE, currentSequence + 1);
+        }
+    }
+
+}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipCDSBuildingBlockListenerTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipCDSBuildingBlockListenerTest.java
new file mode 100644 (file)
index 0000000..fb162f8
--- /dev/null
@@ -0,0 +1,202 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2020  Tech Mahindra
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.infrastructure.workflow.tasks.listeners;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.when;
+import java.util.ArrayList;
+import java.util.List;
+import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.onap.so.bpmn.common.BBConstants;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.so.bpmn.common.DelegateExecutionImpl;
+import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock;
+import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock;
+import org.onap.so.db.catalog.beans.VfModuleCustomization;
+import org.onap.so.db.catalog.beans.VnfResourceCustomization;
+import org.onap.so.db.catalog.client.CatalogDbClient;
+import org.onap.so.serviceinstancebeans.ModelInfo;
+import org.onap.so.serviceinstancebeans.RequestDetails;
+
+@RunWith(MockitoJUnitRunner.Silent.class)
+public class SkipCDSBuildingBlockListenerTest {
+
+    private static final String VNF_SCOPE = "VNF";
+    private static final String VF_SCOPE = "VFModule";
+    private static final String TEST_MODELUUID = "123456789";
+    private static final String VNF_TEST_ACTION = "VnfConfigAssign";
+    private static final String VFModule_TEST_ACTION = "VfModuleConfigAssign";
+    private static final String MODELCUSTOMIZATIONUUID = "123456789";
+    private static final String BBNAME = "ControllerExecutionBB";
+    private static final boolean ISFIRST = true;
+
+    private int actual;
+    private List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>();
+    private List<VnfResourceCustomization> vnfResourceCustomization;
+    private List<VfModuleCustomization> vfModuleCustomization;
+    private ExecuteBuildingBlock executeBuildingBlock = new ExecuteBuildingBlock();
+    private RequestDetails reqDetail = new RequestDetails();
+    private BuildingBlockExecution buildingBlockExecution = new DelegateExecutionImpl(new DelegateExecutionFake());
+    private VnfResourceCustomization vnfCust = new VnfResourceCustomization();
+    private VfModuleCustomization vfCust = new VfModuleCustomization();
+    private BuildingBlock buildingBlock = new BuildingBlock();
+
+    @InjectMocks
+    private SkipCDSBuildingBlockListener skipCDSBuildingBlockListener;
+    @Mock
+    private CatalogDbClient catalogDbClient;
+
+    @Before
+    public void before() {
+        ModelInfo model = new ModelInfo();
+        model.setModelUuid(TEST_MODELUUID);
+        reqDetail.setModelInfo(model);
+        executeBuildingBlock.setRequestDetails(reqDetail);
+    }
+
+    @Test
+    public void testTrigger() {
+        BuildingBlockExecution execution = new DelegateExecutionImpl(new DelegateExecutionFake());
+        skipCDSBuildingBlockListener.shouldRunFor(BBNAME, ISFIRST, execution);
+        assertEquals("ControllerExecutionBB", BBNAME);
+    }
+
+    @Test
+    public void testProcessForVNFToSkipCDSBB() {
+        // given
+        setBuildingBlockAndCurrentSequence(VNF_SCOPE, VNF_TEST_ACTION, 0);
+        vnfResourceCustomization = getVnfResourceCustomizationList(true);
+
+        when(catalogDbClient.getVnfResourceCustomizationByModelUuid(
+                executeBuildingBlock.getRequestDetails().getModelInfo().getModelUuid()))
+                        .thenReturn(vnfResourceCustomization);
+        when(catalogDbClient.findVnfResourceCustomizationInList(executeBuildingBlock.getBuildingBlock().getKey(),
+                vnfResourceCustomization)).thenReturn(vnfCust);
+
+        // when
+        skipCDSBuildingBlockListener.run(flowsToExecute, executeBuildingBlock, buildingBlockExecution);
+
+        // then
+        actual = buildingBlockExecution.getVariable(BBConstants.G_CURRENT_SEQUENCE);
+        assertEquals(1, actual);
+
+    }
+
+    @Test
+    public void testProcessForVNFNotToSkipCDSBB() {
+        // given
+        setBuildingBlockAndCurrentSequence(VNF_SCOPE, VNF_TEST_ACTION, 0);
+        vnfResourceCustomization = getVnfResourceCustomizationList(false);
+
+        when(catalogDbClient.getVnfResourceCustomizationByModelUuid(
+                executeBuildingBlock.getRequestDetails().getModelInfo().getModelUuid()))
+                        .thenReturn(vnfResourceCustomization);
+        when(catalogDbClient.findVnfResourceCustomizationInList(executeBuildingBlock.getBuildingBlock().getKey(),
+                vnfResourceCustomization)).thenReturn(vnfCust);
+
+        // when
+        skipCDSBuildingBlockListener.run(flowsToExecute, executeBuildingBlock, buildingBlockExecution);
+
+        // then
+        actual = buildingBlockExecution.getVariable(BBConstants.G_CURRENT_SEQUENCE);
+        assertEquals(0, actual);
+
+    }
+
+
+    @Test
+    public void testProcessForVFToSkipCDSBB() {
+        // given
+        setBuildingBlockAndCurrentSequence(VF_SCOPE, VFModule_TEST_ACTION, 0);
+        vfModuleCustomization = getVfModuleCustomizationList(true);
+
+        when(catalogDbClient
+                .getVfModuleCustomizationByModelCuztomizationUUID(executeBuildingBlock.getBuildingBlock().getKey()))
+                        .thenReturn(vfCust);
+
+        // when
+        skipCDSBuildingBlockListener.run(flowsToExecute, executeBuildingBlock, buildingBlockExecution);
+
+        // then
+        actual = buildingBlockExecution.getVariable(BBConstants.G_CURRENT_SEQUENCE);
+        assertEquals(1, actual);
+
+    }
+
+    @Test
+    public void testProcessForVFNotToSkipCDSBB() {
+        // given
+        setBuildingBlockAndCurrentSequence(VF_SCOPE, VFModule_TEST_ACTION, 0);
+        vfModuleCustomization = getVfModuleCustomizationList(false);
+
+        when(catalogDbClient
+                .getVfModuleCustomizationByModelCuztomizationUUID(executeBuildingBlock.getBuildingBlock().getKey()))
+                        .thenReturn(vfCust);
+
+        // when
+        skipCDSBuildingBlockListener.run(flowsToExecute, executeBuildingBlock, buildingBlockExecution);
+
+        // then
+        actual = buildingBlockExecution.getVariable(BBConstants.G_CURRENT_SEQUENCE);
+        assertEquals(0, actual);
+
+    }
+
+    /**
+     * setting scope action in buildingBlock and BB current sequence in BuildingBlockExecution
+     *
+     * @param scope
+     * @param action
+     * @param squence
+     */
+    private void setBuildingBlockAndCurrentSequence(String scope, String action, int sequence) {
+        buildingBlock.setBpmnScope(scope);
+        buildingBlock.setBpmnAction(action);
+        buildingBlock.setBpmnFlowName("ControllerExecutionBB");
+        buildingBlock.setKey(MODELCUSTOMIZATIONUUID);
+        executeBuildingBlock.setBuildingBlock(buildingBlock);
+        buildingBlockExecution.setVariable(BBConstants.G_CURRENT_SEQUENCE, sequence);
+
+    }
+
+    private List<VnfResourceCustomization> getVnfResourceCustomizationList(boolean setSkippost) {
+        List<VnfResourceCustomization> vnfResourceCustomizations = new ArrayList<>();
+        vnfCust.setModelCustomizationUUID(MODELCUSTOMIZATIONUUID);
+        vnfCust.setSkipPostInstConf(setSkippost);
+        vnfResourceCustomizations.add(vnfCust);
+        return vnfResourceCustomizations;
+    }
+
+    private List<VfModuleCustomization> getVfModuleCustomizationList(boolean setSkippost) {
+        List<VfModuleCustomization> vfModuleCustomizations = new ArrayList<>();
+        vfCust.setModelCustomizationUUID(MODELCUSTOMIZATIONUUID);
+        vfCust.setSkipPostInstConf(setSkippost);
+        vfModuleCustomizations.add(vfCust);
+        return vfModuleCustomizations;
+    }
+
+}
index 5bcdcb1..05e69b7 100644 (file)
@@ -32,8 +32,8 @@ public class ServiceInstancesRequest implements Serializable {
     private String serviceInstanceId;
     @JsonProperty("vnfInstanceId")
     private String vnfInstanceId;
-    @JsonProperty("pnfId")
-    private String pnfId;
+    @JsonProperty("pnfName")
+    private String pnfName;
     @JsonProperty("networkInstanceId")
     private String networkInstanceId;
     @JsonProperty("volumeGroupInstanceId")
@@ -69,12 +69,12 @@ public class ServiceInstancesRequest implements Serializable {
         this.vnfInstanceId = vnfInstanceId;
     }
 
-    public String getPnfId() {
-        return pnfId;
+    public String getPnfName() {
+        return pnfName;
     }
 
-    public void setPnfId(String pnfId) {
-        this.pnfId = pnfId;
+    public void setPnfName(String pnfName) {
+        this.pnfName = pnfName;
     }
 
     public String getNetworkInstanceId() {
@@ -123,7 +123,7 @@ public class ServiceInstancesRequest implements Serializable {
         sb.append("requestDetails=").append(requestDetails);
         sb.append(", serviceInstanceId='").append(serviceInstanceId).append('\'');
         sb.append(", vnfInstanceId='").append(vnfInstanceId).append('\'');
-        sb.append(", pnfId='").append(pnfId).append('\'');
+        sb.append(", pnfName='").append(pnfName).append('\'');
         sb.append(", networkInstanceId='").append(networkInstanceId).append('\'');
         sb.append(", volumeGroupInstanceId='").append(volumeGroupInstanceId).append('\'');
         sb.append(", vfModuleInstanceId='").append(vfModuleInstanceId).append('\'');
index 84a80e6..9944984 100644 (file)
       <groupId>org.springframework.retry</groupId>
       <artifactId>spring-retry</artifactId>
     </dependency>
+    <dependency>
+      <groupId>org.springframework.boot</groupId>
+      <artifactId>spring-boot-starter-webflux</artifactId>
+    </dependency>
     <dependency>
       <groupId>commons-lang</groupId>
       <artifactId>commons-lang</artifactId>
index 17377d8..f30b66c 100644 (file)
@@ -9,9 +9,11 @@ import javax.ws.rs.core.UriBuilder;
 import javax.xml.bind.DatatypeConverter;
 import org.camunda.bpm.engine.impl.persistence.entity.HistoricActivityInstanceEntity;
 import org.camunda.bpm.engine.impl.persistence.entity.HistoricProcessInstanceEntity;
+import org.json.JSONObject;
 import org.onap.logging.filter.spring.SpringClientPayloadFilter;
 import org.onap.so.logging.jaxrs.filter.SOSpringClientFilter;
 import org.onap.so.utils.CryptoUtils;
+import org.onap.so.apihandlerinfra.exceptions.ContactCamundaException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -29,6 +31,9 @@ import org.springframework.stereotype.Component;
 import org.springframework.web.client.ResourceAccessException;
 import org.springframework.web.client.RestClientException;
 import org.springframework.web.client.RestTemplate;
+import org.springframework.web.reactive.function.BodyInserters;
+import org.springframework.web.reactive.function.client.WebClient;
+import reactor.core.publisher.Flux;
 
 @Component
 public class CamundaRequestHandler {
@@ -202,6 +207,20 @@ public class CamundaRequestHandler {
         return retryTemplate;
     }
 
+    protected void sendCamundaMessages(JSONObject msgJson) {
+        String url = env.getProperty("mso.camundaURL") + "/sobpmnengine/message";
+        HttpHeaders headers =
+                setCamundaHeaders(env.getRequiredProperty("mso.camundaAuth"), env.getRequiredProperty("mso.msoKey"));
+        headers.setContentType(org.springframework.http.MediaType.APPLICATION_JSON);
+        // Workflow may take a long time so use non-blocking request
+        Flux<String> flux = WebClient.create().post().uri(url).headers(httpHeaders -> {
+            httpHeaders.set(httpHeaders.AUTHORIZATION, headers.get(httpHeaders.AUTHORIZATION).get(0));
+            httpHeaders.set(httpHeaders.ACCEPT, headers.get(httpHeaders.ACCEPT).get(0));
+            httpHeaders.set(httpHeaders.CONTENT_TYPE, headers.get(httpHeaders.CONTENT_TYPE).get(0));
+        }).body(BodyInserters.fromObject(msgJson.toString())).retrieve().bodyToFlux(String.class);
+        flux.subscribe(res -> logger.debug("Send Camunda Message: " + res));
+    }
+
     protected RestTemplate getRestTemplate(boolean retry) {
         int timeout;
         if (retry) {
index 028abd6..88028d3 100644 (file)
@@ -95,7 +95,7 @@ public class InstanceManagement {
     @Path("/{version:[vV][1]}/serviceInstances/{serviceInstanceId}/vnfs/{vnfInstanceId}/workflows/{workflowUuid}")
     @Consumes(MediaType.APPLICATION_JSON)
     @Produces(MediaType.APPLICATION_JSON)
-    @Operation(description = "Execute custom workflow", responses = @ApiResponse(
+    @Operation(description = "Execute custom VNF workflow", responses = @ApiResponse(
             content = @Content(array = @ArraySchema(schema = @Schema(implementation = Response.class)))))
     @Transactional
     public Response executeVNFCustomWorkflow(String request, @PathParam("version") String version,
@@ -112,20 +112,20 @@ public class InstanceManagement {
     }
 
     @POST
-    @Path("/{version:[vV][1]}/serviceInstances/{serviceInstanceId}/pnfs/{pnfId}/workflows/{workflowUuid}")
+    @Path("/{version:[vV][1]}/serviceInstances/{serviceInstanceId}/pnfs/{pnfName}/workflows/{workflowUuid}")
     @Consumes(MediaType.APPLICATION_JSON)
     @Produces(MediaType.APPLICATION_JSON)
-    @Operation(description = "Execute custom workflow", responses = @ApiResponse(
+    @Operation(description = "Execute custom PNF workflow", responses = @ApiResponse(
             content = @Content(array = @ArraySchema(schema = @Schema(implementation = Response.class)))))
     @Transactional
     public Response executePNFCustomWorkflow(String request, @PathParam("version") String version,
-            @PathParam("serviceInstanceId") String serviceInstanceId, @PathParam("pnfId") String pnfId,
+            @PathParam("serviceInstanceId") String serviceInstanceId, @PathParam("pnfName") String pnfName,
             @PathParam("workflowUuid") String workflowUuid, @Context ContainerRequestContext requestContext)
             throws ApiException {
         String requestId = requestHandlerUtils.getRequestId(requestContext);
         HashMap<String, String> instanceIdMap = new HashMap<>();
         instanceIdMap.put("serviceInstanceId", serviceInstanceId);
-        instanceIdMap.put("pnfId", pnfId);
+        instanceIdMap.put("pnfName", pnfName);
         instanceIdMap.put("workflowUuid", workflowUuid);
         return processPNFCustomWorkflowRequest(request, Action.forCustomWorkflow, instanceIdMap, version, requestId,
                 requestContext);
@@ -255,18 +255,18 @@ public class InstanceManagement {
         String apiVersion = version.substring(1);
 
         String serviceInstanceId = "";
-        String pnfId = "";
+        String pnfName = "";
         String workflowUuid = "";
         if (instanceIdMap != null) {
             serviceInstanceId = instanceIdMap.get("serviceInstanceId");
-            pnfId = instanceIdMap.get("pnfId");
+            pnfName = instanceIdMap.get("pnfName");
             workflowUuid = instanceIdMap.get("workflowUuid");
         }
 
         String requestUri = requestHandlerUtils.getRequestUri(requestContext, uriPrefix);
         sir = requestHandlerUtils.convertJsonToServiceInstanceRequest(requestJSON, action, requestId, requestUri);
         sir.setServiceInstanceId(serviceInstanceId);
-        sir.setPnfId(pnfId);
+        sir.setPnfName(pnfName);
         String requestScope = ModelType.pnf.name();
         InfraActiveRequests currentActiveReq =
                 msoRequest.createRequestObject(sir, action, requestId, Status.IN_PROGRESS, requestJSON, requestScope);
@@ -299,7 +299,7 @@ public class InstanceManagement {
         try {
             requestClientParameter = new RequestClientParameter.Builder().setRequestId(requestId)
                     .setRecipeTimeout(recipeLookupResult.getRecipeTimeout()).setRequestAction(action.toString())
-                    .setServiceInstanceId(serviceInstanceId).setPnfCorrelationId(pnfId)
+                    .setServiceInstanceId(serviceInstanceId).setPnfCorrelationId(pnfName)
                     .setRequestDetails(requestHandlerUtils.mapJSONtoMSOStyle(requestJSON, null, aLaCarte, action))
                     .setApiVersion(apiVersion).setRequestUri(requestUri).build();
         } catch (IOException e) {
index b7288e4..0afc272 100644 (file)
@@ -92,6 +92,7 @@ public class JerseyConfiguration extends ResourceConfig {
         register(NoRecipeExceptionMapper.class);
         register(RequestConflictMapper.class);
         register(WorkflowEngineConnectionMapper.class);
+        register(OrchestrationTasks.class);
         // this registration seems to be needed to get predictable
         // execution behavior for the above JSON Exception Mappers
         register(com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider.class);
index 5c81f4e..31e026b 100644 (file)
@@ -311,9 +311,9 @@ public class MsoRequest {
                     aq.setVnfId(servInsReq.getVnfInstanceId());
                 }
 
-                if (servInsReq.getPnfId() != null) {
+                if (servInsReq.getPnfName() != null) {
                     aq.setRequestScope(requestScope);
-                    aq.setPnfId(servInsReq.getPnfId());
+                    aq.setPnfName(servInsReq.getPnfName());
                 }
 
                 if (ModelType.service.name().equalsIgnoreCase(requestScope)) {
index 7961cb0..fc57696 100644 (file)
@@ -116,4 +116,26 @@ public class OrchestrationTasks {
         }
     }
 
+    @POST
+    @Path("/{version:[vV][4-7]}/")
+    @Operation(description = "Create an Orchestrated Task", responses = @ApiResponse(
+            content = @Content(array = @ArraySchema(schema = @Schema(implementation = Response.class)))))
+    @Produces(MediaType.APPLICATION_JSON)
+    @Transactional
+    public Response CreateOrchestrationTask(String requestJson, @PathParam("version") String version) {
+        try {
+            OrchestrationTask orchestrationTask = mapper.readValue(requestJson, OrchestrationTask.class);
+            requestsDbClient.createOrchestrationTask(orchestrationTask);
+            return builder.buildResponse(HttpStatus.SC_OK, null, orchestrationTask, version);
+        } catch (Exception e) {
+            logger.error(LoggingAnchor.FOUR, MessageEnum.APIH_DB_ACCESS_EXC.toString(), MSO_PROP_APIHANDLER_INFRA,
+                    ErrorCode.AvailabilityError.getValue(),
+                    "Exception while communciate with Request DB - Orchestration Task Create", e);
+            Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_INTERNAL_SERVER_ERROR,
+                    MsoException.ServiceException, e.getMessage(), ErrorNumbers.COULD_NOT_WRITE_TO_REQUESTS_DB, null,
+                    version);
+            return response;
+        }
+    }
+
 }
index 75b7e74..38fb159 100644 (file)
@@ -506,8 +506,8 @@ public class RequestHandlerUtils extends AbstractRestHandler {
             if (instanceIdMap.get(CommonConstants.INSTANCE_GROUP_INSTANCE_ID) != null) {
                 currentActiveReq.setInstanceGroupId(instanceIdMap.get(CommonConstants.INSTANCE_GROUP_INSTANCE_ID));
             }
-            if (instanceIdMap.get("PnfId") != null) {
-                currentActiveReq.setPnfId(instanceIdMap.get("PnfId"));
+            if (instanceIdMap.get("pnfName") != null) {
+                currentActiveReq.setPnfName(instanceIdMap.get("pnfName"));
             }
         }
     }
index c05ef98..01c7fd3 100644 (file)
@@ -29,20 +29,13 @@ import com.google.common.base.Strings;
 
 public class CustomWorkflowValidation implements ValidationRule {
 
+    /**
+     * This function should be generic both for custom VNF workflow and PNF workflow
+     */
     @Override
     public ValidationInformation validate(ValidationInformation info) throws ValidationException {
         RequestParameters requestParameters = info.getSir().getRequestDetails().getRequestParameters();
-        CloudConfiguration cloudConfiguration = info.getSir().getRequestDetails().getCloudConfiguration();
 
-        if (cloudConfiguration == null) {
-            // throw new ValidationException("cloudConfiguration");
-        } else if (Strings.isNullOrEmpty((cloudConfiguration.getCloudOwner()))) {
-            // throw new ValidationException("cloudOwner");
-        } else if (Strings.isNullOrEmpty((cloudConfiguration.getLcpCloudRegionId()))) {
-            // throw new ValidationException("lcpCloudRegionId");
-        } else if (Strings.isNullOrEmpty((cloudConfiguration.getTenantId()))) {
-            // throw new ValidationException("tenantId");
-        }
         if (requestParameters == null) {
             throw new ValidationException("requestParameters");
         }
index 5c78af3..ba7fe2b 100644 (file)
@@ -192,11 +192,12 @@ public class InstanceManagementTest extends BaseTest {
         requestReferences.setRequestSelfLink(createExpectedSelfLink("v1", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
         expectedResponse.setRequestReferences(requestReferences);
         uri = instanceManagementUri + "v1"
-                + "/serviceInstances/5df8b6de-2083-11e7-93ae-92361f002676/pnfs/testpnfcId/workflows/81526781-e55c-4cb7-adb3-97e09d9c76bf";
+                + "/serviceInstances/5df8b6de-2083-11e7-93ae-92361f002676/pnfs/testPnfName/workflows/81526781-e55c-4cb7-adb3-97e09d9c76bf";
         ResponseEntity<String> response =
                 sendRequest(inputStream("/ExecutePNFCustomWorkflow.json"), uri, HttpMethod.POST, headers);
 
         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+
         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
     }
index 63021b6..09f94b6 100644 (file)
@@ -1,20 +1,47 @@
 {
-  "requestDetails": {
-    "requestParameters": {
-        "userParams": [{
-          "nrmObj": {        
-            "EUtranGenericCell" : [
-                {"cellLocalId":1, "pci":5},
-                {"cellLocalId":2, "pci":6}
-             ],
-            "ExternalEUtranCell" : [
-                {"cellLocalId":3, "eNBId": "x"}, 
-                {"cellLocalId":4, "eNBId": "y"}
-            ],
-            "EUtranRelation": [{"scellLocalId":5, "tcellLocalId":6}]
-          }        
-        }],
-        "payload": "[{\"GNBDUFunction\":{\"gNBId\":1,\"gNBDUId\":5}}]"
-    }
-  }
+  "requestDetails":{
+    "subscriberInfo":{
+      "globalSubscriberId":"Test"
+    },
+    "requestInfo":{
+      "suppressRollback": false,
+      "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb",
+      "requestorId": "tester",
+      "instanceName":"testInstanceName",
+      "source":"test"
+    },
+    "cloudConfiguration":{
+      "lcpCloudRegionId": "RegionOne",
+      "tenantId": "7320ec4a5b9d4589ba7c4412ccfd290f",
+      "cloudOwner": "CloudOwner"
+    },
+    "requestParameters":{
+      "subscriptionServiceType": "test",
+      "userParams":[
+      {
+        "name": "key1",
+        "value": "val1"
+      },
+      {
+        "name": "key2",
+        "value": "val2"
+      }],
+      "aLaCarte": false,
+      "payload": "{\"k1\": \"v1\"}"
+      },
+      "project":{
+         "projectName": "Test"
+      },
+      "owningEntity":{
+        "owningEntityId":"67f2e84c-734d-4e90-a1e4-d2ffa2e75849",
+        "owningEntityName":"OE-Test"
+      },
+      "modelInfo":{
+        "modelVersion": "2.0",
+        "modelVersionId": "test-version-id",
+        "modelInvariantId": "test-invariantUUID",
+        "modelName": "test-name",
+        "modelType": "pnf"
+      }
+   }
 }
index 050780c..1a1e9be 100644 (file)
@@ -1262,7 +1262,7 @@ CREATE TABLE `infra_active_requests` (
   `END_TIME` datetime DEFAULT NULL,
   `SOURCE` varchar(45) DEFAULT NULL,
   `VNF_ID` varchar(45) DEFAULT NULL,
-  `PNF_ID` varchar(45) DEFAULT NULL,
+  `PNF_NAME` varchar(45) DEFAULT NULL,
   `VNF_NAME` varchar(80) DEFAULT NULL,
   `VNF_TYPE` varchar(200) DEFAULT NULL,
   `SERVICE_TYPE` varchar(45) DEFAULT NULL,
index bba0ad4..da8f30a 100644 (file)
@@ -245,8 +245,8 @@ public class InfraActiveRequestsRepositoryImpl implements InfraActiveRequestsRep
                 mapKey = "serviceInstanceName";
             } else if ("vnfInstanceId".equalsIgnoreCase(mapKey)) {
                 mapKey = "vnfId";
-            } else if ("pnfId".equalsIgnoreCase(mapKey)) {
-                mapKey = "pnfId";
+            } else if ("pnfName".equalsIgnoreCase(mapKey)) {
+                mapKey = "pnfName";
             } else if ("vnfInstanceName".equalsIgnoreCase(mapKey)) {
                 mapKey = "vnfName";
             } else if ("vfModuleInstanceId".equalsIgnoreCase(mapKey)) {
index 4f6c19f..1efd125 100644 (file)
@@ -64,7 +64,7 @@ CREATE TABLE IF NOT EXISTS PUBLIC.INFRA_ACTIVE_REQUESTS(
     END_TIME VARCHAR,
     SOURCE VARCHAR SELECTIVITY 2,
     VNF_ID VARCHAR SELECTIVITY 15,
-    PNF_ID VARCHAR SELECTIVITY 15,
+    PNF_NAME VARCHAR SELECTIVITY 15,
     VNF_NAME VARCHAR SELECTIVITY 11,
     VNF_TYPE VARCHAR SELECTIVITY 5,
     SERVICE_TYPE VARCHAR SELECTIVITY 1,
@@ -246,14 +246,14 @@ CREATE CACHED TABLE PUBLIC.WATCHDOG_SERVICE_MOD_VER_ID_LOOKUP(
 INSERT INTO PUBLIC.WATCHDOG_SERVICE_MOD_VER_ID_LOOKUP(DISTRIBUTION_ID, SERVICE_MODEL_VERSION_ID, CREATE_TIME, MODIFY_TIME) VALUES
 ('1533c4bd-a3e3-493f-a16d-28c20614415e', '7e813ab5-88d3-4fcb-86c0-498c5d7eef9a', '2017-11-30 15:48:08', '2017-11-30 15:48:08'),
 ('55429711-809b-4a3b-9ee5-5120d46d9de0', 'cc031e75-4442-4d1a-b774-8a2b434e0a50', '2017-11-30 16:35:36', '2017-11-30 16:35:36'),
-('67f0b2d1-9013-4b2b-9914-bbe2288284fb', 'eade1e9d-c1ec-4ef3-bc31-60570fba1573', '2017-11-30 15:54:39', '2017-11-30 15:54:39');    
+('67f0b2d1-9013-4b2b-9914-bbe2288284fb', 'eade1e9d-c1ec-4ef3-bc31-60570fba1573', '2017-11-30 15:54:39', '2017-11-30 15:54:39');
 
-ALTER TABLE PUBLIC.INFRA_ACTIVE_REQUESTS ADD CONSTRAINT PUBLIC.CONSTRAINT_E PRIMARY KEY(REQUEST_ID);          
-ALTER TABLE PUBLIC.SITE_STATUS ADD CONSTRAINT PUBLIC.CONSTRAINT_C PRIMARY KEY(SITE_NAME); 
+ALTER TABLE PUBLIC.INFRA_ACTIVE_REQUESTS ADD CONSTRAINT PUBLIC.CONSTRAINT_E PRIMARY KEY(REQUEST_ID);
+ALTER TABLE PUBLIC.SITE_STATUS ADD CONSTRAINT PUBLIC.CONSTRAINT_C PRIMARY KEY(SITE_NAME);
 ALTER TABLE PUBLIC.WATCHDOG_DISTRIBUTIONID_STATUS ADD CONSTRAINT PUBLIC.CONSTRAINT_7 PRIMARY KEY(DISTRIBUTION_ID); 
 ALTER TABLE PUBLIC.WATCHDOG_PER_COMPONENT_DISTRIBUTION_STATUS ADD CONSTRAINT PUBLIC.CONSTRAINT_D PRIMARY KEY(DISTRIBUTION_ID, COMPONENT_NAME);
-ALTER TABLE PUBLIC.WATCHDOG_SERVICE_MOD_VER_ID_LOOKUP ADD CONSTRAINT PUBLIC.CONSTRAINT_6 PRIMARY KEY(DISTRIBUTION_ID, SERVICE_MODEL_VERSION_ID);   
-ALTER TABLE PUBLIC.WATCHDOG_PER_COMPONENT_DISTRIBUTION_STATUS ADD CONSTRAINT PUBLIC.CONSTRAINT_DE FOREIGN KEY(DISTRIBUTION_ID) REFERENCES PUBLIC.WATCHDOG_DISTRIBUTIONID_STATUS(DISTRIBUTION_ID) NOCHECK; 
+ALTER TABLE PUBLIC.WATCHDOG_SERVICE_MOD_VER_ID_LOOKUP ADD CONSTRAINT PUBLIC.CONSTRAINT_6 PRIMARY KEY(DISTRIBUTION_ID, SERVICE_MODEL_VERSION_ID);
+ALTER TABLE PUBLIC.WATCHDOG_PER_COMPONENT_DISTRIBUTION_STATUS ADD CONSTRAINT PUBLIC.CONSTRAINT_DE FOREIGN KEY(DISTRIBUTION_ID) REFERENCES PUBLIC.WATCHDOG_DISTRIBUTIONID_STATUS(DISTRIBUTION_ID) NOCHECK;
 
 CREATE TABLE `orchestration_task` (
   `TASK_ID` varchar(200) NOT NULL,
index 5848f3b..9b24646 100644 (file)
@@ -72,15 +72,15 @@ public class InfraActiveRequests extends InfraRequests {
                 .append("statusMessage", getStatusMessage()).append("progress", getProgress())
                 .append("startTime", getStartTime()).append("endTime", getEndTime()).append("source", getSource())
                 .append("vnfId", getVnfId()).append("vnfName", getVnfName()).append("vnfType", getVnfType())
-                .append("pnfId", getPnfId()).append("serviceType", getServiceType()).append("tenantId", getTenantId())
-                .append("vnfParams", getVnfParams()).append("vnfOutputs", getVnfOutputs())
-                .append("requestBody", getRequestBody()).append("responseBody", getResponseBody())
-                .append("lastModifiedBy", getLastModifiedBy()).append("modifyTime", getModifyTime())
-                .append("volumeGroupId", getVolumeGroupId()).append("volumeGroupName", getVolumeGroupName())
-                .append("vfModuleId", getVfModuleId()).append("vfModuleName", getVfModuleName())
-                .append("vfModuleModelName", getVfModuleModelName()).append("CloudRegion", getCloudRegion())
-                .append("callBackUrl", getCallBackUrl()).append("correlator", getCorrelator())
-                .append("serviceInstanceId", getServiceInstanceId())
+                .append("pnfName", getPnfName()).append("serviceType", getServiceType())
+                .append("tenantId", getTenantId()).append("vnfParams", getVnfParams())
+                .append("vnfOutputs", getVnfOutputs()).append("requestBody", getRequestBody())
+                .append("responseBody", getResponseBody()).append("lastModifiedBy", getLastModifiedBy())
+                .append("modifyTime", getModifyTime()).append("volumeGroupId", getVolumeGroupId())
+                .append("volumeGroupName", getVolumeGroupName()).append("vfModuleId", getVfModuleId())
+                .append("vfModuleName", getVfModuleName()).append("vfModuleModelName", getVfModuleModelName())
+                .append("CloudRegion", getCloudRegion()).append("callBackUrl", getCallBackUrl())
+                .append("correlator", getCorrelator()).append("serviceInstanceId", getServiceInstanceId())
                 .append("serviceInstanceName", getServiceInstanceName()).append("requestScope", getRequestScope())
                 .append("requestAction", getRequestAction()).append("networkId", getNetworkId())
                 .append("networkName", getNetworkName()).append("networkType", getNetworkType())
index 8f798a2..6d6b5a8 100644 (file)
@@ -74,8 +74,8 @@ public abstract class InfraRequests implements java.io.Serializable {
     private String source;
     @Column(name = "VNF_ID", length = 45)
     private String vnfId;
-    @Column(name = "PNF_ID", length = 45)
-    private String pnfId;
+    @Column(name = "PNF_NAME", length = 45)
+    private String pnfName;
     @Column(name = "VNF_NAME", length = 80)
     private String vnfName;
     @Column(name = "VNF_TYPE", length = 200)
@@ -249,12 +249,12 @@ public abstract class InfraRequests implements java.io.Serializable {
         this.vnfId = vnfId;
     }
 
-    public String getPnfId() {
-        return this.pnfId;
+    public String getPnfName() {
+        return this.pnfName;
     }
 
-    public void setPnfId(String pnfId) {
-        this.pnfId = pnfId;
+    public void setPnfName(String pnfName) {
+        this.pnfName = pnfName;
     }
 
     public String getVnfName() {
@@ -592,7 +592,7 @@ public abstract class InfraRequests implements java.io.Serializable {
                 .append("flowStatus", getFlowStatus()).append("retryStatusMessage", getRetryStatusMessage())
                 .append("progress", getProgress()).append("startTime", getStartTime()).append("endTime", getEndTime())
                 .append("source", getSource()).append("vnfId", getVnfId()).append("vnfName", getVnfName())
-                .append("pnfId", getPnfId()).append("vnfType", getVnfType()).append("serviceType", getServiceType())
+                .append("pnfName", getPnfName()).append("vnfType", getVnfType()).append("serviceType", getServiceType())
                 .append("tenantId", getTenantId()).append("vnfParams", getVnfParams())
                 .append("vnfOutputs", getVnfOutputs()).append("requestBody", getRequestBody())
                 .append("responseBody", getResponseBody()).append("lastModifiedBy", getLastModifiedBy())