jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From danisevsky <danisev...@gmail.com>
Subject count of all subfolders
Date Wed, 22 Dec 2010 08:12:44 GMT
Hi, could you tell me what is the best way how to get count of
subfolders? There may be thousands so I think recursion:

	private int countAllChildren(int c, Node node) {
		try {
			NodeIterator iterator = node.getNodes();
			while (iterator.hasNext()) {
				Node child = (Node) iterator.next();
				if (child.isNodeType("nt:folder")) {
					c = countAllChildren(++c, child);
				}
			}
			return c;
		} catch (RepositoryException e) {
			throw new RuntimeException(e);
		}
	}

is not good choice.

I would like to use JCR-SQL2 query language, but every query what I
tried didn't work, e.g.:

SELECT * FROM [nt:folder] WHERE ISCHILDNODE(["+node.getPath()+"])

or

SELECT * FROM [nt:folder] as fld WHERE fld.[jcr:path] LIKE
'"+node.getPath()+"/%'

Thanks.

Mime
View raw message