jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r985832 - in /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core: ./ state/ version/
Date Mon, 16 Aug 2010 08:51:59 GMT
Author: jukka
Date: Mon Aug 16 08:51:59 2010
New Revision: 985832

URL: http://svn.apache.org/viewvc?rev=985832&view=rev
Log:
JCR-890: concurrent read-only access to a session

Reverted revision 985273 based on discussion on dev@

Added:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeTypeInstanceHandler.java
      - copied unchanged from r985272, jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeTypeInstanceHandler.java
Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/BatchedItemOperations.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/NodeState.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/PropertyState.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImplRestore.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/BatchedItemOperations.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/BatchedItemOperations.java?rev=985832&r1=985831&r2=985832&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/BatchedItemOperations.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/BatchedItemOperations.java
Mon Aug 16 08:51:59 2010
@@ -1255,7 +1255,13 @@ public class BatchedItemOperations exten
         prop.setMultiValued(def.isMultiple());
 
         // compute system generated values if necessary
-        prop.setDefaultValues(parent, def, session.getUserID());
+        InternalValue[] genValues = session.getNodeTypeInstanceHandler()
+                .computeSystemGeneratedPropertyValues(parent, def);
+        if (genValues != null) {
+            prop.setValues(genValues);
+        } else if (def.getDefaultValues() != null) {
+            prop.setValues(InternalValue.create(def.getDefaultValues()));
+        }
 
         // now add new property entry to parent
         parent.addPropertyName(propName);

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java?rev=985832&r1=985831&r2=985832&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java
Mon Aug 16 08:51:59 2010
@@ -471,8 +471,15 @@ public class NodeImpl extends ItemImpl i
             propState.setType(type);
             propState.setMultiValued(propDef.isMultiple());
             // compute system generated values if necessary
-            propState.setDefaultValues(
-                    data.getNodeState(), propDef, getSession().getUserID());
+            InternalValue[] genValues =
+                sessionContext.getSessionImpl().getNodeTypeInstanceHandler()
+                .computeSystemGeneratedPropertyValues(data.getNodeState(), propDef);
+            if (genValues == null) {
+                genValues = InternalValue.create(propDef.getDefaultValues());
+            }
+            if (genValues != null) {
+                propState.setValues(genValues);
+            }
         } catch (ItemStateException ise) {
             String msg = "failed to add property " + name + " to " + this;
             log.debug(msg);

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java?rev=985832&r1=985831&r2=985832&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java
Mon Aug 16 08:51:59 2010
@@ -167,6 +167,11 @@ public class SessionImpl extends Abstrac
     protected final InternalVersionManager versionMgr;
 
     /**
+     * node type instance handler
+     */
+    protected final NodeTypeInstanceHandler ntInstanceHandler;
+
+    /**
      * Listeners (weak references)
      */
     protected final Map<SessionListener, SessionListener> listeners =
@@ -240,6 +245,7 @@ public class SessionImpl extends Abstrac
                 createObservationManager(wspConfig.getName()));
 
         versionMgr = createVersionManager();
+        ntInstanceHandler = new NodeTypeInstanceHandler(userId);
     }
 
     /**
@@ -432,6 +438,14 @@ public class SessionImpl extends Abstrac
     }
 
     /**
+     * Returns the node type instance handler for this session
+     * @return the node type instance handler.
+     */
+    public NodeTypeInstanceHandler getNodeTypeInstanceHandler() {
+        return ntInstanceHandler;
+    }
+
+    /**
      * Sets the named attribute. If the value is <code>null</code>, then
      * the named attribute is removed.
      *

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/NodeState.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/NodeState.java?rev=985832&r1=985831&r2=985832&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/NodeState.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/NodeState.java
Mon Aug 16 08:51:59 2010
@@ -18,21 +18,15 @@ package org.apache.jackrabbit.core.state
 
 import org.apache.jackrabbit.core.id.ItemId;
 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.QPropertyDefinition;
-import org.apache.jackrabbit.spi.commons.name.NameConstants;
 
 import java.util.ArrayList;
-import java.util.Calendar;
 import java.util.Collections;
 import java.util.HashSet;
 import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Set;
 
-import javax.jcr.RepositoryException;
-
 /**
  * <code>NodeState</code> represents the state of a <code>Node</code>.
  */
@@ -868,70 +862,6 @@ public class NodeState extends ItemState
     //-------------------------------------------------< misc. helper methods >
 
     /**
-     * Computes the values of well-known system (i.e. protected) properties.
-     *
-     * @param def the definition of the property to compute
-     * @return the computed values
-     */
-    public InternalValue[] computeGeneratedValues(
-            QPropertyDefinition def, String userId) {
-        if (userId == null) {
-            userId = "system";
-        }
-
-        Name name = def.getName();
-        Name declaringNT = def.getDeclaringNodeType();
-
-        if (NameConstants.JCR_UUID.equals(name)) {
-            // jcr:uuid property of the mix:referenceable node type
-            if (NameConstants.MIX_REFERENCEABLE.equals(declaringNT)) {
-                return new InternalValue[]{InternalValue.create(getNodeId().toString())};
-            }
-        } else if (NameConstants.JCR_PRIMARYTYPE.equals(name)) {
-            // jcr:primaryType property (of any node type)
-            return new InternalValue[]{InternalValue.create(getNodeTypeName())};
-        } else if (NameConstants.JCR_MIXINTYPES.equals(name)) {
-            // jcr:mixinTypes property (of any node type)
-            Set<Name> mixins = getMixinTypeNames();
-            InternalValue[] values = new InternalValue[mixins.size()];
-            int i = 0;
-            for (Name n : mixins) {
-                values[i++] = InternalValue.create(n);
-            }
-            return values;
-        } else if (NameConstants.JCR_CREATED.equals(name)) {
-            // jcr:created property of a version or a mix:created
-            if (NameConstants.MIX_CREATED.equals(declaringNT)
-                    || NameConstants.NT_VERSION.equals(declaringNT)) {
-                return new InternalValue[]{InternalValue.create(Calendar.getInstance())};
-            }
-        } else if (NameConstants.JCR_CREATEDBY.equals(name)) {
-            // jcr:createdBy property of a mix:created
-            if (NameConstants.MIX_CREATED.equals(declaringNT)) {
-                return new InternalValue[]{InternalValue.create(userId)};
-            }
-        } else if (NameConstants.JCR_LASTMODIFIED.equals(name)) {
-            // jcr:lastModified property of a mix:lastModified
-            if (NameConstants.MIX_LASTMODIFIED.equals(declaringNT)) {
-                return new InternalValue[]{InternalValue.create(Calendar.getInstance())};
-            }
-        } else if (NameConstants.JCR_LASTMODIFIEDBY.equals(name)) {
-            // jcr:lastModifiedBy property of a mix:lastModified
-            if (NameConstants.MIX_LASTMODIFIED.equals(declaringNT)) {
-                return new InternalValue[]{InternalValue.create(userId)};
-            }
-        } else if (NameConstants.JCR_ETAG.equals(name)) {
-            // jcr:etag property of a mix:etag
-            if (NameConstants.MIX_ETAG.equals(declaringNT)) {
-                // TODO: provide real implementation
-                return new InternalValue[]{InternalValue.create("")};
-            }
-        }
-
-        return null;
-    }
-
-    /**
      * {@inheritDoc}
      */
     public long calculateMemoryFootprint() {

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/PropertyState.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/PropertyState.java?rev=985832&r1=985831&r2=985832&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/PropertyState.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/PropertyState.java
Mon Aug 16 08:51:59 2010
@@ -21,10 +21,8 @@ import org.apache.jackrabbit.core.id.Nod
 import org.apache.jackrabbit.core.id.ItemId;
 import org.apache.jackrabbit.core.value.InternalValue;
 import org.apache.jackrabbit.spi.Name;
-import org.apache.jackrabbit.spi.QPropertyDefinition;
 
 import javax.jcr.PropertyType;
-import javax.jcr.RepositoryException;
 
 /**
  * <code>PropertyState</code> represents the state of a <code>Property</code>.
@@ -187,28 +185,6 @@ public class PropertyState extends ItemS
     }
 
     /**
-     * Sets the system-generated or node type -specified default values
-     * of this property. If such values are not specified, then this property
-     * is not modified.
-     * 
-     * @param parent parent node state
-     * @param def property definition
-     * @param userId user identifier associated with the current session
-     * @throws RepositoryException if the default values could not be created 
-     */
-    public void setDefaultValues(
-            NodeState parent, QPropertyDefinition def, String userId)
-            throws RepositoryException {
-        InternalValue[] values = parent.computeGeneratedValues(def, userId);
-        if (values == null) {
-            values = InternalValue.create(def.getDefaultValues());
-        }
-        if (values != null) {
-            setValues(values);
-        }
-    }
-
-    /**
      * Returns the value(s) of this property.
      *
      * @return the value(s) of this property.

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImplRestore.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImplRestore.java?rev=985832&r1=985831&r2=985832&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImplRestore.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImplRestore.java
Mon Aug 16 08:51:59 2010
@@ -651,8 +651,8 @@ abstract public class VersionManagerImpl
                                               boolean useDefaultValues)
             throws RepositoryException {
         // compute system generated values if necessary
-        InternalValue[] values =
-            state.getState().computeGeneratedValues(def, session.getUserID());
+        InternalValue[] values = session.getNodeTypeInstanceHandler().
+                computeSystemGeneratedPropertyValues(state.getState(), def);
         if (values == null && useDefaultValues) {
             values = InternalValue.create(def.getDefaultValues());
         }



Mime
View raw message