Permalink
Browse files

fix the importer to not stumble over exported jcr:root node

  • Loading branch information...
1 parent 33d0fd8 commit 46c57ac7fa0365622271d1f348faba9c0690085e @dbu dbu committed Apr 7, 2013
Showing with 10 additions and 2 deletions.
  1. +10 −2 src/Jackalope/ImportExport/ImportExport.php
@@ -225,7 +225,15 @@ private static function addNode(NodeInterface $parentNode, $nodename, $type, $pr
}
}
- if ('jcr:root' == $nodename && isset($existing) && $existing->getDepth() == 0 && self::IMPORT_UUID_COLLISION_REPLACE_EXISTING == $uuidBehavior) {
+ /* we add a jcr:root somewhere in the tree (either create new ids or
+ * the root was not referenceable. do not make jackrabbit think it
+ * would be the real root node.
+ */
+ if ('jcr:root' === $nodename && 'rep:root' === $type) {
+ $type = 'nt:unstructured';
+ }
+
+ if ('jcr:root' == $nodename && isset($existing) && $existing->getDepth() === 0 && self::IMPORT_UUID_COLLISION_REPLACE_EXISTING == $uuidBehavior) {
// update the root node properties
// http://www.day.com/specs/jcr/2.0/11_Import.html#11.9%20Importing%20%3CI%3Ejcr:root%3C/I%3E
NodeHelper::purgeWorkspace($parentNode->getSession());
@@ -286,7 +294,7 @@ private static function exportSystemViewRecursive(NodeInterface $node, Namespace
if ($root) {
self::exportNamespaceDeclarations($ns, $stream);
}
- fwrite($stream, ' sv:name="'.($node->getPath() == '/' ? 'jcr:root' : htmlspecialchars($node->getName())).'">');
+ fwrite($stream, ' sv:name="'.(0 === $node->getDepth() ? 'jcr:root' : htmlspecialchars($node->getName())).'">');
// the order MUST be primary type, then mixins, if any, then jcr:uuid if its a referenceable node
fwrite($stream, '<sv:property sv:name="jcr:primaryType" sv:type="Name"><sv:value>'.htmlspecialchars($node->getPropertyValue('jcr:primaryType')).'</sv:value></sv:property>');

0 comments on commit 46c57ac

Please sign in to comment.