Author: norman
Date: Sun Nov 19 08:33:39 2006
New Revision: 476846

URL: http://svn.apache.org/viewvc?view=rev&rev=476846
Log:
Add Managment Service for VUT. First step of JAMES-706

Added:
    
james/server/trunk/src/java/org/apache/james/management/VirtualUserTableManagement.java
   (with props)
    
james/server/trunk/src/java/org/apache/james/management/VirtualUserTableManagement.xinfo
    
james/server/trunk/src/java/org/apache/james/management/VirtualUserTableManagementException.java
   (with props)
    
james/server/trunk/src/java/org/apache/james/services/VirtualUserTableManagementService.java
   (with props)
Modified:
    james/server/trunk/src/conf/james-assembly.xml
    
james/server/trunk/src/java/org/apache/james/core/AvalonVirtualUserTableStore.java
    
james/server/trunk/src/java/org/apache/james/core/DefaultVirtualUserTable.java
    
james/server/trunk/src/java/org/apache/james/services/VirtualUserTableManagement.java
    
james/server/trunk/src/java/org/apache/james/vut/AbstractVirtualUserTable.java
    james/server/trunk/src/java/org/apache/james/vut/JDBCVirtualUserTable.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=476846&r1=476845&r2=476846
==============================================================================
--- james/server/trunk/src/conf/james-assembly.xml (original)
+++ james/server/trunk/src/conf/james-assembly.xml Sun Nov 19 08:33:39 2006
@@ -223,6 +223,10 @@
   <block name="filesystem" class="org.apache.james.context.AvalonFileSystem">
   </block>
   
+  <!-- The VirtualUserTable Management block  -->
+  <block name="virtualusertablemanagement" 
class="org.apache.james.management.VirtualUserTableManagement" >
+    <provide name="virtualusertable-store" 
role="org.apache.james.services.VirtualUserTableStore"/>
+  </block>
   
   <!-- VirtualUserTable Store -->
   <block name="virtualusertable-store" 
class="org.apache.james.core.AvalonVirtualUserTableStore">

Modified: 
james/server/trunk/src/java/org/apache/james/core/AvalonVirtualUserTableStore.java
URL: 
http://svn.apache.org/viewvc/james/server/trunk/src/java/org/apache/james/core/AvalonVirtualUserTableStore.java?view=diff&rev=476846&r1=476845&r2=476846
==============================================================================
--- 
james/server/trunk/src/java/org/apache/james/core/AvalonVirtualUserTableStore.java
 (original)
+++ 
james/server/trunk/src/java/org/apache/james/core/AvalonVirtualUserTableStore.java
 Sun Nov 19 08:33:39 2006
@@ -82,6 +82,6 @@
      * @see org.apache.james.core.AbstractAvalonStore#getStoreName()
      */
     public String getStoreName() {
-        return "AvalonVirtualUserStore";
+        return "AvalonVirtualUserTableStore";
     }
 }

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=476846&r1=476845&r2=476846
==============================================================================
--- 
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 08:33:39 2006
@@ -114,4 +114,17 @@
         return vut.getMappings(user, domain);
     }
 
+    /**
+     * @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);
+    }
+
+    /**
+     * @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);
+    }
 }

Added: 
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=auto&rev=476846
==============================================================================
--- 
james/server/trunk/src/java/org/apache/james/management/VirtualUserTableManagement.java
 (added)
+++ 
james/server/trunk/src/java/org/apache/james/management/VirtualUserTableManagement.java
 Sun Nov 19 08:33:39 2006
@@ -0,0 +1,173 @@
+/****************************************************************
+ * 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.management;
+
+import java.util.Collection;
+
+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.services.VirtualUserTableManagementService;
+import org.apache.james.services.VirtualUserTableStore;
+import org.apache.james.vut.InvalidMappingException;
+
+
+/**
+ * Management for VirtualUserTables
+ * 
+ * TODO: Add JMX support
+ *       Add to RemoteManager
+ */
+public class VirtualUserTableManagement implements Serviceable, 
VirtualUserTableManagementService {
+
+    AvalonVirtualUserTableStore store;
+    
+
+    /**
+     * @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));
+    }
+
+    public void setAvalonVirtualUserTableStore(AvalonVirtualUserTableStore 
store) {
+        this.store = store;
+    }
+    
+    /**
+     * Return a VirtualUserTableManagement with the given tablename
+     * 
+     * @param tableName tableName
+     * @return VirtualUserTableManagement object
+     * @throws VirtualUserTableManagementException if no VirtualUserTable with 
the given name exists
+     */
+    private org.apache.james.services.VirtualUserTableManagement 
getTable(String tableName) throws VirtualUserTableManagementException {
+        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;
+        }
+    }
+    
+    /**
+     * @see 
org.apache.james.services.VirtualUserTableManagementService#addAddressMapping(java.lang.String,
 java.lang.String, java.lang.String, java.lang.String)
+     */
+    public boolean addAddressMapping(String virtualUserTable, String user, 
String domain, String address) throws  VirtualUserTableManagementException {
+        try {
+            return getTable(virtualUserTable).addAddressMapping(user, domain, 
address);
+        } catch (InvalidMappingException e) {
+            throw new VirtualUserTableManagementException(e);
+        }
+    }
+
+    /**
+     * @see 
org.apache.james.services.VirtualUserTableManagementService#addErrorMapping(java.lang.String,
 java.lang.String, java.lang.String, java.lang.String)
+     */
+    public boolean addErrorMapping(String virtualUserTable, String user, 
String domain, String error) throws VirtualUserTableManagementException {
+        try {
+            return getTable(virtualUserTable).addErrorMapping(user, domain, 
error);
+        } catch (InvalidMappingException e) {
+            throw new VirtualUserTableManagementException(e);
+        }
+    }
+
+    /**
+     * @see 
org.apache.james.services.VirtualUserTableManagementService#addRegexMapping(java.lang.String,
 java.lang.String, java.lang.String, java.lang.String)
+     */
+    public boolean addRegexMapping(String virtualUserTable, String user, 
String domain, String regex) throws VirtualUserTableManagementException {
+        try {
+            return getTable(virtualUserTable).addRegexMapping(user, domain, 
regex);
+        } catch (InvalidMappingException e) {
+            throw new VirtualUserTableManagementException(e);
+        }
+    }
+
+    /**
+     * @see 
org.apache.james.services.VirtualUserTableManagementService#getUserDomainMappings(java.lang.String,
 java.lang.String, java.lang.String)
+     */
+    public Collection getUserDomainMappings(String virtualUserTable, String 
user, String domain) throws VirtualUserTableManagementException {
+        try {
+            return getTable(virtualUserTable).getUserDomainMappings(user, 
domain);
+        } catch (InvalidMappingException e) {
+            throw new VirtualUserTableManagementException(e);
+        }
+    }
+
+    /**
+     * @see 
org.apache.james.services.VirtualUserTableManagementService#removeAddressMapping(java.lang.String,
 java.lang.String, java.lang.String, java.lang.String)
+     */
+    public boolean removeAddressMapping(String virtualUserTable, String user, 
String domain, String address) throws VirtualUserTableManagementException {
+        try {
+            return getTable(virtualUserTable).removeAddressMapping(user, 
domain, address);
+        } catch (InvalidMappingException e) {
+            throw new VirtualUserTableManagementException(e);
+        }
+    }
+
+    /**
+     * @see 
org.apache.james.services.VirtualUserTableManagementService#removeErrorMapping(java.lang.String,
 java.lang.String, java.lang.String, java.lang.String)
+     */
+    public boolean removeErrorMapping(String virtualUserTable, String user, 
String domain, String error) throws VirtualUserTableManagementException {
+        try {
+            return getTable(virtualUserTable).removeErrorMapping(user, domain, 
error);
+        } catch (InvalidMappingException e) {
+            throw new VirtualUserTableManagementException(e);
+        }
+    }
+
+    /**
+     * @see 
org.apache.james.services.VirtualUserTableManagementService#removeRegexMapping(java.lang.String,
 java.lang.String, java.lang.String, java.lang.String)
+     */
+    public boolean removeRegexMapping(String virtualUserTable, String user, 
String domain, String regex) throws VirtualUserTableManagementException {
+        try {
+            return getTable(virtualUserTable).removeRegexMapping(user, domain, 
regex);
+        } catch (InvalidMappingException e) {
+            throw new VirtualUserTableManagementException(e);
+        }
+    }
+
+    /**
+     * @see 
org.apache.james.services.VirtualUserTableManagementService#addMapping(java.lang.String,
 java.lang.String, java.lang.String, java.lang.String)
+     */
+    public boolean addMapping(String virtualUserTable, String user, String 
domain, String mapping) throws VirtualUserTableManagementException {
+        try {
+            return getTable(virtualUserTable).addMapping(user, domain, 
mapping);
+        } catch (InvalidMappingException e) {
+            throw new VirtualUserTableManagementException(e);
+        }
+    }
+
+    /**
+     * @see 
org.apache.james.services.VirtualUserTableManagementService#removeMapping(java.lang.String,
 java.lang.String, java.lang.String, java.lang.String)
+     */
+    public boolean removeMapping(String virtualUserTable, String user, String 
domain, String mapping) throws VirtualUserTableManagementException {
+        try {
+            return getTable(virtualUserTable).removeMapping(user, domain, 
mapping);
+        } catch (InvalidMappingException e) {
+            throw new VirtualUserTableManagementException(e);
+        }
+    }
+}

Propchange: 
james/server/trunk/src/java/org/apache/james/management/VirtualUserTableManagement.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
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=auto&rev=476846
==============================================================================
--- 
james/server/trunk/src/java/org/apache/james/management/VirtualUserTableManagement.xinfo
 (added)
+++ 
james/server/trunk/src/java/org/apache/james/management/VirtualUserTableManagement.xinfo
 Sun Nov 19 08:33:39 2006
@@ -0,0 +1,15 @@
+<?xml version="1.0"?>
+
+<blockinfo>
+
+  <!-- section to describe block -->
+  <block>
+    <version>1.0</version>
+  </block>
+
+  <dependencies>
+    <dependency>
+      <service name="org.apache.james.services.VirtualUserTableStore" 
version="1.0"/>
+    </dependency>
+  </dependencies>
+</blockinfo>

Added: 
james/server/trunk/src/java/org/apache/james/management/VirtualUserTableManagementException.java
URL: 
http://svn.apache.org/viewvc/james/server/trunk/src/java/org/apache/james/management/VirtualUserTableManagementException.java?view=auto&rev=476846
==============================================================================
--- 
james/server/trunk/src/java/org/apache/james/management/VirtualUserTableManagementException.java
 (added)
+++ 
james/server/trunk/src/java/org/apache/james/management/VirtualUserTableManagementException.java
 Sun Nov 19 08:33:39 2006
@@ -0,0 +1,43 @@
+/****************************************************************
+ * 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.management;
+
+public class VirtualUserTableManagementException extends ManagementException {
+
+    public VirtualUserTableManagementException() {
+        super();
+    }
+
+    public VirtualUserTableManagementException(String message) {
+        super(message);
+    }
+
+    public VirtualUserTableManagementException(Exception e) {
+        super(e);
+    }
+    
+    public VirtualUserTableManagementException(String message, Exception e) {
+        super(message, e);
+    }
+
+}

Propchange: 
james/server/trunk/src/java/org/apache/james/management/VirtualUserTableManagementException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: 
james/server/trunk/src/java/org/apache/james/services/VirtualUserTableManagement.java
URL: 
http://svn.apache.org/viewvc/james/server/trunk/src/java/org/apache/james/services/VirtualUserTableManagement.java?view=diff&rev=476846&r1=476845&r2=476846
==============================================================================
--- 
james/server/trunk/src/java/org/apache/james/services/VirtualUserTableManagement.java
 (original)
+++ 
james/server/trunk/src/java/org/apache/james/services/VirtualUserTableManagement.java
 Sun Nov 19 08:33:39 2006
@@ -108,4 +108,26 @@
      * @throws InvalidMappingException  get thrown if an invalid use or domain 
was given
      */
     public Collection getUserDomainMappings(String user, String domain) throws 
InvalidMappingException;
+    
+    /**
+     * Add mapping
+     * 
+     * @param user the username. Null if no username should be used
+     * @param domain the domain. Null if no domain should be used
+     * @param mapping the mapping
+     * @return true if successfully
+     * @throws InvalidMappingException
+     */
+    public boolean addMapping(String user, String domain, String mapping) 
throws InvalidMappingException;
+    
+    /**
+     * Remove mapping
+     * 
+     * @param user the username. Null if no username should be used
+     * @param domain the domain. Null if no domain should be used
+     * @param mapping the mapping
+     * @return true if successfully
+     * @throws InvalidMappingException
+     */
+    public boolean removeMapping(String user, String domain, String mapping) 
throws InvalidMappingException;
 }

Added: 
james/server/trunk/src/java/org/apache/james/services/VirtualUserTableManagementService.java
URL: 
http://svn.apache.org/viewvc/james/server/trunk/src/java/org/apache/james/services/VirtualUserTableManagementService.java?view=auto&rev=476846
==============================================================================
--- 
james/server/trunk/src/java/org/apache/james/services/VirtualUserTableManagementService.java
 (added)
+++ 
james/server/trunk/src/java/org/apache/james/services/VirtualUserTableManagementService.java
 Sun Nov 19 08:33:39 2006
@@ -0,0 +1,143 @@
+/****************************************************************
+ * 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.services;
+
+import java.util.Collection;
+
+import org.apache.james.management.VirtualUserTableManagementException;
+import org.apache.james.vut.InvalidMappingException;
+
+public interface VirtualUserTableManagementService {
+    
+    /**
+     * The component role used by components implementing this service
+     */
+    public static final String ROLE = 
"org.apache.james.services.VirtualUserTableManagementService";
+
+    /**
+     * Add regex mapping
+     * 
+     * @param virtualUserTable The virtualUserTable 
+     * @param user the username. Null if no username should be used
+     * @param domain the domain. Null if no domain should be used
+     * @param regex the regex.
+     * @return true if successfully
+     * @throws InvalidMappingException get thrown if an invalid argument was 
given
+     */
+    public boolean addRegexMapping(String virtualUserTable, String user, 
String domain, String regex) throws VirtualUserTableManagementException;
+    
+    /**
+     * Remove regex mapping
+     * 
+     * @param virtualUserTable The virtualUserTable 
+     * @param user the username. Null if no username should be used
+     * @param domain the domain. Null if no domain should be used
+     * @param regex the regex.
+     * @return true if successfully
+     * @throws InvalidMappingException get thrown if an invalid argument was 
given
+     */
+    public boolean removeRegexMapping(String virtualUserTable, String 
user,String domain, String regex) throws VirtualUserTableManagementException;
+    
+    /***
+     * Add address mapping
+     * 
+     * @param virtualUserTable The virtualUserTable 
+     * @param user the username. Null if no username should be used
+     * @param domain the domain. Null if no domain should be used
+     * @param regex the regex.
+     * @return true if successfully
+     * @throws InvalidMappingException get thrown if an invalid argument was 
given
+     */
+    public boolean addAddressMapping(String virtualUserTable, String user, 
String domain, String address) throws VirtualUserTableManagementException;
+    
+    /**
+     * Remove address mapping
+     *
+     * @param virtualUserTable The virtualUserTable 
+     * @param user the username. Null if no username should be used
+     * @param domain the domain. Null if no domain should be used
+     * @param regex the regex.
+     * @return true if successfully
+     * @throws InvalidMappingException get thrown if an invalid argument was 
given
+     */
+    public boolean removeAddressMapping(String virtualUserTable, String 
user,String domain, String address) throws VirtualUserTableManagementException;
+    
+    /**
+     * Add error mapping
+     *
+     * @param virtualUserTable The virtualUserTable 
+     * @param user the username. Null if no username should be used
+     * @param domain the domain. Null if no domain should be used
+     * @param regex the regex.
+     * @return true if successfully
+     * @throws InvalidMappingException get thrown if an invalid argument was 
given
+     */
+    public boolean addErrorMapping(String virtualUserTable, String user, 
String domain, String error) throws VirtualUserTableManagementException;
+
+    /**
+     * Remove error mapping
+     *
+     * @param virtualUserTable The virtualUserTable 
+     * @param user the username. Null if no username should be used
+     * @param domain the domain. Null if no domain should be used
+     * @param regex the regex.
+     * @return true if successfully
+     * @throws InvalidMappingException get thrown if an invalid argument was 
given
+     */
+    public boolean removeErrorMapping(String virtualUserTable, String 
user,String domain, String error) throws VirtualUserTableManagementException;
+    
+    /**
+     * Return the explicit mapping stored for the given user and domain. 
Return null
+     * if no mapping was found
+     *
+     * @param virtualUserTable The virtualUserTable     
+     * @param user the username
+     * @param domain the domain
+     * @return the collection which holds the mappings. 
+     * @throws InvalidMappingException  get thrown if an invalid use or domain 
was given
+     */
+    public Collection getUserDomainMappings(String virtualUserTable, String 
user, String domain) throws VirtualUserTableManagementException;
+    
+    /**
+    * Try to identify the right method based on the prefix of the mapping and 
add it.
+    *
+    * @param virtualUserTable The virtualUserTable 
+    * @param user the username. Null if no username should be used
+    * @param domain the domain. Null if no domain should be used
+    * @param mapping the mapping.
+    * @return true if successfully
+    * @throws InvalidMappingException get thrown if an invalid argument was 
given
+    */
+    public boolean addMapping(String virtualUserTable, String user, String 
domain, String mapping) throws VirtualUserTableManagementException;
+    
+    /**
+     * Try to identify the right method based on the prefix of the mapping and 
remove it.
+     *
+     * @param virtualUserTable The virtualUserTable 
+     * @param user the username. Null if no username should be used
+     * @param domain the domain. Null if no domain should be used
+     * @param mapping the mapping.
+     * @return true if successfully
+     * @throws InvalidMappingException get thrown if an invalid argument was 
given
+     */
+    public boolean removeMapping(String virtualUserTable, String user, String 
domain, String mapping) throws VirtualUserTableManagementException;
+}

Propchange: 
james/server/trunk/src/java/org/apache/james/services/VirtualUserTableManagementService.java
------------------------------------------------------------------------------
    svn:eol-style = native

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=476846&r1=476845&r2=476846
==============================================================================
--- 
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 08:33:39 2006
@@ -190,6 +190,40 @@
 
 
     /**
+     * @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 {
+        String map = mapping.toLowerCase();
+        String errorPrefix = "error:";
+        String regexPrefix = "regex:";
+    
+        if (map.startsWith(errorPrefix)) {
+            return 
addErrorMapping(user,domain,map.substring(errorPrefix.length()));
+        } else if (map.startsWith(regexPrefix)) {
+            return 
addRegexMapping(user,domain,map.substring(regexPrefix.length()));
+        } else {
+            return addAddressMapping(user,domain,map);
+        }
+    }
+    
+    /**
+     * @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 {
+        String map = mapping.toLowerCase();
+        String errorPrefix = "error:";
+        String regexPrefix = "regex:";
+    
+        if (map.startsWith(errorPrefix)) {
+            return 
removeErrorMapping(user,domain,map.substring(errorPrefix.length()));
+        } else if (map.startsWith(regexPrefix)) {
+            return 
removeRegexMapping(user,domain,map.substring(regexPrefix.length()));
+        } else {
+            return removeAddressMapping(user,domain,map);
+        }
+    }
+    
+    /**
      * Convert a raw mapping String to a Collection
      * 
      * @param rawMapping the mapping Strin

Modified: 
james/server/trunk/src/java/org/apache/james/vut/JDBCVirtualUserTable.java
URL: 
http://svn.apache.org/viewvc/james/server/trunk/src/java/org/apache/james/vut/JDBCVirtualUserTable.java?view=diff&rev=476846&r1=476845&r2=476846
==============================================================================
--- james/server/trunk/src/java/org/apache/james/vut/JDBCVirtualUserTable.java 
(original)
+++ james/server/trunk/src/java/org/apache/james/vut/JDBCVirtualUserTable.java 
Sun Nov 19 08:33:39 2006
@@ -295,7 +295,7 @@
             map.remove(mapping);
             return updateMapping(newUser,newDomain,CollectionToMapping(map));
         } else {
-            return removeMapping(newUser,newDomain,mapping);
+            return removeRawMapping(newUser,newDomain,mapping);
         }
     }
 
@@ -313,7 +313,7 @@
         
             return updateMapping(newUser,newDomain,CollectionToMapping(map));
         }
-        return addMapping(newUser,newDomain,regex);
+        return addRawMapping(newUser,newDomain,regex);
     }
     
     /**
@@ -364,7 +364,7 @@
      * @param mapping the mapping
      * @return true if succesfully
      */
-    private boolean removeMapping(String user, String domain, String mapping) {
+    private boolean removeRawMapping(String user, String domain, String 
mapping) {
         Connection conn = null;
         PreparedStatement mappingStmt = null;
 
@@ -402,7 +402,7 @@
      * @param mapping the mapping 
      * @return true if successfully
      */
-    private boolean addMapping(String user, String domain, String mapping) {
+    private boolean addRawMapping(String user, String domain, String mapping) {
         Connection conn = null;
         PreparedStatement mappingStmt = null;
 



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to