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