Skip to content

Instantly share code, notes, and snippets.

@iporsut
Created March 11, 2014 05:31
Show Gist options
  • Save iporsut/9480002 to your computer and use it in GitHub Desktop.
Save iporsut/9480002 to your computer and use it in GitHub Desktop.
Add Liferay Article
@RenderMapping
public String main(RenderRequest request, RenderResponse response, Model model) throws SystemException, PortalException {
model.addAttribute("messages", messageToMDService.listMessageToMD());
if (request.getRemoteUser() != null) {
User user = UserLocalServiceUtil.getUserById(Long.parseLong(request.getRemoteUser()));
ThemeDisplay themeDisplay= (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);
ServiceContext serviceContext = new ServiceContext();
serviceContext.setScopeGroupId(themeDisplay.getScopeGroupId());
JournalArticleLocalServiceUtil.addArticle(
themeDisplay.getUserId(),
themeDisplay.getScopeGroupId(),
"test",
true,
"ทดสอบภาษาไทย",
"Add Article from Programming",
"<h1>สวัสดี</h1>",
"general",
"",
"",
3,
11,
2014,
0,
0,
0,
0,
0,
0,
0,
true,
0,
0,
0,
0,
0,
true,
true,
false,
StringPool.BLANK,
null,
null,
StringPool.BLANK,
serviceContext);
System.out.println(user.getFullName());
}
return "list";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment