Due - Wednesday, February 11, 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
Programs must be implemented in Java.
Part 1- XML Database
Implement an XML database module for use in Project 1. Your database must provide (at minimum) the following functionality:
- Maintains data in an XML document of the following format:
<User name="username" local_rootdir="rootdir">
<LastModified>last mod date</LastModified>
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.
- Provides a mechanism to add new files for a given user and device.
- Provides a mechanism to modify content (e.g., changing status of a file to deleted).
- Provides a mechanism to search the database. You will use XPath to enable, at minimum, the following searches:
- For a givenuser, find files with a given name on a given computer.
- For a given user, find files with a name containing a given string on a given computer.
- For a given user, find files modified since a given date on a given computer.
- For a given user, retrieve all files on a given computer.
- Provides a mechanism to export the contents to a file.
- Provides a mechanism to import an existing database from a file.
- 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.
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.
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 - Wednesday February 11, 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.