Author: andrei_exadel
Date: 2008-04-23 05:45:39 -0400 (Wed, 23 Apr 2008)
New Revision: 8090
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/request/MultipartRequest.java
Log:
RF-3055
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/request/MultipartRequest.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/request/MultipartRequest.java 2008-04-23
09:18:01 UTC (rev 8089)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/request/MultipartRequest.java 2008-04-23
09:45:39 UTC (rev 8090)
@@ -14,6 +14,7 @@
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
@@ -174,6 +175,19 @@
}
return tempFile;
}
+
+ public void deleteFile() {
+ try {
+ if (fOut != null) {
+ fOut.close();
+ if (tempFile != null) {
+ tempFile.delete();
+ }
+ }
+ } catch (Exception e) {
+ throw new FileUploadException("Could not delete temporary file");
+ }
+ }
@Override
public void appendData(byte[] data, int start, int length)
@@ -293,6 +307,18 @@
}
return fileName;
}
+
+ public void cancel() {
+ if (parameters != null) {
+ Iterator<Param> it = parameters.values().iterator();
+ while (it.hasNext()) {
+ Param p = it.next();
+ if (p instanceof FileParam) {
+ ((FileParam)p).deleteFile();
+ }
+ }
+ }
+ }
public boolean parseRequest() {
byte[] boundaryMarker = getBoundaryMarker(request.getContentType());
@@ -430,18 +456,14 @@
pos = 0;
fillProgressInfo();
} else {
- if (file != null) {
- file.delete();
- }
+ cancel();
return false;
}
}
return true;
} else {
- if (file != null) {
- file.delete();
- }
+ cancel();
return false;
}
} catch (IOException ex) {
Show replies by date