[01/10] camel git commit: CAMEL-10701 - proper naming considering review and added option for xml dsl

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[01/10] camel git commit: CAMEL-10701 - proper naming considering review and added option for xml dsl

davsclaus-2
Repository: camel
Updated Branches:
  refs/heads/master 968fd2b17 -> 8cd032925


CAMEL-10701 - proper naming considering review and added option for xml dsl


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/09cf89cc
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/09cf89cc
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/09cf89cc

Branch: refs/heads/master
Commit: 09cf89cc702aa3d7e3b5bed68651939341635df5
Parents: fc72a19
Author: onders86 <[hidden email]>
Authored: Tue Mar 14 18:31:54 2017 +0300
Committer: Claus Ibsen <[hidden email]>
Committed: Tue Mar 14 18:29:38 2017 +0100

----------------------------------------------------------------------
 .../camel/model/dataformat/ZipFileDataFormat.java  | 17 +++++++++++++++++
 .../dataformat/zipfile/ZipFileDataFormat.java      | 12 ++++++------
 .../camel/dataformat/zipfile/ZipIterator.java      | 15 +++++++--------
 .../dataformat/zipfile/ZipFileDataFormatTest.java  |  4 ++--
 4 files changed, 32 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/09cf89cc/camel-core/src/main/java/org/apache/camel/model/dataformat/ZipFileDataFormat.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/dataformat/ZipFileDataFormat.java b/camel-core/src/main/java/org/apache/camel/model/dataformat/ZipFileDataFormat.java
index 49ba9b2..4d54554 100644
--- a/camel-core/src/main/java/org/apache/camel/model/dataformat/ZipFileDataFormat.java
+++ b/camel-core/src/main/java/org/apache/camel/model/dataformat/ZipFileDataFormat.java
@@ -36,6 +36,8 @@ import org.apache.camel.spi.Metadata;
 public class ZipFileDataFormat extends DataFormatDefinition {
     @XmlAttribute
     private Boolean usingIterator;
+    @XmlAttribute
+    private Boolean allowEmptyDirectory;
 
     public ZipFileDataFormat() {
         super("zipfile");
@@ -46,11 +48,18 @@ public class ZipFileDataFormat extends DataFormatDefinition {
         if (usingIterator != null) {
             setProperty(camelContext, dataFormat, "usingIterator", usingIterator);
         }
+        if (allowEmptyDirectory != null) {
+            setProperty(camelContext, dataFormat, "allowEmptyDirectory", allowEmptyDirectory);
+        }
     }
 
     public Boolean getUsingIterator() {
         return usingIterator;
     }
+    
+    public Boolean getAllowEmptyDirectory() {
+        return allowEmptyDirectory;
+    }
 
     /**
      * If the zip file has more then one entry, the setting this option to true, allows to work with the splitter EIP,
@@ -59,5 +68,13 @@ public class ZipFileDataFormat extends DataFormatDefinition {
     public void setUsingIterator(Boolean usingIterator) {
         this.usingIterator = usingIterator;
     }
+    
+    /**
+     * If the zip file has more then one entry, setting this option to true, allows to get the iterator
+     * even if the directory is empty
+     */
+    public void setAllowEmptyDirectory(Boolean allowEmptyDirectory) {
+        this.allowEmptyDirectory = allowEmptyDirectory;
+    }
 
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/09cf89cc/components/camel-zipfile/src/main/java/org/apache/camel/dataformat/zipfile/ZipFileDataFormat.java
----------------------------------------------------------------------
diff --git a/components/camel-zipfile/src/main/java/org/apache/camel/dataformat/zipfile/ZipFileDataFormat.java b/components/camel-zipfile/src/main/java/org/apache/camel/dataformat/zipfile/ZipFileDataFormat.java
index 72b4ce5..4bb5824 100644
--- a/components/camel-zipfile/src/main/java/org/apache/camel/dataformat/zipfile/ZipFileDataFormat.java
+++ b/components/camel-zipfile/src/main/java/org/apache/camel/dataformat/zipfile/ZipFileDataFormat.java
@@ -39,7 +39,7 @@ import static org.apache.camel.Exchange.FILE_NAME;
  */
 public class ZipFileDataFormat extends ServiceSupport implements DataFormat, DataFormatName {
     private boolean usingIterator;
-    private boolean supportIteratorForEmptyDirectory;
+    private boolean allowEmptyDirectory;
 
     @Override
     public String getDataFormatName() {
@@ -75,7 +75,7 @@ public class ZipFileDataFormat extends ServiceSupport implements DataFormat, Dat
     public Object unmarshal(final Exchange exchange, final InputStream inputStream) throws Exception {
         if (usingIterator) {
             ZipIterator zipIterator = new ZipIterator(exchange.getIn());
-            zipIterator.setSupportIteratorForEmptyDirectory(supportIteratorForEmptyDirectory);
+            zipIterator.setAllowEmptyDirectory(allowEmptyDirectory);
             return zipIterator;
         } else {
             ZipInputStream zis = new ZipInputStream(inputStream);
@@ -108,12 +108,12 @@ public class ZipFileDataFormat extends ServiceSupport implements DataFormat, Dat
         this.usingIterator = usingIterator;
     }
     
-    public boolean isSupportIteratorForEmptyDirectory() {
-        return supportIteratorForEmptyDirectory;
+    public boolean isAllowEmptyDirectory() {
+        return allowEmptyDirectory;
     }
 
-    public void setSupportIteratorForEmptyDirectory(boolean supportIteratorForEmptyDirectory) {
-        this.supportIteratorForEmptyDirectory = supportIteratorForEmptyDirectory;
+    public void setAllowEmptyDirectory(boolean allowEmptyDirectory) {
+        this.allowEmptyDirectory = allowEmptyDirectory;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/camel/blob/09cf89cc/components/camel-zipfile/src/main/java/org/apache/camel/dataformat/zipfile/ZipIterator.java
----------------------------------------------------------------------
diff --git a/components/camel-zipfile/src/main/java/org/apache/camel/dataformat/zipfile/ZipIterator.java b/components/camel-zipfile/src/main/java/org/apache/camel/dataformat/zipfile/ZipIterator.java
index 3370d21..0e64d2c 100644
--- a/components/camel-zipfile/src/main/java/org/apache/camel/dataformat/zipfile/ZipIterator.java
+++ b/components/camel-zipfile/src/main/java/org/apache/camel/dataformat/zipfile/ZipIterator.java
@@ -40,13 +40,13 @@ public class ZipIterator implements Iterator<Message>, Closeable {
     static final Logger LOGGER = LoggerFactory.getLogger(ZipIterator.class);
     
     private final Message inputMessage;
-    private boolean supportIteratorForEmptyDirectory;
+    private boolean allowEmptyDirectory;
     private volatile ZipInputStream zipInputStream;
     private volatile Message parent;
     
     public ZipIterator(Message inputMessage) {
         this.inputMessage = inputMessage;
-        this.supportIteratorForEmptyDirectory = false;
+        this.allowEmptyDirectory = false;
         InputStream inputStream = inputMessage.getBody(InputStream.class);
         if (inputStream instanceof ZipInputStream) {
             zipInputStream = (ZipInputStream)inputStream;
@@ -132,9 +132,8 @@ public class ZipIterator implements Iterator<Message>, Closeable {
             if (!entry.isDirectory()) {
                 return entry;
             } else {
-                if (supportIteratorForEmptyDirectory) {
-                    ZipEntry dirEntry = new ZipEntry(entry.getName());
-                    return dirEntry;
+                if (allowEmptyDirectory) {
+                    return entry;
                 }
             }
         }
@@ -154,10 +153,10 @@ public class ZipIterator implements Iterator<Message>, Closeable {
     }
     
     public boolean isSupportIteratorForEmptyDirectory() {
-        return supportIteratorForEmptyDirectory;
+        return allowEmptyDirectory;
     }
 
-    public void setSupportIteratorForEmptyDirectory(boolean supportIteratorForEmptyDirectory) {
-        this.supportIteratorForEmptyDirectory = supportIteratorForEmptyDirectory;
+    public void setAllowEmptyDirectory(boolean allowEmptyDirectory) {
+        this.allowEmptyDirectory = allowEmptyDirectory;
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/09cf89cc/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/ZipFileDataFormatTest.java
----------------------------------------------------------------------
diff --git a/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/ZipFileDataFormatTest.java b/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/ZipFileDataFormatTest.java
index de996fb..305283e 100644
--- a/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/ZipFileDataFormatTest.java
+++ b/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/ZipFileDataFormatTest.java
@@ -117,7 +117,7 @@ public class ZipFileDataFormatTest extends CamelTestSupport {
     public void testUnzipWithEmptyDirectorySupported() throws Exception {
         deleteDirectory(new File("hello_out"));
         zip.setUsingIterator(true);
-        zip.setSupportIteratorForEmptyDirectory(true);
+        zip.setAllowEmptyDirectory(true);
         template.sendBody("direct:unzipWithEmptyDirectory", new File("src/test/resources/hello.odt"));
         assertTrue(Files.exists(Paths.get("hello_out/Configurations2")));
         deleteDirectory(new File("hello_out"));
@@ -127,7 +127,7 @@ public class ZipFileDataFormatTest extends CamelTestSupport {
     public void testUnzipWithEmptyDirectoryUnsupported() throws Exception {
         deleteDirectory(new File("hello_out"));
         zip.setUsingIterator(true);
-        zip.setSupportIteratorForEmptyDirectory(false);
+        zip.setAllowEmptyDirectory(false);
         template.sendBody("direct:unzipWithEmptyDirectory", new File("src/test/resources/hello.odt"));
         assertTrue(!Files.exists(Paths.get("hello_out/Configurations2")));
         deleteDirectory(new File("hello_out"));

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[02/10] camel git commit: CAMEL-10791-review adjustment and some proper naming for the option

davsclaus-2
CAMEL-10791-review adjustment and some proper naming for the option


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/fc72a19a
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/fc72a19a
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/fc72a19a

Branch: refs/heads/master
Commit: fc72a19af4722ae162de1f15bd14fe18276cb70e
Parents: 06e0527
Author: onders86 <[hidden email]>
Authored: Tue Mar 14 13:12:26 2017 +0300
Committer: Claus Ibsen <[hidden email]>
Committed: Tue Mar 14 18:29:38 2017 +0100

----------------------------------------------------------------------
 .../camel/dataformat/zipfile/ZipFileDataFormat.java  | 15 ++++++++-------
 .../apache/camel/dataformat/zipfile/ZipIterator.java | 14 +++++++++++---
 .../dataformat/zipfile/ZipFileDataFormatTest.java    |  4 ++--
 3 files changed, 21 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/fc72a19a/components/camel-zipfile/src/main/java/org/apache/camel/dataformat/zipfile/ZipFileDataFormat.java
----------------------------------------------------------------------
diff --git a/components/camel-zipfile/src/main/java/org/apache/camel/dataformat/zipfile/ZipFileDataFormat.java b/components/camel-zipfile/src/main/java/org/apache/camel/dataformat/zipfile/ZipFileDataFormat.java
index 8ae24b2..72b4ce5 100644
--- a/components/camel-zipfile/src/main/java/org/apache/camel/dataformat/zipfile/ZipFileDataFormat.java
+++ b/components/camel-zipfile/src/main/java/org/apache/camel/dataformat/zipfile/ZipFileDataFormat.java
@@ -39,7 +39,7 @@ import static org.apache.camel.Exchange.FILE_NAME;
  */
 public class ZipFileDataFormat extends ServiceSupport implements DataFormat, DataFormatName {
     private boolean usingIterator;
-    private boolean supportEmptyDirectory;
+    private boolean supportIteratorForEmptyDirectory;
 
     @Override
     public String getDataFormatName() {
@@ -73,9 +73,10 @@ public class ZipFileDataFormat extends ServiceSupport implements DataFormat, Dat
 
     @Override
     public Object unmarshal(final Exchange exchange, final InputStream inputStream) throws Exception {
-        exchange.getIn().setHeader("unzipEmptyDirectorySupported", isSupportEmptyDirectory());
         if (usingIterator) {
-            return new ZipIterator(exchange.getIn());
+            ZipIterator zipIterator = new ZipIterator(exchange.getIn());
+            zipIterator.setSupportIteratorForEmptyDirectory(supportIteratorForEmptyDirectory);
+            return zipIterator;
         } else {
             ZipInputStream zis = new ZipInputStream(inputStream);
             OutputStreamBuilder osb = OutputStreamBuilder.withExchange(exchange);
@@ -107,12 +108,12 @@ public class ZipFileDataFormat extends ServiceSupport implements DataFormat, Dat
         this.usingIterator = usingIterator;
     }
     
-    public boolean isSupportEmptyDirectory() {
-        return supportEmptyDirectory;
+    public boolean isSupportIteratorForEmptyDirectory() {
+        return supportIteratorForEmptyDirectory;
     }
 
-    public void setSupportEmptyDirectory(boolean supportEmptyDirectory) {
-        this.supportEmptyDirectory = supportEmptyDirectory;
+    public void setSupportIteratorForEmptyDirectory(boolean supportIteratorForEmptyDirectory) {
+        this.supportIteratorForEmptyDirectory = supportIteratorForEmptyDirectory;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/camel/blob/fc72a19a/components/camel-zipfile/src/main/java/org/apache/camel/dataformat/zipfile/ZipIterator.java
----------------------------------------------------------------------
diff --git a/components/camel-zipfile/src/main/java/org/apache/camel/dataformat/zipfile/ZipIterator.java b/components/camel-zipfile/src/main/java/org/apache/camel/dataformat/zipfile/ZipIterator.java
index bd67f8a..3370d21 100644
--- a/components/camel-zipfile/src/main/java/org/apache/camel/dataformat/zipfile/ZipIterator.java
+++ b/components/camel-zipfile/src/main/java/org/apache/camel/dataformat/zipfile/ZipIterator.java
@@ -40,13 +40,13 @@ public class ZipIterator implements Iterator<Message>, Closeable {
     static final Logger LOGGER = LoggerFactory.getLogger(ZipIterator.class);
     
     private final Message inputMessage;
-    private final boolean unzipEmptyDirectorySupported;
+    private boolean supportIteratorForEmptyDirectory;
     private volatile ZipInputStream zipInputStream;
     private volatile Message parent;
     
     public ZipIterator(Message inputMessage) {
         this.inputMessage = inputMessage;
-        this.unzipEmptyDirectorySupported = (boolean)inputMessage.getHeader("unzipEmptyDirectorySupported");
+        this.supportIteratorForEmptyDirectory = false;
         InputStream inputStream = inputMessage.getBody(InputStream.class);
         if (inputStream instanceof ZipInputStream) {
             zipInputStream = (ZipInputStream)inputStream;
@@ -132,7 +132,7 @@ public class ZipIterator implements Iterator<Message>, Closeable {
             if (!entry.isDirectory()) {
                 return entry;
             } else {
-                if (unzipEmptyDirectorySupported) {
+                if (supportIteratorForEmptyDirectory) {
                     ZipEntry dirEntry = new ZipEntry(entry.getName());
                     return dirEntry;
                 }
@@ -152,4 +152,12 @@ public class ZipIterator implements Iterator<Message>, Closeable {
         IOHelper.close(zipInputStream);
         zipInputStream = null;
     }
+    
+    public boolean isSupportIteratorForEmptyDirectory() {
+        return supportIteratorForEmptyDirectory;
+    }
+
+    public void setSupportIteratorForEmptyDirectory(boolean supportIteratorForEmptyDirectory) {
+        this.supportIteratorForEmptyDirectory = supportIteratorForEmptyDirectory;
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/fc72a19a/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/ZipFileDataFormatTest.java
----------------------------------------------------------------------
diff --git a/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/ZipFileDataFormatTest.java b/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/ZipFileDataFormatTest.java
index caf71dc..de996fb 100644
--- a/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/ZipFileDataFormatTest.java
+++ b/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/ZipFileDataFormatTest.java
@@ -117,7 +117,7 @@ public class ZipFileDataFormatTest extends CamelTestSupport {
     public void testUnzipWithEmptyDirectorySupported() throws Exception {
         deleteDirectory(new File("hello_out"));
         zip.setUsingIterator(true);
-        zip.setSupportEmptyDirectory(true);
+        zip.setSupportIteratorForEmptyDirectory(true);
         template.sendBody("direct:unzipWithEmptyDirectory", new File("src/test/resources/hello.odt"));
         assertTrue(Files.exists(Paths.get("hello_out/Configurations2")));
         deleteDirectory(new File("hello_out"));
@@ -127,7 +127,7 @@ public class ZipFileDataFormatTest extends CamelTestSupport {
     public void testUnzipWithEmptyDirectoryUnsupported() throws Exception {
         deleteDirectory(new File("hello_out"));
         zip.setUsingIterator(true);
-        zip.setSupportEmptyDirectory(false);
+        zip.setSupportIteratorForEmptyDirectory(false);
         template.sendBody("direct:unzipWithEmptyDirectory", new File("src/test/resources/hello.odt"));
         assertTrue(!Files.exists(Paths.get("hello_out/Configurations2")));
         deleteDirectory(new File("hello_out"));

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[03/10] camel git commit: CAMEL-10791-added option to handle empty directories while unzipping

davsclaus-2
In reply to this post by davsclaus-2
CAMEL-10791-added option to handle empty directories while unzipping


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/0eeeaaf8
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/0eeeaaf8
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/0eeeaaf8

Branch: refs/heads/master
Commit: 0eeeaaf8ec3ca7f5c0ade055af9d0cbd200eb099
Parents: c35b72e
Author: onders86 <[hidden email]>
Authored: Mon Mar 13 11:09:09 2017 +0300
Committer: Claus Ibsen <[hidden email]>
Committed: Tue Mar 14 18:29:38 2017 +0100

----------------------------------------------------------------------
 .../org/apache/camel/dataformat/zipfile/ZipFileDataFormatTest.java | 2 ++
 1 file changed, 2 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/0eeeaaf8/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/ZipFileDataFormatTest.java
----------------------------------------------------------------------
diff --git a/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/ZipFileDataFormatTest.java b/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/ZipFileDataFormatTest.java
index 7563abf..e4cecb3 100644
--- a/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/ZipFileDataFormatTest.java
+++ b/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/ZipFileDataFormatTest.java
@@ -115,6 +115,7 @@ public class ZipFileDataFormatTest extends CamelTestSupport {
         zip.setSupportEmptyDirectory(true);
         template.sendBody("direct:unzipWithEmptyDirectory", new File("src/test/resources/hello.odt"));
         assertTrue(Files.exists(Paths.get("hello_out/Configurations2")));
+        deleteDirectory(new File("hello_out"));
     }
     
     @Test
@@ -124,6 +125,7 @@ public class ZipFileDataFormatTest extends CamelTestSupport {
         zip.setSupportEmptyDirectory(false);
         template.sendBody("direct:unzipWithEmptyDirectory", new File("src/test/resources/hello.odt"));
         assertTrue(!Files.exists(Paths.get("hello_out/Configurations2")));
+        deleteDirectory(new File("hello_out"));
     }
 
     @Test

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[04/10] camel git commit: CAMEL-10791-added option to handle empty directories while unzipping

davsclaus-2
In reply to this post by davsclaus-2
CAMEL-10791-added option to handle empty directories while unzipping


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/741b0472
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/741b0472
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/741b0472

Branch: refs/heads/master
Commit: 741b0472f41c4cc32b40c9d1c540af21ce4efa14
Parents: 968fd2b
Author: onders86 <[hidden email]>
Authored: Mon Mar 13 11:03:35 2017 +0300
Committer: Claus Ibsen <[hidden email]>
Committed: Tue Mar 14 18:29:38 2017 +0100

----------------------------------------------------------------------
 .../org/apache/camel/component/file/GenericFileProducer.java   | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/741b0472/camel-core/src/main/java/org/apache/camel/component/file/GenericFileProducer.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/component/file/GenericFileProducer.java b/camel-core/src/main/java/org/apache/camel/component/file/GenericFileProducer.java
index a4769ec..7e8cd61 100644
--- a/camel-core/src/main/java/org/apache/camel/component/file/GenericFileProducer.java
+++ b/camel-core/src/main/java/org/apache/camel/component/file/GenericFileProducer.java
@@ -274,7 +274,11 @@ public class GenericFileProducer<T> extends DefaultProducer {
             log.trace("About to write [{}] to [{}] from exchange [{}]", new Object[]{fileName, getEndpoint(), exchange});
         }
 
-        boolean success = operations.storeFile(fileName, exchange);
+        // if filename indicates the current directory and the directory is created
+        // but no need to store a file under the directory like touch <dir>
+        // this is added due to considering to handle empty directories in zipfile
+        boolean success = !fileName.substring(fileName.lastIndexOf(File.separator) + 1, fileName.length()).equals(".")
+                                            ? operations.storeFile(fileName, exchange) : true;
         if (!success) {
             throw new GenericFileOperationFailedException("Error writing file [" + fileName + "]");
         }

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[05/10] camel git commit: CAMEL-10791-added option to handle empty directories while unzipping

davsclaus-2
In reply to this post by davsclaus-2
CAMEL-10791-added option to handle empty directories while unzipping


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/033bb9d9
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/033bb9d9
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/033bb9d9

Branch: refs/heads/master
Commit: 033bb9d9a1f0db458c7121d93aabeefe6d4bc476
Parents: 741b047
Author: onders86 <[hidden email]>
Authored: Mon Mar 13 11:04:44 2017 +0300
Committer: Claus Ibsen <[hidden email]>
Committed: Tue Mar 14 18:29:38 2017 +0100

----------------------------------------------------------------------
 .../camel/dataformat/zipfile/ZipFileDataFormat.java   | 14 ++++++++++++++
 .../apache/camel/dataformat/zipfile/ZipIterator.java  |  7 +++++++
 2 files changed, 21 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/033bb9d9/components/camel-zipfile/src/main/java/org/apache/camel/dataformat/zipfile/ZipFileDataFormat.java
----------------------------------------------------------------------
diff --git a/components/camel-zipfile/src/main/java/org/apache/camel/dataformat/zipfile/ZipFileDataFormat.java b/components/camel-zipfile/src/main/java/org/apache/camel/dataformat/zipfile/ZipFileDataFormat.java
index b251201..3704d94 100644
--- a/components/camel-zipfile/src/main/java/org/apache/camel/dataformat/zipfile/ZipFileDataFormat.java
+++ b/components/camel-zipfile/src/main/java/org/apache/camel/dataformat/zipfile/ZipFileDataFormat.java
@@ -39,6 +39,7 @@ import static org.apache.camel.Exchange.FILE_NAME;
  */
 public class ZipFileDataFormat extends ServiceSupport implements DataFormat, DataFormatName {
     private boolean usingIterator;
+    private boolean supportEmptyDirectory;
 
     @Override
     public String getDataFormatName() {
@@ -72,6 +73,11 @@ public class ZipFileDataFormat extends ServiceSupport implements DataFormat, Dat
 
     @Override
     public Object unmarshal(final Exchange exchange, final InputStream inputStream) throws Exception {
+        if (supportEmptyDirectory) {
+            exchange.getIn().setHeader("unzipEmptyDirectorySupported", true);
+        } else {
+            exchange.getIn().setHeader("unzipEmptyDirectorySupported", false);
+        }
         if (usingIterator) {
             return new ZipIterator(exchange.getIn());
         } else {
@@ -104,6 +110,14 @@ public class ZipFileDataFormat extends ServiceSupport implements DataFormat, Dat
     public void setUsingIterator(boolean usingIterator) {
         this.usingIterator = usingIterator;
     }
+    
+    public boolean isSupportEmptyDirectory() {
+        return supportEmptyDirectory;
+    }
+
+    public void setSupportEmptyDirectory(boolean supportEmptyDirectory) {
+        this.supportEmptyDirectory = supportEmptyDirectory;
+    }
 
     @Override
     protected void doStart() throws Exception {

http://git-wip-us.apache.org/repos/asf/camel/blob/033bb9d9/components/camel-zipfile/src/main/java/org/apache/camel/dataformat/zipfile/ZipIterator.java
----------------------------------------------------------------------
diff --git a/components/camel-zipfile/src/main/java/org/apache/camel/dataformat/zipfile/ZipIterator.java b/components/camel-zipfile/src/main/java/org/apache/camel/dataformat/zipfile/ZipIterator.java
index 77312a3..6d58ad8 100644
--- a/components/camel-zipfile/src/main/java/org/apache/camel/dataformat/zipfile/ZipIterator.java
+++ b/components/camel-zipfile/src/main/java/org/apache/camel/dataformat/zipfile/ZipIterator.java
@@ -40,11 +40,13 @@ public class ZipIterator implements Iterator<Message>, Closeable {
     static final Logger LOGGER = LoggerFactory.getLogger(ZipIterator.class);
     
     private final Message inputMessage;
+    private final boolean unzipEmptyDirectorySupported;
     private volatile ZipInputStream zipInputStream;
     private volatile Message parent;
     
     public ZipIterator(Message inputMessage) {
         this.inputMessage = inputMessage;
+        this.unzipEmptyDirectorySupported = (boolean)inputMessage.getHeader("unzipEmptyDirectorySupported");
         InputStream inputStream = inputMessage.getBody(InputStream.class);
         if (inputStream instanceof ZipInputStream) {
             zipInputStream = (ZipInputStream)inputStream;
@@ -129,6 +131,11 @@ public class ZipIterator implements Iterator<Message>, Closeable {
         while ((entry = zipInputStream.getNextEntry()) != null) {
             if (!entry.isDirectory()) {
                 return entry;
+            } else {
+                if (unzipEmptyDirectorySupported) {
+                    ZipEntry dirEntry = new ZipEntry(entry.getName() + ".");
+                    return dirEntry;
+                }
             }
         }
 

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[06/10] camel git commit: CAMEL-10791-added option to handle empty directories while unzipping

davsclaus-2
In reply to this post by davsclaus-2
CAMEL-10791-added option to handle empty directories while unzipping


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/c2b2ee2e
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/c2b2ee2e
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/c2b2ee2e

Branch: refs/heads/master
Commit: c2b2ee2ed5f14e12f3f794c12b6f920c9fea6935
Parents: 0eeeaaf
Author: onders86 <[hidden email]>
Authored: Mon Mar 13 11:10:23 2017 +0300
Committer: Claus Ibsen <[hidden email]>
Committed: Tue Mar 14 18:29:38 2017 +0100

----------------------------------------------------------------------
 .../camel/component/file/GenericFileProducer.java   |   6 +-----
 .../camel-zipfile/src/test/resources/hello.odt      | Bin 0 -> 8039 bytes
 2 files changed, 1 insertion(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/c2b2ee2e/camel-core/src/main/java/org/apache/camel/component/file/GenericFileProducer.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/component/file/GenericFileProducer.java b/camel-core/src/main/java/org/apache/camel/component/file/GenericFileProducer.java
index 7e8cd61..a4769ec 100644
--- a/camel-core/src/main/java/org/apache/camel/component/file/GenericFileProducer.java
+++ b/camel-core/src/main/java/org/apache/camel/component/file/GenericFileProducer.java
@@ -274,11 +274,7 @@ public class GenericFileProducer<T> extends DefaultProducer {
             log.trace("About to write [{}] to [{}] from exchange [{}]", new Object[]{fileName, getEndpoint(), exchange});
         }
 
-        // if filename indicates the current directory and the directory is created
-        // but no need to store a file under the directory like touch <dir>
-        // this is added due to considering to handle empty directories in zipfile
-        boolean success = !fileName.substring(fileName.lastIndexOf(File.separator) + 1, fileName.length()).equals(".")
-                                            ? operations.storeFile(fileName, exchange) : true;
+        boolean success = operations.storeFile(fileName, exchange);
         if (!success) {
             throw new GenericFileOperationFailedException("Error writing file [" + fileName + "]");
         }

http://git-wip-us.apache.org/repos/asf/camel/blob/c2b2ee2e/components/camel-zipfile/src/test/resources/hello.odt
----------------------------------------------------------------------
diff --git a/components/camel-zipfile/src/test/resources/hello.odt b/components/camel-zipfile/src/test/resources/hello.odt
new file mode 100644
index 0000000..223391a
Binary files /dev/null and b/components/camel-zipfile/src/test/resources/hello.odt differ

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[07/10] camel git commit: CAMEL-10791-review adjustment

davsclaus-2
In reply to this post by davsclaus-2
CAMEL-10791-review adjustment


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/06e0527c
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/06e0527c
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/06e0527c

Branch: refs/heads/master
Commit: 06e0527c2a024bacd617af0b3fbe111018dbda08
Parents: 928cdb1
Author: onders86 <[hidden email]>
Authored: Tue Mar 14 07:55:26 2017 +0300
Committer: Claus Ibsen <[hidden email]>
Committed: Tue Mar 14 18:29:38 2017 +0100

----------------------------------------------------------------------
 .../zipfile/ZipFileDataFormatTest.java          | 24 ++++++++------------
 1 file changed, 9 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/06e0527c/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/ZipFileDataFormatTest.java
----------------------------------------------------------------------
diff --git a/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/ZipFileDataFormatTest.java b/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/ZipFileDataFormatTest.java
index 6afac67..caf71dc 100644
--- a/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/ZipFileDataFormatTest.java
+++ b/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/ZipFileDataFormatTest.java
@@ -120,7 +120,7 @@ public class ZipFileDataFormatTest extends CamelTestSupport {
         zip.setSupportEmptyDirectory(true);
         template.sendBody("direct:unzipWithEmptyDirectory", new File("src/test/resources/hello.odt"));
         assertTrue(Files.exists(Paths.get("hello_out/Configurations2")));
-        //deleteDirectory(new File("hello_out"));
+        deleteDirectory(new File("hello_out"));
     }
     
     @Test
@@ -130,7 +130,7 @@ public class ZipFileDataFormatTest extends CamelTestSupport {
         zip.setSupportEmptyDirectory(false);
         template.sendBody("direct:unzipWithEmptyDirectory", new File("src/test/resources/hello.odt"));
         assertTrue(!Files.exists(Paths.get("hello_out/Configurations2")));
-        //deleteDirectory(new File("hello_out"));
+        deleteDirectory(new File("hello_out"));
     }
 
     @Test
@@ -229,21 +229,15 @@ public class ZipFileDataFormatTest extends CamelTestSupport {
         }
     }
 
-    private static void copy(File file, OutputStream out) throws IOException {
-        InputStream in = new FileInputStream(file);
-        try {
-            copy(in, out);
-        } finally {
-            in.close();
-        }
+    private static void copy(File file, OutputStream out) throws IOException {
+        try (InputStream in = new FileInputStream(file)) {
+            copy(in, out);
+        }
     }
 
-    private static void copy(InputStream in, File file) throws IOException {
-        OutputStream out = new FileOutputStream(file);
-        try {
-            copy(in, out);
-        } finally {
-            out.close();
+    private static void copy(InputStream in, File file) throws IOException {
+        try (OutputStream out = new FileOutputStream(file)) {
+            copy(in, out);
         }
     }
 

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[08/10] camel git commit: CAMEL-10791-added option to handle empty directories while unzipping

davsclaus-2
In reply to this post by davsclaus-2
CAMEL-10791-added option to handle empty directories while unzipping


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/c35b72e0
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/c35b72e0
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/c35b72e0

Branch: refs/heads/master
Commit: c35b72e05fec2e83e3cae104488b25b4c12eadeb
Parents: 033bb9d
Author: onders86 <[hidden email]>
Authored: Mon Mar 13 11:07:55 2017 +0300
Committer: Claus Ibsen <[hidden email]>
Committed: Tue Mar 14 18:29:38 2017 +0100

----------------------------------------------------------------------
 .../zipfile/ZipFileDataFormatTest.java          | 30 +++++++++++++++++++-
 1 file changed, 29 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/c35b72e0/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/ZipFileDataFormatTest.java
----------------------------------------------------------------------
diff --git a/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/ZipFileDataFormatTest.java b/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/ZipFileDataFormatTest.java
index 7273179..7563abf 100644
--- a/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/ZipFileDataFormatTest.java
+++ b/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/ZipFileDataFormatTest.java
@@ -21,6 +21,9 @@ import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.Iterator;
 import java.util.concurrent.TimeUnit;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipOutputStream;
@@ -53,6 +56,8 @@ public class ZipFileDataFormatTest extends CamelTestSupport {
         + "With horsemen riding royally.";
 
     private static final File TEST_DIR = new File("target/zip");
+    
+    private ZipFileDataFormat zip;
 
     @Test
     public void testZipAndStreamCaching() throws Exception {
@@ -102,6 +107,24 @@ public class ZipFileDataFormatTest extends CamelTestSupport {
 
         assertMockEndpointsSatisfied();
     }
+    
+    @Test
+    public void testUnzipWithEmptyDirectorySupported() throws Exception {
+        deleteDirectory(new File("hello_out"));
+        zip.setUsingIterator(true);
+        zip.setSupportEmptyDirectory(true);
+        template.sendBody("direct:unzipWithEmptyDirectory", new File("src/test/resources/hello.odt"));
+        assertTrue(Files.exists(Paths.get("hello_out/Configurations2")));
+    }
+    
+    @Test
+    public void testUnzipWithEmptyDirectoryUnsupported() throws Exception {
+        deleteDirectory(new File("hello_out"));
+        zip.setUsingIterator(true);
+        zip.setSupportEmptyDirectory(false);
+        template.sendBody("direct:unzipWithEmptyDirectory", new File("src/test/resources/hello.odt"));
+        assertTrue(!Files.exists(Paths.get("hello_out/Configurations2")));
+    }
 
     @Test
     public void testZipAndUnzip() throws Exception {
@@ -195,10 +218,15 @@ public class ZipFileDataFormatTest extends CamelTestSupport {
             public void configure() throws Exception {
                 interceptSendToEndpoint("file:*").to("mock:intercepted");
 
-                ZipFileDataFormat zip = new ZipFileDataFormat();
+                zip = new ZipFileDataFormat();
 
                 from("direct:zip").marshal(zip).to("mock:zip");
                 from("direct:unzip").unmarshal(zip).to("mock:unzip");
+                from("direct:unzipWithEmptyDirectory").unmarshal(zip)
+                                        .split(body(Iterator.class))
+                                        .streaming()
+                                        .to("file:hello_out?autoCreate=true")
+                                        .end();
                 from("direct:zipAndUnzip").marshal(zip).unmarshal(zip).to("mock:zipAndUnzip");
                 from("direct:zipToFile").marshal(zip).to("file:" + TEST_DIR.getPath()).to("mock:zipToFile");
                 from("direct:dslZip").marshal().zipFile().to("mock:dslZip");

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[09/10] camel git commit: CAMEL-10791-only component update

davsclaus-2
In reply to this post by davsclaus-2
CAMEL-10791-only component update


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/928cdb1e
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/928cdb1e
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/928cdb1e

Branch: refs/heads/master
Commit: 928cdb1edf7754a990b23d058fced8fd35ed9de6
Parents: c2b2ee2
Author: onders86 <[hidden email]>
Authored: Mon Mar 13 21:24:47 2017 +0300
Committer: Claus Ibsen <[hidden email]>
Committed: Tue Mar 14 18:29:38 2017 +0100

----------------------------------------------------------------------
 .../dataformat/zipfile/ZipFileDataFormat.java   |  6 +-
 .../camel/dataformat/zipfile/ZipIterator.java   |  2 +-
 .../zipfile/ZipFileDataFormatTest.java          | 59 +++++++++++++++++++-
 3 files changed, 58 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/928cdb1e/components/camel-zipfile/src/main/java/org/apache/camel/dataformat/zipfile/ZipFileDataFormat.java
----------------------------------------------------------------------
diff --git a/components/camel-zipfile/src/main/java/org/apache/camel/dataformat/zipfile/ZipFileDataFormat.java b/components/camel-zipfile/src/main/java/org/apache/camel/dataformat/zipfile/ZipFileDataFormat.java
index 3704d94..8ae24b2 100644
--- a/components/camel-zipfile/src/main/java/org/apache/camel/dataformat/zipfile/ZipFileDataFormat.java
+++ b/components/camel-zipfile/src/main/java/org/apache/camel/dataformat/zipfile/ZipFileDataFormat.java
@@ -73,11 +73,7 @@ public class ZipFileDataFormat extends ServiceSupport implements DataFormat, Dat
 
     @Override
     public Object unmarshal(final Exchange exchange, final InputStream inputStream) throws Exception {
-        if (supportEmptyDirectory) {
-            exchange.getIn().setHeader("unzipEmptyDirectorySupported", true);
-        } else {
-            exchange.getIn().setHeader("unzipEmptyDirectorySupported", false);
-        }
+        exchange.getIn().setHeader("unzipEmptyDirectorySupported", isSupportEmptyDirectory());
         if (usingIterator) {
             return new ZipIterator(exchange.getIn());
         } else {

http://git-wip-us.apache.org/repos/asf/camel/blob/928cdb1e/components/camel-zipfile/src/main/java/org/apache/camel/dataformat/zipfile/ZipIterator.java
----------------------------------------------------------------------
diff --git a/components/camel-zipfile/src/main/java/org/apache/camel/dataformat/zipfile/ZipIterator.java b/components/camel-zipfile/src/main/java/org/apache/camel/dataformat/zipfile/ZipIterator.java
index 6d58ad8..bd67f8a 100644
--- a/components/camel-zipfile/src/main/java/org/apache/camel/dataformat/zipfile/ZipIterator.java
+++ b/components/camel-zipfile/src/main/java/org/apache/camel/dataformat/zipfile/ZipIterator.java
@@ -133,7 +133,7 @@ public class ZipIterator implements Iterator<Message>, Closeable {
                 return entry;
             } else {
                 if (unzipEmptyDirectorySupported) {
-                    ZipEntry dirEntry = new ZipEntry(entry.getName() + ".");
+                    ZipEntry dirEntry = new ZipEntry(entry.getName());
                     return dirEntry;
                 }
             }

http://git-wip-us.apache.org/repos/asf/camel/blob/928cdb1e/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/ZipFileDataFormatTest.java
----------------------------------------------------------------------
diff --git a/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/ZipFileDataFormatTest.java b/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/ZipFileDataFormatTest.java
index e4cecb3..6afac67 100644
--- a/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/ZipFileDataFormatTest.java
+++ b/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/ZipFileDataFormatTest.java
@@ -20,15 +20,20 @@ import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.FileInputStream;
+import java.io.FileOutputStream;
 import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
 import java.nio.file.Files;
 import java.nio.file.Paths;
 import java.util.Iterator;
 import java.util.concurrent.TimeUnit;
 import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
 import java.util.zip.ZipOutputStream;
 
 import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
 import org.apache.camel.builder.NotifyBuilder;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
@@ -115,7 +120,7 @@ public class ZipFileDataFormatTest extends CamelTestSupport {
         zip.setSupportEmptyDirectory(true);
         template.sendBody("direct:unzipWithEmptyDirectory", new File("src/test/resources/hello.odt"));
         assertTrue(Files.exists(Paths.get("hello_out/Configurations2")));
-        deleteDirectory(new File("hello_out"));
+        //deleteDirectory(new File("hello_out"));
     }
     
     @Test
@@ -125,7 +130,7 @@ public class ZipFileDataFormatTest extends CamelTestSupport {
         zip.setSupportEmptyDirectory(false);
         template.sendBody("direct:unzipWithEmptyDirectory", new File("src/test/resources/hello.odt"));
         assertTrue(!Files.exists(Paths.get("hello_out/Configurations2")));
-        deleteDirectory(new File("hello_out"));
+        //deleteDirectory(new File("hello_out"));
     }
 
     @Test
@@ -212,6 +217,35 @@ public class ZipFileDataFormatTest extends CamelTestSupport {
         deleteDirectory(TEST_DIR);
         super.setUp();
     }
+    
+    private static void copy(InputStream in, OutputStream out) throws IOException {
+        byte[] buffer = new byte[1024];
+        while (true) {
+            int readCount = in.read(buffer);
+            if (readCount < 0) {
+                break;
+            }
+            out.write(buffer, 0, readCount);
+        }
+    }
+
+    private static void copy(File file, OutputStream out) throws IOException {
+        InputStream in = new FileInputStream(file);
+        try {
+            copy(in, out);
+        } finally {
+            in.close();
+        }
+    }
+
+    private static void copy(InputStream in, File file) throws IOException {
+        OutputStream out = new FileOutputStream(file);
+        try {
+            copy(in, out);
+        } finally {
+            out.close();
+        }
+    }
 
     @Override
     protected RouteBuilder createRouteBuilder() throws Exception {
@@ -227,7 +261,26 @@ public class ZipFileDataFormatTest extends CamelTestSupport {
                 from("direct:unzipWithEmptyDirectory").unmarshal(zip)
                                         .split(body(Iterator.class))
                                         .streaming()
-                                        .to("file:hello_out?autoCreate=true")
+                                        //.to("file:hello_out?autoCreate=true")
+                                        .process(new Processor() {
+                                            @Override
+                                            public void process(Exchange exchange) throws Exception {
+                                                ZipFile zfile = new ZipFile(new File("src/test/resources/hello.odt"));
+                                                ZipEntry entry = new ZipEntry((String)exchange.getIn().getHeader(Exchange.FILE_NAME));
+                                                File file = new File("hello_out", entry.getName());
+                                                if (entry.isDirectory()) {
+                                                    file.mkdirs();
+                                                } else {
+                                                    file.getParentFile().mkdirs();
+                                                    InputStream in = zfile.getInputStream(entry);
+                                                    try {
+                                                        copy(in, file);
+                                                    } finally {
+                                                        in.close();
+                                                    }
+                                                }
+                                            }
+                                        })
                                         .end();
                 from("direct:zipAndUnzip").marshal(zip).unmarshal(zip).to("mock:zipAndUnzip");
                 from("direct:zipToFile").marshal(zip).to("file:" + TEST_DIR.getPath()).to("mock:zipToFile");

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[10/10] camel git commit: CAMEL-10791: Regen docs

davsclaus-2
In reply to this post by davsclaus-2
CAMEL-10791: Regen docs


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/8cd03292
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/8cd03292
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/8cd03292

Branch: refs/heads/master
Commit: 8cd03292555eb019ecd2131af9792c0be4b16cb8
Parents: 09cf89c
Author: Claus Ibsen <[hidden email]>
Authored: Tue Mar 14 18:34:28 2017 +0100
Committer: Claus Ibsen <[hidden email]>
Committed: Tue Mar 14 18:34:28 2017 +0100

----------------------------------------------------------------------
 .../src/main/docs/zipfile-dataformat.adoc              |  3 ++-
 .../springboot/ZipFileDataFormatConfiguration.java     | 13 +++++++++++++
 2 files changed, 15 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/8cd03292/components/camel-zipfile/src/main/docs/zipfile-dataformat.adoc
----------------------------------------------------------------------
diff --git a/components/camel-zipfile/src/main/docs/zipfile-dataformat.adoc b/components/camel-zipfile/src/main/docs/zipfile-dataformat.adoc
index 9e1f22b..96806e6 100644
--- a/components/camel-zipfile/src/main/docs/zipfile-dataformat.adoc
+++ b/components/camel-zipfile/src/main/docs/zipfile-dataformat.adoc
@@ -17,7 +17,7 @@ aggregate multiple messages into a single Zip file.
 
 
 // dataformat options: START
-The Zip File dataformat supports 2 options which are listed below.
+The Zip File dataformat supports 3 options which are listed below.
 
 
 
@@ -25,6 +25,7 @@ The Zip File dataformat supports 2 options which are listed below.
 |=======================================================================
 | Name | Default | Java Type | Description
 | usingIterator | false | Boolean | If the zip file has more then one entry the setting this option to true allows to work with the splitter EIP to split the data using an iterator in a streaming mode.
+| allowEmptyDirectory | false | Boolean | If the zip file has more then one entry setting this option to true allows to get the iterator even if the directory is empty
 | contentTypeHeader | false | Boolean | Whether the data format should set the Content-Type header with the type from the data format if the data format is capable of doing so. For example application/xml for data formats marshalling to XML or application/json for data formats marshalling to JSon etc.
 |=======================================================================
 // dataformat options: END

http://git-wip-us.apache.org/repos/asf/camel/blob/8cd03292/platforms/spring-boot/components-starter/camel-zipfile-starter/src/main/java/org/apache/camel/dataformat/zipfile/springboot/ZipFileDataFormatConfiguration.java
----------------------------------------------------------------------
diff --git a/platforms/spring-boot/components-starter/camel-zipfile-starter/src/main/java/org/apache/camel/dataformat/zipfile/springboot/ZipFileDataFormatConfiguration.java b/platforms/spring-boot/components-starter/camel-zipfile-starter/src/main/java/org/apache/camel/dataformat/zipfile/springboot/ZipFileDataFormatConfiguration.java
index f21f0ad..fa42d9e 100644
--- a/platforms/spring-boot/components-starter/camel-zipfile-starter/src/main/java/org/apache/camel/dataformat/zipfile/springboot/ZipFileDataFormatConfiguration.java
+++ b/platforms/spring-boot/components-starter/camel-zipfile-starter/src/main/java/org/apache/camel/dataformat/zipfile/springboot/ZipFileDataFormatConfiguration.java
@@ -33,6 +33,11 @@ public class ZipFileDataFormatConfiguration {
      */
     private Boolean usingIterator = false;
     /**
+     * If the zip file has more then one entry setting this option to true
+     * allows to get the iterator even if the directory is empty
+     */
+    private Boolean allowEmptyDirectory = false;
+    /**
      * Whether the data format should set the Content-Type header with the type
      * from the data format if the data format is capable of doing so. For
      * example application/xml for data formats marshalling to XML or
@@ -48,6 +53,14 @@ public class ZipFileDataFormatConfiguration {
         this.usingIterator = usingIterator;
     }
 
+    public Boolean getAllowEmptyDirectory() {
+        return allowEmptyDirectory;
+    }
+
+    public void setAllowEmptyDirectory(Boolean allowEmptyDirectory) {
+        this.allowEmptyDirectory = allowEmptyDirectory;
+    }
+
     public Boolean getContentTypeHeader() {
         return contentTypeHeader;
     }

Loading...