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


Java Asset类代码示例

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


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

示例1: create

import com.day.cq.dam.api.Asset; //导入依赖的package包/类
@Override
public IndexEntry create(String path, @Nonnull ResourceResolver resolver) {
  String[] indexRules = getIndexRules(PRIMARY_TYPE_VALUE);
  if (ArrayUtils.isNotEmpty(indexRules)) {
  Resource res = resolver.getResource(path);
  if (res != null) {
    Asset asset = res.adaptTo(Asset.class);
    if (asset != null) {
      IndexEntry ret = new IndexEntry("idx", "asset", path);
      ret.addContent(getProperties(res, indexRules));
      return ret;
    }
    LOG.error("Could not adapt asset");
    }
  }
  return null;
}
 
开发者ID:deveth0,项目名称:elasticsearch-aem,代码行数:18,代码来源:DAMAssetContentBuilder.java

示例2: 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

示例3: 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

示例4: getBinary

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

示例5: getRendition

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

示例6: internalBuild

import com.day.cq.dam.api.Asset; //导入依赖的package包/类
@Override
protected Asset internalBuild() throws Exception {
	ContentBuilder content = client.getContentBuilder();
	
	String path = path();
	if (StringUtils.isBlank(path)) {
		throw new RuntimeException("Cannot build asset with null path.");
	}
	
	if (hasValue("classpathResource") && StringUtils.isNotBlank(classpathResource())) {
		this.result = content.asset(path, classpathResource(), mimetype(), metadata());
	} else if (hasValue("inputStream")) {
		this.result = content.asset(path, inputStream(), mimetype(), metadata());
	} else {
		this.result = content.asset(path, width(), height(), mimetype(), metadata());
	}
	
	if (hasChildren("renditions")) {
		for (RenditionBuilder cur : renditions()) {
			cur.build();
			if (cur.hasInputStream()) {
				content.assetRendition(result, cur.name(), cur.inputStream(), cur.mimetype());
			} else if (StringUtils.isNotBlank(cur.classpathResource())) {
				content.assetRendition(result, cur.name(), cur.classpathResource(), cur.mimetype());
			} else {
				content.assetRendition(result, cur.name(), cur.width(), cur.height(), cur.mimetype());
			}
		}
	}
	
	return result;
}
 
开发者ID:quatico-solutions,项目名称:aem-testing,代码行数:33,代码来源:AssetBuilder.java

示例7: getMetadataValueReturnsMetadataValue

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

示例8: 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

示例9: getOriginalWithExistingRenditionReturnsOriginal

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

示例10: listRenditionsWithExistingRendtionsIsNotEmpty

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

示例11: apply

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

示例12: findTag

import com.day.cq.dam.api.Asset; //导入依赖的package包/类
public Tag findTag(String tagId, Asset asset, Session session) {
	Tag tag = null;
	ResourceResolver resourceResolver = null;

	try {
		resourceResolver = getResourceResolver(session);
		TagManager tagManager = resourceResolver.adaptTo(TagManager.class);
		tag = tagManager.resolve(tagId);
	} finally {
		if (null != resourceResolver && resourceResolver.isLive()) {
			resourceResolver.close();
		}
	}

	return tag;
}
 
开发者ID:Cognifide,项目名称:AEM-Rules-for-SonarQube,代码行数:17,代码来源:ResourceResolverConsumer.java

示例13: indexData

import com.day.cq.dam.api.Asset; //导入依赖的package包/类
@Override
public void indexData(Map<String, Object> data, Resource resource, String containerPath) {

    Asset asset = resource.adaptTo(Asset.class);
    if (asset != null) {
        data.put(IndexFields.PATH, asset.getPath());
        Object tagsArr = asset.getMetadata(NameConstants.PN_TAGS);
        if (tagsArr != null && tagsArr instanceof Object[]) {
            Object[] tags = (Object[]) tagsArr;
            for (Object tag : tags) {
                putMultiValue(data, IndexFields.TAGS, tag.toString());
            }
        }

        String title = StringUtils.trimToNull((String) asset.getMetadataValue("dc:title"));
        if (title == null || title.trim().length() == 0) {
            title = asset.getName();
        }
        data.put(IndexFields.TITLE, title);
    }
}
 
开发者ID:mwmd,项目名称:ease,代码行数:22,代码来源:AssetIndexer.java

示例14: getReplicationStatusResource

import com.day.cq.dam.api.Asset; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public Resource getReplicationStatusResource(String path, ResourceResolver resourceResolver) {
    final Page page = resourceResolver.adaptTo(PageManager.class).getContainingPage(path);
    final Asset asset = DamUtil.resolveToAsset(resourceResolver.getResource(path));

    Resource resource;
    String type;

    if (page != null) {
        type = "Page";
        resource = page.getContentResource();
    } else if (asset != null) {
        type = "Asset";
        Resource assetResource = resourceResolver.getResource(asset.getPath());
        resource = assetResource.getChild(JcrConstants.JCR_CONTENT);
    } else {
        type = "Resource";
        resource = resourceResolver.getResource(path);
    }

    log.trace(type + "'s resource that tracks replication status is " + resource.getPath());
    return resource;
}
 
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:27,代码来源:ReplicationStatusManagerImpl.java

示例15: invoke

import com.day.cq.dam.api.Asset; //导入依赖的package包/类
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
    String methodName = method.getName();
    Asset asset = (Asset) proxy;
    switch (methodName) {
        case "adaptTo":
            return adaptTo((Class<?>) args[0]);
        case "getMetadataValue":
            return getMetadataValue((String) args[0]);
        case "isSubAsset":
            return isSubAsset();
        case "getRenditions":
            return getRenditions(asset);
        case "getSubAssets":
            return getSubAssets();
        default:
            LOG.error("FROZEN ASSET >> NO IMPLEMENTATION FOR "+methodName);
            throw new UnsupportedOperationException();
    }
}
 
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:21,代码来源:FrozenAsset.java


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