invalidation.invalidateApplicationResources(resources, request.getToken()); invalidation.invalidateUserResources(userIds, request.getToken());
/** * Cache the HttpResponse object before being returned to caller. * The default implementation also invalidate the response object by marking it as valid so the * next request can detect if it has been invalidated. * Override this if you need to add additional processing to cache the response. * * @param request * @param fetchedResponse * @return HttpResponse object that has been updated with some metadata tags. */ protected HttpResponse cacheFetchedResponse(HttpRequest request, HttpResponse fetchedResponse) { if (!request.getIgnoreCache()) { // Mark the response with invalidation information prior to caching if (fetchedResponse.getCacheTtl() > 0) { fetchedResponse = invalidationService.markResponse(request, fetchedResponse); } HttpResponse cached = httpCache.addResponse(request, fetchedResponse); if (cached != null) { fetchedResponse = cached; // possibly modified response. } } return fetchedResponse; }
@Test public void testAllowConsumerAuthInvalidateAppResource() throws Exception { String path = "/cache/invalidate"; RestHandler operation = registry.getRestHandler(path, "POST"); params.put(InvalidationHandler.KEYS_PARAM, new String[]{"http://www.example.org/gadget.xml"}); token.setAuthenticationMode(AuthenticationMode.OAUTH_CONSUMER_REQUEST.name()); invalidationService.invalidateApplicationResources( eq(ImmutableSet.of(Uri.parse("http://www.example.org/gadget.xml"))), eq(token)); expectLastCall(); replay(); operation.execute(params, null, token, converter).get(); verify(); reset(); }
@Test public void testHandleSimpleGetInvalidateViewer() throws Exception { String path = "/cache/invalidate"; RestHandler operation = registry.getRestHandler(path, "GET"); invalidationService.invalidateUserResources( eq(ImmutableSet.of("userX")), eq(token)); expectLastCall(); replay(); operation.execute(params, null, token, converter).get(); verify(); reset(); }
if(invalidationService.isValid(request, cachedResponse)) { return cachedResponse; } else { fetchedResponse = invalidationService.markResponse(request, fetchedResponse);
if (invalidationService.isValid(request, cachedResponse)) { if(LOG.isLoggable(Level.FINEST)) { LOG.logp(Level.FINEST, classname, method, MessageKeys.CACHED_RESPONSE,
@Test public void testAllowConsumerAuthInvalidateAppResource() throws Exception { String path = "/cache/invalidate"; RestHandler operation = registry.getRestHandler(path, "POST"); params.put(InvalidationHandler.KEYS_PARAM, new String[]{"http://www.example.org/gadget.xml"}); token.setAuthenticationMode(AuthenticationMode.OAUTH_CONSUMER_REQUEST.name()); invalidationService.invalidateApplicationResources( eq(ImmutableSet.of(Uri.parse("http://www.example.org/gadget.xml"))), eq(token)); expectLastCall(); replay(); operation.execute(params, null, token, converter).get(); verify(); reset(); }
@Test public void testHandleSimpleGetInvalidateViewer() throws Exception { String path = "/cache/invalidate"; RestHandler operation = registry.getRestHandler(path, "GET"); invalidationService.invalidateUserResources( eq(ImmutableSet.of("userX")), eq(token)); expectLastCall(); replay(); operation.execute(params, null, token, converter).get(); verify(); reset(); }
if(invalidationService.isValid(request, cachedResponse)) { return cachedResponse; } else { fetchedResponse = invalidationService.markResponse(request, fetchedResponse);
invalidation.invalidateApplicationResources(resources, request.getToken()); invalidation.invalidateUserResources(userIds, request.getToken());
@Test public void testAllowConsumerAuthInvalidateAppResource() throws Exception { String path = "/cache/invalidate"; RestHandler operation = registry.getRestHandler(path, "POST"); params.put(InvalidationHandler.KEYS_PARAM, new String[]{"http://www.example.org/gadget.xml"}); token.setAuthenticationMode(AuthenticationMode.OAUTH_CONSUMER_REQUEST.name()); invalidationService.invalidateApplicationResources( eq(ImmutableSet.of(Uri.parse("http://www.example.org/gadget.xml"))), eq(token)); expectLastCall(); replay(); operation.execute(params, null, token, converter).get(); verify(); reset(); }
@Test public void testHandleSimpleGetInvalidateViewer() throws Exception { String path = "/cache/invalidate"; RestHandler operation = registry.getRestHandler(path, "GET"); invalidationService.invalidateUserResources( eq(ImmutableSet.of("userX")), eq(token)); expectLastCall(); replay(); operation.execute(params, null, token, converter).get(); verify(); reset(); }
invalidation.invalidateApplicationResources(resources, request.getToken()); invalidation.invalidateUserResources(userIds, request.getToken());