Package javax.jcr

Examples of javax.jcr.NodeIterator


            && hasChunks((jcrContentNode = node.getNode(JCR_CONTENT)))) {
            chunkParent = jcrContentNode;

        }
        String startPattern = SlingPostConstants.CHUNK_NODE_NAME + "_" + "0_*";
        NodeIterator nodeItr = chunkParent.getNodes(startPattern);
        Node chunkNode = null;
        while (nodeItr.hasNext()) {
            if (nodeItr.getSize() > 1) {
                throw new RepositoryException(
                    "more than one node found for pattern: " + startPattern);
            }
            chunkNode = nodeItr.nextNode();

            String[] indexBounds = chunkNode.getName().substring(
                (SlingPostConstants.CHUNK_NODE_NAME + "_").length()).split("_");
            startPattern = SlingPostConstants.CHUNK_NODE_NAME + "_"
                + String.valueOf(Long.valueOf(indexBounds[1]) + 1) + "_*";
 
View Full Code Here


    }

    public Iterator<Resource> listChildren(Resource parent) {
        try {
            Node node = parent.adaptTo(Node.class);
            final NodeIterator nodes = node.getNodes();
            return new Iterator<Resource>() {

                public void remove() {
                    throw new UnsupportedOperationException();
                }

                public Resource next() {
                    Node next = nodes.nextNode();
                    try {
                        return new MockedResource(MockedResourceResolver.this,
                                next.getPath(), "nt:unstructured");
                    } catch (RepositoryException e) {
                        throw new RuntimeException("RepositoryException: " + e,
                                e);
                    }
                }

                public boolean hasNext() {
                    return nodes.hasNext();
                }
            };
        } catch (RepositoryException e) {
            throw new RuntimeException("RepositoryException: " + e, e);
        }
View Full Code Here

    }

    public Iterator<Resource> findResources(String query, String language) {
        List<Resource> resources = new ArrayList<Resource>();
        try {
            NodeIterator iterator = session.getWorkspace().getQueryManager().createQuery(query, language).execute().getNodes();
            while (iterator.hasNext()) {
                Node n = iterator.nextNode();
                Resource resource = new MockedResource(this, n);
                resources.add(resource);
            }
        } catch (RepositoryException e) {
            LOG.error("Unable to execute JCR query", e);
View Full Code Here

        return result;
    }

    private void scanNode(final Node folder, final ScanResult result, final Set<String> resourcesSeen)
    throws RepositoryException {
        final NodeIterator it = folder.getNodes();
        while(it.hasNext()) {
            final Node n = it.nextNode();
            boolean processed = false;
            for (JcrInstaller.NodeConverter nc : converters) {
                final InstallableResource r = nc.convertNode(n, priority);
                if(r != null) {
                    processed = true;
View Full Code Here

        final int depth = path.split("/").length;
        if(depth > maxWatchedFolderDepth) {
            logger.debug("Not recursing into {} due to maxWatchedFolderDepth={}", path, maxWatchedFolderDepth);
            return;
        }
        final NodeIterator it = n.getNodes();
        while (it.hasNext()) {
            findPathsUnderNode(it.nextNode(), result);
        }
    }
View Full Code Here

        if (session.nodeExists(pauseScanNodePath)) {
            Node node = session.getNode(pauseScanNodePath);
            boolean result = node.hasNodes();
            if (result && logger.isDebugEnabled()) {
                List<String> nodeNames = new ArrayList<String>();
                NodeIterator childItr = node.getNodes();
                while (childItr.hasNext()) {
                    nodeNames.add(childItr.nextNode().getName());
                }
                logger.debug("Found child nodes {} at path {}. Scanning would be paused", nodeNames, pauseScanNodePath);
            }
            return result;
        }
View Full Code Here

            session.refresh(false);

            finalOrder = new ArrayList<String>();

            NodeIterator nodes = session.getNode("/content").getNodes();
            while (nodes.hasNext()) {
                finalOrder.add(nodes.nextNode().getName());
            }
        } finally {
            session.removeItem("/content");
            session.save();
            session.logout();
View Full Code Here

            try {
                int counter = 0;
                resolver = rrFactory.getAdministrativeResourceResolver(null);
                Session session = resolver.adaptTo(Session.class);
                Node node = session.getNode(path);
                NodeIterator it = node.getNodes();
                while (it.hasNext()) {
                    it.nextNode().remove();
                    counter++;
                }
                session.save();

                resp.getWriter().printf("<p class='statline ui-state-error'>Deleted %s notifications</p>%n", counter);
View Full Code Here

        MockControl iteratorCtrl = MockControl.createControl(PropertyIterator.class);
        PropertyIterator iterator = (PropertyIterator) iteratorCtrl.getMock();
       
        MockControl iterCtrl = MockControl.createControl(NodeIterator.class);
        NodeIterator iter = (NodeIterator) iterCtrl.getMock();
       
        nodeCtrl.expectAndReturn(node.getPath(), "path");
        nodeCtrl.expectAndReturn(node.getProperties(), iterator);
        iteratorCtrl.expectAndReturn(iterator.hasNext(), false);
        nodeCtrl.expectAndReturn(node.getNodes(), iter);
        iterCtrl.expectAndReturn(iter.hasNext(), false);
       
        sessionControl.expectAndReturn(session.getRootNode(), node);
       
        sessionControl.replay();
        sfControl.replay();
View Full Code Here

        buffer.append(property.getString());
      }
      buffer.append("\n");
    }

    NodeIterator nodes = node.getNodes();
    while (nodes.hasNext()) {
      Node child = nodes.nextNode();
      buffer.append(dumpNode(child));
    }
    return buffer.toString();

  }
View Full Code Here

TOP

Related Classes of javax.jcr.NodeIterator

Copyright © 2018 www.massapicom. 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.