Source:
<code>List<WorkflowAction> filterActions(final List<WorkflowAction> actions, final Role role, final Permissionable permissionable) throws DotDataException { final List<WorkflowAction> permissionables = new ArrayList<>(actions); if (permissionables.isEmpty()) { Logger.debug(this, () -> " No actions were passed. " ); return permissionables; } <START> <END> try { final User user = userAPI.loadUserById(role.getRoleKey()); Logger.debug(this, () -> " Role :" + role.getName() + " is mapped to a user, filtering based on user permissions." ); return filterActions(permissionables, user, false, permissionable); } catch (Exception nsu) { Logger.debug(this, () -> "Unable to determine role belongs to a user."); } final Iterator<WorkflowAction> workflowActionIterator = permissionables.iterator(); final List<Role> specialRolesHierarchy = getSpecialRolesByPrecedence(); final int index = specialRolesHierarchy.indexOf(role); if (index >= 0) { Logger.debug(this, () -> " Filtering by special roles." ); final List<Role> rolesSublist = specialRolesHierarchy .subList(index, specialRolesHierarchy.size()); while (workflowActionIterator.hasNext()) { final WorkflowAction workflowAction = workflowActionIterator.next(); if (!isAnyRolePresent(workflowAction, rolesSublist)) { workflowActionIterator.remove(); } } return permissionables; } Logger.debug(this, () -> " Filtering by regular roles. " ); final Set<Role> collectedRoles = collectChildRoles(role); while (workflowActionIterator.hasNext()) { final WorkflowAction workflowAction = workflowActionIterator.next(); if (!isAnyRolePresent(workflowAction, collectedRoles, permissionable)) { workflowActionIterator.remove(); } } return permissionables; }</code><technical_language>I missing validation for cmsAdminRole, meaning, if _role_ is a CMS Admin Role return actions</technical_language>

Target:
List<WorkflowAction> filterActions(final List<WorkflowAction> actions, final Role role, final Permissionable permissionable) throws DotDataException { final List<WorkflowAction> permissionables = new ArrayList<>(actions); if (permissionables.isEmpty()) { Logger.debug(this, () -> " No actions were passed. " ); return permissionables; } try { final User user = userAPI.loadUserById(role.getRoleKey()); Logger.debug(this, () -> " Role :" + role.getName() + " is mapped to a user, filtering based on user permissions." ); return filterActions(permissionables, user, RESPECT_FRONTEND_ROLES, permissionable); } catch (Exception nsu) { Logger.debug(this, () -> "Unable to determine role belongs to a user."); } if ((role != null) && (role.equals(cmsAdminRole) || cmsAdminRole.getRoleKey() .equals(role.getRoleKey()))) { Logger.debug(this, () -> "Admin role. returning all actions."); return actions; } final Iterator<WorkflowAction> workflowActionIterator = permissionables.iterator(); final List<Role> specialRolesHierarchy = getSpecialRolesByPrecedence(); final int index = specialRolesHierarchy.indexOf(role); if (index >= 0) { Logger.debug(this, () -> " Filtering by special roles." ); final List<Role> rolesSublist = specialRolesHierarchy .subList(index, specialRolesHierarchy.size()); while (workflowActionIterator.hasNext()) { final WorkflowAction workflowAction = workflowActionIterator.next(); if (!isAnyRolePresent(workflowAction, rolesSublist)) { workflowActionIterator.remove(); } } return permissionables; } Logger.debug(this, () -> " Filtering by regular roles. " ); final Set<Role> collectedRoles = collectChildRoles(role); while (workflowActionIterator.hasNext()) { final WorkflowAction workflowAction = workflowActionIterator.next(); if (!isAnyRolePresent(workflowAction, collectedRoles, permissionable)) { workflowActionIterator.remove(); } } return permissionables; }