users@jersey.java.net

[Jersey] Re: REST service forces regex

From: Jakub Podlesak <jakub.podlesak_at_oracle.com>
Date: Mon, 05 Sep 2011 16:10:40 +0200

Hi,

That is strange and looks like a bug. The sub-resource methods should
not be related.
What was the actual path parameter value?

~Jakub


On 21.8.2011 20:01, gisellas_at_yachay.net wrote:
> I created a simple CRUD interface, where my READ is a
> @GET
> @Path("{location_id: [a-zA-Z0-9_]+}")
> @Produces({ MediaType.APPLICATION_XML,
> MediaType.APPLICATION_JSON })
> @Override
> public Location getLocation(@PathParam("location_id") String
> id) {...}
>
> So, I am limiting the READ to certain location IDs.
> Then I had a CREATE (PUT) that was NOT recognized by REST, unless I use
> the
> regex.
>
> @PUT
> @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
> @Path("{location_id}")
> @Override
> public Response addLocation(@PathParam("location_id") String
> id) {...}
>
> The above method was not recognized (REST could not find a match).
> Then, I changed it to
>
> @PUT
> @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
> @Path("{location_id: [a-zA-Z0-9_]+}")
> @Override
> public Response addLocation(@PathParam("location_id") String
> id) {..}
>
> and my method was recognized.
>
> So, it seems that somehow the REST matcher is expecting that once
> I use a regex for location_id, I have to use it always?
>