Search in sources :

Example 1 with SpecificUserAlreadyRemovedException

use of cz.metacentrum.perun.core.api.exceptions.SpecificUserAlreadyRemovedException in project perun by CESNET.

the class UsersManagerImpl method deleteUser.

@Override
public void deleteUser(PerunSession sess, User user) throws UserAlreadyRemovedException, SpecificUserAlreadyRemovedException {
    try {
        // delete all relations like  user -> sponsor -> service
        jdbc.update("delete from specific_user_users where specific_user_id=? or user_id=?", user.getId(), user.getId());
        int numAffected = jdbc.update("delete from users where id=?", user.getId());
        if (numAffected == 0) {
            if (user.isSpecificUser())
                throw new SpecificUserAlreadyRemovedException("SpecificUser: " + user);
            throw new UserAlreadyRemovedException("User: " + user);
        }
    } catch (RuntimeException err) {
        throw new InternalErrorException(err);
    }
}
Also used : InternalErrorException(cz.metacentrum.perun.core.api.exceptions.InternalErrorException) SpecificUserAlreadyRemovedException(cz.metacentrum.perun.core.api.exceptions.SpecificUserAlreadyRemovedException) UserAlreadyRemovedException(cz.metacentrum.perun.core.api.exceptions.UserAlreadyRemovedException) SpecificUserAlreadyRemovedException(cz.metacentrum.perun.core.api.exceptions.SpecificUserAlreadyRemovedException)

Aggregations

InternalErrorException (cz.metacentrum.perun.core.api.exceptions.InternalErrorException)1 SpecificUserAlreadyRemovedException (cz.metacentrum.perun.core.api.exceptions.SpecificUserAlreadyRemovedException)1 UserAlreadyRemovedException (cz.metacentrum.perun.core.api.exceptions.UserAlreadyRemovedException)1