2 * ============LICENSE_START=======================================================
 
   4 * ================================================================================
 
   5 * Copyright 2018 TechMahindra
 
   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.onap.universalvesadapter.configs;
 
  23 import java.util.concurrent.ConcurrentHashMap;
 
  24 import org.slf4j.Logger;
 
  25 import org.slf4j.LoggerFactory;
 
  26 import org.springframework.beans.factory.annotation.Value;
 
  27 import org.springframework.stereotype.Component;
 
  30  * Configuration for universal adapter service 
 
  36 public class UniversalEventConfiguration{
 
  38         private final Logger LOGGER = LoggerFactory.getLogger(this.getClass());
 
  40         @Value("${universal.configFiles}")
 
  41         private String configFiles;
 
  43         private Map<String, String> eventToConfigFileMap = new ConcurrentHashMap<>();
 
  47          * Returns config file for a particular event from the mapping. 
 
  48          * If mapping is empty, populates its
 
  52          * @return config file name
 
  54         public String getConfigForEvent(String eventType){
 
  55                 LOGGER.debug("Getting config file name for event:" + eventType);
 
  56                 if(null != configFiles && eventToConfigFileMap.isEmpty()){
 
  57                         for(String entry : configFiles.split(",")){
 
  58                                 eventToConfigFileMap.put(entry.split(":")[0], entry.split(":")[1]);
 
  60                         LOGGER.debug("Populated mappings for event type to config files");
 
  63                 return (null == eventToConfigFileMap.get(eventType)) ? "default" : eventToConfigFileMap.get(eventType) ;