public final class SchemaBuilder extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
SchemaBuilder.SchemaBuilderHook
Allows to perform modifications on element's builders before adding the result to this schema builder.
|
Constructor and Description |
---|
SchemaBuilder()
Creates a new schema builder with no schema elements and default compatibility options.
|
SchemaBuilder(Entry entry)
Creates a new schema builder containing all of the schema elements
contained in the provided subschema subentry.
|
SchemaBuilder(Schema schema)
Creates a new schema builder containing all of the schema elements from
the provided schema and its compatibility options.
|
SchemaBuilder(String schemaName)
Creates a new schema builder with no schema elements and default
compatibility options.
|
Modifier and Type | Method and Description |
---|---|
SchemaBuilder |
addAttributeType(String definition,
boolean overwrite)
Adds the provided attribute type definition to this schema builder.
|
SchemaBuilder |
addDitContentRule(String definition,
boolean overwrite)
Adds the provided DIT content rule definition to this schema builder.
|
SchemaBuilder |
addDitStructureRule(String definition,
boolean overwrite)
Adds the provided DIT structure rule definition to this schema builder.
|
SchemaBuilder |
addEnumerationSyntax(String oid,
String description,
boolean overwrite,
String... enumerations)
Adds the provided enumeration syntax definition to this schema builder.
|
SchemaBuilder |
addMatchingRule(String definition,
boolean overwrite)
Adds the provided matching rule definition to this schema builder.
|
SchemaBuilder |
addMatchingRuleUse(String definition,
boolean overwrite)
Adds the provided matching rule use definition to this schema builder.
|
SchemaBuilder |
addNameForm(String definition,
boolean overwrite)
Adds the provided name form definition to this schema builder.
|
SchemaBuilder |
addObjectClass(String definition,
boolean overwrite)
Adds the provided object class definition to this schema builder.
|
SchemaBuilder |
addPatternSyntax(String oid,
String description,
Pattern pattern,
boolean overwrite)
Adds the provided pattern syntax definition to this schema builder.
|
SchemaBuilder |
addSchema(Connection connection,
Dn name,
boolean overwrite)
Reads the schema elements contained in the named subschema sub-entry and
adds them to this schema builder.
|
SchemaBuilder |
addSchema(Entry entry,
boolean overwrite)
Adds all of the schema elements contained in the provided subschema
subentry to this schema builder.
|
SchemaBuilder |
addSchema(Entry entry,
boolean overwrite,
SchemaBuilder.SchemaBuilderHook hook)
Adds all of the schema elements contained in the provided subschema
subentry to this schema builder.
|
Single<SchemaBuilder> |
addSchema(LdapClientSocket socket,
Dn name,
boolean overwrite)
Reads the schema elements contained in the named subschema
sub-entry and adds them to this schema builder.
|
SchemaBuilder |
addSchema(Schema schema,
boolean overwrite)
Adds all of the schema elements in the provided schema to this schema
builder.
|
LdapPromise<SchemaBuilder> |
addSchemaAsync(Connection connection,
Dn name,
boolean overwrite)
Asynchronously reads the schema elements contained in the named subschema
sub-entry and adds them to this schema builder.
|
SchemaBuilder |
addSchemaForEntry(Connection connection,
Dn name,
boolean overwrite)
Reads the schema elements contained in the subschema sub-entry which
applies to the named entry and adds them to this schema builder.
|
Single<SchemaBuilder> |
addSchemaForEntry(LdapClientSocket socket,
Dn name,
boolean overwrite)
Reads the schema elements contained in the subschema sub-entry which applies to the named entry and adds them to
this schema builder.
|
LdapPromise<SchemaBuilder> |
addSchemaForEntryAsync(Connection connection,
Dn name,
boolean overwrite)
Asynchronously reads the schema elements contained in the subschema
sub-entry which applies to the named entry and adds them to this schema
builder.
|
SchemaBuilder |
addSubstitutionSyntax(String oid,
String description,
String substituteSyntax,
boolean overwrite)
Adds the provided substitution syntax definition to this schema builder.
|
SchemaBuilder |
addSyntax(String definition,
boolean overwrite)
Adds the provided syntax definition to this schema builder.
|
AttributeType.Builder |
buildAttributeType(AttributeType attributeType)
Returns an attribute type builder whose fields are initialized to the
values of the provided attribute type.
|
AttributeType.Builder |
buildAttributeType(String oid)
Returns a builder which can be used for incrementally constructing a new
attribute type before adding it to the schema.
|
DitContentRule.Builder |
buildDitContentRule(DitContentRule contentRule)
Returns a DIT content rule builder whose fields are initialized to the
values of the provided DIT content rule.
|
DitContentRule.Builder |
buildDitContentRule(String structuralClassOid)
Returns a builder which can be used for incrementally constructing a new
DIT content rule before adding it to the schema.
|
DitStructureRule.Builder |
buildDitStructureRule(DitStructureRule structureRule)
Returns an DIT structure rule builder whose fields are initialized to the
values of the provided rule.
|
DitStructureRule.Builder |
buildDitStructureRule(int ruleId)
Returns a builder which can be used for incrementally constructing a new
DIT structure rule before adding it to the schema.
|
MatchingRule.Builder |
buildMatchingRule(MatchingRule matchingRule)
Returns a matching rule builder whose fields are initialized to the
values of the provided matching rule.
|
MatchingRule.Builder |
buildMatchingRule(String oid)
Returns a builder which can be used for incrementally constructing a new matching rule before adding it to the
schema.
|
MatchingRuleUse.Builder |
buildMatchingRuleUse(MatchingRuleUse matchingRuleUse)
Returns a matching rule use builder whose fields are initialized to the
values of the provided matching rule use object.
|
MatchingRuleUse.Builder |
buildMatchingRuleUse(String oid)
Returns a builder which can be used for incrementally constructing a new
matching rule use before adding it to the schema.
|
NameForm.Builder |
buildNameForm(NameForm nameForm)
Returns a name form builder whose fields are initialized to the
values of the provided name form.
|
NameForm.Builder |
buildNameForm(String oid)
Returns a builder which can be used for incrementally constructing a new
name form before adding it to the schema.
|
ObjectClass.Builder |
buildObjectClass(ObjectClass objectClass)
Returns an object class builder whose fields are initialized to the
values of the provided object class.
|
ObjectClass.Builder |
buildObjectClass(String oid)
Returns a builder which can be used for incrementally constructing a new
object class before adding it to the schema.
|
Syntax.Builder |
buildSyntax(String oid)
Returns a builder which can be used for incrementally constructing a new
syntax before adding it to the schema.
|
Syntax.Builder |
buildSyntax(Syntax syntax)
Returns a syntax builder whose fields are initialized to the
values of the provided syntax.
|
boolean |
removeAttributeType(String nameOrOid)
Removes the named attribute type from this schema builder.
|
boolean |
removeDitContentRule(String nameOrOid)
Removes the named DIT content rule from this schema builder.
|
boolean |
removeDitStructureRule(int ruleId)
Removes the specified DIT structure rule from this schema builder.
|
boolean |
removeMatchingRule(String nameOrOid)
Removes the named matching rule from this schema builder.
|
boolean |
removeMatchingRuleUse(String nameOrOid)
Removes the named matching rule use from this schema builder.
|
boolean |
removeNameForm(String nameOrOid)
Removes the named name form from this schema builder.
|
boolean |
removeObjectClass(String nameOrOid)
Removes the named object class from this schema builder.
|
boolean |
removeSyntax(String numericOid)
Removes the named syntax from this schema builder.
|
<T> SchemaBuilder |
setOption(Option<T> option,
T value)
Sets a schema option overriding any previous values for the option.
|
Schema |
toSchema()
Returns a strict
Schema containing all of the schema elements
contained in this schema builder as well as the same set of schema
compatibility options. |
public SchemaBuilder()
public SchemaBuilder(Entry entry)
Schema.getWarnings()
method.entry
- The subschema subentry to be parsed.NullPointerException
- If entry
was null
.public SchemaBuilder(Schema schema)
schema
- The initial contents of the schema builder.NullPointerException
- If schema
was null
.public SchemaBuilder(String schemaName)
schemaName
- The user-friendly name of this schema which may be used for
debugging purposes.public SchemaBuilder addAttributeType(String definition, boolean overwrite)
definition
- The attribute type definition.overwrite
- true
if any existing attribute type with the same OID
should be overwritten.ConflictingSchemaElementException
- If overwrite
was false
and a conflicting
schema element was found.LocalizedIllegalArgumentException
- If the provided attribute type definition could not be
parsed.NullPointerException
- If definition
was null
.public SchemaBuilder addDitContentRule(String definition, boolean overwrite)
definition
- The DIT content rule definition.overwrite
- true
if any existing DIT content rule with the same
OID should be overwritten.ConflictingSchemaElementException
- If overwrite
was false
and a conflicting
schema element was found.LocalizedIllegalArgumentException
- If the provided DIT content rule definition could not be
parsed.NullPointerException
- If definition
was null
.public SchemaBuilder addDitStructureRule(String definition, boolean overwrite)
definition
- The DIT structure rule definition.overwrite
- true
if any existing DIT structure rule with the same
OID should be overwritten.ConflictingSchemaElementException
- If overwrite
was false
and a conflicting
schema element was found.LocalizedIllegalArgumentException
- If the provided DIT structure rule definition could not be
parsed.NullPointerException
- If definition
was null
.public SchemaBuilder addEnumerationSyntax(String oid, String description, boolean overwrite, String... enumerations)
oid
- The OID of the enumeration syntax definition.description
- The description of the enumeration syntax definition.overwrite
- true
if any existing syntax with the same OID should
be overwritten.enumerations
- The range of values which attribute values must match in order
to be valid.ConflictingSchemaElementException
- If overwrite
was false
and a conflicting
schema element was found.public SchemaBuilder addMatchingRule(String definition, boolean overwrite)
definition
- The matching rule definition.overwrite
- true
if any existing matching rule with the same OID
should be overwritten.ConflictingSchemaElementException
- If overwrite
was false
and a conflicting
schema element was found.LocalizedIllegalArgumentException
- If the provided matching rule definition could not be parsed.NullPointerException
- If definition
was null
.public SchemaBuilder addMatchingRuleUse(String definition, boolean overwrite)
definition
- The matching rule use definition.overwrite
- true
if any existing matching rule use with the same
OID should be overwritten.ConflictingSchemaElementException
- If overwrite
was false
and a conflicting
schema element was found.LocalizedIllegalArgumentException
- If the provided matching rule use definition could not be
parsed.NullPointerException
- If definition
was null
.public AttributeType.Builder buildAttributeType(String oid)
SchemaBuilder builder = ...; builder.buildAttributeType("attributetype-oid").name("attribute type name").addToSchema();
oid
- The OID of the attribute type definition.public DitStructureRule.Builder buildDitStructureRule(int ruleId)
SchemaBuilder builder = ...; final int myRuleID = ...; builder.buildDITStructureRule(myRuleID).name("DIT structure rule name").addToSchema();
ruleId
- The ID of the DIT structure rule.public MatchingRule.Builder buildMatchingRule(String oid)
SchemaBuilder builder = ...; builder.buildMatchingRule("matchingrule-oid").name("matching rule name").addToSchema();
oid
- The OID of the matching rule definition.public MatchingRuleUse.Builder buildMatchingRuleUse(String oid)
SchemaBuilder builder = ...; builder.buildMatchingRuleUse("matchingrule-oid") .name("matching rule use name") .addToSchema();
oid
- The OID of the matching rule definition.public SchemaBuilder addNameForm(String definition, boolean overwrite)
definition
- The name form definition.overwrite
- true
if any existing name form with the same OID
should be overwritten.ConflictingSchemaElementException
- If overwrite
was false
and a conflicting
schema element was found.LocalizedIllegalArgumentException
- If the provided name form definition could not be parsed.NullPointerException
- If definition
was null
.public DitContentRule.Builder buildDitContentRule(String structuralClassOid)
SchemaBuilder builder = ...; builder.buildDITContentRule("structuralobjectclass-oid").name("DIT content rule name").addToSchema();
structuralClassOid
- The OID of the structural objectclass for the DIT content rule to build.public NameForm.Builder buildNameForm(String oid)
SchemaBuilder builder = ...; builder.buildNameForm("1.2.3.4").name("myNameform").addToSchema();
oid
- The OID of the name form definition.public ObjectClass.Builder buildObjectClass(String oid)
SchemaBuilder builder = ...; builder.buildObjectClass("objectclass-oid").name("object class name").addToSchema();
oid
- The OID of the object class definition.public Syntax.Builder buildSyntax(String oid)
SchemaBuilder builder = ...; builder.buildSyntax("1.2.3.4").addToSchema();
oid
- The OID of the syntax definition.public AttributeType.Builder buildAttributeType(AttributeType attributeType)
attributeType
- The attribute type source.public DitContentRule.Builder buildDitContentRule(DitContentRule contentRule)
contentRule
- The DIT content rule source.public DitStructureRule.Builder buildDitStructureRule(DitStructureRule structureRule)
structureRule
- The DIT structure rule source.public MatchingRule.Builder buildMatchingRule(MatchingRule matchingRule)
matchingRule
- The matching rule source.public MatchingRuleUse.Builder buildMatchingRuleUse(MatchingRuleUse matchingRuleUse)
matchingRuleUse
- The matching rule use source.public NameForm.Builder buildNameForm(NameForm nameForm)
nameForm
- The name form source.public ObjectClass.Builder buildObjectClass(ObjectClass objectClass)
objectClass
- The object class source.public Syntax.Builder buildSyntax(Syntax syntax)
syntax
- The syntax source.public SchemaBuilder addObjectClass(String definition, boolean overwrite)
definition
- The object class definition.overwrite
- true
if any existing object class with the same OID
should be overwritten.ConflictingSchemaElementException
- If overwrite
was false
and a conflicting
schema element was found.LocalizedIllegalArgumentException
- If the provided object class definition could not be parsed.NullPointerException
- If definition
was null
.public SchemaBuilder addPatternSyntax(String oid, String description, Pattern pattern, boolean overwrite)
oid
- The OID of the pattern syntax definition.description
- The description of the pattern syntax definition.pattern
- The regular expression pattern which attribute values must
match in order to be valid.overwrite
- true
if any existing syntax with the same OID should
be overwritten.ConflictingSchemaElementException
- If overwrite
was false
and a conflicting
schema element was found.public SchemaBuilder addSchema(Connection connection, Dn name, boolean overwrite) throws LdapException
If the requested schema is not returned by the Directory Server then the
request will fail with an EntryNotFoundException
.
connection
- A connection to the Directory Server whose schema is to be
read.name
- The distinguished name of the subschema sub-entry.overwrite
- true
if existing schema elements with the same
conflicting OIDs should be overwritten.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
isClosed() == true
.NullPointerException
- If the connection
or name
was null
.public SchemaBuilder addSchema(Entry entry, boolean overwrite)
Schema.getWarnings()
method.entry
- The subschema subentry to be parsed.overwrite
- true
if existing schema elements with the same
conflicting OIDs should be overwritten.NullPointerException
- If entry
was null
.public SchemaBuilder addSchema(Entry entry, boolean overwrite, SchemaBuilder.SchemaBuilderHook hook)
Schema.getWarnings()
method.entry
- The subschema subentry to be parsed.overwrite
- true
if existing schema elements with the same
conflicting OIDs should be overwritten.hook
- Allows to perform modifications on element's builders before adding the result to this schema builder.NullPointerException
- If entry
was null
.public SchemaBuilder addSchema(Schema schema, boolean overwrite)
schema
- The schema to be copied into this schema builder.overwrite
- true
if existing schema elements with the same
conflicting OIDs should be overwritten.ConflictingSchemaElementException
- If overwrite
was false
and conflicting schema
elements were found.NullPointerException
- If schema
was null
.public LdapPromise<SchemaBuilder> addSchemaAsync(Connection connection, Dn name, boolean overwrite)
If the requested schema is not returned by the Directory Server then the
request will fail with an EntryNotFoundException
.
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
.overwrite
- true
if existing schema elements with the same
conflicting OIDs should be overwritten.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 Single<SchemaBuilder> addSchema(LdapClientSocket socket, Dn name, boolean overwrite)
If the requested schema is not returned by the Directory Server then the
request will fail with an EntryNotFoundException
.
Note that the schema elements 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.overwrite
- true
if existing schema elements with the same conflicting OIDs should be overwritten.Single
wrapping the updated schema builder.UnsupportedOperationException
- If the connection 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 SchemaBuilder addSchemaForEntry(Connection connection, Dn name, boolean overwrite) 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
.
This implementation first reads the subschemaSubentry
attribute
of the entry in order to identify the schema and then invokes
addSchemaForEntry(Connection, Dn, boolean)
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.overwrite
- true
if existing schema elements with the same
conflicting OIDs should be overwritten.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 LdapPromise<SchemaBuilder> addSchemaForEntryAsync(Connection connection, Dn name, boolean overwrite)
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
addSchemaAsync(Connection, Dn, boolean)
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.overwrite
- true
if existing schema elements with the same
conflicting OIDs should be overwritten.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 Single<SchemaBuilder> addSchemaForEntry(LdapClientSocket socket, Dn name, boolean overwrite)
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 addSchema(LdapClientSocket, Dn, boolean)
to read the schema.
Note that the request will only be sent 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.overwrite
- true
if existing schema elements with the same conflicting OIDs should be overwritten.Single
representing the updated schema builder.UnsupportedOperationException
- If the connection 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 SchemaBuilder addSubstitutionSyntax(String oid, String description, String substituteSyntax, boolean overwrite)
oid
- The OID of the substitution syntax definition.description
- The description of the substitution syntax definition.substituteSyntax
- The OID of the syntax whose implementation should be
substituted.overwrite
- true
if any existing syntax with the same OID should
be overwritten.ConflictingSchemaElementException
- If overwrite
was false
and a conflicting
schema element was found.public SchemaBuilder addSyntax(String definition, boolean overwrite)
definition
- The syntax definition.overwrite
- true
if any existing syntax with the same OID should
be overwritten.ConflictingSchemaElementException
- If overwrite
was false
and a conflicting
schema element was found.LocalizedIllegalArgumentException
- If the provided syntax definition could not be parsed.NullPointerException
- If definition
was null
.public boolean removeAttributeType(String nameOrOid)
nameOrOid
- The name or OID of the attribute type to be removed.true
if the attribute type was found.public boolean removeDitContentRule(String nameOrOid)
nameOrOid
- The name or OID of the DIT content rule to be removed.true
if the DIT content rule was found.public boolean removeDitStructureRule(int ruleId)
ruleId
- The ID of the DIT structure rule to be removed.true
if the DIT structure rule was found.public boolean removeMatchingRule(String nameOrOid)
nameOrOid
- The name or OID of the matching rule to be removed.true
if the matching rule was found.public boolean removeMatchingRuleUse(String nameOrOid)
nameOrOid
- The name or OID of the matching rule use to be removed.true
if the matching rule use was found.public boolean removeNameForm(String nameOrOid)
nameOrOid
- The name or OID of the name form to be removed.true
if the name form was found.public boolean removeObjectClass(String nameOrOid)
nameOrOid
- The name or OID of the object class to be removed.true
if the object class was found.public boolean removeSyntax(String numericOid)
numericOid
- The name of the syntax to be removed.true
if the syntax was found.public <T> SchemaBuilder setOption(Option<T> option, T value)
T
- The option type.option
- Option with which the specified value is to be associated.value
- Value to be associated with the specified option.UnsupportedOperationException
- If the schema builder options are read only.public Schema toSchema()
Schema
containing all of the schema elements
contained in this schema builder as well as the same set of schema
compatibility options.
This method does not alter the contents of this schema builder.
Schema
containing all of the schema elements contained
in this schema builder as well as the same set of schema
compatibility optionsCopyright 2010-2022 ForgeRock AS.