本文整理汇总了Java中com.day.cq.dam.api.Asset.getRendition方法的典型用法代码示例。如果您正苦于以下问题:Java Asset.getRendition方法的具体用法?Java Asset.getRendition怎么用?Java Asset.getRendition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.day.cq.dam.api.Asset
的用法示例。
在下文中一共展示了Asset.getRendition方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import com.day.cq.dam.api.Asset; //导入方法依赖的package包/类
@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);
}
}
示例2: resolveRendition
import com.day.cq.dam.api.Asset; //导入方法依赖的package包/类
/**
* Returned {@link Rendition} is resolved with the following priority rules:
* <ol>
* <li>Rendition type (eg. web, thumbnail)</li>
* <li>Rendition extension (eg. png, jpeg)</li>
* </ol>
* First match is returned. Requested dimensions are always honored.
* <p>
* {@link RenditionType#ORIGINAL} is a special case which will always result in the "original"
* returned, or null if missing. No extra search rules are used.
*/
@Override
public Rendition resolveRendition(Asset asset, RenditionMeta renditionMeta) {
if (asset == null) return null;
if (renditionMeta == null) return null;
List<String> renditionPriorityList = buildSortedRenditions(renditionMeta);
if (log.isTraceEnabled()) {
log.trace("Searching for {} rendition in order of {}", asset.getPath(), renditionPriorityList);
}
Rendition rendition = null;
for (String name : renditionPriorityList) {
if (log.isTraceEnabled()) log.trace("Searching for {} for {}", name, asset.getPath());
rendition = asset.getRendition(name);
if (rendition != null) break;
}
if (log.isDebugEnabled()) {
log.debug("Resolved rendition {} for {} and {}", (rendition == null) ? "null" : rendition.getName(), asset.getPath(), renditionMeta);
}
return rendition;
}
示例3: getRenditionStringWithExistingNameReturnsRendition
import com.day.cq.dam.api.Asset; //导入方法依赖的package包/类
@Test
public void getRenditionStringWithExistingNameReturnsRendition() throws Exception {
Asset target = anAsset("/libs/quatico/base/templates/backend/thumbnail.png");
target.addRendition("cq5dam.thumbnail.48.48.png", ContentBuilder.createDummyImage(1, 1, EMPTY), EMPTY);
Rendition actual = target.getRendition("cq5dam.thumbnail.48.48.png");
assertEquals("cq5dam.thumbnail.48.48.png", actual.getName());
}
示例4: getCacheKiller
import com.day.cq.dam.api.Asset; //导入方法依赖的package包/类
/**
* 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;
}
}
示例5: assetWithRenditionAndExistingNameYieldsRendition
import com.day.cq.dam.api.Asset; //导入方法依赖的package包/类
@Test
public void assetWithRenditionAndExistingNameYieldsRendition() throws Exception {
Asset target = testObj.anAsset().path("/libs/quatico/base/templates/backend/thumbnail.png").rendition(
testObj.anAssetRendition().name("cq5dam.thumbnail.48.48.png").inputStream(ContentBuilder.createDummyImage(1, 1, EMPTY))
).build();
Rendition actual = target.getRendition("cq5dam.thumbnail.48.48.png");
assertEquals("cq5dam.thumbnail.48.48.png", actual.getName());
}
示例6: getReferencedResource
import com.day.cq.dam.api.Asset; //导入方法依赖的package包/类
@Override
protected Resource getReferencedResource(final String path) {
Resource resource = getResourceResolver().getResource(path);
if (null != resource) {
Asset asset = resource.adaptTo(Asset.class);
if (null != asset) {
// obtain original asset rendition
Rendition rendition = asset.getRendition(getRendition());
resource = (null != rendition)? rendition.adaptTo(Resource.class) : null;
}
}
return resource;
}