Class IUpgrader

  • Direct Known Subclasses:
    FileUpgrader

    public abstract class IUpgrader
    extends java.lang.Object
    Defines the interface to an installation upgrade mechanism.
    Author:
    Holger Eichelberger
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected IUpgrader​(java.net.URI source, java.lang.String dest, java.util.Map<java.lang.String,​java.lang.String> files, java.lang.String marker, ProgressObserver observer)
      Creates an upgrader instance.
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected java.util.Iterator<java.util.Map.Entry<java.lang.String,​java.lang.String>> allFileMappings()
      Returns an iterator over all known file mappings.
      static java.io.File bundleLocationToFile​(java.lang.String location)
      Converts a bundle location to a file.
      protected void copy​(java.io.File source, java.io.File target)
      Copies source to target.
      protected abstract boolean doUpgrade​(ReasoningResult result)
      Performs the upgrade operations.
      protected void error​(ReasoningResult result, java.io.IOException ex)
      Adds an I/O error to result.
      protected java.lang.String getMappedFile​(java.lang.String input)
      Returns a mapped file name.
      protected java.lang.String getMarker()
      Returns the marker file.
      protected ProgressObserver getObserver()
      Returns the progress observer instance.
      protected java.net.URI getSource()
      Returns the source URI.
      protected java.io.File obtainTargetFile​(java.lang.String targetName)
      Obtains a file descriptor for targetName and cares for uniquely renaming existing files.
      static java.lang.String toBundleLocation​(java.io.File file)
      Returns a pseudo bundle location derived from file.
      ReasoningResult upgrade()
      Executes the upgrade.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • PROTOCOL_REFERENCE

        private static final java.lang.String PROTOCOL_REFERENCE
        See Also:
        Constant Field Values
      • source

        private java.net.URI source
      • bundleLocation

        private java.lang.String bundleLocation
      • dest

        private java.io.File dest
      • files

        private java.util.Map<java.lang.String,​java.lang.String> files
      • marker

        private java.lang.String marker
      • timeStamp

        private long timeStamp
    • Constructor Detail

      • IUpgrader

        protected IUpgrader​(java.net.URI source,
                            java.lang.String dest,
                            java.util.Map<java.lang.String,​java.lang.String> files,
                            java.lang.String marker,
                            ProgressObserver observer)
        Creates an upgrader instance.
        Parameters:
        source - the source containing the files to upgrade
        dest - the destination bundle location
        files - the file mapping describing the upgrade
        marker - an optional marker file within dest (may be null)
        observer - a progress observer, use ProgressObserver.NO_OBSERVER if no observer shall be informed
    • Method Detail

      • toBundleLocation

        public static java.lang.String toBundleLocation​(java.io.File file)
                                                 throws java.net.MalformedURLException
        Returns a pseudo bundle location derived from file.
        Parameters:
        file - the file to be converted
        Returns:
        the file location
        Throws:
        java.net.MalformedURLException - in case of translation problems
      • bundleLocationToFile

        public static java.io.File bundleLocationToFile​(java.lang.String location)
        Converts a bundle location to a file.
        Parameters:
        location - the location
        Returns:
        the file
      • doUpgrade

        protected abstract boolean doUpgrade​(ReasoningResult result)
        Performs the upgrade operations.
        Parameters:
        result - the reasoning result to be modified as a side effect
        Returns:
        true if performed, false if node
      • getSource

        protected java.net.URI getSource()
        Returns the source URI.
        Returns:
        the source URI
      • getMappedFile

        protected java.lang.String getMappedFile​(java.lang.String input)
        Returns a mapped file name.
        Parameters:
        input - the input file name
        Returns:
        the output file name, may be null if input is not mapped
      • getMarker

        protected java.lang.String getMarker()
        Returns the marker file.
        Returns:
        the marker file or null if unknown
      • getObserver

        protected ProgressObserver getObserver()
        Returns the progress observer instance.
        Returns:
        the progress observer
      • allFileMappings

        protected java.util.Iterator<java.util.Map.Entry<java.lang.String,​java.lang.String>> allFileMappings()
        Returns an iterator over all known file mappings.
        Returns:
        an iterator with original names in source as keys and target names as values
      • obtainTargetFile

        protected java.io.File obtainTargetFile​(java.lang.String targetName)
        Obtains a file descriptor for targetName and cares for uniquely renaming existing files.
        Parameters:
        targetName - the target name (within dest)
        Returns:
        the file descriptor representing targetName
      • error

        protected void error​(ReasoningResult result,
                             java.io.IOException ex)
        Adds an I/O error to result.
        Parameters:
        result - the reasoning result to be modified as a side effect
        ex - the exception denoting the error
      • copy

        protected void copy​(java.io.File source,
                            java.io.File target)
                     throws java.io.IOException
        Copies source to target.
        Parameters:
        source - the source file
        target - the target file
        Throws:
        java.io.IOException - in case of any I/O problems