Changeset 5615 for trunk/src/install/net


Ignore:
Timestamp:
Apr 19, 2011, 3:42:31 PM (11 years ago)
Author:
Nicklas Nordborg
Message:

References #1592: Unified installation procedure for plug-ins, extensions and more...

Added file processor for installing plug-ins as part of a scan for extensions. Trying to link information about plug-in into the tree with extensions information.

Added "disabled" property to plug-ins to make them behave more similar to extensions. There may still be synchronization issues with the in-memory information and the database information.

Changed the installation procedure somewhat to allow re-using the same code for installing plug-ins (eg. from initdb/updatedb, and scanning extensions). There are some bumps to fix yet.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/install/net/sf/basedb/install/Webclient.java

    r5612 r5615  
    2828import net.sf.basedb.core.Application;
    2929import net.sf.basedb.core.DbControl;
    30 import net.sf.basedb.core.Group;
    31 import net.sf.basedb.core.SystemItems;
    3230import net.sf.basedb.core.ItemKey;
    33 import net.sf.basedb.core.GroupPermissions;
    3431import net.sf.basedb.core.Permission;
    3532import net.sf.basedb.core.Client;
     
    3835import net.sf.basedb.core.BaseException;
    3936import net.sf.basedb.core.ItemNotFoundException;
    40 import net.sf.basedb.core.Version;
    41 import net.sf.basedb.core.plugin.AboutImpl;
    4237import net.sf.basedb.plugins.HelpImporter;
     38import net.sf.basedb.util.extensions.xml.PluginInfo;
     39import net.sf.basedb.util.extensions.xml.XmlLoader;
    4340
    4441import java.io.InputStream;
    4542import java.net.URL;
    46 import java.util.EnumSet;
    4743
    4844/**
     
    9995   
    10096    DbControl dc = sc.newDbControl();
    101     Group everyone = Group.getById(dc, SystemItems.getId(Group.EVERYONE));
    102     GroupPermissions gp = new GroupPermissions();
    103     gp.setPermissions(everyone, EnumSet.of(Permission.USE));
    104     ItemKey everyoneUse = ItemKey.getNewOrExisting(dc, null, gp);
     97    try
     98    {
     99      ItemKey shareToEveryone = ItemKey.getShareToEveryOneKey(dc, Permission.USE);
     100     
     101      Client client = null;
     102      try
     103      {
     104        client = Client.getByExternalId(dc, "net.sf.basedb.clients.web");
     105      }
     106      catch (ItemNotFoundException ex)
     107      {
     108        client = Client.getNew(dc, "net.sf.basedb.clients.web");
     109        client.setName("Web client");
     110        client.setDescription("The web interface to BASE");
     111        client.setItemKey(shareToEveryone);
     112        dc.saveItem(client);
     113      }
     114 
     115      String latinText = "Fusce consectetuer. Suspendisse consectetuer wisi vitae eros. Quisque sapien sapien, "+
     116        "lobortis a, congue sed, tempus vitae, sapien. Aliquam rhoncus ultricies pede. Fusce "+
     117        "gravida pharetra tellus. Nulla tortor. Donec eu enim. Vivamus blandit. Pellentesque "+
     118        "habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Mauris "+
     119        "pulvinar arcu id libero. Vestibulum pharetra. Proin id felis pharetra mauris feugiat adipiscing. "+
     120        "Cras auctor. Nullam turpis. Cras dignissim venenatis erat.<br>\n"+
     121        "[<b>The server administrator should replace this text, or remove it to disable this feature</b>]";
     122 
     123      createSetting(client, "server.about", latinText);
     124      createSetting(client, "server.admin.name", adminName);
     125      createSetting(client, "server.admin.email", adminEmail);
     126      createSetting(client, "server.forgotten.password", latinText);
     127      createSetting(client, "server.get.account", latinText);
     128      createSetting(client, "server.transferRate", Integer.toString(100 * 1024 * 1024)); // 100MB/s
     129      createSetting(client, "server.links.reportbug", "http://base.thep.lu.se/#Feedback");
     130      createSetting(client, "server.links.help", "http://base.thep.lu.se/chrome/site/doc/html/index.html");
     131      createSetting(client, "server.links.faq", "");
     132     
     133      URL fileURL = Webclient.class.getResource("/web-extensions.xml");
     134     
     135      XmlLoader loader = new XmlLoader();
     136      try
     137      {
     138        InputStream in = fileURL.openStream();
     139        loader.loadXmlFile(in, "/web-extensions.xml", null, false);
     140      }
     141      catch (Exception ex)
     142      {
     143        throw new BaseException(ex);
     144      }
     145     
     146      for (PluginInfo info : loader.getPluginDefinitions())
     147      {
     148        PluginDefinition.installOrUpdate(dc, info, null, shareToEveryone);
     149      }
     150      dc.commit();
     151      installHelpTexts(sc, client);
     152    }
     153    finally
     154    {
     155      if (dc != null) dc.close();
     156    }
    105157   
    106     Client client = null;
    107     try
    108     {
    109       client = Client.getByExternalId(dc, "net.sf.basedb.clients.web");
    110     }
    111     catch (ItemNotFoundException ex)
    112     {
    113       client = Client.getNew(dc, "net.sf.basedb.clients.web");
    114       client.setName("Web client");
    115       client.setDescription("The web interface to BASE");
    116       client.setItemKey(everyoneUse);
    117       dc.saveItem(client);
    118     }
    119 
    120     String latinText = "Fusce consectetuer. Suspendisse consectetuer wisi vitae eros. Quisque sapien sapien, "+
    121       "lobortis a, congue sed, tempus vitae, sapien. Aliquam rhoncus ultricies pede. Fusce "+
    122       "gravida pharetra tellus. Nulla tortor. Donec eu enim. Vivamus blandit. Pellentesque "+
    123       "habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Mauris "+
    124       "pulvinar arcu id libero. Vestibulum pharetra. Proin id felis pharetra mauris feugiat adipiscing. "+
    125       "Cras auctor. Nullam turpis. Cras dignissim venenatis erat.<br>\n"+
    126       "[<b>The server administrator should replace this text, or remove it to disable this feature</b>]";
    127 
    128     createSetting(client, "server.about", latinText);
    129     createSetting(client, "server.admin.name", adminName);
    130     createSetting(client, "server.admin.email", adminEmail);
    131     createSetting(client, "server.forgotten.password", latinText);
    132     createSetting(client, "server.get.account", latinText);
    133     createSetting(client, "server.transferRate", Integer.toString(100 * 1024 * 1024)); // 100MB/s
    134     createSetting(client, "server.links.reportbug", "http://base.thep.lu.se/#Feedback");
    135     createSetting(client, "server.links.help", "http://base.thep.lu.se/chrome/site/doc/html/index.html");
    136     createSetting(client, "server.links.faq", "");
    137      
    138     PluginDefinition simpleExport = null;
    139     String simpleExportClassName = "net.sf.basedb.clients.web.plugins.SimpleExport";
    140     try
    141     {
    142       simpleExport = PluginDefinition.getByClassName(dc, simpleExportClassName);
    143       simpleExport.loadPluginInformation(null, simpleExportClassName, true);
    144     }
    145     catch (ItemNotFoundException ex)
    146     {
    147       simpleExport = PluginDefinition.getNew(dc, simpleExportClassName, null, true);
    148       simpleExport.setItemKey(everyoneUse);
    149       simpleExport.setAllowImmediateExecution(true);
    150       dc.saveItem(simpleExport);
    151     }
    152    
    153     simpleExport.setAbout(
    154         new AboutImpl
    155         (
    156             "Table exporter",
    157             "Export all table listings in the web interface as tab-separated text files " +
    158             "or as XML. This plugin only works from within the web client, since it depends " +
    159             "on context and table information.",
    160             Version.getMajor() + "." + Version.getMinor() + "." + Version.getMaintenance(),
    161             "2006, Base 2 development team",
    162             null,
    163             null,
    164             "http://base.thep.lu.se"
    165           ), false);
    166    
    167     dc.commit();
    168    
    169     installHelpTexts(sc, client);
    170158  }
    171159 
Note: See TracChangeset for help on using the changeset viewer.