Make JCR set more robust.
[lgpl/argeo-commons.git] / 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();