You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by tv...@apache.org on 2006/09/21 22:56:38 UTC

svn commit: r448680 [2/4] - in /jakarta/turbine/fulcrum/trunk/security/torque: ./ schema/ src/java/org/apache/fulcrum/security/torque/basic/ src/java/org/apache/fulcrum/security/torque/dynamic/ src/java/org/apache/fulcrum/security/torque/om/map/ src/ja...

Added: jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/dynamic/TorqueDynamicModelManagerImpl.java
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/dynamic/TorqueDynamicModelManagerImpl.java?view=auto&rev=448680
==============================================================================
--- jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/dynamic/TorqueDynamicModelManagerImpl.java (added)
+++ jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/dynamic/TorqueDynamicModelManagerImpl.java Thu Sep 21 13:56:36 2006
@@ -0,0 +1,412 @@
+package org.apache.fulcrum.security.torque.dynamic;
+/*
+ *  Copyright 2001-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+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.torque.om.TorqueDynamicGroupRole;
+import org.apache.fulcrum.security.torque.om.TorqueDynamicGroupRolePeer;
+import org.apache.fulcrum.security.torque.om.TorqueDynamicRolePermission;
+import org.apache.fulcrum.security.torque.om.TorqueDynamicRolePermissionPeer;
+import org.apache.fulcrum.security.torque.om.TorqueDynamicUserDelegates;
+import org.apache.fulcrum.security.torque.om.TorqueDynamicUserDelegatesPeer;
+import org.apache.fulcrum.security.torque.om.TorqueDynamicUserGroup;
+import org.apache.fulcrum.security.torque.om.TorqueDynamicUserGroupPeer;
+import org.apache.fulcrum.security.util.DataBackendException;
+import org.apache.fulcrum.security.util.UnknownEntityException;
+import org.apache.torque.TorqueException;
+import org.apache.torque.util.Criteria;
+/**
+ * This implementation persists to a database via Torque.
+ *
+ * @author <a href="mailto:tv@apache.org">Thomas Vandahl</a>
+ * @version $Id:$
+ */
+public class TorqueDynamicModelManagerImpl extends AbstractDynamicModelManager implements DynamicModelManager
+{
+    /**
+     * Revokes a Role from a Group.
+     *
+     * @param group the Group.
+     * @param role the Role.
+     * @throws DataBackendException if there was an error accessing the data backend.
+     * @throws UnknownEntityException if group or role is not present.
+     */
+    public synchronized void revoke(Group group, Role role)
+        throws DataBackendException, UnknownEntityException
+    {
+        boolean groupExists = false;
+        boolean roleExists = false;
+        try
+        {
+            groupExists = getGroupManager().checkExists(group);
+            roleExists = getRoleManager().checkExists(role);
+
+            if (groupExists && roleExists)
+            {
+                ((DynamicGroup) group).removeRole(role);
+                ((DynamicRole) role).removeGroup(group);
+
+                Criteria criteria = new Criteria();
+                criteria.add(TorqueDynamicGroupRolePeer.ROLE_ID, (Integer)role.getId());
+                criteria.add(TorqueDynamicGroupRolePeer.GROUP_ID, (Integer)group.getId());
+                TorqueDynamicGroupRolePeer.doDelete(criteria);
+            }
+        }
+        catch (TorqueException e)
+        {
+            throw new DataBackendException("revoke('" + group.getName() + "', '" + role.getName() + "') failed", e);
+        }
+
+        if (!groupExists)
+        {
+            throw new UnknownEntityException("Unknown group '" + group.getName() + "'");
+        }
+
+        if (!roleExists)
+        {
+            throw new UnknownEntityException("Unknown role '" + role.getName() + "'");
+        }
+    }
+
+    /**
+     * Grants a Role a Permission
+     *
+     * @param role the Role.
+     * @param permission the Permission.
+     * @throws DataBackendException if there was an error accessing the data backend.
+     * @throws UnknownEntityException if role or permission is not present.
+     */
+    public synchronized void grant(Role role, Permission permission)
+        throws DataBackendException, UnknownEntityException
+    {
+        boolean roleExists = false;
+        boolean permissionExists = false;
+
+        try
+        {
+            roleExists = getRoleManager().checkExists(role);
+            permissionExists = getPermissionManager().checkExists(permission);
+
+            if (roleExists && permissionExists)
+            {
+                ((DynamicRole) role).addPermission(permission);
+                ((DynamicPermission) permission).addRole(role);
+
+                TorqueDynamicRolePermission rp = new TorqueDynamicRolePermission();
+                rp.setPermissionId((Integer)permission.getId());
+                rp.setRoleId((Integer)role.getId());
+                rp.save();
+            }
+        }
+        catch (Exception e)
+        {
+            throw new DataBackendException("grant('" + role.getName() + "', '" + permission.getName() + "') failed", e);
+        }
+
+        if (!roleExists)
+        {
+            throw new UnknownEntityException("Unknown role '" + role.getName() + "'");
+        }
+
+        if (!permissionExists)
+        {
+            throw new UnknownEntityException("Unknown permission '" + permission.getName() + "'");
+        }
+    }
+    
+    /**
+     * Revokes a Permission from a Role.
+     *
+     * @param role the Role.
+     * @param permission the Permission.
+     * @throws DataBackendException if there was an error accessing the data backend.
+     * @throws UnknownEntityException if role or permission is not present.
+     */
+    public synchronized void revoke(Role role, Permission permission)
+        throws DataBackendException, UnknownEntityException
+    {
+        boolean roleExists = false;
+        boolean permissionExists = false;
+
+        try
+        {
+            roleExists = getRoleManager().checkExists(role);
+            permissionExists = getPermissionManager().checkExists(permission);
+
+            if (roleExists && permissionExists)
+            {
+                ((DynamicRole) role).removePermission(permission);
+                ((DynamicPermission) permission).removeRole(role);
+
+                Criteria criteria = new Criteria();
+                criteria.add(TorqueDynamicRolePermissionPeer.ROLE_ID, (Integer)role.getId());
+                criteria.add(TorqueDynamicRolePermissionPeer.PERMISSION_ID, (Integer)permission.getId());
+                TorqueDynamicRolePermissionPeer.doDelete(criteria);
+            }
+        }
+        catch (TorqueException e)
+        {
+            throw new DataBackendException("revoke('" + role.getName() + "', '" + permission.getName() + "') failed", e);
+        }
+        
+        if (!roleExists)
+        {
+            throw new UnknownEntityException("Unknown role '" + role.getName() + "'");
+        }
+        
+        if (!permissionExists)
+        {
+            throw new UnknownEntityException("Unknown permission '" + permission.getName() + "'");
+        }
+    }
+
+    /**
+     * Puts a user in a group.
+     *
+     * This method is used when adding a user to a group
+     *
+     * @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 grant(User user, Group group) throws DataBackendException, UnknownEntityException
+    {
+        boolean groupExists = false;
+        boolean userExists = false;
+        
+        try
+        {
+            groupExists = getGroupManager().checkExists(group);
+            userExists = getUserManager().checkExists(user);
+
+            if (groupExists && userExists)
+            {
+                ((DynamicUser) user).addGroup(group);
+                ((DynamicGroup) group).addUser(user);
+                
+                TorqueDynamicUserGroup ug = new TorqueDynamicUserGroup();
+                ug.setGroupId((Integer)group.getId());
+                ug.setUserId((Integer)user.getId());
+                ug.save();
+
+                return;
+            }
+        }
+        catch (Exception e)
+        {
+            throw new DataBackendException("grant('" + user.getName() + "', '" + group.getName() + "') failed", e);
+        }
+
+        if (!groupExists)
+        {
+            throw new UnknownEntityException("Unknown group '" + group.getName() + "'");
+        }
+
+        if (!userExists)
+        {
+            throw new UnknownEntityException("Unknown user '" + user.getName() + "'");
+        }
+    }
+
+    /**
+     * Removes a user in a group.
+     *
+     * This method is used when removing a user to a group
+     *
+     * @param user the User.
+     * @throws DataBackendException if there was an error accessing the data backend.
+     * @throws UnknownEntityException if the user or group is not present.
+     */
+    public synchronized void revoke(User user, Group group) throws DataBackendException, UnknownEntityException
+    {
+        boolean groupExists = false;
+        boolean userExists = false;
+        
+        try
+        {
+            groupExists = getGroupManager().checkExists(group);
+            userExists = getUserManager().checkExists(user);
+
+            if (groupExists && userExists)
+            {
+                ((DynamicUser) user).removeGroup(group);
+                ((DynamicGroup) group).removeUser(user);
+                
+                Criteria criteria = new Criteria();
+                criteria.add(TorqueDynamicUserGroupPeer.GROUP_ID, (Integer)group.getId());
+                criteria.add(TorqueDynamicUserGroupPeer.USER_ID, (Integer)user.getId());
+                TorqueDynamicUserGroupPeer.doDelete(criteria);
+
+                return;
+            }
+        }
+        catch (TorqueException e)
+        {
+            throw new DataBackendException("revoke('" + user.getName() + "', '" + group.getName() + "') failed", e);
+        }
+
+        if (!groupExists)
+        {
+            throw new UnknownEntityException("Unknown group '" + group.getName() + "'");
+        }
+
+        if (!userExists)
+        {
+            throw new UnknownEntityException("Unknown user '" + user.getName() + "'");
+        }
+    }
+
+    /**
+     * Grants a Group a Role
+     *
+     * @param group the Group.
+     * @param role the Role.
+     * @throws DataBackendException if there was an error accessing the data backend.
+     * @throws UnknownEntityException if group or role is not present.
+     */
+    public synchronized void grant(Group group, Role role)
+        throws DataBackendException, UnknownEntityException
+    {
+        boolean groupExists = false;
+        boolean roleExists = false;
+        
+        try
+        {
+            groupExists = getGroupManager().checkExists(group);
+            roleExists = getRoleManager().checkExists(role);
+            if (groupExists && roleExists)
+            {
+                ((DynamicGroup) group).addRole(role);
+                ((DynamicRole) role).addGroup(group);
+                
+                TorqueDynamicGroupRole gr = new TorqueDynamicGroupRole();
+                gr.setGroupId((Integer)group.getId());
+                gr.setRoleId((Integer)role.getId());
+                gr.save();
+            }
+        }
+        catch (Exception e)
+        {
+            throw new DataBackendException("grant('" + group.getName() + "', '" + role.getName() + "') failed", e);
+        }
+
+        if (!groupExists)
+        {
+            throw new UnknownEntityException("Unknown group '" + group.getName() + "'");
+        }
+
+        if (!roleExists)
+        {
+            throw new UnknownEntityException("Unknown role '" + role.getName() + "'");
+        }
+    }
+
+    /**
+     * Allow B to assumes A's roles, groups and permissions
+     * @param delegator A
+     * @param delegatee B
+     */
+    public synchronized void addDelegate(User delegator, User delegatee)
+            throws DataBackendException, UnknownEntityException 
+    {
+        boolean delegatorExists = false;
+        boolean delegateeExists = false;
+        
+        try
+        {
+            delegatorExists = getUserManager().checkExists(delegator);
+            delegateeExists = getUserManager().checkExists(delegatee);
+
+            if (delegatorExists && delegateeExists)
+            {
+                super.addDelegate(delegator, delegatee);
+
+                TorqueDynamicUserDelegates d = new TorqueDynamicUserDelegates();
+                d.setDelegatorUserId((Integer)delegator.getId());
+                d.setDelegateeUserId((Integer)delegatee.getId());
+                d.save();
+            }
+        }
+        catch (Exception e)
+        {
+            throw new DataBackendException("addDelegate('" 
+                    + delegator.getName() + "', '" 
+                    + delegatee.getName() + "') failed", e);
+        }
+
+        if (!delegatorExists)
+        {
+            throw new UnknownEntityException("Unknown user '" + delegator.getName() + "'");
+        }
+
+        if (!delegateeExists)
+        {
+            throw new UnknownEntityException("Unknown user '" + delegatee.getName() + "'");
+        }
+    }
+
+    /**
+     * Stop A having B's roles, groups and permissions
+     * @param delegate A
+     * @param delegatee B
+     */
+    public synchronized void removeDelegate(User delegator, User delegatee)
+            throws DataBackendException, UnknownEntityException 
+    {
+        boolean delegatorExists = false;
+        boolean delegateeExists = false;
+        
+        try
+        {
+            delegatorExists = getUserManager().checkExists(delegator);
+            delegateeExists = getUserManager().checkExists(delegatee);
+
+            if (delegatorExists && delegateeExists)
+            {
+                super.removeDelegate(delegator, delegatee);
+
+                Criteria criteria = new Criteria();
+                criteria.add(TorqueDynamicUserDelegatesPeer.DELEGATOR_USER_ID, (Integer)delegator.getId());
+                criteria.add(TorqueDynamicUserDelegatesPeer.DELEGATEE_USER_ID, (Integer)delegatee.getId());
+                TorqueDynamicUserDelegatesPeer.doDelete(criteria);
+            }
+        }
+        catch (TorqueException e)
+        {
+            throw new DataBackendException("removeDelegate('" 
+                    + delegator.getName() + "', '" 
+                    + delegatee.getName() + "') failed", e);
+        }
+
+        if (!delegatorExists)
+        {
+            throw new UnknownEntityException("Unknown user '" + delegator.getName() + "'");
+        }
+
+        if (!delegateeExists)
+        {
+            throw new UnknownEntityException("Unknown user '" + delegatee.getName() + "'");
+        }
+    }
+}
\ No newline at end of file

Added: jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/dynamic/TorqueDynamicPermissionManagerImpl.java
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/dynamic/TorqueDynamicPermissionManagerImpl.java?view=auto&rev=448680
==============================================================================
--- jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/dynamic/TorqueDynamicPermissionManagerImpl.java (added)
+++ jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/dynamic/TorqueDynamicPermissionManagerImpl.java Thu Sep 21 13:56:36 2006
@@ -0,0 +1,366 @@
+package org.apache.fulcrum.security.torque.dynamic;
+/*
+ *  Copyright 2001-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+import java.sql.Connection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.fulcrum.security.RoleManager;
+import org.apache.fulcrum.security.entity.Permission;
+import org.apache.fulcrum.security.entity.Role;
+import org.apache.fulcrum.security.model.dynamic.entity.DynamicPermission;
+import org.apache.fulcrum.security.spi.AbstractPermissionManager;
+import org.apache.fulcrum.security.torque.om.TorqueDynamicRolePermissionPeer;
+import org.apache.fulcrum.security.torque.om.TorquePermission;
+import org.apache.fulcrum.security.torque.om.TorquePermissionPeer;
+import org.apache.fulcrum.security.torque.om.TorqueRole;
+import org.apache.fulcrum.security.torque.om.TorqueRolePeer;
+import org.apache.fulcrum.security.util.DataBackendException;
+import org.apache.fulcrum.security.util.EntityExistsException;
+import org.apache.fulcrum.security.util.PermissionSet;
+import org.apache.fulcrum.security.util.RoleSet;
+import org.apache.fulcrum.security.util.UnknownEntityException;
+import org.apache.torque.NoRowsException;
+import org.apache.torque.TorqueException;
+import org.apache.torque.om.SimpleKey;
+import org.apache.torque.util.Criteria;
+import org.apache.torque.util.Transaction;
+/**
+ * This implementation persists to a database via Torque.
+ *
+ * @author <a href="mailto:tv@apache.org">Thomas Vandahl</a>
+ * @version $Id:$
+ */
+public class TorqueDynamicPermissionManagerImpl extends AbstractPermissionManager
+{
+    /**
+     * Retrieves all permissions defined in the system.
+     *
+     * @return the names of all roles defined in the system.
+     * @throws DataBackendException
+     *             if there was an error accessing the data backend.
+     */
+    public PermissionSet getAllPermissions() throws DataBackendException
+    {
+        PermissionSet permissionSet = new PermissionSet();
+        Connection con = null;
+
+        try
+        {
+            con = Transaction.begin(TorquePermissionPeer.DATABASE_NAME);
+            
+            List permissions = TorquePermissionPeer.doSelect(new Criteria(), con);
+            
+            for (Iterator i = permissions.iterator(); i.hasNext();)
+            {
+                TorquePermission p = (TorquePermission)i.next();
+
+                // TODO: This throws UnknownEntityException.
+                Permission permission = getPermissionInstance();
+                permission.setId(p.getId());
+                permission.setName(p.getName());
+
+                // Add roles if they exist
+                ((DynamicPermission)permission).setRoles(getRolesForPermission(permission, con));
+
+                permissionSet.add(permission);
+            }
+
+            Transaction.commit(con);
+        }
+        catch (Exception e)
+        {
+            Transaction.safeRollback(con);
+            throw new DataBackendException("Error retrieving permission information", e);
+        }
+
+        return permissionSet;
+    }
+
+    /**
+     * Renames an existing Permission.
+     *
+     * @param permission
+     *            The object describing the permission to be renamed.
+     * @param name
+     *            the new name for the permission.
+     * @throws DataBackendException
+     *             if there was an error accessing the data backend.
+     * @throws UnknownEntityException
+     *             if the permission does not exist.
+     */
+    public synchronized void renamePermission(Permission permission, String name)
+        throws DataBackendException, UnknownEntityException
+    {
+        if (checkExists(permission))
+        {
+            permission.setName(name);
+            
+            try
+            {
+                TorquePermission p = new TorquePermission();
+                p.setId((Integer)permission.getId());
+                p.setName(name);
+                p.setNew(false);
+                p.save();
+            }
+            catch (Exception e)
+            {
+                throw new DataBackendException("Renaming Permission '" + permission + "' failed", e);
+            }
+        }
+        else
+        {
+            throw new UnknownEntityException("Unknown permission '" + permission + "'");
+        }
+    }
+
+    /**
+     * Determines if the <code>Permission</code> exists in the security
+     * system.
+     *
+     * @param permissionName
+     *            a <code>Permission</code> value
+     * @return true if the permission name exists in the system, false otherwise
+     * @throws DataBackendException
+     *             when more than one Permission with the same name exists.
+     */
+    public boolean checkExists(String permissionName) throws DataBackendException
+    {
+        List permissions;
+        
+        try
+        {
+            Criteria criteria = new Criteria();
+            criteria.add(TorquePermissionPeer.PERMISSION_NAME, permissionName);
+
+            permissions = TorquePermissionPeer.doSelect(criteria);
+        }
+        catch (TorqueException e)
+        {
+            throw new DataBackendException("Error retrieving permission information", e);
+        }
+
+        if (permissions.size() > 1)
+        {
+            throw new DataBackendException("Multiple permissions with same name '" + permissionName + "'");
+        }
+
+        return (permissions.size() == 1);
+    }
+
+    /**
+     * Removes a Permission from the system.
+     *
+     * @param permission
+     *            The object describing the permission to be removed.
+     * @throws DataBackendException
+     *             if there was an error accessing the data backend.
+     * @throws UnknownEntityException
+     *             if the permission does not exist.
+     */
+    public synchronized void removePermission(Permission permission)
+        throws DataBackendException, UnknownEntityException
+    {
+        if (checkExists(permission))
+        {
+            try
+            {
+                TorquePermissionPeer.doDelete(SimpleKey.keyFor((Integer)permission.getId()));
+            }
+            catch (TorqueException e)
+            {
+                throw new DataBackendException("Removing Permission '" + permission + "' failed", e);
+            }
+        }
+        else
+        {
+            throw new UnknownEntityException("Unknown permission '" + permission + "'");
+        }
+    }
+
+    /**
+     * Creates a new permission with specified attributes.
+     *
+     * @param permission
+     *            the object describing the permission to be created.
+     * @return a new Permission object that has id set up properly.
+     * @throws DataBackendException
+     *             if there was an error accessing the data backend.
+     * @throws EntityExistsException
+     *             if the permission already exists.
+     */
+    protected synchronized Permission persistNewPermission(Permission permission)
+        throws DataBackendException
+    {
+        try
+        {
+            TorquePermission p = new TorquePermission();
+            p.setName(permission.getName());
+            p.save();
+            
+            permission.setId(p.getId());
+        }
+        catch (Exception e)
+        {
+            throw new DataBackendException("Adding Permission '" + permission + "' failed", e);
+        }
+
+        return permission;
+    }
+
+    /**
+     * Retrieve a Permission object with specified id.
+     *
+     * @param id
+     *            the id of the Permission.
+     * @return an object representing the Permission with specified id.
+     * @throws DataBackendException
+     *             if there was an error accessing the data backend.
+     * @throws UnknownEntityException
+     *             if the permission does not exist.
+     */
+    public Permission getPermissionById(Object id)
+        throws DataBackendException, UnknownEntityException
+    {
+        Permission permission = getPermissionInstance();
+
+        if (id != null && id instanceof Integer)
+        {
+            Connection con = null;
+
+            try
+            {
+                con = Transaction.begin(TorquePermissionPeer.DATABASE_NAME);
+                
+                TorquePermission p = 
+                    TorquePermissionPeer.retrieveByPK((Integer)id, con);
+                permission.setId(p.getId());
+                permission.setName(p.getName());
+
+                // Add roles if they exist
+                ((DynamicPermission)permission).setRoles(getRolesForPermission(permission, con));
+
+                Transaction.commit(con);
+            }
+            catch (NoRowsException e)
+            {
+                Transaction.safeRollback(con);
+                throw new UnknownEntityException("Permission with id '" + id + "' does not exist.", e);
+            }
+            catch (TorqueException e)
+            {
+                Transaction.safeRollback(con);
+                throw new DataBackendException("Error retrieving permission information", e);
+            }
+        }
+        else
+        {
+            throw new UnknownEntityException("Invalid permission id '" + permission.getId() + "'");
+        }
+
+        return permission;
+    }
+
+    /**
+     * Retrieve a Permission object with specified name.
+     *
+     * @param name the name of the Group.
+     * @return an object representing the Group with specified name.
+     * @throws DataBackendException if there was an error accessing the
+     *         data backend.
+     * @throws UnknownEntityException if the group does not exist.
+     */
+    public Permission getPermissionByName(String name)
+        throws DataBackendException, UnknownEntityException
+    {
+        Permission permission = getPermissionInstance();
+        List permissions = Collections.EMPTY_LIST;
+        Connection con = null;
+
+        try
+        {
+            con = Transaction.begin(TorquePermissionPeer.DATABASE_NAME);
+            
+            Criteria criteria = new Criteria();
+            criteria.add(TorquePermissionPeer.PERMISSION_NAME, name);
+
+            permissions = TorquePermissionPeer.doSelect(criteria, con);
+
+            if (permissions.size() == 1)
+            {
+                TorquePermission p = (TorquePermission) permissions.get(0);
+                
+                permission.setId(p.getId());
+                permission.setName(p.getName());
+                
+                // Add roles if they exist
+                ((DynamicPermission)permission).setRoles(getRolesForPermission(permission, con));
+            }
+
+            Transaction.commit(con);
+        }
+        catch (TorqueException e)
+        {
+            Transaction.safeRollback(con);
+            throw new DataBackendException("Error retrieving permission information", e);
+        }
+
+        if (permissions.size() == 0)
+        {
+            throw new UnknownEntityException("Could not find permission " + name);
+        }
+
+        if (permissions.size() > 1)
+        {
+            throw new DataBackendException("Multiple Permissions with same name '" + name + "'");
+        }
+
+        return permission;
+    }
+
+    /**
+     * Provides the roles for the given permission
+     *  
+     * @param permission the permission for which the roles should be retrieved  
+     * @param con a database connection
+     */
+    private RoleSet getRolesForPermission(Permission permission, Connection con)
+        throws TorqueException, DataBackendException
+    {
+        RoleSet roleSet = new RoleSet();
+        
+        Criteria criteria = new Criteria();
+        criteria.addJoin(TorqueDynamicRolePermissionPeer.ROLE_ID, TorqueRolePeer.ROLE_ID);
+        criteria.add(TorqueDynamicRolePermissionPeer.PERMISSION_ID, (Integer)permission.getId());
+        
+        List roles = TorqueRolePeer.doSelect(criteria, con);
+        RoleManager roleManager = getRoleManager();
+        
+        for (Iterator i = roles.iterator(); i.hasNext();)
+        {
+            TorqueRole r = (TorqueRole)i.next();
+            Role role = roleManager.getRoleInstance();
+            
+            role.setId(r.getId());
+            role.setName(r.getName());
+            roleSet.add(role);
+        }
+        
+        return roleSet;
+    }
+}

Added: jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/dynamic/TorqueDynamicRoleManagerImpl.java
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/dynamic/TorqueDynamicRoleManagerImpl.java?view=auto&rev=448680
==============================================================================
--- jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/dynamic/TorqueDynamicRoleManagerImpl.java (added)
+++ jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/dynamic/TorqueDynamicRoleManagerImpl.java Thu Sep 21 13:56:36 2006
@@ -0,0 +1,404 @@
+package org.apache.fulcrum.security.torque.dynamic;
+/*
+ *  Copyright 2001-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+import java.sql.Connection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.fulcrum.security.GroupManager;
+import org.apache.fulcrum.security.PermissionManager;
+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.model.dynamic.entity.DynamicRole;
+import org.apache.fulcrum.security.spi.AbstractRoleManager;
+import org.apache.fulcrum.security.torque.om.TorqueDynamicGroupRolePeer;
+import org.apache.fulcrum.security.torque.om.TorqueDynamicRolePermissionPeer;
+import org.apache.fulcrum.security.torque.om.TorqueGroup;
+import org.apache.fulcrum.security.torque.om.TorqueGroupPeer;
+import org.apache.fulcrum.security.torque.om.TorquePermission;
+import org.apache.fulcrum.security.torque.om.TorquePermissionPeer;
+import org.apache.fulcrum.security.torque.om.TorqueRole;
+import org.apache.fulcrum.security.torque.om.TorqueRolePeer;
+import org.apache.fulcrum.security.util.DataBackendException;
+import org.apache.fulcrum.security.util.EntityExistsException;
+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;
+import org.apache.torque.NoRowsException;
+import org.apache.torque.TorqueException;
+import org.apache.torque.om.SimpleKey;
+import org.apache.torque.util.Criteria;
+import org.apache.torque.util.Transaction;
+/**
+ * This implementation persists to a database via Torque.
+ *
+ * @author <a href="mailto:tv@apache.org">Thomas Vandahl</a>
+ * @version $Id:$
+ */
+public class TorqueDynamicRoleManagerImpl extends AbstractRoleManager
+{
+    /**
+    * Renames an existing Role.
+    *
+    * @param role The object describing the role to be renamed.
+    * @param name the new name for the role.
+    * @throws DataBackendException if there was an error accessing the data
+    *         backend.
+    * @throws UnknownEntityException if the role does not exist.
+    */
+    public synchronized void renameRole(Role role, String name)
+        throws DataBackendException, UnknownEntityException
+    {
+        if (checkExists(role))
+        {
+            role.setName(name);
+            
+            try
+            {
+                TorqueRole r = new TorqueRole();
+                r.setId((Integer)role.getId());
+                r.setName(name);
+                r.setNew(false);
+                r.save();
+            }
+            catch (Exception e)
+            {
+                throw new DataBackendException("Renaming Role '" + role + "' failed", e);
+            }
+        }
+        else
+        {
+            throw new UnknownEntityException("Unknown Role '" + role + "'");
+        }
+    }
+
+    /**
+      * Determines if the <code>Role</code> exists in the security system.
+      *
+      * @param roleName a <code>Role</code> value
+      * @return true if the role name exists in the system, false otherwise
+      * @throws DataBackendException when more than one Role with
+      *         the same name exists.
+      */
+    public boolean checkExists(String roleName) throws DataBackendException
+    {
+        List roles;
+
+        try
+        {
+            Criteria criteria = new Criteria();
+            criteria.add(TorqueRolePeer.ROLE_NAME, roleName);
+
+            roles = TorqueRolePeer.doSelect(criteria);
+        }
+        catch (TorqueException e)
+        {
+            throw new DataBackendException("Error retrieving role information", e);
+        }
+
+        if (roles.size() > 1)
+        {
+            throw new DataBackendException("Multiple roles with same name '" + roleName + "'");
+        }
+        
+        return (roles.size() == 1);
+    }
+
+    /**
+     * Retrieves all roles defined in the system.
+     *
+     * @return the names of all roles defined in the system.
+     * @throws DataBackendException if there was an error accessing the
+     *         data backend.
+     */
+    public RoleSet getAllRoles() throws DataBackendException
+    {
+        RoleSet roleSet = new RoleSet();
+        Connection con = null;
+
+        try
+        {
+            con = Transaction.begin(TorqueRolePeer.DATABASE_NAME);
+            
+            List roles = TorqueRolePeer.doSelect(new Criteria(), con);
+            
+            for (Iterator i = roles.iterator(); i.hasNext();)
+            {
+                Role role = getRoleInstance();
+                TorqueRole r = (TorqueRole)i.next();
+                role.setId(r.getId());
+                role.setName(r.getName());
+
+                // Add groups if they exist
+                ((DynamicRole)role).setGroups(getGroupsForRole(role, con));
+
+                // Add permissions if they exist
+                ((DynamicRole)role).setPermissions(getPermissionsForRole(role, con));
+
+                roleSet.add(role);
+            }
+
+            Transaction.commit(con);
+        }
+        catch (TorqueException e)
+        {
+            Transaction.safeRollback(con);
+            throw new DataBackendException("Error retrieving role information", e);
+        }
+        catch (UnknownEntityException e)
+        {
+            Transaction.safeRollback(con);
+            throw new DataBackendException("Error creating permission instance", e);
+        }
+        
+        return roleSet;
+    }
+
+    /**
+    * Creates a new role with specified attributes.
+    *
+    * @param role the object describing the role to be created.
+    * @return a new Role object that has id set up properly.
+    * @throws DataBackendException if there was an error accessing the data
+    *         backend.
+    * @throws EntityExistsException if the role already exists.
+    */
+    protected synchronized Role persistNewRole(Role role) throws DataBackendException
+    {
+        try
+        {
+            TorqueRole r = new TorqueRole();
+            r.setName(role.getName());
+            r.save();
+            
+            role.setId(r.getId());
+        }
+        catch (Exception e)
+        {
+            throw new DataBackendException("Adding Role '" + role + "' failed", e);
+        }
+        
+        return role;
+    }
+
+    /**
+    * Removes a Role from the system.
+    *
+    * @param role The object describing the role to be removed.
+    * @throws DataBackendException if there was an error accessing the data
+    *         backend.
+    * @throws UnknownEntityException if the role does not exist.
+    */
+    public synchronized void removeRole(Role role) throws DataBackendException, UnknownEntityException
+    {
+        if (checkExists(role))
+        {
+            try
+            {
+                TorqueRolePeer.doDelete(SimpleKey.keyFor((Integer)role.getId()));
+            }
+            catch (TorqueException e)
+            {
+                throw new DataBackendException("Removing Role '" + role + "' failed", e);
+            }
+        }
+        else
+        {
+            throw new UnknownEntityException("Unknown role '" + role + "'");
+        }
+    }
+
+    /**
+     * Retrieve a Role object with specified id.
+     *
+     * @param id
+     *            the id of the Role.
+     * @return an object representing the Role with specified id.
+     * @throws DataBackendException
+     *             if there was an error accessing the data backend.
+     * @throws UnknownEntityException
+     *             if the role does not exist.
+     */
+    public Role getRoleById(Object id)
+        throws DataBackendException, UnknownEntityException 
+    {
+        Role role = getRoleInstance();
+
+        if (id != null && id instanceof Integer)
+        {
+            Connection con = null;
+
+            try
+            {
+                con = Transaction.begin(TorqueRolePeer.DATABASE_NAME);
+                
+                TorqueRole r = 
+                    TorqueRolePeer.retrieveByPK((Integer)id, con);
+                role.setId(r.getId());
+                role.setName(r.getName());
+                
+                // Add groups if they exist
+                ((DynamicRole)role).setGroups(getGroupsForRole(role, con));
+
+                // Add permissions if they exist
+                ((DynamicRole)role).setPermissions(getPermissionsForRole(role, con));
+
+                Transaction.commit(con);
+            }
+            catch (NoRowsException e)
+            {
+                Transaction.safeRollback(con);
+                throw new UnknownEntityException("Role with id '" + id + "' does not exist.", e);
+            }
+            catch (TorqueException e)
+            {
+                Transaction.safeRollback(con);
+                throw new DataBackendException("Error retrieving role information", e);
+            }
+        }
+        else
+        {
+            throw new UnknownEntityException("Invalid role id '" + role.getId() + "'");
+        }
+
+        return role;
+    }
+
+    /**
+     * Retrieve a Role object with specified name.
+     *
+     * @param name the name of the Role.
+     * @return an object representing the Role with specified name.
+     * @throws DataBackendException if there was an error accessing the
+     *         data backend.
+     * @throws UnknownEntityException if the role does not exist.
+     */
+    public Role getRoleByName(String name)
+        throws DataBackendException, UnknownEntityException
+    {
+        Role role = getRoleInstance();
+        List roles = Collections.EMPTY_LIST;
+        Connection con = null;
+
+        try
+        {
+            con = Transaction.begin(TorqueRolePeer.DATABASE_NAME);
+            
+            Criteria criteria = new Criteria();
+            criteria.add(TorqueRolePeer.ROLE_NAME, name);
+
+            roles = TorqueRolePeer.doSelect(criteria, con);
+
+            if (roles.size() == 1)
+            {
+                TorqueRole r = (TorqueRole) roles.get(0);
+                
+                role.setId(r.getId());
+                role.setName(r.getName());
+                
+                // Add groups if they exist
+                ((DynamicRole)role).setGroups(getGroupsForRole(role, con));
+
+                // Add permissions if they exist
+                ((DynamicRole)role).setPermissions(getPermissionsForRole(role, con));
+            }
+
+            Transaction.commit(con);
+        }
+        catch (TorqueException e)
+        {
+            Transaction.safeRollback(con);
+            throw new DataBackendException("Error retrieving role information", e);
+        }
+
+        if (roles.size() == 0)
+        {
+            throw new UnknownEntityException("Could not find role" + name);
+        }
+
+        if (roles.size() > 1)
+        {
+            throw new DataBackendException("Multiple Roles with same name '" + name + "'");
+        }
+
+        return role;
+    }
+
+    /**
+     * Provides the groups for the given role
+     *  
+     * @param role the role for which the groups should be retrieved  
+     * @param con a database connection
+     */
+    private GroupSet getGroupsForRole(Role role, Connection con)
+        throws TorqueException, DataBackendException
+    {
+        GroupSet groupSet = new GroupSet();
+        
+        Criteria criteria = new Criteria();
+        criteria.addJoin(TorqueDynamicGroupRolePeer.GROUP_ID, TorqueGroupPeer.GROUP_ID);
+        criteria.add(TorqueDynamicGroupRolePeer.ROLE_ID, (Integer)role.getId());
+        
+        List groups = TorqueGroupPeer.doSelect(criteria, con);
+        GroupManager groupManager = getGroupManager();
+        
+        for (Iterator i = groups.iterator(); i.hasNext();)
+        {
+            TorqueGroup g = (TorqueGroup)i.next();
+            Group group = groupManager.getGroupInstance();
+            
+            group.setId(g.getId());
+            group.setName(g.getName());
+            groupSet.add(group);
+        }
+        
+        return groupSet;
+    }
+
+    /**
+     * Provides the permissions for the given role
+     *  
+     * @param role the role for which the permissions should be retrieved  
+     * @param con a database connection
+     */
+    private PermissionSet getPermissionsForRole(Role role, Connection con)
+        throws TorqueException, DataBackendException, UnknownEntityException
+    {
+        PermissionSet permissionSet = new PermissionSet();
+        
+        Criteria criteria = new Criteria();
+        criteria.addJoin(TorqueDynamicRolePermissionPeer.PERMISSION_ID, TorquePermissionPeer.PERMISSION_ID);
+        criteria.add(TorqueDynamicRolePermissionPeer.ROLE_ID, (Integer)role.getId());
+        
+        List permissions = TorquePermissionPeer.doSelect(criteria, con);
+        PermissionManager permissionManager = getPermissionManager();
+        
+        for (Iterator i = permissions.iterator(); i.hasNext();)
+        {
+            TorquePermission p = (TorquePermission)i.next();
+            Permission permission = permissionManager.getPermissionInstance();
+            
+            permission.setId(p.getId());
+            permission.setName(p.getName());
+            permissionSet.add(permission);
+        }
+        
+        return permissionSet;
+    }
+}

Added: jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/dynamic/TorqueDynamicUserManagerImpl.java
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/dynamic/TorqueDynamicUserManagerImpl.java?view=auto&rev=448680
==============================================================================
--- jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/dynamic/TorqueDynamicUserManagerImpl.java (added)
+++ jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/dynamic/TorqueDynamicUserManagerImpl.java Thu Sep 21 13:56:36 2006
@@ -0,0 +1,436 @@
+package org.apache.fulcrum.security.torque.dynamic;
+/*
+ *  Copyright 2001-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+import java.sql.Connection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.fulcrum.security.GroupManager;
+import org.apache.fulcrum.security.entity.Group;
+import org.apache.fulcrum.security.entity.User;
+import org.apache.fulcrum.security.model.dynamic.entity.DynamicUser;
+import org.apache.fulcrum.security.spi.AbstractUserManager;
+import org.apache.fulcrum.security.torque.om.TorqueDynamicUserDelegatesPeer;
+import org.apache.fulcrum.security.torque.om.TorqueDynamicUserGroupPeer;
+import org.apache.fulcrum.security.torque.om.TorqueGroup;
+import org.apache.fulcrum.security.torque.om.TorqueGroupPeer;
+import org.apache.fulcrum.security.torque.om.TorqueUser;
+import org.apache.fulcrum.security.torque.om.TorqueUserPeer;
+import org.apache.fulcrum.security.util.DataBackendException;
+import org.apache.fulcrum.security.util.EntityExistsException;
+import org.apache.fulcrum.security.util.GroupSet;
+import org.apache.fulcrum.security.util.UnknownEntityException;
+import org.apache.fulcrum.security.util.UserSet;
+import org.apache.torque.NoRowsException;
+import org.apache.torque.TorqueException;
+import org.apache.torque.om.SimpleKey;
+import org.apache.torque.util.Criteria;
+import org.apache.torque.util.Transaction;
+/**
+ * This implementation persists to a database via Torque.
+ *
+ * @author <a href="mailto:tv@apache.org">Thomas Vandahl</a>
+ * @version $Id:$
+ */
+public class TorqueDynamicUserManagerImpl extends AbstractUserManager
+{
+    /**
+     * Check whether a specified user's account exists.
+     *
+     * The login name is used for looking up the account.
+     *
+     * @param userName The name of the user to be checked.
+     * @return true if the specified account exists
+     * @throws DataBackendException if there was an error accessing
+     *         the data backend.
+     */
+    public boolean checkExists(String userName) throws DataBackendException
+    {
+        List users;
+
+        try
+        {
+            Criteria criteria = new Criteria();
+            criteria.add(TorqueUserPeer.LOGIN_NAME, userName.toLowerCase());
+
+            users = TorqueUserPeer.doSelect(criteria);
+        }
+        catch (TorqueException e)
+        {
+            throw new DataBackendException("Error retrieving user information", e);
+        }
+
+        if (users.size() > 1)
+        {
+            throw new DataBackendException("Multiple Users with same username '" + userName + "'");
+        }
+        
+        return (users.size() == 1);
+    }
+
+    /**
+     * Retrieve a user from persistent storage using username as the
+     * key.
+     *
+     * @param userName the name of the user.
+     * @return an User object.
+     * @exception UnknownEntityException if the user's account does not
+     *            exist in the database.
+     * @exception DataBackendException if there is a problem accessing the
+     *            storage.
+     */
+    public User getUser(String userName) throws UnknownEntityException, DataBackendException
+    {
+        User user = getUserInstance();
+        List users = Collections.EMPTY_LIST;
+        Connection con = null;
+
+        try
+        {
+            con = Transaction.begin(TorqueUserPeer.DATABASE_NAME);
+            
+            Criteria criteria = new Criteria();
+            criteria.add(TorqueUserPeer.LOGIN_NAME, userName.toLowerCase());
+
+            users = TorqueUserPeer.doSelect(criteria, con);
+
+            if (users.size() == 1)
+            {
+                TorqueUser u = (TorqueUser) users.get(0);
+                
+                user.setId(u.getId());
+                user.setName(u.getName());
+                user.setPassword(u.getPassword());
+                
+                // Add groups if they exist
+                ((DynamicUser)user).setGroups(getGroupsForUser(user, con));
+
+                // Add delegators if they exist
+                ((DynamicUser)user).setDelegators(getDelegatorsForUser(user, con));
+
+                // Add delegatees if they exist
+                ((DynamicUser)user).setDelegatees(getDelegateesForUser(user, con));
+            }
+            
+            Transaction.commit(con);
+        }
+        catch (TorqueException e)
+        {
+            Transaction.safeRollback(con);
+            throw new DataBackendException("Error retrieving user information", e);
+        }
+
+        if (users.size() == 0)
+        {
+            throw new UnknownEntityException("Unknown user '" + userName + "'");
+        }
+
+        if (users.size() > 1)
+        {
+            throw new DataBackendException("Multiple Users with same username '" + userName + "'");
+        }
+
+        return user;
+    }
+
+    /**
+       * Retrieves all users defined in the system.
+       *
+       * @return the names of all users defined in the system.
+       * @throws DataBackendException if there was an error accessing the data
+       *         backend.
+       */
+    public UserSet getAllUsers() throws DataBackendException
+    {
+        UserSet userSet = new UserSet();
+        Connection con = null;
+
+        try
+        {
+            con = Transaction.begin(TorqueUserPeer.DATABASE_NAME);
+            
+            List users = TorqueUserPeer.doSelect(new Criteria(), con);
+
+            for (Iterator i = users.iterator(); i.hasNext();)
+            {
+                User user = getUserInstance();
+                TorqueUser u = (TorqueUser)i.next();
+                user.setId(u.getId());
+                user.setName(u.getName());
+                user.setPassword(u.getPassword());
+
+                // Add groups if they exist
+                ((DynamicUser)user).setGroups(getGroupsForUser(user, con));
+
+                // Add delegators if they exist
+                ((DynamicUser)user).setDelegators(getDelegatorsForUser(user, con));
+
+                // Add delegatees if they exist
+                ((DynamicUser)user).setDelegatees(getDelegateesForUser(user, con));
+                
+                userSet.add(user);
+            }
+
+            Transaction.commit(con);
+        }
+        catch (TorqueException e)
+        {
+            Transaction.safeRollback(con);
+            throw new DataBackendException("Error retrieving all users", e);
+        }
+        
+        return userSet;
+    }
+
+    /**
+    * 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 the data
+    *         backend.
+    * @throws UnknownEntityException if the user account is not present.
+    */
+    public synchronized void removeUser(User user) throws DataBackendException, UnknownEntityException
+    {
+        try
+        {
+            TorqueUserPeer.doDelete(SimpleKey.keyFor((Integer)user.getId()));
+        }
+        catch (TorqueException e)
+        {
+            throw new DataBackendException("Removing User '" + user + "' failed", e);
+        }
+    }
+
+    /**
+       * Creates new user account with specified attributes.
+       *
+       * @param user the object describing account to be created.
+       * @param password The password to use for the account.
+       *
+       * @throws DataBackendException if there was an error accessing the
+       *         data backend.
+       * @throws EntityExistsException if the user account already exists.
+       */
+    protected synchronized User persistNewUser(User user) throws DataBackendException
+    {
+        try
+        {
+            TorqueUser u = new TorqueUser();
+            
+            u.setName(user.getName());
+            u.setPassword(user.getPassword());
+            u.save();
+
+            user.setId(u.getId());
+        }
+        catch (Exception e)
+        {
+            throw new DataBackendException("Adding User '" + user + "' failed", e);
+        }
+        
+        return user;
+    }
+
+    /**
+       * Stores User attributes. The User is required to exist in the system.
+       *
+       * @param role The User to be stored.
+       * @throws DataBackendException if there was an error accessing the data
+       *         backend.
+       * @throws UnknownEntityException if the role does not exist.
+       */
+    public synchronized void saveUser(User user) throws DataBackendException, UnknownEntityException
+    {
+        if (checkExists(user))
+        {
+            try
+            {
+                TorqueUser u = new TorqueUser();
+                
+                u.setId((Integer)user.getId());
+                u.setName(user.getName());
+                u.setPassword(user.getPassword());
+                u.setNew(false);
+                u.save();
+            }
+            catch (Exception e)
+            {
+                throw new DataBackendException("Saving User '" + user + "' failed", e);
+            }
+        }
+        else
+        {
+            throw new UnknownEntityException("Unknown user '" + user + "'");
+        }
+    }
+
+    /**
+     * Retrieve a User object with specified id.
+     *
+     * @param id
+     *            the id of the User.
+     * @return an object representing the User with specified id.
+     * @throws DataBackendException
+     *             if there was an error accessing the data backend.
+     * @throws UnknownEntityException
+     *             if the user does not exist.
+     */
+    public User getUserById(Object id)
+        throws DataBackendException, UnknownEntityException
+    {
+        User user = getUserInstance();
+
+        if (id != null && id instanceof Integer)
+        {
+            Connection con = null;
+            
+            try
+            {
+                con = Transaction.begin(TorqueUserPeer.DATABASE_NAME);
+                
+                TorqueUser u = TorqueUserPeer.retrieveByPK((Integer)id, con);
+
+                user.setId(u.getId());
+                user.setName(u.getName());
+                user.setPassword(u.getPassword());
+
+                // Add groups if they exist
+                ((DynamicUser)user).setGroups(getGroupsForUser(user, con));
+
+                // Add delegators if they exist
+                ((DynamicUser)user).setDelegators(getDelegatorsForUser(user, con));
+
+                // Add delegatees if they exist
+                ((DynamicUser)user).setDelegatees(getDelegateesForUser(user, con));
+                
+                Transaction.commit(con);
+            }
+            catch (NoRowsException e)
+            {
+                Transaction.safeRollback(con);
+                throw new UnknownEntityException("User with id '" + id + "' does not exist.", e);
+            }
+            catch (TorqueException e)
+            {
+                Transaction.safeRollback(con);
+                throw new DataBackendException("Error retrieving user information", e);
+            }
+        }
+        else
+        {
+            throw new UnknownEntityException("Invalid user id '" + user.getId() + "'");
+        }
+
+        return user;
+    }
+    
+    /**
+     * Provides the groups for the given user
+     *  
+     * @param user the user for which the groups should be retrieved  
+     * @param con a database connection
+     */
+    private GroupSet getGroupsForUser(User user, Connection con)
+        throws TorqueException, DataBackendException
+    {
+        GroupSet groupSet = new GroupSet();
+        
+        Criteria criteria = new Criteria();
+        criteria.addJoin(TorqueDynamicUserGroupPeer.GROUP_ID, TorqueGroupPeer.GROUP_ID);
+        criteria.add(TorqueDynamicUserGroupPeer.USER_ID, (Integer)user.getId());
+        
+        List groups = TorqueGroupPeer.doSelect(criteria, con);
+        GroupManager groupManager = getGroupManager();
+        
+        for (Iterator i = groups.iterator(); i.hasNext();)
+        {
+            TorqueGroup g = (TorqueGroup)i.next();
+            Group group = groupManager.getGroupInstance();
+            
+            group.setId(g.getId());
+            group.setName(g.getName());
+            groupSet.add(group);
+        }
+        
+        return groupSet;
+    }
+
+    /**
+     * Provides the delegators for the given user
+     *  
+     * @param user the user for which the delegators should be retrieved  
+     * @param con a database connection
+     */
+    private Set getDelegatorsForUser(User user, Connection con)
+        throws TorqueException, DataBackendException
+    {
+        Set delegatorsSet = new HashSet();
+        
+        Criteria criteria = new Criteria();
+        criteria.addJoin(TorqueDynamicUserDelegatesPeer.DELEGATOR_USER_ID, TorqueUserPeer.USER_ID);
+        criteria.add(TorqueDynamicUserDelegatesPeer.DELEGATEE_USER_ID, (Integer)user.getId());
+        
+        List users = TorqueUserPeer.doSelect(criteria, con);
+        
+        for (Iterator i = users.iterator(); i.hasNext();)
+        {
+            TorqueUser u = (TorqueUser)i.next();
+            User delegator = getUserInstance();
+            
+            delegator.setId(u.getId());
+            delegator.setName(u.getName());
+            delegator.setPassword(u.getPassword());
+            delegatorsSet.add(delegator);
+        }
+        
+        return delegatorsSet;
+    }
+
+    /**
+     * Provides the delegatees for the given user
+     *  
+     * @param user the user for which the delegatees should be retrieved  
+     * @param con a database connection
+     */
+    private Set getDelegateesForUser(User user, Connection con)
+        throws TorqueException, DataBackendException
+    {
+        Set delegateesSet = new HashSet();
+        
+        Criteria criteria = new Criteria();
+        criteria.addJoin(TorqueDynamicUserDelegatesPeer.DELEGATEE_USER_ID, TorqueUserPeer.USER_ID);
+        criteria.add(TorqueDynamicUserDelegatesPeer.DELEGATOR_USER_ID, (Integer)user.getId());
+        
+        List users = TorqueUserPeer.doSelect(criteria, con);
+        
+        for (Iterator i = users.iterator(); i.hasNext();)
+        {
+            TorqueUser u = (TorqueUser)i.next();
+            User delegatee = getUserInstance();
+            
+            delegatee.setId(u.getId());
+            delegatee.setName(u.getName());
+            delegatee.setPassword(u.getPassword());
+            delegateesSet.add(delegatee);
+        }
+        
+        return delegateesSet;
+    }
+}

Added: jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/om/map/TorqueBasicUserGroupMapBuilder.java
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/om/map/TorqueBasicUserGroupMapBuilder.java?view=auto&rev=448680
==============================================================================
--- jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/om/map/TorqueBasicUserGroupMapBuilder.java (added)
+++ jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/om/map/TorqueBasicUserGroupMapBuilder.java Thu Sep 21 13:56:36 2006
@@ -0,0 +1,74 @@
+package org.apache.fulcrum.security.torque.om.map;
+
+import java.util.Date;
+import java.math.BigDecimal;
+
+import org.apache.torque.Torque;
+import org.apache.torque.TorqueException;
+import org.apache.torque.map.MapBuilder;
+import org.apache.torque.map.DatabaseMap;
+import org.apache.torque.map.TableMap;
+
+/**
+  *  This class was autogenerated by Torque on:
+  *
+  * [Sun Aug 27 22:32:46 CEST 2006]
+  *
+  */
+public class TorqueBasicUserGroupMapBuilder implements MapBuilder
+{
+    /**
+     * The name of this class
+     */
+    public static final String CLASS_NAME =
+        "org.apache.fulcrum.security.torque.om.map.TorqueBasicUserGroupMapBuilder";
+
+    /**
+     * The database map.
+     */
+    private DatabaseMap dbMap = null;
+
+    /**
+     * Tells us if this DatabaseMapBuilder is built so that we
+     * don't have to re-build it every time.
+     *
+     * @return true if this DatabaseMapBuilder is built
+     */
+    public boolean isBuilt()
+    {
+        return (dbMap != null);
+    }
+
+    /**
+     * Gets the databasemap this map builder built.
+     *
+     * @return the databasemap
+     */
+    public DatabaseMap getDatabaseMap()
+    {
+        return this.dbMap;
+    }
+
+    /**
+     * The doBuild() method builds the DatabaseMap
+     *
+     * @throws TorqueException
+     */
+    public void doBuild() throws TorqueException
+    {
+        dbMap = Torque.getDatabaseMap("fulcrum");
+
+        dbMap.addTable("BASIC_USER_GROUP");
+        TableMap tMap = dbMap.getTable("BASIC_USER_GROUP");
+
+        tMap.setPrimaryKeyMethod("none");
+
+
+              tMap.addForeignPrimaryKey(
+                "BASIC_USER_GROUP.USER_ID", new Integer(0) , "FULCRUM_USER" ,
+                "USER_ID");
+                    tMap.addForeignPrimaryKey(
+                "BASIC_USER_GROUP.GROUP_ID", new Integer(0) , "FULCRUM_GROUP" ,
+                "GROUP_ID");
+          }
+}

Added: jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/om/map/TorqueDynamicGroupRoleMapBuilder.java
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/om/map/TorqueDynamicGroupRoleMapBuilder.java?view=auto&rev=448680
==============================================================================
--- jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/om/map/TorqueDynamicGroupRoleMapBuilder.java (added)
+++ jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/om/map/TorqueDynamicGroupRoleMapBuilder.java Thu Sep 21 13:56:36 2006
@@ -0,0 +1,74 @@
+package org.apache.fulcrum.security.torque.om.map;
+
+import java.util.Date;
+import java.math.BigDecimal;
+
+import org.apache.torque.Torque;
+import org.apache.torque.TorqueException;
+import org.apache.torque.map.MapBuilder;
+import org.apache.torque.map.DatabaseMap;
+import org.apache.torque.map.TableMap;
+
+/**
+  *  This class was autogenerated by Torque on:
+  *
+  * [Sun Aug 27 22:32:46 CEST 2006]
+  *
+  */
+public class TorqueDynamicGroupRoleMapBuilder implements MapBuilder
+{
+    /**
+     * The name of this class
+     */
+    public static final String CLASS_NAME =
+        "org.apache.fulcrum.security.torque.om.map.TorqueDynamicGroupRoleMapBuilder";
+
+    /**
+     * The database map.
+     */
+    private DatabaseMap dbMap = null;
+
+    /**
+     * Tells us if this DatabaseMapBuilder is built so that we
+     * don't have to re-build it every time.
+     *
+     * @return true if this DatabaseMapBuilder is built
+     */
+    public boolean isBuilt()
+    {
+        return (dbMap != null);
+    }
+
+    /**
+     * Gets the databasemap this map builder built.
+     *
+     * @return the databasemap
+     */
+    public DatabaseMap getDatabaseMap()
+    {
+        return this.dbMap;
+    }
+
+    /**
+     * The doBuild() method builds the DatabaseMap
+     *
+     * @throws TorqueException
+     */
+    public void doBuild() throws TorqueException
+    {
+        dbMap = Torque.getDatabaseMap("fulcrum");
+
+        dbMap.addTable("DYNAMIC_GROUP_ROLE");
+        TableMap tMap = dbMap.getTable("DYNAMIC_GROUP_ROLE");
+
+        tMap.setPrimaryKeyMethod("none");
+
+
+              tMap.addForeignPrimaryKey(
+                "DYNAMIC_GROUP_ROLE.GROUP_ID", new Integer(0) , "FULCRUM_GROUP" ,
+                "GROUP_ID");
+                    tMap.addForeignPrimaryKey(
+                "DYNAMIC_GROUP_ROLE.ROLE_ID", new Integer(0) , "FULCRUM_ROLE" ,
+                "ROLE_ID");
+          }
+}

Added: jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/om/map/TorqueDynamicRolePermissionMapBuilder.java
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/om/map/TorqueDynamicRolePermissionMapBuilder.java?view=auto&rev=448680
==============================================================================
--- jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/om/map/TorqueDynamicRolePermissionMapBuilder.java (added)
+++ jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/om/map/TorqueDynamicRolePermissionMapBuilder.java Thu Sep 21 13:56:36 2006
@@ -0,0 +1,74 @@
+package org.apache.fulcrum.security.torque.om.map;
+
+import java.util.Date;
+import java.math.BigDecimal;
+
+import org.apache.torque.Torque;
+import org.apache.torque.TorqueException;
+import org.apache.torque.map.MapBuilder;
+import org.apache.torque.map.DatabaseMap;
+import org.apache.torque.map.TableMap;
+
+/**
+  *  This class was autogenerated by Torque on:
+  *
+  * [Sun Aug 27 22:32:46 CEST 2006]
+  *
+  */
+public class TorqueDynamicRolePermissionMapBuilder implements MapBuilder
+{
+    /**
+     * The name of this class
+     */
+    public static final String CLASS_NAME =
+        "org.apache.fulcrum.security.torque.om.map.TorqueDynamicRolePermissionMapBuilder";
+
+    /**
+     * The database map.
+     */
+    private DatabaseMap dbMap = null;
+
+    /**
+     * Tells us if this DatabaseMapBuilder is built so that we
+     * don't have to re-build it every time.
+     *
+     * @return true if this DatabaseMapBuilder is built
+     */
+    public boolean isBuilt()
+    {
+        return (dbMap != null);
+    }
+
+    /**
+     * Gets the databasemap this map builder built.
+     *
+     * @return the databasemap
+     */
+    public DatabaseMap getDatabaseMap()
+    {
+        return this.dbMap;
+    }
+
+    /**
+     * The doBuild() method builds the DatabaseMap
+     *
+     * @throws TorqueException
+     */
+    public void doBuild() throws TorqueException
+    {
+        dbMap = Torque.getDatabaseMap("fulcrum");
+
+        dbMap.addTable("DYNAMIC_ROLE_PERMISSION");
+        TableMap tMap = dbMap.getTable("DYNAMIC_ROLE_PERMISSION");
+
+        tMap.setPrimaryKeyMethod("none");
+
+
+              tMap.addForeignPrimaryKey(
+                "DYNAMIC_ROLE_PERMISSION.ROLE_ID", new Integer(0) , "FULCRUM_ROLE" ,
+                "ROLE_ID");
+                    tMap.addForeignPrimaryKey(
+                "DYNAMIC_ROLE_PERMISSION.PERMISSION_ID", new Integer(0) , "FULCRUM_PERMISSION" ,
+                "PERMISSION_ID");
+          }
+}

Added: jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/om/map/TorqueDynamicUserDelegatesMapBuilder.java
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/om/map/TorqueDynamicUserDelegatesMapBuilder.java?view=auto&rev=448680
==============================================================================
--- jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/om/map/TorqueDynamicUserDelegatesMapBuilder.java (added)
+++ jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/om/map/TorqueDynamicUserDelegatesMapBuilder.java Thu Sep 21 13:56:36 2006
@@ -0,0 +1,74 @@
+package org.apache.fulcrum.security.torque.om.map;
+
+import java.util.Date;
+import java.math.BigDecimal;
+
+import org.apache.torque.Torque;
+import org.apache.torque.TorqueException;
+import org.apache.torque.map.MapBuilder;
+import org.apache.torque.map.DatabaseMap;
+import org.apache.torque.map.TableMap;
+
+/**
+  *  This class was autogenerated by Torque on:
+  *
+  * [Sun Aug 27 22:32:46 CEST 2006]
+  *
+  */
+public class TorqueDynamicUserDelegatesMapBuilder implements MapBuilder
+{
+    /**
+     * The name of this class
+     */
+    public static final String CLASS_NAME =
+        "org.apache.fulcrum.security.torque.om.map.TorqueDynamicUserDelegatesMapBuilder";
+
+    /**
+     * The database map.
+     */
+    private DatabaseMap dbMap = null;
+
+    /**
+     * Tells us if this DatabaseMapBuilder is built so that we
+     * don't have to re-build it every time.
+     *
+     * @return true if this DatabaseMapBuilder is built
+     */
+    public boolean isBuilt()
+    {
+        return (dbMap != null);
+    }
+
+    /**
+     * Gets the databasemap this map builder built.
+     *
+     * @return the databasemap
+     */
+    public DatabaseMap getDatabaseMap()
+    {
+        return this.dbMap;
+    }
+
+    /**
+     * The doBuild() method builds the DatabaseMap
+     *
+     * @throws TorqueException
+     */
+    public void doBuild() throws TorqueException
+    {
+        dbMap = Torque.getDatabaseMap("fulcrum");
+
+        dbMap.addTable("DYNAMIC_USER_DELEGATES");
+        TableMap tMap = dbMap.getTable("DYNAMIC_USER_DELEGATES");
+
+        tMap.setPrimaryKeyMethod("none");
+
+
+              tMap.addForeignPrimaryKey(
+                "DYNAMIC_USER_DELEGATES.DELEGATOR_USER_ID", new Integer(0) , "FULCRUM_USER" ,
+                "USER_ID");
+                    tMap.addForeignPrimaryKey(
+                "DYNAMIC_USER_DELEGATES.DELEGATEE_USER_ID", new Integer(0) , "FULCRUM_USER" ,
+                "USER_ID");
+          }
+}

Added: jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/om/map/TorqueDynamicUserGroupMapBuilder.java
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/om/map/TorqueDynamicUserGroupMapBuilder.java?view=auto&rev=448680
==============================================================================
--- jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/om/map/TorqueDynamicUserGroupMapBuilder.java (added)
+++ jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/om/map/TorqueDynamicUserGroupMapBuilder.java Thu Sep 21 13:56:36 2006
@@ -0,0 +1,74 @@
+package org.apache.fulcrum.security.torque.om.map;
+
+import java.util.Date;
+import java.math.BigDecimal;
+
+import org.apache.torque.Torque;
+import org.apache.torque.TorqueException;
+import org.apache.torque.map.MapBuilder;
+import org.apache.torque.map.DatabaseMap;
+import org.apache.torque.map.TableMap;
+
+/**
+  *  This class was autogenerated by Torque on:
+  *
+  * [Sun Aug 27 22:32:46 CEST 2006]
+  *
+  */
+public class TorqueDynamicUserGroupMapBuilder implements MapBuilder
+{
+    /**
+     * The name of this class
+     */
+    public static final String CLASS_NAME =
+        "org.apache.fulcrum.security.torque.om.map.TorqueDynamicUserGroupMapBuilder";
+
+    /**
+     * The database map.
+     */
+    private DatabaseMap dbMap = null;
+
+    /**
+     * Tells us if this DatabaseMapBuilder is built so that we
+     * don't have to re-build it every time.
+     *
+     * @return true if this DatabaseMapBuilder is built
+     */
+    public boolean isBuilt()
+    {
+        return (dbMap != null);
+    }
+
+    /**
+     * Gets the databasemap this map builder built.
+     *
+     * @return the databasemap
+     */
+    public DatabaseMap getDatabaseMap()
+    {
+        return this.dbMap;
+    }
+
+    /**
+     * The doBuild() method builds the DatabaseMap
+     *
+     * @throws TorqueException
+     */
+    public void doBuild() throws TorqueException
+    {
+        dbMap = Torque.getDatabaseMap("fulcrum");
+
+        dbMap.addTable("DYNAMIC_USER_GROUP");
+        TableMap tMap = dbMap.getTable("DYNAMIC_USER_GROUP");
+
+        tMap.setPrimaryKeyMethod("none");
+
+
+              tMap.addForeignPrimaryKey(
+                "DYNAMIC_USER_GROUP.USER_ID", new Integer(0) , "FULCRUM_USER" ,
+                "USER_ID");
+                    tMap.addForeignPrimaryKey(
+                "DYNAMIC_USER_GROUP.GROUP_ID", new Integer(0) , "FULCRUM_GROUP" ,
+                "GROUP_ID");
+          }
+}

Added: jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/om/map/TorqueGroupMapBuilder.java
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/om/map/TorqueGroupMapBuilder.java?view=auto&rev=448680
==============================================================================
--- jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/om/map/TorqueGroupMapBuilder.java (added)
+++ jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/om/map/TorqueGroupMapBuilder.java Thu Sep 21 13:56:36 2006
@@ -0,0 +1,71 @@
+package org.apache.fulcrum.security.torque.om.map;
+
+import java.util.Date;
+import java.math.BigDecimal;
+
+import org.apache.torque.Torque;
+import org.apache.torque.TorqueException;
+import org.apache.torque.map.MapBuilder;
+import org.apache.torque.map.DatabaseMap;
+import org.apache.torque.map.TableMap;
+
+/**
+  *  This class was autogenerated by Torque on:
+  *
+  * [Sun Aug 27 22:32:46 CEST 2006]
+  *
+  */
+public class TorqueGroupMapBuilder implements MapBuilder
+{
+    /**
+     * The name of this class
+     */
+    public static final String CLASS_NAME =
+        "org.apache.fulcrum.security.torque.om.map.TorqueGroupMapBuilder";
+
+    /**
+     * The database map.
+     */
+    private DatabaseMap dbMap = null;
+
+    /**
+     * Tells us if this DatabaseMapBuilder is built so that we
+     * don't have to re-build it every time.
+     *
+     * @return true if this DatabaseMapBuilder is built
+     */
+    public boolean isBuilt()
+    {
+        return (dbMap != null);
+    }
+
+    /**
+     * Gets the databasemap this map builder built.
+     *
+     * @return the databasemap
+     */
+    public DatabaseMap getDatabaseMap()
+    {
+        return this.dbMap;
+    }
+
+    /**
+     * The doBuild() method builds the DatabaseMap
+     *
+     * @throws TorqueException
+     */
+    public void doBuild() throws TorqueException
+    {
+        dbMap = Torque.getDatabaseMap("fulcrum");
+
+        dbMap.addTable("FULCRUM_GROUP");
+        TableMap tMap = dbMap.getTable("FULCRUM_GROUP");
+
+        tMap.setPrimaryKeyMethod(TableMap.ID_BROKER);
+
+        tMap.setPrimaryKeyMethodInfo(tMap.getName());
+
+              tMap.addPrimaryKey("FULCRUM_GROUP.GROUP_ID", new Integer(0) );
+                        	          tMap.addColumn("FULCRUM_GROUP.GROUP_NAME", "", 64 );
+                        }
+}

Added: jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/om/map/TorquePermissionMapBuilder.java
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/om/map/TorquePermissionMapBuilder.java?view=auto&rev=448680
==============================================================================
--- jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/om/map/TorquePermissionMapBuilder.java (added)
+++ jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/om/map/TorquePermissionMapBuilder.java Thu Sep 21 13:56:36 2006
@@ -0,0 +1,71 @@
+package org.apache.fulcrum.security.torque.om.map;
+
+import java.util.Date;
+import java.math.BigDecimal;
+
+import org.apache.torque.Torque;
+import org.apache.torque.TorqueException;
+import org.apache.torque.map.MapBuilder;
+import org.apache.torque.map.DatabaseMap;
+import org.apache.torque.map.TableMap;
+
+/**
+  *  This class was autogenerated by Torque on:
+  *
+  * [Sun Aug 27 22:32:46 CEST 2006]
+  *
+  */
+public class TorquePermissionMapBuilder implements MapBuilder
+{
+    /**
+     * The name of this class
+     */
+    public static final String CLASS_NAME =
+        "org.apache.fulcrum.security.torque.om.map.TorquePermissionMapBuilder";
+
+    /**
+     * The database map.
+     */
+    private DatabaseMap dbMap = null;
+
+    /**
+     * Tells us if this DatabaseMapBuilder is built so that we
+     * don't have to re-build it every time.
+     *
+     * @return true if this DatabaseMapBuilder is built
+     */
+    public boolean isBuilt()
+    {
+        return (dbMap != null);
+    }
+
+    /**
+     * Gets the databasemap this map builder built.
+     *
+     * @return the databasemap
+     */
+    public DatabaseMap getDatabaseMap()
+    {
+        return this.dbMap;
+    }
+
+    /**
+     * The doBuild() method builds the DatabaseMap
+     *
+     * @throws TorqueException
+     */
+    public void doBuild() throws TorqueException
+    {
+        dbMap = Torque.getDatabaseMap("fulcrum");
+
+        dbMap.addTable("FULCRUM_PERMISSION");
+        TableMap tMap = dbMap.getTable("FULCRUM_PERMISSION");
+
+        tMap.setPrimaryKeyMethod(TableMap.ID_BROKER);
+
+        tMap.setPrimaryKeyMethodInfo(tMap.getName());
+
+              tMap.addPrimaryKey("FULCRUM_PERMISSION.PERMISSION_ID", new Integer(0) );
+                        	          tMap.addColumn("FULCRUM_PERMISSION.PERMISSION_NAME", "", 64 );
+                        }
+}

Added: jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/om/map/TorqueRoleMapBuilder.java
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/om/map/TorqueRoleMapBuilder.java?view=auto&rev=448680
==============================================================================
--- jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/om/map/TorqueRoleMapBuilder.java (added)
+++ jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/om/map/TorqueRoleMapBuilder.java Thu Sep 21 13:56:36 2006
@@ -0,0 +1,71 @@
+package org.apache.fulcrum.security.torque.om.map;
+
+import java.util.Date;
+import java.math.BigDecimal;
+
+import org.apache.torque.Torque;
+import org.apache.torque.TorqueException;
+import org.apache.torque.map.MapBuilder;
+import org.apache.torque.map.DatabaseMap;
+import org.apache.torque.map.TableMap;
+
+/**
+  *  This class was autogenerated by Torque on:
+  *
+  * [Sun Aug 27 22:32:46 CEST 2006]
+  *
+  */
+public class TorqueRoleMapBuilder implements MapBuilder
+{
+    /**
+     * The name of this class
+     */
+    public static final String CLASS_NAME =
+        "org.apache.fulcrum.security.torque.om.map.TorqueRoleMapBuilder";
+
+    /**
+     * The database map.
+     */
+    private DatabaseMap dbMap = null;
+
+    /**
+     * Tells us if this DatabaseMapBuilder is built so that we
+     * don't have to re-build it every time.
+     *
+     * @return true if this DatabaseMapBuilder is built
+     */
+    public boolean isBuilt()
+    {
+        return (dbMap != null);
+    }
+
+    /**
+     * Gets the databasemap this map builder built.
+     *
+     * @return the databasemap
+     */
+    public DatabaseMap getDatabaseMap()
+    {
+        return this.dbMap;
+    }
+
+    /**
+     * The doBuild() method builds the DatabaseMap
+     *
+     * @throws TorqueException
+     */
+    public void doBuild() throws TorqueException
+    {
+        dbMap = Torque.getDatabaseMap("fulcrum");
+
+        dbMap.addTable("FULCRUM_ROLE");
+        TableMap tMap = dbMap.getTable("FULCRUM_ROLE");
+
+        tMap.setPrimaryKeyMethod(TableMap.ID_BROKER);
+
+        tMap.setPrimaryKeyMethodInfo(tMap.getName());
+
+              tMap.addPrimaryKey("FULCRUM_ROLE.ROLE_ID", new Integer(0) );
+                        	          tMap.addColumn("FULCRUM_ROLE.ROLE_NAME", "", 64 );
+                        }
+}

Added: jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/om/map/TorqueTurbineRolePermissionMapBuilder.java
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/om/map/TorqueTurbineRolePermissionMapBuilder.java?view=auto&rev=448680
==============================================================================
--- jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/om/map/TorqueTurbineRolePermissionMapBuilder.java (added)
+++ jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/om/map/TorqueTurbineRolePermissionMapBuilder.java Thu Sep 21 13:56:36 2006
@@ -0,0 +1,74 @@
+package org.apache.fulcrum.security.torque.om.map;
+
+import java.util.Date;
+import java.math.BigDecimal;
+
+import org.apache.torque.Torque;
+import org.apache.torque.TorqueException;
+import org.apache.torque.map.MapBuilder;
+import org.apache.torque.map.DatabaseMap;
+import org.apache.torque.map.TableMap;
+
+/**
+  *  This class was autogenerated by Torque on:
+  *
+  * [Sun Aug 27 22:32:46 CEST 2006]
+  *
+  */
+public class TorqueTurbineRolePermissionMapBuilder implements MapBuilder
+{
+    /**
+     * The name of this class
+     */
+    public static final String CLASS_NAME =
+        "org.apache.fulcrum.security.torque.om.map.TorqueTurbineRolePermissionMapBuilder";
+
+    /**
+     * The database map.
+     */
+    private DatabaseMap dbMap = null;
+
+    /**
+     * Tells us if this DatabaseMapBuilder is built so that we
+     * don't have to re-build it every time.
+     *
+     * @return true if this DatabaseMapBuilder is built
+     */
+    public boolean isBuilt()
+    {
+        return (dbMap != null);
+    }
+
+    /**
+     * Gets the databasemap this map builder built.
+     *
+     * @return the databasemap
+     */
+    public DatabaseMap getDatabaseMap()
+    {
+        return this.dbMap;
+    }
+
+    /**
+     * The doBuild() method builds the DatabaseMap
+     *
+     * @throws TorqueException
+     */
+    public void doBuild() throws TorqueException
+    {
+        dbMap = Torque.getDatabaseMap("fulcrum");
+
+        dbMap.addTable("TURBINE_ROLE_PERMISSION");
+        TableMap tMap = dbMap.getTable("TURBINE_ROLE_PERMISSION");
+
+        tMap.setPrimaryKeyMethod("none");
+
+
+              tMap.addForeignPrimaryKey(
+                "TURBINE_ROLE_PERMISSION.ROLE_ID", new Integer(0) , "FULCRUM_ROLE" ,
+                "ROLE_ID");
+                    tMap.addForeignPrimaryKey(
+                "TURBINE_ROLE_PERMISSION.PERMISSION_ID", new Integer(0) , "FULCRUM_PERMISSION" ,
+                "PERMISSION_ID");
+          }
+}

Added: jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/om/map/TorqueTurbineUserGroupRoleMapBuilder.java
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/om/map/TorqueTurbineUserGroupRoleMapBuilder.java?view=auto&rev=448680
==============================================================================
--- jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/om/map/TorqueTurbineUserGroupRoleMapBuilder.java (added)
+++ jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/om/map/TorqueTurbineUserGroupRoleMapBuilder.java Thu Sep 21 13:56:36 2006
@@ -0,0 +1,77 @@
+package org.apache.fulcrum.security.torque.om.map;
+
+import java.util.Date;
+import java.math.BigDecimal;
+
+import org.apache.torque.Torque;
+import org.apache.torque.TorqueException;
+import org.apache.torque.map.MapBuilder;
+import org.apache.torque.map.DatabaseMap;
+import org.apache.torque.map.TableMap;
+
+/**
+  *  This class was autogenerated by Torque on:
+  *
+  * [Sun Aug 27 22:32:46 CEST 2006]
+  *
+  */
+public class TorqueTurbineUserGroupRoleMapBuilder implements MapBuilder
+{
+    /**
+     * The name of this class
+     */
+    public static final String CLASS_NAME =
+        "org.apache.fulcrum.security.torque.om.map.TorqueTurbineUserGroupRoleMapBuilder";
+
+    /**
+     * The database map.
+     */
+    private DatabaseMap dbMap = null;
+
+    /**
+     * Tells us if this DatabaseMapBuilder is built so that we
+     * don't have to re-build it every time.
+     *
+     * @return true if this DatabaseMapBuilder is built
+     */
+    public boolean isBuilt()
+    {
+        return (dbMap != null);
+    }
+
+    /**
+     * Gets the databasemap this map builder built.
+     *
+     * @return the databasemap
+     */
+    public DatabaseMap getDatabaseMap()
+    {
+        return this.dbMap;
+    }
+
+    /**
+     * The doBuild() method builds the DatabaseMap
+     *
+     * @throws TorqueException
+     */
+    public void doBuild() throws TorqueException
+    {
+        dbMap = Torque.getDatabaseMap("fulcrum");
+
+        dbMap.addTable("TURBINE_USER_GROUP_ROLE");
+        TableMap tMap = dbMap.getTable("TURBINE_USER_GROUP_ROLE");
+
+        tMap.setPrimaryKeyMethod("none");
+
+
+              tMap.addForeignPrimaryKey(
+                "TURBINE_USER_GROUP_ROLE.USER_ID", new Integer(0) , "FULCRUM_USER" ,
+                "USER_ID");
+                    tMap.addForeignPrimaryKey(
+                "TURBINE_USER_GROUP_ROLE.GROUP_ID", new Integer(0) , "FULCRUM_GROUP" ,
+                "GROUP_ID");
+                    tMap.addForeignPrimaryKey(
+                "TURBINE_USER_GROUP_ROLE.ROLE_ID", new Integer(0) , "FULCRUM_ROLE" ,
+                "ROLE_ID");
+          }
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org