jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r389544 - in /jackrabbit/branches/1.0/jackrabbit/src: main/java/org/apache/jackrabbit/core/ main/java/org/apache/jackrabbit/core/nodetype/virtual/ main/java/org/apache/jackrabbit/core/observation/ main/java/org/apache/jackrabbit/core/query/...
Date Tue, 28 Mar 2006 17:06:38 GMT
Author: jukka
Date: Tue Mar 28 09:06:35 2006
New Revision: 389544

URL: http://svn.apache.org/viewcvs?rev=389544&view=rev
Log:
1.0: Merged revisions 388123 and 38859: JCR-257 Use separate index for jcr:system tree

Added:
    jackrabbit/branches/1.0/jackrabbit/src/test/java/org/apache/jackrabbit/core/observation/VersionEventsTest.java
      - copied unchanged from r388559, jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/core/observation/VersionEventsTest.java
    jackrabbit/branches/1.0/jackrabbit/src/test/java/org/apache/jackrabbit/core/query/VersionStoreQueryTest.java
      - copied unchanged from r388559, jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/core/query/VersionStoreQueryTest.java
Removed:
    jackrabbit/branches/1.0/jackrabbit/src/main/java/org/apache/jackrabbit/core/SystemSearchManager.java
Modified:
    jackrabbit/branches/1.0/jackrabbit/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
    jackrabbit/branches/1.0/jackrabbit/src/main/java/org/apache/jackrabbit/core/XASessionImpl.java
    jackrabbit/branches/1.0/jackrabbit/src/main/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateManager.java
    jackrabbit/branches/1.0/jackrabbit/src/main/java/org/apache/jackrabbit/core/observation/DelegatingObservationDispatcher.java
    jackrabbit/branches/1.0/jackrabbit/src/main/java/org/apache/jackrabbit/core/observation/EventStateCollection.java
    jackrabbit/branches/1.0/jackrabbit/src/main/java/org/apache/jackrabbit/core/observation/ObservationManagerImpl.java
    jackrabbit/branches/1.0/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/lucene/MultiIndex.java
    jackrabbit/branches/1.0/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/lucene/SearchIndex.java
    jackrabbit/branches/1.0/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java
    jackrabbit/branches/1.0/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/XAVersionManager.java
    jackrabbit/branches/1.0/jackrabbit/src/test/java/org/apache/jackrabbit/core/observation/TestAll.java
    jackrabbit/branches/1.0/jackrabbit/src/test/java/org/apache/jackrabbit/core/query/TestAll.java

Modified: jackrabbit/branches/1.0/jackrabbit/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
URL: http://svn.apache.org/viewcvs/jackrabbit/branches/1.0/jackrabbit/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java?rev=389544&r1=389543&r2=389544&view=diff
==============================================================================
--- jackrabbit/branches/1.0/jackrabbit/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
(original)
+++ jackrabbit/branches/1.0/jackrabbit/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
Tue Mar 28 09:06:35 2006
@@ -250,6 +250,9 @@
             throw e;
         }
 
+        // initialize system search manager
+        getSystemSearchManager(wspName);
+
         // amount of time in seconds before an idle workspace is automatically
         // shut down
         int maxIdleTime = repConfig.getWorkspaceMaxIdleTime();
@@ -556,8 +559,9 @@
             try {
                 if (repConfig.getSearchConfig() != null) {
                     SystemSession defSysSession = getSystemSession(wspName);
-                    systemSearchMgr = new SystemSearchManager(repConfig.getSearchConfig(),
-                            nsReg, ntReg, defSysSession.getItemStateManager(), SYSTEM_ROOT_NODE_ID);
+                    systemSearchMgr = new SearchManager(repConfig.getSearchConfig(),
+                            nsReg, ntReg, defSysSession.getItemStateManager(),
+                            SYSTEM_ROOT_NODE_ID, null, null);
                     ObservationManager obsMgr = defSysSession.getWorkspace().getObservationManager();
                     obsMgr.addEventListener(systemSearchMgr, Event.NODE_ADDED |
                             Event.NODE_REMOVED | Event.PROPERTY_ADDED |

Modified: jackrabbit/branches/1.0/jackrabbit/src/main/java/org/apache/jackrabbit/core/XASessionImpl.java
URL: http://svn.apache.org/viewcvs/jackrabbit/branches/1.0/jackrabbit/src/main/java/org/apache/jackrabbit/core/XASessionImpl.java?rev=389544&r1=389543&r2=389544&view=diff
==============================================================================
--- jackrabbit/branches/1.0/jackrabbit/src/main/java/org/apache/jackrabbit/core/XASessionImpl.java
(original)
+++ jackrabbit/branches/1.0/jackrabbit/src/main/java/org/apache/jackrabbit/core/XASessionImpl.java
Tue Mar 28 09:06:35 2006
@@ -149,7 +149,7 @@
             throws RepositoryException {
 
         VersionManagerImpl vMgr = (VersionManagerImpl) rep.getVersionManager();
-        return new XAVersionManager(vMgr, rep.getNodeTypeRegistry(), wsp);
+        return new XAVersionManager(vMgr, rep.getNodeTypeRegistry(), this);
     }
 
     /**

Modified: jackrabbit/branches/1.0/jackrabbit/src/main/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateManager.java
URL: http://svn.apache.org/viewcvs/jackrabbit/branches/1.0/jackrabbit/src/main/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateManager.java?rev=389544&r1=389543&r2=389544&view=diff
==============================================================================
--- jackrabbit/branches/1.0/jackrabbit/src/main/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateManager.java
(original)
+++ jackrabbit/branches/1.0/jackrabbit/src/main/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateManager.java
Tue Mar 28 09:06:35 2006
@@ -26,6 +26,8 @@
 import org.apache.jackrabbit.core.observation.EventState;
 import org.apache.jackrabbit.core.virtual.VirtualItemStateProvider;
 import org.apache.jackrabbit.name.QName;
+import org.apache.jackrabbit.name.Path;
+import org.apache.jackrabbit.name.MalformedPathException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -47,6 +49,23 @@
      */
     private static Logger log = LoggerFactory.getLogger(VirtualNodeTypeStateManager.class);
 
+    /**
+     * Path: /jcr:system/jcr:nodeTypes
+     */
+    private static final Path NODE_TYPES_PATH;
+
+    static {
+        try {
+            Path.PathBuilder builder = new Path.PathBuilder();
+            builder.addRoot();
+            builder.addLast(QName.JCR_SYSTEM);
+            builder.addLast(QName.JCR_NODETYPES);
+            NODE_TYPES_PATH = builder.getPath();
+        } catch (MalformedPathException e) {
+            // will not happen. path is always valid
+            throw new InternalError("Cannot initialize path");
+        }
+    }
 
     /**
      * an item state provider for the virtual nodetype states
@@ -133,7 +152,7 @@
                 NodeImpl child = root.getNode(ntName);
                 List events = new ArrayList();
                 recursiveAdd(events, root, child);
-                obsDispatcher.dispatch(events, systemSession);
+                obsDispatcher.dispatch(events, systemSession, NODE_TYPES_PATH);
             }
         } catch (RepositoryException e) {
             log.error("Unable to index new nodetype: " + e.toString());
@@ -160,7 +179,7 @@
                 NodeImpl child = root.getNode(ntName);
                 List events = new ArrayList();
                 recursiveRemove(events, root, child);
-                obsDispatcher.dispatch(events, systemSession);
+                obsDispatcher.dispatch(events, systemSession, NODE_TYPES_PATH);
             }
             if (virtProvider != null) {
                 // allow provider to update

Modified: jackrabbit/branches/1.0/jackrabbit/src/main/java/org/apache/jackrabbit/core/observation/DelegatingObservationDispatcher.java
URL: http://svn.apache.org/viewcvs/jackrabbit/branches/1.0/jackrabbit/src/main/java/org/apache/jackrabbit/core/observation/DelegatingObservationDispatcher.java?rev=389544&r1=389543&r2=389544&view=diff
==============================================================================
--- jackrabbit/branches/1.0/jackrabbit/src/main/java/org/apache/jackrabbit/core/observation/DelegatingObservationDispatcher.java
(original)
+++ jackrabbit/branches/1.0/jackrabbit/src/main/java/org/apache/jackrabbit/core/observation/DelegatingObservationDispatcher.java
Tue Mar 28 09:06:35 2006
@@ -17,6 +17,7 @@
 
 import org.apache.jackrabbit.core.SessionImpl;
 import org.apache.jackrabbit.core.state.ChangeLog;
+import org.apache.jackrabbit.name.Path;
 
 import java.util.HashSet;
 import java.util.Iterator;
@@ -58,8 +59,9 @@
      * @param session event source
      * @return new <code>EventStateCollection</code> instance
      */
-    public EventStateCollection createEventStateCollection(SessionImpl session) {
-        return new EventStateCollection(this, session);
+    public EventStateCollection createEventStateCollection(SessionImpl session,
+                                                           Path pathPrefix) {
+        return new EventStateCollection(this, session, pathPrefix);
     }
 
     //------------------------------------------------------< EventDispatcher >
@@ -82,7 +84,7 @@
      * {@inheritDoc}
      */
     void dispatchEvents(EventStateCollection events) {
-        dispatch(events.getEvents(), events.getSession());
+        dispatch(events.getEvents(), events.getSession(), events.getPathPrefix());
     }
 
     /**
@@ -93,11 +95,11 @@
      * @param eventList
      * @param session
      */
-    public void dispatch(List eventList, SessionImpl session) {
+    public void dispatch(List eventList, SessionImpl session, Path pathPrefix) {
         Iterator iter = dispatchers.iterator();
         while (iter.hasNext()) {
             ObservationManagerFactory fac = (ObservationManagerFactory) iter.next();
-            EventStateCollection events = new EventStateCollection(fac, session);
+            EventStateCollection events = new EventStateCollection(fac, session, pathPrefix);
             events.addAll(eventList);
             events.prepare();
             events.dispatch();

Modified: jackrabbit/branches/1.0/jackrabbit/src/main/java/org/apache/jackrabbit/core/observation/EventStateCollection.java
URL: http://svn.apache.org/viewcvs/jackrabbit/branches/1.0/jackrabbit/src/main/java/org/apache/jackrabbit/core/observation/EventStateCollection.java?rev=389544&r1=389543&r2=389544&view=diff
==============================================================================
--- jackrabbit/branches/1.0/jackrabbit/src/main/java/org/apache/jackrabbit/core/observation/EventStateCollection.java
(original)
+++ jackrabbit/branches/1.0/jackrabbit/src/main/java/org/apache/jackrabbit/core/observation/EventStateCollection.java
Tue Mar 28 09:06:35 2006
@@ -81,15 +81,30 @@
     private final SessionImpl session;
 
     /**
+     * The prefix to use for the event paths or <code>null</code> if no prefix
+     * should be used.
+     */
+    private final Path pathPrefix;
+
+    /**
      * Creates a new empty <code>EventStateCollection</code>.
+     * <p/>
+     * Because the item state manager in {@link #createEventStates} may represent
+     * only a subset of the over all item state hierarchy, this constructor
+     * also takes a path prefix argument. If non <code>null</code> all events
+     * created by this collection are prefixed with this path.
      *
      * @param dispatcher event dispatcher
-     * @param session the session that created these events.
+     * @param session    the session that created these events.
+     * @param pathPrefix the path to prefix the event paths or <code>null</code>
+     *                   if no prefix should be used.
      */
     EventStateCollection(EventDispatcher dispatcher,
-                         SessionImpl session) {
+                         SessionImpl session,
+                         Path pathPrefix) {
         this.dispatcher = dispatcher;
         this.session = session;
+        this.pathPrefix = pathPrefix;
     }
 
     /**
@@ -98,17 +113,17 @@
      *
      * @param rootNodeId   the id of the root node.
      * @param changes      the changes on <code>ItemState</code>s.
-     * @param provider     an <code>ItemStateProvider</code> to provide <code>ItemState</code>
+     * @param stateMgr     an <code>ItemStateManager</code> to provide <code>ItemState</code>
      *                     of items that are not contained in the <code>changes</code>
collection.
      * @throws ItemStateException if an error occurs while creating events
      *                            states for the item state changes.
      */
-    public void createEventStates(NodeId rootNodeId, ChangeLog changes, ItemStateManager
provider) throws ItemStateException {
+    public void createEventStates(NodeId rootNodeId, ChangeLog changes, ItemStateManager
stateMgr) throws ItemStateException {
         // create a hierarchy manager, that is based on the ChangeLog and
         // the ItemStateProvider
         // todo use CachingHierarchyManager ?
         ChangeLogBasedHierarchyMgr hmgr =
-                new ChangeLogBasedHierarchyMgr(rootNodeId, provider, changes,
+                new ChangeLogBasedHierarchyMgr(rootNodeId, stateMgr, changes,
                         session.getNamespaceResolver());
 
         /**
@@ -158,7 +173,7 @@
                         } catch (NoSuchItemStateException e) {
                             // old parent has been deleted, retrieve from
                             // shared item state manager
-                            oldParent = (NodeState) provider.getItemState(oldParentId);
+                            oldParent = (NodeState) stateMgr.getItemState(oldParentId);
                         }
 
                         NodeTypeImpl oldParentNodeType = getNodeType(oldParent, session);
@@ -291,7 +306,7 @@
             } else {
                 // property changed
                 Path path = getPath(state.getId(), hmgr);
-                NodeState parent = (NodeState) provider.getItemState(state.getParentId());
+                NodeState parent = (NodeState) stateMgr.getItemState(state.getParentId());
                 NodeTypeImpl nodeType = getNodeType(parent, session);
                 Set mixins = parent.getMixinTypeNames();
                 events.add(EventState.propertyChanged(state.getParentId(),
@@ -310,7 +325,7 @@
             if (state.isNode()) {
                 // node deleted
                 NodeState n = (NodeState) state;
-                NodeState parent = (NodeState) provider.getItemState(n.getParentId());
+                NodeState parent = (NodeState) stateMgr.getItemState(n.getParentId());
                 NodeTypeImpl nodeType = getNodeType(parent, session);
                 Set mixins = parent.getMixinTypeNames();
                 Path path = getZombiePath(state.getId(), hmgr);
@@ -352,8 +367,8 @@
                 NodeId parentId = n.getParentId();
                 NodeState parent;
                 // unknown if parent node is also new
-                if (provider.hasItemState(parentId)) {
-                    parent = (NodeState) provider.getItemState(parentId);
+                if (stateMgr.hasItemState(parentId)) {
+                    parent = (NodeState) stateMgr.getItemState(parentId);
                 } else {
                     parent = (NodeState) changes.get(parentId);
                 }
@@ -416,6 +431,17 @@
     }
 
     /**
+     * Returns the path prefix for this event state collection or <code>null</code>
+     * if no path prefix was set in the constructor of this collection. See
+     * also {@link EventStateCollection#EventStateCollection}.
+     *
+     * @return the path prefix for this event state collection.
+     */
+    public Path getPathPrefix() {
+        return pathPrefix;
+    }
+
+    /**
      * Returns an iterator over {@link EventState} instance.
      *
      * @return an iterator over {@link EventState} instance.
@@ -491,7 +517,7 @@
     private Path getPath(ItemId itemId, HierarchyManager hmgr)
             throws ItemStateException {
         try {
-            return hmgr.getPath(itemId);
+            return prefixPath(hmgr.getPath(itemId));
         } catch (RepositoryException e) {
             // should never happen actually
             String msg = "Unable to resolve path for item: " + itemId;
@@ -511,12 +537,39 @@
     private Path getZombiePath(ItemId itemId, ChangeLogBasedHierarchyMgr hmgr)
             throws ItemStateException {
         try {
-            return hmgr.getZombiePath(itemId);
+            return prefixPath(hmgr.getZombiePath(itemId));
         } catch (RepositoryException e) {
             // should never happen actually
             String msg = "Unable to resolve zombie path for item: " + itemId;
             log.error(msg);
             throw new ItemStateException(msg, e);
+        }
+    }
+
+    /**
+     * Prefixes the Path <code>p</code> with {@link #pathPrefix}.
+     *
+     * @param p the Path to prefix.
+     * @return the prefixed path or <code>p</code> itself if {@link #pathPrefix}
+     *         is <code>null</code>.
+     * @throws RepositoryException if the path cannot be prefixed.
+     */
+    private Path prefixPath(Path p) throws RepositoryException {
+        if (pathPrefix == null) {
+            return p;
+        }
+        Path.PathBuilder builder = new Path.PathBuilder(pathPrefix.getElements());
+        Path.PathElement[] elements = p.getElements();
+        for (int i = 0; i < elements.length; i++) {
+            if (elements[i].denotesRoot()) {
+                continue;
+            }
+            builder.addLast(elements[i]);
+        }
+        try {
+            return builder.getPath();
+        } catch (MalformedPathException e) {
+            throw new RepositoryException(e);
         }
     }
 }

Modified: jackrabbit/branches/1.0/jackrabbit/src/main/java/org/apache/jackrabbit/core/observation/ObservationManagerImpl.java
URL: http://svn.apache.org/viewcvs/jackrabbit/branches/1.0/jackrabbit/src/main/java/org/apache/jackrabbit/core/observation/ObservationManagerImpl.java?rev=389544&r1=389543&r2=389544&view=diff
==============================================================================
--- jackrabbit/branches/1.0/jackrabbit/src/main/java/org/apache/jackrabbit/core/observation/ObservationManagerImpl.java
(original)
+++ jackrabbit/branches/1.0/jackrabbit/src/main/java/org/apache/jackrabbit/core/observation/ObservationManagerImpl.java
Tue Mar 28 09:06:35 2006
@@ -187,6 +187,6 @@
      * which is attached to this <code>ObservationManager</code> instance.
      */
     public EventStateCollection createEventStateCollection() {
-        return new EventStateCollection(obsMgrFactory, session);
+        return new EventStateCollection(obsMgrFactory, session, null);
     }
 }

Modified: jackrabbit/branches/1.0/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/lucene/MultiIndex.java
URL: http://svn.apache.org/viewcvs/jackrabbit/branches/1.0/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/lucene/MultiIndex.java?rev=389544&r1=389543&r2=389544&view=diff
==============================================================================
--- jackrabbit/branches/1.0/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/lucene/MultiIndex.java
(original)
+++ jackrabbit/branches/1.0/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/lucene/MultiIndex.java
Tue Mar 28 09:06:35 2006
@@ -77,11 +77,6 @@
     private static final Logger log = LoggerFactory.getLogger(MultiIndex.class);
 
     /**
-     * Name of the file to persist search internal namespace mappings
-     */
-    private static final String NS_MAPPING_FILE = "ns_mappings.properties";
-
-    /**
      * Default name of the redo log file
      */
     private static final String REDO_LOG = "redo.log";
@@ -201,19 +196,22 @@
      * @param rootId id of the root node
      * @param excludedIDs   Set&lt;NodeId> that contains uuids that should not
      *                      be indexed nor further traversed.
+     * @param mapping the namespace mapping to use
      * @throws IOException if an error occurs
      */
     MultiIndex(File indexDir,
                SearchIndex handler,
                ItemStateManager stateMgr,
                NodeId rootId,
-               Set excludedIDs) throws IOException {
+               Set excludedIDs,
+               NamespaceMappings mapping) throws IOException {
 
         this.indexDir = indexDir;
         this.handler = handler;
         this.cache = new DocNumberCache(handler.getCacheSize());
         this.redoLog = new RedoLog(new File(indexDir, REDO_LOG));
         this.excludedIDs = new HashSet(excludedIDs);
+        this.nsMappings = mapping;
 
         if (indexNames.exists(indexDir)) {
             indexNames.read(indexDir);
@@ -224,10 +222,6 @@
 
         // try to remove deletable files if there are any
         attemptDelete();
-
-        // read namespace mappings
-        File mapFile = new File(indexDir, NS_MAPPING_FILE);
-        nsMappings = new NamespaceMappings(mapFile);
 
         // initialize IndexMerger
         merger = new IndexMerger(this);

Modified: jackrabbit/branches/1.0/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/lucene/SearchIndex.java
URL: http://svn.apache.org/viewcvs/jackrabbit/branches/1.0/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/lucene/SearchIndex.java?rev=389544&r1=389543&r2=389544&view=diff
==============================================================================
--- jackrabbit/branches/1.0/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/lucene/SearchIndex.java
(original)
+++ jackrabbit/branches/1.0/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/lucene/SearchIndex.java
Tue Mar 28 09:06:35 2006
@@ -65,6 +65,11 @@
     private static final Logger log = LoggerFactory.getLogger(SearchIndex.class);
 
     /**
+     * Name of the file to persist search internal namespace mappings
+     */
+    private static final String NS_MAPPING_FILE = "ns_mappings.properties";
+
+    /**
      * The default value for property {@link #minMergeDocs}.
      */
     public static final int DEFAULT_MIN_MERGE_DOCS = 100;
@@ -197,8 +202,21 @@
             excludedIDs.add(context.getExcludedNodeId());
         }
 
-        index = new MultiIndex(new File(path), this,
-                context.getItemStateManager(), context.getRootId(), excludedIDs);
+        File indexDir = new File(path);
+
+        NamespaceMappings nsMappings;
+        if (context.getParentHandler() instanceof SearchIndex) {
+            // use system namespace mappings
+            SearchIndex sysIndex = (SearchIndex) context.getParentHandler();
+            nsMappings = sysIndex.getNamespaceMappings();
+        } else {
+            // read local namespace mappings
+            File mapFile = new File(indexDir, NS_MAPPING_FILE);
+             nsMappings = new NamespaceMappings(mapFile);
+        }
+
+        index = new MultiIndex(indexDir, this, context.getItemStateManager(),
+                context.getRootId(), excludedIDs, nsMappings);
         if (index.getRedoLogApplied() || forceConsistencyCheck) {
             log.info("Running consistency check...");
             try {

Modified: jackrabbit/branches/1.0/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java
URL: http://svn.apache.org/viewcvs/jackrabbit/branches/1.0/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java?rev=389544&r1=389543&r2=389544&view=diff
==============================================================================
--- jackrabbit/branches/1.0/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java
(original)
+++ jackrabbit/branches/1.0/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java
Tue Mar 28 09:06:35 2006
@@ -36,6 +36,8 @@
 import org.apache.jackrabbit.core.value.InternalValue;
 import org.apache.jackrabbit.core.virtual.VirtualItemStateProvider;
 import org.apache.jackrabbit.name.QName;
+import org.apache.jackrabbit.name.Path;
+import org.apache.jackrabbit.name.MalformedPathException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -64,6 +66,24 @@
     private static Logger log = LoggerFactory.getLogger(VersionManager.class);
 
     /**
+     * The path to the version storage: /jcr:system/jcr:versionStorage
+     */
+    private static final Path VERSION_STORAGE_PATH;
+
+    static {
+        try {
+            Path.PathBuilder builder = new Path.PathBuilder();
+            builder.addRoot();
+            builder.addLast(QName.JCR_SYSTEM);
+            builder.addLast(QName.JCR_VERSIONSTORAGE);
+            VERSION_STORAGE_PATH = builder.getPath();
+        } catch (MalformedPathException e) {
+            // will not happen. path is always valid
+            throw new InternalError("Cannot initialize path");
+        }
+    }
+
+    /**
      * The persistence manager for the versions
      */
     private final PersistenceManager pMgr;
@@ -444,7 +464,16 @@
         if (eventSource == null) {
             throw new RepositoryException("Unknown event source.");
         }
-        return obsMgr.createEventStateCollection(eventSource);
+        return createEventStateCollection(eventSource);
+    }
+
+    /**
+     * Creates an {@link EventStateCollection} using the given <code>source</code>.
+     * @param source the Session that did the changes.
+     * @return <code>EventStateCollection</code>.
+     */
+    EventStateCollection createEventStateCollection(SessionImpl source) {
+        return obsMgr.createEventStateCollection(source, VERSION_STORAGE_PATH);
     }
 
     //--------------------------------------------------------< inner classes >

Modified: jackrabbit/branches/1.0/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/XAVersionManager.java
URL: http://svn.apache.org/viewcvs/jackrabbit/branches/1.0/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/XAVersionManager.java?rev=389544&r1=389543&r2=389544&view=diff
==============================================================================
--- jackrabbit/branches/1.0/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/XAVersionManager.java
(original)
+++ jackrabbit/branches/1.0/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/XAVersionManager.java
Tue Mar 28 09:06:35 2006
@@ -24,6 +24,7 @@
 import org.apache.jackrabbit.core.TransactionException;
 import org.apache.jackrabbit.core.nodetype.NodeTypeRegistry;
 import org.apache.jackrabbit.core.observation.EventStateCollectionFactory;
+import org.apache.jackrabbit.core.observation.EventStateCollection;
 import org.apache.jackrabbit.core.state.ChangeLog;
 import org.apache.jackrabbit.core.state.ItemState;
 import org.apache.jackrabbit.core.state.ItemStateException;
@@ -52,7 +53,7 @@
  * manager.
  */
 public class XAVersionManager extends AbstractVersionManager
-        implements VirtualItemStateProvider, InternalXAResource {
+        implements EventStateCollectionFactory, VirtualItemStateProvider, InternalXAResource
{
 
     /**
      * Attribute name for associated change log.
@@ -75,6 +76,11 @@
     private NodeTypeRegistry ntReg;
 
     /**
+     * The session that uses this version manager.
+     */
+    private SessionImpl session;
+
+    /**
      * Items that have been modified and are part of the XA environment.
      */
     private Map xaItems;
@@ -83,13 +89,14 @@
      * Creates a new instance of this class.
      */
     public XAVersionManager(VersionManagerImpl vMgr, NodeTypeRegistry ntReg,
-                            EventStateCollectionFactory factory)
+                            SessionImpl session)
             throws RepositoryException {
 
         this.vMgr = vMgr;
         this.ntReg = ntReg;
+        this.session = session;
         this.stateMgr = new XAItemStateManager(vMgr.getSharedStateMgr(),
-                factory, CHANGE_LOG_ATTRIBUTE_NAME);
+                this, CHANGE_LOG_ATTRIBUTE_NAME);
 
         NodeState state;
         try {
@@ -98,6 +105,16 @@
             throw new RepositoryException("Unable to retrieve history root", e);
         }
         this.historyRoot = new NodeStateEx(stateMgr, ntReg, state, QName.JCR_VERSIONSTORAGE);
+    }
+
+    //------------------------------------------< EventStateCollectionFactory >
+
+    /**
+     * @inheritDoc
+     */
+    public EventStateCollection createEventStateCollection()
+            throws RepositoryException {
+        return vMgr.createEventStateCollection(session);
     }
 
     //-------------------------------------------------------< VersionManager >

Modified: jackrabbit/branches/1.0/jackrabbit/src/test/java/org/apache/jackrabbit/core/observation/TestAll.java
URL: http://svn.apache.org/viewcvs/jackrabbit/branches/1.0/jackrabbit/src/test/java/org/apache/jackrabbit/core/observation/TestAll.java?rev=389544&r1=389543&r2=389544&view=diff
==============================================================================
--- jackrabbit/branches/1.0/jackrabbit/src/test/java/org/apache/jackrabbit/core/observation/TestAll.java
(original)
+++ jackrabbit/branches/1.0/jackrabbit/src/test/java/org/apache/jackrabbit/core/observation/TestAll.java
Tue Mar 28 09:06:35 2006
@@ -37,6 +37,7 @@
 
         suite.addTestSuite(ReorderTest.class);
         suite.addTestSuite(MixinTest.class);
+        suite.addTestSuite(VersionEventsTest.class);
 
         return suite;
     }

Modified: jackrabbit/branches/1.0/jackrabbit/src/test/java/org/apache/jackrabbit/core/query/TestAll.java
URL: http://svn.apache.org/viewcvs/jackrabbit/branches/1.0/jackrabbit/src/test/java/org/apache/jackrabbit/core/query/TestAll.java?rev=389544&r1=389543&r2=389544&view=diff
==============================================================================
--- jackrabbit/branches/1.0/jackrabbit/src/test/java/org/apache/jackrabbit/core/query/TestAll.java
(original)
+++ jackrabbit/branches/1.0/jackrabbit/src/test/java/org/apache/jackrabbit/core/query/TestAll.java
Tue Mar 28 09:06:35 2006
@@ -42,6 +42,7 @@
         suite.addTestSuite(XPathAxisTest.class);
         suite.addTestSuite(SkipDeletedNodesTest.class);
         suite.addTestSuite(MixinTest.class);
+        suite.addTestSuite(VersionStoreQueryTest.class);
 
         // exclude long running tests per default
         //suite.addTestSuite(MassiveRangeTest.class);



Mime
View raw message