2384 |
15 Jun 06 |
nicklas |
1 |
<%-- $Id$ |
2384 |
15 Jun 06 |
nicklas |
2 |
------------------------------------------------------------------ |
3675 |
16 Aug 07 |
jari |
Copyright (C) 2006 Nicklas Nordborg |
2384 |
15 Jun 06 |
nicklas |
4 |
|
2384 |
15 Jun 06 |
nicklas |
5 |
This file is part of BASE - BioArray Software Environment. |
2384 |
15 Jun 06 |
nicklas |
6 |
Available at http://base.thep.lu.se/ |
2384 |
15 Jun 06 |
nicklas |
7 |
|
2384 |
15 Jun 06 |
nicklas |
8 |
BASE is free software; you can redistribute it and/or |
2384 |
15 Jun 06 |
nicklas |
9 |
modify it under the terms of the GNU General Public License |
4476 |
05 Sep 08 |
jari |
10 |
as published by the Free Software Foundation; either version 3 |
2384 |
15 Jun 06 |
nicklas |
11 |
of the License, or (at your option) any later version. |
2384 |
15 Jun 06 |
nicklas |
12 |
|
2384 |
15 Jun 06 |
nicklas |
13 |
BASE is distributed in the hope that it will be useful, |
2384 |
15 Jun 06 |
nicklas |
14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
2384 |
15 Jun 06 |
nicklas |
15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2384 |
15 Jun 06 |
nicklas |
16 |
GNU General Public License for more details. |
2384 |
15 Jun 06 |
nicklas |
17 |
|
2384 |
15 Jun 06 |
nicklas |
18 |
You should have received a copy of the GNU General Public License |
4510 |
11 Sep 08 |
jari |
19 |
along with BASE. If not, see <http://www.gnu.org/licenses/>. |
2384 |
15 Jun 06 |
nicklas |
20 |
------------------------------------------------------------------ |
2384 |
15 Jun 06 |
nicklas |
21 |
|
2384 |
15 Jun 06 |
nicklas |
22 |
@author Nicklas |
2384 |
15 Jun 06 |
nicklas |
23 |
@version 2.0 |
2384 |
15 Jun 06 |
nicklas |
24 |
--%> |
5426 |
24 Sep 10 |
nicklas |
25 |
<%@ page pageEncoding="UTF-8" session="false" |
2384 |
15 Jun 06 |
nicklas |
26 |
import="net.sf.basedb.core.Application" |
2384 |
15 Jun 06 |
nicklas |
27 |
import="net.sf.basedb.core.SessionControl" |
2384 |
15 Jun 06 |
nicklas |
28 |
import="net.sf.basedb.core.DbControl" |
2384 |
15 Jun 06 |
nicklas |
29 |
import="net.sf.basedb.core.Item" |
2384 |
15 Jun 06 |
nicklas |
30 |
import="net.sf.basedb.core.ItemContext" |
2384 |
15 Jun 06 |
nicklas |
31 |
import="net.sf.basedb.core.Permission" |
2384 |
15 Jun 06 |
nicklas |
32 |
import="net.sf.basedb.core.File" |
7738 |
14 Aug 19 |
nicklas |
33 |
import="net.sf.basedb.core.Path" |
2384 |
15 Jun 06 |
nicklas |
34 |
import="net.sf.basedb.core.Location" |
2384 |
15 Jun 06 |
nicklas |
35 |
import="net.sf.basedb.core.User" |
2384 |
15 Jun 06 |
nicklas |
36 |
import="net.sf.basedb.core.PermissionDeniedException" |
2384 |
15 Jun 06 |
nicklas |
37 |
import="net.sf.basedb.core.PluginDefinition" |
2384 |
15 Jun 06 |
nicklas |
38 |
import="net.sf.basedb.core.plugin.GuiContext" |
2384 |
15 Jun 06 |
nicklas |
39 |
import="net.sf.basedb.core.plugin.Plugin" |
2384 |
15 Jun 06 |
nicklas |
40 |
import="net.sf.basedb.clients.web.Base" |
2384 |
15 Jun 06 |
nicklas |
41 |
import="net.sf.basedb.clients.web.WebException" |
2384 |
15 Jun 06 |
nicklas |
42 |
import="net.sf.basedb.clients.web.util.HTML" |
2753 |
20 Oct 06 |
nicklas |
43 |
import="net.sf.basedb.util.Values" |
2384 |
15 Jun 06 |
nicklas |
44 |
|
2384 |
15 Jun 06 |
nicklas |
45 |
%> |
2384 |
15 Jun 06 |
nicklas |
46 |
<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
2384 |
15 Jun 06 |
nicklas |
47 |
<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %> |
2384 |
15 Jun 06 |
nicklas |
48 |
<%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %> |
2384 |
15 Jun 06 |
nicklas |
49 |
<%! |
2384 |
15 Jun 06 |
nicklas |
50 |
private static final Item itemType = Item.FILE; |
2384 |
15 Jun 06 |
nicklas |
51 |
private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.ITEM); |
2384 |
15 Jun 06 |
nicklas |
52 |
%> |
2384 |
15 Jun 06 |
nicklas |
53 |
<% |
2384 |
15 Jun 06 |
nicklas |
54 |
final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
2384 |
15 Jun 06 |
nicklas |
55 |
final String ID = sc.getId(); |
2384 |
15 Jun 06 |
nicklas |
56 |
final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null); |
2384 |
15 Jun 06 |
nicklas |
57 |
final int itemId = cc.getId(); |
2384 |
15 Jun 06 |
nicklas |
58 |
final float scale = Base.getScale(sc); |
2436 |
28 Jun 06 |
nicklas |
59 |
final String root = request.getContextPath() + "/"; |
7954 |
12 May 21 |
nicklas |
60 |
final DbControl dc = sc.newDbControl(":Download file dialog"); |
2384 |
15 Jun 06 |
nicklas |
61 |
try |
2384 |
15 Jun 06 |
nicklas |
62 |
{ |
2384 |
15 Jun 06 |
nicklas |
63 |
File file = File.getById(dc, itemId); |
7738 |
14 Aug 19 |
nicklas |
64 |
Path path = file.getPath(); |
2384 |
15 Jun 06 |
nicklas |
65 |
String title = "Download " + path; |
2384 |
15 Jun 06 |
nicklas |
66 |
|
5327 |
29 Apr 10 |
nicklas |
67 |
if (!file.getLocation().isDownloadable()) |
2384 |
15 Jun 06 |
nicklas |
68 |
{ |
2384 |
15 Jun 06 |
nicklas |
69 |
throw new WebException("popup", "File is not online", "The file {1} " + |
2384 |
15 Jun 06 |
nicklas |
70 |
"is not online and can't be downloaded", path); |
2384 |
15 Jun 06 |
nicklas |
71 |
} |
2384 |
15 Jun 06 |
nicklas |
72 |
|
7738 |
14 Aug 19 |
nicklas |
73 |
String downloadUrl = root + "filemanager/files/download/-"+ID+"-"+path.toURLString("UTF-8"); |
2384 |
15 Jun 06 |
nicklas |
74 |
%> |
2384 |
15 Jun 06 |
nicklas |
75 |
<base:page type="popup" title="<%=title%>"> |
6308 |
20 Aug 13 |
nicklas |
76 |
<base:head scripts="~download_file.js" /> |
6308 |
20 Aug 13 |
nicklas |
77 |
<base:body> |
5908 |
13 Dec 11 |
nicklas |
78 |
<h1><%=title%></h1> |
6308 |
20 Aug 13 |
nicklas |
79 |
|
6308 |
20 Aug 13 |
nicklas |
80 |
<div id="page-data" class="datacontainer" |
6308 |
20 Aug 13 |
nicklas |
81 |
data-download-url="<%=downloadUrl %>"></div> |
6308 |
20 Aug 13 |
nicklas |
82 |
|
5908 |
13 Dec 11 |
nicklas |
83 |
<div class="content"> |
5908 |
13 Dec 11 |
nicklas |
84 |
|
5908 |
13 Dec 11 |
nicklas |
85 |
<table class="fullform smaller bottomborder"> |
2384 |
15 Jun 06 |
nicklas |
86 |
<tr> |
5908 |
13 Dec 11 |
nicklas |
87 |
<th>File</th> |
7738 |
14 Aug 19 |
nicklas |
88 |
<td><a href="<%=downloadUrl%>"><%=HTML.encodeTags(path.toString())%></a></td> |
2384 |
15 Jun 06 |
nicklas |
89 |
</tr> |
2384 |
15 Jun 06 |
nicklas |
90 |
<tr> |
5908 |
13 Dec 11 |
nicklas |
91 |
<th>Size</th> |
5908 |
13 Dec 11 |
nicklas |
92 |
<td><%=Values.formatBytes(file.getSize())%></td> |
5908 |
13 Dec 11 |
nicklas |
93 |
</tr> |
5908 |
13 Dec 11 |
nicklas |
94 |
<tr> |
5908 |
13 Dec 11 |
nicklas |
95 |
<th>Content type</th> |
4520 |
15 Sep 08 |
nicklas |
96 |
<td> |
4520 |
15 Sep 08 |
nicklas |
97 |
<%=HTML.encodeTags(file.getMimeType())%><% |
4520 |
15 Sep 08 |
nicklas |
98 |
if (file.getCharacterSet() != null) |
4520 |
15 Sep 08 |
nicklas |
99 |
{ |
4520 |
15 Sep 08 |
nicklas |
100 |
%>; charset=<%=file.getCharacterSet()%> |
4520 |
15 Sep 08 |
nicklas |
101 |
<% |
4520 |
15 Sep 08 |
nicklas |
102 |
} |
4520 |
15 Sep 08 |
nicklas |
103 |
%> |
4520 |
15 Sep 08 |
nicklas |
104 |
</td> |
2384 |
15 Jun 06 |
nicklas |
105 |
</tr> |
2384 |
15 Jun 06 |
nicklas |
106 |
<tr> |
5908 |
13 Dec 11 |
nicklas |
107 |
<th>Description</th> |
2384 |
15 Jun 06 |
nicklas |
108 |
<td><%=HTML.niceFormat(file.getDescription())%></td> |
2384 |
15 Jun 06 |
nicklas |
109 |
</tr> |
5908 |
13 Dec 11 |
nicklas |
110 |
<tr class="dynamic"> |
5908 |
13 Dec 11 |
nicklas |
111 |
<th></th> |
5915 |
16 Dec 11 |
nicklas |
112 |
<td> |
5915 |
16 Dec 11 |
nicklas |
113 |
<div class="messagecontainer help"> |
5915 |
16 Dec 11 |
nicklas |
114 |
<b>If the download doesn't start, click on the filename above.</b> |
5915 |
16 Dec 11 |
nicklas |
115 |
</div> |
5915 |
16 Dec 11 |
nicklas |
116 |
</td> |
5908 |
13 Dec 11 |
nicklas |
117 |
</tr> |
2384 |
15 Jun 06 |
nicklas |
118 |
</table> |
2384 |
15 Jun 06 |
nicklas |
119 |
</div> |
2384 |
15 Jun 06 |
nicklas |
120 |
</form> |
2384 |
15 Jun 06 |
nicklas |
121 |
|
5908 |
13 Dec 11 |
nicklas |
122 |
<base:buttongroup subclass="dialogbuttons"> |
6308 |
20 Aug 13 |
nicklas |
123 |
<base:button id="close" title="Close" /> |
5908 |
13 Dec 11 |
nicklas |
124 |
</base:buttongroup> |
5908 |
13 Dec 11 |
nicklas |
125 |
|
2384 |
15 Jun 06 |
nicklas |
126 |
</base:body> |
2384 |
15 Jun 06 |
nicklas |
127 |
</base:page> |
2384 |
15 Jun 06 |
nicklas |
128 |
<% |
2384 |
15 Jun 06 |
nicklas |
129 |
} |
2384 |
15 Jun 06 |
nicklas |
130 |
finally |
2384 |
15 Jun 06 |
nicklas |
131 |
{ |
2384 |
15 Jun 06 |
nicklas |
132 |
if (dc != null) dc.close(); |
2384 |
15 Jun 06 |
nicklas |
133 |
} |
2384 |
15 Jun 06 |
nicklas |
134 |
|
2384 |
15 Jun 06 |
nicklas |
135 |
%> |