Lab 3 - XML

Due - Monday, September 21, 2009 - 3:30PM

The goal of this lab is to give you some practice using XML. For this lab, you will write a program that builds a thread-safe XML database and enables a user to search for particular items. You will also write an XML Schema that specifies the format of the XML document you build.

Grading will be based on correctness (whether your program produces the correct output) as well as the design and documentation. Poorly designed programs (e.g., programs that consist of a giant main method) will be penalized.

Programs must be implemented in Java.

Part 1- XML Database

(55 points)

Implement an XML database module for use in Project 1.  Your database must provide (at minimum) the following functionality:

  1. Maintains data in an XML document of the following format:

        <User name="username" local_rootdir="rootdir">
                            <Name>computer name</Name>
                                        <Size>file size</Size>
                                        <LastModified>last mod date</LastModified>

  2. Each file found will be represented by a File element.  The element contains the path to the file, the name of the file, whether a file previously added to the database has been deleted, the size of the file, an element that will contain information about location of backed up files (part 2 of the main project), and the last modified date.

  3. Provides a mechanism to add new files for a given user and device.
  4. Provides a mechanism to modify content (e.g., changing status of a file to deleted).
  5. Provides a mechanism to search the database.  You will use XPath to enable, at minimum, the following searches:
    1. For a given user, find files with a given name on a given computer (i.e., the filename matches the input string).
    2. For a given user, find files with a name containing a given string on a given computer (i.e., the filename contains the input string).
    3. For a given user, find files modified since a given date on a given computer.
    4. For a given user, retrieve all files on a given computer.
  6. Provides a mechanism to export the contents to a file.
  7. Provides a mechanism to import an existing database from a file. 
  8. Provides concurrency control.  You will implement your own concurrency control mechanism.  Your database will support multiple concurrent reads, but a write operation conflicts with both reads and writes.  For example, multiple threads may be concurrently searching the database, but a thread that wishes to add a new file must wait until there are no other threads reading or writing before it begins its operation.  This means you may not simply liberally use the synchronized keyword.

Part 2

(30 points)

Implement an update thread that periodically traverses the root directories specified for each user and updates the database accordingly.  New files will be added to the database, updated files will be changed, and deleted files will be marked as such.

Part 3

(15 points)

Implement an XML Schema for your XML document. You must be able to validate your database using a schema validator such as this one.

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 3:30PM - Monday September 21, 2009

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.