Index: oak-core/src/main/java/org/apache/jackrabbit/oak/osgi/Activator.java
===================================================================
--- oak-core/src/main/java/org/apache/jackrabbit/oak/osgi/Activator.java	(revision 1464940)
+++ oak-core/src/main/java/org/apache/jackrabbit/oak/osgi/Activator.java	(working copy)
@@ -28,7 +28,6 @@
 import org.apache.jackrabbit.oak.core.ContentRepositoryImpl;
 import org.apache.jackrabbit.oak.kernel.KernelNodeStore;
 import org.apache.jackrabbit.oak.osgi.OsgiRepositoryInitializer.RepositoryInitializerObserver;
-import org.apache.jackrabbit.oak.plugins.nodetype.DefaultTypeEditor;
 import org.apache.jackrabbit.oak.security.SecurityProviderImpl;
 import org.apache.jackrabbit.oak.spi.lifecycle.OakInitializer;
 import org.apache.jackrabbit.oak.spi.lifecycle.RepositoryInitializer;
@@ -104,8 +103,6 @@
             Oak oak = new Oak(store)
                 // FIXME: proper osgi setup for security provider (see OAK-17 and sub-tasks)
                 .with(new SecurityProviderImpl())
-                // TODO: DefaultTypeEditor is JCR specific and does not belong here
-                .with(new DefaultTypeEditor())
                 .with(validatorProvider)
                 .with(indexProvider)
                 .with(indexHookProvider);
Index: oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/TypeEditor.java
===================================================================
--- oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/TypeEditor.java	(revision 1464940)
+++ oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/TypeEditor.java	(working copy)
@@ -24,6 +24,7 @@
 import static org.apache.jackrabbit.JcrConstants.JCR_SUPERTYPES;
 import static org.apache.jackrabbit.JcrConstants.JCR_VALUECONSTRAINTS;
 import static org.apache.jackrabbit.JcrConstants.NT_BASE;
+import static org.apache.jackrabbit.JcrConstants.NT_UNSTRUCTURED;
 import static org.apache.jackrabbit.oak.api.Type.BOOLEAN;
 import static org.apache.jackrabbit.oak.api.Type.NAME;
 import static org.apache.jackrabbit.oak.api.Type.NAMES;
@@ -42,9 +43,11 @@
 
 import org.apache.jackrabbit.oak.api.CommitFailedException;
 import org.apache.jackrabbit.oak.api.PropertyState;
+import org.apache.jackrabbit.oak.api.Type;
 import org.apache.jackrabbit.oak.plugins.value.ValueFactoryImpl;
 import org.apache.jackrabbit.oak.spi.commit.DefaultEditor;
 import org.apache.jackrabbit.oak.spi.commit.Editor;
+import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
 
 import com.google.common.base.Joiner;
@@ -71,17 +74,28 @@
     private final NodeState types;
 
     private EffectiveType effective = null;
+    
+    private final NodeBuilder node;
 
-    TypeEditor(NodeState types) {
+    // TODO: Calculate default type from the node definition
+    private final String defaultType = NT_UNSTRUCTURED;
+
+    TypeEditor(NodeState types, NodeBuilder node) {
         this.parent = null;
         this.nodeName = null;
         this.types = checkNotNull(types);
+        this.node = node;
     }
 
     private TypeEditor(TypeEditor parent, String name) {
         this.parent = checkNotNull(parent);
         this.nodeName = checkNotNull(name);
         this.types = parent.types;
+        if (parent != null && parent.node != null) {
+            this.node = parent.node.child(name);
+        } else {
+            this.node = null;
+        }
     }
 
     private String getPath() {
@@ -100,6 +114,9 @@
     @Override
     public void enter(NodeState before, NodeState after)
             throws CommitFailedException {
+        if (after.getProperty(JCR_PRIMARYTYPE) == null && node != null) {
+            node.setProperty(JCR_PRIMARYTYPE, defaultType, Type.NAME);
+        }
         Iterable<String> names = computeEffectiveType(after);
 
         // find matching entry in the parent node's effective type
Index: oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/DefaultTypeEditor.java
===================================================================
--- oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/DefaultTypeEditor.java	(revision 1464940)
+++ oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/DefaultTypeEditor.java	(working copy)
@@ -1,83 +0,0 @@
-/*
- * 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.oak.plugins.nodetype;
-
-import org.apache.jackrabbit.oak.api.CommitFailedException;
-import org.apache.jackrabbit.oak.api.Type;
-import org.apache.jackrabbit.oak.spi.commit.CommitHook;
-import org.apache.jackrabbit.oak.spi.state.ChildNodeEntry;
-import org.apache.jackrabbit.oak.spi.state.DefaultNodeStateDiff;
-import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
-import org.apache.jackrabbit.oak.spi.state.NodeState;
-import org.apache.jackrabbit.oak.spi.state.NodeStateUtils;
-
-/**
- * This class updates a Lucene index when node content is changed.
- */
-public class DefaultTypeEditor implements CommitHook {
-
-    @Override
-    public NodeState processCommit(NodeState before, NodeState after)
-            throws CommitFailedException {
-        // TODO: Calculate default type from the node definition
-        NodeBuilder builder = after.builder();
-        after.compareAgainstBaseState(
-                before, new DefaultTypeDiff(builder, "nt:unstructured"));
-        return builder.getNodeState();
-    }
-
-    private static class DefaultTypeDiff extends DefaultNodeStateDiff {
-
-        private final NodeBuilder builder;
-
-        private final String defaultType;
-
-        public DefaultTypeDiff(NodeBuilder builder, String defaultType) {
-            this.builder = builder;
-            this.defaultType = defaultType;
-        }
-
-        @Override
-        public void childNodeAdded(String name, NodeState after) {
-            if (!NodeStateUtils.isHidden(name)) {
-                NodeBuilder childBuilder = builder.child(name);
-                if (after.getProperty("jcr:primaryType") == null) {
-                    childBuilder.setProperty("jcr:primaryType", defaultType, Type.NAME);
-                }
-                DefaultTypeDiff childDiff =
-                        new DefaultTypeDiff(childBuilder, defaultType);
-                for (ChildNodeEntry entry : after.getChildNodeEntries()) {
-                    childDiff.childNodeAdded(
-                            entry.getName(), entry.getNodeState());
-                }
-            }
-        }
-
-        @Override
-        public void childNodeChanged(
-                String name, NodeState before, NodeState after) {
-            if (!NodeStateUtils.isHidden(name)) {
-                NodeBuilder childBuilder = builder.child(name);
-                DefaultTypeDiff childDiff =
-                        new DefaultTypeDiff(childBuilder, defaultType);
-                after.compareAgainstBaseState(before, childDiff);
-            }
-        }
-
-    }
-
-}
Index: oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/TypeEditorProvider.java
===================================================================
--- oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/TypeEditorProvider.java	(revision 1464940)
+++ oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/TypeEditorProvider.java	(working copy)
@@ -37,7 +37,7 @@
         NodeState system = after.getChildNode(JCR_SYSTEM);
         NodeState types = system.getChildNode(JCR_NODE_TYPES);
         if (types.exists()) {
-            return new VisibleEditor(new TypeEditor(types));
+            return new VisibleEditor(new TypeEditor(types, builder));
         } else {
             return null;
         }
Index: oak-run/src/main/java/org/apache/jackrabbit/oak/run/Main.java
===================================================================
--- oak-run/src/main/java/org/apache/jackrabbit/oak/run/Main.java	(revision 1464940)
+++ oak-run/src/main/java/org/apache/jackrabbit/oak/run/Main.java	(working copy)
@@ -33,7 +33,6 @@
 import org.apache.jackrabbit.oak.plugins.index.p2.Property2IndexHookProvider;
 import org.apache.jackrabbit.oak.plugins.name.NameValidatorProvider;
 import org.apache.jackrabbit.oak.plugins.name.NamespaceValidatorProvider;
-import org.apache.jackrabbit.oak.plugins.nodetype.DefaultTypeEditor;
 import org.apache.jackrabbit.oak.plugins.nodetype.RegistrationEditorProvider;
 import org.apache.jackrabbit.oak.plugins.nodetype.TypeEditorProvider;
 import org.apache.jackrabbit.oak.plugins.nodetype.write.InitialContent;
@@ -168,7 +167,6 @@
                 .with(new NamespaceValidatorProvider())
                 .with(new TypeEditorProvider())
                 .with(new RegistrationEditorProvider())
-                .with(new DefaultTypeEditor())
                 .with(new Property2IndexHookProvider())
                 .with(securityProvider)
                 .with(new InitialContent())
Index: oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/Jcr.java
===================================================================
--- oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/Jcr.java	(revision 1464940)
+++ oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/Jcr.java	(working copy)
@@ -32,7 +32,6 @@
 import org.apache.jackrabbit.oak.plugins.index.p2.Property2IndexProvider;
 import org.apache.jackrabbit.oak.plugins.name.NameValidatorProvider;
 import org.apache.jackrabbit.oak.plugins.name.NamespaceValidatorProvider;
-import org.apache.jackrabbit.oak.plugins.nodetype.DefaultTypeEditor;
 import org.apache.jackrabbit.oak.plugins.nodetype.RegistrationEditorProvider;
 import org.apache.jackrabbit.oak.plugins.nodetype.TypeEditorProvider;
 import org.apache.jackrabbit.oak.plugins.nodetype.write.InitialContent;
@@ -62,7 +61,6 @@
         with(new InitialContent());
 
         with(JcrConflictHandler.JCR_CONFLICT_HANDLER);
-        with(new DefaultTypeEditor());
         with(new VersionHook());
 
         with(new SecurityProviderImpl());
