You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@gora.apache.org by GitBox <gi...@apache.org> on 2020/10/23 21:35:48 UTC

[GitHub] [gora] mgov88 opened a new pull request #227: XSD validation for Lucene datastore

mgov88 opened a new pull request #227:
URL: https://github.com/apache/gora/pull/227


   
   I implemented an XSD validation for the Lucene Datastore, I would like to know if I did it correctly, so I can go on and repeat this implementation for the other datastores.
   
   I created this PR as a draft, when I finish the rest of datastores I will send a complete PR.
   
   Issue: [GORA-455 Create XSD's for all datastore xml mapping files](https://issues.apache.org/jira/projects/GORA/issues/GORA-455)


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [gora] alfonsonishikawa commented on a change in pull request #227: XSD validation for Lucene datastore

Posted by GitBox <gi...@apache.org>.
alfonsonishikawa commented on a change in pull request #227:
URL: https://github.com/apache/gora/pull/227#discussion_r513724584



##########
File path: gora-lucene/src/test/conf/gora-lucene-mapping.xml
##########
@@ -16,7 +16,8 @@
    limitations under the License.
 -->
 
-<gora-otd>
+<gora-otd xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
+          xsi:noNamespaceSchemaLocation="gora-lucene.xsd">

Review comment:
       What does "noNamespaceSchemaLocation" means? Is that the default namespace? Do <class> and <primarykey> use that by default?
   I suggest to create a Unit Test to check that an ill-formed mapping does not pass the validation.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [gora] mgov88 commented on a change in pull request #227: XSD validation for Lucene datastore

Posted by GitBox <gi...@apache.org>.
mgov88 commented on a change in pull request #227:
URL: https://github.com/apache/gora/pull/227#discussion_r513747206



##########
File path: gora-lucene/src/test/conf/gora-lucene-mapping.xml
##########
@@ -16,7 +16,8 @@
    limitations under the License.
 -->
 
-<gora-otd>
+<gora-otd xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
+          xsi:noNamespaceSchemaLocation="gora-lucene.xsd">

Review comment:
       Hi, it found examples on the internet that used that attributes to link to local XSD files, I guess this noNamespaceSchemaLocation is used if there is not a Namespaces defined in the XML.
   
   I will try to implement a test




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [gora] jhnmora000 commented on a change in pull request #227: XSD validation for Lucene datastore

Posted by GitBox <gi...@apache.org>.
jhnmora000 commented on a change in pull request #227:
URL: https://github.com/apache/gora/pull/227#discussion_r511645196



##########
File path: gora-lucene/src/test/conf/gora-lucene.xsd
##########
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8" ?>

Review comment:
       IMHO, a schema file should not be placed in the tests of the datastore

##########
File path: gora-lucene/src/test/conf/gora-lucene.xsd
##########
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

Review comment:
       please add the Apache 2.0 License notice for this file

##########
File path: gora-lucene/src/test/conf/gora-lucene.xsd
##########
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
+
+    <xs:element name="gora-otd" type="lucene-mapping"/>

Review comment:
       format this file with 2-space indentation




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [gora] mgov88 commented on a change in pull request #227: XSD validation for Lucene datastore

Posted by GitBox <gi...@apache.org>.
mgov88 commented on a change in pull request #227:
URL: https://github.com/apache/gora/pull/227#discussion_r512297279



##########
File path: gora-lucene/src/test/conf/gora-lucene.xsd
##########
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

Review comment:
       Thanks for your feedback, I will add it




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [gora] alfonsonishikawa commented on pull request #227: XSD validation for Lucene datastore

Posted by GitBox <gi...@apache.org>.
alfonsonishikawa commented on pull request #227:
URL: https://github.com/apache/gora/pull/227#issuecomment-719062174


   Good to see it works! :)
   The last thing I would ask for is to add an opt-out (or opt-in) option to gora.properties to enable/disable verification.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [gora] mgov88 commented on a change in pull request #227: XSD validation for Lucene datastore

Posted by GitBox <gi...@apache.org>.
mgov88 commented on a change in pull request #227:
URL: https://github.com/apache/gora/pull/227#discussion_r513835747



##########
File path: gora-lucene/src/test/conf/gora-lucene-mapping.xml
##########
@@ -16,7 +16,8 @@
    limitations under the License.
 -->
 
-<gora-otd>
+<gora-otd xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
+          xsi:noNamespaceSchemaLocation="gora-lucene.xsd">

Review comment:
       I developed a test. When a bad XML file is parsed this exception triggers:
   
   `org.apache.gora.util.GoraException: java.io.IOException: Unable to read gora-lucene-mapping-bad.xml
   	at org.apache.gora.lucene.store.TestLuceneStore.testXSDValidation(TestLuceneStore.java:178)
   Caused by: java.io.IOException: Unable to read gora-lucene-mapping-bad.xml
   	at org.apache.gora.lucene.store.TestLuceneStore.testXSDValidation(TestLuceneStore.java:178)
   Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'Field'. One of '{primarykey}' is expected.
   	at org.apache.gora.lucene.store.TestLuceneStore.testXSDValidation(TestLuceneStore.java:178)`




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [gora] mgov88 commented on a change in pull request #227: XSD validation for Lucene datastore

Posted by GitBox <gi...@apache.org>.
mgov88 commented on a change in pull request #227:
URL: https://github.com/apache/gora/pull/227#discussion_r512297873



##########
File path: gora-lucene/src/test/conf/gora-lucene.xsd
##########
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
+
+    <xs:element name="gora-otd" type="lucene-mapping"/>

Review comment:
       Sorry , I did realised that I used the wrong indentation




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [gora] mgov88 commented on a change in pull request #227: XSD validation for Lucene datastore

Posted by GitBox <gi...@apache.org>.
mgov88 commented on a change in pull request #227:
URL: https://github.com/apache/gora/pull/227#discussion_r513835747



##########
File path: gora-lucene/src/test/conf/gora-lucene-mapping.xml
##########
@@ -16,7 +16,8 @@
    limitations under the License.
 -->
 
-<gora-otd>
+<gora-otd xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
+          xsi:noNamespaceSchemaLocation="gora-lucene.xsd">

Review comment:
       I developed a test. When a bad XML file is parsed this exception triggers:
   
   ```
   org.apache.gora.util.GoraException: java.io.IOException: Unable to read gora-lucene-mapping-bad.xml
   	at org.apache.gora.lucene.store.TestLuceneStore.testXSDValidation(TestLuceneStore.java:178)
   Caused by: java.io.IOException: Unable to read gora-lucene-mapping-bad.xml
   	at org.apache.gora.lucene.store.TestLuceneStore.testXSDValidation(TestLuceneStore.java:178)
   Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'Field'. One of '{primarykey}' is expected.
   	at org.apache.gora.lucene.store.TestLuceneStore.testXSDValidation(TestLuceneStore.java:178)
   ```




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [gora] alfonsonishikawa commented on pull request #227: XSD validation for Lucene datastore

Posted by GitBox <gi...@apache.org>.
alfonsonishikawa commented on pull request #227:
URL: https://github.com/apache/gora/pull/227#issuecomment-716888452


   Would be desirable to add the XSD reference to the Lucene mapping XMLs (for sure there is some XML mapping in tests).


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [gora] mgov88 commented on a change in pull request #227: XSD validation for Lucene datastore

Posted by GitBox <gi...@apache.org>.
mgov88 commented on a change in pull request #227:
URL: https://github.com/apache/gora/pull/227#discussion_r512298390



##########
File path: gora-lucene/src/test/conf/gora-lucene.xsd
##########
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8" ?>

Review comment:
       I am going to move the schema file to a 'resources' folder in the main code of the module.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org