[ 
https://issues.apache.org/jira/browse/JAMES-3389?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17221315#comment-17221315
 ] 

ASF GitHub Bot commented on JAMES-3389:
---------------------------------------

mbaechler commented on a change in pull request #256:
URL: https://github.com/apache/james-project/pull/256#discussion_r512581016



##########
File path: pom.xml
##########
@@ -1860,6 +1860,11 @@
                 <artifactId>james-server-webadmin-jmap</artifactId>
                 <version>${project.version}</version>
             </dependency>
+            <dependency>
+                <groupId>${james.groupId}</groupId>
+                <artifactId>james-server-webadmin-mail-over-web</artifactId>

Review comment:
       I personally like that separated module

##########
File path: 
server/protocols/webadmin/webadmin-mail-over-web/src/main/java/org/apache/james/webadmin/request/BodyPartProps.java
##########
@@ -0,0 +1,89 @@
+package org.apache.james.webadmin.request;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Optional;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public class BodyPartProps {
+
+    @JsonCreator
+    public BodyPartProps(

Review comment:
       this ordering will not pass checkstyle rules. You should run checkstyle 
and adjust the coding style accordingly.
   Rules are mainly Java official guidelines

##########
File path: 
server/protocols/webadmin/webadmin-mail-over-web/src/main/java/org/apache/james/webadmin/routes/ReceiveMailOverWebRoutes.java
##########
@@ -0,0 +1,86 @@
+package org.apache.james.webadmin.routes;
+
+import javax.inject.Inject;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+
+import org.apache.james.queue.api.MailQueue;
+import org.apache.james.queue.api.MailQueueFactory;
+import org.apache.james.server.core.MailImpl;
+import org.apache.james.webadmin.Routes;
+import org.apache.james.webadmin.request.MailProps;
+import org.apache.james.webadmin.utils.ErrorResponder;
+import org.apache.james.webadmin.utils.JsonExtractor;
+import org.eclipse.jetty.http.HttpStatus;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiResponse;
+import io.swagger.annotations.ApiResponses;
+import spark.Service;
+
+@Api(tags = "OverWebMailReceiver")
+@Path(ReceiveMailOverWebRoutes.BASE_URL)
+@Produces("application/json")
+public class ReceiveMailOverWebRoutes implements Routes {
+
+    private final JsonExtractor<MailProps> mailPropsJsonExtractor;
+
+    public static final String BASE_URL = "/receiveMail";
+
+    private MailQueue queue;
+
+    @Override
+    public String getBasePath() {
+        return BASE_URL;
+    }
+
+    @Inject
+    public ReceiveMailOverWebRoutes(MailQueueFactory<?> queueFactory) {
+        queue = queueFactory.createQueue(MailQueueFactory.SPOOL);
+        this.mailPropsJsonExtractor = new JsonExtractor<>(MailProps.class);
+    }
+
+    @Override
+    public void define(Service service) {
+        defineReceiveMailFromWebService(service);
+    }
+
+    @POST
+    @Path("/receiveMail")
+    @ApiOperation(value = "Deleting an user")

Review comment:
       it looks like you left some things after your copy/paste

##########
File path: 
server/protocols/webadmin/webadmin-mail-over-web/src/main/java/org/apache/james/webadmin/routes/ReceiveMailOverWebRoutes.java
##########
@@ -0,0 +1,86 @@
+package org.apache.james.webadmin.routes;
+
+import javax.inject.Inject;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+
+import org.apache.james.queue.api.MailQueue;
+import org.apache.james.queue.api.MailQueueFactory;
+import org.apache.james.server.core.MailImpl;
+import org.apache.james.webadmin.Routes;
+import org.apache.james.webadmin.request.MailProps;
+import org.apache.james.webadmin.utils.ErrorResponder;
+import org.apache.james.webadmin.utils.JsonExtractor;
+import org.eclipse.jetty.http.HttpStatus;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiResponse;
+import io.swagger.annotations.ApiResponses;
+import spark.Service;
+
+@Api(tags = "OverWebMailReceiver")
+@Path(ReceiveMailOverWebRoutes.BASE_URL)
+@Produces("application/json")
+public class ReceiveMailOverWebRoutes implements Routes {
+
+    private final JsonExtractor<MailProps> mailPropsJsonExtractor;
+
+    public static final String BASE_URL = "/receiveMail";

Review comment:
       I suggest `POST /mail-transfer-service/` (you don't know if it will be 
delivered locally or not, right? you want it to go into the mailet pipeline I 
guess)

##########
File path: 
server/protocols/webadmin/webadmin-mail-over-web/src/main/java/org/apache/james/webadmin/request/MailProps.java
##########
@@ -0,0 +1,189 @@
+package org.apache.james.webadmin.request;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.UUID;
+import java.util.function.Predicate;
+
+import javax.activation.DataHandler;
+import javax.mail.Header;
+import javax.mail.MessagingException;
+import javax.mail.internet.AddressException;
+import javax.mail.internet.MimeMessage;
+import javax.mail.internet.PreencodedMimeBodyPart;
+import javax.mail.util.ByteArrayDataSource;
+
+import org.apache.james.core.builder.MimeMessageBuilder;
+import org.apache.james.server.core.MailImpl;
+import org.apache.james.server.core.MimeMessageCopyOnWriteProxy;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.github.fge.lambdas.Throwing;
+import com.google.common.annotations.VisibleForTesting;
+
+public class MailProps {
+
+    private String name = UUID.randomUUID().toString();

Review comment:
       we tend to set values to attributes only in the constructor for a better 
readability

##########
File path: 
server/protocols/webadmin/webadmin-mail-over-web/src/test/resources/json/mail.json
##########
@@ -0,0 +1,13 @@
+{

Review comment:
       I agree that defining new formats is almost always a bad idea: it 
reduces the value of the feature by preventing interoperability with others 
tools, it will probably have new design flaws (existing formats have know 
design flow and people are able to deal with them).
   So I would rather send the mail as a `message/rfc822` payload.




----------------------------------------------------------------
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:
us...@infra.apache.org


> New API endpoint to accept incoming message
> -------------------------------------------
>
>                 Key: JAMES-3389
>                 URL: https://issues.apache.org/jira/browse/JAMES-3389
>             Project: James Server
>          Issue Type: Improvement
>            Reporter: Juhan Aasaru
>            Priority: Major
>
> We have messages arriving over a web service (not SMPT). For this we need a 
> new API endpoint that would accept the message and insert it into the queue 
> (ActiveMQ / rabbitMQ) for the email to be processed and stored. 
> This new code would be placed to webadmin where all of the REST API-s live.
> Since the underlying queues are a bit different (ActiveMQ vs RabbitMQ) it 
> needs to be designed in a way that it works for all configurations.
> Original discussion: 
> [https://www.mail-archive.com/server-user@james.apache.org/msg16399.html]
> I would like to work on this myself but it will take me some weeks before I 
> can start. Feel free to discuss under this task how to design it best. All 
> the ideas how to solve this technically are taken from the thread in the 
> mailing list - I haven't looked at the code myself yet.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

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