public class ConsoleUpdateManager extends Object implements UpdateManager, RouterApp
APP_NAME
Constructor and Description |
---|
ConsoleUpdateManager(RouterContext ctx,
ClientAppManager listener,
String[] args) |
Modifier and Type | Method and Description |
---|---|
String |
_t(String s)
translate a string
|
String |
_t(String s,
Object o)
translate a string with a parameter
|
String |
_t(String s,
Object o,
Object o2)
translate a string with parameters
|
void |
check(UpdateType type)
Fire off a checker task
Non-blocking.
|
void |
check(UpdateType type,
String id)
Fire off a checker task
Non-blocking.
|
String |
checkAvailable(UpdateType type)
Is an update available?
Blocking.
|
String |
checkAvailable(UpdateType type,
long maxWait)
Is an update available?
Blocking.
|
String |
checkAvailable(UpdateType type,
String id,
long maxWait)
Is an update available?
Blocking.
|
String |
getDisplayName()
The display name of the ClientApp, used in user interfaces.
|
static ConsoleUpdateManager |
getInstance() |
String |
getName()
The generic name of the ClientApp, used for registration,
e.g.
|
ClientAppState |
getState()
The current state of the ClientApp.
|
String |
getStatus()
The status on any update current or last finished.
|
String |
getUpdateAvailable(UpdateType type)
Is an update available?
Non-blocking, returns result of last check or notification from an Updater.
|
String |
getUpdateAvailable(UpdateType type,
String id)
Is an update available?
Non-blocking, returns result of last check or notification from an Updater.
|
String |
getUpdateConstraint(UpdateType type,
String id)
Is there a reason we can't download the update?
|
String |
getUpdateDownloaded(UpdateType type)
Is an update downloaded?
Non-blocking, returns result of last download
|
String |
getUpdateDownloaded(UpdateType type,
String id)
Is an update downloaded?
Non-blocking, returns result of last download
|
List<URI> |
getUpdateURLs(UpdateType type,
String id,
UpdateMethod method)
Where to find various resources
|
boolean |
installPlugin(String name,
URI uri)
Install a plugin.
|
boolean |
isCheckInProgress()
Is any check in progress?
Does not include updates.
|
boolean |
isCheckInProgress(UpdateType type)
Is a check in progress?
|
boolean |
isCheckInProgress(UpdateType type,
String id)
Is a check in progress?
|
boolean |
isUpdateInProgress()
Is any download in progress?
Does not include checks.
|
boolean |
isUpdateInProgress(UpdateType type)
Is a download in progress?
|
boolean |
isUpdateInProgress(UpdateType type,
String id)
Is a download in progress?
|
(package private) static String |
linkify(String url) |
void |
notifyAttemptFailed(UpdateTask task,
String reason,
Throwable t)
Not necessarily the end if there are more URIs to try.
|
void |
notifyCheckComplete(UpdateTask task,
boolean newer,
boolean success)
Called by the Updater after check() was called and all notifyVersionAvailable() callbacks are finished
|
void |
notifyComplete(UpdateTask task,
String status)
An expiring status
|
boolean |
notifyComplete(UpdateTask task,
String actualVersion,
File file)
An update has been downloaded but not verified.
|
void |
notifyProgress(UpdateTask task,
String status) |
void |
notifyProgress(UpdateTask task,
String status,
long downloaded,
long totalSize) |
void |
notifyTaskFailed(UpdateTask task,
String reason,
Throwable t)
The task has finished and failed.
|
boolean |
notifyVersionAvailable(UpdateTask task,
URI newsSource,
UpdateType type,
String id,
Map<UpdateMethod,List<URI>> sourceMap,
String newVersion,
String minVersion)
Called by the Checker, either after check() was called, or it found out on its own.
|
boolean |
notifyVersionAvailable(UpdateTask task,
URI newsSource,
UpdateType type,
String id,
UpdateMethod method,
List<URI> updateSources,
String newVersion,
String minVersion)
Called by the Updater, either after check() was called, or it found out on its own.
|
void |
notifyVersionConstraint(UpdateTask task,
URI newsSource,
UpdateType type,
String id,
String newVersion,
String message)
A new version is available but cannot be downloaded or installed due to some constraint.
|
void |
register(Checker updater,
UpdateType type,
UpdateMethod method,
int priority) |
void |
register(Updater updater,
UpdateType type,
UpdateMethod method,
int priority)
Call once for each type/method pair.
|
void |
renderStatusHTML(Writer out)
debug
|
(package private) boolean |
shouldInstall()
from NewsFetcher
|
void |
shutdown()
UpdateManager interface
|
void |
shutdown(String[] args)
ClientApp interface
|
void |
start()
UpdateManager interface
|
void |
startup()
ClientApp interface
|
void |
stopCheck(UpdateType type)
Stop this check
|
void |
stopCheck(UpdateType type,
String id)
Stop this check
|
void |
stopChecks()
Stop all checks in progress
|
void |
stopUpdate(UpdateType type)
Stop this download
|
void |
stopUpdate(UpdateType type,
String id)
Stop this download
|
void |
stopUpdates()
Stop all downloads in progress
|
void |
unregister(Checker updater,
UpdateType type,
UpdateMethod method) |
void |
unregister(Updater updater,
UpdateType type,
UpdateMethod method) |
boolean |
update(UpdateType type)
Non-blocking.
|
boolean |
update(UpdateType type,
long maxTime)
Non-blocking.
|
boolean |
update(UpdateType type,
String id)
Non-blocking.
|
boolean |
update(UpdateType type,
String id,
long maxTime)
Non-blocking.
|
public ConsoleUpdateManager(RouterContext ctx, ClientAppManager listener, String[] args)
args
- ignoredpublic static ConsoleUpdateManager getInstance()
public void start()
start
in interface UpdateManager
public void startup()
public void shutdown()
shutdown
in interface UpdateManager
public void shutdown(String[] args)
public ClientAppState getState()
ClientApp
public String getName()
ClientApp
public String getDisplayName()
ClientApp
getDisplayName
in interface ClientApp
public String getStatus()
getStatus
in interface UpdateManager
public String checkAvailable(UpdateType type)
checkAvailable
in interface UpdateManager
type
- the UpdateType of this requestpublic String checkAvailable(UpdateType type, long maxWait)
checkAvailable
in interface UpdateManager
type
- the UpdateType of this requestmaxWait
- max time to blockpublic String checkAvailable(UpdateType type, String id, long maxWait)
checkAvailable
in interface UpdateManager
type
- the UpdateType of this requestid
- id of this requestmaxWait
- max time to blockpublic void check(UpdateType type)
public void check(UpdateType type, String id)
public String getUpdateAvailable(UpdateType type)
public String getUpdateAvailable(UpdateType type, String id)
public String getUpdateDownloaded(UpdateType type)
public String getUpdateDownloaded(UpdateType type, String id)
public boolean isUpdateInProgress()
isUpdateInProgress
in interface UpdateManager
public boolean isUpdateInProgress(UpdateType type)
isUpdateInProgress
in interface UpdateManager
type
- the UpdateType of this requestpublic boolean isUpdateInProgress(UpdateType type, String id)
isUpdateInProgress
in interface UpdateManager
type
- the UpdateType of this requestid
- of this requestpublic void stopUpdates()
public void stopUpdate(UpdateType type)
public void stopUpdate(UpdateType type, String id)
public boolean isCheckInProgress()
public boolean isCheckInProgress(UpdateType type)
public boolean isCheckInProgress(UpdateType type, String id)
public void stopChecks()
public void stopCheck(UpdateType type)
public void stopCheck(UpdateType type, String id)
public boolean installPlugin(String name, URI uri)
name
- if null, a new installpublic boolean update(UpdateType type)
update
in interface UpdateManager
type
- the UpdateType of this requestpublic boolean update(UpdateType type, String id)
update
in interface UpdateManager
type
- the UpdateType of this requestid
- id of this requestpublic boolean update(UpdateType type, long maxTime)
update
in interface UpdateManager
maxTime
- not honored by all Updaterstype
- the UpdateType of this requestpublic boolean update(UpdateType type, String id, long maxTime)
update
in interface UpdateManager
maxTime
- not honored by all Updaterstype
- the UpdateType of this requestid
- id of this requestpublic void register(Updater updater, UpdateType type, UpdateMethod method, int priority)
register
in interface UpdateManager
public void unregister(Updater updater, UpdateType type, UpdateMethod method)
unregister
in interface UpdateManager
public void register(Checker updater, UpdateType type, UpdateMethod method, int priority)
register
in interface UpdateManager
public void unregister(Checker updater, UpdateType type, UpdateMethod method)
unregister
in interface UpdateManager
public boolean notifyVersionAvailable(UpdateTask task, URI newsSource, UpdateType type, String id, UpdateMethod method, List<URI> updateSources, String newVersion, String minVersion)
notifyVersionAvailable
in interface UpdateManager
newsSource
- who told usid
- plugin name for plugins, ignored otherwiseupdateSources
- Where to get the new versionnewVersion
- The new version availableminVersion
- The minimum installed version to be able to update to newVersionmethod
- How to get the new versionpublic boolean notifyVersionAvailable(UpdateTask task, URI newsSource, UpdateType type, String id, Map<UpdateMethod,List<URI>> sourceMap, String newVersion, String minVersion)
notifyVersionAvailable
in interface UpdateManager
newsSource
- who told usid
- plugin name for plugins, ignored otherwisesourceMap
- Mapping of methods to sourcesnewVersion
- The new version availableminVersion
- The minimum installed version to be able to update to newVersionpublic void notifyVersionConstraint(UpdateTask task, URI newsSource, UpdateType type, String id, String newVersion, String message)
notifyVersionConstraint
in interface UpdateManager
newsSource
- who told usid
- plugin name for plugins, ignored otherwisenewVersion
- The new version availablemessage
- A translated message to be displayed to the user, non-nullpublic void notifyCheckComplete(UpdateTask task, boolean newer, boolean success)
notifyCheckComplete
in interface UpdateManager
newer
- notifyVersionAvailable was calledsuccess
- check succeeded (newer or not)public void notifyProgress(UpdateTask task, String status, long downloaded, long totalSize)
notifyProgress
in interface UpdateManager
public void notifyProgress(UpdateTask task, String status)
notifyProgress
in interface UpdateManager
task
- may be nullpublic void notifyComplete(UpdateTask task, String status)
task
- may be nullpublic void notifyAttemptFailed(UpdateTask task, String reason, Throwable t)
notifyAttemptFailed
in interface UpdateManager
task
- checker or updatert
- may be nullpublic void notifyTaskFailed(UpdateTask task, String reason, Throwable t)
notifyTaskFailed
in interface UpdateManager
task
- checker or updatert
- may be nullpublic boolean notifyComplete(UpdateTask task, String actualVersion, File file)
notifyComplete
in interface UpdateManager
task
- must be an Updater, not a CheckeractualVersion
- may be higher (or lower?) than the version requestedfile
- a valid format for the task's UpdateType, or null if it did the installation itselfboolean shouldInstall()
public List<URI> getUpdateURLs(UpdateType type, String id, UpdateMethod method)
public String getUpdateConstraint(UpdateType type, String id)
public void renderStatusHTML(Writer out) throws IOException
renderStatusHTML
in interface UpdateManager
IOException