response.add(outModuleList);
PersistentFactory pf = (PersistentFactory) request.getService(PersistentFactory.ROLE, request.getDomain());
DataSourceComponent dataSourceComponent = (DataSourceComponent) request.getService(DataSourceComponent.ROLE,
"keel-dbpool");
updatePreProcessing(request, dataSourceComponent);
boolean needReboot = false;
boolean newUserPreferences = false;
List<Configuration> moduleConfigs = de.iritgo.aktera.base.module.ModuleInfo
.moduleConfigsSortedByDependency(request);
for (Configuration moduleConfig : moduleConfigs)
{
String moduleId = moduleConfig.getAttribute("id", "unkown");
String moduleName = moduleConfig.getChild("name").getValue("unkown");
ModuleVersion newVersion = new ModuleVersion(moduleConfig.getChild("version").getValue(null));
Output outModule = response.createOutput("module_" + moduleConfig.getAttribute("id", "unknown"));
outModuleList.add(outModule);
outModule.setAttribute("name", moduleName);
outModule.setAttribute("description", moduleConfig.getChild("description").getValue(""));
outModule.setAttribute("newVersion", newVersion.toString());
ModuleVersion currentVersion = new ModuleVersion();
try
{
Persistent version = pf.create("aktera.Version");
version.setField("type", "M");
version.setField("name", moduleId);
if (version.find())
{
currentVersion = new ModuleVersion(version.getFieldString("version"));
}
else
{
currentVersion = new ModuleVersion("0.0.0");
}
}
catch (Exception x)
{
outModule.setAttribute("oldVersion", currentVersion.toString());
outModule.setAttribute("error", "unableToRetrieveCurrentVersion");
outModule.setAttribute("errorException", x.toString());
response.addOutput("updateError", "Y");
continue;
}
outModule.setAttribute("oldVersion", currentVersion.toString());
String updateHandlerClassName = moduleConfig.getChild("update").getAttribute("class", null);
if (updateHandlerClassName != null)
{
try
{
System.out.println("UpdateDatabase: Updating module '" + moduleId + "' with handler '"
+ updateHandlerClassName + "'");
Class klass = Class.forName(updateHandlerClassName);
if (klass != null)
{
UpdateHandler updateHandler = (UpdateHandler) klass.newInstance();
Connection con = null;
try
{
con = dataSourceComponent.getConnection();
updateHandler.setConnection(con);
updateHandler.updateDatabase(request, logger, con, pf, (ModuleVersion) currentVersion
.clone(), newVersion);
}
finally