From beba23d14beb6f68bfe931926a3af6bcea6de6b2 Mon Sep 17 00:00:00 2001 From: Natasa Kapravelou Date: Mon, 11 Oct 2010 15:29:39 +0300 Subject: [PATCH] Revoke the previous commit to the old version since it doesn't add more value to forbid slashes to file names. --- src/gr/ebs/gss/client/FileUploadDialog.java | 49 ++++++--------------------- 1 file changed, 11 insertions(+), 38 deletions(-) diff --git a/src/gr/ebs/gss/client/FileUploadDialog.java b/src/gr/ebs/gss/client/FileUploadDialog.java index 6855e9d..3868328 100644 --- a/src/gr/ebs/gss/client/FileUploadDialog.java +++ b/src/gr/ebs/gss/client/FileUploadDialog.java @@ -38,12 +38,16 @@ import com.google.gwt.http.client.URL; import com.google.gwt.json.client.JSONObject; import com.google.gwt.json.client.JSONString; import com.google.gwt.user.client.DeferredCommand; -import com.google.gwt.user.client.Timer; import com.google.gwt.user.client.Event.NativePreviewEvent; +import com.google.gwt.user.client.Timer; import com.google.gwt.user.client.ui.Button; import com.google.gwt.user.client.ui.DialogBox; import com.google.gwt.user.client.ui.FileUpload; import com.google.gwt.user.client.ui.FormPanel; +import com.google.gwt.user.client.ui.FormPanel.SubmitCompleteEvent; +import com.google.gwt.user.client.ui.FormPanel.SubmitCompleteHandler; +import com.google.gwt.user.client.ui.FormPanel.SubmitEvent; +import com.google.gwt.user.client.ui.FormPanel.SubmitHandler; import com.google.gwt.user.client.ui.Grid; import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.HasHorizontalAlignment; @@ -51,10 +55,6 @@ import com.google.gwt.user.client.ui.Hidden; import com.google.gwt.user.client.ui.HorizontalPanel; import com.google.gwt.user.client.ui.Label; import com.google.gwt.user.client.ui.VerticalPanel; -import com.google.gwt.user.client.ui.FormPanel.SubmitCompleteEvent; -import com.google.gwt.user.client.ui.FormPanel.SubmitCompleteHandler; -import com.google.gwt.user.client.ui.FormPanel.SubmitEvent; -import com.google.gwt.user.client.ui.FormPanel.SubmitHandler; /** * The 'File upload' dialog box implementation. @@ -86,9 +86,6 @@ public class FileUploadDialog extends DialogBox implements Updateable { protected FolderResource folder; - private String fileName; - - /** * The widget's constructor. */ @@ -283,36 +280,12 @@ public class FileUploadDialog extends DialogBox implements Updateable { * Make any last minute checks and start the upload. */ public void prepareAndSubmit() { - fileName = getFilename(upload.getFilename()); - GSS.get(); - if(!GSS.isValidResourceName(fileName)){ - GWT.log("The upload attemp contains bad elements like slashes.", null); - ConfirmationDialog confirmBox = new ConfirmationDialog("The file you are going to upload" + - " contains slashes inside its name or the filename should be different than '.' or '..'" + - " In case you want to continue you should note that the illegal character" + - " will be automatically replaced with '-' otherwise please press Cancel to rename the file name " + - " on your own before continuing the upload.", "Illegal Characters found") { - - @Override - public void cancel() { - FileUploadDialog.this.hide(); - } - - @Override - public void confirm() { - String name = fileName.replace("/","-"); - fileName = name; - } - - }; - confirmBox.center(); - - } - if (getFileForName(fileName) == null) { + final String fname = getFilename(upload.getFilename()); + if (getFileForName(fname) == null) { //we are going to create a file, so we check to see if there is a trashed file with the same name FileResource same = null; for (FileResource fres : folder.getFiles()) - if (fres.isDeleted() && fres.getName().equals(fileName)) + if (fres.isDeleted() && fres.getName().equals(fname)) same = fres; if (same == null) form.submit(); @@ -321,7 +294,7 @@ public class FileUploadDialog extends DialogBox implements Updateable { GWT.log("Same deleted file", null); ConfirmationDialog confirm = new ConfirmationDialog("A file with " + "the same name exists in the trash. If you continue,
the trashed " + - "file '" + fileName + "' will be renamed automatically for you.", "Continue") { + "file '" + fname + "' will be renamed automatically for you.", "Continue") { @Override public void cancel() { @@ -330,7 +303,7 @@ public class FileUploadDialog extends DialogBox implements Updateable { @Override public void confirm() { - updateTrashedFile(getBackupFilename(fileName), sameFile); + updateTrashedFile(getBackupFilename(fname), sameFile); } }; @@ -340,7 +313,7 @@ public class FileUploadDialog extends DialogBox implements Updateable { else { // We are going to update an existing file, so show a confirmation dialog. ConfirmationDialog confirm = new ConfirmationDialog("Are you sure " + - "you want to update " + fileName + "?", "Update") { + "you want to update " + fname + "?", "Update") { @Override public void cancel() { -- 1.7.10.4