For my implementation of Turbine, I have added the concept of an 'active'
and an 'inactive' account by adding a column to the Visitor table.
To insure that I only get active accounts when validating a login, I added
a Criteria line to TurbineUser.retrieveFromStorage( username ) method.

This works fine, but I'm thinking that others may want to perform their own
customizations and a small code change would alleviate the need for them to
extend TurbineUser to set their own criteria.

If we added a retrieveFromStorage method that also accepted a Criteria
object, then the programmer could set the special Criteria and simply use
the existing TurbineUser class.  In this scenario, I would modify the
existing retrieveFromStorage method to instantiate a Criteria object, not
set any special restrictions and then pass it to the method (which would
proceed to set the username in the Criteria as before).

This would look something like this:

>>>>>>>  Code   >>>>>>>

//  Current method with change  //
public User retrieveFromStorage( String username ) throws Exception
{
   Criteria criteria = new Criteria();
   return retrieveFromStorage( username, criteria );
}

//  Proposed method  //
public User retrieveFromStorage( String username, Criteria criteria )
      throws Exception
{
   criteria.add( TurbineUserPeer.USERNAME, username );
   Vector users = TurbineUserPeer.doSelect(criteria);
   ...
}

>>>>>>>  Code   >>>>>>>

Or, for those of you who prefer diffs:

>>>>>>>  Code   >>>>>>>

Index: TurbineUser.java
===================================================================
RCS file:
/products/cvs/turbine/turbine/src/java/org/apache/turbine/util/TurbineUser.java,v
retrieving revision 1.11
diff -r1.11 TurbineUser.java
306a307,315
>               return retrieveFromStorage( username, criteria );
>     }
>
>     /*
>      * This function returns a TurbineUser which has been upcast to a
User.
>      */
>     public User retrieveFromStorage( String username, Criteria criteria )
>               throws Exception
>     {

>>>>>>>  Code   >>>>>>>

Now here's the catch.  To make this most useful, it would be nice if the
User interface would provide this same new method, but that would mean
anyone currently implementing User for their own work would need make the
same modification.

Comments?

-----------------------------
Parker J. May
Outcome Technology Associates
[EMAIL PROTECTED]




------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Problems?:           [EMAIL PROTECTED]

Reply via email to