Package org.apache.james.mailbox.model

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


     * org.apache.james.imap.api.process.ImapSession, java.lang.String,
     * org.apache.james.imap.api.ImapCommand,
     * org.apache.james.imap.api.process.ImapProcessor.Responder)
     */
    protected void doProcess(DeleteRequest request, ImapSession session, String tag, ImapCommand command, Responder responder) {
        final MailboxPath mailboxPath = buildFullPath(session, request.getMailboxName());
        try {
            final SelectedMailbox selected = session.getSelected();
            if (selected != null && selected.getPath().equals(mailboxPath)) {
                session.deselect();
            }
View Full Code Here


                    // non-rooted
                    referenceRoot = "";
                    isRelative = true;
                }
                // Get the mailbox for the reference name.
                final MailboxPath rootPath = new MailboxPath(referenceRoot, "", "");
                results = new ArrayList<MailboxMetaData>(1);
                results.add(new MailboxMetaData() {

                    /**
                     * @see org.apache.james.mailbox.MailboxMetaData#inferiors()
                     */
                    public Children inferiors() {
                        return Children.CHILDREN_ALLOWED_BUT_UNKNOWN;
                    }

                    /**
                     * @see org.apache.james.mailbox.MailboxMetaData#getSelectability()
                     */
                    public Selectability getSelectability() {
                        return Selectability.NOSELECT;
                    }

                    /**
                     * @see org.apache.james.mailbox.MailboxMetaData#getHierarchyDelimiter()
                     */
                    public char getHierarchyDelimiter() {
                        return mailboxSession.getPathDelimiter();
                    }

                    /**
                     * (non-Javadoc)
                     * @see org.apache.james.mailbox.MailboxMetaData#getPath()
                     */
                    public MailboxPath getPath() {
                        return rootPath;
                    }
                   
                });
            } else {
                // If the mailboxPattern is fully qualified, ignore the
                // reference name.
                String finalReferencename = referenceName;
                if (mailboxName.charAt(0) == MailboxConstants.NAMESPACE_PREFIX_CHAR) {
                    finalReferencename = "";
                }
                // Is the interpreted (combined) pattern relative?
                isRelative = ((finalReferencename + mailboxName).charAt(0) != MailboxConstants.NAMESPACE_PREFIX_CHAR);

                finalReferencename = CharsetUtil.decodeModifiedUTF7(finalReferencename);

                MailboxPath basePath = null;
                if (isRelative) {
                    basePath = new MailboxPath(MailboxConstants.USER_NAMESPACE, user, finalReferencename);
                } else {
                    basePath = buildFullPath(session, finalReferencename);
                }

                results = getMailboxManager().search(new MailboxQuery(basePath, CharsetUtil.decodeModifiedUTF7(mailboxName), mailboxSession.getPathDelimiter()), mailboxSession);
View Full Code Here

            String id = session.getUser().getUserName();
            AtomicLong count = counts.get(id);
            if (count == null) {
                long mc = 0;
                List<Mailbox> mailboxes = factory.getMailboxMapper(session).findMailboxWithPathLike(new MailboxPath(session.getPersonalSpace(), id, "%"));
                for (int i = 0; i < mailboxes.size(); i++) {
                    mc += factory.getMessageMapper(session).countMessagesInMailbox(mailboxes.get(i));
                }
                AtomicLong c = counts.putIfAbsent(id, new AtomicLong(mc));
                if (c != null) {
View Full Code Here

          String id = session.getUser().getUserName();
            AtomicLong size = sizes.get(id);
           
            if (size == null) {
                final AtomicLong mSizes = new AtomicLong(0);
                List<Mailbox> mailboxes = factory.getMailboxMapper(session).findMailboxWithPathLike(new MailboxPath(session.getPersonalSpace(), id, "%"));
                for (int i = 0; i < mailboxes.size(); i++) {
                  long messageSizes = 0;
                    Iterator<Message>  messages = mapper.findInMailbox(mailboxes.get(i), MessageRange.all(), FetchType.Metadata, -1);
                   
                    while(messages.hasNext()) {
View Full Code Here

    /**
     * Receive the event and dispatch it to the right {@link MailboxListener} depending on
     * {@link org.apache.james.mailbox.MailboxListener.Event#getMailboxPath()}
     */
    public void event(Event event) {
        MailboxPath path = event.getMailboxPath();
        Map<MailboxPath, List<MailboxListener>> listeners = getListeners();
        synchronized (listeners) {
            List<MailboxListener> mListeners = listeners.get(path);
            if (mListeners != null && mListeners.isEmpty() == false) {
               
View Full Code Here

                mapper.save(mailbox);

                dispatcher.mailboxRenamed(session, from, mailbox);

                // rename submailboxes
                final MailboxPath children = new MailboxPath(MailboxConstants.USER_NAMESPACE, from.getUser(), from.getName() + getDelimiter() + "%");
                locker.executeWithLock(session, children, new LockAwareExecution<Void>() {

                    public Void execute() throws MailboxException {
                        final List<Mailbox<Id>> subMailboxes = mapper.findMailboxWithPathLike(children);
                        for (Mailbox<Id> sub : subMailboxes) {
                            final String subOriginalName = sub.getName();
                            final String subNewName = to.getName() + subOriginalName.substring(from.getName().length());
                            final MailboxPath fromPath = new MailboxPath(children, subOriginalName);
                            sub.setName(subNewName);
                            mapper.save(sub);
                            dispatcher.mailboxRenamed(session, fromPath, sub);

                            if (log.isDebugEnabled())
View Full Code Here

            baseLength = baseName.length();
        }
        final String combinedName = mailboxExpression.getCombinedName()
                .replace(freeWildcard, SQL_WILDCARD_CHAR)
                .replace(localWildcard, SQL_WILDCARD_CHAR);
        final MailboxPath search = new MailboxPath(mailboxExpression.getBase(), combinedName);

        final MailboxMapper<Id> mapper = mailboxSessionMapperFactory.getMailboxMapper(session);
        final List<Mailbox<Id>> mailboxes = mapper.findMailboxWithPathLike(search);
        final List<MailboxMetaData> results = new ArrayList<MailboxMetaData>(mailboxes.size());
        for (Mailbox<Id> mailbox : mailboxes) {
            final String name = mailbox.getName();
            if (name.startsWith(baseName)) {
                final String match = name.substring(baseLength);
                if (mailboxExpression.isExpressionMatch(match)) {
                    final MailboxMetaData.Children inferiors;
                    if (mapper.hasChildren(mailbox, session.getPathDelimiter())) {
                        inferiors = MailboxMetaData.Children.HAS_CHILDREN;
                    } else {
                        inferiors = MailboxMetaData.Children.HAS_NO_CHILDREN;
                    }
                    MailboxPath mailboxPath = new MailboxPath(mailbox.getNamespace(), mailbox.getUser(), name);
                    results.add(new SimpleMailboxMetaData(mailboxPath, getDelimiter(), inferiors, Selectability.NONE));
                }
            }
        }
        Collections.sort(results, new StandardMailboxMetaDataComparator());
View Full Code Here

    public List<MailboxPath> list(MailboxSession session) throws MailboxException {
        List<MailboxPath> mList = new ArrayList<MailboxPath>();
        List<Mailbox<Id>> mailboxes = mailboxSessionMapperFactory.getMailboxMapper(session).list();
        for (int i = 0; i < mailboxes.size(); i++) {
            Mailbox<Id> m = mailboxes.get(i);
            mList.add(new MailboxPath(m.getNamespace(), m.getUser(), m.getName()));
        }
        return Collections.unmodifiableList(mList);

    }
View Full Code Here

                    if (destination.startsWith(session.getPathDelimiter() + ""))
                        destination = destination.substring(1);

                    // Use the MailboxSession to construct the MailboxPath - See
                    // JAMES-1326
                    final MailboxPath path = new MailboxPath(MailboxConstants.USER_NAMESPACE, user, destination);
                    try {
                        if (this.folder.equalsIgnoreCase(destination) && !(mailboxManager.mailboxExists(path, session))) {
                            mailboxManager.createMailbox(path, session);
                        }
                        final MessageManager mailbox = mailboxManager.getMailbox(path, session);
View Full Code Here

        POP3MessageInfo[] list = pop3Client.listUniqueIdentifiers();
        assertEquals("Found unexpected messages", 0, list.length);

        pop3Client.disconnect();
        MailboxPath mailboxPath = new MailboxPath(MailboxConstants.USER_NAMESPACE, "foo", "INBOX");
        MailboxSession session = mailboxManager.login("foo", "bar", LoggerFactory.getLogger("Test"));
        if (!mailboxManager.mailboxExists(mailboxPath, session)) {
            mailboxManager.createMailbox(mailboxPath, session);
        }
        setupTestMails(session, mailboxManager.getMailbox(mailboxPath, session));
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.