jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r812570 [3/24] - in /jackrabbit/sandbox/JCR-1456: ./ jackrabbit-api/ jackrabbit-api/src/main/appended-resources/ jackrabbit-api/src/main/appended-resources/META-INF/ jackrabbit-api/src/main/java/org/apache/jackrabbit/api/security/ jackrabbi...
Date Tue, 08 Sep 2009 16:09:45 GMT
Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemManager.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemManager.java
(original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemManager.java
Tue Sep  8 16:09:28 2009
@@ -125,13 +125,35 @@
 
         // setup item cache with weak references to items
         itemCache = new ReferenceMap(ReferenceMap.HARD, ReferenceMap.WEAK);
-        itemStateProvider.addListener(this);
 
         // setup shareable nodes cache
         shareableNodesCache = new ShareableNodesCache();
     }
 
     /**
+     * Creates a new per-session instance <code>ItemManager</code> instance.
+     *
+     * @param itemStateProvider the item state provider associated with
+     *                          the new instance
+     * @param hierMgr           the hierarchy manager
+     * @param session           the session associated with the new instance
+     * @param rootNodeDef       the definition of the root node
+     * @param rootNodeId        the id of the root node
+     * @return the item manager instance.
+     */
+    public static ItemManager createInstance(
+            SessionItemStateManager itemStateProvider,
+            HierarchyManager hierMgr,
+            SessionImpl session,
+            NodeDefinition rootNodeDef,
+            NodeId rootNodeId) {
+        ItemManager mgr = new ItemManager(itemStateProvider, hierMgr,
+                session, rootNodeDef, rootNodeId);
+        itemStateProvider.addListener(mgr);
+        return mgr;
+    }
+
+    /**
      * Disposes this <code>ItemManager</code> and frees resources.
      */
     void dispose() {
@@ -141,8 +163,13 @@
         shareableNodesCache.clear();
     }
 
-    private NodeDefinition getDefinition(NodeState state)
+    NodeDefinition getDefinition(NodeState state)
             throws RepositoryException {
+        if (state.getId().equals(rootNodeId)) {
+            // special handling required for root node
+            return rootNodeDef;
+        }
+
         NodeDefId defId = state.getDefinitionId();
         NodeDefinitionImpl def = session.getNodeTypeManager().getNodeDefinition(defId);
         if (def == null) {
@@ -155,7 +182,7 @@
 
             // fallback: try finding applicable definition
             NodeImpl parent = (NodeImpl) getItem(state.getParentId());
-            NodeState parentState = (NodeState) parent.getItemState();
+            NodeState parentState = parent.getNodeState();
             ChildNodeEntry cne = parentState.getChildNodeEntry(state.getNodeId());
             def = parent.getApplicableChildNodeDefinition(cne.getName(), state.getNodeTypeName());
             state.setDefinitionId(def.unwrap().getId());
@@ -163,7 +190,7 @@
         return def;
     }
 
-    private PropertyDefinition getDefinition(PropertyState state)
+    PropertyDefinition getDefinition(PropertyState state)
             throws RepositoryException {
         PropDefId defId = state.getDefinitionId();
         PropertyDefinitionImpl def = session.getNodeTypeManager().getPropertyDefinition(defId);
@@ -577,10 +604,9 @@
             log.debug(msg);
             throw new RepositoryException(msg);
         }
-        Iterator iter = ((NodeState) data.getState()).getChildNodeEntries().iterator();
 
-        while (iter.hasNext()) {
-            ChildNodeEntry entry = (ChildNodeEntry) iter.next();
+        NodeState state = (NodeState) data.getState();
+        for (ChildNodeEntry entry : state.getChildNodeEntries()) {
             // make sure any of the properties can be read.
             if (canRead(entry.getId())) {
                 return true;
@@ -699,16 +725,12 @@
      */
     private ItemData createItemData(ItemState state, Path path, boolean permissionCheck)
throws RepositoryException {
         ItemData data;
-        ItemId id = state.getId();
-        if (id.equals(rootNodeId)) {
-            // special handling required for root node
-            data = new NodeData((NodeState) state, rootNodeDef);
-        } else if (state.isNode()) {
+        if (state.isNode()) {
             NodeState nodeState = (NodeState) state;
-            data = new NodeData(nodeState, getDefinition(nodeState));
+            data = new NodeData(nodeState, this);
         } else {
             PropertyState propertyState = (PropertyState) state;
-            data = new PropertyData(propertyState, getDefinition(propertyState));
+            data = new PropertyData(propertyState, this);
         }
         // make sure read-perm. is granted before returning the data.
         if (permissionCheck && !canRead(data, path)) {

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemValidator.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemValidator.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemValidator.java
(original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemValidator.java
Tue Sep  8 16:09:28 2009
@@ -62,10 +62,11 @@
      * option to check lock status
      */
     public static final int CHECK_LOCK = 2;
+
     /**
      * option to check checked-out status
      */
-    public static final int CHECK_VERSIONING = 4;
+    public static final int CHECK_CHECKED_OUT = 4;
 
     /**
      * check for referential integrity upon removal
@@ -294,9 +295,9 @@
                 throw new ConstraintViolationException(msg);
             }
         }
-        if ((options & CHECK_VERSIONING) == CHECK_VERSIONING) {
+        if ((options & CHECK_CHECKED_OUT) == CHECK_CHECKED_OUT) {
             NodeImpl node = (item.isNode()) ? (NodeImpl) item : (NodeImpl) item.getParent();
-            if (!node.internalIsCheckedOut()) {
+            if (!node.isCheckedOut()) {
                 String msg = "Unable to perform operation. Node is checked-in.";
                 log.debug(msg);
                 throw new VersionException(msg);
@@ -342,9 +343,9 @@
                 return false;
             }
         }
-        if ((options & CHECK_VERSIONING) == CHECK_VERSIONING) {
+        if ((options & CHECK_CHECKED_OUT) == CHECK_CHECKED_OUT) {
             NodeImpl node = (item.isNode()) ? (NodeImpl) item : (NodeImpl) item.getParent();
-            if (!node.internalIsCheckedOut()) {
+            if (!node.isCheckedOut()) {
                 return false;
             }
         }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/JackrabbitRepositoryStub.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/JackrabbitRepositoryStub.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/JackrabbitRepositoryStub.java
(original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/JackrabbitRepositoryStub.java
Tue Sep  8 16:09:28 2009
@@ -39,6 +39,7 @@
 import javax.jcr.Session;
 import javax.jcr.Value;
 import javax.jcr.ValueFactory;
+import javax.jcr.nodetype.NodeType;
 import javax.jcr.retention.RetentionPolicy;
 
 import org.apache.commons.io.IOUtils;
@@ -235,6 +236,7 @@
         addPropertyTestData(getOrAddNode(data, "property"));
         addQueryTestData(getOrAddNode(data, "query"));
         addNodeTestData(getOrAddNode(data, "node"));
+        addLifecycleTestData(getOrAddNode(data, "lifecycle"));
         addExportTestData(getOrAddNode(data, "docViewTest"));
 
         Node conf = getOrAddNode(session.getRootNode(), "testconf");
@@ -330,6 +332,22 @@
             });
     }
 
+    /**
+     * Creates a lifecycle policy node and another node with a lifecycle
+     * referencing that policy.
+     */
+    private void addLifecycleTestData(Node node) throws RepositoryException {
+        Node policy = getOrAddNode(node, "policy");
+        policy.addMixin(NodeType.MIX_REFERENCEABLE);
+        Node transitions = getOrAddNode(policy, "transitions");
+        Node transition = getOrAddNode(transitions, "identity");
+        transition.setProperty("from", "identity");
+        transition.setProperty("to", "identity");
+
+        Node lifecycle = getOrAddNode(node, "node");
+        ((NodeImpl) lifecycle).assignLifecyclePolicy(policy, "identity");
+    }
+
     private void addExportTestData(Node node) throws RepositoryException, IOException {
         getOrAddNode(node, "invalidXmlName").setProperty("propName", "some text");
 

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeData.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeData.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeData.java
(original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeData.java
Tue Sep  8 16:09:28 2009
@@ -16,7 +16,6 @@
  */
 package org.apache.jackrabbit.core;
 
-import javax.jcr.nodetype.NodeDefinition;
 import org.apache.jackrabbit.core.state.NodeState;
 
 /**
@@ -30,9 +29,9 @@
      * Create a new instance of this class.
      *
      * @param state node state
-     * @param definition node definition
+     * @param itemMgr item manager
      */
-    NodeData(NodeState state, NodeDefinition definition) {
-        super(state, definition);
+    NodeData(NodeState state, ItemManager itemMgr) {
+        super(state, itemMgr);
     }
 }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeDataRef.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeDataRef.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeDataRef.java
(original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeDataRef.java
Tue Sep  8 16:09:28 2009
@@ -17,6 +17,7 @@
 package org.apache.jackrabbit.core;
 
 import javax.jcr.nodetype.ItemDefinition;
+import javax.jcr.RepositoryException;
 
 import org.apache.jackrabbit.core.id.NodeId;
 import org.apache.jackrabbit.core.state.ItemState;
@@ -66,8 +67,9 @@
      * {@inheritDoc}
      *
      * This implementation returns the definition of the referenced data object.
+     * @throws RepositoryException if the definition cannot be retrieved.
      */
-    public ItemDefinition getDefinition() {
+    public ItemDefinition getDefinition() throws RepositoryException {
         return data.getDefinition();
     }
 



Mime
View raw message