Exemplo n.º 1
0
  protected String buildEntryURL(BlogsEntry entry, ThemeDisplay themeDisplay)
      throws PortalException {

    StringBundler sb = new StringBundler(4);

    sb.append(PortalUtil.getLayoutFullURL(themeDisplay));
    sb.append(Portal.FRIENDLY_URL_SEPARATOR);
    sb.append("blogs/");
    sb.append(entry.getUrlTitle());

    return sb.toString();
  }
Exemplo n.º 2
0
  private static void _addLayoutBreadcrumbEntries(
      List<BreadcrumbEntry> breadcrumbEntries, ThemeDisplay themeDisplay, Layout layout)
      throws Exception {

    if (layout.getParentLayoutId() != LayoutConstants.DEFAULT_PARENT_LAYOUT_ID) {

      Layout parentLayout = LayoutLocalServiceUtil.getParentLayout(layout);

      _addLayoutBreadcrumbEntries(breadcrumbEntries, themeDisplay, parentLayout);
    }

    BreadcrumbEntry breadcrumbEntry = new BreadcrumbEntry();

    breadcrumbEntry.setBaseModel(layout);

    LayoutType layoutType = layout.getLayoutType();

    if (!layoutType.isBrowsable()) {
      breadcrumbEntry.setBrowsable(false);
    }

    String layoutName = layout.getName(themeDisplay.getLocale());

    if (layout.isTypeControlPanel()) {
      if (layoutName.equals(LayoutConstants.NAME_CONTROL_PANEL_DEFAULT)) {
        layoutName = LanguageUtil.get(themeDisplay.getLocale(), "control-panel");
      }
    }

    breadcrumbEntry.setTitle(layoutName);

    String layoutURL = PortalUtil.getLayoutFullURL(layout, themeDisplay);

    if (themeDisplay.isAddSessionIdToURL()) {
      layoutURL = PortalUtil.getURLWithSessionId(layoutURL, themeDisplay.getSessionId());
    }

    breadcrumbEntry.setURL(layoutURL);

    breadcrumbEntries.add(breadcrumbEntry);
  }
  protected String exportToRSS(
      ResourceRequest resourceRequest,
      ResourceResponse resourceResponse,
      String title,
      String description,
      String format,
      double version,
      String displayStyle,
      List<SocialActivity> socialActivities,
      ServiceContext serviceContext)
      throws Exception {

    ThemeDisplay themeDisplay = (ThemeDisplay) resourceRequest.getAttribute(WebKeys.THEME_DISPLAY);

    SyndFeed syndFeed = new SyndFeedImpl();

    syndFeed.setDescription(GetterUtil.getString(description, title));

    List<SyndEntry> syndEntries = new ArrayList<>();

    syndFeed.setEntries(syndEntries);

    for (SocialActivity socialActivity : socialActivities) {
      SocialActivityFeedEntry socialActivityFeedEntry =
          _socialActivityInterpreterLocalService.interpret(
              StringPool.BLANK, socialActivity, serviceContext);

      if (socialActivityFeedEntry == null) {
        continue;
      }

      SyndEntry syndEntry = new SyndEntryImpl();

      SyndContent syndContent = new SyndContentImpl();

      syndContent.setType(RSSUtil.ENTRY_TYPE_DEFAULT);

      String value = null;

      if (displayStyle.equals(RSSUtil.DISPLAY_STYLE_TITLE)) {
        value = StringPool.BLANK;
      } else {
        value = socialActivityFeedEntry.getBody();
      }

      syndContent.setValue(value);

      syndEntry.setDescription(syndContent);

      if (Validator.isNotNull(socialActivityFeedEntry.getLink())) {
        syndEntry.setLink(socialActivityFeedEntry.getLink());
      }

      syndEntry.setPublishedDate(new Date(socialActivity.getCreateDate()));
      syndEntry.setTitle(HtmlUtil.extractText(socialActivityFeedEntry.getTitle()));
      syndEntry.setUri(syndEntry.getLink());

      syndEntries.add(syndEntry);
    }

    syndFeed.setFeedType(RSSUtil.getFeedType(format, version));

    List<SyndLink> syndLinks = new ArrayList<>();

    syndFeed.setLinks(syndLinks);

    SyndLink selfSyndLink = new SyndLinkImpl();

    syndLinks.add(selfSyndLink);

    LiferayPortletResponse liferayPortletResponse = (LiferayPortletResponse) resourceResponse;

    ResourceURL rssURL = liferayPortletResponse.createResourceURL();

    rssURL.setParameter("feedTitle", title);
    rssURL.setResourceID("rss");

    selfSyndLink.setHref(rssURL.toString());

    selfSyndLink.setRel("self");

    SyndLink alternateSyndLink = new SyndLinkImpl();

    syndLinks.add(alternateSyndLink);

    alternateSyndLink.setHref(PortalUtil.getLayoutFullURL(themeDisplay));
    alternateSyndLink.setRel("alternate");

    syndFeed.setPublishedDate(new Date());
    syndFeed.setTitle(title);
    syndFeed.setUri(rssURL.toString());

    return RSSUtil.export(syndFeed);
  }