JAMES-1818 Introduce AttachmentManager
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/f2d46ab4 Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/f2d46ab4 Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/f2d46ab4 Branch: refs/heads/master Commit: f2d46ab4c6ca16f26d54f82190d9b92bf7861e33 Parents: 81f3420 Author: Raphael Ouazana <[email protected]> Authored: Thu Aug 18 15:09:20 2016 +0200 Committer: Raphael Ouazana <[email protected]> Committed: Mon Aug 29 15:15:43 2016 +0200 ---------------------------------------------------------------------- .../apache/james/mailbox/AttachmentManager.java | 39 +++++++++++ .../mailbox/store/StoreAttachmentManager.java | 72 ++++++++++++++++++++ 2 files changed, 111 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/james-project/blob/f2d46ab4/mailbox/api/src/main/java/org/apache/james/mailbox/AttachmentManager.java ---------------------------------------------------------------------- diff --git a/mailbox/api/src/main/java/org/apache/james/mailbox/AttachmentManager.java b/mailbox/api/src/main/java/org/apache/james/mailbox/AttachmentManager.java new file mode 100644 index 0000000..e9f2e0f --- /dev/null +++ b/mailbox/api/src/main/java/org/apache/james/mailbox/AttachmentManager.java @@ -0,0 +1,39 @@ +/**************************************************************** + * 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; + +import java.util.Collection; +import java.util.List; + +import org.apache.james.mailbox.exception.AttachmentNotFoundException; +import org.apache.james.mailbox.exception.MailboxException; +import org.apache.james.mailbox.model.Attachment; +import org.apache.james.mailbox.model.AttachmentId; + +public interface AttachmentManager { + + Attachment getAttachment(AttachmentId attachmentId, MailboxSession mailboxSession) throws MailboxException, AttachmentNotFoundException; + + List<Attachment> getAttachments(List<AttachmentId> attachmentIds, MailboxSession mailboxSession) throws MailboxException; + + void storeAttachment(Attachment attachment, MailboxSession mailboxSession) throws MailboxException; + + void storeAttachments(Collection<Attachment> attachments, MailboxSession mailboxSession) throws MailboxException; +} http://git-wip-us.apache.org/repos/asf/james-project/blob/f2d46ab4/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreAttachmentManager.java ---------------------------------------------------------------------- diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreAttachmentManager.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreAttachmentManager.java new file mode 100644 index 0000000..88799d9 --- /dev/null +++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreAttachmentManager.java @@ -0,0 +1,72 @@ +/**************************************************************** + * 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; + +import java.util.Collection; +import java.util.List; + +import javax.inject.Inject; + +import org.apache.james.mailbox.AttachmentManager; +import org.apache.james.mailbox.MailboxSession; +import org.apache.james.mailbox.exception.AttachmentNotFoundException; +import org.apache.james.mailbox.exception.MailboxException; +import org.apache.james.mailbox.model.Attachment; +import org.apache.james.mailbox.model.AttachmentId; +import org.apache.james.mailbox.store.mail.AttachmentMapper; +import org.apache.james.mailbox.store.mail.AttachmentMapperFactory; + +public class StoreAttachmentManager implements AttachmentManager { + + private final AttachmentMapperFactory attachmentMapperFactory; + + @Inject + public StoreAttachmentManager(AttachmentMapperFactory attachmentMapperFactory) { + this.attachmentMapperFactory = attachmentMapperFactory; + } + + protected AttachmentMapperFactory getAttachmentMapperFactory() { + return attachmentMapperFactory; + } + + protected AttachmentMapper getAttachmentMapper(MailboxSession mailboxSession) throws MailboxException { + return attachmentMapperFactory.getAttachmentMapper(mailboxSession); + } + + @Override + public Attachment getAttachment(AttachmentId attachmentId, MailboxSession mailboxSession) throws MailboxException, AttachmentNotFoundException { + return getAttachmentMapper(mailboxSession).getAttachment(attachmentId); + } + + @Override + public List<Attachment> getAttachments(List<AttachmentId> attachmentIds, MailboxSession mailboxSession) throws MailboxException { + return getAttachmentMapper(mailboxSession).getAttachments(attachmentIds); + } + + @Override + public void storeAttachment(Attachment attachment, MailboxSession mailboxSession) throws MailboxException { + getAttachmentMapper(mailboxSession).storeAttachment(attachment); + } + + @Override + public void storeAttachments(Collection<Attachment> attachments, MailboxSession mailboxSession) throws MailboxException { + getAttachmentMapper(mailboxSession).storeAttachments(attachments); + } +} --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
