[exo-jcr-commits] exo-jcr SVN: r4994 - jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/distribution/impl.
do-not-reply at jboss.org
do-not-reply at jboss.org
Wed Sep 28 06:24:23 EDT 2011
Author: tolusha
Date: 2011-09-28 06:24:22 -0400 (Wed, 28 Sep 2011)
New Revision: 4994
Modified:
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/distribution/impl/DataDistributionByName.java
Log:
EXOJCR-1498: Migration tool and guideline for migration from 1.12.10-GA to 1.14.0.CR4-CP01
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/distribution/impl/DataDistributionByName.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/distribution/impl/DataDistributionByName.java 2011-09-28 09:19:18 UTC (rev 4993)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/distribution/impl/DataDistributionByName.java 2011-09-28 10:24:22 UTC (rev 4994)
@@ -98,36 +98,55 @@
public void migrate(Node rootNode, String nodeType, List<String> mixinTypes, Map<String, String[]> permissions)
throws RepositoryException
{
+ // try to detect if migration is needed
NodeIterator iter = ((NodeImpl)rootNode).getNodesLazily(1);
- if (iter.hasNext() && !iter.nextNode().getPath().endsWith(suffix))
+ while (iter.hasNext())
{
- iter = ((NodeImpl)rootNode).getNodesLazily();
- while (iter.hasNext())
+ String userName = iter.nextNode().getName();
+ if (userName.length() == 1)
{
- Node userNode = iter.nextNode();
- List<String> ancestors = getAncestors(userNode.getName());
-
- Node node = rootNode;
+ continue;
+ }
+ else if (userName.endsWith(suffix) || (!iter.hasNext()))
+ {
+ return;
+ }
+ else
+ {
+ break;
+ }
+ }
- for (int i = 0, length = ancestors.size() - 1; i < length; i++)
+ iter = ((NodeImpl)rootNode).getNodesLazily();
+ while (iter.hasNext())
+ {
+ Node userNode = iter.nextNode();
+ if (userNode.getName().length() == 1)
+ {
+ continue;
+ }
+ List<String> ancestors = getAncestors(userNode.getName());
+
+ Node node = rootNode;
+
+ for (int i = 0, length = ancestors.size() - 1; i < length; i++)
+ {
+ String nodeName = ancestors.get(i);
+ try
{
- String nodeName = ancestors.get(i);
- try
- {
- node = node.getNode(nodeName);
- continue;
- }
- catch (PathNotFoundException e)
- {
- // ignore me
- }
-
- // The node doesn't exist we need to create it
- node = createNode(node, nodeName, nodeType, mixinTypes, permissions, false, false);
+ node = node.getNode(nodeName);
+ continue;
}
+ catch (PathNotFoundException e)
+ {
+ // ignore me
+ }
- userNode.getSession().move(userNode.getPath(), node.getPath() + "/" + ancestors.get(ancestors.size() - 1));
+ // The node doesn't exist we need to create it
+ node = createNode(node, nodeName, nodeType, mixinTypes, permissions, false, false);
}
+
+ userNode.getSession().move(userNode.getPath(), node.getPath() + "/" + ancestors.get(ancestors.size() - 1));
}
rootNode.getSession().save();
More information about the exo-jcr-commits
mailing list