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 extends Configuration {
38 private final Logger LOGGER = LoggerFactory.getLogger(this.getClass());
40 @Value("${snmpTrap.configFile}")
41 private String configFile;
43 @Value("${universal.configFiles}")
44 private String configFiles;
46 private Map<String, String> eventToConfigFileMap = new ConcurrentHashMap<>();
50 * Returns config file for a particular event from the mapping.
51 * If mapping is empty, populates its
55 * @return config file name
57 public String getConfigForEvent(String eventType){
58 LOGGER.debug("Getting config file name for event:" + eventType);
59 if(null != configFiles && eventToConfigFileMap.isEmpty()){
60 for(String entry : configFiles.split(",")){
61 eventToConfigFileMap.put(entry.split(":")[0], entry.split(":")[1]);
63 LOGGER.debug("Populated mappings for event type to config files");
66 return (null == eventToConfigFileMap.get(eventType)) ? "default" : eventToConfigFileMap.get(eventType) ;
71 //think about adding mapping files on runtime as well