Implement Attributes/Outputs BE (part 2)
[sdc.git] / catalog-be / src / main / java / org / openecomp / sdc / config / CatalogBESpringConfig.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
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  * Modifications copyright (c) 2019 Nokia
20  * ================================================================================
21  */
22 package org.openecomp.sdc.config;
23
24 import org.apache.http.impl.client.CloseableHttpClient;
25 import org.onap.portalsdk.core.onboarding.exception.CipherUtilException;
26 import org.onap.sdc.security.PortalClient;
27 import org.openecomp.sdc.be.auditing.impl.ConfigurationProvider;
28 import org.openecomp.sdc.be.components.impl.ComponentLocker;
29 import org.openecomp.sdc.be.components.impl.aaf.RoleAuthorizationHandler;
30 import org.openecomp.sdc.be.components.impl.lock.ComponentLockAspect;
31 import org.openecomp.sdc.be.components.lifecycle.LifecycleBusinessLogic;
32 import org.openecomp.sdc.be.config.ConfigurationManager;
33 import org.openecomp.sdc.be.ecomp.converters.AssetMetadataConverter;
34 import org.openecomp.sdc.be.filters.FilterConfiguration;
35 import org.openecomp.sdc.be.filters.PortalConfiguration;
36 import org.openecomp.sdc.be.filters.ThreadLocalUtils;
37 import org.springframework.beans.factory.annotation.Autowired;
38 import org.springframework.context.annotation.Bean;
39 import org.springframework.context.annotation.ComponentScan;
40 import org.springframework.context.annotation.Configuration;
41 import org.springframework.core.annotation.Order;
42
43 @Configuration
44 @ComponentScan({"org.openecomp.sdc.be.user",
45     "org.openecomp.sdc.be.facade.operations",
46     "org.openecomp.sdc.be.impl",
47     "org.openecomp.sdc.be.auditing.impl",
48     "org.openecomp.sdc.be.distribution",
49     "org.openecomp.sdc.be.switchover.detector",
50     "org.openecomp.sdc.be.tosca",
51     "org.openecomp.sdc.be.components.validation",
52     "org.openecomp.sdc.be.catalog.impl",
53     "org.openecomp.sdc.be.components.impl",
54     "org.openecomp.sdc.be.components.path",
55     "org.openecomp.sdc.be.components.merge",
56     "org.openecomp.sdc.be.components.csar",
57     "org.openecomp.sdc.be.components.property",
58     "org.openecomp.sdc.be.components.attribute",
59     "org.openecomp.sdc.be.csar.security",
60     "org.openecomp.sdc.be.datamodel.utils",
61     "org.openecomp.sdc.be.components.upgrade",
62     "org.openecomp.sdc.be.externalapi.servlet",
63     "org.openecomp.sdc.be.servlets",
64     "org.openecomp.sdc.be.filters",
65     "org.openecomp.sdc.be.plugins",
66     "org.openecomp.sdc.be.togglz"
67 })
68 public class CatalogBESpringConfig {
69
70     private static final int BEFORE_TRANSACTION_MANAGER = 0;
71     private final ComponentLocker componentLocker;
72
73     @Autowired
74     public CatalogBESpringConfig(ComponentLocker componentLocker) {
75         this.componentLocker = componentLocker;
76     }
77
78     @Bean(name = "lifecycleBusinessLogic")
79     public LifecycleBusinessLogic lifecycleBusinessLogic() {
80         return new LifecycleBusinessLogic();
81     }
82
83     @Bean(name = "configurationProvider")
84     public ConfigurationProvider configurationProvider() {
85         return new ConfigurationProvider();
86     }
87
88     @Bean(name = "asset-metadata-utils")
89     public AssetMetadataConverter assetMetadataConverter() {
90         return new AssetMetadataConverter();
91     }
92
93     @Bean(name = "componentLockAspect")
94     @Order(BEFORE_TRANSACTION_MANAGER)
95     public ComponentLockAspect componentLockAspect() {
96         return new ComponentLockAspect(componentLocker);
97     }
98
99     @Bean
100     public RoleAuthorizationHandler roleAuthorizationHandler() {return new RoleAuthorizationHandler();}
101
102     @Bean
103     public CloseableHttpClient httpClientConnectionManager() {
104         HttpClientFactory httpClientFactory = new HttpClientFactory();
105         return httpClientFactory.createHttpClient();
106     }
107
108     @Bean
109     public PortalConfiguration portalConfiguration() throws CipherUtilException {return new PortalConfiguration();}
110
111     @Bean
112     public FilterConfiguration filterConfiguration() {return new FilterConfiguration(configuration());}
113
114     @Bean
115     public ThreadLocalUtils threadLocalUtils() {return new ThreadLocalUtils();}
116
117     @Bean
118     public PortalClient portalClient() throws CipherUtilException {
119         return new PortalClient(httpClientConnectionManager(), portalConfiguration());
120     }
121
122     @Bean
123     public org.openecomp.sdc.be.config.Configuration configuration(){
124         return ConfigurationManager.getConfigurationManager().getConfiguration();
125     }
126
127 }