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