[forge-issues] [JBoss JIRA] (FORGE-1275) @PUT method shouldn't have a @Path

Vineet Reynolds (JIRA) issues at jboss.org
Thu Jun 26 02:34:25 EDT 2014


     [ https://issues.jboss.org/browse/FORGE-1275?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Vineet Reynolds updated FORGE-1275:
-----------------------------------

           Status: Resolved  (was: Pull Request Sent)
    Fix Version/s:     (was: 2.x Future)
       Resolution: Rejected


I'm going to have to reject this issue. The {{@Path}} is very much required since it is used to identified a specific resource to be updated.

If we consider {{/rest/users}} to represent a collection resource, then an update of an individual user must be done via {{PUT /rest/members/X}} where X identifies the individual resource (located in the collection) to update. Note {{/rest/users}} is a collection here, and the HTTP semantics apply to this URL as well. A {{PUT /rest/users}} would represent an entire collection update (replacing everything in it with a single element), must like a {{POST /rest/users}} represents adding a new member to the collection resource. So, the Path annotation is very much necessary.

What is necessary is here, is validation to verify the Path value equality with the id inside the PUT body.

> @PUT method shouldn't have a @Path
> ----------------------------------
>
>                 Key: FORGE-1275
>                 URL: https://issues.jboss.org/browse/FORGE-1275
>             Project: Forge
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>          Components: Scaffold
>    Affects Versions: 1.4.2.Final
>            Reporter: Antonio Goncalves
>
> Hi,
> In the REST scaffolding, the generate {{update}} method looks like this : 
> {code}
>     @PUT
>     @Path("/{id:[0-9][0-9]*}")
>     @Consumes("application/xml")
>     public Response update(Book entity) {
>         em.merge(entity);
>         return Response.noContent().build();
>     }
> {code}
> The method has a {{@Path}} annotation with an id and therefore cannot be invoked (without the id that is not used in the method). So it should simply be : 
> {code}
>     @PUT
>     @Consumes("application/xml")
>     public Response update(Book entity) {
>         em.merge(entity);
>         return Response.noContent().build();
>     }
> {code}



--
This message was sent by Atlassian JIRA
(v6.2.6#6264)


More information about the forge-issues mailing list