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;
}
Aggregations