mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-12-23 03:43:48 +01:00
Check map before save.
This commit is contained in:
parent
6155a70c04
commit
b5a7a11920
@ -162,13 +162,6 @@ public class MindmapController extends BaseController {
|
||||
if (xml == null) {
|
||||
throw new IllegalArgumentException("Map xml can not be null");
|
||||
}
|
||||
|
||||
// Check that what we received a valid mindmap...
|
||||
xml = xml.trim();
|
||||
if (!xml.startsWith("<map") || !xml.endsWith("</map>")) {
|
||||
throw new IllegalArgumentException("Map seems not to be a valid mindmap:"+xml);
|
||||
}
|
||||
|
||||
mindmap.setXmlStr(xml);
|
||||
|
||||
// Update map ...
|
||||
|
@ -29,6 +29,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
@ -100,7 +101,19 @@ public class MindmapServiceImpl
|
||||
@Override
|
||||
public void updateMindmap(@NotNull Mindmap mindMap, boolean saveHistory) throws WiseMappingException {
|
||||
if (mindMap.getTitle() == null || mindMap.getTitle().length() == 0) {
|
||||
throw new WiseMappingException("The tile can not be empty");
|
||||
throw new WiseMappingException("The title can not be empty");
|
||||
}
|
||||
|
||||
// Check that what we received a valid mindmap...
|
||||
final String xml;
|
||||
try {
|
||||
xml = mindMap.getXmlStr().trim();
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new WiseMappingException("Could not be decoded.",e);
|
||||
}
|
||||
|
||||
if (!xml.startsWith("<map") || !xml.endsWith("</map>")) {
|
||||
throw new WiseMappingException("Map seems not to be a valid mindmap:"+xml);
|
||||
}
|
||||
|
||||
mindmapManager.updateMindmap(mindMap, saveHistory);
|
||||
|
Loading…
Reference in New Issue
Block a user