jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r478581 - in /jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi: ./ config/ lock/ operation/ version/
Date Thu, 23 Nov 2006 14:09:50 GMT
Author: angela
Date: Thu Nov 23 06:09:49 2006
New Revision: 478581

URL: http://svn.apache.org/viewvc?view=rev&rev=478581
Log:
work in progress

- RepositoryService.lock -> add return value
- Merge-Operation, VersionManager: merge returns failed-Ids
- LockManager: lock returns lockInfo
- javadoc, todos

Modified:
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemImpl.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemManagerImpl.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceImpl.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/config/RepositoryConfig.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/lock/LockManagerImpl.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/LockOperation.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Merge.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/DefaultVersionManager.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionManager.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionManagerImpl.java

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemImpl.java?view=diff&rev=478581&r1=478580&r2=478581
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemImpl.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemImpl.java
Thu Nov 23 06:09:49 2006
@@ -306,7 +306,9 @@
      * @param previousStatus
      */
     public void statusChanged(ItemState state, int previousStatus) {
-        // TODO: ev. assert that state is this.state?
+        if (state != this.state) {
+            throw new IllegalArgumentException("Invalid argument: ItemState with changed
status must be this.state.");
+        }
 
         switch (state.getStatus()) {
             /**

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemManagerImpl.java?view=diff&rev=478581&r1=478580&r2=478581
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemManagerImpl.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemManagerImpl.java
Thu Nov 23 06:09:49 2006
@@ -351,10 +351,11 @@
         ItemLifeCycleListener[] listeners = new ItemLifeCycleListener[]{this};
 
         // check special nodes
-        if (state.getNodeTypeName().equals(QName.NT_VERSION)) {
+        QName ntName = state.getNodeTypeName();
+        if (QName.NT_VERSION.equals(ntName)) {
             // version
             return new VersionImpl(this, session, state, def, listeners);
-        } else if (state.getNodeTypeName().equals(QName.NT_VERSIONHISTORY)) {
+        } else if (QName.NT_VERSIONHISTORY.equals(ntName)) {
             // version-history
             return new VersionHistoryImpl(this, session, state, def, listeners);
         } else {

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java?view=diff&rev=478581&r1=478580&r2=478581
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java
Thu Nov 23 06:09:49 2006
@@ -53,7 +53,8 @@
 import org.apache.jackrabbit.jcr2spi.util.LogUtil;
 import org.apache.jackrabbit.spi.QPropertyDefinition;
 import org.apache.jackrabbit.spi.QNodeDefinition;
-import org.apache.jackrabbit.spi.NodeId;
+import org.apache.jackrabbit.spi.IdIterator;
+import org.apache.jackrabbit.spi.ItemId;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -92,7 +93,6 @@
 import java.util.List;
 import java.util.Arrays;
 import java.util.Collection;
-import java.util.Iterator;
 
 /**
  * <code>NodeImpl</code>...
@@ -882,15 +882,15 @@
         // make sure the workspace exists and is accessible for this session.
         session.checkAccessibleWorkspace(srcWorkspace);
 
-        Collection failedIds = session.getVersionManager().merge(getNodeState(), srcWorkspace,
bestEffort);
-        if (failedIds.isEmpty()) {
+        IdIterator failedIds = session.getVersionManager().merge(getNodeState(), srcWorkspace,
bestEffort);
+        if (failedIds.getSize() == 0) {
             return IteratorHelper.EMPTY;
         } else {
             List failedStates = new ArrayList();
-            Iterator it = failedIds.iterator();
-            while (it.hasNext()) {
+            while (failedIds.hasNext()) {
                 try {
-                    ItemState state = session.getItemStateManager().getItemState((NodeId)
it.next());
+                    ItemId id = failedIds.nextId();
+                    ItemState state = session.getItemStateManager().getItemState(id);
                     if (state.isNode()) {
                         failedStates.add(state);
                     } else {
@@ -902,7 +902,11 @@
                     throw new RepositoryException(e);
                 }
             }
-            return new LazyItemIterator(itemMgr, failedStates);
+            if (failedStates.isEmpty()) {
+                return IteratorHelper.EMPTY;
+            } else {
+                return new LazyItemIterator(itemMgr, failedStates);
+            }
         }
     }
 

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceImpl.java?view=diff&rev=478581&r1=478580&r2=478581
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceImpl.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceImpl.java
Thu Nov 23 06:09:49 2006
@@ -410,7 +410,6 @@
 
     //------------------------------------< implementation specific methods >---
     void dispose() {
-        // TODO.
         // NOTE: wspManager has already been disposed upon SessionItemStateManager.dispose()
     }
 

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java?view=diff&rev=478581&r1=478580&r2=478581
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java
Thu Nov 23 06:09:49 2006
@@ -75,6 +75,7 @@
 import org.apache.jackrabbit.spi.Batch;
 import org.apache.jackrabbit.spi.EventBundle;
 import org.apache.jackrabbit.spi.EventFilter;
+import org.apache.jackrabbit.spi.IdIterator;
 import org.apache.jackrabbit.value.QValue;
 import org.slf4j.LoggerFactory;
 import org.slf4j.Logger;
@@ -185,7 +186,6 @@
     }
 
     public String[] getWorkspaceNames() throws RepositoryException {
-        // TODO: review
         return service.getWorkspaceNames(sessionInfo);
     }
 
@@ -248,7 +248,6 @@
      * @throws RepositoryException
      */
     public String[] getSupportedQueryLanguages() throws RepositoryException {
-        // TODO: review
         return service.getSupportedQueryLanguages(sessionInfo);
     }
 
@@ -685,8 +684,6 @@
             workspaceOperation.accept(this);
         }
         //-----------------------< OperationVisitor >---------------------------
-        // TODO: review retrival of ItemIds for transient modifications 
-
         public void visit(AddNode operation) throws RepositoryException {
             NodeId parentId = operation.getParentState().getNodeId();
             batch.addNode(parentId, operation.getNodeName(), operation.getNodeTypeName(),
operation.getUuid());
@@ -836,8 +833,8 @@
 
         public void visit(Merge operation) throws NoSuchWorkspaceException, AccessDeniedException,
MergeException, LockException, InvalidItemStateException, RepositoryException {
             NodeId nId = operation.getNodeState().getNodeId();
-            // todo service should return ids of failed nodes
-            service.merge(sessionInfo, nId, operation.getSourceWorkspaceName(), operation.bestEffort());
+            IdIterator failed = service.merge(sessionInfo, nId, operation.getSourceWorkspaceName(),
operation.bestEffort());
+            operation.setFailedIds(failed);
         }
 
         public void visit(ResolveMergeConflict operation) throws VersionException, InvalidItemStateException,
UnsupportedRepositoryOperationException, RepositoryException {
@@ -887,7 +884,8 @@
 
         public void visit(LockOperation operation) throws AccessDeniedException, InvalidItemStateException,
UnsupportedRepositoryOperationException, LockException, RepositoryException {
             NodeId nId = operation.getNodeState().getNodeId();
-            service.lock(sessionInfo, nId, operation.isDeep(), operation.isSessionScoped());
+            LockInfo lInfo = service.lock(sessionInfo, nId, operation.isDeep(), operation.isSessionScoped());
+            operation.setLockInfo(lInfo);
         }
 
         public void visit(LockRefresh operation) throws AccessDeniedException, InvalidItemStateException,
UnsupportedRepositoryOperationException, LockException, RepositoryException {

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/config/RepositoryConfig.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/config/RepositoryConfig.java?view=diff&rev=478581&r1=478580&r2=478581
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/config/RepositoryConfig.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/config/RepositoryConfig.java
Thu Nov 23 06:09:49 2006
@@ -24,7 +24,6 @@
 /**
  * <code>RepositoryConfig</code>...
  */
-// TODO: needs to be done properly
 public interface RepositoryConfig {
 
     public RepositoryService getRepositoryService() throws RepositoryException;

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/lock/LockManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/lock/LockManagerImpl.java?view=diff&rev=478581&r1=478580&r2=478581
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/lock/LockManagerImpl.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/lock/LockManagerImpl.java
Thu Nov 23 06:09:49 2006
@@ -100,10 +100,10 @@
 
         // execute the operation
         NodeState wspNodeState = getWorkspaceState(nodeState);
-        Operation op = LockOperation.create(wspNodeState, isDeep, isSessionScoped);
+        LockOperation op = LockOperation.create(wspNodeState, isDeep, isSessionScoped);
         wspManager.execute(op);
 
-        Lock lock = new LockImpl(new LockState(wspNodeState), lhNode);
+        Lock lock = new LockImpl(new LockState(wspNodeState, op.getLockInfo()), lhNode);
         return lock;
     }
 
@@ -457,14 +457,19 @@
         private boolean isLive = true;
         private final EventFilter eventFilter;
 
-        private LockState(NodeState lockHoldingState) throws LockException, RepositoryException
{
+        private LockState(NodeState lockHoldingState, LockInfo lockInfo)
+            throws LockException, RepositoryException{
             lockHoldingState.checkIsWorkspaceState();
 
             this.lockHoldingState = lockHoldingState;
-            // retrieve lock info from wsp-manager, in order to get the complete
-            // lockInfo including lock-token, which is not available from the
-            // child properties nor from the original lock request.
-            this.lockInfo = wspManager.getLockInfo(lockHoldingState.getNodeId());
+            if (lockInfo == null) {
+                // retrieve lock info from wsp-manager, in order to get the complete
+                // lockInfo including lock-token, which is not available from the
+                // child properties nor from the original lock request.
+                this.lockInfo = wspManager.getLockInfo(lockHoldingState.getNodeId());
+            } else {
+                this.lockInfo = lockInfo;
+            }
 
             // TODO: TOBEFIXED...SPI may not support observation
             // register as internal listener to the wsp manager in order to get
@@ -472,6 +477,10 @@
             eventFilter = wspManager.createEventFilter(Event.PROPERTY_REMOVED,
                     lockHoldingState.getQPath(), false, null, null, true);
             wspManager.addEventListener(this);
+        }
+
+        private LockState(NodeState lockHoldingState) throws LockException, RepositoryException
{
+            this(lockHoldingState, null);
         }
 
         private void refresh() throws RepositoryException {

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/LockOperation.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/LockOperation.java?view=diff&rev=478581&r1=478580&r2=478581
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/LockOperation.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/LockOperation.java
Thu Nov 23 06:09:49 2006
@@ -17,6 +17,7 @@
 package org.apache.jackrabbit.jcr2spi.operation;
 
 import org.apache.jackrabbit.jcr2spi.state.NodeState;
+import org.apache.jackrabbit.spi.LockInfo;
 
 import javax.jcr.RepositoryException;
 import javax.jcr.AccessDeniedException;
@@ -73,6 +74,13 @@
         return isSessionScoped;
     }
 
+    public void setLockInfo(LockInfo lockInfo) {
+        this.lockInfo = lockInfo;
+    }
+
+    public LockInfo getLockInfo() {
+        return lockInfo;
+    }
     //------------------------------------------------------------< Factory >---
     /**
      *
@@ -80,8 +88,8 @@
      * @param isDeep
      * @return
      */
-    public static Operation create(NodeState nodeState, boolean isDeep, boolean isSessionScoped)
{
-        Operation lck = new LockOperation(nodeState, isDeep, isSessionScoped);
+    public static LockOperation create(NodeState nodeState, boolean isDeep, boolean isSessionScoped)
{
+        LockOperation lck = new LockOperation(nodeState, isDeep, isSessionScoped);
         return lck;
     }
 }

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Merge.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Merge.java?view=diff&rev=478581&r1=478580&r2=478581
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Merge.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Merge.java
Thu Nov 23 06:09:49 2006
@@ -16,8 +16,8 @@
  */
 package org.apache.jackrabbit.jcr2spi.operation;
 
-import org.apache.jackrabbit.jcr2spi.observation.InternalEventListener;
 import org.apache.jackrabbit.jcr2spi.state.NodeState;
+import org.apache.jackrabbit.spi.IdIterator;
 
 import javax.jcr.RepositoryException;
 import javax.jcr.AccessDeniedException;
@@ -35,13 +35,13 @@
     private final NodeState nodeState;
     private final String srcWorkspaceName;
     private final boolean bestEffort;
-    private final InternalEventListener eventListener;
 
-    private Merge(NodeState nodeState, String srcWorkspaceName, boolean bestEffort, InternalEventListener
eventListener) {
+    private IdIterator failedIds = null;
+
+    private Merge(NodeState nodeState, String srcWorkspaceName, boolean bestEffort) {
         this.nodeState = nodeState;
         this.srcWorkspaceName = srcWorkspaceName;
         this.bestEffort = bestEffort;
-        this.eventListener = eventListener;
 
         this.addAffectedItemState(nodeState);
     }
@@ -77,10 +77,22 @@
         return bestEffort;
     }
 
-    public InternalEventListener getEventListener() {
-        return eventListener;
+    public void setFailedIds(IdIterator failedIds) {
+        if (failedIds == null) {
+            throw new IllegalArgumentException("IdIterator must not be null.");
+        }
+        if (this.failedIds != null) {
+            throw new IllegalStateException("Merge operation has already been executed ->
FailedIds already set.");
+        }
+        this.failedIds = failedIds;
     }
 
+    public IdIterator getFailedIds() {
+        if (failedIds == null) {
+            throw new IllegalStateException("Merge operation has not been executed yet.");
+        }
+        return failedIds;
+    }
     //------------------------------------------------------------< Factory >---
     /**
      *
@@ -88,7 +100,7 @@
      * @param srcWorkspaceName
      * @return
      */
-    public static Operation create(NodeState nodeState, String srcWorkspaceName, boolean
bestEffort, InternalEventListener eventListener) {
-        return new Merge(nodeState, srcWorkspaceName, bestEffort, eventListener);
+    public static Merge create(NodeState nodeState, String srcWorkspaceName, boolean bestEffort)
{
+        return new Merge(nodeState, srcWorkspaceName, bestEffort);
     }
 }

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/DefaultVersionManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/DefaultVersionManager.java?view=diff&rev=478581&r1=478580&r2=478581
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/DefaultVersionManager.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/DefaultVersionManager.java
Thu Nov 23 06:09:49 2006
@@ -27,8 +27,6 @@
 import org.apache.jackrabbit.name.Path;
 import org.apache.jackrabbit.jcr2spi.state.NodeState;
 
-import java.util.Collection;
-
 /**
  * <code>DefaultVersionManager</code>...
  */
@@ -73,7 +71,7 @@
         throw new UnsupportedRepositoryOperationException("Versioning ist not supported by
this repository.");
     }
 
-    public Collection merge(NodeState nodeState, String workspaceName, boolean bestEffort)
throws RepositoryException {
+    public IdIterator merge(NodeState nodeState, String workspaceName, boolean bestEffort)
throws RepositoryException {
         throw new UnsupportedRepositoryOperationException("Versioning ist not supported by
this repository.");
     }
 

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionManager.java?view=diff&rev=478581&r1=478580&r2=478581
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionManager.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionManager.java
Thu Nov 23 06:09:49 2006
@@ -19,10 +19,10 @@
 import org.apache.jackrabbit.name.QName;
 import org.apache.jackrabbit.name.Path;
 import org.apache.jackrabbit.jcr2spi.state.NodeState;
+import org.apache.jackrabbit.spi.IdIterator;
 
 import javax.jcr.RepositoryException;
 import javax.jcr.version.VersionException;
-import java.util.Collection;
 
 /**
  * <code>VersionManager</code>...
@@ -59,7 +59,7 @@
      * by the user of the API.
      * @see #resolveMergeConflict(NodeState,NodeState,boolean)
      */
-    public Collection merge(NodeState nodeState, String workspaceName, boolean bestEffort)
throws RepositoryException;
+    public IdIterator merge(NodeState nodeState, String workspaceName, boolean bestEffort)
throws RepositoryException;
 
     /**
      * 

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionManagerImpl.java?view=diff&rev=478581&r1=478580&r2=478581
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionManagerImpl.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionManagerImpl.java
Thu Nov 23 06:09:49 2006
@@ -20,7 +20,6 @@
 import org.apache.jackrabbit.jcr2spi.state.PropertyState;
 import org.apache.jackrabbit.jcr2spi.state.ItemStateException;
 import org.apache.jackrabbit.jcr2spi.state.Status;
-import org.apache.jackrabbit.jcr2spi.observation.InternalEventListener;
 import org.apache.jackrabbit.jcr2spi.operation.Operation;
 import org.apache.jackrabbit.jcr2spi.operation.Checkout;
 import org.apache.jackrabbit.jcr2spi.operation.Checkin;
@@ -35,20 +34,11 @@
 import org.slf4j.Logger;
 
 import javax.jcr.RepositoryException;
-import javax.jcr.UnsupportedRepositoryOperationException;
 import javax.jcr.version.VersionException;
 
 import org.apache.jackrabbit.name.QName;
 import org.apache.jackrabbit.name.Path;
-import org.apache.jackrabbit.spi.EventIterator;
-import org.apache.jackrabbit.spi.Event;
-import org.apache.jackrabbit.spi.EventBundle;
-import org.apache.jackrabbit.spi.EventFilter;
-
-import java.util.Collection;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Collections;
+import org.apache.jackrabbit.spi.IdIterator;
 
 /**
  * <code>VersionManagerImpl</code>...
@@ -156,39 +146,11 @@
         workspaceManager.execute(op);
     }
 
-    public Collection merge(NodeState nodeState, String workspaceName, boolean bestEffort)
throws RepositoryException {
+    public IdIterator merge(NodeState nodeState, String workspaceName, boolean bestEffort)
throws RepositoryException {
         NodeState wspState = getWorkspaceState(nodeState);
-        // TODO : needs to be fixed... SPI may not support observation
-        // TODO find better solution to build the mergeFailed-collection
-        EventFilter eventFilter;
-        try {
-            eventFilter = workspaceManager.createEventFilter(Event.ALL_TYPES, nodeState.getQPath(),
true, null, null, false);
-        } catch (UnsupportedRepositoryOperationException e) {
-            eventFilter = null;
-        }
-        final List failedIds = new ArrayList();
-        final Collection fts = (eventFilter == null) ? Collections.EMPTY_LIST : Collections.singletonList(eventFilter);
-
-        InternalEventListener mergeFailedCollector = new InternalEventListener() {
-            public Collection getEventFilters() {
-                return fts;
-            }
-            public void onEvent(EventBundle eventBundle) {
-                if (eventBundle.isLocal()) {
-                    EventIterator it = eventBundle.getEvents();
-                    while (it.hasNext()) {
-                        Event ev = it.nextEvent();
-                        if (ev.getType() == Event.PROPERTY_ADDED && QName.JCR_MERGEFAILED.equals(ev.getQPath().getNameElement().getName()))
{
-                            failedIds.add(ev.getParentId());
-                        }
-                    }
-                }
-            }
-        };
-
-        Operation op = Merge.create(wspState, workspaceName, bestEffort, mergeFailedCollector);
+        Merge op = Merge.create(wspState, workspaceName, bestEffort);
         workspaceManager.execute(op);
-        return failedIds;
+        return op.getFailedIds();
     }
 
     public void resolveMergeConflict(NodeState nodeState, NodeState versionState, boolean
done) throws RepositoryException {



Mime
View raw message