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