/** * Logs expirations that happened a week ago * * @param allowedStatuses allowed Statuses * @param vosMap vos * @throws InternalErrorException internal error */ private void auditOldExpirations(List<Status> allowedStatuses, Map<Integer, Vo> vosMap) throws InternalErrorException { // log message for all members which expired 7 days ago Calendar expiredWeekAgo = Calendar.getInstance(); expiredWeekAgo.add(Calendar.DAY_OF_MONTH, -7); List<Member> expired7DaysAgo = perun.getSearcherBl().getMembersByExpiration(sess, "=", expiredWeekAgo); // include expired in this case allowedStatuses.add(Status.EXPIRED); for (Member m : expired7DaysAgo) { if (allowedStatuses.contains(m.getStatus())) { if (didntSubmitExtensionApplication(m)) { // still didn't apply for extension getPerun().getAuditer().log(sess, new MembershipExpired(m, 7, vosMap.get(m.getVoId()))); } else { log.debug("{} not notified about expiration, has submitted - pending application.", m); } } else { log.debug("{} not notified about expiration, is not in VALID, SUSPENDED or EXPIRED state.", m); } } }
expirationPeriod.getExpirationAuditAction().callOn(getPerun().getAuditer(), sess, m, vosMap.get(m.getVoId())); } else { log.debug("{} not notified about expiration, has submitted - pending application.", m); ExpirationPeriod.MONTH.getExpirationAuditAction().callOn(getPerun().getAuditer(), sess, m, vosMap.get(m.getVoId())); } else { log.debug("{} not notified about expiration, has submitted - pending application.", m);
@Transactional @Override public void deleteFormItem(PerunSession user, ApplicationForm form, int ordnum) throws InternalErrorException, PrivilegeException { if (!AuthzResolver.isAuthorized(user, Role.VOADMIN, form.getVo())) { throw new PrivilegeException(user, "deleteFormItem"); } jdbc.update("delete from application_form_items where form_id=? and ordnum=?", form.getId(), ordnum); jdbc.update("update application_form_items set ordnum=ordnum-1 where form_id=? and ordnum>?", form.getId(), ordnum); perun.getAuditer().log(user, new FormItemDeleted(form)); }
try { int lastMessageBeforeInitializingData = perunInitializer.getPerunBl().getAuditer().getLastMessageId(); System.err.println("Last message id before starting initializing: " + lastMessageBeforeInitializingData + '\n'); int lastMessageAfterInitializingData = perunInitializer.getPerunBl().getAuditer().getLastMessageId(); System.err.println("Last message id after initializing: " + lastMessageAfterInitializingData + '\n');
@Override @Transactional(rollbackFor=Exception.class) public void updateMailById(PerunSession sess, ApplicationMail mail) throws PerunException { ApplicationForm form = registrarManager.getFormById(sess, mail.getFormId()); // update sending (enabled / disabled) jdbc.update("update application_mails set send=? where id=?", mail.getSend() ? "1" : "0", mail.getId()); // update texts (easy way = delete and new insert) jdbc.update("delete from application_mail_texts where mail_id=?", mail.getId()); for (Locale loc : mail.getMessage().keySet()) { MailText text = mail.getMessage(loc); jdbc.update("insert into application_mail_texts(mail_id,locale,subject,text) values (?,?,?,?)", mail.getId(), loc.toString(), text.getSubject(), text.getText()); } if (form.getGroup() != null) { perun.getAuditer().log(sess, new MailForGroupIdUpdated(mail,form.getGroup())); } else { perun.getAuditer().log(sess, new MailForVoIdUpdated(mail, form.getVo())); } }
@Override public void deleteAuthorship(PerunSession sess, Authorship authorship) throws CabinetException, InternalErrorException { getAuthorshipManagerDao().deleteAuthorship(sess, authorship); log.debug("{} deleted.", authorship); int userId = authorship.getUserId(); synchronized (CabinetManagerBlImpl.class) { getCabinetManagerBl().updatePriorityCoefficient(sess, userId, calculateNewRank(userId)); } synchronized (ThanksManagerBlImpl.class) { getCabinetManagerBl().setThanksAttribute(authorship.getUserId()); } perun.getAuditer().log(sess, new AuthorshipDeleted(authorship)); }
@Override public void setSendingEnabled(PerunSession sess, List<ApplicationMail> mails, boolean enabled) throws PerunException { // TODO authz if (mails == null) { throw new InternalErrorException("Mails definitions to update can't be null"); } for (ApplicationMail mail : mails) { // update sending (enabled / disabled) if (Compatibility.isPostgreSql()) { jdbc.update("update application_mails set send=? where id=?", (enabled) ? "1" : "0", mail.getId()); } else { jdbc.update("update application_mails set send=? where id=?", enabled, mail.getId()); } perun.getAuditer().log(sess, new MailSending(mail, enabled)); } }
@Override public void deleteMailById(PerunSession sess, ApplicationForm form, Integer id) throws PerunException { if (form.getGroup() != null) { if (!AuthzResolver.isAuthorized(sess, Role.VOADMIN, form.getVo()) && !AuthzResolver.isAuthorized(sess, Role.GROUPADMIN, form.getGroup())) { throw new PrivilegeException(sess, "deleteMail"); } } else { if (!AuthzResolver.isAuthorized(sess, Role.VOADMIN, form.getVo())) { throw new PrivilegeException(sess, "deleteMail"); } } ApplicationMail mail = getMailById(sess, id); int result = jdbc.update("delete from application_mails where id=?", id); if (result == 0) throw new InternalErrorException("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())); } }
perun.getAuditer().log(sess, new ApplicationApproved(app));
@Override @Transactional(rollbackFor = Exception.class) public Integer addMail(PerunSession sess, ApplicationForm form, ApplicationMail mail) throws PerunException, DuplicateKeyException { if (form.getGroup() != null) { if (!AuthzResolver.isAuthorized(sess, Role.VOADMIN, form.getVo()) && !AuthzResolver.isAuthorized(sess, Role.GROUPADMIN, form.getGroup())) { throw new PrivilegeException(sess, "addMail"); } } else { if (!AuthzResolver.isAuthorized(sess, Role.VOADMIN, form.getVo())) { throw new PrivilegeException(sess, "addMail"); } } int id = Utils.getNewId(jdbc, "APPLICATION_MAILS_ID_SEQ"); mail.setId(id); jdbc.update("insert into application_mails(id, form_id, app_type, mail_type, send) values (?,?,?,?,?)", mail.getId(), form.getId(), mail.getAppType().toString(), mail.getMailType().toString(), mail.getSend() ? "1" : "0"); for (Locale loc : mail.getMessage().keySet()) { jdbc.update("insert into application_mail_texts(mail_id,locale,subject,text) values (?,?,?,?)", mail.getId(), loc.toString(), mail.getMessage(loc).getSubject(), mail.getMessage(loc).getText()); } log.info("[MAIL MANAGER] Mail notification definition created: {}", mail); if (form.getGroup() != null) { perun.getAuditer().log(sess, new MailForGroupIdAdded(mail,form.getGroup())); } else { perun.getAuditer().log(sess, new MailForVoIdAdded(mail, form.getVo())); } return id; }
@Override public Authorship createAuthorship(PerunSession sess, Authorship authorship) throws CabinetException, InternalErrorException { if (authorshipExists(authorship)) throw new CabinetException(ErrorCodes.AUTHORSHIP_ALREADY_EXISTS); if (authorship.getCreatedDate() == null) { authorship.setCreatedDate(new Date()); } if (authorship.getCreatedByUid() == 0) { authorship.setCreatedByUid(sess.getPerunPrincipal().getUserId()); } try { getAuthorshipManagerDao().createAuthorship(sess, authorship); } catch (DataIntegrityViolationException e) { throw new CabinetException(ErrorCodes.USER_NOT_EXISTS, e); } log.debug("{} created.", authorship); synchronized (CabinetManagerBlImpl.class) { getCabinetManagerBl().updatePriorityCoefficient(sess, authorship.getUserId(), calculateNewRank(authorship.getUserId())); } synchronized (ThanksManagerBlImpl.class) { getCabinetManagerBl().setThanksAttribute(authorship.getUserId()); } // log perun.getAuditer().log(sess,new AuthorshipCreated(authorship)); return authorship; }
@Override public Application verifyApplication(PerunSession sess, int appId) throws PerunException { Application app = getApplicationById(appId); if (app == null) throw new RegistrarException("Application with ID="+appId+" doesn't exists."); if (!AuthzResolver.isAuthorized(sess, Role.VOADMIN, app.getVo())) { if (app.getGroup() != null) { if (!AuthzResolver.isAuthorized(sess, Role.GROUPADMIN, app.getGroup())) { throw new PrivilegeException(sess, "verifyApplication"); } } else { throw new PrivilegeException(sess, "verifyApplication"); } } // proceed markApplicationVerified(sess, appId); perun.getAuditer().log(sess, new ApplicationVerified(app)); // return updated application return getApplicationById(appId); }
perun.getAuditer().log(session, new ApplicationCreated(application));
@Override public int updateForm(PerunSession user, ApplicationForm form) throws InternalErrorException, PrivilegeException { if (form.getGroup() == null) { // VO application if (!AuthzResolver.isAuthorized(user, Role.VOADMIN, form.getVo())) { throw new PrivilegeException(user, "updateForm"); } } else { if (!AuthzResolver.isAuthorized(user, Role.VOADMIN, form.getVo()) && !AuthzResolver.isAuthorized(user, Role.GROUPADMIN, form.getGroup()) ) { throw new PrivilegeException(user, "updateForm"); } } perun.getAuditer().log(user, new FormUpdated((form))); return jdbc.update( "update application_form set automatic_approval=?, automatic_approval_extension=?, module_name=? where id=?", form.isAutomaticApproval() ? "1" : "0", form.isAutomaticApprovalExtension() ? "1" : "0", form.getModuleClassName(), form.getId()); }
perun.getAuditer().log(sess, new ApplicationRejected(app)); perun.getAuditer().log(sess, new ApplicationRejected(app));
perun.getAuditer().log(sess, new FormItemsUpdated(form));
perun.getAuditer().log(user, new FormItemAdded(form)); return item;
if (AppState.APPROVED.equals(app.getState())) throw new RegistrarException("Approved application can't be deleted. Try to refresh the view to see changes."); perun.getAuditer().log(sess, new ApplicationDeleted(app));
perun.getAuditer().log(sess, new FormItemUpdated(form,item));
perun.getAuditer().log(sess, new MailSentForApplication(mailType, app.getId()));