[ 
https://issues.apache.org/struts/browse/WW-2515?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=43407#action_43407
 ] 

Sarat Pediredla commented on WW-2515:
-------------------------------------

The method not supported solution only works for when the resource does not 
have a corresponding method for the operation/verb requested.

I think there is a slight confusion here in the definition of "resource". I 
meant it in the RESTful way although I agree that accessing an invalid action 
will throw a 404. The problem is more a REST one. Other RESTful frameworks 
(like RoR) implement the same concept of throwing a 404 if an "object or 
resource" you requested does not exist. In terms of Struts 2 REST, an action 
will always by default map to a "list" of objects (i.e. index() method) rather 
than the specific resource (i.e. show()).

If the controller is non-ModelDriven, then would that not invalidate any other 
real use of the REST plugin as handler.toObject wouldnt return a true 
representation of the object representing the resource but just a 
representation of the action (which in most circumstance is just a RESTful 
controller). In those cases, you wouldnt want a 404 returned and rightly so?

As for the appropriateness, the 404 signifies that the "resource cannot be 
found" and I think this is definitely relevant as far as REST goes. 

> REST plugin does not throw a 404 if resource cannot be found
> ------------------------------------------------------------
>
>                 Key: WW-2515
>                 URL: https://issues.apache.org/struts/browse/WW-2515
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Plugin - REST
>    Affects Versions: 2.1.1
>         Environment: Struts 2.1.1-SNAPSHOT using Jetty 6.1.5
>            Reporter: Sarat Pediredla
>         Attachments: WW-2515.patch
>
>
> When there is a GET request for a resource that does not exist, example GET 
> /authors/25 where author with id 25 does not exist, the getModel() method of 
> the action should return null (and in most cases will return null as the 
> object does not exist).
> However, the current ContentTypeInterceptor implementation is not entirely 
> RESTful as the right response should be HTTP Status Code 404 "Not Found".
> I have patched the ContentTypeInterceptor to return a 404 status if the 
> requested resource could not be found.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to