[exo-jcr-commits] exo-jcr SVN: r4993 - in jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext: distribution/impl and 1 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Wed Sep 28 05:19:18 EDT 2011


Author: tolusha
Date: 2011-09-28 05:19:18 -0400 (Wed, 28 Sep 2011)
New Revision: 4993

Modified:
   jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/distribution/DataDistributionType.java
   jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/distribution/impl/AbstractDataDistributionType.java
   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/hierarchy/impl/NodeHierarchyCreatorImpl.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/DataDistributionType.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/distribution/DataDistributionType.java	2011-09-28 09:13:04 UTC (rev 4992)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/distribution/DataDistributionType.java	2011-09-28 09:19:18 UTC (rev 4993)
@@ -108,4 +108,16 @@
     * @throws RepositoryException if an error occurred during migration
     */
    void migrate(Node rootNode) throws RepositoryException;
+
+   /**
+    * Migrate from old structure to new one.
+    * 
+    * @param rootNode the root node under which the data to migrate is stored
+    * @param nodeType the node type to use in case we need to create the node
+    * @param mixinTypes the mixin types to use in case we need to create the node
+    * @param permissions the permissions to use in case we need to create the node
+    * @throws RepositoryException if an error occurred during migration
+    */
+   void migrate(Node rootNode, String nodeType, List<String> mixinTypes, Map<String, String[]> permissions)
+      throws RepositoryException;
 }

Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/distribution/impl/AbstractDataDistributionType.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/distribution/impl/AbstractDataDistributionType.java	2011-09-28 09:13:04 UTC (rev 4992)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/distribution/impl/AbstractDataDistributionType.java	2011-09-28 09:19:18 UTC (rev 4993)
@@ -43,7 +43,7 @@
    /**
     * The default node type to use when we create a new node
     */
-   protected static final String DEFAULT_NODE_TYPE = "nt:unstructured".intern();
+   private static final String DEFAULT_NODE_TYPE = "nt:unstructured".intern();
 
    /**
     * The map defining all the locks available
@@ -113,7 +113,7 @@
             // ignore me
          }
          // The node doesn't exist we need to create it
-         node = createNode(node, nodeName, nodeType, mixinTypes, permissions, i == length - 1);
+         node = createNode(node, nodeName, nodeType, mixinTypes, permissions, i == length - 1, true);
       }
       return node;
    }
@@ -151,6 +151,15 @@
    }
 
    /**
+    * {@inheritDoc}
+    */
+   public void migrate(Node rootNode, String nodeType, List<String> mixinTypes, Map<String, String[]> permissions)
+      throws RepositoryException
+   {
+      throw new UnsupportedOperationException("The method is not supported");
+   }
+
+   /**
     * Creates the node of the given node type with the given node name directly under 
     * the given parent node, using the given mixin types and permissions
     * @param parentNode the parent node
@@ -162,9 +171,9 @@
     * @return the created node
     * @throws RepositoryException if any exception occurs while creating the node
     */
-   private Node createNode(final Node parentNode, final String nodeName, final String nodeType,
-      final List<String> mixinTypes, final Map<String, String[]> permissions, final boolean isLeaf)
-      throws RepositoryException
+   protected Node createNode(final Node parentNode, final String nodeName, final String nodeType,
+      final List<String> mixinTypes, final Map<String, String[]> permissions, final boolean isLeaf,
+      final boolean callSave) throws RepositoryException
    {
       Lock lock = getLock(parentNode, nodeName);
       lock.lock();
@@ -212,7 +221,11 @@
                }
             }
          }
-         parentNode.save();
+
+         if (callSave)
+         {
+            parentNode.save();
+         }
          return node;         
       }
       finally 

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:13:04 UTC (rev 4992)
+++ 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)
@@ -22,6 +22,7 @@
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
 
 import javax.jcr.Node;
 import javax.jcr.NodeIterator;
@@ -88,6 +89,15 @@
     */
    public void migrate(Node rootNode) throws RepositoryException
    {
+      migrate(rootNode, null, null, null);
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public void migrate(Node rootNode, String nodeType, List<String> mixinTypes, Map<String, String[]> permissions)
+      throws RepositoryException
+   {
       NodeIterator iter = ((NodeImpl)rootNode).getNodesLazily(1);
       if (iter.hasNext() && !iter.nextNode().getPath().endsWith(suffix))
       {
@@ -113,7 +123,7 @@
                }
 
                // The node doesn't exist we need to create it
-               node = node.addNode(nodeName, DEFAULT_NODE_TYPE);
+               node = createNode(node, nodeName, nodeType, mixinTypes, permissions, false, false);
             }
 
             userNode.getSession().move(userNode.getPath(), node.getPath() + "/" + ancestors.get(ancestors.size() - 1));

Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/hierarchy/impl/NodeHierarchyCreatorImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/hierarchy/impl/NodeHierarchyCreatorImpl.java	2011-09-28 09:13:04 UTC (rev 4992)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/hierarchy/impl/NodeHierarchyCreatorImpl.java	2011-09-28 09:19:18 UTC (rev 4993)
@@ -93,8 +93,12 @@
       }
       jcrService_ = jcrService;
       dataDistributionManager_ = dataDistributionManager;
-      oldDistribution = params != null && Boolean.valueOf(params.getValueParam("old-user-distribution").getValue());
-      autoMigrate = params != null && Boolean.valueOf(params.getValueParam("auto-migrate").getValue());
+      oldDistribution =
+         params != null && params.getValueParam("old-user-distribution") != null
+            && Boolean.valueOf(params.getValueParam("old-user-distribution").getValue());
+      autoMigrate =
+         params != null && params.getValueParam("auto-migrate") != null
+            && Boolean.valueOf(params.getValueParam("auto-migrate").getValue());
       
       if (PropertyManager.isDevelopping() && !oldDistribution)
       {



More information about the exo-jcr-commits mailing list