summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cds-ui/client/src/app/feature-modules/blueprint/modify-template/modify-template.component.html2
-rw-r--r--docs/CBA/index.rst4
-rw-r--r--docs/bluePrintsProcessor.rst54
-rw-r--r--docs/controllerBlueprintStudioProcessor.rst28
-rw-r--r--docs/index.rst7
-rw-r--r--docs/media/CDS_architecture.JPGbin0 -> 140539 bytes
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BluePrintWorkflowExecutionServiceImpl.kt (renamed from ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/cds/blueprintsprocessor/services/workflow/BluePrintWorkflowExecutionServiceImpl.kt)8
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BlueprintSvcLogicContext.kt (renamed from ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/cds/blueprintsprocessor/services/workflow/BlueprintSvcLogicContext.kt)0
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BlueprintSvcLogicService.kt (renamed from ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/cds/blueprintsprocessor/services/workflow/BlueprintSvcLogicService.kt)0
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/ComponentWorkflowExecutionService.kt (renamed from ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/cds/blueprintsprocessor/services/workflow/ComponentWorkflowExecutionService.kt)2
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/DGWorkflowExecutionService.kt (renamed from ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/cds/blueprintsprocessor/services/workflow/DGWorkflowExecutionService.kt)6
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/NodeTemplateExecutionService.kt (renamed from ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/cds/blueprintsprocessor/services/workflow/NodeTemplateExecutionService.kt)2
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/WorkflowServiceConfiguration.kt (renamed from ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/cds/blueprintsprocessor/services/workflow/WorkflowServiceConfiguration.kt)0
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/executor/ComponentExecuteNodeExecutor.kt (renamed from ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/cds/blueprintsprocessor/services/workflow/executor/ComponentExecuteNodeExecutor.kt)2
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/utils/SvcGraphUtils.kt (renamed from ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/cds/blueprintsprocessor/services/workflow/utils/SvcGraphUtils.kt)0
-rw-r--r--ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/cds/cdssdclistener/CdsSdcListenerApplication.java17
-rw-r--r--ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/cds/cdssdclistener/CdsSdcListenerConfiguration.java18
-rw-r--r--ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/cds/cdssdclistener/CdsSdcListenerNotificationCallback.java58
-rw-r--r--ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/cds/cdssdclistener/client/CdsSdcListenerAuthClientInterceptor.java16
-rw-r--r--ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/cds/cdssdclistener/client/CdsSdcListenerClient.java25
-rw-r--r--ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/cds/cdssdclistener/dto/CdsSdcListenerDto.java53
-rw-r--r--ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/cds/cdssdclistener/exceptions/CdsSdcListenerException.java17
-rw-r--r--ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/cds/cdssdclistener/handler/BluePrintProcesssorHandler.java17
-rw-r--r--ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/cds/cdssdclistener/service/ListenerService.java23
-rw-r--r--ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/cds/cdssdclistener/service/ListenerServiceImpl.java96
-rw-r--r--ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/cds/cdssdclistener/status/CdsSdcListenerStatus.java83
-rw-r--r--ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/cds/cdssdclistener/status/DistributionStatusMessage.java55
-rw-r--r--ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/cds/cdssdclistener/util/BuilderUtil.java33
-rw-r--r--ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/cds/cdssdclistener/util/FileUtil.java61
-rw-r--r--ms/cds-sdc-listener/application/src/main/resources/application.yml4
-rw-r--r--ms/cds-sdc-listener/application/src/test/java/org/onap/ccsdk/cds/cdssdclistener/CdsSdcListenerClientTest.java19
-rw-r--r--ms/cds-sdc-listener/application/src/test/java/org/onap/ccsdk/cds/cdssdclistener/CdsSdcListenerConfigurationTest.java19
-rw-r--r--ms/cds-sdc-listener/application/src/test/java/org/onap/ccsdk/cds/cdssdclistener/handler/BluePrintProcessorHandlerTest.java18
-rw-r--r--ms/cds-sdc-listener/application/src/test/java/org/onap/ccsdk/cds/cdssdclistener/service/ListenerServiceImplTest.java59
34 files changed, 649 insertions, 157 deletions
diff --git a/cds-ui/client/src/app/feature-modules/blueprint/modify-template/modify-template.component.html b/cds-ui/client/src/app/feature-modules/blueprint/modify-template/modify-template.component.html
index b3eeeeda2..546668d43 100644
--- a/cds-ui/client/src/app/feature-modules/blueprint/modify-template/modify-template.component.html
+++ b/cds-ui/client/src/app/feature-modules/blueprint/modify-template/modify-template.component.html
@@ -36,7 +36,7 @@ limitations under the License.
<button class="mat-button-active" mat-button [matMenuTriggerFor]="menu">Deploy</button>
<mat-menu #menu="matMenu">
<button mat-menu-item (click)="saveToBlueprintProcessor()">Deploy</button>
- <button mat-menu-item (click)="processBlueprint()">Test</button>
+ <!-- <button mat-menu-item (click)="processBlueprint()">Test</button> -->
</mat-menu>
<button class="btn-active" (click)="publishToControllerBlueprint()">Publish</button>
<button class="btn-active" (click)="saveToControllerBlueprint()">Save</button>
diff --git a/docs/CBA/index.rst b/docs/CBA/index.rst
index c7b219f5c..43317e6e5 100644
--- a/docs/CBA/index.rst
+++ b/docs/CBA/index.rst
@@ -2,8 +2,8 @@
.. http://creativecommons.org/licenses/by/4.0
.. Copyright (C) 2019 IBM.
-Controller Blueprint Archived Tool(CBA)
-----------------------------------------
+Controller Blueprint Archived Designer Tool(CBA)
+------------------------------------------------
.. toctree::
:maxdepth: 1
diff --git a/docs/bluePrintsProcessor.rst b/docs/bluePrintsProcessor.rst
index a687d50be..911f99945 100644
--- a/docs/bluePrintsProcessor.rst
+++ b/docs/bluePrintsProcessor.rst
@@ -11,6 +11,8 @@ Blueprints Processor
Micro service to Manage Controller Blueprint Models, such as Resource Dictionary, Service Models, Velocity Templates etc, which will serve service for Controller Design Studio and Controller runtimes.
+This microservice is used to deploy Controller Blueprint Archive file in Run time database. This also helps to test the Valid Blueprint.
+
Architecture:
==============
@@ -18,4 +20,54 @@ Architecture:
.. |image0| image:: images/blueprintprocessor.jpg
:height: 600px
- :width: 800px \ No newline at end of file
+ :width: 800px
+
+Running Blueprints Processor Microservice Locally:
+==================================================
+
+The purpose of this page is to show how to run the Blueprints Processor microservice locally, using the docker-compose.yaml file provided in the project.
+
+Check out the CDS' code:
+
+Check out the latest code from Gerrit: https://gerrit.onap.org/r/#/admin/projects/ccsdk/cds
+
+Build CDS locally:
+In the checked out directory, type
+
+ mvn clean install -DskipTests=true -Dmaven.test.skip=true -Dmaven.javadoc.skip=true -Dadditionalparam=-Xdoclint:none
+
+Create the needed Docker images:
+
+The Blueprints Processor microservice project has a module, called distribution, that provides a docker-compose.yaml file that can be used to spin up Docker containers to run this microservice.
+
+The first step is to create any custom image needed, by building the distribution module. From the CDS home directory (where the code was checked out), navigate to the module:
+
+ cd ms/blueprintsprocessor/distribution/
+Build it using the Maven profile called Docker:
+
+ mvn clean install -Pdocker
+
+Start Docker containers using docker-composer:
+==============================================
+
+Navigate to the docker-compose file in the distribution module:
+
+ cd src/main/dc/
+
+From there, start the containers:
+
+ docker-compose up -d
+This will spin the Docker containers declared inside the docker-compose.yaml file in the background.
+
+
+To verify the logs generated by docker-composer, type:
+
+ docker-compose logs -f
+
+
+Testing the environment:
+========================
+
+Point your browser to http://localhost:8000/api/v1/execution-service/ping (please note that the port is 8000, not 8080)
+
+To authenticate, use ccsdkapps / ccsdkapps as login / password. \ No newline at end of file
diff --git a/docs/controllerBlueprintStudioProcessor.rst b/docs/controllerBlueprintStudioProcessor.rst
index fc9112296..5c67d6c1d 100644
--- a/docs/controllerBlueprintStudioProcessor.rst
+++ b/docs/controllerBlueprintStudioProcessor.rst
@@ -5,6 +5,28 @@
Controller Blueprints Studio Processor
======================================
-.. toctree::
- :maxdepth: 1
- :titlesonly: \ No newline at end of file
+The Controller Blueprint Archive is the overall service design, fully model-driven, intent based package needed for SELF SERVICE provisioning and configuration management automation.
+
+The CBA is .zip file which is saved in Controller Blueprint Database.
+
+Dynamic API:
+===========
+
+The nature of the API request and response is meant to be model driven and dynamic. They both share the same definition.
+
+The actionName, under the actionIdentifiers refers to the name of a Workflow (see workflow)
+
+The content of the payload is what is fully dynamic / model driven.
+
+The first top level element will always be either $actionName-request for a request or $actionName-response for a response.
+
+Then the content within this element is fully based on the workflow input and output.
+
+
+Enrichment:
+===========
+
+Helps to generate complete valid CBA file.
+
+
+ \ No newline at end of file
diff --git a/docs/index.rst b/docs/index.rst
index 477c251da..5f3902687 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -56,6 +56,13 @@ The Controller Design Studio is composed of two major components:
* The Run Time (or backend)
The GUI handles direct user input and allows for displaying both design time and run time activities. For design time, it allows for the creation of controller blueprint, from selecting the DGs to be included, to incorporating the artifact templates, to adding necessary components. For run time, it allows the user to direct the system to resolve the unresolved elements of the controller blueprint and download the resulting configuration into a VNF. At a more basic level, it allows for creation of data dictionaries, capabilities catalogs, and controller blueprint, the basic elements that are used to generate a configuration. The essential function of the Controller Design Studio is to create and populate a controller blueprint, create a configuration file from this Controller blueprint, and download this configuration file (configlet) to a VNF/PNF.
+|image0|
+
+.. |image0| image:: media/CDS_architecture.jpg
+ :height: 4.43750in
+ :width: 7.88889in
+
+
Resource assignment:
=====================
.. toctree::
diff --git a/docs/media/CDS_architecture.JPG b/docs/media/CDS_architecture.JPG
new file mode 100644
index 000000000..c8528ac1e
--- /dev/null
+++ b/docs/media/CDS_architecture.JPG
Binary files differ
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/cds/blueprintsprocessor/services/workflow/BluePrintWorkflowExecutionServiceImpl.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BluePrintWorkflowExecutionServiceImpl.kt
index b18617422..8ae128d4b 100644
--- a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/cds/blueprintsprocessor/services/workflow/BluePrintWorkflowExecutionServiceImpl.kt
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BluePrintWorkflowExecutionServiceImpl.kt
@@ -29,8 +29,8 @@ import org.springframework.stereotype.Service
@Service("bluePrintWorkflowExecutionService")
open class BluePrintWorkflowExecutionServiceImpl(
- private val componentWorkflowExecutionService: ComponentWorkflowExecutionService,
- private val dgWorkflowExecutionService: DGWorkflowExecutionService
+ private val componentWorkflowExecutionService: ComponentWorkflowExecutionService,
+ private val dgWorkflowExecutionService: DGWorkflowExecutionService
) : BluePrintWorkflowExecutionService<ExecutionServiceInput, ExecutionServiceOutput> {
private val log = LoggerFactory.getLogger(BluePrintWorkflowExecutionServiceImpl::class.java)!!
@@ -57,11 +57,11 @@ open class BluePrintWorkflowExecutionServiceImpl(
val executionServiceOutput: ExecutionServiceOutput = when {
derivedFrom.startsWith(BluePrintConstants.MODEL_TYPE_NODE_COMPONENT, true) -> {
componentWorkflowExecutionService
- .executeBluePrintWorkflow(bluePrintRuntimeService, executionServiceInput, properties)
+ .executeBluePrintWorkflow(bluePrintRuntimeService, executionServiceInput, properties)
}
derivedFrom.startsWith(BluePrintConstants.MODEL_TYPE_NODE_WORKFLOW, true) -> {
dgWorkflowExecutionService
- .executeBluePrintWorkflow(bluePrintRuntimeService, executionServiceInput, properties)
+ .executeBluePrintWorkflow(bluePrintRuntimeService, executionServiceInput, properties)
}
else -> {
throw BluePrintProcessorException("couldn't execute workflow($workflowName) step mapped " +
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/cds/blueprintsprocessor/services/workflow/BlueprintSvcLogicContext.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BlueprintSvcLogicContext.kt
index a2db8aab7..a2db8aab7 100644
--- a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/cds/blueprintsprocessor/services/workflow/BlueprintSvcLogicContext.kt
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BlueprintSvcLogicContext.kt
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/cds/blueprintsprocessor/services/workflow/BlueprintSvcLogicService.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BlueprintSvcLogicService.kt
index df250ae98..df250ae98 100644
--- a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/cds/blueprintsprocessor/services/workflow/BlueprintSvcLogicService.kt
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BlueprintSvcLogicService.kt
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/cds/blueprintsprocessor/services/workflow/ComponentWorkflowExecutionService.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/ComponentWorkflowExecutionService.kt
index ee6c35397..3c474de37 100644
--- a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/cds/blueprintsprocessor/services/workflow/ComponentWorkflowExecutionService.kt
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/ComponentWorkflowExecutionService.kt
@@ -39,7 +39,7 @@ open class ComponentWorkflowExecutionService(private val nodeTemplateExecutionSe
val nodeTemplateName = bluePrintContext.workflowFirstStepNodeTemplate(workflowName)
return nodeTemplateExecutionService.executeNodeTemplate(bluePrintRuntimeService,
- nodeTemplateName, executionServiceInput)
+ nodeTemplateName, executionServiceInput)
}
} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/cds/blueprintsprocessor/services/workflow/DGWorkflowExecutionService.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/DGWorkflowExecutionService.kt
index 80aa1030d..4485800ff 100644
--- a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/cds/blueprintsprocessor/services/workflow/DGWorkflowExecutionService.kt
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/DGWorkflowExecutionService.kt
@@ -48,7 +48,7 @@ open class DGWorkflowExecutionService(private val blueprintSvcLogicService: Blue
// Get the DG file info
val artifactDefinition = bluePrintContext.nodeTemplateArtifactForArtifactType(nodeTemplateName,
- WorkflowServiceConstants.ARTIFACT_TYPE_DIRECTED_GRAPH)
+ WorkflowServiceConstants.ARTIFACT_TYPE_DIRECTED_GRAPH)
// Populate the DG Path
val dgFilePath = normalizedPathName(bluePrintContext.rootPath, artifactDefinition.file)
@@ -59,7 +59,9 @@ open class DGWorkflowExecutionService(private val blueprintSvcLogicService: Blue
val graph = SvcGraphUtils.getSvcGraphFromFile(dgFilePath)
// Execute the DG
- return blueprintSvcLogicService.execute(graph, bluePrintRuntimeService, executionServiceInput) as ExecutionServiceOutput
+ return blueprintSvcLogicService.execute(graph,
+ bluePrintRuntimeService,
+ executionServiceInput) as ExecutionServiceOutput
}
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/cds/blueprintsprocessor/services/workflow/NodeTemplateExecutionService.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/NodeTemplateExecutionService.kt
index 5ed280cb5..af7846340 100644
--- a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/cds/blueprintsprocessor/services/workflow/NodeTemplateExecutionService.kt
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/NodeTemplateExecutionService.kt
@@ -72,7 +72,7 @@ open class NodeTemplateExecutionService(private val applicationContext: Applicat
clonedExecutionServiceInput.stepData = stepInputData
// Get the Request from the Context and Set to the Function Input and Invoke the function
- return plugin.applyNB(clonedExecutionServiceInput)
+ return plugin.applyNB(clonedExecutionServiceInput)
}
} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/cds/blueprintsprocessor/services/workflow/WorkflowServiceConfiguration.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/WorkflowServiceConfiguration.kt
index 67f13f760..67f13f760 100644
--- a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/cds/blueprintsprocessor/services/workflow/WorkflowServiceConfiguration.kt
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/WorkflowServiceConfiguration.kt
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/cds/blueprintsprocessor/services/workflow/executor/ComponentExecuteNodeExecutor.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/executor/ComponentExecuteNodeExecutor.kt
index cfba5becd..b6e767503 100644
--- a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/cds/blueprintsprocessor/services/workflow/executor/ComponentExecuteNodeExecutor.kt
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/executor/ComponentExecuteNodeExecutor.kt
@@ -50,7 +50,7 @@ open class ComponentExecuteNodeExecutor(private val nodeTemplateExecutionService
try { // Get the Request from the Context and Set to the Function Input and Invoke the function
val executionOutput = nodeTemplateExecutionService.executeNodeTemplate(ctx.getBluePrintService(),
- nodeTemplateName, executionInput)
+ nodeTemplateName, executionInput)
ctx.setResponse(executionOutput)
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/cds/blueprintsprocessor/services/workflow/utils/SvcGraphUtils.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/utils/SvcGraphUtils.kt
index 8f9579230..8f9579230 100644
--- a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/cds/blueprintsprocessor/services/workflow/utils/SvcGraphUtils.kt
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/utils/SvcGraphUtils.kt
diff --git a/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/cds/cdssdclistener/CdsSdcListenerApplication.java b/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/cds/cdssdclistener/CdsSdcListenerApplication.java
index 30f101246..6f0f65323 100644
--- a/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/cds/cdssdclistener/CdsSdcListenerApplication.java
+++ b/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/cds/cdssdclistener/CdsSdcListenerApplication.java
@@ -1,11 +1,18 @@
/*
- * Copyright (C) 2019 Bell Canada. All rights reserved.
+ * Copyright © 2019 Bell Canada
*
- * NOTICE: All the intellectual and technical concepts contained herein are
- * proprietary to Bell Canada and are protected by trade secret or copyright law.
- * Unauthorized copying of this file, via any medium is strictly prohibited.
+ * 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.
*/
-
package org.onap.ccsdk.cds.cdssdclistener;
import org.springframework.boot.SpringApplication;
diff --git a/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/cds/cdssdclistener/CdsSdcListenerConfiguration.java b/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/cds/cdssdclistener/CdsSdcListenerConfiguration.java
index 242c19c1e..3dfb07eb8 100644
--- a/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/cds/cdssdclistener/CdsSdcListenerConfiguration.java
+++ b/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/cds/cdssdclistener/CdsSdcListenerConfiguration.java
@@ -1,11 +1,18 @@
/*
- * Copyright (C) 2019 Bell Canada. All rights reserved.
+ * Copyright © 2019 Bell Canada
*
- * NOTICE: All the intellectual and technical concepts contained herein are
- * proprietary to Bell Canada and are protected by trade secret or copyright law.
- * Unauthorized copying of this file, via any medium is strictly prohibited.
+ * 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.
*/
-
package org.onap.ccsdk.cds.cdssdclistener;
import java.util.List;
@@ -58,7 +65,6 @@ public class CdsSdcListenerConfiguration implements IConfiguration {
@Value("${listenerservice.config.isUseHttpsWithDmaap}")
private boolean isUseHttpsWithDmaap;
-
@Override
public String getAsdcAddress() {
return asdcAddress;
diff --git a/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/cds/cdssdclistener/CdsSdcListenerNotificationCallback.java b/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/cds/cdssdclistener/CdsSdcListenerNotificationCallback.java
index e2aae9654..58c667c26 100644
--- a/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/cds/cdssdclistener/CdsSdcListenerNotificationCallback.java
+++ b/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/cds/cdssdclistener/CdsSdcListenerNotificationCallback.java
@@ -1,11 +1,18 @@
/*
- * Copyright (C) 2019 Bell Canada. All rights reserved.
+ * Copyright © 2019 Bell Canada
*
- * NOTICE: All the intellectual and technical concepts contained herein are
- * proprietary to Bell Canada and are protected by trade secret or copyright law.
- * Unauthorized copying of this file, via any medium is strictly prohibited.
+ * 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.
*/
-
package org.onap.ccsdk.cds.cdssdclistener;
import static org.onap.sdc.utils.DistributionActionResultEnum.SUCCESS;
@@ -16,12 +23,15 @@ import java.util.List;
import java.util.Objects;
import java.util.Optional;
import org.onap.ccsdk.cds.cdssdclistener.dto.CdsSdcListenerDto;
-import org.onap.ccsdk.cds.cdssdclistener.service.ListenerServiceImpl;
+import org.onap.ccsdk.cds.cdssdclistener.service.ListenerService;
+import org.onap.ccsdk.cds.cdssdclistener.status.CdsSdcListenerStatus;
+import org.onap.ccsdk.cds.cdssdclistener.util.FileUtil;
import org.onap.sdc.api.IDistributionClient;
import org.onap.sdc.api.consumer.INotificationCallback;
import org.onap.sdc.api.notification.IArtifactInfo;
import org.onap.sdc.api.notification.INotificationData;
import org.onap.sdc.api.results.IDistributionClientDownloadResult;
+import org.onap.sdc.utils.DistributionStatusEnum;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -39,16 +49,21 @@ public class CdsSdcListenerNotificationCallback implements INotificationCallback
private CdsSdcListenerDto cdsSdcListenerDto;
@Autowired
- private ListenerServiceImpl listenerService;
+ private ListenerService listenerService;
@Value("${listenerservice.config.archivePath}")
private String pathToStoreArchives;
+ @Autowired
+ private CdsSdcListenerStatus listenerStatus;
+
private static final Logger LOGGER = LoggerFactory.getLogger(CdsSdcListenerNotificationCallback.class);
@Override
public void activateCallback(INotificationData notificationData) {
- LOGGER.info(notificationData.getDistributionID(), "The UUID generated by SDC {}");
+ final String distributionId = notificationData.getDistributionID();
+ cdsSdcListenerDto.setDistributionId(distributionId);
+ LOGGER.info("Received service distribution from SDC with the id {}", distributionId);
processNotification(notificationData);
}
@@ -75,8 +90,11 @@ public class CdsSdcListenerNotificationCallback implements INotificationCallback
IDistributionClientDownloadResult result = distributionClient.download(info);
if (!Objects.equals(result.getDistributionActionResult(), SUCCESS)) {
- LOGGER.error("Failed to download the artifact from : {} due to {} ", url,
+ String errorMessage = String.format("Failed to download the artifact from : %s due to %s ", url,
result.getDistributionActionResult());
+ listenerStatus.sendResponseStatusBackToSDC(cdsSdcListenerDto.getDistributionId(),
+ DistributionStatusEnum.COMPONENT_DONE_ERROR, errorMessage);
+ LOGGER.error(errorMessage);
} else {
LOGGER.info("Trying to write CSAR artifact to file with URL {} and UUID {}", url, id);
processCsarArtifact(result);
@@ -88,20 +106,24 @@ public class CdsSdcListenerNotificationCallback implements INotificationCallback
Path cbaArchivePath = Paths.get(pathToStoreArchives, "cba-archive");
Path csarArchivePath = Paths.get(pathToStoreArchives, "csar-archive");
- // extract and store the CSAR archive into local disk.
+ // Extract and store the CSAR archive into local disk.
listenerService.extractCsarAndStore(result, csarArchivePath.toString());
- Optional<List<File>> csarFiles = listenerService.getFilesFromDisk(csarArchivePath);
+ Optional<List<File>> csarFiles = FileUtil.getFilesFromDisk(csarArchivePath);
if (csarFiles.isPresent()) {
+ //Extract CBA archive from CSAR package and store it into local disk.
+ List<File> files = csarFiles.get();
- //Extract CBA archive from CSAR package and and store it into CDS Database.
- csarFiles.get()
- .forEach(file -> listenerService.extractBluePrint(file.getAbsolutePath(), cbaArchivePath.toString()));
-
- listenerService.saveBluePrintToCdsDatabase(cbaArchivePath);
- } else {
- LOGGER.error("The CSAR file is not present at this location {}", csarArchivePath);
+ if (!files.isEmpty()) {
+ final String archivePath = cbaArchivePath.toString();
+ files.forEach(file -> listenerService.extractBluePrint(file.getAbsolutePath(), archivePath));
+ files.forEach(file -> FileUtil.deleteFile(file, archivePath));
+ } else {
+ LOGGER.error("The CSAR file is not present at this location {}", csarArchivePath);
+ }
}
+
+ listenerService.saveBluePrintToCdsDatabase(cbaArchivePath, cdsSdcListenerDto.getManagedChannelForGrpc());
}
}
diff --git a/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/cds/cdssdclistener/client/CdsSdcListenerAuthClientInterceptor.java b/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/cds/cdssdclistener/client/CdsSdcListenerAuthClientInterceptor.java
index 528fbe2f3..bae4a3754 100644
--- a/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/cds/cdssdclistener/client/CdsSdcListenerAuthClientInterceptor.java
+++ b/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/cds/cdssdclistener/client/CdsSdcListenerAuthClientInterceptor.java
@@ -1,9 +1,17 @@
/*
- * Copyright (C) 2019 Bell Canada. All rights reserved.
+ * Copyright © 2019 Bell Canada
*
- * NOTICE: All the intellectual and technical concepts contained herein are
- * proprietary to Bell Canada and are protected by trade secret or copyright law.
- * Unauthorized copying of this file, via any medium is strictly prohibited.
+ * 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.
*/
package org.onap.ccsdk.cds.cdssdclistener.client;
diff --git a/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/cds/cdssdclistener/client/CdsSdcListenerClient.java b/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/cds/cdssdclistener/client/CdsSdcListenerClient.java
index 6f888dd0b..8d6aca5cd 100644
--- a/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/cds/cdssdclistener/client/CdsSdcListenerClient.java
+++ b/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/cds/cdssdclistener/client/CdsSdcListenerClient.java
@@ -1,9 +1,17 @@
/*
- * Copyright (C) 2019 Bell Canada. All rights reserved.
+ * Copyright © 2019 Bell Canada
*
- * NOTICE: All the intellectual and technical concepts contained herein are
- * proprietary to Bell Canada and are protected by trade secret or copyright law.
- * Unauthorized copying of this file, via any medium is strictly prohibited.
+ * 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.
*/
package org.onap.ccsdk.cds.cdssdclistener.client;
@@ -51,10 +59,11 @@ public class CdsSdcListenerClient {
distributionClient = Optional.of(DistributionClientFactory.createDistributionClient())
.orElseThrow(() -> new CdsSdcListenerException("Could not able to create SDC Distribution client"));
+ listenerDto.setManagedChannelForGrpc();
+
listenerDto.setDistributionClient(distributionClient);
IDistributionClientResult result = distributionClient.init(configuration, notification);
-
startSdcClientBasedOnTheResult(result);
}
@@ -64,6 +73,8 @@ public class CdsSdcListenerClient {
"SDC distribution client init failed with reason:" + result.getDistributionMessageResult());
}
+ LOG.info("Initialization of the SDC distribution client is complete");
+
// Start the client.
result = this.distributionClient.start();
@@ -74,10 +85,8 @@ public class CdsSdcListenerClient {
}
private void closeSdcDistributionclient() throws CdsSdcListenerException {
-
- IDistributionClientResult status = this.distributionClient.stop();
-
LOG.info("Closing SDC distribution client");
+ IDistributionClientResult status = this.distributionClient.stop();
if (status.getDistributionActionResult().equals(DistributionActionResultEnum.SUCCESS)) {
throw new CdsSdcListenerException(
"Failed to close the SDC distribution client due to : " + status.getDistributionMessageResult());
diff --git a/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/cds/cdssdclistener/dto/CdsSdcListenerDto.java b/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/cds/cdssdclistener/dto/CdsSdcListenerDto.java
index 41039eb28..68669307e 100644
--- a/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/cds/cdssdclistener/dto/CdsSdcListenerDto.java
+++ b/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/cds/cdssdclistener/dto/CdsSdcListenerDto.java
@@ -1,19 +1,45 @@
/*
- * Copyright (C) 2019 Bell Canada. All rights reserved.
+ * Copyright © 2019 Bell Canada
*
- * NOTICE: All the intellectual and technical concepts contained herein are
- * proprietary to Bell Canada and are protected by trade secret or copyright law.
- * Unauthorized copying of this file, via any medium is strictly prohibited.
+ * 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.
*/
package org.onap.ccsdk.cds.cdssdclistener.dto;
+import io.grpc.ManagedChannel;
+import io.grpc.ManagedChannelBuilder;
+import org.onap.ccsdk.cds.cdssdclistener.client.CdsSdcListenerAuthClientInterceptor;
import org.onap.sdc.api.IDistributionClient;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
@Component
+@ConfigurationProperties("listenerservice")
public class CdsSdcListenerDto {
+ @Value("${listenerservice.config.grpcAddress}")
+ private String grpcAddress;
+
+ @Value("${listenerservice.config.grpcPort}")
+ private int grpcPort;
+
+ @Autowired
+ private CdsSdcListenerAuthClientInterceptor cdsSdcListenerAuthClientInterceptor;
+
private IDistributionClient distributionClient;
+ private ManagedChannel managedChannel;
+ private String distributionId;
public IDistributionClient getDistributionClient() {
return distributionClient;
@@ -22,4 +48,23 @@ public class CdsSdcListenerDto {
public void setDistributionClient(IDistributionClient distributionClient) {
this.distributionClient = distributionClient;
}
+
+ public void setDistributionId(String id) {
+ this.distributionId = id;
+ }
+
+ public String getDistributionId() {
+ return distributionId;
+ }
+
+ public void setManagedChannelForGrpc() {
+ managedChannel = ManagedChannelBuilder.forAddress(grpcAddress, grpcPort)
+ .usePlaintext()
+ .intercept(cdsSdcListenerAuthClientInterceptor)
+ .build();
+ }
+
+ public ManagedChannel getManagedChannelForGrpc() {
+ return managedChannel;
+ }
}
diff --git a/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/cds/cdssdclistener/exceptions/CdsSdcListenerException.java b/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/cds/cdssdclistener/exceptions/CdsSdcListenerException.java
index 09ef4ed8c..eff5ef050 100644
--- a/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/cds/cdssdclistener/exceptions/CdsSdcListenerException.java
+++ b/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/cds/cdssdclistener/exceptions/CdsSdcListenerException.java
@@ -1,11 +1,18 @@
/*
- * Copyright (C) 2019 Bell Canada. All rights reserved.
+ * Copyright © 2019 Bell Canada
*
- * NOTICE: All the intellectual and technical concepts contained herein are
- * proprietary to Bell Canada and are protected by trade secret or copyright law.
- * Unauthorized copying of this file, via any medium is strictly prohibited.
+ * 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.
*/
-
package org.onap.ccsdk.cds.cdssdclistener.exceptions;
public class CdsSdcListenerException extends Exception {
diff --git a/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/cds/cdssdclistener/handler/BluePrintProcesssorHandler.java b/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/cds/cdssdclistener/handler/BluePrintProcesssorHandler.java
index 6b03b6da2..b05245392 100644
--- a/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/cds/cdssdclistener/handler/BluePrintProcesssorHandler.java
+++ b/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/cds/cdssdclistener/handler/BluePrintProcesssorHandler.java
@@ -1,11 +1,18 @@
/*
- * Copyright (C) 2019 Bell Canada. All rights reserved.
+ * Copyright © 2019 Bell Canada
*
- * NOTICE: All the intellectual and technical concepts contained herein are
- * proprietary to Bell Canada and are protected by trade secret or copyright law.
- * Unauthorized copying of this file, via any medium is strictly prohibited.
+ * 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.
*/
-
package org.onap.ccsdk.cds.cdssdclistener.handler;
import io.grpc.ManagedChannel;
diff --git a/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/cds/cdssdclistener/service/ListenerService.java b/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/cds/cdssdclistener/service/ListenerService.java
index 1efbe8f33..e55aeb134 100644
--- a/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/cds/cdssdclistener/service/ListenerService.java
+++ b/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/cds/cdssdclistener/service/ListenerService.java
@@ -1,13 +1,21 @@
/*
- * Copyright (C) 2019 Bell Canada. All rights reserved.
+ * Copyright © 2019 Bell Canada
*
- * NOTICE: All the intellectual and technical concepts contained herein are
- * proprietary to Bell Canada and are protected by trade secret or copyright law.
- * Unauthorized copying of this file, via any medium is strictly prohibited.
+ * 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.
*/
-
package org.onap.ccsdk.cds.cdssdclistener.service;
+import io.grpc.ManagedChannel;
import java.nio.file.Path;
import org.onap.sdc.api.results.IDistributionClientDownloadResult;
@@ -25,11 +33,12 @@ public interface ListenerService {
* Store the Zip file into CDS database.
*
* @param path path where zip file exists.
+ * @param managedChannel To access the blueprint processor application end point
*/
- void saveBluePrintToCdsDatabase(Path path);
+ void saveBluePrintToCdsDatabase(Path path, ManagedChannel managedChannel);
/**
- * Extract and store CSAR to file.
+ * Extract and store the csar package to local disk.
*
* @param result - IDistributionClientDownloadResult contains payload.
* @param csarArchivePath The destination path where CSAR will be stored.
diff --git a/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/cds/cdssdclistener/service/ListenerServiceImpl.java b/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/cds/cdssdclistener/service/ListenerServiceImpl.java
index 37052082a..1cf1a1bae 100644
--- a/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/cds/cdssdclistener/service/ListenerServiceImpl.java
+++ b/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/cds/cdssdclistener/service/ListenerServiceImpl.java
@@ -1,17 +1,26 @@
/*
- * Copyright (C) 2019 Bell Canada. All rights reserved.
+ * Copyright © 2017-2019 AT&T, Bell Canada
*
- * NOTICE: All the intellectual and technical concepts contained herein are
- * proprietary to Bell Canada and are protected by trade secret or copyright law.
- * Unauthorized copying of this file, via any medium is strictly prohibited.
+ * 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.
*/
package org.onap.ccsdk.cds.cdssdclistener.service;
import static java.nio.file.Files.walk;
+import static org.onap.sdc.utils.DistributionStatusEnum.COMPONENT_DONE_ERROR;
+import static org.onap.sdc.utils.DistributionStatusEnum.COMPONENT_DONE_OK;
import com.google.protobuf.ByteString;
import io.grpc.ManagedChannel;
-import io.grpc.ManagedChannelBuilder;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
@@ -31,7 +40,10 @@ import java.util.zip.ZipFile;
import org.apache.commons.io.FileUtils;
import org.apache.tomcat.util.http.fileupload.IOUtils;
import org.onap.ccsdk.cds.cdssdclistener.client.CdsSdcListenerAuthClientInterceptor;
+import org.onap.ccsdk.cds.cdssdclistener.dto.CdsSdcListenerDto;
import org.onap.ccsdk.cds.cdssdclistener.handler.BluePrintProcesssorHandler;
+import org.onap.ccsdk.cds.cdssdclistener.status.CdsSdcListenerStatus;
+import org.onap.ccsdk.cds.cdssdclistener.util.FileUtil;
import org.onap.ccsdk.cds.controllerblueprints.common.api.Status;
import org.onap.ccsdk.cds.controllerblueprints.management.api.BluePrintUploadInput;
import org.onap.ccsdk.cds.controllerblueprints.management.api.FileChunk;
@@ -53,6 +65,12 @@ public class ListenerServiceImpl implements ListenerService {
@Autowired
private CdsSdcListenerAuthClientInterceptor cdsSdcListenerAuthClientInterceptor;
+ @Autowired
+ private CdsSdcListenerStatus listenerStatus;
+
+ @Autowired
+ private CdsSdcListenerDto cdsSdcListenerDto;
+
@Value("${listenerservice.config.grpcAddress}")
private String grpcAddress;
@@ -61,7 +79,6 @@ public class ListenerServiceImpl implements ListenerService {
private static final String CBA_ZIP_PATH = "Artifacts/Resources/[a-zA-Z0-9-_]+/Deployment/CONTROLLER_BLUEPRINT_ARCHIVE/[a-zA-Z0-9-_]+[.]zip";
private static final int SUCCESS_CODE = 200;
- private static final String CSAR_FILE_EXTENSION = ".csar";
private static final Logger LOGGER = LoggerFactory.getLogger(ListenerServiceImpl.class);
@Override
@@ -78,8 +95,9 @@ public class ListenerServiceImpl implements ListenerService {
storeBluePrint(zipFile, cbaArchiveName, cbaStorageDir, entry);
}
}
+
} catch (Exception e) {
- LOGGER.error("Failed to extract blueprint", e);
+ LOGGER.error("Failed to extract blueprint {}", e);
}
}
@@ -97,16 +115,16 @@ public class ListenerServiceImpl implements ListenerService {
try (InputStream inputStream = zipFile.getInputStream(entry); OutputStream out = new FileOutputStream(
targetZipFile)) {
IOUtils.copy(inputStream, out);
- LOGGER.info("Succesfully store the CBA archive {} at this location", targetZipFile);
+ LOGGER.info("Successfully store the CBA archive {} at this location", targetZipFile);
} catch (Exception e) {
LOGGER.error("Failed to put zip file into target location {}, {}", targetLocation, e);
}
}
@Override
- public void saveBluePrintToCdsDatabase(Path cbaArchivePath) {
- Optional<List<File>> zipFiles = getFilesFromDisk(cbaArchivePath);
- zipFiles.ifPresent(this::prepareRequestForCdsBackend);
+ public void saveBluePrintToCdsDatabase(Path cbaArchivePath, ManagedChannel channel) {
+ Optional<List<File>> zipFiles = FileUtil.getFilesFromDisk(cbaArchivePath);
+ zipFiles.ifPresent(files -> prepareRequestForCdsBackend(files, channel, cbaArchivePath.toString()));
}
@Override
@@ -114,9 +132,8 @@ public class ListenerServiceImpl implements ListenerService {
// Create CSAR storage directory
Path csarStorageDir = getStorageDirectory(csarArchivePath);
-
byte[] payload = result.getArtifactPayload();
- String csarFileName = result.getArtifactFilename() + CSAR_FILE_EXTENSION;
+ String csarFileName = result.getArtifactFilename();
Path targetLocation = csarStorageDir.resolve(csarFileName);
LOGGER.info("The target location for the CSAR file is {}", targetLocation);
@@ -137,49 +154,45 @@ public class ListenerServiceImpl implements ListenerService {
try {
return Files.createDirectories(fileStorageLocation);
} catch (IOException e) {
- LOGGER.error("Fail to create directory", e);
+ LOGGER.error("Fail to create directory {}, {}", e, fileStorageLocation);
}
}
return fileStorageLocation;
}
- private void prepareRequestForCdsBackend(List<File> files) {
- final ManagedChannel channel = getManagedChannel();
+ private void prepareRequestForCdsBackend(List<File> files, ManagedChannel managedChannel, String path) {
+ final String distributionId = cdsSdcListenerDto.getDistributionId();
files.forEach(zipFile -> {
try {
final BluePrintUploadInput request = generateBluePrintUploadInputBuilder(zipFile);
// Send request to CDS Backend.
- final Status responseStatus = bluePrintProcesssorHandler.sendRequest(request, channel);
+ final Status responseStatus = bluePrintProcesssorHandler.sendRequest(request, managedChannel);
if (responseStatus.getCode() != SUCCESS_CODE) {
- LOGGER.error("Failed to store the CBA archive into CDS DB due to {}",
+ final String errorMessage = String.format("Failed to store the CBA archive into CDS DB due to %s",
responseStatus.getErrorMessage());
+ listenerStatus.sendResponseStatusBackToSDC(distributionId,
+ COMPONENT_DONE_ERROR, errorMessage);
+ LOGGER.error(errorMessage);
+
} else {
LOGGER.info(responseStatus.getMessage());
+ listenerStatus.sendResponseStatusBackToSDC(distributionId,
+ COMPONENT_DONE_OK, null);
}
} catch (Exception e) {
- LOGGER.error("Failure due to", e);
+ final String errorMessage = String.format("Failure due to %s", e.getMessage());
+ listenerStatus.sendResponseStatusBackToSDC(distributionId, COMPONENT_DONE_ERROR, errorMessage);
+ LOGGER.error("Failure due to {}", e);
} finally {
- //Delete the file from the local disk.
- boolean fileDeleted = zipFile.delete();
-
- if (!fileDeleted) {
- LOGGER.error("Could not able to delete the zip file {}", zipFile.toString());
- }
+ FileUtil.deleteFile(zipFile, path);
}
});
}
- private ManagedChannel getManagedChannel() {
- return ManagedChannelBuilder.forAddress(grpcAddress, grpcPort)
- .usePlaintext()
- .intercept(cdsSdcListenerAuthClientInterceptor)
- .build();
- }
-
private BluePrintUploadInput generateBluePrintUploadInputBuilder(File file) throws IOException {
byte[] bytes = FileUtils.readFileToByteArray(file);
FileChunk fileChunk = FileChunk.newBuilder().setChunk(ByteString.copyFrom(bytes)).build();
@@ -188,23 +201,4 @@ public class ListenerServiceImpl implements ListenerService {
.setFileChunk(fileChunk)
.build();
}
-
- /**
- * Extract files from the given path
- *
- * @param path where files reside.
- * @return list of files.
- */
- public Optional<List<File>> getFilesFromDisk(Path path) {
- try (Stream<Path> fileTree = walk(path)) {
- // Get the list of files from the path
- return Optional.of(fileTree.filter(Files::isRegularFile)
- .map(Path::toFile)
- .collect(Collectors.toList()));
- } catch (IOException e) {
- LOGGER.error("Failed to find the file", e);
- }
-
- return Optional.empty();
- }
}
diff --git a/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/cds/cdssdclistener/status/CdsSdcListenerStatus.java b/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/cds/cdssdclistener/status/CdsSdcListenerStatus.java
new file mode 100644
index 000000000..60d3127f9
--- /dev/null
+++ b/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/cds/cdssdclistener/status/CdsSdcListenerStatus.java
@@ -0,0 +1,83 @@
+/*
+ * Copyright © 2019 Bell Canada
+ *
+ * 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.
+ */
+package org.onap.ccsdk.cds.cdssdclistener.status;
+
+import static org.onap.sdc.utils.DistributionActionResultEnum.SUCCESS;
+import java.util.Objects;
+import org.onap.ccsdk.cds.cdssdclistener.dto.CdsSdcListenerDto;
+import org.onap.ccsdk.cds.cdssdclistener.util.BuilderUtil;
+import org.onap.sdc.api.IDistributionClient;
+import org.onap.sdc.api.consumer.IFinalDistrStatusMessage;
+import org.onap.sdc.api.results.IDistributionClientResult;
+import org.onap.sdc.impl.DistributionClientImpl;
+import org.onap.sdc.utils.DistributionStatusEnum;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.stereotype.Component;
+
+@Component
+@ConfigurationProperties("listenerservice")
+@ComponentScan("org.onap.ccsdk.cds.cdssdclistener.dto")
+public class CdsSdcListenerStatus {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(CdsSdcListenerStatus.class);
+ private static final String COMPONENT_NAME = "cds";
+
+ @Value("${listenerservice.config.consumerId}")
+ private String consumerId;
+
+ @Autowired
+ private CdsSdcListenerDto cdsSdcListenerDto;
+
+ /**
+ * Send the response back to SDC.
+ *
+ * @param distributionID SDC Distribution ID
+ * @param status Distribution status
+ * @param errorReason Reason of failure
+ */
+ public void sendResponseStatusBackToSDC(String distributionID, DistributionStatusEnum status, String errorReason) {
+
+ final IDistributionClient distributionClient = cdsSdcListenerDto.getDistributionClient();
+
+ IFinalDistrStatusMessage finalDistribution = new BuilderUtil<>(new DistributionStatusMessage())
+ .build(builder -> {
+ builder.distributionID = distributionID;
+ builder.status = status;
+ builder.consumerID = consumerId;
+ builder.componentName = COMPONENT_NAME;
+ }).create();
+
+ if (errorReason == null) {
+ checkResponseStatusFromSdc(distributionClient.sendFinalDistrStatus(finalDistribution));
+ } else {
+ checkResponseStatusFromSdc(distributionClient.sendFinalDistrStatus(finalDistribution, errorReason));
+ }
+ }
+
+ private void checkResponseStatusFromSdc(IDistributionClientResult result) {
+ if (!Objects.equals(result.getDistributionActionResult(), SUCCESS)) {
+ LOGGER.error("SDC failed to receive the response from cds-sdc listener due to {}",
+ result.getDistributionMessageResult());
+ } else {
+ LOGGER.info("SDC successfully received the response");
+ }
+ }
+}
diff --git a/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/cds/cdssdclistener/status/DistributionStatusMessage.java b/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/cds/cdssdclistener/status/DistributionStatusMessage.java
new file mode 100644
index 000000000..676c85c98
--- /dev/null
+++ b/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/cds/cdssdclistener/status/DistributionStatusMessage.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright © 2019 Bell Canada
+ *
+ * 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.
+ */
+package org.onap.ccsdk.cds.cdssdclistener.status;
+
+import org.onap.sdc.api.consumer.IFinalDistrStatusMessage;
+import org.onap.sdc.utils.DistributionStatusEnum;
+
+public class DistributionStatusMessage implements IFinalDistrStatusMessage {
+
+ public String componentName;
+
+ public String consumerID;
+
+ public String distributionID;
+
+ public DistributionStatusEnum status;
+
+ @Override
+ public String getDistributionID() {
+ return distributionID;
+ }
+
+ @Override
+ public long getTimestamp() {
+ return 0;
+ }
+
+ @Override
+ public DistributionStatusEnum getStatus() {
+ return status;
+ }
+
+ @Override
+ public String getConsumerID() {
+ return consumerID;
+ }
+
+ @Override
+ public String getComponentName() {
+ return componentName;
+ }
+}
diff --git a/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/cds/cdssdclistener/util/BuilderUtil.java b/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/cds/cdssdclistener/util/BuilderUtil.java
new file mode 100644
index 000000000..4df545c82
--- /dev/null
+++ b/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/cds/cdssdclistener/util/BuilderUtil.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2019 Bell Canada. All rights reserved.
+ *
+ * NOTICE: All the intellectual and technical concepts contained herein are
+ * proprietary to Bell Canada and are protected by trade secret or copyright law.
+ * Unauthorized copying of this file, via any medium is strictly prohibited.
+ */
+package org.onap.ccsdk.cds.cdssdclistener.util;
+
+import java.util.function.Consumer;
+
+/**
+ * A generic builder for constructing an object.
+ *
+ * @param <T> - Any object
+ */
+public class BuilderUtil<T> {
+
+ private final T object;
+
+ public BuilderUtil(T instance) {
+ this.object = instance;
+ }
+
+ public BuilderUtil<T> build(Consumer<T> consumer) {
+ consumer.accept(object);
+ return this;
+ }
+
+ public T create() {
+ return object;
+ }
+}
diff --git a/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/cds/cdssdclistener/util/FileUtil.java b/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/cds/cdssdclistener/util/FileUtil.java
new file mode 100644
index 000000000..11f4eade1
--- /dev/null
+++ b/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/cds/cdssdclistener/util/FileUtil.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2019 Bell Canada. All rights reserved.
+ *
+ * NOTICE: All the intellectual and technical concepts contained herein are
+ * proprietary to Bell Canada and are protected by trade secret or copyright law.
+ * Unauthorized copying of this file, via any medium is strictly prohibited.
+ */
+
+package org.onap.ccsdk.cds.cdssdclistener.util;
+
+import static java.nio.file.Files.walk;
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.List;
+import java.util.Optional;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+import org.apache.commons.io.FileUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public final class FileUtil {
+ private static final Logger LOGGER = LoggerFactory.getLogger(FileUtils.class);
+
+ private FileUtil() {
+
+ }
+
+ /**
+ * Delete the file.
+ *
+ * @param file - Given file
+ * @param path - Given path
+ */
+ public static void deleteFile(File file, String path) {
+ boolean value = file.delete();
+ if (!value) {
+ LOGGER.error("Failed to delete the file {} at the location {}", file, path);
+ }
+ }
+
+ /**
+ * Extract files from the given path
+ *
+ * @param path where files reside.
+ * @return list of files.
+ */
+ public static Optional<List<File>> getFilesFromDisk(Path path) {
+ try (Stream<Path> fileTree = walk(path)) {
+ // Get the list of files from the path
+ return Optional.of(fileTree.filter(Files::isRegularFile)
+ .map(Path::toFile)
+ .collect(Collectors.toList()));
+ } catch (IOException e) {
+ LOGGER.error("Failed to find the file due to", e);
+ }
+ return Optional.empty();
+ }
+}
diff --git a/ms/cds-sdc-listener/application/src/main/resources/application.yml b/ms/cds-sdc-listener/application/src/main/resources/application.yml
index 657ea9e80..cb1b54c96 100644
--- a/ms/cds-sdc-listener/application/src/main/resources/application.yml
+++ b/ms/cds-sdc-listener/application/src/main/resources/application.yml
@@ -5,7 +5,7 @@ listenerservice:
user: vid
password: Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U
pollingInterval: 15
- pollingTimeout: 15
+ pollingTimeout: 60
relevantArtifactTypes: TOSCA_CSAR
consumerGroup: cds-id-local
environmentName: AUTO
@@ -14,7 +14,7 @@ listenerservice:
keyStorePath:
activateServerTLSAuth : false
isUseHttpsWithDmaap: false
- archivePath: opt/app/onap/cds-sdc-listener/
+ archivePath: /opt/app/onap/cds-sdc-listener/
grpcAddress: localhost
grpcPort: 9111
authHeader: Basic Y2NzZGthcHBzOmNjc2RrYXBwcw==
diff --git a/ms/cds-sdc-listener/application/src/test/java/org/onap/ccsdk/cds/cdssdclistener/CdsSdcListenerClientTest.java b/ms/cds-sdc-listener/application/src/test/java/org/onap/ccsdk/cds/cdssdclistener/CdsSdcListenerClientTest.java
index 948631462..e980c24c6 100644
--- a/ms/cds-sdc-listener/application/src/test/java/org/onap/ccsdk/cds/cdssdclistener/CdsSdcListenerClientTest.java
+++ b/ms/cds-sdc-listener/application/src/test/java/org/onap/ccsdk/cds/cdssdclistener/CdsSdcListenerClientTest.java
@@ -1,11 +1,18 @@
/*
- * Copyright (C) 2019 Bell Canada. All rights reserved.
+ * Copyright © 2019 Bell Canada
*
- * NOTICE: All the intellectual and technical concepts contained herein are
- * proprietary to Bell Canada and are protected by trade secret or copyright law.
- * Unauthorized copying of this file, via any medium is strictly prohibited.
+ * 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.
*/
-
package org.onap.ccsdk.cds.cdssdclistener;
import mockit.Expectations;
@@ -38,7 +45,7 @@ public class CdsSdcListenerClientTest {
@Injectable CdsSdcListenerNotificationCallback notification,
@Injectable CdsSdcListenerDto cdsSdcListenerDto) throws CdsSdcListenerException {
- // Arrange
+ //Arrange
new MockUp<DistributionClientFactory>() {
@Mock
public IDistributionClient createDistributionClient() {
diff --git a/ms/cds-sdc-listener/application/src/test/java/org/onap/ccsdk/cds/cdssdclistener/CdsSdcListenerConfigurationTest.java b/ms/cds-sdc-listener/application/src/test/java/org/onap/ccsdk/cds/cdssdclistener/CdsSdcListenerConfigurationTest.java
index 338b9c150..f940db2aa 100644
--- a/ms/cds-sdc-listener/application/src/test/java/org/onap/ccsdk/cds/cdssdclistener/CdsSdcListenerConfigurationTest.java
+++ b/ms/cds-sdc-listener/application/src/test/java/org/onap/ccsdk/cds/cdssdclistener/CdsSdcListenerConfigurationTest.java
@@ -1,11 +1,18 @@
/*
- * Copyright (C) 2019 Bell Canada. All rights reserved.
+ * Copyright © 2019 Bell Canada
*
- * NOTICE: All the intellectual and technical concepts contained herein are
- * proprietary to Bell Canada and are protected by trade secret or copyright law.
- * Unauthorized copying of this file, via any medium is strictly prohibited.
+ * 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.
*/
-
package org.onap.ccsdk.cds.cdssdclistener;
import static org.junit.Assert.assertEquals;
@@ -31,7 +38,7 @@ public class CdsSdcListenerConfigurationTest {
assertEquals(listenerConfiguration.getUser(), "vid");
assertEquals(listenerConfiguration.getPassword(), "Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U");
assertEquals(listenerConfiguration.getPollingInterval(), 15);
- assertEquals(listenerConfiguration.getPollingTimeout(), 15);
+ assertEquals(listenerConfiguration.getPollingTimeout(), 60);
assertEquals(listenerConfiguration.getRelevantArtifactTypes().stream().findFirst().get(), "TOSCA_CSAR");
assertEquals(listenerConfiguration.getConsumerGroup(), "cds-id-local");
assertEquals(listenerConfiguration.getEnvironmentName(), "AUTO");
diff --git a/ms/cds-sdc-listener/application/src/test/java/org/onap/ccsdk/cds/cdssdclistener/handler/BluePrintProcessorHandlerTest.java b/ms/cds-sdc-listener/application/src/test/java/org/onap/ccsdk/cds/cdssdclistener/handler/BluePrintProcessorHandlerTest.java
index 0d38decdf..f700a7dd2 100644
--- a/ms/cds-sdc-listener/application/src/test/java/org/onap/ccsdk/cds/cdssdclistener/handler/BluePrintProcessorHandlerTest.java
+++ b/ms/cds-sdc-listener/application/src/test/java/org/onap/ccsdk/cds/cdssdclistener/handler/BluePrintProcessorHandlerTest.java
@@ -1,11 +1,18 @@
/*
- * Copyright (C) 2019 Bell Canada. All rights reserved.
+ * Copyright © 2019 Bell Canada
*
- * NOTICE: All the intellectual and technical concepts contained herein are
- * proprietary to Bell Canada and are protected by trade secret or copyright law.
- * Unauthorized copying of this file, via any medium is strictly prohibited.
+ * 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.
*/
-
package org.onap.ccsdk.cds.cdssdclistener.handler;
import static org.junit.Assert.assertEquals;
@@ -35,7 +42,6 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
-
@RunWith(SpringRunner.class)
@EnableConfigurationProperties({BluePrintProcesssorHandler.class, CdsSdcListenerAuthClientInterceptor.class})
@SpringBootTest(classes = {BluePrintProcessorHandlerTest.class})
diff --git a/ms/cds-sdc-listener/application/src/test/java/org/onap/ccsdk/cds/cdssdclistener/service/ListenerServiceImplTest.java b/ms/cds-sdc-listener/application/src/test/java/org/onap/ccsdk/cds/cdssdclistener/service/ListenerServiceImplTest.java
index e33fbcdcc..359ee6cc4 100644
--- a/ms/cds-sdc-listener/application/src/test/java/org/onap/ccsdk/cds/cdssdclistener/service/ListenerServiceImplTest.java
+++ b/ms/cds-sdc-listener/application/src/test/java/org/onap/ccsdk/cds/cdssdclistener/service/ListenerServiceImplTest.java
@@ -1,34 +1,48 @@
/*
- * Copyright (C) 2019 Bell Canada. All rights reserved.
+ * Copyright © 2019 Bell Canada
*
- * NOTICE: All the intellectual and technical concepts contained herein are
- * proprietary to Bell Canada and are protected by trade secret or copyright law.
- * Unauthorized copying of this file, via any medium is strictly prohibited.
+ * 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.
*/
-
package org.onap.ccsdk.cds.cdssdclistener.service;
import static junit.framework.TestCase.assertTrue;
+import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
+import org.apache.commons.io.FileUtils;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.junit.runner.RunWith;
+import org.onap.ccsdk.cds.cdssdclistener.CdsSdcListenerConfiguration;
import org.onap.ccsdk.cds.cdssdclistener.client.CdsSdcListenerAuthClientInterceptor;
+import org.onap.ccsdk.cds.cdssdclistener.dto.CdsSdcListenerDto;
import org.onap.ccsdk.cds.cdssdclistener.handler.BluePrintProcesssorHandler;
-import org.onap.sdc.impl.mock.DistributionClientDownloadResultStubImpl;
+import org.onap.ccsdk.cds.cdssdclistener.status.CdsSdcListenerStatus;
+import org.onap.sdc.api.results.IDistributionClientDownloadResult;
+import org.onap.sdc.impl.mock.DistributionClientResultStubImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
-@EnableConfigurationProperties({ListenerServiceImpl.class, CdsSdcListenerAuthClientInterceptor.class,
- BluePrintProcesssorHandler.class})
+@EnableConfigurationProperties({CdsSdcListenerAuthClientInterceptor.class,
+ BluePrintProcesssorHandler.class, CdsSdcListenerDto.class, ListenerServiceImpl.class, CdsSdcListenerStatus.class,
+ CdsSdcListenerConfiguration.class})
@SpringBootTest(classes = {ListenerServiceImplTest.class})
public class ListenerServiceImplTest {
@@ -80,4 +94,33 @@ public class ListenerServiceImplTest {
.get()
.getName();
}
+
+ public byte[] convertFileToByteArray(File file) {
+ try {
+ return FileUtils.readFileToByteArray(file);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ public class DistributionClientDownloadResultStubImpl extends DistributionClientResultStubImpl implements
+ IDistributionClientDownloadResult {
+
+ public DistributionClientDownloadResultStubImpl() {
+ }
+
+ public byte[] getArtifactPayload() {
+ File file = Paths.get(CSAR_SAMPLE).toFile();
+ return convertFileToByteArray(file);
+ }
+
+ public String getArtifactName() {
+ return "MackArtifactName";
+ }
+
+ public String getArtifactFilename() {
+ return "MackArtifactName.csar";
+ }
+ }
}