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 2006/11/19 21:52:21 UTC

svn commit: r476918 - in /james/server/trunk/src: conf/ java/org/apache/james/core/ java/org/apache/james/management/ java/org/apache/james/remotemanager/ java/org/apache/james/vut/

Author: norman
Date: Sun Nov 19 12:52:20 2006
New Revision: 476918

URL: http://svn.apache.org/viewvc?view=rev&rev=476918
Log:
Add managment commands for VUT-Service to RemoteManager. Second part of JAMES-706
Fix a bug in AbstractVirtualUserTable which allow to add mappings which allready exists

Modified:
    james/server/trunk/src/conf/james-assembly.xml
    james/server/trunk/src/java/org/apache/james/core/DefaultVirtualUserTable.java
    james/server/trunk/src/java/org/apache/james/management/VirtualUserTableManagement.java
    james/server/trunk/src/java/org/apache/james/management/VirtualUserTableManagement.xinfo
    james/server/trunk/src/java/org/apache/james/remotemanager/RemoteManager.java
    james/server/trunk/src/java/org/apache/james/remotemanager/RemoteManager.xinfo
    james/server/trunk/src/java/org/apache/james/remotemanager/RemoteManagerHandler.java
    james/server/trunk/src/java/org/apache/james/remotemanager/RemoteManagerHandlerConfigurationData.java
    james/server/trunk/src/java/org/apache/james/vut/AbstractVirtualUserTable.java

Modified: james/server/trunk/src/conf/james-assembly.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/src/conf/james-assembly.xml?view=diff&rev=476918&r1=476917&r2=476918
==============================================================================
--- james/server/trunk/src/conf/james-assembly.xml (original)
+++ james/server/trunk/src/conf/james-assembly.xml Sun Nov 19 12:52:20 2006
@@ -94,6 +94,7 @@
              role="org.apache.james.services.BayesianAnalyzerManagementService"/>
     <provide name="dnsserver" role="org.apache.james.services.DNSServer"/>
     <provide name="processormanagement" role="org.apache.james.services.ProcessorManagementService"/>
+    <provide name="virtualusertablemanagement" role="org.apache.james.services.VirtualUserTableManagementService"/>
 </block>
 
   <!-- The User Management block  -->
@@ -226,6 +227,7 @@
   <!-- The VirtualUserTable Management block  -->
   <block name="virtualusertablemanagement" class="org.apache.james.management.VirtualUserTableManagement" >
     <provide name="virtualusertable-store" role="org.apache.james.services.VirtualUserTableStore"/>
+    <provide name="defaultvirtualusertable" role="org.apache.james.services.VirtualUserTableManagement" />
   </block>
   
   <!-- VirtualUserTable Store -->

Modified: james/server/trunk/src/java/org/apache/james/core/DefaultVirtualUserTable.java
URL: http://svn.apache.org/viewvc/james/server/trunk/src/java/org/apache/james/core/DefaultVirtualUserTable.java?view=diff&rev=476918&r1=476917&r2=476918
==============================================================================
--- james/server/trunk/src/java/org/apache/james/core/DefaultVirtualUserTable.java (original)
+++ james/server/trunk/src/java/org/apache/james/core/DefaultVirtualUserTable.java Sun Nov 19 12:52:20 2006
@@ -47,7 +47,7 @@
     public void initialize() throws Exception {
         vut = (VirtualUserTableManagement) store.getTable("DefaultVirtualUserTable");
         if (vut == null) {
-            throw new ServiceException("","The VirtualUserTable could not be found.");
+            throw new ServiceException("","The DefaultVirtualUserTable could not be found.");
         }
     }
 
@@ -118,13 +118,13 @@
      * @see org.apache.james.services.VirtualUserTableManagement#addMapping(java.lang.String, java.lang.String, java.lang.String)
      */
     public boolean addMapping(String user, String domain, String mapping) throws InvalidMappingException {
-    return vut.addMapping(user, domain, mapping);
+        return vut.addMapping(user, domain, mapping);
     }
 
     /**
      * @see org.apache.james.services.VirtualUserTableManagement#removeMapping(java.lang.String, java.lang.String, java.lang.String)
      */
     public boolean removeMapping(String user, String domain, String mapping) throws InvalidMappingException {
-    return vut.removeMapping(user, domain, mapping);
+        return vut.removeMapping(user, domain, mapping);
     }
 }

Modified: james/server/trunk/src/java/org/apache/james/management/VirtualUserTableManagement.java
URL: http://svn.apache.org/viewvc/james/server/trunk/src/java/org/apache/james/management/VirtualUserTableManagement.java?view=diff&rev=476918&r1=476917&r2=476918
==============================================================================
--- james/server/trunk/src/java/org/apache/james/management/VirtualUserTableManagement.java (original)
+++ james/server/trunk/src/java/org/apache/james/management/VirtualUserTableManagement.java Sun Nov 19 12:52:20 2006
@@ -26,7 +26,7 @@
 import org.apache.avalon.framework.service.ServiceException;
 import org.apache.avalon.framework.service.ServiceManager;
 import org.apache.avalon.framework.service.Serviceable;
-import org.apache.james.core.AvalonVirtualUserTableStore;
+import org.apache.james.core.DefaultVirtualUserTable;
 import org.apache.james.services.VirtualUserTableManagementService;
 import org.apache.james.services.VirtualUserTableStore;
 import org.apache.james.vut.InvalidMappingException;
@@ -40,36 +40,46 @@
  */
 public class VirtualUserTableManagement implements Serviceable, VirtualUserTableManagementService {
 
-    AvalonVirtualUserTableStore store;
-    
+    VirtualUserTableStore store;
+    org.apache.james.services.VirtualUserTableManagement defaultVUT;    
 
     /**
      * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
      */
     public void service(ServiceManager arg0) throws ServiceException {
-        setAvalonVirtualUserTableStore((AvalonVirtualUserTableStore) arg0.lookup(VirtualUserTableStore.ROLE));
+        setVirtualUserTableStore((VirtualUserTableStore) arg0.lookup(VirtualUserTableStore.ROLE));
+        setDefaultVirtualUserTable((org.apache.james.services.VirtualUserTableManagement) arg0.lookup(DefaultVirtualUserTable.ROLE));
     }
 
-    public void setAvalonVirtualUserTableStore(AvalonVirtualUserTableStore store) {
+    public void setVirtualUserTableStore(VirtualUserTableStore store) {
         this.store = store;
     }
     
+    public void setDefaultVirtualUserTable(org.apache.james.services.VirtualUserTableManagement defaultVUT) {
+        this.defaultVUT = defaultVUT;
+    }
+    
     /**
      * Return a VirtualUserTableManagement with the given tablename
      * 
-     * @param tableName tableName
+     * @param tableName tableName if null is given the DefaultVirtualUserTable get returned
      * @return VirtualUserTableManagement object
      * @throws VirtualUserTableManagementException if no VirtualUserTable with the given name exists
      */
-    private org.apache.james.services.VirtualUserTableManagement getTable(String tableName) throws VirtualUserTableManagementException {
+    private org.apache.james.services.VirtualUserTableManagement getTable(String tableName) throws VirtualUserTableManagementException {     
+    // if the tableName was null return the DefaultVirtualUserTable
+    if (tableName == null) {
+        return defaultVUT;
+    } else {
         org.apache.james.services.VirtualUserTableManagement vut = (org.apache.james.services.VirtualUserTableManagement) store.getTable(tableName);
     
-        // Check if a table with the given name exists, if not throw an Exception
-        if (vut == null) {
-            throw new VirtualUserTableManagementException("No VirtualUserTable with such name: " + tableName);
-        } else {
-            return vut;
-        }
+            // Check if a table with the given name exists, if not throw an Exception
+            if (vut == null) {
+                throw new VirtualUserTableManagementException("No VirtualUserTable with such name: " + tableName);
+            } else {
+                return vut;
+            }
+    }
     }
     
     /**

Modified: james/server/trunk/src/java/org/apache/james/management/VirtualUserTableManagement.xinfo
URL: http://svn.apache.org/viewvc/james/server/trunk/src/java/org/apache/james/management/VirtualUserTableManagement.xinfo?view=diff&rev=476918&r1=476917&r2=476918
==============================================================================
--- james/server/trunk/src/java/org/apache/james/management/VirtualUserTableManagement.xinfo (original)
+++ james/server/trunk/src/java/org/apache/james/management/VirtualUserTableManagement.xinfo Sun Nov 19 12:52:20 2006
@@ -7,9 +7,16 @@
     <version>1.0</version>
   </block>
 
+  <services>
+    <service name="org.apache.james.services.VirtualUserTableManagementService" version="1.0" />
+  </services>
+  
   <dependencies>
     <dependency>
       <service name="org.apache.james.services.VirtualUserTableStore" version="1.0"/>
+    </dependency>
+    <dependency>
+      <service name="org.apache.james.services.VirtualUserTableManagement" version="1.0"/>
     </dependency>
   </dependencies>
 </blockinfo>

Modified: james/server/trunk/src/java/org/apache/james/remotemanager/RemoteManager.java
URL: http://svn.apache.org/viewvc/james/server/trunk/src/java/org/apache/james/remotemanager/RemoteManager.java?view=diff&rev=476918&r1=476917&r2=476918
==============================================================================
--- james/server/trunk/src/java/org/apache/james/remotemanager/RemoteManager.java (original)
+++ james/server/trunk/src/java/org/apache/james/remotemanager/RemoteManager.java Sun Nov 19 12:52:20 2006
@@ -33,6 +33,7 @@
 import org.apache.james.services.SpoolManagementService;
 import org.apache.james.services.UsersRepository;
 import org.apache.james.services.UsersStore;
+import org.apache.james.services.VirtualUserTableManagementService;
 
 import java.util.HashMap;
 
@@ -91,6 +92,8 @@
      * reference to administration of Processors
      */
     private ProcessorManagementService processorManagementService;
+
+    private VirtualUserTableManagementService vutManagemenet;
     
     /**
      * Set the UserStore 
@@ -156,6 +159,15 @@
     }
     
     /**
+     * Set the VirtualUserTableManagementService
+     * 
+     * @param vutManagement the VirtualUserTableManagment 
+     */
+    public void setVirtualUserTableManagement(VirtualUserTableManagementService vutManagement) {
+    this.vutManagemenet = vutManagement;
+    }
+    
+    /**
      * The configuration data to be passed to the handler
      */
     private RemoteManagerHandlerConfigurationData theConfigData
@@ -184,7 +196,8 @@
         setSpoolManagement(spoolManagement);
         
         setBayesianAnalyzerManagement((BayesianAnalyzerManagementService) componentManager.lookup(BayesianAnalyzerManagementService.ROLE));     
-        setProcessorManagement((ProcessorManagementService) componentManager.lookup(ProcessorManagementService.ROLE));     
+        setProcessorManagement((ProcessorManagementService) componentManager.lookup(ProcessorManagementService.ROLE)); 
+        setVirtualUserTableManagement((VirtualUserTableManagementService) componentManager.lookup(VirtualUserTableManagementService.ROLE));
     }
 
     /**
@@ -304,9 +317,19 @@
             return RemoteManager.this.bayesianAnalyzerManagement;
         }
 
+        /**
+         * @see org.apache.james.remotemanager.RemoteManagerHandlerConfigurationData#getProcessorManagement()
+         */
         public ProcessorManagementService getProcessorManagement() {
             return RemoteManager.this.processorManagementService;
         }
+
+        /**
+         * @see org.apache.james.remotemanager.RemoteManagerHandlerConfigurationData#getVirtualUserTableManagement()
+         */
+    public VirtualUserTableManagementService getVirtualUserTableManagement() {
+        return RemoteManager.this.vutManagemenet;
+    }
     }
 
     /**

Modified: james/server/trunk/src/java/org/apache/james/remotemanager/RemoteManager.xinfo
URL: http://svn.apache.org/viewvc/james/server/trunk/src/java/org/apache/james/remotemanager/RemoteManager.xinfo?view=diff&rev=476918&r1=476917&r2=476918
==============================================================================
--- james/server/trunk/src/java/org/apache/james/remotemanager/RemoteManager.xinfo (original)
+++ james/server/trunk/src/java/org/apache/james/remotemanager/RemoteManager.xinfo Sun Nov 19 12:52:20 2006
@@ -46,5 +46,8 @@
     <dependency>
       <service name="org.apache.james.services.ProcessorManagementService" version="1.0"/>
     </dependency>
+    <dependency>
+      <service name="org.apache.james.services.VirtualUserTableManagementService" version="1.0"/>
+    </dependency>
   </dependencies>
 </blockinfo>

Modified: james/server/trunk/src/java/org/apache/james/remotemanager/RemoteManagerHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/src/java/org/apache/james/remotemanager/RemoteManagerHandler.java?view=diff&rev=476918&r1=476917&r2=476918
==============================================================================
--- james/server/trunk/src/java/org/apache/james/remotemanager/RemoteManagerHandler.java (original)
+++ james/server/trunk/src/java/org/apache/james/remotemanager/RemoteManagerHandler.java Sun Nov 19 12:52:20 2006
@@ -36,6 +36,7 @@
 import org.apache.james.core.AbstractJamesHandler;
 import org.apache.james.management.BayesianAnalyzerManagementException;
 import org.apache.james.management.SpoolFilter;
+import org.apache.james.management.VirtualUserTableManagementException;
 import org.apache.james.services.JamesUser;
 import org.apache.james.services.ProcessorManagementService;
 import org.apache.james.services.User;
@@ -88,6 +89,8 @@
         "LISTMATCHERS",
         "SHOWMAILETINFO",
         "SHOWMATCHERINFO",
+        "ADDMAPPING",
+        "REMOVEMAPPING",
         "QUIT",
         "SHUTDOWN"
     });
@@ -106,6 +109,9 @@
     private final static String REGEX_IDENTIFIER = "regex=";
     private final static String KEY_IDENTIFIER = "key=";
 
+    private final static String ADD_MAPPING_ACTION = "ADD_MAPPING";
+    private final static String REMOVE_MAPPING_ACTION = "REMOVE_MAPPING";
+
     /**
      * Set the configuration data for the handler.
      *
@@ -497,6 +503,8 @@
         out.println("showforwarding [username]                                               shows a user's current email forwarding");
         out.println("unsetforwarding [username]                                              removes a forward");
         out.println("user [repositoryname]                                                   change to another user repository");
+        out.println("addmapping [table=virtualusertablename] user@domain mapping             add mapping for the given emailaddress");
+        out.println("removemapping [table=virtualusertablename] user@domain mapping          remove mapping for the given emailaddress");
         out.println("listspool [spoolrepositoryname] ([header=name] [regex=value])           list all mails which reside in the spool and have an error state");
         out.println("flushspool [spoolrepositoryname] ([key] | [header=name] [regex=value])  try to resend the mail assing to the given key. If no key is given all mails get resend");
         out.println("deletespool [spoolrepositoryname] ([key] | [header=name] [regex=value]) delete the mail assign to the given key. If no key is given all mails get deleted");
@@ -1400,6 +1408,99 @@
             writeLoggedResponse("\t" + parameter);
          }
         return true;
+    }
+    
+    private boolean doADDMAPPING(String argument) {
+        String[] args = null;
+        
+        if (argument != null)
+            args = argument.split(" ");
+
+        // check if the command was called correct
+        if (argument == null || argument.trim().equals("") || args.length < 2 || args.length > 3) {
+            writeLoggedFlushedResponse("Usage: ADDMAPPING [table=table] user@domain mapping");
+            return true;
+        }
+        try {
+            out.println("Adding mapping successfull: " + mappingAction(args,ADD_MAPPING_ACTION));
+            out.flush();
+        } catch (VirtualUserTableManagementException e) {
+            getLogger().error("Error on adding mapping: " + e);
+            out.println("Error on adding mapping: " + e);
+            out.flush();
+        } catch (IllegalArgumentException e) {
+            getLogger().error("Error on adding mapping: " + e);
+            out.println("Error on adding mapping: " + e);
+            out.flush();
+        }
+        return true;
+    }
+    
+    private boolean doREMOVEMAPPING(String argument) {
+        String[] args = null;
+        
+        if (argument != null)
+            args = argument.split(" ");
+
+        // check if the command was called correct
+        if (argument == null || argument.trim().equals("") || args.length < 2 || args.length > 3) {
+            writeLoggedFlushedResponse("Usage: REMOVEMAPPING [table=table] user@domain mapping");
+            return true;
+        }
+        try {
+            out.println("Removing mapping successfull: " + mappingAction(args,REMOVE_MAPPING_ACTION));
+            out.flush();
+        } catch (VirtualUserTableManagementException e) {
+            getLogger().error("Error on  removing mapping: " + e);
+            out.println("Error on removing mapping: " + e);
+            out.flush();
+        } catch (IllegalArgumentException e) {
+            getLogger().error("Error on removing mapping: " + e);
+            out.println("Error on removing mapping: " + e);
+            out.flush();
+        }
+        return true;
+    }
+    
+    private String getMappingValue(String raw) {
+        if (raw.equals("*")) {
+            return null;
+        } else {
+            return raw;
+        }
+    }
+    
+    private boolean mappingAction(String[] args, String action) throws IllegalArgumentException, VirtualUserTableManagementException{ 
+        String table = null;
+        String user = null;
+        String domain = null;
+        String mapping = null;
+    
+        if (args[0].startsWith("table=")) {
+            table = args[0].substring("table=".length());
+            if (args[1].indexOf("@") > 0) {
+                user = getMappingValue(args[1].split("@")[0]);
+                domain = getMappingValue(args[1].split("@")[1]);
+            } else {
+                throw new IllegalArgumentException("Invalid usage.");
+            }
+            mapping = args[2];
+        } else {
+            if (args[0].indexOf("@") > 0) {
+                user = getMappingValue(args[0].split("@")[0]);
+                domain = getMappingValue(args[0].split("@")[1]);
+            } else {
+                throw new IllegalArgumentException("Invalid usage.");
+            }
+            mapping = args[1];
+        }
+        if (action.equals(ADD_MAPPING_ACTION)) {
+            return theConfigData.getVirtualUserTableManagement().addMapping(table, user, domain, mapping);
+        } else if (action.equals(REMOVE_MAPPING_ACTION)){
+            return theConfigData.getVirtualUserTableManagement().removeMapping(table, user, domain, mapping);
+        } else {
+            throw new IllegalArgumentException("Invalid action: " + action);
+        }   
     }
 
 }

Modified: james/server/trunk/src/java/org/apache/james/remotemanager/RemoteManagerHandlerConfigurationData.java
URL: http://svn.apache.org/viewvc/james/server/trunk/src/java/org/apache/james/remotemanager/RemoteManagerHandlerConfigurationData.java?view=diff&rev=476918&r1=476917&r2=476918
==============================================================================
--- james/server/trunk/src/java/org/apache/james/remotemanager/RemoteManagerHandlerConfigurationData.java (original)
+++ james/server/trunk/src/java/org/apache/james/remotemanager/RemoteManagerHandlerConfigurationData.java Sun Nov 19 12:52:20 2006
@@ -28,6 +28,7 @@
 import org.apache.james.services.SpoolManagementService;
 import org.apache.james.services.UsersRepository;
 import org.apache.james.services.UsersStore;
+import org.apache.james.services.VirtualUserTableManagementService;
 
 import java.util.HashMap;
 
@@ -109,5 +110,11 @@
      * @return the ProcessorManagementService
      */
     ProcessorManagementService getProcessorManagement();
-
+    
+    /**
+     * Return the VirtualUserTableManagementService
+     * 
+     * @return the VirtualUserTableManagementService
+     */
+    VirtualUserTableManagementService getVirtualUserTableManagement();
 }

Modified: james/server/trunk/src/java/org/apache/james/vut/AbstractVirtualUserTable.java
URL: http://svn.apache.org/viewvc/james/server/trunk/src/java/org/apache/james/vut/AbstractVirtualUserTable.java?view=diff&rev=476918&r1=476917&r2=476918
==============================================================================
--- james/server/trunk/src/java/org/apache/james/vut/AbstractVirtualUserTable.java (original)
+++ james/server/trunk/src/java/org/apache/james/vut/AbstractVirtualUserTable.java Sun Nov 19 12:52:20 2006
@@ -69,7 +69,7 @@
     public Collection getMappings(String user,String domain) throws ErrorMappingException {
 
         String targetString = mapAddress(user, domain);
-
+        
         // Only non-null mappings are translated
         if (targetString != null) {
             Collection mappings = new ArrayList();
@@ -120,14 +120,19 @@
     /**
      * @see org.apache.james.services.VirtualUserTableManagement#addRegexMapping(java.lang.String, java.lang.String, java.lang.String)
      */
-    public synchronized boolean addRegexMapping(String user, String domain, String regex) throws InvalidMappingException {
-        getLogger().info("Add regex mapping => " + regex + " for user: " + user + " domain: " + domain);
+    public synchronized boolean addRegexMapping(String user, String domain, String regex) throws InvalidMappingException {     
         try {
             new Perl5Compiler().compile(regex);
         } catch (MalformedPatternException e) {
             throw new InvalidMappingException("Invalid regex: " + regex);
         }
-        return addMappingInternal(user, domain, "regex:" + regex);
+        
+        if (checkMapping(user,domain,regex) == true) {
+            getLogger().info("Add regex mapping => " + regex + " for user: " + user + " domain: " + domain);
+            return addMappingInternal(user, domain, "regex:" + regex);
+        } else {
+            return false;
+        }
     }
 
     
@@ -136,7 +141,7 @@
      * @see org.apache.james.services.VirtualUserTableManagement#removeRegexMapping(java.lang.String, java.lang.String, java.lang.String)
      */
     public synchronized boolean removeRegexMapping(String user, String domain, String regex) throws InvalidMappingException {
-        getLogger().info("Add regex mapping => " + regex + " for user: " + user + " domain: " + domain);
+        getLogger().info("Remove regex mapping => " + regex + " for user: " + user + " domain: " + domain);
         return removeMappingInternal(user,domain,"regex:" + regex);
     }
     
@@ -144,7 +149,6 @@
      * @see org.apache.james.services.VirtualUserTableManagement#addAddressMapping(java.lang.String, java.lang.String, java.lang.String)
      */
     public synchronized boolean addAddressMapping(String user, String domain, String address) throws InvalidMappingException {
-
         if (address.indexOf('@') < 0) {
             address =  address + "@localhost";
         } 
@@ -153,20 +157,22 @@
         } catch (ParseException e) {
             throw new InvalidMappingException("Invalid emailAddress: " + address);
         }
-        getLogger().info("Add address mapping => " + address + " for user: " + user + " domain: " + domain);
-        return addMappingInternal(user, domain, address);
+        if (checkMapping(user,domain,address) == true) {          
+            getLogger().info("Add address mapping => " + address + " for user: " + user + " domain: " + domain);
+            return addMappingInternal(user, domain, address);
+        } else {
+            return false;
+        }   
     }
     
     /**
-     * @throws InvalidMappingException 
      * @see org.apache.james.services.VirtualUserTableManagement#removeAddressMapping(java.lang.String, java.lang.String, java.lang.String)
      */
     public synchronized boolean removeAddressMapping(String user, String domain, String address) throws InvalidMappingException {
-
         if (address.indexOf('@') < 0) {
             address =  address + "@localhost";
         } 
-        getLogger().info("Add address mapping => " + address + " for user: " + user + " domain: " + domain);
+        getLogger().info("Remove address mapping => " + address + " for user: " + user + " domain: " + domain);
         return removeMappingInternal(user,domain,address);
     }
     
@@ -174,17 +180,19 @@
      * @see org.apache.james.services.VirtualUserTableManagement#addErrorMapping(java.lang.String, java.lang.String, java.lang.String)
      */
     public synchronized boolean addErrorMapping(String user, String domain, String error) throws InvalidMappingException {   
-        getLogger().info("Add error mapping => " + error + " for user: " + user + " domain: " + domain);
-        
-        return addMappingInternal(user,domain, "error:" + error);
+        if (checkMapping(user,domain,error) == true) {          
+            getLogger().info("Add error mapping => " + error + " for user: " + user + " domain: " + domain);
+            return addMappingInternal(user,domain, "error:" + error);
+        } else {
+            return false;
+        } 
     }
     
     /**
      * @see org.apache.james.services.VirtualUserTableManagement#removeErrorMapping(java.lang.String, java.lang.String, java.lang.String)
      */
     public synchronized boolean removeErrorMapping(String user, String domain, String error) throws InvalidMappingException {
-        getLogger().info("Add error mapping => " + error + " for user: " + user + " domain: " + domain);     
-    
+        getLogger().info("Remove error mapping => " + error + " for user: " + user + " domain: " + domain);     
         return removeMappingInternal(user,domain,"error:" + error);
     }
 
@@ -261,6 +269,20 @@
             }
         }  
         return mapping.toString();  
+   }
+    
+   private boolean checkMapping(String user,String domain, String mapping) {
+       Collection mappings;
+       try {
+           mappings = getMappings(user,domain);
+       } catch (ErrorMappingException e) {
+           return false;
+       }
+       if (mappings != null && mappings.contains(mapping)) {
+           return false;
+       } else {
+           return true;
+       }
    }
 
  



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