import java.util.List;
import org.apache.james.mime4j.MimeException;
-import org.apache.james.mime4j.descriptor.BodyDescriptor;
import org.apache.james.mime4j.parser.ContentHandler;
-import org.apache.james.mime4j.parser.Field;
+import org.apache.james.mime4j.stream.BodyDescriptor;
+import org.apache.james.mime4j.stream.Field;
/**
* ContentHandler for parsing mime encoded messages into Jalview objects. TODO:
/**
* sources for data to be parsed
*/
- List<DataProvider> dataItems = new ArrayList<DataProvider>();
+ List<DataProvider> dataItems = new ArrayList<>();
@Override
public void body(BodyDescriptor arg0, InputStream arg1)
// TODO Auto-generated method stub
return null;
}
-
}
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;
-
/**
* data source instantiated from the response of an httpclient request.
*
}
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();
+ EntityUtils.consume(en);
}
return new ParsePackedSet().getAlignment(ds,
handler.getJalviewDataProviders());
{
Cache.log.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;