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:   <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to