001/*
002 * Copyright 2012-2022 Ping Identity Corporation
003 * All Rights Reserved.
004 */
005/*
006 * Copyright 2012-2022 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-2022 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.extensions;
037
038
039
040import com.unboundid.ldap.sdk.Control;
041import com.unboundid.ldap.sdk.ExtendedRequest;
042import com.unboundid.ldap.sdk.ExtendedResult;
043import com.unboundid.ldap.sdk.LDAPConnection;
044import com.unboundid.ldap.sdk.LDAPException;
045import com.unboundid.ldap.sdk.ResultCode;
046import com.unboundid.util.NotMutable;
047import com.unboundid.util.NotNull;
048import com.unboundid.util.Nullable;
049import com.unboundid.util.ThreadSafety;
050import com.unboundid.util.ThreadSafetyLevel;
051
052import static com.unboundid.ldap.sdk.unboundidds.extensions.ExtOpMessages.*;
053
054
055
056/**
057 * This class provides an implementation of the get subtree accessibility
058 * extended request, which may be used to request information about all subtree
059 * accessibility restrictions currently defined in the server, including for
060 * subtrees that are hidden or read-only.  Subtree accessibility may be altered
061 * using the {@link SetSubtreeAccessibilityExtendedRequest}.
062 * <BR>
063 * <BLOCKQUOTE>
064 *   <B>NOTE:</B>  This class, and other classes within the
065 *   {@code com.unboundid.ldap.sdk.unboundidds} package structure, are only
066 *   supported for use against Ping Identity, UnboundID, and
067 *   Nokia/Alcatel-Lucent 8661 server products.  These classes provide support
068 *   for proprietary functionality or for external specifications that are not
069 *   considered stable or mature enough to be guaranteed to work in an
070 *   interoperable way with other types of LDAP servers.
071 * </BLOCKQUOTE>
072 * <BR>
073 * This extended request has an OID of 1.3.6.1.4.1.30221.1.6.20 and does not
074 * have a value.
075 *
076 * @see  GetSubtreeAccessibilityExtendedResult
077 */
078@NotMutable()
079@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE)
080public final class GetSubtreeAccessibilityExtendedRequest
081       extends ExtendedRequest
082{
083  /**
084   * The OID (1.3.6.1.4.1.30221.1.6.20) for the get subtree accessibility
085   * extended request.
086   */
087  @NotNull public static final String GET_SUBTREE_ACCESSIBILITY_REQUEST_OID =
088       "1.3.6.1.4.1.30221.1.6.20";
089
090
091
092  /**
093   * The serial version UID for this serializable class.
094   */
095  private static final long serialVersionUID = 6519976409372387402L;
096
097
098
099  /**
100   * Creates a new get subtree accessibility extended request.
101   *
102   * @param  controls  The set of controls to include in the request.  It may be
103   *                   {@code null} or empty if no controls are needed.
104   */
105  public GetSubtreeAccessibilityExtendedRequest(
106              @Nullable final Control... controls)
107  {
108    super(GET_SUBTREE_ACCESSIBILITY_REQUEST_OID, null, controls);
109  }
110
111
112
113  /**
114   * Creates a new get subtree accessibility extended request from the provided
115   * generic extended request.
116   *
117   * @param  extendedRequest  The generic extended request to use to create this
118   *                          get subtree accessibility extended request.
119   *
120   * @throws  LDAPException  If a problem occurs while decoding the request.
121   */
122  public GetSubtreeAccessibilityExtendedRequest(
123              @NotNull final ExtendedRequest extendedRequest)
124         throws LDAPException
125  {
126    super(extendedRequest);
127
128    if (extendedRequest.hasValue())
129    {
130      throw new LDAPException(ResultCode.DECODING_ERROR,
131           ERR_GET_SUBTREE_ACCESSIBILITY_REQUEST_HAS_VALUE.get());
132    }
133  }
134
135
136
137  /**
138   * {@inheritDoc}
139   */
140  @Override()
141  @NotNull()
142  public GetSubtreeAccessibilityExtendedResult process(
143              @NotNull final LDAPConnection connection, final int depth)
144         throws LDAPException
145  {
146    final ExtendedResult extendedResponse = super.process(connection, depth);
147    return new GetSubtreeAccessibilityExtendedResult(extendedResponse);
148  }
149
150
151
152  /**
153   * {@inheritDoc}
154   */
155  @Override()
156  @NotNull()
157  public GetSubtreeAccessibilityExtendedRequest duplicate()
158  {
159    return duplicate(getControls());
160  }
161
162
163
164  /**
165   * {@inheritDoc}
166   */
167  @Override()
168  @NotNull()
169  public GetSubtreeAccessibilityExtendedRequest duplicate(
170              @Nullable final Control[] controls)
171  {
172    final GetSubtreeAccessibilityExtendedRequest r =
173         new GetSubtreeAccessibilityExtendedRequest(controls);
174    r.setResponseTimeoutMillis(getResponseTimeoutMillis(null));
175    return r;
176  }
177
178
179
180  /**
181   * {@inheritDoc}
182   */
183  @Override()
184  @NotNull()
185  public String getExtendedRequestName()
186  {
187    return INFO_EXTENDED_REQUEST_NAME_GET_SUBTREE_ACCESSIBILITY.get();
188  }
189
190
191
192  /**
193   * {@inheritDoc}
194   */
195  @Override()
196  public void toString(@NotNull final StringBuilder buffer)
197  {
198    buffer.append("GetSubtreeAccessibilityExtendedRequest(");
199
200    final Control[] controls = getControls();
201    if (controls.length > 0)
202    {
203      buffer.append("controls={");
204      for (int i=0; i < controls.length; i++)
205      {
206        if (i > 0)
207        {
208          buffer.append(", ");
209        }
210
211        buffer.append(controls[i]);
212      }
213      buffer.append('}');
214    }
215
216    buffer.append(')');
217  }
218}