@Override public int size() { // Infinispan code analysis on 8.2 shows that this method is never called in practise, and // is not wired to the data / cache container API Loggers.LDAP_LOG.trace("[IL0258] LDAP store: Counting {} entries", getCacheName()); final int count = ldapConnector.countEntries(); Loggers.LDAP_LOG.trace("[IL0259] LDAP store: Counted {} {} entries", count, getCacheName()); return count; }
@Override public void clear() { Loggers.LDAP_LOG.trace("[IL0260] LDAP store: Clearing {} entries", getCacheName()); int numDeleted = ldapConnector.deleteEntries(); Loggers.LDAP_LOG.debug("[IL0254] LDAP store: Cleared {} {} entries", numDeleted, getCacheName()); }
@Override public boolean delete(final Object key) { // The CacheWriter should remove from the external storage the entry identified by the specified key. // Note that keys will be in the cache's native format, which means that if the cache is being used by a remoting protocol // such as HotRod or REST and compatibility mode has not been enabled, then they will be encoded in a byte[]. Loggers.LDAP_LOG.trace("[IL0252] LDAP store: Deleting {} entry with key {}", getCacheName(), key); DN dn = new DN(ldapEntryTransformer.resolveRDN(resolveKey(key)), config.ldapDirectory.baseDN); return ldapConnector.deleteEntry(dn); }
ldapConnector.retrieveEntries(ldapEntry -> { if (ldapConnector.deleteEntry(pair.getLeft())) {
/** * Deletes all entries under the base DN. * * @return The number of deleted entries, zero if none found. */ public int deleteEntries() { SearchRequest request = new SearchRequest( config.ldapDirectory.baseDN.toString(), SearchScope.ONE, MATCH_ANY_FILTER, SearchRequest.NO_ATTRIBUTES); List<String> entryDNs = new LinkedList<>(); doSearch(request, entry -> entryDNs.add(entry.getDN())); int count = 0; for(String dn: entryDNs) { try { if (deleteEntry(new DN(dn))) { ++count; } } catch (LDAPException e) { throw new PersistenceException(e.getMessage(), e); } } return count; }
if (indicatesConnectionException(e)) { cookie = parsePageCookie(searchResult);
if (ldapConnector.addEntry(ldapEntry.getEntry())) { Loggers.LDAP_LOG.trace("[IL0256] LDAP store: Added new {} entry with DN {}", getCacheName(), ldapEntry.getEntry().getDN()); return; // success if (ldapConnector.replaceEntry(ldapEntry.getEntry())) { Loggers.LDAP_LOG.trace("[IL0257] LDAP store: Replaced {} entry with DN {}", getCacheName(), ldapEntry.getEntry().getDN()); return; // success if (! ldapConnector.addEntry(ldapEntry.getEntry())) { if (ldapConnector.replaceEntry(ldapEntry.getEntry())) { Loggers.LDAP_LOG.trace("[IL0265] LDAP store: Replaced {} entry with DN {}", getCacheName(), ldapEntry.getEntry().getDN()); return; // success if (ldapConnector.addEntry(ldapEntry.getEntry())) { Loggers.LDAP_LOG.trace("[IL0266] LDAP store: Added new {} entry with DN {}", getCacheName(), ldapEntry.getEntry().getDN()); return; // success if (! ldapConnector.replaceEntry(ldapEntry.getEntry())) {
/** * Counts the number of entries under the base DN. * * @return The entry count. */ public int countEntries() { SearchRequest request = new SearchRequest( config.ldapDirectory.baseDN.toString(), SearchScope.ONE, MATCH_ANY_FILTER, SearchRequest.NO_ATTRIBUTES); final AtomicInteger count = new AtomicInteger(); doSearch(request, entry -> count.incrementAndGet()); return count.intValue(); }
@Override public boolean contains(final Object key) { // This method will be invoked by the PersistenceManager to determine if the loader contains the specified key. // The implementation should be as fast as possible, e.g. it should strive to transfer the least amount of data possible // from the external storage to perform the check. Also, if possible, make sure the field is indexed on the external storage // so that its existence can be determined as quickly as possible. // // Note that keys will be in the cache's native format, which means that if the cache is being used by a remoting protocol // such as HotRod or REST and compatibility mode has not been enabled, then they will be encoded in a byte[]. Loggers.LDAP_LOG.trace("[IL0250] LDAP store: Checking {} cache key {}", getCacheName(), key); DN dn = new DN(ldapEntryTransformer.resolveRDN(resolveKey(key)), config.ldapDirectory.baseDN); return ldapConnector.entryExists(dn); }
/** * Checks if the specified LDAP exception is caused by the LDAP server * being unavailable, disconnected or timing out. * * @param e The LDAP exception. Must not be {@code null}. * * @return {@code true} if the LDAP exception is caused by the LDAP * server being unavailable, disconnected or timing out, else * {@code false}. */ protected static boolean indicatesConnectionException(final LDAPException e) { return indicatesConnectionException(e.getResultCode()); }
ldapConnector = new LDAPConnector( config, getCacheName(),
ldapConnector.retrieveEntries(ldapEntry -> { if (ldapConnector.deleteEntry(pair.getLeft())) {
/** * Deletes all entries under the base DN. * * @return The number of deleted entries, zero if none found. */ public int deleteEntries() { SearchRequest request = new SearchRequest( config.ldapDirectory.baseDN.toString(), SearchScope.ONE, MATCH_ANY_FILTER, SearchRequest.NO_ATTRIBUTES); List<String> entryDNs = new LinkedList<>(); doSearch(request, entry -> entryDNs.add(entry.getDN())); int count = 0; for(String dn: entryDNs) { try { if (deleteEntry(new DN(dn))) { ++count; } } catch (LDAPException e) { throw new PersistenceException(e.getMessage(), e); } } return count; }
if (indicatesConnectionException(e)) { cookie = parsePageCookie(searchResult);
if (ldapConnector.addEntry(ldapEntry.getEntry())) { Loggers.LDAP_LOG.trace("[IL0256] LDAP store: Added new {} entry with DN {}", getCacheName(), ldapEntry.getEntry().getDN()); return; // success if (ldapConnector.replaceEntry(ldapEntry.getEntry())) { Loggers.LDAP_LOG.trace("[IL0257] LDAP store: Replaced {} entry with DN {}", getCacheName(), ldapEntry.getEntry().getDN()); return; // success if (! ldapConnector.addEntry(ldapEntry.getEntry())) { if (ldapConnector.replaceEntry(ldapEntry.getEntry())) { Loggers.LDAP_LOG.trace("[IL0265] LDAP store: Replaced {} entry with DN {}", getCacheName(), ldapEntry.getEntry().getDN()); return; // success if (ldapConnector.addEntry(ldapEntry.getEntry())) { Loggers.LDAP_LOG.trace("[IL0266] LDAP store: Added new {} entry with DN {}", getCacheName(), ldapEntry.getEntry().getDN()); return; // success if (! ldapConnector.replaceEntry(ldapEntry.getEntry())) {
/** * Counts the number of entries under the base DN. * * @return The entry count. */ public int countEntries() { SearchRequest request = new SearchRequest( config.ldapDirectory.baseDN.toString(), SearchScope.ONE, MATCH_ANY_FILTER, SearchRequest.NO_ATTRIBUTES); final AtomicInteger count = new AtomicInteger(); doSearch(request, entry -> count.incrementAndGet()); return count.intValue(); }
@Override public boolean contains(final Object key) { // This method will be invoked by the PersistenceManager to determine if the loader contains the specified key. // The implementation should be as fast as possible, e.g. it should strive to transfer the least amount of data possible // from the external storage to perform the check. Also, if possible, make sure the field is indexed on the external storage // so that its existence can be determined as quickly as possible. // // Note that keys will be in the cache's native format, which means that if the cache is being used by a remoting protocol // such as HotRod or REST and compatibility mode has not been enabled, then they will be encoded in a byte[]. Loggers.LDAP_LOG.trace("[IL0250] LDAP store: Checking {} cache key {}", getCacheName(), key); DN dn = new DN(ldapEntryTransformer.resolveRDN(resolveKey(key)), config.ldapDirectory.baseDN); return ldapConnector.entryExists(dn); }
/** * Checks if the specified LDAP exception is caused by the LDAP server * being unavailable, disconnected or timing out. * * @param e The LDAP exception. Must not be {@code null}. * * @return {@code true} if the LDAP exception is caused by the LDAP * server being unavailable, disconnected or timing out, else * {@code false}. */ protected static boolean indicatesConnectionException(final LDAPException e) { return indicatesConnectionException(e.getResultCode()); }
ldapConnector = new LDAPConnector( config, getCacheName(),