コード例 #1
0
  protected void doSubmitAction(Object cmd) throws Exception {
    NetworkSettingsCommand command = (NetworkSettingsCommand) cmd;

    settingsService.setPortForwardingEnabled(command.isPortForwardingEnabled());
    settingsService.setUrlRedirectionEnabled(command.isUrlRedirectionEnabled());
    settingsService.setUrlRedirectFrom(StringUtils.lowerCase(command.getUrlRedirectFrom()));

    if (!settingsService.isLicenseValid() && settingsService.getUrlRedirectTrialExpires() == null) {
      Date expiryDate = new Date(System.currentTimeMillis() + TRIAL_DAYS * 24L * 3600L * 1000L);
      settingsService.setUrlRedirectTrialExpires(expiryDate);
    }

    if (settingsService.getServerId() == null) {
      Random rand = new Random(System.currentTimeMillis());
      settingsService.setServerId(String.valueOf(Math.abs(rand.nextLong())));
    }

    settingsService.save();
    networkService.initPortForwarding();
    networkService.initUrlRedirection(true);
  }
コード例 #2
0
  protected Object formBackingObject(HttpServletRequest request) throws Exception {
    NetworkSettingsCommand command = new NetworkSettingsCommand();
    command.setPortForwardingEnabled(settingsService.isPortForwardingEnabled());
    command.setUrlRedirectionEnabled(settingsService.isUrlRedirectionEnabled());
    command.setUrlRedirectFrom(settingsService.getUrlRedirectFrom());
    command.setPort(settingsService.getPort());

    Date trialExpires = settingsService.getUrlRedirectTrialExpires();
    command.setTrialExpires(trialExpires);
    command.setTrialExpired(trialExpires != null && trialExpires.before(new Date()));
    command.setTrial(trialExpires != null && !settingsService.isLicenseValid());

    return command;
  }