refs #2437: Some records accounted on fallback are not recovered in the proper way in a special case

https://support.d4science.org/issues/2437

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-lib@124667 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Luca Frosini 2016-02-29 14:16:54 +00:00
parent f945acc77a
commit 9ba2a2e788
3 changed files with 13 additions and 11 deletions

View File

@ -4,8 +4,7 @@
package org.gcube.accounting.datamodel; package org.gcube.accounting.datamodel;
import org.gcube.documentstore.records.AggregatedRecord; import org.gcube.documentstore.records.AggregatedRecord;
import org.gcube.documentstore.records.implementation.AggregatedField; import org.gcube.documentstore.records.implementation.validations.annotations.ValidBoolean;
import org.gcube.documentstore.records.implementation.validations.annotations.NotEmptyIfNotNull;
import org.gcube.documentstore.records.implementation.validations.annotations.ValidInteger; import org.gcube.documentstore.records.implementation.validations.annotations.ValidInteger;
import org.gcube.documentstore.records.implementation.validations.annotations.ValidLong; import org.gcube.documentstore.records.implementation.validations.annotations.ValidLong;
@ -14,16 +13,16 @@ import org.gcube.documentstore.records.implementation.validations.annotations.Va
*/ */
public interface AggregatedUsageRecord<A extends AggregatedUsageRecord<A,U>, U extends UsageRecord> extends AggregatedRecord<A,U> { public interface AggregatedUsageRecord<A extends AggregatedUsageRecord<A,U>, U extends UsageRecord> extends AggregatedRecord<A,U> {
@AggregatedField @NotEmptyIfNotNull @ValidBoolean
public static final String AGGREGATED = AggregatedRecord.AGGREGATED; public static final String AGGREGATED = AggregatedRecord.AGGREGATED;
@AggregatedField @ValidInteger @ValidInteger
public static final String OPERATION_COUNT = AggregatedRecord.OPERATION_COUNT; public static final String OPERATION_COUNT = AggregatedRecord.OPERATION_COUNT;
@AggregatedField @ValidLong @ValidLong
public static final String START_TIME = AggregatedRecord.START_TIME; public static final String START_TIME = AggregatedRecord.START_TIME;
@AggregatedField @ValidLong @ValidLong
public static final String END_TIME = AggregatedRecord.END_TIME; public static final String END_TIME = AggregatedRecord.END_TIME;
} }

View File

@ -8,6 +8,7 @@ import java.util.Map;
import org.gcube.accounting.datamodel.backwardcompatibility.MoveToRecordType; import org.gcube.accounting.datamodel.backwardcompatibility.MoveToRecordType;
import org.gcube.accounting.datamodel.validations.annotations.ValidOperationResult; import org.gcube.accounting.datamodel.validations.annotations.ValidOperationResult;
import org.gcube.accounting.datamodel.validations.validators.ValidOperationResultValidator;
import org.gcube.common.scope.api.ScopeProvider; import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.documentstore.exception.InvalidValueException; import org.gcube.documentstore.exception.InvalidValueException;
import org.gcube.documentstore.records.implementation.AbstractRecord; import org.gcube.documentstore.records.implementation.AbstractRecord;
@ -115,7 +116,12 @@ public abstract class BasicUsageRecord extends AbstractRecord implements UsageRe
*/ */
@Override @Override
public OperationResult getOperationResult(){ public OperationResult getOperationResult(){
return OperationResult.valueOf((String) this.resourceProperties.get(OPERATION_RESULT)); try {
return (OperationResult) new ValidOperationResultValidator().
validate(OPERATION_RESULT, this.resourceProperties.get(OPERATION_RESULT), null);
} catch (Exception e) {
return null;
}
} }
/** /**

View File

@ -15,8 +15,6 @@ import org.gcube.documentstore.exception.InvalidValueException;
import org.gcube.documentstore.exception.NotAggregatableRecordsExceptions; import org.gcube.documentstore.exception.NotAggregatableRecordsExceptions;
import org.gcube.documentstore.records.aggregation.AggregationUtility; import org.gcube.documentstore.records.aggregation.AggregationUtility;
import org.gcube.documentstore.records.implementation.AggregatedField; import org.gcube.documentstore.records.implementation.AggregatedField;
import org.gcube.documentstore.records.implementation.RequiredField;
import org.gcube.documentstore.records.implementation.validations.annotations.ValidLong;
/** /**
* This Class is for library internal use only * This Class is for library internal use only
@ -29,8 +27,7 @@ public class AggregatedStorageUsageRecord extends AbstractStorageUsageRecord imp
*/ */
private static final long serialVersionUID = 1082525518686785682L; private static final long serialVersionUID = 1082525518686785682L;
// Redefining DATA_VOLUME to Set @AggregatedField @AggregatedField
@RequiredField @ValidLong @AggregatedField
public static final String DATA_VOLUME = AbstractStorageUsageRecord.DATA_VOLUME; public static final String DATA_VOLUME = AbstractStorageUsageRecord.DATA_VOLUME;