@PostConstruct public void init() throws SlingModelsException { Asset asset = resource.adaptTo(Asset.class); if(null == asset){ return; } Rendition rendition = (asset.getRendition("plain") != null) ? asset.getRendition("plain") : asset.getOriginal(); StringWriter writer = new StringWriter(); try { IOUtils.copy(rendition.getStream(), writer, "UTF8"); this.body = writer.toString(); } catch (IOException e) { LOG.error("Error reading rendition: {}", rendition.getPath(), e); } }
@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; } };
@Override public final boolean accepts(@NotNull Media media) { if (!media.isValid()) { return false; } Asset asset = getDamAsset(media); if (asset != null) { return asset.getRendition(new PrefixRenditionPicker(VideoConstants.RENDITION_PREFIX)) != null; } else { return false; } }
/** * Get the timestamp for the last change to the thumbnail. * * @param asset * @return */ private static long getCK(final Asset asset) { try { Resource resource = asset.getRendition(DAM_THUMBNAIL); Resource contentResource = resource.getChild(JcrConstants.JCR_CONTENT); ValueMap properties = contentResource.adaptTo(ValueMap.class); return properties.get(JcrConstants.JCR_LASTMODIFIED, 0L) / ONE_MILLION; } catch (Exception ex) { return 0L; } }
/** * Get the timestamp for the last change to the thumbnail. * * @param asset * @return */ private static long getCacheKiller(final Asset asset) { try { Resource resource = asset.getRendition(DAM_THUMBNAIL); Resource contentResource = resource.getChild(JcrConstants.JCR_CONTENT); ValueMap properties = contentResource.adaptTo(ValueMap.class); return properties.get(JcrConstants.JCR_LASTMODIFIED, 0L) / ONE_MILLION; } catch (Exception ex) { return 0L; } }
com.day.cq.dam.api.Rendition rendition = asset.getRendition(new PrefixRenditionPicker(VideoConstants.RENDITION_PREFIX + H264_PROFILE)); if (rendition == null) { return null;
final Rendition rendition = asset.getRendition(new PrefixRenditionPicker(renditionName));
return; final Rendition rendition = pair.asset.getRendition(new PrefixRenditionPicker(renditionName));
Rendition rendition = asset.getRendition(String.format(DamConstants.PREFIX_ASSET_WEB + ".%d.%d.%s", resizeWidth, resizeWidth, extension)); if (rendition != null) {
Rendition rendition = asset.getRendition(renditionPatternPicker);
Rendition rendition = asset.getRendition(renditionPatternPicker);