2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
6 * Copyright © 2017 Amdocs
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=========================================================
21 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
23 package org.onap.aai.sparky.dal.aai.config;
26 import java.net.URISyntaxException;
27 import java.util.Properties;
29 import org.onap.aai.cl.api.Logger;
30 import org.onap.aai.cl.eelf.LoggerFactory;
31 import org.onap.aai.sparky.logging.AaiUiMsgs;
32 import org.onap.aai.sparky.util.ConfigHelper;
33 import org.onap.aai.sparky.util.Encryptor;
34 import org.onap.aai.sparky.viewandinspect.config.TierSupportUiConstants;
37 * The Class ActiveInventoryConfig.
39 public class ActiveInventoryConfig {
41 public static final String CONFIG_FILE =
42 TierSupportUiConstants.DYNAMIC_CONFIG_APP_LOCATION + "aai.properties";
43 private static ActiveInventoryConfig instance;
45 private static final Logger LOG =
46 LoggerFactory.getInstance().getLogger(ActiveInventoryConfig.class);
49 public static ActiveInventoryConfig getConfig() throws Exception {
50 if (instance == null) {
51 instance = new ActiveInventoryConfig();
57 private ActiveInventoryRestConfig aaiRestConfig;
58 private ActiveInventorySslConfig aaiSslConfig;
61 * Instantiates a new active inventory config.
63 * @throws Exception the exception
65 protected ActiveInventoryConfig() throws Exception {
67 Properties props = ConfigHelper.loadConfigFromExplicitPath(CONFIG_FILE);
71 public ActiveInventoryConfig(Properties props) throws Exception {
75 private void initialize(Properties props) {
76 aaiRestConfig = new ActiveInventoryRestConfig(props);
77 aaiSslConfig = new ActiveInventorySslConfig(props, new Encryptor());
80 public ActiveInventoryRestConfig getAaiRestConfig() {
84 public void setAaiRestConfig(ActiveInventoryRestConfig aaiRestConfig) {
85 this.aaiRestConfig = aaiRestConfig;
88 public ActiveInventorySslConfig getAaiSslConfig() {
92 public void setAaiSslConfig(ActiveInventorySslConfig aaiSslConfig) {
93 this.aaiSslConfig = aaiSslConfig;
98 public static String extractResourcePath(String selflink) {
100 return new URI(selflink).getRawPath();
101 } catch (URISyntaxException uriSyntaxException) {
102 LOG.error(AaiUiMsgs.ERROR_EXTRACTING_RESOURCE_PATH_FROM_LINK,
103 uriSyntaxException.getMessage());
111 * @see java.lang.Object#toString()
114 public String toString() {
115 return "ActiveInventoryConfig [aaiRestConfig=" + aaiRestConfig + ", aaiSslConfig="
116 + aaiSslConfig + "]";