Search in sources :

Example 31 with CacheBlock

use of com.iplanet.am.sdk.common.CacheBlock in project OpenAM by OpenRock.

the class CachedRemoteServicesImpl method renameEntry.

/**
     * Renames an entry. Currently used for only user renaming.
     * 
     * @param token
     *            the sso token
     * @param objectType
     *            the type of entry
     * @param entryDN
     *            the entry DN
     * @param newName
     *            the new name (i.e., if RDN is cn=John, the value passed should
     *            be "John"
     * @param deleteOldName
     *            if true the old name is deleted otherwise it is retained.
     * @return new <code>DN</code> of the renamed entry
     * @throws AMException
     *             if the operation was not successful
     */
public String renameEntry(SSOToken token, int objectType, String entryDN, String newName, boolean deleteOldName) throws AMException {
    String newDN = super.renameEntry(token, objectType, entryDN, newName, deleteOldName);
    // Just rename the dn in the cache. Don't remove the entry. So when the
    // event notification happens, it won't find the entry as it is already
    // renamed. Chances are this cache rename operation may happen before
    // the notification thread trys clean up.
    // NOTE: We should have the code to remove the entry for rename
    // operation as the operation could have been performed by some other
    // process such as amadmin.
    String oldDN = LDAPUtils.formatToRFC(entryDN);
    CacheBlock cb = (CacheBlock) sdkCache.remove(oldDN);
    newDN = LDAPUtils.formatToRFC(newDN);
    sdkCache.put(newDN, cb);
    return newDN;
}
Also used : CacheBlock(com.iplanet.am.sdk.common.CacheBlock)

Example 32 with CacheBlock

use of com.iplanet.am.sdk.common.CacheBlock in project OpenAM by OpenRock.

the class CachedRemoteServicesImpl method updateCache.

/**
     * Method that updates the cache entries locally. This method does a write
     * through cache
     */
private void updateCache(SSOToken token, String dn, Map stringAttributes, Map byteAttributes) throws SSOException {
    String key = LDAPUtils.formatToRFC(dn);
    CacheBlock cb = (CacheBlock) sdkCache.get(key);
    if (cb != null && !cb.hasExpiredAndUpdated() && cb.isExists()) {
        String pDN = MiscUtils.getPrincipalDN(token);
        cb.replaceAttributes(pDN, stringAttributes, byteAttributes);
    }
}
Also used : CacheBlock(com.iplanet.am.sdk.common.CacheBlock)

Aggregations

CacheBlock (com.iplanet.am.sdk.common.CacheBlock)32 Enumeration (java.util.Enumeration)6 AMException (com.iplanet.am.sdk.AMException)5 AMHashMap (com.iplanet.am.sdk.AMHashMap)4 HashSet (java.util.HashSet)4 Iterator (java.util.Iterator)4 Set (java.util.Set)4 SSOToken (com.iplanet.sso.SSOToken)2 Map (java.util.Map)2 DN (org.forgerock.opendj.ldap.DN)2 AMObject (com.iplanet.am.sdk.AMObject)1