Changeset 7233


Ignore:
Timestamp:
Nov 17, 2016, 1:36:34 PM (5 years ago)
Author:
Nicklas Nordborg
Message:

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

Implemented support for managing "ignored" files in the installation wizard. The ignored files are listed at the bottom of the table in a separate section (only displayed if there is at least one ignored file).

There are two possible actions: Install and Stop ignore which can be selected and that are processed in the ExtensionsControl and related classes. Since the files are not managed by the ExtensionsManager there is no special "About" information for them. We display the file size and last modification date.

Location:
trunk
Files:
7 edited

Legend:

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

    r7232 r7233  
    213213    int numUninstalled = 0;
    214214    int numIgnored = 0;
     215    int numNotIgnored = 0;
    215216   
    216217    // Extensions+extension points statistics
     
    224225      if (!initialScan)
    225226      {
     227        // Checks if any of the ignored files have been selected for "Stop ignore"
     228        for (File ignored : manager.getIgnoredFiles(true))
     229        {
     230          boolean stopIgnore = Values.getBoolean(request.getParameter(ignored.getName()+".stopignore"));
     231          boolean install = Values.getBoolean(request.getParameter(ignored.getName()+".install"));
     232         
     233          if (stopIgnore)
     234          {
     235            if (ignored.isFile())
     236            {
     237              ExtensionsFile xtFile = manager.addFile(ignored);
     238              String status = "Not ignored";
     239              if (install && xtFile.hasError()) status = "Not installed";
     240              results.setStatus(xtFile, status);
     241            }
     242            else
     243            {
     244              manager.removeIgnore(ignored);
     245            }
     246            numNotIgnored++;
     247          }
     248        }
     249       
    226250        // 0. Collecting files to be ignored
    227251        IgnoreFilter ignoreFilter = new IgnoreFilter(request);
     
    327351      summary.append(numIgnored + " file(s) ignored\n");
    328352    }
     353    if (numNotIgnored > 0)
     354    {
     355      summary.append(numNotIgnored + " file(s) no longer ignored\n");
     356    }
    329357    if (results.getNumErrorFiles() > 0)
    330358    {
  • trunk/src/core/net/sf/basedb/util/extensions/manager/ExtensionsFile.java

    r7232 r7233  
    379379        if (zipEntry == null)
    380380        {
    381           throw new FileNotFoundException("META-INF/extensions.xml");
     381          throw new FileNotFoundException(name+"!META-INF/extensions.xml");
    382382        }
    383383        in = new CloseResourceInputStream(zipFile.getInputStream(zipEntry), zipFile);
  • trunk/src/core/net/sf/basedb/util/extensions/manager/ExtensionsManager.java

    r7232 r7233  
    225225    ExtensionsFile xtFile = new ExtensionsFile(this, file);
    226226    addExtensionsFile(xtFile);
    227     ignore.remove(file);
     227    removeIgnore(file);
    228228    return xtFile;
    229229  }
  • trunk/src/core/net/sf/basedb/util/extensions/manager/ProcessResults.java

    r6520 r7233  
    185185      fileResults.put(xtFile, m);
    186186      oldFileResults.put(xtFile, m);
     187      if (xtFile.hasError())
     188      {
     189        hasError = true;
     190        numErrorFiles++;
     191        m.hasError = true;
     192      }
    187193    }
    188194    m.status = status;
  • trunk/src/core/net/sf/basedb/util/extensions/manager/processor/IgnoreFileProcessor.java

    r7232 r7233  
    8080    ExtensionsFile xtFile = wFile.getExtensionsFile();
    8181    filesToIgnore.add(wFile);
     82    results.forgetOldResults(xtFile);
    8283    numFiles++;
    8384  }
     
    140141      }
    141142      results.setStatus(xtFile, status);
    142       results.forgetOldResults(xtFile);
    143143    }
    144144  }
  • trunk/www/admin/extensions/wizard.js

    r7232 r7233  
    4444      Events.addEventHandler(element, 'click', wizard.ignoreOnClick);
    4545    }
     46    else if (autoInit == 'stop-ignore')
     47    {
     48      Events.addEventHandler(element, 'click', wizard.stopIgnoreOnClick);
     49    }
    4650  }
    4751  Doc.addElementInitializer(wizard.initCheckBoxes);
     
    6468      var ignore = frm[install.name.replace(/\.install$/, '.ignore')];
    6569      if (ignore) ignore.checked = false;
     70      var stopIgnore = frm[install.name.replace(/\.install$/, '.stopignore')];
     71      if (stopIgnore) stopIgnore.checked = true;
    6672    }
    6773  }
     
    7581      var install = frm[uninstall.name.replace(/\.uninstall$/, '.install')];
    7682      if (install) install.checked = false;
     83    }
     84    else
     85    {
     86      var ignore = frm[uninstall.name.replace(/\.uninstall$/, '.ignore')];
     87      if (ignore) ignore.checked = false;
    7788    }
    7889  }
     
    91102  }
    92103
     104  wizard.stopIgnoreOnClick = function(event)
     105  {
     106    var frm = document.forms['scan'];
     107    var stopIgnore = event.target;
     108    if (!stopIgnore.checked)
     109    {
     110      var install = frm[stopIgnore.name.replace(/\.stopignore$/, '.install')];
     111      if (install) install.checked = false;
     112    }
     113  }
    93114 
    94115  wizard.startManualScan = function()
  • trunk/www/admin/extensions/wizard.jsp

    r7232 r7233  
    3636  import="net.sf.basedb.util.Values"
    3737  import="net.sf.basedb.clients.web.util.HTML"
     38  import="net.sf.basedb.util.formatter.Formatter"
    3839  import="net.sf.basedb.util.extensions.ExtensionPoint"
    3940  import="net.sf.basedb.util.extensions.Extension"
     
    4344  import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
    4445  import="net.sf.basedb.clients.web.extensions.UnsafeScriptable"
     46  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
    4547  import="net.sf.basedb.clients.web.servlet.ContentSecurityPolicyFilter"
    4648  import="java.util.List"
     49  import="java.io.File"
     50  import="java.util.Date"
    4751%>
    4852<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
     
    5559try
    5660{
     61  Formatter<Date> dateFormatter = FormatterFactory.getDateTimeFormatter(sc);
     62 
    5763  dc = sc.newDbControl();
    5864  ExtensionsControl ec = ExtensionsControl.get(dc);
     
    6066  ec.scanForChanges();
    6167  List<ExtensionsFile> xtFiles = ec.getFiles();
     68  List<File> ignoredFiles = ec.getIgnoredFiles();
    6269  %>
    6370  <base:page type="popup" title="Extensions and plug-ins installation wizard">
    64   <base:head scripts="table.js,~wizard.js" styles="table.css" />
     71  <base:head scripts="table.js,~wizard.js" styles="table.css">
     72  <style>
     73    .ignored-header td
     74    {
     75      font-weight: bold;
     76      border-top-style: solid;
     77      border-bottom-style: solid;
     78      border-top-width: 1px;
     79      border-bottom-width: 1px;
     80      padding: 1px 2px;
     81    }
     82    .ignored-file td
     83    {
     84      opacity: 0.5;
     85    }
     86    .ignored-file .input
     87    {
     88      opacity: 1;
     89    }
     90  </style>
     91  </base:head>
    6592  <base:body>
    6693  <h1>Extensions and plug-ins installation wizard <base:help helpid="extensions.install-wizard" /></h1>
     
    6895  <tbl:table id="scan" subclass="fulltable" action="index.jsp" >
    6996    <tbl:columndef id="file" title="File" />
    70     <tbl:columndef id="status" title="Status" />
    71     <tbl:columndef id="install" title="Install" />
    72     <tbl:columndef id="uninstall" title="Uninstall" />
    73     <tbl:columndef id="ignore" title="Ignore" />
     97    <tbl:columndef id="status" title="Status" style="text-align: center;"/>
     98    <tbl:columndef id="install" title="Install" style="text-align: center;"/>
     99    <tbl:columndef id="uninstall" title="Uninstall" style="text-align: center;"/>
     100    <tbl:columndef id="ignore" title="Ignore" style="text-align: center;" />
    74101    <tbl:columndef id="about" title="About" />
    75102 
     
    148175        <tbl:row>
    149176          <tbl:cell column="file" style="white-space: nowrap;"><%=name%></tbl:cell>
    150           <tbl:cell column="status"><%=status%></tbl:cell>
    151           <tbl:cell column="install"  style="text-align: center;">
     177          <tbl:cell column="status" style="text-align: center; white-space: nowrap;"><%=status%></tbl:cell>
     178          <tbl:cell column="install" style="text-align: center;">
    152179            <%
    153180            if (allowInstall)
     
    219246        </tbl:row>
    220247        <%
     248      }
     249      if (ignoredFiles.size() > 0)
     250      {
     251        %>
     252        <tr class="ignored-header bg-filled-100">
     253          <td colspan="2">Ignored files (<%=ignoredFiles.size() %>)</td>
     254          <td class="cell" style="text-align: center;">Install</td>
     255          <td class="cell" ></td>
     256          <td  class="cell" style="text-align: center;">Stop ignoring</td>
     257          <td class="cell"></td>
     258        </tr>
     259        <%
     260        for (File ignoredFile : ignoredFiles)
     261        {
     262          String name = ignoredFile.getName();
     263          String fileInfo = "";
     264          boolean checkStopIgnore = false;
     265          boolean allowInstall = true;
     266          if (ignoredFile.isFile())
     267          {
     268            fileInfo = Values.formatBytes(ignoredFile.length());
     269            fileInfo += "; " + dateFormatter.format(new Date(ignoredFile.lastModified()));
     270          }
     271          else
     272          {
     273            fileInfo = "File does not exist.";
     274            checkStopIgnore = true;
     275            allowInstall = false;
     276          }
     277          %>
     278          <tbl:row clazz="ignored-file">
     279            <tbl:cell column="file" style="white-space: nowrap;"><%=name%></tbl:cell>
     280            <tbl:cell column="status" style="text-align: center; white-space: nowrap;">Ignored</tbl:cell>
     281            <tbl:cell clazz="cell input" column="install" style="text-align: center;">
     282              <%
     283              if (allowInstall)
     284              {
     285                %>
     286                <input type="checkbox" class="auto-init" data-auto-init="install"
     287                  name="<%=name%>.install" value="1">
     288                <%
     289              }
     290              %>
     291            </tbl:cell>
     292            <tbl:cell clazz="cell input" column="ignore" style="text-align: center;">
     293              <input type="checkbox" class="auto-init" data-auto-init="stop-ignore"
     294                name="<%=name%>.stopignore" value="1" <%=checkStopIgnore ? "checked" : "" %>>
     295            </tbl:cell>
     296            <tbl:cell column="about"><%=HTML.encodeTags(fileInfo) %></tbl:cell>
     297          </tbl:row>
     298          <%
     299        }
    221300      }
    222301      %>
Note: See TracChangeset for help on using the changeset viewer.