/** * Given an {@link Asset}, this method will return the first web {@link Rendition} it finds in the asset's renditions list. * * @param asset the asset for which to retrieve the web rendition * @return the rendition, if found, {@code null} otherwise */ private Rendition getAWebRendition(Asset asset) { List<Rendition> renditions = asset.getRenditions(); for (Rendition rendition : renditions) { if (rendition.getName().startsWith(DamConstants.PREFIX_ASSET_WEB)) { return rendition; } } return null; }
/** * @return All renditions that are available for this asset */ Set<RenditionMetadata> getAvailableRenditions(MediaArgs mediaArgs) { if (this.renditions == null) { // gather rendition infos of all renditions and sort them by size (smallest or virtual crop rendition first) Set<RenditionMetadata> candidates = new TreeSet<RenditionMetadata>(); for (Rendition rendition : asset.getRenditions()) { addRendition(candidates, rendition, mediaArgs); } candidates = postProcessCandidates(candidates); this.renditions = ImmutableSet.<RenditionMetadata>copyOf(candidates); } return this.renditions; }
private long getTotalAssetSize(Asset asset) { long size = asset.getRenditions().stream().collect(Collectors.summingLong(r -> r.getSize())); if (includeSubassets && !asset.isSubAsset()) { size += DamUtil.getSubAssets(asset.adaptTo(Resource.class)).stream().collect(Collectors.summingLong(this::getTotalAssetSize)); } return size; }
public final Rendition getRendition(final Asset asset) { final List<Rendition> renditions = asset.getRenditions(); final Pattern p = getPattern();
public final Rendition getRendition(final Asset asset) { final List<Rendition> renditions = asset.getRenditions(); final Pattern p = getPattern();
DamUtil.getSubAssets(asset.adaptTo(Resource.class)).stream().forEach(subasset -> { tabulate(folderPath, Column.subasset_count, 1); long size = subasset.getRenditions().stream().collect(Collectors.summingLong(Rendition::getSize)); tabulate(folderPath, Column.subasset_size, size); tabulate(folderPath, Column.combined_size, size);
@Override public Boolean apply(ResourceResolver r, String path) { nameThread("filterAssetsWithOutdatedRenditions-" + path); Resource res = r.getResource(path); com.day.cq.dam.api.Asset asset = DamUtil.resolveToAsset(res); if (asset == null) { return false; } com.day.cq.dam.api.Rendition original = asset.getRendition(ORIGINAL_RENDITION); if (original == null) { return false; } long originalTime = original.getResourceMetadata().getCreationTime(); int counter = 0; for (com.day.cq.dam.api.Rendition rendition : asset.getRenditions()) { counter++; long time = rendition.getResourceMetadata().getCreationTime(); if (time < originalTime) { return true; } } return counter <= 1; } };