@Override public String apply(String input) { return PathUtils.getAncestorPath(input, level); } });
@Override public String apply(String input) { return PathUtils.getAncestorPath(input, level); } });
@Override public String apply(String input) { return PathUtils.getAncestorPath(input, level); } });
/** * Get the parent of a path. The parent of the root path ("/") is the root * path. * * @param path the path * @return the parent path */ @NotNull public static String getParentPath(String path) { return getAncestorPath(path, 1); }
/** * Get the parent of a path. The parent of the root path ("/") is the root * path. * * @param path the path * @return the parent path */ @Nonnull public static String getParentPath(String path) { return getAncestorPath(path, 1); }
private String getPathPrefix(String indexPath) { // 2 = /oak:index/<index name> String parentPath = PathUtils.getAncestorPath(indexPath, 2); return PathUtils.denotesRoot(parentPath) ? "" : parentPath; }
private String getPathPrefix() { // 2 = /oak:index/<index name> String parentPath = PathUtils.getAncestorPath(indexPath, 2); return PathUtils.denotesRoot(parentPath) ? "" : parentPath; }
private static String getPathWithMaxDepth(String path, int maxDepth){ int depth = PathUtils.getDepth(path); if (depth <= maxDepth){ return path; } return PathUtils.getAncestorPath(path, depth - maxDepth); }
@Test public void testTreePermissionIsGrantedProperty() throws Exception { TreePermission parentPermission = TreePermission.EMPTY; for (String path : TP_PATHS) { TreePermission tp = cppTestUser.getTreePermission(readOnlyRoot.getTree(path), parentPermission); Long toTest = (defPermissions.containsKey(path)) ? defPermissions.get(path) : defPermissions.get(PathUtils.getAncestorPath(path, 1)); if (toTest != null) { assertTrue(tp.isGranted(toTest, PROPERTY_STATE)); } parentPermission = tp; } }
@Test public void testTreePermissionIsGrantedProperty() throws Exception { TreePermission parentPermission = TreePermission.EMPTY; for (String path : TP_PATHS) { TreePermission tp = cpp.getTreePermission(readOnlyRoot.getTree(path), parentPermission); Long toTest = (defPermissions.containsKey(path)) ? defPermissions.get(path) : defPermissions.get(PathUtils.getAncestorPath(path, 1)); if (toTest != null) { assertTrue(tp.isGranted(toTest, PROPERTY_STATE)); } parentPermission = tp; } }
@Test public void testTreePermissionIsGrantedPropertyOR() throws Exception { TreePermission parentPermission = TreePermission.EMPTY; for (String path : TP_PATHS) { TreePermission tp = cppO.getTreePermission(readOnlyRoot.getTree(path), parentPermission); Long toTest = (defPermissions.containsKey(path)) ? defPermissions.get(path) : defPermissions.get(PathUtils.getAncestorPath(path, 1)); if (toTest != null) { assertTrue(tp.isGranted(toTest, PROPERTY_STATE)); } parentPermission = tp; } }
@Test public void testTreePermissionIsGranted() throws Exception { TreePermission parentPermission = TreePermission.EMPTY; for (String path : TP_PATHS) { TreePermission tp = cppTestUser.getTreePermission(readOnlyRoot.getTree(path), parentPermission); Long toTest = (defPermissions.containsKey(path)) ? defPermissions.get(path) : defPermissions.get(PathUtils.getAncestorPath(path, 1)); if (toTest != null) { assertTrue(tp.isGranted(toTest)); } parentPermission = tp; } }
@Test public void testTreePermissionIsGranted() throws Exception { TreePermission parentPermission = TreePermission.EMPTY; for (String path : TP_PATHS) { TreePermission tp = cpp.getTreePermission(root.getTree(path), parentPermission); Long toTest = (defPermissions.containsKey(path)) ? defPermissions.get(path) : defPermissions.get(PathUtils.getAncestorPath(path, 1)); if (toTest != null) { assertTrue(tp.isGranted(toTest)); } parentPermission = tp; } }
@Test public void testTreePermissionIsGrantedOR() throws Exception { TreePermission parentPermission = TreePermission.EMPTY; for (String path : TP_PATHS) { TreePermission tp = cppO.getTreePermission(root.getTree(path), parentPermission); Long toTest = (defPermissions.containsKey(path)) ? defPermissions.get(path) : defPermissions.get(PathUtils.getAncestorPath(path, 1)); if (toTest != null) { assertTrue(tp.isGranted(toTest)); } parentPermission = tp; } }
@Test public void testGroupEmptyPath() throws Exception { Authorizable authorizable = createAuthorizable(true, ""); assertFalse(UserConstants.DEFAULT_GROUP_PATH.equals(PathUtils.getAncestorPath(authorizable.getPath(), 1))); assertTrue(authorizable.getPath().startsWith(UserConstants.DEFAULT_GROUP_PATH)); }
@Test public void testUserRootPath() throws Exception { Authorizable authorizable = createAuthorizable(false, UserConstants.DEFAULT_USER_PATH); assertFalse(UserConstants.DEFAULT_USER_PATH.equals(PathUtils.getAncestorPath(authorizable.getPath(), 1))); assertTrue(authorizable.getPath().startsWith(UserConstants.DEFAULT_USER_PATH)); }
@Test public void testUserEmptyPath() throws Exception { Authorizable authorizable = createAuthorizable(false, ""); assertFalse(UserConstants.DEFAULT_USER_PATH.equals(PathUtils.getAncestorPath(authorizable.getPath(), 1))); assertTrue(authorizable.getPath().startsWith(UserConstants.DEFAULT_USER_PATH)); }
@Test public void testGroupRootPath() throws Exception { Authorizable authorizable = createAuthorizable(true, UserConstants.DEFAULT_GROUP_PATH); assertFalse(UserConstants.DEFAULT_GROUP_PATH.equals(PathUtils.getAncestorPath(authorizable.getPath(), 1))); assertTrue(authorizable.getPath().startsWith(UserConstants.DEFAULT_GROUP_PATH)); }
@Test public void testCurrentRelativePath() throws Exception { Authorizable authorizable = createAuthorizable(false, "."); assertEquals(UserConstants.DEFAULT_USER_PATH, PathUtils.getAncestorPath(authorizable.getPath(), 1)); } }
@Test(expected = IllegalStateException.class) public void testGetSupportedPathsMountsAboveSupportedPath2() { MountInfoProvider mip = Mounts.newBuilder().mount("private", PathUtils.getAncestorPath(SUPPORTED_PATH3, 2)).build(); CugUtil.getSupportedPaths(CUG_CONFIG, mip); }