FileDocCategorySizeDatePackage
ToRepository.javaAPI DocApache James 2.3.14288Fri Jan 12 12:56:30 GMT 2007org.apache.james.transport.mailets

ToRepository

public class ToRepository extends org.apache.mailet.GenericMailet
Stores incoming Mail in the specified Repository. If the "passThrough" in confs is true the mail will be returned untouched in the pipe. If false will be destroyed.
version
1.0.0, 24/04/1999
version
This is $Revision: 494012 $

Fields Summary
private org.apache.james.services.MailRepository
repository
The repository where this mailet stores mail.
private boolean
passThrough
Whether this mailet should allow mails to be processed by additional mailets or mark it as finished.
private String
repositoryPath
The path to the repository
Constructors Summary
Methods Summary
public java.lang.StringgetMailetInfo()
Return a string describing this mailet.

return
a string describing this mailet

        return "ToRepository Mailet";
    
public voidinit()
Initialize the mailet, loading configuration information.


               
       
        repositoryPath = getInitParameter("repositoryPath");
        try {
            passThrough = new Boolean(getInitParameter("passThrough")).booleanValue();
        } catch (Exception e) {
            // Ignore exception, default to false
        }

        ServiceManager compMgr = (ServiceManager)getMailetContext().getAttribute(Constants.AVALON_COMPONENT_MANAGER);
        try {
            Store mailstore = (Store) compMgr.lookup(Store.ROLE);
            DefaultConfiguration mailConf
                = new DefaultConfiguration("repository", "generated:ToRepository");
            mailConf.setAttribute("destinationURL", repositoryPath);
            mailConf.setAttribute("type", "MAIL");
            mailConf.setAttribute("CACHEKEYS", getInitParameter("CACHEKEYS","TRUE"));
            repository = (MailRepository) mailstore.select(mailConf);
        } catch (ServiceException cnfe) {
            log("Failed to retrieve Store component:" + cnfe.getMessage());
        } catch (Exception e) {
            log("Failed to retrieve Store component:" + e.getMessage());
        }

    
public voidservice(org.apache.mailet.Mail mail)
Store a mail in a particular repository.

param
mail the mail to process

        StringBuffer logBuffer =
            new StringBuffer(160)
                    .append("Storing mail ")
                    .append(mail.getName())
                    .append(" in ")
                    .append(repositoryPath);
        log(logBuffer.toString());
        repository.store(mail);
        if (!passThrough) {
            mail.setState(Mail.GHOST);
        }