Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.48 KB | None | 0 0
  1.     /**
  2.      * Gets the platform we want to edit
  3.      *
  4.      * @param uuid  platform.uuid
  5.      * @param model platform
  6.      * @return edit-platform.html
  7.      */
  8.     @GetMapping(path = "/get/{uuid}/edit")
  9.     public String edit(@PathVariable String uuid, Model model) throws NumberFormatException {
  10.         Platform platform = this.dataProvider.getPlatformByUUID(uuid);
  11.         model.addAttribute("platform", platform);
  12.  
  13.         if (platform != null) {
  14.             System.out.println();
  15.             return "edit-platform";
  16.  
  17.         }
  18.         GameManagerException customException = new GameManagerException(HttpStatus.NOT_FOUND,
  19.                 "Platform with this UUID does not exist!");
  20.         model.addAttribute("errormessage", customException);
  21.         return "/exception/game-manager-error.html";
  22.  
  23.     }
  24.  
  25.     /**
  26.      * Updates the platform we want to edit
  27.      *
  28.      * @param uuid      platform.uuid
  29.      * @param publisher String
  30.      * @param name      string
  31.      * @return redirect:/platform
  32.      */
  33.     @PostMapping(path = "/get/{uuid}/edit")
  34.     public String update(@PathVariable String uuid,
  35.                          @RequestParam("publisher") String publisher,
  36.                          @RequestParam("name") String name) {
  37.         Platform platform = this.dataProvider.getPlatformByUUID(uuid);
  38.         platform.setPublisher(publisher);
  39.         platform.setName(name);
  40.         this.dataProvider.updatePlatform(platform);
  41.         return "redirect:/platform";
  42.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement