5370 |
23 Jun 10 |
nicklas |
1 |
<%-- $Id $ |
5370 |
23 Jun 10 |
nicklas |
2 |
------------------------------------------------------------------ |
5370 |
23 Jun 10 |
nicklas |
Copyright (C) 2010 Nicklas Nordborg |
5370 |
23 Jun 10 |
nicklas |
4 |
|
5370 |
23 Jun 10 |
nicklas |
5 |
This file is part of BASE - BioArray Software Environment. |
5370 |
23 Jun 10 |
nicklas |
6 |
Available at http://base.thep.lu.se/ |
5370 |
23 Jun 10 |
nicklas |
7 |
|
5370 |
23 Jun 10 |
nicklas |
8 |
BASE is free software; you can redistribute it and/or |
5370 |
23 Jun 10 |
nicklas |
9 |
modify it under the terms of the GNU General Public License |
5370 |
23 Jun 10 |
nicklas |
10 |
as published by the Free Software Foundation; either version 3 |
5370 |
23 Jun 10 |
nicklas |
11 |
of the License, or (at your option) any later version. |
5370 |
23 Jun 10 |
nicklas |
12 |
|
5370 |
23 Jun 10 |
nicklas |
13 |
BASE is distributed in the hope that it will be useful, |
5370 |
23 Jun 10 |
nicklas |
14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
5370 |
23 Jun 10 |
nicklas |
15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
5370 |
23 Jun 10 |
nicklas |
16 |
GNU General Public License for more details. |
5370 |
23 Jun 10 |
nicklas |
17 |
|
5370 |
23 Jun 10 |
nicklas |
18 |
You should have received a copy of the GNU General Public License |
5370 |
23 Jun 10 |
nicklas |
19 |
along with BASE. If not, see <http://www.gnu.org/licenses/>. |
5370 |
23 Jun 10 |
nicklas |
20 |
------------------------------------------------------------------ |
5370 |
23 Jun 10 |
nicklas |
21 |
|
5370 |
23 Jun 10 |
nicklas |
22 |
@author Nicklas |
5370 |
23 Jun 10 |
nicklas |
23 |
--%> |
5426 |
24 Sep 10 |
nicklas |
24 |
<%@ page pageEncoding="UTF-8" session="false" |
5370 |
23 Jun 10 |
nicklas |
25 |
import="net.sf.basedb.core.SessionControl" |
5370 |
23 Jun 10 |
nicklas |
26 |
import="net.sf.basedb.core.DbControl" |
5370 |
23 Jun 10 |
nicklas |
27 |
import="net.sf.basedb.core.Item" |
5370 |
23 Jun 10 |
nicklas |
28 |
import="net.sf.basedb.core.Include" |
5370 |
23 Jun 10 |
nicklas |
29 |
import="net.sf.basedb.core.PermissionTemplate" |
5370 |
23 Jun 10 |
nicklas |
30 |
import="net.sf.basedb.core.ItemQuery" |
5370 |
23 Jun 10 |
nicklas |
31 |
import="net.sf.basedb.core.Permission" |
5370 |
23 Jun 10 |
nicklas |
32 |
import="net.sf.basedb.core.ItemContext" |
5370 |
23 Jun 10 |
nicklas |
33 |
import="net.sf.basedb.core.ItemQuery" |
5370 |
23 Jun 10 |
nicklas |
34 |
import="net.sf.basedb.core.MultiPermissions" |
5370 |
23 Jun 10 |
nicklas |
35 |
import="net.sf.basedb.core.OwnedItem" |
5370 |
23 Jun 10 |
nicklas |
36 |
import="net.sf.basedb.core.PermissionDeniedException" |
5370 |
23 Jun 10 |
nicklas |
37 |
import="net.sf.basedb.core.ItemAlreadyExistsException" |
5370 |
23 Jun 10 |
nicklas |
38 |
import="net.sf.basedb.util.RemovableUtil" |
5370 |
23 Jun 10 |
nicklas |
39 |
import="net.sf.basedb.util.ShareableUtil" |
5370 |
23 Jun 10 |
nicklas |
40 |
import="net.sf.basedb.util.OwnableUtil" |
5370 |
23 Jun 10 |
nicklas |
41 |
import="net.sf.basedb.clients.web.Base" |
5370 |
23 Jun 10 |
nicklas |
42 |
import="net.sf.basedb.clients.web.WebException" |
5370 |
23 Jun 10 |
nicklas |
43 |
import="net.sf.basedb.util.Values" |
5370 |
23 Jun 10 |
nicklas |
44 |
import="net.sf.basedb.clients.web.util.HTML" |
5501 |
18 Nov 10 |
nicklas |
45 |
import="net.sf.basedb.core.plugin.GuiContext" |
5501 |
18 Nov 10 |
nicklas |
46 |
import="net.sf.basedb.util.extensions.ExtensionsInvoker" |
5501 |
18 Nov 10 |
nicklas |
47 |
import="net.sf.basedb.clients.web.extensions.ExtensionsControl" |
5501 |
18 Nov 10 |
nicklas |
48 |
import="net.sf.basedb.clients.web.extensions.JspContext" |
5501 |
18 Nov 10 |
nicklas |
49 |
import="net.sf.basedb.clients.web.extensions.edit.EditUtil" |
7604 |
25 Feb 19 |
nicklas |
50 |
import="net.sf.basedb.clients.web.extensions.edit.OnSaveAction" |
5501 |
18 Nov 10 |
nicklas |
51 |
import="net.sf.basedb.clients.web.extensions.edit.OnSaveRenderer" |
6040 |
30 Mar 12 |
nicklas |
52 |
import="net.sf.basedb.clients.web.extensions.list.ListColumnExportRenderer" |
7604 |
25 Feb 19 |
nicklas |
53 |
import="net.sf.basedb.clients.web.extensions.list.ListColumnAction" |
6040 |
30 Mar 12 |
nicklas |
54 |
import="net.sf.basedb.clients.web.extensions.list.ListColumnUtil" |
5370 |
23 Jun 10 |
nicklas |
55 |
import="java.util.Enumeration" |
5370 |
23 Jun 10 |
nicklas |
56 |
import="java.util.Set" |
5370 |
23 Jun 10 |
nicklas |
57 |
import="java.util.HashSet" |
5370 |
23 Jun 10 |
nicklas |
58 |
import="java.util.List" |
5370 |
23 Jun 10 |
nicklas |
59 |
import="java.util.ArrayList" |
5370 |
23 Jun 10 |
nicklas |
60 |
import="java.util.Collections" |
5370 |
23 Jun 10 |
nicklas |
61 |
%> |
5370 |
23 Jun 10 |
nicklas |
62 |
<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
5370 |
23 Jun 10 |
nicklas |
63 |
<%! |
5370 |
23 Jun 10 |
nicklas |
64 |
private static final ItemContext defaultContext = Base.createDefaultContext("name", "name,description"); |
5370 |
23 Jun 10 |
nicklas |
65 |
private static final Item itemType = Item.PERMISSIONTEMPLATE; |
5370 |
23 Jun 10 |
nicklas |
66 |
%> |
5370 |
23 Jun 10 |
nicklas |
67 |
<% |
5370 |
23 Jun 10 |
nicklas |
68 |
final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
5370 |
23 Jun 10 |
nicklas |
69 |
final String ID = sc.getId(); |
5370 |
23 Jun 10 |
nicklas |
70 |
final String cmd = request.getParameter("cmd"); |
5370 |
23 Jun 10 |
nicklas |
71 |
final String root = request.getContextPath()+"/"; |
5370 |
23 Jun 10 |
nicklas |
72 |
final String mode = request.getParameter("mode"); |
5370 |
23 Jun 10 |
nicklas |
73 |
final String callback = request.getParameter("callback"); |
5370 |
23 Jun 10 |
nicklas |
74 |
final String itemId = request.getParameter("item_id"); |
5370 |
23 Jun 10 |
nicklas |
75 |
final String listPage = "list_templates.jsp?ID="+ID |
5370 |
23 Jun 10 |
nicklas |
76 |
+(mode == null ? "" : "&mode="+mode) |
5370 |
23 Jun 10 |
nicklas |
77 |
+(callback == null ? "" : "&callback="+callback) |
5370 |
23 Jun 10 |
nicklas |
78 |
+(itemId == null ? "" : "&item_id="+itemId); |
5370 |
23 Jun 10 |
nicklas |
79 |
final String viewPage = "view_template.jsp?ID="+ID; |
5370 |
23 Jun 10 |
nicklas |
80 |
final String editPage = "edit_template.jsp?ID="+ID; |
5370 |
23 Jun 10 |
nicklas |
81 |
|
5370 |
23 Jun 10 |
nicklas |
82 |
String forward = null; |
5370 |
23 Jun 10 |
nicklas |
83 |
String redirect = null; |
5370 |
23 Jun 10 |
nicklas |
84 |
String message = null; |
5370 |
23 Jun 10 |
nicklas |
85 |
DbControl dc = null; |
5370 |
23 Jun 10 |
nicklas |
86 |
|
5370 |
23 Jun 10 |
nicklas |
87 |
try |
5370 |
23 Jun 10 |
nicklas |
88 |
{ |
5370 |
23 Jun 10 |
nicklas |
89 |
if (cmd == null || "List".equals(cmd)) |
5370 |
23 Jun 10 |
nicklas |
90 |
{ |
5370 |
23 Jun 10 |
nicklas |
91 |
// Display the list page without updatinging the current context |
5370 |
23 Jun 10 |
nicklas |
92 |
Base.getAndSetCurrentContext(sc, itemType, null, defaultContext, true); |
5370 |
23 Jun 10 |
nicklas |
93 |
redirect = listPage; |
5370 |
23 Jun 10 |
nicklas |
94 |
} |
5370 |
23 Jun 10 |
nicklas |
95 |
else if ("UpdateContext".equals(cmd)) |
5370 |
23 Jun 10 |
nicklas |
96 |
{ |
5370 |
23 Jun 10 |
nicklas |
97 |
// Display the list page after updating the current context from the request parameters |
5370 |
23 Jun 10 |
nicklas |
98 |
Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
5370 |
23 Jun 10 |
nicklas |
99 |
redirect = listPage; |
5370 |
23 Jun 10 |
nicklas |
100 |
} |
5370 |
23 Jun 10 |
nicklas |
101 |
else if ("LoadContext".equals(cmd)) |
5370 |
23 Jun 10 |
nicklas |
102 |
{ |
5370 |
23 Jun 10 |
nicklas |
103 |
// Display the list page after loading a saved context |
5370 |
23 Jun 10 |
nicklas |
104 |
int contextId = Values.getInt(request.getParameter("context")); |
5370 |
23 Jun 10 |
nicklas |
105 |
Base.loadContext(sc, contextId, defaultContext); |
5370 |
23 Jun 10 |
nicklas |
106 |
redirect = listPage; |
5370 |
23 Jun 10 |
nicklas |
107 |
} |
5370 |
23 Jun 10 |
nicklas |
108 |
|
5370 |
23 Jun 10 |
nicklas |
109 |
else if ("ViewItem".equals(cmd)) |
5370 |
23 Jun 10 |
nicklas |
110 |
{ |
5370 |
23 Jun 10 |
nicklas |
111 |
// Display the view page for a single item |
5370 |
23 Jun 10 |
nicklas |
112 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
5370 |
23 Jun 10 |
nicklas |
113 |
forward = viewPage; |
5370 |
23 Jun 10 |
nicklas |
114 |
} |
5370 |
23 Jun 10 |
nicklas |
115 |
else if ("EditItem".equals(cmd)) |
5370 |
23 Jun 10 |
nicklas |
116 |
{ |
5370 |
23 Jun 10 |
nicklas |
117 |
// Display the edit page for a single item (should be opened in a popup) |
5370 |
23 Jun 10 |
nicklas |
118 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
5370 |
23 Jun 10 |
nicklas |
119 |
redirect = editPage; |
5370 |
23 Jun 10 |
nicklas |
120 |
} |
5370 |
23 Jun 10 |
nicklas |
121 |
else if ("NewItem".equals(cmd)) |
5370 |
23 Jun 10 |
nicklas |
122 |
{ |
5370 |
23 Jun 10 |
nicklas |
123 |
// Display the edit page for a new item (should be opened in a popup) |
5370 |
23 Jun 10 |
nicklas |
124 |
if (!sc.hasPermission(Permission.CREATE, itemType)) |
5370 |
23 Jun 10 |
nicklas |
125 |
{ |
5370 |
23 Jun 10 |
nicklas |
126 |
throw new PermissionDeniedException(Permission.CREATE, itemType.toString()); |
5370 |
23 Jun 10 |
nicklas |
127 |
} |
5370 |
23 Jun 10 |
nicklas |
128 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
5370 |
23 Jun 10 |
nicklas |
129 |
cc.setId(0); |
5370 |
23 Jun 10 |
nicklas |
130 |
redirect = editPage; |
5370 |
23 Jun 10 |
nicklas |
131 |
} |
5370 |
23 Jun 10 |
nicklas |
132 |
else if ("UpdateItem".equals(cmd)) |
5370 |
23 Jun 10 |
nicklas |
133 |
{ |
5370 |
23 Jun 10 |
nicklas |
134 |
// Update the properties on an item (will close the popup) |
5370 |
23 Jun 10 |
nicklas |
135 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, defaultContext); |
7954 |
12 May 21 |
nicklas |
136 |
dc = sc.newDbControl(":Edit "+itemType); |
7605 |
26 Feb 19 |
nicklas |
137 |
PermissionTemplate template = cc.getObject("item"); |
5370 |
23 Jun 10 |
nicklas |
138 |
if (template == null) |
5370 |
23 Jun 10 |
nicklas |
139 |
{ |
5370 |
23 Jun 10 |
nicklas |
140 |
template = PermissionTemplate.getNew(dc); |
5370 |
23 Jun 10 |
nicklas |
141 |
message = "Permission template created"; |
5370 |
23 Jun 10 |
nicklas |
142 |
dc.saveItem(template); |
5370 |
23 Jun 10 |
nicklas |
143 |
} |
5370 |
23 Jun 10 |
nicklas |
144 |
else |
5370 |
23 Jun 10 |
nicklas |
145 |
{ |
5370 |
23 Jun 10 |
nicklas |
146 |
dc.reattachItem(template, false); |
5370 |
23 Jun 10 |
nicklas |
147 |
message = "Permission template updated"; |
5370 |
23 Jun 10 |
nicklas |
148 |
} |
5501 |
18 Nov 10 |
nicklas |
149 |
JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.item(Item.PERMISSIONTEMPLATE), template); |
7604 |
25 Feb 19 |
nicklas |
150 |
ExtensionsInvoker<OnSaveAction> invoker = EditUtil.useOnSaveExtensions(jspContext); |
5501 |
18 Nov 10 |
nicklas |
151 |
try |
5501 |
18 Nov 10 |
nicklas |
152 |
{ |
5501 |
18 Nov 10 |
nicklas |
153 |
template.setName(Values.getStringOrNull(request.getParameter("name"))); |
5501 |
18 Nov 10 |
nicklas |
154 |
template.setDescription(Values.getStringOrNull(request.getParameter("description"))); |
5501 |
18 Nov 10 |
nicklas |
155 |
|
5501 |
18 Nov 10 |
nicklas |
156 |
// OnSave extensions |
5501 |
18 Nov 10 |
nicklas |
157 |
invoker.render(OnSaveRenderer.ON_SAVE); |
5501 |
18 Nov 10 |
nicklas |
158 |
dc.commit(); |
5501 |
18 Nov 10 |
nicklas |
159 |
invoker.render(OnSaveRenderer.ON_COMMIT); |
5501 |
18 Nov 10 |
nicklas |
160 |
} |
5501 |
18 Nov 10 |
nicklas |
161 |
catch (Exception ex) |
5501 |
18 Nov 10 |
nicklas |
162 |
{ |
5501 |
18 Nov 10 |
nicklas |
163 |
invoker.render(OnSaveRenderer.onRollback(ex)); |
5501 |
18 Nov 10 |
nicklas |
164 |
throw ex; |
5501 |
18 Nov 10 |
nicklas |
165 |
} |
5501 |
18 Nov 10 |
nicklas |
166 |
finally |
5501 |
18 Nov 10 |
nicklas |
167 |
{ |
5501 |
18 Nov 10 |
nicklas |
168 |
cc.removeObject("item"); |
5501 |
18 Nov 10 |
nicklas |
169 |
} |
5370 |
23 Jun 10 |
nicklas |
170 |
} |
5370 |
23 Jun 10 |
nicklas |
171 |
else if ("DeleteItem".equals(cmd)) |
5370 |
23 Jun 10 |
nicklas |
172 |
{ |
5370 |
23 Jun 10 |
nicklas |
173 |
// Delete a single item and then return to the view page |
7954 |
12 May 21 |
nicklas |
174 |
dc = sc.newDbControl(":Delete "+itemType); |
5370 |
23 Jun 10 |
nicklas |
175 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
5370 |
23 Jun 10 |
nicklas |
176 |
RemovableUtil.setRemoved(dc, itemType, Collections.singleton(cc.getId()), true); |
5370 |
23 Jun 10 |
nicklas |
177 |
dc.commit(); |
5370 |
23 Jun 10 |
nicklas |
178 |
redirect = viewPage; |
5370 |
23 Jun 10 |
nicklas |
179 |
} |
5370 |
23 Jun 10 |
nicklas |
180 |
else if ("DeleteItems".equals(cmd)) |
5370 |
23 Jun 10 |
nicklas |
181 |
{ |
5370 |
23 Jun 10 |
nicklas |
182 |
// Delete all selected items on the list page |
7954 |
12 May 21 |
nicklas |
183 |
dc = sc.newDbControl(":Delete "+itemType); |
5370 |
23 Jun 10 |
nicklas |
184 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
5370 |
23 Jun 10 |
nicklas |
185 |
int numTotal = cc.getSelected().size(); |
5370 |
23 Jun 10 |
nicklas |
186 |
int numRemoved = RemovableUtil.setRemoved(dc, itemType, cc.getSelected(), true); |
5370 |
23 Jun 10 |
nicklas |
187 |
dc.commit(); |
5370 |
23 Jun 10 |
nicklas |
188 |
if (numTotal != numRemoved) |
5370 |
23 Jun 10 |
nicklas |
189 |
{ |
5370 |
23 Jun 10 |
nicklas |
190 |
message = (numRemoved == 0 ? "No" : "Only "+numRemoved+" of "+numTotal) + " items could be deleted, because you have no DELETE permission"; |
5370 |
23 Jun 10 |
nicklas |
191 |
} |
6192 |
31 Oct 12 |
nicklas |
192 |
redirect = listPage; |
5370 |
23 Jun 10 |
nicklas |
193 |
} |
5370 |
23 Jun 10 |
nicklas |
194 |
else if ("RestoreItem".equals(cmd)) |
5370 |
23 Jun 10 |
nicklas |
195 |
{ |
5370 |
23 Jun 10 |
nicklas |
196 |
// Restore a single item and then return to the view page |
7954 |
12 May 21 |
nicklas |
197 |
dc = sc.newDbControl(":Restore "+itemType); |
5370 |
23 Jun 10 |
nicklas |
198 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
5370 |
23 Jun 10 |
nicklas |
199 |
RemovableUtil.setRemoved(dc, itemType, Collections.singleton(cc.getId()), false); |
5370 |
23 Jun 10 |
nicklas |
200 |
dc.commit(); |
5370 |
23 Jun 10 |
nicklas |
201 |
redirect = viewPage; |
5370 |
23 Jun 10 |
nicklas |
202 |
} |
5370 |
23 Jun 10 |
nicklas |
203 |
else if ("RestoreItems".equals(cmd)) |
5370 |
23 Jun 10 |
nicklas |
204 |
{ |
5370 |
23 Jun 10 |
nicklas |
205 |
// Restore all selected items on the list page |
7954 |
12 May 21 |
nicklas |
206 |
dc = sc.newDbControl(":Restore "+itemType); |
5370 |
23 Jun 10 |
nicklas |
207 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
5370 |
23 Jun 10 |
nicklas |
208 |
int numTotal = cc.getSelected().size(); |
5370 |
23 Jun 10 |
nicklas |
209 |
int numRemoved = RemovableUtil.setRemoved(dc, itemType, cc.getSelected(), false); |
5370 |
23 Jun 10 |
nicklas |
210 |
dc.commit(); |
5370 |
23 Jun 10 |
nicklas |
211 |
if (numTotal != numRemoved) |
5370 |
23 Jun 10 |
nicklas |
212 |
{ |
5370 |
23 Jun 10 |
nicklas |
213 |
message = (numRemoved == 0 ? "No" : "Only "+numRemoved+" of "+numTotal) + " items could be restored, because you have no WRITE permission"; |
5370 |
23 Jun 10 |
nicklas |
214 |
} |
6192 |
31 Oct 12 |
nicklas |
215 |
redirect = listPage; |
5370 |
23 Jun 10 |
nicklas |
216 |
} |
5370 |
23 Jun 10 |
nicklas |
217 |
else if ("ShareItem".equals(cmd)) |
5370 |
23 Jun 10 |
nicklas |
218 |
{ |
5370 |
23 Jun 10 |
nicklas |
219 |
// Display a popup window for sharing a single item |
7954 |
12 May 21 |
nicklas |
220 |
dc = sc.newDbControl(":Share "+itemType); |
5370 |
23 Jun 10 |
nicklas |
221 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
5370 |
23 Jun 10 |
nicklas |
222 |
MultiPermissions permissions = ShareableUtil.getMultiPermissions(dc, itemType, Collections.singleton(cc.getId())); |
5370 |
23 Jun 10 |
nicklas |
223 |
dc.close(); |
5370 |
23 Jun 10 |
nicklas |
224 |
cc.setObject("MultiPermissions", permissions); |
5370 |
23 Jun 10 |
nicklas |
225 |
redirect = "../../common/share/share.jsp?ID="+ID+"&item_type="+itemType.name(); |
5370 |
23 Jun 10 |
nicklas |
226 |
} |
5370 |
23 Jun 10 |
nicklas |
227 |
else if ("ShareItems".equals(cmd)) |
5370 |
23 Jun 10 |
nicklas |
228 |
{ |
5370 |
23 Jun 10 |
nicklas |
229 |
// Display a popup window for sharing all selected items on the list page |
7954 |
12 May 21 |
nicklas |
230 |
dc = sc.newDbControl(":Share "+itemType); |
5370 |
23 Jun 10 |
nicklas |
231 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
5370 |
23 Jun 10 |
nicklas |
232 |
MultiPermissions permissions = ShareableUtil.getMultiPermissions(dc, itemType, cc.getSelected()); |
5370 |
23 Jun 10 |
nicklas |
233 |
dc.close(); |
5370 |
23 Jun 10 |
nicklas |
234 |
cc.setObject("MultiPermissions", permissions); |
5370 |
23 Jun 10 |
nicklas |
235 |
redirect = "../../common/share/share.jsp?ID="+ID+"&item_type="+itemType.name(); |
5370 |
23 Jun 10 |
nicklas |
236 |
} |
5370 |
23 Jun 10 |
nicklas |
237 |
else if ("SetOwnerOfItem".equals(cmd)) |
5370 |
23 Jun 10 |
nicklas |
238 |
{ |
5370 |
23 Jun 10 |
nicklas |
239 |
// Change owner of items selected on a list page |
7954 |
12 May 21 |
nicklas |
240 |
dc = sc.newDbControl(":Set owner of "+itemType); |
5370 |
23 Jun 10 |
nicklas |
241 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
5370 |
23 Jun 10 |
nicklas |
242 |
OwnedItem item = (OwnedItem)itemType.getById(dc, cc.getId()); |
5370 |
23 Jun 10 |
nicklas |
243 |
cc.setObject("OwnedItems", Collections.singleton(item)); |
5370 |
23 Jun 10 |
nicklas |
244 |
redirect = "../../common/ownership/ownership.jsp?ID="+ID+"&item_type="+itemType.name(); |
5370 |
23 Jun 10 |
nicklas |
245 |
} |
5370 |
23 Jun 10 |
nicklas |
246 |
else if ("SetOwnerOfItems".equals(cmd)) |
5370 |
23 Jun 10 |
nicklas |
247 |
{ |
5370 |
23 Jun 10 |
nicklas |
248 |
// Change owner of items selected on a list page |
7954 |
12 May 21 |
nicklas |
249 |
dc = sc.newDbControl(":Set owner of "+itemType); |
5370 |
23 Jun 10 |
nicklas |
250 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
5370 |
23 Jun 10 |
nicklas |
251 |
Set<OwnedItem> items = new HashSet<OwnedItem>(); |
5370 |
23 Jun 10 |
nicklas |
252 |
for (Integer id : cc.getSelected()) |
5370 |
23 Jun 10 |
nicklas |
253 |
{ |
5370 |
23 Jun 10 |
nicklas |
254 |
if (id != null) items.add((OwnedItem)itemType.getById(dc, id)); |
5370 |
23 Jun 10 |
nicklas |
255 |
} |
5370 |
23 Jun 10 |
nicklas |
256 |
dc.close(); |
5370 |
23 Jun 10 |
nicklas |
257 |
cc.setObject("OwnedItems", items); |
5370 |
23 Jun 10 |
nicklas |
258 |
redirect = "../../common/ownership/ownership.jsp?ID="+ID+"&item_type="+itemType.name(); |
5370 |
23 Jun 10 |
nicklas |
259 |
} |
5370 |
23 Jun 10 |
nicklas |
260 |
else if ("ExportItems".equals(cmd)) |
5370 |
23 Jun 10 |
nicklas |
261 |
{ |
5370 |
23 Jun 10 |
nicklas |
262 |
// Run an export plugin in a list context |
5370 |
23 Jun 10 |
nicklas |
263 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
5370 |
23 Jun 10 |
nicklas |
264 |
final ItemQuery<PermissionTemplate> query = PermissionTemplate.getQuery(); |
7954 |
12 May 21 |
nicklas |
265 |
dc = sc.newDbControl(":Export "+itemType); |
7914 |
23 Feb 21 |
nicklas |
266 |
JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.list(itemType), null); |
7914 |
23 Feb 21 |
nicklas |
267 |
cc.configureQuery(dc, query, jspContext, true); |
6040 |
30 Mar 12 |
nicklas |
268 |
cc.setQuery(query); |
7604 |
25 Feb 19 |
nicklas |
269 |
ExtensionsInvoker<ListColumnAction<PermissionTemplate,?>> listInvoker = ListColumnUtil.useExtensions(jspContext); |
7604 |
25 Feb 19 |
nicklas |
270 |
listInvoker.render(new ListColumnExportRenderer<PermissionTemplate>(cc)); |
5590 |
16 Mar 11 |
nicklas |
271 |
dc.close(); |
5370 |
23 Jun 10 |
nicklas |
272 |
redirect = "../../common/export/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=LIST&title=Export+permission+templates"; |
5370 |
23 Jun 10 |
nicklas |
273 |
} |
5370 |
23 Jun 10 |
nicklas |
274 |
else if ("ExportItem".equals(cmd)) |
5370 |
23 Jun 10 |
nicklas |
275 |
{ |
5370 |
23 Jun 10 |
nicklas |
276 |
// Run an export plugin in single-item context |
5370 |
23 Jun 10 |
nicklas |
277 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
5370 |
23 Jun 10 |
nicklas |
278 |
redirect = "../../common/export/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&title=Export+permission+template"; |
5370 |
23 Jun 10 |
nicklas |
279 |
} |
5370 |
23 Jun 10 |
nicklas |
280 |
else if ("ImportItems".equals(cmd)) |
5370 |
23 Jun 10 |
nicklas |
281 |
{ |
5370 |
23 Jun 10 |
nicklas |
282 |
// Run an import plugin in a list context |
5370 |
23 Jun 10 |
nicklas |
283 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
5370 |
23 Jun 10 |
nicklas |
284 |
final ItemQuery<PermissionTemplate> query = PermissionTemplate.getQuery(); |
7954 |
12 May 21 |
nicklas |
285 |
dc = sc.newDbControl(":Import "+itemType); |
7914 |
23 Feb 21 |
nicklas |
286 |
JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.list(itemType), null); |
7914 |
23 Feb 21 |
nicklas |
287 |
cc.configureQuery(dc, query, jspContext, true); |
5590 |
16 Mar 11 |
nicklas |
288 |
dc.close(); |
5370 |
23 Jun 10 |
nicklas |
289 |
cc.setQuery(query); |
5370 |
23 Jun 10 |
nicklas |
290 |
redirect = "../../common/import/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=LIST&title=Import+permission+templates"; |
5370 |
23 Jun 10 |
nicklas |
291 |
} |
5370 |
23 Jun 10 |
nicklas |
292 |
else if ("ImportItem".equals(cmd)) |
5370 |
23 Jun 10 |
nicklas |
293 |
{ |
5370 |
23 Jun 10 |
nicklas |
294 |
// Run an import plugin in single-item context |
5370 |
23 Jun 10 |
nicklas |
295 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
5370 |
23 Jun 10 |
nicklas |
296 |
redirect = "../../common/import/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&title=Import+permission+template"; |
5370 |
23 Jun 10 |
nicklas |
297 |
} |
5370 |
23 Jun 10 |
nicklas |
298 |
else if ("RunListPlugin".equals(cmd)) |
5370 |
23 Jun 10 |
nicklas |
299 |
{ |
5370 |
23 Jun 10 |
nicklas |
300 |
// Run another plugin in a list context |
5370 |
23 Jun 10 |
nicklas |
301 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
5370 |
23 Jun 10 |
nicklas |
302 |
final ItemQuery<PermissionTemplate> query = PermissionTemplate.getQuery(); |
7954 |
12 May 21 |
nicklas |
303 |
dc = sc.newDbControl(":Run plugin "+itemType); |
7914 |
23 Feb 21 |
nicklas |
304 |
JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.list(itemType), null); |
7914 |
23 Feb 21 |
nicklas |
305 |
cc.configureQuery(dc, query, jspContext, true); |
5590 |
16 Mar 11 |
nicklas |
306 |
dc.close(); |
5370 |
23 Jun 10 |
nicklas |
307 |
cc.setQuery(query); |
5370 |
23 Jun 10 |
nicklas |
308 |
redirect = "../../common/plugin/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=LIST&main_type=OTHER&title=Run+plugin"; |
5370 |
23 Jun 10 |
nicklas |
309 |
} |
5370 |
23 Jun 10 |
nicklas |
310 |
else if ("RunPlugin".equals(cmd)) |
5370 |
23 Jun 10 |
nicklas |
311 |
{ |
5370 |
23 Jun 10 |
nicklas |
312 |
// Run another plugin in single-item context |
5370 |
23 Jun 10 |
nicklas |
313 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
5370 |
23 Jun 10 |
nicklas |
314 |
redirect = "../../common/plugin/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&main_type=OTHER&title=Run+plugin"; |
5370 |
23 Jun 10 |
nicklas |
315 |
} |
5370 |
23 Jun 10 |
nicklas |
316 |
else |
5370 |
23 Jun 10 |
nicklas |
317 |
{ |
5370 |
23 Jun 10 |
nicklas |
318 |
throw new WebException("popup", "Invalid command", "The command {1} is not recognised as a valid command.", cmd); |
5370 |
23 Jun 10 |
nicklas |
319 |
} |
5370 |
23 Jun 10 |
nicklas |
320 |
} |
5370 |
23 Jun 10 |
nicklas |
321 |
finally |
5370 |
23 Jun 10 |
nicklas |
322 |
{ |
5370 |
23 Jun 10 |
nicklas |
323 |
if (dc != null) dc.close(); |
5370 |
23 Jun 10 |
nicklas |
324 |
} |
5370 |
23 Jun 10 |
nicklas |
325 |
|
5370 |
23 Jun 10 |
nicklas |
326 |
if (forward != null) |
5370 |
23 Jun 10 |
nicklas |
327 |
{ |
6192 |
31 Oct 12 |
nicklas |
328 |
sc.setSessionSetting("alert-message", message); |
5370 |
23 Jun 10 |
nicklas |
329 |
pageContext.forward(forward); |
5370 |
23 Jun 10 |
nicklas |
330 |
} |
5370 |
23 Jun 10 |
nicklas |
331 |
else if (redirect != null) |
5370 |
23 Jun 10 |
nicklas |
332 |
{ |
6192 |
31 Oct 12 |
nicklas |
333 |
sc.setSessionSetting("alert-message", message); |
5370 |
23 Jun 10 |
nicklas |
334 |
response.sendRedirect(redirect); |
5370 |
23 Jun 10 |
nicklas |
335 |
} |
5370 |
23 Jun 10 |
nicklas |
336 |
else if (message == null) |
5370 |
23 Jun 10 |
nicklas |
337 |
{ |
5370 |
23 Jun 10 |
nicklas |
338 |
response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&wait=0"); |
5370 |
23 Jun 10 |
nicklas |
339 |
} |
5370 |
23 Jun 10 |
nicklas |
340 |
else |
5370 |
23 Jun 10 |
nicklas |
341 |
{ |
5370 |
23 Jun 10 |
nicklas |
342 |
response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&message="+HTML.urlEncode(message)); |
5370 |
23 Jun 10 |
nicklas |
343 |
} |
5370 |
23 Jun 10 |
nicklas |
344 |
%> |
5370 |
23 Jun 10 |
nicklas |
345 |
|