jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tri...@apache.org
Subject svn commit: r795842 - 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/ jackrabbit-s...
Date Mon, 20 Jul 2009 13:55:29 GMT
Author: tripod
Date: Mon Jul 20 13:55:28 2009
New Revision: 795842

URL: http://svn.apache.org/viewvc?rev=795842&view=rev
Log:
JCR-2140: Configurations and Baselines

Added:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalBaseline.java
      - copied, changed from r795442, jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalActivity.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalBaselineImpl.java
  (with props)
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalConfiguration.java
      - copied, changed from r795442, jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalActivity.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalConfigurationImpl.java
      - copied, changed from r795773, jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalActivityImpl.java
Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/AbstractVersionManager.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalActivity.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalFrozenNode.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManager.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/XAVersionManager.java
    jackrabbit/trunk/jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/nodetype/builtin_nodetypes.cnd
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/name/NameConstants.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java?rev=795842&r1=795841&r2=795842&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
Mon Jul 20 13:55:28 2009
@@ -141,6 +141,11 @@
     public static final NodeId ACTIVITIES_NODE_ID = NodeId.valueOf("deadbeef-face-babe-ac71-babecafebabe");
 
     /**
+     * hardcoded id of the "/jcr:system/jcr:versionStorage/jcr:configurations" node
+     */
+    public static final NodeId CONFIGURATIONS_NODE_ID = NodeId.valueOf("deadbeef-face-babe-c04f-babecafebabe");
+
+    /**
      * hardcoded id of the "/jcr:system/jcr:nodeTypes" node
      */
     public static final NodeId NODETYPES_NODE_ID = NodeId.valueOf("deadbeef-cafe-cafe-cafe-babecafebabe");
@@ -474,6 +479,7 @@
                 SYSTEM_ROOT_NODE_ID,
                 VERSION_STORAGE_NODE_ID,
                 ACTIVITIES_NODE_ID,
+                CONFIGURATIONS_NODE_ID,
                 cacheFactory,
                 ismLocking);
     }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/AbstractVersionManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/AbstractVersionManager.java?rev=795842&r1=795841&r2=795842&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/AbstractVersionManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/AbstractVersionManager.java
Mon Jul 20 13:55:28 2009
@@ -21,10 +21,12 @@
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 import javax.jcr.Value;
+import javax.jcr.UnsupportedRepositoryOperationException;
 import javax.jcr.version.VersionException;
 
-import org.apache.jackrabbit.core.id.NodeId;
 import org.apache.jackrabbit.core.NodeImpl;
+import org.apache.jackrabbit.core.value.InternalValue;
+import org.apache.jackrabbit.core.id.NodeId;
 import org.apache.jackrabbit.core.nodetype.NodeTypeRegistry;
 import org.apache.jackrabbit.core.state.DefaultISMLocking;
 import org.apache.jackrabbit.core.state.ISMLocking.ReadLock;
@@ -73,6 +75,11 @@
     protected NodeStateEx activitiesRoot;
 
     /**
+     * Persistent root node of the configurations.
+     */
+    protected NodeStateEx configurationsRoot;
+
+    /**
      * the lock on this version manager
      */
     private final DefaultISMLocking rwLock = new DefaultISMLocking();
@@ -360,6 +367,7 @@
      * @param id the id of the node
      * @throws RepositoryException if an error occurs while reading from the
      *                             repository.
+     * @return the nodestate for the given id.
      */
     protected abstract NodeStateEx getNodeStateEx(NodeId id)
             throws RepositoryException;
@@ -436,6 +444,57 @@
     }
 
     /**
+     * Creates aew configuration node
+     * @param rootId the id of the root node of the workspace configuration
+     * @param baseline the optional baseline
+     * @return a node state of the created configuration
+     * @throws RepositoryException if an error occurs
+     */
+    NodeStateEx internalCreateConfiguration(NodeId rootId, InternalBaseline baseline)
+            throws RepositoryException {
+        if (baseline != null) {
+            // the exact behavior is not clarified yet.
+            // see http://jsr-283.dev.java.net/issues/show_bug.cgi?id=795
+            throw new UnsupportedRepositoryOperationException(
+                    "creating configurations based on a baseline not supported, yet");
+        }
+
+        WriteOperation ops = startWriteOperation();
+        try {
+            // If the parameter baseline is null, a new version history is created
+            // to store baselines of the new configuration, and the jcr:baseVersion
+            // of the new configuration references the root of the new version history.
+            NodeId configId = new NodeId();
+            NodeStateEx configParent = getParentNode(configurationsRoot,
+                    configId.toString(), NameConstants.REP_CONFIGURATIONS);
+            Name name = getName(configId.toString());
+            NodeStateEx config = configParent.addNode(name, NameConstants.NT_CONFIGURATION,
configId, true);
+            config.setPropertyValue(NameConstants.JCR_ROOT, InternalValue.create(rootId));
+
+            // now create the version history of the baseline
+            String uuid = new NodeId().toString();
+            NodeStateEx histParent = getParentNode(historyRoot, uuid, NameConstants.REP_VERSIONSTORAGE);
+            Name histName = getName(uuid);
+            NodeStateEx history =
+                InternalVersionHistoryImpl.create(this, histParent, histName, config.getState(),
null);
+            InternalVersionHistory vh = new InternalVersionHistoryImpl(this, history);
+
+            // and set the base version and history to the config
+            NodeId blId = vh.getRootVersion().getId();
+            config.setPropertyValue(NameConstants.JCR_BASEVERSION, InternalValue.create(blId));
+            config.setPropertyValue(NameConstants.JCR_VERSIONHISTORY, InternalValue.create(vh.getId()));
+            configParent.store();
+            ops.save();
+
+            return config;
+        } catch (ItemStateException e) {
+            throw new RepositoryException(e);
+        } finally {
+            ops.close();
+        }
+    }
+
+    /**
      * Removes the specified activity
      *
      * @param activity the acitvity to remove

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalActivity.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalActivity.java?rev=795842&r1=795841&r2=795842&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalActivity.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalActivity.java
Mon Jul 20 13:55:28 2009
@@ -33,7 +33,7 @@
      * @return the version
      * @throws RepositoryException if an error occurs
      */
-    public InternalVersion getLatestVersion(InternalVersionHistory history)
+    InternalVersion getLatestVersion(InternalVersionHistory history)
             throws RepositoryException;
 
     /**
@@ -44,6 +44,6 @@
      * @return the changeset
      * @throws RepositoryException if an error occurs
      */
-    public Map<NodeId, InternalVersion> getChangeSet() throws RepositoryException;
+    Map<NodeId, InternalVersion> getChangeSet() throws RepositoryException;
 
 }
\ No newline at end of file

Copied: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalBaseline.java
(from r795442, jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalActivity.java)
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalBaseline.java?p2=jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalBaseline.java&p1=jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalActivity.java&r1=795442&r2=795842&rev=795842&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalActivity.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalBaseline.java
Mon Jul 20 13:55:28 2009
@@ -23,27 +23,25 @@
 import org.apache.jackrabbit.core.id.NodeId;
 
 /**
- * This interface defines the internal activity.
+ * This interface defines the internal baseline.
+ * <p/>
+ * A baseline is the state of a configuration at some point in time, recorded in
+ * version storage. A baseline is similar to a normal version except that
+ * instead of representing the state of a single node, it represents the state
+ * of an entire partial subgraph.
+ * <p/>
+ * The internal baseline is the version of the internal configuration.
  */
-public interface InternalActivity extends InternalVersionItem {
+public interface InternalBaseline extends InternalVersion {
 
     /**
-     * Returns the latest version of the given history that is referenced in this activity.
-     * @param history the history
-     * @return the version
+     * Returns the recorded base versions of all versionable nodes in the
+     * configuration.
+     *
+     * @return a map of base versions. the map key is the nodeid of the
+     * version history.
      * @throws RepositoryException if an error occurs
      */
-    public InternalVersion getLatestVersion(InternalVersionHistory history)
-            throws RepositoryException;
-
-    /**
-     * Returns the changeset of this activity.
-     * This is the set of versions that are the latest members of this activity
-     * in their respective version histories. the changeset is a map grouped by
-     * the nodeid of the respective histories.
-     * @return the changeset
-     * @throws RepositoryException if an error occurs
-     */
-    public Map<NodeId, InternalVersion> getChangeSet() throws RepositoryException;
+    Map<NodeId, InternalVersion> getBaseVersions() throws RepositoryException;
 
 }
\ No newline at end of file

Added: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalBaselineImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalBaselineImpl.java?rev=795842&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalBaselineImpl.java
(added)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalBaselineImpl.java
Mon Jul 20 13:55:28 2009
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.core.version;
+
+import java.util.Map;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.UnsupportedRepositoryOperationException;
+
+import org.apache.jackrabbit.core.id.NodeId;
+import org.apache.jackrabbit.core.value.InternalValue;
+import org.apache.jackrabbit.spi.commons.name.NameConstants;
+import org.apache.jackrabbit.spi.Name;
+
+/**
+ * Implements a internal representation of a baseline node.
+ */
+class InternalBaselineImpl extends InternalVersionImpl
+        implements InternalBaseline {
+
+    /**
+     * Creates a new internal baseline with the given version history and
+     * persistance node. please note, that versions must be created by the
+     * version history.
+     *
+     * @param vh containing version history
+     * @param node node state of this version
+     * @param name name of this version
+     */
+    InternalBaselineImpl(InternalVersionHistoryImpl vh, NodeStateEx node, Name name) {
+        super(vh, node, name);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public Map<NodeId, InternalVersion> getBaseVersions() throws RepositoryException
{
+        throw new UnsupportedRepositoryOperationException("InternalBaseline.getBaseversions()");
+    }
+}
\ No newline at end of file

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

Propchange: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalBaselineImpl.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev Url

Copied: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalConfiguration.java
(from r795442, jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalActivity.java)
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalConfiguration.java?p2=jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalConfiguration.java&p1=jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalActivity.java&r1=795442&r2=795842&rev=795842&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalActivity.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalConfiguration.java
Mon Jul 20 13:55:28 2009
@@ -23,27 +23,32 @@
 import org.apache.jackrabbit.core.id.NodeId;
 
 /**
- * This interface defines the internal activity.
+ * This interface defines the internal represenation of a configuration.
+ *
+ * A configuration is a partial subgraph of a workspace. It consists of the tree
+ * rooted at a particular node (called the configuration root node) minus any
+ * subgraphs that are part of another configuration.
+ * <p/>
+ * An internal configuration soley stores the root id of the actual
+ * configuration in the workspace. The configuration is stored at the same
+ * relative path as it's baseline history.
  */
-public interface InternalActivity extends InternalVersionItem {
+public interface InternalConfiguration extends InternalVersionItem {
 
     /**
-     * Returns the latest version of the given history that is referenced in this activity.
-     * @param history the history
-     * @return the version
+     * Returns the id of the root node of the configuration
+     * @return the id of the root node.
      * @throws RepositoryException if an error occurs
      */
-    public InternalVersion getLatestVersion(InternalVersionHistory history)
-            throws RepositoryException;
+    NodeId getRootId() throws RepositoryException;
 
     /**
-     * Returns the changeset of this activity.
-     * This is the set of versions that are the latest members of this activity
-     * in their respective version histories. the changeset is a map grouped by
-     * the nodeid of the respective histories.
-     * @return the changeset
+     * Returns the current baseline of this configuration, i.e. the version of
+     * this "versionable"
+     *
+     * @return the baseline
      * @throws RepositoryException if an error occurs
      */
-    public Map<NodeId, InternalVersion> getChangeSet() throws RepositoryException;
+    InternalBaseline getBaseline() throws RepositoryException;
 
 }
\ No newline at end of file

Copied: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalConfigurationImpl.java
(from r795773, jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalActivityImpl.java)
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalConfigurationImpl.java?p2=jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalConfigurationImpl.java&p1=jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalActivityImpl.java&r1=795773&r2=795842&rev=795842&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalActivityImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalConfigurationImpl.java
Mon Jul 20 13:55:28 2009
@@ -16,34 +16,26 @@
  */
 package org.apache.jackrabbit.core.version;
 
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.jcr.PropertyType;
 import javax.jcr.RepositoryException;
+import javax.jcr.UnsupportedRepositoryOperationException;
 
 import org.apache.jackrabbit.core.id.NodeId;
 import org.apache.jackrabbit.core.value.InternalValue;
-import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.commons.name.NameConstants;
 
 /**
- * Implements a internal representation of an activity node.
- * this is only for the {@link XAVersionManager}.
+ * Implements a internal representation of a configuration node.
  */
-class InternalActivityImpl extends InternalVersionItemImpl implements InternalActivity {
+class InternalConfigurationImpl extends InternalVersionItemImpl
+        implements InternalConfiguration {
 
     /**
-     * Creates a new VersionHistory object for the given node state.
+     * Creates a new InternalConfiguration object for the given node state.
      * @param vMgr version manager
      * @param node version history node state
      * @throws RepositoryException if an error occurs
      */
-    public InternalActivityImpl(AbstractVersionManager vMgr, NodeStateEx node)
+    public InternalConfigurationImpl(AbstractVersionManager vMgr, NodeStateEx node)
             throws RepositoryException {
         super(vMgr, node);
     }
@@ -63,107 +55,20 @@
     }
 
     /**
-     * Creates a new activity history below the given parent node and with
-     * the given name.
-     *
-     * @param parent parent node
-     * @param name activity name
-     * @param activityId node id for the new activity
-     * @param title title of the activity
-     * @return new node state
-     * @throws RepositoryException if an error occurs
-     */
-    static NodeStateEx create(NodeStateEx parent, Name name, NodeId activityId,
-                              String title)
-            throws RepositoryException {
-
-        // create new activity node in the persistent state
-        NodeStateEx pNode = parent.addNode(name, NameConstants.NT_ACTIVITY, activityId, true);
-        Set<Name> mix = new HashSet<Name>();
-        mix.add(NameConstants.REP_VERSION_REFERENCE);
-        pNode.setMixins(mix);
-
-        // set the title
-        pNode.setPropertyValue(NameConstants.JCR_ACTIVITY_TITLE, InternalValue.create(title));
-
-        parent.store();
-
-        return pNode;
-    }
-
-    /**
-     * Adds a version reference
-     * @param v the version
-     * @throws RepositoryException if an error occurs
-     */
-    public void addVersion(InternalVersionImpl v) throws RepositoryException {
-        InternalValue[] versions;
-        if (node.hasProperty(NameConstants.REP_VERSIONS)) {
-            InternalValue[] vs = node.getPropertyValues(NameConstants.REP_VERSIONS);
-            versions = new InternalValue[vs.length+1];
-            System.arraycopy(vs, 0, versions, 0, vs.length);
-            versions[vs.length] = InternalValue.create(v.getId());
-        } else {
-            versions = new InternalValue[]{InternalValue.create(v.getId())};
-        }
-        node.setPropertyValues(NameConstants.REP_VERSIONS, PropertyType.REFERENCE, versions);
-        node.store();
-    }
-
-    /**
-     * Removes the given version from the list of references
-     * @param v the version
-     * @throws RepositoryException if an error occurs
-     */
-    public void removeVersion(InternalVersionImpl v) throws RepositoryException {
-        List<InternalValue> versions = new LinkedList<InternalValue>();
-        if (node.hasProperty(NameConstants.REP_VERSIONS)) {
-            NodeId vId = v.getId();
-            for (InternalValue ref: node.getPropertyValues(NameConstants.REP_VERSIONS)) {
-                if (!vId.equals(ref.getNodeId())) {
-                    versions.add(ref);
-                }
-            }
-        }
-        node.setPropertyValues(NameConstants.REP_VERSIONS, PropertyType.REFERENCE, versions.toArray(new
InternalValue[versions.size()]));
-        node.store();
-
-    }
-
-    /**
-     * Returns the latest version of the given history that is referenced in this activity.
-     * @param history the history
-     * @return the version
-     * @throws RepositoryException if an error occurs
+     * {@inheritDoc}
      */
-    public InternalVersion getLatestVersion(InternalVersionHistory history)
-            throws RepositoryException {
-        if (node.hasProperty(NameConstants.REP_VERSIONS)) {
-            InternalVersion best = null;
-            for (InternalValue ref: node.getPropertyValues(NameConstants.REP_VERSIONS)) {
-                InternalVersion v = history.getVersion(ref.getNodeId());
-                if (v != null) {
-                    // currently we assume that the last version is the best
-                    best = v;
-                }
-            }
-            return best;
-        } else {
-            return null;
+    public NodeId getRootId() throws RepositoryException {
+        InternalValue value = node.getPropertyValue(NameConstants.JCR_ROOT);
+        if (value == null) {
+            throw new RepositoryException("Internal error: configuration has no recorded
jcr:root");
         }
+        return value.getNodeId();
     }
 
     /**
      * {@inheritDoc}
      */
-    public Map<NodeId, InternalVersion> getChangeSet() throws RepositoryException {
-        Map<NodeId, InternalVersion> changeset = new HashMap<NodeId, InternalVersion>();
-        if (node.hasProperty(NameConstants.REP_VERSIONS)) {
-            for (InternalValue ref: node.getPropertyValues(NameConstants.REP_VERSIONS)) {
-                InternalVersion v = vMgr.getVersion(ref.getNodeId());
-                changeset.put(v.getVersionHistory().getId(), v);
-            }
-        }
-        return changeset;
+    public InternalBaseline getBaseline() throws RepositoryException {
+        throw new UnsupportedRepositoryOperationException("InternalConfiguration.getBaseline()");
     }
 }
\ No newline at end of file

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalFrozenNode.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalFrozenNode.java?rev=795842&r1=795841&r2=795842&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalFrozenNode.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalFrozenNode.java
Mon Jul 20 13:55:28 2009
@@ -68,7 +68,7 @@
 
     /**
      * Checks if this frozen node has the frozen version history
-     * @param id
+     * @param id if to check
      * @return <code>true</code> if this node has the history;
      *         <code>false</code> otherwise.
      */

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManager.java?rev=795842&r1=795841&r2=795842&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManager.java
Mon Jul 20 13:55:28 2009
@@ -155,6 +155,20 @@
     InternalVersion getHeadVersionOfNode(NodeId id) throws RepositoryException;
 
     /**
+     * Creates a new internal configuration that represents a configuration
+     * of the tree rooted at the node specified by <code>rootId</code>
+     * 
+     * @param session the session that creates the configuration
+     * @param rootId root id of the configuration
+     * @param baseline the baseline or <code>null</code>
+     * @return a new internal configuration
+     * @throws RepositoryException if an error occurs
+     */
+    InternalConfiguration createConfiguration(Session session, NodeId rootId,
+                                              InternalBaseline baseline)
+            throws RepositoryException;
+
+    /**
      * Creates a new activity
      * @param session the current session
      * @param title title of the new activity

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=795842&r1=795841&r2=795842&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
Mon Jul 20 13:55:28 2009
@@ -23,20 +23,20 @@
 import javax.jcr.PropertyType;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
+import javax.jcr.version.ActivityViolationException;
 import javax.jcr.version.Version;
 import javax.jcr.version.VersionException;
 import javax.jcr.version.VersionHistory;
-import javax.jcr.version.ActivityViolationException;
 
 import org.apache.commons.collections.map.ReferenceMap;
-import org.apache.jackrabbit.core.id.ItemId;
-import org.apache.jackrabbit.core.id.NodeId;
 import org.apache.jackrabbit.core.NodeImpl;
-import org.apache.jackrabbit.core.id.PropertyId;
 import org.apache.jackrabbit.core.SessionImpl;
 import org.apache.jackrabbit.core.cluster.UpdateEventChannel;
 import org.apache.jackrabbit.core.cluster.UpdateEventListener;
 import org.apache.jackrabbit.core.fs.FileSystem;
+import org.apache.jackrabbit.core.id.ItemId;
+import org.apache.jackrabbit.core.id.NodeId;
+import org.apache.jackrabbit.core.id.PropertyId;
 import org.apache.jackrabbit.core.nodetype.NodeTypeRegistry;
 import org.apache.jackrabbit.core.observation.DelegatingObservationDispatcher;
 import org.apache.jackrabbit.core.observation.EventState;
@@ -51,10 +51,10 @@
 import org.apache.jackrabbit.core.state.ItemStateException;
 import org.apache.jackrabbit.core.state.ItemStateListener;
 import org.apache.jackrabbit.core.state.LocalItemStateManager;
+import org.apache.jackrabbit.core.state.NodeReferences;
 import org.apache.jackrabbit.core.state.NodeState;
 import org.apache.jackrabbit.core.state.PropertyState;
 import org.apache.jackrabbit.core.state.SharedItemStateManager;
-import org.apache.jackrabbit.core.state.NodeReferences;
 import org.apache.jackrabbit.core.value.InternalValue;
 import org.apache.jackrabbit.core.virtual.VirtualItemStateProvider;
 import org.apache.jackrabbit.spi.Name;
@@ -86,6 +86,11 @@
      */
     private static final Path ACTIVITIES_PATH;
 
+    /**
+     * The path to the configurations storage: /jcr:system/jcr:versionStorage/jcr:configurations
+     */
+    private static final Path CONFIGURATIONS_PATH;
+
     static {
         try {
             PathBuilder builder = new PathBuilder();
@@ -100,6 +105,13 @@
             builder.addLast(NameConstants.JCR_VERSIONSTORAGE);
             builder.addLast(NameConstants.JCR_ACTIVITIES);
             ACTIVITIES_PATH = builder.getPath();
+
+            builder = new PathBuilder();
+            builder.addRoot();
+            builder.addLast(NameConstants.JCR_SYSTEM);
+            builder.addLast(NameConstants.JCR_VERSIONSTORAGE);
+            builder.addLast(NameConstants.JCR_CONFIGURATIONS);
+            CONFIGURATIONS_PATH = builder.getPath();
         } catch (MalformedPathException e) {
             // will not happen. path is always valid
             throw new InternalError("Cannot initialize path");
@@ -134,12 +146,24 @@
     /**
      * Map of returned items. this is kept for invalidating
      */
+    @SuppressWarnings("unchecked")
     private final Map<ItemId, InternalVersionItem> versionItems =
             new ReferenceMap(ReferenceMap.HARD, ReferenceMap.WEAK);
 
     /**
-     * Creates a new version manager
+     * Creates a new internal version manager
      *
+     * @param pMgr underlying persistence manager
+     * @param fs workspace file system
+     * @param ntReg node type registry
+     * @param obsMgr observation manager
+     * @param rootParentId node id of the version storage parent (i.e. jcr:system)
+     * @param storageId node id of the version storage (i.e. jcr:versionStorage)
+     * @param activitiesId node id of the activities storage (i.e. jcr:activities)
+     * @param configurationsId node if of the configurations storage (i.e. jcr:configurations)
+     * @param cacheFactory item state cache factory
+     * @param ismLocking workspace item state locking
+     * @throws RepositoryException if an error occurs
      */
     public VersionManagerImpl(PersistenceManager pMgr, FileSystem fs,
                               NodeTypeRegistry ntReg,
@@ -147,6 +171,7 @@
                               NodeId rootParentId,
                               NodeId storageId,
                               NodeId activitiesId,
+                              NodeId configurationsId,
                               ItemStateCacheFactory cacheFactory,
                               ISMLocking ismLocking) throws RepositoryException {
         super(ntReg);
@@ -201,6 +226,32 @@
                 pMgr.store(cl);
             }
 
+            // check for jcr:configurations
+            if (!pMgr.exists(configurationsId)) {
+                NodeState root = pMgr.createNew(configurationsId);
+                root.setParentId(storageId);
+                root.setDefinitionId(ntReg.getEffectiveNodeType(NameConstants.REP_VERSIONSTORAGE).getApplicableChildNodeDef(
+                        NameConstants.JCR_CONFIGURATIONS, NameConstants.REP_CONFIGURATIONS,
ntReg).getId());
+                root.setNodeTypeName(NameConstants.REP_CONFIGURATIONS);
+                PropertyState pt = pMgr.createNew(new PropertyId(activitiesId, NameConstants.JCR_PRIMARYTYPE));
+                pt.setDefinitionId(ntReg.getEffectiveNodeType(NameConstants.REP_CONFIGURATIONS).getApplicablePropertyDef(
+                        NameConstants.JCR_PRIMARYTYPE, PropertyType.NAME, false).getId());
+                pt.setMultiValued(false);
+                pt.setType(PropertyType.NAME);
+                pt.setValues(new InternalValue[]{InternalValue.create(NameConstants.REP_CONFIGURATIONS)});
+                root.addPropertyName(pt.getName());
+
+                // add activities as child
+                NodeState historyState = pMgr.load(storageId);
+                historyState.addChildNodeEntry(NameConstants.JCR_CONFIGURATIONS, configurationsId);
+
+                ChangeLog cl = new ChangeLog();
+                cl.added(root);
+                cl.added(pt);
+                cl.modified(historyState);
+                pMgr.store(cl);
+            }
+
             sharedStateMgr = createItemStateManager(pMgr, storageId, ntReg, cacheFactory,
ismLocking);
 
             stateMgr = LocalItemStateManager.createInstance(sharedStateMgr, escFactory, cacheFactory);
@@ -212,6 +263,9 @@
             nodeState = (NodeState) stateMgr.getItemState(activitiesId);
             activitiesRoot =  new NodeStateEx(stateMgr, ntReg, nodeState, NameConstants.JCR_ACTIVITIES);
 
+            nodeState = (NodeState) stateMgr.getItemState(configurationsId);
+            configurationsRoot =  new NodeStateEx(stateMgr, ntReg, nodeState, NameConstants.JCR_CONFIGURATIONS);
+
             // create the virtual item state provider
             versProvider = new VersionItemStateProvider(
                     getHistoryRootId(), sharedStateMgr);
@@ -296,6 +350,22 @@
 
     /**
      * {@inheritDoc}
+     */
+    public InternalConfiguration createConfiguration(Session session,
+                                                     final NodeId rootId,
+                                                     final InternalBaseline baseline)
+            throws RepositoryException {
+        NodeStateEx state = (NodeStateEx)
+                escFactory.doSourced((SessionImpl) session, new SourcedTarget() {
+            public Object run() throws RepositoryException {
+                return internalCreateConfiguration(rootId, baseline);
+            }
+        });
+        return new InternalConfigurationImpl(this, state);
+    }
+
+    /**
+     * {@inheritDoc}
      * <p/>
      * This method must not be synchronized since it could cause deadlocks with
      * item-reading listeners in the observation thread.

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=795842&r1=795841&r2=795842&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
Mon Jul 20 13:55:28 2009
@@ -167,15 +167,32 @@
      */
     public NodeId createActivity(Session session, String title)
             throws RepositoryException {
-
         if (isInXA()) {
             NodeStateEx state = internalCreateActivity(title);
             InternalActivityImpl activity =
                 new InternalActivityImpl(vMgr, state);
             xaItems.put(state.getNodeId(), activity);
             return state.getNodeId();
+        } else {
+            return vMgr.createActivity(session, title);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public InternalConfiguration createConfiguration(Session session,
+                                                     NodeId rootId,
+                                                     InternalBaseline baseline)
+            throws RepositoryException {
+        if (isInXA()) {
+            NodeStateEx state = internalCreateConfiguration(rootId, baseline);
+            InternalConfiguration config = new InternalConfigurationImpl(vMgr, state);
+            xaItems.put(state.getNodeId(), config);
+            return config;
+        } else {
+            return vMgr.createConfiguration(session, rootId, baseline);
         }
-        return vMgr.createActivity(session, title);
     }
 
     /**

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=795842&r1=795841&r2=795842&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
Mon Jul 20 13:55:28 2009
@@ -506,14 +506,19 @@
   + * (nt:versionHistory) = nt:versionHistory protected sns ABORT
   + * (rep:versionStorage) = rep:versionStorage protected sns ABORT
   + * (rep:activities) = rep:activities protected sns ABORT
+  + * (rep:configurations) = rep:activities protected sns ABORT
 
 [rep:activities]
   + * (nt:activity) = nt:activity protected sns ABORT
   + * (rep:activities) = rep:activities protected sns ABORT
 
+[rep:configurations]
+  + * (nt:configuration) = nt:configuration protected sns ABORT
+  + * (rep:configurations) = rep:configurations protected sns ABORT
+
 // implementation note: because node references are not maintained within the
 // version storage, we store a bidirectional relationship between activities and
- // the respective versions
+// the respective versions
 [rep:VersionReference] mix
   - rep:versions (reference) protected multiple abort
   

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=795842&r1=795841&r2=795842&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
Mon Jul 20 13:55:28 2009
@@ -283,6 +283,18 @@
      */
     public static final Name JCR_ACTIVITY_TITLE = FACTORY.create(Name.NS_JCR_URI, "activityTitle");
 
+    /**
+     * jcr:configurations
+     * @since 2.0
+     */
+    public static final Name JCR_CONFIGURATIONS = FACTORY.create(Name.NS_JCR_URI, "configurations");
+
+    /**
+     * jcr:configuration
+     * @since 2.0
+     */
+    public static final Name JCR_CONFIGURATION = FACTORY.create(Name.NS_JCR_URI, "configuration");
+
 
     //--------------------------------< node type related item name constants >
 
@@ -543,6 +555,12 @@
      */
     public static final Name NT_ACTIVITY = FACTORY.create(Name.NS_NT_URI, "activity");
 
+    /**
+     * nt:configuration
+     * @since 2.0
+     */
+    public static final Name NT_CONFIGURATION = FACTORY.create(Name.NS_NT_URI, "configuration");
+
     //--------------------------------------------------------------------------
     /**
      * rep:root
@@ -565,6 +583,11 @@
     public static final Name REP_ACTIVITIES = FACTORY.create(Name.NS_REP_URI, "activities");
 
     /**
+     * rep:activities
+     */
+    public static final Name REP_CONFIGURATIONS = FACTORY.create(Name.NS_REP_URI, "configurations");
+
+    /**
      * rep:versionReference
      */
     public static final Name REP_VERSION_REFERENCE = FACTORY.create(Name.NS_REP_URI, "VersionReference");



Mime
View raw message