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); }
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); }
assertTrue(helper.getDescendants("node11").contains("node112")); assertTrue(helper.isValidParent("node11", null)); assertTrue(helper.isValidParent("node11", "node12")); assertFalse(helper.isValidParent("node11", "node11")); assertFalse(helper.isValidParent("node1", "node111"));