public void setParentRole(GeoServerRole role, GeoServerRole parentRole) throws IOException { RoleHierarchyHelper hhelper = new RoleHierarchyHelper(getParentMappings()); if (hhelper.isValidParent( role.getAuthority(), parentRole == null ? null : parentRole.getAuthority()) == false) throw new IOException( parentRole.getAuthority() + " is not a valid parent for " + role.getAuthority()); checkRole(role); if (parentRole == null) { helper.role_parentMap.remove(role); } else { checkRole(parentRole); helper.role_parentMap.put(role, parentRole); } setModified(true); }
List<String> computeAllowableParentRoles(GeoServerRole role) throws IOException { Map<String, String> parentMappings = getRoleService(roleServiceName).getParentMappings(); if (role != null && StringUtils.hasLength(role.getAuthority())) { // filter out roles already used as parents RoleHierarchyHelper helper = new RoleHierarchyHelper(parentMappings); Set<String> parents = new HashSet<String>(parentMappings.keySet()); parents.removeAll(helper.getDescendants(role.getAuthority())); parents.remove(role.getAuthority()); return new ArrayList(parents); } else { // no rolename given, we are creating a new one return new ArrayList(parentMappings.keySet()); } }
List<String> computeAllowableParentRoles(GeoServerRole role) throws IOException { Map<String, String> parentMappings = getRoleService(roleServiceName).getParentMappings(); if (role != null && StringUtils.hasLength(role.getAuthority())) { //filter out roles already used as parents RoleHierarchyHelper helper = new RoleHierarchyHelper(parentMappings); Set<String> parents = new HashSet<String>(parentMappings.keySet()); parents.removeAll(helper.getDescendants(role.getAuthority())); parents.remove(role.getAuthority()); return new ArrayList(parents); } else { // no rolename given, we are creating a new one return new ArrayList(parentMappings.keySet()); } }
List<String> computeAllowableParentRoles(GeoServerRole role) throws IOException { Map<String, String> parentMappings = getRoleService(roleServiceName).getParentMappings(); if (!role.getAuthority().equals(GeoServerRole.NULL_ROLE.getAuthority()) ) { //filter out roles already used as parents RoleHierarchyHelper helper = new RoleHierarchyHelper(parentMappings); Set<String> parents = new HashSet<String>(parentMappings.keySet()); parents.removeAll(helper.getDescendants(role.getAuthority())); parents.remove(role.getAuthority()); return new ArrayList(parents); } else { // no rolename given, we are creating a new one return new ArrayList(parentMappings.keySet()); } }
public void setParentRole(GeoServerRole role, GeoServerRole parentRole) throws IOException { RoleHierarchyHelper helper = new RoleHierarchyHelper(getParentMappings()); if (helper.isValidParent(role.getAuthority(), parentRole==null ? null : parentRole.getAuthority())==false) throw new IOException(parentRole.getAuthority() + " is not a valid parent for " + role.getAuthority()); Connection con = null; PreparedStatement ps = null; try { con = getConnection(); ps = getDMLStatement("roles.parentUpdate", con); if (parentRole == null) ps.setNull(1, Types.VARCHAR); else ps.setString(1,parentRole.getAuthority()); ps.setString(2,role.getAuthority()); ps.execute(); } catch (SQLException ex) { throw new IOException(ex); } finally { closeFinally(con, ps, null); } setModified(true); }
{"node112", "node11"}, }); RoleHierarchyHelper helper = new RoleHierarchyHelper(map);
{"node2", "node1"} }); RoleHierarchyHelper helper = new RoleHierarchyHelper(map); boolean fail;
@Test public void testInValidTree1() throws Exception { Map<String, String> map = createFromArray(new String[][] {{"node1", "node1"}}); RoleHierarchyHelper helper = new RoleHierarchyHelper(map); boolean fail;