Class VirtualListViewRequestControl

java.lang.Object
com.unboundid.ldap.sdk.Control
com.unboundid.ldap.sdk.controls.VirtualListViewRequestControl
All Implemented Interfaces:
Serializable

This class provides an implementation of the LDAP virtual list view (VLV) request control as defined in draft-ietf-ldapext-ldapv3-vlv. This control may be used to retrieve arbitrary "pages" of entries from the complete set of search results. It is similar to the SimplePagedResultsControl, with the exception that the simple paged results control requires scrolling through the results in sequential order, while the VLV control allows starting and resuming at any arbitrary point in the result set. The starting point may be specified using either a positional offset, or based on the first entry with a value that is greater than or equal to a specified value.

When the start of the result set is to be specified using an offset, then the virtual list view request control should include the following elements:
  • targetOffset -- The position in the result set of the entry to target for the next page of results to return. Note that the offset is one-based (so the first entry has offset 1, the second entry has offset 2, etc.).
  • beforeCount -- The number of entries before the entry specified as the target offset that should be retrieved.
  • afterCount -- The number of entries after the entry specified as the target offset that should be retrieved.
  • contentCount -- The estimated total number of entries that are in the total result set. This should be zero for the first request in a VLV search sequence, but should be the value returned by the server in the corresponding response control for subsequent searches as part of the VLV sequence.
  • contextID -- This is an optional cookie that may be used to help the server resume processing on a VLV search. It should be absent from the initial request, but for subsequent requests should be the value returned in the previous VLV response control.
When the start of the result set is to be specified using a search string, then the virtual list view request control should include the following elements:
  • assertionValue -- The value that specifies the start of the page of results to retrieve. The target entry will be the first entry in which the value for the primary sort attribute is greater than or equal to this assertion value.
  • beforeCount -- The number of entries before the entry specified by the assertion value that should be retrieved.
  • afterCount -- The number of entries after the entry specified by the assertion value that should be retrieved.
  • contextID -- This is an optional cookie that may be used to help the server resume processing on a VLV search. It should be absent from the initial request, but for subsequent requests should be the value returned in the previous VLV response control.
Note that the virtual list view request control may only be included in a search request if that search request also includes the ServerSideSortRequestControl. This is necessary to ensure that a consistent order is used for the resulting entries.

If the search is successful, then the search result done response may include a VirtualListViewResponseControl to provide information about the state of the virtual list view processing.

Example

The following example demonstrates the use of the virtual list view request control to iterate through all users, retrieving up to 10 entries at a time:
 // Perform a search to retrieve all users in the server, but only retrieving
 // ten at a time.  Ensure that the users are sorted in ascending order by
 // last name, then first name.
 int numSearches = 0;
 int totalEntriesReturned = 0;
 SearchRequest searchRequest = new SearchRequest("dc=example,dc=com",
      SearchScope.SUB, Filter.createEqualityFilter("objectClass", "person"));
 int vlvOffset = 1;
 int vlvContentCount = 0;
 ASN1OctetString vlvContextID = null;
 while (true)
 {
   // Note that the VLV control always requires the server-side sort
   // control.
   searchRequest.setControls(
        new ServerSideSortRequestControl(new SortKey("sn"),
             new SortKey("givenName")),
        new VirtualListViewRequestControl(vlvOffset, 0, 9, vlvContentCount,
             vlvContextID));
   SearchResult searchResult = connection.search(searchRequest);
   numSearches++;
   totalEntriesReturned += searchResult.getEntryCount();
   for (SearchResultEntry e : searchResult.getSearchEntries())
   {
     // Do something with each entry...
   }

   LDAPTestUtils.assertHasControl(searchResult,
        VirtualListViewResponseControl.VIRTUAL_LIST_VIEW_RESPONSE_OID);
   VirtualListViewResponseControl vlvResponseControl =
        VirtualListViewResponseControl.get(searchResult);
   vlvContentCount = vlvResponseControl.getContentCount();
   vlvOffset += 10;
   vlvContextID = vlvResponseControl.getContextID();
   if (vlvOffset > vlvContentCount)
   {
     break;
   }
 }
 
See Also:
  • Field Details

  • Constructor Details

    • VirtualListViewRequestControl

      public VirtualListViewRequestControl(int targetOffset, int beforeCount, int afterCount, int contentCount, @Nullable ASN1OctetString contextID)
      Creates a new virtual list view request control that will identify the beginning of the result set by a target offset. It will be marked critical.
      Parameters:
      targetOffset - The position of the entry that should be used as the start of the result set.
      beforeCount - The maximum number of entries that should be returned before the entry with the specified target offset.
      afterCount - The maximum number of entries that should be returned after the entry with the specified target offset.
      contentCount - The estimated number of entries in the result set. For the first request in a series of searches with the VLV control, it should be zero. For subsequent searches in the VLV sequence, it should be the content count included in the response control from the previous search.
      contextID - The context ID that may be used to help the server continue in the same result set for subsequent searches. For the first request in a series of searches with the VLV control, it should be null. For subsequent searches in the VLV sequence, it should be the (possibly null) context ID included in the response control from the previous search.
    • VirtualListViewRequestControl

      public VirtualListViewRequestControl(@NotNull String assertionValue, int beforeCount, int afterCount, @Nullable ASN1OctetString contextID)
      Creates a new virtual list view request control that will identify the beginning of the result set by an assertion value. It will be marked critical.
      Parameters:
      assertionValue - The assertion value that will be used to identify the start of the result set. The target entry will be the first entry with a value for the primary sort attribute that is greater than or equal to this assertion value. It must not be null.
      beforeCount - The maximum number of entries that should be returned before the first entry with a value greater than or equal to the provided assertion value.
      afterCount - The maximum number of entries that should be returned after the first entry with a value greater than or equal to the provided assertion value.
      contextID - The context ID that may be used to help the server continue in the same result set for subsequent searches. For the first request in a series of searches with the VLV control, it should be null. For subsequent searches in the VLV sequence, it should be the (possibly null) context ID included in the response control from the previous search.
    • VirtualListViewRequestControl

      public VirtualListViewRequestControl(@NotNull byte[] assertionValue, int beforeCount, int afterCount, @Nullable ASN1OctetString contextID)
      Creates a new virtual list view request control that will identify the beginning of the result set by an assertion value. It will be marked critical.
      Parameters:
      assertionValue - The assertion value that will be used to identify the start of the result set. The target entry will be the first entry with a value for the primary sort attribute that is greater than or equal to this assertion value. It must not be null.
      beforeCount - The maximum number of entries that should be returned before the first entry with a value greater than or equal to the provided assertion value.
      afterCount - The maximum number of entries that should be returned after the first entry with a value greater than or equal to the provided assertion value.
      contextID - The context ID that may be used to help the server continue in the same result set for subsequent searches. For the first request in a series of searches with the VLV control, it should be null. For subsequent searches in the VLV sequence, it should be the (possibly null) context ID included in the response control from the previous search.
    • VirtualListViewRequestControl

      public VirtualListViewRequestControl(@NotNull ASN1OctetString assertionValue, int beforeCount, int afterCount, @Nullable ASN1OctetString contextID)
      Creates a new virtual list view request control that will identify the beginning of the result set by an assertion value. It will be marked critical.
      Parameters:
      assertionValue - The assertion value that will be used to identify the start of the result set. The target entry will be the first entry with a value for the primary sort attribute that is greater than or equal to this assertion value. It must not be null.
      beforeCount - The maximum number of entries that should be returned before the first entry with a value greater than or equal to the provided assertion value.
      afterCount - The maximum number of entries that should be returned after the first entry with a value greater than or equal to the provided assertion value.
      contextID - The context ID that may be used to help the server continue in the same result set for subsequent searches. For the first request in a series of searches with the VLV control, it should be null. For subsequent searches in the VLV sequence, it should be the (possibly null) context ID included in the response control from the previous search.
    • VirtualListViewRequestControl

      public VirtualListViewRequestControl(int targetOffset, int beforeCount, int afterCount, int contentCount, @Nullable ASN1OctetString contextID, boolean isCritical)
      Creates a new virtual list view request control that will identify the beginning of the result set by a target offset.
      Parameters:
      targetOffset - The position of the entry that should be used as the start of the result set.
      beforeCount - The maximum number of entries that should be returned before the entry with the specified target offset.
      afterCount - The maximum number of entries that should be returned after the entry with the specified target offset.
      contentCount - The estimated number of entries in the result set. For the first request in a series of searches with the VLV control, it should be zero. For subsequent searches in the VLV sequence, it should be the content count included in the response control from the previous search.
      contextID - The context ID that may be used to help the server continue in the same result set for subsequent searches. For the first request in a series of searches with the VLV control, it should be null. For subsequent searches in the VLV sequence, it should be the (possibly null) context ID included in the response control from the previous search.
      isCritical - Indicates whether this control should be marked critical.
    • VirtualListViewRequestControl

      public VirtualListViewRequestControl(@NotNull String assertionValue, int beforeCount, int afterCount, @Nullable ASN1OctetString contextID, boolean isCritical)
      Creates a new virtual list view request control that will identify the beginning of the result set by an assertion value. It will be marked critical.
      Parameters:
      assertionValue - The assertion value that will be used to identify the start of the result set. The target entry will be the first entry with a value for the primary sort attribute that is greater than or equal to this assertion value. It must not be null.
      beforeCount - The maximum number of entries that should be returned before the first entry with a value greater than or equal to the provided assertion value.
      afterCount - The maximum number of entries that should be returned after the first entry with a value greater than or equal to the provided assertion value.
      contextID - The context ID that may be used to help the server continue in the same result set for subsequent searches. For the first request in a series of searches with the VLV control, it should be null. For subsequent searches in the VLV sequence, it should be the (possibly null) context ID included in the response control from the previous search.
      isCritical - Indicates whether this control should be marked critical.
    • VirtualListViewRequestControl

      public VirtualListViewRequestControl(@NotNull byte[] assertionValue, int beforeCount, int afterCount, @Nullable ASN1OctetString contextID, boolean isCritical)
      Creates a new virtual list view request control that will identify the beginning of the result set by an assertion value. It will be marked critical.
      Parameters:
      assertionValue - The assertion value that will be used to identify the start of the result set. The target entry will be the first entry with a value for the primary sort attribute that is greater than or equal to this assertion value. It must not be null.
      beforeCount - The maximum number of entries that should be returned before the first entry with a value greater than or equal to the provided assertion value.
      afterCount - The maximum number of entries that should be returned after the first entry with a value greater than or equal to the provided assertion value.
      contextID - The context ID that may be used to help the server continue in the same result set for subsequent searches. For the first request in a series of searches with the VLV control, it should be null. For subsequent searches in the VLV sequence, it should be the (possibly null) context ID included in the response control from the previous search.
      isCritical - Indicates whether this control should be marked critical.
    • VirtualListViewRequestControl

      public VirtualListViewRequestControl(@NotNull ASN1OctetString assertionValue, int beforeCount, int afterCount, @Nullable ASN1OctetString contextID, boolean isCritical)
      Creates a new virtual list view request control that will identify the beginning of the result set by an assertion value. It will be marked critical.
      Parameters:
      assertionValue - The assertion value that will be used to identify the start of the result set. The target entry will be the first entry with a value for the primary sort attribute that is greater than or equal to this assertion value. It must not be null.
      beforeCount - The maximum number of entries that should be returned before the first entry with a value greater than or equal to the provided assertion value.
      afterCount - The maximum number of entries that should be returned after the first entry with a value greater than or equal to the provided assertion value.
      contextID - The context ID that may be used to help the server continue in the same result set for subsequent searches. For the first request in a series of searches with the VLV control, it should be null. For subsequent searches in the VLV sequence, it should be the (possibly null) context ID included in the response control from the previous search.
      isCritical - Indicates whether this control should be marked critical.
    • VirtualListViewRequestControl

      Creates a new virtual list view request control which is decoded from the provided generic control.
      Parameters:
      control - The generic control to be decoded as a virtual list view request control.
      Throws:
      LDAPException - If the provided control cannot be decoded as a virtual list view request control.
  • Method Details

    • getTargetOffset

      public int getTargetOffset()
      Retrieves the target offset position for this virtual list view request control, if applicable.
      Returns:
      The target offset position for this virtual list view request control, or -1 if the target is specified by an assertion value.
    • getAssertionValueString

      Retrieves the string representation of the assertion value for this virtual list view request control, if applicable.
      Returns:
      The string representation of the assertion value for this virtual list view request control, or null if the target is specified by offset.
    • getAssertionValueBytes

      Retrieves the byte array representation of the assertion value for this virtual list view request control, if applicable.
      Returns:
      The byte array representation of the assertion value for this virtual list view request control, or null if the target is specified by offset.
    • getAssertionValue

      Retrieves the assertion value for this virtual list view request control, if applicable.
      Returns:
      The assertion value for this virtual list view request control, or null if the target is specified by offset.
    • getBeforeCount

      public int getBeforeCount()
      Retrieves the number of entries that should be retrieved before the target entry.
      Returns:
      The number of entries that should be retrieved before the target entry.
    • getAfterCount

      public int getAfterCount()
      Retrieves the number of entries that should be retrieved after the target entry.
      Returns:
      The number of entries that should be retrieved after the target entry.
    • getContentCount

      public int getContentCount()
      Retrieves the estimated number of entries in the result set, if applicable.
      Returns:
      The estimated number of entries in the result set, zero if it is not known (for the first search in a sequence where the target is specified by offset), or -1 if the target is specified by an assertion value.
    • getContextID

      Retrieves the context ID for this virtual list view request control, if available.
      Returns:
      The context ID for this virtual list view request control, or null if there is none.
    • getControlName

      Retrieves the user-friendly name for this control, if available. If no user-friendly name has been defined, then the OID will be returned.
      Overrides:
      getControlName in class Control
      Returns:
      The user-friendly name for this control, or the OID if no user-friendly name is available.
    • toJSONControl

      Retrieves a representation of this virtual list view request control as a JSON object. The JSON object uses the following fields:
      • oid -- A mandatory string field whose value is the object identifier for this control. For the virtual list view request control, the OID is "2.16.840.1.113730.3.4.9".
      • control-name -- An optional string field whose value is a human-readable name for this control. This field is only intended for descriptive purposes, and when decoding a control, the oid field should be used to identify the type of control.
      • criticality -- A mandatory Boolean field used to indicate whether this control is considered critical.
      • value-base64 -- An optional string field whose value is a base64-encoded representation of the raw value for this virtual list view request control. Exactly one of the value-base64 and value-json fields must be present.
      • value-json -- An optional JSON object field whose value is a user-friendly representation of the value for this virtual list view request control. Exactly one of the value-base64 and value-json fields must be present, and if the value-json field is used, then it will use the following fields:
        • target-offset -- An optional integer field whose value is the offset of the target entry within the result set, with the first entry in the result set having an offset value of one. Exactly one of the target-offset and assertion-value fields must be provided.
        • assertion-value -- An optional string field that indicates that the target entry should be the first one in the result set in which the value of the primary sort attribute is greater than or equal to the provided assertion value. Exactly one of the target-offset and assertion-value fields must be provided.
        • before-count -- A mandatory integer field whose value is the maximum number of entries before the target entry that should be included in the page of results to return.
        • after-count -- A mandatory integer field whose value is the maximum number of entries after the target entry that should be included in the page of results to return.
        • content-count -- An optional integer field that represents the estimated number of entries in the entire result set. This field may only be present when the target-offset field is also provided, and its value may be absent or zero when retrieving the first page of results, and it should be the content-count value returned in the previous virtual list view response control for all subsequent pages.
        • context-id -- An optional string field that represents an opaque cookie that may be used to help the server continue a series of searches using the virtual list view request control. For the first search in a series, this should be absent. For all subsequent requests in the series, it should be the context-id value (if any) included in the response control from the previous page of the series. The context ID value used in the JSON representation of the control will be a base64-encoded representation of the raw cookie value that would be used in the LDAP representation of the control, and it must be treated as an opaque blob by the client.
      Overrides:
      toJSONControl in class Control
      Returns:
      A JSON object that contains a representation of this control.
    • decodeJSONControl

      @NotNull public static VirtualListViewRequestControl decodeJSONControl(@NotNull JSONObject controlObject, boolean strict) throws LDAPException
      Attempts to decode the provided object as a JSON representation of a virtual list view request control.
      Parameters:
      controlObject - The JSON object to be decoded. It must not be null.
      strict - Indicates whether to use strict mode when decoding the provided JSON object. If this is true, then this method will throw an exception if the provided JSON object contains any unrecognized fields. If this is false, then unrecognized fields will be ignored.
      Returns:
      The virtual list view request control that was decoded from the provided JSON object.
      Throws:
      LDAPException - If the provided JSON object cannot be parsed as a valid virtual list view request control.
    • toString

      public void toString(@NotNull StringBuilder buffer)
      Appends a string representation of this LDAP control to the provided buffer.
      Overrides:
      toString in class Control
      Parameters:
      buffer - The buffer to which to append the string representation of this buffer.