List of usage examples for com.liferay.portal.kernel.service UserLocalServiceUtil fetchUserById
public static com.liferay.portal.kernel.model.User fetchUserById(long userId)
From source file:com.liferay.journal.util.impl.JournalUtil.java
License:Open Source License
public static void addAllReservedEls(Element rootElement, Map<String, String> tokens, JournalArticle article, String languageId, ThemeDisplay themeDisplay) { addReservedEl(rootElement, tokens, JournalStructureConstants.RESERVED_ARTICLE_ID, article.getArticleId()); addReservedEl(rootElement, tokens, JournalStructureConstants.RESERVED_ARTICLE_VERSION, article.getVersion());/*ww w . ja v a2 s . co m*/ addReservedEl(rootElement, tokens, JournalStructureConstants.RESERVED_ARTICLE_TITLE, article.getTitle(languageId)); addReservedEl(rootElement, tokens, JournalStructureConstants.RESERVED_ARTICLE_URL_TITLE, article.getUrlTitle()); addReservedEl(rootElement, tokens, JournalStructureConstants.RESERVED_ARTICLE_DESCRIPTION, article.getDescription(languageId)); addReservedEl(rootElement, tokens, JournalStructureConstants.RESERVED_ARTICLE_CREATE_DATE, article.getCreateDate()); addReservedEl(rootElement, tokens, JournalStructureConstants.RESERVED_ARTICLE_MODIFIED_DATE, article.getModifiedDate()); if (article.getDisplayDate() != null) { addReservedEl(rootElement, tokens, JournalStructureConstants.RESERVED_ARTICLE_DISPLAY_DATE, article.getDisplayDate()); } String smallImageURL = StringPool.BLANK; if (Validator.isNotNull(article.getSmallImageURL())) { smallImageURL = article.getSmallImageURL(); } else if ((themeDisplay != null) && article.isSmallImage()) { StringBundler sb = new StringBundler(5); sb.append(themeDisplay.getPathImage()); sb.append("/journal/article?img_id="); sb.append(article.getSmallImageId()); sb.append("&t="); sb.append(WebServerServletTokenUtil.getToken(article.getSmallImageId())); smallImageURL = sb.toString(); } addReservedEl(rootElement, tokens, JournalStructureConstants.RESERVED_ARTICLE_SMALL_IMAGE_URL, smallImageURL); String[] assetTagNames = AssetTagLocalServiceUtil.getTagNames(JournalArticle.class.getName(), article.getResourcePrimKey()); addReservedEl(rootElement, tokens, JournalStructureConstants.RESERVED_ARTICLE_ASSET_TAG_NAMES, StringUtil.merge(assetTagNames)); addReservedEl(rootElement, tokens, JournalStructureConstants.RESERVED_ARTICLE_AUTHOR_ID, String.valueOf(article.getUserId())); String userName = StringPool.BLANK; String userEmailAddress = StringPool.BLANK; String userComments = StringPool.BLANK; String userJobTitle = StringPool.BLANK; User user = UserLocalServiceUtil.fetchUserById(article.getUserId()); if (user != null) { userName = user.getFullName(); userEmailAddress = user.getEmailAddress(); userComments = user.getComments(); userJobTitle = user.getJobTitle(); } addReservedEl(rootElement, tokens, JournalStructureConstants.RESERVED_ARTICLE_AUTHOR_NAME, userName); addReservedEl(rootElement, tokens, JournalStructureConstants.RESERVED_ARTICLE_AUTHOR_EMAIL_ADDRESS, userEmailAddress); addReservedEl(rootElement, tokens, JournalStructureConstants.RESERVED_ARTICLE_AUTHOR_COMMENTS, userComments); addReservedEl(rootElement, tokens, JournalStructureConstants.RESERVED_ARTICLE_AUTHOR_JOB_TITLE, userJobTitle); }