*/
package jalview.ws.rest;
-import jalview.bin.Cache;
+import jalview.bin.Console;
import jalview.io.FileParse;
import jalview.io.packed.DataProvider;
import jalview.io.packed.DataProvider.JvDataType;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpRequestBase;
import org.apache.http.entity.mime.MultipartEntity;
+import org.apache.http.util.EntityUtils;
import org.apache.james.mime4j.MimeException;
import org.apache.james.mime4j.parser.MimeStreamParser;
}
jalview.io.packed.JalviewDataset ds = restJob.newJalviewDataset();
// Decide how we deal with content.
- if (en instanceof MultipartEntity)
+ // TODO : verify we are detecting a multipart response correctly
+ if (en.getContentType().getValue().startsWith("multipart/form-data"))
{
// Multipart messages should be properly typed, so we parse them as we go.
- MultipartEntity mpe = (MultipartEntity) en;
- // multipart
JalviewMimeContentHandler handler = new JalviewMimeContentHandler(ds);
MimeStreamParser parser = new MimeStreamParser();
parser.setContentHandler(handler);
try
{
- parser.parse(mpe.getContent());
+ parser.parse(en.getContent());
} catch (MimeException me)
{
error = true;
errormessage = "Couldn't parse message from web service.";
- Cache.log.warn("Failed to parse MIME multipart content", me);
- en.consumeContent();
+ Console.warn("Failed to parse MIME multipart content", me);
+ EntityUtils.consume(en);
}
return new ParsePackedSet().getAlignment(ds,
handler.getJalviewDataProviders());
: en.getContentEncoding().getValue();
if (en.getContentType() != null)
{
- Cache.log.debug("Result Type: " + en.getContentType().toString());
+ Console.debug("Result Type: " + en.getContentType().toString());
}
else
{
- Cache.log.debug("No Result Type Specified.");
+ Console.debug("No Result Type Specified.");
}
if (enc == null || enc.length() < 1)
{
- Cache.log.debug("Assuming 'Default' Result Encoding.");
+ Console.debug("Assuming 'Default' Result Encoding.");
}
else
{
- Cache.log.debug("Result Encoded as : " + enc);
+ Console.debug("Result Encoded as : " + enc);
}
// attempt to identify file and construct an appropriate DataSource
// identifier for it.
: new InputStreamReader(en.getContent());
} catch (UnsupportedEncodingException e)
{
- Cache.log.error("Can't handle encoding '" + enc
+ Console.error("Can't handle encoding '" + enc
+ "' for response from webservice.", e);
- en.consumeContent();
+ EntityUtils.consume(en);
error = true;
errormessage = "Can't handle encoding for response from webservice";
return;