1 | <%-- $Id: view_agent.jsp 3743 2007-09-17 12:47:03Z nicklas $ |
---|
2 | ------------------------------------------------------------------ |
---|
3 | Copyright (C) 2006 Nicklas Nordborg |
---|
4 | Copyright (C) 2007 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 2 |
---|
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 this program; if not, write to the Free Software |
---|
21 | Foundation, Inc., 59 Temple Place - Suite 330, |
---|
22 | Boston, MA 02111-1307, USA. |
---|
23 | ------------------------------------------------------------------ |
---|
24 | |
---|
25 | @author Nicklas |
---|
26 | @version 2.0 |
---|
27 | --%> |
---|
28 | <%@ page session="false" |
---|
29 | import="net.sf.basedb.core.SessionControl" |
---|
30 | import="net.sf.basedb.core.DbControl" |
---|
31 | import="net.sf.basedb.core.SystemItems" |
---|
32 | import="net.sf.basedb.core.Item" |
---|
33 | import="net.sf.basedb.core.ItemContext" |
---|
34 | import="net.sf.basedb.core.Permission" |
---|
35 | import="net.sf.basedb.core.Job" |
---|
36 | import="net.sf.basedb.core.JobAgent" |
---|
37 | import="net.sf.basedb.core.JobAgentSettings" |
---|
38 | import="net.sf.basedb.util.jobagent.JobAgentInfo" |
---|
39 | import="net.sf.basedb.core.User" |
---|
40 | import="net.sf.basedb.core.PermissionDeniedException" |
---|
41 | import="net.sf.basedb.core.PluginDefinition" |
---|
42 | import="net.sf.basedb.core.ItemQuery" |
---|
43 | import="net.sf.basedb.core.ItemResultList" |
---|
44 | import="net.sf.basedb.core.ItemResultIterator" |
---|
45 | import="net.sf.basedb.core.MultiPermissions" |
---|
46 | import="net.sf.basedb.core.Group" |
---|
47 | import="net.sf.basedb.core.Project" |
---|
48 | import="net.sf.basedb.core.query.Orders" |
---|
49 | import="net.sf.basedb.core.query.Hql" |
---|
50 | import="net.sf.basedb.core.plugin.GuiContext" |
---|
51 | import="net.sf.basedb.core.plugin.Plugin" |
---|
52 | import="net.sf.basedb.clients.web.Base" |
---|
53 | import="net.sf.basedb.clients.web.PermissionUtil" |
---|
54 | import="net.sf.basedb.clients.web.util.HTML" |
---|
55 | import="net.sf.basedb.util.Values" |
---|
56 | import="net.sf.basedb.clients.web.util.NameablePluginAdaptor" |
---|
57 | import="net.sf.basedb.util.formatter.Formatter" |
---|
58 | import="net.sf.basedb.clients.web.formatter.FormatterFactory" |
---|
59 | import="java.util.Map" |
---|
60 | import="java.util.Set" |
---|
61 | import="java.util.Date" |
---|
62 | import="java.util.Collections" |
---|
63 | %> |
---|
64 | <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
---|
65 | <%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %> |
---|
66 | <%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %> |
---|
67 | <%@ taglib prefix="p" uri="/WEB-INF/path.tld" %> |
---|
68 | <%! |
---|
69 | private static final Item itemType = Item.JOBAGENT; |
---|
70 | private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.ITEM); |
---|
71 | %> |
---|
72 | <% |
---|
73 | final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
---|
74 | final String ID = sc.getId(); |
---|
75 | final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null); |
---|
76 | final int itemId = cc.getId(); |
---|
77 | final float scale = Base.getScale(sc); |
---|
78 | final DbControl dc = sc.newDbControl(); |
---|
79 | try |
---|
80 | { |
---|
81 | Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext); |
---|
82 | Formatter<Date> dateFormatter = FormatterFactory.getDateTimeFormatter(sc); |
---|
83 | |
---|
84 | String title = null; |
---|
85 | JobAgent agent = JobAgent.getById(dc, itemId); |
---|
86 | |
---|
87 | JobAgentInfo info = agent.getInfo(); |
---|
88 | Boolean paused = info.isPaused(); |
---|
89 | |
---|
90 | final boolean writePermission = agent.hasPermission(Permission.WRITE); |
---|
91 | final boolean deletePermission = agent.hasPermission(Permission.DELETE); |
---|
92 | final boolean sharePermission = agent.hasPermission(Permission.SET_PERMISSION); |
---|
93 | final boolean setOwnerPermission = agent.hasPermission(Permission.SET_OWNER); |
---|
94 | final boolean isOwner = agent.isOwner(); |
---|
95 | %> |
---|
96 | <base:page title="<%=title%>"> |
---|
97 | <base:head scripts="tabcontrol.js,table.js" styles="toolbar.css,headertabcontrol.css,path.css,table.css,progressbar.css"> |
---|
98 | <script language="JavaScript"> |
---|
99 | function editItem() |
---|
100 | { |
---|
101 | Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>, true); |
---|
102 | } |
---|
103 | function shareItem() |
---|
104 | { |
---|
105 | Main.openPopup('index.jsp?ID=<%=ID%>&cmd=ShareItem&item_id=<%=itemId%>', 'ShareJobAgent', 500, 400); |
---|
106 | } |
---|
107 | function deleteItem() |
---|
108 | { |
---|
109 | location.replace('index.jsp?ID=<%=ID%>&cmd=DeleteItem&item_id=<%=itemId%>'); |
---|
110 | } |
---|
111 | function restoreItem() |
---|
112 | { |
---|
113 | location.replace('index.jsp?ID=<%=ID%>&cmd=RestoreItem&item_id=<%=itemId%>'); |
---|
114 | } |
---|
115 | function takeOwnership() |
---|
116 | { |
---|
117 | if (confirm('Are you sure that you want to take ownership of this item? It can\'t be undone.')) |
---|
118 | { |
---|
119 | location.replace('index.jsp?ID=<%=ID%>&cmd=TakeOwnershipOfItem&item_id=<%=itemId%>'); |
---|
120 | } |
---|
121 | } |
---|
122 | function configurePlugin(pluginId) |
---|
123 | { |
---|
124 | Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>, true, '&plugin_id='+pluginId); |
---|
125 | } |
---|
126 | function controlJobAgent(cmd) |
---|
127 | { |
---|
128 | location.href = 'index.jsp?ID=<%=ID%>&cmd='+cmd+'&item_id=<%=itemId%>'; |
---|
129 | } |
---|
130 | </script> |
---|
131 | </base:head> |
---|
132 | <base:body> |
---|
133 | <p> |
---|
134 | <p:path> |
---|
135 | <p:pathelement title="Job agents" href="<%="index.jsp?ID="+ID%>" /> |
---|
136 | <p:pathelement title="<%=HTML.encodeTags(agent.getName())%>" /> |
---|
137 | </p:path> |
---|
138 | |
---|
139 | <t:tabcontrol id="main" active="properties"> |
---|
140 | <t:tab id="properties" title="Properties"> |
---|
141 | |
---|
142 | <tbl:toolbar |
---|
143 | > |
---|
144 | <tbl:button |
---|
145 | disabled="<%=writePermission ? false : true%>" |
---|
146 | image="<%=writePermission ? "edit.gif" : "edit_disabled.gif"%>" |
---|
147 | onclick="editItem()" |
---|
148 | title="Edit…" |
---|
149 | tooltip="<%=writePermission ? "Edit this job agent" : "You do not have permission to edit this job agent"%>" |
---|
150 | /> |
---|
151 | <tbl:button |
---|
152 | disabled="<%=deletePermission ? false : true%>" |
---|
153 | image="<%=deletePermission ? "delete.gif" : "delete_disabled.gif"%>" |
---|
154 | onclick="deleteItem()" |
---|
155 | title="Delete" |
---|
156 | visible="<%=!agent.isRemoved()%>" |
---|
157 | tooltip="<%=deletePermission ? "Delete this job agent" : "You do not have permission to delete this job agent"%>" |
---|
158 | /> |
---|
159 | <tbl:button |
---|
160 | disabled="<%=writePermission ? false : true%>" |
---|
161 | image="<%=writePermission ? "restore.gif" : "restore_disabled.gif"%>" |
---|
162 | onclick="restoreItem()" |
---|
163 | title="Restore" |
---|
164 | visible="<%=agent.isRemoved()%>" |
---|
165 | tooltip="<%=writePermission ? "Restore this job agent" : "You do not have permission to restore this job agent"%>" |
---|
166 | /> |
---|
167 | <tbl:button |
---|
168 | disabled="<%=sharePermission ? false : true%>" |
---|
169 | image="<%=sharePermission ? "share.gif" : "share_disabled.gif"%>" |
---|
170 | onclick="shareItem()" |
---|
171 | title="Share…" |
---|
172 | tooltip="<%=sharePermission ? "Share this job agent to other user, groups and projects" : "You do not have permission to share this job agent"%>" |
---|
173 | /> |
---|
174 | <tbl:button |
---|
175 | disabled="<%=setOwnerPermission ? false : true%>" |
---|
176 | image="<%=setOwnerPermission ? "take_ownership.png" : "take_ownership_disabled.png"%>" |
---|
177 | onclick="takeOwnership()" |
---|
178 | title="Take ownership…" |
---|
179 | visible="<%=!isOwner%>" |
---|
180 | tooltip="<%=setOwnerPermission ? "Take ownership of this item" : "You do not have permission to take ownership of this item"%>" |
---|
181 | /> |
---|
182 | <tbl:button |
---|
183 | image="import.gif" |
---|
184 | onclick="runPlugin('ImportItem')" |
---|
185 | title="Import…" |
---|
186 | tooltip="Import data" |
---|
187 | visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>" |
---|
188 | /> |
---|
189 | <tbl:button |
---|
190 | image="export.gif" |
---|
191 | onclick="runPlugin('ExportItem')" |
---|
192 | title="Export…" |
---|
193 | tooltip="Export data" |
---|
194 | visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>" |
---|
195 | /> |
---|
196 | <tbl:button |
---|
197 | image="runplugin.gif" |
---|
198 | onclick="runPlugin('RunPlugin')" |
---|
199 | title="Run plugin…" |
---|
200 | tooltip="Run a plugin" |
---|
201 | visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>" |
---|
202 | /> |
---|
203 | <tbl:button |
---|
204 | image="start.png" |
---|
205 | onclick="controlJobAgent('Start')" |
---|
206 | title="Start" |
---|
207 | tooltip="Start the job agent" |
---|
208 | visible="<%=writePermission && paused != null && paused == true%>" |
---|
209 | /> |
---|
210 | <tbl:button |
---|
211 | image="pause.png" |
---|
212 | onclick="controlJobAgent('Pause')" |
---|
213 | title="Pause" |
---|
214 | tooltip="Pause the job agent" |
---|
215 | visible="<%=writePermission && paused != null && paused == false%>" |
---|
216 | /> |
---|
217 | <tbl:button |
---|
218 | image="help.gif" |
---|
219 | onclick="<%="Main.openHelp('" + ID +"', 'jobagent.view.properties')"%>" |
---|
220 | title="Help…" |
---|
221 | tooltip="Get help about this page" |
---|
222 | /> |
---|
223 | </tbl:toolbar> |
---|
224 | <div class="boxedbottom"> |
---|
225 | <% |
---|
226 | if (cc.getMessage() != null) |
---|
227 | { |
---|
228 | %> |
---|
229 | <div class="error"><%=cc.getMessage()%></div> |
---|
230 | <% |
---|
231 | cc.setMessage(null); |
---|
232 | } |
---|
233 | %> |
---|
234 | |
---|
235 | <div class="itemstatus">Permissions on this item: <i><%=PermissionUtil.getFullPermissionNames(agent)%></i></div> |
---|
236 | <div class="itemstatus"> |
---|
237 | <base:icon image="deleted.gif" |
---|
238 | visible="<%=agent.isRemoved()%>"> This item has been flagged for deletion<br></base:icon> |
---|
239 | <base:icon image="shared.gif" |
---|
240 | visible="<%=agent.isShared()%>"> This item is shared to other user, groups and/or projects</base:icon> |
---|
241 | <base:icon image="warning.gif" |
---|
242 | visible="<%=!agent.isShared()%>"> This item is NOT shared to other users, groups or projects. Only the |
---|
243 | owner will be able to run jobs on this agent</base:icon> |
---|
244 | </div> |
---|
245 | <table class="form" cellspacing=0> |
---|
246 | <tr> |
---|
247 | <td class="prompt">Name</td> |
---|
248 | <td><%=HTML.encodeTags(agent.getName())%></td> |
---|
249 | </tr> |
---|
250 | <tr> |
---|
251 | <td class="prompt">External ID</td> |
---|
252 | <td><%=HTML.encodeTags(agent.getExternalId())%></td> |
---|
253 | </tr> |
---|
254 | <tr> |
---|
255 | <td class="prompt">Server</td> |
---|
256 | <td><%=HTML.encodeTags(agent.getServer())%></td> |
---|
257 | </tr> |
---|
258 | <tr> |
---|
259 | <td class="prompt">Port</td> |
---|
260 | <td><%=agent.getPort() == null ? "" : agent.getPort().toString()%></td> |
---|
261 | </tr> |
---|
262 | <tr> |
---|
263 | <td class="prompt">Status</td> |
---|
264 | <td> |
---|
265 | <%=paused == null ? "<i>- unknown -</i>" : paused == true ? "Paused" : "Running"%> |
---|
266 | </td> |
---|
267 | </tr> |
---|
268 | <tr> |
---|
269 | <td class="prompt">CPU usage</td> |
---|
270 | <td><%=info.getCpuUsage() == null ? "<i>- unknown -</i>" : info.getCpuUsage() + "%"%></td> |
---|
271 | </tr> |
---|
272 | <tr> |
---|
273 | <td class="prompt">Memory</td> |
---|
274 | <td> |
---|
275 | Total: <%=info.getTotalMemory() == null ? "<i>- unknown -</i>" : Values.formatBytes(info.getTotalMemory())%>, |
---|
276 | Used: <%=info.getUsedMemory() == null ? "<i>- unknown -</i>" : Values.formatBytes(info.getUsedMemory())%> |
---|
277 | </td> |
---|
278 | </tr> |
---|
279 | <tr> |
---|
280 | <td class="prompt">Owner</td> |
---|
281 | <td><base:propertyvalue item="<%=agent%>" property="owner" /></td> |
---|
282 | </tr> |
---|
283 | <tr> |
---|
284 | <td class="prompt">Description</td> |
---|
285 | <td><%=HTML.niceFormat(agent.getDescription())%></td> |
---|
286 | </tr> |
---|
287 | </table> |
---|
288 | |
---|
289 | |
---|
290 | <% |
---|
291 | ItemQuery<JobAgentSettings> query = agent.getSettings(); |
---|
292 | query.order(Orders.asc(Hql.property("pluginDefinition.name"))); |
---|
293 | ItemResultList<JobAgentSettings> plugins = query.list(dc); |
---|
294 | |
---|
295 | if (plugins.size() == 0) |
---|
296 | { |
---|
297 | %> |
---|
298 | <h4>Installed plugins</h4> |
---|
299 | This job agent has no installed plugins (or, you don't have permission to view them). |
---|
300 | <% |
---|
301 | } |
---|
302 | else |
---|
303 | { |
---|
304 | %> |
---|
305 | <h4 class="docked">Installed plugins</h4> |
---|
306 | <tbl:table |
---|
307 | id="plugins" |
---|
308 | clazz="itemlist" |
---|
309 | columns="all" |
---|
310 | > |
---|
311 | <tbl:columndef |
---|
312 | id="plugin" |
---|
313 | title="Plugin" |
---|
314 | /> |
---|
315 | <tbl:columndef |
---|
316 | id="jarPath" |
---|
317 | title="JAR path" |
---|
318 | /> |
---|
319 | <tbl:columndef |
---|
320 | id="trusted" |
---|
321 | title="Trusted" |
---|
322 | /> |
---|
323 | <tbl:columndef |
---|
324 | id="maxMemory" |
---|
325 | title="Max memory" |
---|
326 | /> |
---|
327 | <tbl:columndef |
---|
328 | id="priorityBoost" |
---|
329 | title="Priority boost" |
---|
330 | /> |
---|
331 | <tbl:columndef |
---|
332 | id="configure" |
---|
333 | title="" |
---|
334 | /> |
---|
335 | <tbl:data> |
---|
336 | <tbl:columns> |
---|
337 | </tbl:columns> |
---|
338 | <tbl:rows> |
---|
339 | <% |
---|
340 | for (JobAgentSettings settings : plugins) |
---|
341 | { |
---|
342 | PluginDefinition plugin = null; |
---|
343 | NameablePluginAdaptor nameableProxy = null; |
---|
344 | boolean readPlugin = true; |
---|
345 | try |
---|
346 | { |
---|
347 | plugin = settings.getPluginDefinition(); |
---|
348 | nameableProxy = new NameablePluginAdaptor(plugin); |
---|
349 | } |
---|
350 | catch (PermissionDeniedException ex) |
---|
351 | { |
---|
352 | readPlugin = false; |
---|
353 | } |
---|
354 | Long maxMemory = settings.getEffectiveMaxMemory(); |
---|
355 | String jarPath = settings.getEffectiveJarPath(); |
---|
356 | %> |
---|
357 | <tbl:row> |
---|
358 | <tbl:cell column="plugin"><%=Base.getLinkedName(ID, nameableProxy, !readPlugin, true)%></tbl:cell> |
---|
359 | <tbl:cell column="jarPath"><%=jarPath == null ? "<i>- internal -</i>" : HTML.encodeTags(jarPath)%></tbl:cell> |
---|
360 | <tbl:cell column="trusted"><%=settings.isEffectivelyTrusted()%></tbl:cell> |
---|
361 | <tbl:cell column="maxMemory"><%=maxMemory == null ? "<i>- not specified -</i>" : Values.formatBytes(maxMemory)%></tbl:cell> |
---|
362 | <tbl:cell column="priorityBoost"><%=settings.getPriorityBoost()%></tbl:cell> |
---|
363 | <tbl:cell column="configure"> |
---|
364 | <% |
---|
365 | if (writePermission && plugin != null) |
---|
366 | { |
---|
367 | %> |
---|
368 | <base:icon image="runplugin.gif" |
---|
369 | onclick="<%="configurePlugin(" + plugin.getId() + ")"%>" |
---|
370 | tooltip="Configure the settings for this plugin on the job agent "/> |
---|
371 | <% |
---|
372 | } |
---|
373 | %> |
---|
374 | </tbl:cell> |
---|
375 | </tbl:row> |
---|
376 | <% |
---|
377 | } |
---|
378 | %> |
---|
379 | </tbl:rows> |
---|
380 | </tbl:data> |
---|
381 | </tbl:table> |
---|
382 | <% |
---|
383 | } |
---|
384 | %> |
---|
385 | |
---|
386 | <% |
---|
387 | Set<Integer> jobs = agent.getInfo().getJobs(); |
---|
388 | if (jobs == null || jobs.size() == 0) |
---|
389 | { |
---|
390 | %> |
---|
391 | <h4>Executing jobs</h4> |
---|
392 | <% |
---|
393 | if (jobs == null) |
---|
394 | { |
---|
395 | %> |
---|
396 | Unknown |
---|
397 | <% |
---|
398 | } |
---|
399 | else |
---|
400 | { |
---|
401 | %> |
---|
402 | No jobs are currently executing on this job agent |
---|
403 | <% |
---|
404 | } |
---|
405 | } |
---|
406 | else |
---|
407 | { |
---|
408 | %> |
---|
409 | <h4 class="docked">Executing jobs</h4> |
---|
410 | <tbl:table |
---|
411 | id="jobs" |
---|
412 | clazz="itemlist" |
---|
413 | columns="all" |
---|
414 | > |
---|
415 | <tbl:columndef |
---|
416 | id="job" |
---|
417 | title="Job" |
---|
418 | /> |
---|
419 | <tbl:columndef |
---|
420 | id="plugin" |
---|
421 | title="Plugin" |
---|
422 | /> |
---|
423 | <tbl:columndef |
---|
424 | id="started" |
---|
425 | title="Started" |
---|
426 | /> |
---|
427 | <tbl:columndef |
---|
428 | id="percentComplete" |
---|
429 | title="Percent complete" |
---|
430 | /> |
---|
431 | <tbl:columndef |
---|
432 | id="owner" |
---|
433 | title="Owner" |
---|
434 | /> |
---|
435 | <tbl:data> |
---|
436 | <tbl:columns> |
---|
437 | </tbl:columns> |
---|
438 | <tbl:rows> |
---|
439 | <% |
---|
440 | for (int jobId : jobs) |
---|
441 | { |
---|
442 | Job job = null; |
---|
443 | boolean readJob = true; |
---|
444 | try |
---|
445 | { |
---|
446 | job = Job.getById(dc, jobId); |
---|
447 | } |
---|
448 | catch (Throwable t) |
---|
449 | { |
---|
450 | readJob = false; |
---|
451 | } |
---|
452 | %> |
---|
453 | <tbl:row> |
---|
454 | <tbl:cell column="job"><%=Base.getLinkedName(ID, job, !readJob, true) %></tbl:cell> |
---|
455 | <tbl:cell column="plugin"><base:propertyvalue item="<%=job%>" property="pluginDefinition"/></tbl:cell> |
---|
456 | <tbl:cell column="started"><%=job == null ? "" : dateFormatter.format(job.getStarted())%></tbl:cell> |
---|
457 | <tbl:cell column="percentComplete"> |
---|
458 | <% |
---|
459 | if (job != null) |
---|
460 | { |
---|
461 | %> |
---|
462 | <table border=0 cellspacing=0 cellpadding=0> |
---|
463 | <tr> |
---|
464 | <td width="100"> |
---|
465 | <table width="100" class="progressbar" border=0 cellspacing=0 cellpadding=0> |
---|
466 | <tr> |
---|
467 | <% |
---|
468 | int percent = job.getPercentComplete(); |
---|
469 | if (percent > 0) |
---|
470 | { |
---|
471 | %> |
---|
472 | <td width="<%=percent%>%" class="done"> </td> |
---|
473 | <% |
---|
474 | } |
---|
475 | if (percent < 100) |
---|
476 | { |
---|
477 | %> |
---|
478 | <td width="<%=100-percent%>%" class="remain"> </td> |
---|
479 | <% |
---|
480 | } |
---|
481 | %> |
---|
482 | </tr> |
---|
483 | </table> |
---|
484 | </td> |
---|
485 | <td> <%=percent%>%</td> |
---|
486 | </tr> |
---|
487 | </table> |
---|
488 | <% |
---|
489 | } |
---|
490 | %> |
---|
491 | </tbl:cell> |
---|
492 | <tbl:cell column="owner"><base:propertyvalue item="<%=job%>" property="owner" /></tbl:cell> |
---|
493 | </tbl:row> |
---|
494 | <% |
---|
495 | } |
---|
496 | %> |
---|
497 | </tbl:rows> |
---|
498 | </tbl:data> |
---|
499 | </tbl:table> |
---|
500 | <% |
---|
501 | } |
---|
502 | |
---|
503 | // Tables with users/groups/projects that this item is shared to |
---|
504 | MultiPermissions mp = new MultiPermissions(Collections.singleton(agent)); |
---|
505 | ItemResultIterator<User> users = mp.getUsers().iterate(dc); |
---|
506 | ItemResultIterator<Group> groups = mp.getGroups().iterate(dc); |
---|
507 | ItemResultIterator<Project> projects = mp.getProjects().iterate(dc); |
---|
508 | |
---|
509 | if (users.hasNext() || groups.hasNext() || projects.hasNext()) |
---|
510 | { |
---|
511 | %> |
---|
512 | <h4 class="docked">Shared to</h4> |
---|
513 | <tbl:table |
---|
514 | id="itemsSharedTo" |
---|
515 | clazz="itemlist" |
---|
516 | columns="all" |
---|
517 | > |
---|
518 | <tbl:columndef |
---|
519 | id="itemType" |
---|
520 | title="Item type" |
---|
521 | /> |
---|
522 | <tbl:columndef |
---|
523 | id="name" |
---|
524 | title="Name" |
---|
525 | /> |
---|
526 | <tbl:columndef |
---|
527 | id="permissions" |
---|
528 | title="Permissions" |
---|
529 | /> |
---|
530 | <tbl:data> |
---|
531 | <tbl:columns> |
---|
532 | </tbl:columns> |
---|
533 | <tbl:rows> |
---|
534 | <% |
---|
535 | while(projects.hasNext()) |
---|
536 | { |
---|
537 | Project project = projects.next(); |
---|
538 | Set<Permission> permissions = mp.getPermissions(project).values().iterator().next(); |
---|
539 | %> |
---|
540 | <tbl:row> |
---|
541 | <tbl:cell column="itemType"><%=project.getType()%></tbl:cell> |
---|
542 | <tbl:cell column="name"><%=Base.getLinkedName(ID, project, false, true)%></tbl:cell> |
---|
543 | <tbl:cell column="permissions"> |
---|
544 | <%=PermissionUtil.translatePermissionsToString(permissions)%> |
---|
545 | </tbl:cell> |
---|
546 | </tbl:row> |
---|
547 | <% |
---|
548 | } |
---|
549 | while(groups.hasNext()) |
---|
550 | { |
---|
551 | Group group = groups.next(); |
---|
552 | Set<Permission> permissions = mp.getPermissions(group).values().iterator().next(); |
---|
553 | %> |
---|
554 | <tbl:row> |
---|
555 | <tbl:cell column="itemType"><%=group.getType()%></tbl:cell> |
---|
556 | <tbl:cell column="name"><%=Base.getLinkedName(ID, group, false, true)%></tbl:cell> |
---|
557 | <tbl:cell column="permissions"> |
---|
558 | <%=PermissionUtil.translatePermissionsToString(permissions)%> |
---|
559 | </tbl:cell> |
---|
560 | </tbl:row> |
---|
561 | <% |
---|
562 | } |
---|
563 | while (users.hasNext()) |
---|
564 | { |
---|
565 | User user = users.next(); |
---|
566 | Set<Permission> permissions = mp.getPermissions(user).values().iterator().next(); |
---|
567 | %> |
---|
568 | <tbl:row> |
---|
569 | <tbl:cell column="itemType"><%=user.getType()%></tbl:cell> |
---|
570 | <tbl:cell column="name"><%=Base.getLinkedName(ID, user, false, true)%></tbl:cell> |
---|
571 | <tbl:cell column="permissions"> |
---|
572 | <%=PermissionUtil.translatePermissionsToString(permissions)%> |
---|
573 | </tbl:cell> |
---|
574 | </tbl:row> |
---|
575 | <% |
---|
576 | } |
---|
577 | %> |
---|
578 | </tbl:rows> |
---|
579 | </tbl:data> |
---|
580 | </tbl:table> |
---|
581 | <% |
---|
582 | } |
---|
583 | else |
---|
584 | { |
---|
585 | %> |
---|
586 | <h4>Shared to</h4> |
---|
587 | This job agent is not shared |
---|
588 | (or, you don't have permission to view the ones it is shared to). |
---|
589 | <% |
---|
590 | } |
---|
591 | %> |
---|
592 | |
---|
593 | </div> |
---|
594 | </t:tab> |
---|
595 | </t:tabcontrol> |
---|
596 | </base:body> |
---|
597 | </base:page> |
---|
598 | <% |
---|
599 | } |
---|
600 | finally |
---|
601 | { |
---|
602 | if (dc != null) dc.close(); |
---|
603 | } |
---|
604 | |
---|
605 | %> |
---|