@SuppressWarnings("unchecked")
  public List<String> getEmails(List<? extends Entry> entries, String commentAuthorEmail) {
    if (entries == null) {
      return null;
    }

    if (commentAuthorEmail == null) {
      commentAuthorEmail = CoreConstants.EMPTY;
    }

    List<String> emails = new ArrayList<String>();
    List<Person> authors = null;
    String email = null;
    for (Entry entry : entries) {
      authors = entry.getAuthors();
      if (authors != null) {
        for (Person author : authors) {
          email = author.getEmail();
          if (email != null) {
            email = CoreUtil.getDecodedValue(email);
            if (!email.equals(commentAuthorEmail) && !emails.contains(email)) {
              emails.add(email);
            }
          }
        }
      }
    }

    return emails;
  }
コード例 #2
0
 protected void addEntry(Entry entry, Element parent) throws FeedException {
   Element eEntry = new Element("entry", getFeedNamespace());
   if (entry.getXmlBase() != null) {
     eEntry.setAttribute("base", entry.getXmlBase(), Namespace.XML_NAMESPACE);
   }
   populateEntry(entry, eEntry);
   generateForeignMarkup(eEntry, (List) entry.getForeignMarkup());
   checkEntryConstraints(eEntry);
   generateItemModules(entry.getModules(), eEntry);
   parent.addContent(eEntry);
 }
コード例 #3
0
ファイル: C4AtomApi.java プロジェクト: Reedyuk/atlas
 @SuppressWarnings("unchecked")
 public static Element mediaContent(Entry syndEntry) {
   for (Element element : (List<Element>) syndEntry.getForeignMarkup()) {
     if (NS_MEDIA_RSS.equals(element.getNamespace()) && "content".equals(element.getName())) {
       return element;
     }
   }
   return null;
 }
コード例 #4
0
ファイル: C4AtomApi.java プロジェクト: Reedyuk/atlas
  @SuppressWarnings("unchecked")
  public static String fourOdUri(Entry entry) {
    List<Link> links = entry.getAlternateLinks();

    for (Link link : links) {
      String href = link.getHref();
      if (href.contains("4od#")) {
        return href;
      }
    }
    return null;
  }
コード例 #5
0
ファイル: C4AtomApi.java プロジェクト: Reedyuk/atlas
  @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;
  }
コード例 #6
0
  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);
    }
  }
コード例 #7
0
  private Entry parseEntry(Element eEntry) {
    Entry entry = new Entry();

    Element e = eEntry.getChild("title", getAtomNamespace());
    if (e != null) {
      entry.setTitleEx(parseContent(e));
    }

    List<Element> eList = eEntry.getChildren("link", getAtomNamespace());
    entry.setAlternateLinks(parseAlternateLinks(eList));
    entry.setOtherLinks(parseOtherLinks(eList));

    e = eEntry.getChild("author", getAtomNamespace());
    if (e != null) {
      List<Person> authors = new ArrayList<Person>();
      authors.add(parsePerson(e));
      entry.setAuthors(authors);
    }

    eList = eEntry.getChildren("contributor", getAtomNamespace());
    if (eList.size() > 0) {
      entry.setContributors(parsePersons(eList));
    }

    e = eEntry.getChild("id", getAtomNamespace());
    if (e != null) {
      entry.setId(e.getText());
    }

    e = eEntry.getChild("modified", getAtomNamespace());
    if (e != null) {
      entry.setModified(DateParser.parseDate(e.getText()));
    }

    e = eEntry.getChild("issued", getAtomNamespace());
    if (e != null) {
      entry.setIssued(DateParser.parseDate(e.getText()));
    }

    e = eEntry.getChild("created", getAtomNamespace());
    if (e != null) {
      entry.setCreated(DateParser.parseDate(e.getText()));
    }

    e = eEntry.getChild("summary", getAtomNamespace());
    if (e != null) {
      entry.setSummary(parseContent(e));
    }

    eList = eEntry.getChildren("content", getAtomNamespace());
    if (eList.size() > 0) {
      List<Content> content = new ArrayList<Content>();
      for (int i = 0; i < eList.size(); i++) {
        content.add(parseContent(eList.get(i)));
      }
      entry.setContents(content);
    }

    entry.setModules(parseItemModules(eEntry));

    List<Element> foreignMarkup = extractForeignMarkup(eEntry, entry, getAtomNamespace());
    if (foreignMarkup.size() > 0) {
      entry.setForeignMarkup(foreignMarkup);
    }
    return entry;
  }
コード例 #8
0
ファイル: C4AtomApi.java プロジェクト: Reedyuk/atlas
 @SuppressWarnings("unchecked")
 public static Map<String, String> foreignElementLookup(Entry entry) {
   return foreignElementLookup((Iterable<Element>) entry.getForeignMarkup());
 }
コード例 #9
0
ファイル: Atom10Parser.java プロジェクト: EagerLogic/rome
  protected Entry parseEntry(
      final Feed feed, final Element eEntry, final String baseURI, final Locale locale) {
    final Entry entry = new Entry();

    final String xmlBase = eEntry.getAttributeValue("base", Namespace.XML_NAMESPACE);
    if (xmlBase != null) {
      entry.setXmlBase(xmlBase);
    }

    Element e = eEntry.getChild("title", getAtomNamespace());
    if (e != null) {
      final Content c = new Content();
      c.setValue(parseTextConstructToString(e));
      c.setType(getAttributeValue(e, "type"));
      entry.setTitleEx(c);
    }

    List<Element> eList = eEntry.getChildren("link", getAtomNamespace());
    entry.setAlternateLinks(parseAlternateLinks(feed, entry, baseURI, eList));
    entry.setOtherLinks(parseOtherLinks(feed, entry, baseURI, eList));

    eList = eEntry.getChildren("author", getAtomNamespace());
    if (eList.size() > 0) {
      entry.setAuthors(parsePersons(baseURI, eList, locale));
    }

    eList = eEntry.getChildren("contributor", getAtomNamespace());
    if (eList.size() > 0) {
      entry.setContributors(parsePersons(baseURI, eList, locale));
    }

    e = eEntry.getChild("id", getAtomNamespace());
    if (e != null) {
      entry.setId(e.getText());
    }

    e = eEntry.getChild("updated", getAtomNamespace());
    if (e != null) {
      entry.setUpdated(DateParser.parseDate(e.getText(), locale));
    }

    e = eEntry.getChild("published", getAtomNamespace());
    if (e != null) {
      entry.setPublished(DateParser.parseDate(e.getText(), locale));
    }

    e = eEntry.getChild("summary", getAtomNamespace());
    if (e != null) {
      entry.setSummary(parseContent(e));
    }

    e = eEntry.getChild("content", getAtomNamespace());
    if (e != null) {
      final List<Content> contents = new ArrayList<Content>();
      contents.add(parseContent(e));
      entry.setContents(contents);
    }

    e = eEntry.getChild("rights", getAtomNamespace());
    if (e != null) {
      entry.setRights(e.getText());
    }

    final List<Element> cList = eEntry.getChildren("category", getAtomNamespace());
    entry.setCategories(parseCategories(baseURI, cList));

    // TODO: SHOULD handle Atom entry source element
    e = eEntry.getChild("source", getAtomNamespace());
    if (e != null) {
      entry.setSource(parseFeedMetadata(baseURI, e, locale));
    }

    entry.setModules(parseItemModules(eEntry, locale));

    final List<Element> foreignMarkup = extractForeignMarkup(eEntry, entry, getAtomNamespace());
    if (foreignMarkup.size() > 0) {
      entry.setForeignMarkup(foreignMarkup);
    }
    return entry;
  }