本文整理汇总了Java中com.day.cq.dam.api.Asset.getMetadataValue方法的典型用法代码示例。如果您正苦于以下问题:Java Asset.getMetadataValue方法的具体用法?Java Asset.getMetadataValue怎么用?Java Asset.getMetadataValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.day.cq.dam.api.Asset
的用法示例。
在下文中一共展示了Asset.getMetadataValue方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: addAssetData
import com.day.cq.dam.api.Asset; //导入方法依赖的package包/类
/**
* Derives and adds Asset related information to the map representing the hit.
*
* @param hit
* @param map
* @return
* @throws javax.jcr.RepositoryException
*/
private static Map<String, Object> addAssetData(final Asset asset, final Hit hit, Map<String, Object> map)
throws RepositoryException {
String title = asset.getName();
if (StringUtils.isNotBlank(asset.getMetadataValue(DamConstants.DC_TITLE))) {
title = asset.getMetadataValue(DamConstants.DC_TITLE);
}
// Excerpt
String excerpt = hit.getExcerpt();
if (StringUtils.isBlank(hit.getExcerpt())) {
excerpt = StringUtils.stripToEmpty(asset.getMetadataValue(DamConstants.DC_DESCRIPTION));
if (excerpt.length() > MAX_EXCERPT_LENGTH) {
excerpt = StringUtils.substring(excerpt, 0, (MAX_EXCERPT_LENGTH - ELLIPSE_LENGTH)) + "...";
}
}
map.put(CF_PATH, asset.getPath());
map.put(CF_NAME, asset.getName());
map.put(CF_TITLE, title);
map.put(CF_EXCERPT, excerpt);
map.put(CF_MIMETYPE, asset.getMimeType());
map.put(CF_SIZE, getSize(asset));
map.put(CF_CACHE_KILLER, getCacheKiller(asset));
map.put(CF_TYPE, "Asset");
map.put(CF_LAST_MODIFIED, getLastModified(asset));
return map;
}
示例3: initModel
import com.day.cq.dam.api.Asset; //导入方法依赖的package包/类
@PostConstruct
protected void initModel() {
super.initModel();
boolean altValueFromDAM = properties.get(PN_ALT_VALUE_FROM_DAM, currentStyle.get(PN_ALT_VALUE_FROM_DAM, true));
boolean titleValueFromDAM = properties.get(PN_TITLE_VALUE_FROM_DAM, currentStyle.get(PN_TITLE_VALUE_FROM_DAM, true));
displayPopupTitle = properties.get(PN_DISPLAY_POPUP_TITLE, currentStyle.get(PN_DISPLAY_POPUP_TITLE, true));
if (StringUtils.isNotEmpty(fileReference)) {
// the image is coming from DAM
final Resource assetResource = request.getResourceResolver().getResource(fileReference);
if (assetResource != null) {
Asset asset = assetResource.adaptTo(Asset.class);
if (asset != null) {
if (!isDecorative && altValueFromDAM) {
String damDescription = asset.getMetadataValue(DamConstants.DC_DESCRIPTION);
if(StringUtils.isEmpty(damDescription)) {
damDescription = asset.getMetadataValue(DamConstants.DC_TITLE);
}
if (StringUtils.isNotEmpty(damDescription)) {
alt = damDescription;
}
}
if (titleValueFromDAM) {
String damTitle = asset.getMetadataValue(DamConstants.DC_TITLE);
if (StringUtils.isNotEmpty(damTitle)) {
title = damTitle;
}
}
} else {
LOGGER.error("Unable to adapt resource '{}' used by image '{}' to an asset.", fileReference,
request.getResource().getPath());
}
} else {
LOGGER.error("Unable to find resource '{}' used by image '{}'.", fileReference, request.getResource().getPath());
}
}
if (hasContent) {
disableLazyLoading = currentStyle.get(PN_DESIGN_LAZY_LOADING_ENABLED, true);
srcUriTemplate = request.getContextPath() + Text.escapePath(baseResourcePath) + DOT + AdaptiveImageServlet.DEFAULT_SELECTOR +
SRC_URI_TEMPLATE_WIDTH_VAR + DOT + extension +
(inTemplate ? templateRelativePath : "") + (lastModifiedDate > 0 ? "/" + lastModifiedDate + DOT + extension : "");
buildJson();
}
}
示例4: getTitleOrName
import com.day.cq.dam.api.Asset; //导入方法依赖的package包/类
/**
* Return the title or name of the asset, if the title is not defined.
*
* @param asset the asset
* @return the asset title or name
*/
@Function
public static String getTitleOrName(Asset asset) {
String title = asset.getMetadataValue(DamConstants.DC_TITLE);
return StringUtils.isNotBlank(title) ? title : asset.getName();
}