Package org.elasticsearch.common.settings

Examples of org.elasticsearch.common.settings.SettingsException


  public Date extractDocumentUpdated(Map<String, Object> document) {
    Object val = XContentMapValues.extractValue(remoteDataFieldForUpdated, document);
    if (val == null)
      return null;
    if (!isSimpleValue(val))
      throw new SettingsException("Remote data field '" + remoteDataFieldForUpdated
          + "' must provide simple value, but value is " + val);

    if (val instanceof Date)
      return (Date) val;

    try {
      // try simple timestamp
      return new Date(Long.parseLong(val.toString()));
    } catch (NumberFormatException e) {
      // try ISO format
      try {
        return DateTimeUtils.parseISODateTime(val.toString());
      } catch (IllegalArgumentException e1) {
        throw new SettingsException("Remote data field '" + remoteDataFieldForUpdated
            + "' is not reecognized as timestamp value (ISO format or number with millis from 1.1.1970): " + val);
      }
    }
  }
View Full Code Here


  }

  private void validateConfigurationFieldsStructure(Map<String, Map<String, String>> value, String configFieldName) {
    for (String idxFieldName : value.keySet()) {
      if (Utils.isEmpty(idxFieldName)) {
        throw new SettingsException("Empty key found in '" + configFieldName + "' map.");
      }
      Map<String, String> fc = value.get(idxFieldName);
      if (Utils.isEmpty(fc.get(CONFIG_FIELDS_REMOTEFIELD))) {
        throw new SettingsException("'remote_field' is not defined in '" + configFieldName + "/" + idxFieldName + "'");
      }
      String fil = fc.get(CONFIG_FIELDS_VALUEFILTER);
      if (fil != null && !filtersConfig.containsKey(fil)) {
        throw new SettingsException("Filter definition not found for filter name '" + fil + "' defined in '"
            + configFieldName + "/" + idxFieldName + "/value_filter'");
      }
    }
  }
View Full Code Here

    }
  }

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

    }
  }

  private void validateConfigurationObject(Object value, String configFieldName) throws SettingsException {
    if (value == null) {
      throw new SettingsException("Value must be provided for '" + configFieldName + "' configuration!");
    }
  }
View Full Code Here

          remoteSettings.get("remoteClientClass"), null));
      if (remoteClientClass != null) {
        try {
          remoteSystemClient = (IRemoteSystemClient) Class.forName(remoteClientClass).newInstance();
        } catch (Exception e) {
          throw new SettingsException("Unable to instantiate class defined by 'remote/remoteClientClass': "
              + e.getMessage());
        }
      } else {
        remoteSystemClient = new GetJSONClient();
      }
      remoteSystemClient.init(remoteSettings, allIndexedSpacesKeysNextRefresh != Long.MAX_VALUE, this);
    } else {
      throw new SettingsException("'remote' 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_DOCUMENT_TYPE_NAME_DEFAULT);
    } else {
      indexName = riverName.name();
      typeName = INDEX_DOCUMENT_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.addDataPreprocessor(StructuredContentPreprocessorFactory.createPreprocessor(ppc,
                client));
          } catch (IllegalArgumentException e) {
            throw new SettingsException(e.getMessage(), e);
          }
        }
      }
    }
  }
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);
    }
    sourceBases = (List<String>) settings.get(CFG_source_bases);
  }
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 {
    super.init(settings);
    if (client == null) {
      throw new SettingsException("ElasticSearch client is required 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 = StructureUtils.getListOfStringValues(settings, CFG_idx_search_field);
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

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.