Class StartInteractiveTransactionExtendedRequest
- java.lang.Object
-
- com.unboundid.ldap.sdk.LDAPRequest
-
- com.unboundid.ldap.sdk.ExtendedRequest
-
- com.unboundid.ldap.sdk.unboundidds.extensions.StartInteractiveTransactionExtendedRequest
-
- All Implemented Interfaces:
ProtocolOp
,ReadOnlyLDAPRequest
,java.io.Serializable
@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 a
This 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 theInteractiveTransactionSpecificationRequestControl
. After all requests for the transaction have been submitted to the server, theEndInteractiveTransactionExtendedRequest
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 Nokia/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.
The start transaction extended request may include an element which indicates the base DN below which all operations will be attempted. This may be used to allow the Directory Server to tailor the transaction to the appropriate backend.
Whenever the client sends a start interactive transaction request to the server, theStartInteractiveTransactionExtendedResult
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 aInteractiveTransactionSpecificationRequestControl
attached to each request that is to be processed as part of the transaction. When the transaction has completed, theEndInteractiveTransactionExtendedRequest
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.Example
The following example demonstrates the process for creating an interactive transaction, processing multiple requests as part of that transaction, and then commits the transaction.// 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)); } }
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field 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.-
Fields inherited from class com.unboundid.ldap.sdk.ExtendedRequest
TYPE_EXTENDED_REQUEST_OID, TYPE_EXTENDED_REQUEST_VALUE
-
-
Constructor Summary
Constructors Constructor 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.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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.-
Methods inherited from class com.unboundid.ldap.sdk.ExtendedRequest
encodeProtocolOp, getLastMessageID, getOID, getOperationType, getProtocolOpType, getValue, hasValue, responseReceived, toCode, writeTo
-
Methods inherited from class com.unboundid.ldap.sdk.LDAPRequest
followReferrals, getControl, getControlList, getControls, getIntermediateResponseListener, getReferralConnector, getResponseTimeoutMillis, hasControl, hasControl, setFollowReferrals, setIntermediateResponseListener, setReferralConnector, setResponseTimeoutMillis, toString
-
-
-
-
Field Detail
-
START_INTERACTIVE_TRANSACTION_REQUEST_OID
public static final 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.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
StartInteractiveTransactionExtendedRequest
public StartInteractiveTransactionExtendedRequest()
Creates a new start interactive transaction extended request with no base DN.
-
StartInteractiveTransactionExtendedRequest
public StartInteractiveTransactionExtendedRequest(java.lang.String baseDN)
Creates a new start interactive transaction extended request.- Parameters:
baseDN
- The base DN to use for the request. It may benull
if no base DN should be provided.
-
StartInteractiveTransactionExtendedRequest
public StartInteractiveTransactionExtendedRequest(java.lang.String baseDN, Control[] controls)
Creates a new start interactive transaction extended request.- Parameters:
baseDN
- The base DN to use for the request. It may benull
if no base DN should be provided.controls
- The set of controls to include in the request.
-
StartInteractiveTransactionExtendedRequest
public StartInteractiveTransactionExtendedRequest(ExtendedRequest extendedRequest) throws LDAPException
Creates a new start interactive transaction extended request from the provided generic extended request.- Parameters:
extendedRequest
- The generic extended request to use to create this start interactive transaction extended request.- Throws:
LDAPException
- If a problem occurs while decoding the request.
-
-
Method Detail
-
getBaseDN
public java.lang.String getBaseDN()
Retrieves the base DN for this start interactive transaction extended request, if available.- Returns:
- The base DN for this start interactive transaction extended
request, or
null
if none was provided.
-
process
public StartInteractiveTransactionExtendedResult process(LDAPConnection connection, int depth) throws LDAPException
Sends this extended request to the directory server over the provided connection and returns the associated response.- Overrides:
process
in classExtendedRequest
- Parameters:
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.- Returns:
- An LDAP result object that provides information about the result of the extended operation processing.
- Throws:
LDAPException
- If a problem occurs while sending the request or reading the response.
-
duplicate
public StartInteractiveTransactionExtendedRequest duplicate()
Creates a new instance of this LDAP request that may be modified without impacting this request.. Subclasses should override this method to return a duplicate of the appropriate type.- Specified by:
duplicate
in interfaceReadOnlyLDAPRequest
- Overrides:
duplicate
in classExtendedRequest
- Returns:
- A new instance of this LDAP request that may be modified without impacting this request.
-
duplicate
public StartInteractiveTransactionExtendedRequest duplicate(Control[] controls)
Creates a new instance of this LDAP request that may be modified without impacting this request. The provided controls will be used for the new request instead of duplicating the controls from this request.. Subclasses should override this method to return a duplicate of the appropriate type.- Specified by:
duplicate
in interfaceReadOnlyLDAPRequest
- Overrides:
duplicate
in classExtendedRequest
- Parameters:
controls
- The set of controls to include in the duplicate request.- Returns:
- A new instance of this LDAP request that may be modified without impacting this request.
-
getExtendedRequestName
public java.lang.String getExtendedRequestName()
Retrieves the user-friendly name for the extended request, if available. If no user-friendly name has been defined, then the OID will be returned.- Overrides:
getExtendedRequestName
in classExtendedRequest
- Returns:
- The user-friendly name for this extended request, or the OID if no user-friendly name is available.
-
toString
public void toString(java.lang.StringBuilder buffer)
Appends a string representation of this request to the provided buffer.- Specified by:
toString
in interfaceProtocolOp
- Specified by:
toString
in interfaceReadOnlyLDAPRequest
- Overrides:
toString
in classExtendedRequest
- Parameters:
buffer
- The buffer to which to append a string representation of this request.
-
-