Team 84
Purdue CS 180
May 3rd, 2021
Contributors: Felix Liu, Jiaqi Chen, Paul Fang, Silvia Yang, Teresa Huang.
- Xiaoyu Liu Submitted code on Vocareum
- Teresa Huang Submitted Report on Brightspace
- Ziyang Fang Submitted Presentation on Brightspace
- Download the source code.
- Compile in an IDE of your choice.
1.RunMessageServerMaster.java
.
2.RunMessageClient.java
and allow the program to run in parallel so that multiple clients can run at the same time.
- Click on the "X" on the upper right corner to end the client.
- Click on the red square in IntelliJ (or an IDE of your choice) to terminate MessageServerMaster.
This class ensures that every user has their own thread to connect to the server.
This class will define what type of request is first and then sign the local variable“response” to it. Once the system finds it, it will go to find the corresponding response method. Next, the system will find the needed information and call the method from the message system to realize its objective. After collecting the information from the message system, it will send a response back to the client with the needed data.
This class will save all the messages from the Message System, check if there is a txt, read the data and save it into a hashmap, then refresh the file, wait for the next message from the Message System, and it should have a function that can let Message System use the information which saves in the hashmap easily.
This class contains many methods which are used to realize the specific implementation from the server and give a value back to the server.
This class contains the graphical user interface and functions for clients. There are four inner classes in
MessageClient. TheMessageClient
class includes the main method and invokes the Window class. Thewindow
class contains
the components in the graphical user interface, and the action listeners. TheClientWorker
fetches data from the server
and processes data when the users do action. ClientWorker sends requests to the server and receives corresponding
responses in order to implement the specified action. TheListDisplay
is used by the JList for real-time updates to
display conversations and messages.
The class stores the information of a conversation.
-
String name
The name of the conversation. -
UUID[] userUUIDs
An ArrayList containing the UUIDs of the members. -
UUID adminUUID
The UUID of the administrator. -
UUID[] messageUUIDs
An ArrayList of the UUIDs of the messages.
The class stores the information of a message.
-
UUID senderUUID
The UUID of the message sender. -
Date time
The time that the message is sent. -
String content
The content of the message. -
UUID conversationUUID
The UUID of the conversation that the message belongs.
The class stores the information of the user.
-
Credential credential
The credential of the user. -
Profile profile
The profile of the user.
The class stores the credential of the user.
-
String usrName
The username of the user. -
String passwd
The password of the user.
The class stores the profile of the user.
-
String name
The name of the user. -
int age
The age of the user
The class stores UUIDs.
UUID uuid
A unique and exclusive used to identify objects.
The class stores the event that is used for live-update
-
ArrayList<User> newUsers
newly created users. -
ArrayList<Conversation> newConversations
newly created conversations. -
HashMap<UUID, Arraylist<Message>> newMessages
newly created messages. -
ArrayList<User> users updatedUsers
previously existed users who changed their profile. -
ArrayList<Conversation> updatedConversations
previously existed conversations that are edited. -
ArrayList<Message> updatedMessages
previously existed messages that are edited. -
ArrayList<UUID> removedUsers
users that are removed. -
ArrayList<UUID> removedConversations
conversations that are removed. -
ArrayList<UUID> removedMessages
messages that are removed.
This exception could be called anyway, anything incorrect could be concluded as the request failed.
This exception will be thrown if the user tries to action that is outside their authority such as deleting a message that is not created by the user.
This exception will be thrown if the provided conversationUUID could not be found.
This exception will be thrown if there are special characters in the content.
This exception will be thrown if the name of the conversation is invalid.
This exception will be thrown if the provided password does not match the credential in the system.
This exception will be thrown if the provided username could not be found.
This exception will be thrown when the user tries to log in to the same account multiple times while the account is already logged in.
This exception will be thrown if the provided message could not be found.
This exception will be thrown when the user is not logged in and tries to do action.
This exception will be thrown when the user tries to register for an account, but the username entered has been already taken.
This exception will be thrown when the provided user does not exist.
This exception will be thrown if any failure occurs when parsing the request to a specific request.
The most basic request type. All requests extend this class.
UUID uuid
the universally unique identifier of the request.
The most basic response type. All responses extend this class.
-
boolean state
whether the request successes or fails. -
String msg
some message to be passed. -
UUID requestUUID
UUID of the corresponding request. -
equestFailedException exception
Ifstate==false
, this is the exception that caused the failure. Otherwise, it'snull
.
This request is for logging in. If you are not logged in, you have no permission to perform other operations except register.
Credential credential
login credentials, including a username and a password.
→ The Response if the request is successful
Response
This is the most basic Response with no special fields. The following are all subclasses of Response.
-
Boolean status
true means success, false means failure. -
String msg
message. Can benull
. -
UUID requestUUID
The UUID for the request.
!! Possible Exceptions for a failed request
-
UserNotFoundException
username does not exist -
InvalidPasswordException
password is incorrect -
InvalidUsernameException
The username is invalid -
LoggedInException
You are already logged in, you cannot log in again
Get the user's UUID by the username.
String Name
The user's username.
→ The Response if the request is successful
GetUserByNameResponse
The specific response that allows the users to get usernames.
UUID userUUID
The corresponding UUID of the user
!! Possible Exceptions for a failed request
UserNotFoundException
The provided username does not exist.
Change the userprofile.
Profile profile
new profile
→ The Response if the request is successful
Response
The basic response.
!! Possible Exceptions for a failed request
NotLoggedInException
The user tries to edit the profile but is logged out.
Registration.
-
Credential credential
-
Profile profile
→ The Response if the request is successful
RegisterResponse
UUID uuid
Your ownUUID.
!! Possible Exceptions for a failed request
-
UserExistsException
User already exists -
InvalidUsernameException
The username is invalid -
InvalidPasswordException
The password is invalid
Delete the current account.
Credential credential
→ The Response if the request is successful
response
The basic response.
!! Possible Exceptions for a failed request
-
AuthorizationException
credential error -
UserNotFoundException
user does not exist
Log out.
→ The Response if the request is successful
response
The basic response.
!! Possible Exceptions for a failed request
NotLoggedInException
You are not currently logged in
Sends a message.
-
UUID conversationUUID
-
Message message
Note: Onlymessage.content
is used. Other fields are neglected / auto-generated by the system.
→ The Response if the request is successful
-
PostMessageResponse
-
UUID messageUUID
-
Date date
The time when the message was actually sent successfully.
!! Possible Exceptions for a failed request
-
NotLoggedInException
Not logged in. -
ConversationNotFoundException
The group chat does not exist or does not belong to you. -
AuthorizationException
You do not have permission to change this group chat. -
IllegalContentException
The content of the message is illegal. It is too long or contains illegal characters.
Edit a message of your own.
-
UUID messageUUID
The message's UUID being edited -
String content
The new content
→ The Response if the request is successful
-
EditMessageResponse
-
Date dateEdited
The actual time of successful modification
!! Possible Exceptions for a failed request
-
NotLoggedInException
Not logged in. -
MessageNotFoundException
The message does not exist, or you should not see it. -
AuthorizationException
Does not have permission to change this information (probably because it belongs to someone else) -
IllegalContentException
The content of the message is illegal. It is too long or contains illegal characters.
Delete a message.
UUID messageUUID
The message's UUID being deleted
→ The Response if the request is successful
response
The basic response.
!! Possible Exceptions for a failed request
-
NotLoggedInException
Not logged in. -
MessageNotFoundException
The message does not exist, or you should not see it. -
AuthorizationException
Does not have permission to change this information (probably because it belongs to someone else)
Creates a new group chat.
-
String name
-
UUID[] userUUIDs
(If it is empty, create a single chat)
→ The Response if the request is successful
CreateConversationRsponse
The specific response to create a conversation.
UUID conversationUUID
The UUID of the conversation
!! Possible Exceptions for a failed request
-
NotLoggedInException
Not logged in -
InvalidConversationNameException
Conversation name not valid -
UserNotFoundException
The invited users do not exist
Delete the group chat.
UUID conversationUUID
The UUID of the conversation you would like to delete
→ The Response if the request is successful
response
The basic response.
!! Possible Exceptions for a failed request
-
NotLoggedInException
Not logged in -
ConversationNotFoundException
The conversation does not exist.
Rename the group chat.
-
UUID conversationUUID
The UUID of the conversation -
String name
The name of the conversation
→ The Response if the request is successful
response
The basic response.
!! Possible Exceptions for a failed request
-
NotLoggedInException
Not logged in -
InvalidConversationNameException
Conversation name not valid -
ConversationNotFoundException
The conversation does not exist.
Pulls the user into the group chat.
-
UUID userUUID
The invited user's UUID -
UUID conversationUUID
The conversation UUID
→ The Response if the request is successful
response
The basic response.
!! Possible Exceptions for a failed request
-
NotLoggedInException
Not logged in -
ConversationNotFoundException
The conversation does not exist. -
UserNotFoundException
The invited users do not exist -
AuthorizationException
You are not the administrator of the conversation
Remove the user from the group chat.
-
UUID userUUID
The user's UUID you want to remove -
UUID conversationUUID
The conversation UUID
→ The Response if the request is successful
response
The basic response.
!! Possible Exceptions for a failed request
-
NotLoggedInException
Not logged in -
ConversationNotFoundException
The conversation does not exist, or you do not belong to the group chat. -
UserNotFoundException
The user does not exist -
AuthorizationException
You are not the administrator of the conversation and cannot remove others. -
RequestFailedException
You cannot remove yourself.
Set the group chat administrator.
-
UUID userUUID
The user's UUID you want to remove -
UUID conversationUUID
The conversation UUID
→ The Response if the request is successful
response
The basic response.
!! Possible Exceptions for a failed request
-
NotLoggedInException
Not logged in -
ConversationNotFoundException
The conversation does not exist, or you do not belong to the group chat. -
UserNotFoundException
The user does not exist -
AuthorizationException
You don't have permission to set admin.
The user voluntarily leaves the group chat. If the user is currently an administrator, the system will automatically set an administrator randomly. If the user is the last user in the group chat, then the group chat will be deleted.
UUID conversationUUID
The conversation UUID
→ The Response if the request is successful
response
The basic response.
!! Possible Exceptions for a failed request
-
NotLoggedInException
Not logged in -
ConversationNotFoundException
The conversation does not exist, or you do not belong to the group chat.
List the UUIDs of all users
→ The Response if the request is successful
ListAllUsersResponse
List all the user's UUIDs.
UUID[] userUUIDs
The UUIDs of all the users
!! Possible Exceptions for a failed request
NotLoggedInException
Not logged in
List all group chat UUIDs, including only the group chats that the user has participated in
→ The Response if the request is successful
ListAllUserConversationsResponse
The specific response to the request.
UUID[] conversationUUIDs
The UUIDs of all the conversations
!! Possible Exceptions for a failed request
NotLoggedInException
Not logged in
List all the message UUIDs of a group chat.
UUID conversationUUID
The UUID of the conversation
→ The Response if the request is successful
ListAllMessagesResponse
The specific response to list all messages.
Messages[] userMessages
An array of messages sent by all users in this conversation
!! Possible Exceptions for a failed request
-
NotLoggedInException
Not logged in -
ConversationNotFoundException
The conversation does not exist, or you do not belong to the group chat.
Pull a user by the user's UUID, but cannot see the password
UUID userUUID
The UUID of the user
→ The Response if the request is successful
GetUserResponse
The specific response to get the user.
User user
The corresponding user.
!! Possible Exceptions for a failed request
-
NotLoggedInException
Not logged in -
UserNotFoundException
The user does not exist
Pull a group chat by the conversation's UUID
UUID conversationUUID
The UUID of the conversation
→ The Response if the request is successful
GetConversationResponse
The specific response to get the conversation
Conversation conversation
The corresponding conversation
!! Possible Exceptions for a failed request
-
NotLoggedInException
Not logged in -
ConversationNotFoundException
The conversation does not exist, or you do not belong to the group chat.
Pull a message by the message's UUID
UUID messageUUID
The UUID of the message
→ The Response if the request is successful
-
GetMessageResponse
The specific response to get the message
-
Message message
The corresponding message
!! Possible Exceptions for a failed request
-
NotLoggedInException
Not logged in
-
MessageNotFoundException
The message does not exist
Pull the chat history of a group chat.
UUID conversationUUID
The UUID of the conversation
→ The Response if the request is successful
GetMessageHistoryResponse
The specific response to get the message history
Message[] messages
All the messages in the corresponding conversation
!! Possible Exceptions for a failed request
-
NotLoggedInException
Not logged in -
ConversationNotFoundException
The conversation does not exist, or you do not belong to the group chat.
Update new users, group chats,and messages. Used to implement the live update. The client should request a new event every time. Incidents include:
-Add
-Rename/Edit
-Delete
→ The Response if the request is successful
-
GetEventFeedResponse
The specific response containing all the updated information. -
User[] newUsers
New users. -
Conversation[] newConversations
New group chat. -
ashMap<UUID, Message[] newMessages
All new messages for each group chat. -
User[] updatedUsers users
Users who existed before, but were edited. -
Conversation[] updatedConversations
A group chat that existed before but was edited. -
Message[] updatedMessages
Messages that existed before, but were edited. -
UUID[] removedUsers
The users who are removed from a conversation -
UUID[] removedConversations
The conversations that are removed -
UUID[] removedMessages
The messages that are removed
!! Possible Exceptions for a failed request
NotLoggedInException
Not logged in
All the automatic tests are conducted with JUnit 4. And for each method in Database and MessageSystem, one successful case and one exception expected case are provided.
The Database test is included in DatabaseTest.java, which contains a write method test. The write method contains all the methods that been used in the Database. So successful running of the write method will automatically mean that other methods are running without problems.
Note: this test case can be found atDatabaseTest.java
in the root folder.
The MessageSystem test is more complicated than the database test. It is in the MessageSystemTest.java. Also, the adding, remove and edit method of each field had been tested with different Test methods. For instance, the test method for getUser included the addUser and deleteUser method so successful running of the getUserTest will approve that addUser and deleteUser could run in that situation. Another addUserExceptionExpected test method, which included throwing an expected exception when certain invalid input is provided, is also written in the test class. Every method in the MessageSystem contains an exception expected test case and a successfully running test case, to make sure the program didn't crash even invalid input is provided.
Note: this test case can be found atMessageSystemTest.java
in the root folder.
User’s action | Expected response | Test response |
---|---|---|
Start Client and Server. | Show the sign-in page. | Successfully shows. |
Click the register button. | Show the register page. | Successfully shows. |
Sign in with a non-exist username. | Proper exception prompt shows. | Exception prompt shows as expected. |
While registering, enter valid input for name, age, username, and password. | Create an account successfully. | Successfully creates. |
While registering, enter valid input for name, username, and password, but entering an invalid value for age. (Entered -1) | Proper exception prompt shows. | Exception prompt shows as expected. |
While registering, enter valid input for name, username, and password, but entering an invalid value for age. (Entered “a”) | Proper exception prompt shows. | Exception prompt shows as expected. |
While registering, enter valid input for name, age, and password, but entering a username that already exists. | Proper exception prompt shows. | Exception prompt shows as expected. |
After registering, sign in with the proper username and password. | Show the chatting room. | Successfully shows. |
After registering, sign in with the proper username but enter the wrong password. | Proper exception prompt shows. | Exception prompt shows as expected. |
The main menu will be visible after signing in, then a new chat could be set up with the proper group name and invited users. Enter a valid group name and invite nobody. | Show the group chatting room. | Successfully shows. |
Enter a valid group name and invite another user to use a username. | Show the group chatting room with that person. | Successfully shows. |
Invite a person that does not exist. | Proper exception prompt shows. | Exception prompt shows as expected. |
Sending a message in group chat. | Show the conversation with the current date and time. | Successfully shows. |
Click setting and change profile, enter valid name and age. | Shows edited profile in the My profile section. | Successfully shows. |
Click setting and change profile, enter the valid name but invalid age. | Proper exception prompt shows. | Exception prompt shows as expected. |
Delete current account, and back to the log-in section, trying to log-in with that account. | Proper exception prompt shows. | Exception prompt shows as expected. |
A creates a conversation and adds B to the conversation. | The conversation appears in B's conversation list. | Successfully shows. |
One person sends a message. | All the members in the conversation see the message within seconds. | Successfully shows. |
A sends a message and B tries to edit the message. | Proper exception prompt shows. | Exception prompt shows as expected. |
A sends a message and B tries to delete the message. | Proper exception prompt shows. | Exception prompt shows as expected. |
Edit the message then export. | The file shows edited messages. | Successfully shows. |
Delete the message then export. | The file does not show the deleted message. | The deleted message was not shown. |
Create a new conversation, send a message, exit the conversation, then re-enter the conversation. | The sent message is retained. | Successfully shows. |
Create some conversations, log out, then log back in. | The conversation history is retained. | Successfully shows. |
Log out then log back in, enter the conversation. | The message history is retained. | Successfully shows. |
Delete a conversation from A's list. | The deletion does not impact B's conversation list. | Successfully shows. |
Contributors: Felix Liu, Jiaqi Chen, Paul Fang, Silvia Yang, Teresa Huang.