Changeset 7232


Ignore:
Timestamp:
Nov 17, 2016, 9:06:29 AM (6 years ago)
Author:
Nicklas Nordborg
Message:

References #2042: Add support for ignoring an extension or other file in the extensions directory

It is now possible to select "Ignore" option in the installation wizard. The IgnoreFilter class is used to filter out the selected files which are then processed with the IgnoreFileProcessor. The "Ignore" option is selected by default for files with an error. It is possible to "Ignore" any file. If the extension is already installed the uninstall option is automatically selected as well.

There is currently no way to get back the ignored files again. Until that is resolved the workaround is to stop Tomcat, edit the extensions-settings.xml file (located in userfiles directory configured in base.config) and then start Tomcat again.

Location:
trunk
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/clients/web/net/sf/basedb/clients/web/extensions/ExtensionsControl.java

    r7229 r7232  
    7171import net.sf.basedb.util.extensions.manager.processor.DisablePluginsProcessor;
    7272import net.sf.basedb.util.extensions.manager.processor.ExtractResourcesProcessor;
     73import net.sf.basedb.util.extensions.manager.processor.IgnoreFileProcessor;
    7374import net.sf.basedb.util.extensions.manager.processor.PluginInstallationProcessor;
    7475import net.sf.basedb.util.extensions.manager.processor.ResetProcessor;
     
    211212    int numInstalled = 0;
    212213    int numUninstalled = 0;
     214    int numIgnored = 0;
    213215   
    214216    // Extensions+extension points statistics
     
    222224      if (!initialScan)
    223225      {
     226        // 0. Collecting files to be ignored
     227        IgnoreFilter ignoreFilter = new IgnoreFilter(request);
     228        IgnoreFileProcessor ignore = new IgnoreFileProcessor(results);
     229        ignore.setDelayRegistration(true);
     230        manager.processFiles(ignore, ignoreFilter);
     231       
    224232        // 1. Process files that has been selected for uninstallation
    225233        log.debug("Uninstalling extensions");
     
    245253        numUninstalled = uninstall.getNumFiles();
    246254        log.debug("Uninstalled " + numUninstalled + " extensions");
     255       
     256        // Finalize files that should be ignored
     257        ignore.finalizeRegistration(manager);
     258        numIgnored = ignore.getNumFiles();
     259        log.debug("Ignored " + numIgnored + " files");
    247260      }
    248261     
     
    310323      summary.append(numDisabledPlugins).append(" plug-in(s) have been disabled\n");
    311324    }
     325    if (numIgnored > 0)
     326    {
     327      summary.append(numIgnored + " file(s) ignored\n");
     328    }
    312329    if (results.getNumErrorFiles() > 0)
    313330    {
     
    733750  {
    734751    return manager.getFiles();
     752  }
     753 
     754  /**
     755    Get files that are currently ignored.
     756    @since 3.10
     757  */
     758  public List<File> getIgnoredFiles()
     759  {
     760    return manager.getIgnoredFiles(true);
    735761  }
    736762 
  • trunk/src/core/net/sf/basedb/util/extensions/manager/ExtensionsFile.java

    r7228 r7232  
    238238 
    239239  /**
     240    Is this an extension file that should be ignored?
     241    @since 3.10
     242  */
     243  public boolean isIgnored()
     244  {
     245    return file != null && manager.getSettings().isIgnoredFile(file);
     246  }
     247
     248  /**
    240249    Check if the file was modified when the last call to
    241250    {@link #checkModified()} was made. It is recommended
  • trunk/src/core/net/sf/basedb/util/extensions/manager/ExtensionsManager.java

    r7231 r7232  
    241241    @param file The file to remove (if null this method is ignored)
    242242  */
    243   void removeFile(File file)
    244   {
    245     if (file == null) return;
     243  ExtensionsFile removeFile(File file)
     244  {
     245    if (file == null) return null;
    246246    settings.setUninstalledFile(file);
    247247    ExtensionsFile xtFile = xtFiles.remove(file.toURI());
    248     if (xtFile == null) return;
    249     unregisterAllObjects(xtFile);
     248    if (xtFile != null)
     249    {
     250      unregisterAllObjects(xtFile);
     251    }
     252    return xtFile;
    250253  }
    251254 
  • trunk/www/admin/extensions/details.js

    r6380 r7232  
    5858    var url = 'index.jsp?ID='+App.getSessionId();
    5959    url += '&cmd=ManualScan';
    60     Dialogs.openPopup(url, 'ManualScan', 750, 500);
     60    Dialogs.openPopup(url, 'ManualScan', 900, 600);
    6161  }
    6262 
  • trunk/www/admin/extensions/scan_results.jsp

    r6986 r7232  
    9292      String icon = "ok.png";
    9393      String warning = null;
    94       if (extFile.hasError())
     94      if (extFile.hasError() && !extFile.isIgnored())
    9595      {
    9696        icon = "error.png";
  • trunk/www/admin/extensions/wizard.js

    r6259 r7232  
    4040      Events.addEventHandler(element, 'click', wizard.uninstallOnClick);
    4141    }
     42    else if (autoInit == 'ignore')
     43    {
     44      Events.addEventHandler(element, 'click', wizard.ignoreOnClick);
     45    }
    4246  }
    4347  Doc.addElementInitializer(wizard.initCheckBoxes);
     
    5862      var uninstall = frm[install.name.replace(/\.install$/, '.uninstall')];
    5963      if (uninstall) uninstall.checked = false;
     64      var ignore = frm[install.name.replace(/\.install$/, '.ignore')];
     65      if (ignore) ignore.checked = false;
    6066    }
    6167  }
     
    6975      var install = frm[uninstall.name.replace(/\.uninstall$/, '.install')];
    7076      if (install) install.checked = false;
     77    }
     78  }
     79 
     80  wizard.ignoreOnClick = function(event)
     81  {
     82    var frm = document.forms['scan'];
     83    var ignore = event.target;
     84    if (ignore.checked)
     85    {
     86      var install = frm[ignore.name.replace(/\.ignore$/, '.install')];
     87      if (install) install.checked = false;
     88      var uninstall = frm[ignore.name.replace(/\.ignore$/, '.uninstall')];
     89      if (uninstall) uninstall.checked = true;
    7190    }
    7291  }
  • trunk/www/admin/extensions/wizard.jsp

    r7226 r7232  
    2525  @version 2.0
    2626--%>
    27 <%@page import="net.sf.basedb.clients.web.servlet.ContentSecurityPolicyFilter"%>
    28 <%@page import="net.sf.basedb.clients.web.extensions.UnsafeScriptable"%>
    29 <%@page import="net.sf.basedb.util.extensions.ExtendedAbout"%>
    3027<%@ page pageEncoding="UTF-8" session="false"
    3128  import="net.sf.basedb.core.Application"
     
    4138  import="net.sf.basedb.util.extensions.ExtensionPoint"
    4239  import="net.sf.basedb.util.extensions.Extension"
     40  import="net.sf.basedb.util.extensions.ExtendedAbout"
    4341  import="net.sf.basedb.util.extensions.manager.ExtensionsManager"
    4442  import="net.sf.basedb.util.extensions.manager.ExtensionsFile"
    4543  import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
     44  import="net.sf.basedb.clients.web.extensions.UnsafeScriptable"
     45  import="net.sf.basedb.clients.web.servlet.ContentSecurityPolicyFilter"
    4646  import="java.util.List"
    4747%>
     
    7171    <tbl:columndef id="install" title="Install" />
    7272    <tbl:columndef id="uninstall" title="Uninstall" />
     73    <tbl:columndef id="ignore" title="Ignore" />
    7374    <tbl:columndef id="about" title="About" />
    7475 
     
    9495        boolean allowInstall = false;
    9596        boolean allowUninstall = false;
     97        boolean allowIgnore = false;
    9698        boolean checkInstall = false;
    9799        boolean checkUninstall = false;
     100        boolean checkIgnore = false;
    98101        if (!xtFile.exists())
    99102        {
     
    111114            checkUninstall = true;
    112115          }
     116          allowIgnore = true;
     117          checkIgnore = true;
    113118        }
    114119        else if (xtFile.isNew())
     
    116121          status = "New";
    117122          allowInstall = true;
     123          allowIgnore = true;
    118124          checkInstall = true;
    119125        }
     
    130136          allowInstall = true;
    131137          allowUninstall = true;
     138          allowIgnore = true;
    132139        }
    133140        else
     
    136143          allowInstall = true;
    137144          allowUninstall = true;
     145          allowIgnore = true;
    138146        }
    139147        %>
    140148        <tbl:row>
    141           <tbl:cell column="file"><%=name%></tbl:cell>
     149          <tbl:cell column="file" style="white-space: nowrap;"><%=name%></tbl:cell>
    142150          <tbl:cell column="status"><%=status%></tbl:cell>
    143151          <tbl:cell column="install"  style="text-align: center;">
     
    160168              <input type="checkbox" class="auto-init" data-auto-init="uninstall"
    161169                name="<%=name%>.uninstall" value="1" <%=checkUninstall ? "checked" : "" %>
     170                >
     171              <%
     172            }
     173            %>
     174          </tbl:cell>
     175          <tbl:cell column="ignore" style="text-align: center;">
     176            <%
     177            if (allowIgnore)
     178            {
     179              %>
     180              <input type="checkbox" class="auto-init" data-auto-init="ignore"
     181                name="<%=name%>.ignore" value="1" <%=checkIgnore ? "checked" : "" %>
    162182                >
    163183              <%
Note: See TracChangeset for help on using the changeset viewer.