001/* 002 * Copyright 2012-2024 Ping Identity Corporation 003 * All Rights Reserved. 004 */ 005/* 006 * Copyright 2012-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) 2012-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 defines a request control that may be included in a search request 057 * to indicate that the server should include replication conflict entries in 058 * the set of search result entries. 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 * This control is not based on any public standard. It was originally 071 * developed for use with the Ping Identity, UnboundID, and Nokia/Alcatel-Lucent 072 * 8661 Directory Server. It does not have a value. 073 * <BR><BR> 074 * There is no corresponding response control. Replication conflict entries may 075 * be identified by the object class "ds-sync-conflict-entry". 076 */ 077@NotMutable() 078@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE) 079public final class ReturnConflictEntriesRequestControl 080 extends Control 081{ 082 /** 083 * The OID (1.3.6.1.4.1.30221.2.5.13) for the return conflict entries request 084 * control. 085 */ 086 @NotNull public static final String RETURN_CONFLICT_ENTRIES_REQUEST_OID = 087 "1.3.6.1.4.1.30221.2.5.13"; 088 089 090 091 /** 092 * The serial version UID for this serializable class. 093 */ 094 private static final long serialVersionUID = -7688556660280234650L; 095 096 097 098 /** 099 * Creates a new return conflict entries request control. It will be marked 100 * critical. 101 */ 102 public ReturnConflictEntriesRequestControl() 103 { 104 this(true); 105 } 106 107 108 109 /** 110 * Creates a new return conflict entries request control. 111 * 112 * @param isCritical Indicates whether this control should be marked 113 * critical. 114 */ 115 public ReturnConflictEntriesRequestControl(final boolean isCritical) 116 { 117 super(RETURN_CONFLICT_ENTRIES_REQUEST_OID, isCritical, null); 118 } 119 120 121 122 /** 123 * Creates a new return conflict entries request control which is decoded from 124 * the provided generic control. 125 * 126 * @param control The generic control to be decoded as a return conflict 127 * entries request control. 128 * 129 * @throws LDAPException If the provided control cannot be decoded as a 130 * return conflict entries request control. 131 */ 132 public ReturnConflictEntriesRequestControl(@NotNull final Control control) 133 throws LDAPException 134 { 135 super(control); 136 137 if (control.hasValue()) 138 { 139 throw new LDAPException(ResultCode.DECODING_ERROR, 140 ERR_RETURN_CONFLICT_ENTRIES_REQUEST_HAS_VALUE.get()); 141 } 142 } 143 144 145 146 /** 147 * {@inheritDoc} 148 */ 149 @Override() 150 @NotNull() 151 public String getControlName() 152 { 153 return INFO_CONTROL_NAME_RETURN_CONFLICT_ENTRIES_REQUEST.get(); 154 } 155 156 157 158 /** 159 * Retrieves a representation of this return conflict entries request control 160 * as a JSON object. The JSON object uses the following fields (note that 161 * since this control does not have a value, neither the {@code value-base64} 162 * nor {@code value-json} fields may be present): 163 * <UL> 164 * <LI> 165 * {@code oid} -- A mandatory string field whose value is the object 166 * identifier for this control. For the return conflict entries request 167 * control, the OID is "1.3.6.1.4.1.30221.2.5.13". 168 * </LI> 169 * <LI> 170 * {@code control-name} -- An optional string field whose value is a 171 * human-readable name for this control. This field is only intended for 172 * descriptive purposes, and when decoding a control, the {@code oid} 173 * field should be used to identify the type of control. 174 * </LI> 175 * <LI> 176 * {@code criticality} -- A mandatory Boolean field used to indicate 177 * whether this control is considered critical. 178 * </LI> 179 * </UL> 180 * 181 * @return A JSON object that contains a representation of this control. 182 */ 183 @Override() 184 @NotNull() 185 public JSONObject toJSONControl() 186 { 187 return new JSONObject( 188 new JSONField(JSONControlDecodeHelper.JSON_FIELD_OID, 189 RETURN_CONFLICT_ENTRIES_REQUEST_OID), 190 new JSONField(JSONControlDecodeHelper.JSON_FIELD_CONTROL_NAME, 191 INFO_CONTROL_NAME_RETURN_CONFLICT_ENTRIES_REQUEST.get()), 192 new JSONField(JSONControlDecodeHelper.JSON_FIELD_CRITICALITY, 193 isCritical())); 194 } 195 196 197 198 /** 199 * Attempts to decode the provided object as a JSON representation of a 200 * return conflict entries request control. 201 * 202 * @param controlObject The JSON object to be decoded. It must not be 203 * {@code null}. 204 * @param strict Indicates whether to use strict mode when decoding 205 * the provided JSON object. If this is {@code true}, 206 * then this method will throw an exception if the 207 * provided JSON object contains any unrecognized 208 * fields. If this is {@code false}, then unrecognized 209 * fields will be ignored. 210 * 211 * @return The return conflict entries request control that was decoded from 212 * the provided JSON object. 213 * 214 * @throws LDAPException If the provided JSON object cannot be parsed as a 215 * valid return conflict entrie request control. 216 */ 217 @NotNull() 218 public static ReturnConflictEntriesRequestControl decodeJSONControl( 219 @NotNull final JSONObject controlObject, 220 final boolean strict) 221 throws LDAPException 222 { 223 final JSONControlDecodeHelper jsonControl = new JSONControlDecodeHelper( 224 controlObject, strict, false, false); 225 226 return new ReturnConflictEntriesRequestControl( 227 jsonControl.getCriticality()); 228 } 229 230 231 232 /** 233 * {@inheritDoc} 234 */ 235 @Override() 236 public void toString(@NotNull final StringBuilder buffer) 237 { 238 buffer.append("ReturnConflictEntriesRequestControl(isCritical="); 239 buffer.append(isCritical()); 240 buffer.append(')'); 241 } 242}