[kune-commits] r889 - in trunk/src/main/java/org/ourproject/kune: app/public docs/client platf/server/manager/impl workspace/client/skel

vjrj vjrj at ourproject.org
Sat Sep 27 15:01:44 CEST 2008


Author: vjrj
Date: 2008-09-27 15:01:41 +0200 (Sat, 27 Sep 2008)
New Revision: 889

Modified:
   trunk/src/main/java/org/ourproject/kune/app/public/Kune.html
   trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientActions.java
   trunk/src/main/java/org/ourproject/kune/platf/server/manager/impl/FileDownloadManager.java
   trunk/src/main/java/org/ourproject/kune/workspace/client/skel/WorkspaceSkeleton.java
Log:
Download in hidden iframe instead of Window.open. Download of images and/or inline show with &download=true|false param


Modified: trunk/src/main/java/org/ourproject/kune/app/public/Kune.html
===================================================================
--- trunk/src/main/java/org/ourproject/kune/app/public/Kune.html	2008-09-27 11:14:37 UTC (rev 888)
+++ trunk/src/main/java/org/ourproject/kune/app/public/Kune.html	2008-09-27 13:01:41 UTC (rev 889)
@@ -47,6 +47,7 @@
 <script type="text/javascript" language="javascript"
     src="org.ourproject.kune.app.Kune.nocache.js"></script>
 <iframe id="__gwt_historyFrame" style="width: 0; height: 0; border: 0"></iframe>
+<iframe src="" id="__download" style="width:0;height:0;border:0"></iframe>
 <div id="kuneprogresspanel" class="k-sitebar">
 <table cellspacing="0" summary="Starting" cellpadding="0" border="0"
     style="height: 16px; margin-top: 5px; margin-left: 5px;">

Modified: trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientActions.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientActions.java	2008-09-27 11:14:37 UTC (rev 888)
+++ trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientActions.java	2008-09-27 13:01:41 UTC (rev 889)
@@ -334,7 +334,8 @@
     }
 
     private void downloadContent(final StateToken token) {
-	final String url = "/kune/servlets/FileDownloadManager?token=" + token + "&hash=" + session.getUserHash();
+	final String url = "/kune/servlets/FileDownloadManager?token=" + token + "&hash=" + session.getUserHash()
+		+ "&download=true";
 	ws.openUrl(url);
     }
 }

Modified: trunk/src/main/java/org/ourproject/kune/platf/server/manager/impl/FileDownloadManager.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/server/manager/impl/FileDownloadManager.java	2008-09-27 11:14:37 UTC (rev 888)
+++ trunk/src/main/java/org/ourproject/kune/platf/server/manager/impl/FileDownloadManager.java	2008-09-27 13:01:41 UTC (rev 889)
@@ -63,6 +63,8 @@
 
 	final String userHash = req.getParameter("hash");
 	final StateToken stateToken = new StateToken(req.getParameter("token"));
+	final String downloadS = req.getParameter("download");
+	final boolean download = downloadS != null && downloadS.equals("true") ? true : false;
 	final Content cnt = getContentForDownload(userHash, stateToken);
 
 	final String absDir = kuneProperties.get(KuneProperties.UPLOAD_LOCATION) + FileUtils.toDir(stateToken);
@@ -70,15 +72,16 @@
 	final String absFilename = absDir + filename;
 
 	doBuildResp(resp, absFilename, cnt.getTitle(), cnt.getMimeType(), FileUtils
-		.getFileNameExtension(filename, true));
+		.getFileNameExtension(filename, true), download);
     }
 
     private void doBuildResp(final HttpServletResponse resp, final String filename, final String otherName,
-	    final BasicMimeType mimeType, final String extension) throws FileNotFoundException, IOException {
+	    final BasicMimeType mimeType, final String extension, final boolean download) throws FileNotFoundException,
+	    IOException {
 	final File file = new File(filename);
 
 	resp.setContentLength((int) file.length());
-	if (mimeType == null) {
+	if (mimeType == null || download) {
 	    resp.setContentType("application/x-download");
 	} else if (mimeType.getType().equals("image") || mimeType.toString().equals("text/plain")) {
 	    resp.setContentType(mimeType.toString());

Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/skel/WorkspaceSkeleton.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/skel/WorkspaceSkeleton.java	2008-09-27 11:14:37 UTC (rev 888)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/skel/WorkspaceSkeleton.java	2008-09-27 13:01:41 UTC (rev 889)
@@ -5,8 +5,8 @@
 
 import com.calclab.suco.client.listener.Listener0;
 import com.google.gwt.user.client.Command;
+import com.google.gwt.user.client.DOM;
 import com.google.gwt.user.client.DeferredCommand;
-import com.google.gwt.user.client.Window;
 import com.google.gwt.user.client.ui.RootPanel;
 import com.google.gwt.user.client.ui.Widget;
 import com.gwtext.client.core.ExtElement;
@@ -89,7 +89,8 @@
 	// window.add(urlFrame);
 	// window.show();
 	// window.close();
-	Window.open(url, "", "_blank");
+	// Window.open(url, "", "_blank");
+	DOM.setElementAttribute(RootPanel.get("__download").getElement(), "src", url);
     }
 
     public void promptMessage(final String title, final String message, final Listener0 onEnter) {




More information about the kune-commits mailing list