Custom Metadata population on asset upload | Community
Skip to main content
Level 2
October 16, 2015
Solved

Custom Metadata population on asset upload

  • October 16, 2015
  • 1 reply
  • 620 views

I have a requirement of setting current logged in user's ID as value for a custom metadata field once I upload an asset in AEM DAM. eg. I logged in as admin,then "admin" need to be stored as value for a custom metadata field name "Owner'. How I can achieve it?

Thanks LM

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by smacdonald2008

Write a custom DAM handler that is called when an asset is uploaded:

https://helpx.adobe.com/experience-manager/using/damhandler.html

You need to read the user id using the User management API:

http://jackrabbit.apache.org/api/2.0/org/apache/jackrabbit/api/security/user/UserManager.html

You can get current user:

Session session = resourceResolver.adaptTo(Session.class);
    UserManager userManager = resourceResolver.adaptTo(UserManager.class);
    /* to get the current user */
    Authorizable auth = userManager.getAuthorizable(session.getUserID());

Get the id and set the asset using AssetManger API. 

1 reply

smacdonald2008
smacdonald2008Accepted solution
Level 10
October 16, 2015

Write a custom DAM handler that is called when an asset is uploaded:

https://helpx.adobe.com/experience-manager/using/damhandler.html

You need to read the user id using the User management API:

http://jackrabbit.apache.org/api/2.0/org/apache/jackrabbit/api/security/user/UserManager.html

You can get current user:

Session session = resourceResolver.adaptTo(Session.class);
    UserManager userManager = resourceResolver.adaptTo(UserManager.class);
    /* to get the current user */
    Authorizable auth = userManager.getAuthorizable(session.getUserID());

Get the id and set the asset using AssetManger API.