cancel
Showing results for 
Search instead for 
Did you mean: 

How to query categories with CMIS

evoci
Champ in-the-making
Champ in-the-making
I have a Alfresco Community 5.0a repository, and would like to retrieve categories uid starting from their name using java and OpenCmis (alfresco-opencmis-extension-0.7.jar).
I try to execute

ItemIterable<QueryResult> results = session.query("SELECT * FROM cm:category", false);

but Alfresco logs

01120974 Failed to execute script 'classpath*:alfresco/templates/webscripts/org/alfresco/cmis/queries.post.cmisquery.js': 01120973 Type is unsupported in query: cm:category


I understand that this straightforward approach to retrieve categories is not supported by the opencmis extension I use, and wonder what else I could do.

Thanks
4 REPLIES 4

mrogers
Star Contributor
Star Contributor
If you use the cmis 1.1 endpoints then the query will work.   No need for the extension.

However its not that simple since you will be looking up the category rather than the nodes with that category.    I think you can do it with two lookups with CMIS 1.1   IIRC Jeff Potts looked at this in his first review of Alfresco's CMIS 1.1.

evoci
Champ in-the-making
Champ in-the-making
Got it, thanks.
Can you recommend a way for retrieving children of a category better than querying

SELECT cmis:objectId,cmis:name,alfcmis:nodeRef FROM cm:category C WHERE CONTAINS(C, 'PATH:\"/cm:generalclassifiable/cm:"
                  + categoryName + "/*\"')

mrogers
Star Contributor
Star Contributor
I think you can search by CATEGORY.    Certainly the Categories and TAGS are in the index.

vizziello
Champ in-the-making
Champ in-the-making
Hi,

you could use a POST request to get all information that you need.

Try with this query:

SELECT * FROM cm:category C WHERE CONTAINS(C, 'PATH:\"/cm:generalclassifiable//[CATEGORY-NAME]\"')

This is an example for category "Giurisprudenza":

http://localhost:8080/alfresco/api/-default-/public/cmis/versions/1.1/browser/?cmisaction=query&stat...

Best regards,
Giuseppe.