Custom Namespace in AEM

Why a namespace is required?

Assets metadata in AEM might be updated from multiple 3rd party systems. Namespaces help us identify the source of the metadata.

To persist custom metadata properties to the binary. Unless a namespace is attached to a property, the property will not be persisted to the binary.

Its common knowledge that any updates to metadata node of an asset trigger metadata write-back workflow which writes the metadata to the binary/renditions. For write-back 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 doing a quick test.

  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.

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

Creating a custom namespace

  1. Open CRX explorer -> http://localhost:4502/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”).

Adding namespace to code

Add namespace in nodetypes.cnd (old way)

In AEMaaCS repo-init is recommended way of adding namespaces

1 Comment

  1. Gaurav Raheja

    Thank you. this is helpful for migration of Assets and to ensure namespaces are available in each environment with adding them to the repoinit file. Can we have a separate blog on the repo-init and how to add it through the code and the capabilities.

Leave a Reply

Your email address will not be published. Required fields are marked *