projects
/
lgpl
/
argeo-commons.git
/ commitdiff
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
f4b95d1
)
Retrieve directly the XML value of a node.
author
Mathieu Baudier <mbaudier@argeo.org>
Tue, 6 Jul 2021 10:00:43 +0000
(12:00 +0200)
committer
Mathieu Baudier <mbaudier@argeo.org>
Tue, 6 Jul 2021 10:00:43 +0000
(12:00 +0200)
org.argeo.jcr/src/org/argeo/jcr/JcrxApi.java
patch
|
blob
|
history
diff --git
a/org.argeo.jcr/src/org/argeo/jcr/JcrxApi.java
b/org.argeo.jcr/src/org/argeo/jcr/JcrxApi.java
index 8f1ee9fa9a4f67752dd1661c460f08cb662b72d3..666b2593e5992dbb980f8e12e43c194fddb1f5c4 100644
(file)
--- a/
org.argeo.jcr/src/org/argeo/jcr/JcrxApi.java
+++ b/
org.argeo.jcr/src/org/argeo/jcr/JcrxApi.java
@@
-30,22
+30,33
@@
public class JcrxApi {
* XML
*/
/**
* XML
*/
/**
- *
Set as a subnode which will be exported as an XML element
.
+ *
Get the XML text of this child node
.
*/
public static String getXmlValue(Node node, String name) {
try {
if (!node.hasNode(name))
return null;
Node child = node.getNode(name);
*/
public static String getXmlValue(Node node, String name) {
try {
if (!node.hasNode(name))
return null;
Node child = node.getNode(name);
- if (!child.hasNode(Jcr.JCR_XMLTEXT))
+ return getXmlValue(child);
+ } catch (RepositoryException e) {
+ throw new IllegalStateException("Cannot get " + name + " as XML text", e);
+ }
+ }
+
+ /**
+ * Get the XML text of this node.
+ */
+ public static String getXmlValue(Node node) {
+ try {
+ if (!node.hasNode(Jcr.JCR_XMLTEXT))
return null;
return null;
- Node xmlText =
child
.getNode(Jcr.JCR_XMLTEXT);
+ Node xmlText =
node
.getNode(Jcr.JCR_XMLTEXT);
if (!xmlText.hasProperty(Jcr.JCR_XMLCHARACTERS))
throw new IllegalArgumentException(
"Node " + xmlText + " has no " + Jcr.JCR_XMLCHARACTERS + " property");
return xmlText.getProperty(Jcr.JCR_XMLCHARACTERS).getString();
} catch (RepositoryException e) {
if (!xmlText.hasProperty(Jcr.JCR_XMLCHARACTERS))
throw new IllegalArgumentException(
"Node " + xmlText + " has no " + Jcr.JCR_XMLCHARACTERS + " property");
return xmlText.getProperty(Jcr.JCR_XMLCHARACTERS).getString();
} catch (RepositoryException e) {
- throw new IllegalStateException("Cannot get " + n
am
e + " as XML text", e);
+ throw new IllegalStateException("Cannot get " + n
od
e + " as XML text", e);
}
}
}
}