Lab 3 - Using the RESTlet Framework
Due - Thursday, February 14, 2008
The goal of this lab is to give you some practice using the RESTlet
framework. For this lab, you will use the RESTlet framework to develop the
beginnings of your book download site.
Your application will respond to the following types of requests:
- host.com/books/title/{title} - retrieve data about the book with the
given title
example: host.com/books/title/Catcher%20in%20the%20Rye
- host.com/books/title?startswith={letter} - retrieve data about all
books that have titles beginning with the given letter
example: host.com/books/title?startswith=C
- host.com/books/title?contains={phrase} - retrieve data about all books
that have titles containing the given phrase
example: host.com/books/title?contains=Catcher
- host.com/books/author/{name} - retrieve data about all books by the
given author
example: host.com/books/author/JD%20Salinger
- host.com/books/author?startswith={letter} - retrieve data about all
books that have authors whose last names start with the given letter
example: host.com/books/author?startswith=S
- host.com/books/author?contains={partial_name} - retrieve data about all
books that have authors whose names contain the given phrase
example: host.com/books/author?contains=Salinger
Your responses will be XML documents of the following format, where there
may be several Book elements in a single response:
<?xml version="1.0" encoding="UTF-8"?>
<ResultList>
<Book EtextNum="9548">
<Author First="J.D" Last="Salinger"/>
<Title>Catcher in the Rye</Title>
<Location URI="http://www.host.com/books/9548"/>
<ReleaseDate>April, 2001</ReleaseDate>
</Book>
</ResultList>
Implementation Requirements and Hints
- Implement a database component that maintains the XML structure and
responds to query requests. For the final version of your application,
this component will need to support concurrent read and write
requests.
- Use XPath and the getNodes method of XmlRepresentation to retrieve the
appropriate Book elements.
- Make sure to appropriately handle errors and exceptional situations.
- Updated 2/10/08: When your server starts up it will
need to read the contents of the XML database from a file. You can either
(a) assume the XML file will be in a specific location relative to where
the program is run or (b) specify the location of the XML file in a
configuration file that your program processes at start up. In either
case, your README must specify where to place the XML file in order to
ensure that your program runs correctly. Also, note that your program
should work on any OS.
Grading
- 10 points for correctly responding to each type of request (total 60
points)
- 40 points for program design and documentation
Testing (Updated 2/10/08)
To test your program, I will run the following command:
java -cp {classpath provided in your readme}
BooksiteApplication
This will start an HTTP server that listens at port 3000. I will issue the
six types of GET requests shown above. Your server will respond with XML
documents in the format shown above.
You do not need to provide a client application, though your server should
accept requests from any HTTP client (including a web browser). This means
that you should be able to test your server on the same machine on which it
is running by launching a web browser and visiting a URL such as
http://localhost:3000/books/author?startswith=S.
Due 5:30PM - Thursday, February 14, 2008
- Submit all of your code, along with readmes, to your submit directory
at /home/submit/cs682-s08/username.
Note: No portion of your code may be copied from any other source
including another text book, a web page, or another student (current or
former). You must provide citations for any sources you have used in
designing and implementing your program.
Sami Rollins