This is an automated email from the ASF dual-hosted git repository. rombert pushed a commit to annotated tag org.apache.sling.jcr.contentloader-2.1.0 in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-contentloader.git
commit 90b2827883cff37e059c26a1d05f00a251f37e8c Author: Justin Edelson <[email protected]> AuthorDate: Sat Jun 19 01:32:15 2010 +0000 SLING-1561 - changing destination of ROOT descriptor if path is specified in manifest entry git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/jcr/contentloader@956170 13f79535-47bb-0310-9956-ffa450edef68 --- .../internal/DefaultContentCreator.java | 32 +++++++++++----------- .../sling/jcr/contentloader/internal/Loader.java | 17 ++++++------ 2 files changed, 24 insertions(+), 25 deletions(-) diff --git a/src/main/java/org/apache/sling/jcr/contentloader/internal/DefaultContentCreator.java b/src/main/java/org/apache/sling/jcr/contentloader/internal/DefaultContentCreator.java index 0b96104..b1bc0e3 100644 --- a/src/main/java/org/apache/sling/jcr/contentloader/internal/DefaultContentCreator.java +++ b/src/main/java/org/apache/sling/jcr/contentloader/internal/DefaultContentCreator.java @@ -73,11 +73,11 @@ public class DefaultContentCreator implements ContentCreator { private final Map<String, List<String>> delayedReferences = new HashMap<String, List<String>>(); private final Map<String, String[]> delayedMultipleReferences = new HashMap<String, String[]>(); - private String defaultRootName; + private String defaultName; - private Node rootNode; + private Node createdRootNode; - private boolean isRootNodeImport; + private boolean isParentNodeImport; private boolean ignoreOverwriteFlag = false; @@ -135,17 +135,17 @@ public class DefaultContentCreator implements ContentCreator { /** * - * If the defaultRootName is null, we are in ROOT_NODE import mode. + * If the defaultName is null, we are in PARENT_NODE import mode. * @param parentNode - * @param defaultRootName + * @param defaultName */ public void prepareParsing(final Node parentNode, - final String defaultRootName) { + final String defaultName) { this.parentNodeStack.clear(); this.parentNodeStack.push(parentNode); - this.defaultRootName = defaultRootName; - this.rootNode = null; - isRootNodeImport = defaultRootName == null; + this.defaultName = defaultName; + isParentNodeImport = defaultName == null; + this.createdRootNode = null; } /** @@ -173,8 +173,8 @@ public class DefaultContentCreator implements ContentCreator { /** * Get the created root node. */ - public Node getRootNode() { - return this.rootNode; + public Node getCreatedRootNode() { + return this.createdRootNode; } /** @@ -231,11 +231,11 @@ public class DefaultContentCreator implements ContentCreator { if ( this.parentNodeStack.size() > 1 ) { throw new RepositoryException("Node needs to have a name."); } - name = this.defaultRootName; + name = this.defaultName; } - // if we are in root node import mode, we don't create the root top level node! - if ( !isRootNodeImport || this.parentNodeStack.size() > 1 ) { + // if we are in parent node import mode, we don't create the root top level node! + if ( !isParentNodeImport || this.parentNodeStack.size() > 1 ) { // if node already exists but should be overwritten, delete it if (!this.ignoreOverwriteFlag && this.configuration.isOverwrite() && parentNode.hasNode(name)) { parentNode.getNode(name).remove(); @@ -281,8 +281,8 @@ public class DefaultContentCreator implements ContentCreator { } this.parentNodeStack.push(node); - if ( this.rootNode == null ) { - this.rootNode = node; + if ( this.createdRootNode == null ) { + this.createdRootNode = node; } } } diff --git a/src/main/java/org/apache/sling/jcr/contentloader/internal/Loader.java b/src/main/java/org/apache/sling/jcr/contentloader/internal/Loader.java index 2675d58..b52fb82 100644 --- a/src/main/java/org/apache/sling/jcr/contentloader/internal/Loader.java +++ b/src/main/java/org/apache/sling/jcr/contentloader/internal/Loader.java @@ -392,11 +392,10 @@ public class Loader { return; } - // potential root node import/extension - URL rootNodeDescriptor = importRootNode(parent.getSession(), bundle, path); - if (rootNodeDescriptor != null) { - processedEntries.put(rootNodeDescriptor, - parent.getSession().getRootNode()); + // potential parent node import/extension + URL parentNodeDescriptor = importParentNode(parent.getSession(), bundle, path, parent); + if (parentNodeDescriptor != null) { + processedEntries.put(parentNodeDescriptor, parent); } while (entries.hasMoreElements()) { @@ -549,7 +548,7 @@ public class Loader { this.contentCreator.prepareParsing(parent, toPlainName(name)); nodeReader.parse(resourceUrl, this.contentCreator); - return this.contentCreator.getRootNode(); + return this.contentCreator.getCreatedRootNode(); } catch (RepositoryException re) { throw re; } catch (Throwable t) { @@ -807,9 +806,9 @@ public class Loader { /** * Imports mixin nodes and properties (and optionally child nodes) of the - * root node. + * parent node. */ - private URL importRootNode(Session session, Bundle bundle, String path) + private URL importParentNode(Session session, Bundle bundle, String path, Node parent) throws RepositoryException { final Descriptor descriptor = getRootNodeDescriptor(bundle, path); // no root descriptor found @@ -818,7 +817,7 @@ public class Loader { } try { - this.contentCreator.prepareParsing(session.getRootNode(), null); + this.contentCreator.prepareParsing(parent, null); descriptor.nodeReader.parse(descriptor.rootNodeDescriptor, this.contentCreator); return descriptor.rootNodeDescriptor; -- To stop receiving notification emails like this one, please contact "[email protected]" <[email protected]>.
