You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by GitBox <gi...@apache.org> on 2021/05/21 12:16:40 UTC

[GitHub] [james-project] chibenwa commented on a change in pull request #446: JAMES-3516 Add threadId property to MessageResult POJO, MailboxMessage POJO

chibenwa commented on a change in pull request #446:
URL: https://github.com/apache/james-project/pull/446#discussion_r636860644



##########
File path: mailbox/api/src/main/java/org/apache/james/mailbox/model/ThreadId.java
##########
@@ -0,0 +1,62 @@
+/******************************************************************
+ * 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 com.google.common.base.MoreObjects;
+import com.google.common.base.Objects;
+
+public class ThreadId implements MessageId {
+    private final String id;
+
+    public ThreadId(String id) {
+        this.id = id;
+    }
+
+    @Override
+    public final boolean equals(Object o) {
+        if (o instanceof ThreadId) {
+            ThreadId threadId = (ThreadId) o;
+            return Objects.equal(this.id, threadId.id);
+        }
+        return false;
+    }
+
+    @Override
+    public final int hashCode() {
+        return Objects.hashCode(id);
+    }
+
+    @Override
+    public String toString() {
+        return MoreObjects.toStringHelper(this)
+            .add("id", id)
+            .toString();
+    }
+
+    @Override
+    public String serialize() {
+        return id;
+    }
+
+    @Override
+    public boolean isSerializable() {
+        return true;
+    }

Review comment:
       Put these methods before equals, toString, hashcode.

##########
File path: mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/MailboxMessage.java
##########
@@ -33,6 +34,8 @@
  */
 public interface MailboxMessage extends Message, Comparable<MailboxMessage> {
 
+    ThreadId getThreadId();

Review comment:
       It may worth writing tests for this in SimpleMailboxMessageTest ?

##########
File path: mailbox/api/src/main/java/org/apache/james/mailbox/model/ThreadId.java
##########
@@ -0,0 +1,62 @@
+/******************************************************************
+ * 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 com.google.common.base.MoreObjects;
+import com.google.common.base.Objects;
+
+public class ThreadId implements MessageId {

Review comment:
       Please favor composition.
   
   I would suggest:
   
   ```
   public class ThreadId {
      private final MessageId baseMessageId;
   }
   ```

##########
File path: mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/model/openjpa/AbstractJPAMailboxMessage.java
##########
@@ -493,6 +494,11 @@ public MessageId getMessageId() {
         return new DefaultMessageId();
     }
 
+    @Override
+    public ThreadId getThreadId() {
+        return (ThreadId) getMessageId();

Review comment:
       You then should built a ThreadId that wraps the messageId.

##########
File path: mailbox/store/src/main/java/org/apache/james/mailbox/store/MessageResultImpl.java
##########
@@ -87,7 +88,12 @@ public MessageUid getUid() {
     public MessageId getMessageId() {
         return message.getMessageId();
     }
-    
+
+    @Override
+    public ThreadId getThreadId() {
+        return message.getThreadId();

Review comment:
       Can we try in MailboxManagerTest to access the threadId of a message?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org