Changeset 4859


Ignore:
Timestamp:
Mar 27, 2009, 2:23:57 PM (13 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #1273: Make it easier to develop plug-ins and extensions as a single package

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/doc/src/docbook/admindoc/plugin_installation.xml

    r4537 r4859  
    8282        <guimenuitem>Definitions</guimenuitem>
    8383      </menuchoice>
    84       and click on the &gbNew; button. The pop-up window that appears looks different
    85       depending on if the <property>plugins.dir</property> property
    86       in <filename>base.config</filename>
    87       has been defined or not. If this has been defined you will first have to
    88       choose between manual or automatic installation as described below. Otherwise
    89       you will immediately be taken to the manual installation.
     84      and click on the &gbNew; button. In the pop-up window that appears
     85      you should first decide if you want to do a manual or an (almost) automatic
     86      installation. An automatic installation scans the server disks for plug-ins
     87      and lets you select which ones to install or update from a list in the
     88      web interface. In a manual installation you are required to enter the
     89      path and class name of the plug-in yourself.
    9090    </para>
    9191   
     
    121121                <listitem>
    122122                  <para>
    123                   BASE will scan the given path for JAR files containing
     123                  BASE will scan the selected directories for JAR files containing
    124124                  plug-ins. If it finds any, you will have the option
    125125                  to select which ones to install from a list.
     
    144144          </varlistentry>
    145145          <varlistentry>
    146             <term><guilabel>Path</guilabel> (only when <emphasis>Automatically</emphasis> is selected)</term>
     146            <term><guilabel>Directories</guilabel> (only when <emphasis>Automatically</emphasis> is selected)</term>
    147147            <listitem>
    148148              <para>
    149                 Where BASE will look for JAR files with plug-ins.
     149                Select the checkboxes were BASE should look for new plug-ins.
     150                For security reasons the only options are the dedicated plug-ins
     151                directory that is configured in the <filename>base.config</filename>
     152                directory and the extensions that directory that is normally
     153                used for extensions to the web client.
    150154              </para>
    151155            </listitem>
     
    331335     
    332336      <para>
    333         This window lists all the plug-ins that were found in JAR files, located in the path defined in
    334         <filename>base.config</filename>.
    335         There is a few option to set for each plug-in before they can be registered.
     337        This window lists all the plug-ins that were found in JAR files,
     338        after scanning the selected directories from the previous step.
     339        There are a few options to set for each plug-in before they can be registered.
    336340      </para>
    337341     
     
    367371              <listitem>
    368372                <para>
    369                   A select list for each plug-in that can be registered. There are
     373                  A selection list for each plug-in that can be registered. There are
    370374                  at least two option for each plug-in in this drop-down list. The
    371375                  default option
  • trunk/www/admin/plugindefinitions/auto_install.jsp

    r4624 r4859  
    2525--%>
    2626<%@ page session="false"
    27 
     27  import="net.sf.basedb.core.Application"
    2828  import="net.sf.basedb.core.DbControl"
    2929  import="net.sf.basedb.core.Item"
     
    4545  import="net.sf.basedb.util.Values"
    4646  import="net.sf.basedb.util.Tree"
     47  import="net.sf.basedb.clients.web.Base"
    4748  import="net.sf.basedb.clients.web.util.HTML"
    48   import="net.sf.basedb.clients.web.Base"
     49  import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
    4950  import="java.util.Collections"
    5051  import="java.util.List"
     
    5758<%!
    5859
    59 private Tree<Object> generateTree(DbControl dc, java.io.File pluginDir)
     60private void addDirectory(DbControl dc, Tree<Object> tree, java.io.File directory)
    6061  throws Exception
    6162{
    62   Tree<Object> tree = new Tree<Object>(null);
    6363  FileFilter jarFilter = new RegexpFileFilter(".*\\.jar", null);
    64   List<java.io.File> jarFiles = FileUtil.findFiles(pluginDir, jarFilter);
     64  List<java.io.File> jarFiles = FileUtil.findFiles(directory, jarFilter);
    6565  for (java.io.File file : jarFiles)
    6666  {
    67     addToTree(dc, tree, file);
     67    addPluginJarFile(dc, tree, file);
    6868  }
    69   return tree;
    7069}
    7170
    72 private void addToTree(DbControl dc, Tree<Object> tree, java.io.File file)
     71private void addPluginJarFile(DbControl dc, Tree<Object> tree, java.io.File file)
    7372  throws Exception
    7473{
     
    235234  boolean usePermissions = up == null ? false : Values.getBoolean(up);
    236235  Boolean allowImmediateExecution = aie == null ? null : Values.getBoolean(aie);
     236  boolean scanPluginDir = Values.getBoolean(request.getParameter("plugindir"));
     237  boolean scanExtensionsDir = Values.getBoolean(request.getParameter("extensionsdir"));
    237238 
    238   java.io.File pluginDir = new java.io.File(request.getParameter("plugin_path"));
    239   List<PluginInfo> pluginInfos = new LinkedList<PluginInfo>();
    240   FileFilter jarFilter = new RegexpFileFilter(".*\\.jar", null);
    241  
    242   Tree<Object> plugins = generateTree(dc, pluginDir);
    243  
    244   List<java.io.File> jarFiles = FileUtil.findFiles(pluginDir, jarFilter);
    245    
    246   for (java.io.File file : jarFiles)
    247   {
    248     pluginInfos.addAll(PluginInfo.loadFromJar(file));
    249   }
     239  java.io.File pluginDir = Application.getNonCorePluginDirectory();
     240  java.io.File extensionsDir = new java.io.File(application.getRealPath(ExtensionsControl.EXTENSIONS_URL));
     241  Tree<Object> plugins = new Tree<Object>(null);
     242  if (scanPluginDir) addDirectory(dc, plugins, pluginDir);
     243  if (scanExtensionsDir) addDirectory(dc, plugins, extensionsDir);
    250244  %>
    251245  <base:page type="popup" title="<%=title%>">
     
    416410    <input type="hidden" name="ID" value="<%=ID%>">
    417411    <input type="hidden" name="cmd" value="LoadPlugins">
    418     <input type="hidden" name="plugin_path" value="<%=pluginDir%>">
     412    <input type="hidden" name="plugindir" value="<%=scanPluginDir ? "1" : "0"%>"
     413    <input type="hidden" name="extensionsdir" value="<%=scanExtensionsDir ? "1" : "0"%>"
    419414   
    420415    <h3 class="docked"><%=title%> <base:help tabcontrol="plugins" /></h3>
  • trunk/www/admin/plugindefinitions/index.jsp

    r4711 r4859  
    5959  import="net.sf.basedb.util.Values"
    6060  import="net.sf.basedb.clients.web.util.HTML"
     61  import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
    6162  import="net.sf.basedb.plugins.PluginConfigurationImporter"
    6263  import="java.util.Enumeration"
     
    140141    cc.setId(0);
    141142   
    142     //Go directly to manually installation if plugin directory isn't specified in base.config or
    143     // if it doesn't doesn't exists
    144     if (Application.getNonCorePluginDirectory() != null  &&  Application.getNonCorePluginDirectory().exists())
    145     {
    146       String pluginPath = Application.getNonCorePluginDirectory().getPath();
    147       redirect = "select_installation_type.jsp?ID="+ID+"&plugin_path="+pluginPath;
     143    redirect = "select_installation_type.jsp?ID="+ID;
     144  }
     145  else if("InstallationType".equals(cmd))
     146  {
     147    //Either manually or auto installation is selected
     148    String type = request.getParameter("installationType");
     149    if ("auto".equals(type))
     150    {
     151      forward = "auto_install.jsp?ID="+ID;
    148152    }
    149153    else
     
    151155      redirect = editPage;
    152156    }
    153   }
    154   else if("InstallationType".equals(cmd))
    155   {
    156     //Either manually or auto installation is selected
    157     if (request.getParameter("installationtypes").equals("autoinstall"))
    158     {
    159       String pluginPath = request.getParameter("plugin_path");
    160       redirect = "auto_install.jsp?ID="+ID+"&plugin_path="+pluginPath;
    161     }
    162     else if (request.getParameter("installationtypes").equals("manuellinstall"))
    163     {
    164       redirect = editPage;
    165     }
    166    
    167157  }
    168158  else if("LoadPlugins".equals(cmd))
     
    171161    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, defaultContext);
    172162    dc = sc.newDbControl();
    173     java.io.File pluginDir = new java.io.File(request.getParameter("plugin_path"));
     163    java.io.File pluginDir = Application.getNonCorePluginDirectory();
     164    java.io.File extensionsDir = new java.io.File(application.getRealPath(ExtensionsControl.EXTENSIONS_URL));
     165    FileFilter jarFilter = new RegexpFileFilter(".*\\.jar", null);
     166    List<java.io.File> jarFiles = new LinkedList<java.io.File>();
     167    if (Values.getBoolean(request.getParameter("plugindir")))
     168    {
     169      jarFiles.addAll(FileUtil.findFiles(pluginDir, jarFilter));
     170    }
     171    if (Values.getBoolean(request.getParameter("extensionsdir")))
     172    {
     173      jarFiles.addAll(FileUtil.findFiles(extensionsDir, jarFilter));
     174    }
     175   
    174176    List<PluginInfo> pluginInfos = new LinkedList<PluginInfo>();
    175     FileFilter jarFilter = new RegexpFileFilter(".*\\.jar", null);
    176     List<java.io.File> jarFiles = FileUtil.findFiles(pluginDir, jarFilter);
    177177    Map<PluginInfo, Throwable> installationResult = new LinkedHashMap<PluginInfo, Throwable>();
    178178   
  • trunk/www/admin/plugindefinitions/select_installation_type.jsp

    r4537 r4859  
    3131  import="net.sf.basedb.core.ItemContext"
    3232  import="net.sf.basedb.core.SessionControl"
    33  
    3433  import="net.sf.basedb.clients.web.Base"
     34  import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
    3535%>
    3636<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
     
    4444
    4545String title = "Installation type";
    46 String pluginPath = request.getParameter("plugin_path");
     46java.io.File pluginDir = Application.getNonCorePluginDirectory();
     47boolean pluginDirEnabled = pluginDir != null && pluginDir.exists();
     48
     49java.io.File extensionsDir = new java.io.File(application.getRealPath(ExtensionsControl.EXTENSIONS_URL));
     50boolean extensionsDirEnabled = extensionsDir != null && extensionsDir.exists();
    4751
    4852try
     
    5761      {
    5862        var frm = document.forms['installations'];
    59         var types = frm.installationtypes;
     63        var types = frm.installationType;
    6064        var type = types[types.selectedIndex].value;   
    6165       
     
    6569        }       
    6670        Main.show('description.'+type);
    67         if (type == 'autoinstall')
     71        if (type == 'auto')
    6872        {
    69           Main.show('plugindir');
     73          Main.show('directories');
    7074        }
    7175        else
    7276        {
    73           Main.hide('plugindir');
     77          Main.hide('directories');
    7478        }
    7579        lastSelectedType = type;
     
    7882      {
    7983        var frm = document.forms['installations'];
     84        var types = frm.installationType;
     85        var type = types[types.selectedIndex].value;   
     86        if (type == 'auto')
     87        {
     88          if (!frm['plugindir'].checked && !frm['extensionsdir'].checked)
     89          {
     90            alert('Please select at least one directory for automatic installation');
     91            return;
     92          }
     93        }
    8094        frm.submit();
    8195      }     
     
    90104    <input type="hidden" name="ID" value="<%=ID%>">
    91105    <input type="hidden" name="cmd" value="InstallationType">
    92     <input type="hidden" name="plugin_path" value="<%=pluginPath%>">
    93106 
    94107    <h3 class="docked"><%=title%> <base:help helpid="plugindefinition.installationtype" /></h3>
     
    102115        <td class="prompt" width="100px">Install</td>
    103116        <td>
    104           <select name="installationtypes" class="required" onchange="typeOnChange()">
    105             <option value="autoinstall">Automatically</option>
    106             <option value="manuellinstall">Manually</option>
     117          <select name="installationType" class="required" onchange="typeOnChange()">
     118            <option value="auto">Automatically</option>
     119            <option value="manual">Manually</option>
    107120          </select>
    108121        </td>
    109122      </tr>
    110       <tr id="plugindir" valign="top" style="display:none;">
    111         <td class="prompt">Path</td>
    112         <td><i><%=pluginPath%></i></td>
     123      <tr id=directories valign="top" style="display:none;">
     124        <td class="prompt">Directories</td>
     125        <td>
     126          <input type="checkbox" name="plugindir" checked value="1"
     127            <%=pluginDirEnabled ? "" : "disabled" %>
     128            >Dedicated plug-ins directory (<%=pluginDir%>)<br>
     129          <input type="checkbox" name="extensionsdir" checked value="1"
     130            <%=extensionsDirEnabled ? "" : "disabled" %>
     131            >Extensions directory (<%=extensionsDir%>)
     132        </td>
    113133      </tr>       
    114134      </table>
    115135     
    116136      <div id="descriptions" class="helpmessage">
    117         <div id="description.autoinstall" style="display:none;">
     137        <div id="description.auto" style="display:none;">
    118138          <b>Automatically install non-core plugins</b><br>
    119           The path above will be scanned for plugins in jar-files.<br>
     139          The selected paths above will be scanned for plugins in jar-files.<br>
    120140          Plugins that were found will be available for selection in the next step.
    121141        </div>
    122         <div id="description.manuellinstall" style="display:none;">
     142        <div id="description.manual" style="display:none;">
    123143          <b>Manually install plugins</b><br>
    124144          The plugin´s class name and jar path have to be defined manually.
Note: See TracChangeset for help on using the changeset viewer.