@Override public String getDisplayURL(ThemeDisplay themeDisplay, boolean privateLayout) { if (!privateLayout && (getPublicLayoutsPageCount() > 0)) { try { String groupFriendlyURL = PortalUtil.getGroupFriendlyURL(getPublicLayoutSet(), themeDisplay); return PortalUtil.addPreservedParameters(themeDisplay, groupFriendlyURL); } catch (PortalException pe) { _log.error(pe, pe); } } else if (privateLayout && (getPrivateLayoutsPageCount() > 0)) { try { String groupFriendlyURL = PortalUtil.getGroupFriendlyURL(getPrivateLayoutSet(), themeDisplay); return PortalUtil.addPreservedParameters(themeDisplay, groupFriendlyURL); } catch (PortalException pe) { _log.error(pe); } } return StringPool.BLANK; }
@Override public String getURLViewInContext( LiferayPortletRequest liferayPortletRequest, LiferayPortletResponse liferayPortletResponse, String noSuchEntryRedirect) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) liferayPortletRequest.getAttribute(WebKeys.THEME_DISPLAY); Layout layout = themeDisplay.getLayout(); if (Validator.isNotNull(_article.getLayoutUuid())) { layout = LayoutLocalServiceUtil.getLayoutByUuidAndCompanyId( _article.getLayoutUuid(), _article.getCompanyId()); } String portletId = (String) liferayPortletRequest.getAttribute(WebKeys.PORTLET_ID); PortletPreferences portletSetup = PortletPreferencesFactoryUtil.getLayoutPortletSetup(layout, portletId); String linkToLayoutUuid = GetterUtil.getString(portletSetup.getValue("portletSetupLinkToLayoutUuid", null)); if (Validator.isNotNull(_article.getLayoutUuid()) && Validator.isNull(linkToLayoutUuid)) { Group group = themeDisplay.getScopeGroup(); if (group.getGroupId() != _article.getGroupId()) { group = GroupLocalServiceUtil.getGroup(_article.getGroupId()); } String groupFriendlyURL = PortalUtil.getGroupFriendlyURL(group, layout.isPrivateLayout(), themeDisplay); return PortalUtil.addPreservedParameters( themeDisplay, groupFriendlyURL .concat(JournalArticleConstants.CANONICAL_URL_SEPARATOR) .concat(_article.getUrlTitle())); } List<Long> hitLayoutIds = JournalContentSearchLocalServiceUtil.getLayoutIds( _article.getGroupId(), layout.isPrivateLayout(), _article.getArticleId()); if (!hitLayoutIds.isEmpty()) { Long hitLayoutId = hitLayoutIds.get(0); Layout hitLayout = LayoutLocalServiceUtil.getLayout( _article.getGroupId(), layout.isPrivateLayout(), hitLayoutId.longValue()); return PortalUtil.getLayoutURL(hitLayout, themeDisplay); } return noSuchEntryRedirect; }
protected String updateCloseRedirect( String closeRedirect, Group group, ThemeDisplay themeDisplay, String oldFriendlyURL, String oldStagingFriendlyURL) throws PortalException, SystemException { if (Validator.isNull(closeRedirect) || (group == null)) { return closeRedirect; } String oldPath = null; String newPath = null; if (Validator.isNotNull(oldFriendlyURL)) { oldPath = oldFriendlyURL; newPath = group.getFriendlyURL(); if (closeRedirect.contains(oldPath)) { closeRedirect = PortalUtil.updateRedirect(closeRedirect, oldPath, newPath); } else { closeRedirect = PortalUtil.getGroupFriendlyURL(group, false, themeDisplay); } } if (Validator.isNotNull(oldStagingFriendlyURL)) { Group stagingGroup = group.getStagingGroup(); if (GroupLocalServiceUtil.fetchGroup(stagingGroup.getGroupId()) == null) { oldPath = oldStagingFriendlyURL; newPath = group.getFriendlyURL(); } else { oldPath = oldStagingFriendlyURL; newPath = stagingGroup.getFriendlyURL(); } if (closeRedirect.contains(oldPath)) { closeRedirect = PortalUtil.updateRedirect(closeRedirect, oldPath, newPath); } else { closeRedirect = PortalUtil.getGroupFriendlyURL(group, false, themeDisplay); } } return closeRedirect; }
@Override protected String getPath(SocialActivity activity, ServiceContext serviceContext) throws Exception { JournalArticle article = _journalArticleLocalService.getLatestArticle(activity.getClassPK()); Layout layout = article.getLayout(); if (layout != null) { String groupFriendlyURL = PortalUtil.getGroupFriendlyURL(layout.getLayoutSet(), serviceContext.getThemeDisplay()); return groupFriendlyURL .concat(JournalArticleConstants.CANONICAL_URL_SEPARATOR) .concat(article.getUrlTitle()); } return null; }
protected void visitArticles(Element element, Layout layout, ThemeDisplay themeDisplay) throws PortalException, SystemException { List<JournalArticle> journalArticles = JournalArticleServiceUtil.getArticlesByLayoutUuid(layout.getGroupId(), layout.getUuid()); if (journalArticles.isEmpty()) { return; } Set<String> processedArticleIds = new HashSet<String>(); for (JournalArticle journalArticle : journalArticles) { if (processedArticleIds.contains(journalArticle.getArticleId()) || (journalArticle.getStatus() != WorkflowConstants.STATUS_APPROVED)) { continue; } String portalURL = PortalUtil.getPortalURL(layout, themeDisplay); String groupFriendlyURL = PortalUtil.getGroupFriendlyURL( GroupLocalServiceUtil.getGroup(journalArticle.getGroupId()), false, themeDisplay); StringBundler sb = new StringBundler(4); if (!groupFriendlyURL.startsWith(portalURL)) { sb.append(portalURL); } sb.append(groupFriendlyURL); sb.append(JournalArticleConstants.CANONICAL_URL_SEPARATOR); sb.append(journalArticle.getUrlTitle()); String articleURL = PortalUtil.getCanonicalURL(sb.toString(), themeDisplay, layout); addURLElement( element, articleURL, null, journalArticle.getModifiedDate(), articleURL, getAlternateURLs(articleURL, themeDisplay, layout)); Locale[] availableLocales = LanguageUtil.getAvailableLocales(layout.getGroupId()); if (availableLocales.length > 1) { Locale defaultLocale = LocaleUtil.getSiteDefault(); for (Locale availableLocale : availableLocales) { if (!availableLocale.equals(defaultLocale)) { String alternateURL = PortalUtil.getAlternateURL(articleURL, themeDisplay, availableLocale, layout); addURLElement( element, alternateURL, null, journalArticle.getModifiedDate(), articleURL, getAlternateURLs(articleURL, themeDisplay, layout)); } } } processedArticleIds.add(journalArticle.getArticleId()); } }