jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tri...@apache.org
Subject svn commit: r796586 [2/2] - in /jackrabbit/trunk: jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/ jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/nodetype/ jackra...
Date Tue, 21 Jul 2009 23:41:40 GMT
Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java?rev=796586&r1=796585&r2=796586&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java
Tue Jul 21 23:41:39 2009
@@ -19,6 +19,7 @@
 import java.util.Collection;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 import javax.jcr.PropertyType;
 import javax.jcr.RepositoryException;
@@ -348,17 +349,30 @@
     /**
      * {@inheritDoc}
      */
-    public InternalConfiguration createConfiguration(Session session,
-                                                     final NodeId rootId,
-                                                     final InternalBaseline baseline)
+    public NodeId createConfiguration(Session session, final NodeId rootId)
             throws RepositoryException {
         NodeStateEx state = (NodeStateEx)
                 escFactory.doSourced((SessionImpl) session, new SourcedTarget() {
             public Object run() throws RepositoryException {
-                return internalCreateConfiguration(rootId, baseline);
+                return internalCreateConfiguration(rootId);
+            }
+        });
+        return state.getNodeId();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public InternalBaseline checkin(Session session,
+                                    final InternalConfiguration config,
+                                    final Set<NodeId> baseVersions)
+            throws RepositoryException {
+        return (InternalBaseline)
+                escFactory.doSourced((SessionImpl) session, new SourcedTarget() {
+            public Object run() throws RepositoryException {
+                return internalCheckin((InternalConfigurationImpl) config, baseVersions);
             }
         });
-        return new InternalConfigurationImpl(this, state);
     }
 
     /**

Copied: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionSet.java
(from r795866, jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/LabelVersionSelector.java)
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionSet.java?p2=jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionSet.java&p1=jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/LabelVersionSelector.java&r1=795866&r2=796586&rev=796586&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/LabelVersionSelector.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionSet.java
Tue Jul 21 23:41:39 2009
@@ -16,91 +16,71 @@
  */
 package org.apache.jackrabbit.core.version;
 
+import java.util.Map;
+
 import javax.jcr.RepositoryException;
 
-import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.core.id.NodeId;
 
 /**
- * This Class implements a version selector that selects a version by label.
- *
- * <xmp>
- * V1.0
- * V1.1 - "foo"
- *
- * new LabelVersionSelector("foo").select() --> V1.1
- * new LabelVersionSelector("bar").select() --> null
- *
- * </xmp>
+ * This Class implements a version selector that is based on a set of verions.
  */
-public class LabelVersionSelector implements VersionSelector {
+public class VersionSet implements VersionSelector {
 
     /**
-     * a versionlabel hint
+     * the internal changeset
      */
-    private Name label = null;
+    private final Map<NodeId, InternalVersion> versions;
 
     /**
-     * Creates a <code>LabelVersionSelector</code> that will try to select a
-     * version with the given label.
-     *
-     * @param label label hint
+     * fallback flag
      */
-    public LabelVersionSelector(Name label) {
-        this.label = label;
-    }
+    private final boolean dateFallback;
 
     /**
-     * Returns the label hint
+     * Creates a <code>ChangeSetVersionSelector</code> that will try to select
a
+     * version within the given set of versions.
      *
-     * @return the label hint.
+     * @param versions the set of versions
      */
-    public Name getLabel() {
-        return label;
+    public VersionSet(Map<NodeId, InternalVersion> versions) {
+        this(versions, false);
     }
 
     /**
-     * Sets the label hint
+     * Creates a <code>ChangeSetVersionSelector</code> that will try to select
a
+     * version in the given set. If the version is missing but <code>dateFall 
      *
-     * @param label label hint
+     * @param versions the set of versions
+     * @param dateFallback if <code>true</code> date fallback is enabled.
      */
-    public void setLabel(Name label) {
-        this.label = label;
+    public VersionSet(Map<NodeId, InternalVersion> versions, boolean dateFallback)
{
+        this.versions = versions;
+        this.dateFallback = dateFallback;
     }
 
     /**
-     * {@inheritDoc}
-     *
-     * Selects a version from the given version history using the previously
-     * assigned hint in the following order: name, label, date, latest.
+     * Returns the (modifiable) changeset of this selector. the keys of the
+     * map are the node ids of the version histories.
+     * @return the change set
      */
-    public InternalVersion select(InternalVersionHistory versionHistory)
-            throws RepositoryException {
-        return selectByLabel(versionHistory, label);
+    public Map<NodeId, InternalVersion> versions() {
+        return versions;
     }
 
     /**
-     * Selects a version by label
+     * {@inheritDoc}
      *
-     * @param history history to select from
-     * @param label desired label
-     * @return the version with the given label or <code>null</code>
-     * @throws RepositoryException if an error occurs
+     * Selects a version from set having the given version history.
      */
-    public static InternalVersion selectByLabel(InternalVersionHistory history, Name label)
+    public InternalVersion select(InternalVersionHistory versionHistory)
             throws RepositoryException {
-        return history.getVersionByLabel(label);
+        InternalVersion v = versions.get(versionHistory.getId());
+        if (v == null && dateFallback) {
+            // select latest one
+            v = DateVersionSelector.selectByDate(versionHistory, null);
+        }
+        return v;
     }
 
-    /**
-     * returns debug information
-     * @return debug information
-     */
-    public String toString() {
-        StringBuffer ret = new StringBuffer();
-        ret.append("LabelVersionSelector(");
-        ret.append("label=");
-        ret.append(label);
-        ret.append(")");
-        return ret.toString();
-    }
-}
+}
\ No newline at end of file

Propchange: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionSet.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/XAVersionManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/XAVersionManager.java?rev=796586&r1=796585&r2=796586&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/XAVersionManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/XAVersionManager.java
Tue Jul 21 23:41:39 2009
@@ -18,6 +18,7 @@
 
 import java.util.HashMap;
 import java.util.Map;
+import java.util.Set;
 
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
@@ -178,17 +179,31 @@
     /**
      * {@inheritDoc}
      */
-    public InternalConfiguration createConfiguration(Session session,
-                                                     NodeId rootId,
-                                                     InternalBaseline baseline)
+    public NodeId createConfiguration(Session session, NodeId rootId)
             throws RepositoryException {
         if (isInXA()) {
-            NodeStateEx state = internalCreateConfiguration(rootId, baseline);
+            NodeStateEx state = internalCreateConfiguration(rootId);
             InternalConfiguration config = new InternalConfigurationImpl(vMgr, state);
             xaItems.put(state.getNodeId(), config);
-            return config;
+            return config.getId();
         } else {
-            return vMgr.createConfiguration(session, rootId, baseline);
+            return vMgr.createConfiguration(session, rootId);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public InternalBaseline checkin(Session session,
+                                    InternalConfiguration config,
+                                    Set<NodeId> baseVersions)
+            throws RepositoryException {
+        if (isInXA()) {
+            InternalBaseline version = internalCheckin((InternalConfigurationImpl) config,
baseVersions);
+            xaItems.put(version.getId(), version);
+            return version;
+        } else {
+            return vMgr.checkin(session, config, baseVersions);
         }
     }
 

Modified: jackrabbit/trunk/jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/nodetype/builtin_nodetypes.cnd
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/nodetype/builtin_nodetypes.cnd?rev=796586&r1=796585&r2=796586&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/nodetype/builtin_nodetypes.cnd
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/nodetype/builtin_nodetypes.cnd
Tue Jul 21 23:41:39 2009
@@ -505,22 +505,30 @@
 [rep:versionStorage]
   + * (nt:versionHistory) = nt:versionHistory protected sns ABORT
   + * (rep:versionStorage) = rep:versionStorage protected sns ABORT
-  + * (rep:activities) = rep:activities protected sns ABORT
-  + * (rep:configurations) = rep:configurations protected sns ABORT
+  + * (rep:Activities) = rep:Activities protected sns ABORT
+  + * (rep:Configurations) = rep:Configurations protected sns ABORT
 
-[rep:activities]
+[rep:Activities]
   + * (nt:activity) = nt:activity protected sns ABORT
-  + * (rep:activities) = rep:activities protected sns ABORT
+  + * (rep:Activities) = rep:Activities protected sns ABORT
 
-[rep:configurations]
+[rep:Configurations]
   + * (nt:configuration) = nt:configuration protected sns ABORT
-  + * (rep:configurations) = rep:configurations protected sns ABORT
+  + * (rep:Configurations) = rep:Configurations protected sns ABORT
+
+/**
+ * mixin for baseline versions
+ * @prop rep:baseVersions property that holds all base versions of the
+ *                        versioned configuration.
+ */
+[rep:Baseline] mixin
+  - rep:baseVersions (REFERENCE) protected multiple ABORT
 
 // implementation note: because node references are not maintained within the
 // version storage, we store a bidirectional relationship between activities and
 // the respective versions
 [rep:VersionReference] mix
-  - rep:versions (reference) protected multiple abort
+  - rep:versions (REFERENCE) protected multiple ABORT
   
 // -----------------------------------------------------------------------------
 // J A C K R A B B I T  S E C U R I T Y

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/name/NameConstants.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/name/NameConstants.java?rev=796586&r1=796585&r2=796586&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/name/NameConstants.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/name/NameConstants.java
Tue Jul 21 23:41:39 2009
@@ -578,17 +578,27 @@
     public static final Name REP_VERSIONSTORAGE = FACTORY.create(Name.NS_REP_URI, "versionStorage");
 
     /**
-     * rep:activities
+     * rep:Activities
      */
-    public static final Name REP_ACTIVITIES = FACTORY.create(Name.NS_REP_URI, "activities");
+    public static final Name REP_ACTIVITIES = FACTORY.create(Name.NS_REP_URI, "Activities");
 
     /**
-     * rep:activities
+     * rep:Configurations
      */
-    public static final Name REP_CONFIGURATIONS = FACTORY.create(Name.NS_REP_URI, "configurations");
+    public static final Name REP_CONFIGURATIONS = FACTORY.create(Name.NS_REP_URI, "Configurations");
 
     /**
-     * rep:versionReference
+     * rep:Baseline
+     */
+    public static final Name REP_BASELINE = FACTORY.create(Name.NS_REP_URI, "Baseline");
+
+    /**
+     * rep:baseVersions
+     */
+    public static final Name REP_BASEVERSIONS = FACTORY.create(Name.NS_REP_URI, "baseVersions");
+
+    /**
+     * rep:VersionReference
      */
     public static final Name REP_VERSION_REFERENCE = FACTORY.create(Name.NS_REP_URI, "VersionReference");
 



Mime
View raw message