Merge from ECOMP's repository
[vid.git] / vid-app-common / src / main / java / org / onap / vid / controller / WebConfig.java
  * ============LICENSE_END=========================================================
  */
 
-package org.onap.vid.controllers;
+package org.onap.vid.controller;
 
 import com.fasterxml.jackson.core.JsonProcessingException;
 import io.joshworks.restclient.http.mapper.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;
-import org.onap.vid.aai.PombaRestInterface;
+import org.onap.vid.aai.*;
 import org.onap.vid.aai.model.PortDetailsTranslator;
-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.aai.util.*;
 import org.onap.vid.asdc.AsdcClient;
 import org.onap.vid.asdc.parser.ToscaParserImpl2;
+import org.onap.vid.asdc.parser.VidNotionsBuilder;
 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.scheduler.SchedulerService;
+import org.onap.vid.scheduler.SchedulerServiceImpl;
+import org.onap.vid.services.*;
 import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
@@ -60,6 +43,7 @@ import org.togglz.core.manager.FeatureManager;
 
 import javax.servlet.ServletContext;
 import java.io.File;
+import java.io.IOException;
 
 @Configuration
 public class WebConfig {
@@ -80,6 +64,11 @@ public class WebConfig {
         return new VidServiceImpl(asdcClient, featureManager);
     }
 
+    @Bean
+    public SchedulerService schedulerService(ChangeManagementService changeManagementService) {
+        return new SchedulerServiceImpl(changeManagementService);
+    }
+
     @Bean
     public AaiService getAaiService() {
         return new AaiServiceImpl();
@@ -96,8 +85,8 @@ public class WebConfig {
     }
 
     @Bean
-    public AaiClientInterface getAaiRestInterface(@Qualifier("aaiRestInterface") AAIRestInterface restController, PortDetailsTranslator portsDetailsTranslator) {
-        return new AaiClient(restController, portsDetailsTranslator);
+    public AaiClientInterface getAaiRestInterface(@Qualifier("aaiRestInterface") AAIRestInterface restController, PortDetailsTranslator portsDetailsTranslator, CacheProvider cacheProvider) {
+        return new AaiClient(restController, portsDetailsTranslator, cacheProvider);
     }
 
     @Bean(name = "aaiRestInterface")
@@ -126,9 +115,9 @@ public class WebConfig {
     }
 
     @Bean
-    public HttpsAuthClient httpsAuthClientFactory(ServletContext servletContext, SystemPropertyHelper systemPropertyHelper, SSLContextProvider sslContextProvider) {
+    public HttpsAuthClient httpsAuthClientFactory(ServletContext servletContext, SystemPropertyHelper systemPropertyHelper, SSLContextProvider sslContextProvider ,FeatureManager featureManager) {
         final String certFilePath = new File(servletContext.getRealPath("/WEB-INF/cert/")).getAbsolutePath();
-        return new HttpsAuthClient(certFilePath, systemPropertyHelper, sslContextProvider);
+        return new HttpsAuthClient(certFilePath, systemPropertyHelper, sslContextProvider, featureManager);
     }
 
     @Bean
@@ -147,8 +136,13 @@ public class WebConfig {
     }
 
     @Bean
-    public ToscaParserImpl2 getToscaParser() {
-        return new ToscaParserImpl2();
+    public VidNotionsBuilder vidNotionsBuilder(FeatureManager featureManager) {
+        return new VidNotionsBuilder(featureManager);
+    }
+
+    @Bean
+    public ToscaParserImpl2 getToscaParser(VidNotionsBuilder vidNotionsBuilder) {
+        return new ToscaParserImpl2(vidNotionsBuilder);
     }
 
     @Bean
@@ -162,20 +156,23 @@ public class WebConfig {
     }
 
     @Bean
-    public SchedulerRestInterfaceIfc getSchedulerRestInterface(){
-        return new SchedulerRestInterface();
+    public ServiceInstanceStandardQuery serviceInstanceStandardQuery(AaiClientInterface aaiClient) {
+        return new ServiceInstanceStandardQuery(aaiClient);
     }
 
-    @Bean(name = "aaiClientForFasterXmlMapping")
-    public AaiOverTLSClientInterface getAaiClientForFasterXmlMapping(){
-         ObjectMapper objectMapper = new ObjectMapper() {
+    @Bean
+    public AaiOverTLSClientInterface aaiOverTLSClient(ObjectMapper unirestObjectMapper){
+        return new AaiOverTLSClient(new SyncRestClient(unirestObjectMapper), new AaiOverTLSPropertySupplier());
+    }
 
-            com.fasterxml.jackson.databind.ObjectMapper om = new com.fasterxml.jackson.databind.ObjectMapper();
+    @Bean
+    public ObjectMapper unirestFasterxmlObjectMapper(com.fasterxml.jackson.databind.ObjectMapper objectMapper) {
+        return new ObjectMapper() {
 
             @Override
             public <T> T readValue(String s, Class<T> aClass) {
                 try {
-                    return om.readValue(s, aClass);
+                    return objectMapper.readValue(s, aClass);
                 } catch (IOException e) {
                     throw new RuntimeException(e);
                 }
@@ -184,43 +181,13 @@ public class WebConfig {
             @Override
             public String writeValue(Object o) {
                 try {
-                    return om.writeValueAsString(o);
+                    return objectMapper.writeValueAsString(o);
                 } catch (JsonProcessingException e) {
                     throw new RuntimeException(e);
                 }
             }
         };
 
-        return new AaiOverTLSClient(new SyncRestClient(objectMapper), new AaiOverTLSPropertySupplier());
     }
 
-
-    @Bean(name = "aaiClientForCodehausMapping")
-    public AaiOverTLSClientInterface getAaiClientForCodehausMapping() {
-
-       ObjectMapper objectMapper = new ObjectMapper() {
-
-            org.codehaus.jackson.map.ObjectMapper om = new org.codehaus.jackson.map.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 (IOException e) {
-                    throw new RuntimeException(e);
-                }
-            }
-        };
-
-        return new AaiOverTLSClient(new SyncRestClient(objectMapper), new AaiOverTLSPropertySupplier());
-    }
 }