@NotMutable @ThreadSafety(level=COMPLETELY_THREADSAFE) public final class PostReadRequestControl extends Control
PostReadResponseControl
containing a version of the entry as it appeared after applying that change.
Note that this response control will only be included if the operation was
successful, so it will not be provided if the operation failed for some
reason (e.g., if the change would have violated the server schema, or if the
requester did not have sufficient permission to perform that operation).
SearchRequest
. As is the case with a search
request, if no attributes are specified, then all user attributes will be
included.
test-counter
attribute by one, and will use the pre-read and
post-read controls to determine what the previous and updated values are:
// Create a modify request that we can use to increment the value of a // custom attribute named "test-counter". ModifyRequest modifyRequest = new ModifyRequest( "uid=test.user,ou=People,dc=example,dc=com", new Modification(ModificationType.INCREMENT, "test-counter", // The attribute to increment. "1")); // The amount by which to increment the value. // Update the modify request to add both pre-read and post-read request // controls to see what the entry value was before and after the change. // We only care about getting the test-counter attribute. modifyRequest.setControls( new PreReadRequestControl("test-counter"), new PostReadRequestControl("test-counter")); // Process the modify operation in the server. LDAPResult modifyResult; try { modifyResult = connection.modify(modifyRequest); // If we got here, then the modification should have been successful. } catch (LDAPException le) { // This indicates that the operation did not complete successfully. modifyResult = le.toLDAPResult(); ResultCode resultCode = le.getResultCode(); String errorMessageFromServer = le.getDiagnosticMessage(); } LDAPTestUtils.assertResultCodeEquals(modifyResult, ResultCode.SUCCESS); // Get the pre-read and post-read response controls from the server and // retrieve the before and after values for the test-counter attribute. LDAPTestUtils.assertHasControl(modifyResult, PreReadResponseControl.PRE_READ_RESPONSE_OID); PreReadResponseControl preReadResponse = PreReadResponseControl.get(modifyResult); Integer beforeValue = preReadResponse.getEntry().getAttributeValueAsInteger("test-counter"); LDAPTestUtils.assertHasControl(modifyResult, PostReadResponseControl.POST_READ_RESPONSE_OID); PostReadResponseControl postReadResponse = PostReadResponseControl.get(modifyResult); Integer afterValue = postReadResponse.getEntry().getAttributeValueAsInteger("test-counter");
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
POST_READ_REQUEST_OID
The OID (1.3.6.1.1.13.2) for the post-read request control.
|
Constructor and Description |
---|
PostReadRequestControl(boolean isCritical,
java.lang.String... attributes)
Creates a new post-read request control that will retrieve the specified
set of attributes from the target entry.
|
PostReadRequestControl(Control control)
Creates a new post-read request control which is decoded from the provided
generic control.
|
PostReadRequestControl(java.lang.String... attributes)
Creates a new post-read request control that will retrieve the specified
set of attributes from the target entry.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String[] |
getAttributes()
Retrieves the set of attributes that will be requested for inclusion in the
entry returned in the response control.
|
java.lang.String |
getControlName()
Retrieves the user-friendly name for this control, if available.
|
void |
toString(java.lang.StringBuilder buffer)
Appends a string representation of this LDAP control to the provided
buffer.
|
decode, decode, decodeControls, deregisterDecodeableControl, encode, encodeControls, equals, getOID, getValue, hashCode, hasValue, isCritical, readFrom, registerDecodeableControl, toString, writeTo
public static final java.lang.String POST_READ_REQUEST_OID
public PostReadRequestControl(java.lang.String... attributes)
attributes
- The set of attributes to retrieve from the target
entry. It behaves in the same way as the set of
requested attributes for a search operation. If this
is empty or null
, then all user attributes
will be returned.public PostReadRequestControl(boolean isCritical, java.lang.String... attributes)
isCritical
- Indicates whether this control should be marked
critical.attributes
- The set of attributes to retrieve from the target
entry. It behaves in the same way as the set of
requested attributes for a search operation. If this
is empty or null
, then all user attributes
will be returned.public PostReadRequestControl(Control control) throws LDAPException
control
- The generic control to be decoded as a post-read request
control.LDAPException
- If the provided control cannot be decoded as a
post-read request control.public java.lang.String[] getAttributes()
public java.lang.String getControlName()
getControlName
in class Control