Hi,
I have to get a list of all usernames in Alfresco. It is Alfresco 5 Community Edition. There are many thousands of users. This is my code to get all usernames with a CMIS query:
String query ="SELECT cm:userName FROM cm:person"; ItemIterable<QueryResult> users =this.cmisSession.query(query, false); int pagesize =500;int offset =0;int count =0;boolean done =false; while(!done){ ItemIterable<QueryResult> page = users.skipTo(offset).getPage(pagesize);for(QueryResult result : page){String username = result.getPropertyValueByQueryName("cm:userName"); log.debug("found username ["+(++count)+"] : '"+ username +"'");} offset += pagesize; done =!page.getHasMoreItems(); log.debug("offset = "+ offset +", done = "+ done);}
When I run it, I get the following result:
found username [1]:'guest' found username [2]:'admin' found username [3]:'TestUser_1' ...found username [500]:'TestUser_3278' offset =500, done =false found username [501]:'TestUser_3279' found username [502]:'TestUser_3280' ...found username [1000]:'TestUser_7902' offset =1000, done =false offset =1500, done =false offset =2000, done =false offset =2500, done =false ...
I have read some posts about a limit of 1000 in a single query, but I think it must be possible to get more than thousands by using paging and multiple queries?
Would be great if someone could give me a hint what is wrong with my code.
Thanks,
Pascal