> Fra: Shawn McKinney [mailto:[email protected]]
> Sendt: 6. januar 2016 16:35
[snip]
> Calling sessionPermissions does one search, pulling back all permissions for a
> given user’s session (i.e. pulls back all permissions that are granted to
> their
> activated roles).
[snip]
Using sessionPermissions works great. It lead me to discover that the equals
method on Permission is ignoring object id.
We started with this
private boolean permissionExistsForSession(Permission _permission)
{
return cache.contains(_permission);
}
And ended with this
private boolean permissionExistsForSession(Permission _permission)
{
int index = cache.indexOf(_permission);
if(index > -1)
{
Permission cachedPerm = cache.get(index);
if(cachedPerm.getObjId() == null && _permission.getObjId() == null)
{
return true;
}
if(cachedPerm.getObjId() != null && _permission.getObjId() != null &&
cachedPerm.getObjId().equals(_permission.getObjId()))
{
return true;
}
}
return false;
}
Checking for object id in Permission.equals would be a nice addition :-)
// Jan