jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tri...@apache.org
Subject svn commit: rev 56421 - in incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core: state version virtual
Date Tue, 02 Nov 2004 21:34:18 GMT
Author: tripod
Date: Tue Nov  2 13:34:17 2004
New Revision: 56421

Modified:
   incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/ItemState.java
   incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/SessionItemStateManager.java
   incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/PersistentNode.java
   incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/PersistentVersionManager.java
   incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionManager.java
   incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/virtual/DefaultItemStateProvider.java
   incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/virtual/VirtualNodeState.java
Log:
- fixing problem with virtual overlay
- fixing PersistentNode issue described in JCR-15 [PersistentNode.store() ignores status when
storing]

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/ItemState.java
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/ItemState.java	(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/ItemState.java	Tue
Nov  2 13:34:17 2004
@@ -65,11 +65,10 @@
      * 'existing', i.e. persistent state that has been destroyed by somebody else
      */
     public static final int STATUS_STALE_DESTROYED = 6;
+
     /**
-     * 'virtual' status, i.e. persistent state is virtual
+     * the internal status of this item state
      */
-    public static final int STATUS_EXISTING_VIRTUAL = 7;
-
     protected int status = STATUS_UNDEFINED;
 
     /**
@@ -104,10 +103,6 @@
             case STATUS_NEW:
                 status = initialStatus;
                 break;
-            case STATUS_EXISTING_VIRTUAL:
-                // todo: should be keep this state?
-                status = STATUS_EXISTING;
-                break;
             default:
                 String msg = "illegal status: " + initialStatus;
                 log.error(msg);
@@ -133,10 +128,6 @@
             case STATUS_EXISTING_MODIFIED:
             case STATUS_EXISTING_REMOVED:
                 status = initialStatus;
-                break;
-            case STATUS_EXISTING_VIRTUAL:
-                // todo: should be keep this state?
-                status = STATUS_EXISTING;
                 break;
             default:
                 String msg = "illegal status: " + initialStatus;

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/SessionItemStateManager.java
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/SessionItemStateManager.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/SessionItemStateManager.java
Tue Nov  2 13:34:17 2004
@@ -211,12 +211,6 @@
      */
     public ItemState getItemState(ItemId id)
             throws NoSuchItemStateException, ItemStateException {
-        // check if there is a virtual state for the specified item
-        for (int i = 0; i < virtualProviders.length; i++) {
-            if (virtualProviders[i].hasItemState(id)) {
-                return virtualProviders[i].getItemState(id);
-            }
-        }
 
         // first check if the specified item has been transiently removed
         if (transientStateMgr.hasItemStateInAttic(id)) {
@@ -233,6 +227,13 @@
         // check if there's transient state for the specified item
         if (transientStateMgr.hasItemState(id)) {
             return transientStateMgr.getItemState(id);
+        }
+
+        // check if there is a virtual state for the specified item
+        for (int i=0; i<virtualProviders.length; i++) {
+            if (virtualProviders[i].hasItemState(id)) {
+                return virtualProviders[i].getItemState(id);
+            }
         }
 
         // check if there's persistent state for the specified item

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/PersistentNode.java
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/PersistentNode.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/PersistentNode.java
Tue Nov  2 13:34:17 2004
@@ -501,7 +501,9 @@
             store(nstate);
         }
         // and store itself
-        state.store();
+        if (state.isTransient()) {
+            state.store();
+        }
     }
 
     /**

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/PersistentVersionManager.java
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/PersistentVersionManager.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/PersistentVersionManager.java
Tue Nov  2 13:34:17 2004
@@ -72,11 +72,16 @@
 
 
     /**
-     * the root node of the version histories
+     * the persistent root node of the version histories
      */
     private final PersistentNode historyRoot;
 
     /**
+     * the virtual root node of the version histories
+     */
+    private final String virtHistoryRootId;
+
+    /**
      * the system root id
      */
     private final String systemRootId;
@@ -117,8 +122,13 @@
         if (!systemRoot.hasNode(VERSION_HISTORY_ROOT_NAME)) {
             // if not exist, create
             systemRoot.addNode(VERSION_HISTORY_ROOT_NAME, NodeTypeRegistry.NT_UNSTRUCTURED);
-            systemRoot.save();
         }
+        if (!systemRoot.hasNode(VersionManager.VERSION_HISTORY_ROOT_NAME)) {
+            // if not exist, create
+            systemRoot.addNode(VersionManager.VERSION_HISTORY_ROOT_NAME, NodeTypeRegistry.NT_UNSTRUCTURED);
+        }
+        systemRoot.save();
+        virtHistoryRootId = systemRoot.getNode(VersionManager.VERSION_HISTORY_ROOT_NAME).internalGetUUID();
 
         try {
             PersistentNodeState nodeState = (PersistentNodeState) stateMgr.getItemState(new
NodeId(systemRoot.getNode(VERSION_HISTORY_ROOT_NAME).internalGetUUID()));
@@ -271,7 +281,7 @@
      */
     public synchronized VersionManager getVersionManager() {
         if (versionManager==null) {
-            versionManager = new VersionManager(this, systemRootId);
+            versionManager = new VersionManager(this, virtHistoryRootId);
         }
         return versionManager;
     }

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionManager.java
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionManager.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionManager.java
Tue Nov  2 13:34:17 2004
@@ -117,6 +117,7 @@
 
     /**
      * @param vMgr
+     * @param rootId the uuid of the version history root
      */
     protected VersionManager(PersistentVersionManager vMgr, String rootId) {
         this.vMgr = vMgr;
@@ -132,9 +133,10 @@
     public VirtualItemStateProvider getVirtualItemStateProvider(ItemStateProvider base) {
         if (virtProvider==null) {
             try {
-                NodeState rootState = (NodeState) base.getItemState(new NodeId(rootId));
-                virtProvider = new DefaultItemStateProvider(vMgr.getNodeTypeManager(), rootState);
-                historyRoot = virtProvider.addNode(virtProvider.getRootState(), VERSION_HISTORY_ROOT_NAME,
null, NodeTypeRegistry.NT_UNSTRUCTURED, null);
+                virtProvider = new DefaultItemStateProvider(vMgr.getNodeTypeManager());
+                // create a duplicate of the version history root name
+                NodeState virtRootState = (NodeState) base.getItemState(new NodeId(rootId));
+                historyRoot = virtProvider.addOverlay(virtRootState);
                 Iterator iter = vMgr.getVersionHistories();
                 while (iter.hasNext()) {
                     InternalVersionHistory vh = (InternalVersionHistory) iter.next();

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/virtual/DefaultItemStateProvider.java
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/virtual/DefaultItemStateProvider.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/virtual/DefaultItemStateProvider.java
Tue Nov  2 13:34:17 2004
@@ -48,7 +48,7 @@
     /**
      * the virtual root state of this provider (does not have to be /)
      */
-    private final VirtualNodeState rootState;
+    //private final VirtualNodeState rootState;
 
     /**
      * the items of this provider
@@ -59,21 +59,9 @@
      * Creates a new item state provider.
      *
      * @param ntMgr         the nodetype manager
-     * @param overlayedRoot the node state that is overlayed
      */
-    public DefaultItemStateProvider(NodeTypeManagerImpl ntMgr, NodeState overlayedRoot) {
+    public DefaultItemStateProvider(NodeTypeManagerImpl ntMgr) {
         this.ntMgr = ntMgr;
-        rootState = new VirtualNodeState(overlayedRoot);
-        items.put(rootState.getId(), rootState);
-    }
-
-    /**
-     * Returns the nodestate of the relative root of this provider
-     *
-     * @return
-     */
-    public VirtualNodeState getRootState() {
-        return rootState;
     }
 
     /**
@@ -132,6 +120,15 @@
         }
         VirtualNodeState parent = (VirtualNodeState) getItemState(parentId);
         return addNode(parent, name, id, nodeType, null);
+    }
+
+    public VirtualNodeState addOverlay(NodeState original) throws RepositoryException {
+        VirtualNodeState ns= new VirtualNodeState(original.getUUID(), original.getNodeTypeName(),
original.getParentUUID());
+        ns.setDefinitionId(original.getDefinitionId());
+        setPropertyValue(ns, ItemImpl.PROPNAME_PRIMARYTYPE, InternalValue.create(original.getNodeTypeName()));
+        ns.setMixinTypeNames(original.getMixinTypeNames());
+        items.put(ns.getId(), ns);
+        return ns;
     }
 
     /**

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/virtual/VirtualNodeState.java
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/virtual/VirtualNodeState.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/virtual/VirtualNodeState.java
Tue Nov  2 13:34:17 2004
@@ -33,14 +33,7 @@
      * @param parentUUID
      */
     protected VirtualNodeState(String uuid, QName nodeTypeName, String parentUUID) {
-        super(uuid, nodeTypeName, parentUUID, ItemState.STATUS_EXISTING_VIRTUAL);
+        super(uuid, nodeTypeName, parentUUID, ItemState.STATUS_EXISTING);
     }
 
-    /**
-     *
-     * @param overlayedState
-     */
-    protected VirtualNodeState(NodeState overlayedState) {
-        super(overlayedState, ItemState.STATUS_EXISTING_VIRTUAL);
-    }
 }

Mime
View raw message