List of usage examples for com.liferay.portal.kernel.model User getDisplayURL
public String getDisplayURL(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 w w w . j a v a 2s .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.notifications.ContactsCenterUserNotificationHandler.java
License:Open Source License
protected String getUserNameLink(long userId, ServiceContext serviceContext) { try {//from ww w.j a v a2 s . co m if (userId <= 0) { return StringPool.BLANK; } User user = _userLocalService.getUserById(userId); String userName = user.getFullName(); String userDisplayURL = user.getDisplayURL(serviceContext.getThemeDisplay()); return StringBundler.concat("<a href=\"", userDisplayURL, "\">", HtmlUtil.escape(userName), "</a>"); } catch (Exception e) { return StringPool.BLANK; } }
From source file:com.liferay.flags.internal.messaging.FlagsRequestMessageListener.java
License:Open Source License
@Override protected void doReceive(Message message) throws Exception { FlagsRequest flagsRequest = (FlagsRequest) message.getPayload(); // Service context ServiceContext serviceContext = flagsRequest.getServiceContext(); // Company/*from www. ja v a2s .com*/ long companyId = serviceContext.getCompanyId(); Company company = _companyLocalService.getCompany(serviceContext.getCompanyId()); // Group Layout layout = _layoutLocalService.getLayout(serviceContext.getPlid()); Group group = layout.getGroup(); // Reporter user String reporterUserName = null; String reporterEmailAddress = null; User reporterUser = _userLocalService.getUserById(serviceContext.getUserId()); Locale locale = LocaleUtil.getDefault(); if (reporterUser.isDefaultUser()) { reporterUserName = LanguageUtil.get(locale, "anonymous"); } else { reporterUserName = reporterUser.getFullName(); reporterEmailAddress = reporterUser.getEmailAddress(); } // Reported user String reportedUserName = StringPool.BLANK; String reportedEmailAddress = StringPool.BLANK; String reportedURL = StringPool.BLANK; User reportedUser = _userLocalService.getUserById(flagsRequest.getReportedUserId()); if (reportedUser.isDefaultUser()) { reportedUserName = group.getDescriptiveName(); } else { reportedUserName = reportedUser.getFullName(); reportedEmailAddress = reportedUser.getEmailAddress(); reportedURL = reportedUser.getDisplayURL(serviceContext.getThemeDisplay()); } // Content String contentType = ResourceActionsUtil.getModelResource(locale, flagsRequest.getClassName()); // Reason String reason = LanguageUtil.get(locale, flagsRequest.getReason()); // Email FlagsGroupServiceConfiguration flagsGroupServiceConfiguration = ConfigurationProviderUtil .getCompanyConfiguration(FlagsGroupServiceConfiguration.class, companyId); String fromName = flagsGroupServiceConfiguration.emailFromName(); String fromAddress = flagsGroupServiceConfiguration.emailFromAddress(); String subject = ContentUtil.get(FlagsRequestMessageListener.class.getClassLoader(), flagsGroupServiceConfiguration.emailSubject()); String body = ContentUtil.get(FlagsRequestMessageListener.class.getClassLoader(), flagsGroupServiceConfiguration.emailBody()); // Recipients Set<User> recipients = getRecipients(companyId, serviceContext.getScopeGroupId()); for (User recipient : recipients) { try { notify(reporterUser.getUserId(), company, group, reporterEmailAddress, reporterUserName, reportedEmailAddress, reportedUserName, reportedURL, flagsRequest.getClassPK(), flagsRequest.getContentTitle(), contentType, flagsRequest.getContentURL(), reason, fromName, fromAddress, recipient.getFullName(), recipient.getEmailAddress(), subject, body, serviceContext); } catch (IOException ioe) { if (_log.isWarnEnabled()) { _log.warn(ioe); } } } }
From source file:com.liferay.invitation.invite.members.web.internal.notifications.InviteMembersUserNotificationHandler.java
License:Open Source License
protected String getUserNameLink(long userId, ServiceContext serviceContext) { try {/*w w w . jav a 2 s. c o m*/ if (userId <= 0) { return StringPool.BLANK; } User user = _userLocalService.getUserById(userId); String userName = user.getFullName(); String userDisplayURL = user.getDisplayURL(serviceContext.getThemeDisplay()); return "<a href=\"" + userDisplayURL + "\">" + HtmlUtil.escape(userName) + "</a>"; } catch (Exception e) { return StringPool.BLANK; } }
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; }/*from w w w . j a va 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
protected static String replaceUserTags(String content, ServiceContext serviceContext) throws PortalException { Matcher matcher = _userTagPattern.matcher(content); while (matcher.find()) { String result = matcher.group(); try {// ww w. j ava 2s.com StringBuilder sb = new StringBuilder(5); sb.append("<a href=\""); String assetTagScreenName = result.replace("[@", StringPool.BLANK); assetTagScreenName = assetTagScreenName.replace("]", StringPool.BLANK); ThemeDisplay themeDisplay = serviceContext.getThemeDisplay(); User assetTagUser = UserLocalServiceUtil.getUserByScreenName(themeDisplay.getCompanyId(), assetTagScreenName); sb.append(assetTagUser.getDisplayURL(themeDisplay)); sb.append("\">"); String assetTagUserName = PortalUtil.getUserName(assetTagUser.getUserId(), assetTagScreenName); sb.append(assetTagUserName); sb.append("</a>"); String userLink = sb.toString(); content = StringUtil.replace(content, result, userLink); } catch (NoSuchUserException nsue) { if (_log.isDebugEnabled()) { _log.debug(nsue, nsue); } } } return content; }