users@jersey.java.net

mapping put calls (can't have optional/empty payload?)

From: danomano <dshopkins_at_earthlink.net>
Date: Mon, 7 Jun 2010 14:49:01 -0700 (PDT)

I have a requirement to implement an api as follows:

PUT
../resource/<id>
<body is payload>

Result: new resource is created (error is resource already exists)

PUT
../resource/<id>?someField=abc
<NO BODY>

Result: update the resource such that someField = abc.

I tried mapping this as follows:
    @PUT
    @Path("/{resourceId}")
    public void createOrUpdate(Resource resource,
                               @PathParam("resourceId") String resourceId,
                               @QueryParam("someField") Long someField);

however this only appears to work if the Resource payload is present, i.e.
if I do an HTTP PUT, without a payload the method is never invoked.

I tried mapping as well to 2 seperate methods, one with payload (minus the
queyParam), and one without the playload but with the queryParam, but that
was ambigious for jersey..so that didn't work)

Is this mapping not possible?
(and yes I argued the user should be forced to issue put-update calls with
the payload rather then the queryparam..but got overruled).

Any advice? (Am I going be stuck with using servlets as my
interface?..yuk..I could inject an empty <Resource/> I suppose with a
servletFilter..)

thanx
Dan


-- 
View this message in context: http://jersey.576304.n2.nabble.com/mapping-put-calls-can-t-have-optional-empty-payload-tp5151283p5151283.html
Sent from the Jersey mailing list archive at Nabble.com.