@@ -739,7 +739,11 @@ public boolean stop() {
739739
740740 @ Override
741741 @ DB
742- public String updateConfiguration (final long userId , final String name , final String category , String value , ConfigKey .Scope scope , final Long resourceId ) {
742+ public String updateConfiguration (final long userId , final String name , final String category , String value , final String scope , final Long resourceId ) {
743+ if (Boolean .class == getConfigurationTypeWrapperClass (name )) {
744+ value = value .toLowerCase ();
745+ }
746+
743747 final String validationMsg = validateConfigurationValue (name , value , scope );
744748 if (validationMsg != null ) {
745749 logger .error ("Invalid value [{}] for configuration [{}] due to [{}]." , value , name , validationMsg );
@@ -1307,18 +1311,9 @@ protected String validateConfigurationValue(String name, String value, ConfigKey
13071311 return "Invalid scope id provided for the parameter " + name ;
13081312 }
13091313 }
1310- Class <?> type ;
1311- Config configuration = Config .getConfig (name );
1312- if (configuration == null ) {
1313- logger .warn ("Did not find configuration " + name + " in Config.java. Perhaps moved to ConfigDepot" );
1314- ConfigKey <?> configKey = _configDepot .get (name );
1315- if (configKey == null ) {
1316- logger .warn ("Did not find configuration " + name + " in ConfigDepot too." );
1317- return null ;
1318- }
1319- type = configKey .type ();
1320- } else {
1321- type = configuration .getType ();
1314+ Class <?> type = getConfigurationTypeWrapperClass (name );
1315+ if (type == null ) {
1316+ return null ;
13221317 }
13231318
13241319 validateSpecificConfigurationValues (name , value , type );
@@ -1330,7 +1325,28 @@ protected String validateConfigurationValue(String name, String value, ConfigKey
13301325 return String .format ("Value [%s] is not a valid [%s]." , value , type );
13311326 }
13321327
1333- return validateValueRange (name , value , type , configuration );
1328+ return validateValueRange (name , value , type , Config .getConfig (name ));
1329+ }
1330+
1331+ /**
1332+ * Returns the configuration type's wrapper class.
1333+ * @param name name of the configuration.
1334+ * @return if the configuration exists, returns its type's wrapper class; if not, returns null.
1335+ */
1336+ protected Class <?> getConfigurationTypeWrapperClass (String name ) {
1337+ Config configuration = Config .getConfig (name );
1338+ if (configuration != null ) {
1339+ return configuration .getType ();
1340+ }
1341+
1342+ logger .warn ("Did not find configuration [{}] in Config.java. Perhaps moved to ConfigDepot." , name );
1343+ ConfigKey <?> configKey = _configDepot .get (name );
1344+ if (configKey == null ) {
1345+ logger .warn ("Did not find configuration [{}] in ConfigDepot too." , name );
1346+ return null ;
1347+ }
1348+
1349+ return configKey .type ();
13341350 }
13351351
13361352 /**
@@ -1340,7 +1356,7 @@ protected String validateConfigurationValue(String name, String value, ConfigKey
13401356 * <ul>
13411357 * <li>String: any value, including null;</li>
13421358 * <li>Character: any value, including null;</li>
1343- * <li>Boolean: strings that equal "true" or "false" (case-sensitive );</li>
1359+ * <li>Boolean: strings that equal "true" or "false" (case-insensitive );</li>
13441360 * <li>Integer, Short, Long: strings that contain a valid int/short/long;</li>
13451361 * <li>Float, Double: strings that contain a valid float/double, except infinity.</li>
13461362 * </ul>
@@ -8287,36 +8303,32 @@ public ConfigKey<?>[] getConfigKeys() {
82878303 };
82888304 }
82898305
8306+
8307+ /**
8308+ * Returns a string representing the specified configuration's type.
8309+ * @param configName name of the configuration.
8310+ * @return if the configuration exists, returns its type; if not, returns {@link Configuration.ValueType#String}.
8311+ */
82908312 @ Override
82918313 public String getConfigurationType (final String configName ) {
82928314 final ConfigurationVO cfg = _configDao .findByName (configName );
82938315 if (cfg == null ) {
8294- logger .warn ("Configuration " + configName + " not found" );
8316+ logger .warn ("Configuration [{}] not found" , configName );
82958317 return Configuration .ValueType .String .name ();
82968318 }
82978319
82988320 if (weightBasedParametersForValidation .contains (configName )) {
82998321 return Configuration .ValueType .Range .name ();
83008322 }
83018323
8302- Class <?> type = null ;
8303- final Config c = Config .getConfig (configName );
8304- if (c == null ) {
8305- logger .warn ("Configuration " + configName + " no found. Perhaps moved to ConfigDepot" );
8306- final ConfigKey <?> configKey = _configDepot .get (configName );
8307- if (configKey == null ) {
8308- logger .warn ("Couldn't find configuration " + configName + " in ConfigDepot too." );
8309- return Configuration .ValueType .String .name ();
8310- }
8311- type = configKey .type ();
8312- } else {
8313- type = c .getType ();
8314- }
8315-
8316- return getInputType (type , cfg );
8324+ Class <?> type = getConfigurationTypeWrapperClass (configName );
8325+ return parseConfigurationTypeIntoString (type , cfg );
83178326 }
83188327
8319- private String getInputType (Class <?> type , ConfigurationVO cfg ) {
8328+ /**
8329+ * Parses a configuration type's wrapper class into its string representation.
8330+ */
8331+ protected String parseConfigurationTypeIntoString (Class <?> type , ConfigurationVO cfg ) {
83208332 if (type == null ) {
83218333 return Configuration .ValueType .String .name ();
83228334 }
0 commit comments