001/* 002 * Copyright 2007-2019 Ping Identity Corporation 003 * All Rights Reserved. 004 */ 005/* 006 * Copyright (C) 2015-2019 Ping Identity Corporation 007 * 008 * This program is free software; you can redistribute it and/or modify 009 * it under the terms of the GNU General Public License (GPLv2 only) 010 * or the terms of the GNU Lesser General Public License (LGPLv2.1 only) 011 * as published by the Free Software Foundation. 012 * 013 * This program is distributed in the hope that it will be useful, 014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 016 * GNU General Public License for more details. 017 * 018 * You should have received a copy of the GNU General Public License 019 * along with this program; if not, see <http://www.gnu.org/licenses>. 020 */ 021package com.unboundid.ldap.sdk.unboundidds.controls; 022 023 024 025import com.unboundid.asn1.ASN1OctetString; 026import com.unboundid.ldap.sdk.Control; 027import com.unboundid.ldap.sdk.LDAPException; 028import com.unboundid.ldap.sdk.ResultCode; 029import com.unboundid.ldap.sdk.controls.AssertionRequestControl; 030import com.unboundid.ldap.sdk.controls.ManageDsaITRequestControl; 031import com.unboundid.ldap.sdk.controls.PostReadRequestControl; 032import com.unboundid.ldap.sdk.controls.PreReadRequestControl; 033import com.unboundid.ldap.sdk.controls.ProxiedAuthorizationV1RequestControl; 034import com.unboundid.ldap.sdk.controls.ProxiedAuthorizationV2RequestControl; 035import com.unboundid.ldap.sdk.controls.SubtreeDeleteRequestControl; 036import com.unboundid.ldap.sdk.unboundidds.extensions. 037 StartBatchedTransactionExtendedRequest; 038import com.unboundid.util.NotMutable; 039import com.unboundid.util.ThreadSafety; 040import com.unboundid.util.ThreadSafetyLevel; 041 042import static com.unboundid.ldap.sdk.unboundidds.controls.ControlMessages.*; 043 044 045 046/** 047 * This class provides an implementation of the batched transaction 048 * specification request control, which may be used to indicate that the 049 * associated add, delete, modify, modify DN, or password modify operation is 050 * part of a batched transaction. The transaction should be created with the 051 * start batched transaction extended operation, which will obtain a transaction 052 * ID, and the transaction may be committed or aborted using the end batched 053 * transaction extended operation. 054 * <BR> 055 * <BLOCKQUOTE> 056 * <B>NOTE:</B> This class, and other classes within the 057 * {@code com.unboundid.ldap.sdk.unboundidds} package structure, are only 058 * supported for use against Ping Identity, UnboundID, and 059 * Nokia/Alcatel-Lucent 8661 server products. These classes provide support 060 * for proprietary functionality or for external specifications that are not 061 * considered stable or mature enough to be guaranteed to work in an 062 * interoperable way with other types of LDAP servers. 063 * </BLOCKQUOTE> 064 * <BR> 065 * Note that directory servers may limit the set of controls that are available 066 * for use in requests that are part of a transaction. RFC 5805 section 4 067 * indicates that the following controls may be used in conjunction with the 068 * transaction specification request control: {@link AssertionRequestControl}, 069 * {@link ManageDsaITRequestControl}, {@link PreReadRequestControl}, and 070 * {@link PostReadRequestControl}. The 071 * {@link ProxiedAuthorizationV1RequestControl} and 072 * {@link ProxiedAuthorizationV2RequestControl} controls cannot be included in 073 * requests that are part of a transaction, but you can include them in the 074 * {@link StartBatchedTransactionExtendedRequest} to indicate that all 075 * operations within the transaction should be processed with the specified 076 * authorization identity. 077 * <BR><BR> 078 * The Ping Identity, UnboundID, and Nokia/Alcatel-Lucent 8661 server products 079 * support the following additional UnboundID-specific controls in conjunction 080 * with operations included in a transaction: 081 * {@link AccountUsableRequestControl}, {@link HardDeleteRequestControl}, 082 * {@link IntermediateClientRequestControl}, 083 * {@link PasswordPolicyRequestControl}, 084 * {@link ReplicationRepairRequestControl}, {@link SoftDeleteRequestControl}, 085 * {@link SoftDeletedEntryAccessRequestControl}, 086 * {@link SubtreeDeleteRequestControl}, and {@link UndeleteRequestControl}. 087 * <BR><BR> 088 * See the documentation for the {@link StartBatchedTransactionExtendedRequest} 089 * class for an example of processing a batched transaction. 090 */ 091@NotMutable() 092@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE) 093public final class BatchedTransactionSpecificationRequestControl 094 extends Control 095{ 096 /** 097 * The OID (1.3.6.1.4.1.30221.2.5.1) for the batched transaction specification 098 * request control. 099 */ 100 public static final String BATCHED_TRANSACTION_SPECIFICATION_REQUEST_OID = 101 "1.3.6.1.4.1.30221.2.5.1"; 102 103 104 105 /** 106 * The serial version UID for this serializable class. 107 */ 108 private static final long serialVersionUID = -6817702055586260189L; 109 110 111 112 // The transaction ID for the associated transaction. 113 private final ASN1OctetString transactionID; 114 115 116 117 /** 118 * Creates a new batched transaction specification request control with the 119 * provided transaction ID. 120 * 121 * @param transactionID The transaction ID for the associated transaction, 122 * as obtained from the start batched transaction 123 * extended operation. It must not be {@code null}. 124 */ 125 public BatchedTransactionSpecificationRequestControl( 126 final ASN1OctetString transactionID) 127 { 128 super(BATCHED_TRANSACTION_SPECIFICATION_REQUEST_OID, true, 129 new ASN1OctetString(transactionID.getValue())); 130 131 this.transactionID = transactionID; 132 } 133 134 135 136 /** 137 * Creates a new batched transaction specification request control which is 138 * decoded from the provided generic control. 139 * 140 * @param control The generic control to be decoded as a batched transaction 141 * specification request control. 142 * 143 * @throws LDAPException If the provided control cannot be decoded as a 144 * batched transaction specification request control. 145 */ 146 public BatchedTransactionSpecificationRequestControl(final Control control) 147 throws LDAPException 148 { 149 super(control); 150 151 transactionID = control.getValue(); 152 if (transactionID == null) 153 { 154 throw new LDAPException(ResultCode.DECODING_ERROR, 155 ERR_TXN_REQUEST_CONTROL_NO_VALUE.get()); 156 } 157 } 158 159 160 161 /** 162 * Retrieves the transaction ID for the associated transaction. 163 * 164 * @return The transaction ID for the associated transaction. 165 */ 166 public ASN1OctetString getTransactionID() 167 { 168 return transactionID; 169 } 170 171 172 173 /** 174 * {@inheritDoc} 175 */ 176 @Override() 177 public String getControlName() 178 { 179 return INFO_CONTROL_NAME_BATCHED_TXN_REQUEST.get(); 180 } 181 182 183 184 /** 185 * {@inheritDoc} 186 */ 187 @Override() 188 public void toString(final StringBuilder buffer) 189 { 190 buffer.append("BatchedTransactionSpecificationRequestControl(" + 191 "transactionID='"); 192 buffer.append(transactionID.stringValue()); 193 buffer.append("')"); 194 } 195}