예제 #1
0
  @Override
  public List<Settings> getBundleSettings(long bundleId) throws IOException {
    List<Settings> bundleSettings = new ArrayList<>();

    Map<String, Properties> allDefaultProperties = getBundleDefaultProperties(bundleId);
    Map<String, Properties> allModuleEntries =
        configurationService.getAllBundleProperties(
            getBundleSymbolicName(bundleId), allDefaultProperties);

    for (Map.Entry<String, Properties> entry : allModuleEntries.entrySet()) {
      List<SettingsOption> settingsList = ParamParser.parseProperties(entry.getValue());
      bundleSettings.add(new Settings(entry.getKey(), settingsList));
    }

    return bundleSettings;
  }
예제 #2
0
  @Override
  public void saveBundleSettings(Settings settings, long bundleId) throws IOException {
    Properties props = ParamParser.constructProperties(settings);

    configurationService.addOrUpdateProperties(
        getBundleSymbolicName(bundleId),
        getVersion(bundleId),
        settings.getSection(),
        props,
        getBundleDefaultProperties(bundleId).get(settings.getSection()));

    Map<String, Object> params = new HashMap<>();
    params.put(ConfigurationConstants.BUNDLE_ID, bundleId);
    params.put(ConfigurationConstants.BUNDLE_SYMBOLIC_NAME, getBundleSymbolicName(bundleId));
    params.put(ConfigurationConstants.BUNDLE_SECTION, settings.getSection());

    MotechEvent bundleSettingsChangedEvent =
        new MotechEvent(ConfigurationConstants.BUNDLE_SETTINGS_CHANGED_EVENT_SUBJECT, params);
    eventRelay.sendEventMessage(bundleSettingsChangedEvent);
  }
예제 #3
0
  @Override
  public AdminSettings getSettings() {
    MotechSettings motechSettings = configurationService.getPlatformSettings();
    List<Settings> settingsList = new ArrayList<>();
    AdminSettings adminSettings = new AdminSettings(settingsList, false);

    if (motechSettings != null) {
      List<SettingsOption> generalOptions = new ArrayList<>();
      List<SettingsOption> securityOptions = new ArrayList<>();
      List<SettingsOption> jmxOptions = new ArrayList<>();

      SettingsOption languageOption =
          ParamParser.parseParam(ConfigurationConstants.LANGUAGE, motechSettings.getLanguage());
      generalOptions.add(languageOption);
      SettingsOption msgOption =
          ParamParser.parseParam(
              ConfigurationConstants.STATUS_MSG_TIMEOUT, motechSettings.getStatusMsgTimeout());
      generalOptions.add(msgOption);
      SettingsOption serverUrlOption =
          ParamParser.parseParam(ConfigurationConstants.SERVER_URL, motechSettings.getServerUrl());
      generalOptions.add(serverUrlOption);
      SettingsOption uploadSizeOption =
          ParamParser.parseParam(
              ConfigurationConstants.UPLOAD_SIZE, motechSettings.getUploadSize());
      generalOptions.add(uploadSizeOption);

      SettingsOption emailRequiredOption =
          ParamParser.parseParam(
              ConfigurationConstants.EMAIL_REQUIRED, motechSettings.getEmailRequired());
      securityOptions.add(emailRequiredOption);
      SettingsOption sessionTimeoutOption =
          ParamParser.parseParam(
              ConfigurationConstants.SESSION_TIMEOUT, motechSettings.getSessionTimeout());
      securityOptions.add(sessionTimeoutOption);
      SettingsOption failureLoginLimit =
          ParamParser.parseParam(
              ConfigurationConstants.FAILURE_LOGIN_LIMIT, motechSettings.getFailureLoginLimit());
      securityOptions.add(failureLoginLimit);
      SettingsOption minPasswordLengthOption =
          ParamParser.parseParam(
              ConfigurationConstants.MIN_PASSWORD_LENGTH, motechSettings.getMinPasswordLength());
      securityOptions.add(minPasswordLengthOption);
      SettingsOption passwordValidatorOption =
          ParamParser.parseParam(
              ConfigurationConstants.PASSWORD_VALIDATOR, motechSettings.getPasswordValidator());
      securityOptions.add(passwordValidatorOption);
      SettingsOption passwordResetOption =
          ParamParser.parseParam(
              ConfigurationConstants.PASSWORD_RESET_DAYS,
              motechSettings.getNumberOfDaysToChangePassword());
      securityOptions.add(passwordResetOption);
      SettingsOption passwordReminderOption =
          ParamParser.parseParam(
              ConfigurationConstants.PASSWORD_REMINDER,
              motechSettings.isPasswordResetReminderEnabled());
      securityOptions.add(passwordReminderOption);
      SettingsOption passwordRemindDaysOption =
          ParamParser.parseParam(
              ConfigurationConstants.PASSWORD_REMINDER_DAYS,
              motechSettings.getNumberOfDaysForReminder());
      securityOptions.add(passwordRemindDaysOption);

      SettingsOption jmxUrlOption =
          ParamParser.parseParam(ConfigurationConstants.JMX_HOST, motechSettings.getJmxHost());
      jmxOptions.add(jmxUrlOption);
      SettingsOption jmxBrokerOption =
          ParamParser.parseParam(ConfigurationConstants.JMX_BROKER, motechSettings.getJmxBroker());
      jmxOptions.add(jmxBrokerOption);

      Settings generalSettings = new Settings("general", generalOptions);
      Settings securitySettings = new Settings("security", securityOptions);
      Settings jmxSettings = new Settings("jmx", jmxOptions);

      settingsList.add(generalSettings);
      settingsList.add(securitySettings);
      settingsList.add(jmxSettings);

      if (ConfigSource.FILE.equals(configurationService.getConfigSource())) {
        adminSettings = new AdminSettings(settingsList, true);
      } else {
        adminSettings = new AdminSettings(settingsList, false);
      }
    }
    return adminSettings;
  }