|  1 |     | 
     | 
  |  2 |     | 
     | 
  |  3 |     | 
     | 
  |  4 |     | 
     | 
  |  5 |     | 
     | 
  |  6 |     | 
     | 
  |  7 |     | 
     | 
  |  8 |     | 
     | 
  |  9 |     | 
     | 
  |  10 |     | 
     | 
  |  11 |     | 
     | 
  |  12 |     | 
     | 
  |  13 |     | 
     | 
  |  14 |     | 
     | 
  |  15 |     | 
     | 
  |  16 |     | 
     | 
  |  17 |     | 
   package org.kuali.rice.krad.service.impl;  | 
  |  18 |     | 
     | 
  |  19 |     | 
   import org.kuali.rice.core.api.config.property.ConfigContext;  | 
  |  20 |     | 
   import org.kuali.rice.core.api.config.property.ConfigurationService;  | 
  |  21 |     | 
   import org.kuali.rice.core.util.ImmutableProperties;  | 
  |  22 |     | 
   import org.kuali.rice.kns.web.struts.action.KualiPropertyMessageResources;  | 
  |  23 |     | 
   import org.kuali.rice.kns.web.struts.action.KualiPropertyMessageResourcesFactory;  | 
  |  24 |     | 
   import org.kuali.rice.krad.util.KRADConstants;  | 
  |  25 |     | 
   import org.kuali.rice.krad.util.properties.PropertyHolder;  | 
  |  26 |     | 
     | 
  |  27 |     | 
   import java.util.Properties;  | 
  |  28 |     | 
     | 
  |  29 |     | 
     | 
  |  30 |     | 
   public class ConfigurationServiceImpl implements ConfigurationService { | 
  |  31 |    0 |        private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(ConfigurationServiceImpl.class);  | 
  |  32 |     | 
       private PropertyHolder propertyHolder;  | 
  |  33 |     | 
     | 
  |  34 |     | 
         | 
  |  35 |     | 
     | 
  |  36 |     | 
     | 
  |  37 |    0 |        public ConfigurationServiceImpl() { | 
  |  38 |    0 |            this.propertyHolder = new PropertyHolder();  | 
  |  39 |    0 |            this.propertyHolder.getHeldProperties().putAll(ConfigContext.getCurrentContextConfig().getProperties());  | 
  |  40 |     | 
     | 
  |  41 |    0 |            KualiPropertyMessageResourcesFactory propertyMessageFactory = new KualiPropertyMessageResourcesFactory();  | 
  |  42 |     | 
     | 
  |  43 |     | 
             | 
  |  44 |    0 |            KualiPropertyMessageResources messageResources = (KualiPropertyMessageResources)propertyMessageFactory.createResources(""); | 
  |  45 |     | 
     | 
  |  46 |     | 
             | 
  |  47 |    0 |            this.propertyHolder.getHeldProperties().putAll(messageResources.getKualiProperties(null));  | 
  |  48 |    0 |        }  | 
  |  49 |     | 
     | 
  |  50 |     | 
       public boolean isProductionEnvironment() { | 
  |  51 |    0 |            return getPropertyString(KRADConstants.PROD_ENVIRONMENT_CODE_KEY).equalsIgnoreCase(  | 
  |  52 |     | 
                   getPropertyString(KRADConstants.ENVIRONMENT_KEY));  | 
  |  53 |     | 
       }  | 
  |  54 |     | 
     | 
  |  55 |     | 
         | 
  |  56 |     | 
     | 
  |  57 |     | 
     | 
  |  58 |     | 
       public String getPropertyString(String key) { | 
  |  59 |    0 |            LOG.debug("getPropertyString() started"); | 
  |  60 |     | 
     | 
  |  61 |    0 |            if (key == null) { | 
  |  62 |    0 |                throw new IllegalArgumentException("invalid (null) key"); | 
  |  63 |     | 
           }  | 
  |  64 |     | 
     | 
  |  65 |    0 |            return this.propertyHolder.getProperty(key);  | 
  |  66 |     | 
       }  | 
  |  67 |     | 
     | 
  |  68 |     | 
         | 
  |  69 |     | 
     | 
  |  70 |     | 
     | 
  |  71 |     | 
       public boolean getPropertyAsBoolean(String key) { | 
  |  72 |    0 |            LOG.debug("getPropertyAsBoolean() started"); | 
  |  73 |     | 
     | 
  |  74 |    0 |            if (key == null) { | 
  |  75 |    0 |                throw new IllegalArgumentException("invalid (null) key"); | 
  |  76 |     | 
           }  | 
  |  77 |    0 |            String property = this.propertyHolder.getProperty(key);  | 
  |  78 |    0 |            if ( property != null ) { | 
  |  79 |    0 |                property = property.trim();  | 
  |  80 |    0 |                if ((property.equalsIgnoreCase( "true" )  | 
  |  81 |     | 
                       || property.equalsIgnoreCase( "yes" )  | 
  |  82 |     | 
                       || property.equalsIgnoreCase( "on" )  | 
  |  83 |     | 
                       || property.equalsIgnoreCase( "1" )) ) { | 
  |  84 |    0 |                    return true;  | 
  |  85 |     | 
               }  | 
  |  86 |     | 
           }  | 
  |  87 |    0 |            return false;  | 
  |  88 |     | 
       }  | 
  |  89 |     | 
     | 
  |  90 |     | 
         | 
  |  91 |     | 
     | 
  |  92 |     | 
     | 
  |  93 |     | 
       public Properties getAllProperties() { | 
  |  94 |    0 |            LOG.debug("getAllProperties() started"); | 
  |  95 |     | 
     | 
  |  96 |    0 |            return new ImmutableProperties(propertyHolder.getHeldProperties());  | 
  |  97 |     | 
       }  | 
  |  98 |     | 
     | 
  |  99 |     | 
   }  |