cancel
Showing results for 
Search instead for 
Did you mean: 

Query with skipCount

karstene
Champ in-the-making
Champ in-the-making
Hello,

I receive a strange Java error when I call the query function with a skipCount setting other than 0. To avoid any errors in my own code, I tried a query in the OpenCMIS 0.7 client, and I get the same error.

This is the code (using the Groovy Console):

import org.apache.chemistry.opencmis.commons.*
import org.apache.chemistry.opencmis.commons.data.*
import org.apache.chemistry.opencmis.commons.enums.*
import org.apache.chemistry.opencmis.client.api.*

String cql = "SELECT cmis:objectId, cmis:name, cmis:contentStreamLength FROM cmis:document"

//ItemIterable<QueryResult> results = session.query(cql, false)

//ItemIterable<QueryResult> results = session.query(cql, false).getPage(10)
ItemIterable<QueryResult> results = session.query(cql, false).skipTo(10).getPage(10)

results.each { hit -> 
    hit.properties.each { println "${it.queryName}: ${it.firstValue}" }
    println "————————————–"
}

println "————————————–"   
println "Total number: ${results.totalNumItems}"
println "Has more: ${results.hasMoreItems}"
println "————————————–"

And this is the error shown in the output window:

Exception thrown
org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException: Runtime error. Message: org.json.JSONException: Expected a ',' or ']' at character 105230

   at org.apache.chemistry.opencmis.client.bindings.spi.webservices.AbstractWebServicesService.convertException(AbstractWebServicesService.java:115)
   at org.apache.chemistry.opencmis.client.bindings.spi.webservices.DiscoveryServiceImpl.query(DiscoveryServiceImpl.java:87)
   at org.apache.chemistry.opencmis.client.runtime.SessionImpl$3.fetchPage(SessionImpl.java:557)
   at org.apache.chemistry.opencmis.client.runtime.util.AbstractIterator.getCurrentPage(AbstractIterator.java:132)
   at org.apache.chemistry.opencmis.client.runtime.util.CollectionPageIterator.hasNext(CollectionPageIterator.java:48)
   at ConsoleScript1.run(ConsoleScript1:13)

The error happens with every query I tried. Queries work fine as long as skipCount remains at 0. I am using a standard install of Alfresco 4.0d Community. Has anyone an idea?

thanks
Karsten
5 REPLIES 5

jpotts
World-Class Innovator
World-Class Innovator
The query in your post works as-is in my workbench (0.7.0) running against both 4.0.d Community and 4.0.2 Enterprise. In both cases I am running WAR deployments with Lucene as the search engine.

Jeff

karstene
Champ in-the-making
Champ in-the-making
ok, should have said that I am using solr, as this is the default for 4.0d. I guess, I try to switch to lucene, also to avoid other issues regarding timing of queries.

thanks for testing
Karsten

karstene
Champ in-the-making
Champ in-the-making
I checked this again and noticed that I was using the old CMIS URL (alfresco/cmis). I changed this to the new OpenCMIS path (alfresco/cmisws), and the problem went away.

But the OpenCMIS interface does not return a numItems field for the query, the old one did. numItems is optional according to the spec, so this behavior is correct. Still, I am looking for a way to get the total number of returned objects without retrieving all of them.

thanks
Karsten

goebel
Champ on-the-rise
Champ on-the-rise
Hi

I changed 'alfresco/s/cmis' to 'alfresco/cmisatom' and that works for me too.

Regards

Georges Goebel

andy
Champ on-the-rise
Champ on-the-rise
Hi

There is no reason we can not report the number of items found via CMIS.
Please raise this as an enhancement.

Andy