Class Schema
- Attribute type definitions
- Object class definitions
- Attribute syntax definitions
- Matching rule definitions
- Matching rule use definitions
- DIT content rule definitions
- DIT structure rule definitions
- Name form definitions
-
Method Summary
Modifier and TypeMethodDescriptionReturns a non-strict view of this schema.Returns a strict view of this schema.getAttributeType(String nameOrOid) Returns the attribute type for the specified name or numeric OID.getAttributeType(String nameOrOid, Syntax syntax) Returns the attribute type for the specified name or numeric OID.Returns an unmodifiable collection containing all the attribute types contained in this schema.static SchemaReturns the core schema.static SchemaReturns the default schema which should be used by this application.getDitContentRule(String nameOrOid) Returns the DIT content rule with the specified name or numeric OID.getDitContentRule(ObjectClass structuralClass) Returns the DIT content rule associated with the provided structural object class, ornullif no rule is defined.Returns an unmodifiable collection containing all the DIT content rules contained in this schema.getDitStructureRule(int ruleId) Returns the DIT structure rule with the specified name or numeric OID.getDitStructureRule(String nameOrOid) Returns the DIT structure rule with the specified name or numeric OID.Returns an unmodifiable collection containing all the DIT structure rules contained in this schema.getDitStructureRules(NameForm nameForm) Returns an unmodifiable collection containing all the DIT structure rules associated with the provided name form.static SchemaReturns the empty schema.getMatchingRule(String nameOrOid) Returns the matching rule with the specified name or numeric OID.Returns an unmodifiable collection containing all the matching rules contained in this schema.getMatchingRuleUse(String nameOrOid) Returns the matching rule use with the specified name or numeric OID.getMatchingRuleUse(MatchingRule matchingRule) Returns the matching rule use associated with the provided matching rule, ornullif no use is defined.Returns an unmodifiable collection containing all the matching rule uses contained in this schema.getNameForm(String nameOrOid) Returns the name form with the specified name or numeric OID.Returns an unmodifiable collection containing all the name forms contained in this schema.getNameForms(ObjectClass structuralClass) Returns an unmodifiable collection containing all the name forms associated with the provided structural object class.getObjectClass(String nameOrOid) Returns the object class with the specified name or numeric OID.Returns an unmodifiable collection containing all the object classes contained in this schema.<T> TReturns the value associated to the providedOptionor the option default value, if there is no such option in this schema.static SearchRequestgetReadSchemaSearchRequest(Dn name) Constructs a search request for retrieving the named subschema sub-entry.Returns the user-friendly name of this schema which may be used for debugging purposes.Returns the syntax with the specified numeric OID.Returns an unmodifiable collection containing all the syntaxes contained in this schema.Returns an unmodifiable collection containing all the warnings that were detected when this schema was constructed.booleanhasAttributeType(String nameOrOid) Indicates whether this schema contains an attribute type with the specified name or numeric OID.booleanhasDitContentRule(String nameOrOid) Indicates whether this schema contains a DIT content rule with the specified name or numeric OID.booleanhasDitStructureRule(int ruleId) Indicates whether this schema contains a DIT structure rule with the specified rule ID.booleanhasMatchingRule(String nameOrOid) Indicates whether this schema contains a matching rule with the specified name or numeric OID.booleanhasMatchingRuleUse(String nameOrOid) Indicates whether this schema contains a matching rule use with the specified name or numeric OID.booleanhasNameForm(String nameOrOid) Indicates whether this schema contains a name form with the specified name or numeric OID.booleanhasObjectClass(String nameOrOid) Indicates whether this schema contains an object class with the specified name or numeric OID.booleanIndicates whether this schema contains a syntax with the specified numeric OID.booleanisStrict()Indicates whether this schema is strict.static SchemareadSchema(Connection connection, Dn name) Reads the schema contained in the named subschema sub-entry.readSchema(LdapClientSocket socket, Dn name) Reads the schema contained in the named subschema sub-entry.static LdapPromise<Schema>readSchemaAsync(Connection connection, Dn name) Asynchronously reads the schema contained in the named subschema sub-entry.static SchemareadSchemaForEntry(Connection connection, Dn name) Reads the schema contained in the subschema sub-entry which applies to the named entry.readSchemaForEntry(LdapClientSocket socket, Dn name) Reads the schema contained in the subschema sub-entry which applies to the named entry.static LdapPromise<Schema>readSchemaForEntryAsync(Connection connection, Dn name) Asynchronously reads the schema contained in the subschema sub-entry which applies to the named entry.static voidsetDefaultSchema(Schema schema) Sets the default schema which should be used by this application.Adds the definitions of all the schema elements contained in this schema to the provided subschema subentry.toString()booleanvalidateEntry(Entry entry, SchemaValidationPolicy policy, Collection<LocalizableMessage> errorMessages) Returnstrueif the provided entry is valid according to this schema and the specified schema validation policy.static SchemaParses the provided entry as a subschema subentry.
-
Method Details
-
getCoreSchema
Returns the core schema. The core schema is non-strict and contains the following standard LDAP schema elements:- RFC 4512 - Lightweight Directory Access Protocol (LDAP): Directory Information Models
- RFC 4517 - Lightweight Directory Access Protocol (LDAP): Syntaxes and Matching Rules
- RFC 4519 - Lightweight Directory Access Protocol (LDAP): Schema for User Applications
- RFC 4530 - Lightweight Directory Access Protocol (LDAP): entryUUID Operational Attribute
- RFC 3045 - Storing Vendor Information in the LDAP root DSE
- RFC 3112 - LDAP Authentication Password Schema
- Returns:
- The core schema.
-
getDefaultSchema
Returns the default schema which should be used by this application. The default schema is initially set to the core schema.- Returns:
- The default schema which should be used by this application.
-
getEmptySchema
Returns the empty schema. The empty schema is non-strict and does not contain any schema elements.- Returns:
- The empty schema.
-
getReadSchemaSearchRequest
Constructs a search request for retrieving the named subschema sub-entry.- Parameters:
name- The distinguished name of the subschema sub-entry.- Returns:
- A SearchRequest to fetch the schema from the given dn.
-
readSchema
Reads the schema contained in the named subschema sub-entry.If the requested schema is not returned by the Directory Server then the request will fail with an
EntryNotFoundException. More specifically, this method will never returnnull.- Parameters:
connection- A connection to the Directory Server whose schema is to be read.name- The distinguished name of the subschema sub-entry.- Returns:
- The schema from the Directory Server.
- Throws:
LdapException- If the result code indicates that the request failed for some reason.UnsupportedOperationException- If the connection does not support search operations.IllegalStateException- If the connection has already been closed, i.e. ifconnection.isClosed() == true.NullPointerException- If theconnectionornamewasnull.
-
readSchemaAsync
Asynchronously reads the schema contained in the named subschema sub-entry.If the requested schema is not returned by the Directory Server then the request will fail with an
EntryNotFoundException. More specifically, the returned promise will never returnnull.- Parameters:
connection- A connection to the Directory Server whose schema is to be read.name- The distinguished name of the subschema sub-entry. the operation result when it is received, may benull.- Returns:
- A promise representing the retrieved schema.
- Throws:
UnsupportedOperationException- If the connection does not support search operations.IllegalStateException- If the connection has already been closed, i.e. ifconnection.isClosed() == true.NullPointerException- If theconnectionornamewasnull.
-
readSchema
Reads the schema contained in the named subschema sub-entry.If the requested schema is not returned by the Directory Server then the request will fail with an
EntryNotFoundException.Note that the schema will only be read when the returned
Singlehas been subscribed.- Parameters:
socket- A socket to the Directory Server whose schema is to be read.name- The distinguished name of the subschema sub-entry.- Returns:
- A
Singlewrapping the schema from the Directory Server. - Throws:
UnsupportedOperationException- If the socket does not support search operations.IllegalStateException- If the socket has already been closed, i.e. ifsocket.isClosed() == true.NullPointerException- If thesocketornamewasnull.
-
readSchemaForEntry
Reads the schema contained in the subschema sub-entry which applies to the named entry.If the requested entry or its associated schema are not returned by the Directory Server then the request will fail with an
EntryNotFoundException. More specifically, this method will never returnnull.This implementation first reads the
subschemaSubentryattribute of the entry in order to identify the schema and then invokesreadSchema(Connection, Dn)to read the schema.- Parameters:
connection- A connection to the Directory Server whose schema is to be read.name- The distinguished name of the entry whose schema is to be located.- Returns:
- The schema from the Directory Server which applies to the named entry.
- Throws:
LdapException- If the result code indicates that the request failed for some reason.UnsupportedOperationException- If the connection does not support search operations.IllegalStateException- If the connection has already been closed, i.e. ifconnection.isClosed() == true.NullPointerException- If theconnectionornamewasnull.
-
readSchemaForEntryAsync
Asynchronously reads the schema contained in the subschema sub-entry which applies to the named entry.If the requested entry or its associated schema are not returned by the Directory Server then the request will fail with an
EntryNotFoundException. More specifically, the returned promise will never returnnull.This implementation first reads the
subschemaSubentryattribute of the entry in order to identify the schema and then invokesreadSchemaAsync(Connection, Dn)to read the schema.- Parameters:
connection- A connection to the Directory Server whose schema is to be read.name- The distinguished name of the entry whose schema is to be located.- Returns:
- A promise representing the retrieved schema.
- Throws:
UnsupportedOperationException- If the connection does not support search operations.IllegalStateException- If the connection has already been closed, i.e. ifconnection.isClosed() == true.NullPointerException- If theconnectionornamewasnull.
-
readSchemaForEntry
Reads the schema contained in the subschema sub-entry which applies to the named entry.If the requested entry or its associated schema are not returned by the Directory Server then the request will fail with an
EntryNotFoundException.This implementation first reads the
subschemaSubentryattribute of the entry in order to identify the schema and then invokesreadSchema(LdapClientSocket, Dn)to read the schema.Note that the schema will only be read when the returned
Singlehas been subscribed.- Parameters:
socket- A socket to the Directory Server whose schema is to be read.name- The distinguished name of the entry whose schema is to be located.- Returns:
- A
Singlewrapping the retrieved schema. - Throws:
UnsupportedOperationException- If the socket does not support search operations.IllegalStateException- If the socket has already been closed, i.e. ifsocket.isClosed() == true.NullPointerException- If thesocketornamewasnull.
-
setDefaultSchema
Sets the default schema which should be used by this application. The default schema is initially set to the core schema.- Parameters:
schema- The default schema which should be used by this application.
-
valueOf
Parses the provided entry as a subschema subentry. Any problems encountered while parsing the entry can be retrieved using the returned schema'sgetWarnings()method.- Parameters:
entry- The subschema subentry to be parsed.- Returns:
- The parsed schema.
-
asNonStrictSchema
Returns a non-strict view of this schema.See the description of
isStrict()for more details.- Returns:
- A non-strict view of this schema.
- See Also:
-
asStrictSchema
Returns a strict view of this schema.See the description of
isStrict()for more details.- Returns:
- A strict view of this schema.
- See Also:
-
getAttributeType
Returns the attribute type for the specified name or numeric OID.If the requested attribute type is not registered in this schema and this schema is non-strict then a temporary "place-holder" attribute type will be created and returned. Placeholder attribute types have an OID which is the normalized attribute name with the string
-oidappended. In addition, they will use the directory string syntax and case ignore matching rule.- Parameters:
nameOrOid- The name or OID of the attribute type to retrieve.- Returns:
- The requested attribute type.
- Throws:
UnknownSchemaElementException- If this is a strict schema and the requested attribute type was not found.- See Also:
-
getAttributeType
Returns the attribute type for the specified name or numeric OID.If the requested attribute type is not registered in this schema and this schema is non-strict then a temporary "place-holder" attribute type will be created and returned. Placeholder attribute types have an OID which is the normalized attribute name with the string
-oidappended. In addition, they will use the provided syntax and the default matching rule associated with the syntax.- Parameters:
nameOrOid- The name or OID of the attribute type to retrieve.syntax- The syntax to use when creating the temporary "place-holder" attribute type.- Returns:
- The requested attribute type.
- Throws:
UnknownSchemaElementException- If this is a strict schema and the requested attribute type was not found.- See Also:
-
getAttributeTypes
Returns an unmodifiable collection containing all the attribute types contained in this schema.- Returns:
- An unmodifiable collection containing all the attribute types contained in this schema.
-
getDitContentRule
Returns the DIT content rule associated with the provided structural object class, ornullif no rule is defined.- Parameters:
structuralClass- The structural object class .- Returns:
- The DIT content rule associated with the provided structural
object class, or
nullif no rule is defined.
-
getDitContentRule
Returns the DIT content rule with the specified name or numeric OID.- Parameters:
nameOrOid- The name or OID of the DIT content rule to retrieve.- Returns:
- The requested DIT content rule.
- Throws:
UnknownSchemaElementException- If this is a strict schema and the requested DIT content rule was not found.
-
getDitContentRules
Returns an unmodifiable collection containing all the DIT content rules contained in this schema.- Returns:
- An unmodifiable collection containing all the DIT content rules contained in this schema.
-
getDitStructureRule
Returns the DIT structure rule with the specified name or numeric OID.- Parameters:
ruleId- The ID of the DIT structure rule to retrieve.- Returns:
- The requested DIT structure rule.
- Throws:
UnknownSchemaElementException- If this is a strict schema and the requested DIT structure rule was not found.
-
getDitStructureRule
Returns the DIT structure rule with the specified name or numeric OID.- Parameters:
nameOrOid- The name or OID of the DIT structure rule to retrieve.- Returns:
- The requested DIT structure rule.
- Throws:
UnknownSchemaElementException- If this is a strict schema and the requested DIT structure rule was not found.
-
getDitStructureRules
Returns an unmodifiable collection containing all the DIT structure rules associated with the provided name form.- Parameters:
nameForm- The name form.- Returns:
- An unmodifiable collection containing all the DIT structure rules associated with the provided name form.
-
getDitStructureRules
Returns an unmodifiable collection containing all the DIT structure rules contained in this schema.- Returns:
- An unmodifiable collection containing all the DIT structure rules contained in this schema.
-
getMatchingRule
Returns the matching rule with the specified name or numeric OID.- Parameters:
nameOrOid- The name or OID of the matching rule to retrieve.- Returns:
- The requested matching rule.
- Throws:
UnknownSchemaElementException- If this is a strict schema and the requested matching rule was not found.
-
getMatchingRules
Returns an unmodifiable collection containing all the matching rules contained in this schema.- Returns:
- An unmodifiable collection containing all the matching rules contained in this schema.
-
getMatchingRuleUse
Returns the matching rule use associated with the provided matching rule, ornullif no use is defined.- Parameters:
matchingRule- The matching rule whose matching rule use is to be retrieved.- Returns:
- The matching rule use associated with the provided matching rule,
or
nullif no use is defined.
-
getMatchingRuleUse
Returns the matching rule use with the specified name or numeric OID.- Parameters:
nameOrOid- The name or OID of the matching rule use to retrieve.- Returns:
- The requested matching rule use.
- Throws:
UnknownSchemaElementException- If this is a strict schema and the requested matching rule use was not found.
-
getMatchingRuleUses
Returns an unmodifiable collection containing all the matching rule uses contained in this schema.- Returns:
- An unmodifiable collection containing all the matching rule uses contained in this schema.
-
getNameForm
Returns the name form with the specified name or numeric OID.- Parameters:
nameOrOid- The name or OID of the name form to retrieve.- Returns:
- The requested name form.
- Throws:
UnknownSchemaElementException- If this is a strict schema and the requested name form was not found.
-
getNameForms
Returns an unmodifiable collection containing all the name forms contained in this schema.- Returns:
- An unmodifiable collection containing all the name forms contained in this schema.
-
getNameForms
Returns an unmodifiable collection containing all the name forms associated with the provided structural object class.- Parameters:
structuralClass- The structural object class whose name forms are to be retrieved.- Returns:
- An unmodifiable collection containing all the name forms associated with the provided structural object class.
-
getObjectClass
Returns the object class with the specified name or numeric OID.If the requested object class is not registered in this schema and this schema is non-strict then a temporary "place-holder" object class will be created and returned. Placeholder object classes have an OID which is the normalized name with the string
-oidappended.- Parameters:
nameOrOid- The name or OID of the object class to retrieve.- Returns:
- The requested object class.
- Throws:
UnknownSchemaElementException- If this is a strict schema and the requested object class was not found.- See Also:
-
getObjectClasses
Returns an unmodifiable collection containing all the object classes contained in this schema.- Returns:
- An unmodifiable collection containing all the object classes contained in this schema.
-
getOption
Returns the value associated to the providedOptionor the option default value, if there is no such option in this schema.- Type Parameters:
T- The option type.- Parameters:
option- The option whose associated value should be retrieved.- Returns:
- The value associated to the provided
Optionor the option default value, if there is no such option in this schema.
-
getSchemaName
Returns the user-friendly name of this schema which may be used for debugging purposes. The format of the schema name is not defined but should contain the distinguished name of the subschema sub-entry for those schemas retrieved from a Directory Server.- Returns:
- The user-friendly name of this schema which may be used for debugging purposes.
-
getSyntax
Returns the syntax with the specified numeric OID.- Parameters:
numericOid- The OID of the syntax to retrieve.- Returns:
- The requested syntax.
- Throws:
UnknownSchemaElementException- If this is a strict schema and the requested syntax was not found or if the provided name is ambiguous.
-
getSyntaxes
Returns an unmodifiable collection containing all the syntaxes contained in this schema.- Returns:
- An unmodifiable collection containing all the syntaxes contained in this schema.
-
getWarnings
Returns an unmodifiable collection containing all the warnings that were detected when this schema was constructed.- Returns:
- An unmodifiable collection containing all the warnings that were detected when this schema was constructed.
-
hasAttributeType
Indicates whether this schema contains an attribute type with the specified name or numeric OID.- Parameters:
nameOrOid- The name or OID of the attribute type.- Returns:
trueif this schema contains an attribute type with the specified name or numeric OID, otherwisefalse.
-
hasDitContentRule
Indicates whether this schema contains a DIT content rule with the specified name or numeric OID.- Parameters:
nameOrOid- The name or OID of the DIT content rule.- Returns:
trueif this schema contains a DIT content rule with the specified name or numeric OID, otherwisefalse.
-
hasDitStructureRule
public boolean hasDitStructureRule(int ruleId) Indicates whether this schema contains a DIT structure rule with the specified rule ID.- Parameters:
ruleId- The ID of the DIT structure rule.- Returns:
trueif this schema contains a DIT structure rule with the specified rule ID, otherwisefalse.
-
hasMatchingRule
Indicates whether this schema contains a matching rule with the specified name or numeric OID.- Parameters:
nameOrOid- The name or OID of the matching rule.- Returns:
trueif this schema contains a matching rule with the specified name or numeric OID, otherwisefalse.
-
hasMatchingRuleUse
Indicates whether this schema contains a matching rule use with the specified name or numeric OID.- Parameters:
nameOrOid- The name or OID of the matching rule use.- Returns:
trueif this schema contains a matching rule use with the specified name or numeric OID, otherwisefalse.
-
hasNameForm
Indicates whether this schema contains a name form with the specified name or numeric OID.- Parameters:
nameOrOid- The name or OID of the name form.- Returns:
trueif this schema contains a name form with the specified name or numeric OID, otherwisefalse.
-
hasObjectClass
Indicates whether this schema contains an object class with the specified name or numeric OID.- Parameters:
nameOrOid- The name or OID of the object class.- Returns:
trueif this schema contains an object class with the specified name or numeric OID, otherwisefalse.
-
hasSyntax
Indicates whether this schema contains a syntax with the specified numeric OID.- Parameters:
numericOid- The OID of the syntax.- Returns:
trueif this schema contains a syntax with the specified numeric OID, otherwisefalse.
-
isStrict
public boolean isStrict()Indicates whether this schema is strict.Attribute type queries against non-strict schema always succeed: if the requested attribute type is not found then a temporary attribute type is created automatically having the Octet String syntax and associated matching rules.
Strict schema, on the other hand, throw an
UnknownSchemaElementExceptionwhenever an attempt is made to retrieve a non-existent attribute type.- Returns:
trueif this schema is strict.
-
toEntry
Adds the definitions of all the schema elements contained in this schema to the provided subschema subentry. Any existing attributes (including schema definitions) contained in the provided entry will be preserved.- Parameters:
entry- The subschema subentry to which all schema definitions should be added.- Returns:
- The updated subschema subentry.
- Throws:
NullPointerException- Ifentrywasnull.
-
validateEntry
public boolean validateEntry(Entry entry, SchemaValidationPolicy policy, Collection<LocalizableMessage> errorMessages) Returnstrueif the provided entry is valid according to this schema and the specified schema validation policy.If attribute value validation is enabled then following checks will be performed:
- checking that there is at least one value
- checking that single-valued attributes contain only a single value
- Parameters:
entry- The entry to be validated.policy- The schema validation policy.errorMessages- A collection into which any schema validation warnings or error messages can be placed, ornullif they should not be saved.- Returns:
trueif an entry conforms to this schema based on the provided schema validation policy.
-
toString
-