Author: jukka
Date: Thu Feb 27 15:19:39 2014
New Revision: 1572615

URL: http://svn.apache.org/r1572615
Log:
OAK-1391: Use an existing data store during migration

Make the use of binary references optional

Modified:
    
jackrabbit/oak/trunk/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/JackrabbitNodeState.java
    
jackrabbit/oak/trunk/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/RepositoryUpgrade.java

Modified: 
jackrabbit/oak/trunk/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/JackrabbitNodeState.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/JackrabbitNodeState.java?rev=1572615&r1=1572614&r2=1572615&view=diff
==============================================================================
--- 
jackrabbit/oak/trunk/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/JackrabbitNodeState.java
 (original)
+++ 
jackrabbit/oak/trunk/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/JackrabbitNodeState.java
 Thu Feb 27 15:19:39 2014
@@ -73,16 +73,20 @@ class JackrabbitNodeState extends Abstra
 
     private final NodeState state;
 
+    private final boolean useBinaryReferences;
+
     private JackrabbitNodeState(
             PersistenceManager source, NamespaceRegistry registry,
-            NodeState state) {
+            NodeState state, boolean useBinaryReferences) {
         this.source = source;
         this.registry = registry;
         this.state = state;
+        this.useBinaryReferences = useBinaryReferences;
     }
 
     JackrabbitNodeState(
-            PersistenceManager source, NamespaceRegistry registry, NodeId id) {
+            PersistenceManager source, NamespaceRegistry registry,
+            NodeId id, boolean useBinaryReferences) {
         this.source = source;
         this.registry = registry;
         try {
@@ -90,6 +94,7 @@ class JackrabbitNodeState extends Abstra
         } catch (ItemStateException e) {
             throw new IllegalStateException("Unable to access node " + id, e);
         }
+        this.useBinaryReferences = useBinaryReferences;
     }
 
     //---------------------------------------------------------< NodeState >--
@@ -154,8 +159,9 @@ class JackrabbitNodeState extends Abstra
             }
 
             try {
+                NodeState childState = source.load(entry.getId());
                 JackrabbitNodeState child = new JackrabbitNodeState(
-                        source, registry, source.load(entry.getId()));
+                        source, registry, childState, useBinaryReferences);
                 entries.add(new MemoryChildNodeEntry(name, child));
             } catch (ItemStateException e) {
                 warn("Unable to access child entry " + name, e);
@@ -320,6 +326,9 @@ class JackrabbitNodeState extends Abstra
             }
             @Override
             public String getReference() {
+                if (!useBinaryReferences) {
+                    return null;
+                }
                 try {
                     Binary binary = value.getBinary();
                     try {

Modified: 
jackrabbit/oak/trunk/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/RepositoryUpgrade.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/RepositoryUpgrade.java?rev=1572615&r1=1572614&r2=1572615&view=diff
==============================================================================
--- 
jackrabbit/oak/trunk/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/RepositoryUpgrade.java
 (original)
+++ 
jackrabbit/oak/trunk/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/RepositoryUpgrade.java
 Thu Feb 27 15:19:39 2014
@@ -22,7 +22,6 @@ import java.io.InputStream;
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
-import java.util.Set;
 
 import javax.jcr.NamespaceException;
 import javax.jcr.NamespaceRegistry;
@@ -69,8 +68,6 @@ import org.apache.jackrabbit.spi.QValueC
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.collect.ImmutableSet;
-
 import static com.google.common.base.Preconditions.checkState;
 import static com.google.common.collect.Lists.newArrayListWithCapacity;
 import static com.google.common.collect.Maps.newHashMap;
@@ -139,6 +136,8 @@ public class RepositoryUpgrade {
      */
     private final NodeStore target;
 
+    private boolean copyBinariesByReference = false;
+
     /**
      * Copies the contents of the repository in the given source directory
      * to the given target node store.
@@ -183,6 +182,14 @@ public class RepositoryUpgrade {
         this.target = target;
     }
 
+    public boolean isCopyBinariesByReference() {
+        return copyBinariesByReference;
+    }
+
+    public void setCopyBinariesByReference(boolean copyBinariesByReference) {
+        this.copyBinariesByReference = copyBinariesByReference;
+    }
+
     /**
      * Copies the full content from the source to the target repository.
      * <p>
@@ -531,9 +538,9 @@ public class RepositoryUpgrade {
 
         NodeBuilder system = root.child(JCR_SYSTEM);
         system.setChildNode(JCR_VERSIONSTORAGE, new JackrabbitNodeState(
-                pm, nr, VERSION_STORAGE_NODE_ID));
+                pm, nr, VERSION_STORAGE_NODE_ID, copyBinariesByReference));
         system.setChildNode("jcr:activities", new JackrabbitNodeState(
-                pm, nr, ACTIVITIES_NODE_ID));
+                pm, nr, ACTIVITIES_NODE_ID, copyBinariesByReference));
     }   
 
     private void copyWorkspaces(
@@ -549,7 +556,8 @@ public class RepositoryUpgrade {
                 source.getWorkspaceInfo(name).getPersistenceManager();
         NamespaceRegistryImpl nr = source.getNamespaceRegistry();
 
-        NodeState state = new JackrabbitNodeState(pm, nr, ROOT_NODE_ID);
+        NodeState state = new JackrabbitNodeState(
+                pm, nr, ROOT_NODE_ID, copyBinariesByReference);
         for (PropertyState property : state.getProperties()) {
             root.setProperty(property);
         }


Reply via email to