use of org.gluu.oxtrust.ldap.cache.model.GluuInumMap in project oxTrust by GluuFederation.
the class CacheRefreshTimer method removeTargetEntries.
private Pair<List<String>, List<String>> removeTargetEntries(LdapServerConnection inumDbServerConnection, LdapEntryManager targetLdapEntryManager, List<GluuSimplePerson> removedPersons, HashMap<String, GluuInumMap> inumInumMap) {
String runDate = ldapEntryManager.encodeGeneralizedTime(new Date(this.lastFinishedTime));
LdapEntryManager inumDbLdapEntryManager = inumDbServerConnection.getLdapEntryManager();
List<String> result1 = new ArrayList<String>();
List<String> result2 = new ArrayList<String>();
for (GluuSimplePerson removedPerson : removedPersons) {
String inum = removedPerson.getAttribute(OxTrustConstants.inum);
// Update GluuInumMap if it exist
GluuInumMap currentInumMap = inumInumMap.get(inum);
if (currentInumMap == null) {
log.warn("Can't find inum entry of person with DN: {}", removedPerson.getDn());
} else {
GluuInumMap removedInumMap = getMarkInumMapEntryAsRemoved(currentInumMap, runDate);
try {
inumDbLdapEntryManager.merge(removedInumMap);
result2.add(removedInumMap.getInum());
} catch (BaseMappingException ex) {
log.error("Failed to update entry with inum '{}' and DN: {}", currentInumMap.getInum(), currentInumMap.getDn(), ex);
continue;
}
}
// Remove person from target server
try {
targetLdapEntryManager.removeRecursively(removedPerson.getDn());
result1.add(inum);
} catch (BaseMappingException ex) {
log.error("Failed to remove person entry with inum '{}' and DN: {}", inum, removedPerson.getDn(), ex);
continue;
}
log.debug("Person with DN: '{}' removed from target server", removedPerson.getDn());
}
return new Pair<List<String>, List<String>>(result1, result2);
}
use of org.gluu.oxtrust.ldap.cache.model.GluuInumMap in project oxTrust by GluuFederation.
the class CacheRefreshTimer method addGluuInumMap.
private GluuInumMap addGluuInumMap(String inumbBaseDn, LdapEntryManager inumDbLdapEntryManager, String[] primaryKeyAttrName, String[][] primaryKeyValues) {
String inum = cacheRefreshService.generateInumForNewInumMap(inumbBaseDn, inumDbLdapEntryManager);
String inumDn = cacheRefreshService.getDnForInum(inumbBaseDn, inum);
GluuInumMap inumMap = new GluuInumMap();
inumMap.setDn(inumDn);
inumMap.setInum(inum);
inumMap.setPrimaryKeyAttrName(primaryKeyAttrName[0]);
inumMap.setPrimaryKeyValues(primaryKeyValues[0]);
if (primaryKeyAttrName.length > 1) {
inumMap.setSecondaryKeyAttrName(primaryKeyAttrName[1]);
inumMap.setSecondaryKeyValues(primaryKeyValues[1]);
}
if (primaryKeyAttrName.length > 2) {
inumMap.setTertiaryKeyAttrName(primaryKeyAttrName[2]);
inumMap.setTertiaryKeyValues(primaryKeyValues[2]);
}
inumMap.setStatus(GluuStatus.ACTIVE);
cacheRefreshService.addInumMap(inumDbLdapEntryManager, inumMap);
return inumMap;
}
use of org.gluu.oxtrust.ldap.cache.model.GluuInumMap in project oxTrust by GluuFederation.
the class CacheRefreshTimer method removeTargetEntries.
private Pair<List<String>, List<String>> removeTargetEntries(LdapServerConnection inumDbServerConnection, PersistenceEntryManager targetPersistenceEntryManager, List<GluuSimplePerson> removedPersons, HashMap<String, GluuInumMap> inumInumMap) {
Date runDate = new Date(this.lastFinishedTime);
PersistenceEntryManager inumDbPersistenceEntryManager = inumDbServerConnection.getPersistenceEntryManager();
List<String> result1 = new ArrayList<String>();
List<String> result2 = new ArrayList<String>();
for (GluuSimplePerson removedPerson : removedPersons) {
String inum = removedPerson.getAttribute(OxTrustConstants.inum);
// Update GluuInumMap if it exist
GluuInumMap currentInumMap = inumInumMap.get(inum);
if (currentInumMap == null) {
log.warn("Can't find inum entry of person with DN: {}", removedPerson.getDn());
} else {
GluuInumMap removedInumMap = getMarkInumMapEntryAsRemoved(currentInumMap, ldapEntryManager.encodeTime(removedPerson.getDn(), runDate));
try {
inumDbPersistenceEntryManager.merge(removedInumMap);
result2.add(removedInumMap.getInum());
} catch (BasePersistenceException ex) {
log.error("Failed to update entry with inum '{}' and DN: {}", currentInumMap.getInum(), currentInumMap.getDn(), ex);
continue;
}
}
// Remove person from target server
try {
targetPersistenceEntryManager.removeRecursively(removedPerson.getDn());
result1.add(inum);
} catch (BasePersistenceException ex) {
log.error("Failed to remove person entry with inum '{}' and DN: {}", inum, removedPerson.getDn(), ex);
continue;
}
log.debug("Person with DN: '{}' removed from target server", removedPerson.getDn());
}
return new Pair<List<String>, List<String>>(result1, result2);
}
use of org.gluu.oxtrust.ldap.cache.model.GluuInumMap 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) {
PersistenceEntryManager inumDbPersistenceEntryManager = inumDbServerConnection.getPersistenceEntryManager();
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, inumDbPersistenceEntryManager, 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.GluuInumMap 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) {
PersistenceEntryManager inumDbPersistenceEntryManager = inumDbServerConnection.getPersistenceEntryManager();
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(), inumDbPersistenceEntryManager.getHashCode(sourcePerson));
}
return result;
}
Aggregations