mirror of https://github.com/apache/cloudstack.git
CLOUDSTACK-7930, CLOUDSTACK-7931: Do not allow to set invalid values for global settings which are of type integer and float
This closes #41
This commit is contained in:
parent
bfe53d1b2b
commit
b008d78b57
|
|
@ -725,6 +725,21 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
|||
type = c.getType();
|
||||
}
|
||||
|
||||
String errMsg = null;
|
||||
try {
|
||||
if (type.equals(Integer.class)) {
|
||||
errMsg = "There was error in trying to parse value: " + value + ". Please enter a valid integer value for parameter " + name;
|
||||
Integer.parseInt(value);
|
||||
} else if (type.equals(Float.class)) {
|
||||
errMsg = "There was error in trying to parse value: " + value + ". Please enter a valid float value for parameter " + name;
|
||||
Float.parseFloat(value);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// catching generic exception as some throws NullPointerException and some throws NumberFormatExcpeion
|
||||
s_logger.error(errMsg);
|
||||
return errMsg;
|
||||
}
|
||||
|
||||
if (value == null) {
|
||||
if (type.equals(Boolean.class)) {
|
||||
return "Please enter either 'true' or 'false'.";
|
||||
|
|
|
|||
Loading…
Reference in New Issue