[jira] [Commented] (OFBIZ-10188) Add new FileUtil methods for zip management

2018-02-08 Thread Jacques Le Roux (JIRA)

[ 
https://issues.apache.org/jira/browse/OFBIZ-10188?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16357098#comment-16357098
 ] 

Jacques Le Roux commented on OFBIZ-10188:
-

BTW I created OFBIZ-6712 for that. But I must say I never tried Adrian's 
proposition.

> Add new FileUtil methods for zip management
> ---
>
> Key: OFBIZ-10188
> URL: https://issues.apache.org/jira/browse/OFBIZ-10188
> Project: OFBiz
>  Issue Type: New Feature
>Reporter: Gil Portenseigne
>Assignee: Gil Portenseigne
>Priority: Minor
> Fix For: Upcoming Branch
>
> Attachments: OFBIZ-10188.patch, OFBIZ_10188.patch
>
>
> Add new FileUtil methods for zip management.
> Add zipFileStream method that will zip FileStream to a zipped one.
> Add unzipFileToFolder method to unzip a given archive to a given Folder



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (OFBIZ-10188) Add new FileUtil methods for zip management

2018-02-08 Thread Jacques Le Roux (JIRA)

[ 
https://issues.apache.org/jira/browse/OFBIZ-10188?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16357083#comment-16357083
 ] 

Jacques Le Roux commented on OFBIZ-10188:
-

Michael,

In EntityUtilProperties a lot of methods are only covers over UtilProperties 
methods, like the one in my comment above. And one day if we implement them we 
will need to pass a delegator, so it's incomplete.

> Add new FileUtil methods for zip management
> ---
>
> Key: OFBIZ-10188
> URL: https://issues.apache.org/jira/browse/OFBIZ-10188
> Project: OFBiz
>  Issue Type: New Feature
>Reporter: Gil Portenseigne
>Assignee: Gil Portenseigne
>Priority: Minor
> Fix For: Upcoming Branch
>
> Attachments: OFBIZ-10188.patch, OFBIZ_10188.patch
>
>
> Add new FileUtil methods for zip management.
> Add zipFileStream method that will zip FileStream to a zipped one.
> Add unzipFileToFolder method to unzip a given archive to a given Folder



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (OFBIZ-10188) Add new FileUtil methods for zip management

2018-02-08 Thread Gil Portenseigne (JIRA)

[ 
https://issues.apache.org/jira/browse/OFBIZ-10188?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16357073#comment-16357073
 ] 

Gil Portenseigne commented on OFBIZ-10188:
--

Ooops, sorry Michael to have closed the Jira, i miss your comment :)

I think that Jacques explains that {{EntityUtilProperties}} needs delegator as 
a mandatory additional parameters, that will lead to have it on the calling 
method...

> Add new FileUtil methods for zip management
> ---
>
> Key: OFBIZ-10188
> URL: https://issues.apache.org/jira/browse/OFBIZ-10188
> Project: OFBiz
>  Issue Type: New Feature
>Reporter: Gil Portenseigne
>Assignee: Gil Portenseigne
>Priority: Minor
> Fix For: Upcoming Branch
>
> Attachments: OFBIZ-10188.patch, OFBIZ_10188.patch
>
>
> Add new FileUtil methods for zip management.
> Add zipFileStream method that will zip FileStream to a zipped one.
> Add unzipFileToFolder method to unzip a given archive to a given Folder



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (OFBIZ-10188) Add new FileUtil methods for zip management

2018-02-08 Thread Michael Brohl (JIRA)

[ 
https://issues.apache.org/jira/browse/OFBIZ-10188?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16357051#comment-16357051
 ] 

Michael Brohl commented on OFBIZ-10188:
---

What do you mean with "we should complete EntityUtilProperties"?

> Add new FileUtil methods for zip management
> ---
>
> Key: OFBIZ-10188
> URL: https://issues.apache.org/jira/browse/OFBIZ-10188
> Project: OFBiz
>  Issue Type: New Feature
>Reporter: Gil Portenseigne
>Assignee: Gil Portenseigne
>Priority: Minor
> Fix For: Upcoming Branch
>
> Attachments: OFBIZ-10188.patch, OFBIZ_10188.patch
>
>
> Add new FileUtil methods for zip management.
> Add zipFileStream method that will zip FileStream to a zipped one.
> Add unzipFileToFolder method to unzip a given archive to a given Folder



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (OFBIZ-10188) Add new FileUtil methods for zip management

2018-02-08 Thread Jacques Le Roux (JIRA)

[ 
https://issues.apache.org/jira/browse/OFBIZ-10188?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16357045#comment-16357045
 ] 

Jacques Le Roux commented on OFBIZ-10188:
-

I have not a strong opinion about it.

I regularly ask people to use EntityUtilProperties instead of simply 
UtilProperties, because EntityUtilProperties ultimately relies on 
UtilProperties. But on the other hand it's sometimes a pain because it's 
incomplete. So you write things like

{{boolean ... = EntityUtilProperties.getPropertyAsBoolean("...", "...", 
false);}}
instead of
{{boolean ... = yUtilProperties.getPropertyAsBoolean("...", "...", false);}}
And one day maybe a delegator will miss there. In other words we should 
complete EntityUtilProperties before asking everyone to use it :D
In case or simple properties it's OK though.

> Add new FileUtil methods for zip management
> ---
>
> Key: OFBIZ-10188
> URL: https://issues.apache.org/jira/browse/OFBIZ-10188
> Project: OFBiz
>  Issue Type: New Feature
>Reporter: Gil Portenseigne
>Assignee: Gil Portenseigne
>Priority: Minor
> Fix For: Upcoming Branch
>
> Attachments: OFBIZ-10188.patch, OFBIZ_10188.patch
>
>
> Add new FileUtil methods for zip management.
> Add zipFileStream method that will zip FileStream to a zipped one.
> Add unzipFileToFolder method to unzip a given archive to a given Folder



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (OFBIZ-10188) Add new FileUtil methods for zip management

2018-02-02 Thread Jacques Le Roux (JIRA)

[ 
https://issues.apache.org/jira/browse/OFBIZ-10188?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16350421#comment-16350421
 ] 

Jacques Le Roux commented on OFBIZ-10188:
-

Thanks Gil,

I guess you agree about using EntityUtilProperties?

> Add new FileUtil methods for zip management
> ---
>
> Key: OFBIZ-10188
> URL: https://issues.apache.org/jira/browse/OFBIZ-10188
> Project: OFBiz
>  Issue Type: New Feature
>Reporter: Gil Portenseigne
>Assignee: Gil Portenseigne
>Priority: Minor
> Fix For: Upcoming Branch
>
> Attachments: OFBIZ-10188.patch, OFBIZ_10188.patch
>
>
> Add new FileUtil methods for zip management.
> Add zipFileStream method that will zip FileStream to a zipped one.
> Add unzipFileToFolder method to unzip a given archive to a given Folder



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (OFBIZ-10188) Add new FileUtil methods for zip management

2018-02-02 Thread Gil Portenseigne (JIRA)

[ 
https://issues.apache.org/jira/browse/OFBIZ-10188?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16350029#comment-16350029
 ] 

Gil Portenseigne commented on OFBIZ-10188:
--

zos.setLevel(9) can be rewritten to 
zos.setLevel(Deflater.{color:#9876aa}BEST_COMPRESSION{color}){color:#cc7832};
{color:#33}That will be clearer :), and the choice was made to optimize the 
size of data. No strong opinion here either.{color}{color}

{color:#cc7832}{color:#33}Ok for the new byte[8192], thanks for the link, i 
did some search about this and agree with you increasing the size of the buffer 
!{color}{color}

 

 

{color:#cc7832} {color}

> Add new FileUtil methods for zip management
> ---
>
> Key: OFBIZ-10188
> URL: https://issues.apache.org/jira/browse/OFBIZ-10188
> Project: OFBiz
>  Issue Type: New Feature
>Reporter: Gil Portenseigne
>Assignee: Gil Portenseigne
>Priority: Minor
> Fix For: Upcoming Branch
>
> Attachments: OFBIZ-10188.patch, OFBIZ_10188.patch
>
>
> Add new FileUtil methods for zip management.
> Add zipFileStream method that will zip FileStream to a zipped one.
> Add unzipFileToFolder method to unzip a given archive to a given Folder



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (OFBIZ-10188) Add new FileUtil methods for zip management

2018-02-01 Thread Jacques Le Roux (JIRA)

[ 
https://issues.apache.org/jira/browse/OFBIZ-10188?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16349310#comment-16349310
 ] 

Jacques Le Roux commented on OFBIZ-10188:
-

Thanks Gil,

This seems almost ready to be commited :)

Maybe UtilProperties could be replaced by EntityUtilProperties ?

Why did you pick 
zos.setLevel(9) 
instead of default (DEFAULT_COMPRESSION == -1) Note that I have nothing 
against, just a question. Most of the time default are better, that's why I ask.

You use 
byte bufferData[] = new byte[2048];
and
byte[] buffer = new byte[1024];
Maybe we could follow the same way than at 
https://bugs.openjdk.java.net/browse/JDK-4953311 and use a normalised buffer of 
8k?

> Add new FileUtil methods for zip management
> ---
>
> Key: OFBIZ-10188
> URL: https://issues.apache.org/jira/browse/OFBIZ-10188
> Project: OFBiz
>  Issue Type: New Feature
>Reporter: Gil Portenseigne
>Assignee: Gil Portenseigne
>Priority: Minor
> Fix For: Upcoming Branch
>
> Attachments: OFBIZ-10188.patch, OFBIZ_10188.patch
>
>
> Add new FileUtil methods for zip management.
> Add zipFileStream method that will zip FileStream to a zipped one.
> Add unzipFileToFolder method to unzip a given archive to a given Folder



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (OFBIZ-10188) Add new FileUtil methods for zip management

2018-01-30 Thread Gil Portenseigne (JIRA)

[ 
https://issues.apache.org/jira/browse/OFBIZ-10188?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16346384#comment-16346384
 ] 

Gil Portenseigne commented on OFBIZ-10188:
--

Thanks Jacques for the review,

For formatting issues, i will use IDE formatting tool and republish the patch :)

About the exception, indeed there are handled by the testing system, so no need 
to catch these within the test, i guess. (Thanks for the links)

For the closing streams I double checked, no issue detected.

 

 

 

> Add new FileUtil methods for zip management
> ---
>
> Key: OFBIZ-10188
> URL: https://issues.apache.org/jira/browse/OFBIZ-10188
> Project: OFBiz
>  Issue Type: New Feature
>Reporter: Gil Portenseigne
>Assignee: Gil Portenseigne
>Priority: Minor
> Fix For: Upcoming Branch
>
> Attachments: OFBIZ-10188.patch
>
>
> Add new FileUtil methods for zip management.
> Add zipFileStream method that will zip FileStream to a zipped one.
> Add unzipFileToFolder method to unzip a given archive to a given Folder



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (OFBIZ-10188) Add new FileUtil methods for zip management

2018-01-30 Thread Jacques Le Roux (JIRA)

[ 
https://issues.apache.org/jira/browse/OFBIZ-10188?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16345317#comment-16345317
 ] 

Jacques Le Roux commented on OFBIZ-10188:
-

Hi Gil,

I just had a quick look, it looks good to me.

Few remarks :

*FileUtilTests.groovy*
Formatting
in Groovy
{code}
while((len=zipStream.read(buf))>0){
{code}
OK in Java there:
{code}
while ((len = fileStream.read(bufferData)) > 0) {
 {code}
Please check other places in Java (saw one at least)

I guess it's OK to not handle exceptions and we suppose it will be handled 
by the caller?
https://mrhaki.blogspot.fr/2009/09/groovy-goodness-exception-handling.html

Else I guess this can use try-with-resource
{code}
+//write it down into tmp folder
+OutputStream out = new FileOutputStream(readmeZipped)
+byte[] buf = new byte[1024]
+int len
+while((len=zipStream.read(buf))>0){
+out.write(buf,0,len)
+}
+out.close()
+zipStream.close()
{code}

But be sure to check 
https://stackoverflow.com/questions/28636416/why-do-i-have-to-close-the-zipoutputstream-in-a-certain-way-in-this-situation

*FileUtil.java*

Notsure if this can use try-with-resource, at least the order must be 
important
{code}
+zos.closeEntry();
+zos.close();
+fos.close();
{code}

And alike in unzipFileToFolder()

HTH

> Add new FileUtil methods for zip management
> ---
>
> Key: OFBIZ-10188
> URL: https://issues.apache.org/jira/browse/OFBIZ-10188
> Project: OFBiz
>  Issue Type: New Feature
>Reporter: Gil Portenseigne
>Assignee: Gil Portenseigne
>Priority: Minor
> Fix For: Upcoming Branch
>
> Attachments: OFBIZ-10188.patch
>
>
> Add new FileUtil methods for zip management.
> Add zipFileStream method that will zip FileStream to a zipped one.
> Add unzipFileToFolder method to unzip a given archive to a given Folder



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (OFBIZ-10188) Add new FileUtil methods for zip management

2018-01-30 Thread Gil Portenseigne (JIRA)

[ 
https://issues.apache.org/jira/browse/OFBIZ-10188?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16345033#comment-16345033
 ] 

Gil Portenseigne commented on OFBIZ-10188:
--

I did write down a groovy test that zip README.md to runtime/tmp directory, 
then unzip it and compare resulting file with original one.

Any feedback is welcome, i will commit it in a few days, if not objection

> Add new FileUtil methods for zip management
> ---
>
> Key: OFBIZ-10188
> URL: https://issues.apache.org/jira/browse/OFBIZ-10188
> Project: OFBiz
>  Issue Type: New Feature
>Reporter: Gil Portenseigne
>Assignee: Gil Portenseigne
>Priority: Minor
> Fix For: Upcoming Branch
>
> Attachments: OFBIZ-10188.patch
>
>
> Add new FileUtil methods for zip management.
> Add zipFileStream method that will zip FileStream to a zipped one.
> Add unzipFileToFolder method to unzip a given archive to a given Folder



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)