You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by bt...@apache.org on 2017/08/08 03:42:15 UTC

[1/6] james-project git commit: JAMES-2103 Use final fields in Quota related classes

Repository: james-project
Updated Branches:
  refs/heads/master 7c333a50d -> 975fcf12e


JAMES-2103 Use final fields in Quota related classes


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

Branch: refs/heads/master
Commit: 797660c4560dc459c1e3f0db59f4a010fc246ff9
Parents: 7c333a5
Author: benwa <bt...@linagora.com>
Authored: Fri Jul 28 11:21:37 2017 +0700
Committer: benwa <bt...@linagora.com>
Committed: Tue Aug 8 10:39:48 2017 +0700

----------------------------------------------------------------------
 .../manager/InMemoryIntegrationResources.java       | 11 +++--------
 .../src/main/resources/META-INF/spring/quota.xml    |  8 ++++----
 .../store/quota/ListeningCurrentQuotaUpdater.java   | 12 ++++--------
 .../mailbox/store/quota/StoreQuotaManager.java      | 16 ++++++----------
 .../quota/ListeningCurrentQuotaUpdaterTest.java     |  4 +---
 .../mailbox/store/quota/StoreQuotaManagerTest.java  |  4 +---
 .../cassandra/host/CassandraHostSystem.java         |  8 ++------
 .../inmemory/host/InMemoryHostSystem.java           |  8 ++------
 .../mpt/imapmailbox/jpa/host/JPAHostSystem.java     |  8 ++------
 .../james/transport/matchers/IsOverQuotaTest.java   |  5 ++---
 10 files changed, 27 insertions(+), 57 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/797660c4/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/manager/InMemoryIntegrationResources.java
----------------------------------------------------------------------
diff --git a/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/manager/InMemoryIntegrationResources.java b/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/manager/InMemoryIntegrationResources.java
index 240b5a7..d70e519 100644
--- a/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/manager/InMemoryIntegrationResources.java
+++ b/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/manager/InMemoryIntegrationResources.java
@@ -76,8 +76,6 @@ public class InMemoryIntegrationResources implements IntegrationResources {
     
     @Override
     public QuotaManager createQuotaManager(MaxQuotaManager maxQuotaManager, MailboxManager mailboxManager) throws Exception {
-        StoreQuotaManager quotaManager = new StoreQuotaManager();
-        quotaManager.setCalculateWhenUnlimited(false);
 
         QuotaRootResolver quotaRootResolver =  createQuotaRootResolver(mailboxManager);
 
@@ -86,12 +84,9 @@ public class InMemoryIntegrationResources implements IntegrationResources {
             mailboxManager
         );
 
-        ListeningCurrentQuotaUpdater listeningCurrentQuotaUpdater = new ListeningCurrentQuotaUpdater();
-        listeningCurrentQuotaUpdater.setQuotaRootResolver(quotaRootResolver);
-        listeningCurrentQuotaUpdater.setCurrentQuotaManager(currentQuotaManager);
-
-        quotaManager.setCurrentQuotaManager(currentQuotaManager);
-        quotaManager.setMaxQuotaManager(maxQuotaManager);
+        ListeningCurrentQuotaUpdater listeningCurrentQuotaUpdater = new ListeningCurrentQuotaUpdater(currentQuotaManager, quotaRootResolver);
+        StoreQuotaManager quotaManager = new StoreQuotaManager(currentQuotaManager, maxQuotaManager);
+        quotaManager.setCalculateWhenUnlimited(false);
         ((StoreMailboxManager) mailboxManager).setQuotaManager(quotaManager);
         mailboxManager.addGlobalListener(listeningCurrentQuotaUpdater, null);
         return quotaManager;

http://git-wip-us.apache.org/repos/asf/james-project/blob/797660c4/mailbox/spring/src/main/resources/META-INF/spring/quota.xml
----------------------------------------------------------------------
diff --git a/mailbox/spring/src/main/resources/META-INF/spring/quota.xml b/mailbox/spring/src/main/resources/META-INF/spring/quota.xml
index 31870b3..45361d2 100644
--- a/mailbox/spring/src/main/resources/META-INF/spring/quota.xml
+++ b/mailbox/spring/src/main/resources/META-INF/spring/quota.xml
@@ -45,14 +45,14 @@
 
     <bean id="noQuotaManager" class="org.apache.james.mailbox.store.quota.NoQuotaManager" lazy-init="true"/>
     <bean id="storeQuotaManager" class="org.apache.james.mailbox.store.quota.StoreQuotaManager" lazy-init="true">
-        <property name="maxQuotaManager" ref="maxQuotaManager"/>
-        <property name="currentQuotaManager" ref="currentQuotaManager"/>
+        <constructor-arg index="0" ref="currentQuotaManager"/>
+        <constructor-arg index="1" ref="maxQuotaManager"/>
     </bean>
 
     <bean id="noQuotaUpdater" class="org.apache.james.mailbox.store.quota.NoQuotaUpdater" lazy-init="true"/>
     <bean id="eventQuotaUpdater" class="org.apache.james.mailbox.store.quota.ListeningCurrentQuotaUpdater" lazy-init="true">
-        <property name="quotaRootResolver" ref="quotaRootResolver"/>
-        <property name="currentQuotaManager" ref="currentQuotaManager"/>
+        <constructor-arg index="0" ref="currentQuotaManager"/>
+        <constructor-arg index="1" ref="quotaRootResolver"/>
     </bean>
 
 </beans>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/james-project/blob/797660c4/mailbox/store/src/main/java/org/apache/james/mailbox/store/quota/ListeningCurrentQuotaUpdater.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/quota/ListeningCurrentQuotaUpdater.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/quota/ListeningCurrentQuotaUpdater.java
index 9e48071..c54b9d6 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/quota/ListeningCurrentQuotaUpdater.java
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/quota/ListeningCurrentQuotaUpdater.java
@@ -30,17 +30,13 @@ import javax.inject.Inject;
 
 public class ListeningCurrentQuotaUpdater implements MailboxListener, QuotaUpdater {
 
-    private StoreCurrentQuotaManager currentQuotaManager;
-    private QuotaRootResolver quotaRootResolver;
+    private final StoreCurrentQuotaManager currentQuotaManager;
+    private final QuotaRootResolver quotaRootResolver;
 
     @Inject
-    public void setQuotaRootResolver(QuotaRootResolver quotaRootResolver) {
-        this.quotaRootResolver = quotaRootResolver;
-    }
-
-    @Inject
-    public void setCurrentQuotaManager(StoreCurrentQuotaManager currentQuotaManager) {
+    public ListeningCurrentQuotaUpdater(StoreCurrentQuotaManager currentQuotaManager, QuotaRootResolver quotaRootResolver) {
         this.currentQuotaManager = currentQuotaManager;
+        this.quotaRootResolver = quotaRootResolver;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/james-project/blob/797660c4/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 c1923cf..65cb3fe 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
@@ -34,22 +34,18 @@ import javax.inject.Inject;
  * Relies on the CurrentQuotaManager and MaxQuotaManager provided.
  */
 public class StoreQuotaManager implements QuotaManager {
-    private CurrentQuotaManager currentQuotaManager;
-    private MaxQuotaManager maxQuotaManager;
+    private final CurrentQuotaManager currentQuotaManager;
+    private final MaxQuotaManager maxQuotaManager;
     private boolean calculateWhenUnlimited = false;
 
-    public void setCalculateWhenUnlimited(boolean calculateWhenUnlimited) {
-        this.calculateWhenUnlimited = calculateWhenUnlimited;
-    }
-
     @Inject
-    public void setMaxQuotaManager(MaxQuotaManager maxQuotaManager) {
+    public StoreQuotaManager(CurrentQuotaManager currentQuotaManager, MaxQuotaManager maxQuotaManager) {
+        this.currentQuotaManager = currentQuotaManager;
         this.maxQuotaManager = maxQuotaManager;
     }
 
-    @Inject
-    public void setCurrentQuotaManager(CurrentQuotaManager currentQuotaManager) {
-        this.currentQuotaManager = currentQuotaManager;
+    public void setCalculateWhenUnlimited(boolean calculateWhenUnlimited) {
+        this.calculateWhenUnlimited = calculateWhenUnlimited;
     }
 
     public Quota getMessageQuota(QuotaRoot quotaRoot) throws MailboxException {

http://git-wip-us.apache.org/repos/asf/james-project/blob/797660c4/mailbox/store/src/test/java/org/apache/james/mailbox/store/quota/ListeningCurrentQuotaUpdaterTest.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/quota/ListeningCurrentQuotaUpdaterTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/quota/ListeningCurrentQuotaUpdaterTest.java
index 054a275..63f483a 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/quota/ListeningCurrentQuotaUpdaterTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/quota/ListeningCurrentQuotaUpdaterTest.java
@@ -54,9 +54,7 @@ public class ListeningCurrentQuotaUpdaterTest {
     public void setUp() throws Exception {
         mockedQuotaRootResolver = mock(QuotaRootResolver.class);
         mockedCurrentQuotaManager = mock(StoreCurrentQuotaManager.class);
-        testee = new ListeningCurrentQuotaUpdater();
-        testee.setCurrentQuotaManager(mockedCurrentQuotaManager);
-        testee.setQuotaRootResolver(mockedQuotaRootResolver);
+        testee = new ListeningCurrentQuotaUpdater(mockedCurrentQuotaManager, mockedQuotaRootResolver);
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/james-project/blob/797660c4/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 0c3ac74..c7c6ccc 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
@@ -46,9 +46,7 @@ public class StoreQuotaManagerTest {
     public void setUp() {
         mockedCurrentQuotaManager = mock(CurrentQuotaManager.class);
         mockedMaxQuotaManager = mock(MaxQuotaManager.class);
-        testee = new StoreQuotaManager();
-        testee.setCurrentQuotaManager(mockedCurrentQuotaManager);
-        testee.setMaxQuotaManager(mockedMaxQuotaManager);
+        testee = new StoreQuotaManager(mockedCurrentQuotaManager, mockedMaxQuotaManager);
         quotaRoot = QuotaRootImpl.quotaRoot("benwa");
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/797660c4/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 7996745..54dc713 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
@@ -146,13 +146,9 @@ public class CassandraHostSystem extends JamesImapHostSystem {
 
         CassandraCurrentQuotaManager currentQuotaManager = new CassandraCurrentQuotaManager(session);
 
-        StoreQuotaManager quotaManager = new StoreQuotaManager();
-        quotaManager.setMaxQuotaManager(perUserMaxQuotaManager);
-        quotaManager.setCurrentQuotaManager(currentQuotaManager);
+        StoreQuotaManager quotaManager = new StoreQuotaManager(currentQuotaManager, perUserMaxQuotaManager);
 
-        ListeningCurrentQuotaUpdater quotaUpdater = new ListeningCurrentQuotaUpdater();
-        quotaUpdater.setCurrentQuotaManager(currentQuotaManager);
-        quotaUpdater.setQuotaRootResolver(quotaRootResolver);
+        ListeningCurrentQuotaUpdater quotaUpdater = new ListeningCurrentQuotaUpdater(currentQuotaManager, quotaRootResolver);
 
         mailboxManager.setQuotaRootResolver(quotaRootResolver);
         mailboxManager.setQuotaManager(quotaManager);

http://git-wip-us.apache.org/repos/asf/james-project/blob/797660c4/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 0394d3e..8cc1fd1 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
@@ -88,13 +88,9 @@ public class InMemoryHostSystem extends JamesImapHostSystem {
             new CurrentQuotaCalculator(mailboxManager.getMapperFactory(), quotaRootResolver),
             mailboxManager);
 
-        StoreQuotaManager quotaManager = new StoreQuotaManager();
-        quotaManager.setMaxQuotaManager(perUserMaxQuotaManager);
-        quotaManager.setCurrentQuotaManager(currentQuotaManager);
+        StoreQuotaManager quotaManager = new StoreQuotaManager(currentQuotaManager, perUserMaxQuotaManager);
 
-        ListeningCurrentQuotaUpdater quotaUpdater = new ListeningCurrentQuotaUpdater();
-        quotaUpdater.setCurrentQuotaManager(currentQuotaManager);
-        quotaUpdater.setQuotaRootResolver(quotaRootResolver);
+        ListeningCurrentQuotaUpdater quotaUpdater = new ListeningCurrentQuotaUpdater(currentQuotaManager, quotaRootResolver);
 
         mailboxManager.setQuotaRootResolver(quotaRootResolver);
         mailboxManager.setQuotaManager(quotaManager);

http://git-wip-us.apache.org/repos/asf/james-project/blob/797660c4/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 c3f103a..2ba9c0c 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
@@ -98,12 +98,8 @@ public class JPAHostSystem extends JamesImapHostSystem {
         DefaultQuotaRootResolver quotaRootResolver = new DefaultQuotaRootResolver(mapperFactory);
         JpaCurrentQuotaManager currentQuotaManager = new JpaCurrentQuotaManager(entityManagerFactory);
         maxQuotaManager = new JPAPerUserMaxQuotaManager(entityManagerFactory);
-        StoreQuotaManager storeQuotaManager = new StoreQuotaManager();
-        storeQuotaManager.setCurrentQuotaManager(currentQuotaManager);
-        storeQuotaManager.setMaxQuotaManager(maxQuotaManager);
-        ListeningCurrentQuotaUpdater quotaUpdater = new ListeningCurrentQuotaUpdater();
-        quotaUpdater.setCurrentQuotaManager(currentQuotaManager);
-        quotaUpdater.setQuotaRootResolver(quotaRootResolver);
+        StoreQuotaManager storeQuotaManager = new StoreQuotaManager(currentQuotaManager, maxQuotaManager);
+        ListeningCurrentQuotaUpdater quotaUpdater = new ListeningCurrentQuotaUpdater(currentQuotaManager, quotaRootResolver);
 
         mailboxManager.setQuotaManager(storeQuotaManager);
         mailboxManager.setQuotaUpdater(quotaUpdater);

http://git-wip-us.apache.org/repos/asf/james-project/blob/797660c4/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 c614555..eeb8ccd 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
@@ -68,10 +68,9 @@ public class IsOverQuotaTest {
             new InMemoryMessageId.Factory());
 
         quotaRootResolver = new DefaultQuotaRootResolver(factory);
-        StoreQuotaManager quotaManager = new StoreQuotaManager();
         maxQuotaManager = new InMemoryPerUserMaxQuotaManager();
-        quotaManager.setMaxQuotaManager(maxQuotaManager);
-        quotaManager.setCurrentQuotaManager(new InMemoryCurrentQuotaManager(new CurrentQuotaCalculator(factory, quotaRootResolver), mailboxManager));
+        InMemoryCurrentQuotaManager currentQuotaManager = new InMemoryCurrentQuotaManager(new CurrentQuotaCalculator(factory, quotaRootResolver), mailboxManager);
+        StoreQuotaManager quotaManager = new StoreQuotaManager(currentQuotaManager, maxQuotaManager);
         usersRepository = mock(UsersRepository.class);
         testee = new IsOverQuota(quotaRootResolver, quotaManager, mailboxManager, usersRepository);
 


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


[6/6] james-project git commit: JAMES−2104 Remove mentions of templates in documentation

Posted by bt...@apache.org.
JAMES−2104 Remove mentions of templates in documentation


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

Branch: refs/heads/master
Commit: 975fcf12e8888677a2388a6abc5f86a505479a4e
Parents: a3dced9
Author: benwa <bt...@linagora.com>
Authored: Mon Jul 31 11:51:47 2017 +0700
Committer: benwa <bt...@linagora.com>
Committed: Tue Aug 8 10:41:18 2017 +0700

----------------------------------------------------------------------
 src/site/xdoc/server/config-antispam.xml        |  4 +-
 src/site/xdoc/server/config-cassandra.xml       |  2 +-
 src/site/xdoc/server/config-dnsservice.xml      |  2 +-
 src/site/xdoc/server/config-domainlist.xml      |  2 +-
 src/site/xdoc/server/config-elasticsearch.xml   |  2 +-
 src/site/xdoc/server/config-events.xml          |  2 +-
 src/site/xdoc/server/config-fetchmail.xml       |  2 +-
 src/site/xdoc/server/config-guice.xml           |  4 +-
 src/site/xdoc/server/config-imap4.xml           |  2 +-
 src/site/xdoc/server/config-mailbox.xml         |  2 +-
 src/site/xdoc/server/config-mailetcontainer.xml |  2 +-
 .../xdoc/server/config-mailrepositorystore.xml  |  2 +-
 src/site/xdoc/server/config-pop3.xml            |  2 +-
 src/site/xdoc/server/config-quota.xml           |  4 +-
 .../server/config-recipientrewritetable.xml     |  2 +-
 src/site/xdoc/server/config-smtp-lmtp.xml       |  4 +-
 src/site/xdoc/server/config-system.xml          |  6 +--
 src/site/xdoc/server/config-users.xml           |  2 +-
 src/site/xdoc/server/config.xml                 | 46 ++++++++++----------
 src/site/xdoc/server/install.xml                |  6 +--
 src/site/xdoc/server/quick-start.xml            |  5 +--
 21 files changed, 50 insertions(+), 55 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/975fcf12/src/site/xdoc/server/config-antispam.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/server/config-antispam.xml b/src/site/xdoc/server/config-antispam.xml
index 37008b0..c1682cb 100644
--- a/src/site/xdoc/server/config-antispam.xml
+++ b/src/site/xdoc/server/config-antispam.xml
@@ -30,8 +30,8 @@
     <p>Apache James Server Anti-Spam system can be configured via two main different mechanisms:</p>
     
     <ul>
-       <li>SMTP Hooks; see <a href="https://github.com/apache/james-project/tree/master/server/app/src/main/resources/smtpserver-template.xml">examples</a>.</li>
-       <li>Mailets; see <a href="https://github.com/apache/james-project/tree/master/server/app/src/main/resources/mailetcontainer-template.xml">examples</a>.</li>
+       <li>SMTP Hooks; see <a href="https://github.com/apache/james-project/tree/master/server/app/src/main/resources/smtpserver.xml">examples</a>.</li>
+       <li>Mailets; see <a href="https://github.com/apache/james-project/tree/master/server/app/src/main/resources/mailetcontainer.xml">examples</a>.</li>
     </ul>
 
     <subsection name="AntiSpam SMTP Hooks">

http://git-wip-us.apache.org/repos/asf/james-project/blob/975fcf12/src/site/xdoc/server/config-cassandra.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/server/config-cassandra.xml b/src/site/xdoc/server/config-cassandra.xml
index 2534ceb..6b9bf24 100644
--- a/src/site/xdoc/server/config-cassandra.xml
+++ b/src/site/xdoc/server/config-cassandra.xml
@@ -29,7 +29,7 @@
 
     Note: Cassandra is only available with Guice wiring (cassandra-guice and cassandra-guice-ldap).
 
-    <p>Consult <a href="https://github.com/apache/james-project/blob/master/dockerfiles/run/guice/cassandra/destination/conf/cassandra.properties">cassandra-template.properties</a> to get some examples and hints.</p>
+    <p>Consult <a href="https://github.com/apache/james-project/blob/master/dockerfiles/run/guice/cassandra/destination/conf/cassandra.properties">cassandra.properties</a> to get some examples and hints.</p>
 
       <dl>
         <dt><strong>cassandra.nodes</strong></dt>

http://git-wip-us.apache.org/repos/asf/james-project/blob/975fcf12/src/site/xdoc/server/config-dnsservice.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/server/config-dnsservice.xml b/src/site/xdoc/server/config-dnsservice.xml
index 5ac1d5b..cd8c3f4 100755
--- a/src/site/xdoc/server/config-dnsservice.xml
+++ b/src/site/xdoc/server/config-dnsservice.xml
@@ -29,7 +29,7 @@
 
     <subsection name="dnsservice.xml">
 
-      <p>Consult <a href="https://github.com/apache/james-project/tree/master/server/app/src/main/resources/dnsservice-template.xml">dnsservice-template.xml</a> in GIT to get some examples and hints.</p>
+      <p>Consult <a href="https://github.com/apache/james-project/tree/master/server/app/src/main/resources/dnsservice.xml">dnsservice.xml</a> in GIT to get some examples and hints.</p>
 
       <p>Specifies DNS Server information for use by various components inside Apache James Server.</p>
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/975fcf12/src/site/xdoc/server/config-domainlist.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/server/config-domainlist.xml b/src/site/xdoc/server/config-domainlist.xml
index 2c46dbe..3682df9 100644
--- a/src/site/xdoc/server/config-domainlist.xml
+++ b/src/site/xdoc/server/config-domainlist.xml
@@ -27,7 +27,7 @@
 
   <section name="DomainList Configuration">
 
-    <p>Consult <a href="https://github.com/apache/james-project/tree/master/server/app/src/main/resources/domainlist-template.xml">domainlist-template.xml</a> in GIT to get some examples and hints.</p>
+    <p>Consult <a href="https://github.com/apache/james-project/tree/master/server/app/src/main/resources/domainlist.xml">domainlist.xml</a> in GIT to get some examples and hints.</p>
     
       <p>This configuration block is defined by the <strong>domainlist</strong> tag.</p>
       

http://git-wip-us.apache.org/repos/asf/james-project/blob/975fcf12/src/site/xdoc/server/config-elasticsearch.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/server/config-elasticsearch.xml b/src/site/xdoc/server/config-elasticsearch.xml
index accb7f0..c554e4c 100644
--- a/src/site/xdoc/server/config-elasticsearch.xml
+++ b/src/site/xdoc/server/config-elasticsearch.xml
@@ -29,7 +29,7 @@
 
       This configuration applies only to Guice wiring.
 
-    <p>Consult <a href="https://github.com/apache/james-project/blob/master/dockerfiles/run/guice/cassandra/destination/conf/elasticsearch.properties">elasticsearch-template.properties</a> to get some examples and hints.</p>
+    <p>Consult <a href="https://github.com/apache/james-project/blob/master/dockerfiles/run/guice/cassandra/destination/conf/elasticsearch.properties">elasticsearch.properties</a> to get some examples and hints.</p>
 
       Connection to a cluster :
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/975fcf12/src/site/xdoc/server/config-events.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/server/config-events.xml b/src/site/xdoc/server/config-events.xml
index 92bf0e7..7bc0c48 100644
--- a/src/site/xdoc/server/config-events.xml
+++ b/src/site/xdoc/server/config-events.xml
@@ -29,7 +29,7 @@
 
             This configuration applies only to Spring wiring.
 
-            <p>Consult <a href="https://github.com/apache/james-project/tree/master/server/app/src/main/resources/events-template.xml">events-template.xml</a> in GIT to get some examples and hints.</p>
+            <p>Consult <a href="https://github.com/apache/james-project/tree/master/server/app/src/main/resources/events.xml">events.xml</a> in GIT to get some examples and hints.</p>
 
             <p>Use this configuration to define the type of Event System you want.</p>
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/975fcf12/src/site/xdoc/server/config-fetchmail.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/server/config-fetchmail.xml b/src/site/xdoc/server/config-fetchmail.xml
index c184db1..6feb0b2 100755
--- a/src/site/xdoc/server/config-fetchmail.xml
+++ b/src/site/xdoc/server/config-fetchmail.xml
@@ -29,7 +29,7 @@
 
     This configuration file requires Spring wiring.
 
-    <p>Consult <a href="https://github.com/apache/james-project/tree/master/server/app/src/main/resources/fetchmail-template.xml">fetchmail-template.xml</a> in GIT to get some examples and hints.</p>
+    <p>Consult <a href="https://github.com/apache/james-project/tree/master/server/app/src/main/resources/fetchmail.xml">fetchmail.xml</a> in GIT to get some examples and hints.</p>
 
     <p>Fetchmail acts as a gateway between an external message store such as an IMAP
     or POP3 server and James. Mail is fetched from the external message store and

http://git-wip-us.apache.org/repos/asf/james-project/blob/975fcf12/src/site/xdoc/server/config-guice.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/server/config-guice.xml b/src/site/xdoc/server/config-guice.xml
index f807656..74c2ad9 100644
--- a/src/site/xdoc/server/config-guice.xml
+++ b/src/site/xdoc/server/config-guice.xml
@@ -48,7 +48,7 @@
       </tr>
 
       <tr>
-        <td><a href="https://github.com/apache/james-project/blob/master/dockerfiles/run/guice/cassandra/destination/conf/cassandra.properties">cassandra-template.properties</a></td>
+        <td><a href="https://github.com/apache/james-project/blob/master/dockerfiles/run/guice/cassandra/destination/conf/cassandra.properties">cassandra.properties</a></td>
         <td><a href="config-cassandra.html">Cassandra Configuration</a></td>
         <td></td>
       </tr>
@@ -58,7 +58,7 @@
         <td></td>
       </tr>
       <tr>
-        <td><a href="https://github.com/apache/james-project/blob/master/dockerfiles/run/guice/cassandra/destination/conf/elasticsearch.properties">elasticsearch-template.properties</a></td>
+        <td><a href="https://github.com/apache/james-project/blob/master/dockerfiles/run/guice/cassandra/destination/conf/elasticsearch.properties">elasticsearch.properties</a></td>
         <td><a href="config-elasticsearch.html">ElasticSearch Configuration</a></td>
         <td></td>
       </tr>

http://git-wip-us.apache.org/repos/asf/james-project/blob/975fcf12/src/site/xdoc/server/config-imap4.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/server/config-imap4.xml b/src/site/xdoc/server/config-imap4.xml
index c163590..0348a7d 100644
--- a/src/site/xdoc/server/config-imap4.xml
+++ b/src/site/xdoc/server/config-imap4.xml
@@ -27,7 +27,7 @@
 
 <section name="IMAP4 Configuration">
 
-      <p>Consult <a href="https://github.com/apache/james-project/tree/master/server/app/src/main/resources/imapserver-template.xml">imapserver-template.xml</a> in GIT to get some examples and hints.</p>
+      <p>Consult <a href="https://github.com/apache/james-project/tree/master/server/app/src/main/resources/imapserver.xml">imapserver.xml</a> in GIT to get some examples and hints.</p>
 
     <p>The IMAP4 service is controlled by a configuration block in the imap4server.xml.
        The imap4server tag defines the boundaries of the configuration block.  It encloses 

http://git-wip-us.apache.org/repos/asf/james-project/blob/975fcf12/src/site/xdoc/server/config-mailbox.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/server/config-mailbox.xml b/src/site/xdoc/server/config-mailbox.xml
index 3d18fe0..8db90f0 100644
--- a/src/site/xdoc/server/config-mailbox.xml
+++ b/src/site/xdoc/server/config-mailbox.xml
@@ -29,7 +29,7 @@
 
       This configuration applies only to Spring wiring.
 
-    <p>Consult <a href="https://github.com/apache/james-project/tree/master/server/app/src/main/resources/mailbox-template.xml">mailbox-template.xml</a> in GIT to get some examples and hints.</p>
+    <p>Consult <a href="https://github.com/apache/james-project/tree/master/server/app/src/main/resources/mailbox.xml">mailbox.xml</a> in GIT to get some examples and hints.</p>
     
     <p>Use this configuration to define the type of mailbox storage used to persist the user's mails.</p>
     

http://git-wip-us.apache.org/repos/asf/james-project/blob/975fcf12/src/site/xdoc/server/config-mailetcontainer.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/server/config-mailetcontainer.xml b/src/site/xdoc/server/config-mailetcontainer.xml
index 629da0d..0931327 100644
--- a/src/site/xdoc/server/config-mailetcontainer.xml
+++ b/src/site/xdoc/server/config-mailetcontainer.xml
@@ -34,7 +34,7 @@
 
       <p>Apache James Server includes a number of pre-packaged <a href="dev-provided-mailets.html">Mailets and Matchers</a>.</p>
 
-      <p>Consult <a href="https://github.com/apache/james-project/tree/master/server/app/src/main/resources/mailetcontainer-template.xml">mailetcontainer-template.xml</a> in GIT to get some examples and hints.</p>
+      <p>Consult <a href="https://github.com/apache/james-project/tree/master/server/app/src/main/resources/mailetcontainer.xml">mailetcontainer.xml</a> in GIT to get some examples and hints.</p>
 
       <p>This configuration block is defined by the <strong>mailserver</strong> tag.  All administrators 
       need to adjust the <strong>mailserver</strong> block upon installation.</p>

http://git-wip-us.apache.org/repos/asf/james-project/blob/975fcf12/src/site/xdoc/server/config-mailrepositorystore.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/server/config-mailrepositorystore.xml b/src/site/xdoc/server/config-mailrepositorystore.xml
index 3bf77c3..62e24b5 100644
--- a/src/site/xdoc/server/config-mailrepositorystore.xml
+++ b/src/site/xdoc/server/config-mailrepositorystore.xml
@@ -31,7 +31,7 @@
 
       <p>Read <a href="feature-persistence.html">documentation about persistence</a> for a description of the Mail Repository Store functionality.</p>
     
-      <p>Consult <a href="https://github.com/apache/james-project/tree/master/server/app/src/main/resources/mailrepositorystore-template.xml">mailrepositorystore-template.xml</a> in GIT to get some examples and hints.</p>
+      <p>Consult <a href="https://github.com/apache/james-project/tree/master/server/app/src/main/resources/mailrepositorystore.xml">mailrepositorystore.xml</a> in GIT to get some examples and hints.</p>
 
       <p>Mail Repository Stores are distinguished by where they store data.  There are five types of 
         storage: File, Database, DBFile, MBox and JCR.</p>

http://git-wip-us.apache.org/repos/asf/james-project/blob/975fcf12/src/site/xdoc/server/config-pop3.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/server/config-pop3.xml b/src/site/xdoc/server/config-pop3.xml
index 2c4a89a..7acc82e 100644
--- a/src/site/xdoc/server/config-pop3.xml
+++ b/src/site/xdoc/server/config-pop3.xml
@@ -27,7 +27,7 @@
 
   <section name="POP3 Configuration">
   
-    <p>Consult <a href="https://github.com/apache/james-project/tree/master/server/app/src/main/resources/pop3server-template.xml">pop3server-template.xml</a> in GIT to get some examples and hints.</p>
+    <p>Consult <a href="https://github.com/apache/james-project/tree/master/server/app/src/main/resources/pop3server.xml">pop3server.xml</a> in GIT to get some examples and hints.</p>
 
     <p>The POP3 service is controlled by a configuration block in the pop3server.xml.
        The pop3server tag defines the boundaries of the configuration block.  It encloses 

http://git-wip-us.apache.org/repos/asf/james-project/blob/975fcf12/src/site/xdoc/server/config-quota.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/server/config-quota.xml b/src/site/xdoc/server/config-quota.xml
index 83de100..1198eb0 100644
--- a/src/site/xdoc/server/config-quota.xml
+++ b/src/site/xdoc/server/config-quota.xml
@@ -29,7 +29,7 @@
 
     This configuration applies only to Spring wiring.
 
-    <p>Consult <a href="https://github.com/apache/james-project/tree/master/server/app/src/main/resources/quota-template.xml">quota-template.xml</a> in GIT to get some examples and hints.</p>
+    <p>Consult <a href="https://github.com/apache/james-project/tree/master/server/app/src/main/resources/quota.xml">quota.xml</a> in GIT to get some examples and hints.</p>
     
     <p>Use this configuration to define the type of quota storage used to persist the quotas.</p>
     
@@ -66,7 +66,7 @@
     </p>
 
     <p>
-      To choose the implementation you want for the given components you want simply have a look to the <a href="https://github.com/apache/james-project/tree/master/server/app/src/main/resources/quota-template.xml">quota-template.xml</a> file.
+      To choose the implementation you want for the given components you want simply have a look to the <a href="https://github.com/apache/james-project/tree/master/server/app/src/main/resources/quota.xml">quota.xml</a> file.
     </p>
 
     <p>

http://git-wip-us.apache.org/repos/asf/james-project/blob/975fcf12/src/site/xdoc/server/config-recipientrewritetable.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/server/config-recipientrewritetable.xml b/src/site/xdoc/server/config-recipientrewritetable.xml
index de5e126..b45c75f 100644
--- a/src/site/xdoc/server/config-recipientrewritetable.xml
+++ b/src/site/xdoc/server/config-recipientrewritetable.xml
@@ -27,7 +27,7 @@
 
   <section name="Recipient Rewrite Table Configuration">
 
-    <p>Consult <a href="https://github.com/apache/james-project/tree/master/server/app/src/main/resources/recipientrewritetable-template.xml">recipientrewritetable-template.xml</a> in GIT to get some examples and hints.</p>
+    <p>Consult <a href="https://github.com/apache/james-project/tree/master/server/app/src/main/resources/recipientrewritetable.xml">recipientrewritetable.xml</a> in GIT to get some examples and hints.</p>
 
     <subsection name="JPA Recipient Rewrite Table">
     

http://git-wip-us.apache.org/repos/asf/james-project/blob/975fcf12/src/site/xdoc/server/config-smtp-lmtp.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/server/config-smtp-lmtp.xml b/src/site/xdoc/server/config-smtp-lmtp.xml
index 4991c07..3cf36cc 100644
--- a/src/site/xdoc/server/config-smtp-lmtp.xml
+++ b/src/site/xdoc/server/config-smtp-lmtp.xml
@@ -37,7 +37,7 @@
 
   <section name="SMTP Configuration">
   
-    <p>Consult <a href="https://github.com/apache/james-project/tree/master/server/app/src/main/resources/smtpserver-template.xml">smtpserver-template.xml</a> in GIT to get some examples and hints.</p>
+    <p>Consult <a href="https://github.com/apache/james-project/tree/master/server/app/src/main/resources/smtpserver.xml">smtpserver.xml</a> in GIT to get some examples and hints.</p>
 
     <p>The SMTP service is controlled by a configuration block in the smptserver.xml.
        The smtpserver tag defines the boundaries of the configuration block.  It encloses 
@@ -197,7 +197,7 @@ Correct this.
   
   <section name="LMTP Configuration">
     
-    <p>Consult <a href="https://github.com/apache/james-project/tree/master/server/app/src/main/resources/lmtpserver-template.xml">lmtpserver-template.xml</a> in GIT to get some examples and hints.</p>
+    <p>Consult <a href="https://github.com/apache/james-project/tree/master/server/app/src/main/resources/lmtpserver.xml">lmtpserver.xml</a> in GIT to get some examples and hints.</p>
     
     <p>The configuration is the same of for SMTP.</p>
     

http://git-wip-us.apache.org/repos/asf/james-project/blob/975fcf12/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 08098b7..0c8ca3c 100644
--- a/src/site/xdoc/server/config-system.xml
+++ b/src/site/xdoc/server/config-system.xml
@@ -56,7 +56,7 @@
 
                 <p>This configuration file is only relevant when using JPA, with Spring or Guice.</p>
 
-                <p>Consult <a href="https://github.com/apache/james-project/tree/master/server/app/src/main/resources/james-database-template.properties">james-database.properties</a> in GIT to get some examples and hints.</p>
+                <p>Consult <a href="https://github.com/apache/james-project/tree/master/server/app/src/main/resources/james-database.properties">james.properties</a> in GIT to get some examples and hints.</p>
 
                 <p>The database connection in database.properties</p>
 
@@ -112,7 +112,7 @@
 
             <subsection name="jmx.properties">
 
-                <p>Consult <a href="https://github.com/apache/james-project/tree/master/server/app/src/main/resources/jmx-template.properties">jmx.properties</a> in GIT to get some examples and hints.</p>
+                <p>Consult <a href="https://github.com/apache/james-project/tree/master/server/app/src/main/resources/jmx.properties">jmx.properties</a> in GIT to get some examples and hints.</p>
 
                 <p>This is used to configure the JMX MBean server via which all management is achieved (also used by via the james-cli).</p>
 
@@ -151,7 +151,7 @@
 
             <subsection name="JCR Repository Configuration">
 
-                <p>Consult <a href="https://github.com/apache/james-project/tree/master/server/app/src/main/resources/jcr-repository-template.xml">jcr-repository.xml</a> in GIT to get some examples and hints.</p>
+                <p>Consult <a href="https://github.com/apache/james-project/tree/master/server/app/src/main/resources/jcr-repository.xml">jcr-repository.xml</a> in GIT to get some examples and hints.</p>
 
                 <p>Used to configure the JCR mailbox (if configure in mailbox.xml).</p>
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/975fcf12/src/site/xdoc/server/config-users.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/server/config-users.xml b/src/site/xdoc/server/config-users.xml
index d259725..2b9831c 100644
--- a/src/site/xdoc/server/config-users.xml
+++ b/src/site/xdoc/server/config-users.xml
@@ -31,7 +31,7 @@
   
       <p>User repositories are required to store James user information and authentication data</p>
   
-      <p>Consult <a href="https://github.com/apache/james-project/tree/master/server/app/src/main/resources/usersrepository-template.xml">usersrepository.xml</a> in GIT to get some examples and hints.</p>
+      <p>Consult <a href="https://github.com/apache/james-project/tree/master/server/app/src/main/resources/usersrepository.xml">usersrepository.xml</a> in GIT to get some examples and hints.</p>
       
     </subsection>
     

http://git-wip-us.apache.org/repos/asf/james-project/blob/975fcf12/src/site/xdoc/server/config.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/server/config.xml b/src/site/xdoc/server/config.xml
index 096e94f..00f9dd8 100644
--- a/src/site/xdoc/server/config.xml
+++ b/src/site/xdoc/server/config.xml
@@ -29,10 +29,8 @@
   
     <p>All configuration files resides in the ./conf and ./conf/META-INF folder.</p>
     
-    <p>With default Spring wiring, we ship with default configuration (embedded in jars) and -template files
-       you can use to override the default configuration. Simply copy in conf folder *-template.xml
-       to *.xml (example: smtpserver-template.xml to smtpserver.xml), and change
-       in *.xml the settings to map your needs.</p>
+    <p>With default Spring wiring, we ship with default configuration. It gets automatically deployed in the conf folder while unzipping.
+      Of course, you can change the files *.xml the settings to match your needs.</p>
 
     <p> For Guice based wiring, you are encouraged to take a look at default configuration of the
       <a href="https://github.com/apache/james-project/tree/master/dockerfiles/run/guice">James docker images</a>.</p>
@@ -52,72 +50,72 @@
       </tr>
     
       <tr>
-        <td><a href="https://github.com/apache/james-project/tree/master/server/app/src/main/resources/domainlist-template.xml">domainlist.xml</a></td>
+        <td><a href="https://github.com/apache/james-project/tree/master/server/app/src/main/resources/domainlist.xml">domainlist.xml</a></td>
         <td><a href="config-domainlist.html">Domain List Configuration</a></td>
         <td></td>
       </tr>
       <tr>
-        <td><a href="https://github.com/apache/james-project/tree/master/server/app/src/main/resources/usersrepository-template.xml">usersrepository.xml</a></td>
+        <td><a href="https://github.com/apache/james-project/tree/master/server/app/src/main/resources/usersrepository.xml">usersrepository.xml</a></td>
         <td><a href="config-users.html">Users Configuration</a></td>
         <td></td>
       </tr>
       <tr>
-        <td><a href="https://github.com/apache/james-project/tree/master/server/app/src/main/resources/recipientrewritetable-template.xml">recipientrewritetable.xml</a></td>
+        <td><a href="https://github.com/apache/james-project/tree/master/server/app/src/main/resources/recipientrewritetable.xml">recipientrewritetable.xml</a></td>
         <td><a href="config-recipientrewritetable.html">Recipient Rewrite Table Configuration</a></td>
         <td></td>
       </tr>
       <tr>
-        <td><a href="https://github.com/apache/james-project/tree/master/server/app/src/main/resources/mailbox-template.xml">mailbox.xml</a></td>
+        <td><a href="https://github.com/apache/james-project/tree/master/server/app/src/main/resources/mailbox.xml">mailbox.xml</a></td>
         <td><a href="config-mailbox.html">Mailbox Configuration (Spring only)</a></td>
         <td></td>
       </tr>
       <tr>
-        <td><a href="https://github.com/apache/james-project/tree/master/server/app/src/main/resources/quota-template.xml">mailbox.xml</a></td>
+        <td><a href="https://github.com/apache/james-project/tree/master/server/app/src/main/resources/quota.xml">mailbox.xml</a></td>
         <td><a href="config-quota.html">Quota Configuration (Spring only)</a></td>
         <td></td>
       </tr>
       <tr>
-        <td><a href="https://github.com/apache/james-project/tree/master/server/app/src/main/resources/events-template.xml">events.xml</a></td>
+        <td><a href="https://github.com/apache/james-project/tree/master/server/app/src/main/resources/events.xml">events.xml</a></td>
         <td><a href="config-events.html">Event system Configuration (Spring only)</a></td>
         <td></td>
       </tr>
       <tr>
-        <td><a href="https://github.com/apache/james-project/tree/master/server/app/src/main/resources/mailrepositorystore-template.xml">mailrepositorystore.xml</a></td>
+        <td><a href="https://github.com/apache/james-project/tree/master/server/app/src/main/resources/mailrepositorystore.xml">mailrepositorystore.xml</a></td>
         <td><a href="config-mailrepositorystore.html">Mail Repository Stores Configuration</a></td>
         <td></td>
       </tr>
       <tr>
-        <td><a href="https://github.com/apache/james-project/tree/master/server/app/src/main/resources/dnsservice-template.xml">dnsservice.xml</a></td>
+        <td><a href="https://github.com/apache/james-project/tree/master/server/app/src/main/resources/dnsservice.xml">dnsservice.xml</a></td>
         <td><a href="config-dnsservice.html">DNS Service Configuration</a></td>
         <td></td>
       </tr>
       <tr>
-        <td><a href="https://github.com/apache/james-project/tree/master/server/app/src/main/resources/smtpserver-template.xml">smtpserver.xml</a></td>
+        <td><a href="https://github.com/apache/james-project/tree/master/server/app/src/main/resources/smtpserver.xml">smtpserver.xml</a></td>
         <td><a href="config-smtp-lmtp.html">SMTP Configuration</a></td>
         <td></td>
       </tr>
       <tr>
-        <td><a href="https://github.com/apache/james-project/tree/master/server/app/src/main/resources/lmtpserver-template.xml">lmtpserver.xml</a></td>
+        <td><a href="https://github.com/apache/james-project/tree/master/server/app/src/main/resources/lmtpserver.xml">lmtpserver.xml</a></td>
         <td><a href="config-smtp-lmtp.html">LMTP Configuration</a></td>
         <td></td>
       </tr>
       <tr>
-        <td><a href="https://github.com/apache/james-project/tree/master/server/app/src/main/resources/pop3server-template.xml">pop3server.xml</a></td>
+        <td><a href="https://github.com/apache/james-project/tree/master/server/app/src/main/resources/pop3server.xml">pop3server.xml</a></td>
         <td><a href="config-pop3.html">POP3 Configuration</a></td>
         <td></td>
       </tr>
       <tr>
-        <td><a href="https://github.com/apache/james-project/tree/master/server/app/src/main/resources/imapserver-template.xml">imapserver.xml</a></td>
+        <td><a href="https://github.com/apache/james-project/tree/master/server/app/src/main/resources/imapserver.xml">imapserver.xml</a></td>
         <td><a href="config-imap4.html">IMAP4 Configuration</a></td>
         <td></td>
       </tr>
       <tr>
-        <td><a href="https://github.com/apache/james-project/tree/master/server/app/src/main/resources/mailetcontainer-template.xml">mailetcontainer.xml</a></td>
+        <td><a href="https://github.com/apache/james-project/tree/master/server/app/src/main/resources/mailetcontainer.xml">mailetcontainer.xml</a></td>
         <td><a href="config-mailetcontainer.html">Mailet Container Configuration</a></td>
         <td></td>
       </tr>
       <tr>
-        <td><a href="https://github.com/apache/james-project/tree/master/server/app/src/main/resources/fetchmail-template.xml">fetchmail.xml</a></td>
+        <td><a href="https://github.com/apache/james-project/tree/master/server/app/src/main/resources/fetchmail.xml">fetchmail.xml</a></td>
         <td><a href="config-fetchmail.html">FetchMail Configuration (Spring only)</a></td>
         <td></td>
       </tr>
@@ -140,34 +138,34 @@
         <td></td>
       </tr>
       <tr>
-        <td><a href="https://github.com/apache/james-project/tree/master/server/app/src/main/resources/james-database-template.properties">james-database.properties</a></td>
+        <td><a href="https://github.com/apache/james-project/tree/master/server/app/src/main/resources/james-database.properties">james-database.properties</a></td>
         <td><a href="config-system.html">System Configuration</a></td>
         <td></td>
       </tr>
       <tr>
-        <td><a href="https://github.com/apache/james-project/tree/master/server/app/src/main/resources/META-INF/persistence-template.xml">META-INF/persistence.xml</a></td>
+        <td><a href="https://github.com/apache/james-project/tree/master/server/app/src/main/resources/META-INF/persistence.xml">META-INF/persistence.xml</a></td>
         <td><a href="config-system.html">System Configuration</a></td>
         <td></td>
       </tr>
       <tr>
         <td>
-          <a href="https://github.com/apache/james-project/tree/master/server/app/src/main/resources/jmx-template.properties">jmx.properties</a><br/>
+          <a href="https://github.com/apache/james-project/tree/master/server/app/src/main/resources/jmx.properties">jmx.properties</a><br/>
          </td>
         <td><a href="config-system.html">System Configuration</a></td>
         <td></td>
       </tr>
       <tr>
-        <td><a href="https://github.com/apache/james-project/tree/master/server/app/src/main/resources/log4j-template.properties">log4j.properties</a></td>
+        <td><a href="https://github.com/apache/james-project/tree/master/server/app/src/main/resources/log4j.properties">log4j.properties</a></td>
         <td>See <a href="monitor-logging.html">monitoring with log4j</a> section.</td>
         <td></td>
       </tr>
       <tr>
-        <td><a href="https://github.com/apache/james-project/tree/master/server/app/src/main/resources/sqlResources-template.xml">sqlResources.xml</a></td>
+        <td><a href="https://github.com/apache/james-project/tree/master/server/app/src/main/resources/sqlResources.xml">sqlResources.xml</a></td>
         <td><a href="config-system.html">System Configuration</a></td>
         <td>Deprecated</td>
       </tr>
       <tr>
-        <td><a href="https://github.com/apache/james-project/tree/master/server/app/src/main/resources/jcr-repository-template.xml">jcr-repository.xml</a></td>
+        <td><a href="https://github.com/apache/james-project/tree/master/server/app/src/main/resources/jcr-repository.xml">jcr-repository.xml</a></td>
         <td><a href="config-system.html">System Configuration</a></td>
         <td></td>
       </tr>

http://git-wip-us.apache.org/repos/asf/james-project/blob/975fcf12/src/site/xdoc/server/install.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/server/install.xml b/src/site/xdoc/server/install.xml
index 9b9586c..c0de159 100644
--- a/src/site/xdoc/server/install.xml
+++ b/src/site/xdoc/server/install.xml
@@ -134,11 +134,9 @@
       </div>
   -->
     <p>After unpacking the binary, the next step is to adjust the initial configuration.  
-       All configuration files are embedded in jars. We ship in the conf folder template configuration files.
+       All configuration files are embedded in jars. We ship in the conf folder the configuration files that can be edited to match your needs.
     </p>
-    
-    <p>You can override the default configuration : copy the conf folder any ...-template... you need and update according to your needs.</p>
-    
+
     <p>Additional system files reside under the./conf/META-INF folder.</p>
     
     <p>The out of the box configuration makes certain assumptions and has some default 

http://git-wip-us.apache.org/repos/asf/james-project/blob/975fcf12/src/site/xdoc/server/quick-start.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/server/quick-start.xml b/src/site/xdoc/server/quick-start.xml
index 73e1325..df7a6df 100644
--- a/src/site/xdoc/server/quick-start.xml
+++ b/src/site/xdoc/server/quick-start.xml
@@ -83,9 +83,8 @@ Step 4: Configure
 #################
 
   * All configuration files are embedded in jars.
-  * We ship in the conf folder template configuration files.
-  * You can override the default configuration : 
-      Copy the conf folder any ...-template... you need and update according to your needs.
+  * We ship in the conf folder the configuration files.
+  * You can override the default configuration by editing these files
 
 database.properties
 META-INF/persistence.xml


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


[3/6] james-project git commit: JAMES-2103 Add failing tests for StoreMessageIdManager Quota management

Posted by bt...@apache.org.
JAMES-2103 Add failing tests for StoreMessageIdManager Quota management


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

Branch: refs/heads/master
Commit: 69cef15f708a7caf6dde96b1347e2367ab9d2de4
Parents: 56beed2
Author: benwa <bt...@linagora.com>
Authored: Fri Jul 28 11:23:30 2017 +0700
Committer: benwa <bt...@linagora.com>
Committed: Tue Aug 8 10:39:51 2017 +0700

----------------------------------------------------------------------
 .../CassandraMessageIdManagerQuotaTest.java     |  62 +++++++++
 .../CassandraMessageIdManagerTestSystem.java    |  40 +++++-
 .../cassandra/CassandraTestSystemFixture.java   |  53 +++++--
 .../InMemoryMessageIdManagerTestSystem.java     |   8 +-
 .../AbstractMessageIdManagerQuotaTest.java      | 137 +++++++++++++++++++
 .../store/MessageIdManagerTestSystem.java       |   2 +
 .../store/StoreMessageIdManagerTestSystem.java  |   5 +
 7 files changed, 288 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/69cef15f/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMessageIdManagerQuotaTest.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMessageIdManagerQuotaTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMessageIdManagerQuotaTest.java
new file mode 100644
index 0000000..423af97
--- /dev/null
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMessageIdManagerQuotaTest.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.mailbox.cassandra;
+
+import org.apache.james.mailbox.quota.CurrentQuotaManager;
+import org.apache.james.mailbox.quota.MaxQuotaManager;
+import org.apache.james.mailbox.quota.QuotaManager;
+import org.apache.james.mailbox.store.AbstractMessageIdManagerQuotaTest;
+import org.apache.james.mailbox.store.MessageIdManagerTestSystem;
+import org.apache.james.mailbox.store.quota.StoreQuotaManager;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+
+public class CassandraMessageIdManagerQuotaTest extends AbstractMessageIdManagerQuotaTest {
+
+    @BeforeClass
+    public static void init() {
+        CassandraMessageIdManagerTestSystem.initWithQuota();
+    }
+
+    @AfterClass
+    public static void close() {
+        CassandraMessageIdManagerTestSystem.stop();
+    }
+
+    @Override
+    protected MessageIdManagerTestSystem createTestSystem(QuotaManager quotaManager, CurrentQuotaManager currentQuotaManager) throws Exception {
+        return CassandraMessageIdManagerTestSystem.createTestingDataWithQuota(quotaManager, currentQuotaManager);
+    }
+
+    @Override
+    protected MaxQuotaManager createMaxQuotaManager() {
+        return CassandraTestSystemFixture.createMaxQuotaManager();
+    }
+
+    @Override
+    protected QuotaManager createQuotaManager(MaxQuotaManager maxQuotaManager, CurrentQuotaManager currentQuotaManager) {
+        return new StoreQuotaManager(currentQuotaManager, maxQuotaManager);
+    }
+
+    @Override
+    protected CurrentQuotaManager createCurrentQuotaManager() {
+        return CassandraTestSystemFixture.createCurrentQuotaManager();
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/69cef15f/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMessageIdManagerTestSystem.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMessageIdManagerTestSystem.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMessageIdManagerTestSystem.java
index 73c2b5d..2d4c6c1 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMessageIdManagerTestSystem.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMessageIdManagerTestSystem.java
@@ -32,19 +32,28 @@ import org.apache.james.mailbox.exception.MailboxException;
 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.quota.CurrentQuotaManager;
 import org.apache.james.mailbox.quota.QuotaManager;
 import org.apache.james.mailbox.store.MessageIdManagerTestSystem;
+import org.apache.james.mailbox.store.SimpleMessageMetaData;
 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;
 import org.apache.james.mailbox.store.mail.model.impl.PropertyBuilder;
 import org.apache.james.mailbox.store.mail.model.impl.SimpleMailboxMessage;
+import org.apache.james.mailbox.store.quota.ListeningCurrentQuotaUpdater;
+import org.apache.james.mailbox.store.quota.StoreCurrentQuotaManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import com.google.common.base.Charsets;
 import com.google.common.base.Throwables;
 
 public class CassandraMessageIdManagerTestSystem extends MessageIdManagerTestSystem {
 
+    private static final byte[] MESSAGE_CONTENT = "subject: any\n\nbody".getBytes(Charsets.UTF_8);
+    private static final Logger LOGGER = LoggerFactory.getLogger(CassandraMessageIdManagerTestSystem.class);
+
     public static MessageIdManagerTestSystem createTestingData(QuotaManager quotaManager, MailboxEventDispatcher dispatcher) throws Exception {
         CassandraMailboxSessionMapperFactory mapperFactory = CassandraTestSystemFixture.createMapperFactory();
 
@@ -54,6 +63,20 @@ public class CassandraMessageIdManagerTestSystem extends MessageIdManagerTestSys
             CassandraTestSystemFixture.createMailboxManager(mapperFactory));
     }
 
+    public static MessageIdManagerTestSystem createTestingDataWithQuota(QuotaManager quotaManager, CurrentQuotaManager currentQuotaManager) throws Exception {
+        CassandraMailboxSessionMapperFactory mapperFactory = CassandraTestSystemFixture.createMapperFactory();
+
+        CassandraMailboxManager mailboxManager = CassandraTestSystemFixture.createMailboxManager(mapperFactory);
+        ListeningCurrentQuotaUpdater listeningCurrentQuotaUpdater = new ListeningCurrentQuotaUpdater(
+            (StoreCurrentQuotaManager) currentQuotaManager,
+            mailboxManager.getQuotaRootResolver());
+        mailboxManager.addGlobalListener(listeningCurrentQuotaUpdater, mailboxManager.createSystemSession("System", LOGGER));
+        return new CassandraMessageIdManagerTestSystem(CassandraTestSystemFixture.createMessageIdManager(mapperFactory, quotaManager, mailboxManager.getEventDispatcher()),
+            new CassandraMessageId.Factory(),
+            mapperFactory,
+            mailboxManager);
+    }
+
     private final CassandraMessageId.Factory messageIdFactory;
     private final CassandraMailboxSessionMapperFactory mapperFactory;
     private final CassandraMailboxManager cassandraMailboxManager;
@@ -76,7 +99,9 @@ public class CassandraMessageIdManagerTestSystem extends MessageIdManagerTestSys
         try {
             CassandraMessageId messageId = messageIdFactory.generate();
             Mailbox mailbox = mapperFactory.getMailboxMapper(mailboxSession).findMailboxById(mailboxId);
-            mapperFactory.getMessageMapper(mailboxSession).add(mailbox, createMessage(mailboxId, flags, messageId, uid));
+            MailboxMessage message = createMessage(mailboxId, flags, messageId, uid);
+            mapperFactory.getMessageMapper(mailboxSession).add(mailbox, message);
+            cassandraMailboxManager.getEventDispatcher().added(mailboxSession, new SimpleMessageMetaData(message), mailbox);
             return messageId;
         } catch (Exception e) {
             throw Throwables.propagate(e);
@@ -104,8 +129,8 @@ public class CassandraMessageIdManagerTestSystem extends MessageIdManagerTestSys
     }
 
     private static MailboxMessage createMessage(MailboxId mailboxId, Flags flags, MessageId messageId, MessageUid uid) {
-        MailboxMessage mailboxMessage = new SimpleMailboxMessage(messageId, new Date(), 1596, 1256,
-            new SharedByteArrayInputStream("subject: any\n\nbody".getBytes(Charsets.UTF_8)), flags, new PropertyBuilder(), mailboxId);
+        MailboxMessage mailboxMessage = new SimpleMailboxMessage(messageId, new Date(), MESSAGE_CONTENT.length, 1256,
+            new SharedByteArrayInputStream(MESSAGE_CONTENT), flags, new PropertyBuilder(), mailboxId);
         mailboxMessage.setModSeq(CassandraTestSystemFixture.MOD_SEQ);
         mailboxMessage.setUid(uid);
         return mailboxMessage;
@@ -115,9 +140,16 @@ public class CassandraMessageIdManagerTestSystem extends MessageIdManagerTestSys
         CassandraTestSystemFixture.init();
     }
 
+    public static void initWithQuota() {
+        CassandraTestSystemFixture.initWithQuota();
+    }
+
     public static void stop() {
         CassandraTestSystemFixture.stop();
     }
 
-
+    @Override
+    public int getConstantMessageSize() {
+        return MESSAGE_CONTENT.length;
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/james-project/blob/69cef15f/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraTestSystemFixture.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraTestSystemFixture.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraTestSystemFixture.java
index de5c0ad..8e1a5bd 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraTestSystemFixture.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraTestSystemFixture.java
@@ -50,7 +50,12 @@ import org.apache.james.mailbox.cassandra.modules.CassandraMailboxModule;
 import org.apache.james.mailbox.cassandra.modules.CassandraMailboxRecentsModule;
 import org.apache.james.mailbox.cassandra.modules.CassandraMessageModule;
 import org.apache.james.mailbox.cassandra.modules.CassandraModSeqModule;
+import org.apache.james.mailbox.cassandra.modules.CassandraQuotaModule;
 import org.apache.james.mailbox.cassandra.modules.CassandraUidModule;
+import org.apache.james.mailbox.cassandra.quota.CassandraCurrentQuotaManager;
+import org.apache.james.mailbox.cassandra.quota.CassandraPerUserMaxQuotaManager;
+import org.apache.james.mailbox.quota.CurrentQuotaManager;
+import org.apache.james.mailbox.quota.MaxQuotaManager;
 import org.apache.james.mailbox.quota.QuotaManager;
 import org.apache.james.mailbox.store.Authenticator;
 import org.apache.james.mailbox.store.Authorizator;
@@ -59,10 +64,25 @@ import org.apache.james.mailbox.store.StoreMessageIdManager;
 import org.apache.james.mailbox.store.event.MailboxEventDispatcher;
 import org.apache.james.mailbox.store.mail.model.impl.MessageParser;
 import org.apache.james.mailbox.store.quota.DefaultQuotaRootResolver;
+import org.apache.james.mailbox.store.quota.StoreQuotaManager;
 
 public class CassandraTestSystemFixture {
     
     public static final int MOD_SEQ = 452;
+    public static final CassandraModuleComposite BASE_MAILBOX_MODULES = new CassandraModuleComposite(
+        new CassandraAclModule(),
+        new CassandraMailboxModule(),
+        new CassandraMessageModule(),
+        new CassandraBlobModule(),
+        new CassandraMailboxCounterModule(),
+        new CassandraMailboxRecentsModule(),
+        new CassandraFirstUnseenModule(),
+        new CassandraDeletedMessageModule(),
+        new CassandraUidModule(),
+        new CassandraModSeqModule(),
+        new CassandraAttachmentModule(),
+        new CassandraAnnotationModule(),
+        new CassandraApplicableFlagsModule());
     private static CassandraCluster cassandra;
     
     public static CassandraMailboxSessionMapperFactory createMapperFactory() {
@@ -115,26 +135,31 @@ public class CassandraTestSystemFixture {
             new DefaultQuotaRootResolver(mapperFactory));
     }
 
+    public static MaxQuotaManager createMaxQuotaManager() {
+        return new CassandraPerUserMaxQuotaManager(cassandra.getConf());
+    }
+
+    public static CurrentQuotaManager createCurrentQuotaManager() {
+        return new CassandraCurrentQuotaManager(cassandra.getConf());
+    }
+
+    public static QuotaManager createQuotaManager(MaxQuotaManager maxQuotaManager) {
+        return new StoreQuotaManager(new CassandraCurrentQuotaManager(cassandra.getConf()), maxQuotaManager);
+    }
+
     public static void clean() {
         cassandra.clearAllTables();
     }
 
     public static void init() {
+        cassandra = CassandraCluster.create(BASE_MAILBOX_MODULES);
+    }
+
+    public static void initWithQuota() {
         cassandra = CassandraCluster.create(
-                new CassandraModuleComposite(
-                    new CassandraAclModule(),
-                    new CassandraMailboxModule(),
-                    new CassandraMessageModule(),
-                    new CassandraBlobModule(),
-                    new CassandraMailboxCounterModule(),
-                    new CassandraMailboxRecentsModule(),
-                    new CassandraFirstUnseenModule(),
-                    new CassandraDeletedMessageModule(),
-                    new CassandraUidModule(),
-                    new CassandraModSeqModule(),
-                    new CassandraAttachmentModule(),
-                    new CassandraAnnotationModule(),
-                    new CassandraApplicableFlagsModule()));
+            new CassandraModuleComposite(
+                BASE_MAILBOX_MODULES,
+                new CassandraQuotaModule()));
     }
 
     public static void stop() {

http://git-wip-us.apache.org/repos/asf/james-project/blob/69cef15f/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/InMemoryMessageIdManagerTestSystem.java
----------------------------------------------------------------------
diff --git a/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/InMemoryMessageIdManagerTestSystem.java b/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/InMemoryMessageIdManagerTestSystem.java
index 649f6cb..1bd6068 100644
--- a/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/InMemoryMessageIdManagerTestSystem.java
+++ b/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/InMemoryMessageIdManagerTestSystem.java
@@ -37,6 +37,7 @@ import org.apache.james.mailbox.store.MessageIdManagerTestSystem;
 import org.apache.james.mailbox.store.mail.model.Mailbox;
 import org.apache.james.mailbox.store.mail.model.impl.SimpleMailbox;
 
+import com.google.common.base.Charsets;
 import com.google.common.base.Optional;
 import com.google.common.base.Predicate;
 import com.google.common.base.Throwables;
@@ -47,6 +48,7 @@ public class InMemoryMessageIdManagerTestSystem extends MessageIdManagerTestSyst
     private static final MessageId FIRST_MESSAGE_ID = InMemoryMessageId.of(1);
     private static final long ONE_HUNDRED = 100;
     private static final int UID_VALIDITY = 1024;
+    public static final byte[] CONTENT = "Subject: test\r\n\r\ntestmail".getBytes(Charsets.UTF_8);
 
     private final MailboxManager mailboxManager;
     private Optional<MessageId> lastMessageIdUsed;
@@ -68,7 +70,7 @@ public class InMemoryMessageIdManagerTestSystem extends MessageIdManagerTestSyst
     public MessageId persist(MailboxId mailboxId, MessageUid uid, Flags flags, MailboxSession session) {
         try {
             MessageManager messageManager = mailboxManager.getMailbox(mailboxId, session);
-            MessageId messageId = messageManager.appendMessage(new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(), session, false, flags)
+            MessageId messageId = messageManager.appendMessage(new ByteArrayInputStream(CONTENT), new Date(), session, false, flags)
                     .getMessageId();
             lastMessageIdUsed = Optional.of(messageId);
             return messageId;
@@ -112,4 +114,8 @@ public class InMemoryMessageIdManagerTestSystem extends MessageIdManagerTestSyst
 
     }
 
+    @Override
+    public int getConstantMessageSize() {
+        return CONTENT.length;
+    }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/69cef15f/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
new file mode 100644
index 0000000..bfc59d6
--- /dev/null
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/AbstractMessageIdManagerQuotaTest.java
@@ -0,0 +1,137 @@
+/****************************************************************
+ * 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.store;
+
+import javax.mail.Flags;
+
+import org.apache.james.mailbox.MailboxSession;
+import org.apache.james.mailbox.MessageIdManager;
+import org.apache.james.mailbox.MessageUid;
+import org.apache.james.mailbox.exception.OverQuotaException;
+import org.apache.james.mailbox.manager.MailboxManagerFixture;
+import org.apache.james.mailbox.mock.MockMailboxSession;
+import org.apache.james.mailbox.model.MailboxPath;
+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.QuotaManager;
+import org.apache.james.mailbox.store.mail.model.Mailbox;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+
+import com.google.common.collect.ImmutableList;
+
+public abstract class AbstractMessageIdManagerQuotaTest {
+    private static final MessageUid messageUid1 = MessageUid.of(111);
+
+    public static final Flags FLAGS = new Flags();
+
+    @Rule
+    public ExpectedException expectedException = ExpectedException.none();
+
+    private MessageIdManager messageIdManager;
+    private MailboxSession session;
+    private Mailbox mailbox1;
+    private Mailbox mailbox2;
+    private Mailbox mailbox3;
+    private MessageIdManagerTestSystem testingData;
+    private MaxQuotaManager maxQuotaManager;
+
+    protected abstract MessageIdManagerTestSystem createTestSystem(QuotaManager quotaManager, CurrentQuotaManager currentQuotaManager) throws Exception;
+
+    protected abstract MaxQuotaManager createMaxQuotaManager();
+    protected abstract CurrentQuotaManager createCurrentQuotaManager();
+    protected abstract QuotaManager createQuotaManager(MaxQuotaManager maxQuotaManager, CurrentQuotaManager currentQuotaManager);
+
+    @Before
+    public void setUp() throws Exception {
+        maxQuotaManager = createMaxQuotaManager();
+        CurrentQuotaManager currentQuotaManager = createCurrentQuotaManager();
+        QuotaManager quotaManager = createQuotaManager(maxQuotaManager, currentQuotaManager);
+
+        session = new MockMailboxSession("user");
+        testingData = createTestSystem(quotaManager, currentQuotaManager);
+        messageIdManager = testingData.getMessageIdManager();
+
+        mailbox1 = testingData.createMailbox(MailboxManagerFixture.MAILBOX_PATH1, session);
+        mailbox2 = testingData.createMailbox(MailboxManagerFixture.MAILBOX_PATH2, session);
+        mailbox3 = testingData.createMailbox(MailboxManagerFixture.MAILBOX_PATH3, session);
+    }
+
+    @After
+    public void tearDown() {
+        testingData.clean();
+    }
+
+    @Test
+    public void setInMailboxesShouldNotThrowWhenMessageQuotaNotExceeded() throws Exception {
+        maxQuotaManager.setDefaultMaxMessage(1);
+
+        MessageId messageId = testingData.persist(mailbox2.getMailboxId(), messageUid1, FLAGS, session);
+
+        messageIdManager.setInMailboxes(messageId, ImmutableList.of(mailbox1.getMailboxId()), session);
+    }
+
+    @Test
+    public void setInMailboxesShouldNotThrowWhenStorageQuotaNotExceeded() throws Exception {
+        maxQuotaManager.setDefaultMaxStorage(testingData.getConstantMessageSize());
+
+        MessageId messageId = testingData.persist(mailbox2.getMailboxId(), messageUid1, FLAGS, session);
+
+        messageIdManager.setInMailboxes(messageId, ImmutableList.of(mailbox1.getMailboxId()), session);
+    }
+
+    @Test
+    public void setInMailboxesShouldThrowWhenStorageQuotaExceeded() throws Exception {
+        maxQuotaManager.setDefaultMaxStorage(2 * testingData.getConstantMessageSize());
+
+        testingData.persist(mailbox1.getMailboxId(), messageUid1, FLAGS, session);
+        MessageId messageId = testingData.persist(mailbox2.getMailboxId(), messageUid1, FLAGS, session);
+
+        expectedException.expect(OverQuotaException.class);
+        messageIdManager.setInMailboxes(messageId, ImmutableList.of(mailbox1.getMailboxId(), mailbox2.getMailboxId()), session);
+    }
+
+    @Ignore
+    @Test
+    public void setInMailboxesShouldThrowWhenStorageQuotaExceededWhenCopiedToMultipleMailboxes() throws Exception {
+        maxQuotaManager.setDefaultMaxStorage(2 * testingData.getConstantMessageSize());
+
+        MessageId messageId = testingData.persist(mailbox1.getMailboxId(), messageUid1, FLAGS, session);
+
+        expectedException.expect(OverQuotaException.class);
+        messageIdManager.setInMailboxes(messageId, ImmutableList.of(mailbox1.getMailboxId(), mailbox2.getMailboxId(), mailbox3.getMailboxId()), session);
+    }
+
+    @Test
+    public void setInMailboxesShouldThrowWhenStorageMessageExceeded() throws Exception {
+        maxQuotaManager.setDefaultMaxMessage(2);
+
+        testingData.persist(mailbox1.getMailboxId(), messageUid1, FLAGS, session);
+        MessageId messageId = testingData.persist(mailbox2.getMailboxId(), messageUid1, FLAGS, session);
+
+        expectedException.expect(OverQuotaException.class);
+        messageIdManager.setInMailboxes(messageId, ImmutableList.of(mailbox1.getMailboxId(), mailbox2.getMailboxId(), mailbox3.getMailboxId()), session);
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/69cef15f/mailbox/store/src/test/java/org/apache/james/mailbox/store/MessageIdManagerTestSystem.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/MessageIdManagerTestSystem.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/MessageIdManagerTestSystem.java
index eeae592..ecb45d8e 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/MessageIdManagerTestSystem.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/MessageIdManagerTestSystem.java
@@ -61,4 +61,6 @@ public abstract class MessageIdManagerTestSystem {
     public abstract void deleteMailbox(MailboxId mailboxId, MailboxSession session);
 
     public abstract void clean();
+
+    public abstract int getConstantMessageSize();
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/69cef15f/mailbox/store/src/test/java/org/apache/james/mailbox/store/StoreMessageIdManagerTestSystem.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/StoreMessageIdManagerTestSystem.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/StoreMessageIdManagerTestSystem.java
index 90883fc..2f68685 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/StoreMessageIdManagerTestSystem.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/StoreMessageIdManagerTestSystem.java
@@ -104,4 +104,9 @@ public class StoreMessageIdManagerTestSystem extends MessageIdManagerTestSystem
         when(mailboxMessage.createFlags()).thenReturn(flags);
         return mailboxMessage;
     }
+
+    @Override
+    public int getConstantMessageSize() {
+        throw new NotImplementedException();
+    }
 }


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


[5/6] james-project git commit: JAMES-2106 JMAP support sort by subject, from, to and size

Posted by bt...@apache.org.
JAMES-2106 JMAP support sort by subject, from, to and size


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

Branch: refs/heads/master
Commit: a3dced9c203db1bf06321afd4b640eebe5dd38ae
Parents: 533af6a
Author: quynhn <qn...@linagora.com>
Authored: Mon Jul 31 16:41:58 2017 +0700
Committer: benwa <bt...@linagora.com>
Committed: Tue Aug 8 10:40:42 2017 +0700

----------------------------------------------------------------------
 .../integration/GetMessageListMethodTest.java   | 226 +++++++++++++++++++
 .../apache/james/jmap/utils/SortConverter.java  |  12 +-
 .../james/jmap/utils/SortConverterTest.java     |  24 ++
 3 files changed, 259 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/a3dced9c/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMessageListMethodTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMessageListMethodTest.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMessageListMethodTest.java
index 562e1ea..06bf60b 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMessageListMethodTest.java
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMessageListMethodTest.java
@@ -847,6 +847,232 @@ public abstract class GetMessageListMethodTest {
             .body(ARGUMENTS + ".messageIds", contains(message1.getMessageId().serialize(), message2.getMessageId().serialize()));
     }
 
+    @Test
+    public void getMessageListShouldSortMessagesWhenSortedBySubjectAsc() throws Exception {
+        mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");
+
+        LocalDate date = LocalDate.now();
+        ComposedMessageId message1 = mailboxProbe.appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+                new ByteArrayInputStream("Date: Fri, 02 Jun 2017 13:54:59 +0200\r\nSubject: a subject\r\n\r\ntestmail".getBytes()), convertToDate(date), false, new Flags());
+        ComposedMessageId message2 = mailboxProbe.appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+                new ByteArrayInputStream("Date: Fri, 02 Jun 2017 14:54:59 +0200\r\nSubject: b subject\r\n\r\ntestmail".getBytes()), convertToDate(date), false, new Flags());
+        await();
+
+        given()
+            .header("Authorization", accessToken.serialize())
+            .body("[[\"getMessageList\", {\"sort\":[\"subject asc\"]}, \"#0\"]]")
+        .when()
+            .post("/jmap")
+        .then()
+            .statusCode(200)
+            .body(NAME, equalTo("messageList"))
+            .body(ARGUMENTS + ".messageIds", contains(message1.getMessageId().serialize(), message2.getMessageId().serialize()));
+    }
+
+    @Test
+    public void getMessageListShouldSortMessagesWhenSortedBySubjectDesc() throws Exception {
+        mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");
+
+        LocalDate date = LocalDate.now();
+        ComposedMessageId message1 = mailboxProbe.appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+                new ByteArrayInputStream("Date: Fri, 02 Jun 2017 13:54:59 +0200\r\nSubject: a subject\r\n\r\ntestmail".getBytes()), convertToDate(date), false, new Flags());
+        ComposedMessageId message2 = mailboxProbe.appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+                new ByteArrayInputStream("Date: Fri, 02 Jun 2017 14:54:59 +0200\r\nSubject: b subject\r\n\r\ntestmail".getBytes()), convertToDate(date), false, new Flags());
+        await();
+
+        given()
+            .header("Authorization", accessToken.serialize())
+            .body("[[\"getMessageList\", {\"sort\":[\"subject desc\"]}, \"#0\"]]")
+        .when()
+            .post("/jmap")
+        .then()
+            .statusCode(200)
+            .body(NAME, equalTo("messageList"))
+            .body(ARGUMENTS + ".messageIds", contains(message2.getMessageId().serialize(), message1.getMessageId().serialize()));
+    }
+
+    @Test
+    public void getMessageListShouldSortMessagesWhenSortedByFromAsc() throws Exception {
+        mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");
+
+        LocalDate date = LocalDate.now();
+        ComposedMessageId message1 = mailboxProbe.appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+                new ByteArrayInputStream("Date: Fri, 02 Jun 2017 13:54:59 +0200\r\nSubject: subject\r\nFrom: bbb\r\n\r\ntestmail".getBytes()), convertToDate(date), false, new Flags());
+        ComposedMessageId message2 = mailboxProbe.appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+                new ByteArrayInputStream("Date: Fri, 02 Jun 2017 14:54:59 +0200\r\nSubject: subject\r\nFrom: aaa\r\n\r\ntestmail".getBytes()), convertToDate(date), false, new Flags());
+        await();
+
+        given()
+            .header("Authorization", accessToken.serialize())
+            .body("[[\"getMessageList\", {\"sort\":[\"from asc\"]}, \"#0\"]]")
+        .when()
+            .post("/jmap")
+        .then()
+            .statusCode(200)
+            .body(NAME, equalTo("messageList"))
+            .body(ARGUMENTS + ".messageIds", contains(message2.getMessageId().serialize(), message1.getMessageId().serialize()));
+    }
+
+    @Test
+    public void getMessageListShouldSortMessagesWhenSortedByFromDesc() throws Exception {
+        mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");
+
+        LocalDate date = LocalDate.now();
+        ComposedMessageId message1 = mailboxProbe.appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+                new ByteArrayInputStream("Date: Fri, 02 Jun 2017 13:54:59 +0200\r\nSubject: subject\r\nFrom: aaa\r\n\r\ntestmail".getBytes()), convertToDate(date), false, new Flags());
+        ComposedMessageId message2 = mailboxProbe.appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+                new ByteArrayInputStream("Date: Fri, 02 Jun 2017 14:54:59 +0200\r\nSubject: subject\r\nFrom: bbb\r\n\r\ntestmail".getBytes()), convertToDate(date), false, new Flags());
+        await();
+
+        given()
+            .header("Authorization", accessToken.serialize())
+            .body("[[\"getMessageList\", {\"sort\":[\"from desc\"]}, \"#0\"]]")
+        .when()
+            .post("/jmap")
+        .then()
+            .statusCode(200)
+            .body(NAME, equalTo("messageList"))
+            .body(ARGUMENTS + ".messageIds", contains(message2.getMessageId().serialize(), message1.getMessageId().serialize()));
+    }
+
+    @Test
+    public void getMessageListShouldSortMessagesWhenSortedByToAsc() throws Exception {
+        mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");
+
+        LocalDate date = LocalDate.now();
+        ComposedMessageId message1 = mailboxProbe.appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+                new ByteArrayInputStream("Date: Fri, 02 Jun 2017 13:54:59 +0200\r\nSubject: subject\r\nTo: bbb\r\n\r\ntestmail".getBytes()), convertToDate(date), false, new Flags());
+        ComposedMessageId message2 = mailboxProbe.appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+                new ByteArrayInputStream("Date: Fri, 02 Jun 2017 14:54:59 +0200\r\nSubject: subject\r\nTo: aaa\r\n\r\ntestmail".getBytes()), convertToDate(date), false, new Flags());
+        await();
+
+        given()
+            .header("Authorization", accessToken.serialize())
+            .body("[[\"getMessageList\", {\"sort\":[\"to asc\"]}, \"#0\"]]")
+        .when()
+            .post("/jmap")
+        .then()
+            .statusCode(200)
+            .body(NAME, equalTo("messageList"))
+            .body(ARGUMENTS + ".messageIds", contains(message2.getMessageId().serialize(), message1.getMessageId().serialize()));
+    }
+
+    @Test
+    public void getMessageListShouldSortMessagesWhenSortedByToDesc() throws Exception {
+        mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");
+
+        LocalDate date = LocalDate.now();
+        ComposedMessageId message1 = mailboxProbe.appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+                new ByteArrayInputStream("Date: Fri, 02 Jun 2017 13:54:59 +0200\r\nSubject: subject\r\nTo: aaa\r\n\r\ntestmail".getBytes()), convertToDate(date), false, new Flags());
+        ComposedMessageId message2 = mailboxProbe.appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+                new ByteArrayInputStream("Date: Fri, 02 Jun 2017 14:54:59 +0200\r\nSubject: subject\r\nTo: bbb\r\n\r\ntestmail".getBytes()), convertToDate(date), false, new Flags());
+        await();
+
+        given()
+            .header("Authorization", accessToken.serialize())
+            .body("[[\"getMessageList\", {\"sort\":[\"to desc\"]}, \"#0\"]]")
+        .when()
+            .post("/jmap")
+        .then()
+            .statusCode(200)
+            .body(NAME, equalTo("messageList"))
+            .body(ARGUMENTS + ".messageIds", contains(message2.getMessageId().serialize(), message1.getMessageId().serialize()));
+    }
+
+
+    @Test
+    public void getMessageListShouldSortMessagesWhenSortedBySizeAsc() throws Exception {
+        mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");
+
+        LocalDate date = LocalDate.now();
+        ComposedMessageId message1 = mailboxProbe.appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+                new ByteArrayInputStream("Date: Fri, 02 Jun 2017 13:54:59 +0200\r\nSubject: subject\r\n\r\ntestmail".getBytes()), convertToDate(date), false, new Flags());
+        ComposedMessageId message2 = mailboxProbe.appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+                new ByteArrayInputStream("Date: Fri, 02 Jun 2017 14:54:59 +0200\r\nSubject: subject\r\n\r\ntestmail bigger".getBytes()), convertToDate(date), false, new Flags());
+        await();
+
+        given()
+            .header("Authorization", accessToken.serialize())
+            .body("[[\"getMessageList\", {\"sort\":[\"size asc\"]}, \"#0\"]]")
+        .when()
+            .post("/jmap")
+        .then()
+            .statusCode(200)
+            .body(NAME, equalTo("messageList"))
+            .body(ARGUMENTS + ".messageIds", contains(message1.getMessageId().serialize(), message2.getMessageId().serialize()));
+    }
+
+    @Test
+    public void getMessageListShouldSortMessagesWhenSortedBySizeDesc() throws Exception {
+        mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");
+
+        LocalDate date = LocalDate.now();
+        ComposedMessageId message1 = mailboxProbe.appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+                new ByteArrayInputStream("Date: Fri, 02 Jun 2017 13:54:59 +0200\r\nSubject: subject\r\n\r\ntestmail".getBytes()), convertToDate(date), false, new Flags());
+        ComposedMessageId message2 = mailboxProbe.appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+                new ByteArrayInputStream("Date: Fri, 02 Jun 2017 14:54:59 +0200\r\nSubject: subject\r\n\r\ntestmail bigger".getBytes()), convertToDate(date), false, new Flags());
+        await();
+
+        given()
+            .header("Authorization", accessToken.serialize())
+            .body("[[\"getMessageList\", {\"sort\":[\"size desc\"]}, \"#0\"]]")
+        .when()
+            .post("/jmap")
+        .then()
+            .statusCode(200)
+            .body(NAME, equalTo("messageList"))
+            .body(ARGUMENTS + ".messageIds", contains(message2.getMessageId().serialize(), message1.getMessageId().serialize()));
+    }
+
+    @Test
+    public void getMessageListShouldSortMessagesWhenSortedBySizeAndDateAsc() throws Exception {
+        mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");
+
+        LocalDate date = LocalDate.now();
+        ComposedMessageId message1 = mailboxProbe.appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+                new ByteArrayInputStream("Date: Fri, 02 Jun 2017 13:54:59 +0200\r\nSubject: test\r\n\r\ntestmail really bigger".getBytes()), convertToDate(date.plusDays(1)), false, new Flags());
+        ComposedMessageId message2 = mailboxProbe.appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+                new ByteArrayInputStream("Date: Fri, 02 Jun 2017 14:54:59 +0200\r\nSubject: test\r\n\r\ntestmail smaller".getBytes()), convertToDate(date), false, new Flags());
+        ComposedMessageId message3 = mailboxProbe.appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+                new ByteArrayInputStream("Date: Fri, 02 Jun 2017 15:54:59 +0200\r\nSubject: test\r\n\r\ntestmail really bigger".getBytes()), convertToDate(date.plusDays(1)), false, new Flags());
+
+        await();
+
+        given()
+            .header("Authorization", accessToken.serialize())
+            .body("[[\"getMessageList\", {\"sort\":[\"size asc\", \"date desc\"]}, \"#0\"]]")
+        .when()
+            .post("/jmap")
+        .then()
+            .statusCode(200)
+            .body(NAME, equalTo("messageList"))
+            .body(ARGUMENTS + ".messageIds", contains(message2.getMessageId().serialize(), message3.getMessageId().serialize(), message1.getMessageId().serialize()));
+    }
+
+    @Test
+    public void getMessageListShouldSortMessagesWhenSortedByDateAndSizeAsc() throws Exception {
+        mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");
+
+        LocalDate date = LocalDate.now();
+        ComposedMessageId message1 = mailboxProbe.appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+                new ByteArrayInputStream("Date: Fri, 02 Jun 2017 13:54:59 +0200\r\nSubject: test\r\n\r\ntestmail really bigger".getBytes()), convertToDate(date), false, new Flags());
+        ComposedMessageId message2 = mailboxProbe.appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+                new ByteArrayInputStream("Date: Fri, 02 Jun 2017 13:54:59 +0200\r\nSubject: test\r\n\r\ntestmail smaller".getBytes()), convertToDate(date), false, new Flags());
+        ComposedMessageId message3 = mailboxProbe.appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+                new ByteArrayInputStream("Date: Fri, 02 Jun 2017 15:54:59 +0200\r\nSubject: test\r\n\r\ntestmail really bigger".getBytes()), convertToDate(date), false, new Flags());
+
+        await();
+
+        given()
+            .header("Authorization", accessToken.serialize())
+            .body("[[\"getMessageList\", {\"sort\":[\"date desc\", \"size asc\"]}, \"#0\"]]")
+        .when()
+            .post("/jmap")
+        .then()
+            .statusCode(200)
+            .body(NAME, equalTo("messageList"))
+            .body(ARGUMENTS + ".messageIds", contains(message3.getMessageId().serialize(), message2.getMessageId().serialize(), message1.getMessageId().serialize()));
+    }
 
     @Test
     public void getMessageListShouldSupportIdSorting() throws Exception {

http://git-wip-us.apache.org/repos/asf/james-project/blob/a3dced9c/server/protocols/jmap/src/main/java/org/apache/james/jmap/utils/SortConverter.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/utils/SortConverter.java b/server/protocols/jmap/src/main/java/org/apache/james/jmap/utils/SortConverter.java
index 5d5daac..76b72e8 100644
--- a/server/protocols/jmap/src/main/java/org/apache/james/jmap/utils/SortConverter.java
+++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/utils/SortConverter.java
@@ -38,9 +38,15 @@ public class SortConverter {
     private static final String DESC_ORDERING = "desc";
     private static final String ASC_ORDERING = "asc";
 
-    private static final Map<String, SortClause> SORT_CLAUSE_MAP = ImmutableMap.of(
-        "date", SortClause.SentDate,
-        "id", SortClause.Id);
+    private static final Map<String, SortClause> SORT_CLAUSE_MAP =
+        ImmutableMap.<String, SortClause>builder()
+            .put("date", SortClause.SentDate)
+            .put("id", SortClause.Id)
+            .put("subject", SortClause.BaseSubject)
+            .put("from", SortClause.MailboxFrom)
+            .put("to", SortClause.MailboxTo)
+            .put("size", SortClause.Size)
+            .build();
 
 
     public static List<Sort> convertToSorts(List<String> jmapSorts) {

http://git-wip-us.apache.org/repos/asf/james-project/blob/a3dced9c/server/protocols/jmap/src/test/java/org/apache/james/jmap/utils/SortConverterTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/utils/SortConverterTest.java b/server/protocols/jmap/src/test/java/org/apache/james/jmap/utils/SortConverterTest.java
index af0686c..bb1af24 100644
--- a/server/protocols/jmap/src/test/java/org/apache/james/jmap/utils/SortConverterTest.java
+++ b/server/protocols/jmap/src/test/java/org/apache/james/jmap/utils/SortConverterTest.java
@@ -111,4 +111,28 @@ public class SortConverterTest {
             .containsExactly(new Sort(SortClause.SentDate, Order.NATURAL),
                 new Sort(SortClause.Id, Order.REVERSE));
     }
+
+    @Test
+    public void convertToSortsShouldSupportSubject() {
+        assertThat(SortConverter.convertToSorts(ImmutableList.of("subject desc")))
+                .containsExactly(new Sort(SortClause.BaseSubject, Order.REVERSE));
+    }
+
+    @Test
+    public void convertToSortsShouldSupportFrom() {
+        assertThat(SortConverter.convertToSorts(ImmutableList.of("from desc")))
+                .containsExactly(new Sort(SortClause.MailboxFrom, Order.REVERSE));
+    }
+
+    @Test
+    public void convertToSortsShouldSupportTo() {
+        assertThat(SortConverter.convertToSorts(ImmutableList.of("to desc")))
+                .containsExactly(new Sort(SortClause.MailboxTo, Order.REVERSE));
+    }
+
+    @Test
+    public void convertToSortsShouldSupportSize() {
+        assertThat(SortConverter.convertToSorts(ImmutableList.of("size desc")))
+                .containsExactly(new Sort(SortClause.Size, Order.REVERSE));
+    }
 }


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


[4/6] james-project git commit: JAMES-2101 Affect max and used field in OverQuotaException

Posted by bt...@apache.org.
JAMES-2101 Affect max and used field in OverQuotaException


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

Branch: refs/heads/master
Commit: 56beed22748ca13f975d401846b2eb56e7694bcd
Parents: 797660c
Author: benwa <bt...@linagora.com>
Authored: Fri Jul 28 11:22:31 2017 +0700
Committer: benwa <bt...@linagora.com>
Committed: Tue Aug 8 10:39:51 2017 +0700

----------------------------------------------------------------------
 .../org/apache/james/mailbox/exception/OverQuotaException.java     | 2 ++
 1 file changed, 2 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/56beed22/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 56bdfc8..e1ad77b 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
@@ -36,6 +36,8 @@ public class OverQuotaException extends MailboxException{
 
     public OverQuotaException(String msg, long max, long used) {
         super(msg);
+        this.used = used;
+        this.max = max;
     }
     public OverQuotaException(long max, long used) {
         this(null, max, used);


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


[2/6] james-project git commit: JAMES-2103 Fix StoreMessageIdManager Quota management

Posted by bt...@apache.org.
JAMES-2103 Fix StoreMessageIdManager Quota management


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

Branch: refs/heads/master
Commit: 533af6aa30dddcdea4a01e7c922c4ff165d6c2cc
Parents: 69cef15
Author: benwa <bt...@linagora.com>
Authored: Fri Jul 28 11:24:58 2017 +0700
Committer: benwa <bt...@linagora.com>
Committed: Tue Aug 8 10:39:51 2017 +0700

----------------------------------------------------------------------
 .../org/apache/james/mailbox/store/StoreMessageIdManager.java  | 6 ++++--
 .../james/mailbox/store/AbstractMessageIdManagerQuotaTest.java | 3 ---
 2 files changed, 4 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/533af6aa/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMessageIdManager.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMessageIdManager.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMessageIdManager.java
index 9b9d6e1..3d06f87 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMessageIdManager.java
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMessageIdManager.java
@@ -206,9 +206,11 @@ public class StoreMessageIdManager implements MessageIdManager {
 
         Map<QuotaRoot, Integer> messageCountByQuotaRoot = buildMapQuotaRoot(mailboxIdsToBeAdded, mailboxIdsToBeRemove, mailboxMapper);
         for (Map.Entry<QuotaRoot, Integer> entry : messageCountByQuotaRoot.entrySet()) {
-            if (entry.getValue() > 0) {
+            Integer additionalCopyCount = entry.getValue();
+            if (additionalCopyCount > 0) {
+                long additionalOccupiedSpace = additionalCopyCount * mailboxMessage.getFullContentOctets();
                 new QuotaChecker(quotaManager.getMessageQuota(entry.getKey()), quotaManager.getStorageQuota(entry.getKey()), entry.getKey())
-                    .tryAddition(entry.getValue(), mailboxMessage.getFullContentOctets());
+                    .tryAddition(additionalCopyCount, additionalOccupiedSpace);
             }
         }
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/533af6aa/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 bfc59d6..757f434 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
@@ -27,7 +27,6 @@ import org.apache.james.mailbox.MessageUid;
 import org.apache.james.mailbox.exception.OverQuotaException;
 import org.apache.james.mailbox.manager.MailboxManagerFixture;
 import org.apache.james.mailbox.mock.MockMailboxSession;
-import org.apache.james.mailbox.model.MailboxPath;
 import org.apache.james.mailbox.model.MessageId;
 import org.apache.james.mailbox.quota.CurrentQuotaManager;
 import org.apache.james.mailbox.quota.MaxQuotaManager;
@@ -35,7 +34,6 @@ import org.apache.james.mailbox.quota.QuotaManager;
 import org.apache.james.mailbox.store.mail.model.Mailbox;
 import org.junit.After;
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
@@ -113,7 +111,6 @@ public abstract class AbstractMessageIdManagerQuotaTest {
         messageIdManager.setInMailboxes(messageId, ImmutableList.of(mailbox1.getMailboxId(), mailbox2.getMailboxId()), session);
     }
 
-    @Ignore
     @Test
     public void setInMailboxesShouldThrowWhenStorageQuotaExceededWhenCopiedToMultipleMailboxes() throws Exception {
         maxQuotaManager.setDefaultMaxStorage(2 * testingData.getConstantMessageSize());


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