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