Improve validation of xml mindmaps during save.

This commit is contained in:
Paulo Gustavo Veiga
2022-02-22 14:16:50 -08:00
parent 342099194d
commit c3f93fdf4a
8 changed files with 116 additions and 41 deletions

View File

@@ -133,10 +133,7 @@ public class MindmapController extends BaseController {
collaborationProperties.setMindmapProperties(properties);
// Validate content ...
String xml = restMindmap.getXml();
if (xml == null) {
throw new IllegalArgumentException("Map xml can not be null");
}
final String xml = restMindmap.getXml();
mindmap.setXmlStr(xml);
// Update map ...
@@ -164,14 +161,10 @@ public class MindmapController extends BaseController {
@RequestMapping(method = RequestMethod.PUT, value = {"/maps/{id}/document/xml"}, consumes = {"text/plain"})
@ResponseBody
public void updateDocument(@PathVariable int id, @RequestBody String xmlDoc) throws WiseMappingException, IOException {
final Mindmap mindmap = findMindmapById(id);
final User user = Utils.getUser();
if (xmlDoc != null && !xmlDoc.isEmpty()) {
mindmap.setXmlStr(xmlDoc);
}
mindmap.setXmlStr(xmlDoc);
saveMindmapDocument(false, mindmap, user);
}
@@ -273,7 +266,6 @@ public class MindmapController extends BaseController {
// Is there a map with the same name ?
if (mindmapService.getMindmapByTitle(title, user) != null) {
throw buildValidationException("title", "You already have a mindmap with this title");
}