FileDocCategorySizeDatePackage
StoreProcessor.javaAPI DocApache James 2.3.14352Fri Jan 12 12:56:24 GMT 2007org.apache.james.fetchmail

StoreProcessor

public class StoreProcessor extends ProcessorAbstract

Class StoreProcessor connects to a message store, gets the target Folder and delegates its processing to FolderProcessor.

Creation Date: 27-May-03

Fields Summary
Constructors Summary
protected StoreProcessor(Account account)
Constructor for StoreProcessor.

param
account

        super(account);        
    
Methods Summary
public voidprocess()
Method process connects to a Folder in a Message Store, creates a FolderProcessor and runs it to process the messages in the Folder.

see
org.apache.james.fetchmail.ProcessorAbstract#process()

        Store store = null;
        Folder folder = null;

        StringBuffer logMessageBuffer =
            new StringBuffer("Starting fetching mail from server '");
        logMessageBuffer.append(getHost());
        logMessageBuffer.append("' for user '");
        logMessageBuffer.append(getUser());
        logMessageBuffer.append("' in folder '");
        logMessageBuffer.append(getJavaMailFolderName());
        logMessageBuffer.append("'");
        getLogger().info(logMessageBuffer.toString());

        try
        {
            // Get a Store object
            store = getSession().getStore(getJavaMailProviderName());

            // Connect
            if (getHost() != null
                || getUser() != null
                || getPassword() != null)
                store.connect(getHost(), getUser(), getPassword());
            else
                store.connect();

            // Get the Folder
            folder = store.getFolder(getJavaMailFolderName());
            if (folder == null)
                getLogger().error(getFetchTaskName() + " No default folder");

            // Process the Folder
            new FolderProcessor(folder, getAccount()).process();

        }
        catch (MessagingException ex)
        {
            getLogger().error(
                "A MessagingException has terminated processing of this Folder",
                ex);
        }
        finally
        {
            try
            {
                if (null != store && store.isConnected())
                    store.close();
            }
            catch (MessagingException ex)
            {
                getLogger().error(
                    "A MessagingException occured while closing the Store",
                    ex);
            }
            logMessageBuffer =
                new StringBuffer("Finished fetching mail from server '");
            logMessageBuffer.append(getHost());
            logMessageBuffer.append("' for user '");
            logMessageBuffer.append(getUser());
            logMessageBuffer.append("' in folder '");
            logMessageBuffer.append(getJavaMailFolderName());
            logMessageBuffer.append("'");
            getLogger().info(logMessageBuffer.toString());
        }