List of usage examples for java.util UUID equals
public boolean equals(Object obj)
From source file:org.jasig.ssp.service.impl.MapStatusReportCalcTaskImpl.java
private void sendOffPlanEmailsToCoaches() { boolean sendEmail = Boolean.parseBoolean( configService.getByNameEmpty("map_plan_status_send_off_plan_coach_email").trim().toLowerCase()); if (!(sendEmail)) { return;//from ww w . jav a2 s .c o m } final List<MapStatusReportOwnerAndCoachInfo> distinctOwnerCoachPairs = mapStatusReportService .getOwnersAndCoachesWithOffPlanStudent(); final List<MapStatusReportOwnerAndCoachInfo> distinctWatchers = mapStatusReportService .getWatchersOffPlanStudent(); if (distinctOwnerCoachPairs == null || distinctOwnerCoachPairs.isEmpty()) { return; } final Set<UUID> ownerIds = new HashSet<UUID>(); final Map<UUID, String> emailAddressByPersonId = new HashMap<UUID, String>(); final Map<UUID, Map<PersonToPlanRelationship, List<MapStatusReportPerson>>> statusesByOwnerOrCoachOrWatcher = new HashMap<UUID, Map<PersonToPlanRelationship, List<MapStatusReportPerson>>>(); for (MapStatusReportOwnerAndCoachInfo ownerCoachPair : distinctOwnerCoachPairs) { final UUID ownerId = ownerCoachPair.getOwnerId(); final UUID coachId = ownerCoachPair.getCoachId(); emailAddressByPersonId.put(ownerId, ownerCoachPair.getOwnerPrimaryEmail()); if (coachId != null) { emailAddressByPersonId.put(coachId, ownerCoachPair.getCoachPrimaryEmail()); } ownerIds.add(ownerId); if (!(statusesByOwnerOrCoachOrWatcher.containsKey(ownerId))) { statusesByOwnerOrCoachOrWatcher.put(ownerId, newPlanStatusContainerForOffPlanEmailsToCoaches()); } if (coachId != null && !(statusesByOwnerOrCoachOrWatcher.containsKey(coachId))) { statusesByOwnerOrCoachOrWatcher.put(coachId, newPlanStatusContainerForOffPlanEmailsToCoaches()); } } for (MapStatusReportOwnerAndCoachInfo mapStatusReportOwnerAndCoachInfo : distinctWatchers) { final UUID watcherId = mapStatusReportOwnerAndCoachInfo.getWatcherId(); ownerIds.add(watcherId); if (!(statusesByOwnerOrCoachOrWatcher.containsKey(watcherId))) { statusesByOwnerOrCoachOrWatcher.put(watcherId, newPlanStatusContainerForOffPlanEmailsToCoaches()); } } for (UUID ownerId : ownerIds) { final List<MapStatusReportPerson> offPlanPlansForOwner = mapStatusReportService .getOffPlanPlansForOwner(new Person(ownerId)); // if ( offPlanPlansForOwner == null || offPlanPlansForOwner.isEmpty() ) { // continue; // } for (MapStatusReportPerson status : offPlanPlansForOwner) { final UUID planCoachId = status.getCoachId(); final boolean sameOwnerAndCoach = ownerId.equals(planCoachId); final Map<PersonToPlanRelationship, List<MapStatusReportPerson>> statusesForOwner = statusesByOwnerOrCoachOrWatcher .get(ownerId); if (sameOwnerAndCoach) { final List<MapStatusReportPerson> categorizedStatuses = statusesForOwner .get(PersonToPlanRelationship.OWNER_AND_COACH); categorizedStatuses.add(status); } else { final List<MapStatusReportPerson> ownerCategorizedStatuses = statusesForOwner .get(PersonToPlanRelationship.OWNER_ONLY); ownerCategorizedStatuses.add(status); if (planCoachId != null) { final Map<PersonToPlanRelationship, List<MapStatusReportPerson>> statusesForCoach = statusesByOwnerOrCoachOrWatcher .get(planCoachId); // Seen this lookup come up empty in practice. Possibly b/c coach assignments changed since // the original list of owners and coaches was pulled? Not really worth it to try to // read/repair here, e.g. would have to go look up the coach email. So for now we're just // going to skip such coaches. if (statusesForCoach != null) { final List<MapStatusReportPerson> coachCategorizedStatuses = statusesForCoach .get(PersonToPlanRelationship.COACH_ONLY); coachCategorizedStatuses.add(status); } else { LOGGER.info( "Skipping status notification for coach {} on plan {} because that coach wasn't in the original list of plan owners and coaches", planCoachId, status.getPlanId()); } } } } final List<MapStatusReportPerson> offPlanPlansForWatcher = mapStatusReportService .getOffPlanPlansForWatcher(new Person(ownerId)); for (MapStatusReportPerson mapStatusReportPerson : offPlanPlansForWatcher) { //If watcher is was already owner/coach of a student, it has already been added final boolean isOwnerOrCoach = ownerId.equals(mapStatusReportPerson.getOwnerId()) || ownerId.equals(mapStatusReportPerson.getCoachId()); if (!isOwnerOrCoach) { final Map<PersonToPlanRelationship, List<MapStatusReportPerson>> statusesForPerson = statusesByOwnerOrCoachOrWatcher .get(ownerId); List<MapStatusReportPerson> watcherPlans = statusesForPerson .get(PersonToPlanRelationship.WATCHER_ONLY); watcherPlans.add(mapStatusReportPerson); } } } final MapStatusReportPersonNameComparator sorter = new MapStatusReportPersonNameComparator(); for (Map.Entry<UUID, Map<PersonToPlanRelationship, List<MapStatusReportPerson>>> statusesForOwnerOrCoach : statusesByOwnerOrCoachOrWatcher .entrySet()) { final UUID sendToPersonId = statusesForOwnerOrCoach.getKey(); final String sendToEmailAddress = emailAddressByPersonId.get(sendToPersonId); if (StringUtils.trimToNull(sendToEmailAddress) == null) { continue; } for (List<MapStatusReportPerson> statuses : statusesForOwnerOrCoach.getValue().values()) { Collections.sort(statuses, sorter); } // TODO Templatize: https://issues.jasig.org/browse/SSP-2572 final Map<PersonToPlanRelationship, List<MapStatusReportPerson>> statusesByCategory = statusesForOwnerOrCoach .getValue(); final StringBuilder sb = new StringBuilder(); sb.append("<html><body>\n").append("<h2>MAP Plan Status Report</h2>\n").append( "The following students have been determined to be Off Plan after comparing their transcript to their MAP.</br>\n"); appendOffPlanStanza(statusesByCategory, PersonToPlanRelationship.OWNER_AND_COACH, "Assigned to You (and You Planned the MAP)", sb); appendOffPlanStanza(statusesByCategory, PersonToPlanRelationship.COACH_ONLY, "Assigned to You (but Somebody Else Planned the MAP)", sb); appendOffPlanStanza(statusesByCategory, PersonToPlanRelationship.OWNER_ONLY, "Not Assigned to You (but You Planned the MAP)", sb); appendOffPlanStanza(statusesByCategory, PersonToPlanRelationship.WATCHER_ONLY, "Plans of Students you watch (but you did not Plan the map or are not the coach) ", sb); sb.append("<br/>\n</body></html>"); SubjectAndBody subjectAndBody = new SubjectAndBody("Student MAP Off Plan Report", sb.toString()); try { messageService.createMessage(sendToEmailAddress, null, subjectAndBody); } catch (ObjectNotFoundException e) { LOGGER.error("Failed to send MAP status report to owner or coach {} at address {}", new Object[] { sendToPersonId, sendToEmailAddress, e }); } } }
From source file:de.bangl.lm.LotManagerPlugin.java
public void hasLot(CommandSender sender, String name, UUID uuid) { try {// www.j av a 2 s. c om List<Lot> userlots; userlots = new ArrayList<Lot>(); List<World> worlds; worlds = this.getServer().getWorlds(); for (World world : worlds) { Integer WorldId; WorldId = this.lots.getWorldId(world); Collection<ProtectedRegion> regions; regions = wg.getRegionManager(world).getRegions().values(); for (ProtectedRegion region : regions) { if (this.lots.existsLot(WorldId, region.getId())) { Set<UUID> owners = region.getOwners().getUniqueIds(); for (UUID owner : owners) { if (uuid.equals(owner)) { userlots.add(this.lots.getLot(WorldId, region.getId())); } } } } } if (!userlots.isEmpty()) { List<LotGroup> groups = new ArrayList<LotGroup>(); for (Lot lot : userlots) { LotGroup group = lot.getGroup(); if (!groups.contains(group.getId())) { groups.add(group); } } sendInfo(sender, name + " owns:"); for (LotGroup group : groups) { sendInfo(sender, group.getId() + ":"); for (Lot lot : userlots) { if (lot.getGroup().getId().equals(group.getId())) { sendInfo(sender, " - " + lot.getId()); } } } } else { sendInfo(sender, name + " doesn't own any lot."); } } catch (Exception e) { logError(e.getMessage()); sendError(sender, e.getMessage()); } }
From source file:org.apache.usergrid.management.cassandra.ManagementServiceImpl.java
@Override public ActivationState handleActivationTokenForAdminUser(UUID userId, String token) throws Exception { AuthPrincipalInfo principal = getPrincipalFromAccessToken(token, TOKEN_TYPE_ACTIVATION, ADMIN_USER); if ((principal != null) && userId.equals(principal.getUuid())) { activateAdminUser(principal.getUuid()); UserInfo user = getAdminUserByUuid(principal.getUuid()); sendAdminUserActivatedEmail(user); sendSysAdminNewAdminActivatedNotificationEmail(user); return ActivationState.ACTIVATED; }/*from www . ja va 2 s .c o m*/ return ActivationState.UNKNOWN; }
From source file:org.apache.usergrid.management.cassandra.ManagementServiceImpl.java
@Override public ActivationState handleConfirmationTokenForAdminUser(UUID userId, String token) throws Exception { AuthPrincipalInfo principal = getPrincipalFromAccessToken(token, TOKEN_TYPE_CONFIRM, ADMIN_USER); if ((principal != null) && userId.equals(principal.getUuid())) { UserInfo user = getAdminUserByUuid(principal.getUuid()); confirmAdminUser(user.getUuid()); if (newAdminUsersNeedSysAdminApproval()) { sendAdminUserConfirmedAwaitingActivationEmail(user); sendSysAdminRequestAdminActivationEmail(user); return ActivationState.CONFIRMED_AWAITING_ACTIVATION; } else {// w w w . j a va2s.c o m activateAdminUser(principal.getUuid()); sendAdminUserActivatedEmail(user); sendSysAdminNewAdminActivatedNotificationEmail(user); return ActivationState.ACTIVATED; } } return ActivationState.UNKNOWN; }
From source file:org.apache.usergrid.management.cassandra.ManagementServiceImpl.java
@Override public ActivationState handleActivationTokenForAppUser(UUID applicationId, UUID userId, String token) throws Exception { AuthPrincipalInfo principal = getPrincipalFromAccessToken(token, TOKEN_TYPE_ACTIVATION, APPLICATION_USER); if ((principal != null) && userId.equals(principal.getUuid())) { activateAppUser(applicationId, principal.getUuid()); EntityManager em = emf.getEntityManager(applicationId); User user = em.get(userId, User.class); sendAppUserActivatedEmail(applicationId, user); sendAdminNewAppUserActivatedNotificationEmail(applicationId, user); return ActivationState.ACTIVATED; }/*from www.j a va 2 s . co m*/ return ActivationState.UNKNOWN; }
From source file:org.apache.usergrid.management.cassandra.ManagementServiceImpl.java
@Override public ActivationState handleActivationTokenForOrganization(UUID organizationId, String token) throws Exception { AuthPrincipalInfo principal = getPrincipalFromAccessToken(token, TOKEN_TYPE_ACTIVATION, ORGANIZATION); if ((principal != null) && organizationId.equals(principal.getUuid())) { OrganizationInfo organization = this.getOrganizationByUuid(organizationId); sendOrganizationActivatedEmail(organization); sendSysAdminNewOrganizationActivatedNotificationEmail(organization); activateOrganization(organization, false); return ActivationState.ACTIVATED; }/* www.j a v a2 s .com*/ return ActivationState.UNKNOWN; }
From source file:org.apache.usergrid.management.cassandra.ManagementServiceImpl.java
@Override public ActivationState handleConfirmationTokenForAppUser(UUID applicationId, UUID userId, String token) throws Exception { AuthPrincipalInfo principal = getPrincipalFromAccessToken(token, TOKEN_TYPE_CONFIRM, APPLICATION_USER); if ((principal != null) && userId.equals(principal.getUuid())) { EntityManager em = emf.getEntityManager(applicationId); User user = em.get(userId, User.class); confirmAppUser(applicationId, user.getUuid()); if (newAppUsersNeedAdminApproval(applicationId)) { sendAppUserConfirmedAwaitingActivationEmail(applicationId, user); sendAdminRequestAppUserActivationEmail(applicationId, user); return ActivationState.CONFIRMED_AWAITING_ACTIVATION; } else {// w w w . j a v a 2s .co m activateAppUser(applicationId, principal.getUuid()); sendAppUserActivatedEmail(applicationId, user); sendAdminNewAppUserActivatedNotificationEmail(applicationId, user); return ActivationState.ACTIVATED; } } return ActivationState.UNKNOWN; }
From source file:org.usergrid.management.cassandra.ManagementServiceImpl.java
@Override public ActivationState handleConfirmationTokenForAppUser(UUID applicationId, UUID userId, String token) throws Exception { AuthPrincipalInfo principal = getPrincipalFromAccessToken(token, TOKEN_TYPE_CONFIRM, APPLICATION_USER); if ((principal != null) && userId.equals(principal.getUuid())) { EntityManager em = emf.getEntityManager(applicationId); User user = em.get(userId, User.class); confirmAppUser(applicationId, user.getUuid()); if (newAppUsersNeedAdminApproval(applicationId)) { sendAppUserConfirmedAwaitingActivationEmail(applicationId, user); sendAdminRequestAppUserActivationEmail(applicationId, user); return ActivationState.CONFIRMED_AWAITING_ACTIVATION; } else {/*from w w w. j a v a 2 s . c o m*/ activateAppUser(applicationId, principal.getUuid()); sendAppUserActivatedEmail(applicationId, user); sendAdminNewAppUserActivatedNotificationEmail(applicationId, user); return ActivationState.ACTIVATED; } } return ActivationState.UNKNOWN; }
From source file:org.apache.usergrid.management.cassandra.ManagementServiceImpl.java
@Override public boolean checkPasswordResetTokenForAdminUser(UUID userId, String token) throws Exception { AuthPrincipalInfo principal = null;/*from ww w . jav a 2 s .c om*/ try { principal = getPrincipalFromAccessToken(token, TOKEN_TYPE_PASSWORD_RESET, ADMIN_USER); } catch (Exception e) { logger.error("Unable to verify token", e); } return (principal != null) && userId.equals(principal.getUuid()); }
From source file:org.apache.usergrid.management.cassandra.ManagementServiceImpl.java
@Override public boolean checkPasswordResetTokenForAppUser(UUID applicationId, UUID userId, String token) throws Exception { AuthPrincipalInfo principal = null;// ww w. j ava 2 s. com try { principal = getPrincipalFromAccessToken(token, TOKEN_TYPE_PASSWORD_RESET, APPLICATION_USER); } catch (Exception e) { logger.error("Unable to verify token", e); } return (principal != null) && userId.equals(principal.getUuid()); }