james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject [06/10] james-project git commit: MAILBOX-351 User is not needed for mailboxId based reIndexing
Date Thu, 29 Nov 2018 03:53:20 GMT
MAILBOX-351 User is not needed for mailboxId based reIndexing


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

Branch: refs/heads/master
Commit: a09ef44376ccc4da3ba3071dadc036857e819f13
Parents: 85350b3
Author: Benoit Tellier <btellier@linagora.com>
Authored: Fri Nov 23 16:00:30 2018 +0700
Committer: Benoit Tellier <btellier@linagora.com>
Committed: Thu Nov 29 10:52:45 2018 +0700

----------------------------------------------------------------------
 .../james/webadmin/routes/ReindexingRoutes.java |  6 +-
 .../webadmin/routes/ReindexingRoutesTest.java   | 72 ++++----------------
 src/site/markdown/server/manage-webadmin.md     |  6 +-
 3 files changed, 21 insertions(+), 63 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/a09ef443/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 e954a0f..ffb7d98 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
@@ -63,7 +63,7 @@ public class ReindexingRoutes implements Routes {
     private static final String MAILBOX_PARAM = ":mailbox";
     private static final String UID_PARAM = ":uid";
     private static final String USER_PATH = BASE_PATH + "/users/" + USER_PARAM;
-    private static final String MAILBOX_PATH = USER_PATH + "/mailboxes/" + MAILBOX_PARAM;
+    private static final String MAILBOX_PATH = BASE_PATH + "/mailboxes/" + MAILBOX_PARAM;
     private static final String MESSAGE_PATH = MAILBOX_PATH + "/mails/" + UID_PARAM;
 
     private final TaskManager taskManager;
@@ -147,7 +147,7 @@ public class ReindexingRoutes implements Routes {
     }
 
     @POST
-    @Path("/users/{user}/mailboxes/{mailboxId}")
+    @Path("/mailboxes/{mailboxId}")
     @ApiOperation(value = "Re-indexes all the mails in a mailbox")
     @ApiImplicitParams({
         @ApiImplicitParam(
@@ -185,7 +185,7 @@ public class ReindexingRoutes implements Routes {
     }
 
     @POST
-    @Path("/users/{user}/mailboxes/{mailboxId}/mails/{uid}")
+    @Path("/mailboxes/{mailboxId}/mails/{uid}")
     @ApiOperation(value = "Re-indexes a single email")
     @ApiImplicitParams({
         @ApiImplicitParam(

http://git-wip-us.apache.org/repos/asf/james-project/blob/a09ef443/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/ReindexingRoutesTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/ReindexingRoutesTest.java
b/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/ReindexingRoutesTest.java
index 6ac8cc8..08db547 100644
--- a/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/ReindexingRoutesTest.java
+++ b/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/ReindexingRoutesTest.java
@@ -61,7 +61,6 @@ import org.apache.mailbox.tools.indexer.UserReindexingTask;
 import org.eclipse.jetty.http.HttpStatus;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Disabled;
 import org.junit.jupiter.api.Nested;
 import org.junit.jupiter.api.Test;
 import org.mockito.ArgumentCaptor;
@@ -379,7 +378,7 @@ class ReindexingRoutesTest {
                 MailboxId mailboxId = mailboxManager.createMailbox(INBOX, systemSession).get();
 
                 when()
-                    .post("/mailboxIndex/users/" + USERNAME + "/mailboxes/" + mailboxId.serialize())
+                    .post("/mailboxIndex/mailboxes/" + mailboxId.serialize())
                 .then()
                     .statusCode(HttpStatus.BAD_REQUEST_400)
                     .body("statusCode", is(400))
@@ -393,7 +392,7 @@ class ReindexingRoutesTest {
                 MailboxId mailboxId = mailboxManager.createMailbox(INBOX, systemSession).get();
 
                 when()
-                    .post("/mailboxIndex/users/" + USERNAME + "/mailboxes/" + mailboxId.serialize()
+ "?task=bad")
+                    .post("/mailboxIndex/mailboxes/" + mailboxId.serialize() + "?task=bad")
                 .then()
                     .statusCode(HttpStatus.BAD_REQUEST_400)
                     .body("statusCode", is(400))
@@ -401,25 +400,10 @@ class ReindexingRoutesTest {
                     .body("message", is("task query parameter is mandatory. The only supported
value is `reIndex`"));
             }
 
-            @Disabled("Using user here makes no sens from an API perspective, and will be
removed")
-            @Test
-            void mailboxReprocessingShouldFailWithBadUser() throws Exception {
-                MailboxSession systemSession = mailboxManager.createSystemSession(USERNAME);
-                MailboxId mailboxId = mailboxManager.createMailbox(INBOX, systemSession).get();
-
-                when()
-                    .post("/mailboxIndex/users/bad@bad@bad/mailboxes/" + mailboxId.serialize()
+ "?task=reIndex")
-                .then()
-                    .statusCode(HttpStatus.BAD_REQUEST_400)
-                    .body("statusCode", is(400))
-                    .body("type", is(ErrorResponder.ErrorType.INVALID_ARGUMENT.getType()))
-                    .body("message", is("Error while parsing 'user'"));
-            }
-
             @Test
             void mailboxReprocessingShouldFailWithBadMailboxId() {
                 when()
-                    .post("/mailboxIndex/users/" + USERNAME + "/mailboxes/bad?task=reIndex")
+                    .post("/mailboxIndex/mailboxes/bad?task=reIndex")
                 .then()
                     .statusCode(HttpStatus.BAD_REQUEST_400)
                     .body("statusCode", is(400))
@@ -430,18 +414,7 @@ class ReindexingRoutesTest {
             @Test
             void mailboxReprocessingShouldFailWithNonExistentMailboxId() {
                 when()
-                    .post("/mailboxIndex/users/" + USERNAME + "/mailboxes/36?task=reIndex")
-                .then()
-                    .statusCode(HttpStatus.BAD_REQUEST_400)
-                    .body("statusCode", is(400))
-                    .body("type", is(ErrorResponder.ErrorType.INVALID_ARGUMENT.getType()))
-                    .body("message", is("mailbox not found"));
-            }
-
-            @Test
-            void mailboxReprocessingShouldFailWithNonExistentUser() {
-                when()
-                    .post("/mailboxIndex/users/notFound@domain.tld/mailboxes/36?task=reIndex")
+                    .post("/mailboxIndex/mailboxes/36?task=reIndex")
                 .then()
                     .statusCode(HttpStatus.BAD_REQUEST_400)
                     .body("statusCode", is(400))
@@ -458,7 +431,7 @@ class ReindexingRoutesTest {
                 MailboxId mailboxId = mailboxManager.createMailbox(INBOX, systemSession).get();
 
                 String taskId = when()
-                    .post("/mailboxIndex/users/" + USERNAME + "/mailboxes/" + mailboxId.serialize()
+ "?task=reIndex")
+                    .post("/mailboxIndex/mailboxes/" + mailboxId.serialize() + "?task=reIndex")
                     .jsonPath()
                     .get("taskId");
 
@@ -488,7 +461,7 @@ class ReindexingRoutesTest {
                         systemSession);
 
                 String taskId = when()
-                    .post("/mailboxIndex/users/" + USERNAME + "/mailboxes/" + mailboxId.serialize()
+ "?task=reIndex")
+                    .post("/mailboxIndex/mailboxes/" + mailboxId.serialize() + "?task=reIndex")
                     .jsonPath()
                     .get("taskId");
 
@@ -521,7 +494,7 @@ class ReindexingRoutesTest {
                         systemSession);
 
                 String taskId = when()
-                    .post("/mailboxIndex/users/" + USERNAME + "/mailboxes/" + mailboxId.serialize()
+ "?task=reIndex")
+                    .post("/mailboxIndex/mailboxes/" + mailboxId.serialize() + "?task=reIndex")
                     .jsonPath()
                     .get("taskId");
 
@@ -559,7 +532,7 @@ class ReindexingRoutesTest {
                 MailboxId mailboxId = mailboxManager.createMailbox(INBOX, systemSession).get();
 
                 when()
-                    .post("/mailboxIndex/users/" + USERNAME + "/mailboxes/" + mailboxId.serialize()
+ "/mails/7")
+                    .post("/mailboxIndex/mailboxes/" + mailboxId.serialize() + "/mails/7")
                 .then()
                     .statusCode(HttpStatus.BAD_REQUEST_400)
                     .body("statusCode", is(400))
@@ -573,7 +546,7 @@ class ReindexingRoutesTest {
                 MailboxId mailboxId = mailboxManager.createMailbox(INBOX, systemSession).get();
 
                 when()
-                    .post("/mailboxIndex/users/" + USERNAME + "/mailboxes/" + mailboxId.serialize()
+ "/mails/7?task=bad")
+                    .post("/mailboxIndex/mailboxes/" + mailboxId.serialize() + "/mails/7?task=bad")
                 .then()
                     .statusCode(HttpStatus.BAD_REQUEST_400)
                     .body("statusCode", is(400))
@@ -581,25 +554,10 @@ class ReindexingRoutesTest {
                     .body("message", is("task query parameter is mandatory. The only supported
value is `reIndex`"));
             }
 
-            @Disabled("Using user here makes no sens from an API perspective, and will be
removed")
-            @Test
-            void messageReprocessingShouldFailWithBadUser() throws Exception {
-                MailboxSession systemSession = mailboxManager.createSystemSession(USERNAME);
-                MailboxId mailboxId = mailboxManager.createMailbox(INBOX, systemSession).get();
-
-                when()
-                    .post("/mailboxIndex/users/bad@bad@bad/mailboxes/" + mailboxId.serialize()
+ "/mails/7?task=reIndex")
-                .then()
-                    .statusCode(HttpStatus.BAD_REQUEST_400)
-                    .body("statusCode", is(400))
-                    .body("type", is(ErrorResponder.ErrorType.INVALID_ARGUMENT.getType()))
-                    .body("message", is("Error while parsing 'user'"));
-            }
-
             @Test
             void messageReprocessingShouldFailWithBadMailboxId() {
                 when()
-                    .post("/mailboxIndex/users/" + USERNAME + "/mailboxes/bad/mails/7?task=reIndex")
+                    .post("/mailboxIndex/mailboxes/bad/mails/7?task=reIndex")
                 .then()
                     .statusCode(HttpStatus.BAD_REQUEST_400)
                     .body("statusCode", is(400))
@@ -610,7 +568,7 @@ class ReindexingRoutesTest {
             @Test
             void messageReprocessingShouldFailWithNonExistentMailboxId() {
                 when()
-                    .post("/mailboxIndex/users/" + USERNAME + "/mailboxes/36/mails/7?task=reIndex")
+                    .post("/mailboxIndex/mailboxes/36/mails/7?task=reIndex")
                 .then()
                     .statusCode(HttpStatus.BAD_REQUEST_400)
                     .body("statusCode", is(400))
@@ -621,7 +579,7 @@ class ReindexingRoutesTest {
             @Test
             void messageReprocessingShouldFailWithBadUid() {
                 when()
-                    .post("/mailboxIndex/users/" + USERNAME + "/mailboxes/36/mails/bad?task=reIndex")
+                    .post("/mailboxIndex/mailboxes/36/mails/bad?task=reIndex")
                 .then()
                     .statusCode(HttpStatus.BAD_REQUEST_400)
                     .body("statusCode", is(400))
@@ -638,7 +596,7 @@ class ReindexingRoutesTest {
                 MailboxId mailboxId = mailboxManager.createMailbox(INBOX, systemSession).get();
 
                 String taskId = when()
-                    .post("/mailboxIndex/users/" + USERNAME + "/mailboxes/" + mailboxId.serialize()
+ "/mails/1?task=reIndex")
+                    .post("/mailboxIndex/mailboxes/" + mailboxId.serialize() + "/mails/1?task=reIndex")
                     .jsonPath()
                     .get("taskId");
 
@@ -667,7 +625,7 @@ class ReindexingRoutesTest {
                         systemSession);
 
                 String taskId = when()
-                    .post("/mailboxIndex/users/" + USERNAME + "/mailboxes/" + mailboxId.serialize()
+ "/mails/"
+                    .post("/mailboxIndex/mailboxes/" + mailboxId.serialize() + "/mails/"
                         + composedMessageId.getUid().asLong() + "?task=reIndex")
                     .jsonPath()
                     .get("taskId");
@@ -700,7 +658,7 @@ class ReindexingRoutesTest {
                         systemSession);
 
                 String taskId = when()
-                    .post("/mailboxIndex/users/" + USERNAME + "/mailboxes/" + mailboxId.serialize()
+ "/mails/"
+                    .post("/mailboxIndex/mailboxes/" + mailboxId.serialize() + "/mails/"
                         + createdMessage.getUid().asLong() + "?task=reIndex")
                     .jsonPath()
                     .get("taskId");

http://git-wip-us.apache.org/repos/asf/james-project/blob/a09ef443/src/site/markdown/server/manage-webadmin.md
----------------------------------------------------------------------
diff --git a/src/site/markdown/server/manage-webadmin.md b/src/site/markdown/server/manage-webadmin.md
index 5ce90ac..e1547f9 100644
--- a/src/site/markdown/server/manage-webadmin.md
+++ b/src/site/markdown/server/manage-webadmin.md
@@ -2204,10 +2204,10 @@ concurrent changes done during the reIndexing might be ignored.
 ### ReIndexing a mailbox mails
 
 ```
-curl -XPOST http://ip:port/mailboxIndex/users/bob@domain.com/mailboxes/{mailboxId}?task=reIndex
+curl -XPOST http://ip:port/mailboxIndex/mailboxes/{mailboxId}?task=reIndex
 ```
 
-Will schedule a task for reIndexing all the mails in one mailbox belonging to "bob@domain.com".
+Will schedule a task for reIndexing all the mails in one mailbox.
 
 Note that 'mailboxId' path parameter needs to be a (implementation dependent) valid mailboxId.
 
@@ -2250,7 +2250,7 @@ concurrent changes done during the reIndexing might be ignored.
 ### ReIndexing a single mail
 
 ```
-curl -XPOST http://ip:port/mailboxIndex/users/bob@domain.com/mailboxes/{mailboxId}/uid/36?task=reIndex
+curl -XPOST http://ip:port/mailboxIndex/mailboxes/{mailboxId}/uid/36?task=reIndex
 ```
 
 Will schedule a task for reIndexing a single email.


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