Mark
Mark

Reputation: 7

How to show data from alfresco database?

If I want to know a number of all files in alfresco to show on alfresco page how to do that first?

Now I am not find api access to database and if I find api, what should I do next?

Upvotes: 0

Views: 3461

Answers (3)

streetturtle
streetturtle

Reputation: 5850

According to my experience sometimes it is better to get such information from database.

Just for info: in my current project we have more than 50000 documents in repo and I need to get exact number for monitoring.

Here is few points to use DB queries in some cases:

  1. CMIS is (much) slower (in my case it took ~1-2 seconds per query). As @lightoze suggested you can use SearchService, but then you'll get the documents in ResultSet, so after you'll need also to call length method to get the number of them, which I think is more time consuming rather than sql call. And in my case I do such calls every 5 minutes.

  2. There is a bug in 5.0.c which limits the result of some queries by 1000 docs.

Here you can find how to connect to database and here some interesting queries including the total number of documents in repo.

Upvotes: 1

6LYTH3
6LYTH3

Reputation: 1476

easy way, you can query all type in database by api : localhost:8080/alfresco/service/cmis/query?q={q}
q is CMIS Query Language for alfresco. example SELECT * FROM cmis:document it selects all properties for all documents

see more CMIS Query Language

Upvotes: 1

lightoze
lightoze

Reputation: 121

You can make a query to SearchService, like this:

SearchParameters params = new SearchParameters();
params.getStores().add(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);
params.setLanguage(SearchService.LANGUAGE_FTS_ALFRESCO);
params.setQuery("TYPE:cm\\:content AND PATH:\"/app\\:company_home/st\\:sites/cm\\:test/cm\\:documentLibrary//*\"");
ResultSet result = searchService.query(params);
System.out.println(result.length());

But I'm not sure how optimised it is for performance.

Upvotes: 3

Related Questions