Holger's Java API

## com.antelmann.net.mail
Class IMAPBackup

    java.lang.Object
      com.antelmann.net.mail.IMAPBackup

All Implemented Interfaces:
  LoggerProvider, Task<Exception>, Runnable

    public class IMAPBackup

extends Object
implements Runnable, Task<Exception>, LoggerProvider

allows to easily backup an IMAP account.

Since:
  06.01.2017
Author:
  Holger Antelmann

Nested Class Summary
`static class` `IMAPBackup.DirArchiver`
`static class` `IMAPBackup.ZipDirArchiver`

Constructor Summary
`IMAPBackup()`
`IMAPBackup(javax.mail.Store store)`

Method Summary
`void` `addAllFolders(javax.mail.Store store)`
`void` `addFolder(javax.mail.Folder folder, boolean includeSubFolders)`
`void` `addFolders(ArrayList<javax.mail.Folder> folders)`
`void` `addFolders(javax.mail.Folder... folders)`
`static void` `backupToDB(javax.mail.Store imapStore, DBClassStore<MessageEntry> dbstore, Filter<javax.mail.Message> filter, File logFile)`
`static void` `backupToDir(javax.mail.Store imapStore, File targetBaseDir, Filter<javax.mail.Message> filter, boolean zip, boolean useCounter)`
`void` `clearFolders()`
`static String` `generateLocalUID()`
`javax.mail.Folder[]` `getFolders()`
`Logger` `getLogger()` acess to the (non-null) Logger suitable for logging entries in the context of this instance
`Filter<javax.mail.Message>` `getMessageFilter()`
`Handler<javax.mail.Message,? extends Exception>` `getMessageHandler()`
`Monitor` `getMonitor()`
`boolean` `isRunning()`
`void` `run()` calls `runTask()`
`void` `runTask()` performs the backup operation
`void` `setMessageFilter(Filter<javax.mail.Message> filter)`
`void` `setMessageHandler(Handler<javax.mail.Message,? extends Exception> messageHandler)`
`void` `setMonitor(Monitor monitor)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### IMAPBackup

    public IMAPBackup()

### IMAPBackup

    public IMAPBackup(javax.mail.Store store)
               throws javax.mail.MessagingException

Throws:
  `javax.mail.MessagingException`

Method Detail

### getLogger

    public Logger getLogger()

  Description copied from interface: `LoggerProvider`
  acess to the (non-null) Logger suitable for logging entries in the context of this instance

  Specified by:
    `getLogger` in interface `LoggerProvider`

### getFolders

    public javax.mail.Folder[] getFolders()

### addFolder

    public void addFolder(javax.mail.Folder folder,
                          boolean includeSubFolders)
                   throws javax.mail.MessagingException

  Throws:
    `javax.mail.MessagingException`

### addAllFolders

    public void addAllFolders(javax.mail.Store store)
                       throws javax.mail.MessagingException

  Throws:
    `javax.mail.MessagingException`

### addFolders

    public void addFolders(ArrayList<javax.mail.Folder> folders)

### addFolders

    public void addFolders(javax.mail.Folder... folders)

### clearFolders

    public void clearFolders()

### getMessageHandler

    public Handler<javax.mail.Message,? extends Exception> getMessageHandler()

### setMessageHandler

    public void setMessageHandler(Handler<javax.mail.Message,? extends Exception> messageHandler)

### isRunning

    public boolean isRunning()

### getMonitor

    public Monitor getMonitor()

### getMessageFilter

    public Filter<javax.mail.Message> getMessageFilter()

### setMonitor

    public void setMonitor(Monitor monitor)
                    throws IllegalStateException

  Throws:
    `IllegalStateException`

### setMessageFilter

    public void setMessageFilter(Filter<javax.mail.Message> filter)
                          throws IllegalStateException

  Throws:
    `IllegalStateException`

### run

    public void run()

  calls `runTask()`

  Specified by:
    `run` in interface `Runnable`

### runTask

    public void runTask()
                 throws Exception

  performs the backup operation

  Specified by:
    `runTask` in interface `Task<Exception>`
  Throws:
    `Exception`

### generateLocalUID

    public static String generateLocalUID()

### backupToDir

    public static void backupToDir(javax.mail.Store imapStore,
                                   File targetBaseDir,
                                   Filter<javax.mail.Message> filter,
                                   boolean zip,
                                   boolean useCounter)
                            throws Exception

  Parameters:
    `imapStore` - must be already connected
  Throws:
    `Exception`

### backupToDB

    public static void backupToDB(javax.mail.Store imapStore,
                                  DBClassStore<MessageEntry> dbstore,
                                  Filter<javax.mail.Message> filter,
                                  File logFile)
                           throws Exception

  Parameters:
    `imapStore` - must be already connected
    `dbstore` - should either support automated transactions or this call should be wrapped in a transaction.
  Throws:
    `Exception`

(c) Holger Antelmann since 2001- all rights reserved (contact: info@antelmann.com)
see www.antelmann.com/developer for further details and available downloads