@Override
public PagedConnObjectTOResult listConnObjects(
final String key, final String anyTypeKey, final ConnObjectTOListQuery listQuery) {
Pair<SearchResult, List<ConnObjectTO>> list = logic.listConnObjects(key, anyTypeKey,
listQuery.getSize(), listQuery.getPagedResultsCookie(), getOrderByClauses(listQuery.getOrderBy()));
PagedConnObjectTOResult result = new PagedConnObjectTOResult();
if (list.getLeft() != null) {
result.setAllResultsReturned(list.getLeft().isAllResultsReturned());
result.setPagedResultsCookie(list.getLeft().getPagedResultsCookie());
result.setRemainingPagedResults(list.getLeft().getRemainingPagedResults());
}
result.getResult().addAll(list.getRight());
UriBuilder builder = uriInfo.getAbsolutePathBuilder();
MultivaluedMap<String, String> queryParams = uriInfo.getQueryParameters();
for (Map.Entry<String, List<String>> queryParam : queryParams.entrySet()) {
builder = builder.queryParam(queryParam.getKey(), queryParam.getValue().toArray());
}
if (StringUtils.isNotBlank(result.getPagedResultsCookie())) {
result.setNext(builder.
replaceQueryParam(PARAM_CONNID_PAGED_RESULTS_COOKIE, result.getPagedResultsCookie()).
replaceQueryParam(PARAM_SIZE, listQuery.getSize()).
build());
}
return result;
}