public Object createServiceObjectWithServiceParam( ExchangeService srv) throws Exception { return new Appointment(srv); } }, new ICreateServiceObjectWithAttachmentParam() {
/** * Binds to an existing appointment and loads its first class property. * Calling this method results in a call to EWS. * * @param service the service * @param id the id * @return An Appointment instance representing the appointment * corresponding to the specified Id. * @throws Exception the exception */ public static Appointment bind(ExchangeService service, ItemId id) throws Exception { return Appointment.bind(service, id, PropertySet.FirstClassProperties); }
/** * Binds to an existing appointment and loads its first class property. * Calling this method results in a call to EWS. * * @param service the service * @param recurringMasterId the recurring master id * @param occurenceIndex the occurence index * @return An Appointment instance representing the appointment * corresponding to the specified Id. * @throws Exception the exception */ public static Appointment bindToOccurrence(ExchangeService service, ItemId recurringMasterId, int occurenceIndex) throws Exception { return Appointment.bindToOccurrence(service, recurringMasterId, occurenceIndex, PropertySet.FirstClassProperties); }
private AppointmentDto convertToAppointmentDto(final Appointment appointment) throws ServiceLocalException { final AppointmentDto appointmentDto = new AppointmentDto(); appointmentDto.setExchangeId(appointment.getId().getUniqueId()); appointmentDto.setLastModified(convertToJodaDateTime(appointment.getLastModifiedTime())); appointmentDto.setSummary(appointment.getSubject()); try { appointmentDto.setDescription(MessageBody.getStringFromMessageBody(appointment.getBody())); } catch (final Exception e) { LOG.error("Unable to retrieve appointment body from Exchange", e); appointmentDto.setStart(convertToJodaDateTime(appointment.getStart())); appointmentDto.setEnd(convertToJodaDateTime(appointment.getEnd())); appointmentDto.setAllDay(appointment.getIsAllDayEvent()); appointmentDto.setLocation(appointment.getLocation()); if (appointment.getOrganizer() != null) { appointmentDto.setOrganizer(convertToPersonDto(appointment.getOrganizer(), false)); if (appointment.getRequiredAttendees() != null) { for (final Attendee exchangeAttendee : appointment.getRequiredAttendees()) { attendees.add(convertToPersonDto(exchangeAttendee, false)); if (appointment.getOptionalAttendees() != null) { for (final Attendee exchangeAttendee : appointment.getOptionalAttendees()) { attendees.add(convertToPersonDto(exchangeAttendee, true)); appointmentDto.setReminderMinutesBeforeStart(appointment.getReminderMinutesBeforeStart()); if (appointment.getRecurrence() != null) { if (appointment.getRecurrence() instanceof Recurrence.DailyPattern) { appointmentDto.setRecurrenceType(RecurrenceType.DAILY); } else if (appointment.getRecurrence() instanceof Recurrence.WeeklyPattern) {
private void fillAppointment(Absence absence, Appointment appointment) throws Exception { // NOSONAR - EWS Java API throws Exception, that's life Person person = absence.getPerson(); appointment.setSubject(absence.getEventSubject()); appointment.setStart(absence.getStartDate()); appointment.setEnd(absence.getEndDate()); appointment.setIsAllDayEvent(absence.isAllDay()); appointment.getRequiredAttendees().add(person.getEmail()); }
@Override public Optional<String> add(Absence absence, CalendarSettings calendarSettings) { ExchangeCalendarSettings exchangeCalendarSettings = calendarSettings.getExchangeCalendarSettings(); String calendarName = exchangeCalendarSettings.getCalendar(); connectToExchange(exchangeCalendarSettings); try { CalendarFolder calendarFolder = findOrCreateCalendar(calendarName); Appointment appointment = new Appointment(exchangeService); fillAppointment(absence, appointment); SendInvitationsMode invitationsMode = SendInvitationsMode.SendToNone; if (exchangeCalendarSettings.isSendInvitationActive()) { invitationsMode = SendInvitationsMode.SendToAllAndSaveCopy; } appointment.save(calendarFolder.getId(), invitationsMode); LOG.info(String.format("Appointment %s for '%s' added to exchange calendar '%s'.", appointment.getId(), absence.getPerson().getNiceName(), calendarFolder.getDisplayName())); return Optional.ofNullable(appointment.getId().getUniqueId()); } catch (Exception ex) { // NOSONAR - EWS Java API throws Exception, that's life LOG.warn("An error occurred while trying to add appointment to Exchange calendar"); mailService.sendCalendarSyncErrorNotification(calendarName, absence, ExceptionUtils.getStackTrace(ex)); } return Optional.empty(); }
@Override public void delete(String eventId, CalendarSettings calendarSettings) { ExchangeCalendarSettings exchangeCalendarSettings = calendarSettings.getExchangeCalendarSettings(); String calendarName = exchangeCalendarSettings.getCalendar(); connectToExchange(exchangeCalendarSettings); try { Appointment appointment = Appointment.bind(exchangeService, new ItemId(eventId)); SendCancellationsMode notificationMode = SendCancellationsMode.SendToNone; if (exchangeCalendarSettings.isSendInvitationActive()) { notificationMode = SendCancellationsMode.SendToAllAndSaveCopy; } appointment.delete(DeleteMode.HardDelete, notificationMode); LOG.info(String.format("Appointment %s has been deleted in exchange calendar '%s'.", eventId, calendarName)); } catch (Exception ex) { // NOSONAR - EWS Java API throws Exception, that's life LOG.warn(String.format("Could not delete appointment %s in exchange calendar '%s'", eventId, calendarName)); mailService.sendCalendarDeleteErrorNotification(calendarName, eventId, ExceptionUtils.getStackTrace(ex)); } }
@Override public void update(Absence absence, String eventId, CalendarSettings calendarSettings) { ExchangeCalendarSettings exchangeCalendarSettings = calendarSettings.getExchangeCalendarSettings(); String calendarName = exchangeCalendarSettings.getCalendar(); connectToExchange(exchangeCalendarSettings); try { Appointment appointment = Appointment.bind(exchangeService, new ItemId(eventId)); fillAppointment(absence, appointment); SendInvitationsOrCancellationsMode notificationMode = SendInvitationsOrCancellationsMode.SendToNone; if (exchangeCalendarSettings.isSendInvitationActive()) { notificationMode = SendInvitationsOrCancellationsMode.SendToAllAndSaveCopy; } appointment.update(ConflictResolutionMode.AutoResolve, notificationMode); LOG.info(String.format("Appointment %s has been updated in exchange calendar '%s'.", eventId, calendarName)); } catch (Exception ex) { // NOSONAR - EWS Java API throws Exception, that's life LOG.warn(String.format("Could not update appointment %s in exchange calendar '%s'", eventId, calendarName)); mailService.sendCalendarUpdateErrorNotification(calendarName, absence, eventId, ExceptionUtils.getStackTrace(ex)); } }
/** * Cancels the meeting and sends cancellation messages to all attendees. * Calling this method results in a call to EWS. * * @return A CalendarActionResults object containing the various item that * were created or modified as a results of this operation. * @throws Exception the exception */ public CalendarActionResults cancelMeeting() throws Exception { return this.createCancelMeetingMessage().calendarSendAndSaveCopy(); }
/** * Binds to the master appointment of a recurring series and loads its first * class property. Calling this method results in a call to EWS. * * @param service the service * @param occurrenceId the occurrence id * @return An Appointment instance representing the appointment * corresponding to the specified Id. * @throws Exception the exception */ public static Appointment bindToRecurringMaster(ExchangeService service, ItemId occurrenceId) throws Exception { return Appointment.bindToRecurringMaster(service, occurrenceId, PropertySet.FirstClassProperties); }
/** * Forwards the appointment. Calling this method results in a call to EWS. * * @param bodyPrefix the body prefix * @param toRecipients the to recipients * @throws Exception the exception */ public void forward(MessageBody bodyPrefix, Iterable<EmailAddress> toRecipients) throws Exception { ResponseMessage responseMessage = this.createForward(); responseMessage.setBodyPrefix(bodyPrefix); responseMessage.getToRecipients() .addEmailRange(toRecipients.iterator()); responseMessage.sendAndSaveCopy(); }
/** * Declines the meeting invitation. Calling this method results in a call to * EWS. * * @param sendResponse the send response * @return A CalendarActionResults object containing the various item that * were created or modified as a results of this operation. * @throws Exception the exception */ public CalendarActionResults decline(boolean sendResponse) throws Exception { DeclineMeetingInvitationMessage decline = this.createDeclineMessage(); if (sendResponse) { return decline.calendarSendAndSaveCopy(); } else { return decline.calendarSave(); } }
/** * Accepts the meeting. * * @param tentative the tentative * @param sendResponse the send response * @return A CalendarActionResults object containing the various item that * were created or modified as a results of this operation. * @throws Exception the exception */ protected CalendarActionResults internalAccept(boolean tentative, boolean sendResponse) throws Exception { AcceptMeetingInvitationMessage accept = this .createAcceptMessage(tentative); if (sendResponse) { return accept.calendarSendAndSaveCopy(); } else { return accept.calendarSave(); } }
/** * Cancels the meeting and sends cancellation messages to all attendees. * Calling this method results in a call to EWS. * * @param cancellationMessageText the cancellation message text * @return A CalendarActionResults object containing the various item that * were created or modified as a results of this operation. * @throws Exception the exception */ public CalendarActionResults cancelMeeting(String cancellationMessageText) throws Exception { CancelMeetingMessage cancelMsg = this.createCancelMeetingMessage(); cancelMsg.setBody(new MessageBody(cancellationMessageText)); return cancelMsg.calendarSendAndSaveCopy(); }
/** * Binds to the master appointment of a recurring series and loads its first * class property. Calling this method results in a call to EWS. * * @param service the service * @param occurrenceId the occurrence id * @return An Appointment instance representing the appointment * corresponding to the specified Id. * @throws Exception the exception */ public static Appointment bindToRecurringMaster(ExchangeService service, ItemId occurrenceId) throws Exception { return Appointment.bindToRecurringMaster(service, occurrenceId, PropertySet.FirstClassProperties); }
/** * Forwards the appointment. Calling this method results in a call to EWS. * * @param bodyPrefix the body prefix * @param toRecipients the to recipients * @throws Exception the exception */ public void forward(MessageBody bodyPrefix, Iterable<EmailAddress> toRecipients) throws Exception { ResponseMessage responseMessage = this.createForward(); responseMessage.setBodyPrefix(bodyPrefix); responseMessage.getToRecipients() .addEmailRange(toRecipients.iterator()); responseMessage.sendAndSaveCopy(); }
/** * Declines the meeting invitation. Calling this method results in a call to * EWS. * * @param sendResponse the send response * @return A CalendarActionResults object containing the various item that * were created or modified as a results of this operation. * @throws Exception the exception */ public CalendarActionResults decline(boolean sendResponse) throws Exception { DeclineMeetingInvitationMessage decline = this.createDeclineMessage(); if (sendResponse) { return decline.calendarSendAndSaveCopy(); } else { return decline.calendarSave(); } }
/** * Accepts the meeting. * * @param tentative the tentative * @param sendResponse the send response * @return A CalendarActionResults object containing the various item that * were created or modified as a results of this operation. * @throws Exception the exception */ protected CalendarActionResults internalAccept(boolean tentative, boolean sendResponse) throws Exception { AcceptMeetingInvitationMessage accept = this .createAcceptMessage(tentative); if (sendResponse) { return accept.calendarSendAndSaveCopy(); } else { return accept.calendarSave(); } }
/** * Binds to an existing appointment and loads its first class property. * Calling this method results in a call to EWS. * * @param service the service * @param recurringMasterId the recurring master id * @param occurenceIndex the occurence index * @param propertySet the property set * @return An Appointment instance representing the appointment * corresponding to the specified Id. * @throws Exception the exception */ public static Appointment bindToOccurrence(ExchangeService service, ItemId recurringMasterId, int occurenceIndex, PropertySet propertySet) throws Exception { AppointmentOccurrenceId occurenceId = new AppointmentOccurrenceId( recurringMasterId.getUniqueId(), occurenceIndex); return Appointment.bind(service, occurenceId, propertySet); }
public Object createServiceObjectWithAttachmentParam( ItemAttachment itemAttachment, boolean isNew) throws Exception { return new Appointment(itemAttachment, isNew); } });