-/*\r
- * Copyright 2009 Electronic Business Systems Ltd.\r
- *\r
- * This file is part of GSS.\r
- *\r
- * GSS is free software: you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation, either version 3 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * GSS is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with GSS. If not, see <http://www.gnu.org/licenses/>.\r
- */\r
-package gr.ebs.gss.client;\r
-\r
-import gr.ebs.gss.client.rest.RestCommand;\r
-\r
-import com.google.gwt.gears.client.desktop.File;\r
-import com.google.gwt.gears.client.httprequest.HttpRequest;\r
-import com.google.gwt.gears.client.httprequest.ProgressEvent;\r
-import com.google.gwt.gears.client.httprequest.ProgressHandler;\r
-import com.google.gwt.gears.client.httprequest.RequestCallback;\r
-\r
-/**\r
- * The 'File upload' dialog box implementation with Google Gears support\r
- * for IE.\r
- */\r
-public class FileUploadGearsIEDialog extends FileUploadGearsDialog implements Updateable {\r
-\r
- /**\r
- * Perform the HTTP request to upload the specified file.\r
- */\r
- @Override\r
- protected void doSend(final File file, final int index) {\r
- final GSS app = GSS.get();\r
- HttpRequest request = factory.createHttpRequest();\r
- requests.add(request);\r
- String method = "POST";\r
-\r
- String path;\r
- final String filename = getFilename(file.getName());\r
- path = folder.getUri();\r
- if (!path.endsWith("/"))\r
- path = path + "/";\r
- path = path + encode(filename);\r
-\r
- String token = app.getToken();\r
- String resource = path.substring(app.getApiPath().length()-1, path.length());\r
- String date = RestCommand.getDate();\r
- String sig = RestCommand.calculateSig(method, date, resource, RestCommand.base64decode(token));\r
- request.open(method, path);\r
- request.setRequestHeader("X-GSS-Date", date);\r
- request.setRequestHeader("Authorization", app.getCurrentUserResource().getUsername() + " " + sig);\r
- request.setRequestHeader("Accept", "application/json; charset=utf-8");\r
- request.setCallback(new RequestCallback() {\r
- public void onResponseReceived(HttpRequest req) {\r
- // XXX: No error checking, since IE throws an Internal Error\r
- // when accessing req.getStatus().\r
- selectedFiles.remove(file);\r
- finish();\r
- }\r
- });\r
- request.getUpload().setProgressHandler(new ProgressHandler() {\r
- public void onProgress(ProgressEvent event) {\r
- double pcnt = (double) event.getLoaded() / event.getTotal();\r
- progressBars.get(index).setProgress((int) Math.floor(pcnt * 100));\r
- }\r
- });\r
- request.send(file.getBlob());\r
- }\r
-\r
-}\r
+/*
+ * Copyright 2009 Electronic Business Systems Ltd.
+ *
+ * This file is part of GSS.
+ *
+ * GSS is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GSS is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GSS. If not, see <http://www.gnu.org/licenses/>.
+ */
+package gr.ebs.gss.client;
+
+import java.util.List;
+
+import gr.ebs.gss.client.rest.RestCommand;
+
+import com.google.gwt.gears.client.desktop.File;
+import com.google.gwt.gears.client.httprequest.HttpRequest;
+import com.google.gwt.gears.client.httprequest.ProgressEvent;
+import com.google.gwt.gears.client.httprequest.ProgressHandler;
+import com.google.gwt.gears.client.httprequest.RequestCallback;
+
+/**
+ * The 'File upload' dialog box implementation with Google Gears support
+ * for IE.
+ */
+public class FileUploadGearsIEDialog extends FileUploadGearsDialog implements Updateable {
+
+ /**
+ * Perform the HTTP request to upload the specified file.
+ */
+ @Override
+ protected void doSend(final List<File> filesRemaining) {
+ final GSS app = GSS.get();
+ HttpRequest request = factory.createHttpRequest();
+ requests.add(request);
+ String method = "POST";
+
+ String path;
+ final String filename = getFilename(filesRemaining.get(0).getName());
+ path = folder.getUri();
+ if (!path.endsWith("/"))
+ path = path + "/";
+ path = path + encode(filename);
+
+ String token = app.getToken();
+ String resource = path.substring(app.getApiPath().length()-1, path.length());
+ String date = RestCommand.getDate();
+ String sig = RestCommand.calculateSig(method, date, resource, RestCommand.base64decode(token));
+ request.open(method, path);
+ request.setRequestHeader("X-GSS-Date", date);
+ request.setRequestHeader("Authorization", app.getCurrentUserResource().getUsername() + " " + sig);
+ request.setRequestHeader("Accept", "application/json; charset=utf-8");
+ request.setCallback(new RequestCallback() {
+ @Override
+ public void onResponseReceived(HttpRequest req) {
+ // XXX: No error checking, since IE throws an Internal Error
+ // when accessing req.getStatus().
+ filesRemaining.remove(0);
+ if(filesRemaining.isEmpty()){
+ finish();
+ }
+ doSend(filesRemaining);
+ }
+ });
+ request.getUpload().setProgressHandler(new ProgressHandler() {
+ @Override
+ public void onProgress(ProgressEvent event) {
+ double pcnt = (double) event.getLoaded() / event.getTotal();
+ progressBars.get(0).setProgress((int) Math.floor(pcnt * 100));
+ if(pcnt*100 == 100)
+ progressBars.remove(0);
+ }
+ });
+ request.send(filesRemaining.get(0).getBlob());
+ }
+
+}