gpt4 book ai didi

java - 如何在 AEM 6.3 中从 DAM 获取到期 Assets ?

转载 作者:行者123 更新时间:2023-11-30 05:32:24 24 4
gpt4 key购买 nike

我需要从 DAM 获取过期 Assets ?

我尝试过下面的代码片段。但它不起作用。

protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response) throws ServerException, IOException {
try {

ResourceResolver resourceResolver = resolverFactory.getServiceResourceResolver(null);
session = resourceResolver.adaptTo(Session.class);

// create query description as hash map (simplest way, same as form post)
Map<String, String> map = new HashMap<String, String>();

//set QueryBuilder search criteria
map.put("type", "dam:Asset");
map.put("path", "/content/dam/images/rt1");
map.put("property.value", "image/png");

builder = resourceResolver.adaptTo(QueryBuilder.class);

//INvoke the Search query
Query query = builder.createQuery(PredicateGroup.create(map), session);

SearchResult sr = query.getResult();

//write out to the AEM Log file
log.info("Search Results: " + sr.getTotalMatches());

//Create a MAP to store results
Map<String, InputStream> dataMap = new HashMap<String, InputStream>();

// iterating over the results
for (Hit hit : sr.getHits()) {

//Convert the HIT to an asset - each asset will be placed into a ZIP for downloading
String path = hit.getPath();
Resource rs = resourceResolver.getResource(path);
Asset asset = rs.adaptTo(Asset.class);

//We have the File Name and the inputstream
InputStream data = asset.getOriginal().getStream();
String name = asset.getName();

}
}

我的代码无法正常工作。

最佳答案

有多种方法可以在 AEM 中搜索过期 Assets 。

Option 1: If it is only for view purpose you can use the AEM search from the AEM console

  • 输入您要检查过期资源的 DAM 文件夹路径(或将其留空以搜索整个存储库)
  • 选择文件类型为“图像”(或将其留空以搜索所有资源)
  • 选中“状态”过滤器下的“过期”复选框

    上述过滤器应显示所有过期 Assets

Option 2: Query to retrieve the expired assets

到期日期将作为“prism:expirationDate”存储在元数据节点中

您可以在查询中使用以下属性集来获取结果。

path=/content/dam/<site>
type=dam:Asset
property=@jcr:content/metadata/prism:expirationDate
property.operation=exists

关于java - 如何在 AEM 6.3 中从 DAM 获取到期 Assets ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57264627/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com