1794 |
19 Jan 06 |
nicklas |
1 |
<%-- $Id$ |
1794 |
19 Jan 06 |
nicklas |
2 |
------------------------------------------------------------------ |
5425 |
23 Sep 10 |
nicklas |
Copyright (C) 2006 Jari Häkkinen, Nicklas Nordborg |
1794 |
19 Jan 06 |
nicklas |
4 |
|
2304 |
22 May 06 |
jari |
5 |
This file is part of BASE - BioArray Software Environment. |
2304 |
22 May 06 |
jari |
6 |
Available at http://base.thep.lu.se/ |
1794 |
19 Jan 06 |
nicklas |
7 |
|
1794 |
19 Jan 06 |
nicklas |
8 |
BASE is free software; you can redistribute it and/or |
1794 |
19 Jan 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 |
1794 |
19 Jan 06 |
nicklas |
11 |
of the License, or (at your option) any later version. |
1794 |
19 Jan 06 |
nicklas |
12 |
|
1794 |
19 Jan 06 |
nicklas |
13 |
BASE is distributed in the hope that it will be useful, |
1794 |
19 Jan 06 |
nicklas |
14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
1794 |
19 Jan 06 |
nicklas |
15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1794 |
19 Jan 06 |
nicklas |
16 |
GNU General Public License for more details. |
1794 |
19 Jan 06 |
nicklas |
17 |
|
1794 |
19 Jan 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/>. |
1794 |
19 Jan 06 |
nicklas |
20 |
------------------------------------------------------------------ |
1794 |
19 Jan 06 |
nicklas |
21 |
|
1794 |
19 Jan 06 |
nicklas |
22 |
@author Nicklas |
1794 |
19 Jan 06 |
nicklas |
23 |
@version 2.0 |
1794 |
19 Jan 06 |
nicklas |
24 |
--%> |
5426 |
24 Sep 10 |
nicklas |
25 |
<%@ page pageEncoding="UTF-8" session="false" |
1794 |
19 Jan 06 |
nicklas |
26 |
import="net.sf.basedb.core.SessionControl" |
1794 |
19 Jan 06 |
nicklas |
27 |
import="net.sf.basedb.core.DbControl" |
1794 |
19 Jan 06 |
nicklas |
28 |
import="net.sf.basedb.core.Item" |
2436 |
28 Jun 06 |
nicklas |
29 |
import="net.sf.basedb.core.File" |
1794 |
19 Jan 06 |
nicklas |
30 |
import="net.sf.basedb.core.ItemContext" |
1794 |
19 Jan 06 |
nicklas |
31 |
import="net.sf.basedb.clients.web.Base" |
1794 |
19 Jan 06 |
nicklas |
32 |
import="net.sf.basedb.clients.web.WebException" |
2753 |
20 Oct 06 |
nicklas |
33 |
import="net.sf.basedb.util.Values" |
1794 |
19 Jan 06 |
nicklas |
34 |
import="net.sf.basedb.clients.web.util.HTML" |
1794 |
19 Jan 06 |
nicklas |
35 |
%> |
1794 |
19 Jan 06 |
nicklas |
36 |
<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
1794 |
19 Jan 06 |
nicklas |
37 |
<%! |
5630 |
13 May 11 |
nicklas |
38 |
private static final ItemContext defaultContext = Base.createDefaultContext("name", "name,size,itemSubtype,description,actions"); |
1794 |
19 Jan 06 |
nicklas |
39 |
private static final Item itemType = Item.FILE; |
1794 |
19 Jan 06 |
nicklas |
40 |
%> |
1794 |
19 Jan 06 |
nicklas |
41 |
<% |
1794 |
19 Jan 06 |
nicklas |
42 |
final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
1794 |
19 Jan 06 |
nicklas |
43 |
final String ID = sc.getId(); |
1794 |
19 Jan 06 |
nicklas |
44 |
final String cmd = request.getParameter("cmd"); |
1794 |
19 Jan 06 |
nicklas |
45 |
final String root = request.getContextPath()+"/"; |
1794 |
19 Jan 06 |
nicklas |
46 |
|
1794 |
19 Jan 06 |
nicklas |
47 |
String forward = null; |
1794 |
19 Jan 06 |
nicklas |
48 |
String redirect = null; |
1794 |
19 Jan 06 |
nicklas |
49 |
String message = null; |
1794 |
19 Jan 06 |
nicklas |
50 |
DbControl dc = null; |
1794 |
19 Jan 06 |
nicklas |
51 |
try |
1794 |
19 Jan 06 |
nicklas |
52 |
{ |
1794 |
19 Jan 06 |
nicklas |
53 |
if (cmd == null || "List".equals(cmd)) |
1794 |
19 Jan 06 |
nicklas |
54 |
{ |
1794 |
19 Jan 06 |
nicklas |
55 |
// Display the list page without updatinging the current context |
2811 |
26 Oct 06 |
nicklas |
56 |
Base.getAndSetCurrentContext(sc, itemType, null, defaultContext, true); |
1794 |
19 Jan 06 |
nicklas |
57 |
forward = "manager.jsp"; |
1794 |
19 Jan 06 |
nicklas |
58 |
} |
1794 |
19 Jan 06 |
nicklas |
59 |
else if ("UpdateContext".equals(cmd)) |
1794 |
19 Jan 06 |
nicklas |
60 |
{ |
1794 |
19 Jan 06 |
nicklas |
61 |
// Display the list page after updating the current context from the request parameters |
1794 |
19 Jan 06 |
nicklas |
62 |
Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1794 |
19 Jan 06 |
nicklas |
63 |
forward = "manager.jsp"; |
1794 |
19 Jan 06 |
nicklas |
64 |
} |
1803 |
23 Jan 06 |
nicklas |
65 |
else if ("SelectOne".equals(cmd)) |
1803 |
23 Jan 06 |
nicklas |
66 |
{ |
1803 |
23 Jan 06 |
nicklas |
67 |
// Display the list page after updating the current context from the request parameters |
7738 |
14 Aug 19 |
nicklas |
68 |
Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext, true); |
5713 |
02 Sep 11 |
nicklas |
69 |
forward = "select_file.jsp?mode=selectone"; |
1803 |
23 Jan 06 |
nicklas |
70 |
} |
5713 |
02 Sep 11 |
nicklas |
71 |
else if ("SelectMultiple".equals(cmd)) |
5713 |
02 Sep 11 |
nicklas |
72 |
{ |
5713 |
02 Sep 11 |
nicklas |
73 |
// Display the list page after updating the current context from the request parameters |
7738 |
14 Aug 19 |
nicklas |
74 |
Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext, true); |
5713 |
02 Sep 11 |
nicklas |
75 |
forward = "select_file.jsp?mode=selectmultiple"; |
5713 |
02 Sep 11 |
nicklas |
76 |
} |
1803 |
23 Jan 06 |
nicklas |
77 |
else if ("SaveAs".equals(cmd)) |
1803 |
23 Jan 06 |
nicklas |
78 |
{ |
1803 |
23 Jan 06 |
nicklas |
79 |
// Display the list page after updating the current context from the request parameters |
7738 |
14 Aug 19 |
nicklas |
80 |
Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext, true); |
1803 |
23 Jan 06 |
nicklas |
81 |
forward = "save_as.jsp"; |
1803 |
23 Jan 06 |
nicklas |
82 |
} |
2432 |
27 Jun 06 |
nicklas |
83 |
else if ("ViewItem".equals(cmd)) |
2432 |
27 Jun 06 |
nicklas |
84 |
{ |
2432 |
27 Jun 06 |
nicklas |
85 |
forward = "manager.jsp"; |
2432 |
27 Jun 06 |
nicklas |
86 |
} |
5326 |
29 Apr 10 |
nicklas |
87 |
else if ("NewItem".equals(cmd)) |
5326 |
29 Apr 10 |
nicklas |
88 |
{ |
5793 |
07 Oct 11 |
nicklas |
89 |
redirect = "files/index.jsp?ID="+ID+"&cmd=NewItem&directory_id="+request.getParameter("directory_id"); |
5326 |
29 Apr 10 |
nicklas |
90 |
} |
2432 |
27 Jun 06 |
nicklas |
91 |
else if ("EditItem".equals(cmd)) |
2432 |
27 Jun 06 |
nicklas |
92 |
{ |
2432 |
27 Jun 06 |
nicklas |
93 |
redirect = "files/index.jsp?ID="+ID+"&cmd=EditItem&item_id="+request.getParameter("item_id"); |
2432 |
27 Jun 06 |
nicklas |
94 |
} |
6308 |
20 Aug 13 |
nicklas |
95 |
else if ("ShareItem".equals(cmd)) |
6308 |
20 Aug 13 |
nicklas |
96 |
{ |
6315 |
06 Sep 13 |
nicklas |
97 |
redirect = "files/index.jsp?ID="+ID+"&cmd=ShareItem&item_id="+request.getParameter("item_id"); |
6308 |
20 Aug 13 |
nicklas |
98 |
} |
2436 |
28 Jun 06 |
nicklas |
99 |
else if ("ViewFile".equals(cmd)) |
2436 |
28 Jun 06 |
nicklas |
100 |
{ |
2436 |
28 Jun 06 |
nicklas |
101 |
// View the file contents of a file |
2436 |
28 Jun 06 |
nicklas |
102 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
7954 |
12 May 21 |
nicklas |
103 |
dc = sc.newDbControl(":View file"); |
2436 |
28 Jun 06 |
nicklas |
104 |
File f = File.getById(dc, cc.getId()); |
4951 |
27 May 09 |
nicklas |
105 |
redirect = root + "filemanager/files/view/-"+ID+"-"+ f.getPath().toURLString("UTF-8"); |
2436 |
28 Jun 06 |
nicklas |
106 |
dc.close(); |
2436 |
28 Jun 06 |
nicklas |
107 |
} |
2436 |
28 Jun 06 |
nicklas |
108 |
else if ("DownloadFile".equals(cmd)) |
2436 |
28 Jun 06 |
nicklas |
109 |
{ |
2436 |
28 Jun 06 |
nicklas |
110 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
6457 |
09 May 14 |
nicklas |
111 |
redirect = "files/download_file.jsp?ID="+ID; |
2436 |
28 Jun 06 |
nicklas |
112 |
} |
1794 |
19 Jan 06 |
nicklas |
113 |
else |
1794 |
19 Jan 06 |
nicklas |
114 |
{ |
1794 |
19 Jan 06 |
nicklas |
115 |
throw new WebException("popup", "Invalid command", "The command {1} is not recognised as a valid command.", cmd); |
1794 |
19 Jan 06 |
nicklas |
116 |
} |
1794 |
19 Jan 06 |
nicklas |
117 |
} |
1794 |
19 Jan 06 |
nicklas |
118 |
finally |
1794 |
19 Jan 06 |
nicklas |
119 |
{ |
1794 |
19 Jan 06 |
nicklas |
120 |
if (dc != null) dc.close(); |
1794 |
19 Jan 06 |
nicklas |
121 |
} |
1794 |
19 Jan 06 |
nicklas |
122 |
|
1794 |
19 Jan 06 |
nicklas |
123 |
if (forward != null) |
1794 |
19 Jan 06 |
nicklas |
124 |
{ |
6192 |
31 Oct 12 |
nicklas |
125 |
sc.setSessionSetting("alert-message", message); |
1794 |
19 Jan 06 |
nicklas |
126 |
pageContext.forward(forward); |
1794 |
19 Jan 06 |
nicklas |
127 |
} |
1794 |
19 Jan 06 |
nicklas |
128 |
else if (redirect != null) |
1794 |
19 Jan 06 |
nicklas |
129 |
{ |
6192 |
31 Oct 12 |
nicklas |
130 |
sc.setSessionSetting("alert-message", message); |
1794 |
19 Jan 06 |
nicklas |
131 |
response.sendRedirect(redirect); |
1794 |
19 Jan 06 |
nicklas |
132 |
} |
1794 |
19 Jan 06 |
nicklas |
133 |
else if (message == null) |
1794 |
19 Jan 06 |
nicklas |
134 |
{ |
1794 |
19 Jan 06 |
nicklas |
135 |
response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&wait=0"); |
1794 |
19 Jan 06 |
nicklas |
136 |
} |
1794 |
19 Jan 06 |
nicklas |
137 |
else |
1794 |
19 Jan 06 |
nicklas |
138 |
{ |
1794 |
19 Jan 06 |
nicklas |
139 |
response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&message="+HTML.urlEncode(message)); |
1794 |
19 Jan 06 |
nicklas |
140 |
} |
1794 |
19 Jan 06 |
nicklas |
141 |
%> |
1794 |
19 Jan 06 |
nicklas |
142 |
|