1 | <%-- $Id: index.jsp 7604 2019-02-25 12:19:50Z nicklas $ |
---|
2 | ------------------------------------------------------------------ |
---|
3 | Copyright (C) 2005 Nicklas Nordborg |
---|
4 | Copyright (C) 2006 Jari Häkkinen, Nicklas Nordborg |
---|
5 | |
---|
6 | This file is part of BASE - BioArray Software Environment. |
---|
7 | Available at http://base.thep.lu.se/ |
---|
8 | |
---|
9 | BASE is free software; you can redistribute it and/or |
---|
10 | modify it under the terms of the GNU General Public License |
---|
11 | as published by the Free Software Foundation; either version 3 |
---|
12 | of the License, or (at your option) any later version. |
---|
13 | |
---|
14 | BASE is distributed in the hope that it will be useful, |
---|
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
17 | GNU General Public License for more details. |
---|
18 | |
---|
19 | You should have received a copy of the GNU General Public License |
---|
20 | along with BASE. If not, see <http://www.gnu.org/licenses/>. |
---|
21 | ------------------------------------------------------------------ |
---|
22 | |
---|
23 | @author Nicklas |
---|
24 | @version 2.0 |
---|
25 | --%> |
---|
26 | <%@ page pageEncoding="UTF-8" session="false" |
---|
27 | import="net.sf.basedb.core.SessionControl" |
---|
28 | import="net.sf.basedb.core.DbControl" |
---|
29 | import="net.sf.basedb.core.Item" |
---|
30 | import="net.sf.basedb.core.Include" |
---|
31 | import="net.sf.basedb.core.Session" |
---|
32 | import="net.sf.basedb.core.User" |
---|
33 | import="net.sf.basedb.core.ItemQuery" |
---|
34 | import="net.sf.basedb.core.ItemResultIterator" |
---|
35 | import="net.sf.basedb.core.Include" |
---|
36 | import="net.sf.basedb.core.Permission" |
---|
37 | import="net.sf.basedb.core.ItemContext" |
---|
38 | import="net.sf.basedb.core.MultiPermissions" |
---|
39 | import="net.sf.basedb.core.PermissionDeniedException" |
---|
40 | import="net.sf.basedb.core.ItemAlreadyExistsException" |
---|
41 | import="net.sf.basedb.util.RemovableUtil" |
---|
42 | import="net.sf.basedb.util.ShareableUtil" |
---|
43 | import="net.sf.basedb.clients.web.Base" |
---|
44 | import="net.sf.basedb.clients.web.WebException" |
---|
45 | import="net.sf.basedb.util.Values" |
---|
46 | import="net.sf.basedb.clients.web.util.HTML" |
---|
47 | import="net.sf.basedb.core.plugin.GuiContext" |
---|
48 | import="net.sf.basedb.util.extensions.ExtensionsInvoker" |
---|
49 | import="net.sf.basedb.clients.web.extensions.ExtensionsControl" |
---|
50 | import="net.sf.basedb.clients.web.extensions.JspContext" |
---|
51 | import="net.sf.basedb.clients.web.extensions.list.ListColumnExportRenderer" |
---|
52 | import="net.sf.basedb.clients.web.extensions.list.ListColumnAction" |
---|
53 | import="net.sf.basedb.clients.web.extensions.list.ListColumnUtil" |
---|
54 | import="java.util.Enumeration" |
---|
55 | import="java.util.Set" |
---|
56 | import="java.util.HashSet" |
---|
57 | import="java.util.List" |
---|
58 | import="java.util.ArrayList" |
---|
59 | import="java.util.Collections" |
---|
60 | %> |
---|
61 | <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
---|
62 | <%! |
---|
63 | private static final ItemContext defaultContext = Base.createDefaultContext("loginTime", "loginTime,logoutTime,client,authenticationMethod,remoteId,comment"); |
---|
64 | static |
---|
65 | { |
---|
66 | defaultContext.setSortDirection(ItemContext.SortDirection.DESC); |
---|
67 | } |
---|
68 | private static final Item itemType = Item.SESSION; |
---|
69 | %> |
---|
70 | <% |
---|
71 | final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
---|
72 | final String ID = sc.getId(); |
---|
73 | final String cmd = request.getParameter("cmd"); |
---|
74 | final String root = request.getContextPath()+"/"; |
---|
75 | final String mode = request.getParameter("mode"); |
---|
76 | final String callback = request.getParameter("callback"); |
---|
77 | final String itemId = request.getParameter("item_id"); |
---|
78 | final String listPage = "list_sessions.jsp?ID="+ID |
---|
79 | +(mode == null ? "" : "&mode="+mode) |
---|
80 | +(callback == null ? "" : "&callback="+callback) |
---|
81 | +(itemId == null ? "" : "&item_id="+itemId); |
---|
82 | final String viewPage = "view_session.jsp?ID="+ID; |
---|
83 | //final String editPage = "edit_job.jsp?ID="+ID; |
---|
84 | |
---|
85 | String forward = null; |
---|
86 | String redirect = null; |
---|
87 | String message = null; |
---|
88 | DbControl dc = null; |
---|
89 | |
---|
90 | try |
---|
91 | { |
---|
92 | if (cmd == null || "List".equals(cmd)) |
---|
93 | { |
---|
94 | // Display the list page without updatinging the current context |
---|
95 | Base.getAndSetCurrentContext(sc, itemType, null, defaultContext, true); |
---|
96 | redirect = listPage; |
---|
97 | } |
---|
98 | else if ("UpdateContext".equals(cmd)) |
---|
99 | { |
---|
100 | // Display the list page after updating the current context from the request parameters |
---|
101 | Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
---|
102 | redirect = listPage; |
---|
103 | } |
---|
104 | else if ("LoadContext".equals(cmd)) |
---|
105 | { |
---|
106 | // Display the list page after loading a saved context |
---|
107 | int contextId = Values.getInt(request.getParameter("context")); |
---|
108 | Base.loadContext(sc, contextId, defaultContext); |
---|
109 | redirect = listPage; |
---|
110 | } |
---|
111 | |
---|
112 | else if ("ViewItem".equals(cmd)) |
---|
113 | { |
---|
114 | // Display the view page for a single item (opens in a popup) |
---|
115 | ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
---|
116 | forward = viewPage; |
---|
117 | } |
---|
118 | /* |
---|
119 | else if ("EditItem".equals(cmd)) |
---|
120 | { |
---|
121 | // Display the edit page for a single item (should be opened in a popup) |
---|
122 | ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
---|
123 | redirect = editPage; |
---|
124 | } |
---|
125 | */ |
---|
126 | else if ("ExportItems".equals(cmd)) |
---|
127 | { |
---|
128 | // Run an export plugin in a list context |
---|
129 | ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
---|
130 | dc = sc.newDbControl(); |
---|
131 | final User user = cc.getInclude().contains(Include.OTHERS) ? |
---|
132 | null : User.getById(dc, sc.getLoggedInUserId()); |
---|
133 | final ItemQuery<Session> query = Session.getQuery(user); |
---|
134 | cc.configureQuery(dc, query, true); |
---|
135 | cc.setQuery(query); |
---|
136 | JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.list(itemType), null); |
---|
137 | ExtensionsInvoker<ListColumnAction<Session,?>> listInvoker = ListColumnUtil.useExtensions(jspContext); |
---|
138 | listInvoker.render(new ListColumnExportRenderer<Session>(cc)); |
---|
139 | dc.close(); |
---|
140 | redirect = "../../common/export/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=LIST&title=Export+messages"; |
---|
141 | } |
---|
142 | else if ("ExportItem".equals(cmd)) |
---|
143 | { |
---|
144 | // Run an export plugin in single-item context |
---|
145 | ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
---|
146 | redirect = "../../common/export/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&title=Export+message"; |
---|
147 | } |
---|
148 | else if ("RunListPlugin".equals(cmd)) |
---|
149 | { |
---|
150 | // Run another plugin in a list context |
---|
151 | ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
---|
152 | final User user = cc.getInclude().contains(Include.OTHERS) ? |
---|
153 | null : User.getById(dc, sc.getLoggedInUserId()); |
---|
154 | final ItemQuery<Session> query = Session.getQuery(user); |
---|
155 | dc = sc.newDbControl(); |
---|
156 | cc.configureQuery(dc, query, true); |
---|
157 | dc.close(); |
---|
158 | cc.setQuery(query); |
---|
159 | redirect = "../../common/plugin/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=LIST&main_type=OTHER&title=Run+plugin"; |
---|
160 | } |
---|
161 | else if ("RunPlugin".equals(cmd)) |
---|
162 | { |
---|
163 | // Run another plugin in single-item context |
---|
164 | ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
---|
165 | redirect = "../../common/plugin/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&main_type=OTHER&title=Run+plugin"; |
---|
166 | } |
---|
167 | else |
---|
168 | { |
---|
169 | throw new WebException("popup", "Invalid command", "The command {1} is not recognised as a valid command.", cmd); |
---|
170 | } |
---|
171 | } |
---|
172 | finally |
---|
173 | { |
---|
174 | if (dc != null) dc.close(); |
---|
175 | } |
---|
176 | |
---|
177 | if (forward != null) |
---|
178 | { |
---|
179 | sc.setSessionSetting("alert-message", message); |
---|
180 | pageContext.forward(forward); |
---|
181 | } |
---|
182 | else if (redirect != null) |
---|
183 | { |
---|
184 | sc.setSessionSetting("alert-message", message); |
---|
185 | response.sendRedirect(redirect); |
---|
186 | } |
---|
187 | else if (message == null) |
---|
188 | { |
---|
189 | response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&wait=0"); |
---|
190 | } |
---|
191 | else |
---|
192 | { |
---|
193 | response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&message="+HTML.urlEncode(message)); |
---|
194 | } |
---|
195 | %> |
---|
196 | |
---|