add new format to fetch requests from MSO to the CM
[vid.git] / vid-app-common / src / main / java / org / onap / vid / controller / MsoConfig.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * VID
4  * ================================================================================
5  * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
6  * Modifications Copyright (C) 2018 - 2019 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
11  * 
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  * 
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=========================================================
20  */
21 package org.onap.vid.controller;
22
23 import io.joshworks.restclient.http.mapper.ObjectMapper;
24 import org.onap.portalsdk.core.util.SystemProperties;
25 import org.onap.vid.aai.AaiClientInterface;
26 import org.onap.vid.aai.util.HttpsAuthClient;
27 import org.onap.vid.client.SyncRestClient;
28 import org.onap.vid.factories.MsoRequestFactory;
29 import org.onap.vid.mso.MsoBusinessLogic;
30 import org.onap.vid.mso.MsoBusinessLogicImpl;
31 import org.onap.vid.mso.MsoInterface;
32 import org.onap.vid.mso.MsoProperties;
33 import org.onap.vid.mso.RestMsoImplementation;
34 import org.onap.vid.mso.rest.MsoRestClientNew;
35 import org.onap.vid.services.CloudOwnerService;
36 import org.onap.vid.services.CloudOwnerServiceImpl;
37 import org.onap.vid.utils.Logging;
38 import org.onap.vid.utils.SystemPropertiesWrapper;
39 import org.springframework.context.annotation.Bean;
40 import org.springframework.context.annotation.Configuration;
41 import org.togglz.core.manager.FeatureManager;
42
43
44 @Configuration
45 public class MsoConfig {
46
47     @Bean
48     public MsoRequestFactory createRequestDetailsFactory(){
49         return new MsoRequestFactory();
50     }
51
52     @Bean
53     public MsoRestClientNew msoRestClientNew(ObjectMapper unirestObjectMapper,
54         SystemPropertiesWrapper systemPropertiesWrapper,
55         Logging loggingService){
56         // Satisfy both interfaces -- MsoInterface and RestMsoImplementation
57         return new MsoRestClientNew(
58             new SyncRestClient(unirestObjectMapper, loggingService),
59             SystemProperties.getProperty(MsoProperties.MSO_SERVER_URL),
60             systemPropertiesWrapper
61         );
62     }
63
64     @Bean
65     public RestMsoImplementation restMsoImplementation(HttpsAuthClient httpsAuthClient,
66         SystemPropertiesWrapper systemPropertiesWrapper,
67         Logging loggingService){
68         // Satisfy both interfaces -- MsoInterface and RestMsoImplementation
69         return new RestMsoImplementation(
70             httpsAuthClient,
71             systemPropertiesWrapper,
72             loggingService
73         );
74     }
75
76
77     @Bean
78     public MsoBusinessLogic getMsoBusinessLogic(MsoInterface msoClient, FeatureManager featureManager){
79         return new MsoBusinessLogicImpl(msoClient, featureManager );
80     }
81
82     @Bean
83     public CloudOwnerService cloudOwnerService(AaiClientInterface aaiClient, FeatureManager featureManager) {
84         return new CloudOwnerServiceImpl(aaiClient, featureManager);
85     }
86
87
88 }