Class IUpgrader
- java.lang.Object
-
- net.ssehub.easy.reasoning.core.reasoner.IUpgrader
-
- Direct Known Subclasses:
FileUpgrader
public abstract class IUpgrader extends java.lang.ObjectDefines the interface to an installation upgrade mechanism.- Author:
- Holger Eichelberger
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.StringbundleLocationprivate java.io.Filedestprivate java.util.Map<java.lang.String,java.lang.String>filesprivate java.lang.Stringmarkerprivate ProgressObserverobserverprivate static java.lang.StringPROTOCOL_FILEprivate static java.lang.StringPROTOCOL_REFERENCEprivate java.net.URIsourceprivate longtimeStamp
-
Constructor Summary
Constructors Modifier Constructor Description protectedIUpgrader(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.FilebundleLocationToFile(java.lang.String location)Converts a bundle location to a file.protected voidcopy(java.io.File source, java.io.File target)Copiessourcetotarget.protected abstract booleandoUpgrade(ReasoningResult result)Performs the upgrade operations.protected voiderror(ReasoningResult result, java.io.IOException ex)Adds an I/O error toresult.protected java.lang.StringgetMappedFile(java.lang.String input)Returns a mapped file name.protected java.lang.StringgetMarker()Returns the marker file.protected ProgressObservergetObserver()Returns the progress observer instance.protected java.net.URIgetSource()Returns the source URI.protected java.io.FileobtainTargetFile(java.lang.String targetName)Obtains a file descriptor fortargetNameand cares for uniquely renaming existing files.static java.lang.StringtoBundleLocation(java.io.File file)Returns a pseudo bundle location derived from file.ReasoningResultupgrade()Executes the upgrade.
-
-
-
Field Detail
-
PROTOCOL_REFERENCE
private static final java.lang.String PROTOCOL_REFERENCE
- See Also:
- Constant Field Values
-
PROTOCOL_FILE
private static final java.lang.String PROTOCOL_FILE
- 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
-
observer
private ProgressObserver observer
-
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 upgradedest- the destination bundle locationfiles- the file mapping describing the upgrademarker- an optional marker file withindest(may be null)observer- a progress observer, useProgressObserver.NO_OBSERVERif no observer shall be informed
-
-
Method Detail
-
toBundleLocation
public static java.lang.String toBundleLocation(java.io.File file) throws java.net.MalformedURLExceptionReturns 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
-
upgrade
public ReasoningResult upgrade()
Executes the upgrade.- Returns:
- messages about upgrade problems
- See Also:
doUpgrade(ReasoningResult)
-
doUpgrade
protected abstract boolean doUpgrade(ReasoningResult result)
Performs the upgrade operations.- Parameters:
result- the reasoning result to be modified as a side effect- Returns:
trueif performed,falseif 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
inputis 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 fortargetNameand cares for uniquely renaming existing files.- Parameters:
targetName- the target name (withindest)- Returns:
- the file descriptor representing
targetName
-
error
protected void error(ReasoningResult result, java.io.IOException ex)
Adds an I/O error toresult.- Parameters:
result- the reasoning result to be modified as a side effectex- the exception denoting the error
-
copy
protected void copy(java.io.File source, java.io.File target) throws java.io.IOExceptionCopiessourcetotarget.- Parameters:
source- the source filetarget- the target file- Throws:
java.io.IOException- in case of any I/O problems
-
-