1 | <%-- $Id: view_plugin.jsp 6592 2014-11-12 12:58:23Z 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 pageEncoding="UTF-8" session="false" |
---|
27 | import="net.sf.basedb.core.SessionControl" |
---|
28 | import="net.sf.basedb.core.DbControl" |
---|
29 | import="net.sf.basedb.core.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 boolean iFrame = Values.getBoolean(request.getParameter("iframe")); |
---|
98 | final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
---|
99 | final String ID = sc.getId(); |
---|
100 | final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null); |
---|
101 | final int itemId = cc.getId(); |
---|
102 | final String tab = Values.getStringOrNull(request.getParameter("tab")); |
---|
103 | final float scale = Base.getScale(sc); |
---|
104 | final DbControl dc = sc.newDbControl(); |
---|
105 | try |
---|
106 | { |
---|
107 | Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc); |
---|
108 | Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext); |
---|
109 | |
---|
110 | String title = null; |
---|
111 | String warning = null; |
---|
112 | PluginDefinition plugin = PluginDefinition.getById(dc, itemId); |
---|
113 | final boolean internal = plugin.getJarFile() == null; |
---|
114 | final boolean loaded = internal || JarClassLoader.exists(plugin.getJarPath()); |
---|
115 | final boolean usePermissions = plugin.getUsePermissions(); |
---|
116 | final Set<GuiContext> contexts = new TreeSet<GuiContext>(new ToStringComparator<GuiContext>(false)); |
---|
117 | contexts.addAll(plugin.getGuiContexts()); |
---|
118 | |
---|
119 | final boolean usePermission = plugin.hasPermission(Permission.USE); |
---|
120 | final boolean writePermission = plugin.hasPermission(Permission.WRITE); |
---|
121 | final boolean deletePermission = plugin.hasPermission(Permission.DELETE); |
---|
122 | final boolean sharePermission = plugin.hasPermission(Permission.SET_PERMISSION); |
---|
123 | final boolean setOwnerPermission = plugin.hasPermission(Permission.SET_OWNER); |
---|
124 | final boolean isRemoved = plugin.isRemoved(); |
---|
125 | final boolean isUsed = isRemoved && plugin.isUsed(); |
---|
126 | final boolean deletePermanentlyPermission = deletePermission && !isUsed; |
---|
127 | final boolean isOwner = plugin.isOwner(); |
---|
128 | |
---|
129 | try |
---|
130 | { |
---|
131 | if (plugin.isDisabled()) |
---|
132 | { |
---|
133 | warning = "This plugin is disabled"; |
---|
134 | } |
---|
135 | else |
---|
136 | { |
---|
137 | plugin.newInstance(Plugin.class, sc, null, null); |
---|
138 | } |
---|
139 | } |
---|
140 | catch (RuntimeException ex) |
---|
141 | { |
---|
142 | warning = ex.getMessage(); |
---|
143 | } |
---|
144 | JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, guiContext, plugin); |
---|
145 | ExtensionsInvoker invoker = ToolbarUtil.useExtensions(jspContext); |
---|
146 | %> |
---|
147 | <base:page title="<%=title%>" type="<%=iFrame ? "iframe" : "default" %>" id="view-page"> |
---|
148 | <base:head scripts="tabcontrol-2.js,table.js,~plugins.js" styles="toolbar.css,headertabcontrol.css,path.css,table.css"> |
---|
149 | <ext:scripts context="<%=jspContext%>" /> |
---|
150 | <ext:stylesheets context="<%=jspContext%>" /> |
---|
151 | </base:head> |
---|
152 | <base:body> |
---|
153 | <% |
---|
154 | if (!iFrame) |
---|
155 | { |
---|
156 | %> |
---|
157 | <p:path><p:pathelement |
---|
158 | title="Plugins" href="<%="index.jsp?ID="+ID%>" |
---|
159 | /><p:pathelement title="<%=HTML.encodeTags(plugin.getName())%>" |
---|
160 | /></p:path> |
---|
161 | <% |
---|
162 | } |
---|
163 | %> |
---|
164 | <div id="page-data" data-item-id="<%=itemId%>" data-iframe="<%=iFrame ? 1 : 0%>"></div> |
---|
165 | <t:tabcontrol |
---|
166 | id="main" |
---|
167 | subclass="content mastertabcontrol" |
---|
168 | active="<%=tab%>" |
---|
169 | notabs="<%=iFrame%>"> |
---|
170 | <t:tab id="properties" title="Properties"> |
---|
171 | <div> |
---|
172 | <table class="fullform larger bottomborder"> |
---|
173 | <tr> |
---|
174 | <th class="itemstatus"> |
---|
175 | <base:icon |
---|
176 | image="shared.png" |
---|
177 | visible="<%=plugin.isShared()%>" |
---|
178 | tooltip="This item is shared to other users, groups and/or projects" |
---|
179 | /> |
---|
180 | <base:icon |
---|
181 | id="btnDeletePermanently" |
---|
182 | image="deleted.png" |
---|
183 | tooltip="This item has been flagged for deletion. Click to delete it now." |
---|
184 | enabled="<%=deletePermanentlyPermission %>" |
---|
185 | visible="<%=isRemoved%>" |
---|
186 | /> |
---|
187 | <base:icon |
---|
188 | id="btnUsingItems" |
---|
189 | image="used.png" |
---|
190 | tooltip="This item is used by other items and can't be permanently deleted. Show the items that are using this one" |
---|
191 | visible="<%=isRemoved && isUsed%>" /> |
---|
192 | </th> |
---|
193 | <td style="padding: 0px;"> |
---|
194 | <tbl:toolbar subclass="bottomborder"> |
---|
195 | <tbl:button |
---|
196 | id="btnEdit" |
---|
197 | disabled="<%=!writePermission%>" |
---|
198 | image="edit.png" |
---|
199 | title="Edit…" |
---|
200 | tooltip="<%=writePermission ? "Edit this plugin" : "You do not have permission to edit this plugin"%>" |
---|
201 | /> |
---|
202 | <tbl:button |
---|
203 | id="btnToggleDisabled" |
---|
204 | image="plugin.png" |
---|
205 | data-enable="<%=plugin.isDisabled() ? 1 : 0%>" |
---|
206 | data-plugin-class="<%=plugin.getClassName() %>" |
---|
207 | title="<%=plugin.isDisabled() ? "Enable" : "Disable"%>" |
---|
208 | visible="<%=writePermission%>" |
---|
209 | tooltip="Disable/enable this plugin" |
---|
210 | /> |
---|
211 | <tbl:button |
---|
212 | id="btnDelete" |
---|
213 | data-extra-url="<%="&iframe="+iFrame%>" |
---|
214 | disabled="<%=!deletePermission%>" |
---|
215 | image="delete.png" |
---|
216 | title="Delete" |
---|
217 | visible="<%=!plugin.isRemoved()%>" |
---|
218 | tooltip="<%=deletePermission ? "Delete this plugin" : "You do not have permission to delete this plugin"%>" |
---|
219 | /> |
---|
220 | <tbl:button |
---|
221 | id="btnRestore" |
---|
222 | data-extra-url="<%="&iframe="+iFrame%>" |
---|
223 | disabled="<%=!writePermission%>" |
---|
224 | image="restore.png" |
---|
225 | title="Restore" |
---|
226 | visible="<%=plugin.isRemoved()%>" |
---|
227 | tooltip="<%=writePermission ? "Restore this plugin" : "You do not have permission to restore this plugin"%>" |
---|
228 | /> |
---|
229 | <tbl:button |
---|
230 | id="btnShare" |
---|
231 | disabled="<%=!sharePermission%>" |
---|
232 | image="share.png" |
---|
233 | title="Share…" |
---|
234 | tooltip="<%=sharePermission ? "Share this plugin to other user, groups and projects" : "You do not have permission to share this plugin"%>" |
---|
235 | /> |
---|
236 | <tbl:button |
---|
237 | id="btnSetOwner" |
---|
238 | disabled="<%=!setOwnerPermission%>" |
---|
239 | image="take_ownership.png" |
---|
240 | title="Set owner…" |
---|
241 | tooltip="<%=setOwnerPermission ? "Change owner of this item" : "You do not have permission to change ownership of this item"%>" |
---|
242 | /> |
---|
243 | <tbl:button |
---|
244 | id="btnNewConfiguration" |
---|
245 | image="add.png" |
---|
246 | title="New configuration…" |
---|
247 | tooltip="Create a new configuration for this plugin" |
---|
248 | visible="<%=sc.hasPermission(Permission.CREATE, Item.PLUGINCONFIGURATION) && |
---|
249 | usePermission && plugin.supportsConfigurations()%>" |
---|
250 | /> |
---|
251 | <tbl:button |
---|
252 | id="btnImport" |
---|
253 | image="import.png" |
---|
254 | data-plugin-type="IMPORT" |
---|
255 | title="Import…" |
---|
256 | tooltip="Import data" |
---|
257 | visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>" |
---|
258 | /> |
---|
259 | <tbl:button |
---|
260 | id="btnExport" |
---|
261 | image="export.png" |
---|
262 | data-plugin-type="EXPORT" |
---|
263 | title="Export…" |
---|
264 | tooltip="Export data" |
---|
265 | visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>" |
---|
266 | /> |
---|
267 | <tbl:button |
---|
268 | id="btnRunPlugin" |
---|
269 | image="runplugin.png" |
---|
270 | data-plugin-type="OTHER" |
---|
271 | title="Run plugin…" |
---|
272 | tooltip="Run a plugin" |
---|
273 | visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>" |
---|
274 | /> |
---|
275 | <tbl:button |
---|
276 | id="btnUnload" |
---|
277 | title="Unload" |
---|
278 | tooltip="<%=loaded && !internal ? "Unload the code for this plugin" : "The code for this plugin has not yet been loaded" %>" |
---|
279 | visible="<%=loaded && !internal%>" |
---|
280 | /> |
---|
281 | <ext:render extensions="<%=invoker%>" context="<%=jspContext%>" |
---|
282 | wrapper="<%=new PrefixSuffixRenderer(jspContext, "<td>", "</td>") %>"/> |
---|
283 | <tbl:button |
---|
284 | image="help.png" |
---|
285 | subclass="auto-init" |
---|
286 | data-auto-init="help" |
---|
287 | data-help-id="plugindefinition.view.properties" |
---|
288 | title="Help…" |
---|
289 | tooltip="Get help about this page" |
---|
290 | /> |
---|
291 | </tbl:toolbar> |
---|
292 | </td> |
---|
293 | </tr> |
---|
294 | <tr> |
---|
295 | <th>Name</th> |
---|
296 | <td><%=HTML.encodeTags(plugin.getName())%></td> |
---|
297 | </tr> |
---|
298 | <tr> |
---|
299 | <th>Registered</th> |
---|
300 | <td><%=dateFormatter.format(plugin.getEntryDate())%></td> |
---|
301 | </tr> |
---|
302 | <tr> |
---|
303 | <th>Type</th> |
---|
304 | <td><%=plugin.getMainType()%></td> |
---|
305 | </tr> |
---|
306 | <tr> |
---|
307 | <th>Class</th> |
---|
308 | <td><%=plugin.getClassName()%></td> |
---|
309 | </tr> |
---|
310 | <tr> |
---|
311 | <th>JAR file</th> |
---|
312 | <td><%=internal ? "<i>- internal -</i>" : plugin.getJarFile()%></td> |
---|
313 | </tr> |
---|
314 | <tr> |
---|
315 | <th>Version</th> |
---|
316 | <td><%=plugin.getVersionString()%></td> |
---|
317 | </tr> |
---|
318 | <tr> |
---|
319 | <th>Max memory</th> |
---|
320 | <td><%=Values.formatBytes(plugin.getMaxMemory())%></td> |
---|
321 | </tr> |
---|
322 | <tr> |
---|
323 | <th>Trusted</th> |
---|
324 | <td><%=plugin.isTrusted() ? "yes" : "no"%></td> |
---|
325 | </tr> |
---|
326 | <tr> |
---|
327 | <th>Allow immediate execution</th> |
---|
328 | <td><%=plugin.getAllowImmediateExecution() ? "yes" : "no"%></td> |
---|
329 | </tr> |
---|
330 | <tr> |
---|
331 | <th>Use internal job queue</th> |
---|
332 | <td><%=plugin.getUseInternalJobQueue() ? "yes" : "no"%></td> |
---|
333 | </tr> |
---|
334 | <tr> |
---|
335 | <th>Items</th> |
---|
336 | <td><%=Values.getString(contexts, ", ", true)%></td> |
---|
337 | </tr> |
---|
338 | <tr> |
---|
339 | <th>Contact</th> |
---|
340 | <td><%=HTML.encodeTags(plugin.getContact())%></td> |
---|
341 | </tr> |
---|
342 | <tr> |
---|
343 | <th>Copyright</th> |
---|
344 | <td><%=HTML.encodeTags(plugin.getCopyright())%></td> |
---|
345 | </tr> |
---|
346 | <tr> |
---|
347 | <th>Email</th> |
---|
348 | <td><%=HTML.scanForLinks(plugin.getEmail(), HTML.LINK_EMAIL, "_blank")%></td> |
---|
349 | </tr> |
---|
350 | <tr> |
---|
351 | <th>Url</th> |
---|
352 | <td><%=HTML.scanForLinks(plugin.getUrl(), HTML.LINK_URL, "_blank")%></td> |
---|
353 | </tr> |
---|
354 | <tr> |
---|
355 | <th>Owner</th> |
---|
356 | <td><base:propertyvalue item="<%=plugin%>" property="owner" /></td> |
---|
357 | </tr> |
---|
358 | <tr> |
---|
359 | <th>Permissions</th> |
---|
360 | <td><%=PermissionUtil.getFullPermissionNames(plugin)%></td> |
---|
361 | </tr> |
---|
362 | <tr class="big"> |
---|
363 | <th>Description</th> |
---|
364 | <td><%=HTML.niceFormat(plugin.getDescription())%></td> |
---|
365 | </tr> |
---|
366 | </table> |
---|
367 | </div> |
---|
368 | |
---|
369 | <% |
---|
370 | if (warning != null) |
---|
371 | { |
---|
372 | %> |
---|
373 | <div class="messagecontainer error"><%=warning%></div> |
---|
374 | <% |
---|
375 | } |
---|
376 | %> |
---|
377 | |
---|
378 | <% |
---|
379 | if (plugin.supportsConfigurations()) |
---|
380 | { |
---|
381 | ItemQuery<PluginConfiguration> configQuery = plugin.getPluginConfigurations(); |
---|
382 | configQuery.include(Include.ALL); |
---|
383 | configQuery.order(Orders.asc(Hql.property("name"))); |
---|
384 | ItemResultList<PluginConfiguration> configurations = configQuery.list(dc); |
---|
385 | %> |
---|
386 | <base:section |
---|
387 | id="configurations" |
---|
388 | title="<%="Configurations (" + configurations.size() + ")" %>" |
---|
389 | context="<%=cc%>" |
---|
390 | > |
---|
391 | <% |
---|
392 | if (configurations.size() == 0) |
---|
393 | { |
---|
394 | %> |
---|
395 | <div class="messagecontainer note"> |
---|
396 | There are no configurations for this plugin (or, you don't have permission to view them). |
---|
397 | </div> |
---|
398 | <% |
---|
399 | } |
---|
400 | else |
---|
401 | { |
---|
402 | %> |
---|
403 | <tbl:table |
---|
404 | id="tbl.configurations" |
---|
405 | columns="all" |
---|
406 | > |
---|
407 | <tbl:columndef |
---|
408 | id="name" |
---|
409 | title="Name" |
---|
410 | /> |
---|
411 | <tbl:columndef |
---|
412 | id="description" |
---|
413 | title="Description" |
---|
414 | /> |
---|
415 | <tbl:columndef |
---|
416 | id="configure" |
---|
417 | title="Configure" |
---|
418 | show="<%=plugin.supportsConfigurations() ? "always" : "never" %>" |
---|
419 | /> |
---|
420 | <tbl:data> |
---|
421 | <tbl:headers> |
---|
422 | <tbl:headerrow> |
---|
423 | <tbl:columnheaders /> |
---|
424 | </tbl:headerrow> |
---|
425 | </tbl:headers> |
---|
426 | <tbl:rows> |
---|
427 | <% |
---|
428 | for (PluginConfiguration pc : configurations) |
---|
429 | { |
---|
430 | %> |
---|
431 | <tbl:row> |
---|
432 | <tbl:cell column="name"><base:icon |
---|
433 | image="deleted.png" |
---|
434 | tooltip="This item has been scheduled for deletion" |
---|
435 | visible="<%=pc.isRemoved()%>" |
---|
436 | /><%=Base.getLinkedName(ID, pc, false, true)%></tbl:cell> |
---|
437 | <tbl:cell column="description"><%=HTML.niceFormat(pc.getDescription())%></tbl:cell> |
---|
438 | <tbl:cell column="configure"> |
---|
439 | <% |
---|
440 | if (pc.hasPermission(Permission.WRITE)) |
---|
441 | { |
---|
442 | %> |
---|
443 | <base:icon |
---|
444 | id="<%="configure-plugin."+pc.getId()%>" |
---|
445 | subclass="auto-init" |
---|
446 | data-auto-init="configure-plugin" |
---|
447 | data-item-id="<%=pc.getId()%>" |
---|
448 | image="runplugin.png" |
---|
449 | tooltip="Configure this plugin "/> |
---|
450 | <% |
---|
451 | } |
---|
452 | %> |
---|
453 | </tbl:cell> |
---|
454 | </tbl:row> |
---|
455 | <% |
---|
456 | } |
---|
457 | %> |
---|
458 | </tbl:rows> |
---|
459 | </tbl:data> |
---|
460 | </tbl:table> |
---|
461 | <% |
---|
462 | } |
---|
463 | %> |
---|
464 | </base:section> |
---|
465 | <% |
---|
466 | } |
---|
467 | %> |
---|
468 | <% |
---|
469 | ItemQuery<JobAgent> agentQuery = JobAgent.getQuery(); |
---|
470 | agentQuery.include(Include.ALL); |
---|
471 | agentQuery.order(Orders.asc(Hql.property("name"))); |
---|
472 | agentQuery.join(Hql.innerJoin("plugins", "p")); |
---|
473 | agentQuery.restrict(Restrictions.eq(Hql.property("p", "pluginDefinition"), Hql.entity(plugin))); |
---|
474 | ItemResultList<JobAgent> agents = agentQuery.list(dc); |
---|
475 | %> |
---|
476 | <base:section |
---|
477 | id="jobagents" |
---|
478 | title="<%="Installed on job agents (" + agents.size() + ")" %>" |
---|
479 | context="<%=cc%>" |
---|
480 | > |
---|
481 | <% |
---|
482 | if (agents.size() == 0) |
---|
483 | { |
---|
484 | %> |
---|
485 | <div class="messagecontainer note"> |
---|
486 | This plugin isn't installed on any job agents (or, you don't have permission to view them). |
---|
487 | </div> |
---|
488 | <% |
---|
489 | } |
---|
490 | else |
---|
491 | { |
---|
492 | %> |
---|
493 | <tbl:table |
---|
494 | id="agents" |
---|
495 | columns="all" |
---|
496 | > |
---|
497 | <tbl:columndef |
---|
498 | id="name" |
---|
499 | title="Name" |
---|
500 | /> |
---|
501 | <tbl:columndef |
---|
502 | id="server" |
---|
503 | title="Server" |
---|
504 | /> |
---|
505 | <tbl:columndef |
---|
506 | id="info" |
---|
507 | title="CPU/Memory" |
---|
508 | /> |
---|
509 | <tbl:columndef |
---|
510 | id="maxMemory" |
---|
511 | title="Max memory" |
---|
512 | /> |
---|
513 | <tbl:columndef |
---|
514 | id="trusted" |
---|
515 | title="Trusted" |
---|
516 | /> |
---|
517 | <tbl:columndef |
---|
518 | id="priorityBoost" |
---|
519 | title="Priority boost" |
---|
520 | /> |
---|
521 | <tbl:columndef |
---|
522 | id="configure" |
---|
523 | title="" |
---|
524 | /> |
---|
525 | <tbl:data> |
---|
526 | <tbl:headers> |
---|
527 | <tbl:headerrow> |
---|
528 | <tbl:columnheaders /> |
---|
529 | </tbl:headerrow> |
---|
530 | </tbl:headers> |
---|
531 | <tbl:rows> |
---|
532 | <% |
---|
533 | for (JobAgent agent : agents) |
---|
534 | { |
---|
535 | String server = agent.getServer(); |
---|
536 | Integer port = agent.getPort(); |
---|
537 | JobAgentSettings settings = agent.getSettings(plugin, false); |
---|
538 | Long maxMemory = settings.getEffectiveMaxMemory(); |
---|
539 | %> |
---|
540 | <tbl:row> |
---|
541 | <tbl:cell column="name"><base:icon |
---|
542 | image="deleted.png" |
---|
543 | tooltip="This item has been scheduled for deletion" |
---|
544 | visible="<%=agent.isRemoved()%>" |
---|
545 | /><%=Base.getLinkedName(ID, agent, false, true)%></tbl:cell> |
---|
546 | <tbl:cell column="server"><%=server == null || port == null ? "" : server + ":" + port%></tbl:cell> |
---|
547 | <tbl:cell column="info"> |
---|
548 | CPU usage: <%=agent.getCpuUsage() == null ? "<i>- unknown -</i>" : agent.getCpuUsage()+"%" %><br> |
---|
549 | Total memory: <%=agent.getTotalMemory() == null ? "<i>- unknown -</i>" : Values.formatBytes(agent.getTotalMemory()) %><br> |
---|
550 | Used memory: <%=agent.getUsedMemory() == null ? "<i>- unknown -</i>" : Values.formatBytes(agent.getUsedMemory()) %> |
---|
551 | </tbl:cell> |
---|
552 | <tbl:cell column="maxMemory"><%=maxMemory == null ? "<i>- not specified -</i>" : Values.formatBytes(maxMemory)%></tbl:cell> |
---|
553 | <tbl:cell column="trusted"><%=settings.isEffectivelyTrusted()%></tbl:cell> |
---|
554 | <tbl:cell column="priorityBoost"><%=settings.getPriorityBoost()%></tbl:cell> |
---|
555 | <tbl:cell column="configure"> |
---|
556 | <% |
---|
557 | if (agent.hasPermission(Permission.WRITE)) |
---|
558 | { |
---|
559 | %> |
---|
560 | <base:icon |
---|
561 | id="<%="configure-agent."+agent.getId()%>" |
---|
562 | subclass="auto-init" |
---|
563 | data-auto-init="configure-agent" |
---|
564 | data-item-id="<%=agent.getId()%>" |
---|
565 | image="runplugin.png" |
---|
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 | <% |
---|
579 | } |
---|
580 | %> |
---|
581 | </base:section> |
---|
582 | <base:section |
---|
583 | id="permissions" |
---|
584 | title="<%="Permissions (using permissions: " + (usePermissions ? "yes" : "no") + ")" %>" |
---|
585 | context="<%=cc%>" |
---|
586 | > |
---|
587 | <table class="fullform fullborder"> |
---|
588 | <tbody class="sectionheader"> |
---|
589 | <tr> |
---|
590 | <% |
---|
591 | Map<String, List<Item>> permissionGroups = PermissionUtil.getPermissionGroups(); |
---|
592 | for (String name : permissionGroups.keySet()) |
---|
593 | { |
---|
594 | %> |
---|
595 | <th class="columnheader" colspan="2"><b><%=name%></b></th> |
---|
596 | <% |
---|
597 | } |
---|
598 | %> |
---|
599 | </tr> |
---|
600 | </tbody> |
---|
601 | <% |
---|
602 | int newItems = 0; |
---|
603 | int rowIndex = 0; |
---|
604 | do |
---|
605 | { |
---|
606 | newItems = 0; |
---|
607 | int colIndex = 0; |
---|
608 | StringBuilder sb = new StringBuilder(); |
---|
609 | sb.append("<tr>"); |
---|
610 | for (String name : permissionGroups.keySet()) |
---|
611 | { |
---|
612 | List<Item> items = permissionGroups.get(name); |
---|
613 | if (items.size() > rowIndex) |
---|
614 | { |
---|
615 | newItems++; |
---|
616 | Item item = items.get(rowIndex); |
---|
617 | int keyId = SystemItems.getRoleKeyId(item); |
---|
618 | RoleKey key = RoleKey.getById(dc, keyId); |
---|
619 | |
---|
620 | sb.append("<th"); |
---|
621 | if (colIndex > 0) sb.append(" class=\"leftborder\""); |
---|
622 | sb.append(">").append(key.getName()).append("</th>"); |
---|
623 | sb.append("<td>"); |
---|
624 | |
---|
625 | if (keyId != 0) |
---|
626 | { |
---|
627 | Set<Permission> granted = plugin.getGranted(key); |
---|
628 | Set<Permission> denied = plugin.getDenied(key); |
---|
629 | sb.append(getShortPermissions(item, granted, denied)); |
---|
630 | } |
---|
631 | else |
---|
632 | { |
---|
633 | sb.append("(undefined key)"); |
---|
634 | } |
---|
635 | sb.append("</td>"); |
---|
636 | } |
---|
637 | else |
---|
638 | { |
---|
639 | sb.append("<th class=\"subprompt"); |
---|
640 | if (colIndex > 0) sb.append(" leftborder"); |
---|
641 | sb.append("\"></th><td></td>"); |
---|
642 | } |
---|
643 | colIndex++; |
---|
644 | } |
---|
645 | if (newItems > 0) |
---|
646 | { |
---|
647 | %> |
---|
648 | <%=sb.toString()%> |
---|
649 | <% |
---|
650 | } |
---|
651 | rowIndex++; |
---|
652 | } while (newItems > 0); |
---|
653 | %> |
---|
654 | </table> |
---|
655 | Capital letters = Permission is always granted, Small letters = Permission is only granted if logged in user |
---|
656 | has that permission<br> |
---|
657 | <b>C/c</b> = Create, <b>R/r</b> = Read, <b>U/u</b> = Use, |
---|
658 | <b>W/w</b> = Write, <b>D/d</b> = Delete, <b>O/o</b> = Change owner, |
---|
659 | <b>P/p</b> = Change permissions |
---|
660 | |
---|
661 | </base:section> |
---|
662 | <jsp:include page="../../common/anytoany/list_anytoany.jsp"> |
---|
663 | <jsp:param name="ID" value="<%=ID%>" /> |
---|
664 | <jsp:param name="item_type" value="<%=itemType.name()%>" /> |
---|
665 | <jsp:param name="item_id" value="<%=itemId%>" /> |
---|
666 | <jsp:param name="title" value="Other items related to this plugin" /> |
---|
667 | </jsp:include> |
---|
668 | <jsp:include page="../../common/share/list_share.jsp"> |
---|
669 | <jsp:param name="ID" value="<%=ID%>" /> |
---|
670 | <jsp:param name="item_type" value="<%=itemType.name()%>" /> |
---|
671 | <jsp:param name="item_id" value="<%=itemId%>" /> |
---|
672 | <jsp:param name="title" value="Shared to" /> |
---|
673 | </jsp:include> |
---|
674 | </t:tab> |
---|
675 | <t:tab id="annotations" title="Annotations" |
---|
676 | tooltip="View annotation values" clazz="white" |
---|
677 | visible="<%=!plugin.requiresConfiguration() && plugin.supports("net.sf.basedb.core.plugin.AnnotationSetterPlugin") %>"> |
---|
678 | <jsp:include page="../../common/annotations/list_frameset.jsp"> |
---|
679 | <jsp:param name="item_type" value="<%=itemType.name()%>" /> |
---|
680 | <jsp:param name="item_id" value="<%=itemId%>" /> |
---|
681 | <jsp:param name="ID" value="<%=ID%>" /> |
---|
682 | </jsp:include> |
---|
683 | </t:tab> |
---|
684 | </t:tabcontrol> |
---|
685 | </base:body> |
---|
686 | </base:page> |
---|
687 | <% |
---|
688 | } |
---|
689 | finally |
---|
690 | { |
---|
691 | if (dc != null) dc.close(); |
---|
692 | } |
---|
693 | |
---|
694 | %> |
---|