Mercurial > dive4elements > river
changeset 2947:645c774b3b98
WAS response: Directly use Base64InputStream instead of reading it first into memory.
flys-client/trunk@4922 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Tue, 10 Jul 2012 19:55:22 +0000 |
parents | 1e01d3046260 |
children | 83c962be0dde |
files | flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/server/was/Response.java |
diffstat | 2 files changed, 17 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-client/ChangeLog Tue Jul 10 12:25:51 2012 +0000 +++ b/flys-client/ChangeLog Tue Jul 10 19:55:22 2012 +0000 @@ -1,3 +1,9 @@ +2012-07-10 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/client/server/was/Response.java: + Directly use Base64InputStream filter stream instead of reading into + memory first. + 2012-07-10 Björn Ricks <bjoern.ricks@intevation.de> * pom.xml: Add dependencies for jdom 1.1.3, Apache commons-io 2.2
--- a/flys-client/src/main/java/de/intevation/flys/client/server/was/Response.java Tue Jul 10 12:25:51 2012 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/server/was/Response.java Tue Jul 10 19:55:22 2012 +0000 @@ -1,18 +1,18 @@ package de.intevation.flys.client.server.was; -import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; -import org.apache.commons.codec.binary.Base64; -import org.apache.commons.io.IOUtils; +import org.apache.commons.codec.binary.Base64InputStream; + import org.apache.http.HttpEntity; + import org.apache.log4j.Logger; import org.jdom.Document; import org.jdom.Element; import org.jdom.JDOMException; -import org.jdom.Namespace; + import org.jdom.input.SAXBuilder; public class Response { @@ -30,21 +30,20 @@ String contenttype = entity.getContentType().getValue(); - - try{ + try { InputStream in = entity.getContent(); if (!contenttype.equals("application/vnd.ogc.se_xml")) { - // assume base64 - byte[] content = IOUtils.toByteArray(entity.getContent()); - in = new ByteArrayInputStream(Base64.decodeBase64(content)); + // XXX: Assume base64 encoded content. + in = new Base64InputStream(in); } SAXBuilder builder = new SAXBuilder(); Document doc = builder.build(in); Element root = doc.getRootElement(); + String rname = root.getName(); - if (root.getName() != null && root.getName().equals("ServiceExceptionReport")) { + if (rname != null && rname.equals("ServiceExceptionReport")) { throw new ServiceException(root.getChildText("ServiceException")); } @@ -63,7 +62,8 @@ } public Boolean isSuccess() { - return (this.getStatus() != null && this.getStatus().equals("samlp:Success")); + String status = getStatus(); + return status != null && status.equals("samlp:Success"); } public String getStatus() {