Package org.elasticsearch.common.settings

Examples of org.elasticsearch.common.settings.SettingsException


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

    jiraRestAPIUrlBase = prepareAPIURLFromBaseURL(jiraUrlBase, restApiVersion);
    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());
    }

    PoolingHttpClientConnectionManager connManager = new PoolingHttpClientConnectionManager();
    connManager.setDefaultMaxPerRoute(20);
    connManager.setMaxTotal(20);
View Full Code Here


      Map<String, Object> ret = parser.mapAndClose();
      if (logger.isDebugEnabled())
        logger.debug("jar packaged JSON file {} content is: {}", filePath, ret);
      return ret;
    } 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

    }
  }

  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

      String idFieldConfigPropertyName) {
    Object id = XContentMapValues.extractValue(idFieldName, document);
    if (id == null)
      return null;
    if (!isSimpleValue(id))
      throw new SettingsException("Remote data field '" + idFieldName + "' defined in 'index/"
          + idFieldConfigPropertyName + "' config param must provide simple value, but value is " + id);

    return id.toString();
  }
View Full Code Here

  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

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.