Reputation: 1
How to check programmatically if the currently connected user have access rights to delete the folder or a document in content engine object store? Can I do this with folder.getAccessAllowed() method and AccessLevel.* constants? (CE 5.0)
Upvotes: 0
Views: 2561
Reputation: 750
Here is a way:
int accessAllowed = document.getAccessAllowed();
if (checkRight(accessAllowed, AccessRight.DELETE))
{
log.trace("Access level "
+ AccessRight.DELETE.toString() + " is present");
}
private boolean checkRight(int rights, AccessRight ar)
{
return (rights & ar.getValue()) != 0;
}
Upvotes: 0
Reputation: 5782
AccessLevel
is meant to represent a set of individual access rights. To check for specific right you should use something like this:
(object.getAccessAllowed() & AccessRight.DELETE_AS_INT) == AccessRight.DELETE_AS_INT
Upvotes: 2