You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by bt...@apache.org on 2017/12/06 02:10:55 UTC

[5/5] james-project git commit: JAMES-2233 uniformize HttpResponse code constant in Webadmin

JAMES-2233 uniformize HttpResponse code constant in Webadmin


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

Branch: refs/heads/master
Commit: 21188d00e37d425289b77da4b2ab650991c656bc
Parents: 1787c9c
Author: Luc DUZAN <ld...@linagora.com>
Authored: Mon Dec 4 15:16:25 2017 +0100
Committer: benwa <bt...@linagora.com>
Committed: Wed Dec 6 09:10:16 2017 +0700

----------------------------------------------------------------------
 .../integration/JwtFilterIntegrationTest.java   |   7 +-
 .../WebAdminServerIntegrationTest.java          |  31 ++--
 .../routes/CassandraMigrationRoutes.java        |  31 ++--
 .../routes/CassandraMigrationRoutesTest.java    |  25 +--
 .../webadmin/authentication/JwtFilter.java      |   7 +-
 .../james/webadmin/utils/ErrorResponder.java    |   2 +-
 .../webadmin/authentication/JwtFilterTest.java  |   3 +-
 .../webadmin/utils/ErrorResponderTest.java      |  35 ++--
 .../james/webadmin/routes/DomainsRoutes.java    |  28 ++--
 .../james/webadmin/routes/GroupsRoutes.java     |  33 ++--
 .../james/webadmin/routes/UserRoutes.java       |  21 +--
 .../james/webadmin/service/UserService.java     |   5 +-
 .../webadmin/routes/DomainsRoutesTest.java      |  51 +++---
 .../james/webadmin/routes/GroupsRoutesTest.java |  16 +-
 .../james/webadmin/routes/UsersRoutesTest.java  |  59 +++----
 .../webadmin/routes/GlobalQuotaRoutes.java      |  56 ++++---
 .../webadmin/routes/UserMailboxesRoutes.java    |  56 +++----
 .../webadmin/routes/GlobalQuotaRoutesTest.java  |  46 +++---
 .../routes/UserMailboxesRoutesTest.java         | 159 ++++++++++---------
 .../webadmin/swagger/routes/SwaggerRoutes.java  |   3 +-
 20 files changed, 348 insertions(+), 326 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/21188d00/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/JwtFilterIntegrationTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/JwtFilterIntegrationTest.java b/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/JwtFilterIntegrationTest.java
index 97e6deb..429db13 100644
--- a/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/JwtFilterIntegrationTest.java
+++ b/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/JwtFilterIntegrationTest.java
@@ -37,6 +37,7 @@ import org.apache.james.utils.WebAdminGuiceProbe;
 import org.apache.james.webadmin.authentication.AuthenticationFilter;
 import org.apache.james.webadmin.authentication.JwtFilter;
 import org.apache.james.webadmin.routes.DomainsRoutes;
+import org.eclipse.jetty.http.HttpStatus;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.ClassRule;
@@ -108,7 +109,7 @@ public class JwtFilterIntegrationTest {
         .when()
             .put(SPECIFIC_DOMAIN)
         .then()
-            .statusCode(204);
+            .statusCode(HttpStatus.NO_CONTENT_204);
 
         assertThat(dataProbe.listDomains())
             .contains(DOMAIN);
@@ -122,7 +123,7 @@ public class JwtFilterIntegrationTest {
         .when()
             .put(SPECIFIC_DOMAIN)
         .then()
-            .statusCode(401);
+            .statusCode(HttpStatus.UNAUTHORIZED_401);
 
         assertThat(dataProbe.listDomains())
             .doesNotContain(DOMAIN);
@@ -136,7 +137,7 @@ public class JwtFilterIntegrationTest {
         .when()
             .put(SPECIFIC_DOMAIN)
         .then()
-            .statusCode(401);
+            .statusCode(HttpStatus.UNAUTHORIZED_401);
 
         assertThat(dataProbe.listDomains())
             .doesNotContain(DOMAIN);

http://git-wip-us.apache.org/repos/asf/james-project/blob/21188d00/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 30c810d..d468ddb 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
@@ -42,6 +42,7 @@ import org.apache.james.webadmin.routes.DomainsRoutes;
 import org.apache.james.webadmin.routes.UserMailboxesRoutes;
 import org.apache.james.webadmin.routes.UserRoutes;
 import org.apache.james.webadmin.swagger.routes.SwaggerRoutes;
+import org.eclipse.jetty.http.HttpStatus;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.ClassRule;
@@ -103,7 +104,7 @@ public class WebAdminServerIntegrationTest {
         .when()
             .put(SPECIFIC_DOMAIN)
         .then()
-            .statusCode(204);
+            .statusCode(HttpStatus.NO_CONTENT_204);
 
         assertThat(dataProbe.listDomains()).contains(DOMAIN);
     }
@@ -117,7 +118,7 @@ public class WebAdminServerIntegrationTest {
         .when()
             .delete(SPECIFIC_DOMAIN)
         .then()
-            .statusCode(204);
+            .statusCode(HttpStatus.NO_CONTENT_204);
 
         assertThat(dataProbe.listDomains()).doesNotContain(DOMAIN);
     }
@@ -132,7 +133,7 @@ public class WebAdminServerIntegrationTest {
         .when()
             .put(SPECIFIC_USER)
         .then()
-            .statusCode(204);
+            .statusCode(HttpStatus.NO_CONTENT_204);
 
         assertThat(dataProbe.listUsers()).contains(USERNAME);
     }
@@ -148,7 +149,7 @@ public class WebAdminServerIntegrationTest {
         .when()
             .delete(SPECIFIC_USER)
         .then()
-            .statusCode(204);
+            .statusCode(HttpStatus.NO_CONTENT_204);
 
         assertThat(dataProbe.listUsers()).doesNotContain(USERNAME);
     }
@@ -163,7 +164,7 @@ public class WebAdminServerIntegrationTest {
         .when()
             .get(UserRoutes.USERS)
         .then()
-            .statusCode(200)
+            .statusCode(HttpStatus.OK_200)
             .contentType(JSON_CONTENT_TYPE)
             .body(is("[{\"username\":\"username@domain\"}]"));
     }
@@ -178,7 +179,7 @@ public class WebAdminServerIntegrationTest {
         .when()
             .put(SPECIFIC_MAILBOX)
         .then()
-            .statusCode(204);
+            .statusCode(HttpStatus.NO_CONTENT_204);
 
         assertThat(guiceJamesServer.getProbe(MailboxProbeImpl.class).listUserMailboxes(USERNAME)).containsExactly(MAILBOX);
     }
@@ -194,7 +195,7 @@ public class WebAdminServerIntegrationTest {
         .when()
             .delete(SPECIFIC_MAILBOX)
         .then()
-            .statusCode(204);
+            .statusCode(HttpStatus.NO_CONTENT_204);
 
         assertThat(guiceJamesServer.getProbe(MailboxProbeImpl.class).listUserMailboxes(USERNAME)).isEmpty();
     }
@@ -206,7 +207,7 @@ public class WebAdminServerIntegrationTest {
         .when()
             .get(VERSION)
         .then()
-            .statusCode(200)
+            .statusCode(HttpStatus.OK_200)
             .contentType(JSON_CONTENT_TYPE)
             .body(is("{\"version\":null}"));
     }
@@ -218,7 +219,7 @@ public class WebAdminServerIntegrationTest {
         .when()
             .get(VERSION_LATEST)
         .then()
-            .statusCode(200)
+            .statusCode(HttpStatus.OK_200)
             .contentType(JSON_CONTENT_TYPE)
             .body(is("{\"version\":" + CassandraSchemaVersionManager.MAX_VERSION + "}"));
     }
@@ -231,14 +232,14 @@ public class WebAdminServerIntegrationTest {
         .when()
             .post(UPGRADE_VERSION)
         .then()
-            .statusCode(204);
+            .statusCode(HttpStatus.NO_CONTENT_204);
 
         given()
             .port(webAdminGuiceProbe.getWebAdminPort())
         .when()
             .get(VERSION)
         .then()
-            .statusCode(200)
+            .statusCode(HttpStatus.OK_200)
             .contentType(JSON_CONTENT_TYPE)
             .body(is("{\"version\":" + CassandraSchemaVersionManager.MAX_VERSION + "}"));
     }
@@ -250,14 +251,14 @@ public class WebAdminServerIntegrationTest {
         .when()
             .post(UPGRADE_TO_LATEST_VERSION)
         .then()
-            .statusCode(200);
+            .statusCode(HttpStatus.OK_200);
 
         given()
             .port(webAdminGuiceProbe.getWebAdminPort())
         .when()
             .get(VERSION)
         .then()
-            .statusCode(200)
+            .statusCode(HttpStatus.OK_200)
             .contentType(JSON_CONTENT_TYPE)
             .body(is("{\"version\":" + CassandraSchemaVersionManager.MAX_VERSION + "}"));
     }
@@ -272,7 +273,7 @@ public class WebAdminServerIntegrationTest {
             .when()
             .get("/address/groups/group@domain.com")
             .then()
-            .statusCode(200)
+            .statusCode(HttpStatus.OK_200)
             .contentType(JSON_CONTENT_TYPE)
             .extract()
             .jsonPath()
@@ -287,7 +288,7 @@ public class WebAdminServerIntegrationTest {
         .when()
             .get(SwaggerRoutes.SWAGGER_ENDPOINT)
         .then()
-            .statusCode(200)
+            .statusCode(HttpStatus.OK_200)
             .body(containsString("\"swagger\":\"2.0\""))
             .body(containsString("\"info\":{\"description\":\"All the web administration API for JAMES\",\"version\":\"V1.0\",\"title\":\"JAMES Web Admin API\"}"))
             .body(containsString("\"tags\":[\"User's Mailbox\"]"))

http://git-wip-us.apache.org/repos/asf/james-project/blob/21188d00/server/protocols/webadmin/webadmin-cassandra/src/main/java/org/apache/james/webadmin/routes/CassandraMigrationRoutes.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin/webadmin-cassandra/src/main/java/org/apache/james/webadmin/routes/CassandraMigrationRoutes.java b/server/protocols/webadmin/webadmin-cassandra/src/main/java/org/apache/james/webadmin/routes/CassandraMigrationRoutes.java
index ff08bea..3a42657 100644
--- a/server/protocols/webadmin/webadmin-cassandra/src/main/java/org/apache/james/webadmin/routes/CassandraMigrationRoutes.java
+++ b/server/protocols/webadmin/webadmin-cassandra/src/main/java/org/apache/james/webadmin/routes/CassandraMigrationRoutes.java
@@ -43,11 +43,14 @@ public class CassandraMigrationRoutes implements Routes {
     private static final String VERSION_BASE_LATEST = VERSION_BASE + "/latest";
     private static final String VERSION_UPGRADE_BASE = VERSION_BASE + "/upgrade";
     private static final String VERSION_UPGRADE_TO_LATEST_BASE = VERSION_UPGRADE_BASE + "/latest";
-    private static final int NO_CONTENT = 204;
 
     private final CassandraMigrationService cassandraMigrationService;
     private final JsonTransformer jsonTransformer;
 
+    public static String INVALID_VERSION_UPGRADE_REQUEST = "Invalid request for version upgrade";
+    public static String MIGRATION_REQUEST_CAN_NOT_BE_DONE = "The migration requested can not be performed";
+    public static String PARTIAL_MIGRATION_PROCESS = "An error lead to partial migration process";
+
     @Inject
     public CassandraMigrationRoutes(CassandraMigrationService cassandraMigrationService, JsonTransformer jsonTransformer) {
         this.cassandraMigrationService = cassandraMigrationService;
@@ -69,29 +72,29 @@ public class CassandraMigrationRoutes implements Routes {
             try {
                 CassandraVersionRequest cassandraVersionRequest = CassandraVersionRequest.parse(request.body());
                 cassandraMigrationService.upgradeToVersion(cassandraVersionRequest.getValue());
-                response.status(NO_CONTENT);
+                response.status(HttpStatus.NO_CONTENT_204);
             } catch (NullPointerException | IllegalArgumentException e) {
-                LOGGER.info("Invalid request for version upgrade");
+                LOGGER.info(INVALID_VERSION_UPGRADE_REQUEST);
                 throw ErrorResponder.builder()
                     .statusCode(HttpStatus.BAD_REQUEST_400)
                     .type(ErrorType.INVALID_ARGUMENT)
-                    .message("Invalid request for version upgrade")
+                    .message(INVALID_VERSION_UPGRADE_REQUEST)
                     .cause(e)
                     .haltError();
             } catch (IllegalStateException e) {
-                LOGGER.info("The migration requested can not be performed.", e);
+                LOGGER.info(MIGRATION_REQUEST_CAN_NOT_BE_DONE, e);
                 throw ErrorResponder.builder()
-                    .statusCode(HttpStatus.GONE_410)
+                    .statusCode(HttpStatus.CONFLICT_409)
                     .type(ErrorType.WRONG_STATE)
-                    .message("The migration requested can not be performed")
+                    .message(MIGRATION_REQUEST_CAN_NOT_BE_DONE)
                     .cause(e)
                     .haltError();
             } catch (MigrationException e) {
-                LOGGER.error("An error lead to partial migration process", e);
+                LOGGER.error(PARTIAL_MIGRATION_PROCESS, e);
                 throw ErrorResponder.builder()
                     .statusCode(HttpStatus.INTERNAL_SERVER_ERROR_500)
                     .type(ErrorType.SERVER_ERROR)
-                    .message("An error lead to partial migration process")
+                    .message(PARTIAL_MIGRATION_PROCESS)
                     .cause(e)
                     .haltError();
             }
@@ -102,19 +105,19 @@ public class CassandraMigrationRoutes implements Routes {
             try {
                 cassandraMigrationService.upgradeToLastVersion();
             } catch (IllegalStateException e) {
-                LOGGER.info("The migration requested can not be performed.", e);
+                LOGGER.info(MIGRATION_REQUEST_CAN_NOT_BE_DONE, e);
                 throw ErrorResponder.builder()
-                    .statusCode(HttpStatus.GONE_410)
+                    .statusCode(HttpStatus.CONFLICT_409)
                     .type(ErrorType.WRONG_STATE)
-                    .message("The migration requested can not be performed")
+                    .message(MIGRATION_REQUEST_CAN_NOT_BE_DONE)
                     .cause(e)
                     .haltError();
             } catch (MigrationException e) {
-                LOGGER.error("An error lead to partial migration process", e);
+                LOGGER.error(PARTIAL_MIGRATION_PROCESS, e);
                 throw ErrorResponder.builder()
                     .statusCode(HttpStatus.INTERNAL_SERVER_ERROR_500)
                     .type(ErrorType.SERVER_ERROR)
-                    .message("An error lead to partial migration process")
+                    .message(PARTIAL_MIGRATION_PROCESS)
                     .cause(e)
                     .haltError();
             }

http://git-wip-us.apache.org/repos/asf/james-project/blob/21188d00/server/protocols/webadmin/webadmin-cassandra/src/test/java/org/apache/james/webadmin/routes/CassandraMigrationRoutesTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin/webadmin-cassandra/src/test/java/org/apache/james/webadmin/routes/CassandraMigrationRoutesTest.java b/server/protocols/webadmin/webadmin-cassandra/src/test/java/org/apache/james/webadmin/routes/CassandraMigrationRoutesTest.java
index a6d6c14..e475373 100644
--- a/server/protocols/webadmin/webadmin-cassandra/src/test/java/org/apache/james/webadmin/routes/CassandraMigrationRoutesTest.java
+++ b/server/protocols/webadmin/webadmin-cassandra/src/test/java/org/apache/james/webadmin/routes/CassandraMigrationRoutesTest.java
@@ -43,6 +43,7 @@ import org.apache.james.webadmin.WebAdminServer;
 import org.apache.james.webadmin.WebAdminUtils;
 import org.apache.james.webadmin.service.CassandraMigrationService;
 import org.apache.james.webadmin.utils.JsonTransformer;
+import org.eclipse.jetty.http.HttpStatus;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Ignore;
@@ -107,7 +108,7 @@ public class CassandraMigrationRoutesTest {
             when()
                 .get()
             .then()
-                .statusCode(200)
+                .statusCode(HttpStatus.OK_200)
                 .contentType(ContentType.JSON)
                 .extract()
                 .jsonPath()
@@ -123,7 +124,7 @@ public class CassandraMigrationRoutesTest {
             when()
                 .get("/latest")
             .then()
-                .statusCode(200)
+                .statusCode(HttpStatus.OK_200)
                 .contentType(ContentType.JSON)
                 .extract()
                 .jsonPath()
@@ -138,7 +139,7 @@ public class CassandraMigrationRoutesTest {
         when()
             .post("/upgrade")
         .then()
-            .statusCode(409);
+            .statusCode(HttpStatus.CONFLICT_409);
     }
 
     @Test
@@ -146,11 +147,11 @@ public class CassandraMigrationRoutesTest {
         when(schemaVersionDAO.getCurrentSchemaVersion()).thenReturn(CompletableFuture.completedFuture(Optional.of(OLDER_VERSION)));
 
         Map<String, Object> errors = given()
-            .body(String.valueOf("NonInt"))
+            .body("NonInt")
         .with()
             .post("/upgrade")
         .then()
-            .statusCode(400)
+            .statusCode(HttpStatus.BAD_REQUEST_400)
             .contentType(ContentType.JSON)
             .extract()
             .body()
@@ -158,7 +159,7 @@ public class CassandraMigrationRoutesTest {
             .getMap(".");
 
         assertThat(errors)
-            .containsEntry("statusCode", 400)
+            .containsEntry("statusCode", HttpStatus.BAD_REQUEST_400)
             .containsEntry("type", "InvalidArgument")
             .containsEntry("message", "Invalid request for version upgrade")
             .containsEntry("cause", "For input string: \"NonInt\"");
@@ -175,7 +176,7 @@ public class CassandraMigrationRoutesTest {
         .with()
             .post("/upgrade")
         .then()
-            .statusCode(204);
+            .statusCode(HttpStatus.NO_CONTENT_204);
 
         verify(schemaVersionDAO, times(1)).getCurrentSchemaVersion();
         verify(schemaVersionDAO, times(1)).updateVersion(eq(CURRENT_VERSION));
@@ -191,7 +192,7 @@ public class CassandraMigrationRoutesTest {
         .with()
             .post("/upgrade")
         .then()
-            .statusCode(410)
+            .statusCode(HttpStatus.CONFLICT_409)
             .contentType(ContentType.JSON)
             .extract()
             .body()
@@ -199,7 +200,7 @@ public class CassandraMigrationRoutesTest {
             .getMap(".");
 
         assertThat(errors)
-            .containsEntry("statusCode", 410)
+            .containsEntry("statusCode", HttpStatus.CONFLICT_409)
             .containsEntry("type", "WrongState")
             .containsEntry("message", "The migration requested can not be performed")
             .containsEntry("cause", "Current version is already up to date");
@@ -215,7 +216,7 @@ public class CassandraMigrationRoutesTest {
         when()
             .post("/upgrade/latest")
         .then()
-            .statusCode(200);
+            .statusCode(HttpStatus.OK_200);
 
         verify(schemaVersionDAO, times(1)).getCurrentSchemaVersion();
         verify(schemaVersionDAO, times(1)).updateVersion(eq(CURRENT_VERSION));
@@ -230,7 +231,7 @@ public class CassandraMigrationRoutesTest {
         Map<String, Object> errors = when()
             .post("/upgrade/latest")
         .then()
-            .statusCode(410)
+            .statusCode(HttpStatus.CONFLICT_409)
             .contentType(ContentType.JSON)
             .extract()
             .body()
@@ -238,7 +239,7 @@ public class CassandraMigrationRoutesTest {
             .getMap(".");
 
         assertThat(errors)
-            .containsEntry("statusCode", 410)
+            .containsEntry("statusCode", HttpStatus.CONFLICT_409)
             .containsEntry("type", "WrongState")
             .containsEntry("message", "The migration requested can not be performed")
             .containsEntry("cause", "Current version is already up to date");

http://git-wip-us.apache.org/repos/asf/james-project/blob/21188d00/server/protocols/webadmin/webadmin-core/src/main/java/org/apache/james/webadmin/authentication/JwtFilter.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin/webadmin-core/src/main/java/org/apache/james/webadmin/authentication/JwtFilter.java b/server/protocols/webadmin/webadmin-core/src/main/java/org/apache/james/webadmin/authentication/JwtFilter.java
index 494ee6e..3dda17b 100644
--- a/server/protocols/webadmin/webadmin-core/src/main/java/org/apache/james/webadmin/authentication/JwtFilter.java
+++ b/server/protocols/webadmin/webadmin-core/src/main/java/org/apache/james/webadmin/authentication/JwtFilter.java
@@ -27,6 +27,7 @@ import javax.inject.Inject;
 
 import org.apache.james.jwt.JwtTokenVerifier;
 
+import org.eclipse.jetty.http.HttpStatus;
 import spark.Request;
 import spark.Response;
 
@@ -60,19 +61,19 @@ public class JwtFilter implements AuthenticationFilter {
 
     private void checkHeaderPresent(Optional<String> bearer) {
         if (!bearer.isPresent()) {
-            halt(401, "No Bearer header.");
+            halt(HttpStatus.UNAUTHORIZED_401, "No Bearer header.");
         }
     }
 
     private void checkValidSignature(Optional<String> bearer) {
         if (!jwtTokenVerifier.verify(bearer.get())) {
-            halt(401, "Invalid Bearer header.");
+            halt(HttpStatus.UNAUTHORIZED_401, "Invalid Bearer header.");
         }
     }
 
     private void checkIsAdmin(Optional<String> bearer) {
         if (!jwtTokenVerifier.hasAttribute("admin", true, bearer.get())) {
-            halt(401, "Non authorized user.");
+            halt(HttpStatus.UNAUTHORIZED_401, "Non authorized user.");
         }
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/21188d00/server/protocols/webadmin/webadmin-core/src/main/java/org/apache/james/webadmin/utils/ErrorResponder.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin/webadmin-core/src/main/java/org/apache/james/webadmin/utils/ErrorResponder.java b/server/protocols/webadmin/webadmin-core/src/main/java/org/apache/james/webadmin/utils/ErrorResponder.java
index 90642bb..c87f0f9 100644
--- a/server/protocols/webadmin/webadmin-core/src/main/java/org/apache/james/webadmin/utils/ErrorResponder.java
+++ b/server/protocols/webadmin/webadmin-core/src/main/java/org/apache/james/webadmin/utils/ErrorResponder.java
@@ -88,7 +88,7 @@ public class ErrorResponder {
             return halt(statusCode, new JsonTransformer().render(new ErrorDetail(statusCode,
                 type.getType(),
                 message,
-                cause.map(e -> Optional.of(e.getMessage())).orElse(Optional.empty()))));
+                cause.map(e -> Optional.ofNullable(e.getMessage())).orElse(Optional.empty()))));
         } catch (JsonProcessingException e) {
             return halt(statusCode);
         }

http://git-wip-us.apache.org/repos/asf/james-project/blob/21188d00/server/protocols/webadmin/webadmin-core/src/test/java/org/apache/james/webadmin/authentication/JwtFilterTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin/webadmin-core/src/test/java/org/apache/james/webadmin/authentication/JwtFilterTest.java b/server/protocols/webadmin/webadmin-core/src/test/java/org/apache/james/webadmin/authentication/JwtFilterTest.java
index 6512ddb..0c4b3df 100644
--- a/server/protocols/webadmin/webadmin-core/src/test/java/org/apache/james/webadmin/authentication/JwtFilterTest.java
+++ b/server/protocols/webadmin/webadmin-core/src/test/java/org/apache/james/webadmin/authentication/JwtFilterTest.java
@@ -23,6 +23,7 @@ import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
 import org.apache.james.jwt.JwtTokenVerifier;
+import org.eclipse.jetty.http.HttpStatus;
 import org.hamcrest.BaseMatcher;
 import org.hamcrest.Description;
 import org.hamcrest.Matcher;
@@ -44,7 +45,7 @@ public class JwtFilterTest {
         public boolean matches(Object o) {
             if (o instanceof HaltException) {
                 HaltException haltException = (HaltException) o;
-                return haltException.statusCode() == 401;
+                return haltException.statusCode() == HttpStatus.UNAUTHORIZED_401;
             }
             return false;
         }

http://git-wip-us.apache.org/repos/asf/james-project/blob/21188d00/server/protocols/webadmin/webadmin-core/src/test/java/org/apache/james/webadmin/utils/ErrorResponderTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin/webadmin-core/src/test/java/org/apache/james/webadmin/utils/ErrorResponderTest.java b/server/protocols/webadmin/webadmin-core/src/test/java/org/apache/james/webadmin/utils/ErrorResponderTest.java
index 3e98aae..46f2997 100644
--- a/server/protocols/webadmin/webadmin-core/src/test/java/org/apache/james/webadmin/utils/ErrorResponderTest.java
+++ b/server/protocols/webadmin/webadmin-core/src/test/java/org/apache/james/webadmin/utils/ErrorResponderTest.java
@@ -24,6 +24,7 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
 import java.util.Objects;
 import java.util.Optional;
 
+import org.eclipse.jetty.http.HttpStatus;
 import org.junit.Test;
 
 import com.jayway.jsonpath.DocumentContext;
@@ -45,7 +46,7 @@ public class ErrorResponderTest {
     @Test
     public void haltErrorShouldThrowWhenNoType() throws Exception {
         assertThatThrownBy(() -> ErrorResponder.builder()
-            .statusCode(400)
+            .statusCode(HttpStatus.BAD_REQUEST_400)
             .haltError())
             .isInstanceOf(NullPointerException.class);
     }
@@ -53,7 +54,7 @@ public class ErrorResponderTest {
     @Test
     public void haltErrorShouldThrowWhenNoMessage() throws Exception {
         assertThatThrownBy(() -> ErrorResponder.builder()
-            .statusCode(400)
+            .statusCode(HttpStatus.BAD_REQUEST_400)
             .type(ErrorResponder.ErrorType.INVALID_ARGUMENT)
             .haltError())
             .isInstanceOf(NullPointerException.class);
@@ -62,63 +63,63 @@ public class ErrorResponderTest {
     @Test
     public void haltErrorShouldReturnBodyWithStatusCodeWhenSetting() throws Exception {
         assertThatThrownBy(() -> ErrorResponder.builder()
-                .statusCode(404)
+                .statusCode(HttpStatus.NOT_FOUND_404)
                 .type(ErrorResponder.ErrorType.INVALID_ARGUMENT)
                 .message("Error")
                 .haltError())
             .isInstanceOf(HaltException.class)
-            .matches(e -> hasStatus(e, 404))
-            .matches(e -> bodyHasErrorDetail(e, new ErrorResponder.ErrorDetail(404, "InvalidArgument", "Error", NO_CAUSE)));
+            .matches(e -> hasStatus(e, HttpStatus.NOT_FOUND_404))
+            .matches(e -> bodyHasErrorDetail(e, new ErrorResponder.ErrorDetail(HttpStatus.NOT_FOUND_404, "InvalidArgument", "Error", NO_CAUSE)));
     }
 
     @Test
     public void haltErrorShouldReturnBodyWithErrorTypeWhenSetting() throws Exception {
         assertThatThrownBy(() -> ErrorResponder.builder()
-                .statusCode(400)
+                .statusCode(HttpStatus.BAD_REQUEST_400)
                 .type(ErrorResponder.ErrorType.WRONG_STATE)
                 .message("Error")
                 .haltError())
             .isInstanceOf(HaltException.class)
-            .matches(e -> hasStatus(e, 400))
-            .matches(e -> bodyHasErrorDetail(e, new ErrorResponder.ErrorDetail(400, "WrongState", "Error", NO_CAUSE)));
+            .matches(e -> hasStatus(e, HttpStatus.BAD_REQUEST_400))
+            .matches(e -> bodyHasErrorDetail(e, new ErrorResponder.ErrorDetail(HttpStatus.BAD_REQUEST_400, "WrongState", "Error", NO_CAUSE)));
     }
 
     @Test
     public void haltErrorShouldReturnBodyWithErrorMessageWhenSetting() throws Exception {
         assertThatThrownBy(() -> ErrorResponder.builder()
-                .statusCode(400)
+                .statusCode(HttpStatus.BAD_REQUEST_400)
                 .type(ErrorResponder.ErrorType.INVALID_ARGUMENT)
                 .message("It has error")
                 .haltError())
             .isInstanceOf(HaltException.class)
-            .matches(e -> hasStatus(e, 400))
-            .matches(e -> bodyHasErrorDetail(e, new ErrorResponder.ErrorDetail(400, "InvalidArgument", "It has error", NO_CAUSE)));
+            .matches(e -> hasStatus(e, HttpStatus.BAD_REQUEST_400))
+            .matches(e -> bodyHasErrorDetail(e, new ErrorResponder.ErrorDetail(HttpStatus.BAD_REQUEST_400, "InvalidArgument", "It has error", NO_CAUSE)));
     }
 
     @Test
     public void haltErrorShouldReturnBodyWithCauseTypeWhenSetting() throws Exception {
         assertThatThrownBy(() -> ErrorResponder.builder()
-                .statusCode(400)
+                .statusCode(HttpStatus.BAD_REQUEST_400)
                 .type(ErrorResponder.ErrorType.INVALID_ARGUMENT)
                 .message("Error")
                 .cause(new IllegalArgumentException("The input data is invalid"))
                 .haltError())
             .isInstanceOf(HaltException.class)
-            .matches(e -> hasStatus(e, 400))
-            .matches(e -> bodyHasErrorDetail(e, new ErrorResponder.ErrorDetail(400, "InvalidArgument", "Error", Optional.of("The input data is invalid"))));
+            .matches(e -> hasStatus(e, HttpStatus.BAD_REQUEST_400))
+            .matches(e -> bodyHasErrorDetail(e, new ErrorResponder.ErrorDetail(HttpStatus.BAD_REQUEST_400, "InvalidArgument", "Error", Optional.of("The input data is invalid"))));
     }
 
     @Test
     public void haltErrorShouldReturnBodyWithErrorDetail() throws Exception {
         assertThatThrownBy(() -> ErrorResponder.builder()
-                .statusCode(400)
+                .statusCode(HttpStatus.BAD_REQUEST_400)
                 .type(ErrorResponder.ErrorType.INVALID_ARGUMENT)
                 .message("Error")
                 .cause(new IllegalArgumentException("The input data is invalid"))
             .haltError())
             .isInstanceOf(HaltException.class)
-            .matches(e -> hasStatus(e, 400))
-            .matches(e -> bodyHasErrorDetail(e, new ErrorResponder.ErrorDetail(400, "InvalidArgument", "Error", Optional.of("The input data is invalid"))));
+            .matches(e -> hasStatus(e, HttpStatus.BAD_REQUEST_400))
+            .matches(e -> bodyHasErrorDetail(e, new ErrorResponder.ErrorDetail(HttpStatus.BAD_REQUEST_400, "InvalidArgument", "Error", Optional.of("The input data is invalid"))));
     }
 
     private boolean hasStatus(Throwable throwable, int status) {

http://git-wip-us.apache.org/repos/asf/james-project/blob/21188d00/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/DomainsRoutes.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/DomainsRoutes.java b/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/DomainsRoutes.java
index 0864a8a..8438279 100644
--- a/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/DomainsRoutes.java
+++ b/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/DomainsRoutes.java
@@ -97,8 +97,9 @@ public class DomainsRoutes implements Routes {
             @ApiImplicitParam(required = true, dataType = "string", name = "domainName", paramType = "path")
     })
     @ApiResponses(value = {
-            @ApiResponse(code = 204, message = "OK. Domain is removed."),
-            @ApiResponse(code = 500, message = "Internal server error - Something went bad on the server side.")
+            @ApiResponse(code = HttpStatus.NO_CONTENT_204, message = "OK. Domain is removed."),
+            @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500,
+                message = "Internal server error - Something went bad on the server side.")
     })
     public void defineDeleteDomain() {
         service.delete(SPECIFIC_DOMAIN, this::removeDomain);
@@ -111,9 +112,10 @@ public class DomainsRoutes implements Routes {
             @ApiImplicitParam(required = true, dataType = "string", name = "domainName", paramType = "path")
     })
     @ApiResponses(value = {
-            @ApiResponse(code = 204, message = "OK. New domain is created."),
-            @ApiResponse(code = 400, message = "Invalid request for domain creation"),
-            @ApiResponse(code = 500, message = "Internal server error - Something went bad on the server side.")
+            @ApiResponse(code = HttpStatus.NO_CONTENT_204, message = "OK. New domain is created."),
+            @ApiResponse(code = HttpStatus.BAD_REQUEST_400, message = "Invalid request for domain creation"),
+            @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500,
+                message = "Internal server error - Something went bad on the server side.")
     })
     public void defineAddDomain() {
         service.put(SPECIFIC_DOMAIN, this::addDomain);
@@ -126,9 +128,10 @@ public class DomainsRoutes implements Routes {
     })
     @ApiOperation(value = "Testing existence of a domain.")
     @ApiResponses(value = {
-            @ApiResponse(code = 204, message = "The domain exists", response = String.class),
-            @ApiResponse(code = 404, message = "The domain does not exist."),
-            @ApiResponse(code = 500, message = "Internal server error - Something went bad on the server side.")
+            @ApiResponse(code = HttpStatus.NO_CONTENT_204, message = "The domain exists", response = String.class),
+            @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "The domain does not exist."),
+            @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500,
+                message = "Internal server error - Something went bad on the server side.")
     })
     public void defineDomainExists() {
         service.get(SPECIFIC_DOMAIN, this::exists);
@@ -137,8 +140,9 @@ public class DomainsRoutes implements Routes {
     @GET
     @ApiOperation(value = "Getting all domains")
     @ApiResponses(value = {
-            @ApiResponse(code = 204, message = "OK", response = List.class),
-            @ApiResponse(code = 500, message = "Internal server error - Something went bad on the server side.")
+            @ApiResponse(code = HttpStatus.NO_CONTENT_204, message = "OK", response = List.class),
+            @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500,
+                message = "Internal server error - Something went bad on the server side.")
     })
     public void defineGetDomains() {
         service.get(DOMAINS,
@@ -153,7 +157,7 @@ public class DomainsRoutes implements Routes {
         } catch (DomainListException e) {
             LOGGER.info("{} did not exists", request.params(DOMAIN_NAME));
         }
-        response.status(204);
+        response.status(HttpStatus.NO_CONTENT_204);
         return Constants.EMPTY_BODY;
     }
 
@@ -203,7 +207,7 @@ public class DomainsRoutes implements Routes {
                 .message("The domain list does not contain: " + domainName)
                 .haltError();
         } else {
-            response.status(204);
+            response.status(HttpStatus.NO_CONTENT_204);
         }
         return Constants.EMPTY_BODY;
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/21188d00/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/GroupsRoutes.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/GroupsRoutes.java b/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/GroupsRoutes.java
index b2c6399..63ec39a 100644
--- a/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/GroupsRoutes.java
+++ b/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/GroupsRoutes.java
@@ -117,8 +117,9 @@ public class GroupsRoutes implements Routes {
     @Path(ROOT_PATH)
     @ApiOperation(value = "getting groups list")
     @ApiResponses(value = {
-        @ApiResponse(code = 200, message = "OK", response = List.class),
-        @ApiResponse(code = 500, message = "Internal server error - Something went bad on the server side.")
+        @ApiResponse(code = HttpStatus.OK_200, message = "OK", response = List.class),
+        @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500,
+            message = "Internal server error - Something went bad on the server side.")
     })
     public Set<String> listGroups(Request request, Response response) throws RecipientRewriteTableException {
         return Optional.ofNullable(recipientRewriteTable.getAllMappings())
@@ -143,11 +144,12 @@ public class GroupsRoutes implements Routes {
                 MAILADDRESS_ASCII_DISCLAIMER)
     })
     @ApiResponses(value = {
-        @ApiResponse(code = 200, message = "OK", response = List.class),
-        @ApiResponse(code = 400, message = GROUP_ADDRESS + " or group structure format is not valid"),
-        @ApiResponse(code = 403, message = "server doesn't own the domain"),
-        @ApiResponse(code = 409, message = "requested group address is already used for another purpose"),
-        @ApiResponse(code = 500, message = "Internal server error - Something went bad on the server side.")
+        @ApiResponse(code = HttpStatus.OK_200, message = "OK", response = List.class),
+        @ApiResponse(code = HttpStatus.BAD_REQUEST_400, message = GROUP_ADDRESS + " or group structure format is not valid"),
+        @ApiResponse(code = HttpStatus.FORBIDDEN_403, message = "server doesn't own the domain"),
+        @ApiResponse(code = HttpStatus.CONFLICT_409, message = "requested group address is already used for another purpose"),
+        @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500,
+            message = "Internal server error - Something went bad on the server side.")
     })
     public HaltException addToGroup(Request request, Response response) throws JsonExtractException, AddressException, RecipientRewriteTableException, UsersRepositoryException, DomainListException {
         MailAddress groupAddress = parseMailAddress(request.params(GROUP_ADDRESS));
@@ -187,9 +189,11 @@ public class GroupsRoutes implements Routes {
         @ApiImplicitParam(required = true, dataType = "string", name = USER_ADDRESS, paramType = "path")
     })
     @ApiResponses(value = {
-        @ApiResponse(code = 200, message = "OK", response = List.class),
-        @ApiResponse(code = 400, message = GROUP_ADDRESS + " or group structure format is not valid"),
-        @ApiResponse(code = 500, message = "Internal server error - Something went bad on the server side.")
+        @ApiResponse(code = HttpStatus.OK_200, message = "OK", response = List.class),
+        @ApiResponse(code = HttpStatus.BAD_REQUEST_400,
+            message = GROUP_ADDRESS + " or group structure format is not valid"),
+        @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500,
+            message = "Internal server error - Something went bad on the server side.")
     })
     public HaltException removeFromGroup(Request request, Response response) throws JsonExtractException, AddressException, RecipientRewriteTableException {
         MailAddress groupAddress = parseMailAddress(request.params(GROUP_ADDRESS));
@@ -205,10 +209,11 @@ public class GroupsRoutes implements Routes {
         @ApiImplicitParam(required = true, dataType = "string", name = GROUP_ADDRESS, paramType = "path")
     })
     @ApiResponses(value = {
-        @ApiResponse(code = 200, message = "OK", response = List.class),
-        @ApiResponse(code = 400, message = "The group is not an address"),
-        @ApiResponse(code = 404, message = "The group does not exist"),
-        @ApiResponse(code = 500, message = "Internal server error - Something went bad on the server side.")
+        @ApiResponse(code = HttpStatus.OK_200, message = "OK", response = List.class),
+        @ApiResponse(code = HttpStatus.BAD_REQUEST_400, message = "The group is not an address"),
+        @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "The group does not exist"),
+        @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500,
+            message = "Internal server error - Something went bad on the server side.")
     })
     public ImmutableSortedSet<String> listGroupMembers(Request request, Response response) throws RecipientRewriteTable.ErrorMappingException, RecipientRewriteTableException {
         MailAddress groupAddress = parseMailAddress(request.params(GROUP_ADDRESS));

http://git-wip-us.apache.org/repos/asf/james-project/blob/21188d00/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/UserRoutes.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/UserRoutes.java b/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/UserRoutes.java
index e540d96..dc16425 100644
--- a/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/UserRoutes.java
+++ b/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/UserRoutes.java
@@ -94,9 +94,10 @@ public class UserRoutes implements Routes {
             @ApiImplicitParam(required = true, dataType = "string", name = "username", paramType = "path")
     })
     @ApiResponses(value = {
-            @ApiResponse(code = 204, message = "OK. User is removed."),
-            @ApiResponse(code = 400, message = "Invalid input user."),
-            @ApiResponse(code = 500, message = "Internal server error - Something went bad on the server side.")
+            @ApiResponse(code = HttpStatus.NO_CONTENT_204, message = "OK. User is removed."),
+            @ApiResponse(code = HttpStatus.BAD_REQUEST_400, message = "Invalid input user."),
+            @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500,
+                message = "Internal server error - Something went bad on the server side.")
     })
     public void defineDeleteUser() {
         service.delete(USERS + SEPARATOR + USER_NAME, this::removeUser);
@@ -110,9 +111,10 @@ public class UserRoutes implements Routes {
             @ApiImplicitParam(required = true, dataType = "org.apache.james.webadmin.dto.AddUserRequest", paramType = "body")
     })
     @ApiResponses(value = {
-            @ApiResponse(code = 204, message = "OK. New user is added."),
-            @ApiResponse(code = 400, message = "Invalid input user."),
-            @ApiResponse(code = 500, message = "Internal server error - Something went bad on the server side.")
+            @ApiResponse(code = HttpStatus.NO_CONTENT_204, message = "OK. New user is added."),
+            @ApiResponse(code = HttpStatus.BAD_REQUEST_400, message = "Invalid input user."),
+            @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500,
+                message = "Internal server error - Something went bad on the server side.")
     })
     public void defineCreateUser() {
         service.put(USERS + SEPARATOR + USER_NAME, this::upsertUser);
@@ -121,8 +123,9 @@ public class UserRoutes implements Routes {
     @GET
     @ApiOperation(value = "Getting all users")
     @ApiResponses(value = {
-            @ApiResponse(code = 204, message = "OK.", response = UserResponse.class),
-            @ApiResponse(code = 500, message = "Internal server error - Something went bad on the server side.")
+            @ApiResponse(code = HttpStatus.NO_CONTENT_204, message = "OK.", response = UserResponse.class),
+            @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500,
+                message = "Internal server error - Something went bad on the server side.")
     })
     public void defineGetUsers() {
         service.get(USERS,
@@ -134,7 +137,7 @@ public class UserRoutes implements Routes {
         String username = request.params(USER_NAME);
         try {
             userService.removeUser(username);
-            response.status(204);
+            response.status(HttpStatus.NO_CONTENT_204);
             return Constants.EMPTY_BODY;
         } catch (UsersRepositoryException e) {
             throw ErrorResponder.builder()

http://git-wip-us.apache.org/repos/asf/james-project/blob/21188d00/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/service/UserService.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/service/UserService.java b/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/service/UserService.java
index ee0952d..3b09e4b 100644
--- a/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/service/UserService.java
+++ b/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/service/UserService.java
@@ -30,6 +30,7 @@ import org.apache.james.user.api.UsersRepositoryException;
 import org.apache.james.user.api.model.User;
 import org.apache.james.util.streams.Iterators;
 import org.apache.james.webadmin.dto.UserResponse;
+import org.eclipse.jetty.http.HttpStatus;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -70,10 +71,10 @@ public class UserService {
         User user = usersRepository.getUserByName(username);
         try {
             upsert(user, username, password);
-            response.status(204);
+            response.status(HttpStatus.NO_CONTENT_204);
         } catch (UsersRepositoryException e) {
             LOGGER.info("Error creating or updating user : {}", e.getMessage());
-            response.status(409);
+            response.status(HttpStatus.CONFLICT_409);
         }
         return EMPTY_BODY;
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/21188d00/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/DomainsRoutesTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/DomainsRoutesTest.java b/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/DomainsRoutesTest.java
index a403b5c..1de056d 100644
--- a/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/DomainsRoutesTest.java
+++ b/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/DomainsRoutesTest.java
@@ -27,8 +27,6 @@ import static com.jayway.restassured.config.RestAssuredConfig.newConfig;
 import static org.apache.james.webadmin.Constants.SEPARATOR;
 import static org.apache.james.webadmin.WebAdminServer.NO_CONFIGURATION;
 import static org.assertj.core.api.Assertions.assertThat;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.startsWith;
 import static org.mockito.Matchers.any;
 import static org.mockito.Mockito.doThrow;
 import static org.mockito.Mockito.mock;
@@ -47,6 +45,7 @@ import org.apache.james.metrics.logger.DefaultMetricFactory;
 import org.apache.james.webadmin.WebAdminServer;
 import org.apache.james.webadmin.WebAdminUtils;
 import org.apache.james.webadmin.utils.JsonTransformer;
+import org.eclipse.jetty.http.HttpStatus;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -105,7 +104,7 @@ public class DomainsRoutesTest {
                 given()
                     .get()
                 .then()
-                    .statusCode(200)
+                    .statusCode(HttpStatus.OK_200)
                     .contentType(ContentType.JSON)
                     .extract()
                     .body()
@@ -120,7 +119,7 @@ public class DomainsRoutesTest {
             given()
                 .put(SEPARATOR)
             .then()
-                .statusCode(404);
+                .statusCode(HttpStatus.NOT_FOUND_404);
         }
 
         @Test
@@ -128,7 +127,7 @@ public class DomainsRoutesTest {
             given()
                 .delete(SEPARATOR)
             .then()
-                .statusCode(404);
+                .statusCode(HttpStatus.NOT_FOUND_404);
         }
 
         @Test
@@ -136,7 +135,7 @@ public class DomainsRoutesTest {
             given()
                 .put(DOMAIN)
             .then()
-                .statusCode(204);
+                .statusCode(HttpStatus.NO_CONTENT_204);
         }
 
         @Test
@@ -149,7 +148,7 @@ public class DomainsRoutesTest {
                     .get()
                 .then()
                     .contentType(ContentType.JSON)
-                    .statusCode(200)
+                    .statusCode(HttpStatus.OK_200)
                     .extract()
                     .body()
                     .jsonPath()
@@ -163,7 +162,7 @@ public class DomainsRoutesTest {
             Map<String, Object> errors = when()
                 .put(DOMAIN + "@" + DOMAIN)
             .then()
-                .statusCode(400)
+                .statusCode(HttpStatus.BAD_REQUEST_400)
                 .contentType(ContentType.JSON)
                 .extract()
                 .body()
@@ -171,7 +170,7 @@ public class DomainsRoutesTest {
                 .getMap(".");
 
             assertThat(errors)
-                .containsEntry("statusCode", 400)
+                .containsEntry("statusCode", HttpStatus.BAD_REQUEST_400)
                 .containsEntry("type", "InvalidArgument")
                 .containsEntry("message", "Invalid request for domain creation domain@domain");
         }
@@ -181,7 +180,7 @@ public class DomainsRoutesTest {
             when()
                 .put(DOMAIN + "/" + DOMAIN)
             .then()
-                .statusCode(404);
+                .statusCode(HttpStatus.NOT_FOUND_404);
         }
 
         @Test
@@ -191,7 +190,7 @@ public class DomainsRoutesTest {
                     "0123456789.0123456789.0123456789.0123456789.0123456789.0123456789.0123456789.0123456789.0123456789.0123456789." +
                     "0123456789.0123456789.0123456789.")
             .then()
-                .statusCode(400)
+                .statusCode(HttpStatus.BAD_REQUEST_400)
                 .contentType(ContentType.JSON)
                 .extract()
                 .body()
@@ -199,7 +198,7 @@ public class DomainsRoutesTest {
                 .getMap(".");
 
             assertThat(errors)
-                .containsEntry("statusCode", 400)
+                .containsEntry("statusCode", HttpStatus.BAD_REQUEST_400)
                 .containsEntry("type", "InvalidArgument");
         }
 
@@ -211,7 +210,7 @@ public class DomainsRoutesTest {
             when()
                 .put(DOMAIN)
             .then()
-                .statusCode(204);
+                .statusCode(HttpStatus.NO_CONTENT_204);
         }
 
         @Test
@@ -222,14 +221,14 @@ public class DomainsRoutesTest {
             when()
                 .delete(DOMAIN)
             .then()
-                .statusCode(204);
+                .statusCode(HttpStatus.NO_CONTENT_204);
 
             List<String> domains =
                 when()
                     .get()
                 .then()
                     .contentType(ContentType.JSON)
-                    .statusCode(200)
+                    .statusCode(HttpStatus.OK_200)
                     .extract()
                     .body()
                     .jsonPath()
@@ -243,7 +242,7 @@ public class DomainsRoutesTest {
             given()
                 .delete(DOMAIN)
             .then()
-                .statusCode(204);
+                .statusCode(HttpStatus.NO_CONTENT_204);
         }
 
         @Test
@@ -254,7 +253,7 @@ public class DomainsRoutesTest {
             when()
                 .get(DOMAIN)
             .then()
-                .statusCode(204);
+                .statusCode(HttpStatus.NO_CONTENT_204);
         }
 
         @Test
@@ -262,7 +261,7 @@ public class DomainsRoutesTest {
             given()
                 .get(DOMAIN)
             .then()
-                .statusCode(404);
+                .statusCode(HttpStatus.NOT_FOUND_404);
         }
 
     }
@@ -286,7 +285,7 @@ public class DomainsRoutesTest {
             when()
                 .delete(DOMAIN)
             .then()
-                .statusCode(500);
+                .statusCode(HttpStatus.INTERNAL_SERVER_ERROR_500);
         }
 
         @Test
@@ -296,7 +295,7 @@ public class DomainsRoutesTest {
             when()
                 .put(DOMAIN)
             .then()
-                .statusCode(500);
+                .statusCode(HttpStatus.INTERNAL_SERVER_ERROR_500);
         }
 
         @Test
@@ -306,7 +305,7 @@ public class DomainsRoutesTest {
             when()
                 .get(DOMAIN)
             .then()
-                .statusCode(500);
+                .statusCode(HttpStatus.INTERNAL_SERVER_ERROR_500);
         }
 
         @Test
@@ -316,7 +315,7 @@ public class DomainsRoutesTest {
             when()
                 .get()
             .then()
-                .statusCode(500);
+                .statusCode(HttpStatus.INTERNAL_SERVER_ERROR_500);
         }
 
         @Test
@@ -326,7 +325,7 @@ public class DomainsRoutesTest {
             when()
                 .delete(DOMAIN)
             .then()
-                .statusCode(204);
+                .statusCode(HttpStatus.NO_CONTENT_204);
         }
 
         @Test
@@ -336,7 +335,7 @@ public class DomainsRoutesTest {
             when()
                 .put(DOMAIN)
             .then()
-                .statusCode(204);
+                .statusCode(HttpStatus.NO_CONTENT_204);
         }
 
         @Test
@@ -346,7 +345,7 @@ public class DomainsRoutesTest {
             when()
                 .get(DOMAIN)
             .then()
-                .statusCode(500);
+                .statusCode(HttpStatus.INTERNAL_SERVER_ERROR_500);
         }
 
         @Test
@@ -356,7 +355,7 @@ public class DomainsRoutesTest {
             when()
                 .get()
             .then()
-                .statusCode(500);
+                .statusCode(HttpStatus.INTERNAL_SERVER_ERROR_500);
         }
 
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/21188d00/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/GroupsRoutesTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/GroupsRoutesTest.java b/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/GroupsRoutesTest.java
index ff357e8..a0eae10 100644
--- a/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/GroupsRoutesTest.java
+++ b/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/GroupsRoutesTest.java
@@ -162,7 +162,7 @@ public class GroupsRoutesTest {
                 .getMap(".");
 
             assertThat(errors)
-                .containsEntry("statusCode", 404)
+                .containsEntry("statusCode", HttpStatus.NOT_FOUND_404)
                 .containsEntry("type", "InvalidArgument")
                 .containsEntry("message", "The group does not exist");
         }
@@ -300,7 +300,7 @@ public class GroupsRoutesTest {
                 .getMap(".");
 
             assertThat(errors)
-                .containsEntry("statusCode", 403)
+                .containsEntry("statusCode", HttpStatus.FORBIDDEN_403)
                 .containsEntry("type", "InvalidArgument")
                 .containsEntry("message", "Server doesn't own the domain: unregisteredDomain");
         }
@@ -321,7 +321,7 @@ public class GroupsRoutesTest {
                 .getMap(".");
 
             assertThat(errors)
-                .containsEntry("statusCode", 409)
+                .containsEntry("statusCode", HttpStatus.CONFLICT_409)
                 .containsEntry("type", "InvalidArgument")
                 .containsEntry("message", "Requested group address is already used for another purpose");
         }
@@ -412,7 +412,7 @@ public class GroupsRoutesTest {
                 .getMap(".");
 
             assertThat(errors)
-                .containsEntry("statusCode", 400)
+                .containsEntry("statusCode", HttpStatus.BAD_REQUEST_400)
                 .containsEntry("type", "InvalidArgument")
                 .containsEntry("message", "The group is not an email address")
                 .containsEntry("cause", "Out of data at position 1 in 'not-an-address'");
@@ -431,7 +431,7 @@ public class GroupsRoutesTest {
                 .getMap(".");
 
             assertThat(errors)
-                .containsEntry("statusCode", 400)
+                .containsEntry("statusCode", HttpStatus.BAD_REQUEST_400)
                 .containsEntry("type", "InvalidArgument")
                 .containsEntry("message", "The group is not an email address")
                 .containsEntry("cause", "Out of data at position 1 in 'not-an-address'");
@@ -468,7 +468,7 @@ public class GroupsRoutesTest {
                 .getMap(".");
 
             assertThat(errors)
-                .containsEntry("statusCode", 400)
+                .containsEntry("statusCode", HttpStatus.BAD_REQUEST_400)
                 .containsEntry("type", "InvalidArgument")
                 .containsEntry("message", "The group is not an email address")
                 .containsEntry("cause", "Out of data at position 1 in 'not-an-address'");
@@ -496,7 +496,7 @@ public class GroupsRoutesTest {
                 .getMap(".");
 
             assertThat(errors)
-                .containsEntry("statusCode", 400)
+                .containsEntry("statusCode", HttpStatus.BAD_REQUEST_400)
                 .containsEntry("type", "InvalidArgument")
                 .containsEntry("message", "The group is not an email address")
                 .containsEntry("cause", "Out of data at position 1 in 'not-an-address'");
@@ -515,7 +515,7 @@ public class GroupsRoutesTest {
                 .getMap(".");
 
             assertThat(errors)
-                .containsEntry("statusCode", 400)
+                .containsEntry("statusCode", HttpStatus.BAD_REQUEST_400)
                 .containsEntry("type", "InvalidArgument")
                 .containsEntry("message", "The group is not an email address")
                 .containsEntry("cause", "Out of data at position 1 in 'not-an-address'");

http://git-wip-us.apache.org/repos/asf/james-project/blob/21188d00/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/UsersRoutesTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/UsersRoutesTest.java b/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/UsersRoutesTest.java
index a073b57..c2874db 100644
--- a/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/UsersRoutesTest.java
+++ b/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/UsersRoutesTest.java
@@ -45,6 +45,7 @@ import org.apache.james.webadmin.WebAdminServer;
 import org.apache.james.webadmin.WebAdminUtils;
 import org.apache.james.webadmin.service.UserService;
 import org.apache.james.webadmin.utils.JsonTransformer;
+import org.eclipse.jetty.http.HttpStatus;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -104,7 +105,7 @@ public class UsersRoutesTest {
                 when()
                     .get()
                 .then()
-                    .statusCode(200)
+                    .statusCode(HttpStatus.OK_200)
                     .contentType(ContentType.JSON)
                     .extract()
                     .body()
@@ -119,7 +120,7 @@ public class UsersRoutesTest {
             when()
                 .put(USERNAME)
             .then()
-                .statusCode(400);
+                .statusCode(HttpStatus.BAD_REQUEST_400);
         }
 
         @Test
@@ -129,7 +130,7 @@ public class UsersRoutesTest {
             .when()
                 .put(USERNAME)
             .then()
-                .statusCode(400);
+                .statusCode(HttpStatus.BAD_REQUEST_400);
         }
 
         @Test
@@ -139,7 +140,7 @@ public class UsersRoutesTest {
             .when()
                 .put(USERNAME)
             .then()
-                .statusCode(400);
+                .statusCode(HttpStatus.BAD_REQUEST_400);
         }
 
         @Test
@@ -149,7 +150,7 @@ public class UsersRoutesTest {
             .when()
                 .put(USERNAME)
             .then()
-                .statusCode(204);
+                .statusCode(HttpStatus.NO_CONTENT_204);
         }
 
         @Test
@@ -159,7 +160,7 @@ public class UsersRoutesTest {
             .when()
                 .put(USERNAME)
             .then()
-                .statusCode(400);
+                .statusCode(HttpStatus.BAD_REQUEST_400);
         }
 
         @Test
@@ -172,7 +173,7 @@ public class UsersRoutesTest {
                 when()
                     .get()
                 .then()
-                    .statusCode(200)
+                    .statusCode(HttpStatus.OK_200)
                     .contentType(ContentType.JSON)
                     .extract()
                     .body()
@@ -195,14 +196,14 @@ public class UsersRoutesTest {
             .when()
                 .put(USERNAME)
             .then()
-                .statusCode(204);
+                .statusCode(HttpStatus.NO_CONTENT_204);
 
             // Then
             List<Map<String, String>> users =
                 when()
                     .get()
                 .then()
-                    .statusCode(200)
+                    .statusCode(HttpStatus.OK_200)
                     .contentType(ContentType.JSON)
                     .extract()
                     .body()
@@ -217,7 +218,7 @@ public class UsersRoutesTest {
             when()
                 .delete(USERNAME)
             .then()
-                .statusCode(204);
+                .statusCode(HttpStatus.NO_CONTENT_204);
         }
 
         @Test
@@ -225,7 +226,7 @@ public class UsersRoutesTest {
             when()
                 .delete("/")
             .then()
-                .statusCode(404);
+                .statusCode(HttpStatus.NOT_FOUND_404);
         }
 
         @Test
@@ -235,7 +236,7 @@ public class UsersRoutesTest {
                     "0123456789.0123456789.0123456789.0123456789.0123456789.0123456789.0123456789.0123456789.0123456789.0123456789." +
                     "0123456789.0123456789.0123456789.")
             .then()
-                .statusCode(400);
+                .statusCode(HttpStatus.BAD_REQUEST_400);
         }
 
         @Test
@@ -245,7 +246,7 @@ public class UsersRoutesTest {
             .when()
                 .put(USERNAME + "/" + USERNAME)
             .then()
-                .statusCode(404);
+                .statusCode(HttpStatus.NOT_FOUND_404);
         }
 
         @Test
@@ -255,7 +256,7 @@ public class UsersRoutesTest {
             .when()
                 .put("/")
             .then()
-                .statusCode(404);
+                .statusCode(HttpStatus.NOT_FOUND_404);
         }
 
         @Test
@@ -267,7 +268,7 @@ public class UsersRoutesTest {
                     "0123456789.0123456789.0123456789.0123456789.0123456789.0123456789.0123456789.0123456789.0123456789.0123456789." +
                     "0123456789.0123456789.0123456789.")
             .then()
-                .statusCode(400);
+                .statusCode(HttpStatus.BAD_REQUEST_400);
         }
 
         @Test
@@ -277,7 +278,7 @@ public class UsersRoutesTest {
             .when()
                 .put(USERNAME + "/" + USERNAME)
             .then()
-                .statusCode(404);
+                .statusCode(HttpStatus.NOT_FOUND_404);
         }
 
         @Test
@@ -291,14 +292,14 @@ public class UsersRoutesTest {
             when()
                 .delete(USERNAME)
             .then()
-                .statusCode(204);
+                .statusCode(HttpStatus.NO_CONTENT_204);
 
             // Then
             List<Map<String, String>> users =
                 when()
                     .get()
                 .then()
-                    .statusCode(200)
+                    .statusCode(HttpStatus.OK_200)
                     .contentType(ContentType.JSON)
                     .extract()
                     .body()
@@ -315,7 +316,7 @@ public class UsersRoutesTest {
             .when()
                 .delete(USERNAME)
             .then()
-                .statusCode(204);
+                .statusCode(HttpStatus.NO_CONTENT_204);
         }
     }
 
@@ -340,7 +341,7 @@ public class UsersRoutesTest {
             when()
                 .delete(USERNAME)
             .then()
-                .statusCode(204);
+                .statusCode(HttpStatus.NO_CONTENT_204);
         }
 
         @Test
@@ -350,7 +351,7 @@ public class UsersRoutesTest {
             when()
                 .get()
             .then()
-                .statusCode(500);
+                .statusCode(HttpStatus.INTERNAL_SERVER_ERROR_500);
         }
 
         @Test
@@ -362,7 +363,7 @@ public class UsersRoutesTest {
             .when()
                 .put(USERNAME)
             .then()
-                .statusCode(500);
+                .statusCode(HttpStatus.INTERNAL_SERVER_ERROR_500);
         }
 
         @Test
@@ -375,7 +376,7 @@ public class UsersRoutesTest {
             .when()
                 .put(USERNAME)
             .then()
-                .statusCode(409);
+                .statusCode(HttpStatus.CONFLICT_409);
         }
 
         @Test
@@ -388,7 +389,7 @@ public class UsersRoutesTest {
             .when()
                 .put(USERNAME)
             .then()
-                .statusCode(409);
+                .statusCode(HttpStatus.CONFLICT_409);
         }
 
 
@@ -399,7 +400,7 @@ public class UsersRoutesTest {
             when()
                 .delete(USERNAME)
             .then()
-                .statusCode(500);
+                .statusCode(HttpStatus.INTERNAL_SERVER_ERROR_500);
         }
 
         @Test
@@ -409,7 +410,7 @@ public class UsersRoutesTest {
             when()
                 .get()
             .then()
-                .statusCode(500);
+                .statusCode(HttpStatus.INTERNAL_SERVER_ERROR_500);
         }
 
         @Test
@@ -421,7 +422,7 @@ public class UsersRoutesTest {
             .when()
                 .put(USERNAME)
             .then()
-                .statusCode(500);
+                .statusCode(HttpStatus.INTERNAL_SERVER_ERROR_500);
         }
 
         @Test
@@ -434,7 +435,7 @@ public class UsersRoutesTest {
             .when()
                 .put(USERNAME)
             .then()
-                .statusCode(500);
+                .statusCode(HttpStatus.INTERNAL_SERVER_ERROR_500);
         }
 
         @Test
@@ -447,7 +448,7 @@ public class UsersRoutesTest {
             .when()
                 .put(USERNAME)
             .then()
-                .statusCode(500);
+                .statusCode(HttpStatus.INTERNAL_SERVER_ERROR_500);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/21188d00/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/routes/GlobalQuotaRoutes.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/routes/GlobalQuotaRoutes.java b/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/routes/GlobalQuotaRoutes.java
index a45bff2..0c97839 100644
--- a/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/routes/GlobalQuotaRoutes.java
+++ b/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/routes/GlobalQuotaRoutes.java
@@ -19,8 +19,6 @@
 
 package org.apache.james.webadmin.routes;
 
-import static spark.Spark.halt;
-
 import javax.inject.Inject;
 import javax.ws.rs.DELETE;
 import javax.ws.rs.GET;
@@ -100,9 +98,9 @@ public class GlobalQuotaRoutes implements Routes {
             @ApiImplicitParam(required = true, dataType = "org.apache.james.webadmin.dto.QuotaDTO", paramType = "body")
     })
     @ApiResponses(value = {
-            @ApiResponse(code = 204, message = "OK. The value has been updated."),
-            @ApiResponse(code = 400, message = "The body is not a positive integer or not unlimited value (-1)."),
-            @ApiResponse(code = 500, message = "Internal server error - Something went bad on the server side.")
+            @ApiResponse(code = HttpStatus.NO_CONTENT_204, message = "OK. The value has been updated."),
+            @ApiResponse(code = HttpStatus.BAD_REQUEST_400, message = "The body is not a positive integer or not unlimited value (-1)."),
+            @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "Internal server error - Something went bad on the server side.")
     })
     public void defineUpdateQuota() {
         service.put(QUOTA_ENDPOINT, ((request, response) -> {
@@ -110,7 +108,7 @@ public class GlobalQuotaRoutes implements Routes {
                 QuotaDTO quotaDTO = jsonExtractor.parse(request.body());
                 maxQuotaManager.setDefaultMaxMessage(quotaDTO.getCount());
                 maxQuotaManager.setDefaultMaxStorage(quotaDTO.getSize());
-                response.status(204);
+                response.status(HttpStatus.NO_CONTENT_204);
             } catch (JsonExtractException e) {
                 LOGGER.info("Malformed JSON", e);
                 throw ErrorResponder.builder()
@@ -138,15 +136,15 @@ public class GlobalQuotaRoutes implements Routes {
         notes = "If there is no limitation for count and/or size, the returned value will be -1"
 	)
     @ApiResponses(value = {
-            @ApiResponse(code = 200, message = "OK", response = QuotaDTO.class),
-            @ApiResponse(code = 500, message = "Internal server error - Something went bad on the server side.")
+            @ApiResponse(code = HttpStatus.OK_200, message = "OK", response = QuotaDTO.class),
+            @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "Internal server error - Something went bad on the server side.")
     })
     public void defineGetQuota() {
         service.get(QUOTA_ENDPOINT, (request, response) -> {
             QuotaDTO quotaDTO = QuotaDTO.builder()
                 .count(maxQuotaManager.getDefaultMaxMessage())
                 .size(maxQuotaManager.getDefaultMaxStorage()).build();
-            response.status(200);
+            response.status(HttpStatus.OK_200);
             return quotaDTO;
         }, jsonTransformer);
     }
@@ -155,13 +153,13 @@ public class GlobalQuotaRoutes implements Routes {
     @Path("/size")
     @ApiOperation(value = "Removing per quotaroot mail size limitation by updating to unlimited value")
     @ApiResponses(value = {
-            @ApiResponse(code = 204, message = "The value is updated to unlimited value."),
-            @ApiResponse(code = 500, message = "Internal server error - Something went bad on the server side.")
+            @ApiResponse(code = HttpStatus.NO_CONTENT_204, message = "The value is updated to unlimited value."),
+            @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "Internal server error - Something went bad on the server side.")
     })
     public void defineDeleteQuotaSize() {
         service.delete(SIZE_ENDPOINT, (request, response) -> {
             maxQuotaManager.setDefaultMaxStorage(Quota.UNLIMITED);
-            response.status(204);
+            response.status(HttpStatus.NO_CONTENT_204);
             return Constants.EMPTY_BODY;
         });
     }
@@ -173,16 +171,16 @@ public class GlobalQuotaRoutes implements Routes {
             @ApiImplicitParam(required = true, dataType = "integer", paramType = "body")
     })
     @ApiResponses(value = {
-            @ApiResponse(code = 204, message = "OK. The value has been updated."),
-            @ApiResponse(code = 400, message = "The body is not a positive integer."),
-            @ApiResponse(code = 500, message = "Internal server error - Something went bad on the server side.")
+            @ApiResponse(code = HttpStatus.NO_CONTENT_204, message = "OK. The value has been updated."),
+            @ApiResponse(code = HttpStatus.BAD_REQUEST_400, message = "The body is not a positive integer."),
+            @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "Internal server error - Something went bad on the server side.")
     })
     public void defineUpdateQuotaSize() {
         service.put(SIZE_ENDPOINT, (request, response) -> {
             try {
                 QuotaRequest quotaRequest = QuotaRequest.parse(request.body());
                 maxQuotaManager.setDefaultMaxStorage(quotaRequest.getValue());
-                response.status(204);
+                response.status(HttpStatus.NO_CONTENT_204);
             } catch (IllegalArgumentException e) {
                 LOGGER.info("Invalid quota. Need to be an integer value greater than 0");
                 throw ErrorResponder.builder()
@@ -200,13 +198,13 @@ public class GlobalQuotaRoutes implements Routes {
     @Path("/size")
     @ApiOperation(value = "Reading per quotaroot mail size limitation")
     @ApiResponses(value = {
-            @ApiResponse(code = 200, message = "OK", response = Long.class),
-            @ApiResponse(code = 500, message = "Internal server error - Something went bad on the server side.")
+            @ApiResponse(code = HttpStatus.OK_200, message = "OK", response = Long.class),
+            @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "Internal server error - Something went bad on the server side.")
     })
     public void defineGetQuotaSize() {
         service.get(SIZE_ENDPOINT, (request, response) -> {
             long value = maxQuotaManager.getDefaultMaxStorage();
-            response.status(200);
+            response.status(HttpStatus.OK_200);
             return value;
         }, jsonTransformer);
     }
@@ -215,13 +213,13 @@ public class GlobalQuotaRoutes implements Routes {
     @Path("/count")
     @ApiOperation(value = "Removing per quotaroot mail count limitation by updating to unlimited value")
     @ApiResponses(value = {
-            @ApiResponse(code = 204, message = "The value is updated to unlimited value."),
-            @ApiResponse(code = 500, message = "Internal server error - Something went bad on the server side.")
+            @ApiResponse(code = HttpStatus.NO_CONTENT_204, message = "The value is updated to unlimited value."),
+            @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "Internal server error - Something went bad on the server side.")
     })
     public void defineDeleteQuotaCount() {
         service.delete(COUNT_ENDPOINT, (request, response) -> {
             maxQuotaManager.setDefaultMaxMessage(Quota.UNLIMITED);
-            response.status(204);
+            response.status(HttpStatus.NO_CONTENT_204);
             return Constants.EMPTY_BODY;
         });
     }
@@ -233,16 +231,16 @@ public class GlobalQuotaRoutes implements Routes {
             @ApiImplicitParam(required = true, dataType = "integer", paramType = "body")
     })
     @ApiResponses(value = {
-            @ApiResponse(code = 204, message = "OK. The value has been updated."),
-            @ApiResponse(code = 400, message = "The body is not a positive integer."),
-            @ApiResponse(code = 500, message = "Internal server error - Something went bad on the server side.")
+            @ApiResponse(code = HttpStatus.NO_CONTENT_204, message = "OK. The value has been updated."),
+            @ApiResponse(code = HttpStatus.BAD_REQUEST_400, message = "The body is not a positive integer."),
+            @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "Internal server error - Something went bad on the server side.")
     })
     public void defineUpdateQuotaCount() {
         service.put(COUNT_ENDPOINT, (request, response) -> {
             try {
                 QuotaRequest quotaRequest = QuotaRequest.parse(request.body());
                 maxQuotaManager.setDefaultMaxMessage(quotaRequest.getValue());
-                response.status(204);
+                response.status(HttpStatus.NO_CONTENT_204);
             } catch (IllegalArgumentException e) {
                 LOGGER.info("Invalid quota. Need to be an integer value greater than 0");
                 throw ErrorResponder.builder()
@@ -260,13 +258,13 @@ public class GlobalQuotaRoutes implements Routes {
     @Path("/count")
     @ApiOperation(value = "Reading per quotaroot mail count limitation")
     @ApiResponses(value = {
-            @ApiResponse(code = 200, message = "OK", response = Long.class),
-            @ApiResponse(code = 500, message = "Internal server error - Something went bad on the server side.")
+            @ApiResponse(code = HttpStatus.OK_200, message = "OK", response = Long.class),
+            @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "Internal server error - Something went bad on the server side.")
     })
     public void defineGetQuotaCount() {
         service.get(COUNT_ENDPOINT, (request, response) -> {
             long value = maxQuotaManager.getDefaultMaxMessage();
-            response.status(200);
+            response.status(HttpStatus.OK_200);
             return value;
         }, jsonTransformer);
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/21188d00/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/routes/UserMailboxesRoutes.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/routes/UserMailboxesRoutes.java b/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/routes/UserMailboxesRoutes.java
index 2867c20..0c3b30c 100644
--- a/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/routes/UserMailboxesRoutes.java
+++ b/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/routes/UserMailboxesRoutes.java
@@ -91,14 +91,14 @@ public class UserMailboxesRoutes implements Routes {
     })
     @ApiOperation(value = "Listing all mailboxes of user.")
     @ApiResponses(value = {
-            @ApiResponse(code = 204, message = "The list of mailboxes", response = String.class),
-            @ApiResponse(code = 401, message = "Unauthorized. The user is not authenticated on the platform", response = String.class),
-            @ApiResponse(code = 404, message = "The user name does not exist."),
-            @ApiResponse(code = 500, message = "Internal server error - Something went bad on the server side.")
+            @ApiResponse(code = HttpStatus.NO_CONTENT_204, message = "The list of mailboxes", response = String.class),
+            @ApiResponse(code = HttpStatus.UNAUTHORIZED_401, message = "Unauthorized. The user is not authenticated on the platform", response = String.class),
+            @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "The user name does not exist."),
+            @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "Internal server error - Something went bad on the server side.")
     })
     public void defineGetUserMailboxes() {
         service.get(USER_MAILBOXES_BASE, (request, response) -> {
-            response.status(200);
+            response.status(HttpStatus.OK_200);
             try {
                 return userMailboxesService.listMailboxes(request.params(USER_NAME));
             } catch (IllegalStateException e) {
@@ -121,17 +121,17 @@ public class UserMailboxesRoutes implements Routes {
     })
     @ApiOperation(value = "Deleting a mailbox and its children")
     @ApiResponses(value = {
-            @ApiResponse(code = 204, message = "The mailbox now does not exist on the server", response = String.class),
-            @ApiResponse(code = 400, message = "Invalid mailbox name"),
-            @ApiResponse(code = 401, message = "Unauthorized. The user is not authenticated on the platform"),
-            @ApiResponse(code = 404, message = "The user name does not exist."),
-            @ApiResponse(code = 500, message = "Internal server error - Something went bad on the server side.")
+            @ApiResponse(code = HttpStatus.NO_CONTENT_204, message = "The mailbox now does not exist on the server", response = String.class),
+            @ApiResponse(code = HttpStatus.BAD_REQUEST_400, message = "Invalid mailbox name"),
+            @ApiResponse(code = HttpStatus.UNAUTHORIZED_401, message = "Unauthorized. The user is not authenticated on the platform"),
+            @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "The user name does not exist."),
+            @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "Internal server error - Something went bad on the server side.")
     })
     public void defineDeleteUserMailbox() {
         service.delete(SPECIFIC_MAILBOX, (request, response) -> {
             try {
                 userMailboxesService.deleteMailbox(request.params(USER_NAME), new MailboxName(request.params(MAILBOX_NAME)));
-                response.status(204);
+                response.status(HttpStatus.NO_CONTENT_204);
             } catch (IllegalStateException e) {
                 LOGGER.info("Invalid delete on user mailbox", e);
                 throw ErrorResponder.builder()
@@ -167,16 +167,16 @@ public class UserMailboxesRoutes implements Routes {
     })
     @ApiOperation(value = "Deleting user mailboxes.")
     @ApiResponses(value = {
-            @ApiResponse(code = 204, message = "The user does not have any mailbox", response = String.class),
-            @ApiResponse(code = 401, message = "Unauthorized. The user is not authenticated on the platform"),
-            @ApiResponse(code = 404, message = "The user name does not exist."),
-            @ApiResponse(code = 500, message = "Internal server error - Something went bad on the server side.")
+            @ApiResponse(code = HttpStatus.NO_CONTENT_204, message = "The user does not have any mailbox", response = String.class),
+            @ApiResponse(code = HttpStatus.UNAUTHORIZED_401, message = "Unauthorized. The user is not authenticated on the platform"),
+            @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "The user name does not exist."),
+            @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "Internal server error - Something went bad on the server side.")
     })
     public void defineDeleteUserMailboxes() {
         service.delete(USER_MAILBOXES_BASE, (request, response) -> {
             try {
                 userMailboxesService.deleteMailboxes(request.params(USER_NAME));
-                response.status(204);
+                response.status(HttpStatus.NO_CONTENT_204);
             } catch (IllegalStateException e) {
                 LOGGER.info("Invalid delete on user mailboxes", e);
                 throw ErrorResponder.builder()
@@ -198,17 +198,17 @@ public class UserMailboxesRoutes implements Routes {
     })
     @ApiOperation(value = "Testing existence of a mailbox.")
     @ApiResponses(value = {
-            @ApiResponse(code = 204, message = "The mailbox exists", response = String.class),
-            @ApiResponse(code = 400, message = "Invalid mailbox name"),
-            @ApiResponse(code = 401, message = "Unauthorized. The user is not authenticated on the platform"),
-            @ApiResponse(code = 404, message = "The user name does not exist."),
-            @ApiResponse(code = 500, message = "Internal server error - Something went bad on the server side.")
+            @ApiResponse(code = HttpStatus.NO_CONTENT_204, message = "The mailbox exists", response = String.class),
+            @ApiResponse(code = HttpStatus.BAD_REQUEST_400, message = "Invalid mailbox name"),
+            @ApiResponse(code = HttpStatus.UNAUTHORIZED_401, message = "Unauthorized. The user is not authenticated on the platform"),
+            @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "The user name does not exist."),
+            @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "Internal server error - Something went bad on the server side.")
     })
     public void defineMailboxExists() {
         service.get(SPECIFIC_MAILBOX, (request, response) -> {
             try {
                 if (userMailboxesService.testMailboxExists(request.params(USER_NAME), new MailboxName(request.params(MAILBOX_NAME)))) {
-                    response.status(204);
+                    response.status(HttpStatus.NO_CONTENT_204);
                 } else {
                     throw ErrorResponder.builder()
                         .statusCode(HttpStatus.NOT_FOUND_404)
@@ -245,17 +245,17 @@ public class UserMailboxesRoutes implements Routes {
             @ApiImplicitParam(required = true, dataType = "string", name = "mailboxName", paramType = "path")
     })
     @ApiResponses(value = {
-            @ApiResponse(code = 204, message = "OK. The mailbox now exists on the server.", response = String.class),
-            @ApiResponse(code = 400, message = "Invalid mailbox name"),
-            @ApiResponse(code = 401, message = "Unauthorized. The user is not authenticated on the platform"),
-            @ApiResponse(code = 404, message = "The user name does not exist."),
-            @ApiResponse(code = 500, message = "Internal server error - Something went bad on the server side.")
+            @ApiResponse(code = HttpStatus.NO_CONTENT_204, message = "OK. The mailbox now exists on the server.", response = String.class),
+            @ApiResponse(code = HttpStatus.BAD_REQUEST_400, message = "Invalid mailbox name"),
+            @ApiResponse(code = HttpStatus.UNAUTHORIZED_401, message = "Unauthorized. The user is not authenticated on the platform"),
+            @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "The user name does not exist."),
+            @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "Internal server error - Something went bad on the server side.")
     })
     public void defineCreateUserMailbox() {
         service.put(SPECIFIC_MAILBOX, (request, response) -> {
             try {
                 userMailboxesService.createMailbox(request.params(USER_NAME), new MailboxName(request.params(MAILBOX_NAME)));
-                response.status(204);
+                response.status(HttpStatus.NO_CONTENT_204);
             } catch (IllegalStateException e) {
                 LOGGER.info("Invalid put on user mailbox", e);
                 throw ErrorResponder.builder()


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