jsr339-experts@jax-rs-spec.java.net

[jsr339-experts] Re: [jax-rs-spec users] Re: Re: Re: Re: New to the group - comments on the current draft

From: Santiago Pericas-Geertsen <Santiago.PericasGeertsen_at_oracle.com>
Date: Thu, 22 Dec 2011 15:28:58 -0500

On Dec 22, 2011, at 2:20 PM, Sastry Malladi wrote:

> Do you have an alternate mechanism in mind that you intend to propose/include in the spec ?
> Note that the metadata will only be returned if either the caller is a browser or asked for text/html or sent an OPTIONS request, so it may not be too bad.
> The main point is the simplicity on the part of the resource developer and the consumer.

 The use of OPTIONS seems interesting to me; ideally it shouldn't be exclusively for browsers, but I haven't put much thought into this. Is this something that you'd be interesting in exploring more and proposing some options?

-- Santiago

> From: Santiago Pericas-Geertsen <Santiago.PericasGeertsen_at_oracle.com>
> To: Sastry Malladi <m_sastry_at_yahoo.com>
> Cc: "jsr339-experts_at_jax-rs-spec.java.net" <jsr339-experts_at_jax-rs-spec.java.net>
> Sent: Thursday, December 22, 2011 5:30 AM
> Subject: [jax-rs-spec users] [jsr339-experts] Re: Re: Re: New to the group - comments on the current draft
>
> Sastry,
>
> Right, that was my understanding. As I said, for complex DTOs, this a bit too much information for a link attribute, especially when serialized as a link header or in XML. I think a different mechanism is needed to convey this information.
>
> -- Santiago
>
> On Dec 21, 2011, at 5:42 PM, Sastry Malladi wrote:
>
>> The example is like this.
>> Suppose I've an Item resource, whose attributes are represented by a class called ItemDto (basically the response from a GET). When a user does a GET, in addition to returning the normal ItemDto response, it can also return the metadata, by adding a @Linkable with the template class name on the PUT method. Please see the highlighted lines. Something similar to this - Basically a declarative way to specify the metadata to be returned. The Jayway folks can perhaps explain this better, but this is what I understand.
>>
>>
>> @GET
>> @Path("/{id}")
>> @Produces(MediaType.APPLICATION_JSON)
>> @Consumes(MediaType.APPLICATION_JSON)
>> @Linkable(LinkableIDS.ITEM_GET_ID)
>> public Response getItemByID(@PathParam("id") String id) {
>>
>> return Response.ok(getSingleItem(id))
>> .selfLink(LinkableIDS.ITEM_GET_ID, id)
>> .selfLink(LinkableIDS.ITEM_UPDATE_ID, id).build();
>> }
>>
>> @PUT
>> @Path("/{id}")
>> @Produces(MediaType.APPLICATION_JSON)
>> @Consumes(MediaType.APPLICATION_JSON)
>> @Linkable(value = LinkableIDS.ITEM_UPDATE_ID, templateClass = ItemDto.class)
>> public Response updateItemByID(@PathParam("id") String id, ItemDto itemDto) { ...}
>>
>> A GET on this item resource, can then return data like this (sample)
>>
>> {links :
>> -
>> {
>> rel : "self"
>> href : "280794129251"
>> method : "GET"
>> }
>> -
>> {
>> rel : "self"
>> href : "280794129251"
>> -
>> consumes : [
>> "application/json"
>> ]
>> method : "PUT"
>> -
>> template : {
>> name : null
>> id : null
>> category : null
>> listingType : null
>> condition : null
>> sellerName : null
>> price : 0.0
>> itemURL : null
>> }
>> }
>> ]
>> name : "Apple iPad 2 32GB, Wi-Fi + 3G (Verizon), 9.7in - Black (Latest Model) New sealed"
>> id : "280794129251"
>> category : "171485"
>> listingType : "FixedPrice"
>> condition : "New"
>> sellerName : "chasoncros"
>> price : 649.0
>> itemURL : "280794129251?pt=US_Tablets"
>> From: Santiago Pericas-Geertsen <Santiago.PericasGeertsen_at_oracle.com>
>> To: Sastry Malladi <m_sastry_at_yahoo.com>
>> Cc: "jsr339-experts_at_jax-rs-spec.java.net" <jsr339-experts_at_jax-rs-spec.java.net>
>> Sent: Wednesday, December 21, 2011 1:02 PM
>> Subject: Re: [jax-rs-spec users] [jsr339-experts] Re: Re: New to the group - comments on the current draft
>>
>>
>> On Dec 16, 2011, at 9:09 PM, Sastry Malladi wrote:
>>
>>> You mean something like WADL? Agreeing on the right "description language" would take another EG! Somewhat unfortunate, perhaps, this is not in the scope for JAX-RS 2.0.
>>>
>>> Sastry > I was thinking something simple like what the Jayway folks have implemented, where a template class is specified on the resource method's Linkable annotation and the jax-rs container returns the HTTP method name and the fields in the template class, including any validation contraints (e.g NotNull) etc.
>>
>> I haven't seen an example of this, but it seems the idea is to include a JSON representation in the template link attribute? Seems too much for an attribute. This should be conveyed by an entity --using OPTIONS or something similar?
>>
>> -- Santiago
>>
>>
>>
>
>
>