james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adup...@apache.org
Subject [02/24] james-project git commit: JAMES-2366 Add Forward mapping handling in DataProbe
Date Fri, 06 Apr 2018 13:20:21 GMT
JAMES-2366 Add Forward mapping handling in DataProbe


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

Branch: refs/heads/master
Commit: 71a465ef8b1b8908a35a4036a81775f1dd247a14
Parents: fd6f10a
Author: Antoine Duprat <aduprat@linagora.com>
Authored: Thu Mar 29 11:24:54 2018 +0200
Committer: Antoine Duprat <aduprat@linagora.com>
Committed: Fri Apr 6 14:39:16 2018 +0200

----------------------------------------------------------------------
 .../james/cli/probe/impl/JmxDataProbe.java      | 22 ++++++++++++++++++
 .../org/apache/james/utils/DataProbeImpl.java   | 10 ++++++++
 .../java/org/apache/james/probe/DataProbe.java  |  3 +++
 .../RecipientRewriteTableManagementMBean.java   | 24 ++++++++++++++++++++
 .../lib/RecipientRewriteTableManagement.java    | 18 +++++++++++++++
 5 files changed, 77 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/71a465ef/server/container/cli/src/main/java/org/apache/james/cli/probe/impl/JmxDataProbe.java
----------------------------------------------------------------------
diff --git a/server/container/cli/src/main/java/org/apache/james/cli/probe/impl/JmxDataProbe.java
b/server/container/cli/src/main/java/org/apache/james/cli/probe/impl/JmxDataProbe.java
index 631e11b..4e24f18 100644
--- a/server/container/cli/src/main/java/org/apache/james/cli/probe/impl/JmxDataProbe.java
+++ b/server/container/cli/src/main/java/org/apache/james/cli/probe/impl/JmxDataProbe.java
@@ -237,4 +237,26 @@ public class JmxDataProbe implements DataProbe, JmxProbe {
             virtualUserTableProxy.addDomainMapping(aliasDomain, deliveryDomain);
         }
     }
+
+    @Override
+    public void addForwardMapping(String user, String domain, String address) throws Exception
{
+        try (Closeable closeable =
+                MDCBuilder.create()
+                    .addContext(MDCBuilder.PROTOCOL, JMX)
+                    .addContext(MDCBuilder.ACTION, "addForwardMapping")
+                    .build()) {
+           virtualUserTableProxy.addForwardMapping(user, domain, address);
+       }
+   }
+
+    @Override
+    public void removeForwardMapping(String user, String domain, String address) throws Exception
{
+        try (Closeable closeable =
+                MDCBuilder.create()
+                    .addContext(MDCBuilder.PROTOCOL, JMX)
+                    .addContext(MDCBuilder.ACTION, "removeForwardMapping")
+                    .build()) {
+           virtualUserTableProxy.removeForwardMapping(user, domain, address);
+       }
+   }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/james-project/blob/71a465ef/server/container/guice/guice-common/src/main/java/org/apache/james/utils/DataProbeImpl.java
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/src/main/java/org/apache/james/utils/DataProbeImpl.java
b/server/container/guice/guice-common/src/main/java/org/apache/james/utils/DataProbeImpl.java
index b911dc9..1e70007 100644
--- a/server/container/guice/guice-common/src/main/java/org/apache/james/utils/DataProbeImpl.java
+++ b/server/container/guice/guice-common/src/main/java/org/apache/james/utils/DataProbeImpl.java
@@ -133,4 +133,14 @@ public class DataProbeImpl implements GuiceProbe, DataProbe {
     public void addDomainAliasMapping(String aliasDomain, String deliveryDomain) throws Exception
{
         recipientRewriteTable.addAliasDomainMapping(Domain.of(aliasDomain), Domain.of(deliveryDomain));
     }
+
+    @Override
+    public void addForwardMapping(String user, String domain, String address) throws Exception
{
+        recipientRewriteTable.addForwardMapping(user, Domain.of(domain), address);
+    }
+
+    @Override
+    public void removeForwardMapping(String user, String domain, String address) throws Exception
{
+        recipientRewriteTable.removeForwardMapping(user, Domain.of(domain), address);
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/james-project/blob/71a465ef/server/data/data-api/src/main/java/org/apache/james/probe/DataProbe.java
----------------------------------------------------------------------
diff --git a/server/data/data-api/src/main/java/org/apache/james/probe/DataProbe.java b/server/data/data-api/src/main/java/org/apache/james/probe/DataProbe.java
index 31488d7..2dc6f8c 100644
--- a/server/data/data-api/src/main/java/org/apache/james/probe/DataProbe.java
+++ b/server/data/data-api/src/main/java/org/apache/james/probe/DataProbe.java
@@ -58,4 +58,7 @@ public interface DataProbe {
 
     void addDomainAliasMapping(String aliasDomain, String deliveryDomain) throws Exception;
 
+    void addForwardMapping(String toUser, String toDomain, String fromAddress) throws Exception;
+
+    void removeForwardMapping(String toUser, String toDomain, String fromAddress) throws
Exception;
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/james-project/blob/71a465ef/server/data/data-api/src/main/java/org/apache/james/rrt/api/RecipientRewriteTableManagementMBean.java
----------------------------------------------------------------------
diff --git a/server/data/data-api/src/main/java/org/apache/james/rrt/api/RecipientRewriteTableManagementMBean.java
b/server/data/data-api/src/main/java/org/apache/james/rrt/api/RecipientRewriteTableManagementMBean.java
index 19def77..dec0e4d 100644
--- a/server/data/data-api/src/main/java/org/apache/james/rrt/api/RecipientRewriteTableManagementMBean.java
+++ b/server/data/data-api/src/main/java/org/apache/james/rrt/api/RecipientRewriteTableManagementMBean.java
@@ -187,4 +187,28 @@ public interface RecipientRewriteTableManagementMBean {
      *            If an error occurred
      */
     Map<String, Mappings> getAllMappings() throws Exception;
+
+    /***
+     * Add forward mapping
+     *
+     * @param toUser
+     *            the username part of the mail address destination defined for this forward.
+     * @param toDomain
+     *            the domain part of the mail address destination defined for this forward.
+     * @param fromAddress The base address of the forward. Mails for this address will be
sent to the added forward destination.
+     * @throws Exception If an error occurred
+     */
+    void addForwardMapping(String user, String domain, String address) throws Exception;
+
+    /**
+     * Remove forward mapping
+     * 
+     * @param toUser
+     *            the username part of the mail address destination defined for this forward.
+     * @param toDomain
+     *            the domain part of the mail address destination defined for this forward.
+     * @param fromAddress The base address of the forward. Mails for this address will no
more sent to the removed forward destination.
+     * @throws Exception If an error occurred
+     */
+    void removeForwardMapping(String toUser, String toDomain, String fromAddress) throws
Exception;
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/71a465ef/server/data/data-library/src/main/java/org/apache/james/rrt/lib/RecipientRewriteTableManagement.java
----------------------------------------------------------------------
diff --git a/server/data/data-library/src/main/java/org/apache/james/rrt/lib/RecipientRewriteTableManagement.java
b/server/data/data-library/src/main/java/org/apache/james/rrt/lib/RecipientRewriteTableManagement.java
index 7e22a3e..57c7346 100644
--- a/server/data/data-library/src/main/java/org/apache/james/rrt/lib/RecipientRewriteTableManagement.java
+++ b/server/data/data-library/src/main/java/org/apache/james/rrt/lib/RecipientRewriteTableManagement.java
@@ -155,4 +155,22 @@ public class RecipientRewriteTableManagement extends StandardMBean implements
Re
         }
     }
 
+    @Override
+    public void addForwardMapping(String user, String domain, String address) throws Exception
{
+        try {
+            rrt.addForwardMapping(user, Domain.of(domain), address);
+        } catch (RecipientRewriteTableException e) {
+            throw new Exception(e.getMessage());
+        }
+    }
+
+    @Override
+    public void removeForwardMapping(String user, String domain, String address) throws Exception
{
+        try {
+            rrt.removeForwardMapping(user, Domain.of(domain), address);
+        } catch (RecipientRewriteTableException e) {
+            throw new Exception(e.getMessage());
+        }
+    }
+
 }


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