directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r823497 - in /directory: apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/ shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/reg...
Date Fri, 09 Oct 2009 10:09:50 GMT
Author: elecharny
Date: Fri Oct  9 10:09:49 2009
New Revision: 823497

URL: http://svn.apache.org/viewvc?rev=823497&view=rev
Log:
Fixed many problems with cross references

Modified:
    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/MatchingRuleSynchronizer.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/SyntaxSynchronizer.java
    directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/Registries.java

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=823497&r1=823496&r2=823497&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 10:09:49 2009
@@ -393,11 +393,11 @@
     {
         StringBuilder sb = new StringBuilder();
         
-        Set<SchemaObject> usings = registries.getUsing( schemaObject );
+        Set<SchemaWrapper> useds = registries.getUsedBy( schemaObject );
         
-        for ( SchemaObject using:usings )
+        for ( SchemaWrapper used:useds )
         {
-            sb.append( using );
+            sb.append( used );
             sb.append( '\n' );
         }
         

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=823497&r1=823496&r2=823497&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 10:09:49 2009
@@ -167,6 +167,14 @@
         String schemaName = getSchemaName( entry.getDn() );
         AttributeType attributeType = factory.getAttributeType( entry, registries, schemaName
);
         
+        // Applies the Registries to this AttributeType 
+        Schema schema = registries.getLoadedSchema( schemaName );
+        
+        if ( schema.isEnabled() && attributeType.isEnabled() )
+        {
+            attributeType.applyRegistries( registries );
+        }
+        
         String oid = attributeType.getOid();
         
         // Depending on the fact that the schema is enabled or disabled, we will have
@@ -194,20 +202,20 @@
         // 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.
+            // Update the references.
             // The Syntax
-            registries.delReference( attributeType.getSyntax(), attributeType );
+            registries.delReference( attributeType, attributeType.getSyntax() );
             
             // The Superior
-            registries.delReference( attributeType.getSuperior(), attributeType );
+            registries.delReference( attributeType, attributeType.getSuperior() );
             
             // The MatchingRules
-            registries.delReference( attributeType.getEquality(), attributeType );
-            registries.delReference( attributeType.getOrdering(), attributeType );
-            registries.delReference( attributeType.getSubstring(), attributeType );
+            registries.delReference( attributeType, attributeType.getEquality() );
+            registries.delReference( attributeType, attributeType.getOrdering() );
+            registries.delReference( attributeType, attributeType.getSubstring() );
+            
+            // Update the Registry
+            atRegistry.unregister( attributeType.getOid() );
             
             LOG.debug( "Removed {} from the enabled schema {}", attributeType, schemaName
);
         }

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=823497&r1=823496&r2=823497&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 10:09:49 2009
@@ -168,6 +168,14 @@
         MatchingRule matchingRule = factory.getMatchingRule( entry, registries, schemaName
);
         String oid = matchingRule.getOid();
         
+        // Applies the Registries to this MatchingRule 
+        Schema schema = registries.getLoadedSchema( schemaName );
+
+        if ( schema.isEnabled() && matchingRule.isEnabled() )
+        {
+            matchingRule.applyRegistries( registries );
+        }
+        
         deleteFromSchema( matchingRule, schemaName );
         
         if ( matchingRuleRegistry.contains( oid ) )
@@ -182,7 +190,9 @@
             // The Comparator
             registries.delReference( matchingRule, matchingRule.getLdapComparator() );
 
+            // Update the registry
             matchingRuleRegistry.unregister( matchingRule.getOid() );
+            
             LOG.debug( "Removed {} from the enabled schema {}", matchingRule, schemaName
);
         }
         else

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=823497&r1=823496&r2=823497&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 10:09:49 2009
@@ -171,6 +171,14 @@
         String schemaName = getSchemaName( entry.getDn() );
         ObjectClass objectClass = factory.getObjectClass( entry, registries, schemaName );
 
+        // Applies the Registries to this ObjectClass 
+        Schema schema = registries.getLoadedSchema( schemaName );
+
+        if ( schema.isEnabled() && objectClass.isEnabled() )
+        {
+            objectClass.applyRegistries( registries );
+        }
+        
         String oid = objectClass.getOid();
 
         if ( isSchemaEnabled( schemaName ) )
@@ -208,7 +216,9 @@
                 registries.delReference( objectClass, superior );
             }
             
+            // Update the Registry
             objectClassRegistry.unregister( objectClass.getOid() );
+            
             LOG.debug( "Removed {} from the enabled schema {}", objectClass, schemaName );
         }
         else

Modified: directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/SyntaxSynchronizer.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/SyntaxSynchronizer.java?rev=823497&r1=823496&r2=823497&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/SyntaxSynchronizer.java
(original)
+++ directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/SyntaxSynchronizer.java
Fri Oct  9 10:09:49 2009
@@ -119,7 +119,7 @@
         String schemaName = getSchemaName( dn );
         LdapSyntax syntax = factory.getSyntax( entry, registries, schemaName );
 
-        // Applies the Registrie sto this Syntax 
+        // Applies the Registries to this Syntax 
         Schema schema = registries.getLoadedSchema( schemaName );
 
         if ( schema.isEnabled() && syntax.isEnabled() )
@@ -219,6 +219,14 @@
         String schemaName = getSchemaName( entry.getDn() );
         LdapSyntax syntax = factory.getSyntax( entry, registries, schemaName );
         
+        // Applies the Registries to this Syntax 
+        Schema schema = registries.getLoadedSchema( schemaName );
+
+        if ( schema.isEnabled() && syntax.isEnabled() )
+        {
+            syntax.applyRegistries( registries );
+        }
+
         String oid = syntax.getOid();
         
         if ( isSchemaEnabled( schemaName ) )
@@ -236,11 +244,12 @@
 
         if ( syntaxRegistry.contains( oid ) )
         {
-            syntaxRegistry.unregister( oid );
-            
-            // Now, update the references.
+            // Update the references.
             // The SyntaxChecker
-            registries.delReference( syntax.getSyntaxChecker(), syntax );
+            registries.delReference( syntax, syntax.getSyntaxChecker() );
+            
+            // Update the Registry
+            syntaxRegistry.unregister( oid );
             
             LOG.debug( "Removed {} from the enabled schema {}", syntax, schemaName );
         }

Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/Registries.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/Registries.java?rev=823497&r1=823496&r2=823497&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/Registries.java
(original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/Registries.java
Fri Oct  9 10:09:49 2009
@@ -103,13 +103,13 @@
      *  A map storing a relation between a SchemaObject and all the 
      *  referencing SchemaObjects.
      */
-    protected Map<SchemaWrapper, Set<SchemaObject>> usedBy;
+    protected Map<SchemaWrapper, Set<SchemaWrapper>> usedBy;
     
     /**
      *  A map storing a relation between a SchemaObject and all the 
      *  SchemaObjects it uses.
      */
-    protected Map<SchemaWrapper, Set<SchemaObject>> using;
+    protected Map<SchemaWrapper, Set<SchemaWrapper>> using;
     
 
     /**
@@ -131,9 +131,9 @@
         normalizerRegistry = new NormalizerRegistry( oidRegistry );
         objectClassRegistry = new ObjectClassRegistry( oidRegistry );
         syntaxCheckerRegistry = new SyntaxCheckerRegistry( oidRegistry );
-        schemaObjectsBySchemaName = new HashMap<String, Set<SchemaWrapper>>();
-        usedBy = new ConcurrentHashMap<SchemaWrapper, Set<SchemaObject>>();
-        using = new ConcurrentHashMap<SchemaWrapper, Set<SchemaObject>>();
+        schemaObjectsBySchemaName = new ConcurrentHashMap<String, Set<SchemaWrapper>>();
+        usedBy = new ConcurrentHashMap<SchemaWrapper, Set<SchemaWrapper>>();
+        using = new ConcurrentHashMap<SchemaWrapper, Set<SchemaWrapper>>();
     }
 
     
@@ -848,7 +848,7 @@
     {
         SchemaWrapper wrapper = new SchemaWrapper( schemaObject );
         
-        Set<SchemaObject> set = using.get( wrapper );
+        Set<SchemaWrapper> set = usedBy.get( wrapper );
         
         return ( set != null ) && ( set.size() != 0 );
     }
@@ -860,7 +860,7 @@
      * @param schemaObject The SchemaObject we are looking for
      * @return The Set of referencing SchemaObject, or null 
      */
-    public Set<SchemaObject> getUsedBy( SchemaObject schemaObject )
+    public Set<SchemaWrapper> getUsedBy( SchemaObject schemaObject )
     {
         SchemaWrapper wrapper = new SchemaWrapper( schemaObject );
         
@@ -868,13 +868,78 @@
     }
 
     
+    public String dumpUsedBy()
+    {
+        StringBuilder sb = new StringBuilder();
+        
+        sb.append(  "USED BY :\n" );
+        
+        for ( SchemaWrapper wrapper : usedBy.keySet() )
+        {
+            sb.append( wrapper.get().getObjectType() ).append( '[' ).append( wrapper.get().getOid()
).append( "] : {" );
+            
+            boolean isFirst = true;
+            
+            for ( SchemaWrapper uses : usedBy.get( wrapper) )
+            {
+                if ( isFirst )
+                {
+                    isFirst = false;
+                }
+                else
+                {
+                    sb.append( ", " );
+                }
+                
+                sb.append( uses.get().getObjectType() ).append( '[' ).append( wrapper.get().getOid()
).append( "]" );
+            }
+            
+            sb.append( "}\n" );
+        }
+        
+        return sb.toString();
+    }
+
+    
+    public String dumpUsing()
+    {
+        StringBuilder sb = new StringBuilder();
+        
+        sb.append(  "USING :\n" );
+
+        for ( SchemaWrapper wrapper : using.keySet() )
+        {
+            sb.append( wrapper.get().getObjectType() ).append( '[' ).append( wrapper.get().getOid()
).append( "] : {" );
+            
+            boolean isFirst = true;
+            
+            for ( SchemaWrapper uses : using.get( wrapper) )
+            {
+                if ( isFirst )
+                {
+                    isFirst = false;
+                }
+                else
+                {
+                    sb.append( ", " );
+                }
+                
+                sb.append( uses.get().getObjectType() ).append( '[' ).append( wrapper.get().getOid()
).append( "]" );
+            }
+            
+            sb.append( "}\n" );
+        }
+        
+        return sb.toString();
+    }
+    
     /**
      * Gets the Set of SchemaObjects referenced by the given SchemaObject
      *
      * @param schemaObject The SchemaObject we are looking for
      * @return The Set of referenced SchemaObject, or null 
      */
-    public Set<SchemaObject> getUsing( SchemaObject schemaObject )
+    public Set<SchemaWrapper> getUsing( SchemaObject schemaObject )
     {
         SchemaWrapper wrapper = new SchemaWrapper( schemaObject );
         
@@ -897,15 +962,17 @@
         
         SchemaWrapper wrapper = new SchemaWrapper( reference );
         
-        Set<SchemaObject> usedBy = getUsedBy( reference );
+        Set<SchemaWrapper> uses = getUsing( reference );
         
-        if ( usedBy == null )
+        if ( uses == null )
         {
-            usedBy = new HashSet<SchemaObject>();
-            using.put( wrapper, usedBy );
+            uses = new HashSet<SchemaWrapper>();
         }
         
-        usedBy.add( referee );
+        uses.add( new SchemaWrapper( referee ) );
+        
+        // Put back the set (this is a concurrentHashMap, it won't be replaced implicitly
+        using.put( wrapper, uses );
     }
     
     
@@ -917,8 +984,13 @@
      */
     public void addReference( SchemaObject reference, SchemaObject referee )
     {
+        dump( "add", reference, referee );
+
         addUsing( reference, referee );
         addUsedBy( referee, reference );
+
+        System.out.println( dumpUsedBy() );
+        System.out.println( dumpUsing() );
     }
 
 
@@ -934,17 +1006,20 @@
         {
             return;
         }
+        
         SchemaWrapper wrapper = new SchemaWrapper( referee );
         
-        Set<SchemaObject> using = getUsing( referee );
+        Set<SchemaWrapper> uses = getUsedBy( referee );
         
-        if ( using == null )
+        if ( uses == null )
         {
-            using = new HashSet<SchemaObject>();
-            usedBy.put( wrapper, using );
+            uses = new HashSet<SchemaWrapper>();
         }
         
-        using.add( reference );
+        uses.add( new SchemaWrapper( reference ) );
+        
+        // Put back the set (this is a concurrentHashMap, it won't be replaced implicitly
+        usedBy.put( wrapper, uses );
     }
     
     
@@ -961,21 +1036,25 @@
             return;
         }
         
-        Set<SchemaObject> usedBy = getUsedBy( reference );
+        Set<SchemaWrapper> uses = getUsing( reference );
         
-        if ( usedBy == null )
+        if ( uses == null )
         {
             return;
         }
         
-        usedBy.remove( referee );
+        uses.remove( new SchemaWrapper( referee ) );
+        
+        SchemaWrapper wrapper = new SchemaWrapper( reference );
         
-        if ( usedBy.size() == 0 )
+        if ( uses.size() == 0 )
         {
-            SchemaWrapper wrapper = new SchemaWrapper( reference );
-            
             using.remove( wrapper );
         }
+        else
+        {
+            using.put( wrapper, uses );
+        }
         
         return;
     }
@@ -994,21 +1073,25 @@
             return;
         }
 
-        Set<SchemaObject> using = getUsing( referee );
+        Set<SchemaWrapper> uses = getUsedBy( referee );
         
-        if ( using == null )
+        if ( uses == null )
         {
             return;
         }
         
-        using.remove( reference );
+        uses.remove( new SchemaWrapper( reference ) );
         
-        if ( using.size() == 0 )
+        SchemaWrapper wrapper = new SchemaWrapper( referee );
+
+        if ( uses.size() == 0 )
         {
-            SchemaWrapper wrapper = new SchemaWrapper( referee );
-            
             usedBy.remove( wrapper );
         }
+        else
+        {
+            usedBy.put( wrapper, uses );
+        }
         
         return;
     }
@@ -1022,7 +1105,16 @@
      */
     public void delReference( SchemaObject reference, SchemaObject referee )
     {
+        dump( "del", reference, referee );
         delUsing( reference, referee );
         delUsedBy( referee, reference );
+        System.out.println( dumpUsedBy() );
+        System.out.println( dumpUsing() );
+    }
+    
+    
+    private void dump( String op, SchemaObject reference, SchemaObject referee )
+    {
+        System.out.println( op + " : " + reference.getObjectType() + "[" + reference.getOid()
+ "]/[" + referee.getObjectType() + "[" + referee.getOid() +"]" );
     }
 }



Mime
View raw message