You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by mp...@apache.org on 2002/07/11 09:16:43 UTC
cvs commit: jakarta-turbine-2/src/java/org/apache/turbine/util/parser BaseValueParser.java
mpoeschl 2002/07/11 00:16:43
Modified: src/java/org/apache/turbine/om BaseObject.java
Persistent.java
src/java/org/apache/turbine/om/security/peer GroupPeer.java
PermissionPeer.java RolePeer.java
RolePermissionPeer.java TurbineUserPeer.java
UserGroupRolePeer.java
src/java/org/apache/turbine/services/db
MapBrokerService.java PoolBrokerService.java
TurbineDB.java TurbineMapBrokerService.java
TurbinePoolBrokerService.java
src/java/org/apache/turbine/services/security
BaseSecurityService.java SecurityService.java
TurbineSecurity.java UserManager.java
src/java/org/apache/turbine/services/security/db
DBSecurityService.java DBUserManager.java
src/java/org/apache/turbine/services/security/ldap
LDAPSecurityService.java LDAPUserManager.java
src/java/org/apache/turbine/services/security/passive
PassiveUserManager.java
src/java/org/apache/turbine/util ValueParser.java
src/java/org/apache/turbine/util/db/map
TurbineMapBuilder.java
src/java/org/apache/turbine/util/parser BaseValueParser.java
Log:
use org.apache.torque
Revision Changes Path
1.3 +22 -21 jakarta-turbine-2/src/java/org/apache/turbine/om/BaseObject.java
Index: BaseObject.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/om/BaseObject.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- BaseObject.java 3 Sep 2001 06:01:48 -0000 1.2
+++ BaseObject.java 11 Jul 2002 07:16:42 -0000 1.3
@@ -25,13 +25,13 @@
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
- * 4. The names "Apache" and "Apache Software Foundation" and
- * "Apache Turbine" must not be used to endorse or promote products
- * derived from this software without prior written permission. For
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache Turbine" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
- * "Apache Turbine", nor may "Apache" appear in their name, without
+ * "Apache Turbine", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
@@ -54,7 +54,8 @@
* <http://www.apache.org/>.
*/
-import org.apache.turbine.util.db.pool.DBConnection;
+import java.sql.Connection;
+import org.apache.torque.om.*;
import java.io.Serializable;
import java.math.BigDecimal;
@@ -70,7 +71,7 @@
public abstract class BaseObject implements Persistent, Serializable
{
public static final int NEW_ID = -1;
-
+
/**
* attribute to determine if this object has previously been saved.
*/
@@ -101,7 +102,7 @@
/**
* Attempts to return the object primaryKey as an int.
*
- * @return the object primaryKey as an int;
+ * @return the object primaryKey as an int;
* returns -1 if primaryKey was not set
* or could not be represented as an int.
*
@@ -123,7 +124,7 @@
/**
* Attempts to return the object primaryKey as a long.
*
- * @return the object primaryKey as a long;
+ * @return the object primaryKey as a long;
* returns -1 if primaryKey was not set
* or could not be represented as a long.
*
@@ -145,7 +146,7 @@
/**
* Attempts to return the object primaryKey as a BigDecimal.
*
- * @return the object primaryKey as a BigDecimal;
+ * @return the object primaryKey as a BigDecimal;
* returns -1 if primaryKey was not
* set or could not be represented as a BigDecimal.
*
@@ -170,7 +171,7 @@
/**
* Gets the object primaryKey as a String.
*
- * @return the object primaryKey as a String;
+ * @return the object primaryKey as a String;
* returns null if primaryKey was not
* set.
*
@@ -224,7 +225,7 @@
*
* @param primaryKey The new primaryKey for the object.
* @exception Exception, This method will not throw any exceptions
- * but this allows for children to override the method more easily
+ * but this allows for children to override the method more easily
*
* @deprecated
*/
@@ -238,7 +239,7 @@
*
* @param PrimaryKey The new PrimaryKey for the object.
* @exception Exception, This method will not throw any exceptions
- * but this allows for children to override the method more easily
+ * but this allows for children to override the method more easily
*
* @deprecated
*/
@@ -252,7 +253,7 @@
*
* @param PrimaryKey The new PrimaryKey for the object.
* @exception Exception, This method will not throw any exceptions
- * but this allows for children to override the method more easily
+ * but this allows for children to override the method more easily
*
*/
public void setPrimaryKey(String primaryKey) throws Exception
@@ -265,7 +266,7 @@
*
* @param PrimaryKey The new PrimaryKey for the object.
* @exception Exception, This method will not throw any exceptions
- * but this allows for children to override the method more easily
+ * but this allows for children to override the method more easily
*
*/
public void setPrimaryKey(SimpleKey[] primaryKey) throws Exception
@@ -308,7 +309,7 @@
public void save()
throws Exception
{
- throw new Error("BaseObject.save: " + errMsg);
+ throw new Error("BaseObject.save: " + errMsg);
}
/**
@@ -321,7 +322,7 @@
*/
public Object getByName(String field)
{
- throw new Error("BaseObject.getByName: " + errMsg);
+ throw new Error("BaseObject.getByName: " + errMsg);
}
/**
@@ -331,7 +332,7 @@
*/
public Object getByPeerName(String name)
{
- throw new Error("BaseObject.getByPeerName: " + errMsg);
+ throw new Error("BaseObject.getByPeerName: " + errMsg);
}
/**
@@ -399,11 +400,11 @@
public int hashCode()
{
ObjectKey ok = getPrimaryKey();
- if ( ok == null)
+ if ( ok == null)
{
return super.hashCode();
}
-
+
return ok.hashCode();
}
@@ -423,7 +424,7 @@
* the save() method and the connection details will be handled
* internally
*/
- public void save(DBConnection dbCon) throws Exception
+ public void save(Connection dbCon) throws Exception
{
throw new UnsupportedOperationException("Method must be implemented if called");
}
1.3 +8 -7 jakarta-turbine-2/src/java/org/apache/turbine/om/Persistent.java
Index: Persistent.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/om/Persistent.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Persistent.java 1 Sep 2001 08:37:14 -0000 1.2
+++ Persistent.java 11 Jul 2002 07:16:42 -0000 1.3
@@ -1,6 +1,7 @@
package org.apache.turbine.om;
-import org.apache.turbine.util.db.pool.DBConnection;
+import java.sql.Connection;
+import org.apache.torque.om.ObjectKey;
/* ====================================================================
* The Apache Software License, Version 1.1
@@ -27,13 +28,13 @@
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
- * 4. The names "Apache" and "Apache Software Foundation" and
- * "Apache Turbine" must not be used to endorse or promote products
- * derived from this software without prior written permission. For
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache Turbine" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
- * "Apache Turbine", nor may "Apache" appear in their name, without
+ * "Apache Turbine", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
@@ -138,5 +139,5 @@
* the save() method and the connection details will be handled
* internally
*/
- public void save(DBConnection dbCon) throws Exception;
+ public void save(Connection dbCon) throws Exception;
}
1.2 +66 -58 jakarta-turbine-2/src/java/org/apache/turbine/om/security/peer/GroupPeer.java
Index: GroupPeer.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/om/security/peer/GroupPeer.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- GroupPeer.java 16 Aug 2001 05:08:44 -0000 1.1
+++ GroupPeer.java 11 Jul 2002 07:16:42 -0000 1.2
@@ -25,13 +25,13 @@
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
- * 4. The names "Apache" and "Apache Software Foundation" and
- * "Apache Turbine" must not be used to endorse or promote products
- * derived from this software without prior written permission. For
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache Turbine" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
- * "Apache Turbine", nor may "Apache" appear in their name, without
+ * "Apache Turbine", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
@@ -57,21 +57,22 @@
import com.workingdogs.village.Record;
import com.workingdogs.village.Value;
import java.util.Map;
-import java.util.Vector;
+import java.util.*;
import org.apache.turbine.om.BaseObject;
-import org.apache.turbine.om.ObjectKey;
-import org.apache.turbine.om.peer.BasePeer;
+import org.apache.torque.om.ObjectKey;
+import org.apache.torque.util.BasePeer;
import org.apache.turbine.om.security.Group;
import org.apache.turbine.om.security.SecurityObject;
import org.apache.turbine.om.security.TurbineGroup;
import org.apache.turbine.services.security.TurbineSecurity;
import org.apache.turbine.util.ObjectUtils;
import org.apache.turbine.util.StringStackBuffer;
-import org.apache.turbine.util.db.Criteria;
-import org.apache.turbine.util.db.map.MapBuilder;
+import org.apache.torque.util.Criteria;
+import org.apache.torque.map.MapBuilder;
import org.apache.turbine.util.db.map.TurbineMapBuilder;
import org.apache.turbine.util.security.DataBackendException;
import org.apache.turbine.util.security.GroupSet;
+import org.apache.torque.TorqueException;
/**
* This class handles all the database access for the Group table.
@@ -85,8 +86,8 @@
*/
public class GroupPeer extends BasePeer
{
- private static final TurbineMapBuilder mapBuilder =
- (TurbineMapBuilder) getMapBuilder();
+ private static final TurbineMapBuilder mapBuilder =
+ (TurbineMapBuilder) getMapBuilder("org.apache.turbine.util.db.map.TurbineMapBuilder");
/** The table name for this peer. */
private static final String TABLE_NAME = mapBuilder.getTableGroup();
@@ -121,11 +122,11 @@
*/
public static GroupSet retrieveSet(Criteria criteria) throws Exception
{
- Vector results = GroupPeer.doSelect(criteria);
+ List results = GroupPeer.doSelect(criteria);
GroupSet rs = new GroupSet();
- for (int i=0; i<results.size(); i++)
+ for (int i = 0; i < results.size(); i++)
{
- rs.add( (Group)results.elementAt(i) );
+ rs.add((Group) results.get(i));
}
return rs;
}
@@ -138,51 +139,58 @@
* @return Vector containing Group objects.
* @exception Exception, a generic exception.
*/
- public static Vector doSelect(Criteria criteria)
- throws Exception
+ public static List doSelect(Criteria criteria)
+ throws TorqueException
{
- criteria.addSelectColumn(GROUP_ID)
- .addSelectColumn(NAME)
- .addSelectColumn(OBJECTDATA);
-
- if (criteria.getOrderByColumns() == null ||
- criteria.getOrderByColumns().size() == 0)
+ try
{
- criteria.addAscendingOrderByColumn(NAME);
- }
+ criteria.addSelectColumn(GROUP_ID)
+ .addSelectColumn(NAME)
+ .addSelectColumn(OBJECTDATA);
- // Place any checks here to intercept criteria which require
- // custom SQL. For example:
- // if ( criteria.containsKey("SomeTable.SomeColumn") )
- // {
- // String whereSql = "SomeTable.SomeColumn IN (Select ...";
- // criteria.add("SomeTable.SomeColumn",
- // whereSQL, criteria.CUSTOM);
- // }
-
- // BasePeer returns a Vector of Value (Village) arrays. The
- // array order follows the order columns were placed in the
- // Select clause.
- Vector rows = BasePeer.doSelect(criteria);
- Vector results = new Vector();
+ if (criteria.getOrderByColumns() == null ||
+ criteria.getOrderByColumns().size() == 0)
+ {
+ criteria.addAscendingOrderByColumn(NAME);
+ }
- // Populate the object(s).
- for ( int i=0; i<rows.size(); i++ )
- {
- Group obj = TurbineSecurity.getNewGroup(null);
- Record row = (Record)rows.elementAt(i);
- ((SecurityObject)obj).setPrimaryKey( row.getValue(1).asInt() );
- ((SecurityObject)obj).setName( row.getValue(2).asString() );
- byte[] objectData = (byte[])row.getValue(3).asBytes();
- Map temp = (Map)ObjectUtils.deserialize(objectData);
- if(temp != null)
+ // Place any checks here to intercept criteria which require
+ // custom SQL. For example:
+ // if ( criteria.containsKey("SomeTable.SomeColumn") )
+ // {
+ // String whereSql = "SomeTable.SomeColumn IN (Select ...";
+ // criteria.add("SomeTable.SomeColumn",
+ // whereSQL, criteria.CUSTOM);
+ // }
+
+ // BasePeer returns a Vector of Value (Village) arrays. The
+ // array order follows the order columns were placed in the
+ // Select clause.
+ List rows = BasePeer.doSelect(criteria);
+ List results = new ArrayList();
+
+ // Populate the object(s).
+ for ( int i = 0; i < rows.size(); i++ )
{
- ((SecurityObject)obj).setAttributes(temp);
+ Group obj = TurbineSecurity.getNewGroup(null);
+ Record row = (Record) rows.get(i);
+ ((SecurityObject) obj).setPrimaryKey(row.getValue(1).asInt());
+ ((SecurityObject) obj).setName(row.getValue(2).asString());
+ byte[] objectData = (byte[]) row.getValue(3).asBytes();
+ Map temp = (Map) ObjectUtils.deserialize(objectData);
+ if (temp != null)
+ {
+ ((SecurityObject) obj).setAttributes(temp);
+ }
+ results.add(obj);
}
- results.addElement( obj );
- }
- return results;
+ return results;
+ }
+ catch (Exception ex)
+ {
+ throw new TorqueException(ex);
+ }
}
/**
@@ -193,7 +201,7 @@
* @exception Exception, a generic exception.
*/
public static void doUpdate(Criteria criteria)
- throws Exception
+ throws TorqueException
{
Criteria selectCriteria = new Criteria(2);
selectCriteria.put( GROUP_ID, criteria.remove(GROUP_ID) );
@@ -206,7 +214,7 @@
*
* @param permission The Group to be checked.
* @return <code>true</code> if given Group exists in the system.
- * @throws DataBackendException when more than one Group with
+ * @throws DataBackendException when more than one Group with
* the same name exists.
* @throws Exception, a generic exception.
*/
@@ -216,10 +224,10 @@
Criteria criteria = new Criteria();
criteria.addSelectColumn(GROUP_ID);
criteria.add(NAME, ((SecurityObject)group).getName());
- Vector results = BasePeer.doSelect(criteria);
- if(results.size() > 1)
+ List results = BasePeer.doSelect(criteria);
+ if (results.size() > 1)
{
- throw new DataBackendException("Multiple groups named '" +
+ throw new DataBackendException("Multiple groups named '" +
((TurbineGroup)group).getName() + "' exist!");
}
return (results.size()==1);
1.2 +74 -66 jakarta-turbine-2/src/java/org/apache/turbine/om/security/peer/PermissionPeer.java
Index: PermissionPeer.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/om/security/peer/PermissionPeer.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- PermissionPeer.java 16 Aug 2001 05:08:44 -0000 1.1
+++ PermissionPeer.java 11 Jul 2002 07:16:42 -0000 1.2
@@ -25,13 +25,13 @@
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
- * 4. The names "Apache" and "Apache Software Foundation" and
- * "Apache Turbine" must not be used to endorse or promote products
- * derived from this software without prior written permission. For
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache Turbine" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
- * "Apache Turbine", nor may "Apache" appear in their name, without
+ * "Apache Turbine", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
@@ -57,11 +57,11 @@
import com.workingdogs.village.Record;
import com.workingdogs.village.Value;
import java.util.Enumeration;
-import java.util.Map;
+import java.util.*;
import java.util.Vector;
import org.apache.turbine.om.BaseObject;
-import org.apache.turbine.om.ObjectKey;
-import org.apache.turbine.om.peer.BasePeer;
+import org.apache.torque.om.ObjectKey;
+import org.apache.torque.util.BasePeer;
import org.apache.turbine.om.security.Permission;
import org.apache.turbine.om.security.Role;
import org.apache.turbine.om.security.SecurityObject;
@@ -69,11 +69,12 @@
import org.apache.turbine.services.security.TurbineSecurity;
import org.apache.turbine.util.ObjectUtils;
import org.apache.turbine.util.StringStackBuffer;
-import org.apache.turbine.util.db.Criteria;
-import org.apache.turbine.util.db.map.MapBuilder;
+import org.apache.torque.util.Criteria;
+import org.apache.torque.map.MapBuilder;
import org.apache.turbine.util.db.map.TurbineMapBuilder;
import org.apache.turbine.util.security.DataBackendException;
import org.apache.turbine.util.security.PermissionSet;
+import org.apache.torque.TorqueException;
/**
* This class handles all the database access for the PERMISSION
@@ -87,25 +88,25 @@
*/
public class PermissionPeer extends BasePeer
{
- private static final TurbineMapBuilder mapBuilder =
- (TurbineMapBuilder) getMapBuilder();
+ private static final TurbineMapBuilder mapBuilder =
+ (TurbineMapBuilder) getMapBuilder("org.apache.turbine.util.db.map.TurbineMapBuilder");
/** The table name for this peer. */
private static final String TABLE_NAME = mapBuilder.getTablePermission();
/** The column name for the permission id field. */
- public static final String PERMISSION_ID =
+ public static final String PERMISSION_ID =
mapBuilder.getPermission_PermissionId();
/** The column name for the name field. */
public static final String NAME = mapBuilder.getPermission_Name();
/** The column name for the ObjectData field */
- public static final String OBJECTDATA =
+ public static final String OBJECTDATA =
mapBuilder.getPermission_ObjectData();
/** The Oracle sequence name for this peer. */
- private static final String SEQUENCE_NAME =
+ private static final String SEQUENCE_NAME =
mapBuilder.getSequencePermission();
@@ -119,11 +120,11 @@
public static PermissionSet retrieveSet(Criteria criteria)
throws Exception
{
- Vector results = PermissionPeer.doSelect(criteria);
+ List results = PermissionPeer.doSelect(criteria);
PermissionSet ps = new PermissionSet();
- for (int i=0; i<results.size(); i++)
+ for (int i = 0; i < results.size(); i++)
{
- ps.add( (Permission)results.elementAt(i) );
+ ps.add((Permission) results.get(i));
}
return ps;
}
@@ -139,9 +140,9 @@
throws Exception
{
Criteria criteria = new Criteria();
- criteria.add(RolePermissionPeer.ROLE_ID,
+ criteria.add(RolePermissionPeer.ROLE_ID,
((TurbineRole)role).getPrimaryKey());
- criteria.addJoin(RolePermissionPeer.PERMISSION_ID,
+ criteria.addJoin(RolePermissionPeer.PERMISSION_ID,
PermissionPeer.PERMISSION_ID);
return retrieveSet(criteria);
}
@@ -154,51 +155,58 @@
* @return Vector containing Permission objects.
* @exception Exception, a generic exception.
*/
- public static Vector doSelect(Criteria criteria)
- throws Exception
+ public static List doSelect(Criteria criteria)
+ throws TorqueException
{
- criteria.addSelectColumn(PERMISSION_ID)
- .addSelectColumn(NAME)
- .addSelectColumn(OBJECTDATA);
-
- if (criteria.getOrderByColumns() == null ||
- criteria.getOrderByColumns().size() == 0)
+ try
{
- criteria.addAscendingOrderByColumn(NAME);
- }
+ criteria.addSelectColumn(PERMISSION_ID)
+ .addSelectColumn(NAME)
+ .addSelectColumn(OBJECTDATA);
- // Place any checks here to intercept criteria which require
- // custom SQL. For example:
- // if ( criteria.containsKey("SomeTable.SomeColumn") )
- // {
- // String whereSql = "SomeTable.SomeColumn IN (Select ...";
- // criteria.add("SomeTable.SomeColumn",
- // whereSQL, criteria.CUSTOM);
- // }
-
- // BasePeer returns a Vector of Value (Village) arrays. The
- // array order follows the order columns were placed in the
- // Select clause.
- Vector rows = BasePeer.doSelect(criteria);
- Vector results = new Vector();
+ if (criteria.getOrderByColumns() == null ||
+ criteria.getOrderByColumns().size() == 0)
+ {
+ criteria.addAscendingOrderByColumn(NAME);
+ }
- // Populate the object(s).
- for ( int i=0; i<rows.size(); i++ )
- {
- Permission obj = TurbineSecurity.getNewPermission(null);
- Record row = (Record)rows.elementAt(i);
- ((SecurityObject)obj).setPrimaryKey( row.getValue(1).asInt() );
- ((SecurityObject)obj).setName( row.getValue(2).asString() );
- byte[] objectData = (byte[])row.getValue(3).asBytes();
- Map temp = (Map)ObjectUtils.deserialize(objectData);
- if(temp != null)
+ // Place any checks here to intercept criteria which require
+ // custom SQL. For example:
+ // if ( criteria.containsKey("SomeTable.SomeColumn") )
+ // {
+ // String whereSql = "SomeTable.SomeColumn IN (Select ...";
+ // criteria.add("SomeTable.SomeColumn",
+ // whereSQL, criteria.CUSTOM);
+ // }
+
+ // BasePeer returns a Vector of Value (Village) arrays. The
+ // array order follows the order columns were placed in the
+ // Select clause.
+ List rows = BasePeer.doSelect(criteria);
+ List results = new ArrayList();
+
+ // Populate the object(s).
+ for ( int i=0; i<rows.size(); i++ )
{
- ((SecurityObject)obj).setAttributes(temp);
+ Permission obj = TurbineSecurity.getNewPermission(null);
+ Record row = (Record) rows.get(i);
+ ((SecurityObject) obj).setPrimaryKey( row.getValue(1).asInt() );
+ ((SecurityObject) obj).setName( row.getValue(2).asString() );
+ byte[] objectData = (byte[]) row.getValue(3).asBytes();
+ Map temp = (Map) ObjectUtils.deserialize(objectData);
+ if (temp != null)
+ {
+ ((SecurityObject) obj).setAttributes(temp);
+ }
+ results.add(obj);
}
- results.addElement( obj );
- }
- return results;
+ return results;
+ }
+ catch (Exception ex)
+ {
+ throw new TorqueException(ex);
+ }
}
/**
@@ -209,11 +217,11 @@
Criteria criteria = new Criteria();
if ( !((BaseObject)permission).isNew() )
{
- criteria.add(PERMISSION_ID,
+ criteria.add(PERMISSION_ID,
((BaseObject)permission).getPrimaryKey());
}
criteria.add(NAME, ((SecurityObject)permission).getName());
-
+
/*
* This is causing the the removal and updating of
* a permission to crap out. This addition to the
@@ -221,7 +229,7 @@
*
* where OBJECTDATA = {}
*
- * Is the NAME even necessary. Wouldn't
+ * Is the NAME even necessary. Wouldn't
* criteria.add(PERMISSION_ID, N) be enough to
* generate a where clause that would remove the
* permission?
@@ -239,7 +247,7 @@
* @exception Exception, a generic exception.
*/
public static void doUpdate(Criteria criteria)
- throws Exception
+ throws TorqueException
{
Criteria selectCriteria = new Criteria(2);
selectCriteria.put( PERMISSION_ID,
@@ -253,7 +261,7 @@
*
* @param permission The Permission to be checked.
* @return <code>true</code> if given Permission exists in the system.
- * @throws DataBackendException when more than one Permission with
+ * @throws DataBackendException when more than one Permission with
* the same name exists.
* @throws Exception, a generic exception.
*/
@@ -263,10 +271,10 @@
Criteria criteria = new Criteria();
criteria.addSelectColumn(PERMISSION_ID);
criteria.add(NAME, ((SecurityObject)permission).getName());
- Vector results = BasePeer.doSelect(criteria);
+ List results = BasePeer.doSelect(criteria);
if(results.size() > 1)
{
- throw new DataBackendException("Multiple permissions named '" +
+ throw new DataBackendException("Multiple permissions named '" +
((SecurityObject)permission).getName() + "' exist!");
}
return (results.size()==1);
@@ -314,7 +322,7 @@
for (Enumeration f = clone.elements() ; f.hasMoreElements() ;)
{
Permission tmp2 = (Permission) f.nextElement();
- if (((BaseObject)tmp).getPrimaryKey() ==
+ if (((BaseObject)tmp).getPrimaryKey() ==
((BaseObject)tmp2).getPrimaryKey())
{
clone.removeElement(tmp2);
1.2 +75 -66 jakarta-turbine-2/src/java/org/apache/turbine/om/security/peer/RolePeer.java
Index: RolePeer.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/om/security/peer/RolePeer.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- RolePeer.java 16 Aug 2001 05:08:44 -0000 1.1
+++ RolePeer.java 11 Jul 2002 07:16:42 -0000 1.2
@@ -25,13 +25,13 @@
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
- * 4. The names "Apache" and "Apache Software Foundation" and
- * "Apache Turbine" must not be used to endorse or promote products
- * derived from this software without prior written permission. For
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache Turbine" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
- * "Apache Turbine", nor may "Apache" appear in their name, without
+ * "Apache Turbine", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
@@ -57,11 +57,11 @@
import com.workingdogs.village.Record;
import com.workingdogs.village.Value;
import java.util.Map;
-import java.util.Vector;
+import java.util.*;
import org.apache.turbine.om.BaseObject;
-import org.apache.turbine.om.ObjectKey;
+import org.apache.torque.om.ObjectKey;
import org.apache.turbine.om.Persistent;
-import org.apache.turbine.om.peer.BasePeer;
+import org.apache.torque.util.BasePeer;
import org.apache.turbine.om.security.Group;
import org.apache.turbine.om.security.Role;
import org.apache.turbine.om.security.SecurityEntity;
@@ -73,11 +73,13 @@
import org.apache.turbine.services.security.db.DBSecurityService;
import org.apache.turbine.util.ObjectUtils;
import org.apache.turbine.util.StringStackBuffer;
-import org.apache.turbine.util.db.Criteria;
-import org.apache.turbine.util.db.map.MapBuilder;
+import org.apache.torque.util.Criteria;
+import org.apache.torque.map.MapBuilder;
import org.apache.turbine.util.db.map.TurbineMapBuilder;
import org.apache.turbine.util.security.DataBackendException;
import org.apache.turbine.util.security.RoleSet;
+import org.apache.torque.TorqueException;
+
/**
* This class handles all the database access for the ROLE table.
@@ -90,8 +92,8 @@
*/
public class RolePeer extends BasePeer
{
- private static final TurbineMapBuilder mapBuilder =
- (TurbineMapBuilder) getMapBuilder();
+ private static final TurbineMapBuilder mapBuilder =
+ (TurbineMapBuilder) getMapBuilder("org.apache.turbine.util.db.map.TurbineMapBuilder");
/** The table name for this peer. */
private static final String TABLE_NAME = mapBuilder.getTableRole();
@@ -113,11 +115,11 @@
*/
public static RoleSet retrieveSet(Criteria criteria) throws Exception
{
- Vector results = RolePeer.doSelect(criteria);
+ List results = RolePeer.doSelect(criteria);
RoleSet rs = new RoleSet();
- for (int i=0; i<results.size(); i++)
+ for (int i = 0; i < results.size(); i++)
{
- rs.add( (Role)results.elementAt(i) );
+ rs.add((Role) results.get(i));
}
return rs;
}
@@ -134,7 +136,7 @@
throws Exception
{
Criteria criteria = new Criteria();
-
+
/*
* Peer specific methods should absolutely NOT be part
* of any of the generic interfaces in the security system.
@@ -142,16 +144,16 @@
*
* UserPeer up = TurbineSecurity.getUserPeerInstance();
*/
-
+
UserPeer up = ((DBSecurityService)TurbineSecurity.getService())
.getUserPeerInstance();
-
- criteria.add(up.getFullColumnName(UserPeer.USERNAME),
+
+ criteria.add(up.getFullColumnName(UserPeer.USERNAME),
user.getUserName());
- criteria.add(UserGroupRolePeer.GROUP_ID,
+ criteria.add(UserGroupRolePeer.GROUP_ID,
((Persistent)group).getPrimaryKey());
- criteria.addJoin(up.getFullColumnName(UserPeer.USER_ID),
+ criteria.addJoin(up.getFullColumnName(UserPeer.USER_ID),
UserGroupRolePeer.USER_ID);
criteria.addJoin(UserGroupRolePeer.ROLE_ID, RolePeer.ROLE_ID);
return retrieveSet(criteria);
@@ -165,52 +167,59 @@
* @return Vector containing Role objects.
* @exception Exception, a generic exception.
*/
- public static Vector doSelect(Criteria criteria)
- throws Exception
+ public static List doSelect(Criteria criteria)
+ throws TorqueException
{
- criteria.addSelectColumn(ROLE_ID)
- .addSelectColumn(NAME)
- .addSelectColumn(OBJECTDATA);
-
- if (criteria.getOrderByColumns() == null ||
- criteria.getOrderByColumns().size() == 0)
+ try
{
- criteria.addAscendingOrderByColumn(NAME);
- }
+ criteria.addSelectColumn(ROLE_ID)
+ .addSelectColumn(NAME)
+ .addSelectColumn(OBJECTDATA);
- // Place any checks here to intercept criteria which require
- // custom SQL. For example:
- // if ( criteria.containsKey("SomeTable.SomeColumn") )
- // {
- // String whereSql = "SomeTable.SomeColumn IN (Select ...";
- // criteria.add("SomeTable.SomeColumn",
- // whereSQL, criteria.CUSTOM);
- // }
-
- // BasePeer returns a Vector of Value (Village) arrays. The
- // array order follows the order columns were placed in the
- // Select clause.
- Vector rows = BasePeer.doSelect(criteria);
- Vector results = new Vector();
+ if (criteria.getOrderByColumns() == null ||
+ criteria.getOrderByColumns().size() == 0)
+ {
+ criteria.addAscendingOrderByColumn(NAME);
+ }
- // Populate the object(s).
- for ( int i=0; i<rows.size(); i++ )
- {
- //Role obj = new Role();
- Role obj = new TurbineRole();
- Record row = (Record)rows.elementAt(i);
- ((TurbineRole)obj).setPrimaryKey( row.getValue(1).asInt() );
- ((TurbineRole)obj).setName( row.getValue(2).asString() );
- byte[] objectData = (byte[])row.getValue(3).asBytes();
- Map temp = (Map)ObjectUtils.deserialize(objectData);
- if(temp != null)
+ // Place any checks here to intercept criteria which require
+ // custom SQL. For example:
+ // if ( criteria.containsKey("SomeTable.SomeColumn") )
+ // {
+ // String whereSql = "SomeTable.SomeColumn IN (Select ...";
+ // criteria.add("SomeTable.SomeColumn",
+ // whereSQL, criteria.CUSTOM);
+ // }
+
+ // BasePeer returns a Vector of Value (Village) arrays. The
+ // array order follows the order columns were placed in the
+ // Select clause.
+ List rows = BasePeer.doSelect(criteria);
+ List results = new ArrayList();
+
+ // Populate the object(s).
+ for (int i = 0; i < rows.size(); i++ )
{
- ((TurbineRole)obj).setAttributes(temp);
+ //Role obj = new Role();
+ Role obj = new TurbineRole();
+ Record row = (Record) rows.get(i);
+ ((TurbineRole) obj).setPrimaryKey(row.getValue(1).asInt());
+ ((TurbineRole) obj).setName(row.getValue(2).asString());
+ byte[] objectData = (byte[]) row.getValue(3).asBytes();
+ Map temp = (Map) ObjectUtils.deserialize(objectData);
+ if (temp != null)
+ {
+ ((TurbineRole) obj).setAttributes(temp);
+ }
+ results.add(obj);
}
- results.addElement( obj );
- }
- return results;
+ return results;
+ }
+ catch (Exception ex)
+ {
+ throw new TorqueException (ex);
+ }
}
/**
@@ -229,7 +238,7 @@
//criteria.add(OBJECTDATA, role.getAttributes());
return criteria;
}
-
+
/**
* Issues an update based on a criteria.
*
@@ -238,7 +247,7 @@
* @exception Exception, a generic exception.
*/
public static void doUpdate(Criteria criteria)
- throws Exception
+ throws TorqueException
{
Criteria selectCriteria = new Criteria(2);
selectCriteria.put( ROLE_ID, criteria.remove(ROLE_ID) );
@@ -251,7 +260,7 @@
*
* @param permission The Role to be checked.
* @return <code>true</code> if given Role exists in the system.
- * @throws DataBackendException when more than one Role with
+ * @throws DataBackendException when more than one Role with
* the same name exists.
* @throws Exception, a generic exception.
*/
@@ -261,13 +270,13 @@
Criteria criteria = new Criteria();
criteria.addSelectColumn(ROLE_ID);
criteria.add(NAME, role.getName());
- Vector results = BasePeer.doSelect(criteria);
+ List results = BasePeer.doSelect(criteria);
if(results.size() > 1)
{
- throw new DataBackendException("Multiple roles named '" +
+ throw new DataBackendException("Multiple roles named '" +
role.getName() + "' exist!");
}
- return (results.size()==1);
+ return (results.size() == 1);
}
/**
1.2 +13 -13 jakarta-turbine-2/src/java/org/apache/turbine/om/security/peer/RolePermissionPeer.java
Index: RolePermissionPeer.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/om/security/peer/RolePermissionPeer.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- RolePermissionPeer.java 16 Aug 2001 05:08:45 -0000 1.1
+++ RolePermissionPeer.java 11 Jul 2002 07:16:42 -0000 1.2
@@ -25,13 +25,13 @@
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
- * 4. The names "Apache" and "Apache Software Foundation" and
- * "Apache Turbine" must not be used to endorse or promote products
- * derived from this software without prior written permission. For
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache Turbine" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
- * "Apache Turbine", nor may "Apache" appear in their name, without
+ * "Apache Turbine", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
@@ -54,9 +54,9 @@
* <http://www.apache.org/>.
*/
-import org.apache.turbine.om.peer.BasePeer;
-import org.apache.turbine.util.db.Criteria;
-import org.apache.turbine.util.db.map.MapBuilder;
+import org.apache.torque.util.BasePeer;
+import org.apache.torque.util.Criteria;
+import org.apache.torque.map.MapBuilder;
import org.apache.turbine.util.db.map.TurbineMapBuilder;
/**
@@ -72,19 +72,19 @@
*/
public class RolePermissionPeer extends BasePeer
{
- private static final TurbineMapBuilder mapBuilder =
- (TurbineMapBuilder) getMapBuilder();
+ private static final TurbineMapBuilder mapBuilder =
+ (TurbineMapBuilder) getMapBuilder("org.apache.turbine.util.db.map.TurbineMapBuilder");
/** The table name for this peer. */
- public static final String TABLE_NAME =
+ public static final String TABLE_NAME =
mapBuilder.getTableRolePermission();
/** The column name for the permission id field. */
- public static final String PERMISSION_ID =
+ public static final String PERMISSION_ID =
mapBuilder.getRolePermission_PermissionId();
/** The column name for the role id field. */
- public static final String ROLE_ID =
+ public static final String ROLE_ID =
mapBuilder.getRolePermission_RoleId();
1.2 +131 -111 jakarta-turbine-2/src/java/org/apache/turbine/om/security/peer/TurbineUserPeer.java
Index: TurbineUserPeer.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/om/security/peer/TurbineUserPeer.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- TurbineUserPeer.java 16 Aug 2001 05:08:45 -0000 1.1
+++ TurbineUserPeer.java 11 Jul 2002 07:16:42 -0000 1.2
@@ -25,13 +25,13 @@
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
- * 4. The names "Apache" and "Apache Software Foundation" and
- * "Apache Turbine" must not be used to endorse or promote products
- * derived from this software without prior written permission. For
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache Turbine" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
- * "Apache Turbine", nor may "Apache" appear in their name, without
+ * "Apache Turbine", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
@@ -61,23 +61,25 @@
import java.math.BigDecimal;
import java.sql.Time;
import java.sql.Timestamp;
-import java.util.Date;
+import java.util.*;
import java.util.Hashtable;
import java.util.Vector;
import org.apache.turbine.om.Persistent;
-import org.apache.turbine.om.NumberKey;
-import org.apache.turbine.om.ObjectKey;
-import org.apache.turbine.om.peer.BasePeer;
+import org.apache.torque.om.NumberKey;
+import org.apache.torque.om.ObjectKey;
+import org.apache.torque.util.BasePeer;
import org.apache.turbine.om.security.User;
import org.apache.turbine.services.security.TurbineSecurity;
import org.apache.turbine.util.ObjectUtils;
import org.apache.turbine.util.StringStackBuffer;
-import org.apache.turbine.util.db.Criteria;
-import org.apache.turbine.util.db.map.TableMap;
-import org.apache.turbine.util.db.map.MapBuilder;
+import org.apache.torque.util.Criteria;
+import org.apache.torque.map.TableMap;
+import org.apache.torque.map.MapBuilder;
import org.apache.turbine.util.db.map.TurbineMapBuilder;
-import org.apache.turbine.util.db.pool.DBConnection;
+import java.sql.Connection;
import org.apache.turbine.util.security.DataBackendException;
+import org.apache.torque.TorqueException;
+
/**
* This class handles all the database access for the User/User
@@ -91,15 +93,15 @@
public class TurbineUserPeer extends BasePeer implements UserPeer
{
/** The mapBuilder for this Peer. */
- private static final TurbineMapBuilder mapBuilder =
- (TurbineMapBuilder) getMapBuilder();
+ private static final TurbineMapBuilder mapBuilder =
+ (TurbineMapBuilder) getMapBuilder("org.apache.turbine.util.db.map.TurbineMapBuilder");
// column names
/** The column name for the visitor id field. */
private static final String USER_ID_COLUMN = mapBuilder.getUserId();
/** The column name for the login name field */
- private static final String USERNAME_COLUMN = mapBuilder.getUsername();
+ private static final String USERNAME_COLUMN = mapBuilder.getUsername();
/** The key name for the first name field. */
private static final String FIRST_NAME_COLUMN = mapBuilder.getFirstName();
@@ -120,11 +122,11 @@
private static final String EMAIL_COLUMN = mapBuilder.getEmail();
/** The column name for the confirm_value field. */
- private static final String CONFIRM_VALUE_COLUMN =
+ private static final String CONFIRM_VALUE_COLUMN =
mapBuilder.getConfirmValue();
/** This is the value that is stored in the database for confirmed users. */
- public static final String CONFIRM_DATA =
+ public static final String CONFIRM_DATA =
org.apache.turbine.om.security.User.CONFIRM_DATA;
/** The column name for the visitor id field. */
@@ -162,7 +164,7 @@
public static final String LAST_LOGIN = mapBuilder.getUser_LastLogin();
/** The key name for the confirm_value field. */
- public static final String CONFIRM_VALUE =
+ public static final String CONFIRM_VALUE =
mapBuilder.getUser_ConfirmValue();
/** The key name for the object_data field. */
@@ -175,14 +177,14 @@
private static Schema schema = initTableSchema(TABLE_NAME);
/** The columns. */
- private static com.workingdogs.village.Column[] columns =
+ private static com.workingdogs.village.Column[] columns =
initTableColumns(schema);
/** The names of the columns. */
public static String[] columnNames = initColumnNames(columns);
/** The keys for the criteria. */
- public static String[] criteriaKeys =
+ public static String[] criteriaKeys =
initCriteriaKeys(TABLE_NAME, columnNames);
@@ -211,7 +213,7 @@
}
/**
- *
+ *
* Returns the full name of a column.
*
* @return A String with the full name of the column.
@@ -250,7 +252,8 @@
}
/** Add all the columns needed to create a new object */
- public static void addSelectColumns (Criteria criteria) throws Exception
+ public static void addSelectColumns (Criteria criteria)
+ throws TorqueException
{
for( int i=0; i<columnNames.length; i++ )
{
@@ -262,60 +265,71 @@
}
public static void populateObject(Record row, int offset, User obj)
- throws Exception
+ throws TorqueException
{
- // Set values are where columns are expected. They are not
- // required to be in these positions, as we set the positions
- // immediately following.
- int idPosition = 1;
- int objectDataPosition = columnNames.length;
- for( int i=0; i<columnNames.length; i++ )
+ try
{
- if (columnNames[i].equals(USER_ID_COLUMN))
- idPosition = i+1;
- if (columnNames[i].equals(OBJECT_DATA_COLUMN))
- objectDataPosition = i+1;
- }
+ // Set values are where columns are expected. They are not
+ // required to be in these positions, as we set the positions
+ // immediately following.
+ int idPosition = 1;
+ int objectDataPosition = columnNames.length;
+ for (int i = 0; i < columnNames.length; i++)
+ {
+ if (columnNames[i].equals(USER_ID_COLUMN))
+ {
+ idPosition = i + 1;
+ }
+ if (columnNames[i].equals(OBJECT_DATA_COLUMN))
+ {
+ objectDataPosition = i + 1;
+ }
+ }
- ((Persistent)obj).setPrimaryKey(
- new NumberKey(row.getValue(idPosition).asBigDecimal()) );
+ ((Persistent) obj).setPrimaryKey(
+ new NumberKey(row.getValue(idPosition).asBigDecimal()) );
- // Restore the Permanent Storage Hashtable. First the
- // Hashtable is restored, then any explicit table columns
- // which should be included in the Hashtable are added.
- byte[] objectData = (byte[])row.getValue(objectDataPosition).asBytes();
- Hashtable tempHash = (Hashtable)ObjectUtils.deserialize(objectData);
- if (tempHash == null)
- {
- tempHash = new Hashtable(10);
- }
+ // Restore the Permanent Storage Hashtable. First the
+ // Hashtable is restored, then any explicit table columns
+ // which should be included in the Hashtable are added.
+ byte[] objectData = (byte[])row.getValue(objectDataPosition).asBytes();
+ Hashtable tempHash = (Hashtable)ObjectUtils.deserialize(objectData);
+ if (tempHash == null)
+ {
+ tempHash = new Hashtable(10);
+ }
- for( int j=0; j<columnNames.length; j++ )
- {
- if ( ! ( columnNames[j].equalsIgnoreCase( USER_ID_COLUMN )
- || columnNames[j].equalsIgnoreCase( OBJECT_DATA_COLUMN ) ))
+ for( int j=0; j<columnNames.length; j++ )
{
- Object obj2 = null;
- Value value = row.getValue(j+1);
- if (value.isByte()) obj2 = new Byte(value.asByte());
- if (value.isBigDecimal()) obj2 = value.asBigDecimal();
- if (value.isBytes()) obj2 = value.asBytes();
- if (value.isDate()) obj2 = value.asDate();
- if (value.isShort()) obj2 = new Short(value.asShort());
- if (value.isInt()) obj2 = new Integer(value.asInt());
- if (value.isLong()) obj2 = new Long(value.asLong());
- if (value.isDouble()) obj2 = new Double(value.asDouble());
- if (value.isFloat()) obj2 = new Float(value.asFloat());
- if (value.isBoolean()) obj2 = new Boolean(value.asBoolean());
- if (value.isString()) obj2 = value.asString();
- if (value.isTime()) obj2 = value.asTime();
- if (value.isTimestamp()) obj2 = value.asTimestamp();
- if (value.isUtilDate()) obj2 = value.asUtilDate();
- if ( obj2 != null )
- tempHash.put( columnNames[j], obj2 );
+ if ( ! ( columnNames[j].equalsIgnoreCase( USER_ID_COLUMN )
+ || columnNames[j].equalsIgnoreCase( OBJECT_DATA_COLUMN ) ))
+ {
+ Object obj2 = null;
+ Value value = row.getValue(j+1);
+ if (value.isByte()) obj2 = new Byte(value.asByte());
+ if (value.isBigDecimal()) obj2 = value.asBigDecimal();
+ if (value.isBytes()) obj2 = value.asBytes();
+ if (value.isDate()) obj2 = value.asDate();
+ if (value.isShort()) obj2 = new Short(value.asShort());
+ if (value.isInt()) obj2 = new Integer(value.asInt());
+ if (value.isLong()) obj2 = new Long(value.asLong());
+ if (value.isDouble()) obj2 = new Double(value.asDouble());
+ if (value.isFloat()) obj2 = new Float(value.asFloat());
+ if (value.isBoolean()) obj2 = new Boolean(value.asBoolean());
+ if (value.isString()) obj2 = value.asString();
+ if (value.isTime()) obj2 = value.asTime();
+ if (value.isTimestamp()) obj2 = value.asTimestamp();
+ if (value.isUtilDate()) obj2 = value.asUtilDate();
+ if ( obj2 != null )
+ tempHash.put( columnNames[j], obj2 );
+ }
}
+ obj.setPermStorage( tempHash );
+ }
+ catch (Exception ex)
+ {
+ throw new TorqueException(ex);
}
- obj.setPermStorage( tempHash );
}
/**
@@ -326,10 +340,10 @@
* @return Vector containing TurbineUser objects.
* @exception Exception, a generic exception.
*/
- public static Vector doSelect(Criteria criteria)
- throws Exception
+ public static List doSelect(Criteria criteria)
+ throws TorqueException
{
- return doSelect(criteria, (User)null);
+ return doSelect(criteria, (User) null);
}
/**
@@ -342,16 +356,15 @@
* @return Vector containing TurbineUser objects.
* @exception Exception, a generic exception.
*/
- public static Vector doSelect(Criteria criteria,
- User current)
- throws Exception
+ public static List doSelect(Criteria criteria, User current)
+ throws TorqueException
{
// stuff for postgresql problem.....
criteria.setBlobFlag();
// add User table columns
addSelectColumns(criteria);
-
+
if (criteria.getOrderByColumns() == null)
{
criteria.addAscendingOrderByColumn(LAST_NAME);
@@ -369,22 +382,22 @@
// BasePeer returns a Vector of Record (Village) objects. The
// array order follows the order columns were placed in the
// Select clause.
- Vector rows = BasePeer.doSelect(criteria);
- Vector results = new Vector();
+ List rows = BasePeer.doSelect(criteria);
+ List results = new ArrayList();
// Populate the object(s).
- for ( int i=0; i<rows.size(); i++ )
+ for ( int i = 0; i < rows.size(); i++ )
{
- Record row = (Record)rows.elementAt(i);
+ Record row = (Record) rows.get(i);
// Add User to the return Vector.
- if ( current == null )
+ if (current == null)
{
- results.addElement( row2Object(row, 1, null) );
+ results.add(row2Object(row, 1, null));
}
- else
- {
+ else
+ {
populateObject(row, 1, current);
- ((Persistent)current).setNew(false);
+ ((Persistent) current).setNew(false);
}
}
return results;
@@ -400,15 +413,15 @@
* @return Vector containing TurbineUser objects.
* @exception Exception, a generic exception.
*/
- public static Vector doSelect(Criteria criteria, DBConnection dbConn)
- throws Exception
+ public static List doSelect(Criteria criteria, Connection dbConn)
+ throws TorqueException
{
// stuff for postgresql problem.....
criteria.setBlobFlag();
-
+
// add User table columns
addSelectColumns(criteria);
-
+
if (criteria.getOrderByColumns() == null)
{
criteria.addAscendingOrderByColumn(LAST_NAME);
@@ -417,31 +430,38 @@
// BasePeer returns a Vector of Record (Village) objects. The
// array order follows the order columns were placed in the
// Select clause.
- Vector rows = BasePeer.doSelect(criteria, dbConn);
- Vector results = new Vector();
+ List rows = BasePeer.doSelect(criteria, dbConn);
+ List results = new ArrayList();
// Populate the object(s).
- for ( int i=0; i<rows.size(); i++ )
+ for (int i = 0; i < rows.size(); i++)
{
- Record row = (Record)rows.elementAt(i);
+ Record row = (Record) rows.get(i);
// Add User to the return Vector.
- results.addElement( row2Object(row, 1, null) );
+ results.add(row2Object(row, 1, null));
}
return results;
}
- /**
+ /**
* Implementss torque peers' method. Does not use the Class argument
* as Users need to go through TurbineSecurity
*/
- public static User row2Object (Record row, int offset, Class cls)
- throws Exception
+ public static User row2Object (Record row, int offset, Class cls)
+ throws TorqueException
{
- User obj = TurbineSecurity.getUserInstance();
- populateObject(row, offset, obj);
- ((Persistent)obj).setNew(false);
- ((Persistent)obj).setModified(false);
- return obj;
+ try
+ {
+ User obj = TurbineSecurity.getUserInstance();
+ populateObject(row, offset, obj);
+ ((Persistent)obj).setNew(false);
+ ((Persistent)obj).setModified(false);
+ return obj;
+ }
+ catch (Exception ex)
+ {
+ throw new TorqueException (ex);
+ }
}
/**
@@ -462,7 +482,7 @@
* @exception Exception, a generic exception.
*/
public static void doUpdate(Criteria criteria)
- throws Exception
+ throws TorqueException
{
Criteria selectCriteria = new Criteria(2);
selectCriteria.put( USER_ID, criteria.remove(USER_ID) );
@@ -475,7 +495,7 @@
*
* @param permission The User to be checked.
* @return <code>true</code> if given User exists in the system.
- * @throws DataBackendException when more than one User with
+ * @throws DataBackendException when more than one User with
* the same name exists.
* @throws Exception, a generic exception.
*/
@@ -485,10 +505,10 @@
Criteria criteria = new Criteria();
criteria.addSelectColumn(USER_ID);
criteria.add(USERNAME, user.getUserName());
- Vector results = BasePeer.doSelect(criteria);
+ List results = BasePeer.doSelect(criteria);
if(results.size() > 1)
{
- throw new DataBackendException("Multiple users named '" +
+ throw new DataBackendException("Multiple users named '" +
user.getUserName() + "' exist!");
}
return (results.size()==1);
@@ -500,7 +520,7 @@
* @return A Vector with all users in the system.
* @exception Exception, a generic exception.
*/
- public static Vector selectAllUsers()
+ public static List selectAllUsers()
throws Exception
{
Criteria criteria = new Criteria();
@@ -516,7 +536,7 @@
* @return A Vector with all confirmed users in the system.
* @exception Exception, a generic exception.
*/
- public static Vector selectAllConfirmedUsers()
+ public static List selectAllConfirmedUsers()
throws Exception
{
Criteria criteria = new Criteria();
@@ -527,13 +547,13 @@
return TurbineUserPeer.doSelect(criteria);
}
- /**
- * Returns the TableMap related to this peer. This method is not
+ /**
+ * Returns the TableMap related to this peer. This method is not
* needed for general use but a specific application could have a
* need.
*/
protected static TableMap getTableMap()
{
return mapBuilder.getDatabaseMap().getTable(TABLE_NAME);
- }
+ }
}
1.2 +10 -10 jakarta-turbine-2/src/java/org/apache/turbine/om/security/peer/UserGroupRolePeer.java
Index: UserGroupRolePeer.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/om/security/peer/UserGroupRolePeer.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- UserGroupRolePeer.java 16 Aug 2001 05:08:45 -0000 1.1
+++ UserGroupRolePeer.java 11 Jul 2002 07:16:42 -0000 1.2
@@ -25,13 +25,13 @@
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
- * 4. The names "Apache" and "Apache Software Foundation" and
- * "Apache Turbine" must not be used to endorse or promote products
- * derived from this software without prior written permission. For
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache Turbine" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
- * "Apache Turbine", nor may "Apache" appear in their name, without
+ * "Apache Turbine", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
@@ -54,8 +54,8 @@
* <http://www.apache.org/>.
*/
-import org.apache.turbine.om.peer.BasePeer;
-import org.apache.turbine.util.db.map.MapBuilder;
+import org.apache.torque.util.BasePeer;
+import org.apache.torque.map.MapBuilder;
import org.apache.turbine.util.db.map.TurbineMapBuilder;
/**
@@ -70,12 +70,12 @@
public class UserGroupRolePeer extends BasePeer
{
/** The map builder for this Peer. */
- private static final TurbineMapBuilder
- mapBuilder = (TurbineMapBuilder) getMapBuilder();
+ private static final TurbineMapBuilder
+ mapBuilder = (TurbineMapBuilder) getMapBuilder("org.apache.turbine.util.db.map.TurbineMapBuilder");
/** The table name for this peer. */
public static final String TABLE_NAME = mapBuilder.getTableUserGroupRole();
-
+
/** The column name for the visitor id field. */
public static final String USER_ID = mapBuilder.getUserGroupRole_UserId();
1.3 +10 -10 jakarta-turbine-2/src/java/org/apache/turbine/services/db/MapBrokerService.java
Index: MapBrokerService.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/services/db/MapBrokerService.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- MapBrokerService.java 27 Sep 2001 05:22:31 -0000 1.2
+++ MapBrokerService.java 11 Jul 2002 07:16:42 -0000 1.3
@@ -25,13 +25,13 @@
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
- * 4. The names "Apache" and "Apache Software Foundation" and
- * "Apache Turbine" must not be used to endorse or promote products
- * derived from this software without prior written permission. For
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache Turbine" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
- * "Apache Turbine", nor may "Apache" appear in their name, without
+ * "Apache Turbine", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
@@ -56,7 +56,7 @@
import org.apache.turbine.services.Service;
import org.apache.turbine.util.TurbineException;
-import org.apache.turbine.util.db.map.DatabaseMap;
+import org.apache.torque.map.DatabaseMap;
/**
* This service manages {@link org.apache.turbine.util.db.map.DatabaseMap}
@@ -75,7 +75,7 @@
* Name of the default map builder and map.
*/
public static final String DEFAULT = "default";
-
+
/** Name of default map property */
public static final String DEFAULT_MAP = "defaultMap";
@@ -86,12 +86,12 @@
* Returns the default database map information.
*
* @return A DatabaseMap.
- * @throws TurbineException Any exceptions caught during procssing will be
+ * @throws TurbineException Any exceptions caught during procssing will be
* rethrown wrapped into a TurbineException.
*/
public DatabaseMap getDatabaseMap()
throws TurbineException;
-
+
/**
* Returns the database map information. Name relates to the name
* of the connection pool to associate with the map.
@@ -99,7 +99,7 @@
* @param name The name of the <code>DatabaseMap</code> to
* retrieve.
* @return The named <code>DatabaseMap</code>.
- * @throws TurbineException Any exceptions caught during procssing will be
+ * @throws TurbineException Any exceptions caught during procssing will be
* rethrown wrapped into a TurbineException.
*/
public DatabaseMap getDatabaseMap(String name)
1.3 +13 -33 jakarta-turbine-2/src/java/org/apache/turbine/services/db/PoolBrokerService.java
Index: PoolBrokerService.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/services/db/PoolBrokerService.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- PoolBrokerService.java 27 Sep 2001 05:22:31 -0000 1.2
+++ PoolBrokerService.java 11 Jul 2002 07:16:42 -0000 1.3
@@ -25,13 +25,13 @@
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
- * 4. The names "Apache" and "Apache Software Foundation" and
- * "Apache Turbine" must not be used to endorse or promote products
- * derived from this software without prior written permission. For
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache Turbine" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
- * "Apache Turbine", nor may "Apache" appear in their name, without
+ * "Apache Turbine", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
@@ -54,8 +54,8 @@
* <http://www.apache.org/>.
*/
-import org.apache.turbine.util.db.pool.DBConnection;
-import org.apache.turbine.util.db.adapter.DB;
+import java.sql.Connection;
+import org.apache.torque.adapter.DB;
import org.apache.turbine.services.Service;
/**
@@ -64,7 +64,7 @@
* The service can manage a number of connection pools. Each pool is related
* to a specific database, identified by it's driver class name, url, username
* and password. The pools may be defined in TurbineResources.properties
- * file, or created at runtime using
+ * file, or created at runtime using
* {@link #registerPool(String,String,String,String,String)} method.
*
* <p> You can use {@link #getConnection(String)} to acquire a
@@ -101,7 +101,7 @@
* @throws TurbineException Any exceptions caught during processing will be
* rethrown wrapped into a TurbineException.
*/
- public DBConnection getConnection()
+ public Connection getConnection()
throws Exception;
/**
@@ -123,39 +123,18 @@
* @throws TurbineException Any exceptions caught during processing will be
* rethrown wrapped into a TurbineException.
*/
- public DBConnection getConnection(String name)
+ public Connection getConnection(String name)
throws Exception;
/**
- * This method returns a DBConnecton using the given parameters.
- *
- * @param driver The fully-qualified name of the JDBC driver to use.
- * @param url The URL of the database from which the connection is
- * desired.
- * @param username The name of the database user.
- * @param password The password of the database user.
- * @return A DBConnection.
- * @throws TurbineException Any exceptions caught during processing will be
- * rethrown wrapped into a TurbineException.
- *
- * @deprecated Database parameters should not be specified each
- * time a DBConnection is fetched from the service.
- */
- public DBConnection getConnection(String driver,
- String url,
- String username,
- String password)
- throws Exception;
-
- /**
* Release a connection back to the database pool.
*
* @throws TurbineException Any exceptions caught during processing will be
* rethrown wrapped into a TurbineException.
* @exception Exception A generic exception.
*/
- public void releaseConnection(DBConnection dbconn)
+ public void releaseConnection(Connection dbconn)
throws Exception;
/**
@@ -170,13 +149,14 @@
* @throws TurbineException Any exceptions caught during processing will be
* rethrown wrapped into a TurbineException.
*/
+/*
public void registerPool( String name,
String driver,
String url,
String username,
String password )
throws Exception;
-
+*/
/**
* Returns the database adapter for the default connection pool.
1.4 +18 -42 jakarta-turbine-2/src/java/org/apache/turbine/services/db/TurbineDB.java
Index: TurbineDB.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/services/db/TurbineDB.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- TurbineDB.java 27 Sep 2001 06:02:39 -0000 1.3
+++ TurbineDB.java 11 Jul 2002 07:16:42 -0000 1.4
@@ -25,13 +25,13 @@
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
- * 4. The names "Apache" and "Apache Software Foundation" and
- * "Apache Turbine" must not be used to endorse or promote products
- * derived from this software without prior written permission. For
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache Turbine" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
- * "Apache Turbine", nor may "Apache" appear in their name, without
+ * "Apache Turbine", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
@@ -56,19 +56,19 @@
import org.apache.turbine.services.TurbineServices;
import org.apache.turbine.util.TurbineException;
-import org.apache.turbine.util.db.adapter.DB;
-import org.apache.turbine.util.db.map.DatabaseMap;
-import org.apache.turbine.util.db.pool.DBConnection;
+import org.apache.torque.adapter.DB;
+import org.apache.torque.map.DatabaseMap;
+import java.sql.Connection;
/**
* This class provides a common front end to all database - related
* services in Turbine. Currently these are {@link PoolBrokerService} and
* {@link MapBrokerService}. This class contains static methods that you
- * can call to access the methods of system's configured service
+ * can call to access the methods of system's configured service
* implementations.
* <p>
- * Assuming that your TurbineResources.properties file is setup correctly, the
- * sample code below demonstrates the right way to get and release a database
+ * Assuming that your TurbineResources.properties file is setup correctly, the
+ * sample code below demonstrates the right way to get and release a database
* connection (exception handling is application dependent):
* <blockquote><code><pre>
* DBConnection dbConn = null;
@@ -124,7 +124,7 @@
{
// do nothing
}
-
+
return MapBrokerService.DEFAULT;
}
@@ -182,7 +182,7 @@
{
// do nothing
}
-
+
return PoolBrokerService.DEFAULT;
}
@@ -193,7 +193,7 @@
* @throws TurbineException Any exceptions caught during processing will be
* rethrown wrapped into a TurbineException.
*/
- public static DBConnection getConnection()
+ public static Connection getConnection()
throws Exception
{
return getPoolBroker().getConnection();
@@ -218,37 +218,12 @@
* @throws TurbineException Any exceptions caught during processing will be
* rethrown wrapped into a TurbineException.
*/
- public static DBConnection getConnection(String name)
+ public static Connection getConnection(String name)
throws Exception
{
return getPoolBroker().getConnection(name);
}
-
- /**
- * This method returns a DBConnecton using the given parameters.
- *
- * @param driver The fully-qualified name of the JDBC driver to use.
- * @param url The URL of the database from which the connection is
- * desired.
- * @param username The name of the database user.
- * @param password The password of the database user.
- * @return A DBConnection.
- * @throws TurbineException Any exceptions caught during processing will be
- * rethrown wrapped into a TurbineException.
- *
- * @deprecated Database parameters should not be specified each
- * time a DBConnection is fetched from the service.
- */
- public static DBConnection getConnection(String driver,
- String url,
- String username,
- String password)
- throws Exception
- {
- return getPoolBroker().getConnection(driver, url, username, password);
- }
-
/**
* Release a connection back to the database pool.
*
@@ -256,7 +231,7 @@
* rethrown wrapped into a TurbineException.
* @exception Exception A generic exception.
*/
- public static void releaseConnection(DBConnection dbconn)
+ public static void releaseConnection(Connection dbconn)
throws Exception
{
getPoolBroker().releaseConnection(dbconn);
@@ -274,6 +249,7 @@
* @throws TurbineException Any exceptions caught during processing will be
* rethrown wrapped into a TurbineException.
*/
+/*
public static void registerPool( String name,
String driver,
String url,
@@ -283,7 +259,7 @@
{
getPoolBroker().registerPool(name, driver, url, username, password);
}
-
+*/
///////////////////////////////////////////////////////////////////////////
// DB Adapters
///////////////////////////////////////////////////////////////////////////
1.6 +7 -7 jakarta-turbine-2/src/java/org/apache/turbine/services/db/TurbineMapBrokerService.java
Index: TurbineMapBrokerService.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/services/db/TurbineMapBrokerService.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- TurbineMapBrokerService.java 16 Apr 2002 22:07:08 -0000 1.5
+++ TurbineMapBrokerService.java 11 Jul 2002 07:16:42 -0000 1.6
@@ -60,12 +60,12 @@
import org.apache.turbine.services.BaseService;
import org.apache.turbine.services.resources.TurbineResources;
import org.apache.turbine.util.TurbineException;
-import org.apache.turbine.util.db.IDGeneratorFactory;
-import org.apache.turbine.util.db.IDBroker;
-import org.apache.turbine.util.db.adapter.DB;
-import org.apache.turbine.util.db.adapter.DBFactory;
-import org.apache.turbine.util.db.map.DatabaseMap;
-import org.apache.turbine.util.db.map.TableMap;
+import org.apache.torque.oid.IDGeneratorFactory;
+import org.apache.torque.oid.IDBroker;
+import org.apache.torque.adapter.DB;
+import org.apache.torque.adapter.DBFactory;
+import org.apache.torque.map.DatabaseMap;
+import org.apache.torque.map.TableMap;
import org.apache.commons.configuration.Configuration;
1.5 +19 -199 jakarta-turbine-2/src/java/org/apache/turbine/services/db/TurbinePoolBrokerService.java
Index: TurbinePoolBrokerService.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/services/db/TurbinePoolBrokerService.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- TurbinePoolBrokerService.java 16 Apr 2002 22:07:08 -0000 1.4
+++ TurbinePoolBrokerService.java 11 Jul 2002 07:16:42 -0000 1.5
@@ -60,10 +60,11 @@
import org.apache.turbine.services.BaseService;
import org.apache.turbine.services.resources.TurbineResources;
import org.apache.turbine.util.Log;
-import org.apache.turbine.util.db.adapter.DB;
-import org.apache.turbine.util.db.pool.ConnectionPool;
-import org.apache.turbine.util.db.pool.DBConnection;
+import org.apache.torque.adapter.DB;
+import java.sql.Connection;
import org.apache.commons.configuration.Configuration;
+import org.apache.torque.Torque;
+import org.apache.torque.util.BasePeer;
/**
@@ -110,13 +111,13 @@
defaultPool = configuration.getString(DEFAULT_POOL, DEFAULT);
// Create monitor thread
- Monitor monitor = new Monitor();
+// Monitor monitor = new Monitor();
// Indicate that this is a system thread. JVM will quit only when there
// are no more active user threads. Settings threads spawned internally
// by Turbine as daemons allows commandline applications using Turbine
// to terminate in an orderly manner.
- monitor.setDaemon(true);
- monitor.start();
+// monitor.setDaemon(true);
+// monitor.start();
// indicate that the service initialized correctly
setInit(true);
@@ -127,7 +128,7 @@
*/
public String getDefaultDB()
{
- return defaultPool;
+ return Torque.getDefaultDB();
}
/**
@@ -135,22 +136,7 @@
*/
public synchronized void shutdown()
{
- if ( pools != null )
- {
- // Release connections for each pool.
- Iterator pool = pools.values().iterator();
- while ( pool.hasNext() )
- {
- try
- {
- ((ConnectionPool)pool.next()).shutdown();
- }
- catch (Exception ignored)
- {
- // Unlikely.
- }
- }
- }
+ Torque.shutdown();
}
/**
@@ -160,10 +146,10 @@
* @throws TurbineException Any exceptions caught during processing will be
* rethrown wrapped into a TurbineException.
*/
- public DBConnection getConnection()
+ public Connection getConnection()
throws Exception
{
- return getConnection(defaultPool);
+ return Torque.getConnection();
}
/**
@@ -185,48 +171,10 @@
* @throws TurbineException Any exceptions caught during processing will be
* rethrown wrapped into a TurbineException.
*/
- public DBConnection getConnection(String name)
- throws Exception
- {
- // The getPool method ensures the validity of the returned pool.
- return getPool(name).getConnection();
- }
-
- /**
- * This method returns a DBConnecton using the given parameters.
- *
- * @param driver The fully-qualified name of the JDBC driver to use.
- * @param url The URL of the database from which the connection is
- * desired.
- * @param username The name of the database user.
- * @param password The password of the database user.
- * @return A DBConnection.
- * @throws TurbineException Any exceptions caught during processing will be
- * rethrown wrapped into a TurbineException.
- *
- * @deprecated Database parameters should not be specified each
- * time a DBConnection is fetched from the service.
- */
- public DBConnection getConnection(String driver,
- String url,
- String username,
- String password)
+ public Connection getConnection(String name)
throws Exception
{
- ConnectionPool pool = null;
- url = url.trim();
-
- // Quick (non-sync) check for the pool we want.
- // NOTE: Here we must not call getPool(), since the pool
- // is almost certainly not defined in the properties file
- pool = (ConnectionPool) pools.get(url + username);
- if ( pool == null )
- {
- registerPool(url + username, driver, url, username, password);
- pool = (ConnectionPool) pools.get(url + username);
- }
-
- return pool.getConnection();
+ return Torque.getConnection(name);
}
/**
@@ -237,97 +185,10 @@
* rethrown wrapped into a TurbineException.
* @exception Exception A generic exception.
*/
- public void releaseConnection(DBConnection dbconn)
- throws Exception
- {
- if ( dbconn != null )
- {
- ConnectionPool pool = dbconn.getPool();
- if ( pools.containsValue( pool ) )
- {
- pool.releaseConnection( dbconn );
- }
- }
- }
-
- /**
- * This method registers a new pool using the given parameters.
- *
- * @param name The name of the pool to register.
- * @param driver The fully-qualified name of the JDBC driver to use.
- * @param url The URL of the database to use.
- * @param username The name of the database user.
- * @param password The password of the database user.
- *
- * @throws Exception Any exceptions caught during processing will be
- * rethrown wrapped into a TurbineException.
- */
- public void registerPool( String name,
- String driver,
- String url,
- String username,
- String password )
- throws Exception
- {
- /**
- * Added so that the configuration file can define maxConnections &
- * expiryTime for each database pool that is defined in the
- * TurbineResources.properties
- * Was defined as: database.expiryTime=3600000
- * If you need per database, it is
- * now database.helpdesk.expiryTime=3600000
- */
- registerPool(name,
- driver,
- url,
- username,
- password,
- TurbineResources.getInt(
- getProperty(name, "maxConnections"), 10),
- TurbineResources.getLong(
- getProperty(name, "expiryTime"), 3600000));
- }
-
- /**
- * This thread-safe method registers a new pool using the given parameters.
- *
- * @param name The name of the pool to register.
- * @param driver The fully-qualified name of the JDBC driver to use.
- * @param url The URL of the database to use.
- * @param username The name of the database user.
- * @param password The password of the database user.
- * @exception Exception A generic exception.
- */
- public void registerPool( String name,
- String driver,
- String url,
- String username,
- String password,
- int maxCons,
- long expiryTime)
+ public void releaseConnection(Connection dbconn)
throws Exception
{
-
- // Quick (non-sync) check for the pool we want.
- if ( !pools.containsKey(name) )
- {
- // Pool not there...
- synchronized ( pools )
- {
- // ... sync and look again to avoid race collisions.
- if ( !pools.containsKey(name) )
- {
- // Still not there. Create and add.
- ConnectionPool pool =
- new ConnectionPool(driver,
- url,
- username,
- password,
- maxCons,expiryTime);
- pools.put( name, pool );
- }
- }
- }
+ BasePeer.closeConnection(dbconn);
}
/**
@@ -354,55 +215,12 @@
public DB getDB(String name)
throws Exception
{
- return getPool(name).getDB();
+ return Torque.getDB(getDefaultDB());
}
///////////////////////////////////////////////////////////////////////////
/**
- * This method returns the default pool.
- *
- * @return The default pool.
- * @exception Exception A generic exception.
- */
- private ConnectionPool getPool()
- throws Exception
- {
- return getPool(DEFAULT);
- }
-
- /**
- * This method returns a pool with the specified name. The pool must
- * either have been registered with the
- * {@link #registerPool(String,String,String,String,String)} methd, or be
- * specified in the TurbineResources properties. This method is used
- * interanlly by the service.
- *
- * @param name The name of the pool to get.
- * @return The requested pool.
- *
- * @exception Exception A generic exception.
- */
- private ConnectionPool getPool(String name)
- throws Exception
- {
- ConnectionPool pool = (ConnectionPool) pools.get(name);
-
- // If the pool is not in the Hashtable, we must register it.
- if ( pool == null )
- {
- registerPool( name,
- getDatabaseProperty(name, "driver"),
- getDatabaseProperty(name, "url"),
- getDatabaseProperty(name, "username"),
- getDatabaseProperty(name, "password") );
- pool = (ConnectionPool) pools.get(name);
- }
-
- return pool;
- }
-
- /**
* Returns the specified property of the given database, or the empty
* string if no value is set for the property.
*
@@ -451,6 +269,7 @@
* milliseconds you want to elapse between loging the number of
* connections.
*/
+/*
protected class Monitor extends Thread
{
public void run()
@@ -485,4 +304,5 @@
}
}
}
+*/
}
1.3 +2 -2 jakarta-turbine-2/src/java/org/apache/turbine/services/security/BaseSecurityService.java
Index: BaseSecurityService.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/services/security/BaseSecurityService.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- BaseSecurityService.java 14 Dec 2001 16:06:36 -0000 1.2
+++ BaseSecurityService.java 11 Jul 2002 07:16:42 -0000 1.3
@@ -58,7 +58,7 @@
import org.apache.turbine.util.Log;
import org.apache.turbine.util.RunData;
-import org.apache.turbine.util.db.Criteria;
+import org.apache.torque.util.Criteria;
import org.apache.turbine.om.security.User;
import org.apache.turbine.om.security.Group;
import org.apache.turbine.om.security.Role;
1.2 +49 -49 jakarta-turbine-2/src/java/org/apache/turbine/services/security/SecurityService.java
Index: SecurityService.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/services/security/SecurityService.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- SecurityService.java 16 Aug 2001 05:09:16 -0000 1.1
+++ SecurityService.java 11 Jul 2002 07:16:42 -0000 1.2
@@ -25,13 +25,13 @@
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
- * 4. The names "Apache" and "Apache Software Foundation" and
- * "Apache Turbine" must not be used to endorse or promote products
- * derived from this software without prior written permission. For
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache Turbine" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
- * "Apache Turbine", nor may "Apache" appear in their name, without
+ * "Apache Turbine", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
@@ -73,25 +73,25 @@
import org.apache.turbine.util.security.PasswordMismatchException;
import org.apache.turbine.util.security.TurbineSecurityException;
-import org.apache.turbine.util.db.Criteria;
+import org.apache.torque.util.Criteria;
/**
- * The Security Service manages Users, Groups Roles and Permissions in the
+ * The Security Service manages Users, Groups Roles and Permissions in the
* system.
*
- * The task performed by the security service include creation and removal of
- * accounts, groups, roles, and permissions; assigning users roles in groups;
- * assigning roles specific permissions and construction of objects
+ * The task performed by the security service include creation and removal of
+ * accounts, groups, roles, and permissions; assigning users roles in groups;
+ * assigning roles specific permissions and construction of objects
* representing these logical entities.
*
- * <p> Because of pluggable nature of the Services, it is possible to create
- * multiple implementations of SecurityService, for example employing database
+ * <p> Because of pluggable nature of the Services, it is possible to create
+ * multiple implementations of SecurityService, for example employing database
* and directory server as the data backend.<br>
*
* @author <a href="mailto:Rafal.Krzewski@e-point.pl">Rafal Krzewski</a>
* @version $Id$
*/
-public interface SecurityService
+public interface SecurityService
extends Service
{
/** The name of the service */
@@ -99,31 +99,31 @@
/** the key within services's properties for user implementation classname (user.class) */
public static final String USER_CLASS_KEY = "user.class";
-
+
/** the default implementation of User interface (org.apache.turbine.om.security.DBUser) */
public static final String USER_CLASS_DEFAULT = "org.apache.turbine.om.security.TurbineUser";
/** the key within services's properties for user implementation classname (user.manager) */
public static final String USER_MANAGER_KEY = "user.manager";
-
+
/** the default implementation of UserManager interface (org.apache.turbine.services.security.DBUserManager) */
public static final String USER_MANAGER_DEFAULT = "org.apache.turbine.services.security.DBUserManager";
/** the key within services's properties for secure passwords flag (secure.passwords) */
public static final String SECURE_PASSWORDS_KEY = "secure.passwords";
-
+
/** the value of secure passwords flag (false) */
public static final String SECURE_PASSWORDS_DEFAULT = "false";
/** the key within services's properties for secure passwords algorithm (secure.passwords.algorithm) */
public static final String SECURE_PASSWORDS_ALGORITHM_KEY = "secure.passwords.algorithm";
-
+
/** the default algorithm for password encryption (SHA) */
public static final String SECURE_PASSWORDS_ALGORITHM_DEFAULT = "SHA";
/*-----------------------------------------------------------------------
Management of User objects
- -----------------------------------------------------------------------*/
+ -----------------------------------------------------------------------*/
/**
* Returns the Class object for the implementation of User interface
@@ -193,7 +193,7 @@
* @throws DataBackendException if there was an error accessing the data backend.
* @throws UnknownEntityException if user account is not present.
*/
- public User getUser( String username )
+ public User getUser( String username )
throws DataBackendException, UnknownEntityException;
/**
@@ -217,7 +217,7 @@
* Constructs an User object to represent an anonymous user of the application.
*
* @return An anonymous Turbine User.
- * @throws UnknownEntityException if the anonymous User object couldn't be
+ * @throws UnknownEntityException if the anonymous User object couldn't be
* constructed.
*/
public User getAnonymousUser()
@@ -234,10 +234,10 @@
*/
public void saveUser( User user )
throws UnknownEntityException, DataBackendException;
-
+
/*-----------------------------------------------------------------------
Account management
- -----------------------------------------------------------------------*/
+ -----------------------------------------------------------------------*/
/**
* Creates new user account with specified attributes.
@@ -246,7 +246,7 @@
* @throws DataBackendException if there was an error accessing the data backend.
* @throws EntityExistsException if the user account already exists.
*/
- public void addUser( User user, String password )
+ public void addUser( User user, String password )
throws DataBackendException, EntityExistsException;
/**
@@ -256,19 +256,19 @@
* @throws DataBackendException if there was an error accessing the data backend.
* @throws UnknownEntityException if the user account is not present.
*/
- public void removeUser( User user )
+ public void removeUser( User user )
throws DataBackendException, UnknownEntityException;
/*-----------------------------------------------------------------------
Management of passwords
- -----------------------------------------------------------------------*/
+ -----------------------------------------------------------------------*/
/**
- * This method provides client-side encryption mechanism for passwords.
- *
+ * This method provides client-side encryption mechanism for passwords.
+ *
* This is an utility method that is used by other classes to maintain
* a consistent approach to encrypting password. The behavior of the
- * method can be configured in service's properties.
+ * method can be configured in service's properties.
*
* @param password the password to process
* @return processed password
@@ -281,7 +281,7 @@
* @param user an User to change password for.
* @param oldPassword the current password supplied by the user.
* @param newPassword the current password requested by the user.
- * @exception PasswordMismatchException if the supplied password was
+ * @exception PasswordMismatchException if the supplied password was
* incorrect.
* @exception UnknownEntityException if the user's record does not
* exist in the database.
@@ -289,17 +289,17 @@
* storage.
*/
public void changePassword( User user, String oldPassword, String newPassword )
- throws PasswordMismatchException, UnknownEntityException,
+ throws PasswordMismatchException, UnknownEntityException,
DataBackendException;
/**
* Forcibly sets new password for an User.
*
* This is supposed by the administrator to change the forgotten or
- * compromised passwords. Certain implementatations of this feature
- * would require administrative level access to the authenticating
+ * compromised passwords. Certain implementatations of this feature
+ * would require administrative level access to the authenticating
* server / program.
- *
+ *
* @param user an User to change password for.
* @param password the new password.
* @exception UnknownEntityException if the user's record does not
@@ -312,7 +312,7 @@
/*-----------------------------------------------------------------------
Retrieval of security information
- -----------------------------------------------------------------------*/
+ -----------------------------------------------------------------------*/
/**
* Constructs an AccessControlList for a specific user.
@@ -321,7 +321,7 @@
* @throws DataBackendException if there was an error accessing the data backend.
* @throws UnknownEntityException if user account is not present.
*/
- public AccessControlList getACL( User user )
+ public AccessControlList getACL( User user )
throws DataBackendException, UnknownEntityException;
/**
@@ -336,9 +336,9 @@
/*-----------------------------------------------------------------------
Manipulation of security information
- -----------------------------------------------------------------------*/
+ -----------------------------------------------------------------------*/
- /**
+ /**
* Grant an User a Role in a Group.
*
* @param User the user.
@@ -350,7 +350,7 @@
public void grant( User user, Group group, Role role )
throws DataBackendException, UnknownEntityException;
- /**
+ /**
* Revoke a Role in a Group from an User.
*
* @param User the user.
@@ -413,9 +413,9 @@
-----------------------------------------------------------------------*/
/**
- * Provides a reference to the Group object that represents the
- * <a href="#global">global group</a>.
- *
+ * Provides a reference to the Group object that represents the
+ * <a href="#global">global group</a>.
+ *
* @return a Group object that represents the global group.
*/
public Group getGlobalGroup();
@@ -448,7 +448,7 @@
public Permission getNewPermission( String permissionName );
/**
- * Retrieve a Group object with specified name.
+ * Retrieve a Group object with specified name.
*
* @param name the name of the Group.
* @return an object representing the Group with specified name.
@@ -457,7 +457,7 @@
throws DataBackendException, UnknownEntityException;
/**
- * Retrieve a Role object with specified name.
+ * Retrieve a Role object with specified name.
*
* @param name the name of the Role.
* @return an object representing the Role with specified name.
@@ -466,14 +466,14 @@
throws DataBackendException, UnknownEntityException;
/**
- * Retrieve a Permission object with specified name.
+ * Retrieve a Permission object with specified name.
*
* @param name the name of the Permission.
* @return an object representing the Permission with specified name.
*/
public Permission getPermission( String name )
throws DataBackendException, UnknownEntityException;
-
+
/**
* Retrieve a set of Groups that meet the specified Criteria.
*
@@ -482,7 +482,7 @@
*/
public GroupSet getGroups( Criteria criteria )
throws DataBackendException;
-
+
/**
* Retrieve a set of Roles that meet the specified Criteria.
*
@@ -559,7 +559,7 @@
/*-----------------------------------------------------------------------
Group/Role/Permission management
- -----------------------------------------------------------------------*/
+ -----------------------------------------------------------------------*/
/**
* Creates a new group with specified attributes.
@@ -569,7 +569,7 @@
* @throws DataBackendException if there was an error accessing the data backend.
* @throws EntityExistsException if the group already exists.
*/
- public Group addGroup( Group group )
+ public Group addGroup( Group group )
throws DataBackendException, EntityExistsException;
/**
@@ -634,7 +634,7 @@
*/
public void renameGroup( Group group, String name )
throws DataBackendException, UnknownEntityException;
-
+
/**
* Renames an existing Role.
*
1.2 +42 -42 jakarta-turbine-2/src/java/org/apache/turbine/services/security/TurbineSecurity.java
Index: TurbineSecurity.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/services/security/TurbineSecurity.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- TurbineSecurity.java 16 Aug 2001 05:09:17 -0000 1.1
+++ TurbineSecurity.java 11 Jul 2002 07:16:42 -0000 1.2
@@ -25,13 +25,13 @@
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
- * 4. The names "Apache" and "Apache Software Foundation" and
- * "Apache Turbine" must not be used to endorse or promote products
- * derived from this software without prior written permission. For
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache Turbine" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
- * "Apache Turbine", nor may "Apache" appear in their name, without
+ * "Apache Turbine", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
@@ -73,19 +73,19 @@
import org.apache.turbine.util.security.PasswordMismatchException;
import org.apache.turbine.util.security.TurbineSecurityException;
-import org.apache.turbine.util.db.Criteria;
+import org.apache.torque.util.Criteria;
/**
* This is a Facade class for SecurityService.
*
- * This class provides static methods that call related methods of the
+ * This class provides static methods that call related methods of the
* implementation of SecurityService used by the System, according to
* the settings in TurbineResources.
* <br>
*
* <a name="global">
* <p> Certain Roles that the Users may have in the system may are not related
- * to any specific resource nor entity. They are assigned within a special group
+ * to any specific resource nor entity. They are assigned within a special group
* named 'global' that can be referenced in the code as {@link org.apache.turbine.om.security.Group#GLOBAL_GROUP_NAME}.
*
* @author <a href="mailto:Rafal.Krzewski@e-point.pl">Rafal Krzewski</a>
@@ -102,26 +102,26 @@
public static SecurityService getService()
{
return (SecurityService)TurbineServices.getInstance().
- getService(SecurityService.SERVICE_NAME);
+ getService(SecurityService.SERVICE_NAME);
}
/*-----------------------------------------------------------------------
Management of User objects
- -----------------------------------------------------------------------*/
+ -----------------------------------------------------------------------*/
- /*
- * This method provides client-side encryption of passwords.
- *
+ /*
+ * This method provides client-side encryption of passwords.
+ *
* This is an utility method that is used by other classes to maintain
* a consistent approach to encrypting password. The behavior of the
- * method can be configured in service's properties.
+ * method can be configured in service's properties.
*
* @param password the password to process
* @return processed password
*/
public static String encryptPassword( String password )
{
- return getService().encryptPassword(password);
+ return getService().encryptPassword(password);
}
/**
@@ -129,7 +129,7 @@
* of User interface.
*
* @return systems's chosen implementation of User interface.
- * @throws UnknownEntityException if the implementation of User interface
+ * @throws UnknownEntityException if the implementation of User interface
* could not be determined, or does not exist.
*/
public static Class getUserClass()
@@ -207,7 +207,7 @@
* @throws DataBackendException if there was an error accessing the data backend.
* @throws UnknownEntityException if user account is not present.
*/
- public static User getUser( String username )
+ public static User getUser( String username )
throws DataBackendException, UnknownEntityException
{
return getService().getUser(username);
@@ -237,7 +237,7 @@
* Constructs an User object to represent an anonymous user of the application.
*
* @return An anonymous Turbine User.
- * @throws UnknownEntityException if the anonymous User object couldn't be
+ * @throws UnknownEntityException if the anonymous User object couldn't be
* constructed.
*/
public static User getAnonymousUser()
@@ -267,7 +267,7 @@
* @param user an User to change password for.
* @param oldPassword the current password supplied by the user.
* @param newPassword the current password requested by the user.
- * @exception PasswordMismatchException if the supplied password was
+ * @exception PasswordMismatchException if the supplied password was
* incorrect.
* @exception UnknownEntityException if the user's record does not
* exist in the database.
@@ -275,7 +275,7 @@
* storage.
*/
public static void changePassword( User user, String oldPassword, String newPassword )
- throws PasswordMismatchException, UnknownEntityException,
+ throws PasswordMismatchException, UnknownEntityException,
DataBackendException
{
getService().changePassword(user, oldPassword, newPassword);
@@ -285,10 +285,10 @@
* Forcibly sets new password for an User.
*
* This is supposed by the administrator to change the forgotten or
- * compromised passwords. Certain implementatations of this feature
- * would require administrative level access to the authenticating
+ * compromised passwords. Certain implementatations of this feature
+ * would require administrative level access to the authenticating
* server / program.
- *
+ *
* @param user an User to change password for.
* @param password the new password.
* @exception UnknownEntityException if the user's record does not
@@ -304,7 +304,7 @@
/*-----------------------------------------------------------------------
Creation of AccessControlLists
- -----------------------------------------------------------------------*/
+ -----------------------------------------------------------------------*/
/**
* Constructs an AccessControlList for a specific user.
@@ -313,7 +313,7 @@
* @throws DataBackendException if there was an error accessing the data backend.
* @throws UnknownEntityException if user account is not present.
*/
- public static AccessControlList getACL( User user )
+ public static AccessControlList getACL( User user )
throws DataBackendException, UnknownEntityException
{
return getService().getACL(user);
@@ -321,9 +321,9 @@
/*-----------------------------------------------------------------------
Security management
- -----------------------------------------------------------------------*/
+ -----------------------------------------------------------------------*/
- /**
+ /**
* Grant an User a Role in a Group.
*
* @param User the user.
@@ -338,7 +338,7 @@
getService().grant(user, group, role);
}
- /**
+ /**
* Revoke a Role in a Group from an User.
*
* @param User the user.
@@ -413,7 +413,7 @@
/*-----------------------------------------------------------------------
Account management
- -----------------------------------------------------------------------*/
+ -----------------------------------------------------------------------*/
/**
* Creates new user account with specified attributes.
@@ -424,7 +424,7 @@
* @throws DataBackendException if there was an error accessing the data backend.
* @throws EntityExistsException if the user account already exists.
*/
- public static void addUser( User user, String password )
+ public static void addUser( User user, String password )
throws DataBackendException, EntityExistsException
{
getService().addUser(user, password);
@@ -435,13 +435,13 @@
* Removes an user account from the system.
*
* <strong>TODO</strong> throw more specific exception<br>
- *
+ *
* @param user the object describing the account to be removed.
* @throws DataBackendException if there was an error accessing the data backend.
* @throws UnknownEntityException if the user account is not present.
*/
- public static void removeUser( User user )
- throws DataBackendException, UnknownEntityException
+ public static void removeUser( User user )
+ throws DataBackendException, UnknownEntityException
{
getService().removeUser(user);
}
@@ -449,11 +449,11 @@
/*-----------------------------------------------------------------------
Group/Role/Permission management
- -----------------------------------------------------------------------*/
+ -----------------------------------------------------------------------*/
/**
- * Provides a reference to the Group object that represents the
- * <a name="global">global group</a>.
- *
+ * Provides a reference to the Group object that represents the
+ * <a name="global">global group</a>.
+ *
* @return a Group object that represents the global group.
*/
public static Group getGlobalGroup()
@@ -464,7 +464,7 @@
/**
* Creates a new Group in the system. This is a convenience
* method.
- *
+ *
* @param name The name of the new Group.
* @return An object representing the new Group.
* @throws TurbineSecurityException if the Group could not be created.
@@ -478,7 +478,7 @@
/**
* Creates a new Permission in the system. This is a convenience
* method.
- *
+ *
* @param name The name of the new Permission.
* @return An object representing the new Permission.
* @throws TurbineSecurityException if the Permission could not be created.
@@ -585,7 +585,7 @@
return getService().getGroups(criteria);
}
-
+
/**
* Retrieve a set of Roles that meet the specified Criteria.
*
@@ -704,7 +704,7 @@
* @throws DataBackendException if there was an error accessing the data backend.
* @throws EntityExistsException if the group already exists.
*/
- public static void addGroup( Group group )
+ public static void addGroup( Group group )
throws DataBackendException, EntityExistsException
{
getService().addGroup(group);
@@ -788,7 +788,7 @@
{
getService().renameGroup(group, name);
}
-
+
/**
* Renames an existing Role.
*
1.2 +17 -17 jakarta-turbine-2/src/java/org/apache/turbine/services/security/UserManager.java
Index: UserManager.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/services/security/UserManager.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- UserManager.java 16 Aug 2001 05:09:18 -0000 1.1
+++ UserManager.java 11 Jul 2002 07:16:42 -0000 1.2
@@ -25,13 +25,13 @@
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
- * 4. The names "Apache" and "Apache Software Foundation" and
- * "Apache Turbine" must not be used to endorse or promote products
- * derived from this software without prior written permission. For
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache Turbine" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
- * "Apache Turbine", nor may "Apache" appear in their name, without
+ * "Apache Turbine", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
@@ -60,10 +60,10 @@
import org.apache.turbine.util.security.EntityExistsException;
import org.apache.turbine.util.security.PasswordMismatchException;
-import org.apache.turbine.util.db.Criteria;
+import org.apache.torque.util.Criteria;
/**
- * An UserManager performs {@link org.apache.turbine.om.security.User} objects
+ * An UserManager performs {@link org.apache.turbine.om.security.User} objects
* related tasks on behalf of the {@link org.apache.turbine.services.security.BaseSecurityService}.
*
* The responsibilities of this class include loading data of an user from the
@@ -101,7 +101,7 @@
/**
* Retrieve a user from persistent storage using username as the
- * key.
+ * key.
*
* @param username the name of the user.
* @return an User object.
@@ -139,7 +139,7 @@
* @param username the name of the user.
* @param password the user supplied password.
* @return an User object.
- * @exception PasswordMismatchException if the supplied password was
+ * @exception PasswordMismatchException if the supplied password was
* incorrect.
* @exception UnknownEntityException if the user's record does not
* exist in the database.
@@ -147,7 +147,7 @@
* storage.
*/
public User retrieve( String username, String password )
- throws PasswordMismatchException, UnknownEntityException,
+ throws PasswordMismatchException, UnknownEntityException,
DataBackendException;
/**
@@ -170,7 +170,7 @@
*
* @param user an User object to authenticate.
* @param password the user supplied password.
- * @exception PasswordMismatchException if the supplied password was
+ * @exception PasswordMismatchException if the supplied password was
* incorrect.
* @exception UnknownEntityException if the user's record does not
* exist in the database.
@@ -178,7 +178,7 @@
* storage.
*/
public void authenticate( User user, String password )
- throws PasswordMismatchException, UnknownEntityException,
+ throws PasswordMismatchException, UnknownEntityException,
DataBackendException;
/**
@@ -206,7 +206,7 @@
* @param user an User to change password for.
* @param oldPassword the current password suplied by the user.
* @param newPassword the current password requested by the user.
- * @exception PasswordMismatchException if the supplied password was
+ * @exception PasswordMismatchException if the supplied password was
* incorrect.
* @exception UnknownEntityException if the user's record does not
* exist in the database.
@@ -214,17 +214,17 @@
* storage.
*/
public void changePassword( User user, String oldPassword, String newPassword )
- throws PasswordMismatchException, UnknownEntityException,
+ throws PasswordMismatchException, UnknownEntityException,
DataBackendException;
/**
* Forcibly sets new password for an User.
*
* This is supposed by the administrator to change the forgotten or
- * compromised passwords. Certain implementatations of this feature
- * would require administrative level access to the authenticating
+ * compromised passwords. Certain implementatations of this feature
+ * would require administrative level access to the authenticating
* server / program.
- *
+ *
* @param user an User to change password for.
* @param password the new password.
* @exception UnknownEntityException if the user's record does not
1.5 +74 -74 jakarta-turbine-2/src/java/org/apache/turbine/services/security/db/DBSecurityService.java
Index: DBSecurityService.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/services/security/db/DBSecurityService.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- DBSecurityService.java 26 Dec 2001 21:24:58 -0000 1.4
+++ DBSecurityService.java 11 Jul 2002 07:16:42 -0000 1.5
@@ -25,13 +25,13 @@
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
- * 4. The names "Apache" and "Apache Software Foundation" and
- * "Apache Turbine" must not be used to endorse or promote products
- * derived from this software without prior written permission. For
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache Turbine" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
- * "Apache Turbine", nor may "Apache" appear in their name, without
+ * "Apache Turbine", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
@@ -60,10 +60,10 @@
import java.util.Map;
import java.util.Properties;
import java.util.Set;
-import java.util.Vector;
+import java.util.*;
import org.apache.turbine.om.BaseObject;
-import org.apache.turbine.om.ObjectKey;
-import org.apache.turbine.om.peer.BasePeer;
+import org.apache.torque.om.ObjectKey;
+import org.apache.torque.util.BasePeer;
import org.apache.turbine.om.security.Group;
import org.apache.turbine.om.security.Permission;
import org.apache.turbine.om.security.Role;
@@ -83,7 +83,7 @@
import org.apache.turbine.services.security.BaseSecurityService;
import org.apache.turbine.services.security.TurbineSecurity;
import org.apache.turbine.util.Log;
-import org.apache.turbine.util.db.Criteria;
+import org.apache.torque.util.Criteria;
import org.apache.turbine.util.security.AccessControlList;
import org.apache.turbine.util.security.DataBackendException;
import org.apache.turbine.util.security.EntityExistsException;
@@ -93,7 +93,7 @@
import org.apache.turbine.util.security.UnknownEntityException;
/**
- * An implementation of SecurityService that uses a database as backend.
+ * An implementation of SecurityService that uses a database as backend.
*
* @author <a href="mailto:Rafal.Krzewski@e-point.pl">Rafal Krzewski</a>
* @author <a href="mailto:marco@intermeta.de">Marco Knüttel</a>
@@ -101,22 +101,22 @@
*/
public class DBSecurityService extends BaseSecurityService
{
- /**
- * The key within services's properties for user implementation
- * classname (user.class) - Leandro
+ /**
+ * The key within services's properties for user implementation
+ * classname (user.class) - Leandro
*/
public static final String USER_PEER_CLASS_KEY = "userPeer.class";
-
- /**
- * The default implementation of User interface
- * (org.apache.turbine.om.security.DBUser)
+
+ /**
+ * The default implementation of User interface
+ * (org.apache.turbine.om.security.DBUser)
*/
- public static final String USER_PEER_CLASS_DEFAULT =
+ public static final String USER_PEER_CLASS_DEFAULT =
"org.apache.turbine.om.security.peer.TurbineUserPeer";
-
+
/*-----------------------------------------------------------------------
Creation of AccessControlLists
- -----------------------------------------------------------------------*/
+ -----------------------------------------------------------------------*/
/**
* Constructs an AccessControlList for a specific user.
@@ -129,12 +129,12 @@
* @throws DataBackendException if there was an error accessing the data backend.
* @throws UnknownEntityException if user account is not present.
*/
- public AccessControlList getACL( User user )
+ public AccessControlList getACL( User user )
throws DataBackendException, UnknownEntityException
{
if(!TurbineSecurity.accountExists(user))
{
- throw new UnknownEntityException("The account '" +
+ throw new UnknownEntityException("The account '" +
user.getUserName() + "' does not exist");
}
try
@@ -173,7 +173,7 @@
}
catch(Exception e)
{
- throw new DataBackendException("Failed to build ACL for user '" +
+ throw new DataBackendException("Failed to build ACL for user '" +
user.getUserName() + "'" , e);
}
finally
@@ -185,9 +185,9 @@
/*-----------------------------------------------------------------------
Security management
- -----------------------------------------------------------------------*/
+ -----------------------------------------------------------------------*/
- /**
+ /**
* Grant an User a Role in a Group.
*
* @param User the user.
@@ -211,7 +211,7 @@
if(userExists && groupExists && roleExists)
{
Criteria criteria = new Criteria();
- criteria.add(UserGroupRolePeer.USER_ID,
+ criteria.add(UserGroupRolePeer.USER_ID,
((BaseObject)user).getPrimaryKey());
criteria.add(UserGroupRolePeer.GROUP_ID, ((BaseObject)group).getPrimaryKey());
criteria.add(UserGroupRolePeer.ROLE_ID, ((TurbineRole)role).getPrimaryKey());
@@ -225,26 +225,26 @@
}
finally
{
- unlockExclusive();
+ unlockExclusive();
}
if(!userExists)
{
- throw new UnknownEntityException("Unknown user '" +
+ throw new UnknownEntityException("Unknown user '" +
user.getUserName() + "'");
}
if(!groupExists)
{
- throw new UnknownEntityException("Unknown group '" +
+ throw new UnknownEntityException("Unknown group '" +
((SecurityObject)group).getName() + "'");
}
if(!roleExists)
{
- throw new UnknownEntityException("Unknown role '" +
+ throw new UnknownEntityException("Unknown role '" +
role.getName() + "'");
}
}
- /**
+ /**
* Revoke a Role in a Group from an User.
*
* @param User the user.
@@ -268,9 +268,9 @@
if(userExists && groupExists && roleExists)
{
Criteria criteria = new Criteria();
- criteria.add(UserGroupRolePeer.USER_ID,
+ criteria.add(UserGroupRolePeer.USER_ID,
((BaseObject)user).getPrimaryKey());
- criteria.add(UserGroupRolePeer.GROUP_ID,
+ criteria.add(UserGroupRolePeer.GROUP_ID,
((BaseObject)group).getPrimaryKey());
criteria.add(UserGroupRolePeer.ROLE_ID, ((TurbineRole)role).getPrimaryKey());
UserGroupRolePeer.doDelete(criteria);
@@ -283,21 +283,21 @@
}
finally
{
- unlockExclusive();
+ unlockExclusive();
}
if(!userExists)
{
- throw new UnknownEntityException("Unknown user '" +
+ throw new UnknownEntityException("Unknown user '" +
user.getUserName() + "'");
}
if(!groupExists)
{
- throw new UnknownEntityException("Unknown group '" +
+ throw new UnknownEntityException("Unknown group '" +
((SecurityObject)group).getName() + "'");
}
if(!roleExists)
{
- throw new UnknownEntityException("Unknown role '" +
+ throw new UnknownEntityException("Unknown role '" +
role.getName() + "'");
}
}
@@ -322,7 +322,7 @@
if(userExists)
{
// The following would not work, due to an annoying misfeature of Village.
- // Village allows only a single row to be deleted at a time. I wish that
+ // Village allows only a single row to be deleted at a time. I wish that
// it was possible to disable this behaviour!
// Criteria criteria = new Criteria();
@@ -339,7 +339,7 @@
}
finally
{
- unlockExclusive();
+ unlockExclusive();
}
throw new UnknownEntityException("Unknown user '"+user.getUserName()+"'");
}
@@ -366,7 +366,7 @@
{
Criteria criteria = new Criteria();
criteria.add(RolePermissionPeer.ROLE_ID, ((TurbineRole)role).getPrimaryKey());
- criteria.add(RolePermissionPeer.PERMISSION_ID,
+ criteria.add(RolePermissionPeer.PERMISSION_ID,
((BaseObject)permission).getPrimaryKey());
UserGroupRolePeer.doInsert(criteria);
return;
@@ -378,16 +378,16 @@
}
finally
{
- unlockExclusive();
+ unlockExclusive();
}
if(!roleExists)
{
- throw new UnknownEntityException("Unknown role '" +
+ throw new UnknownEntityException("Unknown role '" +
role.getName() + "'");
}
if(!permissionExists)
{
- throw new UnknownEntityException("Unknown permission '" +
+ throw new UnknownEntityException("Unknown permission '" +
((SecurityObject)permission).getName() + "'");
}
}
@@ -414,7 +414,7 @@
{
Criteria criteria = new Criteria();
criteria.add(RolePermissionPeer.ROLE_ID, ((TurbineRole)role).getPrimaryKey());
- criteria.add(RolePermissionPeer.PERMISSION_ID,
+ criteria.add(RolePermissionPeer.PERMISSION_ID,
((BaseObject)permission).getPrimaryKey());
RolePermissionPeer.doDelete(criteria);
return;
@@ -426,16 +426,16 @@
}
finally
{
- unlockExclusive();
+ unlockExclusive();
}
if(!roleExists)
{
- throw new UnknownEntityException("Unknown role '" +
+ throw new UnknownEntityException("Unknown role '" +
role.getName() + "'");
}
if(!permissionExists)
{
- throw new UnknownEntityException("Unknown permission '" +
+ throw new UnknownEntityException("Unknown permission '" +
((SecurityObject)permission).getName() + "'");
}
}
@@ -467,7 +467,7 @@
// RolePermissionPeer.doDelete(criteria);
int id = ((TurbineRole)role).getPrimaryKeyAsInt();
- RolePermissionPeer.deleteAll(RolePermissionPeer.TABLE_NAME,
+ RolePermissionPeer.deleteAll(RolePermissionPeer.TABLE_NAME,
RolePermissionPeer.ROLE_ID, id);
return;
}
@@ -478,14 +478,14 @@
}
finally
{
- unlockExclusive();
+ unlockExclusive();
}
throw new UnknownEntityException("Unknown role '" + role.getName() + "'");
}
/*-----------------------------------------------------------------------
Group/Role/Permission management
- -----------------------------------------------------------------------*/
+ -----------------------------------------------------------------------*/
/**
* Retrieve a set of Groups that meet the specified Criteria.
@@ -503,7 +503,7 @@
String key = (String)keys.next();
dbCriteria.put(GroupPeer.getColumnName(key), criteria.get(key));
}
- Vector groups = new Vector(0);
+ List groups = new ArrayList(0);
try
{
groups = GroupPeer.doSelect(criteria);
@@ -514,7 +514,7 @@
}
return new GroupSet(groups);
}
-
+
/**
* Retrieve a set of Roles that meet the specified Criteria.
*
@@ -531,7 +531,7 @@
String key = (String)keys.next();
dbCriteria.put(RolePeer.getColumnName(key), criteria.get(key));
}
- Vector roles = new Vector(0);
+ List roles = new ArrayList(0);
try
{
roles = RolePeer.doSelect(criteria);
@@ -549,7 +549,7 @@
* @param a Criteria of Permissions selection.
* @return a set of Permissions that meet the specified Criteria.
*/
- public PermissionSet getPermissions( Criteria criteria )
+ public PermissionSet getPermissions(Criteria criteria)
throws DataBackendException
{
Criteria dbCriteria = new Criteria();
@@ -559,7 +559,7 @@
String key = (String)keys.next();
dbCriteria.put(PermissionPeer.getColumnName(key), criteria.get(key));
}
- Vector permissions = new Vector(0);
+ List permissions = new Vector(0);
try
{
permissions = PermissionPeer.doSelect(criteria);
@@ -599,7 +599,7 @@
{
unlockShared();
}
- throw new UnknownEntityException("Unknown role '" +
+ throw new UnknownEntityException("Unknown role '" +
role.getName() + "'");
}
@@ -731,7 +731,7 @@
* @throws DataBackendException if there was an error accessing the data backend.
* @throws EntityExistsException if the group already exists.
*/
- public synchronized Group addGroup( Group group )
+ public synchronized Group addGroup( Group group )
throws DataBackendException, EntityExistsException
{
boolean groupExists = false;
@@ -747,11 +747,11 @@
// try to get the object back using the name as key.
criteria = new Criteria();
criteria.add(GroupPeer.NAME, ((SecurityObject)group).getName());
- Vector results = GroupPeer.doSelect(criteria);
+ List results = GroupPeer.doSelect(criteria);
if(results.size() != 1)
{
throw new DataBackendException(
- "Internal error - query returned " +
+ "Internal error - query returned " +
results.size() + " rows");
}
Group newGroup = (Group)results.get(0);
@@ -771,7 +771,7 @@
}
// the only way we could get here without return/throw tirggered
// is that the groupExists was true.
- throw new EntityExistsException("Group '" + group +
+ throw new EntityExistsException("Group '" + group +
"' already exists");
}
@@ -783,7 +783,7 @@
* @throws DataBackendException if there was an error accessing the data backend.
* @throws EntityExistsException if the role already exists.
*/
- public synchronized Role addRole( Role role )
+ public synchronized Role addRole( Role role )
throws DataBackendException, EntityExistsException
{
boolean roleExists = false;
@@ -799,11 +799,11 @@
// try to get the object back using the name as key.
criteria = new Criteria();
criteria.add(RolePeer.NAME, role.getName());
- Vector results = RolePeer.doSelect(criteria);
+ List results = RolePeer.doSelect(criteria);
if(results.size() != 1)
{
throw new DataBackendException(
- "Internal error - query returned " +
+ "Internal error - query returned " +
results.size() + " rows");
}
Role newRole = (Role)results.get(0);
@@ -834,7 +834,7 @@
* @throws DataBackendException if there was an error accessing the data backend.
* @throws EntityExistsException if the permission already exists.
*/
- public synchronized Permission addPermission( Permission permission )
+ public synchronized Permission addPermission( Permission permission )
throws DataBackendException, EntityExistsException
{
boolean permissionExists = false;
@@ -849,13 +849,13 @@
PermissionPeer.doInsert(criteria);
// try to get the object back using the name as key.
criteria = new Criteria();
- criteria.add(PermissionPeer.NAME,
+ criteria.add(PermissionPeer.NAME,
((SecurityObject)permission).getName());
- Vector results = PermissionPeer.doSelect(criteria);
+ List results = PermissionPeer.doSelect(criteria);
if(results.size() != 1)
{
throw new DataBackendException(
- "Internal error - query returned " +
+ "Internal error - query returned " +
results.size() + " rows");
}
Permission newPermission = (Permission)results.get(0);
@@ -875,7 +875,7 @@
}
// the only way we could get here without return/throw tirggered
// is that the permissionExists was true.
- throw new EntityExistsException("Permission '" + permission +
+ throw new EntityExistsException("Permission '" + permission +
"' already exists");
}
@@ -982,7 +982,7 @@
{
unlockExclusive();
}
- throw new UnknownEntityException("Unknown permission '" +
+ throw new UnknownEntityException("Unknown permission '" +
permission + "'");
}
@@ -1020,7 +1020,7 @@
}
throw new UnknownEntityException("Unknown group '" + group + "'");
}
-
+
/**
* Renames an existing Role.
*
@@ -1088,7 +1088,7 @@
{
unlockExclusive();
}
- throw new UnknownEntityException("Unknown permission '" +
+ throw new UnknownEntityException("Unknown permission '" +
permission + "'");
}
@@ -1147,7 +1147,7 @@
*
* @param group a <code>Group</code> value
* @return true if the group exists in the system, false otherwise
- * @throws DataBackendException when more than one Group with
+ * @throws DataBackendException when more than one Group with
* the same name exists.
* @throws Exception, a generic exception.
*/
@@ -1162,7 +1162,7 @@
*
* @param role a <code>Role</code> value
* @return true if the role exists in the system, false otherwise
- * @throws DataBackendException when more than one Role with
+ * @throws DataBackendException when more than one Role with
* the same name exists.
* @throws Exception, a generic exception.
*/
@@ -1177,7 +1177,7 @@
*
* @param permission a <code>Permission</code> value
* @return true if the permission exists in the system, false otherwise
- * @throws DataBackendException when more than one Permission with
+ * @throws DataBackendException when more than one Permission with
* the same name exists.
* @throws Exception, a generic exception.
*/
1.2 +44 -44 jakarta-turbine-2/src/java/org/apache/turbine/services/security/db/DBUserManager.java
Index: DBUserManager.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/services/security/db/DBUserManager.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DBUserManager.java 16 Aug 2001 05:09:19 -0000 1.1
+++ DBUserManager.java 11 Jul 2002 07:16:43 -0000 1.2
@@ -25,13 +25,13 @@
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
- * 4. The names "Apache" and "Apache Software Foundation" and
- * "Apache Turbine" must not be used to endorse or promote products
- * derived from this software without prior written permission. For
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache Turbine" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
- * "Apache Turbine", nor may "Apache" appear in their name, without
+ * "Apache Turbine", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
@@ -54,11 +54,11 @@
* <http://www.apache.org/>.
*/
-import java.util.Vector;
+import java.util.*;
import java.util.Iterator;
import org.apache.turbine.om.BaseObject;
-import org.apache.turbine.om.ObjectKey;
+import org.apache.torque.om.ObjectKey;
import org.apache.turbine.om.security.User;
import org.apache.turbine.om.security.peer.TurbineUserPeer;
@@ -68,18 +68,18 @@
import org.apache.turbine.util.security.PasswordMismatchException;
import org.apache.turbine.util.Log;
-import org.apache.turbine.util.db.Criteria;
+import org.apache.torque.util.Criteria;
import org.apache.turbine.services.security.UserManager;
import org.apache.turbine.services.security.TurbineSecurity;
/**
- * An UserManager performs {@link org.apache.turbine.om.security.User} objects
- * related tasks on behalf of the
+ * An UserManager performs {@link org.apache.turbine.om.security.User} objects
+ * related tasks on behalf of the
* {@link org.apache.turbine.services.security.BaseSecurityService}.
*
- * This implementation uses a relational database for storing user data. It
- * expects that the User interface implementation will be castable to
+ * This implementation uses a relational database for storing user data. It
+ * expects that the User interface implementation will be castable to
* {@link org.apache.turbine.om.BaseObject}.
*
* @author <a href="mailto:jon@collab.net">Jon S. Stevens</a>
@@ -98,7 +98,7 @@
*
* @param user The user to be checked.
* @return true if the specified account exists
- * @throws DataBackendException if there was an error accessing
+ * @throws DataBackendException if there was an error accessing
* the data backend.
*/
public boolean accountExists( User user )
@@ -114,7 +114,7 @@
*
* @param usename The name of the user to be checked.
* @return true if the specified account exists
- * @throws DataBackendException if there was an error accessing
+ * @throws DataBackendException if there was an error accessing
* the data backend.
*/
public boolean accountExists( String username )
@@ -122,7 +122,7 @@
{
Criteria criteria = new Criteria();
criteria.add(TurbineUserPeer.USERNAME, username);
- Vector users;
+ List users;
try
{
users = TurbineUserPeer.doSelect(criteria);
@@ -142,7 +142,7 @@
/**
* Retrieve a user from persistent storage using username as the
- * key.
+ * key.
*
* @param username the name of the user.
* @return an User object.
@@ -156,14 +156,14 @@
{
Criteria criteria = new Criteria();
criteria.add( TurbineUserPeer.USERNAME, username );
- Vector users;
+ List users;
try
{
users = TurbineUserPeer.doSelect(criteria);
}
catch(Exception e)
{
- throw new DataBackendException("Failed to retrieve user '" +
+ throw new DataBackendException("Failed to retrieve user '" +
username + "'", e);
}
if ( users.size() > 1 )
@@ -205,13 +205,13 @@
for (int i=0;i<criterion.length;i++)
{
String table = criterion[i].getTable();
- if ( table == null || "".equals(table) )
+ if ( table == null || "".equals(table) )
{
criterion[i].setTable(TurbineUserPeer.getTableName());
}
}
}
- Vector users = new Vector(0);
+ List users = new ArrayList(0);
try
{
users = TurbineUserPeer.doSelect(criteria);
@@ -232,7 +232,7 @@
* @param username the name of the user.
* @param password the user supplied password.
* @return an User object.
- * @exception PasswordMismatchException if the supplied password was
+ * @exception PasswordMismatchException if the supplied password was
* incorrect.
* @exception UnknownEntityException if the user's account does not
* exist in the database.
@@ -240,7 +240,7 @@
* storage.
*/
public User retrieve( String username, String password )
- throws PasswordMismatchException, UnknownEntityException,
+ throws PasswordMismatchException, UnknownEntityException,
DataBackendException
{
User user = retrieve(username);
@@ -263,7 +263,7 @@
{
if(!accountExists(user))
{
- throw new UnknownEntityException("The account '" +
+ throw new UnknownEntityException("The account '" +
user.getUserName() + "' does not exist");
}
Criteria criteria = TurbineUserPeer.buildCriteria(user);
@@ -284,7 +284,7 @@
*
* @param user an User object to authenticate.
* @param password the user supplied password.
- * @exception PasswordMismatchException if the supplied password was
+ * @exception PasswordMismatchException if the supplied password was
* incorrect.
* @exception UnknownEntityException if the user's account does not
* exist in the database.
@@ -292,12 +292,12 @@
* storage.
*/
public void authenticate( User user, String password )
- throws PasswordMismatchException, UnknownEntityException,
+ throws PasswordMismatchException, UnknownEntityException,
DataBackendException
{
if(!accountExists(user))
{
- throw new UnknownEntityException("The account '" +
+ throw new UnknownEntityException("The account '" +
user.getUserName() + "' does not exist");
}
String encrypted = TurbineSecurity.encryptPassword(password);
@@ -312,22 +312,22 @@
*
* @param user an User to change password for.
* @param password the new password.
- * @exception PasswordMismatchException if the supplied password was
+ * @exception PasswordMismatchException if the supplied password was
* incorrect.
* @exception UnknownEntityException if the user's account does not
* exist in the database.
* @exception DataBackendException if there is a problem accessing the
* storage.
*/
- public void changePassword( User user, String oldPassword,
+ public void changePassword( User user, String oldPassword,
String newPassword )
- throws PasswordMismatchException, UnknownEntityException,
+ throws PasswordMismatchException, UnknownEntityException,
DataBackendException
{
String encrypted = TurbineSecurity.encryptPassword(oldPassword);
if(!accountExists(user))
{
- throw new UnknownEntityException("The account '" +
+ throw new UnknownEntityException("The account '" +
user.getUserName() + "' does not exist");
}
if(!user.getPassword().equals(encrypted))
@@ -339,7 +339,7 @@
user.setPassword(TurbineSecurity.encryptPassword(newPassword));
// save the changes in the database imediately, to prevent the password
// being 'reverted' to the old value if the user data is lost somehow
- // before it is saved at session's expiry.
+ // before it is saved at session's expiry.
store(user);
}
@@ -347,10 +347,10 @@
* Forcibly sets new password for an User.
*
* This is supposed by the administrator to change the forgotten or
- * compromised passwords. Certain implementatations of this feature
- * would require administrative level access to the authenticating
+ * compromised passwords. Certain implementatations of this feature
+ * would require administrative level access to the authenticating
* server / program.
- *
+ *
* @param user an User to change password for.
* @param password the new password.
* @exception UnknownEntityException if the user's record does not
@@ -363,13 +363,13 @@
{
if(!accountExists(user))
{
- throw new UnknownEntityException("The account '" +
+ throw new UnknownEntityException("The account '" +
user.getUserName() + "' does not exist");
}
user.setPassword(TurbineSecurity.encryptPassword(password));
- // save the changes in the database immediately, to prevent the
- // password being 'reverted' to the old value if the user data
- // is lost somehow before it is saved at session's expiry.
+ // save the changes in the database immediately, to prevent the
+ // password being 'reverted' to the old value if the user data
+ // is lost somehow before it is saved at session's expiry.
store(user);
}
@@ -377,7 +377,7 @@
* Creates new user account with specified attributes.
*
* @param user the object describing account to be created.
- * @throws DataBackendException if there was an error accessing
+ * @throws DataBackendException if there was an error accessing
the data backend.
* @throws EntityExistsException if the user account already exists.
*/
@@ -386,7 +386,7 @@
{
if(accountExists(user))
{
- throw new EntityExistsException("The account '" +
+ throw new EntityExistsException("The account '" +
user.getUserName() + "' already exists");
}
String encrypted = TurbineSecurity.encryptPassword(initialPassword);
@@ -394,7 +394,7 @@
Criteria criteria = TurbineUserPeer.buildCriteria(user);
try
{
- // we can safely assume that BaseObject derivate is used as User
+ // we can safely assume that BaseObject derivate is used as User
// implementation with this UserManager
((BaseObject)user).setPrimaryKey(
TurbineUserPeer.doInsert(criteria));
@@ -410,7 +410,7 @@
* Removes an user account from the system.
*
* @param user the object describing the account to be removed.
- * @throws DataBackendException if there was an error accessing
+ * @throws DataBackendException if there was an error accessing
the data backend.
* @throws UnknownEntityException if the user account is not present.
*/
@@ -419,7 +419,7 @@
{
if(!accountExists(user))
{
- throw new UnknownEntityException("The account '" +
+ throw new UnknownEntityException("The account '" +
user.getUserName() + "' does not exist");
}
Criteria criteria = new Criteria();
@@ -430,7 +430,7 @@
}
catch(Exception e)
{
- throw new DataBackendException("Failed to remove account '" +
+ throw new DataBackendException("Failed to remove account '" +
user.getUserName() + "'", e);
}
}
1.4 +2 -2 jakarta-turbine-2/src/java/org/apache/turbine/services/security/ldap/LDAPSecurityService.java
Index: LDAPSecurityService.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/services/security/ldap/LDAPSecurityService.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- LDAPSecurityService.java 14 Dec 2001 17:18:53 -0000 1.3
+++ LDAPSecurityService.java 11 Jul 2002 07:16:43 -0000 1.4
@@ -72,7 +72,7 @@
import org.apache.turbine.om.security.peer.TurbineUserPeer;
import org.apache.turbine.util.Log;
-import org.apache.turbine.util.db.Criteria;
+import org.apache.torque.util.Criteria;
import org.apache.turbine.util.security.AccessControlList;
import org.apache.turbine.util.security.GroupSet;
1.2 +21 -21 jakarta-turbine-2/src/java/org/apache/turbine/services/security/ldap/LDAPUserManager.java
Index: LDAPUserManager.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/services/security/ldap/LDAPUserManager.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- LDAPUserManager.java 16 Aug 2001 05:09:21 -0000 1.1
+++ LDAPUserManager.java 11 Jul 2002 07:16:43 -0000 1.2
@@ -71,7 +71,7 @@
import org.apache.turbine.om.security.User;
import org.apache.turbine.util.Log;
-import org.apache.turbine.util.db.Criteria;
+import org.apache.torque.util.Criteria;
import org.apache.turbine.util.security.DataBackendException;
import org.apache.turbine.util.security.UnknownEntityException;
import org.apache.turbine.util.security.EntityExistsException;
@@ -135,7 +135,7 @@
* employed in the DBUserManager can be employed
* here.
*/
-
+
try
{
User ldapUser = retrieve(username);
@@ -145,7 +145,7 @@
throw new DataBackendException(
"Failed to check account's presence", e);
}
-
+
return true;
}
@@ -175,7 +175,7 @@
User ldapUser = null;
/*
- * The userBaseSearch string contains some
+ * The userBaseSearch string contains some
* characters that need to be transformed.
*/
userBaseSearch = userBaseSearch.replace('/', '=');
@@ -214,11 +214,11 @@
}
StringTokenizer sT = new StringTokenizer(dN, ":");
-
+
while (sT.hasMoreElements())
{
dN = sT.nextToken();
- }
+ }
dN = dN.trim();
@@ -273,7 +273,7 @@
* exist in the database.
* @exception DataBackendException Error accessing the data backend.
*/
- public User retrieve(String username, String password)
+ public User retrieve(String username, String password)
throws PasswordMismatchException,
UnknownEntityException,DataBackendException
{
@@ -294,7 +294,7 @@
* exist in the database.
*
*/
- public void store(User user)
+ public void store(User user)
throws UnknownEntityException,DataBackendException
{
if (!accountExists(user))
@@ -317,7 +317,7 @@
* exist in the database.
* @exception DataBackendException Error accessing the data backend.
*/
- public void authenticate(User user, String password)
+ public void authenticate(User user, String password)
throws PasswordMismatchException,
UnknownEntityException, DataBackendException
{
@@ -328,7 +328,7 @@
catch (NamingException authEx)
{
throw new PasswordMismatchException(
- "The given password for: " +
+ "The given password for: " +
user.getUserName() + " is invalid\n");
}
}
@@ -345,7 +345,7 @@
* exist in the database.
* @exception DataBackendException Error accessing the data backend.
*/
- public void changePassword(User user, String oldPassword, String newPassword)
+ public void changePassword(User user, String oldPassword, String newPassword)
throws PasswordMismatchException,
UnknownEntityException, DataBackendException
{
@@ -368,7 +368,7 @@
* exist in the database.
* @exception DataBackendException Error accessing the data backend.
*/
- public void forcePassword(User user, String password)
+ public void forcePassword(User user, String password)
throws UnknownEntityException,DataBackendException
{
throw new DataBackendException(
@@ -383,7 +383,7 @@
* @throws DataBackendException Error accessing the data backend.
* @throws EntityExistsException if the user account already exists.
*/
- public void createAccount(User user, String initialPassword)
+ public void createAccount(User user, String initialPassword)
throws EntityExistsException,DataBackendException
{
throw new DataBackendException(
@@ -398,7 +398,7 @@
* @throws DataBackendException Error accessing the data backend.
* @throws UnknownEntityException if the user account is not present.
*/
- public void removeAccount(User user)
+ public void removeAccount(User user)
throws UnknownEntityException,DataBackendException
{
throw new DataBackendException(
@@ -415,7 +415,7 @@
* @throws UnknownEntityException if the user account is not present.
* @throws NamingException when an error occurs with the named server.
*/
- public DirContext bind(String username, String password)
+ public DirContext bind(String username, String password)
throws NamingException, DataBackendException, UnknownEntityException
{
DirContext ctx = null;
@@ -428,7 +428,7 @@
String providerURL = new String("ldap://" + host + ":" + port);
/*
- * creating an initial context using Sun's client
+ * creating an initial context using Sun's client
* LDAP Provider.
*/
Hashtable env = new Hashtable();
@@ -445,17 +445,17 @@
catch (NamingException ne)
{
String errno = ParseExceptionMessage.findErrno(ne.getExplanation());
-
+
if (errno.equals("49"))
{
throw new UnknownEntityException(
"The given credentials for the administrator are invalid");
- }
+ }
else if (errno.equals("22"))
{
throw new DataBackendException(
"The LDAP server specified is unavailable");
- }
+ }
else
{
throw ne;
@@ -465,7 +465,7 @@
{
Log.error(e);
}
-
+
return ctx;
}
}
1.2 +19 -19 jakarta-turbine-2/src/java/org/apache/turbine/services/security/passive/PassiveUserManager.java
Index: PassiveUserManager.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/services/security/passive/PassiveUserManager.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- PassiveUserManager.java 16 Aug 2001 05:09:21 -0000 1.1
+++ PassiveUserManager.java 11 Jul 2002 07:16:43 -0000 1.2
@@ -25,13 +25,13 @@
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
- * 4. The names "Apache" and "Apache Software Foundation" and
- * "Apache Turbine" must not be used to endorse or promote products
- * derived from this software without prior written permission. For
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache Turbine" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
- * "Apache Turbine", nor may "Apache" appear in their name, without
+ * "Apache Turbine", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
@@ -56,7 +56,7 @@
import org.apache.turbine.om.security.User;
-import org.apache.turbine.util.db.Criteria;
+import org.apache.torque.util.Criteria;
import org.apache.turbine.util.security.DataBackendException;
import org.apache.turbine.util.security.UnknownEntityException;
import org.apache.turbine.util.security.EntityExistsException;
@@ -66,7 +66,7 @@
/**
* Void user manager can be used where no data storage is needed
- * by the application.
+ * by the application.
* It's methods don't provide any useful functionality except throwing
* DataBackendExceptions. Security service will be still able to create
* anonymous User objects when this UserManager is used.
@@ -87,7 +87,7 @@
*/
public boolean accountExists( User user )
throws DataBackendException
- {
+ {
throw new DataBackendException("PassiveUserManager knows no users");
}
@@ -108,7 +108,7 @@
/**
* Retrieve a user from persistent storage using username as the
- * key.
+ * key.
*
* @param username the name of the user.
* @return an User object.
@@ -152,7 +152,7 @@
* @param username the name of the user.
* @param password the user supplied password.
* @return an User object.
- * @exception PasswordMismatchException if the supplied password was
+ * @exception PasswordMismatchException if the supplied password was
* incorrect.
* @exception UnknownEntityException if the user's record does not
* exist in the database.
@@ -160,11 +160,11 @@
* storage.
*/
public User retrieve( String username, String password )
- throws PasswordMismatchException, UnknownEntityException,
+ throws PasswordMismatchException, UnknownEntityException,
DataBackendException
{
throw new DataBackendException("PassiveUserManager knows no users");
- }
+ }
/**
* Save an User object to persistent storage. User's record is
@@ -189,7 +189,7 @@
*
* @param user an User object to authenticate.
* @param password the user supplied password.
- * @exception PasswordMismatchException if the supplied password was
+ * @exception PasswordMismatchException if the supplied password was
* incorrect.
* @exception UnknownEntityException if the user's record does not
* exist in the database.
@@ -197,7 +197,7 @@
* storage.
*/
public void authenticate( User user, String password )
- throws PasswordMismatchException, UnknownEntityException,
+ throws PasswordMismatchException, UnknownEntityException,
DataBackendException
{
throw new DataBackendException("PassiveUserManager knows no users");
@@ -235,7 +235,7 @@
* @param user an User to change password for.
* @param oldPassword the current password supplied by the user.
* @param newPassword the current password requested by the user.
- * @exception PasswordMismatchException if the supplied password was
+ * @exception PasswordMismatchException if the supplied password was
* incorrect.
* @exception UnknownEntityException if the user's record does not
* exist in the database.
@@ -243,7 +243,7 @@
* storage.
*/
public void changePassword( User user, String oldPassword, String newPassword )
- throws PasswordMismatchException, UnknownEntityException,
+ throws PasswordMismatchException, UnknownEntityException,
DataBackendException
{
throw new DataBackendException("PassiveUserManager does not support setting passwords");
@@ -253,10 +253,10 @@
* Forcibly sets new password for an User.
*
* This is supposed by the administrator to change the forgotten or
- * compromised passwords. Certain implementatations of this feature
- * would require administrative level access to the authenticating
+ * compromised passwords. Certain implementatations of this feature
+ * would require administrative level access to the authenticating
* server / program.
- *
+ *
* @param user an User to change password for.
* @param password the new password.
* @exception UnknownEntityException if the user's record does not
1.2 +7 -7 jakarta-turbine-2/src/java/org/apache/turbine/util/ValueParser.java
Index: ValueParser.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/util/ValueParser.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ValueParser.java 16 Aug 2001 05:09:44 -0000 1.1
+++ ValueParser.java 11 Jul 2002 07:16:43 -0000 1.2
@@ -25,13 +25,13 @@
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
- * 4. The names "Apache" and "Apache Software Foundation" and
- * "Apache Turbine" must not be used to endorse or promote products
- * derived from this software without prior written permission. For
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache Turbine" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
- * "Apache Turbine", nor may "Apache" appear in their name, without
+ * "Apache Turbine", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
@@ -63,8 +63,8 @@
import java.util.Date;
import java.util.Enumeration;
-import org.apache.turbine.om.NumberKey;
-import org.apache.turbine.om.StringKey;
+import org.apache.torque.om.NumberKey;
+import org.apache.torque.om.StringKey;
/**
* ValueParser is a base interface for classes that need to parse
1.3 +19 -18 jakarta-turbine-2/src/java/org/apache/turbine/util/db/map/TurbineMapBuilder.java
Index: TurbineMapBuilder.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/util/db/map/TurbineMapBuilder.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- TurbineMapBuilder.java 20 Aug 2001 02:49:32 -0000 1.2
+++ TurbineMapBuilder.java 11 Jul 2002 07:16:43 -0000 1.3
@@ -25,13 +25,13 @@
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
- * 4. The names "Apache" and "Apache Software Foundation" and
- * "Apache Turbine" must not be used to endorse or promote products
- * derived from this software without prior written permission. For
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache Turbine" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
- * "Apache Turbine", nor may "Apache" appear in their name, without
+ * "Apache Turbine", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
@@ -58,6 +58,7 @@
import java.util.Hashtable;
import org.apache.turbine.services.db.TurbineDB;
+import org.apache.torque.map.*;
/**
* Default Builder for Database/Table/Column Maps within the Turbine
@@ -254,7 +255,7 @@
}
/**
- * Column used to store the user's first name.
+ * Column used to store the user's first name.
* Override this if using your custom table.
*
* @return A String.
@@ -274,9 +275,9 @@
{
return getTableUser() + '.' + getFirstName();
}
-
+
/**
- * Column used to store the user's last name.
+ * Column used to store the user's last name.
* Override this if using your custom table.
*
* @return A String.
@@ -298,7 +299,7 @@
}
/**
- * Column used to store the user's data modification time.
+ * Column used to store the user's data modification time.
* Override this if using your custom table.
*
* @return A String.
@@ -307,7 +308,7 @@
{
return "MODIFIED";
}
-
+
/**
* Fully qualified column used to store the user's data modification time.
* Shouldn't need to override this as it uses the above methods.
@@ -320,7 +321,7 @@
}
/**
- * Column used to store the user's record cration time.
+ * Column used to store the user's record cration time.
* Override this if using your custom table.
*
* @return A String.
@@ -342,7 +343,7 @@
}
/**
- * Column used to store the user's email.
+ * Column used to store the user's email.
* Override this if using your custom table.
*
* @return A String.
@@ -364,7 +365,7 @@
}
/**
- * Column used to store the user's confirmation flag.
+ * Column used to store the user's confirmation flag.
* Override this if using your custom table.
*
* @return A String.
@@ -770,7 +771,7 @@
{
return getTableJobentry() + '.' + getEmail();
}
-
+
/**
* Column used to store the job schedule property.
* Override this if using your custom table.
@@ -781,7 +782,7 @@
{
return "PROPERTY";
}
-
+
/**
* Fully qualified column name for property column. Shouldn't
* need to override this as it uses the above methods.
@@ -869,7 +870,7 @@
{
// Reusable TableMap
TableMap tMap;
-
+
// Make some objects.
String string = new String("");
Integer integer = new Integer(0);
@@ -902,7 +903,7 @@
tMap.addColumn(getModified(), date);
tMap.addColumn(getLastLogin(), date);
tMap.addColumn(getObjectData(), new Hashtable(1) );
-
+
// Add Group columns.
tMap = dbMap.getTable(getTableGroup());
tMap.setPrimaryKeyMethod(TableMap.ID_BROKER);
@@ -958,7 +959,7 @@
tMap.setPrimaryKeyMethod(TableMap.ID_BROKER);
tMap.setPrimaryKeyMethodInfo(tMap.getName());
tMap.addPrimaryKey(getJobId(), integer);
- tMap.addColumn(getSecond(), integer);
+ tMap.addColumn(getSecond(), integer);
tMap.addColumn(getMinute(), integer);
tMap.addColumn(getHour(), integer);
tMap.addColumn(getWeekday(), integer);
1.5 +3 -3 jakarta-turbine-2/src/java/org/apache/turbine/util/parser/BaseValueParser.java
Index: BaseValueParser.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/util/parser/BaseValueParser.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- BaseValueParser.java 25 Apr 2002 05:18:13 -0000 1.4
+++ BaseValueParser.java 11 Jul 2002 07:16:43 -0000 1.5
@@ -73,8 +73,8 @@
import java.util.GregorianCalendar;
import java.util.Hashtable;
-import org.apache.turbine.om.NumberKey;
-import org.apache.turbine.om.StringKey;
+import org.apache.torque.om.NumberKey;
+import org.apache.torque.om.StringKey;
import org.apache.turbine.services.resources.TurbineResources;
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>