Package org.apache.james.mailbox.store.user

Examples of org.apache.james.mailbox.store.user.SubscriptionMapper


    /*
     * (non-Javadoc)
     * @see org.apache.james.mailbox.SubscriptionManager#subscribe(org.apache.james.mailbox.MailboxSession, java.lang.String)
     */
    public void subscribe(final MailboxSession session, final String mailbox) throws SubscriptionException {
        final SubscriptionMapper mapper = mapperFactory.getSubscriptionMapper(session);
        try {
            mapper.execute(new Mapper.VoidTransaction() {

                public void runVoid() throws MailboxException {
                    final Subscription subscription = mapper.findMailboxSubscriptionForUser(session.getUser().getUserName(), mailbox);
                    if (subscription == null) {
                        final Subscription newSubscription = createSubscription(session, mailbox);
                        mapper.save(newSubscription);
                    }
                }
               
            });
        } catch (MailboxException e) {
View Full Code Here


    /*
     * (non-Javadoc)
     * @see org.apache.james.mailbox.SubscriptionManager#subscriptions(org.apache.james.mailbox.MailboxSession)
     */
    public Collection<String> subscriptions(final MailboxSession session) throws SubscriptionException {
        final SubscriptionMapper mapper = mapperFactory.getSubscriptionMapper(session);
        final List<Subscription> subscriptions = mapper.findSubscriptionsForUser(session.getUser().getUserName());
        final Collection<String> results = new HashSet<String>(INITIAL_SIZE);
        for (Subscription subscription:subscriptions) {
            results.add(subscription.getMailbox());
        }       
        return results;
View Full Code Here

    /*
     * (non-Javadoc)
     * @see org.apache.james.mailbox.SubscriptionManager#unsubscribe(org.apache.james.mailbox.MailboxSession, java.lang.String)
     */
    public void unsubscribe(final MailboxSession session, final String mailbox) throws SubscriptionException {
        final SubscriptionMapper mapper = mapperFactory.getSubscriptionMapper(session);
        try {
            mapper.execute(new Mapper.VoidTransaction() {

                public void runVoid() throws MailboxException {
                    final Subscription subscription = mapper.findMailboxSubscriptionForUser(session.getUser().getUserName(), mailbox);
                    if (subscription != null) {
                        mapper.delete(subscription);
                    }
                }

            });
        } catch (MailboxException e) {
View Full Code Here

     *
     * @param session
     * @return mapper
     */
    public SubscriptionMapper getSubscriptionMapper(MailboxSession session) throws SubscriptionException {
        SubscriptionMapper mapper = (SubscriptionMapper) session.getAttributes().get(SUBSCRIPTIONMAPPER);
        if (mapper == null) {
            mapper = createSubscriptionMapper(session);
            session.getAttributes().put(SUBSCRIPTIONMAPPER, mapper);
        }
        return mapper;
View Full Code Here

    @SuppressWarnings("unchecked")
    public void endProcessingRequest(MailboxSession session) {
        if (session == null) return;
        MessageMapper<Id> messageMapper = (MessageMapper<Id>) session.getAttributes().get(MESSAGEMAPPER);
        MailboxMapper<Id> mailboxMapper = (MailboxMapper<Id>) session.getAttributes().get(MAILBOXMAPPER);
        SubscriptionMapper subscriptionMapper = (SubscriptionMapper) session.getAttributes().get(SUBSCRIPTIONMAPPER);
        if (messageMapper != null)
            messageMapper.endRequest();
        if (mailboxMapper != null)
            mailboxMapper.endRequest();
        if (subscriptionMapper != null)
            subscriptionMapper.endRequest();       
    }
View Full Code Here

     *
     * @param session
     * @return mapper
     */
    public SubscriptionMapper getSubscriptionMapper(MailboxSession session) throws SubscriptionException {
        SubscriptionMapper mapper = (SubscriptionMapper) session.getAttributes().get(SUBSCRIPTIONMAPPER);
        if (mapper == null) {
            mapper = createSubscriptionMapper(session);
            session.getAttributes().put(SUBSCRIPTIONMAPPER, mapper);
        }
        return mapper;
View Full Code Here

    @SuppressWarnings("unchecked")
    public void endProcessingRequest(MailboxSession session) {
        if (session == null) return;
        MessageMapper<Id> messageMapper = (MessageMapper<Id>) session.getAttributes().get(MESSAGEMAPPER);
        MailboxMapper<Id> mailboxMapper = (MailboxMapper<Id>) session.getAttributes().get(MAILBOXMAPPER);
        SubscriptionMapper subscriptionMapper = (SubscriptionMapper) session.getAttributes().get(SUBSCRIPTIONMAPPER);
        if (messageMapper != null)
            messageMapper.endRequest();
        if (mailboxMapper != null)
            mailboxMapper.endRequest();
        if (subscriptionMapper != null)
            subscriptionMapper.endRequest();       
    }
View Full Code Here

    /**
     * @see org.apache.james.mailbox.SubscriptionManager#subscribe(org.apache.james.mailbox.MailboxSession, java.lang.String)
     */
    public void subscribe(final MailboxSession session, final String mailbox) throws SubscriptionException {
        final SubscriptionMapper mapper = mapperFactory.getSubscriptionMapper(session);
        try {
            mapper.execute(new Mapper.VoidTransaction() {

                public void runVoid() throws MailboxException {
                    final Subscription subscription = mapper.findMailboxSubscriptionForUser(session.getUser().getUserName(), mailbox);
                    if (subscription == null) {
                        final Subscription newSubscription = createSubscription(session, mailbox);
                        mapper.save(newSubscription);
                    }
                }
               
            });
        } catch (MailboxException e) {
View Full Code Here

    /**
     * @see org.apache.james.mailbox.SubscriptionManager#subscriptions(org.apache.james.mailbox.MailboxSession)
     */
    public Collection<String> subscriptions(final MailboxSession session) throws SubscriptionException {
        final SubscriptionMapper mapper = mapperFactory.getSubscriptionMapper(session);
        final List<Subscription> subscriptions = mapper.findSubscriptionsForUser(session.getUser().getUserName());
        final Collection<String> results = new HashSet<String>(INITIAL_SIZE);
        for (Subscription subscription:subscriptions) {
            results.add(subscription.getMailbox());
        }       
        return results;
View Full Code Here

    /**
     * @see org.apache.james.mailbox.SubscriptionManager#unsubscribe(org.apache.james.mailbox.MailboxSession, java.lang.String)
     */
    public void unsubscribe(final MailboxSession session, final String mailbox) throws SubscriptionException {
        final SubscriptionMapper mapper = mapperFactory.getSubscriptionMapper(session);
        try {
            mapper.execute(new Mapper.VoidTransaction() {

                public void runVoid() throws MailboxException {
                    final Subscription subscription = mapper.findMailboxSubscriptionForUser(session.getUser().getUserName(), mailbox);
                    if (subscription != null) {
                        mapper.delete(subscription);
                    }
                }

            });
        } catch (MailboxException e) {
View Full Code Here

TOP

Related Classes of org.apache.james.mailbox.store.user.SubscriptionMapper

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.