cancel
Showing results for 
Search instead for 
Did you mean: 

How to search for a specific aspect/property?

ocean800
Champ in-the-making
Champ in-the-making
Hi everyone! Smiley Happy

So I'm looking to get a list of all checked out documents based on certain aspects, specifically cm:checkedOut. Basically, I want to search for all documents with the aspect cm:checkedOut and assume that that would be the list of all checked out documents.

I've been able to use cm:checkedOut and searched for checked out documents in the node browser, but I'm having a hard time finding a REST endpoint that will let me search for a certain aspect. The thing that I found so far is this CMIS endpoint:

https://wiki.alfresco.com/wiki/CMIS_Web_Scripts_Reference#Query
Executes a CMIS query statement against the contents of the Repository.

GET /alfresco/service/cmis/query?q={q}&includeAllowableActions={includeAllowableActions?}&includeRelationships={includeRelationships?}&renditionFilter={renditionFilter?}&searchAllVersions={searchAllVersions?}&skipCount={skipCount?}&maxItems={maxItems?}

and I'm assuming I'd have to write a CMIS query something like this:
https://wiki.alfresco.com/wiki/CMIS_Web_Scripts_Reference#CMIS_Query

But I'm new to Alfresco and I honestly don't know if I can write a CMIS query to search for a particular aspect?

So my question is: is there a REST endpoint that will let me search for a specific aspect and do what I want to find? If it's relevant I'm using a .NET framework with C#.

Any help is greatly appreciated thanks!! Smiley Happy
3 REPLIES 3

afaust
Legendary Innovator
Legendary Innovator
Hello,

first of all, since you are using Alfresco 4.2, you should be using the proper CMIS endpoints instead of the old /alfresco/service/cmis one which has been removed in Alfresco 5.0. See the <a href="http://docs.alfresco.com/4.2/pra/1/topics/cmis-welcome.html">documentation</a> for details.

In order to search for aspects, you need to either use CMIS 1.1 (only available via the proper CMIS endpoints, not the old alfresco/service/cmis) or an <a href="http://docs.alfresco.com/4.1/concepts/opencmis-ext-using.html">extension to the CMIS bindings specifically for Alfresco</a> (works only on alfresco/service/cmis). The recommended option would be CMIS 1.1.
CMIS 1.1 provides a concept called "secondary object type" which translates to aspect in Alfresco vocabulary. This allows you to query documents based on aspects by including them in as JOIN clauses in the CMIS query or by selecting on a specific CMIS property (i.e. for multi-value / OR-conditions).

It is strongly recomended to use CMIS for generic folder/document access. The browser binding (CMIS 1.1) provides an API that is consumable by a ReST client. There are Alfresco-specific ReST endpoints that would allow you to perform similar searches, but they are primarily intended for internal use to support the Share user interface, and should not be used for application integration (unless you are willing to adapt on potentially every new version of Alfresco).

Regards
Axel

ocean800
Champ in-the-making
Champ in-the-making
Hi! Thanks for the answer! Smiley Happy

Regarding the documentation, where exactly are the RESTful endpoints? On this link(https://wiki.alfresco.com/wiki/CMIS_Web_Scripts_Reference#Get_Repositories_.28getRepositories.2C_get...) for example, the endpoints are listed as:

GET /alfresco/service/cmis


Where is that in the CMIS 1.1 documentation?? If I go to the same link for the same method all I get is this: http://docs.oasis-open.org/cmis/CMIS/v1.1/errata01/os/CMIS-v1.1-errata01-os-complete.html#x1-1670001. Where is the GET? This might be a dumb question sorry but I've been looking for the past day and I just have no idea where to find it.


Also, so if I am understanding you correctly, I should be looking for a CMIS 1.1 endpoint that allows me to executes a CMIS query statement against the contents of the Repository, instead of the the CMIS 1.0 that I was using?

Then, since CMIS 1.1 includes secondary object types, I should be able to query for them by including them in as JOIN clauses in the CMIS query… are there any examples of this that I can find? I understand how to do a query like "SELECT * FROM cmis:document WHERE cmis:name='exampleName'", but how would this be different when I am querying for an aspect? Or for properties with OR-Conditions?

Thanks Smiley Happy

afaust
Legendary Innovator
Legendary Innovator
I have linked the official Alfresco documentation in the last reply. The endpoints are used in all the examples, e.g. in <a href="http://docs.alfresco.com/5.1/pra/1/concepts/cmis-1.1-browser-binding-get.html">this one</a> (/alfresco/api/-default-/public/cmis/versions/1.1/browser). If you google a bit, there is also this <a href="https://www.google.de/url?sa=t&rct=j&q=&esrc=s&source=web&cd=2&ved=0ahUKEwj10OnZmOHNAhXIMhoKHRuNBeQQ...">first steps with CMIS</a> presentation from one of the Alfresco Summit events.

Also, you should not need to care about the specific URLs for an operation. Use a CMIS client library that will automatically look up the proper URLs to use for different operations, e.g. the OpenCMIS library is the de-facto king of handling CMIS both on client and server side.

Regards
Axel