use of uk.gov.gchq.gaffer.accumulostore.key.exception.ElementFilterException in project Gaffer by gchq.
the class AbstractElementFilter method validateOptions.
@Override
public boolean validateOptions(final Map<String, String> options) {
if (!super.validateOptions(options)) {
return false;
}
if (!options.containsKey(AccumuloStoreConstants.ACCUMULO_ELEMENT_CONVERTER_CLASS)) {
throw new IllegalArgumentException("Must specify the " + AccumuloStoreConstants.ACCUMULO_ELEMENT_CONVERTER_CLASS);
}
if (!options.containsKey(AccumuloStoreConstants.SCHEMA)) {
throw new IllegalArgumentException("Must specify the " + AccumuloStoreConstants.SCHEMA);
}
validator = getElementValidator(options);
final Schema schema;
try {
schema = Schema.fromJson(options.get(AccumuloStoreConstants.SCHEMA).getBytes(CommonConstants.UTF_8));
} catch (final UnsupportedEncodingException e) {
throw new SchemaException("Unable to deserialise the schema from JSON", e);
}
try {
final Class<?> elementConverterClass = Class.forName(options.get(AccumuloStoreConstants.ACCUMULO_ELEMENT_CONVERTER_CLASS));
elementConverter = (AccumuloElementConverter) elementConverterClass.getConstructor(Schema.class).newInstance(schema);
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) {
throw new ElementFilterException("Failed to load element converter from class name provided : " + options.get(AccumuloStoreConstants.ACCUMULO_ELEMENT_CONVERTER_CLASS), e);
}
return true;
}
Aggregations