Guest User

Untitled

a guest
Jul 19th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. @Controller
  2. @RequestMapping(value = "api/whatever")
  3. public class WhateverController {
  4.  
  5. @Autowired private WhateverService whateverService;
  6.  
  7. @RequestMapping(value = "/list", method = GET)
  8. @Secured({ "ROLE_WHATEVER_CANSEARCH" })
  9. @ResponseBody
  10. public List<WhateverDTO> findList(@RequestParam(value = "values") String[] values) {
  11. return whateverService.findThings(values);
  12. }
  13.  
  14. }
  15.  
  16. @Service
  17. public class WhateverService {
  18.  
  19. @Autowired private WhateverDAO whateverDAO;
  20.  
  21. public List<WhateverDTO> findThings(String[] values) {
  22. //...
  23. validate();
  24. return whateverDAO.findThings(values);
  25. }
  26.  
  27. @Secured({ "ROLE_SPECIFICPERMISSION" }) // Throws AccessDeniedException
  28. private void validate() {
  29. if(thing) throw new RuntimeException("You can't...");
  30. }
  31.  
  32. }
Add Comment
Please, Sign In to add comment