protected WireFeed parseFeed(Element eFeed) { com.sun.syndication.feed.atom.Feed feed = new com.sun.syndication.feed.atom.Feed(getType()); Element e = eFeed.getChild("title", getAtomNamespace()); if (e != null) { feed.setTitleEx(parseContent(e)); } List<Element> eList = eFeed.getChildren("link", getAtomNamespace()); feed.setAlternateLinks(parseAlternateLinks(eList)); feed.setOtherLinks(parseOtherLinks(eList)); e = eFeed.getChild("author", getAtomNamespace()); if (e != null) { List<Person> authors = new ArrayList<Person>(); authors.add(parsePerson(e)); feed.setAuthors(authors); } eList = eFeed.getChildren("contributor", getAtomNamespace()); if (eList.size() > 0) { feed.setContributors(parsePersons(eList)); } e = eFeed.getChild("tagline", getAtomNamespace()); if (e != null) { feed.setTagline(parseContent(e)); } e = eFeed.getChild("id", getAtomNamespace()); if (e != null) { feed.setId(e.getText()); } e = eFeed.getChild("generator", getAtomNamespace()); if (e != null) { Generator gen = new Generator(); gen.setValue(e.getText()); String att = getAttributeValue(e, "url"); if (att != null) { gen.setUrl(att); } att = getAttributeValue(e, "version"); if (att != null) { gen.setVersion(att); } feed.setGenerator(gen); } e = eFeed.getChild("copyright", getAtomNamespace()); if (e != null) { feed.setCopyright(e.getText()); } e = eFeed.getChild("info", getAtomNamespace()); if (e != null) { feed.setInfo(parseContent(e)); } e = eFeed.getChild("modified", getAtomNamespace()); if (e != null) { feed.setModified(DateParser.parseDate(e.getText())); } feed.setModules(parseFeedModules(eFeed)); eList = eFeed.getChildren("entry", getAtomNamespace()); if (eList.size() > 0) { feed.setEntries(parseEntries(eList)); } List<Element> foreignMarkup = extractForeignMarkup(eFeed, feed, getAtomNamespace()); if (foreignMarkup.size() > 0) { feed.setForeignMarkup(foreignMarkup); } return feed; }
private Feed parseFeedMetadata(final String baseURI, final Element eFeed, final Locale locale) { final com.sun.syndication.feed.atom.Feed feed = new com.sun.syndication.feed.atom.Feed(getType()); Element e = eFeed.getChild("title", getAtomNamespace()); if (e != null) { final Content c = new Content(); c.setValue(parseTextConstructToString(e)); c.setType(getAttributeValue(e, "type")); feed.setTitleEx(c); } List<Element> eList = eFeed.getChildren("link", getAtomNamespace()); feed.setAlternateLinks(parseAlternateLinks(feed, null, baseURI, eList)); feed.setOtherLinks(parseOtherLinks(feed, null, baseURI, eList)); final List<Element> cList = eFeed.getChildren("category", getAtomNamespace()); feed.setCategories(parseCategories(baseURI, cList)); eList = eFeed.getChildren("author", getAtomNamespace()); if (eList.size() > 0) { feed.setAuthors(parsePersons(baseURI, eList, locale)); } eList = eFeed.getChildren("contributor", getAtomNamespace()); if (eList.size() > 0) { feed.setContributors(parsePersons(baseURI, eList, locale)); } e = eFeed.getChild("subtitle", getAtomNamespace()); if (e != null) { final Content subtitle = new Content(); subtitle.setValue(parseTextConstructToString(e)); subtitle.setType(getAttributeValue(e, "type")); feed.setSubtitle(subtitle); } e = eFeed.getChild("id", getAtomNamespace()); if (e != null) { feed.setId(e.getText()); } e = eFeed.getChild("generator", getAtomNamespace()); if (e != null) { final Generator gen = new Generator(); gen.setValue(e.getText()); String att = getAttributeValue(e, "uri"); if (att != null) { gen.setUrl(att); } att = getAttributeValue(e, "version"); if (att != null) { gen.setVersion(att); } feed.setGenerator(gen); } e = eFeed.getChild("rights", getAtomNamespace()); if (e != null) { feed.setRights(parseTextConstructToString(e)); } e = eFeed.getChild("icon", getAtomNamespace()); if (e != null) { feed.setIcon(e.getText()); } e = eFeed.getChild("logo", getAtomNamespace()); if (e != null) { feed.setLogo(e.getText()); } e = eFeed.getChild("updated", getAtomNamespace()); if (e != null) { feed.setUpdated(DateParser.parseDate(e.getText(), locale)); } return feed; }