if (_trobj.state != TourneyObject.PENDING) {
throw new InvocationException(TOO_LATE);
}
// make sure they haven't already signed up
final Participant part = makeParticipant(body);
if (_trobj.participants.contains(part)) {
throw new InvocationException(ALREADY_IN_TOURNEY);
}
// allow the implementing class to do further join checks
joinTourney(body);
// check the entrance fee
if (_trobj.config.entryFee != null) {
if (!_trobj.config.entryFee.hasFee(body)) {
listener.requestFailed("FAILED_ENTRY_FEE");
return;
}
// make the assumption that they're going to get in
_trobj.addToParticipants(part);
ResultListener<Void> rl = new ResultListener<Void>() {
public void requestCompleted (Void result) {
listener.requestProcessed();
}
public void requestFailed (Exception cause) {
// remove them from the tourney
_trobj.removeFromParticipants(part.getKey());
listener.requestFailed("FAILED_ENTRY_FEE");
}
};
_trobj.config.entryFee.reserveFee(body, rl);