microsoft.exchange.webservices.data.core.service.folder.Folder Java Examples
The following examples show how to use
microsoft.exchange.webservices.data.core.service.folder.Folder.
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: EwsUtilitiesTest.java From ews-java-api with MIT License | 6 votes |
@Test public void testGetItemTypeFromXmlElementName() { assertEquals(Task.class, EwsUtilities.getItemTypeFromXmlElementName("Task")); assertEquals(EmailMessage.class, EwsUtilities.getItemTypeFromXmlElementName("Message")); assertEquals(PostItem.class, EwsUtilities.getItemTypeFromXmlElementName("PostItem")); assertEquals(SearchFolder.class, EwsUtilities.getItemTypeFromXmlElementName("SearchFolder")); assertEquals(Conversation.class, EwsUtilities.getItemTypeFromXmlElementName("Conversation")); assertEquals(Folder.class, EwsUtilities.getItemTypeFromXmlElementName("Folder")); assertEquals(CalendarFolder.class, EwsUtilities.getItemTypeFromXmlElementName("CalendarFolder")); assertEquals(MeetingMessage.class, EwsUtilities.getItemTypeFromXmlElementName("MeetingMessage")); assertEquals(Contact.class, EwsUtilities.getItemTypeFromXmlElementName("Contact")); assertEquals(Item.class, EwsUtilities.getItemTypeFromXmlElementName("Item")); assertEquals(Appointment.class, EwsUtilities.getItemTypeFromXmlElementName("CalendarItem")); assertEquals(ContactsFolder.class, EwsUtilities.getItemTypeFromXmlElementName("ContactsFolder")); assertEquals(MeetingRequest.class, EwsUtilities.getItemTypeFromXmlElementName("MeetingRequest")); assertEquals(TasksFolder.class, EwsUtilities.getItemTypeFromXmlElementName("TasksFolder")); assertEquals(MeetingCancellation.class, EwsUtilities.getItemTypeFromXmlElementName("MeetingCancellation")); assertEquals(MeetingResponse.class, EwsUtilities.getItemTypeFromXmlElementName("MeetingResponse")); assertEquals(ContactGroup.class, EwsUtilities.getItemTypeFromXmlElementName("DistributionList")); }
Example #2
Source File: MoveCopyFolderResponse.java From ews-java-api with MIT License | 6 votes |
/** * Reads response elements from XML. * * @param reader The reader. * @throws Exception the exception */ @Override protected void readElementsFromXml(EwsServiceXmlReader reader) throws Exception { super.readElementsFromXml(reader); List<Folder> folders; try { folders = reader.readServiceObjectsCollectionFromXml( XmlElementNames.Folders, this, false,/* clearPropertyBag */ null, /* requestedPropertySet */ false); /* summaryPropertiesOnly */ this.folder = folders.get(0); } catch (ServiceLocalException e) { LOG.error(e); } }
Example #3
Source File: ExchangeService.java From ews-java-api with MIT License | 6 votes |
/** * Binds to a folder. * * * @param folderId the folder id * @param propertySet the property set * @return Folder * @throws Exception the exception */ public Folder bindToFolder(FolderId folderId, PropertySet propertySet) throws Exception { EwsUtilities.validateParam(folderId, "folderId"); EwsUtilities.validateParam(propertySet, "propertySet"); GetFolderRequest request = new GetFolderRequest(this, ServiceErrorHandling.ThrowOnError); request.getFolderIds().add(folderId); request.setPropertySet(propertySet); ServiceResponseCollection<GetFolderResponse> responses = request .execute(); return responses.getResponseAtIndex(0).getFolder(); }
Example #4
Source File: CreateFolderRequest.java From ews-java-api with MIT License | 5 votes |
/** * Validate request. * * @throws Exception the exception */ @Override protected void validate() throws Exception { super.validate(); EwsUtilities.validateParam(this.getFolders(), "Folders"); // Validate each folder. for (Folder folder : this.getFolders()) { folder.validate(); } }
Example #5
Source File: ExchangeFileSystem.java From iaf with Apache License 2.0 | 5 votes |
@Override public void removeFolder(String folderName) throws FileSystemException { try { FolderId folderId = getFolderIdByFolderName(folderName); Folder folder = Folder.bind(exchangeService, folderId); folder.delete(DeleteMode.HardDelete); } catch (Exception e) { throw new FileSystemException(e); } }
Example #6
Source File: ExchangeFileSystem.java From iaf with Apache License 2.0 | 5 votes |
@Override public void createFolder(String folderName) throws FileSystemException { try { Folder folder = new Folder(exchangeService); folder.setDisplayName(folderName); folder.save(new FolderId(basefolderId.getUniqueId())); } catch (Exception e) { throw new FileSystemException(e); } }
Example #7
Source File: ExchangeFileSystem.java From iaf with Apache License 2.0 | 5 votes |
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 #8
Source File: CreateFolderResponse.java From ews-java-api with MIT License | 5 votes |
/** * Reads response elements from XML. * * @param reader The reader * @throws Exception the exception */ @Override protected void readElementsFromXml(EwsServiceXmlReader reader) throws Exception { super.readElementsFromXml(reader); List<Folder> folders = reader.readServiceObjectsCollectionFromXml( XmlElementNames.Folders, this, false, /* clearPropertyBag */ null, /* requestedPropertySet */ false); /* summaryPropertiesOnly */ this.folder = folders.get(0); }
Example #9
Source File: CreateFolderResponse.java From ews-java-api with MIT License | 5 votes |
/** * Gets the object instance. * * @param service The service. * @param xmlElementName Name of the XML element. * @return Folder * @throws Exception the exception */ private Folder getObjectInstance(ExchangeService service, String xmlElementName) throws Exception { if (this.folder != null) { return this.folder; } else { return EwsUtilities.createEwsObjectFromXmlElementName(Folder.class, service, xmlElementName); } }
Example #10
Source File: UpdateFolderResponse.java From ews-java-api with MIT License | 5 votes |
/** * Initializes a new instance of the UpdateFolderResponse class. * * @param folder The folder */ public UpdateFolderResponse(Folder folder) { super(); EwsUtilities.ewsAssert(folder != null, "UpdateFolderResponse.ctor", "folder is null"); this.folder = folder; }
Example #11
Source File: GetFolderResponse.java From ews-java-api with MIT License | 5 votes |
/** * Gets the folder instance. * * @param service The service. * @param xmlElementName Name of the XML element. * @return folder * @throws Exception the exception */ private Folder getObjectInstance(ExchangeService service, String xmlElementName) throws Exception { if (this.getFolder() != null) { return this.getFolder(); } else { return EwsUtilities.createEwsObjectFromXmlElementName(Folder.class, service, xmlElementName); } }
Example #12
Source File: GetFolderResponse.java From ews-java-api with MIT License | 5 votes |
/** * Reads response elements from XML. * * @param reader the reader * @throws Exception the exception */ @Override protected void readElementsFromXml(EwsServiceXmlReader reader) throws Exception { super.readElementsFromXml(reader); List<Folder> folders = reader.readServiceObjectsCollectionFromXml( XmlElementNames.Folders, this, true, /* clearPropertyBag */ this.propertySet, /* requestedPropertySet */ false); /* summaryPropertiesOnly */ this.folder = folders.get(0); }
Example #13
Source File: GetFolderResponse.java From ews-java-api with MIT License | 5 votes |
/** * Initializes a new instance of the GetFolderResponse class. * * @param folder The folder. * @param propertySet The property set from the request. */ public GetFolderResponse(Folder folder, PropertySet propertySet) { super(); this.folder = folder; this.propertySet = propertySet; EwsUtilities .ewsAssert(this.propertySet != null, "GetFolderResponse.ctor", "PropertySet should not be null"); }
Example #14
Source File: UpdateFolderRequest.java From ews-java-api with MIT License | 5 votes |
/** * Writes to xml. * * @param writer the writer * @throws Exception the exception */ @Override protected void writeElementsToXml(EwsServiceXmlWriter writer) throws Exception { writer.writeStartElement(XmlNamespace.Messages, XmlElementNames.FolderChanges); for (Folder folder : this.folders) { folder.writeToXmlForUpdate(writer); } writer.writeEndElement(); }
Example #15
Source File: UpdateFolderRequest.java From ews-java-api with MIT License | 5 votes |
/** * validates request. * * @throws ServiceLocalException the service local exception * @throws Exception the exception */ @Override protected void validate() throws ServiceLocalException, Exception { super.validate(); EwsUtilities.validateParamCollection(this.getFolders().iterator(), "Folders"); for (int i = 0; i < this.getFolders().size(); i++) { Folder folder = this.getFolders().get(i); if ((folder == null) || folder.isNew()) { throw new IllegalArgumentException(String.format("Folders[%d] is either null or does not have an Id.", i)); } folder.validate(); } }
Example #16
Source File: ExchangeService.java From ews-java-api with MIT License | 5 votes |
/** * Binds to folder. * * @param <TFolder> The type of the folder. * @param cls Folder class * @param folderId The folder id. * @param propertySet The property set. * @return Folder * @throws Exception the exception */ public <TFolder extends Folder> TFolder bindToFolder(Class<TFolder> cls, FolderId folderId, PropertySet propertySet) throws Exception { Folder result = this.bindToFolder(folderId, propertySet); if (cls.isAssignableFrom(result.getClass())) { return (TFolder) result; } else { throw new ServiceLocalException(String.format( "The folder type returned by the service (%s) isn't compatible with the requested folder type (%s).", result.getClass().getName(), cls.getName())); } }
Example #17
Source File: ExchangeService.java From ews-java-api with MIT License | 5 votes |
/** * Move a folder. * * @param folderId The folderId. * @param destinationFolderId The destination folder id. * @return the folder * @throws Exception the exception */ public Folder moveFolder(FolderId folderId, FolderId destinationFolderId) throws Exception { MoveFolderRequest request = new MoveFolderRequest(this, ServiceErrorHandling.ThrowOnError); request.setDestinationFolderId(destinationFolderId); request.getFolderIds().add(folderId); ServiceResponseCollection<MoveCopyFolderResponse> responses = request .execute(); return responses.getResponseAtIndex(0).getFolder(); }
Example #18
Source File: PermissionSetPropertyDefinition.java From ews-java-api with MIT License | 5 votes |
/** * Creates the property instance. * * @param owner The owner. * @return ComplexProperty. */ @Override public ComplexProperty createPropertyInstance(ServiceObject owner) { Folder folder = (Folder) owner; EwsUtilities.ewsAssert(folder != null, "PermissionCollectionPropertyDefinition.CreatePropertyInstance", "The owner parameter is not of type Folder or a derived class."); return new FolderPermissionCollection(folder); }
Example #19
Source File: FolderIdWrapperList.java From ews-java-api with MIT License | 5 votes |
/** * Adds the range. * * @param folders the folder * @throws ServiceLocalException the service local exception */ protected void addRangeFolder(Iterable<Folder> folders) throws ServiceLocalException { if (folders != null) { for (Folder folder : folders) { this.add(folder); } } }
Example #20
Source File: ExchangeService.java From ews-java-api with MIT License | 5 votes |
/** * Creates a folder. Calling this method results in a call to EWS. * * @param folder The folder. * @param parentFolderId The parent folder Id * @throws Exception the exception */ public void createFolder(Folder folder, FolderId parentFolderId) throws Exception { CreateFolderRequest request = new CreateFolderRequest(this, ServiceErrorHandling.ThrowOnError); List<Folder> folArry = new ArrayList<Folder>(); folArry.add(folder); request.setFolders(folArry); request.setParentFolderId(parentFolderId); request.execute(); }
Example #21
Source File: ExchangeService.java From ews-java-api with MIT License | 5 votes |
/** * Load specified property for a folder. * * @param folder The folder * @param propertySet The property set * @throws Exception the exception */ public void loadPropertiesForFolder(Folder folder, PropertySet propertySet) throws Exception { EwsUtilities.validateParam(folder, "folder"); EwsUtilities.validateParam(propertySet, "propertySet"); GetFolderRequestForLoad request = new GetFolderRequestForLoad(this, ServiceErrorHandling.ThrowOnError); request.getFolderIds().add(folder); request.setPropertySet(propertySet); request.execute(); }
Example #22
Source File: ExchangeService.java From ews-java-api with MIT License | 5 votes |
/** * Updates a folder. * * @param folder The folder. * @throws Exception the exception */ public void updateFolder(Folder folder) throws Exception { UpdateFolderRequest request = new UpdateFolderRequest(this, ServiceErrorHandling.ThrowOnError); request.getFolders().add(folder); request.execute(); }
Example #23
Source File: ExchangeService.java From ews-java-api with MIT License | 5 votes |
/** * Copies a folder. Calling this method results in a call to EWS. * * @param folderId The folderId. * @param destinationFolderId The destination folder id. * @return the folder * @throws Exception the exception */ public Folder copyFolder(FolderId folderId, FolderId destinationFolderId) throws Exception { CopyFolderRequest request = new CopyFolderRequest(this, ServiceErrorHandling.ThrowOnError); request.setDestinationFolderId(destinationFolderId); request.getFolderIds().add(folderId); ServiceResponseCollection<MoveCopyFolderResponse> responses = request .execute(); return responses.getResponseAtIndex(0).getFolder(); }
Example #24
Source File: FindFolderResponse.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); this.results.setTotalCount(reader.readAttributeValue(Integer.class, XmlAttributeNames.TotalItemsInView)); this.results.setMoreAvailable(!reader.readAttributeValue(Boolean.class, XmlAttributeNames.IncludesLastItemInRange)); // Ignore IndexedPagingOffset attribute if MoreAvailable is false. this.results.setNextPageOffset(results.isMoreAvailable() ? reader .readNullableAttributeValue(Integer.class, XmlAttributeNames.IndexedPagingOffset) : null); reader.readStartElement(XmlNamespace.Types, XmlElementNames.Folders); if (!reader.isEmptyElement()) { do { reader.read(); if (reader.getNodeType().nodeType == XmlNodeType.START_ELEMENT) { Folder folder = EwsUtilities .createEwsObjectFromXmlElementName(Folder.class, reader.getService(), reader.getLocalName()); if (folder == null) { reader.skipCurrentElement(); } else { folder.loadFromXml(reader, true, /* clearPropertyBag */ this.propertySet, true /* summaryPropertiesOnly */); this.results.getFolders().add(folder); } } } while (!reader.isEndElement(XmlNamespace.Types, XmlElementNames.Folders)); } else { reader.read(); } reader .readEndElement(XmlNamespace.Messages, XmlElementNames.RootFolder); }
Example #25
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 #26
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 #27
Source File: CreateFolderRequest.java From ews-java-api with MIT License | 3 votes |
/** * Creates the service response. * * @param service the service * @param responseIndex Index of the response. * @return Service response. */ @Override protected ServiceResponse createServiceResponse(ExchangeService service, int responseIndex) { return new CreateFolderResponse((Folder) EwsUtilities .getEnumeratedObjectAt(this.getFolders(), responseIndex)); }
Example #28
Source File: FolderWrapper.java From ews-java-api with MIT License | 2 votes |
/** * Obtains the Folder object associated with the wrapper. * * @return The Folder object associated with the wrapper */ public Folder getFolder() { return this.folder; }
Example #29
Source File: UpdateFolderRequest.java From ews-java-api with MIT License | 2 votes |
/** * Gets the folder. * * @return the folder */ public ArrayList<Folder> getFolders() { return this.folders; }
Example #30
Source File: FolderPermissionCollection.java From ews-java-api with MIT License | 2 votes |
/** * Initializes a new instance of the FolderPermissionCollection class. * * @param owner the owner */ public FolderPermissionCollection(Folder owner) { super(); this.isCalendarFolder = owner instanceof CalendarFolder; }