use of org.elasticsearch.ElasticsearchParseException in project elasticsearch by elastic.
the class AttachmentProcessorTests method testEncryptedPdf.
public void testEncryptedPdf() throws Exception {
ElasticsearchParseException e = expectThrows(ElasticsearchParseException.class, () -> parseDocument("encrypted.pdf", processor));
assertThat(e.getDetailedMessage(), containsString("document is encrypted"));
}
use of org.elasticsearch.ElasticsearchParseException in project elasticsearch by elastic.
the class GeoIpProcessor method execute.
@Override
public void execute(IngestDocument ingestDocument) {
String ip = ingestDocument.getFieldValue(field, String.class, ignoreMissing);
if (ip == null && ignoreMissing) {
return;
} else if (ip == null) {
throw new IllegalArgumentException("field [" + field + "] is null, cannot extract geoip information.");
}
final InetAddress ipAddress = InetAddresses.forString(ip);
Map<String, Object> geoData;
switch(dbReader.getMetadata().getDatabaseType()) {
case CITY_DB_TYPE:
try {
geoData = retrieveCityGeoData(ipAddress);
} catch (AddressNotFoundRuntimeException e) {
geoData = Collections.emptyMap();
}
break;
case COUNTRY_DB_TYPE:
try {
geoData = retrieveCountryGeoData(ipAddress);
} catch (AddressNotFoundRuntimeException e) {
geoData = Collections.emptyMap();
}
break;
default:
throw new ElasticsearchParseException("Unsupported database type [" + dbReader.getMetadata().getDatabaseType() + "]", new IllegalStateException());
}
if (geoData.isEmpty() == false) {
ingestDocument.setFieldValue(targetField, geoData);
}
}
use of org.elasticsearch.ElasticsearchParseException in project elasticsearch by elastic.
the class UserAgentProcessorFactoryTests method testInvalidPropertiesType.
public void testInvalidPropertiesType() throws Exception {
UserAgentProcessor.Factory factory = new UserAgentProcessor.Factory(userAgentParsers);
Map<String, Object> config = new HashMap<>();
config.put("field", "_field");
config.put("properties", "invalid");
ElasticsearchParseException e = expectThrows(ElasticsearchParseException.class, () -> factory.create(null, null, config));
assertThat(e.getMessage(), equalTo("[properties] property isn't a list, but of type [java.lang.String]"));
}
use of org.elasticsearch.ElasticsearchParseException in project elasticsearch by elastic.
the class UserAgentProcessorFactoryTests method testInvalidProperty.
public void testInvalidProperty() throws Exception {
UserAgentProcessor.Factory factory = new UserAgentProcessor.Factory(userAgentParsers);
Map<String, Object> config = new HashMap<>();
config.put("field", "_field");
config.put("properties", Collections.singletonList("invalid"));
ElasticsearchParseException e = expectThrows(ElasticsearchParseException.class, () -> factory.create(null, null, config));
assertThat(e.getMessage(), equalTo("[properties] illegal property value [invalid]. valid values are [NAME, MAJOR, MINOR, " + "PATCH, OS, OS_NAME, OS_MAJOR, OS_MINOR, DEVICE, BUILD]"));
}
use of org.elasticsearch.ElasticsearchParseException in project elasticsearch by elastic.
the class UserAgentProcessorFactoryTests method testBuildNonExistingRegexFile.
public void testBuildNonExistingRegexFile() throws Exception {
UserAgentProcessor.Factory factory = new UserAgentProcessor.Factory(userAgentParsers);
Map<String, Object> config = new HashMap<>();
config.put("field", "_field");
config.put("regex_file", "does-not-exist.yaml");
ElasticsearchParseException e = expectThrows(ElasticsearchParseException.class, () -> factory.create(null, null, config));
assertThat(e.getMessage(), equalTo("[regex_file] regex file [does-not-exist.yaml] doesn't exist (has to exist at node startup)"));
}
Aggregations