jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From resc...@apache.org
Subject svn commit: r649071 - in /jackrabbit/trunk: jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/ jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version...
Date Thu, 17 Apr 2008 12:44:47 GMT
Author: reschke
Date: Thu Apr 17 05:44:41 2008
New Revision: 649071

URL: http://svn.apache.org/viewvc?rev=649071&view=rev
Log:
JCR-1513: allow RepositoryService.checkin() to return the NodeId of the created version; use
it in JCR2SPI; implement it in SPI2JCR. 

Modified:
    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/operation/Checkin.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/DefaultVersionManager.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-spi/src/main/java/org/apache/jackrabbit/spi/RepositoryService.java
    jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/RepositoryServiceImpl.java

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=649071&r1=649070&r2=649071&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
Thu Apr 17 05:44:41 2008
@@ -767,13 +767,14 @@
         checkIsVersionable();
         checkHasPendingChanges();
         checkIsLocked();
+        NodeEntry newVersion = null;
         if (isCheckedOut()) {
-            session.getVersionManager().checkin(getNodeState());
+            newVersion = session.getVersionManager().checkin(getNodeState());
         } else {
             // nothing to do
             log.debug("Node " + safeGetJCRPath() + " is already checked in.");
         }
-        return getBaseVersion();
+        return newVersion == null ? getBaseVersion() : (Version) itemMgr.getItem(newVersion);
     }
 
     /**

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=649071&r1=649070&r2=649071&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
Thu Apr 17 05:44:41 2008
@@ -911,7 +911,8 @@
          * @see OperationVisitor#visit(Checkin)
          */
         public void visit(Checkin operation) throws UnsupportedRepositoryOperationException,
LockException, InvalidItemStateException, RepositoryException {
-            service.checkin(sessionInfo, operation.getNodeId());
+            NodeId newId = service.checkin(sessionInfo, operation.getNodeId());
+            operation.setNewVersionId(newId);
         }
 
         /**

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Checkin.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Checkin.java?rev=649071&r1=649070&r2=649071&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Checkin.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Checkin.java
Thu Apr 17 05:44:41 2008
@@ -43,6 +43,8 @@
     private final NodeState nodeState;
     private final VersionManager mgr;
 
+    private NodeId newVersionId;
+
     private Checkin(NodeState nodeState, VersionManager mgr) {
         this.nodeState = nodeState;
         this.mgr = mgr;
@@ -77,6 +79,7 @@
         nodeState.getHierarchyEntry().invalidate(false);
     }
     //----------------------------------------< Access Operation Parameters >---
+    
     /**
      *
      * @return The nodeState to be checked in.
@@ -85,6 +88,14 @@
         return nodeState.getNodeEntry().getWorkspaceId();
     }
 
+    public void setNewVersionId(NodeId newVersionId) {
+        this.newVersionId = newVersionId;
+    }
+
+    public NodeId getNewVersionId() {
+        return this.newVersionId;
+    }
+    
     //------------------------------------------------------------< Factory >---
     /**
      *
@@ -92,7 +103,7 @@
      * @param mgr
      * @return
      */
-    public static Operation create(NodeState nodeState, VersionManager mgr) {
+    public static Checkin create(NodeState nodeState, VersionManager mgr) {
         return new Checkin(nodeState, mgr);
     }
 }

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/DefaultVersionManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/DefaultVersionManager.java?rev=649071&r1=649070&r2=649071&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/DefaultVersionManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/DefaultVersionManager.java
Thu Apr 17 05:44:41 2008
@@ -37,7 +37,7 @@
 
     private static Logger log = LoggerFactory.getLogger(DefaultVersionManager.class);
 
-    public void checkin(NodeState nodeState) throws RepositoryException {
+    public NodeEntry checkin(NodeState nodeState) throws RepositoryException {
         throw new UnsupportedRepositoryOperationException("Versioning ist not supported by
this repository.");
     }
 

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=649071&r1=649070&r2=649071&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
Thu Apr 17 05:44:41 2008
@@ -41,6 +41,7 @@
 
     /**
      * @param nodeState
+     * @return <code>NodeEntry</code> of newly created version or <code>null</code>
      * @throws VersionException
      * @throws UnsupportedRepositoryOperationException
      * @throws InvalidItemStateException
@@ -48,7 +49,7 @@
      * @throws RepositoryException
      * @see javax.jcr.Node#checkin()
      */
-    public void checkin(NodeState nodeState) throws VersionException, UnsupportedRepositoryOperationException,
InvalidItemStateException, LockException, RepositoryException;
+    public NodeEntry checkin(NodeState nodeState) throws VersionException, UnsupportedRepositoryOperationException,
InvalidItemStateException, LockException, RepositoryException;
 
     /**
      * @param nodeState

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=649071&r1=649070&r2=649071&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
Thu Apr 17 05:44:41 2008
@@ -58,9 +58,15 @@
         this.workspaceManager = workspaceManager;
     }
 
-    public void checkin(NodeState nodeState) throws RepositoryException {
-        Operation ci = Checkin.create(nodeState, this);
+    public NodeEntry checkin(NodeState nodeState) throws RepositoryException {
+        Checkin ci = Checkin.create(nodeState, this);
         workspaceManager.execute(ci);
+        if (ci.getNewVersionId() == null) {
+            return null;
+        }
+        else {
+            return (NodeEntry) workspaceManager.getHierarchyManager().getHierarchyEntry(ci.getNewVersionId());
+        }
     }
 
     public void checkout(NodeState nodeState) 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=649071&r1=649070&r2=649071&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
Thu Apr 17 05:44:41 2008
@@ -584,8 +584,10 @@
      * @throws javax.jcr.lock.LockException
      * @throws javax.jcr.RepositoryException
      * @see javax.jcr.Node#checkin()
+     * @return <code>NodeId</code> of newly created version, or <code>null</code>
+     * when that information is not available
      */
-    public void checkin(SessionInfo sessionInfo, NodeId nodeId) throws VersionException,
UnsupportedRepositoryOperationException, InvalidItemStateException, LockException, RepositoryException;
+    public NodeId checkin(SessionInfo sessionInfo, NodeId nodeId) throws VersionException,
UnsupportedRepositoryOperationException, InvalidItemStateException, LockException, RepositoryException;
 
     /**
      * Performs a checkout for the <code>Node</code> identified by the given

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=649071&r1=649070&r2=649071&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
Thu Apr 17 05:44:41 2008
@@ -626,15 +626,15 @@
     /**
      * {@inheritDoc}
      */
-    public void checkin(final SessionInfo sessionInfo, final NodeId nodeId)
+    public NodeId checkin(final SessionInfo sessionInfo, final NodeId nodeId)
             throws VersionException, UnsupportedRepositoryOperationException, InvalidItemStateException,
LockException, RepositoryException {
         final SessionInfoImpl sInfo = getSessionInfoImpl(sessionInfo);
-        executeWithLocalEvents(new Callable() {
+        Version newVersion = (Version) executeWithLocalEvents(new Callable() {
             public Object run() throws RepositoryException {
-                getNode(nodeId, getSessionInfoImpl(sessionInfo)).checkin();
-                return null;
+                return getNode(nodeId, getSessionInfoImpl(sessionInfo)).checkin();
             }
         }, sInfo);
+        return idFactory.createNodeId(newVersion, sInfo.getNamePathResolver());
     }
 
     /**



Mime
View raw message