aboutsummaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/org/onap/aai/modelloader/config/BeanConfig.java7
-rw-r--r--src/main/java/org/onap/aai/modelloader/entity/catalog/VnfCatalogArtifactHandler.java2
-rw-r--r--src/main/java/org/onap/aai/modelloader/entity/model/ModelArtifactHandler.java2
-rw-r--r--src/main/java/org/onap/aai/modelloader/extraction/VnfCatalogExtractor.java2
-rw-r--r--src/main/java/org/onap/aai/modelloader/notification/ArtifactDownloadManager.java55
-rw-r--r--src/main/java/org/onap/aai/modelloader/notification/BabelArtifactConverter.java4
-rw-r--r--src/main/java/org/onap/aai/modelloader/notification/EventCallback.java58
-rw-r--r--src/main/java/org/onap/aai/modelloader/notification/NotificationPublisher.java2
-rw-r--r--src/main/java/org/onap/aai/modelloader/restclient/HttpsBabelServiceClient.java3
-rw-r--r--src/main/java/org/onap/aai/modelloader/service/ArtifactDeploymentManager.java38
-rw-r--r--src/main/java/org/onap/aai/modelloader/service/ModelController.java15
-rw-r--r--src/main/java/org/onap/aai/modelloader/service/SdcConnectionJob.java7
12 files changed, 71 insertions, 124 deletions
diff --git a/src/main/java/org/onap/aai/modelloader/config/BeanConfig.java b/src/main/java/org/onap/aai/modelloader/config/BeanConfig.java
index 2d7775d..8f7b2bb 100644
--- a/src/main/java/org/onap/aai/modelloader/config/BeanConfig.java
+++ b/src/main/java/org/onap/aai/modelloader/config/BeanConfig.java
@@ -27,8 +27,6 @@ import java.util.Properties;
import org.onap.aai.cl.api.Logger;
import org.onap.aai.cl.eelf.LoggerFactory;
-import org.onap.aai.modelloader.notification.EventCallback;
-import org.onap.aai.modelloader.service.BabelServiceClientFactory;
import org.onap.aai.modelloader.service.ModelLoaderMsgs;
import org.onap.sdc.api.IDistributionClient;
import org.onap.sdc.impl.DistributionClientFactory;
@@ -60,9 +58,4 @@ public class BeanConfig {
public IDistributionClient iDistributionClient() {
return DistributionClientFactory.createDistributionClient();
}
-
- @Bean
- public EventCallback eventCallback(IDistributionClient client, ModelLoaderConfig config, BabelServiceClientFactory babelClientFactory) {
- return new EventCallback(client, config, babelClientFactory);
- }
}
diff --git a/src/main/java/org/onap/aai/modelloader/entity/catalog/VnfCatalogArtifactHandler.java b/src/main/java/org/onap/aai/modelloader/entity/catalog/VnfCatalogArtifactHandler.java
index c54d7b2..c1f6e9b 100644
--- a/src/main/java/org/onap/aai/modelloader/entity/catalog/VnfCatalogArtifactHandler.java
+++ b/src/main/java/org/onap/aai/modelloader/entity/catalog/VnfCatalogArtifactHandler.java
@@ -44,6 +44,7 @@ import org.onap.aai.modelloader.entity.ArtifactHandler;
import org.onap.aai.modelloader.restclient.AaiRestClient;
import org.onap.aai.modelloader.service.ModelLoaderMsgs;
import org.onap.aai.restclient.client.OperationResult;
+import org.springframework.stereotype.Component;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -53,6 +54,7 @@ import org.xml.sax.InputSource;
/**
* VNF Catalog specific handling
*/
+@Component
public class VnfCatalogArtifactHandler extends ArtifactHandler {
private static Logger logger = LoggerFactory.getInstance().getLogger(VnfCatalogArtifactHandler.class.getName());
diff --git a/src/main/java/org/onap/aai/modelloader/entity/model/ModelArtifactHandler.java b/src/main/java/org/onap/aai/modelloader/entity/model/ModelArtifactHandler.java
index 626ca49..7aa2191 100644
--- a/src/main/java/org/onap/aai/modelloader/entity/model/ModelArtifactHandler.java
+++ b/src/main/java/org/onap/aai/modelloader/entity/model/ModelArtifactHandler.java
@@ -28,7 +28,9 @@ import org.onap.aai.modelloader.entity.Artifact;
import org.onap.aai.modelloader.entity.ArtifactHandler;
import org.onap.aai.modelloader.restclient.AaiRestClient;
import org.onap.aai.modelloader.service.ModelLoaderMsgs;
+import org.springframework.stereotype.Service;
+@Service
public class ModelArtifactHandler extends ArtifactHandler {
private static Logger logger = LoggerFactory.getInstance().getLogger(ModelArtifactHandler.class.getName());
diff --git a/src/main/java/org/onap/aai/modelloader/extraction/VnfCatalogExtractor.java b/src/main/java/org/onap/aai/modelloader/extraction/VnfCatalogExtractor.java
index 3dbdfcc..64ecf8a 100644
--- a/src/main/java/org/onap/aai/modelloader/extraction/VnfCatalogExtractor.java
+++ b/src/main/java/org/onap/aai/modelloader/extraction/VnfCatalogExtractor.java
@@ -38,6 +38,7 @@ import org.onap.aai.modelloader.entity.Artifact;
import org.onap.aai.modelloader.entity.ArtifactType;
import org.onap.aai.modelloader.entity.catalog.VnfCatalogArtifact;
import org.onap.aai.modelloader.service.ModelLoaderMsgs;
+import org.springframework.stereotype.Component;
/**
@@ -47,6 +48,7 @@ import org.onap.aai.modelloader.service.ModelLoaderMsgs;
* A .csar file is a compressed archive like a zip file and this class will treat the byte array as it if were a zip
* file.
*/
+@Component
public class VnfCatalogExtractor {
private static final Logger logger = LoggerFactory.getInstance().getLogger(VnfCatalogExtractor.class.getName());
diff --git a/src/main/java/org/onap/aai/modelloader/notification/ArtifactDownloadManager.java b/src/main/java/org/onap/aai/modelloader/notification/ArtifactDownloadManager.java
index 58bb074..dcec799 100644
--- a/src/main/java/org/onap/aai/modelloader/notification/ArtifactDownloadManager.java
+++ b/src/main/java/org/onap/aai/modelloader/notification/ArtifactDownloadManager.java
@@ -49,6 +49,7 @@ import org.onap.sdc.api.notification.INotificationData;
import org.onap.sdc.api.results.IDistributionClientDownloadResult;
import org.onap.sdc.utils.ArtifactTypeEnum;
import org.onap.sdc.utils.DistributionActionResultEnum;
+import org.springframework.stereotype.Component;
/**
* This class is responsible for downloading the artifacts from the ASDC.
@@ -60,22 +61,26 @@ import org.onap.sdc.utils.DistributionActionResultEnum;
*
* TOSCA_CSAR file artifacts will be converted into XML and returned as model artifacts.
*/
+@Component
public class ArtifactDownloadManager {
private static Logger logger = LoggerFactory.getInstance().getLogger(ArtifactDownloadManager.class);
- private IDistributionClient client;
- private NotificationPublisher notificationPublisher;
- private BabelArtifactConverter babelArtifactConverter;
- private ModelLoaderConfig config;
- private BabelServiceClientFactory clientFactory;
- private VnfCatalogExtractor vnfCatalogExtractor;
+ private final IDistributionClient client;
+ private final NotificationPublisher notificationPublisher;
+ private final BabelArtifactConverter babelArtifactConverter;
+ private final ModelLoaderConfig config;
+ private final BabelServiceClientFactory clientFactory;
+ private final VnfCatalogExtractor vnfCatalogExtractor;
public ArtifactDownloadManager(IDistributionClient client, ModelLoaderConfig config,
- BabelServiceClientFactory clientFactory) {
+ BabelServiceClientFactory clientFactory, BabelArtifactConverter babelArtifactConverter, NotificationPublisher notificationPublisher, VnfCatalogExtractor vnfCatalogExtractor) {
this.client = client;
+ this.notificationPublisher = notificationPublisher;
+ this.babelArtifactConverter = babelArtifactConverter;
this.config = config;
this.clientFactory = clientFactory;
+ this.vnfCatalogExtractor = vnfCatalogExtractor;
}
/**
@@ -96,10 +101,10 @@ public class ArtifactDownloadManager {
IDistributionClientDownloadResult downloadResult = downloadIndividualArtifacts(data, artifact);
processDownloadedArtifacts(modelArtifacts, catalogArtifacts, artifact, downloadResult, data);
} catch (DownloadFailureException e) {
- getNotificationPublisher().publishDownloadFailure(client, data, artifact, e.getMessage());
+ notificationPublisher.publishDownloadFailure(client, data, artifact, e.getMessage());
success = false;
} catch (Exception e) {
- getNotificationPublisher().publishDeployFailure(client, data, artifact);
+ notificationPublisher.publishDeployFailure(client, data, artifact);
success = false;
}
@@ -126,7 +131,7 @@ public class ArtifactDownloadManager {
if (DistributionActionResultEnum.SUCCESS.equals(downloadResult.getDistributionActionResult())) {
logger.info(ModelLoaderMsgs.DISTRIBUTION_EVENT, "Downloaded artifact: " + artifact.getArtifactName());
- getNotificationPublisher().publishDownloadSuccess(client, data, artifact);
+ notificationPublisher.publishDownloadSuccess(client, data, artifact);
} else {
throw new DownloadFailureException(downloadResult.getDistributionMessageResult());
}
@@ -156,7 +161,7 @@ public class ArtifactDownloadManager {
invokeBabelService(modelArtifacts, catalogArtifacts, payload, artifactInfo, distributionId, serviceVersion);
// Get VNF Catalog artifacts directly from CSAR
- List<Artifact> csarCatalogArtifacts = getVnfCatalogExtractor().extract(payload, artifactInfo.getArtifactName());
+ List<Artifact> csarCatalogArtifacts = vnfCatalogExtractor.extract(payload, artifactInfo.getArtifactName());
// Throw an error if VNF Catalog data is present in the Babel payload and directly in the CSAR
if (!catalogArtifacts.isEmpty() && !csarCatalogArtifacts.isEmpty()) {
@@ -187,12 +192,12 @@ public class ArtifactDownloadManager {
if (artifactMap.containsKey(BabelArtifact.ArtifactType.MODEL)) {
modelArtifacts.addAll(
- getBabelArtifactConverter().convertToModel(artifactMap.get(BabelArtifact.ArtifactType.MODEL)));
+ babelArtifactConverter.convertToModel(artifactMap.get(BabelArtifact.ArtifactType.MODEL)));
artifactMap.remove(BabelArtifact.ArtifactType.MODEL);
}
if (artifactMap.containsKey(BabelArtifact.ArtifactType.VNFCATALOG)) {
- catalogArtifacts.addAll(getBabelArtifactConverter()
+ catalogArtifacts.addAll(babelArtifactConverter
.convertToCatalog(artifactMap.get(BabelArtifact.ArtifactType.VNFCATALOG)));
artifactMap.remove(BabelArtifact.ArtifactType.VNFCATALOG);
}
@@ -257,28 +262,4 @@ public class ArtifactDownloadManager {
private boolean parsedArtifactsExist(List<Artifact> parsedArtifacts) {
return parsedArtifacts != null && !parsedArtifacts.isEmpty();
}
-
- private NotificationPublisher getNotificationPublisher() {
- if (notificationPublisher == null) {
- notificationPublisher = new NotificationPublisher();
- }
-
- return notificationPublisher;
- }
-
- private BabelArtifactConverter getBabelArtifactConverter() {
- if (babelArtifactConverter == null) {
- babelArtifactConverter = new BabelArtifactConverter();
- }
-
- return babelArtifactConverter;
- }
-
- private VnfCatalogExtractor getVnfCatalogExtractor() {
- if (vnfCatalogExtractor == null) {
- vnfCatalogExtractor = new VnfCatalogExtractor();
- }
-
- return vnfCatalogExtractor;
- }
}
diff --git a/src/main/java/org/onap/aai/modelloader/notification/BabelArtifactConverter.java b/src/main/java/org/onap/aai/modelloader/notification/BabelArtifactConverter.java
index ad4eb7d..480a461 100644
--- a/src/main/java/org/onap/aai/modelloader/notification/BabelArtifactConverter.java
+++ b/src/main/java/org/onap/aai/modelloader/notification/BabelArtifactConverter.java
@@ -29,12 +29,14 @@ import org.onap.aai.modelloader.entity.catalog.VnfCatalogArtifact;
import org.onap.aai.modelloader.entity.model.BabelArtifactParsingException;
import org.onap.aai.modelloader.entity.model.ModelArtifact;
import org.onap.aai.modelloader.entity.model.ModelArtifactParser;
+import org.springframework.stereotype.Component;
/**
* This class is responsible for converting TOSCA artifacts into instances of {@link ModelArtifact} ready for pushing
* the converted artifacts .
*/
-class BabelArtifactConverter {
+@Component
+public class BabelArtifactConverter {
/**
* This method converts BabelArtifacts into instances of {@link ModelArtifact}.
diff --git a/src/main/java/org/onap/aai/modelloader/notification/EventCallback.java b/src/main/java/org/onap/aai/modelloader/notification/EventCallback.java
index d7bccba..754eaff 100644
--- a/src/main/java/org/onap/aai/modelloader/notification/EventCallback.java
+++ b/src/main/java/org/onap/aai/modelloader/notification/EventCallback.java
@@ -26,33 +26,32 @@ import java.util.List;
import org.onap.aai.cl.api.Logger;
import org.onap.aai.cl.eelf.LoggerFactory;
import org.onap.aai.cl.mdc.MdcContext;
-import org.onap.aai.modelloader.config.ModelLoaderConfig;
import org.onap.aai.modelloader.entity.Artifact;
import org.onap.aai.modelloader.extraction.ArtifactInfoExtractor;
import org.onap.aai.modelloader.service.ArtifactDeploymentManager;
-import org.onap.aai.modelloader.service.BabelServiceClientFactory;
import org.onap.aai.modelloader.service.ModelLoaderMsgs;
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.slf4j.MDC;
+import org.springframework.stereotype.Component;
+@Component
public class EventCallback implements INotificationCallback {
private static Logger logger = LoggerFactory.getInstance().getLogger(EventCallback.class.getName());
private static Logger auditLogger = LoggerFactory.getInstance().getAuditLogger(EventCallback.class.getName());
- private ArtifactDeploymentManager artifactDeploymentManager;
- private ArtifactDownloadManager artifactDownloadManager;
- private NotificationPublisher notificationPublisher;
- private IDistributionClient client;
- private ModelLoaderConfig config;
- private BabelServiceClientFactory babelServiceClientFactory;
+ private final ArtifactDeploymentManager artifactDeploymentManager;
+ private final ArtifactDownloadManager artifactDownloadManager;
+ private final NotificationPublisher notificationPublisher;
+ private final IDistributionClient client;
- public EventCallback(IDistributionClient client, ModelLoaderConfig config, BabelServiceClientFactory babelServiceClientFactory) {
+ public EventCallback(IDistributionClient client, ArtifactDeploymentManager artifactDeploymentManager, ArtifactDownloadManager artifactDownloadManager, NotificationPublisher notificationPublisher) {
+ this.artifactDeploymentManager = artifactDeploymentManager;
+ this.artifactDownloadManager = artifactDownloadManager;
+ this.notificationPublisher = notificationPublisher;
this.client = client;
- this.config = config;
- this.babelServiceClientFactory = babelServiceClientFactory;
}
@Override
@@ -65,10 +64,10 @@ public class EventCallback implements INotificationCallback {
List<Artifact> modelArtifacts = new ArrayList<>();
boolean success =
- getArtifactDownloadManager().downloadArtifacts(data, artifacts, modelArtifacts, catalogArtifacts);
+ artifactDownloadManager.downloadArtifacts(data, artifacts, modelArtifacts, catalogArtifacts);
if (success) {
- success = getArtifactDeploymentManager().deploy(data, modelArtifacts, catalogArtifacts);
+ success = artifactDeploymentManager.deploy(data, modelArtifacts, catalogArtifacts);
}
String statusString = success ? "SUCCESS" : "FAILURE";
@@ -85,37 +84,12 @@ public class EventCallback implements INotificationCallback {
boolean deploymentSuccess) {
if (deploymentSuccess) {
artifacts.stream().filter(a -> filterType.equalsIgnoreCase(a.getArtifactType()))
- .forEach(a -> getNotificationPublisher().publishDeploySuccess(client, data, a));
- getNotificationPublisher().publishComponentSuccess(client, data);
+ .forEach(a -> notificationPublisher.publishDeploySuccess(client, data, a));
+ notificationPublisher.publishComponentSuccess(client, data);
} else {
artifacts.stream().filter(a -> filterType.equalsIgnoreCase(a.getArtifactType()))
- .forEach(a -> getNotificationPublisher().publishDeployFailure(client, data, a));
- getNotificationPublisher().publishComponentFailure(client, data, "deploy failure");
+ .forEach(a -> notificationPublisher.publishDeployFailure(client, data, a));
+ notificationPublisher.publishComponentFailure(client, data, "deploy failure");
}
}
-
- private ArtifactDeploymentManager getArtifactDeploymentManager() {
- if (artifactDeploymentManager == null) {
- artifactDeploymentManager = new ArtifactDeploymentManager(config);
- }
-
- return artifactDeploymentManager;
- }
-
- private ArtifactDownloadManager getArtifactDownloadManager() {
- if (artifactDownloadManager == null) {
- artifactDownloadManager = new ArtifactDownloadManager(client, config, babelServiceClientFactory);
- }
-
- return artifactDownloadManager;
- }
-
-
- private NotificationPublisher getNotificationPublisher() {
- if (notificationPublisher == null) {
- notificationPublisher = new NotificationPublisher();
- }
-
- return notificationPublisher;
- }
}
diff --git a/src/main/java/org/onap/aai/modelloader/notification/NotificationPublisher.java b/src/main/java/org/onap/aai/modelloader/notification/NotificationPublisher.java
index 6e6ff13..7d5b1cc 100644
--- a/src/main/java/org/onap/aai/modelloader/notification/NotificationPublisher.java
+++ b/src/main/java/org/onap/aai/modelloader/notification/NotificationPublisher.java
@@ -38,10 +38,12 @@ import org.onap.sdc.api.notification.INotificationData;
import org.onap.sdc.api.results.IDistributionClientResult;
import org.onap.sdc.utils.DistributionActionResultEnum;
import org.onap.sdc.utils.DistributionStatusEnum;
+import org.springframework.stereotype.Component;
/**
* This class is responsible for publishing the status of actions performed working with artifacts.
*/
+@Component
public class NotificationPublisher {
private static Logger logger = LoggerFactory.getInstance().getLogger(NotificationPublisher.class);
diff --git a/src/main/java/org/onap/aai/modelloader/restclient/HttpsBabelServiceClient.java b/src/main/java/org/onap/aai/modelloader/restclient/HttpsBabelServiceClient.java
index 289015c..88967b2 100644
--- a/src/main/java/org/onap/aai/modelloader/restclient/HttpsBabelServiceClient.java
+++ b/src/main/java/org/onap/aai/modelloader/restclient/HttpsBabelServiceClient.java
@@ -224,7 +224,8 @@ public class HttpsBabelServiceClient implements BabelServiceClient {
MdcOverride override = new MdcOverride();
override.addAttribute(MdcContext.MDC_START_TIME, ZonedDateTime.now().format(formatter));
- WebResource webResource = client.resource(config.getBabelBaseUrl() + config.getBabelGenerateArtifactsUrl());
+ String resourceUrl = config.getBabelBaseUrl() + config.getBabelGenerateArtifactsUrl();
+ WebResource webResource = client.resource(resourceUrl);
ClientResponse response = webResource.type("application/json")
.header(AaiRestClient.HEADER_TRANS_ID, Collections.singletonList(transactionId))
.header(AaiRestClient.HEADER_FROM_APP_ID, Collections.singletonList(AaiRestClient.ML_APP_NAME))
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..9f09703 100644
--- a/src/main/java/org/onap/aai/modelloader/service/ArtifactDeploymentManager.java
+++ b/src/main/java/org/onap/aai/modelloader/service/ArtifactDeploymentManager.java
@@ -28,18 +28,22 @@ 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 ModelLoaderConfig config;
+ private final ModelArtifactHandler modelArtifactHandler;
+ private final VnfCatalogArtifactHandler vnfCatalogArtifactHandler;
- public ArtifactDeploymentManager(ModelLoaderConfig config) {
+ public ArtifactDeploymentManager(ModelLoaderConfig config, ModelArtifactHandler modelArtifactHandler, VnfCatalogArtifactHandler vnfCatalogArtifactHandler) {
this.config = config;
+ this.modelArtifactHandler = modelArtifactHandler;
+ this.vnfCatalogArtifactHandler = vnfCatalogArtifactHandler;
}
/**
@@ -59,36 +63,20 @@ public class ArtifactDeploymentManager {
List<Artifact> 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<Artifact> 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;
- }
}
diff --git a/src/main/java/org/onap/aai/modelloader/service/ModelController.java b/src/main/java/org/onap/aai/modelloader/service/ModelController.java
index 0ca2c02..0921982 100644
--- a/src/main/java/org/onap/aai/modelloader/service/ModelController.java
+++ b/src/main/java/org/onap/aai/modelloader/service/ModelController.java
@@ -55,19 +55,20 @@ import org.springframework.web.bind.annotation.RestController;
@RequestMapping("/services/model-loader/v1/model-service")
public class ModelController implements ModelLoaderInterface {
- private static final Logger logger = LoggerFactory.getInstance().getLogger(ModelController.class.getName());
+ private static final Logger logger = LoggerFactory.getInstance().getLogger(ModelController.class);
private final IDistributionClient client;
private final ModelLoaderConfig config;
private final EventCallback eventCallback;
- private final BabelServiceClientFactory babelClientFactory;
+ private final ArtifactDeploymentManager artifactDeploymentManager;
+ private final ArtifactDownloadManager artifactDownloadManager;
- public ModelController(IDistributionClient client, ModelLoaderConfig config, EventCallback eventCallback,
- BabelServiceClientFactory babelClientFactory) {
+ public ModelController(IDistributionClient client, ModelLoaderConfig config, EventCallback eventCallback, ArtifactDeploymentManager artifactDeploymentManager, ArtifactDownloadManager artifactDownloadManager) {
this.client = client;
this.config = config;
this.eventCallback = eventCallback;
- this.babelClientFactory = babelClientFactory;
+ this.artifactDeploymentManager = artifactDeploymentManager;
+ this.artifactDownloadManager = artifactDownloadManager;
}
/**
@@ -167,7 +168,7 @@ public class ModelController implements ModelLoaderInterface {
List<Artifact> modelArtifacts = new ArrayList<>();
List<Artifact> catalogArtifacts = new ArrayList<>();
- new ArtifactDownloadManager(client, config, babelClientFactory).processToscaArtifacts(modelArtifacts,
+ artifactDownloadManager.processToscaArtifacts(modelArtifacts,
catalogArtifacts, csarFile, artifactInfo, "test-transaction-id", modelVersion);
logger.info(ModelLoaderMsgs.DISTRIBUTION_EVENT, "Loading xml models from test artifacts: "
@@ -176,7 +177,7 @@ public class ModelController implements ModelLoaderInterface {
NotificationDataImpl notificationData = new NotificationDataImpl();
notificationData.setDistributionID("TestDistributionID");
boolean success =
- new ArtifactDeploymentManager(config).deploy(notificationData, modelArtifacts, catalogArtifacts);
+ artifactDeploymentManager.deploy(notificationData, modelArtifacts, catalogArtifacts);
logger.info(ModelLoaderMsgs.DISTRIBUTION_EVENT, "Deployment success was " + success);
response = success ? Response.ok().build() : Response.serverError().build();
} catch (Exception e) {
diff --git a/src/main/java/org/onap/aai/modelloader/service/SdcConnectionJob.java b/src/main/java/org/onap/aai/modelloader/service/SdcConnectionJob.java
index 9a6c6e9..79cf538 100644
--- a/src/main/java/org/onap/aai/modelloader/service/SdcConnectionJob.java
+++ b/src/main/java/org/onap/aai/modelloader/service/SdcConnectionJob.java
@@ -34,12 +34,11 @@ public class SdcConnectionJob extends TimerTask {
private static final Logger logger = LoggerFactory.getInstance().getLogger(SdcConnectionJob.class.getName());
private final IDistributionClient client;
- private ModelLoaderConfig config;
- private EventCallback callback;
- private Timer timer;
+ private final ModelLoaderConfig config;
+ private final EventCallback callback;
+ private final Timer timer;
public SdcConnectionJob(IDistributionClient client, ModelLoaderConfig config, EventCallback callback, Timer timer) {
- super();
this.client = client;
this.timer = timer;
this.callback = callback;