/**
   * This method triggered by cache entry listener.
   *
   * @param identityCacheKey
   * @param policyStatus
   */
  public static void updateLocalPolicyCacheMap(
      IdentityCacheKey identityCacheKey, PolicyStatus policyStatus) {
    if (identityCacheKey.getKey() != null) {
      if (!identityCacheKey.getKey().equals("")) {
        if (log.isDebugEnabled()) {
          log.debug(
              "Updating local cache map for the tenant : "
                  + identityCacheKey.getTenantId()
                  + " and Policy : "
                  + identityCacheKey.getKey());
        }
        synchronized (localPolicyCacheMap) {
          if (localPolicyCacheMap.get(identityCacheKey.getTenantId()) != null) {
            if (localPolicyCacheMap
                    .get(identityCacheKey.getTenantId())
                    .get(identityCacheKey.getKey())
                != null) {
              PolicyStatus status =
                  localPolicyCacheMap
                      .get(identityCacheKey.getTenantId())
                      .get(identityCacheKey.getKey());
              status.setPolicyAction(
                  getPriorityAction(status.getPolicyAction(), policyStatus.getPolicyAction()));
              if (log.isDebugEnabled()) {
                log.debug(
                    "Updated existing policy in local cache map :  Policy : "
                        + identityCacheKey.getKey()
                        + " and new action : "
                        + getPriorityAction(
                            status.getPolicyAction(), policyStatus.getPolicyAction()));
              }
            } else {
              localPolicyCacheMap
                  .get(identityCacheKey.getTenantId())
                  .put(policyStatus.getPolicyId(), policyStatus);
              if (log.isDebugEnabled()) {
                log.debug(
                    "Adding policy in to the local cache policy map : policy :  "
                        + identityCacheKey.getKey());
              }
            }
          } else {
            Map<String, PolicyStatus> map = new HashMap<String, PolicyStatus>();

            map.put(policyStatus.getPolicyId(), policyStatus);
            localPolicyCacheMap.put(identityCacheKey.getTenantId(), map);
            if (log.isDebugEnabled()) {
              log.debug(
                  "Adding policy in to the local cache policy map : policy :  "
                      + identityCacheKey.getKey()
                      + " add new entry for this tenant : "
                      + identityCacheKey.getTenantId());
            }
          }
        }
      } else {
        cacheInvalidationState.put(identityCacheKey.getTenantId(), 1);
        if (log.isDebugEnabled()) {
          log.debug(
              "Trigger event to clear all cache in tenant :  " + identityCacheKey.getTenantId());
        }
      }
    }
  }