Mercurial > dive4elements > gnv-client
changeset 678:2943f69e006f
Removed xml parsing from InputStream while exporting an artifact. Just copy the input stream to the output stream.
gnv/trunk@813 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Mon, 22 Mar 2010 10:15:33 +0000 |
parents | 8315b0a40329 |
children | 4eccd03394ac |
files | gnv/ChangeLog gnv/src/main/java/de/intevation/gnv/artifactdatabase/client/DefaultArtifactDatabaseClient.java |
diffstat | 2 files changed, 33 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/gnv/ChangeLog Mon Mar 22 09:49:48 2010 +0000 +++ b/gnv/ChangeLog Mon Mar 22 10:15:33 2010 +0000 @@ -1,3 +1,9 @@ +2010-03-22 Ingo Weinzierl <ingo.weinzierl@intevation.de> + + * src/main/java/de/intevation/gnv/action/LoadAction.java: Just copy the + input stream to the output stream without parsing it and without creating + a temporary xml document. + 2010-03-22 Tim Englich <tim.englich@intevation.de> * src/main/webapp/WEB-INF/jsp/wmslayout.jsp,
--- a/gnv/src/main/java/de/intevation/gnv/artifactdatabase/client/DefaultArtifactDatabaseClient.java Mon Mar 22 09:49:48 2010 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/artifactdatabase/client/DefaultArtifactDatabaseClient.java Mon Mar 22 10:15:33 2010 +0000 @@ -2,7 +2,9 @@ import java.io.IOException; import java.io.InputStream; +import java.io.InputStreamReader; import java.io.OutputStream; +import java.io.OutputStreamWriter; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; @@ -726,18 +728,41 @@ OutputStream out) throws ArtifactDatabaseClientException { + InputStreamReader reader = null; + OutputStreamWriter writer = null; + try { String url = ((ArtifactFactory) artifactFactory).getDataBaseUrl(); url += "/export/" + currentArtifact.getId(); - Document response = doGetRequest(url); - XMLUtils.toStream(response, out); + Representation response = doGetRequestInternal(url, null); + InputStream in = response.getStream(); + + reader = new InputStreamReader(in); + writer = new OutputStreamWriter(out); + + while (reader.ready()) { + writer.write(reader.read()); + } + } catch (Exception e) { log.error(e, e); throw new ArtifactDatabaseClientException(e); } + finally { + try { + reader.close(); + } catch (IOException ioe) {} + try { + writer.flush(); + } catch (IOException ioe) {} + + try { + writer.close(); + } catch (IOException ioe) {} + } }