public SetSettingsResult execute(SetSettingsAction action,
ExecutionContext context) throws DispatchException {
logger.trace("Saving server settings {}", action);
ServerSettings settings = action.getSettings();
JizzStation station = jizzStationDao.getPrimaryStation();
boolean isNewInstall = false;
if (station == null) {
logger.debug("Creating new station");
station = new JizzStation();
station.setKey(UUID.randomUUID().toString());
isNewInstall = true;
}
station.setName(settings.getStationName());
station.setLocale(settings.getStationLocale());
station.setUrl(settings.getStationUrl());
station.setBroadcastSchedule(settings.getBroadcastSchedule());
station.setSmtpServerHost(settings.getSmtpServerHost());
station.setSmtpServerPort(settings.getSmtpServerPort());
station = jizzStationDao.createOrUpdateStation(station);
if (isNewInstall) {
logger.info("New install - making current user an admin of this "
+ "new station");