You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by bt...@apache.org on 2019/03/08 01:13:47 UTC
[james-project] 03/14: JAMES-2662 Introduce DeletedMessageMetadata
for using to group MetadataWithMailboxId by MessageId and Owner
This is an automated email from the ASF dual-hosted git repository.
btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit eaf5cf1490f68b5a9504ba470c6051a0dfd680af
Author: datph <dp...@linagora.com>
AuthorDate: Fri Mar 1 16:28:06 2019 +0700
JAMES-2662 Introduce DeletedMessageMetadata for using to group MetadataWithMailboxId by MessageId and Owner
---
.../apache/james/vault/DeletedMessageMetadata.java | 84 ++++++++++++++++++++++
.../james/vault/DeletedMessageMetadataTest.java | 34 +++++++++
2 files changed, 118 insertions(+)
diff --git a/mailbox/plugin/deleted-messages-vault/src/main/java/org/apache/james/vault/DeletedMessageMetadata.java b/mailbox/plugin/deleted-messages-vault/src/main/java/org/apache/james/vault/DeletedMessageMetadata.java
new file mode 100644
index 0000000..9215ebd
--- /dev/null
+++ b/mailbox/plugin/deleted-messages-vault/src/main/java/org/apache/james/vault/DeletedMessageMetadata.java
@@ -0,0 +1,84 @@
+/****************************************************************
+ * 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.vault;
+
+import java.util.List;
+import java.util.Objects;
+
+import org.apache.james.core.User;
+import org.apache.james.mailbox.model.MailboxId;
+import org.apache.james.mailbox.model.MessageId;
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.ImmutableList;
+
+class DeletedMessageMetadata {
+ private final MessageId messageId;
+ private final User owner;
+ private final List<MailboxId> ownerMailboxes;
+
+ DeletedMessageMetadata(MessageId messageId, User owner, List<MailboxId> ownerMailboxes) {
+ this.messageId = messageId;
+ this.owner = owner;
+ this.ownerMailboxes = ownerMailboxes;
+ }
+
+ DeletedMessageMetadata combineWith(DeletedMessageMetadata other) {
+ Preconditions.checkArgument(messageId.equals(other.messageId));
+ Preconditions.checkArgument(owner.equals(other.owner));
+
+ return new DeletedMessageMetadata(
+ messageId,
+ owner,
+ ImmutableList.<MailboxId>builder()
+ .addAll(ownerMailboxes)
+ .addAll(other.ownerMailboxes)
+ .build());
+ }
+
+ public MessageId getMessageId() {
+ return messageId;
+ }
+
+ public User getOwner() {
+ return owner;
+ }
+
+ public List<MailboxId> getOwnerMailboxes() {
+ return ownerMailboxes;
+ }
+
+ @Override
+ public final boolean equals(Object o) {
+ if (o instanceof DeletedMessageMetadata) {
+ DeletedMessageMetadata that = (DeletedMessageMetadata) o;
+
+ return Objects.equals(this.messageId, that.messageId)
+ && Objects.equals(this.owner, that.owner)
+ && Objects.equals(this.ownerMailboxes, that.ownerMailboxes);
+ }
+ return false;
+ }
+
+ @Override
+ public final int hashCode() {
+ return Objects.hash(messageId, owner, ownerMailboxes);
+ }
+}
diff --git a/mailbox/plugin/deleted-messages-vault/src/test/java/org/apache/james/vault/DeletedMessageMetadataTest.java b/mailbox/plugin/deleted-messages-vault/src/test/java/org/apache/james/vault/DeletedMessageMetadataTest.java
new file mode 100644
index 0000000..caa8271
--- /dev/null
+++ b/mailbox/plugin/deleted-messages-vault/src/test/java/org/apache/james/vault/DeletedMessageMetadataTest.java
@@ -0,0 +1,34 @@
+/****************************************************************
+ * 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.vault;
+
+import org.apache.james.mailbox.extension.PreDeletionHook;
+import org.junit.jupiter.api.Test;
+
+import nl.jqno.equalsverifier.EqualsVerifier;
+
+public class DeletedMessageMetadataTest {
+
+ @Test
+ void shouldMatchBeanContract() {
+ EqualsVerifier.forClass(PreDeletionHook.DeleteOperation.class)
+ .verify();
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org