List of usage examples for com.liferay.portal.kernel.model User getPortraitURL
public String getPortraitURL(com.liferay.portal.kernel.theme.ThemeDisplay themeDisplay) throws com.liferay.portal.kernel.exception.PortalException;
From source file:com.liferay.blogs.service.impl.BlogsEntryLocalServiceImpl.java
License:Open Source License
protected BlogsEntry startWorkflowInstance(long userId, BlogsEntry entry, ServiceContext serviceContext) throws PortalException { Map<String, Serializable> workflowContext = new HashMap<>(); workflowContext.put(WorkflowConstants.CONTEXT_URL, getEntryURL(entry, serviceContext)); String userPortraitURL = StringPool.BLANK; String userURL = StringPool.BLANK; if (serviceContext.getThemeDisplay() != null) { User user = userPersistence.findByPrimaryKey(userId); userPortraitURL = user.getPortraitURL(serviceContext.getThemeDisplay()); userURL = user.getDisplayURL(serviceContext.getThemeDisplay()); }//from ww w.j a v a 2 s .c o m workflowContext.put(WorkflowConstants.CONTEXT_USER_PORTRAIT_URL, userPortraitURL); workflowContext.put(WorkflowConstants.CONTEXT_USER_URL, userURL); return WorkflowHandlerRegistryUtil.startWorkflowInstance(entry.getCompanyId(), entry.getGroupId(), userId, BlogsEntry.class.getName(), entry.getEntryId(), entry, serviceContext, workflowContext); }
From source file:com.liferay.contacts.web.internal.portlet.ContactsCenterPortlet.java
License:Open Source License
protected JSONObject getUserJSONObject(PortletResponse portletResponse, ThemeDisplay themeDisplay, User user) throws Exception { user = user.toEscapedModel();/* w w w . j a v a 2s .c o m*/ JSONObject jsonObject = ContactsUtil.getUserJSONObject(themeDisplay.getUserId(), user); jsonObject.put("portraitURL", user.getPortraitURL(themeDisplay)); LiferayPortletResponse liferayPortletResponse = portal.getLiferayPortletResponse(portletResponse); PortletURL viewSummaryURL = liferayPortletResponse.createRenderURL(); viewSummaryURL.setParameter("mvcPath", "/contacts_center/view_resources.jsp"); viewSummaryURL.setParameter("userId", String.valueOf(user.getUserId())); viewSummaryURL.setParameter("portalUser", Boolean.TRUE.toString()); viewSummaryURL.setWindowState(LiferayWindowState.EXCLUSIVE); jsonObject.put("viewSummaryURL", viewSummaryURL.toString()); return jsonObject; }
From source file:com.liferay.dynamic.data.mapping.data.provider.web.internal.display.context.DDMDataProviderDisplayContext.java
License:Open Source License
public String getUserPortraitURL(long userId) throws PortalException { User user = _userLocalService.getUser(userId); return user.getPortraitURL(_ddmDataProviderRequestHelper.getThemeDisplay()); }
From source file:com.liferay.frontend.taglib.servlet.taglib.UserVerticalCardTag.java
License:Open Source License
@Override protected void setAttributes(HttpServletRequest request) { super.setAttributes(request); User user = getUser(); request.setAttribute("liferay-frontend:card:colorCssClass", LexiconUtil.getUserColorCssClass(user)); if ((user != null) && (user.getPortraitId() > 0)) { ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); try {/*from www . j a v a 2 s . c o m*/ request.setAttribute("liferay-frontend:card:portraitURL", user.getPortraitURL(themeDisplay)); } catch (PortalException pe) { // LPS-52675 if (_log.isDebugEnabled()) { _log.debug(pe, pe); } } } String initials = StringPool.BLANK; if (user != null) { initials = user.getInitials(); } request.setAttribute("liferay-frontend:card:userInitials", initials); }
From source file:com.liferay.mentions.web.internal.portlet.MentionsPortlet.java
License:Open Source License
protected JSONArray getJSONArray(HttpServletRequest request) throws PortalException { JSONArray jsonArray = JSONFactoryUtil.createJSONArray(); ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); SocialInteractionsConfiguration socialInteractionsConfiguration = SocialInteractionsConfigurationUtil .getSocialInteractionsConfiguration(themeDisplay.getCompanyId(), MentionsPortletKeys.MENTIONS); String query = ParamUtil.getString(request, "query"); List<User> users = _mentionsUserFinder.getUsers(themeDisplay.getCompanyId(), themeDisplay.getUserId(), query, socialInteractionsConfiguration); for (User user : users) { if (user.isDefaultUser() || (themeDisplay.getUserId() == user.getUserId())) { continue; }//w w w . j av a 2 s .co m JSONObject jsonObject = JSONFactoryUtil.createJSONObject(); jsonObject.put("fullName", user.getFullName()); String mention = "@" + user.getScreenName(); String profileURL = user.getDisplayURL(themeDisplay); if (Validator.isNotNull(profileURL)) { mention = StringBundler.concat("<a href=\"", profileURL, "\">@", user.getScreenName(), "</a>"); } jsonObject.put("mention", mention); jsonObject.put("portraitURL", user.getPortraitURL(themeDisplay)); jsonObject.put("screenName", user.getScreenName()); jsonArray.put(jsonObject); } return jsonArray; }
From source file:com.liferay.microblogs.web.internal.util.MicroblogsWebUtil.java
License:Open Source License
public static JSONArray getJSONRecipients(long userId, ThemeDisplay themeDisplay) throws PortalException { JSONArray jsonArray = JSONFactoryUtil.createJSONArray(); List<User> users = UserLocalServiceUtil.getSocialUsers(userId, SocialRelationConstants.TYPE_BI_CONNECTION, QueryUtil.ALL_POS, QueryUtil.ALL_POS, new UserFirstNameComparator(true)); for (User user : users) { if (user.isDefaultUser() || (userId == user.getUserId())) { continue; }/*from w ww. j a v a 2s. co m*/ JSONObject userJSONObject = JSONFactoryUtil.createJSONObject(); userJSONObject.put("emailAddress", user.getEmailAddress()); userJSONObject.put("fullName", user.getFullName()); userJSONObject.put("jobTitle", user.getJobTitle()); userJSONObject.put("portraitURL", user.getPortraitURL(themeDisplay)); userJSONObject.put("screenName", user.getScreenName()); userJSONObject.put("userId", user.getUserId()); jsonArray.put(userJSONObject); } return jsonArray; }
From source file:com.liferay.recommend.service.impl.RecommendEntityLocalServiceImpl.java
License:Open Source License
/** * NOTE FOR DEVELOPERS:/* w ww . j a va 2 s . c o m*/ * * Never reference this class directly. Always use {@link com.liferay.recommend.service.RecommendEntityLocalServiceUtil} to access the recommend entity local service. */ private JSONArray _createJsonArrayFromWikiPageAssetEntries(ServiceContext serviceContext, List<AssetEntry> topViewedEntries) { JSONArray recommendationsJSONArray = JSONFactoryUtil.createJSONArray(); WikiTextExtractor wikiTextExtractor = new WikiTextExtractor(); wikiTextExtractor.setTitleSeparator("|"); for (AssetEntry assetEntry : topViewedEntries) { if (_log.isDebugEnabled()) { _log.debug("Top Entry: " + assetEntry); } AssetRenderer<?> assetRenderer = assetEntry.getAssetRenderer(); if ((assetRenderer != null) && (assetRenderer.getAssetObject() instanceof WikiPage)) { WikiPage wikiPage = (WikiPage) assetRenderer.getAssetObject(); String userPortraitUrl = null; try { ThemeDisplay themeDisplay = new ThemeDisplay(); User user = _userLocalService.fetchUser(assetEntry.getUserId()); userPortraitUrl = user.getPortraitURL(themeDisplay); } catch (PortalException pe) { _log.error("Error while retrieving user portrait URL", pe); } String url = serviceContext.getPortalURL() + "/share/" + _getNormalizedTitle(assetEntry.getTitle()); JSONObject entryJSONObject = JSONFactoryUtil.createJSONObject(); entryJSONObject.put("id", assetEntry.getClassPK()); entryJSONObject.put("userName", assetEntry.getUserName()); entryJSONObject.put("viewCount", assetEntry.getViewCount()); entryJSONObject.put("title", assetEntry.getTitle()); entryJSONObject.put("contentSample", wikiTextExtractor.truncateWikiContent(wikiPage.getContent(), wikiPage.getFormat(), 1000)); entryJSONObject.put("url", url); entryJSONObject.put("userPortraitUrl", userPortraitUrl); recommendationsJSONArray.put(entryJSONObject); } } return recommendationsJSONArray; }