Skip to content

Design Document: GanttProject Update Manager

Dmitry Barashev edited this page Mar 30, 2018 · 4 revisions

Summary

This document describes the architecture of a component responsible for updating GanttProject installation in platform-independent way.

User Interface

When GanttProject detects availability of new updates it should show a dialog with the update details and ask for confirmation to download the update. When download completes, GanttProject should ask user to restart application

Technical Details

This feature includes detection and downloading of available updates when GanttProject is running and applying updates on boot time. It will touch code from the following repositories:

Update Detection

GanttProject once per day issues HTTP request to http://www.ganttproject.biz/my/feed and downloads Atom feed with the news. User can control if this request is sent or not using a checkbox in the settings.

Some Atom entries are not appropriate for particular version of GanttProject (for instance, it makes no sense to show news about new GanttProject release to the user who is already using the latest version), so every entry in the feed contains some categories which GanttProject uses to decide if item should be shown or not. The meaning of existing categories is given below. We plan to add a special category update which indicates that entry contains information about the update. We can use the same rules to decide if update is applicable to the version of GanttProject or not. If update is applicable, we should show the dialog.

The update entry contents will include the new version number in the first line, download link in the second and description in the remaining lines. Entry contents is an encoded HTML. An example of decoded update entry may look like this:

<entry>
    <title></title>
    <link href="http://example.org/2018/12/13/atom03"/>
    <id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id>
    <updated>2018-12-13T18:30:02Z</updated>
    <content type="html"><div>
3.0.1
https://dl.ganttproject.biz/3.0.1/zip/ganttproject-3.0.1-r3001.zip
This is a bugfix release. See the details on the <a href="">release page</a>
</div>
    </content>
  </entry>

Relevant classes: net.sourceforge.ganttproject.client.RssFeedChecker and net.sourceforge.ganttproject.client.RssParser

Downloading

The linked file may be downloaded to any temporary location, and then extracted into appropriate directory. The preferred directory is GanttProject installation directory. However, current use may not have write permissions for that directory. In this case we'll probably want to extract the archive into $HOME/.ganttproject.d/plugins directory.

Applying the update

GanttProject code is packaged into a set of plugins which are managed by a small "microkernel" library called Eclipsito. At boot time launcher starts Eclipsito which finds the directory with plugins. The location of plugins directory can be specified in the config file (ganttproject-eclipsito-config.xml inside eclipsito.jar) or with command line arguments. Currently it is an exact name, like plugins-2.8.6, and only resources from the classpath (which includes eclipsito.jar and GanttProject installation directory) are considered. So if GanttProject 2.8.6 is installed in /usr/share/ganttproject then Eclipsito will search for plugins inside /usr/share/ganttproject/plugins-2.8.6

We can enhance plugin search mechanism by using predefined plugins directory (without version) inside the GanttProject installation directory and .ganttproject.d directory in the user home, and scanning through all subdirectories inside plugins matching version pattern \d.\d\d?.\d\d?. The directory with the highest version is the winner. In this scenario, GanttProject installation may look like this:

/usr/share/ganttproject/
  eclipsito.jar
  plugins/
    3.0.0/
      ganttproject/
    3.0.1/
      ganttproject/
    3.0.2/
      ganttproject/

and Eclipsito will use /usr/share/ganttproject/plugins/3.0.2 to search for plugins.

If user can't write to /usr/share/ganttproject, he will write to his $HOME and the directory structure may look like this:

/usr/share/ganttproject/
  eclipsito.jar
  plugins/
    3.0.0/
      ganttproject/

$HOME/.ganttproject.d/plugins
  3.0.1/
    ganttproject/
  3.0.2/
    ganttproject/

In this case Eclipsito will use $HOME/.ganttproject.d/plugins/3.0.2 as plugin root directory.

The remaining parts of Eclipsito most likely don't need any changes, since they are parameterized with the plugin root directory.

Relevant classes in Eclipsito: org.bardsoftware.eclipsito.Boot and org.bardsoftware.impl.eclipsito.BootImpl

Current version number

Current version number is important both for informing user and for filtering the news feed. Currently the version number is hardcoded as a constant in GPVersion class. With update manager we will need to update it dynamically at boot time. Perhaps the easiest way is to add VERSION file into ganttproject plugin and read it immediately when we enter GanttProject.main method.