Search in sources :

Example 6 with GluuInumMap

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);
}
Also used : GluuSimplePerson(org.gluu.oxtrust.ldap.cache.model.GluuSimplePerson) PersistenceEntryManager(org.gluu.persist.PersistenceEntryManager) GluuInumMap(org.gluu.oxtrust.ldap.cache.model.GluuInumMap) BasePersistenceException(org.gluu.persist.exception.BasePersistenceException) ArrayList(java.util.ArrayList) Date(java.util.Date) Pair(org.gluu.util.Pair)

Example 7 with GluuInumMap

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

the class CacheRefreshService method generateInumForNewInumMap.

public String generateInumForNewInumMap(String inumbBaseDn, LdapEntryManager ldapEntryManager) {
    String newInum = generateInumForNewInumMapImpl();
    String newDn = getDnForInum(inumbBaseDn, newInum);
    GluuInumMap inumMap = new GluuInumMap();
    inumMap.setDn(newDn);
    while (containsInumMap(ldapEntryManager, inumMap)) {
        newInum = generateInumForNewInumMapImpl();
        newDn = getDnForInum(inumbBaseDn, newInum);
        inumMap.setDn(newDn);
    }
    return newInum;
}
Also used : GluuInumMap(org.gluu.oxtrust.ldap.cache.model.GluuInumMap)

Example 8 with GluuInumMap

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

the class CacheRefreshTimer method addGluuInumMap.

private GluuInumMap addGluuInumMap(String inumbBaseDn, PersistenceEntryManager inumDbPersistenceEntryManager, String[] primaryKeyAttrName, String[][] primaryKeyValues) {
    String inum = cacheRefreshService.generateInumForNewInumMap(inumbBaseDn, inumDbPersistenceEntryManager);
    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(inumDbPersistenceEntryManager, inumMap);
    return inumMap;
}
Also used : GluuInumMap(org.gluu.oxtrust.ldap.cache.model.GluuInumMap)

Aggregations

GluuInumMap (org.gluu.oxtrust.ldap.cache.model.GluuInumMap)8 GluuSimplePerson (org.gluu.oxtrust.ldap.cache.model.GluuSimplePerson)4 PersistenceEntryManager (org.gluu.persist.PersistenceEntryManager)3 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 HashMap (java.util.HashMap)2 CacheCompoundKey (org.gluu.oxtrust.ldap.cache.model.CacheCompoundKey)2 BasePersistenceException (org.gluu.persist.exception.BasePersistenceException)2 SocketException (java.net.SocketException)1 EntryPersistenceException (org.gluu.persist.exception.EntryPersistenceException)1 BaseMappingException (org.gluu.persist.exception.mapping.BaseMappingException)1 SearchException (org.gluu.persist.exception.operation.SearchException)1 LdapEntryManager (org.gluu.persist.ldap.impl.LdapEntryManager)1 Pair (org.gluu.util.Pair)1 Pair (org.xdi.util.Pair)1