Author: elecharny
Date: Fri Nov 28 07:26:11 2008
New Revision: 721517
URL: http://svn.apache.org/viewvc?rev=721517&view=rev
Log:
Fix for DISERVER-1292.
o Added some isEnabled(), disable(), enable() method in the Schema interface
o If the schema is alread enabled, don't enable it twice (the very same for disable). As a
consequence, the date o last modification wo'nt be modified if it's the only modification
done on the entry
o Added some test to check that
Modified:
directory/apacheds/branches/apacheds-mina2/bootstrap-plugin/src/main/java/org/apache/directory/server/core/bootstrap/plugin/BootstrapPlugin.java
directory/apacheds/branches/apacheds-mina2/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaSchemaHandlerIT.java
directory/apacheds/branches/apacheds-mina2/core-shared/src/main/java/org/apache/directory/server/schema/bootstrap/AbstractBootstrapSchema.java
directory/apacheds/branches/apacheds-mina2/core-shared/src/main/java/org/apache/directory/server/schema/bootstrap/Schema.java
directory/apacheds/branches/apacheds-mina2/core/src/main/java/org/apache/directory/server/core/schema/AbstractSchema.java
directory/apacheds/branches/apacheds-mina2/core/src/main/java/org/apache/directory/server/core/schema/AbstractSchemaChangeHandler.java
directory/apacheds/branches/apacheds-mina2/core/src/main/java/org/apache/directory/server/core/schema/MetaAttributeTypeHandler.java
directory/apacheds/branches/apacheds-mina2/core/src/main/java/org/apache/directory/server/core/schema/MetaComparatorHandler.java
directory/apacheds/branches/apacheds-mina2/core/src/main/java/org/apache/directory/server/core/schema/MetaDitContentRuleHandler.java
directory/apacheds/branches/apacheds-mina2/core/src/main/java/org/apache/directory/server/core/schema/MetaDitStructureRuleHandler.java
directory/apacheds/branches/apacheds-mina2/core/src/main/java/org/apache/directory/server/core/schema/MetaMatchingRuleHandler.java
directory/apacheds/branches/apacheds-mina2/core/src/main/java/org/apache/directory/server/core/schema/MetaMatchingRuleUseHandler.java
directory/apacheds/branches/apacheds-mina2/core/src/main/java/org/apache/directory/server/core/schema/MetaNameFormHandler.java
directory/apacheds/branches/apacheds-mina2/core/src/main/java/org/apache/directory/server/core/schema/MetaNormalizerHandler.java
directory/apacheds/branches/apacheds-mina2/core/src/main/java/org/apache/directory/server/core/schema/MetaObjectClassHandler.java
directory/apacheds/branches/apacheds-mina2/core/src/main/java/org/apache/directory/server/core/schema/MetaSchemaHandler.java
directory/apacheds/branches/apacheds-mina2/core/src/main/java/org/apache/directory/server/core/schema/MetaSyntaxCheckerHandler.java
directory/apacheds/branches/apacheds-mina2/core/src/main/java/org/apache/directory/server/core/schema/MetaSyntaxHandler.java
directory/apacheds/branches/apacheds-mina2/core/src/main/java/org/apache/directory/server/core/schema/SchemaChangeHandler.java
directory/apacheds/branches/apacheds-mina2/core/src/main/java/org/apache/directory/server/core/schema/SchemaOperationControl.java
Modified: directory/apacheds/branches/apacheds-mina2/bootstrap-plugin/src/main/java/org/apache/directory/server/core/bootstrap/plugin/BootstrapPlugin.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-mina2/bootstrap-plugin/src/main/java/org/apache/directory/server/core/bootstrap/plugin/BootstrapPlugin.java?rev=721517&r1=721516&r2=721517&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-mina2/bootstrap-plugin/src/main/java/org/apache/directory/server/core/bootstrap/plugin/BootstrapPlugin.java
(original)
+++ directory/apacheds/branches/apacheds-mina2/bootstrap-plugin/src/main/java/org/apache/directory/server/core/bootstrap/plugin/BootstrapPlugin.java
Fri Nov 28 07:26:11 2008
@@ -334,10 +334,40 @@
}
+ /**
+ * {@inheritDoc}
+ */
public boolean isDisabled()
{
return false;
}
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isEnabled()
+ {
+ return true;
+ }
+
+
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void disable()
+ {
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void enable()
+ {
+ }
};
createSchemaAndContainers( other );
Modified: directory/apacheds/branches/apacheds-mina2/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaSchemaHandlerIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-mina2/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaSchemaHandlerIT.java?rev=721517&r1=721516&r2=721517&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-mina2/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaSchemaHandlerIT.java
(original)
+++ directory/apacheds/branches/apacheds-mina2/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaSchemaHandlerIT.java
Fri Nov 28 07:26:11 2008
@@ -62,9 +62,11 @@
public class MetaSchemaHandlerIT
{
/** the schema to use for this test: one that is not loaded by default */
- private static final String TEST_SCHEMA = "nis";
+ private static final String NIS_SCHEMA = "nis";
+
/** a test attribute in the test schema: uidNumber in nis schema */
private static final String TEST_ATTR_OID = "1.3.6.1.1.1.1.0";
+
/** the name of the dummy schema to test metaSchema adds/deletes with */
private static final String DUMMY_SCHEMA = "dummy";
@@ -96,6 +98,9 @@
attributes = schemaRoot.getAttributes( "ou=attributeTypes,cn=samba" );
assertNotNull( attributes );
assertTrue( attributes.get( SchemaConstants.OU_AT ).contains( "attributetypes" )
);
+
+ // Disable the NIS schema
+ disableSchema( "nis" );
}
@@ -139,7 +144,7 @@
dummySchema.get( "objectClass" ).add( MetaSchemaConstants.META_SCHEMA_OC );
dummySchema.put( "cn", DUMMY_SCHEMA );
dummySchema.put( MetaSchemaConstants.M_DISABLED_AT, "TRUE" );
- dummySchema.put( MetaSchemaConstants.M_DEPENDENCIES_AT, TEST_SCHEMA );
+ dummySchema.put( MetaSchemaConstants.M_DEPENDENCIES_AT, NIS_SCHEMA );
dummySchema.get( MetaSchemaConstants.M_DEPENDENCIES_AT ).add( "core" );
schemaRoot.createSubcontext( "cn=" + DUMMY_SCHEMA, dummySchema );
@@ -221,7 +226,7 @@
Attributes dummySchema = new BasicAttributes( "objectClass", "top", true );
dummySchema.get( "objectClass" ).add( MetaSchemaConstants.META_SCHEMA_OC );
dummySchema.put( "cn", DUMMY_SCHEMA );
- dummySchema.put( MetaSchemaConstants.M_DEPENDENCIES_AT, TEST_SCHEMA );
+ dummySchema.put( MetaSchemaConstants.M_DEPENDENCIES_AT, NIS_SCHEMA );
try
{
@@ -290,7 +295,7 @@
ModificationItem[] mods = new ModificationItem[1];
mods[0] = new ModificationItem( DirContext.ADD_ATTRIBUTE,
new BasicAttribute( MetaSchemaConstants.M_DEPENDENCIES_AT, DUMMY_SCHEMA )
);
- schemaRoot.modifyAttributes( "cn=" + TEST_SCHEMA, mods );
+ schemaRoot.modifyAttributes( "cn=" + NIS_SCHEMA, mods );
// attempt to delete it now & it should fail
try
@@ -377,6 +382,28 @@
/**
+ * A helper method which tells if a schema is disabled
+ */
+ private boolean isDisabled( String schemaName )
+ {
+ Schema schema = getLoadedSchemas().get( schemaName );
+
+ return ( schema == null ) || ( schema.isDisabled() );
+ }
+
+
+ /**
+ * A helper method which tells if a schema is enabled
+ */
+ private boolean isEnabled( String schemaName )
+ {
+ Schema schema = getLoadedSchemas().get( schemaName );
+
+ return ( schema != null ) && ( !schema.isDisabled() );
+ }
+
+
+ /**
* Checks to make sure updates enabling a metaSchema object in
* the schema partition triggers the loading of that schema into
* the global registries.
@@ -389,7 +416,37 @@
AttributeTypeRegistry atr = getAttributeTypeRegistry();
// check that the nis schema is not loaded
- assertNull( getLoadedSchemas().get( TEST_SCHEMA ) );
+ assertTrue( isDisabled( NIS_SCHEMA ) );
+
+ // double check and make sure an attribute from that schema is
+ // not in the AttributeTypeRegistry
+ assertFalse( atr.hasAttributeType( TEST_ATTR_OID ) );
+
+ // now enable the test schema
+ enableSchema( "nis" );
+
+ // now test that the schema is loaded
+ assertTrue( isEnabled( NIS_SCHEMA ) );
+
+ // double check and make sure the test attribute from the
+ // test schema is now loaded and present within the attr registry
+ assertTrue( atr.hasAttributeType( TEST_ATTR_OID ) );
+ }
+
+
+ /**
+ * Checks to make sure that if we try to enable an already enabled
+ * schema, we don't do anything.
+ *
+ * @throws Exception on error
+ */
+ @Test
+ public void testEnableSchemaAlreadyEnabled() throws Exception
+ {
+ AttributeTypeRegistry atr = getAttributeTypeRegistry();
+
+ // check that the nis schema is not loaded
+ assertTrue( isDisabled( NIS_SCHEMA ) );
// double check and make sure an attribute from that schema is
// not in the AttributeTypeRegistry
@@ -398,15 +455,54 @@
// now enable the test schema
enableSchema( "nis" );
+ // and enable it again (it should not do anything)
+ enableSchema( "nis" );
+
// now test that the schema is loaded
- assertNotNull( getLoadedSchemas().get( TEST_SCHEMA ) );
+ assertTrue( isEnabled( NIS_SCHEMA ) );
// double check and make sure the test attribute from the
// test schema is now loaded and present within the attr registry
assertTrue( atr.hasAttributeType( TEST_ATTR_OID ) );
}
+
+ /**
+ * Checks to make sure that if we try to disable an already disabled
+ * schema, we don't do anything.
+ *
+ * @throws Exception on error
+ */
+ @Test
+ public void testDisableSchemaAlreadyDisabled() throws Exception
+ {
+ AttributeTypeRegistry atr = getAttributeTypeRegistry();
+
+ // check that the nis schema is not loaded
+ assertTrue( isDisabled( NIS_SCHEMA ) );
+
+ // double check and make sure an attribute from that schema is
+ // not in the AttributeTypeRegistry
+ assertFalse( atr.hasAttributeType( TEST_ATTR_OID ) );
+
+ // now disable the test schema
+ disableSchema( "nis" );
+
+ // now test that the schema is loaded
+ assertTrue( isDisabled( NIS_SCHEMA ) );
+
+ // and disable it again (it should not do anything)
+ disableSchema( "nis" );
+
+ // and test again that the schema is still disabled
+ assertTrue( isDisabled( NIS_SCHEMA ) );
+
+ // double check and make sure the test attribute from the
+ // test schema is now loaded and present within the attr registry
+ assertFalse( atr.hasAttributeType( TEST_ATTR_OID ) );
+ }
+
/**
* Checks to make sure an attempt to disable a metaSchema fails if
* that schema has dependents which are enabled.
@@ -421,8 +517,8 @@
AttributeTypeRegistry atr = getAttributeTypeRegistry();
- // check that the nis schema is loaded
- assertNotNull( getLoadedSchemas().get( TEST_SCHEMA ) );
+ // check that the nis schema is enabled
+ assertTrue( isEnabled( NIS_SCHEMA ) );
// double check and make sure an attribute from that schema is
// in the AttributeTypeRegistry
@@ -433,7 +529,7 @@
disableSchema( "nis" );
// now test that the schema is NOT loaded
- assertNull( getLoadedSchemas().get( TEST_SCHEMA ) );
+ assertTrue( isDisabled( NIS_SCHEMA ) );
// double check and make sure the test attribute from the test
// schema is now NOT loaded and present within the attr registry
@@ -463,11 +559,11 @@
Attributes dummySchema = new BasicAttributes( "objectClass", "top", true );
dummySchema.get( "objectClass" ).add( MetaSchemaConstants.META_SCHEMA_OC );
dummySchema.put( "cn", DUMMY_SCHEMA );
- dummySchema.put( MetaSchemaConstants.M_DEPENDENCIES_AT, TEST_SCHEMA );
+ dummySchema.put( MetaSchemaConstants.M_DEPENDENCIES_AT, NIS_SCHEMA );
schemaRoot.createSubcontext( "cn=" + DUMMY_SCHEMA, dummySchema );
// check that the nis schema is loaded and the dummy schema is loaded
- assertNotNull( getLoadedSchemas().get( TEST_SCHEMA ) );
+ assertTrue( isEnabled( NIS_SCHEMA ) );
assertNotNull( getLoadedSchemas().get( DUMMY_SCHEMA ) );
AttributeTypeRegistry atr = getAttributeTypeRegistry();
@@ -493,7 +589,7 @@
}
// now test that both schema are still loaded
- assertNotNull( getLoadedSchemas().get( TEST_SCHEMA ) );
+ assertTrue( isEnabled( NIS_SCHEMA ) );
assertNotNull( getLoadedSchemas().get( DUMMY_SCHEMA ) );
// double check and make sure the test attribute from the test
@@ -631,7 +727,7 @@
try
{
- schemaRoot.modifyAttributes( "cn=" + TEST_SCHEMA, mods );
+ schemaRoot.modifyAttributes( "cn=" + NIS_SCHEMA, mods );
fail( "Should not be able to add bogus dependency to schema" );
}
catch ( LdapOperationNotSupportedException e )
@@ -653,14 +749,14 @@
public void testRejectAddOfDisabledDependencyToEnabledSchema() throws Exception
{
LdapContext schemaRoot = getSchemaContext( service );
- enableSchema( TEST_SCHEMA );
+ enableSchema( NIS_SCHEMA );
ModificationItem[] mods = new ModificationItem[1];
Attribute attr = new BasicAttribute( "m-dependencies", "mozilla" );
mods[0] = new ModificationItem( DirContext.ADD_ATTRIBUTE, attr );
try
{
- schemaRoot.modifyAttributes( "cn=" + TEST_SCHEMA, mods );
+ schemaRoot.modifyAttributes( "cn=" + NIS_SCHEMA, mods );
fail( "Should not be able to add disabled dependency to schema" );
}
catch ( LdapOperationNotSupportedException e )
@@ -683,8 +779,8 @@
ModificationItem[] mods = new ModificationItem[1];
Attribute attr = new BasicAttribute( "m-dependencies", "mozilla" );
mods[0] = new ModificationItem( DirContext.ADD_ATTRIBUTE, attr );
- schemaRoot.modifyAttributes( "cn=" + TEST_SCHEMA, mods );
- Attributes attrs = schemaRoot.getAttributes( "cn=" + TEST_SCHEMA );
+ schemaRoot.modifyAttributes( "cn=" + NIS_SCHEMA, mods );
+ Attributes attrs = schemaRoot.getAttributes( "cn=" + NIS_SCHEMA );
Attribute dependencies = attrs.get( "m-dependencies" );
assertTrue( dependencies.contains( "mozilla" ) );
}
@@ -703,8 +799,8 @@
ModificationItem[] mods = new ModificationItem[1];
Attribute attr = new BasicAttribute( "m-dependencies", "java" );
mods[0] = new ModificationItem( DirContext.ADD_ATTRIBUTE, attr );
- schemaRoot.modifyAttributes( "cn=" + TEST_SCHEMA, mods );
- Attributes attrs = schemaRoot.getAttributes( "cn=" + TEST_SCHEMA );
+ schemaRoot.modifyAttributes( "cn=" + NIS_SCHEMA, mods );
+ Attributes attrs = schemaRoot.getAttributes( "cn=" + NIS_SCHEMA );
Attribute dependencies = attrs.get( "m-dependencies" );
assertTrue( dependencies.contains( "java" ) );
}
Modified: directory/apacheds/branches/apacheds-mina2/core-shared/src/main/java/org/apache/directory/server/schema/bootstrap/AbstractBootstrapSchema.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-mina2/core-shared/src/main/java/org/apache/directory/server/schema/bootstrap/AbstractBootstrapSchema.java?rev=721517&r1=721516&r2=721517&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-mina2/core-shared/src/main/java/org/apache/directory/server/schema/bootstrap/AbstractBootstrapSchema.java
(original)
+++ directory/apacheds/branches/apacheds-mina2/core-shared/src/main/java/org/apache/directory/server/schema/bootstrap/AbstractBootstrapSchema.java
Fri Nov 28 07:26:11 2008
@@ -31,7 +31,7 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$
*/
-public class AbstractBootstrapSchema implements BootstrapSchema
+public abstract class AbstractBootstrapSchema implements BootstrapSchema
{
protected static final String[] DEFAULT_DEPS = ArrayUtils.EMPTY_STRING_ARRAY;
private static final String DEFAULT_OWNER = ServerDNConstants.ADMIN_SYSTEM_DN;
@@ -194,8 +194,36 @@
}
+ /**
+ * {@inheritDoc}
+ */
public boolean isDisabled()
{
return false;
}
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isEnabled()
+ {
+ return true;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void disable()
+ {
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void enable()
+ {
+ }
}
Modified: directory/apacheds/branches/apacheds-mina2/core-shared/src/main/java/org/apache/directory/server/schema/bootstrap/Schema.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-mina2/core-shared/src/main/java/org/apache/directory/server/schema/bootstrap/Schema.java?rev=721517&r1=721516&r2=721517&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-mina2/core-shared/src/main/java/org/apache/directory/server/schema/bootstrap/Schema.java
(original)
+++ directory/apacheds/branches/apacheds-mina2/core-shared/src/main/java/org/apache/directory/server/schema/bootstrap/Schema.java
Fri Nov 28 07:26:11 2008
@@ -35,6 +35,27 @@
*/
boolean isDisabled();
+
+ /**
+ * Disable the schema
+ */
+ void disable();
+
+
+ /**
+ * Checks whether or not this schema is enabled or disabled.
+ *
+ * @return true if this schema is enabled, false otherwise
+ */
+ boolean isEnabled();
+
+
+ /**
+ * Enable the schema
+ */
+ void enable();
+
+
/**
* Gets the name of the owner of the schema objects within this
* Schema.
Modified: directory/apacheds/branches/apacheds-mina2/core/src/main/java/org/apache/directory/server/core/schema/AbstractSchema.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-mina2/core/src/main/java/org/apache/directory/server/core/schema/AbstractSchema.java?rev=721517&r1=721516&r2=721517&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-mina2/core/src/main/java/org/apache/directory/server/core/schema/AbstractSchema.java
(original)
+++ directory/apacheds/branches/apacheds-mina2/core/src/main/java/org/apache/directory/server/core/schema/AbstractSchema.java
Fri Nov 28 07:26:11 2008
@@ -110,8 +110,38 @@
}
+ /**
+ * {@inheritDoc}
+ */
public boolean isDisabled()
{
return disabled;
}
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isEnabled()
+ {
+ return !disabled;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void disable()
+ {
+ this.disabled = true;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void enable()
+ {
+ this.disabled = false;
+ }
}
Modified: directory/apacheds/branches/apacheds-mina2/core/src/main/java/org/apache/directory/server/core/schema/AbstractSchemaChangeHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-mina2/core/src/main/java/org/apache/directory/server/core/schema/AbstractSchemaChangeHandler.java?rev=721517&r1=721516&r2=721517&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-mina2/core/src/main/java/org/apache/directory/server/core/schema/AbstractSchemaChangeHandler.java
(original)
+++ directory/apacheds/branches/apacheds-mina2/core/src/main/java/org/apache/directory/server/core/schema/AbstractSchemaChangeHandler.java
Fri Nov 28 07:26:11 2008
@@ -96,21 +96,21 @@
}
- protected abstract void modify( LdapDN name, ServerEntry entry, ServerEntry targetEntry,
boolean cascade )
+ protected abstract boolean modify( LdapDN name, ServerEntry entry, ServerEntry targetEntry,
boolean cascade )
throws Exception;
- public final void 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
{
- modify( name, entry, targetEntry, cascade );
+ return modify( name, entry, targetEntry, cascade );
}
- public final void modify( LdapDN name, List<Modification> mods, ServerEntry entry,
+ public final boolean modify( LdapDN name, List<Modification> mods, ServerEntry
entry,
ServerEntry targetEntry, boolean cascade ) throws Exception
{
- modify( name, entry, targetEntry, cascade );
+ return modify( name, entry, targetEntry, cascade );
}
Modified: directory/apacheds/branches/apacheds-mina2/core/src/main/java/org/apache/directory/server/core/schema/MetaAttributeTypeHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-mina2/core/src/main/java/org/apache/directory/server/core/schema/MetaAttributeTypeHandler.java?rev=721517&r1=721516&r2=721517&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-mina2/core/src/main/java/org/apache/directory/server/core/schema/MetaAttributeTypeHandler.java
(original)
+++ directory/apacheds/branches/apacheds-mina2/core/src/main/java/org/apache/directory/server/core/schema/MetaAttributeTypeHandler.java
Fri Nov 28 07:26:11 2008
@@ -62,7 +62,7 @@
}
- protected void modify( LdapDN name, ServerEntry entry, ServerEntry targetEntry, boolean
cascade )
+ protected boolean modify( LdapDN name, ServerEntry entry, ServerEntry targetEntry, boolean
cascade )
throws Exception
{
String oid = getOid( entry );
@@ -73,7 +73,11 @@
{
attributeTypeRegistry.unregister( oid );
attributeTypeRegistry.register( at );
+
+ return SCHEMA_MODIFIED;
}
+
+ return SCHEMA_UNCHANGED;
}
Modified: directory/apacheds/branches/apacheds-mina2/core/src/main/java/org/apache/directory/server/core/schema/MetaComparatorHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-mina2/core/src/main/java/org/apache/directory/server/core/schema/MetaComparatorHandler.java?rev=721517&r1=721516&r2=721517&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-mina2/core/src/main/java/org/apache/directory/server/core/schema/MetaComparatorHandler.java
(original)
+++ directory/apacheds/branches/apacheds-mina2/core/src/main/java/org/apache/directory/server/core/schema/MetaComparatorHandler.java
Fri Nov 28 07:26:11 2008
@@ -75,7 +75,7 @@
}
- protected void modify( LdapDN name, ServerEntry entry, ServerEntry targetEntry, boolean
cascade ) throws Exception
+ protected boolean modify( LdapDN name, ServerEntry entry, ServerEntry targetEntry, boolean
cascade ) throws Exception
{
String oid = getOid( entry );
Comparator comparator = factory.getComparator( targetEntry, targetRegistries );
@@ -86,7 +86,11 @@
comparatorRegistry.unregister( oid );
ComparatorDescription description = getComparatorDescription( schema.getSchemaName(),
targetEntry );
comparatorRegistry.register( description, comparator );
+
+ return SCHEMA_MODIFIED;
}
+
+ return SCHEMA_UNCHANGED;
}
Modified: directory/apacheds/branches/apacheds-mina2/core/src/main/java/org/apache/directory/server/core/schema/MetaDitContentRuleHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-mina2/core/src/main/java/org/apache/directory/server/core/schema/MetaDitContentRuleHandler.java?rev=721517&r1=721516&r2=721517&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-mina2/core/src/main/java/org/apache/directory/server/core/schema/MetaDitContentRuleHandler.java
(original)
+++ directory/apacheds/branches/apacheds-mina2/core/src/main/java/org/apache/directory/server/core/schema/MetaDitContentRuleHandler.java
Fri Nov 28 07:26:11 2008
@@ -49,11 +49,11 @@
* @see org.apache.directory.server.core.schema.AbstractSchemaChangeHandler#modify(org.apache.directory.shared.ldap.name.LdapDN,
javax.naming.directory.Attributes, javax.naming.directory.Attributes)
*/
@Override
- protected void modify( LdapDN name, ServerEntry entry, ServerEntry targetEntry, boolean
cascade )
+ protected boolean modify( LdapDN name, ServerEntry entry, ServerEntry targetEntry, boolean
cascade )
throws NamingException
{
// TODO Auto-generated method stub
-
+ return SCHEMA_UNCHANGED;
}
Modified: directory/apacheds/branches/apacheds-mina2/core/src/main/java/org/apache/directory/server/core/schema/MetaDitStructureRuleHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-mina2/core/src/main/java/org/apache/directory/server/core/schema/MetaDitStructureRuleHandler.java?rev=721517&r1=721516&r2=721517&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-mina2/core/src/main/java/org/apache/directory/server/core/schema/MetaDitStructureRuleHandler.java
(original)
+++ directory/apacheds/branches/apacheds-mina2/core/src/main/java/org/apache/directory/server/core/schema/MetaDitStructureRuleHandler.java
Fri Nov 28 07:26:11 2008
@@ -51,11 +51,11 @@
* javax.naming.directory.Attributes)
*/
@Override
- protected void modify( LdapDN name, ServerEntry entry, ServerEntry targetEntry,
+ protected boolean modify( LdapDN name, ServerEntry entry, ServerEntry targetEntry,
boolean cascade ) throws NamingException
{
// TODO Auto-generated method stub
-
+ return SCHEMA_UNCHANGED;
}
Modified: directory/apacheds/branches/apacheds-mina2/core/src/main/java/org/apache/directory/server/core/schema/MetaMatchingRuleHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-mina2/core/src/main/java/org/apache/directory/server/core/schema/MetaMatchingRuleHandler.java?rev=721517&r1=721516&r2=721517&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-mina2/core/src/main/java/org/apache/directory/server/core/schema/MetaMatchingRuleHandler.java
(original)
+++ directory/apacheds/branches/apacheds-mina2/core/src/main/java/org/apache/directory/server/core/schema/MetaMatchingRuleHandler.java
Fri Nov 28 07:26:11 2008
@@ -61,7 +61,7 @@
}
- protected void modify( LdapDN name, ServerEntry entry, ServerEntry targetEntry,
+ protected boolean modify( LdapDN name, ServerEntry entry, ServerEntry targetEntry,
boolean cascade ) throws Exception
{
String oid = getOid( entry );
@@ -72,7 +72,11 @@
{
matchingRuleRegistry.unregister( oid );
matchingRuleRegistry.register( mr );
+
+ return SCHEMA_MODIFIED;
}
+
+ return SCHEMA_UNCHANGED;
}
Modified: directory/apacheds/branches/apacheds-mina2/core/src/main/java/org/apache/directory/server/core/schema/MetaMatchingRuleUseHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-mina2/core/src/main/java/org/apache/directory/server/core/schema/MetaMatchingRuleUseHandler.java?rev=721517&r1=721516&r2=721517&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-mina2/core/src/main/java/org/apache/directory/server/core/schema/MetaMatchingRuleUseHandler.java
(original)
+++ directory/apacheds/branches/apacheds-mina2/core/src/main/java/org/apache/directory/server/core/schema/MetaMatchingRuleUseHandler.java
Fri Nov 28 07:26:11 2008
@@ -46,10 +46,12 @@
@Override
- protected void modify( LdapDN name, ServerEntry entry, ServerEntry targetEntry,
+ protected boolean modify( LdapDN name, ServerEntry entry, ServerEntry targetEntry,
boolean cascade ) throws NamingException
{
// TODO Auto-generated method stub
+
+ return SCHEMA_UNCHANGED;
}
Modified: directory/apacheds/branches/apacheds-mina2/core/src/main/java/org/apache/directory/server/core/schema/MetaNameFormHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-mina2/core/src/main/java/org/apache/directory/server/core/schema/MetaNameFormHandler.java?rev=721517&r1=721516&r2=721517&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-mina2/core/src/main/java/org/apache/directory/server/core/schema/MetaNameFormHandler.java
(original)
+++ directory/apacheds/branches/apacheds-mina2/core/src/main/java/org/apache/directory/server/core/schema/MetaNameFormHandler.java
Fri Nov 28 07:26:11 2008
@@ -51,11 +51,12 @@
* javax.naming.directory.Attributes)
*/
@Override
- protected void modify( LdapDN name, ServerEntry entry, ServerEntry targetEntry,
+ protected boolean modify( LdapDN name, ServerEntry entry, ServerEntry targetEntry,
boolean cascade ) throws NamingException
{
// TODO Auto-generated method stub
-
+
+ return SCHEMA_UNCHANGED;
}
Modified: directory/apacheds/branches/apacheds-mina2/core/src/main/java/org/apache/directory/server/core/schema/MetaNormalizerHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-mina2/core/src/main/java/org/apache/directory/server/core/schema/MetaNormalizerHandler.java?rev=721517&r1=721516&r2=721517&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-mina2/core/src/main/java/org/apache/directory/server/core/schema/MetaNormalizerHandler.java
(original)
+++ directory/apacheds/branches/apacheds-mina2/core/src/main/java/org/apache/directory/server/core/schema/MetaNormalizerHandler.java
Fri Nov 28 07:26:11 2008
@@ -104,7 +104,7 @@
}
- protected void modify( LdapDN name, ServerEntry entry, ServerEntry targetEntry, boolean
cascade ) throws Exception
+ protected boolean modify( LdapDN name, ServerEntry entry, ServerEntry targetEntry, boolean
cascade ) throws Exception
{
String oid = getOid( entry );
Normalizer normalizer = factory.getNormalizer( targetEntry, targetRegistries );
@@ -116,7 +116,11 @@
NormalizerDescription normalizerDescription = getNormalizerDescription( schema.getSchemaName(),
targetEntry );
normalizerRegistry.register( normalizerDescription, normalizer );
+
+ return SCHEMA_MODIFIED;
}
+
+ return SCHEMA_UNCHANGED;
}
Modified: directory/apacheds/branches/apacheds-mina2/core/src/main/java/org/apache/directory/server/core/schema/MetaObjectClassHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-mina2/core/src/main/java/org/apache/directory/server/core/schema/MetaObjectClassHandler.java?rev=721517&r1=721516&r2=721517&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-mina2/core/src/main/java/org/apache/directory/server/core/schema/MetaObjectClassHandler.java
(original)
+++ directory/apacheds/branches/apacheds-mina2/core/src/main/java/org/apache/directory/server/core/schema/MetaObjectClassHandler.java
Fri Nov 28 07:26:11 2008
@@ -61,7 +61,7 @@
}
- protected void modify( LdapDN name, ServerEntry entry, ServerEntry targetEntry,
+ protected boolean modify( LdapDN name, ServerEntry entry, ServerEntry targetEntry,
boolean cascade ) throws Exception
{
String oid = getOid( entry );
@@ -72,7 +72,11 @@
{
objectClassRegistry.unregister( oid );
objectClassRegistry.register( oc );
+
+ return SCHEMA_MODIFIED;
}
+
+ return SCHEMA_UNCHANGED;
}
Modified: directory/apacheds/branches/apacheds-mina2/core/src/main/java/org/apache/directory/server/core/schema/MetaSchemaHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-mina2/core/src/main/java/org/apache/directory/server/core/schema/MetaSchemaHandler.java?rev=721517&r1=721516&r2=721517&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-mina2/core/src/main/java/org/apache/directory/server/core/schema/MetaSchemaHandler.java
(original)
+++ directory/apacheds/branches/apacheds-mina2/core/src/main/java/org/apache/directory/server/core/schema/MetaSchemaHandler.java
Fri Nov 28 07:26:11 2008
@@ -87,9 +87,11 @@
* @param mods the attribute modifications as an Attributes object
* @param entry the entry after the modifications have been applied
*/
- public void modify( LdapDN name, ModificationOperation modOp, ServerEntry mods, ServerEntry
entry,
+ public boolean modify( LdapDN name, ModificationOperation modOp, ServerEntry mods, ServerEntry
entry,
ServerEntry targetEntry, boolean cascade ) throws Exception
{
+ boolean hasModification = SCHEMA_UNCHANGED;
+
EntryAttribute disabledInMods = mods.get( disabledAT );
if ( disabledInMods != null )
@@ -116,6 +118,8 @@
{
checkForDependencies( isEnabled, targetEntry );
}
+
+ return hasModification;
}
@@ -128,15 +132,19 @@
* @param mods the attribute modifications as an ModificationItem arry
* @param entry the entry after the modifications have been applied
*/
- public void modify( LdapDN name, List<Modification> mods, ServerEntry entry,
+ public boolean modify( LdapDN name, List<Modification> mods, ServerEntry entry,
ServerEntry targetEntry, boolean cascade ) throws Exception
{
+ boolean hasModification = SCHEMA_UNCHANGED;
+
+ // Check if the entry has a m-disabled attribute
EntryAttribute disabledInEntry = entry.get( disabledAT );
Modification disabledModification = ServerEntryUtils.getModificationItem( mods, disabledAT
);
if ( disabledModification != null )
{
- disable( name,
+ // We are trying to modify the m-disabled attribute.
+ hasModification = disable( name,
disabledModification.getOperation(),
(ServerAttribute)disabledModification.getAttribute(),
disabledInEntry );
@@ -161,6 +169,8 @@
{
checkForDependencies( isEnabled, targetEntry );
}
+
+ return hasModification;
}
@@ -380,7 +390,7 @@
// -----------------------------------------------------------------------
- private void disable( LdapDN name, ModificationOperation modOp, EntryAttribute disabledInMods,
EntryAttribute disabledInEntry )
+ private boolean disable( LdapDN name, ModificationOperation modOp, EntryAttribute disabledInMods,
EntryAttribute disabledInEntry )
throws Exception
{
switch ( modOp )
@@ -394,7 +404,7 @@
{
if ( "TRUE".equalsIgnoreCase( disabledInMods.getString() ) )
{
- disableSchema( getSchemaName( name ) );
+ return disableSchema( getSchemaName( name ) );
}
}
@@ -405,9 +415,9 @@
* disabled. If so we enable the schema.
*/
case REMOVE_ATTRIBUTE :
- if ( "TRUE".equalsIgnoreCase( disabledInEntry.getString() ) )
+ if ( ( disabledInEntry != null ) && ( "TRUE".equalsIgnoreCase( disabledInEntry.getString()
) ) )
{
- enableSchema( getSchemaName( name ) );
+ return enableSchema( getSchemaName( name ) );
}
break;
@@ -418,18 +428,29 @@
* schema is not disabled we disable it if the mods set m-disabled to true.
*/
case REPLACE_ATTRIBUTE :
- boolean isCurrentlyDisabled = "TRUE".equalsIgnoreCase( disabledInEntry.getString()
);
- boolean isNewStateDisabled = "TRUE".equalsIgnoreCase( disabledInMods.getString()
);
+
+ boolean isCurrentlyDisabled = false;
+
+ if ( disabledInEntry != null )
+ {
+ isCurrentlyDisabled = "TRUE".equalsIgnoreCase( disabledInEntry.getString()
);
+ }
+
+ boolean isNewStateDisabled = false;
+
+ if ( disabledInMods != null )
+ {
+ isNewStateDisabled = "TRUE".equalsIgnoreCase( disabledInMods.getString()
);
+ }
if ( isCurrentlyDisabled && !isNewStateDisabled )
{
- enableSchema( getSchemaName( name ) );
- break;
+ return enableSchema( getSchemaName( name ) );
}
if ( !isCurrentlyDisabled && isNewStateDisabled )
{
- disableSchema( getSchemaName( name ) );
+ return disableSchema( getSchemaName( name ) );
}
break;
@@ -437,6 +458,8 @@
default:
throw new IllegalArgumentException( "Unknown modify operation type: " + modOp
);
}
+
+ return SCHEMA_UNCHANGED;
}
@@ -446,17 +469,32 @@
}
- private void disableSchema( String schemaName ) throws Exception
+ private boolean disableSchema( String schemaName ) throws Exception
{
+ // First check that the schema is not already disabled
+ Map<String, Schema> schemas = globalRegistries.getLoadedSchemas();
+
+ Schema schema = schemas.get( schemaName );
+
+ if ( ( schema == null ) || schema.isDisabled() )
+ {
+ // The schema is disabled, do nothing
+ return SCHEMA_UNCHANGED;
+ }
+
Set<String> dependents = loader.listEnabledDependentSchemaNames( schemaName
);
+
if ( ! dependents.isEmpty() )
{
throw new LdapOperationNotSupportedException(
"Cannot disable schema with enabled dependents: " + dependents,
ResultCodeEnum.UNWILLING_TO_PERFORM );
}
+ schema.disable();
globalRegistries.unload( schemaName );
+
+ return SCHEMA_MODIFIED;
}
@@ -464,16 +502,19 @@
* TODO - for now we're just going to add the schema to the global
* registries ... we may need to add it to more than that though later.
*/
- private void enableSchema( String schemaName ) throws Exception
+ private boolean enableSchema( String schemaName ) throws Exception
{
if ( globalRegistries.getLoadedSchemas().containsKey( schemaName ) )
{
// TODO log warning: schemaName + " was already loaded"
- return;
+ return SCHEMA_UNCHANGED;
}
Schema schema = loader.getSchema( schemaName );
loader.loadWithDependencies( schema, globalRegistries );
+ schema.enable();
+
+ return SCHEMA_MODIFIED;
}
Modified: directory/apacheds/branches/apacheds-mina2/core/src/main/java/org/apache/directory/server/core/schema/MetaSyntaxCheckerHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-mina2/core/src/main/java/org/apache/directory/server/core/schema/MetaSyntaxCheckerHandler.java?rev=721517&r1=721516&r2=721517&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-mina2/core/src/main/java/org/apache/directory/server/core/schema/MetaSyntaxCheckerHandler.java
(original)
+++ directory/apacheds/branches/apacheds-mina2/core/src/main/java/org/apache/directory/server/core/schema/MetaSyntaxCheckerHandler.java
Fri Nov 28 07:26:11 2008
@@ -103,7 +103,7 @@
}
- protected void modify( LdapDN name, ServerEntry entry, ServerEntry targetEntry, boolean
cascade ) throws Exception
+ protected boolean modify( LdapDN name, ServerEntry entry, ServerEntry targetEntry, boolean
cascade ) throws Exception
{
String oid = getOid( entry );
SyntaxChecker syntaxChecker = factory.getSyntaxChecker( targetEntry, targetRegistries
);
@@ -116,7 +116,10 @@
SyntaxCheckerDescription syntaxCheckerDescription =
getSyntaxCheckerDescription( schema.getSchemaName(), targetEntry );
syntaxCheckerRegistry.register( syntaxCheckerDescription, syntaxChecker );
+ return SCHEMA_MODIFIED;
}
+
+ return SCHEMA_UNCHANGED;
}
Modified: directory/apacheds/branches/apacheds-mina2/core/src/main/java/org/apache/directory/server/core/schema/MetaSyntaxHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-mina2/core/src/main/java/org/apache/directory/server/core/schema/MetaSyntaxHandler.java?rev=721517&r1=721516&r2=721517&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-mina2/core/src/main/java/org/apache/directory/server/core/schema/MetaSyntaxHandler.java
(original)
+++ directory/apacheds/branches/apacheds-mina2/core/src/main/java/org/apache/directory/server/core/schema/MetaSyntaxHandler.java
Fri Nov 28 07:26:11 2008
@@ -61,7 +61,7 @@
}
- protected void modify( LdapDN name, ServerEntry entry, ServerEntry targetEntry,
+ protected boolean modify( LdapDN name, ServerEntry entry, ServerEntry targetEntry,
boolean cascade ) throws Exception
{
String oid = getOid( entry );
@@ -72,7 +72,11 @@
{
syntaxRegistry.unregister( oid );
syntaxRegistry.register( syntax );
+
+ return SCHEMA_MODIFIED;
}
+
+ return SCHEMA_UNCHANGED;
}
Modified: directory/apacheds/branches/apacheds-mina2/core/src/main/java/org/apache/directory/server/core/schema/SchemaChangeHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-mina2/core/src/main/java/org/apache/directory/server/core/schema/SchemaChangeHandler.java?rev=721517&r1=721516&r2=721517&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-mina2/core/src/main/java/org/apache/directory/server/core/schema/SchemaChangeHandler.java
(original)
+++ directory/apacheds/branches/apacheds-mina2/core/src/main/java/org/apache/directory/server/core/schema/SchemaChangeHandler.java
Fri Nov 28 07:26:11 2008
@@ -38,16 +38,22 @@
*/
public interface SchemaChangeHandler
{
+ /** A constant to tell the caller that the schema has been modified */
+ static final boolean SCHEMA_MODIFIED = true;
+
+ /** A constant to tell the caller that the schema has not been modified */
+ static final boolean SCHEMA_UNCHANGED = false;
+
void add( LdapDN name, ServerEntry entry ) throws Exception;
void delete( LdapDN name, ServerEntry entry, boolean cascaded ) throws Exception;
void rename( LdapDN name, ServerEntry entry, Rdn newRdn, boolean cascaded ) throws Exception;
- void modify( LdapDN name, ModificationOperation modOp, ServerEntry mods, ServerEntry
entry, ServerEntry targetEntry, boolean cascaded )
+ boolean modify( LdapDN name, ModificationOperation modOp, ServerEntry mods, ServerEntry
entry, ServerEntry targetEntry, boolean cascaded )
throws Exception;
- void modify( LdapDN name, List<Modification> mods, ServerEntry entry, ServerEntry
targetEntry, boolean cascaded )
+ boolean modify( LdapDN name, List<Modification> mods, ServerEntry entry, ServerEntry
targetEntry, boolean cascaded )
throws Exception;
void move( LdapDN oriChildName, LdapDN newParentName, Rdn newRn, boolean deleteOldRn,
ServerEntry entry,
Modified: directory/apacheds/branches/apacheds-mina2/core/src/main/java/org/apache/directory/server/core/schema/SchemaOperationControl.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-mina2/core/src/main/java/org/apache/directory/server/core/schema/SchemaOperationControl.java?rev=721517&r1=721516&r2=721517&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-mina2/core/src/main/java/org/apache/directory/server/core/schema/SchemaOperationControl.java
(original)
+++ directory/apacheds/branches/apacheds-mina2/core/src/main/java/org/apache/directory/server/core/schema/SchemaOperationControl.java
Fri Nov 28 07:26:11 2008
@@ -435,8 +435,13 @@
if ( oc.contains( MetaSchemaConstants.META_SCHEMA_OC ) )
{
- metaSchemaHandler.modify( opContext.getDn(), opContext.getModItems(), entry,
targetEntry, doCascadeModify );
- updateSchemaModificationAttributes( opContext );
+ boolean isSchemaModified = metaSchemaHandler.modify( opContext.getDn(), opContext.getModItems(),
entry, targetEntry, doCascadeModify );
+
+ if ( isSchemaModified )
+ {
+ updateSchemaModificationAttributes( opContext );
+ }
+
return;
}
|