perfsonar-dev - perfsonar: r2620 - in branches/perfsonarui/src/org/perfsonar/perfsonarui: . ippm ls ma playground test/ma
Subject: perfsonar development work
List archive
perfsonar: r2620 - in branches/perfsonarui/src/org/perfsonar/perfsonarui: . ippm ls ma playground test/ma
Chronological Thread
- From:
- To:
- Subject: perfsonar: r2620 - in branches/perfsonarui/src/org/perfsonar/perfsonarui: . ippm ls ma playground test/ma
- Date: Thu, 9 Aug 2007 13:34:49 -0400
Author: nina
Date: 2007-08-09 13:34:49 -0400 (Thu, 09 Aug 2007)
New Revision: 2620
Modified:
branches/perfsonarui/src/org/perfsonar/perfsonarui/AbstractMARequest.java
branches/perfsonarui/src/org/perfsonar/perfsonarui/DebugPerfsonarResponse.java
branches/perfsonarui/src/org/perfsonar/perfsonarui/MetadataListResponseListener.java
branches/perfsonarui/src/org/perfsonar/perfsonarui/PSLogger.java
branches/perfsonarui/src/org/perfsonar/perfsonarui/SmartMARequest.java
branches/perfsonarui/src/org/perfsonar/perfsonarui/ippm/IPPMRequest.java
branches/perfsonarui/src/org/perfsonar/perfsonarui/ls/LSRequest.java
branches/perfsonarui/src/org/perfsonar/perfsonarui/ma/MARequest.java
branches/perfsonarui/src/org/perfsonar/perfsonarui/playground/PlaygroundPerfsonarResponse.java
branches/perfsonarui/src/org/perfsonar/perfsonarui/playground/PlaygroundRequest.java
branches/perfsonarui/src/org/perfsonar/perfsonarui/test/ma/MARequest_ErrorsTest.java
Log:
Introduced static AbstractMARequest.document2String(Document) method and
updated relevant files to use it
Modified:
branches/perfsonarui/src/org/perfsonar/perfsonarui/AbstractMARequest.java
===================================================================
--- branches/perfsonarui/src/org/perfsonar/perfsonarui/AbstractMARequest.java
2007-08-09 17:33:37 UTC (rev 2619)
+++ branches/perfsonarui/src/org/perfsonar/perfsonarui/AbstractMARequest.java
2007-08-09 17:34:49 UTC (rev 2620)
@@ -22,6 +22,7 @@
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
+import java.io.IOException;
import java.io.StringReader;
import java.io.StringWriter;
import java.net.URL;
@@ -33,6 +34,11 @@
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.rpc.ServiceException;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
@@ -51,7 +57,10 @@
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
+import com.sun.org.apache.xml.internal.serialize.OutputFormat;
+import com.sun.org.apache.xml.internal.serialize.XMLSerializer;
+
/**
* Default implementation of
{@link
IPerfsonarRequest}. Descendant classes have to implement
{@link
#createRequest(IUserData, String)}
* and
{@link
#createRequest(MAEndpoint, MetaDataList, String)} in order to generate the
actual XML messages from
{@link
IUserData} and
{@link
MetaDataList}.
@@ -384,6 +393,34 @@
public synchronized boolean isInterrupted() {
return interrupted;
}
+
+ public static String document2string(Document doc) throws Exception {
+ try {
+ StringWriter out = new StringWriter();
+ DOMSource domSource = new DOMSource(doc);
+ StreamResult streamResult = new StreamResult(out);
+ TransformerFactory tf = TransformerFactory.newInstance();
+ Transformer serializer = tf.newTransformer();
+
serializer.setOutputProperty(OutputKeys.ENCODING,"ISO-8859-1");
+ serializer.setOutputProperty(OutputKeys.INDENT,"yes");
+ serializer.transform(domSource, streamResult);
+ return out.toString();
+ } catch (Throwable x) {
+ return x.toString();
+ }
+
+ /*
+ StringWriter outWriter = new StringWriter();
+ OutputFormat format = new OutputFormat(doc);
+ format.setLineWidth(65);
+ format.setIndenting(true);
+ format.setIndent(2);
+
+ XMLSerializer output = new XMLSerializer(outWriter, format);
+ output.serialize(doc);
+ return outWriter.toString();
+ */
+ }
}
Modified:
branches/perfsonarui/src/org/perfsonar/perfsonarui/DebugPerfsonarResponse.java
===================================================================
---
branches/perfsonarui/src/org/perfsonar/perfsonarui/DebugPerfsonarResponse.java
2007-08-09 17:33:37 UTC (rev 2619)
+++
branches/perfsonarui/src/org/perfsonar/perfsonarui/DebugPerfsonarResponse.java
2007-08-09 17:34:49 UTC (rev 2620)
@@ -19,16 +19,11 @@
*/
package org.perfsonar.perfsonarui;
-import java.io.StringWriter;
-
import org.perfsonar.perfsonarui.plugins.IPerfsonarRequest;
import org.perfsonar.perfsonarui.plugins.IPerfsonarResponse;
import org.perfsonar.perfsonarui.plugins.IUserData;
import org.w3c.dom.Document;
-import com.sun.org.apache.xml.internal.serialize.OutputFormat;
-import com.sun.org.apache.xml.internal.serialize.XMLSerializer;
-
/**
* An implementation of
{@link
IPerfsonarResponse} that only does logging.
* @author Nina Jeliazkova
@@ -42,17 +37,8 @@
}
public void process(IUserData uData,Document response) throws
Exception {
- StringWriter sw = new StringWriter();
- OutputFormat format = new OutputFormat(response);
- format.setLineWidth(65);
- format.setIndenting(true);
- format.setIndent(2);
+ logger.debug(AbstractMARequest.document2string(response));
- XMLSerializer output = new XMLSerializer(sw, format);
- output.serialize(response);
-
- logger.debug(sw.toString());
-
}
@Override
Modified:
branches/perfsonarui/src/org/perfsonar/perfsonarui/MetadataListResponseListener.java
===================================================================
---
branches/perfsonarui/src/org/perfsonar/perfsonarui/MetadataListResponseListener.java
2007-08-09 17:33:37 UTC (rev 2619)
+++
branches/perfsonarui/src/org/perfsonar/perfsonarui/MetadataListResponseListener.java
2007-08-09 17:34:49 UTC (rev 2620)
@@ -51,7 +51,7 @@
@Override
public void process(IPerfsonarRequest request, IUserData uData,
Document response) throws Exception {
- super.process(request, uData, response);
+ //super.process(request, uData, response);
dataList.setNotificationEnabled(false);
try {
request.process(uData, response, this);
Modified: branches/perfsonarui/src/org/perfsonar/perfsonarui/PSLogger.java
===================================================================
--- branches/perfsonarui/src/org/perfsonar/perfsonarui/PSLogger.java
2007-08-09 17:33:37 UTC (rev 2619)
+++ branches/perfsonarui/src/org/perfsonar/perfsonarui/PSLogger.java
2007-08-09 17:34:49 UTC (rev 2620)
@@ -22,11 +22,14 @@
import java.io.PrintWriter;
import java.io.StringWriter;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
import org.w3c.dom.Document;
-import com.sun.org.apache.xml.internal.serialize.OutputFormat;
-import com.sun.org.apache.xml.internal.serialize.XMLSerializer;
-
/**
* Logging facility.
* @author Nina Jeliazkova
@@ -194,6 +197,7 @@
}
}
private void debugDocument(Document doc) {
+ /*
try {
StringWriter outWriter = new StringWriter();
OutputFormat format = new OutputFormat(doc);
@@ -204,9 +208,23 @@
XMLSerializer output = new XMLSerializer(outWriter, format);
output.serialize(doc);
log4jLogger.debug(outWriter.toString());
- } catch (Exception x) {
- x.printStackTrace();
+ } catch (Throwable x) {
+ debugThrowable(x);
}
+ */
+ try {
+ StringWriter out = new StringWriter();
+ DOMSource domSource = new DOMSource(doc);
+ StreamResult streamResult = new StreamResult(out);
+ TransformerFactory tf = TransformerFactory.newInstance();
+ Transformer serializer = tf.newTransformer();
+
serializer.setOutputProperty(OutputKeys.ENCODING,"ISO-8859-1");
+ serializer.setOutputProperty(OutputKeys.INDENT,"yes");
+ serializer.transform(domSource, streamResult);
+ log4jLogger.debug(out.toString());
+ } catch (Throwable x) {
+ debugThrowable(x);
+ }
}
private void debugThrowable(Throwable problem) {
if (problem != null) {
Modified:
branches/perfsonarui/src/org/perfsonar/perfsonarui/SmartMARequest.java
===================================================================
--- branches/perfsonarui/src/org/perfsonar/perfsonarui/SmartMARequest.java
2007-08-09 17:33:37 UTC (rev 2619)
+++ branches/perfsonarui/src/org/perfsonar/perfsonarui/SmartMARequest.java
2007-08-09 17:34:49 UTC (rev 2620)
@@ -1,5 +1,5 @@
/*
-Copyright perfsonar.acad.bg (C) 2005-2007
+Copyright perfsonar.acad.bg (C) 2005-2007
Contact:
This program is free software; you can redistribute it and/or
@@ -36,9 +36,9 @@
/**
* An implementation of
{@link
IPerfsonarRequest} that understands different schema versions,
* based on the endpoint
{@link
MAEndpoint}.
- * The descendants should implement
{@link
#createMARequest(MAEndpoint)}
+ * The descendants should implement
{@link
#createMARequest(MAEndpoint)}
* and create specific
{@link
IPerfsonarRequest} based on
{@link
MAEndpoint#getSchema()} or based on another info.
- *
+ *
* <pre>
* SmartRequest request = new SmartRequest() {
public IPerfsonarRequest createMARequest(MAEndpoint
endpoint) {
@@ -48,10 +48,10 @@
else if (schema.equals("perfsonar")) return
new MARequest();
else return null;
}
- }
+ }
* </pre>
- *
+ *
* Maintains one
{@link
PerfsonarRequestsPool} per each schema.
* @author Nina Jeliazkova
*
@@ -63,12 +63,12 @@
Hashtable<IPerfsonarSchema, PerfsonarRequestsPool> requestsPool;
protected int MaxRequests = 16;
//PerfsonarRequestsPool[] requestsPool = null;
-
+
protected transient IUserData data = null;
-
+
public SmartMARequest() {
super();
-
+
propertyChangeListener = new AbstractPerfsonarResponse() {
/**
* return
{@link
IPerfsonarRequest} object if processing is already completed
@@ -81,14 +81,14 @@
if (countInitiated > 0)
firePropertyChange(new
BusyIdleEvent(this,BusyIdleEvent.PROPERTY_PERCENT,
null,new
Double(100*(countCompleted + countErrors)/countInitiated)
- ));
+ ));
/*
firePropertyChange(new
BusyIdleEvent(request,BusyIdleEvent.PROPERTY_BUSY,null,
new Boolean((countCompleted +
countErrors) < countInitiated)));
*/
firePropertyChange(new
BusyIdleEvent(request,BusyIdleEvent.PROPERTY_MESSAGE,
- "","Completed requests "+
Integer.toString(countCompleted)
- ));
+ "","Completed requests "+
Integer.toString(countCompleted)
+ ));
}
@Override
/**
@@ -112,8 +112,8 @@
));
firePropertyChange(new
BusyIdleEvent(this,BusyIdleEvent.PROPERTY_ERROR,
null,x
- ));
-
+ ));
+
}
/* (non-Javadoc)
* @see
org.perfsonar.perfsonarui.AbstractPerfsonarResponse#message(org.perfsonar.perfsonarui.IPerfsonarRequest,
java.lang.String)
@@ -148,7 +148,7 @@
for (int i=0; i < requestsPool.length;i++)
requestsPool[i] = new PerfsonarRequestsPool();
*/
-
+
}
public synchronized int isReady() {
@@ -174,20 +174,20 @@
public synchronized void setRequestsRunning(int requestsRunning) {
this.requestsRunning = requestsRunning;
notifyAll();
- }
+ }
protected synchronized void returnRequest(IPerfsonarRequest request) {
//request.removePropertyChangeListener(propertyChangeListener); already done
in the super class
-
+
request.removePropertyChangeListener(propertyChangeListener);
request.removePropertyChangeListeners();
Enumeration keys = requestsPool.keys();
- while (keys.hasMoreElements())
+ while (keys.hasMoreElements())
if
(requestsPool.get(keys.nextElement()).returnConnection(request))
break;
-
+
}
public abstract IPerfsonarRequest createMARequest(MAEndpoint
endpoint);
-
+
public IPerfsonarRequest getMARequest(MAEndpoint endpoint) {
try {
PerfsonarRequestsPool pool =
requestsPool.get(endpoint.getSchema());
@@ -209,15 +209,15 @@
};
if (request != null) {
-
+
request.removePropertyChangeListener(propertyChangeListener);
request.addPropertyChangeListener(propertyChangeListener);
-
-
- }
+
+
+ }
return request;
-
+
} catch (Exception x) {
logger.error(endpoint,x);
return null;
@@ -229,7 +229,7 @@
IPerfsonarRequest mr =
getMARequest(uData.getEndpoint());
if (mr != null) {
mr.makeRequest(uData, messageType, response,
parallel & runInThread);
- }
+ }
} catch (Exception x) {
fireAxisCallException(uData,x);
}
@@ -244,15 +244,15 @@
//Makes different nodes for each endpoint, in order to create
aggregated requests
for (int i=0; i < queryList.size();i++)
queryList.get(i).setResponse(IUserData.C_STATUS,
AbstractUserData.NULL_DATA);
-
+
List<MetaDataList> queries = new ArrayList<MetaDataList>();
Hashtable<String,MetaDataList> list = new
Hashtable<String,MetaDataList>();
for (int i=0; i < queryList.size();i++) {
IUserData data = (IUserData) queryList.get(i);
MAEndpoint e = data.getEndpoint();
-
-
-
+
+
+
MetaDataList d = (MetaDataList)list.get(e.toString());
if (d == null) {
d = new MetaDataList(null);
@@ -264,29 +264,29 @@
list.remove(e.toString());
}
}
-
+
for (int i=0; i < queries.size(); i++) {
MetaDataList d = queries.get(i);
IPerfsonarRequest mr =
getMARequest(d.get(0).getEndpoint());
if (mr != null) {
mr.makeRequest(d.get(0).getEndpoint(), d, messageType, response, parallel &
runInThread);
- }
+ }
}
-
-
+
+
Enumeration keys = list.keys();
while (keys.hasMoreElements()) {
MetaDataList d = list.get(keys.nextElement());
-
+
IPerfsonarRequest mr =
getMARequest(d.get(0).getEndpoint());
if (mr != null) {
mr.makeRequest(d.get(0).getEndpoint(), d, messageType, response, parallel &
runInThread);
- }
+ }
}
-
-
+
+
} catch (Exception x) {
logger.error(x);
fireAxisCallException(queryList,x);
@@ -311,7 +311,7 @@
// TODO Auto-generated method stub
return null;
}
-
+
/* (non-Javadoc)
* @see
org.perfsonar.perfsonarui.AbstractMARequest#createRequest(org.perfsonar.perfsonarui.IUserData,
org.perfsonar.perfsonarui.MetaDataList, java.lang.String)
*/
@@ -328,9 +328,9 @@
}
public void process(IUserData uData, Document response,
IPerfsonarResponse listener) throws Exception {
// TODO Auto-generated method stub
-
+
}
-
+
public synchronized AbstractPerfsonarResponse
getInternalPropertyChangeListener() {
return propertyChangeListener;
}
@@ -345,7 +345,7 @@
public synchronized void interrupt() {
//super.close();
Enumeration keys = requestsPool.keys();
- while (keys.hasMoreElements())
+ while (keys.hasMoreElements())
//for (int i=0; i < requestsPool.length;i++)
try {
//requestsPool[i].close();
@@ -365,9 +365,9 @@
firePropertyChange(new
BusyIdleEvent(this,BusyIdleEvent.PROPERTY_BUSY,null,
new Boolean(false)));
*/
-
+
}
-
+
/* (non-Javadoc)
* @see org.perfsonar.perfsonarui.AbstractMARequest#close()
*/
@@ -375,7 +375,7 @@
public synchronized void close() {
//super.close();
Enumeration keys = requestsPool.keys();
- while (keys.hasMoreElements())
+ while (keys.hasMoreElements())
//for (int i=0; i < requestsPool.length;i++)
try {
//requestsPool[i].close();
@@ -394,7 +394,7 @@
firePropertyChange(new
BusyIdleEvent(this,BusyIdleEvent.PROPERTY_BUSY,null,
new Boolean(false)));
*/
-
+
}
public String[] getNamespaces() {
// TODO Auto-generated method stub
@@ -408,10 +408,14 @@
public int getMaxRequests() {
return MaxRequests;
}
- public void setMaxRequests(int maxRequests) {
+ public void setMaxRequests(int maxRequests) {
+ if (maxRequests <= 0) maxRequests =1;
MaxRequests = maxRequests;
- System.out.println("Max " + maxRequests + " interfaces in one query
");
+
+ //System.out.println("Max " + maxRequests + " interfaces in one
query ");
+
}
+
public boolean isParallel() {
return parallel;
}
@@ -421,6 +425,6 @@
System.out.println("Requests will be sent in parallel");
else
System.out.println("Requests will be sent sequentially");
-
+
}
}
Modified:
branches/perfsonarui/src/org/perfsonar/perfsonarui/ippm/IPPMRequest.java
===================================================================
--- branches/perfsonarui/src/org/perfsonar/perfsonarui/ippm/IPPMRequest.java
2007-08-09 17:33:37 UTC (rev 2619)
+++ branches/perfsonarui/src/org/perfsonar/perfsonarui/ippm/IPPMRequest.java
2007-08-09 17:34:49 UTC (rev 2620)
@@ -21,7 +21,6 @@
import java.io.IOException;
import java.io.InputStream;
-import java.io.StringWriter;
import javax.swing.JOptionPane;
import javax.xml.parsers.DocumentBuilder;
@@ -47,9 +46,6 @@
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
-import com.sun.org.apache.xml.internal.serialize.OutputFormat;
-import com.sun.org.apache.xml.internal.serialize.XMLSerializer;
-
/**
* Request for IPPM services.
* @author Nina Jeliazkova
@@ -151,16 +147,8 @@
throw new Exception("CreateSetupDataRequest",x);
}
-
- StringWriter sw = new StringWriter();
- OutputFormat format = new OutputFormat(request);
- format.setLineWidth(65);
- format.setIndenting(true);
- format.setIndent(2);
- XMLSerializer output = new XMLSerializer(sw, format);
- output.serialize(request);
- logger.debug(sw.toString());
+ logger.debug(request);
return request;
@@ -365,18 +353,10 @@
//Now traversing org.w3c.dom.Document directly, without File i/o
to get jdom ...
fireStatusMessage(STATUS_PARSINGRESPONSE);
if (response != null) {
+
if (logger.isDebugEnabled()) try {
-
- StringWriter outWriter = new StringWriter();
- OutputFormat format = new
OutputFormat(dataSetupResp);
- format.setLineWidth(65);
- format.setIndenting(true);
- format.setIndent(2);
-
- XMLSerializer output = new
XMLSerializer(outWriter, format);
- output.serialize(dataSetupResp);
- logger.debug(outWriter.toString());
+ logger.debug(dataSetupResp);
} catch (Exception x) {
logger.error(x);
Modified: branches/perfsonarui/src/org/perfsonar/perfsonarui/ls/LSRequest.java
===================================================================
--- branches/perfsonarui/src/org/perfsonar/perfsonarui/ls/LSRequest.java
2007-08-09 17:33:37 UTC (rev 2619)
+++ branches/perfsonarui/src/org/perfsonar/perfsonarui/ls/LSRequest.java
2007-08-09 17:34:49 UTC (rev 2620)
@@ -25,7 +25,6 @@
package org.perfsonar.perfsonarui.ls;
import java.io.InputStream;
-import java.io.StringWriter;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
@@ -37,9 +36,6 @@
import org.perfsonar.perfsonarui.plugins.MetaDataList;
import org.w3c.dom.Document;
-import com.sun.org.apache.xml.internal.serialize.OutputFormat;
-import com.sun.org.apache.xml.internal.serialize.XMLSerializer;
-
public class LSRequest extends AbstractMARequest {
protected String resource;
public String getResource() {
@@ -80,15 +76,7 @@
}
- StringWriter sw = new StringWriter();
- OutputFormat format = new
OutputFormat(request);
- format.setLineWidth(65);
- format.setIndenting(true);
- format.setIndent(2);
-
- XMLSerializer output = new XMLSerializer(sw,
format);
- output.serialize(request);
- logger.debug(sw.toString());
+ logger.debug(request);
return request;
Modified: branches/perfsonarui/src/org/perfsonar/perfsonarui/ma/MARequest.java
===================================================================
--- branches/perfsonarui/src/org/perfsonar/perfsonarui/ma/MARequest.java
2007-08-09 17:33:37 UTC (rev 2619)
+++ branches/perfsonarui/src/org/perfsonar/perfsonarui/ma/MARequest.java
2007-08-09 17:34:49 UTC (rev 2620)
@@ -19,9 +19,6 @@
*/
package org.perfsonar.perfsonarui.ma;
-import java.io.IOException;
-import java.io.StringWriter;
-
import org.jdom.Element;
import org.jdom.Namespace;
import org.perfsonar.perfsonarui.AbstractMARequest;
@@ -40,9 +37,6 @@
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
-import com.sun.org.apache.xml.internal.serialize.OutputFormat;
-import com.sun.org.apache.xml.internal.serialize.XMLSerializer;
-
/**
* Sends request in "perfsonar" schema to Perfsonar Measurement Archive
services.
* @author Nina Jeliazkova
@@ -446,19 +440,8 @@
UserData userData = (UserData) uData;
//Now traversing org.w3c.dom.Document directly, without File i/o
to get jdom ...
if (logger.isDebugEnabled()) {
- try {
+ logger.debug(dataSetupResp);
- StringWriter outWriter = new StringWriter();
- OutputFormat format = new
OutputFormat(dataSetupResp);
- format.setLineWidth(65);
- format.setIndenting(true);
- format.setIndent(2);
-
- XMLSerializer output = new XMLSerializer(outWriter,
format);
- output.serialize(dataSetupResp);
- logger.debug(outWriter.toString());
-
- } catch (IOException x) { logger.error(x);}
}
Modified:
branches/perfsonarui/src/org/perfsonar/perfsonarui/playground/PlaygroundPerfsonarResponse.java
===================================================================
---
branches/perfsonarui/src/org/perfsonar/perfsonarui/playground/PlaygroundPerfsonarResponse.java
2007-08-09 17:33:37 UTC (rev 2619)
+++
branches/perfsonarui/src/org/perfsonar/perfsonarui/playground/PlaygroundPerfsonarResponse.java
2007-08-09 17:34:49 UTC (rev 2620)
@@ -20,8 +20,7 @@
package org.perfsonar.perfsonarui.playground;
-import java.io.StringWriter;
-
+import org.perfsonar.perfsonarui.AbstractMARequest;
import org.perfsonar.perfsonarui.AbstractPerfsonarResponse;
import org.perfsonar.perfsonarui.AbstractUserData;
import org.perfsonar.perfsonarui.PerfsonarResponseEvent;
@@ -29,9 +28,6 @@
import org.perfsonar.perfsonarui.plugins.IUserData;
import org.w3c.dom.Document;
-import com.sun.org.apache.xml.internal.serialize.OutputFormat;
-import com.sun.org.apache.xml.internal.serialize.XMLSerializer;
-
/**
* Response listener for
{@link
PlaygroundRequest}.
* Basically, sets
{@link
IUserData#setResponse}(AbstractUserData.DOCUMENT_RESPONSE} to the string
content of the XML response.
@@ -60,19 +56,9 @@
* to delegate processing to the request class itself.
*/
//uData.setResponse(response);
-
- StringWriter outWriter = new StringWriter();
- OutputFormat format = new OutputFormat(response);
- format.setLineWidth(65);
- format.setIndenting(true);
- format.setIndent(2);
- XMLSerializer output = new XMLSerializer(outWriter, format) ;
- output.serialize(response);
- System.out.println();
- System.out.println("Response received");
- uData.setResponse(AbstractUserData.DOCUMENT_RESPONSE,
outWriter.toString());
+ uData.setResponse(AbstractUserData.DOCUMENT_RESPONSE,
AbstractMARequest.document2string(response));
Modified:
branches/perfsonarui/src/org/perfsonar/perfsonarui/playground/PlaygroundRequest.java
===================================================================
---
branches/perfsonarui/src/org/perfsonar/perfsonarui/playground/PlaygroundRequest.java
2007-08-09 17:33:37 UTC (rev 2619)
+++
branches/perfsonarui/src/org/perfsonar/perfsonarui/playground/PlaygroundRequest.java
2007-08-09 17:34:49 UTC (rev 2620)
@@ -26,7 +26,6 @@
import java.io.IOException;
import java.io.StringReader;
-import java.io.StringWriter;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
@@ -40,9 +39,6 @@
import org.w3c.dom.Document;
import org.xml.sax.InputSource;
-import com.sun.org.apache.xml.internal.serialize.OutputFormat;
-import com.sun.org.apache.xml.internal.serialize.XMLSerializer;
-
/**
* To be used in
{@link
PerfsonarPlaygroundModel}.
* The XML document is not generated as in other
{@link
AbstractMARequest}
@@ -105,15 +101,7 @@
public void process(IUserData uData, Document response,
IPerfsonarResponse listener) throws Exception {
try {
- StringWriter outWriter = new StringWriter();
- OutputFormat format = new OutputFormat(response);
- format.setLineWidth(65);
- format.setIndenting(true);
- format.setIndent(2);
-
- XMLSerializer output = new XMLSerializer(outWriter,
format);
- output.serialize(response);
- uData.setResponse(AbstractUserData.DOCUMENT_RESPONSE,
outWriter.toString());
+ uData.setResponse(AbstractUserData.DOCUMENT_RESPONSE,
document2string(response));
} catch (IOException e) {
System.err.println(e);
}
Modified:
branches/perfsonarui/src/org/perfsonar/perfsonarui/test/ma/MARequest_ErrorsTest.java
===================================================================
---
branches/perfsonarui/src/org/perfsonar/perfsonarui/test/ma/MARequest_ErrorsTest.java
2007-08-09 17:33:37 UTC (rev 2619)
+++
branches/perfsonarui/src/org/perfsonar/perfsonarui/test/ma/MARequest_ErrorsTest.java
2007-08-09 17:34:49 UTC (rev 2620)
@@ -29,15 +29,14 @@
package org.perfsonar.perfsonarui.test.ma;
-import java.io.IOException;
import java.io.InputStream;
-import java.io.StringWriter;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import junit.framework.TestCase;
+import org.perfsonar.perfsonarui.AbstractMARequest;
import org.perfsonar.perfsonarui.AbstractUserData;
import org.perfsonar.perfsonarui.MetadataListResponseListener;
import org.perfsonar.perfsonarui.UserDataResponseListener;
@@ -47,12 +46,8 @@
import org.perfsonar.perfsonarui.plugins.IPerfsonarRequest;
import org.perfsonar.perfsonarui.plugins.MAEndpoint;
import org.perfsonar.perfsonarui.plugins.MetaDataList;
-import org.perfsonar.perfsonarui.plugins.PSErrorsDatum;
import org.w3c.dom.Document;
-import com.sun.org.apache.xml.internal.serialize.OutputFormat;
-import com.sun.org.apache.xml.internal.serialize.XMLSerializer;
-
public class MARequest_ErrorsTest extends TestCase {
protected MARequest_Errors ma_errors;
protected void setUp() throws Exception {
@@ -116,7 +111,7 @@
" <nmwg:data id=\"data_1\" metadataIdRef=\"meta1_1\"/>\n"+
"</nmwg:message>\n";
- assertEquals(request,document2string(doc));
+ assertEquals(request,AbstractMARequest.document2string(doc));
} catch (Exception x) {
fail(x.getMessage());
}
@@ -147,7 +142,7 @@
" <nmwg:data id=\"data_1\" metadataIdRef=\"meta1\"/>\n"+
"</nmwg:message>\n";
- assertEquals(request,document2string(doc));
+ assertEquals(request,AbstractMARequest.document2string(doc));
} catch (Exception x) {
fail(x.getMessage());
@@ -169,7 +164,7 @@
try {
Document doc = ma_errors.createRequest(uData,
IPerfsonarRequest.MA_SetupDataRequest);
- System.out.println(document2string(doc));
+ System.out.println(AbstractMARequest.document2string(doc));
String request = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"+
@@ -199,7 +194,7 @@
" </nmwg:metadata>\n"+
" <nmwg:data id=\"data_N/A\" metadataIdRef=\"m_param_N/A\"/>\n"+
"</nmwg:message>\n";
- assertEquals(request,document2string(doc));
+ assertEquals(request,AbstractMARequest.document2string(doc));
} catch (Exception x) {
fail(x.getMessage());
@@ -233,7 +228,7 @@
try {
Document doc = ma_errors.createRequest(e,query,
IPerfsonarRequest.MA_SetupDataRequest);
- System.out.println(document2string(doc));
+ System.out.println(AbstractMARequest.document2string(doc));
String request =
@@ -327,25 +322,13 @@
" </nmwg:metadata>\n"+
" <nmwg:data id=\"data_1out\"
metadataIdRef=\"m_param_1out\"/>\n"+
"</nmwg:message>\n";
- assertEquals(request,document2string(doc));
+ assertEquals(request,AbstractMARequest.document2string(doc));
} catch (Exception x) {
fail(x.getMessage());
}
}
- protected String document2string(Document doc) throws IOException {
- StringWriter outWriter = new StringWriter();
- OutputFormat format = new OutputFormat(doc);
- format.setLineWidth(65);
- format.setIndenting(true);
- format.setIndent(2);
-
- XMLSerializer output = new XMLSerializer(outWriter, format);
- output.serialize(doc);
- return outWriter.toString();
- }
-
protected Document docFromFile(String name) throws Exception {
DocumentBuilderFactory factory =
DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
@@ -388,7 +371,6 @@
} catch (Exception x) {
fail(x.getMessage());
}
-
-
}
+
}
- perfsonar: r2620 - in branches/perfsonarui/src/org/perfsonar/perfsonarui: . ippm ls ma playground test/ma, svnlog, 08/09/2007
Archive powered by MHonArc 2.6.16.