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:59 UTC

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

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