--- /dev/null
+/**\r
+ * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.\r
+ *\r
+ * This library is free software; you can redistribute it and/or modify it under\r
+ * the terms of the GNU Lesser General Public License as published by the Free\r
+ * Software Foundation; either version 2.1 of the License, or (at your option)\r
+ * any later version.\r
+ *\r
+ * This library is distributed in the hope that it will be useful, but WITHOUT\r
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more\r
+ * details.\r
+ */\r
+\r
+package com.liferay.portal.upload;\r
+\r
+import com.liferay.portal.kernel.util.ProgressTracker;\r
+import com.liferay.portal.kernel.util.Validator;\r
+\r
+import java.util.ArrayList;\r
+import java.util.List;\r
+import java.util.Map;\r
+\r
+import javax.servlet.http.HttpServletRequest;\r
+import javax.servlet.http.HttpSession;\r
+\r
+import org.apache.commons.fileupload.FileItem;\r
+import org.apache.commons.fileupload.FileItemFactory;\r
+import org.apache.commons.fileupload.FileUploadException;\r
+import org.apache.commons.fileupload.servlet.ServletFileUpload;\r
+\r
+/**\r
+ * @author Brian Myunghun Kim\r
+ * @author Brian Wing Shun Chan\r
+ */\r
+public class LiferayFileUpload extends ServletFileUpload {\r
+\r
+ public static final String FILE_NAME =\r
+ LiferayFileUpload.class.getName() + "_FILE_NAME";\r
+\r
+ public static final String PERCENT = ProgressTracker.PERCENT;\r
+\r
+ public LiferayFileUpload(\r
+ FileItemFactory fileItemFactory, HttpServletRequest request) {\r
+\r
+ super(fileItemFactory);\r
+\r
+ _session = request.getSession();\r
+ }\r
+\r
+ @Override\r
+ public List<LiferayFileItem> parseRequest(HttpServletRequest request)\r
+ throws FileUploadException {\r
+\r
+ _session.removeAttribute(LiferayFileUpload.FILE_NAME);\r
+ _session.removeAttribute(LiferayFileUpload.PERCENT);\r
+\r
+ return super.parseRequest(request);\r
+ }\r
+\r
+ /**\r
+ * @deprecated\r
+ */\r
+ @Override\r
+ @SuppressWarnings("rawtypes")\r
+ protected FileItem createItem(Map headers, boolean formField)\r
+ throws FileUploadException {\r
+\r
+ LiferayFileItem item = (LiferayFileItem)super.createItem(\r
+ headers, formField);\r
+\r
+ String fileName = item.getFileName();\r
+\r
+ if (Validator.isNotNull(fileName)) {\r
+ _session.setAttribute(LiferayFileUpload.FILE_NAME, fileName);\r
+ }\r
+\r
+ return item;\r
+ }\r
+\r
+ private HttpSession _session;\r
+\r
+}
\ No newline at end of file