Aharoni, Pavel (pa0916) | ca3cb01 | 2018-10-22 15:29:57 +0300 | [diff] [blame] | 1 | /*-
|
| 2 | * ============LICENSE_START=======================================================
|
| 3 | * OSAM
|
| 4 | * ================================================================================
|
| 5 | * Copyright (C) 2018 AT&T
|
| 6 | * ================================================================================
|
| 7 | * Licensed under the Apache License, Version 2.0 (the "License");
|
| 8 | * you may not use this file except in compliance with the License.
|
| 9 | * You may obtain a copy of the License at
|
| 10 | *
|
| 11 | * http://www.apache.org/licenses/LICENSE-2.0
|
| 12 | *
|
| 13 | * Unless required by applicable law or agreed to in writing, software
|
| 14 | * distributed under the License is distributed on an "AS IS" BASIS,
|
| 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 16 | * See the License for the specific language governing permissions and
|
| 17 | * limitations under the License.
|
| 18 | * ============LICENSE_END=========================================================
|
| 19 | */
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 | package org.onap.osam.controllers;
|
| 24 |
|
| 25 | import com.fasterxml.jackson.databind.ObjectMapper;
|
| 26 | import org.onap.osam.aai.AaiClient;
|
| 27 | import org.onap.osam.aai.AaiClientInterface;
|
| 28 | import org.onap.osam.aai.PombaClientImpl;
|
| 29 | import org.onap.osam.aai.PombaClientInterface;
|
| 30 | import org.onap.osam.aai.PombaRestInterface;
|
| 31 | import org.onap.osam.aai.model.PortDetailsTranslator;
|
| 32 | import org.onap.osam.aai.util.AAIRestInterface;
|
| 33 | import org.onap.osam.aai.util.HttpsAuthClient;
|
| 34 | import org.onap.osam.aai.util.SSLContextProvider;
|
| 35 | import org.onap.osam.aai.util.ServletRequestHelper;
|
| 36 | import org.onap.osam.aai.util.SystemPropertyHelper;
|
| 37 | import org.onap.osam.client.SyncRestClient;
|
| 38 | import org.onap.osam.client.SyncRestClientInterface;
|
| 39 | import org.onap.osam.scheduler.SchedulerRestInterface;
|
| 40 | import org.onap.osam.scheduler.SchedulerRestInterfaceIfc;
|
| 41 | import org.onap.osam.services.AaiServiceImpl;
|
| 42 | import org.onap.osam.services.IAaiService;
|
| 43 | import org.onap.osam.services.IPombaService;
|
| 44 | import org.onap.osam.services.PombaServiceImpl;
|
| 45 | import org.springframework.beans.factory.annotation.Qualifier;
|
| 46 | import org.springframework.context.annotation.Bean;
|
| 47 | import org.springframework.context.annotation.Configuration;
|
Aharoni, Pavel (pa0916) | 0a8080c | 2018-11-22 15:45:19 +0200 | [diff] [blame] | 48 | import org.springframework.web.client.RestTemplate;
|
Aharoni, Pavel (pa0916) | ca3cb01 | 2018-10-22 15:29:57 +0300 | [diff] [blame] | 49 |
|
| 50 | import javax.servlet.ServletContext;
|
| 51 | import java.io.File;
|
| 52 |
|
| 53 | @Configuration
|
| 54 | public class WebConfig {
|
| 55 |
|
| 56 | @Bean
|
| 57 | public ObjectMapper getObjectMapper() {
|
| 58 | return new ObjectMapper();
|
| 59 | }
|
| 60 |
|
| 61 | @Bean
|
| 62 | public IAaiService getAaiService() {
|
| 63 | return new AaiServiceImpl();
|
| 64 | }
|
| 65 |
|
| 66 | @Bean
|
| 67 | public PortDetailsTranslator portDetailsTranslator() {
|
| 68 | return new PortDetailsTranslator();
|
| 69 | }
|
| 70 |
|
| 71 | @Bean
|
| 72 | public AaiClientInterface getAaiRestInterface(@Qualifier("aaiRestInterface") AAIRestInterface restController, PortDetailsTranslator portsDetailsTranslator) {
|
| 73 | return new AaiClient(restController, portsDetailsTranslator);
|
| 74 | }
|
| 75 |
|
| 76 | @Bean(name = "aaiRestInterface")
|
| 77 | public AAIRestInterface aaiRestInterface(HttpsAuthClient httpsAuthClientFactory, ServletRequestHelper servletRequestHelper, SystemPropertyHelper systemPropertyHelper) {
|
| 78 | return new AAIRestInterface(httpsAuthClientFactory, servletRequestHelper, systemPropertyHelper);
|
| 79 | }
|
| 80 |
|
| 81 | @Bean
|
| 82 | public PombaRestInterface getPombaRestInterface(HttpsAuthClient httpsAuthClientFactory, ServletRequestHelper servletRequestHelper, SystemPropertyHelper systemPropertyHelper) {
|
| 83 | return new PombaRestInterface(httpsAuthClientFactory, servletRequestHelper, systemPropertyHelper);
|
| 84 | }
|
| 85 |
|
| 86 | @Bean
|
| 87 | public SSLContextProvider sslContextProvider() {
|
| 88 | return new SSLContextProvider();
|
| 89 | }
|
| 90 |
|
| 91 | @Bean
|
| 92 | public SystemPropertyHelper systemPropertyHelper() {
|
| 93 | return new SystemPropertyHelper();
|
| 94 | }
|
| 95 |
|
| 96 | @Bean
|
| 97 | public ServletRequestHelper servletRequestHelper() {
|
| 98 | return new ServletRequestHelper();
|
| 99 | }
|
| 100 |
|
| 101 | @Bean
|
| 102 | public HttpsAuthClient httpsAuthClientFactory(ServletContext servletContext, SystemPropertyHelper systemPropertyHelper, SSLContextProvider sslContextProvider) {
|
| 103 | final String certFilePath = new File(servletContext.getRealPath("/WEB-INF/cert/")).getAbsolutePath();
|
| 104 | return new HttpsAuthClient(certFilePath, systemPropertyHelper, sslContextProvider);
|
| 105 | }
|
| 106 |
|
| 107 | @Bean
|
| 108 | public SyncRestClientInterface syncRestClient() {
|
| 109 | return new SyncRestClient();
|
| 110 | }
|
| 111 |
|
| 112 | @Bean
|
| 113 | public IPombaService getVerifyServiceInstanceService() {
|
| 114 | return new PombaServiceImpl();
|
| 115 | }
|
| 116 |
|
| 117 | @Bean
|
| 118 | public PombaClientInterface getVerifyServiceInstanceClientInterface() {
|
| 119 | return new PombaClientImpl();
|
| 120 | }
|
| 121 |
|
| 122 | @Bean
|
| 123 | public SchedulerRestInterfaceIfc getSchedulerRestInterface(){
|
| 124 | return new SchedulerRestInterface();
|
| 125 | }
|
Aharoni, Pavel (pa0916) | 0a8080c | 2018-11-22 15:45:19 +0200 | [diff] [blame] | 126 |
|
| 127 | @Bean
|
| 128 | public RestTemplate restTemplate() {
|
| 129 | return new RestTemplate();
|
| 130 | }
|
Aharoni, Pavel (pa0916) | ca3cb01 | 2018-10-22 15:29:57 +0300 | [diff] [blame] | 131 | }
|