users@jersey.java.net

Re: [Jersey] intercept 404 with client filter

From: Martin Matula <martin.matula_at_oracle.com>
Date: Wed, 29 Sep 2010 16:50:17 +0200

Hi Florian,
It should be possible to return a new ClientResponse subclass
overriding getEntity*() methods to return null. You also need to
modify the status code to be something < 300 in this newly returned
response.
Martin

On Sep 23, 2010, at 11:12 AM, Florian Hehlen wrote:

> Hi,
>
> I have an api where we want to return null whenever something is not
> found on the server. With the jersey client I have found 2
> conceivable ways to do this
>
> - Wrap all the WebResource.get() calls with some exception
> handling to handle the possible 404s
> - Add a ClientFilter that can somehow transform the response.
>
> The first is ok but not elegant…. Plus I will have to touch a lot of
> code L
>
> The second is appealing... but I am not sure how to do it. It’s easy
> enough to intercept a 404 but then is there something I can set in
> the response which will result in a null value being returned by the
> get() call?
>
> Cheers,
> Florian
>
> The information in this e-mail is intended only for the person or
> entity to which it is addressed.
>
> It may contain confidential and /or privileged material. If someone
> other than the intended recipient should receive this e-mail, he /
> she shall not be entitled to read, disseminate, disclose or
> duplicate it.
>
> If you receive this e-mail unintentionally, please inform us
> immediately by "reply" and then delete it from your system. Although
> this information has been compiled with great care, neither IMC
> Financial Markets & Asset Management nor any of its related entities
> shall accept any responsibility for any errors, omissions or other
> inaccuracies in this information or for the consequences thereof,
> nor shall it be bound in any way by the contents of this e-mail or
> its attachments. In the event of incomplete or incorrect
> transmission, please return the e-mail to the sender and permanently
> delete this message and any attachments.
>
> Messages and attachments are scanned for all known viruses. Always
> scan attachments before opening them.