Nodes query rewritten to generic rest client
[vid.git] / vid-app-common / src / main / java / org / onap / vid / controllers / WebConfig.java
index 0f4b536..fb8b519 100644 (file)
 
 package org.onap.vid.controllers;
 
+import com.fasterxml.jackson.core.JsonProcessingException;
 import com.fasterxml.jackson.databind.ObjectMapper;
+import java.io.IOException;
 import org.onap.vid.aai.AaiClient;
 import org.onap.vid.aai.AaiClientInterface;
+import org.onap.vid.aai.AaiOverTLSClient;
+import org.onap.vid.aai.AaiOverTLSClientInterface;
+import org.onap.vid.aai.AaiOverTLSPropertySupplier;
 import org.onap.vid.aai.AaiResponseTranslator;
 import org.onap.vid.aai.PombaClientImpl;
 import org.onap.vid.aai.PombaClientInterface;
@@ -48,7 +53,6 @@ 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.*;
 import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
@@ -161,4 +165,34 @@ public class WebConfig {
     public SchedulerRestInterfaceIfc getSchedulerRestInterface(){
         return new SchedulerRestInterface();
     }
+
+
+    @Bean
+    public AaiOverTLSClientInterface getAaiOverTLSClientInterface() {
+
+        io.joshworks.restclient.http.mapper.ObjectMapper objectMapper = new io.joshworks.restclient.http.mapper.ObjectMapper() {
+
+            ObjectMapper om = new ObjectMapper();
+
+            @Override
+            public <T> T readValue(String s, Class<T> aClass) {
+                try {
+                    return om.readValue(s, aClass);
+                } catch (IOException e) {
+                    throw new RuntimeException(e);
+                }
+            }
+
+            @Override
+            public String writeValue(Object o) {
+                try {
+                    return om.writeValueAsString(o);
+                } catch (JsonProcessingException e) {
+                    throw new RuntimeException(e);
+                }
+            }
+        };
+
+        return new AaiOverTLSClient(new SyncRestClient(objectMapper), new AaiOverTLSPropertySupplier());
+    }
 }