use of org.openmrs.util.InputRequiredException in project openmrs-core by openmrs.
the class Listener method startOpenmrs.
/**
* Do the work of starting openmrs.
*
* @param servletContext
* @throws ServletException
*/
public static void startOpenmrs(ServletContext servletContext) throws ServletException {
// start openmrs
try {
// load bundled modules that are packaged into the webapp
Listener.loadBundledModules(servletContext);
Context.startup(getRuntimeProperties());
} catch (DatabaseUpdateException | InputRequiredException updateEx) {
throw new ServletException("Should not be here because updates were run previously", updateEx);
} catch (MandatoryModuleException mandatoryModEx) {
throw new ServletException(mandatoryModEx);
} catch (OpenmrsCoreModuleException coreModEx) {
// in the StartupErrorFilter class
throw coreModEx;
}
try {
// web load modules
Listener.performWebStartOfModules(servletContext);
// start the scheduled tasks
SchedulerUtil.startup(getRuntimeProperties());
} catch (Exception t) {
Context.shutdown();
WebModuleUtil.shutdownModules(servletContext);
throw new ServletException(t);
} finally {
Context.closeSession();
}
}
use of org.openmrs.util.InputRequiredException in project openmrs-core by openmrs.
the class ModuleFactory method runLiquibase.
/**
* Execute all not run changeSets in liquibase.xml for the given module
*
* @param module the module being executed on
*/
private static void runLiquibase(Module module) {
JarFile jarFile = null;
boolean liquibaseFileExists;
try {
try {
jarFile = new JarFile(module.getFile());
} catch (IOException e) {
throw new ModuleException("Unable to get jar file", module.getName(), e);
}
// check whether module has a liquibase.xml
InputStream inStream = null;
ZipEntry entry = null;
try {
inStream = ModuleUtil.getResourceFromApi(jarFile, module.getModuleId(), module.getVersion(), MODULE_CHANGELOG_FILENAME);
if (inStream == null) {
// Try the old way. Loading from the root of the omod
entry = jarFile.getEntry(MODULE_CHANGELOG_FILENAME);
}
liquibaseFileExists = (inStream != null) || (entry != null);
} finally {
IOUtils.closeQuietly(inStream);
}
} finally {
try {
if (jarFile != null) {
jarFile.close();
}
} catch (IOException e) {
log.warn("Unable to close jarfile: " + jarFile.getName());
}
}
if (liquibaseFileExists) {
try {
// run liquibase.xml by Liquibase API
DatabaseUpdater.executeChangelog(MODULE_CHANGELOG_FILENAME, null, null, null, getModuleClassLoader(module));
} catch (InputRequiredException ire) {
// the user would be stepped through the questions returned here.
throw new ModuleException("Input during database updates is not yet implemented.", module.getName(), ire);
} catch (Exception e) {
throw new ModuleException("Unable to update data model using liquibase.xml.", module.getName(), e);
}
}
}
Aggregations