I have a service method which looks like this
public void deleteData(Data data) {
this.dataDao.deleteData(data);
}
Data class have several fields in it. Somethig like this
private String name;
private String category;
private String discriminator;
private String description;
private String appName;
// getters & setters
I need to write a rest method for this. I was thinking to write something like this
@DELETE
@Path("/deleteData")
public Response deleteData(Data data) {
// implementation
}
The problem is that using @DELETE
with entity body is not recommended or widely used.
My question is if it's ok to use @PUT
instead of @DELETE
? I can't change the service method implementation so that's not an option. What's the next best alternative here?
UPDATE
In dataDao.deleteData()
method, finding an object is not done by object's ID. It looks something like this:
DataEntity entity = this.findDataByNameAndAppName(data.getName(), data.getAppName());
I decided to do something like this:
@DELETE
@Path("/deleteDataset")
public Response deleteDataset(@QueryParam("name") String name,
@QueryParam("appName") String appName) {
// implementation...
}
I didn't find any example of @DELETE
method with @QueryParam
, though. All examples was using @PathParam
instead.