incubator-wink-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bryant Luk <>
Subject Re: Entity Manipulation Prior to REST Implementation Call
Date Sun, 18 Sep 2011 22:02:29 GMT
You can create your own JAX-RS MessageBodyReader if you want. You can do the entity lookup
and return the newly created entity in the readFrom method. This is the standard way of doing
it in JAX-RS. To create the MessageBodyReader, you can either extend an existing JSON MessageBodyReader,
write your own JSON parser, or use a @Context Providers to lookup a generic JAX-RS JSON that's
active in the system.

On Sep 18, 2011, at 5:13 AM, Ron wrote:

> 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

View raw message