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.ServiceObject;
033import microsoft.exchange.webservices.data.core.service.schema.ItemSchema;
034import microsoft.exchange.webservices.data.core.service.schema.ServiceObjectSchema;
035import microsoft.exchange.webservices.data.core.enumeration.service.calendar.AffectedTaskOccurrence;
036import microsoft.exchange.webservices.data.core.enumeration.service.ConflictResolutionMode;
037import microsoft.exchange.webservices.data.core.enumeration.service.DeleteMode;
038import microsoft.exchange.webservices.data.core.enumeration.service.EffectiveRights;
039import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion;
040import microsoft.exchange.webservices.data.core.enumeration.property.Importance;
041import microsoft.exchange.webservices.data.core.enumeration.service.MessageDisposition;
042import microsoft.exchange.webservices.data.core.enumeration.service.ResponseActions;
043import microsoft.exchange.webservices.data.core.enumeration.service.SendCancellationsMode;
044import microsoft.exchange.webservices.data.core.enumeration.service.SendInvitationsMode;
045import microsoft.exchange.webservices.data.core.enumeration.service.SendInvitationsOrCancellationsMode;
046import microsoft.exchange.webservices.data.core.enumeration.property.Sensitivity;
047import microsoft.exchange.webservices.data.core.enumeration.service.error.ServiceErrorHandling;
048import microsoft.exchange.webservices.data.core.enumeration.property.WellKnownFolderName;
049import microsoft.exchange.webservices.data.core.exception.misc.InvalidOperationException;
050import microsoft.exchange.webservices.data.core.exception.service.local.ServiceLocalException;
051import microsoft.exchange.webservices.data.core.exception.service.remote.ServiceResponseException;
052import microsoft.exchange.webservices.data.property.complex.Attachment;
053import microsoft.exchange.webservices.data.property.complex.AttachmentCollection;
054import microsoft.exchange.webservices.data.property.complex.ConversationId;
055import microsoft.exchange.webservices.data.property.complex.ExtendedPropertyCollection;
056import microsoft.exchange.webservices.data.property.complex.FolderId;
057import microsoft.exchange.webservices.data.property.complex.InternetMessageHeaderCollection;
058import microsoft.exchange.webservices.data.property.complex.ItemAttachment;
059import microsoft.exchange.webservices.data.property.complex.ItemId;
060import microsoft.exchange.webservices.data.property.complex.MessageBody;
061import microsoft.exchange.webservices.data.property.complex.MimeContent;
062import microsoft.exchange.webservices.data.property.complex.StringList;
063import microsoft.exchange.webservices.data.property.complex.UniqueBody;
064import microsoft.exchange.webservices.data.property.definition.ExtendedPropertyDefinition;
065import microsoft.exchange.webservices.data.property.definition.PropertyDefinition;
066
067import java.util.ArrayList;
068import java.util.Date;
069import java.util.EnumSet;
070import java.util.ListIterator;
071
072/**
073 * Represents a generic item. Properties available on item are defined in the
074 * ItemSchema class.
075 */
076@Attachable
077@ServiceObjectDefinition(xmlElementName = XmlElementNames.Item)
078public class Item extends ServiceObject {
079
080  /**
081   * The parent attachment.
082   */
083  private ItemAttachment parentAttachment;
084
085  /**
086   * Initializes an unsaved local instance of {@link Item}. To bind to
087   * an existing item, use {@link Item#bind(ExchangeService, ItemId)} instead.
088   *
089   * @param service the service
090   * @throws Exception the exception
091   */
092  public Item(ExchangeService service) throws Exception {
093    super(service);
094  }
095
096  public Item(ExchangeService service, ItemId itemId) throws Exception {
097    super(service, itemId);
098  }
099
100  /**
101   * Initializes a new instance of the item class.
102   *
103   * @param parentAttachment The parent attachment.
104   * @throws Exception the exception
105   */
106  public Item(final ItemAttachment parentAttachment) throws Exception {
107    this(parentAttachment.getOwner().getService());
108    this.parentAttachment = parentAttachment;
109  }
110
111  /**
112   * Binds to an existing item, whatever its actual type is, and loads the
113   * specified set of property. Calling this method results in a call to
114   * EWS.
115   *
116   * @param service     The service to use to bind to the item.
117   * @param id          The Id of the item to bind to.
118   * @param propertySet The set of property to load.
119   * @return An Item instance representing the item corresponding to the
120   * specified Id.
121   * @throws Exception the exception
122   */
123  public static Item bind(ExchangeService service, ItemId id,
124      PropertySet propertySet) throws Exception {
125    return service.bindToItem(Item.class, id, propertySet);
126  }
127
128  /**
129   * Binds to an existing item, whatever its actual type is, and loads the
130   * specified set of property. Calling this method results in a call to
131   * EWS.
132   *
133   * @param service The service to use to bind to the item.
134   * @param id      The Id of the item to bind to.
135   * @return An Item instance representing the item corresponding to the
136   * specified Id.
137   * @throws Exception the exception
138   */
139  public static Item bind(ExchangeService service, ItemId id)
140      throws Exception {
141    return Item.bind(service, id, PropertySet.getFirstClassProperties());
142  }
143
144  /**
145   * Internal method to return the schema associated with this type of object.
146   *
147   * @return The schema associated with this type of object.
148   */
149  @Override public ServiceObjectSchema getSchema() {
150    return ItemSchema.getInstance();
151  }
152
153  /**
154   * Gets the minimum required server version.
155   *
156   * @return Earliest Exchange version in which this service object type is
157   * supported.
158   */
159  @Override public ExchangeVersion getMinimumRequiredServerVersion() {
160
161    return ExchangeVersion.Exchange2007_SP1;
162  }
163
164  /**
165   * Throws exception if this is attachment.
166   *
167   * @throws InvalidOperationException the invalid operation exception
168   */
169  protected void throwIfThisIsAttachment() throws InvalidOperationException {
170    if (this.isAttachment()) {
171      throw new InvalidOperationException("This operation isn't supported on attachments.");
172    }
173  }
174
175  /**
176   * The property definition for the Id of this object.
177   *
178   * @return A PropertyDefinition instance.
179   */
180  @Override
181  public PropertyDefinition getIdPropertyDefinition() {
182    return ItemSchema.Id;
183  }
184
185  /**
186   * The property definition for the Id of this object.
187   *
188   * @param propertySet the property set
189   * @throws Exception the exception
190   */
191  @Override
192  protected void internalLoad(PropertySet propertySet) throws Exception {
193    this.throwIfThisIsNew();
194    this.throwIfThisIsAttachment();
195
196    ArrayList<Item> itemArry = new ArrayList<Item>();
197    itemArry.add(this);
198    this.getService().internalLoadPropertiesForItems(itemArry, propertySet,
199        ServiceErrorHandling.ThrowOnError);
200  }
201
202  /**
203   * Deletes the object.
204   *
205   * @param deleteMode              the delete mode
206   * @param sendCancellationsMode   the send cancellations mode
207   * @param affectedTaskOccurrences the affected task occurrences
208   * @throws ServiceLocalException the service local exception
209   * @throws Exception             the exception
210   */
211  @Override
212  protected void internalDelete(DeleteMode deleteMode,
213      SendCancellationsMode sendCancellationsMode,
214      AffectedTaskOccurrence affectedTaskOccurrences)
215      throws ServiceLocalException, Exception {
216    this.throwIfThisIsNew();
217    this.throwIfThisIsAttachment();
218
219    // If sendCancellationsMode is null, use the default value that's
220    // appropriate for item type.
221    if (sendCancellationsMode == null) {
222      sendCancellationsMode = this.getDefaultSendCancellationsMode();
223    }
224
225    // If affectedTaskOccurrences is null, use the default value that's
226    // appropriate for item type.
227    if (affectedTaskOccurrences == null) {
228      affectedTaskOccurrences = this.getDefaultAffectedTaskOccurrences();
229    }
230
231    this.getService().deleteItem(this.getId(), deleteMode,
232        sendCancellationsMode, affectedTaskOccurrences);
233  }
234
235  /**
236   * Create item.
237   *
238   * @param parentFolderId      the parent folder id
239   * @param messageDisposition  the message disposition
240   * @param sendInvitationsMode the send invitations mode
241   * @throws Exception the exception
242   */
243  protected void internalCreate(FolderId parentFolderId,
244      MessageDisposition messageDisposition,
245      SendInvitationsMode sendInvitationsMode) throws Exception {
246    this.throwIfThisIsNotNew();
247    this.throwIfThisIsAttachment();
248
249    if (this.isNew() || this.isDirty()) {
250      this.getService().createItem(
251          this,
252          parentFolderId,
253          messageDisposition,
254          sendInvitationsMode != null ? sendInvitationsMode : this
255              .getDefaultSendInvitationsMode());
256
257      this.getAttachments().save();
258    }
259  }
260
261  /**
262   * Update item.
263   *
264   * @param parentFolderId                     the parent folder id
265   * @param conflictResolutionMode             the conflict resolution mode
266   * @param messageDisposition                 the message disposition
267   * @param sendInvitationsOrCancellationsMode the send invitations or cancellations mode
268   * @return Updated item.
269   * @throws ServiceResponseException the service response exception
270   * @throws Exception                the exception
271   */
272  protected Item internalUpdate(
273      FolderId parentFolderId,
274      ConflictResolutionMode conflictResolutionMode,
275      MessageDisposition messageDisposition,
276      SendInvitationsOrCancellationsMode sendInvitationsOrCancellationsMode)
277      throws ServiceResponseException, Exception {
278    this.throwIfThisIsNew();
279    this.throwIfThisIsAttachment();
280
281    Item returnedItem = null;
282
283    if (this.isDirty() && this.getPropertyBag().getIsUpdateCallNecessary()) {
284      returnedItem = this
285          .getService()
286          .updateItem(
287              this,
288              parentFolderId,
289              conflictResolutionMode,
290              messageDisposition,
291              sendInvitationsOrCancellationsMode != null ? sendInvitationsOrCancellationsMode
292                  : this
293                  .getDefaultSendInvitationsOrCancellationsMode());
294    }
295    if (this.hasUnprocessedAttachmentChanges()) {
296      // Validation of the item and its attachments occurs in
297      // UpdateItems.
298      // If we didn't update the item we still need to validate
299      // attachments.
300      this.getAttachments().validate();
301      this.getAttachments().save();
302
303    }
304
305    return returnedItem;
306  }
307
308  /**
309   * Gets a value indicating whether this instance has unprocessed attachment
310   * collection changes.
311   *
312   * @throws ServiceLocalException
313   */
314  public boolean hasUnprocessedAttachmentChanges()
315      throws ServiceLocalException {
316    return this.getAttachments().hasUnprocessedChanges();
317
318  }
319
320  /**
321   * Gets the parent attachment of this item.
322   *
323   * @return the parent attachment
324   */
325  public ItemAttachment getParentAttachment() {
326    return this.parentAttachment;
327  }
328
329  /**
330   * Gets Id of the root item for this item.
331   *
332   * @return the root item id
333   * @throws ServiceLocalException the service local exception
334   */
335  public ItemId getRootItemId() throws ServiceLocalException {
336
337    if (this.isAttachment()) {
338      return this.getParentAttachment().getOwner().getRootItemId();
339    } else {
340      return this.getId();
341    }
342  }
343
344  /**
345   * Deletes the item. Calling this method results in a call to EWS.
346   *
347   * @param deleteMode the delete mode
348   * @throws ServiceLocalException the service local exception
349   * @throws Exception             the exception
350   */
351  public void delete(DeleteMode deleteMode) throws ServiceLocalException,
352      Exception {
353    this.internalDelete(deleteMode, null, null);
354  }
355
356  /**
357   * Saves this item in a specific folder. Calling this method results in at
358   * least one call to EWS. Mutliple calls to EWS might be made if attachments
359   * have been added.
360   *
361   * @param parentFolderId the parent folder id
362   * @throws Exception the exception
363   */
364  public void save(FolderId parentFolderId) throws Exception {
365    EwsUtilities.validateParam(parentFolderId, "parentFolderId");
366    this.internalCreate(parentFolderId, MessageDisposition.SaveOnly, null);
367  }
368
369  /**
370   * Saves this item in a specific folder. Calling this method results in at
371   * least one call to EWS. Mutliple calls to EWS might be made if attachments
372   * have been added.
373   *
374   * @param parentFolderName the parent folder name
375   * @throws Exception the exception
376   */
377  public void save(WellKnownFolderName parentFolderName) throws Exception {
378    this.internalCreate(new FolderId(parentFolderName),
379        MessageDisposition.SaveOnly, null);
380  }
381
382  /**
383   * Saves this item in the default folder based on the item's type (for
384   * example, an e-mail message is saved to the Drafts folder). Calling this
385   * method results in at least one call to EWS. Mutliple calls to EWS might
386   * be made if attachments have been added.
387   *
388   * @throws Exception the exception
389   */
390  public void save() throws Exception {
391    this.internalCreate(null, MessageDisposition.SaveOnly, null);
392  }
393
394  /**
395   * Applies the local changes that have been made to this item. Calling this
396   * method results in at least one call to EWS. Mutliple calls to EWS might
397   * be made if attachments have been added or removed.
398   *
399   * @param conflictResolutionMode the conflict resolution mode
400   * @throws ServiceResponseException the service response exception
401   * @throws Exception                the exception
402   */
403  public void update(ConflictResolutionMode conflictResolutionMode)
404      throws ServiceResponseException, Exception {
405    this.internalUpdate(null /* parentFolder */, conflictResolutionMode,
406        MessageDisposition.SaveOnly, null);
407  }
408
409  /**
410   * Creates a copy of this item in the specified folder. Calling this method
411   * results in a call to EWS. Copy returns null if the copy operation is
412   * across two mailboxes or between a mailbox and a public folder.
413   *
414   * @param destinationFolderId the destination folder id
415   * @return The copy of this item.
416   * @throws Exception the exception
417   */
418  public Item copy(FolderId destinationFolderId) throws Exception {
419
420    this.throwIfThisIsNew();
421    this.throwIfThisIsAttachment();
422
423    EwsUtilities.validateParam(destinationFolderId, "destinationFolderId");
424
425    return this.getService().copyItem(this.getId(), destinationFolderId);
426  }
427
428  /**
429   * Creates a copy of this item in the specified folder. Calling this method
430   * results in a call to EWS. Copy returns null if the copy operation is
431   * across two mailboxes or between a mailbox and a public folder.
432   *
433   * @param destinationFolderName the destination folder name
434   * @return The copy of this item.
435   * @throws Exception the exception
436   */
437  public Item copy(WellKnownFolderName destinationFolderName)
438      throws Exception {
439    return this.copy(new FolderId(destinationFolderName));
440  }
441
442  /**
443   * Moves this item to a the specified folder. Calling this method results in
444   * a call to EWS. Move returns null if the move operation is across two
445   * mailboxes or between a mailbox and a public folder.
446   *
447   * @param destinationFolderId the destination folder id
448   * @return The moved copy of this item.
449   * @throws Exception the exception
450   */
451  public Item move(FolderId destinationFolderId) throws Exception {
452    this.throwIfThisIsNew();
453    this.throwIfThisIsAttachment();
454
455    EwsUtilities.validateParam(destinationFolderId, "destinationFolderId");
456
457    return this.getService().moveItem(this.getId(), destinationFolderId);
458  }
459
460  /**
461   * Moves this item to a the specified folder. Calling this method results in
462   * a call to EWS. Move returns null if the move operation is across two
463   * mailboxes or between a mailbox and a public folder.
464   *
465   * @param destinationFolderName the destination folder name
466   * @return The moved copy of this item.
467   * @throws Exception the exception
468   */
469  public Item move(WellKnownFolderName destinationFolderName)
470      throws Exception {
471    return this.move(new FolderId(destinationFolderName));
472  }
473
474  /**
475   * Sets the extended property.
476   *
477   * @param extendedPropertyDefinition the extended property definition
478   * @param value                      the value
479   * @throws Exception the exception
480   */
481  public void setExtendedProperty(
482      ExtendedPropertyDefinition extendedPropertyDefinition, Object value)
483      throws Exception {
484    this.getExtendedProperties().setExtendedProperty(
485        extendedPropertyDefinition, value);
486  }
487
488  /**
489   * Removes an extended property.
490   *
491   * @param extendedPropertyDefinition the extended property definition
492   * @return True if property was removed.
493   * @throws Exception the exception
494   */
495  public boolean removeExtendedProperty(
496      ExtendedPropertyDefinition extendedPropertyDefinition)
497      throws Exception {
498    return this.getExtendedProperties().removeExtendedProperty(
499        extendedPropertyDefinition);
500  }
501
502  /**
503   * Validates this instance.
504   *
505   * @throws Exception the exception
506   */
507  @Override public void validate() throws Exception {
508    super.validate();
509    this.getAttachments().validate();
510  }
511
512  /**
513   * Gets a value indicating whether a time zone SOAP header should be emitted
514   * in a CreateItem or UpdateItem request so this item can be property saved
515   * or updated.
516   *
517   * @param isUpdateOperation Indicates whether the operation being petrformed is an update
518   *                          operation.
519   * @return true if a time zone SOAP header should be emitted;
520   * otherwise,false
521   */
522  @Override
523  public boolean getIsTimeZoneHeaderRequired(boolean isUpdateOperation)
524      throws Exception {
525    // Starting E14SP2, attachment will be sent along with CreateItem
526    // request.
527    // if the attachment used to require the Timezone header, CreateItem
528    // request should do so too.
529    //
530
531    if (!isUpdateOperation
532        && (this.getService().getRequestedServerVersion().ordinal() >= ExchangeVersion.Exchange2010_SP2
533        .ordinal())) {
534
535      ListIterator<Attachment> items = this.getAttachments().getItems()
536          .listIterator();
537
538      while (items.hasNext()) {
539
540        ItemAttachment itemAttachment = (ItemAttachment) items.next();
541
542        if ((itemAttachment.getItem() != null)
543            && itemAttachment
544            .getItem()
545            .getIsTimeZoneHeaderRequired(false /* isUpdateOperation */)) {
546          return true;
547        }
548      }
549    }
550
551                /*
552                 * for (ItemAttachment itemAttachment :
553                 * this.getAttachments().OfType<ItemAttachment>().getc) { if
554                 * ((itemAttachment.Item != null) &&
555                 * itemAttachment.Item.GetIsTimeZoneHeaderRequired(false /* //
556                 * isUpdateOperation )) { return true; } }
557                 */
558
559    return super.getIsTimeZoneHeaderRequired(isUpdateOperation);
560  }
561
562  // region Properties
563
564  /**
565   * Gets a value indicating whether the item is an attachment.
566   *
567   * @return true, if is attachment
568   */
569  public boolean isAttachment() {
570    return this.parentAttachment != null;
571  }
572
573  /**
574   * Gets a value indicating whether this object is a real store item, or if
575   * it's a local object that has yet to be saved.
576   *
577   * @return the checks if is new
578   * @throws ServiceLocalException the service local exception
579   */
580  public boolean getIsNew() throws ServiceLocalException {
581
582    // Item attachments don't have an Id, need to check whether the
583    // parentAttachment is new or not.
584    if (this.isAttachment()) {
585      return this.getParentAttachment().isNew();
586    } else {
587      return super.isNew();
588    }
589  }
590
591  /**
592   * Gets the Id of this item.
593   *
594   * @return the id
595   * @throws ServiceLocalException the service local exception
596   */
597  @Override
598  public ItemId getId() throws ServiceLocalException {
599    return getPropertyBag().getObjectFromPropertyDefinition(
600        getIdPropertyDefinition());
601  }
602
603  /**
604   * Get the MIME content of this item.
605   *
606   * @return the mime content
607   * @throws ServiceLocalException the service local exception
608   */
609  public MimeContent getMimeContent() throws ServiceLocalException {
610    return getPropertyBag().getObjectFromPropertyDefinition(
611        ItemSchema.MimeContent);
612  }
613
614  /**
615   * Sets the mime content.
616   *
617   * @param value the new mime content
618   * @throws Exception the exception
619   */
620  public void setMimeContent(MimeContent value) throws Exception {
621    this.getPropertyBag().setObjectFromPropertyDefinition(
622        ItemSchema.MimeContent, value);
623  }
624
625  /**
626   * Gets the Id of the parent folder of this item.
627   *
628   * @return the parent folder id
629   * @throws ServiceLocalException the service local exception
630   */
631  public FolderId getParentFolderId() throws ServiceLocalException {
632    return getPropertyBag().getObjectFromPropertyDefinition(
633        ItemSchema.ParentFolderId);
634  }
635
636  /**
637   * Gets the sensitivity of this item.
638   *
639   * @return the sensitivity
640   * @throws ServiceLocalException the service local exception
641   */
642  public Sensitivity getSensitivity() throws ServiceLocalException {
643    return getPropertyBag().getObjectFromPropertyDefinition(
644        ItemSchema.Sensitivity);
645  }
646
647  /**
648   * Sets the sensitivity.
649   *
650   * @param value the new sensitivity
651   * @throws Exception the exception
652   */
653  public void setSensitivity(Sensitivity value) throws Exception {
654    this.getPropertyBag().setObjectFromPropertyDefinition(
655        ItemSchema.Sensitivity, value);
656  }
657
658  /**
659   * Gets a list of the attachments to this item.
660   *
661   * @return the attachments
662   * @throws ServiceLocalException the service local exception
663   */
664  public AttachmentCollection getAttachments() throws ServiceLocalException {
665    return getPropertyBag().getObjectFromPropertyDefinition(
666        ItemSchema.Attachments);
667  }
668
669  /**
670   * Gets the time when this item was received.
671   *
672   * @return the date time received
673   * @throws ServiceLocalException the service local exception
674   */
675  public Date getDateTimeReceived() throws ServiceLocalException {
676    return getPropertyBag().getObjectFromPropertyDefinition(
677        ItemSchema.DateTimeReceived);
678  }
679
680  /**
681   * Gets the size of this item.
682   *
683   * @return the size
684   * @throws ServiceLocalException the service local exception
685   */
686  public int getSize() throws ServiceLocalException {
687    return getPropertyBag().<Integer>getObjectFromPropertyDefinition(ItemSchema.Size);
688  }
689
690  /**
691   * Gets the list of categories associated with this item.
692   *
693   * @return the categories
694   * @throws ServiceLocalException the service local exception
695   */
696  public StringList getCategories() throws ServiceLocalException {
697    return getPropertyBag().getObjectFromPropertyDefinition(
698        ItemSchema.Categories);
699  }
700
701  /**
702   * Sets the categories.
703   *
704   * @param value the new categories
705   * @throws Exception the exception
706   */
707  public void setCategories(StringList value) throws Exception {
708    this.getPropertyBag().setObjectFromPropertyDefinition(
709        ItemSchema.Categories, value);
710  }
711
712  /**
713   * Gets the culture associated with this item.
714   *
715   * @return the culture
716   * @throws ServiceLocalException the service local exception
717   */
718  public String getCulture() throws ServiceLocalException {
719    return getPropertyBag().getObjectFromPropertyDefinition(
720        ItemSchema.Culture);
721  }
722
723  /**
724   * Sets the culture.
725   *
726   * @param value the new culture
727   * @throws Exception the exception
728   */
729  public void setCulture(String value) throws Exception {
730    this.getPropertyBag().setObjectFromPropertyDefinition(
731        ItemSchema.Culture, value);
732  }
733
734  /**
735   * Gets the importance of this item.
736   *
737   * @return the importance
738   * @throws ServiceLocalException the service local exception
739   */
740  public Importance getImportance() throws ServiceLocalException {
741    return getPropertyBag().getObjectFromPropertyDefinition(
742        ItemSchema.Importance);
743  }
744
745  /**
746   * Sets the importance.
747   *
748   * @param value the new importance
749   * @throws Exception the exception
750   */
751  public void setImportance(Importance value) throws Exception {
752    this.getPropertyBag().setObjectFromPropertyDefinition(
753        ItemSchema.Importance, value);
754  }
755
756  /**
757   * Gets the In-Reply-To reference of this item.
758   *
759   * @return the in reply to
760   * @throws ServiceLocalException the service local exception
761   */
762  public String getInReplyTo() throws ServiceLocalException {
763    return getPropertyBag().getObjectFromPropertyDefinition(
764        ItemSchema.InReplyTo);
765  }
766
767  /**
768   * Sets the in reply to.
769   *
770   * @param value the new in reply to
771   * @throws Exception the exception
772   */
773  public void setInReplyTo(String value) throws Exception {
774    this.getPropertyBag().setObjectFromPropertyDefinition(
775        ItemSchema.InReplyTo, value);
776  }
777
778  /**
779   * Gets a value indicating whether the message has been submitted to be
780   * sent.
781   *
782   * @return the checks if is submitted
783   * @throws ServiceLocalException the service local exception
784   */
785  public boolean getIsSubmitted() throws ServiceLocalException {
786    return getPropertyBag().<Boolean>getObjectFromPropertyDefinition(ItemSchema.IsSubmitted);
787  }
788
789  /**
790   * Gets a value indicating whether the message has been submitted to be
791   * sent.
792   *
793   * @return the checks if is associated
794   * @throws ServiceLocalException the service local exception
795   */
796  public boolean getIsAssociated() throws ServiceLocalException {
797    return getPropertyBag().<Boolean>getObjectFromPropertyDefinition(
798        ItemSchema.IsAssociated);
799  }
800
801  /**
802   * Gets a value indicating whether the message has been submitted to be
803   * sent.
804   *
805   * @return the checks if is draft
806   * @throws ServiceLocalException the service local exception
807   */
808  public boolean getIsDraft() throws ServiceLocalException {
809    return getPropertyBag().<Boolean>getObjectFromPropertyDefinition(
810        ItemSchema.IsDraft);
811  }
812
813  /**
814   * Gets a value indicating whether the item has been sent by the current
815   * authenticated user.
816   *
817   * @return the checks if is from me
818   * @throws ServiceLocalException the service local exception
819   */
820  public boolean getIsFromMe() throws ServiceLocalException {
821    return getPropertyBag().<Boolean>getObjectFromPropertyDefinition(
822        ItemSchema.IsFromMe);
823  }
824
825  /**
826   * Gets a value indicating whether the item is a resend of another item.
827   *
828   * @return the checks if is resend
829   * @throws ServiceLocalException the service local exception
830   */
831  public boolean getIsResend() throws ServiceLocalException {
832    return getPropertyBag().<Boolean>getObjectFromPropertyDefinition(
833        ItemSchema.IsResend);
834  }
835
836  /**
837   * Gets a value indicating whether the item has been modified since it was
838   * created.
839   *
840   * @return the checks if is unmodified
841   * @throws ServiceLocalException the service local exception
842   */
843  public boolean getIsUnmodified() throws ServiceLocalException {
844    return getPropertyBag().<Boolean>getObjectFromPropertyDefinition(
845        ItemSchema.IsUnmodified);
846  }
847
848  /**
849   * Gets a list of Internet headers for this item.
850   *
851   * @return the internet message headers
852   * @throws ServiceLocalException the service local exception
853   */
854  public InternetMessageHeaderCollection getInternetMessageHeaders()
855      throws ServiceLocalException {
856    return getPropertyBag().getObjectFromPropertyDefinition(
857        ItemSchema.InternetMessageHeaders);
858  }
859
860  /**
861   * Gets the date and time this item was sent.
862   *
863   * @return the date time sent
864   * @throws ServiceLocalException the service local exception
865   */
866  public Date getDateTimeSent() throws ServiceLocalException {
867    return getPropertyBag().getObjectFromPropertyDefinition(
868        ItemSchema.DateTimeSent);
869  }
870
871  /**
872   * Gets the date and time this item was created.
873   *
874   * @return the date time created
875   * @throws ServiceLocalException the service local exception
876   */
877  public Date getDateTimeCreated() throws ServiceLocalException {
878    return getPropertyBag().getObjectFromPropertyDefinition(
879        ItemSchema.DateTimeCreated);
880  }
881
882  /**
883   * Gets a value indicating which response actions are allowed on this item.
884   * Examples of response actions are Reply and Forward.
885   *
886   * @return the allowed response actions
887   * @throws ServiceLocalException the service local exception
888   */
889  public EnumSet<ResponseActions> getAllowedResponseActions()
890      throws ServiceLocalException {
891    return getPropertyBag().getObjectFromPropertyDefinition(
892        ItemSchema.AllowedResponseActions);
893  }
894
895  /**
896   * Gets the date and time when the reminder is due for this item.
897   *
898   * @return the reminder due by
899   * @throws ServiceLocalException the service local exception
900   */
901  public Date getReminderDueBy() throws ServiceLocalException {
902    return getPropertyBag().getObjectFromPropertyDefinition(
903        ItemSchema.ReminderDueBy);
904  }
905
906  /**
907   * Sets the reminder due by.
908   *
909   * @param value the new reminder due by
910   * @throws Exception the exception
911   */
912  public void setReminderDueBy(Date value) throws Exception {
913    this.getPropertyBag().setObjectFromPropertyDefinition(
914        ItemSchema.ReminderDueBy, value);
915  }
916
917  /**
918   * Gets a value indicating whether a reminder is set for this item.
919   *
920   * @return the checks if is reminder set
921   * @throws ServiceLocalException the service local exception
922   */
923  public boolean getIsReminderSet() throws ServiceLocalException {
924    return getPropertyBag().<Boolean>getObjectFromPropertyDefinition(
925        ItemSchema.IsReminderSet);
926  }
927
928  /**
929   * Sets the checks if is reminder set.
930   *
931   * @param value the new checks if is reminder set
932   * @throws Exception the exception
933   */
934  public void setIsReminderSet(Boolean value) throws Exception {
935    this.getPropertyBag().setObjectFromPropertyDefinition(
936        ItemSchema.IsReminderSet, value);
937  }
938
939  /**
940   * Gets the number of minutes before the start of this item when the
941   * reminder should be triggered.
942   *
943   * @return the reminder minutes before start
944   * @throws ServiceLocalException the service local exception
945   */
946  public int getReminderMinutesBeforeStart() throws ServiceLocalException {
947    return getPropertyBag().<Integer>getObjectFromPropertyDefinition(
948        ItemSchema.ReminderMinutesBeforeStart);
949  }
950
951  /**
952   * Sets the reminder minutes before start.
953   *
954   * @param value the new reminder minutes before start
955   * @throws Exception the exception
956   */
957  public void setReminderMinutesBeforeStart(int value) throws Exception {
958    this.getPropertyBag().setObjectFromPropertyDefinition(
959        ItemSchema.ReminderMinutesBeforeStart, value);
960  }
961
962  /**
963   * Gets a text summarizing the Cc receipients of this item.
964   *
965   * @return the display cc
966   * @throws ServiceLocalException the service local exception
967   */
968  public String getDisplayCc() throws ServiceLocalException {
969    return getPropertyBag().getObjectFromPropertyDefinition(
970        ItemSchema.DisplayCc);
971  }
972
973  /**
974   * Gets a text summarizing the To recipients of this item.
975   *
976   * @return the display to
977   * @throws ServiceLocalException the service local exception
978   */
979  public String getDisplayTo() throws ServiceLocalException {
980    return getPropertyBag().getObjectFromPropertyDefinition(
981        ItemSchema.DisplayTo);
982  }
983
984  /**
985   * Gets a value indicating whether the item has attachments.
986   *
987   * @return the checks for attachments
988   * @throws ServiceLocalException the service local exception
989   */
990  public boolean getHasAttachments() throws ServiceLocalException {
991    return getPropertyBag().<Boolean>getObjectFromPropertyDefinition(
992        ItemSchema.HasAttachments);
993  }
994
995  /**
996   * Gets the body of this item.
997   *
998   * @return MessageBody
999   * @throws ServiceLocalException the service local exception
1000   */
1001  public MessageBody getBody() throws ServiceLocalException {
1002    return getPropertyBag().getObjectFromPropertyDefinition(ItemSchema.Body);
1003  }
1004
1005  /**
1006   * Sets the body.
1007   *
1008   * @param value the new body
1009   * @throws Exception the exception
1010   */
1011  public void setBody(MessageBody value) throws Exception {
1012    this.getPropertyBag().setObjectFromPropertyDefinition(ItemSchema.Body,
1013        value);
1014  }
1015
1016  /**
1017   * Gets the custom class name of this item.
1018   *
1019   * @return the item class
1020   * @throws ServiceLocalException the service local exception
1021   */
1022  public String getItemClass() throws ServiceLocalException {
1023    return getPropertyBag().getObjectFromPropertyDefinition(
1024        ItemSchema.ItemClass);
1025  }
1026
1027  /**
1028   * Sets the item class.
1029   *
1030   * @param value the new item class
1031   * @throws Exception the exception
1032   */
1033  public void setItemClass(String value) throws Exception {
1034    this.getPropertyBag().setObjectFromPropertyDefinition(
1035        ItemSchema.ItemClass, value);
1036  }
1037
1038  /**
1039   * Sets the subject.
1040   *
1041   * @param subject the new subject
1042   * @throws Exception the exception
1043   */
1044  public void setSubject(String subject) throws Exception {
1045    this.getPropertyBag().setObjectFromPropertyDefinition(
1046        ItemSchema.Subject, subject);
1047  }
1048
1049  /**
1050   * Gets the subject.
1051   *
1052   * @return the subject
1053   * @throws ServiceLocalException the service local exception
1054   */
1055  public String getSubject() throws ServiceLocalException {
1056    return getPropertyBag().getObjectFromPropertyDefinition(
1057        ItemSchema.Subject);
1058  }
1059
1060  /**
1061   * Gets the query string that should be appended to the Exchange Web client
1062   * URL to open this item using the appropriate read form in a web browser.
1063   *
1064   * @return the web client read form query string
1065   * @throws ServiceLocalException the service local exception
1066   */
1067  public String getWebClientReadFormQueryString()
1068      throws ServiceLocalException {
1069    return getPropertyBag().getObjectFromPropertyDefinition(
1070        ItemSchema.WebClientReadFormQueryString);
1071  }
1072
1073  /**
1074   * Gets the query string that should be appended to the Exchange Web client
1075   * URL to open this item using the appropriate read form in a web browser.
1076   *
1077   * @return the web client edit form query string
1078   * @throws ServiceLocalException the service local exception
1079   */
1080  public String getWebClientEditFormQueryString()
1081      throws ServiceLocalException {
1082    return getPropertyBag().getObjectFromPropertyDefinition(
1083        ItemSchema.WebClientEditFormQueryString);
1084  }
1085
1086  /**
1087   * Gets a list of extended property defined on this item.
1088   *
1089   * @return the extended property
1090   * @throws ServiceLocalException the service local exception
1091   */
1092  @Override
1093  public ExtendedPropertyCollection getExtendedProperties()
1094      throws ServiceLocalException {
1095    return getPropertyBag().getObjectFromPropertyDefinition(
1096        ServiceObjectSchema.extendedProperties);
1097  }
1098
1099  /**
1100   * Gets a value indicating the effective rights the current authenticated
1101   * user has on this item.
1102   *
1103   * @return the effective rights
1104   * @throws ServiceLocalException the service local exception
1105   */
1106  public EnumSet<EffectiveRights> getEffectiveRights()
1107      throws ServiceLocalException {
1108    return getPropertyBag().getObjectFromPropertyDefinition(
1109        ItemSchema.EffectiveRights);
1110  }
1111
1112  /**
1113   * Gets the name of the user who last modified this item.
1114   *
1115   * @return the last modified name
1116   * @throws ServiceLocalException the service local exception
1117   */
1118  public String getLastModifiedName() throws ServiceLocalException {
1119    return getPropertyBag().getObjectFromPropertyDefinition(
1120        ItemSchema.LastModifiedName);
1121  }
1122
1123  /**
1124   * Gets the date and time this item was last modified.
1125   *
1126   * @return the last modified time
1127   * @throws ServiceLocalException the service local exception
1128   */
1129  public Date getLastModifiedTime() throws ServiceLocalException {
1130    return getPropertyBag().getObjectFromPropertyDefinition(
1131        ItemSchema.LastModifiedTime);
1132  }
1133
1134  /**
1135   * Gets the Id of the conversation this item is part of.
1136   *
1137   * @return the conversation id
1138   * @throws ServiceLocalException the service local exception
1139   */
1140  public ConversationId getConversationId() throws ServiceLocalException {
1141    return getPropertyBag().getObjectFromPropertyDefinition(
1142        ItemSchema.ConversationId);
1143  }
1144
1145  /**
1146   * Gets the body part that is unique to the conversation this item is part
1147   * of.
1148   *
1149   * @return the unique body
1150   * @throws ServiceLocalException the service local exception
1151   */
1152  public UniqueBody getUniqueBody() throws ServiceLocalException {
1153    return getPropertyBag().getObjectFromPropertyDefinition(
1154        ItemSchema.UniqueBody);
1155  }
1156
1157  /**
1158   * Gets the default setting for how to treat affected task occurrences on
1159   * Delete. Subclasses will override this for different default behavior.
1160   *
1161   * @return the default affected task occurrences
1162   */
1163  protected AffectedTaskOccurrence getDefaultAffectedTaskOccurrences() {
1164    return null;
1165  }
1166
1167  /**
1168   * Gets the default setting for sending cancellations on Delete. Subclasses
1169   * will override this for different default behavior.
1170   *
1171   * @return the default send cancellations mode
1172   */
1173  protected SendCancellationsMode getDefaultSendCancellationsMode() {
1174    return null;
1175  }
1176
1177  /**
1178   * Gets the default settings for sending invitations on Save. Subclasses
1179   * will override this for different default behavior.
1180   *
1181   * @return the default send invitations mode
1182   */
1183  protected SendInvitationsMode getDefaultSendInvitationsMode() {
1184    return null;
1185  }
1186
1187  /**
1188   * Gets the default settings for sending invitations or cancellations on
1189   * Update. Subclasses will override this for different default behavior.
1190   *
1191   * @return the default send invitations or cancellations mode
1192   */
1193  protected SendInvitationsOrCancellationsMode getDefaultSendInvitationsOrCancellationsMode() {
1194    return null;
1195  }
1196
1197}