private String buildFreeBusyAttendeeResponse(
     Profile attendee, ICalFormatter.FreeBusyRequest request, String domain, String attendeeMailto)
     throws NotAuthorizedException, BadRequestException {
   Date start = request.getStart();
   Date finish = request.getFinish();
   List<EventResourceImpl> list = new ArrayList<>();
   if (attendee.getCalendars() != null) {
     for (Calendar cal : attendee.getCalendars()) {
       if (cal.getEvents() != null) {
         for (CalEvent event : cal.getEvents()) {
           if (!outsideDates(event, start, finish)) {
             EventResourceImpl er = new EventResourceImpl();
             er.setEnd(event.getEndDate());
             er.setStart(event.getStartDate());
             er.setSummary(er.getSummary());
             er.setUniqueId(er.getUniqueId());
             list.add(er);
             log.info("** INSIDE: " + event.getSummary());
           } else {
             log.info("Outside dates: " + event.getSummary());
           }
         }
       }
     }
   }
   return formatter.buildFreeBusyAttendeeResponse(list, request, domain, attendeeMailto);
 }
Beispiel #2
0
 public static Profile create(String email, Date now) {
   Profile p = new Profile();
   p.setEmail(email.toLowerCase());
   p.setCreatedDate(now);
   p.setModifiedDate(now);
   return p;
 }
 /**
  * Remove all memberships of this profile within this organiosation or subordinate organisations
  *
  * @param profile
  * @param session
  */
 public void removeMember(Profile profile, Session session) {
   log.info("removeMember: profileid=" + profile.getId() + " org=" + getOrgId());
   List<GroupMembership> toDelete = new ArrayList<>();
   if (profile.getMemberships() != null) {
     for (GroupMembership m : profile.getMemberships()) {
       Organisation memberWithin = m.getWithinOrg();
       if (memberWithin.isWithin(this)) {
         log.info(
             "Remove membership of user: "******" from org: "
                 + memberWithin.getOrgId());
         toDelete.add(m);
       }
     }
   }
   for (GroupMembership m : toDelete) {
     m.delete(session);
   }
 }
 @FreeBusyQuery
 public List<SchedulingResponseItem> freeBusyQuery(Profile profile, String icalQuery)
     throws NotAuthorizedException {
   ICalFormatter.FreeBusyRequest r = formatter.parseFreeBusyRequest(icalQuery);
   log.info(
       "queryFreeBusy: attendees="
           + r.getAttendeeLines().size()
           + " - "
           + r.getAttendeeMailtos().size());
   List<SchedulingResponseItem> list = new ArrayList<>();
   try {
     for (String attendeeMailto : r.getAttendeeMailtos()) {
       MailboxAddress add = MailboxAddress.parse(attendeeMailto);
       Profile attendee = findUserFromMailto(add);
       if (attendee == null) {
         log.warn("Attendee not found: " + attendeeMailto);
         SchedulingResponseItem item =
             new SchedulingResponseItem(
                 "mailto:" + attendeeMailto, ITip.StatusResponse.RS_INVALID_37, null);
         list.add(item);
       } else {
         log.info("Found attendee: " + attendee.getName());
         // Now locate events and build an ical response
         String ical = buildFreeBusyAttendeeResponse(attendee, r, add.domain, attendeeMailto);
         SchedulingResponseItem item =
             new SchedulingResponseItem(
                 "mailto:" + attendeeMailto, ITip.StatusResponse.RS_SUCCESS_20, ical);
         list.add(item);
       }
     }
   } catch (NotAuthorizedException ex) {
     throw ex;
   } catch (BadRequestException ex) {
     throw new RuntimeException(ex);
   }
   return list;
 }
 @CalendarInvitations
 public List<AttendeeRequest> getAttendeeRequests(Profile user) {
   log.info("getAttendeeRequests: " + user.getName());
   return calendarService.getAttendeeRequests(user, false);
 }
 /**
  * @param add
  * @return
  * @throws NotAuthorizedException
  * @throws BadRequestException
  */
 private Profile findUserFromMailto(MailboxAddress add)
     throws NotAuthorizedException, BadRequestException {
   return Profile.findByEmail(add.toPlainAddress(), SessionManager.session());
 }