Class EntryChangeNotificationResponseControl

  • All Implemented Interfaces:
    Control

    public final class EntryChangeNotificationResponseControl
    extends Object
    implements Control
    The entry change notification response control as defined in draft-ietf-ldapext-psearch. This control provides additional information about the change that caused a particular entry to be returned as the result of a persistent search.
     Connection connection = ...;
    
     SearchRequest request =
             Requests.newSearchRequest(
                     "dc=example,dc=com", SearchScope.WHOLE_SUBTREE,
                     "(objectclass=inetOrgPerson)", "cn")
                     .addControl(PersistentSearchRequestControl.newControl(
                                 true, true, true, // critical,changesOnly,returnECs
                                 PersistentSearchChangeType.ADD,
                                 PersistentSearchChangeType.DELETE,
                                 PersistentSearchChangeType.MODIFY,
                                 PersistentSearchChangeType.MODIFYDN));
    
     ConnectionEntryReader reader = connection.search(request);
    
     while (reader.hasNext()) {
         if (!reader.isReference()) {
             SearchResultEntry entry = reader.readEntry(); // Entry that changed
    
             EntryChangeNotificationResponseControl control = entry.getControl(
                     EntryChangeNotificationResponseControl.DECODER,
                     new DecodeOptions());
    
             PersistentSearchChangeType type = control.getChangeType();
             if (type.equals(PersistentSearchChangeType.MODIFYDN)) {
                 // Previous DN: control.getPreviousName()
             }
             // Change number: control.getChangeNumber());
         }
     }
    
     
    See Also:
    PersistentSearchRequestControl, PersistentSearchChangeType, draft-ietf-ldapext-psearch - Persistent Search: A Simple LDAP Change Notification Mechanism
    • Method Detail

      • newControl

        public static EntryChangeNotificationResponseControl newControl​(PersistentSearchChangeType type,
                                                                        Dn previousName,
                                                                        long changeNumber)
        Creates a new entry change notification response control with the provided change type and optional previous distinguished name and change number.
        Parameters:
        type - The change type for this change notification control.
        previousName - The distinguished name that the entry had prior to a modify DN operation, or null if the operation was not a modify DN.
        changeNumber - The change number for the associated change, or a negative value if no change number is available.
        Returns:
        The new control.
        Throws:
        NullPointerException - If type was null.
      • newControl

        public static EntryChangeNotificationResponseControl newControl​(PersistentSearchChangeType type,
                                                                        String previousName,
                                                                        long changeNumber)
        Creates a new entry change notification response control with the provided change type and optional previous distinguished name and change number. The previous distinguished name, if provided, will be decoded using the default schema.
        Parameters:
        type - The change type for this change notification control.
        previousName - The distinguished name that the entry had prior to a modify DN operation, or null if the operation was not a modify DN.
        changeNumber - The change number for the associated change, or a negative value if no change number is available.
        Returns:
        The new control.
        Throws:
        LocalizedIllegalArgumentException - If previousName is not a valid LDAP string representation of a DN.
        NullPointerException - If type was null.
      • getChangeNumber

        public long getChangeNumber()
        Returns the change number for this entry change notification control.
        Returns:
        The change number for this entry change notification control, or a negative value if no change number is available.
      • getChangeType

        public PersistentSearchChangeType getChangeType()
        Returns the change type for this entry change notification control.
        Returns:
        The change type for this entry change notification control.
      • 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.
      • getPreviousName

        public Dn getPreviousName()
        Returns the distinguished name that the entry had prior to a modify DN operation, or null if the operation was not a modify DN.
        Returns:
        The distinguished name that the entry had prior to a modify DN operation.
      • 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.