@NotMutable @ThreadSafety(level=NOT_THREADSAFE) public final class StartInteractiveTransactionExtendedRequest extends ExtendedRequest
NOTE: The use of interactive transactions is discouraged because it can create conditions which are prone to deadlocks between operations that may result in the cancellation of one or both operations. It is strongly recommended that standard LDAP transactions (which may be started using aThis class provides an implementation of the start interactive transaction extended request. It may be used to begin a transaction that allows multiple operations to be processed as a single atomic unit. Interactive transactions may include read operations, in which case it is guaranteed that no operations outside of the transaction will be allowed to access the associated entries until the transaction has been committed or aborted. TheStartTransactionExtendedRequest
) or a multi-update extended operation be used instead. Although they cannot include arbitrary read operations, LDAP transactions and multi-update operations may be used in conjunction with theAssertionRequestControl
,PreReadRequestControl
, andPostReadRequestControl
to incorporate some read capability into a transaction, and in conjunction with theModificationType.INCREMENT
modification type to increment integer values without the need to know the precise value before or after the operation (although the pre-read and/or post-read controls may be used to determine that).
StartInteractiveTransactionExtendedResult
that is returned will
include a a transaction ID, which should be included in each operation that
is part of the transaction using the
InteractiveTransactionSpecificationRequestControl
. After all
requests for the transaction have been submitted to the server, the
EndInteractiveTransactionExtendedRequest
should be used to
commit that transaction, or it may also be used to abort the transaction if
it is decided that it is no longer needed.
NOTE: This class, and other classes within the
com.unboundid.ldap.sdk.unboundidds
package structure, are only
supported for use against Ping Identity, UnboundID, and Alcatel-Lucent 8661
server products. These classes provide support for proprietary
functionality or for external specifications that are not considered stable
or mature enough to be guaranteed to work in an interoperable way with
other types of LDAP servers.
StartInteractiveTransactionExtendedResult
that is
returned will include a transaction ID that may be used to identify the
transaction for all operations which are to be performed as part of the
transaction. This transaction ID should be included in a
InteractiveTransactionSpecificationRequestControl
attached to each
request that is to be processed as part of the transaction. When the
transaction has completed, the
EndInteractiveTransactionExtendedRequest
may be used to commit it,
and it may also be used at any time to abort the transaction if it is no
longer needed.
// Start the interactive transaction and get the transaction ID. StartInteractiveTransactionExtendedRequest startTxnRequest = new StartInteractiveTransactionExtendedRequest("dc=example,dc=com"); StartInteractiveTransactionExtendedResult startTxnResult = (StartInteractiveTransactionExtendedResult) connection.processExtendedOperation(startTxnRequest); if (startTxnResult.getResultCode() != ResultCode.SUCCESS) { throw new LDAPException(startTxnResult); } ASN1OctetString txnID = startTxnResult.getTransactionID(); // At this point, we have a valid transaction. We want to ensure that the // transaction is aborted if any failure occurs, so do that in a // try-finally block. boolean txnFailed = true; try { // Perform a search to find all users in the "Sales" department. SearchRequest searchRequest = new SearchRequest("dc=example,dc=com", SearchScope.SUB, Filter.createEqualityFilter("ou", "Sales")); searchRequest.addControl( new InteractiveTransactionSpecificationRequestControl(txnID, true, true)); SearchResult searchResult = connection.search(searchRequest); if (searchResult.getResultCode() != ResultCode.SUCCESS) { throw new LDAPException(searchResult); } // Iterate through all of the users and assign a new fax number to each // of them. for (SearchResultEntry e : searchResult.getSearchEntries()) { ModifyRequest modifyRequest = new ModifyRequest(e.getDN(), new Modification(ModificationType.REPLACE, "facsimileTelephoneNumber", "+1 123 456 7890")); modifyRequest.addControl( new InteractiveTransactionSpecificationRequestControl(txnID, true, true)); connection.modify(modifyRequest); } // Commit the transaction. ExtendedResult endTxnResult = connection.processExtendedOperation( new EndInteractiveTransactionExtendedRequest(txnID, true)); if (endTxnResult.getResultCode() == ResultCode.SUCCESS) { txnFailed = false; } } finally { if (txnFailed) { connection.processExtendedOperation( new EndInteractiveTransactionExtendedRequest(txnID, false)); } }
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
START_INTERACTIVE_TRANSACTION_REQUEST_OID
The OID (1.3.6.1.4.1.30221.2.6.3) for the start interactive transaction
extended request.
|
TYPE_EXTENDED_REQUEST_OID, TYPE_EXTENDED_REQUEST_VALUE
Constructor and Description |
---|
StartInteractiveTransactionExtendedRequest()
Creates a new start interactive transaction extended request with no base
DN.
|
StartInteractiveTransactionExtendedRequest(ExtendedRequest extendedRequest)
Creates a new start interactive transaction extended request from the
provided generic extended request.
|
StartInteractiveTransactionExtendedRequest(java.lang.String baseDN)
Creates a new start interactive transaction extended request.
|
StartInteractiveTransactionExtendedRequest(java.lang.String baseDN,
Control[] controls)
Creates a new start interactive transaction extended request.
|
Modifier and Type | Method and Description |
---|---|
StartInteractiveTransactionExtendedRequest |
duplicate()
Creates a new instance of this LDAP request that may be modified without
impacting this request.
|
StartInteractiveTransactionExtendedRequest |
duplicate(Control[] controls)
Creates a new instance of this LDAP request that may be modified without
impacting this request.
|
java.lang.String |
getBaseDN()
Retrieves the base DN for this start interactive transaction extended
request, if available.
|
java.lang.String |
getExtendedRequestName()
Retrieves the user-friendly name for the extended request, if available.
|
StartInteractiveTransactionExtendedResult |
process(LDAPConnection connection,
int depth)
Sends this extended request to the directory server over the provided
connection and returns the associated response.
|
void |
toString(java.lang.StringBuilder buffer)
Appends a string representation of this request to the provided buffer.
|
encodeProtocolOp, getLastMessageID, getOID, getOperationType, getProtocolOpType, getValue, hasValue, responseReceived, toCode, writeTo
followReferrals, getControl, getControlList, getControls, getIntermediateResponseListener, getResponseTimeoutMillis, hasControl, hasControl, setFollowReferrals, setIntermediateResponseListener, setResponseTimeoutMillis, toString
public static final java.lang.String START_INTERACTIVE_TRANSACTION_REQUEST_OID
public StartInteractiveTransactionExtendedRequest()
public StartInteractiveTransactionExtendedRequest(java.lang.String baseDN)
baseDN
- The base DN to use for the request. It may be null
if no base DN should be provided.public StartInteractiveTransactionExtendedRequest(java.lang.String baseDN, Control[] controls)
baseDN
- The base DN to use for the request. It may be
null
if no base DN should be provided.controls
- The set of controls to include in the request.public StartInteractiveTransactionExtendedRequest(ExtendedRequest extendedRequest) throws LDAPException
extendedRequest
- The generic extended request to use to create this
start interactive transaction extended request.LDAPException
- If a problem occurs while decoding the request.public java.lang.String getBaseDN()
null
if none was provided.public StartInteractiveTransactionExtendedResult process(LDAPConnection connection, int depth) throws LDAPException
process
in class ExtendedRequest
connection
- The connection to use to communicate with the directory
server.depth
- The current referral depth for this request. It should
always be one for the initial request, and should only
be incremented when following referrals.LDAPException
- If a problem occurs while sending the request or
reading the response.public StartInteractiveTransactionExtendedRequest duplicate()
duplicate
in interface ReadOnlyLDAPRequest
duplicate
in class ExtendedRequest
public StartInteractiveTransactionExtendedRequest duplicate(Control[] controls)
duplicate
in interface ReadOnlyLDAPRequest
duplicate
in class ExtendedRequest
controls
- The set of controls to include in the duplicate request.public java.lang.String getExtendedRequestName()
getExtendedRequestName
in class ExtendedRequest
public void toString(java.lang.StringBuilder buffer)
toString
in interface ProtocolOp
toString
in interface ReadOnlyLDAPRequest
toString
in class ExtendedRequest
buffer
- The buffer to which to append a string representation of
this request.