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;
}
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;
}
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;
}
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;
}
Aggregations