Creating a Mashup
In this assignment, you will learn how to mashup the information
published on the Web
as RSS
feeds. Mashups
are situational
applications: they are meant for specific, generally short lived,
needs and thus have to be put together rather quickly and easily. RSS is
a leading standard for publishing structured summaries of information
(syndication) over the Web. Example uses of RSS include news headlines,
blog posts, stock quotes, and weather information.
A popular way of creating mashups is to aggregate, manipulate, and republish
the information published as RSS feeds by various providers. Visit Yahoo pipes to familiarize yourself with some
simple and cool examples of mashups created by others. You will create
your own mashup in this assignment using tools provided by Project Zero.
What is our Situation (Specific Need)?
John Q. Tourist of Raleigh wishes to plan a vacation trip during the
period of 4/7 to 4/13. He does not have a strong preference about the
location: he can go to either of New York City, Washington DC, or
Miami. Being a bargain-lover, he wants to make sure he gets the best
airline and hotel deal there is. However, John is discouraged by the
daunting task of checking for deals on the Web every so often. How can
we help him?
We find that Farecast publishes airline deals as
RSS feeds. We also
find that Expedia publishes a
similar feed
for hotel deals. At Farecast, we can create a custom RSS feed for deals
to NYC (LGA), Washington DC (DCA), and Miami (MIA). At Expedia, we can
create three custom RSS feeds, one for each city. Then, we can quickly
develop an application using Project Zero to read these feeds, find the
lowest cost city (air + 6 nights at a hotel), and publish a feed that
shows information for air and hotel booking for the cheapest of the
three cities. To remain focused on the best deals, our feed is updated
only when a cheaper city and deal is found. Our application
will simulate checking for updates at Farecast and Expedia
every 7 seconds, by instead checking equivalent feeds found here:
http://bombadil.csc.ncsu.edu:8080/cscairdeals,
http://bombadil.csc.ncsu.edu:8080/cscmiamihotels,
http://bombadil.csc.ncsu.edu:8080/cscdchotels, and
http://bombadil.csc.ncsu.edu:8080/cscnychotels.
These feeds are updated every 7 seconds (to reduce testing
time). So your scripts would read and publish updates every 7
seconds.
Part 1: Reading an RSS Feed
First you should learn how to read an RSS feed. This part is just a
learning exercise and there are no deliverables associated with it.
However, learning this part is essential for the final deliverables. We
will use the
Rome APIs
(built-in support in Project Zero) for reading and creating RSS feeds.
- First, create your custom RSS feeds at the simulated Farecast and
the simulated Expedia for the cities John is interested in (one feed
at Farecast, three separate feeds at Expedia). Save the URLs to each
of these feeds.
- Explore these
Rome tutorials in general for the entire assignment. In particular,
see this
on how RSS feeds can be read.
- Develop a zero application that reads one of your custom feeds and dumps
the retrieved information. To do this
- Go through this
documentation on how to add RSS support to a blank Zero project.
- Right click your ivy.xml -> zero tools -> resolve. This adds the
requisite Rome libraries to your project.
- Following the above tutorial, write a simple Groovy script in your
public folder to read a feed and output the retrieved feeds. You can run the
script simply by pointing your browser to the URL for this script.
- Within your script, access the various fields of the feed entries, such
as title, link, and description. For the airfare feeds, parse the title to
extract the city and the fare amount.
- At this point, you should feel comfortable with reading RSS feeds into
your application.
Part 2: Publishing an RSS Feed
This part also is just a learning exercise, but essential for the final
deliverables.
- Go through this
tutorial.
- Write a public Groovy script that creates a feed from hypothetical data
and outputs it as a file to your public folder.
- Note that when you create your own feed, you have to specify the
feedType. Use "rss_2.0" as the feed type in this assignment.
- Try to read this feed (the URL will be the URL of your file) into the
reader script developed in Part 1.
- At this point, you should feel comfortable with publishing your own RSS
feeds.
Deliverables
Upload to the dropbox a Project Zero project that includes the following
components:
- A Groovy script airdeals.groovy that reads Farecast feeds and publishes
the results every 7 seconds to http://localhost:8080/myairdeals.
- Groovy scripts nyc.groovy, dc.groovy, and miami.groovy that read Expedia
feeds for the three cities and publish the results every 7 seconds to
http://localhost:8080/mynychotels, http://localhost:8080/mydchotels, and
http://localhost:8080/mymiamihotels.
- An aggregator Groovy script cheapest.groovy that reads the above
published feeds, picks the cheapest city in terms of air + 6 nights of
hotel, and updates http://localhost:8080/mycheapestcity only when the
newly available deal is better than the current cheapest deal. For
Expedia feeds, assume that the published deals are available for
John's travel dates.
- A Groovy script showme.groovy that reads the aggregated feed every 7
seconds and shows the result. Here is a sample
of what this result could look like.
Testing and Grading
Notice that the Farecast and Expedia deals do not change frequently
enough for us to test whether your mashup updates correctly and finds
the cheapest combination. For this reason, for testing purposes, we will
replace your scripts that read from these providers with our scripts.
Hence, your aggregator will be tested against our feeds. Our feeds will
conform to the formatting of the Farecast and Expedia feeds. However,
they will have hypothetical fares that update quite frequently. If your
mashup eventually finds the cheapest combination from our feeds and does
not update anymore, then it is correct.
We will run your project and fire browser requests to airdeals.groovy
(ours), nyc.groovy (ours), dc.groovy (ours), miami.groovy (ours), and
cheapest.groovy (yours). We will watch showme.groovy (yours) to see the
result. We will check that the file public/mycheapestcity does not
update once the best deal has been found.
Tips and Tricks for Solving the John Q. Tourist Situation
- You will have to use the Java Timer API in your feed publisher
scripts to fire them at regular
intervals. Here
is a useful tutorial. To avoid MissingMethodExceptions, you may want
to put your TimerTask class in the Java folder of your project and
simply schedule it from Groovy.
- Your script that shows the final result needs to refresh every 7
seconds to show any updates. Find and use a simple HTML refresh
mechanism.