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 no...@apache.org on 2010/11/07 10:49:44 UTC

svn commit: r1032250 - /james/server/trunk/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/camel/CamelMailProcessorList.java

Author: norman
Date: Sun Nov  7 09:49:44 2010
New Revision: 1032250

URL: http://svn.apache.org/viewvc?rev=1032250&view=rev
Log:
Throw ConfigurationException if not all needed processors are configured or if ghost is used as processorname as the name is reserved (JAMES-1118)

Modified:
    james/server/trunk/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/camel/CamelMailProcessorList.java

Modified: james/server/trunk/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/camel/CamelMailProcessorList.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/camel/CamelMailProcessorList.java?rev=1032250&r1=1032249&r2=1032250&view=diff
==============================================================================
--- james/server/trunk/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/camel/CamelMailProcessorList.java (original)
+++ james/server/trunk/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/camel/CamelMailProcessorList.java Sun Nov  7 09:49:44 2010
@@ -343,7 +343,8 @@ public class CamelMailProcessorList impl
             for (int i = 0; i < processorConfs.size(); i++) {
                 final HierarchicalConfiguration processorConf = processorConfs.get(i);
                 String processorName = processorConf.getString("[@name]");
-
+                
+                if (processorName.equals(Mail.GHOST)) throw new ConfigurationException("ProcessorName of " + Mail.GHOST + " is reserved for internal use, choose a different name");
                 
                 mailets.put(processorName, new ArrayList<MailetManagement>());
                 matchers.put(processorName, new ArrayList<MatcherManagement>());
@@ -498,11 +499,42 @@ public class CamelMailProcessorList impl
                   
                 processors.put(processorName, new ProcessorDetail(processorName,new ChildProcessor(processorName)));
             }
-                
+            
+            // check if all needed processors are configured
+            checkProcessors();
+  
         }
+        
     }
     
     /**
+     * Check if all needed Processors are configured and if not throw a {@link ConfigurationException}
+     * 
+     * @throws ConfigurationException
+     */
+    private void checkProcessors() throws ConfigurationException {
+        boolean errorProcessorFound = false;
+        boolean rootProcessorFound = false;
+        Iterator<String> names = processors.keySet().iterator();
+        while(names.hasNext()) {
+            String name = names.next();
+            if (name.equals(Mail.DEFAULT)) {
+                rootProcessorFound = true;
+            } else if (name.equals(Mail.ERROR)) {
+                errorProcessorFound = true;
+            }
+            
+            if (errorProcessorFound && rootProcessorFound) {
+                return;
+            }
+        }
+        if (errorProcessorFound == false) {
+            throw new ConfigurationException("You need to configure a Processor with name " + Mail.ERROR);
+        } else if (rootProcessorFound == false) {
+            throw new ConfigurationException("You need to configure a Processor with name " + Mail.DEFAULT);
+        }
+    }
+    /**
      * Load  {@link CompositeMatcher} implementations and their child {@link Matcher}'s
      * 
      * CompositeMatcher were added by JAMES-948



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