james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adup...@apache.org
Subject [13/29] james-project git commit: JAMES-1842: Rename GuiceServerProbe to JmapGuiceServerProbe
Date Fri, 18 Nov 2016 09:54:06 GMT
JAMES-1842: Rename GuiceServerProbe to JmapGuiceServerProbe


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

Branch: refs/heads/master
Commit: 91be31f9b0f3d0838267c7f90fceb83ff9af5b71
Parents: e48ef9d
Author: Quynh Nguyen <qnguyen@linagora.com>
Authored: Fri Oct 28 16:38:04 2016 +0700
Committer: Quynh Nguyen <qnguyen@linagora.com>
Committed: Fri Nov 18 09:25:34 2016 +0700

----------------------------------------------------------------------
 .../java/org/apache/james/GuiceJamesServer.java |   6 +-
 .../james/modules/CommonServicesModule.java     |   4 +-
 .../apache/james/utils/GuiceServerProbe.java    | 368 -------------------
 .../james/utils/JmapGuiceServerProbe.java       | 368 +++++++++++++++++++
 4 files changed, 373 insertions(+), 373 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/91be31f9/server/container/guice/guice-common/src/main/java/org/apache/james/GuiceJamesServer.java
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/src/main/java/org/apache/james/GuiceJamesServer.java
b/server/container/guice/guice-common/src/main/java/org/apache/james/GuiceJamesServer.java
index e9ce3f6..6d0209d 100644
--- a/server/container/guice/guice-common/src/main/java/org/apache/james/GuiceJamesServer.java
+++ b/server/container/guice/guice-common/src/main/java/org/apache/james/GuiceJamesServer.java
@@ -30,7 +30,7 @@ import org.apache.james.modules.ProtocolsModule;
 import org.apache.james.onami.lifecycle.Stager;
 import org.apache.james.utils.ConfigurationsPerformer;
 import org.apache.james.utils.ExtendedJmapServerProbe;
-import org.apache.james.utils.GuiceServerProbe;
+import org.apache.james.utils.JmapGuiceServerProbe;
 import org.apache.james.webadmin.Port;
 import org.apache.james.webadmin.WebAdminServer;
 
@@ -46,7 +46,7 @@ public class GuiceJamesServer {
 
     private final Module module;
     private Stager<PreDestroy> preDestroy;
-    private GuiceServerProbe serverProbe;
+    private JmapGuiceServerProbe serverProbe;
     private Optional<Integer> jmapPort;
     private Optional<Port> webadminPort;
 
@@ -73,7 +73,7 @@ public class GuiceJamesServer {
         Injector injector = Guice.createInjector(module);
         preDestroy = injector.getInstance(Key.get(new TypeLiteral<Stager<PreDestroy>>()
{}));
         injector.getInstance(ConfigurationsPerformer.class).initModules();
-        serverProbe = injector.getInstance(GuiceServerProbe.class);
+        serverProbe = injector.getInstance(JmapGuiceServerProbe.class);
         jmapPort = locateJMAPPort(injector);
         webadminPort =locateWebAdminPort(injector);
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/91be31f9/server/container/guice/guice-common/src/main/java/org/apache/james/modules/CommonServicesModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/src/main/java/org/apache/james/modules/CommonServicesModule.java
b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/CommonServicesModule.java
index e79ed7f..10af893 100644
--- a/server/container/guice/guice-common/src/main/java/org/apache/james/modules/CommonServicesModule.java
+++ b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/CommonServicesModule.java
@@ -33,7 +33,7 @@ import org.apache.james.modules.server.AsyncTasksExecutorModule;
 import org.apache.james.modules.server.ConfigurationProviderModule;
 import org.apache.james.modules.server.DNSServiceModule;
 import org.apache.james.onami.lifecycle.PreDestroyModule;
-import org.apache.james.utils.GuiceServerProbe;
+import org.apache.james.utils.JmapGuiceServerProbe;
 
 import com.google.inject.AbstractModule;
 import com.google.inject.Provides;
@@ -55,7 +55,7 @@ public class CommonServicesModule extends AbstractModule {
         install(new AsyncTasksExecutorModule());
 
         bind(FileSystemImpl.class).in(Scopes.SINGLETON);
-        bind(GuiceServerProbe.class).in(Scopes.SINGLETON);
+        bind(JmapGuiceServerProbe.class).in(Scopes.SINGLETON);
 
         bind(FileSystem.class).to(FileSystemImpl.class);
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/91be31f9/server/container/guice/guice-common/src/main/java/org/apache/james/utils/GuiceServerProbe.java
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/src/main/java/org/apache/james/utils/GuiceServerProbe.java
b/server/container/guice/guice-common/src/main/java/org/apache/james/utils/GuiceServerProbe.java
deleted file mode 100644
index cbc7f81..0000000
--- a/server/container/guice/guice-common/src/main/java/org/apache/james/utils/GuiceServerProbe.java
+++ /dev/null
@@ -1,368 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-
-package org.apache.james.utils;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Collection;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-import java.util.stream.Collectors;
-
-import javax.inject.Inject;
-import javax.mail.Flags;
-
-import org.apache.commons.lang.NotImplementedException;
-import org.apache.james.adapter.mailbox.SerializableQuota;
-import org.apache.james.domainlist.api.DomainList;
-import org.apache.james.jmap.api.vacation.AccountId;
-import org.apache.james.jmap.api.vacation.Vacation;
-import org.apache.james.jmap.api.vacation.VacationPatch;
-import org.apache.james.jmap.api.vacation.VacationRepository;
-import org.apache.james.mailbox.MailboxManager;
-import org.apache.james.mailbox.MailboxSession;
-import org.apache.james.mailbox.MessageManager;
-import org.apache.james.mailbox.exception.MailboxException;
-import org.apache.james.mailbox.model.MailboxConstants;
-import org.apache.james.mailbox.model.MailboxMetaData;
-import org.apache.james.mailbox.model.MailboxPath;
-import org.apache.james.mailbox.model.MailboxQuery;
-import org.apache.james.mailbox.store.mail.MailboxMapper;
-import org.apache.james.mailbox.store.mail.MailboxMapperFactory;
-import org.apache.james.mailbox.store.mail.model.Mailbox;
-import org.apache.james.rrt.api.RecipientRewriteTable;
-import org.apache.james.rrt.lib.Mappings;
-import org.apache.james.sieverepository.api.SieveRepository;
-import org.apache.james.user.api.UsersRepository;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.Throwables;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Iterables;
-
-public class GuiceServerProbe implements ExtendedJmapServerProbe {
-
-    private static final Logger LOGGER = LoggerFactory.getLogger(GuiceServerProbe.class);
-
-    private final MailboxManager mailboxManager;
-    private final MailboxMapperFactory mailboxMapperFactory;
-    private final DomainList domainList;
-    private final UsersRepository usersRepository;
-    private final SieveRepository sieveRepository;
-    private final RecipientRewriteTable recipientRewriteTable;
-    private final VacationRepository vacationRepository;
-
-    @Inject
-    private GuiceServerProbe(MailboxManager mailboxManager, MailboxMapperFactory mailboxMapperFactory,
-                             DomainList domainList, UsersRepository usersRepository, SieveRepository
sieveRepository,
-                             RecipientRewriteTable recipientRewriteTable, VacationRepository
vacationRepository) {
-        this.mailboxManager = mailboxManager;
-        this.mailboxMapperFactory = mailboxMapperFactory;
-        this.domainList = domainList;
-        this.usersRepository = usersRepository;
-        this.sieveRepository = sieveRepository;
-        this.recipientRewriteTable = recipientRewriteTable;
-        this.vacationRepository = vacationRepository;
-    }
-
-    @Override
-    public void close() throws IOException {
-    }
-
-    @Override
-    public void addUser(String userName, String password) throws Exception {
-        usersRepository.addUser(userName, password);
-    }
-
-    @Override
-    public void removeUser(String username) throws Exception {
-        usersRepository.removeUser(username);
-    }
-
-    @Override
-    public String[] listUsers() throws Exception {
-        return Iterables.toArray(ImmutableList.copyOf(usersRepository.list()), String.class);
-    }
-
-    @Override
-    public void setPassword(String userName, String password) throws Exception {
-        throw new NotImplementedException();
-    }
-
-    @Override
-    public void addDomain(String domain) throws Exception {
-        domainList.addDomain(domain);
-    }
-
-    @Override
-    public boolean containsDomain(String domain) throws Exception {
-        return domainList.containsDomain(domain);
-    }
-
-    @Override
-    public String getDefaultDomain() throws Exception {
-        return domainList.getDefaultDomain();
-    }
-
-    @Override
-    public void removeDomain(String domain) throws Exception {
-        domainList.removeDomain(domain);
-    }
-
-    @Override
-    public List<String> listDomains() throws Exception {
-        return domainList.getDomains();
-    }
-
-    @Override
-    public Map<String, Mappings> listMappings() throws Exception {
-        return recipientRewriteTable.getAllMappings();
-    }
-
-    @Override
-    public void addAddressMapping(String user, String domain, String toAddress) throws Exception
{
-        recipientRewriteTable.addAddressMapping(user, domain, toAddress);
-    }
-
-    @Override
-    public void removeAddressMapping(String user, String domain, String fromAddress) throws
Exception {
-        recipientRewriteTable.removeAddressMapping(user, domain, fromAddress);
-    }
-
-    @Override
-    public Mappings listUserDomainMappings(String user, String domain) throws Exception {
-        throw new NotImplementedException();
-    }
-
-    @Override
-    public void addRegexMapping(String user, String domain, String regex) throws Exception
{
-        recipientRewriteTable.addRegexMapping(user, domain, regex);
-    }
-
-    @Override
-    public void removeRegexMapping(String user, String domain, String regex) throws Exception
{
-        recipientRewriteTable.removeRegexMapping(user, domain, regex);
-    }
-
-    @Override
-    public void copyMailbox(String srcBean, String dstBean) throws Exception {
-        throw new NotImplementedException();
-    }
-
-    @Override
-    public void deleteUserMailboxesNames(String user) throws Exception {
-        throw new NotImplementedException();
-    }
-
-    @Override
-    public void createMailbox(String namespace, String user, String name) {
-        MailboxSession mailboxSession = null;
-        try {
-            mailboxSession = mailboxManager.createSystemSession(user, LOGGER);
-            mailboxManager.startProcessingRequest(mailboxSession);
-            mailboxManager.createMailbox(new MailboxPath(namespace, user, name), mailboxSession);
-        } catch (MailboxException e) {
-            throw Throwables.propagate(e);
-        } finally {
-            closeSession(mailboxSession);
-        }
-    }
-
-    @Override
-    public Mailbox getMailbox(String namespace, String user, String name) {
-        MailboxSession mailboxSession = null;
-        try {
-            mailboxSession = mailboxManager.createSystemSession(user, LOGGER);
-            MailboxMapper mailboxMapper = mailboxMapperFactory.getMailboxMapper(mailboxSession);
-            return mailboxMapper.findMailboxByPath(new MailboxPath(namespace, user, name));
-        } catch (MailboxException e) {
-            throw Throwables.propagate(e);
-        } finally {
-            closeSession(mailboxSession);
-        }
-    }
-
-    private void closeSession(MailboxSession session) {
-        if (session != null) {
-            mailboxManager.endProcessingRequest(session);
-            try {
-                mailboxManager.logout(session, true);
-            } catch (MailboxException e) {
-                throw Throwables.propagate(e);
-            }
-        }
-    }
-
-    @Override
-    public Collection<String> listUserMailboxes(String user) {
-        MailboxSession mailboxSession = null;
-        try {
-            mailboxSession = mailboxManager.createSystemSession(user, LOGGER);
-            mailboxManager.startProcessingRequest(mailboxSession);
-            return searchUserMailboxes(user, mailboxSession)
-                    .stream()
-                    .map(MailboxMetaData::getPath)
-                    .map(MailboxPath::getName)
-                    .collect(Collectors.toList());
-        } catch (MailboxException e) {
-            throw Throwables.propagate(e);
-        } finally {
-            closeSession(mailboxSession);
-        }
-    }
-
-    private List<MailboxMetaData> searchUserMailboxes(String username, MailboxSession
session) throws MailboxException {
-        return mailboxManager.search(
-            new MailboxQuery(new MailboxPath(MailboxConstants.USER_NAMESPACE, username, ""),
-                "*",
-                session.getPathDelimiter()),
-            session);
-    }
-
-    @Override
-    public void deleteMailbox(String namespace, String user, String name) {
-        MailboxSession mailboxSession = null;
-        try {
-            mailboxSession = mailboxManager.createSystemSession(user, LOGGER);
-            mailboxManager.startProcessingRequest(mailboxSession);
-            mailboxManager.deleteMailbox(new MailboxPath(namespace, user, name), mailboxSession);
-        } catch (MailboxException e) {
-            throw Throwables.propagate(e);
-        } finally {
-            closeSession(mailboxSession);
-        }
-    }
-
-    @Override
-    public String getQuotaRoot(String namespace, String user, String name) throws MailboxException
{
-        throw new NotImplementedException();
-    }
-
-    @Override
-    public SerializableQuota getMessageCountQuota(String quotaRoot) throws MailboxException
{
-        throw new NotImplementedException();
-    }
-
-    @Override
-    public SerializableQuota getStorageQuota(String quotaRoot) throws MailboxException {
-        throw new NotImplementedException();
-    }
-
-    @Override
-    public long getMaxMessageCount(String quotaRoot) throws MailboxException {
-        throw new NotImplementedException();
-    }
-
-    @Override
-    public long getMaxStorage(String quotaRoot) throws MailboxException {
-        throw new NotImplementedException();
-    }
-
-    @Override
-    public long getDefaultMaxMessageCount() throws MailboxException {
-        throw new NotImplementedException();
-    }
-
-    @Override
-    public long getDefaultMaxStorage() throws MailboxException {
-        throw new NotImplementedException();
-    }
-
-    @Override
-    public void setMaxMessageCount(String quotaRoot, long maxMessageCount) throws MailboxException
{
-        throw new NotImplementedException();
-    }
-
-    @Override
-    public void setMaxStorage(String quotaRoot, long maxSize) throws MailboxException {
-        throw new NotImplementedException();
-    }
-
-    @Override
-    public void setDefaultMaxMessageCount(long maxDefaultMessageCount) throws MailboxException
{
-        throw new NotImplementedException();
-    }
-
-    @Override
-    public void setDefaultMaxStorage(long maxDefaultSize) throws MailboxException {
-        throw new NotImplementedException();
-    }
-
-    @Override
-    public void appendMessage(String username, MailboxPath mailboxPath, InputStream message,
Date internalDate, boolean isRecent, Flags flags) 
-            throws MailboxException {
-        
-        MailboxSession mailboxSession = mailboxManager.createSystemSession(username, LOGGER);
-        MessageManager messageManager = mailboxManager.getMailbox(mailboxPath, mailboxSession);
-        messageManager.appendMessage(message, internalDate, mailboxSession, isRecent, flags);
-    }
-
-    @Override
-    public void reIndexMailbox(String namespace, String user, String name) throws Exception
{
-        throw new NotImplementedException();
-    }
-
-    @Override
-    public void reIndexAll() throws Exception {
-        throw new NotImplementedException();
-    }
-
-    @Override
-    public long getSieveQuota() throws Exception {
-        return sieveRepository.getQuota();
-    }
-
-    @Override
-    public void setSieveQuota(long quota) throws Exception {
-        sieveRepository.setQuota(quota);
-    }
-
-    @Override
-    public void removeSieveQuota() throws Exception {
-        sieveRepository.removeQuota();
-    }
-
-    @Override
-    public long getSieveQuota(String user) throws Exception {
-        return sieveRepository.getQuota(user);
-    }
-
-    @Override
-    public void setSieveQuota(String user, long quota) throws Exception {
-        sieveRepository.setQuota(user, quota);
-    }
-
-    @Override
-    public void removeSieveQuota(String user) throws Exception {
-        sieveRepository.removeQuota(user);
-    }
-
-    @Override
-    public void modifyVacation(AccountId accountId, VacationPatch vacationPatch) {
-        vacationRepository.modifyVacation(accountId, vacationPatch).join();
-    }
-
-    @Override
-    public Vacation retrieveVacation(AccountId accountId) {
-        return vacationRepository.retrieveVacation(accountId).join();
-    }
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/91be31f9/server/container/guice/guice-common/src/main/java/org/apache/james/utils/JmapGuiceServerProbe.java
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/src/main/java/org/apache/james/utils/JmapGuiceServerProbe.java
b/server/container/guice/guice-common/src/main/java/org/apache/james/utils/JmapGuiceServerProbe.java
new file mode 100644
index 0000000..b2ca5d5
--- /dev/null
+++ b/server/container/guice/guice-common/src/main/java/org/apache/james/utils/JmapGuiceServerProbe.java
@@ -0,0 +1,368 @@
+/****************************************************************
+ * 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.utils;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+import javax.inject.Inject;
+import javax.mail.Flags;
+
+import org.apache.commons.lang.NotImplementedException;
+import org.apache.james.adapter.mailbox.SerializableQuota;
+import org.apache.james.domainlist.api.DomainList;
+import org.apache.james.jmap.api.vacation.AccountId;
+import org.apache.james.jmap.api.vacation.Vacation;
+import org.apache.james.jmap.api.vacation.VacationPatch;
+import org.apache.james.jmap.api.vacation.VacationRepository;
+import org.apache.james.mailbox.MailboxManager;
+import org.apache.james.mailbox.MailboxSession;
+import org.apache.james.mailbox.MessageManager;
+import org.apache.james.mailbox.exception.MailboxException;
+import org.apache.james.mailbox.model.MailboxConstants;
+import org.apache.james.mailbox.model.MailboxMetaData;
+import org.apache.james.mailbox.model.MailboxPath;
+import org.apache.james.mailbox.model.MailboxQuery;
+import org.apache.james.mailbox.store.mail.MailboxMapper;
+import org.apache.james.mailbox.store.mail.MailboxMapperFactory;
+import org.apache.james.mailbox.store.mail.model.Mailbox;
+import org.apache.james.rrt.api.RecipientRewriteTable;
+import org.apache.james.rrt.lib.Mappings;
+import org.apache.james.sieverepository.api.SieveRepository;
+import org.apache.james.user.api.UsersRepository;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.Throwables;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Iterables;
+
+public class JmapGuiceServerProbe implements ExtendedJmapServerProbe {
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(JmapGuiceServerProbe.class);
+
+    private final MailboxManager mailboxManager;
+    private final MailboxMapperFactory mailboxMapperFactory;
+    private final DomainList domainList;
+    private final UsersRepository usersRepository;
+    private final SieveRepository sieveRepository;
+    private final RecipientRewriteTable recipientRewriteTable;
+    private final VacationRepository vacationRepository;
+
+    @Inject
+    private JmapGuiceServerProbe(MailboxManager mailboxManager, MailboxMapperFactory mailboxMapperFactory,
+                             DomainList domainList, UsersRepository usersRepository, SieveRepository
sieveRepository,
+                             RecipientRewriteTable recipientRewriteTable, VacationRepository
vacationRepository) {
+        this.mailboxManager = mailboxManager;
+        this.mailboxMapperFactory = mailboxMapperFactory;
+        this.domainList = domainList;
+        this.usersRepository = usersRepository;
+        this.sieveRepository = sieveRepository;
+        this.recipientRewriteTable = recipientRewriteTable;
+        this.vacationRepository = vacationRepository;
+    }
+
+    @Override
+    public void close() throws IOException {
+    }
+
+    @Override
+    public void addUser(String userName, String password) throws Exception {
+        usersRepository.addUser(userName, password);
+    }
+
+    @Override
+    public void removeUser(String username) throws Exception {
+        usersRepository.removeUser(username);
+    }
+
+    @Override
+    public String[] listUsers() throws Exception {
+        return Iterables.toArray(ImmutableList.copyOf(usersRepository.list()), String.class);
+    }
+
+    @Override
+    public void setPassword(String userName, String password) throws Exception {
+        throw new NotImplementedException();
+    }
+
+    @Override
+    public void addDomain(String domain) throws Exception {
+        domainList.addDomain(domain);
+    }
+
+    @Override
+    public boolean containsDomain(String domain) throws Exception {
+        return domainList.containsDomain(domain);
+    }
+
+    @Override
+    public String getDefaultDomain() throws Exception {
+        return domainList.getDefaultDomain();
+    }
+
+    @Override
+    public void removeDomain(String domain) throws Exception {
+        domainList.removeDomain(domain);
+    }
+
+    @Override
+    public List<String> listDomains() throws Exception {
+        return domainList.getDomains();
+    }
+
+    @Override
+    public Map<String, Mappings> listMappings() throws Exception {
+        return recipientRewriteTable.getAllMappings();
+    }
+
+    @Override
+    public void addAddressMapping(String user, String domain, String toAddress) throws Exception
{
+        recipientRewriteTable.addAddressMapping(user, domain, toAddress);
+    }
+
+    @Override
+    public void removeAddressMapping(String user, String domain, String fromAddress) throws
Exception {
+        recipientRewriteTable.removeAddressMapping(user, domain, fromAddress);
+    }
+
+    @Override
+    public Mappings listUserDomainMappings(String user, String domain) throws Exception {
+        throw new NotImplementedException();
+    }
+
+    @Override
+    public void addRegexMapping(String user, String domain, String regex) throws Exception
{
+        recipientRewriteTable.addRegexMapping(user, domain, regex);
+    }
+
+    @Override
+    public void removeRegexMapping(String user, String domain, String regex) throws Exception
{
+        recipientRewriteTable.removeRegexMapping(user, domain, regex);
+    }
+
+    @Override
+    public void copyMailbox(String srcBean, String dstBean) throws Exception {
+        throw new NotImplementedException();
+    }
+
+    @Override
+    public void deleteUserMailboxesNames(String user) throws Exception {
+        throw new NotImplementedException();
+    }
+
+    @Override
+    public void createMailbox(String namespace, String user, String name) {
+        MailboxSession mailboxSession = null;
+        try {
+            mailboxSession = mailboxManager.createSystemSession(user, LOGGER);
+            mailboxManager.startProcessingRequest(mailboxSession);
+            mailboxManager.createMailbox(new MailboxPath(namespace, user, name), mailboxSession);
+        } catch (MailboxException e) {
+            throw Throwables.propagate(e);
+        } finally {
+            closeSession(mailboxSession);
+        }
+    }
+
+    @Override
+    public Mailbox getMailbox(String namespace, String user, String name) {
+        MailboxSession mailboxSession = null;
+        try {
+            mailboxSession = mailboxManager.createSystemSession(user, LOGGER);
+            MailboxMapper mailboxMapper = mailboxMapperFactory.getMailboxMapper(mailboxSession);
+            return mailboxMapper.findMailboxByPath(new MailboxPath(namespace, user, name));
+        } catch (MailboxException e) {
+            throw Throwables.propagate(e);
+        } finally {
+            closeSession(mailboxSession);
+        }
+    }
+
+    private void closeSession(MailboxSession session) {
+        if (session != null) {
+            mailboxManager.endProcessingRequest(session);
+            try {
+                mailboxManager.logout(session, true);
+            } catch (MailboxException e) {
+                throw Throwables.propagate(e);
+            }
+        }
+    }
+
+    @Override
+    public Collection<String> listUserMailboxes(String user) {
+        MailboxSession mailboxSession = null;
+        try {
+            mailboxSession = mailboxManager.createSystemSession(user, LOGGER);
+            mailboxManager.startProcessingRequest(mailboxSession);
+            return searchUserMailboxes(user, mailboxSession)
+                    .stream()
+                    .map(MailboxMetaData::getPath)
+                    .map(MailboxPath::getName)
+                    .collect(Collectors.toList());
+        } catch (MailboxException e) {
+            throw Throwables.propagate(e);
+        } finally {
+            closeSession(mailboxSession);
+        }
+    }
+
+    private List<MailboxMetaData> searchUserMailboxes(String username, MailboxSession
session) throws MailboxException {
+        return mailboxManager.search(
+            new MailboxQuery(new MailboxPath(MailboxConstants.USER_NAMESPACE, username, ""),
+                "*",
+                session.getPathDelimiter()),
+            session);
+    }
+
+    @Override
+    public void deleteMailbox(String namespace, String user, String name) {
+        MailboxSession mailboxSession = null;
+        try {
+            mailboxSession = mailboxManager.createSystemSession(user, LOGGER);
+            mailboxManager.startProcessingRequest(mailboxSession);
+            mailboxManager.deleteMailbox(new MailboxPath(namespace, user, name), mailboxSession);
+        } catch (MailboxException e) {
+            throw Throwables.propagate(e);
+        } finally {
+            closeSession(mailboxSession);
+        }
+    }
+
+    @Override
+    public String getQuotaRoot(String namespace, String user, String name) throws MailboxException
{
+        throw new NotImplementedException();
+    }
+
+    @Override
+    public SerializableQuota getMessageCountQuota(String quotaRoot) throws MailboxException
{
+        throw new NotImplementedException();
+    }
+
+    @Override
+    public SerializableQuota getStorageQuota(String quotaRoot) throws MailboxException {
+        throw new NotImplementedException();
+    }
+
+    @Override
+    public long getMaxMessageCount(String quotaRoot) throws MailboxException {
+        throw new NotImplementedException();
+    }
+
+    @Override
+    public long getMaxStorage(String quotaRoot) throws MailboxException {
+        throw new NotImplementedException();
+    }
+
+    @Override
+    public long getDefaultMaxMessageCount() throws MailboxException {
+        throw new NotImplementedException();
+    }
+
+    @Override
+    public long getDefaultMaxStorage() throws MailboxException {
+        throw new NotImplementedException();
+    }
+
+    @Override
+    public void setMaxMessageCount(String quotaRoot, long maxMessageCount) throws MailboxException
{
+        throw new NotImplementedException();
+    }
+
+    @Override
+    public void setMaxStorage(String quotaRoot, long maxSize) throws MailboxException {
+        throw new NotImplementedException();
+    }
+
+    @Override
+    public void setDefaultMaxMessageCount(long maxDefaultMessageCount) throws MailboxException
{
+        throw new NotImplementedException();
+    }
+
+    @Override
+    public void setDefaultMaxStorage(long maxDefaultSize) throws MailboxException {
+        throw new NotImplementedException();
+    }
+
+    @Override
+    public void appendMessage(String username, MailboxPath mailboxPath, InputStream message,
Date internalDate, boolean isRecent, Flags flags) 
+            throws MailboxException {
+        
+        MailboxSession mailboxSession = mailboxManager.createSystemSession(username, LOGGER);
+        MessageManager messageManager = mailboxManager.getMailbox(mailboxPath, mailboxSession);
+        messageManager.appendMessage(message, internalDate, mailboxSession, isRecent, flags);
+    }
+
+    @Override
+    public void reIndexMailbox(String namespace, String user, String name) throws Exception
{
+        throw new NotImplementedException();
+    }
+
+    @Override
+    public void reIndexAll() throws Exception {
+        throw new NotImplementedException();
+    }
+
+    @Override
+    public long getSieveQuota() throws Exception {
+        return sieveRepository.getQuota();
+    }
+
+    @Override
+    public void setSieveQuota(long quota) throws Exception {
+        sieveRepository.setQuota(quota);
+    }
+
+    @Override
+    public void removeSieveQuota() throws Exception {
+        sieveRepository.removeQuota();
+    }
+
+    @Override
+    public long getSieveQuota(String user) throws Exception {
+        return sieveRepository.getQuota(user);
+    }
+
+    @Override
+    public void setSieveQuota(String user, long quota) throws Exception {
+        sieveRepository.setQuota(user, quota);
+    }
+
+    @Override
+    public void removeSieveQuota(String user) throws Exception {
+        sieveRepository.removeQuota(user);
+    }
+
+    @Override
+    public void modifyVacation(AccountId accountId, VacationPatch vacationPatch) {
+        vacationRepository.modifyVacation(accountId, vacationPatch).join();
+    }
+
+    @Override
+    public Vacation retrieveVacation(AccountId accountId) {
+        return vacationRepository.retrieveVacation(accountId).join();
+    }
+}


---------------------------------------------------------------------
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