Revision de2ff169 src/gr/ebs/gss/client/FileUploadDialog.java

b/src/gr/ebs/gss/client/FileUploadDialog.java
38 38
import com.google.gwt.json.client.JSONObject;
39 39
import com.google.gwt.json.client.JSONString;
40 40
import com.google.gwt.user.client.DeferredCommand;
41
import com.google.gwt.user.client.Event.NativePreviewEvent;
42 41
import com.google.gwt.user.client.Timer;
42
import com.google.gwt.user.client.Event.NativePreviewEvent;
43 43
import com.google.gwt.user.client.ui.Button;
44 44
import com.google.gwt.user.client.ui.DialogBox;
45 45
import com.google.gwt.user.client.ui.FileUpload;
46 46
import com.google.gwt.user.client.ui.FormPanel;
47
import com.google.gwt.user.client.ui.FormPanel.SubmitCompleteEvent;
48
import com.google.gwt.user.client.ui.FormPanel.SubmitCompleteHandler;
49
import com.google.gwt.user.client.ui.FormPanel.SubmitEvent;
50
import com.google.gwt.user.client.ui.FormPanel.SubmitHandler;
51 47
import com.google.gwt.user.client.ui.Grid;
52 48
import com.google.gwt.user.client.ui.HTML;
53 49
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
......
55 51
import com.google.gwt.user.client.ui.HorizontalPanel;
56 52
import com.google.gwt.user.client.ui.Label;
57 53
import com.google.gwt.user.client.ui.VerticalPanel;
54
import com.google.gwt.user.client.ui.FormPanel.SubmitCompleteEvent;
55
import com.google.gwt.user.client.ui.FormPanel.SubmitCompleteHandler;
56
import com.google.gwt.user.client.ui.FormPanel.SubmitEvent;
57
import com.google.gwt.user.client.ui.FormPanel.SubmitHandler;
58 58

  
59 59
/**
60 60
 * The 'File upload' dialog box implementation.
......
86 86

  
87 87
	protected FolderResource folder;
88 88

  
89
	private String fileName;
90

  
91

  
89 92
	/**
90 93
	 * The widget's constructor.
91 94
	 */
......
280 283
	 * Make any last minute checks and start the upload.
281 284
	 */
282 285
	public void prepareAndSubmit() {
283
		final String fname = getFilename(upload.getFilename());
284
		if (getFileForName(fname) == null) {
286
		fileName = getFilename(upload.getFilename());
287
		GSS.get();
288
		if(!GSS.isValidResourceName(fileName)){
289
			GWT.log("The upload attemp contains bad elements like slashes.", null);
290
			ConfirmationDialog confirmBox = new ConfirmationDialog("The file you are going to upload" +
291
					" contains slashes inside its name or the filename should be different than '.' or '..'" +
292
					" In case you want to continue you should note that the illegal character" +
293
					" will be automatically replaced with '-' otherwise please press Cancel to rename the file name " +
294
					" on your own before continuing the upload.", "Illegal Characters found") {
295

  
296
					@Override
297
					public void cancel() {
298
						FileUploadDialog.this.hide();
299
					}
300

  
301
					@Override
302
					public void confirm() {
303
						String name = fileName.replace("/","-");
304
						fileName = name;
305
					}
306

  
307
				};
308
				confirmBox.center();
309

  
310
		}
311
		if (getFileForName(fileName) == null) {
285 312
			//we are going to create a file, so we check to see if there is a trashed file with the same name
286 313
			FileResource same = null;
287 314
			for (FileResource fres : folder.getFiles())
288
				if (fres.isDeleted() && fres.getName().equals(fname))
315
				if (fres.isDeleted() && fres.getName().equals(fileName))
289 316
					same = fres;
290 317
			if (same == null)
291 318
				form.submit();
......
294 321
				GWT.log("Same deleted file", null);
295 322
				ConfirmationDialog confirm = new ConfirmationDialog("A file with " +
296 323
						"the same name exists in the trash. If you continue,<br/>the trashed " +
297
						"file  '" + fname + "' will be renamed automatically for you.", "Continue") {
324
						"file  '" + fileName + "' will be renamed automatically for you.", "Continue") {
298 325

  
299 326
					@Override
300 327
					public void cancel() {
......
303 330

  
304 331
					@Override
305 332
					public void confirm() {
306
						updateTrashedFile(getBackupFilename(fname), sameFile);
333
						updateTrashedFile(getBackupFilename(fileName), sameFile);
307 334
					}
308 335

  
309 336
				};
......
313 340
		else {
314 341
			// We are going to update an existing file, so show a confirmation dialog.
315 342
			ConfirmationDialog confirm = new ConfirmationDialog("Are you sure " +
316
					"you want to update " + fname + "?", "Update") {
343
					"you want to update " + fileName + "?", "Update") {
317 344

  
318 345
				@Override
319 346
				public void cancel() {

Also available in: Unified diff