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/12/31 16:18:36 UTC
cvs commit: jakarta-turbine-2/src/java/org/apache/turbine/om/security/peer GroupPeer.java PermissionPeer.java RolePeer.java RolePermissionPeer.java TurbineUserPeer.java UserGroupRolePeer.java UserPeer.java
mpoeschl 2002/12/31 07:18:36
Modified: src/java/org/apache/turbine/om/security/peer GroupPeer.java
PermissionPeer.java RolePeer.java
RolePermissionPeer.java TurbineUserPeer.java
UserGroupRolePeer.java UserPeer.java
Log:
checkstyle fixes
Revision Changes Path
1.5 +40 -34 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.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- GroupPeer.java 12 Dec 2002 15:52:32 -0000 1.4
+++ GroupPeer.java 31 Dec 2002 15:18:35 -0000 1.5
@@ -105,18 +105,20 @@
/**
* Retrieves/assembles a GroupSet of all of the Groups.
*
- * @param criteria The criteria to use.
* @return A GroupSet.
- * @exception Exception, a generic exception.
+ * @exception Exception a generic exception.
*/
- public static GroupSet retrieveSet()
- throws Exception
+ public static GroupSet retrieveSet() throws Exception
{
return retrieveSet(new Criteria());
}
/**
* Retrieves/assembles a GroupSet based on the Criteria passed in
+ *
+ * @param criteria The criteria to use.
+ * @throws Exception a generic exception.
+ * @return a GroupSet
*/
public static GroupSet retrieveSet(Criteria criteria) throws Exception
{
@@ -132,13 +134,12 @@
/**
* Issues a select based on a criteria.
*
- * @param Criteria object containing data that is used to create
- * the SELECT statement.
+ * @param criteria object containing data that is used to create
+ * the SELECT statement.
* @return Vector containing Group objects.
- * @exception Exception, a generic exception.
+ * @exception TorqueException a generic exception.
*/
- public static List doSelect(Criteria criteria)
- throws TorqueException
+ public static List doSelect(Criteria criteria) throws TorqueException
{
try
{
@@ -146,8 +147,8 @@
.addSelectColumn(NAME)
.addSelectColumn(OBJECTDATA);
- if (criteria.getOrderByColumns() == null ||
- criteria.getOrderByColumns().size() == 0)
+ if (criteria.getOrderByColumns() == null
+ || criteria.getOrderByColumns().size() == 0)
{
criteria.addAscendingOrderByColumn(NAME);
}
@@ -168,11 +169,12 @@
List results = new ArrayList();
// Populate the object(s).
- for ( int i = 0; i < rows.size(); i++ )
+ for (int i = 0; i < rows.size(); i++)
{
Group obj = TurbineSecurity.getNewGroup(null);
Record row = (Record) rows.get(i);
- ((SecurityObject) obj).setPrimaryKey(new NumberKey(row.getValue(1).asInt()));
+ ((SecurityObject) obj).setPrimaryKey(
+ new NumberKey(row.getValue(1).asInt()));
((SecurityObject) obj).setName(row.getValue(2).asString());
byte[] objectData = (byte[]) row.getValue(3).asBytes();
Map temp = (Map) ObjectUtils.deserialize(objectData);
@@ -194,41 +196,41 @@
/**
* Issues an update based on a criteria.
*
- * @param Criteria object containing data that is used to create
- * the UPDATE statement.
- * @exception Exception, a generic exception.
+ * @param criteria object containing data that is used to create
+ * the UPDATE statement.
+ * @exception TorqueException a generic exception.
*/
public static void doUpdate(Criteria criteria)
throws TorqueException
{
Criteria selectCriteria = new Criteria(2);
- selectCriteria.put( GROUP_ID, criteria.remove(GROUP_ID) );
- BasePeer.doUpdate( selectCriteria, criteria );
+ selectCriteria.put(GROUP_ID, criteria.remove(GROUP_ID));
+ BasePeer.doUpdate(selectCriteria, criteria);
}
/**
* Checks if a Group is defined in the system. The name
* is used as query criteria.
*
- * @param permission The Group to be checked.
+ * @param group The Group to be checked.
* @return <code>true</code> if given Group exists in the system.
* @throws DataBackendException when more than one Group with
* the same name exists.
- * @throws Exception, a generic exception.
+ * @throws Exception a generic exception.
*/
- public static boolean checkExists( Group group )
+ public static boolean checkExists(Group group)
throws DataBackendException, Exception
{
Criteria criteria = new Criteria();
criteria.addSelectColumn(GROUP_ID);
- criteria.add(NAME, ((SecurityObject)group).getName());
+ criteria.add(NAME, ((SecurityObject) group).getName());
List results = BasePeer.doSelect(criteria);
if (results.size() > 1)
{
- throw new DataBackendException("Multiple groups named '" +
- ((TurbineGroup)group).getName() + "' exist!");
+ throw new DataBackendException("Multiple groups named '"
+ + ((TurbineGroup) group).getName() + "' exist!");
}
- return (results.size()==1);
+ return (results.size() == 1);
}
/**
@@ -244,27 +246,31 @@
/**
* Returns the full name of a column.
*
+ * @param name name of the column
* @return A String with the full name of the column.
*/
- public static String getColumnName (String name)
+ public static String getColumnName(String name)
{
StringBuffer sb = new StringBuffer();
- sb.append (TABLE_NAME);
- sb.append (".");
- sb.append (name);
+ sb.append(TABLE_NAME);
+ sb.append(".");
+ sb.append(name);
return sb.toString();
}
/**
* Builds a criteria object based upon an Group object
+ *
+ * @param group object to build the Criteria
+ * @return the Criteria
*/
- public static Criteria buildCriteria( Group group )
+ public static Criteria buildCriteria(Group group)
{
Criteria criteria = new Criteria();
- criteria.add(NAME, ((SecurityObject)group).getName());
- if ( !((BaseObject)group).isNew() )
+ criteria.add(NAME, ((SecurityObject) group).getName());
+ if (!((BaseObject) group).isNew())
{
- criteria.add(GROUP_ID, ((BaseObject)group).getPrimaryKey());
+ criteria.add(GROUP_ID, ((BaseObject) group).getPrimaryKey());
}
// Causing the removal and updating of a group to
// crap out.
1.5 +54 -50 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.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- PermissionPeer.java 12 Dec 2002 15:52:32 -0000 1.4
+++ PermissionPeer.java 31 Dec 2002 15:18:35 -0000 1.5
@@ -87,26 +87,27 @@
*/
public class PermissionPeer extends BasePeer
{
- private static final TurbineMapBuilder mapBuilder =
- (TurbineMapBuilder) getMapBuilder("org.apache.turbine.util.db.map.TurbineMapBuilder");
+ /** The mapBuilder for this Peer. */
+ 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 =
- mapBuilder.getPermission_PermissionId();
+ 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 =
- mapBuilder.getPermission_ObjectData();
+ public static final String OBJECTDATA
+ = mapBuilder.getPermission_ObjectData();
/** The Oracle sequence name for this peer. */
- private static final String SEQUENCE_NAME =
- mapBuilder.getSequencePermission();
+ private static final String SEQUENCE_NAME
+ = mapBuilder.getSequencePermission();
/**
@@ -114,7 +115,7 @@
*
* @param criteria The criteria to use.
* @return A PermissionSet.
- * @exception Exception, a generic exception.
+ * @exception Exception a generic exception.
*/
public static PermissionSet retrieveSet(Criteria criteria)
throws Exception
@@ -133,16 +134,16 @@
*
* @param role The role to query permissions of.
* @return A set of permissions associated with the Role.
- * @exception Exception, a generic exception.
+ * @exception Exception a generic exception.
*/
- public static PermissionSet retrieveSet( Role role )
- throws Exception
+ public static PermissionSet retrieveSet(Role role)
+ throws Exception
{
Criteria criteria = new Criteria();
criteria.add(RolePermissionPeer.ROLE_ID,
- ((TurbineRole)role).getPrimaryKey());
+ ((TurbineRole) role).getPrimaryKey());
criteria.addJoin(RolePermissionPeer.PERMISSION_ID,
- PermissionPeer.PERMISSION_ID);
+ PermissionPeer.PERMISSION_ID);
return retrieveSet(criteria);
}
@@ -150,12 +151,12 @@
* Issues a select based on a criteria.
*
* @param criteria Object containing data that is used to create
- * the SELECT statement.
+ * the SELECT statement.
* @return Vector containing Permission objects.
- * @exception Exception, a generic exception.
+ * @exception TorqueException a generic exception.
*/
public static List doSelect(Criteria criteria)
- throws TorqueException
+ throws TorqueException
{
try
{
@@ -163,8 +164,8 @@
.addSelectColumn(NAME)
.addSelectColumn(OBJECTDATA);
- if (criteria.getOrderByColumns() == null ||
- criteria.getOrderByColumns().size() == 0)
+ if (criteria.getOrderByColumns() == null
+ || criteria.getOrderByColumns().size() == 0)
{
criteria.addAscendingOrderByColumn(NAME);
}
@@ -185,12 +186,13 @@
List results = new ArrayList();
// Populate the object(s).
- for ( int i=0; i<rows.size(); i++ )
+ for (int i = 0; i < rows.size(); i++)
{
Permission obj = TurbineSecurity.getNewPermission(null);
Record row = (Record) rows.get(i);
- ((SecurityObject) obj).setPrimaryKey(new NumberKey(row.getValue(1).asInt()));
- ((SecurityObject) obj).setName( row.getValue(2).asString() );
+ ((SecurityObject) obj).setPrimaryKey(
+ new NumberKey(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)
@@ -210,16 +212,19 @@
/**
* Builds a criteria object based upon an Permission object
+ *
+ * @param permission object to build the criteria
+ * @return the Criteria
*/
- public static Criteria buildCriteria( Permission permission )
+ public static Criteria buildCriteria(Permission permission)
{
Criteria criteria = new Criteria();
- if ( !((BaseObject)permission).isNew() )
+ if (!((BaseObject) permission).isNew())
{
criteria.add(PERMISSION_ID,
- ((BaseObject)permission).getPrimaryKey());
+ ((BaseObject) permission).getPrimaryKey());
}
- criteria.add(NAME, ((SecurityObject)permission).getName());
+ criteria.add(NAME, ((SecurityObject) permission).getName());
/*
* This is causing the the removal and updating of
@@ -242,16 +247,15 @@
* Issues an update based on a criteria.
*
* @param criteria Object containing data that is used to create
- * the UPDATE statement.
- * @exception Exception, a generic exception.
+ * the UPDATE statement.
+ * @exception TorqueException a generic exception.
*/
public static void doUpdate(Criteria criteria)
throws TorqueException
{
Criteria selectCriteria = new Criteria(2);
- selectCriteria.put( PERMISSION_ID,
- criteria.remove(PERMISSION_ID) );
- BasePeer.doUpdate( selectCriteria, criteria );
+ selectCriteria.put(PERMISSION_ID, criteria.remove(PERMISSION_ID));
+ BasePeer.doUpdate(selectCriteria, criteria);
}
/**
@@ -262,21 +266,21 @@
* @return <code>true</code> if given Permission exists in the system.
* @throws DataBackendException when more than one Permission with
* the same name exists.
- * @throws Exception, a generic exception.
+ * @throws Exception a generic exception.
*/
- public static boolean checkExists( Permission permission )
+ public static boolean checkExists(Permission permission)
throws DataBackendException, Exception
{
Criteria criteria = new Criteria();
criteria.addSelectColumn(PERMISSION_ID);
- criteria.add(NAME, ((SecurityObject)permission).getName());
+ criteria.add(NAME, ((SecurityObject) permission).getName());
List results = BasePeer.doSelect(criteria);
- if(results.size() > 1)
+ if (results.size() > 1)
{
- throw new DataBackendException("Multiple permissions named '" +
- ((SecurityObject)permission).getName() + "' exist!");
+ throw new DataBackendException("Multiple permissions named '"
+ + ((SecurityObject) permission).getName() + "' exist!");
}
- return (results.size()==1);
+ return (results.size() == 1);
}
/**
@@ -292,14 +296,15 @@
/**
* Returns the full name of a column.
*
+ * @param name name of a column
* @return A String with the full name of the column.
*/
- public static String getColumnName (String name)
+ public static String getColumnName(String name)
{
StringBuffer sb = new StringBuffer();
- sb.append (TABLE_NAME);
- sb.append (".");
- sb.append (name);
+ sb.append(TABLE_NAME);
+ sb.append(".");
+ sb.append(name);
return sb.toString();
}
@@ -311,18 +316,17 @@
* @param all Vector A in C = (A - B).
* @return Vector C in C = (A - B).
*/
- public static final Vector getDifference(Vector some,
- Vector all)
+ public static final Vector getDifference(Vector some, Vector all)
{
- Vector clone = (Vector)all.clone();
- for (Enumeration e = some.elements() ; e.hasMoreElements() ;)
+ Vector clone = (Vector) all.clone();
+ for (Enumeration e = some.elements(); e.hasMoreElements();)
{
Permission tmp = (Permission) e.nextElement();
- for (Enumeration f = clone.elements() ; f.hasMoreElements() ;)
+ for (Enumeration f = clone.elements(); f.hasMoreElements();)
{
Permission tmp2 = (Permission) f.nextElement();
- if (((BaseObject)tmp).getPrimaryKey() ==
- ((BaseObject)tmp2).getPrimaryKey())
+ if (((BaseObject) tmp).getPrimaryKey()
+ == ((BaseObject) tmp2).getPrimaryKey())
{
clone.removeElement(tmp2);
break;
1.6 +45 -62 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.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- RolePeer.java 31 Dec 2002 12:51:11 -0000 1.5
+++ RolePeer.java 31 Dec 2002 15:18:35 -0000 1.6
@@ -54,7 +54,6 @@
* <http://www.apache.org/>.
*/
-import com.workingdogs.village.Record;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -68,12 +67,11 @@
import org.apache.turbine.om.security.Role;
import org.apache.turbine.om.security.TurbineRole;
import org.apache.turbine.om.security.User;
-import org.apache.turbine.services.security.TurbineSecurity;
-import org.apache.turbine.services.security.db.DBSecurityService;
import org.apache.turbine.util.ObjectUtils;
import org.apache.turbine.util.db.map.TurbineMapBuilder;
import org.apache.turbine.util.security.DataBackendException;
import org.apache.turbine.util.security.RoleSet;
+import com.workingdogs.village.Record;
/**
@@ -87,8 +85,9 @@
*/
public class RolePeer extends BasePeer
{
- private static final TurbineMapBuilder mapBuilder =
- (TurbineMapBuilder) getMapBuilder("org.apache.turbine.util.db.map.TurbineMapBuilder");
+ /** The mapBuilder for this Peer. */
+ 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();
@@ -106,8 +105,12 @@
private static final String SEQUENCE_NAME = mapBuilder.getSequenceRole();
/**
- * Retrieves/assembles a RoleSet based on the Criteria passed in
- */
+ * Retrieves/assembles a RoleSet based on the Criteria passed in
+ *
+ * @param criteria The criteria to use.
+ * @return a RoleSet
+ * @exception Exception a generic exception.
+ */
public static RoleSet retrieveSet(Criteria criteria) throws Exception
{
List results = RolePeer.doSelect(criteria);
@@ -125,53 +128,28 @@
* @param user An user.
* @param group A group
* @return A Set of Roles of this User in the Group
- * @exception Exception, a generic exception.
+ * @exception Exception a generic exception.
*/
- public static RoleSet retrieveSet( User user, Group group )
- throws Exception
+ public static RoleSet retrieveSet(User user, Group group) throws Exception
{
Criteria criteria = new Criteria();
-
- /*
- * Peer specific methods should absolutely NOT be part
- * of any of the generic interfaces in the security system.
- * this is not good.
- *
- * UserPeer up = TurbineSecurity.getUserPeerInstance();
- */
-
-/*
- UserPeer up = ((DBSecurityService)TurbineSecurity.getService())
- .getUserPeerInstance();
-
- criteria.add(up.getFullColumnName(UserPeer.USERNAME),
- user.getUserName());
- criteria.add(UserGroupRolePeer.GROUP_ID,
- ((Persistent)group).getPrimaryKey());
-
- criteria.addJoin(up.getFullColumnName(UserPeer.USER_ID),
- UserGroupRolePeer.USER_ID);
- criteria.addJoin(UserGroupRolePeer.ROLE_ID, RolePeer.ROLE_ID);
-*/
criteria.add(UserGroupRolePeer.USER_ID,
- ((Persistent)user).getPrimaryKey());
+ ((Persistent) user).getPrimaryKey());
criteria.add(UserGroupRolePeer.GROUP_ID,
- ((Persistent)group).getPrimaryKey());
+ ((Persistent) group).getPrimaryKey());
criteria.addJoin(UserGroupRolePeer.ROLE_ID, RolePeer.ROLE_ID);
-
return retrieveSet(criteria);
}
/**
* Issues a select based on a criteria.
*
- * @param Criteria object containing data that is used to create
- * the SELECT statement.
+ * @param criteria object containing data that is used to create
+ * the SELECT statement.
* @return Vector containing Role objects.
- * @exception Exception, a generic exception.
+ * @exception TorqueException a generic exception.
*/
- public static List doSelect(Criteria criteria)
- throws TorqueException
+ public static List doSelect(Criteria criteria) throws TorqueException
{
try
{
@@ -179,8 +157,8 @@
.addSelectColumn(NAME)
.addSelectColumn(OBJECTDATA);
- if (criteria.getOrderByColumns() == null ||
- criteria.getOrderByColumns().size() == 0)
+ if (criteria.getOrderByColumns() == null
+ || criteria.getOrderByColumns().size() == 0)
{
criteria.addAscendingOrderByColumn(NAME);
}
@@ -201,12 +179,13 @@
List results = new ArrayList();
// Populate the object(s).
- for (int i = 0; i < rows.size(); i++ )
+ for (int i = 0; i < rows.size(); i++)
{
//Role obj = new Role();
Role obj = new TurbineRole();
Record row = (Record) rows.get(i);
- ((TurbineRole) obj).setPrimaryKey(new NumberKey(row.getValue(1).asInt()));
+ ((TurbineRole) obj).setPrimaryKey(
+ new NumberKey(row.getValue(1).asInt()));
((TurbineRole) obj).setName(row.getValue(2).asString());
byte[] objectData = (byte[]) row.getValue(3).asBytes();
Map temp = (Map) ObjectUtils.deserialize(objectData);
@@ -227,13 +206,16 @@
/**
* Builds a criteria object based upon an Role object
+ *
+ * @param role object to build the criteria
+ * @return the Criteria
*/
- public static Criteria buildCriteria( Role role )
+ public static Criteria buildCriteria(Role role)
{
Criteria criteria = new Criteria();
- if ( !((BaseObject)role).isNew() )
+ if (!((BaseObject) role).isNew())
{
- criteria.add(ROLE_ID, ((BaseObject)role).getPrimaryKey());
+ criteria.add(ROLE_ID, ((BaseObject) role).getPrimaryKey());
}
criteria.add(NAME, role.getName());
// causing the removal and updating of roles to
@@ -245,39 +227,39 @@
/**
* Issues an update based on a criteria.
*
- * @param Criteria object containing data that is used to create
- * the UPDATE statement.
- * @exception Exception, a generic exception.
+ * @param criteria object containing data that is used to create
+ * the UPDATE statement.
+ * @exception TorqueException a generic exception.
*/
public static void doUpdate(Criteria criteria)
throws TorqueException
{
Criteria selectCriteria = new Criteria(2);
- selectCriteria.put( ROLE_ID, criteria.remove(ROLE_ID) );
- BasePeer.doUpdate( selectCriteria, criteria );
+ selectCriteria.put(ROLE_ID, criteria.remove(ROLE_ID));
+ BasePeer.doUpdate(selectCriteria, criteria);
}
/**
* Checks if a Role is defined in the system. The name
* is used as query criteria.
*
- * @param permission The Role to be checked.
+ * @param role The Role to be checked.
* @return <code>true</code> if given Role exists in the system.
* @throws DataBackendException when more than one Role with
* the same name exists.
- * @throws Exception, a generic exception.
+ * @throws Exception a generic exception.
*/
- public static boolean checkExists( Role role )
+ public static boolean checkExists(Role role)
throws DataBackendException, Exception
{
Criteria criteria = new Criteria();
criteria.addSelectColumn(ROLE_ID);
criteria.add(NAME, role.getName());
List results = BasePeer.doSelect(criteria);
- if(results.size() > 1)
+ if (results.size() > 1)
{
- throw new DataBackendException("Multiple roles named '" +
- role.getName() + "' exist!");
+ throw new DataBackendException("Multiple roles named '"
+ + role.getName() + "' exist!");
}
return (results.size() == 1);
}
@@ -295,14 +277,15 @@
/**
* Returns the full name of a column.
*
+ * @param name name of a column
* @return A String with the full name of the column.
*/
public static String getColumnName (String name)
{
StringBuffer sb = new StringBuffer();
- sb.append (TABLE_NAME);
- sb.append (".");
- sb.append (name);
+ sb.append(TABLE_NAME);
+ sb.append(".");
+ sb.append(name);
return sb.toString();
}
}
1.3 +13 -17 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.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- RolePermissionPeer.java 11 Jul 2002 07:16:42 -0000 1.2
+++ RolePermissionPeer.java 31 Dec 2002 15:18:35 -0000 1.3
@@ -56,7 +56,6 @@
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,30 +71,28 @@
*/
public class RolePermissionPeer extends BasePeer
{
- private static final TurbineMapBuilder mapBuilder =
- (TurbineMapBuilder) getMapBuilder("org.apache.turbine.util.db.map.TurbineMapBuilder");
+ /** The mapBuilder for this Peer. */
+ 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.getTableRolePermission();
+ public static final String TABLE_NAME = mapBuilder.getTableRolePermission();
/** The column name for the permission id field. */
- public static final String PERMISSION_ID =
- mapBuilder.getRolePermission_PermissionId();
+ public static final String PERMISSION_ID
+ = mapBuilder.getRolePermission_PermissionId();
/** The column name for the role id field. */
- public static final String ROLE_ID =
- mapBuilder.getRolePermission_RoleId();
+ public static final String ROLE_ID = mapBuilder.getRolePermission_RoleId();
/**
* Deletes the mappings for a role_id.
*
* @param role_id An int with the role id.
- * @exception Exception, a generic exception.
+ * @exception Exception a generic exception.
*/
- public static void deleteRole(int role_id)
- throws Exception
+ public static void deleteRole(int role_id) throws Exception
{
Criteria criteria = new Criteria();
criteria.add(ROLE_ID, role_id);
@@ -105,11 +102,10 @@
/**
* Deletes the mappings for a permission_id.
*
- * @param permission An int with the permission id.
- * @exception Exception, a generic exception.
+ * @param permission_id An int with the permission id.
+ * @exception Exception a generic exception.
*/
- public static void deletePermission(int permission_id)
- throws Exception
+ public static void deletePermission(int permission_id) throws Exception
{
Criteria criteria = new Criteria();
criteria.add(PERMISSION_ID, permission_id);
1.5 +150 -85 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.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- TurbineUserPeer.java 12 Dec 2002 15:52:32 -0000 1.4
+++ TurbineUserPeer.java 31 Dec 2002 15:18:35 -0000 1.5
@@ -86,8 +86,8 @@
public class TurbineUserPeer extends BasePeer implements UserPeer
{
/** The mapBuilder for this Peer. */
- private static final TurbineMapBuilder mapBuilder =
- (TurbineMapBuilder) getMapBuilder("org.apache.turbine.util.db.map.TurbineMapBuilder");
+ private static final TurbineMapBuilder mapBuilder = (TurbineMapBuilder)
+ getMapBuilder("org.apache.turbine.util.db.map.TurbineMapBuilder");
// column names
/** The column name for the visitor id field. */
@@ -115,12 +115,12 @@
private static final String EMAIL_COLUMN = mapBuilder.getEmail();
/** The column name for the confirm_value field. */
- private static final String CONFIRM_VALUE_COLUMN =
- mapBuilder.getConfirmValue();
+ 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 =
- org.apache.turbine.om.security.User.CONFIRM_DATA;
+ public static final String CONFIRM_DATA
+ = org.apache.turbine.om.security.User.CONFIRM_DATA;
/** The column name for the visitor id field. */
private static final String OBJECT_DATA_COLUMN = mapBuilder.getObjectData();
@@ -157,8 +157,8 @@
public static final String LAST_LOGIN = mapBuilder.getUser_LastLogin();
/** The key name for the confirm_value field. */
- public static final String CONFIRM_VALUE =
- mapBuilder.getUser_ConfirmValue();
+ public static final String CONFIRM_VALUE
+ = mapBuilder.getUser_ConfirmValue();
/** The key name for the object_data field. */
public static final String OBJECT_DATA = mapBuilder.getUser_ObjectData();
@@ -170,15 +170,15 @@
private static Schema schema = initTableSchema(TABLE_NAME);
/** The columns. */
- private static com.workingdogs.village.Column[] columns =
- initTableColumns(schema);
+ 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 =
- initCriteriaKeys(TABLE_NAME, columnNames);
+ public static String[] criteriaKeys
+ = initCriteriaKeys(TABLE_NAME, columnNames);
/**
@@ -194,14 +194,15 @@
/**
* Returns the full name of a column.
*
+ * @param name name of a column
* @return A String with the full name of the column.
*/
- public static String getColumnName (String name)
+ public static String getColumnName(String name)
{
StringBuffer sb = new StringBuffer();
- sb.append (TABLE_NAME);
- sb.append (".");
- sb.append (name);
+ sb.append(TABLE_NAME);
+ sb.append(".");
+ sb.append(name);
return sb.toString();
}
@@ -209,54 +210,70 @@
*
* Returns the full name of a column.
*
+ * @param name name of a column
* @return A String with the full name of the column.
*/
- public String getFullColumnName (String name)
+ public String getFullColumnName(String name)
{
StringBuffer sb = new StringBuffer();
- sb.append (TABLE_NAME);
- sb.append (".");
- sb.append (name);
+ sb.append(TABLE_NAME);
+ sb.append(".");
+ sb.append(name);
return sb.toString();
}
/**
* Builds a criteria object based upon an User object
+ *
+ * @param user object to build the criteria
+ * @return the Criteria
*/
public static Criteria buildCriteria(User user)
{
Hashtable permData = (Hashtable) user.getPermStorage().clone();
Criteria criteria = new Criteria();
- if ( !((Persistent)user).isNew() )
+ if (!((Persistent) user).isNew())
{
- criteria.add(USER_ID, ((Persistent)user).getPrimaryKey());
+ criteria.add(USER_ID, ((Persistent) user).getPrimaryKey());
}
- for (int i=1; i<TurbineUserPeer.columnNames.length; i++ )
+ for (int i = 1; i < TurbineUserPeer.columnNames.length; i++)
{
- if ( permData.containsKey(TurbineUserPeer.columnNames[i]) )
+ if (permData.containsKey(TurbineUserPeer.columnNames[i]))
{
- criteria.add( TurbineUserPeer.criteriaKeys[i],
- permData.remove(TurbineUserPeer.columnNames[i]) );
+ criteria.add(TurbineUserPeer.criteriaKeys[i],
+ permData.remove(TurbineUserPeer.columnNames[i]));
}
}
- criteria.add( TurbineUserPeer.OBJECT_DATA, permData );
+ criteria.add(TurbineUserPeer.OBJECT_DATA, permData);
return criteria;
}
- /** Add all the columns needed to create a new object */
- public static void addSelectColumns (Criteria criteria)
+ /**
+ * Add all the columns needed to create a new object
+ *
+ * @param criteria The criteria to use.
+ * @exception TorqueException a generic exception.
+ */
+ public static void addSelectColumns(Criteria criteria)
throws TorqueException
{
- for( int i=0; i<columnNames.length; i++ )
+ for (int i = 0; i < columnNames.length; i++)
{
criteria.addSelectColumn(new StringBuffer()
.append(TABLE_NAME)
.append(".")
- .append(columnNames[i]).toString() );
+ .append(columnNames[i]).toString());
}
}
+ /**
+ *
+ * @param row
+ * @param offset
+ * @param obj
+ * @throws TorqueException
+ */
public static void populateObject(Record row, int offset, User obj)
throws TorqueException
{
@@ -280,44 +297,90 @@
}
((Persistent) obj).setPrimaryKey(
- new NumberKey(row.getValue(idPosition).asBigDecimal()) );
+ 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);
+ 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++ )
+ for (int j = 0; j < columnNames.length; j++)
{
- if ( ! ( columnNames[j].equalsIgnoreCase( USER_ID_COLUMN )
- || columnNames[j].equalsIgnoreCase( OBJECT_DATA_COLUMN ) ))
+ 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 );
+ 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 );
+ obj.setPermStorage(tempHash);
}
catch (Exception ex)
{
@@ -329,9 +392,9 @@
* Issues a select based on a criteria.
*
* @param criteria Object containing data that is used to create
- * the SELECT statement.
+ * the SELECT statement.
* @return Vector containing TurbineUser objects.
- * @exception Exception, a generic exception.
+ * @exception TorqueException a generic exception.
*/
public static List doSelect(Criteria criteria)
throws TorqueException
@@ -343,11 +406,11 @@
* Issues a select based on a criteria.
*
* @param criteria Object containing data that is used to create
- * the SELECT statement.
+ * the SELECT statement.
* @param current User object that is to be used as part of the
- * results - if not passed, then a new one is created.
+ * results - if not passed, then a new one is created.
* @return Vector containing TurbineUser objects.
- * @exception Exception, a generic exception.
+ * @exception TorqueException a generic exception.
*/
public static List doSelect(Criteria criteria, User current)
throws TorqueException
@@ -379,7 +442,7 @@
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.get(i);
// Add User to the return Vector.
@@ -400,11 +463,10 @@
* Issues a select based on a criteria.
*
* @param criteria Object containing data that is used to create
- * the SELECT statement.
- * @param current User object that is to be used as part of the
- * results - if not passed, then a new one is created.
+ * the SELECT statement.
+ * @param dbConn
* @return Vector containing TurbineUser objects.
- * @exception Exception, a generic exception.
+ * @exception TorqueException a generic exception.
*/
public static List doSelect(Criteria criteria, Connection dbConn)
throws TorqueException
@@ -439,16 +501,18 @@
/**
* Implementss torque peers' method. Does not use the Class argument
* as Users need to go through TurbineSecurity
+ *
+ * @exception TorqueException a generic exception.
*/
- public static User row2Object (Record row, int offset, Class cls)
+ public static User row2Object(Record row, int offset, Class cls)
throws TorqueException
{
try
{
User obj = TurbineSecurity.getUserInstance();
populateObject(row, offset, obj);
- ((Persistent)obj).setNew(false);
- ((Persistent)obj).setModified(false);
+ ((Persistent) obj).setNew(false);
+ ((Persistent) obj).setModified(false);
return obj;
}
catch (Exception ex)
@@ -459,9 +523,10 @@
/**
* The type of User this peer will instantiate.
+ *
+ * @exception Exception a generic exception.
*/
- public static Class getOMClass()
- throws Exception
+ public static Class getOMClass() throws Exception
{
return TurbineSecurity.getUserClass();
}
@@ -471,47 +536,47 @@
* The criteria only uses USER_ID.
*
* @param criteria Object containing data that is used to create
- * the UPDATE statement.
- * @exception Exception, a generic exception.
+ * the UPDATE statement.
+ * @exception TorqueException a generic exception.
*/
public static void doUpdate(Criteria criteria)
throws TorqueException
{
Criteria selectCriteria = new Criteria(2);
- selectCriteria.put( USER_ID, criteria.remove(USER_ID) );
- BasePeer.doUpdate( selectCriteria, criteria );
+ selectCriteria.put(USER_ID, criteria.remove(USER_ID));
+ BasePeer.doUpdate(selectCriteria, criteria);
}
/**
* Checks if a User is defined in the system. The name
* is used as query criteria.
*
- * @param permission The User to be checked.
+ * @param user The User to be checked.
* @return <code>true</code> if given User exists in the system.
* @throws DataBackendException when more than one User with
* the same name exists.
- * @throws Exception, a generic exception.
+ * @throws Exception a generic exception.
*/
- public static boolean checkExists( User user )
+ public static boolean checkExists(User user)
throws DataBackendException, Exception
{
Criteria criteria = new Criteria();
criteria.addSelectColumn(USER_ID);
criteria.add(USERNAME, user.getUserName());
List results = BasePeer.doSelect(criteria);
- if(results.size() > 1)
+ if (results.size() > 1)
{
- throw new DataBackendException("Multiple users named '" +
- user.getUserName() + "' exist!");
+ throw new DataBackendException("Multiple users named '"
+ + user.getUserName() + "' exist!");
}
- return (results.size()==1);
+ return (results.size() == 1);
}
/**
* Returns a vector of all User objects.
*
* @return A Vector with all users in the system.
- * @exception Exception, a generic exception.
+ * @exception Exception a generic exception.
*/
public static List selectAllUsers()
throws Exception
@@ -527,13 +592,13 @@
* Returns a vector of all confirmed User objects.
*
* @return A Vector with all confirmed users in the system.
- * @exception Exception, a generic exception.
+ * @exception Exception a generic exception.
*/
public static List selectAllConfirmedUsers()
throws Exception
{
Criteria criteria = new Criteria();
- criteria.add ( User.CONFIRM_VALUE, User.CONFIRM_DATA );
+ criteria.add(User.CONFIRM_VALUE, User.CONFIRM_DATA);
criteria.addAscendingOrderByColumn(TurbineUserPeer.LAST_NAME);
criteria.addAscendingOrderByColumn(TurbineUserPeer.FIRST_NAME);
criteria.setIgnoreCase(true);
1.3 +8 -8 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.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- UserGroupRolePeer.java 11 Jul 2002 07:16:42 -0000 1.2
+++ UserGroupRolePeer.java 31 Dec 2002 15:18:35 -0000 1.3
@@ -55,7 +55,6 @@
*/
import org.apache.torque.util.BasePeer;
-import org.apache.torque.map.MapBuilder;
import org.apache.turbine.util.db.map.TurbineMapBuilder;
/**
@@ -70,8 +69,8 @@
public class UserGroupRolePeer extends BasePeer
{
/** The map builder for this Peer. */
- private static final TurbineMapBuilder
- mapBuilder = (TurbineMapBuilder) getMapBuilder("org.apache.turbine.util.db.map.TurbineMapBuilder");
+ 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();
@@ -98,14 +97,15 @@
/**
* Returns the full name of a column.
*
+ * @param name name of a column
* @return A String with the full name of the column.
*/
- public static String getColumnName (String name)
+ public static String getColumnName(String name)
{
StringBuffer sb = new StringBuffer();
- sb.append (TABLE_NAME);
- sb.append (".");
- sb.append (name);
+ sb.append(TABLE_NAME);
+ sb.append(".");
+ sb.append(name);
return sb.toString();
}
}
1.3 +14 -14 jakarta-turbine-2/src/java/org/apache/turbine/om/security/peer/UserPeer.java
Index: UserPeer.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/om/security/peer/UserPeer.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- UserPeer.java 7 Jun 2002 21:11:43 -0000 1.2
+++ UserPeer.java 31 Dec 2002 15:18:35 -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
@@ -60,11 +60,11 @@
* The purpose of this class is to decouple DBSecurityService from
* the default User implementation and it's related Peer class.
*
- * @author <a href="mailto:leandro@ibnetwork.com.br">Leandro Rodrigo Saad Cruz</a>
+ * @author <a href="mailto:leandro@ibnetwork.com.br">Leandro Rodrigo Saad Cruz</a>
* @version $Id$
*/
-public interface UserPeer
-{
+public interface UserPeer
+{
/** The key name for the visitor id field. */
public static String USERNAME = "LOGIN_NAME";
@@ -72,10 +72,10 @@
public static String USER_ID = "USER_ID";
/**
- *
- * Returns the full name of a column.
- *
- * @return A String with the full name of the column.
- */
- public String getFullColumnName(String name);
+ * Returns the full name of a column.
+ *
+ * @param name name of a column
+ * @return A String with the full name of the column.
+ */
+ String getFullColumnName(String name);
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>