microsoft.exchange.webservices.data.search.FindItemsResults Java Examples
The following examples show how to use
microsoft.exchange.webservices.data.search.FindItemsResults.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ExchangeFileSystem.java From iaf with Apache License 2.0 | 7 votes |
@Override public Iterator<Item> listFiles(String folder) throws FileSystemException { try { FolderId folderId = findFolder(basefolderId,folder); ItemView view = new ItemView(getMaxNumberOfMessagesToList()); view.getOrderBy().add(ItemSchema.DateTimeReceived, SortDirection.Ascending); FindItemsResults<Item> findResults; if ("NDR".equalsIgnoreCase(getFilter())) { SearchFilter searchFilterBounce = new SearchFilter.IsEqualTo(ItemSchema.ItemClass, "REPORT.IPM.Note.NDR"); findResults = exchangeService.findItems(folderId,searchFilterBounce, view); } else { findResults = exchangeService.findItems(folderId, view); } if (findResults.getTotalCount() == 0) { return null; } else { return findResults.getItems().iterator(); } } catch (Exception e) { throw new FileSystemException("Cannot list messages in folder ["+folder+"]", e); } }
Example #2
Source File: ExchangeService.java From ews-java-api with MIT License | 5 votes |
/** * Obtains a list of item by searching the contents of a specific folder. * Calling this method results in a call to EWS. * * @param parentFolderId the parent folder id * @param queryString the query string * @param view the view * @return An object representing the results of the search operation. * @throws Exception the exception */ public FindItemsResults<Item> findItems(FolderId parentFolderId, String queryString, ItemView view) throws Exception { EwsUtilities.validateParamAllowNull(queryString, "queryString"); List<FolderId> folderIdArray = new ArrayList<FolderId>(); folderIdArray.add(parentFolderId); ServiceResponseCollection<FindItemResponse<Item>> responses = this .findItems(folderIdArray, null, /* searchFilter */ queryString, view, null, /* groupBy */ ServiceErrorHandling.ThrowOnError); return responses.getResponseAtIndex(0).getResults(); }
Example #3
Source File: ExchangeFileSystem.java From iaf with Apache License 2.0 | 5 votes |
@Override public boolean exists(Item f) throws FileSystemException { try { ItemView view = new ItemView(1); view.getOrderBy().add(ItemSchema.DateTimeReceived, SortDirection.Ascending); SearchFilter searchFilter = new SearchFilter.IsEqualTo(ItemSchema.Id, f.getId().toString()); FindItemsResults<Item> findResults; findResults = exchangeService.findItems(basefolderId,searchFilter, view); return findResults.getTotalCount()!=0; } catch (Exception e) { throw new FileSystemException(e); } }
Example #4
Source File: CalendarFolder.java From ews-java-api with MIT License | 5 votes |
/** * Obtains a list of appointments by searching the contents of this folder * and performing recurrence expansion for recurring appointments. Calling * this method results in a call to EWS. * * @param view the view * @return An object representing the results of the search operation. * @throws Exception the exception */ public FindItemsResults<Appointment> findAppointments(CalendarView view) throws Exception { EwsUtilities.validateParam(view, "view"); ServiceResponseCollection<FindItemResponse<Appointment>> responses = this.internalFindItems((SearchFilter) null, view, null /* groupBy */); return responses.getResponseAtIndex(0).getResults(); }
Example #5
Source File: Folder.java From ews-java-api with MIT License | 5 votes |
/** * Find item. * * @param view The view controlling the number of item returned. * @return FindItems results collection. * @throws Exception the exception */ public FindItemsResults<Item> findItems(ItemView view) throws Exception { ServiceResponseCollection<FindItemResponse<Item>> responses = this .internalFindItems((SearchFilter) null, view, null /* groupBy */); return responses.getResponseAtIndex(0).getResults(); }
Example #6
Source File: Folder.java From ews-java-api with MIT License | 5 votes |
/** * Find item. * * @param queryString query string to be used for indexed search * @param view The view controlling the number of item returned. * @return FindItems results collection. * @throws Exception the exception */ public FindItemsResults<Item> findItems(String queryString, ItemView view) throws Exception { EwsUtilities.validateParamAllowNull(queryString, "queryString"); ServiceResponseCollection<FindItemResponse<Item>> responses = this .internalFindItems(queryString, view, null /* groupBy */); return responses.getResponseAtIndex(0).getResults(); }
Example #7
Source File: ExchangeService.java From ews-java-api with MIT License | 5 votes |
/** * Obtains a list of appointments by searching the contents of a specific * folder. Calling this method results in a call to EWS. * * @param parentFolderId the parent folder id * @param calendarView the calendar view * @return A collection of appointments representing the contents of the * specified folder. * @throws Exception the exception */ public FindItemsResults<Appointment> findAppointments( FolderId parentFolderId, CalendarView calendarView) throws Exception { List<FolderId> folderIdArray = new ArrayList<FolderId>(); folderIdArray.add(parentFolderId); ServiceResponseCollection<FindItemResponse<Appointment>> response = this .findItems(folderIdArray, null, /* searchFilter */ null /* queryString */, calendarView, null, /* groupBy */ ServiceErrorHandling.ThrowOnError); return response.getResponseAtIndex(0).getResults(); }
Example #8
Source File: ExchangeService.java From ews-java-api with MIT License | 5 votes |
/** * Obtains a list of item by searching the contents of a specific folder. * Calling this method results in a call to EWS. * * @param parentFolderId the parent folder id * @param view the view * @return An object representing the results of the search operation. * @throws Exception the exception */ public FindItemsResults<Item> findItems(FolderId parentFolderId, ItemView view) throws Exception { List<FolderId> folderIdArray = new ArrayList<FolderId>(); folderIdArray.add(parentFolderId); ServiceResponseCollection<FindItemResponse<Item>> responses = this .findItems(folderIdArray, null, /* searchFilter */ null, /* queryString */ view, null, /* groupBy */ ServiceErrorHandling.ThrowOnError); return responses.getResponseAtIndex(0).getResults(); }
Example #9
Source File: ExchangeService.java From ews-java-api with MIT License | 5 votes |
/** * Obtains a list of item by searching the contents of a specific folder. * Calling this method results in a call to EWS. * * @param parentFolderId the parent folder id * @param searchFilter the search filter * @param view the view * @return An object representing the results of the search operation. * @throws Exception the exception */ public FindItemsResults<Item> findItems(FolderId parentFolderId, SearchFilter searchFilter, ItemView view) throws Exception { EwsUtilities.validateParamAllowNull(searchFilter, "searchFilter"); List<FolderId> folderIdArray = new ArrayList<FolderId>(); folderIdArray.add(parentFolderId); ServiceResponseCollection<FindItemResponse<Item>> responses = this .findItems(folderIdArray, searchFilter, null, /* queryString */ view, null, /* groupBy */ ServiceErrorHandling.ThrowOnError); return responses.getResponseAtIndex(0).getResults(); }
Example #10
Source File: FindItemResponse.java From ews-java-api with MIT License | 4 votes |
/** * Reads response elements from XML. * * @param reader ,The reader * @throws Exception the exception */ @Override protected void readElementsFromXml(EwsServiceXmlReader reader) throws Exception { reader.readStartElement(XmlNamespace.Messages, XmlElementNames.RootFolder); int totalItemsInView = reader.readAttributeValue(Integer.class, XmlAttributeNames.TotalItemsInView); boolean moreItemsAvailable = !reader.readAttributeValue(Boolean.class, XmlAttributeNames.IncludesLastItemInRange); // Ignore IndexedPagingOffset attribute if moreItemsAvailable is false. Integer nextPageOffset = moreItemsAvailable ? reader .readNullableAttributeValue(Integer.class, XmlAttributeNames.IndexedPagingOffset) : null; if (!this.isGrouped) { this.results = new FindItemsResults<TItem>(); this.results.setTotalCount(totalItemsInView); this.results.setNextPageOffset(nextPageOffset); this.results.setMoreAvailable(moreItemsAvailable); internalReadItemsFromXml(reader, this.propertySet, this.results .getItems()); } else { this.groupedFindResults = new GroupedFindItemsResults<TItem>(); this.groupedFindResults.setTotalCount(totalItemsInView); this.groupedFindResults.setNextPageOffset(nextPageOffset); this.groupedFindResults.setMoreAvailable(moreItemsAvailable); reader.readStartElement(XmlNamespace.Types, XmlElementNames.Groups); if (!reader.isEmptyElement()) { do { reader.read(); if (reader.isStartElement(XmlNamespace.Types, XmlElementNames.GroupedItems)) { String groupIndex = reader.readElementValue( XmlNamespace.Types, XmlElementNames.GroupIndex); ArrayList<TItem> itemList = new ArrayList<TItem>(); internalReadItemsFromXml(reader, this.propertySet, itemList); reader.readEndElement(XmlNamespace.Types, XmlElementNames.GroupedItems); this.groupedFindResults.getItemGroups().add( new ItemGroup<TItem>(groupIndex, itemList)); } } while (!reader.isEndElement(XmlNamespace.Types, XmlElementNames.Groups)); } else { reader.read(); } } reader .readEndElement(XmlNamespace.Messages, XmlElementNames.RootFolder); }
Example #11
Source File: ConsumeEWS.java From nifi with Apache License 2.0 | 4 votes |
/** * Fills the internal message queue if such queue is empty. This is due to * the fact that per single session there may be multiple messages retrieved * from the email server (see FETCH_SIZE). */ protected void fillMessageQueueIfNecessary(ProcessContext context) throws ProcessException { if (this.messageQueue.isEmpty()) { ExchangeService service = this.initializeIfNecessary(context); boolean deleteOnRead = context.getProperty(SHOULD_DELETE_MESSAGES).getValue().equals("true"); boolean markAsRead = context.getProperty(SHOULD_MARK_READ).getValue().equals("true"); String includeHeaders = context.getProperty(INCLUDE_EMAIL_HEADERS).getValue(); String excludeHeaders = context.getProperty(EXCLUDE_EMAIL_HEADERS).getValue(); List<String> includeHeadersList = null; List<String> excludeHeadersList = null; if (!StringUtils.isEmpty(includeHeaders)) { includeHeadersList = Arrays.asList(includeHeaders.split(",")); } if (!StringUtils.isEmpty(excludeHeaders)) { excludeHeadersList = Arrays.asList(excludeHeaders.split(",")); } try { //Get Folder Folder folder = getFolder(service); ItemView view = new ItemView(messageQueue.remainingCapacity()); view.getOrderBy().add(ItemSchema.DateTimeReceived, SortDirection.Ascending); SearchFilter sf = new SearchFilter.SearchFilterCollection(LogicalOperator.And, new SearchFilter.IsEqualTo(EmailMessageSchema.IsRead, false)); FindItemsResults<Item> findResults = service.findItems(folder.getId(), sf, view); if(findResults == null || findResults.getItems().size()== 0){ return; } service.loadPropertiesForItems(findResults, PropertySet.FirstClassProperties); for (Item item : findResults) { EmailMessage ewsMessage = (EmailMessage) item; messageQueue.add(parseMessage(ewsMessage,includeHeadersList,excludeHeadersList)); if(deleteOnRead){ ewsMessage.delete(DeleteMode.HardDelete); } else if(markAsRead){ ewsMessage.setIsRead(true); ewsMessage.update(ConflictResolutionMode.AlwaysOverwrite); } } service.close(); } catch (Exception e) { throw new ProcessException("Failed retrieving new messages from EWS.", e); } } }
Example #12
Source File: ConsumeEWS.java From localization_nifi with Apache License 2.0 | 4 votes |
/** * Fills the internal message queue if such queue is empty. This is due to * the fact that per single session there may be multiple messages retrieved * from the email server (see FETCH_SIZE). */ protected void fillMessageQueueIfNecessary(ProcessContext context) throws ProcessException { if (this.messageQueue.isEmpty()) { ExchangeService service = this.initializeIfNecessary(context); boolean deleteOnRead = context.getProperty(SHOULD_DELETE_MESSAGES).getValue().equals("true"); boolean markAsRead = context.getProperty(SHOULD_MARK_READ).getValue().equals("true"); try { //Get Folder Folder folder = getFolder(service); ItemView view = new ItemView(messageQueue.remainingCapacity()); view.getOrderBy().add(ItemSchema.DateTimeReceived, SortDirection.Ascending); SearchFilter sf = new SearchFilter.SearchFilterCollection(LogicalOperator.And, new SearchFilter.IsEqualTo(EmailMessageSchema.IsRead, false)); FindItemsResults<Item> findResults = service.findItems(folder.getId(), sf, view); if(findResults == null || findResults.getItems().size()== 0){ return; } service.loadPropertiesForItems(findResults, PropertySet.FirstClassProperties); for (Item item : findResults) { EmailMessage ewsMessage = (EmailMessage) item; messageQueue.add(parseMessage(ewsMessage)); if(deleteOnRead){ ewsMessage.delete(DeleteMode.HardDelete); } else if(markAsRead){ ewsMessage.setIsRead(true); ewsMessage.update(ConflictResolutionMode.AlwaysOverwrite); } } service.close(); } catch (Exception e) { throw new ProcessException("Failed retrieving new messages from EWS.", e); } } }
Example #13
Source File: Folder.java From ews-java-api with MIT License | 3 votes |
/** * Find 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. * @return FindItems results collection. * @throws Exception the exception */ public FindItemsResults<Item> findItems(SearchFilter searchFilter, ItemView view) throws Exception { EwsUtilities.validateParamAllowNull(searchFilter, "searchFilter"); ServiceResponseCollection<FindItemResponse<Item>> responses = this .internalFindItems(searchFilter, view, null /* groupBy */); return responses.getResponseAtIndex(0).getResults(); }
Example #14
Source File: ExchangeService.java From ews-java-api with MIT License | 3 votes |
/** * Obtains a list of item by searching the contents of a specific folder. * Calling this method results in a call to EWS. * * @param parentFolderName the parent folder name * @param searchFilter the search filter * @param view the view * @return An object representing the results of the search operation. * @throws Exception the exception */ public FindItemsResults<Item> findItems( WellKnownFolderName parentFolderName, SearchFilter searchFilter, ItemView view) throws Exception { return this.findItems(new FolderId(parentFolderName), searchFilter, view); }
Example #15
Source File: ExchangeService.java From ews-java-api with MIT License | 3 votes |
/** * Obtains a list of item by searching the contents of a specific folder. * Calling this method results in a call to EWS. * * @param parentFolderName the parent folder name * @param queryString the query string * @param view the view * @return An object representing the results of the search operation. * @throws Exception the exception */ public FindItemsResults<Item> findItems( WellKnownFolderName parentFolderName, String queryString, ItemView view) throws Exception { return this .findItems(new FolderId(parentFolderName), queryString, view); }
Example #16
Source File: ExchangeService.java From ews-java-api with MIT License | 2 votes |
/** * Obtains a list of item by searching the contents of a specific folder. * Calling this method results in a call to EWS. * * @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 FindItemsResults<Item> findItems( WellKnownFolderName parentFolderName, ItemView view) throws Exception { return this.findItems(new FolderId(parentFolderName), (SearchFilter) null, view); }
Example #17
Source File: ExchangeService.java From ews-java-api with MIT License | 2 votes |
/** * Obtains a list of appointments by searching the contents of a specific * folder. Calling this method results in a call to EWS. * * @param parentFolderName the parent folder name * @param calendarView the calendar view * @return A collection of appointments representing the contents of the * specified folder. * @throws Exception the exception */ public FindItemsResults<Appointment> findAppointments( WellKnownFolderName parentFolderName, CalendarView calendarView) throws Exception { return this.findAppointments(new FolderId(parentFolderName), calendarView); }
Example #18
Source File: FindItemResponse.java From ews-java-api with MIT License | 2 votes |
/** * Gets the results of the search operation. * * @return the results */ public FindItemsResults<TItem> getResults() { return results; }