jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r918491 - in /jackrabbit/trunk: jackrabbit-jcr-client/src/test/java/org/apache/jackrabbit/client/ jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/ jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ jac...
Date Wed, 03 Mar 2010 14:41:01 GMT
Author: angela
Date: Wed Mar  3 14:41:00 2010
New Revision: 918491

URL: http://svn.apache.org/viewvc?rev=918491&view=rev
Log:
JCR-2104: JSR 283 Full Versioning
- checkpoint must be aware of current activity for the checkout part
- minor improvements such as @Override annotations, removal of unused params, methods, use generics whereever possible


Modified:
    jackrabbit/trunk/jackrabbit-jcr-client/src/test/java/org/apache/jackrabbit/client/RepositoryFactoryImplTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/ActivitiesTest.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/operation/Checkpoint.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/AbstractRepositoryService.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-spi2dav/src/test/java/org/apache/jackrabbit/spi2dav/RepositoryStubImpl.java
    jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/BatchReadConfig.java
    jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/EventSubscription.java
    jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/IdFactoryImpl.java
    jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/LockInfoImpl.java
    jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/NodeInfoImpl.java
    jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/PropertyInfoImpl.java
    jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/QueryInfoImpl.java
    jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/RepositoryServiceImpl.java
    jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/SessionInfoImpl.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=918491&r1=918490&r2=918491&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 Mar  3 14:41:00 2010
@@ -107,14 +107,14 @@
     public void testGetRepositoryWithLogger() throws RepositoryException {
         List<Object> lwprovider = new ArrayList<Object>();
         lwprovider.add(null);
-        lwprovider.add(new Boolean(true));
+        lwprovider.add(true);
         lwprovider.add(new Slf4jLogWriterProvider());
 
         Map<String, Object> params = new HashMap<String, Object>();
         params.put("org.apache.jackrabbit.jcr2spi.RepositoryConfig", RepositoryConfigImpl.INSTANCE);
 
-        for (int i = 0; i < lwprovider.size(); i++) {
-            params.put("org.apache.jackrabbit.spi.commons.logging.LogWriterProvider", lwprovider.get(i));
+        for (Object aLwprovider : lwprovider) {
+            params.put("org.apache.jackrabbit.spi.commons.logging.LogWriterProvider", aLwprovider);
             Repository repo = factory.getRepository(params);
             assertNotNull(repo);
         }
@@ -181,7 +181,7 @@
     }
 
     public void testGetRepositoryUnknownParams() throws RepositoryException {
-        Repository repo = factory.getRepository(Collections.EMPTY_MAP);
+        Repository repo = factory.getRepository(Collections.emptyMap());
         assertNull(repo);
     }
 
@@ -381,6 +381,10 @@
             return null;
         }
 
+        public NodeId checkpoint(SessionInfo sessionInfo, NodeId nodeId, NodeId activityId) throws UnsupportedRepositoryOperationException, RepositoryException {
+            return null;
+        }
+
         public void removeVersion(SessionInfo sessionInfo, NodeId versionHistoryId, NodeId versionId) throws ReferentialIntegrityException, AccessDeniedException, UnsupportedRepositoryOperationException, VersionException, RepositoryException {
             // empty
         }

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/ActivitiesTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/ActivitiesTest.java?rev=918491&r1=918490&r2=918491&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/ActivitiesTest.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/ActivitiesTest.java Wed Mar  3 14:41:00 2010
@@ -154,5 +154,32 @@
         }
     }
 
+    public void testActivitiesRelationWithCheckpoint() throws Exception {
+
+        Node an = null;
+
+        try {
+            an = vm.createActivity("foobar2");
+            vm.setActivity(an);
+
+            String path = versionableNode.getPath();
+
+            vm.checkpoint(path);
+
+            versionableNode = superuser.getNode(path);
+            Property act = versionableNode.getProperty(Property.JCR_ACTIVITY);
+            assertNotNull(act);
+            assertEquals(PropertyType.REFERENCE, act.getType());
+            assertTrue(act.getNode().isSame(an));
+
+            versionableNode.remove();
+            superuser.save();
+        }
+        finally {
+            if (an != null) {
+                vm.removeActivity(an);
+            }
+        }
+    }
 }
 

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=918491&r1=918490&r2=918491&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 Mar  3 14:41:00 2010
@@ -902,7 +902,14 @@
             checkout();
             return getBaseVersion();
         } else {
-            NodeEntry newVersion = session.getVersionStateManager().checkpoint(getNodeState());
+            NodeEntry newVersion;
+            if (session.isSupportedOption(Repository.OPTION_ACTIVITIES_SUPPORTED)) {
+                NodeImpl activity = (NodeImpl) session.getWorkspace().getVersionManager().getActivity();
+                NodeId activityId = (activity == null) ? null : activity.getNodeState().getNodeId();
+                newVersion = session.getVersionStateManager().checkpoint(getNodeState(), activityId);
+            } else {
+                newVersion = session.getVersionStateManager().checkpoint(getNodeState());
+            }
             return (Version) getItemManager().getItem(newVersion);
         }
     }
@@ -1304,9 +1311,8 @@
             return true;
         }
         // check if contained in mixin types
-        Name[] mixins = getNodeState().getMixinTypeNames();
-        for (int i = 0; i < mixins.length; i++) {
-            if (mixins[i].equals(qName)) {
+        for (Name mixin : getNodeState().getMixinTypeNames()) {
+            if (mixin.equals(qName)) {
                 return true;
             }
         }
@@ -1521,7 +1527,7 @@
     }
 
     /**
-     * Create a new multivalue property
+     * Create a new multi valued property
      *
      * @param qName
      * @param type
@@ -1539,9 +1545,9 @@
             if (type == PropertyType.UNDEFINED) {
                 // try to retrieve type from the values array
                 if (values.length > 0) {
-                    for (int i = 0; i < values.length; i++) {
-                        if (values[i] != null) {
-                            targetType = values[i].getType();
+                    for (Value value : values) {
+                        if (value != null) {
+                            targetType = value.getType();
                             break;
                         }
                     }

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=918491&r1=918490&r2=918491&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 Mar  3 14:41:00 2010
@@ -977,7 +977,12 @@
          * @see OperationVisitor#visit(Checkpoint)
          */
         public void visit(Checkpoint operation) throws UnsupportedRepositoryOperationException, LockException, InvalidItemStateException, RepositoryException {
-            NodeId newId = service.checkpoint(sessionInfo, operation.getNodeId());
+            NodeId newId;
+            if (operation.supportsActivity()) {
+                newId = service.checkpoint(sessionInfo, operation.getNodeId(), operation.getActivityId());
+            } else {
+                newId = service.checkpoint(sessionInfo, operation.getNodeId());
+            }
             operation.setNewVersionId(newId);
         }
 

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Checkpoint.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Checkpoint.java?rev=918491&r1=918490&r2=918491&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Checkpoint.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Checkpoint.java Wed Mar  3 14:41:00 2010
@@ -42,13 +42,26 @@
 
     private final NodeState nodeState;
     private final VersionManager mgr;
-    
+
+    private final NodeId activityId;
+    private final boolean supportsActivity;
+
     private NodeId newVersionId;
 
     private Checkpoint(NodeState nodeState, VersionManager mgr) {
         this.nodeState = nodeState;
         this.mgr = mgr;
         // NOTE: affected-states only needed for transient modifications
+        supportsActivity = false;
+        activityId = null;
+    }
+
+    private Checkpoint(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
     }
 
     //----------------------------------------------------------< Operation >---
@@ -92,6 +105,26 @@
         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;
+    }
+
     public void setNewVersionId(NodeId newVersionId) {
         this.newVersionId = newVersionId;
     }
@@ -104,4 +137,8 @@
     public static Checkpoint create(NodeState nodeState, VersionManager mgr) {
         return new Checkpoint(nodeState, mgr);
     }
+
+    public static Checkpoint create(NodeState nodeState, NodeId activityId, VersionManager mgr) {
+        return new Checkpoint(nodeState, activityId, mgr);
+    }
 }
\ No newline at end of file

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=918491&r1=918490&r2=918491&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 Mar  3 14:41:00 2010
@@ -78,6 +78,12 @@
 
     /**
      * @param nodeState
+     * @throws RepositoryException
+     * @see javax.jcr.version.VersionManager#checkpoint(String)
+     */
+    public NodeEntry checkpoint(NodeState nodeState, NodeId activityId) throws RepositoryException;
+    /**
+     * @param nodeState
      * @return
      * @throws RepositoryException
      * @see javax.jcr.Node#isCheckedOut()

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=918491&r1=918490&r2=918491&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 Mar  3 14:41:00 2010
@@ -85,6 +85,12 @@
         return workspaceManager.getHierarchyManager().getNodeEntry(cp.getNewVersionId());
     }
 
+    public NodeEntry checkpoint(NodeState nodeState, NodeId activityId) throws RepositoryException {
+        Checkpoint cp = Checkpoint.create(nodeState, activityId, this);
+        workspaceManager.execute(cp);
+        return workspaceManager.getHierarchyManager().getNodeEntry(cp.getNewVersionId());
+    }
+
     /**
      * Search nearest ancestor that is versionable. If no versionable ancestor
      * can be found, <code>true</code> is returned.

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=918491&r1=918490&r2=918491&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 Mar  3 14:41:00 2010
@@ -427,6 +427,11 @@
         return repositoryService.checkpoint(sessionInfo, nodeId);
     }
 
+    public NodeId checkpoint(SessionInfo sessionInfo, NodeId nodeId, NodeId activityId)
+            throws RepositoryException {
+        return repositoryService.checkpoint(sessionInfo, nodeId, activityId);
+    }
+
     public void removeVersion(SessionInfo sessionInfo, NodeId versionHistoryId, NodeId versionId)
             throws RepositoryException {
 

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/AbstractRepositoryService.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/AbstractRepositoryService.java?rev=918491&r1=918490&r2=918491&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/AbstractRepositoryService.java (original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/AbstractRepositoryService.java Wed Mar  3 14:41:00 2010
@@ -643,6 +643,14 @@
     /**
      * @throws UnsupportedRepositoryOperationException always.
      */
+    public NodeId checkpoint(SessionInfo sessionInfo, NodeId nodeId, NodeId activityId)
+            throws UnsupportedRepositoryOperationException, LockException, RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    /**
+     * @throws UnsupportedRepositoryOperationException always.
+     */
     public void removeVersion(SessionInfo sessionInfo,
                               NodeId versionHistoryId,
                               NodeId versionId)

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=918491&r1=918490&r2=918491&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 Mar  3 14:41:00 2010
@@ -426,6 +426,14 @@
         }, "checkpoint(SessionInfo, NodeId)", new Object[]{unwrap(sessionInfo), nodeId});
     }
 
+    public NodeId checkpoint(final SessionInfo sessionInfo, final NodeId nodeId, final NodeId activityId) throws UnsupportedRepositoryOperationException, RepositoryException {
+        return (NodeId) execute(new Callable() {
+            public Object call() throws RepositoryException {
+                return service.checkpoint(unwrap(sessionInfo), nodeId, activityId);
+            }
+        }, "checkpoint(SessionInfo, NodeId, NodeId)", new Object[]{unwrap(sessionInfo), nodeId, activityId});
+    }
+
     public void removeVersion(final SessionInfo sessionInfo, final NodeId versionHistoryId,
             final NodeId versionId) throws RepositoryException {
 
@@ -538,8 +546,8 @@
                 new Object[]{unwrap(sessionInfo), activityId});
     }
 
-    public Iterator mergeActivity(final SessionInfo sessionInfo, final NodeId activityId) throws UnsupportedRepositoryOperationException, RepositoryException {
-        return (Iterator) execute(new Callable() {
+    public Iterator<NodeId> mergeActivity(final SessionInfo sessionInfo, final NodeId activityId) throws UnsupportedRepositoryOperationException, RepositoryException {
+        return (Iterator<NodeId>) execute(new Callable() {
             public Object call() throws RepositoryException {
                 return service.mergeActivity(unwrap(sessionInfo), activityId);
             }

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=918491&r1=918490&r2=918491&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 Mar  3 14:41:00 2010
@@ -665,6 +665,21 @@
     public NodeId checkpoint(SessionInfo sessionInfo, NodeId nodeId) throws UnsupportedRepositoryOperationException, RepositoryException;
 
     /**
+     * Performs a checkpoint for the <code>Node</code> identified by the given
+     * <code>NodeId</code>. For the checkout part the specified <code>activityId</code>
+     * is taken into account as specified in {@link #checkout(SessionInfo, NodeId, 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 NodeId checkpoint(SessionInfo sessionInfo, NodeId nodeId, NodeId activityId)  throws UnsupportedRepositoryOperationException, RepositoryException;
+    /**
      * Remove the version inditified by the specified <code>versionId</code>.
      *
      * @param sessionInfo

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=918491&r1=918490&r2=918491&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 Mar  3 14:41:00 2010
@@ -1528,6 +1528,18 @@
     }
 
     /**
+     * @see RepositoryService#checkpoint(SessionInfo, NodeId, NodeId)
+     */
+    public NodeId checkpoint(SessionInfo sessionInfo, NodeId nodeId, NodeId activityId) throws UnsupportedRepositoryOperationException, RepositoryException {
+        if (activityId == null) {
+            return checkpoint(sessionInfo, nodeId);
+        } else {
+            // TODO
+            throw new UnsupportedOperationException("JCR-2104: JSR 283 Versioning. Implementation missing");
+        }
+    }
+
+    /**
      * @see RepositoryService#removeVersion(SessionInfo, NodeId, NodeId)
      */
     public void removeVersion(SessionInfo sessionInfo, NodeId versionHistoryId, NodeId versionId) throws RepositoryException {

Modified: jackrabbit/trunk/jackrabbit-spi2dav/src/test/java/org/apache/jackrabbit/spi2dav/RepositoryStubImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi2dav/src/test/java/org/apache/jackrabbit/spi2dav/RepositoryStubImpl.java?rev=918491&r1=918490&r2=918491&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi2dav/src/test/java/org/apache/jackrabbit/spi2dav/RepositoryStubImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-spi2dav/src/test/java/org/apache/jackrabbit/spi2dav/RepositoryStubImpl.java Wed Mar  3 14:41:00 2010
@@ -41,7 +41,7 @@
 /**
  * <code>RepositoryStubImpl</code>...
  */
-public class RepositoryStubImpl  extends RepositoryStub {
+public class RepositoryStubImpl extends RepositoryStub {
 
     /**
      * Property for the repository url

Modified: jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/BatchReadConfig.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/BatchReadConfig.java?rev=918491&r1=918490&r2=918491&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/BatchReadConfig.java (original)
+++ jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/BatchReadConfig.java Wed Mar  3 14:41:00 2010
@@ -31,7 +31,7 @@
     public static final int DEPTH_DEFAULT = 0;
     public static final int DEPTH_INFINITE = -1;
 
-    private Map depthMap = new HashMap(0);
+    private Map<Name, Integer> depthMap = new HashMap<Name, Integer>(0);
 
     /**
      * Return the depth for the given node type name. If the name is
@@ -47,7 +47,7 @@
      */
     public int getDepth(Name ntName) {
         if (depthMap.containsKey(ntName)) {
-            return ((Integer) (depthMap.get(ntName))).intValue();
+            return depthMap.get(ntName);
         } else {
             return DEPTH_DEFAULT;
         }
@@ -63,6 +63,6 @@
         if (ntName == null || depth < DEPTH_INFINITE) {
             throw new IllegalArgumentException();
         }
-        depthMap.put(ntName, new Integer(depth));
+        depthMap.put(ntName, depth);
     }
 }

Modified: jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/EventSubscription.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/EventSubscription.java?rev=918491&r1=918490&r2=918491&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/EventSubscription.java (original)
+++ jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/EventSubscription.java Wed Mar  3 14:41:00 2010
@@ -101,13 +101,6 @@
     }
 
     /**
-     * @return the session info associated with this event subscription.
-     */
-    SessionInfoImpl getSessionInfo() {
-        return sessionInfo;
-    }
-
-    /**
      * Sets a new list of event filters for this subscription.
      *
      * @param filters the new filters.
@@ -175,22 +168,21 @@
                     // continue
                 }
             }
-            bundles = (EventBundle[]) eventBundles.toArray(new EventBundle[eventBundles.size()]);
+            bundles = eventBundles.toArray(new EventBundle[eventBundles.size()]);
             eventBundles.clear();
         }
-        EventFilter[] eventFilters = (EventFilter[]) filters.toArray(
-                new EventFilter[filters.size()]);
+        EventFilter[] eventFilters = filters.toArray(new EventFilter[filters.size()]);
         // apply filters to bundles
         for (int i = 0; i < bundles.length; i++) {
-            List filteredEvents = new ArrayList();
-            for (Iterator it = bundles[i].getEvents(); it.hasNext(); ) {
-                Event e = (Event) it.next();
+            List<Event> filteredEvents = new ArrayList<Event>();
+            for (Iterator<Event> it = bundles[i].getEvents(); it.hasNext(); ) {
+                Event e = it.next();
                 // TODO: this is actually not correct. if filters are empty no event should go out
                 if (eventFilters == null || eventFilters.length == 0) {
                     filteredEvents.add(e);
                 } else {
-                    for (int j = 0; j < eventFilters.length; j++) {
-                        if (eventFilters[j].accept(e, bundles[i].isLocal())) {
+                    for (EventFilter eventFilter : eventFilters) {
+                        if (eventFilter.accept(e, bundles[i].isLocal())) {
                             filteredEvents.add(e);
                             break;
                         }

Modified: jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/IdFactoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/IdFactoryImpl.java?rev=918491&r1=918490&r2=918491&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/IdFactoryImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/IdFactoryImpl.java Wed Mar  3 14:41:00 2010
@@ -17,7 +17,6 @@
 package org.apache.jackrabbit.spi2jcr;
 
 import org.apache.jackrabbit.spi.commons.name.PathFactoryImpl;
-import org.apache.jackrabbit.spi.commons.name.PathBuilder;
 import org.apache.jackrabbit.spi.IdFactory;
 import org.apache.jackrabbit.spi.PropertyId;
 import org.apache.jackrabbit.spi.NodeId;
@@ -44,6 +43,7 @@
         return INSTANCE;
     }
 
+    @Override
     protected PathFactory getPathFactory() {
         return PathFactoryImpl.getInstance();
     }
@@ -51,15 +51,11 @@
      * Creates a <code>NodeId</code> for the given <code>node</code>.
      *
      * @param node       the JCR Node.
-     * @param resolver
      * @return the <code>NodeId</code> for <code>node</code>.
      * @throws RepositoryException if an error occurs while reading from
      *                             <code>node</code>.
      */
-    public NodeId createNodeId(Node node, NamePathResolver resolver)
-            throws RepositoryException {
-        PathBuilder builder = new PathBuilder();
-        int pathElements = 0;
+    public NodeId createNodeId(Node node) throws RepositoryException {
         String uniqueId = node.getIdentifier();
         return createNodeId(uniqueId);
     }
@@ -77,7 +73,7 @@
                                        NamePathResolver resolver)
             throws RepositoryException {
         Node parent = property.getParent();
-        NodeId nodeId = createNodeId(parent, resolver);
+        NodeId nodeId = createNodeId(parent);
         String jcrName = property.getName();
         Name name;
         try {
@@ -87,4 +83,4 @@
         }
         return createPropertyId(nodeId, name);
     }
-}
\ No newline at end of file
+}

Modified: jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/LockInfoImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/LockInfoImpl.java?rev=918491&r1=918490&r2=918491&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/LockInfoImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/LockInfoImpl.java Wed Mar  3 14:41:00 2010
@@ -33,15 +33,13 @@
      *
      * @param lock the lock.
      * @param idFactory the id factory.
-     * @param resolver the name and path resolver.
      * @throws RepositoryException if an error occurs while the node from the
      * given lock or while creating the node id.
      */
-    private LockInfoImpl(Lock lock, IdFactoryImpl idFactory,
-                         NamePathResolver resolver) throws RepositoryException {
+    private LockInfoImpl(Lock lock, IdFactoryImpl idFactory) throws RepositoryException {
         super(lock.getLockToken(), lock.getLockOwner(), lock.isDeep(),
                 lock.isSessionScoped(), lock.getSecondsRemaining(), lock.isLockOwningSession(), 
-                idFactory.createNodeId(lock.getNode(), resolver));
+                idFactory.createNodeId(lock.getNode()));
     }
 
     /**
@@ -49,11 +47,10 @@
      * 
      * @param lock the JCR lock.
      * @param idFactory the id factory.
-     * @param resolver the name and path resolver.
      * @return a new <code>LockInfo</code>
      * @throws RepositoryException If an error occurs while creating the info.
      */
-    public static LockInfo createLockInfo(Lock lock, IdFactoryImpl idFactory, NamePathResolver resolver) throws RepositoryException {
-        return new LockInfoImpl(lock, idFactory, resolver);
+    public static LockInfo createLockInfo(Lock lock, IdFactoryImpl idFactory) throws RepositoryException {
+        return new LockInfoImpl(lock, idFactory);
     }
 }
\ No newline at end of file

Modified: jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/NodeInfoImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/NodeInfoImpl.java?rev=918491&r1=918490&r2=918491&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/NodeInfoImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/NodeInfoImpl.java Wed Mar  3 14:41:00 2010
@@ -17,6 +17,8 @@
 package org.apache.jackrabbit.spi2jcr;
 
 import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.PropertyId;
+import org.apache.jackrabbit.spi.ChildInfo;
 import org.apache.jackrabbit.spi.commons.conversion.NameException;
 import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
 
@@ -50,7 +52,7 @@
                         NamePathResolver resolver)
             throws RepositoryException, NameException {
         super(resolver.getQPath(node.getPath()),
-                idFactory.createNodeId(node, resolver), node.getIndex(),
+                idFactory.createNodeId(node), node.getIndex(),
                 resolver.getQName(node.getPrimaryNodeType().getName()),
                 getNodeTypeNames(node.getMixinNodeTypes(), resolver),
                 getPropertyIds(node.getReferences(), resolver, idFactory),
@@ -90,20 +92,20 @@
      * @throws RepositoryException if an error occurs while reading from the
      *                             properties.
      */
-    private static Iterator getPropertyIds(PropertyIterator props,
-                                              NamePathResolver resolver,
-                                              IdFactoryImpl idFactory)
+    private static Iterator<PropertyId> getPropertyIds(PropertyIterator props,
+                                                       NamePathResolver resolver,
+                                                       IdFactoryImpl idFactory)
             throws RepositoryException {
-        List references = new ArrayList();
+        List<PropertyId> references = new ArrayList<PropertyId>();
         while (props.hasNext()) {
             references.add(idFactory.createPropertyId(props.nextProperty(), resolver));
         }
         return references.iterator();
     }
 
-    private static Iterator getChildInfos(NodeIterator childNodes,
-                                          NamePathResolver resolver) throws RepositoryException {
-        List childInfos = new ArrayList();
+    private static Iterator<ChildInfo> getChildInfos(NodeIterator childNodes,
+                                                     NamePathResolver resolver) throws RepositoryException {
+        List<ChildInfo> childInfos = new ArrayList<ChildInfo>();
         while (childNodes.hasNext()) {
             childInfos.add(new ChildInfoImpl(childNodes.nextNode(), resolver));
         }

Modified: jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/PropertyInfoImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/PropertyInfoImpl.java?rev=918491&r1=918490&r2=918491&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/PropertyInfoImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/PropertyInfoImpl.java Wed Mar  3 14:41:00 2010
@@ -46,8 +46,7 @@
     public PropertyInfoImpl(Property property,
                             IdFactoryImpl idFactory,
                             NamePathResolver resolver,
-                            QValueFactory qValueFactory)
-            throws RepositoryException, NameException {
+                            QValueFactory qValueFactory) throws RepositoryException, NameException {
         super(resolver.getQPath(property.getPath()),
                 idFactory.createPropertyId(property, resolver),
                 property.getType(), property.isMultiple(),
@@ -65,8 +64,7 @@
      */
     private static QValue[] getValues(Property property,
                                       NamePathResolver resolver,
-                                      QValueFactory factory)
-            throws RepositoryException {
+                                      QValueFactory factory) throws RepositoryException {
         boolean isMultiValued = property.isMultiple();
         QValue[] values;
         if (isMultiValued) {
@@ -77,7 +75,8 @@
             }
         } else {
             values = new QValue[]{
-                ValueFormat.getQValue(property.getValue(), resolver, factory)};
+                    ValueFormat.getQValue(property.getValue(), resolver, factory)
+            };
         }
         return values;
     }

Modified: jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/QueryInfoImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/QueryInfoImpl.java?rev=918491&r1=918490&r2=918491&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/QueryInfoImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/QueryInfoImpl.java Wed Mar  3 14:41:00 2010
@@ -103,6 +103,7 @@
     public RangeIterator getRows() {
         try {
             return new RangeIteratorDecorator(result.getRows()) {
+                @Override
                 public Object next() {
                     try {
                         return new QueryResultRowImpl(

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=918491&r1=918490&r2=918491&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 Mar  3 14:41:00 2010
@@ -16,115 +16,116 @@
  */
 package org.apache.jackrabbit.spi2jcr;
 
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.security.AccessControlException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import org.apache.jackrabbit.spi.ItemInfoCache;
+import org.apache.jackrabbit.spi.RepositoryService;
+import org.apache.jackrabbit.spi.IdFactory;
+import org.apache.jackrabbit.spi.QValueFactory;
+import org.apache.jackrabbit.spi.SessionInfo;
+import org.apache.jackrabbit.spi.ItemId;
+import org.apache.jackrabbit.spi.NodeId;
+import org.apache.jackrabbit.spi.QNodeDefinition;
+import org.apache.jackrabbit.spi.QPropertyDefinition;
+import org.apache.jackrabbit.spi.PropertyId;
+import org.apache.jackrabbit.spi.NodeInfo;
+import org.apache.jackrabbit.spi.PropertyInfo;
+import org.apache.jackrabbit.spi.Batch;
+import org.apache.jackrabbit.spi.LockInfo;
+import org.apache.jackrabbit.spi.QueryInfo;
+import org.apache.jackrabbit.spi.EventFilter;
+import org.apache.jackrabbit.spi.EventBundle;
+import org.apache.jackrabbit.spi.QValue;
+import org.apache.jackrabbit.spi.NameFactory;
+import org.apache.jackrabbit.spi.PathFactory;
+import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.Path;
+import org.apache.jackrabbit.spi.Subscription;
+import org.apache.jackrabbit.spi.QNodeTypeDefinition;
+import org.apache.jackrabbit.spi.Event;
+import org.apache.jackrabbit.spi.ItemInfo;
+import org.apache.jackrabbit.spi.ChildInfo;
+import org.apache.jackrabbit.spi.commons.EventFilterImpl;
+import org.apache.jackrabbit.spi.commons.EventBundleImpl;
+import org.apache.jackrabbit.spi.commons.ItemInfoCacheImpl;
+import org.apache.jackrabbit.spi.commons.QPropertyDefinitionImpl;
+import org.apache.jackrabbit.spi.commons.QNodeDefinitionImpl;
+import org.apache.jackrabbit.spi.commons.QNodeTypeDefinitionImpl;
+import org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver;
+import org.apache.jackrabbit.spi.commons.nodetype.NodeTypeDefinitionImpl;
+import org.apache.jackrabbit.spi.commons.name.NameFactoryImpl;
+import org.apache.jackrabbit.spi.commons.name.PathFactoryImpl;
+import org.apache.jackrabbit.spi.commons.name.NameConstants;
+import org.apache.jackrabbit.spi.commons.name.PathBuilder;
+import org.apache.jackrabbit.spi.commons.conversion.NameException;
+import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
+import org.apache.jackrabbit.spi.commons.conversion.MalformedPathException;
+import org.apache.jackrabbit.spi.commons.conversion.DefaultNamePathResolver;
+import org.apache.jackrabbit.spi.commons.value.QValueFactoryImpl;
+import org.apache.jackrabbit.spi.commons.value.ValueFormat;
+import org.apache.jackrabbit.spi.commons.value.ValueFactoryQImpl;
+import org.apache.jackrabbit.JcrConstants;
 
-import javax.jcr.AccessDeniedException;
+import javax.jcr.RepositoryException;
 import javax.jcr.Credentials;
-import javax.jcr.GuestCredentials;
-import javax.jcr.ImportUUIDBehavior;
-import javax.jcr.InvalidItemStateException;
-import javax.jcr.ItemExistsException;
-import javax.jcr.ItemNotFoundException;
-import javax.jcr.ItemVisitor;
 import javax.jcr.LoginException;
-import javax.jcr.MergeException;
-import javax.jcr.NamespaceException;
-import javax.jcr.NamespaceRegistry;
 import javax.jcr.NoSuchWorkspaceException;
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
+import javax.jcr.ItemNotFoundException;
 import javax.jcr.PathNotFoundException;
-import javax.jcr.Property;
-import javax.jcr.PropertyIterator;
+import javax.jcr.ValueFormatException;
+import javax.jcr.AccessDeniedException;
+import javax.jcr.UnsupportedRepositoryOperationException;
+import javax.jcr.ItemExistsException;
+import javax.jcr.InvalidItemStateException;
 import javax.jcr.ReferentialIntegrityException;
+import javax.jcr.MergeException;
+import javax.jcr.NamespaceException;
 import javax.jcr.Repository;
-import javax.jcr.RepositoryException;
 import javax.jcr.Session;
-import javax.jcr.UnsupportedRepositoryOperationException;
+import javax.jcr.Node;
+import javax.jcr.Property;
+import javax.jcr.NodeIterator;
+import javax.jcr.NamespaceRegistry;
+import javax.jcr.Workspace;
+import javax.jcr.ImportUUIDBehavior;
 import javax.jcr.Value;
+import javax.jcr.ItemVisitor;
 import javax.jcr.ValueFactory;
-import javax.jcr.ValueFormatException;
-import javax.jcr.Workspace;
-import javax.jcr.lock.Lock;
-import javax.jcr.lock.LockException;
-import javax.jcr.nodetype.ConstraintViolationException;
-import javax.jcr.nodetype.InvalidNodeTypeDefinitionException;
-import javax.jcr.nodetype.NoSuchNodeTypeException;
-import javax.jcr.nodetype.NodeType;
-import javax.jcr.nodetype.NodeTypeDefinition;
-import javax.jcr.nodetype.NodeTypeExistsException;
-import javax.jcr.nodetype.NodeTypeIterator;
-import javax.jcr.nodetype.NodeTypeManager;
-import javax.jcr.observation.EventJournal;
-import javax.jcr.observation.EventListener;
+import javax.jcr.GuestCredentials;
+import javax.jcr.PropertyIterator;
+import javax.jcr.util.TraversingItemVisitor;
 import javax.jcr.observation.ObservationManager;
+import javax.jcr.observation.EventListener;
+import javax.jcr.observation.EventJournal;
 import javax.jcr.query.InvalidQueryException;
-import javax.jcr.query.Query;
 import javax.jcr.query.QueryManager;
-import javax.jcr.util.TraversingItemVisitor;
-import javax.jcr.version.Version;
+import javax.jcr.query.Query;
+import javax.jcr.lock.LockException;
+import javax.jcr.lock.Lock;
 import javax.jcr.version.VersionException;
 import javax.jcr.version.VersionHistory;
+import javax.jcr.version.Version;
 import javax.jcr.version.VersionManager;
-
-import org.apache.jackrabbit.JcrConstants;
-import org.apache.jackrabbit.spi.Batch;
-import org.apache.jackrabbit.spi.Event;
-import org.apache.jackrabbit.spi.EventBundle;
-import org.apache.jackrabbit.spi.EventFilter;
-import org.apache.jackrabbit.spi.IdFactory;
-import org.apache.jackrabbit.spi.ItemId;
-import org.apache.jackrabbit.spi.ItemInfoCache;
-import org.apache.jackrabbit.spi.LockInfo;
-import org.apache.jackrabbit.spi.Name;
-import org.apache.jackrabbit.spi.NameFactory;
-import org.apache.jackrabbit.spi.NodeId;
-import org.apache.jackrabbit.spi.NodeInfo;
-import org.apache.jackrabbit.spi.Path;
-import org.apache.jackrabbit.spi.PathFactory;
-import org.apache.jackrabbit.spi.PropertyId;
-import org.apache.jackrabbit.spi.PropertyInfo;
-import org.apache.jackrabbit.spi.QNodeDefinition;
-import org.apache.jackrabbit.spi.QNodeTypeDefinition;
-import org.apache.jackrabbit.spi.QPropertyDefinition;
-import org.apache.jackrabbit.spi.QValue;
-import org.apache.jackrabbit.spi.QValueFactory;
-import org.apache.jackrabbit.spi.QueryInfo;
-import org.apache.jackrabbit.spi.RepositoryService;
-import org.apache.jackrabbit.spi.SessionInfo;
-import org.apache.jackrabbit.spi.Subscription;
-import org.apache.jackrabbit.spi.commons.EventBundleImpl;
-import org.apache.jackrabbit.spi.commons.EventFilterImpl;
-import org.apache.jackrabbit.spi.commons.ItemInfoCacheImpl;
-import org.apache.jackrabbit.spi.commons.QNodeDefinitionImpl;
-import org.apache.jackrabbit.spi.commons.QNodeTypeDefinitionImpl;
-import org.apache.jackrabbit.spi.commons.QPropertyDefinitionImpl;
-import org.apache.jackrabbit.spi.commons.conversion.DefaultNamePathResolver;
-import org.apache.jackrabbit.spi.commons.conversion.MalformedPathException;
-import org.apache.jackrabbit.spi.commons.conversion.NameException;
-import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
-import org.apache.jackrabbit.spi.commons.name.NameConstants;
-import org.apache.jackrabbit.spi.commons.name.NameFactoryImpl;
-import org.apache.jackrabbit.spi.commons.name.PathBuilder;
-import org.apache.jackrabbit.spi.commons.name.PathFactoryImpl;
-import org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver;
-import org.apache.jackrabbit.spi.commons.nodetype.NodeTypeDefinitionImpl;
-import org.apache.jackrabbit.spi.commons.value.QValueFactoryImpl;
-import org.apache.jackrabbit.spi.commons.value.ValueFactoryQImpl;
-import org.apache.jackrabbit.spi.commons.value.ValueFormat;
+import javax.jcr.nodetype.NoSuchNodeTypeException;
+import javax.jcr.nodetype.ConstraintViolationException;
+import javax.jcr.nodetype.NodeTypeManager;
+import javax.jcr.nodetype.NodeTypeIterator;
+import javax.jcr.nodetype.NodeType;
+import javax.jcr.nodetype.InvalidNodeTypeDefinitionException;
+import javax.jcr.nodetype.NodeTypeExistsException;
+import javax.jcr.nodetype.NodeTypeDefinition;
+import java.util.Map;
+import java.util.Iterator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Collection;
+import java.io.InputStream;
+import java.io.IOException;
+import java.io.ByteArrayInputStream;
+import java.security.AccessControlException;
 
 /**
  * <code>RepositoryServiceImpl</code> implements a repository service on top
@@ -218,6 +219,9 @@
         return qValueFactory;
     }
 
+    /**
+     * {@inheritDoc}
+     */
     public ItemInfoCache getItemInfoCache(SessionInfo sessionInfo) throws RepositoryException {
         return new ItemInfoCacheImpl(itemInfoCacheSize);
     }
@@ -226,7 +230,7 @@
      * {@inheritDoc}
      */
     public Map<String, QValue[]> getRepositoryDescriptors() throws RepositoryException {
-        Map<String, QValue[]> descriptors = new HashMap();
+        Map<String, QValue[]> descriptors = new HashMap<String, QValue[]>();
         for (String key : repository.getDescriptorKeys()) {
             if (key.equals(Repository.OPTION_TRANSACTIONS_SUPPORTED)) {
                 descriptors.put(key, new QValue[] {qValueFactory.create(false)});
@@ -238,10 +242,10 @@
                     // as Name/Path values are not expected to occur in the
                     // descriptors. TODO: check again.
                     NamePathResolver resolver = new DefaultNamePathResolver(new NamespaceResolver() {
-                        public String getURI(String prefix) throws NamespaceException {
+                        public String getURI(String prefix) {
                             return prefix;
                         }
-                        public String getPrefix(String uri) throws NamespaceException {
+                        public String getPrefix(String uri) {
                             return uri;
                         }
                     });
@@ -286,8 +290,7 @@
      */
     public void dispose(SessionInfo sessionInfo) throws RepositoryException {
         SessionInfoImpl sInfo = getSessionInfoImpl(sessionInfo);
-        for (Iterator it = sInfo.getSubscriptions().iterator(); it.hasNext(); ) {
-            EventSubscription s = (EventSubscription) it.next();
+        for (EventSubscription s : sInfo.getSubscriptions()) {
             s.dispose();
         }
         sInfo.getSession().logout();
@@ -318,9 +321,9 @@
             } else {
                 String comma = "";
                 actStr = "";
-                for (int i = 0; i < actions.length; i++) {
+                for (String action : actions) {
                     actStr += comma;
-                    actStr += actions[i];
+                    actStr += action;
                     comma = ",";
                 }
             }
@@ -380,7 +383,7 @@
     /**
      * {@inheritDoc}
      */
-    public Iterator getItemInfos(SessionInfo sessionInfo, NodeId nodeId)
+    public Iterator<? extends ItemInfo> getItemInfos(SessionInfo sessionInfo, NodeId nodeId)
             throws ItemNotFoundException, RepositoryException {
         final SessionInfoImpl sInfo = getSessionInfoImpl(sessionInfo);
         Node node = getNode(nodeId, sInfo);
@@ -400,8 +403,9 @@
             }
             return Collections.singletonList(info).iterator();
         } else {
-            final List itemInfos = new ArrayList();
+            final List<ItemInfo> itemInfos = new ArrayList<ItemInfo>();
             ItemVisitor visitor = new TraversingItemVisitor(false, depth) {
+                @Override
                 protected void entering(Property property, int i) throws RepositoryException {
                     try {
                         itemInfos.add(new PropertyInfoImpl(property, idFactory, sInfo.getNamePathResolver(), getQValueFactory()));
@@ -409,6 +413,7 @@
                         throw new RepositoryException(e);
                     }
                 }
+                @Override
                 protected void entering(Node node, int i) throws RepositoryException {
                     try {
                         itemInfos.add(new NodeInfoImpl(node, idFactory, sInfo.getNamePathResolver()));
@@ -416,9 +421,11 @@
                         throw new RepositoryException(e);
                     }
                 }
+                @Override
                 protected void leaving(Property property, int i) {
                     // nothing to do
                 }
+                @Override
                 protected void leaving(Node node, int i) {
                     // nothing to do
                 }
@@ -431,11 +438,11 @@
     /**
      * {@inheritDoc}
      */
-    public Iterator getChildInfos(SessionInfo sessionInfo, NodeId parentId)
+    public Iterator<ChildInfo> getChildInfos(SessionInfo sessionInfo, NodeId parentId)
             throws ItemNotFoundException, RepositoryException {
         SessionInfoImpl sInfo = getSessionInfoImpl(sessionInfo);
         NodeIterator children = getNode(parentId, sInfo).getNodes();
-        List childInfos = new ArrayList();
+        List<ChildInfo> childInfos = new ArrayList<ChildInfo>();
         try {
             while (children.hasNext()) {
                 childInfos.add(new ChildInfoImpl(children.nextNode(),
@@ -628,7 +635,7 @@
         SessionInfoImpl sInfo = getSessionInfoImpl(sessionInfo);
         try {
             Lock lock = getNode(nodeId, sInfo).getLock();
-            return LockInfoImpl.createLockInfo(lock, idFactory, sInfo.getNamePathResolver());
+            return LockInfoImpl.createLockInfo(lock, idFactory);
         } catch (LockException e) {
             // no lock present on this node.
             return null;
@@ -648,7 +655,7 @@
             public Object run() throws RepositoryException {
                 Node n = getNode(nodeId, sInfo);
                 Lock lock = n.lock(deep, sessionScoped);
-                return LockInfoImpl.createLockInfo(lock, idFactory, sInfo.getNamePathResolver());
+                return LockInfoImpl.createLockInfo(lock, idFactory);
             }
         }, sInfo);
     }
@@ -662,14 +669,9 @@
             public Object run() throws RepositoryException {
                 Node n = getNode(nodeId, sInfo);
                 Lock lock;
-                // TODO: remove check once jsr283 is released
-                if (sInfo.getSession() instanceof javax.jcr.Session) {
-                    javax.jcr.lock.LockManager lMgr = ((sInfo.getSession().getWorkspace()).getLockManager());
-                    lock = lMgr.lock(n.getPath(), deep, sessionScoped, timeoutHint, ownerHint);
-                } else {
-                    lock = n.lock(deep, sessionScoped);
-                }
-                return LockInfoImpl.createLockInfo(lock, idFactory, sInfo.getNamePathResolver());
+                javax.jcr.lock.LockManager lMgr = (sInfo.getSession().getWorkspace()).getLockManager();
+                lock = lMgr.lock(n.getPath(), deep, sessionScoped, timeoutHint, ownerHint);
+                return LockInfoImpl.createLockInfo(lock, idFactory);
             }
         }, sInfo);
     }
@@ -707,7 +709,7 @@
                 return getNode(nodeId, getSessionInfoImpl(sessionInfo)).checkin();
             }
         }, sInfo);
-        return idFactory.createNodeId(newVersion, sInfo.getNamePathResolver());
+        return idFactory.createNodeId(newVersion);
     }
 
     /**
@@ -730,15 +732,23 @@
     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);
+        VersionManager vMgr = sInfo.getSession().getWorkspace().getVersionManager();
+        vMgr.setActivity(activity);
+        try {
+            executeWithLocalEvents(new Callable() {
+                public Object run() throws RepositoryException {
+                    getNode(nodeId, sInfo).checkout();
+                    return null;
+                }
+            }, sInfo);
+        } finally {
+            vMgr.setActivity(null);
+        }
     }
 
+    /**
+     * {@inheritDoc}
+     */
     public NodeId checkpoint(SessionInfo sessionInfo, final NodeId nodeId) throws UnsupportedRepositoryOperationException, RepositoryException {
         final SessionInfoImpl sInfo = getSessionInfoImpl(sessionInfo);
         Version newVersion = (Version) executeWithLocalEvents(new Callable() {
@@ -747,7 +757,28 @@
                 return vMgr.checkpoint(getNodePath(nodeId, sInfo));
             }
         }, sInfo);
-        return idFactory.createNodeId(newVersion, sInfo.getNamePathResolver());
+        return idFactory.createNodeId(newVersion);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public NodeId checkpoint(SessionInfo sessionInfo, final NodeId nodeId, final NodeId activityId) throws UnsupportedRepositoryOperationException, RepositoryException {
+        final SessionInfoImpl sInfo = getSessionInfoImpl(sessionInfo);
+        Node activity = (activityId == null) ? null : getNode(activityId, sInfo);
+        VersionManager vMgr = sInfo.getSession().getWorkspace().getVersionManager();
+        vMgr.setActivity(activity);
+        try {
+            Version newVersion = (Version) executeWithLocalEvents(new Callable() {
+                public Object run() throws RepositoryException {
+                    VersionManager vMgr = sInfo.getSession().getWorkspace().getVersionManager();
+                    return vMgr.checkpoint(getNodePath(nodeId, sInfo));
+                }
+            }, sInfo);
+            return idFactory.createNodeId(newVersion);
+        } finally {
+            vMgr.setActivity(null);
+        }
     }
 
     /**
@@ -857,20 +888,20 @@
     /**
      * {@inheritDoc}
      */
-    public Iterator merge(final SessionInfo sessionInfo,
+    public Iterator<NodeId> merge(final SessionInfo sessionInfo,
                           final NodeId nodeId,
                           final String srcWorkspaceName,
                           final boolean bestEffort)
             throws NoSuchWorkspaceException, AccessDeniedException, MergeException, LockException, InvalidItemStateException, RepositoryException {
         final SessionInfoImpl sInfo = getSessionInfoImpl(sessionInfo);
-        return (Iterator) executeWithLocalEvents(new Callable() {
+        return (Iterator<NodeId>) executeWithLocalEvents(new Callable() {
             public Object run() throws RepositoryException {
                 String nodePath = getNodePath(nodeId, sInfo);
                 NodeIterator it = getVersionManager(sInfo).merge(nodePath, srcWorkspaceName, bestEffort);
-                List ids = new ArrayList();
+                List<NodeId> ids = new ArrayList<NodeId>();
                 while (it.hasNext()) {
-                    ids.add(idFactory.createNodeId(it.nextNode(),
-                            sInfo.getNamePathResolver()));
+                    ids.add(idFactory.createNodeId(it.nextNode()
+                    ));
                 }
                 return ids.iterator();
             }
@@ -880,21 +911,21 @@
     /**
      * {@inheritDoc}
      */
-    public Iterator merge(final SessionInfo sessionInfo,
+    public Iterator<NodeId> merge(final SessionInfo sessionInfo,
                           final NodeId nodeId,
                           final String srcWorkspaceName,
                           final boolean bestEffort,
                           final boolean isShallow)
             throws NoSuchWorkspaceException, AccessDeniedException, MergeException, LockException, InvalidItemStateException, RepositoryException {
         final SessionInfoImpl sInfo = getSessionInfoImpl(sessionInfo);
-        return (Iterator) executeWithLocalEvents(new Callable() {
+        return (Iterator<NodeId>) executeWithLocalEvents(new Callable() {
             public Object run() throws RepositoryException {
                 String nodePath = getNodePath(nodeId, sInfo);
                 NodeIterator it = getVersionManager(sInfo).merge(nodePath, srcWorkspaceName, bestEffort, isShallow);
-                List ids = new ArrayList();
+                List<NodeId> ids = new ArrayList<NodeId>();
                 while (it.hasNext()) {
-                    ids.add(idFactory.createNodeId(it.nextNode(),
-                            sInfo.getNamePathResolver()));
+                    ids.add(idFactory.createNodeId(it.nextNode()
+                    ));
                 }
                 return ids.iterator();
             }
@@ -916,23 +947,21 @@
                 Version version = null;
                 boolean cancel;
                 NamePathResolver resolver = sInfo.getNamePathResolver();
-                List l = Arrays.asList(mergeFailedIds);
+                List<NodeId> l = Arrays.asList(mergeFailedIds);
                 Property mergeFailed = node.getProperty(resolver.getJCRName(NameConstants.JCR_MERGEFAILED));
-                Value[] values = mergeFailed.getValues();
-                for (int i = 0; i < values.length; i++) {
-                    String uuid = values[i].getString();
+                for (Value value : mergeFailed.getValues()) {
+                    String uuid = value.getString();
                     if (!l.contains(idFactory.createNodeId(uuid))) {
-                        version = (Version) sInfo.getSession().getNodeByUUID(uuid);
+                        version = (Version) sInfo.getSession().getNodeByIdentifier(uuid);
                         break;
                     }
                 }
 
-                l = new ArrayList(predecessorIds.length);
+                l = new ArrayList<NodeId>(predecessorIds.length);
                 l.addAll(Arrays.asList(predecessorIds));
                 Property predecessors = node.getProperty(resolver.getJCRName(NameConstants.JCR_PREDECESSORS));
-                values = predecessors.getValues();
-                for (int i = 0; i < values.length; i++) {
-                    NodeId vId = idFactory.createNodeId(values[i].getString());
+                for (Value value : predecessors.getValues()) {
+                    NodeId vId = idFactory.createNodeId(value.getString());
                     l.remove(vId);
                 }
                 cancel = l.isEmpty();
@@ -1006,7 +1035,7 @@
                 return vMgr.createActivity(title);
             }
         }, getSessionInfoImpl(sessionInfo));
-        return idFactory.createNodeId(activity, sInfo.getNamePathResolver());
+        return idFactory.createNodeId(activity);
     }
 
     /**
@@ -1026,16 +1055,16 @@
     /**
      * {@inheritDoc}
      */
-    public Iterator mergeActivity(SessionInfo sessionInfo, final NodeId activityId) throws UnsupportedRepositoryOperationException, RepositoryException {
+    public Iterator<NodeId> mergeActivity(SessionInfo sessionInfo, final NodeId activityId) throws UnsupportedRepositoryOperationException, RepositoryException {
         final SessionInfoImpl sInfo = getSessionInfoImpl(sessionInfo);
-        return (Iterator) executeWithLocalEvents(new Callable() {
+        return (Iterator<NodeId>) executeWithLocalEvents(new Callable() {
             public Object run() throws RepositoryException {
                 Node node = getNode(activityId, sInfo);
                 NodeIterator it = getVersionManager(sInfo).merge(node);
-                List ids = new ArrayList();
+                List<NodeId> ids = new ArrayList<NodeId>();
                 while (it.hasNext()) {
-                    ids.add(idFactory.createNodeId(it.nextNode(),
-                            sInfo.getNamePathResolver()));
+                    ids.add(idFactory.createNodeId(it.nextNode()
+                    ));
                 }
                 return ids.iterator();
             }
@@ -1054,7 +1083,7 @@
                 return vMgr.createConfiguration(getNodePath(nodeId, sInfo));
             }
         }, getSessionInfoImpl(sessionInfo));
-        return idFactory.createNodeId(configuration, sInfo.getNamePathResolver());
+        return idFactory.createNodeId(configuration);
     }
 
     /**
@@ -1072,7 +1101,7 @@
     public String[] checkQueryStatement(SessionInfo sessionInfo,
                                     String statement,
                                     String language,
-                                    Map namespaces)
+                                    Map<String, String> namespaces)
             throws InvalidQueryException, RepositoryException {
         Query q = createQuery(getSessionInfoImpl(sessionInfo).getSession(),
                 statement, language, namespaces);
@@ -1113,9 +1142,9 @@
                                          Name[] nodeTypeName,
                                          boolean noLocal)
             throws UnsupportedRepositoryOperationException, RepositoryException {
-        Set ntNames = null;
+        Set<Name> ntNames = null;
         if (nodeTypeName != null) {
-            ntNames = new HashSet(Arrays.asList(nodeTypeName));
+            ntNames = new HashSet<Name>(Arrays.asList(nodeTypeName));
         }
         return new EventFilterImpl(eventTypes, absPath, isDeep, uuid, ntNames, noLocal);
     }
@@ -1192,14 +1221,13 @@
     /**
      * {@inheritDoc}
      */
-    public Map getRegisteredNamespaces(SessionInfo sessionInfo)
+    public Map<String, String> getRegisteredNamespaces(SessionInfo sessionInfo)
             throws RepositoryException {
         SessionInfoImpl sInfo = getSessionInfoImpl(sessionInfo);
         NamespaceRegistry nsReg = sInfo.getSession().getWorkspace().getNamespaceRegistry();
-        Map namespaces = new HashMap();
-        String[] prefixes = nsReg.getPrefixes();
-        for (int i = 0; i < prefixes.length; i++) {
-            namespaces.put(prefixes[i], nsReg.getURI(prefixes[i]));
+        Map<String, String> namespaces = new HashMap<String, String>();
+        for (String prefix : nsReg.getPrefixes()) {
+            namespaces.put(prefix, nsReg.getURI(prefix));
         }
         return namespaces;
     }
@@ -1348,7 +1376,7 @@
            from lower index, the index of the following siblings must be reset
            in order to avoid PathNotFoundException.
          */
-        private final Set removedNodeIds = new HashSet();
+        private final Set<NodeId> removedNodeIds = new HashSet<NodeId>();
 
         private boolean failed = false;
 
@@ -1478,7 +1506,7 @@
             NodeId nodeId = (NodeId) itemId;
             Path p = itemId.getPath();
             if (p != null) {
-                removedNodeIds.add(itemId);
+                removedNodeIds.add(nodeId);
                 int index = p.getNameElement().getNormalizedIndex();
                 if (index > Path.INDEX_DEFAULT) {
                     Path.Element[] elems = p.getElements();
@@ -1531,24 +1559,23 @@
                 throws RepositoryException {
             executeGuarded(new Callable() {
                 public Object run() throws RepositoryException {
-                    Set mixinNames = new HashSet();
-                    for (int i = 0; i < mixinNodeTypeIds.length; i++) {
-                        mixinNames.add(getJcrName(mixinNodeTypeIds[i]));
+                    Set<String> mixinNames = new HashSet<String>();
+                    for (Name mixinNodeTypeId : mixinNodeTypeIds) {
+                        mixinNames.add(getJcrName(mixinNodeTypeId));
                     }
                     Node n = getNode(nodeId, sInfo);
-                    NodeType[] nts = n.getMixinNodeTypes();
-                    Set currentMixins = new HashSet();
-                    for (int i = 0; i < nts.length; i++) {
-                        currentMixins.add(nts[i].getName());
+                    Set<String> currentMixins = new HashSet<String>();
+                    for (NodeType nt : n.getMixinNodeTypes()) {
+                        currentMixins.add(nt.getName());
                     }
-                    Set remove = new HashSet(currentMixins);
+                    Set<String> remove = new HashSet<String>(currentMixins);
                     remove.removeAll(mixinNames);
                     mixinNames.removeAll(currentMixins);
-                    for (Iterator it = remove.iterator(); it.hasNext(); ) {
-                        n.removeMixin((String) it.next());
+                    for (String mixName : remove) {
+                        n.removeMixin(mixName);
                     }
-                    for (Iterator it = mixinNames.iterator(); it.hasNext(); ) {
-                        n.addMixin((String) it.next());
+                    for (String mixName : mixinNames) {
+                        n.addMixin(mixName);
                     }
                     return null;
                 }
@@ -1739,7 +1766,7 @@
     }
 
     private String getNodePath(NodeId nodeId, SessionInfoImpl sessionInfo) throws RepositoryException {
-        // TODO: improve. avoid roundtrip over node access.
+        // TODO: improve. avoid round trip over node access.
         return getNode(nodeId, sessionInfo).getPath();
     }
 
@@ -1766,12 +1793,12 @@
     private Query createQuery(Session session,
                               String statement,
                               String language,
-                              Map namespaces)
+                              Map<String, String> namespaces)
             throws InvalidQueryException, RepositoryException {
         QueryManager qMgr = session.getWorkspace().getQueryManager();
 
         // apply namespace mappings to session
-        Map previous = setNamespaceMappings(session, namespaces);
+        Map<String, String> previous = setNamespaceMappings(session, namespaces);
         try {
             return qMgr.createQuery(statement, language);
         } finally {
@@ -1789,15 +1816,13 @@
      * @return the previous namespace mappings that were modified
      * @throws RepositoryException if a repository error occurs
      */
-    private Map setNamespaceMappings(Session session, Map namespaces)
+    private Map<String, String> setNamespaceMappings(Session session, Map<String, String> namespaces)
             throws RepositoryException {
-        Map previous = new HashMap();
+        Map<String, String> previous = new HashMap<String, String>();
 
-        Iterator iterator = namespaces.entrySet().iterator();
-        while (iterator.hasNext()) {
-            Map.Entry entry = (Map.Entry) iterator.next();
-            String uri = (String) entry.getValue();
-            String prefix = (String) entry.getKey();
+        for (Map.Entry<String, String> entry : namespaces.entrySet()) {
+            String uri = entry.getValue();
+            String prefix = entry.getKey();
 
             // Get the previous prefix for this URI, throws if
             // URI not found (which is OK, as that's an error)
@@ -1848,13 +1873,12 @@
             throws RepositoryException {
         if (supportsObservation) {
             // register local event listener
-            Collection subscr = sInfo.getSubscriptions();
+            Collection<EventSubscription> subscr = sInfo.getSubscriptions();
             if (subscr.size() != 0) {
                 ObservationManager obsMgr = sInfo.getSession().getWorkspace().getObservationManager();
-                List listeners = new ArrayList(subscr.size());
+                List<EventListener> listeners = new ArrayList<EventListener>(subscr.size());
                 try {
-                    for (Iterator it = subscr.iterator(); it.hasNext(); ) {
-                        EventSubscription s = (EventSubscription) it.next();
+                    for (EventSubscription s : subscr) {
                         EventListener listener = s.getLocalEventListener();
                         listeners.add(listener);
                         obsMgr.addEventListener(listener, EventSubscription.ALL_EVENTS,
@@ -1862,9 +1886,9 @@
                     }
                     return call.run();
                 } finally {
-                    for (Iterator it = listeners.iterator(); it.hasNext(); ) {
+                    for (EventListener listener : listeners) {
                         try {
-                            obsMgr.removeEventListener((EventListener) it.next());
+                            obsMgr.removeEventListener(listener);
                         } catch (RepositoryException e) {
                             // ignore and remove next
                         }

Modified: jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/SessionInfoImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/SessionInfoImpl.java?rev=918491&r1=918490&r2=918491&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/SessionInfoImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/SessionInfoImpl.java Wed Mar  3 14:41:00 2010
@@ -71,12 +71,12 @@
     /**
      * The subscriptions that are currently in place for this session info.
      */
-    private List subscriptions = Collections.EMPTY_LIST;
+    private List<EventSubscription> subscriptions = Collections.emptyList();
 
     /**
      * Monitor object for subscription changes.
      */
-    private Object subscriptionChange = new Object();
+    private final Object subscriptionChange = new Object();
 
     /**
      * Creates a new session info based on the given <code>session</code>.
@@ -144,7 +144,7 @@
         return duplicateCredentials(credentials);
     }
 
-    Collection getSubscriptions() {
+    Collection<EventSubscription> getSubscriptions() {
         synchronized (subscriptionChange) {
             return subscriptions;
         }
@@ -162,7 +162,7 @@
     Subscription createSubscription(IdFactory idFactory, QValueFactory qValueFactory, EventFilter[] filters)
             throws RepositoryException {
         synchronized (subscriptionChange) {
-            List tmp = new ArrayList(subscriptions);
+            List<EventSubscription> tmp = new ArrayList<EventSubscription>(subscriptions);
             EventSubscription s = new EventSubscription(idFactory, qValueFactory, this, filters);
             tmp.add(s);
             subscriptions = Collections.unmodifiableList(tmp);
@@ -175,9 +175,9 @@
      *
      * @param subscription the subscription to remove.
      */
-    void removeSubscription(Subscription subscription) {
+    void removeSubscription(EventSubscription subscription) {
         synchronized (subscriptionChange) {
-            List tmp = new ArrayList(subscriptions);
+            List<EventSubscription> tmp = new ArrayList<EventSubscription>(subscriptions);
             tmp.remove(subscription);
             subscriptions = Collections.unmodifiableList(tmp);
         }



Mime
View raw message