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.ServiceObjectDefinition;
027import microsoft.exchange.webservices.data.core.ExchangeService;
028import microsoft.exchange.webservices.data.core.PropertySet;
029import microsoft.exchange.webservices.data.core.XmlElementNames;
030import microsoft.exchange.webservices.data.core.service.ServiceObject;
031import microsoft.exchange.webservices.data.core.service.schema.ConversationSchema;
032import microsoft.exchange.webservices.data.core.service.schema.ServiceObjectSchema;
033import microsoft.exchange.webservices.data.core.enumeration.service.calendar.AffectedTaskOccurrence;
034import microsoft.exchange.webservices.data.core.enumeration.service.ConversationFlagStatus;
035import microsoft.exchange.webservices.data.core.enumeration.service.DeleteMode;
036import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion;
037import microsoft.exchange.webservices.data.core.enumeration.property.Importance;
038import microsoft.exchange.webservices.data.core.enumeration.service.SendCancellationsMode;
039import microsoft.exchange.webservices.data.core.exception.misc.ArgumentException;
040import microsoft.exchange.webservices.data.core.exception.service.local.ServiceLocalException;
041import microsoft.exchange.webservices.data.core.exception.service.remote.ServiceResponseException;
042import microsoft.exchange.webservices.data.misc.OutParam;
043import microsoft.exchange.webservices.data.property.complex.ConversationId;
044import microsoft.exchange.webservices.data.property.complex.ExtendedPropertyCollection;
045import microsoft.exchange.webservices.data.property.complex.FolderId;
046import microsoft.exchange.webservices.data.property.complex.ItemIdCollection;
047import microsoft.exchange.webservices.data.property.complex.StringList;
048import microsoft.exchange.webservices.data.property.definition.PropertyDefinition;
049
050import java.util.ArrayList;
051import java.util.Date;
052import java.util.HashMap;
053import java.util.List;
054
055/**
056 * Represents a collection of Conversation related property.
057 * Properties available on this object are defined
058 * in the ConversationSchema class.
059 */
060@ServiceObjectDefinition(xmlElementName = XmlElementNames.Conversation)
061public class Conversation extends ServiceObject {
062
063  /**
064   * Initializes an unsaved local instance of Conversation.
065   *
066   * @param service The service
067   *                The ExchangeService object to which the item will be bound.
068   * @throws Exception
069   */
070  public Conversation(ExchangeService service) throws Exception {
071    super(service);
072  }
073
074  /**
075   * Internal method to return the schema associated with this type of object
076   *
077   * @return The schema associated with this type of object.
078   */
079  @Override public ServiceObjectSchema getSchema() {
080    return ConversationSchema.Instance;
081  }
082
083  /**
084   * Gets the minimum required server version.
085   *
086   * @return Earliest Exchange version in which
087   * this service object type is supported.
088   */
089  @Override public ExchangeVersion getMinimumRequiredServerVersion() {
090    return ExchangeVersion.Exchange2010_SP1;
091  }
092
093  /**
094   * The property definition for the Id of this object.
095   *
096   * @return A PropertyDefinition instance.
097   */
098  @Override public PropertyDefinition getIdPropertyDefinition() {
099    return ConversationSchema.Id;
100  }
101
102  /**
103   * This method is not supported in this object.
104   * Loads the specified set of property on the object.
105   *
106   * @param propertySet The propertySet
107   *                    The property to load.
108   */
109  @Override
110  protected void internalLoad(PropertySet propertySet) {
111    throw new UnsupportedOperationException();
112  }
113
114  /**
115   * This is not supported in this object.
116   * Deletes the object.
117   *
118   * @param deleteMode              The deleteMode
119   *                                The deletion mode.
120   * @param sendCancellationsMode   The sendCancellationsMode
121   *                                Indicates whether meeting cancellation messages should be sent.
122   * @param affectedTaskOccurrences The affectedTaskOccurrences
123   *                                Indicate which occurrence of a recurring task should be deleted.
124   */
125  @Override
126  protected void internalDelete(DeleteMode deleteMode,
127      SendCancellationsMode sendCancellationsMode,
128      AffectedTaskOccurrence affectedTaskOccurrences) {
129    throw new UnsupportedOperationException();
130  }
131
132  /**
133   * This method is not supported in this object.
134   * Gets the name of the change XML element.
135   *
136   * @return XML element name
137   */
138  @Override public String getChangeXmlElementName() {
139    throw new UnsupportedOperationException();
140  }
141
142  /**
143   * This method is not supported in this object.
144   * Gets the name of the delete field XML element.
145   *
146   * @return XML element name
147   */
148  @Override public String getDeleteFieldXmlElementName() {
149    throw new UnsupportedOperationException();
150  }
151
152  /**
153   * This method is not supported in this object.
154   * Gets the name of the set field XML element.
155   *
156   * @return XML element name
157   */
158  @Override public String getSetFieldXmlElementName() {
159    throw new UnsupportedOperationException();
160  }
161
162  /**
163   * This method is not supported in this object.
164   * Gets a value indicating whether a time zone
165   * SOAP header should be emitted in a CreateItem
166   * or UpdateItem request so this item can be property saved or updated.
167   *
168   * @param isUpdateOperation Indicates whether
169   *                          the operation being petrformed is an update operation.
170   * @return true if a time zone SOAP header
171   * should be emitted; otherwise, false.
172   */
173  @Override
174  protected boolean getIsTimeZoneHeaderRequired(boolean isUpdateOperation) {
175    throw new UnsupportedOperationException();
176  }
177
178  /**
179   * This method is not supported in this object.
180   * Gets the extended property collection.
181   *
182   * @return Extended property collection.
183   */
184  @Override
185  protected ExtendedPropertyCollection getExtendedProperties() {
186    throw new UnsupportedOperationException();
187  }
188
189  /**
190   * Sets up a conversation so that any item
191   * received within that conversation is always categorized.
192   * Calling this method results in a call to EWS.
193   *
194   * @param categories           The categories that should be stamped on item in the conversation.
195   * @param processSynchronously Indicates whether the method should
196   *                             return only once enabling this rule and stamping existing item
197   *                             in the conversation is completely done.
198   *                             If processSynchronously is false, the method returns immediately.
199   * @throws Exception
200   * @throws IndexOutOfBoundsException
201   * @throws ServiceResponseException
202   */
203  public void enableAlwaysCategorizeItems(Iterable<String> categories,
204      boolean processSynchronously) throws ServiceResponseException,
205      IndexOutOfBoundsException, Exception {
206
207    ArrayList<ConversationId> convArry = new ArrayList<ConversationId>();
208    convArry.add(this.getId());
209
210    this.getService().enableAlwaysCategorizeItemsInConversations(
211        convArry,
212        categories,
213        processSynchronously).getResponseAtIndex(0).throwIfNecessary();
214  }
215
216  /**
217   * Sets up a conversation so that any item
218   * received within that conversation is no longer categorized.
219   * Calling this method results in a call to EWS.
220   *
221   * @param processSynchronously Indicates whether the method should
222   *                             return only once disabling this rule and
223   *                             removing the categories from existing item
224   *                             in the conversation is completely done. If processSynchronously
225   *                             is false, the method returns immediately.
226   * @throws Exception
227   * @throws IndexOutOfBoundsException
228   * @throws ServiceResponseException
229   */
230  public void disableAlwaysCategorizeItems(boolean processSynchronously)
231      throws ServiceResponseException, IndexOutOfBoundsException, Exception {
232    ArrayList<ConversationId> convArry = new ArrayList<ConversationId>();
233    convArry.add(this.getId());
234    this.getService().disableAlwaysCategorizeItemsInConversations(
235        convArry, processSynchronously).
236        getResponseAtIndex(0).throwIfNecessary();
237  }
238
239  /**
240   * Sets up a conversation so that any item received
241   * within that conversation is always moved to Deleted Items folder.
242   * Calling this method results in a call to EWS.
243   *
244   * @param processSynchronously Indicates whether the method should
245   *                             return only once enabling this rule and deleting existing item
246   *                             in the conversation is completely done. If processSynchronously
247   *                             is false, the method returns immediately.
248   * @throws Exception
249   * @throws IndexOutOfBoundsException
250   * @throws ServiceResponseException
251   */
252  public void enableAlwaysDeleteItems(boolean processSynchronously)
253      throws ServiceResponseException, IndexOutOfBoundsException, Exception {
254    ArrayList<ConversationId> convArry = new ArrayList<ConversationId>();
255    convArry.add(this.getId());
256    this.getService().enableAlwaysDeleteItemsInConversations(
257        convArry,
258        processSynchronously).getResponseAtIndex(0).throwIfNecessary();
259  }
260
261  /**
262   * Sets up a conversation so that any item received within that
263   * conversation is no longer moved to Deleted Items folder.
264   * Calling this method results in a call to EWS.
265   *
266   * @param processSynchronously Indicates whether the method should return
267   *                             only once disabling this rule and restoring the item
268   *                             in the conversation is completely done. If processSynchronously
269   *                             is false, the method returns immediately.
270   * @throws Exception
271   * @throws IndexOutOfBoundsException
272   * @throws ServiceResponseException
273   */
274  public void disableAlwaysDeleteItems(boolean processSynchronously)
275      throws ServiceResponseException, IndexOutOfBoundsException, Exception {
276    ArrayList<ConversationId> convArry = new ArrayList<ConversationId>();
277    convArry.add(this.getId());
278    this.getService().disableAlwaysDeleteItemsInConversations(
279        convArry,
280        processSynchronously).getResponseAtIndex(0).throwIfNecessary();
281  }
282
283  /**
284   * Sets up a conversation so that any item received within
285   * that conversation is always moved to a specific folder.
286   * Calling this method results in a call to EWS.
287   *
288   * @param destinationFolderId  The Id of the folder to which conversation item should be moved.
289   * @param processSynchronously Indicates whether the method should return only
290   *                             once enabling this rule
291   *                             and moving existing item in the conversation is completely done.
292   *                             If processSynchronously is false, the method returns immediately.
293   * @throws Exception
294   * @throws IndexOutOfBoundsException
295   * @throws ServiceResponseException
296   */
297  public void enableAlwaysMoveItems(FolderId destinationFolderId,
298      boolean processSynchronously) throws ServiceResponseException,
299      IndexOutOfBoundsException, Exception {
300    ArrayList<ConversationId> convArry = new ArrayList<ConversationId>();
301    convArry.add(this.getId());
302    this.getService().enableAlwaysMoveItemsInConversations(
303        convArry,
304        destinationFolderId,
305        processSynchronously).getResponseAtIndex(0).throwIfNecessary();
306  }
307
308  /**
309   * Sets up a conversation so that any item received within
310   * that conversation is no longer moved to a specific
311   * folder. Calling this method results in a call to EWS.
312   *
313   * @param processSynchronously Indicates whether the method should return only
314   *                             once disabling this
315   *                             rule is completely done. If processSynchronously
316   *                             is false, the method returns immediately.
317   * @throws Exception
318   * @throws IndexOutOfBoundsException
319   * @throws ServiceResponseException
320   */
321  public void disableAlwaysMoveItemsInConversation(boolean processSynchronously)
322      throws ServiceResponseException, IndexOutOfBoundsException, Exception {
323    ArrayList<ConversationId> convArry = new ArrayList<ConversationId>();
324    convArry.add(this.getId());
325    this.getService().disableAlwaysMoveItemsInConversations(
326        convArry,
327        processSynchronously).getResponseAtIndex(0).throwIfNecessary();
328  }
329
330  /**
331   * Deletes item in the specified conversation.
332   * Calling this method results in a call to EWS.
333   *
334   * @param contextFolderId The Id of the folder item must belong
335   *                        to in order to be deleted. If contextFolderId is
336   *                        null, item across the entire mailbox are deleted.
337   * @param deleteMode      The deletion mode.
338   * @throws Exception
339   * @throws IndexOutOfBoundsException
340   * @throws ServiceResponseException
341   */
342  public void deleteItems(FolderId contextFolderId, DeleteMode deleteMode)
343      throws ServiceResponseException, IndexOutOfBoundsException, Exception {
344    HashMap<ConversationId, Date> m = new HashMap<ConversationId, Date>();
345    m.put(this.getId(), this.getGlobalLastDeliveryTime());
346
347    List<HashMap<ConversationId, Date>> f = new ArrayList<HashMap<ConversationId, Date>>();
348    f.add(m);
349
350    this.getService().deleteItemsInConversations(
351        f,
352        contextFolderId,
353        deleteMode).getResponseAtIndex(0).throwIfNecessary();
354  }
355
356
357  /**
358   * Moves item in the specified conversation to a specific folder.
359   * Calling this method results in a call to EWS.
360   *
361   * @param contextFolderId     The Id of the folder item must belong to
362   *                            in order to be moved. If contextFolderId is null,
363   *                            item across the entire mailbox are moved.
364   * @param destinationFolderId The Id of the destination folder.
365   * @throws Exception
366   * @throws IndexOutOfBoundsException
367   * @throws ServiceResponseException
368   */
369  public void moveItemsInConversation(
370      FolderId contextFolderId,
371      FolderId destinationFolderId) throws ServiceResponseException,
372      IndexOutOfBoundsException, Exception {
373    HashMap<ConversationId, Date> m = new HashMap<ConversationId, Date>();
374    m.put(this.getId(), this.getGlobalLastDeliveryTime());
375
376    List<HashMap<ConversationId, Date>> f = new ArrayList<HashMap<ConversationId, Date>>();
377    f.add(m);
378
379    this.getService().moveItemsInConversations(
380        f, contextFolderId, destinationFolderId).
381        getResponseAtIndex(0).throwIfNecessary();
382  }
383
384  /**
385   * Copies item in the specified conversation to a specific folder.
386   * Calling this method results in a call to EWS.
387   *
388   * @param contextFolderId     The Id of the folder item must belong to in
389   *                            order to be copied. If contextFolderId
390   *                            is null, item across the entire mailbox are copied.
391   * @param destinationFolderId The Id of the destination folder.
392   * @throws Exception
393   * @throws IndexOutOfBoundsException
394   * @throws ServiceResponseException
395   */
396  public void copyItemsInConversation(
397      FolderId contextFolderId,
398      FolderId destinationFolderId) throws ServiceResponseException,
399      IndexOutOfBoundsException, Exception {
400    HashMap<ConversationId, Date> m = new HashMap<ConversationId, Date>();
401    m.put(this.getId(), this.getGlobalLastDeliveryTime());
402
403    List<HashMap<ConversationId, Date>> f = new ArrayList<HashMap<ConversationId, Date>>();
404    f.add(m);
405
406    this.getService().copyItemsInConversations(
407        f, contextFolderId, destinationFolderId).
408        getResponseAtIndex(0).throwIfNecessary();
409  }
410
411  /**
412   * Sets the read state of item in the specified conversation.
413   * Calling this method results in a call to EWS.
414   *
415   * @param contextFolderId The Id of the folder item must
416   *                        belong to in order for their read state to
417   *                        be set. If contextFolderId is null, the read states of
418   *                        item across the entire mailbox are set.
419   * @param isRead          if set to <c>true</c>, conversation item are marked as read;
420   *                        otherwise they are marked as unread.
421   * @throws Exception
422   * @throws IndexOutOfBoundsException
423   * @throws ServiceResponseException
424   */
425  public void setReadStateForItemsInConversation(
426      FolderId contextFolderId,
427      boolean isRead) throws ServiceResponseException,
428      IndexOutOfBoundsException, Exception {
429    HashMap<ConversationId, Date> m = new HashMap<ConversationId, Date>();
430    m.put(this.getId(), this.getGlobalLastDeliveryTime());
431
432    List<HashMap<ConversationId, Date>> f = new ArrayList<HashMap<ConversationId, Date>>();
433    f.add(m);
434
435    this.getService().setReadStateForItemsInConversations(
436        f, contextFolderId, isRead).
437        getResponseAtIndex(0).throwIfNecessary();
438  }
439
440  /**
441   * Gets the Id of this Conversation.
442   *
443   * @return Id
444   * @throws ServiceLocalException
445   */
446  public ConversationId getId() throws ServiceLocalException {
447    return getPropertyBag().getObjectFromPropertyDefinition(
448        getIdPropertyDefinition());
449  }
450
451  /**
452   * Gets the topic of this Conversation.
453   *
454   * @return value
455   * @throws ArgumentException
456   */
457  public String getTopic() throws ArgumentException {
458    String returnValue = "";
459
460    /**This property need not be present hence the
461     *  property bag may not contain it.
462     *Check for the presence of this property before accessing it.
463     */
464    if (this.getPropertyBag().contains(ConversationSchema.Topic)) {
465      OutParam<String> out = new OutParam<String>();
466      this.getPropertyBag().tryGetPropertyType(String.class,
467          ConversationSchema.Topic,
468          out);
469      returnValue = out.getParam();
470    }
471
472    return returnValue;
473  }
474
475  /**
476   * Gets a list of all the people who have received
477   * messages in this conversation in the current folder only.
478   *
479   * @return String
480   * @throws Exception
481   */
482  public StringList getUniqueRecipients() throws Exception {
483    return getPropertyBag().getObjectFromPropertyDefinition(
484        ConversationSchema.UniqueRecipients);
485  }
486
487  /**
488   * Gets a list of all the people who have received
489   * messages in this conversation across all folder in the mailbox.
490   *
491   * @return String
492   * @throws Exception
493   */
494  public StringList getGlobalUniqueRecipients() throws Exception {
495    return getPropertyBag().getObjectFromPropertyDefinition(
496        ConversationSchema.GlobalUniqueRecipients);
497  }
498
499  /**
500   * Gets a list of all the people who have sent messages
501   * that are currently unread in this conversation in
502   * the current folder only.
503   *
504   * @return unreadSenders
505   * @throws ArgumentException
506   */
507  public StringList getUniqueUnreadSenders() throws ArgumentException {
508    StringList unreadSenders = null;
509
510    /**This property need not be present hence
511     *  the property bag may not contain it.
512     *Check for the presence of this property before accessing it.
513     */
514    if (this.getPropertyBag().contains(ConversationSchema.UniqueUnreadSenders)) {
515      OutParam<StringList> out = new OutParam<StringList>();
516      this.getPropertyBag().tryGetPropertyType(StringList.class,
517          ConversationSchema.UniqueUnreadSenders,
518          out);
519      unreadSenders = out.getParam();
520    }
521
522    return unreadSenders;
523  }
524
525
526  /**
527   * Gets a list of all the people who have sent
528   * messages that are currently unread in this
529   * conversation across all folder in the mailbox.
530   *
531   * @return unreadSenders
532   * @throws ArgumentException
533   */
534  public StringList getGlobalUniqueUnreadSenders() throws ArgumentException {
535    StringList unreadSenders = null;
536
537    // This property need not be present hence
538    //the property bag may not contain it.
539    // Check for the presence of this property before accessing it.
540    if (this.getPropertyBag().contains(ConversationSchema.GlobalUniqueUnreadSenders)) {
541      OutParam<StringList> out = new OutParam<StringList>();
542      this.getPropertyBag().tryGetPropertyType(StringList.class,
543          ConversationSchema.GlobalUniqueUnreadSenders,
544          out);
545      unreadSenders = out.getParam();
546    }
547
548    return unreadSenders;
549  }
550
551  /**
552   * Gets a list of all the people who have sent
553   * messages in this conversation in the current folder only.
554   *
555   * @return String
556   * @throws Exception
557   */
558  public StringList getUniqueSenders() throws Exception {
559    return getPropertyBag().getObjectFromPropertyDefinition(
560        ConversationSchema.UniqueSenders);
561  }
562
563  /**
564   * Gets a list of all the people who have sent messages
565   * in this conversation across all folder in the mailbox.
566   *
567   * @return String
568   * @throws Exception
569   */
570  public StringList getGlobalUniqueSenders() throws Exception {
571    return getPropertyBag().getObjectFromPropertyDefinition(
572        ConversationSchema.GlobalUniqueSenders);
573  }
574
575  /**
576   * Gets the delivery time of the message that was last
577   * received in this conversation in the current folder only.
578   *
579   * @return Date
580   * @throws Exception
581   */
582  public Date getLastDeliveryTime() throws Exception {
583    return getPropertyBag().getObjectFromPropertyDefinition(
584        ConversationSchema.LastDeliveryTime);
585  }
586
587  /**
588   * Gets the delivery time of the message that was last
589   * received in this conversation across all folder in the mailbox.
590   *
591   * @return Date
592   * @throws Exception
593   */
594  public Date getGlobalLastDeliveryTime() throws Exception {
595    return getPropertyBag().getObjectFromPropertyDefinition(
596        ConversationSchema.GlobalLastDeliveryTime);
597  }
598
599  /**
600   * Gets a list summarizing the categories stamped on
601   * messages in this conversation, in the current folder only.
602   *
603   * @return value
604   * @throws ArgumentException
605   */
606  public StringList getCategories() throws ArgumentException {
607    StringList returnValue = null;
608
609    /**This property need not be present hence
610     * the property bag may not contain it.
611     * Check for the presence of this property before accessing it.
612     */
613    if (this.getPropertyBag().contains(ConversationSchema.Categories)) {
614      OutParam<StringList> out = new OutParam<StringList>();
615      this.getPropertyBag().tryGetPropertyType(StringList.class,
616          ConversationSchema.Categories,
617          out);
618      returnValue = out.getParam();
619    }
620    return returnValue;
621  }
622
623  /**
624   * Gets a list summarizing the categories stamped on
625   * messages in this conversation, across all folder in the mailbox.
626   *
627   * @return returnValue
628   * @throws ArgumentException
629   */
630  public StringList getGlobalCategories() throws ArgumentException {
631    StringList returnValue = null;
632
633    // This property need not be present hence the
634    //property bag may not contain it.
635    // Check for the presence of this property before accessing it.
636    if (this.getPropertyBag().contains(ConversationSchema.GlobalCategories)) {
637      OutParam<StringList> out = new OutParam<StringList>();
638      this.getPropertyBag().tryGetPropertyType(StringList.class,
639          ConversationSchema.GlobalCategories,
640          out);
641      returnValue = out.getParam();
642    }
643    return returnValue;
644  }
645
646  /**
647   * Gets the flag status for this conversation, calculated
648   * by aggregating individual messages flag status in the current folder.
649   *
650   * @return returnValue
651   * @throws ArgumentException
652   */
653  public ConversationFlagStatus getFlagStatus() throws ArgumentException {
654    ConversationFlagStatus returnValue = ConversationFlagStatus.NotFlagged;
655
656    // This property need not be present hence the
657    //property bag may not contain it.
658    // Check for the presence of this property before accessing it.
659    if (this.getPropertyBag().contains(ConversationSchema.FlagStatus)) {
660      OutParam<ConversationFlagStatus> out = new OutParam<ConversationFlagStatus>();
661      this.getPropertyBag().tryGetPropertyType(
662          ConversationFlagStatus.class,
663          ConversationSchema.FlagStatus,
664          out);
665      returnValue = out.getParam();
666    }
667
668    return returnValue;
669  }
670
671  /**
672   * Gets the flag status for this conversation, calculated by aggregating
673   * individual messages flag status across all folder in the mailbox.
674   *
675   * @return returnValue
676   * @throws ArgumentException
677   */
678  public ConversationFlagStatus getGlobalFlagStatus()
679      throws ArgumentException {
680    ConversationFlagStatus returnValue = ConversationFlagStatus.NotFlagged;
681
682    // This property need not be present hence the
683    //property bag may not contain it.
684    // Check for the presence of this property before accessing it.
685    if (this.getPropertyBag().contains(ConversationSchema.GlobalFlagStatus)) {
686      OutParam<ConversationFlagStatus> out = new OutParam<ConversationFlagStatus>();
687      this.getPropertyBag().tryGetPropertyType(
688          ConversationFlagStatus.class,
689          ConversationSchema.GlobalFlagStatus,
690          out);
691      returnValue = out.getParam();
692    }
693
694    return returnValue;
695  }
696
697  /**
698   * Gets a value indicating if at least one message in this
699   * conversation, in the current folder only, has an attachment.
700   *
701   * @return Value
702   * @throws ServiceLocalException
703   */
704  public boolean getHasAttachments() throws ServiceLocalException {
705    return getPropertyBag().<Boolean>getObjectFromPropertyDefinition(ConversationSchema.HasAttachments);
706  }
707
708  /**
709   * Gets a value indicating if at least one message
710   * in this conversation, across all folder in the mailbox,
711   * has an attachment.
712   *
713   * @return boolean
714   * @throws ServiceLocalException
715   */
716  public boolean getGlobalHasAttachments() throws ServiceLocalException {
717    return getPropertyBag().<Boolean>getObjectFromPropertyDefinition(
718        ConversationSchema.GlobalHasAttachments);
719  }
720
721  /**
722   * Gets the total number of messages in this conversation
723   * in the current folder only.
724   *
725   * @return integer
726   * @throws ServiceLocalException
727   */
728  public int getMessageCount() throws ServiceLocalException {
729    return getPropertyBag().<Integer>getObjectFromPropertyDefinition(
730        ConversationSchema.MessageCount);
731  }
732
733  /**
734   * Gets the total number of messages in this
735   * conversation across all folder in the mailbox.
736   *
737   * @return integer
738   * @throws ServiceLocalException
739   */
740  public int getGlobalMessageCount() throws ServiceLocalException {
741    return getPropertyBag().<Integer>getObjectFromPropertyDefinition(
742        ConversationSchema.GlobalMessageCount);
743  }
744
745  /**
746   * Gets the total number of unread messages in this
747   * conversation in the current folder only.
748   *
749   * @return returnValue
750   * @throws ArgumentException
751   */
752  public int getUnreadCount() throws ArgumentException {
753    int returnValue = 0;
754
755    /**This property need not be present hence the
756     * property bag may not contain it.
757     * Check for the presence of this property before accessing it.
758     */
759    if (this.getPropertyBag().contains(ConversationSchema.UnreadCount)) {
760      OutParam<Integer> out = new OutParam<Integer>();
761      this.getPropertyBag().tryGetPropertyType(Integer.class,
762          ConversationSchema.UnreadCount,
763          out);
764      returnValue = out.getParam().intValue();
765    }
766
767    return returnValue;
768  }
769
770  /**
771   * Gets the total number of unread messages in this
772   * conversation across all folder in the mailbox.
773   *
774   * @return returnValue
775   * @throws ArgumentException
776   */
777  public int getGlobalUnreadCount() throws ArgumentException {
778    int returnValue = 0;
779
780    if (this.getPropertyBag().contains(ConversationSchema.GlobalUnreadCount)) {
781      OutParam<Integer> out = new OutParam<Integer>();
782      this.getPropertyBag().tryGetPropertyType(Integer.class,
783          ConversationSchema.GlobalUnreadCount,
784          out);
785      returnValue = out.getParam().intValue();
786    }
787    return returnValue;
788
789  }
790
791
792  /**
793   * Gets the size of this conversation, calculated by
794   * adding the sizes of all messages in the conversation in
795   * the current folder only.
796   *
797   * @return integer
798   * @throws ServiceLocalException
799   */
800  public int getSize() throws ServiceLocalException {
801    return getPropertyBag().<Integer>getObjectFromPropertyDefinition(
802        ConversationSchema.Size);
803  }
804
805  /**
806   * Gets the size of this conversation, calculated by
807   * adding the sizes of all messages in the conversation
808   * across all folder in the mailbox.
809   *
810   * @return integer
811   * @throws ServiceLocalException
812   */
813  public int getGlobalSize() throws ServiceLocalException {
814    return getPropertyBag().<Integer>getObjectFromPropertyDefinition(
815        ConversationSchema.GlobalSize);
816  }
817
818  /**
819   * Gets a list summarizing the classes of the item
820   * in this conversation, in the current folder only.
821   *
822   * @return string
823   * @throws Exception
824   */
825  public StringList getItemClasses() throws Exception {
826    return getPropertyBag().getObjectFromPropertyDefinition(
827        ConversationSchema.ItemClasses);
828  }
829
830  /**
831   * Gets a list summarizing the classes of the item
832   * in this conversation, across all folder in the mailbox.
833   *
834   * @return string
835   * @throws Exception
836   */
837  public StringList getGlobalItemClasses() throws Exception {
838    return getPropertyBag().getObjectFromPropertyDefinition(
839        ConversationSchema.GlobalItemClasses);
840  }
841
842  /**
843   * Gets the importance of this conversation, calculated by
844   * aggregating individual messages importance in the current folder only.
845   *
846   * @return important
847   * @throws Exception
848   */
849  public Importance getImportance() throws Exception {
850    return getPropertyBag().getObjectFromPropertyDefinition(
851        ConversationSchema.Importance);
852  }
853
854  /**
855   * Gets the importance of this conversation, calculated by
856   * aggregating individual messages importance across all
857   * folder in the mailbox.
858   *
859   * @return important
860   * @throws Exception
861   */
862  public Importance getGlobalImportance() throws Exception {
863    return getPropertyBag().getObjectFromPropertyDefinition(
864        ConversationSchema.GlobalImportance);
865  }
866
867  /**
868   * Gets the Ids of the messages in this conversation,
869   * in the current folder only.
870   *
871   * @return Id
872   * @throws Exception
873   */
874  public ItemIdCollection getItemIds() throws Exception {
875    return getPropertyBag().getObjectFromPropertyDefinition(
876        ConversationSchema.ItemIds);
877  }
878
879  /**
880   * Gets the Ids of the messages in this conversation,
881   * across all folder in the mailbox.
882   *
883   * @return Id
884   * @throws Exception
885   */
886  public ItemIdCollection getGlobalItemIds() throws Exception {
887    return getPropertyBag().getObjectFromPropertyDefinition(
888        ConversationSchema.GlobalItemIds);
889  }
890
891}