Newer
Older
CosmosServer / src / main / java / com / example / cosmos_serversb / resources / GroupsRest.java
  1. package com.example.cosmos_serversb.resources;
  2.  
  3. import com.fasterxml.jackson.core.JsonProcessingException;
  4. import com.fasterxml.jackson.databind.ObjectMapper;
  5. import org.springframework.stereotype.Component;
  6.  
  7. import javax.ws.rs.*;
  8.  
  9. @Component
  10.  
  11. public class GroupsRest {
  12. @Path("/groups")
  13. @GET
  14. public String getGroupsListByUid(@QueryParam("uId") String uId, @QueryParam("token") String token) throws JsonProcessingException{
  15. ObjectMapper mapper = new ObjectMapper();
  16. String json = mapper.writeValueAsString(null);
  17. return json;
  18. }
  19.  
  20. @Path("/groups")
  21. @POST
  22. public String createGroup(@FormParam("name") String name, @FormParam("uId") String uId, @FormParam("token") String token) throws JsonProcessingException{
  23. ObjectMapper mapper = new ObjectMapper();
  24. String json = mapper.writeValueAsString(null);
  25. return json;
  26. }
  27.  
  28. @Path("/{gId}")
  29. @GET
  30. public String getGroupInfoByGid(@PathParam("gId") String gId, @QueryParam("token") String token) throws JsonProcessingException{
  31. ObjectMapper mapper = new ObjectMapper();
  32. String json = mapper.writeValueAsString(null);
  33. return json;
  34. }
  35.  
  36. @Path("/{gId}")
  37. @DELETE
  38. public String deleteGroup(@PathParam("gId") String gId, @FormParam("token") String token) throws JsonProcessingException{
  39. ObjectMapper mapper = new ObjectMapper();
  40. String json = mapper.writeValueAsString(null);
  41. return json;
  42. }
  43.  
  44. @Path("/{gId}/members")
  45. @GET
  46. public String getGroupMembersListByGid(@PathParam("gId") String gId, @QueryParam("token") String token) throws JsonProcessingException{
  47. ObjectMapper mapper = new ObjectMapper();
  48. String json = mapper.writeValueAsString(null);
  49. return json;
  50. }
  51.  
  52. @Path("/{gId}/members")
  53. @POST
  54. public String addMember(@PathParam("gId") String gId, @FormParam("uId") String uId, @FormParam("token") String token) throws JsonProcessingException{
  55. ObjectMapper mapper = new ObjectMapper();
  56. String json = mapper.writeValueAsString(null);
  57. return json;
  58. }
  59.  
  60. @Path("/{gId}/members")
  61. @DELETE
  62. public String deleteMember(@PathParam("gId") String gId, @FormParam("uId") String uId, @FormParam("token") String token) throws JsonProcessingException{
  63. ObjectMapper mapper = new ObjectMapper();
  64. String json = mapper.writeValueAsString(null);
  65. return json;
  66. }
  67.  
  68. @Path("/{gId}/requests")
  69. @GET
  70. public String getRequestsListByGid(@PathParam("gId") String gId, @QueryParam("token") String token) throws JsonProcessingException{
  71. ObjectMapper mapper = new ObjectMapper();
  72. String json = mapper.writeValueAsString(null);
  73. return json;
  74. }
  75.  
  76. @Path("/{gId}/requests")
  77. @POST
  78. public String addRequests(@PathParam("gId") String gId, @FormParam("uId") String uId, @FormParam("product") String product, @FormParam("deadline") String deadline, @FormParam("location") int location, @FormParam("token") String token) throws JsonProcessingException{
  79. ObjectMapper mapper = new ObjectMapper();
  80. String json = mapper.writeValueAsString(null);
  81. return json;
  82. }
  83.  
  84. @Path("{gId}/requests/{rId}")
  85. @GET
  86. public String getRequestsDetailByGidAndRid(@PathParam("gId") String gId, @PathParam("rId") String rId, @QueryParam("token") String token) throws JsonProcessingException{
  87. ObjectMapper mapper = new ObjectMapper();
  88. String json = mapper.writeValueAsString(null);
  89. return json;
  90. }
  91.  
  92. @Path("{gId}/requests/{rId}")
  93. @PUT
  94. public String updateRequest(@PathParam("gId") String gId, @PathParam("rId") String rId, @FormParam("uId") String uId, @FormParam("product") String product, @FormParam("deadline") String deadline, @FormParam("location") int location, @FormParam("done") boolean done, @FormParam("token") String token) throws JsonProcessingException{
  95. ObjectMapper mapper = new ObjectMapper();
  96. String json = mapper.writeValueAsString(null);
  97. return json;
  98. }
  99.  
  100. @Path("{gId}/requests/{rId}")
  101. @DELETE
  102. public String deleteRequest(@PathParam("gId") String gId, @PathParam("rId") String rId, @FormParam("token") String token) throws JsonProcessingException{
  103. ObjectMapper mapper = new ObjectMapper();
  104. String json = mapper.writeValueAsString(null);
  105. return json;
  106. }
  107. }