Reputation: 45
In my project I query my alfresco repository to get all the documents who have "aspect A" and print all their names, what I want is to get the path of the found documents?
How can I do it?
Upvotes: 0
Views: 1653
Reputation: 48366
Starting from a CMIS Document object, you can call getPaths(). Assuming the object has a path (with in Alfresco everything other than the root should), it'll be the first one in the list
Your code would be something like:
String queryString = "SELECT ......"
ItemIterable<QueryResult> results = session.query(queryString, false);
for (QueryResult qResult : results) {
String objectId = qResult.getPropertyValueByQueryName(objectIdQueryName);
Document doc = (Document) session.getObject(session.createObjectId(objectId));
List<String> paths = doc.getPaths();
if (! paths.isEmpty()) {
System.out.println(objectId + " lives at " + paths.get(0));
}
}
Do note that objects can have multiple paths if they're multiply filed
Upvotes: 5