org.apache.directory.server.core.schema
Class SchemaPartitionDao

java.lang.Object
  extended by org.apache.directory.server.core.schema.SchemaPartitionDao

public class SchemaPartitionDao
extends java.lang.Object

A specialized data access object for managing schema objects in the schema partition. WARNING: This dao operates directly on a partition. Hence no interceptors are available to perform the various expected services of respective interceptors. Take care to normalize all filters and distinguished names. A single write operation exists for enabling schemas needed for operating indices in partitions and enabling schemas that are dependencies of other schemas that are enabled. In both these limited cases there is no need to worry about issues with a lack of replication propagation because these same updates will take place on replicas when the original operation is propagated or when replicas start up.

Version:
$Rev$
Author:
Apache Directory Project

Constructor Summary
SchemaPartitionDao(Partition partition, Registries registries)
          Creates a schema dao object backing information within a schema partition.
 
Method Summary
 void enableSchema(java.lang.String schemaName)
          Enables a schema by removing it's m-disabled attribute if present.
 ServerEntry find(java.lang.String entityName)
          Given the non-normalized name (alias) or the OID for a schema entity.
 org.apache.directory.shared.ldap.name.LdapDN findDn(java.lang.String entityName)
           
 java.lang.String findSchema(java.lang.String entityName)
          Given the non-normalized name (alias) or the OID for a schema entity.
 Schema getSchema(java.lang.String schemaName)
           
 java.util.Set<java.lang.String> getSchemaNames()
           
 java.util.Map<java.lang.String,Schema> getSchemas()
           
 boolean hasAttributeType(java.lang.String oid)
           
 boolean hasMatchingRule(java.lang.String oid)
           
 boolean hasObjectClass(java.lang.String oid)
           
 boolean hasSyntax(java.lang.String oid)
           
 boolean hasSyntaxChecker(java.lang.String oid)
           
 EntryFilteringCursor listAllNames()
           
 java.util.Set<ServerEntry> listAttributeTypeDependents(org.apache.directory.shared.ldap.schema.AttributeType at)
           
 java.util.Set<ServerEntry> listEnabledSchemaDependents(java.lang.String schemaName)
          Lists the SearchResults of metaSchema objects that depend on a schema.
 java.util.Set<ServerEntry> listMatchingRuleDependents(org.apache.directory.shared.ldap.schema.MatchingRule mr)
           
 java.util.Set<ServerEntry> listObjectClassDependents(org.apache.directory.shared.ldap.schema.ObjectClass oc)
           
 java.util.Set<ServerEntry> listSchemaDependents(java.lang.String schemaName)
          Lists the SearchResults of metaSchema objects that depend on a schema.
 java.util.Set<ServerEntry> listSyntaxDependents(java.lang.String numericOid)
          Returns the set of matchingRules and attributeTypes which depend on the provided syntax.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SchemaPartitionDao

public SchemaPartitionDao(Partition partition,
                          Registries registries)
                   throws java.lang.Exception
Creates a schema dao object backing information within a schema partition.

Parameters:
partition - the schema partition
registries - the bootstrap registries that were used to start up the schema partition
Throws:
javax.naming.NamingException - if there are problems initializing this schema partion dao
java.lang.Exception
Method Detail

getSchemas

public java.util.Map<java.lang.String,Schema> getSchemas()
                                                  throws java.lang.Exception
Throws:
java.lang.Exception

getSchemaNames

public java.util.Set<java.lang.String> getSchemaNames()
                                               throws java.lang.Exception
Throws:
java.lang.Exception

getSchema

public Schema getSchema(java.lang.String schemaName)
                 throws java.lang.Exception
Throws:
java.lang.Exception

hasMatchingRule

public boolean hasMatchingRule(java.lang.String oid)
                        throws java.lang.Exception
Throws:
java.lang.Exception

hasAttributeType

public boolean hasAttributeType(java.lang.String oid)
                         throws java.lang.Exception
Throws:
java.lang.Exception

hasObjectClass

public boolean hasObjectClass(java.lang.String oid)
                       throws java.lang.Exception
Throws:
java.lang.Exception

hasSyntax

public boolean hasSyntax(java.lang.String oid)
                  throws java.lang.Exception
Throws:
java.lang.Exception

hasSyntaxChecker

public boolean hasSyntaxChecker(java.lang.String oid)
                         throws java.lang.Exception
Throws:
java.lang.Exception

findSchema

public java.lang.String findSchema(java.lang.String entityName)
                            throws java.lang.Exception
Given the non-normalized name (alias) or the OID for a schema entity. This method finds the schema under which that entity is located. NOTE: this method presumes that all alias names across schemas are unique. This should be the case for LDAP but this can potentially be violated so we should make sure this is a unique name.

Parameters:
entityName - one of the names of the entity or it's numeric id
Returns:
the name of the schema that contains that entity or null if no entity with that alias name exists
Throws:
javax.naming.NamingException - if more than one entity has the name, or if there are underlying data access problems
java.lang.Exception

findDn

public org.apache.directory.shared.ldap.name.LdapDN findDn(java.lang.String entityName)
                                                    throws java.lang.Exception
Throws:
java.lang.Exception

find

public ServerEntry find(java.lang.String entityName)
                 throws java.lang.Exception
Given the non-normalized name (alias) or the OID for a schema entity. This method finds the entry of the schema entity. NOTE: this method presumes that all alias names across schemas are unique. This should be the case for LDAP but this can potentially be violated so we should make sure this is a unique name.

Parameters:
entityName - one of the names of the entity or it's numeric id
Returns:
the search result for the entity or null if no such entity exists with that alias or numeric oid
Throws:
javax.naming.NamingException - if more than one entity has the name, or if there are underlying data access problems
java.lang.Exception

enableSchema

public void enableSchema(java.lang.String schemaName)
                  throws java.lang.Exception
Enables a schema by removing it's m-disabled attribute if present. NOTE: This is a write operation and great care must be taken to make sure it is used in a limited capacity. This method is called in two places currently. (1) Within the initialization sequence to enable schemas required for the correct operation of indices in other partitions. (2) Within the partition schema loader to auto enable schemas that are depended on by other schemas which are enabled. In both cases, the modifier is effectively the administrator since the server is performing the operation directly or on behalf of a user. In case (1) during intialization there is no other user involved so naturally the modifier is the administrator. In case (2) when a user enables a schema with a dependency that is not enabled the server enables that dependency on behalf of the user. Again effectively it is the server that is modifying the schema entry and hence the admin is the modifier. No need to worry about a lack of replication propagation in both cases. In case (1) all replicas will enable these schemas anyway on startup. In case (2) the original operation that enabled the schema depending on the on that enableSchema() is called for itself will be replicated. Hence the same chain reaction will occur in a replica.

Parameters:
schemaName - the name of the schema to enable
Throws:
javax.naming.NamingException - if there is a problem updating the schema entry
java.lang.Exception

listSyntaxDependents

public java.util.Set<ServerEntry> listSyntaxDependents(java.lang.String numericOid)
                                                throws java.lang.Exception
Returns the set of matchingRules and attributeTypes which depend on the provided syntax.

Parameters:
numericOid - the numeric identifier for the entity
Returns:
the set of matchingRules and attributeTypes depending on a syntax
Throws:
javax.naming.NamingException - if the dao fails to perform search operations
java.lang.Exception

listMatchingRuleDependents

public java.util.Set<ServerEntry> listMatchingRuleDependents(org.apache.directory.shared.ldap.schema.MatchingRule mr)
                                                      throws java.lang.Exception
Throws:
java.lang.Exception

listAllNames

public EntryFilteringCursor listAllNames()
                                  throws java.lang.Exception
Throws:
java.lang.Exception

listAttributeTypeDependents

public java.util.Set<ServerEntry> listAttributeTypeDependents(org.apache.directory.shared.ldap.schema.AttributeType at)
                                                       throws java.lang.Exception
Throws:
java.lang.Exception

listSchemaDependents

public java.util.Set<ServerEntry> listSchemaDependents(java.lang.String schemaName)
                                                throws java.lang.Exception
Lists the SearchResults of metaSchema objects that depend on a schema.

Parameters:
schemaName - the name of the schema to search for dependees
Returns:
a set of SearchResults over the schemas whose m-dependency attribute contains schemaName
Throws:
javax.naming.NamingException - if there is a problem while searching the schema partition
java.lang.Exception

listEnabledSchemaDependents

public java.util.Set<ServerEntry> listEnabledSchemaDependents(java.lang.String schemaName)
                                                       throws java.lang.Exception
Lists the SearchResults of metaSchema objects that depend on a schema.

Parameters:
schemaName - the name of the schema to search for dependencies
Returns:
a set of SearchResults over the schemas whose m-dependency attribute contains schemaName
Throws:
javax.naming.NamingException - if there is a problem while searching the schema partition
java.lang.Exception

listObjectClassDependents

public java.util.Set<ServerEntry> listObjectClassDependents(org.apache.directory.shared.ldap.schema.ObjectClass oc)
                                                     throws java.lang.Exception
Throws:
java.lang.Exception


Copyright © 2003-2009 Apache Software Foundation. All Rights Reserved.