james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject [06/12] james-project git commit: JAMES-2555 Swagger documentation for WebAdmin re-indexing API
Date Tue, 23 Oct 2018 01:44:37 GMT
JAMES-2555 Swagger documentation for WebAdmin re-indexing API


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

Branch: refs/heads/master
Commit: 0ad8c161a78ac6118e63f8eeb18f197ffbe82863
Parents: 5f1d679
Author: Benoit Tellier <btellier@linagora.com>
Authored: Fri Oct 12 14:56:33 2018 +0700
Committer: Benoit Tellier <btellier@linagora.com>
Committed: Tue Oct 23 08:43:21 2018 +0700

----------------------------------------------------------------------
 .../WebAdminServerIntegrationTest.java          |  25 ++--
 .../james/webadmin/routes/ReindexingRoutes.java | 124 +++++++++++++++++++
 2 files changed, 137 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/0ad8c161/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/WebAdminServerIntegrationTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/WebAdminServerIntegrationTest.java
b/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/WebAdminServerIntegrationTest.java
index 6374bdf..20e0a71 100644
--- a/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/WebAdminServerIntegrationTest.java
+++ b/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/WebAdminServerIntegrationTest.java
@@ -58,16 +58,16 @@ import io.restassured.RestAssured;
 
 public class WebAdminServerIntegrationTest {
 
-    public static final String DOMAIN = "domain";
-    public static final String USERNAME = "username@" + DOMAIN;
-    public static final String SPECIFIC_DOMAIN = DomainsRoutes.DOMAINS + SEPARATOR + DOMAIN;
-    public static final String SPECIFIC_USER = UserRoutes.USERS + SEPARATOR + USERNAME;
-    public static final String MAILBOX = "mailbox";
-    public static final String SPECIFIC_MAILBOX = SPECIFIC_USER + SEPARATOR + UserMailboxesRoutes.MAILBOXES
+ SEPARATOR + MAILBOX;
-    public static final String VERSION = "/cassandra/version";
-    public static final String VERSION_LATEST = VERSION + "/latest";
-    public static final String UPGRADE_VERSION = VERSION + "/upgrade";
-    public static final String UPGRADE_TO_LATEST_VERSION = UPGRADE_VERSION + "/latest";
+    private static final String DOMAIN = "domain";
+    private static final String USERNAME = "username@" + DOMAIN;
+    private static final String SPECIFIC_DOMAIN = DomainsRoutes.DOMAINS + SEPARATOR + DOMAIN;
+    private static final String SPECIFIC_USER = UserRoutes.USERS + SEPARATOR + USERNAME;
+    private static final String MAILBOX = "mailbox";
+    private static final String SPECIFIC_MAILBOX = SPECIFIC_USER + SEPARATOR + UserMailboxesRoutes.MAILBOXES
+ SEPARATOR + MAILBOX;
+    private static final String VERSION = "/cassandra/version";
+    private static final String VERSION_LATEST = VERSION + "/latest";
+    private static final String UPGRADE_VERSION = VERSION + "/upgrade";
+    private static final String UPGRADE_TO_LATEST_VERSION = UPGRADE_VERSION + "/latest";
 
     @ClassRule
     public static DockerCassandraRule cassandra = new DockerCassandraRule();
@@ -326,11 +326,12 @@ public class WebAdminServerIntegrationTest {
             .body(containsString("\"tags\":[\"MailRepositories\"]"))
             .body(containsString("\"tags\":[\"MailQueues\"]"))
             .body(containsString("\"tags\":[\"Address Forwards\"]"))
-            .body(containsString("\"tags\":[\"Address Groups\"]"));
+            .body(containsString("\"tags\":[\"Address Groups\"]"))
+            .body(containsString("{\"name\":\"ReIndexing\"}"));
     }
 
     @Test
-    public void validateHealthChecksShouldReturnOk() throws Exception {
+    public void validateHealthChecksShouldReturnOk() {
         when()
             .get(HealthCheckRoutes.HEALTHCHECK)
         .then()

http://git-wip-us.apache.org/repos/asf/james-project/blob/0ad8c161/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/routes/ReindexingRoutes.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/routes/ReindexingRoutes.java
b/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/routes/ReindexingRoutes.java
index 512ef57..b9c67c5 100644
--- a/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/routes/ReindexingRoutes.java
+++ b/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/routes/ReindexingRoutes.java
@@ -20,6 +20,9 @@
 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.core.User;
 import org.apache.james.mailbox.MailboxManager;
@@ -41,10 +44,19 @@ import org.eclipse.jetty.http.HttpStatus;
 
 import com.github.fge.lambdas.supplier.ThrowingSupplier;
 
+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.Request;
 import spark.Response;
 import spark.Service;
 
+@Api(tags = "ReIndexing")
+@Path("/mailboxIndex")
+@Produces("application/json")
 public class ReindexingRoutes implements Routes {
     private static final String BASE_PATH = "/mailboxIndex";
     private static final String USER_PARAM = ":user";
@@ -82,21 +94,133 @@ public class ReindexingRoutes implements Routes {
         service.post(MESSAGE_PATH, this::reIndexMessage, jsonTransformer);
     }
 
+    @POST
+    @Path("/")
+    @ApiOperation(value = "Re-indexes all the mails on this server")
+    @ApiImplicitParams({
+        @ApiImplicitParam(
+            required = true,
+            name = "task",
+            paramType = "query parameter",
+            dataType = "String",
+            defaultValue = "none",
+            example = "?task=reIndex",
+            value = "Compulsory. Only supported value is `reIndex`")
+    })
+    @ApiResponses(value = {
+        @ApiResponse(code = HttpStatus.CREATED_201, message = "Task is created", response
= TaskIdDto.class),
+        @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "Internal server
error - Something went bad on the server side."),
+        @ApiResponse(code = HttpStatus.BAD_REQUEST_400, message = "Bad request - details
in the returned error message")
+    })
     private TaskIdDto reIndexAll(Request request, Response response) {
         return wrap(request, response,
             () -> reIndexer.reIndex());
     }
 
+    @POST
+    @Path("/users/{user}")
+    @ApiOperation(value = "Re-indexes all the mails of a user")
+    @ApiImplicitParams({
+        @ApiImplicitParam(
+            required = true,
+            name = "task",
+            paramType = "query parameter",
+            dataType = "String",
+            defaultValue = "none",
+            example = "?task=reIndex",
+            value = "Compulsory. Only supported value is `reIndex`"),
+        @ApiImplicitParam(
+            required = true,
+            name = "user",
+            paramType = "path parameter",
+            dataType = "String",
+            defaultValue = "none",
+            example = "benoit@apache.org",
+            value = "Compulsory. Needs to be a valid username")
+    })
+    @ApiResponses(value = {
+        @ApiResponse(code = HttpStatus.CREATED_201, message = "Task is created", response
= TaskIdDto.class),
+        @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "Internal server
error - Something went bad on the server side."),
+        @ApiResponse(code = HttpStatus.BAD_REQUEST_400, message = "Bad request - details
in the returned error message")
+    })
     private TaskIdDto reIndexUser(Request request, Response response) {
         return wrap(request, response,
             () -> reIndexer.reIndex(extractUser(request)));
     }
 
+    @POST
+    @Path("/users/{user}/mailboxes/{mailboxId}")
+    @ApiOperation(value = "Re-indexes all the mails in a mailbox")
+    @ApiImplicitParams({
+        @ApiImplicitParam(
+            required = true,
+            name = "task",
+            paramType = "query parameter",
+            dataType = "String",
+            defaultValue = "none",
+            example = "?task=reIndex",
+            value = "Compulsory. Only supported value is `reIndex`"),
+        @ApiImplicitParam(
+            required = true,
+            name = "user",
+            paramType = "path parameter",
+            dataType = "String",
+            defaultValue = "none",
+            example = "benoit@apache.org",
+            value = "Compulsory. Needs to be a valid username"),
+        @ApiImplicitParam(
+            required = true,
+            name = "mailboxId",
+            paramType = "path parameter",
+            dataType = "String",
+            defaultValue = "none",
+            value = "Compulsory. Needs to be a valid mailbox ID")
+    })
+    @ApiResponses(value = {
+        @ApiResponse(code = HttpStatus.CREATED_201, message = "Task is created", response
= TaskIdDto.class),
+        @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "Internal server
error - Something went bad on the server side."),
+        @ApiResponse(code = HttpStatus.BAD_REQUEST_400, message = "Bad request - details
in the returned error message")
+    })
     private TaskIdDto reIndexMailbox(Request request, Response response) {
         return wrap(request, response,
             () -> reIndexer.reIndex(retrievePath(request)));
     }
 
+    @POST
+    @Path("/users/{user}/mailboxes/{mailboxId}/mails/{uid}")
+    @ApiOperation(value = "Re-indexes a single email")
+    @ApiImplicitParams({
+        @ApiImplicitParam(
+            required = true,
+            name = "task",
+            paramType = "query parameter",
+            dataType = "String",
+            defaultValue = "none",
+            example = "?task=reIndex",
+            value = "Compulsory. Only supported value is `reIndex`"),
+        @ApiImplicitParam(
+            required = true,
+            name = "user",
+            paramType = "path parameter",
+            dataType = "String",
+            defaultValue = "none",
+            example = "benoit@apache.org",
+            value = "Compulsory. Needs to be a valid username"),
+        @ApiImplicitParam(
+            required = true,
+            name = "mailboxId",
+            paramType = "path parameter",
+            dataType = "String",
+            defaultValue = "none",
+            value = "Compulsory. Needs to be a valid mailbox ID"),
+        @ApiImplicitParam(
+            required = true,
+            name = "uid",
+            paramType = "path parameter",
+            dataType = "Integer",
+            defaultValue = "none",
+            value = "Compulsory. Needs to be a valid UID")
+    })
     private TaskIdDto reIndexMessage(Request request, Response response) {
         return wrap(request, response,
             () -> reIndexer.reIndex(retrievePath(request), extractUid(request)));


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