List of usage examples for com.liferay.portal.kernel.util PortalUtil getPlidFromPortletId
public static long getPlidFromPortletId(long groupId, boolean privateLayout, String portletId) throws PortalException
From source file:com.liferay.microblogs.web.internal.asset.MicroblogsEntryAssetRenderer.java
License:Open Source License
@Override public String getURLViewInContext(LiferayPortletRequest liferayPortletRequest, LiferayPortletResponse liferayPortletResponse, String noSuchEntryRedirect) { try {/*from w w w . j ava2 s .c o m*/ ThemeDisplay themeDisplay = (ThemeDisplay) liferayPortletRequest.getAttribute(WebKeys.THEME_DISPLAY); User user = themeDisplay.getUser(); long portletPlid = PortalUtil.getPlidFromPortletId(user.getGroupId(), true, MicroblogsPortletKeys.MICROBLOGS); PortletURL portletURL = PortletURLFactoryUtil.create(liferayPortletRequest, MicroblogsPortletKeys.MICROBLOGS, portletPlid, PortletRequest.RENDER_PHASE); portletURL.setParameter("mvcPath", "/html/microblogs/view.jsp"); long microblogsEntryId = _entry.getMicroblogsEntryId(); if (_entry.getParentMicroblogsEntryId() > 0) { microblogsEntryId = _entry.getParentMicroblogsEntryId(); } portletURL.setParameter("parentMicroblogsEntryId", String.valueOf(microblogsEntryId)); return portletURL.toString(); } catch (Exception e) { } return null; }
From source file:com.liferay.microblogs.web.internal.util.MicroblogsWebUtil.java
License:Open Source License
protected static String replaceHashtags(String content, ServiceContext serviceContext) throws PortalException { String escapedContent = HtmlUtil.escape(content); ThemeDisplay themeDisplay = serviceContext.getThemeDisplay(); Matcher matcher = _hashtagPattern.matcher(content); while (matcher.find()) { String result = matcher.group(); StringBuilder sb = new StringBuilder(6); sb.append("<span class=\"hashtag\">#</span>"); sb.append("<a class=\"hashtag-link\" href=\""); PortletURL portletURL = null;//w ww .j a va2 s. c o m Group group = GroupLocalServiceUtil.getUserGroup(themeDisplay.getCompanyId(), themeDisplay.getUserId()); long portletPlid = PortalUtil.getPlidFromPortletId(group.getGroupId(), true, MicroblogsPortletKeys.MICROBLOGS); if (portletPlid != 0) { portletURL = PortletURLFactoryUtil.create(serviceContext.getLiferayPortletRequest(), MicroblogsPortletKeys.MICROBLOGS, portletPlid, PortletRequest.RENDER_PHASE); try { portletURL.setWindowState(LiferayWindowState.NORMAL); } catch (WindowStateException wse) { } } else { LiferayPortletResponse liferayPortletResponse = serviceContext.getLiferayPortletResponse(); portletURL = liferayPortletResponse.createRenderURL(MicroblogsPortletKeys.MICROBLOGS); try { portletURL.setWindowState(WindowState.MAXIMIZED); } catch (WindowStateException wse) { } } portletURL.setParameter("mvcPath", "/microblogs/view.jsp"); String assetTagName = result.substring(1); portletURL.setParameter("tabs1", assetTagName); portletURL.setParameter("assetTagName", assetTagName); sb.append(portletURL); sb.append("\">"); sb.append(assetTagName); sb.append("</a>"); String tagLink = sb.toString(); escapedContent = StringUtil.replace(escapedContent, result, tagLink); } return escapedContent; }