PermissionUtil implements PermissionConstants { @Nullable public static String getParentPathOrNull(@NotNull final String path) { if (path.length() <= 1) { return null; } else { int idx = path.lastIndexOf('/'); if (idx == 0) { return "/"; } else { return path.substring(0, idx); } } } private  PermissionUtil(); @Nullable static String getParentPathOrNull(@NotNull final String path); @NotNull static String getEntryName(@Nullable String accessControlledPath); static boolean checkACLPath(@NotNull NodeBuilder node, @NotNull String path); static boolean checkACLPath(@NotNull Tree node, @NotNull String path); @NotNull static Tree getPermissionsRoot(@NotNull Root root, @NotNull String permissionRootName); @NotNull static Tree getPrincipalRoot(@NotNull Tree permissionsTree, @NotNull String principalName); static boolean isAdminOrSystem(@NotNull Set<Principal> principals, @NotNull ConfigurationParameters config); @Nullable static String getPath(@Nullable Tree parentBefore, @Nullable Tree parentAfter); @Nullable static Tree getReadOnlyTreeOrNull(@Nullable Tree tree, @NotNull Root readOnlyRoot); @NotNull static Tree getReadOnlyTree(@NotNull Tree tree, @NotNull Root readOnlyRoot);  }
@Test public void testParentPathOrNull() { for (String path : new String[] {"", PathUtils.ROOT_PATH, "a"}) { assertNull(PermissionUtil.getParentPathOrNull(path)); } assertEquals(PathUtils.ROOT_PATH, PermissionUtil.getParentPathOrNull("/single")); for (String path : new String[] {"/a/path", "/a/longer/path"}) { assertEquals(PathUtils.getParentPath(path), PermissionUtil.getParentPathOrNull(path)); } }