/** * Check if member didn't submit new extension application - in such case, do not send expiration notifications * * @param member Member to check applications for * @return TRUE = didn't submit application / FALSE = otherwise */ private boolean didntSubmitExtensionApplication(Member member) { try { Application application = jdbc.queryForObject(RegistrarManagerImpl.APP_SELECT + " where a.id=(select max(id) from application where vo_id=? and apptype=? and user_id=? )", RegistrarManagerImpl.APP_MAPPER, member.getVoId(), String.valueOf(Application.AppType.EXTENSION), member.getUserId()); return !Arrays.asList(Application.AppState.NEW, Application.AppState.VERIFIED).contains(application.getState()); } catch (EmptyResultDataAccessException ex) { // has no application submitted return true; } catch (Exception ex) { log.error("Unable to check if {} has submitted pending application: {}.", member, ex); return true; } }
/** * 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); } } }
@Override public String serializeToString() { return this.getClass().getSimpleName() + ":[" + "id=<" + getId() + ">" + ", userId=<" + getUserId() + ">" + ", voId=<" + getVoId() + ">" + ", status=<" + (getStatus() == null ? "\\0" : BeansUtils.createEscaping(getStatus().toString())) + ">" + ", type=<" + (getMembershipType() == null ? "\\0" : BeansUtils.createEscaping(getMembershipType().toString())) + ">" + ", sourceGroupId=<" + (getSourceGroupId() == null ? "\\0" : getSourceGroupId().toString()) + ">" + ", sponsored=<" + sponsored + ">" + ']'; }
@Override public List<Application> getApplicationsForMember(PerunSession sess, Group group, Member member) throws PerunException { // authz if (!AuthzResolver.isAuthorized(sess, Role.VOADMIN, member) && !AuthzResolver.isAuthorized(sess, Role.VOOBSERVER, member)) { if (group != null) { if (!AuthzResolver.isAuthorized(sess, Role.GROUPADMIN, group)) { throw new PrivilegeException(sess, "getApplicationsForMember"); } } else { throw new PrivilegeException(sess, "getApplicationsForMember"); } } try { if (group == null) { return jdbc.query(APP_SELECT + " where user_id=? and a.vo_id=? order by a.id desc", APP_MAPPER, member.getUserId(), member.getVoId()); } else { return jdbc.query(APP_SELECT + " where user_id=? and a.vo_id=? and a.group_id=? order by a.id desc", APP_MAPPER, member.getUserId(), member.getVoId(), group.getId()); } } catch (EmptyResultDataAccessException ex) { return new ArrayList<Application>(); } }
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);
for(Member member: members) { if(member.getStatus().equals(Status.VALID)) { membersOfPerunVo.add("memberOfPerunVo: " + member.getVoId()); List<Group> groups; groups = perun.getGroupsManagerBl().getAllMemberGroups(perunSession, member);
public RichMember(User user, Member member, List<UserExtSource> userExtSources) { super(member.getId(), member.getUserId(), member.getVoId(), member.getStatus(), member.getCreatedAt(), member.getCreatedBy(), member.getModifiedAt(), member.getModifiedBy(), member.getCreatedByUid(), member.getModifiedByUid()); setMembershipType(member.getMembershipType()); setSponsored(member.isSponsored()); this.setGroupsStatuses(member.getGroupStatuses()); this.user = user; this.userExtSources = userExtSources; this.userAttributes = null; this.memberAttributes = null; }