Package org.apache.james.mailrepository.api

Examples of org.apache.james.mailrepository.api.MailRepository


        Collection<MailAddress> recipients = new HashSet<MailAddress>();
        recipients.add(recipient);
        MailImpl mail = new MailImpl(getId(), sender, recipients, message);
        try {
            MailRepository userInbox = getRepository(username);
            if (userInbox == null) {
                StringBuffer errorBuffer = new StringBuffer(128).append(
                        "The repository for user ").append(username).append(
                        " was not found on this server.");
                throw new MessagingException(errorBuffer.toString());
            }
            userInbox.store(mail);
        } finally {
            mail.dispose();
        }
    }
View Full Code Here


        StringBuffer destinationBuffer = new StringBuffer(192).append(repositoryUrl).append(userName).append("/");
        String destination = destinationBuffer.toString();
        DefaultConfigurationBuilder mboxConf = new DefaultConfigurationBuilder();
        mboxConf.addProperty("[@destinationURL]", destination);
        mboxConf.addProperty("[@type]", repositoryType);
        MailRepository userInbox;
        try {
            userInbox = (MailRepository) store.select(mboxConf);
        } catch (Exception e) {
            log("Cannot open repository " + e);
            userInbox = null;
View Full Code Here

        return mr;
    }

    // Try to write a unit test for JAMES-744. At the moment it seems that we cannot reproduce it.
    public void testReadMboxrdFile() throws Exception {
        MailRepository mr = getMailRepository();
       
        Iterator<String> keys = mr.list();
   
        assertTrue("Two messages in list", keys.hasNext());
        keys.next();
   
        assertTrue("One messages in list", keys.hasNext());
View Full Code Here

        if (idx == -1)
            throw new MailRepositoryStoreException("Destination is malformed. Must be a valid URL: " + destination);
        String protocol = destination.substring(0, idx);

        String repID = destination;
        MailRepository reply = repositories.get(repID);
        StringBuffer logBuffer;
        if (reply != null) {
            if (getLogger().isDebugEnabled()) {
                logBuffer = new StringBuffer(128).append("obtained repository: ").append(repID).append(",").append(reply.getClass());
                getLogger().debug(logBuffer.toString());
            }
            return reply;
        } else {
            String repClass = classes.get(protocol);
View Full Code Here

        Iterator<String> james23userRepositoryIterator = james23UsersRepository.list();

        while (james23userRepositoryIterator.hasNext()) {

            String userName23 = james23userRepositoryIterator.next();
            MailRepository mailRepository = mailRepositoryStore.select(james23MailRepositoryPath + "/" + userName23);
            Iterator<String> mailRepositoryIterator = mailRepository.list();

            String userName30 = convert23UserTo30(userName23);


            MailboxSession mailboxSession = mailboxManager.createSystemSession(userName30, log);
            MailboxPath mailboxPath = MailboxPath.inbox(mailboxSession);

            mailboxManager.startProcessingRequest(mailboxSession);
            try {
                mailboxManager.createMailbox(mailboxPath, mailboxSession);
            } catch (MailboxExistsException e) {
                // Do nothing, the mailbox already exists.
            }
            mailboxManager.endProcessingRequest(mailboxSession);

            MessageManager messageManager = mailboxManager.getMailbox(mailboxPath, mailboxSession);

            while (mailRepositoryIterator.hasNext()) {
                Mail mail = mailRepository.retrieve(mailRepositoryIterator.next());
                mailboxManager.startProcessingRequest(mailboxSession);
                messageManager.appendMessage(new MimeMessageInputStream(mail.getMessage()), new Date(), mailboxSession, isRecent, flags);
                mailboxManager.endProcessingRequest(mailboxSession);
            }
View Full Code Here

    // Try to write a unit test for JAMES-744. At the moment it seems that we
    // cannot reproduce it.
    @Test
    public void testReadMboxrdFile() throws Exception {
        MailRepository mr = getMailRepository();

        Iterator<String> keys = mr.list();

        assertTrue("Two messages in list", keys.hasNext());
        keys.next();

        assertTrue("One messages in list", keys.hasNext());
View Full Code Here

        m_storedObjectMap.put(url, obj);
    }

    @Override
    public MailRepository select(String url) throws MailRepositoryStoreException {
        MailRepository result = get(url);
        return result;
    }
View Full Code Here

TOP

Related Classes of org.apache.james.mailrepository.api.MailRepository

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.