sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From o...@apache.org
Subject svn commit: r1664834 - in /sling/trunk/bundles/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal: Loader.java SystemViewImporter.java
Date Sat, 07 Mar 2015 12:00:05 GMT
Author: olli
Date: Sat Mar  7 12:00:04 2015
New Revision: 1664834

URL: http://svn.apache.org/r1664834
Log:
SLING-3535 reduce duplicated code in content loader

* change call in Loader to use InputStream instead of URL and with replace flag set to false
* remove wrong comment regarding already existing content node
* remove obsolete method for Loader

Modified:
    sling/trunk/bundles/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/Loader.java
    sling/trunk/bundles/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/SystemViewImporter.java

Modified: sling/trunk/bundles/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/Loader.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/Loader.java?rev=1664834&r1=1664833&r2=1664834&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/Loader.java
(original)
+++ sling/trunk/bundles/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/Loader.java
Sat Mar  7 12:00:04 2015
@@ -465,7 +465,8 @@ public class Loader extends BaseImportLo
         try {
             // special treatment for system view imports
             if (resourcePath.endsWith(EXT_JCR_XML)) {
-                return importSystemView(parent, name, resourceUrl);
+                final InputStream contentStream = resourceUrl.openStream();
+                return importSystemView(parent, name, contentStream, false);
             }
 
             // get the node reader for this resource

Modified: sling/trunk/bundles/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/SystemViewImporter.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/SystemViewImporter.java?rev=1664834&r1=1664833&r2=1664834&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/SystemViewImporter.java
(original)
+++ sling/trunk/bundles/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/SystemViewImporter.java
Sat Mar  7 12:00:04 2015
@@ -42,60 +42,6 @@ public class SystemViewImporter {
     public SystemViewImporter() {
     }
 
-    // TODO from Loader
-
-    /**
-     * Import the XML file as JCR system or document view import. If the XML
-     * file is not a valid system or document view export/import file,
-     * <code>false</code> is returned.
-     *
-     * @param parent  The parent node below which to import
-     * @param nodeXML The URL to the XML file to import
-     * @return <code>true</code> if the import succeeds, <code>false</code>
-     *         if the import fails due to XML format errors.
-     * @throws java.io.IOException If an IO error occurs reading the XML file.
-     */
-    protected Node importSystemView(Node parent, String name, URL nodeXML) throws IOException
{
-
-        InputStream ins = null;
-        try {
-            // check whether we have the content already, nothing to do then
-            if (name.endsWith(EXT_JCR_XML)) {
-                name = name.substring(0, name.length() - EXT_JCR_XML.length());
-            }
-            if (parent.hasNode(name)) {
-                logger.debug("importSystemView: Node {} for XML {} already exists, nothing
to do", name, nodeXML);
-                return parent.getNode(name);
-            }
-
-            ins = nodeXML.openStream();
-            Session session = parent.getSession();
-            session.importXML(parent.getPath(), ins, IMPORT_UUID_CREATE_NEW);
-
-            // additionally check whether the expected child node exists
-            return (parent.hasNode(name)) ? parent.getNode(name) : null;
-        } catch (InvalidSerializedDataException isde) {
-            // the XML might not be system or document view export, fall back
-            // to old-style XML reading
-            logger.info("importSystemView: XML {} does not seem to be system view export,
trying old style; cause: {}", nodeXML, isde.toString());
-            return null;
-        } catch (RepositoryException re) {
-            // any other repository related issue...
-            logger.info("importSystemView: Repository issue loading XML {}, trying old style;
cause: {}", nodeXML, re.toString());
-            return null;
-        } finally {
-            if (ins != null) {
-                try {
-                    ins.close();
-                } catch (IOException ignore) {
-                    // ignore
-                }
-            }
-        }
-    }
-
-    // TODO from DefaultContentImporter
-
     /**
      * Import the XML file as JCR system or document view import. If the XML
      * file is not a valid system or document view export/import file,
@@ -112,7 +58,6 @@ public class SystemViewImporter {
     protected Node importSystemView(Node parent, String name, InputStream contentStream,
boolean replace) throws IOException {
         InputStream ins = null;
         try {
-            // check whether we have the content already, nothing to do then
             final String nodeName = (name.endsWith(EXT_JCR_XML)) ? name.substring(0, name.length()
- EXT_JCR_XML.length()) : name;
 
             // ensure the name is not empty



Mime
View raw message