77 return users.toString();
78 }
79
80 @RequestMapping(value = "user/getAllStudents", method = RequestMethod.GET) 81 @ResponseBody 82 public String getAllStudents(){ 83 List<Student> students = userHibControl.getAllStudents(); 84 GsonBuilder gson = new GsonBuilder(); 85 gson.registerTypeAdapter(Student.class, new StudentSerializer()); 86 Gson parser = gson.create(); 87 return parser.toJson(students); 88 } 89
90 @RequestMapping(value = "user/getAllModerators", method = RequestMethod.GET)
91 @ResponseBody
87 return parser.toJson(students);
88 }
89
90 @RequestMapping(value = "user/getAllModerators", method = RequestMethod.GET) 91 @ResponseBody 92 public String getAllModerators(){ 93 List<Moderator> moderators = userHibControl.getAllModerators(); 94 GsonBuilder gson = new GsonBuilder(); 95 gson.registerTypeAdapter(Moderator.class, new ModeratorSerializer()); 96 Gson parser = gson.create(); 97 return parser.toJson(moderators); 98 } 99
100 @RequestMapping(value = "user/deleteUser", method = RequestMethod.DELETE)
101 @ResponseBody
97 return parser.toJson(moderators);
98 }
99
100 @RequestMapping(value = "user/deleteUser", method = RequestMethod.DELETE)101 @ResponseBody102 public String deleteUser(@RequestParam("id") int id){103 userHibControl.removeUser(id);104 return STATUS_SUCCESS;105 }106
107 @RequestMapping(value = "user/createMod", method = RequestMethod.POST)
108 @ResponseStatus(value = HttpStatus.OK)
104 return STATUS_SUCCESS;
105 }
106
107 @RequestMapping(value = "user/createMod", method = RequestMethod.POST)108 @ResponseStatus(value = HttpStatus.OK)109 @ResponseBody110 public String createMod(@RequestBody String request){111 Gson gson = new Gson();112 Properties properties = gson.fromJson(request, Properties.class);113 Moderator mod = new Moderator(properties.getProperty(PROPERTY_LOGIN), properties.getProperty(PROPERTY_PASSWORD), properties.getProperty(PROPERTY_NAME), properties.getProperty(PROPERTY_SURNAME), properties.getProperty(PROPERTY_EMAIL));114 userHibControl.createUser(mod);115 return STATUS_SUCCESS;116 }117
118 @RequestMapping(value = "user/updateStudent", method = RequestMethod.PUT)
119 @ResponseBody
115 return STATUS_SUCCESS;
116 }
117
118 @RequestMapping(value = "user/updateStudent", method = RequestMethod.PUT)119 @ResponseBody120 public String updateStudent(@RequestBody String request){121 Gson gson = new Gson();122 Properties properties = gson.fromJson(request, Properties.class);123 Student student = new Student(properties.getProperty(PROPERTY_LOGIN), properties.getProperty(PROPERTY_PASSWORD), properties.getProperty(PROPERTY_NAME), properties.getProperty(PROPERTY_SURNAME), properties.getProperty(PROPERTY_EMAIL), properties.getProperty(PROPERTY_STUDENT_NUMBER));124 userHibControl.editUser(student);125 return STATUS_SUCCESS;126 }127
128 @RequestMapping(value = "user/updateMod", method = RequestMethod.PUT)
129 @ResponseStatus(value = HttpStatus.OK)
This method does not have any documentation.
Consider adding a documentation comment to explain its use.
While it may seem like the usage of a method is perfectly obvious, any consumers of your API may not be able to pick up on certain details.
This method appears to return an address string based on its name and the return type, but it is hard to say anything further about it. We neither know if the address will be formatted in a special way nor are we given any useful information regarding the returned value.
String getAddress() {
// ...
}
Provide a detailed description of what the method does.
/**
* Returns the address in 3 line format,
* with street address on line 1, area/city on line 2
* and state and country as well as postal code on line 3.
*/
String getAddress() {
// ...
}