Introduce get node name quietly
authorMathieu Baudier <mbaudier@argeo.org>
Wed, 31 Oct 2012 14:41:18 +0000 (14:41 +0000)
committerMathieu Baudier <mbaudier@argeo.org>
Wed, 31 Oct 2012 14:41:18 +0000 (14:41 +0000)
git-svn-id: https://svn.argeo.org/commons/trunk@5684 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

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

index 442e70d777577aa19403064f6f8b1780f7ad3696..6f5765ed5c9672c1cdf12909613a069db73a4803 100644 (file)
@@ -286,6 +286,30 @@ public class JcrUtils implements ArgeoJcrConstants {
                return path.substring(index + 1);
        }
 
+       /**
+        * Call {@link Node#getName()} without exceptions (useful in super
+        * constructors).
+        */
+       public static String getNameQuietly(Node node) {
+               try {
+                       return node.getName();
+               } catch (RepositoryException e) {
+                       throw new ArgeoException("Cannot get name from " + node, e);
+               }
+       }
+
+       /**
+        * Call {@link Node#getProperty(String)} without exceptions (useful in super
+        * constructors).
+        */
+       public static String getStringPropertyQuietly(Node node, String propertyName) {
+               try {
+                       return node.getProperty(propertyName).getString();
+               } catch (RepositoryException e) {
+                       throw new ArgeoException("Cannot get name from " + node, e);
+               }
+       }
+
        /**
         * Routine that get the child with this name, adding id it does not already
         * exist