jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject svn commit: r605880 - in /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core: NodeImpl.java SessionImpl.java
Date Thu, 20 Dec 2007 10:43:22 GMT
Author: stefan
Date: Thu Dec 20 02:43:22 2007
New Revision: 605880

URL: http://svn.apache.org/viewvc?rev=605880&view=rev
Log:
my last commit (r605622) accidentally reverted changes of previous commits (r604872, r605134)...
:(

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java?rev=605880&r1=605879&r2=605880&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java
Thu Dec 20 02:43:22 2007
@@ -2989,13 +2989,26 @@
         // check lock status
         checkLock();
 
-        Property prop = internalSetProperty(NameConstants.JCR_ISCHECKEDOUT, InternalValue.create(true));
-        prop.save();
-        prop = internalSetProperty(NameConstants.JCR_PREDECESSORS,
+        boolean hasPendingChanges = session.hasPendingChanges();
+
+        Property[] props = new Property[2];
+        props[0] = internalSetProperty(NameConstants.JCR_ISCHECKEDOUT, InternalValue.create(true));
+        props[1] = internalSetProperty(NameConstants.JCR_PREDECESSORS,
                 new InternalValue[]{
-                    InternalValue.create(new UUID(getBaseVersion().getUUID()))
+                        InternalValue.create(new UUID(getBaseVersion().getUUID()))
                 });
-        prop.save();
+        if (hasPendingChanges) {
+            for (int i = 0; i < props.length; i++) {
+                props[i].save();
+            }
+        } else {
+            try {
+                session.save();
+            } catch (RepositoryException e) {
+                session.refresh(false);
+                throw e;
+            }
+        }
     }
 
     /**

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java?rev=605880&r1=605879&r2=605880&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java
Thu Dec 20 02:43:22 2007
@@ -19,22 +19,28 @@
 import org.apache.commons.collections.IteratorUtils;
 import org.apache.commons.collections.map.ReferenceMap;
 import org.apache.jackrabbit.commons.AbstractSession;
+import org.apache.jackrabbit.core.RepositoryImpl.WorkspaceInfo;
 import org.apache.jackrabbit.core.config.AccessManagerConfig;
 import org.apache.jackrabbit.core.config.WorkspaceConfig;
+import org.apache.jackrabbit.core.data.GarbageCollector;
 import org.apache.jackrabbit.core.lock.LockManager;
 import org.apache.jackrabbit.core.nodetype.NodeDefinitionImpl;
 import org.apache.jackrabbit.core.nodetype.NodeTypeImpl;
 import org.apache.jackrabbit.core.nodetype.NodeTypeManagerImpl;
+import org.apache.jackrabbit.core.persistence.IterablePersistenceManager;
+import org.apache.jackrabbit.core.persistence.PersistenceManager;
 import org.apache.jackrabbit.core.security.AMContext;
 import org.apache.jackrabbit.core.security.AccessManager;
 import org.apache.jackrabbit.core.security.AuthContext;
 import org.apache.jackrabbit.core.security.SecurityConstants;
+import org.apache.jackrabbit.core.state.ItemStateException;
 import org.apache.jackrabbit.core.state.LocalItemStateManager;
 import org.apache.jackrabbit.core.state.NodeState;
 import org.apache.jackrabbit.core.state.SessionItemStateManager;
 import org.apache.jackrabbit.core.state.SharedItemStateManager;
 import org.apache.jackrabbit.core.util.Dumpable;
 import org.apache.jackrabbit.core.version.VersionManager;
+import org.apache.jackrabbit.core.version.VersionManagerImpl;
 import org.apache.jackrabbit.core.xml.DocViewSAXEventGenerator;
 import org.apache.jackrabbit.core.xml.ImportHandler;
 import org.apache.jackrabbit.core.xml.SessionImporter;
@@ -587,6 +593,39 @@
      */
     public void removeListener(SessionListener listener) {
         listeners.remove(listener);
+    }
+
+    /**
+     * Create a data store garbage collector for this repository.
+     *
+     * @throws ItemStateException
+     * @throws RepositoryException
+     */
+    public GarbageCollector createDataStoreGarbageCollector() throws RepositoryException,
ItemStateException {
+        ArrayList pmList = new ArrayList();
+        VersionManagerImpl vm = (VersionManagerImpl)rep.getVersionManager();
+        PersistenceManager pm = vm.getPersistenceManager();
+        pmList.add(pm);
+        String[] wspNames = rep.getWorkspaceNames();
+        SystemSession[] sysSessions = new SystemSession[wspNames.length];
+        for (int i = 0; i < wspNames.length; i++) {
+            String wspName = wspNames[i];
+            WorkspaceInfo wspInfo = rep.getWorkspaceInfo(wspName);
+            sysSessions[i] = rep.getSystemSession(wspName);
+            pm = wspInfo.getPersistenceManager();
+            pmList.add(pm);
+        }
+        IterablePersistenceManager[] ipmList = new IterablePersistenceManager[pmList.size()];
+        for (int i = 0; i < pmList.size(); i++) {
+            pm = (PersistenceManager) pmList.get(i);
+            if (!(pm instanceof IterablePersistenceManager)) {
+                ipmList = null;
+                break;
+            }
+            ipmList[i] = (IterablePersistenceManager) pm;
+        }
+        GarbageCollector gc = new GarbageCollector(this, ipmList, sysSessions);
+        return gc;
     }
 
     //--------------------------------------------------------< NameResolver >



Mime
View raw message