@@ -703,6 +703,10 @@ public boolean stop() {
703703 @ Override
704704 @ DB
705705 public String updateConfiguration (final long userId , final String name , final String category , String value , final String scope , final Long resourceId ) {
706+ if (Boolean .class == getConfigurationTypeWrapperClass (name )) {
707+ value = value .toLowerCase ();
708+ }
709+
706710 final String validationMsg = validateConfigurationValue (name , value , scope );
707711 if (validationMsg != null ) {
708712 logger .error ("Invalid value [{}] for configuration [{}] due to [{}]." , value , name , validationMsg );
@@ -1241,18 +1245,9 @@ protected String validateConfigurationValue(String name, String value, String sc
12411245 return "Invalid scope id provided for the parameter " + name ;
12421246 }
12431247 }
1244- Class <?> type ;
1245- Config configuration = Config .getConfig (name );
1246- if (configuration == null ) {
1247- logger .warn ("Did not find configuration " + name + " in Config.java. Perhaps moved to ConfigDepot" );
1248- ConfigKey <?> configKey = _configDepot .get (name );
1249- if (configKey == null ) {
1250- logger .warn ("Did not find configuration " + name + " in ConfigDepot too." );
1251- return null ;
1252- }
1253- type = configKey .type ();
1254- } else {
1255- type = configuration .getType ();
1248+ Class <?> type = getConfigurationTypeWrapperClass (name );
1249+ if (type == null ) {
1250+ return null ;
12561251 }
12571252
12581253 validateSpecificConfigurationValues (name , value , type );
@@ -1262,7 +1257,28 @@ protected String validateConfigurationValue(String name, String value, String sc
12621257 return String .format ("Value [%s] is not a valid [%s]." , value , type );
12631258 }
12641259
1265- return validateValueRange (name , value , type , configuration );
1260+ return validateValueRange (name , value , type , Config .getConfig (name ));
1261+ }
1262+
1263+ /**
1264+ * Returns the configuration type's wrapper class.
1265+ * @param name name of the configuration.
1266+ * @return if the configuration exists, returns its type's wrapper class; if not, returns null.
1267+ */
1268+ protected Class <?> getConfigurationTypeWrapperClass (String name ) {
1269+ Config configuration = Config .getConfig (name );
1270+ if (configuration != null ) {
1271+ return configuration .getType ();
1272+ }
1273+
1274+ logger .warn ("Did not find configuration [{}] in Config.java. Perhaps moved to ConfigDepot." , name );
1275+ ConfigKey <?> configKey = _configDepot .get (name );
1276+ if (configKey == null ) {
1277+ logger .warn ("Did not find configuration [{}] in ConfigDepot too." , name );
1278+ return null ;
1279+ }
1280+
1281+ return configKey .type ();
12661282 }
12671283
12681284 protected void validateConfigurationAllowedOnlyForDefaultAdmin (String configName , String value ) {
@@ -1299,7 +1315,7 @@ protected void validateConfigurationAllowedOnlyForDefaultAdmin(String configName
12991315 * <ul>
13001316 * <li>String: any value, including null;</li>
13011317 * <li>Character: any value, including null;</li>
1302- * <li>Boolean: strings that equal "true" or "false" (case-sensitive );</li>
1318+ * <li>Boolean: strings that equal "true" or "false" (case-insensitive );</li>
13031319 * <li>Integer, Short, Long: strings that contain a valid int/short/long;</li>
13041320 * <li>Float, Double: strings that contain a valid float/double, except infinity.</li>
13051321 * </ul>
@@ -8176,36 +8192,32 @@ public ConfigKey<?>[] getConfigKeys() {
81768192 };
81778193 }
81788194
8195+
8196+ /**
8197+ * Returns a string representing the specified configuration's type.
8198+ * @param configName name of the configuration.
8199+ * @return if the configuration exists, returns its type; if not, returns {@link Configuration.ValueType#String}.
8200+ */
81798201 @ Override
81808202 public String getConfigurationType (final String configName ) {
81818203 final ConfigurationVO cfg = _configDao .findByName (configName );
81828204 if (cfg == null ) {
8183- logger .warn ("Configuration " + configName + " not found" );
8205+ logger .warn ("Configuration [{}] not found" , configName );
81848206 return Configuration .ValueType .String .name ();
81858207 }
81868208
81878209 if (weightBasedParametersForValidation .contains (configName )) {
81888210 return Configuration .ValueType .Range .name ();
81898211 }
81908212
8191- Class <?> type = null ;
8192- final Config c = Config .getConfig (configName );
8193- if (c == null ) {
8194- logger .warn ("Configuration " + configName + " no found. Perhaps moved to ConfigDepot" );
8195- final ConfigKey <?> configKey = _configDepot .get (configName );
8196- if (configKey == null ) {
8197- logger .warn ("Couldn't find configuration " + configName + " in ConfigDepot too." );
8198- return Configuration .ValueType .String .name ();
8199- }
8200- type = configKey .type ();
8201- } else {
8202- type = c .getType ();
8203- }
8204-
8205- return getInputType (type , cfg );
8213+ Class <?> type = getConfigurationTypeWrapperClass (configName );
8214+ return parseConfigurationTypeIntoString (type , cfg );
82068215 }
82078216
8208- private String getInputType (Class <?> type , ConfigurationVO cfg ) {
8217+ /**
8218+ * Parses a configuration type's wrapper class into its string representation.
8219+ */
8220+ protected String parseConfigurationTypeIntoString (Class <?> type , ConfigurationVO cfg ) {
82098221 if (type == null ) {
82108222 return Configuration .ValueType .String .name ();
82118223 }
0 commit comments