src/java.naming/share/classes/com/sun/jndi/ldap/AbstractLdapNamingEnumeration.java

Print this page




 283     protected abstract T createItem(String dn, Attributes attrs,
 284         Vector<Control> respCtls) throws NamingException;
 285 
 286     /*
 287      * Append the supplied (chain of) referrals onto the
 288      * end of the current (chain of) referrals.
 289      */
 290     @Override
 291     public void appendUnprocessedReferrals(LdapReferralException ex) {
 292         if (refEx != null) {
 293             refEx = refEx.appendUnprocessedReferrals(ex);
 294         } else {
 295             refEx = ex.appendUnprocessedReferrals(refEx);
 296         }
 297     }
 298 
 299     final void setNamingException(NamingException e) {
 300         errEx = e;
 301     }
 302 
 303     protected abstract AbstractLdapNamingEnumeration<T> getReferredResults(
 304             LdapReferralContext refCtx) throws NamingException;
 305 
 306     /*
 307      * Iterate through the URLs of a referral. If successful then perform
 308      * a search operation and merge the received results with the current
 309      * results.
 310      */
 311     protected final boolean hasMoreReferrals() throws NamingException {
 312 
 313         if ((refEx != null) &&
 314             (refEx.hasMoreReferrals() ||
 315              refEx.hasMoreReferralExceptions())) {
 316 
 317             if (homeCtx.handleReferrals == LdapClient.LDAP_REF_THROW) {
 318                 throw (NamingException)(refEx.fillInStackTrace());
 319             }
 320 
 321             // process the referrals sequentially
 322             while (true) {
 323 


 343                     // Make sure we close referral context
 344                     refCtx.close();
 345                 }
 346             }
 347             return hasMoreImpl();
 348 
 349         } else {
 350             cleanup();
 351 
 352             if (errEx != null) {
 353                 throw errEx;
 354             }
 355             return (false);
 356         }
 357     }
 358 
 359     /*
 360      * Merge the entries and/or referrals from the supplied enumeration
 361      * with those of the current enumeration.
 362      */
 363     protected void update(AbstractLdapNamingEnumeration<T> ne) {
 364         // Cleanup previous context first
 365         homeCtx.decEnumCount();
 366 
 367         // New enum will have already incremented enum count and recorded clnt
 368         homeCtx = ne.homeCtx;
 369         enumClnt = ne.enumClnt;
 370 
 371         // Do this to prevent referral enumeration (ne) from decrementing
 372         // enum count because we'll be doing that here from this
 373         // enumeration.
 374         ne.homeCtx = null;
 375 
 376         // Record rest of information from new enum
 377         posn = ne.posn;
 378         limit = ne.limit;
 379         res = ne.res;
 380         entries = ne.entries;
 381         refEx = ne.refEx;
 382         listArg = ne.listArg;
 383     }




 283     protected abstract T createItem(String dn, Attributes attrs,
 284         Vector<Control> respCtls) throws NamingException;
 285 
 286     /*
 287      * Append the supplied (chain of) referrals onto the
 288      * end of the current (chain of) referrals.
 289      */
 290     @Override
 291     public void appendUnprocessedReferrals(LdapReferralException ex) {
 292         if (refEx != null) {
 293             refEx = refEx.appendUnprocessedReferrals(ex);
 294         } else {
 295             refEx = ex.appendUnprocessedReferrals(refEx);
 296         }
 297     }
 298 
 299     final void setNamingException(NamingException e) {
 300         errEx = e;
 301     }
 302 
 303     protected abstract AbstractLdapNamingEnumeration<? extends NameClassPair> getReferredResults(
 304             LdapReferralContext refCtx) throws NamingException;
 305 
 306     /*
 307      * Iterate through the URLs of a referral. If successful then perform
 308      * a search operation and merge the received results with the current
 309      * results.
 310      */
 311     protected final boolean hasMoreReferrals() throws NamingException {
 312 
 313         if ((refEx != null) &&
 314             (refEx.hasMoreReferrals() ||
 315              refEx.hasMoreReferralExceptions())) {
 316 
 317             if (homeCtx.handleReferrals == LdapClient.LDAP_REF_THROW) {
 318                 throw (NamingException)(refEx.fillInStackTrace());
 319             }
 320 
 321             // process the referrals sequentially
 322             while (true) {
 323 


 343                     // Make sure we close referral context
 344                     refCtx.close();
 345                 }
 346             }
 347             return hasMoreImpl();
 348 
 349         } else {
 350             cleanup();
 351 
 352             if (errEx != null) {
 353                 throw errEx;
 354             }
 355             return (false);
 356         }
 357     }
 358 
 359     /*
 360      * Merge the entries and/or referrals from the supplied enumeration
 361      * with those of the current enumeration.
 362      */
 363     protected void update(AbstractLdapNamingEnumeration<? extends NameClassPair> ne) {
 364         // Cleanup previous context first
 365         homeCtx.decEnumCount();
 366 
 367         // New enum will have already incremented enum count and recorded clnt
 368         homeCtx = ne.homeCtx;
 369         enumClnt = ne.enumClnt;
 370 
 371         // Do this to prevent referral enumeration (ne) from decrementing
 372         // enum count because we'll be doing that here from this
 373         // enumeration.
 374         ne.homeCtx = null;
 375 
 376         // Record rest of information from new enum
 377         posn = ne.posn;
 378         limit = ne.limit;
 379         res = ne.res;
 380         entries = ne.entries;
 381         refEx = ne.refEx;
 382         listArg = ne.listArg;
 383     }