/** * @param value DAM rendition * @return true if rendition is the original file that was uploaded initially */ private boolean isOriginalRendition(Rendition value) { return StringUtils.equals(value.getName(), ORIGINAL_FILE); }
/** * 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; }
private RenditionMetadata getWebEnabledRendition(NavigableSet<RenditionMetadata> candidates) { Iterator<RenditionMetadata> descendingIterator = candidates.descendingIterator(); while (descendingIterator.hasNext()) { RenditionMetadata rendition = descendingIterator.next(); if (DEFAULT_WEB_RENDITION_PATTERN.matcher(rendition.getRendition().getName()).matches()) { return rendition; } } return null; }
/** * adds rendition to the list of candidates, if it should be available for resolving * @param candidates * @param rendition */ private void addRendition(Set<RenditionMetadata> candidates, Rendition rendition, MediaArgs mediaArgs) { // ignore CQ thumbnail renditions (unless explicitly enabled in mediaargs) if (mediaArgs.isIncludeAssetThumbnails() || !StringUtils.startsWith(rendition.getName(), DamConstants.PREFIX_ASSET_THUMBNAIL + ".")) { RenditionMetadata renditionMetadata = createRenditionMetadata(rendition); candidates.add(renditionMetadata); } }
void saveImage(Asset asset, Rendition toReplace, Layer layer, String mimetype, double quality, WorkflowHelper workflowHelper) throws IOException { File tmpFile = File.createTempFile(getTempFileSpecifier(), "." + workflowHelper.getExtension(mimetype)); OutputStream out = FileUtils.openOutputStream(tmpFile); InputStream is = null; try { layer.write(mimetype, quality, out); is = FileUtils.openInputStream(tmpFile); asset.addRendition(toReplace.getName(), is, mimetype); } finally { IOUtils.closeQuietly(out); IOUtils.closeQuietly(is); FileUtils.deleteQuietly(tmpFile); } }
void saveImage(Asset asset, Rendition toReplace, Layer layer, String mimetype, double quality) throws IOException { File tmpFile = File.createTempFile(getTempFileSpecifier(), "." + getExtension(mimetype)); OutputStream out = FileUtils.openOutputStream(tmpFile); InputStream is = null; try { layer.write(mimetype, quality, out); is = FileUtils.openInputStream(tmpFile); asset.addRendition(toReplace.getName(), is, mimetype); } finally { IOUtils.closeQuietly(out); IOUtils.closeQuietly(is); FileUtils.deleteQuietly(tmpFile); } }
final Matcher m = p.matcher(rendition.getName());
final Matcher m = p.matcher(rendition.getName());
String renditionName = rendition.getName(); if (isOriginal) { renditionName = asset.getName(); String metadataPath = JcrConstants.JCR_CONTENT + "/" + NN_RENDITIONS_METADATA + "/" + rendition.getName(); Resource metadataResource = asset.adaptTo(Resource.class).getChild(metadataPath); if (metadataResource != null) {
asset.listRenditions().forEachRemaining(r -> renditions.put(r.getName(), r)); Rendition original = renditions.remove("original"); tabulate(folderPath, Column.rendition_count, renditions.size());