WIP.
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCModelView.java b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCModelView.java
index 4a6e3a5..c65737f 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCModelView.java
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCModelView.java
@@ -159,6 +159,12 @@
int MODEL_VERSION_MAXLEN = 16;
/**
+ * TODO:
+ * Max model element length for {@link NCElement#getId()} method.
+ */
+ int MODEL_ELEMENT_ID_MAXLEN = 64;
+
+ /**
* Default value for {@link #isSparse()} method.
*/
boolean DFLT_IS_SPARSE = false;
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/deploy/NCDeployManager.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/deploy/NCDeployManager.scala
index a72b6c0..9ed5af3 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/deploy/NCDeployManager.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/deploy/NCDeployManager.scala
@@ -923,6 +923,9 @@
checkCollection("metadata", mdl.getMetadata)
checkCollection("restrictedCombinations", mdl.getRestrictedCombinations)
+ // TODO:
+ mdl.getElements.asScala.foreach(e => checkMandatoryString(e.getId, s"elementId=${e.getId}", MODEL_ELEMENT_ID_MAXLEN))
+
for ((elm, restrs: util.Set[String]) <- mdl.getRestrictedCombinations.asScala) {
if (elm != "nlpcraft:limit" && elm != "nlpcraft:sort" && elm != "nlpcraft:relation")
throw new NCE(s"Unsupported restricting element ID [" +
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/server/rest/NCBasicRestApi.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/server/rest/NCBasicRestApi.scala
index d94f7d1..91d5d8e 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/server/rest/NCBasicRestApi.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/server/rest/NCBasicRestApi.scala
@@ -107,6 +107,7 @@
private final val STD_FIELD_LENGTHS = Map[String, Int](
"srvReqId" -> 32,
"mdlId" -> NCModelView.MODEL_ID_MAXLEN,
+ "elemId" -> NCModelView.MODEL_ELEMENT_ID_MAXLEN,
"country" -> 32,
"postalCode" -> 32,
@@ -840,7 +841,7 @@
"acsTok" -> req.acsTok,
"mdlId" -> req.mdlId,
"elemId" -> req.elemId) { span =>
- checkLength("acsTok" -> req.acsTok, "mdlId" -> req.mdlId)
+ checkLength("acsTok" -> req.acsTok, "mdlId" -> req.mdlId, "elemId" -> req.elemId)
val admUsr = authenticateAsAdmin(req.acsTok)
diff --git a/nlpcraft/src/test/scala/org/apache/nlpcraft/server/rest/NCRestModelSpec.scala b/nlpcraft/src/test/scala/org/apache/nlpcraft/server/rest/NCRestModelSpec.scala
index 6cdc0af..a00fc11 100644
--- a/nlpcraft/src/test/scala/org/apache/nlpcraft/server/rest/NCRestModelSpec.scala
+++ b/nlpcraft/src/test/scala/org/apache/nlpcraft/server/rest/NCRestModelSpec.scala
@@ -92,6 +92,8 @@
postError("model/syns", 400, "NC_INVALID_FIELD", "mdlId" -> "UNKNOWN", "elemId" -> "UNKNOWN")
postError("model/syns", 400, "NC_INVALID_FIELD", "mdlId" -> "rest.test.model", "elemId" -> "UNKNOWN")
+ postError("model/syns", 400, "NC_INVALID_FIELD", "mdlId" -> ("A" * 33), "elemId" -> "UNKNOWN")
+ postError("model/syns", 400, "NC_INVALID_FIELD", "mdlId" -> "rest.test.model", "elemId" -> ("A" * 65))
postError("model/syns", 400, "NC_ERROR", "mdlId" -> "rest.test.model")
}
}
diff --git a/openapi/nlpcraft_swagger.yml b/openapi/nlpcraft_swagger.yml
index c317157..51bfee8 100644
--- a/openapi/nlpcraft_swagger.yml
+++ b/openapi/nlpcraft_swagger.yml
@@ -265,6 +265,7 @@
description: ID of the model to run synonym suggestion on.
elemId:
type: string
+ maxLength: 64
description: ID of the model element to getting synonyms.
responses:
'200':