|
From: Bill B. <bb...@re...> - 2008-03-15 19:19:16
|
Ryan J. McDonough wrote:
> In one of the initial versions of RESTEasy (some code I never
> apparently committed) I did have a RepresentationHandler
> for "multipart/form-data" and it worked out okay. The only down side was
> your method ended up looking something like this:
>
Cool, port it over :)
> @ConsumeMime("multipart/form-data")
> public Object post(MimeMultipart muliPart) {
> Order order = MultipartHelper.unmarshallPart(
> mp.getBodyPart(0),Order.class);
> ...
>
> Not the most elegant solution, but it should be able to work within
> guidelines of JAX-RS. On the other hand, it maybe nice to do something
> more like:
>
Why do you
> @ConsumeMime("multipart/form-data")
> public Object post(@MultiPartParam(name="order",type =
> "application/order+xml") Order order) {
> ...
>
> In this case, we'd push all of the processing logic to RESTEasy and the
> let the developer work with order element directly. However, I'm not
> sure if the processing logic would conflict with JAX-RS. I'm trying to
> play catch up on the spec as I got a bit rusty over the past few months.
> The MessageReader/Writer stuff is a bit new to me.
>
I don't think it would work with JAX-RS. The problem is, there's no way
in isReadable() to determine what the mime type of Order is. You could
see @MultiPartParam within isReadable() as the signature now accepts
Annotation[], but you'd have to hope and pray that Order's type matches
something when you get into readFrom().
BTW, I was also hoping to support multipart/mixed, form-data with
List<>, and Set<> return and parameter types.
Bill
--
Bill Burke
JBoss, a division of Red Hat
http://bill.burkecentral.com
|