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