[GitHub] struts issue #114: Virtual file representation

2016-11-24 Thread cnenning
Github user cnenning commented on the issue:

https://github.com/apache/struts/pull/114
  
Looks good to me 👍 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: dev-unsubscr...@struts.apache.org
For additional commands, e-mail: dev-h...@struts.apache.org



Re: [jira] [Updated] (WW-4717) Refactor file upload support to allow create virtual representation of java.io.File

2016-11-24 Thread Greg Huber
found it here :

https://github.com/lukaszlenart/struts/tree/WW-4717

Followed the instructions for the filter and listener updates to web.xml
and I get:


2016-11-24 10:01:03,825 WARN
org.apache.struts2.conversion.UploadedFileConverter
UploadedFileConverter:convertValue - Converting java.io.File into
org.apache.struts2.dispatcher.multipart.UploadedFile, consider switching to
org.apache.struts2.dispatcher.multipart.UploadedFile and do not access
java.io.File directly!
2016-11-24 10:01:03,949 ERROR mypackage.Resources Resources:upload - ERROR:
uploading resource
java.lang.NullPointerException: null




On 23 November 2016 at 12:56, Lukasz Lenart  wrote:

> Could someone tag that PR with :+1:?
>
> 2016-11-22 20:41 GMT+01:00 Lukasz Lenart :
> > All is good :) I have refactored the file upload logic a bit, cleaned
> > up and fixed some issues with wrong message keys. Also I added
> > dedicated converter to keep support for java.io.File so there is no
> > need for migration :)
> >
> > I've also developed a small GAE plugin which is using the mentioned
> > changes (that's why build cannot pass as a Struts SNAPSHOT is wrong
> > ;-)), tested it locally and everything works as expected :D
> > https://github.com/lukaszlenart/struts2-gea-plugin
> >
> > Can you take a look on that PR?
> >
> >
> > Thanks in advance
> > --
> > Łukasz
> > + 48 606 323 122 http://www.lenart.org.pl/
> >
> > 2016-11-22 9:44 GMT+01:00 Lukasz Lenart :
> >> Done, thanks Aaron :) Now I must test this solution with Google
> AppEngine ;-)
> >>
> >> 2016-11-22 7:49 GMT+01:00 Lukasz Lenart :
> >>> 2016-11-21 20:12 GMT+01:00 Aaron Johnson :
>  Is it possible to have a converter from UploadedFile to File? The
>  UploadedFile has a getContent() method that returns the File object.
> >>>
> >>> Hm... it would be possible to add a converter, that should work :)
> >>>
> >>>
> >>> Regards
> >>> --
> >>> Łukasz
> >>> + 48 606 323 122 http://www.lenart.org.pl/
>
> -
> To unsubscribe, e-mail: dev-unsubscr...@struts.apache.org
> For additional commands, e-mail: dev-h...@struts.apache.org
>
>


Re: [jira] [Updated] (WW-4717) Refactor file upload support to allow create virtual representation of java.io.File

2016-11-24 Thread Greg Huber
Seems to be this line in UploadedFileConverter:

if (value.getClass().isArray() && Array.getLength(value) == 1) {

where value ==
org.apache.struts2.dispatcher.multipart.StrutsUploadedFile@62e25d8

and is not an array.

this works:

Object obj = null;
if (value.getClass().isArray() && Array.getLength(value) == 1) {
obj = Array.get(value, 0);
} else {
obj = value;
}
if (obj instanceof UploadedFile) {
UploadedFile file = (UploadedFile) obj;
if (file.getContent() instanceof File) {
return file.getContent();
}
return new File(file.getAbsolutePath());
}

This works for both my ajax and normal upload.

On 23 November 2016 at 12:56, Lukasz Lenart  wrote:

> Could someone tag that PR with :+1:?
>
> 2016-11-22 20:41 GMT+01:00 Lukasz Lenart :
> > All is good :) I have refactored the file upload logic a bit, cleaned
> > up and fixed some issues with wrong message keys. Also I added
> > dedicated converter to keep support for java.io.File so there is no
> > need for migration :)
> >
> > I've also developed a small GAE plugin which is using the mentioned
> > changes (that's why build cannot pass as a Struts SNAPSHOT is wrong
> > ;-)), tested it locally and everything works as expected :D
> > https://github.com/lukaszlenart/struts2-gea-plugin
> >
> > Can you take a look on that PR?
> >
> >
> > Thanks in advance
> > --
> > Łukasz
> > + 48 606 323 122 http://www.lenart.org.pl/
> >
> > 2016-11-22 9:44 GMT+01:00 Lukasz Lenart :
> >> Done, thanks Aaron :) Now I must test this solution with Google
> AppEngine ;-)
> >>
> >> 2016-11-22 7:49 GMT+01:00 Lukasz Lenart :
> >>> 2016-11-21 20:12 GMT+01:00 Aaron Johnson :
>  Is it possible to have a converter from UploadedFile to File? The
>  UploadedFile has a getContent() method that returns the File object.
> >>>
> >>> Hm... it would be possible to add a converter, that should work :)
> >>>
> >>>
> >>> Regards
> >>> --
> >>> Łukasz
> >>> + 48 606 323 122 http://www.lenart.org.pl/
>
> -
> To unsubscribe, e-mail: dev-unsubscr...@struts.apache.org
> For additional commands, e-mail: dev-h...@struts.apache.org
>
>


Re: [jira] [Updated] (WW-4717) Refactor file upload support to allow create virtual representation of java.io.File

2016-11-24 Thread Lukasz Lenart
How is that possible? I meant, parameters should always be passed as
arrays, that's how HttpServletRequest works. Do you use custom
implementation of MultiPartRequest? Could you share your upload logic,
action and JSP/JavaScript?

That's why JakartaMultiPartRequest (and other implementations as well)
always creates an array, even if only one file is uploaded:
https://github.com/lukaszlenart/struts/blob/WW-4717/core/src/main/java/org/apache/struts2/dispatcher/multipart/JakartaMultiPartRequest.java#L110-L118


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

2016-11-24 12:13 GMT+01:00 Greg Huber :
> Seems to be this line in UploadedFileConverter:
>
> if (value.getClass().isArray() && Array.getLength(value) == 1) {
>
> where value ==
> org.apache.struts2.dispatcher.multipart.StrutsUploadedFile@62e25d8
>
> and is not an array.
>
> this works:
>
> Object obj = null;
> if (value.getClass().isArray() && Array.getLength(value) == 1) {
> obj = Array.get(value, 0);
> } else {
> obj = value;
> }
> if (obj instanceof UploadedFile) {
> UploadedFile file = (UploadedFile) obj;
> if (file.getContent() instanceof File) {
> return file.getContent();
> }
> return new File(file.getAbsolutePath());
> }
>
> This works for both my ajax and normal upload.
>
> On 23 November 2016 at 12:56, Lukasz Lenart  wrote:
>
>> Could someone tag that PR with :+1:?
>>
>> 2016-11-22 20:41 GMT+01:00 Lukasz Lenart :
>> > All is good :) I have refactored the file upload logic a bit, cleaned
>> > up and fixed some issues with wrong message keys. Also I added
>> > dedicated converter to keep support for java.io.File so there is no
>> > need for migration :)
>> >
>> > I've also developed a small GAE plugin which is using the mentioned
>> > changes (that's why build cannot pass as a Struts SNAPSHOT is wrong
>> > ;-)), tested it locally and everything works as expected :D
>> > https://github.com/lukaszlenart/struts2-gea-plugin
>> >
>> > Can you take a look on that PR?
>> >
>> >
>> > Thanks in advance
>> > --
>> > Łukasz
>> > + 48 606 323 122 http://www.lenart.org.pl/
>> >
>> > 2016-11-22 9:44 GMT+01:00 Lukasz Lenart :
>> >> Done, thanks Aaron :) Now I must test this solution with Google
>> AppEngine ;-)
>> >>
>> >> 2016-11-22 7:49 GMT+01:00 Lukasz Lenart :
>> >>> 2016-11-21 20:12 GMT+01:00 Aaron Johnson :
>>  Is it possible to have a converter from UploadedFile to File? The
>>  UploadedFile has a getContent() method that returns the File object.
>> >>>
>> >>> Hm... it would be possible to add a converter, that should work :)
>> >>>
>> >>>
>> >>> Regards
>> >>> --
>> >>> Łukasz
>> >>> + 48 606 323 122 http://www.lenart.org.pl/
>>
>> -
>> To unsubscribe, e-mail: dev-unsubscr...@struts.apache.org
>> For additional commands, e-mail: dev-h...@struts.apache.org
>>
>>

-
To unsubscribe, e-mail: dev-unsubscr...@struts.apache.org
For additional commands, e-mail: dev-h...@struts.apache.org



Re: [jira] [Updated] (WW-4717) Refactor file upload support to allow create virtual representation of java.io.File

2016-11-24 Thread Lukasz Lenart
Hm... this can be an internal conversion of collection containing
uploaded files. Does your ajax upload allow upload multiple files at
once?

2016-11-24 14:18 GMT+01:00 Lukasz Lenart :
> How is that possible? I meant, parameters should always be passed as
> arrays, that's how HttpServletRequest works. Do you use custom
> implementation of MultiPartRequest? Could you share your upload logic,
> action and JSP/JavaScript?
>
> That's why JakartaMultiPartRequest (and other implementations as well)
> always creates an array, even if only one file is uploaded:
> https://github.com/lukaszlenart/struts/blob/WW-4717/core/src/main/java/org/apache/struts2/dispatcher/multipart/JakartaMultiPartRequest.java#L110-L118
>
>
> Regards
> --
> Łukasz
> + 48 606 323 122 http://www.lenart.org.pl/
>
> 2016-11-24 12:13 GMT+01:00 Greg Huber :
>> Seems to be this line in UploadedFileConverter:
>>
>> if (value.getClass().isArray() && Array.getLength(value) == 1) {
>>
>> where value ==
>> org.apache.struts2.dispatcher.multipart.StrutsUploadedFile@62e25d8
>>
>> and is not an array.
>>
>> this works:
>>
>> Object obj = null;
>> if (value.getClass().isArray() && Array.getLength(value) == 1) {
>> obj = Array.get(value, 0);
>> } else {
>> obj = value;
>> }
>> if (obj instanceof UploadedFile) {
>> UploadedFile file = (UploadedFile) obj;
>> if (file.getContent() instanceof File) {
>> return file.getContent();
>> }
>> return new File(file.getAbsolutePath());
>> }
>>
>> This works for both my ajax and normal upload.
>>
>> On 23 November 2016 at 12:56, Lukasz Lenart  wrote:
>>
>>> Could someone tag that PR with :+1:?
>>>
>>> 2016-11-22 20:41 GMT+01:00 Lukasz Lenart :
>>> > All is good :) I have refactored the file upload logic a bit, cleaned
>>> > up and fixed some issues with wrong message keys. Also I added
>>> > dedicated converter to keep support for java.io.File so there is no
>>> > need for migration :)
>>> >
>>> > I've also developed a small GAE plugin which is using the mentioned
>>> > changes (that's why build cannot pass as a Struts SNAPSHOT is wrong
>>> > ;-)), tested it locally and everything works as expected :D
>>> > https://github.com/lukaszlenart/struts2-gea-plugin
>>> >
>>> > Can you take a look on that PR?
>>> >
>>> >
>>> > Thanks in advance
>>> > --
>>> > Łukasz
>>> > + 48 606 323 122 http://www.lenart.org.pl/
>>> >
>>> > 2016-11-22 9:44 GMT+01:00 Lukasz Lenart :
>>> >> Done, thanks Aaron :) Now I must test this solution with Google
>>> AppEngine ;-)
>>> >>
>>> >> 2016-11-22 7:49 GMT+01:00 Lukasz Lenart :
>>> >>> 2016-11-21 20:12 GMT+01:00 Aaron Johnson :
>>>  Is it possible to have a converter from UploadedFile to File? The
>>>  UploadedFile has a getContent() method that returns the File object.
>>> >>>
>>> >>> Hm... it would be possible to add a converter, that should work :)
>>> >>>
>>> >>>
>>> >>> Regards
>>> >>> --
>>> >>> Łukasz
>>> >>> + 48 606 323 122 http://www.lenart.org.pl/
>>>
>>> -
>>> To unsubscribe, e-mail: dev-unsubscr...@struts.apache.org
>>> For additional commands, e-mail: dev-h...@struts.apache.org
>>>
>>>

-
To unsubscribe, e-mail: dev-unsubscr...@struts.apache.org
For additional commands, e-mail: dev-h...@struts.apache.org



Re: [jira] [Updated] (WW-4717) Refactor file upload support to allow create virtual representation of java.io.File

2016-11-24 Thread Lukasz Lenart
Greg
Pushed changes based on your suggestions and added a unit test to
cover the logic, thanks :)


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

2016-11-24 14:26 GMT+01:00 Lukasz Lenart :
> Hm... this can be an internal conversion of collection containing
> uploaded files. Does your ajax upload allow upload multiple files at
> once?
>
> 2016-11-24 14:18 GMT+01:00 Lukasz Lenart :
>> How is that possible? I meant, parameters should always be passed as
>> arrays, that's how HttpServletRequest works. Do you use custom
>> implementation of MultiPartRequest? Could you share your upload logic,
>> action and JSP/JavaScript?
>>
>> That's why JakartaMultiPartRequest (and other implementations as well)
>> always creates an array, even if only one file is uploaded:
>> https://github.com/lukaszlenart/struts/blob/WW-4717/core/src/main/java/org/apache/struts2/dispatcher/multipart/JakartaMultiPartRequest.java#L110-L118
>>
>>
>> Regards
>> --
>> Łukasz
>> + 48 606 323 122 http://www.lenart.org.pl/
>>
>> 2016-11-24 12:13 GMT+01:00 Greg Huber :
>>> Seems to be this line in UploadedFileConverter:
>>>
>>> if (value.getClass().isArray() && Array.getLength(value) == 1) {
>>>
>>> where value ==
>>> org.apache.struts2.dispatcher.multipart.StrutsUploadedFile@62e25d8
>>>
>>> and is not an array.
>>>
>>> this works:
>>>
>>> Object obj = null;
>>> if (value.getClass().isArray() && Array.getLength(value) == 1) {
>>> obj = Array.get(value, 0);
>>> } else {
>>> obj = value;
>>> }
>>> if (obj instanceof UploadedFile) {
>>> UploadedFile file = (UploadedFile) obj;
>>> if (file.getContent() instanceof File) {
>>> return file.getContent();
>>> }
>>> return new File(file.getAbsolutePath());
>>> }
>>>
>>> This works for both my ajax and normal upload.
>>>
>>> On 23 November 2016 at 12:56, Lukasz Lenart  wrote:
>>>
 Could someone tag that PR with :+1:?

 2016-11-22 20:41 GMT+01:00 Lukasz Lenart :
 > All is good :) I have refactored the file upload logic a bit, cleaned
 > up and fixed some issues with wrong message keys. Also I added
 > dedicated converter to keep support for java.io.File so there is no
 > need for migration :)
 >
 > I've also developed a small GAE plugin which is using the mentioned
 > changes (that's why build cannot pass as a Struts SNAPSHOT is wrong
 > ;-)), tested it locally and everything works as expected :D
 > https://github.com/lukaszlenart/struts2-gea-plugin
 >
 > Can you take a look on that PR?
 >
 >
 > Thanks in advance
 > --
 > Łukasz
 > + 48 606 323 122 http://www.lenart.org.pl/
 >
 > 2016-11-22 9:44 GMT+01:00 Lukasz Lenart :
 >> Done, thanks Aaron :) Now I must test this solution with Google
 AppEngine ;-)
 >>
 >> 2016-11-22 7:49 GMT+01:00 Lukasz Lenart :
 >>> 2016-11-21 20:12 GMT+01:00 Aaron Johnson :
  Is it possible to have a converter from UploadedFile to File? The
  UploadedFile has a getContent() method that returns the File object.
 >>>
 >>> Hm... it would be possible to add a converter, that should work :)
 >>>
 >>>
 >>> Regards
 >>> --
 >>> Łukasz
 >>> + 48 606 323 122 http://www.lenart.org.pl/

 -
 To unsubscribe, e-mail: dev-unsubscr...@struts.apache.org
 For additional commands, e-mail: dev-h...@struts.apache.org



-
To unsubscribe, e-mail: dev-unsubscr...@struts.apache.org
For additional commands, e-mail: dev-h...@struts.apache.org



Re: [jira] [Updated] (WW-4717) Refactor file upload support to allow create virtual representation of java.io.File

2016-11-24 Thread Greg Huber
Sorry, forgot to add this is not on the app engine!  Was only testing the
plugin functionality ie the filter and the listener.  I assume the array
comes from when running the webapp on the app engine?



On 24 November 2016 at 13:26, Lukasz Lenart  wrote:

> Hm... this can be an internal conversion of collection containing
> uploaded files. Does your ajax upload allow upload multiple files at
> once?
>
> 2016-11-24 14:18 GMT+01:00 Lukasz Lenart :
> > How is that possible? I meant, parameters should always be passed as
> > arrays, that's how HttpServletRequest works. Do you use custom
> > implementation of MultiPartRequest? Could you share your upload logic,
> > action and JSP/JavaScript?
> >
> > That's why JakartaMultiPartRequest (and other implementations as well)
> > always creates an array, even if only one file is uploaded:
> > https://github.com/lukaszlenart/struts/blob/WW-
> 4717/core/src/main/java/org/apache/struts2/dispatcher/multipart/
> JakartaMultiPartRequest.java#L110-L118
> >
> >
> > Regards
> > --
> > Łukasz
> > + 48 606 323 122 http://www.lenart.org.pl/
> >
> > 2016-11-24 12:13 GMT+01:00 Greg Huber :
> >> Seems to be this line in UploadedFileConverter:
> >>
> >> if (value.getClass().isArray() && Array.getLength(value) == 1) {
> >>
> >> where value ==
> >> org.apache.struts2.dispatcher.multipart.StrutsUploadedFile@62e25d8
> >>
> >> and is not an array.
> >>
> >> this works:
> >>
> >> Object obj = null;
> >> if (value.getClass().isArray() && Array.getLength(value) ==
> 1) {
> >> obj = Array.get(value, 0);
> >> } else {
> >> obj = value;
> >> }
> >> if (obj instanceof UploadedFile) {
> >> UploadedFile file = (UploadedFile) obj;
> >> if (file.getContent() instanceof File) {
> >> return file.getContent();
> >> }
> >> return new File(file.getAbsolutePath());
> >> }
> >>
> >> This works for both my ajax and normal upload.
> >>
> >> On 23 November 2016 at 12:56, Lukasz Lenart 
> wrote:
> >>
> >>> Could someone tag that PR with :+1:?
> >>>
> >>> 2016-11-22 20:41 GMT+01:00 Lukasz Lenart :
> >>> > All is good :) I have refactored the file upload logic a bit, cleaned
> >>> > up and fixed some issues with wrong message keys. Also I added
> >>> > dedicated converter to keep support for java.io.File so there is no
> >>> > need for migration :)
> >>> >
> >>> > I've also developed a small GAE plugin which is using the mentioned
> >>> > changes (that's why build cannot pass as a Struts SNAPSHOT is wrong
> >>> > ;-)), tested it locally and everything works as expected :D
> >>> > https://github.com/lukaszlenart/struts2-gea-plugin
> >>> >
> >>> > Can you take a look on that PR?
> >>> >
> >>> >
> >>> > Thanks in advance
> >>> > --
> >>> > Łukasz
> >>> > + 48 606 323 122 http://www.lenart.org.pl/
> >>> >
> >>> > 2016-11-22 9:44 GMT+01:00 Lukasz Lenart :
> >>> >> Done, thanks Aaron :) Now I must test this solution with Google
> >>> AppEngine ;-)
> >>> >>
> >>> >> 2016-11-22 7:49 GMT+01:00 Lukasz Lenart :
> >>> >>> 2016-11-21 20:12 GMT+01:00 Aaron Johnson  >:
> >>>  Is it possible to have a converter from UploadedFile to File? The
> >>>  UploadedFile has a getContent() method that returns the File
> object.
> >>> >>>
> >>> >>> Hm... it would be possible to add a converter, that should work :)
> >>> >>>
> >>> >>>
> >>> >>> Regards
> >>> >>> --
> >>> >>> Łukasz
> >>> >>> + 48 606 323 122 http://www.lenart.org.pl/
> >>>
> >>> -
> >>> To unsubscribe, e-mail: dev-unsubscr...@struts.apache.org
> >>> For additional commands, e-mail: dev-h...@struts.apache.org
> >>>
> >>>
>
> -
> To unsubscribe, e-mail: dev-unsubscr...@struts.apache.org
> For additional commands, e-mail: dev-h...@struts.apache.org
>
>


Re: [jira] [Updated] (WW-4717) Refactor file upload support to allow create virtual representation of java.io.File

2016-11-24 Thread Lukasz Lenart
That shouldn't matter but I think how can I test this behaviour.

2016-11-24 15:03 GMT+01:00 Greg Huber :
> Sorry, forgot to add this is not on the app engine!  Was only testing the
> plugin functionality ie the filter and the listener.  I assume the array
> comes from when running the webapp on the app engine?
>
>
>
> On 24 November 2016 at 13:26, Lukasz Lenart  wrote:
>
>> Hm... this can be an internal conversion of collection containing
>> uploaded files. Does your ajax upload allow upload multiple files at
>> once?
>>
>> 2016-11-24 14:18 GMT+01:00 Lukasz Lenart :
>> > How is that possible? I meant, parameters should always be passed as
>> > arrays, that's how HttpServletRequest works. Do you use custom
>> > implementation of MultiPartRequest? Could you share your upload logic,
>> > action and JSP/JavaScript?
>> >
>> > That's why JakartaMultiPartRequest (and other implementations as well)
>> > always creates an array, even if only one file is uploaded:
>> > https://github.com/lukaszlenart/struts/blob/WW-
>> 4717/core/src/main/java/org/apache/struts2/dispatcher/multipart/
>> JakartaMultiPartRequest.java#L110-L118
>> >
>> >
>> > Regards
>> > --
>> > Łukasz
>> > + 48 606 323 122 http://www.lenart.org.pl/
>> >
>> > 2016-11-24 12:13 GMT+01:00 Greg Huber :
>> >> Seems to be this line in UploadedFileConverter:
>> >>
>> >> if (value.getClass().isArray() && Array.getLength(value) == 1) {
>> >>
>> >> where value ==
>> >> org.apache.struts2.dispatcher.multipart.StrutsUploadedFile@62e25d8
>> >>
>> >> and is not an array.
>> >>
>> >> this works:
>> >>
>> >> Object obj = null;
>> >> if (value.getClass().isArray() && Array.getLength(value) ==
>> 1) {
>> >> obj = Array.get(value, 0);
>> >> } else {
>> >> obj = value;
>> >> }
>> >> if (obj instanceof UploadedFile) {
>> >> UploadedFile file = (UploadedFile) obj;
>> >> if (file.getContent() instanceof File) {
>> >> return file.getContent();
>> >> }
>> >> return new File(file.getAbsolutePath());
>> >> }
>> >>
>> >> This works for both my ajax and normal upload.
>> >>
>> >> On 23 November 2016 at 12:56, Lukasz Lenart 
>> wrote:
>> >>
>> >>> Could someone tag that PR with :+1:?
>> >>>
>> >>> 2016-11-22 20:41 GMT+01:00 Lukasz Lenart :
>> >>> > All is good :) I have refactored the file upload logic a bit, cleaned
>> >>> > up and fixed some issues with wrong message keys. Also I added
>> >>> > dedicated converter to keep support for java.io.File so there is no
>> >>> > need for migration :)
>> >>> >
>> >>> > I've also developed a small GAE plugin which is using the mentioned
>> >>> > changes (that's why build cannot pass as a Struts SNAPSHOT is wrong
>> >>> > ;-)), tested it locally and everything works as expected :D
>> >>> > https://github.com/lukaszlenart/struts2-gea-plugin
>> >>> >
>> >>> > Can you take a look on that PR?
>> >>> >
>> >>> >
>> >>> > Thanks in advance
>> >>> > --
>> >>> > Łukasz
>> >>> > + 48 606 323 122 http://www.lenart.org.pl/
>> >>> >
>> >>> > 2016-11-22 9:44 GMT+01:00 Lukasz Lenart :
>> >>> >> Done, thanks Aaron :) Now I must test this solution with Google
>> >>> AppEngine ;-)
>> >>> >>
>> >>> >> 2016-11-22 7:49 GMT+01:00 Lukasz Lenart :
>> >>> >>> 2016-11-21 20:12 GMT+01:00 Aaron Johnson > >:
>> >>>  Is it possible to have a converter from UploadedFile to File? The
>> >>>  UploadedFile has a getContent() method that returns the File
>> object.
>> >>> >>>
>> >>> >>> Hm... it would be possible to add a converter, that should work :)
>> >>> >>>
>> >>> >>>
>> >>> >>> Regards
>> >>> >>> --
>> >>> >>> Łukasz
>> >>> >>> + 48 606 323 122 http://www.lenart.org.pl/
>> >>>
>> >>> -
>> >>> To unsubscribe, e-mail: dev-unsubscr...@struts.apache.org
>> >>> For additional commands, e-mail: dev-h...@struts.apache.org
>> >>>
>> >>>
>>
>> -
>> To unsubscribe, e-mail: dev-unsubscr...@struts.apache.org
>> For additional commands, e-mail: dev-h...@struts.apache.org
>>
>>

-
To unsubscribe, e-mail: dev-unsubscr...@struts.apache.org
For additional commands, e-mail: dev-h...@struts.apache.org



Re: [jira] [Updated] (WW-4717) Refactor file upload support to allow create virtual representation of java.io.File

2016-11-24 Thread Greg Huber
For every file it calls the UploadedFileConverter, this is the same for
the ajax uploader and a form with multiple upload files.

On 24 November 2016 at 14:08, Lukasz Lenart  wrote:

> That shouldn't matter but I think how can I test this behaviour.
>
> 2016-11-24 15:03 GMT+01:00 Greg Huber :
> > Sorry, forgot to add this is not on the app engine!  Was only testing the
> > plugin functionality ie the filter and the listener.  I assume the array
> > comes from when running the webapp on the app engine?
> >
> >
> >
> > On 24 November 2016 at 13:26, Lukasz Lenart 
> wrote:
> >
> >> Hm... this can be an internal conversion of collection containing
> >> uploaded files. Does your ajax upload allow upload multiple files at
> >> once?
> >>
> >> 2016-11-24 14:18 GMT+01:00 Lukasz Lenart :
> >> > How is that possible? I meant, parameters should always be passed as
> >> > arrays, that's how HttpServletRequest works. Do you use custom
> >> > implementation of MultiPartRequest? Could you share your upload logic,
> >> > action and JSP/JavaScript?
> >> >
> >> > That's why JakartaMultiPartRequest (and other implementations as well)
> >> > always creates an array, even if only one file is uploaded:
> >> > https://github.com/lukaszlenart/struts/blob/WW-
> >> 4717/core/src/main/java/org/apache/struts2/dispatcher/multipart/
> >> JakartaMultiPartRequest.java#L110-L118
> >> >
> >> >
> >> > Regards
> >> > --
> >> > Łukasz
> >> > + 48 606 323 122 http://www.lenart.org.pl/
> >> >
> >> > 2016-11-24 12:13 GMT+01:00 Greg Huber :
> >> >> Seems to be this line in UploadedFileConverter:
> >> >>
> >> >> if (value.getClass().isArray() && Array.getLength(value) == 1) {
> >> >>
> >> >> where value ==
> >> >> org.apache.struts2.dispatcher.multipart.StrutsUploadedFile@62e25d8
> >> >>
> >> >> and is not an array.
> >> >>
> >> >> this works:
> >> >>
> >> >> Object obj = null;
> >> >> if (value.getClass().isArray() && Array.getLength(value)
> ==
> >> 1) {
> >> >> obj = Array.get(value, 0);
> >> >> } else {
> >> >> obj = value;
> >> >> }
> >> >> if (obj instanceof UploadedFile) {
> >> >> UploadedFile file = (UploadedFile) obj;
> >> >> if (file.getContent() instanceof File) {
> >> >> return file.getContent();
> >> >> }
> >> >> return new File(file.getAbsolutePath());
> >> >> }
> >> >>
> >> >> This works for both my ajax and normal upload.
> >> >>
> >> >> On 23 November 2016 at 12:56, Lukasz Lenart  >
> >> wrote:
> >> >>
> >> >>> Could someone tag that PR with :+1:?
> >> >>>
> >> >>> 2016-11-22 20:41 GMT+01:00 Lukasz Lenart :
> >> >>> > All is good :) I have refactored the file upload logic a bit,
> cleaned
> >> >>> > up and fixed some issues with wrong message keys. Also I added
> >> >>> > dedicated converter to keep support for java.io.File so there is
> no
> >> >>> > need for migration :)
> >> >>> >
> >> >>> > I've also developed a small GAE plugin which is using the
> mentioned
> >> >>> > changes (that's why build cannot pass as a Struts SNAPSHOT is
> wrong
> >> >>> > ;-)), tested it locally and everything works as expected :D
> >> >>> > https://github.com/lukaszlenart/struts2-gea-plugin
> >> >>> >
> >> >>> > Can you take a look on that PR?
> >> >>> >
> >> >>> >
> >> >>> > Thanks in advance
> >> >>> > --
> >> >>> > Łukasz
> >> >>> > + 48 606 323 122 http://www.lenart.org.pl/
> >> >>> >
> >> >>> > 2016-11-22 9:44 GMT+01:00 Lukasz Lenart  >:
> >> >>> >> Done, thanks Aaron :) Now I must test this solution with Google
> >> >>> AppEngine ;-)
> >> >>> >>
> >> >>> >> 2016-11-22 7:49 GMT+01:00 Lukasz Lenart  >:
> >> >>> >>> 2016-11-21 20:12 GMT+01:00 Aaron Johnson <
> johnson.aar...@gmail.com
> >> >:
> >> >>>  Is it possible to have a converter from UploadedFile to File?
> The
> >> >>>  UploadedFile has a getContent() method that returns the File
> >> object.
> >> >>> >>>
> >> >>> >>> Hm... it would be possible to add a converter, that should work
> :)
> >> >>> >>>
> >> >>> >>>
> >> >>> >>> Regards
> >> >>> >>> --
> >> >>> >>> Łukasz
> >> >>> >>> + 48 606 323 122 http://www.lenart.org.pl/
> >> >>>
> >> >>> 
> -
> >> >>> To unsubscribe, e-mail: dev-unsubscr...@struts.apache.org
> >> >>> For additional commands, e-mail: dev-h...@struts.apache.org
> >> >>>
> >> >>>
> >>
> >> -
> >> To unsubscribe, e-mail: dev-unsubscr...@struts.apache.org
> >> For additional commands, e-mail: dev-h...@struts.apache.org
> >>
> >>
>
> -
> To unsubscribe, e-mail: dev-unsubscr...@struts.apache.org
> For additional commands, e-mail: dev-h...@struts.apache.org
>
>


Re: Upgrading do Servlet API 2.5 and JSP API 2.1

2016-11-24 Thread Rene Gielen
Am 23.11.16 um 12:56 schrieb Lukasz Lenart:
> I prefer to go in small steps:
> 
> - Struts 2.6 - Servlets 2.5, JSP 2.1, Java 7
> - Struts 3 - Servlets 3.0, JSP 2.2, Java 7
> - Struts 4 - ..., Java 8
> 
> and as from Struts 3 switch to full Semantic Versioning http://semver.org/

+1 to all these proposals.

While Struts itself keeps innovating a great deal, a big portion of our
user base is usually conservative in their platform upgrade policy.

- René

> 
> 
> Regards
> Lukasz
> 
> 2016-11-18 13:15 GMT+01:00 Aaron Johnson :
>> +1 for Struts 2.6 with Servlet 3.0 and JSP 2.2
>>
>> On Thu, Nov 17, 2016 at 2:17 AM, Johannes Geppert  wrote:
>>
>>> +1 for a 2.6.x based on Servlet 3.0 and JSP 2.2.
>>>
>>> Best Regards
>>>
>>> Johannes
>>>
>>> #
>>> web: http://www.jgeppert.com
>>> twitter: http://twitter.com/jogep
>>>
>>>
>>> 2016-11-16 18:01 GMT+01:00 Aleksandr Mashchenko :
>>>
 Maybe Servlet 3.0 and JSP 2.2.

 For example: Apache Tomcat implements both in it 7.0.x series, which is
 available since ~2011.
 And support for the Apache Tomcat 6.0.x will end on 31 December 2016.

 ---
 Regards,
 Aleksandr


 -
 To unsubscribe, e-mail: dev-unsubscr...@struts.apache.org
 For additional commands, e-mail: dev-h...@struts.apache.org


>>>
> 
> -
> To unsubscribe, e-mail: dev-unsubscr...@struts.apache.org
> For additional commands, e-mail: dev-h...@struts.apache.org
> 


-
To unsubscribe, e-mail: dev-unsubscr...@struts.apache.org
For additional commands, e-mail: dev-h...@struts.apache.org



Re: [jira] [Updated] (WW-4717) Refactor file upload support to allow create virtual representation of java.io.File

2016-11-24 Thread Lukasz Lenart
Cool, I think we are good to go with this refactoring, the rest can be
resolved during a test build period.

Thanks a lot Greg for your help :)


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/


2016-11-24 15:29 GMT+01:00 Greg Huber :
> For every file it calls the UploadedFileConverter, this is the same for
> the ajax uploader and a form with multiple upload files.
>
> On 24 November 2016 at 14:08, Lukasz Lenart  wrote:
>
>> That shouldn't matter but I think how can I test this behaviour.
>>
>> 2016-11-24 15:03 GMT+01:00 Greg Huber :
>> > Sorry, forgot to add this is not on the app engine!  Was only testing the
>> > plugin functionality ie the filter and the listener.  I assume the array
>> > comes from when running the webapp on the app engine?
>> >
>> >
>> >
>> > On 24 November 2016 at 13:26, Lukasz Lenart 
>> wrote:
>> >
>> >> Hm... this can be an internal conversion of collection containing
>> >> uploaded files. Does your ajax upload allow upload multiple files at
>> >> once?
>> >>
>> >> 2016-11-24 14:18 GMT+01:00 Lukasz Lenart :
>> >> > How is that possible? I meant, parameters should always be passed as
>> >> > arrays, that's how HttpServletRequest works. Do you use custom
>> >> > implementation of MultiPartRequest? Could you share your upload logic,
>> >> > action and JSP/JavaScript?
>> >> >
>> >> > That's why JakartaMultiPartRequest (and other implementations as well)
>> >> > always creates an array, even if only one file is uploaded:
>> >> > https://github.com/lukaszlenart/struts/blob/WW-
>> >> 4717/core/src/main/java/org/apache/struts2/dispatcher/multipart/
>> >> JakartaMultiPartRequest.java#L110-L118
>> >> >
>> >> >
>> >> > Regards
>> >> > --
>> >> > Łukasz
>> >> > + 48 606 323 122 http://www.lenart.org.pl/
>> >> >
>> >> > 2016-11-24 12:13 GMT+01:00 Greg Huber :
>> >> >> Seems to be this line in UploadedFileConverter:
>> >> >>
>> >> >> if (value.getClass().isArray() && Array.getLength(value) == 1) {
>> >> >>
>> >> >> where value ==
>> >> >> org.apache.struts2.dispatcher.multipart.StrutsUploadedFile@62e25d8
>> >> >>
>> >> >> and is not an array.
>> >> >>
>> >> >> this works:
>> >> >>
>> >> >> Object obj = null;
>> >> >> if (value.getClass().isArray() && Array.getLength(value)
>> ==
>> >> 1) {
>> >> >> obj = Array.get(value, 0);
>> >> >> } else {
>> >> >> obj = value;
>> >> >> }
>> >> >> if (obj instanceof UploadedFile) {
>> >> >> UploadedFile file = (UploadedFile) obj;
>> >> >> if (file.getContent() instanceof File) {
>> >> >> return file.getContent();
>> >> >> }
>> >> >> return new File(file.getAbsolutePath());
>> >> >> }
>> >> >>
>> >> >> This works for both my ajax and normal upload.
>> >> >>
>> >> >> On 23 November 2016 at 12:56, Lukasz Lenart > >
>> >> wrote:
>> >> >>
>> >> >>> Could someone tag that PR with :+1:?
>> >> >>>
>> >> >>> 2016-11-22 20:41 GMT+01:00 Lukasz Lenart :
>> >> >>> > All is good :) I have refactored the file upload logic a bit,
>> cleaned
>> >> >>> > up and fixed some issues with wrong message keys. Also I added
>> >> >>> > dedicated converter to keep support for java.io.File so there is
>> no
>> >> >>> > need for migration :)
>> >> >>> >
>> >> >>> > I've also developed a small GAE plugin which is using the
>> mentioned
>> >> >>> > changes (that's why build cannot pass as a Struts SNAPSHOT is
>> wrong
>> >> >>> > ;-)), tested it locally and everything works as expected :D
>> >> >>> > https://github.com/lukaszlenart/struts2-gea-plugin
>> >> >>> >
>> >> >>> > Can you take a look on that PR?
>> >> >>> >
>> >> >>> >
>> >> >>> > Thanks in advance
>> >> >>> > --
>> >> >>> > Łukasz
>> >> >>> > + 48 606 323 122 http://www.lenart.org.pl/
>> >> >>> >
>> >> >>> > 2016-11-22 9:44 GMT+01:00 Lukasz Lenart > >:
>> >> >>> >> Done, thanks Aaron :) Now I must test this solution with Google
>> >> >>> AppEngine ;-)
>> >> >>> >>
>> >> >>> >> 2016-11-22 7:49 GMT+01:00 Lukasz Lenart > >:
>> >> >>> >>> 2016-11-21 20:12 GMT+01:00 Aaron Johnson <
>> johnson.aar...@gmail.com
>> >> >:
>> >> >>>  Is it possible to have a converter from UploadedFile to File?
>> The
>> >> >>>  UploadedFile has a getContent() method that returns the File
>> >> object.
>> >> >>> >>>
>> >> >>> >>> Hm... it would be possible to add a converter, that should work
>> :)
>> >> >>> >>>
>> >> >>> >>>
>> >> >>> >>> Regards
>> >> >>> >>> --
>> >> >>> >>> Łukasz
>> >> >>> >>> + 48 606 323 122 http://www.lenart.org.pl/
>> >> >>>
>> >> >>> 
>> -
>> >> >>> To unsubscribe, e-mail: dev-unsubscr...@struts.apache.org
>> >> >>> For additional commands, e-mail: dev-h...@struts.apache.org
>> >> >>>
>> >> >>>
>> >>
>> >> -
>> >> To unsubscribe, e-mail: dev-unsubscr...@struts.apache.org
>> >> For additional co