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/10/15 13:12:32 UTC

svn commit: r464155 - in /james/server/trunk/src/java/org/apache/james/vut: AbstractVirtualUserTable.java JDBCVirtualUserTable.xinfo

Author: norman
Date: Sun Oct 15 04:12:29 2006
New Revision: 464155

URL: http://svn.apache.org/viewvc?view=rev&rev=464155
Log:
Fix mapping creation after reread the documentation. See JAMES-582

Modified:
    james/server/trunk/src/java/org/apache/james/vut/AbstractVirtualUserTable.java
    james/server/trunk/src/java/org/apache/james/vut/JDBCVirtualUserTable.xinfo

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=464155&r1=464154&r2=464155
==============================================================================
--- james/server/trunk/src/java/org/apache/james/vut/AbstractVirtualUserTable.java (original)
+++ james/server/trunk/src/java/org/apache/james/vut/AbstractVirtualUserTable.java Sun Oct 15 04:12:29 2006
@@ -38,6 +38,8 @@
 
 public abstract class AbstractVirtualUserTable extends AbstractLogEnabled
     implements VirtualUserTable, VirtualUserTableManagement {
+    
+    private static String WILDCARD = "%";
 
     /**
      * @see org.apache.james.services.VirtualUserTable#getMapping(org.apache.mailet.MailAddress)
@@ -206,42 +208,40 @@
    }
     
     /**
-     * Return true if the userString is valid
-     * TODO: More checkin ?
+     * Return user String for the given argument
      * 
-     * @param user the userString
-     * @return true of false
-     * @throws InvalidMappingException 
+     * @param user the given user String
+     * @return user the user String
+     * @throws InvalidMappingException get thrown on invalid argument
      */
     private String getUserString(String user) throws InvalidMappingException {
         if (user != null) {
-            if(user.endsWith("@%") || user.indexOf("@") < 0) {
+            if(user.equals(WILDCARD) || user.indexOf("@") < 0) {
                 return user;
             } else {
                 throw new InvalidMappingException("Invalid user: " + user);
             }
         } else {
-            return "";
+            return WILDCARD;
         }
     }
     
     /**
-     * Return true if the domainString is valid
-     * TODO: More checkin ?
+     * Return domain String for the given argument
      * 
-     * @param domain the domainString
-     * @return true of false
-     * @throws InvalidMappingException 
+     * @param domain the given domain String
+     * @return domainString the domain String
+     * @throws InvalidMappingException get thrown on invalid argument
      */
     private String getDomainString(String domain) throws InvalidMappingException {
         if(domain != null) {
-            if (domain.startsWith("%@") || domain.indexOf("@") < 0) {
+            if (domain.equals(WILDCARD) || domain.indexOf("@") < 0) {
                 return domain;  
             } else {
                 throw new InvalidMappingException("Invalid domain: " + domain);
             }
         } else {
-            return "";
+            return WILDCARD;
         }
     }
     

Modified: james/server/trunk/src/java/org/apache/james/vut/JDBCVirtualUserTable.xinfo
URL: http://svn.apache.org/viewvc/james/server/trunk/src/java/org/apache/james/vut/JDBCVirtualUserTable.xinfo?view=diff&rev=464155&r1=464154&r2=464155
==============================================================================
--- james/server/trunk/src/java/org/apache/james/vut/JDBCVirtualUserTable.xinfo (original)
+++ james/server/trunk/src/java/org/apache/james/vut/JDBCVirtualUserTable.xinfo Sun Oct 15 04:12:29 2006
@@ -12,12 +12,6 @@
     <service name="org.apache.james.services.VirtualUserTable" version="1.0" />
   </services>
   
-  <!-- interfaces that may be exported to manange this block -->
-  <!--
-  <management-access-points>
-    <service name="org.apache.james.management.BayesianAnalyzerManagementMBean"/>
-  </management-access-points>
--->
   <dependencies>
     <dependency>
       <service name="org.apache.avalon.cornerstone.services.datasources.DataSourceSelector" version="1.0"/>



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


VirtualUserTable refactorings

Posted by "Noel J. Bergman" <no...@devtech.com>.
> AbstractVirtualUserTable.java

> Fix mapping creation after reread the documentation.

If that's what the docs actually say, they are wrong.

>  public abstract class AbstractVirtualUserTable extends AbstractLogEnabled
>      implements VirtualUserTable, VirtualUserTableManagement {
> +    
> +    private static String WILDCARD = "%";

This shouldn't be here at all.

AbstractVirtualUserTable intentionally defers thins to the implementations.  The XML version defines '*' as a limited wildcard.  For JDBC, the query carries the wildcard character to the query engine, so the JDBC VUT doesn't need to understand it at all.  

The two uses are similar, but use different characters (* is normally expected, and % would be weird to impose on non-SQL users) and are implemented totally differently, since the goal for any database functionality should be to let the database handle as much as possible.

For more sophisticated uses, regex is supported, with examples.

Speaking of JDBC, e might add a VirtualUserTable section to sqlResources, and use that to handle different databases, rather than just use a query property.

It appears that you're introducing code that doesn't belong here.  Please review how the current system works and explain what you are trying to accomplish, other than refactoring the code to allow it to be called as a utility.

	--- Noel



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