/** * @inheritDoc */ public void orderBefore(String srcChildRelPath, String destChildRelPath) throws UnsupportedRepositoryOperationException, VersionException, ConstraintViolationException, ItemNotFoundException, LockException, RepositoryException { node.orderBefore(srcChildRelPath, destChildRelPath); }
/** * Orders the node last among its siblings. */ public static void orderLast(Node node) throws RepositoryException { node.getParent().orderBefore(node.getName(), null); }
/** * Convenience - delegate to {@link Node#orderBefore(String, String)}. */ public static void orderBefore(Node node, String siblingName) throws RepositoryException { node.getParent().orderBefore(node.getName(), siblingName); }
/** * Orders the node first among its siblings. */ public static void orderFirst(Node node) throws RepositoryException { Node parent = node.getParent(); NodeIterator siblings = parent.getNodes(); Node firstSibling = siblings.nextNode(); if (!firstSibling.isSame(node)) { parent.orderBefore(node.getName(), firstSibling.getName()); } }
/** * Orders the node down one step among its siblings. If the node is the only sibling or the last sibling this method * has no effect. */ public static void orderNodeDown(Node node) throws RepositoryException { Node siblingAfter = getSiblingAfter(node); if (siblingAfter != null) { node.getParent().orderBefore(siblingAfter.getName(), node.getName()); } }
public static void moveNodeBefore(Node nodeToMove, Node target) throws RepositoryException { Node targetParent = target.getParent(); moveNode(nodeToMove, targetParent); targetParent.orderBefore(nodeToMove.getName(), target.getName()); }
/** * Orders the node up one step among its siblings. If the node is the only sibling or the first sibling this method * has no effect. */ public static void orderNodeUp(Node node) throws RepositoryException { Node siblingBefore = getSiblingBefore(node); if (siblingBefore != null) { node.getParent().orderBefore(node.getName(), siblingBefore.getName()); } }
public static void renameNode(Node node, String newName) throws RepositoryException { if (node.getName().equals(newName)) { return; } final Node parent = node.getParent(); final String newPath = combinePathAndName(parent.getPath(), newName); final Node siblingAfter = NodeUtil.getSiblingAfter(node); node.getSession().move(node.getPath(), newPath); if (siblingAfter != null) { parent.orderBefore(newName, siblingAfter.getName()); } }
@Override protected void doExecute(InstallContext installContext) throws RepositoryException, TaskExecutionException { final Node node = installContext.getJCRSession(repository).getNode(path); node.getParent().orderBefore(node.getName(), orderBeforeNodeName); }
@Test public void orderSameNode() throws Exception { Session session = getAdminSession(); Node n = session.getRootNode().addNode("test", "nt:unstructured"); Node a = n.addNode("a"); n.orderBefore("a", "a"); }
public void testReorderWithAdd() throws Exception { testRootNode.orderBefore("C", "A"); session.getNode(testRoot).addNode("D"); session.save(); try { superuser.save(); fail("must throw InvalidItemStateException"); } catch (InvalidItemStateException e) { // expected } }
@Override public void testRevertReorderToEnd() throws RepositoryException { testRootNode.orderBefore(getRelPath(child1), null); testOrder(testRootNode, new Node[] { child2, child3, child4, child1}); // NEW child nodes -> must be removed upon refresh testRootNode.refresh(false); NodeIterator it = testRootNode.getNodes(); if (it.hasNext()) { fail("Reverting creation and reordering of new children must remove the children again."); } } }
@Override public void testRevertReorderToEnd() throws RepositoryException { testRootNode.orderBefore(getRelPath(child1), null); testOrder(testRootNode, new Node[] { child2, child3, child4, child1}); // NEW child nodes -> must be removed upon refresh testRootNode.refresh(false); NodeIterator it = testRootNode.getNodes(nodeName2); if (it.hasNext()) { fail("Reverting creation and reordering of new SNSs must remove the children again."); } } }
public void testReorderTwice() throws RepositoryException { testRootNode.orderBefore(getRelPath(child2), null); testRootNode.orderBefore(getRelPath(child4), getRelPath(child1)); testOrder(testRootNode, new Node[] { child4, child1, child3, child2}); testRootNode.save(); testOrder(testRootNode, new Node[] { child4, child1, child3, child2}); }
@Override public void testRevertReorder() throws RepositoryException { testRootNode.orderBefore(getRelPath(child4), getRelPath(child2)); testOrder(testRootNode, new Node[] { child1, child4, child2, child3}); // NEW child nodes -> must be removed upon refresh testRootNode.refresh(false); NodeIterator it = testRootNode.getNodes(); if (it.hasNext()) { fail("Reverting creation and reordering of new children must remove the children again."); } }
public void testReorder3() throws RepositoryException { String pathBefore = child3.getPath(); testRootNode.orderBefore(getRelPath(child3), getRelPath(child1)); testRootNode.save(); Item itemIndex3 = testRootNode.getSession().getItem(pathBefore); assertTrue(itemIndex3.isSame(child2)); Item item3 = testRootNode.getSession().getItem(child3.getPath()); assertTrue(item3.isSame(child3)); } }
public void testReorderToEnd() throws RepositoryException, ConstraintViolationException, UnsupportedRepositoryOperationException, VersionException { testRootNode.orderBefore(getRelPath(child2), null); testOrder(testRootNode, new Node[] { child1, child3, child4, child2}); testRootNode.save(); testOrder(testRootNode, new Node[] { child1, child3, child4, child2}); }
@Test public void testReorder3() throws Exception { Node n = testSession.getNode(path); // give 'add_child_nodes', 'nt-management' and 'remove_child_nodes' at // 'path' -> reorder must succeed allow(path, privilegesFromNames(new String[] {Privilege.JCR_ADD_CHILD_NODES, Privilege.JCR_REMOVE_CHILD_NODES, Privilege.JCR_NODE_TYPE_MANAGEMENT})); n.orderBefore(Text.getName(childNPath2), Text.getName(childNPath)); testSession.save(); }
@Override public void testRevertReorder() throws RepositoryException { testRootNode.orderBefore(getRelPath(child4), getRelPath(child2)); testOrder(testRootNode, new Node[] { child1, child4, child2, child3}); testRootNode.refresh(false); testOrder(testRootNode, new Node[] { child1, child2 }); }
public void testReorder() throws RepositoryException { testRootNode.orderBefore(getRelPath(child1), getRelPath(child3)); testOrder(testRootNode, new Node[] { child2, child1, child3, child4}); testRootNode.save(); testOrder(testRootNode, new Node[] { child2, child1, child3, child4}); }