Refine search
@Override public void apply(Root root) throws RemoteCommitException { logger.debug("performing 'remove' operation on path={}", path); Tree tree = root.getTree(path); if (!tree.exists()) { throw new RemoteCommitException("tree does not exists"); } if (!tree.remove()) { throw new RemoteCommitException("unable to remove the tree"); } }
@Override public boolean remove() { Tree tokenTree = getTokenTree(this); if (tokenTree.exists()) { try { if (tokenTree.remove()) { root.commit(CommitMarker.asCommitAttributes()); return true; } } catch (CommitFailedException e) { log.debug("Error while removing expired token {}", e.getMessage()); } } return false; }
@Test public void testDefaultMount() throws Exception { setUp(); ContentSession s = repository.login(null, null); Root r = s.getLatestRoot(); Tree t = r.getTree("/").addChild("test"); t.addChild("node1").setProperty("jcr:primaryType", "nt:base"); t.addChild("node2").setProperty("jcr:primaryType", "nt:base"); t.addChild("node3").setProperty("jcr:primaryType", "nt:base"); r.commit(); t.getChild("node1").removeProperty("jcr:primaryType"); r.commit(); t.getChild("node1").remove(); r.commit(); }
@Override public void onDisable(@NotNull User user, @Nullable String disableReason, @NotNull Root root, @NotNull NamePathMapper namePathMapper) throws RepositoryException { if (disableReason != null) { Tree t = root.getTree(user.getPath()); if (t.exists() && t.hasChild("profiles")) { t.getChild("profiles").remove(); } } }
@Override public boolean remove() { Tree tokenTree = getTokenTree(this); if (tokenTree.exists()) { try { if (tokenTree.remove()) { root.commit(CommitMarker.asCommitAttributes()); return true; } } catch (CommitFailedException e) { log.debug("Error while removing expired token {}", e.getMessage()); } } return false; }
@Test public void propertyStatus() throws CommitFailedException { Tree tree = root.getTree("/"); tree.setProperty("new", "value1"); assertEquals(Tree.Status.NEW, tree.getPropertyStatus("new")); root.commit(); assertEquals(Tree.Status.UNCHANGED, tree.getPropertyStatus("new")); tree.setProperty("new", "value2"); assertEquals(Tree.Status.MODIFIED, tree.getPropertyStatus("new")); root.commit(); assertEquals(Tree.Status.UNCHANGED, tree.getPropertyStatus("new")); tree.removeProperty("new"); assertNull(tree.getPropertyStatus("new")); root.commit(); assertNull(tree.getPropertyStatus("new")); Tree x = root.getTree("/x"); x.setProperty("y", "value1"); x.remove(); }
@Override public boolean remove() { Tree tokenTree = getTokenTree(this); if (tokenTree.exists()) { try { if (tokenTree.remove()) { root.commit(CommitMarker.asCommitAttributes()); return true; } } catch (CommitFailedException e) { log.debug("Error while removing expired token {}", e.getMessage()); } } return false; }
@Test public void testRemoveParentTree() throws Exception { UserProvider up = createUserProvider(); Tree u1 = up.createUser("b", "b"); Tree u2 = up.createUser("bb", "bb"); Tree folder = root.getTree(Text.getRelativeParent(u1.getPath(), 2)); folder.remove(); if (up.getAuthorizable("b") != null) { fail("Removing the top authorizable folder must remove all users contained."); u1.remove(); } if (up.getAuthorizable("bb") != null) { fail("Removing the top authorizable folder must remove all users contained."); u2.remove(); } }