@Override public void read(Node node) throws RepositoryException { for (Node child : JcrUtils.getChildNodes(node)) { child.getProperty("title").getString(); child.getProperty("content").getString(); } } };
@Override protected void runTest() throws Exception { Node top = root.getNode("node" + RANDOM.nextInt(scale)); Node middle = top.getNode("node" + RANDOM.nextInt(1000)); for (Node bottom : JcrUtils.getChildNodes(middle)) { content.read(bottom); } } };
private void recurse( List<String> facets, String prefix, Node node ) throws RepositoryException { for ( Node n : JcrUtils.getChildNodes( node ) ) { String name = prefix + "/" + n.getName(); if ( n.hasNodes() ) { recurse( facets, name, n ); } else { // strip leading / first facets.add( name.substring( 1 ) ); } } }
private void recurse( List<String> facets, String prefix, Node node ) throws RepositoryException { for ( Node n : JcrUtils.getChildNodes( node ) ) { String name = prefix + "/" + n.getName(); if ( n.hasNodes() ) { recurse( facets, name, n ); } else { // strip leading / first facets.add( name.substring( 1 ) ); } } }
@Override public Object call() throws Exception { try { Node testRoot = session.getNode(p); createChildren(testRoot, 100); for (Node m : JcrUtils.getChildNodes(testRoot)) { createChildren(m, 100 / WRITER_COUNT); for (Node n : JcrUtils.getChildNodes(m)) { createChildren(n, 5); } } session.save(); } finally { session.logout(); } return null; }
@Override public Collection<String> getArtifactVersions( String repositoryId, String namespace, String projectId, String projectVersion ) throws MetadataResolutionException { Set<String> versions = new LinkedHashSet<String>(); try { Node root = getJcrSession().getRootNode(); Node node = root.getNode( getProjectVersionPath( repositoryId, namespace, projectId, projectVersion ) ); for ( Node n : JcrUtils.getChildNodes( node ) ) { versions.add( n.getProperty( "version" ).getString() ); } } catch ( PathNotFoundException e ) { // ignore repo not found for now } catch ( RepositoryException e ) { throw new MetadataResolutionException( e.getMessage(), e ); } return versions; }
@Override public Collection<String> getArtifactVersions( String repositoryId, String namespace, String projectId, String projectVersion ) throws MetadataResolutionException { Set<String> versions = new LinkedHashSet<String>(); try { Node root = getJcrSession().getRootNode(); Node node = root.getNode( getProjectVersionPath( repositoryId, namespace, projectId, projectVersion ) ); for ( Node n : JcrUtils.getChildNodes( node ) ) { versions.add( n.getProperty( "version" ).getString() ); } } catch ( PathNotFoundException e ) { // ignore repo not found for now } catch ( RepositoryException e ) { throw new MetadataResolutionException( e.getMessage(), e ); } return versions; }
private Collection<String> getNodeNames( String path, String nodeType ) throws MetadataResolutionException { List<String> names = new ArrayList<>(); try { Node root = getJcrSession().getRootNode(); Node nodeAtPath = root.getNode( path ); for ( Node node : JcrUtils.getChildNodes( nodeAtPath ) ) { if ( node.isNodeType( nodeType ) ) { names.add( node.getName() ); } } } catch ( PathNotFoundException e ) { // ignore repo not found for now } catch ( RepositoryException e ) { throw new MetadataResolutionException( e.getMessage(), e ); } return names; }
public void visit(Node node) throws RepositoryException { for (Node child : JcrUtils.getChildNodes(node)) { child.accept(this); } }
@Override public void removeProject( String repositoryId, String namespace, String projectId ) throws MetadataRepositoryException { try { Node root = getJcrSession().getRootNode(); String namespacePath = getNamespacePath( repositoryId, namespace ); if ( root.hasNode( namespacePath ) ) { Iterator<Node> nodeIterator = JcrUtils.getChildNodes( root.getNode( namespacePath ) ).iterator(); while ( nodeIterator.hasNext() ) { Node node = nodeIterator.next(); if ( node.isNodeType( PROJECT_NODE_TYPE ) && projectId.equals( node.getName() ) ) { node.remove(); } } } } catch ( RepositoryException e ) { throw new MetadataRepositoryException( e.getMessage(), e ); } }
@Override protected void setUp() throws Exception { super.setUp(); for (Node c : JcrUtils.getChildNodes(testRootNode)) { testRootNode.getSession().removeItem(c.getPath()); } testRootNode.getSession().save(); }
@Override protected void tearDown() throws Exception { for (Node c : JcrUtils.getChildNodes(testRootNode)) { testRootNode.getSession().removeItem(c.getPath()); } testRootNode.getSession().save(); super.tearDown(); }
@Override protected void setUp() throws Exception { super.setUp(); for (Node c : JcrUtils.getChildNodes(testRootNode)) { testRootNode.getSession().removeItem(c.getPath()); } testRootNode.getSession().save(); }
@Override protected void tearDown() throws Exception { for (Node c : JcrUtils.getChildNodes(testRootNode)) { testRootNode.getSession().removeItem(c.getPath()); } testRootNode.getSession().save(); super.tearDown(); }
@Override protected void tearDown() throws Exception { for (Node c : JcrUtils.getChildNodes(testRootNode)) { testRootNode.getSession().removeItem(c.getPath()); } testRootNode.getSession().save(); super.tearDown(); }
@Override protected void tearDown() throws Exception { for (Node c : JcrUtils.getChildNodes(testRootNode)) { testRootNode.getSession().removeItem(c.getPath()); } testRootNode.getSession().save(); super.tearDown(); }
@Override protected void tearDown() throws Exception { for (Node c : JcrUtils.getChildNodes(testRootNode)) { testRootNode.getSession().removeItem(c.getPath()); } superuser.save(); super.tearDown(); }
@Override public void removeProjectVersion( String repoId, String namespace, String projectId, String projectVersion ) throws MetadataRepositoryException { try { String path = getProjectPath( repoId, namespace, projectId ); Node root = getJcrSession().getRootNode(); Node nodeAtPath = root.getNode( path ); for ( Node node : JcrUtils.getChildNodes( nodeAtPath ) ) { if ( node.isNodeType( PROJECT_VERSION_NODE_TYPE ) && StringUtils.equals( projectVersion, node.getName() ) ) { node.remove(); } } } catch ( RepositoryException e ) { throw new MetadataRepositoryException( e.getMessage(), e ); } }
@Override public void removeProjectVersion( String repoId, String namespace, String projectId, String projectVersion ) throws MetadataRepositoryException { try { String path = getProjectPath( repoId, namespace, projectId ); Node root = getJcrSession().getRootNode(); Node nodeAtPath = root.getNode( path ); for ( Node node : JcrUtils.getChildNodes( nodeAtPath ) ) { if ( node.isNodeType( PROJECT_VERSION_NODE_TYPE ) && StringUtils.equals( projectVersion, node.getName() ) ) { node.remove(); } } } catch ( RepositoryException e ) { throw new MetadataRepositoryException( e.getMessage(), e ); } }
@Test public void testGetDefinitionWithSNS() throws RepositoryException, IOException { Session session = getAdminSession(); Node node = session.getNode("/jcr:system/jcr:nodeTypes/nt:file"); // TODO: use getNode("jcr:childNodeDefinition[1]") once that works for (Node child : getChildNodes(node, "jcr:childNodeDefinition")) { NodeDefinition definition = child.getDefinition(); // OAK-829 definition.getDefaultPrimaryType(); // OAK-826 definition.getRequiredPrimaryTypes(); // OAK-826 } }