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,
XContentMapValues.nodeStringValue(jiraSettings.get("restApiVersion"), null));
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));
}