jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r803444 - in /jackrabbit/trunk: jackrabbit-jcr-client/src/test/java/org/apache/jackrabbit/client/ jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ jack...
Date Wed, 12 Aug 2009 11:02:11 GMT
Author: angela
Date: Wed Aug 12 11:02:10 2009
New Revision: 803444

URL: http://svn.apache.org/viewvc?rev=803444&view=rev
Log:
JCR-2104:  JSR 283 Full Versioning (work in progress)

- setActivity
- checkout with activity param -> spi level
- more checks in version manager
- invalidation after sucessful mergeActivity

Modified:
    jackrabbit/trunk/jackrabbit-jcr-client/src/test/java/org/apache/jackrabbit/client/RepositoryFactoryImplTest.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/JcrVersionManager.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/EntryFactory.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Checkout.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Merge.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionManager.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionManagerImpl.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/AbstractJCR2SPITest.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/AbstractReadableRepositoryService.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/RepositoryServiceLogger.java
    jackrabbit/trunk/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/RepositoryService.java
    jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
    jackrabbit/trunk/jackrabbit-spi2jcr/pom.xml
    jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/RepositoryServiceImpl.java

Modified: jackrabbit/trunk/jackrabbit-jcr-client/src/test/java/org/apache/jackrabbit/client/RepositoryFactoryImplTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-client/src/test/java/org/apache/jackrabbit/client/RepositoryFactoryImplTest.java?rev=803444&r1=803443&r2=803444&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-client/src/test/java/org/apache/jackrabbit/client/RepositoryFactoryImplTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-client/src/test/java/org/apache/jackrabbit/client/RepositoryFactoryImplTest.java
Wed Aug 12 11:02:10 2009
@@ -264,6 +264,9 @@
         public void checkout(SessionInfo sessionInfo, NodeId nodeId) throws UnsupportedRepositoryOperationException,
LockException, RepositoryException {
         }
 
+        public void checkout(SessionInfo sessionInfo, NodeId nodeId, NodeId activityId) throws
UnsupportedRepositoryOperationException, LockException, RepositoryException {
+        }
+
         public NodeId checkpoint(SessionInfo sessionInfo, NodeId nodeId) throws UnsupportedRepositoryOperationException,
RepositoryException {
             return null;
         }

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/JcrVersionManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/JcrVersionManager.java?rev=803444&r1=803443&r2=803444&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/JcrVersionManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/JcrVersionManager.java
Wed Aug 12 11:02:10 2009
@@ -22,6 +22,9 @@
 import org.apache.jackrabbit.jcr2spi.version.VersionManager;
 import org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry;
 import org.apache.jackrabbit.spi.commons.conversion.PathResolver;
+import org.apache.jackrabbit.spi.commons.name.NameConstants;
+import org.apache.jackrabbit.spi.NodeId;
+import org.apache.jackrabbit.spi.ItemId;
 import org.apache.jackrabbit.commons.iterator.NodeIteratorAdapter;
 
 import javax.jcr.version.Version;
@@ -37,6 +40,8 @@
 import javax.jcr.AccessDeniedException;
 import javax.jcr.MergeException;
 import javax.jcr.Node;
+import javax.jcr.ItemNotFoundException;
+import javax.jcr.Repository;
 import javax.jcr.nodetype.ConstraintViolationException;
 import javax.jcr.lock.LockException;
 import java.util.Iterator;
@@ -56,6 +61,12 @@
     private final ItemManager itemManager;
     private final PathResolver resolver;
 
+    /**
+     * The ID of the activity currently in effect for the session this
+     * manager has been created for.
+     */
+    private NodeId activityId;
+
     protected JcrVersionManager(SessionImpl session) {
         this.session = session;
         vMgr = session.getVersionStateManager();
@@ -68,6 +79,8 @@
      * @see javax.jcr.version.VersionManager#checkin(String)
      */
     public Version checkin(String absPath) throws VersionException, UnsupportedRepositoryOperationException,
InvalidItemStateException, LockException, RepositoryException {
+        session.checkIsAlive();
+        
         Node n = itemManager.getNode(resolver.getQPath(absPath));
         return n.checkin();
     }
@@ -76,6 +89,8 @@
      * @see javax.jcr.version.VersionManager#checkout(String)
      */
     public void checkout(String absPath) throws UnsupportedRepositoryOperationException,
LockException, RepositoryException {
+        session.checkIsAlive();
+
         Node n = itemManager.getNode(resolver.getQPath(absPath));
         n.checkout();
     }
@@ -85,6 +100,7 @@
      */
     public Version checkpoint(String absPath) throws VersionException, UnsupportedRepositoryOperationException,
InvalidItemStateException, LockException, RepositoryException {
         session.checkIsAlive();
+
         NodeImpl n = (NodeImpl) itemManager.getNode(resolver.getQPath(absPath));
         return n.checkpoint();
     }
@@ -93,6 +109,8 @@
      * @see javax.jcr.version.VersionManager#isCheckedOut(String)
      */
     public boolean isCheckedOut(String absPath) throws RepositoryException {
+        session.checkIsAlive();
+
         Node n = itemManager.getNode(resolver.getQPath(absPath));
         return n.isCheckedOut();
     }
@@ -101,6 +119,8 @@
      * @see javax.jcr.version.VersionManager#getVersionHistory(String)
      */
     public VersionHistory getVersionHistory(String absPath) throws UnsupportedRepositoryOperationException,
RepositoryException {
+        session.checkIsAlive();
+
         Node n = itemManager.getNode(resolver.getQPath(absPath));
         return n.getVersionHistory();
     }
@@ -109,6 +129,8 @@
      * @see javax.jcr.version.VersionManager#getBaseVersion(String)
      */
     public Version getBaseVersion(String absPath) throws UnsupportedRepositoryOperationException,
RepositoryException {
+        session.checkIsAlive();
+
         Node n = itemManager.getNode(resolver.getQPath(absPath));
         return n.getBaseVersion();
     }
@@ -131,6 +153,8 @@
      * @see javax.jcr.version.VersionManager#restore(String, String, boolean)
      */
     public void restore(String absPath, String versionName, boolean removeExisting) throws
VersionException, ItemExistsException, UnsupportedRepositoryOperationException, LockException,
InvalidItemStateException, RepositoryException {
+        session.checkIsAlive();
+
         Node n = itemManager.getNode(resolver.getQPath(absPath));
         n.restore(versionName, removeExisting);
     }
@@ -146,6 +170,8 @@
      * @see javax.jcr.version.VersionManager#restore(String, Version, boolean)
      */
     public void restore(String absPath, Version version, boolean removeExisting) throws PathNotFoundException,
ItemExistsException, VersionException, ConstraintViolationException, UnsupportedRepositoryOperationException,
LockException, InvalidItemStateException, RepositoryException {
+        session.checkIsAlive();
+
         Node n = itemManager.getNode(resolver.getQPath(absPath));
         n.restore(version, removeExisting);
     }
@@ -154,6 +180,8 @@
      * @see javax.jcr.version.VersionManager#restoreByLabel(String, String, boolean)
      */
     public void restoreByLabel(String absPath, String versionLabel, boolean removeExisting)
throws VersionException, ItemExistsException, UnsupportedRepositoryOperationException, LockException,
InvalidItemStateException, RepositoryException {
+        session.checkIsAlive();
+
         Node n = itemManager.getNode(resolver.getQPath(absPath));
         n.restoreByLabel(versionLabel, removeExisting);
     }
@@ -169,6 +197,8 @@
      * @see javax.jcr.version.VersionManager#merge(String, String, boolean, boolean)
      */
     public NodeIterator merge(String absPath, String srcWorkspace, boolean bestEffort, boolean
isShallow) throws NoSuchWorkspaceException, AccessDeniedException, MergeException, LockException,
InvalidItemStateException, RepositoryException {
+        session.checkIsAlive();        
+
         NodeImpl n = (NodeImpl) itemManager.getNode(resolver.getQPath(absPath));
         n.checkIsWritable();
         session.checkHasPendingChanges();
@@ -188,6 +218,8 @@
      * @see javax.jcr.version.VersionManager#doneMerge(String, Version)
      */
     public void doneMerge(String absPath, Version version) throws VersionException, InvalidItemStateException,
UnsupportedRepositoryOperationException, RepositoryException {
+        session.checkIsAlive();
+
         Node n = itemManager.getNode(resolver.getQPath(absPath));
         n.doneMerge(version);
     }
@@ -196,6 +228,8 @@
      * @see javax.jcr.version.VersionManager#cancelMerge(String, Version)
      */
     public void cancelMerge(String absPath, Version version) throws VersionException, InvalidItemStateException,
UnsupportedRepositoryOperationException, RepositoryException {
+        session.checkIsAlive();                                  
+
         Node n = itemManager.getNode(resolver.getQPath(absPath));
         n.cancelMerge(version);
     }
@@ -204,7 +238,8 @@
      * @see javax.jcr.version.VersionManager#createConfiguration(String)
      */
     public Node createConfiguration(String absPath) throws UnsupportedRepositoryOperationException,
RepositoryException {
-        // TODO: add validation
+        session.checkIsAlive();
+
         NodeImpl n = (NodeImpl) itemManager.getNode(resolver.getQPath(absPath));
         NodeEntry entry = vMgr.createConfiguration((NodeState) n.getItemState());
         return (Node) itemManager.getItem(entry);
@@ -214,23 +249,47 @@
      * @see javax.jcr.version.VersionManager#setActivity(Node)
      */
     public Node setActivity(Node activity) throws UnsupportedRepositoryOperationException,
RepositoryException {
-        // TODO
-        throw new UnsupportedOperationException("JCR-2104: JSR 283 Versioning. Implementation
missing");
+        session.checkIsAlive();
+        session.checkSupportedOption(Repository.OPTION_ACTIVITIES_SUPPORTED);
+
+
+        Node oldActivity = getActivity();
+        if (activity == null) {
+            activityId = null;
+        } else {
+            NodeImpl activityNode = getValidActivity(activity, "set");
+            activityId = (NodeId) activityNode.getItemState().getId();
+        }
+        return oldActivity;
     }
 
     /**
      * @see javax.jcr.version.VersionManager#getActivity()
      */
     public Node getActivity() throws UnsupportedRepositoryOperationException, RepositoryException
{
-        // TODO
-        throw new UnsupportedOperationException("JCR-2104: JSR 283 Versioning. Implementation
missing");
+        session.checkIsAlive();
+        session.checkSupportedOption(Repository.OPTION_ACTIVITIES_SUPPORTED);
+
+        if (activityId == null) {
+            return null;
+        } else {
+            try {
+                return (Node) itemManager.getItem(session.getHierarchyManager().getNodeEntry(activityId));
+            } catch (ItemNotFoundException e) {
+                // the activity doesn't exist any more.
+                log.warn("Activity node with id " + activityId + " doesn't exist any more.");
+                activityId = null;
+                return null;
+            }
+        }
     }
 
     /**
      * @see javax.jcr.version.VersionManager#createActivity(String)
      */
     public Node createActivity(String title) throws UnsupportedRepositoryOperationException,
RepositoryException {
-        // TODO: add validation
+        session.checkIsAlive();
+
         NodeEntry entry = vMgr.createActivity(title);
         return (Node) itemManager.getItem(entry);
     }
@@ -239,16 +298,57 @@
      * @see javax.jcr.version.VersionManager#removeActivity(Node)
      */
     public void removeActivity(Node activityNode) throws UnsupportedRepositoryOperationException,
RepositoryException {
-        vMgr.removeActivity((NodeState) ((NodeImpl) activityNode).getItemState());
+        session.checkIsAlive();
+        NodeImpl activity = getValidActivity(activityNode, "remove");
+
+        NodeState nState = (NodeState) activity.getItemState();
+        ItemId removeId = nState.getId();
+        vMgr.removeActivity(nState);
+
+        // if the removal succeeded, make sure there is no current activity
+        // setting on this session, that points to the removed activity.
+        if (activityId != null && activityId.equals(removeId)) {
+            activityId = null;
+        }
     }
 
     /**
      * @see javax.jcr.version.VersionManager#merge(Node)
      */
     public NodeIterator merge(Node activityNode) throws VersionException, AccessDeniedException,
MergeException, LockException, InvalidItemStateException, RepositoryException {
-        // TODO: add validation
-        Iterator failedIds = vMgr.mergeActivity((NodeState) ((NodeImpl) activityNode).getItemState());
+        session.checkIsAlive();
+        NodeImpl activity = getValidActivity(activityNode, "merge");
+        Iterator failedIds = vMgr.mergeActivity((NodeState) activity.getItemState());
         return new LazyItemIterator(itemManager, session.getHierarchyManager(), failedIds);
     }
 
+    /**
+     * Assert that activity nodes passes to any of the activity methods have
+     * been obtained from the session this version manager has been created for.
+     * This is particularly important for workspace operations that are followed
+     * by internal updated of modified items: The hierarchy entries invalidated
+     * after successful completion of the operation must reside within scope
+     * defined by this session.
+     * <br>
+     * In addition this method varifies that the passed node is of type nt:activity.
+     *
+     * @param activityNode
+     * @param methodName
+     * @return
+     * @throws RepositoryException
+     */
+    private NodeImpl getValidActivity(Node activityNode, String methodName) throws UnsupportedRepositoryOperationException,
RepositoryException {
+        NodeImpl activity;
+        if (session != activityNode.getSession()) {
+            String msg = "Attempt to " +methodName+ " an activity node that has been retrieved
by another session.";
+            log.warn(msg);
+            activity = (NodeImpl) session.getNodeByIdentifier(activityNode.getIdentifier());
+        } else {
+            activity = (NodeImpl) activityNode;
+        }
+        if (!activity.isNodeType(NameConstants.NT_ACTIVITY)) {
+            throw new UnsupportedRepositoryOperationException("Given node is not an activity.");
+        }
+        return activity;
+    }
 }
\ No newline at end of file

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java?rev=803444&r1=803443&r2=803444&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java
Wed Aug 12 11:02:10 2009
@@ -42,6 +42,7 @@
 import javax.jcr.UnsupportedRepositoryOperationException;
 import javax.jcr.Value;
 import javax.jcr.ValueFormatException;
+import javax.jcr.Repository;
 import javax.jcr.lock.Lock;
 import javax.jcr.lock.LockException;
 import javax.jcr.nodetype.ConstraintViolationException;
@@ -77,6 +78,7 @@
 import org.apache.jackrabbit.spi.QPropertyDefinition;
 import org.apache.jackrabbit.spi.QValue;
 import org.apache.jackrabbit.spi.PropertyId;
+import org.apache.jackrabbit.spi.NodeId;
 import org.apache.jackrabbit.spi.commons.conversion.NameException;
 import org.apache.jackrabbit.spi.commons.name.NameConstants;
 import org.apache.jackrabbit.spi.commons.value.ValueFormat;
@@ -876,7 +878,13 @@
         checkIsVersionable();
         checkIsLocked();
         if (!isCheckedOut()) {
-            session.getVersionStateManager().checkout(getNodeState());
+            if (session.isSupportedOption(Repository.OPTION_ACTIVITIES_SUPPORTED)) {
+                NodeImpl activity = (NodeImpl) session.getWorkspace().getVersionManager().getActivity();
+                NodeId activityId = (activity == null) ? null : activity.getNodeState().getNodeId();
+                session.getVersionStateManager().checkout(getNodeState(), activityId);
+            } else {
+                session.getVersionStateManager().checkout(getNodeState());
+            }
         } else {
             // nothing to do
             log.debug("Node " + safeGetJCRPath() + " is already checked out.");

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java?rev=803444&r1=803443&r2=803444&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java
Wed Aug 12 11:02:10 2009
@@ -963,7 +963,11 @@
          * @see OperationVisitor#visit(Checkout)
          */
         public void visit(Checkout operation) throws UnsupportedRepositoryOperationException,
LockException, RepositoryException {
-            service.checkout(sessionInfo, operation.getNodeId());
+            if (operation.supportsActivity()) {
+                service.checkout(sessionInfo, operation.getNodeId(), operation.getActivityId());
+            } else {
+                service.checkout(sessionInfo, operation.getNodeId());
+            }
         }
 
         /**

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/EntryFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/EntryFactory.java?rev=803444&r1=803443&r2=803444&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/EntryFactory.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/EntryFactory.java
Wed Aug 12 11:02:10 2009
@@ -23,16 +23,12 @@
 import org.apache.jackrabbit.spi.Path;
 import org.apache.jackrabbit.spi.PathFactory;
 import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 /**
  * <code>EntryFactory</code>...
  */
 public class EntryFactory {
 
-    private static Logger log = LoggerFactory.getLogger(EntryFactory.class);
-
     /**
      * IdFactory to create an ItemId based on the parent NodeId.
      */
@@ -43,7 +39,7 @@
     private final NodeEntry rootEntry;
 
     /**
-     *
+     * Listener to creation and uid-changes of node entries.
      */
     private final NodeEntryListener listener;
 

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Checkout.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Checkout.java?rev=803444&r1=803443&r2=803444&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Checkout.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Checkout.java
Wed Aug 12 11:02:10 2009
@@ -41,11 +41,23 @@
     private static Logger log = LoggerFactory.getLogger(Checkout.class);
 
     private final NodeState nodeState;
+    private final NodeId activityId;
+    private final boolean supportsActivity;
     private final VersionManager mgr;
 
     private Checkout(NodeState nodeState, VersionManager mgr) {
         this.nodeState = nodeState;
         this.mgr = mgr;
+        supportsActivity = false;
+        activityId = null;
+        // NOTE: affected-states only needed for transient modifications
+    }
+
+    private Checkout(NodeState nodeState, NodeId activityId, VersionManager mgr) {
+        this.nodeState = nodeState;
+        this.activityId = activityId;
+        this.mgr = mgr;
+        supportsActivity = true;
         // NOTE: affected-states only needed for transient modifications
     }
 
@@ -90,8 +102,32 @@
         return nodeState.getNodeEntry().getWorkspaceId();
     }
 
+    /**
+     * The id of the current activity present on the editing session or <code>null</code>.
+     *
+     * @return id of the current activity present on the editing session or <code>null</code>.
+     */
+    public NodeId getActivityId() {
+        return activityId;
+    }
+
+    /**
+     * Returns <code>true</code>, if activities are supported, 
+     * <code>false</code> otherwise.
+     *
+     * @return  <code>true</code>, if activities are supported,
+     * <code>false</code> otherwise.
+     */
+    public boolean supportsActivity() {
+        return supportsActivity;
+    }
+
     //------------------------------------------------------------< Factory >---
     public static Operation create(NodeState nodeState, VersionManager mgr) {
         return new Checkout(nodeState, mgr);
     }
+
+    public static Operation create(NodeState nodeState, NodeId activityId, VersionManager
mgr) {
+        return new Checkout(nodeState, activityId, mgr);
+    }
 }
\ No newline at end of file

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Merge.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Merge.java?rev=803444&r1=803443&r2=803444&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Merge.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Merge.java
Wed Aug 12 11:02:10 2009
@@ -19,6 +19,7 @@
 import org.apache.jackrabbit.jcr2spi.state.NodeState;
 import org.apache.jackrabbit.jcr2spi.version.VersionManager;
 import org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry;
+import org.apache.jackrabbit.jcr2spi.hierarchy.HierarchyEntry;
 import org.apache.jackrabbit.spi.NodeId;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -75,7 +76,13 @@
         assert status == STATUS_PENDING;
         status = STATUS_PERSISTED;
         if (isActivityMerge()) {
-            // TODO invalidate
+            // TODO be more specific about what needs to be invalidated
+            // look for the root entry and invalidate the complete tree
+            HierarchyEntry entry = nodeState.getNodeEntry();
+            while (entry.getParent() != null) {
+                entry = entry.getParent();
+            }
+            entry.invalidate(true);
         } else {
             try {
                 NodeEntry vhe = mgr.getVersionHistoryEntry(nodeState);

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionManager.java?rev=803444&r1=803443&r2=803444&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionManager.java
Wed Aug 12 11:02:10 2009
@@ -18,6 +18,7 @@
 
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.Path;
+import org.apache.jackrabbit.spi.NodeId;
 import org.apache.jackrabbit.jcr2spi.state.NodeState;
 import org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry;
 
@@ -61,6 +62,14 @@
     public void checkout(NodeState nodeState) throws UnsupportedRepositoryOperationException,
LockException, RepositoryException;
 
     /**
+     * 
+     * @param nodeState
+     * @param activityId
+     * @throws RepositoryException
+     */
+    public void checkout(NodeState nodeState, NodeId activityId) throws RepositoryException;
+
+    /**
      * @param nodeState
      * @throws RepositoryException
      * @see javax.jcr.version.VersionManager#checkpoint(String)

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionManagerImpl.java?rev=803444&r1=803443&r2=803444&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionManagerImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionManagerImpl.java
Wed Aug 12 11:02:10 2009
@@ -34,8 +34,6 @@
 import org.apache.jackrabbit.jcr2spi.operation.RemoveActivity;
 import org.apache.jackrabbit.jcr2spi.WorkspaceManager;
 import org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry;
-import org.slf4j.LoggerFactory;
-import org.slf4j.Logger;
 
 import javax.jcr.RepositoryException;
 import javax.jcr.ItemNotFoundException;
@@ -60,8 +58,6 @@
  */
 public class VersionManagerImpl implements VersionManager {
 
-    private static Logger log = LoggerFactory.getLogger(VersionManagerImpl.class);
-
     private final WorkspaceManager workspaceManager;
 
     public VersionManagerImpl(WorkspaceManager workspaceManager) {
@@ -75,7 +71,11 @@
     }
 
     public void checkout(NodeState nodeState) throws RepositoryException {
-        Operation co = Checkout.create(nodeState, this);
+        checkout(nodeState, null);
+    }
+
+    public void checkout(NodeState nodeState, NodeId activityId) throws RepositoryException
{
+        Operation co = Checkout.create(nodeState, activityId, this);
         workspaceManager.execute(co);
     }
 

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/AbstractJCR2SPITest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/AbstractJCR2SPITest.java?rev=803444&r1=803443&r2=803444&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/AbstractJCR2SPITest.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/AbstractJCR2SPITest.java
Wed Aug 12 11:02:10 2009
@@ -362,9 +362,12 @@
         repositoryService.checkout(sessionInfo, nodeId);
     }
 
+    public void checkout(SessionInfo sessionInfo, NodeId nodeId, NodeId activityId) throws
RepositoryException {
+        repositoryService.checkout(sessionInfo, nodeId, activityId);
+    }
+
     public NodeId checkpoint(SessionInfo sessionInfo, NodeId nodeId)
             throws RepositoryException {
-
         return repositoryService.checkpoint(sessionInfo, nodeId);
     }
 
@@ -418,7 +421,6 @@
 
     public NodeId createActivity(SessionInfo sessionInfo, String title)
             throws RepositoryException {
-
         return repositoryService.createActivity(sessionInfo, title);
     }
 
@@ -436,10 +438,9 @@
 
     public NodeId createConfiguration(SessionInfo sessionInfo, NodeId nodeId)
             throws RepositoryException {
-
         return repositoryService.createConfiguration(sessionInfo, nodeId);
     }
-
+    
     //----------------------------------------------------------< Searching >---
 
     public String[] getSupportedQueryLanguages(SessionInfo sessionInfo) throws RepositoryException
{

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/AbstractReadableRepositoryService.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/AbstractReadableRepositoryService.java?rev=803444&r1=803443&r2=803444&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/AbstractReadableRepositoryService.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/AbstractReadableRepositoryService.java
Wed Aug 12 11:02:10 2009
@@ -558,6 +558,14 @@
     /**
      * @throws UnsupportedRepositoryOperationException always.
      */
+    public void checkout(SessionInfo sessionInfo, NodeId nodeId, NodeId activityId)
+            throws UnsupportedRepositoryOperationException, LockException, RepositoryException
{
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    /**
+     * @throws UnsupportedRepositoryOperationException always.
+     */
     public NodeId checkpoint(SessionInfo sessionInfo, NodeId nodeId)
             throws UnsupportedRepositoryOperationException, LockException, RepositoryException
{
         throw new UnsupportedRepositoryOperationException();

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/RepositoryServiceLogger.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/RepositoryServiceLogger.java?rev=803444&r1=803443&r2=803444&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/RepositoryServiceLogger.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/RepositoryServiceLogger.java
Wed Aug 12 11:02:10 2009
@@ -398,6 +398,17 @@
         }, "checkout(SessionInfo, NodeId)", new Object[]{unwrap(sessionInfo), nodeId});
     }
 
+    public void checkout(final SessionInfo sessionInfo, final NodeId nodeId, final NodeId
activityId)
+            throws RepositoryException {
+
+        execute(new Callable() {
+            public Object call() throws RepositoryException {
+                service.checkout(unwrap(sessionInfo), nodeId, activityId);
+                return null;
+            }
+        }, "checkout(SessionInfo, NodeId, NodeId)", new Object[]{unwrap(sessionInfo), nodeId,
activityId});
+    }
+
     public NodeId checkpoint(final SessionInfo sessionInfo, final NodeId nodeId) throws UnsupportedRepositoryOperationException,
RepositoryException {
         return (NodeId) execute(new Callable() {
             public Object call() throws RepositoryException {

Modified: jackrabbit/trunk/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/RepositoryService.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/RepositoryService.java?rev=803444&r1=803443&r2=803444&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/RepositoryService.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/RepositoryService.java
Wed Aug 12 11:02:10 2009
@@ -613,7 +613,8 @@
 
     /**
      * Performs a checkout for the <code>Node</code> identified by the given
-     * <code>NodeId</code>.
+     * <code>NodeId</code>. Same as {@link #checkout(SessionInfo, NodeId, NodeId)}
+     * where the <code>activityId</code> is <code>null</code>.
      *
      * @param sessionInfo
      * @param nodeId
@@ -625,6 +626,23 @@
     public void checkout(SessionInfo sessionInfo, NodeId nodeId) throws UnsupportedRepositoryOperationException,
LockException, RepositoryException;
 
     /**
+     * Performs a checkout for the <code>Node</code> identified by the given
+     * <code>NodeId</code> and for activity identified by the specified
+     * <code>activityId</code>. If the <code>activityId</code> is
<code>null</code>
+     * this corresponds to {@link #checkout(SessionInfo, NodeId)}
+     *
+     * @param sessionInfo
+     * @param nodeId
+     * @param activityId  Id of the activity node set to the editing session or
+     * <code>null</code> if no activity is in effect.
+     * @throws UnsupportedRepositoryOperationException
+     * @throws LockException
+     * @throws RepositoryException
+     * @since JCR 2.0
+     */
+    public void checkout(SessionInfo sessionInfo, NodeId nodeId, NodeId activityId) throws
UnsupportedRepositoryOperationException, LockException, RepositoryException;
+
+    /**
      * Performs a checkpoint for the <code>Node</code> identified by the given
      * <code>NodeId</code>.
      *

Modified: jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java?rev=803444&r1=803443&r2=803444&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
Wed Aug 12 11:02:10 2009
@@ -1463,6 +1463,17 @@
         execute(method, sessionInfo);
     }
 
+    /**
+     * @see RepositoryService#checkout(SessionInfo, NodeId, NodeId)
+     */
+    public void checkout(SessionInfo sessionInfo, NodeId nodeId, NodeId activityOd) throws
UnsupportedRepositoryOperationException, LockException, RepositoryException {
+        // TODO
+        throw new UnsupportedOperationException("JCR-2104: JSR 283 Versioning. Implementation
missing");
+    }
+
+    /**
+     * @see RepositoryService#checkpoint(SessionInfo, NodeId)
+     */
     public NodeId checkpoint(SessionInfo sessionInfo, NodeId nodeId) throws UnsupportedRepositoryOperationException,
RepositoryException {
         // TODO
         throw new UnsupportedOperationException("JCR-2104: JSR 283 Versioning. Implementation
missing");

Modified: jackrabbit/trunk/jackrabbit-spi2jcr/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi2jcr/pom.xml?rev=803444&r1=803443&r2=803444&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi2jcr/pom.xml (original)
+++ jackrabbit/trunk/jackrabbit-spi2jcr/pom.xml Wed Aug 12 11:02:10 2009
@@ -71,9 +71,9 @@
                 org.apache.jackrabbit.jcr2spi.name.NamespaceRegistryTest#testRegisteredNamespaceVisibility
                 org.apache.jackrabbit.test.api.ShareableNodeTest
                 org.apache.jackrabbit.test.api.version.simple
-                org.apache.jackrabbit.test.api.version.ActivitiesTest
-                org.apache.jackrabbit.test.api.version.MergeActivityTest
-                org.apache.jackrabbit.test.api.version.ConfigurationsTest
+                org.apache.jackrabbit.test.api.version.ActivitiesTest#testActivitiesPath
+                org.apache.jackrabbit.test.api.version.ActivitiesTest#testActivitiesRelation
+                org.apache.jackrabbit.test.api.version.ConfigurationsTest#testCreateConfigWithBaseline
                 org.apache.jackrabbit.test.api.LifecycleTest
                 org.apache.jackrabbit.test.api.RepositoryDescriptorTest#testRequiredDescriptors
                 org.apache.jackrabbit.test.api.RepositoryDescriptorTest#testGetDescriptorValues

Modified: jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/RepositoryServiceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/RepositoryServiceImpl.java?rev=803444&r1=803443&r2=803444&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/RepositoryServiceImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/RepositoryServiceImpl.java
Wed Aug 12 11:02:10 2009
@@ -684,7 +684,22 @@
         final SessionInfoImpl sInfo = getSessionInfoImpl(sessionInfo);
         executeWithLocalEvents(new Callable() {
             public Object run() throws RepositoryException {
-                getNode(nodeId, getSessionInfoImpl(sessionInfo)).checkout();
+                getNode(nodeId, sInfo).checkout();
+                return null;
+            }
+        }, sInfo);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void checkout(final SessionInfo sessionInfo, final NodeId nodeId, NodeId activityId)
throws UnsupportedRepositoryOperationException, LockException, RepositoryException {
+        final SessionInfoImpl sInfo = getSessionInfoImpl(sessionInfo);
+        Node activity = (activityId == null) ? null : getNode(activityId, sInfo);
+        sInfo.getSession().getWorkspace().getVersionManager().setActivity(activity);
+        executeWithLocalEvents(new Callable() {
+            public Object run() throws RepositoryException {
+                getNode(nodeId, sInfo).checkout();
                 return null;
             }
         }, sInfo);
@@ -966,11 +981,10 @@
     public void removeActivity(SessionInfo sessionInfo, final NodeId activityId) throws UnsupportedRepositoryOperationException,
RepositoryException {
         final SessionInfoImpl sInfo = getSessionInfoImpl(sessionInfo);
         final VersionManager vMgr = getVersionManager(sInfo);
-        Node activity = (Node) executeWithLocalEvents(new Callable() {
+        executeWithLocalEvents(new Callable() {
             public Object run() throws RepositoryException {
-                // TODO: uncomment as soon as removeActivity method is fixed in jsr 283
-                // return vMgr.removeActivity(getNode(activityId, sInfo));
-                throw new UnsupportedOperationException("Impl missing... waiting for updated
jsr 283 jar.");
+                vMgr.removeActivity(getNode(activityId, sInfo));
+                return null;
             }
         }, getSessionInfoImpl(sessionInfo));
     }



Mime
View raw message