# HG changeset patch # User Sascha L. Teichmann # Date 1341950122 0 # Node ID 645c774b3b981a45868b4335e8b21f639f026f38 # Parent 1e01d30462602a2c9dd66414c5b6e9dbdab42df6 WAS response: Directly use Base64InputStream instead of reading it first into memory. flys-client/trunk@4922 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 1e01d3046260 -r 645c774b3b98 flys-client/ChangeLog --- 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 + + * 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 * pom.xml: Add dependencies for jdom 1.1.3, Apache commons-io 2.2 diff -r 1e01d3046260 -r 645c774b3b98 flys-client/src/main/java/de/intevation/flys/client/server/was/Response.java --- 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() {