- Oracle Java 8 installed and
JAVA_HOME
set orjava
executable inPATH
./gradlew.bat run
in root of project directory
./gradlew run
in root of project directory
Server will start running at http://localhost:8080
with default configuration.
API endpoints are at http://localhost:8080/api/v1/*
Configuration is perform with a Java properties file specified within the run
task in build.gradle
. Default configuration is at config/config.ini
Endpoints, requests, responses are documented using Swagger here (default server port is 8080)
- Embedded Jetty for server and servlets
- JSON-Simple for (de)serialisation of JSON request and responses
- MongoDB for persistence
- Gradle for dependency management and scripting
- Separation of concerns between Actions and request/reponse mechanisms
- JSON parsing and response properties setting encapsulated in FriendManagementServlet
- Action routing and extraction of action arguments in ActionHandler
- Action logic encapsulated in XAction classes e.g. (AddFriendAction)
- Ablility to switch out persistence implementations for easy testing
- Instantiation of persistence handler through reflection
- HashMapUserPersistence for testing
- Easy basic configuration of route to Action objects
- Added PropertiesHelper to parse config for routes and Actions enum
- Create friend connection
- If any email address doesn't exist as a user
- return
{"notUser" : [email1, email2]}
- return
- Retrieve friend list
- If requested email address doesn't exist as a user
- return
{"notUser" : [email]}
- return
- Get common friends
- If either email adress doesn't exist as a user
- return
{"notUser" : [email1, email2]}
- return
- If the two email addresses are the same
- return
{"sameUser": true, "friends":[...]}
- return
- Subscribe to updates
- If target doesnt exist as a user
- return
{"notUser" : [target_email]}
- return
- If requestor doesn't exist as a user
- return
{"notUser" : [requestor_email]}
- return
- Block updates
- If target doesnt exist as a user
- return
{"notUser" : [target_email]}
- return
- If requestor doesn't exist as a user
- return
{"notUser" : [requestor_email]}
- return
- If requestor is already friends with target but blocks target
- return
{"isFriend": true}
- return
- Retrieve recipients
- If @ mentioned email is not a user
- return
{"notUser" : [email1, email2, ...]}
- return
- If recipient is already friends with sender but blocks sender
- return
{"recipient": recipientEmail, "isFriend": true}
- return
- If recipient is already subscribed to sender but blocks sender
- return
{"recipient": recipientEmail, "isSubscribed": true}
- return
Current implementation does not check whether user exists unless it checks the friend list, blocked list or list of subscribers.