Package org.elasticsearch.common.settings

Examples of org.elasticsearch.common.settings.SettingsException


    }
  }

  private void validateConfigurationString(String value, String configFieldName) throws SettingsException {
    if (Utils.isEmpty(value)) {
      throw new SettingsException("No default '" + configFieldName + "' configuration found!");
    }
  }
View Full Code Here


    }
  }

  private void validateConfigurationObject(Object value, String configFieldName) throws SettingsException {
    if (value == null) {
      throw new SettingsException("No default '" + configFieldName + "' configuration found!");
    }
  }
View Full Code Here

    if (settings.containsKey("jira")) {
      Map<String, Object> jiraSettings = (Map<String, Object>) settings.get("jira");
      jiraUrlBase = XContentMapValues.nodeStringValue(jiraSettings.get("urlBase"), null);
      if (Utils.isEmpty(jiraUrlBase)) {
        throw new SettingsException("jira/urlBase element of configuration structure not found or empty");
      }
      Integer timeout = new Long(Utils.parseTimeValue(jiraSettings, "timeout", 5, TimeUnit.SECONDS)).intValue();
      jiraUser = XContentMapValues.nodeStringValue(jiraSettings.get("username"), "Anonymous access");
      jiraClient = new JIRA5RestClient(jiraUrlBase, XContentMapValues.nodeStringValue(jiraSettings.get("username"),
          null), XContentMapValues.nodeStringValue(jiraSettings.get("pwd"), null), timeout);
      jiraClient.setListJIRAIssuesMax(XContentMapValues.nodeIntegerValue(jiraSettings.get("maxIssuesPerRequest"), 50));
      if (jiraSettings.get("jqlTimeZone") != null) {
        TimeZone tz = TimeZone.getTimeZone(XContentMapValues.nodeStringValue(jiraSettings.get("jqlTimeZone"), null));
        jiraJqlTimezone = tz.getDisplayName();
        jiraClient.setJQLDateFormatTimezone(tz);
      }
      maxIndexingThreads = XContentMapValues.nodeIntegerValue(jiraSettings.get("maxIndexingThreads"), 1);
      indexUpdatePeriod = Utils.parseTimeValue(jiraSettings, "indexUpdatePeriod", 5, TimeUnit.MINUTES);
      indexFullUpdatePeriod = Utils.parseTimeValue(jiraSettings, "indexFullUpdatePeriod", 12, TimeUnit.HOURS);
      if (jiraSettings.containsKey("projectKeysIndexed")) {
        allIndexedProjectsKeys = Utils.parseCsvString(XContentMapValues.nodeStringValue(
            jiraSettings.get("projectKeysIndexed"), null));
        if (allIndexedProjectsKeys != null) {
          // stop loading from JIRA
          allIndexedProjectsKeysNextRefresh = Long.MAX_VALUE;
        }
      }
      if (jiraSettings.containsKey("projectKeysExcluded")) {
        projectKeysExcluded = Utils.parseCsvString(XContentMapValues.nodeStringValue(
            jiraSettings.get("projectKeysExcluded"), null));
      }
    } else {
      throw new SettingsException("'jira' element of river configuration structure not found");
    }

    Map<String, Object> indexSettings = null;
    if (settings.containsKey("index")) {
      indexSettings = (Map<String, Object>) settings.get("index");
      indexName = XContentMapValues.nodeStringValue(indexSettings.get("index"), riverName.name());
      typeName = XContentMapValues.nodeStringValue(indexSettings.get("type"), INDEX_ISSUE_TYPE_NAME_DEFAULT);
    } else {
      indexName = riverName.name();
      typeName = INDEX_ISSUE_TYPE_NAME_DEFAULT;
    }

    Map<String, Object> activityLogSettings = null;
    if (settings.containsKey("activity_log")) {
      activityLogSettings = (Map<String, Object>) settings.get("activity_log");
      activityLogIndexName = Utils
          .trimToNull(XContentMapValues.nodeStringValue(activityLogSettings.get("index"), null));
      if (activityLogIndexName == null) {
        throw new SettingsException(
            "'activity_log/index' element of river configuration structure must be defined with some string");
      }
      activityLogTypeName = Utils.trimToNull(XContentMapValues.nodeStringValue(activityLogSettings.get("type"),
          INDEX_ACTIVITY_TYPE_NAME_DEFAULT));
    }
View Full Code Here

        for (Map<String, Object> ppc : preproclist) {
          try {
            indexStructureBuilder.addIssueDataPreprocessor(StructuredContentPreprocessorFactory.createPreprocessor(ppc,
                client));
          } catch (IllegalArgumentException e) {
            throw new SettingsException(e.getMessage(), e);
          }
        }
      }
    }
  }
View Full Code Here

  protected String fieldSource;

  @Override
  public void init(Map<String, Object> settings) throws SettingsException {
    if (settings == null) {
      throw new SettingsException("'settings' section is not defined for preprocessor " + name);
    }
    fieldTarget = XContentMapValues.nodeStringValue(settings.get(CFG_TARGET_FIELD), null);
    fieldSource = XContentMapValues.nodeStringValue(settings.get(CFG_SOURCE_FIELD), null);
    validateConfigurationStringNotEmpty(fieldSource, CFG_SOURCE_FIELD);
    validateConfigurationStringNotEmpty(fieldTarget, CFG_TARGET_FIELD);
View Full Code Here

  @SuppressWarnings("unchecked")
  @Override
  public void init(Map<String, Object> settings) throws SettingsException {
    if (client == null) {
      throw new SettingsException("ElasticSearch client is required for preprocessor " + name);
    }
    if (settings == null) {
      throw new SettingsException("'settings' section is not defined for preprocessor " + name);
    }
    indexName = XContentMapValues.nodeStringValue(settings.get(CFG_index_name), null);
    validateConfigurationStringNotEmpty(indexName, CFG_index_name);
    indexType = XContentMapValues.nodeStringValue(settings.get(CFG_index_type), null);
    validateConfigurationStringNotEmpty(indexType, CFG_index_type);
    sourceField = XContentMapValues.nodeStringValue(settings.get(CFG_source_field), null);
    if (ValueUtils.isEmpty(sourceField)) {
      sourceField = null;
      sourceValuePattern = XContentMapValues.nodeStringValue(settings.get(CFG_source_value), null);
    }
    if (ValueUtils.isEmpty(sourceField) && ValueUtils.isEmpty(sourceValuePattern)) {
      throw new SettingsException("At least one of 'settings/" + CFG_source_field + "' or 'settings/"
          + CFG_source_value + "' configuration value must be defined for '" + name + "' preprocessor");
    }
    resultMapping = (List<Map<String, String>>) settings.get(CFG_result_mapping);
    validateResultMappingConfiguration(resultMapping, CFG_result_mapping);
    idxSearchField = XContentMapValues.nodeStringValue(settings.get(CFG_idx_search_field), null);
View Full Code Here

   * @throws SettingsException thrown if value is not valid
   */
  protected void validateResultMappingConfiguration(List<Map<String, String>> value, String configFieldName)
      throws SettingsException {
    if (value == null || value.isEmpty()) {
      throw new SettingsException("Missing or empty 'settings/" + configFieldName + "' configuration array for '"
          + name + "' preprocessor");
    }
    for (Map<String, String> mappingRecord : value) {
      if (ValueUtils.isEmpty(mappingRecord.get(CFG_idx_result_field))) {
        throw new SettingsException("Missing or empty 'settings/" + configFieldName + "/" + CFG_idx_result_field
            + "' configuration value for '" + name + "' preprocessor");
      }
      if (ValueUtils.isEmpty(mappingRecord.get(CFG_target_field))) {
        throw new SettingsException("Missing or empty 'settings/" + configFieldName + "/" + CFG_target_field
            + "' configuration value for '" + name + "' preprocessor");
      }
    }
  }
View Full Code Here

  protected String field;

  @Override
  public void init(Map<String, Object> settings) throws SettingsException {
    if (settings == null) {
      throw new SettingsException("'settings' section is not defined for preprocessor " + name);
    }
    field = XContentMapValues.nodeStringValue(settings.get(CFG_FIELD), null);
    validateConfigurationStringNotEmpty(field, CFG_FIELD);
  }
View Full Code Here

  @SuppressWarnings("unchecked")
  @Override
  public void init(Map<String, Object> settings) throws SettingsException {
    if (settings == null) {
      throw new SettingsException("'settings' section is not defined for preprocessor " + name);
    }
    fieldsSource = ((List<String>) settings.get(CFG_SOURCE_FIELDS));
    validateConfigurationObjectNotEmpty(fieldsSource, CFG_SOURCE_FIELDS);
    fieldTarget = XContentMapValues.nodeStringValue(settings.get(CFG_TARGET_FIELD), null);
    validateConfigurationStringNotEmpty(fieldTarget, CFG_TARGET_FIELD);
View Full Code Here

  protected Map<String, Object> fields;

  @Override
  public void init(Map<String, Object> settings) throws SettingsException {
    if (settings == null) {
      throw new SettingsException("'settings' section is not defined for preprocessor " + name);
    }
    fields = settings;
  }
View Full Code Here

TOP

Related Classes of org.elasticsearch.common.settings.SettingsException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.