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.workflowmessage;
 
  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 Workflow Message Adapter properties.
 
  31 public final class WMAdapterProperties {
 
  32         private static final MsoPropertiesFactory MSO_PROPERTIES_FACTORY = new MsoPropertiesFactory();
 
  33         private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA);
 
  36          * Gets the value of a Workflow Message Adapter property.
 
  37          * @param key the property key
 
  38          * @param defaultValue the default value to use if the property does not
 
  39          *        exist or if an error occurs
 
  41         public static String getProperty(String key, String defaultValue) {
 
  42                 MsoJavaProperties properties;
 
  45                         properties = MSO_PROPERTIES_FACTORY.getMsoJavaProperties(WMAdapterConstants.MSO_PROPERTIES_ID);
 
  46                 } catch (MsoPropertiesException e) {
 
  47                         LOGGER.error (MessageEnum.NO_PROPERTIES,
 
  48                                 "Unknown. MSO Properties ID not found in cache: " + WMAdapterConstants.MSO_PROPERTIES_ID,
 
  49                                 "WorkflowMessageAdatper", "", MsoLogger.ErrorCode.DataError,
 
  50                                 "Exception - MSO Properties ID not found in cache", e);
 
  54                 String value = properties.getProperty(key, defaultValue);
 
  55                 LOGGER.debug("Config read for " + WMAdapterConstants.MSO_PROPERTIES_ID
 
  56                         + " - key:" + key + " value:" + value);
 
  61          * Gets the value of an Workflow Message Adapter property.
 
  62          * @param key the property key
 
  63          * @param defaultValue the default value to use if the property does not
 
  64          *        exist or if an error occurs
 
  66         public static String getEncryptedProperty(String key, String defaultValue, String encryptionKey) {
 
  67                 MsoJavaProperties properties;
 
  70                         properties = MSO_PROPERTIES_FACTORY.getMsoJavaProperties(WMAdapterConstants.MSO_PROPERTIES_ID);
 
  71                 } catch (MsoPropertiesException e) {
 
  72                         LOGGER.error (MessageEnum.NO_PROPERTIES,
 
  73                                 "Unknown. MSO Properties ID not found in cache: " + WMAdapterConstants.MSO_PROPERTIES_ID,
 
  74                                 "WorkflowMessageAdatper", "", MsoLogger.ErrorCode.DataError,
 
  75                                 "Exception - MSO Properties ID not found in cache", e);
 
  79                 String value = properties.getEncryptedProperty(key, defaultValue, encryptionKey);
 
  80                 LOGGER.debug("Config read for " + WMAdapterConstants.MSO_PROPERTIES_ID + " - key:" + key);
 
  85          * Instantiation is not allowed.
 
  87         private WMAdapterProperties() {