use of com.unboundid.ldap.sdk.controls.ServerSideSortRequestControl in project oxCore by GluuFederation.
the class LdapOperationsServiceImpl method searchVirtualListView.
/*
* (non-Javadoc)
*
* @see
* org.gluu.site.ldap.PlatformOperationFacade#searchVirtualListView(java.lang.
* String, com.unboundid.ldap.sdk.Filter, org.xdi.ldap.model.SearchScope, int,
* int, java.lang.String, org.xdi.ldap.model.SortOrder,
* org.xdi.ldap.model.VirtualListViewResponse, java.lang.String)
*/
@Deprecated
public SearchResult searchVirtualListView(String dn, Filter filter, SearchScope scope, int startIndex, int count, String sortBy, SortOrder sortOrder, ListViewResponse vlvResponse, String... attributes) throws Exception {
if (StringHelper.equalsIgnoreCase(dn, "o=gluu")) {
(new Exception()).printStackTrace();
}
SearchRequest searchRequest;
if (attributes == null) {
searchRequest = new SearchRequest(dn, scope, filter);
} else {
searchRequest = new SearchRequest(dn, scope, filter, attributes);
}
// startIndex and count should be "cleansed" before arriving here
int targetOffset = startIndex;
int beforeCount = 0;
int afterCount = (count > 0) ? (count - 1) : 0;
int contentCount = 0;
boolean reverseOrder = false;
if (sortOrder != null) {
reverseOrder = sortOrder.equals(SortOrder.DESCENDING) ? true : false;
}
// Note that the VLV control always requires the server-side sort control.
searchRequest.setControls(new ServerSideSortRequestControl(new SortKey(sortBy, reverseOrder)), new VirtualListViewRequestControl(targetOffset, beforeCount, afterCount, contentCount, null));
SearchResult searchResult = getConnectionPool().search(searchRequest);
/*
* for (SearchResultEntry searchResultEntry : searchResult.getSearchEntries()) {
* log.info("##### searchResultEntry = " + searchResultEntry.toString()); }
*/
// LDAPTestUtils.assertHasControl(searchResult,
// VirtualListViewResponseControl.VIRTUAL_LIST_VIEW_RESPONSE_OID);
VirtualListViewResponseControl vlvResponseControl = VirtualListViewResponseControl.get(searchResult);
// Get results info
vlvResponse.setItemsPerPage(searchResult.getEntryCount());
vlvResponse.setTotalResults(vlvResponseControl.getContentCount());
vlvResponse.setStartIndex(vlvResponseControl.getTargetPosition());
return searchResult;
}
Aggregations