You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2009/11/07 08:54:52 UTC
svn commit: r833646 - in /directory/shared/branches/shared-schema:
ldap-schema-loader/src/main/java/org/apache/directory/shared/schema/DefaultSchemaManager.java
ldap/src/main/java/org/apache/directory/shared/ldap/schema/SchemaManager.java
Author: elecharny
Date: Sat Nov 7 07:54:52 2009
New Revision: 833646
URL: http://svn.apache.org/viewvc?rev=833646&view=rev
Log:
Added a SchemaManager Interface and the associated class
Modified:
directory/shared/branches/shared-schema/ldap-schema-loader/src/main/java/org/apache/directory/shared/schema/DefaultSchemaManager.java
directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/SchemaManager.java
Modified: directory/shared/branches/shared-schema/ldap-schema-loader/src/main/java/org/apache/directory/shared/schema/DefaultSchemaManager.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap-schema-loader/src/main/java/org/apache/directory/shared/schema/DefaultSchemaManager.java?rev=833646&r1=833645&r2=833646&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap-schema-loader/src/main/java/org/apache/directory/shared/schema/DefaultSchemaManager.java (original)
+++ directory/shared/branches/shared-schema/ldap-schema-loader/src/main/java/org/apache/directory/shared/schema/DefaultSchemaManager.java Sat Nov 7 07:54:52 2009
@@ -21,6 +21,7 @@
import java.util.ArrayList;
import java.util.List;
+import java.util.Map;
import javax.naming.NamingException;
@@ -41,10 +42,36 @@
import org.apache.directory.shared.ldap.schema.Normalizer;
import org.apache.directory.shared.ldap.schema.ObjectClass;
import org.apache.directory.shared.ldap.schema.SchemaManager;
+import org.apache.directory.shared.ldap.schema.SchemaObject;
import org.apache.directory.shared.ldap.schema.SyntaxChecker;
+import org.apache.directory.shared.ldap.schema.normalizers.OidNormalizer;
+import org.apache.directory.shared.ldap.schema.registries.AttributeTypeRegistry;
+import org.apache.directory.shared.ldap.schema.registries.ComparatorRegistry;
+import org.apache.directory.shared.ldap.schema.registries.DITContentRuleRegistry;
+import org.apache.directory.shared.ldap.schema.registries.DITStructureRuleRegistry;
+import org.apache.directory.shared.ldap.schema.registries.ImmutableAttributeTypeRegistry;
+import org.apache.directory.shared.ldap.schema.registries.ImmutableComparatorRegistry;
+import org.apache.directory.shared.ldap.schema.registries.ImmutableDITContentRuleRegistry;
+import org.apache.directory.shared.ldap.schema.registries.ImmutableDITStructureRuleRegistry;
+import org.apache.directory.shared.ldap.schema.registries.ImmutableLdapSyntaxRegistry;
+import org.apache.directory.shared.ldap.schema.registries.ImmutableMatchingRuleRegistry;
+import org.apache.directory.shared.ldap.schema.registries.ImmutableMatchingRuleUseRegistry;
+import org.apache.directory.shared.ldap.schema.registries.ImmutableNameFormRegistry;
+import org.apache.directory.shared.ldap.schema.registries.ImmutableNormalizerRegistry;
+import org.apache.directory.shared.ldap.schema.registries.ImmutableObjectClassRegistry;
+import org.apache.directory.shared.ldap.schema.registries.ImmutableSyntaxCheckerRegistry;
+import org.apache.directory.shared.ldap.schema.registries.LdapSyntaxRegistry;
+import org.apache.directory.shared.ldap.schema.registries.MatchingRuleRegistry;
+import org.apache.directory.shared.ldap.schema.registries.MatchingRuleUseRegistry;
+import org.apache.directory.shared.ldap.schema.registries.NameFormRegistry;
+import org.apache.directory.shared.ldap.schema.registries.NormalizerRegistry;
+import org.apache.directory.shared.ldap.schema.registries.ObjectClassRegistry;
+import org.apache.directory.shared.ldap.schema.registries.OidRegistry;
import org.apache.directory.shared.ldap.schema.registries.Registries;
import org.apache.directory.shared.ldap.schema.registries.Schema;
import org.apache.directory.shared.ldap.schema.registries.SchemaLoader;
+import org.apache.directory.shared.ldap.schema.registries.SyntaxCheckerRegistry;
+import org.apache.directory.shared.ldap.util.StringTools;
import org.apache.directory.shared.schema.loader.ldif.SchemaEntityFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -270,6 +297,7 @@
{
return registries;
}
+
public boolean isDisabledAccepter()
{
@@ -294,7 +322,6 @@
// Swap the registries if it is consistent
return swapRegistries( clonedRegistries );
-
}
@@ -563,7 +590,7 @@
throws Exception
{
LdapComparator<?> comparator =
- factory.getLdapComparator( entry, registries, schema.getSchemaName() );
+ factory.getLdapComparator( this, entry, registries, schema.getSchemaName() );
comparator.setOid( entry.get( MetaSchemaConstants.M_OID_AT ).getString() );
@@ -729,7 +756,7 @@
throws Exception
{
Normalizer normalizer =
- factory.getNormalizer( entry, registries, schema.getSchemaName() );
+ factory.getNormalizer( this, entry, registries, schema.getSchemaName() );
if ( registries.isRelaxed() )
{
@@ -823,7 +850,7 @@
throws Exception
{
SyntaxChecker syntaxChecker =
- factory.getSyntaxChecker( entry, registries, schema.getSchemaName() );
+ factory.getSyntaxChecker( this, entry, registries, schema.getSchemaName() );
syntaxChecker.setOid( entry.get( MetaSchemaConstants.M_OID_AT ).getString() );
if ( registries.isRelaxed() )
@@ -923,16 +950,37 @@
return false;
}
+
+ /**
+ * {@inheritDoc}
+ */
public boolean loadDisabled( Schema... schemas ) throws Exception
{
- // TODO Auto-generated method stub
- return false;
+ // Work on a cloned and relaxed registries
+ Registries clonedRegistries = cloneRegistries();
+
+ // Accept the disabled schemas
+ clonedRegistries.setDisabledAccepted( true );
+
+ // Load the schemas
+ for ( Schema schema : schemas )
+ {
+ // Enable the Schema object before loading it
+ schema.enable();
+ load( clonedRegistries, schema );
+ }
+
+ // Swap the registries if it is consistent
+ return swapRegistries( clonedRegistries );
}
+
+ /**
+ * {@inheritDoc}
+ */
public boolean loadDisabled( String... schemas ) throws Exception
{
- // TODO Auto-generated method stub
- return false;
+ return loadDisabled( toArray( schemas ) );
}
public boolean loadRelaxed( Schema... schemas ) throws Exception
@@ -1122,4 +1170,273 @@
{
return loader;
}
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public AttributeTypeRegistry getAttributeTypeRegistry()
+ {
+ return new ImmutableAttributeTypeRegistry( registries.getAttributeTypeRegistry() );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public ComparatorRegistry getComparatorRegistry()
+ {
+ return new ImmutableComparatorRegistry( registries.getComparatorRegistry() );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public DITContentRuleRegistry getDITContentRuleRegistry()
+ {
+ return new ImmutableDITContentRuleRegistry( registries.getDitContentRuleRegistry() );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public DITStructureRuleRegistry getDITStructureRuleRegistry()
+ {
+ return new ImmutableDITStructureRuleRegistry( registries.getDitStructureRuleRegistry() );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public MatchingRuleRegistry getMatchingRuleRegistry()
+ {
+ return new ImmutableMatchingRuleRegistry( registries.getMatchingRuleRegistry() );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public MatchingRuleUseRegistry getMatchingRuleUseRegistry()
+ {
+ return new ImmutableMatchingRuleUseRegistry( registries.getMatchingRuleUseRegistry() );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public NameFormRegistry getNameFormRegistry()
+ {
+ return new ImmutableNameFormRegistry( registries.getNameFormRegistry() );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public NormalizerRegistry getNormalizerRegistry()
+ {
+ return new ImmutableNormalizerRegistry( registries.getNormalizerRegistry() );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public ObjectClassRegistry getObjectClassRegistry()
+ {
+ return new ImmutableObjectClassRegistry( registries.getObjectClassRegistry() );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public LdapSyntaxRegistry getLdapSyntaxRegistry()
+ {
+ return new ImmutableLdapSyntaxRegistry( registries.getLdapSyntaxRegistry() );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public SyntaxCheckerRegistry getSyntaxCheckerRegistry()
+ {
+ return new ImmutableSyntaxCheckerRegistry( registries.getSyntaxCheckerRegistry() );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public AttributeType lookupAttributeTypeRegistry( String oid ) throws NamingException
+ {
+ return registries.getAttributeTypeRegistry().lookup( StringTools.toLowerCase( oid ).trim() );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public LdapComparator<?> lookupComparatorRegistry( String oid ) throws NamingException
+ {
+ return registries.getComparatorRegistry().lookup( oid );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void register( SchemaObject schemaObject ) throws NamingException
+ {
+ registries.register( schemaObject );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public SchemaObject unregister( SchemaObject schemaObject ) throws NamingException
+ {
+ return registries.unregister( schemaObject );
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Map<String, OidNormalizer> getNormalizerMapping()
+ {
+ return registries.getAttributeTypeRegistry().getNormalizerMapping();
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public OidRegistry getOidRegistry()
+ {
+ return registries.getOidRegistry();
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public Schema getLoadedSchema( String schemaName )
+ {
+ return registries.getLoadedSchema( schemaName );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isSchemaLoaded( String schemaName )
+ {
+ return registries.isSchemaLoaded( schemaName );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public SchemaObject unregisterAttributeType( String attributeTypeOid ) throws NamingException
+ {
+ return registries.getAttributeTypeRegistry().unregister( attributeTypeOid );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public SchemaObject unregisterComparator( String comparatorOid ) throws NamingException
+ {
+ return registries.getComparatorRegistry().unregister( comparatorOid );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public SchemaObject unregisterDitControlRule( String ditControlRuleOid ) throws NamingException
+ {
+ return registries.getDitContentRuleRegistry().unregister( ditControlRuleOid );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public SchemaObject unregisterDitStructureRule( String ditStructureRuleOid ) throws NamingException
+ {
+ return registries.getDitStructureRuleRegistry().unregister( ditStructureRuleOid );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public SchemaObject unregisterLdapSyntax( String ldapSyntaxOid ) throws NamingException
+ {
+ return registries.getLdapSyntaxRegistry().unregister( ldapSyntaxOid );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public SchemaObject unregisterMatchingRule( String matchingRuleOid ) throws NamingException
+ {
+ return registries.getMatchingRuleRegistry().unregister( matchingRuleOid );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public SchemaObject unregisterMatchingRuleUse( String matchingRuleUseOid ) throws NamingException
+ {
+ return registries.getMatchingRuleUseRegistry().unregister( matchingRuleUseOid );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public SchemaObject unregisterNameForm( String nameFormOid ) throws NamingException
+ {
+ return registries.getNameFormRegistry().unregister( nameFormOid );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public SchemaObject unregisterNormalizer( String normalizerOid ) throws NamingException
+ {
+ return registries.getNormalizerRegistry().unregister( normalizerOid );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public SchemaObject unregisterObjectClass( String objectClassOid ) throws NamingException
+ {
+ return registries.getObjectClassRegistry().unregister( objectClassOid );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public SchemaObject unregisterSyntaxChecker( String syntaxCheckerOid ) throws NamingException
+ {
+ return registries.getSyntaxCheckerRegistry().unregister( syntaxCheckerOid );
+ }
}
Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/SchemaManager.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/SchemaManager.java?rev=833646&r1=833645&r2=833646&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/SchemaManager.java (original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/SchemaManager.java Sat Nov 7 07:54:52 2009
@@ -20,11 +20,27 @@
package org.apache.directory.shared.ldap.schema;
import java.util.List;
+import java.util.Map;
+
+import javax.naming.NamingException;
import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.shared.ldap.schema.normalizers.OidNormalizer;
+import org.apache.directory.shared.ldap.schema.registries.AttributeTypeRegistry;
+import org.apache.directory.shared.ldap.schema.registries.ComparatorRegistry;
+import org.apache.directory.shared.ldap.schema.registries.DITContentRuleRegistry;
+import org.apache.directory.shared.ldap.schema.registries.DITStructureRuleRegistry;
+import org.apache.directory.shared.ldap.schema.registries.LdapSyntaxRegistry;
+import org.apache.directory.shared.ldap.schema.registries.MatchingRuleRegistry;
+import org.apache.directory.shared.ldap.schema.registries.MatchingRuleUseRegistry;
+import org.apache.directory.shared.ldap.schema.registries.NameFormRegistry;
+import org.apache.directory.shared.ldap.schema.registries.NormalizerRegistry;
+import org.apache.directory.shared.ldap.schema.registries.ObjectClassRegistry;
+import org.apache.directory.shared.ldap.schema.registries.OidRegistry;
import org.apache.directory.shared.ldap.schema.registries.Registries;
import org.apache.directory.shared.ldap.schema.registries.Schema;
import org.apache.directory.shared.ldap.schema.registries.SchemaLoader;
+import org.apache.directory.shared.ldap.schema.registries.SyntaxCheckerRegistry;
/**
* A class used to manage access to the Schemas and Registries. It's associated
@@ -271,6 +287,124 @@
* @return The Registries
*/
Registries getRegistries();
+
+
+ /**
+ * Lookup for an AttributeType in the AttributeType registry
+ *
+ * @param String oid the OID we are looking for
+ * @return The found AttributeType
+ * @throws NamingException if the OID is not found in the AttributeType registry
+ */
+ AttributeType lookupAttributeTypeRegistry( String oid ) throws NamingException;
+
+
+ /**
+ * Lookup for a Comparator in the Comparator registry
+ *
+ * @param String oid the OID we are looking for
+ * @return The found Comparator
+ * @throws NamingException if the OID is not found in the Comparator registry
+ */
+ LdapComparator<?> lookupComparatorRegistry( String oid ) throws NamingException;
+
+
+ /**
+ * Get an immutable reference on the AttributeType registry
+ *
+ * @return A reference to the AttributeType registry.
+ */
+ AttributeTypeRegistry getAttributeTypeRegistry();
+
+
+ /**
+ * Get an immutable reference on the Comparator registry
+ *
+ * @return A reference to the Comparator registry.
+ */
+ ComparatorRegistry getComparatorRegistry();
+
+
+ /**
+ * Get an immutable reference on the DITContentRule registry
+ *
+ * @return A reference to the DITContentRule registry.
+ */
+ DITContentRuleRegistry getDITContentRuleRegistry();
+
+
+ /**
+ * Get an immutable reference on the DITStructureRule registry
+ *
+ * @return A reference to the DITStructureRule registry.
+ */
+ DITStructureRuleRegistry getDITStructureRuleRegistry();
+
+
+ /**
+ * Get an immutable reference on the MatchingRule registry
+ *
+ * @return A reference to the MatchingRule registry.
+ */
+ MatchingRuleRegistry getMatchingRuleRegistry();
+
+
+ /**
+ * Get an immutable reference on the MatchingRuleUse registry
+ *
+ * @return A reference to the MatchingRuleUse registry.
+ */
+ MatchingRuleUseRegistry getMatchingRuleUseRegistry();
+
+
+ /**
+ * Get an immutable reference on the Normalizer registry
+ *
+ * @return A reference to the Normalizer registry.
+ */
+ NormalizerRegistry getNormalizerRegistry();
+
+
+ /**
+ * Get an immutable reference on the NameForm registry
+ *
+ * @return A reference to the NameForm registry.
+ */
+ NameFormRegistry getNameFormRegistry();
+
+
+ /**
+ * Get an immutable reference on the ObjectClass registry
+ *
+ * @return A reference to the ObjectClass registry.
+ */
+ ObjectClassRegistry getObjectClassRegistry();
+
+
+ /**
+ * Get an immutable reference on the LdapSyntax registry
+ *
+ * @return A reference to the LdapSyntax registry.
+ */
+ LdapSyntaxRegistry getLdapSyntaxRegistry();
+
+
+ /**
+ * Get an immutable reference on the SyntaxChecker registry
+ *
+ * @return A reference to the SyntaxChecker registry.
+ */
+ SyntaxCheckerRegistry getSyntaxCheckerRegistry();
+
+
+ /**
+ * Get an immutable reference on the Normalizer mapping
+ *
+ * @return A reference to the Normalizer mapping
+ */
+ Map<String, OidNormalizer> getNormalizerMapping();
+
+
void setRegistries( Registries registries );
@@ -301,4 +435,148 @@
* @return The used loader
*/
SchemaLoader getLoader();
+
+
+ /**
+ * Registers a new SchemaObject.
+ *
+ * @param schemaObject the SchemaObject to register
+ * @throws NamingException if the SchemaObject is already registered or
+ * the registration operation is not supported
+ */
+ void register( SchemaObject schemaObject ) throws NamingException;
+
+
+ /**
+ * Removes the registered SchemaObject from the registries
+ *
+ * @param schemaObject the schemaObject to unregister
+ * @throws NamingException if the schemaObject is invalid
+ */
+ SchemaObject unregister( SchemaObject schemaObject ) throws NamingException;
+
+
+ /**
+ * Removes the registered attributeType from the attributeTypeRegistry
+ *
+ * @param String the attributeType OID to unregister
+ * @throws NamingException if the attributeType is invalid
+ */
+ SchemaObject unregisterAttributeType( String attributeTypeOid ) throws NamingException;
+
+
+ /**
+ * Removes the registered Comparator from the ComparatorRegistry
+ *
+ * @param String the Comparator OID to unregister
+ * @throws NamingException if the Comparator is invalid
+ */
+ SchemaObject unregisterComparator( String comparatorOid ) throws NamingException;
+
+
+ /**
+ * Removes the registered DitControlRule from the DitControlRuleRegistry
+ *
+ * @param String the DitControlRule OID to unregister
+ * @throws NamingException if the DitControlRule is invalid
+ */
+ SchemaObject unregisterDitControlRule( String ditControlRuleOid ) throws NamingException;
+
+
+ /**
+ * Removes the registered DitStructureRule from the DitStructureRuleRegistry
+ *
+ * @param String the DitStructureRule OID to unregister
+ * @throws NamingException if the DitStructureRule is invalid
+ */
+ SchemaObject unregisterDitStructureRule( String ditStructureRuleOid ) throws NamingException;
+
+
+ /**
+ * Removes the registered MatchingRule from the MatchingRuleRegistry
+ *
+ * @param String the MatchingRuleRule OID to unregister
+ * @throws NamingException if the MatchingRule is invalid
+ */
+ SchemaObject unregisterMatchingRule( String matchingRuleOid ) throws NamingException;
+
+
+ /**
+ * Removes the registered MatchingRuleUse from the MatchingRuleUseRegistry
+ *
+ * @param String the MatchingRuleUse OID to unregister
+ * @throws NamingException if the MatchingRuleUse is invalid
+ */
+ SchemaObject unregisterMatchingRuleUse( String matchingRuleUseOid ) throws NamingException;
+
+
+ /**
+ * Removes the registered NameForm from the NameFormRegistry
+ *
+ * @param String the NameForm OID to unregister
+ * @throws NamingException if the NameForm is invalid
+ */
+ SchemaObject unregisterNameForm( String nameFormOid ) throws NamingException;
+
+
+ /**
+ * Removes the registered Normalizer from the NormalizerRegistry
+ *
+ * @param String the Normalizer OID to unregister
+ * @throws NamingException if the Normalizer is invalid
+ */
+ SchemaObject unregisterNormalizer( String normalizerOid ) throws NamingException;
+
+
+ /**
+ * Removes the registered ObjectClass from the ObjectClassRegistry
+ *
+ * @param String the ObjectClass OID to unregister
+ * @throws NamingException if the ObjectClass is invalid
+ */
+ SchemaObject unregisterObjectClass( String objectClassOid ) throws NamingException;
+
+
+ /**
+ * Removes the registered LdapSyntax from the LdapSyntaxRegistry
+ *
+ * @param String the LdapSyntax OID to unregister
+ * @throws NamingException if the LdapSyntax is invalid
+ */
+ SchemaObject unregisterLdapSyntax( String ldapSyntaxOid ) throws NamingException;
+
+
+ /**
+ * Removes the registered SyntaxChecker from the SyntaxCheckerRegistry
+ *
+ * @param String the SyntaxChecker OID to unregister
+ * @throws NamingException if the SyntaxChecker is invalid
+ */
+ SchemaObject unregisterSyntaxChecker( String syntaxCheckerOid ) throws NamingException;
+
+
+ /**
+ * Returns a reference to the OidRegistry
+ *
+ * @return The OidRegistry
+ */
+ OidRegistry getOidRegistry();
+
+
+ /**
+ * Gets a schema that has been loaded into these Registries.
+ *
+ * @param schemaName the name of the schema to lookup
+ * @return the loaded Schema if one corresponding to the name exists
+ */
+ Schema getLoadedSchema( String schemaName );
+
+
+ /**
+ * Tells if the specific schema is loaded
+ *
+ * @param schemaName The schema we want to check
+ * @return true if the schema is laoded
+ */
+ boolean isSchemaLoaded( String schemaName );
}