/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at legal-notices/CDDLv1_0.txt.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information:
* Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
*
* Copyright 2006-2010 Sun Microsystems, Inc.
* Portions Copyright 2011-2015 ForgeRock AS
*/
/**
* This class defines a data structure that holds information about
* the components of the Directory Server schema. It includes the
* following kinds of elements:
*
* <UL>
* <LI>Attribute type definitions</LI>
* <LI>Objectclass definitions</LI>
* <LI>Attribute syntax definitions</LI>
* <LI>Matching rule definitions</LI>
* <LI>Matching rule use definitions</LI>
* <LI>DIT content rule definitions</LI>
* <LI>DIT structure rule definitions</LI>
* <LI>Name form definitions</LI>
* </UL>
*/
mayInstantiate=false,
mayExtend=false,
mayInvoke=true)
public final class Schema
{
/**
* The set of subordinate attribute types registered within the server schema.
*/
/**
* The set of attribute type definitions for this schema, mapped between the
* lowercase names and OID for the definition and the attribute type itself.
*/
/**
* The set of objectclass definitions for this schema, mapped between the
* lowercase names and OID for the definition and the objectclass itself.
*/
/**
* The set of attribute syntaxes for this schema, mapped between the OID for
* the syntax and the syntax itself.
*/
/**
* The default attribute syntax to use for attributes with no defined syntax.
*/
/**
* The entire set of matching rules for this schema, mapped between the
* lowercase names and OID for the definition and the matching rule itself.
*/
/**
* The set of matching rule uses for this schema, mapped between the matching
* rule for the definition and the matching rule use itself.
*/
/**
* The set of DIT content rules for this schema, mapped between the structural
* objectclass for the definition and the DIT content rule itself.
*/
/**
* The set of DIT structure rules for this schema, mapped between the name
* form for the definition and the DIT structure rule itself.
*/
/**
* The set of DIT structure rules for this schema, mapped between the name
* form for the definition and the DIT structure rule itself.
*/
/**
* The set of name forms for this schema, mapped between the structural
* objectclass for the definition and the list of name forms.
*/
/**
* name form itself.
*/
/**
* The set of ldap syntax descriptions for this schema, mapped the OID and the
* ldap syntax description itself.
*/
/** The oldest modification timestamp for any schema configuration file. */
private long oldestModificationTime;
/** The youngest modification timestamp for any schema configuration file. */
private long youngestModificationTime;
/**
* A set of extra attributes that are not used directly by the schema but may
* be used by other component to store information in the schema.
* <p>
* ex : Replication uses this to store its state and GenerationID.
*/
/** Creates a new schema structure with all elements initialized but empty. */
public Schema()
{
attributeTypes = new ConcurrentHashMap<>();
objectClasses = new ConcurrentHashMap<>();
syntaxes = new ConcurrentHashMap<>();
matchingRules = new ConcurrentHashMap<>();
matchingRuleUses = new ConcurrentHashMap<>();
ditContentRules = new ConcurrentHashMap<>();
ditStructureRulesByID = new ConcurrentHashMap<>();
ditStructureRulesByNameForm = new ConcurrentHashMap<>();
nameFormsByOC = new ConcurrentHashMap<>();
nameFormsByName = new ConcurrentHashMap<>();
ldapSyntaxDescriptions = new ConcurrentHashMap<>();
subordinateTypes = new ConcurrentHashMap<>();
}
/**
* Retrieves the attribute type definitions for this schema, as a
* mapping between the lowercase names and OIDs for the attribute
* type and the attribute type itself. Each attribute type may be
* associated with multiple keys (once for the OID and again for
* each name). The contents of the returned mapping must not be
* altered.
*
* @return The attribute type definitions for this schema.
*/
{
return attributeTypes;
}
/**
* Indicates whether this schema definition includes an attribute
* type with the provided name or OID.
*
* @param lowerName The name or OID for which to make the
* determination, formatted in all lowercase
* characters.
*
* @return {@code true} if this schema contains an attribute type
* with the provided name or OID, or {@code false} if not.
*/
{
}
/**
* Retrieves the attribute type definition with the specified name
* or OID.
*
* @param lowerName The name or OID of the attribute type to
* retrieve, formatted in all lowercase
* characters.
*
* @return The requested attribute type, or <CODE>null</CODE> if no
* type is registered with the provided name or OID.
*/
{
}
/**
* Registers the provided attribute type definition with this
* schema.
*
* @param attributeType The attribute type to register with
* this schema.
* @param overwriteExisting Indicates whether to overwrite an
* existing mapping if there are any
* conflicts (i.e., another attribute
* type with the same OID or name).
*
* @throws DirectoryException If a conflict is encountered and the
* <CODE>overwriteExisting</CODE> flag
* is set to <CODE>false</CODE>
*/
boolean overwriteExisting)
throws DirectoryException
{
synchronized (attributeTypes)
{
if (! overwriteExisting)
{
{
throw new DirectoryException(
}
{
{
throw new DirectoryException(
}
}
}
{
// Mark the old attribute type as stale so that caches (such as
// compressed schema) can detect changes.
}
{
}
if (superiorType != null)
{
}
}
}
/**
* Deregisters the provided attribute type definition with this
* schema.
*
* @param attributeType The attribute type to deregister with this
* schema.
*/
{
synchronized (attributeTypes)
{
{
// Mark the old attribute type as stale so that caches (such as
// compressed schema) can detect changes.
}
{
}
if (superiorType != null)
{
}
}
}
/**
* Registers the provided attribute type as a subtype of the given
* superior attribute type, recursively following any additional
* elements in the superior chain.
*
* @param attributeType The attribute type to be registered as a
* subtype for the given superior type.
* @param superiorType The superior type for which to register
* the given attribute type as a subtype.
*/
{
{
}
{
if (higherSuperior != null)
{
}
}
}
/**
* Deregisters the provided attribute type as a subtype of the given
* superior attribute type, recursively following any additional
* elements in the superior chain.
*
* @param attributeType The attribute type to be deregistered as a
* subtype for the given superior type.
* @param superiorType The superior type for which to deregister
* the given attribute type as a subtype.
*/
{
{
if (higherSuperior != null)
{
}
}
}
/**
* Retrieves the set of subtypes registered for the given attribute
* type.
*
* @param attributeType The attribute type for which to retrieve
* the set of registered subtypes.
*
* @return The set of subtypes registered for the given attribute
* type, or an empty set if there are no subtypes
* registered for the attribute type.
*/
{
{
return Collections.emptyList();
}
else
{
return subTypes;
}
}
/**
* Retrieves the objectclass definitions for this schema, as a
* mapping between the lowercase names and OIDs for the objectclass
* and the objectclass itself. Each objectclass may be associated
* with multiple keys (once for the OID and again for each name).
* The contents of the returned mapping must not be altered.
*
* @return The objectclass definitions for this schema.
*/
{
return objectClasses;
}
/**
* Indicates whether this schema definition includes an objectclass
* with the provided name or OID.
*
* @param lowerName The name or OID for which to make the
* determination, formatted in all lowercase
* characters.
*
* @return {@code true} if this schema contains an objectclass with
* the provided name or OID, or {@code false} if not.
*/
{
}
/**
* Retrieves the objectclass definition with the specified name or
* OID.
*
* @param lowerName The name or OID of the objectclass to
* retrieve, formatted in all lowercase
* characters.
*
* @return The requested objectclass, or <CODE>null</CODE> if no
* class is registered with the provided name or OID.
*/
{
}
/**
* Registers the provided objectclass definition with this schema.
*
* @param objectClass The objectclass to register with this
* schema.
* @param overwriteExisting Indicates whether to overwrite an
* existing mapping if there are any
* conflicts (i.e., another objectclass
* with the same OID or name).
*
* @throws DirectoryException If a conflict is encountered and the
* <CODE>overwriteExisting</CODE> flag
* is set to <CODE>false</CODE>.
*/
boolean overwriteExisting)
throws DirectoryException
{
synchronized (objectClasses)
{
if (! overwriteExisting)
{
{
throw new DirectoryException(
}
{
{
throw new DirectoryException(
}
}
}
{
// Mark the old object class as stale so that caches (such as compressed
// schema) can detect changes.
}
{
}
}
}
/**
* Deregisters the provided objectclass definition with this schema.
*
* @param objectClass The objectclass to deregister with this
* schema.
*/
{
synchronized (objectClasses)
{
{
// Mark the old object class as stale so that caches (such as
// compressed schema) can detect changes.
}
{
}
}
}
/**
* Retrieves the attribute syntax definitions for this schema, as a
* mapping between the OID for the syntax and the syntax itself.
* Each syntax should only be present once, since its only key is
* its OID. The contents of the returned mapping must not be
* altered.
*
* @return The attribute syntax definitions for this schema.
*/
{
return syntaxes;
}
/**
* Indicates whether this schema definition includes an attribute
* syntax with the provided name or OID.
*
* @param lowerName The name or OID for which to make the
* determination, formatted in all lowercase
* characters.
*
* @return {@code true} if this schema contains an attribute syntax
* with the provided name or OID, or {@code false} if not.
*/
{
}
/**
* Retrieves the requested attribute syntax.
*
* @param oid
* The OID of the syntax to retrieve.
* @param allowDefault
* Indicates whether to return the default attribute syntax if the
* requested syntax is unknown.
* @return The requested attribute syntax, the default syntax if the requested
* syntax is unknown and the caller has indicated that the default is
* acceptable, or <CODE>null</CODE> otherwise.
*/
{
{
return getDefaultSyntax();
}
return syntax;
}
/**
* Retrieves the attribute syntax definition with the OID.
*
* @param lowerName The OID of the attribute syntax to retrieve,
* formatted in all lowercase characters.
*
* @return The requested attribute syntax, or <CODE>null</CODE> if
* no syntax is registered with the provided OID.
*/
{
}
/**
* Retrieves the default attribute syntax that should be used for attributes
* that are not defined in the server schema.
*
* @return The default attribute syntax that should be used for attributes
* that are not defined in the server schema.
*/
{
return defaultSyntax;
}
/**
* Registers the defaut syntax for this schema.
*
* @param defaultSyntax
* The defautl syntax to use.
*/
public void registerDefaultSyntax(
{
this.defaultSyntax = defaultSyntax;
}
/**
* Registers the provided attribute syntax definition with this
* schema.
*
* @param syntax The attribute syntax to register with
* this schema.
* @param overwriteExisting Indicates whether to overwrite an
* existing mapping if there are any
* conflicts (i.e., another attribute
* syntax with the same OID).
*
* @throws DirectoryException If a conflict is encountered and the
* <CODE>overwriteExisting</CODE> flag
* is set to <CODE>false</CODE>
*/
boolean overwriteExisting)
throws DirectoryException
{
synchronized (syntaxes)
{
if (! overwriteExisting)
{
{
throw new DirectoryException(
}
}
}
}
/**
* Deregisters the provided attribute syntax definition with this
* schema.
*
* @param syntax The attribute syntax to deregister with this
* schema.
*/
{
synchronized (syntaxes)
{
}
}
/**
* Retrieves the ldap syntax definitions for this schema, as a
* mapping between the OID for the syntax and the ldap syntax
* definition itself. Each ldap syntax should only be present once,
* since its only key is its OID. The contents of the returned
* mapping must not be altered.
*
* @return The ldap syntax definitions for this schema.
*/
{
return ldapSyntaxDescriptions;
}
/**
* Indicates whether this schema definition includes an ldap
* syntax description with the provided name or OID.
*
* @param lowerName The OID for which to make the
* determination, formatted in all lowercase
* characters.
*
* @return {@code true} if this schema contains an ldap syntax
* with the provided name or OID, or {@code false} if not.
*/
{
}
/**
* Retrieves the ldap syntax definition with the OID.
*
* @param lowerName The OID of the ldap syntax to retrieve,
* formatted in all lowercase characters.
*
* @return The requested ldap syntax, or <CODE>null</CODE> if
* no syntax is registered with the provided OID.
*/
{
}
/**
* Registers the provided ldap syntax description with this
* schema.
*
* @param syntax The ldap syntax description to register
* with this schema.
* @param overwriteExisting Indicates whether to overwrite an
* existing mapping if there are any
* conflicts (i.e., another ldap
* syntax with the same OID).
*
* @throws DirectoryException If a conflict is encountered and
* <CODE>overwriteExisting</CODE> flag
* is set to <CODE>false</CODE>
*/
public void registerLdapSyntaxDescription(
boolean overwriteExisting)
throws DirectoryException
{
/**
* ldapsyntaxes is part real and part virtual. For any
* ldapsyntaxes attribute this is real, an LDAPSyntaxDescription
* object is created and stored with the schema. Also, the
* associated LDAPSyntaxDescriptionSyntax is added into the
* virtual syntax set to make this available through virtual
* ldapsyntaxes attribute.
*/
synchronized (ldapSyntaxDescriptions)
{
{
}
//Register the attribute syntax with the schema. It will ensure
// syntax is available along with the other virtual values for
// ldapsyntaxes.
}
}
/**
* Deregisters the provided ldap syntax description with this
* schema.
*
* @param syntax The ldap syntax to deregister with this
* schema.
*/
public void deregisterLdapSyntaxDescription(
{
synchronized (ldapSyntaxDescriptions)
{
//Remove the real value.
syntax);
try
{
//Get rid of this from the virtual ldapsyntaxes.
}
catch (Exception e)
{
}
}
}
/**
* Retrieves the entire set of matching rule definitions for this
* schema, as a mapping between the lowercase names and OIDs for the
* matching rule and the matching rule itself. Each matching rule
* may be associated with multiple keys (once for the OID and again
* for each name). This should be a superset of the sets of
* approximate, equality, ordering, and substring matching rules.
* The contents of the returned mapping must not be altered.
*
* @return The matching rule definitions for this schema.
*/
{
return matchingRules;
}
/**
* Indicates whether this schema definition includes a matching rule
* with the provided name or OID.
*
* @param lowerName The name or OID for which to make the
* determination, formatted in all lowercase
* characters.
*
* @return {@code true} if this schema contains a matching rule
* with the provided name or OID, or {@code false} if not.
*/
{
}
/**
* Retrieves the matching rule definition with the specified name or
* OID.
*
* @param lowerName The name or OID of the matching rule to
* retrieve, formatted in all lowercase
* characters.
*
* @return The requested matching rule, or <CODE>null</CODE> if no
* rule is registered with the provided name or OID.
*/
{
}
/**
* Registers the provided matching rule definition with this schema.
*
* @param matchingRule The matching rule to register with
* this schema.
* @param overwriteExisting Indicates whether to overwrite an
* existing mapping if there are any
* conflicts (i.e.,
* another matching rule with the same
* OID or name).
*
* @throws DirectoryException If a conflict is encountered and the
* <CODE>overwriteExisting</CODE> flag
* is set to <CODE>false</CODE>
*/
throws DirectoryException
{
synchronized (matchingRules)
{
if (!overwriteExisting)
{
{
}
{
{
{
message);
}
}
}
}
{
{
}
}
}
}
/**
* Deregisters the provided matching rule definition with this
* schema.
*
* @param matchingRule The matching rule to deregister with this
* schema.
*/
{
synchronized (matchingRules)
{
{
{
}
}
}
}
/**
* Retrieves the matching rule use definitions for this schema, as a
* mapping between the matching rule for the matching rule use
* definition and the matching rule use itself. Each matching rule
* use should only be present once, since its only key is its
* matching rule. The contents of the returned mapping must not be
* altered.
*
* @return The matching rule use definitions for this schema.
*/
{
return matchingRuleUses;
}
/**
* Indicates whether this schema definition includes a matching rule
* use for the provided matching rule.
*
* @param matchingRule The matching rule for which to make the
* determination.
*
* @return {@code true} if this schema contains a matching rule use
* for the provided matching rule, or {@code false} if not.
*/
{
}
/**
* Retrieves the matching rule use definition for the specified
* matching rule.
*
* @param matchingRule The matching rule for which to retrieve the
* matching rule use definition.
*
* @return The matching rule use definition, or <CODE>null</CODE>
* if none exists for the specified matching rule.
*/
{
}
/**
* Registers the provided matching rule use definition with this
* schema.
*
* @param matchingRuleUse The matching rule use definition to
* register.
* @param overwriteExisting Indicates whether to overwrite an
* existing mapping if there are any
* conflicts (i.e., another matching rule
* use with the same matching rule).
*
* @throws DirectoryException If a conflict is encountered and the
* <CODE>overwriteExisting</CODE> flag
* is set to <CODE>false</CODE>
*/
boolean overwriteExisting)
throws DirectoryException
{
synchronized (matchingRuleUses)
{
{
throw new DirectoryException(
}
}
}
/**
* Deregisters the provided matching rule use definition with this
* schema.
*
* @param matchingRuleUse The matching rule use to deregister with
* this schema.
*/
public void deregisterMatchingRuleUse(
{
synchronized (matchingRuleUses)
{
}
}
/**
* Retrieves the DIT content rule definitions for this schema, as a
* mapping between the objectclass for the rule and the DIT content
* rule itself. Each DIT content rule should only be present once,
* since its only key is its objectclass. The contents of the
* returned mapping must not be altered.
*
* @return The DIT content rule definitions for this schema.
*/
{
return ditContentRules;
}
/**
* Indicates whether this schema definition includes a DIT content
* rule for the provided objectclass.
*
* @param objectClass The objectclass for which to make the
* determination.
*
* @return {@code true} if this schema contains a DIT content rule
* for the provided objectclass, or {@code false} if not.
*/
{
}
/**
* Retrieves the DIT content rule definition for the specified
* objectclass.
*
* @param objectClass The objectclass for the DIT content rule to
* retrieve.
*
* @return The requested DIT content rule, or <CODE>null</CODE> if
* no DIT content rule is registered with the provided
* objectclass.
*/
{
}
/**
* Registers the provided DIT content rule definition with this
* schema.
*
* @param ditContentRule The DIT content rule to register.
* @param overwriteExisting Indicates whether to overwrite an
* existing mapping if there are any
* conflicts (i.e., another DIT content
* rule with the same objectclass).
*
* @throws DirectoryException If a conflict is encountered and the
* <CODE>overwriteExisting</CODE> flag
* is set to <CODE>false</CODE>
*/
boolean overwriteExisting)
throws DirectoryException
{
synchronized (ditContentRules)
{
{
throw new DirectoryException(
}
}
}
/**
* Deregisters the provided DIT content rule definition with this
* schema.
*
* @param ditContentRule The DIT content rule to deregister with
* this schema.
*/
{
synchronized (ditContentRules)
{
}
}
/**
* Retrieves the DIT structure rule definitions for this schema, as
* a mapping between the rule ID for the rule and the DIT structure
* rule itself. Each DIT structure rule should only be present
* once, since its only key is its rule ID. The contents of the
* returned mapping must not be altered.
*
* @return The DIT structure rule definitions for this schema.
*/
{
return ditStructureRulesByID;
}
/**
* Retrieves the DIT structure rule definitions for this schema, as
* a mapping between the name form for the rule and the DIT
* structure rule itself. Each DIT structure rule should only be
* present once, since its only key is its name form. The contents
* of the returned mapping must not be altered.
*
* @return The DIT structure rule definitions for this schema.
*/
{
return ditStructureRulesByNameForm;
}
/**
* Indicates whether this schema definition includes a DIT structure
* rule with the provided rule ID.
*
* @param ruleID The rule ID for which to make the determination.
*
* @return {@code true} if this schema contains a DIT structure
* rule with the provided rule ID, or {@code false} if not.
*/
{
}
/**
* Indicates whether this schema definition includes a DIT structure
* rule for the provided name form.
*
* @param nameForm The name form for which to make the
* determination.
*
* @return {@code true} if this schema contains a DIT structure
* rule for the provided name form, or {@code false} if
* not.
*/
{
}
/**
* Retrieves the DIT structure rule definition with the provided
* rule ID.
*
* @param ruleID The rule ID for the DIT structure rule to
* retrieve.
*
* @return The requested DIT structure rule, or <CODE>null</CODE>
* if no DIT structure rule is registered with the provided
* rule ID.
*/
{
}
/**
* Retrieves the DIT structure rule definition for the provided name
* form.
*
* @param nameForm The name form for the DIT structure rule to
* retrieve.
*
* @return The requested DIT structure rule, or <CODE>null</CODE>
* if no DIT structure rule is registered with the provided
* name form.
*/
{
}
/**
* Registers the provided DIT structure rule definition with this
* schema.
*
* @param ditStructureRule The DIT structure rule to register.
* @param overwriteExisting Indicates whether to overwrite an
* existing mapping if there are any
* conflicts (i.e., another DIT structure
* rule with the same name form).
*
* @throws DirectoryException If a conflict is encountered and the
* <CODE>overwriteExisting</CODE> flag
* is set to <CODE>false</CODE>
*/
public void registerDITStructureRule(
boolean overwriteExisting)
throws DirectoryException
{
synchronized (ditStructureRulesByNameForm)
{
if (! overwriteExisting)
{
{
throw new DirectoryException(
}
{
throw new DirectoryException(
}
}
}
}
/**
* Deregisters the provided DIT structure rule definition with this
* schema.
*
* @param ditStructureRule The DIT structure rule to deregister
* with this schema.
*/
public void deregisterDITStructureRule(
{
synchronized (ditStructureRulesByNameForm)
{
}
}
/**
* Retrieves the name form definitions for this schema, as a mapping
* between the objectclass for the name forms and the name forms
* themselves.
*
* @return The name form definitions for this schema.
*/
{
return nameFormsByOC;
}
/**
* Retrieves the name form definitions for this schema, as a mapping
* Each name form may be present multiple times with different names
* and its OID. The contents of the returned mapping must not be
* altered.
*
* @return The name form definitions for this schema.
*/
{
return nameFormsByName;
}
/**
* Indicates whether this schema definition includes a name form for
* the specified objectclass.
*
* @param objectClass The objectclass for which to make the
* determination.
*
* @return {@code true} if this schema contains a name form for the
* provided objectclass, or {@code false} if not.
*/
{
}
/**
* Indicates whether this schema definition includes a name form
* with the specified name or OID.
*
* @param lowerName The name or OID for which to make the
* determination, formatted in all lowercase
* characters.
*
* @return {@code true} if this schema contains a name form with
* the provided name or OID, or {@code false} if not.
*/
{
}
/**
* Retrieves the name forms definition for the specified
* objectclass.
*
* @param objectClass The objectclass for the name form to
* retrieve.
*
* @return The requested name forms, or <CODE>null</CODE> if no
* name forms are registered with the provided
* objectClass.
*/
{
}
/**
* Retrieves the name form definition with the provided name or OID.
*
* @param lowerName The name or OID of the name form to retrieve,
* formatted in all lowercase characters.
*
* @return The requested name form, or <CODE>null</CODE> if no name
* form is registered with the provided name or OID.
*/
{
}
/**
* Registers the provided name form definition with this schema.
*
* @param nameForm The name form definition to register.
* @param overwriteExisting Indicates whether to overwrite an
* existing mapping if there are any
* conflicts (i.e., another name form
* with the same objectclass).
*
* @throws DirectoryException If a conflict is encountered and the
* <CODE>overwriteExisting</CODE> flag
* is set to <CODE>false</CODE>
*/
boolean overwriteExisting)
throws DirectoryException
{
synchronized (nameFormsByOC)
{
if (! overwriteExisting)
{
if(mappedForms !=null)
{
//Iterate over the forms to make sure we aren't adding a
//duplicate.
{
{
nf.getNameOrOID());
throw new DirectoryException(
}
}
}
{
throw new DirectoryException(
}
{
{
throw new DirectoryException(
}
}
}
if(mappedForms == null)
{
mappedForms = new ArrayList<>();
}
{
}
}
}
/**
* Deregisters the provided name form definition with this schema.
*
* @param nameForm The name form definition to deregister.
*/
{
synchronized (nameFormsByOC)
{
if(mappedForms != null)
{
if(mappedForms.isEmpty())
{
}
}
nameForm);
{
}
}
}
/**
* Retrieves the modification timestamp for the file in the schema
* configuration directory with the oldest last modified time.
*
* @return The modification timestamp for the file in the schema
* configuration directory with the oldest last modified
* time.
*/
public long getOldestModificationTime()
{
return oldestModificationTime;
}
/**
* Sets the modification timestamp for the oldest file in the schema
* configuration directory.
*
* @param oldestModificationTime The modification timestamp for
* the oldest file in the schema
* configuration directory.
*/
{
}
/**
* Retrieves the modification timestamp for the file in the schema
* configuration directory with the youngest last modified time.
*
* @return The modification timestamp for the file in the schema
* configuration directory with the youngest last modified
* time.
*/
public long getYoungestModificationTime()
{
return youngestModificationTime;
}
/**
* Sets the modification timestamp for the youngest file in the
* schema configuration directory.
*
* @param youngestModificationTime The modification timestamp for
* the youngest file in the schema
* configuration directory.
*/
public void setYoungestModificationTime(
long youngestModificationTime)
{
}
/**
* Recursively rebuilds all schema elements that are dependent upon
* the provided element. This must be invoked whenever an existing
* schema element is modified in order to ensure that any elements
* that depend on it should also be recreated to reflect the change.
* <BR><BR>
* The following conditions create dependencies between schema
* elements:
* <UL>
* <LI>If an attribute type references a superior attribute type,
* then it is dependent upon that superior attribute
* type.</LI>
* <LI>If an objectclass requires or allows an attribute type,
* then it is dependent upon that attribute type.</LI>
* <LI>If a name form requires or allows an attribute type in the
* RDN, then it is dependent upon that attribute type.</LI>
* <LI>If a DIT content rule requires, allows, or forbids the use
* of an attribute type, then it is dependent upon that
* attribute type.</LI>
* <LI>If a matching rule use references an attribute type, then
* it is dependent upon that attribute type.</LI>
* <LI>If an objectclass references a superior objectclass, then
* it is dependent upon that superior objectclass.</LI>
* <LI>If a name form references a structural objectclass, then it
* is dependent upon that objectclass.</LI>
* <LI>If a DIT content rule references a structural or auxiliary
* objectclass, then it is dependent upon that
* objectclass.</LI>
* <LI>If a DIT structure rule references a name form, then it is
* dependent upon that name form.</LI>
* <LI>If a DIT structure rule references a superior DIT structure
* rule, then it is dependent upon that superior DIT structure
* rule.</LI>
* </UL>
*
* @param element The element for which to recursively rebuild all
* dependent elements.
*
* @throws DirectoryException If a problem occurs while rebuilding
* any of the schema elements.
*/
throws DirectoryException
{
try
{
}
catch (DirectoryException de)
{
// If we got an error as a result of a circular reference, then
// we want to make sure that the schema element we call out is
// the one that is at the root of the problem.
{
de);
}
// It wasn't a circular reference error, so just re-throw the
// exception.
throw de;
}
}
/**
* Recursively rebuilds all schema elements that are dependent upon
* the provided element, increasing the depth for each level of
* recursion to protect against errors due to circular references.
*
* @param element The element for which to recursively rebuild all
* dependent elements.
* @param depth The current recursion depth.
*
* @throws DirectoryException If a problem occurs while rebuilding
* any of the schema elements.
*/
int depth)
throws DirectoryException
{
if (depth > 20)
{
// FIXME -- Is this an appropriate maximum depth for detecting
// circular references?
}
// Figure out what type of element we're dealing with and make the
// appropriate determinations for that element.
if (element instanceof AttributeType)
{
{
{
registerAttributeType(newAT, true);
}
}
{
{
registerObjectClass(newOC, true);
}
}
{
{
{
registerNameForm(newNF, true);
}
}
}
{
{
registerDITContentRule(newDCR, true);
}
}
{
{
registerMatchingRuleUse(newMRU, true);
}
}
}
else if (element instanceof ObjectClass)
{
{
{
registerObjectClass(newOC, true);
}
}
if(mappedForms != null)
{
{
{
registerNameForm(newNF, true);
}
}
}
{
{
registerDITContentRule(newDCR, true);
}
}
}
{
{
registerDITStructureRule(newDSR, true);
}
}
else if (element instanceof DITStructureRule)
{
{
{
registerDITStructureRule(newDSR, true);
}
}
}
}
throws DirectoryException
{
if (attrType.mayHaveSubordinateTypes())
{
}
return copy;
}
throws DirectoryException
{
return copy;
}
throws DirectoryException
{
return copy;
}
throws DirectoryException
{
return copy;
}
throws DirectoryException
{
return copy;
}
throws DirectoryException
{
return copy;
}
/**
* Creates a new <CODE>Schema</CODE> object that is a duplicate of
* this one. It elements may be added and removed from the
* duplicate without impacting this version.
*
* @return A new <CODE>Schema</CODE> object that is a duplicate of
* this one.
*/
{
if (extraAttributes != null)
{
}
return dupSchema;
}
/**
* Get the extraAttributes stored in this schema.
*
* @return The extraAttributes stored in this schema.
*/
{
return extraAttributes;
}
/**
* Add a new extra Attribute for this schema.
*
* @param name The identifier of the extra Attribute.
*
* @param attr The extra attribute that must be added to
* this Schema.
*/
{
}
/**
* Writes a single file containing all schema element definitions,
* which can be used on startup to determine whether the schema
* files were edited with the server offline.
*/
public static void writeConcatenatedSchema()
{
try
{
{
}
{
}
{
}
{
}
{
}
{
}
{
}
if (concatFile.exists())
{
concatFile.delete();
}
}
catch (Exception e)
{
logger.traceException(e);
// This is definitely not ideal, but it's not the end of the
// world. The worst that should happen is that the schema
// changes could potentially be sent to the other servers again
// when this server is restarted, which shouldn't hurt anything.
// Still, we should log a warning message.
}
}
/**
* Reads the files contained in the schema directory and generates a
* concatenated view of their contents in the provided sets.
*
* @param attributeTypes The set into which to place the
* attribute types read from the schema
* files.
* @param objectClasses The set into which to place the object
* classes read from the schema files.
* @param nameForms The set into which to place the name
* forms read from the schema files.
* @param ditContentRules The set into which to place the DIT
* content rules read from the schema
* files.
* @param ditStructureRules The set into which to place the DIT
* structure rules read from the schema
* files.
* @param matchingRuleUses The set into which to place the
* matching rule uses read from the
* schema files.
* @param ldapSyntaxes The set into which to place the
* ldap syntaxes read from the
* schema files.
*
* @throws IOException If a problem occurs while reading the
* schema file elements.
*/
public static void genConcatenatedSchema(
throws IOException
{
// Get a sorted list of the files in the schema directory.
{
if (f.isFile())
{
schemaFiles.add(f);
}
}
// Open each of the files in order and read the elements that they
// contain, appending them to the appropriate lists.
for (File f : schemaFiles)
{
// Read the contents of the file into a list with one schema
// element per list element.
while (true)
{
{
break;
}
{
continue;
}
{
}
else
{
}
}
// Iterate through each line in the list. Find the colon and
// get the attribute name at the beginning. If it's something
// that we don't recognize, then skip it. Otherwise, add the
// X-SCHEMA-FILE extension and add it to the appropriate schema
// element list.
{
// Get the line and add the X-SCHEMA-FILE extension to the end
// of it. All of them should end with " )" but some might
// have the parenthesis crammed up against the last character
// so deal with that as well.
{
}
{
}
else
{
continue;
}
}
}
}
/**
* Reads data from the specified concatenated schema file into the
* provided sets.
*
* @param concatSchemaFile The path to the concatenated schema
* file to be read.
* @param attributeTypes The set into which to place the
* attribute types read from the
* concatenated schema file.
* @param objectClasses The set into which to place the object
* classes read from the concatenated
* schema file.
* @param nameForms The set into which to place the name
* forms read from the concatenated
* schema file.
* @param ditContentRules The set into which to place the DIT
* content rules read from the
* concatenated schema file.
* @param ditStructureRules The set into which to place the DIT
* structure rules read from the
* concatenated schema file.
* @param matchingRuleUses The set into which to place the
* matching rule uses read from the
* concatenated schema file.
* @param ldapSyntaxes The set into which to place the
* ldap syntaxes read from the
* concatenated schema file.
*
* @throws IOException If a problem occurs while reading the
* schema file elements.
*/
throws IOException
{
while (true)
{
{
break;
}
}
}
/**
* Parse a line of a schema file into the provided sets.
*
* @param line The current line of schema.
* @param attributeTypes The set into which to place the
* attribute type if the line represents
* one.
* @param objectClasses The set into which to place the object
* class if the line represents one.
* @param nameForms The set into which to place the name
* form if the line represents one.
* @param ditContentRules The set into which to place the DIT
* content rule if the line represents one.
* @param ditStructureRules The set into which to place the DIT
* structure rule if the line represents one.
* @param matchingRuleUses The set into which to place the
* matching rule use if the line represents
* one.
* @param ldapSyntaxes The set into which to place the ldap
* syntax if the line represents one.
*/
{
{
value =
}
{
}
{
}
{
}
{
}
{
}
{
}
}
/**
* Compares the provided sets of schema element definitions and
* writes any differences found into the given list of
* modifications.
*
* @param oldElements The set of elements of the specified type
* read from the previous concatenated schema
* files.
* @param newElements The set of elements of the specified type
* read from the server's current schema.
* @param elementType The attribute type associated with the
* schema element being compared.
* @param mods The list of modifications into which any
* identified differences should be written.
*/
public static void compareConcatenatedSchema(
{
for (String s : oldElements)
{
if (!newElements.contains(s))
{
}
}
{
builder.toAttribute()));
}
for (String s : newElements)
{
if (!oldElements.contains(s))
{
}
}
{
builder.toAttribute()));
}
}
/**
* Destroys the structures maintained by the schema so that they are
* no longer usable. This should only be called at the end of the
* server shutdown process, and it can help detect inappropriate
* cached references.
*/
mayInstantiate=false,
mayExtend=false,
mayInvoke=true)
public synchronized void destroy()
{
if (attributeTypes != null)
{
}
if (ditContentRules != null)
{
}
if (ditStructureRulesByID != null)
{
}
if (ditStructureRulesByNameForm != null)
{
}
if (matchingRules != null)
{
}
if (matchingRuleUses != null)
{
}
if (nameFormsByName != null)
{
}
if (nameFormsByOC != null)
{
}
if (objectClasses != null)
{
}
if (subordinateTypes != null)
{
}
if (extraAttributes != null)
{
}
{
}
if(ldapSyntaxDescriptions != null)
{
}
}
}