@RequestMapping(value = "projects/{id}/{type}")
 public void getProjectReport(
     @PathVariable("id") Integer id,
     @RequestParam(value = "start", required = false) String b,
     @RequestParam(value = "end", required = false) String e,
     @PathVariable("type") String type,
     HttpServletResponse response)
     throws IOException {
   if (type.equals("pdf")) gen = new PDFGenerator();
   else gen = new SheetGenerator();
   if (b != null && e != null) {
     DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
     try {
       Date begin = formatter.parse(b);
       Date end = formatter.parse(e);
       Collection<Activity> col = activityRepository.findByDateBetweenAndProjId(begin, end, id);
       InputStream is = new FileInputStream(gen.getDocumentByProject(col, begin + "-" + end));
       if (type.equals("pdf")) response.setContentType("application/pdf");
       else
         response.setContentType(
             "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
       OutputStream os = response.getOutputStream();
       int n = 0;
       byte[] byteBuffer = new byte[16384];
       while ((n = is.read(byteBuffer)) > -1) {
         os.write(byteBuffer, 0, n); // Don't allow any extra bytes to creep in, final write
       }
       response.flushBuffer();
     } catch (Exception ex) {
     }
   } else {
     try {
       Collection<Activity> col = activityRepository.findByProjId(id);
       InputStream is = new FileInputStream(gen.getDocumentByProject(col, "Whole period"));
       response.setContentType("application/pdf");
       OutputStream os = response.getOutputStream();
       int n = 0;
       byte[] byteBuffer = new byte[16384];
       while ((n = is.read(byteBuffer)) > -1) {
         os.write(byteBuffer, 0, n); // Don't allow any extra bytes to creep in, final write
       }
       response.flushBuffer();
     } catch (Exception ex) {
     }
   }
 }