Changeset 6340


Ignore:
Timestamp:
Oct 31, 2013, 1:54:35 PM (9 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #1777: Error messages for extensions that fail to install are forgotten after installing other extensions

The old installation results are now copied over to the new ProcessResults instance. Uninstalling an extension should remove the old results, but a weak hash map is used just in case something forgotten...

Location:
branches/3.2-stable
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/3.2-stable/src/clients/web/net/sf/basedb/clients/web/extensions/ExtensionsControl.java

    r6028 r6340  
    197197
    198198    // Collect the results from this scan
    199     ProcessResults results = new ProcessResults();
     199    ProcessResults results = new ProcessResults(lastScanResults);
    200200   
    201201    // File statistics
  • branches/3.2-stable/src/clients/web/net/sf/basedb/clients/web/extensions/UninstalledFileProcessor.java

    r5616 r6340  
    6666    ExtensionsFile xtFile = wFile.getExtensionsFile();
    6767    results.setStatus(xtFile, "Uninstalled");
     68    results.forgetOldResults(xtFile);
    6869    wFile.setUninstalled();
    6970    numFiles++;
  • branches/3.2-stable/src/core/net/sf/basedb/util/extensions/manager/ProcessResults.java

    r5616 r6340  
    2727import java.util.Map;
    2828import java.util.TreeMap;
     29import java.util.WeakHashMap;
    2930
    3031/**
     
    4243
    4344  private Map<ExtensionsFile, FileResults> fileResults;
     45  private Map<ExtensionsFile, FileResults> oldFileResults;
     46 
    4447  private boolean hasError;
    4548  private int numErrorFiles;
     
    5255  public ProcessResults()
    5356  {
     57    this(null);
     58  }
     59 
     60  /**
     61    Create a new process results object, keeping information about
     62    previous results.
     63    @since 3.2.4
     64  */
     65  public ProcessResults(ProcessResults oldResults)
     66  {
    5467    this.fileResults = new TreeMap<ExtensionsFile, FileResults>();
     68    this.oldFileResults = new WeakHashMap<ExtensionsFile, FileResults>();
     69    if (oldResults != null)
     70    {
     71      oldFileResults.putAll(oldResults.oldFileResults);
     72    }
    5573    this.hasError = false;
    5674    this.numErrorFiles = 0;
     
    127145 
    128146  /**
    129     Get the results for a specific extensions file.
     147    Get the results for a specific extensions file. If
     148    no current results exists, old results are searched.
    130149    @param xtFile The extensions file to get the results for
    131150    @return A {@link FileResults} object or null if the
     
    134153  public FileResults getResults(ExtensionsFile xtFile)
    135154  {
    136     return fileResults.get(xtFile);
    137   }
    138 
     155    FileResults results = fileResults.get(xtFile);
     156    if (results == null) results = oldFileResults.get(xtFile);
     157    return results;
     158  }
     159
     160  /**
     161    Forget old processing results for the given file.
     162    Should be called when an extension has been uninstalled,
     163    @param xtFile The extensions file to forget
     164    @since 3.2.4
     165  */
     166  public void forgetOldResults(ExtensionsFile xtFile)
     167  {
     168    oldFileResults.remove(xtFile);
     169  }
     170 
    139171  /**
    140172    Sets a short overall status message for an entire file. Example:
     
    152184      m = new FileResults(xtFile);
    153185      fileResults.put(xtFile, m);
     186      oldFileResults.put(xtFile, m);
    154187    }
    155188    m.status = status;
     
    186219      m = new FileResults(xtFile);
    187220      fileResults.put(xtFile, m);
     221      oldFileResults.put(xtFile, m);
    188222    }
    189223    m.messages.add(message);
     
    205239   
    206240    private final ExtensionsFile xtFile;
     241    private final long time;
    207242    List<String> messages;
    208243    boolean hasError = false;
     
    212247    {
    213248      this.xtFile = xtFile;
     249      this.time = System.currentTimeMillis();
    214250      this.messages = new LinkedList<String>();
    215251    }
     
    218254    {
    219255      return xtFile;
     256    }
     257   
     258    /**
     259      Get the time of the results as a millisecond value.
     260      @since 3.2.4
     261    */
     262    public long getTime()
     263    {
     264      return time;
    220265    }
    221266   
  • branches/3.2-stable/www/admin/extensions/details.jsp

    r5951 r6340  
    8787  final ExtensionsControl ec = ExtensionsControl.get(dc);
    8888  final boolean writePermission = ec.hasPermission(Permission.WRITE);
     89  Formatter dateTimeFormatter = FormatterFactory.getDateTimeFormatter(sc);
    8990 
    9091  Extension<?> ext = null;
     
    443444      About about = file.getAbout();
    444445      if (about == null) about = new AboutBean();
     446      ProcessResults results = ec.getLastScanResults();
     447      FileResults fileResults = results.getResults(file);
    445448      %>
    446449      <tbody>
     
    456459        <th>Up to date</th>
    457460        <td><%=file.checkModified() ? "No" : "Yes"%></td>
     461      </tr>
     462      <tr>
     463        <th>Last installed</th>
     464        <td><%=fileResults == null ? "unknown" : dateTimeFormatter.format(new Date(fileResults.getTime())) %></td>
    458465      </tr>
    459466      <tr class="big">
     
    463470          if (file.hasError())
    464471          {
    465             ProcessResults results = ec.getLastScanResults();
    466             FileResults fileResults = results.getResults(file);
    467             List<String> messages = fileResults.getMessages();
     472            List<String> messages = fileResults == null ? null : fileResults.getMessages();
    468473            Throwable validationError = file.getValidationError();
    469474            %>
     
    477482              <%
    478483            }
    479             for (String msg : messages)
     484            if (messages != null)
    480485            {
    481               %>
    482               <li><%=HTML.niceFormat(msg)%>
    483               <%
     486              for (String msg : messages)
     487              {
     488                %>
     489                <li><%=HTML.niceFormat(msg)%>
     490                <%
     491              }
    484492            }
    485493            %>
     
    533541    {
    534542      ProcessResults results = ec.getLastScanResults();
    535       Formatter dateTimeFormatter = FormatterFactory.getDateTimeFormatter(sc);
    536543      %>
    537544      <tbody>
Note: See TracChangeset for help on using the changeset viewer.