diff options
35 files changed, 1639 insertions, 45 deletions
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/beans/DeploymentInfoBuilder.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/beans/DeploymentInfoBuilder.java index 2e12869c95..3b945ae484 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/beans/DeploymentInfoBuilder.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/beans/DeploymentInfoBuilder.java @@ -44,7 +44,9 @@ public final class DeploymentInfoBuilder { } public DeploymentInfoBuilder withDeploymentOutputs(Map<String, Object> deploymentOutputs) { - this.deploymentOutputs = deploymentOutputs; + if (deploymentOutputs != null) { + this.deploymentOutputs = deploymentOutputs; + } return this; } diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/utils/MsoCloudifyUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/utils/MsoCloudifyUtils.java index bee2d09711..6b16194471 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/utils/MsoCloudifyUtils.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/utils/MsoCloudifyUtils.java @@ -104,7 +104,6 @@ import org.springframework.stereotype.Component; @Component public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{ - private static final String CLOUDIFY_ERROR = "CloudifyError"; private static final String CLOUDIFY = "Cloudify"; private static final String CREATE_DEPLOYMENT = "CreateDeployment"; private static final String DELETE_DEPLOYMENT = "DeleteDeployment"; @@ -258,11 +257,10 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{ if (installWorkflow.getStatus().equals(TERMINATED)) { // Success! // Create and return a DeploymentInfo structure. Include the Runtime outputs - DeploymentOutputs outputs = getDeploymentOutputs (cloudify, deploymentId); return new DeploymentInfoBuilder() .withId(deployment.getId()) .withDeploymentInputs(deployment.getInputs()) - .withDeploymentOutputs(outputs.getOutputs()) + .withDeploymentOutputs(getDeploymentOutputs(cloudify, deploymentId).get()) .fromExecution(installWorkflow) .build(); } @@ -352,16 +350,21 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{ * Get the runtime Outputs of a deployment. * Return the Map of tag/value outputs. */ - private DeploymentOutputs getDeploymentOutputs (Cloudify cloudify, String deploymentId) + private Optional<Map<String, Object>> getDeploymentOutputs (Cloudify cloudify, String deploymentId) throws MsoException { // Build and send the Cloudify request - DeploymentOutputs deploymentOutputs = null; + DeploymentOutputs deploymentOutputs; try { GetDeploymentOutputs queryDeploymentOutputs = cloudify.deployments().outputsById(deploymentId); logger.debug(queryDeploymentOutputs.toString()); deploymentOutputs = executeAndRecordCloudifyRequest(queryDeploymentOutputs); + if (deploymentOutputs != null) { + return Optional.ofNullable(deploymentOutputs.getOutputs()); + } else { + return Optional.empty(); + } } catch (CloudifyConnectException ce) { // Couldn't connect to Cloudify @@ -372,7 +375,7 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{ catch (CloudifyResponseException re) { if (re.getStatus () == 404) { // No Outputs - return null; + return Optional.empty(); } throw new MsoCloudifyException (re.getStatus(), re.getMessage(), re.getLocalizedMessage(), re); } @@ -380,8 +383,6 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{ // Catch-all throw new MsoAdapterException (e.getMessage(), e); } - - return deploymentOutputs; } /* @@ -579,16 +580,11 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{ // Build and send the Cloudify request Deployment deployment = new Deployment(); - DeploymentOutputs outputs = null; try { GetDeployment queryDeployment = cloudify.deployments().byId(deploymentId); logger.debug(queryDeployment.toString()); - -// deployment = queryDeployment.execute(); deployment = executeAndRecordCloudifyRequest(queryDeployment); - outputs = getDeploymentOutputs (cloudify, deploymentId); - // Next look for the latest execution ListExecutions listExecutions = cloudify.executions().listFiltered ("deployment_id=" + deploymentId, "-created_at"); Executions executions = listExecutions.execute(); @@ -604,7 +600,7 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{ return new DeploymentInfoBuilder() .withId(deployment.getId()) .withDeploymentInputs(deployment.getInputs()) - .withDeploymentOutputs(outputs.getOutputs()) + .withDeploymentOutputs(getDeploymentOutputs(cloudify, deploymentId).get()) .fromExecution(executions.getItems().get(0)) .build(); } @@ -623,7 +619,7 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{ return new DeploymentInfoBuilder() .withId(deployment.getId()) .withDeploymentInputs(deployment.getInputs()) - .withDeploymentOutputs(outputs.getOutputs()) + .withDeploymentOutputs(getDeploymentOutputs(cloudify, deploymentId).get()) .build(); } else { // Deployment not found. Default status of a DeploymentInfo object is NOTFOUND @@ -670,12 +666,11 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{ logger.debug ("Ready to Uninstall/Delete Deployment ({})", deploymentId); // Query first to save the trouble if deployment not found - Deployment deployment = null; - try { + try { GetDeployment queryDeploymentRequest = cloudify.deployments().byId(deploymentId); logger.debug(queryDeploymentRequest.toString()); - deployment = executeAndRecordCloudifyRequest (queryDeploymentRequest); + // deployment = executeAndRecordCloudifyRequest (queryDeploymentRequest); } catch (CloudifyResponseException e) { // Since this came on the 'Create Deployment' command, nothing was changed @@ -707,7 +702,7 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{ /* * Query the outputs before deleting so they can be returned as well */ - DeploymentOutputs outputs = getDeploymentOutputs (cloudify, deploymentId); + //DeploymentOutputs outputs = getDeploymentOutputs (cloudify, deploymentId); /* * Next execute the "uninstall" workflow. @@ -745,6 +740,7 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{ // At this point, the deployment has been successfully uninstalled. // Next step is to delete the deployment itself + Deployment deployment; try { DeleteDeployment deleteRequest = cloudify.deployments().deleteByName(deploymentId); logger.debug(deleteRequest.toString()); @@ -781,7 +777,7 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{ return new DeploymentInfoBuilder() .withId(deployment.getId()) .withDeploymentInputs(deployment.getInputs()) - .withDeploymentOutputs(outputs.getOutputs()) + .withDeploymentOutputs(getDeploymentOutputs(cloudify, deploymentId).get()) .fromExecution(uninstallWorkflow) .build(); } diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/beans/DeploymentInfoBuilderTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/beans/DeploymentInfoBuilderTest.java index 8f172b79ca..ce13d98dd1 100644 --- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/beans/DeploymentInfoBuilderTest.java +++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/beans/DeploymentInfoBuilderTest.java @@ -149,6 +149,12 @@ public class DeploymentInfoBuilderTest { verifyDeploymentInfoConstruction(workflowIdLastAction, status, expectedDeploymentStatus); } + @Test + public void shouldSetEmptyOutputsMapWhenInputIsNull() { + DeploymentInfo deploymentInfo = new DeploymentInfoBuilder().withDeploymentOutputs(null).build(); + assertThat(deploymentInfo.getOutputs()).isEmpty(); + } + private void verifyDeploymentInfoConstruction(String workflowIdLastAction, String actionStatus, DeploymentStatus expectedDeploymentStatus) { diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/NetworkAdapterRestTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/NetworkAdapterRestTest.java index 3910d9ec44..4e2d5e5da2 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/NetworkAdapterRestTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/NetworkAdapterRestTest.java @@ -51,9 +51,10 @@ import org.onap.so.adapters.nwrest.CreateNetworkRequest; import org.onap.so.adapters.nwrest.CreateNetworkResponse; import org.onap.so.adapters.nwrest.DeleteNetworkRequest; import org.onap.so.adapters.nwrest.DeleteNetworkResponse; -import org.onap.so.adapters.nwrest.NetworkTechnology; import org.onap.so.adapters.nwrest.QueryNetworkError; import org.onap.so.adapters.nwrest.QueryNetworkResponse; +import org.onap.so.adapters.nwrest.RollbackNetworkRequest; +import org.onap.so.adapters.nwrest.RollbackNetworkResponse; import org.onap.so.adapters.nwrest.UpdateNetworkRequest; import org.onap.so.adapters.nwrest.UpdateNetworkResponse; import org.onap.so.adapters.vnf.BaseRestTestUtils; @@ -193,6 +194,40 @@ public class NetworkAdapterRestTest extends BaseRestTestUtils { } @Test + public void testRollbackNetwork() throws IOException { + + RollbackNetworkRequest request = new RollbackNetworkRequest(); + + MsoRequest msoReq = new MsoRequest(); + + msoReq.setRequestId(MSO_REQUEST_ID); + msoReq.setServiceInstanceId(MSO_SERVICE_INSTANCE_ID); + + mockOpenStackResponseAccess(wireMockPort); + + mockOpenStackPublicUrlStackByID_200(wireMockPort); + + mockOpenStackGetPublicUrlStackByNameAndID_204(wireMockPort); + + mockOpenStackDeletePublicUrlStackByNameAndID_204(); + + headers.add("Accept", MediaType.APPLICATION_JSON); + + HttpEntity<RollbackNetworkRequest> entity = new HttpEntity<>(request, headers); + + ResponseEntity<RollbackNetworkResponse> response = restTemplate + .exchange(createURLWithPort("/services/rest/v1/networks/da886914-efb2-4917-b335-c8381528d90b/rollback"), + HttpMethod.DELETE, entity, RollbackNetworkResponse.class); + + RollbackNetworkResponse expectedResponse = jettisonTypeObjectMapper.getMapper() + .readValue(new File("src/test/resources/__files/RollbackNetworkResponse.json"), RollbackNetworkResponse.class); + + assertThat(response.getBody(), sameBeanAs(expectedResponse)); + assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value()); + + } + + @Test public void testQueryNetwork_Exception() throws IOException{ MsoRequest msoReq = new MsoRequest(); msoReq.setRequestId(MSO_REQUEST_ID); diff --git a/adapters/mso-openstack-adapters/src/test/resources/__files/RollbackNetworkResponse.json b/adapters/mso-openstack-adapters/src/test/resources/__files/RollbackNetworkResponse.json new file mode 100644 index 0000000000..d319fedecd --- /dev/null +++ b/adapters/mso-openstack-adapters/src/test/resources/__files/RollbackNetworkResponse.json @@ -0,0 +1,5 @@ +{ + "rollbackNetworkResponse" : { + "networkRolledBack" : true + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtils.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtils.java index 29abe4413b..0b2ef928ad 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtils.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtils.java @@ -25,11 +25,11 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicReference; import org.camunda.bpm.engine.delegate.DelegateExecution; -import org.onap.ccsdk.apps.controllerblueprints.common.api.ActionIdentifiers; -import org.onap.ccsdk.apps.controllerblueprints.common.api.CommonHeader; -import org.onap.ccsdk.apps.controllerblueprints.common.api.EventType; -import org.onap.ccsdk.apps.controllerblueprints.processing.api.ExecutionServiceInput; -import org.onap.ccsdk.apps.controllerblueprints.processing.api.ExecutionServiceOutput; +import org.onap.ccsdk.cds.controllerblueprints.common.api.ActionIdentifiers; +import org.onap.ccsdk.cds.controllerblueprints.common.api.CommonHeader; +import org.onap.ccsdk.cds.controllerblueprints.common.api.EventType; +import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput; +import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceOutput; import org.onap.so.client.PreconditionFailedException; import org.onap.so.client.RestPropertiesLoader; import org.onap.so.client.cds.beans.AbstractCDSPropertiesBean; diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/VnfResourceTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/VnfResourceTest.java index a83337fc5b..5271bb3c53 100644 --- a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/VnfResourceTest.java +++ b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/VnfResourceTest.java @@ -22,13 +22,17 @@ package org.onap.so.bpmn.core.domain; import static org.junit.Assert.*; import java.io.IOException; +import java.util.ArrayList; import java.util.List; import com.fasterxml.jackson.databind.ObjectMapper; import org.junit.Test; public class VnfResourceTest { - + + private final static String ALL_VF_MODULES_JSON = + "{\"ArrayList\":[{\"resourceType\":\"MODULE\",\"resourceInstance\":{},\"homingSolution\":{\"license\":{},\"rehome\":false},\"vfModuleName\":\"vfModuleName\",\"vfModuleType\":\"vfModuleType\",\"heatStackId\":\"heatStackId\",\"hasVolumeGroup\":true,\"isBase\":true,\"vfModuleLabel\":\"vfModuleLabel\",\"initialCount\":0},{\"resourceType\":\"MODULE\",\"resourceInstance\":{},\"homingSolution\":{\"license\":{},\"rehome\":false},\"vfModuleName\":\"vfModuleName\",\"vfModuleType\":\"vfModuleType\",\"heatStackId\":\"heatStackId\",\"hasVolumeGroup\":true,\"isBase\":true,\"vfModuleLabel\":\"vfModuleLabel\",\"initialCount\":0}]}"; + private VnfResource vnf= new VnfResource(); List<ModuleResource> moduleResources; @@ -63,4 +67,34 @@ public class VnfResourceTest { assertTrue(vnfResource != null); } + @Test + public void testVfModules() { + + moduleResources = new ArrayList<>(); + + ModuleResource moduleresource = new ModuleResource(); + moduleresource.setVfModuleName("vfModuleName"); + moduleresource.setHeatStackId("heatStackId"); + moduleresource.setIsBase(true); + moduleresource.setVfModuleLabel("vfModuleLabel"); + moduleresource.setInitialCount(0); + moduleresource.setVfModuleType("vfModuleType"); + moduleresource.setHasVolumeGroup(true); + + moduleResources.add(moduleresource); + + vnf.setModules(moduleResources); + assertEquals(vnf.getVfModules(), moduleResources); + + List<ModuleResource> moduleResources = vnf.getAllVfModuleObjects(); + assertEquals(1, moduleResources.size()); + + vnf.addVfModule(moduleresource); + moduleResources = vnf.getAllVfModuleObjects(); + assertEquals(2, moduleResources.size()); + + assertEquals(ALL_VF_MODULES_JSON, vnf.getAllVfModulesJson()); + + } + } diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ConfigDeployVnfBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ConfigDeployVnfBB.bpmn new file mode 100644 index 0000000000..92ac5f9f5b --- /dev/null +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ConfigDeployVnfBB.bpmn @@ -0,0 +1,116 @@ +<?xml version="1.0" encoding="UTF-8"?> +<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1556kf5" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="2.2.4"> + <bpmn:process id="ConfigDeployVnfBB" name="ConfigDeployVnfBB" isExecutable="true"> + <bpmn:startEvent id="Start" name="Start"> + <bpmn:outgoing>SequenceFlow_0pd4jka</bpmn:outgoing> + </bpmn:startEvent> + <bpmn:serviceTask id="UpdateAAIConfigured" name="Update AAI Configured" camunda:expression="${ConfigDeployVnf.updateAAIConfigured(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn:incoming>SequenceFlow_1tb7fs1</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_00u29dm</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:endEvent id="End" name="End"> + <bpmn:incoming>SequenceFlow_00u29dm</bpmn:incoming> + </bpmn:endEvent> + <bpmn:sequenceFlow id="SequenceFlow_0pd4jka" sourceRef="Start" targetRef="UpdateAAIConfigure" /> + <bpmn:sequenceFlow id="SequenceFlow_03xbj4e" sourceRef="AbstractCDSBB" targetRef="ExclusiveGateway_0duh80v" /> + <bpmn:sequenceFlow id="SequenceFlow_00u29dm" sourceRef="UpdateAAIConfigured" targetRef="End" /> + <bpmn:callActivity id="AbstractCDSBB" name="Abstract CDS (CDS Call)" calledElement="AbstractCDSProcessingBB"> + <bpmn:extensionElements> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:in source="executionObject" target="executionObject" /> + <camunda:out source="CDSStatus" target="CDSStatus" /> + </bpmn:extensionElements> + <bpmn:incoming>SequenceFlow_0kruy8t</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_03xbj4e</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:serviceTask id="UpdateAAIConfigure" name="Update AAI Configure" camunda:expression="${ConfigDeployVnf.updateAAIConfigure(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn:incoming>SequenceFlow_0pd4jka</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0moyu92</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="SequenceFlow_0moyu92" sourceRef="UpdateAAIConfigure" targetRef="PreProcessAbstractCDSProcessing" /> + <bpmn:sequenceFlow id="SequenceFlow_0kruy8t" sourceRef="PreProcessAbstractCDSProcessing" targetRef="AbstractCDSBB" /> + <bpmn:serviceTask id="PreProcessAbstractCDSProcessing" name="PreProcess Abstract CDS Processing" camunda:expression="${ConfigDeployVnf.preProcessAbstractCDSProcessing(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn:incoming>SequenceFlow_0moyu92</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0kruy8t</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:exclusiveGateway id="ExclusiveGateway_0duh80v" default="SequenceFlow_0o50k2d"> + <bpmn:incoming>SequenceFlow_03xbj4e</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1tb7fs1</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_0o50k2d</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:sequenceFlow id="SequenceFlow_1tb7fs1" name="success" sourceRef="ExclusiveGateway_0duh80v" targetRef="UpdateAAIConfigured"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("CDSStatus").equals("Success")}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="SequenceFlow_0o50k2d" sourceRef="ExclusiveGateway_0duh80v" targetRef="EndEvent_0wwnq4u" /> + <bpmn:endEvent id="EndEvent_0wwnq4u"> + <bpmn:incoming>SequenceFlow_0o50k2d</bpmn:incoming> + <bpmn:errorEventDefinition errorRef="Error_0zsv500" /> + </bpmn:endEvent> + </bpmn:process> + <bpmn:error id="Error_0zsv500" name="MSOWorkflowException" errorCode="MSOWorkflowException" /> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="ConfigDeployVnfBB"> + <bpmndi:BPMNEdge id="SequenceFlow_0pd4jka_di" bpmnElement="SequenceFlow_0pd4jka"> + <di:waypoint x="542" y="248" /> + <di:waypoint x="607" y="248" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_03xbj4e_di" bpmnElement="SequenceFlow_03xbj4e"> + <di:waypoint x="1039" y="248" /> + <di:waypoint x="1089" y="248" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_00u29dm_di" bpmnElement="SequenceFlow_00u29dm"> + <di:waypoint x="1327" y="248" /> + <di:waypoint x="1399" y="248" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="Start"> + <dc:Bounds x="506" y="230" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="512" y="273" width="25" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ServiceTask_0c9apxl_di" bpmnElement="UpdateAAIConfigured"> + <dc:Bounds x="1227" y="208" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_0p7ssqo_di" bpmnElement="End"> + <dc:Bounds x="1399" y="230" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1407" y="273" width="20" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="CallActivity_0vg7uiv_di" bpmnElement="AbstractCDSBB"> + <dc:Bounds x="939" y="208" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ServiceTask_05zt0do_di" bpmnElement="UpdateAAIConfigure"> + <dc:Bounds x="607" y="208" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0moyu92_di" bpmnElement="SequenceFlow_0moyu92"> + <di:waypoint x="707" y="248" /> + <di:waypoint x="770" y="248" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0kruy8t_di" bpmnElement="SequenceFlow_0kruy8t"> + <di:waypoint x="870" y="248" /> + <di:waypoint x="939" y="248" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ServiceTask_0m4kmps_di" bpmnElement="PreProcessAbstractCDSProcessing"> + <dc:Bounds x="770" y="208" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ExclusiveGateway_0duh80v_di" bpmnElement="ExclusiveGateway_0duh80v" isMarkerVisible="true"> + <dc:Bounds x="1089" y="223" width="50" height="50" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1tb7fs1_di" bpmnElement="SequenceFlow_1tb7fs1"> + <di:waypoint x="1139" y="248" /> + <di:waypoint x="1227" y="248" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1163" y="230" width="41" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0o50k2d_di" bpmnElement="SequenceFlow_0o50k2d"> + <di:waypoint x="1114" y="273" /> + <di:waypoint x="1114" y="348" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="EndEvent_1p3d0t4_di" bpmnElement="EndEvent_0wwnq4u"> + <dc:Bounds x="1096" y="348" width="36" height="36" /> + </bpmndi:BPMNShape> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn:definitions> diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java index bc6770cc81..82b61c17b5 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java @@ -538,4 +538,26 @@ public class AAIUpdateTasks { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } } + + public void updateOrchestrationStausConfigDeployConfigureVnf(BuildingBlockExecution execution){ + try{ + GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID); + aaiVnfResources.updateOrchestrationStatusVnf(vnf, OrchestrationStatus.CONFIGURE); + + }catch(Exception ex){ + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); + } + + } + + public void updateOrchestrationStausConfigDeployConfiguredVnf(BuildingBlockExecution execution){ + try{ + GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID); + aaiVnfResources.updateOrchestrationStatusVnf(vnf, OrchestrationStatus.CONFIGURED); + + }catch(Exception ex){ + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); + } + + } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigDeployVnf.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigDeployVnf.java new file mode 100644 index 0000000000..1bc7c0f574 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigDeployVnf.java @@ -0,0 +1,130 @@ +/* +* ============LICENSE_START======================================================= +* ONAP : SO +* ================================================================================ +* Copyright 2019 TechMahindra +*================================================================================= +* 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.flowspecific.tasks; + +import java.util.UUID; + +import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.infrastructure.aai.tasks.AAIUpdateTasks; +import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; +import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock; +import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; +import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB; +import org.onap.so.client.cds.beans.AbstractCDSPropertiesBean; +import org.onap.so.client.cds.beans.ConfigDeployPropertiesForVnf; +import org.onap.so.client.cds.beans.ConfigDeployRequestVnf; +import org.onap.so.client.exception.ExceptionBuilder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * + * Get vnf related data and config Deploy + * + */ +@Component +public class ConfigDeployVnf { + private static final Logger logger = LoggerFactory.getLogger(ConfigDeployVnf.class); + private final static String ORIGINATOR_ID = "SO"; + private final static String ACTION_NAME = "config-deploy"; + private final static String MODE = "async"; + + @Autowired + private ExceptionBuilder exceptionUtil; + @Autowired + private ExtractPojosForBB extractPojosForBB; + @Autowired + private AAIUpdateTasks aaiUpdateTask; + + /** + * Update vnf orch status to configure in AAI + * + * @param execution + */ + public void updateAAIConfigure(BuildingBlockExecution execution) { + aaiUpdateTask.updateOrchestrationStausConfigDeployConfigureVnf(execution); + + } + /** + * Getting the vnf object and set in execution object + * + * @param execution + * + * + */ + public void preProcessAbstractCDSProcessing(BuildingBlockExecution execution) { + + + logger.info("Start preProcessAbstractCDSProcessing"); + try { + GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID); + + ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID); + + ConfigDeployPropertiesForVnf configDeployPropertiesForVnf = new ConfigDeployPropertiesForVnf(); + configDeployPropertiesForVnf.setServiceInstanceId(serviceInstance.getServiceInstanceId()); + configDeployPropertiesForVnf.setServiceModelUuid(serviceInstance.getModelInfoServiceInstance().getModelUuid()); + configDeployPropertiesForVnf.setVnfCustomizationUuid(vnf.getModelInfoGenericVnf().getModelCustomizationUuid()); + configDeployPropertiesForVnf.setVnfId(vnf.getVnfId()); + configDeployPropertiesForVnf.setVnfName(vnf.getVnfName()); + + ConfigDeployRequestVnf configDeployRequestVnf = new ConfigDeployRequestVnf(); + + configDeployRequestVnf.setResolutionKey(vnf.getVnfName()); + configDeployRequestVnf.setConfigDeployPropertiesForVnf(configDeployPropertiesForVnf); + + String blueprintName = vnf.getBlueprintName(); + String blueprintVersion = vnf.getBlueprintVersion(); + AbstractCDSPropertiesBean abstractCDSPropertiesBean = new AbstractCDSPropertiesBean(); + + abstractCDSPropertiesBean.setBlueprintName(blueprintName); + abstractCDSPropertiesBean.setBlueprintVersion(blueprintVersion); + abstractCDSPropertiesBean.setRequestObject(configDeployRequestVnf.toString()); + + + GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock(); + + abstractCDSPropertiesBean.setOriginatorId( ORIGINATOR_ID); + abstractCDSPropertiesBean.setRequestId(gBBInput.getRequestContext().getMsoRequestId()); + abstractCDSPropertiesBean.setSubRequestId(UUID.randomUUID().toString()); + abstractCDSPropertiesBean.setActionName(ACTION_NAME); + abstractCDSPropertiesBean.setMode(MODE); + + execution.setVariable("executionObject", abstractCDSPropertiesBean); + + } catch (Exception ex) { + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); + } + } + + /** + * Update vnf orch status to configured in AAI + * + * @param execution + */ + public void updateAAIConfigured(BuildingBlockExecution execution) { + aaiUpdateTask.updateOrchestrationStausConfigDeployConfiguredVnf(execution); + + } +}
\ No newline at end of file diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java index 78d08aa1f1..05af58040a 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java @@ -655,4 +655,17 @@ public class AAIUpdateTasksTest extends BaseTaskTest{ aaiUpdateTasks.updateManagementV6AddressVnf(execution); verify(aaiVnfResources, times(0)).updateObjectVnf(genericVnf); } + + @Test + public void updateOrchestrationStatusVnfConfigureTest() throws Exception { + doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.CONFIGURE); + + aaiUpdateTasks.updateOrchestrationStausConfigDeployConfigureVnf(execution); + } + @Test + public void updateOrchestrationStatusVnfConfiguredTest() throws Exception { + doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.CONFIGURED); + + aaiUpdateTasks.updateOrchestrationStausConfigDeployConfiguredVnf(execution); + } } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigDeployVnfTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigDeployVnfTest.java new file mode 100644 index 0000000000..e5aa702dad --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigDeployVnfTest.java @@ -0,0 +1,97 @@ + +/* +* ============LICENSE_START======================================================= +* ONAP : SO +* ================================================================================ +* Copyright 2019 TechMahindra +*================================================================================= +* 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.flowspecific.tasks; + +import static org.junit.Assert.assertTrue; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.doThrow; +import static org.mockito.Mockito.when; + +import java.util.UUID; + +import org.camunda.bpm.engine.delegate.BpmnError; +import org.junit.Before; +import org.junit.Test; +import org.mockito.ArgumentMatchers; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.onap.so.bpmn.BaseTaskTest; +import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.infrastructure.aai.tasks.AAIUpdateTasks; +import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; +import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; +import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; +import org.onap.so.client.exception.BBObjectNotFoundException; + +public class ConfigDeployVnfTest extends BaseTaskTest { + + @InjectMocks + private ConfigDeployVnf configDeployVnf = new ConfigDeployVnf(); + @Mock + AAIUpdateTasks aAIUpdateTasks = new AAIUpdateTasks(); + + + private GenericVnf genericVnf; + private ServiceInstance serviceInstance; + private RequestContext requestContext; + private String msoRequestId; + + @Before + public void before() throws BBObjectNotFoundException { + genericVnf = setGenericVnf(); + serviceInstance = setServiceInstance(); + msoRequestId = UUID.randomUUID().toString(); + requestContext = setRequestContext(); + requestContext.setMsoRequestId(msoRequestId); + gBBInput.setRequestContext(requestContext); + + doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class)); + when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(genericVnf); + when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID))).thenReturn(serviceInstance); + } + + + + @Test + public void preProcessAbstractCDSProcessingTest() throws Exception { + + configDeployVnf.preProcessAbstractCDSProcessing(execution); + + assertTrue(true); + } + + @Test + public void updateAAIConfigureTaskTest() throws Exception { + + configDeployVnf.updateAAIConfigure(execution); + assertTrue(true); + } + + @Test + public void updateAAIConfiguredTaskTest() throws Exception { + configDeployVnf.updateAAIConfigured(execution); + assertTrue(true); + } + +} diff --git a/common/pom.xml b/common/pom.xml index 883d48c21c..2a9f88f6d2 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -15,7 +15,7 @@ <grpc.version>1.17.1</grpc.version> <protobuf.version>3.6.1</protobuf.version> <grpc.netty.version>4.1.30.Final</grpc.netty.version> - <ccsdk.version>0.4.1-SNAPSHOT</ccsdk.version> + <ccsdk.version>0.4.2-SNAPSHOT</ccsdk.version> </properties> <dependencies> @@ -143,7 +143,7 @@ <!-- CDS dependencies --> <dependency> - <groupId>org.onap.ccsdk.apps.components</groupId> + <groupId>org.onap.ccsdk.cds.components</groupId> <artifactId>proto-definition</artifactId> <version>${ccsdk.version}</version> </dependency> diff --git a/common/src/main/java/org/onap/so/client/RestTemplateConfig.java b/common/src/main/java/org/onap/so/client/RestTemplateConfig.java index 34ad6ef758..0633ae74c9 100644 --- a/common/src/main/java/org/onap/so/client/RestTemplateConfig.java +++ b/common/src/main/java/org/onap/so/client/RestTemplateConfig.java @@ -26,6 +26,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Primary; import org.springframework.http.client.BufferingClientHttpRequestFactory; import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; import org.springframework.web.client.RestTemplate; @@ -39,6 +40,7 @@ public class RestTemplateConfig { private HttpComponentsClientConfiguration httpComponentsClientConfiguration; @Bean + @Primary public RestTemplate restTemplate() { final RestTemplate restTemplate = new RestTemplate(); restTemplate diff --git a/common/src/main/java/org/onap/so/client/cds/CDSProcessingClient.java b/common/src/main/java/org/onap/so/client/cds/CDSProcessingClient.java index 756c26ddef..9b2fd3fdb0 100644 --- a/common/src/main/java/org/onap/so/client/cds/CDSProcessingClient.java +++ b/common/src/main/java/org/onap/so/client/cds/CDSProcessingClient.java @@ -25,7 +25,7 @@ import io.grpc.internal.DnsNameResolverProvider; import io.grpc.internal.PickFirstLoadBalancerProvider; import io.grpc.netty.NettyChannelBuilder; import java.util.concurrent.CountDownLatch; -import org.onap.ccsdk.apps.controllerblueprints.processing.api.ExecutionServiceInput; +import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput; import org.onap.so.client.PreconditionFailedException; import org.onap.so.client.RestPropertiesLoader; import org.slf4j.Logger; diff --git a/common/src/main/java/org/onap/so/client/cds/CDSProcessingHandler.java b/common/src/main/java/org/onap/so/client/cds/CDSProcessingHandler.java index 1791be2991..4b86493f79 100644 --- a/common/src/main/java/org/onap/so/client/cds/CDSProcessingHandler.java +++ b/common/src/main/java/org/onap/so/client/cds/CDSProcessingHandler.java @@ -23,11 +23,11 @@ package org.onap.so.client.cds; import io.grpc.ManagedChannel; import io.grpc.stub.StreamObserver; import java.util.concurrent.CountDownLatch; -import org.onap.ccsdk.apps.controllerblueprints.common.api.ActionIdentifiers; -import org.onap.ccsdk.apps.controllerblueprints.processing.api.BluePrintProcessingServiceGrpc; -import org.onap.ccsdk.apps.controllerblueprints.processing.api.BluePrintProcessingServiceGrpc.BluePrintProcessingServiceStub; -import org.onap.ccsdk.apps.controllerblueprints.processing.api.ExecutionServiceInput; -import org.onap.ccsdk.apps.controllerblueprints.processing.api.ExecutionServiceOutput; +import org.onap.ccsdk.cds.controllerblueprints.common.api.ActionIdentifiers; +import org.onap.ccsdk.cds.controllerblueprints.processing.api.BluePrintProcessingServiceGrpc; +import org.onap.ccsdk.cds.controllerblueprints.processing.api.BluePrintProcessingServiceGrpc.BluePrintProcessingServiceStub; +import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput; +import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceOutput; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/common/src/main/java/org/onap/so/client/cds/CDSProcessingListener.java b/common/src/main/java/org/onap/so/client/cds/CDSProcessingListener.java index 8c92a5810c..ed7b4e51ba 100644 --- a/common/src/main/java/org/onap/so/client/cds/CDSProcessingListener.java +++ b/common/src/main/java/org/onap/so/client/cds/CDSProcessingListener.java @@ -20,7 +20,7 @@ package org.onap.so.client.cds; -import org.onap.ccsdk.apps.controllerblueprints.processing.api.ExecutionServiceOutput; +import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceOutput; public interface CDSProcessingListener { diff --git a/common/src/test/java/org/onap/so/client/cds/CDSProcessingClientTest.java b/common/src/test/java/org/onap/so/client/cds/CDSProcessingClientTest.java index 135277fa47..f6bf21458d 100644 --- a/common/src/test/java/org/onap/so/client/cds/CDSProcessingClientTest.java +++ b/common/src/test/java/org/onap/so/client/cds/CDSProcessingClientTest.java @@ -42,10 +42,10 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; import org.mockito.Mock; -import org.onap.ccsdk.apps.controllerblueprints.common.api.ActionIdentifiers; -import org.onap.ccsdk.apps.controllerblueprints.processing.api.BluePrintProcessingServiceGrpc.BluePrintProcessingServiceImplBase; -import org.onap.ccsdk.apps.controllerblueprints.processing.api.ExecutionServiceInput; -import org.onap.ccsdk.apps.controllerblueprints.processing.api.ExecutionServiceOutput; +import org.onap.ccsdk.cds.controllerblueprints.common.api.ActionIdentifiers; +import org.onap.ccsdk.cds.controllerblueprints.processing.api.BluePrintProcessingServiceGrpc.BluePrintProcessingServiceImplBase; +import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput; +import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceOutput; @RunWith(JUnit4.class) public class CDSProcessingClientTest { diff --git a/common/src/test/java/org/onap/so/client/cds/TestCDSProcessingListener.java b/common/src/test/java/org/onap/so/client/cds/TestCDSProcessingListener.java index 977f1d41be..ce515e162e 100644 --- a/common/src/test/java/org/onap/so/client/cds/TestCDSProcessingListener.java +++ b/common/src/test/java/org/onap/so/client/cds/TestCDSProcessingListener.java @@ -21,7 +21,7 @@ package org.onap.so.client.cds; import io.grpc.Status; -import org.onap.ccsdk.apps.controllerblueprints.processing.api.ExecutionServiceOutput; +import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceOutput; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/common/src/test/java/org/onap/so/client/cds/TestCDSPropertiesImpl.java b/common/src/test/java/org/onap/so/client/cds/TestCDSPropertiesImpl.java index b0e67090ff..636f92835f 100644 --- a/common/src/test/java/org/onap/so/client/cds/TestCDSPropertiesImpl.java +++ b/common/src/test/java/org/onap/so/client/cds/TestCDSPropertiesImpl.java @@ -15,7 +15,6 @@ */ package org.onap.so.client.cds; -import java.net.MalformedURLException; import java.net.URL; public class TestCDSPropertiesImpl implements CDSProperties { diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/JerseyConfiguration.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/JerseyConfiguration.java index 182e398461..5790f1afe9 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/JerseyConfiguration.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/JerseyConfiguration.java @@ -62,6 +62,7 @@ public class JerseyConfiguration extends ResourceConfig { register(RuntimeExceptionMapper.class); register(RequestUriFilter.class); register(E2EServiceInstances.class); + register(WorkflowSpecificationsHandler.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); diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/WorkflowSpecificationsHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/WorkflowSpecificationsHandler.java new file mode 100644 index 0000000000..b58a3cdddc --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/WorkflowSpecificationsHandler.java @@ -0,0 +1,90 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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.apihandlerinfra; + +import java.nio.file.Files; +import java.nio.file.Paths; + +import javax.transaction.Transactional; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.Response; + +import org.apache.http.HttpStatus; + +import org.onap.so.apihandler.common.ErrorNumbers; +import org.onap.so.apihandler.common.ResponseBuilder; +import org.onap.so.apihandlerinfra.exceptions.ValidateException; + +import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo; +import org.onap.so.apihandlerinfra.workflowspecificationbeans.WorkflowSpecifications; +import org.onap.so.logger.ErrorCode; +import org.onap.so.logger.MessageEnum; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; + +@Path("onap/so/infra/workflowSpecifications") +@Api(value="onap/so/infra/workflowSpecifications",description="Queries of Workflow Specifications") +@Component +public class WorkflowSpecificationsHandler { + + @Autowired + private ResponseBuilder builder; + + @Path("/{version:[vV]1}/workflows") + @GET + @ApiOperation(value="Finds Workflow Specifications",response=Response.class) + @Transactional + public Response queryFilters (@QueryParam("vnfModelVersionId") String vnfModelVersionId, + @PathParam("version") String version) throws Exception { + + String apiVersion = version.substring(1); + + ObjectMapper mapper1 = new ObjectMapper(); + mapper1.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + + //Replace with Catalog DB Query + WorkflowSpecifications workflowSpecifications = mapper1.readValue(new String(Files.readAllBytes(Paths.get("src/test/resources/__files/WorkflowSpecifications.json"))), WorkflowSpecifications.class); + + String jsonResponse = null; + try { + ObjectMapper mapper = new ObjectMapper(); + jsonResponse = mapper.writeValueAsString(workflowSpecifications); + } + catch (JsonProcessingException e) { + ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, ErrorCode.SchemaError).build(); + ValidateException validateException = new ValidateException.Builder("Mapping of request to JSON object failed : " + e.getMessage(), + HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e).errorInfo(errorLoggerInfo).build(); + throw validateException; + } + + return builder.buildResponse(HttpStatus.SC_ACCEPTED, "", jsonResponse, apiVersion); + } +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/workflowspecificationbeans/ActivitySequence.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/workflowspecificationbeans/ActivitySequence.java new file mode 100644 index 0000000000..594b43e07d --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/workflowspecificationbeans/ActivitySequence.java @@ -0,0 +1,86 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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.apihandlerinfra.workflowspecificationbeans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "name", + "description" +}) +public class ActivitySequence { + + @JsonProperty("name") + private String name; + @JsonProperty("description") + private String description; + + /** + * No args constructor for use in serialization + * + */ + public ActivitySequence() { + } + + /** + * + * @param description + * @param name + */ + public ActivitySequence(String name, String description) { + super(); + this.name = name; + this.description = description; + } + + @JsonProperty("name") + public String getName() { + return name; + } + + @JsonProperty("name") + public void setName(String name) { + this.name = name; + } + + public ActivitySequence withName(String name) { + this.name = name; + return this; + } + + @JsonProperty("description") + public String getDescription() { + return description; + } + + @JsonProperty("description") + public void setDescription(String description) { + this.description = description; + } + + public ActivitySequence withDescription(String description) { + this.description = description; + return this; + } + +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/workflowspecificationbeans/ArtifactInfo.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/workflowspecificationbeans/ArtifactInfo.java new file mode 100644 index 0000000000..0861ff2033 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/workflowspecificationbeans/ArtifactInfo.java @@ -0,0 +1,226 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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.apihandlerinfra.workflowspecificationbeans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "artifactType", + "artifactUuid", + "artifactName", + "artifactVersion", + "artifactDescription", + "workflowName", + "operationName", + "workflowSource", + "workflowResourceTarget" +}) +public class ArtifactInfo { + + @JsonProperty("artifactType") + private String artifactType; + @JsonProperty("artifactUuid") + private String artifactUuid; + @JsonProperty("artifactName") + private String artifactName; + @JsonProperty("artifactVersion") + private String artifactVersion; + @JsonProperty("artifactDescription") + private String artifactDescription; + @JsonProperty("workflowName") + private String workflowName; + @JsonProperty("operationName") + private String operationName; + @JsonProperty("workflowSource") + private String workflowSource; + @JsonProperty("workflowResourceTarget") + private String workflowResourceTarget; + + /** + * No args constructor for use in serialization + * + */ + public ArtifactInfo() { + } + + /** + * + * @param artifactName + * @param workflowName + * @param artifactType + * @param operationName + * @param artifactVersion + * @param workflowResourceTarget + * @param workflowSource + * @param artifactUuid + * @param artifactDescription + */ + public ArtifactInfo(String artifactType, String artifactUuid, String artifactName, String artifactVersion, String artifactDescription, String workflowName, String operationName, String workflowSource, String workflowResourceTarget) { + super(); + this.artifactType = artifactType; + this.artifactUuid = artifactUuid; + this.artifactName = artifactName; + this.artifactVersion = artifactVersion; + this.artifactDescription = artifactDescription; + this.workflowName = workflowName; + this.operationName = operationName; + this.workflowSource = workflowSource; + this.workflowResourceTarget = workflowResourceTarget; + } + + @JsonProperty("artifactType") + public String getArtifactType() { + return artifactType; + } + + @JsonProperty("artifactType") + public void setArtifactType(String artifactType) { + this.artifactType = artifactType; + } + + public ArtifactInfo withArtifactType(String artifactType) { + this.artifactType = artifactType; + return this; + } + + @JsonProperty("artifactUuid") + public String getArtifactUuid() { + return artifactUuid; + } + + @JsonProperty("artifactUuid") + public void setArtifactUuid(String artifactUuid) { + this.artifactUuid = artifactUuid; + } + + public ArtifactInfo withArtifactUuid(String artifactUuid) { + this.artifactUuid = artifactUuid; + return this; + } + + @JsonProperty("artifactName") + public String getArtifactName() { + return artifactName; + } + + @JsonProperty("artifactName") + public void setArtifactName(String artifactName) { + this.artifactName = artifactName; + } + + public ArtifactInfo withArtifactName(String artifactName) { + this.artifactName = artifactName; + return this; + } + + @JsonProperty("artifactVersion") + public String getArtifactVersion() { + return artifactVersion; + } + + @JsonProperty("artifactVersion") + public void setArtifactVersion(String artifactVersion) { + this.artifactVersion = artifactVersion; + } + + public ArtifactInfo withArtifactVersion(String artifactVersion) { + this.artifactVersion = artifactVersion; + return this; + } + + @JsonProperty("artifactDescription") + public String getArtifactDescription() { + return artifactDescription; + } + + @JsonProperty("artifactDescription") + public void setArtifactDescription(String artifactDescription) { + this.artifactDescription = artifactDescription; + } + + public ArtifactInfo withArtifactDescription(String artifactDescription) { + this.artifactDescription = artifactDescription; + return this; + } + + @JsonProperty("workflowName") + public String getWorkflowName() { + return workflowName; + } + + @JsonProperty("workflowName") + public void setWorkflowName(String workflowName) { + this.workflowName = workflowName; + } + + public ArtifactInfo withWorkflowName(String workflowName) { + this.workflowName = workflowName; + return this; + } + + @JsonProperty("operationName") + public String getOperationName() { + return operationName; + } + + @JsonProperty("operationName") + public void setOperationName(String operationName) { + this.operationName = operationName; + } + + public ArtifactInfo withOperationName(String operationName) { + this.operationName = operationName; + return this; + } + + @JsonProperty("workflowSource") + public String getWorkflowSource() { + return workflowSource; + } + + @JsonProperty("workflowSource") + public void setWorkflowSource(String workflowSource) { + this.workflowSource = workflowSource; + } + + public ArtifactInfo withWorkflowSource(String workflowSource) { + this.workflowSource = workflowSource; + return this; + } + + @JsonProperty("workflowResourceTarget") + public String getWorkflowResourceTarget() { + return workflowResourceTarget; + } + + @JsonProperty("workflowResourceTarget") + public void setWorkflowResourceTarget(String workflowResourceTarget) { + this.workflowResourceTarget = workflowResourceTarget; + } + + public ArtifactInfo withWorkflowResourceTarget(String workflowResourceTarget) { + this.workflowResourceTarget = workflowResourceTarget; + return this; + } + +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/workflowspecificationbeans/Validation.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/workflowspecificationbeans/Validation.java new file mode 100644 index 0000000000..3a4d5cb5f0 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/workflowspecificationbeans/Validation.java @@ -0,0 +1,86 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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.apihandlerinfra.workflowspecificationbeans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "maxLength", + "allowableChars" +}) +public class Validation { + + @JsonProperty("maxLength") + private String maxLength; + @JsonProperty("allowableChars") + private String allowableChars; + + /** + * No args constructor for use in serialization + * + */ + public Validation() { + } + + /** + * + * @param maxLength + * @param allowableChars + */ + public Validation(String maxLength, String allowableChars) { + super(); + this.maxLength = maxLength; + this.allowableChars = allowableChars; + } + + @JsonProperty("maxLength") + public String getMaxLength() { + return maxLength; + } + + @JsonProperty("maxLength") + public void setMaxLength(String maxLength) { + this.maxLength = maxLength; + } + + public Validation withMaxLength(String maxLength) { + this.maxLength = maxLength; + return this; + } + + @JsonProperty("allowableChars") + public String getAllowableChars() { + return allowableChars; + } + + @JsonProperty("allowableChars") + public void setAllowableChars(String allowableChars) { + this.allowableChars = allowableChars; + } + + public Validation withAllowableChars(String allowableChars) { + this.allowableChars = allowableChars; + return this; + } + +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/workflowspecificationbeans/WorkflowInputParameter.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/workflowspecificationbeans/WorkflowInputParameter.java new file mode 100644 index 0000000000..416442c216 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/workflowspecificationbeans/WorkflowInputParameter.java @@ -0,0 +1,167 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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.apihandlerinfra.workflowspecificationbeans; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "label", + "inputType", + "required", + "validation", + "soFieldName", + "soPayloadLocation" +}) +public class WorkflowInputParameter { + + @JsonProperty("label") + private String label; + @JsonProperty("inputType") + private String inputType; + @JsonProperty("required") + private Boolean required; + @JsonProperty("validation") + private List<Validation> validation = null; + @JsonProperty("soFieldName") + private String soFieldName; + @JsonProperty("soPayloadLocation") + private String soPayloadLocation; + + /** + * No args constructor for use in serialization + * + */ + public WorkflowInputParameter() { + } + + /** + * + * @param validation + * @param inputType + * @param soPayloadLocation + * @param label + * @param required + * @param soFieldName + */ + public WorkflowInputParameter(String label, String inputType, Boolean required, List<Validation> validation, String soFieldName, String soPayloadLocation) { + super(); + this.label = label; + this.inputType = inputType; + this.required = required; + this.validation = validation; + this.soFieldName = soFieldName; + this.soPayloadLocation = soPayloadLocation; + } + + @JsonProperty("label") + public String getLabel() { + return label; + } + + @JsonProperty("label") + public void setLabel(String label) { + this.label = label; + } + + public WorkflowInputParameter withLabel(String label) { + this.label = label; + return this; + } + + @JsonProperty("inputType") + public String getInputType() { + return inputType; + } + + @JsonProperty("inputType") + public void setInputType(String inputType) { + this.inputType = inputType; + } + + public WorkflowInputParameter withInputType(String inputType) { + this.inputType = inputType; + return this; + } + + @JsonProperty("required") + public Boolean getRequired() { + return required; + } + + @JsonProperty("required") + public void setRequired(Boolean required) { + this.required = required; + } + + public WorkflowInputParameter withRequired(Boolean required) { + this.required = required; + return this; + } + + @JsonProperty("validation") + public List<Validation> getValidation() { + return validation; + } + + @JsonProperty("validation") + public void setValidation(List<Validation> validation) { + this.validation = validation; + } + + public WorkflowInputParameter withValidation(List<Validation> validation) { + this.validation = validation; + return this; + } + + @JsonProperty("soFieldName") + public String getSoFieldName() { + return soFieldName; + } + + @JsonProperty("soFieldName") + public void setSoFieldName(String soFieldName) { + this.soFieldName = soFieldName; + } + + public WorkflowInputParameter withSoFieldName(String soFieldName) { + this.soFieldName = soFieldName; + return this; + } + + @JsonProperty("soPayloadLocation") + public String getSoPayloadLocation() { + return soPayloadLocation; + } + + @JsonProperty("soPayloadLocation") + public void setSoPayloadLocation(String soPayloadLocation) { + this.soPayloadLocation = soPayloadLocation; + } + + public WorkflowInputParameter withSoPayloadLocation(String soPayloadLocation) { + this.soPayloadLocation = soPayloadLocation; + return this; + } + +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/workflowspecificationbeans/WorkflowSpecification.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/workflowspecificationbeans/WorkflowSpecification.java new file mode 100644 index 0000000000..86dc44ef39 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/workflowspecificationbeans/WorkflowSpecification.java @@ -0,0 +1,107 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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.apihandlerinfra.workflowspecificationbeans; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "artifactInfo", + "activitySequence", + "workflowInputParameters" +}) +public class WorkflowSpecification { + + @JsonProperty("artifactInfo") + private ArtifactInfo artifactInfo; + @JsonProperty("activitySequence") + private List<ActivitySequence> activitySequence = null; + @JsonProperty("workflowInputParameters") + private List<WorkflowInputParameter> workflowInputParameters = null; + + /** + * No args constructor for use in serialization + * + */ + public WorkflowSpecification() { + } + + /** + * + * @param activitySequence + * @param artifactInfo + * @param workflowInputParameters + */ + public WorkflowSpecification(ArtifactInfo artifactInfo, List<ActivitySequence> activitySequence, List<WorkflowInputParameter> workflowInputParameters) { + super(); + this.artifactInfo = artifactInfo; + this.activitySequence = activitySequence; + this.workflowInputParameters = workflowInputParameters; + } + + @JsonProperty("artifactInfo") + public ArtifactInfo getArtifactInfo() { + return artifactInfo; + } + + @JsonProperty("artifactInfo") + public void setArtifactInfo(ArtifactInfo artifactInfo) { + this.artifactInfo = artifactInfo; + } + + public WorkflowSpecification withArtifactInfo(ArtifactInfo artifactInfo) { + this.artifactInfo = artifactInfo; + return this; + } + + @JsonProperty("activitySequence") + public List<ActivitySequence> getActivitySequence() { + return activitySequence; + } + + @JsonProperty("activitySequence") + public void setActivitySequence(List<ActivitySequence> activitySequence) { + this.activitySequence = activitySequence; + } + + public WorkflowSpecification withActivitySequence(List<ActivitySequence> activitySequence) { + this.activitySequence = activitySequence; + return this; + } + + @JsonProperty("workflowInputParameters") + public List<WorkflowInputParameter> getWorkflowInputParameters() { + return workflowInputParameters; + } + + @JsonProperty("workflowInputParameters") + public void setWorkflowInputParameters(List<WorkflowInputParameter> workflowInputParameters) { + this.workflowInputParameters = workflowInputParameters; + } + + public WorkflowSpecification withWorkflowInputParameters(List<WorkflowInputParameter> workflowInputParameters) { + this.workflowInputParameters = workflowInputParameters; + return this; + } + +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/workflowspecificationbeans/WorkflowSpecificationList.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/workflowspecificationbeans/WorkflowSpecificationList.java new file mode 100644 index 0000000000..c6bf4e3d41 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/workflowspecificationbeans/WorkflowSpecificationList.java @@ -0,0 +1,66 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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.apihandlerinfra.workflowspecificationbeans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "workflowSpecification" +}) +public class WorkflowSpecificationList { + + @JsonProperty("workflowSpecification") + private WorkflowSpecification workflowSpecification; + + /** + * No args constructor for use in serialization + * + */ + public WorkflowSpecificationList() { + } + + /** + * + * @param workflowSpecification + */ + public WorkflowSpecificationList(WorkflowSpecification workflowSpecification) { + super(); + this.workflowSpecification = workflowSpecification; + } + + @JsonProperty("workflowSpecification") + public WorkflowSpecification getWorkflowSpecification() { + return workflowSpecification; + } + + @JsonProperty("workflowSpecification") + public void setWorkflowSpecification(WorkflowSpecification workflowSpecification) { + this.workflowSpecification = workflowSpecification; + } + + public WorkflowSpecificationList withWorkflowSpecification(WorkflowSpecification workflowSpecification) { + this.workflowSpecification = workflowSpecification; + return this; + } + +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/workflowspecificationbeans/WorkflowSpecifications.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/workflowspecificationbeans/WorkflowSpecifications.java new file mode 100644 index 0000000000..ffe9980af4 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/workflowspecificationbeans/WorkflowSpecifications.java @@ -0,0 +1,67 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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.apihandlerinfra.workflowspecificationbeans; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "workflowSpecificationList" +}) +public class WorkflowSpecifications { + + @JsonProperty("workflowSpecificationList") + private List<WorkflowSpecificationList> workflowSpecificationList = null; + + /** + * No args constructor for use in serialization + * + */ + public WorkflowSpecifications() { + } + + /** + * + * @param workflowSpecificationList + */ + public WorkflowSpecifications(List<WorkflowSpecificationList> workflowSpecificationList) { + super(); + this.workflowSpecificationList = workflowSpecificationList; + } + + @JsonProperty("workflowSpecificationList") + public List<WorkflowSpecificationList> getWorkflowSpecificationList() { + return workflowSpecificationList; + } + + @JsonProperty("workflowSpecificationList") + public void setWorkflowSpecificationList(List<WorkflowSpecificationList> workflowSpecificationList) { + this.workflowSpecificationList = workflowSpecificationList; + } + + public WorkflowSpecifications withWorkflowSpecificationList(List<WorkflowSpecificationList> workflowSpecificationList) { + this.workflowSpecificationList = workflowSpecificationList; + return this; + } + +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/BeanMultiTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/BeanMultiTest.java index 68c5c918ba..e249c2d8ef 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/BeanMultiTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/BeanMultiTest.java @@ -53,6 +53,7 @@ public class BeanMultiTest { test("org.onap.so.apihandlerinfra.tasksbeans"); test("org.onap.so.apihandlerinfra.vnfbeans"); test("org.onap.so.apihandlerinfra.tenantisolationbeans"); + test("org.onap.so.apihandlerinfra.workflowspecificationbeans"); } private void test(String packageName) { diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/WorkflowSpecificationsHandlerTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/WorkflowSpecificationsHandlerTest.java new file mode 100644 index 0000000000..1a2eca6300 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/WorkflowSpecificationsHandlerTest.java @@ -0,0 +1,82 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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.apihandlerinfra; + +import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThat; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.text.ParseException; + +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +import org.json.JSONException; +import org.junit.Test; +import org.onap.so.apihandlerinfra.workflowspecificationbeans.WorkflowSpecifications; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.ResponseEntity; +import org.springframework.web.util.UriComponentsBuilder; + +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +public class WorkflowSpecificationsHandlerTest extends BaseTest{ + + private final String basePath = "onap/so/infra/workflowSpecifications/v1/workflows"; + + @Test + public void getTasksTestByOriginalRequestId() throws ParseException, JSONException, JsonParseException, JsonMappingException, IOException{ + + HttpHeaders headers = new HttpHeaders(); + headers.set("Accept", MediaType.APPLICATION_JSON); + headers.set("Content-Type", MediaType.APPLICATION_JSON); + HttpEntity<String> entity = new HttpEntity<String>(null, headers); + + UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(basePath)) + .queryParam("vnfModelVersionId", "b5fa707a-f55a-11e7-a796-005056856d52"); + + ResponseEntity<String> response = restTemplate.exchange( + builder.toUriString(), + HttpMethod.GET, entity, String.class); + + ObjectMapper mapper = new ObjectMapper(); + + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + + WorkflowSpecifications expectedResponse = mapper.readValue(new String(Files.readAllBytes(Paths.get("src/test/resources/__files/WorkflowSpecifications.json"))), WorkflowSpecifications.class); + + assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); + WorkflowSpecifications realResponse = mapper.readValue(response.getBody(), WorkflowSpecifications.class); + assertThat(realResponse, sameBeanAs(expectedResponse)); + assertEquals("application/json", response.getHeaders().get(HttpHeaders.CONTENT_TYPE).get(0)); + assertEquals("0", response.getHeaders().get("X-MinorVersion").get(0)); + assertEquals("0", response.getHeaders().get("X-PatchVersion").get(0)); + assertEquals("1.0.0", response.getHeaders().get("X-LatestVersion").get(0)); + } +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/workflowspecificationbeans/WorkflowSpecificationBeansTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/workflowspecificationbeans/WorkflowSpecificationBeansTest.java new file mode 100644 index 0000000000..c469a56e48 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/workflowspecificationbeans/WorkflowSpecificationBeansTest.java @@ -0,0 +1,40 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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.apihandlerinfra.workflowspecificationbeans; + +import org.junit.Test; +import org.onap.so.apihandlerinfra.BaseTest; + +import com.openpojo.reflection.filters.FilterPackageInfo; +import com.openpojo.validation.Validator; +import com.openpojo.validation.ValidatorBuilder; +import com.openpojo.validation.rule.impl.GetterMustExistRule; +import com.openpojo.validation.rule.impl.SetterMustExistRule; +import com.openpojo.validation.test.impl.GetterTester; +import com.openpojo.validation.test.impl.SetterTester; + +public class WorkflowSpecificationBeansTest extends BaseTest{ + @Test + public void validateGettersAndSetters() { + Validator validator = ValidatorBuilder.create().with(new SetterMustExistRule(), new GetterMustExistRule()) + .with(new SetterTester(), new GetterTester()).build(); + validator.validate("org.onap.so.apihandlerinfra.tasksbeans", new FilterPackageInfo()); + } +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/WorkflowSpecifications.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/WorkflowSpecifications.json new file mode 100644 index 0000000000..beca93bd70 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/WorkflowSpecifications.json @@ -0,0 +1,116 @@ +{ + "workflowSpecificationList": [ + { + "workflowSpecification": { + "artifactInfo": { + "artifactType": "workflow", + "artifactUuid": "ab6478e4-ea33-3346-ac12-ab121484a333", + "artifactName": "inPlaceSoftwareUpdate-1_0.bpmn", + "artifactVersion": "1.0", + "artifactDescription": "xyz xyz", + "workflowName": "inPlaceSoftwareUpdate", + "operationName": "inPlaceSoftwareUpdate", + "workflowSource": "sdc", + "workflowResourceTarget": "vnf" + }, + "activitySequence": [ + { + "name": "VNFQuiesceTrafficActivity", + "description": "Activity to QuiesceTraffic on VNF" + }, + { + "name": "VNFHealthCheckActivity", + "description": "Activity to HealthCheck VNF" + }, + { + "name": "FlowCompleteActivity", + "description": "Activity to Complete the BPMN Flow" + } + ], + "workflowInputParameters": [ + { + "label": "Cloud Owner", + "inputType": "text", + "required": true, + "validation": [ + { + "maxLength": "7", + "allowableChars": "someRegEx" + } + ], + "soFieldName": "cloudOwner", + "soPayloadLocation": "cloudConfiguration" + }, + { + "label": "Cloud Region ID", + "inputType": "text", + "required": true, + "validation": [ + { + "maxLength": "7", + "allowableChars": "someRegEx" + } + ], + "soFieldName": "lcpCloudRegionId", + "soPayloadLocation": "cloudConfiguration" + }, + { + "label": "Tenant/Project ID", + "inputType": "text", + "required": true, + "validation": [ + { + "maxLength": "36", + "allowableChars": "someRegEx" + } + ], + "soFieldName": "tenantId", + "soPayloadLocation": "cloudConfiguration" + }, + { + "label": "Operations Timeout", + "inputType": "text", + "required": true, + "validation": [ + { + "maxLength": "50", + "allowableChars": "someRegEx" + } + ], + "soFieldName": "operations_timeout", + "soPayloadLocation": "userParams" + }, + { + "label": "Existing Software Version", + "inputType": "text", + "required": true, + "validation": [ + { + "maxLength": "50", + "allowableChars": "someRegEx" + } + ], + "soFieldName": "existing_software_version", + "soPayloadLocation": "userParams" + }, + { + "label": "New Software Version", + "inputType": "text", + "required": true, + "validation": [ + { + "maxLength": "50", + "allowableChars": "someRegEx" + } + ], + "soFieldName": "new_software_version", + "soPayloadLocation": "userParams" + } + ] + } + }, + { + "workflowSpecification": {} + } + ] +} diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/OrchestrationStatus.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/OrchestrationStatus.java index 6902d8f36a..0fa07cfe0f 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/OrchestrationStatus.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/OrchestrationStatus.java @@ -30,7 +30,9 @@ public enum OrchestrationStatus { PENDING_CREATE("PendingCreate", "pending.?create"), PENDING_DELETE("PendingDelete", "pending.?delete"), PRECREATED("PreCreated", "pre.?created"), - CONFIGASSIGNED("ConfigAssigned", "config.?assigned"); + CONFIGASSIGNED("ConfigAssigned", "config.?assigned"), + CONFIGURE("Configure" , "configure"), + CONFIGURED("Configured" , "configured"); private final String name; private final String fuzzyMatcher; diff --git a/packages/docker/src/main/docker/docker-files/Dockerfile.so-base-image b/packages/docker/src/main/docker/docker-files/Dockerfile.so-base-image index de446b734a..cf50868ca5 100644 --- a/packages/docker/src/main/docker/docker-files/Dockerfile.so-base-image +++ b/packages/docker/src/main/docker/docker-files/Dockerfile.so-base-image @@ -11,7 +11,7 @@ ENV https_proxy=$HTTPS_PROXY RUN apk update && apk upgrade # Install commonly needed tools -RUN apk --no-cache add curl netcat-openbsd sudo +RUN apk --no-cache add curl netcat-openbsd sudo nss # Create 'so' user RUN addgroup -g 1000 so && adduser -S -u 1000 -G so -s /bin/sh so |