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/10/09 02:03:51 UTC
svn commit: r823360 [1/6] - in /directory:
apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/
apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/syn...
Author: elecharny
Date: Fri Oct 9 00:03:45 2009
New Revision: 823360
URL: http://svn.apache.org/viewvc?rev=823360&view=rev
Log:
Many fixes and improvements in the way we handle Schema
Added:
directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/schema/AbstractMetaSchemaObjectHandlerIT.java
directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaObjectClassHandlerIT.java
- copied, changed from r822146, directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaObjectClassHandlerIT.java
Removed:
directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntaxCheckers/AcceptAllSyntaxChecker.java
Modified:
directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/PartitionSchemaLoader.java
directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/SchemaPartition.java
directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/SchemaPartitionDaoImpl.java
directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/AbstractRegistrySynchronizer.java
directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/AttributeTypeSynchronizer.java
directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/ComparatorSynchronizer.java
directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/DitContentRuleSynchronizer.java
directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/DitStructureRuleSynchronizer.java
directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/MatchingRuleSynchronizer.java
directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/MatchingRuleUseSynchronizer.java
directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/NameFormSynchronizer.java
directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/NormalizerSynchronizer.java
directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/ObjectClassSynchronizer.java
directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/RegistrySynchronizer.java
directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/RegistrySynchronizerAdaptor.java
directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/SchemaSynchronizer.java
directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/SyntaxCheckerSynchronizer.java
directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/SyntaxSynchronizer.java
directory/apacheds/branches/apacheds-schema/core-constants/src/main/java/org/apache/directory/server/constants/ServerDNConstants.java
directory/apacheds/branches/apacheds-schema/core-entry/src/test/java/org/apache/directory/server/core/entry/DefaultServerAttributeTest.java
directory/apacheds/branches/apacheds-schema/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerBinaryValueTest.java
directory/apacheds/branches/apacheds-schema/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerStringValueTest.java
directory/apacheds/branches/apacheds-schema/core-integ/src/main/java/org/apache/directory/server/core/integ/IntegrationUtils.java
directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/operational/OperationalAttributeServiceIT.java
directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/operations/compare/CompareDirserver1139IT.java
directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaAttributeTypeHandlerIT.java
directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaComparatorHandlerIT.java
directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaMatchingRuleHandlerIT.java
directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaNormalizerHandlerIT.java
directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaSchemaHandlerIT.java
directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaSyntaxCheckerHandlerIT.java
directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaSyntaxHandlerIT.java
directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/schema/SubschemaSubentryIT.java
directory/apacheds/branches/apacheds-schema/core-jndi/src/main/java/org/apache/directory/server/core/jndi/ServerDirContext.java
directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/changelog/ChangeLogInterceptor.java
directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/exception/ExceptionInterceptor.java
directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/operational/OperationalAttributeInterceptor.java
directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/schema/SchemaInterceptor.java
directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/schema/SchemaSubentryModifier.java
directory/apacheds/branches/apacheds-schema/core/src/test/java/org/apache/directory/server/core/schema/SchemaServiceTest.java
directory/apacheds/branches/apacheds-schema/ldap-api-test/src/test/java/org/apache/directory/shared/client/api/unit/AbstractServerTest.java
directory/apacheds/branches/apacheds-schema/server-unit/src/main/java/org/apache/directory/server/unit/AbstractServerTest.java
directory/apacheds/branches/apacheds-schema/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/BogusSyntax.java
directory/apacheds/branches/apacheds-schema/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/GreaterEqTest.java
directory/apacheds/branches/apacheds-schema/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/LessEqTest.java
directory/shared/branches/shared-schema/ldap-constants/src/main/java/org/apache/directory/shared/ldap/constants/MetaSchemaConstants.java
directory/shared/branches/shared-schema/ldap-constants/src/main/java/org/apache/directory/shared/ldap/constants/SchemaConstants.java
directory/shared/branches/shared-schema/ldap-convert/src/main/java/org/apache/directory/shared/converter/schema/AttributeTypeHolder.java
directory/shared/branches/shared-schema/ldap-convert/src/main/java/org/apache/directory/shared/converter/schema/ObjectClassHolder.java
directory/shared/branches/shared-schema/ldap-schema-loader/src/main/java/org/apache/directory/shared/schema/loader/ldif/JarLdifSchemaLoader.java
directory/shared/branches/shared-schema/ldap-schema-loader/src/main/java/org/apache/directory/shared/schema/loader/ldif/LdifSchemaLoader.java
directory/shared/branches/shared-schema/ldap-schema-loader/src/main/java/org/apache/directory/shared/schema/loader/ldif/SchemaEntityFactory.java
directory/shared/branches/shared-schema/ldap-schema/src/main/resources/schema/ou=schema/cn=nis/ou=syntaxcheckers/m-oid=1.3.6.1.1.1.0.0.ldif
directory/shared/branches/shared-schema/ldap-schema/src/main/resources/schema/ou=schema/cn=nis/ou=syntaxcheckers/m-oid=1.3.6.1.1.1.0.1.ldif
directory/shared/branches/shared-schema/ldap-schema/src/main/resources/schema/ou=schema/cn=system/ou=syntaxcheckers/m-oid=1.3.6.1.4.1.1466.115.121.1.55.ldif
directory/shared/branches/shared-schema/ldap-schema/src/main/resources/schema/ou=schema/cn=system/ou=syntaxcheckers/m-oid=1.3.6.1.4.1.1466.115.121.1.56.ldif
directory/shared/branches/shared-schema/ldap-schema/src/main/resources/schema/ou=schema/cn=system/ou=syntaxcheckers/m-oid=1.3.6.1.4.1.1466.115.121.1.57.ldif
directory/shared/branches/shared-schema/ldap-schema/src/main/resources/schema/ou=schema/cn=system/ou=syntaxcheckers/m-oid=1.3.6.1.4.1.1466.115.121.1.59.ldif
directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/AttributeType.java
directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/LdapSyntax.java
directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/MatchingRule.java
directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/Normalizer.java
directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/ObjectClass.java
directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/SchemaObject.java
directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/SchemaObjectType.java
directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparators/DnComparator.java
directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/CachingDeepTrimNormalizer.java
directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/CachingDeepTrimToLowerNormalizer.java
directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/CachingDnNormalizer.java
directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/CachingNormalizer.java
directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/DnNormalizer.java
directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/NameAndOptionalUIDNormalizer.java
directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/NameOrNumericIdNormalizer.java
directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/AttributeTypeRegistry.java
directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/Registries.java
directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/SchemaObjectRegistry.java
directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/SyntaxCheckerRegistry.java
directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntaxCheckers/OctetStringSyntaxChecker.java
directory/shared/branches/shared-schema/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/OctetStringSyntaxCheckerTest.java
directory/shared/branches/shared-schema/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/SyntaxCheckerDescriptionSchemaParserTest.java
Modified: directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/PartitionSchemaLoader.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/PartitionSchemaLoader.java?rev=823360&r1=823359&r2=823360&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/PartitionSchemaLoader.java (original)
+++ directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/PartitionSchemaLoader.java Fri Oct 9 00:03:45 2009
@@ -131,37 +131,65 @@
{
// Initialize AttributeType Dns
- LdapDN dn = new LdapDN( "ou=attributetypes,cn=" + schemaName + ",ou=schema" );
+ LdapDN dn = new LdapDN(
+ SchemaConstants.ATTRIBUTES_TYPE_PATH,
+ "cn=" + schemaName,
+ SchemaConstants.OU_SCHEMA );
+
dn.normalize( atRegistry.getNormalizerMapping() );
staticAttributeTypeDNs.put( schemaName, dn );
// Initialize ObjectClasses Dns
- dn = new LdapDN( "ou=objectclasses,cn=" + schemaName + ",ou=schema" );
+ dn = new LdapDN(
+ SchemaConstants.OBJECT_CLASSES_PATH,
+ "cn=" + schemaName,
+ SchemaConstants.OU_SCHEMA );
+
dn.normalize( atRegistry.getNormalizerMapping() );
staticObjectClassesDNs.put( schemaName, dn );
// Initialize MatchingRules Dns
- dn = new LdapDN( "ou=matchingrules,cn=" + schemaName + ",ou=schema" );
+ dn = new LdapDN(
+ SchemaConstants.MATCHING_RULES_PATH,
+ "cn=" + schemaName,
+ SchemaConstants.OU_SCHEMA );
+
dn.normalize( atRegistry.getNormalizerMapping() );
staticMatchingRulesDNs.put( schemaName, dn );
// Initialize Comparators Dns
- dn = new LdapDN( "ou=comparators,cn=" + schemaName + ",ou=schema" );
+ dn = new LdapDN(
+ SchemaConstants.COMPARATORS_PATH,
+ "cn=" + schemaName,
+ SchemaConstants.OU_SCHEMA );
+
dn.normalize( atRegistry.getNormalizerMapping() );
staticComparatorsDNs.put( schemaName, dn );
// Initialize Normalizers Dns
- dn = new LdapDN( "ou=normalizers,cn=" + schemaName + ",ou=schema" );
+ dn = new LdapDN(
+ SchemaConstants.NORMALIZERS_PATH,
+ "cn=" + schemaName,
+ SchemaConstants.OU_SCHEMA );
+
dn.normalize( atRegistry.getNormalizerMapping() );
staticNormalizersDNs.put( schemaName, dn );
// Initialize SyntaxCheckers Dns
- dn = new LdapDN( "ou=syntaxcheckers,cn=" + schemaName + ",ou=schema" );
+ dn = new LdapDN(
+ SchemaConstants.SYNTAX_CHECKERS_PATH,
+ "cn=" + schemaName,
+ SchemaConstants.OU_SCHEMA );
+
dn.normalize( atRegistry.getNormalizerMapping() );
staticSyntaxCheckersDNs.put( schemaName, dn );
// Initialize Syntaxes Dns
- dn = new LdapDN( "ou=syntaxes,cn=" + schemaName + ",ou=schema" );
+ dn = new LdapDN(
+ SchemaConstants.SYNTAXES_PATH,
+ "cn=" + schemaName,
+ SchemaConstants.OU_SCHEMA );
+
dn.normalize( atRegistry.getNormalizerMapping() );
staticSyntaxesDNs.put( schemaName, dn );
@@ -367,7 +395,6 @@
loadDitStructureRules( schema, targetRegistries );
-
notifyListenerOrRegistries( schema, targetRegistries );
}
@@ -409,7 +436,11 @@
if ( dn == null )
{
- dn = new LdapDN( "ou=objectclasses,cn=" + schema.getSchemaName() + ",ou=schema" );
+ dn = new LdapDN(
+ SchemaConstants.OBJECT_CLASSES_PATH,
+ "cn=" + schema.getSchemaName(),
+ SchemaConstants.OU_SCHEMA );
+
dn.normalize( atRegistry.getNormalizerMapping() );
staticObjectClassesDNs.put( schema.getSchemaName(), dn );
}
@@ -510,7 +541,11 @@
if ( dn == null )
{
- dn = new LdapDN( "ou=attributetypes,cn=" + schema.getSchemaName() + ",ou=schema" );
+ dn = new LdapDN(
+ SchemaConstants.ATTRIBUTES_TYPE_PATH,
+ "cn=" + schema.getSchemaName(),
+ SchemaConstants.OU_SCHEMA );
+
dn.normalize( atRegistry.getNormalizerMapping() );
staticAttributeTypeDNs.put( schema.getSchemaName(), dn );
}
@@ -611,7 +646,11 @@
if ( dn == null )
{
- dn = new LdapDN( "ou=matchingrules,cn=" + schema.getSchemaName() + ",ou=schema" );
+ dn = new LdapDN(
+ SchemaConstants.MATCHING_RULES_PATH,
+ "cn=" + schema.getSchemaName(),
+ SchemaConstants.OU_SCHEMA );
+
dn.normalize( atRegistry.getNormalizerMapping() );
staticMatchingRulesDNs.put( schema.getSchemaName(), dn );
}
@@ -644,7 +683,11 @@
if ( dn == null )
{
- dn = new LdapDN( "ou=syntaxes,cn=" + schema.getSchemaName() + ",ou=schema" );
+ dn = new LdapDN(
+ SchemaConstants.SYNTAXES_PATH,
+ "cn=" + schema.getSchemaName(),
+ SchemaConstants.OU_SCHEMA );
+
dn.normalize( atRegistry.getNormalizerMapping() );
staticSyntaxesDNs.put( schema.getSchemaName(), dn );
}
@@ -676,7 +719,11 @@
if ( dn == null )
{
- dn = new LdapDN( "ou=syntaxcheckers,cn=" + schema.getSchemaName() + ",ou=schema" );
+ dn = new LdapDN(
+ SchemaConstants.SYNTAX_CHECKERS_PATH,
+ "cn=" + schema.getSchemaName(),
+ SchemaConstants.OU_SCHEMA );
+
dn.normalize( atRegistry.getNormalizerMapping() );
staticSyntaxCheckersDNs.put( schema.getSchemaName(), dn );
}
@@ -696,7 +743,7 @@
LdapDN resultDN = result.getDn();
resultDN.normalize( atRegistry.getNormalizerMapping() );
ServerEntry attrs = lookupPartition( resultDN );
- SyntaxChecker sc = factory.getSyntaxChecker( attrs, targetRegistries );
+ SyntaxChecker sc = factory.getSyntaxChecker( attrs, targetRegistries, schema.getSchemaName() );
SyntaxCheckerDescription syntaxCheckerDescription =
getSyntaxCheckerDescription( schema.getSchemaName(), attrs );
// @TODO elecharny what should I do with the description
@@ -712,7 +759,11 @@
if ( dn == null )
{
- dn = new LdapDN( "ou=normalizers,cn=" + schema.getSchemaName() + ",ou=schema" );
+ dn = new LdapDN(
+ SchemaConstants.NORMALIZERS_PATH,
+ "cn=" + schema.getSchemaName(),
+ SchemaConstants.OU_SCHEMA );
+
dn.normalize( atRegistry.getNormalizerMapping() );
staticNormalizersDNs.put( schema.getSchemaName(), dn );
}
@@ -732,7 +783,7 @@
LdapDN resultDN = result.getDn();
resultDN.normalize( atRegistry.getNormalizerMapping() );
ServerEntry attrs = lookupPartition( resultDN );
- Normalizer normalizer = factory.getNormalizer( attrs, targetRegistries );
+ Normalizer normalizer = factory.getNormalizer( attrs, targetRegistries,schema.getSchemaName() );
NormalizerDescription normalizerDescription = getNormalizerDescription( schema.getSchemaName(), attrs );
// @TODO elecharny what should I do with the description
@@ -793,7 +844,11 @@
if ( dn == null )
{
- dn = new LdapDN( "ou=comparators,cn=" + schema.getSchemaName() + ",ou=schema" );
+ dn = new LdapDN(
+ SchemaConstants.COMPARATORS_PATH,
+ "cn=" + schema.getSchemaName(),
+ SchemaConstants.OU_SCHEMA );
+
dn.normalize( atRegistry.getNormalizerMapping() );
staticComparatorsDNs.put( schema.getSchemaName(), dn );
}
@@ -813,7 +868,7 @@
LdapDN resultDN = result.getDn();
resultDN.normalize( atRegistry.getNormalizerMapping() );
ClonedServerEntry attrs = lookupPartition( resultDN );
- LdapComparator<?> comparator = factory.getLdapComparator( attrs, targetRegistries );
+ LdapComparator<?> comparator = factory.getLdapComparator( attrs, targetRegistries, schema.getSchemaName() );
LdapComparatorDescription comparatorDescription = getLdapComparatorDescription( schema.getSchemaName(), attrs );
// @TODO elecharny what should I do with description
Modified: directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/SchemaPartition.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/SchemaPartition.java?rev=823360&r1=823359&r2=823360&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/SchemaPartition.java (original)
+++ directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/SchemaPartition.java Fri Oct 9 00:03:45 2009
@@ -50,6 +50,7 @@
import org.apache.directory.server.core.partition.NullPartition;
import org.apache.directory.server.core.partition.Partition;
import org.apache.directory.server.core.schema.registries.synchronizers.RegistrySynchronizerAdaptor;
+import org.apache.directory.shared.ldap.constants.SchemaConstants;
import org.apache.directory.shared.ldap.entry.Modification;
import org.apache.directory.shared.ldap.entry.ModificationOperation;
import org.apache.directory.shared.ldap.message.control.CascadeControl;
@@ -196,7 +197,7 @@
*/
public final String getSuffix()
{
- return ServerDNConstants.OU_SCHEMA_DN;
+ return SchemaConstants.OU_SCHEMA;
}
@@ -205,7 +206,7 @@
*/
public final void setSuffix( String suffix )
{
- LOG.warn( "This partition's suffix is fixed: {}", ServerDNConstants.OU_SCHEMA_DN );
+ LOG.warn( "This partition's suffix is fixed: {}", SchemaConstants.OU_SCHEMA );
}
@@ -231,7 +232,7 @@
SerializableComparator.setRegistry( registries.getComparatorRegistry() );
wrapped.setId( ID );
- wrapped.setSuffix( ServerDNConstants.OU_SCHEMA_DN );
+ wrapped.setSuffix( SchemaConstants.OU_SCHEMA );
wrapped.getSuffixDn().normalize( registries.getAttributeTypeRegistry().getNormalizerMapping() );
wrapped.setRegistries( registries );
@@ -288,8 +289,24 @@
*/
public void add( AddOperationContext opContext ) throws Exception
{
+ // At this point, the added SchemaObject does not exist in the partition
+ // We have to check if it's enabled and then inject it into the registries
+ // but only if it does not break the server.
synchronizer.add( opContext );
- wrapped.add( opContext );
+
+ // Now, write the newly added SchemaObject into the schemaPartition
+ try
+ {
+ wrapped.add( opContext );
+ }
+ catch ( Exception e )
+ {
+ // If something went wrong, we have to unregister the schemaObject
+ // from the registries
+ // TODO : deregister the newly added element.
+ throw e;
+ }
+
updateSchemaModificationAttributes( opContext );
}
@@ -309,8 +326,20 @@
public void delete( DeleteOperationContext opContext ) throws Exception
{
boolean cascade = opContext.hasRequestControl( CascadeControl.CONTROL_OID );
- synchronizer.delete( opContext, opContext.getEntry(), cascade );
- wrapped.delete( opContext );
+
+ // The SchemaObject always exist when we reach this method.
+ synchronizer.delete( opContext, cascade );
+
+ try
+ {
+ wrapped.delete( opContext );
+ }
+ catch ( Exception e )
+ {
+ // TODO : If something went wrong, what should we do here ?
+ throw e;
+ }
+
updateSchemaModificationAttributes( opContext );
}
@@ -360,8 +389,12 @@
boolean cascade = opContext.hasRequestControl( CascadeControl.CONTROL_OID );
- synchronizer.modify( opContext, opContext.getEntry(), targetEntry, cascade );
- wrapped.modify( opContext );
+ boolean hasModification = synchronizer.modify( opContext, targetEntry, cascade );
+
+ if ( hasModification )
+ {
+ wrapped.modify( opContext );
+ }
if ( !opContext.getDn().equals( schemaModificationDN ) )
{
@@ -491,4 +524,13 @@
{
return loader;
}
+
+
+ /**
+ * @see Object#toString()
+ */
+ public String toString()
+ {
+ return "Partition : " + ID;
+ }
}
Modified: directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/SchemaPartitionDaoImpl.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/SchemaPartitionDaoImpl.java?rev=823360&r1=823359&r2=823360&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/SchemaPartitionDaoImpl.java (original)
+++ directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/SchemaPartitionDaoImpl.java Fri Oct 9 00:03:45 2009
@@ -198,7 +198,7 @@
private EntryFilteringCursor listSchemas() throws Exception
{
- LdapDN base = new LdapDN( ServerDNConstants.OU_SCHEMA_DN );
+ LdapDN base = new LdapDN( SchemaConstants.OU_SCHEMA );
base.normalize( atRegistry.getNormalizerMapping() );
ExprNode filter = new EqualityNode<String>( atRegistry.getOidByName( SchemaConstants.OBJECT_CLASS_AT ),
new ClientStringValue( MetaSchemaConstants.META_SCHEMA_OC ) );
Modified: directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/AbstractRegistrySynchronizer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/AbstractRegistrySynchronizer.java?rev=823360&r1=823359&r2=823360&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/AbstractRegistrySynchronizer.java (original)
+++ directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/AbstractRegistrySynchronizer.java Fri Oct 9 00:03:45 2009
@@ -20,17 +20,19 @@
package org.apache.directory.server.core.schema.registries.synchronizers;
+import java.util.HashMap;
import java.util.HashSet;
-import java.util.List;
+import java.util.Map;
import java.util.Set;
import javax.naming.NamingException;
import org.apache.directory.server.core.entry.ServerEntry;
+import org.apache.directory.server.core.interceptor.context.ModifyOperationContext;
import org.apache.directory.shared.ldap.constants.MetaSchemaConstants;
+import org.apache.directory.shared.ldap.constants.SchemaConstants;
import org.apache.directory.shared.ldap.entry.EntryAttribute;
-import org.apache.directory.shared.ldap.entry.Modification;
-import org.apache.directory.shared.ldap.entry.ModificationOperation;
+import org.apache.directory.shared.ldap.exception.LdapInvalidNameException;
import org.apache.directory.shared.ldap.exception.LdapNamingException;
import org.apache.directory.shared.ldap.exception.LdapOperationNotSupportedException;
import org.apache.directory.shared.ldap.message.ResultCodeEnum;
@@ -42,6 +44,7 @@
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.SchemaObjectRegistry;
import org.apache.directory.shared.schema.loader.ldif.SchemaEntityFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -64,12 +67,31 @@
/** The OID registry */
protected final OidRegistry oidRegistry;
- /** The m-oid AttrributeType */
+ /** The m-oid AttributeType */
protected final AttributeType m_oidAT;
/** The Schema objetc factory */
protected final SchemaEntityFactory factory;
+
+ /** A map associating a SchemaObject type with its path on the partition*/
+ private final static Map<String, String> OBJECT_TYPE_TO_PATH = new HashMap<String, String>();
+ static
+ {
+ // Removed the starting 'ou=' from the paths
+ OBJECT_TYPE_TO_PATH.put( SchemaConstants.ATTRIBUTE_TYPE, SchemaConstants.ATTRIBUTES_TYPE_PATH.substring( 3 ) );
+ OBJECT_TYPE_TO_PATH.put( SchemaConstants.COMPARATOR, SchemaConstants.COMPARATORS_PATH.substring( 3 ) );
+ OBJECT_TYPE_TO_PATH.put( SchemaConstants.DIT_CONTENT_RULE, SchemaConstants.DIT_CONTENT_RULES_PATH.substring( 3 ) );
+ OBJECT_TYPE_TO_PATH.put( SchemaConstants.DIT_STRUCTURE_RULE, SchemaConstants.DIT_STRUCTURE_RULES_PATH.substring( 3 ) );
+ OBJECT_TYPE_TO_PATH.put( SchemaConstants.MATCHING_RULE, SchemaConstants.MATCHING_RULES_PATH.substring( 3 ) );
+ OBJECT_TYPE_TO_PATH.put( SchemaConstants.MATCHING_RULE_USE, SchemaConstants.MATCHING_RULE_USE_PATH.substring( 3 ) );
+ OBJECT_TYPE_TO_PATH.put( SchemaConstants.NAME_FORM, SchemaConstants.NAME_FORMS_PATH.substring( 3 ) );
+ OBJECT_TYPE_TO_PATH.put( SchemaConstants.NORMALIZER, SchemaConstants.NORMALIZERS_PATH.substring( 3 ) );
+ OBJECT_TYPE_TO_PATH.put( SchemaConstants.OBJECT_CLASS, SchemaConstants.OBJECT_CLASSES_PATH.substring( 3 ) );
+ OBJECT_TYPE_TO_PATH.put( SchemaConstants.SYNTAX, SchemaConstants.SYNTAXES_PATH.substring( 3 ) );
+ OBJECT_TYPE_TO_PATH.put( SchemaConstants.SYNTAX_CHECKER, SchemaConstants.SYNTAX_CHECKERS_PATH.substring( 3 ) );
+ }
+
protected AbstractRegistrySynchronizer( Registries targetRegistries ) throws Exception
{
@@ -77,6 +99,7 @@
m_oidAT = targetRegistries.getAttributeTypeRegistry().lookup( MetaSchemaConstants.M_OID_AT );
factory = new SchemaEntityFactory();
oidRegistry = registries.getOidRegistry();
+
}
@@ -154,6 +177,35 @@
}
}
+
+ /**
+ * Checks that the parent DN is a valid DN
+ */
+ protected void checkParent( LdapDN newParent, SchemaObjectRegistry<?> registry, String objectType ) throws NamingException
+ {
+ if ( newParent.size() != 3 )
+ {
+ throw new LdapInvalidNameException(
+ "The parent dn of a attributeType should be at most 3 name components in length.",
+ ResultCodeEnum.NAMING_VIOLATION );
+ }
+
+ Rdn rdn = newParent.getRdn();
+
+ if ( ! registries.getAttributeTypeRegistry().getOidByName( rdn.getNormType() ).equals( SchemaConstants.OU_AT_OID ) )
+ {
+ throw new LdapInvalidNameException( "The parent entry of a " + objectType + " should be an organizationalUnit.",
+ ResultCodeEnum.NAMING_VIOLATION );
+ }
+
+ if ( ! ( ( String ) rdn.getValue() ).equalsIgnoreCase( OBJECT_TYPE_TO_PATH.get( objectType ) ) )
+ {
+ throw new LdapInvalidNameException(
+ "The parent entry of a " + objectType + " should have a relative name of ou=" +
+ OBJECT_TYPE_TO_PATH.get( objectType ) + ".",
+ ResultCodeEnum.NAMING_VIOLATION );
+ }
+ }
protected void checkOidIsUnique( SchemaObject schemaObject ) throws Exception
{
@@ -178,17 +230,19 @@
/**
- * Add a new SchemaObject to the schema registry, assuming that
+ * Add a new SchemaObject to the schema content, assuming that
* it has an associated schema and that this schema is loaded
*/
protected void addToSchema( SchemaObject schemaObject, String schemaName ) throws Exception
{
if ( isSchemaLoaded( schemaName ) )
{
- Set<SchemaWrapper> schemaObjects = registries.getObjectBySchemaname().get( schemaName );
+ // Get the set of all the SchemaObjects associated with this schema
+ Set<SchemaWrapper> schemaObjects = registries.getObjectBySchemaName().get( schemaName );
if ( schemaObjects == null )
{
+ // TODO : this should never happen...
schemaObjects = registries.addSchema( schemaName );
}
@@ -227,7 +281,7 @@
{
if ( isSchemaLoaded( schemaName ) )
{
- Set<SchemaWrapper> schemaObjects = registries.getObjectBySchemaname().get( schemaName );
+ Set<SchemaWrapper> schemaObjects = registries.getObjectBySchemaName().get( schemaName );
SchemaWrapper schemaWrapper = new SchemaWrapper( schemaObject );
@@ -254,11 +308,14 @@
}
- protected abstract boolean modify( LdapDN name, ServerEntry entry, ServerEntry targetEntry, boolean cascade )
+ /**
+ * {@inheritDoc}
+ */
+ public abstract boolean modify( ModifyOperationContext opContext, ServerEntry targetEntry, boolean cascade )
throws Exception;
- public final boolean modify( LdapDN name, ModificationOperation modOp, ServerEntry mods, ServerEntry entry, ServerEntry targetEntry,
+ /*public final boolean modify( LdapDN name, ModificationOperation modOp, ServerEntry mods, ServerEntry entry, ServerEntry targetEntry,
boolean cascade ) throws Exception
{
return modify( name, entry, targetEntry, cascade );
@@ -270,6 +327,7 @@
{
return modify( name, entry, targetEntry, cascade );
}
+ */
protected Set<String> getOids( Set<ServerEntry> results ) throws Exception
@@ -300,14 +358,49 @@
}
+ /**
+ * Unregister a SchemaObject's OID from the associated oidRegistry
+ *
+ * @param obj The SchemaObject to unregister
+ * @throws Exception If the unregistering failed
+ */
protected void unregisterOids( SchemaObject obj ) throws Exception
{
oidRegistry.unregister( obj.getOid() );
}
+ /**
+ * Register a SchemaObject's OID in the associated oidRegistry
+ *
+ * @param obj The SchemaObject to register
+ * @throws Exception If the registering failed
+ */
protected void registerOids( SchemaObject obj ) throws Exception
{
oidRegistry.register( obj );
}
+
+
+ /**
+ * Get a String containing the SchemaObjects referencing the
+ * given ShcemaObject
+ *
+ * @param schemaObject The SchemaObject we want the referencing SchemaObjects for
+ * @return A String containing all the SchemaObjects referencing the give SchemaObject
+ */
+ protected String getReferenced( SchemaObject schemaObject )
+ {
+ StringBuilder sb = new StringBuilder();
+
+ Set<SchemaObject> usings = registries.getUsing( schemaObject );
+
+ for ( SchemaObject using:usings )
+ {
+ sb.append( using );
+ sb.append( '\n' );
+ }
+
+ return sb.toString();
+ }
}
Modified: directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/AttributeTypeSynchronizer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/AttributeTypeSynchronizer.java?rev=823360&r1=823359&r2=823360&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/AttributeTypeSynchronizer.java (original)
+++ directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/AttributeTypeSynchronizer.java Fri Oct 9 00:03:45 2009
@@ -20,12 +20,10 @@
package org.apache.directory.server.core.schema.registries.synchronizers;
-import javax.naming.NamingException;
-
import org.apache.directory.server.core.entry.ServerEntry;
+import org.apache.directory.server.core.interceptor.context.ModifyOperationContext;
import org.apache.directory.shared.ldap.constants.MetaSchemaConstants;
import org.apache.directory.shared.ldap.constants.SchemaConstants;
-import org.apache.directory.shared.ldap.exception.LdapInvalidNameException;
import org.apache.directory.shared.ldap.exception.LdapOperationNotSupportedException;
import org.apache.directory.shared.ldap.message.ResultCodeEnum;
import org.apache.directory.shared.ldap.name.LdapDN;
@@ -33,6 +31,7 @@
import org.apache.directory.shared.ldap.schema.AttributeType;
import org.apache.directory.shared.ldap.schema.registries.AttributeTypeRegistry;
import org.apache.directory.shared.ldap.schema.registries.Registries;
+import org.apache.directory.shared.ldap.schema.registries.Schema;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -74,18 +73,46 @@
LdapDN parentDn = ( LdapDN ) dn.clone();
parentDn.remove( parentDn.size() - 1 );
- checkNewParent( parentDn );
+ // The parent DN must be ou=attributetypes,cn=<schemaName>,ou=schema
+ checkParent( parentDn, atRegistry, SchemaConstants.ATTRIBUTE_TYPE );
+
+ // The new schemaObject's OID must not already exist
checkOidIsUnique( entry );
+ // Build the new AttributeType from the given entry
String schemaName = getSchemaName( dn );
AttributeType at = factory.getAttributeType( entry, registries, schemaName );
+ // At this point, the constructed AttributeType has not been checked against the
+ // existing Registries. It may be broken (missing SUP, or such), it will be checked
+ // there, if the schema and the AttributeType are both enabled.
+ Schema schema = registries.getLoadedSchema( schemaName );
+
+ if ( schema.isEnabled() && at.isEnabled() )
+ {
+ at.applyRegistries( registries );
+ }
+
+ // Associates this AttributeType with the schema
addToSchema( at, schemaName );
+ // Don't inject the modified element if the schema is disabled
if ( isSchemaEnabled( schemaName ) )
{
- // Don't inject the modified element if the schema is disabled
atRegistry.register( at );
+
+ // Update the referenced objects
+ // The Syntax,
+ registries.addReference( at, at.getSyntax() );
+
+ // The Superior if any
+ registries.addReference( at, at.getSuperior() );
+
+ // The MatchingRules
+ registries.addReference( at, at.getEquality() );
+ registries.addReference( at, at.getOrdering() );
+ registries.addReference( at, at.getSubstring() );
+
LOG.debug( "Added {} into the enabled schema {}", dn.getUpName(), schemaName );
}
else
@@ -96,9 +123,14 @@
}
- public boolean modify( LdapDN name, ServerEntry entry, ServerEntry targetEntry, boolean cascade )
+ /**
+ * {@inheritDoc}
+ */
+ public boolean modify( ModifyOperationContext opContext, ServerEntry targetEntry, boolean cascade )
throws Exception
{
+ LdapDN name = opContext.getDn();
+ ServerEntry entry = opContext.getEntry();
String schemaName = getSchemaName( name );
String oid = getOid( entry );
AttributeType at = factory.getAttributeType( targetEntry, registries, schemaName );
@@ -124,36 +156,59 @@
*/
public void delete( ServerEntry entry, boolean cascade ) throws Exception
{
+ LdapDN dn = entry.getDn();
+ LdapDN parentDn = ( LdapDN ) dn.clone();
+ parentDn.remove( parentDn.size() - 1 );
+
+ // The parent DN must be ou=attributetypes,cn=<schemaName>,ou=schema
+ checkParent( parentDn, atRegistry, SchemaConstants.ATTRIBUTE_TYPE );
+
+ // Get the AttributeType from the given entry ( it has been grabbed from the server earlier)
String schemaName = getSchemaName( entry.getDn() );
AttributeType attributeType = factory.getAttributeType( entry, registries, schemaName );
- if ( !isSchemaLoaded( schemaName ) )
- {
- // Cannot remove an AT from a not loaded schema
- String msg = "Cannot delete " + entry.getDn().getUpName() + ", from the not loade schema " +
- schemaName;
- LOG.warn( msg );
- throw new LdapOperationNotSupportedException( msg, ResultCodeEnum.UNWILLING_TO_PERFORM );
- }
-
+ String oid = attributeType.getOid();
+
+ // Depending on the fact that the schema is enabled or disabled, we will have
+ // to unregister the AttributeType from the registries or not. In any case,
+ // we have to remove it from the schemaPartition.
+ // We also have to check that the removal will let the server Registries in a
+ // stable state, which means in this case that we don't have any AttributeType
+ // directly inherit from the removed AttributeType, and that no ObjectClass
+ // has this AttributeType in its MAY or MUST...
+ // We will also have to remove an index that has been set on this AttributeType.
if ( isSchemaEnabled( schemaName ) )
{
- // Check that the entry has no descendant
- if ( atRegistry.hasDescendants( attributeType.getOid() ) )
+ if ( registries.isReferenced( attributeType ) )
{
String msg = "Cannot delete " + entry.getDn().getUpName() + ", as there are some " +
- " dependant AttributeTypes";
+ " dependant SchemaObjects :\n" + getReferenced( attributeType );
LOG.warn( msg );
throw new LdapOperationNotSupportedException( msg, ResultCodeEnum.UNWILLING_TO_PERFORM );
}
}
+ // Remove the AttributeType from the schema content
deleteFromSchema( attributeType, schemaName );
- if ( isSchemaEnabled( schemaName ) )
+ // Update the Registries now
+ if ( atRegistry.contains( oid ) )
{
// Don't inject the modified element if the schema is disabled
atRegistry.unregister( attributeType.getOid() );
+
+ // Now, update the references.
+ // The Syntax
+ registries.delReference( attributeType.getSyntax(), attributeType );
+
+ // The Superior
+ registries.delReference( attributeType.getSuperior(), attributeType );
+
+ // The MatchingRules
+ registries.delReference( attributeType.getEquality(), attributeType );
+ registries.delReference( attributeType.getOrdering(), attributeType );
+ registries.delReference( attributeType.getSubstring(), attributeType );
+
LOG.debug( "Removed {} from the enabled schema {}", attributeType, schemaName );
}
else
@@ -211,7 +266,7 @@
public void moveAndRename( LdapDN oriChildName, LdapDN newParentName, Rdn newRn, boolean deleteOldRn,
ServerEntry entry, boolean cascade ) throws Exception
{
- checkNewParent( newParentName );
+ checkParent( newParentName, atRegistry, SchemaConstants.ATTRIBUTE_TYPE );
String oldSchemaName = getSchemaName( oriChildName );
String newSchemaName = getSchemaName( newParentName );
AttributeType oldAt = factory.getAttributeType( entry, registries, oldSchemaName );
@@ -262,7 +317,7 @@
public void move( LdapDN oriChildName, LdapDN newParentName, ServerEntry entry, boolean cascade )
throws Exception
{
- checkNewParent( newParentName );
+ checkParent( newParentName, atRegistry, SchemaConstants.ATTRIBUTE_TYPE );
String oldSchemaName = getSchemaName( oriChildName );
String newSchemaName = getSchemaName( newParentName );
AttributeType oldAt = factory.getAttributeType( entry, registries, oldSchemaName );
@@ -303,30 +358,4 @@
registerOids( newAt );
}
}
-
-
- private void checkNewParent( LdapDN newParent ) throws NamingException
- {
- if ( newParent.size() != 3 )
- {
- throw new LdapInvalidNameException(
- "The parent dn of a attributeType should be at most 3 name components in length.",
- ResultCodeEnum.NAMING_VIOLATION );
- }
-
- Rdn rdn = newParent.getRdn();
-
- if ( ! registries.getAttributeTypeRegistry().getOidByName( rdn.getNormType() ).equals( SchemaConstants.OU_AT_OID ) )
- {
- throw new LdapInvalidNameException( "The parent entry of a attributeType should be an organizationalUnit.",
- ResultCodeEnum.NAMING_VIOLATION );
- }
-
- if ( ! ( ( String ) rdn.getValue() ).equalsIgnoreCase( SchemaConstants.ATTRIBUTE_TYPES_AT ) )
- {
- throw new LdapInvalidNameException(
- "The parent entry of a attributeType should have a relative name of ou=attributeTypes.",
- ResultCodeEnum.NAMING_VIOLATION );
- }
- }
}
Modified: directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/ComparatorSynchronizer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/ComparatorSynchronizer.java?rev=823360&r1=823359&r2=823360&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/ComparatorSynchronizer.java (original)
+++ directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/ComparatorSynchronizer.java Fri Oct 9 00:03:45 2009
@@ -23,6 +23,7 @@
import javax.naming.NamingException;
import org.apache.directory.server.core.entry.ServerEntry;
+import org.apache.directory.server.core.interceptor.context.ModifyOperationContext;
import org.apache.directory.shared.ldap.constants.MetaSchemaConstants;
import org.apache.directory.shared.ldap.constants.SchemaConstants;
import org.apache.directory.shared.ldap.exception.LdapInvalidNameException;
@@ -72,11 +73,16 @@
}
- public boolean modify( LdapDN name, ServerEntry entry, ServerEntry targetEntry, boolean cascade ) throws Exception
+ /**
+ * {@inheritDoc}
+ */
+ public boolean modify( ModifyOperationContext opContext, ServerEntry targetEntry, boolean cascade ) throws Exception
{
+ LdapDN name = opContext.getDn();
+ ServerEntry entry = opContext.getEntry();
String schemaName = getSchemaName( name );
String oid = getOid( entry );
- LdapComparator<?> comparator = factory.getLdapComparator( targetEntry, registries );
+ LdapComparator<?> comparator = factory.getLdapComparator( targetEntry, registries, schemaName );
if ( isSchemaEnabled( schemaName ) )
{
@@ -100,16 +106,21 @@
LdapDN dn = entry.getDn();
LdapDN parentDn = ( LdapDN ) dn.clone();
parentDn.remove( parentDn.size() - 1 );
- checkNewParent( parentDn );
- checkOidIsUniqueForComparator( entry );
- LdapComparator<?> comparator = factory.getLdapComparator( entry, registries );
+ // The parent DN must be ou=comparators,cn=<schemaName>,ou=schema
+ checkParent( parentDn, comparatorRegistry, SchemaConstants.COMPARATOR );
+
+ // The new schemaObject's OID must not already exist
+ checkOidIsUniqueForComparator( entry );
+
+ // Build the new Comparator from the given entry
String schemaName = getSchemaName( dn );
- comparator.setSchemaName( schemaName );
+
+ LdapComparator<?> comparator = factory.getLdapComparator( entry, registries, schemaName );
addToSchema( comparator, schemaName );
- if ( isSchemaEnabled( schemaName ) )
+ if ( isSchemaEnabled( schemaName ) && comparator.isEnabled() )
{
comparatorRegistry.register( comparator );
LOG.debug( "Added {} into the enabled schema {}", dn.getUpName(), schemaName );
@@ -122,21 +133,30 @@
*/
public void delete( ServerEntry entry, boolean cascade ) throws Exception
{
- String oid = getOid( entry );
+ LdapDN dn = entry.getDn();
+ LdapDN parentDn = ( LdapDN ) dn.clone();
+ parentDn.remove( parentDn.size() - 1 );
+
+ // The parent DN must be ou=comparators,cn=<schemaName>,ou=schema
+ checkParent( parentDn, comparatorRegistry, SchemaConstants.COMPARATOR );
+
+ // Get the Comparator from the given entry ( it has been grabbed from the server earlier)
String schemaName = getSchemaName( entry.getDn() );
+ LdapComparator<?> comparator = factory.getLdapComparator( entry, registries, schemaName );
- if ( matchingRuleRegistry.contains( oid ) )
+ String oid = comparator.getOid();
+
+ if ( isSchemaEnabled( schemaName ) )
{
- String msg = "The comparator with OID " + oid
- + " cannot be deleted until all "
- + "matchingRules using that comparator have also been deleted.";
- LOG.warn( msg );
- throw new LdapOperationNotSupportedException( msg,
- ResultCodeEnum.UNWILLING_TO_PERFORM );
+ if ( registries.isReferenced( comparator ) )
+ {
+ String msg = "Cannot delete " + entry.getDn().getUpName() + ", as there are some " +
+ " dependant SchemaObjects :\n" + getReferenced( comparator );
+ LOG.warn( msg );
+ throw new LdapOperationNotSupportedException( msg, ResultCodeEnum.UNWILLING_TO_PERFORM );
+ }
}
- LdapComparator<?> comparator = factory.getLdapComparator( entry, registries );
-
deleteFromSchema( comparator, schemaName );
if ( comparatorRegistry.contains( oid ) )
@@ -186,7 +206,7 @@
targetEntry.setDn( newDn );
// Register the new comparator, and unregister the old one
- LdapComparator<?> comparator = factory.getLdapComparator( targetEntry, registries );
+ LdapComparator<?> comparator = factory.getLdapComparator( targetEntry, registries, schemaName );
comparatorRegistry.unregister( oldOid );
comparatorRegistry.register( comparator );
}
@@ -210,7 +230,9 @@
String oid = ( String ) newRdn.getValue();
checkOidIsUniqueForComparator( oid );
- LdapComparator<?> comparator = factory.getLdapComparator( entry, registries );
+ String newSchemaName = getSchemaName( newParentName );
+
+ LdapComparator<?> comparator = factory.getLdapComparator( entry, registries, newSchemaName );
String oldSchemaName = getSchemaName( oriChildName );
@@ -219,8 +241,6 @@
comparatorRegistry.unregister( oldOid );
}
- String newSchemaName = getSchemaName( newParentName );
-
if ( isSchemaEnabled( newSchemaName ) )
{
comparatorRegistry.register( comparator );
@@ -242,7 +262,9 @@
ResultCodeEnum.UNWILLING_TO_PERFORM );
}
- LdapComparator<?> comparator = factory.getLdapComparator( entry, registries );
+ String newSchemaName = getSchemaName( newParentName );
+
+ LdapComparator<?> comparator = factory.getLdapComparator( entry, registries, newSchemaName );
String oldSchemaName = getSchemaName( oriChildName );
@@ -251,8 +273,6 @@
comparatorRegistry.unregister( oid );
}
- String newSchemaName = getSchemaName( newParentName );
-
if ( isSchemaEnabled( newSchemaName ) )
{
comparatorRegistry.register( comparator );
Modified: directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/DitContentRuleSynchronizer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/DitContentRuleSynchronizer.java?rev=823360&r1=823359&r2=823360&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/DitContentRuleSynchronizer.java (original)
+++ directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/DitContentRuleSynchronizer.java Fri Oct 9 00:03:45 2009
@@ -23,6 +23,7 @@
import javax.naming.NamingException;
import org.apache.directory.server.core.entry.ServerEntry;
+import org.apache.directory.server.core.interceptor.context.ModifyOperationContext;
import org.apache.directory.shared.ldap.name.LdapDN;
import org.apache.directory.shared.ldap.name.Rdn;
import org.apache.directory.shared.ldap.schema.DITContentRule;
@@ -51,11 +52,11 @@
}
- /* (non-Javadoc)
- * @see org.apache.directory.server.core.schema.AbstractSchemaChangeHandler#modify(org.apache.directory.shared.ldap.name.LdapDN, javax.naming.directory.Attributes, javax.naming.directory.Attributes)
+ /**
+ * {@inheritDoc}
*/
@Override
- public boolean modify( LdapDN name, ServerEntry entry, ServerEntry targetEntry, boolean cascade )
+ public boolean modify( ModifyOperationContext opContext, ServerEntry targetEntry, boolean cascade )
throws NamingException
{
// TODO Auto-generated method stub
Modified: directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/DitStructureRuleSynchronizer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/DitStructureRuleSynchronizer.java?rev=823360&r1=823359&r2=823360&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/DitStructureRuleSynchronizer.java (original)
+++ directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/DitStructureRuleSynchronizer.java Fri Oct 9 00:03:45 2009
@@ -23,6 +23,7 @@
import javax.naming.NamingException;
import org.apache.directory.server.core.entry.ServerEntry;
+import org.apache.directory.server.core.interceptor.context.ModifyOperationContext;
import org.apache.directory.shared.ldap.name.LdapDN;
import org.apache.directory.shared.ldap.name.Rdn;
import org.apache.directory.shared.ldap.schema.DITStructureRule;
@@ -50,13 +51,11 @@
}
- /* (non-Javadoc)
- * @see org.apache.directory.server.core.schema.AbstractSchemaChangeHandler#modify(
- * org.apache.directory.shared.ldap.name.LdapDN, javax.naming.directory.Attributes,
- * javax.naming.directory.Attributes)
+ /**
+ * {@inheritDoc}
*/
@Override
- public boolean modify( LdapDN name, ServerEntry entry, ServerEntry targetEntry,
+ public boolean modify( ModifyOperationContext opContext, ServerEntry targetEntry,
boolean cascade ) throws NamingException
{
// TODO Auto-generated method stub
Modified: directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/MatchingRuleSynchronizer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/MatchingRuleSynchronizer.java?rev=823360&r1=823359&r2=823360&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/MatchingRuleSynchronizer.java (original)
+++ directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/MatchingRuleSynchronizer.java Fri Oct 9 00:03:45 2009
@@ -23,6 +23,7 @@
import javax.naming.NamingException;
import org.apache.directory.server.core.entry.ServerEntry;
+import org.apache.directory.server.core.interceptor.context.ModifyOperationContext;
import org.apache.directory.shared.ldap.constants.MetaSchemaConstants;
import org.apache.directory.shared.ldap.constants.SchemaConstants;
import org.apache.directory.shared.ldap.exception.LdapInvalidNameException;
@@ -32,6 +33,7 @@
import org.apache.directory.shared.ldap.schema.MatchingRule;
import org.apache.directory.shared.ldap.schema.registries.MatchingRuleRegistry;
import org.apache.directory.shared.ldap.schema.registries.Registries;
+import org.apache.directory.shared.ldap.schema.registries.Schema;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -66,9 +68,14 @@
}
- public boolean modify( LdapDN name, ServerEntry entry, ServerEntry targetEntry,
+ /**
+ * {@inheritDoc}
+ */
+ public boolean modify( ModifyOperationContext opContext, ServerEntry targetEntry,
boolean cascade ) throws Exception
{
+ LdapDN name = opContext.getDn();
+ ServerEntry entry = opContext.getEntry();
String schemaName = getSchemaName( name );
MatchingRule mr = factory.getMatchingRule( targetEntry, registries, schemaName );
@@ -96,22 +103,49 @@
LdapDN dn = entry.getDn();
LdapDN parentDn = ( LdapDN ) dn.clone();
parentDn.remove( parentDn.size() - 1 );
- checkNewParent( parentDn );
+
+ // The parent DN must be ou=matchingrules,cn=<schemaName>,ou=schema
+ checkParent( parentDn, matchingRuleRegistry, SchemaConstants.MATCHING_RULE );
+
+ // The new schemaObject's OID must not already exist
checkOidIsUnique( entry );
+ // Build the new MatchingRule from the given entry
String schemaName = getSchemaName( dn );
- MatchingRule mr = factory.getMatchingRule( entry, registries, schemaName );
+ MatchingRule matchingRule = factory.getMatchingRule( entry, registries, schemaName );
- addToSchema( mr, schemaName );
+ // At this point, the constructed MatchingRule has not been checked against the
+ // existing Registries. It may be broken (missing SYNTAX), it will be checked
+ // there, if the schema and the MatchingRule are both enabled.
+ Schema schema = registries.getLoadedSchema( schemaName );
+ if ( schema.isEnabled() && matchingRule.isEnabled() )
+ {
+ matchingRule.applyRegistries( registries );
+ }
+
+ // Associates this MatchingRule with the schema
+ addToSchema( matchingRule, schemaName );
+
+ // Don't inject the modified element if the schema is disabled
if ( isSchemaEnabled( schemaName ) )
{
- matchingRuleRegistry.register( mr );
+ // Update the referenced and referencing objects
+ // The Syntax
+ registries.addReference( matchingRule, matchingRule.getSyntax() );
+
+ // The Normalizer
+ registries.addReference( matchingRule, matchingRule.getNormalizer() );
+
+ // The Comparator
+ registries.addReference( matchingRule, matchingRule.getLdapComparator() );
+
+ matchingRuleRegistry.register( matchingRule );
LOG.debug( "Added {} into the enabled schema {}", dn.getUpName(), schemaName );
}
else
{
- registerOids( mr );
+ registerOids( matchingRule );
LOG.debug( "Added {} into the disabled schema {}", dn.getUpName(), schemaName );
}
}
@@ -122,13 +156,32 @@
*/
public void delete( ServerEntry entry, boolean cascade ) throws Exception
{
+ LdapDN dn = entry.getDn();
+ LdapDN parentDn = ( LdapDN ) dn.clone();
+ parentDn.remove( parentDn.size() - 1 );
+
+ // The parent DN must be ou=matchingrules,cn=<schemaName>,ou=schema
+ checkParent( parentDn, matchingRuleRegistry, SchemaConstants.MATCHING_RULE );
+
+ // Get the MatchingRule from the given entry ( it has been grabbed from the server earlier)
String schemaName = getSchemaName( entry.getDn() );
MatchingRule matchingRule = factory.getMatchingRule( entry, registries, schemaName );
+ String oid = matchingRule.getOid();
deleteFromSchema( matchingRule, schemaName );
- if ( isSchemaEnabled( schemaName ) )
+ if ( matchingRuleRegistry.contains( oid ) )
{
+ // Update the referenced and referencing objects
+ // The Syntax
+ registries.delReference( matchingRule, matchingRule.getSyntax() );
+
+ // The Normalizer
+ registries.delReference( matchingRule, matchingRule.getNormalizer() );
+
+ // The Comparator
+ registries.delReference( matchingRule, matchingRule.getLdapComparator() );
+
matchingRuleRegistry.unregister( matchingRule.getOid() );
LOG.debug( "Removed {} from the enabled schema {}", matchingRule, schemaName );
}
Modified: directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/MatchingRuleUseSynchronizer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/MatchingRuleUseSynchronizer.java?rev=823360&r1=823359&r2=823360&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/MatchingRuleUseSynchronizer.java (original)
+++ directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/MatchingRuleUseSynchronizer.java Fri Oct 9 00:03:45 2009
@@ -23,6 +23,7 @@
import javax.naming.NamingException;
import org.apache.directory.server.core.entry.ServerEntry;
+import org.apache.directory.server.core.interceptor.context.ModifyOperationContext;
import org.apache.directory.shared.ldap.name.LdapDN;
import org.apache.directory.shared.ldap.name.Rdn;
import org.apache.directory.shared.ldap.schema.MatchingRuleUse;
@@ -50,8 +51,11 @@
}
+ /**
+ * {@inheritDoc}
+ */
@Override
- public boolean modify( LdapDN name, ServerEntry entry, ServerEntry targetEntry,
+ public boolean modify( ModifyOperationContext opContext, ServerEntry targetEntry,
boolean cascade ) throws NamingException
{
// TODO Auto-generated method stub
Modified: directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/NameFormSynchronizer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/NameFormSynchronizer.java?rev=823360&r1=823359&r2=823360&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/NameFormSynchronizer.java (original)
+++ directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/NameFormSynchronizer.java Fri Oct 9 00:03:45 2009
@@ -23,6 +23,7 @@
import javax.naming.NamingException;
import org.apache.directory.server.core.entry.ServerEntry;
+import org.apache.directory.server.core.interceptor.context.ModifyOperationContext;
import org.apache.directory.shared.ldap.name.LdapDN;
import org.apache.directory.shared.ldap.name.Rdn;
import org.apache.directory.shared.ldap.schema.NameForm;
@@ -49,13 +50,11 @@
}
- /* (non-Javadoc)
- * @see org.apache.directory.server.core.schema.AbstractSchemaChangeHandler#modify(
- * org.apache.directory.shared.ldap.name.LdapDN, javax.naming.directory.Attributes,
- * javax.naming.directory.Attributes)
+ /**
+ * {@inheritDoc}
*/
@Override
- public boolean modify( LdapDN name, ServerEntry entry, ServerEntry targetEntry,
+ public boolean modify( ModifyOperationContext opContext, ServerEntry targetEntry,
boolean cascade ) throws NamingException
{
return SCHEMA_UNCHANGED;
Modified: directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/NormalizerSynchronizer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/NormalizerSynchronizer.java?rev=823360&r1=823359&r2=823360&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/NormalizerSynchronizer.java (original)
+++ directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/NormalizerSynchronizer.java Fri Oct 9 00:03:45 2009
@@ -23,6 +23,7 @@
import javax.naming.NamingException;
import org.apache.directory.server.core.entry.ServerEntry;
+import org.apache.directory.server.core.interceptor.context.ModifyOperationContext;
import org.apache.directory.shared.ldap.constants.MetaSchemaConstants;
import org.apache.directory.shared.ldap.constants.SchemaConstants;
import org.apache.directory.shared.ldap.exception.LdapInvalidNameException;
@@ -71,11 +72,16 @@
}
- public boolean modify( LdapDN name, ServerEntry entry, ServerEntry targetEntry, boolean cascade ) throws Exception
+ /**
+ * {@inheritDoc}
+ */
+ public boolean modify( ModifyOperationContext opContext, ServerEntry targetEntry, boolean cascade ) throws Exception
{
+ LdapDN name = opContext.getDn();
+ ServerEntry entry = opContext.getEntry();
String schemaName = getSchemaName( name );
String oldOid = getOid( entry );
- Normalizer normalizer = factory.getNormalizer( targetEntry, registries );
+ Normalizer normalizer = factory.getNormalizer( targetEntry, registries, schemaName );
if ( isSchemaEnabled( schemaName ) )
{
@@ -99,13 +105,17 @@
LdapDN dn = entry.getDn();
LdapDN parentDn = ( LdapDN ) dn.clone();
parentDn.remove( parentDn.size() - 1 );
- checkNewParent( parentDn );
+
+ // The parent DN must be ou=normalizers,cn=<schemaName>,ou=schema
+ checkParent( parentDn, normalizerRegistry, SchemaConstants.NORMALIZER );
+
+ // The new schemaObject's OID must not already exist
checkOidIsUniqueForNormalizer( entry );
- Normalizer normalizer = factory.getNormalizer( entry, registries );
-
+ // Build the new Normalizer from the given entry
String schemaName = getSchemaName( dn );
- normalizer.setSchemaName( schemaName );
+
+ Normalizer normalizer = factory.getNormalizer( entry, registries, schemaName );
addToSchema( normalizer, schemaName );
@@ -122,18 +132,28 @@
*/
public void delete( ServerEntry entry, boolean cascade ) throws Exception
{
+ LdapDN dn = entry.getDn();
+ LdapDN parentDn = ( LdapDN ) dn.clone();
+ parentDn.remove( parentDn.size() - 1 );
+
+ // The parent DN must be ou=normalizers,cn=<schemaName>,ou=schema
+ checkParent( parentDn, normalizerRegistry, SchemaConstants.NORMALIZER );
+
+ // Get the Normalizer from the given entry ( it has been grabbed from the server earlier)
String schemaName = getSchemaName( entry.getDn() );
- Normalizer normalizer = factory.getNormalizer( entry, registries );
+ Normalizer normalizer = factory.getNormalizer( entry, registries, schemaName );
+
String oid = normalizer.getOid();
- if ( matchingRuleRegistry.contains( oid ) )
+ if ( isSchemaEnabled( schemaName ) )
{
- String msg = "The normalizer with OID " + oid
- + " cannot be deleted until all "
- + "matchingRules using that normalizer have also been deleted.";
- LOG.warn( msg );
- throw new LdapOperationNotSupportedException( msg,
- ResultCodeEnum.UNWILLING_TO_PERFORM );
+ if ( registries.isReferenced( normalizer ) )
+ {
+ String msg = "Cannot delete " + entry.getDn().getUpName() + ", as there are some " +
+ " dependant SchemaObjects :\n" + getReferenced( normalizer );
+ LOG.warn( msg );
+ throw new LdapOperationNotSupportedException( msg, ResultCodeEnum.UNWILLING_TO_PERFORM );
+ }
}
deleteFromSchema( normalizer, schemaName );
@@ -181,7 +201,7 @@
newDn.add( newRdn );
targetEntry.setDn( newDn );
- Normalizer normalizer = factory.getNormalizer( targetEntry, registries );
+ Normalizer normalizer = factory.getNormalizer( targetEntry, registries, schemaName );
normalizerRegistry.unregister( oldOid );
normalizerRegistry.register( normalizer );
}
@@ -206,7 +226,7 @@
String oid = ( String ) newRdn.getValue();
checkOidIsUniqueForNormalizer( oid );
- Normalizer normalizer = factory.getNormalizer( entry, registries );
+ Normalizer normalizer = factory.getNormalizer( entry, registries, newSchemaName );
if ( isSchemaEnabled( oldSchemaName ) )
{
@@ -236,7 +256,7 @@
ResultCodeEnum.UNWILLING_TO_PERFORM );
}
- Normalizer normalizer = factory.getNormalizer( entry, registries );
+ Normalizer normalizer = factory.getNormalizer( entry, registries, newSchemaName );
if ( isSchemaEnabled( oldSchemaName ) )
{
Modified: directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/ObjectClassSynchronizer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/ObjectClassSynchronizer.java?rev=823360&r1=823359&r2=823360&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/ObjectClassSynchronizer.java (original)
+++ directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/ObjectClassSynchronizer.java Fri Oct 9 00:03:45 2009
@@ -23,6 +23,7 @@
import javax.naming.NamingException;
import org.apache.directory.server.core.entry.ServerEntry;
+import org.apache.directory.server.core.interceptor.context.ModifyOperationContext;
import org.apache.directory.shared.ldap.constants.MetaSchemaConstants;
import org.apache.directory.shared.ldap.constants.SchemaConstants;
import org.apache.directory.shared.ldap.exception.LdapInvalidNameException;
@@ -30,9 +31,11 @@
import org.apache.directory.shared.ldap.message.ResultCodeEnum;
import org.apache.directory.shared.ldap.name.LdapDN;
import org.apache.directory.shared.ldap.name.Rdn;
+import org.apache.directory.shared.ldap.schema.AttributeType;
import org.apache.directory.shared.ldap.schema.ObjectClass;
import org.apache.directory.shared.ldap.schema.registries.ObjectClassRegistry;
import org.apache.directory.shared.ldap.schema.registries.Registries;
+import org.apache.directory.shared.ldap.schema.registries.Schema;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -65,8 +68,13 @@
}
- public boolean modify( LdapDN name, ServerEntry entry, ServerEntry targetEntry, boolean cascade ) throws Exception
+ /**
+ * {@inheritDoc}
+ */
+ public boolean modify( ModifyOperationContext opContext, ServerEntry targetEntry, boolean cascade ) throws Exception
{
+ LdapDN name = opContext.getDn();
+ ServerEntry entry = opContext.getEntry();
String oid = getOid( entry );
ObjectClass oc = factory.getObjectClass( targetEntry, registries, getSchemaName( name ) );
String schemaName = getSchemaName( entry.getDn() );
@@ -91,22 +99,57 @@
LdapDN dn = entry.getDn();
LdapDN parentDn = ( LdapDN ) dn.clone();
parentDn.remove( parentDn.size() - 1 );
- checkNewParent( parentDn );
+
+ // The parent DN must be ou=objectclasses,cn=<schemaName>,ou=schema
+ checkParent( parentDn, objectClassRegistry, SchemaConstants.OBJECT_CLASS );
+
+ // The new schemaObject's OID must not already exist
checkOidIsUnique( entry );
+ // Build the new ObjectClass from the given entry
String schemaName = getSchemaName( dn );
- ObjectClass oc = factory.getObjectClass( entry, registries, schemaName );
+ ObjectClass objectClass = factory.getObjectClass( entry, registries, schemaName );
+
+ // At this point, the constructed ObjectClass has not been checked against the
+ // existing Registries. It may be broken (missing SUPs), it will be checked
+ // there, if the schema and the ObjectClass are both enabled.
+ Schema schema = registries.getLoadedSchema( schemaName );
- addToSchema( oc, schemaName );
+ if ( schema.isEnabled() && objectClass.isEnabled() )
+ {
+ objectClass.applyRegistries( registries );
+ }
+
+ // Associates this ObjectClass with the schema
+ addToSchema( objectClass, schemaName );
if ( isSchemaEnabled( schemaName ) )
{
- objectClassRegistry.register( oc );
+ // Update the referenced and referencing objects
+ // The MAY AttributeTypes
+ for ( AttributeType may : objectClass.getMayAttributeTypes() )
+ {
+ registries.addReference( objectClass, may );
+ }
+
+ // The MUST AttributeTypes
+ for ( AttributeType must : objectClass.getMayAttributeTypes() )
+ {
+ registries.addReference( objectClass, must );
+ }
+
+ // The superiors
+ for ( ObjectClass superior : objectClass.getSuperiors() )
+ {
+ registries.addReference( objectClass, superior );
+ }
+
+ objectClassRegistry.register( objectClass );
LOG.debug( "Added {} into the enabled schema {}", dn.getUpName(), schemaName );
}
else
{
- registerOids( oc );
+ registerOids( objectClass );
LOG.debug( "Added {} into the disabled schema {}", dn.getUpName(), schemaName );
}
}
@@ -117,34 +160,54 @@
*/
public void delete( ServerEntry entry, boolean cascade ) throws Exception
{
+ LdapDN dn = entry.getDn();
+ LdapDN parentDn = ( LdapDN ) dn.clone();
+ parentDn.remove( parentDn.size() - 1 );
+
+ // The parent DN must be ou=objectclasses,cn=<schemaName>,ou=schema
+ checkParent( parentDn, objectClassRegistry, SchemaConstants.OBJECT_CLASS );
+
+ // Get the ObjectClass from the given entry ( it has been grabbed from the server earlier)
String schemaName = getSchemaName( entry.getDn() );
ObjectClass objectClass = factory.getObjectClass( entry, registries, schemaName );
- if ( !isSchemaLoaded( schemaName ) )
- {
- // Cannot remove an AT from a not loaded schema
- String msg = "Cannot delete " + entry.getDn().getUpName() + ", from the not loade schema " +
- schemaName;
- LOG.warn( msg );
- throw new LdapOperationNotSupportedException( msg, ResultCodeEnum.UNWILLING_TO_PERFORM );
- }
+ String oid = objectClass.getOid();
if ( isSchemaEnabled( schemaName ) )
{
- // Check that the entry has no descendant
- if ( objectClassRegistry.hasDescendants( objectClass.getOid() ) )
+ if ( registries.isReferenced( objectClass ) )
{
String msg = "Cannot delete " + entry.getDn().getUpName() + ", as there are some " +
- " dependant ObjectClasses";
-
+ " dependant SchemaObjects :\n" + getReferenced( objectClass );
+ LOG.warn( msg );
throw new LdapOperationNotSupportedException( msg, ResultCodeEnum.UNWILLING_TO_PERFORM );
}
}
+ // Remove the ObjectClass from the schema content
deleteFromSchema( objectClass, schemaName );
- if ( isSchemaEnabled( schemaName ) )
+ if ( objectClassRegistry.contains( oid ) )
{
+ // Update the referenced and referencing objects
+ // The MAY AttributeTypes
+ for ( AttributeType may : objectClass.getMayAttributeTypes() )
+ {
+ registries.delReference( objectClass, may );
+ }
+
+ // The MUST AttributeTypes
+ for ( AttributeType must : objectClass.getMayAttributeTypes() )
+ {
+ registries.delReference( objectClass, must );
+ }
+
+ // The superiors
+ for ( ObjectClass superior : objectClass.getSuperiors() )
+ {
+ registries.delReference( objectClass, superior );
+ }
+
objectClassRegistry.unregister( objectClass.getOid() );
LOG.debug( "Removed {} from the enabled schema {}", objectClass, schemaName );
}
Modified: directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/RegistrySynchronizer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/RegistrySynchronizer.java?rev=823360&r1=823359&r2=823360&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/RegistrySynchronizer.java (original)
+++ directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/RegistrySynchronizer.java Fri Oct 9 00:03:45 2009
@@ -20,10 +20,8 @@
package org.apache.directory.server.core.schema.registries.synchronizers;
-import java.util.List;
-
import org.apache.directory.server.core.entry.ServerEntry;
-import org.apache.directory.shared.ldap.entry.Modification;
+import org.apache.directory.server.core.interceptor.context.ModifyOperationContext;
import org.apache.directory.shared.ldap.name.LdapDN;
import org.apache.directory.shared.ldap.name.Rdn;
@@ -73,7 +71,17 @@
*/
void rename( ServerEntry entry, Rdn newRdn, boolean cascaded ) throws Exception;
- boolean modify( LdapDN name, List<Modification> mods, ServerEntry entry, ServerEntry targetEntry, boolean cascaded )
+
+ /**
+ * Applies a set of modification to an entry
+ *
+ * @param opContext The OperationContext, which contains the entry and the modifications to apply
+ * @param targetEntry The modified entry
+ * @param cascaded Unused
+ * @return True if the modification has been done
+ * @throws Exception If the modification failed
+ */
+ boolean modify( ModifyOperationContext opContext, ServerEntry targetEntry, boolean cascaded )
throws Exception;
void moveAndRename( LdapDN oriChildName, LdapDN newParentName, Rdn newRn, boolean deleteOldRn, ServerEntry entry,
Modified: directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/RegistrySynchronizerAdaptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/RegistrySynchronizerAdaptor.java?rev=823360&r1=823359&r2=823360&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/RegistrySynchronizerAdaptor.java (original)
+++ directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/RegistrySynchronizerAdaptor.java Fri Oct 9 00:03:45 2009
@@ -22,12 +22,10 @@
import java.util.HashMap;
import java.util.HashSet;
-import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.directory.server.constants.ApacheSchemaConstants;
-import org.apache.directory.server.core.entry.ClonedServerEntry;
import org.apache.directory.server.core.entry.ServerEntry;
import org.apache.directory.server.core.interceptor.context.AddOperationContext;
import org.apache.directory.server.core.interceptor.context.DeleteOperationContext;
@@ -39,13 +37,11 @@
import org.apache.directory.shared.ldap.constants.MetaSchemaConstants;
import org.apache.directory.shared.ldap.constants.SchemaConstants;
import org.apache.directory.shared.ldap.entry.EntryAttribute;
-import org.apache.directory.shared.ldap.entry.Modification;
import org.apache.directory.shared.ldap.entry.Value;
import org.apache.directory.shared.ldap.exception.LdapInvalidNameException;
import org.apache.directory.shared.ldap.exception.LdapNamingException;
import org.apache.directory.shared.ldap.exception.LdapOperationNotSupportedException;
import org.apache.directory.shared.ldap.message.ResultCodeEnum;
-import org.apache.directory.shared.ldap.name.LdapDN;
import org.apache.directory.shared.ldap.schema.AttributeType;
import org.apache.directory.shared.ldap.schema.ObjectClass;
import org.apache.directory.shared.ldap.schema.registries.ObjectClassRegistry;
@@ -205,9 +201,11 @@
/**
* {@inheritDoc}
*/
- public void delete( DeleteOperationContext opContext, ClonedServerEntry entry, boolean doCascadeDelete )
+ public void delete( DeleteOperationContext opContext, boolean doCascadeDelete )
throws Exception
{
+ ServerEntry entry = opContext.getEntry();
+
EntryAttribute oc = entry.get( objectClassAT );
for ( Value<?> value:oc )
@@ -254,12 +252,17 @@
}
- /* (non-Javadoc)
- * @see org.apache.directory.server.core.schema.SchemaChangeManager#modify(org.apache.directory.server.core.interceptor.context.ModifyOperationContext, org.apache.directory.server.core.entry.ServerEntry, org.apache.directory.server.core.entry.ServerEntry, boolean)
+ /**
+ * Modify the schema
+ *
+ * @param opContext The context
+ * @param targetEntry The modified entry
+ * @param doCascadeModify Not used
+ * @throws Exception If the modification failed
*/
- public void modify( ModifyOperationContext opContext, ServerEntry entry,
- ServerEntry targetEntry, boolean doCascadeModify ) throws Exception
+ public boolean modify( ModifyOperationContext opContext, ServerEntry targetEntry, boolean doCascadeModify ) throws Exception
{
+ ServerEntry entry = opContext.getEntry();
EntryAttribute oc = entry.get( objectClassAT );
for ( Value<?> value:oc )
@@ -269,22 +272,20 @@
if ( objectClass2synchronizerMap.containsKey( oid ) )
{
RegistrySynchronizer synchronizer = objectClass2synchronizerMap.get( oid );
- synchronizer.modify( opContext.getDn(), opContext.getModItems(), entry, targetEntry, doCascadeModify );
- return;
+ boolean hasModification = synchronizer.modify( opContext, targetEntry, doCascadeModify );
+ return hasModification;
}
}
if ( oc.contains( MetaSchemaConstants.META_SCHEMA_OC ) )
{
- LdapDN dn = opContext.getDn();
- List<Modification> modifications = opContext.getModItems();
- schemaSynchronizer.modify( dn, modifications, entry, targetEntry, doCascadeModify );
- return;
+ boolean hasModification = schemaSynchronizer.modify( opContext, targetEntry, doCascadeModify );
+ return hasModification;
}
if ( oc.contains( ApacheSchemaConstants.SCHEMA_MODIFICATION_ATTRIBUTES_OC ) )
{
- return;
+ return false;
}
LOG.error( String.format( "Unwilling to perform modify on %s:\n\nEntry:\n%s\n\nModifications:\n%s",