perfsonar-dev - perfsonar: r5267 - in trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient: lsinfo xml
Subject: perfsonar development work
List archive
perfsonar: r5267 - in trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient: lsinfo xml
Chronological Thread
- From:
- To:
- Subject: perfsonar: r5267 - in trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient: lsinfo xml
- Date: Wed, 26 Aug 2009 10:25:55 -0400
Author: krzjed
Date: 2009-08-26 10:25:55 -0400 (Wed, 26 Aug 2009)
New Revision: 5267
Modified:
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/lsinfo/Namespaces.java
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/xml/ResponseParser.java
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/xml/ServiceMeasurementMetadataSAXHandler.java
Log:
Detection of error information in response added
Modified:
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/lsinfo/Namespaces.java
===================================================================
---
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/lsinfo/Namespaces.java
2009-08-26 08:04:05 UTC (rev 5266)
+++
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/lsinfo/Namespaces.java
2009-08-26 14:25:55 UTC (rev 5267)
@@ -9,6 +9,7 @@
public class Namespaces {
public static final String PERFSONAR =
"http://ggf.org/ns/nmwg/tools/org/perfsonar/1.0/";
public static final String NMWG = "http://ggf.org/ns/nmwg/base/2.0/";
+ public static final String NMWGR = "http://ggf.org/ns/nmwg/result/2.0/";
public static final String PSSERVICE =
"http://ggf.org/ns/nmwg/tools/org/perfsonar/service/1.0/";
public static final String NMWGT =
"http://ggf.org/ns/nmwg/topology/2.0/";
public static final String NETUTIL =
"http://ggf.org/ns/nmwg/characteristic/utilization/2.0/";
Modified:
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/xml/ResponseParser.java
===================================================================
---
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/xml/ResponseParser.java
2009-08-26 08:04:05 UTC (rev 5266)
+++
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/xml/ResponseParser.java
2009-08-26 14:25:55 UTC (rev 5267)
@@ -7,6 +7,7 @@
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
+import org.perfsonar.lsclient.LsQueryException;
import org.perfsonar.lsclient.data.ServiceMeasurementMetadata;
import org.perfsonar.ri.lsclient.handlers.ServiceMeasurementMetadataHandler;
import org.perfsonar.ri.lsclient.level1.LSMeasuredTopologyQuery;
@@ -32,17 +33,29 @@
* Sax problems
* @throws SAXException
* Sax problems
+ * @throws LsQueryException
+ * when problems with executing query occurs
* @throws IOException
* Connection to LS problems
*/
public static void parseServiceMeasurementMetadata(InputStream is,
ServiceMeasurementMetadataHandler metadataHandler)
- throws ParserConfigurationException, SAXException, IOException {
- SAXParserFactory saxFact = SAXParserFactory.newInstance();
- saxFact.setNamespaceAware(true);
- SAXParser sax = saxFact.newSAXParser();
- ServiceMeasurementMetadataSAXHandler handler = new
ServiceMeasurementMetadataSAXHandler(
- metadataHandler);
- sax.parse(is, handler);
+ throws ParserConfigurationException, SAXException, IOException,
+ LsQueryException {
+ try {
+ SAXParserFactory saxFact = SAXParserFactory.newInstance();
+ saxFact.setNamespaceAware(true);
+ SAXParser sax = saxFact.newSAXParser();
+ ServiceMeasurementMetadataSAXHandler handler = new
ServiceMeasurementMetadataSAXHandler(
+ metadataHandler);
+ sax.parse(is, handler);
+ } catch (SAXException e) {
+ Exception embedded = e.getException();
+ if (embedded != null && embedded instanceof LsQueryException) {
+ throw (LsQueryException) embedded;
+ } else {
+ throw e;
+ }
+ }
}
}
Modified:
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/xml/ServiceMeasurementMetadataSAXHandler.java
===================================================================
---
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/xml/ServiceMeasurementMetadataSAXHandler.java
2009-08-26 08:04:05 UTC (rev 5266)
+++
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/xml/ServiceMeasurementMetadataSAXHandler.java
2009-08-26 14:25:55 UTC (rev 5267)
@@ -4,6 +4,7 @@
import java.util.HashMap;
import java.util.Map;
+import org.perfsonar.lsclient.LsQueryException;
import
org.perfsonar.ri.lsclient.data.implementation.ServiceMeasurementMetadataImpl;
import org.perfsonar.ri.lsclient.handlers.ServiceMeasurementMetadataHandler;
import org.perfsonar.ri.lsclient.lsinfo.Namespaces;
@@ -26,11 +27,21 @@
private boolean inDatum;
/**
- * processing is inside metadata tag inside datum tag
+ * Processing is inside datum tag inside metadata tag
*/
private boolean inMetadata;
/**
+ * Processing is inside result datum (nmwgr) tag
+ */
+ private boolean inResultDatum;
+
+ /**
+ * Message in nmwgr:datum tag
+ */
+ private String resultMessage;
+
+ /**
* Mapping of namespaces outside metadata tag
*/
private Map<String, String> globalMapping = new HashMap<String,
String>();
@@ -66,6 +77,8 @@
throws SAXException {
if (this.inMetadata) {
this.builder.append(ch, start, length);
+ } else if (this.inResultDatum) {
+ this.resultMessage = new String(ch, start, length);
}
}
@@ -96,6 +109,12 @@
if (uri.equals(Namespaces.PSSERVICE) &&
localName.equals("datum")) {
this.inDatum = false;
}
+ } else if (this.inResultDatum) {
+ if (uri.equals(Namespaces.NMWGR) && localName.equals("datum")) {
+ LsQueryException exception = new LsQueryException(
+ "Error occured: " + this.resultMessage);
+ throw new SAXException(exception);
+ }
}
}
@@ -111,6 +130,9 @@
if (!this.inDatum) {
if (uri.equals(Namespaces.PSSERVICE) &&
localName.equals("datum")) {
this.inDatum = true;
+ } else if (uri.equals(Namespaces.NMWGR)
+ && localName.equals("datum")) {
+ this.inResultDatum = true;
}
} else if (!this.inMetadata) {
datumStartElement(uri, localName, name, attributes);
- perfsonar: r5267 - in trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient: lsinfo xml, svnlog, 08/26/2009
Archive powered by MHonArc 2.6.16.