Lab 3 - RESTlets

Due - Wednesday, February 18, 2009- 3:30PM

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 a web service that will provide access to the content stored in the XML database you developed for Lab 2.

You will implement a RESTlet application that accepts HTTP GET requests for the following URLs and responds with the content specified:

 URL Response Format
 Action
{device_name}/xml/filelist   200 OK
    <FileList>
        <File>
            <Path>/path/to/file</Path>
            <Name>filename.ext</Name>
            <Size>file size</Size>
            <LastModified>last mod date</LastModified>
        </File>
    </FileList>   
List all files on the computer identified by device_name.  For device name all, return a list of all files on all of the user's computers.
{device_name}/xml/filelist?contains={query}     200 OK
    <FileList>
        <File>
            <Path>/path/to/file</Path>
            <Name>filename.ext</Name>
            <Size>file size</Size>
            <LastModified>last mod date</LastModified>
        </File>
    </FileList>   

List all files on the computer identified by device_name that have a file name that contains the query term.  For device name all, return a list of all files on all of the user's computers that meet the query criteria.
{device_name}/xml/filelist?matches={query}    200 OK
    <FileList>
        <File>
            <Path>/path/to/file</Path>
            <Name>filename.ext</Name>
            <Size>file size</Size>
            <LastModified>last mod date</LastModified>
        </File>
    </FileList>   
List all files on the computer identified by device_name that have a file name that match the query term exactly.  For device name all, return a list of all files on all of the user's computers that meet the query criteria.
{device_name}/xml/filelist?modifiedsince={date}    200 OK
    <FileList>
        <File>
            <Path>/path/to/file</Path>
            <Name>filename.ext</Name>
            <Size>file size</Size>
            <LastModified>last mod date</LastModified>
        </File>
    </FileList>   
List all files on the computer identified by device_name that have been modified since the date provided.  For device name all, return a list of all files on all of the user's computers that meet the query criteria.
{device_name}/xml/file/{path/to/file/and/filename.ext}    200 OK
    File Contents
Return contents of specified file.

Implementation Requirements and Hints

  1. At startup, your server will initialize your XML database.  Between runs, you may save your database to a file and read it in at startup.  You will also start the update thread you implemented for Lab 2.
  2. Your server will listen on port 3000.  You may use a final variable to specify this value, or make it configurable.  
  3. You may assume there is only one user at this point.
  4. You may assume that you only return locally stored information.  In other words, run the query over the data in the XML document in memory; do not worry about proactively querying any other devices.
  5. Following is the testing procedure I will use to test your program:
    1. Configure server to read a local directory.
    2. Start server using java -cp {classpath you provide} FileSyncApplication
    3. Using an HTTP client (e.g., a browser), issue GET requests for each of the URLs above.  I will issue requests using valid information and invalid information.  You should correctly respond to requests for data that does not exist as well as correctly respond to invalid requests.

Grading

  • 15 points each for correct responses to each type of query (total 75 points)
  • 25 points design and documentation
Refer to the Submission Instructions.  In addition, make sure you do not hardcode any parameters that will change when running your program in a different environment.  For example, you should not hard code "C:\\bob's computer\my directory" as your root directory, as I will not be running your program on "bob's computer".  You may use a configuration file if you feel it is appropriate, and provide sufficient README instructions for changing necessary parameters.

Due - Wednesday, February 18, 2009- 3:30PM

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.
Comments