com.bjorsond.timeline.service.rest.impl
Class TimelineResource

java.lang.Object
  extended by com.bjorsond.timeline.service.rest.impl.TimelineResource

public class TimelineResource
extends java.lang.Object

REST services for bjorsond Timeline Android Application.

Author:
andekr, andrstor

Constructor Summary
TimelineResource()
           
 
Method Summary
 com.bjorsond.timeline.service.model.Group addUserToGroup(java.lang.String groupid, java.lang.String username)
          PUT
Adds a user to a group
URL: /group/{groupid}/user/{username}/
TODO: Register user if not registered
 com.bjorsond.timeline.service.model.Experiences GetAllExperiences()
          GET
Gets all experiences in server
URL: /experiences/
Gets all the experiences stored.
 java.lang.String getAverageMoodByID(java.lang.String experienceid)
          GET
Gets the average mood of an experience by ID
URL: /mood/id/{experienceid}/
Produces a string with the average mood as integer.
 java.lang.String getAverageMoodByName(java.lang.String title)
          GET
Gets the average mood of an experience by title
Note: Not as accurate as ID, and is case sensitive
URL: /mood/title/{title}/
 java.lang.String getEvents()
          GET
Get events as String (Mainly for testing purposes)
URL: /events/
Produces toString of all events as String
 com.bjorsond.timeline.service.model.Experiences GetExperiences(java.lang.String username)
          GET
Gets all experiences of a user
URL: /experiences/{username}
Takes username of the user to get experiences Produces the all experiences shared with the user as JSON or XML
 com.bjorsond.timeline.service.model.Group getGroup(java.lang.String groupid)
          GET
Gets the group with the id sent as parameter
URL: /group/{groupid}
Produces JSON or XML with group information.
 com.bjorsond.timeline.service.model.Groups getGroups()
          GET
Gets all the groups
URL: /groups/
Produces JSON or XML with list of all groups
 com.bjorsond.timeline.service.model.Groups getGroupsOfUser(java.lang.String username)
          GET
Gets the groups the user with the username given as parameter
URL: /groups/{username}
Produces JSON or XML with list of groups the user is member of.
 com.bjorsond.timeline.service.model.User getUser(java.lang.String username)
          GET
Gets the user with the username sent as parameter
URL: /user/{username}
Produces JSON or XML with user information.
 com.bjorsond.timeline.service.model.Users getUsers()
          GET
Gets all the users
URL: /users/ Produces JSON or XML with all users.
 java.lang.String isUserInGroup(java.lang.String groupid, java.lang.String username)
          GET
Gets if user is member in a group
URL: /group/{groupid}/{username}/
 com.bjorsond.timeline.service.model.Event putAverageMoodByID(java.lang.String id, java.lang.String username, int mood)
          PUT
Inserts a mood to an experience only by parameters, and no content needed
Uses experience id to identify experience
URL: /mood/id/{id}/{username}/{mood}/
 com.bjorsond.timeline.service.model.Event putAverageMoodByName(java.lang.String title, java.lang.String username, int mood)
          PUT
Inserts a mood to an experience only by parameters, and no content needed
Uses experience title to identify experience
URL: /mood/title/{title}/{username}/{mood}/
 com.bjorsond.timeline.service.model.Event putEvent(com.bjorsond.timeline.service.model.Event event)
          PUT
Store or update one Event
URL: /event/
Consumes a complete event as JSON or XML and stores/updates in Google App Engine.
 com.bjorsond.timeline.service.model.Experience putExperience(com.bjorsond.timeline.service.model.Experience experience)
          PUT
Store or update one Experience
URL: /experience/
Consumes a complete experience as JSON or XML and stores/updates in Google App Engine.
 com.bjorsond.timeline.service.model.Experiences putExperiences(com.bjorsond.timeline.service.model.Experiences experiences)
          PUT
Stores/updates all experiences in server URL: /experiences/
Stores all the experiences sent in.
 com.bjorsond.timeline.service.model.Group putGroup(com.bjorsond.timeline.service.model.Group group)
          PUT
Registers a group
URL: /group/
Consumes a JSON or XML with the group information.
 com.bjorsond.timeline.service.model.User putUser(com.bjorsond.timeline.service.model.User user)
          PUT
Registers a user
URL: /user/
Consumes a JSON or XML with the user information.
 java.lang.String removeGroup(java.lang.String groupid)
          DELETE
Deletes a group
URL: /group/{groupid}
Takes a group id as parameter.
 java.lang.String removeUserFromGroup(java.lang.String groupid, java.lang.String username)
          DELETE
Removes a user form a group
URL: /group/{groupid}/user/{username}/
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TimelineResource

public TimelineResource()
Method Detail

putEvent

public com.bjorsond.timeline.service.model.Event putEvent(com.bjorsond.timeline.service.model.Event event)
PUT
Store or update one Event
URL: /event/
Consumes a complete event as JSON or XML and stores/updates in Google App Engine. Requires that the "father-experience" is already registered. Produces the registered event as JSON or XML
Example of JSON:
{ "className":"Event", "creator":"anderskri@gmail.com", "eventItems":[ { "className":"SimpleNote", "creator":"anderskri@gmail.com", "id":"b44f63a4-a17e-468d-bc4f-149430a8aa20", "noteText":"This is the content of an example note.", "noteTitle":"This is an example of a note." } ], "experienceid":"13b9b0d2-c8cd-4436-9be3-bddef9ebd5a2", "id":"d270281e-5579-429d-8570-5de901d52a0f", "latitude":63.41652922, "longitude":10.40268466, "datetimemillis":1301904788593, "shared":true, "mood":0, "average":false }


getEvents

public java.lang.String getEvents()
GET
Get events as String (Mainly for testing purposes)
URL: /events/
Produces toString of all events as String


putExperience

public com.bjorsond.timeline.service.model.Experience putExperience(com.bjorsond.timeline.service.model.Experience experience)
PUT
Store or update one Experience
URL: /experience/
Consumes a complete experience as JSON or XML and stores/updates in Google App Engine. Also stores all children Produces the registered experience as JSON or XML
Example of JSON:
{ "creator":"anderskri@gmail.com", "events":[ { "className":"MoodEvent", "creator":"anderskri@gmail.com", "datetimemillis":"1301556003782", "experienceid":"4cfb71dc-30f6-47e5-829a-a21e08e568b9", "id":"43799bf7-53fa-4acc-8045-0d8a0f29ea8b", "latitude":"63.41652448", "longitude":"10.4027416", "mood":"1", "shared":"true" }, { "className":"MoodEvent", "creator":"andrstor87@gmail.com", "datetimemillis":"1301556030401", "experienceid":"4cfb71dc-30f6-47e5-829a-a21e08e568b9", "id":"9689012d-520b-4bf1-b19f-06c1072f9f8b", "latitude":"63.4165383", "longitude":"10.40269734", "mood":"-2", "shared":"true" }, { "className":"Event", "creator":"andrstor87@gmail.com", "datetimemillis":"1301556205024", "emotionList":[ { "emotionType":"LIKE", "emotionid":"22d08b27-0266-4561-8a16-96b86b099aa9" } ], "eventItems":[ { "className":"SimplePicture", "creator":"andrstor87@gmail.com", "filename":"-1779601815.jpg", "id":"91e0b5ba-a384-40b4-88ac-edecf8c28e91" }, { "className":"SimpleNote", "creator":"andrstor87@gmail.com", "id":"9b3dd9a7-ac7e-44e2-a62d-e6191c2a3aff", "noteText":"The most productive in the world.", "noteTitle":"My workplace" } ], "experienceid":"4cfb71dc-30f6-47e5-829a-a21e08e568b9", "id":"b05348b2-d827-4192-b153-c283ac251586", "latitude":"63.41654401", "longitude":"10.4027174", "mood":"0", "shared":"true" }, { "className":"Event", "creator":"anderskri@gmail.com", "datetimemillis":"1301564716999", "eventItems":[ { "className":"SimpleNote", "creator":"test@timelineapp.no", "id":"5c58f9ae-3f6a-4a79-b09e-a3ad9b58d26b", "noteText":"Finally bjorsond is on Timeline!", "noteTitle":"bjorsond on Timeline" } ], "experienceid":"4cfb71dc-30f6-47e5-829a-a21e08e568b9", "id":"adf77be1-fc8d-4a5b-b465-16c4d09a68f6", "latitude":"63.41654447", "longitude":"10.402711", "mood":"0", "shared":"true" }, { "className":"Event", "creator":"test@timelineapp.no", "datetimemillis":"1301567596334", "eventItems":[ { "className":"SimplePicture", "creator":"test@timelineapp.no", "filename":"1689419062.mp4", "id":"5fc3463d-31ef-42a4-8b5e-3ae5a9a58f57" } ], "experienceid":"4cfb71dc-30f6-47e5-829a-a21e08e568b9", "id":"76d46599-eda8-487d-a829-b5517bc6ab43", "latitude":"0.0", "longitude":"0.0", "mood":"0", "shared":"true" } ], "id":"4cfb71dc-30f6-47e5-829a-a21e08e568b9", "shared":"true", "sharingGroup":"4bbd7541-5c49-45e5-87c9-d75ac1e3a36a", "title":"bjorsond" }


GetExperiences

public com.bjorsond.timeline.service.model.Experiences GetExperiences(java.lang.String username)
GET
Gets all experiences of a user
URL: /experiences/{username}
Takes username of the user to get experiences Produces the all experiences shared with the user as JSON or XML


GetAllExperiences

public com.bjorsond.timeline.service.model.Experiences GetAllExperiences()
GET
Gets all experiences in server
URL: /experiences/
Gets all the experiences stored. Mainly for testing and administrative purposes. Produces the all experiences as JSON or XML


putExperiences

public com.bjorsond.timeline.service.model.Experiences putExperiences(com.bjorsond.timeline.service.model.Experiences experiences)
PUT
Stores/updates all experiences in server URL: /experiences/
Stores all the experiences sent in. Mainly for testing and administrative purposes. Produces the all experiences as JSON or XML


putUser

public com.bjorsond.timeline.service.model.User putUser(com.bjorsond.timeline.service.model.User user)
PUT
Registers a user
URL: /user/
Consumes a JSON or XML with the user information. Currently only a username. Produces the JSON or XML of the registered user.
Example JSON:
{"username":"yourusername@mail.com"}


getUser

public com.bjorsond.timeline.service.model.User getUser(java.lang.String username)
GET
Gets the user with the username sent as parameter
URL: /user/{username}
Produces JSON or XML with user information.

Parameters:
username - of user to get
Returns:
User the user with the username sent as parameter

getUsers

public com.bjorsond.timeline.service.model.Users getUsers()
GET
Gets all the users
URL: /users/ Produces JSON or XML with all users.
Example of returning JSON:
{"users":[{"username":"user1@gmail.com"},{"username":"user2@gmail.com"},{"username":"test@timelineapp.no"}]}

Returns:
Users the users

getGroup

public com.bjorsond.timeline.service.model.Group getGroup(java.lang.String groupid)
GET
Gets the group with the id sent as parameter
URL: /group/{groupid}
Produces JSON or XML with group information.

Parameters:
groupid - of group to get
Returns:
Group the group with the id sent as parameter

putGroup

public com.bjorsond.timeline.service.model.Group putGroup(com.bjorsond.timeline.service.model.Group group)
PUT
Registers a group
URL: /group/
Consumes a JSON or XML with the group information. The JSON should contain at least one member(the creator). Produces the JSON or XML of the registered group.


removeGroup

public java.lang.String removeGroup(java.lang.String groupid)
DELETE
Deletes a group
URL: /group/{groupid}
Takes a group id as parameter. Deletes the group with the given id. Returns a boolean as String of the status of the delete. Not implemented yet.

Parameters:
groupid - group id
Returns:
String true if successful. Not implemented

getGroupsOfUser

public com.bjorsond.timeline.service.model.Groups getGroupsOfUser(java.lang.String username)
GET
Gets the groups the user with the username given as parameter
URL: /groups/{username}
Produces JSON or XML with list of groups the user is member of.

Parameters:
username - of user to get groups from.
Returns:
Groups the user is member of.

getGroups

public com.bjorsond.timeline.service.model.Groups getGroups()
GET
Gets all the groups
URL: /groups/
Produces JSON or XML with list of all groups

Returns:
Groups the user is member of.

isUserInGroup

public java.lang.String isUserInGroup(java.lang.String groupid,
                                      java.lang.String username)
GET
Gets if user is member in a group
URL: /group/{groupid}/{username}/

Parameters:
groupid -
username -
Returns:
String true if user is in group

addUserToGroup

public com.bjorsond.timeline.service.model.Group addUserToGroup(java.lang.String groupid,
                                                              java.lang.String username)
PUT
Adds a user to a group
URL: /group/{groupid}/user/{username}/
TODO: Register user if not registered

Parameters:
groupid - Id of group to add user to
username - username of already registered user
Returns:
JSON or XML with the group

removeUserFromGroup

public java.lang.String removeUserFromGroup(java.lang.String groupid,
                                            java.lang.String username)
DELETE
Removes a user form a group
URL: /group/{groupid}/user/{username}/

Parameters:
groupid - id of group to remove user from
username - of user to remove
Returns:
String true if user is removed from group

getAverageMoodByID

public java.lang.String getAverageMoodByID(java.lang.String experienceid)
GET
Gets the average mood of an experience by ID
URL: /mood/id/{experienceid}/
Produces a string with the average mood as integer.

Parameters:
experienceid - Experience id of the experience to get average mood from.

getAverageMoodByName

public java.lang.String getAverageMoodByName(java.lang.String title)
GET
Gets the average mood of an experience by title
Note: Not as accurate as ID, and is case sensitive
URL: /mood/title/{title}/

Parameters:
title - title of the experience to get average mood from.

putAverageMoodByName

public com.bjorsond.timeline.service.model.Event putAverageMoodByName(java.lang.String title,
                                                                    java.lang.String username,
                                                                    int mood)
PUT
Inserts a mood to an experience only by parameters, and no content needed
Uses experience title to identify experience
URL: /mood/title/{title}/{username}/{mood}/

Parameters:
title - of experience to insert mood
username - of user to set as creator
mood - to insert. int from -2 to 2. Very sad to very happy.
Returns:
the created Event

putAverageMoodByID

public com.bjorsond.timeline.service.model.Event putAverageMoodByID(java.lang.String id,
                                                                  java.lang.String username,
                                                                  int mood)
PUT
Inserts a mood to an experience only by parameters, and no content needed
Uses experience id to identify experience
URL: /mood/id/{id}/{username}/{mood}/

Parameters:
id - of experience to insert mood
username - of user to set as creator
mood - to insert. int from -2 to 2. Very sad to very happy.
Returns:
the created Event