@Immutable public final class Schema extends Object
Modifier and Type | Method and Description |
---|---|
Schema |
asNonStrictSchema()
Returns a non-strict view of this schema.
|
Schema |
asStrictSchema()
Returns a strict view of this schema.
|
AttributeType |
getAttributeType(String nameOrOid)
Returns the attribute type for the specified name or numeric OID.
|
AttributeType |
getAttributeType(String nameOrOid,
Syntax syntax)
Returns the attribute type for the specified name or numeric OID.
|
Collection<AttributeType> |
getAttributeTypes()
Returns an unmodifiable collection containing all of the attribute types
contained in this schema.
|
static Schema |
getCoreSchema()
Returns the core schema.
|
static Schema |
getDefaultSchema()
Returns the default schema which should be used by this application.
|
DitContentRule |
getDitContentRule(ObjectClass structuralClass)
Returns the DIT content rule associated with the provided structural
object class, or
null if no rule is defined. |
DitContentRule |
getDitContentRule(String nameOrOid)
Returns the DIT content rule with the specified name or numeric OID.
|
Collection<DitContentRule> |
getDitContentRules()
Returns an unmodifiable collection containing all of the DIT content
rules contained in this schema.
|
DitStructureRule |
getDitStructureRule(int ruleId)
Returns the DIT structure rule with the specified name or numeric OID.
|
DitStructureRule |
getDitStructureRule(String nameOrOid)
Returns the DIT structure rule with the specified name or numeric OID.
|
Collection<DitStructureRule> |
getDitStructureRules(NameForm nameForm)
Returns an unmodifiable collection containing all of the DIT structure
rules associated with the provided name form.
|
Collection<DitStructureRule> |
getDitStuctureRules()
Returns an unmodifiable collection containing all of the DIT structure
rules contained in this schema.
|
static Schema |
getEmptySchema()
Returns the empty schema.
|
MatchingRule |
getMatchingRule(String nameOrOid)
Returns the matching rule with the specified name or numeric OID.
|
Collection<MatchingRule> |
getMatchingRules()
Returns an unmodifiable collection containing all of the matching rules
contained in this schema.
|
MatchingRuleUse |
getMatchingRuleUse(MatchingRule matchingRule)
Returns the matching rule use associated with the provided matching rule,
or
null if no use is defined. |
MatchingRuleUse |
getMatchingRuleUse(String nameOrOid)
Returns the matching rule use with the specified name or numeric OID.
|
Collection<MatchingRuleUse> |
getMatchingRuleUses()
Returns an unmodifiable collection containing all of the matching rule
uses contained in this schema.
|
NameForm |
getNameForm(String nameOrOid)
Returns the name form with the specified name or numeric OID.
|
Collection<NameForm> |
getNameForms()
Returns an unmodifiable collection containing all of the name forms
contained in this schema.
|
Collection<NameForm> |
getNameForms(ObjectClass structuralClass)
Returns an unmodifiable collection containing all of the name forms
associated with the provided structural object class.
|
ObjectClass |
getObjectClass(String nameOrOid)
Returns the object class with the specified name or numeric OID.
|
Collection<ObjectClass> |
getObjectClasses()
Returns an unmodifiable collection containing all of the object classes
contained in this schema.
|
<T> T |
getOption(Option<T> option)
Returns the value associated to the provided
Option or the option
default value, if there is no such option in this schema. |
String |
getSchemaName()
Returns the user-friendly name of this schema which may be used for
debugging purposes.
|
Syntax |
getSyntax(String numericOid)
Returns the syntax with the specified numeric OID.
|
Collection<Syntax> |
getSyntaxes()
Returns an unmodifiable collection containing all of the syntaxes
contained in this schema.
|
Collection<LocalizableMessage> |
getWarnings()
Returns an unmodifiable collection containing all of the warnings that
were detected when this schema was constructed.
|
boolean |
hasAttributeType(String nameOrOid)
Indicates whether this schema contains an attribute type with the
specified name or numeric OID.
|
boolean |
hasDitContentRule(String nameOrOid)
Indicates whether this schema contains a DIT content rule with the
specified name or numeric OID.
|
boolean |
hasDitStructureRule(int ruleId)
Indicates whether this schema contains a DIT structure rule with
the specified rule ID.
|
boolean |
hasMatchingRule(String nameOrOid)
Indicates whether this schema contains a matching rule with the
specified name or numeric OID.
|
boolean |
hasMatchingRuleUse(String nameOrOid)
Indicates whether this schema contains a matching rule use with
the specified name or numeric OID.
|
boolean |
hasNameForm(String nameOrOid)
Indicates whether this schema contains a name form with the
specified name or numeric OID.
|
boolean |
hasObjectClass(String nameOrOid)
Indicates whether this schema contains an object class with the
specified name or numeric OID.
|
boolean |
hasSyntax(String numericOid)
Indicates whether this schema contains a syntax with the specified
numeric OID.
|
boolean |
isStrict()
Indicates whether this schema is strict.
|
static Schema |
readSchema(Connection connection,
Dn name)
Reads the schema contained in the named subschema sub-entry.
|
static Single<Schema> |
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 Schema |
readSchemaForEntry(Connection connection,
Dn name)
Reads the schema contained in the subschema sub-entry which applies to
the named entry.
|
static Single<Schema> |
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 void |
setDefaultSchema(Schema schema)
Sets the default schema which should be used by this application.
|
Entry |
toEntry(Entry entry)
Adds the definitions of all the schema elements contained in this schema
to the provided subschema subentry.
|
String |
toString() |
boolean |
validateEntry(Entry entry,
SchemaValidationPolicy policy,
Collection<LocalizableMessage> errorMessages)
Returns
true if the provided entry is valid according to this
schema and the specified schema validation policy. |
static Schema |
valueOf(Entry entry)
Parses the provided entry as a subschema subentry.
|
public static Schema getCoreSchema()
public static Schema getDefaultSchema()
public static Schema getEmptySchema()
public static Schema readSchema(Connection connection, Dn name) throws LdapException
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 return null
.
connection
- A connection to the Directory Server whose schema is to be
read.name
- The distinguished name of the subschema sub-entry.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. if
connection.isClosed() == true
.NullPointerException
- If the connection
or name
was null
.public static LdapPromise<Schema> readSchemaAsync(Connection connection, Dn name)
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 return null
.
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 be null
.UnsupportedOperationException
- If the connection does not support search operations.IllegalStateException
- If the connection has already been closed, i.e. if
connection.isClosed() == true
.NullPointerException
- If the connection
or name
was null
.public static Single<Schema> readSchema(LdapClientSocket socket, Dn name)
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 Single
has been subscribed.
socket
- A socket to the Directory Server whose schema is to be
read.name
- The distinguished name of the subschema sub-entry.Single
wrapping the schema from the Directory Server.UnsupportedOperationException
- If the socket does not support search operations.IllegalStateException
- If the socket has already been closed, i.e. if
socket.isClosed() == true
.NullPointerException
- If the socket
or name
was null
.public static Schema readSchemaForEntry(Connection connection, Dn name) throws LdapException
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
return null
.
This implementation first reads the subschemaSubentry
attribute
of the entry in order to identify the schema and then invokes
readSchema(Connection, Dn)
to read the schema.
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.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. if
connection.isClosed() == true
.NullPointerException
- If the connection
or name
was null
.public static LdapPromise<Schema> readSchemaForEntryAsync(Connection connection, Dn name)
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 return null
.
This implementation first reads the subschemaSubentry
attribute
of the entry in order to identify the schema and then invokes
readSchemaAsync(Connection, Dn)
to read the schema.
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.UnsupportedOperationException
- If the connection does not support search operations.IllegalStateException
- If the connection has already been closed, i.e. if
connection.isClosed() == true
.NullPointerException
- If the connection
or name
was null
.public static Single<Schema> readSchemaForEntry(LdapClientSocket socket, Dn name)
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 subschemaSubentry
attribute
of the entry in order to identify the schema and then invokes
readSchema(LdapClientSocket, Dn)
to read the schema.
Note that the schema will only be read when the returned Single
has been subscribed.
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.Single
wrapping the retrieved schema.UnsupportedOperationException
- If the socket does not support search operations.IllegalStateException
- If the socket has already been closed, i.e. if
socket.isClosed() == true
.NullPointerException
- If the socket
or name
was null
.public static void setDefaultSchema(Schema schema)
schema
- The default schema which should be used by this application.public static Schema valueOf(Entry entry)
getWarnings()
method.entry
- The subschema subentry to be parsed.public Schema asNonStrictSchema()
See the description of isStrict()
for more details.
isStrict()
public Schema asStrictSchema()
See the description of isStrict()
for more details.
isStrict()
public AttributeType getAttributeType(String nameOrOid)
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. Place holder attribute types have an OID which
is the normalized attribute name with the string -oid
appended.
In addition, they will use the directory string syntax and case ignore
matching rule.
nameOrOid
- The name or OID of the attribute type to retrieve.UnknownSchemaElementException
- If this is a strict schema and the requested attribute type
was not found.AttributeType.isPlaceHolder()
public AttributeType getAttributeType(String nameOrOid, Syntax syntax)
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. Place holder attribute types have an OID which
is the normalized attribute name with the string -oid
appended.
In addition, they will use the provided syntax and the default matching
rule associated with the syntax.
nameOrOid
- The name or OID of the attribute type to retrieve.syntax
- The syntax to use when creating the temporary "place-holder" attribute type.UnknownSchemaElementException
- If this is a strict schema and the requested attribute type
was not found.AttributeType.isPlaceHolder()
public Collection<AttributeType> getAttributeTypes()
public DitContentRule getDitContentRule(ObjectClass structuralClass)
null
if no rule is defined.structuralClass
- The structural object class .null
if no rule is defined.public DitContentRule getDitContentRule(String nameOrOid)
nameOrOid
- The name or OID of the DIT content rule to retrieve.UnknownSchemaElementException
- If this is a strict schema and the requested DIT content rule
was not found.public Collection<DitContentRule> getDitContentRules()
public DitStructureRule getDitStructureRule(int ruleId)
ruleId
- The ID of the DIT structure rule to retrieve.UnknownSchemaElementException
- If this is a strict schema and the requested DIT structure
rule was not found.public DitStructureRule getDitStructureRule(String nameOrOid)
nameOrOid
- The name or OID of the DIT structure rule to retrieve.UnknownSchemaElementException
- If this is a strict schema and the requested DIT structure rule
was not found.public Collection<DitStructureRule> getDitStructureRules(NameForm nameForm)
nameForm
- The name form.public Collection<DitStructureRule> getDitStuctureRules()
public MatchingRule getMatchingRule(String nameOrOid)
nameOrOid
- The name or OID of the matching rule to retrieve.UnknownSchemaElementException
- If this is a strict schema and the requested matching rule
was not found.public Collection<MatchingRule> getMatchingRules()
public MatchingRuleUse getMatchingRuleUse(MatchingRule matchingRule)
null
if no use is defined.matchingRule
- The matching rule whose matching rule use is to be retrieved.null
if no use is defined.public MatchingRuleUse getMatchingRuleUse(String nameOrOid)
nameOrOid
- The name or OID of the matching rule use to retrieve.UnknownSchemaElementException
- If this is a strict schema and the requested matching rule
use was not found.public Collection<MatchingRuleUse> getMatchingRuleUses()
public NameForm getNameForm(String nameOrOid)
nameOrOid
- The name or OID of the name form to retrieve.UnknownSchemaElementException
- If this is a strict schema and the requested name form was
not found.public Collection<NameForm> getNameForms()
public Collection<NameForm> getNameForms(ObjectClass structuralClass)
structuralClass
- The structural object class whose name forms are to be
retrieved.public ObjectClass getObjectClass(String nameOrOid)
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. Place holder object classes have an OID which
is the normalized name with the string -oid
appended.
nameOrOid
- The name or OID of the object class to retrieve.UnknownSchemaElementException
- If this is a strict schema and the requested object class was
not found.ObjectClass.isPlaceHolder()
public Collection<ObjectClass> getObjectClasses()
public <T> T getOption(Option<T> option)
Option
or the option
default value, if there is no such option in this schema.T
- The option type.option
- The option whose associated value should to be retrieve.Option
or the option
default value, if there is no such option in this schema.public String getSchemaName()
public Syntax getSyntax(String numericOid)
numericOid
- The OID of the syntax to retrieve.UnknownSchemaElementException
- If this is a strict schema and the requested syntax was not
found or if the provided name is ambiguous.public Collection<Syntax> getSyntaxes()
public Collection<LocalizableMessage> getWarnings()
public boolean hasAttributeType(String nameOrOid)
nameOrOid
- The name or OID of the attribute type.true
if this schema contains an attribute type with the
specified name or numeric OID, otherwise false
.public boolean hasDitContentRule(String nameOrOid)
nameOrOid
- The name or OID of the DIT content rule.true
if this schema contains a DIT content rule with the
specified name or numeric OID, otherwise false
.public boolean hasDitStructureRule(int ruleId)
ruleId
- The ID of the DIT structure rule.true
if this schema contains a DIT structure rule with
the specified rule ID, otherwise false
.public boolean hasMatchingRule(String nameOrOid)
nameOrOid
- The name or OID of the matching rule.true
if this schema contains a matching rule with the
specified name or numeric OID, otherwise false
.public boolean hasMatchingRuleUse(String nameOrOid)
nameOrOid
- The name or OID of the matching rule use.true
if this schema contains a matching rule use with the
specified name or numeric OID, otherwise false
.public boolean hasNameForm(String nameOrOid)
nameOrOid
- The name or OID of the name form.true
if this schema contains a name form with the
specified name or numeric OID, otherwise false
.public boolean hasObjectClass(String nameOrOid)
nameOrOid
- The name or OID of the object class.true
if this schema contains an object class with the
specified name or numeric OID, otherwise false
.public boolean hasSyntax(String numericOid)
numericOid
- The OID of the syntax.true
if this schema contains a syntax with the specified
numeric OID, otherwise false
.public boolean isStrict()
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
UnknownSchemaElementException
whenever an attempt is made to
retrieve a non-existent attribute type.
true
if this schema is strict.public Entry toEntry(Entry entry)
entry
- The subschema subentry to which all schema definitions should
be added.NullPointerException
- If entry
was null
.public boolean validateEntry(Entry entry, SchemaValidationPolicy policy, Collection<LocalizableMessage> errorMessages)
true
if 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:
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, or null
if they should
not be saved.true
if an entry conforms to this schema based on the
provided schema validation policy.Copyright 2010-2022 ForgeRock AS.