001/*
002 * Copyright 2007-2020 Ping Identity Corporation
003 * All Rights Reserved.
004 */
005/*
006 * Copyright 2007-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) 2008-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;
037
038
039
040import java.io.Serializable;
041import java.util.List;
042
043import com.unboundid.util.NotExtensible;
044import com.unboundid.util.ThreadSafety;
045import com.unboundid.util.ThreadSafetyLevel;
046
047
048
049/**
050 * This interface defines a set of methods that may be safely called in an LDAP
051 * request without altering its contents.  This interface must not be
052 * implemented by any class outside of the LDAP SDK.
053 * <BR><BR>
054 * This interface does not inherently provide the assurance of thread safety for
055 * the methods that it exposes, because it is still possible for a thread
056 * referencing the object which implements this interface to alter the request
057 * using methods not included in this interface.  However, if it can be
058 * guaranteed that no thread will alter the underlying object, then the methods
059 * exposed by this interface can be safely invoked concurrently by any number of
060 * threads.
061 */
062@NotExtensible()
063@ThreadSafety(level=ThreadSafetyLevel.INTERFACE_NOT_THREADSAFE)
064public interface ReadOnlyLDAPRequest
065       extends Serializable
066{
067  /**
068   * Retrieves the set of controls for this request.  The caller must not alter
069   * this set of controls.
070   *
071   * @return  The set of controls for this request.
072   */
073  Control[] getControls();
074
075
076
077  /**
078   * Retrieves a list containing the set of controls for this request.
079   *
080   * @return  A list containing the set of controls for this request.
081   */
082  List<Control> getControlList();
083
084
085
086  /**
087   * Indicates whether this request contains at least one control.
088   *
089   * @return  {@code true} if this request contains at least one control, or
090   *          {@code false} if not.
091   */
092  boolean hasControl();
093
094
095
096  /**
097   * Indicates whether this request contains at least one control with the
098   * specified OID.
099   *
100   * @param  oid  The object identifier for which to make the determination.  It
101   *              must not be {@code null}.
102   *
103   * @return  {@code true} if this request contains at least one control with
104   *          the specified OID, or {@code false} if not.
105   */
106  boolean hasControl(String oid);
107
108
109
110  /**
111   * Retrieves the control with the specified OID from this request.  If this
112   * request has multiple controls with the specified OID, then the first will
113   * be returned.
114   *
115   * @param  oid  The object identifier for which to retrieve the corresponding
116   *              control.  It must not be {@code null}.
117   *
118   * @return  The first control found with the specified OID, or {@code null} if
119   *          no control with that OID is included in this request.
120   */
121  Control getControl(String oid);
122
123
124
125  /**
126   * Retrieves the maximum length of time in milliseconds that processing on
127   * this operation should be allowed to block while waiting for a response from
128   * the server.
129   *
130   * @param  connection  The connection to use in order to retrieve the default
131   *                     value, if appropriate.  It may be {@code null} to
132   *                     retrieve the request-specific timeout (which may be
133   *                     negative if no response-specific timeout has been set).
134   *
135   * @return  The maximum length of time in milliseconds that processing on this
136   *          operation should be allowed to block while waiting for a response
137   *          from the server, or zero if no timeout should be enforced.
138   */
139  long getResponseTimeoutMillis(LDAPConnection connection);
140
141
142
143  /**
144   * Indicates whether to automatically follow any referrals encountered while
145   * processing this request.  If a value has been set for this request, then it
146   * will be returned.  Otherwise, the default from the connection options for
147   * the provided connection will be used.
148   *
149   * @param  connection  The connection whose connection options may be used in
150   *                     the course of making the determination.  It must not
151   *                     be {@code null}.
152   *
153   * @return  {@code true} if any referrals encountered during processing should
154   *          be automatically followed, or {@code false} if not.
155   */
156  boolean followReferrals(LDAPConnection connection);
157
158
159
160  /**
161   * Retrieves the referral connector that should be used when establishing a
162   * connection for the purpose of automatically following a referral.
163   *
164   * @param  connection  The connection that may be used in the course of
165   *                     obtaining the appropriate referral connector.  It must
166   *                     not be {@code null}.
167   *
168   * @return  The referral connector that should be used for the purpose of
169   *          automatically following a referral.  It will not be {@code null}.
170   */
171  ReferralConnector getReferralConnector(LDAPConnection connection);
172
173
174
175  /**
176   * Creates a new instance of this LDAP request that may be modified without
177   * impacting this request.
178   *
179   * @return  A new instance of this LDAP request that may be modified without
180   *          impacting this request.
181   */
182  LDAPRequest duplicate();
183
184
185
186  /**
187   * Creates a new instance of this LDAP request that may be modified without
188   * impacting this request.  The provided controls will be used for the new
189   * request instead of duplicating the controls from this request.
190   *
191   * @param  controls  The set of controls to include in the duplicate request.
192   *
193   * @return  A new instance of this LDAP request that may be modified without
194   *          impacting this request.
195   */
196  LDAPRequest duplicate(Control[] controls);
197
198
199
200  /**
201   * Retrieves a string representation of this request.
202   *
203   * @return  A string representation of this request.
204   */
205  @Override()
206  String toString();
207
208
209
210  /**
211   * Appends a string representation of this request to the provided buffer.
212   *
213   * @param  buffer  The buffer to which to append a string representation of
214   *                 this request.
215   */
216  void toString(StringBuilder buffer);
217
218
219
220  /**
221   * Appends a number of lines comprising the Java source code that can be used
222   * to recreate this request to the given list.
223   *
224   * @param  lineList           The list to which the source code lines should
225   *                            be added.
226   * @param  requestID          The name that should be used as an identifier
227   *                            for the request.  If this is {@code null} or
228   *                            empty, then a generic ID will be used.
229   * @param  indentSpaces       The number of spaces that should be used to
230   *                            indent the generated code.  It must not be
231   *                            negative.
232   * @param  includeProcessing  Indicates whether the generated code should
233   *                            include code required to actually process the
234   *                            request and handle the result (if {@code true}),
235   *                            or just to generate the request (if
236   *                            {@code false}).
237   */
238  void toCode(List<String> lineList, String requestID,
239              int indentSpaces, boolean includeProcessing);
240}