public Set<String> getRelationshipNames(
      IdentityStoreInvocationContext ctx,
      IdentityObject identity,
      IdentityObjectSearchCriteria criteria)
      throws IdentityException, OperationNotSupportedException {

    IdentityObjectRelationshipNameSearchImpl search =
        new IdentityObjectRelationshipNameSearchImpl();
    if (identity != null) {
      search.setIoName(identity.getName());
      search.setIoType(identity.getIdentityType().getName());
    }
    search.setIdentityObjectSearchCriteria(criteria);

    Set<String> results =
        cacheSupport.getIdentityObjectRelationshipNameSearch(getCacheNS(ctx), search);

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

    results = identityStore.getRelationshipNames(ctx, identity, criteria);

    cacheSupport.putIdentityObjectRelationshipNameSearch(getCacheNS(ctx), 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 Set<IdentityObjectRelationship> resolveRelationships(
      IdentityStoreInvocationContext invocationCxt,
      IdentityObject fromIdentity,
      IdentityObject toIdentity,
      IdentityObjectRelationshipType relationshipType)
      throws IdentityException {

    IdentityObjectRelationshipSearchImpl search = new IdentityObjectRelationshipSearchImpl();
    if (fromIdentity != null) {
      search.setFromIOName(fromIdentity.getName());
      search.setFromIOType(fromIdentity.getIdentityType().getName());
    }
    if (toIdentity != null) {
      search.setToIOName(toIdentity.getName());
      search.setToIOType(toIdentity.getIdentityType().getName());
    }
    if (relationshipType != null) {
      search.setRelationshipType(relationshipType.getName());
    }

    Set<IdentityObjectRelationship> results =
        cacheSupport.getIdentityObjectRelationshipSearch(getCacheNS(invocationCxt), search);

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

    results =
        identityStore.resolveRelationships(
            invocationCxt, fromIdentity, toIdentity, relationshipType);

    cacheSupport.putIdentityObjectRelationshipSearch(getCacheNS(invocationCxt), search, results);

    return results;
  }
  public void removeIdentityObject(
      IdentityStoreInvocationContext invocationCtx, IdentityObject identity)
      throws IdentityException {
    identityStore.removeIdentityObject(invocationCtx, identity);

    cacheSupport.invalidateIdentityObjectRelationshipNameSearches(getCacheNS(invocationCtx));
    cacheSupport.invalidateIdentityObjectRelationshipSearches(getCacheNS(invocationCtx));
    cacheSupport.invalidateIdentityObjectSearches(getCacheNS(invocationCtx));
    cacheSupport.invalidateIdentityObjectAttriubtes(getCacheNS(invocationCtx), identity);
    cacheSupport.invalidateIdentityObjectCount(
        getCacheNS(invocationCtx), identity.getIdentityType().getName());
  }
  public Set<IdentityObjectRelationship> resolveRelationships(
      IdentityStoreInvocationContext invocationCtx,
      IdentityObject identity,
      IdentityObjectRelationshipType relationshipType,
      boolean parent,
      boolean named,
      String name)
      throws IdentityException {

    IdentityObjectRelationshipSearchImpl search = new IdentityObjectRelationshipSearchImpl();
    if (identity != null) {
      search.setIoName(identity.getName());
      search.setIoType(identity.getIdentityType().getName());
    }
    if (relationshipType != null) {
      search.setRelationshipType(relationshipType.getName());
    }
    search.setParent(parent);
    search.setNamed(named);
    search.setName(name);

    Set<IdentityObjectRelationship> results =
        cacheSupport.getIdentityObjectRelationshipSearch(getCacheNS(invocationCtx), search);

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

    results =
        identityStore.resolveRelationships(
            invocationCtx, identity, relationshipType, parent, named, name);

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

    return results;
  }