james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject [02/19] james-project git commit: JAMES-2616 replace getSession() in ElasticSearchQuotaMailboxListener
Date Fri, 07 Dec 2018 01:10:25 GMT
JAMES-2616 replace getSession() in ElasticSearchQuotaMailboxListener


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

Branch: refs/heads/master
Commit: 543284e21ad90147e6668741a228a3388195b18a
Parents: f23ffa3
Author: tran tien duc <dtran@linagora.com>
Authored: Fri Nov 30 11:40:09 2018 +0700
Committer: Benoit Tellier <btellier@linagora.com>
Committed: Fri Dec 7 07:44:58 2018 +0700

----------------------------------------------------------------------
 .../events/ElasticSearchQuotaMailboxListener.java      | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/543284e2/mailbox/plugin/quota-search-elasticsearch/src/main/java/org/apache/james/quota/search/elasticsearch/events/ElasticSearchQuotaMailboxListener.java
----------------------------------------------------------------------
diff --git a/mailbox/plugin/quota-search-elasticsearch/src/main/java/org/apache/james/quota/search/elasticsearch/events/ElasticSearchQuotaMailboxListener.java
b/mailbox/plugin/quota-search-elasticsearch/src/main/java/org/apache/james/quota/search/elasticsearch/events/ElasticSearchQuotaMailboxListener.java
index 1bdd295..f901cfd 100644
--- a/mailbox/plugin/quota-search-elasticsearch/src/main/java/org/apache/james/quota/search/elasticsearch/events/ElasticSearchQuotaMailboxListener.java
+++ b/mailbox/plugin/quota-search-elasticsearch/src/main/java/org/apache/james/quota/search/elasticsearch/events/ElasticSearchQuotaMailboxListener.java
@@ -22,9 +22,9 @@ import javax.inject.Inject;
 import javax.inject.Named;
 
 import org.apache.james.backends.es.ElasticSearchIndexer;
+import org.apache.james.core.User;
 import org.apache.james.mailbox.Event;
 import org.apache.james.mailbox.MailboxListener;
-import org.apache.james.mailbox.MailboxSession.User;
 import org.apache.james.quota.search.elasticsearch.QuotaRatioElasticSearchConstants;
 import org.apache.james.quota.search.elasticsearch.json.QuotaRatioToElasticSearchJson;
 import org.slf4j.Logger;
@@ -56,7 +56,7 @@ public class ElasticSearchQuotaMailboxListener implements MailboxListener
{
     public void event(Event event) {
         try {
             if (event instanceof QuotaUsageUpdatedEvent) {
-                handleEvent(getUser(event), (QuotaUsageUpdatedEvent) event);
+                handleEvent(event.getUser(), (QuotaUsageUpdatedEvent) event);
             }
         } catch (Exception e) {
             LOGGER.error("Can not index quota ratio", e);
@@ -64,12 +64,7 @@ public class ElasticSearchQuotaMailboxListener implements MailboxListener
{
     }
 
     private void handleEvent(User user, QuotaUsageUpdatedEvent event) throws JsonProcessingException
{
-        indexer.index(user.getUserName(), 
-                quotaRatioToElasticSearchJson.convertToJson(user.getUserName(), event));
-    }
-
-    private User getUser(Event event) {
-        return event.getSession()
-                .getUser();
+        indexer.index(user.asString(),
+                quotaRatioToElasticSearchJson.convertToJson(user.asString(), event));
     }
 }


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


Mime
View raw message