Make JCR set more robust.
authorMathieu Baudier <mbaudier@argeo.org>
Sun, 6 Dec 2020 07:03:37 +0000 (08:03 +0100)
committerMathieu Baudier <mbaudier@argeo.org>
Sun, 6 Dec 2020 07:03:37 +0000 (08:03 +0100)
org.argeo.jcr/src/org/argeo/jcr/Jcr.java

index 3cbdd57f5df6731578875e5328601b79b28606d3..6f0e39d8298759db33affea0dc57d9a69b7bb47f 100644 (file)
@@ -297,8 +297,13 @@ public class Jcr {
         */
        public static void set(Node node, String property, Object value) {
                try {
-                       if (!node.hasProperty(property))
-                               throw new IllegalArgumentException("No property " + property + " in " + node);
+                       if (!node.hasProperty(property)) {
+                               if (value != null)
+                                       node.setProperty(property, value.toString());
+                               return;
+                               // throw new IllegalArgumentException("No property " + property + " in " +
+                               // node);
+                       }
                        Property prop = node.getProperty(property);
                        if (value == null) {
                                prop.remove();