Source:
CompletionStage<RestResponse> putValueToCache(RestRequest request) { String cacheName = request.variables().get("cacheName"); MediaType contentType = request.contentType(); MediaType keyContentType = request.keyContentType(); RestCacheManager<Object> restCacheManager = invocationHelper.getRestCacheManager(); AdvancedCache<Object, Object> cache = restCacheManager.getCache(cacheName, keyContentType, contentType, request); Object key = request.variables().get("cacheKey"); if (key == null) throw new NoKeyException(); NettyRestResponse.Builder responseBuilder = new NettyRestResponse.Builder().status(HttpResponseStatus.NO_CONTENT); ContentSource contents = request.contents(); if (contents == null) throw new NoDataFoundException(); Long ttl = request.getTimeToLiveSecondsHeader(); Long idle = request.getMaxIdleTimeSecondsHeader(); byte[] data = request.contents().rawContent(); return restCacheManager.getPrivilegedInternalEntry(cache, key, true).thenCompose(entry -> { if (request.method() == POST && entry != null) { return CompletableFuture.completedFuture(responseBuilder.status(HttpResponseStatus.CONFLICT.code()).entity("An entry already exists").build()); } if (entry instanceof InternalCacheEntry) { InternalCacheEntry ice = (InternalCacheEntry) entry; String etagNoneMatch = request.getEtagIfNoneMatchHeader(); if (etagNoneMatch != null) { String etag = calcETAG(ice.getValue()); if (etagNoneMatch.equals(etag)) { responseBuilder.status(HttpResponseStatus.NOT_MODIFIED.code()); return CompletableFuture.completedFuture(responseBuilder.build()); } } } return putInCache(responseBuilder, cache, key, data, ttl, idle, request.getSubject()); }); }

Target:
CompletionStage<RestResponse> putValueToCache(RestRequest request) { String cacheName = request.variables().get("cacheName"); MediaType contentType = request.contentType(); MediaType keyContentType = request.keyContentType(); RestCacheManager<Object> restCacheManager = invocationHelper.getRestCacheManager(); AdvancedCache<Object, Object> cache = restCacheManager.getCache(cacheName, keyContentType, contentType, request); Object key = request.variables().get("cacheKey"); if (key == null) throw new NoKeyException(); NettyRestResponse.Builder responseBuilder = new NettyRestResponse.Builder().status(HttpResponseStatus.NO_CONTENT); ContentSource contents = request.contents(); if (contents == null) throw new NoDataFoundException(); Long ttl = request.getTimeToLiveSecondsHeader(); Long idle = request.getMaxIdleTimeSecondsHeader(); byte[] data = request.contents().rawContent(); return restCacheManager.getPrivilegedInternalEntry(cache, key, true).thenCompose(entry -> { if (request.method() == POST && entry != null) { return CompletableFuture.completedFuture(responseBuilder.status(HttpResponseStatus.CONFLICT.code()).entity("An entry already exists").build()); } if (entry instanceof InternalCacheEntry) { InternalCacheEntry ice = (InternalCacheEntry) entry; String etagNoneMatch = request.getEtagIfNoneMatchHeader(); if (etagNoneMatch != null) { String etag = calcETAG(ice.getValue()); if (etagNoneMatch.equals(etag)) { responseBuilder.status(HttpResponseStatus.NOT_MODIFIED.code()); return CompletableFuture.completedFuture(responseBuilder.build()); } } } return putInCache(responseBuilder, cache, key, data, ttl, idle); }); }