@RequestMapping(
      value = {"/add-document-{userId}"},
      method = RequestMethod.POST)
  public String uploadDocument(
      @Valid FileBucket fileBucket, BindingResult result, ModelMap model, @PathVariable int userId)
      throws IOException {

    if (result.hasErrors()) {
      System.out.println("validation errors");
      User user = userService.findById(userId);
      model.addAttribute("user", user);

      List<UserDocument> documents = userDocumentService.findAllByUserId(userId);
      model.addAttribute("documents", documents);

      return "managedocuments";
    } else {

      System.out.println("Fetching file");

      User user = userService.findById(userId);
      model.addAttribute("user", user);

      saveDocument(fileBucket, user);

      return "redirect:/add-document-" + userId;
    }
  }
  @RequestMapping(
      value = {"/add-document-{userId}"},
      method = RequestMethod.GET)
  public String addDocuments(@PathVariable int userId, ModelMap model) {
    User user = userService.findById(userId);
    model.addAttribute("user", user);

    FileBucket fileModel = new FileBucket();
    model.addAttribute("fileBucket", fileModel);

    List<UserDocument> documents = userDocumentService.findAllByUserId(userId);
    model.addAttribute("documents", documents);

    return "managedocuments";
  }