How to add a property to existing AEM node
Hi I want to add a property in some nodes in AEM, those nodes were created using a template and I already added that property to the template. The question is how can I change the existing nodes created using that template?
Here's my code:
String queryString = "SELECT [jcr:path] FROM [cq:Page] AS s WHERE ISDESCENDANTNODE(/content/pagefolder1])";
ResourceResolver resourceResolver = request.getResourceResolver();
Session session = resourceResolver .adaptTo(Session.class);
QueryManager queryManager =sessopm.getWorkspace().getQueryManager();
Query query = queryManager.createQuery(queryString . Query.JCR_SQL2);
QueryResult queryResult = query.execute();
NodeIterator nodes= queryResult.getNodes();
While(nodes.hasNext()){
Node node = nodes.nextNode();
if(!node.hasProperty("NewProperty")){
JcrUtil.setProperty (node, "NewProperty", true); } }
when I run the code, I am getting javax.jcr.nodetype.ConstraintViolationException : No matching property defintion: NewProperty = true
Please advise, thanks