@Test public void should_return_all_assets() { AssetRequestContext.get(request).addBundles("bundle5").excludeCss("unknown_css"); Set<Asset> assets = new AssetQuery(request, context).perform(); assertThat(assets).extracting("name").containsExactly("a5_1", "a5_2", "a5_3", "a5_4", "a5_5"); }
public Set<Asset> perform() { Set<Asset> requestedAssets = null; String requestCacheKey = null; String currentUri = UrlUtils.getCurrentUri(request).toString(); LOG.debug("Performing query for the request \"{}\"", currentUri); if (this.context.getConfiguration().isCachingEnabled()) { requestCacheKey = this.context.getCacheManager().generateRequestCacheKey(this.request); CacheEntry cacheElement = this.context.getCacheManager().getAssets(requestCacheKey); if (cacheElement != null) { requestedAssets = cacheElement.getAssets(); } } if (requestedAssets == null) { Set<AssetStorageUnit> assetStorageUnits = collectAssetStorageUnits(); AssetMapper assetMapper = new AssetMapper(context, request); requestedAssets = assetMapper.mapToAssets(assetStorageUnits); if (this.context.getConfiguration().isCachingEnabled()) { requestedAssets = context.getCacheManager() .storeAssets(requestCacheKey, new CacheEntry(currentUri, requestedAssets)).getAssets(); } } Set<Asset> filteredAssets = getFilteredAssets(requestedAssets); LOG.debug("-> Query returned {} assets: {}", filteredAssets.size(), filteredAssets); return filteredAssets; }
AssetQuery { public Set<Asset> perform() { Set<Asset> requestedAssets = null; String requestCacheKey = null; String currentUri = UrlUtils.getCurrentUri(request).toString(); LOG.debug("Performing query for the request \"{}\"", currentUri); if (this.context.getConfiguration().isCachingEnabled()) { requestCacheKey = this.context.getCacheManager().generateRequestCacheKey(this.request); CacheEntry cacheElement = this.context.getCacheManager().getAssets(requestCacheKey); if (cacheElement != null) { requestedAssets = cacheElement.getAssets(); } } if (requestedAssets == null) { Set<AssetStorageUnit> assetStorageUnits = collectAssetStorageUnits(); AssetMapper assetMapper = new AssetMapper(context, request); requestedAssets = assetMapper.mapToAssets(assetStorageUnits); if (this.context.getConfiguration().isCachingEnabled()) { requestedAssets = context.getCacheManager() .storeAssets(requestCacheKey, new CacheEntry(currentUri, requestedAssets)).getAssets(); } } Set<Asset> filteredAssets = getFilteredAssets(requestedAssets); LOG.debug("-> Query returned {} assets: {}", filteredAssets.size(), filteredAssets); return filteredAssets; } }
AssetQuery { public Set<Asset> perform() { Set<Asset> requestedAssets = null; String requestCacheKey = null; String currentUri = UrlUtils.getCurrentUri(request).toString(); LOG.debug("Performing query for the request \"{}\"", currentUri); if (this.context.getConfiguration().isCachingEnabled()) { requestCacheKey = this.context.getCacheManager().generateRequestCacheKey(this.request); CacheEntry cacheElement = this.context.getCacheManager().getAssets(requestCacheKey); if (cacheElement != null) { requestedAssets = cacheElement.getAssets(); } } if (requestedAssets == null) { Set<AssetStorageUnit> assetStorageUnits = collectAssetStorageUnits(); AssetMapper assetMapper = new AssetMapper(context, request); requestedAssets = assetMapper.mapToAssets(assetStorageUnits); if (this.context.getConfiguration().isCachingEnabled()) { requestedAssets = context.getCacheManager() .storeAssets(requestCacheKey, new CacheEntry(currentUri, requestedAssets)).getAssets(); } } Set<Asset> filteredAssets = getFilteredAssets(requestedAssets); LOG.debug("-> Query returned {} assets: {}", filteredAssets.size(), filteredAssets); return filteredAssets; } AssetQuery(HttpServletRequest request, Context context); }
AssetQuery { public Set<Asset> perform() { Set<Asset> requestedAssets = null; String requestCacheKey = null; String currentUri = UrlUtils.getCurrentUri(request).toString(); LOG.debug("Performing query for the request \"{}\"", currentUri); if (this.context.getConfiguration().isCachingEnabled()) { requestCacheKey = this.context.getCacheManager().generateRequestCacheKey(this.request); CacheEntry cacheElement = this.context.getCacheManager().getAssets(requestCacheKey); if (cacheElement != null) { requestedAssets = cacheElement.getAssets(); } } if (requestedAssets == null) { Set<AssetStorageUnit> assetStorageUnits = collectAssetStorageUnits(); AssetMapper assetMapper = new AssetMapper(context, request); requestedAssets = assetMapper.mapToAssets(assetStorageUnits); if (this.context.getConfiguration().isCachingEnabled()) { requestedAssets = context.getCacheManager() .storeAssets(requestCacheKey, new CacheEntry(currentUri, requestedAssets)).getAssets(); } } Set<Asset> filteredAssets = getFilteredAssets(requestedAssets); LOG.debug("-> Query returned {} assets: {}", filteredAssets.size(), filteredAssets); return filteredAssets; } AssetQuery(HttpServletRequest request, Context context); AssetQuery atPosition(AssetDomPosition assetDomPosition); Set<Asset> perform(); Set<Alert> alerts(); }
AssetQuery { public Set<Asset> perform() { Set<Asset> requestedAssets = null; String requestCacheKey = null; String currentUri = UrlUtils.getCurrentUri(request).toString(); LOG.debug("Performing query for the request \"{}\"", currentUri); if (this.context.getConfiguration().isCachingEnabled()) { requestCacheKey = this.context.getCacheManager().generateRequestCacheKey(this.request); CacheEntry cacheElement = this.context.getCacheManager().getAssets(requestCacheKey); if (cacheElement != null) { requestedAssets = cacheElement.getAssets(); } } if (requestedAssets == null) { Set<AssetStorageUnit> assetStorageUnits = collectAssetStorageUnits(); AssetMapper assetMapper = new AssetMapper(context, request); requestedAssets = assetMapper.mapToAssets(assetStorageUnits); if (this.context.getConfiguration().isCachingEnabled()) { requestedAssets = context.getCacheManager() .storeAssets(requestCacheKey, new CacheEntry(currentUri, requestedAssets)).getAssets(); } } Set<Asset> filteredAssets = getFilteredAssets(requestedAssets); LOG.debug("-> Query returned {} assets: {}", filteredAssets.size(), filteredAssets); return filteredAssets; } AssetQuery(HttpServletRequest request, Context context); AssetQuery atPosition(AssetDomPosition assetDomPosition); Set<Asset> perform(); Set<Alert> alerts();  }