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