public final class SchemaHandler extends Object
The schema handler initializes the schema in four steps :
The schema handler provides read and write access to the schema.
As schema is immutable, there is no risk to alter it outside this handler. However, no long-lived reference should be kept on the schema because further schema updates would be missed. It is advised to retrieve the server's schema from the handler for any operation.
The server's schema can be updated using one of the updateSchema()
method.
Modifier and Type | Class and Description |
---|---|
static interface |
SchemaHandler.SchemaUpdater
Interface to update a schema provided a schema builder.
|
Constructor and Description |
---|
SchemaHandler()
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
static void |
addServerSyntaxesAndMatchingRules(org.forgerock.opendj.ldap.schema.SchemaBuilder schemaBuilder)
Adds server's specific syntaxes and matching rules not provided by the SDK to the provided schema
builder.
|
void |
destroy()
Destroys the structures maintained by this handler so that they are no longer usable.
|
void |
detectChangesOnInitialization()
Detects offline schema changes by comparing schema files and concatenated schema.
|
void |
exclusiveLock()
Takes an exclusive lock on the schema.
|
void |
exclusiveUnlock()
Releases an exclusive lock on the schema.
|
Map<String,Attribute> |
getExtraAttributes()
Returns the mapping (oid, attribute) for extra attributes stored in this schema handler.
|
List<Modification> |
getOfflineSchemaModifications()
Returns the list of offline modifications made to the schema, which is built once when
initializing the schema.
|
long |
getOldestModificationTime()
Returns the oldest modification time for schema files.
|
org.forgerock.opendj.ldap.schema.Schema |
getSchema()
Returns the schema.
|
File |
getSchemaDirectoryPath()
Retrieves the path to the directory containing the server schema files.
|
long |
getYoungestModificationTime()
Returns the youngest modification time for schema files.
|
void |
importEntry(Entry newSchemaEntry,
AlertGenerator alertGenerator)
Imports the provided schema entry in the schema.
|
void |
initialize(ServerContext serverContext)
Initializes this schema handler.
|
static boolean |
isSchemaAttribute(String attrOid)
Checks if a given attribute oid corresponds to an attribute that is used by the definition of the schema.
|
void |
loadSchemaFileIntoSchemaBuilder(File schemaFile,
org.forgerock.opendj.ldap.schema.SchemaBuilder schemaBuilder,
org.forgerock.opendj.ldap.schema.Schema readSchema)
Loads the contents of the provided schema file into the provided schema builder.
|
List<Modification> |
loadSchemaFileIntoSchemaBuilderAndReturnModifications(File schemaFile,
org.forgerock.opendj.ldap.schema.SchemaBuilder schemaBuilder,
org.forgerock.opendj.ldap.schema.Schema readSchema)
Loads the contents of the provided schema file into the provided schema builder and returns the list
of modifications.
|
void |
updateSchema(org.forgerock.opendj.ldap.schema.Schema schema)
Replaces the schema with the provided schema.
|
void |
updateSchema(SchemaHandler.SchemaUpdater updater)
Updates the schema using the provided schema updater.
|
void |
updateSchemaAndConcatenatedSchemaFile(org.forgerock.opendj.ldap.schema.Schema newSchema)
Replaces the schema with the provided schema and update the concatenated schema file.
|
void |
updateSchemaAndSchemaFiles(org.forgerock.opendj.ldap.schema.Schema newSchema,
Map<String,Attribute> newExtraAttributes,
TreeSet<String> modifiedSchemaFileNames,
AlertGenerator alertGenerator)
Replaces the schema with the provided schema and updates the provided set of schema files.
|
<T> void |
updateSchemaOption(org.forgerock.util.Option<T> option,
T newValue)
Updates the schema option if the new value differs from the old value.
|
public SchemaHandler()
public long getYoungestModificationTime()
public long getOldestModificationTime()
public void initialize(ServerContext serverContext) throws InitializationException, org.forgerock.opendj.config.server.ConfigException
serverContext
- The server context.org.forgerock.opendj.config.server.ConfigException
- If a configuration problem arises in the process of performing
the initialization.InitializationException
- If a problem that is not configuration-related occurs during
initialization.public static void addServerSyntaxesAndMatchingRules(org.forgerock.opendj.ldap.schema.SchemaBuilder schemaBuilder) throws org.forgerock.opendj.config.server.ConfigException
schemaBuilder
- The schema builderorg.forgerock.opendj.config.server.ConfigException
- If there is a schema conflict for the added elementspublic void detectChangesOnInitialization() throws InitializationException
Updates the concatenated schema if changes are detected.
InitializationException
- If an error occurs while updating the concatenated schemapublic org.forgerock.opendj.ldap.schema.Schema getSchema()
public File getSchemaDirectoryPath() throws InitializationException
InitializationException
- If the directory path does not exists or is not a directorypublic List<Modification> getOfflineSchemaModifications()
public void updateSchema(SchemaHandler.SchemaUpdater updater) throws DirectoryException
The schema files are not updated.
updater
- the updater that performs modifications on the schema builderDirectoryException
- if there is any problem updating the schemapublic void updateSchema(org.forgerock.opendj.ldap.schema.Schema schema) throws DirectoryException
The schema files are not updated.
schema
- the new schema to useDirectoryException
- if the provided schema contains warningspublic void updateSchemaAndSchemaFiles(org.forgerock.opendj.ldap.schema.Schema newSchema, Map<String,Attribute> newExtraAttributes, TreeSet<String> modifiedSchemaFileNames, AlertGenerator alertGenerator) throws DirectoryException
The concatenated schema file is updated as well.
newSchema
- The new schema to usenewExtraAttributes
- The new map of extra attributesmodifiedSchemaFileNames
- The set of names of schema files that need to be updatedalertGenerator
- The generator to use for alertsDirectoryException
- If an error occurs during update of schema or schema filespublic void updateSchemaAndConcatenatedSchemaFile(org.forgerock.opendj.ldap.schema.Schema newSchema) throws DirectoryException
newSchema
- The new schema to useDirectoryException
- If an error occurs during update of schema or schema filespublic <T> void updateSchemaOption(org.forgerock.util.Option<T> option, T newValue) throws DirectoryException
T
- the schema option's typeoption
- the schema option to updatenewValue
- the new value for the schema optionDirectoryException
- if there is any problem updating the schemapublic Map<String,Attribute> getExtraAttributes()
public void exclusiveLock()
public void exclusiveUnlock()
public void destroy()
This should only be called at the end of the server shutdown process, and it can help detect inappropriate cached references.
public void importEntry(Entry newSchemaEntry, AlertGenerator alertGenerator) throws DirectoryException
The behavior is:
FIXME: currently, attributeTypes and objectClasses are the only elements taken into account.
newSchemaEntry
- The schema entry to be imported.alertGenerator
- Alert generator to use.DirectoryException
- If an error occurs during the importpublic void loadSchemaFileIntoSchemaBuilder(File schemaFile, org.forgerock.opendj.ldap.schema.SchemaBuilder schemaBuilder, org.forgerock.opendj.ldap.schema.Schema readSchema) throws InitializationException, org.forgerock.opendj.config.server.ConfigException
This method has no effect on the current schema.
schemaFile
- The schema file to load.schemaBuilder
- The schema builder to update.readSchema
- The schema used to read the schema file.InitializationException
- If a problem occurs when reading the schema file.org.forgerock.opendj.config.server.ConfigException
- If a problem occurs when updating the schema builder.public List<Modification> loadSchemaFileIntoSchemaBuilderAndReturnModifications(File schemaFile, org.forgerock.opendj.ldap.schema.SchemaBuilder schemaBuilder, org.forgerock.opendj.ldap.schema.Schema readSchema) throws InitializationException, org.forgerock.opendj.config.server.ConfigException
This method has no effect on the current schema.
schemaFile
- The schema file to load.schemaBuilder
- The schema builder to update.readSchema
- The schema used to read the schema file.org.forgerock.opendj.config.server.ConfigException
- If a configuration problem causes the schema element initialization to fail.InitializationException
- If a problem occurs while initializing the schema elements that is not related to the
server configuration.public static boolean isSchemaAttribute(String attrOid)
attribute
- The oid of the attribute to be checked.true
if the attribute is part of the schema definition, false otherwiseCopyright © 2010-2017 ForgeRock AS. All Rights Reserved.