Project

General

Profile

« Previous | Next » 

Revision 3938

Added by Jing Tao almost 16 years ago

Check into CVS head. Add code to handle that referral server is down.

View differences:

src/edu/ucsb/nceas/metacat/AuthLdap.java
358 358
          for (boolean moreReferrals = true; moreReferrals;) {
359 359
              try {
360 360
                  // Perform the search
361
            	  logMetacat.debug("before searching for DNs with following filter: " + filter);
362
            	  //logMetacat.debug("the context name space is ====== "+sctx.getNameInNamespace());
361 363
                  NamingEnumeration answer = 
362 364
                      sctx.search("", filter, ctls);
363

  
365
                  logMetacat.debug("after searching for DNs with following filter: " + filter);
364 366
                  // Return the answer
365 367
                  while (answer.hasMore()) {
368
                	  logMetacat.debug("In anwer.hasMore() while loop");
366 369
                      SearchResult sr = (SearchResult)answer.next();
367 370
                      identifier = sr.getName();
371
                      logMetacat.debug("after anwer.hasMore() while loop "+identifier);
368 372
                      return identifier;
369 373
                  }
370 374
                  // The search completes with no more referrals
371 375
                  moreReferrals = false;
372 376
              } catch (ReferralException e) {
373
            	  logMetacat.info("Got referral: " + e.getReferralInfo());
377
            	  logMetacat.warn("Got referral: " + e.getReferralInfo());
374 378
            	  // Point to the new context from the referral
375
                  if (moreReferrals) {
376
                      sctx = (DirContext) e.getReferralContext();
377
                  }
379
            	  DirContext storedConext = sctx;
380
            	  try
381
            	  {
382
	                  if (moreReferrals) {
383
	                      sctx = (DirContext) e.getReferralContext();
384
	                  }
385
            	  }
386
            	  catch(Exception ee)
387
            	  {
388
            		   e.skipReferral();
389
            		   if (moreReferrals) {
390
 	                      sctx = (DirContext) e.getReferralContext();
391
 	                   }
392
            		   logMetacat.warn("Naming exception while setting context to referral: " + ee);
393
            	  }
394
                  logMetacat.debug("after reset new context " + e.getReferralInfo());
378 395
              }
379 396
          }
380 397
      } catch (NamingException e) {
......
830 847
                }
831 848
                
832 849
              } catch (NamingException nameEx){
833
                logMetacat.debug("Caught naming exception: ");
834
                nameEx.printStackTrace(System.err);
850
                logMetacat.debug("Caught naming exception1: "+nameEx.getMessage());
851
                //nameEx.printStackTrace(System.err);
835 852
              }
836 853
            }
837 854
          }// end while
......
848 865
          
849 866
          // set moreReferrals to true and set the referral context
850 867
          moreReferrals = true;
851
          ctx = (DirContext) re.getReferralContext();
868
          try
869
          {
870
              ctx = (DirContext) re.getReferralContext();
871
          }
872
          catch(Exception ee)
873
    	  {
874
    		   re.skipReferral();
875
    		   if (moreReferrals) {
876
                   ctx = (DirContext) re.getReferralContext();
877
                }
878
    		   logMetacat.error("Naming exception while setting context to referral: " + ee);
879
    	  }
880
          logMetacat.debug("after reset new context in referral in getGroups " );
852 881
           
853 882
        }// end inner try
854 883
      }// end for
......
860 889
    } catch (NamingException e) {
861 890
      
862 891
      // naming exceptions get logged, groups are returned
863
      logMetacat.info("In AuthLdap.getGroups(), caught naming exception: ");
864
      e.printStackTrace(System.err);
892
      logMetacat.info("In AuthLdap.getGroups()2, caught naming exception: "+e.getMessage());
893
      //e.printStackTrace(System.err);
865 894
      
866 895
    } finally {
867 896
      // once all referrals are followed, report and return the groups found

Also available in: Unified diff