jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chet...@apache.org
Subject svn commit: r1578738 - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/datastore/ oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/blob/ds/ oak-run/src/main/java/org/apache/jackrabbit/oak/fixture/
Date Tue, 18 Mar 2014 05:04:11 GMT
Author: chetanm
Date: Tue Mar 18 05:04:11 2014
New Revision: 1578738

URL: http://svn.apache.org/r1578738
Log:
OAK-1502 - Make DataStores available to NodeStores

Changes as per review by Amit Jain. Thanks!

-- Specifying a default DataStore for tests
-- Populating bean properties before init

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/datastore/DataStoreBlobStore.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/blob/ds/DataStoreUtils.java
    jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/fixture/OakFixture.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/datastore/DataStoreBlobStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/datastore/DataStoreBlobStore.java?rev=1578738&r1=1578737&r2=1578738&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/datastore/DataStoreBlobStore.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/datastore/DataStoreBlobStore.java
Tue Mar 18 05:04:11 2014
@@ -31,7 +31,6 @@ import javax.annotation.Nullable;
 import javax.jcr.RepositoryException;
 
 import com.google.common.base.Function;
-import com.google.common.base.Preconditions;
 import com.google.common.collect.Iterators;
 import com.google.common.io.ByteStreams;
 import com.google.common.io.Closeables;
@@ -44,6 +43,8 @@ import org.apache.jackrabbit.core.data.M
 import org.apache.jackrabbit.oak.spi.blob.BlobStore;
 import org.apache.jackrabbit.oak.spi.blob.GarbageCollectableBlobStore;
 
+import static com.google.common.base.Preconditions.checkNotNull;
+
 /**
  * BlobStore wrapper for DataStore. Wraps Jackrabbit 2 DataStore and expose them as BlobStores
  * It also handles inlining binaries if there size is smaller than
@@ -124,6 +125,7 @@ public class DataStoreBlobStore implemen
     public String writeBlob(InputStream stream) throws IOException {
         boolean threw = true;
         try {
+            checkNotNull(stream);
             String id = writeStream(stream).getIdentifier().toString();
             threw = false;
             return id;
@@ -156,6 +158,7 @@ public class DataStoreBlobStore implemen
     @Override
     public long getBlobLength(String blobId) throws IOException {
         try {
+            checkNotNull(blobId, "BlobId must be specified");
             return getDataRecord(blobId).getLength();
         } catch (DataStoreException e) {
             throw new IOException(e);
@@ -266,8 +269,8 @@ public class DataStoreBlobStore implemen
             id = InMemoryDataRecord.getInstance(blobId);
         }else{
             id = delegate.getRecord(new DataIdentifier(blobId));
-            Preconditions.checkNotNull(id, "No DataRecord found for blodId [%s]", blobId);
         }
+        checkNotNull(id, "No DataRecord found for blodId [%s]", blobId);
         return id;
     }
 

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/blob/ds/DataStoreUtils.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/blob/ds/DataStoreUtils.java?rev=1578738&r1=1578737&r2=1578738&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/blob/ds/DataStoreUtils.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/blob/ds/DataStoreUtils.java
Tue Mar 18 05:04:11 2014
@@ -47,21 +47,18 @@ public class DataStoreUtils extends Abst
     private static final String BS_PROP_PREFIX = "bs.";
 
     public static DataStoreBlobStore getBlobStore() throws Exception {
-        String className = System.getProperty(DS_CLASS_NAME);
-        if(className != null){
-            DataStore ds = Class.forName(className).asSubclass(DataStore.class).newInstance();
-            ds.init(getHomeDir());
-            PropertiesUtil.populate(ds, getConfig() , false);
-            return new DataStoreBlobStore(ds);
-        }
-        return null;
+        String className = System.getProperty(DS_CLASS_NAME, FileDataStore.class.getName());
+        DataStore ds = Class.forName(className).asSubclass(DataStore.class).newInstance();
+        PropertiesUtil.populate(ds, getConfig(), false);
+        ds.init(getHomeDir());
+        return new DataStoreBlobStore(ds);
     }
 
-    private static Map<String,?> getConfig(){
-        Map<String,Object> result = Maps.newHashMap();
-        for(Map.Entry<String,?> e : Maps.fromProperties(System.getProperties()).entrySet()){
+    private static Map<String, ?> getConfig() {
+        Map<String, Object> result = Maps.newHashMap();
+        for (Map.Entry<String, ?> e : Maps.fromProperties(System.getProperties()).entrySet())
{
             String key = e.getKey();
-            if(key.startsWith(DS_PROP_PREFIX) || key.startsWith(BS_PROP_PREFIX)){
+            if (key.startsWith(DS_PROP_PREFIX) || key.startsWith(BS_PROP_PREFIX)) {
                 key = key.substring(3); //length of bs.
                 result.put(key, e.getValue());
             }
@@ -70,7 +67,7 @@ public class DataStoreUtils extends Abst
     }
 
     private static String getHomeDir() {
-        return concat( new File(".").getAbsolutePath(), "target/blobstore/"+System.currentTimeMillis());
+        return concat(new File(".").getAbsolutePath(), "target/blobstore/" + System.currentTimeMillis());
     }
 
     @Test

Modified: jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/fixture/OakFixture.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/fixture/OakFixture.java?rev=1578738&r1=1578737&r2=1578738&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/fixture/OakFixture.java
(original)
+++ jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/fixture/OakFixture.java
Tue Mar 18 05:04:11 2014
@@ -149,8 +149,8 @@ public abstract class OakFixture {
                     String className = System.getProperty("dataStore");
                     if(className != null){
                         DataStore ds = Class.forName(className).asSubclass(DataStore.class).newInstance();
-                        ds.init(null);
                         PropertiesUtil.populate(ds, getConfig(), false);
+                        ds.init(null);
                         blobStore = new DataStoreBlobStore(ds);
                     }
                 } catch (Exception e) {



Mime
View raw message