kwin commented on a change in pull request #163:
URL: 
https://github.com/apache/jackrabbit-filevault/pull/163#discussion_r700802516



##########
File path: 
vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/io/DocViewSAXImporter.java
##########
@@ -1247,6 +1248,21 @@ public void endElement(String uri, String localName, 
String qName) throws SAXExc
         }
     }
 
+    private int getSiblWithReqPrimType(Node child) throws RepositoryException {

Review comment:
       This IMHO not only returns the number of siblings but includes child 
itself. Also the method does not care about required primary type. Why not 
rename to `getNumChildrenOfPrimaryNodeType(Node parent, String primaryNodeType)`

##########
File path: 
vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/MandatoryNode.java
##########
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jackrabbit.vault.packaging.integration;
+
+import java.io.IOException;
+
+import javax.jcr.RepositoryException;
+
+import org.apache.jackrabbit.api.JackrabbitSession;
+import org.apache.jackrabbit.api.security.user.Authorizable;
+import org.apache.jackrabbit.api.security.user.UserManager;
+import org.apache.jackrabbit.api.security.user.Authorizable;
+import org.apache.jackrabbit.vault.packaging.PackageException;
+import org.junit.Test;
+
+
+public class MandatoryNode extends IntegrationTestBase {
+ 
+    @Test
+    public void testSimpleFileAggregateOverwritesChildNodes()
+            throws RepositoryException, IOException, PackageException {
+
+        extractVaultPackage("/test-packages/wcm-rollout-config-1.zip");

Review comment:
       Can you provide minimal test packages in exploded form (similar to 
https://github.com/apache/jackrabbit-filevault/tree/master/vault-core/src/test/resources/test-packages/test_nodetype_on_merge.zip)

##########
File path: 
vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/io/DocViewSAXImporter.java
##########
@@ -1247,6 +1248,21 @@ public void endElement(String uri, String localName, 
String qName) throws SAXExc
         }
     }
 
+    private int getSiblWithReqPrimType(Node child) throws RepositoryException {
+
+        int count=0;
+        Node parent = child.getParent();
+        NodeIterator iter = parent.getNodes();
+        while (iter.hasNext()) {
+            Node sibling = iter.nextNode();
+            if(child.getPrimaryNodeType().toString()

Review comment:
       what about extended primary node types 
(https://docs.adobe.com/content/docs/en/spec/jsr170/javadocs/jcr-2.0/javax/jcr/nodetype/NodeType.html#isNodeType(java.lang.String))?

##########
File path: 
vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/io/DocViewSAXImporter.java
##########
@@ -1215,10 +1215,11 @@ public void endElement(String uri, String localName, 
String qName) throws SAXExc
                             }
                         } else {
                             if (wspFilter.getImportMode(path) == 
ImportMode.REPLACE) {
+
                                 // check if child is not protected
                                 if (child.getDefinition().isProtected()) {
                                     log.debug("Refuse to delete protected 
child node: {}", path);
-                                } else if (child.getDefinition().isMandatory() 
&& numChildren <= JcrConstants.NUM_MANDATORY_CHILDREN) {
+                                } else if (child.getDefinition().isMandatory() 
&&  getSiblWithReqPrimType(child) < 0) {

Review comment:
       How can this ever be true? IMHO`getSiblWithReqPrimType(..)` always 
returns an integer >= 0




-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to