@Test public void whenCacheTokenOsInvalidShouldBeStale() { underTest = new OrientPyPiGroupFacet(repositoryManager, constraintViolationFactory, new GroupType()) { @Override public boolean isStale(@Nullable final Content content) { return true; } }; assertTrue(underTest.isStale(null, originalContent, ImmutableMap.of())); }
public boolean isStale(final String name, final Content content, final Map<Repository, Response> responses) { DateTime cacheModified = extractLastModified(content); if (cacheModified == null || isStale(content)) { return true; } for (Entry<Repository, Response> response : responses.entrySet()) { Response responseValue = response.getValue(); if (responseValue.getStatus().getCode() == HttpStatus.OK) { Content responseContent = (Content) responseValue.getPayload(); if (responseContent != null) { DateTime memberLastModified = responseContent.getAttributes().get(CONTENT_LAST_MODIFIED, DateTime.class); if (memberLastModified == null || memberLastModified.isAfter(cacheModified)) { log.debug("Found stale content while fetching {} from repository {}", name, response.getKey().getName()); return true; } } } } return false; }
OrientPyPiGroupFacet extends GroupFacetImpl { public boolean isStale(final String name, final Content content, final Map<Repository, Response> responses) { DateTime cacheModified = extractLastModified(content); if (cacheModified == null || isStale(content)) { return true; } for (Entry<Repository, Response> response : responses.entrySet()) { Response responseValue = response.getValue(); if (responseValue.getStatus().getCode() == HttpStatus.OK) { Content responseContent = (Content) responseValue.getPayload(); if (responseContent != null) { DateTime memberLastModified = responseContent.getAttributes().get(CONTENT_LAST_MODIFIED, DateTime.class); if (memberLastModified == null || memberLastModified.isAfter(cacheModified)) { log.debug("Found stale content while fetching {} from repository {}", name, response.getKey().getName()); return true; } } } } return false; } }
OrientPyPiGroupFacet extends GroupFacetImpl { public boolean isStale(final String name, final Content content, final Map<Repository, Response> responses) { DateTime cacheModified = extractLastModified(content); if (cacheModified == null || isStale(content)) { return true; } for (Entry<Repository, Response> response : responses.entrySet()) { Response responseValue = response.getValue(); if (responseValue.getStatus().getCode() == HttpStatus.OK) { Content responseContent = (Content) responseValue.getPayload(); if (responseContent != null) { DateTime memberLastModified = responseContent.getAttributes().get(CONTENT_LAST_MODIFIED, DateTime.class); if (memberLastModified == null || memberLastModified.isAfter(cacheModified)) { log.debug("Found stale content while fetching {} from repository {}", name, response.getKey().getName()); return true; } } } } return false; } @Inject  OrientPyPiGroupFacet(final RepositoryManager repositoryManager,
                        final ConstraintViolationFactory constraintViolationFactory,
                        @Named(GroupType.NAME) final Type groupType); }
OrientPyPiGroupFacet extends GroupFacetImpl { public boolean isStale(final String name, final Content content, final Map<Repository, Response> responses) { DateTime cacheModified = extractLastModified(content); if (cacheModified == null || isStale(content)) { return true; } for (Entry<Repository, Response> response : responses.entrySet()) { Response responseValue = response.getValue(); if (responseValue.getStatus().getCode() == HttpStatus.OK) { Content responseContent = (Content) responseValue.getPayload(); if (responseContent != null) { DateTime memberLastModified = responseContent.getAttributes().get(CONTENT_LAST_MODIFIED, DateTime.class); if (memberLastModified == null || memberLastModified.isAfter(cacheModified)) { log.debug("Found stale content while fetching {} from repository {}", name, response.getKey().getName()); return true; } } } } return false; } @Inject  OrientPyPiGroupFacet(final RepositoryManager repositoryManager,
                        final ConstraintViolationFactory constraintViolationFactory,
                        @Named(GroupType.NAME) final Type groupType); Content buildIndexRoot(final String name, final AssetKind assetKind, final Supplier<String> lazyMergeResult); @Subscribe @Guarded(by = STARTED) @AllowConcurrentEvents void on(final AssetCreatedEvent event); @Subscribe @Guarded(by = STARTED) @AllowConcurrentEvents void on(final AssetDeletedEvent event); @TransactionalTouchBlob Content getFromCache(final String name, final AssetKind assetKind); boolean isStale(final String name, final Content content, final Map<Repository, Response> responses); @TransactionalStoreBlob Content saveToCache(final String name, final Content content); }
OrientPyPiGroupFacet extends GroupFacetImpl { public boolean isStale(final String name, final Content content, final Map<Repository, Response> responses) { DateTime cacheModified = extractLastModified(content); if (cacheModified == null || isStale(content)) { return true; } for (Entry<Repository, Response> response : responses.entrySet()) { Response responseValue = response.getValue(); if (responseValue.getStatus().getCode() == HttpStatus.OK) { Content responseContent = (Content) responseValue.getPayload(); if (responseContent != null) { DateTime memberLastModified = responseContent.getAttributes().get(CONTENT_LAST_MODIFIED, DateTime.class); if (memberLastModified == null || memberLastModified.isAfter(cacheModified)) { log.debug("Found stale content while fetching {} from repository {}", name, response.getKey().getName()); return true; } } } } return false; } @Inject  OrientPyPiGroupFacet(final RepositoryManager repositoryManager,
                        final ConstraintViolationFactory constraintViolationFactory,
                        @Named(GroupType.NAME) final Type groupType); Content buildIndexRoot(final String name, final AssetKind assetKind, final Supplier<String> lazyMergeResult); @Subscribe @Guarded(by = STARTED) @AllowConcurrentEvents void on(final AssetCreatedEvent event); @Subscribe @Guarded(by = STARTED) @AllowConcurrentEvents void on(final AssetDeletedEvent event); @TransactionalTouchBlob Content getFromCache(final String name, final AssetKind assetKind); boolean isStale(final String name, final Content content, final Map<Repository, Response> responses); @TransactionalStoreBlob Content saveToCache(final String name, final Content content);  }