jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r395386 - /jackrabbit/trunk/contrib/bdb-persistence/src/java/org/apache/jackrabbit/core/state/bdb/BerkeleyDBPersistenceManager.java
Date Wed, 19 Apr 2006 20:21:31 GMT
Author: jukka
Date: Wed Apr 19 13:21:29 2006
New Revision: 395386

URL: http://svn.apache.org/viewcvs?rev=395386&view=rev
Log:
JCR-298: Remove blobs when property state is removed. Fix contributed by Alexandru Popescu.

Modified:
    jackrabbit/trunk/contrib/bdb-persistence/src/java/org/apache/jackrabbit/core/state/bdb/BerkeleyDBPersistenceManager.java

Modified: jackrabbit/trunk/contrib/bdb-persistence/src/java/org/apache/jackrabbit/core/state/bdb/BerkeleyDBPersistenceManager.java
URL: http://svn.apache.org/viewcvs/jackrabbit/trunk/contrib/bdb-persistence/src/java/org/apache/jackrabbit/core/state/bdb/BerkeleyDBPersistenceManager.java?rev=395386&r1=395385&r2=395386&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/bdb-persistence/src/java/org/apache/jackrabbit/core/state/bdb/BerkeleyDBPersistenceManager.java
(original)
+++ jackrabbit/trunk/contrib/bdb-persistence/src/java/org/apache/jackrabbit/core/state/bdb/BerkeleyDBPersistenceManager.java
Wed Apr 19 13:21:29 2006
@@ -15,6 +15,8 @@
  */
 package org.apache.jackrabbit.core.state.bdb;
 
+import javax.jcr.PropertyType;
+
 import com.sleepycat.je.Database;
 import com.sleepycat.je.DatabaseConfig;
 import com.sleepycat.je.DatabaseEntry;
@@ -40,6 +42,8 @@
 import org.apache.jackrabbit.core.state.PropertyState;
 import org.apache.jackrabbit.core.state.util.BLOBStore;
 import org.apache.jackrabbit.core.state.util.FileSystemBLOBStore;
+import org.apache.jackrabbit.core.value.InternalValue;
+import org.apache.jackrabbit.core.value.BLOBFileValue;
 
 import java.io.File;
 
@@ -318,6 +322,27 @@
             if (!operationStatus.equals(OperationStatus.SUCCESS)) {
                 throw new ItemStateException(operationStatus.toString());
             }
+
+            InternalValue[] values = state.getValues();
+            if (values != null) {
+                for (int i = 0; i < values.length; i++) {
+                    InternalValue val = values[i];
+                    if (val != null) {
+                        if (val.getType() == PropertyType.BINARY) {
+                            BLOBFileValue blobVal = (BLOBFileValue) val.internalValue();
+                            // delete internal resource representation of BLOB value
+                            blobVal.delete(true);
+                            // also remove from BLOBStore
+                            String blobId = blobStore.createId((PropertyId) state.getId(),
i);
+                            try {
+                                blobStore.remove(blobId);
+                            } catch (Exception e) {
+                                log.warn("failed to remove from BLOBStore: " + blobId, e);
+                            }
+                        }
+                    }
+                }
+            } 
         } catch (Exception e) {
             log.error(e);
             throw new ItemStateException(e.getMessage(), e);



Mime
View raw message