List of usage examples for javax.naming ReferralException skipReferral
public abstract boolean skipReferral();
From source file:org.apache.directory.studio.connection.core.io.jndi.JNDIConnectionWrapper.java
/** * Retrieves all referrals from the ReferralException and * creates or updates the ReferralsInfo. * //from w w w . ja v a2s.c om * @param referralException the referral exception * @param initialReferralsInfo the initial referrals info, may be null * * @return the created or updated referrals info * * @throws NamingException if a loop was encountered. */ static ReferralsInfo handleReferralException(ReferralException referralException, ReferralsInfo initialReferralsInfo) throws NamingException { if (initialReferralsInfo == null) { initialReferralsInfo = new ReferralsInfo(true); } Referral referral = handleReferralException(referralException, initialReferralsInfo, null); while (referralException.skipReferral()) { try { Context ctx = referralException.getReferralContext(); ctx.list(StringUtils.EMPTY); //$NON-NLS-1$ } catch (NamingException ne) { if (ne instanceof ReferralException) { if (ne != referralException) { // what a hack: // if the same exception is throw, we have another URL for the same Referral/SearchResultReference // if another exception is throws, we have a new Referral/SearchResultReference // in the latter case we null out the reference, a new one will be created by handleReferral() referral = null; } referralException = (ReferralException) ne; referral = handleReferralException(referralException, initialReferralsInfo, referral); } else { break; } } } return initialReferralsInfo; }