aboutsummaryrefslogtreecommitdiffstats
path: root/vid-app-common/src/main/java/org/onap/vid/controllers
diff options
context:
space:
mode:
authorWojciech Sliwka <wojciech.sliwka@nokia.com>2018-08-20 15:45:03 +0200
committerWojciech Sliwka <wojciech.sliwka@nokia.com>2018-08-24 12:26:03 +0200
commit17e8b54e83547d8dc37c335c5df1b989f8b5ff3c (patch)
tree87201581f26048e7c88a1d9339392f7c11d05b8e /vid-app-common/src/main/java/org/onap/vid/controllers
parent5adc0b0ee92d1e39ddaacd27e67a327dd5988f11 (diff)
Replace sdc client
Replace old SDC client to use genericRestClient Change-Id: I9b3b567871ac3f319742fca9457e42b6d4db0a8a Issue-ID: VID-268 Signed-off-by: Wojciech Sliwka <wojciech.sliwka@nokia.com>
Diffstat (limited to 'vid-app-common/src/main/java/org/onap/vid/controllers')
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controllers/WebConfig.java72
1 files changed, 32 insertions, 40 deletions
diff --git a/vid-app-common/src/main/java/org/onap/vid/controllers/WebConfig.java b/vid-app-common/src/main/java/org/onap/vid/controllers/WebConfig.java
index cf32e92e0..0f4b536a1 100644
--- a/vid-app-common/src/main/java/org/onap/vid/controllers/WebConfig.java
+++ b/vid-app-common/src/main/java/org/onap/vid/controllers/WebConfig.java
@@ -22,14 +22,30 @@
package org.onap.vid.controllers;
import com.fasterxml.jackson.databind.ObjectMapper;
-import org.onap.vid.aai.*;
+import org.onap.vid.aai.AaiClient;
+import org.onap.vid.aai.AaiClientInterface;
+import org.onap.vid.aai.AaiResponseTranslator;
+import org.onap.vid.aai.PombaClientImpl;
+import org.onap.vid.aai.PombaClientInterface;
+import org.onap.vid.aai.PombaRestInterface;
import org.onap.vid.aai.model.PortDetailsTranslator;
-import org.onap.vid.aai.util.*;
+import org.onap.vid.aai.util.AAIRestInterface;
+import org.onap.vid.aai.util.HttpsAuthClient;
+import org.onap.vid.aai.util.SSLContextProvider;
+import org.onap.vid.aai.util.ServletRequestHelper;
+import org.onap.vid.aai.util.SystemPropertyHelper;
import org.onap.vid.asdc.AsdcClient;
import org.onap.vid.asdc.parser.ToscaParserImpl2;
-import org.onap.vid.asdc.rest.RestfulAsdcClient;
-import org.onap.vid.exceptions.GenericUncheckedException;
+import org.onap.vid.asdc.rest.SdcRestClient;
+import org.onap.vid.client.SyncRestClient;
+import org.onap.vid.client.SyncRestClientInterface;
import org.onap.vid.properties.AsdcClientConfiguration;
+import org.onap.vid.services.AaiService;
+import org.onap.vid.services.AaiServiceImpl;
+import org.onap.vid.services.PombaService;
+import org.onap.vid.services.PombaServiceImpl;
+import org.onap.vid.services.VidService;
+import org.onap.vid.services.VidServiceImpl;
import org.onap.vid.scheduler.SchedulerRestInterface;
import org.onap.vid.scheduler.SchedulerRestInterfaceIfc;
import org.onap.vid.services.*;
@@ -38,15 +54,8 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.togglz.core.manager.FeatureManager;
-import javax.net.ssl.SSLContext;
import javax.servlet.ServletContext;
-import javax.ws.rs.client.Client;
-import javax.ws.rs.client.ClientBuilder;
import java.io.File;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.security.KeyManagementException;
-import java.security.NoSuchAlgorithmException;
@Configuration
public class WebConfig {
@@ -119,35 +128,18 @@ public class WebConfig {
}
@Bean
- public AsdcClient asdcClient(AsdcClientConfiguration asdcClientConfig) {
-
- final String protocol = asdcClientConfig.getAsdcClientProtocol();
- final String host = asdcClientConfig.getAsdcClientHost();
- final int port = asdcClientConfig.getAsdcClientPort();
- final String auth = asdcClientConfig.getAsdcClientAuth();
- Client cl = null;
- if (protocol.equalsIgnoreCase("https")) {
- try {
- SSLContext ctx = SSLContext.getInstance("TLSv1.2");
- ctx.init(null, null, null);
- cl = ClientBuilder.newBuilder().sslContext(ctx).build();
- } catch (NoSuchAlgorithmException n) {
- throw new GenericUncheckedException("SDC Client could not be instantiated due to unsupported protocol TLSv1.2", n);
- } catch (KeyManagementException k) {
- throw new GenericUncheckedException("SDC Client could not be instantiated due to a key management exception", k);
- }
- } else {
- cl = ClientBuilder.newBuilder().build();
- }
-
- try {
- final URI uri = new URI(protocol + "://" + host + ":" + port + "/");
- return new RestfulAsdcClient.Builder(cl, uri)
- .auth(auth)
- .build();
- } catch (URISyntaxException e) {
- throw new GenericUncheckedException("SDC Client could not be instantiated due to a syntax error in the URI", e);
- }
+ public AsdcClient sdcClient(AsdcClientConfiguration asdcClientConfiguration, SyncRestClientInterface syncRestClient) {
+ String auth = asdcClientConfiguration.getAsdcClientAuth();
+ String host = asdcClientConfiguration.getAsdcClientHost();
+ String protocol = asdcClientConfiguration.getAsdcClientProtocol();
+ int port = asdcClientConfiguration.getAsdcClientPort();
+
+ return new SdcRestClient(protocol + "://" + host + ":" + port + "/", auth, syncRestClient);
+ }
+
+ @Bean
+ public SyncRestClientInterface syncRestClient() {
+ return new SyncRestClient();
}
@Bean