001/*
002 * Copyright 2024 Ping Identity Corporation
003 * All Rights Reserved.
004 */
005/*
006 * Copyright 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) 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.forgerockds.controls;
037
038
039
040import com.unboundid.ldap.sdk.Control;
041import com.unboundid.ldap.sdk.LDAPException;
042import com.unboundid.ldap.sdk.ResultCode;
043import com.unboundid.util.NotMutable;
044import com.unboundid.util.NotNull;
045import com.unboundid.util.ThreadSafety;
046import com.unboundid.util.ThreadSafetyLevel;
047
048import static com.unboundid.ldap.sdk.forgerockds.controls.ControlMessages.*;
049
050
051
052/**
053 * This class provides an implementation of a control that may be used to
054 * request that the server return the replication change sequence number (CSN)
055 * that it has assigned to the associated add, delete, modify, or modify DN
056 * operation.
057 * <BR>
058 * This request control has an OID of 1.3.6.1.4.1.42.2.27.9.5.9, the criticality
059 * may be either true or false, and it does not have a value.
060 *
061 * @see ChangeSequenceNumberResponseControl
062 */
063@NotMutable()
064@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE)
065public final class ChangeSequenceNumberRequestControl
066       extends Control
067{
068  /**
069   * The OID (1.3.6.1.4.1.42.2.27.9.5.9) for the change sequence number request
070   * control.
071   */
072  @NotNull public static final String CHANGE_SEQUENCE_NUMBER_REQUEST_OID =
073       "1.3.6.1.4.1.42.2.27.9.5.9";
074
075
076
077  /**
078   * The serial version UID for this serializable class.
079   */
080  private static final long serialVersionUID = 3753511587752899510L;
081
082
083
084  /**
085   * Creates a new change sequence number  request control.  It will not be
086   * marked critical.
087   */
088  public ChangeSequenceNumberRequestControl()
089  {
090    this(false);
091  }
092
093
094
095  /**
096   * Creates a new change sequence number request control with the specified
097   * criticality.
098   *
099   * @param  isCritical  Indicates whether the control should be marked
100   *                     critical.
101   */
102  public ChangeSequenceNumberRequestControl(final boolean isCritical)
103  {
104    super(CHANGE_SEQUENCE_NUMBER_REQUEST_OID, isCritical, null);
105  }
106
107
108
109  /**
110   * Creates a new change sequence number request control that is decoded from
111   * the provided generic control.
112   *
113   * @param  control  The generic control to be decoded as a change sequence
114   *                  number request control.
115   *
116   * @throws  LDAPException  If the provided control cannot be decoded as a
117   *                         change sequence number  request control.
118   */
119  public ChangeSequenceNumberRequestControl(@NotNull final Control control)
120         throws LDAPException
121  {
122    super(control);
123
124    if (control.hasValue())
125    {
126      throw new LDAPException(ResultCode.DECODING_ERROR,
127           ERR_CSN_REQUEST_HAS_VALUE.get());
128    }
129  }
130
131
132
133  /**
134   * {@inheritDoc}
135   */
136  @Override()
137  @NotNull()
138  public String getControlName()
139  {
140    return INFO_CONTROL_NAME_CSN_REQUEST.get();
141  }
142
143
144
145  /**
146   * {@inheritDoc}
147   */
148  @Override()
149  public void toString(@NotNull final StringBuilder buffer)
150  {
151    buffer.append("ChangeSequenceNumberRequestControl()");
152  }
153}