cancel
Showing results for 
Search instead for 
Did you mean: 

CMIS Query

adn741
Champ in-the-making
Champ in-the-making
Hello,

I read on the specs and on the web that it's possible to find documents (and maybe more) by using SQL like syntaxe.
I tried to do it whithout any success. Then I tried to find an example on the web but whithout any success too.

So i just want to know if somebody succeeded to use the query service???? And if it's possible to show a working example???

I give you what I send to Alfresco if you can tell me why it returns a 500 error???

POST /alfresco/service/api/query?alf_ticket=TICKET_eca231fs5aa1yxdec820ebc77d44dbdfbc79c91a31 HTTP/1.1
Host: alfresco
User-Agent: PEAR HTTP_Request class ( http://pear.php.net/ )
Connection: close
Authorization: Basic ZGpvZ3ggHrsib25qb3VyMzQ=
Content-Type: application/cmisquery+xml
Content-Length: 151

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<query xmlns="http://www.cmis.org/2008/05">
<statement>SELECT * FROM document</statement>
</query>
4 REPLIES 4

paulraby
Champ in-the-making
Champ in-the-making
This works for me. It took a while to get working  Smiley Very Happy

POST http://myalfresco:8080/alfresco/service/api/query HTTP/1.1
Accept: application/atom+xml;type=feed
Content-Type: application/cmisquery+xml
User-Agent: Jakarta Commons-HttpClient/3.1
Content-Length: 353
Authorization: Basic YWRtaW46YWRtaW4=
Host: uk-paulr-alfresco:8080

<query xmlns="http://www.cmis.org/2008/05">
   <statement>SELECT ObjectId, Name FROM Document WHERE IN_FOLDER('workspace://SpacesStore/5515864c-9dcd-4054-b7bc-cadf2ccd315e')</statement>
   <searchAllVersions>true</searchAllVersions>
   <pageSize>0</pageSize>
   <skipCount>0</skipCount>
   <returnAllowableActions>false</returnAllowableActions>
</query>

adn741
Champ in-the-making
Champ in-the-making
I understand why it didn't work on my computer.

The solution works on an alfresco 3.1. Mine was a 3.0.

I think the 3.0 doesn't implement cmis query api.

Thank you paulraby !!!

pbertrand
Champ in-the-making
Champ in-the-making
Hello, i'm trying to filter the alfresco files in a CMIS Query and i'm experiencing troubles.

my actual request is :

 <cmis:statement>SELECT * FROM DOCUMENT  WHERE NOT (CreatedBy = 'System')</cmis:statement>  

It works perfectly but when I add new condition, I get no documents in my list. For example : I've tried this request :

 <cmis:statement>SELECT * FROM DOCUMENT  WHERE NOT (CreatedBy = 'System') AND NOT(ContentStreamFilename = 'doclib.png')</cmis:statement>  

and got no results but i've got a lot of files that are not created by System and who the file name is not doclib.png. Do you know why it doesn't work ?

pbertrand
Champ in-the-making
Champ in-the-making
i've solved my problem. In fact cmis queries doesn't take more than one NOT condition. So you have to put all your condition in one.

here is my request :


<cmis:statement>SELECT * FROM DOCUMENT  WHERE NOT((CreatedBy = 'System') OR (Name = 'doclib.png') OR (Name = 'webpreview.swf')) </cmis:statement> 

doclib.png et webpreview.swf are generated files from alfresco share and the system files are javascript scripts and freemarker template. With this request you will have all documents created by the users of alfresco.