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; }
FindItemsResults<Item> findResults = service.findItems(folder.getId(), sf, view);
/** * 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); } }
/** * Find item. * * @param <TItem> The type of the item. * @param queryString query string to be used for indexed search * @param view The view controlling the number of item returned. * @param groupBy The group by. * @return FindItems response collection. * @throws Exception the exception */ <TItem extends Item> ServiceResponseCollection<FindItemResponse<TItem>> internalFindItems(String queryString, ViewBase view, Grouping groupBy) throws Exception { ArrayList<FolderId> folderIdArry = new ArrayList<FolderId>(); folderIdArry.add(this.getId()); this.throwIfThisIsNew(); return this.getService().findItems(folderIdArry, null, /* searchFilter */ queryString, view, groupBy, ServiceErrorHandling.ThrowOnError); }
/** * Find item. * * @param <TItem> The type of the item. * @param searchFilter The search filter. Available search filter classes include * SearchFilter.IsEqualTo, SearchFilter.ContainsSubstring and * SearchFilter.SearchFilterCollection * @param view The view controlling the number of item returned. * @param groupBy The group by. * @return FindItems response collection. * @throws Exception the exception */ <TItem extends Item> ServiceResponseCollection<FindItemResponse<TItem>> internalFindItems(SearchFilter searchFilter, ViewBase view, Grouping groupBy) throws Exception { ArrayList<FolderId> folderIdArry = new ArrayList<FolderId>(); folderIdArry.add(this.getId()); this.throwIfThisIsNew(); return this.getService().findItems(folderIdArry, searchFilter, null, /* queryString */ view, groupBy, ServiceErrorHandling.ThrowOnError); }
/** * 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); }
/** * 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); }
/** * Deletes the object. * * @param deleteMode the delete mode * @param sendCancellationsMode Indicates whether meeting cancellation messages should be * sent. * @param affectedTaskOccurrences Indicate which occurrence of a recurring task should be * deleted. * @throws Exception the exception */ @Override protected void internalDelete(DeleteMode deleteMode, SendCancellationsMode sendCancellationsMode, AffectedTaskOccurrence affectedTaskOccurrences) throws Exception { try { this.throwIfThisIsNew(); } catch (InvalidOperationException e) { LOG.error(e); } this.getService().deleteFolder(this.getId(), deleteMode); }
/** * Obtains a list of folder by searching the sub-folder of this folder. * Calling this method results in a call to EWS. * * @param searchFilter The search filter. Available search filter classes include * SearchFilter.IsEqualTo, SearchFilter.ContainsSubstring and * SearchFilter.SearchFilterCollection * @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(SearchFilter searchFilter, FolderView view) throws Exception { this.throwIfThisIsNew(); return this.getService().findFolders(this.getId(), searchFilter, view); }
/** * Copies this folder into a specific folder. Calling this method results in * a call to EWS. * * @param destinationFolderId The Id 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(FolderId destinationFolderId) throws Exception { this.throwIfThisIsNew(); EwsUtilities.validateParam(destinationFolderId, "destinationFolderId"); return this.getService().copyFolder(this.getId(), destinationFolderId); }
/** * Moves this folder to a specific folder. Calling this method results in a * call to EWS. * * @param destinationFolderId The Id of the folder in which to move this folder. * @return A new folder representing this folder in its new location. After * Move completes, this folder does not exist anymore. * @throws Exception the exception */ public Folder move(FolderId destinationFolderId) throws Exception { this.throwIfThisIsNew(); EwsUtilities.validateParam(destinationFolderId, "destinationFolderId"); return this.getService().moveFolder(this.getId(), destinationFolderId); }
/** * 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); } }
/** * Find item. * * @param <TItem> The type of the item. * @param searchFilter The search filter. Available search filter classes include * SearchFilter.IsEqualTo, SearchFilter.ContainsSubstring and * SearchFilter.SearchFilterCollection * @param view The view controlling the number of item returned. * @param groupBy The group by. * @return FindItems response collection. * @throws Exception the exception */ <TItem extends Item> ServiceResponseCollection<FindItemResponse<TItem>> internalFindItems(SearchFilter searchFilter, ViewBase view, Grouping groupBy) throws Exception { ArrayList<FolderId> folderIdArry = new ArrayList<FolderId>(); folderIdArry.add(this.getId()); this.throwIfThisIsNew(); return this.getService().findItems(folderIdArry, searchFilter, null, /* queryString */ view, groupBy, ServiceErrorHandling.ThrowOnError); }
/** * Find item. * * @param <TItem> The type of the item. * @param queryString query string to be used for indexed search * @param view The view controlling the number of item returned. * @param groupBy The group by. * @return FindItems response collection. * @throws Exception the exception */ <TItem extends Item> ServiceResponseCollection<FindItemResponse<TItem>> internalFindItems(String queryString, ViewBase view, Grouping groupBy) throws Exception { ArrayList<FolderId> folderIdArry = new ArrayList<FolderId>(); folderIdArry.add(this.getId()); this.throwIfThisIsNew(); return this.getService().findItems(folderIdArry, null, /* searchFilter */ queryString, view, groupBy, ServiceErrorHandling.ThrowOnError); }
/** * 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); }
/** * 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); }
/** * Deletes the object. * * @param deleteMode the delete mode * @param sendCancellationsMode Indicates whether meeting cancellation messages should be * sent. * @param affectedTaskOccurrences Indicate which occurrence of a recurring task should be * deleted. * @throws Exception the exception */ @Override protected void internalDelete(DeleteMode deleteMode, SendCancellationsMode sendCancellationsMode, AffectedTaskOccurrence affectedTaskOccurrences) throws Exception { try { this.throwIfThisIsNew(); } catch (InvalidOperationException e) { LOG.error(e); } this.getService().deleteFolder(this.getId(), deleteMode); }
/** * Obtains a list of folder by searching the sub-folder of this folder. * Calling this method results in a call to EWS. * * @param searchFilter The search filter. Available search filter classes include * SearchFilter.IsEqualTo, SearchFilter.ContainsSubstring and * SearchFilter.SearchFilterCollection * @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(SearchFilter searchFilter, FolderView view) throws Exception { this.throwIfThisIsNew(); return this.getService().findFolders(this.getId(), searchFilter, view); }
/** * Copies this folder into a specific folder. Calling this method results in * a call to EWS. * * @param destinationFolderId The Id 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(FolderId destinationFolderId) throws Exception { this.throwIfThisIsNew(); EwsUtilities.validateParam(destinationFolderId, "destinationFolderId"); return this.getService().copyFolder(this.getId(), destinationFolderId); }
/** * Moves this folder to a specific folder. Calling this method results in a * call to EWS. * * @param destinationFolderId The Id of the folder in which to move this folder. * @return A new folder representing this folder in its new location. After * Move completes, this folder does not exist anymore. * @throws Exception the exception */ public Folder move(FolderId destinationFolderId) throws Exception { this.throwIfThisIsNew(); EwsUtilities.validateParam(destinationFolderId, "destinationFolderId"); return this.getService().moveFolder(this.getId(), destinationFolderId); }