1 | <%-- $Id: view_plugin.jsp 5425 2010-09-23 13:30:07Z nicklas $ |
---|
2 | ------------------------------------------------------------------ |
---|
3 | Copyright (C) 2006 Jari Häkkinen, Nicklas Nordborg, Martin Svensson |
---|
4 | Copyright (C) 2007 Johan Enell, Martin Svensson |
---|
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 session="false" |
---|
27 | import="net.sf.basedb.core.SessionControl" |
---|
28 | import="net.sf.basedb.core.DbControl" |
---|
29 | import="net.sf.basedb.core.SystemItems" |
---|
30 | import="net.sf.basedb.core.Item" |
---|
31 | import="net.sf.basedb.core.ItemContext" |
---|
32 | import="net.sf.basedb.core.Permission" |
---|
33 | import="net.sf.basedb.core.PluginDefinition" |
---|
34 | import="net.sf.basedb.core.PluginConfiguration" |
---|
35 | import="net.sf.basedb.core.Group" |
---|
36 | import="net.sf.basedb.core.JobAgent" |
---|
37 | import="net.sf.basedb.core.JobAgentSettings" |
---|
38 | import="net.sf.basedb.core.User" |
---|
39 | import="net.sf.basedb.core.Include" |
---|
40 | import="net.sf.basedb.core.ItemQuery" |
---|
41 | import="net.sf.basedb.core.ItemResultIterator" |
---|
42 | import="net.sf.basedb.core.ItemResultList" |
---|
43 | import="net.sf.basedb.core.MultiPermissions" |
---|
44 | import="net.sf.basedb.core.PermissionDeniedException" |
---|
45 | import="net.sf.basedb.core.BaseException" |
---|
46 | import="net.sf.basedb.core.RoleKey" |
---|
47 | import="net.sf.basedb.core.plugin.GuiContext" |
---|
48 | import="net.sf.basedb.core.plugin.Plugin" |
---|
49 | import="net.sf.basedb.core.Project" |
---|
50 | import="net.sf.basedb.core.query.Restrictions" |
---|
51 | import="net.sf.basedb.core.query.Orders" |
---|
52 | import="net.sf.basedb.core.query.Hql" |
---|
53 | import="net.sf.basedb.util.JarClassLoader" |
---|
54 | import="net.sf.basedb.util.ToStringComparator" |
---|
55 | import="net.sf.basedb.clients.web.Base" |
---|
56 | import="net.sf.basedb.clients.web.PermissionUtil" |
---|
57 | import="net.sf.basedb.clients.web.util.HTML" |
---|
58 | import="net.sf.basedb.util.Values" |
---|
59 | import="net.sf.basedb.util.formatter.Formatter" |
---|
60 | import="net.sf.basedb.clients.web.formatter.FormatterFactory" |
---|
61 | import="net.sf.basedb.clients.web.extensions.ExtensionsControl" |
---|
62 | import="net.sf.basedb.clients.web.extensions.JspContext" |
---|
63 | import="net.sf.basedb.clients.web.extensions.renderer.PrefixSuffixRenderer" |
---|
64 | import="net.sf.basedb.clients.web.extensions.toolbar.ToolbarUtil" |
---|
65 | import="net.sf.basedb.util.extensions.ExtensionsInvoker" |
---|
66 | import="java.util.Date" |
---|
67 | import="java.util.Collections" |
---|
68 | import="java.util.List" |
---|
69 | import="java.util.Map" |
---|
70 | import="java.util.Set" |
---|
71 | import="java.util.TreeSet" |
---|
72 | %> |
---|
73 | <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
---|
74 | <%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %> |
---|
75 | <%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %> |
---|
76 | <%@ taglib prefix="p" uri="/WEB-INF/path.tld" %> |
---|
77 | <%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %> |
---|
78 | <%! |
---|
79 | private static final Item itemType = Item.PLUGINDEFINITION; |
---|
80 | private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.ITEM); |
---|
81 | |
---|
82 | private static final String getShortPermissions(Item itemType, Set<Permission> granted, Set<Permission> denied) |
---|
83 | { |
---|
84 | Set<Permission> defined = itemType.getDefinedPermissions(); |
---|
85 | StringBuilder sb = new StringBuilder(); |
---|
86 | if (defined.contains(Permission.CREATE)) sb.append(granted.contains(Permission.CREATE) ? "C" : denied.contains(Permission.CREATE) ? "-" : "c"); |
---|
87 | if (defined.contains(Permission.READ)) sb.append(granted.contains(Permission.READ) ? "R" : denied.contains(Permission.READ) ? "-" : "r"); |
---|
88 | if (defined.contains(Permission.USE)) sb.append(granted.contains(Permission.USE) ? "U" : denied.contains(Permission.USE) ? "-" : "u"); |
---|
89 | if (defined.contains(Permission.WRITE)) sb.append(granted.contains(Permission.WRITE) ? "W" : denied.contains(Permission.WRITE) ? "-" : "w"); |
---|
90 | if (defined.contains(Permission.DELETE)) sb.append(granted.contains(Permission.DELETE) ? "D" : denied.contains(Permission.DELETE) ? "-" : "d"); |
---|
91 | if (defined.contains(Permission.SET_OWNER)) sb.append(granted.contains(Permission.SET_OWNER) ? "O" : denied.contains(Permission.SET_OWNER) ? "-" : "o"); |
---|
92 | if (defined.contains(Permission.SET_PERMISSION)) sb.append(granted.contains(Permission.SET_PERMISSION) ? "P" : denied.contains(Permission.SET_PERMISSION) ? "-" : "p"); |
---|
93 | return sb.toString(); |
---|
94 | } |
---|
95 | %> |
---|
96 | <% |
---|
97 | final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
---|
98 | final String ID = sc.getId(); |
---|
99 | final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null); |
---|
100 | final int itemId = cc.getId(); |
---|
101 | final float scale = Base.getScale(sc); |
---|
102 | final DbControl dc = sc.newDbControl(); |
---|
103 | try |
---|
104 | { |
---|
105 | Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc); |
---|
106 | Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext); |
---|
107 | |
---|
108 | String title = null; |
---|
109 | String warning = null; |
---|
110 | PluginDefinition plugin = PluginDefinition.getById(dc, itemId); |
---|
111 | final boolean internal = plugin.getJarPath() == null; |
---|
112 | final boolean loaded = internal || JarClassLoader.exists(plugin.getJarPath()); |
---|
113 | final boolean usePermissions = plugin.getUsePermissions(); |
---|
114 | final Set<GuiContext> contexts = new TreeSet<GuiContext>(new ToStringComparator<GuiContext>(false)); |
---|
115 | contexts.addAll(plugin.getGuiContexts()); |
---|
116 | |
---|
117 | final boolean usePermission = plugin.hasPermission(Permission.USE); |
---|
118 | final boolean writePermission = plugin.hasPermission(Permission.WRITE); |
---|
119 | final boolean deletePermission = plugin.hasPermission(Permission.DELETE); |
---|
120 | final boolean sharePermission = plugin.hasPermission(Permission.SET_PERMISSION); |
---|
121 | final boolean setOwnerPermission = plugin.hasPermission(Permission.SET_OWNER); |
---|
122 | final boolean isRemoved = plugin.isRemoved(); |
---|
123 | final boolean isUsed = isRemoved && plugin.isUsed(); |
---|
124 | final boolean deletePermanentlyPermission = deletePermission && !isUsed; |
---|
125 | final boolean isOwner = plugin.isOwner(); |
---|
126 | |
---|
127 | try |
---|
128 | { |
---|
129 | Plugin thePlugin = plugin.newInstance(Plugin.class, null, sc, null, null); |
---|
130 | } |
---|
131 | catch (BaseException ex) |
---|
132 | { |
---|
133 | warning = ex.getMessage(); |
---|
134 | } |
---|
135 | JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, guiContext, plugin); |
---|
136 | ExtensionsInvoker invoker = ToolbarUtil.useExtensions(jspContext); |
---|
137 | %> |
---|
138 | <base:page title="<%=title%>"> |
---|
139 | <base:head scripts="tabcontrol.js,table.js" styles="toolbar.css,headertabcontrol.css,path.css,table.css"> |
---|
140 | <ext:scripts context="<%=jspContext%>" /> |
---|
141 | <ext:stylesheets context="<%=jspContext%>" /> |
---|
142 | <script language="JavaScript"> |
---|
143 | function editItem() |
---|
144 | { |
---|
145 | Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>, true); |
---|
146 | } |
---|
147 | function shareItem() |
---|
148 | { |
---|
149 | Main.openPopup('index.jsp?ID=<%=ID%>&cmd=ShareItem&item_id=<%=itemId%>', 'SharePlugin', 600, 400); |
---|
150 | } |
---|
151 | function deleteItem() |
---|
152 | { |
---|
153 | location.replace('index.jsp?ID=<%=ID%>&cmd=DeleteItem&item_id=<%=itemId%>'); |
---|
154 | } |
---|
155 | function restoreItem() |
---|
156 | { |
---|
157 | location.replace('index.jsp?ID=<%=ID%>&cmd=RestoreItem&item_id=<%=itemId%>'); |
---|
158 | } |
---|
159 | function deleteItemPermanently() |
---|
160 | { |
---|
161 | Main.deleteItemPermanently('<%=ID%>', true, '<%=itemType.name()%>', <%=itemId%>, '&callback=itemDeleted'); |
---|
162 | } |
---|
163 | function itemDeleted() |
---|
164 | { |
---|
165 | Main.listItems('<%=ID%>', '<%=itemType.name()%>'); |
---|
166 | } |
---|
167 | function showUsingItems() |
---|
168 | { |
---|
169 | Main.showUsingItems('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>); |
---|
170 | } |
---|
171 | function setOwner() |
---|
172 | { |
---|
173 | Main.openPopup('index.jsp?ID=<%=ID%>&cmd=SetOwnerOfItem&item_id=<%=itemId%>', 'SetOwnerOfItem', 450, 150); |
---|
174 | } |
---|
175 | function runPlugin(cmd) |
---|
176 | { |
---|
177 | Main.openPopup('index.jsp?ID=<%=ID%>&cmd='+cmd+'&item_id=<%=itemId%>', 'RunPlugin'+cmd, 740, 540); |
---|
178 | } |
---|
179 | function unloadPlugin() |
---|
180 | { |
---|
181 | location.replace('index.jsp?ID=<%=ID%>&cmd=UnloadItem&item_id=<%=itemId%>'); |
---|
182 | } |
---|
183 | function newConfiguration() |
---|
184 | { |
---|
185 | Main.viewOrEditItem('<%=ID%>', 'PLUGINCONFIGURATION', 0, true, '&plugindefinition_id=<%=itemId%>'); |
---|
186 | } |
---|
187 | function configurePlugin(itemId) |
---|
188 | { |
---|
189 | Main.openPopup('../../common/plugin/index.jsp?ID=<%=ID%>&cmd=ConfigurePlugin&pluginconfiguration_id='+itemId, 'ConfigurePlugin', 800, 600); |
---|
190 | } |
---|
191 | function configureAgent(agentId) |
---|
192 | { |
---|
193 | Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>, true, '&jobagent_id='+agentId); |
---|
194 | } |
---|
195 | </script> |
---|
196 | </base:head> |
---|
197 | <base:body> |
---|
198 | <p> |
---|
199 | <p:path> |
---|
200 | <p:pathelement title="Plugins" href="<%="index.jsp?ID="+ID%>" /> |
---|
201 | <p:pathelement title="<%=HTML.encodeTags(plugin.getName())%>" /> |
---|
202 | </p:path> |
---|
203 | |
---|
204 | <t:tabcontrol id="main" active="properties"> |
---|
205 | <t:tab id="properties" title="Properties"> |
---|
206 | <tbl:toolbar |
---|
207 | > |
---|
208 | <tbl:button |
---|
209 | disabled="<%=writePermission ? false : true%>" |
---|
210 | image="<%=writePermission ? "edit.gif" : "edit_disabled.gif"%>" |
---|
211 | onclick="editItem()" |
---|
212 | title="Edit…" |
---|
213 | tooltip="<%=writePermission ? "Edit this plugin" : "You do not have permission to edit this plugin"%>" |
---|
214 | /> |
---|
215 | <tbl:button |
---|
216 | disabled="<%=deletePermission ? false : true%>" |
---|
217 | image="<%=deletePermission ? "delete.gif" : "delete_disabled.gif"%>" |
---|
218 | onclick="deleteItem()" |
---|
219 | title="Delete" |
---|
220 | visible="<%=!plugin.isRemoved()%>" |
---|
221 | tooltip="<%=deletePermission ? "Delete this plugin" : "You do not have permission to delete this plugin"%>" |
---|
222 | /> |
---|
223 | <tbl:button |
---|
224 | disabled="<%=writePermission ? false : true%>" |
---|
225 | image="<%=writePermission ? "restore.gif" : "restore_disabled.gif"%>" |
---|
226 | onclick="restoreItem()" |
---|
227 | title="Restore" |
---|
228 | visible="<%=plugin.isRemoved()%>" |
---|
229 | tooltip="<%=writePermission ? "Restore this plugin" : "You do not have permission to restore this plugin"%>" |
---|
230 | /> |
---|
231 | <tbl:button |
---|
232 | disabled="<%=sharePermission ? false : true%>" |
---|
233 | image="<%=sharePermission ? "share.gif" : "share_disabled.gif"%>" |
---|
234 | onclick="shareItem()" |
---|
235 | title="Share…" |
---|
236 | tooltip="<%=sharePermission ? "Share this plugin to other user, groups and projects" : "You do not have permission to share this plugin"%>" |
---|
237 | /> |
---|
238 | <tbl:button |
---|
239 | disabled="<%=setOwnerPermission ? false : true%>" |
---|
240 | image="<%=setOwnerPermission ? "take_ownership.png" : "take_ownership_disabled.png"%>" |
---|
241 | onclick="setOwner()" |
---|
242 | title="Set owner…" |
---|
243 | tooltip="<%=setOwnerPermission ? "Change owner of this item" : "You do not have permission to change ownership of this item"%>" |
---|
244 | /> |
---|
245 | <tbl:button |
---|
246 | image="add.png" |
---|
247 | onclick="newConfiguration()" |
---|
248 | title="New configuration…" |
---|
249 | tooltip="Create a new configuration for this plugin" |
---|
250 | visible="<%=sc.hasPermission(Permission.CREATE, Item.PLUGINCONFIGURATION) && |
---|
251 | usePermission && plugin.supportsConfigurations()%>" |
---|
252 | /> |
---|
253 | <tbl:button |
---|
254 | image="import.gif" |
---|
255 | onclick="runPlugin('ImportItem')" |
---|
256 | title="Import…" |
---|
257 | tooltip="Import data" |
---|
258 | visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>" |
---|
259 | /> |
---|
260 | <tbl:button |
---|
261 | image="export.gif" |
---|
262 | onclick="runPlugin('ExportItem')" |
---|
263 | title="Export…" |
---|
264 | tooltip="Export data" |
---|
265 | visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>" |
---|
266 | /> |
---|
267 | <tbl:button |
---|
268 | image="runplugin.gif" |
---|
269 | onclick="runPlugin('RunPlugin')" |
---|
270 | title="Run plugin…" |
---|
271 | tooltip="Run a plugin" |
---|
272 | visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>" |
---|
273 | /> |
---|
274 | <tbl:button |
---|
275 | onclick="unloadPlugin()" |
---|
276 | title="Unload" |
---|
277 | tooltip="<%=loaded && !internal ? "Unload the code for this plugin" : "The code for this plugin has not yet been loaded" %>" |
---|
278 | visible="<%=loaded && !internal%>" |
---|
279 | /> |
---|
280 | <ext:render extensions="<%=invoker%>" context="<%=jspContext%>" |
---|
281 | wrapper="<%=new PrefixSuffixRenderer(jspContext, "<td>", "</td>") %>"/> |
---|
282 | <tbl:button |
---|
283 | image="help.gif" |
---|
284 | onclick="<%="Main.openHelp('" + ID +"', 'plugindefinition.view.properties')"%>" |
---|
285 | title="Help…" |
---|
286 | tooltip="Get help about this page" |
---|
287 | /> |
---|
288 | </tbl:toolbar> |
---|
289 | <div class="boxedbottom"> |
---|
290 | <div class="itemstatus">Permissions on this item: <i><%=PermissionUtil.getFullPermissionNames(plugin)%></i></div> |
---|
291 | <% |
---|
292 | if (plugin.isRemoved() || plugin.isShared()) |
---|
293 | { |
---|
294 | %> |
---|
295 | <div class="itemstatus"> |
---|
296 | <base:icon |
---|
297 | image="<%=deletePermanentlyPermission ? "deleted.gif" : "deleted_disabled.gif"%>" |
---|
298 | onclick="<%=deletePermanentlyPermission ? "deleteItemPermanently()" : null%>" |
---|
299 | tooltip="<%=deletePermanentlyPermission ? "Permanently delete this item" : null%>" |
---|
300 | visible="<%=isRemoved%>"> This item has been flagged for deletion<br></base:icon> |
---|
301 | <base:icon image="used.gif" |
---|
302 | onclick="showUsingItems()" |
---|
303 | tooltip="Show the items that are using this one" |
---|
304 | visible="<%=isUsed%>"> This item is used by other items and can't be permanently deleted<br></base:icon> |
---|
305 | <base:icon image="shared.gif" |
---|
306 | visible="<%=plugin.isShared()%>"> This item is shared to other users, groups and/or projects</base:icon> |
---|
307 | </div> |
---|
308 | <% |
---|
309 | } |
---|
310 | %> |
---|
311 | <% |
---|
312 | if (warning != null) |
---|
313 | { |
---|
314 | %> |
---|
315 | <div class="error"><%=warning%></div> |
---|
316 | <% |
---|
317 | } |
---|
318 | %> |
---|
319 | <table class="form" cellspacing="0"> |
---|
320 | <tr> |
---|
321 | <td class="prompt">Name</td> |
---|
322 | <td><%=HTML.encodeTags(plugin.getName())%></td> |
---|
323 | </tr> |
---|
324 | <tr> |
---|
325 | <td class="prompt">Registered</td> |
---|
326 | <td><%=dateFormatter.format(plugin.getEntryDate())%></td> |
---|
327 | </tr> |
---|
328 | <tr> |
---|
329 | <td class="prompt">Type</td> |
---|
330 | <td><%=plugin.getMainType()%></td> |
---|
331 | </tr> |
---|
332 | <tr> |
---|
333 | <td class="prompt">Class</td> |
---|
334 | <td><%=plugin.getClassName()%></td> |
---|
335 | </tr> |
---|
336 | <tr> |
---|
337 | <td class="prompt">Jar path</td> |
---|
338 | <td><%=plugin.getJarPath() == null ? "<i>- internal -</i>" : plugin.getJarPath()%></td> |
---|
339 | </tr> |
---|
340 | <tr> |
---|
341 | <td class="prompt">Version</td> |
---|
342 | <td><%=plugin.getVersionString()%></td> |
---|
343 | </tr> |
---|
344 | <tr> |
---|
345 | <td class="prompt">Max memory</td> |
---|
346 | <td><%=Values.formatBytes(plugin.getMaxMemory())%></td> |
---|
347 | </tr> |
---|
348 | <tr> |
---|
349 | <td class="prompt">Trusted</td> |
---|
350 | <td><%=plugin.isTrusted() ? "yes" : "no"%></td> |
---|
351 | </tr> |
---|
352 | <tr> |
---|
353 | <td class="prompt">Allow immediate execution</td> |
---|
354 | <td><%=plugin.getAllowImmediateExecution() ? "yes" : "no"%></td> |
---|
355 | </tr> |
---|
356 | <tr> |
---|
357 | <td class="prompt">Use internal job queue</td> |
---|
358 | <td><%=plugin.getUseInternalJobQueue() ? "yes" : "no"%></td> |
---|
359 | </tr> |
---|
360 | <tr> |
---|
361 | <td class="prompt" valign="baseline">Items</td> |
---|
362 | <td><%=Values.getString(contexts, ", ", true)%></td> |
---|
363 | </tr> |
---|
364 | <tr> |
---|
365 | <td class="prompt">Contact</td> |
---|
366 | <td><%=HTML.encodeTags(plugin.getContact())%></td> |
---|
367 | </tr> |
---|
368 | <tr> |
---|
369 | <td class="prompt">Copyright</td> |
---|
370 | <td><%=HTML.encodeTags(plugin.getCopyright())%></td> |
---|
371 | </tr> |
---|
372 | <tr> |
---|
373 | <td class="prompt">Email</td> |
---|
374 | <td><%=HTML.scanForLinks(plugin.getEmail(), HTML.LINK_EMAIL, "_new")%></td> |
---|
375 | </tr> |
---|
376 | <tr> |
---|
377 | <td class="prompt">Url</td> |
---|
378 | <td><%=HTML.scanForLinks(plugin.getUrl(), HTML.LINK_URL, "_new")%></td> |
---|
379 | </tr> |
---|
380 | <tr> |
---|
381 | <td class="prompt">Owner</td> |
---|
382 | <td><base:propertyvalue item="<%=plugin%>" property="owner" /></td> |
---|
383 | </tr> |
---|
384 | <tr valign="top"> |
---|
385 | <td class="prompt">Description</td> |
---|
386 | <td><%=HTML.niceFormat(plugin.getDescription())%></td> |
---|
387 | </tr> |
---|
388 | </table> |
---|
389 | <% |
---|
390 | ItemQuery<PluginConfiguration> configQuery = plugin.getPluginConfigurations(); |
---|
391 | configQuery.include(Include.ALL); |
---|
392 | configQuery.order(Orders.asc(Hql.property("name"))); |
---|
393 | ItemResultList<PluginConfiguration> configurations = configQuery.list(dc); |
---|
394 | |
---|
395 | if (configurations.size() == 0) |
---|
396 | { |
---|
397 | if (plugin.supportsConfigurations()) |
---|
398 | { |
---|
399 | %> |
---|
400 | <h4>Configurations</h4> |
---|
401 | There are no configurations for this plugin (or, you don't have permission to view them). |
---|
402 | <% |
---|
403 | } |
---|
404 | } |
---|
405 | else |
---|
406 | { |
---|
407 | %> |
---|
408 | <base:section |
---|
409 | id="configurations" |
---|
410 | title="<%="Configurations (" + configurations.size() + ")" %>" |
---|
411 | context="<%=cc%>" |
---|
412 | > |
---|
413 | <tbl:table |
---|
414 | id="configurations" |
---|
415 | clazz="itemlist" |
---|
416 | columns="all" |
---|
417 | > |
---|
418 | <tbl:columndef |
---|
419 | id="name" |
---|
420 | title="Name" |
---|
421 | /> |
---|
422 | <tbl:columndef |
---|
423 | id="description" |
---|
424 | title="Description" |
---|
425 | /> |
---|
426 | <tbl:columndef |
---|
427 | id="configure" |
---|
428 | title="Configure" |
---|
429 | show="<%=plugin.supportsConfigurations() ? "always" : "never" %>" |
---|
430 | /> |
---|
431 | <tbl:data> |
---|
432 | <tbl:columns> |
---|
433 | </tbl:columns> |
---|
434 | <tbl:rows> |
---|
435 | <% |
---|
436 | for (PluginConfiguration pc : configurations) |
---|
437 | { |
---|
438 | %> |
---|
439 | <tbl:row> |
---|
440 | <tbl:cell column="name"><base:icon |
---|
441 | image="deleted.gif" |
---|
442 | tooltip="This item has been scheduled for deletion" |
---|
443 | visible="<%=pc.isRemoved()%>" |
---|
444 | /><%=Base.getLinkedName(ID, pc, false, true)%></tbl:cell> |
---|
445 | <tbl:cell column="description"><%=HTML.niceFormat(pc.getDescription())%></tbl:cell> |
---|
446 | <tbl:cell column="configure"> |
---|
447 | <% |
---|
448 | if (pc.hasPermission(Permission.WRITE)) |
---|
449 | { |
---|
450 | %> |
---|
451 | <base:icon image="runplugin.gif" |
---|
452 | onclick="<%="configurePlugin(" + pc.getId() + ")"%>" |
---|
453 | tooltip="Configure this plugin "/> |
---|
454 | <% |
---|
455 | } |
---|
456 | %> |
---|
457 | </tbl:cell> |
---|
458 | </tbl:row> |
---|
459 | <% |
---|
460 | } |
---|
461 | %> |
---|
462 | </tbl:rows> |
---|
463 | </tbl:data> |
---|
464 | </tbl:table> |
---|
465 | </base:section> |
---|
466 | <% |
---|
467 | } |
---|
468 | %> |
---|
469 | |
---|
470 | <% |
---|
471 | ItemQuery<JobAgent> agentQuery = JobAgent.getQuery(); |
---|
472 | agentQuery.include(Include.ALL); |
---|
473 | agentQuery.order(Orders.asc(Hql.property("name"))); |
---|
474 | agentQuery.join(Hql.innerJoin("plugins", "p")); |
---|
475 | agentQuery.restrict(Restrictions.eq(Hql.property("p", "pluginDefinition"), Hql.entity(plugin))); |
---|
476 | ItemResultList<JobAgent> agents = agentQuery.list(dc); |
---|
477 | |
---|
478 | if (agents.size() == 0) |
---|
479 | { |
---|
480 | %> |
---|
481 | <h4>Installed on job agents</h4> |
---|
482 | This plugin isn't installed on any job agents (or, you don't have permission to view them). |
---|
483 | <% |
---|
484 | } |
---|
485 | else |
---|
486 | { |
---|
487 | %> |
---|
488 | <base:section |
---|
489 | id="jobagents" |
---|
490 | title="<%="Installed on job agents (" + agents.size() + ")" %>" |
---|
491 | context="<%=cc%>" |
---|
492 | > |
---|
493 | <tbl:table |
---|
494 | id="agents" |
---|
495 | clazz="itemlist" |
---|
496 | columns="all" |
---|
497 | > |
---|
498 | <tbl:columndef |
---|
499 | id="name" |
---|
500 | title="Name" |
---|
501 | /> |
---|
502 | <tbl:columndef |
---|
503 | id="server" |
---|
504 | title="Server" |
---|
505 | /> |
---|
506 | <tbl:columndef |
---|
507 | id="info" |
---|
508 | title="CPU/Memory" |
---|
509 | /> |
---|
510 | <tbl:columndef |
---|
511 | id="jarPath" |
---|
512 | title="JAR path" |
---|
513 | /> |
---|
514 | <tbl:columndef |
---|
515 | id="maxMemory" |
---|
516 | title="Max memory" |
---|
517 | /> |
---|
518 | <tbl:columndef |
---|
519 | id="trusted" |
---|
520 | title="Trusted" |
---|
521 | /> |
---|
522 | <tbl:columndef |
---|
523 | id="priorityBoost" |
---|
524 | title="Priority boost" |
---|
525 | /> |
---|
526 | <tbl:columndef |
---|
527 | id="configure" |
---|
528 | title="" |
---|
529 | /> |
---|
530 | <tbl:data> |
---|
531 | <tbl:columns> |
---|
532 | </tbl:columns> |
---|
533 | <tbl:rows> |
---|
534 | <% |
---|
535 | for (JobAgent agent : agents) |
---|
536 | { |
---|
537 | String server = agent.getServer(); |
---|
538 | Integer port = agent.getPort(); |
---|
539 | JobAgentSettings settings = agent.getSettings(plugin, false); |
---|
540 | Long maxMemory = settings.getEffectiveMaxMemory(); |
---|
541 | String jarPath = settings.getEffectiveJarPath(); |
---|
542 | %> |
---|
543 | <tbl:row> |
---|
544 | <tbl:cell column="name"><base:icon |
---|
545 | image="deleted.gif" |
---|
546 | tooltip="This item has been scheduled for deletion" |
---|
547 | visible="<%=agent.isRemoved()%>" |
---|
548 | /><%=Base.getLinkedName(ID, agent, false, true)%></tbl:cell> |
---|
549 | <tbl:cell column="server"><%=server == null || port == null ? "" : server + ":" + port%></tbl:cell> |
---|
550 | <tbl:cell column="info"> |
---|
551 | CPU usage: <%=agent.getCpuUsage() == null ? "<i>- unknown -</i>" : agent.getCpuUsage()+"%" %><br> |
---|
552 | Total memory: <%=agent.getTotalMemory() == null ? "<i>- unknown -</i>" : Values.formatBytes(agent.getTotalMemory()) %><br> |
---|
553 | Used memory: <%=agent.getUsedMemory() == null ? "<i>- unknown -</i>" : Values.formatBytes(agent.getUsedMemory()) %> |
---|
554 | </tbl:cell> |
---|
555 | <tbl:cell column="jarPath"><%=jarPath == null ? "<i>- internal -</i>" : HTML.encodeTags(jarPath)%></tbl:cell> |
---|
556 | <tbl:cell column="maxMemory"><%=maxMemory == null ? "<i>- not specified -</i>" : Values.formatBytes(maxMemory)%></tbl:cell> |
---|
557 | <tbl:cell column="trusted"><%=settings.isEffectivelyTrusted()%></tbl:cell> |
---|
558 | <tbl:cell column="priorityBoost"><%=settings.getPriorityBoost()%></tbl:cell> |
---|
559 | <tbl:cell column="configure"> |
---|
560 | <% |
---|
561 | if (agent.hasPermission(Permission.WRITE)) |
---|
562 | { |
---|
563 | %> |
---|
564 | <base:icon image="runplugin.gif" |
---|
565 | onclick="<%="configureAgent(" + agent.getId() + ")"%>" |
---|
566 | tooltip="Configure the settings for this plugin on the job agent "/> |
---|
567 | <% |
---|
568 | } |
---|
569 | %> |
---|
570 | </tbl:cell> |
---|
571 | </tbl:row> |
---|
572 | <% |
---|
573 | } |
---|
574 | %> |
---|
575 | </tbl:rows> |
---|
576 | </tbl:data> |
---|
577 | </tbl:table> |
---|
578 | </base:section> |
---|
579 | <% |
---|
580 | } |
---|
581 | |
---|
582 | // Tables with users/groups/projects that this item is shared to |
---|
583 | MultiPermissions mp = new MultiPermissions(Collections.singleton(plugin)); |
---|
584 | List<User> users = mp.getUsers().list(dc); |
---|
585 | List<Group> groups = mp.getGroups().list(dc); |
---|
586 | List<Project> projects = mp.getProjects().list(dc); |
---|
587 | int totalShare = users.size() + groups.size() + projects.size(); |
---|
588 | if (totalShare > 0) |
---|
589 | { |
---|
590 | %> |
---|
591 | <base:section |
---|
592 | id="sharedTo" |
---|
593 | title="<%="Shared to (" + totalShare + ")"%>" |
---|
594 | context="<%=cc%>" |
---|
595 | > |
---|
596 | <tbl:table |
---|
597 | id="itemsSharedTo" |
---|
598 | clazz="itemlist" |
---|
599 | columns="all" |
---|
600 | > |
---|
601 | <tbl:columndef |
---|
602 | id="itemType" |
---|
603 | title="Item type" |
---|
604 | /> |
---|
605 | <tbl:columndef |
---|
606 | id="name" |
---|
607 | title="Name" |
---|
608 | /> |
---|
609 | <tbl:columndef |
---|
610 | id="permissions" |
---|
611 | title="Permissions" |
---|
612 | /> |
---|
613 | <tbl:data> |
---|
614 | <tbl:columns> |
---|
615 | </tbl:columns> |
---|
616 | <tbl:rows> |
---|
617 | <% |
---|
618 | for (Project project : projects) |
---|
619 | { |
---|
620 | Set<Permission> permissions = mp.getPermissions(project).values().iterator().next(); |
---|
621 | %> |
---|
622 | <tbl:row> |
---|
623 | <tbl:cell column="itemType"><%=project.getType()%></tbl:cell> |
---|
624 | <tbl:cell column="name"><base:icon |
---|
625 | image="deleted.gif" |
---|
626 | tooltip="This item has been scheduled for deletion" |
---|
627 | visible="<%=project.isRemoved()%>" |
---|
628 | /><%=Base.getLinkedName(ID, project, false, true)%></tbl:cell> |
---|
629 | <tbl:cell column="permissions"> |
---|
630 | <%=PermissionUtil.translatePermissionsToString(permissions)%> |
---|
631 | </tbl:cell> |
---|
632 | </tbl:row> |
---|
633 | <% |
---|
634 | } |
---|
635 | for (Group group : groups) |
---|
636 | { |
---|
637 | Set<Permission> permissions = mp.getPermissions(group).values().iterator().next(); |
---|
638 | %> |
---|
639 | <tbl:row> |
---|
640 | <tbl:cell column="itemType"><%=group.getType()%></tbl:cell> |
---|
641 | <tbl:cell column="name"><base:icon |
---|
642 | image="deleted.gif" |
---|
643 | tooltip="This item has been scheduled for deletion" |
---|
644 | visible="<%=group.isRemoved()%>" |
---|
645 | /><%=Base.getLinkedName(ID, group, false, true)%></tbl:cell> |
---|
646 | <tbl:cell column="permissions"> |
---|
647 | <%=PermissionUtil.translatePermissionsToString(permissions)%> |
---|
648 | </tbl:cell> |
---|
649 | </tbl:row> |
---|
650 | <% |
---|
651 | } |
---|
652 | for (User user : users) |
---|
653 | { |
---|
654 | Set<Permission> permissions = mp.getPermissions(user).values().iterator().next(); |
---|
655 | %> |
---|
656 | <tbl:row> |
---|
657 | <tbl:cell column="itemType"><%=user.getType()%></tbl:cell> |
---|
658 | <tbl:cell column="name"><base:icon |
---|
659 | image="deleted.gif" |
---|
660 | tooltip="This item has been scheduled for deletion" |
---|
661 | visible="<%=user.isRemoved()%>" |
---|
662 | /><%=Base.getLinkedName(ID, user, false, true)%></tbl:cell> |
---|
663 | <tbl:cell column="permissions"> |
---|
664 | <%=PermissionUtil.translatePermissionsToString(permissions)%> |
---|
665 | </tbl:cell> |
---|
666 | </tbl:row> |
---|
667 | <% |
---|
668 | } |
---|
669 | %> |
---|
670 | </tbl:rows> |
---|
671 | </tbl:data> |
---|
672 | </tbl:table> |
---|
673 | </base:section> |
---|
674 | <% |
---|
675 | } |
---|
676 | else |
---|
677 | { |
---|
678 | %> |
---|
679 | <h4>Shared to</h4> |
---|
680 | This plugin is not shared |
---|
681 | (or, you don't have permission to view the ones it is shared to). |
---|
682 | <% |
---|
683 | } |
---|
684 | %> |
---|
685 | <br> |
---|
686 | <base:section |
---|
687 | id="permissions" |
---|
688 | title="<%="Permissions (using permissions: " + (usePermissions ? "yes" : "no") + ")" %>" |
---|
689 | context="<%=cc%>" |
---|
690 | > |
---|
691 | <div class="itemlist"> |
---|
692 | <div class="data"> |
---|
693 | <table border="0" cellspacing="0" cellpadding="0"> |
---|
694 | <tr> |
---|
695 | <% |
---|
696 | Map<String, List<Item>> permissionGroups = PermissionUtil.getPermissionGroups(); |
---|
697 | |
---|
698 | for (String name : permissionGroups.keySet()) |
---|
699 | { |
---|
700 | %> |
---|
701 | <th class="columnheader" colspan="2"><b><%=name%></b></th> |
---|
702 | <% |
---|
703 | } |
---|
704 | %> |
---|
705 | </tr> |
---|
706 | <% |
---|
707 | int newItems = 0; |
---|
708 | int index = 0; |
---|
709 | int i = 0; |
---|
710 | do |
---|
711 | { |
---|
712 | newItems = 0; |
---|
713 | StringBuilder sb = new StringBuilder(); |
---|
714 | sb.append("<tr valign=\"top\""); |
---|
715 | sb.append(" class=\"").append(i == 1 ? "oddrow" : "evenrow").append("\""); |
---|
716 | sb.append(">"); |
---|
717 | for (String name : permissionGroups.keySet()) |
---|
718 | { |
---|
719 | List<Item> items = permissionGroups.get(name); |
---|
720 | if (items.size() > index) |
---|
721 | { |
---|
722 | newItems++; |
---|
723 | Item item = items.get(index); |
---|
724 | int keyId = SystemItems.getRoleKeyId(item); |
---|
725 | RoleKey key = RoleKey.getById(dc, keyId); |
---|
726 | |
---|
727 | sb.append("<td class=\"cell\"><b>").append(key.getName()).append("</b></td>"); |
---|
728 | sb.append("<td class=\"cell\">"); |
---|
729 | |
---|
730 | if (keyId != 0) |
---|
731 | { |
---|
732 | Set<Permission> granted = plugin.getGranted(key); |
---|
733 | Set<Permission> denied = plugin.getDenied(key); |
---|
734 | sb.append(getShortPermissions(item, granted, denied)); |
---|
735 | } |
---|
736 | else |
---|
737 | { |
---|
738 | sb.append("(undefined key)"); |
---|
739 | } |
---|
740 | sb.append("</td>"); |
---|
741 | } |
---|
742 | else |
---|
743 | { |
---|
744 | sb.append("<td class=\"cell\" colspan=\"2\"> </td>"); |
---|
745 | } |
---|
746 | } |
---|
747 | if (newItems > 0) |
---|
748 | { |
---|
749 | %> |
---|
750 | <%=sb.toString()%> |
---|
751 | <% |
---|
752 | } |
---|
753 | i = 1 - i; |
---|
754 | index++; |
---|
755 | } while (newItems > 0); |
---|
756 | %> |
---|
757 | <tr class="panel"> |
---|
758 | <td colspan="99" class="panel"> |
---|
759 | Capital letters = Permission is always granted, Small letters = Permission is only granted if logged in user |
---|
760 | has that permission<br> |
---|
761 | <b>C/c</b> = Create, <b>R/r</b> = Read, <b>U/u</b> = Use, |
---|
762 | <b>W/w</b> = Write, <b>D/d</b> = Delete, <b>O/o</b> = Change owner, |
---|
763 | <b>P/p</b> = Change permissions |
---|
764 | </td> |
---|
765 | </tr> |
---|
766 | </table> |
---|
767 | </div> |
---|
768 | </div> |
---|
769 | </base:section> |
---|
770 | |
---|
771 | </div> |
---|
772 | </t:tab> |
---|
773 | |
---|
774 | <t:tab id="annotations" title="Annotations" |
---|
775 | tooltip="View annotation values" |
---|
776 | visible="<%=!plugin.requiresConfiguration() && plugin.supports("net.sf.basedb.core.plugin.AnnotationSetterPlugin") %>"> |
---|
777 | <div class="boxed"> |
---|
778 | <jsp:include page="../../common/annotations/list_annotations.jsp"> |
---|
779 | <jsp:param name="item_type" value="<%=itemType.name()%>" /> |
---|
780 | <jsp:param name="item_id" value="<%=itemId%>" /> |
---|
781 | <jsp:param name="ID" value="<%=ID%>" /> |
---|
782 | </jsp:include> |
---|
783 | </div> |
---|
784 | </t:tab> |
---|
785 | </t:tabcontrol> |
---|
786 | |
---|
787 | </base:body> |
---|
788 | </base:page> |
---|
789 | <% |
---|
790 | } |
---|
791 | finally |
---|
792 | { |
---|
793 | if (dc != null) dc.close(); |
---|
794 | } |
---|
795 | |
---|
796 | %> |
---|