use of org.alfresco.query.EmptyPagingResults in project alfresco-remote-api by Alfresco.
the class GroupsImpl method getGroups.
public CollectionWithPagingInfo<Group> getGroups(final Parameters parameters) {
final List<String> includeParam = parameters.getInclude();
Paging paging = parameters.getPaging();
// Retrieve sort column. This is limited for now to sort column due to
// v0 api implementation. Should be improved in the future.
Pair<String, Boolean> sortProp = getGroupsSortProp(parameters);
// Parse where clause properties.
Query q = parameters.getQuery();
Boolean isRootParam = null;
String zoneFilter = null;
if (q != null) {
GroupsQueryWalker propertyWalker = new GroupsQueryWalker();
QueryHelper.walk(q, propertyWalker);
isRootParam = propertyWalker.getIsRoot();
List<String> zonesParam = propertyWalker.getZones();
if (zonesParam != null) {
validateZonesParam(zonesParam);
zoneFilter = zonesParam.get(0);
}
}
final AuthorityType authorityType = AuthorityType.GROUP;
final Set<String> rootAuthorities = getAllRootAuthorities(authorityType);
PagingResults<AuthorityInfo> pagingResult;
try {
pagingResult = getAuthoritiesInfo(authorityType, isRootParam, zoneFilter, rootAuthorities, sortProp, paging);
} catch (UnknownAuthorityException e) {
// Non-existent zone
pagingResult = new EmptyPagingResults<>();
}
// Create response.
final List<AuthorityInfo> page = pagingResult.getPage();
int totalItems = pagingResult.getTotalResultCount().getFirst();
List<Group> groups = new AbstractList<Group>() {
@Override
public Group get(int index) {
AuthorityInfo authorityInfo = page.get(index);
return getGroup(authorityInfo, includeParam, rootAuthorities);
}
@Override
public int size() {
return page.size();
}
};
return CollectionWithPagingInfo.asPaged(paging, groups, pagingResult.hasMoreItems(), totalItems);
}
use of org.alfresco.query.EmptyPagingResults in project alfresco-remote-api by Alfresco.
the class ForumTopicsFilteredGet method doSearch.
/**
* Do the actual search
*
* @param searchQuery Pair with query string in first and query language in second
* @param sortAscending boolean
* @param paging PagingRequest
*/
protected PagingResults<TopicInfo> doSearch(Pair<String, String> searchQuery, boolean sortAscending, PagingRequest paging) {
ResultSet resultSet = null;
PagingResults<TopicInfo> pagedResults = new EmptyPagingResults<TopicInfo>();
String sortOn = "@{http://www.alfresco.org/model/content/1.0}created";
// Setup the search parameters
SearchParameters sp = new SearchParameters();
sp.addStore(SPACES_STORE);
sp.setQuery(searchQuery.getFirst());
sp.setLanguage(searchQuery.getSecond());
sp.addSort(sortOn, sortAscending);
if (paging.getMaxItems() > 0) {
// Multiply maxItems by 10. This is to catch topics that have multiple replies and ensure that the maximum number of topics is shown.
sp.setLimit(paging.getMaxItems() * 10);
sp.setLimitBy(LimitBy.FINAL_SIZE);
}
if (paging.getSkipCount() > 0) {
sp.setSkipCount(paging.getSkipCount());
}
try {
resultSet = searchService.query(sp);
pagedResults = wrap(resultSet, paging);
} finally {
try {
resultSet.close();
} catch (Exception e) {
// do nothing
}
}
return pagedResults;
}
use of org.alfresco.query.EmptyPagingResults in project alfresco-remote-api by Alfresco.
the class GroupsFilter method getGroups.
public CollectionWithPagingInfo<Group> getGroups(final Parameters parameters) {
Paging paging = parameters.getPaging();
// Retrieve sort column. This is limited for now to sort column due to
// v0 api implementation. Should be improved in the future.
Pair<String, Boolean> sortProp = getGroupsSortProp(parameters);
// Parse where clause properties.
GroupsFilter groupsFilters = getGroupsFilterFromQueryParameters(parameters.getQuery());
final AuthorityType authorityType = AuthorityType.GROUP;
final Set<String> rootAuthorities = getAllRootAuthorities(authorityType);
PagingResults<AuthorityInfo> pagingResult;
try {
pagingResult = getAuthoritiesInfo(authorityType, groupsFilters, rootAuthorities, sortProp, paging);
} catch (UnknownAuthorityException e) {
// Non-existent zone
pagingResult = new EmptyPagingResults<>();
}
List<Group> groups = createGroupsResponse(pagingResult.getPage(), parameters.getInclude(), rootAuthorities);
int totalItems = pagingResult.getTotalResultCount().getFirst();
return CollectionWithPagingInfo.asPaged(paging, groups, pagingResult.hasMoreItems(), totalItems);
}
Aggregations