Package org.openbravo.erpCommon.modules
Class ImportModule
- java.lang.Object
-
- org.openbravo.erpCommon.modules.ImportModule
-
- All Implemented Interfaces:
Serializable
public class ImportModule extends Object implements Serializable
ImportModule is able to install modules. This is done in two steps: -First check if it is possible to install and receive the latest installable modules -Second install them These two processes are callable independently in order to do it from UI and show messages and wait for confirmation after first one. It is possible to do the whole installation remotely pulling for the modules to install from the central repository or locally, installing everything from the obx file (which can be passed as an InputStream or as a String file name)- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static int
MSG_ERROR
static int
MSG_SUCCESS
static int
MSG_WARN
-
Constructor Summary
Constructors Constructor Description ImportModule(ConnectionProvider conn, String obdir, VariablesSecureApp _vars)
Initializes a new ImportModule object, it reads from obdir directory the database model to be able to read the xml information within the obx file.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description boolean
checkDependenciesFile(InputStream file)
Check the dependencies for a file.boolean
checkDependenciesId(String[] installableModules, String[] updateableModules, HashMap<String,String> maturityLevels)
Check the dependencies for a id.void
execute()
Executes the modules installation, first one of the checkDependencies method should have been called in order to set the installable and updateable modules.void
execute(InputStream file)
Executes the modules installation, first one of the checkDependencies method should have been called in order to set the installable and updateable modules.void
execute(InputStream file, InputStream file2)
Deprecated.void
execute(String fileName)
Executes the modules installation, first one of the checkDependencies method should have been called in order to set the installable and updateable modules.OBError
getCheckError()
Returns the list of errors.String[]
getDependencyErrors()
static HashMap<String,String[][]>
getInstalledModulesAndDeps()
Returns the current installed modules with its version (with the exception of those which are marked for deinstallation)boolean
getIsLocal()
static org.codehaus.jettison.json.JSONObject
getJsonInstalledModulesAndDeps()
Module
getModule(String moduleID)
Returns the module with the ID that is in the module to install or update.Module[]
getModulesToInstall()
Returns the list of modules to install.Module[]
getModulesToMerge()
Returns the list of modules to merge.Module[]
getModulesToUpdate()
Returns the list of modules to update.OBError
getOBError(ConnectionProvider conn)
Returns an OBError instance based on the log for the current ImportModule instancestatic StringBuilder
getScanError()
boolean
isChecked()
boolean
isModuleUpdate(InputStream is)
Checks whether the given .obx InputStream contains an update to an already installed version.boolean
isUpgradePrecheckFail()
static Map<String,String>
scanForUpdates(ConnectionProvider conn, VariablesSecureApp vars)
Scans for updates for the existent modules and sets and returs the list of modules that have updates availablevoid
setForce(boolean force)
void
setInstallLocal(boolean v)
Set the install locally variable, install locally means that no pull is going to be done for the contents of the obx, it will be installed directly from the obx file regardless better versions are available.
-
-
-
Field Detail
-
MSG_SUCCESS
public static final int MSG_SUCCESS
- See Also:
- Constant Field Values
-
MSG_WARN
public static final int MSG_WARN
- See Also:
- Constant Field Values
-
MSG_ERROR
public static final int MSG_ERROR
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ImportModule
public ImportModule(ConnectionProvider conn, String obdir, VariablesSecureApp _vars)
Initializes a new ImportModule object, it reads from obdir directory the database model to be able to read the xml information within the obx file.- Parameters:
obdir
- base directory for the application_vars
- VariablesSecureApp that will be used to parse messages, if null they will not be parsed.
-
-
Method Detail
-
isModuleUpdate
public boolean isModuleUpdate(InputStream is) throws Exception
Checks whether the given .obx InputStream contains an update to an already installed version.- Parameters:
is
- an InputStream to the module .obx file- Returns:
- true if the .obx represents an update to the module
- Throws:
Exception
- if an error occurs performing the comparison
-
checkDependenciesFile
public boolean checkDependenciesFile(InputStream file) throws Exception
Check the dependencies for a file. Used only for local installation from obx file.- Throws:
Exception
- See Also:
checkDependenciesId(String[], String[], HashMap)
-
checkDependenciesId
public boolean checkDependenciesId(String[] installableModules, String[] updateableModules, HashMap<String,String> maturityLevels) throws Exception
Check the dependencies for a id. After checking dependencies modulesToInstall and modulesToUpdate arrays of modules are completed, thus it is possible to know which are the modules that are needed to install and/or update in order to complete the installation.- Throws:
Exception
-
execute
public void execute(String fileName) throws Exception
Executes the modules installation, first one of the checkDependencies method should have been called in order to set the installable and updateable modules. This method receives a filename- Throws:
Exception
-
execute
@Deprecated public void execute(InputStream file, InputStream file2)
Deprecated.Deprecated, use instead ImportModule.execute(InputStream file)- Parameters:
file
-file2
-
-
execute
public void execute(InputStream file)
Executes the modules installation, first one of the checkDependencies method should have been called in order to set the installable and updateable modules. This method receives a InputStream of the obx file
-
execute
public void execute()
Executes the modules installation, first one of the checkDependencies method should have been called in order to set the installable and updateable modules.
-
getModulesToUpdate
public Module[] getModulesToUpdate()
Returns the list of modules to update. This list is set by one of the checkDependencies methods.
-
getModulesToInstall
public Module[] getModulesToInstall()
Returns the list of modules to install. This list is set by one of the checkDependencies methods.
-
getModulesToMerge
public Module[] getModulesToMerge()
Returns the list of modules to merge. This list is set by one of the checkDependencies methods.
-
getCheckError
public OBError getCheckError()
Returns the list of errors. This list is set by one of the checkDependencies methods. A list of errors is returned in case the selected modules cannot be installed because dependencies are not satisfied.
-
getScanError
public static StringBuilder getScanError()
-
setInstallLocal
public void setInstallLocal(boolean v)
Set the install locally variable, install locally means that no pull is going to be done for the contents of the obx, it will be installed directly from the obx file regardless better versions are available.
-
getOBError
public OBError getOBError(ConnectionProvider conn)
Returns an OBError instance based on the log for the current ImportModule instance
-
getIsLocal
public boolean getIsLocal()
-
scanForUpdates
public static Map<String,String> scanForUpdates(ConnectionProvider conn, VariablesSecureApp vars)
Scans for updates for the existent modules and sets and returs the list of modules that have updates available- Parameters:
conn
-vars
-- Returns:
- the list of updates keyed by module id
-
getInstalledModulesAndDeps
public static HashMap<String,String[][]> getInstalledModulesAndDeps()
Returns the current installed modules with its version (with the exception of those which are marked for deinstallation)- Returns:
- HashMap<String, String[][]> --> <ModuleId, VersionInfo[]>
- VersionInfo [x][0] -> Type "M" Module, "D" Dependency
- VersionInfo [x][1] -> If type=="M", version number. If type =="D" dep module Id
- VersionInfo [x][2] -> If type=="M", module visibility level. If type=="D", from version
- VersionInfo [x][3] -> If type=="D", to version
- VersionInfo [x][4] -> If type=="D", "Y"/"N" is included
- VersionInfo [x][5] -> If type=="D", Dependent module name
- VersionInfo [x][6] -> If type=="D", Dependency enforcement
- VersionInfo [x][7] -> If type=="D", Instance dependency enforcement
-
getJsonInstalledModulesAndDeps
public static org.codehaus.jettison.json.JSONObject getJsonInstalledModulesAndDeps()
-
getModule
public Module getModule(String moduleID)
Returns the module with the ID that is in the module to install or update.- Parameters:
moduleID
-- Returns:
- the module with the moduleID, or null if not found
-
isChecked
public boolean isChecked()
-
setForce
public void setForce(boolean force)
-
getDependencyErrors
public String[] getDependencyErrors()
-
isUpgradePrecheckFail
public boolean isUpgradePrecheckFail()
-
-