Search in sources :

Example 1 with GroupMembershipExpired

use of cz.metacentrum.perun.audit.events.ExpirationNotifScheduler.GroupMembershipExpired in project perun by CESNET.

the class ExpirationNotifScheduler method auditOldGroupExpirations.

/**
 * Logs expirations that happened a week ago for a group
 *
 * @param allowedStatuses allowed Statuses
 * @param group group
 * @throws InternalErrorException internal error
 */
private void auditOldGroupExpirations(List<Status> allowedStatuses, Group group) {
    // log message for all members which expired 7 days ago
    LocalDate expiredWeekAgo = getCurrentLocalDate().minusDays(7);
    List<Member> expired7DaysAgo = perun.getSearcherBl().getMembersByGroupExpiration(sess, group, "=", expiredWeekAgo);
    for (Member m : expired7DaysAgo) {
        if (allowedStatuses.contains(m.getStatus())) {
            MemberGroupStatus status = perun.getGroupsManagerBl().getDirectMemberGroupStatus(sess, m, group);
            // we don't notify members in indirect only relation
            if (status != null) {
                if (didntSubmitGroupExtensionApplication(m, group)) {
                    // still didn't apply for extension
                    getPerun().getAuditer().log(sess, new GroupMembershipExpired(m, 7, group));
                } else {
                    log.debug("{} not notified about expiration in {}, has submitted - pending application.", m, group);
                }
            } else {
                log.debug("{} not notified about expiration in {}, isn't DIRECT member but still has expiration set!", m, group);
            }
        } else {
            log.debug("{} not notified about expiration in {}, is not in VALID, SUSPENDED or EXPIRED state.", m, group);
        }
    }
}
Also used : LocalDate(java.time.LocalDate) Member(cz.metacentrum.perun.core.api.Member) GroupMembershipExpired(cz.metacentrum.perun.audit.events.ExpirationNotifScheduler.GroupMembershipExpired) MemberGroupStatus(cz.metacentrum.perun.core.api.MemberGroupStatus)

Aggregations

GroupMembershipExpired (cz.metacentrum.perun.audit.events.ExpirationNotifScheduler.GroupMembershipExpired)1 Member (cz.metacentrum.perun.core.api.Member)1 MemberGroupStatus (cz.metacentrum.perun.core.api.MemberGroupStatus)1 LocalDate (java.time.LocalDate)1