【问题标题】:How to add custom metadata field in Asset programatically during the creation of asset如何在资产创建过程中以编程方式在资产中添加自定义元数据字段
【发布时间】:2016-10-12 16:46:15
【问题描述】:

我想在资产创建期间在资产中添加自定义元数据字段。我参考了资产类和资产管理器类的文档。我已经使用 createAsset 函数来创建资产。

<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dam="http://www.day.com/dam/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:mix="http://www.jcp.org/jcr/mix/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
    jcr:mixinTypes="[mix:referenceable]"
    jcr:primaryType="dam:Asset"
    jcr:uuid="11111111111111111111111">
    <jcr:content
        dam:relativePath="demo/demo"
        jcr:lastModified="{Date}2016-10-12T21:13:27.224+05:30"
        jcr:lastModifiedBy="dam-replication-service"
        jcr:primaryType="dam:AssetContent">
        <metadata
            dam:extracted="{Date}2016-10-12T21:13:27.164+05:30"
            dam:sha1="17cb9a4ba368ff01951a11c3ca7e3f8348eee59c"
            dam:size="{Long}1184"
            dc:format="application/demo"
            jcr:mixinTypes="[cq:Taggable]"
            jcr:primaryType="nt:unstructured"/>
        <related jcr:primaryType="nt:unstructured"/>
    </jcr:content>
</jcr:root>

这是一个演示代码。我想在元数据中添加一个附加属性说:source="xyz"。我还提到了这个链接Adding additional Metadata field in AEM-DAM。 有人可以帮帮我吗。 提前致谢。

【问题讨论】:

    标签: adobe aem livefyre


    【解决方案1】:

    不清楚您在添加其他元数据字段时遇到了什么问题。有几种方法可以做到这一点 -

    1. 覆盖元数据表单并添加附加字段,如here 所述
    2. 如果源是可自动识别的,您可以添加自定义流程(编写您自己的流程步骤,然后添加到模型)步骤来更新资产工作流程 - /etc/workflow/models/dam/update_asset.html 或编写事件监听器(流程密集型,因为它会被称为多个通过工作流导入和处理资产的时间),它监听资产变化并添加元数据字段

    【讨论】:

    • 我想在资产中添加自定义 mimetype 属性。假设我有函数 Asset myAsset = assetManager.createAsset(path, byteArrayStream, "application/demo", true);
    • 我想在创建资产后添加自定义 mimetype 属性,如 source="xyz"
    • 抱歉不同的cmets。错误地我按下了回车键并发布了评论我​​没有看到编辑它的选项。结果将是:
    • 您可以尝试asset.adapTo(Resource.class) 然后按照上面链接中的更新步骤进行操作
    【解决方案2】:

    使用 java Sling 你可以像这样添加我希望如此:-

        session = resource.getResourceResolver().adaptTo(Session.class);
        Node node = session.getNode(resource.getPath());
        node.setProperty("hpe-un:objec_name", "my text");
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-09-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多