use of cz.metacentrum.perun.audit.events.MailManagerEvents.MailForVoIdRemoved in project perun by CESNET.
the class MailManagerImpl method deleteMailById.
@Override
public void deleteMailById(PerunSession sess, ApplicationForm form, Integer id) throws ApplicationMailAlreadyRemovedException, PrivilegeException, ApplicationMailNotExistsException {
// Authorization
if (form.getGroup() != null) {
if (!AuthzResolver.authorizedInternal(sess, "group-deleteMailById_ApplicationForm_Integer_policy", Arrays.asList(form.getGroup(), form.getVo()))) {
throw new PrivilegeException(sess, "deleteMailById");
}
} else {
if (!AuthzResolver.authorizedInternal(sess, "vo-deleteMailById_ApplicationForm_Integer_policy", Collections.singletonList(form.getVo()))) {
throw new PrivilegeException(sess, "deleteMailById");
}
}
ApplicationMail mail = getMailById(sess, id);
int result = jdbc.update("delete from application_mails where id=?", id);
if (result == 0)
throw new ApplicationMailAlreadyRemovedException("Mail notification with id=" + id + " doesn't exists!");
if (result == 1)
log.info("[MAIL MANAGER] Mail notification with id={} deleted", id);
if (result > 1)
throw new ConsistencyErrorException("There is more than one mail notification with id=" + id);
if (form.getGroup() != null) {
perun.getAuditer().log(sess, new MailForGroupIdRemoved(mail, form.getGroup()));
} else {
perun.getAuditer().log(sess, new MailForVoIdRemoved(mail, form.getVo()));
}
}
Aggregations