001/* 002 * Copyright 2013-2024 Ping Identity Corporation 003 * All Rights Reserved. 004 */ 005/* 006 * Copyright 2013-2024 Ping Identity Corporation 007 * 008 * Licensed under the Apache License, Version 2.0 (the "License"); 009 * you may not use this file except in compliance with the License. 010 * You may obtain a copy of the License at 011 * 012 * http://www.apache.org/licenses/LICENSE-2.0 013 * 014 * Unless required by applicable law or agreed to in writing, software 015 * distributed under the License is distributed on an "AS IS" BASIS, 016 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 017 * See the License for the specific language governing permissions and 018 * limitations under the License. 019 */ 020/* 021 * Copyright (C) 2013-2024 Ping Identity Corporation 022 * 023 * This program is free software; you can redistribute it and/or modify 024 * it under the terms of the GNU General Public License (GPLv2 only) 025 * or the terms of the GNU Lesser General Public License (LGPLv2.1 only) 026 * as published by the Free Software Foundation. 027 * 028 * This program is distributed in the hope that it will be useful, 029 * but WITHOUT ANY WARRANTY; without even the implied warranty of 030 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 031 * GNU General Public License for more details. 032 * 033 * You should have received a copy of the GNU General Public License 034 * along with this program; if not, see <http://www.gnu.org/licenses>. 035 */ 036package com.unboundid.ldap.sdk.unboundidds.controls; 037 038 039 040import com.unboundid.ldap.sdk.Control; 041import com.unboundid.ldap.sdk.JSONControlDecodeHelper; 042import com.unboundid.ldap.sdk.LDAPException; 043import com.unboundid.ldap.sdk.ResultCode; 044import com.unboundid.util.NotMutable; 045import com.unboundid.util.NotNull; 046import com.unboundid.util.ThreadSafety; 047import com.unboundid.util.ThreadSafetyLevel; 048import com.unboundid.util.json.JSONField; 049import com.unboundid.util.json.JSONObject; 050 051import static com.unboundid.ldap.sdk.unboundidds.controls.ControlMessages.*; 052 053 054 055/** 056 * This class provides a request control which may be included in a delete or 057 * modify DN request to indicate that the server should skip any referential 058 * integrity processing that would have otherwise been done for that operation. 059 * <BR> 060 * <BLOCKQUOTE> 061 * <B>NOTE:</B> This class, and other classes within the 062 * {@code com.unboundid.ldap.sdk.unboundidds} package structure, are only 063 * supported for use against Ping Identity, UnboundID, and 064 * Nokia/Alcatel-Lucent 8661 server products. These classes provide support 065 * for proprietary functionality or for external specifications that are not 066 * considered stable or mature enough to be guaranteed to work in an 067 * interoperable way with other types of LDAP servers. 068 * </BLOCKQUOTE> 069 * <BR> 070 * The request control has an OID of "1.3.6.1.4.1.30221.2.5.30" and does not 071 * have a value. The criticality for this control may be either {@code TRUE} 072 * or {@code FALSE}, which may impact whether a server will process the 073 * associated modify DN or delete operation if the server does not support the 074 * use of this control. If a server receives a critical control that it does 075 * not support for the associated operation, then it will return a failure 076 * result without attempting to process that operation. If a server receives 077 * a non-critical control that it does not support for the associated operation, 078 * then it will process the operation as if that control had not been provided. 079 */ 080@NotMutable() 081@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE) 082public final class SuppressReferentialIntegrityUpdatesRequestControl 083 extends Control 084{ 085 /** 086 * The OID (1.3.6.1.4.1.30221.2.5.30) for the suppress referential integrity 087 * updates request control. 088 */ 089 @NotNull public static final String SUPPRESS_REFINT_REQUEST_OID = 090 "1.3.6.1.4.1.30221.2.5.30"; 091 092 093 094 /** 095 * The serial version UID for this serializable class. 096 */ 097 private static final long serialVersionUID = 4761880447993567116L; 098 099 100 101 /** 102 * Creates a new suppress referential integrity updates request control. It 103 * will be critical. 104 */ 105 public SuppressReferentialIntegrityUpdatesRequestControl() 106 { 107 this(true); 108 } 109 110 111 112 /** 113 * Creates a new suppress referential integrity updates request control. 114 * 115 * @param isCritical Indicates whether the control should be marked 116 * critical. 117 */ 118 public SuppressReferentialIntegrityUpdatesRequestControl( 119 final boolean isCritical) 120 { 121 super(SUPPRESS_REFINT_REQUEST_OID, isCritical, null); 122 } 123 124 125 126 /** 127 * Creates a new suppress referential integrity updates request control which 128 * is decoded from the provided generic control. 129 * 130 * @param control The generic control to be decoded as a suppress 131 * referential integrity updates request control. 132 * 133 * @throws LDAPException If the provided control cannot be decoded as a 134 * suppress referential integrity updates request 135 * control. 136 */ 137 public SuppressReferentialIntegrityUpdatesRequestControl( 138 @NotNull final Control control) 139 throws LDAPException 140 { 141 super(control); 142 143 if (control.hasValue()) 144 { 145 throw new LDAPException(ResultCode.DECODING_ERROR, 146 ERR_SUPPRESS_REFINT_REQUEST_CONTROL_HAS_VALUE.get()); 147 } 148 } 149 150 151 152 /** 153 * {@inheritDoc} 154 */ 155 @Override() 156 @NotNull() 157 public String getControlName() 158 { 159 return INFO_CONTROL_NAME_SUPPRESS_REFINT_REQUEST.get(); 160 } 161 162 163 164 /** 165 * Retrieves a representation of this suppress referential integrity updates 166 * request control as a JSON object. The JSON object uses the following 167 * fields (note that since this control does not have a value, neither the 168 * {@code value-base64} nor {@code value-json} fields may be present): 169 * <UL> 170 * <LI> 171 * {@code oid} -- A mandatory string field whose value is the object 172 * identifier for this control. For the suppress referential integrity 173 * updates request control, the OID is "1.3.6.1.4.1.30221.2.5.30". 174 * </LI> 175 * <LI> 176 * {@code control-name} -- An optional string field whose value is a 177 * human-readable name for this control. This field is only intended for 178 * descriptive purposes, and when decoding a control, the {@code oid} 179 * field should be used to identify the type of control. 180 * </LI> 181 * <LI> 182 * {@code criticality} -- A mandatory Boolean field used to indicate 183 * whether this control is considered critical. 184 * </LI> 185 * </UL> 186 * 187 * @return A JSON object that contains a representation of this control. 188 */ 189 @Override() 190 @NotNull() 191 public JSONObject toJSONControl() 192 { 193 return new JSONObject( 194 new JSONField(JSONControlDecodeHelper.JSON_FIELD_OID, 195 SUPPRESS_REFINT_REQUEST_OID), 196 new JSONField(JSONControlDecodeHelper.JSON_FIELD_CONTROL_NAME, 197 INFO_CONTROL_NAME_SUPPRESS_REFINT_REQUEST.get()), 198 new JSONField(JSONControlDecodeHelper.JSON_FIELD_CRITICALITY, 199 isCritical())); 200 } 201 202 203 204 /** 205 * Attempts to decode the provided object as a JSON representation of a 206 * suppress referential integrity updates request control. 207 * 208 * @param controlObject The JSON object to be decoded. It must not be 209 * {@code null}. 210 * @param strict Indicates whether to use strict mode when decoding 211 * the provided JSON object. If this is {@code true}, 212 * then this method will throw an exception if the 213 * provided JSON object contains any unrecognized 214 * fields. If this is {@code false}, then unrecognized 215 * fields will be ignored. 216 * 217 * @return The suppress referential integrity updates request control that 218 * was decoded from the provided JSON object. 219 * 220 * @throws LDAPException If the provided JSON object cannot be parsed as a 221 * valid suppress referential integrity updates 222 * request control. 223 */ 224 @NotNull() 225 public static SuppressReferentialIntegrityUpdatesRequestControl 226 decodeJSONControl(@NotNull final JSONObject controlObject, 227 final boolean strict) 228 throws LDAPException 229 { 230 final JSONControlDecodeHelper jsonControl = new JSONControlDecodeHelper( 231 controlObject, strict, false, false); 232 233 return new SuppressReferentialIntegrityUpdatesRequestControl( 234 jsonControl.getCriticality()); 235 } 236 237 238 239 /** 240 * {@inheritDoc} 241 */ 242 @Override() 243 public void toString(@NotNull final StringBuilder buffer) 244 { 245 buffer.append("SuppressReferentialIntegrityUpdatesRequestControl(" + 246 "isCritical="); 247 buffer.append(isCritical()); 248 buffer.append(')'); 249 } 250}