Hi,

On Tue, Jun 24, 2014 at 7:08 AM, anjan <[email protected]> wrote:
> -F":contentType=zip" -F":operation=import"
> -F":contentFile=@/home/anjan/Downloads/Samples.zip"
> http://localhost:8888/content/Test

I had a deeper look and the nt:folder node type is indeed hardcoded in
the contentloader's ZipReader class - the patch below demonstrates
changing that to sling:Folder statically.

It might be good to make this configurable, and by configuring an
empty node type you'd get the default child node type defined by the
parent node, which is sling:Folder for a sling:Folder parent.

Patches welcome ;-)

-Bertrand


===================================================================
--- 
bundles/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/readers/ZipReader.java
(revision 1603387)
+++ 
bundles/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/readers/ZipReader.java
(working copy)
@@ -38,8 +38,6 @@
  */
 public class ZipReader implements ContentReader {

-    private static final String NT_FOLDER = "nt:folder";
-
     public static final ImportProvider ZIP_PROVIDER = new ImportProvider() {
         private ZipReader zipReader;

@@ -82,8 +80,9 @@
  */
  public void parse(InputStream ins, ContentCreator creator)
  throws IOException, RepositoryException {
+     final String folderNodeType = "sling:Folder";
         try {
-            creator.createNode(null, NT_FOLDER, null);
+            creator.createNode(null, folderNodeType, null);
             final ZipInputStream zis = new ZipInputStream(ins);
             ZipEntry entry;
             do {
@@ -93,7 +92,7 @@
                         String name = entry.getName();
                         int pos = name.lastIndexOf('/');
                         if ( pos != -1 ) {
-
creator.switchCurrentNode(name.substring(0, pos), NT_FOLDER);
+
creator.switchCurrentNode(name.substring(0, pos), folderNodeType);
                         }
                         creator.createFileAndResourceNode(name, new
CloseShieldInputStream(zis), null, entry.getTime());
                         creator.finishNode();

Reply via email to