You are viewing a plain text version of this content. The canonical link for it is here.
Posted to slide-dev@jakarta.apache.org by Christopher Lenz <cm...@gmx.de> on 2001/07/16 12:17:37 UTC

[PATCH] Check if permission exists before creating it

I've changed AbstractStore.grantPermission() to check whether a 
permission exists before creating it. I'm not sure whether that's the 
appropriate place for the check, though.

(I can't currently connect to the jakarta cvs-pserver for some reason, 
so I'm including the actual code here instead of a diff, sorry.)

src/share/org/apache/slide/store/AbstractStore.java, line 576ff
================================================================
public void grantPermission(Uri uri, NodePermission permission)
    throws ServiceAccessException {
    NodePermission tempPermission = permission.cloneObject();
    tempPermission.validate(uri.toString());
    
    // Checking if the permission is already present
    Enumeration permissions = enumeratePermissions(uri);
    while (permissions.hasMoreElements()) {
        if (tempPermission.equals(permissions.nextElement())) {
            return;
        }
    }
    
    // Not present yet, so create it
    enlist(securityStore);
    try {
        securityStore.grantPermission(uri, tempPermission);
    } catch (ServiceAccessException e) {
        delist(securityStore, false);
        throw e;
    }
    delist(securityStore);
}
================================================================

-chris
________________________________________________________________
cmlenz@gmx.de