james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adup...@apache.org
Subject [14/41] james-project git commit: JAMES-2082 getHeaderOctets should be a message property
Date Mon, 10 Jul 2017 17:54:26 GMT
JAMES-2082 getHeaderOctets should be a message property


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/2a4987df
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/2a4987df
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/2a4987df

Branch: refs/heads/master
Commit: 2a4987dfe4205c9c5c2735b816dbc353ec3ff115
Parents: a308596
Author: benwa <btellier@linagora.com>
Authored: Thu Jul 6 11:24:25 2017 +0700
Committer: Antoine Duprat <aduprat@linagora.com>
Committed: Mon Jul 10 14:23:56 2017 +0200

----------------------------------------------------------------------
 .../cassandra/mail/CassandraMessageDAO.java     |  2 +-
 .../cassandra/mail/CassandraMessageDAOV2.java   |  2 +-
 .../mailbox/hbase/mail/HBaseMailboxMessage.java |  5 ++++
 .../jcr/mail/model/JCRMailboxMessage.java       |  5 ++++
 .../openjpa/AbstractJPAMailboxMessage.java      | 31 ++++++++++++--------
 .../maildir/mail/model/MaildirMessage.java      |  5 ++++
 .../james/mailbox/store/MessageResultImpl.java  |  2 +-
 .../mail/model/DelegatingMailboxMessage.java    |  5 ++++
 .../james/mailbox/store/mail/model/Message.java |  7 +++++
 .../store/mail/model/impl/SimpleMessage.java    |  5 ++++
 .../mailbox/store/SimpleMailboxMembership.java  |  7 ++++-
 .../store/mail/model/ListMessageAssertTest.java |  5 ++++
 12 files changed, 64 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/2a4987df/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageDAO.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageDAO.java
b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageDAO.java
index 5b11de3..77e03d9 100644
--- a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageDAO.java
+++ b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageDAO.java
@@ -145,7 +145,7 @@ public class CassandraMessageDAO {
             BoundStatement boundStatement = insert.bind()
                 .setUUID(MESSAGE_ID, messageId.get())
                 .setTimestamp(INTERNAL_DATE, message.getInternalDate())
-                .setInt(BODY_START_OCTET, (int) (message.getFullContentOctets() - message.getBodyOctets()))
+                .setInt(BODY_START_OCTET, (int) (message.getHeaderOctets()))
                 .setLong(FULL_CONTENT_OCTETS, message.getFullContentOctets())
                 .setLong(BODY_OCTECTS, message.getBodyOctets())
                 .setBytes(BODY_CONTENT, toByteBuffer(message.getBodyContent()))

http://git-wip-us.apache.org/repos/asf/james-project/blob/2a4987df/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageDAOV2.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageDAOV2.java
b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageDAOV2.java
index 9bb0b35..f9b3255 100644
--- a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageDAOV2.java
+++ b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageDAOV2.java
@@ -166,7 +166,7 @@ public class CassandraMessageDAOV2 {
         return insert.bind()
                 .setUUID(MESSAGE_ID, messageId.get())
                 .setTimestamp(INTERNAL_DATE, message.getInternalDate())
-                .setInt(BODY_START_OCTET, (int) (message.getFullContentOctets() - message.getBodyOctets()))
+                .setInt(BODY_START_OCTET, (int) (message.getHeaderOctets()))
                 .setLong(FULL_CONTENT_OCTETS, message.getFullContentOctets())
                 .setLong(BODY_OCTECTS, message.getBodyOctets())
                 .setString(BODY_CONTENT, pair.getLeft().map(BlobId::getId).orElse(DEFAULT_OBJECT_VALUE))

http://git-wip-us.apache.org/repos/asf/james-project/blob/2a4987df/mailbox/hbase/src/main/java/org/apache/james/mailbox/hbase/mail/HBaseMailboxMessage.java
----------------------------------------------------------------------
diff --git a/mailbox/hbase/src/main/java/org/apache/james/mailbox/hbase/mail/HBaseMailboxMessage.java
b/mailbox/hbase/src/main/java/org/apache/james/mailbox/hbase/mail/HBaseMailboxMessage.java
index 2815b61..e4b57e9a 100644
--- a/mailbox/hbase/src/main/java/org/apache/james/mailbox/hbase/mail/HBaseMailboxMessage.java
+++ b/mailbox/hbase/src/main/java/org/apache/james/mailbox/hbase/mail/HBaseMailboxMessage.java
@@ -309,6 +309,11 @@ public class HBaseMailboxMessage implements MailboxMessage {
         return FlagsBuilder.createFlags(this, createUserFlags());
     }
 
+    @Override
+    public long getHeaderOctets() {
+        return bodyStartOctet;
+    }
+
     /**
      * This implementation supports user flags
      */

http://git-wip-us.apache.org/repos/asf/james-project/blob/2a4987df/mailbox/jcr/src/main/java/org/apache/james/mailbox/jcr/mail/model/JCRMailboxMessage.java
----------------------------------------------------------------------
diff --git a/mailbox/jcr/src/main/java/org/apache/james/mailbox/jcr/mail/model/JCRMailboxMessage.java
b/mailbox/jcr/src/main/java/org/apache/james/mailbox/jcr/mail/model/JCRMailboxMessage.java
index d7bb123..3637e41 100644
--- a/mailbox/jcr/src/main/java/org/apache/james/mailbox/jcr/mail/model/JCRMailboxMessage.java
+++ b/mailbox/jcr/src/main/java/org/apache/james/mailbox/jcr/mail/model/JCRMailboxMessage.java
@@ -679,6 +679,11 @@ public class JCRMailboxMessage implements MailboxMessage, JCRImapConstants,
Pers
     }
 
     @Override
+    public long getHeaderOctets() {
+        return getBodyStartOctet();
+    }
+
+    @Override
     public int compareTo(MailboxMessage other) {
         return MESSAGE_UID_COMPARATOR.compare(this, other);
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/2a4987df/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/model/openjpa/AbstractJPAMailboxMessage.java
----------------------------------------------------------------------
diff --git a/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/model/openjpa/AbstractJPAMailboxMessage.java
b/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/model/openjpa/AbstractJPAMailboxMessage.java
index 69f5f11..c9ae2e4 100644
--- a/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/model/openjpa/AbstractJPAMailboxMessage.java
+++ b/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/model/openjpa/AbstractJPAMailboxMessage.java
@@ -233,7 +233,7 @@ public abstract class AbstractJPAMailboxMessage implements MailboxMessage
{
     private List<JPAUserFlag> userFlags;
 
     public AbstractJPAMailboxMessage() {
-        
+
     }
 
     public AbstractJPAMailboxMessage(JPAMailbox mailbox, Date internalDate, Flags flags,
long contentOctets,
@@ -260,7 +260,7 @@ public abstract class AbstractJPAMailboxMessage implements MailboxMessage
{
     /**
      * Constructs a copy of the given message. All properties are cloned except
      * mailbox and UID.
-     * 
+     *
      * @param mailbox
      *            new mailbox
      * @param uid
@@ -330,7 +330,7 @@ public abstract class AbstractJPAMailboxMessage implements MailboxMessage
{
 
     /**
      * Gets the top level MIME content media type.
-     * 
+     *
      * @return top level MIME content media type, or null if default
      */
     public String getMediaType() {
@@ -339,7 +339,7 @@ public abstract class AbstractJPAMailboxMessage implements MailboxMessage
{
 
     /**
      * Gets the MIME content subtype.
-     * 
+     *
      * @return the MIME content subtype, or null if default
      */
     public String getSubType() {
@@ -350,7 +350,7 @@ public abstract class AbstractJPAMailboxMessage implements MailboxMessage
{
      * Gets a read-only list of meta-data properties. For properties with
      * multiple values, this list will contain several enteries with the same
      * namespace and local name.
-     * 
+     *
      * @return unmodifiable list of meta-data, not null
      */
     public List<Property> getProperties() {
@@ -359,7 +359,7 @@ public abstract class AbstractJPAMailboxMessage implements MailboxMessage
{
 
     /**
      * Gets the number of CRLF in a textual document.
-     * 
+     *
      * @return CRLF count when document is textual, null otherwise
      */
     public Long getTextualLineCount() {
@@ -430,6 +430,11 @@ public abstract class AbstractJPAMailboxMessage implements MailboxMessage
{
     }
 
     @Override
+    public long getHeaderOctets() {
+        return bodyStartOctet;
+    }
+
+    @Override
     public void setFlags(Flags flags) {
         answered = flags.contains(Flags.Flag.ANSWERED);
         deleted = flags.contains(Flags.Flag.DELETED);
@@ -493,16 +498,16 @@ public abstract class AbstractJPAMailboxMessage implements MailboxMessage
{
     }
 
     public String toString() {
-        return "message(" 
-                + "mailboxId = " + this.getMailboxId() + TOSTRING_SEPARATOR 
+        return "message("
+                + "mailboxId = " + this.getMailboxId() + TOSTRING_SEPARATOR
                 + "uid = " + this.uid + TOSTRING_SEPARATOR
-                + "internalDate = " + this.internalDate + TOSTRING_SEPARATOR 
+                + "internalDate = " + this.internalDate + TOSTRING_SEPARATOR
                 + "answered = " + this.answered + TOSTRING_SEPARATOR
-                + "deleted = " + this.deleted + TOSTRING_SEPARATOR 
+                + "deleted = " + this.deleted + TOSTRING_SEPARATOR
                 + "draft = " + this.draft + TOSTRING_SEPARATOR
-                + "flagged = " + this.flagged + TOSTRING_SEPARATOR 
-                + "recent = " + this.recent + TOSTRING_SEPARATOR 
-                + "seen = " + this.seen + TOSTRING_SEPARATOR 
+                + "flagged = " + this.flagged + TOSTRING_SEPARATOR
+                + "recent = " + this.recent + TOSTRING_SEPARATOR
+                + "seen = " + this.seen + TOSTRING_SEPARATOR
                 + " )";
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/2a4987df/mailbox/maildir/src/main/java/org/apache/james/mailbox/maildir/mail/model/MaildirMessage.java
----------------------------------------------------------------------
diff --git a/mailbox/maildir/src/main/java/org/apache/james/mailbox/maildir/mail/model/MaildirMessage.java
b/mailbox/maildir/src/main/java/org/apache/james/mailbox/maildir/mail/model/MaildirMessage.java
index 6c1a599..f21eafd 100644
--- a/mailbox/maildir/src/main/java/org/apache/james/mailbox/maildir/mail/model/MaildirMessage.java
+++ b/mailbox/maildir/src/main/java/org/apache/james/mailbox/maildir/mail/model/MaildirMessage.java
@@ -224,6 +224,11 @@ public class MaildirMessage implements Message {
     }
 
     @Override
+    public long getHeaderOctets() {
+        return getBodyStartOctet();
+    }
+
+    @Override
     public Long getTextualLineCount() {
         parseMessage();
         return propertyBuilder.getTextualLineCount();

http://git-wip-us.apache.org/repos/asf/james-project/blob/2a4987df/mailbox/store/src/main/java/org/apache/james/mailbox/store/MessageResultImpl.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/MessageResultImpl.java
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/MessageResultImpl.java
index dd8212d..c7eb014 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/MessageResultImpl.java
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/MessageResultImpl.java
@@ -398,7 +398,7 @@ public class MessageResultImpl implements MessageResult {
 
         @Override
         public long size() {
-            return msg.getFullContentOctets() - msg.getBodyOctets();
+            return msg.getHeaderOctets();
         }
 
         @Override

http://git-wip-us.apache.org/repos/asf/james-project/blob/2a4987df/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/DelegatingMailboxMessage.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/DelegatingMailboxMessage.java
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/DelegatingMailboxMessage.java
index 3601005..515bdb7 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/DelegatingMailboxMessage.java
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/DelegatingMailboxMessage.java
@@ -97,6 +97,11 @@ public abstract class DelegatingMailboxMessage implements MailboxMessage
{
     }
 
     @Override
+    public long getHeaderOctets() {
+        return message.getHeaderOctets();
+    }
+
+    @Override
     public String getMediaType() {
         return message.getMediaType();
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/2a4987df/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/Message.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/Message.java
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/Message.java
index a6b9cd7..b619e0b 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/Message.java
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/Message.java
@@ -70,6 +70,13 @@ public interface Message {
     long getFullContentOctets();
 
     /**
+     * The number of octets contained in the header content of this document.
+     *
+     * @return number of octets
+     */
+    long getHeaderOctets();
+
+    /**
      * Gets the number of CRLF in a textual document.
      * @return CRLF count when document is textual,
      * null otherwise

http://git-wip-us.apache.org/repos/asf/james-project/blob/2a4987df/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/SimpleMessage.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/SimpleMessage.java
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/SimpleMessage.java
index 71ad13e..4141cdc 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/SimpleMessage.java
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/SimpleMessage.java
@@ -93,6 +93,11 @@ public class SimpleMessage implements Message {
     }
 
     @Override
+    public long getHeaderOctets() {
+        return bodyStartOctet;
+    }
+
+    @Override
     public long getFullContentOctets() {
         return size;
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/2a4987df/mailbox/store/src/test/java/org/apache/james/mailbox/store/SimpleMailboxMembership.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/SimpleMailboxMembership.java
b/mailbox/store/src/test/java/org/apache/james/mailbox/store/SimpleMailboxMembership.java
index c99aaf0..d18501d 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/SimpleMailboxMembership.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/SimpleMailboxMembership.java
@@ -119,7 +119,12 @@ public class SimpleMailboxMembership implements MailboxMessage {
     public void unsetRecent() {
         recent = false;
     }
-    
+
+    @Override
+    public long getHeaderOctets() {
+        return size - body.length;
+    }
+
     public void setFlags(Flags flags) {
         answered = flags.contains(Flags.Flag.ANSWERED);
         deleted = flags.contains(Flags.Flag.DELETED);

http://git-wip-us.apache.org/repos/asf/james-project/blob/2a4987df/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/ListMessageAssertTest.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/ListMessageAssertTest.java
b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/ListMessageAssertTest.java
index a465c65..8d76ccc 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/ListMessageAssertTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/ListMessageAssertTest.java
@@ -153,6 +153,11 @@ public class ListMessageAssertTest {
             }
 
             @Override
+            public long getHeaderOctets() {
+                return bodyStart;
+            }
+
+            @Override
             public MessageId getMessageId() {
                 return messageId;
             }


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


Mime
View raw message