public int jsFunction_getDepth() { try { return node.getDepth(); } catch (RepositoryException re) { return -1; } }
public RepositoryWorkflowImpl(Session userSession, Session rootSession, Node subject) throws RemoteException, RepositoryException { this.session = rootSession; if(subject.getDepth() == 0) this.subject = rootSession.getRootNode(); else this.subject = rootSession.getRootNode().getNode(subject.getPath().substring(1)); }
/** * Print this node and its properties to System.out if printing is enabled. * * @param node the node to be printed * @throws RepositoryException */ public void printNode( Node node ) throws RepositoryException { printSubgraph(node, " ", node.getDepth(), 1); //$NON-NLS-1$ }
public List<Node> ancestorsInSite(Node content, String nodeTypeName) throws RepositoryException { List<Node> allAncestors = templatingFunctions.ancestors(content, nodeTypeName); Node siteRoot = siteRoot(content); List<Node> ancestoresInSite = new ArrayList<Node>(); for (Node current : allAncestors) { if (current.getDepth() >= siteRoot.getDepth()) { ancestoresInSite.add(current); } } return ancestoresInSite; }
private boolean isChildOf(Node child, Node parent) { try { return parent.getDepth() == 0 || child.getPath().startsWith(parent.getPath() + "/"); } catch (RepositoryException e) { throw new RuntimeRepositoryException(e); } } }
/** * Print this node and its properties to System.out if printing is enabled. * * @param node the node to be printed * @throws RepositoryException */ public void printNode( Node node ) throws RepositoryException { printSubgraph(node, " ", node.getDepth(), 1); }
/** * Test if depth of root node is 0. */ public void testGetDepth() throws RepositoryException { assertEquals("The depth of the root node must be equal to 0.", 0, rootNode.getDepth()); }
@Override protected void entering(Node node, int level) throws RepositoryException, SAXException { final AttributesImpl attrs = new AttributesImpl(); String nodeName; if (node.getDepth() == 0) { nodeName = jcrRoot; } else { nodeName = node.getName(); } addAttribute(attrs, SV_NAME, CDATA_TYPE, nodeName); startElement(NameConstants.SV_NODE, attrs); }
/** * {@inheritDoc} */ public boolean includes(Node root, Node node, String path) throws RepositoryException { if (path == null) { path = node.getPath(); } return contentFilter.contains(node, path, PathUtil.getDepth(path) - root.getDepth()); }
@Override protected void exportNode(String uri, String local, Node node) throws RepositoryException, SAXException { if (node.getDepth() == 0) { //don't include root node final NodeIterator iterator = node.getNodes(); while (iterator.hasNext()) { final Node child = iterator.nextNode(); super.exportNode(StringUtils.EMPTY, serializeKey(uri, child.getName()), child); //omit jcr: prefix for all child nodes } } else { super.exportNode(uri, serializeKey(uri, local), node); } }
@Override public Item getAncestor(int depth) throws ItemNotFoundException, AccessDeniedException, RepositoryException { // at some point we will enter the real hierarchy, so its easiest to loop Node parent = getParent(); while (parent.getDepth() > depth) { parent = parent.getParent(); } return parent; }
/** * Tests if depth of a property of depth of node + 1 */ public void testGetDepth() throws RepositoryException { assertEquals("getDepth() of a property of root must be 1", testRootNode.getDepth() + 1, property.getDepth()); }
/** * Test if the ancestor at depth = n, where n is the depth of this * <code>Item</code>, returns this <code>Node</code> itself. */ public void testGetAncestorOfNodeDepth() throws RepositoryException { Node nodeAtDepth = (Node) testRootNode.getAncestor(testRootNode.getDepth()); assertTrue("The ancestor of depth = n, where n is the depth of this " + "Node must be the item itself.", testRootNode.isSame(nodeAtDepth)); }
protected long countNodes( Node node ) throws RepositoryException { long count = 1; NodeIterator iter = node.getNodes(); while (iter.hasNext()) { Node child = iter.nextNode(); if (child.getDepth() == 1 && child.getName().equals("jcr:system")) continue; count += countNodes(child); } return count; } }
@Test public void assertThatRootNodeIsNotCheckedForTemplate() throws Exception { // GIVEN final Node root = mock(Node.class); when(root.getDepth()).thenReturn(0); // WHEN templateTypeHelper.findParentWithTemplateType(root, DefaultTemplateTypes.HOME); // THEN verify(root, times(1)).getDepth(); verifyNoMoreInteractions(root); }
@Override public Item getAncestor(int depth) throws RepositoryException { if (this.getDepth() == depth) { return this; } Node parentNode = this.getParent(); while (parentNode.getDepth() != depth) { parentNode = parentNode.getParent(); } return parentNode; }
private NavigationModel createVerticalNavigation() throws RepositoryException { int startLevel = siteRoot.getDepth(); boolean rootIsHome = true; if (isShowHorizontalNavigation()) { startLevel = getStartLevel(); rootIsHome = false; } Node root = (Node) currentNode.getAncestor(startLevel); boolean allOpen = siteNavigation.getVertical().getAllOpen(); return new NavigationModel(root, currentNode, getVerticalLevel(), allOpen, rootIsHome); }
public void testAncestorAfterRevert() throws RepositoryException { superuser.refresh(false); Item ancestor = grandChildNode.getAncestor(srcParentNode.getDepth()); assertTrue("Reverting a move-operation must move the tree back.", ancestor.isSame(srcParentNode)); }
public void testTreeAncestors() throws RepositoryException { int degree = destParentNode.getDepth(); Item ancestor = childNode.getAncestor(degree); assertTrue("Moving a node must move all child items as well.", ancestor.isSame(destParentNode)); ancestor = childProperty.getAncestor(degree); assertTrue("Moving a node must move all child items as well.", ancestor.isSame(destParentNode)); ancestor = grandChildNode.getAncestor(degree); assertTrue("Moving a node must move all child items as well.", ancestor.isSame(destParentNode)); }