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 2007/05/05 08:58:51 UTC

svn commit: r535465 [30/49] - in /jakarta/turbine/fulcrum/trunk: ./ bsf/ bsf/src/java/org/apache/fulcrum/bsf/ bsf/src/test/ bsf/xdocs/ cache/ cache/src/java/org/apache/fulcrum/cache/ cache/src/java/org/apache/fulcrum/cache/impl/ cache/src/test/ cache/s...

Modified: jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/basic/TorqueAbstractBasicGroup.java
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/basic/TorqueAbstractBasicGroup.java?view=diff&rev=535465&r1=535464&r2=535465
==============================================================================
--- jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/basic/TorqueAbstractBasicGroup.java (original)
+++ jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/basic/TorqueAbstractBasicGroup.java Fri May  4 23:58:06 2007
@@ -1,193 +1,196 @@
-package org.apache.fulcrum.security.torque.basic;
-/*
- *  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.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import org.apache.fulcrum.security.entity.User;
-import org.apache.fulcrum.security.model.basic.entity.BasicGroup;
-import org.apache.fulcrum.security.torque.TorqueAbstractSecurityEntity;
-import org.apache.fulcrum.security.torque.om.TorqueBasicGroupPeer;
-import org.apache.fulcrum.security.torque.om.TorqueBasicUser;
-import org.apache.fulcrum.security.torque.om.TorqueBasicUserGroup;
-import org.apache.fulcrum.security.torque.om.TorqueBasicUserGroupPeer;
-import org.apache.fulcrum.security.util.UserSet;
-import org.apache.torque.TorqueException;
-import org.apache.torque.om.SimpleKey;
-import org.apache.torque.util.Criteria;
-/**
- * This abstract class provides the SecurityInterface to the managers.
- *
- * @author <a href="mailto:tv@apache.org">Thomas Vandahl</a>
- * @version $Id:$
- */
-public abstract class TorqueAbstractBasicGroup extends TorqueAbstractSecurityEntity
-    implements BasicGroup
-{
-    /** a cache of user objects */
-    private Set userSet = null;
-    
-    /**
-     * Forward reference to generated code
-     * 
-     * Get a list of association objects, pre-populated with their TorqueBasicUser 
-     * objects.
-     * 
-     * @param criteria Criteria to define the selection of records
-     * @throws TorqueException
-     * 
-     * @return a list of User/Group relations
-     */
-    protected abstract List getTorqueBasicUserGroupsJoinTorqueBasicUser(Criteria criteria) 
-        throws TorqueException;
-
-    /**
-     * @see org.apache.fulcrum.security.model.basic.entity.BasicGroup#addUser(org.apache.fulcrum.security.entity.User)
-     */
-    public void addUser(User user)
-    {
-        getUsers().add(user);
-    }
-
-    /**
-     * @see org.apache.fulcrum.security.model.basic.entity.BasicGroup#getUsers()
-     */
-    public UserSet getUsers()
-    {
-        if (userSet == null)
-        {
-            userSet = new UserSet();
-        }
-        else if(!(userSet instanceof UserSet))
-        {
-            userSet = new UserSet(userSet);
-        }
-
-        return (UserSet)userSet;
-    }
-
-    /**
-     * @see org.apache.fulcrum.security.model.basic.entity.BasicGroup#getUsersAsSet()
-     */
-    public Set getUsersAsSet()
-    {
-        return userSet;
-    }
-
-    /**
-     * @see org.apache.fulcrum.security.model.basic.entity.BasicGroup#removeUser(org.apache.fulcrum.security.entity.User)
-     */
-    public void removeUser(User user)
-    {
-        getUsers().remove(user);
-    }
-
-    /**
-     * @see org.apache.fulcrum.security.model.basic.entity.BasicGroup#setUsers(org.apache.fulcrum.security.util.UserSet)
-     */
-    public void setUsers(UserSet userSet)
-    {
-        if(userSet != null)
-        {
-            this.userSet = userSet;
-        }
-        else
-        {
-            this.userSet = new UserSet();
-        }
-    }
-
-    /**
-     * @see org.apache.fulcrum.security.model.basic.entity.BasicGroup#setUsersAsSet(java.util.Set)
-     */
-    public void setUsersAsSet(Set users)
-    {
-        setUsers(new UserSet(users));
-    }
-    
-    /**
-     * Retrieve attached objects such as users, permissions,....
-     */
-    public void retrieveAttachedObjects(Connection con) throws TorqueException
-    {
-        this.userSet = new UserSet();
-        
-        // the generated method that allows a Connection parameter is missing
-        List usergroups = getTorqueBasicUserGroupsJoinTorqueBasicUser(new Criteria());
-
-        for (Iterator i = usergroups.iterator(); i.hasNext();)
-        {
-            TorqueBasicUserGroup tbug = (TorqueBasicUserGroup)i.next(); 
-            userSet.add(tbug.getTorqueBasicUser());
-        }
-    }
-    
-    /**
-     * Update this instance to the database with all dependend objects
-     * 
-     * @param con A database connection 
-     */
-    public void update(Connection con) throws TorqueException
-    {
-        if (userSet != null)
-        {
-            Criteria criteria = new Criteria();
-            
-            /* remove old entries */
-            criteria.add(TorqueBasicUserGroupPeer.GROUP_ID, getEntityId());
-            TorqueBasicUserGroupPeer.doDelete(criteria, con);
-
-            for (Iterator i = userSet.iterator(); i.hasNext();)
-            {
-                TorqueBasicUser user = (TorqueBasicUser)i.next();
-
-                TorqueBasicUserGroup ug = new TorqueBasicUserGroup();
-                ug.setUserId(user.getEntityId());
-                ug.setGroupId(getEntityId());
-                ug.save(con);
-            }
-        }
-        
-        try
-        {
-            save(con);
-        }
-        catch (Exception e)
-        {
-            throw new TorqueException(e);
-        }
-    }
-
-    /**
-     * Get the name of the connnection pool associated to this object
-     * 
-     * @return the logical Torque database name 
-     */
-    public String getDatabaseName()
-    {
-        return TorqueBasicGroupPeer.DATABASE_NAME;
-    }
-
-    /**
-     * @see org.apache.fulcrum.security.torque.TorqueAbstractSecurityEntity#delete()
-     */
-    public void delete() throws TorqueException
-    {
-        TorqueBasicGroupPeer.doDelete(SimpleKey.keyFor(getEntityId()));
-    }
-}
\ No newline at end of file
+package org.apache.fulcrum.security.torque.basic;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.fulcrum.security.entity.User;
+import org.apache.fulcrum.security.model.basic.entity.BasicGroup;
+import org.apache.fulcrum.security.torque.TorqueAbstractSecurityEntity;
+import org.apache.fulcrum.security.torque.om.TorqueBasicGroupPeer;
+import org.apache.fulcrum.security.torque.om.TorqueBasicUser;
+import org.apache.fulcrum.security.torque.om.TorqueBasicUserGroup;
+import org.apache.fulcrum.security.torque.om.TorqueBasicUserGroupPeer;
+import org.apache.fulcrum.security.util.UserSet;
+import org.apache.torque.TorqueException;
+import org.apache.torque.om.SimpleKey;
+import org.apache.torque.util.Criteria;
+/**
+ * This abstract class provides the SecurityInterface to the managers.
+ *
+ * @author <a href="mailto:tv@apache.org">Thomas Vandahl</a>
+ * @version $Id:$
+ */
+public abstract class TorqueAbstractBasicGroup extends TorqueAbstractSecurityEntity
+    implements BasicGroup
+{
+    /** a cache of user objects */
+    private Set userSet = null;
+
+    /**
+     * Forward reference to generated code
+     *
+     * Get a list of association objects, pre-populated with their TorqueBasicUser
+     * objects.
+     *
+     * @param criteria Criteria to define the selection of records
+     * @throws TorqueException
+     *
+     * @return a list of User/Group relations
+     */
+    protected abstract List getTorqueBasicUserGroupsJoinTorqueBasicUser(Criteria criteria)
+        throws TorqueException;
+
+    /**
+     * @see org.apache.fulcrum.security.model.basic.entity.BasicGroup#addUser(org.apache.fulcrum.security.entity.User)
+     */
+    public void addUser(User user)
+    {
+        getUsers().add(user);
+    }
+
+    /**
+     * @see org.apache.fulcrum.security.model.basic.entity.BasicGroup#getUsers()
+     */
+    public UserSet getUsers()
+    {
+        if (userSet == null)
+        {
+            userSet = new UserSet();
+        }
+        else if(!(userSet instanceof UserSet))
+        {
+            userSet = new UserSet(userSet);
+        }
+
+        return (UserSet)userSet;
+    }
+
+    /**
+     * @see org.apache.fulcrum.security.model.basic.entity.BasicGroup#getUsersAsSet()
+     */
+    public Set getUsersAsSet()
+    {
+        return userSet;
+    }
+
+    /**
+     * @see org.apache.fulcrum.security.model.basic.entity.BasicGroup#removeUser(org.apache.fulcrum.security.entity.User)
+     */
+    public void removeUser(User user)
+    {
+        getUsers().remove(user);
+    }
+
+    /**
+     * @see org.apache.fulcrum.security.model.basic.entity.BasicGroup#setUsers(org.apache.fulcrum.security.util.UserSet)
+     */
+    public void setUsers(UserSet userSet)
+    {
+        if(userSet != null)
+        {
+            this.userSet = userSet;
+        }
+        else
+        {
+            this.userSet = new UserSet();
+        }
+    }
+
+    /**
+     * @see org.apache.fulcrum.security.model.basic.entity.BasicGroup#setUsersAsSet(java.util.Set)
+     */
+    public void setUsersAsSet(Set users)
+    {
+        setUsers(new UserSet(users));
+    }
+
+    /**
+     * Retrieve attached objects such as users, permissions,....
+     */
+    public void retrieveAttachedObjects(Connection con) throws TorqueException
+    {
+        this.userSet = new UserSet();
+
+        // the generated method that allows a Connection parameter is missing
+        List usergroups = getTorqueBasicUserGroupsJoinTorqueBasicUser(new Criteria());
+
+        for (Iterator i = usergroups.iterator(); i.hasNext();)
+        {
+            TorqueBasicUserGroup tbug = (TorqueBasicUserGroup)i.next();
+            userSet.add(tbug.getTorqueBasicUser());
+        }
+    }
+
+    /**
+     * Update this instance to the database with all dependend objects
+     *
+     * @param con A database connection
+     */
+    public void update(Connection con) throws TorqueException
+    {
+        if (userSet != null)
+        {
+            Criteria criteria = new Criteria();
+
+            /* remove old entries */
+            criteria.add(TorqueBasicUserGroupPeer.GROUP_ID, getEntityId());
+            TorqueBasicUserGroupPeer.doDelete(criteria, con);
+
+            for (Iterator i = userSet.iterator(); i.hasNext();)
+            {
+                TorqueBasicUser user = (TorqueBasicUser)i.next();
+
+                TorqueBasicUserGroup ug = new TorqueBasicUserGroup();
+                ug.setUserId(user.getEntityId());
+                ug.setGroupId(getEntityId());
+                ug.save(con);
+            }
+        }
+
+        try
+        {
+            save(con);
+        }
+        catch (Exception e)
+        {
+            throw new TorqueException(e);
+        }
+    }
+
+    /**
+     * Get the name of the connnection pool associated to this object
+     *
+     * @return the logical Torque database name
+     */
+    public String getDatabaseName()
+    {
+        return TorqueBasicGroupPeer.DATABASE_NAME;
+    }
+
+    /**
+     * @see org.apache.fulcrum.security.torque.TorqueAbstractSecurityEntity#delete()
+     */
+    public void delete() throws TorqueException
+    {
+        TorqueBasicGroupPeer.doDelete(SimpleKey.keyFor(getEntityId()));
+    }
+}

Modified: jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/basic/TorqueAbstractBasicUser.java
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/basic/TorqueAbstractBasicUser.java?view=diff&rev=535465&r1=535464&r2=535465
==============================================================================
--- jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/basic/TorqueAbstractBasicUser.java (original)
+++ jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/basic/TorqueAbstractBasicUser.java Fri May  4 23:58:06 2007
@@ -1,192 +1,195 @@
-package org.apache.fulcrum.security.torque.basic;
-/*
- *  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.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import org.apache.fulcrum.security.entity.Group;
-import org.apache.fulcrum.security.model.basic.entity.BasicUser;
-import org.apache.fulcrum.security.torque.TorqueAbstractSecurityEntity;
-import org.apache.fulcrum.security.torque.om.TorqueBasicGroup;
-import org.apache.fulcrum.security.torque.om.TorqueBasicUserGroup;
-import org.apache.fulcrum.security.torque.om.TorqueBasicUserGroupPeer;
-import org.apache.fulcrum.security.torque.om.TorqueBasicUserPeer;
-import org.apache.fulcrum.security.util.GroupSet;
-import org.apache.torque.TorqueException;
-import org.apache.torque.om.SimpleKey;
-import org.apache.torque.util.Criteria;
-/**
- * This abstract class provides the SecurityInterface to the managers.
- *
- * @author <a href="mailto:tv@apache.org">Thomas Vandahl</a>
- * @version $Id:$
- */
-public abstract class TorqueAbstractBasicUser extends TorqueAbstractSecurityEntity
-    implements BasicUser
-{
-    /** a cache of group objects */
-    private Set groupSet = null;
-    
-    /**
-     * Forward reference to generated code
-     * 
-     * Get a list of association objects, pre-populated with their TorqueBasicGroup 
-     * objects.
-     * 
-     * @param criteria Criteria to define the selection of records
-     * @throws TorqueException
-     * 
-     * @return a list of User/Group relations
-     */
-    protected abstract List getTorqueBasicUserGroupsJoinTorqueBasicGroup(Criteria criteria) 
-        throws TorqueException;
-    
-    /**
-     * @see org.apache.fulcrum.security.model.basic.entity.BasicUser#addGroup(org.apache.fulcrum.security.entity.Group)
-     */
-    public void addGroup(Group group)
-    {
-        getGroups().add(group);
-    }
-
-    /**
-     * @see org.apache.fulcrum.security.model.basic.entity.BasicUser#getGroups()
-     */
-    public GroupSet getGroups()
-    {
-        if (groupSet == null)
-        {
-            groupSet = new GroupSet();
-        }
-        else if(!(groupSet instanceof GroupSet))
-        {
-            groupSet = new GroupSet(groupSet);
-        }
-
-        return (GroupSet)groupSet;
-    }
-
-    /**
-     * @see org.apache.fulcrum.security.model.basic.entity.BasicUser#getGroupsAsSet()
-     */
-    public Set getGroupsAsSet()
-    {
-        return groupSet;
-    }
-
-    /**
-     * @see org.apache.fulcrum.security.model.basic.entity.BasicUser#removeGroup(org.apache.fulcrum.security.entity.Group)
-     */
-    public void removeGroup(Group group)
-    {
-        getGroups().remove(group);
-    }
-
-    /**
-     * @see org.apache.fulcrum.security.model.basic.entity.BasicUser#setGroups(org.apache.fulcrum.security.util.GroupSet)
-     */
-    public void setGroups(GroupSet groups)
-    {
-        if(groups != null)
-        {
-            this.groupSet = groups;
-        }
-        else
-        {
-            this.groupSet = new GroupSet();
-        }
-    }
-
-    /**
-     * @see org.apache.fulcrum.security.model.basic.entity.BasicUser#setGroupsAsSet(java.util.Set)
-     */
-    public void setGroupsAsSet(Set groups)
-    {
-        setGroups(new GroupSet(groups));
-    }
-
-    /**
-     * Retrieve attached objects such as users, permissions,....
-     */
-    public void retrieveAttachedObjects(Connection con) throws TorqueException
-    {
-        this.groupSet = new GroupSet();
-        
-        List usergroups = getTorqueBasicUserGroupsJoinTorqueBasicGroup(new Criteria());
-
-        for (Iterator i = usergroups.iterator(); i.hasNext();)
-        {
-            TorqueBasicUserGroup tbug = (TorqueBasicUserGroup)i.next(); 
-            groupSet.add(tbug.getTorqueBasicGroup());
-        }
-    }
-
-    /**
-     * Update this instance to the database with all dependend objects
-     * 
-     * @param con A database connection 
-     */
-    public void update(Connection con) throws TorqueException
-    {
-        if (groupSet != null)
-        {
-            Criteria criteria = new Criteria();
-            
-            /* remove old entries */
-            criteria.add(TorqueBasicUserGroupPeer.USER_ID, getEntityId());
-            TorqueBasicUserGroupPeer.doDelete(criteria, con);
-
-            for (Iterator i = groupSet.iterator(); i.hasNext();)
-            {
-                TorqueBasicGroup group = (TorqueBasicGroup)i.next();
-
-                TorqueBasicUserGroup ug = new TorqueBasicUserGroup();
-                ug.setUserId(getEntityId());
-                ug.setGroupId(group.getEntityId());
-                ug.save(con);
-            }
-        }
-        
-        try
-        {
-            save(con);
-        }
-        catch (Exception e)
-        {
-            throw new TorqueException(e);
-        }
-    }
-
-    /**
-     * Get the name of the connnection pool associated to this object
-     * 
-     * @return the logical Torque database name 
-     */
-    public String getDatabaseName()
-    {
-        return TorqueBasicUserPeer.DATABASE_NAME;
-    }
-
-    /**
-     * @see org.apache.fulcrum.security.torque.TorqueAbstractSecurityEntity#delete()
-     */
-    public void delete() throws TorqueException
-    {
-        TorqueBasicUserPeer.doDelete(SimpleKey.keyFor(getEntityId()));
-    }
-}
\ No newline at end of file
+package org.apache.fulcrum.security.torque.basic;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.fulcrum.security.entity.Group;
+import org.apache.fulcrum.security.model.basic.entity.BasicUser;
+import org.apache.fulcrum.security.torque.TorqueAbstractSecurityEntity;
+import org.apache.fulcrum.security.torque.om.TorqueBasicGroup;
+import org.apache.fulcrum.security.torque.om.TorqueBasicUserGroup;
+import org.apache.fulcrum.security.torque.om.TorqueBasicUserGroupPeer;
+import org.apache.fulcrum.security.torque.om.TorqueBasicUserPeer;
+import org.apache.fulcrum.security.util.GroupSet;
+import org.apache.torque.TorqueException;
+import org.apache.torque.om.SimpleKey;
+import org.apache.torque.util.Criteria;
+/**
+ * This abstract class provides the SecurityInterface to the managers.
+ *
+ * @author <a href="mailto:tv@apache.org">Thomas Vandahl</a>
+ * @version $Id:$
+ */
+public abstract class TorqueAbstractBasicUser extends TorqueAbstractSecurityEntity
+    implements BasicUser
+{
+    /** a cache of group objects */
+    private Set groupSet = null;
+
+    /**
+     * Forward reference to generated code
+     *
+     * Get a list of association objects, pre-populated with their TorqueBasicGroup
+     * objects.
+     *
+     * @param criteria Criteria to define the selection of records
+     * @throws TorqueException
+     *
+     * @return a list of User/Group relations
+     */
+    protected abstract List getTorqueBasicUserGroupsJoinTorqueBasicGroup(Criteria criteria)
+        throws TorqueException;
+
+    /**
+     * @see org.apache.fulcrum.security.model.basic.entity.BasicUser#addGroup(org.apache.fulcrum.security.entity.Group)
+     */
+    public void addGroup(Group group)
+    {
+        getGroups().add(group);
+    }
+
+    /**
+     * @see org.apache.fulcrum.security.model.basic.entity.BasicUser#getGroups()
+     */
+    public GroupSet getGroups()
+    {
+        if (groupSet == null)
+        {
+            groupSet = new GroupSet();
+        }
+        else if(!(groupSet instanceof GroupSet))
+        {
+            groupSet = new GroupSet(groupSet);
+        }
+
+        return (GroupSet)groupSet;
+    }
+
+    /**
+     * @see org.apache.fulcrum.security.model.basic.entity.BasicUser#getGroupsAsSet()
+     */
+    public Set getGroupsAsSet()
+    {
+        return groupSet;
+    }
+
+    /**
+     * @see org.apache.fulcrum.security.model.basic.entity.BasicUser#removeGroup(org.apache.fulcrum.security.entity.Group)
+     */
+    public void removeGroup(Group group)
+    {
+        getGroups().remove(group);
+    }
+
+    /**
+     * @see org.apache.fulcrum.security.model.basic.entity.BasicUser#setGroups(org.apache.fulcrum.security.util.GroupSet)
+     */
+    public void setGroups(GroupSet groups)
+    {
+        if(groups != null)
+        {
+            this.groupSet = groups;
+        }
+        else
+        {
+            this.groupSet = new GroupSet();
+        }
+    }
+
+    /**
+     * @see org.apache.fulcrum.security.model.basic.entity.BasicUser#setGroupsAsSet(java.util.Set)
+     */
+    public void setGroupsAsSet(Set groups)
+    {
+        setGroups(new GroupSet(groups));
+    }
+
+    /**
+     * Retrieve attached objects such as users, permissions,....
+     */
+    public void retrieveAttachedObjects(Connection con) throws TorqueException
+    {
+        this.groupSet = new GroupSet();
+
+        List usergroups = getTorqueBasicUserGroupsJoinTorqueBasicGroup(new Criteria());
+
+        for (Iterator i = usergroups.iterator(); i.hasNext();)
+        {
+            TorqueBasicUserGroup tbug = (TorqueBasicUserGroup)i.next();
+            groupSet.add(tbug.getTorqueBasicGroup());
+        }
+    }
+
+    /**
+     * Update this instance to the database with all dependend objects
+     *
+     * @param con A database connection
+     */
+    public void update(Connection con) throws TorqueException
+    {
+        if (groupSet != null)
+        {
+            Criteria criteria = new Criteria();
+
+            /* remove old entries */
+            criteria.add(TorqueBasicUserGroupPeer.USER_ID, getEntityId());
+            TorqueBasicUserGroupPeer.doDelete(criteria, con);
+
+            for (Iterator i = groupSet.iterator(); i.hasNext();)
+            {
+                TorqueBasicGroup group = (TorqueBasicGroup)i.next();
+
+                TorqueBasicUserGroup ug = new TorqueBasicUserGroup();
+                ug.setUserId(getEntityId());
+                ug.setGroupId(group.getEntityId());
+                ug.save(con);
+            }
+        }
+
+        try
+        {
+            save(con);
+        }
+        catch (Exception e)
+        {
+            throw new TorqueException(e);
+        }
+    }
+
+    /**
+     * Get the name of the connnection pool associated to this object
+     *
+     * @return the logical Torque database name
+     */
+    public String getDatabaseName()
+    {
+        return TorqueBasicUserPeer.DATABASE_NAME;
+    }
+
+    /**
+     * @see org.apache.fulcrum.security.torque.TorqueAbstractSecurityEntity#delete()
+     */
+    public void delete() throws TorqueException
+    {
+        TorqueBasicUserPeer.doDelete(SimpleKey.keyFor(getEntityId()));
+    }
+}

Modified: jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/basic/TorqueBasicGroupManagerImpl.java
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/basic/TorqueBasicGroupManagerImpl.java?view=diff&rev=535465&r1=535464&r2=535465
==============================================================================
--- jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/basic/TorqueBasicGroupManagerImpl.java (original)
+++ jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/basic/TorqueBasicGroupManagerImpl.java Fri May  4 23:58:06 2007
@@ -1,75 +1,78 @@
-package org.apache.fulcrum.security.torque.basic;
-/*
- *  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.List;
-
-import org.apache.fulcrum.security.entity.Group;
-import org.apache.fulcrum.security.torque.TorqueAbstractGroupManager;
-import org.apache.fulcrum.security.torque.om.TorqueBasicGroupPeer;
-import org.apache.torque.NoRowsException;
-import org.apache.torque.TooManyRowsException;
-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 TorqueBasicGroupManagerImpl extends TorqueAbstractGroupManager
-{
-    /**
-     * @see org.apache.fulcrum.security.torque.TorqueAbstractGroupManager#doSelectAllGroups(java.sql.Connection)
-     */
-    protected List doSelectAllGroups(Connection con)
-        throws TorqueException
-    {
-        Criteria criteria = new Criteria(TorqueBasicGroupPeer.DATABASE_NAME);
-
-        return TorqueBasicGroupPeer.doSelect(criteria, con);
-    }
-
-    /**
-     * @see org.apache.fulcrum.security.torque.TorqueAbstractGroupManager#doSelectById(java.lang.Integer, java.sql.Connection)
-     */
-    protected Group doSelectById(Integer id, Connection con)
-        throws NoRowsException, TooManyRowsException, TorqueException
-    {
-        return TorqueBasicGroupPeer.retrieveByPK(id, con);
-    }
-
-    /**
-     * @see org.apache.fulcrum.security.torque.TorqueAbstractGroupManager#doSelectByName(java.lang.String, java.sql.Connection)
-     */
-    protected Group doSelectByName(String name, Connection con)
-        throws NoRowsException, TooManyRowsException, TorqueException
-    {
-        Criteria criteria = new Criteria(TorqueBasicGroupPeer.DATABASE_NAME);
-        criteria.add(TorqueBasicGroupPeer.GROUP_NAME, name);
-        criteria.setIgnoreCase(true);
-        criteria.setSingleRecord(true);
-
-        List groups = TorqueBasicGroupPeer.doSelect(criteria, con);
-        
-        if (groups.isEmpty())
-        {
-            throw new NoRowsException(name);
-        }
-        
-        return (Group)groups.get(0);
-    }
-}
\ No newline at end of file
+package org.apache.fulcrum.security.torque.basic;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.List;
+
+import org.apache.fulcrum.security.entity.Group;
+import org.apache.fulcrum.security.torque.TorqueAbstractGroupManager;
+import org.apache.fulcrum.security.torque.om.TorqueBasicGroupPeer;
+import org.apache.torque.NoRowsException;
+import org.apache.torque.TooManyRowsException;
+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 TorqueBasicGroupManagerImpl extends TorqueAbstractGroupManager
+{
+    /**
+     * @see org.apache.fulcrum.security.torque.TorqueAbstractGroupManager#doSelectAllGroups(java.sql.Connection)
+     */
+    protected List doSelectAllGroups(Connection con)
+        throws TorqueException
+    {
+        Criteria criteria = new Criteria(TorqueBasicGroupPeer.DATABASE_NAME);
+
+        return TorqueBasicGroupPeer.doSelect(criteria, con);
+    }
+
+    /**
+     * @see org.apache.fulcrum.security.torque.TorqueAbstractGroupManager#doSelectById(java.lang.Integer, java.sql.Connection)
+     */
+    protected Group doSelectById(Integer id, Connection con)
+        throws NoRowsException, TooManyRowsException, TorqueException
+    {
+        return TorqueBasicGroupPeer.retrieveByPK(id, con);
+    }
+
+    /**
+     * @see org.apache.fulcrum.security.torque.TorqueAbstractGroupManager#doSelectByName(java.lang.String, java.sql.Connection)
+     */
+    protected Group doSelectByName(String name, Connection con)
+        throws NoRowsException, TooManyRowsException, TorqueException
+    {
+        Criteria criteria = new Criteria(TorqueBasicGroupPeer.DATABASE_NAME);
+        criteria.add(TorqueBasicGroupPeer.GROUP_NAME, name);
+        criteria.setIgnoreCase(true);
+        criteria.setSingleRecord(true);
+
+        List groups = TorqueBasicGroupPeer.doSelect(criteria, con);
+
+        if (groups.isEmpty())
+        {
+            throw new NoRowsException(name);
+        }
+
+        return (Group)groups.get(0);
+    }
+}

Modified: jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/basic/TorqueBasicModelManagerImpl.java
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/basic/TorqueBasicModelManagerImpl.java?view=diff&rev=535465&r1=535464&r2=535465
==============================================================================
--- jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/basic/TorqueBasicModelManagerImpl.java (original)
+++ jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/basic/TorqueBasicModelManagerImpl.java Fri May  4 23:58:06 2007
@@ -1,212 +1,215 @@
-package org.apache.fulcrum.security.torque.basic;
-/*
- *  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.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.apache.fulcrum.security.entity.Group;
-import org.apache.fulcrum.security.entity.User;
-import org.apache.fulcrum.security.model.basic.BasicModelManager;
-import org.apache.fulcrum.security.model.basic.entity.BasicGroup;
-import org.apache.fulcrum.security.model.basic.entity.BasicUser;
-import org.apache.fulcrum.security.spi.AbstractManager;
-import org.apache.fulcrum.security.torque.TorqueAbstractSecurityEntity;
-import org.apache.fulcrum.security.util.DataBackendException;
-import org.apache.fulcrum.security.util.UnknownEntityException;
-import org.apache.torque.TorqueException;
-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 TorqueBasicModelManagerImpl extends AbstractManager implements BasicModelManager
-{
-    /**
-     * 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 = getGroupManager().checkExists(group);
-        boolean userExists = getUserManager().checkExists(user);
-        
-        if (groupExists && userExists)
-        {
-            ((BasicUser) user).addGroup(group);
-            ((BasicGroup) group).addUser(user);
-            
-            Connection con = null;
-            
-            try
-            {
-                con = Transaction.begin(((TorqueAbstractSecurityEntity)user).getDatabaseName());
-                
-                ((TorqueAbstractSecurityEntity)user).update(con);
-                ((TorqueAbstractSecurityEntity)group).update(con);
-                
-                Transaction.commit(con);
-                con = null;
-            }
-            catch (TorqueException e)
-            {
-                throw new DataBackendException("grant('" + user.getName() + user.getId() + "', '" + group.getName() + group.getId() + "') failed", e);
-            }
-            finally
-            {
-                if (con != null)
-                {
-                    Transaction.safeRollback(con);
-                }
-            }
-
-            return;
-        }
-
-        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 = getGroupManager().checkExists(group);
-        boolean userExists = getUserManager().checkExists(user);
-        
-        if (groupExists && userExists)
-        {
-            ((BasicUser) user).removeGroup(group);
-            ((BasicGroup) group).removeUser(user);
-            
-            Connection con = null;
-            
-            try
-            {
-                con = Transaction.begin(((TorqueAbstractSecurityEntity)user).getDatabaseName());
-                
-                ((TorqueAbstractSecurityEntity)user).update(con);
-                ((TorqueAbstractSecurityEntity)group).update(con);
-                
-                Transaction.commit(con);
-                con = null;
-            }
-            catch (TorqueException e)
-            {
-                throw new DataBackendException("grant('" + user.getName() + user.getId() + "', '" + group.getName() + group.getId() + "') failed", e);
-            }
-            finally
-            {
-                if (con != null)
-                {
-                    Transaction.safeRollback(con);
-                }
-            }
-            
-            return;
-        }
-
-        if (!groupExists)
-        {
-            throw new UnknownEntityException("Unknown group '" + group.getName() + "'");
-        }
-
-        if (!userExists)
-        {
-            throw new UnknownEntityException("Unknown user '" + user.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 = getUserManager().checkExists(user);
-        
-        if (userExists)
-        {
-            BasicUser u = (BasicUser) user;
-            
-            // copy to avoid ConcurrentModificationException
-            List groups = new ArrayList(u.getGroups());
-
-            for (Iterator i = groups.iterator(); i.hasNext();)
-            {
-                Group group = (Group)i.next();
-                u.removeGroup(group);
-            }
-            
-            Connection con = null;
-            
-            try
-            {
-                con = Transaction.begin(((TorqueAbstractSecurityEntity)user).getDatabaseName());
-                
-                ((TorqueAbstractSecurityEntity)user).update(con);
-                
-                Transaction.commit(con);
-                con = null;
-            }
-            catch (TorqueException e)
-            {
-                throw new DataBackendException("revokeAll('" + user.getName() + user.getId() + "') failed", e);
-            }
-            finally
-            {
-                if (con != null)
-                {
-                    Transaction.safeRollback(con);
-                }
-            }
-
-            return;
-        }
-        else
-        {
-            throw new UnknownEntityException("Unknown user '" + user.getName() + "'");
-        }
-    }
-}
\ No newline at end of file
+package org.apache.fulcrum.security.torque.basic;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.fulcrum.security.entity.Group;
+import org.apache.fulcrum.security.entity.User;
+import org.apache.fulcrum.security.model.basic.BasicModelManager;
+import org.apache.fulcrum.security.model.basic.entity.BasicGroup;
+import org.apache.fulcrum.security.model.basic.entity.BasicUser;
+import org.apache.fulcrum.security.spi.AbstractManager;
+import org.apache.fulcrum.security.torque.TorqueAbstractSecurityEntity;
+import org.apache.fulcrum.security.util.DataBackendException;
+import org.apache.fulcrum.security.util.UnknownEntityException;
+import org.apache.torque.TorqueException;
+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 TorqueBasicModelManagerImpl extends AbstractManager implements BasicModelManager
+{
+    /**
+     * 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 = getGroupManager().checkExists(group);
+        boolean userExists = getUserManager().checkExists(user);
+
+        if (groupExists && userExists)
+        {
+            ((BasicUser) user).addGroup(group);
+            ((BasicGroup) group).addUser(user);
+
+            Connection con = null;
+
+            try
+            {
+                con = Transaction.begin(((TorqueAbstractSecurityEntity)user).getDatabaseName());
+
+                ((TorqueAbstractSecurityEntity)user).update(con);
+                ((TorqueAbstractSecurityEntity)group).update(con);
+
+                Transaction.commit(con);
+                con = null;
+            }
+            catch (TorqueException e)
+            {
+                throw new DataBackendException("grant('" + user.getName() + user.getId() + "', '" + group.getName() + group.getId() + "') failed", e);
+            }
+            finally
+            {
+                if (con != null)
+                {
+                    Transaction.safeRollback(con);
+                }
+            }
+
+            return;
+        }
+
+        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 = getGroupManager().checkExists(group);
+        boolean userExists = getUserManager().checkExists(user);
+
+        if (groupExists && userExists)
+        {
+            ((BasicUser) user).removeGroup(group);
+            ((BasicGroup) group).removeUser(user);
+
+            Connection con = null;
+
+            try
+            {
+                con = Transaction.begin(((TorqueAbstractSecurityEntity)user).getDatabaseName());
+
+                ((TorqueAbstractSecurityEntity)user).update(con);
+                ((TorqueAbstractSecurityEntity)group).update(con);
+
+                Transaction.commit(con);
+                con = null;
+            }
+            catch (TorqueException e)
+            {
+                throw new DataBackendException("grant('" + user.getName() + user.getId() + "', '" + group.getName() + group.getId() + "') failed", e);
+            }
+            finally
+            {
+                if (con != null)
+                {
+                    Transaction.safeRollback(con);
+                }
+            }
+
+            return;
+        }
+
+        if (!groupExists)
+        {
+            throw new UnknownEntityException("Unknown group '" + group.getName() + "'");
+        }
+
+        if (!userExists)
+        {
+            throw new UnknownEntityException("Unknown user '" + user.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 = getUserManager().checkExists(user);
+
+        if (userExists)
+        {
+            BasicUser u = (BasicUser) user;
+
+            // copy to avoid ConcurrentModificationException
+            List groups = new ArrayList(u.getGroups());
+
+            for (Iterator i = groups.iterator(); i.hasNext();)
+            {
+                Group group = (Group)i.next();
+                u.removeGroup(group);
+            }
+
+            Connection con = null;
+
+            try
+            {
+                con = Transaction.begin(((TorqueAbstractSecurityEntity)user).getDatabaseName());
+
+                ((TorqueAbstractSecurityEntity)user).update(con);
+
+                Transaction.commit(con);
+                con = null;
+            }
+            catch (TorqueException e)
+            {
+                throw new DataBackendException("revokeAll('" + user.getName() + user.getId() + "') failed", e);
+            }
+            finally
+            {
+                if (con != null)
+                {
+                    Transaction.safeRollback(con);
+                }
+            }
+
+            return;
+        }
+        else
+        {
+            throw new UnknownEntityException("Unknown user '" + user.getName() + "'");
+        }
+    }
+}

Modified: jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/basic/TorqueBasicUserManagerImpl.java
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/basic/TorqueBasicUserManagerImpl.java?view=diff&rev=535465&r1=535464&r2=535465
==============================================================================
--- jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/basic/TorqueBasicUserManagerImpl.java (original)
+++ jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/basic/TorqueBasicUserManagerImpl.java Fri May  4 23:58:06 2007
@@ -1,72 +1,75 @@
-package org.apache.fulcrum.security.torque.basic;
-/*
- *  Copyright 2001-2006 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.List;
-
-import org.apache.fulcrum.security.entity.User;
-import org.apache.fulcrum.security.torque.TorqueAbstractUserManager;
-import org.apache.fulcrum.security.torque.om.TorqueBasicUserPeer;
-import org.apache.torque.NoRowsException;
-import org.apache.torque.TooManyRowsException;
-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 TorqueBasicUserManagerImpl extends TorqueAbstractUserManager
-{
-    /**
-     * @see org.apache.fulcrum.security.torque.TorqueAbstractUserManager#doSelectAllUsers(java.sql.Connection)
-     */
-    protected List doSelectAllUsers(Connection con) throws TorqueException
-    {
-        Criteria criteria = new Criteria(TorqueBasicUserPeer.DATABASE_NAME);
-
-        return TorqueBasicUserPeer.doSelect(criteria, con);
-    }
-
-    /**
-     * @see org.apache.fulcrum.security.torque.TorqueAbstractUserManager#doSelectById(java.lang.Integer, java.sql.Connection)
-     */
-    protected User doSelectById(Integer id, Connection con) throws NoRowsException, TooManyRowsException, TorqueException
-    {
-        return TorqueBasicUserPeer.retrieveByPK(id, con);
-    }
-
-    /**
-     * @see org.apache.fulcrum.security.torque.TorqueAbstractUserManager#doSelectByName(java.lang.String, java.sql.Connection)
-     */
-    protected User doSelectByName(String name, Connection con) throws NoRowsException, TooManyRowsException, TorqueException
-    {
-        Criteria criteria = new Criteria(TorqueBasicUserPeer.DATABASE_NAME);
-        criteria.add(TorqueBasicUserPeer.LOGIN_NAME, name);
-        criteria.setIgnoreCase(true);
-        criteria.setSingleRecord(true);
-
-        List users = TorqueBasicUserPeer.doSelect(criteria, con);
-        
-        if (users.isEmpty())
-        {
-            throw new NoRowsException(name);
-        }
-        
-        return (User)users.get(0);
-    }
-}
+package org.apache.fulcrum.security.torque.basic;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.List;
+
+import org.apache.fulcrum.security.entity.User;
+import org.apache.fulcrum.security.torque.TorqueAbstractUserManager;
+import org.apache.fulcrum.security.torque.om.TorqueBasicUserPeer;
+import org.apache.torque.NoRowsException;
+import org.apache.torque.TooManyRowsException;
+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 TorqueBasicUserManagerImpl extends TorqueAbstractUserManager
+{
+    /**
+     * @see org.apache.fulcrum.security.torque.TorqueAbstractUserManager#doSelectAllUsers(java.sql.Connection)
+     */
+    protected List doSelectAllUsers(Connection con) throws TorqueException
+    {
+        Criteria criteria = new Criteria(TorqueBasicUserPeer.DATABASE_NAME);
+
+        return TorqueBasicUserPeer.doSelect(criteria, con);
+    }
+
+    /**
+     * @see org.apache.fulcrum.security.torque.TorqueAbstractUserManager#doSelectById(java.lang.Integer, java.sql.Connection)
+     */
+    protected User doSelectById(Integer id, Connection con) throws NoRowsException, TooManyRowsException, TorqueException
+    {
+        return TorqueBasicUserPeer.retrieveByPK(id, con);
+    }
+
+    /**
+     * @see org.apache.fulcrum.security.torque.TorqueAbstractUserManager#doSelectByName(java.lang.String, java.sql.Connection)
+     */
+    protected User doSelectByName(String name, Connection con) throws NoRowsException, TooManyRowsException, TorqueException
+    {
+        Criteria criteria = new Criteria(TorqueBasicUserPeer.DATABASE_NAME);
+        criteria.add(TorqueBasicUserPeer.LOGIN_NAME, name);
+        criteria.setIgnoreCase(true);
+        criteria.setSingleRecord(true);
+
+        List users = TorqueBasicUserPeer.doSelect(criteria, con);
+
+        if (users.isEmpty())
+        {
+            throw new NoRowsException(name);
+        }
+
+        return (User)users.get(0);
+    }
+}

Modified: jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/dynamic/TorqueAbstractDynamicGroup.java
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/dynamic/TorqueAbstractDynamicGroup.java?view=diff&rev=535465&r1=535464&r2=535465
==============================================================================
--- jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/dynamic/TorqueAbstractDynamicGroup.java (original)
+++ jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/dynamic/TorqueAbstractDynamicGroup.java Fri May  4 23:58:06 2007
@@ -1,305 +1,308 @@
-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.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import org.apache.fulcrum.security.entity.Role;
-import org.apache.fulcrum.security.entity.User;
-import org.apache.fulcrum.security.model.dynamic.entity.DynamicGroup;
-import org.apache.fulcrum.security.torque.TorqueAbstractSecurityEntity;
-import org.apache.fulcrum.security.torque.om.TorqueDynamicGroupPeer;
-import org.apache.fulcrum.security.torque.om.TorqueDynamicGroupRole;
-import org.apache.fulcrum.security.torque.om.TorqueDynamicGroupRolePeer;
-import org.apache.fulcrum.security.torque.om.TorqueDynamicRole;
-import org.apache.fulcrum.security.torque.om.TorqueDynamicUser;
-import org.apache.fulcrum.security.torque.om.TorqueDynamicUserGroup;
-import org.apache.fulcrum.security.torque.om.TorqueDynamicUserGroupPeer;
-import org.apache.fulcrum.security.util.RoleSet;
-import org.apache.fulcrum.security.util.UserSet;
-import org.apache.torque.TorqueException;
-import org.apache.torque.om.SimpleKey;
-import org.apache.torque.util.Criteria;
-/**
- * This abstract class provides the SecurityInterface to the managers.
- *
- * @author <a href="mailto:tv@apache.org">Thomas Vandahl</a>
- * @version $Id:$
- */
-public abstract class TorqueAbstractDynamicGroup extends TorqueAbstractSecurityEntity
-    implements DynamicGroup
-{
-    /** a cache of user objects */
-    private Set userSet = null;
-    
-    /** a cache of role objects */
-    private Set roleSet = null;
-    
-    /**
-     * Forward reference to generated code
-     * 
-     * Get a list of association objects, pre-populated with their TorqueDynamicUser 
-     * objects.
-     * 
-     * @param criteria Criteria to define the selection of records
-     * @throws TorqueException
-     * 
-     * @return a list of User/Group relations
-     */
-    protected abstract List getTorqueDynamicUserGroupsJoinTorqueDynamicUser(Criteria criteria) 
-        throws TorqueException;
-
-    /**
-     * Forward reference to generated code
-     * 
-     * Get a list of association objects, pre-populated with their TorqueDynamicRole 
-     * objects.
-     * 
-     * @param criteria Criteria to define the selection of records
-     * @throws TorqueException
-     * 
-     * @return a list of Role/Group relations
-     */
-    protected abstract List getTorqueDynamicGroupRolesJoinTorqueDynamicRole(Criteria criteria) 
-        throws TorqueException;
-
-    /**
-     * @see org.apache.fulcrum.security.model.basic.entity.BasicGroup#addUser(org.apache.fulcrum.security.entity.User)
-     */
-    public void addUser(User user)
-    {
-        getUsers().add(user);
-    }
-
-    /**
-     * @see org.apache.fulcrum.security.model.basic.entity.BasicGroup#getUsers()
-     */
-    public UserSet getUsers()
-    {
-        if (userSet == null)
-        {
-            userSet = new UserSet();
-        }
-        else if(!(userSet instanceof UserSet))
-        {
-            userSet = new UserSet(userSet);
-        }
-
-        return (UserSet)userSet;
-    }
-
-    /**
-     * @see org.apache.fulcrum.security.model.basic.entity.BasicGroup#getUsersAsSet()
-     */
-    public Set getUsersAsSet()
-    {
-        return userSet;
-    }
-
-    /**
-     * @see org.apache.fulcrum.security.model.basic.entity.BasicGroup#removeUser(org.apache.fulcrum.security.entity.User)
-     */
-    public void removeUser(User user)
-    {
-        getUsers().remove(user);
-    }
-
-    /**
-     * @see org.apache.fulcrum.security.model.basic.entity.BasicGroup#setUsers(org.apache.fulcrum.security.util.UserSet)
-     */
-    public void setUsers(UserSet userSet)
-    {
-        if(userSet != null)
-        {
-            this.userSet = userSet;
-        }
-        else
-        {
-            this.userSet = new UserSet();
-        }
-    }
-
-    /**
-     * @see org.apache.fulcrum.security.model.basic.entity.BasicGroup#setUsersAsSet(java.util.Set)
-     */
-    public void setUsersAsSet(Set users)
-    {
-        setUsers(new UserSet(users));
-    }
-    
-    /**
-     * @see org.apache.fulcrum.security.model.dynamic.entity.DynamicGroup#addRole(org.apache.fulcrum.security.entity.Role)
-     */
-    public void addRole(Role role)
-    {
-        getRoles().add(role);
-    }
-
-    /**
-     * @see org.apache.fulcrum.security.model.dynamic.entity.DynamicGroup#getRoles()
-     */
-    public RoleSet getRoles()
-    {
-        if (roleSet == null)
-        {
-            roleSet = new RoleSet();
-        }
-        else if(!(roleSet instanceof RoleSet))
-        {
-            roleSet = new RoleSet(roleSet);
-        }
-
-        return (RoleSet)roleSet;
-    }
-
-    /**
-     * @see org.apache.fulcrum.security.model.dynamic.entity.DynamicGroup#getRolesAsSet()
-     */
-    public Set getRolesAsSet()
-    {
-        return roleSet;
-    }
-
-    /**
-     * @see org.apache.fulcrum.security.model.dynamic.entity.DynamicGroup#removeRole(org.apache.fulcrum.security.entity.Role)
-     */
-    public void removeRole(Role role)
-    {
-        getRoles().remove(role);
-    }
-
-    /**
-     * @see org.apache.fulcrum.security.model.dynamic.entity.DynamicGroup#setRoles(org.apache.fulcrum.security.util.RoleSet)
-     */
-    public void setRoles(RoleSet roleSet)
-    {
-        if(roleSet != null)
-        {
-            this.roleSet = roleSet;
-        }
-        else
-        {
-            this.roleSet = new RoleSet();
-        }
-    }
-
-    /**
-     * @see org.apache.fulcrum.security.model.dynamic.entity.DynamicGroup#setRolesAsSet(java.util.Set)
-     */
-    public void setRolesAsSet(Set roles)
-    {
-        setRoles(new RoleSet(roles));
-    }
-
-    /**
-     * @see org.apache.fulcrum.security.torque.TorqueAbstractSecurityEntity#getDatabaseName()
-     */
-    public String getDatabaseName()
-    {
-        return TorqueDynamicGroupPeer.DATABASE_NAME;
-    }
-
-    /**
-     * @see org.apache.fulcrum.security.torque.TorqueAbstractSecurityEntity#retrieveAttachedObjects(java.sql.Connection)
-     */
-    public void retrieveAttachedObjects(Connection con) throws TorqueException
-    {
-        this.userSet = new UserSet();
-        
-        // the generated method that allows a Connection parameter is missing
-        List usergroups = getTorqueDynamicUserGroupsJoinTorqueDynamicUser(new Criteria());
-
-        for (Iterator i = usergroups.iterator(); i.hasNext();)
-        {
-            TorqueDynamicUserGroup tdug = (TorqueDynamicUserGroup)i.next(); 
-            userSet.add(tdug.getTorqueDynamicUser());
-        }
-
-        this.roleSet = new RoleSet();
-        
-        // the generated method that allows a Connection parameter is missing
-        List grouproles = getTorqueDynamicGroupRolesJoinTorqueDynamicRole(new Criteria());
-
-        for (Iterator i = grouproles.iterator(); i.hasNext();)
-        {
-            TorqueDynamicGroupRole tdgr = (TorqueDynamicGroupRole)i.next(); 
-            roleSet.add(tdgr.getTorqueDynamicRole());
-        }
-    }
-
-    /**
-     * @see org.apache.fulcrum.security.torque.TorqueAbstractSecurityEntity#update(java.sql.Connection)
-     */
-    public void update(Connection con) throws TorqueException
-    {
-        if (userSet != null)
-        {
-            Criteria criteria = new Criteria();
-            
-            /* remove old entries */
-            criteria.add(TorqueDynamicUserGroupPeer.GROUP_ID, getEntityId());
-            TorqueDynamicUserGroupPeer.doDelete(criteria, con);
-
-            for (Iterator i = userSet.iterator(); i.hasNext();)
-            {
-                TorqueDynamicUser user = (TorqueDynamicUser)i.next();
-
-                TorqueDynamicUserGroup ug = new TorqueDynamicUserGroup();
-                ug.setUserId(user.getEntityId());
-                ug.setGroupId(getEntityId());
-                ug.save(con);
-            }
-        }
-        
-        if (roleSet != null)
-        {
-            Criteria criteria = new Criteria();
-            
-            /* remove old entries */
-            criteria.add(TorqueDynamicGroupRolePeer.GROUP_ID, getEntityId());
-            TorqueDynamicGroupRolePeer.doDelete(criteria, con);
-
-            for (Iterator i = roleSet.iterator(); i.hasNext();)
-            {
-                TorqueDynamicRole role = (TorqueDynamicRole)i.next();
-
-                TorqueDynamicGroupRole gr = new TorqueDynamicGroupRole();
-                gr.setRoleId(role.getEntityId());
-                gr.setGroupId(getEntityId());
-                gr.save(con);
-            }
-        }
-        
-        try
-        {
-            save(con);
-        }
-        catch (Exception e)
-        {
-            throw new TorqueException(e);
-        }
-    }
-
-    /**
-     * @see org.apache.fulcrum.security.torque.TorqueAbstractSecurityEntity#delete()
-     */
-    public void delete() throws TorqueException
-    {
-        TorqueDynamicGroupPeer.doDelete(SimpleKey.keyFor(getEntityId()));
-    }
-}
\ No newline at end of file
+package org.apache.fulcrum.security.torque.dynamic;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.fulcrum.security.entity.Role;
+import org.apache.fulcrum.security.entity.User;
+import org.apache.fulcrum.security.model.dynamic.entity.DynamicGroup;
+import org.apache.fulcrum.security.torque.TorqueAbstractSecurityEntity;
+import org.apache.fulcrum.security.torque.om.TorqueDynamicGroupPeer;
+import org.apache.fulcrum.security.torque.om.TorqueDynamicGroupRole;
+import org.apache.fulcrum.security.torque.om.TorqueDynamicGroupRolePeer;
+import org.apache.fulcrum.security.torque.om.TorqueDynamicRole;
+import org.apache.fulcrum.security.torque.om.TorqueDynamicUser;
+import org.apache.fulcrum.security.torque.om.TorqueDynamicUserGroup;
+import org.apache.fulcrum.security.torque.om.TorqueDynamicUserGroupPeer;
+import org.apache.fulcrum.security.util.RoleSet;
+import org.apache.fulcrum.security.util.UserSet;
+import org.apache.torque.TorqueException;
+import org.apache.torque.om.SimpleKey;
+import org.apache.torque.util.Criteria;
+/**
+ * This abstract class provides the SecurityInterface to the managers.
+ *
+ * @author <a href="mailto:tv@apache.org">Thomas Vandahl</a>
+ * @version $Id:$
+ */
+public abstract class TorqueAbstractDynamicGroup extends TorqueAbstractSecurityEntity
+    implements DynamicGroup
+{
+    /** a cache of user objects */
+    private Set userSet = null;
+
+    /** a cache of role objects */
+    private Set roleSet = null;
+
+    /**
+     * Forward reference to generated code
+     *
+     * Get a list of association objects, pre-populated with their TorqueDynamicUser
+     * objects.
+     *
+     * @param criteria Criteria to define the selection of records
+     * @throws TorqueException
+     *
+     * @return a list of User/Group relations
+     */
+    protected abstract List getTorqueDynamicUserGroupsJoinTorqueDynamicUser(Criteria criteria)
+        throws TorqueException;
+
+    /**
+     * Forward reference to generated code
+     *
+     * Get a list of association objects, pre-populated with their TorqueDynamicRole
+     * objects.
+     *
+     * @param criteria Criteria to define the selection of records
+     * @throws TorqueException
+     *
+     * @return a list of Role/Group relations
+     */
+    protected abstract List getTorqueDynamicGroupRolesJoinTorqueDynamicRole(Criteria criteria)
+        throws TorqueException;
+
+    /**
+     * @see org.apache.fulcrum.security.model.basic.entity.BasicGroup#addUser(org.apache.fulcrum.security.entity.User)
+     */
+    public void addUser(User user)
+    {
+        getUsers().add(user);
+    }
+
+    /**
+     * @see org.apache.fulcrum.security.model.basic.entity.BasicGroup#getUsers()
+     */
+    public UserSet getUsers()
+    {
+        if (userSet == null)
+        {
+            userSet = new UserSet();
+        }
+        else if(!(userSet instanceof UserSet))
+        {
+            userSet = new UserSet(userSet);
+        }
+
+        return (UserSet)userSet;
+    }
+
+    /**
+     * @see org.apache.fulcrum.security.model.basic.entity.BasicGroup#getUsersAsSet()
+     */
+    public Set getUsersAsSet()
+    {
+        return userSet;
+    }
+
+    /**
+     * @see org.apache.fulcrum.security.model.basic.entity.BasicGroup#removeUser(org.apache.fulcrum.security.entity.User)
+     */
+    public void removeUser(User user)
+    {
+        getUsers().remove(user);
+    }
+
+    /**
+     * @see org.apache.fulcrum.security.model.basic.entity.BasicGroup#setUsers(org.apache.fulcrum.security.util.UserSet)
+     */
+    public void setUsers(UserSet userSet)
+    {
+        if(userSet != null)
+        {
+            this.userSet = userSet;
+        }
+        else
+        {
+            this.userSet = new UserSet();
+        }
+    }
+
+    /**
+     * @see org.apache.fulcrum.security.model.basic.entity.BasicGroup#setUsersAsSet(java.util.Set)
+     */
+    public void setUsersAsSet(Set users)
+    {
+        setUsers(new UserSet(users));
+    }
+
+    /**
+     * @see org.apache.fulcrum.security.model.dynamic.entity.DynamicGroup#addRole(org.apache.fulcrum.security.entity.Role)
+     */
+    public void addRole(Role role)
+    {
+        getRoles().add(role);
+    }
+
+    /**
+     * @see org.apache.fulcrum.security.model.dynamic.entity.DynamicGroup#getRoles()
+     */
+    public RoleSet getRoles()
+    {
+        if (roleSet == null)
+        {
+            roleSet = new RoleSet();
+        }
+        else if(!(roleSet instanceof RoleSet))
+        {
+            roleSet = new RoleSet(roleSet);
+        }
+
+        return (RoleSet)roleSet;
+    }
+
+    /**
+     * @see org.apache.fulcrum.security.model.dynamic.entity.DynamicGroup#getRolesAsSet()
+     */
+    public Set getRolesAsSet()
+    {
+        return roleSet;
+    }
+
+    /**
+     * @see org.apache.fulcrum.security.model.dynamic.entity.DynamicGroup#removeRole(org.apache.fulcrum.security.entity.Role)
+     */
+    public void removeRole(Role role)
+    {
+        getRoles().remove(role);
+    }
+
+    /**
+     * @see org.apache.fulcrum.security.model.dynamic.entity.DynamicGroup#setRoles(org.apache.fulcrum.security.util.RoleSet)
+     */
+    public void setRoles(RoleSet roleSet)
+    {
+        if(roleSet != null)
+        {
+            this.roleSet = roleSet;
+        }
+        else
+        {
+            this.roleSet = new RoleSet();
+        }
+    }
+
+    /**
+     * @see org.apache.fulcrum.security.model.dynamic.entity.DynamicGroup#setRolesAsSet(java.util.Set)
+     */
+    public void setRolesAsSet(Set roles)
+    {
+        setRoles(new RoleSet(roles));
+    }
+
+    /**
+     * @see org.apache.fulcrum.security.torque.TorqueAbstractSecurityEntity#getDatabaseName()
+     */
+    public String getDatabaseName()
+    {
+        return TorqueDynamicGroupPeer.DATABASE_NAME;
+    }
+
+    /**
+     * @see org.apache.fulcrum.security.torque.TorqueAbstractSecurityEntity#retrieveAttachedObjects(java.sql.Connection)
+     */
+    public void retrieveAttachedObjects(Connection con) throws TorqueException
+    {
+        this.userSet = new UserSet();
+
+        // the generated method that allows a Connection parameter is missing
+        List usergroups = getTorqueDynamicUserGroupsJoinTorqueDynamicUser(new Criteria());
+
+        for (Iterator i = usergroups.iterator(); i.hasNext();)
+        {
+            TorqueDynamicUserGroup tdug = (TorqueDynamicUserGroup)i.next();
+            userSet.add(tdug.getTorqueDynamicUser());
+        }
+
+        this.roleSet = new RoleSet();
+
+        // the generated method that allows a Connection parameter is missing
+        List grouproles = getTorqueDynamicGroupRolesJoinTorqueDynamicRole(new Criteria());
+
+        for (Iterator i = grouproles.iterator(); i.hasNext();)
+        {
+            TorqueDynamicGroupRole tdgr = (TorqueDynamicGroupRole)i.next();
+            roleSet.add(tdgr.getTorqueDynamicRole());
+        }
+    }
+
+    /**
+     * @see org.apache.fulcrum.security.torque.TorqueAbstractSecurityEntity#update(java.sql.Connection)
+     */
+    public void update(Connection con) throws TorqueException
+    {
+        if (userSet != null)
+        {
+            Criteria criteria = new Criteria();
+
+            /* remove old entries */
+            criteria.add(TorqueDynamicUserGroupPeer.GROUP_ID, getEntityId());
+            TorqueDynamicUserGroupPeer.doDelete(criteria, con);
+
+            for (Iterator i = userSet.iterator(); i.hasNext();)
+            {
+                TorqueDynamicUser user = (TorqueDynamicUser)i.next();
+
+                TorqueDynamicUserGroup ug = new TorqueDynamicUserGroup();
+                ug.setUserId(user.getEntityId());
+                ug.setGroupId(getEntityId());
+                ug.save(con);
+            }
+        }
+
+        if (roleSet != null)
+        {
+            Criteria criteria = new Criteria();
+
+            /* remove old entries */
+            criteria.add(TorqueDynamicGroupRolePeer.GROUP_ID, getEntityId());
+            TorqueDynamicGroupRolePeer.doDelete(criteria, con);
+
+            for (Iterator i = roleSet.iterator(); i.hasNext();)
+            {
+                TorqueDynamicRole role = (TorqueDynamicRole)i.next();
+
+                TorqueDynamicGroupRole gr = new TorqueDynamicGroupRole();
+                gr.setRoleId(role.getEntityId());
+                gr.setGroupId(getEntityId());
+                gr.save(con);
+            }
+        }
+
+        try
+        {
+            save(con);
+        }
+        catch (Exception e)
+        {
+            throw new TorqueException(e);
+        }
+    }
+
+    /**
+     * @see org.apache.fulcrum.security.torque.TorqueAbstractSecurityEntity#delete()
+     */
+    public void delete() throws TorqueException
+    {
+        TorqueDynamicGroupPeer.doDelete(SimpleKey.keyFor(getEntityId()));
+    }
+}

Modified: jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/dynamic/TorqueAbstractDynamicPermission.java
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/dynamic/TorqueAbstractDynamicPermission.java?view=diff&rev=535465&r1=535464&r2=535465
==============================================================================
--- jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/dynamic/TorqueAbstractDynamicPermission.java (original)
+++ jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/dynamic/TorqueAbstractDynamicPermission.java Fri May  4 23:58:06 2007
@@ -1,189 +1,192 @@
-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.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import org.apache.fulcrum.security.entity.Role;
-import org.apache.fulcrum.security.model.dynamic.entity.DynamicPermission;
-import org.apache.fulcrum.security.torque.TorqueAbstractSecurityEntity;
-import org.apache.fulcrum.security.torque.om.TorqueDynamicPermissionPeer;
-import org.apache.fulcrum.security.torque.om.TorqueDynamicRole;
-import org.apache.fulcrum.security.torque.om.TorqueDynamicRolePermission;
-import org.apache.fulcrum.security.torque.om.TorqueDynamicRolePermissionPeer;
-import org.apache.fulcrum.security.util.RoleSet;
-import org.apache.torque.TorqueException;
-import org.apache.torque.om.SimpleKey;
-import org.apache.torque.util.Criteria;
-/**
- * This abstract class provides the SecurityInterface to the managers.
- *
- * @author <a href="mailto:tv@apache.org">Thomas Vandahl</a>
- * @version $Id:$
- */
-public abstract class TorqueAbstractDynamicPermission extends TorqueAbstractSecurityEntity
-    implements DynamicPermission
-{
-    /** a cache of role objects */
-    private Set roleSet = null;
-    
-    /**
-     * Forward reference to generated code
-     * 
-     * Get a list of association objects, pre-populated with their TorqueDynamicRole 
-     * objects.
-     * 
-     * @param criteria Criteria to define the selection of records
-     * @throws TorqueException
-     * 
-     * @return a list of Role/Permission relations
-     */
-    protected abstract List getTorqueDynamicRolePermissionsJoinTorqueDynamicRole(Criteria criteria)
-        throws TorqueException;
-
-    /**
-     * @see org.apache.fulcrum.security.model.dynamic.entity.DynamicPermission#addRole(org.apache.fulcrum.security.entity.Role)
-     */
-    public void addRole(Role role)
-    {
-        getRoles().add(role);
-    }
-
-    /**
-     * @see org.apache.fulcrum.security.model.dynamic.entity.DynamicPermission#getRoles()
-     */
-    public RoleSet getRoles()
-    {
-        if (roleSet == null)
-        {
-            roleSet = new RoleSet();
-        }
-        else if(!(roleSet instanceof RoleSet))
-        {
-            roleSet = new RoleSet(roleSet);
-        }
-
-        return (RoleSet)roleSet;
-    }
-
-    /**
-     * @see org.apache.fulcrum.security.model.dynamic.entity.DynamicPermission#getRolesAsSet()
-     */
-    public Set getRolesAsSet()
-    {
-        return roleSet;
-    }
-
-    /**
-     * @see org.apache.fulcrum.security.model.dynamic.entity.DynamicPermission#removeRole(org.apache.fulcrum.security.entity.Role)
-     */
-    public void removeRole(Role role)
-    {
-        getRoles().remove(role);
-    }
-
-    /**
-     * @see org.apache.fulcrum.security.model.dynamic.entity.DynamicPermission#setRoles(org.apache.fulcrum.security.util.RoleSet)
-     */
-    public void setRoles(RoleSet roleSet)
-    {
-        if (roleSet != null)
-        {
-            this.roleSet = roleSet;
-        }
-        else
-        {
-            this.roleSet = new RoleSet();
-        }
-    }
-
-    /**
-     * @see org.apache.fulcrum.security.model.dynamic.entity.DynamicPermission#setRolesAsSet(java.util.Set)
-     */
-    public void setRolesAsSet(Set roles)
-    {
-        setRoles(new RoleSet(roles));
-    }
-
-    /**
-     * @see org.apache.fulcrum.security.torque.TorqueAbstractSecurityEntity#getDatabaseName()
-     */
-    public String getDatabaseName()
-    {
-        return TorqueDynamicPermissionPeer.DATABASE_NAME;
-    }
-
-    /**
-     * @see org.apache.fulcrum.security.torque.TorqueAbstractSecurityEntity#retrieveAttachedObjects(java.sql.Connection)
-     */
-    public void retrieveAttachedObjects(Connection con) throws TorqueException
-    {
-        this.roleSet = new RoleSet();
-        
-        // the generated method that allows a Connection parameter is missing
-        List rolepermissions = getTorqueDynamicRolePermissionsJoinTorqueDynamicRole(new Criteria());
-
-        for (Iterator i = rolepermissions.iterator(); i.hasNext();)
-        {
-            TorqueDynamicRolePermission tdrp = (TorqueDynamicRolePermission)i.next(); 
-            roleSet.add(tdrp.getTorqueDynamicRole());
-        }
-    }
-
-    /**
-     * @see org.apache.fulcrum.security.torque.TorqueAbstractSecurityEntity#update(java.sql.Connection)
-     */
-    public void update(Connection con) throws TorqueException
-    {
-        if (roleSet != null)
-        {
-            Criteria criteria = new Criteria();
-            
-            /* remove old entries */
-            criteria.add(TorqueDynamicRolePermissionPeer.PERMISSION_ID, getEntityId());
-            TorqueDynamicRolePermissionPeer.doDelete(criteria, con);
-
-            for (Iterator i = roleSet.iterator(); i.hasNext();)
-            {
-                TorqueDynamicRole role = (TorqueDynamicRole)i.next();
-
-                TorqueDynamicRolePermission rp = new TorqueDynamicRolePermission();
-                rp.setRoleId(role.getEntityId());
-                rp.setPermissionId(getEntityId());
-                rp.save(con);
-            }
-        }
-        
-        try
-        {
-            save(con);
-        }
-        catch (Exception e)
-        {
-            throw new TorqueException(e);
-        }
-    }
-
-    /**
-     * @see org.apache.fulcrum.security.torque.TorqueAbstractSecurityEntity#delete()
-     */
-    public void delete() throws TorqueException
-    {
-        TorqueDynamicPermissionPeer.doDelete(SimpleKey.keyFor(getEntityId()));
-    }
-}
\ No newline at end of file
+package org.apache.fulcrum.security.torque.dynamic;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.fulcrum.security.entity.Role;
+import org.apache.fulcrum.security.model.dynamic.entity.DynamicPermission;
+import org.apache.fulcrum.security.torque.TorqueAbstractSecurityEntity;
+import org.apache.fulcrum.security.torque.om.TorqueDynamicPermissionPeer;
+import org.apache.fulcrum.security.torque.om.TorqueDynamicRole;
+import org.apache.fulcrum.security.torque.om.TorqueDynamicRolePermission;
+import org.apache.fulcrum.security.torque.om.TorqueDynamicRolePermissionPeer;
+import org.apache.fulcrum.security.util.RoleSet;
+import org.apache.torque.TorqueException;
+import org.apache.torque.om.SimpleKey;
+import org.apache.torque.util.Criteria;
+/**
+ * This abstract class provides the SecurityInterface to the managers.
+ *
+ * @author <a href="mailto:tv@apache.org">Thomas Vandahl</a>
+ * @version $Id:$
+ */
+public abstract class TorqueAbstractDynamicPermission extends TorqueAbstractSecurityEntity
+    implements DynamicPermission
+{
+    /** a cache of role objects */
+    private Set roleSet = null;
+
+    /**
+     * Forward reference to generated code
+     *
+     * Get a list of association objects, pre-populated with their TorqueDynamicRole
+     * objects.
+     *
+     * @param criteria Criteria to define the selection of records
+     * @throws TorqueException
+     *
+     * @return a list of Role/Permission relations
+     */
+    protected abstract List getTorqueDynamicRolePermissionsJoinTorqueDynamicRole(Criteria criteria)
+        throws TorqueException;
+
+    /**
+     * @see org.apache.fulcrum.security.model.dynamic.entity.DynamicPermission#addRole(org.apache.fulcrum.security.entity.Role)
+     */
+    public void addRole(Role role)
+    {
+        getRoles().add(role);
+    }
+
+    /**
+     * @see org.apache.fulcrum.security.model.dynamic.entity.DynamicPermission#getRoles()
+     */
+    public RoleSet getRoles()
+    {
+        if (roleSet == null)
+        {
+            roleSet = new RoleSet();
+        }
+        else if(!(roleSet instanceof RoleSet))
+        {
+            roleSet = new RoleSet(roleSet);
+        }
+
+        return (RoleSet)roleSet;
+    }
+
+    /**
+     * @see org.apache.fulcrum.security.model.dynamic.entity.DynamicPermission#getRolesAsSet()
+     */
+    public Set getRolesAsSet()
+    {
+        return roleSet;
+    }
+
+    /**
+     * @see org.apache.fulcrum.security.model.dynamic.entity.DynamicPermission#removeRole(org.apache.fulcrum.security.entity.Role)
+     */
+    public void removeRole(Role role)
+    {
+        getRoles().remove(role);
+    }
+
+    /**
+     * @see org.apache.fulcrum.security.model.dynamic.entity.DynamicPermission#setRoles(org.apache.fulcrum.security.util.RoleSet)
+     */
+    public void setRoles(RoleSet roleSet)
+    {
+        if (roleSet != null)
+        {
+            this.roleSet = roleSet;
+        }
+        else
+        {
+            this.roleSet = new RoleSet();
+        }
+    }
+
+    /**
+     * @see org.apache.fulcrum.security.model.dynamic.entity.DynamicPermission#setRolesAsSet(java.util.Set)
+     */
+    public void setRolesAsSet(Set roles)
+    {
+        setRoles(new RoleSet(roles));
+    }
+
+    /**
+     * @see org.apache.fulcrum.security.torque.TorqueAbstractSecurityEntity#getDatabaseName()
+     */
+    public String getDatabaseName()
+    {
+        return TorqueDynamicPermissionPeer.DATABASE_NAME;
+    }
+
+    /**
+     * @see org.apache.fulcrum.security.torque.TorqueAbstractSecurityEntity#retrieveAttachedObjects(java.sql.Connection)
+     */
+    public void retrieveAttachedObjects(Connection con) throws TorqueException
+    {
+        this.roleSet = new RoleSet();
+
+        // the generated method that allows a Connection parameter is missing
+        List rolepermissions = getTorqueDynamicRolePermissionsJoinTorqueDynamicRole(new Criteria());
+
+        for (Iterator i = rolepermissions.iterator(); i.hasNext();)
+        {
+            TorqueDynamicRolePermission tdrp = (TorqueDynamicRolePermission)i.next();
+            roleSet.add(tdrp.getTorqueDynamicRole());
+        }
+    }
+
+    /**
+     * @see org.apache.fulcrum.security.torque.TorqueAbstractSecurityEntity#update(java.sql.Connection)
+     */
+    public void update(Connection con) throws TorqueException
+    {
+        if (roleSet != null)
+        {
+            Criteria criteria = new Criteria();
+
+            /* remove old entries */
+            criteria.add(TorqueDynamicRolePermissionPeer.PERMISSION_ID, getEntityId());
+            TorqueDynamicRolePermissionPeer.doDelete(criteria, con);
+
+            for (Iterator i = roleSet.iterator(); i.hasNext();)
+            {
+                TorqueDynamicRole role = (TorqueDynamicRole)i.next();
+
+                TorqueDynamicRolePermission rp = new TorqueDynamicRolePermission();
+                rp.setRoleId(role.getEntityId());
+                rp.setPermissionId(getEntityId());
+                rp.save(con);
+            }
+        }
+
+        try
+        {
+            save(con);
+        }
+        catch (Exception e)
+        {
+            throw new TorqueException(e);
+        }
+    }
+
+    /**
+     * @see org.apache.fulcrum.security.torque.TorqueAbstractSecurityEntity#delete()
+     */
+    public void delete() throws TorqueException
+    {
+        TorqueDynamicPermissionPeer.doDelete(SimpleKey.keyFor(getEntityId()));
+    }
+}



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