mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
split client and server into maven modules
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
package com.commafeed.backend.rome;
|
||||
|
||||
import org.jdom2.Element;
|
||||
|
||||
import com.rometools.opml.feed.opml.Opml;
|
||||
|
||||
/**
|
||||
* Add missing title to the generated OPML
|
||||
*
|
||||
*/
|
||||
public class OPML11Generator extends com.rometools.opml.io.impl.OPML10Generator {
|
||||
|
||||
public OPML11Generator() {
|
||||
super("opml_1.1");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Element generateHead(Opml opml) {
|
||||
Element head = new Element("head");
|
||||
addNotNullSimpleElement(head, "title", opml.getTitle());
|
||||
return head;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.commafeed.backend.rome;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import org.jdom2.Document;
|
||||
import org.jdom2.Element;
|
||||
|
||||
import com.rometools.opml.io.impl.OPML10Parser;
|
||||
import com.rometools.rome.feed.WireFeed;
|
||||
import com.rometools.rome.io.FeedException;
|
||||
|
||||
/**
|
||||
* Support for OPML 1.1 parsing
|
||||
*
|
||||
*/
|
||||
public class OPML11Parser extends OPML10Parser {
|
||||
|
||||
public OPML11Parser() {
|
||||
super("opml_1.1");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMyType(Document document) {
|
||||
Element e = document.getRootElement();
|
||||
|
||||
if (e.getName().equals("opml")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public WireFeed parse(Document document, boolean validate, Locale locale) throws IllegalArgumentException, FeedException {
|
||||
document.getRootElement().getChildren().add(new Element("head"));
|
||||
return super.parse(document, validate, locale);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.commafeed.backend.rome;
|
||||
|
||||
import com.rometools.rome.feed.rss.Description;
|
||||
import com.rometools.rome.feed.rss.Item;
|
||||
import com.rometools.rome.feed.synd.SyndContentImpl;
|
||||
import com.rometools.rome.feed.synd.SyndEntry;
|
||||
import com.rometools.rome.feed.synd.impl.ConverterForRSS090;
|
||||
|
||||
/**
|
||||
* Support description tag for RSS09
|
||||
*
|
||||
*/
|
||||
public class RSS090DescriptionConverter extends ConverterForRSS090 {
|
||||
|
||||
@Override
|
||||
protected SyndEntry createSyndEntry(Item item, boolean preserveWireItem) {
|
||||
SyndEntry entry = super.createSyndEntry(item, preserveWireItem);
|
||||
Description desc = item.getDescription();
|
||||
if (desc != null) {
|
||||
SyndContentImpl syndDesc = new SyndContentImpl();
|
||||
syndDesc.setValue(desc.getValue());
|
||||
entry.setDescription(syndDesc);
|
||||
}
|
||||
return entry;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.commafeed.backend.rome;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import org.jdom2.Element;
|
||||
|
||||
import com.rometools.rome.feed.rss.Description;
|
||||
import com.rometools.rome.feed.rss.Item;
|
||||
import com.rometools.rome.io.impl.RSS090Parser;
|
||||
|
||||
/**
|
||||
* Support description tag for RSS09
|
||||
*
|
||||
*/
|
||||
public class RSS090DescriptionParser extends RSS090Parser {
|
||||
|
||||
@Override
|
||||
protected Item parseItem(Element rssRoot, Element eItem, Locale locale) {
|
||||
Item item = super.parseItem(rssRoot, eItem, locale);
|
||||
Element e = eItem.getChild("description", getRSSNamespace());
|
||||
if (e != null) {
|
||||
Description desc = new Description();
|
||||
desc.setValue(e.getText());
|
||||
item.setDescription(desc);
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.commafeed.backend.rome;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.jdom2.Document;
|
||||
import org.jdom2.Element;
|
||||
import org.jdom2.Namespace;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.rometools.rome.io.impl.RSS10Parser;
|
||||
|
||||
public class RSSRDF10Parser extends RSS10Parser {
|
||||
|
||||
private static final String RSS_URI = "http://purl.org/rss/1.0/";
|
||||
private static final Namespace RSS_NS = Namespace.getNamespace(RSS_URI);
|
||||
|
||||
public RSSRDF10Parser() {
|
||||
super("rss_1.0", RSS_NS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMyType(Document document) {
|
||||
boolean ok = false;
|
||||
|
||||
Element rssRoot = document.getRootElement();
|
||||
Namespace defaultNS = rssRoot.getNamespace();
|
||||
List<Namespace> additionalNSs = Lists.newArrayList(rssRoot.getAdditionalNamespaces());
|
||||
List<Element> children = rssRoot.getChildren();
|
||||
if (CollectionUtils.isNotEmpty(children)) {
|
||||
Element child = children.get(0);
|
||||
additionalNSs.add(child.getNamespace());
|
||||
additionalNSs.addAll(child.getAdditionalNamespaces());
|
||||
}
|
||||
|
||||
ok = defaultNS != null && defaultNS.equals(getRDFNamespace());
|
||||
if (ok) {
|
||||
if (additionalNSs == null) {
|
||||
ok = false;
|
||||
} else {
|
||||
ok = false;
|
||||
for (int i = 0; !ok && i < additionalNSs.size(); i++) {
|
||||
ok = getRSSNamespace().equals(additionalNSs.get(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user