Пример #1
0
  public void serialize(
      ResultSummary summary,
      List<DashBoardItem> workItems,
      String columnsDefinition,
      List<String> labels,
      String lang,
      Response response,
      HttpServletRequest req)
      throws ClientException {
    // TODO labels, lang

    SyndFeed atomFeed = new SyndFeedImpl();
    atomFeed.setFeedType(ATOM_TYPE);

    // XXX TODO : To be translated
    atomFeed.setTitle(summary.getTitle());

    atomFeed.setLink(summary.getLink());

    List<SyndEntry> entries = new ArrayList<SyndEntry>();
    for (DashBoardItem item : workItems) {
      entries.add(adaptDashBoardItem(item, req));
    }

    atomFeed.setEntries(entries);

    SyndFeedOutput output = new SyndFeedOutput();

    // Try to return feed
    try {
      response.setEntity(output.outputString(atomFeed), MediaType.TEXT_XML);
      response.getEntity().setCharacterSet(CharacterSet.UTF_8);
    } catch (FeedException fe) {
    }
  }
Пример #2
0
  public SyndFeedMediaResource(final SyndFeed feed) {
    this.feed = feed;

    feedString = null;
    try {
      final SyndFeedOutput output = new SyndFeedOutput();
      feedString = output.outputString(feed);
    } catch (final FeedException e) {
      /* TODO: ORID-1007 ExceptionHandling */
      log.error(e.getMessage());
    }
  }
Пример #3
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);
    }
  }
Пример #4
0
 /** @return the feed we built as serialized XML string */
 public String outputString() throws FeedException {
   SyndFeedOutput feedWriter = new SyndFeedOutput();
   return feedWriter.outputString(feed);
 }