I have a ScriptRunner script that adds multiple permissions to scheme for a given user, group or role. But, if I run it twice, it adds duplicates. Is there a class/method that checks if a permission entity already exists? Also, how do I delete an entry via the API?
Here's the block that adds:
if(permsToAdd.any({ it == prjPerm.getKey() })) {
// add it, if not present (or we get dups)
SchemeEntity schemeEntity = new SchemeEntity(permType, permRoleId, prjPerm.getKey())
permSchemeMgr.createSchemeEntity(scheme, schemeEntity)
}