From: Mathieu Baudier Date: Fri, 8 Mar 2013 19:30:03 +0000 (+0000) Subject: Fix repo sync X-Git-Tag: argeo-slc-2.1.7~420 X-Git-Url: http://git.argeo.org/?a=commitdiff_plain;h=b5659b00d83ced604ab8aba88c05defe08680ac0;p=gpl%2Fargeo-slc.git Fix repo sync git-svn-id: https://svn.argeo.org/slc/trunk@6119 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc --- diff --git a/runtime/org.argeo.slc.repo/src/main/java/org/argeo/slc/repo/RepoSync.java b/runtime/org.argeo.slc.repo/src/main/java/org/argeo/slc/repo/RepoSync.java index 942987841..d145eb225 100644 --- a/runtime/org.argeo.slc.repo/src/main/java/org/argeo/slc/repo/RepoSync.java +++ b/runtime/org.argeo.slc.repo/src/main/java/org/argeo/slc/repo/RepoSync.java @@ -312,12 +312,6 @@ public class RepoSync implements Runnable { // } // } - // next level - for (NodeIterator ni = sourceNode.getNodes(); ni.hasNext();) { - Node sourceChild = ni.nextNode(); - syncNode(sourceChild, targetSession); - } - // mixin and properties for (NodeType nt : sourceNode.getMixinNodeTypes()) { if (!targetNode.isNodeType(nt.getName()) @@ -326,6 +320,14 @@ public class RepoSync implements Runnable { } copyProperties(sourceNode, targetNode); + // next level + for (NodeIterator ni = sourceNode.getNodes(); ni.hasNext();) { + Node sourceChild = ni.nextNode(); + syncNode(sourceChild, targetSession); + } + + copyTimestamps(sourceNode, targetNode); + if (sourceNode.isNodeType(NodeType.NT_HIERARCHY_NODE)) { if (targetSession.hasPendingChanges()) { if (sourceNode.isNodeType(NodeType.NT_FILE)) @@ -341,6 +343,35 @@ public class RepoSync implements Runnable { } } + private void copyTimestamps(Node sourceNode, Node targetNode) + throws RepositoryException { + if (sourceNode.getDefinition().isProtected()) + return; + if (targetNode.getDefinition().isProtected()) + return; + copyTimestamp(sourceNode, targetNode, Property.JCR_CREATED); + copyTimestamp(sourceNode, targetNode, Property.JCR_CREATED_BY); + copyTimestamp(sourceNode, targetNode, Property.JCR_LAST_MODIFIED); + copyTimestamp(sourceNode, targetNode, Property.JCR_LAST_MODIFIED_BY); + } + + private void copyTimestamp(Node sourceNode, Node targetNode, String property) + throws RepositoryException { + if (sourceNode.hasProperty(property)) { + Property p = sourceNode.getProperty(property); + if (p.getDefinition().isProtected()) + return; + if (targetNode.hasProperty(property) + && targetNode + .getProperty(property) + .getValue() + .equals(sourceNode.getProperty(property).getValue())) + return; + targetNode.setProperty(property, sourceNode.getProperty(property) + .getValue()); + } + } + private void copyProperties(Node sourceNode, Node targetNode) throws RepositoryException { properties: for (PropertyIterator pi = sourceNode.getProperties(); pi @@ -348,6 +379,12 @@ public class RepoSync implements Runnable { Property p = pi.nextProperty(); if (p.getDefinition().isProtected()) continue properties; + if (p.getName().equals(Property.JCR_CREATED) + || p.getName().equals(Property.JCR_CREATED_BY) + || p.getName().equals(Property.JCR_LAST_MODIFIED) + || p.getName().equals(Property.JCR_LAST_MODIFIED_BY)) + continue properties; + if (p.getType() == PropertyType.BINARY) { copyBinary(p, targetNode); } else {