Given a certain input parameter, for a rest api i want to use the hashcode as etag. What is the probability that the json response has changed and the hashcode will be the same?
Alternatively is there a better way to do this?
@GET
public Response getConfigurationForView(@PathParam("in1") String in1, @Context Request request) throws Exception {
String jsonResponse = getJsonResponse(in1);
EntityTag etag = new EntityTag(Integer.toString(in1.hashCode()) + "-" + Integer.toString(jsonResponse.hashCode()));
ResponseBuilder builder = request.evaluatePreconditions(etag);
if(builder == null){
builder = Response.ok(jsonResponse, MediaType.APPLICATION_JSON);
builder.tag(etag);
}
return builder.build();
}