JAMES-1818 Move Attachment and AttachmentId to API
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/81f3420a Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/81f3420a Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/81f3420a Branch: refs/heads/master Commit: 81f3420a7656167eda12b00b1a14fd264fb7b5ff Parents: 10cbc71 Author: Raphael Ouazana <[email protected]> Authored: Thu Aug 18 15:05:54 2016 +0200 Committer: Raphael Ouazana <[email protected]> Committed: Mon Aug 29 15:15:43 2016 +0200 ---------------------------------------------------------------------- mailbox/api/pom.xml | 4 + .../apache/james/mailbox/model/Attachment.java | 137 +++++++++++++++++++ .../james/mailbox/model/AttachmentId.java | 72 ++++++++++ .../james/mailbox/model/AttachmentIdTest.java | 57 ++++++++ .../james/mailbox/model/AttachmentTest.java | 127 +++++++++++++++++ .../mail/CassandraAttachmentMapper.java | 4 +- .../cassandra/mail/CassandraMessageMapper.java | 4 +- .../inmemory/mail/InMemoryAttachmentMapper.java | 4 +- mailbox/store/pom.xml | 4 - .../mailbox/store/StoreMessageManager.java | 2 +- .../mailbox/store/mail/AttachmentMapper.java | 4 +- .../store/mail/NoopAttachmentMapper.java | 4 +- .../mailbox/store/mail/model/Attachment.java | 137 ------------------- .../mailbox/store/mail/model/AttachmentId.java | 72 ---------- .../store/mail/model/MessageAttachment.java | 2 + .../store/mail/model/impl/MessageParser.java | 2 +- .../store/mail/model/AttachmentIdTest.java | 56 -------- .../store/mail/model/AttachmentMapperTest.java | 2 + .../store/mail/model/AttachmentTest.java | 125 ----------------- .../store/mail/model/MessageAttachmentTest.java | 1 + .../store/mail/model/MessageMapperTest.java | 2 + .../mail/model/impl/MessageParserTest.java | 2 +- .../integration/SetMessagesMethodTest.java | 2 +- .../org/apache/james/jmap/DownloadServlet.java | 4 +- .../org/apache/james/jmap/UploadHandler.java | 2 +- .../methods/SetMessagesCreationProcessor.java | 2 +- .../jmap/methods/MIMEMessageConverterTest.java | 6 +- .../SetMessagesCreationProcessorTest.java | 2 +- .../james/jmap/model/MailboxMessageTest.java | 4 +- 29 files changed, 428 insertions(+), 418 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/james-project/blob/81f3420a/mailbox/api/pom.xml ---------------------------------------------------------------------- diff --git a/mailbox/api/pom.xml b/mailbox/api/pom.xml index 9dbca1d..86b1f27 100644 --- a/mailbox/api/pom.xml +++ b/mailbox/api/pom.xml @@ -41,6 +41,10 @@ <artifactId>commons-lang</artifactId> </dependency> <dependency> + <groupId>commons-codec</groupId> + <artifactId>commons-codec</artifactId> + </dependency> + <dependency> <groupId>${javax.mail.groupId}</groupId> <artifactId>${javax.mail.artifactId}</artifactId> </dependency> http://git-wip-us.apache.org/repos/asf/james-project/blob/81f3420a/mailbox/api/src/main/java/org/apache/james/mailbox/model/Attachment.java ---------------------------------------------------------------------- diff --git a/mailbox/api/src/main/java/org/apache/james/mailbox/model/Attachment.java b/mailbox/api/src/main/java/org/apache/james/mailbox/model/Attachment.java new file mode 100644 index 0000000..2be135a --- /dev/null +++ b/mailbox/api/src/main/java/org/apache/james/mailbox/model/Attachment.java @@ -0,0 +1,137 @@ +/**************************************************************** + * 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.model; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.Arrays; + +import com.google.common.base.MoreObjects; +import com.google.common.base.Objects; +import com.google.common.base.Preconditions; +import com.google.common.base.Strings; + +public class Attachment { + + public static Builder builder() { + return new Builder(); + } + + public static class Builder { + + private AttachmentId attachmentId; + private byte[] bytes; + private String type; + + public Builder attachmentId(AttachmentId attachmentId) { + Preconditions.checkArgument(attachmentId != null); + this.attachmentId = attachmentId; + return this; + } + + public Builder bytes(byte[] bytes) { + Preconditions.checkArgument(bytes != null); + this.bytes = bytes; + return this; + } + + public Builder type(String type) { + Preconditions.checkArgument(!Strings.isNullOrEmpty(type)); + this.type = type; + return this; + } + + public Attachment build() { + Preconditions.checkState(bytes != null, "'bytes' is mandatory"); + AttachmentId builtAttachmentId = attachmentId(); + Preconditions.checkState(builtAttachmentId != null, "'attachmentId' is mandatory"); + Preconditions.checkState(type != null, "'type' is mandatory"); + return new Attachment(bytes, builtAttachmentId, type, size()); + } + + private AttachmentId attachmentId() { + if (attachmentId != null) { + return attachmentId; + } + return AttachmentId.forPayload(bytes); + } + + private long size() { + return bytes.length; + } + } + + private final byte[] bytes; + private final AttachmentId attachmentId; + private final String type; + private final long size; + + private Attachment(byte[] bytes, AttachmentId attachmentId, String type, long size) { + this.bytes = bytes; + this.attachmentId = attachmentId; + this.type = type; + this.size = size; + } + + public AttachmentId getAttachmentId() { + return attachmentId; + } + + public String getType() { + return type; + } + + public long getSize() { + return size; + } + + public InputStream getStream() throws IOException { + return new ByteArrayInputStream(bytes); + } + + @Override + public boolean equals(Object obj) { + if (obj instanceof Attachment) { + Attachment other = (Attachment) obj; + return Objects.equal(attachmentId, other.attachmentId) + && Arrays.equals(bytes, other.bytes) + && Objects.equal(type, other.type) + && Objects.equal(size, other.size); + } + return false; + } + + @Override + public int hashCode() { + return Objects.hashCode(attachmentId, bytes, type, size); + } + + @Override + public String toString() { + return MoreObjects + .toStringHelper(this) + .add("attachmentId", attachmentId) + .add("bytes", bytes) + .add("type", type) + .add("size", size) + .toString(); + } +} http://git-wip-us.apache.org/repos/asf/james-project/blob/81f3420a/mailbox/api/src/main/java/org/apache/james/mailbox/model/AttachmentId.java ---------------------------------------------------------------------- diff --git a/mailbox/api/src/main/java/org/apache/james/mailbox/model/AttachmentId.java b/mailbox/api/src/main/java/org/apache/james/mailbox/model/AttachmentId.java new file mode 100644 index 0000000..0cdc4c3 --- /dev/null +++ b/mailbox/api/src/main/java/org/apache/james/mailbox/model/AttachmentId.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.model; + + +import org.apache.commons.codec.digest.DigestUtils; + +import com.google.common.base.MoreObjects; +import com.google.common.base.Objects; +import com.google.common.base.Preconditions; +import com.google.common.base.Strings; + +public class AttachmentId { + + public static AttachmentId forPayload(byte[] payload) { + Preconditions.checkArgument(payload != null); + return new AttachmentId(DigestUtils.sha1Hex(payload)); + } + + public static AttachmentId from(String id) { + Preconditions.checkArgument(!Strings.isNullOrEmpty(id)); + return new AttachmentId(id); + } + + private final String id; + + private AttachmentId(String id) { + this.id = id; + } + + public String getId() { + return id; + } + + @Override + public boolean equals(Object obj) { + if (obj instanceof AttachmentId) { + AttachmentId other = (AttachmentId) obj; + return Objects.equal(id, other.id); + } + return false; + } + + @Override + public int hashCode() { + return Objects.hashCode(id); + } + + @Override + public String toString() { + return MoreObjects + .toStringHelper(this) + .add("id", id) + .toString(); + } +} http://git-wip-us.apache.org/repos/asf/james-project/blob/81f3420a/mailbox/api/src/test/java/org/apache/james/mailbox/model/AttachmentIdTest.java ---------------------------------------------------------------------- diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/model/AttachmentIdTest.java b/mailbox/api/src/test/java/org/apache/james/mailbox/model/AttachmentIdTest.java new file mode 100644 index 0000000..75039bd --- /dev/null +++ b/mailbox/api/src/test/java/org/apache/james/mailbox/model/AttachmentIdTest.java @@ -0,0 +1,57 @@ +/**************************************************************** + * 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.model; + +import static org.assertj.core.api.Assertions.assertThat; + +import org.apache.james.mailbox.model.AttachmentId; +import org.junit.Test; + +public class AttachmentIdTest { + + @Test + public void forPayloadShouldCalculateTheUnderlyingSha1() { + AttachmentId attachmentId = AttachmentId.forPayload("payload".getBytes()); + String expectedId = "f07e5a815613c5abeddc4b682247a4c42d8a95df"; + assertThat(attachmentId.getId()).isEqualTo(expectedId); + } + + @Test(expected = IllegalArgumentException.class) + public void forPayloadShouldThrowWhenPayloadIsNull() { + AttachmentId.forPayload(null); + } + + @Test(expected = IllegalArgumentException.class) + public void fromShouldThrowWhenIdIsNull() { + AttachmentId.from(null); + } + + @Test(expected = IllegalArgumentException.class) + public void fromShouldThrowWhenIdIsEmpty() { + AttachmentId.from(""); + } + + @Test + public void fromShouldWork() { + String expectedId = "f07e5a815613c5abeddc4b682247a4c42d8a95df"; + AttachmentId attachmentId = AttachmentId.from(expectedId); + assertThat(attachmentId.getId()).isEqualTo(expectedId); + } +} http://git-wip-us.apache.org/repos/asf/james-project/blob/81f3420a/mailbox/api/src/test/java/org/apache/james/mailbox/model/AttachmentTest.java ---------------------------------------------------------------------- diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/model/AttachmentTest.java b/mailbox/api/src/test/java/org/apache/james/mailbox/model/AttachmentTest.java new file mode 100644 index 0000000..6a1c29c --- /dev/null +++ b/mailbox/api/src/test/java/org/apache/james/mailbox/model/AttachmentTest.java @@ -0,0 +1,127 @@ +/**************************************************************** + * 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.model; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.io.InputStream; + +import org.apache.commons.io.IOUtils; +import org.apache.james.mailbox.model.Attachment; + +import org.junit.Test; + +public class AttachmentTest { + + @Test + public void streamShouldBeConsumedOneTime() throws Exception { + String input = "mystream"; + Attachment attachment = Attachment.builder() + .bytes(input.getBytes()) + .type("content") + .build(); + + InputStream stream = attachment.getStream(); + assertThat(stream).isNotNull(); + assertThat(IOUtils.toString(stream)).isEqualTo(input); + } + + @Test + public void streamShouldBeConsumedMoreThanOneTime() throws Exception { + String input = "mystream"; + Attachment attachment = Attachment.builder() + .bytes(input.getBytes()) + .type("content") + .build(); + + attachment.getStream(); + InputStream stream = attachment.getStream(); + assertThat(stream).isNotNull(); + assertThat(IOUtils.toString(stream)).isEqualTo(input); + } + + @Test (expected = IllegalArgumentException.class) + public void builderShouldThrowWhenAttachmentIdIsNull() { + Attachment.builder() + .attachmentId(null); + } + + @Test (expected = IllegalArgumentException.class) + public void builderShouldThrowWhenBytesIsNull() { + Attachment.builder() + .bytes(null); + } + + @Test (expected = IllegalArgumentException.class) + public void builderShouldThrowWhenTypeIsNull() { + Attachment.builder() + .type(null); + } + + @Test (expected = IllegalArgumentException.class) + public void builderShouldThrowWhenTypeIsEmpty() { + Attachment.builder() + .type(""); + } + + @Test (expected = IllegalStateException.class) + public void buildShouldThrowWhenAttachmentIdIsNotProvided() { + Attachment.builder().build(); + } + + @Test (expected = IllegalStateException.class) + public void buildShouldThrowWhenBytesIsNotProvided() { + Attachment.builder() + .attachmentId(AttachmentId.forPayload("mystream".getBytes())) + .build(); + } + + @Test (expected = IllegalStateException.class) + public void buildShouldThrowWhenTypeIsNotProvided() { + Attachment.builder() + .attachmentId(AttachmentId.forPayload("mystream".getBytes())) + .bytes("mystream".getBytes()) + .build(); + } + + @Test + public void buildShouldSetTheAttachmentId() throws Exception { + byte[] bytes = "mystream".getBytes(); + Attachment attachment = Attachment.builder() + .bytes(bytes) + .type("content") + .build(); + AttachmentId expected = AttachmentId.forPayload(bytes); + + assertThat(attachment.getAttachmentId()).isEqualTo(expected); + } + + @Test + public void buildShouldSetTheSize() throws Exception { + String input = "mystream"; + Attachment attachment = Attachment.builder() + .bytes(input.getBytes()) + .type("content") + .build(); + + assertThat(attachment.getSize()).isEqualTo(input.getBytes().length); + } +} http://git-wip-us.apache.org/repos/asf/james-project/blob/81f3420a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraAttachmentMapper.java ---------------------------------------------------------------------- diff --git a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraAttachmentMapper.java b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraAttachmentMapper.java index e47ad93..768c964 100644 --- a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraAttachmentMapper.java +++ b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraAttachmentMapper.java @@ -40,9 +40,9 @@ import org.apache.commons.io.IOUtils; import org.apache.james.backends.cassandra.utils.CassandraAsyncExecutor; 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.model.Attachment; -import org.apache.james.mailbox.store.mail.model.AttachmentId; import com.datastax.driver.core.ResultSet; import com.datastax.driver.core.Row; http://git-wip-us.apache.org/repos/asf/james-project/blob/81f3420a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageMapper.java ---------------------------------------------------------------------- diff --git a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageMapper.java b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageMapper.java index 4e7bd9f..4818ed7 100644 --- a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageMapper.java +++ b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageMapper.java @@ -84,6 +84,8 @@ import org.apache.james.mailbox.cassandra.table.CassandraMessageTable; import org.apache.james.mailbox.cassandra.table.CassandraMessageTable.Attachments; import org.apache.james.mailbox.cassandra.table.CassandraMessageTable.Properties; 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.model.MessageMetaData; import org.apache.james.mailbox.model.MessageRange; import org.apache.james.mailbox.model.UpdatedFlags; @@ -93,8 +95,6 @@ import org.apache.james.mailbox.store.mail.AttachmentMapper; import org.apache.james.mailbox.store.mail.MessageMapper; import org.apache.james.mailbox.store.mail.ModSeqProvider; import org.apache.james.mailbox.store.mail.UidProvider; -import org.apache.james.mailbox.store.mail.model.Attachment; -import org.apache.james.mailbox.store.mail.model.AttachmentId; import org.apache.james.mailbox.store.mail.model.Mailbox; import org.apache.james.mailbox.store.mail.model.MailboxMessage; import org.apache.james.mailbox.store.mail.model.MessageAttachment; http://git-wip-us.apache.org/repos/asf/james-project/blob/81f3420a/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/mail/InMemoryAttachmentMapper.java ---------------------------------------------------------------------- diff --git a/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/mail/InMemoryAttachmentMapper.java b/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/mail/InMemoryAttachmentMapper.java index 188318e..43e4699 100644 --- a/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/mail/InMemoryAttachmentMapper.java +++ b/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/mail/InMemoryAttachmentMapper.java @@ -25,9 +25,9 @@ import java.util.concurrent.ConcurrentHashMap; 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.model.Attachment; -import org.apache.james.mailbox.store.mail.model.AttachmentId; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; http://git-wip-us.apache.org/repos/asf/james-project/blob/81f3420a/mailbox/store/pom.xml ---------------------------------------------------------------------- diff --git a/mailbox/store/pom.xml b/mailbox/store/pom.xml index 599e1bc..fd4993a 100644 --- a/mailbox/store/pom.xml +++ b/mailbox/store/pom.xml @@ -69,10 +69,6 @@ <artifactId>commons-lang</artifactId> </dependency> <dependency> - <groupId>commons-codec</groupId> - <artifactId>commons-codec</artifactId> - </dependency> - <dependency> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> </dependency> http://git-wip-us.apache.org/repos/asf/james-project/blob/81f3420a/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMessageManager.java ---------------------------------------------------------------------- diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMessageManager.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMessageManager.java index f0452db..5bdb68c 100644 --- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMessageManager.java +++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMessageManager.java @@ -49,6 +49,7 @@ import org.apache.james.mailbox.acl.UnionMailboxACLResolver; import org.apache.james.mailbox.exception.MailboxException; import org.apache.james.mailbox.exception.ReadOnlyException; import org.apache.james.mailbox.exception.UnsupportedRightException; +import org.apache.james.mailbox.model.Attachment; import org.apache.james.mailbox.model.MailboxACL; import org.apache.james.mailbox.model.MailboxACL.MailboxACLRights; import org.apache.james.mailbox.model.MailboxId; @@ -65,7 +66,6 @@ import org.apache.james.mailbox.store.event.MailboxEventDispatcher; import org.apache.james.mailbox.store.mail.AttachmentMapper; import org.apache.james.mailbox.store.mail.MessageMapper; import org.apache.james.mailbox.store.mail.MessageMapper.FetchType; -import org.apache.james.mailbox.store.mail.model.Attachment; import org.apache.james.mailbox.store.mail.model.Mailbox; import org.apache.james.mailbox.store.mail.model.MailboxMessage; import org.apache.james.mailbox.store.mail.model.MessageAttachment; http://git-wip-us.apache.org/repos/asf/james-project/blob/81f3420a/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/AttachmentMapper.java ---------------------------------------------------------------------- diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/AttachmentMapper.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/AttachmentMapper.java index 946a460..dffc815 100644 --- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/AttachmentMapper.java +++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/AttachmentMapper.java @@ -23,8 +23,8 @@ import java.util.List; 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; +import org.apache.james.mailbox.model.Attachment; +import org.apache.james.mailbox.model.AttachmentId; import org.apache.james.mailbox.store.transaction.Mapper; public interface AttachmentMapper extends Mapper { http://git-wip-us.apache.org/repos/asf/james-project/blob/81f3420a/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 index 36000e8..072ae70 100644 --- 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 @@ -24,8 +24,8 @@ import java.util.List; 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; +import org.apache.james.mailbox.model.Attachment; +import org.apache.james.mailbox.model.AttachmentId; public class NoopAttachmentMapper implements AttachmentMapper { http://git-wip-us.apache.org/repos/asf/james-project/blob/81f3420a/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/Attachment.java ---------------------------------------------------------------------- diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/Attachment.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/Attachment.java deleted file mode 100644 index 441b690..0000000 --- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/Attachment.java +++ /dev/null @@ -1,137 +0,0 @@ -/**************************************************************** - * 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.model; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.Arrays; - -import com.google.common.base.MoreObjects; -import com.google.common.base.Objects; -import com.google.common.base.Preconditions; -import com.google.common.base.Strings; - -public class Attachment { - - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - - private AttachmentId attachmentId; - private byte[] bytes; - private String type; - - public Builder attachmentId(AttachmentId attachmentId) { - Preconditions.checkArgument(attachmentId != null); - this.attachmentId = attachmentId; - return this; - } - - public Builder bytes(byte[] bytes) { - Preconditions.checkArgument(bytes != null); - this.bytes = bytes; - return this; - } - - public Builder type(String type) { - Preconditions.checkArgument(!Strings.isNullOrEmpty(type)); - this.type = type; - return this; - } - - public Attachment build() { - Preconditions.checkState(bytes != null, "'bytes' is mandatory"); - AttachmentId builtAttachmentId = attachmentId(); - Preconditions.checkState(builtAttachmentId != null, "'attachmentId' is mandatory"); - Preconditions.checkState(type != null, "'type' is mandatory"); - return new Attachment(bytes, builtAttachmentId, type, size()); - } - - private AttachmentId attachmentId() { - if (attachmentId != null) { - return attachmentId; - } - return AttachmentId.forPayload(bytes); - } - - private long size() { - return bytes.length; - } - } - - private final byte[] bytes; - private final AttachmentId attachmentId; - private final String type; - private final long size; - - private Attachment(byte[] bytes, AttachmentId attachmentId, String type, long size) { - this.bytes = bytes; - this.attachmentId = attachmentId; - this.type = type; - this.size = size; - } - - public AttachmentId getAttachmentId() { - return attachmentId; - } - - public String getType() { - return type; - } - - public long getSize() { - return size; - } - - public InputStream getStream() throws IOException { - return new ByteArrayInputStream(bytes); - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof Attachment) { - Attachment other = (Attachment) obj; - return Objects.equal(attachmentId, other.attachmentId) - && Arrays.equals(bytes, other.bytes) - && Objects.equal(type, other.type) - && Objects.equal(size, other.size); - } - return false; - } - - @Override - public int hashCode() { - return Objects.hashCode(attachmentId, bytes, type, size); - } - - @Override - public String toString() { - return MoreObjects - .toStringHelper(this) - .add("attachmentId", attachmentId) - .add("bytes", bytes) - .add("type", type) - .add("size", size) - .toString(); - } -} http://git-wip-us.apache.org/repos/asf/james-project/blob/81f3420a/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/AttachmentId.java ---------------------------------------------------------------------- diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/AttachmentId.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/AttachmentId.java deleted file mode 100644 index 344c84e..0000000 --- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/AttachmentId.java +++ /dev/null @@ -1,72 +0,0 @@ -/**************************************************************** - * 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.model; - - -import org.apache.commons.codec.digest.DigestUtils; - -import com.google.common.base.MoreObjects; -import com.google.common.base.Objects; -import com.google.common.base.Preconditions; -import com.google.common.base.Strings; - -public class AttachmentId { - - public static AttachmentId forPayload(byte[] payload) { - Preconditions.checkArgument(payload != null); - return new AttachmentId(DigestUtils.sha1Hex(payload)); - } - - public static AttachmentId from(String id) { - Preconditions.checkArgument(!Strings.isNullOrEmpty(id)); - return new AttachmentId(id); - } - - private final String id; - - private AttachmentId(String id) { - this.id = id; - } - - public String getId() { - return id; - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof AttachmentId) { - AttachmentId other = (AttachmentId) obj; - return Objects.equal(id, other.id); - } - return false; - } - - @Override - public int hashCode() { - return Objects.hashCode(id); - } - - @Override - public String toString() { - return MoreObjects - .toStringHelper(this) - .add("id", id) - .toString(); - } -} http://git-wip-us.apache.org/repos/asf/james-project/blob/81f3420a/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/MessageAttachment.java ---------------------------------------------------------------------- diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/MessageAttachment.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/MessageAttachment.java index 2fb9b78..e59912c 100644 --- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/MessageAttachment.java +++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/MessageAttachment.java @@ -19,6 +19,8 @@ package org.apache.james.mailbox.store.mail.model; +import org.apache.james.mailbox.model.Attachment; +import org.apache.james.mailbox.model.AttachmentId; import org.apache.james.mailbox.store.mail.model.impl.Cid; import com.google.common.annotations.VisibleForTesting; http://git-wip-us.apache.org/repos/asf/james-project/blob/81f3420a/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/MessageParser.java ---------------------------------------------------------------------- diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/MessageParser.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/MessageParser.java index ba407bb..c4d877a 100644 --- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/MessageParser.java +++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/MessageParser.java @@ -24,7 +24,7 @@ import java.io.IOException; import java.io.InputStream; import java.util.List; -import org.apache.james.mailbox.store.mail.model.Attachment; +import org.apache.james.mailbox.model.Attachment; import org.apache.james.mailbox.store.mail.model.MessageAttachment; import org.apache.james.mime4j.MimeException; import org.apache.james.mime4j.dom.Body; http://git-wip-us.apache.org/repos/asf/james-project/blob/81f3420a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/AttachmentIdTest.java ---------------------------------------------------------------------- diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/AttachmentIdTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/AttachmentIdTest.java deleted file mode 100644 index b95dc84..0000000 --- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/AttachmentIdTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/**************************************************************** - * 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.model; - -import static org.assertj.core.api.Assertions.assertThat; - -import org.junit.Test; - -public class AttachmentIdTest { - - @Test - public void forPayloadShouldCalculateTheUnderlyingSha1() { - AttachmentId attachmentId = AttachmentId.forPayload("payload".getBytes()); - String expectedId = "f07e5a815613c5abeddc4b682247a4c42d8a95df"; - assertThat(attachmentId.getId()).isEqualTo(expectedId); - } - - @Test(expected = IllegalArgumentException.class) - public void forPayloadShouldThrowWhenPayloadIsNull() { - AttachmentId.forPayload(null); - } - - @Test(expected = IllegalArgumentException.class) - public void fromShouldThrowWhenIdIsNull() { - AttachmentId.from(null); - } - - @Test(expected = IllegalArgumentException.class) - public void fromShouldThrowWhenIdIsEmpty() { - AttachmentId.from(""); - } - - @Test - public void fromShouldWork() { - String expectedId = "f07e5a815613c5abeddc4b682247a4c42d8a95df"; - AttachmentId attachmentId = AttachmentId.from(expectedId); - assertThat(attachmentId.getId()).isEqualTo(expectedId); - } -} http://git-wip-us.apache.org/repos/asf/james-project/blob/81f3420a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/AttachmentMapperTest.java ---------------------------------------------------------------------- diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/AttachmentMapperTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/AttachmentMapperTest.java index 830cbf5..d3ba172 100644 --- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/AttachmentMapperTest.java +++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/AttachmentMapperTest.java @@ -25,6 +25,8 @@ 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; import org.apache.james.mailbox.store.mail.AttachmentMapper; import org.junit.After; import org.junit.Rule; http://git-wip-us.apache.org/repos/asf/james-project/blob/81f3420a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/AttachmentTest.java ---------------------------------------------------------------------- diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/AttachmentTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/AttachmentTest.java deleted file mode 100644 index a0018ba..0000000 --- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/AttachmentTest.java +++ /dev/null @@ -1,125 +0,0 @@ -/**************************************************************** - * 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.model; - -import static org.assertj.core.api.Assertions.assertThat; - -import java.io.InputStream; - -import org.apache.commons.io.IOUtils; -import org.junit.Test; - -public class AttachmentTest { - - @Test - public void streamShouldBeConsumedOneTime() throws Exception { - String input = "mystream"; - Attachment attachment = Attachment.builder() - .bytes(input.getBytes()) - .type("content") - .build(); - - InputStream stream = attachment.getStream(); - assertThat(stream).isNotNull(); - assertThat(IOUtils.toString(stream)).isEqualTo(input); - } - - @Test - public void streamShouldBeConsumedMoreThanOneTime() throws Exception { - String input = "mystream"; - Attachment attachment = Attachment.builder() - .bytes(input.getBytes()) - .type("content") - .build(); - - attachment.getStream(); - InputStream stream = attachment.getStream(); - assertThat(stream).isNotNull(); - assertThat(IOUtils.toString(stream)).isEqualTo(input); - } - - @Test (expected = IllegalArgumentException.class) - public void builderShouldThrowWhenAttachmentIdIsNull() { - Attachment.builder() - .attachmentId(null); - } - - @Test (expected = IllegalArgumentException.class) - public void builderShouldThrowWhenBytesIsNull() { - Attachment.builder() - .bytes(null); - } - - @Test (expected = IllegalArgumentException.class) - public void builderShouldThrowWhenTypeIsNull() { - Attachment.builder() - .type(null); - } - - @Test (expected = IllegalArgumentException.class) - public void builderShouldThrowWhenTypeIsEmpty() { - Attachment.builder() - .type(""); - } - - @Test (expected = IllegalStateException.class) - public void buildShouldThrowWhenAttachmentIdIsNotProvided() { - Attachment.builder().build(); - } - - @Test (expected = IllegalStateException.class) - public void buildShouldThrowWhenBytesIsNotProvided() { - Attachment.builder() - .attachmentId(AttachmentId.forPayload("mystream".getBytes())) - .build(); - } - - @Test (expected = IllegalStateException.class) - public void buildShouldThrowWhenTypeIsNotProvided() { - Attachment.builder() - .attachmentId(AttachmentId.forPayload("mystream".getBytes())) - .bytes("mystream".getBytes()) - .build(); - } - - @Test - public void buildShouldSetTheAttachmentId() throws Exception { - byte[] bytes = "mystream".getBytes(); - Attachment attachment = Attachment.builder() - .bytes(bytes) - .type("content") - .build(); - AttachmentId expected = AttachmentId.forPayload(bytes); - - assertThat(attachment.getAttachmentId()).isEqualTo(expected); - } - - @Test - public void buildShouldSetTheSize() throws Exception { - String input = "mystream"; - Attachment attachment = Attachment.builder() - .bytes(input.getBytes()) - .type("content") - .build(); - - assertThat(attachment.getSize()).isEqualTo(input.getBytes().length); - } -} http://git-wip-us.apache.org/repos/asf/james-project/blob/81f3420a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MessageAttachmentTest.java ---------------------------------------------------------------------- diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MessageAttachmentTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MessageAttachmentTest.java index f29c116..7d13932 100644 --- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MessageAttachmentTest.java +++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MessageAttachmentTest.java @@ -21,6 +21,7 @@ package org.apache.james.mailbox.store.mail.model; import static org.assertj.core.api.Assertions.assertThat; +import org.apache.james.mailbox.model.Attachment; import org.apache.james.mailbox.store.mail.model.impl.Cid; import org.junit.Test; http://git-wip-us.apache.org/repos/asf/james-project/blob/81f3420a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MessageMapperTest.java ---------------------------------------------------------------------- diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MessageMapperTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MessageMapperTest.java index 3c22274..0bfda0c 100644 --- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MessageMapperTest.java +++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MessageMapperTest.java @@ -33,6 +33,8 @@ import javax.mail.util.SharedByteArrayInputStream; import org.apache.james.mailbox.FlagsBuilder; import org.apache.james.mailbox.MessageManager.FlagsUpdateMode; 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.model.MailboxId; import org.apache.james.mailbox.model.MailboxPath; import org.apache.james.mailbox.model.MessageMetaData; http://git-wip-us.apache.org/repos/asf/james-project/blob/81f3420a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/impl/MessageParserTest.java ---------------------------------------------------------------------- diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/impl/MessageParserTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/impl/MessageParserTest.java index ca5354e..fa1edcd 100644 --- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/impl/MessageParserTest.java +++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/impl/MessageParserTest.java @@ -23,7 +23,7 @@ import static org.assertj.core.api.Assertions.assertThat; import java.util.List; -import org.apache.james.mailbox.store.mail.model.Attachment; +import org.apache.james.mailbox.model.Attachment; import org.apache.james.mailbox.store.mail.model.MessageAttachment; import org.junit.Before; import org.junit.Test; http://git-wip-us.apache.org/repos/asf/james-project/blob/81f3420a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMessagesMethodTest.java ---------------------------------------------------------------------- diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMessagesMethodTest.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMessagesMethodTest.java index 9bb8220..c70a7be 100644 --- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMessagesMethodTest.java +++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMessagesMethodTest.java @@ -54,9 +54,9 @@ import org.apache.james.jmap.JmapAuthentication; import org.apache.james.jmap.api.access.AccessToken; import org.apache.james.jmap.model.mailbox.Role; import org.apache.james.mailbox.exception.MailboxException; +import org.apache.james.mailbox.model.Attachment; import org.apache.james.mailbox.model.MailboxConstants; import org.apache.james.mailbox.model.MailboxPath; -import org.apache.james.mailbox.store.mail.model.Attachment; import org.apache.james.mailbox.store.mail.model.Mailbox; import org.apache.james.util.ZeroedInputStream; import org.hamcrest.Matchers; http://git-wip-us.apache.org/repos/asf/james-project/blob/81f3420a/server/protocols/jmap/src/main/java/org/apache/james/jmap/DownloadServlet.java ---------------------------------------------------------------------- diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/DownloadServlet.java b/server/protocols/jmap/src/main/java/org/apache/james/jmap/DownloadServlet.java index d54a7e3..35f283a 100644 --- a/server/protocols/jmap/src/main/java/org/apache/james/jmap/DownloadServlet.java +++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/DownloadServlet.java @@ -38,10 +38,10 @@ import org.apache.james.jmap.utils.DownloadPath; 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.MailboxSessionMapperFactory; import org.apache.james.mailbox.store.mail.AttachmentMapper; -import org.apache.james.mailbox.store.mail.model.Attachment; -import org.apache.james.mailbox.store.mail.model.AttachmentId; import org.slf4j.Logger; import org.slf4j.LoggerFactory; http://git-wip-us.apache.org/repos/asf/james-project/blob/81f3420a/server/protocols/jmap/src/main/java/org/apache/james/jmap/UploadHandler.java ---------------------------------------------------------------------- diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/UploadHandler.java b/server/protocols/jmap/src/main/java/org/apache/james/jmap/UploadHandler.java index 1bd5af3..4ec90b3 100644 --- a/server/protocols/jmap/src/main/java/org/apache/james/jmap/UploadHandler.java +++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/UploadHandler.java @@ -30,9 +30,9 @@ import org.apache.james.jmap.json.ObjectMapperFactory; import org.apache.james.jmap.model.UploadResponse; import org.apache.james.mailbox.MailboxSession; import org.apache.james.mailbox.exception.MailboxException; +import org.apache.james.mailbox.model.Attachment; import org.apache.james.mailbox.store.MailboxSessionMapperFactory; import org.apache.james.mailbox.store.mail.AttachmentMapper; -import org.apache.james.mailbox.store.mail.model.Attachment; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.io.ByteStreams; http://git-wip-us.apache.org/repos/asf/james-project/blob/81f3420a/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetMessagesCreationProcessor.java ---------------------------------------------------------------------- diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetMessagesCreationProcessor.java b/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetMessagesCreationProcessor.java index 4ffd308..5d1b1e6 100644 --- a/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetMessagesCreationProcessor.java +++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetMessagesCreationProcessor.java @@ -61,13 +61,13 @@ 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.exception.MailboxNotFoundException; +import org.apache.james.mailbox.model.AttachmentId; import org.apache.james.mailbox.model.MailboxId; import org.apache.james.mailbox.model.MailboxPath; import org.apache.james.mailbox.store.MailboxSessionMapperFactory; import org.apache.james.mailbox.store.mail.AttachmentMapper; import org.apache.james.mailbox.store.mail.AttachmentMapperFactory; import org.apache.james.mailbox.store.mail.MessageMapper; -import org.apache.james.mailbox.store.mail.model.AttachmentId; import org.apache.james.mailbox.store.mail.model.Mailbox; import org.apache.james.mailbox.store.mail.model.MailboxMessage; import org.apache.james.mailbox.store.mail.model.MessageAttachment; http://git-wip-us.apache.org/repos/asf/james-project/blob/81f3420a/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/MIMEMessageConverterTest.java ---------------------------------------------------------------------- diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/MIMEMessageConverterTest.java b/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/MIMEMessageConverterTest.java index 3bbe36c..5876bc3 100644 --- a/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/MIMEMessageConverterTest.java +++ b/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/MIMEMessageConverterTest.java @@ -30,7 +30,7 @@ import org.apache.james.jmap.methods.ValueWithId.MessageWithId; import org.apache.james.jmap.model.CreationMessage; import org.apache.james.jmap.model.CreationMessage.DraftEmailer; import org.apache.james.jmap.model.CreationMessageId; -import org.apache.james.mailbox.store.mail.model.AttachmentId; +import org.apache.james.mailbox.model.AttachmentId; import org.apache.james.mailbox.store.mail.model.MessageAttachment; import org.apache.james.mailbox.store.mail.model.impl.Cid; import org.apache.james.mime4j.Charsets; @@ -366,7 +366,7 @@ public class MIMEMessageConverterTest { String text = "123456"; TextBody expectedBody = new BasicBodyFactory().textBody(text.getBytes(), Charsets.UTF_8); MessageAttachment attachment = MessageAttachment.builder() - .attachment(org.apache.james.mailbox.store.mail.model.Attachment.builder() + .attachment(org.apache.james.mailbox.model.Attachment.builder() .attachmentId(AttachmentId.from("blodId")) .bytes(text.getBytes()) .type(expectedMimeType) @@ -412,7 +412,7 @@ public class MIMEMessageConverterTest { String text = "123456"; TextBody expectedAttachmentBody = new BasicBodyFactory().textBody(text.getBytes(), Charsets.UTF_8); MessageAttachment attachment = MessageAttachment.builder() - .attachment(org.apache.james.mailbox.store.mail.model.Attachment.builder() + .attachment(org.apache.james.mailbox.model.Attachment.builder() .attachmentId(AttachmentId.from("blodId")) .bytes(text.getBytes()) .type(expectedMimeType) http://git-wip-us.apache.org/repos/asf/james-project/blob/81f3420a/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/SetMessagesCreationProcessorTest.java ---------------------------------------------------------------------- diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/SetMessagesCreationProcessorTest.java b/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/SetMessagesCreationProcessorTest.java index 178c554..f8cc675 100644 --- a/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/SetMessagesCreationProcessorTest.java +++ b/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/SetMessagesCreationProcessorTest.java @@ -61,6 +61,7 @@ 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.mock.MockMailboxSession; +import org.apache.james.mailbox.model.AttachmentId; import org.apache.james.mailbox.model.MailboxPath; import org.apache.james.mailbox.store.MailboxSessionMapperFactory; import org.apache.james.mailbox.store.TestId; @@ -68,7 +69,6 @@ import org.apache.james.mailbox.store.extractor.DefaultTextExtractor; import org.apache.james.mailbox.store.mail.AttachmentMapper; import org.apache.james.mailbox.store.mail.AttachmentMapperFactory; import org.apache.james.mailbox.store.mail.MessageMapper; -import org.apache.james.mailbox.store.mail.model.AttachmentId; import org.apache.james.mailbox.store.mail.model.Mailbox; import org.apache.james.mailbox.store.mail.model.MailboxMessage; import org.apache.james.mailbox.store.mail.model.impl.SimpleMailbox; http://git-wip-us.apache.org/repos/asf/james-project/blob/81f3420a/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/MailboxMessageTest.java ---------------------------------------------------------------------- diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/MailboxMessageTest.java b/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/MailboxMessageTest.java index a9280e0..d42e539 100644 --- a/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/MailboxMessageTest.java +++ b/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/MailboxMessageTest.java @@ -32,8 +32,8 @@ import javax.mail.util.SharedByteArrayInputStream; import org.apache.commons.io.IOUtils; import org.apache.james.jmap.utils.HtmlTextExtractor; +import org.apache.james.mailbox.model.AttachmentId; import org.apache.james.mailbox.store.TestId; -import org.apache.james.mailbox.store.mail.model.AttachmentId; import org.apache.james.mailbox.store.mail.model.MailboxMessage; import org.apache.james.mailbox.store.mail.model.MessageAttachment; import org.apache.james.mailbox.store.mail.model.impl.Cid; @@ -418,7 +418,7 @@ public class MailboxMessageTest { .build(); Message testee = messageFactory.fromMailboxMessage(testMail, ImmutableList.of(MessageAttachment.builder() - .attachment(org.apache.james.mailbox.store.mail.model.Attachment.builder() + .attachment(org.apache.james.mailbox.model.Attachment.builder() .attachmentId(AttachmentId.from(blodId.getRawValue())) .bytes(payload.getBytes()) .type(type) --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
