-
Notifications
You must be signed in to change notification settings - Fork 0
/
readme.txt
97 lines (76 loc) · 2.92 KB
/
readme.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
Steps to run:
Required Softwares:
* java-8-jdk/jre
* maven
* tomcat server
* mysql server
1) Assuming you have a MySQL user acccount server setup, Edit the src/main/resources/db.properties with the right details of the MySQL account.
2) Login to the MySQL account and execute schema.sql located in the project's root directory. This file has the schema of the database.
3) To package, run: 'mvn clean package'. This generates a war file in the target folder. The war file name is feedgenerator.war.
4) Copy this file to the webapps directory in present in the Tomcat installation folder. Start the server.
5) Check catalina.out for any errors.
6) To check if the app is up, run: curl http://localhost:8080/feedgenerator/ping. This response should be "All is Well!" (Replace localhost with the host name of the machine where the application is deployed)
REST APIs:
There are three main resources in this webapp: Users, Topics, UserRoles. The REST APIs for all the resources follow the same convention. Below are the only things that you need to remember when using the APIs. (The structure of the request and reponse for each endpoint is different, obviously).
Operation: INSERT/CREATE
HTTP verb: POST
Resource endpoints: <BASEURI>/users,<BASEURI>/userroles, <BASEURI>/topics
Operation: UPDATE
HTTP verb: PUT
Resource endpoints: <BASEURI>/users,<BASEURI>/userroles, <BASEURI>/topics
Operation: DELETE
HTTP verb: DELETE
Resource endpoints: <BASEURI>/users/{id}, <BASEURI>/userroles/{id}, <BASEURI>/topics/{id}
Operation: GET
HTTP verb: GET
Resource endpoints: <BASEURI>/users/{id}, <BASEURI>/userroles/{id}, <BASEURI>/topics/{id}
Operation: GETALL
HTTP verb: GET
Resource endpoints: <BASEURI>/users, <BASEURI>/userroles, <BASEURI>/topics
JSON Structures:
#########
Create a User:
{
"username": "test3",
"email": "email",
"firstName": "fn",
"lastName": "ln",
"roles": [
"admin",
"subscriber"
],
"topics": {
"topic1": 0.5,
"topic2": 0.5
}
}
Update a User:
{
"id": 1,
"username": "test3",
"email": "email",
"firstName": "fn",
"lastName": "ln",
"roles": [
"admin",
"subscriber"
],
"topics": {
"topic1": 0.5,
"topic2": 0.5
}
}
GOTCHAs for update: the existing roles during update don't get updated. New Roles will be added if they are not already there. Topics: the existing topics will be cleared and the new topics would be added with the latest weights(This is very inefficient. Having explicit fields which indicates the topics added/removed/modified would be a better appraoch. However, the JSON structure would be slightly complex)
Get a User: The response is similar the Create request. But it will have an id field.
#########
Create a UserRole:
{
"name": "newrole"
}
Get a UserRole: The response is similar the Create request. But it will have an id field.
#########
Create a Topic:
{
"name": "topic1"
}
Get a Topic: The response is similar the Create request. But it will have an id field.