0
votes

I am trying to delete a property of a node. I could manually do it in the crx explorer but there is just way to many properties that I need to delete. Below is the sample code that is currently working. However just changing its value will not solve what I am trying to accomplish. Therefore my question is:

How can I delete a property of a node?

void deleteJob(Node node, Session jcr) throws RepositoryException {

           Node jobDescNode = (Node)jcr.getItem(node.getPath() + "/jcr:content/contentpar/jobsdescription");
           if(jobDescNode.hasProperty("foo")) {

               jobDescNode.setProperty("foo", "null");
               jcr.save();

           }

     }
1

1 Answers

0
votes

It looks like you are setting the value of the property to "null" instead of removing the property.

Use

jobDescNode.setProperty("foo", (String)null);

Check the Node API for more info.