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 2018/06/26 09:12:57 UTC

[01/20] james-project git commit: JAMES-2151 Administer Sieve quotas via webadmin

Repository: james-project
Updated Branches:
  refs/heads/master 5a4c0ded9 -> b10fa18aa


JAMES-2151 Administer Sieve quotas via webadmin

>From the awesome work of Sebastian Górecki on https://github.com/linagora/james-project/pull/1066


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

Branch: refs/heads/master
Commit: b9ac736b4644c4471e931c12dffcd167e32aa3ba
Parents: 5a4c0de
Author: Sebastian Górecki <go...@gmail.com>
Authored: Tue Oct 24 23:10:02 2017 +0200
Committer: benwa <bt...@linagora.com>
Committed: Tue Jun 26 16:05:27 2018 +0700

----------------------------------------------------------------------
 .../api/SieveQuotaRepository.java               |  46 ++++
 .../sieverepository/api/SieveRepository.java    |  19 +-
 .../james/webadmin/routes/SieveQuotaRoutes.java | 260 +++++++++++++++++++
 .../routes/InMemorySieveQuotaRepository.java    |  82 ++++++
 .../webadmin/routes/SieveQuotaRoutesTest.java   | 215 +++++++++++++++
 5 files changed, 604 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/b9ac736b/server/data/data-api/src/main/java/org/apache/james/sieverepository/api/SieveQuotaRepository.java
----------------------------------------------------------------------
diff --git a/server/data/data-api/src/main/java/org/apache/james/sieverepository/api/SieveQuotaRepository.java b/server/data/data-api/src/main/java/org/apache/james/sieverepository/api/SieveQuotaRepository.java
new file mode 100644
index 0000000..ec11c1e
--- /dev/null
+++ b/server/data/data-api/src/main/java/org/apache/james/sieverepository/api/SieveQuotaRepository.java
@@ -0,0 +1,46 @@
+/*
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *   or more contributor license agreements.  See the NOTICE file
+ *   distributed with this work for additional information
+ *   regarding copyright ownership.  The ASF licenses this file
+ *   to you under the Apache License, Version 2.0 (the
+ *   "License"); you may not use this file except in compliance
+ *   with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing,
+ *   software distributed under the License is distributed on an
+ *   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *   KIND, either express or implied.  See the License for the
+ *   specific language governing permissions and limitations
+ *   under the License.
+ *
+ */
+
+package org.apache.james.sieverepository.api;
+
+import org.apache.james.sieverepository.api.exception.QuotaNotFoundException;
+import org.apache.james.sieverepository.api.exception.StorageException;
+
+/**
+ * SieveQuotaRepository
+ */
+public interface SieveQuotaRepository {
+
+    boolean hasQuota() throws StorageException;
+
+    long getQuota() throws QuotaNotFoundException, StorageException;
+
+    void setQuota(long quota) throws StorageException;
+
+    void removeQuota() throws QuotaNotFoundException, StorageException;
+
+    boolean hasQuota(String user) throws StorageException;
+
+    long getQuota(String user) throws QuotaNotFoundException, StorageException;
+
+    void setQuota(String user, long quota) throws StorageException;
+
+    void removeQuota(String user) throws QuotaNotFoundException, StorageException;
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/b9ac736b/server/data/data-api/src/main/java/org/apache/james/sieverepository/api/SieveRepository.java
----------------------------------------------------------------------
diff --git a/server/data/data-api/src/main/java/org/apache/james/sieverepository/api/SieveRepository.java b/server/data/data-api/src/main/java/org/apache/james/sieverepository/api/SieveRepository.java
index 9bdb55e..f93d080 100644
--- a/server/data/data-api/src/main/java/org/apache/james/sieverepository/api/SieveRepository.java
+++ b/server/data/data-api/src/main/java/org/apache/james/sieverepository/api/SieveRepository.java
@@ -26,7 +26,6 @@ import java.util.List;
 import org.apache.james.sieverepository.api.exception.DuplicateException;
 import org.apache.james.sieverepository.api.exception.IsActiveException;
 import org.apache.james.sieverepository.api.exception.QuotaExceededException;
-import org.apache.james.sieverepository.api.exception.QuotaNotFoundException;
 import org.apache.james.sieverepository.api.exception.ScriptNotFoundException;
 import org.apache.james.sieverepository.api.exception.StorageException;
 import org.joda.time.DateTime;
@@ -35,7 +34,7 @@ import org.joda.time.DateTime;
 /**
  * <code>SieveRepository</code>
  */
-public interface SieveRepository {
+public interface SieveRepository extends SieveQuotaRepository {
 
     String NO_SCRIPT_NAME = "";
 
@@ -68,20 +67,4 @@ public interface SieveRepository {
     
     void renameScript(String user, String oldName, String newName) throws ScriptNotFoundException, DuplicateException, StorageException;
 
-    boolean hasQuota() throws StorageException;
-    
-    long getQuota() throws QuotaNotFoundException, StorageException;
-    
-    void setQuota(long quota) throws StorageException;
-    
-    void removeQuota() throws QuotaNotFoundException, StorageException;
-    
-    boolean hasQuota(String user) throws StorageException;
-    
-    long getQuota(String user) throws QuotaNotFoundException, StorageException;
-    
-    void setQuota(String user, long quota) throws StorageException;
-    
-    void removeQuota(String user) throws QuotaNotFoundException, StorageException;
-
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/b9ac736b/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/SieveQuotaRoutes.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/SieveQuotaRoutes.java b/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/SieveQuotaRoutes.java
new file mode 100644
index 0000000..1c779db
--- /dev/null
+++ b/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/SieveQuotaRoutes.java
@@ -0,0 +1,260 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.webadmin.routes;
+
+import static org.apache.james.webadmin.Constants.SEPARATOR;
+
+import javax.inject.Inject;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+
+import org.apache.james.sieverepository.api.SieveQuotaRepository;
+import org.apache.james.sieverepository.api.exception.QuotaNotFoundException;
+import org.apache.james.webadmin.Constants;
+import org.apache.james.webadmin.Routes;
+import org.apache.james.webadmin.utils.ErrorResponder;
+import org.apache.james.webadmin.utils.JsonExtractException;
+import org.apache.james.webadmin.utils.JsonExtractor;
+import org.apache.james.webadmin.utils.JsonTransformer;
+import org.eclipse.jetty.http.HttpStatus;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiResponse;
+import io.swagger.annotations.ApiResponses;
+import spark.Request;
+import spark.Service;
+
+@Api(tags = "SieveQuota")
+@Path(SieveQuotaRoutes.ROOT_PATH)
+@Produces("application/json")
+public class SieveQuotaRoutes implements Routes {
+
+    static final String ROOT_PATH = "/sieve/quota";
+    private static final String USER_ID = "userId";
+    private static final String USER_SIEVE_QUOTA_PATH = ROOT_PATH + SEPARATOR + ":" + USER_ID;
+    private static final String REQUESTED_SIZE = "requestedSize";
+    private static final Logger LOGGER = LoggerFactory.getLogger(SieveQuotaRoutes.class);
+
+    private final SieveQuotaRepository sieveQuotaRepository;
+    private final JsonTransformer jsonTransformer;
+    private final JsonExtractor<Long> jsonExtractor;
+
+    @Inject
+    public SieveQuotaRoutes(SieveQuotaRepository sieveQuotaRepository, JsonTransformer jsonTransformer) {
+        this.sieveQuotaRepository = sieveQuotaRepository;
+        this.jsonTransformer = jsonTransformer;
+        this.jsonExtractor = new JsonExtractor<>(Long.class);
+    }
+
+    @Override
+    public void define(Service service) {
+        defineGetGlobalSieveQuota(service);
+        defineUpdateGlobalSieveQuota(service);
+        defineRemoveGlobalSieveQuota(service);
+
+        defineGetPerUserSieveQuota(service);
+        defineUpdatePerUserSieveQuota(service);
+        defineRemovePerUserSieveQuota(service);
+    }
+
+    @GET
+    @ApiOperation(value = "Reading global sieve quota size")
+    @ApiResponses(value = {
+            @ApiResponse(code = 200, message = "OK", response = Long.class),
+            @ApiResponse(code = 404, message = "Global sieve quota not set."),
+            @ApiResponse(code = 500, message = "Internal server error - Something went bad on the server side.")
+    })
+    public void defineGetGlobalSieveQuota(Service service) {
+        service.get(ROOT_PATH, (request, response) -> {
+            try {
+                long sieveQuota = sieveQuotaRepository.getQuota();
+                response.status(HttpStatus.OK_200);
+                return sieveQuota;
+            } catch (QuotaNotFoundException e) {
+                LOGGER.info("Global sieve quota not set", e);
+                throw ErrorResponder.builder()
+                    .type(ErrorResponder.ErrorType.NOT_FOUND)
+                    .statusCode(HttpStatus.NOT_FOUND_404)
+                    .message("Global sieve quota not set")
+                    .haltError();
+            }
+        }, jsonTransformer);
+    }
+
+    @PUT
+    @ApiOperation(value = "Update global sieve quota size")
+    @ApiImplicitParams({
+            @ApiImplicitParam(required = true, dataType = "long", name = REQUESTED_SIZE, paramType = "body")
+    })
+    @ApiResponses(value = {
+            @ApiResponse(code = 200, message = "OK", response = Long.class),
+            @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.")
+    })
+    public void defineUpdateGlobalSieveQuota(Service service) {
+        service.put(ROOT_PATH, (request, response) -> {
+            try {
+                Long requestedSize = extractRequestedQuotaSizeFromRequest(request);
+                sieveQuotaRepository.setQuota(requestedSize);
+                response.status(HttpStatus.NO_CONTENT_204);
+                return Constants.EMPTY_BODY;
+            } catch (JsonExtractException e) {
+                LOGGER.info("Malformed JSON", e);
+                throw ErrorResponder.builder()
+                    .type(ErrorResponder.ErrorType.INVALID_ARGUMENT)
+                    .statusCode(HttpStatus.BAD_REQUEST_400)
+                    .message("Malformed JSON")
+                    .cause(e)
+                    .haltError();
+            }
+        }, jsonTransformer);
+    }
+
+    @DELETE
+    @ApiOperation(value = "Removes global sieve quota")
+    @ApiResponses(value = {
+            @ApiResponse(code = 204, message = "Global sieve quota removed."),
+            @ApiResponse(code = 404, message = "Global sieve quota not set."),
+            @ApiResponse(code = 500, message = "Internal server error - Something went bad on the server side.")
+    })
+    public void defineRemoveGlobalSieveQuota(Service service) {
+        service.delete(ROOT_PATH, (request, response) -> {
+            try {
+                sieveQuotaRepository.removeQuota();
+                response.status(HttpStatus.NO_CONTENT_204);
+            } catch (QuotaNotFoundException e) {
+                LOGGER.info("Global sieve quota not set", e);
+                throw ErrorResponder.builder()
+                    .type(ErrorResponder.ErrorType.NOT_FOUND)
+                    .statusCode(HttpStatus.NOT_FOUND_404)
+                    .message("Global sieve quota not set")
+                    .haltError();
+            }
+            return Constants.EMPTY_BODY;
+        });
+    }
+
+    @GET
+    @Path(value = ROOT_PATH + "/{" + USER_ID + "}")
+    @ApiImplicitParams({
+            @ApiImplicitParam(required = true, dataType = "string", name = USER_ID, paramType = "path")
+    })
+    @ApiResponses(value = {
+            @ApiResponse(code = 200, message = "OK", response = Long.class),
+            @ApiResponse(code = 404, message = "User sieve quota not set."),
+            @ApiResponse(code = 500, message = "Internal server error - Something went bad on the server side.")
+    })
+    public void defineGetPerUserSieveQuota(Service service) {
+        service.get(USER_SIEVE_QUOTA_PATH, (request, response) -> {
+            String userId = request.params(USER_ID);
+            try {
+                long userQuota = sieveQuotaRepository.getQuota(userId);
+                response.status(HttpStatus.OK_200);
+                return userQuota;
+            } catch (QuotaNotFoundException e) {
+                LOGGER.info("User sieve quota not set", e);
+                throw ErrorResponder.builder()
+                    .type(ErrorResponder.ErrorType.NOT_FOUND)
+                    .statusCode(HttpStatus.NOT_FOUND_404)
+                    .message("User sieve quota not set")
+                    .haltError();
+            }
+        }, jsonTransformer);
+    }
+
+    @PUT
+    @Path(value = ROOT_PATH + "/{" + USER_ID + "}")
+    @ApiImplicitParams({
+            @ApiImplicitParam(required = true, dataType = "string", name = USER_ID, paramType = "path"),
+            @ApiImplicitParam(required = true, dataType = "long", name = REQUESTED_SIZE, paramType = "body")
+    })
+    @ApiResponses(value = {
+            @ApiResponse(code = 200, message = "OK", response = Long.class),
+            @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.")
+    })
+    public void defineUpdatePerUserSieveQuota(Service service) {
+        service.put(USER_SIEVE_QUOTA_PATH, (request, response) -> {
+            String userId = request.params(USER_ID);
+            try {
+                Long requestedSize = extractRequestedQuotaSizeFromRequest(request);
+                sieveQuotaRepository.setQuota(userId, requestedSize);
+                response.status(HttpStatus.NO_CONTENT_204);
+            } catch (JsonExtractException e) {
+                LOGGER.info("Malformed JSON", e);
+                throw ErrorResponder.builder()
+                    .type(ErrorResponder.ErrorType.INVALID_ARGUMENT)
+                    .statusCode(HttpStatus.BAD_REQUEST_400)
+                    .message("Malformed JSON")
+                    .cause(e)
+                    .haltError();
+            }
+            return Constants.EMPTY_BODY;
+        }, jsonTransformer);
+    }
+
+    @DELETE
+    @Path(value = ROOT_PATH + "/{" + USER_ID + "}")
+    @ApiImplicitParams({
+            @ApiImplicitParam(required = true, dataType = "string", name = USER_ID, paramType = "path")
+    })
+    @ApiResponses(value = {
+            @ApiResponse(code = 204, message = "User sieve quota removed."),
+            @ApiResponse(code = 404, message = "User sieve quota not set."),
+            @ApiResponse(code = 500, message = "Internal server error - Something went bad on the server side.")
+    })
+    public void defineRemovePerUserSieveQuota(Service service) {
+        service.delete(USER_SIEVE_QUOTA_PATH, (request, response) -> {
+            String userId = request.params(USER_ID);
+            try {
+                sieveQuotaRepository.removeQuota(userId);
+                response.status(HttpStatus.NO_CONTENT_204);
+            } catch (QuotaNotFoundException e) {
+                LOGGER.info("User sieve quota not set", e);
+                throw ErrorResponder.builder()
+                    .type(ErrorResponder.ErrorType.NOT_FOUND)
+                    .statusCode(HttpStatus.NOT_FOUND_404)
+                    .message("User sieve quota not set")
+                    .haltError();
+            }
+            return Constants.EMPTY_BODY;
+        });
+    }
+
+    private Long extractRequestedQuotaSizeFromRequest(Request request) throws JsonExtractException {
+        Long requestedSize = jsonExtractor.parse(request.body());
+        if (requestedSize < 0) {
+            throw ErrorResponder.builder()
+                .type(ErrorResponder.ErrorType.INVALID_ARGUMENT)
+                .statusCode(HttpStatus.BAD_REQUEST_400)
+                .message("Requested quota size have to be a positive integer")
+                .haltError();
+        }
+        return requestedSize;
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/b9ac736b/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/InMemorySieveQuotaRepository.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/InMemorySieveQuotaRepository.java b/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/InMemorySieveQuotaRepository.java
new file mode 100644
index 0000000..d3aedd0
--- /dev/null
+++ b/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/InMemorySieveQuotaRepository.java
@@ -0,0 +1,82 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.webadmin.routes;
+
+import java.util.Map;
+import java.util.Optional;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.apache.james.sieverepository.api.SieveQuotaRepository;
+import org.apache.james.sieverepository.api.exception.QuotaNotFoundException;
+
+public class InMemorySieveQuotaRepository implements SieveQuotaRepository {
+
+    private Optional<Long> globalQuota = Optional.empty();
+
+    private Map<String, Long> userQuota = new ConcurrentHashMap<>();
+
+    @Override
+    public boolean hasQuota() {
+        return globalQuota.isPresent();
+    }
+
+    @Override
+    public long getQuota() throws QuotaNotFoundException {
+        return globalQuota.orElseThrow(QuotaNotFoundException::new);
+    }
+
+    @Override
+    public void setQuota(long quota) {
+        this.globalQuota = Optional.of(quota);
+    }
+
+    @Override
+    public void removeQuota() throws QuotaNotFoundException {
+        if (!globalQuota.isPresent()) {
+            throw new QuotaNotFoundException();
+        }
+        globalQuota = Optional.empty();
+    }
+
+    @Override
+    public boolean hasQuota(String user) {
+        return userQuota.containsKey(user);
+    }
+
+    @Override
+    public long getQuota(String user) throws QuotaNotFoundException {
+        return Optional.ofNullable(userQuota.get(user))
+            .orElseThrow(QuotaNotFoundException::new);
+    }
+
+    @Override
+    public void setQuota(String user, long quota) {
+        userQuota.put(user, quota);
+    }
+
+    @Override
+    public void removeQuota(String user) throws QuotaNotFoundException {
+        Optional<Long> quotaValue = Optional.ofNullable(userQuota.get(user));
+        if (!quotaValue.isPresent()) {
+            throw new QuotaNotFoundException();
+        }
+        userQuota.remove(user);
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/b9ac736b/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/SieveQuotaRoutesTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/SieveQuotaRoutesTest.java b/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/SieveQuotaRoutesTest.java
new file mode 100644
index 0000000..e127901
--- /dev/null
+++ b/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/SieveQuotaRoutesTest.java
@@ -0,0 +1,215 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.webadmin.routes;
+
+import static com.jayway.restassured.RestAssured.given;
+import static org.apache.james.webadmin.Constants.SEPARATOR;
+import static org.apache.james.webadmin.WebAdminServer.NO_CONFIGURATION;
+import static org.apache.james.webadmin.routes.SieveQuotaRoutes.ROOT_PATH;
+import static org.assertj.core.api.Assertions.assertThat;
+
+import org.apache.james.metrics.logger.DefaultMetricFactory;
+import org.apache.james.sieverepository.api.SieveQuotaRepository;
+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.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import com.jayway.restassured.RestAssured;
+import com.jayway.restassured.http.ContentType;
+
+public class SieveQuotaRoutesTest {
+
+    private static final String USER_A = "userA";
+
+    private WebAdminServer webAdminServer;
+    private SieveQuotaRepository sieveRepository;
+
+    @BeforeEach
+    public void setUp() throws Exception {
+        sieveRepository = new InMemorySieveQuotaRepository();
+        webAdminServer = WebAdminUtils.createWebAdminServer(
+                new DefaultMetricFactory(),
+                new SieveQuotaRoutes(sieveRepository, new JsonTransformer()));
+        webAdminServer.configure(NO_CONFIGURATION);
+        webAdminServer.await();
+
+        RestAssured.requestSpecification = WebAdminUtils.buildRequestSpecification(webAdminServer)
+            .build();
+    }
+
+    @AfterEach
+    public void tearDown() {
+        webAdminServer.destroy();
+    }
+
+    @Test
+    public void getGlobalSieveQuotaShouldReturn404WhenNoQuotaSet() {
+        given()
+            .get(SieveQuotaRoutes.ROOT_PATH)
+        .then()
+            .statusCode(404);
+    }
+
+    @Test
+    public void getGlobalSieveQuotaShouldReturnStoredValue() throws Exception {
+        long value = 1000L;
+        sieveRepository.setQuota(value);
+
+        long actual =
+            given()
+                .get(SieveQuotaRoutes.ROOT_PATH)
+            .then()
+                .statusCode(HttpStatus.OK_200)
+                .contentType(ContentType.JSON)
+                .extract()
+                .as(Long.class);
+
+        assertThat(actual).isEqualTo(value);
+    }
+
+    @Test
+    public void updateGlobalSieveQuotaShouldUpdateStoredValue() throws Exception {
+        sieveRepository.setQuota(500L);
+        long requiredSize = 1024L;
+
+        given()
+            .body(requiredSize)
+            .put(SieveQuotaRoutes.ROOT_PATH)
+        .then()
+            .statusCode(HttpStatus.NO_CONTENT_204);
+
+        assertThat(sieveRepository.getQuota()).isEqualTo(requiredSize);
+    }
+
+    @Test
+    public void updateGlobalSieveQuotaShouldReturn400WhenMalformedJSON() {
+        given()
+            .body("invalid")
+            .put(SieveQuotaRoutes.ROOT_PATH)
+        .then()
+            .statusCode(HttpStatus.BAD_REQUEST_400);
+    }
+
+    @Test
+    public void updateGlobalSieveQuotaShouldReturn400WhenRequestedSizeNotPositiveInteger() {
+        given()
+            .body(-100L)
+            .put(SieveQuotaRoutes.ROOT_PATH)
+        .then()
+            .statusCode(HttpStatus.BAD_REQUEST_400);
+    }
+
+    @Test
+    public void removeGlobalSieveQuotaShouldReturn404WhenNoQuotaSet() {
+        given()
+            .delete(SieveQuotaRoutes.ROOT_PATH)
+        .then()
+            .statusCode(HttpStatus.NOT_FOUND_404);
+    }
+
+    @Test
+    public void removeGlobalSieveQuotaShouldRemoveGlobalSieveQuota() throws Exception {
+        sieveRepository.setQuota(1024L);
+
+        given()
+            .delete(SieveQuotaRoutes.ROOT_PATH)
+        .then()
+            .statusCode(HttpStatus.NO_CONTENT_204);
+    }
+
+    @Test
+    public void getPerUserQuotaShouldReturn404WhenNoQuotaSetForUser() {
+        given()
+            .get(ROOT_PATH + SEPARATOR + USER_A)
+        .then()
+            .statusCode(HttpStatus.NOT_FOUND_404);
+    }
+
+    @Test
+    public void getPerUserSieveQuotaShouldReturnedStoredValue() throws Exception {
+        long value = 1024L;
+        sieveRepository.setQuota(USER_A, value);
+
+        long actual =
+            given()
+                .get(ROOT_PATH + SEPARATOR + USER_A)
+            .then()
+                .statusCode(HttpStatus.OK_200)
+                .contentType(ContentType.JSON)
+                .extract()
+                .as(Long.class);
+
+        assertThat(actual).isEqualTo(value);
+    }
+
+    @Test
+    public void updatePerUserSieveQuotaShouldUpdateStoredValue() throws Exception {
+        sieveRepository.setQuota(USER_A, 500L);
+        long requiredSize = 1024L;
+
+        given()
+            .body(requiredSize)
+            .put(ROOT_PATH + SEPARATOR + USER_A)
+        .then()
+            .statusCode(HttpStatus.NO_CONTENT_204);
+
+        assertThat(sieveRepository.getQuota(USER_A)).isEqualTo(requiredSize);
+    }
+
+    @Test
+    public void updatePerUserSieveQuotaShouldReturn400WhenMalformedJSON() {
+        given()
+            .body("invalid")
+            .put(ROOT_PATH + SEPARATOR + USER_A)
+        .then()
+            .statusCode(HttpStatus.BAD_REQUEST_400);
+    }
+
+    @Test
+    public void updatePerUserSieveQuotaShouldReturn400WhenRequestedSizeNotPositiveInteger() {
+        given()
+            .body(-100L)
+            .put(ROOT_PATH + SEPARATOR + USER_A)
+        .then()
+            .statusCode(HttpStatus.BAD_REQUEST_400);
+    }
+
+    @Test
+    public void removePerUserSieveQuotaShouldReturn404WhenNoQuotaSetForUser() {
+        given()
+            .delete(ROOT_PATH + SEPARATOR + USER_A)
+        .then()
+            .statusCode(HttpStatus.NOT_FOUND_404);
+    }
+
+    @Test
+    public void removePerUserSieveQuotaShouldRemoveQuotaForUser() throws Exception {
+        sieveRepository.setQuota(USER_A, 1024L);
+
+        given()
+            .delete(ROOT_PATH + SEPARATOR + USER_A)
+        .then()
+            .statusCode(HttpStatus.NO_CONTENT_204);
+    }
+}


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


[19/20] james-project git commit: JAMES-2439 Document new Guice jmx.enabled configuration option

Posted by bt...@apache.org.
JAMES-2439 Document new Guice jmx.enabled configuration option


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

Branch: refs/heads/master
Commit: 5f505b658720fbe144a546ee69ff33e5f7d471f2
Parents: a2e1b1d
Author: benwa <bt...@linagora.com>
Authored: Mon Jun 25 11:58:20 2018 +0700
Committer: benwa <bt...@linagora.com>
Committed: Tue Jun 26 16:11:09 2018 +0700

----------------------------------------------------------------------
 src/site/xdoc/server/config-system.xml | 2 ++
 1 file changed, 2 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/5f505b65/src/site/xdoc/server/config-system.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/server/config-system.xml b/src/site/xdoc/server/config-system.xml
index 0c8ca3c..c4ab38f 100644
--- a/src/site/xdoc/server/config-system.xml
+++ b/src/site/xdoc/server/config-system.xml
@@ -117,6 +117,8 @@
                 <p>This is used to configure the JMX MBean server via which all management is achieved (also used by via the james-cli).</p>
 
                 <dl>
+                    <dt><strong>jmx.enabled</strong></dt>
+                    <dd>(Guice only). Boolean. Should the JMX server be enabled? Defaults to `true`.</dd>
                     <dt><strong>jmx.address</strong></dt>
                     <dd>The IP address (host name) the MBean Server will bind/listen to.</dd>
                     <dt><strong>jmx.port</strong></dt>


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


[16/20] james-project git commit: JAMES-2439 Extract configuration management from JMXServer

Posted by bt...@apache.org.
JAMES-2439 Extract configuration management from JMXServer


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

Branch: refs/heads/master
Commit: 3c3c8fc6bf247727a6f3311e0626f389ccd8b51f
Parents: 81db3c2
Author: benwa <bt...@linagora.com>
Authored: Mon Jun 25 11:42:02 2018 +0700
Committer: benwa <bt...@linagora.com>
Committed: Tue Jun 26 16:10:41 2018 +0700

----------------------------------------------------------------------
 server/container/guice/jmx/pom.xml              | 20 ++++++
 .../apache/james/modules/server/JMXServer.java  | 35 +++------
 .../james/modules/server/JMXServerModule.java   | 19 +++++
 .../james/modules/server/JmxConfiguration.java  | 75 ++++++++++++++++++++
 .../modules/server/JmxConfigurationTest.java    | 55 ++++++++++++++
 5 files changed, 177 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/3c3c8fc6/server/container/guice/jmx/pom.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/jmx/pom.xml b/server/container/guice/jmx/pom.xml
index df9326f..aa1190f 100644
--- a/server/container/guice/jmx/pom.xml
+++ b/server/container/guice/jmx/pom.xml
@@ -77,6 +77,26 @@
             <artifactId>guice-multibindings</artifactId>
         </dependency>
         <dependency>
+            <groupId>nl.jqno.equalsverifier</groupId>
+            <artifactId>equalsverifier</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.assertj</groupId>
+            <artifactId>assertj-core</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.junit.jupiter</groupId>
+            <artifactId>junit-jupiter-engine</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.junit.platform</groupId>
+            <artifactId>junit-platform-launcher</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
             <groupId>org.slf4j</groupId>
             <artifactId>slf4j-api</artifactId>
         </dependency>

http://git-wip-us.apache.org/repos/asf/james-project/blob/3c3c8fc6/server/container/guice/jmx/src/main/java/org/apache/james/modules/server/JMXServer.java
----------------------------------------------------------------------
diff --git a/server/container/guice/jmx/src/main/java/org/apache/james/modules/server/JMXServer.java b/server/container/guice/jmx/src/main/java/org/apache/james/modules/server/JMXServer.java
index 9fc69fe..130b572 100644
--- a/server/container/guice/jmx/src/main/java/org/apache/james/modules/server/JMXServer.java
+++ b/server/container/guice/jmx/src/main/java/org/apache/james/modules/server/JMXServer.java
@@ -19,7 +19,6 @@
 
 package org.apache.james.modules.server;
 
-import java.io.FileNotFoundException;
 import java.lang.management.ManagementFactory;
 import java.net.ServerSocket;
 import java.rmi.registry.LocateRegistry;
@@ -35,21 +34,13 @@ import javax.management.remote.JMXConnectorServer;
 import javax.management.remote.JMXConnectorServerFactory;
 import javax.management.remote.JMXServiceURL;
 
-import org.apache.commons.configuration.ConfigurationException;
-import org.apache.commons.configuration.PropertiesConfiguration;
 import org.apache.james.util.RestrictingRMISocketFactory;
-import org.apache.james.utils.PropertiesProvider;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 import com.github.fge.lambdas.Throwing;
 import com.google.common.collect.ImmutableMap;
 
 public class JMXServer {
-
-    private static final Logger LOGGER = LoggerFactory.getLogger(JMXServer.class);
-
-    private final PropertiesProvider propertiesProvider;
+    private final JmxConfiguration jmxConfiguration;
     private final Set<String> registeredKeys;
     private final Object lock;
     private JMXConnectorServer jmxConnectorServer;
@@ -57,8 +48,8 @@ public class JMXServer {
     private RestrictingRMISocketFactory restrictingRMISocketFactory;
 
     @Inject
-    public JMXServer(PropertiesProvider propertiesProvider) {
-        this.propertiesProvider = propertiesProvider;
+    public JMXServer(JmxConfiguration jmxConfiguration) {
+        this.jmxConfiguration = jmxConfiguration;
         isStarted = false;
         registeredKeys = new HashSet<>();
         lock = new Object();
@@ -94,12 +85,11 @@ public class JMXServer {
 
     private void doStart() {
         try {
-            PropertiesConfiguration configuration = getPropertiesConfiguration();
-            String address = configuration.getString("jmx.address", "localhost");
-            int port = configuration.getInt("jmx.port", 9999);
-            String serviceURL = "service:jmx:rmi://" + address + "/jndi/rmi://" + address + ":" + port + "/jmxrmi";
-            restrictingRMISocketFactory = new RestrictingRMISocketFactory(address);
-            LocateRegistry.createRegistry(port, restrictingRMISocketFactory, restrictingRMISocketFactory);
+            String serviceURL = "service:jmx:rmi://" + jmxConfiguration.getHost().getHostName()
+                + "/jndi/rmi://" + jmxConfiguration.getHost().getHostName()
+                + ":" + jmxConfiguration.getHost().getPort() + "/jmxrmi";
+            restrictingRMISocketFactory = new RestrictingRMISocketFactory(jmxConfiguration.getHost().getHostName());
+            LocateRegistry.createRegistry(jmxConfiguration.getHost().getPort(), restrictingRMISocketFactory, restrictingRMISocketFactory);
 
             Map<String, ?> environment = ImmutableMap.of();
             jmxConnectorServer = JMXConnectorServerFactory.newJMXConnectorServer(new JMXServiceURL(serviceURL),
@@ -112,15 +102,6 @@ public class JMXServer {
         }
     }
 
-    private PropertiesConfiguration getPropertiesConfiguration() throws ConfigurationException {
-        try {
-            return propertiesProvider.getConfiguration("jmx");
-        } catch (FileNotFoundException e) {
-            LOGGER.warn("Could not locate configuration file for JMX. Defaults to rmi://127.0.0.1:9999");
-            return new PropertiesConfiguration();
-        }
-    }
-
     private void doStop() {
         try {
             MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();

http://git-wip-us.apache.org/repos/asf/james-project/blob/3c3c8fc6/server/container/guice/jmx/src/main/java/org/apache/james/modules/server/JMXServerModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/jmx/src/main/java/org/apache/james/modules/server/JMXServerModule.java b/server/container/guice/jmx/src/main/java/org/apache/james/modules/server/JMXServerModule.java
index ca6938f..92105a5 100644
--- a/server/container/guice/jmx/src/main/java/org/apache/james/modules/server/JMXServerModule.java
+++ b/server/container/guice/jmx/src/main/java/org/apache/james/modules/server/JMXServerModule.java
@@ -19,8 +19,10 @@
 
 package org.apache.james.modules.server;
 
+import java.io.FileNotFoundException;
 import java.util.List;
 
+import org.apache.commons.configuration.ConfigurationException;
 import org.apache.james.adapter.mailbox.MailboxCopierManagement;
 import org.apache.james.adapter.mailbox.MailboxCopierManagementMBean;
 import org.apache.james.adapter.mailbox.MailboxManagerManagement;
@@ -47,10 +49,14 @@ import org.apache.james.user.api.UsersRepositoryManagementMBean;
 import org.apache.james.user.lib.UsersRepositoryManagement;
 import org.apache.james.utils.ConfigurationPerformer;
 import org.apache.james.utils.GuiceMailboxManagerResolver;
+import org.apache.james.utils.PropertiesProvider;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import com.google.common.collect.ImmutableList;
 import com.google.inject.AbstractModule;
 import com.google.inject.Inject;
+import com.google.inject.Provides;
 import com.google.inject.Scopes;
 import com.google.inject.Singleton;
 import com.google.inject.multibindings.Multibinder;
@@ -58,6 +64,8 @@ import com.google.inject.name.Names;
 
 public class JMXServerModule extends AbstractModule {
 
+    private static final Logger LOGGER = LoggerFactory.getLogger(JMXServerModule.class);
+
     private static final String JMX_COMPONENT_DOMAINLIST = "org.apache.james:type=component,name=domainlist";
     private static final String JMX_COMPONENT_USERS_REPOSITORY = "org.apache.james:type=component,name=usersrepository";
     private static final String JMX_COMPONENT_RECIPIENTREWRITETABLE = "org.apache.james:type=component,name=recipientrewritetable";
@@ -94,6 +102,17 @@ public class JMXServerModule extends AbstractModule {
         configurationMultibinder.addBinding().to(JMXModuleConfigurationPerformer.class);
     }
 
+    @Provides
+    @Singleton
+    public JmxConfiguration provideConfiguration(PropertiesProvider propertiesProvider) throws ConfigurationException {
+        try {
+            return JmxConfiguration.fromProperties(propertiesProvider.getConfiguration("jmx"));
+        } catch (FileNotFoundException e) {
+            LOGGER.warn("Could not locate configuration file for JMX. Defaults to rmi://127.0.0.1:9999");
+            return JmxConfiguration.DEFAULT_CONFIGURATION;
+        }
+    }
+
     @Singleton
     public static class JMXModuleConfigurationPerformer implements ConfigurationPerformer {
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/3c3c8fc6/server/container/guice/jmx/src/main/java/org/apache/james/modules/server/JmxConfiguration.java
----------------------------------------------------------------------
diff --git a/server/container/guice/jmx/src/main/java/org/apache/james/modules/server/JmxConfiguration.java b/server/container/guice/jmx/src/main/java/org/apache/james/modules/server/JmxConfiguration.java
new file mode 100644
index 0000000..793e930
--- /dev/null
+++ b/server/container/guice/jmx/src/main/java/org/apache/james/modules/server/JmxConfiguration.java
@@ -0,0 +1,75 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.modules.server;
+
+import java.util.Objects;
+
+import org.apache.commons.configuration.PropertiesConfiguration;
+import org.apache.james.util.Host;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.MoreObjects;
+
+public class JmxConfiguration {
+
+    public static final String LOCALHOST = "localhost";
+    public static final int DEFAULT_PORT = 9999;
+
+    public static final JmxConfiguration DEFAULT_CONFIGURATION = new JmxConfiguration(Host.from(LOCALHOST, DEFAULT_PORT));
+
+    public static JmxConfiguration fromProperties(PropertiesConfiguration configuration) {
+        String address = configuration.getString("jmx.address", LOCALHOST);
+        int port = configuration.getInt("jmx.port", DEFAULT_PORT);
+        return new JmxConfiguration(Host.from(address, port));
+    }
+
+    private final Host host;
+
+    @VisibleForTesting
+    JmxConfiguration(Host host) {
+        this.host = host;
+    }
+
+    public Host getHost() {
+        return host;
+    }
+
+    @Override
+    public final boolean equals(Object o) {
+        if (o instanceof JmxConfiguration) {
+            JmxConfiguration that = (JmxConfiguration) o;
+
+            return Objects.equals(this.host, that.host);
+        }
+        return false;
+    }
+
+    @Override
+    public final int hashCode() {
+        return Objects.hash(host);
+    }
+
+    @Override
+    public String toString() {
+        return MoreObjects.toStringHelper(this)
+            .add("host", host)
+            .toString();
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/3c3c8fc6/server/container/guice/jmx/src/test/java/org/apache/james/modules/server/JmxConfigurationTest.java
----------------------------------------------------------------------
diff --git a/server/container/guice/jmx/src/test/java/org/apache/james/modules/server/JmxConfigurationTest.java b/server/container/guice/jmx/src/test/java/org/apache/james/modules/server/JmxConfigurationTest.java
new file mode 100644
index 0000000..a727b58
--- /dev/null
+++ b/server/container/guice/jmx/src/test/java/org/apache/james/modules/server/JmxConfigurationTest.java
@@ -0,0 +1,55 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.modules.server;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.io.StringReader;
+
+import org.apache.commons.configuration.PropertiesConfiguration;
+import org.apache.james.util.Host;
+import org.junit.jupiter.api.Test;
+
+import nl.jqno.equalsverifier.EqualsVerifier;
+
+public class JmxConfigurationTest {
+    @Test
+    void shouldMatchBeanContract() {
+        EqualsVerifier.forClass(JmxConfiguration.class)
+            .verify();
+    }
+
+    @Test
+    void fromPropertiesShouldReturnDefaultWhenEmpty() {
+        assertThat(JmxConfiguration.fromProperties(new PropertiesConfiguration()))
+            .isEqualTo(JmxConfiguration.DEFAULT_CONFIGURATION);
+    }
+
+    @Test
+    void fromPropertiesShouldReturnConfiguredValues() throws Exception {
+        PropertiesConfiguration configuration = new PropertiesConfiguration();
+        configuration.load(new StringReader(
+                "jmx.address=172.0.0.5\n" +
+                "jmx.port=889\n"));
+
+        assertThat(JmxConfiguration.fromProperties(configuration))
+            .isEqualTo(new JmxConfiguration(Host.from("172.0.0.5", 889)));
+    }
+}


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


[14/20] james-project git commit: JAMES-2151 InMemorySieveQuotaRepository should be synchronized

Posted by bt...@apache.org.
JAMES-2151 InMemorySieveQuotaRepository should be synchronized


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

Branch: refs/heads/master
Commit: 280c6f725f80824312636553f3bb8367c873023b
Parents: 37ba4e3
Author: benwa <bt...@linagora.com>
Authored: Tue Jun 26 09:48:03 2018 +0700
Committer: benwa <bt...@linagora.com>
Committed: Tue Jun 26 16:09:37 2018 +0700

----------------------------------------------------------------------
 .../memory/InMemorySieveQuotaRepository.java          | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/280c6f72/server/data/data-memory/src/main/java/org/apache/james/sieverepository/memory/InMemorySieveQuotaRepository.java
----------------------------------------------------------------------
diff --git a/server/data/data-memory/src/main/java/org/apache/james/sieverepository/memory/InMemorySieveQuotaRepository.java b/server/data/data-memory/src/main/java/org/apache/james/sieverepository/memory/InMemorySieveQuotaRepository.java
index 3ca888f..0ed13b0 100644
--- a/server/data/data-memory/src/main/java/org/apache/james/sieverepository/memory/InMemorySieveQuotaRepository.java
+++ b/server/data/data-memory/src/main/java/org/apache/james/sieverepository/memory/InMemorySieveQuotaRepository.java
@@ -35,22 +35,22 @@ public class InMemorySieveQuotaRepository implements SieveQuotaRepository {
     private Map<User, QuotaSize> userQuota = new ConcurrentHashMap<>();
 
     @Override
-    public boolean hasDefaultQuota() {
+    public synchronized boolean hasDefaultQuota() {
         return globalQuota.isPresent();
     }
 
     @Override
-    public QuotaSize getDefaultQuota() throws QuotaNotFoundException {
+    public synchronized QuotaSize getDefaultQuota() throws QuotaNotFoundException {
         return globalQuota.orElseThrow(QuotaNotFoundException::new);
     }
 
     @Override
-    public void setDefaultQuota(QuotaSize quota) {
+    public synchronized void setDefaultQuota(QuotaSize quota) {
         this.globalQuota = Optional.of(quota);
     }
 
     @Override
-    public void removeQuota() throws QuotaNotFoundException {
+    public synchronized void removeQuota() throws QuotaNotFoundException {
         if (!globalQuota.isPresent()) {
             throw new QuotaNotFoundException();
         }
@@ -58,7 +58,7 @@ public class InMemorySieveQuotaRepository implements SieveQuotaRepository {
     }
 
     @Override
-    public boolean hasQuota(User user) {
+    public synchronized boolean hasQuota(User user) {
         return userQuota.containsKey(user);
     }
 
@@ -69,12 +69,12 @@ public class InMemorySieveQuotaRepository implements SieveQuotaRepository {
     }
 
     @Override
-    public void setQuota(User user, QuotaSize quota) {
+    public synchronized void setQuota(User user, QuotaSize quota) {
         userQuota.put(user, quota);
     }
 
     @Override
-    public void removeQuota(User user) throws QuotaNotFoundException {
+    public synchronized void removeQuota(User user) throws QuotaNotFoundException {
         Optional<QuotaSize> quotaValue = Optional.ofNullable(userQuota.get(user));
         if (!quotaValue.isPresent()) {
             throw new QuotaNotFoundException();


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


[04/20] james-project git commit: JAMES-2151 Bound SieveQuotaRoutes with guice

Posted by bt...@apache.org.
JAMES-2151 Bound SieveQuotaRoutes with guice


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

Branch: refs/heads/master
Commit: 27c8436550ba7d1a63aac751ab661ca7cf624e76
Parents: e8d5319
Author: benwa <bt...@linagora.com>
Authored: Wed Jun 20 16:18:50 2018 +0700
Committer: benwa <bt...@linagora.com>
Committed: Tue Jun 26 16:06:31 2018 +0700

----------------------------------------------------------------------
 .../apache/james/CassandraJamesServerMain.java  |  4 ++-
 .../data/CassandraSieveRepositoryModule.java    |  2 ++
 .../modules/data/SieveFileRepositoryModule.java |  2 ++
 .../org/apache/james/JPAJamesServerMain.java    |  4 ++-
 .../org/apache/james/MemoryJamesServerMain.java |  4 ++-
 .../modules/server/SieveQuotaRoutesModule.java  | 35 ++++++++++++++++++++
 6 files changed, 48 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/27c84365/server/container/guice/cassandra-guice/src/main/java/org/apache/james/CassandraJamesServerMain.java
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/CassandraJamesServerMain.java b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/CassandraJamesServerMain.java
index 4878e1e..240cf8a 100644
--- a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/CassandraJamesServerMain.java
+++ b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/CassandraJamesServerMain.java
@@ -51,6 +51,7 @@ import org.apache.james.modules.server.JMXServerModule;
 import org.apache.james.modules.server.MailQueueRoutesModule;
 import org.apache.james.modules.server.MailRepositoriesRoutesModule;
 import org.apache.james.modules.server.MailboxRoutesModule;
+import org.apache.james.modules.server.SieveQuotaRoutesModule;
 import org.apache.james.modules.server.SwaggerRoutesModule;
 import org.apache.james.modules.server.WebAdminServerModule;
 import org.apache.james.modules.spamassassin.SpamAssassinListenerModule;
@@ -69,7 +70,8 @@ public class CassandraJamesServerMain {
         new MailRepositoriesRoutesModule(),
         new SwaggerRoutesModule(),
         new WebAdminServerModule(),
-        new DLPRoutesModule());
+        new DLPRoutesModule(),
+        new SieveQuotaRoutesModule());
 
     public static final Module PROTOCOLS = Modules.combine(
         new CassandraJmapModule(),

http://git-wip-us.apache.org/repos/asf/james-project/blob/27c84365/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/data/CassandraSieveRepositoryModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/data/CassandraSieveRepositoryModule.java b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/data/CassandraSieveRepositoryModule.java
index 9021a53..f4947b8 100644
--- a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/data/CassandraSieveRepositoryModule.java
+++ b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/data/CassandraSieveRepositoryModule.java
@@ -21,6 +21,7 @@ package org.apache.james.modules.data;
 
 import org.apache.james.backends.cassandra.components.CassandraModule;
 import org.apache.james.sieve.cassandra.CassandraSieveRepository;
+import org.apache.james.sieverepository.api.SieveQuotaRepository;
 import org.apache.james.sieverepository.api.SieveRepository;
 
 import com.google.inject.AbstractModule;
@@ -33,6 +34,7 @@ public class CassandraSieveRepositoryModule extends AbstractModule {
     protected void configure() {
         bind(CassandraSieveRepository.class).in(Scopes.SINGLETON);
         bind(SieveRepository.class).to(CassandraSieveRepository.class);
+        bind(SieveQuotaRepository.class).to(CassandraSieveRepository.class);
 
         Multibinder<CassandraModule> cassandraDataDefinitions = Multibinder.newSetBinder(binder(), CassandraModule.class);
         cassandraDataDefinitions.addBinding().to(org.apache.james.sieve.cassandra.CassandraSieveRepositoryModule.class);

http://git-wip-us.apache.org/repos/asf/james-project/blob/27c84365/server/container/guice/guice-common/src/main/java/org/apache/james/modules/data/SieveFileRepositoryModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/src/main/java/org/apache/james/modules/data/SieveFileRepositoryModule.java b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/data/SieveFileRepositoryModule.java
index c6b36fd..d27d1a3 100644
--- a/server/container/guice/guice-common/src/main/java/org/apache/james/modules/data/SieveFileRepositoryModule.java
+++ b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/data/SieveFileRepositoryModule.java
@@ -18,6 +18,7 @@
  ****************************************************************/
 package org.apache.james.modules.data;
 
+import org.apache.james.sieverepository.api.SieveQuotaRepository;
 import org.apache.james.sieverepository.api.SieveRepository;
 import org.apache.james.sieverepository.file.SieveFileRepository;
 
@@ -31,6 +32,7 @@ public class SieveFileRepositoryModule extends AbstractModule {
         bind(SieveFileRepository.class).in(Scopes.SINGLETON);
 
         bind(SieveRepository.class).to(SieveFileRepository.class);
+        bind(SieveQuotaRepository.class).to(SieveFileRepository.class);
     }
 
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/27c84365/server/container/guice/jpa-guice/src/main/java/org/apache/james/JPAJamesServerMain.java
----------------------------------------------------------------------
diff --git a/server/container/guice/jpa-guice/src/main/java/org/apache/james/JPAJamesServerMain.java b/server/container/guice/jpa-guice/src/main/java/org/apache/james/JPAJamesServerMain.java
index 743d25c..bd5f5cb 100644
--- a/server/container/guice/jpa-guice/src/main/java/org/apache/james/JPAJamesServerMain.java
+++ b/server/container/guice/jpa-guice/src/main/java/org/apache/james/JPAJamesServerMain.java
@@ -41,6 +41,7 @@ import org.apache.james.modules.server.MailRepositoriesRoutesModule;
 import org.apache.james.modules.server.MailboxRoutesModule;
 import org.apache.james.modules.server.NoJwtModule;
 import org.apache.james.modules.server.RawPostDequeueDecoratorModule;
+import org.apache.james.modules.server.SieveQuotaRoutesModule;
 import org.apache.james.modules.server.SwaggerRoutesModule;
 import org.apache.james.modules.server.WebAdminServerModule;
 import org.apache.james.modules.spamassassin.SpamAssassinListenerModule;
@@ -57,7 +58,8 @@ public class JPAJamesServerMain {
         new MailboxRoutesModule(),
         new MailQueueRoutesModule(),
         new MailRepositoriesRoutesModule(),
-        new SwaggerRoutesModule());
+        new SwaggerRoutesModule(),
+        new SieveQuotaRoutesModule());
 
     public static final Module PROTOCOLS = Modules.combine(
         new IMAPServerModule(),

http://git-wip-us.apache.org/repos/asf/james-project/blob/27c84365/server/container/guice/memory-guice/src/main/java/org/apache/james/MemoryJamesServerMain.java
----------------------------------------------------------------------
diff --git a/server/container/guice/memory-guice/src/main/java/org/apache/james/MemoryJamesServerMain.java b/server/container/guice/memory-guice/src/main/java/org/apache/james/MemoryJamesServerMain.java
index fc80fe6..7c5b961 100644
--- a/server/container/guice/memory-guice/src/main/java/org/apache/james/MemoryJamesServerMain.java
+++ b/server/container/guice/memory-guice/src/main/java/org/apache/james/MemoryJamesServerMain.java
@@ -41,6 +41,7 @@ import org.apache.james.modules.server.MailRepositoriesRoutesModule;
 import org.apache.james.modules.server.MailboxRoutesModule;
 import org.apache.james.modules.server.MemoryMailQueueModule;
 import org.apache.james.modules.server.RawPostDequeueDecoratorModule;
+import org.apache.james.modules.server.SieveQuotaRoutesModule;
 import org.apache.james.modules.server.SwaggerRoutesModule;
 import org.apache.james.modules.server.WebAdminServerModule;
 import org.apache.james.modules.spamassassin.SpamAssassinListenerModule;
@@ -58,7 +59,8 @@ public class MemoryJamesServerMain {
         new MailQueueRoutesModule(),
         new MailRepositoriesRoutesModule(),
         new SwaggerRoutesModule(),
-        new DLPRoutesModule());
+        new DLPRoutesModule(),
+        new SieveQuotaRoutesModule());
 
     public static final Module PROTOCOLS = Modules.combine(
         new IMAPServerModule(),

http://git-wip-us.apache.org/repos/asf/james-project/blob/27c84365/server/container/guice/protocols/webadmin-data/src/main/java/org/apache/james/modules/server/SieveQuotaRoutesModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/protocols/webadmin-data/src/main/java/org/apache/james/modules/server/SieveQuotaRoutesModule.java b/server/container/guice/protocols/webadmin-data/src/main/java/org/apache/james/modules/server/SieveQuotaRoutesModule.java
new file mode 100644
index 0000000..27fdcbb
--- /dev/null
+++ b/server/container/guice/protocols/webadmin-data/src/main/java/org/apache/james/modules/server/SieveQuotaRoutesModule.java
@@ -0,0 +1,35 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.modules.server;
+
+import org.apache.james.webadmin.Routes;
+import org.apache.james.webadmin.routes.SieveQuotaRoutes;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.multibindings.Multibinder;
+
+public class SieveQuotaRoutesModule extends AbstractModule {
+    @Override
+    protected void configure() {
+        Multibinder.newSetBinder(binder(), Routes.class)
+            .addBinding()
+            .to(SieveQuotaRoutes.class);
+    }
+}


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


[18/20] james-project git commit: JAMES-2439 Add jmx.enabled in reference configurations

Posted by bt...@apache.org.
JAMES-2439 Add jmx.enabled in reference configurations


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

Branch: refs/heads/master
Commit: 25e9a11be2ea06617b1a7bc3b2c41ead9d0c3f0b
Parents: 5f505b65
Author: benwa <bt...@linagora.com>
Authored: Mon Jun 25 12:00:45 2018 +0700
Committer: benwa <bt...@linagora.com>
Committed: Tue Jun 26 16:11:09 2018 +0700

----------------------------------------------------------------------
 .../run/guice/cassandra-ldap/destination/conf/jmx.properties        | 1 +
 dockerfiles/run/guice/cassandra/destination/conf/jmx.properties     | 1 +
 dockerfiles/run/guice/jpa/destination/conf/jmx.properties           | 1 +
 .../guice/memory-guice/sample-configuration/jmx.properties          | 1 +
 4 files changed, 4 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/25e9a11b/dockerfiles/run/guice/cassandra-ldap/destination/conf/jmx.properties
----------------------------------------------------------------------
diff --git a/dockerfiles/run/guice/cassandra-ldap/destination/conf/jmx.properties b/dockerfiles/run/guice/cassandra-ldap/destination/conf/jmx.properties
index a1dbdf8..1c39a17 100644
--- a/dockerfiles/run/guice/cassandra-ldap/destination/conf/jmx.properties
+++ b/dockerfiles/run/guice/cassandra-ldap/destination/conf/jmx.properties
@@ -24,5 +24,6 @@
 
 # See http://james.apache.org/server/3/config.html for usage
 
+jmx.enabled=true
 jmx.address=127.0.0.1
 jmx.port=9999

http://git-wip-us.apache.org/repos/asf/james-project/blob/25e9a11b/dockerfiles/run/guice/cassandra/destination/conf/jmx.properties
----------------------------------------------------------------------
diff --git a/dockerfiles/run/guice/cassandra/destination/conf/jmx.properties b/dockerfiles/run/guice/cassandra/destination/conf/jmx.properties
index a1dbdf8..1c39a17 100644
--- a/dockerfiles/run/guice/cassandra/destination/conf/jmx.properties
+++ b/dockerfiles/run/guice/cassandra/destination/conf/jmx.properties
@@ -24,5 +24,6 @@
 
 # See http://james.apache.org/server/3/config.html for usage
 
+jmx.enabled=true
 jmx.address=127.0.0.1
 jmx.port=9999

http://git-wip-us.apache.org/repos/asf/james-project/blob/25e9a11b/dockerfiles/run/guice/jpa/destination/conf/jmx.properties
----------------------------------------------------------------------
diff --git a/dockerfiles/run/guice/jpa/destination/conf/jmx.properties b/dockerfiles/run/guice/jpa/destination/conf/jmx.properties
index a1dbdf8..1c39a17 100644
--- a/dockerfiles/run/guice/jpa/destination/conf/jmx.properties
+++ b/dockerfiles/run/guice/jpa/destination/conf/jmx.properties
@@ -24,5 +24,6 @@
 
 # See http://james.apache.org/server/3/config.html for usage
 
+jmx.enabled=true
 jmx.address=127.0.0.1
 jmx.port=9999

http://git-wip-us.apache.org/repos/asf/james-project/blob/25e9a11b/server/container/guice/memory-guice/sample-configuration/jmx.properties
----------------------------------------------------------------------
diff --git a/server/container/guice/memory-guice/sample-configuration/jmx.properties b/server/container/guice/memory-guice/sample-configuration/jmx.properties
index a1dbdf8..1c39a17 100644
--- a/server/container/guice/memory-guice/sample-configuration/jmx.properties
+++ b/server/container/guice/memory-guice/sample-configuration/jmx.properties
@@ -24,5 +24,6 @@
 
 # See http://james.apache.org/server/3/config.html for usage
 
+jmx.enabled=true
 jmx.address=127.0.0.1
 jmx.port=9999


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


[03/20] james-project git commit: JAMES-2151 Move InMemorySieveQuotaRepository in a more generic module

Posted by bt...@apache.org.
JAMES-2151 Move InMemorySieveQuotaRepository in a more generic module


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

Branch: refs/heads/master
Commit: 1914c7b86c8f001a307f6c5d0f4d83888a580155
Parents: 27c8436
Author: benwa <bt...@linagora.com>
Authored: Thu Jun 21 10:08:13 2018 +0700
Committer: benwa <bt...@linagora.com>
Committed: Tue Jun 26 16:06:31 2018 +0700

----------------------------------------------------------------------
 .../memory/InMemorySieveQuotaRepository.java    | 82 ++++++++++++++++++++
 .../routes/InMemorySieveQuotaRepository.java    | 82 --------------------
 .../webadmin/routes/SieveQuotaRoutesTest.java   |  1 +
 3 files changed, 83 insertions(+), 82 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/1914c7b8/server/data/data-memory/src/main/java/org/apache/james/sieverepository/memory/InMemorySieveQuotaRepository.java
----------------------------------------------------------------------
diff --git a/server/data/data-memory/src/main/java/org/apache/james/sieverepository/memory/InMemorySieveQuotaRepository.java b/server/data/data-memory/src/main/java/org/apache/james/sieverepository/memory/InMemorySieveQuotaRepository.java
new file mode 100644
index 0000000..1e30b9c
--- /dev/null
+++ b/server/data/data-memory/src/main/java/org/apache/james/sieverepository/memory/InMemorySieveQuotaRepository.java
@@ -0,0 +1,82 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.sieverepository.memory;
+
+import java.util.Map;
+import java.util.Optional;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.apache.james.sieverepository.api.SieveQuotaRepository;
+import org.apache.james.sieverepository.api.exception.QuotaNotFoundException;
+
+public class InMemorySieveQuotaRepository implements SieveQuotaRepository {
+
+    private Optional<Long> globalQuota = Optional.empty();
+
+    private Map<String, Long> userQuota = new ConcurrentHashMap<>();
+
+    @Override
+    public boolean hasQuota() {
+        return globalQuota.isPresent();
+    }
+
+    @Override
+    public long getQuota() throws QuotaNotFoundException {
+        return globalQuota.orElseThrow(QuotaNotFoundException::new);
+    }
+
+    @Override
+    public void setQuota(long quota) {
+        this.globalQuota = Optional.of(quota);
+    }
+
+    @Override
+    public void removeQuota() throws QuotaNotFoundException {
+        if (!globalQuota.isPresent()) {
+            throw new QuotaNotFoundException();
+        }
+        globalQuota = Optional.empty();
+    }
+
+    @Override
+    public boolean hasQuota(String user) {
+        return userQuota.containsKey(user);
+    }
+
+    @Override
+    public long getQuota(String user) throws QuotaNotFoundException {
+        return Optional.ofNullable(userQuota.get(user))
+            .orElseThrow(QuotaNotFoundException::new);
+    }
+
+    @Override
+    public void setQuota(String user, long quota) {
+        userQuota.put(user, quota);
+    }
+
+    @Override
+    public void removeQuota(String user) throws QuotaNotFoundException {
+        Optional<Long> quotaValue = Optional.ofNullable(userQuota.get(user));
+        if (!quotaValue.isPresent()) {
+            throw new QuotaNotFoundException();
+        }
+        userQuota.remove(user);
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/1914c7b8/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/InMemorySieveQuotaRepository.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/InMemorySieveQuotaRepository.java b/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/InMemorySieveQuotaRepository.java
deleted file mode 100644
index d3aedd0..0000000
--- a/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/InMemorySieveQuotaRepository.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-
-package org.apache.james.webadmin.routes;
-
-import java.util.Map;
-import java.util.Optional;
-import java.util.concurrent.ConcurrentHashMap;
-
-import org.apache.james.sieverepository.api.SieveQuotaRepository;
-import org.apache.james.sieverepository.api.exception.QuotaNotFoundException;
-
-public class InMemorySieveQuotaRepository implements SieveQuotaRepository {
-
-    private Optional<Long> globalQuota = Optional.empty();
-
-    private Map<String, Long> userQuota = new ConcurrentHashMap<>();
-
-    @Override
-    public boolean hasQuota() {
-        return globalQuota.isPresent();
-    }
-
-    @Override
-    public long getQuota() throws QuotaNotFoundException {
-        return globalQuota.orElseThrow(QuotaNotFoundException::new);
-    }
-
-    @Override
-    public void setQuota(long quota) {
-        this.globalQuota = Optional.of(quota);
-    }
-
-    @Override
-    public void removeQuota() throws QuotaNotFoundException {
-        if (!globalQuota.isPresent()) {
-            throw new QuotaNotFoundException();
-        }
-        globalQuota = Optional.empty();
-    }
-
-    @Override
-    public boolean hasQuota(String user) {
-        return userQuota.containsKey(user);
-    }
-
-    @Override
-    public long getQuota(String user) throws QuotaNotFoundException {
-        return Optional.ofNullable(userQuota.get(user))
-            .orElseThrow(QuotaNotFoundException::new);
-    }
-
-    @Override
-    public void setQuota(String user, long quota) {
-        userQuota.put(user, quota);
-    }
-
-    @Override
-    public void removeQuota(String user) throws QuotaNotFoundException {
-        Optional<Long> quotaValue = Optional.ofNullable(userQuota.get(user));
-        if (!quotaValue.isPresent()) {
-            throw new QuotaNotFoundException();
-        }
-        userQuota.remove(user);
-    }
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/1914c7b8/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/SieveQuotaRoutesTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/SieveQuotaRoutesTest.java b/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/SieveQuotaRoutesTest.java
index e127901..02d3ef1 100644
--- a/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/SieveQuotaRoutesTest.java
+++ b/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/SieveQuotaRoutesTest.java
@@ -27,6 +27,7 @@ import static org.assertj.core.api.Assertions.assertThat;
 
 import org.apache.james.metrics.logger.DefaultMetricFactory;
 import org.apache.james.sieverepository.api.SieveQuotaRepository;
+import org.apache.james.sieverepository.memory.InMemorySieveQuotaRepository;
 import org.apache.james.webadmin.WebAdminServer;
 import org.apache.james.webadmin.WebAdminUtils;
 import org.apache.james.webadmin.utils.JsonTransformer;


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


[05/20] james-project git commit: JAMES-2151 SieveRepository strong typing for User

Posted by bt...@apache.org.
http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/managesieve/ManageSieveMailetTestCase.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/managesieve/ManageSieveMailetTestCase.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/managesieve/ManageSieveMailetTestCase.java
index 0ca9a75..fd1d103 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/managesieve/ManageSieveMailetTestCase.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/managesieve/ManageSieveMailetTestCase.java
@@ -21,6 +21,7 @@
 package org.apache.james.transport.mailets.managesieve;
 
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Matchers.anyString;
 import static org.mockito.Mockito.doThrow;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
@@ -38,9 +39,12 @@ import javax.mail.internet.MimeMultipart;
 
 import org.apache.commons.io.IOUtils;
 import org.apache.james.core.MailAddress;
+import org.apache.james.core.User;
 import org.apache.james.core.builder.MimeMessageBuilder;
 import org.apache.james.managesieve.api.SieveParser;
 import org.apache.james.managesieve.api.SyntaxException;
+import org.apache.james.sieverepository.api.ScriptContent;
+import org.apache.james.sieverepository.api.ScriptName;
 import org.apache.james.sieverepository.api.ScriptSummary;
 import org.apache.james.sieverepository.api.SieveRepository;
 import org.apache.james.sieverepository.api.exception.ScriptNotFoundException;
@@ -56,12 +60,12 @@ import com.google.common.collect.Lists;
 
 public class ManageSieveMailetTestCase {
 
-    public static final String USER = "test@localhost";
-    public static final String SCRIPT_NAME = "scriptName";
-    public static final String SCRIPT_CONTENT = "scriptContent";
+    public static final User USER = User.fromUsername("test@localhost");
+    public static final ScriptName SCRIPT_NAME = new ScriptName("scriptName");
+    public static final ScriptContent SCRIPT_CONTENT = new ScriptContent("scriptContent");
     public static final String SYNTAX_EXCEPTION = "SyntaxException";
-    public static final String OLD_SCRIPT_NAME = "oldScriptName";
-    public static final String NEW_SCRIPT_NAME = "newScriptName";
+    public static final ScriptName OLD_SCRIPT_NAME = new ScriptName("oldScriptName");
+    public static final ScriptName NEW_SCRIPT_NAME = new ScriptName("newScriptName");
     public static final String SIEVE_LOCALHOST = "sieve@localhost";
 
     private ManageSieveMailet mailet;
@@ -76,7 +80,7 @@ public class ManageSieveMailetTestCase {
         sieveParser = mock(SieveParser.class);
         usersRepository = mock(UsersRepository.class);
         initializeMailet();
-        when(usersRepository.contains(USER)).thenReturn(true);
+        when(usersRepository.contains(USER.asString())).thenReturn(true);
     }
 
     @Test
@@ -131,7 +135,7 @@ public class ManageSieveMailetTestCase {
 
     @Test
     public final void testPutScript() throws Exception {
-        when(sieveParser.parse(SCRIPT_CONTENT)).thenReturn(Lists.newArrayList("warning1", "warning2"));
+        when(sieveParser.parse(anyString())).thenReturn(Lists.newArrayList("warning1", "warning2"));
         MimeMessage message = prepareMessageWithAttachment(SCRIPT_CONTENT, "PUTSCRIPT \"" + SCRIPT_NAME + "\" {100+}");
         Mail mail = createAuthentificatedMail(message);
         mailet.service(mail);
@@ -189,10 +193,10 @@ public class ManageSieveMailetTestCase {
 
     @Test
     public final void testGetScript() throws Exception {
-        when(sieveRepository.getScript(USER, SCRIPT_NAME)).thenReturn(new ByteArrayInputStream(SCRIPT_CONTENT.getBytes()));
+        when(sieveRepository.getScript(USER, SCRIPT_NAME)).thenReturn(new ByteArrayInputStream(SCRIPT_CONTENT.getValue().getBytes()));
         MimeMessage message = prepareMimeMessage("GETSCRIPT \"" + SCRIPT_NAME + "\"");
         Mail mail = createUnauthenticatedMail(message);
-        mail.setAttribute(Mail.SMTP_AUTH_USER_ATTRIBUTE_NAME, USER);
+        mail.setAttribute(Mail.SMTP_AUTH_USER_ATTRIBUTE_NAME, USER.asString());
         mailet.service(mail);
         ensureResponse("Re: GETSCRIPT \"" + SCRIPT_NAME + "\"", "{13}\r\n" + SCRIPT_CONTENT + "\r\nOK");
     }
@@ -210,19 +214,19 @@ public class ManageSieveMailetTestCase {
         doThrow(new ScriptNotFoundException()).when(sieveRepository).getScript(USER, SCRIPT_NAME);
         MimeMessage message = prepareMimeMessage("GETSCRIPT \"" + SCRIPT_NAME + "\"");
         Mail mail = createUnauthenticatedMail(message);
-        mail.setAttribute(Mail.SMTP_AUTH_USER_ATTRIBUTE_NAME, USER);
+        mail.setAttribute(Mail.SMTP_AUTH_USER_ATTRIBUTE_NAME, USER.asString());
         mailet.service(mail);
         ensureResponse("Re: GETSCRIPT \"" + SCRIPT_NAME + "\"", "NO (NONEXISTENT) \"There is no script by that name\"");
     }
 
     @Test
     public final void testGetScriptNoScriptName() throws Exception {
-        String scriptContent = "line1\r\nline2";
+        ScriptContent scriptContent = new ScriptContent("line1\r\nline2");
         sieveRepository.putScript(USER, SCRIPT_NAME, scriptContent);
         MimeMessage message = prepareMimeMessage("GETSCRIPT");
         Mail mail = createUnauthenticatedMail(message);
 
-        mail.setAttribute(Mail.SMTP_AUTH_USER_ATTRIBUTE_NAME, USER);
+        mail.setAttribute(Mail.SMTP_AUTH_USER_ATTRIBUTE_NAME, USER.asString());
         mailet.service(mail);
         ensureResponse("Re: GETSCRIPT", "NO \"Missing argument: script name\"");
     }
@@ -237,7 +241,7 @@ public class ManageSieveMailetTestCase {
 
     @Test
     public final void testCheckScript() throws Exception {
-        when(sieveParser.parse(SCRIPT_CONTENT)).thenReturn(Lists.newArrayList("warning1", "warning2"));
+        when(sieveParser.parse(anyString())).thenReturn(Lists.newArrayList("warning1", "warning2"));
         MimeMessage message = prepareMessageWithAttachment(SCRIPT_CONTENT, "CHECKSCRIPT {100+}");
         Mail mail = createAuthentificatedMail(message);
         mailet.service(mail);
@@ -367,7 +371,7 @@ public class ManageSieveMailetTestCase {
 
     @Test
     public final void testListScripts() throws Exception {
-        when(sieveRepository.listScripts(USER)).thenReturn(Lists.newArrayList(new ScriptSummary("scriptName2", true), new ScriptSummary("scriptName1", false)));
+        when(sieveRepository.listScripts(USER)).thenReturn(Lists.newArrayList(new ScriptSummary(new ScriptName("scriptName2"), true), new ScriptSummary(new ScriptName("scriptName1"), false)));
         MimeMessage message = prepareMimeMessage("LISTSCRIPTS");
         Mail mail = createAuthentificatedMail(message);
         mailet.service(mail);
@@ -384,7 +388,7 @@ public class ManageSieveMailetTestCase {
 
     @Test
     public final void testRenameScriptsUnauthorised() throws Exception {
-        sieveRepository.putScript(USER, OLD_SCRIPT_NAME, NEW_SCRIPT_NAME);
+        sieveRepository.putScript(USER, OLD_SCRIPT_NAME, SCRIPT_CONTENT);
         MimeMessage message = prepareMimeMessage("RENAMESCRIPT \"" + OLD_SCRIPT_NAME + "\" \"" + NEW_SCRIPT_NAME + "\"");
         Mail mail = createUnauthenticatedMail(message);
         mailet.service(mail);
@@ -393,7 +397,7 @@ public class ManageSieveMailetTestCase {
 
     @Test
     public final void testRenameScripts() throws Exception {
-        sieveRepository.putScript(USER, OLD_SCRIPT_NAME, NEW_SCRIPT_NAME);
+        sieveRepository.putScript(USER, OLD_SCRIPT_NAME, SCRIPT_CONTENT);
         MimeMessage message = prepareMimeMessage("RENAMESCRIPT \"" + OLD_SCRIPT_NAME + "\" \"" + NEW_SCRIPT_NAME + "\"");
         Mail mail = createAuthentificatedMail(message);
         mailet.service(mail);
@@ -402,7 +406,7 @@ public class ManageSieveMailetTestCase {
 
     @Test
     public final void testRenameScriptsExtraArgs() throws Exception {
-        sieveRepository.putScript(USER, OLD_SCRIPT_NAME, NEW_SCRIPT_NAME);
+        sieveRepository.putScript(USER, OLD_SCRIPT_NAME, SCRIPT_CONTENT);
         MimeMessage message = prepareMimeMessage("RENAMESCRIPT \"" + OLD_SCRIPT_NAME + "\" \"" + NEW_SCRIPT_NAME + "\" extra");
         Mail mail = createUnauthenticatedMail(message);
         mailet.service(mail);
@@ -411,7 +415,7 @@ public class ManageSieveMailetTestCase {
 
     @Test
     public final void testRenameScriptsNoScriptName() throws Exception {
-        sieveRepository.putScript(USER, OLD_SCRIPT_NAME, NEW_SCRIPT_NAME);
+        sieveRepository.putScript(USER, OLD_SCRIPT_NAME, SCRIPT_CONTENT);
         MimeMessage message = prepareMimeMessage("RENAMESCRIPT");
         Mail mail = createUnauthenticatedMail(message);
         mailet.service(mail);
@@ -420,7 +424,7 @@ public class ManageSieveMailetTestCase {
 
     @Test
     public final void testRenameScriptsNoNewScriptName() throws Exception {
-        sieveRepository.putScript(USER, OLD_SCRIPT_NAME, NEW_SCRIPT_NAME);
+        sieveRepository.putScript(USER, OLD_SCRIPT_NAME, SCRIPT_CONTENT);
         MimeMessage message = prepareMimeMessage("RENAMESCRIPT \"" + OLD_SCRIPT_NAME + "\"");
         Mail mail = createUnauthenticatedMail(message);
         mailet.service(mail);
@@ -503,7 +507,7 @@ public class ManageSieveMailetTestCase {
     private Mail createUnauthenticatedMail(MimeMessage message) throws Exception {
         return FakeMail.builder()
                 .mimeMessage(message)
-                .sender(USER)
+                .sender(USER.asString())
                 .recipient(SIEVE_LOCALHOST)
                 .build();
     }
@@ -518,20 +522,24 @@ public class ManageSieveMailetTestCase {
         return MimeMessageBuilder.mimeMessageBuilder()
             .setSubject(subject)
             .addToRecipient(SIEVE_LOCALHOST)
-            .setSender(USER)
+            .setSender(USER.asString())
             .build();
     }
 
+    private MimeMessage prepareMessageWithAttachment(ScriptContent scriptContent, String subject) throws MessagingException, IOException {
+        return prepareMessageWithAttachment(scriptContent.getValue(), subject);
+    }
+
     private MimeMessage prepareMessageWithAttachment(String scriptContent, String subject) throws MessagingException, IOException {
         return MimeMessageBuilder.mimeMessageBuilder()
             .setSubject(subject)
             .addToRecipient(SIEVE_LOCALHOST)
-            .setSender(USER)
+            .setSender(USER.asString())
             .setMultipartWithBodyParts(
                 MimeMessageBuilder.bodyPartBuilder()
                     .data(scriptContent)
                     .disposition(MimeBodyPart.ATTACHMENT)
-                    .filename(SCRIPT_NAME)
+                    .filename(SCRIPT_NAME.getValue())
                     .addHeader("Content-Type", "application/sieve; charset=UTF-8"))
             .build();
     }
@@ -557,14 +565,14 @@ public class ManageSieveMailetTestCase {
 
     private MimeMessage verifyHeaders(String subject) throws MessagingException {
         FakeMailContext.SentMail sentMail = FakeMailContext.sentMailBuilder()
-            .recipient(new MailAddress(USER))
+            .recipient(new MailAddress(USER.asString()))
             .sender(new MailAddress(SIEVE_LOCALHOST))
             .fromMailet()
             .build();
         assertThat(fakeMailContext.getSentMails()).containsOnly(sentMail);
         MimeMessage result = fakeMailContext.getSentMails().get(0).getMsg();
         assertThat(result.getSubject()).isEqualTo(subject);
-        assertThat(result.getRecipients(RecipientType.TO)).containsOnly(new InternetAddress(USER));
+        assertThat(result.getRecipients(RecipientType.TO)).containsOnly(new InternetAddress(USER.asString()));
         return result;
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/IsOverQuotaTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/IsOverQuotaTest.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/IsOverQuotaTest.java
index 018c00f..25e021f 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/IsOverQuotaTest.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/IsOverQuotaTest.java
@@ -26,14 +26,14 @@ import static org.mockito.Mockito.when;
 import java.util.Collection;
 
 import org.apache.james.core.MailAddress;
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.mailbox.acl.SimpleGroupMembershipResolver;
 import org.apache.james.mailbox.inmemory.manager.InMemoryIntegrationResources;
 import org.apache.james.mailbox.inmemory.quota.InMemoryCurrentQuotaManager;
 import org.apache.james.mailbox.inmemory.quota.InMemoryPerUserMaxQuotaManager;
 import org.apache.james.mailbox.model.MailboxPath;
 import org.apache.james.mailbox.model.QuotaRoot;
-import org.apache.james.mailbox.quota.QuotaCount;
-import org.apache.james.mailbox.quota.QuotaSize;
 import org.apache.james.mailbox.store.StoreMailboxManager;
 import org.apache.james.mailbox.store.quota.CurrentQuotaCalculator;
 import org.apache.james.mailbox.store.quota.DefaultUserQuotaRootResolver;

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMailboxesMethodTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMailboxesMethodTest.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMailboxesMethodTest.java
index 6602882..8348fe2 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMailboxesMethodTest.java
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMailboxesMethodTest.java
@@ -54,6 +54,8 @@ import java.util.Map;
 import java.util.Optional;
 
 import org.apache.james.GuiceJamesServer;
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.jmap.api.access.AccessToken;
 import org.apache.james.jmap.model.mailbox.MailboxNamespace;
 import org.apache.james.mailbox.DefaultMailboxes;
@@ -63,8 +65,6 @@ import org.apache.james.mailbox.model.MailboxACL.Right;
 import org.apache.james.mailbox.model.MailboxConstants;
 import org.apache.james.mailbox.model.MailboxId;
 import org.apache.james.mailbox.model.MailboxPath;
-import org.apache.james.mailbox.quota.QuotaCount;
-import org.apache.james.mailbox.quota.QuotaSize;
 import org.apache.james.mailbox.store.mail.model.Mailbox;
 import org.apache.james.mailbox.store.mail.model.SerializableQuotaValue;
 import org.apache.james.mailbox.store.probe.ACLProbe;

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/QuotaMailingTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/QuotaMailingTest.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/QuotaMailingTest.java
index 4753add..420a18e 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/QuotaMailingTest.java
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/QuotaMailingTest.java
@@ -38,10 +38,10 @@ import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
 
 import org.apache.james.GuiceJamesServer;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.jmap.api.access.AccessToken;
 import org.apache.james.mailbox.DefaultMailboxes;
 import org.apache.james.mailbox.model.MailboxConstants;
-import org.apache.james.mailbox.quota.QuotaSize;
 import org.apache.james.mailbox.store.mail.model.SerializableQuotaValue;
 import org.apache.james.mailbox.store.probe.MailboxProbe;
 import org.apache.james.modules.MailboxProbeImpl;

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SendMDNMethodTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SendMDNMethodTest.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SendMDNMethodTest.java
index f7602a5..e272ea7 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SendMDNMethodTest.java
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SendMDNMethodTest.java
@@ -45,13 +45,13 @@ import java.util.List;
 import java.util.Optional;
 
 import org.apache.james.GuiceJamesServer;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.jmap.MessageAppender;
 import org.apache.james.jmap.api.access.AccessToken;
 import org.apache.james.mailbox.DefaultMailboxes;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.model.MailboxConstants;
 import org.apache.james.mailbox.model.MessageId;
-import org.apache.james.mailbox.quota.QuotaSize;
 import org.apache.james.mailbox.store.mail.model.SerializableQuotaValue;
 import org.apache.james.mailbox.store.probe.MailboxProbe;
 import org.apache.james.mailbox.store.probe.QuotaProbe;

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMessagesMethodTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMessagesMethodTest.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMessagesMethodTest.java
index a886af8..3d5fda6 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMessagesMethodTest.java
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMessagesMethodTest.java
@@ -75,6 +75,7 @@ import javax.mail.internet.MimeMessage;
 
 import org.apache.commons.io.IOUtils;
 import org.apache.james.GuiceJamesServer;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.jmap.HttpJmapAuthentication;
 import org.apache.james.jmap.MessageAppender;
 import org.apache.james.jmap.api.access.AccessToken;
@@ -92,7 +93,6 @@ import org.apache.james.mailbox.model.MailboxId;
 import org.apache.james.mailbox.model.MailboxPath;
 import org.apache.james.mailbox.model.MessageId;
 import org.apache.james.mailbox.model.MessageResult;
-import org.apache.james.mailbox.quota.QuotaSize;
 import org.apache.james.mailbox.store.event.EventFactory;
 import org.apache.james.mailbox.store.mail.model.SerializableQuotaValue;
 import org.apache.james.mailbox.store.probe.ACLProbe;

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/MailboxFactory.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/MailboxFactory.java b/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/MailboxFactory.java
index afac80c..94310a2 100644
--- a/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/MailboxFactory.java
+++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/MailboxFactory.java
@@ -23,6 +23,7 @@ import java.util.Optional;
 
 import javax.inject.Inject;
 
+import org.apache.james.core.quota.QuotaValue;
 import org.apache.james.jmap.model.mailbox.Mailbox;
 import org.apache.james.jmap.model.mailbox.MailboxNamespace;
 import org.apache.james.jmap.model.mailbox.Quotas;
@@ -44,7 +45,6 @@ import org.apache.james.mailbox.model.Quota;
 import org.apache.james.mailbox.model.QuotaRoot;
 import org.apache.james.mailbox.quota.QuotaManager;
 import org.apache.james.mailbox.quota.QuotaRootResolver;
-import org.apache.james.mailbox.quota.QuotaValue;
 
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Preconditions;

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/mailbox/Quotas.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/mailbox/Quotas.java b/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/mailbox/Quotas.java
index 1579f32..30ae9a2 100644
--- a/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/mailbox/Quotas.java
+++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/mailbox/Quotas.java
@@ -21,11 +21,11 @@ package org.apache.james.jmap.model.mailbox;
 import java.util.Map;
 import java.util.Optional;
 
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
+import org.apache.james.core.quota.QuotaValue;
 import org.apache.james.jmap.model.Number;
 import org.apache.james.mailbox.model.QuotaRoot;
-import org.apache.james.mailbox.quota.QuotaCount;
-import org.apache.james.mailbox.quota.QuotaSize;
-import org.apache.james.mailbox.quota.QuotaValue;
 
 import com.fasterxml.jackson.annotation.JsonValue;
 import com.google.common.collect.ImmutableMap;

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/SieveQuotaRoutes.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/SieveQuotaRoutes.java b/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/SieveQuotaRoutes.java
index 1c779db..c0abc61 100644
--- a/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/SieveQuotaRoutes.java
+++ b/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/SieveQuotaRoutes.java
@@ -28,6 +28,8 @@ import javax.ws.rs.PUT;
 import javax.ws.rs.Path;
 import javax.ws.rs.Produces;
 
+import org.apache.james.core.User;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.sieverepository.api.SieveQuotaRepository;
 import org.apache.james.sieverepository.api.exception.QuotaNotFoundException;
 import org.apache.james.webadmin.Constants;
@@ -92,9 +94,9 @@ public class SieveQuotaRoutes implements Routes {
     public void defineGetGlobalSieveQuota(Service service) {
         service.get(ROOT_PATH, (request, response) -> {
             try {
-                long sieveQuota = sieveQuotaRepository.getQuota();
+                QuotaSize sieveQuota = sieveQuotaRepository.getQuota();
                 response.status(HttpStatus.OK_200);
-                return sieveQuota;
+                return sieveQuota.asLong();
             } catch (QuotaNotFoundException e) {
                 LOGGER.info("Global sieve quota not set", e);
                 throw ErrorResponder.builder()
@@ -119,7 +121,7 @@ public class SieveQuotaRoutes implements Routes {
     public void defineUpdateGlobalSieveQuota(Service service) {
         service.put(ROOT_PATH, (request, response) -> {
             try {
-                Long requestedSize = extractRequestedQuotaSizeFromRequest(request);
+                QuotaSize requestedSize = extractRequestedQuotaSizeFromRequest(request);
                 sieveQuotaRepository.setQuota(requestedSize);
                 response.status(HttpStatus.NO_CONTENT_204);
                 return Constants.EMPTY_BODY;
@@ -171,11 +173,11 @@ public class SieveQuotaRoutes implements Routes {
     })
     public void defineGetPerUserSieveQuota(Service service) {
         service.get(USER_SIEVE_QUOTA_PATH, (request, response) -> {
-            String userId = request.params(USER_ID);
+            User userId = User.fromUsername(request.params(USER_ID));
             try {
-                long userQuota = sieveQuotaRepository.getQuota(userId);
+                QuotaSize userQuota = sieveQuotaRepository.getQuota(userId);
                 response.status(HttpStatus.OK_200);
-                return userQuota;
+                return userQuota.asLong();
             } catch (QuotaNotFoundException e) {
                 LOGGER.info("User sieve quota not set", e);
                 throw ErrorResponder.builder()
@@ -200,9 +202,9 @@ public class SieveQuotaRoutes implements Routes {
     })
     public void defineUpdatePerUserSieveQuota(Service service) {
         service.put(USER_SIEVE_QUOTA_PATH, (request, response) -> {
-            String userId = request.params(USER_ID);
+            User userId = User.fromUsername(request.params(USER_ID));
             try {
-                Long requestedSize = extractRequestedQuotaSizeFromRequest(request);
+                QuotaSize requestedSize = extractRequestedQuotaSizeFromRequest(request);
                 sieveQuotaRepository.setQuota(userId, requestedSize);
                 response.status(HttpStatus.NO_CONTENT_204);
             } catch (JsonExtractException e) {
@@ -230,7 +232,7 @@ public class SieveQuotaRoutes implements Routes {
     })
     public void defineRemovePerUserSieveQuota(Service service) {
         service.delete(USER_SIEVE_QUOTA_PATH, (request, response) -> {
-            String userId = request.params(USER_ID);
+            User userId = User.fromUsername(request.params(USER_ID));
             try {
                 sieveQuotaRepository.removeQuota(userId);
                 response.status(HttpStatus.NO_CONTENT_204);
@@ -246,7 +248,7 @@ public class SieveQuotaRoutes implements Routes {
         });
     }
 
-    private Long extractRequestedQuotaSizeFromRequest(Request request) throws JsonExtractException {
+    private QuotaSize extractRequestedQuotaSizeFromRequest(Request request) throws JsonExtractException {
         Long requestedSize = jsonExtractor.parse(request.body());
         if (requestedSize < 0) {
             throw ErrorResponder.builder()
@@ -255,6 +257,6 @@ public class SieveQuotaRoutes implements Routes {
                 .message("Requested quota size have to be a positive integer")
                 .haltError();
         }
-        return requestedSize;
+        return QuotaSize.size(requestedSize);
     }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/dto/OccupationDTO.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/dto/OccupationDTO.java b/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/dto/OccupationDTO.java
index ca85a37..455de1d 100644
--- a/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/dto/OccupationDTO.java
+++ b/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/dto/OccupationDTO.java
@@ -19,9 +19,9 @@
 
 package org.apache.james.webadmin.dto;
 
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.mailbox.model.Quota;
-import org.apache.james.mailbox.quota.QuotaCount;
-import org.apache.james.mailbox.quota.QuotaSize;
 
 public class OccupationDTO {
     public static OccupationDTO from(Quota<QuotaSize> sizeQuota, Quota<QuotaCount> countQuota) {

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/dto/OccupationRatioDTO.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/dto/OccupationRatioDTO.java b/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/dto/OccupationRatioDTO.java
index 2189aa2..d3fc923 100644
--- a/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/dto/OccupationRatioDTO.java
+++ b/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/dto/OccupationRatioDTO.java
@@ -19,10 +19,10 @@
 
 package org.apache.james.webadmin.dto;
 
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.mailbox.model.Quota;
 import org.apache.james.mailbox.model.QuotaRatio;
-import org.apache.james.mailbox.quota.QuotaCount;
-import org.apache.james.mailbox.quota.QuotaSize;
 
 public class OccupationRatioDTO {
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/dto/QuotaDTO.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/dto/QuotaDTO.java b/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/dto/QuotaDTO.java
index b48f1f9..9a02cc6 100644
--- a/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/dto/QuotaDTO.java
+++ b/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/dto/QuotaDTO.java
@@ -23,8 +23,8 @@ package org.apache.james.webadmin.dto;
 import java.util.Objects;
 import java.util.Optional;
 
-import org.apache.james.mailbox.quota.QuotaCount;
-import org.apache.james.mailbox.quota.QuotaSize;
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
 
 import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
 import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder;

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/dto/QuotaDetailsDTO.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/dto/QuotaDetailsDTO.java b/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/dto/QuotaDetailsDTO.java
index e365ecc..9042122 100644
--- a/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/dto/QuotaDetailsDTO.java
+++ b/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/dto/QuotaDetailsDTO.java
@@ -22,9 +22,9 @@ package org.apache.james.webadmin.dto;
 
 import java.util.Optional;
 
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.mailbox.model.Quota;
-import org.apache.james.mailbox.quota.QuotaCount;
-import org.apache.james.mailbox.quota.QuotaSize;
 
 import com.google.common.base.Preconditions;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/dto/QuotaValueDeserializer.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/dto/QuotaValueDeserializer.java b/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/dto/QuotaValueDeserializer.java
index 52cef2e..9a2a7e8 100644
--- a/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/dto/QuotaValueDeserializer.java
+++ b/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/dto/QuotaValueDeserializer.java
@@ -21,7 +21,7 @@ package org.apache.james.webadmin.dto;
 import java.io.IOException;
 import java.util.function.Function;
 
-import org.apache.james.mailbox.quota.QuotaValue;
+import org.apache.james.core.quota.QuotaValue;
 
 import com.fasterxml.jackson.core.JsonParser;
 import com.fasterxml.jackson.databind.DeserializationContext;

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/dto/QuotaValueSerializer.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/dto/QuotaValueSerializer.java b/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/dto/QuotaValueSerializer.java
index f683558..3c4067b 100644
--- a/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/dto/QuotaValueSerializer.java
+++ b/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/dto/QuotaValueSerializer.java
@@ -20,7 +20,7 @@ package org.apache.james.webadmin.dto;
 
 import java.io.IOException;
 
-import org.apache.james.mailbox.quota.QuotaValue;
+import org.apache.james.core.quota.QuotaValue;
 
 import com.fasterxml.jackson.core.JsonGenerator;
 import com.fasterxml.jackson.databind.JsonSerializer;

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/jackson/QuotaModule.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/jackson/QuotaModule.java b/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/jackson/QuotaModule.java
index 2188fd5..003226a 100644
--- a/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/jackson/QuotaModule.java
+++ b/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/jackson/QuotaModule.java
@@ -18,8 +18,8 @@
  ****************************************************************/
 package org.apache.james.webadmin.jackson;
 
-import org.apache.james.mailbox.quota.QuotaCount;
-import org.apache.james.mailbox.quota.QuotaSize;
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.webadmin.dto.QuotaValueDeserializer;
 import org.apache.james.webadmin.dto.QuotaValueSerializer;
 import org.apache.james.webadmin.utils.JsonTransformerModule;

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/routes/DomainQuotaRoutes.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/routes/DomainQuotaRoutes.java b/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/routes/DomainQuotaRoutes.java
index 7fedff1..5c40253 100644
--- a/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/routes/DomainQuotaRoutes.java
+++ b/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/routes/DomainQuotaRoutes.java
@@ -31,10 +31,10 @@ import javax.ws.rs.Path;
 import javax.ws.rs.Produces;
 
 import org.apache.james.core.Domain;
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.domainlist.api.DomainList;
 import org.apache.james.domainlist.api.DomainListException;
-import org.apache.james.mailbox.quota.QuotaCount;
-import org.apache.james.mailbox.quota.QuotaSize;
 import org.apache.james.user.api.UsersRepository;
 import org.apache.james.user.api.UsersRepositoryException;
 import org.apache.james.webadmin.Routes;

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/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 1054ad4..b96927e 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
@@ -28,9 +28,9 @@ import javax.ws.rs.PUT;
 import javax.ws.rs.Path;
 import javax.ws.rs.Produces;
 
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.mailbox.exception.MailboxException;
-import org.apache.james.mailbox.quota.QuotaCount;
-import org.apache.james.mailbox.quota.QuotaSize;
 import org.apache.james.webadmin.Routes;
 import org.apache.james.webadmin.dto.QuotaDTO;
 import org.apache.james.webadmin.jackson.QuotaModule;

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/routes/UserQuotaRoutes.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/routes/UserQuotaRoutes.java b/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/routes/UserQuotaRoutes.java
index 4b8a310..3024d72 100644
--- a/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/routes/UserQuotaRoutes.java
+++ b/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/routes/UserQuotaRoutes.java
@@ -35,8 +35,8 @@ import javax.ws.rs.Produces;
 
 import org.apache.james.core.Domain;
 import org.apache.james.core.User;
-import org.apache.james.mailbox.quota.QuotaCount;
-import org.apache.james.mailbox.quota.QuotaSize;
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.quota.search.Limit;
 import org.apache.james.quota.search.Offset;
 import org.apache.james.quota.search.QuotaBoundary;

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/service/DomainQuotaService.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/service/DomainQuotaService.java b/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/service/DomainQuotaService.java
index c0ad607..525e041 100644
--- a/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/service/DomainQuotaService.java
+++ b/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/service/DomainQuotaService.java
@@ -24,10 +24,10 @@ import java.util.Optional;
 import javax.inject.Inject;
 
 import org.apache.james.core.Domain;
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.quota.MaxQuotaManager;
-import org.apache.james.mailbox.quota.QuotaCount;
-import org.apache.james.mailbox.quota.QuotaSize;
 import org.apache.james.webadmin.dto.QuotaDTO;
 
 import com.github.fge.lambdas.Throwing;

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/service/GlobalQuotaService.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/service/GlobalQuotaService.java b/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/service/GlobalQuotaService.java
index 5619429..83e7a32 100644
--- a/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/service/GlobalQuotaService.java
+++ b/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/service/GlobalQuotaService.java
@@ -22,10 +22,10 @@ import java.util.Optional;
 
 import javax.inject.Inject;
 
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.quota.MaxQuotaManager;
-import org.apache.james.mailbox.quota.QuotaCount;
-import org.apache.james.mailbox.quota.QuotaSize;
 import org.apache.james.webadmin.dto.QuotaDTO;
 
 public class GlobalQuotaService {

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/service/UserQuotaService.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/service/UserQuotaService.java b/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/service/UserQuotaService.java
index 6fdb9c0..03969b4 100644
--- a/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/service/UserQuotaService.java
+++ b/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/service/UserQuotaService.java
@@ -27,13 +27,13 @@ import java.util.stream.Collectors;
 import javax.inject.Inject;
 
 import org.apache.james.core.User;
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.model.Quota;
 import org.apache.james.mailbox.model.QuotaRoot;
 import org.apache.james.mailbox.quota.MaxQuotaManager;
-import org.apache.james.mailbox.quota.QuotaCount;
 import org.apache.james.mailbox.quota.QuotaManager;
-import org.apache.james.mailbox.quota.QuotaSize;
 import org.apache.james.mailbox.quota.UserQuotaRootResolver;
 import org.apache.james.quota.search.QuotaQuery;
 import org.apache.james.quota.search.QuotaSearcher;

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/validation/Quotas.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/validation/Quotas.java b/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/validation/Quotas.java
index b088621..523fbbc 100644
--- a/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/validation/Quotas.java
+++ b/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/validation/Quotas.java
@@ -21,8 +21,8 @@ package org.apache.james.webadmin.validation;
 
 import java.util.Optional;
 
-import org.apache.james.mailbox.quota.QuotaCount;
-import org.apache.james.mailbox.quota.QuotaSize;
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.webadmin.utils.ErrorResponder;
 import org.eclipse.jetty.http.HttpStatus;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/dto/QuotaValueDeserializerTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/dto/QuotaValueDeserializerTest.java b/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/dto/QuotaValueDeserializerTest.java
index e47256a..8cb7f28 100644
--- a/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/dto/QuotaValueDeserializerTest.java
+++ b/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/dto/QuotaValueDeserializerTest.java
@@ -18,8 +18,8 @@
  ****************************************************************/
 package org.apache.james.webadmin.dto;
 
-import org.apache.james.mailbox.quota.QuotaCount;
-import org.apache.james.mailbox.quota.QuotaSize;
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.webadmin.utils.JsonExtractException;
 import org.apache.james.webadmin.utils.JsonExtractor;
 import org.assertj.core.api.Assertions;

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/dto/UsersQuotaDetailsDTOTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/dto/UsersQuotaDetailsDTOTest.java b/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/dto/UsersQuotaDetailsDTOTest.java
index d96915d..d6592e2 100644
--- a/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/dto/UsersQuotaDetailsDTOTest.java
+++ b/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/dto/UsersQuotaDetailsDTOTest.java
@@ -24,9 +24,9 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
 import javax.mail.internet.AddressException;
 
 import org.apache.james.core.User;
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.mailbox.model.Quota;
-import org.apache.james.mailbox.quota.QuotaCount;
-import org.apache.james.mailbox.quota.QuotaSize;
 import org.junit.Test;
 
 public class UsersQuotaDetailsDTOTest {

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/DomainQuotaRoutesTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/DomainQuotaRoutesTest.java b/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/DomainQuotaRoutesTest.java
index b27c0d6..f8548b2 100644
--- a/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/DomainQuotaRoutesTest.java
+++ b/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/DomainQuotaRoutesTest.java
@@ -26,9 +26,9 @@ import static org.assertj.core.api.Assertions.assertThat;
 import java.util.Map;
 
 import org.apache.james.core.Domain;
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.mailbox.quota.MaxQuotaManager;
-import org.apache.james.mailbox.quota.QuotaCount;
-import org.apache.james.mailbox.quota.QuotaSize;
 import org.eclipse.jetty.http.HttpStatus;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/GlobalQuotaRoutesTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/GlobalQuotaRoutesTest.java b/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/GlobalQuotaRoutesTest.java
index cb3380d..25bd32e 100644
--- a/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/GlobalQuotaRoutesTest.java
+++ b/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/GlobalQuotaRoutesTest.java
@@ -25,9 +25,9 @@ import static org.assertj.core.api.Assertions.assertThat;
 
 import java.util.Map;
 
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.mailbox.quota.MaxQuotaManager;
-import org.apache.james.mailbox.quota.QuotaCount;
-import org.apache.james.mailbox.quota.QuotaSize;
 import org.assertj.core.api.SoftAssertions;
 import org.eclipse.jetty.http.HttpStatus;
 import org.junit.jupiter.api.BeforeEach;

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/UserQuotaRoutesTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/UserQuotaRoutesTest.java b/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/UserQuotaRoutesTest.java
index 694cea4..a2299ca 100644
--- a/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/UserQuotaRoutesTest.java
+++ b/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/UserQuotaRoutesTest.java
@@ -35,6 +35,8 @@ import java.util.Map;
 
 import org.apache.james.core.Domain;
 import org.apache.james.core.User;
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.domainlist.api.DomainList;
 import org.apache.james.mailbox.MailboxManager;
 import org.apache.james.mailbox.MailboxSession;
@@ -43,8 +45,6 @@ import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.inmemory.quota.InMemoryCurrentQuotaManager;
 import org.apache.james.mailbox.model.MailboxPath;
 import org.apache.james.mailbox.quota.MaxQuotaManager;
-import org.apache.james.mailbox.quota.QuotaCount;
-import org.apache.james.mailbox.quota.QuotaSize;
 import org.apache.james.mailbox.quota.UserQuotaRootResolver;
 import org.apache.james.quota.search.QuotaSearchTestSystem;
 import org.apache.james.user.api.UsersRepository;

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/validation/QuotaValueTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/validation/QuotaValueTest.java b/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/validation/QuotaValueTest.java
index d38d78a..23f88ce 100644
--- a/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/validation/QuotaValueTest.java
+++ b/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/validation/QuotaValueTest.java
@@ -22,8 +22,8 @@ package org.apache.james.webadmin.validation;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
 
-import org.apache.james.mailbox.quota.QuotaCount;
-import org.apache.james.mailbox.quota.QuotaSize;
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
 import org.junit.jupiter.api.Test;
 
 import spark.HaltException;


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


[17/20] james-project git commit: JAMES-2439 Allow to disable JMX

Posted by bt...@apache.org.
JAMES-2439 Allow to disable JMX


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

Branch: refs/heads/master
Commit: a2e1b1d23b03e66086c0919353417c48975fb059
Parents: 3c3c8fc
Author: benwa <bt...@linagora.com>
Authored: Mon Jun 25 11:50:04 2018 +0700
Committer: benwa <bt...@linagora.com>
Committed: Tue Jun 26 16:11:09 2018 +0700

----------------------------------------------------------------------
 .../apache/james/modules/server/JMXServer.java  |  3 ++
 .../james/modules/server/JmxConfiguration.java  | 36 ++++++++++++++++----
 .../modules/server/JmxConfigurationTest.java    | 25 +++++++++++++-
 3 files changed, 56 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/a2e1b1d2/server/container/guice/jmx/src/main/java/org/apache/james/modules/server/JMXServer.java
----------------------------------------------------------------------
diff --git a/server/container/guice/jmx/src/main/java/org/apache/james/modules/server/JMXServer.java b/server/container/guice/jmx/src/main/java/org/apache/james/modules/server/JMXServer.java
index 130b572..7d37c14 100644
--- a/server/container/guice/jmx/src/main/java/org/apache/james/modules/server/JMXServer.java
+++ b/server/container/guice/jmx/src/main/java/org/apache/james/modules/server/JMXServer.java
@@ -57,6 +57,9 @@ public class JMXServer {
 
     public void start() {
         synchronized (lock) {
+            if (!jmxConfiguration.isEnabled()) {
+                return;
+            }
             if (isStarted) {
                 return;
             }

http://git-wip-us.apache.org/repos/asf/james-project/blob/a2e1b1d2/server/container/guice/jmx/src/main/java/org/apache/james/modules/server/JmxConfiguration.java
----------------------------------------------------------------------
diff --git a/server/container/guice/jmx/src/main/java/org/apache/james/modules/server/JmxConfiguration.java b/server/container/guice/jmx/src/main/java/org/apache/james/modules/server/JmxConfiguration.java
index 793e930..05ceb32 100644
--- a/server/container/guice/jmx/src/main/java/org/apache/james/modules/server/JmxConfiguration.java
+++ b/server/container/guice/jmx/src/main/java/org/apache/james/modules/server/JmxConfiguration.java
@@ -20,35 +20,56 @@
 package org.apache.james.modules.server;
 
 import java.util.Objects;
+import java.util.Optional;
 
 import org.apache.commons.configuration.PropertiesConfiguration;
 import org.apache.james.util.Host;
 
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.MoreObjects;
+import com.google.common.base.Preconditions;
 
 public class JmxConfiguration {
 
     public static final String LOCALHOST = "localhost";
     public static final int DEFAULT_PORT = 9999;
+    public static final boolean ENABLED = true;
 
-    public static final JmxConfiguration DEFAULT_CONFIGURATION = new JmxConfiguration(Host.from(LOCALHOST, DEFAULT_PORT));
+    public static final JmxConfiguration DEFAULT_CONFIGURATION = new JmxConfiguration(ENABLED, Optional.of(Host.from(LOCALHOST, DEFAULT_PORT)));
+    public static final JmxConfiguration DISABLED = new JmxConfiguration(!ENABLED, Optional.empty());
 
     public static JmxConfiguration fromProperties(PropertiesConfiguration configuration) {
+        boolean jmxEnabled = configuration.getBoolean("jmx.enabled", true);
+        if (!jmxEnabled) {
+            return DISABLED;
+        }
+
         String address = configuration.getString("jmx.address", LOCALHOST);
         int port = configuration.getInt("jmx.port", DEFAULT_PORT);
-        return new JmxConfiguration(Host.from(address, port));
+        return new JmxConfiguration(ENABLED, Optional.of(Host.from(address, port)));
     }
 
-    private final Host host;
+    private final boolean enabled;
+    private final Optional<Host> host;
 
     @VisibleForTesting
-    JmxConfiguration(Host host) {
+    JmxConfiguration(boolean enabled, Optional<Host> host) {
+        Preconditions.checkArgument(disabledOrHasHost(enabled, host), "Specifying a host is compulsory when JMX is enabled");
+        this.enabled = enabled;
         this.host = host;
     }
 
+    private boolean disabledOrHasHost(boolean enabled, Optional<Host> host) {
+        return !enabled || host.isPresent();
+    }
+
+    public boolean isEnabled() {
+        return enabled;
+    }
+
     public Host getHost() {
-        return host;
+        Preconditions.checkState(isEnabled(), "Trying to access JMX host while JMX is not enabled");
+        return host.get();
     }
 
     @Override
@@ -56,14 +77,15 @@ public class JmxConfiguration {
         if (o instanceof JmxConfiguration) {
             JmxConfiguration that = (JmxConfiguration) o;
 
-            return Objects.equals(this.host, that.host);
+            return Objects.equals(this.host, that.host)
+                && Objects.equals(this.enabled, that.enabled);
         }
         return false;
     }
 
     @Override
     public final int hashCode() {
-        return Objects.hash(host);
+        return Objects.hash(host, enabled);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/james-project/blob/a2e1b1d2/server/container/guice/jmx/src/test/java/org/apache/james/modules/server/JmxConfigurationTest.java
----------------------------------------------------------------------
diff --git a/server/container/guice/jmx/src/test/java/org/apache/james/modules/server/JmxConfigurationTest.java b/server/container/guice/jmx/src/test/java/org/apache/james/modules/server/JmxConfigurationTest.java
index a727b58..604d4f6 100644
--- a/server/container/guice/jmx/src/test/java/org/apache/james/modules/server/JmxConfigurationTest.java
+++ b/server/container/guice/jmx/src/test/java/org/apache/james/modules/server/JmxConfigurationTest.java
@@ -22,6 +22,7 @@ package org.apache.james.modules.server;
 import static org.assertj.core.api.Assertions.assertThat;
 
 import java.io.StringReader;
+import java.util.Optional;
 
 import org.apache.commons.configuration.PropertiesConfiguration;
 import org.apache.james.util.Host;
@@ -50,6 +51,28 @@ public class JmxConfigurationTest {
                 "jmx.port=889\n"));
 
         assertThat(JmxConfiguration.fromProperties(configuration))
-            .isEqualTo(new JmxConfiguration(Host.from("172.0.0.5", 889)));
+            .isEqualTo(new JmxConfiguration(JmxConfiguration.ENABLED, Optional.of(Host.from("172.0.0.5", 889))));
+    }
+
+    @Test
+    void fromPropertiesShouldReturnDisabledWhenConfiguredAsDisabled() throws Exception {
+        PropertiesConfiguration configuration = new PropertiesConfiguration();
+        configuration.load(new StringReader(
+                    "jmx.enabled=false\n"));
+
+        assertThat(JmxConfiguration.fromProperties(configuration))
+            .isEqualTo(JmxConfiguration.DISABLED);
+    }
+
+    @Test
+    void fromPropertiesShouldReturnDisabledWhenConfiguredAsDisabledWithHost() throws Exception {
+        PropertiesConfiguration configuration = new PropertiesConfiguration();
+        configuration.load(new StringReader(
+                    "jmx.enabled=false\n" +
+                "jmx.address=172.0.0.5\n" +
+                "jmx.port=889\n"));
+
+        assertThat(JmxConfiguration.fromProperties(configuration))
+            .isEqualTo(JmxConfiguration.DISABLED);
     }
 }


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


[06/20] james-project git commit: JAMES-2151 SieveRepository strong typing for User

Posted by bt...@apache.org.
http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/server/data/data-cassandra/src/main/java/org/apache/james/sieve/cassandra/CassandraSieveDAO.java
----------------------------------------------------------------------
diff --git a/server/data/data-cassandra/src/main/java/org/apache/james/sieve/cassandra/CassandraSieveDAO.java b/server/data/data-cassandra/src/main/java/org/apache/james/sieve/cassandra/CassandraSieveDAO.java
index 9e3c7aa..429ca4b 100644
--- a/server/data/data-cassandra/src/main/java/org/apache/james/sieve/cassandra/CassandraSieveDAO.java
+++ b/server/data/data-cassandra/src/main/java/org/apache/james/sieve/cassandra/CassandraSieveDAO.java
@@ -40,7 +40,9 @@ import java.util.concurrent.CompletableFuture;
 import javax.inject.Inject;
 
 import org.apache.james.backends.cassandra.utils.CassandraAsyncExecutor;
+import org.apache.james.core.User;
 import org.apache.james.sieve.cassandra.model.Script;
+import org.apache.james.sieverepository.api.ScriptName;
 import org.apache.james.sieverepository.api.ScriptSummary;
 
 import com.datastax.driver.core.PreparedStatement;
@@ -96,37 +98,37 @@ public class CassandraSieveDAO {
             .where(eq(USER_NAME, bindMarker(USER_NAME)));
     }
 
-    public CompletableFuture<Void> insertScript(String user, Script script) {
+    public CompletableFuture<Void> insertScript(User user, Script script) {
         return cassandraAsyncExecutor.executeVoid(
             insertScriptStatement.bind()
-                .setString(USER_NAME, user)
-                .setString(SCRIPT_NAME, script.getName())
-                .setString(SCRIPT_CONTENT, script.getContent())
+                .setString(USER_NAME, user.asString())
+                .setString(SCRIPT_NAME, script.getName().getValue())
+                .setString(SCRIPT_CONTENT, script.getContent().getValue())
                 .setBool(IS_ACTIVE, script.isActive())
                 .setLong(SIZE, script.getSize()));
     }
 
-    public CompletableFuture<List<ScriptSummary>> listScripts(String user) {
+    public CompletableFuture<List<ScriptSummary>> listScripts(User user) {
         return cassandraAsyncExecutor.execute(
             selectScriptsStatement.bind()
-                .setString(USER_NAME, user))
+                .setString(USER_NAME, user.asString()))
             .thenApply(resultSet -> resultSet.all()
                 .stream()
                 .map(row -> new ScriptSummary(
-                    row.getString(SCRIPT_NAME),
+                    new ScriptName(row.getString(SCRIPT_NAME)),
                     row.getBool(IS_ACTIVE)))
                 .collect(Guavate.toImmutableList()));
     }
 
-    public CompletableFuture<Boolean> updateScriptActivation(String user, String scriptName, boolean active) {
+    public CompletableFuture<Boolean> updateScriptActivation(User user, ScriptName scriptName, boolean active) {
         return cassandraAsyncExecutor.executeReturnApplied(
             updateScriptActivationStatement.bind()
-                .setString(USER_NAME, user)
-                .setString(SCRIPT_NAME, scriptName)
+                .setString(USER_NAME, user.asString())
+                .setString(SCRIPT_NAME, scriptName.getValue())
                 .setBool(IS_ACTIVE, active));
     }
 
-    public CompletableFuture<Optional<Script>> getScript(String user, String name) {
+    public CompletableFuture<Optional<Script>> getScript(User user, ScriptName name) {
         return getScriptRow(user, name).thenApply(opt -> opt.map(row -> Script.builder()
                 .content(row.getString(SCRIPT_CONTENT))
                 .isActive(row.getBool(IS_ACTIVE))
@@ -135,18 +137,18 @@ public class CassandraSieveDAO {
                 .build()));
     }
 
-    public CompletableFuture<Boolean> deleteScriptInCassandra(String user, String name) {
+    public CompletableFuture<Boolean> deleteScriptInCassandra(User user, ScriptName name) {
         return cassandraAsyncExecutor.executeReturnApplied(
             deleteScriptStatement.bind()
-                .setString(USER_NAME, user)
-                .setString(SCRIPT_NAME, name));
+                .setString(USER_NAME, user.asString())
+                .setString(SCRIPT_NAME, name.getValue()));
     }
 
-    private CompletableFuture<Optional<Row>> getScriptRow(String user, String name) {
+    private CompletableFuture<Optional<Row>> getScriptRow(User user, ScriptName name) {
         return cassandraAsyncExecutor.executeSingleRow(
             selectScriptStatement.bind()
-                .setString(USER_NAME, user)
-                .setString(SCRIPT_NAME, name));
+                .setString(USER_NAME, user.asString())
+                .setString(SCRIPT_NAME, name.getValue()));
     }
 
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/server/data/data-cassandra/src/main/java/org/apache/james/sieve/cassandra/CassandraSieveQuotaDAO.java
----------------------------------------------------------------------
diff --git a/server/data/data-cassandra/src/main/java/org/apache/james/sieve/cassandra/CassandraSieveQuotaDAO.java b/server/data/data-cassandra/src/main/java/org/apache/james/sieve/cassandra/CassandraSieveQuotaDAO.java
index eaeb39e..b20ea30 100644
--- a/server/data/data-cassandra/src/main/java/org/apache/james/sieve/cassandra/CassandraSieveQuotaDAO.java
+++ b/server/data/data-cassandra/src/main/java/org/apache/james/sieve/cassandra/CassandraSieveQuotaDAO.java
@@ -33,6 +33,8 @@ import java.util.concurrent.CompletableFuture;
 import javax.inject.Inject;
 
 import org.apache.james.backends.cassandra.utils.CassandraAsyncExecutor;
+import org.apache.james.core.User;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.sieve.cassandra.tables.CassandraSieveClusterQuotaTable;
 import org.apache.james.sieve.cassandra.tables.CassandraSieveQuotaTable;
 import org.apache.james.sieve.cassandra.tables.CassandraSieveSpaceTable;
@@ -97,32 +99,33 @@ public class CassandraSieveQuotaDAO {
                 .where(eq(CassandraSieveQuotaTable.USER_NAME, bindMarker(CassandraSieveQuotaTable.USER_NAME))));
     }
 
-    public CompletableFuture<Long> spaceUsedBy(String user) {
+    public CompletableFuture<Long> spaceUsedBy(User user) {
         return cassandraAsyncExecutor.executeSingleRow(
             selectSpaceUsedByUserStatement.bind()
-                .setString(CassandraSieveSpaceTable.USER_NAME, user))
+                .setString(CassandraSieveSpaceTable.USER_NAME, user.asString()))
             .thenApply(optional -> optional.map(row -> row.getLong(CassandraSieveSpaceTable.SPACE_USED))
                 .orElse(0L));
     }
 
-    public CompletableFuture<Void> updateSpaceUsed(String user, long spaceUsed) {
+    public CompletableFuture<Void> updateSpaceUsed(User user, long spaceUsed) {
         return cassandraAsyncExecutor.executeVoid(
             updateSpaceUsedStatement.bind()
                 .setLong(CassandraSieveSpaceTable.SPACE_USED, spaceUsed)
-                .setString(CassandraSieveSpaceTable.USER_NAME, user));
+                .setString(CassandraSieveSpaceTable.USER_NAME, user.asString()));
     }
 
-    public CompletableFuture<Optional<Long>> getQuota() {
+    public CompletableFuture<Optional<QuotaSize>> getQuota() {
         return cassandraAsyncExecutor.executeSingleRow(
             selectClusterQuotaStatement.bind()
                 .setString(CassandraSieveClusterQuotaTable.NAME, CassandraSieveClusterQuotaTable.DEFAULT_NAME))
-            .thenApply(optional -> optional.map(row -> row.getLong(CassandraSieveClusterQuotaTable.VALUE)));
+            .thenApply(optional -> optional.map(row ->
+                QuotaSize.size(row.getLong(CassandraSieveClusterQuotaTable.VALUE))));
     }
 
-    public CompletableFuture<Void> setQuota(long quota) {
+    public CompletableFuture<Void> setQuota(QuotaSize quota) {
         return cassandraAsyncExecutor.executeVoid(
             updateClusterQuotaStatement.bind()
-                .setLong(CassandraSieveClusterQuotaTable.VALUE, quota)
+                .setLong(CassandraSieveClusterQuotaTable.VALUE, quota.asLong())
                 .setString(CassandraSieveClusterQuotaTable.NAME, CassandraSieveClusterQuotaTable.DEFAULT_NAME));
     }
 
@@ -132,24 +135,25 @@ public class CassandraSieveQuotaDAO {
                 .setString(CassandraSieveClusterQuotaTable.NAME, CassandraSieveClusterQuotaTable.DEFAULT_NAME));
     }
 
-    public CompletableFuture<Optional<Long>> getQuota(String user) {
+    public CompletableFuture<Optional<QuotaSize>> getQuota(User user) {
         return cassandraAsyncExecutor.executeSingleRow(
             selectUserQuotaStatement.bind()
-                .setString(CassandraSieveQuotaTable.USER_NAME, user))
-            .thenApply(optional -> optional.map(row -> row.getLong(CassandraSieveQuotaTable.QUOTA)));
+                .setString(CassandraSieveQuotaTable.USER_NAME, user.asString()))
+            .thenApply(optional -> optional.map(row ->
+                QuotaSize.size(row.getLong(CassandraSieveQuotaTable.QUOTA))));
     }
 
-    public CompletableFuture<Void> setQuota(String user, long quota) {
+    public CompletableFuture<Void> setQuota(User user, QuotaSize quota) {
         return cassandraAsyncExecutor.executeVoid(
             updateUserQuotaStatement.bind()
-                .setLong(CassandraSieveQuotaTable.QUOTA, quota)
-                .setString(CassandraSieveQuotaTable.USER_NAME, user));
+                .setLong(CassandraSieveQuotaTable.QUOTA, quota.asLong())
+                .setString(CassandraSieveQuotaTable.USER_NAME, user.asString()));
     }
 
-    public CompletableFuture<Void> removeQuota(String user)  {
+    public CompletableFuture<Void> removeQuota(User user)  {
         return cassandraAsyncExecutor.executeVoid(
             deleteUserQuotaStatement.bind()
-                .setString(CassandraSieveQuotaTable.USER_NAME, user));
+                .setString(CassandraSieveQuotaTable.USER_NAME, user.asString()));
     }
 
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/server/data/data-cassandra/src/main/java/org/apache/james/sieve/cassandra/CassandraSieveRepository.java
----------------------------------------------------------------------
diff --git a/server/data/data-cassandra/src/main/java/org/apache/james/sieve/cassandra/CassandraSieveRepository.java b/server/data/data-cassandra/src/main/java/org/apache/james/sieve/cassandra/CassandraSieveRepository.java
index d6e656e..73e4626 100644
--- a/server/data/data-cassandra/src/main/java/org/apache/james/sieve/cassandra/CassandraSieveRepository.java
+++ b/server/data/data-cassandra/src/main/java/org/apache/james/sieve/cassandra/CassandraSieveRepository.java
@@ -28,9 +28,13 @@ import java.util.concurrent.CompletableFuture;
 import javax.inject.Inject;
 
 import org.apache.commons.io.IOUtils;
+import org.apache.james.core.User;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.sieve.cassandra.model.ActiveScriptInfo;
 import org.apache.james.sieve.cassandra.model.Script;
 import org.apache.james.sieve.cassandra.model.SieveQuota;
+import org.apache.james.sieverepository.api.ScriptContent;
+import org.apache.james.sieverepository.api.ScriptName;
 import org.apache.james.sieverepository.api.ScriptSummary;
 import org.apache.james.sieverepository.api.SieveRepository;
 import org.apache.james.sieverepository.api.exception.DuplicateException;
@@ -56,32 +60,33 @@ public class CassandraSieveRepository implements SieveRepository {
     }
 
     @Override
-    public DateTime getActivationDateForActiveScript(String user) throws StorageException, ScriptNotFoundException {
+    public DateTime getActivationDateForActiveScript(User user) throws StorageException, ScriptNotFoundException {
         return cassandraActiveScriptDAO.getActiveSctiptInfo(user).join()
             .orElseThrow(ScriptNotFoundException::new)
             .getActivationDate();
     }
 
     @Override
-    public void haveSpace(String user, String name, long newSize) throws QuotaExceededException, StorageException {
+    public void haveSpace(User user, ScriptName name, long newSize) throws QuotaExceededException, StorageException {
         throwOnOverQuota(user, spaceThatWillBeUsedByNewScript(user, name, newSize));
     }
 
-    private void throwOnOverQuota(String user, CompletableFuture<Long> sizeDifference) throws QuotaExceededException, StorageException {
-        CompletableFuture<Optional<Long>> userQuotaFuture = cassandraSieveQuotaDAO.getQuota(user);
-        CompletableFuture<Optional<Long>> globalQuotaFuture = cassandraSieveQuotaDAO.getQuota();
+    private void throwOnOverQuota(User user, CompletableFuture<Long> sizeDifference) throws QuotaExceededException, StorageException {
+        CompletableFuture<Optional<QuotaSize>> userQuotaFuture = cassandraSieveQuotaDAO.getQuota(user);
+        CompletableFuture<Optional<QuotaSize>> globalQuotaFuture = cassandraSieveQuotaDAO.getQuota();
         CompletableFuture<Long> spaceUsedFuture = cassandraSieveQuotaDAO.spaceUsedBy(user);
 
-        new SieveQuota(spaceUsedFuture.join(), limitToUse(userQuotaFuture, globalQuotaFuture)).checkOverQuotaUponModification(sizeDifference.join());
+        new SieveQuota(spaceUsedFuture.join(), limitToUse(userQuotaFuture, globalQuotaFuture))
+            .checkOverQuotaUponModification(sizeDifference.join());
     }
 
-    public CompletableFuture<Long> spaceThatWillBeUsedByNewScript(String user, String name, long scriptSize) {
+    public CompletableFuture<Long> spaceThatWillBeUsedByNewScript(User user, ScriptName name, long scriptSize) {
         return cassandraSieveDAO.getScript(user, name)
             .thenApply(optional -> optional.map(Script::getSize).orElse(0L))
             .thenApply(sizeOfStoredScript -> scriptSize - sizeOfStoredScript);
     }
 
-    private Optional<Long> limitToUse(CompletableFuture<Optional<Long>> userQuota, CompletableFuture<Optional<Long>> globalQuota) {
+    private Optional<QuotaSize> limitToUse(CompletableFuture<Optional<QuotaSize>> userQuota, CompletableFuture<Optional<QuotaSize>> globalQuota) {
         if (userQuota.join().isPresent()) {
             return userQuota.join();
         }
@@ -89,7 +94,7 @@ public class CassandraSieveRepository implements SieveRepository {
     }
 
     @Override
-    public void putScript(String user, String name, String content) throws QuotaExceededException, StorageException {
+    public void putScript(User user, ScriptName name, ScriptContent content) throws QuotaExceededException, StorageException {
         CompletableFuture<Long> spaceUsed = spaceThatWillBeUsedByNewScript(user, name, content.length());
         throwOnOverQuota(user, spaceUsed);
 
@@ -104,7 +109,7 @@ public class CassandraSieveRepository implements SieveRepository {
             .join();
     }
 
-    public CompletableFuture<Void> updateSpaceUsed(String user, long spaceUsed) {
+    public CompletableFuture<Void> updateSpaceUsed(User user, long spaceUsed) {
         if (spaceUsed == 0) {
             return CompletableFuture.completedFuture(null);
         }
@@ -112,12 +117,12 @@ public class CassandraSieveRepository implements SieveRepository {
     }
 
     @Override
-    public List<ScriptSummary> listScripts(String user) {
+    public List<ScriptSummary> listScripts(User user) {
         return cassandraSieveDAO.listScripts(user).join();
     }
 
     @Override
-    public InputStream getActive(String user) throws ScriptNotFoundException {
+    public InputStream getActive(User user) throws ScriptNotFoundException {
         return IOUtils.toInputStream(
             cassandraActiveScriptDAO.getActiveSctiptInfo(user)
                 .thenCompose(optionalActiveName -> optionalActiveName
@@ -125,11 +130,12 @@ public class CassandraSieveRepository implements SieveRepository {
                     .orElse(CompletableFuture.completedFuture(Optional.empty())))
                 .join()
                 .orElseThrow(ScriptNotFoundException::new)
-                .getContent(), StandardCharsets.UTF_8);
+                .getContent()
+                .getValue(), StandardCharsets.UTF_8);
     }
 
     @Override
-    public void setActive(String user, String name) throws ScriptNotFoundException {
+    public void setActive(User user, ScriptName name) throws ScriptNotFoundException {
         CompletableFuture<Boolean> activateNewScript =
             unactivateOldScript(user)
                 .thenCompose(any -> updateScriptActivation(user, name, true)
@@ -141,7 +147,7 @@ public class CassandraSieveRepository implements SieveRepository {
         }
     }
 
-    private CompletableFuture<Void> unactivateOldScript(String user) {
+    private CompletableFuture<Void> unactivateOldScript(User user) {
         return cassandraActiveScriptDAO.getActiveSctiptInfo(user)
             .thenCompose(scriptNameOptional -> scriptNameOptional
                 .map(activeScriptInfo -> updateScriptActivation(user, activeScriptInfo.getName(), false)
@@ -149,7 +155,7 @@ public class CassandraSieveRepository implements SieveRepository {
                 .orElse(CompletableFuture.completedFuture(null)));
     }
 
-    private CompletableFuture<Boolean> updateScriptActivation(String user, String scriptName, boolean active) {
+    private CompletableFuture<Boolean> updateScriptActivation(User user, ScriptName scriptName, boolean active) {
         if (!scriptName.equals(SieveRepository.NO_SCRIPT_NAME)) {
             return cassandraSieveDAO.updateScriptActivation(user, scriptName, active);
         }
@@ -157,30 +163,30 @@ public class CassandraSieveRepository implements SieveRepository {
     }
 
     @Override
-    public InputStream getScript(String user, String name) throws ScriptNotFoundException {
+    public InputStream getScript(User user, ScriptName name) throws ScriptNotFoundException {
         return  cassandraSieveDAO.getScript(user, name)
             .join()
-            .map(script -> IOUtils.toInputStream(script.getContent(), StandardCharsets.UTF_8))
+            .map(script -> IOUtils.toInputStream(script.getContent().getValue(), StandardCharsets.UTF_8))
             .orElseThrow(ScriptNotFoundException::new);
     }
 
     @Override
-    public void deleteScript(String user, String name) throws ScriptNotFoundException, IsActiveException {
+    public void deleteScript(User user, ScriptName name) throws ScriptNotFoundException, IsActiveException {
         ensureIsNotActive(user, name);
         if (!cassandraSieveDAO.deleteScriptInCassandra(user, name).join()) {
             throw new ScriptNotFoundException();
         }
     }
 
-    private void ensureIsNotActive(String user, String name) throws IsActiveException {
-        Optional<String> activeName = cassandraActiveScriptDAO.getActiveSctiptInfo(user).join().map(ActiveScriptInfo::getName);
+    private void ensureIsNotActive(User user, ScriptName name) throws IsActiveException {
+        Optional<ScriptName> activeName = cassandraActiveScriptDAO.getActiveSctiptInfo(user).join().map(ActiveScriptInfo::getName);
         if (activeName.isPresent() && name.equals(activeName.get())) {
             throw new IsActiveException();
         }
     }
 
     @Override
-    public void renameScript(String user, String oldName, String newName) throws ScriptNotFoundException, DuplicateException {
+    public void renameScript(User user, ScriptName oldName, ScriptName newName) throws ScriptNotFoundException, DuplicateException {
         CompletableFuture<Boolean> scriptExistsFuture = cassandraSieveDAO.getScript(user, newName)
             .thenApply(Optional::isPresent);
         CompletableFuture<Optional<Script>> oldScriptFuture = cassandraSieveDAO.getScript(user, oldName);
@@ -195,7 +201,7 @@ public class CassandraSieveRepository implements SieveRepository {
             oldScriptFuture.join().orElseThrow(ScriptNotFoundException::new));
     }
 
-    private void performScriptRename(String user, String newName, Script oldScript) {
+    private void performScriptRename(User user, ScriptName newName, Script oldScript) {
         CompletableFuture.allOf(
             cassandraSieveDAO.insertScript(user,
                 Script.builder()
@@ -207,7 +213,7 @@ public class CassandraSieveRepository implements SieveRepository {
             .join();
     }
 
-    private CompletableFuture<Void> performActiveScriptRename(String user, String oldName, String newName) {
+    private CompletableFuture<Void> performActiveScriptRename(User user, ScriptName oldName, ScriptName newName) {
         return cassandraActiveScriptDAO.getActiveSctiptInfo(user)
             .thenCompose(optionalActivationInfo -> optionalActivationInfo
                 .filter(activeScriptInfo -> activeScriptInfo.getName().equals(oldName))
@@ -223,14 +229,14 @@ public class CassandraSieveRepository implements SieveRepository {
     }
 
     @Override
-    public long getQuota() throws QuotaNotFoundException {
+    public QuotaSize getQuota() throws QuotaNotFoundException {
         return cassandraSieveQuotaDAO.getQuota()
             .join()
             .orElseThrow(QuotaNotFoundException::new);
     }
 
     @Override
-    public void setQuota(long quota) {
+    public void setQuota(QuotaSize quota) {
         cassandraSieveQuotaDAO.setQuota(quota).join();
     }
 
@@ -240,7 +246,7 @@ public class CassandraSieveRepository implements SieveRepository {
     }
 
     @Override
-    public boolean hasQuota(String user) {
+    public boolean hasQuota(User user) {
         return CompletableFutureUtil.combine(
             cassandraSieveQuotaDAO.getQuota(user).thenApply(Optional::isPresent),
             cassandraSieveQuotaDAO.getQuota().thenApply(Optional::isPresent),
@@ -249,19 +255,19 @@ public class CassandraSieveRepository implements SieveRepository {
     }
 
     @Override
-    public long getQuota(String user) throws QuotaNotFoundException {
+    public QuotaSize getQuota(User user) throws QuotaNotFoundException {
         return cassandraSieveQuotaDAO.getQuota(user)
             .join()
             .orElseThrow(QuotaNotFoundException::new);
     }
 
     @Override
-    public void setQuota(String user, long quota) {
+    public void setQuota(User user, QuotaSize quota) {
         cassandraSieveQuotaDAO.setQuota(user, quota).join();
     }
 
     @Override
-    public void removeQuota(String user) throws QuotaNotFoundException {
+    public void removeQuota(User user) throws QuotaNotFoundException {
         cassandraSieveQuotaDAO.removeQuota(user).join();
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/server/data/data-cassandra/src/main/java/org/apache/james/sieve/cassandra/model/ActiveScriptInfo.java
----------------------------------------------------------------------
diff --git a/server/data/data-cassandra/src/main/java/org/apache/james/sieve/cassandra/model/ActiveScriptInfo.java b/server/data/data-cassandra/src/main/java/org/apache/james/sieve/cassandra/model/ActiveScriptInfo.java
index b3377be..051d7a4 100644
--- a/server/data/data-cassandra/src/main/java/org/apache/james/sieve/cassandra/model/ActiveScriptInfo.java
+++ b/server/data/data-cassandra/src/main/java/org/apache/james/sieve/cassandra/model/ActiveScriptInfo.java
@@ -21,19 +21,20 @@ package org.apache.james.sieve.cassandra.model;
 
 import java.util.Date;
 
+import org.apache.james.sieverepository.api.ScriptName;
 import org.joda.time.DateTime;
 
 public class ActiveScriptInfo {
 
-    private final String name;
+    private final ScriptName name;
     private final DateTime activationDate;
 
-    public ActiveScriptInfo(String content, Date date) {
-        this.name = content;
+    public ActiveScriptInfo(ScriptName name, Date date) {
+        this.name = name;
         this.activationDate = new DateTime(date);
     }
 
-    public String getName() {
+    public ScriptName getName() {
         return name;
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/server/data/data-cassandra/src/main/java/org/apache/james/sieve/cassandra/model/Script.java
----------------------------------------------------------------------
diff --git a/server/data/data-cassandra/src/main/java/org/apache/james/sieve/cassandra/model/Script.java b/server/data/data-cassandra/src/main/java/org/apache/james/sieve/cassandra/model/Script.java
index 8424a41..de68ade 100644
--- a/server/data/data-cassandra/src/main/java/org/apache/james/sieve/cassandra/model/Script.java
+++ b/server/data/data-cassandra/src/main/java/org/apache/james/sieve/cassandra/model/Script.java
@@ -6,6 +6,8 @@ import java.nio.charset.StandardCharsets;
 import java.util.Objects;
 import java.util.Optional;
 
+import org.apache.james.sieverepository.api.ScriptContent;
+import org.apache.james.sieverepository.api.ScriptName;
 import org.apache.james.sieverepository.api.ScriptSummary;
 
 import com.google.common.base.Preconditions;
@@ -17,16 +19,20 @@ public class Script {
     }
 
     public static class Builder {
-        private String name;
-        private String content;
+        private ScriptName name;
+        private ScriptContent content;
         private Optional<Boolean> isActive = Optional.empty();
         private Optional<Long> size = Optional.empty();
 
-        public Builder name(String name) {
+        public Builder name(ScriptName name) {
             this.name = name;
             return this;
         }
 
+        public Builder name(String name) {
+            return this.name(new ScriptName(name));
+        }
+
         public Builder copyOf(Script script) {
             this.name = script.getName();
             this.content = script.getContent();
@@ -35,11 +41,15 @@ public class Script {
             return this;
         }
 
-        public Builder content(String content) {
+        public Builder content(ScriptContent content) {
             this.content = content;
             return this;
         }
 
+        public Builder content(String content) {
+            return this.content(new ScriptContent(content));
+        }
+
         public Builder size(long size) {
             this.size = Optional.of(size);
             return this;
@@ -58,28 +68,28 @@ public class Script {
             return new Script(name,
                 content,
                 isActive.get(),
-                size.orElse((long) content.getBytes(StandardCharsets.UTF_8).length));
+                size.orElse((long) content.getValue().getBytes(StandardCharsets.UTF_8).length));
         }
 
     }
 
-    private final String name;
-    private final String content;
+    private final ScriptName name;
+    private final ScriptContent content;
     private final boolean isActive;
     private final long size;
 
-    private Script(String name, String content, boolean isActive, long size) {
+    private Script(ScriptName name, ScriptContent content, boolean isActive, long size) {
         this.name = name;
         this.content = content;
         this.isActive = isActive;
         this.size = size;
     }
 
-    public String getName() {
+    public ScriptName getName() {
         return name;
     }
 
-    public String getContent() {
+    public ScriptContent getContent() {
         return content;
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/server/data/data-cassandra/src/main/java/org/apache/james/sieve/cassandra/model/SieveQuota.java
----------------------------------------------------------------------
diff --git a/server/data/data-cassandra/src/main/java/org/apache/james/sieve/cassandra/model/SieveQuota.java b/server/data/data-cassandra/src/main/java/org/apache/james/sieve/cassandra/model/SieveQuota.java
index c1a44d6..b8a0154 100644
--- a/server/data/data-cassandra/src/main/java/org/apache/james/sieve/cassandra/model/SieveQuota.java
+++ b/server/data/data-cassandra/src/main/java/org/apache/james/sieve/cassandra/model/SieveQuota.java
@@ -22,6 +22,7 @@ package org.apache.james.sieve.cassandra.model;
 
 import java.util.Optional;
 
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.sieverepository.api.exception.QuotaExceededException;
 
 import com.google.common.base.Preconditions;
@@ -29,11 +30,11 @@ import com.google.common.base.Preconditions;
 public class SieveQuota {
 
     private final long currentUsage;
-    private final Optional<Long> limit;
+    private final Optional<QuotaSize> limit;
 
-    public SieveQuota(long currentUsage, Optional<Long> limit) {
+    public SieveQuota(long currentUsage, Optional<QuotaSize> limit) {
         Preconditions.checkArgument(currentUsage >= 0, "Current usage should be positive or equal to zero");
-        limit.ifPresent(limitValue -> Preconditions.checkArgument(limitValue >= 0, "Limit value should be positive or equal to zero"));
+        limit.ifPresent(limitValue -> Preconditions.checkArgument(limitValue.asLong() >= 0, "Limit value should be positive or equal to zero"));
         this.currentUsage = currentUsage;
         this.limit = limit;
     }
@@ -45,7 +46,7 @@ public class SieveQuota {
     }
 
     public boolean isExceededUponModification(long sizeDifference) {
-        return limit.map(limitContent -> currentUsage + sizeDifference > limitContent)
+        return limit.map(limitContent -> !limitContent.isGreaterThan(QuotaSize.size(currentUsage + sizeDifference)))
                 .orElse(false);
     }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/server/data/data-cassandra/src/test/java/org/apache/james/sieve/cassandra/CassandraActiveScriptDAOTest.java
----------------------------------------------------------------------
diff --git a/server/data/data-cassandra/src/test/java/org/apache/james/sieve/cassandra/CassandraActiveScriptDAOTest.java b/server/data/data-cassandra/src/test/java/org/apache/james/sieve/cassandra/CassandraActiveScriptDAOTest.java
index 93ac85b..8c7b6ae 100644
--- a/server/data/data-cassandra/src/test/java/org/apache/james/sieve/cassandra/CassandraActiveScriptDAOTest.java
+++ b/server/data/data-cassandra/src/test/java/org/apache/james/sieve/cassandra/CassandraActiveScriptDAOTest.java
@@ -25,7 +25,9 @@ import java.util.Optional;
 
 import org.apache.james.backends.cassandra.CassandraCluster;
 import org.apache.james.backends.cassandra.DockerCassandraRule;
+import org.apache.james.core.User;
 import org.apache.james.sieve.cassandra.model.ActiveScriptInfo;
+import org.apache.james.sieverepository.api.ScriptName;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.ClassRule;
@@ -33,9 +35,9 @@ import org.junit.Test;
 
 public class CassandraActiveScriptDAOTest {
 
-    public static final String USER = "user";
-    public static final String SCRIPT_NAME = "sciptName";
-    public static final String NEW_SCRIPT_NAME = "newScriptName";
+    public static final User USER = User.fromUsername("user");
+    public static final ScriptName SCRIPT_NAME = new ScriptName("sciptName");
+    public static final ScriptName NEW_SCRIPT_NAME = new ScriptName("newScriptName");
 
     @ClassRule public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
     

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/server/data/data-cassandra/src/test/java/org/apache/james/sieve/cassandra/CassandraSieveDAOTest.java
----------------------------------------------------------------------
diff --git a/server/data/data-cassandra/src/test/java/org/apache/james/sieve/cassandra/CassandraSieveDAOTest.java b/server/data/data-cassandra/src/test/java/org/apache/james/sieve/cassandra/CassandraSieveDAOTest.java
index 95750b9..0c29873 100644
--- a/server/data/data-cassandra/src/test/java/org/apache/james/sieve/cassandra/CassandraSieveDAOTest.java
+++ b/server/data/data-cassandra/src/test/java/org/apache/james/sieve/cassandra/CassandraSieveDAOTest.java
@@ -26,7 +26,9 @@ import java.util.Optional;
 
 import org.apache.james.backends.cassandra.CassandraCluster;
 import org.apache.james.backends.cassandra.DockerCassandraRule;
+import org.apache.james.core.User;
 import org.apache.james.sieve.cassandra.model.Script;
+import org.apache.james.sieverepository.api.ScriptName;
 import org.apache.james.sieverepository.api.ScriptSummary;
 import org.junit.After;
 import org.junit.Before;
@@ -35,9 +37,9 @@ import org.junit.Test;
 
 public class CassandraSieveDAOTest {
 
-    public static final String USER = "user";
-    public static final String SCRIPT_NAME = "scriptName";
-    public static final String SCRIPT_NAME2 = "scriptName2";
+    public static final User USER = User.fromUsername("user");
+    public static final ScriptName SCRIPT_NAME = new ScriptName("scriptName");
+    public static final ScriptName SCRIPT_NAME2 = new ScriptName("scriptName2");
     public static final Script SCRIPT = Script.builder()
         .name(SCRIPT_NAME)
         .content("content")

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/server/data/data-cassandra/src/test/java/org/apache/james/sieve/cassandra/CassandraSieveQuotaDAOTest.java
----------------------------------------------------------------------
diff --git a/server/data/data-cassandra/src/test/java/org/apache/james/sieve/cassandra/CassandraSieveQuotaDAOTest.java b/server/data/data-cassandra/src/test/java/org/apache/james/sieve/cassandra/CassandraSieveQuotaDAOTest.java
index 49de699..869a257 100644
--- a/server/data/data-cassandra/src/test/java/org/apache/james/sieve/cassandra/CassandraSieveQuotaDAOTest.java
+++ b/server/data/data-cassandra/src/test/java/org/apache/james/sieve/cassandra/CassandraSieveQuotaDAOTest.java
@@ -21,10 +21,10 @@ package org.apache.james.sieve.cassandra;
 
 import static org.assertj.core.api.Assertions.assertThat;
 
-import java.util.Optional;
-
 import org.apache.james.backends.cassandra.CassandraCluster;
 import org.apache.james.backends.cassandra.DockerCassandraRule;
+import org.apache.james.core.User;
+import org.apache.james.core.quota.QuotaSize;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.ClassRule;
@@ -32,9 +32,9 @@ import org.junit.Test;
 
 public class CassandraSieveQuotaDAOTest {
 
-    public static final String USER = "user";
+    public static final User USER = User.fromUsername("user");
+    public static final QuotaSize QUOTA_SIZE = QuotaSize.size(15L);
 
-    
     @ClassRule public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
     
     private CassandraCluster cassandra;
@@ -53,70 +53,66 @@ public class CassandraSieveQuotaDAOTest {
 
     @Test
     public void getQuotaShouldReturnEmptyByDefault() {
-        assertThat(sieveQuotaDAO.getQuota().join().isPresent())
-            .isFalse();
+        assertThat(sieveQuotaDAO.getQuota().join())
+            .isEmpty();
     }
 
     @Test
     public void getQuotaUserShouldReturnEmptyByDefault() {
-        assertThat(sieveQuotaDAO.getQuota(USER).join().isPresent())
-            .isFalse();
+        assertThat(sieveQuotaDAO.getQuota(USER).join())
+            .isEmpty();
     }
 
     @Test
     public void getQuotaShouldReturnStoredValue() {
-        long quota = 15L;
-        sieveQuotaDAO.setQuota(quota).join();
+        sieveQuotaDAO.setQuota(QUOTA_SIZE).join();
 
-        Optional<Long> actual = sieveQuotaDAO.getQuota().join();
-        assertThat(actual.isPresent()).isTrue();
-        assertThat(actual.get()).isEqualTo(quota);
+        assertThat(sieveQuotaDAO.getQuota().join())
+            .contains(QUOTA_SIZE);
     }
 
     @Test
     public void getQuotaUserShouldReturnStoredValue() {
-        long quota = 15L;
-        sieveQuotaDAO.setQuota(USER, quota).join();
+        sieveQuotaDAO.setQuota(USER, QUOTA_SIZE).join();
 
-        Optional<Long> actual = sieveQuotaDAO.getQuota(USER).join();
-        assertThat(actual.isPresent()).isTrue();
-        assertThat(actual.get()).isEqualTo(quota);
+        assertThat(sieveQuotaDAO.getQuota(USER).join())
+            .contains(QUOTA_SIZE);
     }
 
     @Test
     public void removeQuotaShouldDeleteQuota() {
-        sieveQuotaDAO.setQuota(15L).join();
+        sieveQuotaDAO.setQuota(QUOTA_SIZE).join();
 
         sieveQuotaDAO.removeQuota().join();
 
-        Optional<Long> actual = sieveQuotaDAO.getQuota().join();
-        assertThat(actual.isPresent()).isFalse();
+        assertThat(sieveQuotaDAO.getQuota().join())
+            .isEmpty();
     }
 
     @Test
     public void removeQuotaUserShouldDeleteQuotaUser() {
-        sieveQuotaDAO.setQuota(USER, 15L).join();
+        sieveQuotaDAO.setQuota(USER, QUOTA_SIZE).join();
 
         sieveQuotaDAO.removeQuota(USER).join();
 
-        Optional<Long> actual = sieveQuotaDAO.getQuota(USER).join();
-        assertThat(actual.isPresent()).isFalse();
+        assertThat(sieveQuotaDAO.getQuota(USER).join())
+            .isEmpty();
     }
 
     @Test
     public void removeQuotaShouldWorkWhenNoneStore() {
         sieveQuotaDAO.removeQuota().join();
 
-        Optional<Long> actual = sieveQuotaDAO.getQuota().join();
-        assertThat(actual.isPresent()).isFalse();
+        assertThat(sieveQuotaDAO.getQuota().join())
+            .isEmpty();
     }
 
     @Test
     public void removeQuotaUserShouldWorkWhenNoneStore() {
         sieveQuotaDAO.removeQuota(USER).join();
 
-        Optional<Long> actual = sieveQuotaDAO.getQuota(USER).join();
-        assertThat(actual.isPresent()).isFalse();
+        assertThat(sieveQuotaDAO.getQuota(USER).join())
+            .isEmpty();
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/server/data/data-cassandra/src/test/java/org/apache/james/sieve/cassandra/model/ScriptTest.java
----------------------------------------------------------------------
diff --git a/server/data/data-cassandra/src/test/java/org/apache/james/sieve/cassandra/model/ScriptTest.java b/server/data/data-cassandra/src/test/java/org/apache/james/sieve/cassandra/model/ScriptTest.java
index 95af5ce..ca757d9 100644
--- a/server/data/data-cassandra/src/test/java/org/apache/james/sieve/cassandra/model/ScriptTest.java
+++ b/server/data/data-cassandra/src/test/java/org/apache/james/sieve/cassandra/model/ScriptTest.java
@@ -23,6 +23,7 @@ import static org.assertj.core.api.Assertions.assertThat;
 
 import java.nio.charset.StandardCharsets;
 
+import org.apache.james.sieverepository.api.ScriptName;
 import org.apache.james.sieverepository.api.ScriptSummary;
 import org.junit.Rule;
 import org.junit.Test;
@@ -159,7 +160,7 @@ public class ScriptTest {
                 .size(48L)
                 .build()
                 .toSummary())
-            .isEqualTo(new ScriptSummary(name, isActive));
+            .isEqualTo(new ScriptSummary(new ScriptName(name), isActive));
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/server/data/data-cassandra/src/test/java/org/apache/james/sieve/cassandra/model/SieveQuotaTest.java
----------------------------------------------------------------------
diff --git a/server/data/data-cassandra/src/test/java/org/apache/james/sieve/cassandra/model/SieveQuotaTest.java b/server/data/data-cassandra/src/test/java/org/apache/james/sieve/cassandra/model/SieveQuotaTest.java
index fe93a82..3ec44ce 100644
--- a/server/data/data-cassandra/src/test/java/org/apache/james/sieve/cassandra/model/SieveQuotaTest.java
+++ b/server/data/data-cassandra/src/test/java/org/apache/james/sieve/cassandra/model/SieveQuotaTest.java
@@ -21,16 +21,17 @@ package org.apache.james.sieve.cassandra.model;
 
 import java.util.Optional;
 
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.sieverepository.api.exception.QuotaExceededException;
 import org.junit.Test;
 
 public class SieveQuotaTest {
 
     public static final long INVALID_VALUE = -1L;
-    public static final long LIMIT_LOW_VALUE = 10L;
+    public static final QuotaSize LIMIT_LOW_VALUE = QuotaSize.size(10L);
     public static final long SIZE_DIFFERENCE = 20L;
     public static final int CURRENT_USAGE = 0;
-    public static final long LIMIT_HIGH_VALUE = 100L;
+    public static final QuotaSize LIMIT_HIGH_VALUE = QuotaSize.size(100L);
 
     @Test(expected = IllegalArgumentException.class)
     public void sieveQuotaShouldThrowOnNegativeCurrentValue() {
@@ -39,7 +40,7 @@ public class SieveQuotaTest {
 
     @Test(expected = IllegalArgumentException.class)
     public void sieveQuotaShouldThrowOnNegativeLimitValue() {
-        new SieveQuota(0, Optional.of(INVALID_VALUE));
+        new SieveQuota(0, Optional.of(QuotaSize.size(INVALID_VALUE)));
     }
 
     @Test(expected = QuotaExceededException.class)

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/server/data/data-file/src/main/java/org/apache/james/sieverepository/file/SieveDefaultRepository.java
----------------------------------------------------------------------
diff --git a/server/data/data-file/src/main/java/org/apache/james/sieverepository/file/SieveDefaultRepository.java b/server/data/data-file/src/main/java/org/apache/james/sieverepository/file/SieveDefaultRepository.java
index dd865e2..9dcaea3 100644
--- a/server/data/data-file/src/main/java/org/apache/james/sieverepository/file/SieveDefaultRepository.java
+++ b/server/data/data-file/src/main/java/org/apache/james/sieverepository/file/SieveDefaultRepository.java
@@ -28,7 +28,11 @@ import java.util.List;
 
 import javax.inject.Inject;
 
+import org.apache.james.core.User;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.filesystem.api.FileSystem;
+import org.apache.james.sieverepository.api.ScriptContent;
+import org.apache.james.sieverepository.api.ScriptName;
 import org.apache.james.sieverepository.api.ScriptSummary;
 import org.apache.james.sieverepository.api.SieveRepository;
 import org.apache.james.sieverepository.api.exception.DuplicateException;
@@ -55,22 +59,22 @@ public class SieveDefaultRepository implements SieveRepository {
     }
 
     @Override
-    public void haveSpace(String user, String name, long size) throws QuotaExceededException, StorageException {
+    public void haveSpace(User user, ScriptName name, long size) throws QuotaExceededException, StorageException {
         throw apologizeForQuotas();
     }
 
     @Override
-    public void putScript(String user, String name, String content) throws StorageException, QuotaExceededException {
+    public void putScript(User user, ScriptName name, ScriptContent content) throws StorageException, QuotaExceededException {
         throw new StorageException("This implementation is deprecated and does not support script put operation. You must directly position your scripts in the .sieve folder. Please consider using a SieveFileRepository.");
     }
 
     @Override
-    public List<ScriptSummary> listScripts(String user) throws StorageException {
+    public List<ScriptSummary> listScripts(User user) throws StorageException {
         throw new StorageException("This implementation is deprecated and does not support listScripts operation. Please consider using a SieveFileRepository.");
     }
 
     @Override
-    public InputStream getActive(String user) throws ScriptNotFoundException, StorageException {
+    public InputStream getActive(User user) throws ScriptNotFoundException, StorageException {
         try {
             return new FileInputStream(retrieveUserFile(user));
         } catch (FileNotFoundException e) {
@@ -79,13 +83,13 @@ public class SieveDefaultRepository implements SieveRepository {
     }
 
     @Override
-    public DateTime getActivationDateForActiveScript(String user) throws StorageException, ScriptNotFoundException {
+    public DateTime getActivationDateForActiveScript(User user) throws StorageException, ScriptNotFoundException {
         return new DateTime(retrieveUserFile(user).lastModified());
     }
 
-    public File retrieveUserFile(String user) throws ScriptNotFoundException {
+    public File retrieveUserFile(User user) throws ScriptNotFoundException {
         // RFC 5228 permits extensions: .siv .sieve
-        String sieveFilePrefix = FileSystem.FILE_PROTOCOL + "sieve/" + user + ".";
+        String sieveFilePrefix = FileSystem.FILE_PROTOCOL + "sieve/" + user.asString() + ".";
         try {
             return fileSystem.getFile(sieveFilePrefix + "sieve");
         } catch (FileNotFoundException e) {
@@ -98,22 +102,22 @@ public class SieveDefaultRepository implements SieveRepository {
     }
 
     @Override
-    public void setActive(String user, String name) throws ScriptNotFoundException, StorageException {
+    public void setActive(User user, ScriptName name) throws ScriptNotFoundException, StorageException {
         throw new StorageException("This implementation is deprecated and does not support script SetActive operation. Your uploaded script is by default the active script. Please consider using a SieveFileRepository.");
     }
 
     @Override
-    public InputStream getScript(String user, String name) throws ScriptNotFoundException, StorageException {
+    public InputStream getScript(User user, ScriptName name) throws ScriptNotFoundException, StorageException {
         return getActive(user);
     }
 
     @Override
-    public void deleteScript(String user, String name) throws ScriptNotFoundException, IsActiveException, StorageException {
+    public void deleteScript(User user, ScriptName name) throws ScriptNotFoundException, IsActiveException, StorageException {
         throw new StorageException("This implementation is deprecated and does not support delete script operation. Please consider using a SieveFileRepository.");
     }
 
     @Override
-    public void renameScript(String user, String oldName, String newName) throws ScriptNotFoundException, DuplicateException, StorageException {
+    public void renameScript(User user, ScriptName oldName, ScriptName newName) throws ScriptNotFoundException, DuplicateException, StorageException {
         throw new StorageException("This implementation is deprecated and does not support rename script operation. Please consider using a SieveFileRepository.");
     }
 
@@ -123,12 +127,12 @@ public class SieveDefaultRepository implements SieveRepository {
     }
 
     @Override
-    public long getQuota() throws QuotaNotFoundException, StorageException {
+    public QuotaSize getQuota() throws QuotaNotFoundException, StorageException {
         throw apologizeForQuotas();
     }
 
     @Override
-    public void setQuota(long quota) throws StorageException {
+    public void setQuota(QuotaSize quota) throws StorageException {
         throw apologizeForQuotas();
     }
 
@@ -138,22 +142,22 @@ public class SieveDefaultRepository implements SieveRepository {
     }
 
     @Override
-    public boolean hasQuota(String user) throws StorageException {
+    public boolean hasQuota(User user) throws StorageException {
         throw apologizeForQuotas();
     }
 
     @Override
-    public long getQuota(String user) throws QuotaNotFoundException, StorageException {
+    public QuotaSize getQuota(User user) throws QuotaNotFoundException, StorageException {
         throw apologizeForQuotas();
     }
 
     @Override
-    public void setQuota(String user, long quota) throws StorageException {
+    public void setQuota(User user, QuotaSize quota) throws StorageException {
         throw apologizeForQuotas();
     }
 
     @Override
-    public void removeQuota(String user) throws QuotaNotFoundException, StorageException {
+    public void removeQuota(User user) throws QuotaNotFoundException, StorageException {
         throw apologizeForQuotas();
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/server/data/data-file/src/main/java/org/apache/james/sieverepository/file/SieveFileRepository.java
----------------------------------------------------------------------
diff --git a/server/data/data-file/src/main/java/org/apache/james/sieverepository/file/SieveFileRepository.java b/server/data/data-file/src/main/java/org/apache/james/sieverepository/file/SieveFileRepository.java
index 400cad5..9c6bbd6 100644
--- a/server/data/data-file/src/main/java/org/apache/james/sieverepository/file/SieveFileRepository.java
+++ b/server/data/data-file/src/main/java/org/apache/james/sieverepository/file/SieveFileRepository.java
@@ -39,7 +39,11 @@ import javax.inject.Inject;
 
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.IOUtils;
+import org.apache.james.core.User;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.filesystem.api.FileSystem;
+import org.apache.james.sieverepository.api.ScriptContent;
+import org.apache.james.sieverepository.api.ScriptName;
 import org.apache.james.sieverepository.api.ScriptSummary;
 import org.apache.james.sieverepository.api.SieveRepository;
 import org.apache.james.sieverepository.api.exception.DuplicateException;
@@ -143,11 +147,11 @@ public class SieveFileRepository implements SieveRepository {
     }
 
     @Override
-    public void deleteScript(String user, String name) throws ScriptNotFoundException, IsActiveException, StorageException {
+    public void deleteScript(User user, ScriptName name) throws ScriptNotFoundException, IsActiveException, StorageException {
         synchronized (lock) {
             File file = getScriptFile(user, name);
             if (isActiveFile(user, file)) {
-                throw new IsActiveException("User: " + user + "Script: " + name);
+                throw new IsActiveException("User: " + user.asString() + "Script: " + name);
             }
             try {
                 FileUtils.forceDelete(file);
@@ -158,7 +162,7 @@ public class SieveFileRepository implements SieveRepository {
     }
 
     @Override
-    public InputStream getScript(String user, String name) throws ScriptNotFoundException, StorageException {
+    public InputStream getScript(User user, ScriptName name) throws ScriptNotFoundException, StorageException {
         InputStream script;
         try {
             script = new FileInputStream(getScriptFile(user, name));
@@ -175,9 +179,9 @@ public class SieveFileRepository implements SieveRepository {
      * The '.quota' file contains a single positive integer value representing the quota in octets.
      */
     @Override
-    public void haveSpace(String user, String name, long size) throws QuotaExceededException, StorageException {
+    public void haveSpace(User user, ScriptName name, long size) throws QuotaExceededException, StorageException {
         long usedSpace = Arrays.stream(getUserDirectory(user).listFiles())
-            .filter(file -> !(file.getName().equals(name) || SYSTEM_FILES.contains(file.getName())))
+            .filter(file -> !(file.getName().equals(name.getValue()) || SYSTEM_FILES.contains(file.getName())))
             .mapToLong(File::length)
             .sum();
 
@@ -206,7 +210,7 @@ public class SieveFileRepository implements SieveRepository {
     }
 
     @Override
-    public List<ScriptSummary> listScripts(String user) throws StorageException {
+    public List<ScriptSummary> listScripts(User user) throws StorageException {
         File[] files = getUserDirectory(user).listFiles();
         List<ScriptSummary> summaries = new ArrayList<>(files.length);
         File activeFile = null;
@@ -217,7 +221,7 @@ public class SieveFileRepository implements SieveRepository {
         }
         for (File file : files) {
             if (!SYSTEM_FILES.contains(file.getName())) {
-                summaries.add(new ScriptSummary(file.getName(), isActive(file, activeFile)));
+                summaries.add(new ScriptSummary(new ScriptName(file.getName()), isActive(file, activeFile)));
             }
         }
         return summaries;
@@ -229,22 +233,22 @@ public class SieveFileRepository implements SieveRepository {
     }
 
     @Override
-    public void putScript(String user, String name, String content) throws StorageException, QuotaExceededException {
+    public void putScript(User user, ScriptName name, ScriptContent content) throws StorageException, QuotaExceededException {
         synchronized (lock) {
-            File file = new File(getUserDirectory(user), name);
+            File file = new File(getUserDirectory(user), name.getValue());
             haveSpace(user, name, content.length());
-            toFile(file, content);
+            toFile(file, content.getValue());
         }
     }
 
     @Override
-    public void renameScript(String user, String oldName, String newName)
+    public void renameScript(User user, ScriptName oldName, ScriptName newName)
             throws ScriptNotFoundException, DuplicateException, StorageException {
         synchronized (lock) {
             File oldFile = getScriptFile(user, oldName);
-            File newFile = new File(getUserDirectory(user), newName);
+            File newFile = new File(getUserDirectory(user), newName.getValue());
             if (newFile.exists()) {
-                throw new DuplicateException("User: " + user + "Script: " + newName);
+                throw new DuplicateException("User: " + user.asString() + "Script: " + newName);
             }
             try {
                 FileUtils.copyFile(oldFile, newFile);
@@ -259,7 +263,7 @@ public class SieveFileRepository implements SieveRepository {
     }
 
     @Override
-    public InputStream getActive(String user) throws ScriptNotFoundException, StorageException {
+    public InputStream getActive(User user) throws ScriptNotFoundException, StorageException {
         InputStream script;
         try {
             script = new FileInputStream(getActiveFile(user));
@@ -270,12 +274,12 @@ public class SieveFileRepository implements SieveRepository {
     }
 
     @Override
-    public DateTime getActivationDateForActiveScript(String user) throws StorageException, ScriptNotFoundException {
+    public DateTime getActivationDateForActiveScript(User user) throws StorageException, ScriptNotFoundException {
         return new DateTime(getActiveFile(user).lastModified());
     }
 
     @Override
-    public void setActive(String user, String name) throws ScriptNotFoundException, StorageException {
+    public void setActive(User user, ScriptName scriptName) throws ScriptNotFoundException, StorageException {
         synchronized (lock) {
             // Turn off currently active script, if any
             File oldActive = null;
@@ -286,9 +290,10 @@ public class SieveFileRepository implements SieveRepository {
                 // This is permissible
             }
             // Turn on the new active script if not an empty name
+            String name = scriptName.getValue();
             if ((null != name) && (!name.trim().isEmpty())) {
                 try {
-                    setActiveFile(getScriptFile(user, name), user, true);
+                    setActiveFile(getScriptFile(user, new ScriptName(name)), user, true);
                 } catch (ScriptNotFoundException ex) {
                     if (null != oldActive) {
                         setActiveFile(oldActive, user, true);
@@ -307,7 +312,7 @@ public class SieveFileRepository implements SieveRepository {
         }
     }
 
-    protected File getUserDirectory(String user) throws StorageException {
+    protected File getUserDirectory(User user) throws StorageException {
         File file = getUserDirectoryFile(user);
         if (!file.exists()) {
             ensureUser(user);
@@ -315,22 +320,22 @@ public class SieveFileRepository implements SieveRepository {
         return file;
     }
 
-    protected File getUserDirectoryFile(String user) throws StorageException {
-        return new File(getSieveRootDirectory(), user + '/');
+    protected File getUserDirectoryFile(User user) throws StorageException {
+        return new File(getSieveRootDirectory(), user.asString() + '/');
     }
 
-    protected File getActiveFile(String user) throws ScriptNotFoundException, StorageException {
+    protected File getActiveFile(User user) throws ScriptNotFoundException, StorageException {
         File dir = getUserDirectory(user);
         String content;
         try {
             content = toString(new File(dir, FILE_NAME_ACTIVE), UTF_8);
         } catch (FileNotFoundException ex) {
-            throw new ScriptNotFoundException("There is no active script for user " + user);
+            throw new ScriptNotFoundException("There is no active script for user " + user.asString());
         }
         return new File(dir, content);
     }
 
-    protected boolean isActiveFile(String user, File file) throws StorageException {
+    protected boolean isActiveFile(User user, File file) throws StorageException {
         try {
             return 0 == getActiveFile(user).compareTo(file);
         } catch (ScriptNotFoundException ex) {
@@ -338,11 +343,11 @@ public class SieveFileRepository implements SieveRepository {
         }
     }
 
-    protected void setActiveFile(File scriptToBeActivated, String userName, boolean isActive) throws StorageException {
+    protected void setActiveFile(File scriptToBeActivated, User userName, boolean isActive) throws StorageException {
         File personalScriptDirectory = scriptToBeActivated.getParentFile();
         File sieveBaseDirectory = personalScriptDirectory.getParentFile();
         File activeScriptPersistenceFile = new File(personalScriptDirectory, FILE_NAME_ACTIVE);
-        File activeScriptCopy = new File(sieveBaseDirectory, userName + SIEVE_EXTENSION);
+        File activeScriptCopy = new File(sieveBaseDirectory, userName.asString() + SIEVE_EXTENSION);
         if (isActive) {
             toFile(activeScriptPersistenceFile, scriptToBeActivated.getName());
             try {
@@ -360,15 +365,15 @@ public class SieveFileRepository implements SieveRepository {
         }
     }
 
-    protected File getScriptFile(String user, String name) throws ScriptNotFoundException, StorageException {
-        File file = new File(getUserDirectory(user), name);
+    protected File getScriptFile(User user, ScriptName name) throws ScriptNotFoundException, StorageException {
+        File file = new File(getUserDirectory(user), name.getValue());
         if (!file.exists()) {
             throw new ScriptNotFoundException("User: " + user + "Script: " + name);
         }
         return file;
     }
 
-    public void ensureUser(String user) throws StorageException {
+    public void ensureUser(User user) throws StorageException {
         synchronized (lock) {
             try {
                 FileUtils.forceMkdir(getUserDirectoryFile(user));
@@ -388,7 +393,7 @@ public class SieveFileRepository implements SieveRepository {
     }
 
     @Override
-    public long getQuota() throws QuotaNotFoundException, StorageException {
+    public QuotaSize getQuota() throws QuotaNotFoundException, StorageException {
         Long quota = null;
         File file = getQuotaFile();
         if (file.exists()) {
@@ -407,7 +412,7 @@ public class SieveFileRepository implements SieveRepository {
         if (null == quota) {
             throw new QuotaNotFoundException("No default quota");
         }
-        return quota;
+        return QuotaSize.size(quota);
     }
 
     @Override
@@ -424,23 +429,23 @@ public class SieveFileRepository implements SieveRepository {
     }
 
     @Override
-    public synchronized void setQuota(long quota) throws StorageException {
+    public synchronized void setQuota(QuotaSize quota) throws StorageException {
         File file = getQuotaFile();
-        String content = Long.toString(quota);
+        String content = Long.toString(quota.asLong());
         toFile(file, content);
     }
 
-    protected File getQuotaFile(String user) throws StorageException {
+    protected File getQuotaFile(User user) throws StorageException {
         return new File(getUserDirectory(user), FILE_NAME_QUOTA);
     }
 
     @Override
-    public boolean hasQuota(String user) throws StorageException {
+    public boolean hasQuota(User user) throws StorageException {
         return getQuotaFile(user).exists();
     }
 
     @Override
-    public long getQuota(String user) throws QuotaNotFoundException, StorageException {
+    public QuotaSize getQuota(User user) throws QuotaNotFoundException, StorageException {
         Long quota = null;
         File file = getQuotaFile(user);
         if (file.exists()) {
@@ -457,13 +462,13 @@ public class SieveFileRepository implements SieveRepository {
             }
         }
         if (null == quota) {
-            throw new QuotaNotFoundException("No quota for user: " + user);
+            throw new QuotaNotFoundException("No quota for user: " + user.asString());
         }
-        return quota;
+        return QuotaSize.size(quota);
     }
 
     @Override
-    public void removeQuota(String user) throws QuotaNotFoundException, StorageException {
+    public void removeQuota(User user) throws QuotaNotFoundException, StorageException {
         synchronized (lock) {
             File file = getQuotaFile(user);
             if (!file.exists()) {
@@ -478,10 +483,10 @@ public class SieveFileRepository implements SieveRepository {
     }
 
     @Override
-    public void setQuota(String user, long quota) throws StorageException {
+    public void setQuota(User user, QuotaSize quota) throws StorageException {
         synchronized (lock) {
             File file = getQuotaFile(user);
-            String content = Long.toString(quota);
+            String content = Long.toString(quota.asLong());
             toFile(file, content);
         }
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/server/data/data-library/src/main/java/org/apache/james/sieverepository/lib/SieveRepositoryManagement.java
----------------------------------------------------------------------
diff --git a/server/data/data-library/src/main/java/org/apache/james/sieverepository/lib/SieveRepositoryManagement.java b/server/data/data-library/src/main/java/org/apache/james/sieverepository/lib/SieveRepositoryManagement.java
index c5b2ca4..d60cf1a 100644
--- a/server/data/data-library/src/main/java/org/apache/james/sieverepository/lib/SieveRepositoryManagement.java
+++ b/server/data/data-library/src/main/java/org/apache/james/sieverepository/lib/SieveRepositoryManagement.java
@@ -24,6 +24,8 @@ import javax.inject.Inject;
 import javax.management.NotCompliantMBeanException;
 import javax.management.StandardMBean;
 
+import org.apache.james.core.User;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.sieverepository.api.SieveRepository;
 import org.apache.james.sieverepository.api.SieveRepositoryManagementMBean;
 import org.apache.james.sieverepository.api.exception.SieveRepositoryException;
@@ -43,12 +45,12 @@ public class SieveRepositoryManagement extends StandardMBean implements SieveRep
 
     @Override
     public long getQuota() throws SieveRepositoryException {
-        return sieveRepository.getQuota();
+        return sieveRepository.getQuota().asLong();
     }
 
     @Override
     public void setQuota(long quota) throws SieveRepositoryException {
-        sieveRepository.setQuota(quota);
+        sieveRepository.setQuota(QuotaSize.size(quota));
     }
 
     @Override
@@ -58,16 +60,16 @@ public class SieveRepositoryManagement extends StandardMBean implements SieveRep
 
     @Override
     public long getQuota(String user) throws SieveRepositoryException {
-        return sieveRepository.getQuota(user);
+        return sieveRepository.getQuota(User.fromUsername(user)).asLong();
     }
 
     @Override
     public void setQuota(String user, long quota) throws SieveRepositoryException {
-        sieveRepository.setQuota(user, quota);
+        sieveRepository.setQuota(User.fromUsername(user), QuotaSize.size(quota));
     }
 
     @Override
     public void removeQuota(String user) throws SieveRepositoryException {
-        sieveRepository.removeQuota(user);
+        sieveRepository.removeQuota(User.fromUsername(user));
     }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/server/data/data-library/src/test/java/org/apache/james/sieverepository/lib/AbstractSieveRepositoryTest.java
----------------------------------------------------------------------
diff --git a/server/data/data-library/src/test/java/org/apache/james/sieverepository/lib/AbstractSieveRepositoryTest.java b/server/data/data-library/src/test/java/org/apache/james/sieverepository/lib/AbstractSieveRepositoryTest.java
index 7f5eaa4..fe5b557 100644
--- a/server/data/data-library/src/test/java/org/apache/james/sieverepository/lib/AbstractSieveRepositoryTest.java
+++ b/server/data/data-library/src/test/java/org/apache/james/sieverepository/lib/AbstractSieveRepositoryTest.java
@@ -22,8 +22,13 @@ import static org.assertj.core.api.Assertions.assertThat;
 
 import java.io.IOException;
 import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
 
 import org.apache.commons.io.IOUtils;
+import org.apache.james.core.User;
+import org.apache.james.core.quota.QuotaSize;
+import org.apache.james.sieverepository.api.ScriptContent;
+import org.apache.james.sieverepository.api.ScriptName;
 import org.apache.james.sieverepository.api.ScriptSummary;
 import org.apache.james.sieverepository.api.SieveRepository;
 import org.apache.james.sieverepository.api.exception.DuplicateException;
@@ -36,15 +41,14 @@ import org.junit.Test;
 
 public abstract class AbstractSieveRepositoryTest {
 
-    protected static final String USER = "test";
-    protected static final String SCRIPT_NAME = "script";
-    protected static final String SCRIPT_CONTENT = "Hello World";
+    protected static final User USER = User.fromUsername("test");
+    protected static final ScriptName SCRIPT_NAME = new ScriptName("script");
+    protected static final ScriptContent SCRIPT_CONTENT = new ScriptContent("Hello World");
 
-    private static final String OTHER_SCRIPT_NAME = "other_script";
-    private static final String OTHER_SCRIPT_CONTENT = "Other script content";
-    private static final long DEFAULT_QUOTA = Long.MAX_VALUE - 1L;
-    private static final long USER_QUOTA = Long.MAX_VALUE / 2;
-    private static final String UTF8_ENCODING = "UTF-8";
+    private static final ScriptName OTHER_SCRIPT_NAME = new ScriptName("other_script");
+    private static final ScriptContent OTHER_SCRIPT_CONTENT = new ScriptContent("Other script content");
+    private static final QuotaSize DEFAULT_QUOTA = QuotaSize.size(Long.MAX_VALUE - 1L);
+    private static final QuotaSize USER_QUOTA = QuotaSize.size(Long.MAX_VALUE / 2);
 
     protected SieveRepository sieveRepository;
 
@@ -79,40 +83,40 @@ public abstract class AbstractSieveRepositoryTest {
 
     @Test
     public void haveSpaceShouldNotThrowWhenUserDoesNotHaveQuota() throws Exception {
-        sieveRepository.haveSpace(USER, SCRIPT_NAME, DEFAULT_QUOTA + 1L);
+        sieveRepository.haveSpace(USER, SCRIPT_NAME, DEFAULT_QUOTA.asLong() + 1L);
     }
 
     @Test
     public void haveSpaceShouldNotThrowWhenQuotaIsNotReached() throws Exception {
         sieveRepository.setQuota(DEFAULT_QUOTA);
-        sieveRepository.haveSpace(USER, SCRIPT_NAME, DEFAULT_QUOTA);
+        sieveRepository.haveSpace(USER, SCRIPT_NAME, DEFAULT_QUOTA.asLong());
     }
 
     @Test(expected = QuotaExceededException.class)
     public void haveSpaceShouldThrowWhenQuotaIsExceed() throws Exception {
         sieveRepository.setQuota(DEFAULT_QUOTA);
-        sieveRepository.haveSpace(USER, SCRIPT_NAME, DEFAULT_QUOTA + 1);
+        sieveRepository.haveSpace(USER, SCRIPT_NAME, DEFAULT_QUOTA.asLong() + 1);
     }
 
     @Test
     public void haveSpaceShouldNotThrowWhenAttemptToReplaceOtherScript() throws Exception {
         sieveRepository.setQuota(USER, USER_QUOTA);
         sieveRepository.putScript(USER, SCRIPT_NAME, SCRIPT_CONTENT);
-        sieveRepository.haveSpace(USER, SCRIPT_NAME, USER_QUOTA);
+        sieveRepository.haveSpace(USER, SCRIPT_NAME, USER_QUOTA.asLong());
     }
 
     @Test(expected = QuotaExceededException.class)
     public void haveSpaceShouldThrowWhenAttemptToReplaceOtherScriptWithTooLargeScript() throws Exception {
         sieveRepository.setQuota(USER, USER_QUOTA);
         sieveRepository.putScript(USER, SCRIPT_NAME, SCRIPT_CONTENT);
-        sieveRepository.haveSpace(USER, SCRIPT_NAME, USER_QUOTA + 1);
+        sieveRepository.haveSpace(USER, SCRIPT_NAME, USER_QUOTA.asLong() + 1);
     }
 
     @Test(expected = QuotaExceededException.class)
     public void haveSpaceShouldTakeAlreadyExistingScriptsIntoAccount() throws Exception {
         sieveRepository.setQuota(USER, USER_QUOTA);
         sieveRepository.putScript(USER, SCRIPT_NAME, SCRIPT_CONTENT);
-        sieveRepository.haveSpace(USER, OTHER_SCRIPT_NAME, USER_QUOTA - 1);
+        sieveRepository.haveSpace(USER, OTHER_SCRIPT_NAME, USER_QUOTA.asLong() - 1);
     }
 
     @Test
@@ -120,7 +124,7 @@ public abstract class AbstractSieveRepositoryTest {
         sieveRepository.setQuota(USER, USER_QUOTA);
         sieveRepository.putScript(USER, SCRIPT_NAME, SCRIPT_CONTENT);
         sieveRepository.setActive(USER, SCRIPT_NAME);
-        sieveRepository.haveSpace(USER, SCRIPT_NAME, USER_QUOTA);
+        sieveRepository.haveSpace(USER, SCRIPT_NAME, USER_QUOTA.asLong());
     }
 
     @Test
@@ -156,15 +160,15 @@ public abstract class AbstractSieveRepositoryTest {
 
     @Test(expected = QuotaExceededException.class)
     public void putScriptShouldThrowWhenScriptTooBig() throws Exception {
-        sieveRepository.setQuota(SCRIPT_CONTENT.length() - 1);
+        sieveRepository.setQuota(QuotaSize.size(SCRIPT_CONTENT.length() - 1));
         sieveRepository.putScript(USER, SCRIPT_NAME, SCRIPT_CONTENT);
     }
 
     @Test(expected = QuotaExceededException.class)
     public void putScriptShouldThrowWhenQuotaChangedInBetween() throws Exception {
-        sieveRepository.setQuota(SCRIPT_CONTENT.length());
+        sieveRepository.setQuota(QuotaSize.size(SCRIPT_CONTENT.length()));
         sieveRepository.putScript(USER, SCRIPT_NAME, SCRIPT_CONTENT);
-        sieveRepository.setQuota(SCRIPT_CONTENT.length() - 1);
+        sieveRepository.setQuota(QuotaSize.size(SCRIPT_CONTENT.length() - 1));
         sieveRepository.putScript(USER, SCRIPT_NAME, SCRIPT_CONTENT);
     }
 
@@ -340,7 +344,7 @@ public abstract class AbstractSieveRepositoryTest {
     }
 
     protected String getScriptContent(InputStream inputStream) throws IOException {
-        return IOUtils.toString(inputStream, UTF8_ENCODING);
+        return IOUtils.toString(inputStream, StandardCharsets.UTF_8);
     }
 
     protected abstract SieveRepository createSieveRepository() throws Exception;

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/server/data/data-memory/src/main/java/org/apache/james/sieverepository/memory/InMemorySieveQuotaRepository.java
----------------------------------------------------------------------
diff --git a/server/data/data-memory/src/main/java/org/apache/james/sieverepository/memory/InMemorySieveQuotaRepository.java b/server/data/data-memory/src/main/java/org/apache/james/sieverepository/memory/InMemorySieveQuotaRepository.java
index 1e30b9c..8820ee9 100644
--- a/server/data/data-memory/src/main/java/org/apache/james/sieverepository/memory/InMemorySieveQuotaRepository.java
+++ b/server/data/data-memory/src/main/java/org/apache/james/sieverepository/memory/InMemorySieveQuotaRepository.java
@@ -23,14 +23,16 @@ import java.util.Map;
 import java.util.Optional;
 import java.util.concurrent.ConcurrentHashMap;
 
+import org.apache.james.core.User;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.sieverepository.api.SieveQuotaRepository;
 import org.apache.james.sieverepository.api.exception.QuotaNotFoundException;
 
 public class InMemorySieveQuotaRepository implements SieveQuotaRepository {
 
-    private Optional<Long> globalQuota = Optional.empty();
+    private Optional<QuotaSize> globalQuota = Optional.empty();
 
-    private Map<String, Long> userQuota = new ConcurrentHashMap<>();
+    private Map<User, QuotaSize> userQuota = new ConcurrentHashMap<>();
 
     @Override
     public boolean hasQuota() {
@@ -38,12 +40,12 @@ public class InMemorySieveQuotaRepository implements SieveQuotaRepository {
     }
 
     @Override
-    public long getQuota() throws QuotaNotFoundException {
+    public QuotaSize getQuota() throws QuotaNotFoundException {
         return globalQuota.orElseThrow(QuotaNotFoundException::new);
     }
 
     @Override
-    public void setQuota(long quota) {
+    public void setQuota(QuotaSize quota) {
         this.globalQuota = Optional.of(quota);
     }
 
@@ -56,24 +58,24 @@ public class InMemorySieveQuotaRepository implements SieveQuotaRepository {
     }
 
     @Override
-    public boolean hasQuota(String user) {
+    public boolean hasQuota(User user) {
         return userQuota.containsKey(user);
     }
 
     @Override
-    public long getQuota(String user) throws QuotaNotFoundException {
+    public QuotaSize getQuota(User user) throws QuotaNotFoundException {
         return Optional.ofNullable(userQuota.get(user))
             .orElseThrow(QuotaNotFoundException::new);
     }
 
     @Override
-    public void setQuota(String user, long quota) {
+    public void setQuota(User user, QuotaSize quota) {
         userQuota.put(user, quota);
     }
 
     @Override
-    public void removeQuota(String user) throws QuotaNotFoundException {
-        Optional<Long> quotaValue = Optional.ofNullable(userQuota.get(user));
+    public void removeQuota(User user) throws QuotaNotFoundException {
+        Optional<QuotaSize> quotaValue = Optional.ofNullable(userQuota.get(user));
         if (!quotaValue.isPresent()) {
             throw new QuotaNotFoundException();
         }

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/IsOverQuotaMatcherTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/IsOverQuotaMatcherTest.java b/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/IsOverQuotaMatcherTest.java
index 26a3658..6b755fb 100644
--- a/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/IsOverQuotaMatcherTest.java
+++ b/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/IsOverQuotaMatcherTest.java
@@ -29,8 +29,8 @@ import static org.apache.james.mailets.configuration.Constants.awaitAtMostOneMin
 import static org.assertj.core.api.Assertions.assertThat;
 
 import org.apache.james.MemoryJamesServerMain;
-import org.apache.james.mailbox.quota.QuotaCount;
-import org.apache.james.mailbox.quota.QuotaSize;
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.mailets.TemporaryJamesServer;
 import org.apache.james.mailets.configuration.CommonProcessors;
 import org.apache.james.mailets.configuration.MailetConfiguration;

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/ResourceLocator.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/ResourceLocator.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/ResourceLocator.java
index 736687f..cdb310c 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/ResourceLocator.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/ResourceLocator.java
@@ -21,6 +21,7 @@ package org.apache.james.transport.mailets.jsieve;
 import java.io.InputStream;
 
 import org.apache.james.core.MailAddress;
+import org.apache.james.core.User;
 import org.apache.james.sieverepository.api.SieveRepository;
 import org.apache.james.user.api.UsersRepository;
 import org.apache.james.user.api.UsersRepositoryException;
@@ -61,16 +62,15 @@ public class ResourceLocator {
     }
 
     public UserSieveInformation get(MailAddress mailAddress) throws Exception {
-        String username = retrieveUsername(mailAddress);
+        User username = retrieveUsername(mailAddress);
         return new UserSieveInformation(sieveRepository.getActivationDateForActiveScript(username), DateTime.now(), sieveRepository.getActive(username));
     }
 
-    private String retrieveUsername(MailAddress mailAddress) {
+    private User retrieveUsername(MailAddress mailAddress) {
         try {
-            return usersRepository.getUser(mailAddress);
+            return User.fromUsername(usersRepository.getUser(mailAddress));
         } catch (UsersRepositoryException e) {
-
-            return mailAddress.asString();
+            return User.fromMailAddress(mailAddress);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/ResourceLocatorTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/ResourceLocatorTest.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/ResourceLocatorTest.java
index 30064ab..12ff8d3 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/ResourceLocatorTest.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/ResourceLocatorTest.java
@@ -27,6 +27,7 @@ import java.io.ByteArrayInputStream;
 import java.io.InputStream;
 
 import org.apache.james.core.MailAddress;
+import org.apache.james.core.User;
 import org.apache.james.sieverepository.api.SieveRepository;
 import org.apache.james.sieverepository.api.exception.ScriptNotFoundException;
 import org.apache.james.transport.mailets.jsieve.ResourceLocator;
@@ -37,6 +38,7 @@ import org.junit.Test;
 public class ResourceLocatorTest {
 
     public static final String RECEIVER_LOCALHOST = "receiver@localhost";
+    public static final User USER = User.fromUsername(RECEIVER_LOCALHOST);
     private SieveRepository sieveRepository;
     private ResourceLocator resourceLocator;
     private MailAddress mailAddress;
@@ -52,7 +54,7 @@ public class ResourceLocatorTest {
 
     @Test(expected = ScriptNotFoundException.class)
     public void resourceLocatorImplShouldPropagateScriptNotFound() throws Exception {
-        when(sieveRepository.getActive(RECEIVER_LOCALHOST)).thenThrow(new ScriptNotFoundException());
+        when(sieveRepository.getActive(USER)).thenThrow(new ScriptNotFoundException());
         when(usersRepository.getUser(mailAddress)).thenReturn(RECEIVER_LOCALHOST);
 
         resourceLocator.get(mailAddress);
@@ -61,7 +63,7 @@ public class ResourceLocatorTest {
     @Test
     public void resourceLocatorImplShouldWork() throws Exception {
         InputStream inputStream = new ByteArrayInputStream(new byte[0]);
-        when(sieveRepository.getActive(RECEIVER_LOCALHOST)).thenReturn(inputStream);
+        when(sieveRepository.getActive(USER)).thenReturn(inputStream);
         when(usersRepository.getUser(mailAddress)).thenReturn(RECEIVER_LOCALHOST);
 
         assertThat(resourceLocator.get(mailAddress).getScriptContent()).isEqualTo(inputStream);


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


[08/20] james-project git commit: JAMES-2151 SieveRepository strong typing for User

Posted by bt...@apache.org.
JAMES-2151 SieveRepository strong typing for User


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

Branch: refs/heads/master
Commit: 3d0a55344e4656150c10ffba69d7dd3d78128888
Parents: 1914c7b
Author: benwa <bt...@linagora.com>
Authored: Fri Jun 22 10:14:34 2018 +0700
Committer: benwa <bt...@linagora.com>
Committed: Tue Jun 26 16:06:31 2018 +0700

----------------------------------------------------------------------
 core/pom.xml                                    | 20 +++-
 .../main/java/org/apache/james/core/User.java   |  6 ++
 .../org/apache/james/core/quota/QuotaCount.java | 94 +++++++++++++++++++
 .../org/apache/james/core/quota/QuotaSize.java  | 96 ++++++++++++++++++++
 .../org/apache/james/core/quota/QuotaValue.java | 36 ++++++++
 .../apache/james/core/quota/QuotaCountTest.java | 42 +++++++++
 .../apache/james/core/quota/QuotaSizeTest.java  | 42 +++++++++
 .../apache/james/core/quota/QuotaValueTest.java | 75 +++++++++++++++
 .../apache/james/mailbox/MailboxListener.java   |  4 +-
 .../mailbox/exception/OverQuotaException.java   |  2 +-
 .../org/apache/james/mailbox/model/Quota.java   |  2 +-
 .../apache/james/mailbox/model/QuotaRatio.java  |  4 +-
 .../mailbox/quota/CurrentQuotaManager.java      |  2 +
 .../james/mailbox/quota/MaxQuotaManager.java    |  2 +
 .../apache/james/mailbox/quota/QuotaCount.java  | 94 -------------------
 .../james/mailbox/quota/QuotaManager.java       |  2 +
 .../apache/james/mailbox/quota/QuotaSize.java   | 96 --------------------
 .../apache/james/mailbox/quota/QuotaValue.java  | 36 --------
 .../mailbox/manager/ManagerTestResources.java   |  4 +-
 .../manager/QuotaMessageManagerTest.java        |  4 +-
 .../james/mailbox/model/QuotaRatioTest.java     |  4 +-
 .../apache/james/mailbox/model/QuotaTest.java   |  4 +-
 .../james/mailbox/quota/QuotaCountTest.java     | 42 ---------
 .../james/mailbox/quota/QuotaFixture.java       |  2 +
 .../james/mailbox/quota/QuotaSizeTest.java      | 42 ---------
 .../james/mailbox/quota/QuotaValueTest.java     | 75 ---------------
 .../quota/CassandraCurrentQuotaManager.java     |  4 +-
 .../quota/CassandraGlobalMaxQuotaDao.java       |  4 +-
 .../quota/CassandraPerDomainMaxQuotaDao.java    |  4 +-
 .../quota/CassandraPerUserMaxQuotaDao.java      |  4 +-
 .../quota/CassandraPerUserMaxQuotaManager.java  |  4 +-
 .../mailbox/cassandra/quota/QuotaCodec.java     |  6 +-
 .../jpa/quota/JPAPerUserMaxQuotaDAO.java        |  6 +-
 .../jpa/quota/JPAPerUserMaxQuotaManager.java    |  4 +-
 .../jpa/quota/JpaCurrentQuotaManager.java       |  4 +-
 .../jpa/quota/model/JpaCurrentQuota.java        |  4 +-
 .../quota/InMemoryCurrentQuotaManager.java      |  4 +-
 .../quota/InMemoryPerUserMaxQuotaManager.java   |  4 +-
 .../quota/InMemoryCurrentQuotaManagerTest.java  |  4 +-
 .../mailbox/quota/cassandra/dto/QuotaDTO.java   |  4 +-
 .../mailbox/quota/cassandra/dto/DTOTest.java    |  4 +-
 .../mailing/aggregates/UserQuotaThresholds.java |  4 +-
 .../commands/DetectThresholdCrossing.java       |  4 +-
 .../events/QuotaThresholdChangedEvent.java      |  4 +-
 .../subscribers/QuotaThresholdNotice.java       |  4 +-
 .../subscribers/QuotaThresholdNoticeTest.java   |  4 +-
 .../mailbox/quota/model/QuotaThresholdTest.java |  2 +-
 .../quota/model/QuotaThresholdsTest.java        |  2 +-
 .../json/QuotaRatioAsJsonTest.java              |  4 +-
 .../quota/search/scanning/ClauseConverter.java  |  4 +-
 .../quota/search/QuotaSearcherContract.java     |  2 +-
 .../store/event/MailboxEventDispatcher.java     |  4 +-
 .../store/mail/model/SerializableQuota.java     |  2 +-
 .../mail/model/SerializableQuotaValue.java      |  2 +-
 .../james/mailbox/store/probe/QuotaProbe.java   |  4 +-
 .../store/quota/FixedMaxQuotaManager.java       |  4 +-
 .../mailbox/store/quota/NoMaxQuotaManager.java  |  4 +-
 .../mailbox/store/quota/NoQuotaManager.java     |  4 +-
 .../james/mailbox/store/quota/QuotaChecker.java |  4 +-
 .../mailbox/store/quota/StoreQuotaManager.java  |  4 +-
 .../AbstractMessageIdManagerQuotaTest.java      |  4 +-
 .../AbstractMessageIdManagerSideEffectTest.java |  4 +-
 .../store/quota/GenericMaxQuotaManagerTest.java |  4 +-
 .../mailbox/store/quota/QuotaCheckerTest.java   |  4 +-
 .../quota/StoreCurrentQuotaManagerTest.java     |  4 +-
 .../store/quota/StoreQuotaManagerTest.java      |  4 +-
 .../apache/james/mpt/api/ImapHostSystem.java    |  4 +-
 .../james/mpt/host/ExternalHostSystem.java      |  4 +-
 .../cassandra/host/CassandraHostSystem.java     |  4 +-
 .../james/mpt/imapmailbox/suite/QuotaTest.java  |  4 +-
 .../imapmailbox/cyrus/host/CyrusHostSystem.java |  4 +-
 .../host/ElasticSearchHostSystem.java           |  4 +-
 .../james/host/ExternalJamesHostSystem.java     |  4 +-
 .../imapmailbox/hbase/host/HBaseHostSystem.java |  4 +-
 .../inmemory/host/InMemoryHostSystem.java       |  4 +-
 .../mpt/imapmailbox/jcr/host/JCRHostSystem.java |  4 +-
 .../mpt/imapmailbox/jpa/host/JPAHostSystem.java |  4 +-
 .../host/LuceneSearchHostSystem.java            |  4 +-
 .../maildir/host/MaildirHostSystem.java         |  4 +-
 .../mpt/host/JamesManageSieveHostSystem.java    |  6 +-
 .../james/imap/processor/GetQuotaProcessor.java |  4 +-
 .../imap/processor/GetQuotaRootProcessor.java   |  4 +-
 .../imap/encode/QuotaResponseEncoderTest.java   |  4 +-
 .../imap/processor/GetQuotaProcessorTest.java   |  4 +-
 .../processor/GetQuotaRootProcessorTest.java    |  4 +-
 .../james/managesieve/core/CoreProcessor.java   | 35 +++----
 .../java/org/apache/james/cli/ServerCmd.java    |  6 +-
 .../james/cli/probe/impl/JmxQuotaProbe.java     |  4 +-
 .../org/apache/james/cli/ServerCmdTest.java     |  4 +-
 .../org/apache/james/JPAJamesServerTest.java    |  2 +-
 .../apache/james/modules/QuotaProbesImpl.java   |  4 +-
 .../james/modules/protocols/SieveProbeImpl.java | 21 +++--
 .../james/adapter/mailbox/QuotaManagement.java  |  4 +-
 .../adapter/mailbox/QuotaManagementMBean.java   |  4 +-
 .../mailbox/MaxQuotaConfigurationReader.java    |  4 +-
 .../sieverepository/api/ScriptContent.java      | 62 +++++++++++++
 .../james/sieverepository/api/ScriptName.java   | 58 ++++++++++++
 .../sieverepository/api/ScriptSummary.java      |  6 +-
 .../api/SieveQuotaRepository.java               | 14 +--
 .../sieverepository/api/SieveRepository.java    | 21 +++--
 .../sieverepository/api/ScriptNameTest.java     | 32 +++++++
 .../cassandra/CassandraActiveScriptDAO.java     | 18 ++--
 .../sieve/cassandra/CassandraSieveDAO.java      | 36 ++++----
 .../sieve/cassandra/CassandraSieveQuotaDAO.java | 36 ++++----
 .../cassandra/CassandraSieveRepository.java     | 66 ++++++++------
 .../sieve/cassandra/model/ActiveScriptInfo.java |  9 +-
 .../james/sieve/cassandra/model/Script.java     | 30 ++++--
 .../james/sieve/cassandra/model/SieveQuota.java |  9 +-
 .../cassandra/CassandraActiveScriptDAOTest.java |  8 +-
 .../sieve/cassandra/CassandraSieveDAOTest.java  |  8 +-
 .../cassandra/CassandraSieveQuotaDAOTest.java   | 52 +++++------
 .../james/sieve/cassandra/model/ScriptTest.java |  3 +-
 .../sieve/cassandra/model/SieveQuotaTest.java   |  7 +-
 .../file/SieveDefaultRepository.java            | 38 ++++----
 .../file/SieveFileRepository.java               | 85 +++++++++--------
 .../lib/SieveRepositoryManagement.java          | 12 ++-
 .../lib/AbstractSieveRepositoryTest.java        | 42 +++++----
 .../memory/InMemorySieveQuotaRepository.java    | 20 ++--
 .../mailets/IsOverQuotaMatcherTest.java         |  4 +-
 .../mailets/jsieve/ResourceLocator.java         | 10 +-
 .../transport/mailets/ResourceLocatorTest.java  |  6 +-
 .../managesieve/ManageSieveMailetTestCase.java  | 58 +++++++-----
 .../transport/matchers/IsOverQuotaTest.java     |  4 +-
 .../integration/GetMailboxesMethodTest.java     |  4 +-
 .../methods/integration/QuotaMailingTest.java   |  2 +-
 .../methods/integration/SendMDNMethodTest.java  |  2 +-
 .../integration/SetMessagesMethodTest.java      |  2 +-
 .../apache/james/jmap/model/MailboxFactory.java |  2 +-
 .../apache/james/jmap/model/mailbox/Quotas.java |  6 +-
 .../james/webadmin/routes/SieveQuotaRoutes.java | 24 ++---
 .../james/webadmin/dto/OccupationDTO.java       |  4 +-
 .../james/webadmin/dto/OccupationRatioDTO.java  |  4 +-
 .../org/apache/james/webadmin/dto/QuotaDTO.java |  4 +-
 .../james/webadmin/dto/QuotaDetailsDTO.java     |  4 +-
 .../webadmin/dto/QuotaValueDeserializer.java    |  2 +-
 .../webadmin/dto/QuotaValueSerializer.java      |  2 +-
 .../james/webadmin/jackson/QuotaModule.java     |  4 +-
 .../webadmin/routes/DomainQuotaRoutes.java      |  4 +-
 .../webadmin/routes/GlobalQuotaRoutes.java      |  4 +-
 .../james/webadmin/routes/UserQuotaRoutes.java  |  4 +-
 .../webadmin/service/DomainQuotaService.java    |  4 +-
 .../webadmin/service/GlobalQuotaService.java    |  4 +-
 .../webadmin/service/UserQuotaService.java      |  4 +-
 .../james/webadmin/validation/Quotas.java       |  4 +-
 .../dto/QuotaValueDeserializerTest.java         |  4 +-
 .../webadmin/dto/UsersQuotaDetailsDTOTest.java  |  4 +-
 .../webadmin/routes/DomainQuotaRoutesTest.java  |  4 +-
 .../webadmin/routes/GlobalQuotaRoutesTest.java  |  4 +-
 .../webadmin/routes/UserQuotaRoutesTest.java    |  4 +-
 .../webadmin/validation/QuotaValueTest.java     |  4 +-
 150 files changed, 1135 insertions(+), 889 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/core/pom.xml
----------------------------------------------------------------------
diff --git a/core/pom.xml b/core/pom.xml
index d096b67..336d7e4 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -57,11 +57,6 @@
             <artifactId>javax.mail</artifactId>
         </dependency>
         <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
             <groupId>nl.jqno.equalsverifier</groupId>
             <artifactId>equalsverifier</artifactId>
             <scope>test</scope>
@@ -71,6 +66,21 @@
             <artifactId>assertj-core</artifactId>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>org.junit.jupiter</groupId>
+            <artifactId>junit-jupiter-engine</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.junit.platform</groupId>
+            <artifactId>junit-platform-launcher</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.junit.vintage</groupId>
+            <artifactId>junit-vintage-engine</artifactId>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 
 </project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/core/src/main/java/org/apache/james/core/User.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/james/core/User.java b/core/src/main/java/org/apache/james/core/User.java
index a327da3..299f767 100644
--- a/core/src/main/java/org/apache/james/core/User.java
+++ b/core/src/main/java/org/apache/james/core/User.java
@@ -58,6 +58,12 @@ public class User {
         return new User(localPart, Optional.of(domain));
     }
 
+    public static User fromMailAddress(MailAddress address) {
+        Preconditions.checkNotNull(address);
+
+        return new User(address.getLocalPart(), Optional.of(address.getDomain()));
+    }
+
     public static User fromLocalPartWithoutDomain(String localPart) {
         return from(localPart,
             Optional.empty());

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/core/src/main/java/org/apache/james/core/quota/QuotaCount.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/james/core/quota/QuotaCount.java b/core/src/main/java/org/apache/james/core/quota/QuotaCount.java
new file mode 100644
index 0000000..eef03fa
--- /dev/null
+++ b/core/src/main/java/org/apache/james/core/quota/QuotaCount.java
@@ -0,0 +1,94 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+package org.apache.james.core.quota;
+
+import java.util.Optional;
+
+import com.google.common.base.MoreObjects;
+import com.google.common.base.Objects;
+
+public class QuotaCount implements QuotaValue<QuotaCount> {
+
+    public static QuotaCount unlimited() {
+        return new QuotaCount(Optional.empty());
+    }
+
+    public static QuotaCount count(long value) {
+        return count(Optional.of(value));
+    }
+
+    public static QuotaCount count(Optional<Long> value) {
+        return new QuotaCount(value);
+    }
+
+    private final Optional<Long> value;
+
+    private QuotaCount(Optional<Long> value) {
+        this.value = value;
+    }
+
+    @Override
+    public long asLong() {
+        return value.orElseThrow(IllegalStateException::new);
+    }
+
+    @Override
+    public boolean isLimited() {
+        return value.isPresent();
+    }
+
+    @Override
+    public QuotaCount add(long additionalValue) {
+        return new QuotaCount(value.map(x -> x + additionalValue));
+    }
+
+    @Override
+    public QuotaCount add(QuotaCount additionalValue) {
+        if (additionalValue.isUnlimited()) {
+            return unlimited();
+        }
+        return new QuotaCount(value.map(x -> x + additionalValue.asLong()));
+    }
+
+    @Override
+    public String toString() {
+        return MoreObjects.toStringHelper(this)
+            .add("value", value.map(String::valueOf).orElse("unlimited"))
+            .toString();
+    }
+
+    @Override
+    public boolean isGreaterThan(QuotaCount other) {
+        return value.orElse(Long.MAX_VALUE) > other.value.orElse(Long.MAX_VALUE);
+    }
+
+    @Override
+    public final boolean equals(Object o) {
+        if (o instanceof QuotaCount) {
+            QuotaCount that = (QuotaCount) o;
+            return Objects.equal(this.value, that.value);
+        }
+        return false;
+    }
+
+    @Override
+    public final int hashCode() {
+        return Objects.hashCode(value);
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/core/src/main/java/org/apache/james/core/quota/QuotaSize.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/james/core/quota/QuotaSize.java b/core/src/main/java/org/apache/james/core/quota/QuotaSize.java
new file mode 100644
index 0000000..6d1f2ac
--- /dev/null
+++ b/core/src/main/java/org/apache/james/core/quota/QuotaSize.java
@@ -0,0 +1,96 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+package org.apache.james.core.quota;
+
+import java.util.Optional;
+
+import com.google.common.base.MoreObjects;
+import com.google.common.base.Objects;
+
+public class QuotaSize implements QuotaValue<QuotaSize> {
+
+    public static final QuotaSize QUOTA_SIZE = new QuotaSize(Optional.empty());
+
+    public static QuotaSize unlimited() {
+        return QUOTA_SIZE;
+    }
+
+    public static QuotaSize size(long value) {
+        return size(Optional.of(value));
+    }
+
+    public static QuotaSize size(Optional<Long> value) {
+        return new QuotaSize(value);
+    }
+
+    private final Optional<Long> value;
+
+    private QuotaSize(Optional<Long> value) {
+        this.value = value;
+    }
+
+    @Override
+    public long asLong() {
+        return value.orElseThrow(IllegalStateException::new);
+    }
+
+    @Override
+    public boolean isLimited() {
+        return value.isPresent();
+    }
+
+    @Override
+    public QuotaSize add(long additionalValue) {
+        return new QuotaSize(value.map(x -> x + additionalValue));
+    }
+
+    @Override
+    public QuotaSize add(QuotaSize additionalValue) {
+        if (additionalValue.isUnlimited()) {
+            return unlimited();
+        }
+        return new QuotaSize(value.map(x -> x + additionalValue.asLong()));
+    }
+
+    @Override
+    public boolean isGreaterThan(QuotaSize other) {
+        return value.orElse(Long.MAX_VALUE) > other.value.orElse(Long.MAX_VALUE);
+    }
+
+    @Override
+    public String toString() {
+        return MoreObjects.toStringHelper(this)
+            .add("value", value.map(String::valueOf).orElse("unlimited"))
+            .toString();
+    }
+
+    @Override
+    public final boolean equals(Object o) {
+        if (o instanceof QuotaSize) {
+            QuotaSize that = (QuotaSize) o;
+            return Objects.equal(this.value, that.value);
+        }
+        return false;
+    }
+
+    @Override
+    public final int hashCode() {
+        return Objects.hashCode(value);
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/core/src/main/java/org/apache/james/core/quota/QuotaValue.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/james/core/quota/QuotaValue.java b/core/src/main/java/org/apache/james/core/quota/QuotaValue.java
new file mode 100644
index 0000000..f4342d3
--- /dev/null
+++ b/core/src/main/java/org/apache/james/core/quota/QuotaValue.java
@@ -0,0 +1,36 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+package org.apache.james.core.quota;
+
+public interface QuotaValue<T extends QuotaValue<T>> {
+
+    long asLong();
+
+    boolean isLimited();
+
+    default boolean isUnlimited() {
+        return !isLimited();
+    }
+
+    T add(long additionalValue);
+
+    T add(T additionalValue);
+
+    boolean isGreaterThan(T other);
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/core/src/test/java/org/apache/james/core/quota/QuotaCountTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/james/core/quota/QuotaCountTest.java b/core/src/test/java/org/apache/james/core/quota/QuotaCountTest.java
new file mode 100644
index 0000000..d704687
--- /dev/null
+++ b/core/src/test/java/org/apache/james/core/quota/QuotaCountTest.java
@@ -0,0 +1,42 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+package org.apache.james.core.quota;
+
+import org.junit.jupiter.api.Test;
+
+import nl.jqno.equalsverifier.EqualsVerifier;
+
+public class QuotaCountTest implements QuotaValueTest<QuotaCount> {
+
+    @Override
+    public QuotaCount instance(long value) {
+        return QuotaCount.count(value);
+    }
+
+    @Override
+    public QuotaCount unlimited() {
+        return QuotaCount.unlimited();
+    }
+
+    @Test
+    public void shouldRespectBeanContract() {
+        EqualsVerifier.forClass(QuotaCount.class).verify();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/core/src/test/java/org/apache/james/core/quota/QuotaSizeTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/james/core/quota/QuotaSizeTest.java b/core/src/test/java/org/apache/james/core/quota/QuotaSizeTest.java
new file mode 100644
index 0000000..f89223b
--- /dev/null
+++ b/core/src/test/java/org/apache/james/core/quota/QuotaSizeTest.java
@@ -0,0 +1,42 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+package org.apache.james.core.quota;
+
+import org.junit.jupiter.api.Test;
+
+import nl.jqno.equalsverifier.EqualsVerifier;
+
+public class QuotaSizeTest implements QuotaValueTest<QuotaSize> {
+
+    @Override
+    public QuotaSize instance(long value) {
+        return QuotaSize.size(value);
+    }
+
+    @Override
+    public QuotaSize unlimited() {
+        return QuotaSize.unlimited();
+    }
+
+    @Test
+    public void shouldRespectBeanContract() {
+        EqualsVerifier.forClass(QuotaSize.class).verify();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/core/src/test/java/org/apache/james/core/quota/QuotaValueTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/james/core/quota/QuotaValueTest.java b/core/src/test/java/org/apache/james/core/quota/QuotaValueTest.java
new file mode 100644
index 0000000..8545e31
--- /dev/null
+++ b/core/src/test/java/org/apache/james/core/quota/QuotaValueTest.java
@@ -0,0 +1,75 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+package org.apache.james.core.quota;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import org.junit.jupiter.api.Test;
+
+public interface QuotaValueTest<T extends QuotaValue<T>> {
+
+    T instance(long i);
+
+    T unlimited();
+
+    @Test
+    default void greaterThanShouldReturnFalseWhenFirstEqualToSecond() {
+        assertThat(instance(1).isGreaterThan(instance(1))).isFalse();
+    }
+
+    @Test
+    default void greaterThanShouldReturnFalseWhenFirstSmallerThanSecond() {
+        assertThat(instance(1).isGreaterThan(instance(2))).isFalse();
+    }
+
+    @Test
+    default void greaterThanShouldReturnTrueWhenFirstGreaterThanSecond() {
+        assertThat(instance(2).isGreaterThan(instance(1))).isTrue();
+    }
+
+    @Test
+    default void greaterThanShouldReturnFalseWhenFirstIsLimitedAndSecondUnlimited() {
+        assertThat(instance(1).isGreaterThan(unlimited())).isFalse();
+    }
+
+    @Test
+    default void greaterThanShouldReturnFalseWhenBothAreUnlimited() {
+        assertThat(unlimited().isGreaterThan(unlimited())).isFalse();
+    }
+
+    @Test
+    default void greaterThanShouldReturnTrueWhenFirstIsUnlimitedAndSecondLimited() {
+        assertThat(unlimited().isGreaterThan(instance(1))).isTrue();
+    }
+
+    @Test
+    default void addShouldReturnUnlimitedWhenThisIsUnlimited() {
+        assertThat(unlimited().add(2)).isEqualTo(unlimited());
+    }
+
+    @Test
+    default void addShouldReturnUnlimitedWhenBothAre() {
+        assertThat(unlimited().add(unlimited())).isEqualTo(unlimited());
+    }
+
+    @Test
+    default void addShouldReturnSumResult() {
+        assertThat(instance(12).add(instance(23))).isEqualTo(instance(35));
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxListener.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxListener.java b/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxListener.java
index 9021aa9..5329b87 100644
--- a/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxListener.java
+++ b/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxListener.java
@@ -24,14 +24,14 @@ import java.time.Instant;
 import java.util.List;
 import java.util.Objects;
 
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.mailbox.acl.ACLDiff;
 import org.apache.james.mailbox.model.MailboxPath;
 import org.apache.james.mailbox.model.MessageMetaData;
 import org.apache.james.mailbox.model.Quota;
 import org.apache.james.mailbox.model.QuotaRoot;
 import org.apache.james.mailbox.model.UpdatedFlags;
-import org.apache.james.mailbox.quota.QuotaCount;
-import org.apache.james.mailbox.quota.QuotaSize;
 
 
 /**

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/mailbox/api/src/main/java/org/apache/james/mailbox/exception/OverQuotaException.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/main/java/org/apache/james/mailbox/exception/OverQuotaException.java b/mailbox/api/src/main/java/org/apache/james/mailbox/exception/OverQuotaException.java
index ef4fb3e..b8b13bd 100644
--- a/mailbox/api/src/main/java/org/apache/james/mailbox/exception/OverQuotaException.java
+++ b/mailbox/api/src/main/java/org/apache/james/mailbox/exception/OverQuotaException.java
@@ -18,7 +18,7 @@
  ****************************************************************/
 package org.apache.james.mailbox.exception;
 
-import org.apache.james.mailbox.quota.QuotaValue;
+import org.apache.james.core.quota.QuotaValue;
 
 /**
  * {@link MailboxException} which identicate that a user was over-quota

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/mailbox/api/src/main/java/org/apache/james/mailbox/model/Quota.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/main/java/org/apache/james/mailbox/model/Quota.java b/mailbox/api/src/main/java/org/apache/james/mailbox/model/Quota.java
index 8b2a2a8..0ea126f 100644
--- a/mailbox/api/src/main/java/org/apache/james/mailbox/model/Quota.java
+++ b/mailbox/api/src/main/java/org/apache/james/mailbox/model/Quota.java
@@ -20,7 +20,7 @@ package org.apache.james.mailbox.model;
 
 import java.util.Map;
 
-import org.apache.james.mailbox.quota.QuotaValue;
+import org.apache.james.core.quota.QuotaValue;
 
 import com.google.common.base.Objects;
 import com.google.common.base.Preconditions;

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/mailbox/api/src/main/java/org/apache/james/mailbox/model/QuotaRatio.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/main/java/org/apache/james/mailbox/model/QuotaRatio.java b/mailbox/api/src/main/java/org/apache/james/mailbox/model/QuotaRatio.java
index 5ba6bf1..649439f 100644
--- a/mailbox/api/src/main/java/org/apache/james/mailbox/model/QuotaRatio.java
+++ b/mailbox/api/src/main/java/org/apache/james/mailbox/model/QuotaRatio.java
@@ -20,8 +20,8 @@ package org.apache.james.mailbox.model;
 
 import java.util.Objects;
 
-import org.apache.james.mailbox.quota.QuotaCount;
-import org.apache.james.mailbox.quota.QuotaSize;
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
 
 import com.google.common.base.MoreObjects;
 import com.google.common.base.Preconditions;

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/mailbox/api/src/main/java/org/apache/james/mailbox/quota/CurrentQuotaManager.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/main/java/org/apache/james/mailbox/quota/CurrentQuotaManager.java b/mailbox/api/src/main/java/org/apache/james/mailbox/quota/CurrentQuotaManager.java
index ab9ea88..4fe63b5 100644
--- a/mailbox/api/src/main/java/org/apache/james/mailbox/quota/CurrentQuotaManager.java
+++ b/mailbox/api/src/main/java/org/apache/james/mailbox/quota/CurrentQuotaManager.java
@@ -19,6 +19,8 @@
 
 package org.apache.james.mailbox.quota;
 
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.model.QuotaRoot;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/mailbox/api/src/main/java/org/apache/james/mailbox/quota/MaxQuotaManager.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/main/java/org/apache/james/mailbox/quota/MaxQuotaManager.java b/mailbox/api/src/main/java/org/apache/james/mailbox/quota/MaxQuotaManager.java
index 355e786..884ed14 100644
--- a/mailbox/api/src/main/java/org/apache/james/mailbox/quota/MaxQuotaManager.java
+++ b/mailbox/api/src/main/java/org/apache/james/mailbox/quota/MaxQuotaManager.java
@@ -23,6 +23,8 @@ import java.util.Map;
 import java.util.Optional;
 
 import org.apache.james.core.Domain;
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.model.Quota;
 import org.apache.james.mailbox.model.QuotaRoot;

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/mailbox/api/src/main/java/org/apache/james/mailbox/quota/QuotaCount.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/main/java/org/apache/james/mailbox/quota/QuotaCount.java b/mailbox/api/src/main/java/org/apache/james/mailbox/quota/QuotaCount.java
deleted file mode 100644
index ac17fa0..0000000
--- a/mailbox/api/src/main/java/org/apache/james/mailbox/quota/QuotaCount.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-package org.apache.james.mailbox.quota;
-
-import java.util.Optional;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.Objects;
-
-public class QuotaCount implements QuotaValue<QuotaCount> {
-
-    public static QuotaCount unlimited() {
-        return new QuotaCount(Optional.empty());
-    }
-
-    public static QuotaCount count(long value) {
-        return count(Optional.of(value));
-    }
-
-    public static QuotaCount count(Optional<Long> value) {
-        return new QuotaCount(value);
-    }
-
-    private final Optional<Long> value;
-
-    private QuotaCount(Optional<Long> value) {
-        this.value = value;
-    }
-
-    @Override
-    public long asLong() {
-        return value.orElseThrow(IllegalStateException::new);
-    }
-
-    @Override
-    public boolean isLimited() {
-        return value.isPresent();
-    }
-
-    @Override
-    public QuotaCount add(long additionalValue) {
-        return new QuotaCount(value.map(x -> x + additionalValue));
-    }
-
-    @Override
-    public QuotaCount add(QuotaCount additionalValue) {
-        if (additionalValue.isUnlimited()) {
-            return unlimited();
-        }
-        return new QuotaCount(value.map(x -> x + additionalValue.asLong()));
-    }
-
-    @Override
-    public String toString() {
-        return MoreObjects.toStringHelper(this)
-            .add("value", value.map(String::valueOf).orElse("unlimited"))
-            .toString();
-    }
-
-    @Override
-    public boolean isGreaterThan(QuotaCount other) {
-        return value.orElse(Long.MAX_VALUE) > other.value.orElse(Long.MAX_VALUE);
-    }
-
-    @Override
-    public final boolean equals(Object o) {
-        if (o instanceof QuotaCount) {
-            QuotaCount that = (QuotaCount) o;
-            return Objects.equal(this.value, that.value);
-        }
-        return false;
-    }
-
-    @Override
-    public final int hashCode() {
-        return Objects.hashCode(value);
-    }
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/mailbox/api/src/main/java/org/apache/james/mailbox/quota/QuotaManager.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/main/java/org/apache/james/mailbox/quota/QuotaManager.java b/mailbox/api/src/main/java/org/apache/james/mailbox/quota/QuotaManager.java
index 37a3c9e..231d6ad 100644
--- a/mailbox/api/src/main/java/org/apache/james/mailbox/quota/QuotaManager.java
+++ b/mailbox/api/src/main/java/org/apache/james/mailbox/quota/QuotaManager.java
@@ -18,6 +18,8 @@
  ****************************************************************/
 package org.apache.james.mailbox.quota;
 
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.model.Quota;
 import org.apache.james.mailbox.model.QuotaRoot;

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/mailbox/api/src/main/java/org/apache/james/mailbox/quota/QuotaSize.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/main/java/org/apache/james/mailbox/quota/QuotaSize.java b/mailbox/api/src/main/java/org/apache/james/mailbox/quota/QuotaSize.java
deleted file mode 100644
index 4d16e52..0000000
--- a/mailbox/api/src/main/java/org/apache/james/mailbox/quota/QuotaSize.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-package org.apache.james.mailbox.quota;
-
-import java.util.Optional;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.Objects;
-
-public class QuotaSize implements QuotaValue<QuotaSize> {
-
-    public static final QuotaSize QUOTA_SIZE = new QuotaSize(Optional.empty());
-
-    public static QuotaSize unlimited() {
-        return QUOTA_SIZE;
-    }
-
-    public static QuotaSize size(long value) {
-        return size(Optional.of(value));
-    }
-
-    public static QuotaSize size(Optional<Long> value) {
-        return new QuotaSize(value);
-    }
-
-    private final Optional<Long> value;
-
-    private QuotaSize(Optional<Long> value) {
-        this.value = value;
-    }
-
-    @Override
-    public long asLong() {
-        return value.orElseThrow(IllegalStateException::new);
-    }
-
-    @Override
-    public boolean isLimited() {
-        return value.isPresent();
-    }
-
-    @Override
-    public QuotaSize add(long additionalValue) {
-        return new QuotaSize(value.map(x -> x + additionalValue));
-    }
-
-    @Override
-    public QuotaSize add(QuotaSize additionalValue) {
-        if (additionalValue.isUnlimited()) {
-            return unlimited();
-        }
-        return new QuotaSize(value.map(x -> x + additionalValue.asLong()));
-    }
-
-    @Override
-    public boolean isGreaterThan(QuotaSize other) {
-        return value.orElse(Long.MAX_VALUE) > other.value.orElse(Long.MAX_VALUE);
-    }
-
-    @Override
-    public String toString() {
-        return MoreObjects.toStringHelper(this)
-            .add("value", value.map(String::valueOf).orElse("unlimited"))
-            .toString();
-    }
-
-    @Override
-    public final boolean equals(Object o) {
-        if (o instanceof QuotaSize) {
-            QuotaSize that = (QuotaSize) o;
-            return Objects.equal(this.value, that.value);
-        }
-        return false;
-    }
-
-    @Override
-    public final int hashCode() {
-        return Objects.hashCode(value);
-    }
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/mailbox/api/src/main/java/org/apache/james/mailbox/quota/QuotaValue.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/main/java/org/apache/james/mailbox/quota/QuotaValue.java b/mailbox/api/src/main/java/org/apache/james/mailbox/quota/QuotaValue.java
deleted file mode 100644
index 5fe9c89..0000000
--- a/mailbox/api/src/main/java/org/apache/james/mailbox/quota/QuotaValue.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-package org.apache.james.mailbox.quota;
-
-public interface QuotaValue<T extends QuotaValue<T>> {
-
-    long asLong();
-
-    boolean isLimited();
-
-    default boolean isUnlimited() {
-        return !isLimited();
-    }
-
-    T add(long additionalValue);
-
-    T add(T additionalValue);
-
-    boolean isGreaterThan(T other);
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/mailbox/api/src/test/java/org/apache/james/mailbox/manager/ManagerTestResources.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/manager/ManagerTestResources.java b/mailbox/api/src/test/java/org/apache/james/mailbox/manager/ManagerTestResources.java
index 774c06a..58b7292 100644
--- a/mailbox/api/src/test/java/org/apache/james/mailbox/manager/ManagerTestResources.java
+++ b/mailbox/api/src/test/java/org/apache/james/mailbox/manager/ManagerTestResources.java
@@ -25,6 +25,8 @@ import java.util.Calendar;
 
 import javax.mail.Flags;
 
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.mailbox.FlagsBuilder;
 import org.apache.james.mailbox.MailboxManager;
 import org.apache.james.mailbox.MailboxSession;
@@ -35,10 +37,8 @@ import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.mock.MockMail;
 import org.apache.james.mailbox.model.MailboxPath;
 import org.apache.james.mailbox.quota.MaxQuotaManager;
-import org.apache.james.mailbox.quota.QuotaCount;
 import org.apache.james.mailbox.quota.QuotaManager;
 import org.apache.james.mailbox.quota.QuotaRootResolver;
-import org.apache.james.mailbox.quota.QuotaSize;
 
 /**
  * Provide an initialized Mailbox environment where we can run managers tests

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/mailbox/api/src/test/java/org/apache/james/mailbox/manager/QuotaMessageManagerTest.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/manager/QuotaMessageManagerTest.java b/mailbox/api/src/test/java/org/apache/james/mailbox/manager/QuotaMessageManagerTest.java
index d763de3..f8e6308 100644
--- a/mailbox/api/src/test/java/org/apache/james/mailbox/manager/QuotaMessageManagerTest.java
+++ b/mailbox/api/src/test/java/org/apache/james/mailbox/manager/QuotaMessageManagerTest.java
@@ -21,6 +21,8 @@ package org.apache.james.mailbox.manager;
 
 import javax.mail.Flags;
 
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.mailbox.FlagsBuilder;
 import org.apache.james.mailbox.MailboxManager;
 import org.apache.james.mailbox.MailboxSession;
@@ -30,9 +32,7 @@ import org.apache.james.mailbox.mock.MockMail;
 import org.apache.james.mailbox.model.MailboxPath;
 import org.apache.james.mailbox.model.MessageRange;
 import org.apache.james.mailbox.quota.MaxQuotaManager;
-import org.apache.james.mailbox.quota.QuotaCount;
 import org.apache.james.mailbox.quota.QuotaRootResolver;
-import org.apache.james.mailbox.quota.QuotaSize;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/mailbox/api/src/test/java/org/apache/james/mailbox/model/QuotaRatioTest.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/model/QuotaRatioTest.java b/mailbox/api/src/test/java/org/apache/james/mailbox/model/QuotaRatioTest.java
index ac3ad9c..98fc6ce 100644
--- a/mailbox/api/src/test/java/org/apache/james/mailbox/model/QuotaRatioTest.java
+++ b/mailbox/api/src/test/java/org/apache/james/mailbox/model/QuotaRatioTest.java
@@ -21,8 +21,8 @@ package org.apache.james.mailbox.model;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
 
-import org.apache.james.mailbox.quota.QuotaCount;
-import org.apache.james.mailbox.quota.QuotaSize;
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
 import org.junit.jupiter.api.Test;
 
 import nl.jqno.equalsverifier.EqualsVerifier;

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/mailbox/api/src/test/java/org/apache/james/mailbox/model/QuotaTest.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/model/QuotaTest.java b/mailbox/api/src/test/java/org/apache/james/mailbox/model/QuotaTest.java
index bcf360b..e11ebdc 100644
--- a/mailbox/api/src/test/java/org/apache/james/mailbox/model/QuotaTest.java
+++ b/mailbox/api/src/test/java/org/apache/james/mailbox/model/QuotaTest.java
@@ -22,8 +22,8 @@ package org.apache.james.mailbox.model;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
 
-import org.apache.james.mailbox.quota.QuotaCount;
-import org.apache.james.mailbox.quota.QuotaSize;
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
 import org.junit.Test;
 
 public class QuotaTest {

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/mailbox/api/src/test/java/org/apache/james/mailbox/quota/QuotaCountTest.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/quota/QuotaCountTest.java b/mailbox/api/src/test/java/org/apache/james/mailbox/quota/QuotaCountTest.java
deleted file mode 100644
index 9148001..0000000
--- a/mailbox/api/src/test/java/org/apache/james/mailbox/quota/QuotaCountTest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-package org.apache.james.mailbox.quota;
-
-import org.junit.jupiter.api.Test;
-
-import nl.jqno.equalsverifier.EqualsVerifier;
-
-public class QuotaCountTest implements QuotaValueTest<QuotaCount> {
-
-    @Override
-    public QuotaCount instance(long value) {
-        return QuotaCount.count(value);
-    }
-
-    @Override
-    public QuotaCount unlimited() {
-        return QuotaCount.unlimited();
-    }
-
-    @Test
-    public void shouldRespectBeanContract() {
-        EqualsVerifier.forClass(QuotaCount.class).verify();
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/mailbox/api/src/test/java/org/apache/james/mailbox/quota/QuotaFixture.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/quota/QuotaFixture.java b/mailbox/api/src/test/java/org/apache/james/mailbox/quota/QuotaFixture.java
index 740f8c4..594c787 100644
--- a/mailbox/api/src/test/java/org/apache/james/mailbox/quota/QuotaFixture.java
+++ b/mailbox/api/src/test/java/org/apache/james/mailbox/quota/QuotaFixture.java
@@ -19,6 +19,8 @@
 
 package org.apache.james.mailbox.quota;
 
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.mailbox.model.Quota;
 
 public interface QuotaFixture {

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/mailbox/api/src/test/java/org/apache/james/mailbox/quota/QuotaSizeTest.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/quota/QuotaSizeTest.java b/mailbox/api/src/test/java/org/apache/james/mailbox/quota/QuotaSizeTest.java
deleted file mode 100644
index cc036d8..0000000
--- a/mailbox/api/src/test/java/org/apache/james/mailbox/quota/QuotaSizeTest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-package org.apache.james.mailbox.quota;
-
-import org.junit.jupiter.api.Test;
-
-import nl.jqno.equalsverifier.EqualsVerifier;
-
-public class QuotaSizeTest implements QuotaValueTest<QuotaSize> {
-
-    @Override
-    public QuotaSize instance(long value) {
-        return QuotaSize.size(value);
-    }
-
-    @Override
-    public QuotaSize unlimited() {
-        return QuotaSize.unlimited();
-    }
-
-    @Test
-    public void shouldRespectBeanContract() {
-        EqualsVerifier.forClass(QuotaSize.class).verify();
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/mailbox/api/src/test/java/org/apache/james/mailbox/quota/QuotaValueTest.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/quota/QuotaValueTest.java b/mailbox/api/src/test/java/org/apache/james/mailbox/quota/QuotaValueTest.java
deleted file mode 100644
index 57d6b9e..0000000
--- a/mailbox/api/src/test/java/org/apache/james/mailbox/quota/QuotaValueTest.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-package org.apache.james.mailbox.quota;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-import org.junit.jupiter.api.Test;
-
-public interface QuotaValueTest<T extends QuotaValue<T>> {
-
-    T instance(long i);
-
-    T unlimited();
-
-    @Test
-    default void greaterThanShouldReturnFalseWhenFirstEqualToSecond() {
-        assertThat(instance(1).isGreaterThan(instance(1))).isFalse();
-    }
-
-    @Test
-    default void greaterThanShouldReturnFalseWhenFirstSmallerThanSecond() {
-        assertThat(instance(1).isGreaterThan(instance(2))).isFalse();
-    }
-
-    @Test
-    default void greaterThanShouldReturnTrueWhenFirstGreaterThanSecond() {
-        assertThat(instance(2).isGreaterThan(instance(1))).isTrue();
-    }
-
-    @Test
-    default void greaterThanShouldReturnFalseWhenFirstIsLimitedAndSecondUnlimited() {
-        assertThat(instance(1).isGreaterThan(unlimited())).isFalse();
-    }
-
-    @Test
-    default void greaterThanShouldReturnFalseWhenBothAreUnlimited() {
-        assertThat(unlimited().isGreaterThan(unlimited())).isFalse();
-    }
-
-    @Test
-    default void greaterThanShouldReturnTrueWhenFirstIsUnlimitedAndSecondLimited() {
-        assertThat(unlimited().isGreaterThan(instance(1))).isTrue();
-    }
-
-    @Test
-    default void addShouldReturnUnlimitedWhenThisIsUnlimited() {
-        assertThat(unlimited().add(2)).isEqualTo(unlimited());
-    }
-
-    @Test
-    default void addShouldReturnUnlimitedWhenBothAre() {
-        assertThat(unlimited().add(unlimited())).isEqualTo(unlimited());
-    }
-
-    @Test
-    default void addShouldReturnSumResult() {
-        assertThat(instance(12).add(instance(23))).isEqualTo(instance(35));
-    }
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/quota/CassandraCurrentQuotaManager.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/quota/CassandraCurrentQuotaManager.java b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/quota/CassandraCurrentQuotaManager.java
index d6f495c..79f8aa2 100644
--- a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/quota/CassandraCurrentQuotaManager.java
+++ b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/quota/CassandraCurrentQuotaManager.java
@@ -28,12 +28,12 @@ import static com.datastax.driver.core.querybuilder.QueryBuilder.update;
 
 import javax.inject.Inject;
 
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.mailbox.MailboxListener;
 import org.apache.james.mailbox.cassandra.table.CassandraCurrentQuota;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.model.QuotaRoot;
-import org.apache.james.mailbox.quota.QuotaCount;
-import org.apache.james.mailbox.quota.QuotaSize;
 import org.apache.james.mailbox.store.quota.StoreCurrentQuotaManager;
 
 import com.datastax.driver.core.PreparedStatement;

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/quota/CassandraGlobalMaxQuotaDao.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/quota/CassandraGlobalMaxQuotaDao.java b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/quota/CassandraGlobalMaxQuotaDao.java
index 3497ab6..eda028e 100644
--- a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/quota/CassandraGlobalMaxQuotaDao.java
+++ b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/quota/CassandraGlobalMaxQuotaDao.java
@@ -29,9 +29,9 @@ import java.util.Optional;
 
 import javax.inject.Inject;
 
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.mailbox.cassandra.table.CassandraGlobalMaxQuota;
-import org.apache.james.mailbox.quota.QuotaCount;
-import org.apache.james.mailbox.quota.QuotaSize;
 
 import com.datastax.driver.core.PreparedStatement;
 import com.datastax.driver.core.ResultSet;

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/quota/CassandraPerDomainMaxQuotaDao.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/quota/CassandraPerDomainMaxQuotaDao.java b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/quota/CassandraPerDomainMaxQuotaDao.java
index d72f432..0b34759 100644
--- a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/quota/CassandraPerDomainMaxQuotaDao.java
+++ b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/quota/CassandraPerDomainMaxQuotaDao.java
@@ -30,9 +30,9 @@ import java.util.Optional;
 import javax.inject.Inject;
 
 import org.apache.james.core.Domain;
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.mailbox.cassandra.table.CassandraDomainMaxQuota;
-import org.apache.james.mailbox.quota.QuotaCount;
-import org.apache.james.mailbox.quota.QuotaSize;
 
 import com.datastax.driver.core.PreparedStatement;
 import com.datastax.driver.core.ResultSet;

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/quota/CassandraPerUserMaxQuotaDao.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/quota/CassandraPerUserMaxQuotaDao.java b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/quota/CassandraPerUserMaxQuotaDao.java
index 1a861c7..5eeff8f 100644
--- a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/quota/CassandraPerUserMaxQuotaDao.java
+++ b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/quota/CassandraPerUserMaxQuotaDao.java
@@ -29,10 +29,10 @@ import java.util.Optional;
 
 import javax.inject.Inject;
 
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.mailbox.cassandra.table.CassandraMaxQuota;
 import org.apache.james.mailbox.model.QuotaRoot;
-import org.apache.james.mailbox.quota.QuotaCount;
-import org.apache.james.mailbox.quota.QuotaSize;
 
 import com.datastax.driver.core.PreparedStatement;
 import com.datastax.driver.core.ResultSet;

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/quota/CassandraPerUserMaxQuotaManager.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/quota/CassandraPerUserMaxQuotaManager.java b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/quota/CassandraPerUserMaxQuotaManager.java
index fb2178c..e4f7327 100644
--- a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/quota/CassandraPerUserMaxQuotaManager.java
+++ b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/quota/CassandraPerUserMaxQuotaManager.java
@@ -29,11 +29,11 @@ import javax.inject.Inject;
 
 import org.apache.commons.lang3.tuple.Pair;
 import org.apache.james.core.Domain;
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.mailbox.model.Quota;
 import org.apache.james.mailbox.model.QuotaRoot;
 import org.apache.james.mailbox.quota.MaxQuotaManager;
-import org.apache.james.mailbox.quota.QuotaCount;
-import org.apache.james.mailbox.quota.QuotaSize;
 import org.apache.james.util.OptionalUtils;
 
 import com.github.fge.lambdas.Throwing;

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/quota/QuotaCodec.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/quota/QuotaCodec.java b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/quota/QuotaCodec.java
index 3ab6eaa..85470cd 100644
--- a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/quota/QuotaCodec.java
+++ b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/quota/QuotaCodec.java
@@ -21,9 +21,9 @@ package org.apache.james.mailbox.cassandra.quota;
 import java.util.Optional;
 import java.util.function.Function;
 
-import org.apache.james.mailbox.quota.QuotaCount;
-import org.apache.james.mailbox.quota.QuotaSize;
-import org.apache.james.mailbox.quota.QuotaValue;
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
+import org.apache.james.core.quota.QuotaValue;
 
 public class QuotaCodec {
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/quota/JPAPerUserMaxQuotaDAO.java
----------------------------------------------------------------------
diff --git a/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/quota/JPAPerUserMaxQuotaDAO.java b/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/quota/JPAPerUserMaxQuotaDAO.java
index 19e83d8..f0b21d2 100644
--- a/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/quota/JPAPerUserMaxQuotaDAO.java
+++ b/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/quota/JPAPerUserMaxQuotaDAO.java
@@ -28,6 +28,9 @@ import javax.persistence.EntityManagerFactory;
 
 import org.apache.james.backends.jpa.TransactionRunner;
 import org.apache.james.core.Domain;
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
+import org.apache.james.core.quota.QuotaValue;
 import org.apache.james.mailbox.jpa.quota.model.MaxDomainMessageCount;
 import org.apache.james.mailbox.jpa.quota.model.MaxDomainStorage;
 import org.apache.james.mailbox.jpa.quota.model.MaxGlobalMessageCount;
@@ -35,9 +38,6 @@ import org.apache.james.mailbox.jpa.quota.model.MaxGlobalStorage;
 import org.apache.james.mailbox.jpa.quota.model.MaxUserMessageCount;
 import org.apache.james.mailbox.jpa.quota.model.MaxUserStorage;
 import org.apache.james.mailbox.model.QuotaRoot;
-import org.apache.james.mailbox.quota.QuotaCount;
-import org.apache.james.mailbox.quota.QuotaSize;
-import org.apache.james.mailbox.quota.QuotaValue;
 
 public class JPAPerUserMaxQuotaDAO {
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/quota/JPAPerUserMaxQuotaManager.java
----------------------------------------------------------------------
diff --git a/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/quota/JPAPerUserMaxQuotaManager.java b/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/quota/JPAPerUserMaxQuotaManager.java
index e7de42d..dd24bd2 100644
--- a/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/quota/JPAPerUserMaxQuotaManager.java
+++ b/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/quota/JPAPerUserMaxQuotaManager.java
@@ -29,11 +29,11 @@ import javax.inject.Inject;
 
 import org.apache.commons.lang3.tuple.Pair;
 import org.apache.james.core.Domain;
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.mailbox.model.Quota;
 import org.apache.james.mailbox.model.QuotaRoot;
 import org.apache.james.mailbox.quota.MaxQuotaManager;
-import org.apache.james.mailbox.quota.QuotaCount;
-import org.apache.james.mailbox.quota.QuotaSize;
 import org.apache.james.util.OptionalUtils;
 
 import com.github.fge.lambdas.Throwing;

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/quota/JpaCurrentQuotaManager.java
----------------------------------------------------------------------
diff --git a/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/quota/JpaCurrentQuotaManager.java b/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/quota/JpaCurrentQuotaManager.java
index a8f2c54..222a96b 100644
--- a/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/quota/JpaCurrentQuotaManager.java
+++ b/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/quota/JpaCurrentQuotaManager.java
@@ -26,12 +26,12 @@ import javax.persistence.EntityManager;
 import javax.persistence.EntityManagerFactory;
 
 import org.apache.james.backends.jpa.TransactionRunner;
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.mailbox.MailboxListener;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.jpa.quota.model.JpaCurrentQuota;
 import org.apache.james.mailbox.model.QuotaRoot;
-import org.apache.james.mailbox.quota.QuotaCount;
-import org.apache.james.mailbox.quota.QuotaSize;
 import org.apache.james.mailbox.store.quota.StoreCurrentQuotaManager;
 
 import com.google.common.base.Preconditions;

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/quota/model/JpaCurrentQuota.java
----------------------------------------------------------------------
diff --git a/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/quota/model/JpaCurrentQuota.java b/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/quota/model/JpaCurrentQuota.java
index 0b0a201..0011e41 100644
--- a/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/quota/model/JpaCurrentQuota.java
+++ b/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/quota/model/JpaCurrentQuota.java
@@ -24,8 +24,8 @@ import javax.persistence.Entity;
 import javax.persistence.Id;
 import javax.persistence.Table;
 
-import org.apache.james.mailbox.quota.QuotaCount;
-import org.apache.james.mailbox.quota.QuotaSize;
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
 
 @Entity(name = "CurrentQuota")
 @Table(name = "JAMES_QUOTA_CURRENTQUOTA")

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/quota/InMemoryCurrentQuotaManager.java
----------------------------------------------------------------------
diff --git a/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/quota/InMemoryCurrentQuotaManager.java b/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/quota/InMemoryCurrentQuotaManager.java
index d41ad0e..673ac44 100644
--- a/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/quota/InMemoryCurrentQuotaManager.java
+++ b/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/quota/InMemoryCurrentQuotaManager.java
@@ -24,12 +24,12 @@ import java.util.concurrent.atomic.AtomicLong;
 
 import javax.inject.Inject;
 
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.mailbox.MailboxListener;
 import org.apache.james.mailbox.MailboxManager;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.model.QuotaRoot;
-import org.apache.james.mailbox.quota.QuotaCount;
-import org.apache.james.mailbox.quota.QuotaSize;
 import org.apache.james.mailbox.store.quota.CurrentQuotaCalculator;
 import org.apache.james.mailbox.store.quota.StoreCurrentQuotaManager;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/quota/InMemoryPerUserMaxQuotaManager.java
----------------------------------------------------------------------
diff --git a/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/quota/InMemoryPerUserMaxQuotaManager.java b/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/quota/InMemoryPerUserMaxQuotaManager.java
index 9c42e38..b2b56a7 100644
--- a/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/quota/InMemoryPerUserMaxQuotaManager.java
+++ b/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/quota/InMemoryPerUserMaxQuotaManager.java
@@ -26,11 +26,11 @@ import java.util.stream.Stream;
 
 import org.apache.commons.lang3.tuple.Pair;
 import org.apache.james.core.Domain;
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.mailbox.model.Quota;
 import org.apache.james.mailbox.model.QuotaRoot;
 import org.apache.james.mailbox.quota.MaxQuotaManager;
-import org.apache.james.mailbox.quota.QuotaCount;
-import org.apache.james.mailbox.quota.QuotaSize;
 import org.apache.james.util.OptionalUtils;
 
 import com.github.fge.lambdas.Throwing;

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/quota/InMemoryCurrentQuotaManagerTest.java
----------------------------------------------------------------------
diff --git a/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/quota/InMemoryCurrentQuotaManagerTest.java b/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/quota/InMemoryCurrentQuotaManagerTest.java
index 3ea0438..4707ea4 100644
--- a/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/quota/InMemoryCurrentQuotaManagerTest.java
+++ b/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/quota/InMemoryCurrentQuotaManagerTest.java
@@ -25,10 +25,10 @@ import static org.mockito.Mockito.when;
 
 import java.util.Optional;
 
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.mailbox.MailboxManager;
 import org.apache.james.mailbox.model.QuotaRoot;
-import org.apache.james.mailbox.quota.QuotaCount;
-import org.apache.james.mailbox.quota.QuotaSize;
 import org.apache.james.mailbox.store.quota.CurrentQuotaCalculator;
 import org.junit.Before;
 import org.junit.Test;

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/mailbox/plugin/quota-mailing-cassandra/src/main/java/org/apache/james/mailbox/quota/cassandra/dto/QuotaDTO.java
----------------------------------------------------------------------
diff --git a/mailbox/plugin/quota-mailing-cassandra/src/main/java/org/apache/james/mailbox/quota/cassandra/dto/QuotaDTO.java b/mailbox/plugin/quota-mailing-cassandra/src/main/java/org/apache/james/mailbox/quota/cassandra/dto/QuotaDTO.java
index bf204c8..30b0685 100644
--- a/mailbox/plugin/quota-mailing-cassandra/src/main/java/org/apache/james/mailbox/quota/cassandra/dto/QuotaDTO.java
+++ b/mailbox/plugin/quota-mailing-cassandra/src/main/java/org/apache/james/mailbox/quota/cassandra/dto/QuotaDTO.java
@@ -21,9 +21,9 @@ package org.apache.james.mailbox.quota.cassandra.dto;
 
 import java.util.Optional;
 
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.mailbox.model.Quota;
-import org.apache.james.mailbox.quota.QuotaCount;
-import org.apache.james.mailbox.quota.QuotaSize;
 
 import com.fasterxml.jackson.annotation.JsonCreator;
 import com.fasterxml.jackson.annotation.JsonIgnore;

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/mailbox/plugin/quota-mailing-cassandra/src/test/java/org/apache/james/mailbox/quota/cassandra/dto/DTOTest.java
----------------------------------------------------------------------
diff --git a/mailbox/plugin/quota-mailing-cassandra/src/test/java/org/apache/james/mailbox/quota/cassandra/dto/DTOTest.java b/mailbox/plugin/quota-mailing-cassandra/src/test/java/org/apache/james/mailbox/quota/cassandra/dto/DTOTest.java
index 5ed61ab..93a9a35 100644
--- a/mailbox/plugin/quota-mailing-cassandra/src/test/java/org/apache/james/mailbox/quota/cassandra/dto/DTOTest.java
+++ b/mailbox/plugin/quota-mailing-cassandra/src/test/java/org/apache/james/mailbox/quota/cassandra/dto/DTOTest.java
@@ -27,11 +27,11 @@ import static org.assertj.core.api.Assertions.assertThat;
 import java.time.Instant;
 
 import org.apache.james.core.User;
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.eventsourcing.EventId;
 import org.apache.james.eventsourcing.eventstore.cassandra.JsonEventSerializer;
 import org.apache.james.mailbox.model.Quota;
-import org.apache.james.mailbox.quota.QuotaCount;
-import org.apache.james.mailbox.quota.QuotaSize;
 import org.apache.james.mailbox.quota.mailing.aggregates.UserQuotaThresholds;
 import org.apache.james.mailbox.quota.mailing.events.QuotaThresholdChangedEvent;
 import org.apache.james.mailbox.quota.model.HistoryEvolution;

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/mailbox/plugin/quota-mailing/src/main/java/org/apache/james/mailbox/quota/mailing/aggregates/UserQuotaThresholds.java
----------------------------------------------------------------------
diff --git a/mailbox/plugin/quota-mailing/src/main/java/org/apache/james/mailbox/quota/mailing/aggregates/UserQuotaThresholds.java b/mailbox/plugin/quota-mailing/src/main/java/org/apache/james/mailbox/quota/mailing/aggregates/UserQuotaThresholds.java
index 5ae7835..9b09e13 100644
--- a/mailbox/plugin/quota-mailing/src/main/java/org/apache/james/mailbox/quota/mailing/aggregates/UserQuotaThresholds.java
+++ b/mailbox/plugin/quota-mailing/src/main/java/org/apache/james/mailbox/quota/mailing/aggregates/UserQuotaThresholds.java
@@ -26,11 +26,11 @@ import java.util.Objects;
 import java.util.stream.Collectors;
 
 import org.apache.james.core.User;
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.eventsourcing.AggregateId;
 import org.apache.james.eventsourcing.eventstore.History;
 import org.apache.james.mailbox.model.Quota;
-import org.apache.james.mailbox.quota.QuotaCount;
-import org.apache.james.mailbox.quota.QuotaSize;
 import org.apache.james.mailbox.quota.mailing.QuotaMailingListenerConfiguration;
 import org.apache.james.mailbox.quota.mailing.commands.DetectThresholdCrossing;
 import org.apache.james.mailbox.quota.mailing.events.QuotaThresholdChangedEvent;

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/mailbox/plugin/quota-mailing/src/main/java/org/apache/james/mailbox/quota/mailing/commands/DetectThresholdCrossing.java
----------------------------------------------------------------------
diff --git a/mailbox/plugin/quota-mailing/src/main/java/org/apache/james/mailbox/quota/mailing/commands/DetectThresholdCrossing.java b/mailbox/plugin/quota-mailing/src/main/java/org/apache/james/mailbox/quota/mailing/commands/DetectThresholdCrossing.java
index 1128c0b..2f9547a 100644
--- a/mailbox/plugin/quota-mailing/src/main/java/org/apache/james/mailbox/quota/mailing/commands/DetectThresholdCrossing.java
+++ b/mailbox/plugin/quota-mailing/src/main/java/org/apache/james/mailbox/quota/mailing/commands/DetectThresholdCrossing.java
@@ -23,10 +23,10 @@ import java.time.Instant;
 import java.util.Objects;
 
 import org.apache.james.core.User;
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.eventsourcing.Command;
 import org.apache.james.mailbox.model.Quota;
-import org.apache.james.mailbox.quota.QuotaCount;
-import org.apache.james.mailbox.quota.QuotaSize;
 
 public class DetectThresholdCrossing implements Command {
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/mailbox/plugin/quota-mailing/src/main/java/org/apache/james/mailbox/quota/mailing/events/QuotaThresholdChangedEvent.java
----------------------------------------------------------------------
diff --git a/mailbox/plugin/quota-mailing/src/main/java/org/apache/james/mailbox/quota/mailing/events/QuotaThresholdChangedEvent.java b/mailbox/plugin/quota-mailing/src/main/java/org/apache/james/mailbox/quota/mailing/events/QuotaThresholdChangedEvent.java
index 1c036f7..99022f3 100644
--- a/mailbox/plugin/quota-mailing/src/main/java/org/apache/james/mailbox/quota/mailing/events/QuotaThresholdChangedEvent.java
+++ b/mailbox/plugin/quota-mailing/src/main/java/org/apache/james/mailbox/quota/mailing/events/QuotaThresholdChangedEvent.java
@@ -21,11 +21,11 @@ package org.apache.james.mailbox.quota.mailing.events;
 
 import java.util.Objects;
 
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.eventsourcing.Event;
 import org.apache.james.eventsourcing.EventId;
 import org.apache.james.mailbox.model.Quota;
-import org.apache.james.mailbox.quota.QuotaCount;
-import org.apache.james.mailbox.quota.QuotaSize;
 import org.apache.james.mailbox.quota.mailing.aggregates.UserQuotaThresholds;
 import org.apache.james.mailbox.quota.model.HistoryEvolution;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/mailbox/plugin/quota-mailing/src/main/java/org/apache/james/mailbox/quota/mailing/subscribers/QuotaThresholdNotice.java
----------------------------------------------------------------------
diff --git a/mailbox/plugin/quota-mailing/src/main/java/org/apache/james/mailbox/quota/mailing/subscribers/QuotaThresholdNotice.java b/mailbox/plugin/quota-mailing/src/main/java/org/apache/james/mailbox/quota/mailing/subscribers/QuotaThresholdNotice.java
index 1d3fdc8..884f4a1 100644
--- a/mailbox/plugin/quota-mailing/src/main/java/org/apache/james/mailbox/quota/mailing/subscribers/QuotaThresholdNotice.java
+++ b/mailbox/plugin/quota-mailing/src/main/java/org/apache/james/mailbox/quota/mailing/subscribers/QuotaThresholdNotice.java
@@ -34,10 +34,10 @@ import java.util.stream.Stream;
 
 import org.apache.commons.io.IOUtils;
 import org.apache.james.core.builder.MimeMessageBuilder;
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.filesystem.api.FileSystem;
 import org.apache.james.mailbox.model.Quota;
-import org.apache.james.mailbox.quota.QuotaCount;
-import org.apache.james.mailbox.quota.QuotaSize;
 import org.apache.james.mailbox.quota.mailing.QuotaMailingListenerConfiguration;
 import org.apache.james.mailbox.quota.model.HistoryEvolution;
 import org.apache.james.mailbox.quota.model.QuotaThreshold;

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/mailbox/plugin/quota-mailing/src/test/java/org/apache/james/mailbox/quota/mailing/subscribers/QuotaThresholdNoticeTest.java
----------------------------------------------------------------------
diff --git a/mailbox/plugin/quota-mailing/src/test/java/org/apache/james/mailbox/quota/mailing/subscribers/QuotaThresholdNoticeTest.java b/mailbox/plugin/quota-mailing/src/test/java/org/apache/james/mailbox/quota/mailing/subscribers/QuotaThresholdNoticeTest.java
index 8ddcf64..f62ad85 100644
--- a/mailbox/plugin/quota-mailing/src/test/java/org/apache/james/mailbox/quota/mailing/subscribers/QuotaThresholdNoticeTest.java
+++ b/mailbox/plugin/quota-mailing/src/test/java/org/apache/james/mailbox/quota/mailing/subscribers/QuotaThresholdNoticeTest.java
@@ -29,12 +29,12 @@ import static org.assertj.core.api.Assertions.assertThat;
 
 import java.util.Optional;
 
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.filesystem.api.FileSystem;
 import org.apache.james.mailbox.model.Quota;
-import org.apache.james.mailbox.quota.QuotaCount;
 import org.apache.james.mailbox.quota.QuotaFixture.Counts;
 import org.apache.james.mailbox.quota.QuotaFixture.Sizes;
-import org.apache.james.mailbox.quota.QuotaSize;
 import org.apache.james.mailbox.quota.mailing.QuotaMailingListenerConfiguration;
 import org.apache.james.mailbox.quota.mailing.QuotaMailingListenerConfiguration.RenderingInformation;
 import org.apache.james.mailbox.quota.model.HistoryEvolution;

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/mailbox/plugin/quota-mailing/src/test/java/org/apache/james/mailbox/quota/model/QuotaThresholdTest.java
----------------------------------------------------------------------
diff --git a/mailbox/plugin/quota-mailing/src/test/java/org/apache/james/mailbox/quota/model/QuotaThresholdTest.java b/mailbox/plugin/quota-mailing/src/test/java/org/apache/james/mailbox/quota/model/QuotaThresholdTest.java
index 2d850be..f316459 100644
--- a/mailbox/plugin/quota-mailing/src/test/java/org/apache/james/mailbox/quota/model/QuotaThresholdTest.java
+++ b/mailbox/plugin/quota-mailing/src/test/java/org/apache/james/mailbox/quota/model/QuotaThresholdTest.java
@@ -26,9 +26,9 @@ import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.assertThatCode;
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
 
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.mailbox.model.Quota;
 import org.apache.james.mailbox.quota.QuotaFixture.Sizes;
-import org.apache.james.mailbox.quota.QuotaSize;
 import org.junit.jupiter.api.Test;
 
 import nl.jqno.equalsverifier.EqualsVerifier;

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/mailbox/plugin/quota-mailing/src/test/java/org/apache/james/mailbox/quota/model/QuotaThresholdsTest.java
----------------------------------------------------------------------
diff --git a/mailbox/plugin/quota-mailing/src/test/java/org/apache/james/mailbox/quota/model/QuotaThresholdsTest.java b/mailbox/plugin/quota-mailing/src/test/java/org/apache/james/mailbox/quota/model/QuotaThresholdsTest.java
index f7f18f6..4674f02 100644
--- a/mailbox/plugin/quota-mailing/src/test/java/org/apache/james/mailbox/quota/model/QuotaThresholdsTest.java
+++ b/mailbox/plugin/quota-mailing/src/test/java/org/apache/james/mailbox/quota/model/QuotaThresholdsTest.java
@@ -25,9 +25,9 @@ import static org.apache.james.mailbox.quota.model.QuotaThresholdFixture._95;
 import static org.apache.james.mailbox.quota.model.QuotaThresholdFixture._99;
 import static org.assertj.core.api.Assertions.assertThat;
 
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.mailbox.model.Quota;
 import org.apache.james.mailbox.quota.QuotaFixture.Sizes;
-import org.apache.james.mailbox.quota.QuotaSize;
 import org.junit.jupiter.api.Test;
 
 import com.google.common.collect.ImmutableList;

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/mailbox/plugin/quota-search-elasticsearch/src/test/java/org/apache/james/quota/search/elasticsearch/json/QuotaRatioAsJsonTest.java
----------------------------------------------------------------------
diff --git a/mailbox/plugin/quota-search-elasticsearch/src/test/java/org/apache/james/quota/search/elasticsearch/json/QuotaRatioAsJsonTest.java b/mailbox/plugin/quota-search-elasticsearch/src/test/java/org/apache/james/quota/search/elasticsearch/json/QuotaRatioAsJsonTest.java
index 32a1aca..b2c6411 100644
--- a/mailbox/plugin/quota-search-elasticsearch/src/test/java/org/apache/james/quota/search/elasticsearch/json/QuotaRatioAsJsonTest.java
+++ b/mailbox/plugin/quota-search-elasticsearch/src/test/java/org/apache/james/quota/search/elasticsearch/json/QuotaRatioAsJsonTest.java
@@ -23,10 +23,10 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
 
 import java.util.Optional;
 
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.mailbox.model.Quota;
 import org.apache.james.mailbox.model.QuotaRatio;
-import org.apache.james.mailbox.quota.QuotaCount;
-import org.apache.james.mailbox.quota.QuotaSize;
 import org.junit.jupiter.api.Test;
 
 import nl.jqno.equalsverifier.EqualsVerifier;


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


[12/20] james-project git commit: JAMES-2151 Solve IntelliJ warnings in CassandraSieveRepository

Posted by bt...@apache.org.
JAMES-2151 Solve IntelliJ warnings in CassandraSieveRepository


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

Branch: refs/heads/master
Commit: 2e8f3f755d25b610c3e45c8b6d6f54eb412086ff
Parents: ff2113e
Author: benwa <bt...@linagora.com>
Authored: Mon Jun 25 10:44:08 2018 +0700
Committer: benwa <bt...@linagora.com>
Committed: Tue Jun 26 16:07:50 2018 +0700

----------------------------------------------------------------------
 .../sieve/cassandra/CassandraSieveRepository.java  | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/2e8f3f75/server/data/data-cassandra/src/main/java/org/apache/james/sieve/cassandra/CassandraSieveRepository.java
----------------------------------------------------------------------
diff --git a/server/data/data-cassandra/src/main/java/org/apache/james/sieve/cassandra/CassandraSieveRepository.java b/server/data/data-cassandra/src/main/java/org/apache/james/sieve/cassandra/CassandraSieveRepository.java
index b4ca04b..56a7563 100644
--- a/server/data/data-cassandra/src/main/java/org/apache/james/sieve/cassandra/CassandraSieveRepository.java
+++ b/server/data/data-cassandra/src/main/java/org/apache/james/sieve/cassandra/CassandraSieveRepository.java
@@ -42,7 +42,6 @@ import org.apache.james.sieverepository.api.exception.IsActiveException;
 import org.apache.james.sieverepository.api.exception.QuotaExceededException;
 import org.apache.james.sieverepository.api.exception.QuotaNotFoundException;
 import org.apache.james.sieverepository.api.exception.ScriptNotFoundException;
-import org.apache.james.sieverepository.api.exception.StorageException;
 import org.apache.james.util.CompletableFutureUtil;
 import org.joda.time.DateTime;
 
@@ -60,18 +59,18 @@ public class CassandraSieveRepository implements SieveRepository {
     }
 
     @Override
-    public DateTime getActivationDateForActiveScript(User user) throws StorageException, ScriptNotFoundException {
+    public DateTime getActivationDateForActiveScript(User user) throws ScriptNotFoundException {
         return cassandraActiveScriptDAO.getActiveSctiptInfo(user).join()
             .orElseThrow(ScriptNotFoundException::new)
             .getActivationDate();
     }
 
     @Override
-    public void haveSpace(User user, ScriptName name, long newSize) throws QuotaExceededException, StorageException {
+    public void haveSpace(User user, ScriptName name, long newSize) throws QuotaExceededException {
         throwOnOverQuota(user, spaceThatWillBeUsedByNewScript(user, name, newSize));
     }
 
-    private void throwOnOverQuota(User user, CompletableFuture<Long> sizeDifference) throws QuotaExceededException, StorageException {
+    private void throwOnOverQuota(User user, CompletableFuture<Long> sizeDifference) throws QuotaExceededException {
         CompletableFuture<Optional<QuotaSize>> userQuotaFuture = cassandraSieveQuotaDAO.getQuota(user);
         CompletableFuture<Optional<QuotaSize>> globalQuotaFuture = cassandraSieveQuotaDAO.getQuota();
         CompletableFuture<Long> spaceUsedFuture = cassandraSieveQuotaDAO.spaceUsedBy(user);
@@ -80,7 +79,7 @@ public class CassandraSieveRepository implements SieveRepository {
             .checkOverQuotaUponModification(sizeDifference.join());
     }
 
-    public CompletableFuture<Long> spaceThatWillBeUsedByNewScript(User user, ScriptName name, long scriptSize) {
+    private CompletableFuture<Long> spaceThatWillBeUsedByNewScript(User user, ScriptName name, long scriptSize) {
         return cassandraSieveDAO.getScript(user, name)
             .thenApply(optional -> optional.map(Script::getSize).orElse(0L))
             .thenApply(sizeOfStoredScript -> scriptSize - sizeOfStoredScript);
@@ -94,7 +93,7 @@ public class CassandraSieveRepository implements SieveRepository {
     }
 
     @Override
-    public void putScript(User user, ScriptName name, ScriptContent content) throws QuotaExceededException, StorageException {
+    public void putScript(User user, ScriptName name, ScriptContent content) throws QuotaExceededException {
         CompletableFuture<Long> spaceUsed = spaceThatWillBeUsedByNewScript(user, name, content.length());
         throwOnOverQuota(user, spaceUsed);
 
@@ -109,7 +108,7 @@ public class CassandraSieveRepository implements SieveRepository {
             .join();
     }
 
-    public CompletableFuture<Void> updateSpaceUsed(User user, long spaceUsed) {
+    private CompletableFuture<Void> updateSpaceUsed(User user, long spaceUsed) {
         if (spaceUsed == 0) {
             return CompletableFuture.completedFuture(null);
         }
@@ -241,7 +240,7 @@ public class CassandraSieveRepository implements SieveRepository {
     }
 
     @Override
-    public void removeQuota() throws QuotaNotFoundException {
+    public void removeQuota() {
         cassandraSieveQuotaDAO.removeQuota().join();
     }
 
@@ -267,7 +266,7 @@ public class CassandraSieveRepository implements SieveRepository {
     }
 
     @Override
-    public void removeQuota(User user) throws QuotaNotFoundException {
+    public void removeQuota(User user) {
         cassandraSieveQuotaDAO.removeQuota(user).join();
     }
 


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


[09/20] james-project git commit: JAMES-2151 Update REST API endpoints for Sieve quota

Posted by bt...@apache.org.
JAMES-2151 Update REST API endpoints for Sieve quota

Differentiate /sieve/quota/default from /sieve/quota/users/bob@domain.tld

Also DELETEs should be idempotent.


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

Branch: refs/heads/master
Commit: 3caa3d6c3ae8366f21769000fe4c25b1666d8254
Parents: 685a13b
Author: benwa <bt...@linagora.com>
Authored: Fri Jun 22 11:34:10 2018 +0700
Committer: benwa <bt...@linagora.com>
Committed: Tue Jun 26 16:06:31 2018 +0700

----------------------------------------------------------------------
 .../james/webadmin/routes/SieveQuotaRoutes.java | 29 ++++------
 .../webadmin/routes/SieveQuotaRoutesTest.java   | 58 ++++++++++----------
 2 files changed, 40 insertions(+), 47 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/3caa3d6c/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/SieveQuotaRoutes.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/SieveQuotaRoutes.java b/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/SieveQuotaRoutes.java
index a1fb584..1b99b72 100644
--- a/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/SieveQuotaRoutes.java
+++ b/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/SieveQuotaRoutes.java
@@ -42,6 +42,8 @@ import org.eclipse.jetty.http.HttpStatus;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.google.common.base.Joiner;
+
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
@@ -57,8 +59,9 @@ import spark.Service;
 public class SieveQuotaRoutes implements Routes {
 
     static final String ROOT_PATH = "/sieve/quota";
+    public static final String DEFAULT_QUOTA_PATH = ROOT_PATH + SEPARATOR + "default";
     private static final String USER_ID = "userId";
-    private static final String USER_SIEVE_QUOTA_PATH = ROOT_PATH + SEPARATOR + ":" + USER_ID;
+    private static final String USER_SIEVE_QUOTA_PATH = Joiner.on(SEPARATOR).join(ROOT_PATH, "users", ":" + USER_ID);
     private static final String REQUESTED_SIZE = "requestedSize";
     private static final Logger LOGGER = LoggerFactory.getLogger(SieveQuotaRoutes.class);
 
@@ -92,7 +95,7 @@ public class SieveQuotaRoutes implements Routes {
             @ApiResponse(code = 500, message = "Internal server error - Something went bad on the server side.")
     })
     public void defineGetGlobalSieveQuota(Service service) {
-        service.get(ROOT_PATH, (request, response) -> {
+        service.get(DEFAULT_QUOTA_PATH, (request, response) -> {
             try {
                 QuotaSize sieveQuota = sieveQuotaRepository.getDefaultQuota();
                 response.status(HttpStatus.OK_200);
@@ -119,7 +122,7 @@ public class SieveQuotaRoutes implements Routes {
             @ApiResponse(code = 500, message = "Internal server error - Something went bad on the server side.")
     })
     public void defineUpdateGlobalSieveQuota(Service service) {
-        service.put(ROOT_PATH, (request, response) -> {
+        service.put(DEFAULT_QUOTA_PATH, (request, response) -> {
             try {
                 QuotaSize requestedSize = extractRequestedQuotaSizeFromRequest(request);
                 sieveQuotaRepository.setDefaultQuota(requestedSize);
@@ -145,18 +148,13 @@ public class SieveQuotaRoutes implements Routes {
             @ApiResponse(code = 500, message = "Internal server error - Something went bad on the server side.")
     })
     public void defineRemoveGlobalSieveQuota(Service service) {
-        service.delete(ROOT_PATH, (request, response) -> {
+        service.delete(DEFAULT_QUOTA_PATH, (request, response) -> {
             try {
                 sieveQuotaRepository.removeQuota();
-                response.status(HttpStatus.NO_CONTENT_204);
             } catch (QuotaNotFoundException e) {
-                LOGGER.info("Global sieve quota not set", e);
-                throw ErrorResponder.builder()
-                    .type(ErrorResponder.ErrorType.NOT_FOUND)
-                    .statusCode(HttpStatus.NOT_FOUND_404)
-                    .message("Global sieve quota not set")
-                    .haltError();
+                // Do nothing
             }
+            response.status(HttpStatus.NO_CONTENT_204);
             return Constants.EMPTY_BODY;
         });
     }
@@ -235,15 +233,10 @@ public class SieveQuotaRoutes implements Routes {
             User userId = User.fromUsername(request.params(USER_ID));
             try {
                 sieveQuotaRepository.removeQuota(userId);
-                response.status(HttpStatus.NO_CONTENT_204);
             } catch (QuotaNotFoundException e) {
-                LOGGER.info("User sieve quota not set", e);
-                throw ErrorResponder.builder()
-                    .type(ErrorResponder.ErrorType.NOT_FOUND)
-                    .statusCode(HttpStatus.NOT_FOUND_404)
-                    .message("User sieve quota not set")
-                    .haltError();
+                // Do nothing
             }
+            response.status(HttpStatus.NO_CONTENT_204);
             return Constants.EMPTY_BODY;
         });
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/3caa3d6c/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/SieveQuotaRoutesTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/SieveQuotaRoutesTest.java b/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/SieveQuotaRoutesTest.java
index 41be8cc..80b3891 100644
--- a/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/SieveQuotaRoutesTest.java
+++ b/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/SieveQuotaRoutesTest.java
@@ -20,11 +20,11 @@
 package org.apache.james.webadmin.routes;
 
 import static com.jayway.restassured.RestAssured.given;
-import static org.apache.james.webadmin.Constants.SEPARATOR;
 import static org.apache.james.webadmin.WebAdminServer.NO_CONFIGURATION;
-import static org.apache.james.webadmin.routes.SieveQuotaRoutes.ROOT_PATH;
 import static org.assertj.core.api.Assertions.assertThat;
 
+import org.apache.james.core.User;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.metrics.logger.DefaultMetricFactory;
 import org.apache.james.sieverepository.api.SieveQuotaRepository;
 import org.apache.james.sieverepository.memory.InMemorySieveQuotaRepository;
@@ -41,7 +41,7 @@ import com.jayway.restassured.http.ContentType;
 
 public class SieveQuotaRoutesTest {
 
-    private static final String USER_A = "userA";
+    private static final User USER_A = User.fromUsername("userA");
 
     private WebAdminServer webAdminServer;
     private SieveQuotaRepository sieveRepository;
@@ -67,47 +67,47 @@ public class SieveQuotaRoutesTest {
     @Test
     public void getGlobalSieveQuotaShouldReturn404WhenNoQuotaSet() {
         given()
-            .get(SieveQuotaRoutes.ROOT_PATH)
+            .get("/sieve/quota/default")
         .then()
             .statusCode(404);
     }
 
     @Test
     public void getGlobalSieveQuotaShouldReturnStoredValue() throws Exception {
-        long value = 1000L;
+        QuotaSize value = QuotaSize.size(1000L);
         sieveRepository.setDefaultQuota(value);
 
         long actual =
             given()
-                .get(SieveQuotaRoutes.ROOT_PATH)
+                .get("/sieve/quota/default")
             .then()
                 .statusCode(HttpStatus.OK_200)
                 .contentType(ContentType.JSON)
                 .extract()
                 .as(Long.class);
 
-        assertThat(actual).isEqualTo(value);
+        assertThat(actual).isEqualTo(value.asLong());
     }
 
     @Test
     public void updateGlobalSieveQuotaShouldUpdateStoredValue() throws Exception {
-        sieveRepository.setDefaultQuota(500L);
+        sieveRepository.setDefaultQuota(QuotaSize.size(500L));
         long requiredSize = 1024L;
 
         given()
             .body(requiredSize)
-            .put(SieveQuotaRoutes.ROOT_PATH)
+            .put("/sieve/quota/default")
         .then()
             .statusCode(HttpStatus.NO_CONTENT_204);
 
-        assertThat(sieveRepository.getDefaultQuota()).isEqualTo(requiredSize);
+        assertThat(sieveRepository.getDefaultQuota().asLong()).isEqualTo(requiredSize);
     }
 
     @Test
     public void updateGlobalSieveQuotaShouldReturn400WhenMalformedJSON() {
         given()
             .body("invalid")
-            .put(SieveQuotaRoutes.ROOT_PATH)
+            .put("/sieve/quota/default")
         .then()
             .statusCode(HttpStatus.BAD_REQUEST_400);
     }
@@ -116,7 +116,7 @@ public class SieveQuotaRoutesTest {
     public void updateGlobalSieveQuotaShouldReturn400WhenRequestedSizeNotPositiveInteger() {
         given()
             .body(-100L)
-            .put(SieveQuotaRoutes.ROOT_PATH)
+            .put("/sieve/quota/default")
         .then()
             .statusCode(HttpStatus.BAD_REQUEST_400);
     }
@@ -124,17 +124,17 @@ public class SieveQuotaRoutesTest {
     @Test
     public void removeGlobalSieveQuotaShouldReturn404WhenNoQuotaSet() {
         given()
-            .delete(SieveQuotaRoutes.ROOT_PATH)
+            .delete("/sieve/quota/default")
         .then()
-            .statusCode(HttpStatus.NOT_FOUND_404);
+            .statusCode(HttpStatus.NO_CONTENT_204);
     }
 
     @Test
     public void removeGlobalSieveQuotaShouldRemoveGlobalSieveQuota() throws Exception {
-        sieveRepository.setDefaultQuota(1024L);
+        sieveRepository.setDefaultQuota(QuotaSize.size(1024L));
 
         given()
-            .delete(SieveQuotaRoutes.ROOT_PATH)
+            .delete("/sieve/quota/default")
         .then()
             .statusCode(HttpStatus.NO_CONTENT_204);
     }
@@ -142,47 +142,47 @@ public class SieveQuotaRoutesTest {
     @Test
     public void getPerUserQuotaShouldReturn404WhenNoQuotaSetForUser() {
         given()
-            .get(ROOT_PATH + SEPARATOR + USER_A)
+            .get("/sieve/quota/users/" + USER_A.asString())
         .then()
             .statusCode(HttpStatus.NOT_FOUND_404);
     }
 
     @Test
     public void getPerUserSieveQuotaShouldReturnedStoredValue() throws Exception {
-        long value = 1024L;
+        QuotaSize value = QuotaSize.size(1024L);
         sieveRepository.setQuota(USER_A, value);
 
         long actual =
             given()
-                .get(ROOT_PATH + SEPARATOR + USER_A)
+                .get("/sieve/quota/users/" + USER_A.asString())
             .then()
                 .statusCode(HttpStatus.OK_200)
                 .contentType(ContentType.JSON)
                 .extract()
                 .as(Long.class);
 
-        assertThat(actual).isEqualTo(value);
+        assertThat(actual).isEqualTo(value.asLong());
     }
 
     @Test
     public void updatePerUserSieveQuotaShouldUpdateStoredValue() throws Exception {
-        sieveRepository.setQuota(USER_A, 500L);
+        sieveRepository.setQuota(USER_A, QuotaSize.size(500L));
         long requiredSize = 1024L;
 
         given()
             .body(requiredSize)
-            .put(ROOT_PATH + SEPARATOR + USER_A)
+            .put("/sieve/quota/users/" + USER_A.asString())
         .then()
             .statusCode(HttpStatus.NO_CONTENT_204);
 
-        assertThat(sieveRepository.getQuota(USER_A)).isEqualTo(requiredSize);
+        assertThat(sieveRepository.getQuota(USER_A).asLong()).isEqualTo(requiredSize);
     }
 
     @Test
     public void updatePerUserSieveQuotaShouldReturn400WhenMalformedJSON() {
         given()
             .body("invalid")
-            .put(ROOT_PATH + SEPARATOR + USER_A)
+            .put("/sieve/quota/users/" + USER_A.asString())
         .then()
             .statusCode(HttpStatus.BAD_REQUEST_400);
     }
@@ -191,7 +191,7 @@ public class SieveQuotaRoutesTest {
     public void updatePerUserSieveQuotaShouldReturn400WhenRequestedSizeNotPositiveInteger() {
         given()
             .body(-100L)
-            .put(ROOT_PATH + SEPARATOR + USER_A)
+            .put("/sieve/quota/users/" + USER_A.asString())
         .then()
             .statusCode(HttpStatus.BAD_REQUEST_400);
     }
@@ -199,17 +199,17 @@ public class SieveQuotaRoutesTest {
     @Test
     public void removePerUserSieveQuotaShouldReturn404WhenNoQuotaSetForUser() {
         given()
-            .delete(ROOT_PATH + SEPARATOR + USER_A)
+            .delete("/sieve/quota/users/" + USER_A.asString())
         .then()
-            .statusCode(HttpStatus.NOT_FOUND_404);
+            .statusCode(HttpStatus.NO_CONTENT_204);
     }
 
     @Test
     public void removePerUserSieveQuotaShouldRemoveQuotaForUser() throws Exception {
-        sieveRepository.setQuota(USER_A, 1024L);
+        sieveRepository.setQuota(USER_A, QuotaSize.size(1024));
 
         given()
-            .delete(ROOT_PATH + SEPARATOR + USER_A)
+            .delete("/sieve/quota/users/" + USER_A.asString())
         .then()
             .statusCode(HttpStatus.NO_CONTENT_204);
     }


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


[02/20] james-project git commit: JAMES-2151 SieveRepository default quota methods should have an explicit name

Posted by bt...@apache.org.
JAMES-2151 SieveRepository default quota methods should have an explicit name


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

Branch: refs/heads/master
Commit: 685a13b46fe5a70e0fa3d9d58e9d78c39eec00a5
Parents: 3d0a553
Author: benwa <bt...@linagora.com>
Authored: Fri Jun 22 11:23:31 2018 +0700
Committer: benwa <bt...@linagora.com>
Committed: Tue Jun 26 16:06:31 2018 +0700

----------------------------------------------------------------------
 .../james/modules/protocols/SieveProbeImpl.java |  4 +--
 .../api/SieveQuotaRepository.java               |  6 ++--
 .../cassandra/CassandraSieveRepository.java     |  6 ++--
 .../file/SieveDefaultRepository.java            |  6 ++--
 .../file/SieveFileRepository.java               |  6 ++--
 .../lib/SieveRepositoryManagement.java          |  4 +--
 .../lib/AbstractSieveRepositoryTest.java        | 34 ++++++++++----------
 .../memory/InMemorySieveQuotaRepository.java    |  6 ++--
 .../james/webadmin/routes/SieveQuotaRoutes.java |  4 +--
 .../webadmin/routes/SieveQuotaRoutesTest.java   |  8 ++---
 10 files changed, 42 insertions(+), 42 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/685a13b4/server/container/guice/protocols/managedsieve/src/main/java/org/apache/james/modules/protocols/SieveProbeImpl.java
----------------------------------------------------------------------
diff --git a/server/container/guice/protocols/managedsieve/src/main/java/org/apache/james/modules/protocols/SieveProbeImpl.java b/server/container/guice/protocols/managedsieve/src/main/java/org/apache/james/modules/protocols/SieveProbeImpl.java
index 54ccc24..9e09e44 100644
--- a/server/container/guice/protocols/managedsieve/src/main/java/org/apache/james/modules/protocols/SieveProbeImpl.java
+++ b/server/container/guice/protocols/managedsieve/src/main/java/org/apache/james/modules/protocols/SieveProbeImpl.java
@@ -39,12 +39,12 @@ public class SieveProbeImpl implements GuiceProbe, SieveProbe {
 
     @Override
     public long getSieveQuota() throws Exception {
-        return sieveRepository.getQuota().asLong();
+        return sieveRepository.getDefaultQuota().asLong();
     }
 
     @Override
     public void setSieveQuota(long quota) throws Exception {
-        sieveRepository.setQuota(QuotaSize.size(quota));
+        sieveRepository.setDefaultQuota(QuotaSize.size(quota));
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/james-project/blob/685a13b4/server/data/data-api/src/main/java/org/apache/james/sieverepository/api/SieveQuotaRepository.java
----------------------------------------------------------------------
diff --git a/server/data/data-api/src/main/java/org/apache/james/sieverepository/api/SieveQuotaRepository.java b/server/data/data-api/src/main/java/org/apache/james/sieverepository/api/SieveQuotaRepository.java
index 02206e5..4866b01 100644
--- a/server/data/data-api/src/main/java/org/apache/james/sieverepository/api/SieveQuotaRepository.java
+++ b/server/data/data-api/src/main/java/org/apache/james/sieverepository/api/SieveQuotaRepository.java
@@ -30,11 +30,11 @@ import org.apache.james.sieverepository.api.exception.StorageException;
  */
 public interface SieveQuotaRepository {
 
-    boolean hasQuota() throws StorageException;
+    boolean hasDefaultQuota() throws StorageException;
 
-    QuotaSize getQuota() throws QuotaNotFoundException, StorageException;
+    QuotaSize getDefaultQuota() throws QuotaNotFoundException, StorageException;
 
-    void setQuota(QuotaSize quota) throws StorageException;
+    void setDefaultQuota(QuotaSize quota) throws StorageException;
 
     void removeQuota() throws QuotaNotFoundException, StorageException;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/685a13b4/server/data/data-cassandra/src/main/java/org/apache/james/sieve/cassandra/CassandraSieveRepository.java
----------------------------------------------------------------------
diff --git a/server/data/data-cassandra/src/main/java/org/apache/james/sieve/cassandra/CassandraSieveRepository.java b/server/data/data-cassandra/src/main/java/org/apache/james/sieve/cassandra/CassandraSieveRepository.java
index 73e4626..b4ca04b 100644
--- a/server/data/data-cassandra/src/main/java/org/apache/james/sieve/cassandra/CassandraSieveRepository.java
+++ b/server/data/data-cassandra/src/main/java/org/apache/james/sieve/cassandra/CassandraSieveRepository.java
@@ -222,21 +222,21 @@ public class CassandraSieveRepository implements SieveRepository {
     }
 
     @Override
-    public boolean hasQuota() {
+    public boolean hasDefaultQuota() {
         return cassandraSieveQuotaDAO.getQuota()
             .join()
             .isPresent();
     }
 
     @Override
-    public QuotaSize getQuota() throws QuotaNotFoundException {
+    public QuotaSize getDefaultQuota() throws QuotaNotFoundException {
         return cassandraSieveQuotaDAO.getQuota()
             .join()
             .orElseThrow(QuotaNotFoundException::new);
     }
 
     @Override
-    public void setQuota(QuotaSize quota) {
+    public void setDefaultQuota(QuotaSize quota) {
         cassandraSieveQuotaDAO.setQuota(quota).join();
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/685a13b4/server/data/data-file/src/main/java/org/apache/james/sieverepository/file/SieveDefaultRepository.java
----------------------------------------------------------------------
diff --git a/server/data/data-file/src/main/java/org/apache/james/sieverepository/file/SieveDefaultRepository.java b/server/data/data-file/src/main/java/org/apache/james/sieverepository/file/SieveDefaultRepository.java
index 9dcaea3..bfa8f64 100644
--- a/server/data/data-file/src/main/java/org/apache/james/sieverepository/file/SieveDefaultRepository.java
+++ b/server/data/data-file/src/main/java/org/apache/james/sieverepository/file/SieveDefaultRepository.java
@@ -122,17 +122,17 @@ public class SieveDefaultRepository implements SieveRepository {
     }
 
     @Override
-    public boolean hasQuota() throws StorageException {
+    public boolean hasDefaultQuota() throws StorageException {
         throw apologizeForQuotas();
     }
 
     @Override
-    public QuotaSize getQuota() throws QuotaNotFoundException, StorageException {
+    public QuotaSize getDefaultQuota() throws QuotaNotFoundException, StorageException {
         throw apologizeForQuotas();
     }
 
     @Override
-    public void setQuota(QuotaSize quota) throws StorageException {
+    public void setDefaultQuota(QuotaSize quota) throws StorageException {
         throw apologizeForQuotas();
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/685a13b4/server/data/data-file/src/main/java/org/apache/james/sieverepository/file/SieveFileRepository.java
----------------------------------------------------------------------
diff --git a/server/data/data-file/src/main/java/org/apache/james/sieverepository/file/SieveFileRepository.java b/server/data/data-file/src/main/java/org/apache/james/sieverepository/file/SieveFileRepository.java
index 9c6bbd6..a651ceb 100644
--- a/server/data/data-file/src/main/java/org/apache/james/sieverepository/file/SieveFileRepository.java
+++ b/server/data/data-file/src/main/java/org/apache/james/sieverepository/file/SieveFileRepository.java
@@ -388,12 +388,12 @@ public class SieveFileRepository implements SieveRepository {
     }
 
     @Override
-    public boolean hasQuota() throws StorageException {
+    public boolean hasDefaultQuota() throws StorageException {
         return getQuotaFile().exists();
     }
 
     @Override
-    public QuotaSize getQuota() throws QuotaNotFoundException, StorageException {
+    public QuotaSize getDefaultQuota() throws QuotaNotFoundException, StorageException {
         Long quota = null;
         File file = getQuotaFile();
         if (file.exists()) {
@@ -429,7 +429,7 @@ public class SieveFileRepository implements SieveRepository {
     }
 
     @Override
-    public synchronized void setQuota(QuotaSize quota) throws StorageException {
+    public synchronized void setDefaultQuota(QuotaSize quota) throws StorageException {
         File file = getQuotaFile();
         String content = Long.toString(quota.asLong());
         toFile(file, content);

http://git-wip-us.apache.org/repos/asf/james-project/blob/685a13b4/server/data/data-library/src/main/java/org/apache/james/sieverepository/lib/SieveRepositoryManagement.java
----------------------------------------------------------------------
diff --git a/server/data/data-library/src/main/java/org/apache/james/sieverepository/lib/SieveRepositoryManagement.java b/server/data/data-library/src/main/java/org/apache/james/sieverepository/lib/SieveRepositoryManagement.java
index d60cf1a..0fdd8e9 100644
--- a/server/data/data-library/src/main/java/org/apache/james/sieverepository/lib/SieveRepositoryManagement.java
+++ b/server/data/data-library/src/main/java/org/apache/james/sieverepository/lib/SieveRepositoryManagement.java
@@ -45,12 +45,12 @@ public class SieveRepositoryManagement extends StandardMBean implements SieveRep
 
     @Override
     public long getQuota() throws SieveRepositoryException {
-        return sieveRepository.getQuota().asLong();
+        return sieveRepository.getDefaultQuota().asLong();
     }
 
     @Override
     public void setQuota(long quota) throws SieveRepositoryException {
-        sieveRepository.setQuota(QuotaSize.size(quota));
+        sieveRepository.setDefaultQuota(QuotaSize.size(quota));
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/james-project/blob/685a13b4/server/data/data-library/src/test/java/org/apache/james/sieverepository/lib/AbstractSieveRepositoryTest.java
----------------------------------------------------------------------
diff --git a/server/data/data-library/src/test/java/org/apache/james/sieverepository/lib/AbstractSieveRepositoryTest.java b/server/data/data-library/src/test/java/org/apache/james/sieverepository/lib/AbstractSieveRepositoryTest.java
index fe5b557..4352209 100644
--- a/server/data/data-library/src/test/java/org/apache/james/sieverepository/lib/AbstractSieveRepositoryTest.java
+++ b/server/data/data-library/src/test/java/org/apache/james/sieverepository/lib/AbstractSieveRepositoryTest.java
@@ -88,13 +88,13 @@ public abstract class AbstractSieveRepositoryTest {
 
     @Test
     public void haveSpaceShouldNotThrowWhenQuotaIsNotReached() throws Exception {
-        sieveRepository.setQuota(DEFAULT_QUOTA);
+        sieveRepository.setDefaultQuota(DEFAULT_QUOTA);
         sieveRepository.haveSpace(USER, SCRIPT_NAME, DEFAULT_QUOTA.asLong());
     }
 
     @Test(expected = QuotaExceededException.class)
     public void haveSpaceShouldThrowWhenQuotaIsExceed() throws Exception {
-        sieveRepository.setQuota(DEFAULT_QUOTA);
+        sieveRepository.setDefaultQuota(DEFAULT_QUOTA);
         sieveRepository.haveSpace(USER, SCRIPT_NAME, DEFAULT_QUOTA.asLong() + 1);
     }
 
@@ -160,15 +160,15 @@ public abstract class AbstractSieveRepositoryTest {
 
     @Test(expected = QuotaExceededException.class)
     public void putScriptShouldThrowWhenScriptTooBig() throws Exception {
-        sieveRepository.setQuota(QuotaSize.size(SCRIPT_CONTENT.length() - 1));
+        sieveRepository.setDefaultQuota(QuotaSize.size(SCRIPT_CONTENT.length() - 1));
         sieveRepository.putScript(USER, SCRIPT_NAME, SCRIPT_CONTENT);
     }
 
     @Test(expected = QuotaExceededException.class)
     public void putScriptShouldThrowWhenQuotaChangedInBetween() throws Exception {
-        sieveRepository.setQuota(QuotaSize.size(SCRIPT_CONTENT.length()));
+        sieveRepository.setDefaultQuota(QuotaSize.size(SCRIPT_CONTENT.length()));
         sieveRepository.putScript(USER, SCRIPT_NAME, SCRIPT_CONTENT);
-        sieveRepository.setQuota(QuotaSize.size(SCRIPT_CONTENT.length() - 1));
+        sieveRepository.setDefaultQuota(QuotaSize.size(SCRIPT_CONTENT.length() - 1));
         sieveRepository.putScript(USER, SCRIPT_NAME, SCRIPT_CONTENT);
     }
 
@@ -262,13 +262,13 @@ public abstract class AbstractSieveRepositoryTest {
 
     @Test(expected = QuotaNotFoundException.class)
     public void getQuotaShouldThrowIfQuotaNotFound() throws Exception {
-        sieveRepository.getQuota();
+        sieveRepository.getDefaultQuota();
     }
 
     @Test
     public void getQuotaShouldWork() throws Exception {
-        sieveRepository.setQuota(DEFAULT_QUOTA);
-        assertThat(sieveRepository.getQuota()).isEqualTo(DEFAULT_QUOTA);
+        sieveRepository.setDefaultQuota(DEFAULT_QUOTA);
+        assertThat(sieveRepository.getDefaultQuota()).isEqualTo(DEFAULT_QUOTA);
     }
 
     @Test
@@ -279,18 +279,18 @@ public abstract class AbstractSieveRepositoryTest {
 
     @Test
     public void hasQuotaShouldReturnFalseWhenRepositoryDoesNotHaveQuota() throws Exception {
-        assertThat(sieveRepository.hasQuota()).isFalse();
+        assertThat(sieveRepository.hasDefaultQuota()).isFalse();
     }
 
     @Test
     public void hasQuotaShouldReturnTrueWhenRepositoryHaveQuota() throws Exception {
-        sieveRepository.setQuota(DEFAULT_QUOTA);
-        assertThat(sieveRepository.hasQuota()).isTrue();
+        sieveRepository.setDefaultQuota(DEFAULT_QUOTA);
+        assertThat(sieveRepository.hasDefaultQuota()).isTrue();
     }
 
     @Test
     public void hasQuotaShouldReturnFalseWhenUserDoesNotHaveQuota() throws Exception {
-        assertThat(sieveRepository.hasQuota()).isFalse();
+        assertThat(sieveRepository.hasDefaultQuota()).isFalse();
     }
 
     @Test
@@ -311,9 +311,9 @@ public abstract class AbstractSieveRepositoryTest {
 
     @Test
     public void removeQuotaShouldWorkOnRepositories() throws Exception {
-        sieveRepository.setQuota(DEFAULT_QUOTA);
+        sieveRepository.setDefaultQuota(DEFAULT_QUOTA);
         sieveRepository.removeQuota();
-        assertThat(sieveRepository.hasQuota()).isFalse();
+        assertThat(sieveRepository.hasDefaultQuota()).isFalse();
     }
 
     @Test
@@ -325,7 +325,7 @@ public abstract class AbstractSieveRepositoryTest {
 
     @Test(expected = QuotaNotFoundException.class)
     public void removeQuotaShouldWorkOnUsersWithGlobalQuota() throws Exception {
-        sieveRepository.setQuota(DEFAULT_QUOTA);
+        sieveRepository.setDefaultQuota(DEFAULT_QUOTA);
         sieveRepository.setQuota(USER, USER_QUOTA);
         sieveRepository.removeQuota(USER);
         sieveRepository.getQuota(USER);
@@ -333,8 +333,8 @@ public abstract class AbstractSieveRepositoryTest {
 
     @Test
     public void setQuotaShouldWork() throws Exception {
-        sieveRepository.setQuota(DEFAULT_QUOTA);
-        assertThat(sieveRepository.getQuota()).isEqualTo(DEFAULT_QUOTA);
+        sieveRepository.setDefaultQuota(DEFAULT_QUOTA);
+        assertThat(sieveRepository.getDefaultQuota()).isEqualTo(DEFAULT_QUOTA);
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/james-project/blob/685a13b4/server/data/data-memory/src/main/java/org/apache/james/sieverepository/memory/InMemorySieveQuotaRepository.java
----------------------------------------------------------------------
diff --git a/server/data/data-memory/src/main/java/org/apache/james/sieverepository/memory/InMemorySieveQuotaRepository.java b/server/data/data-memory/src/main/java/org/apache/james/sieverepository/memory/InMemorySieveQuotaRepository.java
index 8820ee9..3ca888f 100644
--- a/server/data/data-memory/src/main/java/org/apache/james/sieverepository/memory/InMemorySieveQuotaRepository.java
+++ b/server/data/data-memory/src/main/java/org/apache/james/sieverepository/memory/InMemorySieveQuotaRepository.java
@@ -35,17 +35,17 @@ public class InMemorySieveQuotaRepository implements SieveQuotaRepository {
     private Map<User, QuotaSize> userQuota = new ConcurrentHashMap<>();
 
     @Override
-    public boolean hasQuota() {
+    public boolean hasDefaultQuota() {
         return globalQuota.isPresent();
     }
 
     @Override
-    public QuotaSize getQuota() throws QuotaNotFoundException {
+    public QuotaSize getDefaultQuota() throws QuotaNotFoundException {
         return globalQuota.orElseThrow(QuotaNotFoundException::new);
     }
 
     @Override
-    public void setQuota(QuotaSize quota) {
+    public void setDefaultQuota(QuotaSize quota) {
         this.globalQuota = Optional.of(quota);
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/685a13b4/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/SieveQuotaRoutes.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/SieveQuotaRoutes.java b/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/SieveQuotaRoutes.java
index c0abc61..a1fb584 100644
--- a/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/SieveQuotaRoutes.java
+++ b/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/SieveQuotaRoutes.java
@@ -94,7 +94,7 @@ public class SieveQuotaRoutes implements Routes {
     public void defineGetGlobalSieveQuota(Service service) {
         service.get(ROOT_PATH, (request, response) -> {
             try {
-                QuotaSize sieveQuota = sieveQuotaRepository.getQuota();
+                QuotaSize sieveQuota = sieveQuotaRepository.getDefaultQuota();
                 response.status(HttpStatus.OK_200);
                 return sieveQuota.asLong();
             } catch (QuotaNotFoundException e) {
@@ -122,7 +122,7 @@ public class SieveQuotaRoutes implements Routes {
         service.put(ROOT_PATH, (request, response) -> {
             try {
                 QuotaSize requestedSize = extractRequestedQuotaSizeFromRequest(request);
-                sieveQuotaRepository.setQuota(requestedSize);
+                sieveQuotaRepository.setDefaultQuota(requestedSize);
                 response.status(HttpStatus.NO_CONTENT_204);
                 return Constants.EMPTY_BODY;
             } catch (JsonExtractException e) {

http://git-wip-us.apache.org/repos/asf/james-project/blob/685a13b4/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/SieveQuotaRoutesTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/SieveQuotaRoutesTest.java b/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/SieveQuotaRoutesTest.java
index 02d3ef1..41be8cc 100644
--- a/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/SieveQuotaRoutesTest.java
+++ b/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/SieveQuotaRoutesTest.java
@@ -75,7 +75,7 @@ public class SieveQuotaRoutesTest {
     @Test
     public void getGlobalSieveQuotaShouldReturnStoredValue() throws Exception {
         long value = 1000L;
-        sieveRepository.setQuota(value);
+        sieveRepository.setDefaultQuota(value);
 
         long actual =
             given()
@@ -91,7 +91,7 @@ public class SieveQuotaRoutesTest {
 
     @Test
     public void updateGlobalSieveQuotaShouldUpdateStoredValue() throws Exception {
-        sieveRepository.setQuota(500L);
+        sieveRepository.setDefaultQuota(500L);
         long requiredSize = 1024L;
 
         given()
@@ -100,7 +100,7 @@ public class SieveQuotaRoutesTest {
         .then()
             .statusCode(HttpStatus.NO_CONTENT_204);
 
-        assertThat(sieveRepository.getQuota()).isEqualTo(requiredSize);
+        assertThat(sieveRepository.getDefaultQuota()).isEqualTo(requiredSize);
     }
 
     @Test
@@ -131,7 +131,7 @@ public class SieveQuotaRoutesTest {
 
     @Test
     public void removeGlobalSieveQuotaShouldRemoveGlobalSieveQuota() throws Exception {
-        sieveRepository.setQuota(1024L);
+        sieveRepository.setDefaultQuota(1024L);
 
         given()
             .delete(SieveQuotaRoutes.ROOT_PATH)


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


[10/20] james-project git commit: JAMES-2151 Add website documentation for WebAdmin Sieve quotas

Posted by bt...@apache.org.
JAMES-2151 Add website documentation for WebAdmin Sieve quotas


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

Branch: refs/heads/master
Commit: e8d5319d2af59af9eef6cf0b636b346a2a3cd92d
Parents: b9ac736
Author: benwa <bt...@linagora.com>
Authored: Wed Jun 20 16:15:28 2018 +0700
Committer: benwa <bt...@linagora.com>
Committed: Tue Jun 26 16:06:31 2018 +0700

----------------------------------------------------------------------
 src/site/markdown/server/manage-webadmin.md | 105 +++++++++++++++++++++++
 1 file changed, 105 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/e8d5319d/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 f516efd..71e6cf0 100644
--- a/src/site/markdown/server/manage-webadmin.md
+++ b/src/site/markdown/server/manage-webadmin.md
@@ -34,6 +34,7 @@ In case of any error, the system will return an error message which is json form
  - [Administrating mail repositories](#Administrating_mail_repositories)
  - [Administrating mail queues](#Administrating_mail_queues)
  - [Administrating DLP Configuration](#Administrating_dlp_configuration)
+ - [Administrating Sieve quotas](#Administrating_Sieve_quotas)
  - [Task management](#Task_management)
 
 ## Administrating domains
@@ -1926,6 +1927,110 @@ Response codes:
  - 404: The domain does not exist.
  - 500: Internal error
 
+## Administrating Sieve quotas
+
+Some limitations on space Users Sieve script can occupy can be configured by default, and overridden by user.
+
+ - [Retrieving global sieve quota](#Retieving_global_sieve_quota)
+ - [Updating global sieve quota](#Updating_global_sieve_quota)
+ - [Removing global sieve quota](#Removing_global_sieve_quota)
+ - [Retieving user sieve quota](#Retieving_user_sieve_quota)
+ - [Updating user sieve quota](#Updating_user_sieve_quota)
+ - [Removing user sieve quota](#Removing_user_sieve_quota)
+
+### Retrieving global sieve quota
+
+This endpoints allows to retrieve the global Sieve quota, which will be users default:
+
+```
+curl -XGET http://ip:port/sieve/quota/default
+```
+
+Will return the bytes count allowed by user per default on this server.
+
+```
+102400
+```
+
+Response codes:
+ - 200: Request is a success and the value is returned
+ - 404: No quota is being configured
+
+### Updating global sieve quota
+
+This endpoints allows to update the global Sieve quota, which will be users default:
+
+```
+curl -XPUT http://ip:port/sieve/quota/default
+```
+
+With the body being the bytes count allowed by user per default on this server.
+
+```
+102400
+```
+
+Response codes:
+ - 204: Operation succeeded
+ - 400: Invalid payload
+
+### Removing global sieve quota
+
+This endpoints allows to remove the global Sieve quota. There will no more be users default:
+
+```
+curl -XDELETE http://ip:port/sieve/quota/default
+```
+
+Response codes:
+ - 204: Operation succeeded
+
+### Retrieving user sieve quota
+
+This endpoints allows to retrieve the Sieve quota of a user, which will be this users quota:
+
+```
+curl -XGET http://ip:port/sieve/quota/users/user@domain.com
+```
+
+Will return the bytes count allowed for this user.
+
+```
+102400
+```
+
+Response codes:
+ - 200: Request is a success and the value is returned
+ - 404: No quota is being configured for this user
+
+### Updating user sieve quota
+
+This endpoints allows to update the Sieve quota of a user, which will be users default:
+
+```
+curl -XPUT http://ip:port/sieve/quota/users/user@domain.com
+```
+
+With the body being the bytes count allowed for this user on this server.
+
+```
+102400
+```
+
+Response codes:
+ - 204: Operation succeeded
+ - 400: Invalid payload
+
+### Removing user sieve quota
+
+This endpoints allows to remove the Sieve quota of a user. There will no more quota for this userrrrrrr:
+
+```
+curl -XDELETE http://ip:port/sieve/quota/users/user@domain.com
+```
+
+Response codes:
+ - 204: Operation succeeded
 
 ## Task management
 


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


[07/20] james-project git commit: JAMES-2151 SieveRepository strong typing for User

Posted by bt...@apache.org.
http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/mailbox/plugin/quota-search-scanning/src/main/java/org/apache/james/quota/search/scanning/ClauseConverter.java
----------------------------------------------------------------------
diff --git a/mailbox/plugin/quota-search-scanning/src/main/java/org/apache/james/quota/search/scanning/ClauseConverter.java b/mailbox/plugin/quota-search-scanning/src/main/java/org/apache/james/quota/search/scanning/ClauseConverter.java
index c527a70..8fad3b9 100644
--- a/mailbox/plugin/quota-search-scanning/src/main/java/org/apache/james/quota/search/scanning/ClauseConverter.java
+++ b/mailbox/plugin/quota-search-scanning/src/main/java/org/apache/james/quota/search/scanning/ClauseConverter.java
@@ -26,13 +26,13 @@ import java.util.function.Predicate;
 import javax.inject.Inject;
 
 import org.apache.james.core.User;
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.model.Quota;
 import org.apache.james.mailbox.model.QuotaRatio;
 import org.apache.james.mailbox.model.QuotaRoot;
-import org.apache.james.mailbox.quota.QuotaCount;
 import org.apache.james.mailbox.quota.QuotaManager;
-import org.apache.james.mailbox.quota.QuotaSize;
 import org.apache.james.mailbox.quota.UserQuotaRootResolver;
 import org.apache.james.quota.search.QuotaClause;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/mailbox/plugin/quota-search/src/test/java/org/apache/james/quota/search/QuotaSearcherContract.java
----------------------------------------------------------------------
diff --git a/mailbox/plugin/quota-search/src/test/java/org/apache/james/quota/search/QuotaSearcherContract.java b/mailbox/plugin/quota-search/src/test/java/org/apache/james/quota/search/QuotaSearcherContract.java
index 0abfc21..5463f65 100644
--- a/mailbox/plugin/quota-search/src/test/java/org/apache/james/quota/search/QuotaSearcherContract.java
+++ b/mailbox/plugin/quota-search/src/test/java/org/apache/james/quota/search/QuotaSearcherContract.java
@@ -32,13 +32,13 @@ import java.nio.charset.StandardCharsets;
 import org.apache.james.core.CoreFixture.Users.Alphabet;
 import org.apache.james.core.CoreFixture.Users.Simpson;
 import org.apache.james.core.User;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.domainlist.api.DomainListException;
 import org.apache.james.mailbox.MailboxManager;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.MessageManager;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.model.MailboxPath;
-import org.apache.james.mailbox.quota.QuotaSize;
 import org.apache.james.user.api.UsersRepositoryException;
 import org.junit.jupiter.api.Test;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/MailboxEventDispatcher.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/MailboxEventDispatcher.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/MailboxEventDispatcher.java
index 80dcc18..c897ac9 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/MailboxEventDispatcher.java
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/MailboxEventDispatcher.java
@@ -26,6 +26,8 @@ import java.util.SortedMap;
 
 import javax.inject.Inject;
 
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.mailbox.Event;
 import org.apache.james.mailbox.MailboxListener;
 import org.apache.james.mailbox.MailboxSession;
@@ -37,8 +39,6 @@ import org.apache.james.mailbox.model.MessageMoves;
 import org.apache.james.mailbox.model.Quota;
 import org.apache.james.mailbox.model.QuotaRoot;
 import org.apache.james.mailbox.model.UpdatedFlags;
-import org.apache.james.mailbox.quota.QuotaCount;
-import org.apache.james.mailbox.quota.QuotaSize;
 import org.apache.james.mailbox.store.SimpleMessageMetaData;
 import org.apache.james.mailbox.store.mail.model.Mailbox;
 import org.apache.james.mailbox.store.mail.model.MailboxMessage;

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/SerializableQuota.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/SerializableQuota.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/SerializableQuota.java
index 5f66c16..486aef3 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/SerializableQuota.java
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/SerializableQuota.java
@@ -23,8 +23,8 @@ import java.io.Serializable;
 import java.util.Objects;
 import java.util.Optional;
 
+import org.apache.james.core.quota.QuotaValue;
 import org.apache.james.mailbox.model.Quota;
-import org.apache.james.mailbox.quota.QuotaValue;
 
 import com.google.common.base.MoreObjects;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/SerializableQuotaValue.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/SerializableQuotaValue.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/SerializableQuotaValue.java
index 1773464..bec5271 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/SerializableQuotaValue.java
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/SerializableQuotaValue.java
@@ -24,7 +24,7 @@ import java.util.Objects;
 import java.util.Optional;
 import java.util.function.Function;
 
-import org.apache.james.mailbox.quota.QuotaValue;
+import org.apache.james.core.quota.QuotaValue;
 
 import com.google.common.base.MoreObjects;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/mailbox/store/src/main/java/org/apache/james/mailbox/store/probe/QuotaProbe.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/probe/QuotaProbe.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/probe/QuotaProbe.java
index 2bcbff6..451ee0e 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/probe/QuotaProbe.java
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/probe/QuotaProbe.java
@@ -19,9 +19,9 @@
 
 package org.apache.james.mailbox.store.probe;
 
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.mailbox.exception.MailboxException;
-import org.apache.james.mailbox.quota.QuotaCount;
-import org.apache.james.mailbox.quota.QuotaSize;
 import org.apache.james.mailbox.store.mail.model.SerializableQuota;
 import org.apache.james.mailbox.store.mail.model.SerializableQuotaValue;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/mailbox/store/src/main/java/org/apache/james/mailbox/store/quota/FixedMaxQuotaManager.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/quota/FixedMaxQuotaManager.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/quota/FixedMaxQuotaManager.java
index 3fc825a..0cab231 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/quota/FixedMaxQuotaManager.java
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/quota/FixedMaxQuotaManager.java
@@ -4,13 +4,13 @@ import java.util.Map;
 import java.util.Optional;
 
 import org.apache.james.core.Domain;
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.exception.UnsupportedOperationException;
 import org.apache.james.mailbox.model.Quota;
 import org.apache.james.mailbox.model.QuotaRoot;
 import org.apache.james.mailbox.quota.MaxQuotaManager;
-import org.apache.james.mailbox.quota.QuotaCount;
-import org.apache.james.mailbox.quota.QuotaSize;
 
 import com.google.common.collect.ImmutableMap;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/mailbox/store/src/main/java/org/apache/james/mailbox/store/quota/NoMaxQuotaManager.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/quota/NoMaxQuotaManager.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/quota/NoMaxQuotaManager.java
index d5e290a..9f52bce 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/quota/NoMaxQuotaManager.java
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/quota/NoMaxQuotaManager.java
@@ -23,12 +23,12 @@ import java.util.Map;
 import java.util.Optional;
 
 import org.apache.james.core.Domain;
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.model.Quota;
 import org.apache.james.mailbox.model.QuotaRoot;
 import org.apache.james.mailbox.quota.MaxQuotaManager;
-import org.apache.james.mailbox.quota.QuotaCount;
-import org.apache.james.mailbox.quota.QuotaSize;
 
 import com.google.common.collect.ImmutableMap;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/mailbox/store/src/main/java/org/apache/james/mailbox/store/quota/NoQuotaManager.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/quota/NoQuotaManager.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/quota/NoQuotaManager.java
index 852f91c..ded398a 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/quota/NoQuotaManager.java
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/quota/NoQuotaManager.java
@@ -19,11 +19,11 @@
 
 package org.apache.james.mailbox.store.quota;
 
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.mailbox.model.Quota;
 import org.apache.james.mailbox.model.QuotaRoot;
-import org.apache.james.mailbox.quota.QuotaCount;
 import org.apache.james.mailbox.quota.QuotaManager;
-import org.apache.james.mailbox.quota.QuotaSize;
 
 /**
  * This quota manager is intended to be used when you want to deactivate the Quota feature

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/mailbox/store/src/main/java/org/apache/james/mailbox/store/quota/QuotaChecker.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/quota/QuotaChecker.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/quota/QuotaChecker.java
index 156f92a..fe8c65b 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/quota/QuotaChecker.java
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/quota/QuotaChecker.java
@@ -19,14 +19,14 @@
 
 package org.apache.james.mailbox.store.quota;
 
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.exception.OverQuotaException;
 import org.apache.james.mailbox.model.Quota;
 import org.apache.james.mailbox.model.QuotaRoot;
-import org.apache.james.mailbox.quota.QuotaCount;
 import org.apache.james.mailbox.quota.QuotaManager;
 import org.apache.james.mailbox.quota.QuotaRootResolver;
-import org.apache.james.mailbox.quota.QuotaSize;
 import org.apache.james.mailbox.store.mail.model.Mailbox;
 
 public class QuotaChecker {

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/mailbox/store/src/main/java/org/apache/james/mailbox/store/quota/StoreQuotaManager.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/quota/StoreQuotaManager.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/quota/StoreQuotaManager.java
index b3cf4f0..d2825cb 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/quota/StoreQuotaManager.java
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/quota/StoreQuotaManager.java
@@ -21,14 +21,14 @@ package org.apache.james.mailbox.store.quota;
 
 import javax.inject.Inject;
 
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.model.Quota;
 import org.apache.james.mailbox.model.QuotaRoot;
 import org.apache.james.mailbox.quota.CurrentQuotaManager;
 import org.apache.james.mailbox.quota.MaxQuotaManager;
-import org.apache.james.mailbox.quota.QuotaCount;
 import org.apache.james.mailbox.quota.QuotaManager;
-import org.apache.james.mailbox.quota.QuotaSize;
 
 /**
  * Default implementation for the Quota Manager.

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/mailbox/store/src/test/java/org/apache/james/mailbox/store/AbstractMessageIdManagerQuotaTest.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/AbstractMessageIdManagerQuotaTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/AbstractMessageIdManagerQuotaTest.java
index ecb8796..9571e20 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/AbstractMessageIdManagerQuotaTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/AbstractMessageIdManagerQuotaTest.java
@@ -23,6 +23,8 @@ import static org.apache.james.mailbox.fixture.MailboxFixture.ALICE;
 
 import javax.mail.Flags;
 
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.MessageIdManager;
 import org.apache.james.mailbox.MessageUid;
@@ -32,9 +34,7 @@ import org.apache.james.mailbox.mock.MockMailboxSession;
 import org.apache.james.mailbox.model.MessageId;
 import org.apache.james.mailbox.quota.CurrentQuotaManager;
 import org.apache.james.mailbox.quota.MaxQuotaManager;
-import org.apache.james.mailbox.quota.QuotaCount;
 import org.apache.james.mailbox.quota.QuotaManager;
-import org.apache.james.mailbox.quota.QuotaSize;
 import org.apache.james.mailbox.store.mail.model.Mailbox;
 import org.junit.Before;
 import org.junit.Rule;

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/mailbox/store/src/test/java/org/apache/james/mailbox/store/AbstractMessageIdManagerSideEffectTest.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/AbstractMessageIdManagerSideEffectTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/AbstractMessageIdManagerSideEffectTest.java
index cac1a73..fdf0480 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/AbstractMessageIdManagerSideEffectTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/AbstractMessageIdManagerSideEffectTest.java
@@ -34,6 +34,8 @@ import java.util.List;
 
 import javax.mail.Flags;
 
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.MessageIdManager;
 import org.apache.james.mailbox.MessageManager;
@@ -49,9 +51,7 @@ import org.apache.james.mailbox.model.MessageResult;
 import org.apache.james.mailbox.model.Quota;
 import org.apache.james.mailbox.model.QuotaRoot;
 import org.apache.james.mailbox.model.UpdatedFlags;
-import org.apache.james.mailbox.quota.QuotaCount;
 import org.apache.james.mailbox.quota.QuotaManager;
-import org.apache.james.mailbox.quota.QuotaSize;
 import org.apache.james.mailbox.store.event.MailboxEventDispatcher;
 import org.apache.james.mailbox.store.mail.model.Mailbox;
 import org.apache.james.mailbox.store.mail.model.MailboxMessage;

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/mailbox/store/src/test/java/org/apache/james/mailbox/store/quota/GenericMaxQuotaManagerTest.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/quota/GenericMaxQuotaManagerTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/quota/GenericMaxQuotaManagerTest.java
index 7205cc1..9513974 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/quota/GenericMaxQuotaManagerTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/quota/GenericMaxQuotaManagerTest.java
@@ -24,11 +24,11 @@ import static org.assertj.core.api.Assertions.assertThat;
 import java.util.Optional;
 
 import org.apache.james.core.Domain;
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.mailbox.model.Quota;
 import org.apache.james.mailbox.model.QuotaRoot;
 import org.apache.james.mailbox.quota.MaxQuotaManager;
-import org.apache.james.mailbox.quota.QuotaCount;
-import org.apache.james.mailbox.quota.QuotaSize;
 import org.junit.Before;
 import org.junit.Test;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/mailbox/store/src/test/java/org/apache/james/mailbox/store/quota/QuotaCheckerTest.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/quota/QuotaCheckerTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/quota/QuotaCheckerTest.java
index 0f3aee1..cffd847 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/quota/QuotaCheckerTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/quota/QuotaCheckerTest.java
@@ -25,15 +25,15 @@ import static org.mockito.Mockito.when;
 
 import java.util.Optional;
 
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.exception.OverQuotaException;
 import org.apache.james.mailbox.model.MailboxPath;
 import org.apache.james.mailbox.model.Quota;
 import org.apache.james.mailbox.model.QuotaRoot;
-import org.apache.james.mailbox.quota.QuotaCount;
 import org.apache.james.mailbox.quota.QuotaManager;
 import org.apache.james.mailbox.quota.QuotaRootResolver;
-import org.apache.james.mailbox.quota.QuotaSize;
 import org.apache.james.mailbox.store.mail.model.impl.SimpleMailbox;
 import org.junit.Before;
 import org.junit.Test;

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/mailbox/store/src/test/java/org/apache/james/mailbox/store/quota/StoreCurrentQuotaManagerTest.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/quota/StoreCurrentQuotaManagerTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/quota/StoreCurrentQuotaManagerTest.java
index 4fb109d..e83aee6 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/quota/StoreCurrentQuotaManagerTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/quota/StoreCurrentQuotaManagerTest.java
@@ -23,9 +23,9 @@ import static org.assertj.core.api.Assertions.assertThat;
 
 import java.util.Optional;
 
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.mailbox.model.QuotaRoot;
-import org.apache.james.mailbox.quota.QuotaCount;
-import org.apache.james.mailbox.quota.QuotaSize;
 import org.junit.Before;
 import org.junit.Test;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/mailbox/store/src/test/java/org/apache/james/mailbox/store/quota/StoreQuotaManagerTest.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/quota/StoreQuotaManagerTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/quota/StoreQuotaManagerTest.java
index 36a9750..ee8dee4 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/quota/StoreQuotaManagerTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/quota/StoreQuotaManagerTest.java
@@ -25,12 +25,12 @@ import static org.mockito.Mockito.when;
 
 import java.util.Optional;
 
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.mailbox.model.Quota;
 import org.apache.james.mailbox.model.QuotaRoot;
 import org.apache.james.mailbox.quota.CurrentQuotaManager;
 import org.apache.james.mailbox.quota.MaxQuotaManager;
-import org.apache.james.mailbox.quota.QuotaCount;
-import org.apache.james.mailbox.quota.QuotaSize;
 import org.junit.Before;
 import org.junit.Test;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/mpt/core/src/main/java/org/apache/james/mpt/api/ImapHostSystem.java
----------------------------------------------------------------------
diff --git a/mpt/core/src/main/java/org/apache/james/mpt/api/ImapHostSystem.java b/mpt/core/src/main/java/org/apache/james/mpt/api/ImapHostSystem.java
index 41f3ecc..0ce9b0c 100644
--- a/mpt/core/src/main/java/org/apache/james/mpt/api/ImapHostSystem.java
+++ b/mpt/core/src/main/java/org/apache/james/mpt/api/ImapHostSystem.java
@@ -18,10 +18,10 @@
  ****************************************************************/
 package org.apache.james.mpt.api;
 
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.mailbox.model.MailboxACL;
 import org.apache.james.mailbox.model.MailboxPath;
-import org.apache.james.mailbox.quota.QuotaCount;
-import org.apache.james.mailbox.quota.QuotaSize;
 import org.apache.james.mpt.api.ImapFeatures.Feature;
 
 public interface ImapHostSystem extends HostSystem {

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/mpt/core/src/main/java/org/apache/james/mpt/host/ExternalHostSystem.java
----------------------------------------------------------------------
diff --git a/mpt/core/src/main/java/org/apache/james/mpt/host/ExternalHostSystem.java b/mpt/core/src/main/java/org/apache/james/mpt/host/ExternalHostSystem.java
index 53a1972..24aa86a 100644
--- a/mpt/core/src/main/java/org/apache/james/mpt/host/ExternalHostSystem.java
+++ b/mpt/core/src/main/java/org/apache/james/mpt/host/ExternalHostSystem.java
@@ -20,10 +20,10 @@
 package org.apache.james.mpt.host;
 
 import org.apache.commons.lang.NotImplementedException;
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.mailbox.model.MailboxACL;
 import org.apache.james.mailbox.model.MailboxPath;
-import org.apache.james.mailbox.quota.QuotaCount;
-import org.apache.james.mailbox.quota.QuotaSize;
 import org.apache.james.mpt.api.ImapFeatures;
 import org.apache.james.mpt.api.ImapFeatures.Feature;
 import org.apache.james.mpt.api.ImapHostSystem;

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/host/CassandraHostSystem.java
----------------------------------------------------------------------
diff --git a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/host/CassandraHostSystem.java b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/host/CassandraHostSystem.java
index 13e303e..63b0357 100644
--- a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/host/CassandraHostSystem.java
+++ b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/host/CassandraHostSystem.java
@@ -22,6 +22,8 @@ import org.apache.james.backends.cassandra.CassandraCluster;
 import org.apache.james.backends.cassandra.components.CassandraModule;
 import org.apache.james.backends.cassandra.init.CassandraModuleComposite;
 import org.apache.james.blob.cassandra.CassandraBlobModule;
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.imap.encode.main.DefaultImapEncoderFactory;
 import org.apache.james.imap.main.DefaultImapDecoderFactory;
 import org.apache.james.imap.processor.main.DefaultImapProcessorFactory;
@@ -53,9 +55,7 @@ import org.apache.james.mailbox.cassandra.quota.CassandraPerDomainMaxQuotaDao;
 import org.apache.james.mailbox.cassandra.quota.CassandraPerUserMaxQuotaDao;
 import org.apache.james.mailbox.cassandra.quota.CassandraPerUserMaxQuotaManager;
 import org.apache.james.mailbox.exception.MailboxException;
-import org.apache.james.mailbox.quota.QuotaCount;
 import org.apache.james.mailbox.quota.QuotaRootResolver;
-import org.apache.james.mailbox.quota.QuotaSize;
 import org.apache.james.mailbox.store.JVMMailboxPathLocker;
 import org.apache.james.mailbox.store.StoreMailboxAnnotationManager;
 import org.apache.james.mailbox.store.StoreRightManager;

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/mpt/impl/imap-mailbox/core/src/main/java/org/apache/james/mpt/imapmailbox/suite/QuotaTest.java
----------------------------------------------------------------------
diff --git a/mpt/impl/imap-mailbox/core/src/main/java/org/apache/james/mpt/imapmailbox/suite/QuotaTest.java b/mpt/impl/imap-mailbox/core/src/main/java/org/apache/james/mpt/imapmailbox/suite/QuotaTest.java
index 13427e5..a0686e8 100644
--- a/mpt/impl/imap-mailbox/core/src/main/java/org/apache/james/mpt/imapmailbox/suite/QuotaTest.java
+++ b/mpt/impl/imap-mailbox/core/src/main/java/org/apache/james/mpt/imapmailbox/suite/QuotaTest.java
@@ -21,8 +21,8 @@ package org.apache.james.mpt.imapmailbox.suite;
 
 import java.util.Locale;
 
-import org.apache.james.mailbox.quota.QuotaCount;
-import org.apache.james.mailbox.quota.QuotaSize;
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.mpt.api.ImapFeatures;
 import org.apache.james.mpt.api.ImapHostSystem;
 import org.apache.james.mpt.imapmailbox.ImapTestConstants;

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/mpt/impl/imap-mailbox/cyrus/src/test/java/org/apache/james/mpt/imapmailbox/cyrus/host/CyrusHostSystem.java
----------------------------------------------------------------------
diff --git a/mpt/impl/imap-mailbox/cyrus/src/test/java/org/apache/james/mpt/imapmailbox/cyrus/host/CyrusHostSystem.java b/mpt/impl/imap-mailbox/cyrus/src/test/java/org/apache/james/mpt/imapmailbox/cyrus/host/CyrusHostSystem.java
index 0458861..64e2b66 100644
--- a/mpt/impl/imap-mailbox/cyrus/src/test/java/org/apache/james/mpt/imapmailbox/cyrus/host/CyrusHostSystem.java
+++ b/mpt/impl/imap-mailbox/cyrus/src/test/java/org/apache/james/mpt/imapmailbox/cyrus/host/CyrusHostSystem.java
@@ -22,9 +22,9 @@ import java.net.InetSocketAddress;
 import java.util.function.Supplier;
 
 import org.apache.commons.lang.NotImplementedException;
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.mailbox.model.MailboxPath;
-import org.apache.james.mailbox.quota.QuotaCount;
-import org.apache.james.mailbox.quota.QuotaSize;
 import org.apache.james.mpt.api.ImapFeatures;
 import org.apache.james.mpt.api.ImapFeatures.Feature;
 import org.apache.james.mpt.api.Session;

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/mpt/impl/imap-mailbox/elasticsearch/src/test/java/org/apache/james/mpt/imapmailbox/elasticsearch/host/ElasticSearchHostSystem.java
----------------------------------------------------------------------
diff --git a/mpt/impl/imap-mailbox/elasticsearch/src/test/java/org/apache/james/mpt/imapmailbox/elasticsearch/host/ElasticSearchHostSystem.java b/mpt/impl/imap-mailbox/elasticsearch/src/test/java/org/apache/james/mpt/imapmailbox/elasticsearch/host/ElasticSearchHostSystem.java
index 1d05e91..c5a387c 100644
--- a/mpt/impl/imap-mailbox/elasticsearch/src/test/java/org/apache/james/mpt/imapmailbox/elasticsearch/host/ElasticSearchHostSystem.java
+++ b/mpt/impl/imap-mailbox/elasticsearch/src/test/java/org/apache/james/mpt/imapmailbox/elasticsearch/host/ElasticSearchHostSystem.java
@@ -29,6 +29,8 @@ import org.apache.commons.lang.NotImplementedException;
 import org.apache.james.backends.es.ElasticSearchIndexer;
 import org.apache.james.backends.es.EmbeddedElasticSearch;
 import org.apache.james.backends.es.utils.TestingClientProvider;
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.imap.api.process.ImapProcessor;
 import org.apache.james.imap.encode.main.DefaultImapEncoderFactory;
 import org.apache.james.imap.main.DefaultImapDecoderFactory;
@@ -49,8 +51,6 @@ import org.apache.james.mailbox.inmemory.InMemoryMailboxSessionMapperFactory;
 import org.apache.james.mailbox.inmemory.InMemoryMessageId;
 import org.apache.james.mailbox.inmemory.manager.InMemoryIntegrationResources;
 import org.apache.james.mailbox.mock.MockMailboxSession;
-import org.apache.james.mailbox.quota.QuotaCount;
-import org.apache.james.mailbox.quota.QuotaSize;
 import org.apache.james.mailbox.store.StoreMailboxManager;
 import org.apache.james.mailbox.store.StoreSubscriptionManager;
 import org.apache.james.mailbox.store.extractor.DefaultTextExtractor;

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/mpt/impl/imap-mailbox/external-james/src/test/java/org/apache/james/mpt/imapmailbox/external/james/host/ExternalJamesHostSystem.java
----------------------------------------------------------------------
diff --git a/mpt/impl/imap-mailbox/external-james/src/test/java/org/apache/james/mpt/imapmailbox/external/james/host/ExternalJamesHostSystem.java b/mpt/impl/imap-mailbox/external-james/src/test/java/org/apache/james/mpt/imapmailbox/external/james/host/ExternalJamesHostSystem.java
index 38ddd84..465ce24 100644
--- a/mpt/impl/imap-mailbox/external-james/src/test/java/org/apache/james/mpt/imapmailbox/external/james/host/ExternalJamesHostSystem.java
+++ b/mpt/impl/imap-mailbox/external-james/src/test/java/org/apache/james/mpt/imapmailbox/external/james/host/ExternalJamesHostSystem.java
@@ -22,9 +22,9 @@ import java.net.InetSocketAddress;
 import java.util.function.Supplier;
 
 import org.apache.commons.lang.NotImplementedException;
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.mailbox.model.MailboxPath;
-import org.apache.james.mailbox.quota.QuotaCount;
-import org.apache.james.mailbox.quota.QuotaSize;
 import org.apache.james.mpt.api.ImapFeatures;
 import org.apache.james.mpt.api.ImapFeatures.Feature;
 import org.apache.james.mpt.host.ExternalHostSystem;

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/mpt/impl/imap-mailbox/hbase/src/test/java/org/apache/james/mpt/imapmailbox/hbase/host/HBaseHostSystem.java
----------------------------------------------------------------------
diff --git a/mpt/impl/imap-mailbox/hbase/src/test/java/org/apache/james/mpt/imapmailbox/hbase/host/HBaseHostSystem.java b/mpt/impl/imap-mailbox/hbase/src/test/java/org/apache/james/mpt/imapmailbox/hbase/host/HBaseHostSystem.java
index f09749f..b933b23 100644
--- a/mpt/impl/imap-mailbox/hbase/src/test/java/org/apache/james/mpt/imapmailbox/hbase/host/HBaseHostSystem.java
+++ b/mpt/impl/imap-mailbox/hbase/src/test/java/org/apache/james/mpt/imapmailbox/hbase/host/HBaseHostSystem.java
@@ -26,6 +26,8 @@ import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hbase.HBaseConfiguration;
 import org.apache.hadoop.hbase.HBaseTestingUtility;
 import org.apache.hadoop.hbase.MiniHBaseCluster;
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.imap.api.process.ImapProcessor;
 import org.apache.james.imap.encode.main.DefaultImapEncoderFactory;
 import org.apache.james.imap.main.DefaultImapDecoderFactory;
@@ -41,8 +43,6 @@ import org.apache.james.mailbox.hbase.HBaseMailboxManager;
 import org.apache.james.mailbox.hbase.HBaseMailboxSessionMapperFactory;
 import org.apache.james.mailbox.hbase.mail.HBaseModSeqProvider;
 import org.apache.james.mailbox.hbase.mail.HBaseUidProvider;
-import org.apache.james.mailbox.quota.QuotaCount;
-import org.apache.james.mailbox.quota.QuotaSize;
 import org.apache.james.mailbox.store.JVMMailboxPathLocker;
 import org.apache.james.mailbox.store.StoreMailboxAnnotationManager;
 import org.apache.james.mailbox.store.StoreRightManager;

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/mpt/impl/imap-mailbox/inmemory/src/test/java/org/apache/james/mpt/imapmailbox/inmemory/host/InMemoryHostSystem.java
----------------------------------------------------------------------
diff --git a/mpt/impl/imap-mailbox/inmemory/src/test/java/org/apache/james/mpt/imapmailbox/inmemory/host/InMemoryHostSystem.java b/mpt/impl/imap-mailbox/inmemory/src/test/java/org/apache/james/mpt/imapmailbox/inmemory/host/InMemoryHostSystem.java
index c341a58..2f5a3c4 100644
--- a/mpt/impl/imap-mailbox/inmemory/src/test/java/org/apache/james/mpt/imapmailbox/inmemory/host/InMemoryHostSystem.java
+++ b/mpt/impl/imap-mailbox/inmemory/src/test/java/org/apache/james/mpt/imapmailbox/inmemory/host/InMemoryHostSystem.java
@@ -19,6 +19,8 @@
 
 package org.apache.james.mpt.imapmailbox.inmemory.host;
 
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.imap.api.process.ImapProcessor;
 import org.apache.james.imap.encode.main.DefaultImapEncoderFactory;
 import org.apache.james.imap.main.DefaultImapDecoderFactory;
@@ -30,9 +32,7 @@ import org.apache.james.mailbox.inmemory.manager.InMemoryIntegrationResources;
 import org.apache.james.mailbox.inmemory.quota.InMemoryCurrentQuotaManager;
 import org.apache.james.mailbox.inmemory.quota.InMemoryPerUserMaxQuotaManager;
 import org.apache.james.mailbox.mock.MockMailboxSession;
-import org.apache.james.mailbox.quota.QuotaCount;
 import org.apache.james.mailbox.quota.QuotaRootResolver;
-import org.apache.james.mailbox.quota.QuotaSize;
 import org.apache.james.mailbox.store.StoreMailboxManager;
 import org.apache.james.mailbox.store.StoreSubscriptionManager;
 import org.apache.james.mailbox.store.quota.CurrentQuotaCalculator;

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/mpt/impl/imap-mailbox/jcr/src/test/java/org/apache/james/mpt/imapmailbox/jcr/host/JCRHostSystem.java
----------------------------------------------------------------------
diff --git a/mpt/impl/imap-mailbox/jcr/src/test/java/org/apache/james/mpt/imapmailbox/jcr/host/JCRHostSystem.java b/mpt/impl/imap-mailbox/jcr/src/test/java/org/apache/james/mpt/imapmailbox/jcr/host/JCRHostSystem.java
index 16395e6..2e8da35 100644
--- a/mpt/impl/imap-mailbox/jcr/src/test/java/org/apache/james/mpt/imapmailbox/jcr/host/JCRHostSystem.java
+++ b/mpt/impl/imap-mailbox/jcr/src/test/java/org/apache/james/mpt/imapmailbox/jcr/host/JCRHostSystem.java
@@ -24,6 +24,8 @@ import org.apache.commons.io.FileUtils;
 import org.apache.commons.lang.NotImplementedException;
 import org.apache.jackrabbit.core.RepositoryImpl;
 import org.apache.jackrabbit.core.config.RepositoryConfig;
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.imap.api.process.ImapProcessor;
 import org.apache.james.imap.encode.main.DefaultImapEncoderFactory;
 import org.apache.james.imap.main.DefaultImapDecoderFactory;
@@ -41,8 +43,6 @@ import org.apache.james.mailbox.jcr.JCRSubscriptionManager;
 import org.apache.james.mailbox.jcr.JCRUtils;
 import org.apache.james.mailbox.jcr.mail.JCRModSeqProvider;
 import org.apache.james.mailbox.jcr.mail.JCRUidProvider;
-import org.apache.james.mailbox.quota.QuotaCount;
-import org.apache.james.mailbox.quota.QuotaSize;
 import org.apache.james.mailbox.store.JVMMailboxPathLocker;
 import org.apache.james.mailbox.store.StoreMailboxAnnotationManager;
 import org.apache.james.mailbox.store.StoreRightManager;

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/mpt/impl/imap-mailbox/jpa/src/test/java/org/apache/james/mpt/imapmailbox/jpa/host/JPAHostSystem.java
----------------------------------------------------------------------
diff --git a/mpt/impl/imap-mailbox/jpa/src/test/java/org/apache/james/mpt/imapmailbox/jpa/host/JPAHostSystem.java b/mpt/impl/imap-mailbox/jpa/src/test/java/org/apache/james/mpt/imapmailbox/jpa/host/JPAHostSystem.java
index 41f1bbc..ebd8e94 100644
--- a/mpt/impl/imap-mailbox/jpa/src/test/java/org/apache/james/mpt/imapmailbox/jpa/host/JPAHostSystem.java
+++ b/mpt/impl/imap-mailbox/jpa/src/test/java/org/apache/james/mpt/imapmailbox/jpa/host/JPAHostSystem.java
@@ -25,6 +25,8 @@ import javax.persistence.EntityManagerFactory;
 
 import org.apache.commons.io.FileUtils;
 import org.apache.james.backends.jpa.JpaTestCluster;
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.imap.api.process.ImapProcessor;
 import org.apache.james.imap.encode.main.DefaultImapEncoderFactory;
 import org.apache.james.imap.main.DefaultImapDecoderFactory;
@@ -45,8 +47,6 @@ import org.apache.james.mailbox.jpa.openjpa.OpenJPAMailboxManager;
 import org.apache.james.mailbox.jpa.quota.JPAPerUserMaxQuotaDAO;
 import org.apache.james.mailbox.jpa.quota.JPAPerUserMaxQuotaManager;
 import org.apache.james.mailbox.jpa.quota.JpaCurrentQuotaManager;
-import org.apache.james.mailbox.quota.QuotaCount;
-import org.apache.james.mailbox.quota.QuotaSize;
 import org.apache.james.mailbox.store.JVMMailboxPathLocker;
 import org.apache.james.mailbox.store.StoreMailboxAnnotationManager;
 import org.apache.james.mailbox.store.StoreRightManager;

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/mpt/impl/imap-mailbox/lucenesearch/src/test/java/org/apache/james/mpt/imapmailbox/lucenesearch/host/LuceneSearchHostSystem.java
----------------------------------------------------------------------
diff --git a/mpt/impl/imap-mailbox/lucenesearch/src/test/java/org/apache/james/mpt/imapmailbox/lucenesearch/host/LuceneSearchHostSystem.java b/mpt/impl/imap-mailbox/lucenesearch/src/test/java/org/apache/james/mpt/imapmailbox/lucenesearch/host/LuceneSearchHostSystem.java
index 63b31a0..fb203fd 100644
--- a/mpt/impl/imap-mailbox/lucenesearch/src/test/java/org/apache/james/mpt/imapmailbox/lucenesearch/host/LuceneSearchHostSystem.java
+++ b/mpt/impl/imap-mailbox/lucenesearch/src/test/java/org/apache/james/mpt/imapmailbox/lucenesearch/host/LuceneSearchHostSystem.java
@@ -27,6 +27,8 @@ import javax.persistence.EntityManagerFactory;
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.lang.NotImplementedException;
 import org.apache.james.backends.jpa.JpaTestCluster;
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.imap.api.process.ImapProcessor;
 import org.apache.james.imap.encode.main.DefaultImapEncoderFactory;
 import org.apache.james.imap.main.DefaultImapDecoderFactory;
@@ -49,8 +51,6 @@ import org.apache.james.mailbox.jpa.mail.JPAUidProvider;
 import org.apache.james.mailbox.jpa.openjpa.OpenJPAMailboxManager;
 import org.apache.james.mailbox.lucene.search.LuceneMessageSearchIndex;
 import org.apache.james.mailbox.model.MessageId;
-import org.apache.james.mailbox.quota.QuotaCount;
-import org.apache.james.mailbox.quota.QuotaSize;
 import org.apache.james.mailbox.store.JVMMailboxPathLocker;
 import org.apache.james.mailbox.store.StoreMailboxAnnotationManager;
 import org.apache.james.mailbox.store.StoreRightManager;

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/mpt/impl/imap-mailbox/maildir/src/test/java/org/apache/james/mpt/imapmailbox/maildir/host/MaildirHostSystem.java
----------------------------------------------------------------------
diff --git a/mpt/impl/imap-mailbox/maildir/src/test/java/org/apache/james/mpt/imapmailbox/maildir/host/MaildirHostSystem.java b/mpt/impl/imap-mailbox/maildir/src/test/java/org/apache/james/mpt/imapmailbox/maildir/host/MaildirHostSystem.java
index 0243bf0..6592c09 100644
--- a/mpt/impl/imap-mailbox/maildir/src/test/java/org/apache/james/mpt/imapmailbox/maildir/host/MaildirHostSystem.java
+++ b/mpt/impl/imap-mailbox/maildir/src/test/java/org/apache/james/mpt/imapmailbox/maildir/host/MaildirHostSystem.java
@@ -22,6 +22,8 @@ import java.io.File;
 
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.lang.NotImplementedException;
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.imap.api.process.ImapProcessor;
 import org.apache.james.imap.encode.main.DefaultImapEncoderFactory;
 import org.apache.james.imap.main.DefaultImapDecoderFactory;
@@ -33,8 +35,6 @@ import org.apache.james.mailbox.acl.SimpleGroupMembershipResolver;
 import org.apache.james.mailbox.acl.UnionMailboxACLResolver;
 import org.apache.james.mailbox.maildir.MaildirMailboxSessionMapperFactory;
 import org.apache.james.mailbox.maildir.MaildirStore;
-import org.apache.james.mailbox.quota.QuotaCount;
-import org.apache.james.mailbox.quota.QuotaSize;
 import org.apache.james.mailbox.store.JVMMailboxPathLocker;
 import org.apache.james.mailbox.store.StoreMailboxAnnotationManager;
 import org.apache.james.mailbox.store.StoreMailboxManager;

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/mpt/impl/managesieve/core/src/main/java/org/apache/james/mpt/host/JamesManageSieveHostSystem.java
----------------------------------------------------------------------
diff --git a/mpt/impl/managesieve/core/src/main/java/org/apache/james/mpt/host/JamesManageSieveHostSystem.java b/mpt/impl/managesieve/core/src/main/java/org/apache/james/mpt/host/JamesManageSieveHostSystem.java
index 5cec736..df33cbc 100644
--- a/mpt/impl/managesieve/core/src/main/java/org/apache/james/mpt/host/JamesManageSieveHostSystem.java
+++ b/mpt/impl/managesieve/core/src/main/java/org/apache/james/mpt/host/JamesManageSieveHostSystem.java
@@ -19,6 +19,8 @@
 
 package org.apache.james.mpt.host;
 
+import org.apache.james.core.User;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.managesieve.core.CoreProcessor;
 import org.apache.james.managesieve.jsieve.Parser;
 import org.apache.james.managesieve.transcode.ArgumentParser;
@@ -58,11 +60,11 @@ public abstract class JamesManageSieveHostSystem implements ManageSieveHostSyste
 
     @Override
     public void setMaxQuota(String user, long value) throws Exception {
-        sieveRepository.setQuota(user, value);
+        sieveRepository.setQuota(User.fromUsername(user), QuotaSize.size(value));
     }
 
     @Override
-    public Session newSession(Continuation continuation) throws Exception {
+    public Session newSession(Continuation continuation) {
         return new ManageSieveSession(processor, continuation);
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/protocols/imap/src/main/java/org/apache/james/imap/processor/GetQuotaProcessor.java
----------------------------------------------------------------------
diff --git a/protocols/imap/src/main/java/org/apache/james/imap/processor/GetQuotaProcessor.java b/protocols/imap/src/main/java/org/apache/james/imap/processor/GetQuotaProcessor.java
index 35cbef0..463c507 100644
--- a/protocols/imap/src/main/java/org/apache/james/imap/processor/GetQuotaProcessor.java
+++ b/protocols/imap/src/main/java/org/apache/james/imap/processor/GetQuotaProcessor.java
@@ -22,6 +22,8 @@ package org.apache.james.imap.processor;
 import java.io.Closeable;
 import java.util.List;
 
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.imap.api.ImapCommand;
 import org.apache.james.imap.api.ImapConstants;
 import org.apache.james.imap.api.ImapSessionUtils;
@@ -38,10 +40,8 @@ import org.apache.james.mailbox.model.MailboxACL;
 import org.apache.james.mailbox.model.MailboxPath;
 import org.apache.james.mailbox.model.Quota;
 import org.apache.james.mailbox.model.QuotaRoot;
-import org.apache.james.mailbox.quota.QuotaCount;
 import org.apache.james.mailbox.quota.QuotaManager;
 import org.apache.james.mailbox.quota.QuotaRootResolver;
-import org.apache.james.mailbox.quota.QuotaSize;
 import org.apache.james.metrics.api.MetricFactory;
 import org.apache.james.util.MDCBuilder;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/protocols/imap/src/main/java/org/apache/james/imap/processor/GetQuotaRootProcessor.java
----------------------------------------------------------------------
diff --git a/protocols/imap/src/main/java/org/apache/james/imap/processor/GetQuotaRootProcessor.java b/protocols/imap/src/main/java/org/apache/james/imap/processor/GetQuotaRootProcessor.java
index f564364..022b898 100644
--- a/protocols/imap/src/main/java/org/apache/james/imap/processor/GetQuotaRootProcessor.java
+++ b/protocols/imap/src/main/java/org/apache/james/imap/processor/GetQuotaRootProcessor.java
@@ -22,6 +22,8 @@ package org.apache.james.imap.processor;
 import java.io.Closeable;
 import java.util.List;
 
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.imap.api.ImapCommand;
 import org.apache.james.imap.api.ImapConstants;
 import org.apache.james.imap.api.ImapSessionUtils;
@@ -40,10 +42,8 @@ import org.apache.james.mailbox.model.MailboxACL;
 import org.apache.james.mailbox.model.MailboxPath;
 import org.apache.james.mailbox.model.Quota;
 import org.apache.james.mailbox.model.QuotaRoot;
-import org.apache.james.mailbox.quota.QuotaCount;
 import org.apache.james.mailbox.quota.QuotaManager;
 import org.apache.james.mailbox.quota.QuotaRootResolver;
-import org.apache.james.mailbox.quota.QuotaSize;
 import org.apache.james.metrics.api.MetricFactory;
 import org.apache.james.util.MDCBuilder;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/protocols/imap/src/test/java/org/apache/james/imap/encode/QuotaResponseEncoderTest.java
----------------------------------------------------------------------
diff --git a/protocols/imap/src/test/java/org/apache/james/imap/encode/QuotaResponseEncoderTest.java b/protocols/imap/src/test/java/org/apache/james/imap/encode/QuotaResponseEncoderTest.java
index f70c022..f428b08 100644
--- a/protocols/imap/src/test/java/org/apache/james/imap/encode/QuotaResponseEncoderTest.java
+++ b/protocols/imap/src/test/java/org/apache/james/imap/encode/QuotaResponseEncoderTest.java
@@ -21,13 +21,13 @@ package org.apache.james.imap.encode;
 
 import static org.junit.Assert.assertEquals;
 
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.imap.encode.base.ByteImapResponseWriter;
 import org.apache.james.imap.encode.base.EndImapEncoder;
 import org.apache.james.imap.encode.base.ImapResponseComposerImpl;
 import org.apache.james.imap.message.response.QuotaResponse;
 import org.apache.james.mailbox.model.Quota;
-import org.apache.james.mailbox.quota.QuotaCount;
-import org.apache.james.mailbox.quota.QuotaSize;
 import org.junit.Test;
 
 /**

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/protocols/imap/src/test/java/org/apache/james/imap/processor/GetQuotaProcessorTest.java
----------------------------------------------------------------------
diff --git a/protocols/imap/src/test/java/org/apache/james/imap/processor/GetQuotaProcessorTest.java b/protocols/imap/src/test/java/org/apache/james/imap/processor/GetQuotaProcessorTest.java
index 50cc173..1d375e7 100644
--- a/protocols/imap/src/test/java/org/apache/james/imap/processor/GetQuotaProcessorTest.java
+++ b/protocols/imap/src/test/java/org/apache/james/imap/processor/GetQuotaProcessorTest.java
@@ -29,6 +29,8 @@ import static org.mockito.Mockito.when;
 
 import java.util.Optional;
 
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.imap.api.ImapCommand;
 import org.apache.james.imap.api.ImapSessionState;
 import org.apache.james.imap.api.ImapSessionUtils;
@@ -46,10 +48,8 @@ import org.apache.james.mailbox.model.MailboxACL;
 import org.apache.james.mailbox.model.MailboxPath;
 import org.apache.james.mailbox.model.Quota;
 import org.apache.james.mailbox.model.QuotaRoot;
-import org.apache.james.mailbox.quota.QuotaCount;
 import org.apache.james.mailbox.quota.QuotaManager;
 import org.apache.james.mailbox.quota.QuotaRootResolver;
-import org.apache.james.mailbox.quota.QuotaSize;
 import org.apache.james.metrics.api.NoopMetricFactory;
 import org.junit.Before;
 import org.junit.Test;

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/protocols/imap/src/test/java/org/apache/james/imap/processor/GetQuotaRootProcessorTest.java
----------------------------------------------------------------------
diff --git a/protocols/imap/src/test/java/org/apache/james/imap/processor/GetQuotaRootProcessorTest.java b/protocols/imap/src/test/java/org/apache/james/imap/processor/GetQuotaRootProcessorTest.java
index e907c1e..bf1e169 100644
--- a/protocols/imap/src/test/java/org/apache/james/imap/processor/GetQuotaRootProcessorTest.java
+++ b/protocols/imap/src/test/java/org/apache/james/imap/processor/GetQuotaRootProcessorTest.java
@@ -21,6 +21,8 @@ package org.apache.james.imap.processor;
 
 import java.util.Optional;
 
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.imap.api.ImapCommand;
 import org.apache.james.imap.api.ImapSessionState;
 import org.apache.james.imap.api.ImapSessionUtils;
@@ -39,10 +41,8 @@ import org.apache.james.mailbox.model.MailboxACL;
 import org.apache.james.mailbox.model.MailboxPath;
 import org.apache.james.mailbox.model.Quota;
 import org.apache.james.mailbox.model.QuotaRoot;
-import org.apache.james.mailbox.quota.QuotaCount;
 import org.apache.james.mailbox.quota.QuotaManager;
 import org.apache.james.mailbox.quota.QuotaRootResolver;
-import org.apache.james.mailbox.quota.QuotaSize;
 import org.apache.james.metrics.api.NoopMetricFactory;
 import org.jmock.Expectations;
 import org.jmock.Mockery;

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/protocols/managesieve/src/main/java/org/apache/james/managesieve/core/CoreProcessor.java
----------------------------------------------------------------------
diff --git a/protocols/managesieve/src/main/java/org/apache/james/managesieve/core/CoreProcessor.java b/protocols/managesieve/src/main/java/org/apache/james/managesieve/core/CoreProcessor.java
index 988f311..9998fa3 100644
--- a/protocols/managesieve/src/main/java/org/apache/james/managesieve/core/CoreProcessor.java
+++ b/protocols/managesieve/src/main/java/org/apache/james/managesieve/core/CoreProcessor.java
@@ -30,6 +30,7 @@ import java.util.Map;
 import javax.inject.Inject;
 
 import org.apache.commons.io.IOUtils;
+import org.apache.james.core.User;
 import org.apache.james.managesieve.api.AuthenticationException;
 import org.apache.james.managesieve.api.AuthenticationProcessor;
 import org.apache.james.managesieve.api.AuthenticationRequiredException;
@@ -41,6 +42,8 @@ import org.apache.james.managesieve.api.SyntaxException;
 import org.apache.james.managesieve.api.UnknownSaslMechanism;
 import org.apache.james.managesieve.api.commands.CoreCommands;
 import org.apache.james.managesieve.util.ParserUtils;
+import org.apache.james.sieverepository.api.ScriptContent;
+import org.apache.james.sieverepository.api.ScriptName;
 import org.apache.james.sieverepository.api.SieveRepository;
 import org.apache.james.sieverepository.api.exception.DuplicateException;
 import org.apache.james.sieverepository.api.exception.IsActiveException;
@@ -109,7 +112,7 @@ public class CoreProcessor implements CoreCommands {
     }
 
     @Override
-    public String checkScript(final Session session, final String content) {
+    public String checkScript(Session session, String content) {
         return handleCommandExecution(() -> {
             authenticationCheck(session);
             return manageWarnings(parser.parse(content));
@@ -125,42 +128,42 @@ public class CoreProcessor implements CoreCommands {
     }
 
     @Override
-    public String deleteScript(final Session session, final String name) {
+    public String deleteScript(Session session, String name) {
         return handleCommandExecution(() -> {
             authenticationCheck(session);
-            sieveRepository.deleteScript(session.getUser(), name);
+            sieveRepository.deleteScript(User.fromUsername(session.getUser()), new ScriptName(name));
             return "OK";
         }, session);
     }
 
     @Override
-    public String getScript(final Session session, final String name) {
+    public String getScript(Session session, String name) {
         return handleCommandExecution(() -> {
             authenticationCheck(session);
-            String scriptContent = IOUtils.toString(sieveRepository.getScript(session.getUser(), name), StandardCharsets.UTF_8);
+            String scriptContent = IOUtils.toString(sieveRepository.getScript(User.fromUsername(session.getUser()), new ScriptName(name)), StandardCharsets.UTF_8);
             return "{" + scriptContent.length() + "}" + "\r\n" + scriptContent + "\r\nOK";
         }, session);
     }
 
     @Override
-    public String haveSpace(final Session session, final String name, final long size) {
+    public String haveSpace(Session session, String name, long size) {
         return handleCommandExecution(() -> {
             authenticationCheck(session);
-            sieveRepository.haveSpace(session.getUser(), name, size);
+            sieveRepository.haveSpace(User.fromUsername(session.getUser()), new ScriptName(name), size);
             return "OK";
         }, session);
     }
 
     @Override
-    public String listScripts(final Session session) {
+    public String listScripts(Session session) {
         return handleCommandExecution(() -> listScriptsInternals(session), session);
     }
 
     private String listScriptsInternals(Session session) throws AuthenticationRequiredException, StorageException {
         authenticationCheck(session);
         String list = Joiner.on("\r\n").join(
-            Iterables.transform(sieveRepository.listScripts(session.getUser()),
-                scriptSummary -> '"' + scriptSummary.getName() + '"' + (scriptSummary.isActive() ? " ACTIVE" : "")));
+            Iterables.transform(sieveRepository.listScripts(User.fromUsername(session.getUser())),
+                scriptSummary -> '"' + scriptSummary.getName().getValue() + '"' + (scriptSummary.isActive() ? " ACTIVE" : "")));
         if (Strings.isNullOrEmpty(list)) {
             return "OK";
         } else {
@@ -169,28 +172,28 @@ public class CoreProcessor implements CoreCommands {
     }
 
     @Override
-    public String putScript(final Session session, final String name, final String content) {
+    public String putScript(Session session, String name, String content) {
         return handleCommandExecution(() -> {
             authenticationCheck(session);
-            sieveRepository.putScript(session.getUser(), name, content);
+            sieveRepository.putScript(User.fromUsername(session.getUser()), new ScriptName(name), new ScriptContent(content));
             return manageWarnings(parser.parse(content));
         }, session);
     }
 
     @Override
-    public String renameScript(final Session session, final String oldName, final String newName) {
+    public String renameScript(Session session, String oldName, String newName) {
         return handleCommandExecution(() -> {
             authenticationCheck(session);
-            sieveRepository.renameScript(session.getUser(), oldName, newName);
+            sieveRepository.renameScript(User.fromUsername(session.getUser()), new ScriptName(oldName), new ScriptName(newName));
             return "OK";
         }, session);
     }
 
     @Override
-    public String setActive(final Session session, final String name) {
+    public String setActive(Session session, String name) {
         return handleCommandExecution(() -> {
             authenticationCheck(session);
-            sieveRepository.setActive(session.getUser(), name);
+            sieveRepository.setActive(User.fromUsername(session.getUser()), new ScriptName(name));
             return "OK";
         }, session);
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/server/container/cli/src/main/java/org/apache/james/cli/ServerCmd.java
----------------------------------------------------------------------
diff --git a/server/container/cli/src/main/java/org/apache/james/cli/ServerCmd.java b/server/container/cli/src/main/java/org/apache/james/cli/ServerCmd.java
index c6ac5e4..f705bc1 100644
--- a/server/container/cli/src/main/java/org/apache/james/cli/ServerCmd.java
+++ b/server/container/cli/src/main/java/org/apache/james/cli/ServerCmd.java
@@ -44,9 +44,9 @@ import org.apache.james.cli.probe.impl.JmxMailboxProbe;
 import org.apache.james.cli.probe.impl.JmxQuotaProbe;
 import org.apache.james.cli.probe.impl.JmxSieveProbe;
 import org.apache.james.cli.type.CmdType;
-import org.apache.james.mailbox.quota.QuotaCount;
-import org.apache.james.mailbox.quota.QuotaSize;
-import org.apache.james.mailbox.quota.QuotaValue;
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
+import org.apache.james.core.quota.QuotaValue;
 import org.apache.james.mailbox.store.mail.model.SerializableQuota;
 import org.apache.james.mailbox.store.mail.model.SerializableQuotaValue;
 import org.apache.james.mailbox.store.probe.MailboxProbe;

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/server/container/cli/src/main/java/org/apache/james/cli/probe/impl/JmxQuotaProbe.java
----------------------------------------------------------------------
diff --git a/server/container/cli/src/main/java/org/apache/james/cli/probe/impl/JmxQuotaProbe.java b/server/container/cli/src/main/java/org/apache/james/cli/probe/impl/JmxQuotaProbe.java
index 545d180..fd82f8c 100644
--- a/server/container/cli/src/main/java/org/apache/james/cli/probe/impl/JmxQuotaProbe.java
+++ b/server/container/cli/src/main/java/org/apache/james/cli/probe/impl/JmxQuotaProbe.java
@@ -24,9 +24,9 @@ import java.io.IOException;
 import javax.management.MalformedObjectNameException;
 
 import org.apache.james.adapter.mailbox.QuotaManagementMBean;
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.mailbox.exception.MailboxException;
-import org.apache.james.mailbox.quota.QuotaCount;
-import org.apache.james.mailbox.quota.QuotaSize;
 import org.apache.james.mailbox.store.mail.model.SerializableQuota;
 import org.apache.james.mailbox.store.mail.model.SerializableQuotaValue;
 import org.apache.james.mailbox.store.probe.QuotaProbe;

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/server/container/cli/src/test/java/org/apache/james/cli/ServerCmdTest.java
----------------------------------------------------------------------
diff --git a/server/container/cli/src/test/java/org/apache/james/cli/ServerCmdTest.java b/server/container/cli/src/test/java/org/apache/james/cli/ServerCmdTest.java
index b94b40e..0724cf1 100644
--- a/server/container/cli/src/test/java/org/apache/james/cli/ServerCmdTest.java
+++ b/server/container/cli/src/test/java/org/apache/james/cli/ServerCmdTest.java
@@ -34,9 +34,9 @@ import org.apache.james.cli.exceptions.InvalidArgumentNumberException;
 import org.apache.james.cli.exceptions.MissingCommandException;
 import org.apache.james.cli.exceptions.UnrecognizedCommandException;
 import org.apache.james.cli.type.CmdType;
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.mailbox.model.MailboxId;
-import org.apache.james.mailbox.quota.QuotaCount;
-import org.apache.james.mailbox.quota.QuotaSize;
 import org.apache.james.mailbox.store.mail.model.SerializableQuota;
 import org.apache.james.mailbox.store.mail.model.SerializableQuotaValue;
 import org.apache.james.mailbox.store.probe.MailboxProbe;

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/server/container/guice/jpa-guice/src/test/java/org/apache/james/JPAJamesServerTest.java
----------------------------------------------------------------------
diff --git a/server/container/guice/jpa-guice/src/test/java/org/apache/james/JPAJamesServerTest.java b/server/container/guice/jpa-guice/src/test/java/org/apache/james/JPAJamesServerTest.java
index d99192a..75c7c6b 100644
--- a/server/container/guice/jpa-guice/src/test/java/org/apache/james/JPAJamesServerTest.java
+++ b/server/container/guice/jpa-guice/src/test/java/org/apache/james/JPAJamesServerTest.java
@@ -23,7 +23,7 @@ import static org.assertj.core.api.Assertions.assertThat;
 
 import java.io.IOException;
 
-import org.apache.james.mailbox.quota.QuotaSize;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.mailbox.store.mail.model.SerializableQuotaValue;
 import org.apache.james.modules.QuotaProbesImpl;
 import org.apache.james.server.core.configuration.Configuration;

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/server/container/guice/mailbox/src/main/java/org/apache/james/modules/QuotaProbesImpl.java
----------------------------------------------------------------------
diff --git a/server/container/guice/mailbox/src/main/java/org/apache/james/modules/QuotaProbesImpl.java b/server/container/guice/mailbox/src/main/java/org/apache/james/modules/QuotaProbesImpl.java
index 4f123cc..18d1cfb 100644
--- a/server/container/guice/mailbox/src/main/java/org/apache/james/modules/QuotaProbesImpl.java
+++ b/server/container/guice/mailbox/src/main/java/org/apache/james/modules/QuotaProbesImpl.java
@@ -21,13 +21,13 @@ package org.apache.james.modules;
 
 import javax.inject.Inject;
 
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.model.MailboxPath;
 import org.apache.james.mailbox.quota.MaxQuotaManager;
-import org.apache.james.mailbox.quota.QuotaCount;
 import org.apache.james.mailbox.quota.QuotaManager;
 import org.apache.james.mailbox.quota.QuotaRootResolver;
-import org.apache.james.mailbox.quota.QuotaSize;
 import org.apache.james.mailbox.store.mail.model.SerializableQuota;
 import org.apache.james.mailbox.store.mail.model.SerializableQuotaValue;
 import org.apache.james.mailbox.store.probe.QuotaProbe;

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/server/container/guice/protocols/managedsieve/src/main/java/org/apache/james/modules/protocols/SieveProbeImpl.java
----------------------------------------------------------------------
diff --git a/server/container/guice/protocols/managedsieve/src/main/java/org/apache/james/modules/protocols/SieveProbeImpl.java b/server/container/guice/protocols/managedsieve/src/main/java/org/apache/james/modules/protocols/SieveProbeImpl.java
index 07c18bb..54ccc24 100644
--- a/server/container/guice/protocols/managedsieve/src/main/java/org/apache/james/modules/protocols/SieveProbeImpl.java
+++ b/server/container/guice/protocols/managedsieve/src/main/java/org/apache/james/modules/protocols/SieveProbeImpl.java
@@ -20,7 +20,11 @@ package org.apache.james.modules.protocols;
 
 import javax.inject.Inject;
 
+import org.apache.james.core.User;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.mailbox.store.probe.SieveProbe;
+import org.apache.james.sieverepository.api.ScriptContent;
+import org.apache.james.sieverepository.api.ScriptName;
 import org.apache.james.sieverepository.api.SieveRepository;
 import org.apache.james.utils.GuiceProbe;
 
@@ -35,12 +39,12 @@ public class SieveProbeImpl implements GuiceProbe, SieveProbe {
 
     @Override
     public long getSieveQuota() throws Exception {
-        return sieveRepository.getQuota();
+        return sieveRepository.getQuota().asLong();
     }
 
     @Override
     public void setSieveQuota(long quota) throws Exception {
-        sieveRepository.setQuota(quota);
+        sieveRepository.setQuota(QuotaSize.size(quota));
     }
 
     @Override
@@ -50,22 +54,23 @@ public class SieveProbeImpl implements GuiceProbe, SieveProbe {
 
     @Override
     public long getSieveQuota(String user) throws Exception {
-        return sieveRepository.getQuota(user);
+        return sieveRepository.getQuota(User.fromUsername(user)).asLong();
     }
 
     @Override
     public void setSieveQuota(String user, long quota) throws Exception {
-        sieveRepository.setQuota(user, quota);
+        sieveRepository.setQuota(User.fromUsername(user), QuotaSize.size(quota));
     }
 
     @Override
     public void removeSieveQuota(String user) throws Exception {
-        sieveRepository.removeQuota(user);
+        sieveRepository.removeQuota(User.fromUsername(user));
     }
 
     @Override
-    public void addActiveSieveScript(String user, String name, String script) throws Exception {
-        sieveRepository.putScript(user, name, script);
-        sieveRepository.setActive(user, name);
+    public void addActiveSieveScript(String username, String name, String script) throws Exception {
+        User user = User.fromUsername(username);
+        sieveRepository.putScript(user, new ScriptName(name), new ScriptContent(script));
+        sieveRepository.setActive(user, new ScriptName(name));
     }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/server/container/mailbox-adapter/src/main/java/org/apache/james/adapter/mailbox/QuotaManagement.java
----------------------------------------------------------------------
diff --git a/server/container/mailbox-adapter/src/main/java/org/apache/james/adapter/mailbox/QuotaManagement.java b/server/container/mailbox-adapter/src/main/java/org/apache/james/adapter/mailbox/QuotaManagement.java
index b557935..25fef15 100644
--- a/server/container/mailbox-adapter/src/main/java/org/apache/james/adapter/mailbox/QuotaManagement.java
+++ b/server/container/mailbox-adapter/src/main/java/org/apache/james/adapter/mailbox/QuotaManagement.java
@@ -24,13 +24,13 @@ import java.io.IOException;
 
 import javax.inject.Inject;
 
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.model.MailboxPath;
 import org.apache.james.mailbox.quota.MaxQuotaManager;
-import org.apache.james.mailbox.quota.QuotaCount;
 import org.apache.james.mailbox.quota.QuotaManager;
 import org.apache.james.mailbox.quota.QuotaRootResolver;
-import org.apache.james.mailbox.quota.QuotaSize;
 import org.apache.james.mailbox.store.mail.model.SerializableQuota;
 import org.apache.james.mailbox.store.mail.model.SerializableQuotaValue;
 import org.apache.james.util.MDCBuilder;

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/server/container/mailbox-adapter/src/main/java/org/apache/james/adapter/mailbox/QuotaManagementMBean.java
----------------------------------------------------------------------
diff --git a/server/container/mailbox-adapter/src/main/java/org/apache/james/adapter/mailbox/QuotaManagementMBean.java b/server/container/mailbox-adapter/src/main/java/org/apache/james/adapter/mailbox/QuotaManagementMBean.java
index 57f1615..5263988 100644
--- a/server/container/mailbox-adapter/src/main/java/org/apache/james/adapter/mailbox/QuotaManagementMBean.java
+++ b/server/container/mailbox-adapter/src/main/java/org/apache/james/adapter/mailbox/QuotaManagementMBean.java
@@ -19,9 +19,9 @@
 
 package org.apache.james.adapter.mailbox;
 
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.mailbox.exception.MailboxException;
-import org.apache.james.mailbox.quota.QuotaCount;
-import org.apache.james.mailbox.quota.QuotaSize;
 import org.apache.james.mailbox.store.mail.model.SerializableQuota;
 import org.apache.james.mailbox.store.mail.model.SerializableQuotaValue;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/server/container/spring/src/main/java/org/apache/james/container/spring/mailbox/MaxQuotaConfigurationReader.java
----------------------------------------------------------------------
diff --git a/server/container/spring/src/main/java/org/apache/james/container/spring/mailbox/MaxQuotaConfigurationReader.java b/server/container/spring/src/main/java/org/apache/james/container/spring/mailbox/MaxQuotaConfigurationReader.java
index b5888d5..d46f302 100644
--- a/server/container/spring/src/main/java/org/apache/james/container/spring/mailbox/MaxQuotaConfigurationReader.java
+++ b/server/container/spring/src/main/java/org/apache/james/container/spring/mailbox/MaxQuotaConfigurationReader.java
@@ -25,13 +25,13 @@ import java.util.Map;
 
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.commons.configuration.HierarchicalConfiguration;
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.lifecycle.api.Configurable;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.model.QuotaRoot;
 import org.apache.james.mailbox.quota.MaxQuotaManager;
-import org.apache.james.mailbox.quota.QuotaCount;
 import org.apache.james.mailbox.quota.QuotaRootResolver;
-import org.apache.james.mailbox.quota.QuotaSize;
 
 public class MaxQuotaConfigurationReader implements Configurable {
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/server/data/data-api/src/main/java/org/apache/james/sieverepository/api/ScriptContent.java
----------------------------------------------------------------------
diff --git a/server/data/data-api/src/main/java/org/apache/james/sieverepository/api/ScriptContent.java b/server/data/data-api/src/main/java/org/apache/james/sieverepository/api/ScriptContent.java
new file mode 100644
index 0000000..6f8cbd6
--- /dev/null
+++ b/server/data/data-api/src/main/java/org/apache/james/sieverepository/api/ScriptContent.java
@@ -0,0 +1,62 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.sieverepository.api;
+
+import java.util.Objects;
+
+import com.google.common.base.MoreObjects;
+
+public class ScriptContent {
+    private final String value;
+
+    public ScriptContent(String value) {
+        this.value = value;
+    }
+
+    public String getValue() {
+        return value;
+    }
+
+    public int length() {
+        return value.length();
+    }
+
+    @Override
+    public final boolean equals(Object o) {
+        if (o instanceof ScriptContent) {
+            ScriptContent that = (ScriptContent) o;
+
+            return Objects.equals(this.value, that.value);
+        }
+        return false;
+    }
+
+    @Override
+    public final int hashCode() {
+        return Objects.hash(value);
+    }
+
+    @Override
+    public String toString() {
+        return MoreObjects.toStringHelper(this)
+            .add("value", value)
+            .toString();
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/server/data/data-api/src/main/java/org/apache/james/sieverepository/api/ScriptName.java
----------------------------------------------------------------------
diff --git a/server/data/data-api/src/main/java/org/apache/james/sieverepository/api/ScriptName.java b/server/data/data-api/src/main/java/org/apache/james/sieverepository/api/ScriptName.java
new file mode 100644
index 0000000..453c814
--- /dev/null
+++ b/server/data/data-api/src/main/java/org/apache/james/sieverepository/api/ScriptName.java
@@ -0,0 +1,58 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.sieverepository.api;
+
+import java.util.Objects;
+
+import com.google.common.base.MoreObjects;
+
+public class ScriptName {
+    private final String value;
+
+    public ScriptName(String value) {
+        this.value = value;
+    }
+
+    public String getValue() {
+        return value;
+    }
+
+    @Override
+    public final boolean equals(Object o) {
+        if (o instanceof ScriptName) {
+            ScriptName that = (ScriptName) o;
+
+            return Objects.equals(this.value, that.value);
+        }
+        return false;
+    }
+
+    @Override
+    public final int hashCode() {
+        return Objects.hash(value);
+    }
+
+    @Override
+    public String toString() {
+        return MoreObjects.toStringHelper(this)
+            .add("value", value)
+            .toString();
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/server/data/data-api/src/main/java/org/apache/james/sieverepository/api/ScriptSummary.java
----------------------------------------------------------------------
diff --git a/server/data/data-api/src/main/java/org/apache/james/sieverepository/api/ScriptSummary.java b/server/data/data-api/src/main/java/org/apache/james/sieverepository/api/ScriptSummary.java
index 126a6d6..6ecdfd2 100644
--- a/server/data/data-api/src/main/java/org/apache/james/sieverepository/api/ScriptSummary.java
+++ b/server/data/data-api/src/main/java/org/apache/james/sieverepository/api/ScriptSummary.java
@@ -25,15 +25,15 @@ import com.google.common.base.Objects;
 
 public class ScriptSummary {
 
-    private final String name;
+    private final ScriptName name;
     private final boolean activeFile;
 
-    public ScriptSummary(String name, boolean activeFile) {
+    public ScriptSummary(ScriptName name, boolean activeFile) {
         this.name = name;
         this.activeFile = activeFile;
     }
 
-    public String getName() {
+    public ScriptName getName() {
         return name;
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/server/data/data-api/src/main/java/org/apache/james/sieverepository/api/SieveQuotaRepository.java
----------------------------------------------------------------------
diff --git a/server/data/data-api/src/main/java/org/apache/james/sieverepository/api/SieveQuotaRepository.java b/server/data/data-api/src/main/java/org/apache/james/sieverepository/api/SieveQuotaRepository.java
index ec11c1e..02206e5 100644
--- a/server/data/data-api/src/main/java/org/apache/james/sieverepository/api/SieveQuotaRepository.java
+++ b/server/data/data-api/src/main/java/org/apache/james/sieverepository/api/SieveQuotaRepository.java
@@ -20,6 +20,8 @@
 
 package org.apache.james.sieverepository.api;
 
+import org.apache.james.core.User;
+import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.sieverepository.api.exception.QuotaNotFoundException;
 import org.apache.james.sieverepository.api.exception.StorageException;
 
@@ -30,17 +32,17 @@ public interface SieveQuotaRepository {
 
     boolean hasQuota() throws StorageException;
 
-    long getQuota() throws QuotaNotFoundException, StorageException;
+    QuotaSize getQuota() throws QuotaNotFoundException, StorageException;
 
-    void setQuota(long quota) throws StorageException;
+    void setQuota(QuotaSize quota) throws StorageException;
 
     void removeQuota() throws QuotaNotFoundException, StorageException;
 
-    boolean hasQuota(String user) throws StorageException;
+    boolean hasQuota(User user) throws StorageException;
 
-    long getQuota(String user) throws QuotaNotFoundException, StorageException;
+    QuotaSize getQuota(User user) throws QuotaNotFoundException, StorageException;
 
-    void setQuota(String user, long quota) throws StorageException;
+    void setQuota(User user, QuotaSize quota) throws StorageException;
 
-    void removeQuota(String user) throws QuotaNotFoundException, StorageException;
+    void removeQuota(User user) throws QuotaNotFoundException, StorageException;
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/server/data/data-api/src/main/java/org/apache/james/sieverepository/api/SieveRepository.java
----------------------------------------------------------------------
diff --git a/server/data/data-api/src/main/java/org/apache/james/sieverepository/api/SieveRepository.java b/server/data/data-api/src/main/java/org/apache/james/sieverepository/api/SieveRepository.java
index f93d080..ea50969 100644
--- a/server/data/data-api/src/main/java/org/apache/james/sieverepository/api/SieveRepository.java
+++ b/server/data/data-api/src/main/java/org/apache/james/sieverepository/api/SieveRepository.java
@@ -23,6 +23,7 @@ package org.apache.james.sieverepository.api;
 import java.io.InputStream;
 import java.util.List;
 
+import org.apache.james.core.User;
 import org.apache.james.sieverepository.api.exception.DuplicateException;
 import org.apache.james.sieverepository.api.exception.IsActiveException;
 import org.apache.james.sieverepository.api.exception.QuotaExceededException;
@@ -36,9 +37,9 @@ import org.joda.time.DateTime;
  */
 public interface SieveRepository extends SieveQuotaRepository {
 
-    String NO_SCRIPT_NAME = "";
+    ScriptName NO_SCRIPT_NAME = new ScriptName("");
 
-    void haveSpace(String user, String name, long size) throws QuotaExceededException, StorageException;
+    void haveSpace(User user, ScriptName name, long size) throws QuotaExceededException, StorageException;
     
     /**
      * PutScript.
@@ -51,20 +52,20 @@ public interface SieveRepository extends SieveQuotaRepository {
      * @throws StorageException
      * @throws QuotaExceededException
      */
-    void putScript(String user, String name, String content) throws StorageException, QuotaExceededException;
+    void putScript(User user, ScriptName name, ScriptContent content) throws StorageException, QuotaExceededException;
     
-    List<ScriptSummary> listScripts(String user) throws StorageException;
+    List<ScriptSummary> listScripts(User user) throws StorageException;
 
-    DateTime getActivationDateForActiveScript(String user) throws StorageException, ScriptNotFoundException;
+    DateTime getActivationDateForActiveScript(User user) throws StorageException, ScriptNotFoundException;
 
-    InputStream getActive(String user) throws ScriptNotFoundException, StorageException;
+    InputStream getActive(User user) throws ScriptNotFoundException, StorageException;
     
-    void setActive(String user, String name) throws ScriptNotFoundException, StorageException;
+    void setActive(User user, ScriptName name) throws ScriptNotFoundException, StorageException;
     
-    InputStream getScript(String user, String name) throws ScriptNotFoundException, StorageException;
+    InputStream getScript(User user, ScriptName name) throws ScriptNotFoundException, StorageException;
     
-    void deleteScript(String user, String name) throws ScriptNotFoundException, IsActiveException, StorageException;
+    void deleteScript(User user, ScriptName name) throws ScriptNotFoundException, IsActiveException, StorageException;
     
-    void renameScript(String user, String oldName, String newName) throws ScriptNotFoundException, DuplicateException, StorageException;
+    void renameScript(User user, ScriptName oldName, ScriptName newName) throws ScriptNotFoundException, DuplicateException, StorageException;
 
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/server/data/data-api/src/test/java/org/apache/james/sieverepository/api/ScriptNameTest.java
----------------------------------------------------------------------
diff --git a/server/data/data-api/src/test/java/org/apache/james/sieverepository/api/ScriptNameTest.java b/server/data/data-api/src/test/java/org/apache/james/sieverepository/api/ScriptNameTest.java
new file mode 100644
index 0000000..c643235
--- /dev/null
+++ b/server/data/data-api/src/test/java/org/apache/james/sieverepository/api/ScriptNameTest.java
@@ -0,0 +1,32 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.sieverepository.api;
+
+import org.junit.jupiter.api.Test;
+
+import nl.jqno.equalsverifier.EqualsVerifier;
+
+public class ScriptNameTest {
+    @Test
+    public void shouldMatchBeanContract() {
+        EqualsVerifier.forClass(ScriptName.class)
+            .verify();
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/james-project/blob/3d0a5534/server/data/data-cassandra/src/main/java/org/apache/james/sieve/cassandra/CassandraActiveScriptDAO.java
----------------------------------------------------------------------
diff --git a/server/data/data-cassandra/src/main/java/org/apache/james/sieve/cassandra/CassandraActiveScriptDAO.java b/server/data/data-cassandra/src/main/java/org/apache/james/sieve/cassandra/CassandraActiveScriptDAO.java
index 5f53375..b3773f9 100644
--- a/server/data/data-cassandra/src/main/java/org/apache/james/sieve/cassandra/CassandraActiveScriptDAO.java
+++ b/server/data/data-cassandra/src/main/java/org/apache/james/sieve/cassandra/CassandraActiveScriptDAO.java
@@ -36,7 +36,9 @@ import java.util.concurrent.CompletableFuture;
 import javax.inject.Inject;
 
 import org.apache.james.backends.cassandra.utils.CassandraAsyncExecutor;
+import org.apache.james.core.User;
 import org.apache.james.sieve.cassandra.model.ActiveScriptInfo;
+import org.apache.james.sieverepository.api.ScriptName;
 
 import com.datastax.driver.core.PreparedStatement;
 import com.datastax.driver.core.Session;
@@ -62,26 +64,26 @@ public class CassandraActiveScriptDAO {
             .where(eq(USER_NAME, bindMarker(USER_NAME))));
     }
 
-    public CompletableFuture<Optional<ActiveScriptInfo>> getActiveSctiptInfo(String username) {
+    public CompletableFuture<Optional<ActiveScriptInfo>> getActiveSctiptInfo(User user) {
         return cassandraAsyncExecutor.executeSingleRow(
             selectActiveName.bind()
-                .setString(USER_NAME, username))
+                .setString(USER_NAME, user.asString()))
             .thenApply(rowOptional -> rowOptional.map(row -> new ActiveScriptInfo(
-                row.getString(SCRIPT_NAME),
+                new ScriptName(row.getString(SCRIPT_NAME)),
                 row.getTimestamp(DATE))));
     }
 
-    public CompletableFuture<Void> unactivate(String username) {
+    public CompletableFuture<Void> unactivate(User user) {
         return cassandraAsyncExecutor.executeVoid(
             deleteActive.bind()
-                .setString(USER_NAME, username));
+                .setString(USER_NAME, user.asString()));
     }
 
-    public CompletableFuture<Void> activate(String username, String scriptName) {
+    public CompletableFuture<Void> activate(User user, ScriptName scriptName) {
         return cassandraAsyncExecutor.executeVoid(
             insertActive.bind()
-                .setString(USER_NAME, username)
-                .setString(SCRIPT_NAME, scriptName)
+                .setString(USER_NAME, user.asString())
+                .setString(SCRIPT_NAME, scriptName.getValue())
                 .setTimestamp(DATE, new Date()));
     }
 }


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


[15/20] james-project git commit: JAMES-2151 Update REST API endpoints for Sieve quota

Posted by bt...@apache.org.
JAMES-2151 Update REST API endpoints for Sieve quota


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

Branch: refs/heads/master
Commit: 81db3c28c71d4e4522390f9016739aca7b79d14a
Parents: 280c6f7
Author: benwa <bt...@linagora.com>
Authored: Tue Jun 26 09:57:32 2018 +0700
Committer: benwa <bt...@linagora.com>
Committed: Tue Jun 26 16:09:51 2018 +0700

----------------------------------------------------------------------
 .../james/webadmin/routes/SieveQuotaRoutes.java | 25 +++++---------
 .../webadmin/routes/SieveQuotaRoutesTest.java   | 36 ++++++++++----------
 src/site/markdown/server/manage-webadmin.md     |  4 +--
 3 files changed, 28 insertions(+), 37 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/81db3c28/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/SieveQuotaRoutes.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/SieveQuotaRoutes.java b/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/SieveQuotaRoutes.java
index 1b99b72..26f5a0c 100644
--- a/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/SieveQuotaRoutes.java
+++ b/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/SieveQuotaRoutes.java
@@ -19,6 +19,7 @@
 
 package org.apache.james.webadmin.routes;
 
+import static org.apache.james.webadmin.Constants.EMPTY_BODY;
 import static org.apache.james.webadmin.Constants.SEPARATOR;
 
 import javax.inject.Inject;
@@ -91,7 +92,7 @@ public class SieveQuotaRoutes implements Routes {
     @ApiOperation(value = "Reading global sieve quota size")
     @ApiResponses(value = {
             @ApiResponse(code = 200, message = "OK", response = Long.class),
-            @ApiResponse(code = 404, message = "Global sieve quota not set."),
+            @ApiResponse(code = 204, message = "Global sieve quota not set."),
             @ApiResponse(code = 500, message = "Internal server error - Something went bad on the server side.")
     })
     public void defineGetGlobalSieveQuota(Service service) {
@@ -101,12 +102,8 @@ public class SieveQuotaRoutes implements Routes {
                 response.status(HttpStatus.OK_200);
                 return sieveQuota.asLong();
             } catch (QuotaNotFoundException e) {
-                LOGGER.info("Global sieve quota not set", e);
-                throw ErrorResponder.builder()
-                    .type(ErrorResponder.ErrorType.NOT_FOUND)
-                    .statusCode(HttpStatus.NOT_FOUND_404)
-                    .message("Global sieve quota not set")
-                    .haltError();
+                response.status(HttpStatus.NO_CONTENT_204);
+                return EMPTY_BODY;
             }
         }, jsonTransformer);
     }
@@ -144,7 +141,6 @@ public class SieveQuotaRoutes implements Routes {
     @ApiOperation(value = "Removes global sieve quota")
     @ApiResponses(value = {
             @ApiResponse(code = 204, message = "Global sieve quota removed."),
-            @ApiResponse(code = 404, message = "Global sieve quota not set."),
             @ApiResponse(code = 500, message = "Internal server error - Something went bad on the server side.")
     })
     public void defineRemoveGlobalSieveQuota(Service service) {
@@ -166,7 +162,7 @@ public class SieveQuotaRoutes implements Routes {
     })
     @ApiResponses(value = {
             @ApiResponse(code = 200, message = "OK", response = Long.class),
-            @ApiResponse(code = 404, message = "User sieve quota not set."),
+            @ApiResponse(code = 204, message = "User sieve quota not set."),
             @ApiResponse(code = 500, message = "Internal server error - Something went bad on the server side.")
     })
     public void defineGetPerUserSieveQuota(Service service) {
@@ -177,12 +173,8 @@ public class SieveQuotaRoutes implements Routes {
                 response.status(HttpStatus.OK_200);
                 return userQuota.asLong();
             } catch (QuotaNotFoundException e) {
-                LOGGER.info("User sieve quota not set", e);
-                throw ErrorResponder.builder()
-                    .type(ErrorResponder.ErrorType.NOT_FOUND)
-                    .statusCode(HttpStatus.NOT_FOUND_404)
-                    .message("User sieve quota not set")
-                    .haltError();
+                response.status(HttpStatus.NO_CONTENT_204);
+                return EMPTY_BODY;
             }
         }, jsonTransformer);
     }
@@ -194,7 +186,7 @@ public class SieveQuotaRoutes implements Routes {
             @ApiImplicitParam(required = true, dataType = "long", name = REQUESTED_SIZE, paramType = "body")
     })
     @ApiResponses(value = {
-            @ApiResponse(code = 200, message = "OK", response = Long.class),
+            @ApiResponse(code = 204, message = "OK", response = Long.class),
             @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.")
     })
@@ -225,7 +217,6 @@ public class SieveQuotaRoutes implements Routes {
     })
     @ApiResponses(value = {
             @ApiResponse(code = 204, message = "User sieve quota removed."),
-            @ApiResponse(code = 404, message = "User sieve quota not set."),
             @ApiResponse(code = 500, message = "Internal server error - Something went bad on the server side.")
     })
     public void defineRemovePerUserSieveQuota(Service service) {

http://git-wip-us.apache.org/repos/asf/james-project/blob/81db3c28/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/SieveQuotaRoutesTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/SieveQuotaRoutesTest.java b/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/SieveQuotaRoutesTest.java
index 80b3891..a5ebd5a 100644
--- a/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/SieveQuotaRoutesTest.java
+++ b/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/SieveQuotaRoutesTest.java
@@ -47,7 +47,7 @@ public class SieveQuotaRoutesTest {
     private SieveQuotaRepository sieveRepository;
 
     @BeforeEach
-    public void setUp() throws Exception {
+    void setUp() throws Exception {
         sieveRepository = new InMemorySieveQuotaRepository();
         webAdminServer = WebAdminUtils.createWebAdminServer(
                 new DefaultMetricFactory(),
@@ -60,20 +60,20 @@ public class SieveQuotaRoutesTest {
     }
 
     @AfterEach
-    public void tearDown() {
+    void tearDown() {
         webAdminServer.destroy();
     }
 
     @Test
-    public void getGlobalSieveQuotaShouldReturn404WhenNoQuotaSet() {
+    void getGlobalSieveQuotaShouldReturn204WhenNoQuotaSet() {
         given()
             .get("/sieve/quota/default")
         .then()
-            .statusCode(404);
+            .statusCode(204);
     }
 
     @Test
-    public void getGlobalSieveQuotaShouldReturnStoredValue() throws Exception {
+    void getGlobalSieveQuotaShouldReturnStoredValue() throws Exception {
         QuotaSize value = QuotaSize.size(1000L);
         sieveRepository.setDefaultQuota(value);
 
@@ -90,7 +90,7 @@ public class SieveQuotaRoutesTest {
     }
 
     @Test
-    public void updateGlobalSieveQuotaShouldUpdateStoredValue() throws Exception {
+    void updateGlobalSieveQuotaShouldUpdateStoredValue() throws Exception {
         sieveRepository.setDefaultQuota(QuotaSize.size(500L));
         long requiredSize = 1024L;
 
@@ -104,7 +104,7 @@ public class SieveQuotaRoutesTest {
     }
 
     @Test
-    public void updateGlobalSieveQuotaShouldReturn400WhenMalformedJSON() {
+    void updateGlobalSieveQuotaShouldReturn400WhenMalformedJSON() {
         given()
             .body("invalid")
             .put("/sieve/quota/default")
@@ -113,7 +113,7 @@ public class SieveQuotaRoutesTest {
     }
 
     @Test
-    public void updateGlobalSieveQuotaShouldReturn400WhenRequestedSizeNotPositiveInteger() {
+    void updateGlobalSieveQuotaShouldReturn400WhenRequestedSizeNotPositiveInteger() {
         given()
             .body(-100L)
             .put("/sieve/quota/default")
@@ -122,7 +122,7 @@ public class SieveQuotaRoutesTest {
     }
 
     @Test
-    public void removeGlobalSieveQuotaShouldReturn404WhenNoQuotaSet() {
+    void removeGlobalSieveQuotaShouldReturn204WhenNoQuotaSet() {
         given()
             .delete("/sieve/quota/default")
         .then()
@@ -130,7 +130,7 @@ public class SieveQuotaRoutesTest {
     }
 
     @Test
-    public void removeGlobalSieveQuotaShouldRemoveGlobalSieveQuota() throws Exception {
+    void removeGlobalSieveQuotaShouldRemoveGlobalSieveQuota() throws Exception {
         sieveRepository.setDefaultQuota(QuotaSize.size(1024L));
 
         given()
@@ -140,15 +140,15 @@ public class SieveQuotaRoutesTest {
     }
 
     @Test
-    public void getPerUserQuotaShouldReturn404WhenNoQuotaSetForUser() {
+    void getPerUserQuotaShouldReturn204WhenNoQuotaSetForUser() {
         given()
             .get("/sieve/quota/users/" + USER_A.asString())
         .then()
-            .statusCode(HttpStatus.NOT_FOUND_404);
+            .statusCode(HttpStatus.NO_CONTENT_204);
     }
 
     @Test
-    public void getPerUserSieveQuotaShouldReturnedStoredValue() throws Exception {
+    void getPerUserSieveQuotaShouldReturnStoredValue() throws Exception {
         QuotaSize value = QuotaSize.size(1024L);
         sieveRepository.setQuota(USER_A, value);
 
@@ -165,7 +165,7 @@ public class SieveQuotaRoutesTest {
     }
 
     @Test
-    public void updatePerUserSieveQuotaShouldUpdateStoredValue() throws Exception {
+    void updatePerUserSieveQuotaShouldUpdateStoredValue() throws Exception {
         sieveRepository.setQuota(USER_A, QuotaSize.size(500L));
         long requiredSize = 1024L;
 
@@ -179,7 +179,7 @@ public class SieveQuotaRoutesTest {
     }
 
     @Test
-    public void updatePerUserSieveQuotaShouldReturn400WhenMalformedJSON() {
+    void updatePerUserSieveQuotaShouldReturn400WhenMalformedJSON() {
         given()
             .body("invalid")
             .put("/sieve/quota/users/" + USER_A.asString())
@@ -188,7 +188,7 @@ public class SieveQuotaRoutesTest {
     }
 
     @Test
-    public void updatePerUserSieveQuotaShouldReturn400WhenRequestedSizeNotPositiveInteger() {
+    void updatePerUserSieveQuotaShouldReturn400WhenRequestedSizeNotPositiveInteger() {
         given()
             .body(-100L)
             .put("/sieve/quota/users/" + USER_A.asString())
@@ -197,7 +197,7 @@ public class SieveQuotaRoutesTest {
     }
 
     @Test
-    public void removePerUserSieveQuotaShouldReturn404WhenNoQuotaSetForUser() {
+    void removePerUserSieveQuotaShouldReturn204WhenNoQuotaSetForUser() {
         given()
             .delete("/sieve/quota/users/" + USER_A.asString())
         .then()
@@ -205,7 +205,7 @@ public class SieveQuotaRoutesTest {
     }
 
     @Test
-    public void removePerUserSieveQuotaShouldRemoveQuotaForUser() throws Exception {
+    void removePerUserSieveQuotaShouldRemoveQuotaForUser() throws Exception {
         sieveRepository.setQuota(USER_A, QuotaSize.size(1024));
 
         given()

http://git-wip-us.apache.org/repos/asf/james-project/blob/81db3c28/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 637fb98..6708a26 100644
--- a/src/site/markdown/server/manage-webadmin.md
+++ b/src/site/markdown/server/manage-webadmin.md
@@ -1895,7 +1895,7 @@ Will return the bytes count allowed by user per default on this server.
 
 Response codes:
  - 200: Request is a success and the value is returned
- - 404: No quota is being configured
+ - 204: No default quota is being configured
 
 ### Updating global sieve quota
 
@@ -1942,7 +1942,7 @@ Will return the bytes count allowed for this user.
 
 Response codes:
  - 200: Request is a success and the value is returned
- - 404: No quota is being configured for this user
+ - 204: No quota is being configured for this user
 
 ### Updating user sieve quota
 


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


[13/20] james-project git commit: JAMES-2151 SieveRepository strong typing

Posted by bt...@apache.org.
JAMES-2151 SieveRepository strong typing


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

Branch: refs/heads/master
Commit: 37ba4e342c20b18c44913d563f055f0f711c6709
Parents: 2e8f3f7
Author: benwa <bt...@linagora.com>
Authored: Fri Jun 22 13:46:21 2018 +0700
Committer: benwa <bt...@linagora.com>
Committed: Tue Jun 26 16:08:59 2018 +0700

----------------------------------------------------------------------
 .../sieverepository/api/ScriptContent.java      |  3 +-
 .../james/sieve/cassandra/model/Script.java     |  3 +-
 .../james/sieve/cassandra/model/SieveQuota.java |  7 +-
 .../james/sieve/cassandra/model/ScriptTest.java |  5 +-
 .../lib/AbstractSieveRepositoryTest.java        |  4 +-
 .../managesieve/ManageSieveMailetTestCase.java  | 86 ++++++++++----------
 6 files changed, 56 insertions(+), 52 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/37ba4e34/server/data/data-api/src/main/java/org/apache/james/sieverepository/api/ScriptContent.java
----------------------------------------------------------------------
diff --git a/server/data/data-api/src/main/java/org/apache/james/sieverepository/api/ScriptContent.java b/server/data/data-api/src/main/java/org/apache/james/sieverepository/api/ScriptContent.java
index 6f8cbd6..a5351a7 100644
--- a/server/data/data-api/src/main/java/org/apache/james/sieverepository/api/ScriptContent.java
+++ b/server/data/data-api/src/main/java/org/apache/james/sieverepository/api/ScriptContent.java
@@ -19,6 +19,7 @@
 
 package org.apache.james.sieverepository.api;
 
+import java.nio.charset.StandardCharsets;
 import java.util.Objects;
 
 import com.google.common.base.MoreObjects;
@@ -35,7 +36,7 @@ public class ScriptContent {
     }
 
     public int length() {
-        return value.length();
+        return value.getBytes(StandardCharsets.UTF_8).length;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/james-project/blob/37ba4e34/server/data/data-cassandra/src/main/java/org/apache/james/sieve/cassandra/model/Script.java
----------------------------------------------------------------------
diff --git a/server/data/data-cassandra/src/main/java/org/apache/james/sieve/cassandra/model/Script.java b/server/data/data-cassandra/src/main/java/org/apache/james/sieve/cassandra/model/Script.java
index de68ade..89952a3 100644
--- a/server/data/data-cassandra/src/main/java/org/apache/james/sieve/cassandra/model/Script.java
+++ b/server/data/data-cassandra/src/main/java/org/apache/james/sieve/cassandra/model/Script.java
@@ -2,7 +2,6 @@
 
 package org.apache.james.sieve.cassandra.model;
 
-import java.nio.charset.StandardCharsets;
 import java.util.Objects;
 import java.util.Optional;
 
@@ -68,7 +67,7 @@ public class Script {
             return new Script(name,
                 content,
                 isActive.get(),
-                size.orElse((long) content.getValue().getBytes(StandardCharsets.UTF_8).length));
+                size.orElse((long) content.length()));
         }
 
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/37ba4e34/server/data/data-cassandra/src/main/java/org/apache/james/sieve/cassandra/model/SieveQuota.java
----------------------------------------------------------------------
diff --git a/server/data/data-cassandra/src/main/java/org/apache/james/sieve/cassandra/model/SieveQuota.java b/server/data/data-cassandra/src/main/java/org/apache/james/sieve/cassandra/model/SieveQuota.java
index b8a0154..25cdff6 100644
--- a/server/data/data-cassandra/src/main/java/org/apache/james/sieve/cassandra/model/SieveQuota.java
+++ b/server/data/data-cassandra/src/main/java/org/apache/james/sieve/cassandra/model/SieveQuota.java
@@ -46,7 +46,10 @@ public class SieveQuota {
     }
 
     public boolean isExceededUponModification(long sizeDifference) {
-        return limit.map(limitContent -> !limitContent.isGreaterThan(QuotaSize.size(currentUsage + sizeDifference)))
-                .orElse(false);
+        return limit.map(limitContent ->
+            QuotaSize.size(currentUsage)
+                .add(sizeDifference)
+                .isGreaterThan(limitContent))
+            .orElse(false);
     }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/37ba4e34/server/data/data-cassandra/src/test/java/org/apache/james/sieve/cassandra/model/ScriptTest.java
----------------------------------------------------------------------
diff --git a/server/data/data-cassandra/src/test/java/org/apache/james/sieve/cassandra/model/ScriptTest.java b/server/data/data-cassandra/src/test/java/org/apache/james/sieve/cassandra/model/ScriptTest.java
index ca757d9..718c824 100644
--- a/server/data/data-cassandra/src/test/java/org/apache/james/sieve/cassandra/model/ScriptTest.java
+++ b/server/data/data-cassandra/src/test/java/org/apache/james/sieve/cassandra/model/ScriptTest.java
@@ -23,6 +23,7 @@ import static org.assertj.core.api.Assertions.assertThat;
 
 import java.nio.charset.StandardCharsets;
 
+import org.apache.james.sieverepository.api.ScriptContent;
 import org.apache.james.sieverepository.api.ScriptName;
 import org.apache.james.sieverepository.api.ScriptSummary;
 import org.junit.Rule;
@@ -73,7 +74,7 @@ public class ScriptTest {
 
     @Test
     public void buildShouldPreserveName() {
-        String name = "name";
+        ScriptName name = new ScriptName("name");
         assertThat(
             Script.builder()
                 .name(name)
@@ -86,7 +87,7 @@ public class ScriptTest {
 
     @Test
     public void buildShouldPreserveContent() {
-        String content = "content";
+        ScriptContent content = new ScriptContent("content");
         assertThat(
             Script.builder()
                 .name("name")

http://git-wip-us.apache.org/repos/asf/james-project/blob/37ba4e34/server/data/data-library/src/test/java/org/apache/james/sieverepository/lib/AbstractSieveRepositoryTest.java
----------------------------------------------------------------------
diff --git a/server/data/data-library/src/test/java/org/apache/james/sieverepository/lib/AbstractSieveRepositoryTest.java b/server/data/data-library/src/test/java/org/apache/james/sieverepository/lib/AbstractSieveRepositoryTest.java
index 4352209..a057d3a 100644
--- a/server/data/data-library/src/test/java/org/apache/james/sieverepository/lib/AbstractSieveRepositoryTest.java
+++ b/server/data/data-library/src/test/java/org/apache/james/sieverepository/lib/AbstractSieveRepositoryTest.java
@@ -343,8 +343,8 @@ public abstract class AbstractSieveRepositoryTest {
         assertThat(sieveRepository.getQuota(USER)).isEqualTo(DEFAULT_QUOTA);
     }
 
-    protected String getScriptContent(InputStream inputStream) throws IOException {
-        return IOUtils.toString(inputStream, StandardCharsets.UTF_8);
+    protected ScriptContent getScriptContent(InputStream inputStream) throws IOException {
+        return new ScriptContent(IOUtils.toString(inputStream, StandardCharsets.UTF_8));
     }
 
     protected abstract SieveRepository createSieveRepository() throws Exception;

http://git-wip-us.apache.org/repos/asf/james-project/blob/37ba4e34/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/managesieve/ManageSieveMailetTestCase.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/managesieve/ManageSieveMailetTestCase.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/managesieve/ManageSieveMailetTestCase.java
index fd1d103..e9967b5 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/managesieve/ManageSieveMailetTestCase.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/managesieve/ManageSieveMailetTestCase.java
@@ -127,52 +127,52 @@ public class ManageSieveMailetTestCase {
 
     @Test
     public final void testPutScriptinvalidLiteral() throws Exception {
-        MimeMessage message = prepareMessageWithAttachment(SCRIPT_CONTENT, "PUTSCRIPT \"" + SCRIPT_NAME + "\"");
+        MimeMessage message = prepareMessageWithAttachment(SCRIPT_CONTENT, "PUTSCRIPT \"" + SCRIPT_NAME.getValue() + "\"");
         Mail mail = createUnauthenticatedMail(message);
         mailet.service(mail);
-        ensureResponse("Re: PUTSCRIPT \"" + SCRIPT_NAME + "\"", "NO \"Missing argument: script size\"");
+        ensureResponse("Re: PUTSCRIPT \"" + SCRIPT_NAME.getValue() + "\"", "NO \"Missing argument: script size\"");
     }
 
     @Test
     public final void testPutScript() throws Exception {
         when(sieveParser.parse(anyString())).thenReturn(Lists.newArrayList("warning1", "warning2"));
-        MimeMessage message = prepareMessageWithAttachment(SCRIPT_CONTENT, "PUTSCRIPT \"" + SCRIPT_NAME + "\" {100+}");
+        MimeMessage message = prepareMessageWithAttachment(SCRIPT_CONTENT, "PUTSCRIPT \"" + SCRIPT_NAME.getValue() + "\" {100+}");
         Mail mail = createAuthentificatedMail(message);
         mailet.service(mail);
-        ensureResponse("Re: PUTSCRIPT \"" + SCRIPT_NAME + "\" {100+}", "OK (WARNINGS) \"warning1\" \"warning2\"");
+        ensureResponse("Re: PUTSCRIPT \"" + SCRIPT_NAME.getValue() + "\" {100+}", "OK (WARNINGS) \"warning1\" \"warning2\"");
     }
 
     @Test
     public final void testPutScriptInvalidLiteral() throws Exception {
-        MimeMessage message = prepareMessageWithAttachment(SCRIPT_CONTENT, "PUTSCRIPT \"" + SCRIPT_NAME + "\" extra");
+        MimeMessage message = prepareMessageWithAttachment(SCRIPT_CONTENT, "PUTSCRIPT \"" + SCRIPT_NAME.getValue() + "\" extra");
         Mail mail = createUnauthenticatedMail(message);
         mailet.service(mail);
-        ensureResponse("Re: PUTSCRIPT \"" + SCRIPT_NAME + "\" extra", "NO \"extra is an invalid size literal : it should be at least 4 char looking like {_+}\"");
+        ensureResponse("Re: PUTSCRIPT \"" + SCRIPT_NAME.getValue() + "\" extra", "NO \"extra is an invalid size literal : it should be at least 4 char looking like {_+}\"");
     }
 
     @Test
     public final void testPutScriptExtraArgs() throws Exception {
-        MimeMessage message = prepareMessageWithAttachment(SCRIPT_CONTENT, "PUTSCRIPT \"" + SCRIPT_NAME + "\" {10+} extra");
+        MimeMessage message = prepareMessageWithAttachment(SCRIPT_CONTENT, "PUTSCRIPT \"" + SCRIPT_NAME.getValue() + "\" {10+} extra");
         Mail mail = createUnauthenticatedMail(message);
         mailet.service(mail);
-        ensureResponse("Re: PUTSCRIPT \"" + SCRIPT_NAME + "\" {10+} extra", "NO \"Extra arguments not supported\"");
+        ensureResponse("Re: PUTSCRIPT \"" + SCRIPT_NAME.getValue() + "\" {10+} extra", "NO \"Extra arguments not supported\"");
     }
 
     @Test
     public final void testPutScriptSyntaxError() throws Exception {
         doThrow(new SyntaxException("error message")).when(sieveParser).parse(SYNTAX_EXCEPTION);
-        MimeMessage message = prepareMessageWithAttachment(SYNTAX_EXCEPTION, "PUTSCRIPT \"" + SCRIPT_NAME + "\" {10+}");
+        MimeMessage message = prepareMessageWithAttachment(SYNTAX_EXCEPTION, "PUTSCRIPT \"" + SCRIPT_NAME.getValue() + "\" {10+}");
         Mail mail = createAuthentificatedMail(message);
         mailet.service(mail);
-        ensureResponse("Re: PUTSCRIPT \"" + SCRIPT_NAME + "\" {10+}", "NO \"Syntax Error: error message\"");
+        ensureResponse("Re: PUTSCRIPT \"" + SCRIPT_NAME.getValue() + "\" {10+}", "NO \"Syntax Error: error message\"");
     }
 
     @Test
     public final void testPutScriptNoScript() throws Exception {
-        MimeMessage message = prepareMimeMessage("PUTSCRIPT \"" + SCRIPT_NAME + "\"");
+        MimeMessage message = prepareMimeMessage("PUTSCRIPT \"" + SCRIPT_NAME.getValue() + "\"");
         Mail mail = createUnauthenticatedMail(message);
         mailet.service(mail);
-        ensureResponse("Re: PUTSCRIPT \"" + SCRIPT_NAME + "\"", "NO \"Missing argument: script size\"");
+        ensureResponse("Re: PUTSCRIPT \"" + SCRIPT_NAME.getValue() + "\"", "NO \"Missing argument: script size\"");
     }
 
     @Test
@@ -185,38 +185,38 @@ public class ManageSieveMailetTestCase {
 
     @Test
     public final void testGetScriptNonAuthorized() throws Exception {
-        MimeMessage message = prepareMimeMessage("GETSCRIPT \"" + SCRIPT_NAME + "\"");
+        MimeMessage message = prepareMimeMessage("GETSCRIPT \"" + SCRIPT_NAME.getValue() + "\"");
         Mail mail = createUnauthenticatedMail(message);
         mailet.service(mail);
-        ensureResponse("Re: GETSCRIPT \"" + SCRIPT_NAME + "\"", "NO");
+        ensureResponse("Re: GETSCRIPT \"" + SCRIPT_NAME.getValue() + "\"", "NO");
     }
 
     @Test
     public final void testGetScript() throws Exception {
-        when(sieveRepository.getScript(USER, SCRIPT_NAME)).thenReturn(new ByteArrayInputStream(SCRIPT_CONTENT.getValue().getBytes()));
-        MimeMessage message = prepareMimeMessage("GETSCRIPT \"" + SCRIPT_NAME + "\"");
+        when(sieveRepository.getScript(USER, SCRIPT_NAME)).thenReturn(new ByteArrayInputStream(SCRIPT_CONTENT.getValue().getBytes(StandardCharsets.UTF_8)));
+        MimeMessage message = prepareMimeMessage("GETSCRIPT \"" + SCRIPT_NAME.getValue() + "\"");
         Mail mail = createUnauthenticatedMail(message);
         mail.setAttribute(Mail.SMTP_AUTH_USER_ATTRIBUTE_NAME, USER.asString());
         mailet.service(mail);
-        ensureResponse("Re: GETSCRIPT \"" + SCRIPT_NAME + "\"", "{13}\r\n" + SCRIPT_CONTENT + "\r\nOK");
+        ensureResponse("Re: GETSCRIPT \"" + SCRIPT_NAME.getValue() + "\"", "{13}\r\n" + SCRIPT_CONTENT.getValue() + "\r\nOK");
     }
 
     @Test
     public final void testGetScriptExtraArgs() throws Exception {
-        MimeMessage message = prepareMimeMessage("GETSCRIPT \"" + SCRIPT_NAME + "\" extra");
+        MimeMessage message = prepareMimeMessage("GETSCRIPT \"" + SCRIPT_NAME.getValue() + "\" extra");
         Mail mail = createUnauthenticatedMail(message);
         mailet.service(mail);
-        ensureResponse("Re: GETSCRIPT \"" + SCRIPT_NAME + "\" extra", "NO \"Too many arguments: extra\"");
+        ensureResponse("Re: GETSCRIPT \"" + SCRIPT_NAME.getValue() + "\" extra", "NO \"Too many arguments: extra\"");
     }
 
     @Test
     public final void testGetScriptNoScript() throws Exception {
         doThrow(new ScriptNotFoundException()).when(sieveRepository).getScript(USER, SCRIPT_NAME);
-        MimeMessage message = prepareMimeMessage("GETSCRIPT \"" + SCRIPT_NAME + "\"");
+        MimeMessage message = prepareMimeMessage("GETSCRIPT \"" + SCRIPT_NAME.getValue() + "\"");
         Mail mail = createUnauthenticatedMail(message);
         mail.setAttribute(Mail.SMTP_AUTH_USER_ATTRIBUTE_NAME, USER.asString());
         mailet.service(mail);
-        ensureResponse("Re: GETSCRIPT \"" + SCRIPT_NAME + "\"", "NO (NONEXISTENT) \"There is no script by that name\"");
+        ensureResponse("Re: GETSCRIPT \"" + SCRIPT_NAME.getValue() + "\"", "NO (NONEXISTENT) \"There is no script by that name\"");
     }
 
     @Test
@@ -283,26 +283,26 @@ public class ManageSieveMailetTestCase {
 
     @Test
     public final void testDeleteScriptUnauthenticated() throws Exception {
-        MimeMessage message = prepareMimeMessage("DELETESCRIPT \"" + SCRIPT_NAME + "\"");
+        MimeMessage message = prepareMimeMessage("DELETESCRIPT \"" + SCRIPT_NAME.getValue() + "\"");
         Mail mail = createUnauthenticatedMail(message);
         mailet.service(mail);
-        ensureResponse("Re: DELETESCRIPT \"" + SCRIPT_NAME + "\"", "NO");
+        ensureResponse("Re: DELETESCRIPT \"" + SCRIPT_NAME.getValue() + "\"", "NO");
     }
 
     @Test
     public final void testDeleteScript() throws Exception {
-        MimeMessage message = prepareMimeMessage("DELETESCRIPT \"" + SCRIPT_NAME + "\"");
+        MimeMessage message = prepareMimeMessage("DELETESCRIPT \"" + SCRIPT_NAME.getValue() + "\"");
         Mail mail = createAuthentificatedMail(message);
         mailet.service(mail);
-        ensureResponse("Re: DELETESCRIPT \"" + SCRIPT_NAME + "\"", "OK");
+        ensureResponse("Re: DELETESCRIPT \"" + SCRIPT_NAME.getValue() + "\"", "OK");
     }
 
     @Test
     public final void testDeleteScriptExtraArgs() throws Exception {
-        MimeMessage message = prepareMimeMessage("DELETESCRIPT \"" + SCRIPT_NAME + "\" extra");
+        MimeMessage message = prepareMimeMessage("DELETESCRIPT \"" + SCRIPT_NAME.getValue() + "\" extra");
         Mail mail = createUnauthenticatedMail(message);
         mailet.service(mail);
-        ensureResponse("Re: DELETESCRIPT \"" + SCRIPT_NAME + "\" extra", "NO \"Too many arguments: extra\"");
+        ensureResponse("Re: DELETESCRIPT \"" + SCRIPT_NAME.getValue() + "\" extra", "NO \"Too many arguments: extra\"");
     }
 
     @Test
@@ -315,26 +315,26 @@ public class ManageSieveMailetTestCase {
 
     @Test
     public final void testHaveSpaceUnauthenticated() throws Exception {
-        MimeMessage message = prepareMimeMessage("HAVESPACE \"" + SCRIPT_NAME + "\" 1");
+        MimeMessage message = prepareMimeMessage("HAVESPACE \"" + SCRIPT_NAME.getValue() + "\" 1");
         Mail mail = createUnauthenticatedMail(message);
         mailet.service(mail);
-        ensureResponse("Re: HAVESPACE \"" + SCRIPT_NAME + "\" 1", "NO");
+        ensureResponse("Re: HAVESPACE \"" + SCRIPT_NAME.getValue() + "\" 1", "NO");
     }
 
     @Test
     public final void testHaveSpace() throws Exception {
-        MimeMessage message = prepareMimeMessage("HAVESPACE \"" + SCRIPT_NAME + "\" 1");
+        MimeMessage message = prepareMimeMessage("HAVESPACE \"" + SCRIPT_NAME.getValue() + "\" 1");
         Mail mail = createAuthentificatedMail(message);
         mailet.service(mail);
-        ensureResponse("Re: HAVESPACE \"" + SCRIPT_NAME + "\" 1", "OK");
+        ensureResponse("Re: HAVESPACE \"" + SCRIPT_NAME.getValue() + "\" 1", "OK");
     }
 
     @Test
     public final void testHaveSpaceExtraArgs() throws Exception {
-        MimeMessage message = prepareMimeMessage("HAVESPACE \"" + SCRIPT_NAME + "\" 1 extra");
+        MimeMessage message = prepareMimeMessage("HAVESPACE \"" + SCRIPT_NAME.getValue() + "\" 1 extra");
         Mail mail = createUnauthenticatedMail(message);
         mailet.service(mail);
-        ensureResponse("Re: HAVESPACE \"" + SCRIPT_NAME + "\" 1 extra", "NO \"Too many arguments: extra\"");
+        ensureResponse("Re: HAVESPACE \"" + SCRIPT_NAME.getValue() + "\" 1 extra", "NO \"Too many arguments: extra\"");
     }
 
     @Test
@@ -347,18 +347,18 @@ public class ManageSieveMailetTestCase {
 
     @Test
     public final void testHaveSpaceNoScriptSize() throws Exception {
-        MimeMessage message = prepareMimeMessage("HAVESPACE \"" + SCRIPT_NAME + "\"");
+        MimeMessage message = prepareMimeMessage("HAVESPACE \"" + SCRIPT_NAME.getValue() + "\"");
         Mail mail = createUnauthenticatedMail(message);
         mailet.service(mail);
-        ensureResponse("Re: HAVESPACE \"" + SCRIPT_NAME + "\"", "NO \"Missing argument: script size\"");
+        ensureResponse("Re: HAVESPACE \"" + SCRIPT_NAME.getValue() + "\"", "NO \"Missing argument: script size\"");
     }
 
     @Test
     public final void testHaveSpaceInvalidScriptSize() throws Exception {
-        MimeMessage message = prepareMimeMessage("HAVESPACE \"" + SCRIPT_NAME + "\" X");
+        MimeMessage message = prepareMimeMessage("HAVESPACE \"" + SCRIPT_NAME.getValue() + "\" X");
         Mail mail = createUnauthenticatedMail(message);
         mailet.service(mail);
-        ensureResponse("Re: HAVESPACE \"" + SCRIPT_NAME + "\" X", "NO \"Invalid argument: script size\"");
+        ensureResponse("Re: HAVESPACE \"" + SCRIPT_NAME.getValue() + "\" X", "NO \"Invalid argument: script size\"");
     }
 
     @Test
@@ -433,26 +433,26 @@ public class ManageSieveMailetTestCase {
 
     @Test
     public final void testSetActiveUnauthorised() throws Exception {
-        MimeMessage message = prepareMimeMessage("SETACTIVE \"" + SCRIPT_NAME + "\"");
+        MimeMessage message = prepareMimeMessage("SETACTIVE \"" + SCRIPT_NAME.getValue() + "\"");
         Mail mail = createUnauthenticatedMail(message);
         mailet.service(mail);
-        ensureResponse("Re: SETACTIVE \"" + SCRIPT_NAME + "\"", "NO");
+        ensureResponse("Re: SETACTIVE \"" + SCRIPT_NAME.getValue() + "\"", "NO");
     }
 
     @Test
     public final void testSetActive() throws Exception {
-        MimeMessage message = prepareMimeMessage("SETACTIVE \"" + SCRIPT_NAME + "\"");
+        MimeMessage message = prepareMimeMessage("SETACTIVE \"" + SCRIPT_NAME.getValue() + "\"");
         Mail mail = createAuthentificatedMail(message);
         mailet.service(mail);
-        ensureResponse("Re: SETACTIVE \"" + SCRIPT_NAME + "\"", "OK");
+        ensureResponse("Re: SETACTIVE \"" + SCRIPT_NAME.getValue() + "\"", "OK");
     }
 
     @Test
     public final void testSetActiveExtraArgs() throws Exception {
-        MimeMessage message = prepareMimeMessage("SETACTIVE \"" + SCRIPT_NAME + "\" extra");
+        MimeMessage message = prepareMimeMessage("SETACTIVE \"" + SCRIPT_NAME.getValue() + "\" extra");
         Mail mail = createUnauthenticatedMail(message);
         mailet.service(mail);
-        ensureResponse("Re: SETACTIVE \"" + SCRIPT_NAME + "\" extra", "NO \"Too many arguments: extra\"");
+        ensureResponse("Re: SETACTIVE \"" + SCRIPT_NAME.getValue() + "\" extra", "NO \"Too many arguments: extra\"");
     }
 
     @Test


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


[20/20] james-project git commit: JAMES-2437 When the publickey is missing in the keystore a NPE is thrown

Posted by bt...@apache.org.
JAMES-2437 When the publickey is missing in the keystore a NPE is thrown


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

Branch: refs/heads/master
Commit: b10fa18aa252624ce178e064919d92c7929d7d50
Parents: 25e9a11
Author: Gautier DI FOLCO <gd...@linagora.com>
Authored: Thu Jun 21 12:58:44 2018 +0200
Committer: benwa <bt...@linagora.com>
Committed: Tue Jun 26 16:12:07 2018 +0700

----------------------------------------------------------------------
 .../jmap/crypto/JamesSignatureHandler.java      |  16 ++++++---
 .../crypto/JamesSignatureHandlerProvider.java   |  33 ++++++++++++-------
 .../jmap/crypto/JamesSignatureHandlerTest.java  |  17 +++++++++-
 .../jmap/src/test/resources/badAliasKeystore    | Bin 0 -> 2246 bytes
 4 files changed, 50 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/b10fa18a/server/protocols/jmap/src/main/java/org/apache/james/jmap/crypto/JamesSignatureHandler.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/crypto/JamesSignatureHandler.java b/server/protocols/jmap/src/main/java/org/apache/james/jmap/crypto/JamesSignatureHandler.java
index 5ba69b9..5d3dd4f 100644
--- a/server/protocols/jmap/src/main/java/org/apache/james/jmap/crypto/JamesSignatureHandler.java
+++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/crypto/JamesSignatureHandler.java
@@ -23,11 +23,14 @@ import java.io.InputStream;
 import java.security.InvalidKeyException;
 import java.security.Key;
 import java.security.KeyStore;
+import java.security.KeyStoreException;
 import java.security.NoSuchAlgorithmException;
 import java.security.PrivateKey;
 import java.security.PublicKey;
 import java.security.Signature;
 import java.security.SignatureException;
+import java.security.cert.Certificate;
+import java.util.Optional;
 
 import javax.inject.Inject;
 
@@ -65,11 +68,16 @@ public class JamesSignatureHandler implements SignatureHandler {
     public void init() throws Exception {
         KeyStore keystore = KeyStore.getInstance(JKS);
         InputStream fis = fileSystem.getResource(jmapConfiguration.getKeystore());
-        keystore.load(fis, jmapConfiguration.getSecret().toCharArray());
-        publicKey = keystore.getCertificate(ALIAS).getPublicKey();
-        Key key = keystore.getKey(ALIAS, jmapConfiguration.getSecret().toCharArray());
+        char[] secret = jmapConfiguration.getSecret().toCharArray();
+        keystore.load(fis, secret);
+        Certificate aliasCertificate = Optional
+                .ofNullable(keystore.getCertificate(ALIAS))
+                .orElseThrow(() -> new KeyStoreException("Alias '" + ALIAS + "' keystore can't be found"));
+
+        publicKey = aliasCertificate.getPublicKey();
+        Key key = keystore.getKey(ALIAS, secret);
         if (! (key instanceof PrivateKey)) {
-            throw new Exception("Provided key is not a PrivateKey");
+            throw new KeyStoreException("Provided key is not a PrivateKey");
         }
         privateKey = (PrivateKey) key;
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/b10fa18a/server/protocols/jmap/src/test/java/org/apache/james/jmap/crypto/JamesSignatureHandlerProvider.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/crypto/JamesSignatureHandlerProvider.java b/server/protocols/jmap/src/test/java/org/apache/james/jmap/crypto/JamesSignatureHandlerProvider.java
index b2b84bf..c531581 100644
--- a/server/protocols/jmap/src/test/java/org/apache/james/jmap/crypto/JamesSignatureHandlerProvider.java
+++ b/server/protocols/jmap/src/test/java/org/apache/james/jmap/crypto/JamesSignatureHandlerProvider.java
@@ -27,8 +27,10 @@ import java.util.Optional;
 
 import org.apache.james.filesystem.api.FileSystem;
 import org.apache.james.jmap.JMAPConfiguration;
+import org.apache.james.jmap.JMAPConfiguration.Builder;
 
 public class JamesSignatureHandlerProvider {
+
     private static final String JWT_PUBLIC_KEY = "-----BEGIN PUBLIC KEY-----\n" +
         "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtlChO/nlVP27MpdkG0Bh\n" +
         "16XrMRf6M4NeyGa7j5+1UKm42IKUf3lM28oe82MqIIRyvskPc11NuzSor8HmvH8H\n" +
@@ -39,11 +41,29 @@ public class JamesSignatureHandlerProvider {
         "kwIDAQAB\n" +
         "-----END PUBLIC KEY-----";
 
+    public JamesSignatureHandlerProvider() {
+    }
+
     public JamesSignatureHandler provide() throws Exception {
-        FileSystem fileSystem = new FileSystem() {
+        JamesSignatureHandler signatureHandler = new JamesSignatureHandler(newFileSystem(),
+                newConfigurationBuilder().build());
+        signatureHandler.init();
+        return signatureHandler;
+    }
+
+    public static Builder newConfigurationBuilder() {
+        return JMAPConfiguration.builder()
+            .enable()
+            .keystore("keystore")
+            .secret("james72laBalle")
+            .jwtPublicKeyPem(Optional.of(JWT_PUBLIC_KEY));
+    }
+
+    public static FileSystem newFileSystem() {
+        return new FileSystem() {
             @Override
             public InputStream getResource(String url) throws IOException {
-                return ClassLoader.getSystemResourceAsStream("keystore");
+                return ClassLoader.getSystemResourceAsStream(url);
             }
 
             @Override
@@ -56,15 +76,6 @@ public class JamesSignatureHandlerProvider {
                 return null;
             }
         };
-        JamesSignatureHandler signatureHandler = new JamesSignatureHandler(fileSystem, 
-                JMAPConfiguration.builder()
-                    .enable()
-                    .keystore("keystore")
-                    .secret("james72laBalle")
-                    .jwtPublicKeyPem(Optional.of(JWT_PUBLIC_KEY))
-                    .build());
-        signatureHandler.init();
-        return signatureHandler;
     }
 
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/b10fa18a/server/protocols/jmap/src/test/java/org/apache/james/jmap/crypto/JamesSignatureHandlerTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/crypto/JamesSignatureHandlerTest.java b/server/protocols/jmap/src/test/java/org/apache/james/jmap/crypto/JamesSignatureHandlerTest.java
index 7aec75f..e885f41 100644
--- a/server/protocols/jmap/src/test/java/org/apache/james/jmap/crypto/JamesSignatureHandlerTest.java
+++ b/server/protocols/jmap/src/test/java/org/apache/james/jmap/crypto/JamesSignatureHandlerTest.java
@@ -21,6 +21,9 @@ package org.apache.james.jmap.crypto;
 
 import static org.assertj.core.api.Assertions.assertThat;
 
+import java.security.KeyStoreException;
+
+import org.apache.james.jmap.JMAPConfiguration;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -34,7 +37,19 @@ public class JamesSignatureHandlerTest {
 
     @Before
     public void setUp() throws Exception {
-        signatureHandler = new JamesSignatureHandlerProvider().provide();
+       signatureHandler = new JamesSignatureHandlerProvider().provide();
+    }
+
+    @Test(expected = KeyStoreException.class)
+    public void initShouldThrowOnUnknownKeystore() throws Exception {
+        JMAPConfiguration jmapConfiguration = JamesSignatureHandlerProvider.newConfigurationBuilder()
+            .keystore("badAliasKeystore")
+            .secret("password")
+            .build();
+
+        JamesSignatureHandler signatureHandler = new JamesSignatureHandler(JamesSignatureHandlerProvider.newFileSystem(),
+                jmapConfiguration);
+        signatureHandler.init();
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/james-project/blob/b10fa18a/server/protocols/jmap/src/test/resources/badAliasKeystore
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/test/resources/badAliasKeystore b/server/protocols/jmap/src/test/resources/badAliasKeystore
new file mode 100644
index 0000000..0a4de22
Binary files /dev/null and b/server/protocols/jmap/src/test/resources/badAliasKeystore differ


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


[11/20] james-project git commit: JAMES-2151 Remove 500 documentation from website webadmin doc

Posted by bt...@apache.org.
JAMES-2151 Remove 500  documentation from website webadmin doc


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

Branch: refs/heads/master
Commit: ff2113e5976f76dfc6af89e8e8dfe1b390665d1d
Parents: 3caa3d6
Author: benwa <bt...@linagora.com>
Authored: Fri Jun 22 11:40:58 2018 +0700
Committer: benwa <bt...@linagora.com>
Committed: Tue Jun 26 16:07:50 2018 +0700

----------------------------------------------------------------------
 src/site/markdown/server/manage-webadmin.md | 67 ++----------------------
 1 file changed, 4 insertions(+), 63 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/ff2113e5/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 71e6cf0..637fb98 100644
--- a/src/site/markdown/server/manage-webadmin.md
+++ b/src/site/markdown/server/manage-webadmin.md
@@ -19,6 +19,9 @@ In case of any error, the system will return an error message which is json form
 }
 ```
 
+Also be aware that, in case things go wrong, all endpoints might return a 500 internal error (with a JSON body formatted
+as exposed above). To avoid information duplication, this is ommited on endpoint specific documentation.
+
 ## Navigation menu
 
  - [Administrating domains](#Administrating_domains)
@@ -61,7 +64,6 @@ Response codes:
 
  - 204: The domain was successfully added
  - 400: The domain name is invalid
- - 500: Internal error while adding the domain
 
 ### Delete a domain
 
@@ -72,7 +74,6 @@ curl -XDELETE http://ip:port/domains/domainToBeDeleted
 Response codes:
 
  - 204: The domain was successfully removed
- - 500: Internal error while removing the domain
 
 ### Test if a domain exists
 
@@ -84,7 +85,6 @@ Response codes:
 
  - 204: The domain exists
  - 404: The domain does not exist
- - 500: Internal error while accessing the domains
 
 ### Get the list of domains
 
@@ -101,7 +101,6 @@ Possible response:
 Response codes:
 
  - 200: The domain list was successfully retrieved
- - 500: Internal error while accessing the domains
 
 ## Administrating users
 
@@ -127,7 +126,6 @@ Response codes:
  - 204: The user was successfully created
  - 400: The user name or the payload is invalid
  - 409: Conflict: A concurrent modification make that query to fail
- - 500: Internal error while adding the user
 
 Note: if the user is already, its password will be updated.
 
@@ -146,7 +144,6 @@ curl -XDELETE http://ip:port/users/userToBeDeleted
 Response codes:
 
  - 204: The user was successfully deleted
- - 500: Internal error while deleting the user
 
 ### Retrieving the user list
 
@@ -163,7 +160,6 @@ The answer looks like:
 Response codes:
 
  - 200: The user name list was successfully retrieved
- - 500: Internal error while retrieving the users
 
 ## Administrating user mailboxes
 
@@ -209,7 +205,6 @@ Response codes:
  - 204: The mailbox now does not exist on the server
  - 400: Invalid mailbox name
  - 404: The user name does not exist
- - 500: Internal error
 
 ### Testing existence of a mailbox
 
@@ -225,7 +220,6 @@ Response codes:
  - 204: The mailbox exists
  - 400: Invalid mailbox name
  - 404: The user name does not exist, the mailbox does not exist
- - 500: Internal error
 
 ### Listing user mailboxes
 
@@ -245,7 +239,6 @@ Response codes:
 
  - 200: The mailboxes list was successfully retrieved
  - 404: The user name does not exist
- - 500: Internal error
 
 ### Deleting user mailboxes
 
@@ -259,7 +252,6 @@ Response codes:
 
  - 204: The user do not have mailboxes anymore
  - 404: The user name does not exist
- - 500: Internal error
 
 ## Administrating quotas by users
 
@@ -333,7 +325,6 @@ Response codes:
 
  - 200: The user's quota was successfully retrieved
  - 404: The user does not exist
- - 500: Internal error while accessing the user's quota
 
 ### Updating the quota for a user
 
@@ -359,7 +350,6 @@ Response codes:
  - 400: The body is not a positive integer neither an unlimited value (-1).
  - 404: The user does not exist
  - 409: The requested restriction can’t be enforced right now.
- - 500: Internal server error - Something went bad on the server side.
 
 ### Getting the quota count for a user
 
@@ -379,7 +369,6 @@ Response codes:
 
  - 200: The user's quota was successfully retrieved
  - 404: The user does not exist
- - 500: Internal error while accessing the user's quota
 
 ### Updating the quota count for a user
 
@@ -401,7 +390,6 @@ Response codes:
  - 400: The body is not a positive integer neither an unlimited value (-1).
  - 404: The user does not exist
  - 409: The requested restriction can’t be enforced right now.
- - 500: Internal server error - Something went bad on the server side.
 
 ### Deleting the quota count for a user
 
@@ -417,7 +405,6 @@ Response codes:
  - 400: The body is not a positive integer neither an unlimited value (-1).
  - 404: The user does not exist
  - 409: The requested restriction can’t be enforced right now.
- - 500: Internal server error - Something went bad on the server side.
 
 ### Getting the quota size for a user
 
@@ -437,7 +424,6 @@ Response codes:
 
  - 200: The user's quota was successfully retrieved
  - 404: The user does not exist
- - 500: Internal error while accessing the user's quota
 
 ### Updating the quota size for a user
 
@@ -459,7 +445,6 @@ Response codes:
  - 400: The body is not a positive integer neither an unlimited value (-1).
  - 404: The user does not exist
  - 409: The requested restriction can’t be enforced right now.
- - 500: Internal server error - Something went bad on the server side.
 
 ### Deleting the quota size for a user
 
@@ -475,7 +460,6 @@ Response codes:
  - 400: The body is not a positive integer neither an unlimited value (-1).
  - 404: The user does not exist
  - 409: The requested restriction can’t be enforced right now.
- - 500: Internal server error - Something went bad on the server side.
 
 ### Searching user by quota ratio
 
@@ -537,7 +521,6 @@ Response codes:
 
  - 200: List of users had successfully been returned.
  - 400: Validation issues with parameters
- - 500: Internal server error - Something went bad on the server side.
 
 ## Administrating quotas by domains
 
@@ -577,7 +560,6 @@ Response codes:
  - 200: The domain's quota was successfully retrieved
  - 404: The domain does not exist
  - 405: Domain Quota configuration not supported when virtual hosting is desactivated.
- - 500: Internal error while accessing the domain's quota
 
 ### Updating the quota for a domain
 
@@ -604,7 +586,6 @@ Response codes:
  - 404: The domain does not exist
  - 405: Domain Quota configuration not supported when virtual hosting is desactivated.
  - 409: The requested restriction can’t be enforced right now.
- - 500: Internal server error - Something went bad on the server side.
 
 ### Getting the quota count for a domain
 
@@ -648,7 +629,6 @@ Response codes:
  - 404: The domain does not exist
  - 405: Domain Quota configuration not supported when virtual hosting is desactivated.
  - 409: The requested restriction can’t be enforced right now.
- - 500: Internal server error - Something went bad on the server side.
 
 ### Deleting the quota count for a domain
 
@@ -686,7 +666,6 @@ Response codes:
  - 200: The domain's quota was successfully retrieved
  - 404: The domain does not exist
  - 405: Domain Quota configuration not supported when virtual hosting is desactivated.
- - 500: Internal error while accessing the domain's quota
 
 ### Updating the quota size for a domain
 
@@ -768,7 +747,6 @@ Note that `quota` object can contain a fixed value, an empty value (null) or an
 Response codes:
 
  - 200: The quota was successfully retrieved
- - 500: Internal error while accessing quota
 
 ### Updating global quota
 
@@ -790,7 +768,6 @@ Response codes:
 
  - 204: The quota has been updated
  - 400: The body is not a positive integer neither an unlimited value (-1).
- - 500: Internal server error - Something went bad on the server side.
 
 ### Getting the global quota count
 
@@ -809,7 +786,6 @@ The answer looks like:
 Response codes:
 
  - 200: The quota was successfully retrieved
- - 500: Internal error while accessing the quota
 
 ### Updating the global quota count
 
@@ -828,7 +804,6 @@ Response codes:
 
  - 204: The quota has been updated
  - 400: The body is not a positive integer neither an unlimited value (-1).
- - 500: Internal server error - Something went bad on the server side.
 
 ### Deleting the global quota count
 
@@ -844,7 +819,6 @@ Response codes:
  - 400: The body is not a positive integer neither an unlimited value (-1).
  - 404: The user does not exist
  - 409: The requested restriction can’t be enforced right now.
- - 500: Internal server error - Something went bad on the server side.
 
 ### Getting the global quota size
 
@@ -862,7 +836,6 @@ The answer looks like:
 Response codes:
 
  - 200: The quota was successfully retrieved
- - 500: Internal error while accessing the quota
 
 ### Updating the global quota size
 
@@ -881,7 +854,6 @@ Response codes:
  - 204: The quota has been updated
  - 400: The body is not a positive integer neither an unlimited value (-1).
  - 409: The requested restriction can’t be enforced right now.
- - 500: Internal server error - Something went bad on the server side.
 
 ### Deleting the global quota size
 
@@ -894,7 +866,6 @@ Response codes:
  - 204: The quota has been updated to unlimited value.
  - 400: The body is not a positive integer neither an unlimited value (-1).
  - 409: The requested restriction can’t be enforced right now.
- - 500: Internal server error - Something went bad on the server side.
 
 ## Cassandra Schema upgrades
 
@@ -934,7 +905,6 @@ Where the number corresponds to the current schema version of the database you a
 Response codes:
 
  - 200: Success
- - 500: Internal error
 
 ### Retrieving latest available Cassandra schema version
 
@@ -954,7 +924,6 @@ migrating to this schema version.
 Response codes:
 
  - 200: Success
- - 500: Internal error
 
 ### Upgrading to a specific version
 
@@ -974,7 +943,6 @@ Response codes:
  - 200: Success. The scheduled task taskId is returned.
  - 400: The version is invalid. The version should be a strictly positive number.
  - 410: Error while planning this migration. This resource is gone away. Reason is mentionned in the body.
- - 500: Internal error while creating the migration task.
 
 Note that several calls to this endpoint will be run in a sequential pattern.
 
@@ -1011,7 +979,6 @@ Response codes:
 
  - 200: Success. The scheduled task taskId is returned.
  - 410: Error while planning this migration. This resource is gone away. Reason is mentionned in the body.
- - 500: Internal error while creating the migration task.
 
 Note that several calls to this endpoint will be run in a sequential pattern.
 
@@ -1104,7 +1071,6 @@ Will return the groups as a list of JSON Strings representing mail addresses. Fo
 Response codes:
 
  - 200: Success
- - 500: Internal error
 
 ### Listing members of a group
 
@@ -1123,7 +1089,6 @@ Response codes:
  - 200: Success
  - 400: Group structure is not valid
  - 404: The group does not exist
- - 500: Internal error
 
 ### Adding a group member
 
@@ -1139,7 +1104,6 @@ Response codes:
  - 400: Group structure or member is not valid
  - 403: Server does not own the requested domain
  - 409: Requested group address is already used for another purpose
- - 500: Internal error
 
 ### Removing a group member
 
@@ -1153,7 +1117,6 @@ Response codes:
 
  - 200: Success
  - 400: Group structure or member is not valid
- - 500: Internal error
 
 ## Creating address forwards
 
@@ -1192,7 +1155,6 @@ Will return the users having forwards configured as a list of JSON Strings repre
 Response codes:
 
  - 200: Success
- - 500: Internal error
 
 ### Listing destinations in a forward
 
@@ -1214,7 +1176,6 @@ Response codes:
  - 200: Success
  - 400: Forward structure is not valid
  - 404: The given user don't have forwards or does not exist
- - 500: Internal error
 
 ### Adding a new destination to a forward
 
@@ -1230,7 +1191,6 @@ Response codes:
  - 400: Forward structure or member is not valid
  - 403: Server does not own the requested domain
  - 404: Requested forward address does not match an existing user
- - 500: Internal error
 
 ### Removing a destination of a forward
 
@@ -1244,7 +1204,6 @@ Response codes:
 
  - 200: Success
  - 400: Forward structure or member is not valid
- - 500: Internal error
 
 ## Administrating mail repositories
 
@@ -1273,7 +1232,6 @@ curl -XPUT http://ip:port/mailRepositories/file%3A%2F%2FmailRepo
 Response codes:
 
  - 204: The repository is created
- - 500: Internal error
 
 ### Listing mail repositories
 
@@ -1309,7 +1267,6 @@ You can use `id`, the encoded URL of the repository, to access it in later reque
 Response codes:
 
  - 200: The list of mail repositories
- - 500: Internal error
 
 ### Getting additional information for a mail repository
 
@@ -1337,7 +1294,6 @@ Response codes:
 
  - 200: Additonnal information for that repository
  - 404: This repository can not be found
- - 500: Internal error
 
 ### Listing mails contained in a mail repository
 
@@ -1378,7 +1334,6 @@ Response codes:
  - 200: The list of mail keys contained in that mail repository
  - 400: Invalid parameters
  - 404: This repository can not be found
- - 500: Internal error
 
 ### Reading/downloading a mail details
 
@@ -1468,7 +1423,6 @@ Response codes:
 
  - 200: Details of the mail
  - 404: This repository or mail can not be found
- - 500: Internal error
 
 ### Removing a mail from a mail repository
 
@@ -1486,7 +1440,6 @@ Response codes:
 
  - 204: This mail no longer exists in this repository
  - 404: This repository can not be found
- - 500: Internal error
 
 ### Removing all mails from a mail repository
 
@@ -1519,7 +1472,6 @@ Response codes:
 
  - 201: Success. Corresponding task id is returned.
  - 404: Could not find that mail repository
- - 500: Internal error
 
 The scheduled task will have the following type `clearMailRepository` and the following `additionalInformation`:
 
@@ -1581,7 +1533,6 @@ Response codes:
 
  - 201: Success. Corresponding task id is returned.
  - 404: Could not find that mail repository
- - 500: Internal error
 
 The scheduled task will have the following type `reprocessingAllTask` and the following `additionalInformation`:
 
@@ -1643,7 +1594,6 @@ Response codes:
 
  - 201: Success. Corresponding task id is returned.
  - 404: Could not find that mail repository
- - 500: Internal error
 
 The scheduled task will have the following type `reprocessingOneTask` and the following `additionalInformation`:
 
@@ -1679,8 +1629,7 @@ The answer looks like:
 
 Response codes:
 
- - 200: The list of mail queuess
- - 500: Internal error
+ - 200: The list of mail queues
 
 ### Getting a mail queue details
 
@@ -1699,7 +1648,6 @@ Response codes:
  - 200: Success
  - 400: Mail queue is not valid
  - 404: The mail queue does not exist
- - 500: Internal error
 
 ### Listing the mails of a mail queue
 
@@ -1731,7 +1679,6 @@ Response codes:
  - 200: Success
  - 400: Mail queue is not valid or limit is invalid
  - 404: The mail queue does not exist
- - 500: Internal error
 
 ### Deleting mails from a mail queue
 
@@ -1753,7 +1700,6 @@ Response codes:
  - 201: Success. Corresponding task id is returned.
  - 400: Invalid request
  - 404: The mail queue does not exist
- - 500: Internal error
 
 The scheduled task will have the following type `deleteMailsFromMailQueue` and the following `additionalInformation`:
 
@@ -1782,7 +1728,6 @@ Response codes:
  - 201: Success. Corresponding task id is returned.
  - 400: Invalid request
  - 404: The mail queue does not exist
- - 500: Internal error
 
 The scheduled task will have the following type `clearMailQueue` and the following `additionalInformation`:
 
@@ -1812,7 +1757,6 @@ Response codes:
  - 204: Success (No content)
  - 400: Invalid request
  - 404: The mail queue does not exist
- - 500: Internal error
 
 ## Administrating DLP Configuration
 
@@ -1840,7 +1784,6 @@ Response codes:
  - 200: A list of dlp configuration items is returned
  - 400: Invalid senderDomain or payload in request
  - 404: The domain does not exist.
- - 500: Internal error
 
 This is an example of returned body. The rules field is a list of rules as described below.
 
@@ -1910,7 +1853,6 @@ Response codes:
  - 204: List of dlp configuration items is stored
  - 400: Invalid senderDomain or payload in request
  - 404: The domain does not exist.
- - 500: Internal error
 
 ### Remove DLP configuration by sender domain
 
@@ -1925,7 +1867,6 @@ Response codes:
  - 204: DLP configuration is removed
  - 400: Invalid senderDomain or payload in request
  - 404: The domain does not exist.
- - 500: Internal error
 
 ## Administrating Sieve quotas
 


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