/** * @inheritDoc */ public int getIndex() throws RepositoryException { return node.getIndex(); }
public int jsFunction_getIndex() { try { return node.getIndex(); } catch (RepositoryException re) { return 1; } }
@Override public int getIndex() throws RepositoryException { return this.node.getIndex(); }
private String nameOf( Node node ) throws RepositoryException { int index = node.getIndex(); String childName = node.getName(); return index == 1 ? childName : childName + "[" + index + "]"; }
protected String nodeName( Node node ) throws RepositoryException { int index = node.getIndex(); String name = node.getName(); if (index != 1) name = name + "[" + index + "]"; return name; }
protected static List<String> namesOfChildren( Node node ) throws RepositoryException { List<String> children = new LinkedList<String>(); for (NodeIterator iter = node.getNodes(); iter.hasNext();) { Node child = iter.nextNode(); String name = child.getIndex() == 1 ? child.getName() : child.getName() + "[" + child.getIndex() + "]"; children.add(name); } return children; }
/** {@inheritDoc} */ public int getIndex() throws RepositoryException, RemoteException { try { return node.getIndex(); } catch (RepositoryException ex) { throw getRepositoryException(ex); } }
// loop to get each item from ArrayList for( int i = 0; i < web.size(); i++ ){ // get a node from array Node thisNode = (Node)web.get(i); // print its title System.out.println( thisNode.getTitle() ); // print other properties if needed System.out.println( thisNode.getIndex() ); }
@Override public int getIndex() throws RepositoryException { return getWrappedNode().getIndex(); }
protected String createNodeName(final Node sourceNode) throws RepositoryException { final String name = sourceNode.getName(); if (sourceNode.getIndex() > 1) { return name + "[" + sourceNode.getIndex() + "]"; } else { if (sourceNode.getDefinition().allowsSameNameSiblings() && sourceNode.getParent().hasNode(name + "[2]")) { return name + "[1]"; } } return name; }
protected Node getParentNode( Property property ) throws RepositoryException { Node parentNode = property.getParent(); if (JcrConstants.JCR_CONTENT.equalsIgnoreCase(parentNode.getName()) && parentNode.getIndex() == 1) { parentNode = parentNode.getParent(); } return parentNode; }
private void saveState() throws RepositoryException { // save top-level nodes for tearDown validation topLevelNodes = new HashSet<String>(); for (Node node : new NodeIterable(session.getRootNode().getNodes())) { topLevelNodes.add(node.getName() + "[" + node.getIndex() + "]"); } jcrStates = new ArrayList<>(); for (String pathToCheck : getPathsToCheck()) { jcrStates.add(new JcrState(pathToCheck, session, log)); } }
private static void checkIndex(Node node, int expectedIndex) throws RepositoryException { int index = node.getIndex(); if (index != expectedIndex) { fail("Unexpected index " + index + ". Expected index was " + expectedIndex); } } }
/** * Implementation specific: * Same as {@link #testMovedNodeGetPath()}, but calls save prior to the * test. */ public void testMovedNodeGetPath2() throws RepositoryException, NotExecutableException { int index = destSibling.getIndex() + 1; //move the node doMove(moveNode.getPath(), destParentNode.getPath() + "/" + nodeName2); superuser.save(); assertEquals("After successful move the moved node must return the destination path.", destinationPath + "["+ index +"]", moveNode.getPath()); }
/** * Implementation specific: * Test if the path of a moved node, contains the index of the last sibling. */ public void testMovedNodeGetPath() throws RepositoryException, NotExecutableException { int index = destSibling.getIndex() + 1; //move the node doMove(moveNode.getPath(),destinationPath); assertEquals("After successful move the moved node must return the destination path.", destinationPath + "["+ index +"]", moveNode.getPath()); }
public void testIndexAfterReorder() throws RepositoryException { testRootNode.orderBefore(getRelPath(child1), getRelPath(child3)); assertTrue(child1.getIndex() == 2); assertTrue(child2.getIndex() == 1); assertTrue(child3.getIndex() == 3); assertTrue(child4.getIndex() == 4); testRootNode.save(); assertTrue(child1.getIndex() == 2); assertTrue(child2.getIndex() == 1); assertTrue(child3.getIndex() == 3); assertTrue(child4.getIndex() == 4); }
protected void assertFolder( Node node, File dir ) throws Exception { assertThat(dir.exists(), is(true)); assertThat(dir.canRead(), is(true)); assertThat(dir.isDirectory(), is(true)); assertThat(node.getName(), is(dir.getName())); assertThat(node.getIndex(), is(1)); assertThat(node.getPrimaryNodeType().getName(), is("nt:folder")); assertThat(node.getProperty("jcr:created").getLong(), is(createdTimeFor(dir))); }
protected void assertFile( Node node, File file ) throws Exception { assertThat(node.getName(), is(file.getName())); assertThat(node.getIndex(), is(1)); assertThat(node.getPrimaryNodeType().getName(), is("nt:file")); assertThat(node.getProperty("jcr:created").getLong(), is(createdTimeFor(file))); Node content = node.getNode("jcr:content"); assertThat(content.getName(), is("jcr:content")); assertThat(content.getIndex(), is(1)); assertThat(content.getPrimaryNodeType().getName(), is("nt:resource")); assertThat(content.getProperty("jcr:lastModified").getLong(), is(file.lastModified())); }
@Test public void shouldHaveSameNameSiblingIndex() throws Exception { assertThat(altima.getIndex(), is(1)); javax.jcr.Node altima2 = hybrid.addNode("Nissan Altima"); try { assertThat(altima2, is(notNullValue())); assertThat(altima2.getIndex(), is(2)); } finally { altima2.remove(); // remove the node we added in this test to not interfere with other tests } }