Add mixins before copying properties.
[lgpl/argeo-commons.git] / org.argeo.jcr / src / org / argeo / jcr / JcrUtils.java
index 98dce7eb8f4cd0e460caad6dd4933b517dd7acc7..af8aca69bedf7dbe766c4b31ae06957d4423a409 100644 (file)
@@ -731,6 +731,11 @@ public class JcrUtils {
                        if (toNode.getDefinition().isProtected())
                                return;
 
+                       // add mixins
+                       for (NodeType mixinType : fromNode.getMixinNodeTypes()) {
+                               toNode.addMixin(mixinType.getName());
+                       }
+
                        // process properties
                        PropertyIterator pit = fromNode.getProperties();
                        properties: while (pit.hasNext()) {
@@ -757,11 +762,6 @@ public class JcrUtils {
                        // they existed, before adding the mixins
                        updateLastModified(toNode, true);
 
-                       // add mixins
-                       for (NodeType mixinType : fromNode.getMixinNodeTypes()) {
-                               toNode.addMixin(mixinType.getName());
-                       }
-
                        // process children nodes
                        NodeIterator nit = fromNode.getNodes();
                        while (nit.hasNext()) {
@@ -1233,6 +1233,16 @@ public class JcrUtils {
                }
        }
 
+       /**
+        * Update lastModified recursively until this parent.
+        * 
+        * @param node      the node
+        * @param untilPath the base path, null is equivalent to "/"
+        */
+       public static void updateLastModifiedAndParents(Node node, String untilPath) {
+               updateLastModifiedAndParents(node, untilPath, true);
+       }
+
        /**
         * Update lastModified recursively until this parent.
         *