source: trunk/www/admin/plugindefinitions/index.jsp @ 4906

Last change on this file since 4906 was 4906, checked in by Martin Svensson, 13 years ago

References #1128 More item-pages updated

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 21.6 KB
Line 
1<%-- $Id: index.jsp 4906 2009-04-24 13:53:14Z martin $
2  ------------------------------------------------------------------
3  Copyright (C) 2005 Nicklas Nordborg
4  Copyright (C) 2006 Jari Häkkinen, Nicklas Nordborg, Martin Svensson
5  Copyright (C) 2007 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  @author Nicklas
25  @version 2.0
26--%>
27<%@ page session="false"
28  import="net.sf.basedb.core.Application"
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.Include"
33  import="net.sf.basedb.core.PluginDefinition"
34  import="net.sf.basedb.core.JobAgent"
35  import="net.sf.basedb.core.JobAgentSettings"
36  import="net.sf.basedb.core.ItemQuery"
37  import="net.sf.basedb.core.ItemResultList"
38  import="net.sf.basedb.core.Permission"
39  import="net.sf.basedb.core.ItemContext"
40  import="net.sf.basedb.core.MultiPermissions"
41  import="net.sf.basedb.core.OwnedItem"
42  import="net.sf.basedb.core.BaseException"
43  import="net.sf.basedb.core.PermissionDeniedException"
44  import="net.sf.basedb.core.PluginConfiguration"
45  import="net.sf.basedb.core.ItemAlreadyExistsException"
46  import="net.sf.basedb.core.RoleKey"
47  import="net.sf.basedb.core.plugin.Plugin"
48  import="net.sf.basedb.core.query.Expressions"
49  import="net.sf.basedb.core.query.Hql"
50  import="net.sf.basedb.core.query.Orders"
51  import="net.sf.basedb.core.query.Restrictions"
52  import="net.sf.basedb.util.FileUtil"
53  import="net.sf.basedb.util.PluginInfo"
54  import="net.sf.basedb.util.PluginConfigInfo"
55  import="net.sf.basedb.util.RemovableUtil"
56  import="net.sf.basedb.util.ShareableUtil"
57  import="net.sf.basedb.util.OwnableUtil"
58  import="net.sf.basedb.util.JarClassLoader"
59  import="net.sf.basedb.util.RegexpFileFilter"
60  import="net.sf.basedb.util.Values"
61  import="net.sf.basedb.util.formatter.NameableFormatter"
62  import="net.sf.basedb.clients.web.Base"
63  import="net.sf.basedb.clients.web.PermissionUtil"
64  import="net.sf.basedb.clients.web.WebException" 
65  import="net.sf.basedb.clients.web.plugins.ItemQueryLoader"
66  import="net.sf.basedb.clients.web.util.HTML"
67  import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
68  import="net.sf.basedb.plugins.PluginConfigurationImporter"
69  import="java.util.Enumeration"
70  import="java.util.Set"
71  import="java.util.Map"
72  import="java.util.LinkedHashMap"
73  import="java.util.HashMap"
74  import="java.util.HashSet"
75  import="java.util.List"
76  import="java.util.LinkedList"
77  import="java.util.Collections"
78  import="java.io.FileFilter"
79%>
80<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
81<%!
82  private static final ItemContext defaultContext = Base.createDefaultContext("name", "name,pluginType,className,description");
83  private static final Item itemType = Item.PLUGINDEFINITION;
84 
85  private static void registerExportUtils(ItemContext cc)
86  {
87    // Register formatters
88    cc.setObject("export.formatter.&configurations(name)", new NameableFormatter());
89   
90    // Register dataloaders
91    String pluginParameter = "plugin";
92    ItemQuery<PluginConfiguration> configQuery = PluginConfiguration.getQuery();
93    configQuery.include(cc.getInclude());
94    configQuery.restrict(Restrictions.eq(Hql.property("pluginDefinition"), Expressions.parameter("plugin")));
95    configQuery.order(Orders.asc(Hql.property("name"))); 
96    cc.setObject("export.dataloader.&configurations(name)", new ItemQueryLoader(configQuery, pluginParameter));
97  }
98%>
99<%
100final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
101final String ID = sc.getId();
102final String cmd = request.getParameter("cmd");
103final String root = request.getContextPath()+"/";
104final String mode = request.getParameter("mode");
105final String callback = request.getParameter("callback");
106final String itemId = request.getParameter("item_id");
107final String listPage = "list_plugins.jsp?ID="+ID
108  +(mode == null ? "" : "&mode="+mode)
109  +(callback == null ? "" : "&callback="+callback)
110  +(itemId == null ? "" : "&item_id="+itemId);
111final String viewPage = "view_plugin.jsp?ID="+ID;
112final String editPage = "edit_plugin.jsp?ID="+ID;
113
114String forward = null;
115String redirect = null;
116String message = null;
117DbControl dc = null;
118
119try
120{
121  if (cmd == null || "List".equals(cmd))
122  {
123    // Display the list page without updatinging the current context
124    Base.getAndSetCurrentContext(sc, itemType, null, defaultContext, true);
125    redirect = listPage;
126  }
127  else if ("UpdateContext".equals(cmd))
128  {
129    // Display the list page after updating the current context from the request parameters
130    Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
131    redirect = listPage;
132  }
133  else if ("LoadContext".equals(cmd))
134  {
135    // Display the list page after loading a saved context
136    int contextId = Values.getInt(request.getParameter("context"));
137    Base.loadContext(sc, contextId, defaultContext);
138    redirect = listPage;
139  }
140
141  else if ("ViewItem".equals(cmd))
142  {
143    // Display the view page for a single item
144    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
145    forward = viewPage;
146  }
147  else if ("EditItem".equals(cmd))
148  {
149    // Display the edit page for a single item (should be opened in a popup)
150    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
151    forward = editPage;
152  }
153  else if ("NewItem".equals(cmd))
154  {
155    // Display the edit page for a new item (should be opened in a popup)
156    if (!sc.hasPermission(Permission.CREATE, itemType))
157    {
158      throw new PermissionDeniedException(Permission.CREATE, itemType.toString());
159    }
160    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
161    cc.setId(0);
162   
163    redirect = "select_installation_type.jsp?ID="+ID;
164  }
165  else if("InstallationType".equals(cmd))
166  {
167    //Either manually or auto installation is selected
168    String type = request.getParameter("installationType");
169    if ("auto".equals(type))
170    {
171      forward = "auto_install.jsp?ID="+ID;
172    }
173    else
174    {
175      redirect = editPage;
176    }
177  }
178  else if("LoadPlugins".equals(cmd))
179  {
180    //Loads and install plugins that have been selected in auto_installer.jsp
181    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, defaultContext);
182    dc = sc.newDbControl();
183    java.io.File pluginDir = Application.getNonCorePluginDirectory();
184    java.io.File extensionsDir = new java.io.File(application.getRealPath(ExtensionsControl.EXTENSIONS_URL));
185    FileFilter jarFilter = new RegexpFileFilter(".*\\.jar", null);
186    List<java.io.File> jarFiles = new LinkedList<java.io.File>();
187    if (Values.getBoolean(request.getParameter("plugindir")))
188    {
189      jarFiles.addAll(FileUtil.findFiles(pluginDir, jarFilter));
190    }
191    if (Values.getBoolean(request.getParameter("extensionsdir")))
192    {
193      jarFiles.addAll(FileUtil.findFiles(extensionsDir, jarFilter));
194    }
195   
196    List<PluginInfo> pluginInfos = new LinkedList<PluginInfo>();
197    Map<PluginInfo, Throwable> installationResult = new LinkedHashMap<PluginInfo, Throwable>();
198   
199    //Get information about all plugins in jar-files that were found.
200    for (java.io.File file : jarFiles)
201    {
202      pluginInfos.addAll(PluginInfo.loadFromJar(file));
203    }
204    //Load selected plugins.
205    for (PluginInfo info : pluginInfos)
206    {
207      String selectedOption = request.getParameter(info.getJarPath() + ":" + info.getClassName());
208      if (selectedOption == null) selectedOption = "";     
209      boolean isInstalled = Values.getBoolean(request.getParameter(info.getClassName()+":isInstalled"));
210      boolean inSameJarFile = Values.getBoolean(request.getParameter(info.getClassName()+":inSameJarFile"));
211      if (selectedOption.equals("plugin") || selectedOption.equals("plugin+confs"))
212      {
213        //The plugin doesn't exists
214        if (!isInstalled)
215        {
216          PluginDefinition pd = null;
217          try
218          {
219            pd = PluginDefinition.getNew(dc, info.getClassName(), info.getJarPath(), true);
220            installationResult.put(info, null);
221          }
222          catch (Throwable t)
223          {
224            installationResult.put(info, new BaseException("Could not install: " + 
225                info.getClassName() + " in jar:" + info.getJarPath(), t));
226          }
227          if (pd != null)
228          {
229            dc.saveItem(pd);
230            pd.setTrusted(Values.getBoolean(request.getParameter(info.getClassName()+":trusted")));
231            String aie = Values.getStringOrNull(request.getParameter(info.getClassName()+":immediate_execution"));
232            pd.setAllowImmediateExecution(aie == null ? 
233              pd.getMainType() == Plugin.MainType.EXPORT : Values.getBoolean(aie));           
234          }
235        }
236        //The plugin exists but in a different jar, this will change the plugin's jarpath
237        else if (isInstalled && !inSameJarFile)
238        {
239          try 
240          {
241            PluginDefinition pd = PluginDefinition.getByClassName(dc, info.getClassName());
242            pd.loadPluginInformation(info.getJarPath(), info.getClassName(), true);
243            installationResult.put(info, null);
244          }
245          catch (Throwable t)
246          {
247            installationResult.put(info, new BaseException("Could not install: " + 
248                info.getClassName() + " in jar:" + info.getJarPath(), t));
249          }
250        }
251      }     
252    }
253    dc.commit();
254   
255    //Import selected configurations for each plugin in pluginInfos
256    dc = sc.newDbControl();
257    for (PluginInfo info : pluginInfos)
258    {
259      if (installationResult.get(info) != null) continue;
260     
261      List<PluginConfigInfo> configInfos = info.getConfigurations();
262      if (configInfos != null && configInfos.size() > 0)
263      {
264        HashMap<Integer, Boolean> configurations = new HashMap<Integer, Boolean>();
265        for (PluginConfigInfo cnfInfo : configInfos)
266        {
267          Boolean toImport = Values.getBoolean(request.getParameter(info.getClassName() + ":config:" + cnfInfo.getName()));
268          configurations.put(cnfInfo.getOrderInXml(), toImport);
269        }
270        try 
271        {
272          PluginConfigurationImporter configImporter = new PluginConfigurationImporter();
273          configImporter.init(sc, null, null);
274          configImporter.importPluginConfigurationsFromJar(info.getJarPath(), info.getConfigurationsPath(), configurations, false, true );
275        }
276        catch (Throwable t)
277        {
278          installationResult.put(info, 
279              new BaseException("Could not import configuration for: " + 
280              info.getClassName() + " in jar:" + info.getJarPath(), t));
281        }
282      }
283    }
284   
285    for (Map.Entry<PluginInfo, Throwable> entry : installationResult.entrySet())
286    {
287      Throwable t = entry.getValue();
288      if (t != null) t.printStackTrace();
289    }
290   
291    sc.setSessionSetting("pluginwizard.installationresult", installationResult);
292    redirect = "auto_install_result.jsp?ID=" + ID;
293  }
294  else if ("UpdateItem".equals(cmd))
295  {
296    // Update the properties on an item (will close the popup)
297    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, defaultContext);
298    dc = sc.newDbControl();
299    PluginDefinition plugin = (PluginDefinition)cc.getObject("item");
300    String className = Values.getStringOrNull(request.getParameter("className"));
301    String jarPath = Values.getStringOrNull(request.getParameter("jarPath"));
302    int usePermissions = Values.getInt(request.getParameter("use_permissions"));
303    if (plugin == null)
304    {
305      plugin = PluginDefinition.getNew(dc, className, jarPath, usePermissions == 2);
306      message = "Plugin created";
307      dc.saveItem(plugin);
308    }
309    else
310    {
311      dc.reattachItem(plugin);
312      plugin.loadPluginInformation(jarPath, className, usePermissions == 2);
313      message = "Plugin updated";
314    }
315    plugin.setMaxMemory(Values.parseBytes(request.getParameter("maxMemory"), null));
316    plugin.setTrusted(Values.getBoolean(request.getParameter("trusted")));
317    plugin.setUseInternalJobQueue(Values.getBoolean(request.getParameter("use_internal_jobqueue")));
318    String aie = Values.getStringOrNull(request.getParameter("allow_immediate_execution"));
319    plugin.setAllowImmediateExecution(aie == null ? 
320      plugin.getMainType() == Plugin.MainType.EXPORT : Values.getBoolean(aie));
321
322    //Update permissions
323    ItemQuery<RoleKey> q = RoleKey.getQuery();
324    q.setCacheResult(true);
325    ItemResultList<RoleKey> roleKeys = q.list(dc);
326    for (RoleKey key : roleKeys)
327    {
328      String name = key.getItemType().name();
329      int granted = Values.getInt(request.getParameter(name+"_granted"));
330      int denied = Values.getInt(request.getParameter(name+"_denied"));
331      plugin.setPermissions(key, PermissionUtil.getPermissions(granted), PermissionUtil.getPermissions(denied));
332    }
333    plugin.setUsePermissions(usePermissions != 0);
334   
335    // Installed on job agents
336    String[] removeAgents = Values.getString(request.getParameter("removeAgents")).split(",");
337    for (int i = 0; i < removeAgents.length; ++i)
338    {
339      int agentId = Values.getInt(removeAgents[i], -1);
340      if (agentId != -1) 
341      {
342        JobAgent agent = JobAgent.getById(dc, agentId);
343        JobAgentSettings settings = agent.getSettings(plugin, false);
344        if (settings != null && settings.isInDatabase()) dc.deleteItem(settings);
345      }
346    }
347
348    String[] allAgents = Values.getString(request.getParameter("allAgents")).split(",");
349    for (int i = 0; i < allAgents.length; ++i)
350    {
351      int agentId = Values.getInt(allAgents[i], -1);
352      if (agentId != -1) 
353      {
354        JobAgent agent = JobAgent.getById(dc, agentId);
355        JobAgentSettings settings = agent.getSettings(plugin, true);
356        if (!settings.isInDatabase()) 
357        {
358          dc.saveItem(settings);
359        }
360        else
361        {
362          dc.reattachItem(settings);
363        }
364        settings.setJarPath(Values.getStringOrNull(request.getParameter("jarPath."+agentId)));
365        settings.setMaxMemory(Values.parseBytes(request.getParameter("maxMemory."+agentId), null));
366        settings.setPriorityBoost(Values.getInt(request.getParameter("priorityBoost."+agentId)));
367        String trusted = request.getParameter("trusted."+agentId);
368        settings.setTrusted(trusted == null ? null : Values.getBoolean(trusted));
369      }
370    }
371   
372    //Annotations
373    Base.updateAnnotations(dc, plugin, plugin, request);
374   
375    dc.commit();
376    cc.removeObject("item");
377  }
378  else if ("DeleteItem".equals(cmd))
379  {
380    // Delete a single item and then return to the view page
381    dc = sc.newDbControl();
382    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
383    RemovableUtil.setRemoved(dc, itemType, Collections.singleton(cc.getId()), true);
384    dc.commit();
385    redirect = viewPage;
386  }
387  else if ("DeleteItems".equals(cmd))
388  {
389    // Delete all selected items on the list page
390    dc = sc.newDbControl();
391    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
392    int numTotal = cc.getSelected().size();
393    int numRemoved = RemovableUtil.setRemoved(dc, itemType, cc.getSelected(), true);
394    dc.commit();
395    if (numTotal != numRemoved)
396    {
397      message = (numRemoved == 0 ? "No" : "Only "+numRemoved+" of "+numTotal) + " items could be deleted, because you have no DELETE permission";
398    }
399    redirect = listPage+(message != null ? "&popmessage="+HTML.urlEncode(message) : "");
400  }
401  else if ("RestoreItem".equals(cmd))
402  {
403    // Restore a single item and then return to the view page
404    dc = sc.newDbControl();
405    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
406    RemovableUtil.setRemoved(dc, itemType, Collections.singleton(cc.getId()), false);
407    dc.commit();
408    redirect = viewPage;
409  }
410  else if ("RestoreItems".equals(cmd))
411  {
412    // Restore all selected items on the list page
413    dc = sc.newDbControl();
414    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
415    int numTotal = cc.getSelected().size();
416    int numRemoved = RemovableUtil.setRemoved(dc, itemType, cc.getSelected(), false);
417    dc.commit();
418    if (numTotal != numRemoved)
419    {
420      message = (numRemoved == 0 ? "No" : "Only "+numRemoved+" of "+numTotal) + " items could be restored, because you have no WRITE permission";
421    }
422    redirect = listPage+(message != null ? "&popmessage="+HTML.urlEncode(message) : "");
423  }
424  else if ("ShareItem".equals(cmd))
425  {
426    // Display a popup window for sharing a single item
427    dc = sc.newDbControl();
428    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
429    MultiPermissions permissions = ShareableUtil.getMultiPermissions(dc, itemType, Collections.singleton(cc.getId()));
430    dc.close();
431    cc.setObject("MultiPermissions", permissions);
432    redirect = "../../common/share/share.jsp?ID="+ID+"&item_type="+itemType.name();
433  }
434  else if ("ShareItems".equals(cmd))
435  {
436    // Display a popup window for sharing all selected items on the list page
437    dc = sc.newDbControl();
438    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
439    MultiPermissions permissions = ShareableUtil.getMultiPermissions(dc, itemType, cc.getSelected());
440    dc.close();
441    cc.setObject("MultiPermissions", permissions);
442    redirect = "../../common/share/share.jsp?ID="+ID+"&item_type="+itemType.name();
443  }
444  else if ("SetOwnerOfItem".equals(cmd))
445  {
446    // Change owner of items selected on a list page
447    dc = sc.newDbControl();
448    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
449    OwnedItem item = (OwnedItem)itemType.getById(dc, cc.getId());
450    cc.setObject("OwnedItems", Collections.singleton(item));
451    redirect = "../../common/ownership/ownership.jsp?ID="+ID+"&item_type="+itemType.name();
452  }
453  else if ("SetOwnerOfItems".equals(cmd))
454  {
455    // Change owner of items selected on a list page
456    dc = sc.newDbControl();
457    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
458    Set<OwnedItem> items = new HashSet<OwnedItem>();
459    for (Integer id : cc.getSelected())
460    {
461      if (id != null) items.add((OwnedItem)itemType.getById(dc, id));
462    }
463    dc.close();
464    cc.setObject("OwnedItems", items);
465    redirect = "../../common/ownership/ownership.jsp?ID="+ID+"&item_type="+itemType.name();
466  }
467  else if ("ExportItems".equals(cmd))
468  {
469    // Run an export plugin in a list context
470    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
471    final ItemQuery<PluginDefinition> query = PluginDefinition.getQuery();
472    query.join(Hql.leftJoin("guiContexts", "ctx"));
473    query.setDistinct(true);
474    cc.configureQuery(query, true);
475    cc.setQuery(query);
476    registerExportUtils(cc);
477    redirect = "../../common/export/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=LIST&title=Export+plugins";
478  }
479  else if ("ExportItem".equals(cmd))
480  {
481    // Run an export plugin in single-item context
482    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
483    registerExportUtils(cc);
484    redirect = "../../common/export/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&title=Export+plugin";
485  }
486  else if ("ImportItems".equals(cmd))
487  {
488    // Run an import plugin in a list context
489    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
490    final ItemQuery<PluginDefinition> query = PluginDefinition.getQuery();
491    query.join(Hql.leftJoin("guiContexts", "ctx"));
492    query.setDistinct(true);
493    cc.configureQuery(query, true);
494    cc.setQuery(query);
495    redirect = "../../common/import/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=LIST&title=Import+plugins";
496  }
497  else if ("ImportItem".equals(cmd))
498  {
499    // Run an import plugin in single-item context
500    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
501    redirect = "../../common/import/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&title=Import+plugin";
502  }
503  else if ("RunListPlugin".equals(cmd))
504  {
505    // Run another plugin in a list context
506    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
507    final ItemQuery<PluginDefinition> query = PluginDefinition.getQuery();
508    query.join(Hql.leftJoin("guiContexts", "ctx"));
509    query.setDistinct(true);
510    cc.configureQuery(query, true);
511    cc.setQuery(query);
512    redirect = "../../common/plugin/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=LIST&main_type=OTHER&title=Run+plugin";
513  }
514  else if ("RunPlugin".equals(cmd))
515  {
516    // Run another plugin in single-item context
517    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
518    redirect = "../../common/plugin/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&main_type=OTHER&title=Run+plugin";
519  }
520  else if ("UnloadItems".equals(cmd))
521  {
522    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
523    dc = sc.newDbControl();
524    for (int id : cc.getSelected())
525    {
526      PluginDefinition pd = PluginDefinition.getById(dc, id);
527      if (pd.getJarPath() != null)
528      {
529        JarClassLoader.unload(pd.getJarPath());
530      }
531    }
532    dc.close();
533    redirect = listPage;
534  }
535  else if ("UnloadItem".equals(cmd))
536  {
537    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
538    dc = sc.newDbControl();
539    PluginDefinition pd = PluginDefinition.getById(dc, cc.getId());
540    if (pd.getJarPath() != null)
541    {
542      JarClassLoader.unload(pd.getJarPath());
543    }
544    dc.close();
545    redirect = viewPage;
546  }
547  else
548  {
549    throw new WebException("popup", "Invalid command", "The command {1} is not recognised as a valid command.", cmd);
550  }
551}
552finally
553{
554  if (dc != null) dc.close();
555}
556
557if (forward != null)
558{
559  pageContext.forward(forward);
560}
561else if (redirect != null)
562{
563  response.sendRedirect(redirect);
564}
565else if (message == null)
566{
567  response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&wait=0");
568}
569else
570{
571  response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&message="+HTML.urlEncode(message));
572}
573%>
574
Note: See TracBrowser for help on using the repository browser.