Hi,

I need a suggestion regarding Rest best practices.

******************************************************************************
Use Case: There is CRUD java interface exposed as Rest service. Objects are 
identified using Long ID:

@Path("/root")
public interface Service {
    @GET
    @Path("/{Id}")
    public ObjectTO read(@PathParam("Id") final Long id);

    @POST
    @Path("/")
    public Response create(final ObjectTO objectTO);

    @PUT
    @Path("/{Id}")
    public ObjectTO update(@PathParam("Id") final Long Id, final ObjectTO 
object);

    @DELETE
    @Path("/{Id}")
    public Response delete(@PathParam("Id") final Long Id);
}

Create operation returns Response object with link of created resource and HTTP 
201 status code.

****************************************************************************
Alternatives: Basically there are two ways to read object after creation:

A)     Using WebClient and URL returned with Response

B)      Extract object ID form URL returned with Response and use interface.

******************************************************************************
Alternative (A) seems to be more restful, but (B) allows to use central 
interface to access object that also has some benefits.
Question: what is the recommended way to access objects in such situation? 
Should I decide between two ways or can I mix them?

Cheers,
Andrei.

Reply via email to