Program: 84543
Project: 84543
Buggy source:
/** 
 * Called by   {@link #doFilter(ServletRequest,ServletResponse,FilterChain)} on POST requests
 * @param httpRequest
 * @param httpResponse
 */
protected void doPost(HttpServletRequest httpRequest,HttpServletResponse httpResponse) throws IOException, ServletException {
  String page=httpRequest.getParameter("String_Node_Str");
  Map<String,Object> referenceMap=new HashMap<String,Object>();
  Writer writer=httpResponse.getWriter();
  if ("String_Node_Str".equals(page)) {
    wizardModel.databaseConnection=httpRequest.getParameter("String_Node_Str");
    checkForEmptyValue(wizardModel.databaseConnection,errors,"String_Node_Str");
    if ("String_Node_Str".equals(httpRequest.getParameter("String_Node_Str"))) {
      wizardModel.databaseName=httpRequest.getParameter("String_Node_Str");
      checkForEmptyValue(wizardModel.databaseName,errors,"String_Node_Str");
      wizardModel.hasCurrentOpenmrsDatabase=true;
    }
 else {
      wizardModel.hasCurrentOpenmrsDatabase=false;
      wizardModel.createTables=true;
      wizardModel.databaseName=httpRequest.getParameter("String_Node_Str");
      checkForEmptyValue(wizardModel.databaseName,errors,"String_Node_Str");
      wizardModel.createDatabaseUsername=httpRequest.getParameter("String_Node_Str");
      checkForEmptyValue(wizardModel.createDatabaseUsername,errors,"String_Node_Str");
      wizardModel.createDatabasePassword=httpRequest.getParameter("String_Node_Str");
      checkForEmptyValue(wizardModel.createDatabasePassword,errors,"String_Node_Str");
    }
    if (errors.isEmpty()) {
      page="String_Node_Str";
    }
    renderTemplate(page,referenceMap,writer);
  }
 else   if ("String_Node_Str".equals(page)) {
    if ("String_Node_Str".equals(httpRequest.getParameter("String_Node_Str"))) {
      renderTemplate("String_Node_Str",referenceMap,writer);
      return;
    }
    if (wizardModel.hasCurrentOpenmrsDatabase) {
      wizardModel.createTables="String_Node_Str".equals(httpRequest.getParameter("String_Node_Str"));
    }
    wizardModel.addDemoData="String_Node_Str".equals(httpRequest.getParameter("String_Node_Str"));
    if ("String_Node_Str".equals(httpRequest.getParameter("String_Node_Str"))) {
      wizardModel.currentDatabaseUsername=httpRequest.getParameter("String_Node_Str");
      checkForEmptyValue(wizardModel.currentDatabaseUsername,errors,"String_Node_Str");
      wizardModel.currentDatabasePassword=httpRequest.getParameter("String_Node_Str");
      checkForEmptyValue(wizardModel.currentDatabasePassword,errors,"String_Node_Str");
      wizardModel.hasCurrentDatabaseUser=true;
      wizardModel.createDatabaseUser=false;
    }
 else {
      wizardModel.hasCurrentDatabaseUser=false;
      wizardModel.createDatabaseUser=true;
      wizardModel.createUserUsername=httpRequest.getParameter("String_Node_Str");
      checkForEmptyValue(wizardModel.createUserUsername,errors,"String_Node_Str");
      wizardModel.createUserPassword=httpRequest.getParameter("String_Node_Str");
      checkForEmptyValue(wizardModel.createUserPassword,errors,"String_Node_Str");
    }
    if (errors.isEmpty()) {
      page="String_Node_Str";
    }
    renderTemplate(page,referenceMap,writer);
  }
 else   if ("String_Node_Str".equals(page)) {
    if ("String_Node_Str".equals(httpRequest.getParameter("String_Node_Str"))) {
      renderTemplate("String_Node_Str",referenceMap,writer);
      return;
    }
    wizardModel.moduleWebAdmin="String_Node_Str".equals(httpRequest.getParameter("String_Node_Str"));
    wizardModel.autoUpdateDatabase="String_Node_Str".equals(httpRequest.getParameter("String_Node_Str"));
    if (wizardModel.createTables) {
      page="String_Node_Str";
    }
 else {
      page="String_Node_Str";
    }
    renderTemplate(page,referenceMap,writer);
  }
 else   if ("String_Node_Str".equals(page)) {
    if ("String_Node_Str".equals(httpRequest.getParameter("String_Node_Str"))) {
      renderTemplate("String_Node_Str",referenceMap,writer);
      return;
    }
    wizardModel.adminUserPassword=httpRequest.getParameter("String_Node_Str");
    String adminUserConfirm=httpRequest.getParameter("String_Node_Str");
    if (!wizardModel.adminUserPassword.equals(adminUserConfirm)) {
      errors.add("String_Node_Str");
      renderTemplate("String_Node_Str",referenceMap,writer);
      return;
    }
    if (wizardModel.adminUserPassword.equals("String_Node_Str")) {
      errors.add("String_Node_Str");
      renderTemplate("String_Node_Str",referenceMap,writer);
      return;
    }
    try {
      OpenmrsUtil.validatePassword("String_Node_Str",wizardModel.adminUserPassword,"String_Node_Str");
    }
 catch (    PasswordException p) {
      errors.add("String_Node_Str");
      renderTemplate("String_Node_Str",referenceMap,writer);
      return;
    }
    if (errors.isEmpty()) {
      page="String_Node_Str";
    }
    renderTemplate(page,referenceMap,writer);
  }
 else   if ("String_Node_Str".equals(page)) {
    if ("String_Node_Str".equals(httpRequest.getParameter("String_Node_Str"))) {
      if (wizardModel.createTables)       renderTemplate("String_Node_Str",referenceMap,writer);
 else       renderTemplate("String_Node_Str",referenceMap,writer);
      return;
    }
    wizardModel.implementationIdName=httpRequest.getParameter("String_Node_Str");
    wizardModel.implementationId=httpRequest.getParameter("String_Node_Str");
    wizardModel.implementationIdPassPhrase=httpRequest.getParameter("String_Node_Str");
    wizardModel.implementationIdDescription=httpRequest.getParameter("String_Node_Str");
    if (wizardModel.implementationId.indexOf('^') != -1 || wizardModel.implementationId.indexOf('|') != -1) {
      errors.add("String_Node_Str");
      renderTemplate("String_Node_Str",referenceMap,writer);
      return;
    }
    if (errors.isEmpty()) {
      page="String_Node_Str";
    }
    renderTemplate(page,referenceMap,writer);
  }
 else   if ("String_Node_Str".equals(page)) {
    if ("String_Node_Str".equals(httpRequest.getParameter("String_Node_Str"))) {
      renderTemplate("String_Node_Str",referenceMap,writer);
      return;
    }
    Properties runtimeProperties=new Properties();
    String connectionUsername;
    String connectionPassword;
    if (!wizardModel.hasCurrentOpenmrsDatabase) {
      String sql="String_Node_Str";
      int result=executeStatement(false,wizardModel.createDatabaseUsername,wizardModel.createDatabasePassword,sql,wizardModel.databaseName);
      if (result < 0) {
        renderTemplate(DEFAULT_PAGE,null,writer);
        return;
      }
 else {
        wizardModel.workLog.add("String_Node_Str" + wizardModel.databaseName);
      }
    }
    if (wizardModel.createDatabaseUser) {
      connectionUsername=wizardModel.databaseName + "String_Node_Str";
      if (connectionUsername.length() > 16)       connectionUsername=wizardModel.databaseName.substring(0,11) + "String_Node_Str";
      connectionPassword="String_Node_Str";
      String chars="String_Node_Str";
      Random r=new Random();
      for (int x=0; x < 12; x++) {
        connectionPassword+=chars.charAt(r.nextInt(chars.length()));
      }
      String sql="String_Node_Str";
      executeStatement(true,wizardModel.createUserUsername,wizardModel.createUserPassword,sql,connectionUsername);
      sql="String_Node_Str";
      if (-1 != executeStatement(false,wizardModel.createUserUsername,wizardModel.createUserPassword,sql,connectionUsername,connectionPassword)) {
        wizardModel.workLog.add("String_Node_Str" + connectionUsername);
      }
 else {
        renderTemplate(DEFAULT_PAGE,null,writer);
        return;
      }
      sql="String_Node_Str";
      int result=executeStatement(false,wizardModel.createUserUsername,wizardModel.createUserPassword,sql,wizardModel.databaseName,connectionUsername);
      if (result < 0) {
        renderTemplate(DEFAULT_PAGE,null,writer);
        return;
      }
 else {
        wizardModel.workLog.add("String_Node_Str" + connectionUsername + "String_Node_Str"+ wizardModel.databaseName);
      }
    }
 else {
      connectionUsername=wizardModel.currentDatabaseUsername;
      connectionPassword=wizardModel.currentDatabasePassword;
    }
    String finalDatabaseConnectionString=wizardModel.databaseConnection.replace("String_Node_Str",wizardModel.databaseName);
    if (!verifyConnection(connectionUsername,connectionPassword,finalDatabaseConnectionString)) {
      renderTemplate(DEFAULT_PAGE,null,writer);
      return;
    }
    runtimeProperties.put("String_Node_Str",finalDatabaseConnectionString);
    runtimeProperties.put("String_Node_Str",connectionUsername);
    runtimeProperties.put("String_Node_Str",connectionPassword);
    runtimeProperties.put("String_Node_Str",wizardModel.moduleWebAdmin.toString());
    runtimeProperties.put("String_Node_Str",wizardModel.autoUpdateDatabase.toString());
    runtimeProperties.put(SchedulerConstants.SCHEDULER_USERNAME_PROPERTY,"String_Node_Str");
    runtimeProperties.put(SchedulerConstants.SCHEDULER_PASSWORD_PROPERTY,wizardModel.adminUserPassword);
    Context.setRuntimeProperties(runtimeProperties);
    if (wizardModel.createTables) {
      try {
        DatabaseUpdater.executeChangelog(LIQUIBASE_SCHEMA_DATA,null);
        DatabaseUpdater.executeChangelog(LIQUIBASE_CORE_DATA,null);
        wizardModel.workLog.add("String_Node_Str");
      }
 catch (      Exception e) {
        errors.add(e.getMessage() + "String_Node_Str");
        log.warn("String_Node_Str",e);
      }
    }
    if (wizardModel.createTables && wizardModel.addDemoData) {
      try {
        DatabaseUpdater.executeChangelog(LIQUIBASE_DEMO_DATA,null);
        wizardModel.workLog.add("String_Node_Str");
      }
 catch (      Exception e) {
        errors.add(e.getMessage() + "String_Node_Str");
        log.warn("String_Node_Str",e);
      }
    }
    try {
      DatabaseUpdater.update();
    }
 catch (    Exception e) {
      errors.add(e.getMessage() + "String_Node_Str");
      log.warn("String_Node_Str",e);
      renderTemplate(DEFAULT_PAGE,null,writer);
      return;
    }
    ContextLoader contextLoader=new ContextLoader();
    contextLoader.initWebApplicationContext(filterConfig.getServletContext());
    try {
      Context.openSession();
      Context.startup(runtimeProperties);
    }
 catch (    DatabaseUpdateException updateEx) {
      log.warn("String_Node_Str",updateEx);
      errors.add(updateEx.getMessage() + "String_Node_Str" + updateEx.getMessage());
      renderTemplate(DEFAULT_PAGE,null,writer);
      return;
    }
catch (    InputRequiredException inputRequiredEx) {
      log.warn("String_Node_Str");
      errors.add("String_Node_Str");
      renderTemplate(DEFAULT_PAGE,null,writer);
      return;
    }
    if (!wizardModel.implementationId.equals("String_Node_Str")) {
      try {
        Context.addProxyPrivilege(OpenmrsConstants.PRIV_MANAGE_GLOBAL_PROPERTIES);
        Context.addProxyPrivilege(OpenmrsConstants.PRIV_MANAGE_CONCEPT_SOURCES);
        Context.addProxyPrivilege(OpenmrsConstants.PRIV_VIEW_CONCEPT_SOURCES);
        ImplementationId implId=new ImplementationId();
        implId.setName(wizardModel.implementationIdName);
        implId.setImplementationId(wizardModel.implementationId);
        implId.setPassphrase(wizardModel.implementationIdPassPhrase);
        implId.setDescription(wizardModel.implementationIdDescription);
        Context.getAdministrationService().setImplementationId(implId);
      }
 catch (      Throwable t) {
        errors.add(t.getMessage() + "String_Node_Str");
        log.warn("String_Node_Str",t);
        renderTemplate(DEFAULT_PAGE,null,writer);
        Context.shutdown();
        WebModuleUtil.shutdownModules(filterConfig.getServletContext());
        contextLoader.closeWebApplicationContext(filterConfig.getServletContext());
        return;
      }
 finally {
        Context.removeProxyPrivilege(OpenmrsConstants.PRIV_MANAGE_GLOBAL_PROPERTIES);
        Context.removeProxyPrivilege(OpenmrsConstants.PRIV_MANAGE_CONCEPT_SOURCES);
        Context.removeProxyPrivilege(OpenmrsConstants.PRIV_VIEW_CONCEPT_SOURCES);
      }
    }
    try {
      if (wizardModel.createTables) {
        Context.authenticate("String_Node_Str","String_Node_Str");
        Context.getUserService().changePassword("String_Node_Str",wizardModel.adminUserPassword);
        Context.logout();
      }
      Listener.loadAndStartCoreModules(filterConfig.getServletContext());
      Listener.performWebStartOfModules(filterConfig.getServletContext());
      SchedulerUtil.startup(runtimeProperties);
    }
 catch (    Throwable t) {
      Context.shutdown();
      WebModuleUtil.shutdownModules(filterConfig.getServletContext());
      contextLoader.closeWebApplicationContext(filterConfig.getServletContext());
      errors.add(t.getMessage() + "String_Node_Str");
      log.warn("String_Node_Str",t);
      renderTemplate(DEFAULT_PAGE,null,writer);
      return;
    }
    FileOutputStream fos=null;
    try {
      fos=new FileOutputStream(getRuntimePropertiesFile());
      runtimeProperties.store(fos,"String_Node_Str");
      wizardModel.workLog.add("String_Node_Str" + getRuntimePropertiesFile());
    }
  finally {
      if (fos != null) {
        fos.close();
      }
    }
    initializationComplete=true;
    Context.closeSession();
    httpResponse.sendRedirect("String_Node_Str" + WebConstants.WEBAPP_NAME);
  }
}

Fixed version (ground truth):
/** 
 * Called by   {@link #doFilter(ServletRequest,ServletResponse,FilterChain)} on POST requests
 * @param httpRequest
 * @param httpResponse
 */
protected void doPost(HttpServletRequest httpRequest,HttpServletResponse httpResponse) throws IOException, ServletException {
  String page=httpRequest.getParameter("String_Node_Str");
  Map<String,Object> referenceMap=new HashMap<String,Object>();
  Writer writer=httpResponse.getWriter();
  if ("String_Node_Str".equals(page)) {
    wizardModel.databaseConnection=httpRequest.getParameter("String_Node_Str");
    checkForEmptyValue(wizardModel.databaseConnection,errors,"String_Node_Str");
    if ("String_Node_Str".equals(httpRequest.getParameter("String_Node_Str"))) {
      wizardModel.databaseName=httpRequest.getParameter("String_Node_Str");
      checkForEmptyValue(wizardModel.databaseName,errors,"String_Node_Str");
      wizardModel.hasCurrentOpenmrsDatabase=true;
    }
 else {
      wizardModel.hasCurrentOpenmrsDatabase=false;
      wizardModel.createTables=true;
      wizardModel.databaseName=httpRequest.getParameter("String_Node_Str");
      checkForEmptyValue(wizardModel.databaseName,errors,"String_Node_Str");
      wizardModel.createDatabaseUsername=httpRequest.getParameter("String_Node_Str");
      checkForEmptyValue(wizardModel.createDatabaseUsername,errors,"String_Node_Str");
      wizardModel.createDatabasePassword=httpRequest.getParameter("String_Node_Str");
      checkForEmptyValue(wizardModel.createDatabasePassword,errors,"String_Node_Str");
    }
    if (errors.isEmpty()) {
      page="String_Node_Str";
    }
    renderTemplate(page,referenceMap,writer);
  }
 else   if ("String_Node_Str".equals(page)) {
    if ("String_Node_Str".equals(httpRequest.getParameter("String_Node_Str"))) {
      renderTemplate("String_Node_Str",referenceMap,writer);
      return;
    }
    if (wizardModel.hasCurrentOpenmrsDatabase) {
      wizardModel.createTables="String_Node_Str".equals(httpRequest.getParameter("String_Node_Str"));
    }
    wizardModel.addDemoData="String_Node_Str".equals(httpRequest.getParameter("String_Node_Str"));
    if ("String_Node_Str".equals(httpRequest.getParameter("String_Node_Str"))) {
      wizardModel.currentDatabaseUsername=httpRequest.getParameter("String_Node_Str");
      checkForEmptyValue(wizardModel.currentDatabaseUsername,errors,"String_Node_Str");
      wizardModel.currentDatabasePassword=httpRequest.getParameter("String_Node_Str");
      checkForEmptyValue(wizardModel.currentDatabasePassword,errors,"String_Node_Str");
      wizardModel.hasCurrentDatabaseUser=true;
      wizardModel.createDatabaseUser=false;
    }
 else {
      wizardModel.hasCurrentDatabaseUser=false;
      wizardModel.createDatabaseUser=true;
      wizardModel.createUserUsername=httpRequest.getParameter("String_Node_Str");
      checkForEmptyValue(wizardModel.createUserUsername,errors,"String_Node_Str");
      wizardModel.createUserPassword=httpRequest.getParameter("String_Node_Str");
      checkForEmptyValue(wizardModel.createUserPassword,errors,"String_Node_Str");
    }
    if (errors.isEmpty()) {
      page="String_Node_Str";
    }
    renderTemplate(page,referenceMap,writer);
  }
 else   if ("String_Node_Str".equals(page)) {
    if ("String_Node_Str".equals(httpRequest.getParameter("String_Node_Str"))) {
      renderTemplate("String_Node_Str",referenceMap,writer);
      return;
    }
    wizardModel.moduleWebAdmin="String_Node_Str".equals(httpRequest.getParameter("String_Node_Str"));
    wizardModel.autoUpdateDatabase="String_Node_Str".equals(httpRequest.getParameter("String_Node_Str"));
    if (wizardModel.createTables) {
      page="String_Node_Str";
    }
 else {
      page="String_Node_Str";
    }
    renderTemplate(page,referenceMap,writer);
  }
 else   if ("String_Node_Str".equals(page)) {
    if ("String_Node_Str".equals(httpRequest.getParameter("String_Node_Str"))) {
      renderTemplate("String_Node_Str",referenceMap,writer);
      return;
    }
    wizardModel.adminUserPassword=httpRequest.getParameter("String_Node_Str");
    String adminUserConfirm=httpRequest.getParameter("String_Node_Str");
    if (!wizardModel.adminUserPassword.equals(adminUserConfirm)) {
      errors.add("String_Node_Str");
      renderTemplate("String_Node_Str",referenceMap,writer);
      return;
    }
    if (wizardModel.adminUserPassword.equals("String_Node_Str")) {
      errors.add("String_Node_Str");
      renderTemplate("String_Node_Str",referenceMap,writer);
      return;
    }
    try {
      OpenmrsUtil.validatePassword("String_Node_Str",wizardModel.adminUserPassword,"String_Node_Str");
    }
 catch (    PasswordException p) {
      errors.add("String_Node_Str");
      renderTemplate("String_Node_Str",referenceMap,writer);
      return;
    }
    if (errors.isEmpty()) {
      page="String_Node_Str";
    }
    renderTemplate(page,referenceMap,writer);
  }
 else   if ("String_Node_Str".equals(page)) {
    if ("String_Node_Str".equals(httpRequest.getParameter("String_Node_Str"))) {
      if (wizardModel.createTables)       renderTemplate("String_Node_Str",referenceMap,writer);
 else       renderTemplate("String_Node_Str",referenceMap,writer);
      return;
    }
    wizardModel.implementationIdName=httpRequest.getParameter("String_Node_Str");
    wizardModel.implementationId=httpRequest.getParameter("String_Node_Str");
    wizardModel.implementationIdPassPhrase=httpRequest.getParameter("String_Node_Str");
    wizardModel.implementationIdDescription=httpRequest.getParameter("String_Node_Str");
    if (wizardModel.implementationId.indexOf('^') != -1 || wizardModel.implementationId.indexOf('|') != -1) {
      errors.add("String_Node_Str");
      renderTemplate("String_Node_Str",referenceMap,writer);
      return;
    }
    if (errors.isEmpty()) {
      page="String_Node_Str";
    }
    renderTemplate(page,referenceMap,writer);
  }
 else   if ("String_Node_Str".equals(page)) {
    if ("String_Node_Str".equals(httpRequest.getParameter("String_Node_Str"))) {
      renderTemplate("String_Node_Str",referenceMap,writer);
      return;
    }
    Properties runtimeProperties=new Properties();
    String connectionUsername;
    String connectionPassword;
    if (!wizardModel.hasCurrentOpenmrsDatabase) {
      String sql="String_Node_Str";
      int result=executeStatement(false,wizardModel.createDatabaseUsername,wizardModel.createDatabasePassword,sql,wizardModel.databaseName);
      if (result < 0) {
        renderTemplate(DEFAULT_PAGE,null,writer);
        return;
      }
 else {
        wizardModel.workLog.add("String_Node_Str" + wizardModel.databaseName);
      }
    }
    if (wizardModel.createDatabaseUser) {
      connectionUsername=wizardModel.databaseName + "String_Node_Str";
      if (connectionUsername.length() > 16)       connectionUsername=wizardModel.databaseName.substring(0,11) + "String_Node_Str";
      connectionPassword="String_Node_Str";
      String chars="String_Node_Str";
      Random r=new Random();
      for (int x=0; x < 12; x++) {
        connectionPassword+=chars.charAt(r.nextInt(chars.length()));
      }
      String sql="String_Node_Str";
      executeStatement(true,wizardModel.createUserUsername,wizardModel.createUserPassword,sql,connectionUsername);
      sql="String_Node_Str";
      if (-1 != executeStatement(false,wizardModel.createUserUsername,wizardModel.createUserPassword,sql,connectionUsername,connectionPassword)) {
        wizardModel.workLog.add("String_Node_Str" + connectionUsername);
      }
 else {
        renderTemplate(DEFAULT_PAGE,null,writer);
        return;
      }
      sql="String_Node_Str";
      int result=executeStatement(false,wizardModel.createUserUsername,wizardModel.createUserPassword,sql,wizardModel.databaseName,connectionUsername);
      if (result < 0) {
        renderTemplate(DEFAULT_PAGE,null,writer);
        return;
      }
 else {
        wizardModel.workLog.add("String_Node_Str" + connectionUsername + "String_Node_Str"+ wizardModel.databaseName);
      }
    }
 else {
      connectionUsername=wizardModel.currentDatabaseUsername;
      connectionPassword=wizardModel.currentDatabasePassword;
    }
    String finalDatabaseConnectionString=wizardModel.databaseConnection.replace("String_Node_Str",wizardModel.databaseName);
    if (!verifyConnection(connectionUsername,connectionPassword,finalDatabaseConnectionString)) {
      renderTemplate(DEFAULT_PAGE,null,writer);
      return;
    }
    runtimeProperties.put("String_Node_Str",finalDatabaseConnectionString);
    runtimeProperties.put("String_Node_Str",connectionUsername);
    runtimeProperties.put("String_Node_Str",connectionPassword);
    runtimeProperties.put("String_Node_Str",wizardModel.moduleWebAdmin.toString());
    runtimeProperties.put("String_Node_Str",wizardModel.autoUpdateDatabase.toString());
    runtimeProperties.put(SchedulerConstants.SCHEDULER_USERNAME_PROPERTY,"String_Node_Str");
    runtimeProperties.put(SchedulerConstants.SCHEDULER_PASSWORD_PROPERTY,wizardModel.adminUserPassword);
    Context.setRuntimeProperties(runtimeProperties);
    if (wizardModel.createTables) {
      try {
        DatabaseUpdater.executeChangelog(LIQUIBASE_SCHEMA_DATA,null);
        DatabaseUpdater.executeChangelog(LIQUIBASE_CORE_DATA,null);
        wizardModel.workLog.add("String_Node_Str");
      }
 catch (      Exception e) {
        errors.add(e.getMessage() + "String_Node_Str");
        log.warn("String_Node_Str",e);
      }
    }
    if (wizardModel.createTables && wizardModel.addDemoData) {
      try {
        DatabaseUpdater.executeChangelog(LIQUIBASE_DEMO_DATA,null);
        wizardModel.workLog.add("String_Node_Str");
      }
 catch (      Exception e) {
        errors.add(e.getMessage() + "String_Node_Str");
        log.warn("String_Node_Str",e);
      }
    }
    try {
      DatabaseUpdater.update();
    }
 catch (    Exception e) {
      errors.add(e.getMessage() + "String_Node_Str");
      log.warn("String_Node_Str",e);
      renderTemplate(DEFAULT_PAGE,null,writer);
      return;
    }
    ContextLoader contextLoader=new ContextLoader();
    contextLoader.initWebApplicationContext(filterConfig.getServletContext());
    try {
      Context.openSession();
      Context.startup(runtimeProperties);
    }
 catch (    DatabaseUpdateException updateEx) {
      log.warn("String_Node_Str",updateEx);
      errors.add(updateEx.getMessage() + "String_Node_Str" + updateEx.getMessage());
      renderTemplate(DEFAULT_PAGE,null,writer);
      return;
    }
catch (    InputRequiredException inputRequiredEx) {
      log.warn("String_Node_Str");
      errors.add("String_Node_Str");
      renderTemplate(DEFAULT_PAGE,null,writer);
      return;
    }
    if (!wizardModel.implementationId.equals("String_Node_Str")) {
      try {
        Context.addProxyPrivilege(OpenmrsConstants.PRIV_MANAGE_GLOBAL_PROPERTIES);
        Context.addProxyPrivilege(OpenmrsConstants.PRIV_MANAGE_CONCEPT_SOURCES);
        Context.addProxyPrivilege(OpenmrsConstants.PRIV_VIEW_CONCEPT_SOURCES);
        Context.addProxyPrivilege(OpenmrsConstants.PRIV_MANAGE_IMPLEMENTATION_ID);
        ImplementationId implId=new ImplementationId();
        implId.setName(wizardModel.implementationIdName);
        implId.setImplementationId(wizardModel.implementationId);
        implId.setPassphrase(wizardModel.implementationIdPassPhrase);
        implId.setDescription(wizardModel.implementationIdDescription);
        Context.getAdministrationService().setImplementationId(implId);
      }
 catch (      Throwable t) {
        errors.add(t.getMessage() + "String_Node_Str");
        log.warn("String_Node_Str",t);
        renderTemplate(DEFAULT_PAGE,null,writer);
        Context.shutdown();
        WebModuleUtil.shutdownModules(filterConfig.getServletContext());
        contextLoader.closeWebApplicationContext(filterConfig.getServletContext());
        return;
      }
 finally {
        Context.removeProxyPrivilege(OpenmrsConstants.PRIV_MANAGE_GLOBAL_PROPERTIES);
        Context.removeProxyPrivilege(OpenmrsConstants.PRIV_MANAGE_CONCEPT_SOURCES);
        Context.removeProxyPrivilege(OpenmrsConstants.PRIV_VIEW_CONCEPT_SOURCES);
        Context.removeProxyPrivilege(OpenmrsConstants.PRIV_MANAGE_IMPLEMENTATION_ID);
      }
    }
    try {
      if (wizardModel.createTables) {
        Context.authenticate("String_Node_Str","String_Node_Str");
        Context.getUserService().changePassword("String_Node_Str",wizardModel.adminUserPassword);
        Context.logout();
      }
      Listener.loadAndStartCoreModules(filterConfig.getServletContext());
      Listener.performWebStartOfModules(filterConfig.getServletContext());
      SchedulerUtil.startup(runtimeProperties);
    }
 catch (    Throwable t) {
      Context.shutdown();
      WebModuleUtil.shutdownModules(filterConfig.getServletContext());
      contextLoader.closeWebApplicationContext(filterConfig.getServletContext());
      errors.add(t.getMessage() + "String_Node_Str");
      log.warn("String_Node_Str",t);
      renderTemplate(DEFAULT_PAGE,null,writer);
      return;
    }
    FileOutputStream fos=null;
    try {
      fos=new FileOutputStream(getRuntimePropertiesFile());
      runtimeProperties.store(fos,"String_Node_Str");
      wizardModel.workLog.add("String_Node_Str" + getRuntimePropertiesFile());
    }
  finally {
      if (fos != null) {
        fos.close();
      }
    }
    initializationComplete=true;
    Context.closeSession();
    httpResponse.sendRedirect("String_Node_Str" + WebConstants.WEBAPP_NAME);
  }
}