You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by ep...@apache.org on 2004/03/29 09:50:28 UTC

cvs commit: jakarta-turbine-fulcrum/security/xdocs changes.xml

epugh       2004/03/28 23:50:28

  Modified:    security/hibernate/src/java/org/apache/fulcrum/security/hibernate/dynamic
                        HibernateModelManagerImpl.java
               security/hibernate/src/java/org/apache/fulcrum/security/hibernate
                        HibernateRoleManagerImpl.java
                        HibernateGroupManagerImpl.java
                        HibernateUserManagerImpl.java
                        HibernatePermissionManagerImpl.java
               security/hibernate/src/java/org/apache/fulcrum/security/hibernate/basic
                        HibernateModelManagerImpl.java
               security/api/src/java/org/apache/fulcrum/security/model/dynamic/entity
                        DynamicUser.java DynamicRole.java DynamicGroup.java
               security/xdocs changes.xml
  Log:
  Hibernate implementation refactoring from Mike Manner.  Thanks!
  
  Revision  Changes    Path
  1.4       +54 -7     jakarta-turbine-fulcrum/security/hibernate/src/java/org/apache/fulcrum/security/hibernate/dynamic/HibernateModelManagerImpl.java
  
  Index: HibernateModelManagerImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-fulcrum/security/hibernate/src/java/org/apache/fulcrum/security/hibernate/dynamic/HibernateModelManagerImpl.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- HibernateModelManagerImpl.java	10 Jan 2004 16:13:49 -0000	1.3
  +++ HibernateModelManagerImpl.java	29 Mar 2004 07:50:27 -0000	1.4
  @@ -201,9 +201,9 @@
           }
       }
       /**
  -	 * Revokes all permissions from a Role.
  +	 * Revokes all permissions and groups from a Role.
   	 * 
  -	 * This method is user when deleting a Role.
  +	 * This method is used when deleting a Role.
   	 * 
   	 * @param role the Role
   	 * @throws DataBackendException if there was an error accessing the data backend.
  @@ -220,8 +220,16 @@
               {
                   ((DynamicRole) role).setPermissions(new PermissionSet());
   				getPersistenceHelper().updateEntity(role);
  -                return;
  -            }
  +				
  +				Object groups[] = ((DynamicRole) role).getGroups().toArray();
  +				
  +				for (int i = 0; i < groups.length; i++)
  +				{
  +					Group group = (Group) groups[i];
  +					revoke(group, role);
  +				}	
  +				return;            
  +			}
           }
           catch (Exception e)
           {
  @@ -242,7 +250,7 @@
   	 * @throws DataBackendException if there was an error accessing the data backend.
   	 * @throws UnknownEntityException if the account is not present.
   	 */
  -    public void grant(User user, Group group) throws DataBackendException, UnknownEntityException
  +    public synchronized void grant(User user, Group group) throws DataBackendException, UnknownEntityException
       {
           boolean groupExists = false;
           boolean userExists = false;
  @@ -287,7 +295,7 @@
   	 * @throws DataBackendException if there was an error accessing the data backend.
   	 * @throws UnknownEntityException if the user or group is not present.
   	 */
  -    public void revoke(User user, Group group) throws DataBackendException, UnknownEntityException
  +    public synchronized void revoke(User user, Group group) throws DataBackendException, UnknownEntityException
       {
           boolean groupExists = false;
           boolean userExists = false;
  @@ -398,5 +406,44 @@
               throw new UnknownEntityException("Unknown role '" + role.getName() + "'");
           }
       }
  -
  +    
  +    /**
  +     * Revokes all users and roles from a group
  +     * 
  +     * This method is used when deleting a group.
  +     * 
  +     * @param group the Group.
  +     * @throws DataBackendException if there was an error accessing the data backend.
  +     * @throws UnknownEntityException if the account is not present.
  +     */
  +    public synchronized void revokeAll(Group group)
  +	throws DataBackendException, UnknownEntityException
  +	{
  +    	boolean groupExists = false;
  +    	groupExists = getGroupManager().checkExists(group);
  +    	if (groupExists)
  +    	{
  +    		Object users[] = ((DynamicGroup) group).getUsers().toArray();
  +   		
  +    		for (int i = 0; i < users.length; i++)
  +    		{
  +    			User user = (User) users[i];
  +    			revoke(user, group);
  +    		}
  +
  +    		Object roles[] = ((DynamicGroup) group).getRoles().toArray();
  +    		
  +    		for (int i = 0; i < roles.length; i++)
  +    		{
  +    			Role role = (Role) roles[i];
  +    			revoke(group, role);
  +    		}
  +
  +    		return;
  +    	}
  +    	else
  +    	{
  +    		throw new UnknownEntityException("Unknown group '" + group.getName() + "'");
  +    	}
  +    }
   }
  
  
  
  1.2       +57 -7     jakarta-turbine-fulcrum/security/hibernate/src/java/org/apache/fulcrum/security/hibernate/HibernateRoleManagerImpl.java
  
  Index: HibernateRoleManagerImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-fulcrum/security/hibernate/src/java/org/apache/fulcrum/security/hibernate/HibernateRoleManagerImpl.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- HibernateRoleManagerImpl.java	5 Dec 2003 23:20:24 -0000	1.1
  +++ HibernateRoleManagerImpl.java	29 Mar 2004 07:50:27 -0000	1.2
  @@ -107,19 +107,18 @@
       /**
         * Determines if the <code>Role</code> exists in the security system.
         *
  -      * @param role a <code>Role</code> value
  -      * @return true if the role exists in the system, false otherwise
  +      * @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.
  -      * @throws Exception A generic exception.
         */
  -    public boolean checkExists(Role role) throws DataBackendException
  +    public boolean checkExists(String roleName) throws DataBackendException
       {
           List roles;
           try
           {
               
  -            roles = getPersistenceHelper().retrieveSession().find("from " + Role.class.getName() + " sr where sr.name=?", role.getName(), Hibernate.STRING);
  +            roles = getPersistenceHelper().retrieveSession().find("from " + Role.class.getName() + " sr where sr.name=?", roleName, Hibernate.STRING);
   
           }
           catch (HibernateException e)
  @@ -128,7 +127,7 @@
           }
           if (roles.size() > 1)
           {
  -            throw new DataBackendException("Multiple roles with same name '" + role.getName() + "'");
  +            throw new DataBackendException("Multiple roles with same name '" + roleName + "'");
           }
           return (roles.size() == 1);
       }
  @@ -211,5 +210,56 @@
   			persistenceHelper = (PersistenceHelper)resolve(PersistenceHelper.ROLE);
   		}
   		return persistenceHelper;
  +	}
  +	
  +	/**
  +	 * Determines if the <code>Role</code> exists in the security system.
  +	 *
  +	 * @param role a <code>Role</code> value
  +	 * @return true if the role exists in the system, false otherwise
  +	 * @throws DataBackendException when more than one Role with
  +	 *         the same name exists.
  +	 */
  +	public boolean checkExists(Role role) throws DataBackendException
  +	{
  +		return checkExists(role.getName());
  +	}
  +	
  +	/**
  +	 * 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 = null;
  +
  +		if (id != null)
  +			try {
  +				List roles =
  +					getPersistenceHelper().retrieveSession().find(
  +							"from " + Role.class.getName() + " sr where sr.id=?",
  +							id,
  +							Hibernate.LONG);
  +				if (roles.size() == 0) {
  +					throw new UnknownEntityException(
  +							"Could not find role by id " + id);
  +				}
  +				role = (Role) roles.get(0);
  +				
  +			} catch (HibernateException e) {
  +				throw new DataBackendException(
  +						"Error retriving role information",
  +						e);
  +			}
  +			
  +		return role;
   	}
   }
  
  
  
  1.2       +76 -26    jakarta-turbine-fulcrum/security/hibernate/src/java/org/apache/fulcrum/security/hibernate/HibernateGroupManagerImpl.java
  
  Index: HibernateGroupManagerImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-fulcrum/security/hibernate/src/java/org/apache/fulcrum/security/hibernate/HibernateGroupManagerImpl.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- HibernateGroupManagerImpl.java	5 Dec 2003 23:20:24 -0000	1.1
  +++ HibernateGroupManagerImpl.java	29 Mar 2004 07:50:27 -0000	1.2
  @@ -186,34 +186,45 @@
        * @return true if the group exists in the system, false otherwise
        * @throws DataBackendException when more than one Group with
        *         the same name exists.
  -     * @throws Exception A generic exception.
        */
       public boolean checkExists(Group group) throws DataBackendException
       {
  -        List groups;
  -        try
  -        {
  +    	return checkExists(group.getName());
  +    }
  +    /**
  +     * Determines if the <code>Group</code> exists in the security system.
  +     *
  +     * @param groupName a <code>Group</code> value
  +     * @return true if the group name exists in the system, false otherwise
  +     * @throws DataBackendException when more than one Group with
  +     *         the same name exists.
  +     */
  +    public boolean checkExists(String groupName) throws DataBackendException
  +	{
  +    	List groups;
  +    	try
  +		{
   
  -            groups =
  -			getPersistenceHelper().retrieveSession().find(
  -                    "from "
  -                        + Group.class.getName()
  -                        + " sg where sg.name=?",
  -                    group.getName(),
  -                    Hibernate.STRING);
  -        }
  -        catch (HibernateException e)
  -        {
  -            throw new DataBackendException(
  -                "Error retriving user information",
  -                e);
  -        }
  -        if (groups.size() > 1)
  -        {
  -            throw new DataBackendException(
  -                "Multiple groups with same name '" + group.getName() + "'");
  -        }
  -        return (groups.size() == 1);
  +    		groups =
  +    			getPersistenceHelper().retrieveSession().find(
  +    					"from "
  +    					+ Group.class.getName()
  +						+ " sg where sg.name=?",
  +						groupName,
  +						Hibernate.STRING);
  +    	}
  +    	catch (HibernateException e)
  +		{
  +    		throw new DataBackendException(
  +    				"Error retriving user information",
  +					e);
  +    	}
  +    	if (groups.size() > 1)
  +    	{
  +    		throw new DataBackendException(
  +    				"Multiple groups with same name '" + groupName + "'");
  +    	}
  +    	return (groups.size() == 1);
       }
       /**
       * Creates a new group with specified attributes.
  @@ -244,4 +255,43 @@
           return persistenceHelper;
       }
   
  +    /**
  +     * Retrieve a Group object with specified id.
  +     * 
  +     * @param id
  +     *            the id of the Group.
  +     * @return an object representing the Group with specified id.
  +     * @throws DataBackendException
  +     *             if there was an error accessing the data backend.
  +     * @throws UnknownEntityException
  +     *             if the group does not exist.
  +     */
  +    public Group getGroupById(Object id)
  +	throws DataBackendException, UnknownEntityException {
  +    	
  +    	Group group = null;
  +
  +    	if (id != null)
  +    		try {
  +    			List groups =
  +    				getPersistenceHelper().retrieveSession().find(
  +    						"from " + Group.class.getName() + " sr where sr.id=?",
  +							id,
  +							Hibernate.LONG);
  +    			if (groups.size() == 0) {
  +    				throw new UnknownEntityException(
  +    						"Could not find group by id " + id);
  +    			}
  +    			group = (Group) groups.get(0);
  +    			
  +    		} catch (HibernateException e) {
  +    			throw new DataBackendException(
  +    					"Error retriving group information",
  +						e);
  +    		}
  +    		
  +    		return group;
  +    }
  +    
  +    
   }
  
  
  
  1.3       +38 -1     jakarta-turbine-fulcrum/security/hibernate/src/java/org/apache/fulcrum/security/hibernate/HibernateUserManagerImpl.java
  
  Index: HibernateUserManagerImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-fulcrum/security/hibernate/src/java/org/apache/fulcrum/security/hibernate/HibernateUserManagerImpl.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- HibernateUserManagerImpl.java	10 Jan 2004 16:13:49 -0000	1.2
  +++ HibernateUserManagerImpl.java	29 Mar 2004 07:50:27 -0000	1.3
  @@ -230,4 +230,41 @@
   		return persistenceHelper;
   	}    
       
  +	/**
  +	 * 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 = null;
  +
  +		if (id != null)
  +			try {
  +				List users =
  +					getPersistenceHelper().retrieveSession().find(
  +							"from " + User.class.getName() + " su where su.id=?",
  +							id,
  +							Hibernate.LONG);
  +				if (users.size() == 0) {
  +					throw new UnknownEntityException(
  +							"Could not find user by id " + id);
  +				}
  +				user = (User) users.get(0);
  +				//session.close();
  +			} catch (HibernateException e) {
  +				throw new DataBackendException(
  +						"Error retriving user information",
  +						e);
  +			}
  +			
  +		return user;
  +	}
   }
  
  
  
  1.2       +56 -8     jakarta-turbine-fulcrum/security/hibernate/src/java/org/apache/fulcrum/security/hibernate/HibernatePermissionManagerImpl.java
  
  Index: HibernatePermissionManagerImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-fulcrum/security/hibernate/src/java/org/apache/fulcrum/security/hibernate/HibernatePermissionManagerImpl.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- HibernatePermissionManagerImpl.java	5 Dec 2003 23:20:24 -0000	1.1
  +++ HibernatePermissionManagerImpl.java	29 Mar 2004 07:50:27 -0000	1.2
  @@ -127,20 +127,19 @@
       /**
       * Determines if the <code>Permission</code> exists in the security system.
       *
  -    * @param permission a <code>Permission</code> value
  -    * @return true if the permission exists in the system, false otherwise
  +    * @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.
  -    * @throws Exception A generic exception.
       */
  -    public boolean checkExists(Permission permission) throws DataBackendException
  +    public boolean checkExists(String permissionName) throws DataBackendException
       {
           List permissions;
           try
           {
           
               permissions =
  -			getPersistenceHelper().retrieveSession().find("from " + Permission.class.getName() + " sr where sr.name=?", permission.getName(), Hibernate.STRING);
  +			getPersistenceHelper().retrieveSession().find("from " + Permission.class.getName() + " sp where sp.name=?", permissionName, Hibernate.STRING);
   		
           }
           catch (HibernateException e)
  @@ -149,7 +148,7 @@
           }
           if (permissions.size() > 1)
           {
  -            throw new DataBackendException("Multiple permissions with same name '" + permission.getName() + "'");
  +            throw new DataBackendException("Multiple permissions with same name '" + permissionName + "'");
           }
           return (permissions.size() == 1);
       }
  @@ -203,5 +202,54 @@
   		}
   		return persistenceHelper;
   	}
  -   
  +	/**
  +	 * Determines if the <code>Permission</code> exists in the security system.
  +	 *
  +	 * @param permission a <code>Permission</code> value
  +	 * @return true if the permission exists in the system, false otherwise
  +	 * @throws DataBackendException when more than one Permission with
  +	 *         the same name exists.
  +	 */
  +	public boolean checkExists(Permission permission) throws DataBackendException
  +	{
  +		return checkExists(permission.getName());
  +	}
  +	
  +	/**
  +	 * 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 = null;
  +
  +		if (id != null)
  +			try {
  +				List permissions =
  +					getPersistenceHelper().retrieveSession().find(
  +							"from " + Permission.class.getName() + " sp where sp.id=?",
  +							id,
  +							Hibernate.LONG);
  +				if (permissions.size() == 0) {
  +					throw new UnknownEntityException(
  +							"Could not find permission by id " + id);
  +				}
  +				permission = (Permission) permissions.get(0);
  +				
  +			} catch (HibernateException e) {
  +				throw new DataBackendException(
  +						"Error retriving permission information",
  +						e);
  +			}
  +			
  +		return permission;
  +	}
   }
  
  
  
  1.4       +3 -3      jakarta-turbine-fulcrum/security/hibernate/src/java/org/apache/fulcrum/security/hibernate/basic/HibernateModelManagerImpl.java
  
  Index: HibernateModelManagerImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-fulcrum/security/hibernate/src/java/org/apache/fulcrum/security/hibernate/basic/HibernateModelManagerImpl.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- HibernateModelManagerImpl.java	10 Jan 2004 16:13:49 -0000	1.3
  +++ HibernateModelManagerImpl.java	29 Mar 2004 07:50:27 -0000	1.4
  @@ -86,7 +86,7 @@
   	 * @throws DataBackendException if there was an error accessing the data backend.
   	 * @throws UnknownEntityException if the account is not present.
   	 */
  -    public void grant(User user, Group group) throws DataBackendException, UnknownEntityException
  +    public synchronized void grant(User user, Group group) throws DataBackendException, UnknownEntityException
       {
           boolean groupExists = false;
           boolean userExists = false;
  @@ -132,7 +132,7 @@
   	 * @throws DataBackendException if there was an error accessing the data backend.
   	 * @throws UnknownEntityException if the user or group is not present.
   	 */
  -    public void revoke(User user, Group group) throws DataBackendException, UnknownEntityException
  +    public synchronized void revoke(User user, Group group) throws DataBackendException, UnknownEntityException
       {
           boolean groupExists = false;
           boolean userExists = false;
  
  
  
  1.2       +16 -8     jakarta-turbine-fulcrum/security/api/src/java/org/apache/fulcrum/security/model/dynamic/entity/DynamicUser.java
  
  Index: DynamicUser.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-fulcrum/security/api/src/java/org/apache/fulcrum/security/model/dynamic/entity/DynamicUser.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DynamicUser.java	5 Dec 2003 23:29:11 -0000	1.1
  +++ DynamicUser.java	29 Mar 2004 07:50:27 -0000	1.2
  @@ -71,7 +71,7 @@
   public class DynamicUser extends SecurityEntityImpl implements User
   {
       private String password;
  -    private GroupSet groups = new GroupSet();
  +    private Set groupSet = new GroupSet();
   
   
       /**
  @@ -93,14 +93,22 @@
       */
       public GroupSet getGroups()
       {
  -        return groups;
  +    	if( groupSet instanceof GroupSet )
  +    		return (GroupSet) groupSet;
  +    	else {
  +    		groupSet = new GroupSet(groupSet);
  +    		return (GroupSet)groupSet;
  +    	}
       }
       /**
        * @param groups
        */
       public void setGroups(GroupSet groups)
       {
  -        this.groups = groups;
  +    	if( groups != null )
  +    		this.groupSet = groups;
  +    	else
  +    		this.groupSet = new GroupSet();
       }
       public void removeGroup(Group group)
       {
  @@ -111,12 +119,12 @@
           getGroups().add(group);
       }
   
  -	void setGroupsAsSet(Set groups)
  +	public void setGroupsAsSet(Set groups)
   	{
  -		this.getGroups().add(groups);
  +		this.groupSet = groups;
   	}
  -	Set getGroupsAsSet()
  +	public Set getGroupsAsSet()
   	{
  -		return getGroups().getSet();
  +		return groupSet;
   	}
   }
  
  
  
  1.2       +30 -14    jakarta-turbine-fulcrum/security/api/src/java/org/apache/fulcrum/security/model/dynamic/entity/DynamicRole.java
  
  Index: DynamicRole.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-fulcrum/security/api/src/java/org/apache/fulcrum/security/model/dynamic/entity/DynamicRole.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DynamicRole.java	5 Dec 2003 23:29:10 -0000	1.1
  +++ DynamicRole.java	29 Mar 2004 07:50:27 -0000	1.2
  @@ -72,34 +72,42 @@
    */
   public class DynamicRole extends SecurityEntityImpl implements Role
   {
  -    private PermissionSet permissionSet = new PermissionSet();
  +    private Set permissionSet = new PermissionSet();
   
  -    private GroupSet groupSet = new GroupSet();
  +    private Set groupSet = new GroupSet();
       /**
        * @return
        */
       public PermissionSet getPermissions()
       {
  -        return permissionSet;
  +    	if( permissionSet instanceof PermissionSet )
  +    		return (PermissionSet) permissionSet;
  +    	else {
  +    		permissionSet = new PermissionSet(permissionSet);
  +    		return (PermissionSet)permissionSet;
  +    	}
       }
       /**
        * @return
        */
       public Set getPermissionsAsSet()
       {
  -        return permissionSet.getSet();
  +        return permissionSet;
       }
   
  -    void setPermissionsAsSet(Set permissions)
  +    public void setPermissionsAsSet(Set permissions)
       {
  -        this.getPermissions().add(permissions);
  +        this.permissionSet = permissions;;
       }
       /**
        * @param permissionSet
        */
       public void setPermissions(PermissionSet permissionSet)
       {
  -        this.permissionSet = permissionSet;
  +    	if( permissionSet != null )
  +    		this.permissionSet = permissionSet;
  +    	else
  +    		this.permissionSet = new PermissionSet();
       }
   
       /**
  @@ -124,14 +132,22 @@
       	*/
       public GroupSet getGroups()
       {
  -        return groupSet;
  +    	if( groupSet instanceof GroupSet )
  +    		return (GroupSet) groupSet;
  +    	else {
  +    		groupSet = new GroupSet(groupSet);
  +    		return (GroupSet)groupSet;
  +    	}
       }
       /**
       	* @param groupSet
       	*/
       public void setGroups(GroupSet groupSet)
       {
  -        this.groupSet = groupSet;
  +    	if( groupSet != null )
  +    		this.groupSet = groupSet;
  +    	else
  +    		this.groupSet = new GroupSet();
       }
   
       /**
  @@ -151,12 +167,12 @@
           getGroups().remove(group);
       }
   
  -    void setGroupsAsSet(Set groups)
  +    public void setGroupsAsSet(Set groups)
       {
  -        this.getGroups().add(groups);
  +        this.groupSet = groups;
       }
  -    Set getGroupsAsSet()
  +    public Set getGroupsAsSet()
       {
  -        return getGroups().getSet();
  +        return groupSet;
       }
   }
  
  
  
  1.2       +29 -13    jakarta-turbine-fulcrum/security/api/src/java/org/apache/fulcrum/security/model/dynamic/entity/DynamicGroup.java
  
  Index: DynamicGroup.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-fulcrum/security/api/src/java/org/apache/fulcrum/security/model/dynamic/entity/DynamicGroup.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DynamicGroup.java	5 Dec 2003 23:29:10 -0000	1.1
  +++ DynamicGroup.java	29 Mar 2004 07:50:27 -0000	1.2
  @@ -72,14 +72,19 @@
    */
   public class DynamicGroup extends SecurityEntityImpl implements Group
   {
  -    private RoleSet roleSet = new RoleSet();
  -    private UserSet userSet = new UserSet();
  +    private Set roleSet = new RoleSet();
  +    private Set userSet = new UserSet();
       /**
        * @return
        */
       public UserSet getUsers()
       {
  -        return userSet;
  +    	if( userSet instanceof UserSet )
  +    		return (UserSet) userSet;
  +    	else {
  +    		userSet = new UserSet(userSet);
  +    		return (UserSet)userSet;
  +    	}
       }
   
       /**
  @@ -87,13 +92,16 @@
        */
       public void setUsers(UserSet userSet)
       {
  -        this.userSet = userSet;
  +    	if( userSet != null )
  +    		this.userSet = userSet;
  +    	else
  +    		this.userSet = new UserSet();
       }
       
   	/**
   	 * @return
   	 */
  -	public UserSet getUsersAsSet()
  +	public Set getUsersAsSet()
   	{
   		return userSet;
   	}
  @@ -103,7 +111,7 @@
   	 */
   	public void setUsersAsSet(Set users)
   	{
  -		getUsers().add(users);
  +		this.userSet = users;
   	}    
   
       /**
  @@ -111,14 +119,22 @@
        */
       public RoleSet getRoles()
       {
  -        return roleSet;
  +    	if( roleSet instanceof RoleSet )
  +    		return (RoleSet) roleSet;
  +    	else {
  +    		roleSet = new RoleSet(roleSet);
  +    		return (RoleSet)roleSet;
  +    	}
       }
       /**
        * @param roleSet
        */
       public void setRoles(RoleSet roleSet)
       {
  -        this.roleSet = roleSet;
  +    	if( roleSet != null )
  +    		this.roleSet = roleSet;
  +    	else
  +    		this.roleSet = new RoleSet();
       }
       public void addRole(Role role)
       {
  @@ -138,12 +154,12 @@
           getUsers().remove(user);
       }
       
  -	void setRolesAsSet(Set roles)
  +	public void setRolesAsSet(Set roles)
   	{
  -		this.getRoles().add(roles);
  +		this.roleSet = roles;
   	}
  -	Set getRolesAsSet()
  +	public Set getRolesAsSet()
   	{
  -		return getRoles().getSet();
  +		return roleSet;
   	}    
   }
  
  
  
  1.14      +12 -5     jakarta-turbine-fulcrum/security/xdocs/changes.xml
  
  Index: changes.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-fulcrum/security/xdocs/changes.xml,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- changes.xml	10 Jan 2004 16:16:11 -0000	1.13
  +++ changes.xml	29 Mar 2004 07:50:27 -0000	1.14
  @@ -6,18 +6,25 @@
     </properties>
   
     <body>
  -  	<release version="1.0-alpha-6" date="in cvs">
  +    <release version="1.0-alpha-7" date="in cvs">
  +      <action dev="mmanner" type="add">
  +        Change Dynamic* entity objects to use Set.  Refactored Hibernate implementation of Security to 
  +        use more efficient deletion when doing oneshot deletes during revokeAll methods.  Added get[Entity]ById()
  +        method as well.  Change grants/revokes to be Synchronizied.
  +      </action>
  +    </release>  
  +    <release version="1.0-alpha-6" date="in cvs">
         <action dev="epugh" type="add">
  -	  Added getAllUsers() to UserManager
  +    Added getAllUsers() to UserManager
         </action>
       </release>
       <release version="1.0-alpha-4" date="in cvs">
         <action dev="epugh" type="add">
  -	  Added ThreadSafe marker interface to AbstractManager.
  -      </action>        	
  +    Added ThreadSafe marker interface to AbstractManager.
  +      </action>         
         <action dev="epugh" type="add">
         Added the "Basic" model and supplied implementations for memory, NT, and Hibernate.
  -      </action>        	
  +      </action>         
         <action dev="epugh" type="add">
         Added the "Basic" model and supplied implementations for memory, NT, and Hibernate.
         </action>       
  
  
  

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


Re: cvs commit: jakarta-turbine-fulcrum/security/xdocs changes.xml

Posted by Angelo Turetta <at...@commit.it>.
----- Original Message ----- 
From: <ep...@apache.org>


> epugh       2004/03/28 23:50:28
>
>   Modified:
security/hibernate/src/java/org/apache/fulcrum/security/hibernate/dynamic
>                         HibernateModelManagerImpl.java
>
security/hibernate/src/java/org/apache/fulcrum/security/hibernate
>                         HibernateRoleManagerImpl.java
>                         HibernateGroupManagerImpl.java
>                         HibernateUserManagerImpl.java
>                         HibernatePermissionManagerImpl.java
>
security/hibernate/src/java/org/apache/fulcrum/security/hibernate/basic
>                         HibernateModelManagerImpl.java
>
security/api/src/java/org/apache/fulcrum/security/model/dynamic/entity
>                         DynamicUser.java DynamicRole.java
DynamicGroup.java
>                security/xdocs changes.xml
>   Log:
>   Hibernate implementation refactoring from Mike Manner.  Thanks!

I just noticed that most of the code changed by this patch now uses tabs
instead of spaces for indentation.

I suppose that was unintentional...

Angelo.


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