Ejemplo n.º 1
0
  /**
   * A helper function to print out the contents of an entry to log.trace
   *
   * @param entry
   */
  public static void printEntry(SyndEntry entry) {
    if (!log.isTraceEnabled()) {
      return;
    }

    StringBuffer pr =
        new StringBuffer(
            "URI: "
                + entry.getUri()
                + "\n"
                + "Title: "
                + entry.getTitle()
                + "\n"
                + "\n"
                + "Date: "
                + entry.getPublishedDate()
                + "\n"
                + "Modified: "
                + entry.getUpdatedDate()
                + "\n");

    pr.append("Creators: \n");

    for (SyndPerson author : FeedHelper.getAuthors(entry)) {
      pr.append("  - " + author.getName() + "\n");
    }

    pr.append("Links: \n");
    for (SyndLink link : FeedHelper.getLinks(entry)) {
      pr.append("  - " + link.getTitle() + ": " + link.getHref() + "\n");
    }

    SyndContent description = entry.getDescription();
    if (description != null) {
      pr.append("\nDescription(" + description.getType() + "): " + description.getValue());
    }

    pr.append("Contents: \n");
    for (SyndContent content : FeedHelper.getContents(entry)) {
      pr.append(" Type: " + content.getType());
      pr.append(" Body: " + content.getValue());
      try {
        pr.append(
            " Body (Plain text): "
                + PlainTextExtractor.getPlainText(content.getType(), content.getValue()));
      } catch (ParserException e) {
        pr.append("Failed to parse content");
      }
    }

    pr.append("Categories: \n");
    for (SyndCategory category : FeedHelper.getCategories(entry)) {
      pr.append(category.getName() + "(" + category.getTaxonomyUri() + ")");
    }
    log.trace(pr.toString());
  }