directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r802884 - /directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/SchemaInterceptor.java
Date Mon, 10 Aug 2009 18:25:38 GMT
Author: elecharny
Date: Mon Aug 10 18:25:38 2009
New Revision: 802884

URL: http://svn.apache.org/viewvc?rev=802884&view=rev
Log:
Hack added to deal with removal of not existing values

Modified:
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/SchemaInterceptor.java

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/SchemaInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/SchemaInterceptor.java?rev=802884&r1=802883&r2=802884&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/SchemaInterceptor.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/SchemaInterceptor.java
Mon Aug 10 18:25:38 2009
@@ -1240,6 +1240,9 @@
             // Get the entry we already read at the beginning
             entry = opContext.getEntry();
         }
+        
+        boolean schemaModification = name.startsWith( schemaBaseDN );
+        boolean subSchemaModification = subschemaSubentryDnNorm.equals( name.getNormName()
);
 
         // First, we get the entry from the backend. If it does not exist, then we throw
an exception
         ServerEntry targetEntry = (ServerEntry)SchemaUtils.getTargetEntry( mods , entry );
@@ -1310,7 +1313,7 @@
         else
         {
             objectClass = getResultantObjectClasses( objectClassMod.getOperation(), objectClassMod.getAttribute(),
-                tmpEntry.get( SchemaConstants.OBJECT_CLASS_AT ) );
+                tmpEntry.get( SchemaConstants.OBJECT_CLASS_AT ).clone() );
         }
 
         ObjectClassRegistry ocRegistry = this.registries.getObjectClassRegistry();
@@ -1409,7 +1412,15 @@
                         // And inject back the values except the ones to remove
                         for ( Value<?> value : change )
                         {
-                            modified.remove( value );
+                            if ( modified.contains( value ) )
+                            {
+                                modified.remove( value );
+                            }
+                            else if ( !subSchemaModification )
+                            {
+                                // We are trying to remove an not existing value : error
+                                throw new LdapNoSuchAttributeException( "Value " + value
+ " does not exist in the " + modified + " AT" );
+                            }
                         }
 
                         // ok, done. Last check : if the attribute does not content any more
value;
@@ -1518,14 +1529,14 @@
             }
         }
 
-        if ( name.startsWith( schemaBaseDN ) )
+        if ( schemaModification )
         {
             LOG.debug( "Modification attempt on schema partition {}: \n{}", name, opContext
);
 
             schemaManager.modify( opContext, entry, targetEntry, opContext
                 .hasRequestControl( CascadeControl.CONTROL_OID ) );
         }
-        else if ( subschemaSubentryDnNorm.equals( name.getNormName() ) )
+        else if ( subSchemaModification )
         {
             LOG.debug( "Modification attempt on schema subentry {}: \n{}", name, opContext
);
 



Mime
View raw message