camel-zipfile

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

camel-zipfile

zhurlik
Hi,
I am dealing with *.odt/*.ott file as a zip file using camel-zipfile component and faced with an issue.
I am looking at ZipFileDataFormat.java that uses ZipIterator.java but in the line 130 I see that ZipIterator skips empty directories in the zip file (in my case *.odt/*.ott).

Is it possible to have an ability to handle this case via options in either ZipFileDataFormat or ZipIterator to be able to say when I want to go through all entities in the zip file, I mean files and folders.

_____________________
Thanks,
Vlad
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: camel-zipfile

Willem.Jiang
We could add an option in the ZipFileDataFormat to let the iterator support
the empty directory.
Please feel free to log a JIRA[1] for it.

[1]https://issues.apache.org/jira/browse/CAMEL


Willem Jiang

Blog: http://willemjiang.blogspot.com (English)
          http://jnn.iteye.com  (Chinese)
Twitter: willemjiang
Weibo: 姜宁willem

On Mon, Feb 6, 2017 at 5:03 AM, zhurlik <[hidden email]> wrote:

> Hi,
> I am dealing with *.odt/*.ott file as a zip file using *camel-zipfile*
> component and faced with an issue.
> I am looking at  ZipFileDataFormat.java
> <https://github.com/apache/camel/blob/master/components/
> camel-zipfile/src/main/java/org/apache/camel/dataformat/
> zipfile/ZipFileDataFormat.java>
> that uses  ZipIterator.java
> <https://github.com/apache/camel/blob/master/components/
> camel-zipfile/src/main/java/org/apache/camel/dataformat/
> zipfile/ZipIterator.java>
> but in the line 130
> <https://github.com/apache/camel/blob/master/components/
> camel-zipfile/src/main/java/org/apache/camel/dataformat/
> zipfile/ZipIterator.java#L130>
> I see that ZipIterator skips empty directories in the zip file (in my case
> *.odt/*.ott).
>
> Is it possible to have an ability to handle this case via options in either
> ZipFileDataFormat or ZipIterator to be able to say when I want to go
> through
> all entities in the zip file, I mean files and folders.
>
> _____________________
> Thanks,
>  Vlad
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.
> com/camel-zipfile-tp5793495.html
> Sent from the Camel Development mailing list archive at Nabble.com.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: camel-zipfile

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

Re: camel-zipfile

zhurlik
In reply to this post by Willem.Jiang
Hi,
Looks like the same issue with ZipAggregationStrategy there is no way to add empty folder (ZipEnty is a directory entry when name ends with a '/').
At least will be an exception in this code
Thanks.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: camel-zipfile

Willem.Jiang
Hi zhurlik,

It could save us some time to help you if you can upload a simple test case
to show the issue.
I also want to know about why you need to deal with the empty file
directory in the Zip file.   It could help us to polish the options (maybe
we need to support empty directory by default.)


Willem Jiang

Blog: http://willemjiang.blogspot.com (English)
          http://jnn.iteye.com  (Chinese)
Twitter: willemjiang
Weibo: 姜宁willem

On Sun, Feb 12, 2017 at 5:09 AM, zhurlik <[hidden email]> wrote:

> Hi,
> Looks like the same issue with  ZipAggregationStrategy
> <https://github.com/apache/camel/blob/master/components/
> camel-zipfile/src/main/java/org/apache/camel/processor/aggregate/zipfile/
> ZipAggregationStrategy.java>
> there is no way to add empty folder (ZipEnty is a directory entry when name
> ends with a '/').
> At least will be an exception  in this code
> <https://github.com/apache/camel/blob/master/components/
> camel-zipfile/src/main/java/org/apache/camel/processor/aggregate/zipfile/
> ZipAggregationStrategy.java#L187-L193>
> Thanks.
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.
> com/camel-zipfile-tp5793495p5793793.html
> Sent from the Camel Development mailing list archive at Nabble.com.
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: camel-zipfile

zhurlik
Hi,

Sure, let me try to explain the issue.
So I am working on LibreOffice files: *.odt/*.ott, they are zip archives that contain xml files and empty folder (I don't know the reason of having empty folders, but in any case I think that a potential zip file can have a structure with empty folders).
Here is a sample of structure from simple odt file:  
unzip -Zl hello.odt 
Archive:  hello.odt
Zip file size: 8039 bytes, number of entries: 17
-rw----     2.0 fat       39 b-       39 stor 17-Feb-13 07:32 mimetype
-rw----     2.0 fat      405 b-      405 stor 17-Feb-13 07:32 Thumbnails/thumbnail.png
-rw----     2.0 fat     3569 bl      906 defN 17-Feb-13 07:32 content.xml
-rw----     2.0 fat    11385 bl     2043 defN 17-Feb-13 07:32 styles.xml
-rw----     2.0 fat      971 bl      444 defN 17-Feb-13 07:32 meta.xml
-rw----     2.0 fat    10714 bl     1577 defN 17-Feb-13 07:32 settings.xml
-rw----     2.0 fat        0 b-        0 stor 17-Feb-13 07:32 Configurations2/accelerator/
-rw----     2.0 fat        0 b-        0 stor 17-Feb-13 07:32 Configurations2/toolpanel/
-rw----     2.0 fat        0 b-        0 stor 17-Feb-13 07:32 Configurations2/floater/
-rw----     2.0 fat        0 b-        0 stor 17-Feb-13 07:32 Configurations2/menubar/
-rw----     2.0 fat        0 b-        0 stor 17-Feb-13 07:32 Configurations2/images/Bitmaps/
-rw----     2.0 fat        0 b-        0 stor 17-Feb-13 07:32 Configurations2/popupmenu/
-rw----     2.0 fat        0 b-        0 stor 17-Feb-13 07:32 Configurations2/progressbar/
-rw----     2.0 fat        0 b-        0 stor 17-Feb-13 07:32 Configurations2/toolbar/
-rw----     2.0 fat        0 b-        0 stor 17-Feb-13 07:32 Configurations2/statusbar/
-rw----     2.0 fat      899 bl      261 defN 17-Feb-13 07:32 manifest.rdf
-rw----     2.0 fat      978 bl      268 defN 17-Feb-13 07:32 META-INF/manifest.xml
17 files, 28960 bytes uncompressed, 5943 bytes compressed:  79.5%
where you can see that Configurations2/* consists of empty folder.

My idea is to make changes with xml files and save the same structure after updating a *.odt file. I am using camel-xslt and camel-zipfile components. I ran to the problem that camel-zipfile doesn't work with empty folder within zip file.

ZipIterator can not read empty folders and ZipAggregator can not put them back into zip file.
I am attaching a simple odt file hello.odt
If you want I can try to create a pull request with changes in java code and unit tests. I just need to figure out a little bit how to make a clone of camel-zipfile and try to build it locally. Or else I can try to create a patch with diffs.

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

Re: camel-zipfile

zhurlik
In reply to this post by zhurlik
Hi,

Looks like you have fixed https://issues.apache.org/jira/browse/CAMEL-10791
What about second part of issue related with ZipAggregationStrategy.

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

Re: camel-zipfile

onders
i think i missed that. i'll try to look and will do another PR.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: camel-zipfile

onders
In reply to this post by zhurlik
Hi,

As per my observations, unless zipdataformat does not get the filename of such empty directory from the file consumer. that's there is no need any such change in ZipAggregationStrategy.

However, with a bit of hacking on file consumer in camel-core as well and i could have passed empty folder'sfilename to zipdataformat and zip dataformat could process the iterator and created the empty folder on output with file producer endpoint.(for example in my initial PR, i had a change in camel-core GenericFileProducer which Claus did not accept. (it was reasonable.)

To sum, no code change required. please try running AggregationStrategyWithPreservationTest which passes already.

However, i understand what you are trying to do with the zipfile component in case of empty directories. there may be option in component only if file consuming and producing endpoints support handling empty directories. right now, as far as i can see file component does not support it.

So it is another issue. I will give a try to create test case for it and raise an issue. Let's see how we will move forward.

Cheers.
Loading...