close
Skip to content
This repository was archived by the owner on May 28, 2018. It is now read-only.

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

README.md

Feed Combiner WebApp Example

Feed Combiner is an application that allows us to aggregate entries from individual feeds and to provide a final combined result in several ways. In order to download a given aggregated combined feed, we can use REST API and consume the entry feeds in format, such as HTML, JSON and ATOM. If it's easier for us to use a browser and sufficient to display the settings of combined feeds, there is also a simple HTML page in which is possible to manage our combined feeds.

The application provides two ways to manage it: REST API and WEB Application

Contents

The example consists of four web resources implemented by the following:

org.glassfish.jersey.examples.feedcombiner.resource.CombinedFeedResource : The combined feed resource that saves a new combined feed which automatically starts a scheduler for downloading new entries for provided feeds. Then it is also able to delete a particular feed and provide list of entries of the given feed in JSON or ATOM XML format.

org.glassfish.jersey.examples.feedcombiner.resource.CombinedFeedController : The combined feed controller provides GUI Manager using FreeMarker templates. It is possible to save, delete, and show a particular feed using HTML forms generated from templates.

The mapping of the URI path space is presented in the following table:

URI path Resource class HTTP methods Allowed values
/combiner/feeds CombinerFeedResource POST returns JSON
/combiner/feeds/{feed_id} CombinerFeedResource DELETE N/A
/combiner/feeds/{feed_id}/entries CombinerFeedResource GET returns JSON or ATOM_XML
/combiner CombinerFeedController GET FreeMarker templates/index.ftl
/combiner CombinerFeedController POST FreeMarker templates/index.ftl
/combiner/{feed_id} CombinerFeedController GET FreeMarker templates/feed-entries.ftl
_/combiner/delete/{feed_id}?method=DELETE CombinerFeedController POST FreeMarker templates/index.ftl

Sample Response

Create a Combined Feed

  • URL: http://localhost:8080/combiner/feeds
  • Http-Method: POST
  • Content-Type: application/json
{
    "title": "title",
    "description": "description",
    "refreshPeriod": 5,
    "urls": [
        "http://www.buzzfeed.com/index.xml",
        "http://www.reddit.com/r/java/.rss"
    ]
}
  • refreshPeriod is optional value, if it's null, the default value from application.properties will be used
  • At least one URL must be valid otherwise an error message will be returned
{
    "messages":[
        "At least one valid URL must be in the request."
    ]
}

Response

  • Status Code: 201 Created
  • Location: http://localhost:8080/combiner/feeds/1
  • Content-Type: application/json
{
  "id":"1",
  "urls":[
    "http://www.buzzfeed.com/index.xml","http://www.reddit.com/r/java/.rss"
  ],
  "refreshPeriod":5,
  "feedEntries":[],
  "title":"title",
  "description":"description"
}

Delete a Combined Feed

Request

  • URL: http://localhost:8080/combiner/feeds/{feed_id}
  • Http-Method: DELETE

Response

  • Status Code: 204 No Content

Get Combined Feed entries

Request

  • URL: http://localhost:8080/combiner/feeds/{feed_id}/entries
  • Http-Method: GET
  • Accept: application/json or application/atom+xml

Response

  • Status Code: 200 OK
  • Body: Structured data depending on the Accept header in the request

Running the Example

Run the example as follows:

mvn clean compile exec:java

This deploys the example using Grizzly

mvn clean package jetty:run

This deploys current example using Jetty. You can access the application at

Resources

This examples is using the following (3-rd party) libraries:

ROME by RomeTools

ROME includes a set of parsers and generators for the various flavors of syndication feeds, as well as converters to convert from one format to another. The parsers can give you back Java objects that are either specific for the format you want to work with, or a generic normalized SyndFeed class that lets you work on with the data without bothering about the incoming or outgoing feed type.