Search in sources :

Example 1 with SortKey

use of com.unboundid.ldap.sdk.controls.SortKey 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;
}
Also used : SearchRequest(com.unboundid.ldap.sdk.SearchRequest) ServerSideSortRequestControl(com.unboundid.ldap.sdk.controls.ServerSideSortRequestControl) VirtualListViewResponseControl(com.unboundid.ldap.sdk.controls.VirtualListViewResponseControl) VirtualListViewRequestControl(com.unboundid.ldap.sdk.controls.VirtualListViewRequestControl) SortKey(com.unboundid.ldap.sdk.controls.SortKey) SearchResult(com.unboundid.ldap.sdk.SearchResult) InvalidSimplePageControlException(org.gluu.persist.ldap.exception.InvalidSimplePageControlException) ConnectionException(org.gluu.persist.exception.operation.ConnectionException) SearchException(org.gluu.persist.exception.operation.SearchException) LDAPSearchException(com.unboundid.ldap.sdk.LDAPSearchException) MappingException(org.gluu.persist.exception.mapping.MappingException) LDAPException(com.unboundid.ldap.sdk.LDAPException) DuplicateEntryException(org.gluu.persist.exception.operation.DuplicateEntryException)

Aggregations

LDAPException (com.unboundid.ldap.sdk.LDAPException)1 LDAPSearchException (com.unboundid.ldap.sdk.LDAPSearchException)1 SearchRequest (com.unboundid.ldap.sdk.SearchRequest)1 SearchResult (com.unboundid.ldap.sdk.SearchResult)1 ServerSideSortRequestControl (com.unboundid.ldap.sdk.controls.ServerSideSortRequestControl)1 SortKey (com.unboundid.ldap.sdk.controls.SortKey)1 VirtualListViewRequestControl (com.unboundid.ldap.sdk.controls.VirtualListViewRequestControl)1 VirtualListViewResponseControl (com.unboundid.ldap.sdk.controls.VirtualListViewResponseControl)1 MappingException (org.gluu.persist.exception.mapping.MappingException)1 ConnectionException (org.gluu.persist.exception.operation.ConnectionException)1 DuplicateEntryException (org.gluu.persist.exception.operation.DuplicateEntryException)1 SearchException (org.gluu.persist.exception.operation.SearchException)1 InvalidSimplePageControlException (org.gluu.persist.ldap.exception.InvalidSimplePageControlException)1