use of cz.metacentrum.perun.audit.events.OwnersManagerEvents.OwnerDeleted in project perun by CESNET.
the class OwnersManagerBlImpl method deleteOwner.
@Override
public void deleteOwner(PerunSession sess, Owner owner, boolean forceDelete) throws RelationExistsException, OwnerAlreadyRemovedException {
// Check if the owner is assigned to some facility
List<Facility> facilities = getPerunBl().getFacilitiesManagerBl().getOwnerFacilities(sess, owner);
if (facilities != null && facilities.size() > 0) {
if (!forceDelete) {
throw new RelationExistsException("Owner own " + facilities.size() + " facilities");
} else {
for (Facility facility : facilities) {
try {
getPerunBl().getFacilitiesManagerBl().removeOwner(sess, facility, owner);
} catch (OwnerAlreadyRemovedException e) {
throw new InternalErrorException(e);
}
}
}
}
getOwnersManagerImpl().deleteOwner(sess, owner);
getPerunBl().getAuditer().log(sess, new OwnerDeleted(owner));
}
Aggregations