@RequestMapping(value = MappingConstants.USER_LIST, method = RequestMethod.GET) @PreAuthorize("hasRole('" + PermissionConstants.ADMIN_USER_LIST + "')") public String displayUserList( Model model, @AuthenticationPrincipal CustomUserDetails userDetails) { languageDelegate.addAvailableLanguages(model); languageDelegate.addNotAvailableLanguages(model); model.addAttribute( AUTHENTICATED_USER_FIRST_NAME, userDetails != null ? userDetails.getFirstName() : null); return ViewConstants.ADMIN + "/" + ViewConstants.USER_LIST; }
@RequestMapping(value = MappingConstants.ARTICLE, method = RequestMethod.POST) @PreAuthorize("hasRole('" + PermissionConstants.ADMIN_CREATE_ARTICLE + "')") public @ResponseBody Long createArticle( @RequestBody @Valid Article article, @AuthenticationPrincipal CustomUserDetails userDetails) { // for the time being the author of the published article is the logged in user Set<Long> authorIds = new HashSet<>(); authorIds.add(userDetails.getId()); Long articleId = articleService.create(authorIds); article.setId(articleId); createDictionary(article); return articleId; }
@RequestMapping(value = MappingConstants.ARTICLE, method = RequestMethod.GET) @PreAuthorize("hasRole('" + PermissionConstants.ADMIN_CREATE_ARTICLE + "')") public String createArticleForm( Model model, Locale locale, @AuthenticationPrincipal CustomUserDetails userDetails, @RequestParam(required = false, value = "id") Long articleId) { languageDelegate.addAvailableLanguages(model); languageDelegate.addNotAvailableLanguages(model); if (articleId != null) { Optional<Article> article = articleService.find(articleId, locale.getLanguage()); if (article.isPresent()) { model.addAttribute("article", article.get()); } } model.addAttribute( AUTHENTICATED_USER_FIRST_NAME, userDetails != null ? userDetails.getFirstName() : null); return ViewConstants.ADMIN + "/" + ViewConstants.CREATE_ARTICLE; }