Example #1
0
 public void setItemNode(Node itemNode) {
   try {
     Node rssNode = itemNode.getNode(RSS_NODE_NAME);
     if (rssNode.hasProperty(CONTENT_PROPERTY)) {
       setContent(rssNode.getProperty(CONTENT_PROPERTY).getValue().getStream());
     } else {
       throw new IllegalArgumentException("Node does not have an RSS feed child");
     }
   } catch (Exception e) {
     throw new RuntimeException("Failed to set item node for RSS", e);
   }
   this.itemNode = itemNode;
 }
Example #2
0
  public void saveFeed(SyndFeed feed, String rssNodeType) {
    try {
      boolean isNew = false;
      try {
        itemNode.getNode(RSS_NODE_NAME);
      } catch (PathNotFoundException pnfe) {
        LOG.debug("Feed node not found for " + itemNode.getName() + " creating...");
        itemNode.addNode(RSS_NODE_NAME, rssNodeType);
        isNew = true;
      }

      SyndFeedOutput output = new SyndFeedOutput();
      setContent(new ByteArrayInputStream(output.outputString(feed).getBytes()));

      if (isNew) itemNode.getSession().save();
      else itemNode.save();
    } catch (Exception e) {
      LOG.error("Failed to save feed content", e);
    }
  }