|
From: Bill B. <bb...@re...> - 2008-06-22 11:17:56
|
Ryan J. McDonough wrote:
>> Still working on multipart
>> stuff?
>
> Yeah and I'm wrapping it up too. I'm finalizing the basic Multipart
> stuff now and I was using JAF and JavaMail. I have the basic multipart
> stuff working and now moving on to being able to do the idea you
> had originally with a List:
>
> @PUT
> @ConsumeMime("multipart/form-data")
> @ProduceMime("text/plain")
> public String putData(List<?> parts) {
>
> Here's the kinks with that one:
>
> in the read case, we don't have the class information for the different
> parts. If every element is the same in the List, it could be ok.
> However, most of the time I've had to work with Multipart, I've always
> dealt with multiple data types. So you'd have 2 XML documents, an image,
> etc. In that case, we only have the data and mime type and no class
> info. With that said, we can't use createMessageBodyReader() to locate a
> suitable MessageBodyReader. With JAXB, this would be a real challenge
> because you can't say: here's some XML, now unmarshall it and find the
> appropriate class. Now using JAF kinda works, but then you end up with a
> ByteArrayInputStream. Any thoughts?
>
I think you'll need a Multipart abstraction where the resource methods
can inject what type they want marshalled into.
public void post(Multipart parts) {
MyJaxb jaxb = parts.getPart(0).read(MyJaxb.class);
JPEG jpg = parts.getPart(1).read(JPEG.class);
or
MyJaxb jaxb = parts.get("myField").read(MyJaxb.class);
}
Alternatively, you could do:
public void post(@Multipart({MyJaxB.class, JPEG.class}) List parts);
But that only works if the format of the buffer is fixed and defined and
it seems kinda quirky and quickly unreadable.
--
Bill Burke
JBoss, a division of Red Hat
http://bill.burkecentral.com
|