jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r1511339 - in /jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/version: VersionHistoryImpl.java VersionImpl.java
Date Wed, 07 Aug 2013 14:51:36 GMT
Author: mreutegg
Date: Wed Aug  7 14:51:36 2013
New Revision: 1511339

URL: http://svn.apache.org/r1511339
Log:
OAK-168: Basic JCR VersionManager support
- Wrap JCR API method implementations with perform(new SessionOperation())

Modified:
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/version/VersionHistoryImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/version/VersionImpl.java

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/version/VersionHistoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/version/VersionHistoryImpl.java?rev=1511339&r1=1511338&r2=1511339&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/version/VersionHistoryImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/version/VersionHistoryImpl.java
Wed Aug  7 14:51:36 2013
@@ -45,7 +45,6 @@ import org.apache.jackrabbit.oak.util.TO
 
 /**
  * {@code VersionHistoryImpl}...
- * TODO: wrap all calls with sessionDelegate.perform()
  */
 public class VersionHistoryImpl extends NodeImpl<VersionHistoryDelegate>
         implements VersionHistory {
@@ -61,12 +60,22 @@ public class VersionHistoryImpl extends 
 
     @Override
     public String getVersionableIdentifier() throws RepositoryException {
-        return dlg.getVersionableIdentifier();
+        return perform(new SessionOperation<String>() {
+            @Override
+            public String perform() throws RepositoryException {
+                return dlg.getVersionableIdentifier();
+            }
+        });
     }
 
     @Override
     public Version getRootVersion() throws RepositoryException {
-        return new VersionImpl(dlg.getRootVersion(), sessionContext);
+        return perform(new SessionOperation<Version>() {
+            @Override
+            public Version perform() throws RepositoryException {
+                return new VersionImpl(dlg.getRootVersion(), sessionContext);
+            }
+        });
     }
 
     @Override
@@ -76,13 +85,18 @@ public class VersionHistoryImpl extends 
 
     @Override
     public VersionIterator getAllVersions() throws RepositoryException {
-        return new VersionIteratorAdapter(Iterators.transform(
-                dlg.getAllVersions(), new Function<VersionDelegate, Version>() {
+        return perform(new SessionOperation<VersionIterator>() {
             @Override
-            public Version apply(VersionDelegate input) {
-                return new VersionImpl(input, sessionContext);
+            public VersionIterator perform() throws RepositoryException {
+                return new VersionIteratorAdapter(Iterators.transform(
+                        dlg.getAllVersions(), new Function<VersionDelegate, Version>()
{
+                    @Override
+                    public Version apply(VersionDelegate input) {
+                        return new VersionImpl(input, sessionContext);
+                    }
+                }));
             }
-        }));
+        });
     }
 
     @Override
@@ -96,16 +110,26 @@ public class VersionHistoryImpl extends 
     }
 
     @Override
-    public Version getVersion(String versionName)
+    public Version getVersion(final String versionName)
             throws VersionException, RepositoryException {
-        return new VersionImpl(dlg.getVersion(versionName), sessionContext);
+        return perform(new SessionOperation<Version>() {
+            @Override
+            public Version perform() throws RepositoryException {
+                return new VersionImpl(dlg.getVersion(versionName), sessionContext);
+            }
+        });
     }
 
     @Override
-    public Version getVersionByLabel(String label)
+    public Version getVersionByLabel(final String label)
             throws VersionException, RepositoryException {
-        String oakLabel = sessionContext.getOakName(label);
-        return new VersionImpl(dlg.getVersionByLabel(oakLabel), sessionContext);
+        return perform(new SessionOperation<Version>() {
+            @Override
+            public Version perform() throws RepositoryException {
+                String oakLabel = sessionContext.getOakName(label);
+                return new VersionImpl(dlg.getVersionByLabel(oakLabel), sessionContext);
+            }
+        });
     }
 
     @Override
@@ -114,7 +138,7 @@ public class VersionHistoryImpl extends 
                                 final boolean moveLabel)
             throws LabelExistsVersionException, VersionException,
             RepositoryException {
-        sessionDelegate.perform(new SessionOperation<Void>() {
+        perform(new SessionOperation<Void>() {
             @Override
             public Void perform() throws RepositoryException {
                 String oakLabel = sessionContext.getOakName(label);
@@ -129,7 +153,7 @@ public class VersionHistoryImpl extends 
     @Override
     public void removeVersionLabel(final String label)
             throws VersionException, RepositoryException {
-        sessionDelegate.perform(new SessionOperation<Void>() {
+        perform(new SessionOperation<Void>() {
             @Override
             public Void perform() throws RepositoryException {
                 String oakLabel = sessionContext.getOakName(label);
@@ -152,25 +176,35 @@ public class VersionHistoryImpl extends 
 
     @Override
     public String[] getVersionLabels() throws RepositoryException {
-        List<String> labels = new ArrayList<String>();
-        for (String label : dlg.getVersionLabels()) {
-            labels.add(sessionContext.getJcrName(label));
-        }
-        return labels.toArray(new String[labels.size()]);
+        return perform(new SessionOperation<String[]>() {
+            @Override
+            public String[] perform() throws RepositoryException {
+                List<String> labels = new ArrayList<String>();
+                for (String label : dlg.getVersionLabels()) {
+                    labels.add(sessionContext.getJcrName(label));
+                }
+                return labels.toArray(new String[labels.size()]);
+            }
+        });
     }
 
     @Override
-    public String[] getVersionLabels(Version version)
+    public String[] getVersionLabels(final Version version)
             throws VersionException, RepositoryException {
         if (!version.getContainingHistory().getPath().equals(getPath())) {
             throw new VersionException("Version is not contained in this " +
                     "VersionHistory");
         }
-        List<String> labels = new ArrayList<String>();
-        for (String label : dlg.getVersionLabels(version.getIdentifier())) {
-            labels.add(sessionContext.getJcrName(label));
-        }
-        return labels.toArray(new String[labels.size()]);
+        return perform(new SessionOperation<String[]>() {
+            @Override
+            public String[] perform() throws RepositoryException {
+                List<String> labels = new ArrayList<String>();
+                for (String label : dlg.getVersionLabels(version.getIdentifier())) {
+                    labels.add(sessionContext.getJcrName(label));
+                }
+                return labels.toArray(new String[labels.size()]);
+            }
+        });
     }
 
     @Override

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/version/VersionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/version/VersionImpl.java?rev=1511339&r1=1511338&r2=1511339&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/version/VersionImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/version/VersionImpl.java
Wed Aug  7 14:51:36 2013
@@ -37,6 +37,7 @@ import org.apache.jackrabbit.oak.jcr.Ses
 import org.apache.jackrabbit.oak.jcr.delegate.PropertyDelegate;
 import org.apache.jackrabbit.oak.jcr.delegate.VersionDelegate;
 import org.apache.jackrabbit.oak.jcr.delegate.VersionManagerDelegate;
+import org.apache.jackrabbit.oak.jcr.operation.SessionOperation;
 import org.apache.jackrabbit.oak.plugins.value.ValueFactoryImpl;
 import org.apache.jackrabbit.oak.plugins.version.VersionConstants;
 import org.apache.jackrabbit.oak.util.TODO;
@@ -49,15 +50,25 @@ public class VersionImpl extends NodeImp
 
     @Override
     public VersionHistory getContainingHistory() throws RepositoryException {
-        return new VersionHistoryImpl(
-                getVersionManagerDelegate().createVersionHistory(
-                        dlg.getParent()), sessionContext);
+        return perform(new SessionOperation<VersionHistory>() {
+            @Override
+            public VersionHistory perform() throws RepositoryException {
+                return new VersionHistoryImpl(
+                        getVersionManagerDelegate().createVersionHistory(
+                                dlg.getParent()), sessionContext);
+            }
+        });
     }
 
     @Override
     public Calendar getCreated() throws RepositoryException {
-        PropertyDelegate dlg = getPropertyOrThrow(JcrConstants.JCR_CREATED);
-        return ValueFactoryImpl.createValue(dlg.getSingleState(), sessionContext).getDate();
+        return sessionDelegate.perform(new SessionOperation<Calendar>() {
+            @Override
+            public Calendar perform() throws RepositoryException {
+                PropertyDelegate dlg = getPropertyOrThrow(JcrConstants.JCR_CREATED);
+                return ValueFactoryImpl.createValue(dlg.getSingleState(), sessionContext).getDate();
+            }
+        });
     }
 
     @Override
@@ -76,32 +87,47 @@ public class VersionImpl extends NodeImp
 
     @Override
     public Version[] getPredecessors() throws RepositoryException {
-        PropertyDelegate p = getPropertyOrThrow(VersionConstants.JCR_PREDECESSORS);
-        List<Version> predecessors = new ArrayList<Version>();
-        VersionManagerDelegate vMgr = getVersionManagerDelegate();
-        for (Value v : getValues(p)) {
-            String id = v.getString();
-            predecessors.add(new VersionImpl(vMgr.getVersionByIdentifier(id), sessionContext));
-        }
-        return predecessors.toArray(new Version[predecessors.size()]);
+        return perform(new SessionOperation<Version[]>() {
+            @Override
+            public Version[] perform() throws RepositoryException {
+                PropertyDelegate p = getPropertyOrThrow(VersionConstants.JCR_PREDECESSORS);
+                List<Version> predecessors = new ArrayList<Version>();
+                VersionManagerDelegate vMgr = getVersionManagerDelegate();
+                for (Value v : getValues(p)) {
+                    String id = v.getString();
+                    predecessors.add(new VersionImpl(vMgr.getVersionByIdentifier(id), sessionContext));
+                }
+                return predecessors.toArray(new Version[predecessors.size()]);
+            }
+        });
     }
 
     @Override
     public Version[] getSuccessors() throws RepositoryException {
-        PropertyDelegate p = getPropertyOrThrow(VersionConstants.JCR_SUCCESSORS);
-        List<Version> successors = new ArrayList<Version>();
-        VersionManagerDelegate vMgr = getVersionManagerDelegate();
-        for (Value v : getValues(p)) {
-            String id = v.getString();
-            successors.add(new VersionImpl(vMgr.getVersionByIdentifier(id), sessionContext));
-        }
-        return successors.toArray(new Version[successors.size()]);
+        return perform(new SessionOperation<Version[]>() {
+            @Override
+            public Version[] perform() throws RepositoryException {
+                PropertyDelegate p = getPropertyOrThrow(VersionConstants.JCR_SUCCESSORS);
+                List<Version> successors = new ArrayList<Version>();
+                VersionManagerDelegate vMgr = getVersionManagerDelegate();
+                for (Value v : getValues(p)) {
+                    String id = v.getString();
+                    successors.add(new VersionImpl(vMgr.getVersionByIdentifier(id), sessionContext));
+                }
+                return successors.toArray(new Version[successors.size()]);
+            }
+        });
     }
 
     @Override
     public Node getFrozenNode() throws RepositoryException {
-        return sessionContext.createNodeOrNull(
-                dlg.getChild(VersionConstants.JCR_FROZENNODE));
+        return perform(new SessionOperation<Node>() {
+            @Override
+            public Node perform() throws RepositoryException {
+                return sessionContext.createNodeOrNull(
+                        dlg.getChild(VersionConstants.JCR_FROZENNODE));
+            }
+        });
     }
 
     //------------------------------< internal >--------------------------------



Mime
View raw message