perfsonar-dev - r1765 - branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType
Subject: perfsonar development work
List archive
r1765 - branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType
Chronological Thread
- From:
- To:
- Subject: r1765 - branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType
- Date: Fri, 17 Nov 2006 11:13:23 -0500
Author: yi
Date: 2006-11-17 11:13:22 -0500 (Fri, 17 Nov 2006)
New Revision: 1765
Modified:
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSSummary.java
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSTokenUtilities.java
Log:
external summary (XQuery Version) for BDB is also integrated into
LSTokenUtilities
Modified:
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSSummary.java
===================================================================
---
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSSummary.java
2006-11-15 21:18:06 UTC (rev 1764)
+++
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSSummary.java
2006-11-17 16:13:22 UTC (rev 1765)
@@ -202,9 +202,9 @@
// TODO: any better ways to read a query string from
a file?
query = "";
FileReader inputStream = new
FileReader(getSummaryXQuery());
- int c;
- while ((c = inputStream.read()) != -1)
- query += (char)c;
+ int ch;
+ while ((ch = inputStream.read()) != -1)
+ query += (char)ch;
inputStream.close();
edbres = (XmlDbResult)xmlStorageManager.fetch(query);
Modified:
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSTokenUtilities.java
===================================================================
---
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSTokenUtilities.java
2006-11-15 21:18:06 UTC (rev 1764)
+++
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSTokenUtilities.java
2006-11-17 16:13:22 UTC (rev 1765)
@@ -39,6 +39,7 @@
import org.apache.axis.message.SOAPBodyElement;
import org.w3c.dom.Document;
+import java.io.FileReader;
import java.io.IOException;
import java.io.File;
import java.util.ArrayList;
@@ -107,13 +108,19 @@
* name of property in config file
*/
private static final String LS_SUMMARY_STYLESHEET =
"component.ls_summary_loader.stylesheet_external";
-
+ private static final String LS_SUMMARY_XQUERY =
"component.ls_summary_loader.xquery_external";
+
/**
* location of summary sheet
*/
private String summarySheet = "";
+ /**
+ * location of summary XQuery
+ */
+ private String summaryXQuery = "";
+
public LSTokenUtilities(LoggerComponent logger, ConfigurationComponent
configuration,
LSUtilities lsUtil, String lsTokenInterval) throws SystemException {
@@ -157,7 +164,22 @@
// we need to throw an error or something...
}
logger.debug("LSSummary: LS XSLT=" + getSummarySheet());
-
+
+ temp = null;
+ try {
+ temp = configuration.getProperty(LS_SUMMARY_XQUERY);
+ }
+ catch (SystemException e) {
+ temp = null;
+ }
+
+ if(temp != null) {
+ setSummaryXQuery(temp);
+ }
+ else {
+ // we need to throw an error or something...
+ }
+ logger.debug("LSSummary: LS XQuery=" + getSummaryXQuery());
}
@@ -194,7 +216,22 @@
return summarySheet;
}
+ /**
+ * Set the value of the summary XQuery
+ */
+ public void setSummaryXQuery(String newSummaryXQuery) {
+ summaryXQuery = newSummaryXQuery;
+ return;
+ }
+
+ /**
+ * get the value of the summary XQuery
+ */
+ public String getSummaryXQuery() {
+ return summaryXQuery;
+ }
+
public Message sendRequest(String endPoint,
org.ggf.ns.nmwg.base.v2_0.Message requestDocument)
throws Exception {
try {
@@ -824,9 +861,23 @@
results = (String[])edbres.getResultAsStringArray();
}
else if(xmlStorageManager instanceof BerkeleyDbXmlStorageManager) {
- query = XQUERY_UPDATE_DECLARE + "data(collection(\"" +
LS_CACHE_CONTAINER + "\"))";
- edbres = (XmlDbResult)xmlStorageManager.fetch(query);
- results = (String[])edbres.getResultAsStringArray();
+ logger.debug("LSTokenUtilities: XQuery Starting...");
+
+ try {
+ // TODO: any better ways to read a query string from
a file?
+ query = "";
+ FileReader inputStream = new
FileReader(getSummaryXQuery());
+ int ch;
+ while ((ch = inputStream.read()) != -1)
+ query += (char)ch;
+ inputStream.close();
+
+ edbres = (XmlDbResult)xmlStorageManager.fetch(query);
+ results = (String[])edbres.getResultAsStringArray();
+ }
+ catch(Exception err) {
+ logger.error("LSTokenUtilities: Caught XQuery Processing
Error");
+ }
}
else {
throw new SystemException("error.common.storage.xmldb.query",
"No database exists");
@@ -835,22 +886,33 @@
//Make sure we got something (don't want to do this on an empty set)
if(results.length != 0 && results[0] != null) {
- logger.debug("LSTokenUtilities: XSLT Starting...");
try {
-
- //create a factory and transformer using the stylesheet
- TransformerFactory factory =
TransformerFactory.newInstance();
- Transformer transformer = factory.newTemplates(new
StreamSource(new File(getSummarySheet()))).newTransformer();
-
- //need a spot to store the output (temporarily)
- StringWriter sw = new StringWriter();
- transformer.transform(new StreamSource(new
StringReader(results[0])), new StreamResult(sw));
-
- output = sw.toString();
- }
- catch (Exception err) {
- logger.error("LSTokenUtilities: Caught XSLT Processing
Error");
- }
+ if(xmlStorageManager instanceof
ExistDbXmlrpcXmlStorageManager ||
+ xmlStorageManager instanceof
ExistDbHttpXmlStorageManager) {
+ logger.debug("LSTokenUtilities: XSLT
Starting...");
+
+ //create a factory and transformer using the
stylesheet
+ TransformerFactory factory =
TransformerFactory.newInstance();
+ Transformer transformer =
factory.newTemplates(new StreamSource(new
File(getSummarySheet()))).newTransformer();
+
+ //need a spot to store the output
(temporarily)
+ StringWriter sw = new StringWriter();
+ transformer.transform(new StreamSource(new
StringReader(results[0])), new StreamResult(sw));
+
+ output = sw.toString();
+ }
+ else if(xmlStorageManager instanceof
BerkeleyDbXmlStorageManager) {
+ // because in the summary query, all results
are wrapped by a root element
+ // so results[0] is all the results
+ output = results[0];
+ }
+ else {
+ throw new
SystemException("error.common.storage.xmldb.query", "No database exists");
+ }
+ }
+ catch(Exception err) {
+ logger.error("LSTokenUtilities: Caught XSLT Processing
Error");
+ }
//We essentually get back a string (but its really a message) so
// using a new XMLUtils function we can get this into NMWG format
- r1765 - branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType, svnlog, 11/17/2006
Archive powered by MHonArc 2.6.16.