Class ValidateJson
java.lang.Object
org.apache.nifi.components.AbstractConfigurableComponent
org.apache.nifi.processor.AbstractSessionFactoryProcessor
org.apache.nifi.processor.AbstractProcessor
org.apache.nifi.processors.standard.ValidateJson
- All Implemented Interfaces:
org.apache.nifi.components.ConfigurableComponent,org.apache.nifi.processor.Processor
@SideEffectFree
@SupportsBatching
@InputRequirement(INPUT_REQUIRED)
@Tags({"JSON","schema","validation"})
@WritesAttributes(@WritesAttribute(attribute="json.validation.errors",description="If the flow file is routed to the invalid relationship , this attribute will contain the error message resulting from the validation failure."))
@CapabilityDescription("Validates the contents of FlowFiles against a configurable JSON Schema. See json-schema.org for specification standards. This Processor does not support input containing multiple JSON objects, such as newline-delimited JSON. If the input FlowFile contains newline-delimited JSON, only the first line will be validated.")
@SystemResourceConsideration(resource=MEMORY,
description="Validating JSON requires reading FlowFile content into memory")
@Restricted(restrictions=@Restriction(requiredPermission=REFERENCE_REMOTE_RESOURCES,explanation="Schema configuration can reference resources over HTTP"))
public class ValidateJson
extends org.apache.nifi.processor.AbstractProcessor
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Stringprotected static final Stringprivate JsonSchemaRegistryprivate com.fasterxml.jackson.databind.ObjectMapperstatic final org.apache.nifi.components.PropertyDescriptorprivate static final List<org.apache.nifi.components.PropertyDescriptor> static final org.apache.nifi.processor.Relationshipstatic final org.apache.nifi.processor.Relationshipstatic final org.apache.nifi.processor.Relationshipprivate static final Set<org.apache.nifi.processor.Relationship> private com.networknt.schema.JsonSchemastatic final org.apache.nifi.components.PropertyDescriptorstatic final org.apache.nifi.components.PropertyDescriptorprivate static final Stringstatic final org.apache.nifi.components.PropertyDescriptorprivate static final Stringstatic final org.apache.nifi.components.PropertyDescriptorstatic final org.apache.nifi.components.PropertyDescriptorprivate final ConcurrentMap<SchemaVersion, com.networknt.schema.JsonSchemaFactory> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected Collection<org.apache.nifi.components.ValidationResult> customValidate(org.apache.nifi.components.ValidationContext validationContext) private StringgetPropertyValidateMessage(ValidateJson.JsonSchemaStrategy schemaAccessStrategy, org.apache.nifi.components.PropertyDescriptor property) Set<org.apache.nifi.processor.Relationship> private ValidateJson.JsonSchemaStrategygetSchemaAccessStrategy(org.apache.nifi.context.PropertyContext context) final List<org.apache.nifi.components.PropertyDescriptor> voidvoidonScheduled(org.apache.nifi.processor.ProcessContext context) voidonTrigger(org.apache.nifi.processor.ProcessContext context, org.apache.nifi.processor.ProcessSession session) Methods inherited from class org.apache.nifi.processor.AbstractProcessor
onTriggerMethods inherited from class org.apache.nifi.processor.AbstractSessionFactoryProcessor
getControllerServiceLookup, getIdentifier, getLogger, getNodeTypeProvider, init, initialize, isConfigurationRestored, isScheduled, toString, updateConfiguredRestoredTrue, updateScheduledFalse, updateScheduledTrueMethods inherited from class org.apache.nifi.components.AbstractConfigurableComponent
equals, getPropertyDescriptor, getPropertyDescriptors, getSupportedDynamicPropertyDescriptor, hashCode, onPropertyModified, validateMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.nifi.components.ConfigurableComponent
getPropertyDescriptor, getPropertyDescriptors, onPropertyModified, validateMethods inherited from interface org.apache.nifi.processor.Processor
isStateful, migrateRelationships
-
Field Details
-
ERROR_ATTRIBUTE_KEY
- See Also:
-
SCHEMA_NAME_PROPERTY_NAME
- See Also:
-
SCHEMA_CONTENT_PROPERTY_NAME
- See Also:
-
DEFAULT_MAX_STRING_LENGTH
- See Also:
-
SCHEMA_ACCESS_STRATEGY
public static final org.apache.nifi.components.PropertyDescriptor SCHEMA_ACCESS_STRATEGY -
SCHEMA_NAME
public static final org.apache.nifi.components.PropertyDescriptor SCHEMA_NAME -
SCHEMA_REGISTRY
public static final org.apache.nifi.components.PropertyDescriptor SCHEMA_REGISTRY -
SCHEMA_CONTENT
public static final org.apache.nifi.components.PropertyDescriptor SCHEMA_CONTENT -
MAX_STRING_LENGTH
public static final org.apache.nifi.components.PropertyDescriptor MAX_STRING_LENGTH -
SCHEMA_VERSION
public static final org.apache.nifi.components.PropertyDescriptor SCHEMA_VERSION -
PROPERTY_DESCRIPTORS
-
REL_VALID
public static final org.apache.nifi.processor.Relationship REL_VALID -
REL_INVALID
public static final org.apache.nifi.processor.Relationship REL_INVALID -
REL_FAILURE
public static final org.apache.nifi.processor.Relationship REL_FAILURE -
RELATIONSHIPS
-
mapper
private com.fasterxml.jackson.databind.ObjectMapper mapper -
schemaFactories
-
schema
private volatile com.networknt.schema.JsonSchema schema -
jsonSchemaRegistry
-
-
Constructor Details
-
ValidateJson
public ValidateJson()
-
-
Method Details
-
migrateProperties
-
getRelationships
- Specified by:
getRelationshipsin interfaceorg.apache.nifi.processor.Processor- Overrides:
getRelationshipsin classorg.apache.nifi.processor.AbstractSessionFactoryProcessor
-
getSupportedPropertyDescriptors
- Overrides:
getSupportedPropertyDescriptorsin classorg.apache.nifi.components.AbstractConfigurableComponent
-
customValidate
protected Collection<org.apache.nifi.components.ValidationResult> customValidate(org.apache.nifi.components.ValidationContext validationContext) - Overrides:
customValidatein classorg.apache.nifi.components.AbstractConfigurableComponent
-
onScheduled
@OnScheduled public void onScheduled(org.apache.nifi.processor.ProcessContext context) throws IOException - Throws:
IOException
-
onTrigger
public void onTrigger(org.apache.nifi.processor.ProcessContext context, org.apache.nifi.processor.ProcessSession session) throws org.apache.nifi.processor.exception.ProcessException - Specified by:
onTriggerin classorg.apache.nifi.processor.AbstractProcessor- Throws:
org.apache.nifi.processor.exception.ProcessException
-
getPropertyValidateMessage
private String getPropertyValidateMessage(ValidateJson.JsonSchemaStrategy schemaAccessStrategy, org.apache.nifi.components.PropertyDescriptor property) -
getSchemaAccessStrategy
private ValidateJson.JsonSchemaStrategy getSchemaAccessStrategy(org.apache.nifi.context.PropertyContext context)
-