@ FFDCIgnore ( NamingException . class ) private NamingEnumeration < SearchResult > updateSearchCache ( String searchBase , String key , NamingEnumeration < SearchResult > neu , String [ ] reqAttrIds ) throws WIMSystemException { final String METHODNAME = "updateSearchCache" ; CachedNamingEnumeration clone1 = new CachedNamingEnumeration ( ) ; CachedNamingEnumeration clone2 = new CachedNamingEnumeration ( ) ; int count = cloneSearchResults ( neu , clone1 , clone2 ) ; // Size limit 0 means no limit. if ( iSearchResultSizeLmit == 0 || count < iSearchResultSizeLmit ) { getSearchResultsCache ( ) . put ( key , clone2 , 1 , iSearchResultsCacheTimeOut , 0 , null ) ; if ( tc . isDebugEnabled ( ) ) Tr . debug ( tc , METHODNAME + " Update " + iSearchResultsCacheName + "(size: " + getSearchResultsCache ( ) . size ( ) + ")\n" + key ) ; // To reduce JNDI calls during get(), cache the entry into attribute cache if ( getAttributesCache ( ) != null ) { try { count = 0 ; while ( clone2 . hasMore ( ) ) { SearchResult result = clone2 . nextElement ( ) ; String dnKey = LdapHelper . prepareDN ( result . getName ( ) , searchBase ) ; Object cached = getAttributesCache ( ) . get ( dnKey ) ; Attributes cachedAttrs = null ; if ( cached != null && cached instanceof Attributes ) { cachedAttrs = ( Attributes ) cached ; } updateAttributesCache ( dnKey , result . getAttributes ( ) , cachedAttrs , reqAttrIds ) ; if ( ++ count > 20 ) { // cache only first 20 results from the search. // caching all entries may thrash the attributeCache if ( tc . isDebugEnabled ( ) ) Tr . debug ( tc , METHODNAME + " attribute cache updated with " + ( count - 1 ) + " entries. skipping rest." ) ; break ; } } } catch ( NamingException e ) { /* Ignore. */ } } } return clone1 ; }
Update the search cache with search results .