how to call Property change listener of an asset . | Community
Skip to main content
djohn98390536
Level 4
February 12, 2024
Solved

how to call Property change listener of an asset .

  • February 12, 2024
  • 2 replies
  • 1610 views

I have an requirement like whenever a property called "dxmlLastCreatedVersion" of an asset  is getting changed a listener should listen the event .I am using the below code kindly hv a look and let me know is this the correct way get an event for a node property change. It is working for all property change under /content/dam/sample this path ,but it should work only specific property change.

 

@8220494(immediate = true,
        service = ResourceChangeListener.class,
        property = {
                ResourceChangeListener.PATHS + "=" + "/content/dam/sample",
                ResourceChangeListener.CHANGES + "=" + "CHANGED",
                ResourceChangeListener.PROPERTY_NAMES_HINT + "=dxmlLastCreatedVersion"
        })
 
public class PropertyChangeListener implements ResourceChangeListener {
 
    
    private static final Logger LOG = LoggerFactory.getLogger(PropertyChangeListener.class);
 
    
 @3214626
    private ResourceResolverService rr;
@9944223
    public void onChange(List<ResourceChange> lists) {
       
ResourceResolver resourceResolver = null;
 
try {
 
resourceResolver = rr.getResourceResolver();
for (ResourceChange resourceChange : lists) {
String resourcepath = resourceChange.getPath();
 
LOG.info("******* RESOURCE PATH *******"+ resourcepath);
 
Resource resource = resourceResolver.getResource(resourcepath);
 
LOG.info("******* RESOURCE NAME *******"+ resource.getName());
 
}
 
} catch (LoginException e) {
 
e.printStackTrace();
 
 
    
   }
 
}
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 DivrajSingh

@djohn98390536 : To answer "how can you trigger a process when a property of an asset is updated", my inputs below:

  • You can setup a workflow launcher where you can configure the property on which a listener should be setup and call your custom process on change/delete events. [read more about Workflow launcher]
  • A similar question is answered on this forum post

 

However, what customization are you planning to implement on change of property jcr:content/dxmlLastCreatedVersion?

 

2 replies

DivrajSingh
Adobe Employee
DivrajSinghAdobe EmployeeAccepted solution
Adobe Employee
February 15, 2024

@djohn98390536 : To answer "how can you trigger a process when a property of an asset is updated", my inputs below:

  • You can setup a workflow launcher where you can configure the property on which a listener should be setup and call your custom process on change/delete events. [read more about Workflow launcher]
  • A similar question is answered on this forum post

 

However, what customization are you planning to implement on change of property jcr:content/dxmlLastCreatedVersion?

 

aanchal-sikka
Community Advisor
Community Advisor
February 15, 2024

Please refer to the reply on https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/query-on-resourcechangelistener/m-p/248115 

They have been able to resolve this.

 

However, I have not found "PROPERTY_NAMES_HINT" on multiple implementations. Even the documentation suggests.

"This is only a hint, a change listener registering with this property must be prepared that the underlying implementation is not able to filter based on this property."

Ref: https://developer.adobe.com/experience-manager/reference-materials/6-5/javadoc/org/apache/sling/api/resource/observation/ResourceChangeListener.html#PROPERTY_NAMES_HINT 

 

 

Aanchal Sikka