From ad29722a3ece42252d6adcf5812f0a59bb084622 Mon Sep 17 00:00:00 2001 From: Mathieu Baudier Date: Wed, 31 Oct 2012 14:41:18 +0000 Subject: [PATCH] Introduce get node name quietly git-svn-id: https://svn.argeo.org/commons/trunk@5684 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc --- .../src/main/java/org/argeo/jcr/JcrUtils.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/server/runtime/org.argeo.server.jcr/src/main/java/org/argeo/jcr/JcrUtils.java b/server/runtime/org.argeo.server.jcr/src/main/java/org/argeo/jcr/JcrUtils.java index 442e70d77..6f5765ed5 100644 --- a/server/runtime/org.argeo.server.jcr/src/main/java/org/argeo/jcr/JcrUtils.java +++ b/server/runtime/org.argeo.server.jcr/src/main/java/org/argeo/jcr/JcrUtils.java @@ -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 -- 2.30.2