perfsonar-dev - perfsonar: r5357 - in branches/new-structure-with-base2/ps-mdm-ls/src/main: java/org/perfsonar/service/lookupservice/servlets java/org/perfsonar/service/lookupservice/storage/exist resources/perfsonar/conf
Subject: perfsonar development work
List archive
perfsonar: r5357 - in branches/new-structure-with-base2/ps-mdm-ls/src/main: java/org/perfsonar/service/lookupservice/servlets java/org/perfsonar/service/lookupservice/storage/exist resources/perfsonar/conf
Chronological Thread
- From:
- To:
- Subject: perfsonar: r5357 - in branches/new-structure-with-base2/ps-mdm-ls/src/main: java/org/perfsonar/service/lookupservice/servlets java/org/perfsonar/service/lookupservice/storage/exist resources/perfsonar/conf
- Date: Wed, 25 Nov 2009 06:41:14 -0500
Author: trzaszcz
Date: 2009-11-25 06:41:14 -0500 (Wed, 25 Nov 2009)
New Revision: 5357
Modified:
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/servlets/ExistDbInitializerServlet.java
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/storage/exist/ExistXmlDb.java
branches/new-structure-with-base2/ps-mdm-ls/src/main/resources/perfsonar/conf/configuration.xml
Log:
refactoring
Modified:
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/servlets/ExistDbInitializerServlet.java
===================================================================
---
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/servlets/ExistDbInitializerServlet.java
2009-11-25 11:02:32 UTC (rev 5356)
+++
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/servlets/ExistDbInitializerServlet.java
2009-11-25 11:41:14 UTC (rev 5357)
@@ -68,8 +68,7 @@
XMLDBComponent existRODbComponent = (XMLDBComponent)
configManager
.getConfiguration().getAuxiliaryComponent("exist-ro");
- String dbUrl =
existDbComponent.getUri().replace("rest", "xmlrpc")
- .replace("http",
"xmldb:exist").replace("/ls", "");
+ String dbUrl =
existDbComponent.getUri().replace("http", "xmldb:exist").concat("/xmlrpc/db");
DatabaseManager.registerDatabase(database);
Collection collection =
DatabaseManager.getCollection(dbUrl,
Modified:
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/storage/exist/ExistXmlDb.java
===================================================================
---
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/storage/exist/ExistXmlDb.java
2009-11-25 11:02:32 UTC (rev 5356)
+++
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/storage/exist/ExistXmlDb.java
2009-11-25 11:41:14 UTC (rev 5357)
@@ -8,7 +8,9 @@
import javax.xml.stream.XMLStreamException;
import javax.xml.transform.OutputKeys;
+import org.perfsonar.base2.service.configuration.ConfigurationManager;
import org.perfsonar.base2.service.exceptions.PerfSONARException;
+import org.perfsonar.base2.service.storage.xml.XMLDBComponent;
import org.perfsonar.base2.service.storage.xml.XMLDBResult;
import org.perfsonar.base2.xml.ConfigurationStaxParser;
import org.perfsonar.base2.xml.Element;
@@ -21,9 +23,15 @@
import org.xmldb.api.base.ResourceSet;
import org.xmldb.api.base.XMLDBException;
import org.xmldb.api.modules.XPathQueryService;
-
+/**
+ *
+ * Provide access to existDb
+ *
+ *
+ * @author Slawomir Trzaszczka
+ *
+ */
public class ExistXmlDb {
- protected static String URI =
"xmldb:exist://localhost:8080/exist/xmlrpc";
private static XPathQueryService service;
@@ -33,11 +41,15 @@
// initialize database driver
Class cl;
try {
+ XMLDBComponent
xmlDb=(XMLDBComponent)ConfigurationManager.getInstance().getConfiguration().getAuxiliaryComponent("exist");
+ String URI = xmlDb.getUri().replace("http",
"xmldb:exist").concat("/xmlrpc");
+
cl = Class.forName(driver);
Database database = (Database) cl.newInstance();
DatabaseManager.registerDatabase(database);
// get the collection
+
Collection col = DatabaseManager.getCollection(URI
+"/db/ls","admin","");
col.setProperty(OutputKeys.INDENT, "no");
XPathQueryService service =
@@ -58,6 +70,8 @@
} catch (XMLDBException e) {
// TODO Auto-generated catch block
e.printStackTrace();
+ } catch (PerfSONARException e) {
+ e.printStackTrace();
}
}
@@ -68,14 +82,8 @@
return service;
}
- public static void setService(XPathQueryService service) {
- ExistXmlDb.service = service;
- }
-
public static synchronized void uploadStoreFile(String name, String
content) {
-// long id = Thread.currentThread().getId();
try {
-// System.out.println("S1 :" + id);
Collection col = DatabaseManager
.getCollection(
"xmldb:exist://localhost:8080/exist/xmlrpc/db/ls/store",
@@ -83,7 +91,6 @@
Resource res = col.createResource(name,
"XMLResource");
res.setContent(content);
col.storeResource(res);
-// System.out.println("E1 :" + id);
} catch (XMLDBException e) {
e.printStackTrace();
}
@@ -107,12 +114,6 @@
public static synchronized XMLDBResult performXQuery(String xquery)
throws PerfSONARException {
-// long id = Thread.currentThread().getId();
-// System.out.println("S2 *:" + id);
-// System.out.println("query:");
-// System.out.println("---------------------");
-// System.out.println(xquery);
-// System.out.println("---------------------");
XPathQueryService service = ExistXmlDb.getService();
try {
@@ -138,7 +139,6 @@
}
sb.append("</exist>");
String existResult = sb.toString();
-// System.out.println("E2 *:" + id);
if (existResult == null ||
existResult.isEmpty()) {
return new XMLDBResult(new
HashSet<Element>(), 0, 0, 0);
} else {
@@ -154,13 +154,6 @@
e.printStackTrace();
}
return null;
-
-
- // XMLDBResult res = getDataStorage().performXQuery(xquery,
- // getDataCollection(), getDataCredential());
- //
- // return res;
-
}
private static XMLDBResult parseExistXMLReponse(InputStream
inputStream,
@@ -179,8 +172,6 @@
} else
return null;
- // TODO: handle <exist:value>
-
}
}
Modified:
branches/new-structure-with-base2/ps-mdm-ls/src/main/resources/perfsonar/conf/configuration.xml
===================================================================
---
branches/new-structure-with-base2/ps-mdm-ls/src/main/resources/perfsonar/conf/configuration.xml
2009-11-25 11:02:32 UTC (rev 5356)
+++
branches/new-structure-with-base2/ps-mdm-ls/src/main/resources/perfsonar/conf/configuration.xml
2009-11-25 11:41:14 UTC (rev 5357)
@@ -77,7 +77,7 @@
className="org.perfsonar.base2.service.storage.xml.XMLDBComponent">
<option name="dataStorageClassName"
value="org.perfsonar.base2.service.storage.xml.exist.ExistHTTPDataStorage"/>
- <option name="uri"
value="http://localhost:8080/exist/rest/db/ls"/>
+ <option name="uri" value="http://localhost:8080/exist/"/>
<option name="username" value="lookupservice"/>
<option name="password" value="sonar"/>
</component>
@@ -88,7 +88,7 @@
className="org.perfsonar.base2.service.storage.xml.XMLDBComponent">
<option name="dataStorageClassName"
value="org.perfsonar.base2.service.storage.xml.exist.ExistHTTPDataStorage"/>
- <option name="uri"
value="http://localhost:8080/exist/rest/db/ls"/>
+ <option name="uri" value="http://localhost:8080/exist"/>
<option name="username" value="guest"/>
<option name="password" value="guest"/>
</component>
- perfsonar: r5357 - in branches/new-structure-with-base2/ps-mdm-ls/src/main: java/org/perfsonar/service/lookupservice/servlets java/org/perfsonar/service/lookupservice/storage/exist resources/perfsonar/conf, svnlog, 11/25/2009
Archive powered by MHonArc 2.6.16.