示例#1
0
 @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;
 }
示例#2
0
 @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;
 }
示例#3
0
 @RequestMapping(MappingConstants.ARTICLE_LIST_JSON)
 @PreAuthorize("hasRole('" + PermissionConstants.ADMIN_ARTICLE_LIST + "')")
 public @ResponseBody List<Article> findArticles(Locale locale) {
   return articleService.find(locale.getLanguage());
 }