summaryrefslogtreecommitdiffstats
path: root/src/main/java/org
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org')
-rw-r--r--src/main/java/org/onap/aai/modelloader/notification/ArtifactDownloadManager.java11
-rw-r--r--src/main/java/org/onap/aai/modelloader/notification/EventCallback.java8
-rw-r--r--src/main/java/org/onap/aai/modelloader/restclient/AaiRestClient.java6
-rw-r--r--src/main/java/org/onap/aai/modelloader/restclient/BabelServiceClientFactory.java38
-rw-r--r--src/main/java/org/onap/aai/modelloader/service/ModelLoaderService.java5
5 files changed, 54 insertions, 14 deletions
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 bdd101e..3fa0b40 100644
--- a/src/main/java/org/onap/aai/modelloader/notification/ArtifactDownloadManager.java
+++ b/src/main/java/org/onap/aai/modelloader/notification/ArtifactDownloadManager.java
@@ -26,7 +26,6 @@ import java.util.Base64;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
-
import org.onap.aai.babel.service.data.BabelArtifact;
import org.onap.aai.babel.service.data.BabelArtifact.ArtifactType;
import org.onap.aai.cl.api.Logger;
@@ -40,6 +39,7 @@ import org.onap.aai.modelloader.entity.model.IModelParser;
import org.onap.aai.modelloader.entity.model.NamedQueryArtifactParser;
import org.onap.aai.modelloader.extraction.InvalidArchiveException;
import org.onap.aai.modelloader.restclient.BabelServiceClient;
+import org.onap.aai.modelloader.restclient.BabelServiceClientFactory;
import org.onap.aai.modelloader.service.ModelLoaderMsgs;
import org.openecomp.sdc.api.IDistributionClient;
import org.openecomp.sdc.api.notification.IArtifactInfo;
@@ -66,10 +66,13 @@ public class ArtifactDownloadManager {
private NotificationPublisher notificationPublisher;
private BabelArtifactConverter babelArtifactConverter;
private ModelLoaderConfig config;
+ private BabelServiceClientFactory clientFactory;
- public ArtifactDownloadManager(IDistributionClient client, ModelLoaderConfig config) {
+ public ArtifactDownloadManager(IDistributionClient client, ModelLoaderConfig config,
+ BabelServiceClientFactory clientFactory) {
this.client = client;
this.config = config;
+ this.clientFactory = clientFactory;
}
/**
@@ -193,12 +196,12 @@ public class ArtifactDownloadManager {
}
}
- private BabelServiceClient createBabelServiceClient(IArtifactInfo artifact, String serviceVersion)
+ BabelServiceClient createBabelServiceClient(IArtifactInfo artifact, String serviceVersion)
throws ProcessToscaArtifactsException {
BabelServiceClient babelClient;
try {
logger.debug(ModelLoaderMsgs.DISTRIBUTION_EVENT, "Creating Babel client");
- babelClient = new BabelServiceClient(config);
+ babelClient = clientFactory.create(config);
} catch (Exception e) {
logger.error(ModelLoaderMsgs.BABEL_REST_REQUEST_ERROR, e, "POST", config.getBabelBaseUrl(),
"Error posting artifact " + artifact.getArtifactName() + " " + serviceVersion + " to Babel: "
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 827ff81..fe6bf7b 100644
--- a/src/main/java/org/onap/aai/modelloader/notification/EventCallback.java
+++ b/src/main/java/org/onap/aai/modelloader/notification/EventCallback.java
@@ -28,6 +28,7 @@ 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.restclient.BabelServiceClientFactory;
import org.onap.aai.modelloader.service.ModelLoaderMsgs;
import org.openecomp.sdc.api.IDistributionClient;
import org.openecomp.sdc.api.consumer.INotificationCallback;
@@ -58,8 +59,8 @@ public class EventCallback implements INotificationCallback {
List<Artifact> catalogArtifacts = new ArrayList<>();
List<Artifact> modelArtifacts = new ArrayList<>();
- boolean success = getArtifactDownloadManager()
- .downloadArtifacts(data, artifacts, modelArtifacts, catalogArtifacts);
+ boolean success =
+ getArtifactDownloadManager().downloadArtifacts(data, artifacts, modelArtifacts, catalogArtifacts);
if (success) {
success = getArtifactDeploymentManager().deploy(data, artifacts, modelArtifacts, catalogArtifacts);
@@ -75,13 +76,12 @@ public class EventCallback implements INotificationCallback {
if (artifactDeploymentManager == null) {
artifactDeploymentManager = new ArtifactDeploymentManager(client, config);
}
-
return artifactDeploymentManager;
}
private ArtifactDownloadManager getArtifactDownloadManager() {
if (artifactDownloadManager == null) {
- artifactDownloadManager = new ArtifactDownloadManager(client, config);
+ artifactDownloadManager = new ArtifactDownloadManager(client, config, new BabelServiceClientFactory());
}
return artifactDownloadManager;
diff --git a/src/main/java/org/onap/aai/modelloader/restclient/AaiRestClient.java b/src/main/java/org/onap/aai/modelloader/restclient/AaiRestClient.java
index 7d2ab09..28cd671 100644
--- a/src/main/java/org/onap/aai/modelloader/restclient/AaiRestClient.java
+++ b/src/main/java/org/onap/aai/modelloader/restclient/AaiRestClient.java
@@ -21,7 +21,6 @@
package org.onap.aai.modelloader.restclient;
import com.sun.jersey.core.util.MultivaluedMapImpl; // NOSONAR
-// import edu.emory.mathcs.backport.java.util.Collections;
import java.io.IOException;
import java.io.StringReader;
import java.net.URI;
@@ -91,7 +90,7 @@ public class AaiRestClient {
* @return operation result
*/
public OperationResult putResource(String url, String payload, String transId, MediaType mediaType) {
- logger.info(ModelLoaderMsgs.AAI_REST_REQUEST_PAYLOAD, payload);
+ logger.info(ModelLoaderMsgs.AAI_REST_REQUEST_PAYLOAD, payload);
return setupClient().put(url, payload, buildHeaders(transId), mediaType, mediaType);
}
@@ -106,7 +105,7 @@ public class AaiRestClient {
* @return ClientResponse
*/
public OperationResult postResource(String url, String payload, String transId, MediaType mediaType) {
- logger.info(ModelLoaderMsgs.AAI_REST_REQUEST_PAYLOAD, payload);
+ logger.info(ModelLoaderMsgs.AAI_REST_REQUEST_PAYLOAD, payload);
return setupClient().post(url, payload, buildHeaders(transId), mediaType, mediaType);
}
@@ -180,7 +179,6 @@ public class AaiRestClient {
* @param transId
* @return map of headers
*/
- @SuppressWarnings("unchecked")
private Map<String, List<String>> buildHeaders(String transId) {
MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
headers.put(HEADER_TRANS_ID, Collections.singletonList(transId));
diff --git a/src/main/java/org/onap/aai/modelloader/restclient/BabelServiceClientFactory.java b/src/main/java/org/onap/aai/modelloader/restclient/BabelServiceClientFactory.java
new file mode 100644
index 0000000..6ce4a60
--- /dev/null
+++ b/src/main/java/org/onap/aai/modelloader/restclient/BabelServiceClientFactory.java
@@ -0,0 +1,38 @@
+/**
+ * ============LICENSE_START==========================================
+ * org.onap.aai
+ * ===================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017-2018 Amdocs
+ * ===================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END============================================
+ */
+package org.onap.aai.modelloader.restclient;
+
+import java.io.IOException;
+import java.security.KeyManagementException;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.security.UnrecoverableKeyException;
+import java.security.cert.CertificateException;
+import org.onap.aai.modelloader.config.ModelLoaderConfig;
+
+public class BabelServiceClientFactory {
+
+ public BabelServiceClient create(ModelLoaderConfig config) throws UnrecoverableKeyException, KeyManagementException,
+ NoSuchAlgorithmException, KeyStoreException, CertificateException, IOException {
+ return new BabelServiceClient(config);
+ }
+
+}
diff --git a/src/main/java/org/onap/aai/modelloader/service/ModelLoaderService.java b/src/main/java/org/onap/aai/modelloader/service/ModelLoaderService.java
index aa3481c..a4cc5d1 100644
--- a/src/main/java/org/onap/aai/modelloader/service/ModelLoaderService.java
+++ b/src/main/java/org/onap/aai/modelloader/service/ModelLoaderService.java
@@ -39,6 +39,7 @@ import org.onap.aai.modelloader.entity.Artifact;
import org.onap.aai.modelloader.notification.ArtifactDeploymentManager;
import org.onap.aai.modelloader.notification.ArtifactDownloadManager;
import org.onap.aai.modelloader.notification.EventCallback;
+import org.onap.aai.modelloader.restclient.BabelServiceClientFactory;
import org.openecomp.sdc.api.IDistributionClient;
import org.openecomp.sdc.api.notification.IArtifactInfo;
import org.openecomp.sdc.api.notification.INotificationData;
@@ -196,8 +197,8 @@ public class ModelLoaderService implements ModelLoaderInterface {
logger.info(ModelLoaderMsgs.DISTRIBUTION_EVENT, "Generating xml models from test artifact");
- new ArtifactDownloadManager(client, config).processToscaArtifacts(modelArtifacts, catalogArtifacts,
- csarFile, artifactInfo, "test-transaction-id", modelVersion);
+ new ArtifactDownloadManager(client, config, new BabelServiceClientFactory()).processToscaArtifacts(
+ modelArtifacts, catalogArtifacts, csarFile, artifactInfo, "test-transaction-id", modelVersion);
List<IArtifactInfo> artifacts = new ArrayList<>();
artifacts.add(artifactInfo);