/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* Basic enumeration for NameClassPair, Binding, and SearchResults.
*/
private boolean cleaned = false;
/*
*/
// These checks are to accommodate referrals and limit exceptions
// which will generate an enumeration and defer the exception
// to be thrown at the end of the enumeration.
// All other exceptions are thrown immediately.
// Exceptions shouldn't be thrown here anyhow because
// process_return_code() is called before the constructor
// is called, so these are just safety checks.
// %%% need to deal with referral
NamingException e = new NamingException(
throw cont.fillInException(e);
}
// otherwise continue
}
// Ensures that context won't get closed from underneath us
}
try {
return next();
} catch (NamingException e) {
// can't throw exception
cleanup();
return null;
}
}
public boolean hasMoreElements() {
try {
return hasMore();
} catch (NamingException e) {
// can't throw exception
cleanup();
return false;
}
}
/*
*/
return;
}
// mimimize the number of calls to processReturnCode()
// (expensive when batchSize is small and there are many results)
try {
// convert referrals into a chain of LdapReferralException
} catch (LimitExceededException e) {
} catch (PartialResultException e) {
}
}
// merge any newly received referrals with any current referrals
} else {
}
}
}
}
private boolean hasMoreCalled = false;
/*
* Test if unprocessed entries or referrals exist.
*/
if (hasMoreCalled) {
return more;
}
hasMoreCalled = true;
if (!more) {
return false;
} else {
return (more = hasMoreImpl());
}
}
/*
* Retrieve the next entry.
*/
if (!hasMoreCalled) {
hasMore();
}
hasMoreCalled = false;
return nextImpl();
}
/*
* Test if unprocessed entries or referrals exist.
*/
// when page size is supported, this
// might generate an exception while attempting
// to fetch the next batch to determine
// whether there are any more elements
// test if the current set of entries has been processed
getNextBatch();
}
// test if any unprocessed entries exist
return true;
} else {
try {
// try to process another referral
return hasMoreReferrals();
} catch (LdapReferralException e) {
cleanup();
throw e;
} catch (LimitExceededException e) {
cleanup();
throw e;
} catch (PartialResultException e) {
cleanup();
throw e;
} catch (NamingException e) {
cleanup();
pre.setRootCause(e);
throw pre;
}
}
}
/*
* Retrieve the next entry.
*/
try {
return nextAux();
} catch (NamingException e) {
cleanup();
throw cont.fillInException(e);
}
}
getNextBatch(); // updates posn and limit
}
cleanup();
throw new NoSuchElementException("invalid enumeration handle");
}
// gets and outputs DN from the entry
}
// need to strip off all but lowest component of dn
// so that is relative to current context (currentDN)
try {
} catch (NamingException e) {
return dn;
}
}
// use the Java classname if present
} else {
}
ncp = new NameClassPairWithControls(
} else {
}
return ncp;
}
/*
* Append the supplied (chain of) referrals onto the
* end of the current (chain of) referrals.
*/
} else {
}
}
errEx = e;
}
protected LdapNamingEnumeration
// repeat the original operation at the new context
}
/*
* Iterate through the URLs of a referral. If successful then perform
* a search operation and merge the received results with the current
* results.
*/
(refEx.hasMoreReferrals() ||
}
// process the referrals sequentially
while (true) {
try {
break;
} catch (LdapReferralException re) {
// record a previous exception
}
continue;
} finally {
// Make sure we close referral context
}
}
return hasMoreImpl();
} else {
cleanup();
throw errEx;
}
return (false);
}
}
/*
* with those of the current enumeration.
*/
// Cleanup previous context first
// New enum will have already incremented enum count and recorded clnt
// Do this to prevent referral enumeration (ne) from decrementing
// enum count because we'll be doing that here from this
// enumeration.
// Record rest of information from new enum
}
protected void finalize() {
cleanup();
}
protected void cleanup() {
if (cleaned) return; // been there; done that
}
cleaned = true;
}
}
public void close() {
cleanup();
}
}