Corrections on NetworkSettingsController.
This commit is contained in:
+7
-12
@@ -52,8 +52,8 @@ public class NetworkSettingsController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private NetworkService networkService;
|
private NetworkService networkService;
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.GET)
|
@ModelAttribute
|
||||||
protected String formBackingObject(Model model) throws Exception {
|
protected void formBackingObject(Model model) throws Exception {
|
||||||
NetworkSettingsCommand command = new NetworkSettingsCommand();
|
NetworkSettingsCommand command = new NetworkSettingsCommand();
|
||||||
command.setPortForwardingEnabled(settingsService.isPortForwardingEnabled());
|
command.setPortForwardingEnabled(settingsService.isPortForwardingEnabled());
|
||||||
command.setUrlRedirectionEnabled(settingsService.isUrlRedirectionEnabled());
|
command.setUrlRedirectionEnabled(settingsService.isUrlRedirectionEnabled());
|
||||||
@@ -62,27 +62,23 @@ public class NetworkSettingsController {
|
|||||||
command.setUrlRedirectCustomUrl(settingsService.getUrlRedirectCustomUrl());
|
command.setUrlRedirectCustomUrl(settingsService.getUrlRedirectCustomUrl());
|
||||||
command.setPort(settingsService.getPort());
|
command.setPort(settingsService.getPort());
|
||||||
command.setLicenseInfo(settingsService.getLicenseInfo());
|
command.setLicenseInfo(settingsService.getLicenseInfo());
|
||||||
|
|
||||||
model.addAttribute("command",command);
|
model.addAttribute("command",command);
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping(method = RequestMethod.GET)
|
||||||
|
protected String displayForm() throws Exception {
|
||||||
return "networkSettings";
|
return "networkSettings";
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.POST)
|
@RequestMapping(method = RequestMethod.POST)
|
||||||
protected String doSubmitAction(@ModelAttribute NetworkSettingsCommand command, Model model) throws Exception {
|
protected String doSubmitAction(@ModelAttribute("command") NetworkSettingsCommand command, Model model) throws Exception {
|
||||||
command.setToast(true);
|
command.setToast(true);
|
||||||
|
|
||||||
settingsService.setPortForwardingEnabled(command.isPortForwardingEnabled());
|
settingsService.setPortForwardingEnabled(command.isPortForwardingEnabled());
|
||||||
settingsService.setUrlRedirectionEnabled(command.isUrlRedirectionEnabled());
|
settingsService.setUrlRedirectionEnabled(command.isUrlRedirectionEnabled());
|
||||||
String urlRedirectType = command.getUrlRedirectType();
|
|
||||||
if (urlRedirectType == null) {
|
|
||||||
command.setUrlRedirectType("NORMAL");
|
|
||||||
command.setUrlRedirectFrom("yourname");
|
|
||||||
command.setUrlRedirectCustomUrl("http://");
|
|
||||||
} else {
|
|
||||||
settingsService.setUrlRedirectType(UrlRedirectType.valueOf(command.getUrlRedirectType()));
|
settingsService.setUrlRedirectType(UrlRedirectType.valueOf(command.getUrlRedirectType()));
|
||||||
settingsService.setUrlRedirectFrom(StringUtils.lowerCase(command.getUrlRedirectFrom()));
|
settingsService.setUrlRedirectFrom(StringUtils.lowerCase(command.getUrlRedirectFrom()));
|
||||||
settingsService.setUrlRedirectCustomUrl(StringUtils.trimToEmpty(command.getUrlRedirectCustomUrl()));
|
settingsService.setUrlRedirectCustomUrl(StringUtils.trimToEmpty(command.getUrlRedirectCustomUrl()));
|
||||||
}
|
|
||||||
|
|
||||||
if (settingsService.getServerId() == null) {
|
if (settingsService.getServerId() == null) {
|
||||||
Random rand = new Random(System.currentTimeMillis());
|
Random rand = new Random(System.currentTimeMillis());
|
||||||
@@ -92,7 +88,6 @@ public class NetworkSettingsController {
|
|||||||
settingsService.save();
|
settingsService.save();
|
||||||
networkService.initPortForwarding(0);
|
networkService.initPortForwarding(0);
|
||||||
networkService.initUrlRedirection(true);
|
networkService.initUrlRedirection(true);
|
||||||
model.addAttribute("command",command);
|
|
||||||
return "networkSettings";
|
return "networkSettings";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user