public class ModuleUtil
extends java.lang.Object
Constructor and Description |
---|
ModuleUtil() |
Modifier and Type | Method and Description |
---|---|
static java.lang.Boolean |
allowAdmin() |
static java.lang.Boolean |
checkForModuleUpdates()
Iterates over the modules and checks each update.rdf file for an update
|
protected static void |
checkMandatoryModulesStarted()
Looks at the
|
protected static void |
checkOpenmrsCoreModulesStarted()
Looks at the list of modules in
ModuleConstants.CORE_MODULES to make sure that all
modules that are core to OpenMRS are started and have at least a minimum version that OpenMRS
needs. |
static void |
checkRequiredVersion(java.lang.String version,
java.lang.String versionRange)
This method is an enhancement of
compareVersion(String, String) and adds support for
wildcard characters and upperbounds. |
static int |
compareVersion(java.lang.String version,
java.lang.String value)
Compares
version to value version and value are strings like
1.9.2.0 Returns 0 if either version or value is null. |
static void |
expandJar(java.io.File fileToExpand,
java.io.File tmpModuleDir,
java.lang.String name,
boolean keepFullPath)
Expand the given
fileToExpand jar to the tmpModuleFile |
static java.net.URL |
file2url(java.io.File file)
Utility method to convert a
File object to a local URL. |
static java.util.List<java.lang.String> |
getMandatoryModules()
Returns all modules that are marked as mandatory.
|
static Module |
getModuleForPath(java.lang.String path)
Gets the module that should handle a path.
|
static java.io.File |
getModuleRepository()
Gets the folder where modules are stored.
|
static java.util.Collection<java.lang.String> |
getPackagesFromFile(java.io.File file)
This loops over all FILES in this jar to get the package names.
|
static java.lang.String |
getPathForResource(Module module,
java.lang.String path)
Takes a global path and returns the local path within the specified module.
|
static java.lang.String |
getURL(java.net.URL url)
Downloads the contents of a URL and copies them to a string (Borrowed from oreilly)
|
static java.io.InputStream |
getURLStream(java.net.URL url)
Downloads the contents of a URL and copies them to a string (Borrowed from oreilly)
|
static boolean |
ignoreCoreModules()
Uses the runtime properties to determine if the core modules should be enforced or not.
|
static java.io.File |
insertModuleFile(java.io.InputStream inputStream,
java.lang.String filename)
Add the
inputStream as a file in the modules repository |
static boolean |
isVersionWithQualifier(java.lang.String version)
Checks for qualifier version (i.e "-SNAPSHOT", "-ALPHA" etc.
|
static boolean |
matchRequiredVersions(java.lang.String version,
java.lang.String versionRange)
This method is an enhancement of
compareVersion(String, String) and adds support for
wildcard characters and upperbounds. |
protected static java.io.InputStream |
openConnectionCheckRedirects(java.net.URLConnection c)
Convenience method to follow http to https redirects.
|
static org.springframework.context.support.AbstractRefreshableApplicationContext |
refreshApplicationContext(org.springframework.context.support.AbstractRefreshableApplicationContext ctx) |
static org.springframework.context.support.AbstractRefreshableApplicationContext |
refreshApplicationContext(org.springframework.context.support.AbstractRefreshableApplicationContext ctx,
boolean isOpenmrsStartup,
Module startedModule)
Refreshes the given application context "properly" in OpenMRS.
|
static void |
shutdown()
Stops the module system by calling stopModule for all modules that are currently started
|
static void |
startup(java.util.Properties props)
Start up the module system with the given properties.
|
public static void startup(java.util.Properties props) throws ModuleMustStartException, OpenmrsCoreModuleException
props
- Properties (OpenMRS runtime properties)ModuleMustStartException
OpenmrsCoreModuleException
public static void shutdown()
public static java.io.File insertModuleFile(java.io.InputStream inputStream, java.lang.String filename)
inputStream
as a file in the modules repositoryinputStream
- InputStream
to loadpublic static boolean matchRequiredVersions(java.lang.String version, java.lang.String versionRange)
compareVersion(String, String)
and adds support for
wildcard characters and upperbounds. checkRequiredVersion(String, String)
internally. version
- openmrs version number to be comparedversionRange
- value in the config file for required openmrs versionversion
is within the value
public static void checkRequiredVersion(java.lang.String version, java.lang.String versionRange) throws ModuleException
compareVersion(String, String)
and adds support for
wildcard characters and upperbounds. version
- openmrs version number to be comparedversionRange
- value in the config file for required openmrs versionModuleException
- if the version
is not within the value
public static int compareVersion(java.lang.String version, java.lang.String value)
version
to value
version and value are strings like
1.9.2.0 Returns 0
if either version
or value
is null.version
- String like 1.9.2.0value
- String like 1.9.2.00
if version
is equal to the argument
value
; a value less than 0
if version
is
numerically less than the argument value
; and a value greater than
0
if version
is numerically greater than the argument
value
public static boolean isVersionWithQualifier(java.lang.String version)
version
- String like 1.9.2-SNAPSHOTpublic static java.io.File getModuleRepository()
public static java.net.URL file2url(java.io.File file) throws java.net.MalformedURLException
File
object to a local URL.file
- a file objectjava.net.MalformedURLException
- if file can't be represented as URL for some reasonpublic static void expandJar(java.io.File fileToExpand, java.io.File tmpModuleDir, java.lang.String name, boolean keepFullPath) throws java.io.IOException
fileToExpand
jar to the tmpModuleFile directory
If name
is null, the entire jar is expanded. Ifname
is not null,
then only that path/file is expanded.
fileToExpand
- file pointing at a .jartmpModuleDir
- directory in which to place the filesname
- filename inside of the jar to look for and expandkeepFullPath
- if true, will recreate entire directory structure in tmpModuleDir
relating to name
. if false will start directory structure at
name
java.io.IOException
public static java.io.InputStream getURLStream(java.net.URL url)
url
- protected static java.io.InputStream openConnectionCheckRedirects(java.net.URLConnection c) throws java.io.IOException
c
- the URLConnection
to openInputStream
that is not necessarily at the same url, possibly at a 403 redirect.java.io.IOException
#getURLStream(URL)}
public static java.lang.String getURL(java.net.URL url)
url
- public static java.lang.Boolean checkForModuleUpdates() throws ModuleException
ModuleException
public static java.lang.Boolean allowAdmin()
public static org.springframework.context.support.AbstractRefreshableApplicationContext refreshApplicationContext(org.springframework.context.support.AbstractRefreshableApplicationContext ctx)
ModuleUtil#refreshApplicationContext(AbstractRefreshableApplicationContext, Module)
public static org.springframework.context.support.AbstractRefreshableApplicationContext refreshApplicationContext(org.springframework.context.support.AbstractRefreshableApplicationContext ctx, boolean isOpenmrsStartup, Module startedModule)
ctx
- Spring application context that needs refreshing.isOpenmrsStartup
- if this refresh is being done at application startup.startedModule
- the module that was just started and waiting on the context refresh.protected static void checkMandatoryModulesStarted() throws ModuleException
ModuleException
- if a mandatory module isn't startedprotected static void checkOpenmrsCoreModulesStarted() throws OpenmrsCoreModuleException
ModuleConstants.CORE_MODULES
to make sure that all
modules that are core to OpenMRS are started and have at least a minimum version that OpenMRS
needs.ModuleException
- if a module that is core to OpenMRS is not startedOpenmrsCoreModuleException
public static boolean ignoreCoreModules()
public static java.util.List<java.lang.String> getMandatoryModules()
public static Module getModuleForPath(java.lang.String path)
Gets the module that should handle a path. The path you pass in should be a module id (in path format, i.e. /ui/springmvc, not ui.springmvc) followed by a resource. Something like the following: /ui/springmvc/css/ui.css The first running module out of the following would be returned: ui.springmvc.css ui.springmvc ui
path
- public static java.lang.String getPathForResource(Module module, java.lang.String path)
module
- path
- public static java.util.Collection<java.lang.String> getPackagesFromFile(java.io.File file)
file
- jar file to look intoCopyright © 2018 OpenMRS Inc.. All Rights Reserved.