diff options
Diffstat (limited to 'graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryRestClient.java')
-rw-r--r-- | graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryRestClient.java | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryRestClient.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryRestClient.java index c2422085aa..6ccd1a2cab 100644 --- a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryRestClient.java +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryRestClient.java @@ -21,10 +21,16 @@ package org.onap.aaiclient.client.graphinventory; import java.net.URI; -import java.util.Map; import java.util.Optional; +import javax.ws.rs.client.ClientBuilder; +import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.core.Response; +import org.javatuples.Pair; +import org.onap.aaiclient.client.CacheControlFeature; +import org.onap.aaiclient.client.FlushCache; import org.onap.logging.filter.base.ONAPComponentsList; +import org.onap.so.client.AddCacheHeaders; +import org.onap.so.client.CacheFactory; import org.onap.so.client.ResponseExceptionMapper; import org.onap.so.client.RestClientSSL; import org.onap.so.client.RestProperties; @@ -41,11 +47,26 @@ public abstract class GraphInventoryRestClient extends RestClientSSL { super(props, Optional.of(uri)); } + + protected ClientBuilder enableCaching(ClientBuilder builder) { + builder.register(new AddCacheHeaders(props.getCacheProperties())); + builder.register(new FlushCache(props.getCacheProperties())); + CacheControlFeature cacheControlFeature = new CacheControlFeature(); + cacheControlFeature.setCacheResponseInputStream(true); + cacheControlFeature.setExpiryPolicyFactory(new CacheFactory(props.getCacheProperties())); + builder.property("org.onap.aaiclient.client.CacheControlFeature.name", + props.getCacheProperties().getCacheName()); + + builder.register(cacheControlFeature); + + return builder; + } + @Override public abstract ONAPComponentsList getTargetEntity(); @Override - protected abstract void initializeHeaderMap(Map<String, String> headerMap); + protected abstract void initializeHeaderMap(MultivaluedMap<String, Pair<String, String>> headerMap); @Override protected abstract Optional<ResponseExceptionMapper> addResponseExceptionMapper(); |