[Yanel-commits] rev 23608 - public/yanel/trunk/src/resources/add-realm/src/java/org/wyona/yanel/impl/resources

michi at wyona.com michi at wyona.com
Thu Apr 5 11:44:52 CEST 2007


Author: michi
Date: 2007-04-05 11:44:51 +0200 (Thu, 05 Apr 2007)
New Revision: 23608

Modified:
   public/yanel/trunk/src/resources/add-realm/src/java/org/wyona/yanel/impl/resources/AddRealmResource2.java
Log:
get parameter value via JDOM

Modified: public/yanel/trunk/src/resources/add-realm/src/java/org/wyona/yanel/impl/resources/AddRealmResource2.java
===================================================================
--- public/yanel/trunk/src/resources/add-realm/src/java/org/wyona/yanel/impl/resources/AddRealmResource2.java	2007-04-05 09:26:29 UTC (rev 23607)
+++ public/yanel/trunk/src/resources/add-realm/src/java/org/wyona/yanel/impl/resources/AddRealmResource2.java	2007-04-05 09:44:51 UTC (rev 23608)
@@ -168,7 +168,27 @@
     private Document getFromScratchInputDocument() {
         Document doc = getDocument();
         Element rootElement = doc.getDocumentElement();
-        rootElement.appendChild(doc.createElementNS(NAMESPACE, "from-scratch"));
+        Element fromScratchElement = (Element) rootElement.appendChild(doc.createElementNS(NAMESPACE, "from-scratch"));
+        Element parameterElement = (Element) fromScratchElement.appendChild(doc.createElementNS(NAMESPACE, "parameter"));
+        parameterElement.setAttributeNS(NAMESPACE, "sample-value", getParameter());
         return doc;
     }
+
+    /**
+     * Get parameter from custom configuration
+     */
+    private String getParameter() {
+        try {
+            org.jdom.Document jdomDocument = new org.jdom.input.DOMBuilder().build(getConfiguration().getCustomConfiguration());
+
+            org.jdom.xpath.XPath xpath = org.jdom.xpath.XPath.newInstance("/yanel:custom-config/arr:parameter[@name='realmid']/@samplevalue");
+            xpath.addNamespace("yanel", "http://www.wyona.org/yanel/rti/1.0");
+	    xpath.addNamespace("arr", "http://www.wyona.org/yanel/resource/add-realm-resource/1.0");
+
+            org.jdom.Attribute sampleValue = (org.jdom.Attribute) xpath.selectSingleNode(jdomDocument);
+            return sampleValue.getValue();
+        } catch (Exception e) {
+            return null;
+        }
+    }
 }




More information about the Yanel-commits mailing list