jmcnally 01/05/30 15:52:54
Modified: src/java/org/apache/turbine/services/security/db
DBSecurityService.java
Log:
refactor XXXPeer.checkExists calls into protected methods so that SecurityServices
that do not use the exact same tables can still extend this service.
Revision Changes Path
1.6 +70 -23
jakarta-turbine/src/java/org/apache/turbine/services/security/db/DBSecurityService.java
Index: DBSecurityService.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine/src/java/org/apache/turbine/services/security/db/DBSecurityService.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- DBSecurityService.java 2001/05/05 14:03:43 1.5
+++ DBSecurityService.java 2001/05/30 22:52:52 1.6
@@ -96,7 +96,7 @@
* An implementation of SecurityService that uses a database as backend.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Rafal Krzewski</a>
- * @version $Id: DBSecurityService.java,v 1.5 2001/05/05 14:03:43 jvanzyl Exp $
+ * @version $Id: DBSecurityService.java,v 1.6 2001/05/30 22:52:52 jmcnally Exp $
*/
public class DBSecurityService extends BaseSecurityService
{
@@ -205,8 +205,8 @@
{
lockExclusive();
userExists=TurbineSecurity.accountExists(user);
- groupExists=GroupPeer.checkExists(group);
- roleExists=RolePeer.checkExists(role);
+ groupExists=checkExists(group);
+ roleExists=checkExists(role);
if(userExists && groupExists && roleExists)
{
Criteria criteria = new Criteria();
@@ -262,8 +262,8 @@
{
lockExclusive();
userExists=TurbineSecurity.accountExists(user);
- groupExists=GroupPeer.checkExists(group);
- roleExists=RolePeer.checkExists(role);
+ groupExists=checkExists(group);
+ roleExists=checkExists(role);
if(userExists && groupExists && roleExists)
{
Criteria criteria = new Criteria();
@@ -359,8 +359,8 @@
try
{
lockExclusive();
- roleExists=RolePeer.checkExists(role);
- permissionExists=PermissionPeer.checkExists(permission);
+ roleExists=checkExists(role);
+ permissionExists=checkExists(permission);
if(roleExists && permissionExists)
{
Criteria criteria = new Criteria();
@@ -407,8 +407,8 @@
try
{
lockExclusive();
- roleExists=RolePeer.checkExists(role);
- permissionExists=PermissionPeer.checkExists(permission);
+ roleExists=checkExists(role);
+ permissionExists=checkExists(permission);
if(roleExists && permissionExists)
{
Criteria criteria = new Criteria();
@@ -455,7 +455,7 @@
try
{
lockExclusive();
- roleExists=RolePeer.checkExists(role);
+ roleExists=checkExists(role);
if(roleExists)
{
// The following would not work, due to an annoying misfeature of
Village.
@@ -584,7 +584,7 @@
try
{
lockShared();
- roleExists = RolePeer.checkExists(role);
+ roleExists = checkExists(role);
if(roleExists)
{
return PermissionPeer.retrieveSet(role);
@@ -615,7 +615,7 @@
boolean groupExists = false;
try
{
- groupExists = GroupPeer.checkExists(group);
+ groupExists = checkExists(group);
if(groupExists)
{
Criteria criteria = GroupPeer.buildCriteria(group);
@@ -642,7 +642,7 @@
boolean roleExists = false;
try
{
- roleExists = RolePeer.checkExists(role);
+ roleExists = checkExists(role);
if(roleExists)
{
Criteria criteria = RolePeer.buildCriteria(role);
@@ -669,7 +669,7 @@
boolean permissionExists = false;
try
{
- permissionExists = PermissionPeer.checkExists(permission);
+ permissionExists = checkExists(permission);
if(permissionExists)
{
Criteria criteria = PermissionPeer.buildCriteria(permission);
@@ -734,7 +734,7 @@
try
{
lockExclusive();
- groupExists = GroupPeer.checkExists(group);
+ groupExists = checkExists(group);
if(!groupExists)
{
// add a row to the table
@@ -786,7 +786,7 @@
try
{
lockExclusive();
- roleExists = RolePeer.checkExists(role);
+ roleExists = checkExists(role);
if(!roleExists)
{
// add a row to the table
@@ -837,7 +837,7 @@
try
{
lockExclusive();
- permissionExists = PermissionPeer.checkExists(permission);
+ permissionExists = checkExists(permission);
if(!permissionExists)
{
// add a row to the table
@@ -889,7 +889,7 @@
try
{
lockExclusive();
- groupExists = GroupPeer.checkExists(group);
+ groupExists = checkExists(group);
if(groupExists)
{
Criteria criteria = GroupPeer.buildCriteria(group);
@@ -925,7 +925,7 @@
try
{
lockExclusive();
- roleExists = RolePeer.checkExists(role);
+ roleExists = checkExists(role);
if(roleExists)
{
// revoke all permissions from the role to be deleted
@@ -961,7 +961,7 @@
try
{
lockExclusive();
- permissionExists = PermissionPeer.checkExists(permission);
+ permissionExists = checkExists(permission);
if(permissionExists)
{
Criteria criteria = PermissionPeer.buildCriteria(permission);
@@ -997,7 +997,7 @@
try
{
lockExclusive();
- groupExists = GroupPeer.checkExists(group);
+ groupExists = checkExists(group);
if(groupExists)
{
((SecurityObject)group).setName(name);
@@ -1032,7 +1032,7 @@
try
{
lockExclusive();
- roleExists = RolePeer.checkExists(role);
+ roleExists = checkExists(role);
if(roleExists)
{
role.setName(name);
@@ -1067,7 +1067,7 @@
try
{
lockExclusive();
- permissionExists = PermissionPeer.checkExists(permission);
+ permissionExists = checkExists(permission);
if(permissionExists)
{
((SecurityObject)permission).setName(name);
@@ -1136,4 +1136,51 @@
}
return up;
}
+
+
+ /**
+ * Determines if the <code>Group</code> exists in the security system.
+ *
+ * @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
+ * the same name exists.
+ * @throws Exception, a generic exception.
+ */
+ protected boolean checkExists(Group group)
+ throws DataBackendException, Exception
+ {
+ return GroupPeer.checkExists(group);
+ }
+
+ /**
+ * Determines if the <code>Role</code> exists in the security system.
+ *
+ * @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
+ * the same name exists.
+ * @throws Exception, a generic exception.
+ */
+ protected boolean checkExists(Role role)
+ throws DataBackendException, Exception
+ {
+ return RolePeer.checkExists(role);
+ }
+
+ /**
+ * Determines if the <code>Permission</code> exists in the security system.
+ *
+ * @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
+ * the same name exists.
+ * @throws Exception, a generic exception.
+ */
+ protected boolean checkExists(Permission permission)
+ throws DataBackendException, Exception
+ {
+ return PermissionPeer.checkExists(permission);
+ }
+
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]