Validate.notNull(user);
if (userGroupCache.isUserMemberOfAdminGroup(user.getId()) == true) {
// A user group "Admin" has always access.
return true;
}
final TaskNode node = taskTree.getTaskNodeById(taskId);
if (node == null) {
log.error("Task with " + taskId + " not found.");
if (throwException == true) {
throw new AccessException(taskId, accessType, operationType);
}
return false;
}
final Collection<Integer> groupIds = userGroupCache.getUserGroups(user);
if (groupIds == null) {
// No groups are assigned to this user.
if (throwException == true) {
throw new AccessException(taskId, accessType, operationType);
}
return false;
}
for (final Integer groupId : groupIds) {
if (node.hasPermission(groupId, accessType, operationType) == true) {
return true;
}
}
if (throwException == true) {
throw new AccessException(taskId, accessType, operationType);