Example #1
0
 public static SyndContent createRssNewsDescription(LabsNews news) throws ClientException {
   SyndContent description;
   description = new SyndContentImpl();
   description.setType("text/html");
   if (!StringUtils.isEmpty(news.getAccroche())) {
     description.setValue(news.getAccroche());
   } else if (contentNewsIsInRow(news)) {
     description.setValue(news.getRows().get(0).content(0).getHtml());
   } else {
     description.setValue(news.getContent());
   }
   return description;
 }
 private SyndContent createSyndContent(CMTeasable teasable) {
   String textPlain = getText(teasable);
   SyndContent syndContent = new SyndContentImpl();
   syndContent.setType("text/plain");
   syndContent.setValue(textPlain == null ? "" : textPlain);
   return syndContent;
 }
Example #3
0
  private SyndFeed createFeed() {

    SyndFeed feed = new SyndFeedImpl();

    SyndPerson auteur = new SyndPersonImpl();
    auteur.setName("Gildas Cuisinier");
    auteur.setEmail("*****@*****.**");

    feed.setTitle("RSS Veille Techno");
    feed.setAuthors(Collections.singletonList(auteur));
    feed.setDescription("RSS d'exemple !");
    feed.setLink("http://svn.cyg.be/");
    feed.setPublishedDate(new Date());
    feed.setLanguage("fr");

    SyndEntry entry = new SyndEntryImpl();
    entry.setTitle("Ajout du projet Rome sur le SVN");
    entry.setLink("https://rome.dev.java.net/");

    SyndContent description = new SyndContentImpl();
    description.setValue("Ajout d'un projet Rome sur le SVN afin de voir comment creer un RSS");
    description.setType("text");
    entry.setDescription(description);
    entry.setAuthors(Collections.singletonList(auteur));

    feed.getEntries().add(entry);

    return feed;
  }
 private List getFeedEntries(Collection entries) {
   List syndEntries = new ArrayList();
   try {
     List calendarEntries = new ArrayList(entries);
     CalendarEntry calEntry = null;
     for (int i = 0; i < entries.size(); i++) {
       SyndEntry sEntry = new SyndEntryImpl();
       calEntry = (CalendarEntry) calendarEntries.get(i);
       SyndContent scont = new SyndContentImpl();
       String content =
           "Name: "
               + calEntry.getName()
               + " Type: "
               + calEntry.getEntryTypeName()
               + " From: "
               + calEntry.getDate()
               + " To: "
               + calEntry.getEndDate();
       scont.setValue(content);
       sEntry.setTitle(calEntry.getName());
       sEntry.setDescription(scont);
       sEntry.setPublishedDate(calEntry.getDate());
       syndEntries.add(sEntry);
     }
   } catch (RuntimeException e1) {
     // TODO Auto-generated catch block
     e1.printStackTrace();
   }
   return syndEntries;
 }
  @Override
  protected void createFeed(SyndFeed feed, Map model) {
    @SuppressWarnings("unchecked")
    List<PreparedUserEvent> list = (List<PreparedUserEvent>) model.get("topicsList");
    String s = "Ответы на комментарии пользователя " + model.get("nick");
    feed.setTitle(s);
    feed.setLink("http://www.linux.org.ru");
    feed.setUri("http://www.linux.org.ru");
    feed.setAuthor("");
    feed.setDescription(s);

    Date lastModified;
    if (!list.isEmpty()) {
      lastModified = list.get(0).getEvent().getEventDate();
    } else {
      lastModified = new Date();
    }
    feed.setPublishedDate(lastModified);

    List<SyndEntry> entries = new ArrayList<>();
    feed.setEntries(entries);
    for (PreparedUserEvent preparedUserEvent : list) {
      UserEvent item = preparedUserEvent.getEvent();

      SyndEntry feedEntry = new SyndEntryImpl();
      feedEntry.setPublishedDate(item.getEventDate());
      feedEntry.setTitle(StringEscapeUtils.unescapeHtml4(item.getSubj()));

      String link;

      if (item.getCid() != 0) {
        feedEntry.setAuthor(preparedUserEvent.getAuthor().getNick());

        link =
            String.format(
                "http://www.linux.org.ru/jump-message.jsp?msgid=%s&cid=%s",
                String.valueOf(item.getTopicId()), String.valueOf(item.getCid()));
      } else {
        link =
            String.format(
                "http://www.linux.org.ru/view-message.jsp?msgid=%s",
                String.valueOf(item.getTopicId()));
      }

      feedEntry.setLink(link);
      feedEntry.setUri(link);

      if (preparedUserEvent.getMessageText() != null) {
        SyndContent message = new SyndContentImpl();
        message.setValue(StringUtil.removeInvalidXmlChars(preparedUserEvent.getMessageText()));
        message.setType("text/html");
        feedEntry.setDescription(message);
      }
      entries.add(feedEntry);
    }
  }
 protected SyndEntry createSyndEntry(Item item) {
   SyndEntry syndEntry = super.createSyndEntry(item);
   Description desc = item.getDescription();
   if (desc != null) {
     SyndContent descContent = new SyndContentImpl();
     descContent.setType(desc.getType());
     descContent.setValue(desc.getValue());
     syndEntry.setDescription(descContent);
   }
   Content cont = item.getContent();
   if (cont != null) {
     SyndContent content = new SyndContentImpl();
     content.setType(cont.getType());
     content.setValue(cont.getValue());
     List syndContents = new ArrayList();
     syndContents.add(content);
     syndEntry.setContents(syndContents);
   }
   return syndEntry;
 }
Example #7
0
  @Override
  public void execute(WebScriptRequest req, WebScriptResponse res) throws IOException {
    Writer writer = null;
    try {
      writer = res.getWriter();

      // Get the section placed in the request context by ApplicationDataInterceptor
      RequestContext requestContext = ThreadLocalRequestContext.getRequestContext();
      Section section = (Section) requestContext.getValue("section");
      WebSite webSite = (WebSite) requestContext.getValue("webSite");

      // Get the collection property from the page definition
      String collectionName = requestContext.getPage().getProperty("collection");
      if (collectionName == null)
        throw new WebScriptException("collectionName property must be supplied");

      // Fetch the named collection
      AssetCollection collection =
          (AssetCollection) collectionFactory.getCollection(section.getId(), collectionName);

      // Use ROME library to output the colleciton as a syndication feed
      SyndFeed feed = new SyndFeedImpl();
      feed.setFeedType(FEED_TYPE);

      feed.setTitle(section.getTitle());
      feed.setLink(urlUtils.getWebsiteDomain(webSite) + urlUtils.getUrl(section));
      feed.setDescription(section.getDescription());

      List<SyndEntry> entries = new ArrayList<SyndEntry>();
      for (Asset asset : collection.getAssets()) {
        SyndEntry entry = new SyndEntryImpl();
        entry.setTitle(asset.getTitle());
        entry.setLink(urlUtils.getWebsiteDomain(webSite) + urlUtils.getUrl(asset));
        entry.setUri(urlUtils.getWebsiteDomain(webSite) + urlUtils.getShortUrl(asset));
        entry.setPublishedDate((Date) asset.getProperties().get(Asset.PROPERTY_PUBLISHED_TIME));
        SyndContent description = new SyndContentImpl();
        description.setType("text/html");
        description.setValue(asset.getDescription());
        entry.setDescription(description);
        entries.add(entry);
      }
      feed.setEntries(entries);

      SyndFeedOutput output = new SyndFeedOutput();
      output.output(feed, writer);
      writer.flush();
    } catch (IOException e) {
      log.error("Unable to output rss", e);
    } catch (FeedException e) {
      log.error("Unable to output rss", e);
    }
  }
Example #8
0
 public static SyndFeed create(
     List<Bookmark> bookmarks,
     String author,
     String title,
     String link,
     Date pubDate,
     String feedUri) {
   logger.debug("SyndFeedFactory create method called");
   logger.debug("bookmarks=" + bookmarks);
   logger.debug("author=" + author);
   logger.debug("title=" + title);
   logger.debug("link=" + link);
   logger.debug("pubDate=" + pubDate);
   logger.debug("feedUri=" + feedUri);
   SyndFeed syndFeed = new SyndFeedImpl();
   syndFeed.setAuthor(author);
   syndFeed.setTitle(title);
   syndFeed.setUri(feedUri);
   syndFeed.setLink(link);
   syndFeed.setPublishedDate(pubDate);
   List<SyndEntry> entries = new ArrayList<SyndEntry>();
   for (Bookmark bmark : bookmarks) {
     SyndEntry entry = new SyndEntryImpl();
     entry.setTitle(bmark.getTitle());
     entry.setAuthor(bmark.getUser().getUsername());
     entry.setLink(bmark.getLink().getUrl());
     entry.setUri("urn:bookmark:" + bmark.getId());
     entry.setUpdatedDate(bmark.getLastUpdated());
     List<String> tags = bmark.getTagList();
     List<SyndCategory> cats = new ArrayList<SyndCategory>();
     for (String aTag : tags) {
       SyndCategory aCat = new SyndCategoryImpl();
       aCat.setName(aTag);
       cats.add(aCat);
     }
     if (cats.isEmpty() == false) {
       entry.setCategories(cats);
     }
     SyndContent cnt = new SyndContentImpl();
     cnt.setType("text/html");
     cnt.setValue(bmark.getNotes());
     entry.setDescription(cnt);
     entries.add(entry);
   }
   syndFeed.setEntries(entries);
   syndFeed.setEncoding("UTF-8");
   logger.debug("done initializing syndFeed object");
   return syndFeed;
 }
Example #9
0
 public static SyndFeed createFromBookmarkDoc(
     List<BookmarkDoc> bookmarks,
     String author,
     String title,
     String link,
     Date pubDate,
     String feedUri) {
   logger.debug("SyndFeedFactory create method called");
   logger.debug("bookmarks=" + bookmarks);
   logger.debug("author=" + author);
   logger.debug("title=" + title);
   logger.debug("link=" + link);
   logger.debug("pubDate=" + pubDate);
   logger.debug("feedUri=" + feedUri);
   SyndFeed syndFeed = new SyndFeedImpl();
   syndFeed.setAuthor(author);
   syndFeed.setTitle(title);
   syndFeed.setUri(feedUri);
   syndFeed.setLink(link);
   syndFeed.setPublishedDate(pubDate);
   List<SyndEntry> entries = new ArrayList<SyndEntry>();
   for (BookmarkDoc bmark : bookmarks) {
     SyndEntry entry = new SyndEntryImpl();
     entry.setTitle(bmark.getTitle());
     entry.setAuthor(bmark.getUsername());
     entry.setLink(bmark.getUrl());
     entry.setUri("urn-x:gnizr:bookmark:" + bmark.getBookmarkId());
     SyndContent cnt = new SyndContentImpl();
     cnt.setType("text/html");
     if (bmark.getNotes() != null) {
       cnt.setValue(bmark.getNotes());
       entry.setDescription(cnt);
     }
     entries.add(entry);
   }
   syndFeed.setEntries(entries);
   syndFeed.setEncoding("UTF-8");
   logger.debug("done initializing syndFeed object");
   return syndFeed;
 }
  protected SyndEntry createSyndEntry(Item item) {
    SyndEntry syndEntry = new SyndEntryImpl();

    syndEntry.setModules(ModuleUtils.cloneModules(item.getModules()));

    if (((List) item.getForeignMarkup()).size() > 0) {
      syndEntry.setForeignMarkup(item.getForeignMarkup());
    }

    syndEntry.setUri(item.getUri());
    syndEntry.setLink(item.getLink());
    syndEntry.setTitle(item.getTitle());
    if (item.getDescription() != null) {
      SyndContent description = new SyndContentImpl();
      description.setValue(item.getDescription().getValue());
      syndEntry.setDescription(description);
    }
    if (item.getAuthor() != null) syndEntry.setAuthor(item.getAuthor());
    if (item.getPubDate() != null) syndEntry.setPublishedDate(item.getPubDate());
    syndEntry.setCategories(item.getCategories());
    return syndEntry;
  }
Example #11
0
  protected String exportToRSS(
      PortletRequest portletRequest,
      PortletResponse portletResponse,
      String name,
      String description,
      String type,
      double version,
      String displayStyle,
      String linkBehavior,
      List<AssetEntry> assetEntries)
      throws Exception {

    SyndFeed syndFeed = new SyndFeedImpl();

    syndFeed.setFeedType(RSSUtil.getFeedType(type, version));
    syndFeed.setTitle(name);
    syndFeed.setLink(getFeedURL(portletRequest));
    syndFeed.setDescription(GetterUtil.getString(description, name));

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

    syndFeed.setEntries(syndEntries);

    for (AssetEntry assetEntry : assetEntries) {
      String link = getEntryURL(portletRequest, portletResponse, linkBehavior, assetEntry);

      String author = PortalUtil.getUserName(assetEntry);

      String value = null;

      String languageId = LanguageUtil.getLanguageId(portletRequest);

      if (displayStyle.equals(RSSUtil.DISPLAY_STYLE_TITLE)) {
        value = StringPool.BLANK;
      } else {
        value = assetEntry.getSummary(languageId, true);
      }

      SyndEntry syndEntry = new SyndEntryImpl();

      syndEntry.setAuthor(author);

      syndEntry.setTitle(assetEntry.getTitle(languageId, true));

      syndEntry.setLink(link);
      syndEntry.setUri(syndEntry.getLink());
      syndEntry.setPublishedDate(assetEntry.getCreateDate());
      syndEntry.setUpdatedDate(assetEntry.getModifiedDate());

      SyndContent syndContent = new SyndContentImpl();

      syndContent.setType(RSSUtil.ENTRY_TYPE_DEFAULT);
      syndContent.setValue(value);

      syndEntry.setDescription(syndContent);

      syndEntries.add(syndEntry);
    }

    return RSSUtil.export(syndFeed);
  }
  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);
  }
  protected String exportToRSS(
      String name,
      String description,
      String type,
      double version,
      String displayStyle,
      String feedURL,
      String entryURL,
      List blogsEntries)
      throws SystemException {

    SyndFeed syndFeed = new SyndFeedImpl();

    syndFeed.setFeedType(type + "_" + version);
    syndFeed.setTitle(name);
    syndFeed.setLink(feedURL);
    syndFeed.setDescription(GetterUtil.getString(description, name));

    List entries = new ArrayList();

    syndFeed.setEntries(entries);

    Iterator itr = blogsEntries.iterator();

    while (itr.hasNext()) {
      BlogsEntry entry = (BlogsEntry) itr.next();

      String author = PortalUtil.getUserName(entry.getUserId(), entry.getUserName());

      String link = entryURL;

      if (link.endsWith("/blogs/rss")) {
        link = link.substring(0, link.length() - 3) + entry.getUrlTitle();
      } else {
        if (!link.endsWith("?")) {
          link += "&";
        }

        link += "entryId=" + entry.getEntryId();
      }

      String value = null;

      if (displayStyle.equals(RSSUtil.DISPLAY_STYLE_ABSTRACT)) {
        value =
            StringUtil.shorten(
                Html.stripHtml(entry.getContent()), _RSS_ABSTRACT_LENGTH, StringPool.BLANK);
      } else {
        value = entry.getContent();
      }

      SyndEntry syndEntry = new SyndEntryImpl();

      syndEntry.setAuthor(author);
      syndEntry.setTitle(entry.getTitle());
      syndEntry.setLink(link);
      syndEntry.setPublishedDate(entry.getCreateDate());

      SyndContent syndContent = new SyndContentImpl();

      syndContent.setType("html");
      syndContent.setValue(value);

      syndEntry.setDescription(syndContent);

      entries.add(syndEntry);
    }

    try {
      return RSSUtil.export(syndFeed);
    } catch (FeedException fe) {
      throw new SystemException(fe);
    } catch (IOException ioe) {
      throw new SystemException(ioe);
    }
  }
  protected String exportToRSS(
      long companyId,
      String name,
      String description,
      String type,
      double version,
      String displayStyle,
      String feedURL,
      String entryURL,
      List<WikiPage> pages,
      boolean diff,
      Locale locale)
      throws SystemException {

    SyndFeed syndFeed = new SyndFeedImpl();

    syndFeed.setFeedType(RSSUtil.getFeedType(type, version));
    syndFeed.setTitle(name);
    syndFeed.setLink(feedURL);
    syndFeed.setDescription(description);

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

    syndFeed.setEntries(syndEntries);

    WikiPage latestPage = null;

    StringBundler link = new StringBundler(7);

    for (WikiPage page : pages) {
      String author = HtmlUtil.escape(PortalUtil.getUserName(page.getUserId(), page.getUserName()));

      String title = page.getTitle() + StringPool.SPACE + page.getVersion();

      if (page.isMinorEdit()) {
        title +=
            StringPool.SPACE
                + StringPool.OPEN_PARENTHESIS
                + LanguageUtil.get(locale, "minor-edit")
                + StringPool.CLOSE_PARENTHESIS;
      }

      link.setIndex(0);

      link.append(entryURL);
      link.append(StringPool.AMPERSAND);
      link.append(HttpUtil.encodeURL(page.getTitle()));

      SyndEntry syndEntry = new SyndEntryImpl();

      syndEntry.setAuthor(author);
      syndEntry.setTitle(title);
      syndEntry.setPublishedDate(page.getCreateDate());
      syndEntry.setUpdatedDate(page.getModifiedDate());

      SyndContent syndContent = new SyndContentImpl();

      syndContent.setType(RSSUtil.ENTRY_TYPE_DEFAULT);

      if (diff) {
        if (latestPage != null) {
          link.append(StringPool.QUESTION);
          link.append(PortalUtil.getPortletNamespace(PortletKeys.WIKI));
          link.append("version=");
          link.append(page.getVersion());

          String value = getPageDiff(companyId, latestPage, page, locale);

          syndContent.setValue(value);

          syndEntry.setDescription(syndContent);

          syndEntries.add(syndEntry);
        }
      } else {
        String value = null;

        if (displayStyle.equals(RSSUtil.DISPLAY_STYLE_ABSTRACT)) {
          value =
              StringUtil.shorten(
                  HtmlUtil.extractText(page.getContent()),
                  PropsValues.WIKI_RSS_ABSTRACT_LENGTH,
                  StringPool.BLANK);
        } else if (displayStyle.equals(RSSUtil.DISPLAY_STYLE_TITLE)) {
          value = StringPool.BLANK;
        } else {
          value = page.getContent();
        }

        syndContent.setValue(value);

        syndEntry.setDescription(syndContent);

        syndEntries.add(syndEntry);
      }

      syndEntry.setLink(link.toString());
      syndEntry.setUri(syndEntry.getLink());

      latestPage = page;
    }

    try {
      return RSSUtil.export(syndFeed);
    } catch (FeedException fe) {
      throw new SystemException(fe);
    }
  }
  protected String exportToRSS(
      String name,
      String description,
      String type,
      double version,
      String displayStyle,
      String feedURL,
      String entryURL,
      List<MBMessage> messages,
      ThemeDisplay themeDisplay)
      throws SystemException {

    SyndFeed syndFeed = new SyndFeedImpl();

    syndFeed.setDescription(description);

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

    syndFeed.setEntries(syndEntries);

    for (MBMessage message : messages) {
      SyndEntry syndEntry = new SyndEntryImpl();

      if (!message.isAnonymous()) {
        String author = PortalUtil.getUserName(message);

        syndEntry.setAuthor(author);
      }

      SyndContent syndContent = new SyndContentImpl();

      syndContent.setType(RSSUtil.ENTRY_TYPE_DEFAULT);

      String value = null;

      if (displayStyle.equals(RSSUtil.DISPLAY_STYLE_ABSTRACT)) {
        value =
            StringUtil.shorten(
                HtmlUtil.extractText(message.getBody()),
                PropsValues.MESSAGE_BOARDS_RSS_ABSTRACT_LENGTH,
                StringPool.BLANK);
      } else if (displayStyle.equals(RSSUtil.DISPLAY_STYLE_TITLE)) {
        value = StringPool.BLANK;
      } else if (message.isFormatBBCode()) {
        value = BBCodeTranslatorUtil.getHTML(message.getBody());

        value = MBUtil.replaceMessageBodyPaths(themeDisplay, value);
      } else {
        value = message.getBody();
      }

      syndContent.setValue(value);

      syndEntry.setDescription(syndContent);

      syndEntry.setLink(entryURL + "&messageId=" + message.getMessageId());
      syndEntry.setPublishedDate(message.getCreateDate());
      syndEntry.setTitle(message.getSubject());
      syndEntry.setUpdatedDate(message.getModifiedDate());
      syndEntry.setUri(syndEntry.getLink());

      syndEntries.add(syndEntry);
    }

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

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

    syndFeed.setLinks(syndLinks);

    SyndLink selfSyndLink = new SyndLinkImpl();

    syndLinks.add(selfSyndLink);

    selfSyndLink.setHref(feedURL);
    selfSyndLink.setRel("self");

    syndFeed.setPublishedDate(new Date());
    syndFeed.setTitle(name);
    syndFeed.setUri(feedURL);

    try {
      return RSSUtil.export(syndFeed);
    } catch (FeedException fe) {
      throw new SystemException(fe);
    }
  }
Example #16
0
  protected static String exportToRSS(
      PortletRequest portletRequest,
      PortletResponse portletResponse,
      String name,
      String description,
      String format,
      double version,
      String displayStyle,
      String linkBehavior,
      List<AssetEntry> assetEntries)
      throws Exception {

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

    SyndFeed syndFeed = new SyndFeedImpl();

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

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

    syndFeed.setEntries(syndEntries);

    for (AssetEntry assetEntry : assetEntries) {
      SyndEntry syndEntry = new SyndEntryImpl();

      String author = PortalUtil.getUserName(assetEntry);

      syndEntry.setAuthor(author);

      SyndContent syndContent = new SyndContentImpl();

      syndContent.setType(RSSUtil.ENTRY_TYPE_DEFAULT);

      String value = null;

      String languageId = LanguageUtil.getLanguageId(portletRequest);

      if (displayStyle.equals(RSSUtil.DISPLAY_STYLE_TITLE)) {
        value = StringPool.BLANK;
      } else {
        value = assetEntry.getSummary(languageId, true);
      }

      syndContent.setValue(value);

      syndEntry.setDescription(syndContent);

      String link = getEntryURL(portletRequest, portletResponse, linkBehavior, assetEntry);

      syndEntry.setLink(link);

      syndEntry.setPublishedDate(assetEntry.getPublishDate());
      syndEntry.setTitle(assetEntry.getTitle(languageId, true));
      syndEntry.setUpdatedDate(assetEntry.getModifiedDate());
      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);

    String feedURL = getFeedURL(portletRequest);

    selfSyndLink.setHref(feedURL);

    selfSyndLink.setRel("self");

    SyndLink alternateSyndLink = new SyndLinkImpl();

    syndLinks.add(alternateSyndLink);

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

    syndFeed.setPublishedDate(new Date());
    syndFeed.setTitle(name);
    syndFeed.setUri(feedURL);

    return RSSUtil.export(syndFeed);
  }
Example #17
0
  // Logs a new ATOM entry
  public static synchronized void addATOMEntry(
      String title, String link, String description, File atomFile, String context) {
    try {

      if (atomFile.exists()) {

        // System.out.println("ATOM file found!");
        /** Namespace URI for content:encoded elements */
        String CONTENT_NS = "http://www.w3.org/2005/Atom";

        /** Parses RSS or Atom to instantiate a SyndFeed. */
        SyndFeedInput input = new SyndFeedInput();

        /** Transforms SyndFeed to RSS or Atom XML. */
        SyndFeedOutput output = new SyndFeedOutput();

        // Load the feed, regardless of RSS or Atom type
        SyndFeed feed = input.build(new XmlReader(atomFile));

        // Set the output format of the feed
        feed.setFeedType("atom_1.0");

        List<SyndEntry> items = feed.getEntries();
        int numItems = items.size();
        if (numItems > 9) {
          items.remove(0);
          feed.setEntries(items);
        }

        SyndEntry newItem = new SyndEntryImpl();
        newItem.setTitle(title);
        newItem.setLink(link);
        newItem.setUri(link);
        SyndContent desc = new SyndContentImpl();
        desc.setType("text/html");
        desc.setValue(description);
        newItem.setDescription(desc);
        desc.setType("text/html");
        newItem.setPublishedDate(new java.util.Date());

        List<SyndCategory> categories = new ArrayList<SyndCategory>();
        if (CommonConfiguration.getProperty("htmlTitle", context) != null) {
          SyndCategory category2 = new SyndCategoryImpl();
          category2.setName(CommonConfiguration.getProperty("htmlTitle", context));
          categories.add(category2);
        }
        newItem.setCategories(categories);
        if (CommonConfiguration.getProperty("htmlAuthor", context) != null) {
          newItem.setAuthor(CommonConfiguration.getProperty("htmlAuthor", context));
        }
        items.add(newItem);
        feed.setEntries(items);

        feed.setPublishedDate(new java.util.Date());

        FileWriter writer = new FileWriter(atomFile);
        output.output(feed, writer);
        writer.toString();
      }
    } catch (IOException ioe) {
      System.out.println("ERROR: Could not find the ATOM file.");
      ioe.printStackTrace();
    } catch (Exception e) {
      System.out.println("Unknown exception trying to add an entry to the ATOM file.");
      e.printStackTrace();
    }
  }
  /** Fills in the feed and entry-level metadata from DSpace objects. */
  public void populate(HttpServletRequest request, SummaryStatBean bean) {
    Locale locale = request.getLocale();
    ResourceBundle msgs = ResourceBundle.getBundle("Messages", locale);

    int type = bean.getType();
    int freq = bean.getFreq();

    // String logoURL = ConfigurationManager
    // .getProperty("webui.feed.stats.logo.url");
    String objectURL = bean.getObjectURL();

    feed.setTitle(
        MessageFormat.format(
            localize(msgs, MSG_FEED_TITLE, freq, type, null, null), bean.getObjectName()));
    feed.setDescription(
        MessageFormat.format(
            localize(msgs, MSG_FEED_DESCRIPTION, freq, type, null, null), bean.getObjectName()));
    feed.setLink(objectURL);
    feed.setPublishedDate(new Date());
    feed.setUri(objectURL);

    // // add logo if we found one:
    // if (logoURL != null)
    // {
    // // we use the path to the logo for this, the logo itself cannot
    // // be contained in the rdf. Not all RSS-viewers show this logo.
    // SyndImage image = new SyndImageImpl();
    // image.setLink(objectURL);
    // image.setTitle(localize(labels, MSG_LOGO_TITLE, freq, type));
    // image.setUrl(logoURL);
    // feed.setImage(image);
    // }

    // add entries for items
    if (bean.getData() != null) {
      List<SyndEntry> entries = new ArrayList<SyndEntry>();
      for (SummaryStatBean.StatDataBean dataBean : bean.getData()) {
        Date date = dataBean.getDate();

        SyndEntry entry = new SyndEntryImpl();
        entries.add(entry);

        // all the feed has the same url... details on the statistics
        // page
        entry.setLink(bean.getStatURL() + "&freq=" + bean.getFreq() + "&date=" + date.getTime());
        // entry.setUri();

        entry.setTitle(
            MessageFormat.format(
                localize(msgs, MSG_ENTRY_TITLE, freq, type, null, null),
                bean.getObjectName(),
                dataBean.getDate()));

        Calendar c1 = Calendar.getInstance();
        c1.setTime(date);
        if (bean.getFreq() != StatSubscription.FREQUENCY_MONTHLY) {
          c1.add(Calendar.DAY_OF_MONTH, 1);
        } else {
          c1.add(Calendar.MONTH, 1);
        }
        date = c1.getTime();
        entry.setPublishedDate(date);
        // date of last change to Item
        entry.setUpdatedDate(dataBean.getDate());

        SyndContent desc = new SyndContentImpl();
        desc.setType("text/html");

        String tmpMessage = "";

        tmpMessage +=
            MessageFormat.format(
                localize(
                    msgs,
                    MSG_ENTRY_DESCRIPTION,
                    freq,
                    type,
                    AStatComponentService._SELECTED_OBJECT,
                    "view"),
                dataBean.getPeriodSelectedView(),
                dataBean.getTotalSelectedView());

        if (dataBean.isShowSelectedObjectDownload()) {
          tmpMessage +=
              MessageFormat.format(
                  localize(
                      msgs,
                      MSG_ENTRY_DESCRIPTION,
                      freq,
                      type,
                      AStatComponentService._SELECTED_OBJECT,
                      "download"),
                  dataBean.getPeriodSelectedDownload(),
                  dataBean.getTotalSelectedDownload());
        }

        for (String key : dataBean.getPeriodAndTotalTopView().keySet()) {
          if (dataBean.getPeriodAndTotalTopView().get(key) != null) {
            if (dataBean.getPeriodAndTotalTopView().get(key).size() > 0) {
              tmpMessage +=
                  MessageFormat.format(
                      localize(msgs, MSG_ENTRY_DESCRIPTION, freq, type, key, "view"),
                      dataBean.getPeriodAndTotalTopView().get(key).get(0),
                      dataBean.getPeriodAndTotalTopView().get(key).get(1));
            }
            if (dataBean.getPeriodAndTotalTopDownload().get(key) != null) {
              if (dataBean.getPeriodAndTotalTopDownload().get(key).size() > 0) {
                tmpMessage +=
                    MessageFormat.format(
                        localize(msgs, MSG_ENTRY_DESCRIPTION, freq, type, key, "download"),
                        dataBean.getPeriodAndTotalTopDownload().get(key).get(0),
                        dataBean.getPeriodAndTotalTopDownload().get(key).get(1));
              }
            }
          }
        }

        String message =
            MessageFormat.format(
                localize(msgs, MSG_ENTRY_DESCRIPTION, freq, type, null, null),
                bean.getObjectName(),
                dataBean.getDate(),
                tmpMessage);

        desc.setValue(message);
        entry.setDescription(desc);

        entry.setAuthor(ConfigurationManager.getProperty("webui.feed.stats.authors"));
      }
      feed.setEntries(entries);
    }
  }
  @SuppressWarnings("unchecked")
  private void serializeToFeed(
      OutputStream outputStream,
      GeolocResultsDto geolocResultsDto,
      String feedVersion,
      int startPaginationIndex) {
    SyndFeed synFeed = new SyndFeedImpl();
    Writer oWriter = null;
    try {

      synFeed.setFeedType(feedVersion);

      synFeed.setTitle(Constants.FEED_TITLE);
      synFeed.setLink(Constants.FEED_LINK);
      synFeed.setDescription(Constants.FEED_DESCRIPTION);
      List<SyndEntry> entries = new ArrayList<SyndEntry>();

      for (GisFeatureDistance gisFeatureDistance : geolocResultsDto.getResult()) {

        SyndEntry entry = new SyndEntryImpl();
        GeoRSSModule geoRSSModuleGML = new GMLModuleImpl();
        OpenSearchModule openSearchModule = new OpenSearchModuleImpl();

        geoRSSModuleGML.setLatitude(gisFeatureDistance.getLat());
        geoRSSModuleGML.setLongitude(gisFeatureDistance.getLng());

        openSearchModule.setItemsPerPage(Pagination.DEFAULT_MAX_RESULTS);
        openSearchModule.setTotalResults(geolocResultsDto.getNumFound());
        openSearchModule.setStartIndex(startPaginationIndex);

        entry.getModules().add(openSearchModule);
        entry.getModules().add(geoRSSModuleGML);
        entry.setTitle(gisFeatureDistance.getName());
        entry.setAuthor(Constants.MAIL_ADDRESS);
        entry.setLink(Constants.GISFEATURE_BASE_URL + +gisFeatureDistance.getFeatureId());
        SyndContent description = new SyndContentImpl();
        description.setType(OutputFormat.ATOM.getContentType());
        description.setValue(gisFeatureDistance.getName());
        entry.setDescription(description);
        entries.add(entry);
      }

      synFeed.setEntries(entries);

      try {
        oWriter = new OutputStreamWriter(outputStream, Constants.CHARSET);
      } catch (UnsupportedEncodingException e) {
        throw new RuntimeException("unknow encoding " + Constants.CHARSET);
      }

      // Copy synfeed to output
      SyndFeedOutput output = new SyndFeedOutput();
      try {
        output.output(synFeed, oWriter);
        // Flush
        oWriter.flush();
      } catch (Exception e) {
        throw new RuntimeException(e);
      }

    } finally {
      if (oWriter != null)
        try {
          oWriter.close();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      if (outputStream != null)
        try {
          outputStream.close();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
    }
  }
Example #20
0
  /**
   * Fills in the feed and entry-level metadata from DSpace objects.
   *
   * @param request request
   * @param context context
   * @param dso DSpaceObject
   * @param items array of objects
   * @param labels label map
   */
  public void populate(
      HttpServletRequest request,
      Context context,
      DSpaceObject dso,
      List<? extends DSpaceObject> items,
      Map<String, String> labels) {
    String logoURL = null;
    String objectURL = null;
    String defaultTitle = null;
    boolean podcastFeed = false;
    this.request = request;

    // dso is null for the whole site, or a search without scope
    if (dso == null) {
      defaultTitle = ConfigurationManager.getProperty("dspace.name");
      feed.setDescription(localize(labels, MSG_FEED_DESCRIPTION));
      objectURL = resolveURL(request, null);
      logoURL = ConfigurationManager.getProperty("webui.feed.logo.url");
    } else {
      Bitstream logo = null;
      if (dso.getType() == Constants.COLLECTION) {
        Collection col = (Collection) dso;
        defaultTitle = col.getName();
        feed.setDescription(collectionService.getMetadata(col, "short_description"));
        logo = col.getLogo();
        String cols = ConfigurationManager.getProperty("webui.feed.podcast.collections");
        if (cols != null && cols.length() > 1 && cols.contains(col.getHandle())) {
          podcastFeed = true;
        }
      } else if (dso.getType() == Constants.COMMUNITY) {
        Community comm = (Community) dso;
        defaultTitle = comm.getName();
        feed.setDescription(communityService.getMetadata(comm, "short_description"));
        logo = comm.getLogo();
        String comms = ConfigurationManager.getProperty("webui.feed.podcast.communities");
        if (comms != null && comms.length() > 1 && comms.contains(comm.getHandle())) {
          podcastFeed = true;
        }
      }
      objectURL = resolveURL(request, dso);
      if (logo != null) {
        logoURL = urlOfBitstream(request, logo);
      }
    }
    feed.setTitle(
        labels.containsKey(MSG_FEED_TITLE) ? localize(labels, MSG_FEED_TITLE) : defaultTitle);
    feed.setLink(objectURL);
    feed.setPublishedDate(new Date());
    feed.setUri(objectURL);

    // add logo if we found one:
    if (logoURL != null) {
      // we use the path to the logo for this, the logo itself cannot
      // be contained in the rdf. Not all RSS-viewers show this logo.
      SyndImage image = new SyndImageImpl();
      image.setLink(objectURL);
      if (StringUtils.isNotBlank(feed.getTitle())) {
        image.setTitle(feed.getTitle());
      } else {
        image.setTitle(localize(labels, MSG_LOGO_TITLE));
      }
      image.setUrl(logoURL);
      feed.setImage(image);
    }

    // add entries for items
    if (items != null) {
      List<SyndEntry> entries = new ArrayList<SyndEntry>();
      for (DSpaceObject itemDSO : items) {
        if (itemDSO.getType() != Constants.ITEM) {
          continue;
        }
        Item item = (Item) itemDSO;
        boolean hasDate = false;
        SyndEntry entry = new SyndEntryImpl();
        entries.add(entry);

        String entryURL = resolveURL(request, item);
        entry.setLink(entryURL);
        entry.setUri(entryURL);

        String title = getOneDC(item, titleField);
        entry.setTitle(title == null ? localize(labels, MSG_UNTITLED) : title);

        // "published" date -- should be dc.date.issued
        String pubDate = getOneDC(item, dateField);
        if (pubDate != null) {
          entry.setPublishedDate((new DCDate(pubDate)).toDate());
          hasDate = true;
        }
        // date of last change to Item
        entry.setUpdatedDate(item.getLastModified());

        StringBuffer db = new StringBuffer();
        for (String df : descriptionFields) {
          // Special Case: "(date)" in field name means render as date
          boolean isDate = df.indexOf("(date)") > 0;
          if (isDate) {
            df = df.replaceAll("\\(date\\)", "");
          }

          List<MetadataValue> dcv = itemService.getMetadataByMetadataString(item, df);
          if (dcv.size() > 0) {
            String fieldLabel = labels.get(MSG_METADATA + df);
            if (fieldLabel != null && fieldLabel.length() > 0) {
              db.append(fieldLabel).append(": ");
            }
            boolean first = true;
            for (MetadataValue v : dcv) {
              if (first) {
                first = false;
              } else {
                db.append("; ");
              }
              db.append(isDate ? new DCDate(v.getValue()).toString() : v.getValue());
            }
            db.append("\n");
          }
        }
        if (db.length() > 0) {
          SyndContent desc = new SyndContentImpl();
          desc.setType("text/plain");
          desc.setValue(db.toString());
          entry.setDescription(desc);
        }

        // This gets the authors into an ATOM feed
        List<MetadataValue> authors = itemService.getMetadataByMetadataString(item, authorField);
        if (authors.size() > 0) {
          List<SyndPerson> creators = new ArrayList<SyndPerson>();
          for (MetadataValue author : authors) {
            SyndPerson sp = new SyndPersonImpl();
            sp.setName(author.getValue());
            creators.add(sp);
          }
          entry.setAuthors(creators);
        }

        // only add DC module if any DC fields are configured
        if (dcCreatorField != null || dcDateField != null || dcDescriptionField != null) {
          DCModule dc = new DCModuleImpl();
          if (dcCreatorField != null) {
            List<MetadataValue> dcAuthors =
                itemService.getMetadataByMetadataString(item, dcCreatorField);
            if (dcAuthors.size() > 0) {
              List<String> creators = new ArrayList<String>();
              for (MetadataValue author : dcAuthors) {
                creators.add(author.getValue());
              }
              dc.setCreators(creators);
            }
          }
          if (dcDateField != null && !hasDate) {
            List<MetadataValue> v = itemService.getMetadataByMetadataString(item, dcDateField);
            if (v.size() > 0) {
              dc.setDate((new DCDate(v.get(0).getValue())).toDate());
            }
          }
          if (dcDescriptionField != null) {
            List<MetadataValue> v =
                itemService.getMetadataByMetadataString(item, dcDescriptionField);
            if (v.size() > 0) {
              StringBuffer descs = new StringBuffer();
              for (MetadataValue d : v) {
                if (descs.length() > 0) {
                  descs.append("\n\n");
                }
                descs.append(d.getValue());
              }
              dc.setDescription(descs.toString());
            }
          }
          entry.getModules().add(dc);
        }

        // iTunes Podcast Support - START
        if (podcastFeed) {
          // Add enclosure(s)
          List<SyndEnclosure> enclosures = new ArrayList();
          try {
            List<Bundle> bunds = itemService.getBundles(item, "ORIGINAL");
            if (bunds.get(0) != null) {
              List<Bitstream> bits = bunds.get(0).getBitstreams();
              for (Bitstream bit : bits) {
                String mime = bit.getFormat(context).getMIMEType();
                if (ArrayUtils.contains(podcastableMIMETypes, mime)) {
                  SyndEnclosure enc = new SyndEnclosureImpl();
                  enc.setType(bit.getFormat(context).getMIMEType());
                  enc.setLength(bit.getSize());
                  enc.setUrl(urlOfBitstream(request, bit));
                  enclosures.add(enc);
                } else {
                  continue;
                }
              }
            }
            // Also try to add an external value from dc.identifier.other
            // We are assuming that if this is set, then it is a media file
            List<MetadataValue> externalMedia =
                itemService.getMetadataByMetadataString(item, externalSourceField);
            if (externalMedia.size() > 0) {
              for (MetadataValue anExternalMedia : externalMedia) {
                SyndEnclosure enc = new SyndEnclosureImpl();
                enc.setType(
                    "audio/x-mpeg"); // We can't determine MIME of external file, so just picking
                                     // one.
                enc.setLength(1);
                enc.setUrl(anExternalMedia.getValue());
                enclosures.add(enc);
              }
            }

          } catch (Exception e) {
            System.out.println(e.getMessage());
          }
          entry.setEnclosures(enclosures);

          // Get iTunes specific fields: author, subtitle, summary, duration, keywords
          EntryInformation itunes = new EntryInformationImpl();

          String author = getOneDC(item, authorField);
          if (author != null && author.length() > 0) {
            itunes.setAuthor(author); // <itunes:author>
          }

          itunes.setSubtitle(
              title == null ? localize(labels, MSG_UNTITLED) : title); // <itunes:subtitle>

          if (db.length() > 0) {
            itunes.setSummary(db.toString()); // <itunes:summary>
          }

          String extent =
              getOneDC(
                  item,
                  "dc.format.extent"); // assumed that user will enter this field with length of
                                       // song in seconds
          if (extent != null && extent.length() > 0) {
            extent = extent.split(" ")[0];
            Integer duration = Integer.parseInt(extent);
            itunes.setDuration(new Duration(duration)); // <itunes:duration>
          }

          String subject = getOneDC(item, "dc.subject");
          if (subject != null && subject.length() > 0) {
            String[] subjects = new String[1];
            subjects[0] = subject;
            itunes.setKeywords(subjects); // <itunes:keywords>
          }

          entry.getModules().add(itunes);
        }
      }
      feed.setEntries(entries);
    }
  }
Example #21
0
  protected void topicUpdated(String path, String linkItem, final boolean updated) {
    try {
      Node topicNode = (Node) getCurrentSession().getItem(path);
      Node forumNode = topicNode.getParent();
      Node categoryNode = forumNode.getParent();
      boolean categoryHasRestrictedAudience = (hasProperty(categoryNode, "exo:viewer"));
      boolean forumHasRestrictedAudience = (hasProperty(forumNode, "exo:viewer"));
      boolean debug = LOG.isDebugEnabled();
      String topicName = topicNode.getName();
      if (categoryHasRestrictedAudience || forumHasRestrictedAudience) {
        if (debug) {
          LOG.debug(
              "Post"
                  + topicName
                  + " was not added to feed because category or forum has restricted audience");
        }
        return;
      }

      PropertyReader topic = new PropertyReader(topicNode);
      SyndContent description;
      List<String> listContent = new ArrayList<String>();
      String message = topic.string("exo:description");
      listContent.add(message);
      description = new SyndContentImpl();
      description.setType(RSS.PLAIN_TEXT);
      description.setValue(message);
      final String title = topic.string("exo:name");
      final Date created = topic.date("exo:createdDate");
      final String owner = topic.string("exo:owner");
      SyndEntry entry =
          RSS.createNewEntry(topicName, title, linkItem, listContent, description, created, owner);
      entry.setLink(linkItem + topicNode.getName());

      // save topic, forum and category feeds
      for (Node node : new Node[] {forumNode, categoryNode}) {
        PropertyReader reader = new PropertyReader(node);
        String desc = reader.string("exo:description", " ");

        RSS data = new RSS(node);
        if (data.feedExists()) {
          SyndFeed feed = null;
          if (updated) {
            feed = data.removeEntry(topicName);
          }
          feed = data.addEntry(entry);
          feed.setDescription(reader.string("exo:description", " "));
          data.saveFeed(feed, FORUM_RSS_TYPE);
        } else {
          SyndFeed feed =
              RSS.createNewFeed(
                  node.getProperty("exo:name").getString(),
                  node.getProperty("exo:createdDate").getDate().getTime());
          feed.setLink(linkItem + node.getName());
          feed.setEntries(Arrays.asList(new SyndEntry[] {entry}));
          feed.setDescription(desc);
          data.saveFeed(feed, FORUM_RSS_TYPE);
        }
      }

      // update posts in topic
      NodeIterator nodeIterator = topicNode.getNodes();
      Node postNode = null;
      while (nodeIterator.hasNext()) {
        postNode = nodeIterator.nextNode();
        if (postNode.isNodeType("exo:post")) {
          try {
            postUpdated(postNode, linkItem, updated);
          } catch (Exception e) {
            if (LOG.isDebugEnabled()) {
              LOG.debug("Failed to generate feed for post " + postNode.getPath(), e);
            }
          }
        }
      }
    } catch (PathNotFoundException e) {
      LOG.warn("Failed to get properties", e);
    } catch (Exception e) {
      LOG.error("Failed to update topics", e);
    }
  }
Example #22
0
  private void postUpdated(Node postNode, String linkItem, final boolean updated) throws Exception {
    boolean debug = LOG.isDebugEnabled();
    Node topicNode = postNode.getParent();
    String postName = postNode.getName();
    PropertyReader post = new PropertyReader(postNode);
    PropertyReader topic = new PropertyReader(topicNode);
    boolean isFirstPost =
        post.bool("exo:isFirstPost"); // postNode.hasProperty("exo:isFirstPost") &&
    // postNode.getProperty("exo:isFirstPost").getBoolean();
    boolean notApproved =
        !post.bool("exo:isApproved"); // (postNode.hasProperty("exo:isApproved") &&
    // !postNode.getProperty("exo:isApproved").getBoolean());
    boolean isPrivatePost =
        hasProperty(topicNode, "exo:userPrivate")
            && !"exoUserPri"
                .equals(
                    topic
                        .strings("exo:userPrivate")[
                        0]); // (postNode.hasProperty("exo:userPrivate") &&
    // !postNode.getProperty("exo:userPrivate").getValues()[0].getString().equals("exoUserPri"));
    boolean topicHasLimitedViewers =
        hasProperty(topicNode, "exo:canView"); // (topicNode.hasProperty("exo:canView") &&
    // topicNode.getProperty("exo:canView").getValues()[0].getString().trim().length() > 0);

    if ((isFirstPost && notApproved) || isPrivatePost || topicHasLimitedViewers) {
      if (debug) {
        LOG.debug(
            "Post"
                + postName
                + " was not added to feed because it is private or topic has restricted audience or it is approval pending");
      }
      return;
    }

    Node forumNode = topicNode.getParent();
    Node categoryNode = forumNode.getParent();
    boolean categoryHasRestrictedAudience = (hasProperty(categoryNode, "exo:viewer"));
    boolean forumHasRestrictedAudience = (hasProperty(forumNode, "exo:viewer"));

    if (categoryHasRestrictedAudience || forumHasRestrictedAudience) {
      if (debug) {
        LOG.debug(
            "Post"
                + postName
                + " was not added to feed because category or forum has restricted audience");
      }
      return;
    }

    boolean inactive =
        !post.bool("exo:isActiveByTopic"); // (postNode.hasProperty("exo:isActiveByTopic") &&
    // !postNode.getProperty("exo:isActiveByTopic").getBoolean());
    boolean hidden = post.bool("exo:isHidden"); // (postNode.hasProperty("exo:isHidden") &&
    // postNode.getProperty("exo:isHidden").getBoolean());

    if (notApproved || inactive || hidden) {

      if (updated) {
        removePostFromParentFeeds(postNode, topicNode, forumNode, categoryNode);
      }
      if (debug) {
        LOG.debug(
            "Post"
                + postName
                + " was not added to feed because because it is hidden, inactive or not approved");
      }
      return;
    }

    SyndContent description;
    List<String> listContent = new ArrayList<String>();
    String message = post.string("exo:message");
    listContent.add(message);
    description = new SyndContentImpl();
    description.setType(RSS.PLAIN_TEXT);
    description.setValue(message);
    final String title = post.string("exo:name");
    final Date created = post.date("exo:createdDate");
    final String owner = post.string("exo:owner");
    SyndEntry entry =
        RSS.createNewEntry(postName, title, linkItem, listContent, description, created, owner);
    entry.setLink(linkItem + topicNode.getName());

    // save topic, forum and category feeds
    for (Node node : new Node[] {topicNode, forumNode, categoryNode}) {
      PropertyReader reader = new PropertyReader(node);
      String desc = reader.string("exo:description", " ");

      RSS data = new RSS(node);
      if (data.feedExists()) {
        SyndFeed feed = null;
        if (updated) {
          feed = data.removeEntry(postName);
        }
        feed = data.addEntry(entry);
        feed.setDescription(reader.string("exo:description", " "));
        data.saveFeed(feed, FORUM_RSS_TYPE);
      } else {
        SyndFeed feed = RSS.createNewFeed(title, created);
        feed.setLink(linkItem + node.getName());
        feed.setEntries(Arrays.asList(new SyndEntry[] {entry}));
        feed.setDescription(desc);
        data.saveFeed(feed, FORUM_RSS_TYPE);
      }
    }
  }
 /**
  * Creates a new {@link SyndContent} instance for the given content type and value.
  *
  * @param type content type
  * @param value the content
  * @return a new {@link SyndContent} instance
  */
 protected SyndContent getSyndContent(String type, String value) {
   SyndContent content = new SyndContentImpl();
   content.setType(type);
   content.setValue(value);
   return content;
 }
  protected String exportToRSS(
      ResourceRequest resourceRequest,
      ResourceResponse resourceResponse,
      JournalFeed feed,
      String languageId,
      Layout layout,
      ThemeDisplay themeDisplay)
      throws Exception {

    SyndFeed syndFeed = new SyndFeedImpl();

    syndFeed.setDescription(feed.getDescription());

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

    syndFeed.setEntries(syndEntries);

    List<JournalArticle> articles = JournalRSSUtil.getArticles(feed);

    if (_log.isDebugEnabled()) {
      _log.debug("Syndicating " + articles.size() + " articles");
    }

    for (JournalArticle article : articles) {
      SyndEntry syndEntry = new SyndEntryImpl();

      String author = PortalUtil.getUserName(article);

      syndEntry.setAuthor(author);

      SyndContent syndContent = new SyndContentImpl();

      syndContent.setType(RSSUtil.ENTRY_TYPE_DEFAULT);

      String value = article.getDescription(languageId);

      try {
        value = processContent(feed, article, languageId, themeDisplay, syndEntry, syndContent);
      } catch (Exception e) {
        if (_log.isWarnEnabled()) {
          _log.warn(e, e);
        }
      }

      syndContent.setValue(value);

      syndEntry.setDescription(syndContent);

      String link = getEntryURL(resourceRequest, feed, article, layout, themeDisplay);

      syndEntry.setLink(link);

      syndEntry.setPublishedDate(article.getDisplayDate());
      syndEntry.setTitle(article.getTitle(languageId));
      syndEntry.setUpdatedDate(article.getModifiedDate());
      syndEntry.setUri(link);

      syndEntries.add(syndEntry);
    }

    syndFeed.setFeedType(feed.getFeedType() + "_" + feed.getFeedVersion());

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

    syndFeed.setLinks(syndLinks);

    SyndLink selfSyndLink = new SyndLinkImpl();

    syndLinks.add(selfSyndLink);

    ResourceURL feedURL = resourceResponse.createResourceURL();

    feedURL.setCacheability(ResourceURL.FULL);
    feedURL.setParameter("struts_action", "/journal/rss");
    feedURL.setParameter("groupId", String.valueOf(feed.getGroupId()));
    feedURL.setParameter("feedId", String.valueOf(feed.getFeedId()));

    String link = feedURL.toString();

    selfSyndLink.setHref(link);

    selfSyndLink.setRel("self");

    syndFeed.setTitle(feed.getName());
    syndFeed.setPublishedDate(new Date());
    syndFeed.setUri(feedURL.toString());

    try {
      return RSSUtil.export(syndFeed);
    } catch (FeedException fe) {
      throw new SystemException(fe);
    }
  }