X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fonap%2Faai%2Fmodelloader%2Fservice%2FArtifactDeploymentManager.java;h=222ae34ff512ec74110ee5894ed58f7f3a8487d3;hb=refs%2Fheads%2Fmaster;hp=af006f56f49ef20b53adff26783717346811f738;hpb=c5aea4a8bc398fc1c6220875e55b9520fd7f7524;p=aai%2Fmodel-loader.git
diff --git a/src/main/java/org/onap/aai/modelloader/service/ArtifactDeploymentManager.java b/src/main/java/org/onap/aai/modelloader/service/ArtifactDeploymentManager.java
index af006f5..e4535be 100644
--- a/src/main/java/org/onap/aai/modelloader/service/ArtifactDeploymentManager.java
+++ b/src/main/java/org/onap/aai/modelloader/service/ArtifactDeploymentManager.java
@@ -22,73 +22,57 @@ package org.onap.aai.modelloader.service;
import java.util.ArrayList;
import java.util.List;
-import org.onap.aai.modelloader.config.ModelLoaderConfig;
+
import org.onap.aai.modelloader.entity.Artifact;
import org.onap.aai.modelloader.entity.catalog.VnfCatalogArtifactHandler;
import org.onap.aai.modelloader.entity.model.ModelArtifactHandler;
import org.onap.aai.modelloader.restclient.AaiRestClient;
-import org.onap.sdc.api.notification.INotificationData;
+import org.springframework.stereotype.Component;
/**
* This class is responsible for deploying model and catalog artifacts.
*/
+@Component
public class ArtifactDeploymentManager {
- private ModelLoaderConfig config;
- private ModelArtifactHandler modelArtifactHandler;
- private VnfCatalogArtifactHandler vnfCatalogArtifactHandler;
+ private final ModelArtifactHandler modelArtifactHandler;
+ private final VnfCatalogArtifactHandler vnfCatalogArtifactHandler;
+ private final AaiRestClient aaiClient;
- public ArtifactDeploymentManager(ModelLoaderConfig config) {
- this.config = config;
+ public ArtifactDeploymentManager(ModelArtifactHandler modelArtifactHandler, VnfCatalogArtifactHandler vnfCatalogArtifactHandler, AaiRestClient aaiClient) {
+ this.modelArtifactHandler = modelArtifactHandler;
+ this.vnfCatalogArtifactHandler = vnfCatalogArtifactHandler;
+ this.aaiClient = aaiClient;
}
/**
* Deploys model and catalog artifacts to A&AI.
*
- * @param data data about the notification that is being processed
+ * @param distributionId data about the notification that is being processed
* @param modelArtifacts collection of artifacts that represent yml files found in a TOSCA_CSAR file that have been
* converted to XML and also those for model query specs
* @param catalogArtifacts collection of artifacts that represent vnf catalog files
* @return boolean true
if all deployments were successful otherwise false
*/
- public boolean deploy(final INotificationData data, final List modelArtifacts,
+ public boolean deploy(final String distributionId, final List modelArtifacts,
final List catalogArtifacts) {
- AaiRestClient aaiClient = new AaiRestClient(config);
- String distributionId = data.getDistributionID();
-
List completedArtifacts = new ArrayList<>();
boolean deploySuccess =
- getModelArtifactHandler().pushArtifacts(modelArtifacts, distributionId, completedArtifacts, aaiClient);
+ modelArtifactHandler.pushArtifacts(modelArtifacts, distributionId, completedArtifacts, aaiClient);
if (!deploySuccess) {
- getModelArtifactHandler().rollback(completedArtifacts, distributionId, aaiClient);
+ modelArtifactHandler.rollback(completedArtifacts, distributionId, aaiClient);
} else {
List completedImageData = new ArrayList<>();
- deploySuccess = getVnfCatalogArtifactHandler().pushArtifacts(catalogArtifacts, distributionId,
+ deploySuccess = vnfCatalogArtifactHandler.pushArtifacts(catalogArtifacts, distributionId,
completedImageData, aaiClient);
if (!deploySuccess) {
- getModelArtifactHandler().rollback(completedArtifacts, distributionId, aaiClient);
- getVnfCatalogArtifactHandler().rollback(completedImageData, distributionId, aaiClient);
+ modelArtifactHandler.rollback(completedArtifacts, distributionId, aaiClient);
+ vnfCatalogArtifactHandler.rollback(completedImageData, distributionId, aaiClient);
}
}
return deploySuccess;
}
-
- private ModelArtifactHandler getModelArtifactHandler() {
- if (modelArtifactHandler == null) {
- modelArtifactHandler = new ModelArtifactHandler(config);
- }
-
- return modelArtifactHandler;
- }
-
- private VnfCatalogArtifactHandler getVnfCatalogArtifactHandler() {
- if (vnfCatalogArtifactHandler == null) {
- this.vnfCatalogArtifactHandler = new VnfCatalogArtifactHandler(config);
- }
-
- return vnfCatalogArtifactHandler;
- }
-}
+}
\ No newline at end of file