public Collection<IdentityObject> findIdentityObject(
      IdentityStoreInvocationContext invocationCtx,
      IdentityObjectType identityType,
      IdentityObjectSearchCriteria criteria)
      throws IdentityException {

    // TODO: fix

    //      IdentityObjectSearchImpl search = new IdentityObjectSearchImpl();
    //      search.setIdentityObjectSearchCriteria(criteria);
    //      if (identityType != null)
    //      {
    //         search.setType(identityType.getName());
    //      }

    //      Collection<IdentityObject> results =
    // cacheSupport.getIdentityObjectSearch(getCacheNS(invocationCtx), search);

    //      if (results != null)
    //      {
    //         return results;
    //      }

    Collection<IdentityObject> results =
        identityStore.findIdentityObject(invocationCtx, identityType, criteria);

    //      cacheSupport.putIdentityObjectSearch(getCacheNS(invocationCtx), search, results);

    return results;
  }
  public Collection<IdentityObject> findIdentityObject(
      IdentityStoreInvocationContext invocationCtx,
      IdentityObject identity,
      IdentityObjectRelationshipType relationshipType,
      boolean parent,
      IdentityObjectSearchCriteria criteria)
      throws IdentityException {

    IdentityObjectSearchImpl search = new IdentityObjectSearchImpl();
    search.setIdentityObjectSearchCriteria(criteria);
    search.setParent(parent);
    if (relationshipType != null) {
      search.setRelationshipType(relationshipType.getName());
    }
    if (identity != null) {
      search.setName(identity.getName());
      search.setType(identity.getIdentityType().getName());
    }

    Collection<IdentityObject> results =
        cacheSupport.getIdentityObjectSearch(getCacheNS(invocationCtx), search);

    if (results != null) {
      // TODO
      return results;
    }

    results =
        identityStore.findIdentityObject(
            invocationCtx, identity, relationshipType, parent, criteria);

    cacheSupport.putIdentityObjectSearch(getCacheNS(invocationCtx), search, results);

    return results;
  }
  public IdentityObject findIdentityObject(
      IdentityStoreInvocationContext invocationContext,
      String name,
      IdentityObjectType identityObjectType)
      throws IdentityException {
    IdentityObjectSearchImpl search = new IdentityObjectSearchImpl();
    search.setName(name);
    if (identityObjectType != null) {
      search.setType(identityObjectType.getName());
    }
    Collection<IdentityObject> results =
        cacheSupport.getIdentityObjectSearch(getCacheNS(invocationContext), search);

    if (results != null && results.size() == 1) {
      return results.iterator().next();
    }

    IdentityObject io =
        identityStore.findIdentityObject(invocationContext, name, identityObjectType);

    if (io != null) {
      Set<IdentityObject> temp = new HashSet<IdentityObject>();
      temp.add(io);
      cacheSupport.putIdentityObjectSearch(getCacheNS(invocationContext), search, temp);
    }

    return io;
  }