Java - Apache CXF: return response code(HTTP status code)
1
2
3
4
5
6
7
import javax.ws.rs.core.Response;
Entity entity = service.getById(uuid);
if(entity == null) {
return Response.status(Response.Status.NOT_FOUND).entity("Entity not found for UUID: " + uuid).build();
}
String json = //convert entity to json
return Response.ok(json, MediaType.APPLICATION_JSON).build();