Hi
On 04/09/12 03:26, XiLai Dai wrote:
Thanks Sergey!
That means in case atts> 0 , then, return Response.ok(new MultipartBody(atts,
true)).build();
Else, return Response.ok().build();
Yes
And nothing to be changed in the wadl ? just keep this<response> ?
<response status="200">
<representation
mediaType="multipart/mixed;type=application/xml" />
</response>
Yes, that should be OK. If no multipart message is returned then the
client will get 204 which does not contradict to the above. Perhaps you
may want to provide two response elements:
<method name="GET">
<response status="200">
<doc title="List of attachments, root part is XML"/>
<representation mediaType="multipart/mixed;type=application/xml" />
</response>
<response status="204">
<doc title="Empty response, no attachments">
</response>
</method>
the following should work too:
<response status="200 204">
<doc title="List of attachments, root part is XML"/>
<representation mediaType="multipart/mixed;type=application/xml" />
</response>
Cheers, Sergey
Thanks, Xilai
-----Original Message-----
From: Sergey Beryozkin [mailto:[email protected]]
Sent: Monday, September 03, 2012 9:16 PM
To: [email protected]; XiLai Dai
Subject: Re: No any Attachment will throw IndexOutOfBoundsException in
org.apache.cxf.jaxrs.ext.MessageContextImpl
Hi Xilai
Apologies for a delay, I've lost this message but got it again thanks to
Colm...
The best way to solve the issue is to return Response without setting an
actual entity, example, "return Response.ok().build()".
Right now the provider throws IndexOutOfBoundsException which is a bug
but I also think that the fix is to throw an exception because the
multipart payload does have to have at least one part.
Cheers, Sergey
---------- Forwarded message ----------
From: *XiLai Dai*<[email protected]<mailto:[email protected]>>
Date: Wed, Aug 29, 2012 at 10:17 AM
Subject: No any Attachment will throw IndexOutOfBoundsException in
org.apache.cxf.jaxrs.ext.MessageContextImpl
To: "[email protected]<mailto:[email protected]>"
<[email protected]<mailto:[email protected]>>
Hi,
The WADL fragment :
<resource path="/abc/def">
<method name="GET" id="lookupABC">
......
<response status="200">
<representation mediaType="multipart/mixed;type=application/xml" />
</response>
</method>
</resource>
And code in the implement class:
public Response lookupABC(String str) {
...
List<Attachment> atts = new LinkedList<Attachment>();
return Response.ok(new MultipartBody(atts, true)).build();
}
This exception will be thrown when atts.size() = 0. (no any attachment).
After debug into the cxf code (2.6.2), on (line 189):
Attachment root = (Attachment)handlers.get(0);
In the org.apache.cxf.jaxrs.ext.MessageContextImpl, which use get()
without any check.
Is it a MessageContextImpl issue? Or is there another way to return
multipart but with no any attachment response?
Thanks.
Xilai