protected void entering(Node n, int level) throws RepositoryException { if (!node.isSame(n)) { descendants.add(n); } } });
protected void entering(Node node, int level) throws RepositoryException { if (node.getName().equals(name) && !testRootNode.isSame(node)) { nodes.add(node); } } });
/** * 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()); } }
/** * Returns true if both arguments represents the same node. In case the nodes are wrapped the comparison is done one * the actual nodes behind the wrappers. */ public static boolean isSame(Node lhs, Node rhs) throws RepositoryException { return unwrap(lhs).isSame(unwrap(rhs)); }
public Node getContainingFolder() throws RepositoryException { Node jcrRoot = node.getSession().getRootNode(); Node parent = node.getParent(); while (!parent.isSame(jcrRoot)) { if (parent.isNodeType(HippoNodeType.NT_DOCUMENT)) { return parent; } parent = parent.getParent(); } return null; }
/** * Tests if getParent() returns parent node */ public void testGetParent() throws RepositoryException { assertTrue("getParent() of a property must return the parent node.", testRootNode.isSame(property.getParent())); }
/** * Test the persistence of a property modified with an Node parameter and * saved from the Session Requires a Node value (node) */ public void testNodeSession() throws RepositoryException, NotExecutableException { property1.setValue(node); superuser.save(); assertTrue("Reference property not saved", node.isSame(property1.getNode())); }
/** * <code>Node.getNode(".") </code> applied to the root node must return * the same <code>Node</code> again. * * @throws RepositoryException */ public void testRootGetNodeDot() throws RepositoryException { Node root = superuser.getRootNode(); assertTrue("Node.getNode(\".\") must return the same node", root.getNode(DOT).isSame(root)); }
public Object doInJcr( final Session session ) throws RepositoryException, IOException { PentahoJcrConstants pentahoJcrConstants = new PentahoJcrConstants( session ); Node node = session.getNodeByIdentifier( id.toString() ); if ( !node.getParent().isSame( session.getRootNode() ) ) { return toAcl( session, pentahoJcrConstants, node.getParent().getIdentifier() ); } else { return null; } } } );
/** * Tests if getParent() returns parent node */ public void testGetParent() throws NotExecutableException, RepositoryException { if (childNode == null) { throw new NotExecutableException("Workspace does not have sufficient content to run this test."); } assertTrue("getParent() of a child node return the parent node.", testRootNode.isSame(childNode.getParent())); }
private static Node getHandleNodeIfIsAncestor(final Node currentNode, final Node rootNode) throws RepositoryException { if (currentNode.isNodeType(HippoNodeType.NT_HANDLE)) { return currentNode; } if (currentNode.isSame(rootNode)) { return null; } return getHandleNodeIfIsAncestor(currentNode.getParent(), rootNode); }
public void testShadowingItems() throws RepositoryException { Node n = testRootNode.addNode(nodeName1, testNodeType); Node n2 = testRootNode.addNode(nodeName2, testNodeType); Property p = n.setProperty(propertyName1, "anyValue"); testRootNode.save(); testRootNode.getSession().move(n.getPath(), n2.getPath() + "/destination"); Node replaceNode = testRootNode.addNode(nodeName1, testNodeType); Property replaceProp = replaceNode.setProperty(propertyName1, "anyValue"); assertFalse(replaceNode.isSame(n)); assertFalse(replaceProp.isSame(p)); }
@Test public void testSessionGetNode() throws Exception { Node nn = superuser.getNode(n.getPath()); assertTrue(n.isSame(nn)); }
@Test public void getNodeDot() throws RepositoryException { Node node = getNode("/foo"); Node same = node.getNode("."); assertNotNull(same); assertEquals("foo", same.getName()); assertTrue(same.isSame(node)); }
protected void verifyShare( Node original, Node sharedNode ) throws RepositoryException { // The identity, properties and children match the original node ... assertThat(sharedNode.getIdentifier(), is(original.getIdentifier())); assertThat(sharedNode.isSame(original), is(true)); assertSameProperties(sharedNode, original); assertSameChildren(sharedNode, original); // Verify the shared attributes ... assertThat(sharedNode.isNodeType(MIX_SHAREABLE), is(true)); assertSharedSetIncludes(original, original.getPath(), sharedNode.getPath()); assertSharedSetIncludes(sharedNode, original.getPath(), sharedNode.getPath()); }
public void testTreeEntries() throws RepositoryException { Item item = superuser.getItem(destinationPath + "/" + nodeName2); assertTrue("Moving a node must move all child items as well.", childNode.isSame(item)); item = superuser.getItem(destinationPath + "/" + propertyName2); assertTrue("Moving a node must move all child items as well.", childProperty.isSame(item)); item = superuser.getItem(destinationPath + "/" + nodeName2 + "/" + nodeName3); assertTrue("Moving a node must move all child items as well.", grandChildNode.isSame(item)); }
@Test public void getNodeDotDot() throws RepositoryException { Node node = getNode("/foo"); Node root = node.getNode(".."); assertNotNull(root); assertEquals("", root.getName()); assertTrue(root.isSame(node.getParent())); }
@Test public void testIsSame() throws Exception { assertFalse(n.isSame(p)); assertFalse(p.isSame(n)); }
@Test public void getNodeByIdentifier() throws RepositoryException { Node node = getNode("/foo"); String id = node.getIdentifier(); Node node2 = getAdminSession().getNodeByIdentifier(id); assertTrue(node.isSame(node2)); }
public void testParentChildLock2() throws Exception { childNode.addMixin(mixLockable); testRootNode.save(); try { Lock l = childNode.lock(false, isSessionScoped()); assertTrue("child node must still hold lock", l.getNode().isSame(childNode)); } finally { childNode.unlock(); } }