Repository: james-project Updated Branches: refs/heads/master 31ae6de4c -> 7697abfe1
MAILBOX-268 Introduce a default AttachmentMapper Project: http://git-wip-us.apache.org/repos/asf/james-project/repo Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/7b259d9a Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/7b259d9a Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/7b259d9a Branch: refs/heads/master Commit: 7b259d9a28f72115a07ada5b7e4511acdb65ba51 Parents: 321ad9a Author: Antoine Duprat <adup...@linagora.com> Authored: Wed May 25 10:14:34 2016 +0200 Committer: Antoine Duprat <antdup...@gmail.com> Committed: Fri May 27 10:01:52 2016 +0200 ---------------------------------------------------------------------- .../CachingMailboxSessionMapperFactory.java | 7 +++ .../CassandraMailboxSessionMapperFactory.java | 7 +++ .../hbase/HBaseMailboxSessionMapperFactory.java | 7 +++ .../jcr/JCRMailboxSessionMapperFactory.java | 7 +++ .../jpa/JPAMailboxSessionMapperFactory.java | 8 ++++ .../MaildirMailboxSessionMapperFactory.java | 8 ++++ .../InMemoryMailboxSessionMapperFactory.java | 9 ++++ .../store/MailboxSessionMapperFactory.java | 13 ++++++ .../store/mail/NoopAttachmentMapper.java | 47 ++++++++++++++++++++ 9 files changed, 113 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/james-project/blob/7b259d9a/mailbox/caching/src/main/java/org/apache/james/mailbox/caching/CachingMailboxSessionMapperFactory.java ---------------------------------------------------------------------- diff --git a/mailbox/caching/src/main/java/org/apache/james/mailbox/caching/CachingMailboxSessionMapperFactory.java b/mailbox/caching/src/main/java/org/apache/james/mailbox/caching/CachingMailboxSessionMapperFactory.java index d5cb0a9..0495d59 100644 --- a/mailbox/caching/src/main/java/org/apache/james/mailbox/caching/CachingMailboxSessionMapperFactory.java +++ b/mailbox/caching/src/main/java/org/apache/james/mailbox/caching/CachingMailboxSessionMapperFactory.java @@ -4,8 +4,10 @@ import org.apache.james.mailbox.MailboxSession; import org.apache.james.mailbox.exception.MailboxException; import org.apache.james.mailbox.exception.SubscriptionException; import org.apache.james.mailbox.store.MailboxSessionMapperFactory; +import org.apache.james.mailbox.store.mail.AttachmentMapper; import org.apache.james.mailbox.store.mail.MailboxMapper; import org.apache.james.mailbox.store.mail.MessageMapper; +import org.apache.james.mailbox.store.mail.NoopAttachmentMapper; import org.apache.james.mailbox.store.user.SubscriptionMapper; /** @@ -45,4 +47,9 @@ public class CachingMailboxSessionMapperFactory extends return underlying.createSubscriptionMapper(session); } + @Override + public AttachmentMapper createAttachmentMapper(MailboxSession session) throws MailboxException { + return new NoopAttachmentMapper(); + } + } http://git-wip-us.apache.org/repos/asf/james-project/blob/7b259d9a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraMailboxSessionMapperFactory.java ---------------------------------------------------------------------- diff --git a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraMailboxSessionMapperFactory.java b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraMailboxSessionMapperFactory.java index dd8025d..02e8373 100644 --- a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraMailboxSessionMapperFactory.java +++ b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraMailboxSessionMapperFactory.java @@ -27,8 +27,10 @@ import org.apache.james.mailbox.cassandra.mail.CassandraMailboxMapper; import org.apache.james.mailbox.cassandra.mail.CassandraMessageMapper; import org.apache.james.mailbox.cassandra.user.CassandraSubscriptionMapper; import org.apache.james.mailbox.store.MailboxSessionMapperFactory; +import org.apache.james.mailbox.store.mail.AttachmentMapper; import org.apache.james.mailbox.store.mail.MailboxMapper; import org.apache.james.mailbox.store.mail.ModSeqProvider; +import org.apache.james.mailbox.store.mail.NoopAttachmentMapper; import org.apache.james.mailbox.store.mail.UidProvider; import org.apache.james.mailbox.store.user.SubscriptionMapper; @@ -71,6 +73,11 @@ public class CassandraMailboxSessionMapperFactory extends MailboxSessionMapperFa } @Override + public AttachmentMapper createAttachmentMapper(MailboxSession mailboxSession) { + return new NoopAttachmentMapper(); + } + + @Override public SubscriptionMapper createSubscriptionMapper(MailboxSession mailboxSession) { return new CassandraSubscriptionMapper(session); } http://git-wip-us.apache.org/repos/asf/james-project/blob/7b259d9a/mailbox/hbase/src/main/java/org/apache/james/mailbox/hbase/HBaseMailboxSessionMapperFactory.java ---------------------------------------------------------------------- diff --git a/mailbox/hbase/src/main/java/org/apache/james/mailbox/hbase/HBaseMailboxSessionMapperFactory.java b/mailbox/hbase/src/main/java/org/apache/james/mailbox/hbase/HBaseMailboxSessionMapperFactory.java index 400bf78..0f93752 100644 --- a/mailbox/hbase/src/main/java/org/apache/james/mailbox/hbase/HBaseMailboxSessionMapperFactory.java +++ b/mailbox/hbase/src/main/java/org/apache/james/mailbox/hbase/HBaseMailboxSessionMapperFactory.java @@ -43,9 +43,11 @@ import org.apache.james.mailbox.hbase.mail.HBaseMailboxMapper; import org.apache.james.mailbox.hbase.mail.HBaseMessageMapper; import org.apache.james.mailbox.hbase.user.HBaseSubscriptionMapper; import org.apache.james.mailbox.store.MailboxSessionMapperFactory; +import org.apache.james.mailbox.store.mail.AttachmentMapper; import org.apache.james.mailbox.store.mail.MailboxMapper; import org.apache.james.mailbox.store.mail.MessageMapper; import org.apache.james.mailbox.store.mail.ModSeqProvider; +import org.apache.james.mailbox.store.mail.NoopAttachmentMapper; import org.apache.james.mailbox.store.mail.UidProvider; import org.apache.james.mailbox.store.user.SubscriptionMapper; @@ -140,6 +142,11 @@ public class HBaseMailboxSessionMapperFactory extends MailboxSessionMapperFactor return new HBaseSubscriptionMapper(this.conf); } + @Override + public AttachmentMapper createAttachmentMapper(MailboxSession session) throws MailboxException { + return new NoopAttachmentMapper(); + } + /** * Returns the configuration object for accessing the cluster. * @return The configuration for accessing the cluster http://git-wip-us.apache.org/repos/asf/james-project/blob/7b259d9a/mailbox/jcr/src/main/java/org/apache/james/mailbox/jcr/JCRMailboxSessionMapperFactory.java ---------------------------------------------------------------------- diff --git a/mailbox/jcr/src/main/java/org/apache/james/mailbox/jcr/JCRMailboxSessionMapperFactory.java b/mailbox/jcr/src/main/java/org/apache/james/mailbox/jcr/JCRMailboxSessionMapperFactory.java index 35a80ea..151fbb3 100644 --- a/mailbox/jcr/src/main/java/org/apache/james/mailbox/jcr/JCRMailboxSessionMapperFactory.java +++ b/mailbox/jcr/src/main/java/org/apache/james/mailbox/jcr/JCRMailboxSessionMapperFactory.java @@ -25,9 +25,11 @@ import org.apache.james.mailbox.jcr.mail.JCRMailboxMapper; import org.apache.james.mailbox.jcr.mail.JCRMessageMapper; import org.apache.james.mailbox.jcr.user.JCRSubscriptionMapper; import org.apache.james.mailbox.store.MailboxSessionMapperFactory; +import org.apache.james.mailbox.store.mail.AttachmentMapper; import org.apache.james.mailbox.store.mail.MailboxMapper; import org.apache.james.mailbox.store.mail.MessageMapper; import org.apache.james.mailbox.store.mail.ModSeqProvider; +import org.apache.james.mailbox.store.mail.NoopAttachmentMapper; import org.apache.james.mailbox.store.mail.UidProvider; import org.apache.james.mailbox.store.user.SubscriptionMapper; @@ -72,6 +74,11 @@ public class JCRMailboxSessionMapperFactory extends MailboxSessionMapperFactory return new JCRSubscriptionMapper(repository, session, DEFAULT_SCALING); } + @Override + public AttachmentMapper createAttachmentMapper(MailboxSession session) throws MailboxException { + return new NoopAttachmentMapper(); + } + public MailboxSessionJCRRepository getRepository() { return repository; } http://git-wip-us.apache.org/repos/asf/james-project/blob/7b259d9a/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/JPAMailboxSessionMapperFactory.java ---------------------------------------------------------------------- diff --git a/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/JPAMailboxSessionMapperFactory.java b/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/JPAMailboxSessionMapperFactory.java index 73890fb..7a3e4a1 100644 --- a/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/JPAMailboxSessionMapperFactory.java +++ b/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/JPAMailboxSessionMapperFactory.java @@ -22,13 +22,16 @@ import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; import org.apache.james.mailbox.MailboxSession; +import org.apache.james.mailbox.exception.MailboxException; import org.apache.james.mailbox.jpa.mail.JPAMailboxMapper; import org.apache.james.mailbox.jpa.mail.JPAMessageMapper; import org.apache.james.mailbox.jpa.user.JPASubscriptionMapper; import org.apache.james.mailbox.store.MailboxSessionMapperFactory; +import org.apache.james.mailbox.store.mail.AttachmentMapper; import org.apache.james.mailbox.store.mail.MailboxMapper; import org.apache.james.mailbox.store.mail.MessageMapper; import org.apache.james.mailbox.store.mail.ModSeqProvider; +import org.apache.james.mailbox.store.mail.NoopAttachmentMapper; import org.apache.james.mailbox.store.mail.UidProvider; import org.apache.james.mailbox.store.user.SubscriptionMapper; @@ -63,6 +66,11 @@ public class JPAMailboxSessionMapperFactory extends MailboxSessionMapperFactory public SubscriptionMapper createSubscriptionMapper(MailboxSession session) { return new JPASubscriptionMapper(entityManagerFactory); } + + @Override + public AttachmentMapper createAttachmentMapper(MailboxSession session) throws MailboxException { + return new NoopAttachmentMapper(); + } /** * Return a new {@link EntityManager} instance http://git-wip-us.apache.org/repos/asf/james-project/blob/7b259d9a/mailbox/maildir/src/main/java/org/apache/james/mailbox/maildir/MaildirMailboxSessionMapperFactory.java ---------------------------------------------------------------------- diff --git a/mailbox/maildir/src/main/java/org/apache/james/mailbox/maildir/MaildirMailboxSessionMapperFactory.java b/mailbox/maildir/src/main/java/org/apache/james/mailbox/maildir/MaildirMailboxSessionMapperFactory.java index de572a5..bd4c3f4 100644 --- a/mailbox/maildir/src/main/java/org/apache/james/mailbox/maildir/MaildirMailboxSessionMapperFactory.java +++ b/mailbox/maildir/src/main/java/org/apache/james/mailbox/maildir/MaildirMailboxSessionMapperFactory.java @@ -25,8 +25,10 @@ import org.apache.james.mailbox.maildir.mail.MaildirMailboxMapper; import org.apache.james.mailbox.maildir.mail.MaildirMessageMapper; import org.apache.james.mailbox.maildir.user.MaildirSubscriptionMapper; import org.apache.james.mailbox.store.MailboxSessionMapperFactory; +import org.apache.james.mailbox.store.mail.AttachmentMapper; import org.apache.james.mailbox.store.mail.MailboxMapper; import org.apache.james.mailbox.store.mail.MessageMapper; +import org.apache.james.mailbox.store.mail.NoopAttachmentMapper; import org.apache.james.mailbox.store.user.SubscriptionMapper; public class MaildirMailboxSessionMapperFactory extends @@ -58,4 +60,10 @@ public class MaildirMailboxSessionMapperFactory extends return new MaildirSubscriptionMapper(store); } + + @Override + public AttachmentMapper createAttachmentMapper(MailboxSession session) throws MailboxException { + return new NoopAttachmentMapper(); + } + } http://git-wip-us.apache.org/repos/asf/james-project/blob/7b259d9a/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/InMemoryMailboxSessionMapperFactory.java ---------------------------------------------------------------------- diff --git a/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/InMemoryMailboxSessionMapperFactory.java b/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/InMemoryMailboxSessionMapperFactory.java index ed8184f..db46861 100644 --- a/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/InMemoryMailboxSessionMapperFactory.java +++ b/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/InMemoryMailboxSessionMapperFactory.java @@ -27,8 +27,10 @@ import org.apache.james.mailbox.inmemory.mail.InMemoryModSeqProvider; import org.apache.james.mailbox.inmemory.mail.InMemoryUidProvider; import org.apache.james.mailbox.inmemory.user.InMemorySubscriptionMapper; import org.apache.james.mailbox.store.MailboxSessionMapperFactory; +import org.apache.james.mailbox.store.mail.AttachmentMapper; import org.apache.james.mailbox.store.mail.MailboxMapper; import org.apache.james.mailbox.store.mail.MessageMapper; +import org.apache.james.mailbox.store.mail.NoopAttachmentMapper; import org.apache.james.mailbox.store.user.SubscriptionMapper; public class InMemoryMailboxSessionMapperFactory extends MailboxSessionMapperFactory { @@ -36,11 +38,13 @@ public class InMemoryMailboxSessionMapperFactory extends MailboxSessionMapperFac private final MailboxMapper mailboxMapper; private final MessageMapper messageMapper; private final SubscriptionMapper subscriptionMapper; + private final AttachmentMapper attachmentMapper; public InMemoryMailboxSessionMapperFactory() { mailboxMapper = new InMemoryMailboxMapper(); messageMapper = new InMemoryMessageMapper(null, new InMemoryUidProvider(), new InMemoryModSeqProvider()); subscriptionMapper = new InMemorySubscriptionMapper(); + attachmentMapper = new NoopAttachmentMapper(); } @Override @@ -57,6 +61,11 @@ public class InMemoryMailboxSessionMapperFactory extends MailboxSessionMapperFac public SubscriptionMapper createSubscriptionMapper(MailboxSession session) throws SubscriptionException { return subscriptionMapper; } + + @Override + public AttachmentMapper createAttachmentMapper(MailboxSession session) throws MailboxException { + return attachmentMapper; + } public void deleteAll() throws MailboxException { ((InMemoryMailboxMapper) mailboxMapper).deleteAll(); http://git-wip-us.apache.org/repos/asf/james-project/blob/7b259d9a/mailbox/store/src/main/java/org/apache/james/mailbox/store/MailboxSessionMapperFactory.java ---------------------------------------------------------------------- diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/MailboxSessionMapperFactory.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/MailboxSessionMapperFactory.java index 3069eae..7c3da7d 100644 --- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/MailboxSessionMapperFactory.java +++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/MailboxSessionMapperFactory.java @@ -22,6 +22,7 @@ import org.apache.james.mailbox.MailboxSession; import org.apache.james.mailbox.RequestAware; import org.apache.james.mailbox.exception.MailboxException; import org.apache.james.mailbox.exception.SubscriptionException; +import org.apache.james.mailbox.store.mail.AttachmentMapper; import org.apache.james.mailbox.store.mail.MailboxMapper; import org.apache.james.mailbox.store.mail.MailboxMapperFactory; import org.apache.james.mailbox.store.mail.MessageMapper; @@ -36,6 +37,7 @@ import org.apache.james.mailbox.store.user.SubscriptionMapperFactory; */ public abstract class MailboxSessionMapperFactory implements RequestAware, MailboxMapperFactory, MessageMapperFactory, SubscriptionMapperFactory{ + protected final static String ATTACHMENTMAPPER = "ATTACHMENTMAPPER"; protected final static String MESSAGEMAPPER ="MESSAGEMAPPER"; protected final static String MAILBOXMAPPER ="MAILBOXMAPPER"; protected final static String SUBSCRIPTIONMAPPER ="SUBSCRIPTIONMAPPER"; @@ -54,6 +56,15 @@ public abstract class MailboxSessionMapperFactory implements RequestAware, Mailb return mapper; } + public AttachmentMapper getAttachmentMapper(MailboxSession session) throws MailboxException { + AttachmentMapper mapper = (AttachmentMapper) session.getAttributes().get(ATTACHMENTMAPPER); + if (mapper == null) { + mapper = createAttachmentMapper(session); + session.getAttributes().put(ATTACHMENTMAPPER, mapper); + } + return mapper; + } + /** * Create a {@link MessageMapper} instance which will get reused during the whole {@link MailboxSession} * @@ -63,6 +74,8 @@ public abstract class MailboxSessionMapperFactory implements RequestAware, Mailb */ public abstract MessageMapper createMessageMapper(MailboxSession session) throws MailboxException; + public abstract AttachmentMapper createAttachmentMapper(MailboxSession session) throws MailboxException; + /** * @see org.apache.james.mailbox.store.mail.MailboxMapperFactory#getMailboxMapper(MailboxSession) http://git-wip-us.apache.org/repos/asf/james-project/blob/7b259d9a/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/NoopAttachmentMapper.java ---------------------------------------------------------------------- diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/NoopAttachmentMapper.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/NoopAttachmentMapper.java new file mode 100644 index 0000000..b6aeb59 --- /dev/null +++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/NoopAttachmentMapper.java @@ -0,0 +1,47 @@ +/**************************************************************** + * Licensed to the Apache Software Foundation (ASF) under one * + * or more contributor license agreements. See the NOTICE file * + * distributed with this work for additional information * + * regarding copyright ownership. The ASF licenses this file * + * to you under the Apache License, Version 2.0 (the * + * "License"); you may not use this file except in compliance * + * with the License. You may obtain a copy of the License at * + * * + * http://www.apache.org/licenses/LICENSE-2.0 * + * * + * Unless required by applicable law or agreed to in writing, * + * software distributed under the License is distributed on an * + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * + * KIND, either express or implied. See the License for the * + * specific language governing permissions and limitations * + * under the License. * + ****************************************************************/ + +package org.apache.james.mailbox.store.mail; + +import org.apache.james.mailbox.exception.AttachmentNotFoundException; +import org.apache.james.mailbox.exception.MailboxException; +import org.apache.james.mailbox.store.mail.model.Attachment; +import org.apache.james.mailbox.store.mail.model.AttachmentId; + +public class NoopAttachmentMapper implements AttachmentMapper { + + @Override + public void endRequest() { + + } + + @Override + public <T> T execute(Transaction<T> transaction) throws MailboxException { + return transaction.run(); + } + + @Override + public Attachment getAttachment(AttachmentId attachmentId) throws AttachmentNotFoundException { + return null; + } + + @Override + public void storeAttachment(Attachment attachment) throws MailboxException { + } +} --------------------------------------------------------------------- To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org