Package org.frankframework.filesystem
Class ImapFileSystem
java.lang.Object
org.frankframework.filesystem.AbstractFileSystem<jakarta.mail.Message>
org.frankframework.filesystem.AbstractConnectedFileSystem<jakarta.mail.Message,org.eclipse.angus.mail.imap.IMAPFolder>
org.frankframework.filesystem.AbstractMailFileSystem<jakarta.mail.Message,jakarta.mail.internet.MimeBodyPart,org.eclipse.angus.mail.imap.IMAPFolder>
org.frankframework.filesystem.ImapFileSystem
- All Implemented Interfaces:
AutoCloseable
,HasPhysicalDestination
,IBasicFileSystem<jakarta.mail.Message>
,IMailFileSystem<jakarta.mail.Message,
jakarta.mail.internet.MimeBodyPart>
public class ImapFileSystem
extends AbstractMailFileSystem<jakarta.mail.Message,jakarta.mail.internet.MimeBodyPart,org.eclipse.angus.mail.imap.IMAPFolder>
-
Field Summary
Fields inherited from class org.frankframework.filesystem.AbstractFileSystem
log
Fields inherited from interface org.frankframework.filesystem.IMailFileSystem
BCC_RECIPIENTS_KEY, BEST_REPLY_ADDRESS_KEY, CC_RECIPIENTS_KEY, DATETIME_RECEIVED_KEY, DATETIME_SENT_KEY, FROM_ADDRESS_KEY, MAIL_MESSAGE_ID, REPLY_ADDRESS_FIELDS_DEFAULT, REPLY_TO_RECIPIENTS_KEY, RETURN_PATH_HEADER, SENDER_ADDRESS_KEY, TO_RECIPIENTS_KEY
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
closeConnection
(org.eclipse.angus.mail.imap.IMAPFolder folder) Close connection to the FileSystem, releasing all resources.void
jakarta.mail.Message
Copies the file to another folder.protected org.eclipse.angus.mail.imap.IMAPFolder
Create a fresh connection to the FileSystem.void
createFolder
(String folderName) void
deleteFile
(jakarta.mail.Message message) boolean
exists
(jakarta.mail.Message f) void
extractAttachment
(jakarta.mail.internet.MimeBodyPart attachment, SaxElementBuilder attachmentsXml) void
extractEmail
(jakarta.mail.Message emailMessage, SaxElementBuilder emailXml) boolean
folderExists
(String foldername) void
forwardMail
(jakarta.mail.Message emailMessage, String destination) getAdditionalAttachmentProperties
(jakarta.mail.internet.MimeBodyPart a) getAdditionalFileProperties
(jakarta.mail.Message f) getAttachmentContentType
(jakarta.mail.internet.MimeBodyPart a) getAttachmentFileName
(jakarta.mail.internet.MimeBodyPart a) getAttachmentName
(jakarta.mail.internet.MimeBodyPart a) long
getAttachmentSize
(jakarta.mail.internet.MimeBodyPart a) getCanonicalName
(jakarta.mail.Message f) jakarta.mail.Message
getFileFromAttachment
(jakarta.mail.internet.MimeBodyPart a) long
getFileSize
(jakarta.mail.Message f) getMimeContent
(jakarta.mail.Message emailMessage) getModificationTime
(jakarta.mail.Message message) getName
(jakarta.mail.Message f) Get a string representation of an identification of a file.int
getNumberOfFilesInFolder
(String foldername) getParentFolder
(jakarta.mail.Message f) protected String
For test purposes only.getSubject
(jakarta.mail.Message emailMessage) boolean
isFolder
(jakarta.mail.Message message) DirectoryStream
<jakarta.mail.Message> list
(String foldername, TypeFilter filter) Lists files, directories or both, from a 'folder' or in the 'root' of the filesystem (when folder is null).Iterator
<jakarta.mail.internet.MimeBodyPart> listAttachments
(jakarta.mail.Message f) jakarta.mail.Message
Moves the file to another folder.readAttachment
(jakarta.mail.internet.MimeBodyPart a) void
removeFolder
(String folderName, boolean removeNonEmptyFolder) void
The hostname of the IMAP servervoid
setPort
(int port) The port of the IMAP serverjakarta.mail.Message
Get a file 'F' representation of an identification of a file.jakarta.mail.Message
Creates a reference to a file.Methods inherited from class org.frankframework.filesystem.AbstractMailFileSystem
setAuthAlias, setBaseFolder, setPassword, setReadMimeContents, setReplyAddressFields, setUsername
Methods inherited from class org.frankframework.filesystem.AbstractConnectedFileSystem
close, getConnection, open, releaseConnection
Methods inherited from class org.frankframework.filesystem.AbstractFileSystem
getMaxNumberOfMessagesToList, isOpen, setMaxNumberOfMessagesToList
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.frankframework.core.HasPhysicalDestination
getDomain
Methods inherited from interface org.frankframework.filesystem.IBasicFileSystem
close, getCanonicalNameOrErrorMessage, isOpen, open
Methods inherited from interface org.frankframework.filesystem.IMailFileSystem
getReplyAddressFields
-
Constructor Details
-
ImapFileSystem
public ImapFileSystem()
-
-
Method Details
-
configure
- Throws:
ConfigurationException
-
getStoreName
For test purposes only. Defaults to IMAPS, but tests use IMAP- Throws:
jakarta.mail.NoSuchProviderException
-
createConnection
Description copied from class:AbstractConnectedFileSystem
Create a fresh connection to the FileSystem.- Specified by:
createConnection
in classAbstractConnectedFileSystem<jakarta.mail.Message,
org.eclipse.angus.mail.imap.IMAPFolder> - Throws:
FileSystemException
-
closeConnection
protected void closeConnection(org.eclipse.angus.mail.imap.IMAPFolder folder) throws FileSystemException Description copied from class:AbstractConnectedFileSystem
Close connection to the FileSystem, releasing all resources.- Overrides:
closeConnection
in classAbstractConnectedFileSystem<jakarta.mail.Message,
org.eclipse.angus.mail.imap.IMAPFolder> - Throws:
FileSystemException
-
getName
Description copied from interface:IBasicFileSystem
Get a string representation of an identification of a file. Must pair up with the implementation ofIBasicFileSystem.toFile(String)
. Can reflect name a file has in its folder, is not expected to be unique over folders. -
getParentFolder
-
toFile
Description copied from interface:IBasicFileSystem
Get a file 'F' representation of an identification of a file. Must pair up with the implementation ofIBasicFileSystem.getName(Object)
.- Throws:
FileSystemException
-
toFile
public jakarta.mail.Message toFile(@Nullable String defaultFolder, @Nullable String filename) throws FileSystemException Description copied from interface:IBasicFileSystem
Creates a reference to a file. If filename is not absolute, it will be created in 'defaultFolder'.- Throws:
FileSystemException
-
exists
- Throws:
FileSystemException
-
isFolder
- Throws:
FileSystemException
-
folderExists
- Throws:
FileSystemException
-
getNumberOfFilesInFolder
- Specified by:
getNumberOfFilesInFolder
in interfaceIBasicFileSystem<jakarta.mail.Message>
- Overrides:
getNumberOfFilesInFolder
in classAbstractFileSystem<jakarta.mail.Message>
- Throws:
FileSystemException
-
list
public DirectoryStream<jakarta.mail.Message> list(String foldername, TypeFilter filter) throws FileSystemException Description copied from interface:IBasicFileSystem
Lists files, directories or both, from a 'folder' or in the 'root' of the filesystem (when folder is null). Only lists the objects as defined by the type filter.- Throws:
FileSystemException
-
deleteFile
- Throws:
FileSystemException
-
moveFile
public jakarta.mail.Message moveFile(jakarta.mail.Message f, String destinationFolder, boolean createFolder) throws FileSystemException Description copied from interface:IBasicFileSystem
Moves the file to another folder. Does not need to check for existence of the source or non-existence of the destination. Returns the moved file, or null if no file was moved or there is no reference to the moved file.- Throws:
FileSystemException
-
copyFile
public jakarta.mail.Message copyFile(jakarta.mail.Message f, String destinationFolder, boolean createFolder) throws FileSystemException Description copied from interface:IBasicFileSystem
Copies the file to another folder. Does not need to check for existence of the source or non-existence of the destination. Returns the copied file, or null if no file was copied or there is no reference to the copied file.- Throws:
FileSystemException
-
createFolder
- Throws:
FileSystemException
-
removeFolder
public void removeFolder(String folderName, boolean removeNonEmptyFolder) throws FileSystemException - Throws:
FileSystemException
-
readFile
public Message readFile(jakarta.mail.Message f, String charset) throws FileSystemException, IOException - Throws:
FileSystemException
IOException
-
listAttachments
public Iterator<jakarta.mail.internet.MimeBodyPart> listAttachments(jakarta.mail.Message f) throws FileSystemException - Throws:
FileSystemException
-
getAttachmentName
- Throws:
FileSystemException
-
readAttachment
-
getAttachmentSize
- Throws:
FileSystemException
-
getAttachmentContentType
public String getAttachmentContentType(jakarta.mail.internet.MimeBodyPart a) throws FileSystemException - Throws:
FileSystemException
-
getAttachmentFileName
public String getAttachmentFileName(jakarta.mail.internet.MimeBodyPart a) throws FileSystemException - Throws:
FileSystemException
-
getFileFromAttachment
public jakarta.mail.Message getFileFromAttachment(jakarta.mail.internet.MimeBodyPart a) throws FileSystemException - Throws:
FileSystemException
-
getAdditionalAttachmentProperties
public Map<String,Object> getAdditionalAttachmentProperties(jakarta.mail.internet.MimeBodyPart a) throws FileSystemException - Throws:
FileSystemException
-
getFileSize
- Throws:
FileSystemException
-
getCanonicalName
-
getModificationTime
-
getAdditionalFileProperties
@Nullable public Map<String,Object> getAdditionalFileProperties(jakarta.mail.Message f) throws FileSystemException - Throws:
FileSystemException
-
forwardMail
public void forwardMail(jakarta.mail.Message emailMessage, String destination) throws FileSystemException - Throws:
FileSystemException
-
getPhysicalDestinationName
- Specified by:
getPhysicalDestinationName
in interfaceHasPhysicalDestination
- Overrides:
getPhysicalDestinationName
in classAbstractMailFileSystem<jakarta.mail.Message,
jakarta.mail.internet.MimeBodyPart, org.eclipse.angus.mail.imap.IMAPFolder>
-
getSubject
- Throws:
FileSystemException
-
getMimeContent
-
extractEmail
public void extractEmail(jakarta.mail.Message emailMessage, SaxElementBuilder emailXml) throws FileSystemException, SAXException - Throws:
FileSystemException
SAXException
-
extractAttachment
public void extractAttachment(jakarta.mail.internet.MimeBodyPart attachment, SaxElementBuilder attachmentsXml) throws FileSystemException, SAXException - Throws:
FileSystemException
SAXException
-
setHost
The hostname of the IMAP server -
setPort
public void setPort(int port) The port of the IMAP server- Default value
- 993
-