jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chet...@apache.org
Subject svn commit: r1581718 - in /jackrabbit/oak/trunk: oak-blob/src/main/java/org/apache/jackrabbit/oak/spi/blob/ oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/datastore/ oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo...
Date Wed, 26 Mar 2014 07:56:19 GMT
Author: chetanm
Date: Wed Mar 26 07:56:19 2014
New Revision: 1581718

URL: http://svn.apache.org/r1581718
Log:
OAK-1604 - Support for signed references in Blob

- Update BlobStore interface with reference mgmt related methods
  - getReference(blobId)
  - getBlobId(reference)
- DataStoreBlobStore delegate the calls to DataStore specific impl
- Default impl return null

Modified:
    jackrabbit/oak/trunk/oak-blob/src/main/java/org/apache/jackrabbit/oak/spi/blob/AbstractBlobStore.java
    jackrabbit/oak/trunk/oak-blob/src/main/java/org/apache/jackrabbit/oak/spi/blob/BlobStore.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/datastore/DataStoreBlobStore.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/gridfs/MongoGridFSBlobStore.java

Modified: jackrabbit/oak/trunk/oak-blob/src/main/java/org/apache/jackrabbit/oak/spi/blob/AbstractBlobStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-blob/src/main/java/org/apache/jackrabbit/oak/spi/blob/AbstractBlobStore.java?rev=1581718&r1=1581717&r2=1581718&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-blob/src/main/java/org/apache/jackrabbit/oak/spi/blob/AbstractBlobStore.java
(original)
+++ jackrabbit/oak/trunk/oak-blob/src/main/java/org/apache/jackrabbit/oak/spi/blob/AbstractBlobStore.java
Wed Mar 26 07:56:19 2014
@@ -163,6 +163,16 @@ public abstract class AbstractBlobStore 
         return new BlobStoreInputStream(this, blobId, 0);
     }
 
+    @Override
+    public String getReference(String blobId) {
+        return null;
+    }
+
+    @Override
+    public String getBlobId(String reference) {
+        return null;
+    }
+
     protected void usesBlobId(String blobId) {
         inUse.put(blobId, new WeakReference<String>(blobId));
     }

Modified: jackrabbit/oak/trunk/oak-blob/src/main/java/org/apache/jackrabbit/oak/spi/blob/BlobStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-blob/src/main/java/org/apache/jackrabbit/oak/spi/blob/BlobStore.java?rev=1581718&r1=1581717&r2=1581718&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-blob/src/main/java/org/apache/jackrabbit/oak/spi/blob/BlobStore.java
(original)
+++ jackrabbit/oak/trunk/oak-blob/src/main/java/org/apache/jackrabbit/oak/spi/blob/BlobStore.java
Wed Mar 26 07:56:19 2014
@@ -19,6 +19,8 @@ package org.apache.jackrabbit.oak.spi.bl
 import java.io.IOException;
 import java.io.InputStream;
 
+import javax.annotation.CheckForNull;
+
 /**
  * An interface to store and read large binary objects.
  */
@@ -65,4 +67,25 @@ public interface BlobStore {
      */
     InputStream getInputStream(String blobId) throws IOException;
 
+    /**
+     * Returns the blobId that referred by the given binary reference.
+     * Returns {@code null} if the reference is invalid, for example if it
+     * points to a blob that does not exist.
+     *
+     * @param reference binary reference
+     * @return matching blobId, or {@code null}
+     */
+    @CheckForNull
+    String getBlobId(String reference);
+
+    /**
+     * Returns a secure reference to blob referred by blobid, or {@code null} if no such
+     * reference is available.
+     *
+     * @param blobId blobId referring the blob for which reference is required
+     * @return binary reference, or {@code null}
+     */
+    @CheckForNull
+    String getReference(String blobId);
+
 }

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=1581718&r1=1581717&r2=1581718&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
Wed Mar 26 07:56:19 2014
@@ -43,6 +43,8 @@ import org.apache.jackrabbit.core.data.D
 import org.apache.jackrabbit.core.data.MultiDataStoreAware;
 import org.apache.jackrabbit.oak.spi.blob.BlobStore;
 import org.apache.jackrabbit.oak.spi.blob.GarbageCollectableBlobStore;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import static com.google.common.base.Preconditions.checkNotNull;
 
@@ -52,6 +54,8 @@ import static com.google.common.base.Pre
  * {@link org.apache.jackrabbit.core.data.DataStore#getMinRecordLength()}
  */
 public class DataStoreBlobStore implements DataStore, BlobStore, GarbageCollectableBlobStore
{
+    private final Logger log = LoggerFactory.getLogger(getClass());
+
     private final DataStore delegate;
 
     public DataStoreBlobStore(DataStore delegate) {
@@ -167,6 +171,36 @@ public class DataStoreBlobStore implemen
     }
 
     @Override
+    public String getBlobId(String reference) {
+        DataRecord record;
+        try {
+            record = delegate.getRecordFromReference(reference);
+            if (record != null) {
+                return record.getIdentifier().toString();
+            }
+        } catch (DataStoreException e) {
+            log.warn("Unable to access the blobId for  [{}]", reference, e);
+        }
+        return null;
+    }
+
+    @Override
+    public String getReference(String blobId) {
+        DataRecord record;
+        try {
+            record = delegate.getRecord(new DataIdentifier(blobId));
+            if(record != null){
+                return record.getReference();
+            }else{
+                log.debug("No blob found for id [{}]", blobId);
+            }
+        } catch (DataStoreException e) {
+            log.warn("Unable to access the blobId for  [{}]", blobId, e);
+        }
+        return  null;
+    }
+
+    @Override
     public InputStream getInputStream(String blobId) throws IOException {
         return getStream(blobId);
     }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/gridfs/MongoGridFSBlobStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/gridfs/MongoGridFSBlobStore.java?rev=1581718&r1=1581717&r2=1581718&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/gridfs/MongoGridFSBlobStore.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/gridfs/MongoGridFSBlobStore.java
Wed Mar 26 07:56:19 2014
@@ -56,6 +56,16 @@ public class MongoGridFSBlobStore implem
     }
 
     @Override
+    public String getBlobId(String reference) {
+        return null;
+    }
+
+    @Override
+    public String getReference(String blobId) {
+        return null;
+    }
+
+    @Override
     public int readBlob(String blobId, long blobOffset, byte[] buffer, int bufferOffset,
int length) throws IOException {
         Command<Integer> command = new ReadBlobCommandGridFS(gridFS, blobId, blobOffset,
                 buffer, bufferOffset, length);



Mime
View raw message