Bug 335890 - [client] make import/upload more usable
Summary: [client] make import/upload more usable
Status: RESOLVED FIXED
Alias: None
Product: Orion (Archived)
Classification: ECD
Component: Client (show other bugs)
Version: 0.2   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: 0.5 M2   Edit
Assignee: John Arthorne CLA
QA Contact:
URL:
Whiteboard:
Keywords: polish
: 367368 (view as bug list)
Depends on: 335916
Blocks:
  Show dependency tree
 
Reported: 2011-01-31 13:52 EST by Susan McCourt CLA
Modified: 2012-05-04 06:04 EDT (History)
7 users (show)

See Also:


Attachments
screenshot of first prompt to download after trying to import non-zip (70.20 KB, image/png)
2011-01-31 13:52 EST, Susan McCourt CLA
no flags Details
screenshot of different behavior on chrome (6.93 KB, image/png)
2011-01-31 13:57 EST, Susan McCourt CLA
no flags Details
Patch for server components (12.49 KB, patch)
2012-03-01 05:31 EST, Jay Arthanareeswaran CLA
no flags Details | Diff
Patch for client component (2.54 KB, patch)
2012-03-01 05:35 EST, Jay Arthanareeswaran CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Susan McCourt CLA 2011-01-31 13:52:09 EST
Created attachment 187991 [details]
screenshot of first prompt to download after trying to import non-zip

M5 candidate from master, Win7, FF 3.6.13

I was trying import for the first time and didn't notice/read the "import a zip" title on the dialog.  So I had selected a text file.

When I clicked finish, I got a download prompt from FF (see attached screenshot).  I cancelled the download prompt and clicked finish again.  This time, the browse button animates briefly and then nothing happens.

At this point, the import dialog will never work again (even for zip files) unless you reload all the javascript code. 

The silent failure for non-zips is disturbing, but the fact that zip downloads won't work again (even if you close/open the dialog) is much worse.
Comment 1 Susan McCourt CLA 2011-01-31 13:57:45 EST
Created attachment 187992 [details]
screenshot of different behavior on chrome

On Chrome the behavior is different.
If you pick a non-zip, it shows the filename with "fakepath" used as the path.

The failure is similar to FF (it won't import, fails silently).

BUT...the good news is that you can choose a zip file and it WILL work, the failure does not last for the life of the JS in the browser.
Comment 2 Susan McCourt CLA 2011-01-31 14:10:51 EST
On IE 8.0.7600.16385, Win7

It tries to do the download of the non-zip.
That fails, and you end up back in the import dialog.  At that point the import dialog won't work until you refresh the JS code.
Comment 3 Szymon Brandys CLA 2011-01-31 15:47:39 EST
dojo FileUploader sometimes goes into a weird state when only a refresh helps :|
Comment 4 Szymon Brandys CLA 2011-01-31 18:11:43 EST
I modified the code in TransferServlet so it returns 400 (HttpServletResponse.SC_BAD_REQUEST) instead of 201 (HttpServletResponse.SC_CREATED). If the error is returned instead of OK status, the download is not triggered. The Import dialog is just closed.
Comment 5 Susan McCourt CLA 2011-10-14 12:54:42 EDT
this would be a good polish item for RC3.
The symptoms are slightly different, but still confusing.

On Chrome, it seemed like after a failed import, i started getting strange errors when trying to do other things, like delete a file.

On Firefox, you get a 404 bad request error (which seems like the right response) but the UI doesn't report it.

We should either not let the user do a non-zip, or else handle the error gracefully, or possibly even let the user upload a single non-zip file (I find myself wanting to do this all the time!)
Comment 6 Susan McCourt CLA 2011-10-18 13:30:55 EDT
sigh, I don't see an easy way to deal with this in the RC3 timeframe.

(In reply to comment #5)
> this would be a good polish item for RC3.
>
> We should either not let the user do a non-zip, 

The old dojox.form.fileuploader had a fileMask array.  
But the (new in dojo 1.6) dojox.form.uploader, which we are using, does not support a file mask.  Apparently some HTML5 specs discuss a mask for inputs of file type, but it's not consistently implemented and therefore not supported in the dojox.form.uploader API

> or else handle the error
> gracefully, 

Both Chrome and FF are reporting a 400 (bad request) in the console.  This seems like a reasonable thing for the server to do.  Chrome also reports some additional errors (HTML Upload Error: Cannot read property 'value' of undefined) and additional errors reported by IFrame.js in the uploader (not sure why FF doesn't run that error handler, I put a breakpoint in the code and it was never hit.)

I tried including onError handling in the ImportDialog (currently it hides the dialog, I added code to report the error in Orion) but that code was never hit in the debugger.

I also found this in uploader.js
onError: function(/* Object or String */evtObject){
		// summary:
		//		Fires on errors
		//
		//FIXME: Unsure of a standard form of error events
	},

In summary I'm having trouble hooking in any kind of error handler.


> or possibly even let the user upload a single non-zip file (I find
> myself wanting to do this all the time!)

This would require server-side code.

What I think we should do (in 0.4) is:

- modify the server side to accept non-zips (new feature, usability)
- consider allowing multiple file selection (new feature, usability)
- consider getting rid of import dialog and instead just insert the dojox.form.filelist and uploader into the dom (this is just a presentation issue, we don't really need a dialog here, we could just open up a file selection input somewhere)
- figure out the error reporting and how to ensure that server reported problems are exposed by our client rather than going to the console
Comment 7 Susan McCourt CLA 2011-12-02 12:51:25 EST
generalizing title since previous comment discusses general enhancements.
Comment 8 John Arthorne CLA 2011-12-21 16:22:43 EST
*** Bug 367368 has been marked as a duplicate of this bug. ***
Comment 9 Tomasz Zarna CLA 2012-02-09 05:07:14 EST
Any news on this one?
Comment 10 John Arthorne CLA 2012-02-10 16:20:38 EST
Defer to 0.5 would be my suggestion. This is a nice enhancement but there is an easy workaround of using a zip file.
Comment 11 Jay Arthanareeswaran CLA 2012-02-29 07:15:52 EST
I am working on a fix that will enable us to do the following:

1. Upload zip and non-zip files
2. Specify overwrite options
3. Specify whether or not the zip file needs to be extracted (the user might simply want an archive to be present in his project. I think this is not supported now)

I will soon post a patch for review.
Comment 12 Jay Arthanareeswaran CLA 2012-03-01 05:31:32 EST
Created attachment 211864 [details]
Patch for server components

Patch contains necessary changes to support either a zip or non-zip file. It also makes unzipping optional, which means users can directly copy zip files from their local disk. The patch might need some clean-up.

Another point is, the multipart request is parsed in a limited way only for this specific use case. If we think we might be working with multipart forms in other places too, we either have to look at a third-party parser or write a full-fledged parser.
Comment 13 Jay Arthanareeswaran CLA 2012-03-01 05:35:15 EST
Created attachment 211865 [details]
Patch for client component

A partial front end support is provided in this patch. It doesn't yet handle the errors well. On an error, the dialog is not dismissed and only the console logs the error status. This needs more work. But just about enough to test the previous patch.

A question that comes to my mind is, do we want to support selection and importing of multiple files too? This would be a handy feature in my opinion.
Comment 14 John Arthorne CLA 2012-03-02 16:12:00 EST
Thanks for the patch Jay.

I will review at least the server side of this change, and probably pull Anton in for the client because he has some ideas there. I'm assigning the bug to myself for now so I don't lose track of it.
Comment 15 John Arthorne CLA 2012-03-14 15:49:41 EDT
Hi Jay,

I'm reviewing your patch and trying to understand the changes. It looks like it now requires a multi-part POST message with various header supplied in the form (like the destination file name). This seems more complicated for clients.. our previous API supported the simple case of the POST body to be the exact contents of the file, and used HTTP headers to pass extra information and arguments. I seem to remember it being difficult for some clients like dojo xhr to build multi-part form POSTs. Do you think we can go back to a simpler approach without a multi-part body, or is there some limitation to this?

Reviewing our old code I see we had a "raw" option to indicate the file should not be unzipped. it looks like you changed this to a multi-part segment called "extract". Is there a reason for doing it that way?

I should have given you this reference before:

http://wiki.eclipse.org/Orion/Server_API/Transfer_API

To give some context, we essentially supported two different import mechanisms before:

1) A POST request is used to start a transfer, followed by a series of PUT calls to upload chunks at a time. 
2) A single POST request with the entire file to be uploaded.

I originally designed 1) because I thought this would be more scalable and allow progress during upload. But, it turns out dojo didn't support any way to do this so we added 2). So for now 2) is the most important one to handle and I would be ok if we didn't support approach 1 at all now (since we don't have any client that can use it today).

All of our TransferTest suites fail with this change. If possible I would like to support the new cases while having the old ones continue working.
Comment 16 Anton McConville CLA 2012-03-14 17:16:14 EDT
dojo xhr does not handle binary - the dojo io frame needs to be used for that, but to be frank is not well documented for programmatic use outside of the file upload widget.

Anton

(In reply to comment #15)
> Hi Jay,
> 
> I'm reviewing your patch and trying to understand the changes. It looks like it
> now requires a multi-part POST message with various header supplied in the form
> (like the destination file name). This seems more complicated for clients.. our
> previous API supported the simple case of the POST body to be the exact
> contents of the file, and used HTTP headers to pass extra information and
> arguments. I seem to remember it being difficult for some clients like dojo xhr
> to build multi-part form POSTs. Do you think we can go back to a simpler
> approach without a multi-part body, or is there some limitation to this?
> 
> Reviewing our old code I see we had a "raw" option to indicate the file should
> not be unzipped. it looks like you changed this to a multi-part segment called
> "extract". Is there a reason for doing it that way?
> 
> I should have given you this reference before:
> 
> http://wiki.eclipse.org/Orion/Server_API/Transfer_API
> 
> To give some context, we essentially supported two different import mechanisms
> before:
> 
> 1) A POST request is used to start a transfer, followed by a series of PUT
> calls to upload chunks at a time. 
> 2) A single POST request with the entire file to be uploaded.
> 
> I originally designed 1) because I thought this would be more scalable and
> allow progress during upload. But, it turns out dojo didn't support any way to
> do this so we added 2). So for now 2) is the most important one to handle and I
> would be ok if we didn't support approach 1 at all now (since we don't have any
> client that can use it today).
> 
> All of our TransferTest suites fail with this change. If possible I would like
> to support the new cases while having the old ones continue working.
Comment 17 Jay Arthanareeswaran CLA 2012-03-15 09:27:37 EDT
(In reply to comment #15)
> Reviewing our old code I see we had a "raw" option to indicate the file should
> not be unzipped. it looks like you changed this to a multi-part segment called
> "extract". Is there a reason for doing it that way?
> 
> I should have given you this reference before:
> 
> http://wiki.eclipse.org/Orion/Server_API/Transfer_API

There was no particular reason. But thanks for sharing the link. I will stick to what we already have. I am working on the patch.
Comment 18 John Arthorne CLA 2012-04-19 14:10:46 EDT
I have fixed this. You can now import non-zip files. If the file is a zip we will still extract it. This was already supported on the server - I just had to tweak the headers sent from the client:

http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=0693279a7b4fc03bb08c689cdb9ea287f96f2127
Comment 19 Susan McCourt CLA 2012-04-19 15:58:40 EDT
thanks, John, you just made my life way easier for uploading new icons, etc.
Comment 20 Tomasz Zarna CLA 2012-05-02 11:15:52 EDT
(In reply to comment #6)
> - figure out the error reporting and how to ensure that server reported problems
> are exposed by our client rather than going to the console

John, Jay, has the bullet above been covered by this bug?
Comment 21 John Arthorne CLA 2012-05-02 14:53:46 EDT
(In reply to comment #20)
> (In reply to comment #6)
> > - figure out the error reporting and how to ensure that server reported problems
> > are exposed by our client rather than going to the console
> 
> John, Jay, has the bullet above been covered by this bug?

No, the error case in question was when you attempted to import non-zip. This went away because we now allow that.
Comment 22 Tomasz Zarna CLA 2012-05-04 06:04:07 EDT
In that case I think it makes sense to file a separate bug for the error handling on the client side => bug 378456.