/* * Retrieve the next set of entries and/or referrals. */ private void getNextBatch() throws NamingException { res = homeCtx.getSearchReply(enumClnt, res); if (res == null) { limit = posn = 0; return; } entries = res.entries; limit = (entries == null) ? 0 : entries.size(); // handle empty set posn = 0; // reset // minimize the number of calls to processReturnCode() // (expensive when batchSize is small and there are many results) if ((res.status != LdapClient.LDAP_SUCCESS) || ((res.status == LdapClient.LDAP_SUCCESS) && (res.referrals != null))) { try { // convert referrals into a chain of LdapReferralException homeCtx.processReturnCode(res, listArg); } catch (LimitExceededException | PartialResultException e) { setNamingException(e); } } // merge any newly received referrals with any current referrals if (res.refEx != null) { if (refEx == null) { refEx = res.refEx; } else { refEx = refEx.appendUnprocessedReferrals(res.refEx); } res.refEx = null; // reset } if (res.resControls != null) { homeCtx.respCtls = res.resControls; } }