use of org.motechproject.server.web.validator.StartupFormValidator in project motech by motech.
the class StartupController method submitForm.
@RequestMapping(value = "/startup", method = RequestMethod.POST)
@ResponseBody
public List<String> submitForm(@RequestBody StartupForm startupSettings) throws IOException {
ConfigSource configSource = (configurationService.loadBootstrapConfig() != null) ? configurationService.loadBootstrapConfig().getConfigSource() : ConfigSource.UI;
StartupFormValidator startupFormValidator = startupFormValidatorFactory.getStartupFormValidator(startupSettings, userService);
List<String> errors = startupFormValidator.validate(startupSettings, configurationService.getConfigSource());
if (!errors.isEmpty()) {
return errors;
} else if (!startupManager.canLaunchBundles()) {
if (ConfigSource.UI.equals(configSource)) {
MotechSettings settings = startupManager.getDefaultSettings();
settings.setLanguage(startupSettings.getLanguage());
settings.setLoginModeValue(startupSettings.getLoginMode());
settings.setProviderName(startupSettings.getProviderName());
settings.setProviderUrl(startupSettings.getProviderUrl());
configurationService.savePlatformSettings(settings);
if (LoginMode.REPOSITORY.equals(LoginMode.valueOf(startupSettings.getLoginMode()))) {
registerMotechAdmin(startupSettings);
}
} else {
registerMotechAdmin(startupSettings);
}
startupManager.startup();
}
return errors;
}
Aggregations