Make JcrUtils.get() return null for missing property
authorMathieu Baudier <mbaudier@argeo.org>
Tue, 29 May 2012 15:12:43 +0000 (15:12 +0000)
committerMathieu Baudier <mbaudier@argeo.org>
Tue, 29 May 2012 15:12:43 +0000 (15:12 +0000)
git-svn-id: https://svn.argeo.org/commons/trunk@5317 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

server/runtime/org.argeo.server.jcr/src/main/java/org/argeo/jcr/JcrUtils.java

index 4c0cbf39ddb351045b065402043ed9813ecd3bb0..e7b3656cfd8e5e7e195a873924f65b92c95eefcb 100644 (file)
@@ -307,9 +307,14 @@ public class JcrUtils implements ArgeoJcrConstants {
         * PROPERTIES
         */
 
-       /** Concisely get the string value of a property */
+       /**
+        * Concisely get the string value of a property or null if this node doesn't
+        * have this property
+        */
        public static String get(Node node, String propertyName) {
                try {
+                       if (!node.hasProperty(propertyName))
+                               return null;
                        return node.getProperty(propertyName).getString();
                } catch (RepositoryException e) {
                        throw new ArgeoException("Cannot get property " + propertyName