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

@ -37,15 +37,15 @@ public class InvalidMindmapException
}
static public InvalidMindmapException emptyMindmap() {
return new InvalidMindmapException(EMPTY_MINDMAP,"<empty string>");
return new InvalidMindmapException(EMPTY_MINDMAP, "<empty string>");
}
static public InvalidMindmapException invalidFormat(@Nullable String xmlDoc) {
return new InvalidMindmapException(INVALID_MINDMAP_FORMAT,xmlDoc);
return new InvalidMindmapException(INVALID_MINDMAP_FORMAT, xmlDoc);
}
static public InvalidMindmapException tooBigMindnap() {
return new InvalidMindmapException(TOO_BIG_MINDMAP,"<too-big>");
static public InvalidMindmapException tooBigMindnap(int numberOfTopics) {
return new InvalidMindmapException(TOO_BIG_MINDMAP, "<too-big " + numberOfTopics + ">");
}
@NotNull

View File

@ -6,7 +6,7 @@ import org.jetbrains.annotations.Nullable;
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 {
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.
if (xmlDoc.split("<topic").length > MAX_SUPPORTED_NODES) {
throw InvalidMindmapException.tooBigMindnap();
int numberOfTopics = xmlDoc.split("<topic").length;
if (numberOfTopics > MAX_SUPPORTED_NODES) {
throw InvalidMindmapException.tooBigMindnap(numberOfTopics);
}
}
}