You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by bu...@apache.org on 2004/08/20 23:44:08 UTC
cvs commit: jakarta-commons-sandbox/feedparser/src/java/org/apache/commons/feedparser/locate DiscoveryLocator.java FeedLocator.java ProbeLocator.java
burton 2004/08/20 14:44:07
Modified: feedparser/src/java/org/apache/commons/feedparser
FeedList.java
feedparser/src/java/org/apache/commons/feedparser/locate
DiscoveryLocator.java FeedLocator.java
ProbeLocator.java
Log:
Fixed bugs WRT the Atom feedparser RFC
Revision Changes Path
1.2 +25 -3 jakarta-commons-sandbox/feedparser/src/java/org/apache/commons/feedparser/FeedList.java
Index: FeedList.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/feedparser/src/java/org/apache/commons/feedparser/FeedList.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- FeedList.java 23 Apr 2004 17:45:43 -0000 1.1
+++ FeedList.java 20 Aug 2004 21:44:06 -0000 1.2
@@ -77,10 +77,32 @@
*
* @author <a href="mailto:burton@peerfear.org">Kevin Burton</a>
*/
- public void setAdAtomFeed( FeedReference adAtomFeed ) {
+ public void setAdAtomFeed( FeedReference ref ) {
- this.adAtomFeed = adAtomFeed;
+ this.adAtomFeed = ref;
+ }
+
+ public void setFirstAdAtomFeed( FeedReference ref ) {
+
+ // > The order of the autodiscovery elements is significant.
+ // > The first element SHOULD point to the publisher's
+ // > preferred feed for the document.
+
+ if ( getAdAtomFeed() == null )
+ setAdAtomFeed( ref );
+
+ }
+
+ public void setFirstAdRSSFeed( FeedReference ref ) {
+
+ // > The order of the autodiscovery elements is significant.
+ // > The first element SHOULD point to the publisher's
+ // > preferred feed for the document.
+
+ if ( getAdRSSFeed() == null )
+ setAdRSSFeed( ref );
+
}
}
1.13 +32 -8 jakarta-commons-sandbox/feedparser/src/java/org/apache/commons/feedparser/locate/DiscoveryLocator.java
Index: DiscoveryLocator.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/feedparser/src/java/org/apache/commons/feedparser/locate/DiscoveryLocator.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- DiscoveryLocator.java 13 Aug 2004 23:19:24 -0000 1.12
+++ DiscoveryLocator.java 20 Aug 2004 21:44:06 -0000 1.13
@@ -24,6 +24,8 @@
/**
*
+ * http://xml.coverpages.org/draft-ietf-atompub-autodiscovery-00.txt
+ *
* @author <a href="mailto:burton@apache.org">Kevin A. Burton</a>
*/
public class DiscoveryLocator {
@@ -33,13 +35,21 @@
* this.
*/
static Pattern element_pattern =
- Pattern.compile( "<link[^>]+" );
+ Pattern.compile( "<link[^>]+",
+ Pattern.CASE_INSENSITIVE );
/**
- * Regex to match on
+ * Regex to match on attributes.
*/
+
+ // > Attribute values MUST be one of the following: enclosed in double
+ // > quotes, enclosed in single quotes, or not enclosed in quotes at all.
+ //
+ // FIXME: we don't YET support this.
+
static Pattern attr_pattern =
- Pattern.compile( "([a-zA-Z]+)=[\"']([^\"']+)[\"']" );
+ Pattern.compile( "([a-zA-Z]+)=[\"']([^\"']+)[\"']",
+ Pattern.CASE_INSENSITIVE );
static HashSet mediatypes = new HashSet();
@@ -88,17 +98,28 @@
//expand the href
String href = (String)attributes.get( "href" );
+
+ // http://xml.coverpages.org/draft-ietf-atompub-autodiscovery-00.txt
+
+ // > The href attribute MUST be present in an Atom autodiscovery element,
+ // > and its value MUST be the URI [RFC2396] of an Atom feed. The value
+ // > MAY be a relative URI, and if so, clients MUST resolve it to a full
+ // > URI (section 5 of [RFC2396]) using the document's base URI (section
+ // > 12.4 of HTML 4 [W3C.REC-html401-19991224]).
+
href = ResourceExpander.expand( resource, href );
FeedReference feedReference = new FeedReference( href, type );
+ feedReference.title = (String)attributes.get( "title" );
+
list.add( feedReference );
if ( type.equals( FeedReference.ATOM_MEDIA_TYPE ) )
- list.setAdAtomFeed( feedReference );
-
+ list.setFirstAdAtomFeed( feedReference );
+
if ( type.equals( FeedReference.RSS_MEDIA_TYPE ) )
- list.setAdRSSFeed( feedReference );
+ list.setFirstAdRSSFeed( feedReference );
}
@@ -123,8 +144,11 @@
while ( m.find( index ) ) {
- String name = m.group( 1 );
- String value = m.group( 2 );
+ String name = m.group( 1 ).toLowerCase().trim();
+ String value = m.group( 2 ).toLowerCase().trim();
+
+ if ( "".equals( value ) )
+ value = null;
map.put( name, value );
1.17 +7 -1 jakarta-commons-sandbox/feedparser/src/java/org/apache/commons/feedparser/locate/FeedLocator.java
Index: FeedLocator.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/feedparser/src/java/org/apache/commons/feedparser/locate/FeedLocator.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- FeedLocator.java 18 Aug 2004 18:23:01 -0000 1.16
+++ FeedLocator.java 20 Aug 2004 21:44:06 -0000 1.17
@@ -85,13 +85,19 @@
//String resource = "file:///projects/feedparser/tests/locate5.html";
//String resource = "file:///projects/feedparser/tests/locate6.html";
+ String resource = "file:///projects/feedparser/tests/locate8.html";
+
//String resource = "http://blogs.sun.com/roller/page/gonzo";
//String resource = "http://gonze.com/weblog/";
//String resource = "http://codinginparadise.org/";
- String resource= "http://www.thealarmclock.com/mt/";
+
+ // String resource = "http://bucsfishingreport.com/pMachine/weblog.php";
+
+ //String resource = "http://www.livejournal.com/community/indiexiankids/";
+//String resource= "http://www.thealarmclock.com/mt/";
//String resource = "http://guinness.joeuser.com";
1.8 +9 -0 jakarta-commons-sandbox/feedparser/src/java/org/apache/commons/feedparser/locate/ProbeLocator.java
Index: ProbeLocator.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/feedparser/src/java/org/apache/commons/feedparser/locate/ProbeLocator.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- ProbeLocator.java 11 Aug 2004 20:48:09 -0000 1.7
+++ ProbeLocator.java 20 Aug 2004 21:44:06 -0000 1.8
@@ -31,6 +31,15 @@
static HashMap probeMapping = new HashMap();
+ //FIXME: also just try common path names. Do this in ORDER so that I find
+ //beter metadata feeds sooner
+ //
+ // /atom.xml
+ // /atom.xml
+ // /rss.xml
+ // /index.xml
+ // /index.rdf
+
static {
// We can use:
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org