2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * Modifications Copyright (C) 2018 Nokia. All rights reserved.
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
22 package org.onap.vid.controllers;
24 import com.fasterxml.jackson.databind.ObjectMapper;
25 import org.onap.vid.aai.AaiClient;
26 import org.onap.vid.aai.AaiClientInterface;
27 import org.onap.vid.aai.AaiResponseTranslator;
28 import org.onap.vid.aai.PombaClientImpl;
29 import org.onap.vid.aai.PombaClientInterface;
30 import org.onap.vid.aai.PombaRestInterface;
31 import org.onap.vid.aai.model.PortDetailsTranslator;
32 import org.onap.vid.aai.util.AAIRestInterface;
33 import org.onap.vid.aai.util.HttpsAuthClient;
34 import org.onap.vid.aai.util.SSLContextProvider;
35 import org.onap.vid.aai.util.ServletRequestHelper;
36 import org.onap.vid.aai.util.SystemPropertyHelper;
37 import org.onap.vid.asdc.AsdcClient;
38 import org.onap.vid.asdc.parser.ToscaParserImpl2;
39 import org.onap.vid.asdc.rest.SdcRestClient;
40 import org.onap.vid.client.SyncRestClient;
41 import org.onap.vid.client.SyncRestClientInterface;
42 import org.onap.vid.properties.AsdcClientConfiguration;
43 import org.onap.vid.services.AaiService;
44 import org.onap.vid.services.AaiServiceImpl;
45 import org.onap.vid.services.PombaService;
46 import org.onap.vid.services.PombaServiceImpl;
47 import org.onap.vid.services.VidService;
48 import org.onap.vid.services.VidServiceImpl;
49 import org.onap.vid.scheduler.SchedulerRestInterface;
50 import org.onap.vid.scheduler.SchedulerRestInterfaceIfc;
51 import org.onap.vid.services.*;
52 import org.springframework.beans.factory.annotation.Qualifier;
53 import org.springframework.context.annotation.Bean;
54 import org.springframework.context.annotation.Configuration;
55 import org.togglz.core.manager.FeatureManager;
57 import javax.servlet.ServletContext;
61 public class WebConfig {
64 * Gets the object mapper.
66 * @return the object mapper
69 public ObjectMapper getObjectMapper() {
70 return new ObjectMapper();
75 public VidService vidService(AsdcClient asdcClient, FeatureManager featureManager) {
76 return new VidServiceImpl(asdcClient, featureManager);
80 public AaiService getAaiService() {
81 return new AaiServiceImpl();
85 public AaiResponseTranslator aaiResponseTranslator() {
86 return new AaiResponseTranslator();
90 public PortDetailsTranslator portDetailsTranslator() {
91 return new PortDetailsTranslator();
95 public AaiClientInterface getAaiRestInterface(@Qualifier("aaiRestInterface") AAIRestInterface restController, PortDetailsTranslator portsDetailsTranslator) {
96 return new AaiClient(restController, portsDetailsTranslator);
99 @Bean(name = "aaiRestInterface")
100 public AAIRestInterface aaiRestInterface(HttpsAuthClient httpsAuthClientFactory, ServletRequestHelper servletRequestHelper, SystemPropertyHelper systemPropertyHelper) {
101 return new AAIRestInterface(httpsAuthClientFactory, servletRequestHelper, systemPropertyHelper);
105 public PombaRestInterface getPombaRestInterface(HttpsAuthClient httpsAuthClientFactory, ServletRequestHelper servletRequestHelper, SystemPropertyHelper systemPropertyHelper) {
106 return new PombaRestInterface(httpsAuthClientFactory, servletRequestHelper, systemPropertyHelper);
110 public SSLContextProvider sslContextProvider() {
111 return new SSLContextProvider();
115 public SystemPropertyHelper systemPropertyHelper() {
116 return new SystemPropertyHelper();
120 public ServletRequestHelper servletRequestHelper() {
121 return new ServletRequestHelper();
125 public HttpsAuthClient httpsAuthClientFactory(ServletContext servletContext, SystemPropertyHelper systemPropertyHelper, SSLContextProvider sslContextProvider) {
126 final String certFilePath = new File(servletContext.getRealPath("/WEB-INF/cert/")).getAbsolutePath();
127 return new HttpsAuthClient(certFilePath, systemPropertyHelper, sslContextProvider);
131 public AsdcClient sdcClient(AsdcClientConfiguration asdcClientConfiguration, SyncRestClientInterface syncRestClient) {
132 String auth = asdcClientConfiguration.getAsdcClientAuth();
133 String host = asdcClientConfiguration.getAsdcClientHost();
134 String protocol = asdcClientConfiguration.getAsdcClientProtocol();
135 int port = asdcClientConfiguration.getAsdcClientPort();
137 return new SdcRestClient(protocol + "://" + host + ":" + port + "/", auth, syncRestClient);
141 public SyncRestClientInterface syncRestClient() {
142 return new SyncRestClient();
146 public ToscaParserImpl2 getToscaParser() {
147 return new ToscaParserImpl2();
151 public PombaService getVerifyServiceInstanceService() {
152 return new PombaServiceImpl();
156 public PombaClientInterface getVerifyServiceInstanceClientInterface() {
157 return new PombaClientImpl();
161 public SchedulerRestInterfaceIfc getSchedulerRestInterface(){
162 return new SchedulerRestInterface();