001/*
002 * Copyright 2015-2018 Ping Identity Corporation
003 * All Rights Reserved.
004 */
005/*
006 * Copyright (C) 2015-2018 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.ldap.sdk.Control;
026import com.unboundid.ldap.sdk.LDAPException;
027import com.unboundid.ldap.sdk.ResultCode;
028import com.unboundid.util.NotMutable;
029import com.unboundid.util.ThreadSafety;
030import com.unboundid.util.ThreadSafetyLevel;
031
032import static com.unboundid.ldap.sdk.unboundidds.controls.ControlMessages.*;
033
034
035
036/**
037 * This class provides an implementation of the name with entryUUID request
038 * control.  It may be included in an add request to indicate that the server
039 * should replace the provided RDN with the server-generated entryUUID value.
040 * It will also cause the server to include a
041 * {@link com.unboundid.ldap.sdk.controls.PostReadResponseControl} in
042 * the add result to make the generated DN available to the client.  If the
043 * request already includes a
044 * {@link com.unboundid.ldap.sdk.controls.PostReadRequestControl}, then the
045 * attributes included in the post-read response control will be generated from
046 * that request control.  Otherwise, the server will behave as if the request
047 * had included a post-read request control requesting only the entryUUID
048 * attribute.
049 * <BR>
050 * <BLOCKQUOTE>
051 *   <B>NOTE:</B>  This class, and other classes within the
052 *   {@code com.unboundid.ldap.sdk.unboundidds} package structure, are only
053 *   supported for use against Ping Identity, UnboundID, and Alcatel-Lucent 8661
054 *   server products.  These classes provide support for proprietary
055 *   functionality or for external specifications that are not considered stable
056 *   or mature enough to be guaranteed to work in an interoperable way with
057 *   other types of LDAP servers.
058 * </BLOCKQUOTE>
059 * <BR>
060 * This control has an OID of "1.3.6.1.4.1.30221.2.5.44".  It is recommended
061 * that it be used with a criticality of {@code true}.  It does not take a
062 * value.
063 */
064@NotMutable()
065@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE)
066public final class NameWithEntryUUIDRequestControl
067       extends Control
068{
069  /**
070   * The OID (1.3.6.1.4.1.30221.2.5.44) for the name with entryUUID request
071   * control.
072   */
073  public static final  String NAME_WITH_ENTRY_UUID_REQUEST_OID =
074       "1.3.6.1.4.1.30221.2.5.44";
075
076
077
078  /**
079   * The serial version UID for this serializable class.
080   */
081  private static final long serialVersionUID = -1083494935823253033L;
082
083
084
085  /**
086   * Creates a new name with entryUUID request control.  It will be marked
087   * critical.
088   */
089  public NameWithEntryUUIDRequestControl()
090  {
091    this(true);
092  }
093
094
095
096  /**
097   * Creates a new name with entryUUID request control with the specified
098   * criticality.
099   *
100   * @param  isCritical  Indicates whether this control should be marked
101   *                     critical.
102   */
103  public NameWithEntryUUIDRequestControl(final boolean isCritical)
104  {
105    super(NAME_WITH_ENTRY_UUID_REQUEST_OID, isCritical, null);
106  }
107
108
109
110  /**
111   * Creates a new name with entryUUID request control which is decoded from the
112   * provided generic control.
113   *
114   * @param  control  The generic control to be decoded as a name with entryUUID
115   *                  request control.
116   *
117   * @throws LDAPException  If the provided control cannot be decoded as a name
118   *                         with entryUUID request control.
119   */
120  public NameWithEntryUUIDRequestControl(final Control control)
121       throws LDAPException
122  {
123    super(control);
124
125    if (control.hasValue())
126    {
127      throw new LDAPException(ResultCode.DECODING_ERROR,
128           ERR_NAME_WITH_ENTRY_UUID_REQUEST_HAS_VALUE.get());
129    }
130  }
131
132
133
134  /**
135   * {@inheritDoc}
136   */
137  @Override()
138  public String getControlName()
139  {
140    return INFO_CONTROL_NAME_WITH_ENTRY_UUID_REQUEST.get();
141  }
142
143
144
145  /**
146   * {@inheritDoc}
147   */
148  @Override()
149  public void toString(final StringBuilder buffer)
150  {
151    buffer.append("NameWithEntryUUIDRequestControl(isCritical=");
152    buffer.append(isCritical());
153    buffer.append(')');
154  }
155}