This is an automated email from the ASF dual-hosted git repository.

sergeykamov pushed a commit to branch NLPCRAFT-371
in repository https://gitbox.apache.org/repos/asf/incubator-nlpcraft.git


The following commit(s) were added to refs/heads/NLPCRAFT-371 by this push:
     new 86cfff4  WIP.
86cfff4 is described below

commit 86cfff431865b478d549f8879ee74c9e652e16f3
Author: Sergey Kamov <[email protected]>
AuthorDate: Thu Jul 22 14:46:42 2021 +0300

    WIP.
---
 nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCModelView.java  | 6 ++++++
 .../org/apache/nlpcraft/probe/mgrs/deploy/NCDeployManager.scala     | 3 +++
 .../main/scala/org/apache/nlpcraft/server/rest/NCBasicRestApi.scala | 3 ++-
 .../scala/org/apache/nlpcraft/server/rest/NCRestModelSpec.scala     | 2 ++
 openapi/nlpcraft_swagger.yml                                        | 1 +
 5 files changed, 14 insertions(+), 1 deletion(-)

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 @@ public interface NCModelView extends NCMetadata {
     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 @@ object NCDeployManager extends NCService {
         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 @@ class NCBasicRestApi extends NCRestApi with LazyLogging 
with NCOpenCensusTrace w
     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 @@ class NCBasicRestApi extends NCRestApi with LazyLogging 
with NCOpenCensusTrace w
                 "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 @@ class NCRestModelSpec extends NCRestSpec {
 
         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 @@ paths:
                 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':

Reply via email to