Search in sources :

Example 1 with SpecificUserOwnerAlreadyRemovedException

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

the class UsersManagerBlImpl method unsetSpecificUser.

@Override
public User unsetSpecificUser(PerunSession sess, User specificUser, SpecificUserType specificUserType) {
    if (!specificUser.getMajorSpecificType().equals(specificUserType)) {
        throw new InternalErrorException("Can't unset " + specificUserType.getSpecificUserType() + " for " + specificUser + ", because he hasn't this flag yet.");
    }
    // remove all owners for this new specific user
    List<User> owners = getPerunBl().getUsersManagerBl().getUsersBySpecificUser(sess, specificUser);
    for (User owner : owners) {
        try {
            this.removeSpecificUserOwner(sess, owner, specificUser, true);
        } catch (RelationNotExistsException | SpecificUserOwnerAlreadyRemovedException ex) {
            throw new InternalErrorException("Can't remove ownership of user " + specificUser, ex);
        }
    }
    // Unset specific type for user
    specificUser = getUsersManagerImpl().unsetSpecificUserType(sess, specificUser, specificUserType);
    return specificUser;
}
Also used : RelationNotExistsException(cz.metacentrum.perun.core.api.exceptions.RelationNotExistsException) OwnershipRemovedForSpecificUser(cz.metacentrum.perun.audit.events.UserManagerEvents.OwnershipRemovedForSpecificUser) User(cz.metacentrum.perun.core.api.User) OwnershipEnabledForSpecificUser(cz.metacentrum.perun.audit.events.UserManagerEvents.OwnershipEnabledForSpecificUser) UserAddedToOwnersOfSpecificUser(cz.metacentrum.perun.audit.events.UserManagerEvents.UserAddedToOwnersOfSpecificUser) UserExtSourceRemovedFromUser(cz.metacentrum.perun.audit.events.UserManagerEvents.UserExtSourceRemovedFromUser) RichUser(cz.metacentrum.perun.core.api.RichUser) OwnershipDisabledForSpecificUser(cz.metacentrum.perun.audit.events.UserManagerEvents.OwnershipDisabledForSpecificUser) UserExtSourceAddedToUser(cz.metacentrum.perun.audit.events.UserManagerEvents.UserExtSourceAddedToUser) AllUserExtSourcesDeletedForUser(cz.metacentrum.perun.audit.events.UserManagerEvents.AllUserExtSourcesDeletedForUser) SpecificUserOwnerAlreadyRemovedException(cz.metacentrum.perun.core.api.exceptions.SpecificUserOwnerAlreadyRemovedException) InternalErrorException(cz.metacentrum.perun.core.api.exceptions.InternalErrorException)

Aggregations

AllUserExtSourcesDeletedForUser (cz.metacentrum.perun.audit.events.UserManagerEvents.AllUserExtSourcesDeletedForUser)1 OwnershipDisabledForSpecificUser (cz.metacentrum.perun.audit.events.UserManagerEvents.OwnershipDisabledForSpecificUser)1 OwnershipEnabledForSpecificUser (cz.metacentrum.perun.audit.events.UserManagerEvents.OwnershipEnabledForSpecificUser)1 OwnershipRemovedForSpecificUser (cz.metacentrum.perun.audit.events.UserManagerEvents.OwnershipRemovedForSpecificUser)1 UserAddedToOwnersOfSpecificUser (cz.metacentrum.perun.audit.events.UserManagerEvents.UserAddedToOwnersOfSpecificUser)1 UserExtSourceAddedToUser (cz.metacentrum.perun.audit.events.UserManagerEvents.UserExtSourceAddedToUser)1 UserExtSourceRemovedFromUser (cz.metacentrum.perun.audit.events.UserManagerEvents.UserExtSourceRemovedFromUser)1 RichUser (cz.metacentrum.perun.core.api.RichUser)1 User (cz.metacentrum.perun.core.api.User)1 InternalErrorException (cz.metacentrum.perun.core.api.exceptions.InternalErrorException)1 RelationNotExistsException (cz.metacentrum.perun.core.api.exceptions.RelationNotExistsException)1 SpecificUserOwnerAlreadyRemovedException (cz.metacentrum.perun.core.api.exceptions.SpecificUserOwnerAlreadyRemovedException)1