Coverage Report - org.kuali.rice.core.impl.config.property.ConfigParserImplConfig
 
Classes in this File Line Coverage Branch Coverage Complexity
ConfigParserImplConfig
0%
0/51
0%
0/18
2.5
ConfigParserImplConfig$1
0%
0/2
N/A
2.5
 
 1  
 /**
 2  
  * Copyright 2005-2011 The Kuali Foundation
 3  
  *
 4  
  * Licensed under the Educational Community License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  * http://www.opensource.org/licenses/ecl2.php
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 package org.kuali.rice.core.impl.config.property;
 17  
 
 18  
 import org.apache.commons.lang.StringUtils;
 19  
 import org.apache.log4j.Logger;
 20  
 import org.kuali.rice.core.framework.config.property.SimpleConfig;
 21  
 
 22  
 import java.io.IOException;
 23  
 import java.util.Comparator;
 24  
 import java.util.Iterator;
 25  
 import java.util.Map;
 26  
 import java.util.Properties;
 27  
 import java.util.Set;
 28  
 import java.util.SortedSet;
 29  
 import java.util.TreeSet;
 30  
 
 31  
 /**
 32  
  * Old config implementation still used by PluginConfig to support old non-JAXB-compliant
 33  
  * Plugin config xml
 34  
  * @deprecated We need to retrofit PluginConfig to JAXBConfig, or eliminate along with old KEW plugin architecture
 35  
  */
 36  
 @Deprecated
 37  
 public class ConfigParserImplConfig extends SimpleConfig {
 38  0
     private static final Logger LOG = Logger.getLogger(ConfigParserImplConfig.class);
 39  
 
 40  
     public ConfigParserImplConfig(String fileLoc) {
 41  0
         super(fileLoc);
 42  0
     }
 43  
 
 44  
     public ConfigParserImplConfig(Properties properties) {
 45  0
         super(properties);
 46  0
     }
 47  
 
 48  
     protected void parseWithConfigParserImpl() throws IOException {
 49  0
         ConfigParserImpl cp = new ConfigParserImpl();
 50  0
         Map p = new Properties();
 51  0
         p.putAll(getProperties());
 52  0
         cp.parse(p, fileLocs.toArray(new String[fileLocs.size()]));
 53  0
         putPropertiesInPropsUsed(p, StringUtils.join(fileLocs, ", "));
 54  0
     }
 55  
 
 56  
     protected void putPropertiesInPropsUsed(Map properties, String fileName) {
 57  
         // Properties configProperties = (Properties)config.getValue();
 58  0
         Map<String, String> safeConfig = ConfigLogger.getDisplaySafeConfig(properties);
 59  0
         if ( LOG.isInfoEnabled() ) {
 60  0
             LOG.info("Loading properties for config " + fileName);
 61  
         }
 62  0
         for (Iterator iterator2 = properties.entrySet().iterator(); iterator2.hasNext();) {
 63  0
             Map.Entry configProp = (Map.Entry) iterator2.next();
 64  0
             String key = (String) configProp.getKey();
 65  0
             String value = (String) configProp.getValue();
 66  0
             String safeValue = safeConfig.get(key);
 67  0
             if ( LOG.isDebugEnabled() ) {
 68  0
                 LOG.debug("---->Putting config Prop " + key + "=[" + safeValue + "]");
 69  
             }
 70  0
             this.propertiesUsed.put(key, value);
 71  0
         }
 72  0
     }
 73  
 
 74  
     public void parseConfig() throws IOException {
 75  0
         if ( LOG.isInfoEnabled() ) {
 76  0
             LOG.info("Loading Rice configs: " + StringUtils.join(fileLocs, ", "));
 77  
         }
 78  0
         Map<String, Object> baseObjects = getBaseObjects();
 79  0
         if (baseObjects != null) {
 80  0
             this.getObjects().putAll(baseObjects);
 81  
         }
 82  0
         configureBuiltIns(getProperties());
 83  0
         Properties baseProperties = getBaseProperties();
 84  0
         if (baseProperties != null) {
 85  0
             this.getProperties().putAll(baseProperties);
 86  
         }
 87  
 
 88  0
         parseWithConfigParserImpl();
 89  
         //parseWithHierarchicalConfigParser();
 90  
 
 91  
         //if (!fileLocs.isEmpty()) {
 92  0
         if ( LOG.isInfoEnabled() ) {
 93  0
             LOG.info("");
 94  0
             LOG.info("####################################");
 95  0
             LOG.info("#");
 96  0
             LOG.info("# Properties used after config override/replacement");
 97  0
             LOG.info("# " + StringUtils.join(fileLocs, ", "));
 98  0
             LOG.info("#");
 99  0
             LOG.info("####################################");
 100  0
             LOG.info("");
 101  
         }
 102  0
         Map<String, String> safePropsUsed = ConfigLogger.getDisplaySafeConfig(this.propertiesUsed);
 103  0
         Set<Map.Entry<String,String>> entrySet = safePropsUsed.entrySet();
 104  
         // sort it for display
 105  
         SortedSet<Map.Entry<String,String>>
 106  0
                 sorted = new TreeSet<Map.Entry<String,String>>(new Comparator<Map.Entry<String,String>>() {
 107  
             public int compare(Map.Entry<String,String> a, Map.Entry<String,String> b) {
 108  0
                 return a.getKey().compareTo(b.getKey());
 109  
             }
 110  
         });
 111  0
         sorted.addAll(entrySet);
 112  
         //}
 113  0
         if ( LOG.isInfoEnabled() ) {
 114  0
             for (Map.Entry<String, String> propUsed: sorted) {
 115  0
                 LOG.info("Using config Prop " + propUsed.getKey() + "=[" + propUsed.getValue() + "]");
 116  
             }
 117  
         }
 118  0
     }
 119  
 }