james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject [14/27] james-project git commit: JAMES-2132 Support arbitrary MDN Disposition modifier
Date Fri, 01 Sep 2017 01:18:27 GMT
JAMES-2132 Support arbitrary MDN Disposition modifier

RFC defines them in https://tools.ietf.org/html/rfc8098#section-3.2.6.3 as:

   disposition-modifier = "error" / disposition-modifier-extension

   The following disposition-types are defined:

   disposition-modifier-extension
                       Disposition modifiers may be defined in the
                       future by later revisions or extensions to this
                       specification.  MDN disposition value names MUST
                       be registered with the Internet Assigned Numbers
                       Authority (IANA) using the "Specification
                       Required" registration policy.  (See Section 10
                       for a registration form.)  MDNs with disposition
                       modifier names not understood by the receiving
                       MUA MAY be silently ignored or placed in the
                       user's mailbox without special interpretation.
                       They MUST NOT cause any error message to be sent
                       to the sender of the MDN.


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

Branch: refs/heads/master
Commit: 5ee43e68e7f87738caf513f70c93d7c755f6dc14
Parents: b254ac3
Author: benwa <btellier@linagora.com>
Authored: Mon Aug 28 17:44:30 2017 +0700
Committer: benwa <btellier@linagora.com>
Committed: Thu Aug 31 18:00:20 2017 +0700

----------------------------------------------------------------------
 .../james/mdn/modifier/DispositionModifier.java | 25 +++------
 .../org/apache/james/mdn/MDNFactoryTest.java    | 56 +++++---------------
 2 files changed, 21 insertions(+), 60 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/5ee43e68/mdn/src/main/java/org/apache/james/mdn/modifier/DispositionModifier.java
----------------------------------------------------------------------
diff --git a/mdn/src/main/java/org/apache/james/mdn/modifier/DispositionModifier.java b/mdn/src/main/java/org/apache/james/mdn/modifier/DispositionModifier.java
index 1efb7d0..ac4ba63 100644
--- a/mdn/src/main/java/org/apache/james/mdn/modifier/DispositionModifier.java
+++ b/mdn/src/main/java/org/apache/james/mdn/modifier/DispositionModifier.java
@@ -19,30 +19,21 @@
 
 package org.apache.james.mdn.modifier;
 
-import java.util.Optional;
-import java.util.stream.Stream;
-
 /**
  * Interface <code>DispositionModifier</code> marks a type encapsulating
  * disposition modifier information as defined by RFC 2298.
  */
-public enum DispositionModifier {
-    Error("error"),
-    Expired("expired"),
-    Failed("failed"),
-    MailboxTerminated("mailbox-terminated"),
-    Superseded("superseded"),
-    Warning("warning");
-
-    public static Optional<DispositionModifier> fromString(String value) {
-        return Stream.of(values())
-            .filter(sendingMode -> sendingMode.getValue().equalsIgnoreCase(value))
-            .findFirst();
-    }
+public class DispositionModifier {
+    public static DispositionModifier Error = new DispositionModifier("error");
+    public static DispositionModifier Expired = new DispositionModifier("expired");
+    public static DispositionModifier Failed = new DispositionModifier("failed");
+    public static DispositionModifier MailboxTerminated = new DispositionModifier("mailbox-terminated");
+    public static DispositionModifier Superseded = new DispositionModifier("superseded");
+    public static DispositionModifier Warning = new DispositionModifier("warning");
 
     private final String value;
 
-    DispositionModifier(String value) {
+    public DispositionModifier(String value) {
         this.value = value;
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/5ee43e68/mdn/src/test/java/org/apache/james/mdn/MDNFactoryTest.java
----------------------------------------------------------------------
diff --git a/mdn/src/test/java/org/apache/james/mdn/MDNFactoryTest.java b/mdn/src/test/java/org/apache/james/mdn/MDNFactoryTest.java
index 968c788..ac51b08 100644
--- a/mdn/src/test/java/org/apache/james/mdn/MDNFactoryTest.java
+++ b/mdn/src/test/java/org/apache/james/mdn/MDNFactoryTest.java
@@ -101,35 +101,6 @@ public class MDNFactoryTest {
     }
 
     @Test
-    public void generateMDNReportShouldFormatTypeDenied() {
-        Disposition disposition = Disposition.builder()
-            .actionMode(DispositionActionMode.Manual)
-            .sendingMode(DispositionSendingMode.Manual)
-            .type(DispositionType.Denied)
-            .addModifier(DispositionModifier.Error)
-            .addModifier(DispositionModifier.Failed)
-            .build();
-
-        String report = MDNReport.builder()
-            .reportingUserAgentField(new ReportingUserAgent(
-                "UA_name",
-                Optional.of("UA_product")))
-            .finalRecipientField(new FinalRecipient("final_recipient"))
-            .originalRecipientField(new OriginalRecipient("originalRecipient"))
-            .originalMessageIdField(new OriginalMessageId("original_message_id"))
-            .dispositionField(disposition)
-            .build()
-            .formattedValue();
-
-        assertThat(report)
-            .isEqualTo("Reporting-UA: UA_name; UA_product\r\n" +
-                "Original-Recipient: rfc822; originalRecipient\r\n" +
-                "Final-Recepient: rfc822; final_recipient\r\n" +
-                "Original-Message-ID: original_message_id\r\n" +
-                "Disposition: manual-action/MDN-sent-manually;denied/error,failed\r\n");
-    }
-
-    @Test
     public void generateMDNReportShouldFormatTypeDispatcher() {
         Disposition disposition = Disposition.builder()
         .actionMode(DispositionActionMode.Manual)
@@ -188,11 +159,11 @@ public class MDNFactoryTest {
     }
 
     @Test
-    public void generateMDNReportShouldFormatTypeFailed() {
+    public void generateMDNReportShouldFormatTypeDeleted() {
         Disposition disposition = Disposition.builder()
             .actionMode(DispositionActionMode.Manual)
             .sendingMode(DispositionSendingMode.Manual)
-            .type(DispositionType.Failed)
+            .type(DispositionType.Deleted)
             .addModifier(DispositionModifier.Error)
             .addModifier(DispositionModifier.Failed)
             .build();
@@ -213,17 +184,17 @@ public class MDNFactoryTest {
                 "Original-Recipient: rfc822; originalRecipient\r\n" +
                 "Final-Recepient: rfc822; final_recipient\r\n" +
                 "Original-Message-ID: original_message_id\r\n" +
-                "Disposition: manual-action/MDN-sent-manually;failed/error,failed\r\n");
+                "Disposition: manual-action/MDN-sent-manually;deleted/error,failed\r\n");
     }
 
     @Test
-    public void generateMDNReportShouldFormatTypeDeleted() {
+    public void generateMDNReportShouldFormatAllModifier() {
         Disposition disposition = Disposition.builder()
             .actionMode(DispositionActionMode.Manual)
             .sendingMode(DispositionSendingMode.Manual)
             .type(DispositionType.Deleted)
-            .addModifier(DispositionModifier.Error)
-            .addModifier(DispositionModifier.Failed)
+            .addModifiers(DispositionModifier.Error, DispositionModifier.Expired, DispositionModifier.Failed,
+                DispositionModifier.MailboxTerminated, DispositionModifier.Superseded, DispositionModifier.Warning)
             .build();
 
         String report = MDNReport.builder()
@@ -242,17 +213,16 @@ public class MDNFactoryTest {
                 "Original-Recipient: rfc822; originalRecipient\r\n" +
                 "Final-Recepient: rfc822; final_recipient\r\n" +
                 "Original-Message-ID: original_message_id\r\n" +
-                "Disposition: manual-action/MDN-sent-manually;deleted/error,failed\r\n");
+                "Disposition: manual-action/MDN-sent-manually;deleted/error,expired,failed,mailbox-terminated,superseded,warning\r\n");
     }
 
     @Test
-    public void generateMDNReportShouldFormatAllModifier() {
+    public void generateMDNReportShouldFormatOneModifier() {
         Disposition disposition = Disposition.builder()
             .actionMode(DispositionActionMode.Manual)
             .sendingMode(DispositionSendingMode.Manual)
             .type(DispositionType.Deleted)
-            .addModifiers(DispositionModifier.Error, DispositionModifier.Expired, DispositionModifier.Failed,
-                DispositionModifier.MailboxTerminated, DispositionModifier.Superseded, DispositionModifier.Warning)
+            .addModifier(DispositionModifier.Error)
             .build();
 
         String report = MDNReport.builder()
@@ -271,16 +241,16 @@ public class MDNFactoryTest {
                 "Original-Recipient: rfc822; originalRecipient\r\n" +
                 "Final-Recepient: rfc822; final_recipient\r\n" +
                 "Original-Message-ID: original_message_id\r\n" +
-                "Disposition: manual-action/MDN-sent-manually;deleted/error,expired,failed,mailbox-terminated,superseded,warning\r\n");
+                "Disposition: manual-action/MDN-sent-manually;deleted/error\r\n");
     }
 
     @Test
-    public void generateMDNReportShouldFormatOneModifier() {
+    public void generateMDNReportShouldFormatUnknownModifier() {
         Disposition disposition = Disposition.builder()
             .actionMode(DispositionActionMode.Manual)
             .sendingMode(DispositionSendingMode.Manual)
             .type(DispositionType.Deleted)
-            .addModifier(DispositionModifier.Error)
+            .addModifier(new DispositionModifier("new"))
             .build();
 
         String report = MDNReport.builder()
@@ -299,7 +269,7 @@ public class MDNFactoryTest {
                 "Original-Recipient: rfc822; originalRecipient\r\n" +
                 "Final-Recepient: rfc822; final_recipient\r\n" +
                 "Original-Message-ID: original_message_id\r\n" +
-                "Disposition: manual-action/MDN-sent-manually;deleted/error\r\n");
+                "Disposition: manual-action/MDN-sent-manually;deleted/new\r\n");
     }
 
     @Test


---------------------------------------------------------------------
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