Package org.nuxeo.launcher.connect
Class ConnectBroker
- java.lang.Object
-
- org.nuxeo.launcher.connect.ConnectBroker
-
public class ConnectBroker extends Object
- Since:
- 5.6
-
-
Field Summary
Fields Modifier and Type Field Description protected static String
LAUNCHER_CHANGED_PROPERTY
static String
OPTION_ACCEPT_DEFAULT
static String
OPTION_RELAX_DEFAULT
static String[]
POSITIVE_ANSWERS
-
Constructor Summary
Constructors Constructor Description ConnectBroker(Environment env)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
downloadPackages(List<String> packagesToDownload)
boolean
executePending(File commandsFile, boolean doExecute, boolean useResolver, boolean ignoreMissing)
protected org.nuxeo.connect.update.Package
findPackage(String pkg)
Looks for a package.protected List<String>
getAllLocalPackageIdsFromName(String pkgName)
protected String
getBestIdForNameInList(String pkgName, List<? extends org.nuxeo.connect.update.Package> pkgList)
String
getCLID()
CommandSetInfo
getCommandSet()
protected org.nuxeo.connect.update.LocalPackage
getInstalledPackageByName(String pkgName)
protected String
getInstalledPackageIdFromName(String pkgName)
protected org.nuxeo.connect.update.LocalPackage
getLocalPackage(String pkgIdOrName)
Looks for a local package from its name or idprotected File
getLocalPackageFile(String pkgFile)
Looks for a package file from its pathprotected String
getLocalPackageFileId(File pkgFile)
Load package definition from a local file or directory and get package Id from it.protected String
getLocalPackageIdFromName(String pkgName)
org.nuxeo.connect.packages.PackageManager
getPackageManager()
Path
getPendingFile()
List<org.nuxeo.connect.update.LocalPackage>
getPkgList()
protected String
getRemotePackageId(String pkgNameOrId)
Looks for a remote package from its name or idprotected String
getRemotePackageIdFromName(String pkgName)
StandaloneUpdateService
getUpdateService()
protected boolean
isInstalledPackage(String pkgName)
protected boolean
isLocalPackageFile(String pkgFile)
protected boolean
isLocalPackageId(String pkgId)
protected boolean
isRemotePackageId(String pkgId)
protected boolean
isRestartRequired()
boolean
listPending(File commandsFile)
static String
parseAnswer(String answer)
protected void
performTask(org.nuxeo.connect.update.task.Task task)
protected void
persistCommand(String command)
Persists the pending package operation into file system.org.nuxeo.connect.update.LocalPackage
pkgAdd(String packageFileName, boolean ignoreMissing)
Add a package file into the cacheboolean
pkgAdd(List<String> pkgsToAdd, boolean ignoreMissing)
Add a list of packages into the cache, downloading them if needed and possible.boolean
pkgHotfix()
org.nuxeo.connect.update.LocalPackage
pkgInstall(String pkgId, boolean ignoreMissing)
Install a local package.boolean
pkgInstall(List<String> packageIdsToInstall, boolean ignoreMissing)
Install a list of local packages.void
pkgList()
void
pkgList(List<? extends org.nuxeo.connect.data.DownloadablePackage> packagesList)
void
pkgListAll()
boolean
pkgPurge()
org.nuxeo.connect.update.LocalPackage
pkgRemove(String pkgId)
Remove a package from cache.boolean
pkgRemove(List<String> pkgsToRemove)
Remove a list of packages from cache.boolean
pkgRequest(List<String> pkgsToAdd, List<String> pkgsToInstall, List<String> pkgsToUninstall, List<String> pkgsToRemove, boolean keepExisting, boolean ignoreMissing)
boolean
pkgRequest(List<String> pkgsToAdd, List<String> pkgsToInstall, List<String> pkgsToUninstall, List<String> pkgsToRemove, boolean keepExisting, boolean ignoreMissing, boolean upgradeMode)
boolean
pkgReset()
boolean
pkgSet(List<String> pkgList, boolean ignoreMissing)
Installs a list of packages and uninstalls the rest (no dependency check)boolean
pkgShow(List<String> packages)
org.nuxeo.connect.update.LocalPackage
pkgUninstall(String pkgId)
Uninstall a local package.boolean
pkgUninstall(List<String> packageIdsToRemove)
Uninstall a list of packages.boolean
pkgUpgrade()
protected String
readConsole(String message, String defaultValue, Object... objects)
Prompt user for yes/no answervoid
refreshCache()
void
saveCLID()
void
setAccept(String acceptValue)
void
setAllowSNAPSHOT(boolean allow)
void
setCLID(String file)
void
setPendingFile(Path pendingFile)
void
setRelax(String relaxValue)
Must be called aftersetAccept(String)
which overwrites its value.
-
-
-
Field Detail
-
POSITIVE_ANSWERS
public static final String[] POSITIVE_ANSWERS
-
LAUNCHER_CHANGED_PROPERTY
protected static final String LAUNCHER_CHANGED_PROPERTY
- See Also:
- Constant Field Values
-
OPTION_RELAX_DEFAULT
public static final String OPTION_RELAX_DEFAULT
- See Also:
- Constant Field Values
-
OPTION_ACCEPT_DEFAULT
public static final String OPTION_ACCEPT_DEFAULT
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ConnectBroker
public ConnectBroker(Environment env) throws IOException, org.nuxeo.connect.update.PackageException
- Throws:
IOException
org.nuxeo.connect.update.PackageException
-
-
Method Detail
-
getPendingFile
public Path getPendingFile()
- Since:
- 10.2
-
setPendingFile
public void setPendingFile(Path pendingFile)
- Since:
- 10.2
-
getCLID
public String getCLID() throws org.nuxeo.connect.identity.LogicalInstanceIdentifier.NoCLID
- Throws:
org.nuxeo.connect.identity.LogicalInstanceIdentifier.NoCLID
-
setCLID
public void setCLID(String file) throws org.nuxeo.connect.identity.LogicalInstanceIdentifier.NoCLID
- Throws:
org.nuxeo.connect.identity.LogicalInstanceIdentifier.NoCLID
- if the CLID is absent or invalid- Since:
- 6.0
-
saveCLID
public void saveCLID() throws IOException, org.nuxeo.connect.identity.LogicalInstanceIdentifier.NoCLID
- Throws:
IOException
org.nuxeo.connect.identity.LogicalInstanceIdentifier.NoCLID
- Since:
- 8.10-HF15
-
getUpdateService
public StandaloneUpdateService getUpdateService()
-
getPackageManager
public org.nuxeo.connect.packages.PackageManager getPackageManager()
-
refreshCache
public void refreshCache()
-
getCommandSet
public CommandSetInfo getCommandSet()
-
getInstalledPackageByName
protected org.nuxeo.connect.update.LocalPackage getInstalledPackageByName(String pkgName)
-
isInstalledPackage
protected boolean isInstalledPackage(String pkgName)
-
isLocalPackageId
protected boolean isLocalPackageId(String pkgId)
-
isRemotePackageId
protected boolean isRemotePackageId(String pkgId)
-
getBestIdForNameInList
protected String getBestIdForNameInList(String pkgName, List<? extends org.nuxeo.connect.update.Package> pkgList)
-
getRemotePackageId
protected String getRemotePackageId(String pkgNameOrId)
Looks for a remote package from its name or id- Returns:
- the remote package Id; null if not found
- Since:
- 5.7
-
getLocalPackage
protected org.nuxeo.connect.update.LocalPackage getLocalPackage(String pkgIdOrName) throws org.nuxeo.connect.update.PackageException
Looks for a local package from its name or id- Returns:
- the local package Id; null if not found
- Throws:
org.nuxeo.connect.update.PackageException
- Since:
- 5.7
-
getLocalPackageFile
protected File getLocalPackageFile(String pkgFile)
Looks for a package file from its path- Parameters:
pkgFile
- Absolute or relative package file path- Returns:
- the file if found, else null
-
getLocalPackageFileId
protected String getLocalPackageFileId(File pkgFile)
Load package definition from a local file or directory and get package Id from it.- Returns:
- null the package definition cannot be loaded for any reason.
- Since:
- 8.4
-
isLocalPackageFile
protected boolean isLocalPackageFile(String pkgFile)
-
getPkgList
public List<org.nuxeo.connect.update.LocalPackage> getPkgList()
-
pkgList
public void pkgList()
-
pkgListAll
public void pkgListAll()
-
pkgList
public void pkgList(List<? extends org.nuxeo.connect.data.DownloadablePackage> packagesList)
-
performTask
protected void performTask(org.nuxeo.connect.update.task.Task task) throws org.nuxeo.connect.update.PackageException
- Throws:
org.nuxeo.connect.update.PackageException
-
pkgReset
public boolean pkgReset()
-
pkgPurge
public boolean pkgPurge() throws org.nuxeo.connect.update.PackageException
- Throws:
org.nuxeo.connect.update.PackageException
-
pkgUninstall
public boolean pkgUninstall(List<String> packageIdsToRemove)
Uninstall a list of packages. If the list contains a package name (versus an ID), only the considered as best matching package is uninstalled.- Parameters:
packageIdsToRemove
- The list can contain package IDs and names- See Also:
pkgUninstall(String)
-
pkgUninstall
public org.nuxeo.connect.update.LocalPackage pkgUninstall(String pkgId)
Uninstall a local package. The package is not removed from cache.- Parameters:
pkgId
- Package ID or Name- Returns:
- The uninstalled LocalPackage or null if failed
-
pkgRemove
public boolean pkgRemove(List<String> pkgsToRemove)
Remove a list of packages from cache. If the list contains a package name (versus an ID), all matching packages are removed.- Parameters:
pkgsToRemove
- The list can contain package IDs and names- See Also:
pkgRemove(String)
-
pkgRemove
public org.nuxeo.connect.update.LocalPackage pkgRemove(String pkgId)
Remove a package from cache. If it was installed, the package is uninstalled then removed.- Parameters:
pkgId
- Package ID or Name- Returns:
- The removed LocalPackage or null if failed
-
pkgAdd
public boolean pkgAdd(List<String> pkgsToAdd, boolean ignoreMissing)
Add a list of packages into the cache, downloading them if needed and possible.- Returns:
- true if command succeeded
- Since:
- 6.0
- See Also:
pkgAdd(String, boolean)
-
pkgAdd
public org.nuxeo.connect.update.LocalPackage pkgAdd(String packageFileName, boolean ignoreMissing)
Add a package file into the cache- Returns:
- The added LocalPackage or null if failed
- Since:
- 6.0
- See Also:
pkgAdd(List, boolean)
-
pkgInstall
public boolean pkgInstall(List<String> packageIdsToInstall, boolean ignoreMissing)
Install a list of local packages. If the list contains a package name (versus an ID), only the considered as best matching package is installed.- Parameters:
packageIdsToInstall
- The list can contain package IDs and namesignoreMissing
- If true, doesn't throw an exception on unknown packages- Since:
- 6.0
- See Also:
pkgInstall(String, boolean)
-
persistCommand
protected void persistCommand(String command)
Persists the pending package operation into file system. It's useful when Nuxeo launcher is about to exit. Empty command line won't be persisted.The given command will be appended as a new line into target file
pendingFile
. NOTE: the command line options are not serialized. Therefore, they should be provided by nuxeoctl again after launcher's restart.- Parameters:
command
- command to persist (appended as a new line)- Throws:
IllegalStateException
- if any exception occurs- Since:
- 10.2
- See Also:
pendingFile
-
isRestartRequired
protected boolean isRestartRequired()
- Since:
- 10.2
-
pkgInstall
public org.nuxeo.connect.update.LocalPackage pkgInstall(String pkgId, boolean ignoreMissing)
Install a local package.- Parameters:
pkgId
- Package ID or NameignoreMissing
- If true, doesn't throw an exception on unknown packages- Returns:
- The installed LocalPackage or null if failed
- Since:
- 6.0
- See Also:
pkgInstall(List, boolean)
-
listPending
public boolean listPending(File commandsFile)
-
executePending
public boolean executePending(File commandsFile, boolean doExecute, boolean useResolver, boolean ignoreMissing)
- Parameters:
commandsFile
- File containing the commands to executedoExecute
- Whether to execute or list the actionsuseResolver
- Whether to use full resolution or just execute individual actions- Since:
- 5.6
-
pkgRequest
public boolean pkgRequest(List<String> pkgsToAdd, List<String> pkgsToInstall, List<String> pkgsToUninstall, List<String> pkgsToRemove, boolean keepExisting, boolean ignoreMissing)
- Parameters:
keepExisting
- If false, the request will remove existing packages that are not part of the resolutionignoreMissing
- Do not error out on missing packages, just handle the rest- Since:
- 5.9.2
-
pkgRequest
public boolean pkgRequest(List<String> pkgsToAdd, List<String> pkgsToInstall, List<String> pkgsToUninstall, List<String> pkgsToRemove, boolean keepExisting, boolean ignoreMissing, boolean upgradeMode)
- Parameters:
keepExisting
- If false, the request will remove existing packages that are not part of the resolutionignoreMissing
- Do not error out on missing packages, just handle the restupgradeMode
- If true, all packages will be upgraded to their last compliant version- Throws:
LauncherRestartException
- if launcher is required to restart- Since:
- 8.4
-
pkgSet
public boolean pkgSet(List<String> pkgList, boolean ignoreMissing)
Installs a list of packages and uninstalls the rest (no dependency check)- Since:
- 6.0
-
readConsole
protected String readConsole(String message, String defaultValue, Object... objects)
Prompt user for yes/no answer- Parameters:
message
- The message to displaydefaultValue
- The default answer if there's no console or if "Enter" key is pressed.objects
- Parameters to use in the message (like inString.format(String, Object...)
)- Returns:
"true"
if answer is inPOSITIVE_ANSWERS
, else return"false"
-
parseAnswer
public static String parseAnswer(String answer)
- Returns:
"true"
if answer is inPOSITIVE_ANSWERS
, and"ask"
if answer values"ask"
, else return"false"
- Since:
- 6.0
-
pkgHotfix
public boolean pkgHotfix()
-
pkgUpgrade
public boolean pkgUpgrade()
-
setRelax
public void setRelax(String relaxValue)
Must be called aftersetAccept(String)
which overwrites its value.- Parameters:
relaxValue
- true, false or ask; ignored if null
-
setAccept
public void setAccept(String acceptValue)
- Parameters:
acceptValue
- true, false or ask; if true or ask, then callssetRelax(String)
with the same value; ignored if null
-
pkgShow
public boolean pkgShow(List<String> packages)
- Parameters:
packages
- List of packages identified by their ID, name or local filename.- Since:
- 5.7
-
findPackage
protected org.nuxeo.connect.update.Package findPackage(String pkg) throws org.nuxeo.connect.update.PackageException
Looks for a package. First look if it's a local ZIP file, second if it's a local package and finally if it's a remote package.- Parameters:
pkg
- A ZIP filename or file path, or package ID or a package name.- Returns:
- The first package found matching the given string.
- Throws:
org.nuxeo.connect.update.PackageException
- If no package is found or if an issue occurred while searching.- See Also:
PackageDefinition
,LocalPackage
,DownloadablePackage
-
setAllowSNAPSHOT
public void setAllowSNAPSHOT(boolean allow)
- Since:
- 5.9.1
-
-