microsoft.exchange.webservices.data.search.FindFoldersResults Java Examples

The following examples show how to use microsoft.exchange.webservices.data.search.FindFoldersResults. 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: ExchangeService.java    From ews-java-api with MIT License 5 votes vote down vote up
/**
 * 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();
}
 
Example #2
Source File: ExchangeService.java    From ews-java-api with MIT License 5 votes vote down vote up
/**
 * 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 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,
    FolderView view) throws Exception {
  EwsUtilities.validateParam(parentFolderId, "parentFolderId");
  EwsUtilities.validateParam(view, "view");

  List<FolderId> folderIdArray = new ArrayList<FolderId>();
  folderIdArray.add(parentFolderId);

  ServiceResponseCollection<FindFolderResponse> responses = this
      .internalFindFolders(folderIdArray, null, /* searchFilter */
          view, ServiceErrorHandling.ThrowOnError);

  return responses.getResponseAtIndex(0).getResults();
}
 
Example #3
Source File: ExchangeFileSystem.java    From iaf with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #4
Source File: ExchangeFileSystem.java    From iaf with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #5
Source File: Folder.java    From ews-java-api with MIT License 3 votes vote down vote up
/**
 * 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);
}
 
Example #6
Source File: ExchangeService.java    From ews-java-api with MIT License 2 votes vote down vote up
/**
 * 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);
}
 
Example #7
Source File: ExchangeService.java    From ews-java-api with MIT License 2 votes vote down vote up
/**
 * 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);
}
 
Example #8
Source File: FindFolderResponse.java    From ews-java-api with MIT License 2 votes vote down vote up
/**
 * Gets the results of the search operation.
 *
 * @return the results
 */
public FindFoldersResults getResults() {
  return this.results;
}
 
Example #9
Source File: Folder.java    From ews-java-api with MIT License 2 votes vote down vote up
/**
 * 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);
}