Package org.apache.james.mailbox

Examples of org.apache.james.mailbox.MailboxPath


   
    /**
     * Receive the event and dispatch it to the right {@link MailboxListener} depending on {@link 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) {
                List<MailboxListener> closedListener = new ArrayList<MailboxListener>();
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

        if (max != Quota.UNLIMITED || calculateWhenUnlimited) {
            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++) {
                    factory.getMessageMapper(session).findInMailbox(mailboxes.get(i), MessageRange.all(), FetchType.Metadata, new MessageCallback<Object>() {
                        long messageSizes = 0;

                        @Override
View Full Code Here

     * @see org.apache.james.mailbox.store.mail.MailboxMapper#findMailboxByName(java.lang.String)
     */
    public synchronized Mailbox<Long> findMailboxByPath(MailboxPath path) throws MailboxException, MailboxNotFoundException {
        Mailbox<Long> result = null;
        for (final Mailbox<Long> mailbox:mailboxesById.values()) {
            MailboxPath mp = new MailboxPath(mailbox.getNamespace(), mailbox.getUser(), mailbox.getName());
            if (mp.equals(path)) {
                result = mailbox;
                break;
            }
        }
        if (result == null) {
View Full Code Here

        final CountDownLatch latch = new CountDownLatch(APPEND_OPERATIONS);
        final ExecutorService pool = Executors.newFixedThreadPool(APPEND_OPERATIONS/2);
       
        MailboxSession session = getMailboxManager().createSystemSession("test", LoggerFactory.getLogger("Test"));
        getMailboxManager().startProcessingRequest(session);
        final MailboxPath path = new MailboxPath(MailboxConstants.USER_NAMESPACE, "username", "INBOX");
        getMailboxManager().createMailbox(path, session);
        getMailboxManager().endProcessingRequest(session);
        getMailboxManager().logout(session, false);
        final AtomicBoolean fail = new AtomicBoolean(false);
        final ConcurrentHashMap<Long, Object> uids = new ConcurrentHashMap<Long, Object>();
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 == null || "".equals(destination)) {
                            destination = "INBOX";
                        }
                        if (destination.startsWith(MailboxConstants.DEFAULT_DELIMITER_STRING))
                            destination = destination.substring(1);
                        final MailboxPath path = new MailboxPath(MailboxConstants.USER_NAMESPACE, user, destination);
                        try {
                            if ("INBOX".equalsIgnoreCase(destination) && !(mailboxManager.mailboxExists(path, session))) {
                                mailboxManager.createMailbox(path, session);
                            }
                            final MessageManager mailbox = mailboxManager.getMailbox(path, session);
View Full Code Here

            SMTPResponse response;
           
            try {
               
                MailboxSession mailboxSession = mailboxManager.createSystemSession(username, session.getLogger());
                MailboxPath inbox = MailboxPath.inbox(username);
               
                mailboxManager.startProcessingRequest(mailboxSession);
               
                // create inbox if not exist
                if (mailboxManager.mailboxExists(inbox, mailboxSession) == false) {
View Full Code Here

TOP

Related Classes of org.apache.james.mailbox.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.