users@jersey.java.net

Re: [Jersey] DELETE Response status code...

From: Felipe Gaúcho <fgaucho_at_gmail.com>
Date: Thu, 30 Apr 2009 18:13:29 +0200

ah....... ! sorry.

On Thu, Apr 30, 2009 at 6:10 PM, Rabick, Mark A (IS)
<Mark.Rabick_at_ngc.com> wrote:
>> by default:
>> if it doesn't throw any exception, it worked..
>> otherwise, get the error code.........
>
> Actually, I'm asking about the tags in the method documentation... Use @return or @response.representation.204.doc  ...
>
> -mark
> _______________________________________________
> Mark A. Rabick - Software Engineer
> Em: mark.rabick_at_ngc.com
>
>
>
>> -----Original Message-----
>> From: Felipe Gaúcho [mailto:fgaucho_at_gmail.com]
>> Sent: Thursday, April 30, 2009 11:08 AM
>> To: users_at_jersey.dev.java.net
>> Subject: Re: [Jersey] DELETE Response status code...
>>
>> by default:
>>
>> if it doesn't throw any exception, it worked..
>>
>> otherwise, get the error code.........
>>
>> On Thu, Apr 30, 2009 at 6:06 PM, Rabick, Mark A (IS)
>> <Mark.Rabick_at_ngc.com> wrote:
>> > How would you document that in an extended wadl doclet?
>> >
>> >        /**
>> >         * Delete a Node with the given SK.
>> >         *
>> >         * @param sk    The Node SK value.
>> >         *
>> >         * @response.representation.204.doc The status code
>> No Content
>> > (204) on successful delete.
>> >       */
>> >
>> > Or
>> >
>> >        /**
>> >         * Delete a Node with the given SK.
>> >         *
>> >         * @param sk    The Node SK value.
>> >         *
>> >         * @return 204 (No Content).
>> >       */
>> >
>> > Neither really seems appropriate on a method with return
>> type void....
>> > Suggestions?
>> >
>> > -mark
>> > _______________________________________________
>> > Mark A. Rabick - Software Engineer
>> > Em: mark.rabick_at_ngc.com
>> >
>> >
>> >
>> >> -----Original Message-----
>> >> From: Paul.Sandoz_at_Sun.COM [mailto:Paul.Sandoz_at_Sun.COM]
>> >> Sent: Thursday, April 30, 2009 10:39 AM
>> >> To: users_at_jersey.dev.java.net
>> >> Subject: Re: [Jersey] DELETE Response status code...
>> >>
>> >> Hi Mark,
>> >>
>> >> On Apr 30, 2009, at 5:33 PM, Rabick, Mark A (IS) wrote:
>> >>
>> >> > What is the best choice for an HTTP response status code for the
>> >> > successful deletion of a 'resource'?  I have a DELETE method:
>> >> >
>> >> >         @DELETE @Path("{sk: [a-zA-Z0-9 ]{1,32}}")
>> >> >         public synchronized Response
>> >> > deleteNodeBySk(@PathParam("nodesk") String nodeSk) {
>> >> >
>> >> >                 Response resp = null;
>> >> >
>> >> >                 Node nodeToDelete = new Node(nodeSk);
>> >> >                 nodeRemote.delete(nodeToDelete);
>> >> >                 /*
>> >> >                  * Response Status code is 204 (No Content)
>> >> >                  */
>> >> >                 resp = Response.noContent().entity(null).build();
>> >> >                 System.out.println("Deleted sk: " + nodeSk);
>> >> >
>> >> >                 return resp;
>> >> >         }
>> >> >
>> >> > I've looked at the examples and mostly see delete
>> methods returning
>> >> > 'void'.  The method is synchronous above so the delete should be
>> >> > complete before the method returns.  Is the 204 (No Content)
>> >> > appropriate or would a 205 (reset content) or 200 (ok)?
>> >> >
>> >>
>> >> A 204, if you are not sending a response entity:
>> >>
>> >>          @DELETE @Path("{sk: [a-zA-Z0-9 ]{1,32}}")
>> >>          public synchronized void
>> deleteNodeBySk(@PathParam("nodesk")
>> >> String nodeSk) {
>> >>
>> >>                  Response resp = null;
>> >>
>> >>                  Node nodeToDelete = new Node(nodeSk);
>> >>                  nodeRemote.delete(nodeToDelete);
>> >>          }
>> >>
>> >>
>> >> A void results in a 204 response, assuming that no exception is
>> >> thrown.
>> >>
>> >>
>> >> > I've seen a couple of different examples for each on 'the net'.
>> >> >
>> >> > The other question I have is on a 'create' method (@POST).
>> >> I want to
>> >> > return both the URI for the newly created entity as well as
>> >> return the
>> >> > created entity itself in the message body.  Would the
>> URL go in the
>> >> > Location header?  If so, how is that accomplished?
>> >> >
>> >>
>> >> URI u = ...
>> >>
>> >> Response.created(u)...
>> >>
>> >> https://jsr311.dev.java.net/nonav/javadoc/javax/ws/rs/core/
>> >> Response.html#created(java.net.URI)
>> >>
>> >> Paul.
>> >> > --mark
>> >> >
>> >> > _______________________________________________
>> >> > Mark A. Rabick
>> >> > Software Engineer
>> >> > Northrop Grumman - Integrated Mission Systems (IS/DSD/IMS)
>> >> 3200 Samson
>> >> > Way Bellevue, NE  68123
>> >> > Ph:  (402) 293-7091
>> >> > Em: mark.rabick_at_ngc.com
>> >> > Remember PFC Ross A. McGinnis...
>> >> >   http://www.army.mil/medalofhonor/McGinnis/index.html
>> >> > ... MA2 Michael A. Monsoor, Lt. Michael P. Murphy, Cpl.
>> >> Jason Dunham,
>> >> > SFC Paul Ray Smith and the rest...
>> >> >   http://www.cmohs.org/recipients/most_recent.htm
>> >> >
>> >> >
>> >>
>> >>
>> >>
>> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>> >> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>> >>
>> >>
>> >
>> >
>> ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>> > For additional commands, e-mail: users-help_at_jersey.dev.java.net
>> >
>> >
>>
>>
>>
>> --
>>
>> Please help to test this application:
>> http://fgaucho.dyndns.org:8080/cejug-classifieds-richfaces
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>
>



-- 
Please help to test this application:
http://fgaucho.dyndns.org:8080/cejug-classifieds-richfaces