2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Copyright (C) 2017 Amdocs
8 * =============================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
21 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22 * ============LICENSE_END=========================================================
25 package org.openecomp.appc.oam.util;
27 import com.att.eelf.configuration.EELFLogger;
28 import org.apache.commons.lang3.ArrayUtils;
29 import org.openecomp.appc.Constants;
30 import org.openecomp.appc.configuration.Configuration;
31 import org.openecomp.appc.configuration.ConfigurationFactory;
34 * Utility class provides general configuration helps
36 public class ConfigurationHelper {
37 final static String PROP_KEY_APPC_NAME = Constants.PROPERTY_APPLICATION_NAME;
38 final static String PROP_KEY_METRIC_STATE = "metric.enabled";
40 private final EELFLogger logger;
41 private Configuration configuration = ConfigurationFactory.getConfiguration();
43 public ConfigurationHelper(EELFLogger eelfLogger) {
47 public String getAppcName() {
48 return configuration.getProperty(PROP_KEY_APPC_NAME);
51 public boolean isMetricEnabled() {
52 return configuration.getBooleanProperty(PROP_KEY_METRIC_STATE, false);
55 public Configuration getConfig() {
60 * Read property value of a specified proeprty key
62 * @param propertyKey string of the property key
63 * @return String[] of the property values associated with the propertyKey
65 String[] readProperty(String propertyKey) {
66 String propertyValue = configuration.getProperty(propertyKey);
67 if (propertyValue == null) {
68 return ArrayUtils.EMPTY_STRING_ARRAY;
71 if (logger.isDebugEnabled()) {
72 logger.debug(String.format("Property[%s] has value (%s).", propertyKey, propertyValue));
75 if (propertyValue.contains(",")) {
76 return propertyValue.split("\\s*,\\s*");
78 return new String[]{propertyValue};