Fixed bug on object creation from map

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-lib@117069 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Luca Frosini 2015-07-08 09:15:54 +00:00
parent 56be686649
commit d15590926e
1 changed files with 6 additions and 5 deletions

View File

@ -288,8 +288,8 @@ public abstract class BasicUsageRecord implements UsageRecord, Serializable {
*/
@Override
public void setResourceProperties(Map<String, Serializable> properties) throws InvalidValueException {
validateProperties(properties);
this.resourceProperties = new HashMap<String, Serializable>(properties);
Map<String, Serializable> validated = validateProperties(properties);
this.resourceProperties = new HashMap<String, Serializable>(validated);
}
/**
@ -400,11 +400,13 @@ public abstract class BasicUsageRecord implements UsageRecord, Serializable {
return checkedValue;
}
protected void validateProperties(Map<String, Serializable> properties) throws InvalidValueException{
protected Map<String, Serializable> validateProperties(Map<String, Serializable> properties) throws InvalidValueException{
Map<String, Serializable> validated = new HashMap<String, Serializable>();
for(String key : properties.keySet()){
Serializable serializable = properties.get(key);
validateField(key, serializable);
validated.put(key, validateField(key, serializable));
}
return validated;
}
/**
@ -471,7 +473,6 @@ public abstract class BasicUsageRecord implements UsageRecord, Serializable {
}
return 1;
}
@SuppressWarnings("unchecked")
protected static Class<? extends UsageRecord> getClass(String usageRecordName, boolean aggregated) throws ClassNotFoundException {