Search This Blog

Thursday 19 September 2019

Custom Namespace for metadata properties of assets


Use case

Add custom metadata properties to schema of an asset. Update properties manually or through bulk upload on the metadata node of an asset. Custom properties should be persisted to the binary.

Approach

Its common knowledge that any updates to metadata node of an asset trigger metadata writeback workflow which writes the metadata to the binary/renditions.

For writeback to write a property to the binary the property should have a namespace attached. Else the properties without namespace are ignored.

This premise can be confirmed by following the below steps.

  1. Add a property w/o namespace ex. "testProperty" on the metadata node of the asset from crx and give it some random value.
  2. Add a custom namespace(xyz) and add a property(xyz:testProperty) with custom namespace on the metadata node of the asset.
  3. Run the metadata writeback. Properties on the metadata node should be written to original rendition.
  4. Download the original rendition, rename it and upload it again to AEM.
  5. "testProperty" is not available, while the xyz:testProperty is available on the asset metadata node.
Conclusion: XMP writback doesnt work for properties w/o namespaces.

There are other consequences of not having namespaces for custom properties like Bulk upload (tools like url-asset-importer or csvimporter) wont work for properties w/o namespaces.


Implementation


Creating a custom namespace

  1. Open crx explorer. http://localhost:4504/crx/explorer/index.jsp > Node Type Administration > Namespaces > Add >
    a.   Enter a url for the namespace (ex. “http://my-namespace”)b. Enter the Prefix (ex.  “custom”).

     2. Use url-asset-importer to import the xls.
         http://localhost:4504/etc/acs-commons/manage-controlled-processes.html





Adding namespace to code


Add namespace in nodetypes.cnd






No comments:

Post a Comment