예제 #1
0
  /**
   * Method to remove the user profile from cache.
   *
   * @param userId
   */
  protected void removeProfileDataFromCache(String userId) throws ProfileServiceException {
    if (logger.isLoggable(Level.FINEST)) {
      logger.entering(sourceClass, "removeProfileDataFromCache", userId);
    }
    if (isEmail(userId)) {
      String key;
      Set<String> keys = lruCache.getKeySet();
      Iterator<String> itr = keys.iterator();
      while (itr.hasNext()) {
        key = itr.next();
        Document data = lruCache.get(key);
        // check if email in profile object is same as input userId
        String email = "";
        try {
          email = DOMUtil.value(data, Profile.xpathMap.get("email"));
        } catch (XMLException e) {
          continue;
        }

        // cache hit
        if (StringUtil.equalsIgnoreCase(email, userId)) {
          lruCache.remove(key);
        }
      }
      // Cache miss

    } else {
      lruCache.remove(userId);
    }
    if (logger.isLoggable(Level.FINEST)) {
      logger.exiting(sourceClass, "removeProfileDataFromCache");
    }
  }
예제 #2
0
 /*
  * Method to search the cache
  *
  * @param userId
  * @return Document
  */
 private Document findInCache(String userId) {
   String key;
   Set<String> keys = lruCache.getKeySet();
   Iterator<String> itr = keys.iterator();
   while (itr.hasNext()) {
     key = itr.next();
     Document data = lruCache.get(key);
     // check if email in profile object is same as input userId
     String email = "";
     try {
       email = DOMUtil.value(data, Profile.xpathMap.get("email"), Profile.nameSpaceCtx);
     } catch (XMLException e) {
       continue;
     }
     // cache hit
     if (StringUtil.equalsIgnoreCase(email, userId)) {
       return data;
     }
   }
   // Cache miss
   return null;
 }