users@jersey.java.net

[Jersey] Re: custom object or Response

From: Paul Blakeley <Paul.Blakeley_at_lifestylegroup.co.uk>
Date: Fri, 20 Feb 2015 15:05:15 -0000

Thanks for your response. Agreed. That would be better to do that. Can you please provide an example or point me to an example on the net which demonstrates how to handle the common use cases like POST, DELETE etc.



From: DiFrango, Ronald (CONT) [mailto:Ronald.DiFrango_at_capitalone.com]
Sent: 20 February 2015 14:29
To: users_at_jersey.java.net
Subject: [Jersey] Re: custom object or Response



Given that Jersey will automatically wrap any custom object in a response for you, I feel like its “cleaner” to just return your custom object and let Jersey do its thing.



Also, I know in our case doing this allows us to create response filters to handle common use cases like a POST’s returning 201, DELETE 204, thereby eliminating the need for every API do remember to do that.





From: Paul Blakeley [mailto:Paul.Blakeley_at_lifestylegroup.co.uk]
Sent: Friday, February 20, 2015 9:09 AM
To: users_at_jersey.java.net
Subject: [Jersey] custom object or Response



Hi,

                I use restful services quite a lot these days. But one of my colleges was questioning whether when returning a response from a service should you return a custom object or wrap the object in the Response. I thought wrapping any custom object in a Response was the right thing to do. He seemed to think otherwise! It would be good to get some idea on what is the right way, if there is one? Or to get the advantages/disadvantages of either way? I have provided examples below of either way just to clarify.



    @GET

    @Produces({ MediaType.APPLICATION_JSON })

    public Response getCustomers() {

        ...

    }



    @GET

    @Produces({ MediaType.APPLICATION_JSON })

    public List<Customer> getCustomers() {

        ...

    }

Assurant Solutions - The new name for Lifestyle Services Group.

This e-mail message and all attachments transmitted with it may contain legally privileged and/or confidential information intended solely for the use of the addressee(s). If the reader of this message is not the intended recipient, you are hereby notified that any reading, dissemination, distribution, copying, forwarding or other use of this message or its attachments is strictly prohibited. If you have received this message in error, please notify the sender immediately and delete this message and all copies and backups thereof.

In the UK, Assurant Solutions is a trading name for each of the following companies: Assurant Group Limited, registered in England no. 3264846; Lifestyle Services Group Limited, registered in England no. 5114385; Assurant General Insurance Limited, registered in England No. 2341082; Assurant Life Limited, registered in England no. 3264844; Assurant Services (UK) Limited, registered in England no. 2515130; Assurant Direct Limited, registered in England no. 5399683; Assurant Intermediary Limited, registered in England no. 4019801 The UK branch of Assurant Services Limited, registered in England no. FC028217.

The registered office for all the companies noted above is Assurant House, 6-12 Victoria Street, Windsor, Berkshire, SL4 1EN.

Lifestyle Services Group Limited is authorised and regulated by the Financial Conduct Authority under register number 315245. Assurant General Insurance Limited is authorised by the Prudential Regulation Authority and regulated by the Financial Conduct Authority and the Prudential Regulation Authority under register number 202735. Assurant Life Limited is authorised by the Prudential Regulation Authority and regulated by the Financial Conduct Authority and the Prudential Regulation Authority under register number 203060. Assurant Direct Limited is an appointed representative of Assurant Intermediary Limited, which is authorised and regulated by the Financial Conduct Authority under register number 311243.

You can check this information on the Financial Services Register at http://www.fca.org.uk/register or by calling 0800 111 6768.



________________________________

The information contained in this e-mail is confidential and/or proprietary to Capital One and/or its affiliates. The information transmitted herewith is intended only for use by the individual or entity to which it is addressed. If the reader of this message is not the intended recipient, you are hereby notified that any review, retransmission, dissemination, distribution, copying or other use of, or taking of any action in reliance upon this information is strictly prohibited. If you have received this communication in error, please contact the sender and delete the material from your computer.


Assurant Solutions - The new name for Lifestyle Services Group.
This e-mail message and all attachments transmitted with it may contain legally privileged and/or confidential information intended solely for the use of the addressee(s). If the reader of this message is not the intended recipient, you are hereby notified that any reading, dissemination, distribution, copying, forwarding or other use of this message or its attachments is strictly prohibited. If you have received this message in error, please notify the sender immediately and delete this message and all copies and backups thereof.
In the UK, Assurant Solutions is a trading name for each of the following companies: Assurant Group Limited, registered in England no. 3264846; Lifestyle Services Group Limited, registered in England no. 5114385; Assurant General Insurance Limited, registered in England No. 2341082; Assurant Life Limited, registered in England no. 3264844; Assurant Services (UK) Limited, registered in England no. 2515130; Assurant Direct Limited, registered in England no. 5399683; Assurant Intermediary Limited, registered in England no. 4019801 The UK branch of Assurant Services Limited, registered in England no. FC028217.
The registered office for all the companies noted above is Assurant House, 6-12 Victoria Street, Windsor, Berkshire, SL4 1EN.
Lifestyle Services Group Limited is authorised and regulated by the Financial Conduct Authority under register number 315245. Assurant General Insurance Limited is authorised by the Prudential Regulation Authority and regulated by the Financial Conduct Authority and the Prudential Regulation Authority under register number 202735. Assurant Life Limited is authorised by the Prudential Regulation Authority and regulated by the Financial Conduct Authority and the Prudential Regulation Authority under register number 203060. Assurant Direct Limited is an appointed representative of Assurant Intermediary Limited, which is authorised and regulated by the Financial Conduct Authority under register number 311243.
You can check this information on the Financial Services Register at http://www.fca.org.uk/register or by calling 0800 111 6768.