refs #200: Create accouting-lib library

https://support.d4science.org/issues/200
Moved Record Validation inside thread

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-lib@115554 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Luca Frosini 2015-06-25 14:41:13 +00:00
parent 73c7b93111
commit 2ca5595de7
2 changed files with 4 additions and 4 deletions

View File

@ -65,6 +65,8 @@ public abstract class BasicUsageRecord implements UsageRecord, Serializable {
protected static final String USAGE_RECORD_TYPE = "usageRecordType";
@RequiredField @NotEmpty
public static final String SCOPE = "scope";
@RequiredField @ValidOperationResult
public static final String OPERATION_RESULT = "operationResult";

View File

@ -150,9 +150,7 @@ public abstract class Persistence {
/**
* Persist the {@link #UsageRecord}.
* The Record is validated first, if validation fails an
* #InvalidValueException is thrown.
* If validation success, the record is accounted in a separated thread.
* The Record is validated first, then accounted, in a separated thread.
* So that the program can continue the execution.
* If the persistence fails the class write that the record in a local file
* so that the {@link #UsageRecord} can be recorder later.
@ -160,11 +158,11 @@ public abstract class Persistence {
* @throws InvalidValueException if the Record Validation Fails
*/
public void account(final SingleUsageRecord usageRecord) throws InvalidValueException{
usageRecord.validate();
Runnable runnable = new Runnable(){
@Override
public void run(){
try {
usageRecord.validate();
persistence.accountWithFallback(usageRecord);
} catch (Exception e) {
logger.error("Error accouting UsageRecod", e.getCause());