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.folder; 025 026import microsoft.exchange.webservices.data.attribute.ServiceObjectDefinition; 027import microsoft.exchange.webservices.data.core.EwsUtilities; 028import microsoft.exchange.webservices.data.core.ExchangeService; 029import microsoft.exchange.webservices.data.core.PropertySet; 030import microsoft.exchange.webservices.data.core.XmlElementNames; 031import microsoft.exchange.webservices.data.core.response.FindItemResponse; 032import microsoft.exchange.webservices.data.core.response.ServiceResponseCollection; 033import microsoft.exchange.webservices.data.core.service.ServiceObject; 034import microsoft.exchange.webservices.data.core.service.item.Item; 035import microsoft.exchange.webservices.data.core.service.schema.FolderSchema; 036import microsoft.exchange.webservices.data.core.service.schema.ServiceObjectSchema; 037import microsoft.exchange.webservices.data.core.enumeration.service.calendar.AffectedTaskOccurrence; 038import microsoft.exchange.webservices.data.core.enumeration.service.DeleteMode; 039import microsoft.exchange.webservices.data.core.enumeration.service.EffectiveRights; 040import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; 041import microsoft.exchange.webservices.data.core.enumeration.service.SendCancellationsMode; 042import microsoft.exchange.webservices.data.core.enumeration.service.error.ServiceErrorHandling; 043import microsoft.exchange.webservices.data.core.enumeration.property.WellKnownFolderName; 044import microsoft.exchange.webservices.data.core.exception.misc.InvalidOperationException; 045import microsoft.exchange.webservices.data.core.exception.service.local.ServiceLocalException; 046import microsoft.exchange.webservices.data.property.complex.ExtendedPropertyCollection; 047import microsoft.exchange.webservices.data.property.complex.FolderId; 048import microsoft.exchange.webservices.data.property.complex.FolderPermissionCollection; 049import microsoft.exchange.webservices.data.property.complex.ManagedFolderInformation; 050import microsoft.exchange.webservices.data.property.definition.ExtendedPropertyDefinition; 051import microsoft.exchange.webservices.data.property.definition.PropertyDefinition; 052import microsoft.exchange.webservices.data.search.FindFoldersResults; 053import microsoft.exchange.webservices.data.search.FindItemsResults; 054import microsoft.exchange.webservices.data.search.FolderView; 055import microsoft.exchange.webservices.data.search.GroupedFindItemsResults; 056import microsoft.exchange.webservices.data.search.Grouping; 057import microsoft.exchange.webservices.data.search.ItemView; 058import microsoft.exchange.webservices.data.search.ViewBase; 059import microsoft.exchange.webservices.data.search.filter.SearchFilter; 060import org.apache.commons.logging.Log; 061import org.apache.commons.logging.LogFactory; 062 063import java.util.ArrayList; 064import java.util.EnumSet; 065 066/** 067 * Represents a generic folder. 068 */ 069@ServiceObjectDefinition(xmlElementName = XmlElementNames.Folder) 070public class Folder extends ServiceObject { 071 072 private static final Log LOG = LogFactory.getLog(Folder.class); 073 074 /** 075 * Initializes an unsaved local instance of {@link Folder}. 076 * 077 * @param service EWS service to which this object belongs 078 * @throws Exception the exception 079 */ 080 public Folder(ExchangeService service) throws Exception { 081 super(service); 082 } 083 084 /** 085 * Binds to an existing folder, whatever its actual type is, and loads the 086 * specified set of property. Calling this method results in a call to 087 * EWS. 088 * 089 * @param service The service to use to bind to the folder. 090 * @param id The Id of the folder to bind to. 091 * @param propertySet The set of property to load. 092 * @return A Folder instance representing the folder corresponding to the 093 * specified Id. 094 * @throws Exception the exception 095 */ 096 public static Folder bind(ExchangeService service, FolderId id, 097 PropertySet propertySet) throws Exception { 098 return service.bindToFolder(Folder.class, id, propertySet); 099 } 100 101 /** 102 * Binds to an existing folder, whatever its actual type is, and loads the 103 * specified set of property. Calling this method results in a call to 104 * EWS. 105 * 106 * @param service , The service to use to bind to the folder. 107 * @param id , The Id of the folder to bind to. 108 * @return A Folder instance representing the folder corresponding to the 109 * specified Id. 110 * @throws Exception the exception 111 */ 112 public static Folder bind(ExchangeService service, FolderId id) 113 throws Exception { 114 return Folder.bind(service, id, PropertySet.getFirstClassProperties()); 115 } 116 117 /** 118 * Binds to an existing folder, whatever its actual type is, and loads the 119 * specified set of property. Calling this method results in a call to 120 * EWS. 121 * 122 * @param service The service to use to bind to the folder. 123 * @param name The name of the folder to bind to. 124 * @param propertySet The set of property to load. 125 * @return A Folder instance representing the folder corresponding to the 126 * specified Id. 127 * @throws Exception the exception 128 */ 129 public static Folder bind(ExchangeService service, 130 WellKnownFolderName name, PropertySet propertySet) 131 throws Exception { 132 return Folder.bind(service, new FolderId(name), propertySet); 133 } 134 135 /** 136 * Binds to an existing folder, whatever its actual type is, and loads the 137 * specified set of property. Calling this method results in a call to 138 * EWS. 139 * 140 * @param service The service to use to bind to the folder. 141 * @param name The name of the folder to bind to. 142 * @return the folder 143 * @throws Exception the exception 144 */ 145 public static Folder bind(ExchangeService service, WellKnownFolderName name) 146 throws Exception { 147 return Folder.bind(service, new FolderId(name), PropertySet 148 .getFirstClassProperties()); 149 } 150 151 /** 152 * Validates this instance. 153 * 154 * @throws Exception the exception 155 */ 156 @Override public void validate() throws Exception { 157 super.validate(); 158 159 // Validate folder permissions 160 try { 161 if (this.getPropertyBag().contains(FolderSchema.Permissions)) { 162 this.getPermissions().validate(); 163 } 164 } catch (ServiceLocalException e) { 165 LOG.error(e); 166 } 167 } 168 169 /** 170 * Internal method to return the schema associated with this type of object. 171 * 172 * @return The schema associated with this type of object. 173 */ 174 @Override public ServiceObjectSchema getSchema() { 175 return FolderSchema.Instance; 176 } 177 178 /** 179 * Gets the minimum required server version. 180 * 181 * @return Earliest Exchange version in which this service object type is 182 * supported. 183 */ 184 @Override public ExchangeVersion getMinimumRequiredServerVersion() { 185 return ExchangeVersion.Exchange2007_SP1; 186 } 187 188 /** 189 * Gets the name of the change XML element. 190 * 191 * @return Xml element name 192 */ 193 @Override public String getChangeXmlElementName() { 194 return XmlElementNames.FolderChange; 195 } 196 197 /** 198 * Gets the name of the set field XML element. 199 * 200 * @return Xml element name 201 */ 202 @Override public String getSetFieldXmlElementName() { 203 return XmlElementNames.SetFolderField; 204 } 205 206 /** 207 * Gets the name of the delete field XML element. 208 * 209 * @return Xml element name 210 */ 211 @Override public String getDeleteFieldXmlElementName() { 212 return XmlElementNames.DeleteFolderField; 213 } 214 215 /** 216 * Loads the specified set of property on the object. 217 * 218 * @param propertySet The property to load. 219 * @throws Exception the exception 220 */ 221 @Override 222 protected void internalLoad(PropertySet propertySet) throws Exception { 223 this.throwIfThisIsNew(); 224 225 this.getService().loadPropertiesForFolder(this, propertySet); 226 } 227 228 /** 229 * Deletes the object. 230 * 231 * @param deleteMode the delete mode 232 * @param sendCancellationsMode Indicates whether meeting cancellation messages should be 233 * sent. 234 * @param affectedTaskOccurrences Indicate which occurrence of a recurring task should be 235 * deleted. 236 * @throws Exception the exception 237 */ 238 @Override 239 protected void internalDelete(DeleteMode deleteMode, 240 SendCancellationsMode sendCancellationsMode, 241 AffectedTaskOccurrence affectedTaskOccurrences) throws Exception { 242 try { 243 this.throwIfThisIsNew(); 244 } catch (InvalidOperationException e) { 245 LOG.error(e); 246 } 247 248 this.getService().deleteFolder(this.getId(), deleteMode); 249 } 250 251 /** 252 * Deletes the folder. Calling this method results in a call to EWS. 253 * 254 * @param deleteMode the delete mode 255 * @throws Exception the exception 256 */ 257 public void delete(DeleteMode deleteMode) throws Exception { 258 this.internalDelete(deleteMode, null, null); 259 } 260 261 /** 262 * Empties the folder. Calling this method results in a call to EWS. 263 * 264 * @param deletemode the delete mode 265 * @param deleteSubFolders Indicates whether sub-folder should also be deleted. 266 * @throws Exception 267 */ 268 public void empty(DeleteMode deletemode, boolean deleteSubFolders) 269 throws Exception { 270 this.throwIfThisIsNew(); 271 this.getService().emptyFolder(this.getId(), 272 deletemode, deleteSubFolders); 273 } 274 275 /** 276 * Saves this folder in a specific folder. Calling this method results in a 277 * call to EWS. 278 * 279 * @param parentFolderId The Id of the folder in which to save this folder. 280 * @throws Exception the exception 281 */ 282 public void save(FolderId parentFolderId) throws Exception { 283 this.throwIfThisIsNotNew(); 284 285 EwsUtilities.validateParam(parentFolderId, "parentFolderId"); 286 287 if (this.isDirty()) { 288 this.getService().createFolder(this, parentFolderId); 289 } 290 } 291 292 /** 293 * Saves this folder in a specific folder. Calling this method results in a 294 * call to EWS. 295 * 296 * @param parentFolderName The name of the folder in which to save this folder. 297 * @throws Exception the exception 298 */ 299 public void save(WellKnownFolderName parentFolderName) throws Exception { 300 this.save(new FolderId(parentFolderName)); 301 } 302 303 /** 304 * Applies the local changes that have been made to this folder. Calling 305 * this method results in a call to EWS. 306 * 307 * @throws Exception the exception 308 */ 309 public void update() throws Exception { 310 if (this.isDirty()) { 311 if (this.getPropertyBag().getIsUpdateCallNecessary()) { 312 this.getService().updateFolder(this); 313 } 314 } 315 } 316 317 /** 318 * Copies this folder into a specific folder. Calling this method results in 319 * a call to EWS. 320 * 321 * @param destinationFolderId The Id of the folder in which to copy this folder. 322 * @return A Folder representing the copy of this folder. 323 * @throws Exception the exception 324 */ 325 public Folder copy(FolderId destinationFolderId) throws Exception { 326 this.throwIfThisIsNew(); 327 328 EwsUtilities.validateParam(destinationFolderId, "destinationFolderId"); 329 330 return this.getService().copyFolder(this.getId(), destinationFolderId); 331 } 332 333 /** 334 * Copies this folder into the specified folder. Calling this method results 335 * in a call to EWS. 336 * 337 * @param destinationFolderName The name of the folder in which to copy this folder. 338 * @return A Folder representing the copy of this folder. 339 * @throws Exception the exception 340 */ 341 public Folder copy(WellKnownFolderName destinationFolderName) 342 throws Exception { 343 return this.copy(new FolderId(destinationFolderName)); 344 } 345 346 /** 347 * Moves this folder to a specific folder. Calling this method results in a 348 * call to EWS. 349 * 350 * @param destinationFolderId The Id of the folder in which to move this folder. 351 * @return A new folder representing this folder in its new location. After 352 * Move completes, this folder does not exist anymore. 353 * @throws Exception the exception 354 */ 355 public Folder move(FolderId destinationFolderId) throws Exception { 356 this.throwIfThisIsNew(); 357 358 EwsUtilities.validateParam(destinationFolderId, "destinationFolderId"); 359 360 return this.getService().moveFolder(this.getId(), destinationFolderId); 361 } 362 363 /** 364 * Moves this folder to a specific folder. Calling this method results in a 365 * call to EWS. 366 * 367 * @param destinationFolderName The name of the folder in which to move this folder. 368 * @return A new folder representing this folder in its new location. After 369 * Move completes, this folder does not exist anymore. 370 * @throws Exception the exception 371 */ 372 public Folder move(WellKnownFolderName destinationFolderName) 373 throws Exception { 374 return this.move(new FolderId(destinationFolderName)); 375 } 376 377 /** 378 * Find item. 379 * 380 * @param <TItem> The type of the item. 381 * @param queryString query string to be used for indexed search 382 * @param view The view controlling the number of item returned. 383 * @param groupBy The group by. 384 * @return FindItems response collection. 385 * @throws Exception the exception 386 */ 387 <TItem extends Item> ServiceResponseCollection<FindItemResponse<TItem>> 388 internalFindItems(String queryString, 389 ViewBase view, Grouping groupBy) 390 throws Exception { 391 ArrayList<FolderId> folderIdArry = new ArrayList<FolderId>(); 392 folderIdArry.add(this.getId()); 393 394 this.throwIfThisIsNew(); 395 return this.getService().findItems(folderIdArry, 396 null, /* searchFilter */ 397 queryString, view, groupBy, ServiceErrorHandling.ThrowOnError); 398 399 } 400 401 /** 402 * Find item. 403 * 404 * @param <TItem> The type of the item. 405 * @param searchFilter The search filter. Available search filter classes include 406 * SearchFilter.IsEqualTo, SearchFilter.ContainsSubstring and 407 * SearchFilter.SearchFilterCollection 408 * @param view The view controlling the number of item returned. 409 * @param groupBy The group by. 410 * @return FindItems response collection. 411 * @throws Exception the exception 412 */ 413 <TItem extends Item> ServiceResponseCollection<FindItemResponse<TItem>> 414 internalFindItems(SearchFilter searchFilter, 415 ViewBase view, Grouping groupBy) 416 throws Exception { 417 ArrayList<FolderId> folderIdArry = new ArrayList<FolderId>(); 418 folderIdArry.add(this.getId()); 419 this.throwIfThisIsNew(); 420 421 return this.getService().findItems(folderIdArry, searchFilter, 422 null, /* queryString */ 423 view, groupBy, ServiceErrorHandling.ThrowOnError); 424 } 425 426 /** 427 * Find item. 428 * 429 * @param searchFilter The search filter. Available search filter classes include 430 * SearchFilter.IsEqualTo, SearchFilter.ContainsSubstring and 431 * SearchFilter.SearchFilterCollection 432 * @param view The view controlling the number of item returned. 433 * @return FindItems results collection. 434 * @throws Exception the exception 435 */ 436 public FindItemsResults<Item> findItems(SearchFilter searchFilter, 437 ItemView view) throws Exception { 438 EwsUtilities.validateParamAllowNull(searchFilter, "searchFilter"); 439 440 ServiceResponseCollection<FindItemResponse<Item>> responses = this 441 .internalFindItems(searchFilter, view, null /* groupBy */); 442 443 return responses.getResponseAtIndex(0).getResults(); 444 } 445 446 /** 447 * Find item. 448 * 449 * @param queryString query string to be used for indexed search 450 * @param view The view controlling the number of item returned. 451 * @return FindItems results collection. 452 * @throws Exception the exception 453 */ 454 public FindItemsResults<Item> findItems(String queryString, ItemView view) 455 throws Exception { 456 EwsUtilities.validateParamAllowNull(queryString, "queryString"); 457 458 ServiceResponseCollection<FindItemResponse<Item>> responses = this 459 .internalFindItems(queryString, view, null /* groupBy */); 460 461 return responses.getResponseAtIndex(0).getResults(); 462 } 463 464 /** 465 * Find item. 466 * 467 * @param view The view controlling the number of item returned. 468 * @return FindItems results collection. 469 * @throws Exception the exception 470 */ 471 public FindItemsResults<Item> findItems(ItemView view) throws Exception { 472 ServiceResponseCollection<FindItemResponse<Item>> responses = this 473 .internalFindItems((SearchFilter) null, view, 474 null /* groupBy */); 475 476 return responses.getResponseAtIndex(0).getResults(); 477 } 478 479 /** 480 * Find item. 481 * 482 * @param searchFilter The search filter. Available search filter classes include 483 * SearchFilter.IsEqualTo, SearchFilter.ContainsSubstring and 484 * SearchFilter.SearchFilterCollection 485 * @param view The view controlling the number of item returned. 486 * @param groupBy The group by. 487 * @return A collection of grouped item representing the contents of this 488 * folder. 489 * @throws Exception the exception 490 */ 491 public GroupedFindItemsResults<Item> findItems(SearchFilter searchFilter, 492 ItemView view, Grouping groupBy) throws Exception { 493 EwsUtilities.validateParam(groupBy, "groupBy"); 494 EwsUtilities.validateParamAllowNull(searchFilter, "searchFilter"); 495 496 ServiceResponseCollection<FindItemResponse<Item>> responses = this 497 .internalFindItems(searchFilter, view, groupBy); 498 499 return responses.getResponseAtIndex(0).getGroupedFindResults(); 500 } 501 502 /** 503 * Find item. 504 * 505 * @param queryString query string to be used for indexed search 506 * @param view The view controlling the number of item returned. 507 * @param groupBy The group by. 508 * @return A collection of grouped item representing the contents of this 509 * folder. 510 * @throws Exception the exception 511 */ 512 public GroupedFindItemsResults<Item> findItems(String queryString, 513 ItemView view, Grouping groupBy) throws Exception { 514 EwsUtilities.validateParam(groupBy, "groupBy"); 515 516 ServiceResponseCollection<FindItemResponse<Item>> responses = this 517 .internalFindItems(queryString, view, groupBy); 518 519 return responses.getResponseAtIndex(0).getGroupedFindResults(); 520 } 521 522 /** 523 * Obtains a list of folder by searching the sub-folder of this folder. 524 * Calling this method results in a call to EWS. 525 * 526 * @param view The view controlling the number of folder returned. 527 * @return An object representing the results of the search operation. 528 * @throws Exception the exception 529 */ 530 public FindFoldersResults findFolders(FolderView view) throws Exception { 531 this.throwIfThisIsNew(); 532 533 return this.getService().findFolders(this.getId(), view); 534 } 535 536 /** 537 * Obtains a list of folder by searching the sub-folder of this folder. 538 * Calling this method results in a call to EWS. 539 * 540 * @param searchFilter The search filter. Available search filter classes include 541 * SearchFilter.IsEqualTo, SearchFilter.ContainsSubstring and 542 * SearchFilter.SearchFilterCollection 543 * @param view The view controlling the number of folder returned. 544 * @return An object representing the results of the search operation. 545 * @throws Exception the exception 546 */ 547 public FindFoldersResults findFolders(SearchFilter searchFilter, 548 FolderView view) throws Exception { 549 this.throwIfThisIsNew(); 550 551 return this.getService().findFolders(this.getId(), searchFilter, view); 552 } 553 554 /** 555 * Obtains a grouped list of item by searching the contents of this folder. 556 * Calling this method results in a call to EWS. 557 * 558 * @param view The view controlling the number of folder returned. 559 * @param groupBy The grouping criteria. 560 * @return A collection of grouped item representing the contents of this 561 * folder. 562 * @throws Exception the exception 563 */ 564 public GroupedFindItemsResults<Item> findItems(ItemView view, 565 Grouping groupBy) throws Exception { 566 EwsUtilities.validateParam(groupBy, "groupBy"); 567 568 return this.findItems((SearchFilter) null, view, groupBy); 569 } 570 571 /** 572 * Get the property definition for the Id property. 573 * 574 * @return the id property definition 575 */ 576 @Override public PropertyDefinition getIdPropertyDefinition() { 577 return FolderSchema.Id; 578 } 579 580 /** 581 * Sets the extended property. 582 * 583 * @param extendedPropertyDefinition The extended property definition. 584 * @param value The value. 585 * @throws Exception the exception 586 */ 587 public void setExtendedProperty( 588 ExtendedPropertyDefinition extendedPropertyDefinition, Object value) 589 throws Exception { 590 this.getExtendedProperties().setExtendedProperty( 591 extendedPropertyDefinition, value); 592 } 593 594 /** 595 * Removes an extended property. 596 * 597 * @param extendedPropertyDefinition The extended property definition. 598 * @return True if property was removed. 599 * @throws Exception the exception 600 */ 601 public boolean removeExtendedProperty( 602 ExtendedPropertyDefinition extendedPropertyDefinition) 603 throws Exception { 604 return this.getExtendedProperties().removeExtendedProperty( 605 extendedPropertyDefinition); 606 } 607 608 /** 609 * True if property was removed. 610 * 611 * @return Extended property collection. 612 * @throws Exception the exception 613 */ 614 @Override 615 protected ExtendedPropertyCollection getExtendedProperties() 616 throws Exception { 617 return this.getExtendedPropertiesForService(); 618 } 619 620 /** 621 * Gets the Id of the folder. 622 * 623 * @return the id 624 */ 625 public FolderId getId() { 626 try { 627 return getPropertyBag().getObjectFromPropertyDefinition( 628 getIdPropertyDefinition()); 629 } catch (ServiceLocalException e) { 630 LOG.error(e); 631 return null; 632 } 633 } 634 635 /** 636 * Gets the Id of this folder's parent folder. 637 * 638 * @return the parent folder id 639 * @throws ServiceLocalException the service local exception 640 */ 641 public FolderId getParentFolderId() throws ServiceLocalException { 642 return getPropertyBag().getObjectFromPropertyDefinition( 643 FolderSchema.ParentFolderId); 644 } 645 646 /** 647 * Gets the number of child folder this folder has. 648 * 649 * @return the child folder count 650 * @throws NumberFormatException the number format exception 651 * @throws ServiceLocalException the service local exception 652 */ 653 public int getChildFolderCount() throws NumberFormatException, 654 ServiceLocalException { 655 return (Integer.parseInt(this.getPropertyBag() 656 .getObjectFromPropertyDefinition(FolderSchema.ChildFolderCount) 657 .toString())); 658 } 659 660 /** 661 * Gets the display name of the folder. 662 * 663 * @return the display name 664 * @throws ServiceLocalException the service local exception 665 */ 666 public String getDisplayName() throws ServiceLocalException { 667 return getPropertyBag().getObjectFromPropertyDefinition( 668 FolderSchema.DisplayName); 669 } 670 671 /** 672 * Sets the display name of the folder. 673 * 674 * @param value Name of the folder 675 * @throws Exception the exception 676 */ 677 public void setDisplayName(String value) throws Exception { 678 this.getPropertyBag().setObjectFromPropertyDefinition( 679 FolderSchema.DisplayName, value); 680 } 681 682 /** 683 * Gets the custom class name of this folder. 684 * 685 * @return the folder class 686 * @throws ServiceLocalException the service local exception 687 */ 688 public String getFolderClass() throws ServiceLocalException { 689 return getPropertyBag().getObjectFromPropertyDefinition( 690 FolderSchema.FolderClass); 691 } 692 693 /** 694 * Sets the custom class name of this folder. 695 * 696 * @param value name of the folder 697 * @throws Exception the exception 698 */ 699 public void setFolderClass(String value) throws Exception { 700 this.getPropertyBag().setObjectFromPropertyDefinition( 701 FolderSchema.FolderClass, value); 702 } 703 704 /** 705 * Gets the total number of item contained in the folder. 706 * 707 * @return the total count 708 * @throws NumberFormatException the number format exception 709 * @throws ServiceLocalException the service local exception 710 */ 711 public int getTotalCount() throws NumberFormatException, 712 ServiceLocalException { 713 return (Integer.parseInt(this.getPropertyBag() 714 .getObjectFromPropertyDefinition(FolderSchema.TotalCount) 715 .toString())); 716 } 717 718 /** 719 * Gets a list of extended property associated with the folder. 720 * 721 * @return the extended property for service 722 * @throws ServiceLocalException the service local exception 723 */ 724 // changed the name of method as another method with same name exists 725 public ExtendedPropertyCollection getExtendedPropertiesForService() 726 throws ServiceLocalException { 727 return getPropertyBag().getObjectFromPropertyDefinition( 728 ServiceObjectSchema.extendedProperties); 729 } 730 731 /** 732 * Gets the Email Lifecycle Management (ELC) information associated with the 733 * folder. 734 * 735 * @return the managed folder information 736 * @throws ServiceLocalException the service local exception 737 */ 738 public ManagedFolderInformation getManagedFolderInformation() 739 throws ServiceLocalException { 740 return getPropertyBag().getObjectFromPropertyDefinition( 741 FolderSchema.ManagedFolderInformation); 742 } 743 744 /** 745 * Gets a value indicating the effective rights the current authenticated 746 * user has on the folder. 747 * 748 * @return the effective rights 749 * @throws ServiceLocalException the service local exception 750 */ 751 public EnumSet<EffectiveRights> getEffectiveRights() throws ServiceLocalException { 752 return getPropertyBag().getObjectFromPropertyDefinition( 753 FolderSchema.EffectiveRights); 754 } 755 756 /** 757 * Gets a list of permissions for the folder. 758 * 759 * @return the permissions 760 * @throws ServiceLocalException the service local exception 761 */ 762 public FolderPermissionCollection getPermissions() 763 throws ServiceLocalException { 764 return getPropertyBag().getObjectFromPropertyDefinition( 765 FolderSchema.Permissions); 766 } 767 768 /** 769 * Gets the number of unread item in the folder. 770 * 771 * @return the unread count 772 * @throws NumberFormatException the number format exception 773 * @throws ServiceLocalException the service local exception 774 */ 775 public int getUnreadCount() throws NumberFormatException, 776 ServiceLocalException { 777 return (Integer.parseInt(this.getPropertyBag() 778 .getObjectFromPropertyDefinition(FolderSchema.UnreadCount) 779 .toString())); 780 } 781 782}