Catching the right exception

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-lib@124342 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Luca Frosini 2016-02-19 10:49:07 +00:00
parent 1ef3cedd3d
commit c4fd8c253c
5 changed files with 51 additions and 33 deletions

View File

@ -93,13 +93,13 @@ public class AggregatedJobUsageRecord extends AbstractJobUsageRecord implements
public AggregatedJobUsageRecord aggregate(AggregatedJobUsageRecord record) public AggregatedJobUsageRecord aggregate(AggregatedJobUsageRecord record)
throws NotAggregatableRecordsExceptions { throws NotAggregatableRecordsExceptions {
try { try {
/* /* TODO
AggregationUtility<AggregatedJobUsageRecord> aggregationUtility = new AggregationUtility<AggregatedJobUsageRecord>(this); AggregationUtility<AggregatedJobUsageRecord> aggregationUtility = new AggregationUtility<AggregatedJobUsageRecord>(this);
aggregationUtility.aggregate(record); aggregationUtility.aggregate(record);
*/ } catch(NotAggregatableRecordsExceptions e){
// TODO throw e; */
}catch(Exception e){ } catch(Exception ex){
throw new UnsupportedOperationException(e); throw new NotAggregatableRecordsExceptions(ex);
} }
//return this; //return this;
@ -114,8 +114,10 @@ public class AggregatedJobUsageRecord extends AbstractJobUsageRecord implements
throws NotAggregatableRecordsExceptions { throws NotAggregatableRecordsExceptions {
try { try {
return aggregate(new AggregatedJobUsageRecord(record)); return aggregate(new AggregatedJobUsageRecord(record));
} catch (InvalidValueException e) { } catch(NotAggregatableRecordsExceptions e){
throw new NotAggregatableRecordsExceptions(e.getCause()); throw e;
} catch(Exception ex){
throw new NotAggregatableRecordsExceptions(ex);
} }
} }
@ -136,8 +138,10 @@ public class AggregatedJobUsageRecord extends AbstractJobUsageRecord implements
public boolean isAggregable(JobUsageRecord record) throws NotAggregatableRecordsExceptions { public boolean isAggregable(JobUsageRecord record) throws NotAggregatableRecordsExceptions {
try { try {
return isAggregable(new AggregatedJobUsageRecord(record)); return isAggregable(new AggregatedJobUsageRecord(record));
} catch (InvalidValueException e) { } catch(NotAggregatableRecordsExceptions e){
throw new NotAggregatableRecordsExceptions(e.getCause()); throw e;
} catch(Exception ex){
throw new NotAggregatableRecordsExceptions(ex);
} }
} }

View File

@ -95,13 +95,13 @@ public class AggregatedPortletUsageRecord extends AbstractPortletUsageRecord imp
AggregatedPortletUsageRecord record) AggregatedPortletUsageRecord record)
throws NotAggregatableRecordsExceptions { throws NotAggregatableRecordsExceptions {
try { try {
/* /* TODO
AggregationUtility<AggregatedPortletUsageRecord> aggregationUtility = new AggregationUtility<AggregatedPortletUsageRecord>(this); AggregationUtility<AggregatedPortletUsageRecord> aggregationUtility = new AggregationUtility<AggregatedPortletUsageRecord>(this);
aggregationUtility.aggregate(record); aggregationUtility.aggregate(record);
*/ } catch(NotAggregatableRecordsExceptions e){
// TODO throw e; */
}catch(Exception e){ } catch(Exception ex){
throw new UnsupportedOperationException(e); throw new NotAggregatableRecordsExceptions(ex);
} }
//return this; //return this;

View File

@ -171,8 +171,10 @@ public class AggregatedServiceUsageRecord extends AbstractServiceUsageRecord imp
throws NotAggregatableRecordsExceptions { throws NotAggregatableRecordsExceptions {
try { try {
return aggregate(new AggregatedServiceUsageRecord(record)); return aggregate(new AggregatedServiceUsageRecord(record));
} catch (InvalidValueException e) { } catch(NotAggregatableRecordsExceptions e){
throw new NotAggregatableRecordsExceptions(e.getCause()); throw e;
} catch(Exception ex){
throw new NotAggregatableRecordsExceptions(ex);
} }
} }
@ -194,8 +196,10 @@ public class AggregatedServiceUsageRecord extends AbstractServiceUsageRecord imp
throws NotAggregatableRecordsExceptions { throws NotAggregatableRecordsExceptions {
try { try {
return isAggregable(new AggregatedServiceUsageRecord(record)); return isAggregable(new AggregatedServiceUsageRecord(record));
} catch (InvalidValueException e) { } catch(NotAggregatableRecordsExceptions e){
throw new NotAggregatableRecordsExceptions(e.getCause()); throw e;
} catch(Exception ex){
throw new NotAggregatableRecordsExceptions(ex);
} }
} }

View File

@ -109,8 +109,10 @@ public class AggregatedStorageUsageRecord extends AbstractStorageUsageRecord imp
AggregationUtility<AggregatedStorageUsageRecord> aggregationUtility = new AggregationUtility<AggregatedStorageUsageRecord>(this); AggregationUtility<AggregatedStorageUsageRecord> aggregationUtility = new AggregationUtility<AggregatedStorageUsageRecord>(this);
aggregationUtility.aggregate(record); aggregationUtility.aggregate(record);
this.setDataVolume(this.getDataVolume() + record.getDataVolume()); this.setDataVolume(this.getDataVolume() + record.getDataVolume());
}catch(Exception e){ }catch(NotAggregatableRecordsExceptions e){
throw new UnsupportedOperationException(e); throw e;
} catch(Exception ex){
throw new NotAggregatableRecordsExceptions(ex);
} }
return this; return this;
} }
@ -123,8 +125,10 @@ public class AggregatedStorageUsageRecord extends AbstractStorageUsageRecord imp
throws NotAggregatableRecordsExceptions { throws NotAggregatableRecordsExceptions {
try { try {
return aggregate(new AggregatedStorageUsageRecord(record)); return aggregate(new AggregatedStorageUsageRecord(record));
} catch (InvalidValueException e) { } catch(NotAggregatableRecordsExceptions e){
throw new NotAggregatableRecordsExceptions(e.getCause()); throw e;
} catch(Exception ex){
throw new NotAggregatableRecordsExceptions(ex);
} }
} }
@ -146,8 +150,10 @@ public class AggregatedStorageUsageRecord extends AbstractStorageUsageRecord imp
throws NotAggregatableRecordsExceptions { throws NotAggregatableRecordsExceptions {
try { try {
return isAggregable(new AggregatedStorageUsageRecord(record)); return isAggregable(new AggregatedStorageUsageRecord(record));
} catch (InvalidValueException e) { } catch(NotAggregatableRecordsExceptions e){
throw new NotAggregatableRecordsExceptions(e.getCause()); throw e;
} catch(Exception ex){
throw new NotAggregatableRecordsExceptions(ex);
} }
} }

View File

@ -94,13 +94,13 @@ public class AggregatedTaskUsageRecord extends AbstractTaskUsageRecord implement
public AggregatedTaskUsageRecord aggregate(AggregatedTaskUsageRecord record) public AggregatedTaskUsageRecord aggregate(AggregatedTaskUsageRecord record)
throws NotAggregatableRecordsExceptions { throws NotAggregatableRecordsExceptions {
try { try {
/* /* TODO
AggregationUtility<AggregatedTaskUsageRecord> aggregationUtility = new AggregationUtility<AggregatedTaskUsageRecord>(this); AggregationUtility<AggregatedTaskUsageRecord> aggregationUtility = new AggregationUtility<AggregatedTaskUsageRecord>(this);
aggregationUtility.aggregate(record); aggregationUtility.aggregate(record);
*/ } catch(NotAggregatableRecordsExceptions e){
// TODO throw e; */
}catch(Exception e){ } catch(Exception ex){
throw new UnsupportedOperationException(e); throw new NotAggregatableRecordsExceptions(ex);
} }
//return this; //return this;
@ -115,8 +115,10 @@ public class AggregatedTaskUsageRecord extends AbstractTaskUsageRecord implement
throws NotAggregatableRecordsExceptions { throws NotAggregatableRecordsExceptions {
try { try {
return aggregate(new AggregatedTaskUsageRecord(record)); return aggregate(new AggregatedTaskUsageRecord(record));
} catch (InvalidValueException e) { } catch(NotAggregatableRecordsExceptions e){
throw new NotAggregatableRecordsExceptions(e.getCause()); throw e;
} catch(Exception ex){
throw new NotAggregatableRecordsExceptions(ex);
} }
} }
@ -136,8 +138,10 @@ public class AggregatedTaskUsageRecord extends AbstractTaskUsageRecord implement
public boolean isAggregable(TaskUsageRecord record) throws NotAggregatableRecordsExceptions { public boolean isAggregable(TaskUsageRecord record) throws NotAggregatableRecordsExceptions {
try { try {
return isAggregable(new AggregatedTaskUsageRecord(record)); return isAggregable(new AggregatedTaskUsageRecord(record));
} catch (InvalidValueException e) { } catch(NotAggregatableRecordsExceptions e){
throw new NotAggregatableRecordsExceptions(e.getCause()); throw e;
} catch(Exception ex){
throw new NotAggregatableRecordsExceptions(ex);
} }
} }