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 ro...@apache.org on 2019/03/18 16:39:52 UTC

[james-project] 02/03: JAMES-2578 Deprecate MailetContext Attributes API

This is an automated email from the ASF dual-hosted git repository.

rouazana pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit c4311e3afb9cb59f1035f552d4a4916033645028
Author: Gautier DI FOLCO <gd...@linagora.com>
AuthorDate: Tue Feb 26 18:18:37 2019 +0100

    JAMES-2578 Deprecate MailetContext Attributes API
---
 mailet/api/src/main/java/org/apache/mailet/MailetContext.java  |  4 ++++
 .../org/apache/james/transport/mailets/WhiteListManager.java   | 10 +++++++---
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/mailet/api/src/main/java/org/apache/mailet/MailetContext.java b/mailet/api/src/main/java/org/apache/mailet/MailetContext.java
index 6b91dd0..44c0e9a 100644
--- a/mailet/api/src/main/java/org/apache/mailet/MailetContext.java
+++ b/mailet/api/src/main/java/org/apache/mailet/MailetContext.java
@@ -124,6 +124,7 @@ public interface MailetContext {
      *
      * @return an Iterator (of Strings) over all attribute names
      */
+    @Deprecated
     Iterator<String> getAttributeNames();
 
     /**
@@ -133,6 +134,7 @@ public interface MailetContext {
      * @param name the attribute name
      * @return the attribute value, or null if the attribute does not exist
      */
+    @Deprecated
     Object getAttribute(String name);
 
     /**
@@ -160,6 +162,7 @@ public interface MailetContext {
      * @param name  the attribute name
      * @param value the attribute value
      */
+    @Deprecated
     void setAttribute(String name, Object value);
 
     /**
@@ -168,6 +171,7 @@ public interface MailetContext {
      * @param name the name of the attribute to be removed
      * @since Mailet API v2.1
      */
+    @Deprecated
     void removeAttribute(String name);
 
     /**
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/WhiteListManager.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/WhiteListManager.java
index 0249c7a..e666d78 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/WhiteListManager.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/WhiteListManager.java
@@ -55,6 +55,7 @@ import org.apache.james.util.sql.JDBCUtil;
 import org.apache.james.util.sql.SqlResources;
 import org.apache.mailet.Experimental;
 import org.apache.mailet.Mail;
+import org.apache.mailet.MailetException;
 import org.apache.mailet.base.DateFormats;
 import org.apache.mailet.base.GenericMailet;
 import org.apache.mailet.base.RFC2822Headers;
@@ -752,9 +753,12 @@ public class WhiteListManager extends GenericMailet {
             }
 
             /*
-      Holds value of property sqlFile.
-     */
-            File sqlFile = new File((String) mailetContext.getAttribute("confDir"), "sqlResources.xml").getCanonicalFile();
+                Holds value of property sqlFile.
+            */
+            String confDir = getInitParameterAsOptional("confDir")
+                .orElseThrow(() -> new MailetException("WhiteListManager has no 'confDir' configured"));
+
+            File sqlFile = new File(confDir, "sqlResources.xml").getCanonicalFile();
             sqlQueries.init(sqlFile, "WhiteList", conn, getSqlParameters());
 
             checkTables(conn);


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