Ejemplo n.º 1
0
 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);
   }
 }
Ejemplo n.º 2
0
 protected void writeMediaNotReadable(final HttpServletResponse httpServletResponse) {
   SimpleStatusResponse simpleStatusResponse = new SimpleStatusResponse();
   simpleStatusResponse.setResponseStatus(ResponseStatus.RESOURCE_NOT_FOUND);
   writeResponse(httpServletResponse, simpleStatusResponse);
 }
Ejemplo n.º 3
0
 public void writeErrorResponse(final HttpServletResponse httpServletResponse, final Exception e) {
   SimpleStatusResponse simpleStatusResponse = new SimpleStatusResponse();
   simpleStatusResponse.setResponseStatus(ResponseStatus.INTERNAL_ERROR);
   writeResponse(httpServletResponse, simpleStatusResponse);
 }