jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1378981 - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/ oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/
Date Thu, 30 Aug 2012 15:13:31 GMT
Author: mduerig
Date: Thu Aug 30 15:13:30 2012
New Revision: 1378981

URL: http://svn.apache.org/viewvc?rev=1378981&view=rev
Log:
OAK-66: JCR Node Type Management
refactor NodeTypeManagerImpl: remove session scope remove session scope dependencies 

Added:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/AbstractNodeTypeManager.java
Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/NodeTypeManagerImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/PropertyDefinitionImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/WorkspaceImpl.java

Added: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/AbstractNodeTypeManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/AbstractNodeTypeManager.java?rev=1378981&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/AbstractNodeTypeManager.java
(added)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/AbstractNodeTypeManager.java
Thu Aug 30 15:13:30 2012
@@ -0,0 +1,185 @@
+package org.apache.jackrabbit.oak.plugins.type;
+
+import java.util.List;
+
+import javax.annotation.CheckForNull;
+import javax.annotation.Nonnull;
+import javax.jcr.RepositoryException;
+import javax.jcr.UnsupportedRepositoryOperationException;
+import javax.jcr.ValueFactory;
+import javax.jcr.nodetype.NoSuchNodeTypeException;
+import javax.jcr.nodetype.NodeDefinitionTemplate;
+import javax.jcr.nodetype.NodeType;
+import javax.jcr.nodetype.NodeTypeDefinition;
+import javax.jcr.nodetype.NodeTypeIterator;
+import javax.jcr.nodetype.NodeTypeManager;
+import javax.jcr.nodetype.NodeTypeTemplate;
+import javax.jcr.nodetype.PropertyDefinitionTemplate;
+
+import com.google.common.collect.Lists;
+import org.apache.jackrabbit.commons.iterator.NodeTypeIteratorAdapter;
+import org.apache.jackrabbit.oak.api.CoreValueFactory;
+import org.apache.jackrabbit.oak.api.Tree;
+import org.apache.jackrabbit.oak.namepath.NameMapper;
+import org.apache.jackrabbit.oak.namepath.NamePathMapperImpl;
+import org.apache.jackrabbit.oak.plugins.memory.MemoryValueFactory;
+import org.apache.jackrabbit.oak.util.NodeUtil;
+
+public abstract class AbstractNodeTypeManager implements NodeTypeManager {
+
+    /**
+     * Returns the internal name for the specified JCR name.
+     *
+     * @param jcrName JCR node type name.
+     * @return the internal representation of the given JCR name.
+     * @throws javax.jcr.RepositoryException If there is no valid internal representation
+     * of the specified JCR name.
+     */
+    @Nonnull
+    protected final String getOakName(String jcrName) throws RepositoryException {
+        String oakName = getNameMapper().getOakName(jcrName);
+        if (oakName == null) {
+            throw new RepositoryException("Invalid JCR name " + jcrName);
+        }
+        return oakName;
+    }
+
+    /**
+     * @return  {@link org.apache.jackrabbit.oak.api.Tree} instance where the node types
+     * are stored or {@code null} if none.
+     */
+    @CheckForNull
+    protected abstract Tree getTypes();
+
+    /**
+     * Called by the {@link NodeTypeManager} implementation methods to
+     * refresh the state of the session associated with this instance.
+     * That way the session is kept in sync with the latest global state
+     * seen by the node type manager.
+     *
+     * @throws RepositoryException if the session could not be refreshed
+     */
+    protected void refresh() throws RepositoryException {
+    }
+
+    /**
+     * The value factory to be used by {@link org.apache.jackrabbit.oak.plugins.type.PropertyDefinitionImpl#getDefaultValues()}.
+     * If {@code null} the former returns {@code null}.
+     * @return  {@code ValueFactory} instance or {@code null}.
+     */
+    @CheckForNull
+    protected ValueFactory getValueFactory() {
+        return null;
+    }
+
+    @Nonnull
+    protected CoreValueFactory getCoreValueFactory() {
+        return MemoryValueFactory.INSTANCE;
+    }
+
+    @Nonnull
+    protected NameMapper getNameMapper() {
+        return NamePathMapperImpl.DEFAULT;
+    }
+
+    //----------------------------------------------------< NodeTypeManager >---
+
+    @Override
+    public boolean hasNodeType(String name) throws RepositoryException {
+        Tree types = getTypes();
+        return types != null && types.hasChild(getOakName(name));
+    }
+
+    @Override
+    public NodeType getNodeType(String name) throws RepositoryException {
+        Tree types = getTypes();
+        if (types != null) {
+            Tree type = types.getChild(getOakName(name));
+            if (type != null) {
+                return new NodeTypeImpl(this, getValueFactory(),
+                        new NodeUtil(type, getCoreValueFactory(), getNameMapper()));
+            }
+        }
+        throw new NoSuchNodeTypeException(name);
+    }
+
+    @Override
+    public NodeTypeIterator getAllNodeTypes() throws RepositoryException {
+        List<NodeType> list = Lists.newArrayList();
+        Tree types = getTypes();
+        if (types != null) {
+            for (Tree type : types.getChildren()) {
+                list.add(new NodeTypeImpl(this, getValueFactory(),
+                        new NodeUtil(type, getCoreValueFactory(), getNameMapper())));
+
+            }
+        }
+        return new NodeTypeIteratorAdapter(list);
+    }
+
+    @Override
+    public NodeTypeIterator getPrimaryNodeTypes() throws RepositoryException {
+        List<NodeType> list = Lists.newArrayList();
+        NodeTypeIterator iterator = getAllNodeTypes();
+        while (iterator.hasNext()) {
+            NodeType type = iterator.nextNodeType();
+            if (!type.isMixin()) {
+                list.add(type);
+            }
+        }
+        return new NodeTypeIteratorAdapter(list);
+    }
+
+    @Override
+    public NodeTypeIterator getMixinNodeTypes() throws RepositoryException {
+        List<NodeType> list = Lists.newArrayList();
+        NodeTypeIterator iterator = getAllNodeTypes();
+        while (iterator.hasNext()) {
+            NodeType type = iterator.nextNodeType();
+            if (type.isMixin()) {
+                list.add(type);
+            }
+        }
+        return new NodeTypeIteratorAdapter(list);
+    }
+
+    @Override
+    public NodeTypeTemplate createNodeTypeTemplate() throws RepositoryException {
+        return new NodeTypeTemplateImpl(this, getValueFactory());
+    }
+
+    @Override
+    public NodeTypeTemplate createNodeTypeTemplate(NodeTypeDefinition ntd) throws RepositoryException
{
+        return new NodeTypeTemplateImpl(this, getValueFactory(), ntd);
+    }
+
+    @Override
+    public NodeDefinitionTemplate createNodeDefinitionTemplate() {
+        return new NodeDefinitionTemplateImpl();
+    }
+
+    @Override
+    public PropertyDefinitionTemplate createPropertyDefinitionTemplate() {
+        return new PropertyDefinitionTemplateImpl();
+    }
+
+    @Override
+    public NodeType registerNodeType(NodeTypeDefinition ntd, boolean allowUpdate) throws
RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    @Override
+    public NodeTypeIterator registerNodeTypes(NodeTypeDefinition[] ntds, boolean allowUpdate)
throws RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    @Override
+    public void unregisterNodeType(String name) throws RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    @Override
+    public void unregisterNodeTypes(String[] names) throws RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+}

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/NodeTypeManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/NodeTypeManagerImpl.java?rev=1378981&r1=1378980&r2=1378981&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/NodeTypeManagerImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/NodeTypeManagerImpl.java
Thu Aug 30 15:13:30 2012
@@ -21,7 +21,6 @@ import java.io.InputStreamReader;
 import java.util.List;
 import java.util.Map;
 
-import javax.annotation.Nonnull;
 import javax.jcr.PropertyType;
 import javax.jcr.RepositoryException;
 import javax.jcr.Value;
@@ -29,17 +28,17 @@ import javax.jcr.ValueFactory;
 import javax.jcr.nodetype.ItemDefinition;
 import javax.jcr.nodetype.NoSuchNodeTypeException;
 import javax.jcr.nodetype.NodeDefinition;
-import javax.jcr.nodetype.NodeDefinitionTemplate;
 import javax.jcr.nodetype.NodeType;
 import javax.jcr.nodetype.NodeTypeDefinition;
 import javax.jcr.nodetype.NodeTypeExistsException;
 import javax.jcr.nodetype.NodeTypeIterator;
-import javax.jcr.nodetype.NodeTypeManager;
 import javax.jcr.nodetype.NodeTypeTemplate;
 import javax.jcr.nodetype.PropertyDefinition;
-import javax.jcr.nodetype.PropertyDefinitionTemplate;
 import javax.jcr.version.OnParentVersionAction;
 
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import org.apache.jackrabbit.JcrConstants;
 import org.apache.jackrabbit.commons.cnd.CompactNodeTypeDefReader;
 import org.apache.jackrabbit.commons.iterator.NodeTypeIteratorAdapter;
 import org.apache.jackrabbit.oak.api.CommitFailedException;
@@ -49,12 +48,9 @@ import org.apache.jackrabbit.oak.api.Roo
 import org.apache.jackrabbit.oak.api.Tree;
 import org.apache.jackrabbit.oak.core.DefaultConflictHandler;
 import org.apache.jackrabbit.oak.namepath.NameMapper;
-
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
 import org.apache.jackrabbit.oak.util.NodeUtil;
 
-public class NodeTypeManagerImpl implements NodeTypeManager, NodeTypeConstants {
+public class NodeTypeManagerImpl extends AbstractNodeTypeManager {
 
     private final ContentSession session;
 
@@ -62,8 +58,7 @@ public class NodeTypeManagerImpl impleme
 
     private final ValueFactory factory;
 
-    public NodeTypeManagerImpl(
-            ContentSession session, NameMapper mapper, ValueFactory factory) {
+    public NodeTypeManagerImpl(ContentSession session, NameMapper mapper, ValueFactory factory)
{
         this.session = session;
         this.mapper = mapper;
         this.factory = factory;
@@ -86,12 +81,12 @@ public class NodeTypeManagerImpl impleme
                     }
                     for (NodeTypeTemplate template : templates.values()) {
                         if (!template.isMixin()
-                                && !NT_BASE.equals(template.getName())) {
+                                && !JcrConstants.NT_BASE.equals(template.getName()))
{
                             String[] supertypes =
                                     template.getDeclaredSupertypeNames();
                             if (supertypes.length == 0) {
                                 template.setDeclaredSuperTypeNames(
-                                        new String[] {NT_BASE});
+                                        new String[] {JcrConstants.NT_BASE});
                             } else {
                                 // Check whether we need to add the implicit "nt:base" supertype
                                 boolean needsNtBase = true;
@@ -102,7 +97,7 @@ public class NodeTypeManagerImpl impleme
                                 }
                                 if (needsNtBase) {
                                     String[] withBase = new String[supertypes.length + 1];
-                                    withBase[0] = NT_BASE;
+                                    withBase[0] = JcrConstants.NT_BASE;
                                     System.arraycopy(supertypes, 0, withBase, 1, supertypes.length);
                                     template.setDeclaredSuperTypeNames(withBase);
                                 }
@@ -121,114 +116,27 @@ public class NodeTypeManagerImpl impleme
         }
     }
 
-    /**
-     * Returns the internal name for the specified JCR name.
-     *
-     * @param jcrName JCR node type name.
-     * @return the internal representation of the given JCR name.
-     * @throws RepositoryException If there is no valid internal representation
-     * of the specified JCR name.
-     */
-    @Nonnull
-    protected String getOakName(String jcrName) throws RepositoryException {
-        String oakName = mapper.getOakName(jcrName);
-        if (oakName == null) {
-            throw new RepositoryException("Invalid JCR name " + jcrName);
-        }
-        return oakName;
-    }
-
-    /**
-     * Called by the {@link NodeTypeManager} implementation methods to
-     * refresh the state of the session associated with this instance.
-     * That way the session is kept in sync with the latest global state
-     * seen by the node type manager.
-     *
-     * @throws RepositoryException if the session could not be refreshed
-     */
-    protected void refresh() throws RepositoryException {
-    }
-
-    //----------------------------------------------------< NodeTypeManager >---
-
-    @Override
-    public boolean hasNodeType(String name) throws RepositoryException {
-        Tree types = session.getCurrentRoot().getTree(NODE_TYPES_PATH);
-        return types != null && types.hasChild(getOakName(name));
-    }
-
-    @Override
-    public NodeType getNodeType(String name) throws RepositoryException {
-        Tree types = session.getCurrentRoot().getTree(NODE_TYPES_PATH);
-        if (types != null) {
-            Tree type = types.getChild(getOakName(name));
-            if (type != null) {
-                return new NodeTypeImpl(this, factory, new NodeUtil(
-                        type, session.getCoreValueFactory(), mapper));
-            }
-        }
-        throw new NoSuchNodeTypeException(name);
-    }
-
     @Override
-    public NodeTypeIterator getAllNodeTypes() throws RepositoryException {
-        List<NodeType> list = Lists.newArrayList();
-        Tree types = session.getCurrentRoot().getTree(NODE_TYPES_PATH);
-        if (types != null) {
-            for (Tree type : types.getChildren()) {
-                list.add(new NodeTypeImpl(this, factory, new NodeUtil(
-                        type, session.getCoreValueFactory(), mapper)));
-
-            }
-        }
-        return new NodeTypeIteratorAdapter(list);
-    }
-
-    @Override
-    public NodeTypeIterator getPrimaryNodeTypes() throws RepositoryException {
-        List<NodeType> list = Lists.newArrayList();
-        NodeTypeIterator iterator = getAllNodeTypes();
-        while (iterator.hasNext()) {
-            NodeType type = iterator.nextNodeType();
-            if (!type.isMixin()) {
-                list.add(type);
-            }
-        }
-        return new NodeTypeIteratorAdapter(list);
+    protected Tree getTypes() {
+        return session.getCurrentRoot().getTree(NodeTypeConstants.NODE_TYPES_PATH);
     }
 
     @Override
-    public NodeTypeIterator getMixinNodeTypes() throws RepositoryException {
-        List<NodeType> list = Lists.newArrayList();
-        NodeTypeIterator iterator = getAllNodeTypes();
-        while (iterator.hasNext()) {
-            NodeType type = iterator.nextNodeType();
-            if (type.isMixin()) {
-                list.add(type);
-            }
-        }
-        return new NodeTypeIteratorAdapter(list);
-    }
-
-    @Override
-    public NodeTypeTemplate createNodeTypeTemplate() throws RepositoryException {
-        return new NodeTypeTemplateImpl(this, factory);
+    protected ValueFactory getValueFactory() {
+        return factory;
     }
 
     @Override
-    public NodeTypeTemplate createNodeTypeTemplate(NodeTypeDefinition ntd) throws RepositoryException
{
-        return new NodeTypeTemplateImpl(this, factory, ntd);
+    protected CoreValueFactory getCoreValueFactory() {
+        return session.getCoreValueFactory();
     }
 
     @Override
-    public NodeDefinitionTemplate createNodeDefinitionTemplate() {
-        return new NodeDefinitionTemplateImpl();
+    protected NameMapper getNameMapper() {
+        return mapper;
     }
 
-    @Override
-    public PropertyDefinitionTemplate createPropertyDefinitionTemplate() {
-        return new PropertyDefinitionTemplateImpl();
-    }
+    //----------------------------------------------------< NodeTypeManager >---
 
     @Override
     public NodeType registerNodeType(NodeTypeDefinition ntd, boolean allowUpdate) throws
RepositoryException {
@@ -245,7 +153,8 @@ public class NodeTypeManagerImpl impleme
     }
 
     @Override
-    public NodeTypeIterator registerNodeTypes(NodeTypeDefinition[] ntds, boolean allowUpdate)
throws RepositoryException {
+    public final NodeTypeIterator registerNodeTypes(NodeTypeDefinition[] ntds, boolean allowUpdate)
+            throws RepositoryException {
         // TODO handle inter-type dependencies (OAK-66)
         Root root = session.getCurrentRoot();
         Tree types = getOrCreateNodeTypes(root);
@@ -278,100 +187,99 @@ public class NodeTypeManagerImpl impleme
         }
         type = types.addChild(oakName);
 
-        CoreValueFactory factory = session.getCoreValueFactory();
-        NodeUtil node = new NodeUtil(type, factory, mapper);
-        node.setName(JCR_PRIMARYTYPE, NT_NODETYPE);
-        node.setName(JCR_NODETYPENAME, jcrName);
-        node.setNames(JCR_SUPERTYPES, ntd.getDeclaredSupertypeNames());
-        node.setBoolean(JCR_IS_ABSTRACT, ntd.isAbstract());
-        node.setBoolean(JCR_IS_QUERYABLE, ntd.isQueryable());
-        node.setBoolean(JCR_ISMIXIN, ntd.isMixin());
-        node.setBoolean(JCR_HASORDERABLECHILDNODES, ntd.hasOrderableChildNodes());
+        NodeUtil node = new NodeUtil(type, getCoreValueFactory(), mapper);
+        node.setName(JcrConstants.JCR_PRIMARYTYPE, JcrConstants.NT_NODETYPE);
+        node.setName(JcrConstants.JCR_NODETYPENAME, jcrName);
+        node.setNames(JcrConstants.JCR_SUPERTYPES, ntd.getDeclaredSupertypeNames());
+        node.setBoolean(NodeTypeConstants.JCR_IS_ABSTRACT, ntd.isAbstract());
+        node.setBoolean(NodeTypeConstants.JCR_IS_QUERYABLE, ntd.isQueryable());
+        node.setBoolean(JcrConstants.JCR_ISMIXIN, ntd.isMixin());
+        node.setBoolean(JcrConstants.JCR_HASORDERABLECHILDNODES, ntd.hasOrderableChildNodes());
         String primaryItemName = ntd.getPrimaryItemName();
         if (primaryItemName != null) {
-            node.setName(JCR_PRIMARYITEMNAME, primaryItemName);
+            node.setName(JcrConstants.JCR_PRIMARYITEMNAME, primaryItemName);
         }
 
         int pdn = 1;
         for (PropertyDefinition pd : ntd.getDeclaredPropertyDefinitions()) {
-            NodeUtil def = node.addChild(JCR_PROPERTYDEFINITION + pdn++, NT_PROPERTYDEFINITION);
+            NodeUtil def = node.addChild(JcrConstants.JCR_PROPERTYDEFINITION + pdn++, JcrConstants.NT_PROPERTYDEFINITION);
             internalRegisterPropertyDefinition(def, pd);
         }
 
         int ndn = 1;
         for (NodeDefinition nd : ntd.getDeclaredChildNodeDefinitions()) {
-            NodeUtil def = node.addChild(JCR_CHILDNODEDEFINITION + ndn++, NT_CHILDNODEDEFINITION);
+            NodeUtil def = node.addChild(JcrConstants.JCR_CHILDNODEDEFINITION + ndn++, JcrConstants.NT_CHILDNODEDEFINITION);
             internalRegisterNodeDefinition(def, nd);
         }
 
         return new NodeTypeImpl(this, this.factory, node);
     }
 
-    private void internalRegisterItemDefinition(
+    private static void internalRegisterItemDefinition(
             NodeUtil node, ItemDefinition def) {
         String name = def.getName();
         if (!"*".equals(name)) {
-            node.setName(JCR_NAME, name);
+            node.setName(JcrConstants.JCR_NAME, name);
         }
-        node.setBoolean(JCR_AUTOCREATED, def.isAutoCreated());
-        node.setBoolean(JCR_MANDATORY, def.isMandatory());
-        node.setBoolean(JCR_PROTECTED, def.isProtected());
+        node.setBoolean(JcrConstants.JCR_AUTOCREATED, def.isAutoCreated());
+        node.setBoolean(JcrConstants.JCR_MANDATORY, def.isMandatory());
+        node.setBoolean(JcrConstants.JCR_PROTECTED, def.isProtected());
         node.setString(
-                JCR_ONPARENTVERSION,
+                JcrConstants.JCR_ONPARENTVERSION,
                 OnParentVersionAction.nameFromValue(def.getOnParentVersion()));
     }
 
-    private void internalRegisterPropertyDefinition(
+    private static void internalRegisterPropertyDefinition(
             NodeUtil node, PropertyDefinition def) {
         internalRegisterItemDefinition(node, def);
 
         node.setString(
-                JCR_REQUIREDTYPE,
+                JcrConstants.JCR_REQUIREDTYPE,
                 PropertyType.nameFromValue(def.getRequiredType()));
-        node.setBoolean(JCR_MULTIPLE, def.isMultiple());
-        node.setBoolean(JCR_IS_FULLTEXT_SEARCHABLE, def.isFullTextSearchable());
-        node.setBoolean(JCR_IS_QUERY_ORDERABLE, def.isQueryOrderable());
-        node.setStrings(JCR_AVAILABLE_QUERY_OPERATORS, def.getAvailableQueryOperators());
+        node.setBoolean(JcrConstants.JCR_MULTIPLE, def.isMultiple());
+        node.setBoolean(NodeTypeConstants.JCR_IS_FULLTEXT_SEARCHABLE, def.isFullTextSearchable());
+        node.setBoolean(NodeTypeConstants.JCR_IS_QUERY_ORDERABLE, def.isQueryOrderable());
+        node.setStrings(NodeTypeConstants.JCR_AVAILABLE_QUERY_OPERATORS, def.getAvailableQueryOperators());
 
         String[] constraints = def.getValueConstraints();
         if (constraints != null) {
-            node.setStrings(JCR_VALUECONSTRAINTS, constraints);
+            node.setStrings(JcrConstants.JCR_VALUECONSTRAINTS, constraints);
         }
 
         Value[] values = def.getDefaultValues();
         if (values != null) {
-            node.setValues(JCR_DEFAULTVALUES, values);
+            node.setValues(JcrConstants.JCR_DEFAULTVALUES, values);
         }
     }
 
-    private void internalRegisterNodeDefinition(NodeUtil node, NodeDefinition def) {
+    private static void internalRegisterNodeDefinition(NodeUtil node, NodeDefinition def)
{
         internalRegisterItemDefinition(node, def);
 
-        node.setBoolean(JCR_SAMENAMESIBLINGS, def.allowsSameNameSiblings());
+        node.setBoolean(JcrConstants.JCR_SAMENAMESIBLINGS, def.allowsSameNameSiblings());
         node.setNames(
-                JCR_REQUIREDPRIMARYTYPES,
+                JcrConstants.JCR_REQUIREDPRIMARYTYPES,
                 def.getRequiredPrimaryTypeNames());
         String defaultPrimaryType = def.getDefaultPrimaryTypeName();
         if (defaultPrimaryType != null) {
-            node.setName(JCR_DEFAULTPRIMARYTYPE, defaultPrimaryType);
+            node.setName(JcrConstants.JCR_DEFAULTPRIMARYTYPE, defaultPrimaryType);
         }
     }
 
-    private Tree getOrCreateNodeTypes(Root root) {
-        Tree types = root.getTree(NODE_TYPES_PATH);
+    private static Tree getOrCreateNodeTypes(Root root) {
+        Tree types = root.getTree(NodeTypeConstants.NODE_TYPES_PATH);
         if (types == null) {
-            Tree system = root.getTree(JCR_SYSTEM);
+            Tree system = root.getTree('/' + JcrConstants.JCR_SYSTEM);
             if (system == null) {
-                system = root.getTree("").addChild(JCR_SYSTEM);
+                system = root.getTree("/").addChild(JcrConstants.JCR_SYSTEM);
             }
-            types = system.addChild(JCR_NODE_TYPES);
+            types = system.addChild(NodeTypeConstants.JCR_NODE_TYPES);
         }
         return types;
     }
 
     private boolean nodeTypesInContent() {
         Root currentRoot = session.getCurrentRoot();
-        Tree types = currentRoot.getTree(NODE_TYPES_PATH);
+        Tree types = currentRoot.getTree(NodeTypeConstants.NODE_TYPES_PATH);
         return types != null && types.getChildrenCount() > 0;
     }
 
@@ -379,7 +287,7 @@ public class NodeTypeManagerImpl impleme
     public void unregisterNodeType(String name) throws RepositoryException {
         Tree type = null;
         Root root = session.getCurrentRoot();
-        Tree types = root.getTree(NODE_TYPES_PATH);
+        Tree types = root.getTree(NodeTypeConstants.NODE_TYPES_PATH);
         if (types != null) {
             type = types.getChild(getOakName(name));
         }
@@ -399,7 +307,7 @@ public class NodeTypeManagerImpl impleme
     @Override
     public void unregisterNodeTypes(String[] names) throws RepositoryException {
         Root root = session.getCurrentRoot();
-        Tree types = root.getTree(NODE_TYPES_PATH);
+        Tree types = root.getTree(NodeTypeConstants.NODE_TYPES_PATH);
         if (types == null) {
             throw new NoSuchNodeTypeException("Node types can not be unregistered.");
         }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/PropertyDefinitionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/PropertyDefinitionImpl.java?rev=1378981&r1=1378980&r2=1378981&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/PropertyDefinitionImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/PropertyDefinitionImpl.java
Thu Aug 30 15:13:30 2012
@@ -75,7 +75,13 @@ class PropertyDefinitionImpl extends Ite
 
     @Override
     public Value[] getDefaultValues() {
-        return node.getValues("jcr:defaultValues", factory);
+        if (factory != null) {
+            return node.getValues("jcr:defaultValues", factory);
+        }
+        else {
+            log.warn("Cannot create default values: no value factory");
+            return null;
+        }
     }
 
     @Override

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/WorkspaceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/WorkspaceImpl.java?rev=1378981&r1=1378980&r2=1378981&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/WorkspaceImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/WorkspaceImpl.java
Thu Aug 30 15:13:30 2012
@@ -158,7 +158,12 @@ public class WorkspaceImpl implements Ja
         return new NodeTypeManagerImpl(
                 sessionDelegate.getContentSession(),
                 sessionDelegate.getNamePathMapper(),
-                sessionDelegate.getValueFactory());
+                sessionDelegate.getValueFactory()) {
+            @Override
+            protected void refresh() throws RepositoryException {
+                getSession().refresh(true);
+            }
+        };
     }
 
     @Override



Mime
View raw message