private MoveEntry(@Nonnull String sourcePath, @Nonnull String destPath) { this.sourcePath = sourcePath; this.destPath = destPath; parentSourcePaths.add(Text.getRelativeParent(sourcePath, 1)); parentDestPaths.add(Text.getRelativeParent(destPath, 1)); } }
private MoveEntry(@NotNull String sourcePath, @NotNull String destPath) { this.sourcePath = sourcePath; this.destPath = destPath; parentSourcePaths.add(Text.getRelativeParent(sourcePath, 1)); parentDestPaths.add(Text.getRelativeParent(destPath, 1)); } }
/** * Same as {@link #getRelativeParent(String, int)} but adding the possibility * to pass paths that end with a trailing '/' * * @see #getRelativeParent(String, int) */ public static String getRelativeParent(String path, int level, boolean ignoreTrailingSlash) { if (ignoreTrailingSlash && path.endsWith("/") && path.length() > 1) { path = path.substring(0, path.length()-1); } return getRelativeParent(path, level); }
/** * Same as {@link #getRelativeParent(String, int)} but adding the possibility * to pass paths that end with a trailing '/' * * @see #getRelativeParent(String, int) */ public static String getRelativeParent(String path, int level, boolean ignoreTrailingSlash) { if (ignoreTrailingSlash && path.endsWith("/") && path.length() > 1) { path = path.substring(0, path.length()-1); } return getRelativeParent(path, level); }
/** * Same as {@link #getRelativeParent(String, int)} but adding the possibility * to pass paths that end with a trailing '/' * * @see #getRelativeParent(String, int) */ public static String getRelativeParent(String path, int level, boolean ignoreTrailingSlash) { if (ignoreTrailingSlash && path.endsWith("/") && path.length() > 1) { path = path.substring(0, path.length()-1); } return getRelativeParent(path, level); }
/** * Same as {@link #getRelativeParent(String, int)} but adding the possibility * to pass paths that end with a trailing '/' * * @see #getRelativeParent(String, int) */ public static String getRelativeParent(String path, int level, boolean ignoreTrailingSlash) { if (ignoreTrailingSlash && path.endsWith("/") && path.length() > 1) { path = path.substring(0, path.length()-1); } return getRelativeParent(path, level); }
/** * Same as {@link #getRelativeParent(String, int)} but adding the possibility * to pass paths that end with a trailing '/' * * @see #getRelativeParent(String, int) */ public static String getRelativeParent(String path, int level, boolean ignoreTrailingSlash) { if (ignoreTrailingSlash && path.endsWith("/") && path.length() > 1) { path = path.substring(0, path.length()-1); } return getRelativeParent(path, level); }
void setSearchRoots(String userSearchRoot, String groupSearchRoot) { this.userSearchRoot = userSearchRoot; this.groupSearchRoot = groupSearchRoot; authorizableSearchRoot = userSearchRoot; while (!Text.isDescendant(authorizableSearchRoot, groupSearchRoot)) { authorizableSearchRoot = Text.getRelativeParent(authorizableSearchRoot, 1); } }
void setSearchRoots(String userSearchRoot, String groupSearchRoot) { this.userSearchRoot = userSearchRoot; this.groupSearchRoot = groupSearchRoot; authorizableSearchRoot = userSearchRoot; while (!Text.isDescendant(authorizableSearchRoot, groupSearchRoot)) { authorizableSearchRoot = Text.getRelativeParent(authorizableSearchRoot, 1); } }
private String getClosestParent(Session session, String path) throws RepositoryException { do { if (session.nodeExists(path)) { return path; } path = Text.getRelativeParent(path, 1); } while (path != null && path.length() > 0); return null; }
@Nullable private User getUser(@NotNull Tree tokenTree) throws RepositoryException { String userPath = Text.getRelativeParent(tokenTree.getPath(), 2); Authorizable authorizable = userManager.getAuthorizableByPath(userPath); if (authorizable != null && !authorizable.isGroup() && !((User) authorizable).isDisabled()) { return (User) authorizable; } else { return null; } }
@CheckForNull private User getUser(@Nonnull Tree tokenTree) throws RepositoryException { String userPath = Text.getRelativeParent(tokenTree.getPath(), 2); Authorizable authorizable = userManager.getAuthorizableByPath(userPath); if (authorizable != null && !authorizable.isGroup() && !((User) authorizable).isDisabled()) { return (User) authorizable; } else { return null; } }
@Nullable private User getUser(@NotNull Tree tokenTree) throws RepositoryException { String userPath = Text.getRelativeParent(tokenTree.getPath(), 2); Authorizable authorizable = userManager.getAuthorizableByPath(userPath); if (authorizable != null && !authorizable.isGroup() && !((User) authorizable).isDisabled()) { return (User) authorizable; } else { return null; } }
public void move(String fromPath, String toPath) throws RepositoryException { final String fromParentPath = Text.getRelativeParent(fromPath, 1); final boolean appendName = getSession().nodeExists(toPath); final String toParentPath = appendName ? toPath : Text.getRelativeParent(toPath, 1); final String finalPath = appendName ? toPath + "/" + Text.getName(fromPath) : toPath; getSession().move(fromPath, toPath); processChanges(fromParentPath, fromPath, toParentPath, finalPath); }
private ZipEntryImportContext(ImportContext context, ZipEntry entry, BoundedInputStream bin, Node contentNode) throws IOException, RepositoryException { super(contentNode, Text.getName(makeValidJCRPath(entry.getName(), true)), null, bin, context.getIOListener(), getIOManager().getDetector()); this.entry = entry; String path = makeValidJCRPath(entry.getName(), true); importRoot = IOUtil.mkDirs(contentNode, Text.getRelativeParent(path, 1), getCollectionNodeType()); }
@Override public Page getParent(int level) { String parentPath = Text.getRelativeParent(resource.getPath(), level); Resource parentResource = resource.getResourceResolver().getResource(parentPath); if (parentResource != null) { return parentResource.adaptTo(Page.class); } return null; }
@Override public void afterSuite() throws Exception { UserManager userMgr = ((JackrabbitSession) session).getUserManager(); Authorizable authorizable = userMgr.getAuthorizable(USER); if (authorizable != null) { authorizable.remove(); } authorizable = userMgr.getAuthorizable(GROUP); if (authorizable != null) { Node n = session.getNode(Text.getRelativeParent(authorizable.getPath(), 1)); n.remove(); } session.save(); }
public void removeItem(String path) throws RepositoryException { Item item = getSession().getItem(path); if (item.isNode()) { new NodeProxy((Node) item).remove(); } else { item.remove(); processChanges(Text.getRelativeParent(path, 1), path); } }
@Test public void testHasHiddenChild() { ImmutableTree parent = (ImmutableTree) TreeUtil.getTree(immutable, Text.getRelativeParent(HIDDEN_PATH, 1)); assertNotNull(parent); assertTrue(parent.hasChild(Text.getName(HIDDEN_PATH))); }
@Test public void testCreateGroup() throws RepositoryException { UserProvider up = createUserProvider(); Tree groupTree = up.createGroup("group1", null); assertNotNull(groupTree); assertTrue(Text.isDescendant(defaultGroupPath, groupTree.getPath())); int level = defaultConfig.getConfigValue(UserConstants.PARAM_DEFAULT_DEPTH, UserConstants.DEFAULT_DEPTH) + 1; assertEquals(defaultGroupPath, Text.getRelativeParent(groupTree.getPath(), level)); }