use of com.okta.sdk.impl.ds.DefaultResourceDataResult in project okta-sdk-java by okta.
the class DefaultResourceCacheStrategy method readFromCache.
@Override
public ResourceDataResult readFromCache(ResourceDataRequest request) {
if (!isCacheRetrievalEnabled(request)) {
return null;
}
final CanonicalUri uri = request.getUri();
final Class<? extends Resource> clazz = request.getResourceClass();
Map<String, ?> data = null;
// Prevent an expanded request to obtain a non-expanded resource from the cache
String cacheKey = getCacheKey(request);
if (!(request.getUri().hasQuery() && request.getUri().getQuery().containsKey("expand") ^ (cacheKey != null && cacheKey.contains("expand=")))) {
data = getCachedValue(cacheKey, clazz);
}
// return if no data
if (Collections.isEmpty(data)) {
return null;
}
return new DefaultResourceDataResult(request.getAction(), uri, clazz, coerce(data));
}
Aggregations