Package org.elasticsearch.common.settings

Examples of org.elasticsearch.common.settings.SettingsException


        fields = new ArrayList<String>();
        fields.add(s);
      }
    }
    if (fields == null || fields.isEmpty()) {
      throw new SettingsException("Missing, empty or bad 'settings/" + CFG_FIELDS + "' configuration value for '"
          + name + "' preprocessor");
    }
  }
View Full Code Here


    String pattern = XContentMapValues.nodeStringValue(settings.get(CFG_PATTERN), null);
    validateConfigurationStringNotEmpty(pattern, CFG_PATTERN);
    try {
      patternCompiled = Pattern.compile(pattern);
    } catch (PatternSyntaxException e) {
      throw new SettingsException("'settings/" + CFG_PATTERN + "' configuration value for '" + name
          + "' preprocessor is invalid: " + e.getMessage());
    }
    try {
      resultMapping = (Map<Object, String>) settings.get(CFG_RESULT_MAPPING);
      validateResultMappingConfiguration(resultMapping, CFG_RESULT_MAPPING);
    } catch (ClassCastException e) {
      throw new SettingsException("'settings/" + CFG_RESULT_MAPPING + "' configuration value for '" + name
          + "' preprocessor is invalid");
    }
  }
View Full Code Here

   * @throws SettingsException thrown if value is not valid
   */
  protected void validateResultMappingConfiguration(Map<Object, String> value, String configFieldName)
      throws SettingsException {
    if (value == null || value.isEmpty()) {
      throw new SettingsException("Missing or empty 'settings/" + configFieldName + "' configuration object for '"
          + name + "' preprocessor");
    }
    for (Object index : value.keySet()) {
      if (ValueUtils.isEmpty(index)) {
        throw new SettingsException("Missing or empty index in 'settings/" + configFieldName + "' configuration for '"
            + name + "' preprocessor");
      }
      boolean isnumber = false;
      if (index instanceof Number) {
        isnumber = true;
      } else if (index instanceof String) {
        try {
          new Integer((String) index);
          isnumber = true;
        } catch (NumberFormatException e) {

        }
      }
      if (!isnumber) {
        throw new SettingsException("Index must be a number in 'settings/" + configFieldName + "' configuration for '"
            + name + "' preprocessor");
      }

      try {
        if (ValueUtils.isEmpty((String) value.get(index))) {
          throw new SettingsException("Missing or empty value in 'settings/" + configFieldName + "/" + index
              + "' configuration for '" + name + "' preprocessor");
        }
      } catch (ClassCastException e) {
        throw new SettingsException("Value for 'settings/" + configFieldName + "/" + index + "' configuration for '"
            + name + "' preprocessor must be String");
      }
    }
  }
View Full Code Here

  @SuppressWarnings("unchecked")
  public SourceClientESTransportClient(Map<String, Object> sourceClientSettings) throws SettingsException {
    super(null);
    List<Map<String, Object>> adr = (List<Map<String, Object>>) sourceClientSettings.get("addresses");
    if (adr == null || adr.isEmpty()) {
      throw new SettingsException("es_connection/addresses element of configuration structure not found or is empty");
    }
    transportAddresses = new TransportAddress[adr.size()];
    int i = 0;
    for (Map<String, Object> a : adr) {
      if (Utils.isEmpty(a.get("host"))) {
        throw new SettingsException(
            "es_connection/addresses/host element of configuration structure not found or is empty");
      }
      if (Utils.isEmpty(a.get("port"))) {
        throw new SettingsException(
            "es_connection/addresses/port element of configuration structure not found or is empty");
      }
      transportAddresses[i++] = new InetSocketTransportAddress((String) a.get("host"), Utils.nodeIntegerValue(a
          .get("port")));
    }
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

   */
  public JIRA5RestClient(String jiraUrlBase, String jiraUsername, String jiraPassword, Integer timeout) {

    jiraRestAPIUrlBase = prepareAPIURLFromBaseURL(jiraUrlBase);
    if (jiraRestAPIUrlBase == null) {
      throw new SettingsException("Parameter jira/urlBase must be set!");
    }

    URL url = null;
    try {
      url = new URL(jiraRestAPIUrlBase);
    } catch (MalformedURLException e) {
      throw new SettingsException("Parameter jira/urlBase is malformed " + e.getMessage());
    }

    PoolingClientConnectionManager connectionManager = new PoolingClientConnectionManager();
    connectionManager.setDefaultMaxPerRoute(20);
    connectionManager.setMaxTotal(20);
View Full Code Here

   */
  public JIRA5RestClient(String jiraUrlBase, String jiraUsername, String jiraPassword, Integer timeout) {

    jiraRestAPIUrlBase = prepareAPIURLFromBaseURL(jiraUrlBase);
    if (jiraRestAPIUrlBase == null) {
      throw new SettingsException("Parameter jira/urlBase must be set!");
    }

    URL url = null;
    try {
      url = new URL(jiraRestAPIUrlBase);
    } catch (MalformedURLException e) {
      throw new SettingsException("Parameter jira/urlBase is malformed " + e.getMessage());
    }

    PoolingClientConnectionManager connectionManager = new PoolingClientConnectionManager();
    connectionManager.setDefaultMaxPerRoute(20);
    connectionManager.setMaxTotal(20);
View Full Code Here

    XContentParser parser = null;
    try {
      parser = XContentFactory.xContent(XContentType.JSON).createParser(Utils.class.getResourceAsStream(filePath));
      return parser.mapAndClose();
    } catch (IOException e) {
      throw new SettingsException(e.getMessage(), e);
    } finally {
      if (parser != null)
        parser.close();
    }
  }
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_JIRAFIELD))) {
        throw new SettingsException("'jira_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

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.