Examples of JCRSubscription


Examples of org.apache.james.mailbox.jcr.user.model.JCRSubscription

     * org.apache.james.mailbox.store.user.SubscriptionMapper#delete(org.apache
     * .james.imap.store.user.model.Subscription)
     */
    public void delete(Subscription subscription) throws SubscriptionException {

        JCRSubscription sub = (JCRSubscription) subscription;
        try {

            Node node = sub.getNode();
            if (node != null) {
                Property prop = node.getProperty(JCRSubscription.MAILBOXES_PROPERTY);
                Value[] values = prop.getValues();
                List<String> newValues = new ArrayList<String>();
                for (int i = 0; i < values.length; i++) {
                    String m = values[i].getString();
                    if (m.equals(sub.getMailbox()) == false) {
                        newValues.add(m);
                    }
                }
                if (newValues.isEmpty() == false) {
                    prop.setValue(newValues.toArray(new String[newValues.size()]));
View Full Code Here

Examples of org.apache.james.mailbox.jcr.user.model.JCRSubscription

            QueryManager manager = getSession().getWorkspace().getQueryManager();
            QueryResult result = manager.createQuery(queryString, Query.XPATH).execute();
           
            NodeIterator nodeIt = result.getNodes();
            if (nodeIt.hasNext()) {
                JCRSubscription sub = new JCRSubscription(nodeIt.nextNode(), mailbox, getLogger());
                return sub;
            }
           
        } catch (PathNotFoundException e) {
            // nothing todo here
View Full Code Here

Examples of org.apache.james.mailbox.jcr.user.model.JCRSubscription

            while (nodeIt.hasNext()) {
                Node node = nodeIt.nextNode();
                if (node.hasProperty(JCRSubscription.MAILBOXES_PROPERTY)) {
                    Value[] values = node.getProperty(JCRSubscription.MAILBOXES_PROPERTY).getValues();
                    for (int i = 0; i < values.length; i++) {
                        subList.add(new JCRSubscription(node, values[i].getString(), getLogger()));
                    }
                }
            }
        } catch (PathNotFoundException e) {
            // Do nothing just return the empty list later
View Full Code Here

Examples of org.apache.james.mailbox.jcr.user.model.JCRSubscription

        String mailbox = subscription.getMailbox();
        try {

            Node node = null;
        
            JCRSubscription sub = (JCRSubscription) findMailboxSubscriptionForUser(username, mailbox);
           
            // its a new subscription
            if (sub == null) {
                node = JcrUtils.getOrAddNode(getSession().getRootNode(), MAILBOXES_PATH);
                node = JcrUtils.getOrAddNode(node, Text.escapeIllegalJcrChars(MailboxConstants.USER_NAMESPACE));

                // This is needed to minimize the child nodes a bit
                node = createUserPathStructure(node, Text.escapeIllegalJcrChars(username));
            } else {
                node = sub.getNode();
            }
           
            // Copy new properties to the node
            ((JCRSubscription)subscription).merge(node);
View Full Code Here

Examples of org.apache.james.mailbox.jcr.user.model.JCRSubscription

        super(mapperFactory);
    }

    @Override
    protected Subscription createSubscription(MailboxSession session, String mailbox) {
        return new JCRSubscription(session.getUser().getUserName(), mailbox, logger);
    }
View Full Code Here

Examples of org.apache.james.mailbox.jcr.user.model.JCRSubscription

     * org.apache.james.mailbox.store.user.SubscriptionMapper#delete(org.apache
     * .james.imap.store.user.model.Subscription)
     */
    public void delete(Subscription subscription) throws SubscriptionException {

        JCRSubscription sub = (JCRSubscription) subscription;
        try {

            Node node = sub.getNode();
            if (node != null) {
                Property prop = node.getProperty(JCRSubscription.MAILBOXES_PROPERTY);
                Value[] values = prop.getValues();
                List<String> newValues = new ArrayList<String>();
                for (int i = 0; i < values.length; i++) {
                    String m = values[i].getString();
                    if (m.equals(sub.getMailbox()) == false) {
                        newValues.add(m);
                    }
                }
                if (newValues.isEmpty() == false) {
                    prop.setValue(newValues.toArray(new String[newValues.size()]));
View Full Code Here

Examples of org.apache.james.mailbox.jcr.user.model.JCRSubscription

            QueryManager manager = getSession().getWorkspace().getQueryManager();
            QueryResult result = manager.createQuery(queryString, Query.XPATH).execute();
           
            NodeIterator nodeIt = result.getNodes();
            if (nodeIt.hasNext()) {
                JCRSubscription sub = new JCRSubscription(nodeIt.nextNode(), mailbox, getLogger());
                return sub;
            }
           
        } catch (PathNotFoundException e) {
            // nothing todo here
View Full Code Here

Examples of org.apache.james.mailbox.jcr.user.model.JCRSubscription

            while (nodeIt.hasNext()) {
                Node node = nodeIt.nextNode();
                if (node.hasProperty(JCRSubscription.MAILBOXES_PROPERTY)) {
                    Value[] values = node.getProperty(JCRSubscription.MAILBOXES_PROPERTY).getValues();
                    for (int i = 0; i < values.length; i++) {
                        subList.add(new JCRSubscription(node, values[i].getString(), getLogger()));
                    }
                }
            }
        } catch (PathNotFoundException e) {
            // Do nothing just return the empty list later
View Full Code Here

Examples of org.apache.james.mailbox.jcr.user.model.JCRSubscription

        String mailbox = subscription.getMailbox();
        try {

            Node node = null;
        
            JCRSubscription sub = (JCRSubscription) findMailboxSubscriptionForUser(username, mailbox);
           
            // its a new subscription
            if (sub == null) {
                node = JcrUtils.getOrAddNode(getSession().getRootNode(), MAILBOXES_PATH);
                node = JcrUtils.getOrAddNode(node, Text.escapeIllegalJcrChars(MailboxConstants.USER_NAMESPACE));

                // This is needed to minimize the child nodes a bit
                node = createUserPathStructure(node, Text.escapeIllegalJcrChars(username));
            } else {
                node = sub.getNode();
            }
           
            // Copy new properties to the node
            ((JCRSubscription)subscription).merge(node);
View Full Code Here

Examples of org.apache.james.mailbox.jcr.user.model.JCRSubscription

     * org.apache.james.mailbox.store.user.SubscriptionMapper#delete(org.apache
     * .james.imap.store.user.model.Subscription)
     */
    public void delete(Subscription subscription) throws SubscriptionException {

        JCRSubscription sub = (JCRSubscription) subscription;
        try {

            Node node = sub.getNode();
            if (node != null) {
                Property prop = node.getProperty(JCRSubscription.MAILBOXES_PROPERTY);
                Value[] values = prop.getValues();
                List<String> newValues = new ArrayList<String>();
                for (int i = 0; i < values.length; i++) {
                    String m = values[i].getString();
                    if (m.equals(sub.getMailbox()) == false) {
                        newValues.add(m);
                    }
                }
                if (newValues.isEmpty() == false) {
                    prop.setValue(newValues.toArray(new String[newValues.size()]));
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.