• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Rendition类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.day.cq.dam.api.Rendition的典型用法代码示例。如果您正苦于以下问题:Java Rendition类的具体用法?Java Rendition怎么用?Java Rendition使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Rendition类属于com.day.cq.dam.api包,在下文中一共展示了Rendition类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: init

import com.day.cq.dam.api.Rendition; //导入依赖的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.Rendition; //导入依赖的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: getBinary

import com.day.cq.dam.api.Rendition; //导入依赖的package包/类
@Override
public ResourceBinary getBinary(Resource resource) {

    Asset asset = resource.adaptTo(Asset.class);
    ResourceBinary binary = null;
    if (asset != null) {
        binary = new ResourceBinary();
        binary.setName(asset.getName());
        binary.setPath(resource.getPath());
        binary.setContentType(asset.getMimeType());
        // get original rendition
        Rendition original = asset.getOriginal();
        if (original != null) {
            binary.setSize(original.getSize());
            binary.setStream(original.getStream());
            return binary;
        }
    }
    return binary;
}
 
开发者ID:mwmd,项目名称:ease,代码行数:21,代码来源:AssetIndexer.java


示例4: getRendition

import com.day.cq.dam.api.Rendition; //导入依赖的package包/类
/**
 * Gets the rendition which matches against the constructor's Regex pattern.
 * <p>
 * If no matches are made and an Original exists, returns the Original.
 * <p>
 * If no matches are made and an Original doesn't exist, return the first Rendition.
 *
 * @param asset Asset whose Renditions will be selected.
 * @return The first rendition whose name matches the supplied pattern (via constructor).
 */
@Override
public final Rendition getRendition(final Asset asset) {

    final List<Rendition> renditions = asset.getRenditions();
    final Pattern p = getPattern();

    boolean hasOriginal = asset.getOriginal() != null;
    boolean hasRenditions = renditions.size() > 0;

    for (final Rendition rendition : renditions) {
        final Matcher m = p.matcher(rendition.getName());

        if (m.find()) {
            return rendition;
        }
    }

    if (hasOriginal) {
        return asset.getOriginal();
    } else if (hasRenditions) {
        return renditions.get(0);
    } else {
        return null;
    }
}
 
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:36,代码来源:RenditionPatternPicker.java


示例5: getRenditionStringWithExistingNameReturnsRendition

import com.day.cq.dam.api.Rendition; //导入依赖的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


示例6: getOriginalWithExistingRenditionReturnsOriginal

import com.day.cq.dam.api.Rendition; //导入依赖的package包/类
@Test
public void getOriginalWithExistingRenditionReturnsOriginal() throws Exception {
	Asset target = anAsset("/libs/quatico/base/templates/backend/thumbnail.png");
	
	Rendition actual = target.getOriginal();
	
	assertEquals("original", actual.getName());
}
 
开发者ID:quatico-solutions,项目名称:aem-testing,代码行数:9,代码来源:AssetTestDriver.java


示例7: listRenditionsWithExistingRendtionsIsNotEmpty

import com.day.cq.dam.api.Rendition; //导入依赖的package包/类
@Test
public void listRenditionsWithExistingRendtionsIsNotEmpty() throws Exception {
	Asset target = anAsset("/libs/quatico/base/templates/backend/thumbnail.png");
	
	Iterator<Rendition> actual = target.listRenditions();
	
	assertTrue(actual.hasNext());
}
 
开发者ID:quatico-solutions,项目名称:aem-testing,代码行数:9,代码来源:AssetTestDriver.java


示例8: apply

import com.day.cq.dam.api.Rendition; //导入依赖的package包/类
public Rendition apply(Asset asset) {
    InputStream stream = null;

    Rendition var3;
    try {
        stream = RenditionMakerImpl.this.gfx.render(this.plan, ((Resource)asset.adaptTo(Resource.class)).getResourceResolver());
        if(stream == null) {
            return null;
        }

        var3 = asset.addRendition(this.renditionName, stream, this.mimeType);
    } finally {
        IOUtils.closeQuietly(stream);
    }

    return var3;
}
 
开发者ID:Shashi-Bhushan,项目名称:General,代码行数:18,代码来源:RenditionMakerImpl.java


示例9: writeResponse

import com.day.cq.dam.api.Rendition; //导入依赖的package包/类
private static void writeResponse(SlingHttpServletResponse response, Rendition rendition) throws IOException {
	InputStream inputStream = null;
	OutputStream outputStream = null;
	try {
		inputStream = rendition.getStream();
		outputStream = response.getOutputStream();
		
		// NOTE: This does not matter if dispatcher serves image	
		// Dispatcher will use extension of file, it does not save HTTP Content-Type header
		response.setContentType(rendition.getMimeType());
		
		IOUtils.copy(inputStream, outputStream);
	} finally {
		if (inputStream != null) inputStream.close();
		if (outputStream != null) outputStream.close();
	}
}
 
开发者ID:HeroDigital,项目名称:renditions-servlet,代码行数:18,代码来源:ImageRenditionServlet.java


示例10: getSize

import com.day.cq.dam.api.Rendition; //导入依赖的package包/类
/**
 * Get the size of the Asset (the original rendition).
 *
 * @param asset
 * @return
 */
private static long getSize(final Asset asset) {
    final Rendition original = asset.getOriginal();
    if (original == null) {
        return 0;
    }
    return original.getSize();
}
 
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:14,代码来源:ContentFinderHitBuilder.java


示例11: processLayer

import com.day.cq.dam.api.Rendition; //导入依赖的package包/类
@Override
protected Layer processLayer(Layer layer, Rendition rendition, WorkflowSession workflowSession, String[] args) {
    final String watermarkPath = workflowHelper.getValuesFromArgs(ARG_WATERMARK, args).size() > 0 ? workflowHelper.getValuesFromArgs(
            ARG_WATERMARK, args).get(0) : null;

    if (watermarkPath != null) {
        Layer watermark = null;
        try {
            watermark = getLayer(watermarkPath, workflowSession);

            if (watermark != null) {
                addWatermark(layer, watermark);
            }
        } catch (LoginException e) {
            log.error("Unable to log into repository.", e);
        } finally {
            if (watermark != null) {
                watermark.dispose();
                watermark = null;
            }
        }
    } else {
        log.info("No watermark specified. Skipping.");
    }
    return layer;
}
 
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:27,代码来源:AddWatermarkToRenditionProcess.java


示例12: getRenditionsWithExistingRenditionsIsNotEmpty

import com.day.cq.dam.api.Rendition; //导入依赖的package包/类
@Test
public void getRenditionsWithExistingRenditionsIsNotEmpty() throws Exception {
	Asset target = anAsset("/libs/quatico/base/templates/backend/thumbnail.png");
	
	List<Rendition> actual = target.getRenditions();
	
	assertFalse(actual.isEmpty());
}
 
开发者ID:quatico-solutions,项目名称:aem-testing,代码行数:9,代码来源:AssetTestDriver.java


示例13: assetWithRenditionAndExistingNameYieldsRendition

import com.day.cq.dam.api.Rendition; //导入依赖的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


示例14: getAWebRendition

import com.day.cq.dam.api.Rendition; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:Adobe-Marketing-Cloud,项目名称:aem-core-wcm-components,代码行数:16,代码来源:AdaptiveImageServlet.java


示例15: init

import com.day.cq.dam.api.Rendition; //导入依赖的package包/类
@Before
public void init() throws IOException {
    resourceResolver = CONTEXT.resourceResolver();
    servlet = new AdaptiveImageServlet();
    Whitebox.setInternalState(servlet, "mimeTypeService", mockedMimeTypeService);
    AssetHandler assetHandler = mock(AssetHandler.class);
    AssetStore assetStore = mock(AssetStore.class);
    when(assetStore.getAssetHandler(anyString())).thenReturn(assetHandler);
    when(assetHandler.getImage(any(Rendition.class))).thenAnswer(invocation -> {
        Rendition rendition = invocation.getArgumentAt(0, Rendition.class);
        return ImageIO.read(rendition.getStream());
    });
    Whitebox.setInternalState(servlet, "assetStore", assetStore);
    activateServlet(servlet);
}
 
开发者ID:Adobe-Marketing-Cloud,项目名称:aem-core-wcm-components,代码行数:16,代码来源:AdaptiveImageServletTest.java


示例16: createThumbnailTemplate

import com.day.cq.dam.api.Rendition; //导入依赖的package包/类
public RenditionTemplate createThumbnailTemplate(Rendition rendition, int width, int height, boolean doCenter) {
    RenditionMakerImpl.PlanBasedTemplate template = new RenditionMakerImpl.PlanBasedTemplate();
    Asset asset = rendition.getAsset();
    boolean useRenditionPath = rendition.equals(asset.getOriginal());
    template.renditionName = DamUtil.getThumbnailName(width, height, doCenter?new String[]{"margin"}:null);
    template.mimeType = "image/jpg";
    template.plan = this.gfx.createPlan();
    template.plan.layer(0).set("src", useRenditionPath?rendition.getPath():asset.getPath());
    applyOrientation(OrientationUtil.getOrientation(asset), template.plan.layer(0));
    applyThumbnail(width, height, doCenter, template.mimeType, template.plan);
    return template;
}
 
开发者ID:Shashi-Bhushan,项目名称:General,代码行数:13,代码来源:RenditionMakerImpl.java


示例17: generateRenditions

import com.day.cq.dam.api.Rendition; //导入依赖的package包/类
public List<Rendition> generateRenditions(Asset asset, RenditionTemplate... templates) {
    boolean oldBatchMode = asset.isBatchMode();
    asset.setBatchMode(true);
    ArrayList renditions = new ArrayList();
    RenditionTemplate[] e = templates;
    int len$ = templates.length;

    for(int i$ = 0; i$ < len$; ++i$) {
        RenditionTemplate cfg = e[i$];
        Rendition rendition = cfg.apply(asset);
        if(rendition != null) {
            log.info("generated rendition: {}", rendition.getPath());
            renditions.add(rendition);
        }
    }

    if(this.propagateXMP) {
        this.propagateXMP(asset, renditions);
    }

    asset.setBatchMode(oldBatchMode);

    try {
        ((Node)asset.adaptTo(Node.class)).getSession().save();
    } catch (RepositoryException var10) {
        log.error("Error while generating renditions for asset " + asset.getPath(), var10);
    }

    return renditions;
}
 
开发者ID:Shashi-Bhushan,项目名称:General,代码行数:31,代码来源:RenditionMakerImpl.java


示例18: propagateXMP

import com.day.cq.dam.api.Rendition; //导入依赖的package包/类
private void propagateXMP(Asset asset, List<Rendition> renditions) {
        if(this.xmpHandler != null && this.xmpHandler.isSupported(asset.getMimeType())) {
//            XMPWriteBackOptionsImpl writeBackOptions = new XMPWriteBackOptionsImpl();
//            writeBackOptions.createVersion(false);
//            writeBackOptions.setRenditions(new HashSet(renditions));
//            this.writeXmp(asset, writeBackOptions, this.xmpHandler);
        }

    }
 
开发者ID:Shashi-Bhushan,项目名称:General,代码行数:10,代码来源:RenditionMakerImpl.java


示例19: execute

import com.day.cq.dam.api.Rendition; //导入依赖的package包/类
public void execute(WorkItem workItem, WorkflowSession workflowSession, MetaDataMap metaData) throws WorkflowException {
    Asset asset = null;
    try {
        final Map<String, Object> map = new HashMap<String, Object>();
        map.put("user.jcr.session", workflowSession.getSession());

        ResourceResolver rr = resolverFactory.getResourceResolver(map);

        String path = workItem.getWorkflowData().getPayload().toString();
        Resource resource = rr.getResource(path);

        Rendition rendition = resource.adaptTo(Rendition.class);

        asset = rendition.getAsset();
    } catch (LoginException e) {
        log.info("Error in Try Catch");
    } catch(Exception cause){
        log.info("Cause : " , cause.getMessage());
    }

    if(asset == null) {
        String config1 = workItem.getWorkflowData().getPayload().toString();
        String templates1 = "execute: cannot create thumbnails, asset [{" + config1 + "}] in payload doesn\'t exist for workflow [{" + workItem.getId() + "}].";
        throw new WorkflowException(templates1);
    } else {
        CreateThumbnailProcess.Config config = this.parseConfig(metaData);
        if(this.handleAsset(asset, config)) {
            asset.setBatchMode(true);
            RenditionTemplate[] templates = createRenditionTemplates(asset, config.thumbnails, this.renditionMakerImpl);
            this.renditionMakerImpl.generateRenditions(asset, templates);
        }

    }
}
 
开发者ID:Shashi-Bhushan,项目名称:General,代码行数:35,代码来源:ImageWorkflow.java


示例20: sendRedirectToProperExtension

import com.day.cq.dam.api.Rendition; //导入依赖的package包/类
private static void sendRedirectToProperExtension(SlingHttpServletRequest request, SlingHttpServletResponse response, Rendition rendition, RenditionMeta renditionMeta) throws IOException {
	String requestURL = request.getRequestURL().toString();
	String requestExt = request.getRequestPathInfo().getExtension();
	String newExt = getExtension(rendition.getMimeType());
	String redirect = requestURL;
	redirect = redirect.replaceAll(requestExt+"$", newExt);
	
	log.warn("Requested {}, however, mime type of rendition is {}. Redirecting to {}", requestURL, rendition.getMimeType(), redirect);
	response.sendRedirect(redirect);
}
 
开发者ID:HeroDigital,项目名称:renditions-servlet,代码行数:11,代码来源:ImageRenditionServlet.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ParametersListUtil类代码示例发布时间:2022-05-22
下一篇:
Java TimeSeriesURLGenerator类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap