1 | <%-- $Id: edit_plugin.jsp 3871 2007-10-22 12:21:37Z nicklas $ |
---|
2 | ------------------------------------------------------------------ |
---|
3 | Copyright (C) 2005 Nicklas Nordborg |
---|
4 | Copyright (C) 2006 Jari Hakkinen, Nicklas Nordborg, Martin Svensson |
---|
5 | Copyright (C) 2007 Johan Enell, Nicklas Nordborg |
---|
6 | |
---|
7 | This file is part of BASE - BioArray Software Environment. |
---|
8 | Available at http://base.thep.lu.se/ |
---|
9 | |
---|
10 | BASE is free software; you can redistribute it and/or |
---|
11 | modify it under the terms of the GNU General Public License |
---|
12 | as published by the Free Software Foundation; either version 2 |
---|
13 | of the License, or (at your option) any later version. |
---|
14 | |
---|
15 | BASE is distributed in the hope that it will be useful, |
---|
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
18 | GNU General Public License for more details. |
---|
19 | |
---|
20 | You should have received a copy of the GNU General Public License |
---|
21 | along with this program; if not, write to the Free Software |
---|
22 | Foundation, Inc., 59 Temple Place - Suite 330, |
---|
23 | Boston, MA 02111-1307, USA. |
---|
24 | ------------------------------------------------------------------ |
---|
25 | |
---|
26 | |
---|
27 | @author Nicklas |
---|
28 | @version 2.0 |
---|
29 | --%> |
---|
30 | <%@ page session="false" |
---|
31 | import="net.sf.basedb.core.SessionControl" |
---|
32 | import="net.sf.basedb.core.DbControl" |
---|
33 | import="net.sf.basedb.core.Item" |
---|
34 | import="net.sf.basedb.core.ItemContext" |
---|
35 | import="net.sf.basedb.core.Include" |
---|
36 | import="net.sf.basedb.core.Permission" |
---|
37 | import="net.sf.basedb.core.PluginDefinition" |
---|
38 | import="net.sf.basedb.core.ItemQuery" |
---|
39 | import="net.sf.basedb.core.ItemResultList" |
---|
40 | import="net.sf.basedb.core.JobAgent" |
---|
41 | import="net.sf.basedb.core.JobAgentSettings" |
---|
42 | import="net.sf.basedb.core.BaseException" |
---|
43 | import="net.sf.basedb.core.PermissionDeniedException" |
---|
44 | import="net.sf.basedb.core.RoleKey" |
---|
45 | import="net.sf.basedb.core.SystemItems" |
---|
46 | import="net.sf.basedb.core.plugin.Plugin" |
---|
47 | import="net.sf.basedb.core.plugin.Permissions" |
---|
48 | import="net.sf.basedb.core.query.Restrictions" |
---|
49 | import="net.sf.basedb.core.query.Orders" |
---|
50 | import="net.sf.basedb.core.query.Hql" |
---|
51 | import="net.sf.basedb.clients.web.Base" |
---|
52 | import="net.sf.basedb.clients.web.util.HTML" |
---|
53 | import="net.sf.basedb.clients.web.PermissionUtil" |
---|
54 | import="net.sf.basedb.util.Values" |
---|
55 | import="java.util.EnumSet" |
---|
56 | import="java.util.Set" |
---|
57 | import="java.util.Map" |
---|
58 | import="java.util.List" |
---|
59 | import="java.util.Collection" |
---|
60 | %> |
---|
61 | <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
---|
62 | <%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %> |
---|
63 | <%! |
---|
64 | private static final int DENY_CODE = PermissionUtil.getPermissionCode(EnumSet.of(Permission.DENIED)); |
---|
65 | private static final int CREATE_CODE = PermissionUtil.getPermissionCode(EnumSet.of(Permission.CREATE)); |
---|
66 | private static final int READ_CODE = PermissionUtil.getPermissionCode(EnumSet.of(Permission.READ)); |
---|
67 | private static final int USE_CODE = PermissionUtil.getPermissionCode(EnumSet.of(Permission.USE)); |
---|
68 | private static final int WRITE_CODE = PermissionUtil.getPermissionCode(EnumSet.of(Permission.WRITE)); |
---|
69 | private static final int DELETE_CODE = PermissionUtil.getPermissionCode(EnumSet.of(Permission.DELETE)); |
---|
70 | private static final int SET_OWNER_CODE = PermissionUtil.getPermissionCode(EnumSet.of(Permission.SET_OWNER)); |
---|
71 | private static final int SET_PERMISSION_CODE = PermissionUtil.getPermissionCode(EnumSet.of(Permission.SET_PERMISSION)); |
---|
72 | |
---|
73 | private String getOption(DbControl dc, PluginDefinition plugin, Item itemType) |
---|
74 | throws BaseException |
---|
75 | { |
---|
76 | int keyId = SystemItems.getRoleKeyId(itemType); |
---|
77 | if (keyId == 0) return ""; |
---|
78 | |
---|
79 | RoleKey key = RoleKey.getById(dc, keyId); |
---|
80 | StringBuilder sb = new StringBuilder(); |
---|
81 | sb.append("<option value=\"").append(key.getItemType().name()).append("\">"); |
---|
82 | sb.append(HTML.encodeTags(key.getName())); |
---|
83 | sb.append(" []"); |
---|
84 | return sb.toString(); |
---|
85 | } |
---|
86 | private void appendPermissionLetter(StringBuilder sb, Permission p, String letter, |
---|
87 | Set<Permission> defined, Set<Permission> always, Set<Permission> maybe) |
---|
88 | { |
---|
89 | if (defined != null && defined.contains(p)) |
---|
90 | { |
---|
91 | if (always != null && always.contains(p)) |
---|
92 | { |
---|
93 | sb.append(letter.toUpperCase()); |
---|
94 | } |
---|
95 | else if (maybe != null && maybe.contains(p)) |
---|
96 | { |
---|
97 | sb.append(letter.toLowerCase()); |
---|
98 | } |
---|
99 | else |
---|
100 | { |
---|
101 | sb.append("-"); |
---|
102 | } |
---|
103 | } |
---|
104 | } |
---|
105 | %> |
---|
106 | <% |
---|
107 | final Item itemType = Item.PLUGINDEFINITION; |
---|
108 | final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
---|
109 | final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null); |
---|
110 | final int itemId = cc.getId(); |
---|
111 | final String ID = sc.getId(); |
---|
112 | final float scale = Base.getScale(sc); |
---|
113 | final DbControl dc = sc.newDbControl(); |
---|
114 | try |
---|
115 | { |
---|
116 | String title = null; |
---|
117 | PluginDefinition plugin = null; |
---|
118 | boolean isTrusted = true; |
---|
119 | Boolean allowImmediateExecution = null; |
---|
120 | boolean usePermissions = false; |
---|
121 | Collection<Permissions> requestedPermissions = null; |
---|
122 | String warning = null; |
---|
123 | |
---|
124 | final int selectedAgentId = Values.getInt(request.getParameter("jobagent_id"), -1); |
---|
125 | |
---|
126 | // Query to retrieve job agents |
---|
127 | ItemQuery<JobAgent> agentQuery = null; |
---|
128 | |
---|
129 | // Query to retrieve role keys |
---|
130 | final ItemQuery<RoleKey> roleKeyQuery = RoleKey.getQuery(); |
---|
131 | roleKeyQuery.order(Orders.asc(Hql.property("name"))); |
---|
132 | |
---|
133 | if (itemId == 0) |
---|
134 | { |
---|
135 | title = "Create plugin"; |
---|
136 | cc.removeObject("item"); |
---|
137 | String tt = cc.getPropertyValue("trusted"); |
---|
138 | String up = cc.getPropertyValue("usePermissions"); |
---|
139 | String aie = cc.getPropertyValue("allowImmediateExection"); |
---|
140 | isTrusted = tt == null ? isTrusted : Values.getBoolean(tt); |
---|
141 | usePermissions = up == null ? usePermissions : Values.getBoolean(up); |
---|
142 | allowImmediateExecution = aie == null ? null : Values.getBoolean(aie); |
---|
143 | } |
---|
144 | else |
---|
145 | { |
---|
146 | plugin = PluginDefinition.getById(dc, itemId); |
---|
147 | cc.setObject("item", plugin); |
---|
148 | title = "Edit plugin -- " + HTML.encodeTags(plugin.getName()); |
---|
149 | plugin.checkPermission(Permission.WRITE); |
---|
150 | isTrusted = plugin.isTrusted(); |
---|
151 | usePermissions = plugin.getUsePermissions(); |
---|
152 | allowImmediateExecution = plugin.getAllowImmediateExecution(); |
---|
153 | |
---|
154 | agentQuery = JobAgent.getQuery(); |
---|
155 | agentQuery.include(Include.MINE, Include.SHARED, Include.OTHERS, Include.IN_PROJECT); |
---|
156 | agentQuery.order(Orders.asc(Hql.property("name"))); |
---|
157 | agentQuery.join(Hql.innerJoin("plugins", "p")); |
---|
158 | agentQuery.restrict(Restrictions.eq(Hql.property("p", "pluginDefinition"), Hql.entity(plugin))); |
---|
159 | |
---|
160 | try |
---|
161 | { |
---|
162 | Plugin thePlugin = plugin.newInstance(Plugin.class, null, sc, null, null); |
---|
163 | requestedPermissions = thePlugin.getPermissions(); |
---|
164 | } |
---|
165 | catch (BaseException ex) |
---|
166 | { |
---|
167 | warning = ex.getMessage(); |
---|
168 | } |
---|
169 | } |
---|
170 | |
---|
171 | final String clazz = "class=\"text\""; |
---|
172 | final String requiredClazz = "class=\"text required\""; |
---|
173 | %> |
---|
174 | |
---|
175 | <base:page type="popup" title="<%=title%>"> |
---|
176 | <base:head scripts="tabcontrol.js,linkitems.js" styles="tabcontrol.css"> |
---|
177 | <script language="JavaScript"> |
---|
178 | // Validate the "Plugin" tab |
---|
179 | function validatePlugin() |
---|
180 | { |
---|
181 | var frm = document.forms['plugin']; |
---|
182 | if (Main.trimString(frm.className.value) == '') |
---|
183 | { |
---|
184 | alert("You must enter a class name"); |
---|
185 | frm.className.focus(); |
---|
186 | return false; |
---|
187 | } |
---|
188 | return true; |
---|
189 | } |
---|
190 | |
---|
191 | // Submit the form |
---|
192 | function saveSettings() |
---|
193 | { |
---|
194 | var frm = document.forms['plugin']; |
---|
195 | if (TabControl.validateActiveTab('settings')) |
---|
196 | { |
---|
197 | var agents = Link.getListIds(frm.agents, 'A'); |
---|
198 | for (var i = 0; i < agents.length; i++) |
---|
199 | { |
---|
200 | var agentId = agents[i]; |
---|
201 | var settings = getAgentSettings(agentId); |
---|
202 | if (settings) |
---|
203 | { |
---|
204 | if (!settings.useDefaultJarPath) |
---|
205 | { |
---|
206 | Forms.createHidden(frm, 'jarPath.'+agentId, settings.jarPath); |
---|
207 | } |
---|
208 | if (!settings.useDefaultMaxMemory) |
---|
209 | { |
---|
210 | Forms.createHidden(frm, 'maxMemory.'+agentId, settings.maxMemory); |
---|
211 | } |
---|
212 | if (!settings.useDefaultTrusted) |
---|
213 | { |
---|
214 | Forms.createHidden(frm, 'trusted.'+agentId, settings.trusted); |
---|
215 | } |
---|
216 | Forms.createHidden(frm, 'priorityBoost.'+agentId, settings.priorityBoost); |
---|
217 | } |
---|
218 | } |
---|
219 | |
---|
220 | frm.allAgents.value = agents.join(','); |
---|
221 | frm.removeAgents.value = Link.getActionIds(-1, 'A').join(','); |
---|
222 | frm.submit(); |
---|
223 | } |
---|
224 | } |
---|
225 | |
---|
226 | function addAgentsOnClick() |
---|
227 | { |
---|
228 | var agents = Link.getListIds(document.forms['plugin'].agents, 'A'); |
---|
229 | var url = '../jobagents/index.jsp?ID=<%=ID%>&cmd=UpdateContext&mode=selectmultiple&callback=addAgentCallback'; |
---|
230 | url += '&exclude='+agents.join(','); |
---|
231 | Main.openPopup(url, 'AddAgents', 1000, 700); |
---|
232 | } |
---|
233 | function addAgentCallback(agentId, name) |
---|
234 | { |
---|
235 | var item = Link.getItem('A', agentId); |
---|
236 | if (!item) |
---|
237 | { |
---|
238 | item = new Item('A', agentId, name); |
---|
239 | new AgentSetting(agentId, '', '', '', '0'); |
---|
240 | } |
---|
241 | var numBefore = document.forms['plugin'].agents.length; |
---|
242 | Link.addItem(document.forms['plugin'].agents, item); |
---|
243 | var numAfter = document.forms['plugin'].agents.length; |
---|
244 | if (numBefore == 0 && numAfter > 0) |
---|
245 | { |
---|
246 | document.forms['plugin'].use_internal_jobqueue.checked = false; |
---|
247 | } |
---|
248 | agentsOnClick(); |
---|
249 | } |
---|
250 | |
---|
251 | function removeOnClick() |
---|
252 | { |
---|
253 | Link.removeSelected(document.forms['plugin'].agents); |
---|
254 | Main.hide('agentsettings'); |
---|
255 | } |
---|
256 | |
---|
257 | |
---|
258 | function init() |
---|
259 | { |
---|
260 | <% |
---|
261 | if (plugin == null) |
---|
262 | { |
---|
263 | %> |
---|
264 | var frm = document.forms['plugin']; |
---|
265 | frm.className.focus(); |
---|
266 | frm.className.select(); |
---|
267 | <% |
---|
268 | } |
---|
269 | %> |
---|
270 | initAgents(); |
---|
271 | <% |
---|
272 | if (selectedAgentId != -1) |
---|
273 | { |
---|
274 | %> |
---|
275 | selectAgent(<%=selectedAgentId%>); |
---|
276 | <% |
---|
277 | } |
---|
278 | %> |
---|
279 | initPermissions(); |
---|
280 | } |
---|
281 | function initAgents() |
---|
282 | { |
---|
283 | var agents = document.forms['plugin'].agents; |
---|
284 | Link.addNewSection(agents, new Section('A', 'Job agents')); |
---|
285 | <% |
---|
286 | if (agentQuery != null) |
---|
287 | { |
---|
288 | ItemResultList<JobAgent> agents = agentQuery.list(dc); |
---|
289 | for (JobAgent agent : agents) |
---|
290 | { |
---|
291 | // Agent specific settings |
---|
292 | JobAgentSettings settings = agent.getSettings(plugin, false); |
---|
293 | String jarPath = null; |
---|
294 | Boolean trusted = null; |
---|
295 | Long maxMemory = null; |
---|
296 | int priorityBoost = 0; |
---|
297 | if (settings != null) |
---|
298 | { |
---|
299 | jarPath = settings.getJarPath(); |
---|
300 | trusted = settings.isTrusted(); |
---|
301 | maxMemory = settings.getMaxMemory(); |
---|
302 | priorityBoost = settings.getPriorityBoost(); |
---|
303 | %> |
---|
304 | Link.addNewItem(agents, new Item('A', <%=agent.getId()%>, '<%=HTML.javaScriptEncode(agent.getName())%>')); |
---|
305 | <% |
---|
306 | } |
---|
307 | %> |
---|
308 | new AgentSetting(<%=agent.getId()%>, '<%=HTML.javaScriptEncode(jarPath)%>', '<%=trusted == null ? "" : trusted ? "1" : "0"%>', '<%=Values.formatBytes(maxMemory)%>', '<%=priorityBoost%>'); |
---|
309 | <% |
---|
310 | } |
---|
311 | } |
---|
312 | %> |
---|
313 | } |
---|
314 | |
---|
315 | function selectAgent(agentId) |
---|
316 | { |
---|
317 | var frm = document.forms['plugin']; |
---|
318 | for (var i = 0; i < frm.agents.length; i++) |
---|
319 | { |
---|
320 | if (frm.agents[i].item.id == agentId) |
---|
321 | { |
---|
322 | frm.agents.selectedIndex = i; |
---|
323 | agentsOnClick(); |
---|
324 | return; |
---|
325 | } |
---|
326 | } |
---|
327 | } |
---|
328 | |
---|
329 | function getAgentSettings(agentId) |
---|
330 | { |
---|
331 | return allAgentSettings['A'+agentId]; |
---|
332 | } |
---|
333 | var allAgentSettings = new Array(); |
---|
334 | function AgentSetting(agentId, jarPath, trusted, maxMemory, priorityBoost) |
---|
335 | { |
---|
336 | this.agentId = agentId; |
---|
337 | this.jarPath = jarPath; |
---|
338 | this.useDefaultJarPath = (jarPath == ''); |
---|
339 | this.trusted = trusted; |
---|
340 | this.useDefaultTrusted = trusted != null; |
---|
341 | this.maxMemory = maxMemory; |
---|
342 | this.useDefaultMaxMemory = (maxMemory == ''); |
---|
343 | this.priorityBoost = priorityBoost; |
---|
344 | allAgentSettings['A'+agentId] = this; |
---|
345 | } |
---|
346 | |
---|
347 | var selectedAgentId; |
---|
348 | function agentsOnClick() |
---|
349 | { |
---|
350 | var frm = document.forms['plugin']; |
---|
351 | var agentId = frm.agents[frm.agents.selectedIndex].item.id; |
---|
352 | var settings = getAgentSettings(agentId); |
---|
353 | if (settings) |
---|
354 | { |
---|
355 | Main.show('agentsettings'); |
---|
356 | selectedAgentId = agentId; |
---|
357 | // Set JAR path |
---|
358 | frm.useDefaultJarPath.checked = settings.useDefaultJarPath; |
---|
359 | useDefaultJarPathOnClick(); |
---|
360 | var defaultJarPath = document.getElementById("defaultJarPath"); |
---|
361 | var html = frm.jarPath.value; |
---|
362 | if (html.length > 50) |
---|
363 | { |
---|
364 | html = '<span title="'+html+'">'+Main.cutString(html, 50)+'</span>'; |
---|
365 | } |
---|
366 | if (html == '') html = 'internal'; |
---|
367 | defaultJarPath.innerHTML = html; |
---|
368 | |
---|
369 | // Set max memory |
---|
370 | frm.useDefaultMaxMemory.checked = settings.useDefaultMaxMemory; |
---|
371 | useDefaultMaxMemoryOnClick(); |
---|
372 | var defaultMaxMemory = document.getElementById("defaultMaxMemory"); |
---|
373 | defaultMaxMemory.innerHTML = frm.maxMemory.value == '' ? 'not specified' : frm.maxMemory.value; |
---|
374 | |
---|
375 | // Set trusted |
---|
376 | Forms.checkRadio(frm.agentTrusted, settings.trusted); |
---|
377 | var defaultTrusted = document.getElementById("defaultTrusted"); |
---|
378 | defaultTrusted.innerHTML = Forms.getCheckedRadio(frm.trusted).value == '0' ? 'no' : 'yes'; |
---|
379 | |
---|
380 | // Set priority boost |
---|
381 | frm.agentPriorityBoost.value = settings.priorityBoost; |
---|
382 | } |
---|
383 | else |
---|
384 | { |
---|
385 | Main.hide('agentsettings'); |
---|
386 | } |
---|
387 | } |
---|
388 | |
---|
389 | function useDefaultJarPathOnClick() |
---|
390 | { |
---|
391 | var frm = document.forms['plugin']; |
---|
392 | var settings = getAgentSettings(selectedAgentId); |
---|
393 | if (settings) |
---|
394 | { |
---|
395 | var useDefault = frm.useDefaultJarPath.checked; |
---|
396 | settings.useDefaultJarPath = useDefault; |
---|
397 | frm.agentJarPath.disabled = useDefault; |
---|
398 | if (!useDefault) |
---|
399 | { |
---|
400 | frm.agentJarPath.focus(); |
---|
401 | frm.agentJarPath.value = settings.jarPath; |
---|
402 | } |
---|
403 | } |
---|
404 | } |
---|
405 | |
---|
406 | function jarPathOnBlur() |
---|
407 | { |
---|
408 | var frm = document.forms['plugin']; |
---|
409 | var settings = getAgentSettings(selectedAgentId); |
---|
410 | if (settings) |
---|
411 | { |
---|
412 | settings.jarPath = frm.agentJarPath.value; |
---|
413 | } |
---|
414 | } |
---|
415 | |
---|
416 | function useDefaultMaxMemoryOnClick() |
---|
417 | { |
---|
418 | var frm = document.forms['plugin']; |
---|
419 | var settings = getAgentSettings(selectedAgentId); |
---|
420 | if (settings) |
---|
421 | { |
---|
422 | var useDefault = frm.useDefaultMaxMemory.checked; |
---|
423 | settings.useDefaultMaxMemory = useDefault; |
---|
424 | frm.agentMaxMemory.disabled = useDefault; |
---|
425 | if (!useDefault) |
---|
426 | { |
---|
427 | frm.agentMaxMemory.focus(); |
---|
428 | frm.agentMaxMemory.value = settings.maxMemory; |
---|
429 | } |
---|
430 | } |
---|
431 | } |
---|
432 | |
---|
433 | function maxMemoryOnBlur() |
---|
434 | { |
---|
435 | var frm = document.forms['plugin']; |
---|
436 | var settings = getAgentSettings(selectedAgentId); |
---|
437 | if (settings) |
---|
438 | { |
---|
439 | settings.maxMemory = frm.agentMaxMemory.value; |
---|
440 | } |
---|
441 | } |
---|
442 | |
---|
443 | function trustedOnClick() |
---|
444 | { |
---|
445 | var frm = document.forms['plugin']; |
---|
446 | var settings = getAgentSettings(selectedAgentId); |
---|
447 | if (settings) |
---|
448 | { |
---|
449 | var selected = Forms.getCheckedRadio(frm.agentTrusted); |
---|
450 | if (selected != null) |
---|
451 | { |
---|
452 | settings.trusted = selected.value; |
---|
453 | settings.useDefaultTrusted = settings.trusted == ''; |
---|
454 | } |
---|
455 | } |
---|
456 | } |
---|
457 | |
---|
458 | function priorityBoostOnBlur() |
---|
459 | { |
---|
460 | var frm = document.forms['plugin']; |
---|
461 | var settings = getAgentSettings(selectedAgentId); |
---|
462 | if (settings) |
---|
463 | { |
---|
464 | var priorityBoost = parseInt(frm.agentPriorityBoost.value); |
---|
465 | if (priorityBoost < 0 || priorityBoost > 10) |
---|
466 | { |
---|
467 | alert('The priority boost must be between 0 and 10'); |
---|
468 | frm.agentPriorityBoost.focus(); |
---|
469 | return; |
---|
470 | } |
---|
471 | settings.priorityBoost = priorityBoost; |
---|
472 | } |
---|
473 | } |
---|
474 | |
---|
475 | function usePermissionsOnClick() |
---|
476 | { |
---|
477 | var frm = document.forms['plugin']; |
---|
478 | var use = Forms.getCheckedRadio(frm.use_permissions).value == '1'; |
---|
479 | frm.items.disabled = !use; |
---|
480 | frm.grant_create.disabled = !use; |
---|
481 | frm.grant_read.disabled = !use; |
---|
482 | frm.grant_use.disabled = !use; |
---|
483 | frm.grant_write.disabled = !use; |
---|
484 | frm.grant_delete.disabled = !use; |
---|
485 | frm.grant_set_owner.disabled = !use; |
---|
486 | frm.grant_set_permission.disabled = !use; |
---|
487 | frm.deny_create.disabled = !use; |
---|
488 | frm.deny_read.disabled = !use; |
---|
489 | frm.deny_use.disabled = !use; |
---|
490 | frm.deny_write.disabled = !use; |
---|
491 | frm.deny_delete.disabled = !use; |
---|
492 | frm.deny_set_owner.disabled = !use; |
---|
493 | frm.deny_set_permission.disabled = !use; |
---|
494 | } |
---|
495 | |
---|
496 | function initPermissions() |
---|
497 | { |
---|
498 | var frm = document.forms['plugin']; |
---|
499 | for (var i = 0; i < frm.items.length; i++) |
---|
500 | { |
---|
501 | updateListText(i); |
---|
502 | } |
---|
503 | usePermissionsOnClick(); |
---|
504 | } |
---|
505 | |
---|
506 | /* |
---|
507 | Update the permission code string for the list entry with given index |
---|
508 | */ |
---|
509 | function updateListText(index) |
---|
510 | { |
---|
511 | var frm = document.forms['plugin']; |
---|
512 | var item = frm.items[index]; |
---|
513 | var itemType = item.value; |
---|
514 | if (itemType) |
---|
515 | { |
---|
516 | var granted = parseInt(frm[itemType+'_granted'].value); |
---|
517 | var denied = parseInt(frm[itemType+'_denied'].value); |
---|
518 | var defined = parseInt(frm[itemType+'_defined'].value); |
---|
519 | |
---|
520 | var s = ''; |
---|
521 | s += appendPermission('C', granted, denied, defined, <%=CREATE_CODE%>); |
---|
522 | s += appendPermission('R', granted, denied, defined, <%=READ_CODE%>); |
---|
523 | s += appendPermission('U', granted, denied, defined, <%=USE_CODE%>); |
---|
524 | s += appendPermission('W', granted, denied, defined, <%=WRITE_CODE%>); |
---|
525 | s += appendPermission('D', granted, denied, defined, <%=DELETE_CODE%>); |
---|
526 | s += appendPermission('O', granted, denied, defined, <%=SET_OWNER_CODE%>); |
---|
527 | s += appendPermission('P', granted, denied, defined, <%=SET_PERMISSION_CODE%>); |
---|
528 | |
---|
529 | var text = item.text.replace(/\[.*\]/, '['+s+']'); |
---|
530 | item.text = text; |
---|
531 | } |
---|
532 | } |
---|
533 | |
---|
534 | function appendPermission(cc, granted, denied, defined, permission) |
---|
535 | { |
---|
536 | var p = ''; |
---|
537 | if ((defined & permission) > 0) |
---|
538 | { |
---|
539 | p = (granted & permission) > 0 ? cc.toUpperCase() : ((denied & permission) > 0 ? '-' : cc.toLowerCase()); |
---|
540 | } |
---|
541 | return p; |
---|
542 | } |
---|
543 | |
---|
544 | function itemsOnClick() |
---|
545 | { |
---|
546 | var frm = document.forms['plugin']; |
---|
547 | var itemType = frm.items[frm.items.selectedIndex].value; |
---|
548 | if (itemType) |
---|
549 | { |
---|
550 | showPermissions(itemType); |
---|
551 | } |
---|
552 | } |
---|
553 | |
---|
554 | /* |
---|
555 | Update checkboxes to show the permissions for specified item type |
---|
556 | */ |
---|
557 | function showPermissions(itemType) |
---|
558 | { |
---|
559 | var frm = document.forms['plugin']; |
---|
560 | if (itemType) |
---|
561 | { |
---|
562 | var granted = parseInt(frm[itemType+'_granted'].value); |
---|
563 | var denied = parseInt(frm[itemType+'_denied'].value); |
---|
564 | var defined = parseInt(frm[itemType+'_defined'].value); |
---|
565 | |
---|
566 | updateCheckBox('create', <%=CREATE_CODE%>, granted, denied, defined); |
---|
567 | updateCheckBox('read', <%=READ_CODE%>, granted, denied, defined); |
---|
568 | updateCheckBox('use', <%=USE_CODE%>, granted, denied, defined); |
---|
569 | updateCheckBox('write', <%=WRITE_CODE%>, granted, denied, defined); |
---|
570 | updateCheckBox('delete', <%=DELETE_CODE%>, granted, denied, defined); |
---|
571 | updateCheckBox('set_owner', <%=SET_OWNER_CODE%>, granted, denied, defined); |
---|
572 | updateCheckBox('set_permission', <%=SET_PERMISSION_CODE%>, granted, denied, defined); |
---|
573 | } |
---|
574 | } |
---|
575 | |
---|
576 | /* |
---|
577 | Check/uncheck and enable/disable checkboxes depending on given permissions |
---|
578 | */ |
---|
579 | function updateCheckBox(nameSuffix, permission, granted, denied, defined) |
---|
580 | { |
---|
581 | var frm = document.forms['plugin']; |
---|
582 | var isGranted = (permission & granted) > 0; |
---|
583 | var isDenied = (permission & denied) > 0; |
---|
584 | var isDefined = (permission & defined) > 0; |
---|
585 | |
---|
586 | frm['grant_'+nameSuffix].disabled = !isDefined; |
---|
587 | frm['deny_'+nameSuffix].disabled = !isDefined || isGranted; |
---|
588 | frm['grant_'+nameSuffix].checked = isGranted & isDefined; |
---|
589 | frm['deny_'+nameSuffix].checked = isDenied & isDefined; |
---|
590 | } |
---|
591 | |
---|
592 | |
---|
593 | // When a user clicks on one of the permission checkboxes |
---|
594 | function permissionOnClick(checkbox) |
---|
595 | { |
---|
596 | var frm = document.forms['plugin']; |
---|
597 | cascadeSelections(checkbox.checked); |
---|
598 | var granted = getCheckedPermissions('grant_'); |
---|
599 | var denied = getCheckedPermissions('deny_'); |
---|
600 | for (var i = 0; i < frm.items.length; i++) |
---|
601 | { |
---|
602 | var item = frm.items[i]; |
---|
603 | var itemType = item.value; |
---|
604 | if (item.selected && itemType) |
---|
605 | { |
---|
606 | frm[itemType+'_granted'].value = granted; |
---|
607 | frm[itemType+'_denied'].value = denied; |
---|
608 | updateListText(i); |
---|
609 | } |
---|
610 | } |
---|
611 | } |
---|
612 | |
---|
613 | /* |
---|
614 | Get the permission for the checked checkboxes |
---|
615 | prefix should be "grant_" or "deny_" |
---|
616 | */ |
---|
617 | function getCheckedPermissions(prefix) |
---|
618 | { |
---|
619 | var permissionCode = 0; |
---|
620 | var frm = document.forms['plugin']; |
---|
621 | permissionCode += frm[prefix+'create'].checked ? <%=CREATE_CODE%>: 0; |
---|
622 | permissionCode += frm[prefix+'read'].checked ? <%=READ_CODE%>: 0; |
---|
623 | permissionCode += frm[prefix+'use'].checked ? <%=USE_CODE%>: 0; |
---|
624 | permissionCode += frm[prefix+'write'].checked ? <%=WRITE_CODE%>: 0; |
---|
625 | permissionCode += frm[prefix+'delete'].checked ? <%=DELETE_CODE%>: 0; |
---|
626 | permissionCode += frm[prefix+'set_owner'].checked ? <%=SET_OWNER_CODE%>: 0; |
---|
627 | permissionCode += frm[prefix+'set_permission'].checked ? <%=SET_PERMISSION_CODE%>: 0; |
---|
628 | return permissionCode; |
---|
629 | } |
---|
630 | /* |
---|
631 | Makes sure all checkboxes are in a consistent state with |
---|
632 | each other. |
---|
633 | */ |
---|
634 | function cascadeSelections(checked) |
---|
635 | { |
---|
636 | var frm = document.forms['plugin']; |
---|
637 | |
---|
638 | // Grant permissions |
---|
639 | if (checked) |
---|
640 | { |
---|
641 | frm['grant_write'].checked = (frm['grant_write'].checked || frm['grant_delete'].checked || frm['grant_set_owner'].checked || frm['grant_set_permission'].checked); |
---|
642 | frm['grant_use'].checked = (frm['grant_use'].checked || frm['grant_write'].checked); |
---|
643 | frm['grant_read'].checked = (frm['grant_read'].checked || frm['grant_use'].checked); |
---|
644 | } |
---|
645 | else |
---|
646 | { |
---|
647 | frm['grant_use'].checked = (frm['grant_use'].checked && frm['grant_read'].checked); |
---|
648 | frm['grant_write'].checked = (frm['grant_write'].checked && frm['grant_use'].checked); |
---|
649 | frm['grant_delete'].checked = (frm['grant_delete'].checked && frm['grant_write'].checked); |
---|
650 | frm['grant_set_owner'].checked = (frm['grant_set_owner'].checked && frm['grant_write'].checked); |
---|
651 | frm['grant_set_permission'].checked = (frm['grant_set_permission'].checked && frm['grant_write'].checked); |
---|
652 | } |
---|
653 | |
---|
654 | // Deny permissions |
---|
655 | frm['deny_create'].disabled = frm['grant_create'].disabled || frm['grant_create'].checked; |
---|
656 | frm['deny_read'].disabled =frm['grant_read'].disabled || frm['grant_read'].checked; |
---|
657 | frm['deny_use'].disabled = frm['grant_use'].disabled || frm['grant_use'].checked; |
---|
658 | frm['deny_write'].disabled = frm['grant_write'].disabled || frm['grant_write'].checked; |
---|
659 | frm['deny_delete'].disabled = frm['grant_delete'].disabled || frm['grant_delete'].checked; |
---|
660 | frm['deny_set_owner'].disabled = frm['grant_set_owner'].disabled || frm['grant_set_owner'].checked; |
---|
661 | frm['deny_set_permission'].disabled = frm['grant_set_permission'].disabled || frm['grant_set_permission'].checked; |
---|
662 | if (checked) |
---|
663 | { |
---|
664 | if (!frm['deny_use'].disabled) frm['deny_use'].checked = frm['deny_use'].checked || frm['deny_read'].checked; |
---|
665 | if (!frm['deny_write'].disabled) frm['deny_write'].checked = frm['deny_write'].checked || frm['deny_use'].checked; |
---|
666 | if (!frm['deny_delete'].disabled) frm['deny_delete'].checked = frm['deny_delete'].checked || frm['deny_write'].checked; |
---|
667 | if (!frm['deny_set_owner'].disabled) frm['deny_set_owner'].checked = frm['deny_set_owner'].checked || frm['deny_write'].checked; |
---|
668 | if (!frm['deny_set_permission'].disabled) frm['deny_set_permission'].checked = frm['deny_set_permission'].checked || frm['deny_write'].checked; |
---|
669 | } |
---|
670 | else |
---|
671 | { |
---|
672 | if (!frm['deny_write'].disabled) frm['deny_write'].checked = frm['deny_write'].checked && !((!frm['deny_delete'].checked && !frm['deny_delete'].disabled) || (!frm['deny_set_owner'].checked && !frm['deny_set_owner'].disabled) || (!frm['deny_set_permission'].checked && !frm['deny_set_permission'].disabled)); |
---|
673 | if (!frm['deny_use'].disabled) frm['deny_use'].checked = frm['deny_use'].checked && frm['deny_write'].checked; |
---|
674 | if (!frm['deny_read'].disabled) frm['deny_read'].checked = frm['deny_read'].checked && frm['deny_use'].checked; |
---|
675 | } |
---|
676 | } |
---|
677 | <% |
---|
678 | if (requestedPermissions != null && requestedPermissions.size() > 0) |
---|
679 | { |
---|
680 | %> |
---|
681 | function setRequestedPermissions() |
---|
682 | { |
---|
683 | var frm = document.forms['plugin']; |
---|
684 | // Reset all existing permissions |
---|
685 | for (var i = 0; i < frm.items.length; i++) |
---|
686 | { |
---|
687 | var itemType = frm.items[i].value; |
---|
688 | if (itemType) |
---|
689 | { |
---|
690 | frm[itemType+'_granted'].value = 0; |
---|
691 | frm[itemType+'_denied'].value = 255; |
---|
692 | } |
---|
693 | } |
---|
694 | // Set requested permissions |
---|
695 | <% |
---|
696 | for (Permissions pp : requestedPermissions) |
---|
697 | { |
---|
698 | Item ppType = pp.getItemType(); |
---|
699 | if (ppType.getDefinedPermissions() != null) |
---|
700 | { |
---|
701 | Set<Permission> always = Permission.expand(pp.getAlwaysGranted()); |
---|
702 | Set<Permission> maybe = Permission.expand(pp.getMaybeGranted()); |
---|
703 | %> |
---|
704 | frm['<%=ppType.name()%>_granted'].value = <%=always == null ? 0 : PermissionUtil.getPermissionCode(always)%>; |
---|
705 | frm['<%=ppType.name()%>_denied'].value = <%=maybe == null ? 255 : 255 & ~PermissionUtil.getPermissionCode(maybe)%>; |
---|
706 | <% |
---|
707 | } |
---|
708 | } |
---|
709 | %> |
---|
710 | // Update the list |
---|
711 | initPermissions(); |
---|
712 | } |
---|
713 | <% |
---|
714 | } |
---|
715 | %> |
---|
716 | </script> |
---|
717 | </base:head> |
---|
718 | <base:body onload="init()"> |
---|
719 | <p> |
---|
720 | <form action="index.jsp?ID=<%=ID%>" method="post" name="plugin" onsubmit="return false;"> |
---|
721 | <input type="hidden" name="cmd" value="UpdateItem"> |
---|
722 | |
---|
723 | <h3 class="docked"><%=title%> <base:help tabcontrol="settings" /></h3> |
---|
724 | <t:tabcontrol id="settings" contentstyle="<%="height: "+(int)(scale*300)+"px;"%>" |
---|
725 | position="bottom" remember="<%=plugin != null%>" active="<%=selectedAgentId == -1 ? null : "agents" %>"> |
---|
726 | <t:tab id="info" title="Plugin" validate="validatePlugin()" helpid="plugindefinition.edit"> |
---|
727 | <table class="form" cellspacing=0> |
---|
728 | <tr> |
---|
729 | <td class="prompt">Name</td> |
---|
730 | <td><%=HTML.encodeTags(plugin == null ? Values.getString(cc.getPropertyValue("name"), "New plugin") : plugin.getName())%></td> |
---|
731 | </tr> |
---|
732 | <tr> |
---|
733 | <td class="prompt">Class</td> |
---|
734 | <td><input <%=requiredClazz%> type="text" name="className" |
---|
735 | value="<%=HTML.encodeTags(plugin == null ? cc.getPropertyValue("className") : plugin.getClassName())%>" |
---|
736 | size="50" maxlength="<%=PluginDefinition.MAX_CLASSNAME_LENGTH%>"></td> |
---|
737 | </tr> |
---|
738 | |
---|
739 | <tr> |
---|
740 | <td class="prompt">Path</td> |
---|
741 | <td><input <%=clazz%> type="text" name="jarPath" |
---|
742 | value="<%=HTML.encodeTags(plugin == null ? cc.getPropertyValue("jarPath") : plugin.getJarPath())%>" |
---|
743 | size="50" maxlength="<%=PluginDefinition.MAX_JARPATH_LENGTH%>"> |
---|
744 | </td> |
---|
745 | </tr> |
---|
746 | <tr> |
---|
747 | <td class="prompt">Max memory</td> |
---|
748 | <td><input <%=clazz%> type="text" name="maxMemory" |
---|
749 | value="<%=Values.formatBytes(plugin == null ? Values.parseBytes(cc.getPropertyValue("maxMemory"), null) : plugin.getMaxMemory())%>" |
---|
750 | size="16" maxlength="16"> (Use KB, MB or GB to specify units)</td> |
---|
751 | </tr> |
---|
752 | |
---|
753 | <tr> |
---|
754 | <td class="prompt">Trusted</td> |
---|
755 | <td> |
---|
756 | <input type="radio" name="trusted" value="0" <%=!isTrusted ? "checked" : ""%>>no |
---|
757 | <input type="radio" name="trusted" value="1" <%=isTrusted ? "checked" : ""%>>yes |
---|
758 | </td> |
---|
759 | </tr> |
---|
760 | |
---|
761 | <tr> |
---|
762 | <td class="prompt">Allow immediate exection</td> |
---|
763 | <td> |
---|
764 | <input type="radio" name="allow_immediate_execution" value="0" |
---|
765 | <%=Boolean.FALSE.equals(allowImmediateExecution) ? "checked" : ""%>>no |
---|
766 | <input type="radio" name="allow_immediate_execution" value="1" |
---|
767 | <%=Boolean.TRUE.equals(allowImmediateExecution) ? "checked" : ""%>>yes |
---|
768 | <% |
---|
769 | if (allowImmediateExecution == null) |
---|
770 | { |
---|
771 | %> |
---|
772 | <input type="radio" name="allow_immediate_execution" value="" |
---|
773 | "checked">auto |
---|
774 | <% |
---|
775 | } |
---|
776 | %> |
---|
777 | </td> |
---|
778 | </tr> |
---|
779 | </table> |
---|
780 | <% |
---|
781 | if (warning != null) |
---|
782 | { |
---|
783 | %> |
---|
784 | <div class="error"><%=warning%></div> |
---|
785 | <% |
---|
786 | } |
---|
787 | %> |
---|
788 | <div align=right> <i><base:icon image="required.gif" /> = required information</i></div> |
---|
789 | </t:tab> |
---|
790 | |
---|
791 | <t:tab id="permissions" title="Permissions" |
---|
792 | tooltip="Set permissions for this plugindefintion" helpid="plugindefinition.edit.permissions"> |
---|
793 | <table class="form"> |
---|
794 | <tr> |
---|
795 | <td class="prompt">Use permissions</td> |
---|
796 | <td> |
---|
797 | <input type="radio" name="use_permissions" value="1" |
---|
798 | <%=usePermissions ? "checked" : ""%> onclick="usePermissionsOnClick()">yes |
---|
799 | <input type="radio" name="use_permissions" value="0" |
---|
800 | <%=!usePermissions ? "checked" : ""%> onclick="usePermissionsOnClick()">no |
---|
801 | <% |
---|
802 | if (plugin == null) |
---|
803 | { |
---|
804 | %> |
---|
805 | <input type="radio" name="use_permissions" value="2" |
---|
806 | onclick="usePermissionsOnClick()">if requested by plugin |
---|
807 | <% |
---|
808 | } |
---|
809 | %> |
---|
810 | </td> |
---|
811 | </tr> |
---|
812 | </table> |
---|
813 | |
---|
814 | <table> |
---|
815 | <tr valign="top"> |
---|
816 | <td> |
---|
817 | <b>Item types</b><br> |
---|
818 | <select name="items" size="15" onChange="itemsOnClick()" multiple> |
---|
819 | <% |
---|
820 | Map<String, List<Item>> permissionGroups = PermissionUtil.getPermissionGroups(); |
---|
821 | for (Map.Entry<String, List<Item>> entry : permissionGroups.entrySet()) |
---|
822 | { |
---|
823 | String name = entry.getKey(); |
---|
824 | List<Item> items = entry.getValue(); |
---|
825 | %> |
---|
826 | <option class="selectoptionheader" value="">-- <%=name%> |
---|
827 | <% |
---|
828 | for (Item item : items) |
---|
829 | { |
---|
830 | %> |
---|
831 | <%=getOption(dc, plugin, item)%> |
---|
832 | <% |
---|
833 | } |
---|
834 | } |
---|
835 | %> |
---|
836 | </select> |
---|
837 | </td> |
---|
838 | <td> |
---|
839 | <table> |
---|
840 | <tr valign="top"><td> |
---|
841 | <b>Always grant</b><br> |
---|
842 | <input type="checkbox" name="grant_create" onClick="permissionOnClick(this)">Create<br> |
---|
843 | <input type="checkbox" name="grant_read" onClick="permissionOnClick(this)">Read<br> |
---|
844 | <input type="checkbox" name="grant_use" onClick="permissionOnClick(this)">Use<br> |
---|
845 | <input type="checkbox" name="grant_write" onClick="permissionOnClick(this)">Write<br> |
---|
846 | <input type="checkbox" name="grant_delete" onClick="permissionOnClick(this)">Delete<br> |
---|
847 | <input type="checkbox" name="grant_set_owner" onClick="permissionOnClick(this)">Take ownership<br> |
---|
848 | <input type="checkbox" name="grant_set_permission" onClick="permissionOnClick(this)">Set permission |
---|
849 | </td> |
---|
850 | <td> |
---|
851 | <b>Always deny</b><br> |
---|
852 | <input type="checkbox" name="deny_create" onClick="permissionOnClick(this)">Create<br> |
---|
853 | <input type="checkbox" name="deny_read" onClick="permissionOnClick(this)">Read<br> |
---|
854 | <input type="checkbox" name="deny_use" onClick="permissionOnClick(this)">Use<br> |
---|
855 | <input type="checkbox" name="deny_write" onClick="permissionOnClick(this)">Write<br> |
---|
856 | <input type="checkbox" name="deny_delete" onClick="permissionOnClick(this)">Delete<br> |
---|
857 | <input type="checkbox" name="deny_set_owner" onClick="permissionOnClick(this)">Take ownership<br> |
---|
858 | <input type="checkbox" name="deny_set_permission" onClick="permissionOnClick(this)">Set permission |
---|
859 | </td> |
---|
860 | <% |
---|
861 | if (requestedPermissions != null && requestedPermissions.size() > 0) |
---|
862 | { |
---|
863 | %> |
---|
864 | <td> |
---|
865 | <b>Requested by plugin</b><br> |
---|
866 | <table> |
---|
867 | <% |
---|
868 | for (Permissions pp : requestedPermissions) |
---|
869 | { |
---|
870 | Item ppType = pp.getItemType(); |
---|
871 | Set<Permission> always = Permission.expand(pp.getAlwaysGranted()); |
---|
872 | Set<Permission> maybe = Permission.expand(pp.getMaybeGranted()); |
---|
873 | Set<Permission> defined = ppType.getDefinedPermissions(); |
---|
874 | if (defined != null) |
---|
875 | { |
---|
876 | StringBuilder sb = new StringBuilder(); |
---|
877 | sb.append("["); |
---|
878 | appendPermissionLetter(sb, Permission.CREATE, "C", defined, always, maybe); |
---|
879 | appendPermissionLetter(sb, Permission.READ, "R", defined, always, maybe); |
---|
880 | appendPermissionLetter(sb, Permission.USE, "U", defined, always, maybe); |
---|
881 | appendPermissionLetter(sb, Permission.WRITE, "W", defined, always, maybe); |
---|
882 | appendPermissionLetter(sb, Permission.DELETE, "D", defined, always, maybe); |
---|
883 | appendPermissionLetter(sb, Permission.SET_OWNER, "O", defined, always, maybe); |
---|
884 | appendPermissionLetter(sb, Permission.SET_PERMISSION, "P", defined, always, maybe); |
---|
885 | sb.append("]"); |
---|
886 | %> |
---|
887 | <tr> |
---|
888 | <td><%=ppType%></td> |
---|
889 | <td><%=sb.toString()%></td> |
---|
890 | </tr> |
---|
891 | <% |
---|
892 | } |
---|
893 | } |
---|
894 | %> |
---|
895 | </table> |
---|
896 | <table><tr><td> |
---|
897 | <base:button title="Use requested permissions" onclick="setRequestedPermissions()" |
---|
898 | tooltip="Use the permissions requested by the plugin." /> |
---|
899 | </td></tr></table> |
---|
900 | </td> |
---|
901 | <% |
---|
902 | } |
---|
903 | %> |
---|
904 | </tr> |
---|
905 | </table> |
---|
906 | <b>Capital letters</b> = Permission is always granted<br> |
---|
907 | <b>Small letters</b> = Permission is only granted if logged in user |
---|
908 | has that permission |
---|
909 | |
---|
910 | </td> |
---|
911 | </tr> |
---|
912 | </table> |
---|
913 | |
---|
914 | |
---|
915 | </t:tab> |
---|
916 | |
---|
917 | |
---|
918 | <t:tab id="agents" title="Job agents" helpid="plugindefinition.jobagents"> |
---|
919 | <table class="form"> |
---|
920 | <tr valign="top"> |
---|
921 | <td class="prompt">Run this plugin on</td> |
---|
922 | <td> |
---|
923 | <input type="checkbox" name="use_internal_jobqueue" value="1" |
---|
924 | <%=plugin == null || plugin.getUseInternalJobQueue() ? "checked" : "" %>> |
---|
925 | internal job queue |
---|
926 | </td> |
---|
927 | </tr> |
---|
928 | <tr> |
---|
929 | <td> |
---|
930 | <select name="agents" size="12" multiple style="width: 15em;" |
---|
931 | onclick="agentsOnClick()"> |
---|
932 | </select> |
---|
933 | <input type="hidden" name="removeAgents" value=""> |
---|
934 | <input type="hidden" name="allAgents" value=""> |
---|
935 | </td> |
---|
936 | <td> |
---|
937 | <table width="150"> |
---|
938 | <tr><td><base:button |
---|
939 | onclick="addAgentsOnClick()" |
---|
940 | title="Add job agents…" |
---|
941 | tooltip="Add job agents to this plugin" |
---|
942 | /></td></tr> |
---|
943 | <tr><td><base:button |
---|
944 | onclick="removeOnClick()" |
---|
945 | title="Remove" |
---|
946 | tooltip="Remove the selected job agents" |
---|
947 | /></td></tr> |
---|
948 | </table> |
---|
949 | |
---|
950 | <br> |
---|
951 | <div id="agentsettings" style="display: none;"> |
---|
952 | <b>Settings for the selected job agent</b> |
---|
953 | <table border="0" cellspacing="0" class="form"> |
---|
954 | <tr> |
---|
955 | <td class="prompt">Jar path</td> |
---|
956 | <td> |
---|
957 | <input type="text" name="agentJarPath" class="text" size="50" |
---|
958 | maxlength="<%=JobAgentSettings.MAX_JARPATH_LENGTH%>" |
---|
959 | onblur="jarPathOnBlur()"> |
---|
960 | </td> |
---|
961 | </tr> |
---|
962 | <tr> |
---|
963 | <td style="padding-left: 10px;">-use default</td> |
---|
964 | <td> |
---|
965 | <input type="checkbox" name="useDefaultJarPath" |
---|
966 | onclick="useDefaultJarPathOnClick()"> |
---|
967 | (<span id="defaultJarPath"></span>) |
---|
968 | </td> |
---|
969 | </tr> |
---|
970 | <tr> |
---|
971 | <td class="prompt">Max memory</td> |
---|
972 | <td> |
---|
973 | <input type="text" name="agentMaxMemory" class="text" size="16" |
---|
974 | maxlength="16" |
---|
975 | onblur="maxMemoryOnBlur()"> |
---|
976 | (Use KB, MB or GB to specify memory) |
---|
977 | </td> |
---|
978 | </tr> |
---|
979 | <tr> |
---|
980 | <td style="padding-left: 10px;">-use default</td> |
---|
981 | <td> |
---|
982 | <input type="checkbox" name="useDefaultMaxMemory" |
---|
983 | onclick="useDefaultMaxMemoryOnClick()"> |
---|
984 | (<span id="defaultMaxMemory"></span>) |
---|
985 | </td> |
---|
986 | </tr> |
---|
987 | <tr> |
---|
988 | <td class="prompt">Trusted</td> |
---|
989 | <td> |
---|
990 | <input type="radio" name="agentTrusted" value="" |
---|
991 | onclick="trustedOnClick()">default (<span id="defaultTrusted"></span>) |
---|
992 | <input type="radio" name="agentTrusted" value="1" |
---|
993 | onclick="trustedOnClick()">yes |
---|
994 | <input type="radio" name="agentTrusted" value="0" |
---|
995 | onclick="trustedOnClick()">no |
---|
996 | </td> |
---|
997 | </tr> |
---|
998 | <tr> |
---|
999 | <td class="prompt">Priority boost</td> |
---|
1000 | <td> |
---|
1001 | <input type="text" name="agentPriorityBoost" class="text" size="12" |
---|
1002 | maxlength="10" onkeypress="return Numbers.integerOnly(event)" |
---|
1003 | onblur="priorityBoostOnBlur()"> |
---|
1004 | </td> |
---|
1005 | </tr> |
---|
1006 | </table> |
---|
1007 | </div> |
---|
1008 | </td> |
---|
1009 | </tr> |
---|
1010 | </table> |
---|
1011 | </t:tab> |
---|
1012 | |
---|
1013 | </t:tabcontrol> |
---|
1014 | |
---|
1015 | <table align="center"> |
---|
1016 | <tr> |
---|
1017 | <td width="50%"><base:button onclick="saveSettings()" title="Save" /></td> |
---|
1018 | <td width="50%"><base:button onclick="window.close()" title="Cancel" /></td> |
---|
1019 | </tr> |
---|
1020 | </table> |
---|
1021 | <% |
---|
1022 | ItemResultList<RoleKey> roleKeys = roleKeyQuery.list(dc); |
---|
1023 | for (RoleKey key : roleKeys) |
---|
1024 | { |
---|
1025 | int grantedCode = plugin == null ? 0 : PermissionUtil.getPermissionCode(plugin.getGranted(key)); |
---|
1026 | int deniedCode = plugin == null ? 255 : PermissionUtil.getPermissionCode(plugin.getDenied(key)); |
---|
1027 | int definedCode = key.getItemType().getDefinedPermissions() == null ? 0 : PermissionUtil.getPermissionCode(key.getItemType().getDefinedPermissions()); |
---|
1028 | String name = key.getItemType().name(); |
---|
1029 | %> |
---|
1030 | <input type="hidden" name="<%=name%>_granted" value="<%=grantedCode%>"> |
---|
1031 | <input type="hidden" name="<%=name%>_denied" value="<%=deniedCode%>"> |
---|
1032 | <input type="hidden" name="<%=name%>_defined" value="<%=definedCode%>"> |
---|
1033 | <% |
---|
1034 | } |
---|
1035 | %> |
---|
1036 | </form> |
---|
1037 | </base:body> |
---|
1038 | </base:page> |
---|
1039 | <% |
---|
1040 | } |
---|
1041 | finally |
---|
1042 | { |
---|
1043 | if (dc != null) dc.close(); |
---|
1044 | } |
---|
1045 | %> |
---|