Server Interface - CMPUT301F12T01/classproject GitHub Wiki
Server Interface
Hindle has given us a server to populate with requests. His server's README hints at a way to use it. However, it's not suitible for our uses. Every object accessible is supposed to be a task. This means that tasks must contain their own responses. Since the server is dumb (it's not going to do anything else other than storing stuff), this means that clients are responsible for updating task with the requests. This could lead to race conditions. If two (or more) clients fetch a task at the same time and add a request, the report that was updated last would be kept, whilst the other would be destroyed.
The new protocol
Instead, we'll make "summary"
consist of one of the following strings:
- "task"
- "report"
Then the "contents"
will be the GSON'd Task
or Request
instance,
verbatim. The description can be left blank.
Getting tasks and reports
Simply list all objects stored and filter through the object desired.
Hypothetical Example
Once all entries have been listed and the particular Report has been identified, one can access it thusly:
GET http://crowdsourcer.softwareprocess.es/F12/CMPUT301F12T01/?action=get&id=9b42669cb3ba373ff7877ab826984bde4859ccf0 HTTP/1.1
Host: crowdsourcer.softwareprocess.es
No HTTP request headers other than these are really required -- most likely any HTTP library we use will do all of this automatically for us. The response should look like this:
HTTP/1.1 200 OK
Date: Fri, 23 Nov 2012 01:00:37 GMT
Server: Apache
Keep-Alive: timeout=2, max=100
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: application/json
{
"summary": "request",
"description": "",
"content": {
"taskId": "550e8400-e29b-41d4-a716-446655440000",
"sharing": "TASK_CREATOR",
"timestamp": 1353632831,
"responses": [
{
"mediaType": "text",
"data": "This is the text response"
}
]
},
"id": "9b42669cb3ba373ff7877ab826984bde4859ccf0"
}
Note that the JSON here has been modified to be human readable, thus will not represent what will actually be sent by the server.