diff options
author | beili.zhou <beili.zhou@amdocs.com> | 2017-08-11 22:16:05 -0400 |
---|---|---|
committer | beili.zhou <beili.zhou@amdocs.com> | 2017-08-14 13:33:08 -0400 |
commit | 9adb43f6b764ca4766c43fbdb8afe351f43a24ee (patch) | |
tree | 48e0c153f31a88237da2ecd851146ef56add431a /appc-oam/appc-oam-bundle/src/main/java/org/openecomp/appc/oam/util/ConfigurationHelper.java | |
parent | 5ac1e8648e03877d72e145ba59d2c6f9cca78ad2 (diff) |
OAM operations 2 - oam
OAM operations changes are large, need to break down to multiple
submissions based on size and compilability. This is the second set which
covers the following OAM operations: start, stop, restart,
maintenance-mode, and timeout of the operation along with error OAM
state.
Includes these user stories: APPC-39/41/43/44/45/46/52/77.
Issue Id: APPC-38
Change-Id: Iafad643c5ba2d2af24482b03db8f7a40397fa46e
Signed-off-by: beili.zhou <beili.zhou@amdocs.com>
Diffstat (limited to 'appc-oam/appc-oam-bundle/src/main/java/org/openecomp/appc/oam/util/ConfigurationHelper.java')
-rw-r--r-- | appc-oam/appc-oam-bundle/src/main/java/org/openecomp/appc/oam/util/ConfigurationHelper.java | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/appc-oam/appc-oam-bundle/src/main/java/org/openecomp/appc/oam/util/ConfigurationHelper.java b/appc-oam/appc-oam-bundle/src/main/java/org/openecomp/appc/oam/util/ConfigurationHelper.java new file mode 100644 index 000000000..c465b9b10 --- /dev/null +++ b/appc-oam/appc-oam-bundle/src/main/java/org/openecomp/appc/oam/util/ConfigurationHelper.java @@ -0,0 +1,80 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.appc.oam.util; + +import com.att.eelf.configuration.EELFLogger; +import org.apache.commons.lang3.ArrayUtils; +import org.openecomp.appc.Constants; +import org.openecomp.appc.configuration.Configuration; +import org.openecomp.appc.configuration.ConfigurationFactory; + +/** + * Utility class provides general configuration helps + */ +public class ConfigurationHelper { + final static String PROP_KEY_APPC_NAME = Constants.PROPERTY_APPLICATION_NAME; + final static String PROP_KEY_METRIC_STATE = "metric.enabled"; + + private final EELFLogger logger; + private Configuration configuration = ConfigurationFactory.getConfiguration(); + + public ConfigurationHelper(EELFLogger eelfLogger) { + logger = eelfLogger; + } + + public String getAppcName() { + return configuration.getProperty(PROP_KEY_APPC_NAME); + } + + public boolean isMetricEnabled() { + return configuration.getBooleanProperty(PROP_KEY_METRIC_STATE, false); + } + + public Configuration getConfig() { + return configuration; + } + + /** + * Read property value of a specified proeprty key + * + * @param propertyKey string of the property key + * @return String[] of the property values associated with the propertyKey + */ + String[] readProperty(String propertyKey) { + String propertyValue = configuration.getProperty(propertyKey); + if (propertyValue == null) { + return ArrayUtils.EMPTY_STRING_ARRAY; + } + + if (logger.isDebugEnabled()) { + logger.debug(String.format("Property[%s] has value (%s).", propertyKey, propertyValue)); + } + + if (propertyValue.contains(",")) { + return propertyValue.split("\\s*,\\s*"); + } + return new String[]{propertyValue}; + } +} |