Reputation: 325
I was trying to update the metadata of DAM Asset adding a new property-value using custom workflow. The below code works fine in the execute() method.
Resource metadata = resourceResolver.getResource(resourcePath);
ModifiableValueMap properties = metadata.adaptTo(ModifiableValueMap.class);
properties.put("360 degree", "true");
try {
metadata.getResourceResolver().commit();
} catch (PersistenceException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Updating the code as below the property-value is not being created.
Resource metadata = resourceResolver.getResource(resourcePath);
Node metanode = metadata.adaptTo(Node.class);
try {
metanode.setProperty("360 degree", "true", PropertyType.BOOLEAN);
} catch (RepositoryException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Am I missing something?
Upvotes: 0
Views: 996
Reputation: 3951
I guess you forget to call javax.jcr.Session#save
.
But you should not use the JCR api when working in AEM, rely on the Sling API or even higher level apis (wcm in particular) if possible.
Upvotes: 2