mirror of https://github.com/apache/nifi.git
NIFI-1859 Using .equals instead of == for default locale check. Adding some additional information for the input and output schema properties.
This closes #418. Signed-off-by: Aldrin Piri <aldrin@apache.org>
This commit is contained in:
parent
63a0d0c211
commit
993d3cd78f
|
@ -135,12 +135,12 @@ public class ConvertAvroSchema extends AbstractKiteProcessor {
|
||||||
@Override
|
@Override
|
||||||
public ValidationResult validate(final String subject, final String value, final ValidationContext context) {
|
public ValidationResult validate(final String subject, final String value, final ValidationContext context) {
|
||||||
String reason = null;
|
String reason = null;
|
||||||
if (value.equals(DEFAULT_LOCALE_VALUE) == false) {
|
if (!value.equals(DEFAULT_LOCALE_VALUE)) {
|
||||||
try {
|
try {
|
||||||
final Locale locale = LocaleUtils.toLocale(value);
|
final Locale locale = LocaleUtils.toLocale(value);
|
||||||
if (locale == null) {
|
if (locale == null) {
|
||||||
reason = "null locale returned";
|
reason = "null locale returned";
|
||||||
} else if (LocaleUtils.isAvailableLocale(locale) == false) {
|
} else if (!LocaleUtils.isAvailableLocale(locale)) {
|
||||||
reason = "locale not available";
|
reason = "locale not available";
|
||||||
}
|
}
|
||||||
} catch (final IllegalArgumentException e) {
|
} catch (final IllegalArgumentException e) {
|
||||||
|
@ -153,15 +153,19 @@ public class ConvertAvroSchema extends AbstractKiteProcessor {
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
static final PropertyDescriptor INPUT_SCHEMA = new PropertyDescriptor.Builder()
|
static final PropertyDescriptor INPUT_SCHEMA = new PropertyDescriptor.Builder()
|
||||||
.name("Input Schema").description("Avro Schema of Input Flowfiles")
|
.name("Input Schema")
|
||||||
.addValidator(SCHEMA_VALIDATOR).expressionLanguageSupported(true)
|
.description("Avro Schema of Input Flowfiles. This can be a URI (dataset, view, or resource) or literal JSON schema.")
|
||||||
.required(true).build();
|
.addValidator(SCHEMA_VALIDATOR)
|
||||||
|
.expressionLanguageSupported(true)
|
||||||
|
.required(true)
|
||||||
|
.build();
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
static final PropertyDescriptor OUTPUT_SCHEMA = new PropertyDescriptor.Builder()
|
static final PropertyDescriptor OUTPUT_SCHEMA = new PropertyDescriptor.Builder()
|
||||||
.name("Output Schema")
|
.name("Output Schema")
|
||||||
.description("Avro Schema of Output Flowfiles")
|
.description("Avro Schema of Output Flowfiles. This can be a URI (dataset, view, or resource) or literal JSON schema.")
|
||||||
.addValidator(MAPPED_SCHEMA_VALIDATOR).expressionLanguageSupported(true)
|
.addValidator(MAPPED_SCHEMA_VALIDATOR)
|
||||||
|
.expressionLanguageSupported(true)
|
||||||
.required(true).build();
|
.required(true).build();
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
|
@ -274,7 +278,7 @@ public class ConvertAvroSchema extends AbstractKiteProcessor {
|
||||||
}
|
}
|
||||||
// Set locale
|
// Set locale
|
||||||
final String localeProperty = context.getProperty(LOCALE).getValue();
|
final String localeProperty = context.getProperty(LOCALE).getValue();
|
||||||
final Locale locale = (localeProperty == DEFAULT_LOCALE_VALUE)?Locale.getDefault():LocaleUtils.toLocale(localeProperty);
|
final Locale locale = localeProperty.equals(DEFAULT_LOCALE_VALUE) ? Locale.getDefault() : LocaleUtils.toLocale(localeProperty);
|
||||||
final AvroRecordConverter converter = new AvroRecordConverter(
|
final AvroRecordConverter converter = new AvroRecordConverter(
|
||||||
inputSchema, outputSchema, fieldMapping, locale);
|
inputSchema, outputSchema, fieldMapping, locale);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue