JAMES-2346 Add a simplistic MDN processor

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

Branch: refs/heads/master
Commit: 7802c7304359ee122c1e6e0487b2f85c78dfdab9
Parents: b54014d
Author: benwa <btell...@linagora.com>
Authored: Thu Mar 8 10:58:50 2018 +0700
Committer: benwa <btell...@linagora.com>
Committed: Tue Mar 13 15:11:54 2018 +0700

----------------------------------------------------------------------
 .../org/apache/james/jmap/MethodsModule.java    |  2 +
 .../james/jmap/methods/SendMDNProcessor.java    | 58 ++++++++++++++++++++
 2 files changed, 60 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/7802c730/server/container/guice/protocols/jmap/src/main/java/org/apache/james/jmap/MethodsModule.java
----------------------------------------------------------------------
diff --git 
a/server/container/guice/protocols/jmap/src/main/java/org/apache/james/jmap/MethodsModule.java
 
b/server/container/guice/protocols/jmap/src/main/java/org/apache/james/jmap/MethodsModule.java
index 9feb897..37b2863 100644
--- 
a/server/container/guice/protocols/jmap/src/main/java/org/apache/james/jmap/MethodsModule.java
+++ 
b/server/container/guice/protocols/jmap/src/main/java/org/apache/james/jmap/MethodsModule.java
@@ -29,6 +29,7 @@ import org.apache.james.jmap.methods.JmapRequestParserImpl;
 import org.apache.james.jmap.methods.JmapResponseWriter;
 import org.apache.james.jmap.methods.JmapResponseWriterImpl;
 import org.apache.james.jmap.methods.Method;
+import org.apache.james.jmap.methods.SendMDNProcessor;
 import org.apache.james.jmap.methods.SetMailboxesCreationProcessor;
 import org.apache.james.jmap.methods.SetMailboxesDestructionProcessor;
 import org.apache.james.jmap.methods.SetMailboxesMethod;
@@ -79,6 +80,7 @@ public class MethodsModule extends AbstractModule {
         
setMessagesProcessors.addBinding().to(SetMessagesUpdateProcessor.class);
         
setMessagesProcessors.addBinding().to(SetMessagesCreationProcessor.class);
         
setMessagesProcessors.addBinding().to(SetMessagesDestructionProcessor.class);
+        setMessagesProcessors.addBinding().to(SendMDNProcessor.class);
     }
 
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/7802c730/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SendMDNProcessor.java
----------------------------------------------------------------------
diff --git 
a/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SendMDNProcessor.java
 
b/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SendMDNProcessor.java
new file mode 100644
index 0000000..c0dfa27
--- /dev/null
+++ 
b/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SendMDNProcessor.java
@@ -0,0 +1,58 @@
+/****************************************************************
+ * 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.jmap.methods;
+
+import static org.apache.james.jmap.methods.Method.JMAP_PREFIX;
+
+import javax.inject.Inject;
+
+import org.apache.james.jmap.model.SetError;
+import org.apache.james.jmap.model.SetMessagesRequest;
+import org.apache.james.jmap.model.SetMessagesResponse;
+import org.apache.james.mailbox.MailboxSession;
+import org.apache.james.metrics.api.MetricFactory;
+
+public class SendMDNProcessor implements SetMessagesProcessor {
+    private final MetricFactory metricFactory;
+
+    @Inject
+    public SendMDNProcessor(MetricFactory metricFactory) {
+        this.metricFactory = metricFactory;
+    }
+
+    @Override
+    public SetMessagesResponse process(SetMessagesRequest request, 
MailboxSession mailboxSession) {
+        return metricFactory.withMetric(JMAP_PREFIX + "SendMDN",
+            () -> handleMDNCreation(request));
+    }
+
+    public SetMessagesResponse handleMDNCreation(SetMessagesRequest request) {
+        SetMessagesResponse.Builder builder = SetMessagesResponse.builder();
+
+        request.getSendMDN()
+            .forEach(creationMDNEntry -> 
builder.MDNNotSent(creationMDNEntry.getCreationId(),
+                SetError.builder()
+                    .description(String.format("Could not send MDN %s", 
creationMDNEntry.getCreationId().getId()))
+                    .type("Not implemented yet")
+                    .build()));
+
+        return builder.build();
+    }
+}


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

Reply via email to