Java源码示例:microsoft.exchange.webservices.data.search.filter.SearchFilter
示例1
/**
* Tries to read element from XML.
*
* @param reader the reader
* @return True if element was read.
* @throws Exception the exception
*/
@Override
public boolean tryReadElementFromXml(EwsServiceXmlReader reader)
throws Exception {
if (reader.getLocalName().equalsIgnoreCase(
XmlElementNames.BaseFolderIds)) {
this.rootFolderIds.internalClear();
this.rootFolderIds.loadFromXml(reader, reader.getLocalName());
return true;
} else if (reader.getLocalName().equalsIgnoreCase(
XmlElementNames.Restriction)) {
reader.read();
this.searchFilter = SearchFilter.loadFromXml(reader);
return true;
} else {
return false;
}
}
示例2
/**
* Finds item.
*
* @param <TItem> The type of item
* @param parentFolderIds The parent folder ids.
* @param searchFilter The search filter. Available search filter classes include
* SearchFilter.IsEqualTo, SearchFilter.ContainsSubstring and
* SearchFilter.SearchFilterCollection
* @param queryString the query string
* @param view The view controlling the number of folder returned.
* @param groupBy The group by.
* @param errorHandlingMode Indicates the type of error handling should be done.
* @return Service response collection.
* @throws Exception the exception
*/
public <TItem extends Item> ServiceResponseCollection<FindItemResponse<TItem>> findItems(
Iterable<FolderId> parentFolderIds, SearchFilter searchFilter, String queryString, ViewBase view,
Grouping groupBy, ServiceErrorHandling errorHandlingMode) throws Exception {
EwsUtilities.validateParamCollection(parentFolderIds.iterator(),
"parentFolderIds");
EwsUtilities.validateParam(view, "view");
EwsUtilities.validateParamAllowNull(groupBy, "groupBy");
EwsUtilities.validateParamAllowNull(queryString, "queryString");
EwsUtilities.validateParamAllowNull(searchFilter, "searchFilter");
FindItemRequest<TItem> request = new FindItemRequest<TItem>(this,
errorHandlingMode);
request.getParentFolderIds().addRangeFolderId(parentFolderIds);
request.setSearchFilter(searchFilter);
request.setQueryString(queryString);
request.setView(view);
request.setGroupBy(groupBy);
return request.execute();
}
示例3
/**
* Obtains a grouped 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
* @param groupBy the group by
* @return A list of item containing the contents of the specified folder.
* @throws Exception the exception
*/
public GroupedFindItemsResults<Item> findItems(FolderId parentFolderId,
SearchFilter searchFilter, ItemView view, Grouping groupBy)
throws Exception {
EwsUtilities.validateParam(groupBy, "groupBy");
EwsUtilities.validateParamAllowNull(searchFilter, "searchFilter");
List<FolderId> folderIdArray = new ArrayList<FolderId>();
folderIdArray.add(parentFolderId);
ServiceResponseCollection<FindItemResponse<Item>> responses = this
.findItems(folderIdArray, searchFilter, null, /* queryString */
view, groupBy, ServiceErrorHandling.ThrowOnError);
return responses.getResponseAtIndex(0).getGroupedFindResults();
}
示例4
/**
* Retrieves a collection of all Conversations in the specified Folder.
*
* @param view The view controlling the number of conversations returned.
* @param filter The search filter. Only search filter class supported
* SearchFilter.IsEqualTo
* @param folderId The Id of the folder in which to search for conversations.
* @throws Exception
*/
private Collection<Conversation> findConversation(
ConversationIndexedItemView view, SearchFilter.IsEqualTo filter,
FolderId folderId) throws Exception {
EwsUtilities.validateParam(view, "view");
EwsUtilities.validateParamAllowNull(filter, "filter");
EwsUtilities.validateParam(folderId, "folderId");
EwsUtilities.validateMethodVersion(this,
ExchangeVersion.Exchange2010_SP1, "FindConversation");
FindConversationRequest request = new FindConversationRequest(this);
request.setIndexedItemView(view);
request.setConversationViewFilter(filter);
request.setFolderId(new FolderIdWrapper(folderId));
return request.execute().getConversations();
}
示例5
@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);
}
}
示例6
/**
* Sets the search filter.
*
* @param searchFilter the new search filter
*/
public void setSearchFilter(SearchFilter searchFilter) {
if (this.searchFilter != null) {
this.searchFilter.removeChangeEvent(this);
}
if (this.canSetFieldValue(this.searchFilter, searchFilter)) {
this.searchFilter = searchFilter;
this.changed();
}
if (this.searchFilter != null) {
this.searchFilter.addOnChangeEvent(this);
}
}
示例7
/**
* Finds folder.
*
* @param parentFolderIds The parent folder ids.
* @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.
* @param errorHandlingMode Indicates the type of error handling should be done.
* @return Collection of service response.
* @throws Exception the exception
*/
private ServiceResponseCollection<FindFolderResponse> internalFindFolders(
Iterable<FolderId> parentFolderIds, SearchFilter searchFilter,
FolderView view, ServiceErrorHandling errorHandlingMode)
throws Exception {
FindFolderRequest request = new FindFolderRequest(this,
errorHandlingMode);
request.getParentFolderIds().addRangeFolderId(parentFolderIds);
request.setSearchFilter(searchFilter);
request.setView(view);
return request.execute();
}
示例8
/**
* Obtains a list of folder by searching the sub-folder of the specified
* folder.
*
* @param parentFolderId The Id 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(FolderId parentFolderId,
SearchFilter searchFilter, FolderView view) throws Exception {
EwsUtilities.validateParam(parentFolderId, "parentFolderId");
EwsUtilities.validateParam(view, "view");
EwsUtilities.validateParamAllowNull(searchFilter, "searchFilter");
List<FolderId> folderIdArray = new ArrayList<FolderId>();
folderIdArray.add(parentFolderId);
ServiceResponseCollection<FindFolderResponse> responses = this
.internalFindFolders(folderIdArray, searchFilter, view,
ServiceErrorHandling.ThrowOnError);
return responses.getResponseAtIndex(0).getResults();
}
示例9
/**
* 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();
}
示例10
/**
* 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);
}
示例11
/**
* 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();
}
示例12
/**
* 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();
}
示例13
public FolderId findFolder(FolderId baseFolderId, String folderName) throws Exception {
FindFoldersResults findFoldersResultsIn;
FolderId result;
FolderView folderViewIn = new FolderView(10);
if (StringUtils.isNotEmpty(folderName)) {
log.debug("searching folder ["+folderName+"]");
SearchFilter searchFilterIn = new SearchFilter.IsEqualTo(FolderSchema.DisplayName, folderName);
if (baseFolderId==null) {
findFoldersResultsIn = exchangeService.findFolders(WellKnownFolderName.MsgFolderRoot, searchFilterIn, folderViewIn);
} else {
findFoldersResultsIn = exchangeService.findFolders(baseFolderId, searchFilterIn, folderViewIn);
}
if (findFoldersResultsIn.getTotalCount() == 0) {
if(log.isDebugEnabled()) log.debug("no folder found with name [" + folderName + "] in basefolder ["+baseFolderId+"]");
return null;
}
if (findFoldersResultsIn.getTotalCount() > 1) {
if (log.isDebugEnabled()) {
for (Folder folder:findFoldersResultsIn.getFolders()) {
log.debug("found folder ["+folder.getDisplayName()+"]");
}
}
throw new ConfigurationException("multiple folders found with name ["+ folderName + "]");
}
} else {
//findFoldersResultsIn = exchangeService.findFolders(baseFolderId, folderViewIn);
return baseFolderId;
}
if (findFoldersResultsIn.getFolders().isEmpty()) {
result=baseFolderId;
} else {
result=findFoldersResultsIn.getFolders().get(0).getId();
}
return result;
}
示例14
@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);
}
}
示例15
public FolderId getFolderIdByFolderName(String folderName) throws Exception{
FindFoldersResults findResults;
findResults = exchangeService.findFolders(basefolderId, new SearchFilter.IsEqualTo(FolderSchema.DisplayName, folderName), new FolderView(Integer.MAX_VALUE));
if (log.isDebugEnabled()) {
log.debug("amount of folders with name: " + folderName + " = " + findResults.getTotalCount());
log.debug("found folder with name: " + findResults.getFolders().get(0).getDisplayName());
}
FolderId folderId = findResults.getFolders().get(0).getId();
return folderId;
}
示例16
/**
* 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);
}
}
}
示例17
/**
* Gets or sets the search filter.
*/
protected SearchFilter.IsEqualTo getConversationViewFilter() {
return this.searchFilter;
}
示例18
/**
* 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);
}
}
}
示例19
/**
* 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);
}
示例20
/**
* Obtains a grouped list of item by searching the contents of a specific
* folder. Calling this method results in a call to EWS.
*
* @param <TItem> the generic type
* @param cls the cls
* @param parentFolderId the parent folder id
* @param searchFilter the search filter
* @param view the view
* @param groupBy the group by
* @return A list of item containing the contents of the specified folder.
* @throws Exception the exception
*/
protected <TItem extends Item> ServiceResponseCollection<FindItemResponse<TItem>> findItems(
Class<TItem> cls, FolderId parentFolderId,
SearchFilter searchFilter, ViewBase view, Grouping groupBy)
throws Exception {
List<FolderId> folderIdArray = new ArrayList<FolderId>();
folderIdArray.add(parentFolderId);
return this.findItems(folderIdArray, searchFilter, null, /* queryString */
view, groupBy, ServiceErrorHandling.ThrowOnError);
}
示例21
/**
* 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();
}
示例22
/**
* 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.
* @param groupBy The group by.
* @return A collection of grouped item representing the contents of this
* folder.
* @throws Exception the exception
*/
public GroupedFindItemsResults<Item> findItems(SearchFilter searchFilter,
ItemView view, Grouping groupBy) throws Exception {
EwsUtilities.validateParam(groupBy, "groupBy");
EwsUtilities.validateParamAllowNull(searchFilter, "searchFilter");
ServiceResponseCollection<FindItemResponse<Item>> responses = this
.internalFindItems(searchFilter, view, groupBy);
return responses.getResponseAtIndex(0).getGroupedFindResults();
}
示例23
/**
* 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);
}
示例24
/**
* 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);
}
示例25
/**
* Gets the search filter associated with the search folder.
* Available search filter classes include SearchFilter.IsEqualTo,
* SearchFilter.ContainsSubstring and SearchFilter.SearchFilterCollection.
*
* @return the search filter
*/
public SearchFilter getSearchFilter() {
return searchFilter;
}
示例26
/**
* 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);
}
示例27
/**
* 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);
}
示例28
/**
* Obtains a grouped 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
* @param groupBy the group by
* @return A collection of grouped item containing the contents of the
* specified.
* @throws Exception the exception
*/
public GroupedFindItemsResults<Item> findItems(
WellKnownFolderName parentFolderName, SearchFilter searchFilter,
ItemView view, Grouping groupBy) throws Exception {
return this.findItems(new FolderId(parentFolderName), searchFilter, view, groupBy);
}
示例29
public void setConversationViewFilter(SearchFilter.IsEqualTo value) {
this.searchFilter = value;
}
示例30
/**
* Gets the search filter. Available search filter classes include
* SearchFilter.IsEqualTo, SearchFilter.ContainsSubstring and
* SearchFilter.SearchFilterCollection. If SearchFilter is null, no search
* filter are applied.
*
* @return the search filter
*/
public SearchFilter getSearchFilter() {
return searchFilter;
}