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