Added support for docs, managingEditor, webMaster and generator on RSS

channel and comments on RSS items (fixes #162)
This commit is contained in:
Martin Kurz 2013-10-07 23:05:58 +02:00
parent c1851448e3
commit e9bb18b89b
7 changed files with 250 additions and 3 deletions

View file

@ -421,6 +421,23 @@ public interface SyndEntry extends Cloneable, CopyFrom<SyndEntry>, Extendable {
*/ */
public void setForeignMarkup(List<Element> foreignMarkup); public void setForeignMarkup(List<Element> foreignMarkup);
/**
* URL of a page for comments relating to the item.
*
* @since 2.0.0
* @return comments URL or {@code null}.
*
*/
String getComments();
/**
* URL of a page for comments relating to the item.
*
* @since 2.0.0
* @param comments URL
*/
void setComments(String comments);
/** /**
* Creates a deep clone of the object. * Creates a deep clone of the object.
* <p> * <p>

View file

@ -51,6 +51,7 @@ public class SyndEntryImpl implements Serializable, SyndEntry {
private final ObjectBean objBean; private final ObjectBean objBean;
private String uri; private String uri;
private String link; private String link;
private String comments;
private Date updatedDate; private Date updatedDate;
private SyndContent title; private SyndContent title;
private SyndContent description; private SyndContent description;
@ -691,6 +692,22 @@ public class SyndEntryImpl implements Serializable, SyndEntry {
this.foreignMarkup = foreignMarkup; this.foreignMarkup = foreignMarkup;
} }
/**
* {@inheritDoc}
*/
@Override
public String getComments() {
return comments;
}
/**
* {@inheritDoc}
*/
@Override
public void setComments(String comments) {
this.comments = comments;
}
@Override @Override
public Object getWireEntry() { public Object getWireEntry() {
return wireEntry; return wireEntry;

View file

@ -572,6 +572,76 @@ public interface SyndFeed extends Cloneable, CopyFrom<SyndFeed>, Extendable {
*/ */
public void setForeignMarkup(List<Element> foreignMarkup); public void setForeignMarkup(List<Element> foreignMarkup);
/**
* This tag should contain a URL that references a description of the
* channel.
*
* @since 2.0.0
* @return channel description URL or {@code null}
*/
String getDocs();
/**
* This tag should contain a URL that references a description of the
* channel.
*
* @since 2.0.0
* @param channel description URL
*/
public void setDocs(String docs);
/**
* A string indicating the program used to generate the channel.
*
* @since 2.0.0
* @return string indicating the program or {@code null}
*/
String getGenerator();
/**
* A string indicating the program used to generate the channel.
*
* @since 2.0.0
* @param string indicating the program
*/
public void setGenerator(String generator);
/**
* The email address of the managing editor of the site, the person to
* contact for editorial inquiries.
*
* @since 2.0.0
* @return email address of the managing editor or {@code null}
*/
String getManagingEditor();
/**
* The email address of the managing editor of the site, the person to
* contact for editorial inquiries.
*
* @since 2.0.0
* @param managingEditor email address of the managing editor
*/
public void setManagingEditor(String managingEditor);
/**
* The email address of the webmaster for the site, the person to contact if
* there are technical problems with the channel.
*
* @since 2.0.0
* @return email address of the webmaster or {@code null}
*/
String getWebMaster();
/**
* The email address of the webmaster for the site, the person to contact if
* there are technical problems with the channel.
*
* @since 2.0.0
* @param webMaster email address of the webmaster
*/
void setWebMaster(String webMaster);
/** /**
* Creates a deep clone of the object. * Creates a deep clone of the object.
* <p> * <p>

View file

@ -62,6 +62,10 @@ public class SyndFeedImpl implements Serializable, SyndFeed {
private SyndContent description; private SyndContent description;
private String feedType; private String feedType;
private String link; private String link;
private String webMaster;
private String managingEditor;
private String docs;
private String generator;
private List<SyndLink> links; private List<SyndLink> links;
private SyndImage image; private SyndImage image;
private List<SyndEntry> entries; private List<SyndEntry> entries;
@ -929,4 +933,68 @@ public class SyndFeedImpl implements Serializable, SyndFeed {
public boolean isPreservingWireFeed() { public boolean isPreservingWireFeed() {
return preserveWireFeed; return preserveWireFeed;
} }
/**
* {@inheritDoc}
*/
@Override
public String getDocs() {
return docs;
}
/**
* {@inheritDoc}
*/
@Override
public void setDocs(String docs) {
this.docs = docs;
}
/**
* {@inheritDoc}
*/
@Override
public String getGenerator() {
return generator;
}
/**
* {@inheritDoc}
*/
@Override
public void setGenerator(String generator) {
this.generator = generator;
}
/**
* {@inheritDoc}
*/
@Override
public String getManagingEditor() {
return managingEditor;
}
/**
* {@inheritDoc}
*/
@Override
public void setManagingEditor(String managingEditor) {
this.managingEditor = managingEditor;
}
/**
* {@inheritDoc}
*/
@Override
public String getWebMaster() {
return webMaster;
}
/**
* {@inheritDoc}
*/
@Override
public void setWebMaster(String webMaster) {
this.webMaster = webMaster;
}
} }

View file

@ -53,6 +53,10 @@ public class ConverterForRSS091Userland extends ConverterForRSS090 {
super.copyInto(channel, syndFeed); super.copyInto(channel, syndFeed);
syndFeed.setLanguage(channel.getLanguage()); // c syndFeed.setLanguage(channel.getLanguage()); // c
syndFeed.setCopyright(channel.getCopyright()); // c syndFeed.setCopyright(channel.getCopyright()); // c
syndFeed.setDocs(channel.getDocs());
syndFeed.setManagingEditor(channel.getManagingEditor());
syndFeed.setWebMaster(channel.getWebMaster());
syndFeed.setGenerator(channel.getGenerator());
final Date pubDate = channel.getPubDate(); final Date pubDate = channel.getPubDate();
@ -101,7 +105,7 @@ public class ConverterForRSS091Userland extends ConverterForRSS090 {
@Override @Override
protected Item createRSSItem(final SyndEntry sEntry) { protected Item createRSSItem(final SyndEntry sEntry) {
final Item item = super.createRSSItem(sEntry); final Item item = super.createRSSItem(sEntry);
item.setComments(sEntry.getComments());
final SyndContent sContent = sEntry.getDescription(); final SyndContent sContent = sEntry.getDescription();
if (sContent != null) { if (sContent != null) {
@ -127,6 +131,10 @@ public class ConverterForRSS091Userland extends ConverterForRSS090 {
channel.setLanguage(syndFeed.getLanguage()); // c channel.setLanguage(syndFeed.getLanguage()); // c
channel.setCopyright(syndFeed.getCopyright()); // c channel.setCopyright(syndFeed.getCopyright()); // c
channel.setPubDate(syndFeed.getPublishedDate()); // c channel.setPubDate(syndFeed.getPublishedDate()); // c
channel.setDocs(syndFeed.getDocs());
channel.setManagingEditor(syndFeed.getManagingEditor());
channel.setWebMaster(syndFeed.getWebMaster());
channel.setGenerator(syndFeed.getGenerator());
if (syndFeed.getAuthors() != null && syndFeed.getAuthors().size() > 0) { if (syndFeed.getAuthors() != null && syndFeed.getAuthors().size() > 0) {
final SyndPerson author = syndFeed.getAuthors().get(0); final SyndPerson author = syndFeed.getAuthors().get(0);
@ -143,6 +151,7 @@ public class ConverterForRSS091Userland extends ConverterForRSS090 {
protected SyndEntry createSyndEntry(final Item item, final boolean preserveWireItem) { protected SyndEntry createSyndEntry(final Item item, final boolean preserveWireItem) {
final SyndEntry syndEntry = super.createSyndEntry(item, preserveWireItem); final SyndEntry syndEntry = super.createSyndEntry(item, preserveWireItem);
final Description desc = item.getDescription(); final Description desc = item.getDescription();
syndEntry.setComments(item.getComments());
if (desc != null) { if (desc != null) {
final SyndContent descContent = new SyndContentImpl(); final SyndContent descContent = new SyndContentImpl();

View file

@ -115,9 +115,9 @@ public class RSS091UserlandParser extends RSS090Parser {
if (e != null) { if (e != null) {
channel.setDocs(e.getText()); channel.setDocs(e.getText());
} }
e = eChannel.getChild("docs", getRSSNamespace()); e = eChannel.getChild("generator", getRSSNamespace());
if (e != null) { if (e != null) {
channel.setDocs(e.getText()); channel.setGenerator(e.getText());
} }
e = eChannel.getChild("managingEditor", getRSSNamespace()); e = eChannel.getChild("managingEditor", getRSSNamespace());
if (e != null) { if (e != null) {

View file

@ -0,0 +1,66 @@
package com.sun.syndication.unittest.issues;
import java.util.List;
import com.sun.syndication.feed.rss.Channel;
import com.sun.syndication.feed.rss.Item;
import com.sun.syndication.feed.synd.SyndEntry;
import com.sun.syndication.feed.synd.SyndFeed;
import com.sun.syndication.unittest.TestSyndFeedRSS20;
/**
* Test for #161: No source element in RSS 2.0 items.
* @author Martin Kurz
*
*/
public class Isseue162Test extends TestSyndFeedRSS20 {
public Isseue162Test() {
super("rss_2.0");
}
public void testWireFeed() throws Exception {
final Channel channel = ((Channel) this.getCachedWireFeed());
assertProperty(channel.getDocs(), "channel.docs");
assertProperty(channel.getGenerator(), "channel.generator");
assertProperty(channel.getManagingEditor(), "channel.managingEditor");
assertProperty(channel.getWebMaster(), "channel.webMaster");
}
public void testWireFeedItems() throws Exception {
final int count = ((Channel) this.getCachedWireFeed()).getItems().size();
for (int i = 0; i < count; i++) {
testItem(i);
}
}
protected void testWireFeedItem(final int i) throws Exception {
final List<Item> items = ((Channel) this.getCachedWireFeed()).getItems();
final Item entry = items.get(i);
assertProperty(entry.getComments(), "channel.item[" + i + "].comments");
}
public void testSyndFeed() throws Exception {
final SyndFeed feed = this.getCachedSyndFeed();
assertProperty(feed.getDocs(), "channel.docs");
assertProperty(feed.getGenerator(), "channel.generator");
assertProperty(feed.getManagingEditor(), "channel.managingEditor");
assertProperty(feed.getWebMaster(), "channel.webMaster");
}
public void testSyndFeedItems() throws Exception {
final int count = this.getCachedSyndFeed().getEntries().size();
for (int i = 0; i < count; i++) {
testItem(i);
}
}
@Override
protected void testItem(final int i) throws Exception {
super.testItem(i);
final List<SyndEntry> items = this.getCachedSyndFeed().getEntries();
final SyndEntry entry = items.get(i);
assertProperty(entry.getComments(), "channel.item[" + i + "].comments");
}
}