You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by "Weaver, Scott" <Sw...@rippe.com> on 2001/12/21 23:31:29 UTC

[PATCH] save methods in DBSecurityService always throwing Unknown EntityException

Why would you ALWAYS throw  an UnknownEntityException?  Is there a good
reason for this, IMOHO it is not correct.  The same thing was being done for
savePermission() and saveRole().  This will cause errors any time someone
tries to update a Group. 

I noticed this since a couple of my classes implement the Group interface
and function as a Decorator to Group objects within Turbine.


public void saveGroup( Group group )
throws DataBackendException, UnknownEntityException
    {
        boolean groupExists = false;
        try
        {
            groupExists = checkExists(group);
            if(groupExists)
            {
                Criteria criteria = GroupPeer.buildCriteria(group);
                GroupPeer.doUpdate(criteria);
            }
        }
        catch(Exception e)
        {
            throw new DataBackendException("saveGroup(Group) failed" ,e);
        }

        throw new UnknownEntityException("Unknown group '" + group + "'");
    }

It should be like this:

public void saveGroup( Group group )
throws DataBackendException, UnknownEntityException
    {
        boolean groupExists = false;
        try
        {
            groupExists = checkExists(group);
            if(groupExists)
            {
                Criteria criteria = GroupPeer.buildCriteria(group);
                GroupPeer.doUpdate(criteria);
                //this return statement prevents the unwanted
UnknownEntityException
	          return;
            }
           
        }
        catch(Exception e)
        {
            throw new DataBackendException("saveGroup(Group) failed" ,e);
        }
	  
            throw new UnknownEntityException("Unknown group '" + group +
"'");
        
       
    }

The attached patch addresses this method and both saveRole() and
savePermission()



Regards,
Scott


Re: [PATCH] save methods in DBSecurityService always throwing UnknownEntityException

Posted by John McNally <jm...@collab.net>.
patch applied, thank you

john mcnally

"Weaver, Scott" wrote:
> 
> Why would you ALWAYS throw  an UnknownEntityException?  Is there a good
> reason for this, IMOHO it is not correct.  The same thing was being done for
> savePermission() and saveRole().  This will cause errors any time someone
> tries to update a Group.
> 
> I noticed this since a couple of my classes implement the Group interface
> and function as a Decorator to Group objects within Turbine.
> 
> public void saveGroup( Group group )
> throws DataBackendException, UnknownEntityException
>     {
>         boolean groupExists = false;
>         try
>         {
>             groupExists = checkExists(group);
>             if(groupExists)
>             {
>                 Criteria criteria = GroupPeer.buildCriteria(group);
>                 GroupPeer.doUpdate(criteria);
>             }
>         }
>         catch(Exception e)
>         {
>             throw new DataBackendException("saveGroup(Group) failed" ,e);
>         }
> 
>         throw new UnknownEntityException("Unknown group '" + group + "'");
>     }
> 
> It should be like this:
> 
> public void saveGroup( Group group )
> throws DataBackendException, UnknownEntityException
>     {
>         boolean groupExists = false;
>         try
>         {
>             groupExists = checkExists(group);
>             if(groupExists)
>             {
>                 Criteria criteria = GroupPeer.buildCriteria(group);
>                 GroupPeer.doUpdate(criteria);
>                 //this return statement prevents the unwanted
> UnknownEntityException
>                   return;
>             }
> 
>         }
>         catch(Exception e)
>         {
>             throw new DataBackendException("saveGroup(Group) failed" ,e);
>         }
> 
>             throw new UnknownEntityException("Unknown group '" + group +
> "'");
> 
> 
>     }
> 
> The attached patch addresses this method and both saveRole() and
> savePermission()
> 
> Regards,
> Scott
> 
>   ------------------------------------------------------------------------
> 
>    DBSecurityEntity-always-throwing-UnknownEntity.txtName: DBSecurityEntity-always-throwing-UnknownEntity.txt
>                                                      Type: Plain Text (text/plain)
> 
>   ------------------------------------------------------------------------
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>