Search in sources :

Example 1 with CacheCompoundKey

use of org.gluu.oxtrust.ldap.cache.model.CacheCompoundKey in project oxTrust by GluuFederation.

the class CacheRefreshTimer method addNewInumServerEntries.

private HashMap<CacheCompoundKey, GluuInumMap> addNewInumServerEntries(CacheRefreshConfiguration cacheRefreshConfiguration, LdapServerConnection inumDbServerConnection, Map<CacheCompoundKey, GluuSimplePerson> sourcePersonCacheCompoundKeyMap, HashMap<CacheCompoundKey, GluuInumMap> primaryKeyAttrValueInumMap) {
    LdapEntryManager inumDbLdapEntryManager = inumDbServerConnection.getLdapEntryManager();
    String inumbaseDn = inumDbServerConnection.getBaseDns()[0];
    HashMap<CacheCompoundKey, GluuInumMap> result = new HashMap<CacheCompoundKey, GluuInumMap>();
    String[] keyAttributesWithoutValues = getCompoundKeyAttributesWithoutValues(cacheRefreshConfiguration);
    for (Entry<CacheCompoundKey, GluuSimplePerson> sourcePersonCacheCompoundKeyEntry : sourcePersonCacheCompoundKeyMap.entrySet()) {
        CacheCompoundKey cacheCompoundKey = sourcePersonCacheCompoundKeyEntry.getKey();
        GluuSimplePerson sourcePerson = sourcePersonCacheCompoundKeyEntry.getValue();
        if (log.isTraceEnabled()) {
            log.trace("Checking source entry with key: '{}', and DN: {}", cacheCompoundKey, sourcePerson.getDn());
        }
        GluuInumMap currentInumMap = primaryKeyAttrValueInumMap.get(cacheCompoundKey);
        if (currentInumMap == null) {
            String[][] keyAttributesValues = getKeyAttributesValues(keyAttributesWithoutValues, sourcePerson);
            currentInumMap = addGluuInumMap(inumbaseDn, inumDbLdapEntryManager, keyAttributesWithoutValues, keyAttributesValues);
            result.put(cacheCompoundKey, currentInumMap);
            log.debug("Added new inum entry for DN: {}", sourcePerson.getDn());
        } else {
            log.trace("Inum entry for DN: '{}' exist", sourcePerson.getDn());
        }
    }
    return result;
}
Also used : GluuSimplePerson(org.gluu.oxtrust.ldap.cache.model.GluuSimplePerson) GluuInumMap(org.gluu.oxtrust.ldap.cache.model.GluuInumMap) LdapEntryManager(org.gluu.site.ldap.persistence.LdapEntryManager) HashMap(java.util.HashMap) CacheCompoundKey(org.gluu.oxtrust.ldap.cache.model.CacheCompoundKey)

Example 2 with CacheCompoundKey

use of org.gluu.oxtrust.ldap.cache.model.CacheCompoundKey in project oxTrust by GluuFederation.

the class CacheRefreshTimer method getSourcePersonsHashCodesMap.

private HashMap<String, Integer> getSourcePersonsHashCodesMap(LdapServerConnection inumDbServerConnection, Map<CacheCompoundKey, GluuSimplePerson> sourcePersonCacheCompoundKeyMap, HashMap<CacheCompoundKey, GluuInumMap> primaryKeyAttrValueInumMap) {
    LdapEntryManager inumDbLdapEntryManager = inumDbServerConnection.getLdapEntryManager();
    HashMap<String, Integer> result = new HashMap<String, Integer>();
    for (Entry<CacheCompoundKey, GluuSimplePerson> sourcePersonCacheCompoundKeyEntry : sourcePersonCacheCompoundKeyMap.entrySet()) {
        CacheCompoundKey cacheCompoundKey = sourcePersonCacheCompoundKeyEntry.getKey();
        GluuSimplePerson sourcePerson = sourcePersonCacheCompoundKeyEntry.getValue();
        GluuInumMap currentInumMap = primaryKeyAttrValueInumMap.get(cacheCompoundKey);
        result.put(currentInumMap.getInum(), inumDbLdapEntryManager.getHashCode(sourcePerson));
    }
    return result;
}
Also used : GluuSimplePerson(org.gluu.oxtrust.ldap.cache.model.GluuSimplePerson) GluuInumMap(org.gluu.oxtrust.ldap.cache.model.GluuInumMap) LdapEntryManager(org.gluu.site.ldap.persistence.LdapEntryManager) HashMap(java.util.HashMap) CacheCompoundKey(org.gluu.oxtrust.ldap.cache.model.CacheCompoundKey)

Example 3 with CacheCompoundKey

use of org.gluu.oxtrust.ldap.cache.model.CacheCompoundKey in project oxTrust by GluuFederation.

the class CacheRefreshTimer method getSourcePersonCompoundKeyMap.

private Map<CacheCompoundKey, GluuSimplePerson> getSourcePersonCompoundKeyMap(CacheRefreshConfiguration cacheRefreshConfiguration, List<GluuSimplePerson> sourcePersons) {
    Map<CacheCompoundKey, GluuSimplePerson> result = new HashMap<CacheCompoundKey, GluuSimplePerson>();
    Set<CacheCompoundKey> duplicateKeys = new HashSet<CacheCompoundKey>();
    String[] keyAttributesWithoutValues = getCompoundKeyAttributesWithoutValues(cacheRefreshConfiguration);
    for (GluuSimplePerson sourcePerson : sourcePersons) {
        String[][] keyAttributesValues = getKeyAttributesValues(keyAttributesWithoutValues, sourcePerson);
        CacheCompoundKey cacheCompoundKey = new CacheCompoundKey(keyAttributesValues);
        if (result.containsKey(cacheCompoundKey)) {
            duplicateKeys.add(cacheCompoundKey);
        }
        result.put(cacheCompoundKey, sourcePerson);
    }
    for (CacheCompoundKey duplicateKey : duplicateKeys) {
        log.error("Non-deterministic primary key. Skipping user with key: {}", duplicateKey);
        result.remove(duplicateKey);
    }
    return result;
}
Also used : GluuSimplePerson(org.gluu.oxtrust.ldap.cache.model.GluuSimplePerson) HashMap(java.util.HashMap) CacheCompoundKey(org.gluu.oxtrust.ldap.cache.model.CacheCompoundKey) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Example 4 with CacheCompoundKey

use of org.gluu.oxtrust.ldap.cache.model.CacheCompoundKey in project oxTrust by GluuFederation.

the class CacheRefreshTimer method updateTargetEntriesViaCopy.

private List<String> updateTargetEntriesViaCopy(CacheRefreshConfiguration cacheRefreshConfiguration, Map<CacheCompoundKey, GluuSimplePerson> sourcePersonCacheCompoundKeyMap, HashMap<CacheCompoundKey, GluuInumMap> primaryKeyAttrValueInumMap, Set<String> changedInums) {
    HashMap<String, CacheCompoundKey> inumCacheCompoundKeyMap = getInumCacheCompoundKeyMap(primaryKeyAttrValueInumMap);
    Map<String, String> targetServerAttributesMapping = getTargetServerAttributesMapping(cacheRefreshConfiguration);
    String[] customObjectClasses = appConfiguration.getPersonObjectClassTypes();
    List<String> result = new ArrayList<String>();
    if (!validateTargetServerSchema(cacheRefreshConfiguration, targetServerAttributesMapping, customObjectClasses)) {
        return result;
    }
    for (String targetInum : changedInums) {
        CacheCompoundKey compoundKey = inumCacheCompoundKeyMap.get(targetInum);
        if (compoundKey == null) {
            continue;
        }
        GluuSimplePerson sourcePerson = sourcePersonCacheCompoundKeyMap.get(compoundKey);
        if (sourcePerson == null) {
            continue;
        }
        if (updateTargetEntryViaCopy(sourcePerson, targetInum, customObjectClasses, targetServerAttributesMapping)) {
            result.add(targetInum);
        }
    }
    return result;
}
Also used : GluuSimplePerson(org.gluu.oxtrust.ldap.cache.model.GluuSimplePerson) CacheCompoundKey(org.gluu.oxtrust.ldap.cache.model.CacheCompoundKey) ArrayList(java.util.ArrayList)

Aggregations

CacheCompoundKey (org.gluu.oxtrust.ldap.cache.model.CacheCompoundKey)4 GluuSimplePerson (org.gluu.oxtrust.ldap.cache.model.GluuSimplePerson)4 HashMap (java.util.HashMap)3 GluuInumMap (org.gluu.oxtrust.ldap.cache.model.GluuInumMap)2 LdapEntryManager (org.gluu.site.ldap.persistence.LdapEntryManager)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 LinkedHashSet (java.util.LinkedHashSet)1