Class VirtualListViewResponseControl

  • All Implemented Interfaces:
    Control

    public final class VirtualListViewResponseControl
    extends Object
    implements Control
    The virtual list view response control as defined in draft-ietf-ldapext-ldapv3-vlv. This control is included with a search result in response to a virtual list view request included with a search request.

    If the result code included with this control indicates that the virtual list view request succeeded then the content count and target position give sufficient information for the client to update a list box slider position to match the newly retrieved entries and identify the target entry.

    The content count and context ID should be used in a subsequent virtual list view requests.

    The following example demonstrates use of the virtual list view controls.

     ByteString contextID = ByteString.empty();
    
     // Add a window of 2 entries on either side of the first sn=Jensen entry.
     SearchRequest request = Requests.newSearchRequest("ou=People,dc=example,dc=com",
              SearchScope.WHOLE_SUBTREE, "(sn=*)", "sn", "givenName")
              .addControl(ServerSideSortRequestControl.newControl(true, new SortKey("sn")))
              .addControl(VirtualListViewRequestControl.newAssertionControl(
                      true, ByteString.valueOf("Jensen"), 2, 2, contextID));
    
     SearchResultHandler resultHandler = new MySearchResultHandler();
     Result result = connection.search(request, resultHandler);
    
     ServerSideSortResponseControl sssControl =
             result.getControl(ServerSideSortResponseControl.DECODER, new DecodeOptions());
     if (sssControl != null && sssControl.getResult() == ResultCode.SUCCESS) {
         // Entries are sorted.
     } else {
         // Entries not necessarily sorted
     }
    
     VirtualListViewResponseControl vlvControl =
             result.getControl(VirtualListViewResponseControl.DECODER, new DecodeOptions());
     // Position in list: vlvControl.getTargetPosition()/vlvControl.getContentCount()
     
    The search result handler in this case displays pages of results as LDIF on standard out.
     private static class MySearchResultHandler implements SearchResultHandler {
    
         @Override
         public void handleExceptionResult(LdapException error) {
             // Ignore.
         }
    
         @Override
         public void handleResult(Result result) {
             // Ignore.
         }
    
         @Override
         public boolean handleEntry(SearchResultEntry entry) {
             final LDIFEntryWriter writer = new LDIFEntryWriter(System.out);
             try {
                 writer.writeEntry(entry);
                 writer.flush();
             } catch (final IOException e) {
                 // The writer could not write to System.out.
             }
             return true;
         }
    
         @Override
         public boolean handleReference(SearchResultReference reference) {
             System.out.println("Got a reference: " + reference.toString());
             return false;
         }
     }
     
    See Also:
    VirtualListViewRequestControl, draft-ietf-ldapext-ldapv3-vlv - LDAP Extensions for Scrolling View Browsing of Search Results
    • Method Detail

      • newControl

        public static VirtualListViewResponseControl newControl​(int targetPosition,
                                                                int contentCount,
                                                                ResultCode result,
                                                                ByteString contextId)
        Creates a new virtual list view response control.
        Parameters:
        targetPosition - The position of the target entry in the result set.
        contentCount - An estimate of the total number of entries in the result set.
        result - The result code indicating the outcome of the virtual list view request.
        contextId - A server-defined octet string. If present, the contextId should be sent back to the server by the client in a subsequent virtual list request.
        Returns:
        The new control.
        Throws:
        IllegalArgumentException - If targetPosition or contentCount were less than 0.
        NullPointerException - If result was null.
      • getContentCount

        public int getContentCount()
        Returns the estimated total number of entries in the result set.
        Returns:
        The estimated total number of entries in the result set.
      • getContextId

        public ByteString getContextId()
        Returns a server-defined octet string which, if present, should be sent back to the server by the client in a subsequent virtual list request.
        Returns:
        A server-defined octet string which, if present, should be sent back to the server by the client in a subsequent virtual list request, or null if there is no context ID.
      • getOid

        public String getOid()
        Description copied from interface: Control
        Returns the numeric OID associated with this control.
        Specified by:
        getOid in interface Control
        Returns:
        The numeric OID associated with this control.
      • getResult

        public ResultCode getResult()
        Returns result code indicating the outcome of the virtual list view request.
        Returns:
        The result code indicating the outcome of the virtual list view request.
      • getTargetPosition

        public int getTargetPosition()
        Returns the position of the target entry in the result set.
        Returns:
        The position of the target entry in the result set.
      • getValue

        public ByteString getValue()
        Description copied from interface: Control
        Returns the value, if any, associated with this control. Its format is defined by the specification of this control.
        Specified by:
        getValue in interface Control
        Returns:
        The value associated with this control, or null if there is no value.
      • hasValue

        public boolean hasValue()
        Description copied from interface: Control
        Returns true if this control has a value. In some circumstances it may be useful to determine if a control has a value, without actually calculating the value and incurring any performance costs.
        Specified by:
        hasValue in interface Control
        Returns:
        true if this control has a value, or false if there is no value.
      • isCritical

        public boolean isCritical()
        Description copied from interface: Control
        Returns true if it is unacceptable to perform the operation without applying the semantics of this control.

        The criticality field only has meaning in controls attached to request messages (except UnbindRequest). For controls attached to response messages and the UnbindRequest, the criticality field SHOULD be false, and MUST be ignored by the receiving protocol peer. A value of true indicates that it is unacceptable to perform the operation without applying the semantics of the control.

        Specified by:
        isCritical in interface Control
        Returns:
        true if this control must be processed by the Directory Server, or false if it can be ignored.