首页 > > 详细

辅导data编程、辅导java/sql程序

ChatSys
For this course’s assignment, you will have to implement a chat system as a web service named ChatSys.
The chat system will provide the following functionalities to the user:
• Get the list of recent messages in the chat
• Authenticate a user
• Register a user
• Post a message in the chat
• Get the list of unread messages for an authenticated user
A user is represented by the following information:
• id: unique identifier (i.e. number) representing the user
• username: textual representation of the user in the chat. Can only contain letters, numbers and the
underscore character (_)
• password: for authentication purpose
A message is represented by the following information:
• id: unique identifier (i.e. number) representing the message
• user: person who authored the message
• creation time: timestamp when the message was sent by the user
• message: textual content of the chat message
ChatSys 0.1 (exercise 1 & 2)
Our future chat system will need to be able to remember two types of information: the list of users and the list
of messages. In the first versions of the system, we will create objects that will be used to manipulate in Java
the data representing the users and the chat messages. The goal of the first two exercises will be to implement
two classes, one for each type of information we need to manage:
• User, who has:
o A user name (String)
o A full name (String)
o A password (String)
• ChatMessage
o A unique id (int)
o A user name of the author (String)
o A timestamp (java.sql.Timestamp)
o A message (String)
We will also create a Database interface that manages both users and chat messages. The database provides
different operations for:
• Obtaining the list of the n chat messages (with n being a parameter)
• Obtaining the list of unread chat messages for a given user
o After calling this method, the last read id of the user will be updated
• Adding a new user
• Adding a new chat message
• Authenticating a user
ChatSys 0.2 (exercise 3)
The next iteration of ChatSys will provide a new implementation of the Database interface so users and chat
messages can be saved in text files. For this we will separate each attribute with a tabulation. The timestamp is
saved as the number of milliseconds elapsed since 1970 using the getTime method of the class Timestamp.
More specifically, we use the following format:
• User: “\t\t \t\r\n”
• ChatMessage: “\t\t\t\r\n”
Because our chat messages are saved as single line of text, it means that the attributes of user and chat
messages (including the actual text message) cannot contain a line feed character (\n).
You will also implement unit tests to make sure that the behavior of your classes is correct.
ChatSys 1.0 (exercise 4)
The first real version of ChatSys will include an HTTP server that will serve queries to clients.
In this version of ChatSys, our server will need to be able to handle the following HTTP requests:
• GET /recent/:
o The server replies with a list of N messages, formatted using the same format used in ChatSys
0.2
o Less than N messages might be returned if N is larger than the number of messages
• GET /unread/?username=&password= :
o The server replies with the list of new chat messages since the last time the client sent this
query
o The server returns an error if the username or password are invalid.
• POST /user/:
o Used to register a user, with the information provided in the body of the request
• POST /message/?username=&password= :
o Used to send a chat message, with the message provided in the body of the request
ChatSys 2.0 (exercise 5)
In the second version of chatsys, we will use JSON to encode the body of our HTTP messages.
The following messages will be used:
• Chat messages (returned by the GET requests) are encoded as:
o {type:messages, messages:[
{username:, time:, message:},
{username:, time:, message:},
…]}
• User information entered when registering is encoded using the following JSON format:
o {username:, password: , fullname:}
ChatSys 3.0 (exercise 6)
So far, we have used simple text files for saving the information about users and chat messages. However, this
would be highly inefficient in a real case scenario. In this version, we will replace our dummy file database with
an SQLite database. (And with MySQL as a bonus)
Submission requirements
In addition to implementing features, your assignment must also meet certain design specifications that will
allow to test the functionality of your code more easily.
• You must submit a zip or tar archive on Moodle
• Your code must be compatible with Java 8
• Your archive must contain the following file structure:
o report.pdf: a pdf reporting:
▪ the list of features you managed to implement
▪ the features missing
▪ known bugs in the features implemented
o ChatSys.jar: a JAR file containing your compiled project
o src directory with the source and test files (inside the subdirectories “main” and “test”)
o pom.xml: Maven file for compiling the source and running tests
o Your archive shouldn’t include any other compiled binary files (e.g. .class files) besides the jar
or subfolders (e.g. .git, idea, target)
• Classes must be organized as packages like this:
o programming3.chatsys: all your classes must be in this package
o programming3.chatsys.data: classes relating to persistence of data (i.e. text files or database)
o programming3.chatsys.http: classes relating to HTTP server and client
• You must provide a class programming3.chatsys.http.RunServer with
o Three public static boolean fields “supportsMySQL”, “supportsTextDB” and “supportsSQLite”
that are true or false depending on which persistence system is supported.
o If you support in memory database, a public static method run with the following arguments:
▪ int port: port on which to run the HTTP server
o If you support file database, a public static method run with the following arguments:
▪ int port: port on which to run the HTTP server
▪ String messageDb: file location of the message database
▪ String userDb: file location of the user database
o If you support SQLite database, a public static method run with the following arguments:
▪ int port: port on which to run the HTTP server
▪ String dbFile: file location of the SQLite database
o If you support MySQL database, a public static method run with the following arguments:
▪ int port: port on which to run the HTTP server
▪ String dbHost: host on which MySQL server runs (e.g. “localhost”)
▪ int dbPort: port on which MySQL server runs
▪ String dbUser: MySQL database user
▪ String dbPassword: MySQL database password
▪ String dbName: MySQL database name
Evaluation
The assignment will be graded based on the following criteria:
• Which version of ChatSys you were able to implement (0.1, 0.2, 1.0, 2.0 or 3.0)
• Additional functionality implemented, such as,
o Secured connection (HTTPS)
o Different types of persistence (e.g. MySQL)
• Presence of unit tests
• Code properly documented with Javadoc
• Overall quality of the code

联系我们
  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp
热点标签

联系我们 - QQ: 99515681 微信:codinghelp
程序辅导网!