protected void writeResponse( final HttpServletResponse httpServletResponse, final SimpleStatusResponse simpleStatusResponse) { Gson gson = new Gson(); try { httpServletResponse.setContentType("application/json; charset=utf-8"); _log.debug("Serializing: " + simpleStatusResponse); final PrintWriter writer = httpServletResponse.getWriter(); gson.toJson(simpleStatusResponse.getResponseStatus(), writer); writer.flush(); writer.close(); } catch (Exception e) { _log.error("Error while writing response: " + e.getMessage(), e); } }
protected void writeMediaNotReadable(final HttpServletResponse httpServletResponse) { SimpleStatusResponse simpleStatusResponse = new SimpleStatusResponse(); simpleStatusResponse.setResponseStatus(ResponseStatus.RESOURCE_NOT_FOUND); writeResponse(httpServletResponse, simpleStatusResponse); }
public void writeErrorResponse(final HttpServletResponse httpServletResponse, final Exception e) { SimpleStatusResponse simpleStatusResponse = new SimpleStatusResponse(); simpleStatusResponse.setResponseStatus(ResponseStatus.INTERNAL_ERROR); writeResponse(httpServletResponse, simpleStatusResponse); }