Ejemplo n.º 1
0
 @RequestMapping(
     value = {"/areas"},
     method = RequestMethod.GET)
 public List<AreaJsonDto> getAreas(HttpServletResponse response) {
   List<AreaJsonDto> dtos =
       dtoService.convert(areaService.getAll(), AreaJsonDto.class, Area.class);
   response.addIntHeader("X-Total-Count", dtos.size());
   return dtos;
 }
  /**
   * Set the headers in the response object, excluding the Gzip header
   *
   * @param pageInfo
   * @param response
   */
  protected void setHeaders(final PageInfo pageInfo, final HttpServletResponse response) {

    Collection<Header<? extends Serializable>> headers = pageInfo.getHeaders();

    // Track which headers have been set so all headers of the same name
    // after the first are added
    TreeSet<String> setHeaders = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);

    for (Header<? extends Serializable> header : headers) {
      String name = header.getName();

      switch (header.getType()) {
        case STRING:
          if (setHeaders.contains(name)) {
            response.addHeader(name, (String) header.getValue());
          } else {
            setHeaders.add(name);
            response.setHeader(name, (String) header.getValue());
          }
          break;
        case DATE:
          if (setHeaders.contains(name)) {
            response.addDateHeader(name, (Long) header.getValue());
          } else {
            setHeaders.add(name);
            response.setDateHeader(name, (Long) header.getValue());
          }
          break;
        case INT:
          if (setHeaders.contains(name)) {
            response.addIntHeader(name, (Integer) header.getValue());
          } else {
            setHeaders.add(name);
            response.setIntHeader(name, (Integer) header.getValue());
          }
          break;
        default:
          throw new IllegalArgumentException("No mapping for Header: " + header);
      }
    }
  }
Ejemplo n.º 3
0
 @Override
 public void addIntHeader(String s, int i) {
   response.addIntHeader(s, i);
 }
 public synchronized void addIntHeader(String arg0, int arg1) {
   actualResponse.addIntHeader(arg0, arg1);
 }
Ejemplo n.º 5
0
 public void addIntHeader(String name, int value) {
   rawResponse.addIntHeader(name, value);
 }