2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
20 package org.openecomp.mso.adapters.sdnc.sdncrest;
22 import org.openecomp.mso.logger.MessageEnum;
23 import org.openecomp.mso.logger.MsoLogger;
24 import org.openecomp.mso.properties.MsoJavaProperties;
25 import org.openecomp.mso.properties.MsoPropertiesException;
26 import org.openecomp.mso.properties.MsoPropertiesFactory;
29 * Static methods to access SDNC adapter properties.
31 public final class SDNCAdapterProperties {
32 private static final String MSO_PROPERTIES_ID = "MSO_PROP_SDNC_ADAPTER";
33 private static final MsoPropertiesFactory MSO_PROPERTIES_FACTORY = new MsoPropertiesFactory();
34 private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA);
37 * Gets the value of an SDNC adapter property.
38 * @param key the property key
39 * @param defaultValue the default value to use if the property does not
40 * exist or if an error occurs
42 public static String getProperty(String key, String defaultValue) {
43 MsoJavaProperties properties;
46 properties = MSO_PROPERTIES_FACTORY.getMsoJavaProperties(MSO_PROPERTIES_ID);
47 } catch (MsoPropertiesException e) {
48 LOGGER.error (MessageEnum.NO_PROPERTIES, "Unknown. Mso Properties ID not found in cache: " + MSO_PROPERTIES_ID,
49 "SDNC", "", MsoLogger.ErrorCode.DataError, "Exception - Mso Properties ID not found in cache", e);
53 String value = properties.getProperty(key, defaultValue);
54 LOGGER.debug("Config read for " + MSO_PROPERTIES_ID + " - key:" + key + " value:" + value);
59 * Gets the value of an SDNC adapter property.
60 * @param key the property key
61 * @param defaultValue the default value to use if the property does not
62 * exist or if an error occurs
64 public static String getEncryptedProperty(String key, String defaultValue, String encryptionKey) {
65 MsoJavaProperties properties;
68 properties = MSO_PROPERTIES_FACTORY.getMsoJavaProperties(MSO_PROPERTIES_ID);
69 } catch (MsoPropertiesException e) {
70 LOGGER.error (MessageEnum.NO_PROPERTIES, "Unknown. Mso Properties ID not found in cache: " + MSO_PROPERTIES_ID,
71 "SDNC", "", MsoLogger.ErrorCode.DataError, "Exception - Mso Properties ID not found in cache", e);
75 String value = properties.getEncryptedProperty(key, defaultValue, encryptionKey);
76 LOGGER.debug("Config read for " + MSO_PROPERTIES_ID + " - key:" + key);
81 * Instantiation is not allowed.
83 private SDNCAdapterProperties() {