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 list of folder by searching the sub-folder of the specified * folder. * * @param parentFolderName the parent folder name * @param view the view * @return An object representing the results of the search operation. * @throws Exception the exception */ public FindFoldersResults findFolders(WellKnownFolderName parentFolderName, FolderView view) throws Exception { return this.findFolders(new FolderId(parentFolderName), view); }
/** * Obtains a list of folder by searching the sub-folder of the specified * folder. * * @param parentFolderName The name of the folder in which to search for folder. * @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(WellKnownFolderName parentFolderName, SearchFilter searchFilter, FolderView view) throws Exception { return this.findFolders(new FolderId(parentFolderName), searchFilter, view); }
/** * 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); }
/** * 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); }
/** * Obtains a list of folder by searching the sub-folder of the specified * folder. * * @param parentFolderName the parent folder name * @param view the view * @return An object representing the results of the search operation. * @throws Exception the exception */ public FindFoldersResults findFolders(WellKnownFolderName parentFolderName, FolderView view) throws Exception { return this.findFolders(new FolderId(parentFolderName), view); }
/** * Obtains a list of folder by searching the sub-folder of the specified * folder. * * @param parentFolderName The name of the folder in which to search for folder. * @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(WellKnownFolderName parentFolderName, SearchFilter searchFilter, FolderView view) throws Exception { return this.findFolders(new FolderId(parentFolderName), searchFilter, view); }
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(); }
/** * 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); }
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()); } }
/** * 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); }
private Folder getAllItemsFolder() throws Exception { final FolderId rootFolderId = new FolderId(WellKnownFolderName.Root); final FolderView folderView = new FolderView(MAX_RESULTS); folderView.setTraversal(FolderTraversal.Shallow); final SearchFilter searchFilter1 = new SearchFilter.IsEqualTo(PR_ALL_FOLDERS, "2"); final SearchFilter searchFilter2 = new SearchFilter.IsEqualTo(FolderSchema.DisplayName, "allitems"); final SearchFilter.SearchFilterCollection searchFilterCollection = new SearchFilter.SearchFilterCollection( LogicalOperator.And); searchFilterCollection.add(searchFilter1); searchFilterCollection.add(searchFilter2); final FindFoldersResults findFoldersResults = service.findFolders(rootFolderId, searchFilterCollection, folderView); if (findFoldersResults.getFolders().size() == 0) { return null; } return findFoldersResults.getFolders().iterator().next(); }
view.getPropertySet().add(FolderSchema.DisplayName); view.setTraversal(FolderTraversal.Deep); FindFoldersResults findFolderResults = service.findFolders(rootFolderId, view);
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; }