Package javax.jcr

Examples of javax.jcr.Node.orderBefore()


        }

        // allow 'remove_node' at childNPath
        // -> now reorder must succeed
        givePrivileges(childNPath, privilegesFromName(Privilege.JCR_REMOVE_NODE), getRestrictions(superuser, childNPath));
        n.orderBefore(Text.getName(childNPath), Text.getName(childNPath2));
        testSession.save();
    }

    /**
     * Test case for JCR-2420
View Full Code Here


        try {
            if (!n.getPrimaryNodeType().hasOrderableChildNodes()) {
                throw new NotExecutableException("Reordering child nodes is not supported..");
            }

            n.orderBefore(Text.getName(childNPath), Text.getName(childNPath2));
            testSession.save();
            fail("test session must not be allowed to reorder nodes.");
        } catch (AccessDeniedException e) {
            // success.
        }
View Full Code Here

        // give 'add_child_nodes' and 'nt-management' privilege
        // -> not sufficient privileges for a reorder
        givePrivileges(path, privilegesFromNames(new String[] {Privilege.JCR_ADD_CHILD_NODES, Privilege.JCR_NODE_TYPE_MANAGEMENT}), getRestrictions(superuser, path));
        try {
            n.orderBefore(Text.getName(childNPath), Text.getName(childNPath2));
            testSession.save();
            fail("test session must not be allowed to reorder nodes.");
        } catch (AccessDeniedException e) {
            // success.
        }
View Full Code Here

        }

        // add 'remove_child_nodes' at 'path
        // -> reorder must now succeed
        givePrivileges(path, privilegesFromName(Privilege.JCR_REMOVE_CHILD_NODES), getRestrictions(superuser, path));
        n.orderBefore(Text.getName(childNPath), Text.getName(childNPath2));
        testSession.save();
    }

    public void testRename() throws RepositoryException, NotExecutableException {
        Session testSession = getTestSession();
View Full Code Here

            Session s = node.getSession();
            s.move(node.getPath(), p.getPath() + "/" + key);

            // If orderable, move to first child node
            if (p.getPrimaryNodeType().hasOrderableChildNodes()) {
                p.orderBefore(key, p.getNodes().nextNode().getName());
            }
        }
    }

    protected static class NodeSequenceImpl extends ItemSequence implements NodeSequence {
View Full Code Here

                if (ORDER_POSITION_FIRST.equals(orderPosition)) {
                    if (destName != null) {
                        throw new DiffException(ORDER_POSITION_FIRST + " may not have a leading destination.");
                    }
                    destName = Text.getName(parent.getNodes().nextNode().getPath());
                    parent.orderBefore(srcName, destName);
                } else if (ORDER_POSITION_LAST.equals(orderPosition)) {
                    if (destName != null) {
                        throw new DiffException(ORDER_POSITION_LAST + " may not have a leading destination.");
                    }
                    parent.orderBefore(srcName, null);
View Full Code Here

                    parent.orderBefore(srcName, destName);
                } else if (ORDER_POSITION_LAST.equals(orderPosition)) {
                    if (destName != null) {
                        throw new DiffException(ORDER_POSITION_LAST + " may not have a leading destination.");
                    }
                    parent.orderBefore(srcName, null);
                } else if (ORDER_POSITION_AFTER.equals(orderPosition)) {
                    if (destName == null) {
                        throw new DiffException(ORDER_POSITION_AFTER + " must have a leading destination.");
                    }
                    for (NodeIterator it = parent.getNodes(); it.hasNext();) {
View Full Code Here

            for (OrderPatch.Member instruction : orderPatch.getOrderInstructions()) {
                String srcRelPath = Text.unescape(instruction.getMemberHandle());
                Position pos = instruction.getPosition();
                String destRelPath = getRelDestinationPath(pos, n.getNodes());
                // preform the reordering
                n.orderBefore(srcRelPath, destRelPath);
            }
            complete();
        } catch (RepositoryException e) {
            // UnsupportedRepositoryException should not occur
            throw new JcrDavException(e);
View Full Code Here

        root.addNode("b");
        root.addNode("c");

        NodeIterator iterator;

        root.orderBefore("a", "b");
        iterator = root.getNodes();
        assertEquals("a", iterator.nextNode().getName());
        assertEquals("b", iterator.nextNode().getName());
        assertEquals("c", iterator.nextNode().getName());
        assertFalse(iterator.hasNext());
View Full Code Here

        assertEquals("a", iterator.nextNode().getName());
        assertEquals("b", iterator.nextNode().getName());
        assertEquals("c", iterator.nextNode().getName());
        assertFalse(iterator.hasNext());

        root.orderBefore("c", "a");
        iterator = root.getNodes();
        assertEquals("c", iterator.nextNode().getName());
        assertEquals("a", iterator.nextNode().getName());
        assertEquals("b", iterator.nextNode().getName());
        assertFalse(iterator.hasNext());
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.