@Mutable @ThreadSafety(level=NOT_THREADSAFE) public final class SchemaValidator extends java.lang.Object
Constructor and Description |
---|
SchemaValidator()
Creates a new schema validator with the default settings.
|
Modifier and Type | Method and Description |
---|---|
boolean |
allowAttributeTypesWithoutEqualityMatchingRule()
Indicates whether to allow attribute type definitions to be missing an
equality matching definition, by neither directly specifying the matching
rule name or OID nor referencing a superior attribute type from which the
matching rule will be inherited.
|
boolean |
allowAttributeTypesWithoutSyntax()
Indicates whether to allow attribute type definitions to be missing an
attribute syntax definition, by neither directly specifying the attribute
syntax OID nor referencing a superior attribute type from which the syntax
will be inherited.
|
boolean |
allowCollectiveAttributes()
Indicates whether to allow collective attribute type definitions.
|
boolean |
allowElementsWithoutNames()
Indicates whether to allow schema elements that do not contain names but
may only be identified by an OID (or by the rule ID in the case of DIT
structure rules).
|
boolean |
allowEmptyDescription()
Indicates whether to allow schema elements to have empty descriptions.
|
boolean |
allowInvalidObjectClassInheritance()
Indicates whether to allow object classes with an invalid inheritance
relationship.
|
boolean |
allowMultipleEntriesPerFile()
Indicates whether a schema file is allowed to contain multiple entries.
|
boolean |
allowMultipleSuperiorObjectClasses()
Indicates whether to allow object classes with multiple superior classes.
|
boolean |
allowNamesWithInitialDigit()
Indicates whether to allow schema element names that start with a digit.
|
boolean |
allowNamesWithInitialHyphen()
Indicates whether to allow schema element names that start with a hyphen.
|
boolean |
allowNamesWithUnderscore()
Indicates whether to allow schema element names that contain the underscore
character.
|
boolean |
allowNonNumericOIDsNotUsingName()
Indicates whether schema elements will be permitted to include non-numeric
object identifiers that are of a form other than one of the element names
followed by "-oid".
|
boolean |
allowNonNumericOIDsUsingName()
Indicates whether schema elements will be permitted to include non-numeric
object identifiers that are comprised of the name for that element with
"-oid" appended to it.
|
boolean |
allowObsoleteElements()
Indicates whether to allow schema elements declared with the OBSOLETE
modifier.
|
boolean |
allowRedefiningElements()
Indicates whether the same schema element may be defined multiple times.
|
boolean |
allowSchemaFilesInSubDirectories()
Indicates whether to examine files in subdirectories when provided with a
schema path that is a directory.
|
boolean |
allowStructuralObjectClassWithoutSuperior()
Indicates whether to allow structural object classes that do not declare a
superior class.
|
void |
configureLDAPSDKDefaultAttributeSyntaxes()
Configures the schema validator to use a default set of attribute syntaxes
that are known to the LDAP SDK.
|
void |
configureLDAPSDKDefaultMatchingRules()
Configures the schema validator to use a default set of matching rules that
that are known to the LDAP SDK.
|
boolean |
ensureSchemaEntryIsValid()
Indicates whether to validate each entry containing the schema definitions
using the schema that has been parsed thus far.
|
java.util.Set<SchemaElementType> |
getAllowedSchemaElementTypes()
Retrieves an unmodifiable set of the schema element types that may be
defined in schema files.
|
java.util.Set<SchemaElementType> |
getAllowReferencesToUndefinedElementTypes()
Retrieves the types of schema elements that can be referenced by other
elements without the referenced types being known to the schema validator
(e.g., by having been previously defined in the schema files).
|
java.util.List<AttributeSyntaxDefinition> |
getAttributeSyntaxes()
Retrieves a list of the attribute syntaxes that will be used in the course
of validating attribute type definitions.
|
java.util.List<MatchingRuleDefinition> |
getMatchingRuleDefinitions()
Retrieves a list of the matching rules that will be used in the course of
of validating attribute type definitions.
|
java.util.regex.Pattern |
getSchemaFileNamePattern()
Retrieves the pattern that schema file names are expected to match.
|
boolean |
ignoreSchemaFilesNotMatchingFileNamePattern()
Indicates whether to ignore any files in a schema directory that do not
match the value pattern (if one is defined).
|
void |
setAllowAttributeTypesWithoutEqualityMatchingRule(boolean allowAttributeTypesWithoutEqualityMatchingRule)
Indicates whether to allow attribute type definitions to be missing an
equality matching definition, by neither directly specifying the matching
rule name or OID nor referencing a superior attribute type from which the
matching rule will be inherited.
|
void |
setAllowAttributeTypesWithoutSyntax(boolean allowAttributeTypesWithoutSyntax)
Specifies whether to allow attribute type definitions to be missing an
attribute syntax definition, by neither directly specifying the attribute
syntax OID nor referencing a superior attribute type from which the syntax
will be inherited.
|
void |
setAllowCollectiveAttributes(boolean allowCollectiveAttributes)
Specifies whether to allow collective attribute type definitions.
|
void |
setAllowedSchemaElementTypes(java.util.Collection<SchemaElementType> allowedSchemaElementTypes)
Specifies the set of schema element types that may be defined in schema
files.
|
void |
setAllowedSchemaElementTypes(SchemaElementType... allowedSchemaElementTypes)
Specifies the set of schema element types that may be defined in schema
files.
|
void |
setAllowElementsWithoutNames(boolean allowElementsWithoutNames)
Specifies whether to allow schema elements that do not contain names but
may only be identified by an OID (or by the rule ID in the case of DIT
structure rules).
|
void |
setAllowEmptyDescription(boolean allowEmptyDescription)
Specifies whether to allow schema elements to have empty descriptions.
|
void |
setAllowInvalidObjectClassInheritance(boolean allowInvalidObjectClassInheritance)
Specifies whether to allow object classes with an invalid inheritance
relationship.
|
void |
setAllowMultipleEntriesPerFile(boolean allowMultipleEntriesPerFile)
Specifies whether a schema file is allowed to contain multiple entries.
|
void |
setAllowMultipleSuperiorObjectClasses(boolean allowMultipleSuperiorObjectClasses)
Specifies whether to allow object classes with multiple superior classes.
|
void |
setAllowNamesWithInitialDigit(boolean allowNamesWithInitialDigit)
Specifies whether to allow schema element names that start with a digit.
|
void |
setAllowNamesWithInitialHyphen(boolean allowNamesWithInitialHyphen)
Specifies whether to allow schema element names that start with a hyphen.
|
void |
setAllowNamesWithUnderscore(boolean allowNamesWithUnderscore)
Indicates whether to allow schema element names that contain the underscore
character.
|
void |
setAllowObsoleteElements(boolean allowObsoleteElements)
Specifies whether to allow schema elements declared with the OBSOLETE
modifier.
|
void |
setAllowRedefiningElements(boolean allowRedefiningElements)
Specifies whether the same schema element may be defined multiple times.
|
void |
setAllowReferencesToUndefinedElementTypes(java.util.Collection<SchemaElementType> undefinedElementTypes)
Specifies the types of schema elements that can be referenced by other
elements without the referenced types being known to the schema validator
(e.g., by having been previously defined in the schema files).
|
void |
setAllowReferencesToUndefinedElementTypes(SchemaElementType... undefinedElementTypes)
Specifies the types of schema elements that can be referenced by other
elements without the referenced types being known to the schema validator
(e.g., by having been previously defined in the schema files).
|
void |
setAllowSchemaFilesInSubDirectories(boolean allowSchemaFilesInSubDirectories)
Specifies whether to examine files in subdirectories when provided with a
schema path that is a directory.
|
void |
setAllowStructuralObjectClassWithoutSuperior(boolean allowStructuralObjectClassWithoutSuperior)
Specifies whether to allow structural object classes that do not declare a
superior class.
|
void |
setAttributeSyntaxes(java.util.Collection<AttributeSyntaxDefinition> attributeSyntaxes)
Specifies a set of attribute syntaxes that will be used in the course
of validating attribute type definitions.
|
void |
setEnsureSchemaEntryIsValid(boolean ensureSchemaEntryIsValid)
Specifies whether to validate each entry containing the schema definitions
using the schema that has been parsed thus far.
|
void |
setMatchingRules(java.util.Collection<MatchingRuleDefinition> matchingRules)
Specifies a set of matching rules that will be used in the course of
validating attribute type definitions.
|
void |
setOIDValidation(boolean allowNonNumericOIDsUsingName,
boolean allowNonNumericOIDsNotUsingName,
boolean useStrictOIDValidation)
Specifies the behavior to use when validating object identifiers.
|
void |
setSchemaFileNamePattern(java.util.regex.Pattern schemaFileNamePattern,
boolean ignoreSchemaFilesNotMatchingFileNamePattern)
Specifies a pattern that may be used to indicate which files should be
examined if a provided path is a directory rather than a file.
|
boolean |
useStrictOIDValidation()
Indicates whether to use strict validation for numeric object identifiers.
|
Schema |
validateSchema(java.io.File schemaPath,
Schema existingSchema,
java.util.List<java.lang.String> errorMessages)
Validates the schema definitions in the file or set of files at the given
path.
|
public SchemaValidator()
@Nullable public java.util.regex.Pattern getSchemaFileNamePattern()
null
if no schema file name pattern is defined.public boolean ignoreSchemaFilesNotMatchingFileNamePattern()
true
if files not matching the defined value pattern
should be ignored, or false
if they should not be ignored
but a warning should be generated.public void setSchemaFileNamePattern(@Nullable java.util.regex.Pattern schemaFileNamePattern, boolean ignoreSchemaFilesNotMatchingFileNamePattern)
schemaFileNamePattern
- A regular expression that may be used to specify the pattern
that schema file names are expected to match. This may be
null
if no pattern is defined and any identified files
will be processed.ignoreSchemaFilesNotMatchingFileNamePattern
- Specifies whether to ignore any files in a schema directory
that do not match the value pattern (if one is defined). This
will only have an effect when attempting to parse schema
definitions from a path that references a directory rather
than a file. If this is true
then any files that do
not match the pattern (if it is non-null
will be
skipped. If this is false
, then all files will be
parsed even if they do not match the value pattern, but a
warning will be added to the message list for each file that
does not match the pattern. If the path provided to the
validateSchema(java.io.File, com.unboundid.ldap.sdk.schema.Schema, java.util.List<java.lang.String>)
method refers to a file rather than a
directory, then the file will always be processed, but a
warning message will be added to the given list if the name
does not match the given pattern.public boolean allowMultipleEntriesPerFile()
true
if a schema file may have multiple entries and all
entries contained in that file should be processed, or
false
if a schema file should only have a single entry
and additional entries will be ignored and an error message
reported.public void setAllowMultipleEntriesPerFile(boolean allowMultipleEntriesPerFile)
allowMultipleEntriesPerFile
- Indicates whether a schema file is allowed to contain multiple
entries. If this is true
, then all entries in each
file will be examined. If this is false
, then only
the first entry in each file will be examined and an error
message will be reported for each file that contains multiple
entries. In either case, an error will be reported for each
schema file that does not contain any entries or that contains
a malformed entry.public boolean allowSchemaFilesInSubDirectories()
true
to examine files in subdirectories when provided with
a schema path that is a directory, or false
if only
files directly contained in the provided directory will be
examined and an error will be reported if the schema directory
contains subdirectories.public void setAllowSchemaFilesInSubDirectories(boolean allowSchemaFilesInSubDirectories)
validateSchema(java.io.File, com.unboundid.ldap.sdk.schema.Schema, java.util.List<java.lang.String>)
method is called with a schema path that is a file
rather than a directory.allowSchemaFilesInSubDirectories
- Indicates whether to examine files in subdirectories when
provided with a schema path that is a directory. If this is
true
, then files in subdirectories will be examined,
to any depth, with files in the directory processed first
(in lexicographic order by name) and then subdirectories will
be processed (also in lexicographic order by name). if this
is false
, then only files contained directly in the
specified schema directory will be examined and an error
will be reported for each subdirectory that is encountered.public boolean ensureSchemaEntryIsValid()
true
if entries containing schema definitions should be
validated according to the schema, or false
if schema
entries will not themselves be validated against the schema.public void setEnsureSchemaEntryIsValid(boolean ensureSchemaEntryIsValid)
ensureSchemaEntryIsValid
- Indicates whether to validate each entry containing the schema
definitions using the schema that has been parsed thus far.
If this is true
, then each entry will be validated
to ensure that it conforms to the schema definitions read from
that file and any previuos files that have already been
processed and any errors identified will be reported If this
is false
, then schema entries will not be validated.@NotNull public java.util.Set<SchemaElementType> getAllowedSchemaElementTypes()
public void setAllowedSchemaElementTypes(@NotNull SchemaElementType... allowedSchemaElementTypes)
allowedSchemaElementTypes
- The set of schema element types that may be defined in schema
files. It must not be null
or empty.public void setAllowedSchemaElementTypes(@NotNull java.util.Collection<SchemaElementType> allowedSchemaElementTypes)
allowedSchemaElementTypes
- The set of schema element types that may be defined in schema
files. It must not be null
or empty.@NotNull public java.util.Set<SchemaElementType> getAllowReferencesToUndefinedElementTypes()
public void setAllowReferencesToUndefinedElementTypes(@Nullable SchemaElementType... undefinedElementTypes)
undefinedElementTypes
- The types of schema elements that can be referenced by other
elements without the referenced types being known to the
schema validator. It may be null
or empty if no
undefined schema elements will be permitted.public void setAllowReferencesToUndefinedElementTypes(@Nullable java.util.Collection<SchemaElementType> undefinedElementTypes)
undefinedElementTypes
- The types of schema elements that can be referenced by other
elements without the referenced types being known to the
schema validator. It may be null
or empty if no
undefined schema elements will be permitted.public boolean allowRedefiningElements()
true
if the same schema element may be defined multiple
times, in which case subsequent definitions will override previous
definitions, or false
if an error will be reported if the
same element is encountered multiple times.public void setAllowRedefiningElements(boolean allowRedefiningElements)
allowRedefiningElements
- Indicates whether the same schema element may be defined
multiple times. If this is true
, then a schema
element may be defined multiple times, with the most recent
definition ultimately being used, as long as the redefined
definition keeps the same OID and names of the former
definition (although the redefined element may add additional
names), but other details may be changed. If this is
false
, then any attempt to define the same element
multiple times will be reported as an error.public boolean allowElementsWithoutNames()
true
if the schema validator will elements without names,
or false
if an error will be reported for each schema
element (other than attribute syntaxes) without a name.public void setAllowElementsWithoutNames(boolean allowElementsWithoutNames)
allowElementsWithoutNames
- Indicates whether to allow schema elements that do not contain
names. If this is true
, then elements without names
will be allowed. If this is false
, then an error will
be reported for each element (other than attribute syntaxes)
that does not have a name.public boolean allowNonNumericOIDsUsingName()
true
if non-numeric OIDs will be allowed if they are
comprised of the schema element name followed by "-oid", or
false
if not.public boolean allowNonNumericOIDsNotUsingName()
true
if non-numeric OIDs will be allowed if they are not
comprised of the schema element name followed by "-oid", or
false
if not.public boolean useStrictOIDValidation()
true
if strict validation will be performed for numeric
OIDs, or false
if more relaxed validation will be used
that only requires them to be comprised of a non-empty string
comprised only of digits and periods that does not start or end
with a period and does not contain consecutive periods.public void setOIDValidation(boolean allowNonNumericOIDsUsingName, boolean allowNonNumericOIDsNotUsingName, boolean useStrictOIDValidation)
allowNonNumericOIDsUsingName
- Indicates whether to allow non-numeric OIDs if they are
comprised of the name for the schema element followed by
"-oid". If this is true
, then non-numeric OIDs will
be allowed if they use that form. If this is false
,
then an error will be reported for schema elements with a
non-numeric OID in that form.allowNonNumericOIDsNotUsingName
- Indicates whether to allow non-numeric OIDs if they are not
comprised of the name for the schema element followed by
"-oid". If this is true
, then non-numeric OIDs will
be allowed if they use that form. If this is false
,
then an error will be reported for schema elements with a
non-numeric OID that does not use the element name.useStrictOIDValidation
- Indicates whether to use strict validation for numeric
object identifiers. If this is false
, then numeric
OIDs will be required to be comprised entirely of digits and
periods, must not start or end with a period, and must not
contain consecutive periods. If this is true
, then
numeric OIDs must also consist of at least two components,
the first component must be zero, one or two, and the second
component may only be greater than 39 if the first component
is two.public boolean allowNamesWithInitialDigit()
true
if schema element names will be permitted to start
with digits, or false
if an error will be reported for
names that start with a digit.public void setAllowNamesWithInitialDigit(boolean allowNamesWithInitialDigit)
allowNamesWithInitialDigit
- Indicates whether to allow schema element names that start
with a digit. If this is true
, then names will be
permitted to start with a digit. If this is false
,
then an error will be reported for each name that starts with
a digit.public boolean allowNamesWithInitialHyphen()
true
if schema element names will be permitted to start
with hyphens, or false
if an error will be reported for
names that start with a hyphen.public void setAllowNamesWithInitialHyphen(boolean allowNamesWithInitialHyphen)
allowNamesWithInitialHyphen
- Indicates whether to allow schema element names that start
with a hyphen. If this is true
, then names will be
permitted to start with a hyphen. If this is false
,
then an error will be reported for each name that starts with
a hyphen.public boolean allowNamesWithUnderscore()
true
if schema element names will be permitted to contain
underscores, or false
if an error will be reported for
names that contain an underscore.public void setAllowNamesWithUnderscore(boolean allowNamesWithUnderscore)
allowNamesWithUnderscore
- Indicates whether to allow schema element names that contain
the underscore character. If this is true
, then names
will be permitted to contain underscores. If this is
false
, then an error will be reported for each name
that contains an underscore.public boolean allowEmptyDescription()
true
if empty descriptions will be allowed, or
false
if errors will be reported for schema elements with
empty descriptions.public void setAllowEmptyDescription(boolean allowEmptyDescription)
allowEmptyDescription
- Indicates whether to allow schema elements to have empty
descriptions. If this is true
, then schema elements
will be permitted to have empty descriptions. If it is
false
, then an error will be reported for each
schema element with an empty description.@NotNull public java.util.List<AttributeSyntaxDefinition> getAttributeSyntaxes()
configureLDAPSDKDefaultAttributeSyntaxes()
method),
in addition to any attribute type definitions contained in schema entries.public void setAttributeSyntaxes(@Nullable java.util.Collection<AttributeSyntaxDefinition> attributeSyntaxes)
attributeSyntaxes
- The set of attribute syntaxes that will be used in the course
of validating attribute type definitions. It may be
null
or empty if only syntaxes defined in the schema
files will be used.public void configureLDAPSDKDefaultAttributeSyntaxes()
public boolean allowAttributeTypesWithoutSyntax()
true
if attribute type definitions will be permitted to
omit both an attribute syntax and a superior type, or
false
if an error will be reported for each such attribute
type.public void setAllowAttributeTypesWithoutSyntax(boolean allowAttributeTypesWithoutSyntax)
allowAttributeTypesWithoutSyntax
- Indicates whether to allow attribute type definitions to be
missing an attribute syntax definition, by neither directly
specifying the attribute syntax OID nor referencing a superior
attribute type from which the syntax will be inherited. If
this is true
, then attribute types that do not specify
either a syntax OID or a superior type will be permitted. If
this is false
, then an error will be reported for
each such attribute type.@NotNull public java.util.List<MatchingRuleDefinition> getMatchingRuleDefinitions()
configureLDAPSDKDefaultMatchingRules()
method), in addition
to any matching rule definitions contained in schema entries.public void setMatchingRules(@Nullable java.util.Collection<MatchingRuleDefinition> matchingRules)
matchingRules
- The set of attribute syntaxes that will be used in the course
of validating attribute type definitions. It may be
null
or empty if only syntaxes defined in the schema
files will be used.public void configureLDAPSDKDefaultMatchingRules()
public boolean allowAttributeTypesWithoutEqualityMatchingRule()
true
if attribute type definitions will be permitted to
omit both an attribute syntax and a superior type, or
false
if an error will be reported for each such attribute
type.public void setAllowAttributeTypesWithoutEqualityMatchingRule(boolean allowAttributeTypesWithoutEqualityMatchingRule)
allowAttributeTypesWithoutEqualityMatchingRule
- Specifies whether to allow attribute type definitions to be
missing an equality matching definition, by neither directly
specifying the matching rule name or OID nor referencing a
superior attribute type from which the matching rule will be
inherited. If this is true
, then attribute types that
do not specify either an equality matching rule or a superior
type will be permitted. If this is false
, then an
error will be reported for each such attribute type.public boolean allowMultipleSuperiorObjectClasses()
true
if object classes will be allowed to have multiple
superior classes, or false
if an error will be reported
for each object class with multiple superiors.public void setAllowMultipleSuperiorObjectClasses(boolean allowMultipleSuperiorObjectClasses)
allowMultipleSuperiorObjectClasses
- Indicates whether to allow object classes with multiple
superior classes. If this is true
, then object
classes with multiple superiors will be allowed. If this is
false
, then an error will be reported for each
object class with more than one superior class.public boolean allowStructuralObjectClassWithoutSuperior()
true
if object classes that do not declare their superiors
will be permitted, ro false
if an error will be reported
for each structural class that does not declare any superiors.public void setAllowStructuralObjectClassWithoutSuperior(boolean allowStructuralObjectClassWithoutSuperior)
allowStructuralObjectClassWithoutSuperior
- Indicates whether to allow structural object classes that do
not declare a superior class. If this is true
, then
structural object classes that do not declare any superior
class will be assumed to subclass "top". if this is
false
, then an error will be reported for each
structural object class that does not define any superior
class.public boolean allowInvalidObjectClassInheritance()
true
if the schema validator will allow object classes
with invalid inheritance relationships, or false
if an
error will be reported for each object class with an invalid
superior class.public void setAllowInvalidObjectClassInheritance(boolean allowInvalidObjectClassInheritance)
allowInvalidObjectClassInheritance
- Indicates whether to allow object classes with an invalid
inheritance relationship. If this is true
, then
invalid inheritance relationships will be allowed. If this is
false
, then an error will be reported for each
object class with an invalid superior class reference.public boolean allowCollectiveAttributes()
true
if collective attributes will be allowed, or
false
if the schema validator will report an error for
each collective attribute type definition.public void setAllowCollectiveAttributes(boolean allowCollectiveAttributes)
allowCollectiveAttributes
- Indicates whether to allow collective attribute type
definitions. If this is true
, then collective
attribute type definitions will be allowed. If this is
false
, then an error will be reported for each
collective attribute type definition.public boolean allowObsoleteElements()
true
if schema elements declared with the OBSOLETE
modifier will be allowed, or false
if an error will be
reported for each schema element declared as OBSOLETE.public void setAllowObsoleteElements(boolean allowObsoleteElements)
allowObsoleteElements
- Indicates whether to allow schema elements declared with the
OBSOLETE modifier. If this is true
, then obsolete
elements will be allowed. If this is false
, then
an error will be reported for each OBSOLETE schema element.@Nullable public Schema validateSchema(@NotNull java.io.File schemaPath, @Nullable Schema existingSchema, @NotNull java.util.List<java.lang.String> errorMessages)
schemaPath
- The file or directory containing the schema definitions to
validate. It must not be null
, and the target file
or directory must exist. If it is a directory, then files in
the directory will be processed in lexicographic order by
filename, optionally restricted to files matching the schema
file name pattern.existingSchema
- An existing schema to use in the course of validating
definitions. It may be null
if there is no existing
schema and only the definitions read from the provided path
should be used.errorMessages
- A list that will be updated with error messages about any
problems identified during processing. It must not be
null
, and it must be updatable.Schema
object that contains the definitions that were
loaded. This may include schema elements that were flagged as
invalid (if they could be parsed). If an existing schema was
already available, the schema that is returned will be a merged
representation of the existing schema and the newly loaded schema.
This may be null
if an error prevented any schema files
from being processed and no existing schema was provided.