You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by mm...@apache.org on 2001/08/21 21:04:14 UTC

cvs commit: xml-cocoon2/src/org/apache/cocoon/acting DatabaseAuthenticatorAction.java

mman        01/08/21 12:04:14

  Modified:    src/org/apache/cocoon/acting
                        DatabaseAuthenticatorAction.java
  Log:
  Added ability to have "nullable" form parameters, these are excluded from auth sql query if they don't exist.
  FIXME: add to documentation
  
  Revision  Changes    Path
  1.10      +21 -11    xml-cocoon2/src/org/apache/cocoon/acting/DatabaseAuthenticatorAction.java
  
  Index: DatabaseAuthenticatorAction.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/acting/DatabaseAuthenticatorAction.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- DatabaseAuthenticatorAction.java	2001/08/20 13:55:09	1.9
  +++ DatabaseAuthenticatorAction.java	2001/08/21 19:04:14	1.10
  @@ -1,4 +1,4 @@
  -// $Id: DatabaseAuthenticatorAction.java,v 1.9 2001/08/20 13:55:09 dims Exp $
  +// $Id: DatabaseAuthenticatorAction.java,v 1.10 2001/08/21 19:04:14 mman Exp $
   package org.apache.cocoon.acting;
   
   import org.apache.avalon.excalibur.datasource.DataSourceComponent;
  @@ -50,7 +50,7 @@
    * not verified.
    *
    * @author Martin Man <Martin.Man@seznam.cz>
  - * @version CVS $Revision: 1.9 $ $Date: 2001/08/20 13:55:09 $
  + * @version CVS $Revision: 1.10 $ $Date: 2001/08/21 19:04:14 $
    */
   public class DatabaseAuthenticatorAction extends AbstractDatabaseAction
   {
  @@ -156,7 +156,8 @@
           boolean first_constraint = true;
           StringBuffer queryBuffer = new StringBuffer ("SELECT ");
           StringBuffer queryBufferEnd = new StringBuffer ("");
  -        String dbcol, request_param, request_value;
  +        String dbcol, request_param, request_value, nullstr;
  +        boolean nullable = false;
           Configuration table = conf.getChild ("table");
           Configuration[] select = table.getChildren ("select");
           try {
  @@ -171,6 +172,11 @@
                               request_param.trim().equals ("")) {
                           continue;
                       }
  +                    nullstr = select[i].getAttribute ("nullable");
  +                    if (nullstr != null) nullstr = nullstr.trim ();
  +                    if ("yes".equals (nullstr) || "true".equals (nullstr)) {
  +                        nullable = true;
  +                    }
                   } catch (Exception e) {
                       continue;
                   }
  @@ -180,14 +186,18 @@
                   request_value = req.getParameter (
                           request_param);
                   if (request_value == null || request_value.trim().equals ("")) {
  -                    getLogger ().debug ("DBAUTH: request-param "
  -                            + request_param + " does not exist");
  -                    return null;
  +                    // value is null
  +                    if (!nullable) {
  +                        getLogger ().debug ("DBAUTH: request-param "
  +                                + request_param + " does not exist");
  +                        return null;
  +                    }
  +                } else {
  +                    if (!first_constraint)
  +                        queryBufferEnd.append (" AND ");
  +                    queryBufferEnd.append (dbcol + "='" + request_value + "'");
  +                    first_constraint = false;
                   }
  -                if (!first_constraint)
  -                    queryBufferEnd.append (" AND ");
  -                queryBufferEnd.append (dbcol + "='" + request_value + "'");
  -                first_constraint = false;
               }
               queryBuffer.append (" FROM ");
               queryBuffer.append (table.getAttribute ("name"));
  @@ -251,5 +261,5 @@
       }
   }
   
  -// $Id: DatabaseAuthenticatorAction.java,v 1.9 2001/08/20 13:55:09 dims Exp $
  +// $Id: DatabaseAuthenticatorAction.java,v 1.10 2001/08/21 19:04:14 mman Exp $
   // vim: set et ts=4 sw=4:
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          cocoon-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-cvs-help@xml.apache.org