Exemple #1
0
  @SuppressWarnings("unchecked")
  public static String canonicalUri(Entry entry) {
    List<Link> links = entry.getAlternateLinks();

    for (Link link : links) {
      String href = link.getHref();
      if (C4AtomApi.isACanonicalEpisodeUri(href)) {
        return href;
      }
    }

    links = entry.getOtherLinks();
    for (Link link : links) {
      String href = link.getHref();
      if (C4AtomApi.isACanonicalEpisodeUri(href)) {
        return href;
      }
    }

    return null;
  }
  protected void populateEntry(Entry entry, Element eEntry) throws FeedException {
    if (entry.getTitleEx() != null) {
      Element titleElement = new Element("title", getFeedNamespace());
      fillContentElement(titleElement, entry.getTitleEx());
      eEntry.addContent(titleElement);
    }
    List links = entry.getAlternateLinks();
    if (links != null) {
      for (int i = 0; i < links.size(); i++) {
        eEntry.addContent(generateLinkElement((Link) links.get(i)));
      }
    }
    links = entry.getOtherLinks();
    if (links != null) {
      for (int i = 0; i < links.size(); i++) {
        eEntry.addContent(generateLinkElement((Link) links.get(i)));
      }
    }

    List cats = entry.getCategories();
    if (cats != null) {
      for (int i = 0; i < cats.size(); i++) {
        eEntry.addContent(generateCategoryElement((Category) cats.get(i)));
      }
    }

    List authors = entry.getAuthors();
    if (authors != null && authors.size() > 0) {
      for (int i = 0; i < authors.size(); i++) {
        Element authorElement = new Element("author", getFeedNamespace());
        fillPersonElement(authorElement, (Person) entry.getAuthors().get(i));
        eEntry.addContent(authorElement);
      }
    }

    List contributors = entry.getContributors();
    if (contributors != null && contributors.size() > 0) {
      for (int i = 0; i < contributors.size(); i++) {
        Element contributorElement = new Element("contributor", getFeedNamespace());
        fillPersonElement(contributorElement, (Person) contributors.get(i));
        eEntry.addContent(contributorElement);
      }
    }
    if (entry.getId() != null) {
      eEntry.addContent(generateSimpleElement("id", entry.getId()));
    }

    if (entry.getUpdated() != null) {
      Element updatedElement = new Element("updated", getFeedNamespace());
      updatedElement.addContent(DateParser.formatW3CDateTime(entry.getUpdated()));
      eEntry.addContent(updatedElement);
    }

    if (entry.getPublished() != null) {
      Element publishedElement = new Element("published", getFeedNamespace());
      publishedElement.addContent(DateParser.formatW3CDateTime(entry.getPublished()));
      eEntry.addContent(publishedElement);
    }

    if (entry.getContents() != null && entry.getContents().size() > 0) {
      Element contentElement = new Element("content", getFeedNamespace());
      Content content = (Content) entry.getContents().get(0);
      fillContentElement(contentElement, content);
      eEntry.addContent(contentElement);
    }

    if (entry.getSummary() != null) {
      Element summaryElement = new Element("summary", getFeedNamespace());
      fillContentElement(summaryElement, entry.getSummary());
      eEntry.addContent(summaryElement);
    }

    if (entry.getSource() != null) {
      Element sourceElement = new Element("source", getFeedNamespace());
      populateFeedHeader(entry.getSource(), sourceElement);
      eEntry.addContent(sourceElement);
    }
  }