burton      2004/09/30 12:27:38

  Modified:    feedparser/src/java/org/apache/commons/feedparser/locate
                        BlogService.java BlogServiceDiscovery.java
                        FeedLocator.java ProbeLocator.java
  Log:
  Fix for flickr... use HTTP 404 guys... ug
  
  Revision  Changes    Path
  1.4       +112 -32   
jakarta-commons-sandbox/feedparser/src/java/org/apache/commons/feedparser/locate/BlogService.java
  
  Index: BlogService.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/feedparser/src/java/org/apache/commons/feedparser/locate/BlogService.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- BlogService.java  30 Sep 2004 18:00:32 -0000      1.3
  +++ BlogService.java  30 Sep 2004 19:27:38 -0000      1.4
  @@ -46,37 +46,6 @@
       public static BlogService GREYMATTER             = new BlogService(16, true);
       public static BlogService TEXTAMERICA            = new BlogService(17, false);
   
  -    public static BlogService YAHOOGROUPS            = new BlogService(18, false) {
  -
  -            public String getFeedResource( String resource ) {
  -
  -//                 * Input: http://groups.yahoo.com/group/aggregators/
  -//                 *
  -//                 * Output: http://rss.groups.yahoo.com/group/aggregators/rss
  -
  -                if ( resource == null )
  -                    return null;
  -
  -                if ( resource.indexOf( "/group/" ) != -1  &&
  -                     resource.indexOf( "groups.yahoo.com" ) != -1 ) {
  -
  -                    resource = "http://rss."; +
  -                        resource.substring( "http://".length(), resource.length() )
  -                        ;
  -
  -                    if ( resource.endsWith( "/" ) ) {
  -                        resource += "rss";
  -                    } else {
  -                        resource += "/rss";
  -                    }
  -
  -                } 
  -
  -                return resource;
  -            }
  -
  -        };
  -    
       /** The type of BlogService this is, such as BlogService.BLOSXOM. */
       private int type;
       
  @@ -122,7 +91,39 @@
       public String getFeedResource( String resource ) {
           return resource;
       }
  -    
  +
  +    /**
  +     * Set to true if getFeedResource() should be used.
  +     *
  +     * @author <a href="mailto:[EMAIL PROTECTED]">Kevin A. Burton</a>
  +     */
  +    public boolean useCustomFeedResource() {
  +        return false;
  +    }
  +
  +    /**
  +     * Return true when this BlogService supports this URL.
  +     *
  +     * @author <a href="mailto:[EMAIL PROTECTED]">Kevin A. Burton</a>
  +     */
  +    public boolean accept( String resource, String content ) {
  +        return false;
  +    }
  +
  +    /**
  +     * Required implementation when you want to perform a location map.  The
  +     * default implementation does nothing.
  +     *
  +     * @author <a href="mailto:[EMAIL PROTECTED]">Kevin A. Burton</a>
  +     */
  +    public FeedReference[] getLocations() {
  +
  +        FeedReference[] locations = { new FeedReference( "", 
FeedReference.RSS_MEDIA_TYPE) };
  +
  +        return locations;
  +
  +    }
  +
       public String toString() {
           // use reflection to get the type string; useful so we don't have to
           // maintain a list of types here.  Since this is only used for debugging
  @@ -164,4 +165,83 @@
       public int hashCode() {
           return type;
       }
  +
  +    // **** custom BlogService impls ********************************************
  +
  +    public static BlogService YAHOOGROUPS            = new BlogService( 18, false ) 
{
  +
  +            public String getFeedResource( String resource ) {
  +
  +                //  * Input: http://groups.yahoo.com/group/aggregators/
  +                //  *
  +                //  * Output: http://rss.groups.yahoo.com/group/aggregators/rss
  +
  +                if ( resource == null )
  +                    return null;
  +
  +                if ( resource.indexOf( "/group/" ) != -1  &&
  +                     resource.indexOf( "groups.yahoo.com" ) != -1 ) {
  +
  +                    resource = "http://rss."; +
  +                        resource.substring( "http://".length(), resource.length() )
  +                        ;
  +
  +                    if ( resource.endsWith( "/" ) ) {
  +                        resource += "rss";
  +                    } else {
  +                        resource += "/rss";
  +                    }
  +
  +                } 
  +
  +                return resource;
  +            }
  +
  +            public boolean useCustomFeedResource() {
  +                return true;
  +            }
  +
  +        };
  +
  +    public static BlogService FLICKR                 = new BlogService( 19, false ) 
{
  +
  +            public String getFeedResource( String resource ) {
  +
  +                //  * Input: http://flickr.com/photos/tags/cats/
  +                //  *
  +                //  * Output: 
http://flickr.com/services/feeds/photos_public.gne?tags=cats&format=atom_03
  +
  +                if ( resource == null )
  +                    return null;
  +
  +                int begin = resource.indexOf( "/tags/" );
  +
  +                //we can't continue here.
  +                if ( begin == -1 )
  +                    return resource;
  +
  +                begin += 6;
  +
  +                int end = resource.lastIndexOf( "/" );
  +                if ( end == -1 || end < begin )
  +                    end = resource.length();
  +
  +                String tag = resource.substring( begin, end );
  +
  +                return "http://flickr.com/services/feeds/photos_public.gne?tags="; +
  +                       tag +
  +                       "&format=atom_03";
  +                
  +            }
  +
  +            public boolean useCustomFeedResource() {
  +                return true;
  +            }
  +
  +            public boolean accept( String resource, String content ) {
  +                return resource.indexOf( "http://flickr.com"; ) != -1;
  +            }
  +
  +        };
  +
   }
  
  
  
  1.4       +3 -0      
jakarta-commons-sandbox/feedparser/src/java/org/apache/commons/feedparser/locate/BlogServiceDiscovery.java
  
  Index: BlogServiceDiscovery.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/feedparser/src/java/org/apache/commons/feedparser/locate/BlogServiceDiscovery.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- BlogServiceDiscovery.java 30 Sep 2004 18:00:32 -0000      1.3
  +++ BlogServiceDiscovery.java 30 Sep 2004 19:27:38 -0000      1.4
  @@ -121,6 +121,9 @@
           else if ( isYahooGroups( resource, content ) ) {
               return BlogService.YAHOOGROUPS;
           }
  +        else if ( BlogService.FLICKR.accept( resource, content ) ) {
  +            return BlogService.FLICKR;
  +        }
           else {
               return BlogService.UNKNOWN;
           }
  
  
  
  1.22      +1 -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.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- FeedLocator.java  30 Sep 2004 18:00:32 -0000      1.21
  +++ FeedLocator.java  30 Sep 2004 19:27:38 -0000      1.22
  @@ -104,7 +104,7 @@
           //String resource = "file:///projects/feedparser/tests/locate5.html";
           //String resource = "file:///projects/feedparser/tests/locate6.html";
   
  -        String resource = "http://groups.yahoo.com/group/aggregators/";;
  +        String resource = "http://flickr.com/photos/tags/cat/";;
           
           //String resource = "file:///projects/feedparser/tests/locate8.html";
   
  
  
  
  1.15      +11 -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.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- ProbeLocator.java 30 Sep 2004 18:00:32 -0000      1.14
  +++ ProbeLocator.java 30 Sep 2004 19:27:38 -0000      1.15
  @@ -174,7 +174,12 @@
           probeMapping.put( BlogService.XANGA,          xangaLocations);
           probeMapping.put( BlogService.YAHOOGROUPS,    yahooGroupsLocations);
   
  +        //probeMapping.put( BlogService.YAHOOGROUPS,    yahooGroupsLocations);
  +
  +        probeMapping.put( BlogService.FLICKR,         
BlogService.FLICKR.getLocations() );
  +
           probeMapping.put( BlogService.UNKNOWN,        unknownLocations );
  +
           probeMapping.put( BlogService.TEXTAMERICA,    textAmericaLocations );
   
       }
  @@ -233,6 +238,12 @@
                           
                       }
   
  +                    //right now this is ONLY for Flickr
  +
  +                    if ( blogService.useCustomFeedResource() ) {
  +                        pathToTest = blogService.getFeedResource( resource );
  +                    }
  +                    
                       log.info( "pathToTest = " + pathToTest );
   
                       if ( feedExists( pathToTest ) ) {
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to