当前位置: 首页>>代码示例>>Java>>正文


Java Asset.getRendition方法代码示例

本文整理汇总了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);
        }

    }
 
开发者ID:headwirecom,项目名称:aem-solr-search,代码行数:20,代码来源:GeometrixxMediaArticleBody.java

示例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;
}
 
开发者ID:HeroDigital,项目名称:renditions-servlet,代码行数:36,代码来源:AssetRenditionResolverImpl.java

示例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());
}
 
开发者ID:quatico-solutions,项目名称:aem-testing,代码行数:10,代码来源:AssetTestDriver.java

示例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;
    }
}
 
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:18,代码来源:ContentFinderHitBuilder.java

示例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());
}
 
开发者ID:quatico-solutions,项目名称:aem-testing,代码行数:11,代码来源:AssetTestDriver.java

示例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;
}
 
开发者ID:steeleforge,项目名称:ironsites,代码行数:14,代码来源:IronImage.java


注:本文中的com.day.cq.dam.api.Asset.getRendition方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。