Author: ndkhoiits
Date: 2011-09-23 07:26:13 -0400 (Fri, 23 Sep 2011)
New Revision: 7499
Modified:
portal/branches/xss/component/web/server/src/main/java/org/exoplatform/upload/UploadService.java
portal/branches/xss/component/web/server/src/main/java/org/exoplatform/web/handler/UploadHandler.java
portal/branches/xss/web/eXoResources/src/main/webapp/javascript/eXo/webui/UIUpload.js
Log:
GTNPORTAL-2116 Broken form layout after upload a file which has special name
Modified:
portal/branches/xss/component/web/server/src/main/java/org/exoplatform/upload/UploadService.java
===================================================================
---
portal/branches/xss/component/web/server/src/main/java/org/exoplatform/upload/UploadService.java 2011-09-23
10:00:16 UTC (rev 7498)
+++
portal/branches/xss/component/web/server/src/main/java/org/exoplatform/upload/UploadService.java 2011-09-23
11:26:13 UTC (rev 7499)
@@ -39,6 +39,7 @@
import org.exoplatform.container.xml.PortalContainerInfo;
import org.gatein.common.logging.Logger;
import org.gatein.common.logging.LoggerFactory;
+import org.gatein.common.text.EntityEncoder;
public class UploadService
{
@@ -75,7 +76,6 @@
* the webapp's {@link javax.servlet.http.HttpServletRequest}
* @throws FileUploadException
*/
- @SuppressWarnings("unchecked")
public void createUploadResource(HttpServletRequest request) throws
FileUploadException
{
String uploadId = request.getParameter("uploadId");
@@ -112,8 +112,10 @@
if (fileName == null)
fileName = uploadId;
fileName = fileName.substring(fileName.lastIndexOf('\\') + 1);
+ fileName = EntityEncoder.FULL.encode(fileName);
String storeLocation = uploadLocation_ + "/" + uploadId + "." +
fileName;
+
// commons-fileupload will store the temp file with name *.tmp
// we need to rename it to our desired name
fileItem.getStoreLocation().renameTo(new File(storeLocation));
Modified:
portal/branches/xss/component/web/server/src/main/java/org/exoplatform/web/handler/UploadHandler.java
===================================================================
---
portal/branches/xss/component/web/server/src/main/java/org/exoplatform/web/handler/UploadHandler.java 2011-09-23
10:00:16 UTC (rev 7498)
+++
portal/branches/xss/component/web/server/src/main/java/org/exoplatform/web/handler/UploadHandler.java 2011-09-23
11:26:13 UTC (rev 7499)
@@ -27,6 +27,7 @@
import org.exoplatform.web.ControllerContext;
import org.exoplatform.web.WebAppController;
import org.exoplatform.web.WebRequestHandler;
+import org.gatein.common.text.EntityEncoder;
import java.io.Writer;
import java.net.URLEncoder;
@@ -85,7 +86,6 @@
continue;
if (upResource.getStatus() == UploadResource.FAILED_STATUS)
{
-
int limitMB = service.getUploadLimitsMB().get(uploadIds[i]).intValue();
value.append("\n
\"").append(uploadIds[i]).append("\": {");
value.append("\n
\"status\":").append('\"').append("failed").append("\",");
Modified:
portal/branches/xss/web/eXoResources/src/main/webapp/javascript/eXo/webui/UIUpload.js
===================================================================
---
portal/branches/xss/web/eXoResources/src/main/webapp/javascript/eXo/webui/UIUpload.js 2011-09-23
10:00:16 UTC (rev 7498)
+++
portal/branches/xss/web/eXoResources/src/main/webapp/javascript/eXo/webui/UIUpload.js 2011-09-23
11:26:13 UTC (rev 7499)
@@ -43,7 +43,7 @@
//eXo.webui.UIUpload.listLimitMB.push();
this.createUploadEntry(uploadId, isAutoUpload);
} else if(response.upload[uploadId].percent == 100) {
- this.showUploaded(uploadId, decodeURIComponent(response.upload[uploadId].fileName));
+ this.showUploaded(uploadId, (response.upload[uploadId].fileName));
}
};
@@ -97,11 +97,10 @@
if(list.length < 1) return;
var url = eXo.env.server.context + "/upload?" ;
url += "action=progress" ;
-// var url = eXo.env.server.context + "/upload?action=progress";
+// var url = eXo.env.server.context + "/upload?action=progress";
for(var i = 0; i < list.length; i++){
url = url + "&uploadId=" + list[i];
}
-
var responseText = ajaxAsyncGetRequest(url, false);
if(list.length > 0) {
setTimeout("eXo.webui.UIUpload.refeshProgress('" + elementId +
"');", 1000);
@@ -111,16 +110,15 @@
try {
eval("response = "+responseText);
}catch(err) {
- return;
+ return;
}
-
+
+
for(id in response.upload) {
var container = parent.document.getElementById(elementId);
if (response.upload[id].status == "failed") {
this.abortUpload(id);
var message = eXo.core.DOMUtil.findFirstChildByClass(container, "div",
"LimitMessage").innerHTML ;
- alert(message.replace("{0}", response.upload[id].size)) ;
-// alert(response.upload[id].message);
continue;
}
var element = document.getElementById(id+"ProgressIframe");
@@ -129,9 +127,11 @@
var blueProgressBar = eXo.core.DOMUtil.findFirstChildByClass(progressBarMiddle,
"div", "BlueProgressBar") ;
var progressBarLabel = eXo.core.DOMUtil.findFirstChildByClass(blueProgressBar,
"div", "ProgressBarLabel") ;
blueProgressBar.style.width = percent + "%" ;
+
progressBarLabel.innerHTML = percent + "%" ;
-
- if(percent == 100) this.showUploaded(id, "");
+ if(percent == 100) {
+ this.showUploaded(id, response.upload[id].fileName);
+ }
}
if(eXo.webui.UIUpload.listUpload.length < 1) return;
@@ -160,7 +160,7 @@
var selectFileFrame = eXo.core.DOMUtil.findFirstDescendantByClass(container,
"div", "SelectFileFrame") ;
selectFileFrame.style.display = "block" ;
var fileNameLabel = eXo.core.DOMUtil.findFirstDescendantByClass(selectFileFrame,
"div", "FileNameLabel") ;
- if(fileName != null) fileNameLabel.innerHTML += " " + fileName;
+ if(fileName != null) fileNameLabel.innerHTML = decodeURIComponent(fileName);
var progressBarFrame = eXo.core.DOMUtil.findFirstDescendantByClass(container,
"div", "ProgressBarFrame") ;
progressBarFrame.style.display = "none" ;
var tmp = element.parentNode;
@@ -246,19 +246,7 @@
var file = DOMUtil.findDescendantById(form, "file");
if(file.value == null || file.value == '') return;
- var infoUploaded = eXo.core.DOMUtil.findFirstDescendantByClass(container,
"div", "FileNameLabel") ;
- var temp = file.value;
- if (temp.indexOf('/') != -1) {
- temp = temp.substr((temp.lastIndexOf('/') + 1), temp.length - 1) ;
- }
-
- if (temp.indexOf('\\') != -1) {
- temp = temp.substr((temp.lastIndexOf('\\') + 1), temp.length - 1) ;
- }
-
- infoUploaded.innerHTML = temp ;
-
var progressBarFrame = DOMUtil.findFirstDescendantByClass(container, "div",
"ProgressBarFrame") ;
progressBarFrame.style.display = "block" ;
var progressBarMiddle = DOMUtil.findFirstDescendantByClass(container, "div",
"ProgressBarMiddle") ;