Package org.apache.james.mailbox.model

Examples of org.apache.james.mailbox.model.MailboxPath


     * Create a {@link MaildirFolder} for a mailbox
     * @param mailbox
     * @return The MaildirFolder
     */
    public MaildirFolder createMaildirFolder(Mailbox<Integer> mailbox) {
        MaildirFolder mf = new MaildirFolder(getFolderName(mailbox), new MailboxPath(mailbox.getNamespace(), mailbox.getUser(), mailbox.getName()), locker);
        mf.setMessageNameStrictParse(isMessageNameStrictParse());
        return mf;
    }
View Full Code Here


     * @return The Mailbox object populated with data from the file system
     * @throws MailboxException If the mailbox folder doesn't exist or can't be read
     */
    public Mailbox<Integer> loadMailbox(MailboxSession session, File root, String namespace, String user, String folderName) throws MailboxException {
        String mailboxName = getMailboxNameFromFolderName(folderName);
        return loadMailbox(session, new File(root, folderName), new MailboxPath(namespace, user, mailboxName));
    }
View Full Code Here

        CLUSTER.clearTable(SUBSCRIPTIONS);
    }

    public static void generateTestData() {
        final Random random = new Random();
        MailboxPath mboxPath;
        final PropertyBuilder propBuilder = new PropertyBuilder();

        for (int i = 0; i < COUNT; i++) {
            if (i % 2 == 0) {
                mboxPath = new MailboxPath("gsoc", "ieugen" + i, "INBOX");
            } else {
                mboxPath = new MailboxPath("gsoc", "ieugen" + i, "INBOX.box" + i);
            }
            MBOX_PATHS.add(mboxPath);
            MBOXES.add(new HBaseMailbox(MBOX_PATHS.get(i), random.nextLong()));
            propBuilder.setProperty("gsoc", "prop" + i, "value");
        }
View Full Code Here

        LOG.info("findMailboxByPath");
        HBaseMailbox mailbox;
        for (MailboxPath path : pathsList) {
            LOG.info("Searching for " + path);
            mailbox = (HBaseMailbox) mapper.findMailboxByPath(path);
            assertEquals(path, new MailboxPath(mailbox.getNamespace(), mailbox.getUser(), mailbox.getName()));
        }
    }
View Full Code Here

    /**
     * Test of findMailboxWithPathLike method, of class HBaseMailboxMapper.
     */
    private void testFindMailboxWithPathLike() throws Exception {
        LOG.info("findMailboxWithPathLike");
        MailboxPath path = pathsList.get(pathsList.size() / 2);

        List<Mailbox<UUID>> result = mapper.findMailboxWithPathLike(path);
        assertEquals(1, result.size());

        int start = 3;
        int end = 7;
        MailboxPath newPath;

        for (int i = start; i < end; i++) {
            newPath = new MailboxPath(path);
            newPath.setName(i + newPath.getName() + " " + i);
            // test for paths with null user
            if (i % 2 == 0) {
                newPath.setUser(null);
            }
            addMailbox(new HBaseMailbox(newPath, 1234));
        }
        result = mapper.findMailboxWithPathLike(path);
        assertEquals(end - start + 1, result.size());
View Full Code Here

     */
    @Override
    public boolean hasChildren(Mailbox<Integer> mailbox, char delimiter) throws MailboxException, MailboxNotFoundException {
        String searchString = mailbox.getName() + MaildirStore.maildirDelimiter + MaildirStore.WILDCARD;
        List<Mailbox<Integer>> mailboxes = findMailboxWithPathLike(
                new MailboxPath(mailbox.getNamespace(), mailbox.getUser(), searchString));
        return (mailboxes.size() > 0);
    }
View Full Code Here

            else {
                userName = user.getName() + "@" + domain.getName();
            }
           
            // Special case for INBOX: Let's use the user's folder.
            MailboxPath inboxMailboxPath = new MailboxPath(session.getPersonalSpace(), userName, MailboxConstants.INBOX);
            mailboxList.add(maildirStore.loadMailbox(session, inboxMailboxPath));
           
            // List all INBOX sub folders.
           
            File[] mailboxes = user.listFiles(new FileFilter() {
                @Override
                public boolean accept(File pathname) {
                    return pathname.getName().startsWith(".");
                }
            });
           
            for (File mailbox: mailboxes) {
              
               
                MailboxPath mailboxPath = new MailboxPath(MailboxConstants.USER_NAMESPACE,
                        userName,
                        mailbox.getName().substring(1));
                mailboxList.add(maildirStore.loadMailbox(session, mailboxPath));

            }
View Full Code Here

        while (iterator.hasNext()) {
            HBaseMailbox mailbox = iterator.next();
            mapper.delete(mailbox);
            iterator.remove();
            MailboxPath path = new MailboxPath(mailbox.getNamespace(), mailbox.getUser(), mailbox.getName());
            pathsList.remove(path);
            LOG.info("Removing mailbox: {}", path);
            try {
                mapper.findMailboxByPath(path);
            } catch (MailboxNotFoundException e) {
View Full Code Here

    }

    private static void fillMailboxList() {
        mailboxList = new ArrayList<HBaseMailbox>();
        pathsList = new ArrayList<MailboxPath>();
        MailboxPath path;
        String name;
        for (int i = 0; i < NAMESPACES; i++) {
            for (int j = 0; j < USERS; j++) {
                for (int k = 0; k < MAILBOX_NO; k++) {
                    if (j == 3) {
                        name = "test" + SEPARATOR + "subbox" + k;
                    } else {
                        name = "mailbox" + k;
                    }
                    path = new MailboxPath("namespace" + i, "user" + j, name);
                    pathsList.add(path);
                    mailboxList.add(new HBaseMailbox(path, 13));
                }
            }
        }
View Full Code Here

                mailboxList.size(), pathsList.size());
    }

    private void addMailbox(HBaseMailbox mailbox) throws MailboxException {
        mailboxList.add(mailbox);
        pathsList.add(new MailboxPath(mailbox.getNamespace(), mailbox.getUser(), mailbox.getName()));
        mapper = new HBaseMailboxMapper(conf);
        mapper.save(mailbox);
        LOG.info("Added new mailbox: {} paths: {}", mailboxList.size(), pathsList.size());
    }
View Full Code Here

TOP

Related Classes of org.apache.james.mailbox.model.MailboxPath

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.