return getCurrentUser();
}
@Override
public User transfer(long toAccount, long amount, String comment) throws CaprabankException {
User currentUser = getCurrentUser();
if (toAccount == currentUser.accountNum) {
log.warning("Self-tranfer attempted by user " + currentUser.username + ".");
throw new CaprabankException("Very funny... That's you.");
}
if (amount <= 0) {
log.warning("Negative amount tranfer attempted by user " + currentUser.username + " (amount=" + formatAmount(amount) + ").");
throw new CaprabankException("Very funny...");
}
User toUser = dataStore.findUserByAccountNum(toAccount);
if (toUser == null) {
log.warning("Tranfer to nonexistent account attempted by user " + currentUser.username + " (account=" + toAccount + ").");
throw new CaprabankException("Account " + toAccount + " not found.");
}