perfsonar-dev - perfsonar: r4120 - in trunk/perfsonar_base/src/main/java/org/perfsonar: base/util service/measurementArchive/metadataConfig
Subject: perfsonar development work
List archive
perfsonar: r4120 - in trunk/perfsonar_base/src/main/java/org/perfsonar: base/util service/measurementArchive/metadataConfig
Chronological Thread
- From:
- To:
- Subject: perfsonar: r4120 - in trunk/perfsonar_base/src/main/java/org/perfsonar: base/util service/measurementArchive/metadataConfig
- Date: Fri, 4 Jul 2008 10:59:08 -0400
Author: roman
Date: 2008-07-04 10:59:08 -0400 (Fri, 04 Jul 2008)
New Revision: 4120
Modified:
trunk/perfsonar_base/src/main/java/org/perfsonar/base/util/XMLUtils.java
trunk/perfsonar_base/src/main/java/org/perfsonar/service/measurementArchive/metadataConfig/MetadataConfigurationStorageManager.java
Log:
Parsing from String to DOM document added.
Modified:
trunk/perfsonar_base/src/main/java/org/perfsonar/base/util/XMLUtils.java
===================================================================
--- trunk/perfsonar_base/src/main/java/org/perfsonar/base/util/XMLUtils.java
2008-07-04 14:57:28 UTC (rev 4119)
+++ trunk/perfsonar_base/src/main/java/org/perfsonar/base/util/XMLUtils.java
2008-07-04 14:59:08 UTC (rev 4120)
@@ -142,7 +142,7 @@
*/
public static Document convertMessageToDOM(Message m)
throws PerfSONARException{
-
+
try {
DocumentBuilder builder =
DocumentBuilderFactory.newInstance().newDocumentBuilder();
@@ -151,15 +151,36 @@
if (builtDoc==null) throw new NullPointerException();
else return builtDoc;
-
+
} catch (Exception e) {
throw new PerfSONARException(
"error.common.parse_error",
"Cannot convert Message to DOM");
}
-
+
}
-
+
+
+ public static Document convertMessageToDOM(String m)
+ throws PerfSONARException{
+
+ try {
+ java.io.InputStream stream = new
ByteArrayInputStream(m.getBytes());
+ DocumentBuilderFactory factory =
DocumentBuilderFactory.newInstance();
+ factory.setNamespaceAware(true);
+ DocumentBuilder builder = factory.newDocumentBuilder();
+ Document doc = builder.parse(stream);
+ return doc;
+
+ } catch (Exception e) {
+ throw new PerfSONARException(
+ "error.common.parse_error",
+ "Cannot convert Message string to DOM");
+ }
+
+ }
+
+
/**
* Converts Document containing message into NMWG Message object
* @param request - message Document
Modified:
trunk/perfsonar_base/src/main/java/org/perfsonar/service/measurementArchive/metadataConfig/MetadataConfigurationStorageManager.java
===================================================================
---
trunk/perfsonar_base/src/main/java/org/perfsonar/service/measurementArchive/metadataConfig/MetadataConfigurationStorageManager.java
2008-07-04 14:57:28 UTC (rev 4119)
+++
trunk/perfsonar_base/src/main/java/org/perfsonar/service/measurementArchive/metadataConfig/MetadataConfigurationStorageManager.java
2008-07-04 14:59:08 UTC (rev 4120)
@@ -79,22 +79,8 @@
Message message = new Message();
- String query = transformations.getMetadataQuery(dataQuery);
+ String[] xmlResults = fetchXmlStorage(dataQuery);
- logger.debug("MetadataConfigurationStorageManager.fetch: "
- + "xquery to fetch metadata/data from the metadata
configuration: \n"
- + query);
-
-
- // if query is an empty string then the method returns empty message
- if (query.trim().equals(""))
- throw new PerfSONARException(
- "error.ma.query",
- "MetadataConfigurationStorageManager.fetch: "
- + "Empty query to get data from the metadata
configuration");
-
- String[] xmlResults = executeQuery(query);
-
if (xmlResults == null)
throw new PerfSONARException(
"error.ma",
@@ -144,7 +130,6 @@
+ "No metadata or data elements in the fetch result "
+ "sent from xml database");
-
Collection<Element> collection = elements.values();
for (Element elem : collection) {
message.addChild(elem);
@@ -156,6 +141,25 @@
}
+ public String[] fetchXmlStorage(Message dataQuery) throws
PerfSONARException {
+
+ String query = transformations.getMetadataQuery(dataQuery);
+
+ logger.debug("MetadataConfigurationStorageManager.fetchXmlStorage: "
+ + "xquery to fetch metadata/data from the metadata
configuration: \n"
+ + query);
+
+ // if query is an empty string then the method returns empty message
+ if (query.trim().equals(""))
+ throw new PerfSONARException(
+ "error.ma.query",
+ "MetadataConfigurationStorageManager.fetchXmlStorage: "
+ + "Empty query to get data from the metadata
configuration");
+
+ return executeQuery(query);
+ }
+
+
public Message store(Message dataSet) throws PerfSONARException {
if (dataSet.getMetadataMap().size() > 1)
- perfsonar: r4120 - in trunk/perfsonar_base/src/main/java/org/perfsonar: base/util service/measurementArchive/metadataConfig, svnlog, 07/04/2008
Archive powered by MHonArc 2.6.16.