Package org.apache.james.mailbox.jcr.mail.model

Examples of org.apache.james.mailbox.jcr.mail.model.JCRMailbox


     * imap.store.mail.model.Mailbox)
     */
    public void save(Mailbox<String> mailbox) throws MailboxException {
       
        try {
            final JCRMailbox jcrMailbox = (JCRMailbox)mailbox;
            Node node = null;

            if (jcrMailbox.isPersistent()) {
                node = getSession().getNodeByIdentifier(jcrMailbox.getMailboxId());
            }
            if (node == null) {
                Node rootNode = getSession().getRootNode();
                Node mailboxNode;
                if (rootNode.hasNode(MAILBOXES_PATH) == false) {
                    mailboxNode = rootNode.addNode(MAILBOXES_PATH);
                    mailboxNode.addMixin(JcrConstants.MIX_LOCKABLE);
                    getSession().save();
                } else {
                    mailboxNode = rootNode.getNode(MAILBOXES_PATH);
                }

                node = JcrUtils.getOrAddNode(mailboxNode, Text.escapeIllegalJcrChars(jcrMailbox.getNamespace()), "nt:unstructured");
                if (jcrMailbox.getUser() != null) {
                    node = createUserPathStructure(node, Text.escapeIllegalJcrChars(jcrMailbox.getUser()));
                }
                node = JcrUtils.getOrAddNode(node, Text.escapeIllegalJcrChars(jcrMailbox.getName()), "nt:unstructured");
                node.addMixin("jamesMailbox:mailbox");

                jcrMailbox.merge(node);
               
           } else {
               jcrMailbox.merge(node);
           }
           
        } catch (RepositoryException e) {
            throw new MailboxException("Unable to save mailbox " + mailbox, e);
        }
View Full Code Here


            String queryString = "/jcr:root/" + MAILBOXES_PATH + "//element(*,jamesMailbox:mailbox)";
            QueryResult result = manager.createQuery(queryString, Query.XPATH).execute();
            NodeIterator it = result.getNodes();
            while (it.hasNext()) {
                mList.add(new JCRMailbox(it.nextNode(), getLogger()));
            }
            return mList;
        } catch (RepositoryException e) {
            throw new MailboxException("Unable to retrieve the list of mailboxes", e);
        }
View Full Code Here

TOP

Related Classes of org.apache.james.mailbox.jcr.mail.model.JCRMailbox

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.