protected Folder getFolder(ExchangeService service) { Folder folder; if(folderName.equals("INBOX")){ try { folder = Folder.bind(service, WellKnownFolderName.Inbox); } catch (Exception e) { throw new ProcessException("Failed to bind Inbox Folder on EWS Server", e); } } else { FolderView view = new FolderView(10); view.setTraversal(FolderTraversal.Deep); SearchFilter searchFilter = new SearchFilter.IsEqualTo(FolderSchema.DisplayName, folderName); try { FindFoldersResults foldersResults = service.findFolders(WellKnownFolderName.Root,searchFilter, view); ArrayList<Folder> folderIds = foldersResults.getFolders(); if(folderIds.size() > 1){ throw new ProcessException("More than 1 folder found with the name " + folderName); } folder = Folder.bind(service, folderIds.get(0).getId()); } catch (Exception e) { throw new ProcessException("Search for Inbox Subfolder failed.", e); } } return folder; }
/** * Obtains a grouped list of item by searching the contents of this folder. * Calling this method results in a call to EWS. * * @param view The view controlling the number of folder returned. * @param groupBy The grouping criteria. * @return A collection of grouped item representing the contents of this * folder. * @throws Exception the exception */ public GroupedFindItemsResults<Item> findItems(ItemView view, Grouping groupBy) throws Exception { EwsUtilities.validateParam(groupBy, "groupBy"); return this.findItems((SearchFilter) null, view, groupBy); }
public Object createServiceObjectWithServiceParam( ExchangeService srv) throws Exception { return new Folder(srv); } }, null);
/** * Obtains a list of folder by searching the sub-folder of this folder. * Calling this method results in a call to EWS. * * @param view The view controlling the number of folder returned. * @return An object representing the results of the search operation. * @throws Exception the exception */ public FindFoldersResults findFolders(FolderView view) throws Exception { this.throwIfThisIsNew(); return this.getService().findFolders(this.getId(), view); }
/** * Binds to an existing folder, whatever its actual type is, and loads the * specified set of property. Calling this method results in a call to * EWS. * * @param service , The service to use to bind to the folder. * @param id , The Id of the folder to bind to. * @return A Folder instance representing the folder corresponding to the * specified Id. * @throws Exception the exception */ public static Folder bind(ExchangeService service, FolderId id) throws Exception { return Folder.bind(service, id, PropertySet.getFirstClassProperties()); }
if (f.getDisplayName().equals(folderName)) { folders.put(folderName, f.getId()); return f.getId();
FindItemsResults<Item> findResults = service.findItems(folder.getId(), sf, view);
/** * define last message index on the server, so that on next request, we only get the newly received messages * @throws Exception */ @Override public void setLastMessageIndex() throws Exception { Folder folder = Folder.bind(service, defaultFolderId); lastMessageIndex = folder.getTotalCount(); }
private Optional<CalendarFolder> findCalendar(String calendarName) throws Exception { // NOSONAR - EWS Java API throws Exception, that's life FindFoldersResults calendarRoot = exchangeService.findFolders(WellKnownFolderName.Calendar, new FolderView(Integer.MAX_VALUE)); for (Folder folder : calendarRoot.getFolders()) { if (folder.getDisplayName().equals(calendarName)) { return Optional.of((CalendarFolder) folder); } } return Optional.empty(); }
/** * Clears the change log of the updated folder if the update succeeded. */ @Override protected void loaded() { if (this.getResult() == ServiceResult.Success) { this.folder.clearChangeLog(); } }
/** * Sets the extended property. * * @param extendedPropertyDefinition The extended property definition. * @param value The value. * @throws Exception the exception */ public void setExtendedProperty( ExtendedPropertyDefinition extendedPropertyDefinition, Object value) throws Exception { this.getExtendedProperties().setExtendedProperty( extendedPropertyDefinition, value); }
/** * True if property was removed. * * @return Extended property collection. * @throws Exception the exception */ @Override protected ExtendedPropertyCollection getExtendedProperties() throws Exception { return this.getExtendedPropertiesForService(); }
/** * Copies this folder into the specified folder. Calling this method results * in a call to EWS. * * @param destinationFolderName The name of the folder in which to copy this folder. * @return A Folder representing the copy of this folder. * @throws Exception the exception */ public Folder copy(WellKnownFolderName destinationFolderName) throws Exception { return this.copy(new FolderId(destinationFolderName)); }
/** * Empties the folder. Calling this method results in a call to EWS. * * @param deletemode the delete mode * @param deleteSubFolders Indicates whether sub-folder should also be deleted. * @throws Exception */ public void empty(DeleteMode deletemode, boolean deleteSubFolders) throws Exception { this.throwIfThisIsNew(); this.getService().emptyFolder(this.getId(), deletemode, deleteSubFolders); }
/** * Binds to an existing folder, whatever its actual type is, and loads the * specified set of property. Calling this method results in a call to * EWS. * * @param service The service to use to bind to the folder. * @param name The name of the folder to bind to. * @param propertySet The set of property to load. * @return A Folder instance representing the folder corresponding to the * specified Id. * @throws Exception the exception */ public static Folder bind(ExchangeService service, WellKnownFolderName name, PropertySet propertySet) throws Exception { return Folder.bind(service, new FolderId(name), propertySet); }
/** * Writes the Id encapsulated in the wrapper to XML. * * @param writer the writer * @throws Exception the exception */ protected void writeToXml(EwsServiceXmlWriter writer) throws Exception { this.folder.getId().writeToXml(writer); } }
Folder folder = Folder.bind(service, folderId); lastMessageIndex = folder.getTotalCount(); preFilteredItems = service.findItems(folderId, new ItemView(lastMessageIndex - firstMessageIndex + 1)).getItems(); } else {
private void discoverFolders(WellKnownFolderName wellKnownFolderName) throws Exception { // NOSONAR - EWS Java API throws Exception, that's life FindFoldersResults folders = exchangeService.findFolders(wellKnownFolderName, new FolderView(Integer.MAX_VALUE)); for (Folder folder : folders.getFolders()) { LOG.info("Found folder: " + wellKnownFolderName.name() + " - " + folder.getDisplayName()); } }
/** * Clears the change log of the created folder if the creation succeeded. */ @Override protected void loaded() { if (this.getResult() == ServiceResult.Success) { this.folder.clearChangeLog(); } }
/** * Removes an extended property. * * @param extendedPropertyDefinition The extended property definition. * @return True if property was removed. * @throws Exception the exception */ public boolean removeExtendedProperty( ExtendedPropertyDefinition extendedPropertyDefinition) throws Exception { return this.getExtendedProperties().removeExtendedProperty( extendedPropertyDefinition); }