Add configurable support for admin profile.

This commit is contained in:
Paulo Gustavo Veiga
2012-02-21 16:36:19 -03:00
parent 7b6cae0fd2
commit 6ff556b317
10 changed files with 102 additions and 26 deletions

View File

@@ -18,7 +18,7 @@ public class AdminController {
@Autowired
private UserService userService;
@RequestMapping(method = RequestMethod.GET, value = "admin/users/{id}", produces = {"application/xml", "application/json"})
@RequestMapping(method = RequestMethod.GET, value = "admin/users/{id}", produces = {"application/xml", "application/json","text/html"})
@ResponseBody
public ModelAndView getUserById(@PathVariable int id) throws IOException {
final User userBy = userService.getUserBy(id);
@@ -28,22 +28,24 @@ public class AdminController {
return new ModelAndView("userView", "user", new RestUser(userBy));
}
@RequestMapping(method = RequestMethod.GET, value = "admin/users/email/{email}", produces = {"application/xml", "application/json"})
@RequestMapping(method = RequestMethod.GET, value = "admin/users/email/{email}", produces = {"application/xml", "application/json","text/html"})
@ResponseBody
public ModelAndView getUserByEmail(@PathVariable String email) throws IOException {
final User userBy = userService.getUserBy(email);
if (userBy == null) {
throw new IllegalArgumentException("User could not be found");
throw new IllegalArgumentException("User '" + email + "' could not be found" );
}
return new ModelAndView("userView", "user", new RestUser(userBy));
}
@RequestMapping(method = RequestMethod.POST, value = "admin/users", consumes = {"application/xml", "application/json"})
public void getUserByEmail(@RequestBody RestUser user) throws IOException, WiseMappingException {
public ModelAndView getUserByEmail(@RequestBody RestUser user) throws IOException, WiseMappingException {
if (user == null) {
throw new IllegalArgumentException("User could not be found");
}
userService.createUser(user.getDelegated(), false);
return new ModelAndView("responseView", "message", "User created successfully");
}
}