001/*
002 * The MIT License
003 * Copyright (c) 2012 Microsoft Corporation
004 *
005 * Permission is hereby granted, free of charge, to any person obtaining a copy
006 * of this software and associated documentation files (the "Software"), to deal
007 * in the Software without restriction, including without limitation the rights
008 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
009 * copies of the Software, and to permit persons to whom the Software is
010 * furnished to do so, subject to the following conditions:
011 *
012 * The above copyright notice and this permission notice shall be included in
013 * all copies or substantial portions of the Software.
014 *
015 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
016 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
017 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
018 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
019 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
020 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
021 * THE SOFTWARE.
022 */
023
024package microsoft.exchange.webservices.data.core.service.item;
025
026import microsoft.exchange.webservices.data.attribute.Attachable;
027import microsoft.exchange.webservices.data.attribute.ServiceObjectDefinition;
028import microsoft.exchange.webservices.data.core.EwsUtilities;
029import microsoft.exchange.webservices.data.core.ExchangeService;
030import microsoft.exchange.webservices.data.core.PropertySet;
031import microsoft.exchange.webservices.data.core.XmlElementNames;
032import microsoft.exchange.webservices.data.core.service.response.AcceptMeetingInvitationMessage;
033import microsoft.exchange.webservices.data.core.service.response.CancelMeetingMessage;
034import microsoft.exchange.webservices.data.core.service.response.DeclineMeetingInvitationMessage;
035import microsoft.exchange.webservices.data.core.service.response.ResponseMessage;
036import microsoft.exchange.webservices.data.core.service.schema.AppointmentSchema;
037import microsoft.exchange.webservices.data.core.service.schema.ServiceObjectSchema;
038import microsoft.exchange.webservices.data.core.enumeration.service.calendar.AppointmentType;
039import microsoft.exchange.webservices.data.core.enumeration.service.ConflictResolutionMode;
040import microsoft.exchange.webservices.data.core.enumeration.service.DeleteMode;
041import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion;
042import microsoft.exchange.webservices.data.core.enumeration.property.LegacyFreeBusyStatus;
043import microsoft.exchange.webservices.data.core.enumeration.property.MeetingResponseType;
044import microsoft.exchange.webservices.data.core.enumeration.service.ResponseMessageType;
045import microsoft.exchange.webservices.data.core.enumeration.service.SendCancellationsMode;
046import microsoft.exchange.webservices.data.core.enumeration.service.SendInvitationsMode;
047import microsoft.exchange.webservices.data.core.enumeration.service.SendInvitationsOrCancellationsMode;
048import microsoft.exchange.webservices.data.core.enumeration.property.WellKnownFolderName;
049import microsoft.exchange.webservices.data.core.exception.service.local.ServiceLocalException;
050import microsoft.exchange.webservices.data.misc.CalendarActionResults;
051import microsoft.exchange.webservices.data.misc.TimeSpan;
052import microsoft.exchange.webservices.data.property.complex.AppointmentOccurrenceId;
053import microsoft.exchange.webservices.data.property.complex.AttendeeCollection;
054import microsoft.exchange.webservices.data.property.complex.DeletedOccurrenceInfoCollection;
055import microsoft.exchange.webservices.data.property.complex.EmailAddress;
056import microsoft.exchange.webservices.data.property.complex.FolderId;
057import microsoft.exchange.webservices.data.property.complex.ItemAttachment;
058import microsoft.exchange.webservices.data.property.complex.ItemCollection;
059import microsoft.exchange.webservices.data.property.complex.ItemId;
060import microsoft.exchange.webservices.data.property.complex.MessageBody;
061import microsoft.exchange.webservices.data.property.complex.OccurrenceInfo;
062import microsoft.exchange.webservices.data.property.complex.OccurrenceInfoCollection;
063import microsoft.exchange.webservices.data.property.complex.RecurringAppointmentMasterId;
064import microsoft.exchange.webservices.data.property.complex.recurrence.pattern.Recurrence;
065import microsoft.exchange.webservices.data.property.complex.time.TimeZoneDefinition;
066
067import java.util.Arrays;
068import java.util.Date;
069
070/**
071 * Represents an appointment or a meeting. Properties available on appointments
072 * are defined in the AppointmentSchema class.
073 */
074@Attachable
075@ServiceObjectDefinition(xmlElementName = XmlElementNames.CalendarItem)
076public class Appointment extends Item implements ICalendarActionProvider {
077
078  /**
079   * Initializes an unsaved local instance of Appointment". To bind to an
080   * existing appointment, use Appointment.Bind() instead.
081   *
082   * @param service The ExchangeService instance to which this appointmtnt is
083   *                bound.
084   * @throws Exception the exception
085   */
086  public Appointment(ExchangeService service) throws Exception {
087    super(service);
088  }
089
090  /**
091   * Initializes a new instance of Appointment.
092   *
093   * @param parentAttachment the parent attachment
094   * @param isNew            If true, attachment is new.
095   * @throws Exception the exception
096   */
097  public Appointment(ItemAttachment parentAttachment, boolean isNew)
098      throws Exception {
099    // If we're running against Exchange 2007, we need to explicitly preset
100    // the StartTimeZone property since Exchange 2007 will otherwise scope
101    // start and end to UTC.
102    super(parentAttachment);
103  }
104
105  /**
106   * Binds to an existing appointment and loads the specified set of
107   * property. Calling this method results in a call to EWS.
108   *
109   * @param service     the service
110   * @param id          the id
111   * @param propertySet the property set
112   * @return An Appointment instance representing the appointment
113   * corresponding to the specified Id.
114   * @throws Exception the exception
115   */
116  public static Appointment bind(ExchangeService service, ItemId id,
117      PropertySet propertySet) throws Exception {
118    return service.bindToItem(Appointment.class, id, propertySet);
119  }
120
121  /**
122   * Binds to an existing appointment and loads its first class property.
123   * Calling this method results in a call to EWS.
124   *
125   * @param service the service
126   * @param id      the id
127   * @return An Appointment instance representing the appointment
128   * corresponding to the specified Id.
129   * @throws Exception the exception
130   */
131  public static Appointment bind(ExchangeService service, ItemId id)
132      throws Exception {
133    return Appointment.bind(service, id, PropertySet.FirstClassProperties);
134  }
135
136  /**
137   * Binds to an existing appointment and loads its first class property.
138   * Calling this method results in a call to EWS.
139   *
140   * @param service           the service
141   * @param recurringMasterId the recurring master id
142   * @param occurenceIndex    the occurence index
143   * @return An Appointment instance representing the appointment
144   * corresponding to the specified Id.
145   * @throws Exception the exception
146   */
147  public static Appointment bindToOccurrence(ExchangeService service,
148      ItemId recurringMasterId, int occurenceIndex) throws Exception {
149    return Appointment.bindToOccurrence(service, recurringMasterId,
150        occurenceIndex, PropertySet.FirstClassProperties);
151  }
152
153  /**
154   * Binds to an existing appointment and loads its first class property.
155   * Calling this method results in a call to EWS.
156   *
157   * @param service           the service
158   * @param recurringMasterId the recurring master id
159   * @param occurenceIndex    the occurence index
160   * @param propertySet       the property set
161   * @return An Appointment instance representing the appointment
162   * corresponding to the specified Id.
163   * @throws Exception the exception
164   */
165  public static Appointment bindToOccurrence(ExchangeService service,
166      ItemId recurringMasterId, int occurenceIndex,
167      PropertySet propertySet) throws Exception {
168    AppointmentOccurrenceId occurenceId = new AppointmentOccurrenceId(
169        recurringMasterId.getUniqueId(), occurenceIndex);
170    return Appointment.bind(service, occurenceId, propertySet);
171  }
172
173  /**
174   * Binds to the master appointment of a recurring series and loads its first
175   * class property. Calling this method results in a call to EWS.
176   *
177   * @param service      the service
178   * @param occurrenceId the occurrence id
179   * @return An Appointment instance representing the appointment
180   * corresponding to the specified Id.
181   * @throws Exception the exception
182   */
183  public static Appointment bindToRecurringMaster(ExchangeService service,
184      ItemId occurrenceId) throws Exception {
185    return Appointment.bindToRecurringMaster(service, occurrenceId,
186        PropertySet.FirstClassProperties);
187  }
188
189  /**
190   * Binds to the master appointment of a recurring series and loads its first
191   * class property. Calling this method results in a call to EWS.
192   *
193   * @param service      the service
194   * @param occurrenceId the occurrence id
195   * @param propertySet  the property set
196   * @return An Appointment instance representing the appointment
197   * corresponding to the specified Id.
198   * @throws Exception the exception
199   */
200  public static Appointment bindToRecurringMaster(ExchangeService service,
201      ItemId occurrenceId, PropertySet propertySet) throws Exception {
202    RecurringAppointmentMasterId recurringMasterId =
203        new RecurringAppointmentMasterId(
204            occurrenceId.getUniqueId());
205    return Appointment.bind(service, recurringMasterId, propertySet);
206  }
207
208  /**
209   * Internal method to return the schema associated with this type of object.
210   *
211   * @return The schema associated with this type of object
212   */
213  @Override public ServiceObjectSchema getSchema() {
214    return AppointmentSchema.Instance;
215  }
216
217  /**
218   * Gets the minimum required server version.
219   *
220   * @return Earliest Exchange version in which this service object type is
221   * supported.
222   */
223  @Override public ExchangeVersion getMinimumRequiredServerVersion() {
224    return ExchangeVersion.Exchange2007_SP1;
225  }
226
227  /**
228   * Determines whether property defined with
229   * ScopedDateTimePropertyDefinition require custom time zone scoping.
230   *
231   * @return if this item type requires custom scoping for scoped date/time
232   * property; otherwise, .
233   */
234  @Override
235  protected boolean getIsCustomDateTimeScopingRequired() {
236    return true;
237  }
238
239  /**
240   * Validates this instance.
241   *
242   * @throws Exception
243   */
244  @Override public void validate() throws Exception {
245    super.validate();
246
247    //  PS # 250452: Make sure that if we're
248    //on the Exchange2007_SP1 schema version,
249    // if any of the following
250    //  property are set or updated:
251    //      o   Start
252    //      o   End
253    //      o   IsAllDayEvent
254    //      o   Recurrence
255    //  ... then, we must send the MeetingTimeZone element
256    // (which is generated from StartTimeZone for
257    //  Exchange2007_SP1 request (see
258    //StartTimeZonePropertyDefinition.cs).
259    // If the StartTimeZone isn't
260    //  in the property bag, then throw, because clients must
261    // supply the proper time zone - either by
262    //  loading it from a currently-existing appointment,
263    //or by setting it directly.
264    // Otherwise, to dirty
265    //  the StartTimeZone property, we just set it to its current value.
266    if ((this.getService().getRequestedServerVersion() == ExchangeVersion.Exchange2007_SP1) &&
267        !(this.getService().getExchange2007CompatibilityMode())) {
268      if (this.getPropertyBag().isPropertyUpdated(AppointmentSchema.Start) ||
269          this.getPropertyBag().isPropertyUpdated(AppointmentSchema.End) ||
270          this.getPropertyBag().isPropertyUpdated(AppointmentSchema.IsAllDayEvent) ||
271          this.getPropertyBag().isPropertyUpdated(AppointmentSchema.Recurrence)) {
272        //  If the property isn't in the property bag, throw....
273        if (!this.getPropertyBag().contains(AppointmentSchema.StartTimeZone)) {
274          throw new ServiceLocalException("StartTimeZone required when setting the Start, End, IsAllDayEvent, "
275                                          + "or Recurrence property.  You must load or assign this property "
276                                          + "before attempting to update the appointment.");
277          //getStartTimeZoneRequired());
278        }
279
280        //  Otherwise, set the time zone to its current value to
281        // force it to be sent with the request.
282        this.setStartTimeZone(this.getStartTimeZone());
283      }
284    }
285  }
286
287  /**
288   * Creates a reply response to the organizer and/or attendees of the
289   * meeting.
290   *
291   * @param replyAll the reply all
292   * @return A ResponseMessage representing the reply response that can
293   * subsequently be modified and sent.
294   * @throws Exception the exception
295   */
296  public ResponseMessage createReply(boolean replyAll) throws Exception {
297    this.throwIfThisIsNew();
298
299    return new ResponseMessage(this,
300        replyAll ? ResponseMessageType.ReplyAll :
301            ResponseMessageType.Reply);
302  }
303
304  /**
305   * Replies to the organizer and/or the attendees of the meeting. Calling
306   * this method results in a call to EWS.
307   *
308   * @param bodyPrefix the body prefix
309   * @param replyAll   the reply all
310   * @throws Exception the exception
311   */
312  public void reply(MessageBody bodyPrefix, boolean replyAll)
313      throws Exception {
314    ResponseMessage responseMessage = this.createReply(replyAll);
315
316    responseMessage.setBodyPrefix(bodyPrefix);
317    responseMessage.sendAndSaveCopy();
318  }
319
320  /**
321   * Creates a forward message from this appointment.
322   *
323   * @return A ResponseMessage representing the forward response that can
324   * subsequently be modified and sent.
325   * @throws Exception the exception
326   */
327  public ResponseMessage createForward() throws Exception {
328    this.throwIfThisIsNew();
329    return new ResponseMessage(this, ResponseMessageType.Forward);
330  }
331
332  /**
333   * Forwards the appointment. Calling this method results in a call to EWS.
334   *
335   * @param bodyPrefix   the body prefix
336   * @param toRecipients the to recipients
337   * @throws Exception the exception
338   */
339  public void forward(MessageBody bodyPrefix, EmailAddress... toRecipients)
340      throws Exception {
341    if (null != toRecipients) {
342      forward(bodyPrefix, Arrays.asList(toRecipients));
343    }
344  }
345
346  /**
347   * Forwards the appointment. Calling this method results in a call to EWS.
348   *
349   * @param bodyPrefix   the body prefix
350   * @param toRecipients the to recipients
351   * @throws Exception the exception
352   */
353  public void forward(MessageBody bodyPrefix,
354      Iterable<EmailAddress> toRecipients) throws Exception {
355    ResponseMessage responseMessage = this.createForward();
356
357    responseMessage.setBodyPrefix(bodyPrefix);
358    responseMessage.getToRecipients()
359        .addEmailRange(toRecipients.iterator());
360
361    responseMessage.sendAndSaveCopy();
362  }
363
364  /**
365   * Saves this appointment in the specified folder. Calling this method
366   * results in at least one call to EWS. Mutliple calls to EWS might be made
367   * if attachments have been added.
368   *
369   * @param destinationFolderName the destination folder name
370   * @param sendInvitationsMode   the send invitations mode
371   * @throws Exception the exception
372   */
373  public void save(WellKnownFolderName destinationFolderName,
374      SendInvitationsMode sendInvitationsMode) throws Exception {
375    this.internalCreate(new FolderId(destinationFolderName), null,
376        sendInvitationsMode);
377  }
378
379  /**
380   * Saves this appointment in the specified folder. Calling this method
381   * results in at least one call to EWS. Mutliple calls to EWS might be made
382   * if attachments have been added.
383   *
384   * @param destinationFolderId the destination folder id
385   * @param sendInvitationsMode the send invitations mode
386   * @throws Exception the exception
387   */
388  public void save(FolderId destinationFolderId,
389      SendInvitationsMode sendInvitationsMode) throws Exception {
390    EwsUtilities.validateParam(destinationFolderId, "destinationFolderId");
391
392    this.internalCreate(destinationFolderId, null, sendInvitationsMode);
393  }
394
395  /**
396   * Saves this appointment in the Calendar folder. Calling this method
397   * results in at least one call to EWS. Mutliple calls to EWS might be made
398   * if attachments have been added.
399   *
400   * @param sendInvitationsMode the send invitations mode
401   * @throws Exception the exception
402   */
403  public void save(SendInvitationsMode sendInvitationsMode) throws Exception {
404    this.internalCreate(null, null, sendInvitationsMode);
405  }
406
407  /**
408   * Applies the local changes that have been made to this appointment.
409   * Calling this method results in at least one call to EWS. Mutliple calls
410   * to EWS might be made if attachments have been added or removed.
411   *
412   * @param conflictResolutionMode             the conflict resolution mode
413   * @param sendInvitationsOrCancellationsMode the send invitations or cancellations mode
414   * @throws Exception the exception
415   */
416  public void update(
417      ConflictResolutionMode conflictResolutionMode,
418      SendInvitationsOrCancellationsMode
419          sendInvitationsOrCancellationsMode)
420      throws Exception {
421    this.internalUpdate(null, conflictResolutionMode, null,
422        sendInvitationsOrCancellationsMode);
423  }
424
425  /**
426   * Deletes this appointment. Calling this method results in a call to EWS.
427   *
428   * @param deleteMode            the delete mode
429   * @param sendCancellationsMode the send cancellations mode
430   * @throws Exception the exception
431   */
432  public void delete(DeleteMode deleteMode,
433      SendCancellationsMode sendCancellationsMode) throws Exception {
434    this.internalDelete(deleteMode, sendCancellationsMode, null);
435  }
436
437  /**
438   * Creates a local meeting acceptance message that can be customized and
439   * sent.
440   *
441   * @param tentative the tentative
442   * @return An AcceptMeetingInvitationMessage representing the meeting
443   * acceptance message.
444   * @throws Exception the exception
445   */
446  public AcceptMeetingInvitationMessage createAcceptMessage(boolean tentative)
447      throws Exception {
448    return new AcceptMeetingInvitationMessage(this, tentative);
449  }
450
451  /**
452   * Creates a local meeting acceptance message that can be customized and
453   * sent.
454   *
455   * @return A CancelMeetingMessage representing the meeting cancellation
456   * message.
457   * @throws Exception the exception
458   */
459  public CancelMeetingMessage createCancelMeetingMessage() throws Exception {
460    return new CancelMeetingMessage(this);
461  }
462
463  /**
464   * Creates a local meeting declination message that can be customized and
465   * sent.
466   *
467   * @return A DeclineMeetingInvitation representing the meeting declination
468   * message.
469   * @throws Exception the exception
470   */
471  public DeclineMeetingInvitationMessage createDeclineMessage()
472      throws Exception {
473    return new DeclineMeetingInvitationMessage(this);
474  }
475
476  /**
477   * Accepts the meeting. Calling this method results in a call to EWS.
478   *
479   * @param sendResponse the send response
480   * @return A CalendarActionResults object containing the various item that
481   * were created or modified as a results of this operation.
482   * @throws Exception the exception
483   */
484  public CalendarActionResults accept(boolean sendResponse) throws Exception {
485    return this.internalAccept(false, sendResponse);
486  }
487
488  /**
489   * Tentatively accepts the meeting. Calling this method results in a call to
490   * EWS.
491   *
492   * @param sendResponse the send response
493   * @return A CalendarActionResults object containing the various item that
494   * were created or modified as a results of this operation.
495   * @throws Exception the exception
496   */
497  public CalendarActionResults acceptTentatively(boolean sendResponse)
498      throws Exception {
499    return this.internalAccept(true, sendResponse);
500  }
501
502  /**
503   * Accepts the meeting.
504   *
505   * @param tentative    the tentative
506   * @param sendResponse the send response
507   * @return A CalendarActionResults object containing the various item that
508   * were created or modified as a results of this operation.
509   * @throws Exception the exception
510   */
511  protected CalendarActionResults internalAccept(boolean tentative,
512      boolean sendResponse) throws Exception {
513    AcceptMeetingInvitationMessage accept = this
514        .createAcceptMessage(tentative);
515
516    if (sendResponse) {
517      return accept.calendarSendAndSaveCopy();
518    } else {
519      return accept.calendarSave();
520    }
521  }
522
523  /**
524   * Cancels the meeting and sends cancellation messages to all attendees.
525   * Calling this method results in a call to EWS.
526   *
527   * @return A CalendarActionResults object containing the various item that
528   * were created or modified as a results of this operation.
529   * @throws Exception the exception
530   */
531  public CalendarActionResults cancelMeeting() throws Exception {
532    return this.createCancelMeetingMessage().calendarSendAndSaveCopy();
533  }
534
535  /**
536   * Cancels the meeting and sends cancellation messages to all attendees.
537   * Calling this method results in a call to EWS.
538   *
539   * @param cancellationMessageText the cancellation message text
540   * @return A CalendarActionResults object containing the various item that
541   * were created or modified as a results of this operation.
542   * @throws Exception the exception
543   */
544  public CalendarActionResults cancelMeeting(String cancellationMessageText)
545      throws Exception {
546    CancelMeetingMessage cancelMsg = this.createCancelMeetingMessage();
547    cancelMsg.setBody(new MessageBody(cancellationMessageText));
548    return cancelMsg.calendarSendAndSaveCopy();
549  }
550
551  /**
552   * Declines the meeting invitation. Calling this method results in a call to
553   * EWS.
554   *
555   * @param sendResponse the send response
556   * @return A CalendarActionResults object containing the various item that
557   * were created or modified as a results of this operation.
558   * @throws Exception the exception
559   */
560  public CalendarActionResults decline(boolean
561      sendResponse) throws Exception {
562    DeclineMeetingInvitationMessage decline = this.createDeclineMessage();
563
564    if (sendResponse) {
565      return decline.calendarSendAndSaveCopy();
566    } else {
567      return decline.calendarSave();
568    }
569  }
570
571  /**
572   * Gets the default setting for sending cancellations on Delete.
573   *
574   * @return If Delete() is called on Appointment, we want to send
575   * cancellations and save a copy.
576   */
577  @Override
578  protected SendCancellationsMode getDefaultSendCancellationsMode() {
579    return SendCancellationsMode.SendToAllAndSaveCopy;
580  }
581
582  /**
583   * Gets the default settings for sending invitations on Save.
584   *
585   * @return the default send invitations mode
586   */
587  @Override
588  protected SendInvitationsMode getDefaultSendInvitationsMode() {
589    return SendInvitationsMode.SendToAllAndSaveCopy;
590  }
591
592  /**
593   * Gets the default settings for sending invitations on Save.
594   *
595   * @return the default send invitations or cancellations mode
596   */
597  @Override
598  protected SendInvitationsOrCancellationsMode
599  getDefaultSendInvitationsOrCancellationsMode() {
600    return SendInvitationsOrCancellationsMode.SendToAllAndSaveCopy;
601  }
602
603  // Properties
604
605  /**
606   * Gets the start time of the appointment.
607   *
608   * @return the start
609   * @throws ServiceLocalException the service local exception
610   */
611  public Date getStart() throws ServiceLocalException {
612    return getPropertyBag().getObjectFromPropertyDefinition(
613        AppointmentSchema.Start);
614  }
615
616  /**
617   * Sets the start.
618   *
619   * @param value the new start
620   * @throws Exception the exception
621   */
622  public void setStart(Date value) throws Exception {
623    this.getPropertyBag().setObjectFromPropertyDefinition(
624        AppointmentSchema.Start, value);
625  }
626
627  /**
628   * Gets or sets the end time of the appointment.
629   *
630   * @return the end
631   * @throws ServiceLocalException the service local exception
632   */
633  public Date getEnd() throws ServiceLocalException {
634    return getPropertyBag().getObjectFromPropertyDefinition(
635        AppointmentSchema.End);
636  }
637
638  /**
639   * Sets the end.
640   *
641   * @param value the new end
642   * @throws Exception the exception
643   */
644  public void setEnd(Date value) throws Exception {
645    this.getPropertyBag().setObjectFromPropertyDefinition(
646        AppointmentSchema.End, value);
647  }
648
649  /**
650   * Gets the original start time of this appointment.
651   *
652   * @return the original start
653   * @throws ServiceLocalException the service local exception
654   */
655  public Date getOriginalStart() throws ServiceLocalException {
656    return getPropertyBag().getObjectFromPropertyDefinition(
657        AppointmentSchema.OriginalStart);
658  }
659
660  /**
661   * Gets a value indicating whether this appointment is an all day
662   * event.
663   *
664   * @return the checks if is all day event
665   * @throws ServiceLocalException the service local exception
666   */
667  public Boolean getIsAllDayEvent() throws ServiceLocalException {
668    return getPropertyBag().getObjectFromPropertyDefinition(
669        AppointmentSchema.IsAllDayEvent);
670  }
671
672  /**
673   * Sets the checks if is all day event.
674   *
675   * @param value the new checks if is all day event
676   * @throws Exception the exception
677   */
678  public void setIsAllDayEvent(Boolean value) throws Exception {
679    this.getPropertyBag().setObjectFromPropertyDefinition(
680        AppointmentSchema.IsAllDayEvent, value);
681  }
682
683  /**
684   * Gets  a value indicating the free/busy status of the owner of this
685   * appointment.
686   *
687   * @return the legacy free busy status
688   * @throws ServiceLocalException the service local exception
689   */
690  public LegacyFreeBusyStatus getLegacyFreeBusyStatus()
691      throws ServiceLocalException {
692    return getPropertyBag().getObjectFromPropertyDefinition(
693        AppointmentSchema.LegacyFreeBusyStatus);
694  }
695
696  /**
697   * Sets the legacy free busy status.
698   *
699   * @param value the new legacy free busy status
700   * @throws Exception the exception
701   */
702  public void setLegacyFreeBusyStatus(LegacyFreeBusyStatus value)
703      throws Exception {
704    this.getPropertyBag().setObjectFromPropertyDefinition(
705        AppointmentSchema.LegacyFreeBusyStatus, value);
706  }
707
708  /**
709   * Gets  the location of this appointment.
710   *
711   * @return the location
712   * @throws ServiceLocalException the service local exception
713   */
714  public String getLocation() throws ServiceLocalException {
715    return getPropertyBag().getObjectFromPropertyDefinition(
716        AppointmentSchema.Location);
717  }
718
719  /**
720   * Sets the location.
721   *
722   * @param value the new location
723   * @throws Exception the exception
724   */
725  public void setLocation(String value) throws Exception {
726    this.getPropertyBag().setObjectFromPropertyDefinition(
727        AppointmentSchema.Location, value);
728  }
729
730  /**
731   * Gets a text indicating when this appointment occurs. The text returned by
732   * When is localized using the Exchange Server culture or using the culture
733   * specified in the PreferredCulture property of the ExchangeService object
734   * this appointment is bound to.
735   *
736   * @return the when
737   * @throws ServiceLocalException the service local exception
738   */
739  public String getWhen() throws ServiceLocalException {
740    return getPropertyBag().getObjectFromPropertyDefinition(
741        AppointmentSchema.When);
742  }
743
744  /**
745   * Gets a value indicating whether the appointment is a meeting.
746   *
747   * @return the checks if is meeting
748   * @throws ServiceLocalException the service local exception
749   */
750  public Boolean getIsMeeting() throws ServiceLocalException {
751    return getPropertyBag().getObjectFromPropertyDefinition(
752        AppointmentSchema.IsMeeting);
753  }
754
755  /**
756   * Gets a value indicating whether the appointment has been cancelled.
757   *
758   * @return the checks if is cancelled
759   * @throws ServiceLocalException the service local exception
760   */
761  public Boolean getIsCancelled() throws ServiceLocalException {
762    return getPropertyBag().getObjectFromPropertyDefinition(
763        AppointmentSchema.IsCancelled);
764  }
765
766  /**
767   * Gets a value indicating whether the appointment is recurring.
768   *
769   * @return the checks if is recurring
770   * @throws ServiceLocalException the service local exception
771   */
772  public Boolean getIsRecurring() throws ServiceLocalException {
773    return getPropertyBag().getObjectFromPropertyDefinition(
774        AppointmentSchema.IsRecurring);
775  }
776
777  /**
778   * Gets a value indicating whether the appointment is recurring.
779   *
780   * @return the checks if is recurring
781   * @throws ServiceLocalException the service local exception
782   */
783  public Boolean getIsOrganizer() throws ServiceLocalException {
784    return getPropertyBag().getObjectFromPropertyDefinition(
785        AppointmentSchema.IsOrganizer);
786  }
787
788  /**
789   * Gets a value indicating whether the meeting request has already been
790   * sent.
791   *
792   * @return the meeting request was sent
793   * @throws ServiceLocalException the service local exception
794   */
795  public Boolean getMeetingRequestWasSent() throws ServiceLocalException {
796    return getPropertyBag().getObjectFromPropertyDefinition(
797        AppointmentSchema.MeetingRequestWasSent);
798  }
799
800  /**
801   * Gets  a value indicating whether response are requested when
802   * invitations are sent for this meeting.
803   *
804   * @return the checks if is response requested
805   * @throws ServiceLocalException the service local exception
806   */
807  public Boolean getIsResponseRequested() throws ServiceLocalException {
808    return getPropertyBag().getObjectFromPropertyDefinition(
809        AppointmentSchema.IsResponseRequested);
810  }
811
812  /**
813   * Sets the checks if is response requested.
814   *
815   * @param value the new checks if is response requested
816   * @throws Exception the exception
817   */
818  public void setIsResponseRequested(Boolean value) throws Exception {
819    this.getPropertyBag().setObjectFromPropertyDefinition(
820        AppointmentSchema.IsResponseRequested, value);
821  }
822
823  /**
824   * Gets a value indicating the type of this appointment.
825   *
826   * @return the appointment type
827   * @throws ServiceLocalException the service local exception
828   */
829  public AppointmentType getAppointmentType() throws ServiceLocalException {
830    return getPropertyBag().getObjectFromPropertyDefinition(
831        AppointmentSchema.AppointmentType);
832  }
833
834  /**
835   * Gets a value indicating what was the last response of the user that
836   * loaded this meeting.
837   *
838   * @param value the my response type
839   * @throws Exception 
840   */
841  public void setMyResponseType(MeetingResponseType value)
842      throws Exception {
843    this.getPropertyBag().setObjectFromPropertyDefinition(
844        AppointmentSchema.MyResponseType, value);
845  }
846
847  /**
848   * Gets a value indicating what was the last response of the user that
849   * loaded this meeting.
850   *
851   * @return the my response type
852   * @throws ServiceLocalException the service local exception
853   */
854  public MeetingResponseType getMyResponseType()
855      throws ServiceLocalException {
856    return getPropertyBag().getObjectFromPropertyDefinition(
857        AppointmentSchema.MyResponseType);
858  }
859
860  /**
861   * Gets the organizer of this meeting. The Organizer property is read-only
862   * and is only relevant for attendees. The organizer of a meeting is
863   * automatically set to the user that created the meeting.
864   *
865   * @return the organizer
866   * @throws ServiceLocalException the service local exception
867   */
868  public EmailAddress getOrganizer() throws ServiceLocalException {
869    return getPropertyBag().getObjectFromPropertyDefinition(
870        AppointmentSchema.Organizer);
871  }
872
873  /**
874   * Gets a list of required attendees for this meeting.
875   *
876   * @return the required attendees
877   * @throws ServiceLocalException the service local exception
878   */
879  public AttendeeCollection getRequiredAttendees()
880      throws ServiceLocalException {
881    return getPropertyBag().getObjectFromPropertyDefinition(
882        AppointmentSchema.RequiredAttendees);
883  }
884
885  /**
886   * Gets a list of optional attendeed for this meeting.
887   *
888   * @return the optional attendees
889   * @throws ServiceLocalException the service local exception
890   */
891  public AttendeeCollection getOptionalAttendees()
892      throws ServiceLocalException {
893    return getPropertyBag().getObjectFromPropertyDefinition(
894        AppointmentSchema.OptionalAttendees);
895  }
896
897  /**
898   * Gets a list of resources for this meeting.
899   *
900   * @return the resources
901   * @throws ServiceLocalException the service local exception
902   */
903  public AttendeeCollection getResources() throws ServiceLocalException {
904    return getPropertyBag().getObjectFromPropertyDefinition(
905        AppointmentSchema.Resources);
906  }
907
908  /**
909   * Gets the number of calendar entries that conflict with this appointment
910   * in the authenticated user's calendar.
911   *
912   * @return the conflicting meeting count
913   * @throws ServiceLocalException the service local exception
914   */
915  public Integer getConflictingMeetingCount() throws ServiceLocalException {
916    return getPropertyBag().getObjectFromPropertyDefinition(
917        AppointmentSchema.ConflictingMeetingCount);
918  }
919
920  /**
921   * Gets the number of calendar entries that are adjacent to this appointment
922   * in the authenticated user's calendar.
923   *
924   * @return the adjacent meeting count
925   * @throws ServiceLocalException the service local exception
926   */
927  public Integer getAdjacentMeetingCount() throws ServiceLocalException {
928    return getPropertyBag().getObjectFromPropertyDefinition(
929        AppointmentSchema.AdjacentMeetingCount);
930  }
931
932  /**
933   * Gets a list of meetings that conflict with this appointment in the
934   * authenticated user's calendar.
935   *
936   * @return the conflicting meetings
937   * @throws ServiceLocalException the service local exception
938   */
939  public ItemCollection<Appointment> getConflictingMeetings()
940      throws ServiceLocalException {
941    return getPropertyBag().getObjectFromPropertyDefinition(
942        AppointmentSchema.ConflictingMeetings);
943  }
944
945  /**
946   * Gets a list of meetings that conflict with this appointment in the
947   * authenticated user's calendar.
948   *
949   * @return the adjacent meetings
950   * @throws ServiceLocalException the service local exception
951   */
952  public ItemCollection<Appointment> getAdjacentMeetings()
953      throws ServiceLocalException {
954    return getPropertyBag().getObjectFromPropertyDefinition(
955            AppointmentSchema.AdjacentMeetings);
956  }
957
958  /**
959   * Gets the duration of this appointment.
960   *
961   * @return the duration
962   * @throws ServiceLocalException the service local exception
963   */
964  public TimeSpan getDuration() throws ServiceLocalException {
965    return getPropertyBag().getObjectFromPropertyDefinition(
966        AppointmentSchema.Duration);
967  }
968
969  /**
970   * Gets the name of the time zone this appointment is defined in.
971   *
972   * @return the time zone
973   * @throws ServiceLocalException the service local exception
974   */
975  public String getTimeZone() throws ServiceLocalException {
976    return getPropertyBag().getObjectFromPropertyDefinition(
977        AppointmentSchema.TimeZone);
978  }
979
980  /**
981   * Gets the time when the attendee replied to the meeting request.
982   *
983   * @return the appointment reply time
984   * @throws ServiceLocalException the service local exception
985   */
986  public Date getAppointmentReplyTime() throws ServiceLocalException {
987    return getPropertyBag().getObjectFromPropertyDefinition(
988        AppointmentSchema.AppointmentReplyTime);
989  }
990
991  /**
992   * Gets the sequence number of this appointment.
993   *
994   * @return the appointment sequence number
995   * @throws ServiceLocalException the service local exception
996   */
997  public Integer getAppointmentSequenceNumber() throws ServiceLocalException {
998    return getPropertyBag().getObjectFromPropertyDefinition(
999        AppointmentSchema.AppointmentSequenceNumber);
1000  }
1001
1002  /**
1003   * Gets the state of this appointment.
1004   *
1005   * @return the appointment state
1006   * @throws ServiceLocalException the service local exception
1007   */
1008  public Integer getAppointmentState() throws ServiceLocalException {
1009    return getPropertyBag().getObjectFromPropertyDefinition(
1010        AppointmentSchema.AppointmentState);
1011  }
1012
1013  /**
1014   * Gets the recurrence pattern for this appointment. Available
1015   * recurrence pattern classes include Recurrence.DailyPattern,
1016   * Recurrence.MonthlyPattern and Recurrence.YearlyPattern.
1017   *
1018   * @return the recurrence
1019   * @throws ServiceLocalException the service local exception
1020   */
1021  public Recurrence getRecurrence() throws ServiceLocalException {
1022    return getPropertyBag().getObjectFromPropertyDefinition(
1023        AppointmentSchema.Recurrence);
1024  }
1025
1026  /**
1027   * Sets the recurrence.
1028   *
1029   * @param value the new recurrence
1030   * @throws Exception the exception
1031   */
1032  public void setRecurrence(Recurrence value) throws Exception {
1033    if (value != null) {
1034      if (value.isRegenerationPattern()) {
1035        throw new ServiceLocalException("Regeneration pattern can only be used with Task item.");
1036      }
1037    }
1038    this.getPropertyBag().setObjectFromPropertyDefinition(
1039        AppointmentSchema.Recurrence, value);
1040  }
1041
1042  /**
1043   * Gets an OccurrenceInfo identifying the first occurrence of this meeting.
1044   *
1045   * @return the first occurrence
1046   * @throws ServiceLocalException the service local exception
1047   */
1048  public OccurrenceInfo getFirstOccurrence() throws ServiceLocalException {
1049    return getPropertyBag().getObjectFromPropertyDefinition(
1050          AppointmentSchema.FirstOccurrence);
1051  }
1052
1053  /**
1054   * Gets an OccurrenceInfo identifying the first occurrence of this meeting.
1055   *
1056   * @return the last occurrence
1057   * @throws ServiceLocalException the service local exception
1058   */
1059  public OccurrenceInfo getLastOccurrence() throws ServiceLocalException {
1060    return getPropertyBag().getObjectFromPropertyDefinition(
1061          AppointmentSchema.LastOccurrence);
1062  }
1063
1064  /**
1065   * Gets a list of modified occurrences for this meeting.
1066   *
1067   * @return the modified occurrences
1068   * @throws ServiceLocalException the service local exception
1069   */
1070  public OccurrenceInfoCollection getModifiedOccurrences()
1071      throws ServiceLocalException {
1072    return getPropertyBag().getObjectFromPropertyDefinition(
1073          AppointmentSchema.ModifiedOccurrences);
1074  }
1075
1076  /**
1077   * Gets a list of deleted occurrences for this meeting.
1078   *
1079   * @return the deleted occurrences
1080   * @throws ServiceLocalException the service local exception
1081   */
1082  public DeletedOccurrenceInfoCollection getDeletedOccurrences()
1083      throws ServiceLocalException {
1084    return getPropertyBag().getObjectFromPropertyDefinition(
1085          AppointmentSchema.DeletedOccurrences);
1086  }
1087
1088  /**
1089   * Gets the start time zone.
1090   *
1091   * @return the start time zone
1092   * @throws ServiceLocalException the service local exception
1093   */
1094  public TimeZoneDefinition getStartTimeZone() throws ServiceLocalException {
1095    return getPropertyBag().getObjectFromPropertyDefinition(
1096          AppointmentSchema.StartTimeZone);
1097  }
1098
1099  /**
1100   * Sets the start time zone.
1101   *
1102   * @param value the new start time zone
1103   * @throws Exception the exception
1104   */
1105  public void setStartTimeZone(TimeZoneDefinition value) throws Exception {
1106    this.getPropertyBag().setObjectFromPropertyDefinition(
1107        AppointmentSchema.StartTimeZone, value);
1108
1109  }
1110
1111  /**
1112   * Gets the start time zone.
1113   *
1114   * @return the start time zone
1115   * @throws ServiceLocalException the service local exception
1116   */
1117  public TimeZoneDefinition getEndTimeZone() throws ServiceLocalException {
1118    return getPropertyBag()
1119        .getObjectFromPropertyDefinition(AppointmentSchema.EndTimeZone);
1120  }
1121
1122  /**
1123   * Sets the start time zone.
1124   *
1125   * @param value the new end time zone
1126   * @throws Exception the exception
1127   */
1128  public void setEndTimeZone(TimeZoneDefinition value) throws Exception {
1129    this.getPropertyBag().setObjectFromPropertyDefinition(
1130        AppointmentSchema.EndTimeZone, value);
1131
1132  }
1133
1134  /**
1135   * Gets  the type of conferencing that will be used during the
1136   * meeting.
1137   *
1138   * @return the conference type
1139   * @throws ServiceLocalException the service local exception
1140   */
1141  public Integer getConferenceType() throws ServiceLocalException {
1142    return getPropertyBag().getObjectFromPropertyDefinition(
1143        AppointmentSchema.ConferenceType);
1144  }
1145
1146  /**
1147   * Sets the conference type.
1148   *
1149   * @param value the new conference type
1150   * @throws Exception the exception
1151   */
1152  public void setConferenceType(Integer value) throws Exception {
1153    this.getPropertyBag().setObjectFromPropertyDefinition(
1154        AppointmentSchema.ConferenceType, value);
1155  }
1156
1157  /**
1158   * Gets a value indicating whether new time proposals are allowed
1159   * for attendees of this meeting.
1160   *
1161   * @return the allow new time proposal
1162   * @throws ServiceLocalException the service local exception
1163   */
1164  public Boolean getAllowNewTimeProposal() throws ServiceLocalException {
1165    return getPropertyBag().getObjectFromPropertyDefinition(
1166        AppointmentSchema.AllowNewTimeProposal);
1167  }
1168
1169  /**
1170   * Sets the allow new time proposal.
1171   *
1172   * @param value the new allow new time proposal
1173   * @throws Exception the exception
1174   */
1175  public void setAllowNewTimeProposal(Boolean value) throws Exception {
1176    this.getPropertyBag().setObjectFromPropertyDefinition(
1177        AppointmentSchema.AllowNewTimeProposal, value);
1178  }
1179
1180  /**
1181   * Gets  a value indicating whether this is an online meeting.
1182   *
1183   * @return the checks if is online meeting
1184   * @throws ServiceLocalException the service local exception
1185   */
1186  public Boolean getIsOnlineMeeting() throws ServiceLocalException {
1187    return getPropertyBag().getObjectFromPropertyDefinition(
1188        AppointmentSchema.IsOnlineMeeting);
1189  }
1190
1191  /**
1192   * Sets the checks if is online meeting.
1193   *
1194   * @param value the new checks if is online meeting
1195   * @throws Exception the exception
1196   */
1197  public void setIsOnlineMeeting(Boolean value) throws Exception {
1198    this.getPropertyBag().setObjectFromPropertyDefinition(
1199        AppointmentSchema.IsOnlineMeeting, value);
1200  }
1201
1202  /**
1203   * Gets  the URL of the meeting workspace. A meeting workspace is a
1204   * shared Web site for planning meetings and tracking results.
1205   *
1206   * @return the meeting workspace url
1207   * @throws ServiceLocalException the service local exception
1208   */
1209  public String getMeetingWorkspaceUrl() throws ServiceLocalException {
1210    return getPropertyBag().getObjectFromPropertyDefinition(
1211        AppointmentSchema.MeetingWorkspaceUrl);
1212  }
1213
1214  /**
1215   * Sets the meeting workspace url.
1216   *
1217   * @param value the new meeting workspace url
1218   * @throws Exception the exception
1219   */
1220  public void setMeetingWorkspaceUrl(String value) throws Exception {
1221    this.getPropertyBag().setObjectFromPropertyDefinition(
1222        AppointmentSchema.MeetingWorkspaceUrl, value);
1223  }
1224
1225  /**
1226   * Gets the URL of the Microsoft NetShow online meeting.
1227   *
1228   * @return the net show url
1229   * @throws ServiceLocalException the service local exception
1230   */
1231  public String getNetShowUrl() throws ServiceLocalException {
1232    return getPropertyBag().getObjectFromPropertyDefinition(
1233        AppointmentSchema.NetShowUrl);
1234  }
1235
1236  /**
1237   * Sets the net show url.
1238   *
1239   * @param value the new net show url
1240   * @throws Exception the exception
1241   */
1242  public void setNetShowUrl(String value) throws Exception {
1243    this.getPropertyBag().setObjectFromPropertyDefinition(
1244        AppointmentSchema.NetShowUrl, value);
1245  }
1246
1247  /**
1248   * Gets the ICalendar Uid.
1249   *
1250   * @return the i cal uid
1251   * @throws ServiceLocalException the service local exception
1252   */
1253  public String getICalUid() throws ServiceLocalException {
1254    return getPropertyBag().getObjectFromPropertyDefinition(
1255        AppointmentSchema.ICalUid);
1256  }
1257
1258  /**
1259   * Sets the ICalendar Uid.
1260   *
1261   * @param value the i cal uid
1262   * @throws Exception
1263   *///this.PropertyBag[AppointmentSchema.ICalUid] = value;
1264  public void setICalUid(String value) throws Exception {
1265    this.getPropertyBag().setObjectFromPropertyDefinition(
1266        AppointmentSchema.ICalUid, value);
1267  }
1268
1269  /**
1270   * Gets the ICalendar RecurrenceId.
1271   *
1272   * @return the i cal recurrence id
1273   * @throws ServiceLocalException the service local exception
1274   */
1275  public Date getICalRecurrenceId() throws ServiceLocalException {
1276    return getPropertyBag().getObjectFromPropertyDefinition(
1277        AppointmentSchema.ICalRecurrenceId);
1278  }
1279
1280  /**
1281   * Gets the ICalendar DateTimeStamp.
1282   *
1283   * @return the i cal date time stamp
1284   * @throws ServiceLocalException the service local exception
1285   */
1286  public Date getICalDateTimeStamp() throws ServiceLocalException {
1287    return getPropertyBag().getObjectFromPropertyDefinition(
1288        AppointmentSchema.ICalDateTimeStamp);
1289  }
1290}