use of javax.jcr.NodeIterator in project jackrabbit by apache.
the class AbstractOrderByTest method checkResultOrder.
/**
* Checks if the node ordering in <code>result</code> is according to
* <code>nodeNames</code>.
* @param result the query result.
* @param nodeNames the node names.
*/
protected void checkResultOrder(QueryResult result, String[] nodeNames) throws RepositoryException {
List<Node> nodes = new ArrayList<Node>();
for (NodeIterator it = result.getNodes(); it.hasNext(); ) {
nodes.add(it.nextNode());
}
assertEquals("Wrong hit count:", nodeNames.length, nodes.size());
for (int i = 0; i < nodeNames.length; i++) {
String name = nodes.get(i).getName();
assertEquals("Wrong order of nodes:", nodeNames[i], name);
}
}
use of javax.jcr.NodeIterator in project jackrabbit by apache.
the class RepositoryServiceImpl method getChildInfos.
/**
* {@inheritDoc}
*/
public Iterator<ChildInfo> getChildInfos(SessionInfo sessionInfo, NodeId parentId) throws ItemNotFoundException, RepositoryException {
SessionInfoImpl sInfo = getSessionInfoImpl(sessionInfo);
NodeIterator children = getNode(parentId, sInfo).getNodes();
List<ChildInfo> childInfos = new ArrayList<ChildInfo>();
try {
while (children.hasNext()) {
childInfos.add(new ChildInfoImpl(children.nextNode(), sInfo.getNamePathResolver()));
}
} catch (NameException e) {
throw new RepositoryException(e);
}
return childInfos.iterator();
}
use of javax.jcr.NodeIterator in project jackrabbit by apache.
the class RepositoryServiceImpl method merge.
/**
* {@inheritDoc}
*/
public Iterator<NodeId> merge(final SessionInfo sessionInfo, final NodeId nodeId, final String srcWorkspaceName, final boolean bestEffort) throws NoSuchWorkspaceException, AccessDeniedException, MergeException, LockException, InvalidItemStateException, RepositoryException {
final SessionInfoImpl sInfo = getSessionInfoImpl(sessionInfo);
return (Iterator<NodeId>) executeWithLocalEvents(new Callable() {
public Object run() throws RepositoryException {
String nodePath = getNodePath(nodeId, sInfo);
NodeIterator it = getVersionManager(sInfo).merge(nodePath, srcWorkspaceName, bestEffort);
List<NodeId> ids = new ArrayList<NodeId>();
while (it.hasNext()) {
ids.add(idFactory.createNodeId(it.nextNode()));
}
return ids.iterator();
}
}, sInfo);
}
use of javax.jcr.NodeIterator in project jackrabbit by apache.
the class RepositoryServiceImpl method mergeActivity.
/**
* {@inheritDoc}
*/
public Iterator<NodeId> mergeActivity(SessionInfo sessionInfo, final NodeId activityId) throws UnsupportedRepositoryOperationException, RepositoryException {
final SessionInfoImpl sInfo = getSessionInfoImpl(sessionInfo);
return (Iterator<NodeId>) executeWithLocalEvents(new Callable() {
public Object run() throws RepositoryException {
Node node = getNode(activityId, sInfo);
NodeIterator it = getVersionManager(sInfo).merge(node);
List<NodeId> ids = new ArrayList<NodeId>();
while (it.hasNext()) {
ids.add(idFactory.createNodeId(it.nextNode()));
}
return ids.iterator();
}
}, sInfo);
}
use of javax.jcr.NodeIterator in project jackrabbit-oak by apache.
the class SimpleSearchTest method runTest.
@Override
public void runTest() throws Exception {
QueryManager manager = session.getWorkspace().getQueryManager();
for (int i = 0; i < NODE_COUNT; i++) {
Query query = createQuery(manager, i);
NodeIterator iterator = query.execute().getNodes();
while (iterator.hasNext()) {
Node node = iterator.nextNode();
if (node.getProperty("testcount").getLong() != i) {
throw new Exception("Invalid test result: " + node.getPath());
}
}
}
}
Aggregations