bda1c14bf9c0ae75c6706cd93dfadc09e004e0d0
[dmaap/messagerouter/msgrtr.git] / src / main / java / com / att / nsa / cambria / utils / PropertyReader.java
1 /*******************************************************************************
2  *  ============LICENSE_START=======================================================
3  *  org.onap.dmaap
4  *  ================================================================================
5  *  Copyright © 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
10  *        http://www.apache.org/licenses/LICENSE-2.0
11  *  
12  *  Unless required by applicable law or agreed to in writing, software
13  *  distributed under the License is distributed on an "AS IS" BASIS,
14  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  *  See the License for the specific language governing permissions and
16  *  limitations under the License.
17  *  ============LICENSE_END=========================================================
18  *
19  *  ECOMP is a trademark and service mark of AT&T Intellectual Property.
20  *  
21  *******************************************************************************/
22 package com.att.nsa.cambria.utils;
23
24 import java.io.File;
25 import java.net.MalformedURLException;
26 import java.net.URL;
27 import java.util.HashMap;
28 import java.util.Map;
29
30 import com.att.eelf.configuration.EELFLogger;
31 import com.att.eelf.configuration.EELFManager;
32
33 import com.att.nsa.cambria.constants.CambriaConstants;
34 import com.att.nsa.drumlin.till.nv.impl.nvPropertiesFile;
35 import com.att.nsa.drumlin.till.nv.impl.nvReadableStack;
36 import com.att.nsa.drumlin.till.nv.impl.nvReadableTable;
37
38 /**
39  * 
40  * @author 
41  *
42  *
43  */
44 public class PropertyReader extends nvReadableStack {
45         /**
46          * 
47          * initializing logger
48          * 
49          */
50         //private static final Logger LOGGER = Logger.getLogger(PropertyReader.class);
51         private static final EELFLogger log = EELFManager.getInstance().getLogger(PropertyReader.class);
52 //      private static final String MSGRTR_PROPERTIES_FILE = "msgRtrApi.properties";
53
54         /**
55          * constructor initialization
56          * 
57          * @throws loadException
58          * 
59          */
60         public PropertyReader() throws loadException {
61         /*      Map<String, String> argMap = new HashMap<String, String>();
62                 final String config = getSetting(argMap, CambriaConstants.kConfig, MSGRTR_PROPERTIES_FILE);
63                 final URL settingStream = findStream(config, ConfigurationReader.class);
64                 push(new nvPropertiesFile(settingStream));
65                 push(new nvReadableTable(argMap));*/
66         }
67
68         /**
69          * 
70          * 
71          * @param argMap
72          * @param key
73          * @param defaultValue
74          * @return
75          * 
76          */
77         @SuppressWarnings("unused")
78         private static String getSetting(Map<String, String> argMap, final String key, final String defaultValue) {
79                 String val = (String) argMap.get(key);
80                 if (null == val) {
81                         return defaultValue;
82                 }
83                 return val;
84         }
85
86         /**
87          * 
88          * @param resourceName
89          * @param clazz
90          * @return
91          * @exception MalformedURLException
92          * 
93          */
94         /*public static URL findStream(final String resourceName, Class<?> clazz) {
95                 try {
96                         File file = new File(resourceName);
97
98                         if (file.isAbsolute()) {
99                                 return file.toURI().toURL();
100                         }
101
102                         String filesRoot = System.getProperty("RRWT_FILES", null);
103
104                         if (null != filesRoot) {
105
106                                 String fullPath = filesRoot + "/" + resourceName;
107
108                                 LOGGER.debug("Looking for [" + fullPath + "].");
109
110                                 file = new File(fullPath);
111                                 if (file.exists()) {
112                                         return file.toURI().toURL();
113                                 }
114                         }
115
116                         URL res = clazz.getClassLoader().getResource(resourceName);
117
118                         if (null != res) {
119                                 return res;
120                         }
121
122                         res = ClassLoader.getSystemResource(resourceName);
123
124                         if (null != res) {
125                                 return res;
126                         }
127                 } catch (MalformedURLException e) {
128                         LOGGER.error("Unexpected failure to convert a local filename into a URL: " + e.getMessage(), e);
129                 }
130                 return null;
131         }
132 */
133 }