users@jersey.java.net

[Jersey] Entity Manipulation Prior to REST Implementation Call

From: <webron_at_gmail.com>
Date: Sat, 17 Sep 2011 12:54:33 +0000 (GMT)

Hi everyone,

I hope this haven't been asked and answered before - I wasn't sure
exactly what to look for.

Brief description of our architecture:
We have an entity-management Spring-based system. The system consisted
of several entities - all JAXB annotated. Those entities are used both
with our DB ORM framework and by our REST API implementation. The
entities are sent to the REST API in JSON format.

Currently, when the client invoke an API call, it needs to send the
whole JSON/entity.
For example, assume the following API declaration:

@PUT
@Path("/entity")
@Consumes({MediaType.APPLICATION_JSON})
public void updateEntity(FooEntity fooEntity) { ... }

What I'd like to do is allow the client to send only parts of the
entity, and somehow add a hook before the actual updateEntity(...)
invocation. In that hook, I would read the actual entity from the
database (or whichever source), and modify only the fields received
from the client, and only then invoke the updateEntity(...) with the
newly created entity. I would probably want to put some extra
security-checks logic in that hook.

Is there any way to do it? If there's more than one way, I'd like to
hear the options out there (with pros and cons if willing).

Thanks,
Ron