Add REST support for changing map title and description.

This commit is contained in:
Paulo Gustavo Veiga
2012-03-15 01:47:42 -03:00
parent 0e3b0754cd
commit 731df774a8
3 changed files with 95 additions and 25 deletions

View File

@@ -85,6 +85,37 @@ public class MindmapController extends BaseController {
updateMindmap(minor, mindMap, user);
}
@RequestMapping(method = RequestMethod.PUT, value = "/maps/{id}/title", consumes = {"text/plain"}, produces = {"application/json", "text/html", "application/xml"})
@ResponseStatus(value = HttpStatus.NO_CONTENT)
public void changeMapTitle(@RequestBody String title, @PathVariable int id) throws WiseMappingException {
final MindMap mindMap = mindmapService.getMindmapById(id);
final User user = Utils.getUser();
// Is there a map with the same name ?
if (mindmapService.getMindmapByTitle(title, user) != null) {
throw new IllegalArgumentException("Map already exists with this title");
}
// Update map ...
final MindMap mindmap = mindmapService.getMindmapById(id);
mindmap.setTitle(title);
updateMindmap(true, mindMap, user);
}
@RequestMapping(method = RequestMethod.PUT, value = "/maps/{id}/description", consumes = {"text/plain"}, produces = {"application/json", "text/html", "application/xml"})
@ResponseStatus(value = HttpStatus.NO_CONTENT)
public void changeMapDescription(@RequestBody String description, @PathVariable int id) throws WiseMappingException {
final MindMap mindMap = mindmapService.getMindmapById(id);
final User user = Utils.getUser();
// Update map ...
final MindMap mindmap = mindmapService.getMindmapById(id);
mindmap.setDescription(description);
updateMindmap(true, mindMap, user);
}
@RequestMapping(method = RequestMethod.DELETE, value = "/maps/{id}")
@ResponseStatus(value = HttpStatus.NO_CONTENT)