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