Increase number of nodes supported.

This commit is contained in:
Paulo Gustavo Veiga 2022-02-23 14:34:55 -08:00
parent ba80f9479c
commit c3be0b6552
2 changed files with 8 additions and 7 deletions

View File

@ -44,8 +44,8 @@ public class InvalidMindmapException
return new InvalidMindmapException(INVALID_MINDMAP_FORMAT, xmlDoc); return new InvalidMindmapException(INVALID_MINDMAP_FORMAT, xmlDoc);
} }
static public InvalidMindmapException tooBigMindnap() { static public InvalidMindmapException tooBigMindnap(int numberOfTopics) {
return new InvalidMindmapException(TOO_BIG_MINDMAP,"<too-big>"); return new InvalidMindmapException(TOO_BIG_MINDMAP, "<too-big " + numberOfTopics + ">");
} }
@NotNull @NotNull

View File

@ -6,7 +6,7 @@ import org.jetbrains.annotations.Nullable;
abstract public class MindmapUtils { abstract public class MindmapUtils {
private static final int MAX_SUPPORTED_NODES = 500; private static final int MAX_SUPPORTED_NODES = 1000;
public static void verifyMindmap(@Nullable String xmlDoc) throws InvalidMindmapException { public static void verifyMindmap(@Nullable String xmlDoc) throws InvalidMindmapException {
if (xmlDoc == null || xmlDoc.trim().isEmpty()) { if (xmlDoc == null || xmlDoc.trim().isEmpty()) {
@ -20,8 +20,9 @@ abstract public class MindmapUtils {
} }
// Validate that the number of nodes is not bigger 500 nodes. // Validate that the number of nodes is not bigger 500 nodes.
if (xmlDoc.split("<topic").length > MAX_SUPPORTED_NODES) { int numberOfTopics = xmlDoc.split("<topic").length;
throw InvalidMindmapException.tooBigMindnap(); if (numberOfTopics > MAX_SUPPORTED_NODES) {
throw InvalidMindmapException.tooBigMindnap(numberOfTopics);
} }
} }
} }