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

Index: src/java/org/apache/turbine/services/security/db/DBSecurityService.java
===================================================================
RCS file: 
/home/cvspublic/jakarta-turbine-2/src/java/org/apache/turbine/services/security/db/DBSecurityService.java,v
retrieving revision 1.3
diff -u -r1.3 DBSecurityService.java
--- src/java/org/apache/turbine/services/security/db/DBSecurityService.java     
2001/12/14 17:18:52     1.3
+++ src/java/org/apache/turbine/services/security/db/DBSecurityService.java     
+2001/12/21 22:24:13
@@ -621,6 +621,7 @@
             {
                 Criteria criteria = GroupPeer.buildCriteria(group);
                 GroupPeer.doUpdate(criteria);
+                return;
             }
         }
         catch(Exception e)
@@ -648,6 +649,7 @@
             {
                 Criteria criteria = RolePeer.buildCriteria(role);
                 RolePeer.doUpdate(criteria);
+                return;
             }
         }
         catch(Exception e)
@@ -675,6 +677,7 @@
             {
                 Criteria criteria = PermissionPeer.buildCriteria(permission);
                 PermissionPeer.doUpdate(criteria);
+                return;
             }
         }
         catch(Exception e)

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

Reply via email to