Expand my Community achievements bar.

SOLVED

how to call Property change listener of an asset .

Avatar

Level 4

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.

 

@component(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);
 
    
    private ResourceResolverService rr;
    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();
 
 
    
   }
 
}
1 Accepted Solution

Avatar

Correct answer by
Employee

@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?

 

View solution in original post

2 Replies

Avatar

Correct answer by
Employee

@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?

 

Avatar

Community Advisor

Please refer to the reply on https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/query-on-resourcechangelis... 

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/... 

 

 


Aanchal Sikka