Search code examples
javaopencmis

Retrieving a Document from a QueryResult with OpenCMIS


I'm using the Apache Chemistry OpenCMIS java library. Given a QueryResult (e.g. I found a document or a bunch of documents by searching on metadata properties), is this a reasonable way to retrieve the Document object itself? Or is there a more efficient way?

ItemIterable<QueryResult> results = session.query("SELECT * FROM cmis:document WHERE cmis:name LIKE 'test%'", false);

for(QueryResult hit: results) {
        Document document = (Document) session.getObject(session.createObjectId((String) hit.getPropertyValueById("cmis:objectId"))); 
    }

Solution

  • Try the Session.queryObjects() method.