Hi All,
I have a basic requirement where I have a Image and havings it's custom rendition under /content/dam/test/Test.jpg/jcr:content/metadata/customRendition
Now I have to readthe values of properties from /content/dam/test/Test.jpg/jcr:content/metadata/customRendition which holds the path of assets [in given case it is prop1, prop2, prop3...] and unpublish those path.
For unpublishing we can use replicator.replicate(__,ReplicationActionType.DEACTIVATE).
But How o read the values of properties, and in our case property name is prop1, prop2, prop3 and so on...
Similarly we have to read all the values from all properties and it is not fixed.
// Get the current node
Node currentNode = resourceResolver.getResource("/content/dam/test/Test.jpg/jcr:content/metadata/customRendition").adaptTo(Node.class);
// Get the properties
PropertyIterator properties = currentNode.getProperties();
// Iterate over properties
while (properties.hasNext()) {
Property property = properties.nextProperty();
String propertyName = property.getName();
// Check if the property is prop1, prop2, prop3
if (propertyName.equals("prop1") || propertyName.equals("prop2") || propertyName.equals("prop3")) {
// Get the asset paths
String assetPath = property.getValue().getString();
// Get the asset node
Node assetNode = resourceResolver.getResource(assetPath).adaptTo(Node.class);
we can use Property Iterator but since we don't have fixed set of properties in that case how to check for properties.equal condition?
Thanks
@kautuk_sahni @arunpatidar @BrianKasingli @Theo_Pendle
Solved! Go to Solution.
Views
Replies
Total Likes
Resource resource = resourceResolver.getResource("/content/dam/test/Test.jpg/jcr:content/metadata/customRendition");
ValueMap properties = resource.getValueMap();
for(Entry<String, Object> e : properties.entrySet()) {
String key = e.getKey();
Object value = e.getValue();
//use the key and value here
}
I would suggest to use the query api like this:
https://gist.github.com/munim/e03a3f418dbc29cc912c1fc5c4eaeb87
Views
Replies
Total Likes
Resource resource = resourceResolver.getResource("/content/dam/test/Test.jpg/jcr:content/metadata/customRendition");
ValueMap properties = resource.getValueMap();
for(Entry<String, Object> e : properties.entrySet()) {
String key = e.getKey();
Object value = e.getValue();
//use the key and value here
}
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies