use of io.hops.hopsworks.persistence.entity.user.security.audit.RolesAudit in project hopsworks by logicalclocks.
the class UsersController method deleteUser.
/**
* Delete users. Will fail if the user is an initiator of an audit log.
* @param u
* @throws UserException
*/
public void deleteUser(Users u) throws UserException {
if (u != null) {
// Should not delete user that is an Initiator in a RolesAudit
List<RolesAudit> results = rolesAuditFacade.findByTarget(u);
for (Iterator<RolesAudit> iterator = results.iterator(); iterator.hasNext(); ) {
RolesAudit next = iterator.next();
rolesAuditFacade.remove(next);
}
// Should not delete user that is an Initiator in an AccountAudit
List<AccountAudit> resultsAA = accountAuditFacade.findByTarget(u);
for (Iterator<AccountAudit> iterator = resultsAA.iterator(); iterator.hasNext(); ) {
AccountAudit next = iterator.next();
accountAuditFacade.remove(next);
}
// run delete handlers
UserAccountHandler.runUserAccountDeleteHandlers(userAccountHandlers, u);
try {
userFacade.removeByEmail(u.getEmail());
} catch (ConstraintViolationException cve) {
throw new UserException(RESTCodes.UserErrorCode.ACCOUNT_DELETION_ERROR, Level.FINE, "User that initiated " + "audit log on another account can not be deleted.", cve.getMessage());
}
}
}
use of io.hops.hopsworks.persistence.entity.user.security.audit.RolesAudit in project hopsworks by logicalclocks.
the class AccountAuditFacade method registerRoleChange.
/**
* @param user
* @param action
* @param outcome
* @param message
* @param targetUser
* @param remoteHost
* @param userAgent
*/
public void registerRoleChange(Users user, String action, String outcome, String message, Users targetUser, String remoteHost, String userAgent) {
RolesAudit rolesAudit = new RolesAudit(action, new Date(), message, userAgent, remoteHost, outcome, targetUser, user);
em.persist(rolesAudit);
}
Aggregations