I am trying to invoke a query to get me all the documents in a folder but when I try yo iterate through the result, I get the following CmisRuntimeException (Internal Server Error) without any clue as to what caused it in the log. I would appreciate if I could get some help in resolving this issue.
Caused by: org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException: Internal Server Error
at org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubService.convertStatusCode(AbstractAtomPubService.java:452)
at org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubService.post(AbstractAtomPubService.java:570)
at org.apache.chemistry.opencmis.client.bindings.spi.atompub.DiscoveryServiceImpl.query(DiscoveryServiceImpl.java:142)
at org.apache.chemistry.opencmis.client.runtime.SessionImpl$3.fetchPage(SessionImpl.java:567)
at org.apache.chemistry.opencmis.client.runtime.util.AbstractIterator.getCurrentPage(AbstractIterator.java:132)
at org.apache.chemistry.opencmis.client.runtime.util.CollectionIterator.hasNext(CollectionIterator.java:48)
Below I put the relevant code I used to execute the query: [Please note that I am forced to use Alfresco 3.4a and can not upgrade at the moment.] In getting the session, I used alfresco/service/cmis
for the ATOMPUB_URL path.
try {
cmisSession = getCmisSession();
// Get Content Type Definition
String contentTypeString = "cmis:document";
ObjectType contentType = cmisSession.getTypeDefinition(contentTypeString);
// Get Object Id Property Definition
PropertyDefinition<?> objectIdPropDef = contentType.getPropertyDefinitions().get(PropertyIds.OBJECT_ID);
String objectIdQueryName = objectIdPropDef.getQueryName();
// Define CMIS Query - Get all document IN_FOLDER
//Please note the difference of IN_FOLDER (immediate children) vs IN_TREE (matches any object beneath the folder)
String cquery =
"SELECT " + objectIdQueryName +
" FROM " + contentType.getQueryName() +
" WHERE IN_FOLDER('" + folderId + "')";
List<com.XXXX.model.v3.Document> docs = new ArrayList<com.XXXX.model.v3.Document>();
OperationContext oc = new OperationContextImpl();
oc.setMaxItemsPerPage(maxItems);
// The second param of query(boolean) if set to true will search all
// the previous versions.Alfresco does not support searching older version and only false
// is valid (See page 340 Alfresco-3-Web-Services book
ItemIterable<QueryResult> results = cmisSession.query(cquery, false , oc);
for (QueryResult qResult : results) { //THIS IS THE LINE I GET CMISRUNTIMEEXCEPTION —-
String objectId = qResult
.getPropertyValueByQueryName(PropertyIds.NAME);
Document doc = (Document) cmisSession.getObject(cmisSession
.createObjectId(objectId));
docs.add(conversionService
.convert(
doc,
com.XXXX.model.v3.Document.class));
}
return docs;
} catch (CmisBaseException cmisBE) {
throw new ApiBusinessException("Could not retreive documents",
cmisBE);
}