Hi, i need to retrieve all the users of alfresco on a java action here the code i use :
private NodeService nodeService;
private OwnableService ownableService;
private PersonService personService;
private PermissionService permissionService;
private AuthorityService authorityService;
@Override
protected void executeImpl(Action action, NodeRef actionedUponNodeRef) {
PagingResults<PersonInfo> users =
personService.getPeople(
"*",
new ArrayList<QName>(),
new ArrayList<Pair<QName,Boolean>>(),
new PagingRequest(personService.countPeople())
);
logger.info("The number of users in the system: " + personService.countPeople());
for(;users.hasMoreItems():smileywink: //always false ???????
{
for(PersonInfo personInfo : users.getPage()) {
//THIS PART OF CODE IS NEVER REACHED
String authority = personInfo.getUserName();
logger.info("Analizzo Nodo Utente: " + authority);
}
}
}
It's the code right?
Because it's seem i never reach the code in the inner loop of users.getPage().
UPDATE
Just like Faust said i use the pagingResult in a wrong way. For anyone found it useful here is how resolve the problemastic by using a lucene query:
ResultSet rs = null;
SearchParameters sp = new SearchParameters();
sp.addLocale(new Locale("it", "IT"));
sp.addStore(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);
sp.setLanguage(SearchService.LANGUAGE_LUCENE);
sp.setQuery("TYPE:\"cm
erson\"");
sp.setLimitBy(LimitBy.UNLIMITED);
//little hack to remove the limit from the query
sp.setMaxItems(-1);
sp.setMaxPermissionChecks(100000);
sp.setMaxPermissionCheckTimeMillis(100000);
sp.addSort(new SortDefinition(SortType.FIELD,ContentModel.PROP_USERNAME.toString(), true));
rs = searchService.query(sp);
long count = rs.getNumberFound();
logger.info("The number of users in the system: " + personService.countPeople());
logger.info("The number of users in the query : " + String.valueOf(count));
for(int i=0;i<rs.length();i++){
ResultSetRow row = rs.getRow(i);
NodeRef personNodeRef = row.getNodeRef();
String authority = (String)nodeService.getProperty(personNodeRef,ContentModel.PROP_USERNAME);
...............................................................................
logger.info("Username:" + authority);
}