Search code examples
alfrescoalfresco-shareopencmis

How to retrieve all document content from alfresco repository with seperation of document types using Open CMIS


I Want to retrieve All document content from alfresco repository. So can anyone help me that how can i traverse the repository using CMIS. And while traversing i also want to separate the documents based on its type.

At this moment i am able to get any one document by specifying the path. but now my requirement is to traverse whole repository and get all the documents.

So can any one help me with this. Also suggest me that "Traversal of all folders and later separate by specific type" will be the good approach OR "Search specific type of document using CMIS query" will be the good approach.

Thanks in Advance.


Solution

  • Yagami's answer is a good start, but there are a few things to add.

    First, do not do "select *" unless you actually need every single property the repository has. That is a potential performance problem. Only ask for what you need.

    Second, one of your comments talks about segmenting results by type. In CMIS, a type is kind of like a SQL table. So in your case, you would do three different queries using each of your three custom types as a different type in the from clause:

    select * from test:mainContract;
    select * from test:subContract;
    select * from test:royaltyStatement;
    

    Finally, unless you have just a handful of documents in your repository, you are almost certainly going to want to use a paged result set. Otherwise, you will only get back the maximum number of results the server is configured to return. That may not be large enough to get the entire set.

    For an example showing paging the result set, see Apache CMIS: Paging query result