use of com.cinchapi.concourse.TransactionException in project concourse by cinchapi.
the class ConcourseAccount method debit.
@Override
public boolean debit(String charge, double amount) {
Preconditions.checkArgument(amount > 0);
Concourse concourse = Constants.CONCOURSE_CONNECTIONS.request();
try {
concourse.stage();
if (withdrawImpl(concourse, amount)) {
// By using the #add method, we can store multiple charges in
// the record at the same time
concourse.add("charges", charge, id);
return concourse.commit();
} else {
concourse.abort();
return false;
}
} catch (TransactionException e) {
concourse.abort();
return false;
} finally {
Constants.CONCOURSE_CONNECTIONS.release(concourse);
}
}
Aggregations