* Creates aggregate permset representing effective perms of a user
* @param ImmutableSet<PermissionSet> permsets
* @return PermissionSet
*/
public static PermissionSet aggregatePermissionSets(ImmutableSet<PermissionSet> permsets, String compareType) {
PermissionSet permset = new PermissionSet("aggregatePermset_FakeId");
Set<String> aggregateUserPerms = new HashSet<String>();
Iterator permIter = permsets.iterator();
while (permIter.hasNext()) {
PermissionSet tempPermset = (PermissionSet) permIter.next();
if (USER_PERMS.equals(compareType)) {
aggregateUserPerms.addAll(tempPermset.getUserPerms());
} else if (SETUP_ENTITY_PERMS.equals(compareType)) {
for (SetupEntityTypes type : SetupEntityTypes.values()) {
permset.getSeaPermMap(ObjPermCategory.original)
.get(type)
.addAll(tempPermset.getSeaPermMap(
ObjPermCategory.original).get(type));
}
} else if (OBJECT_PERMS.equals(compareType)) {
// Don't do anything here since object perms does not require aggregate -- query gets all perms