You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by ep...@apache.org on 2004/07/07 20:19:06 UTC
cvs commit: jakarta-turbine-fulcrum/security/memory/src/test/org/apache/fulcrum/security/memory/turbine MemoryTurbineModelManagerTest.java
epugh 2004/07/07 11:19:06
Modified: security/memory/src/java/org/apache/fulcrum/security/memory/dynamic
MemoryModelManagerImpl.java
security/memory/src/test/org/apache/fulcrum/security/memory/turbine
MemoryTurbineModelManagerTest.java
Log:
refactor to use AbstractDynamicModelManager
Revision Changes Path
1.3 +4 -101 jakarta-turbine-fulcrum/security/memory/src/java/org/apache/fulcrum/security/memory/dynamic/MemoryModelManagerImpl.java
Index: MemoryModelManagerImpl.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-fulcrum/security/memory/src/java/org/apache/fulcrum/security/memory/dynamic/MemoryModelManagerImpl.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- MemoryModelManagerImpl.java 7 Jul 2004 16:51:26 -0000 1.2
+++ MemoryModelManagerImpl.java 7 Jul 2004 18:19:06 -0000 1.3
@@ -14,24 +14,19 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import java.util.Iterator;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.fulcrum.security.entity.Group;
import org.apache.fulcrum.security.entity.Permission;
import org.apache.fulcrum.security.entity.Role;
import org.apache.fulcrum.security.entity.User;
+import org.apache.fulcrum.security.model.dynamic.AbstractDynamicModelManager;
import org.apache.fulcrum.security.model.dynamic.DynamicModelManager;
import org.apache.fulcrum.security.model.dynamic.entity.DynamicGroup;
import org.apache.fulcrum.security.model.dynamic.entity.DynamicPermission;
import org.apache.fulcrum.security.model.dynamic.entity.DynamicRole;
import org.apache.fulcrum.security.model.dynamic.entity.DynamicUser;
-import org.apache.fulcrum.security.spi.AbstractManager;
import org.apache.fulcrum.security.util.DataBackendException;
-import org.apache.fulcrum.security.util.GroupSet;
-import org.apache.fulcrum.security.util.PermissionSet;
-import org.apache.fulcrum.security.util.RoleSet;
import org.apache.fulcrum.security.util.UnknownEntityException;
/**
@@ -42,7 +37,7 @@
* @version $Id$
*/
public class MemoryModelManagerImpl
- extends AbstractManager
+ extends AbstractDynamicModelManager
implements DynamicModelManager
{
/** Logging */
@@ -259,6 +254,7 @@
if (roleExists && permissionExists)
{
((DynamicRole) role).removePermission(permission);
+ ((DynamicPermission) permission).removeRole(role);
return;
}
}
@@ -276,98 +272,5 @@
throw new UnknownEntityException("Unknown permission '" + permission.getName() + "'");
}
}
- /**
- * Revokes all permissions from a Role.
- *
- * This method is user when deleting a Role.
- *
- * @param role the Role
- * @throws DataBackendException if there was an error accessing the data backend.
- * @throws UnknownEntityException if the Role is not present.
- */
- public synchronized void revokeAll(Role role)
- throws DataBackendException, UnknownEntityException
- {
- boolean roleExists = false;
- try
- {
- roleExists = getRoleManager().checkExists(role);
- if (roleExists)
- {
- ((DynamicRole) role).setPermissions(new PermissionSet());
- return;
- }
- }
- catch (Exception e)
- {
- throw new DataBackendException("revokeAll(Role) failed", e);
- }
-
- throw new UnknownEntityException("Unknown role '" + role.getName() + "'");
- }
- /**
- * Revokes all groups from a user
- *
- * This method is used when deleting an account.
- *
- * @param user the User.
- * @throws DataBackendException if there was an error accessing the data backend.
- * @throws UnknownEntityException if the account is not present.
- */
- public synchronized void revokeAll(User user)
- throws DataBackendException, UnknownEntityException
- {
- boolean userExists = false;
- try
- {
- userExists = getUserManager().checkExists(user);
- if (userExists)
- {
- for (Iterator i = ((DynamicUser) user).getGroups().iterator(); i.hasNext();)
- {
- DynamicGroup group = (DynamicGroup) i.next();
- group.removeUser(user);
- }
- ((DynamicUser) user).setGroups(new GroupSet());
- return;
- }
- }
- catch (Exception e)
- {
- throw new DataBackendException("revokeAll(User) failed:" + e.getMessage(), e);
- }
- throw new UnknownEntityException("Unknown user '" + user.getName() + "'");
- }
-
- /**
- * Revokes all roles from a Permission.
- *
- * This method is used when deleting a Permission.
- *
- * @param permission the Permission
- * @throws DataBackendException if there was an error accessing the data backend.
- * @throws UnknownEntityException if the Permission is not present.
- */
- public synchronized void revokeAll(Permission permission)
- throws DataBackendException, UnknownEntityException
- {
- boolean roleExists = false;
- try
- {
- roleExists = getPermissionManager().checkExists(permission);
- if (roleExists)
- {
- ((DynamicPermission) permission).setRoles(new RoleSet());
- return;
- }
- }
- catch (Exception e)
- {
- throw new DataBackendException("revokeAll(Permission) failed", e);
- }
-
- throw new UnknownEntityException("Unknown permission '" + permission.getName() + "'");
- }
-
}
1.3 +1 -4 jakarta-turbine-fulcrum/security/memory/src/test/org/apache/fulcrum/security/memory/turbine/MemoryTurbineModelManagerTest.java
Index: MemoryTurbineModelManagerTest.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-fulcrum/security/memory/src/test/org/apache/fulcrum/security/memory/turbine/MemoryTurbineModelManagerTest.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- MemoryTurbineModelManagerTest.java 7 Jul 2004 16:51:27 -0000 1.2
+++ MemoryTurbineModelManagerTest.java 7 Jul 2004 18:19:06 -0000 1.3
@@ -33,10 +33,7 @@
public class MemoryTurbineModelManagerTest
extends AbstractTurbineModelManagerTest
{
- public static void main(String[] args)
- {
- junit.textui.TestRunner.run(MemoryTurbineModelManagerTest.class);
- }
+
public void setUp() throws Exception
{
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org