directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r965904 - in /directory/apacheds/branches/apacheds-subtree/core/src/main/java/org/apache/directory/server/core/subtree: SubentryCache.java SubentryInterceptor.java
Date Tue, 20 Jul 2010 16:55:00 GMT
Author: elecharny
Date: Tue Jul 20 16:55:00 2010
New Revision: 965904

URL: http://svn.apache.org/viewvc?rev=965904&view=rev
Log:
Merged changes from trunk into the branch

Modified:
    directory/apacheds/branches/apacheds-subtree/core/src/main/java/org/apache/directory/server/core/subtree/SubentryCache.java
  (contents, props changed)
    directory/apacheds/branches/apacheds-subtree/core/src/main/java/org/apache/directory/server/core/subtree/SubentryInterceptor.java
  (contents, props changed)

Modified: directory/apacheds/branches/apacheds-subtree/core/src/main/java/org/apache/directory/server/core/subtree/SubentryCache.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-subtree/core/src/main/java/org/apache/directory/server/core/subtree/SubentryCache.java?rev=965904&r1=965903&r2=965904&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-subtree/core/src/main/java/org/apache/directory/server/core/subtree/SubentryCache.java
(original)
+++ directory/apacheds/branches/apacheds-subtree/core/src/main/java/org/apache/directory/server/core/subtree/SubentryCache.java
Tue Jul 20 16:55:00 2010
@@ -20,9 +20,9 @@
 package org.apache.directory.server.core.subtree;
 
 
-import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.atomic.AtomicInteger;
 
 import org.apache.directory.shared.ldap.name.DN;
@@ -55,7 +55,7 @@ public class SubentryCache implements It
      */
     public SubentryCache()
     {
-        cache = new HashMap<DN, Subentry>();
+        cache = new ConcurrentHashMap<DN, Subentry>();
         cacheSize = new AtomicInteger( 0 );
     }
     
@@ -65,7 +65,7 @@ public class SubentryCache implements It
      */
     public SubentryCache( int maxSize )
     {
-        cache = new HashMap<DN, Subentry>();
+        cache = new ConcurrentHashMap<DN, Subentry>();
         cacheSize = new AtomicInteger( 0 );
         cacheMaxSize = maxSize;
     }
@@ -92,7 +92,6 @@ public class SubentryCache implements It
      */
     final Subentry removeSubentry( DN dn )
     {
-        int k = dn.hashCode();
         Subentry oldSubentry = cache.remove( dn );
         
         if ( oldSubentry != null )
@@ -114,7 +113,6 @@ public class SubentryCache implements It
      */
     /* No qualifier */ Subentry addSubentry( DN dn, Subentry subentry )
     {
-        int k = dn.hashCode();
         if ( cacheSize.get() > cacheMaxSize )
         {
             // TODO : Throw an exception here

Propchange: directory/apacheds/branches/apacheds-subtree/core/src/main/java/org/apache/directory/server/core/subtree/SubentryCache.java
------------------------------------------------------------------------------
--- svn:mergeinfo (added)
+++ svn:mergeinfo Tue Jul 20 16:55:00 2010
@@ -0,0 +1,4 @@
+/directory/apacheds/branches/apacheds-replication/core/src/main/java/org/apache/directory/server/core/subtree/SubentryCache.java:749790-764110
+/directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/subtree/SubentryCache.java:806623-896441
+/directory/apacheds/branches/xdbm-refactoring/core/src/main/java/org/apache/directory/server/core/subtree/SubentryCache.java:945827-946347
+/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/SubentryCache.java:965751

Modified: directory/apacheds/branches/apacheds-subtree/core/src/main/java/org/apache/directory/server/core/subtree/SubentryInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-subtree/core/src/main/java/org/apache/directory/server/core/subtree/SubentryInterceptor.java?rev=965904&r1=965903&r2=965904&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-subtree/core/src/main/java/org/apache/directory/server/core/subtree/SubentryInterceptor.java
(original)
+++ directory/apacheds/branches/apacheds-subtree/core/src/main/java/org/apache/directory/server/core/subtree/SubentryInterceptor.java
Tue Jul 20 16:55:00 2010
@@ -403,6 +403,7 @@ public class SubentryInterceptor extends
                             */
                     }
                     
+                    LOG.debug( "The entry {} has been evaluated to true for subentry {}",
candidate.getDn(), subentryDn );
                     nexus.modify( new ModifyOperationContext( session, candidateDn, modifications
) );
                 }
             }
@@ -438,6 +439,7 @@ public class SubentryInterceptor extends
         // check that administrativeRole has something valid in it for us
         if ( ( administrativeRole == null ) || ( administrativeRole.size() <= 0 ) )
         {
+            LOG.error( "The entry on {} is not an AdministrativePoint", apDn );
             throw new LdapNoSuchAttributeException( I18n.err( I18n.ERR_306, apDn ) );
         }
     }
@@ -826,6 +828,23 @@ public class SubentryInterceptor extends
 
         return modList;
     }
+    
+    
+    /**
+     * Update the Operational Attribute with the reference to the subentry 
+     */
+    private void setOperationalAttribute( Entry entry, DN subentryDn, AttributeType opAttr)
throws LdapException
+    {
+        EntryAttribute operational = entry.get( opAttr );
+
+        if ( operational == null )
+        {
+            operational = new DefaultEntryAttribute( opAttr );
+            entry.put( operational );
+        }
+
+        operational.add( subentryDn.getNormName() );
+    }
 
     
     //-------------------------------------------------------------------------------------------
@@ -839,7 +858,7 @@ public class SubentryInterceptor extends
         DN dn = addContext.getDn();
         ClonedServerEntry entry = addContext.getEntry();
 
-        // Check that the added entry is a subentry
+        // Check if the added entry is a subentry
         if ( entry.contains( OBJECT_CLASS_AT, SchemaConstants.SUBENTRY_OC ) )
         {
             // get the name of the administrative point and its administrativeRole attributes
@@ -851,7 +870,8 @@ public class SubentryInterceptor extends
                 throw new LdapOtherException( "Cannot find an AdministrativePoint for " +
dn );
             }
             
-            // Get the administrativePoint role
+            // Get the administrativePoint role : we must have one immediately
+            // upper
             DN apDn = dn.getParent();
             checkAdministrativeRole( addContext, apDn );
 
@@ -893,8 +913,8 @@ public class SubentryInterceptor extends
             
             updateEntries( OperationEnum.ADD, addContext.getSession(), dn, apDn, subentry.getSubtreeSpecification(),
baseDn, operationalAttributes );
 
-            // TODO why are we doing this here if we got the entry from the 
-            // opContext in the first place - got to look into this 
+            // Store the newly modified entry into the context for later use in interceptor
+            // just in case
             addContext.setEntry( entry );
         }
         else
@@ -902,6 +922,9 @@ public class SubentryInterceptor extends
             // The added entry is not a Subentry.
             // Nevertheless, we have to check if the entry is added into an AdministrativePoint
             // and is associated with some SubtreeSpecification
+            // We brutally check *all* the subentries, as we don't hold a hierarchy
+            // of AP
+            // TODO : add a hierarchy of subentries
             for ( DN subentryDn : subentryCache )
             {
                 DN apDn = subentryDn.getParent();
@@ -913,68 +936,35 @@ public class SubentryInterceptor extends
                     SubtreeSpecification ss = subentry.getSubtreeSpecification();
     
                     // Now, evaluate the entry wrt the subentry ss
+                    // and inject a ref to the subentry if it evaluates to true
                     if ( evaluator.evaluate( ss, apDn, dn, entry ) )
                     {
                         
-                        EntryAttribute operational;
-    
                         if ( subentry.isAccessControlAdminRole() )
                         {
-                            operational = entry.get( ACCESS_CONTROL_SUBENTRIES_AT );
-    
-                            if ( operational == null )
-                            {
-                                operational = new DefaultEntryAttribute( ACCESS_CONTROL_SUBENTRIES_AT
);
-                                entry.put( operational );
-                            }
-    
-                            operational.add( subentryDn.getNormName() );
+                            setOperationalAttribute( entry, subentryDn, ACCESS_CONTROL_SUBENTRIES_AT
);
                         }
     
                         if ( subentry.isSchemaAdminRole() )
                         {
-                            operational = entry.get( SUBSCHEMA_SUBENTRY_AT );
-    
-                            if ( operational == null )
-                            {
-                                operational = new DefaultEntryAttribute( SUBSCHEMA_SUBENTRY_AT
);
-                                entry.put( operational );
-                            }
-    
-                            operational.add( subentryDn.getNormName() );
+                            setOperationalAttribute( entry, subentryDn, SUBSCHEMA_SUBENTRY_AT
);
                         }
     
                         if ( subentry.isCollectiveAdminRole() )
                         {
-                            operational = entry.get( COLLECTIVE_ATTRIBUTE_SUBENTRIES_AT );
-    
-                            if ( operational == null )
-                            {
-                                operational = new DefaultEntryAttribute( COLLECTIVE_ATTRIBUTE_SUBENTRIES_AT
);
-                                entry.put( operational );
-                            }
-    
-                            operational.add( subentryDn.getNormName() );
+                            setOperationalAttribute( entry, subentryDn, COLLECTIVE_ATTRIBUTE_SUBENTRIES_AT
);
                         }
     
                         if ( subentry.isTriggersAdminRole() )
                         {
-                            operational = entry.get( TRIGGER_EXECUTION_SUBENTRIES_AT );
-    
-                            if ( operational == null )
-                            {
-                                operational = new DefaultEntryAttribute( TRIGGER_EXECUTION_SUBENTRIES_AT
);
-                                entry.put( operational );
-                            }
-    
-                            operational.add( subentryDn.getNormName() );
+                            setOperationalAttribute( entry, subentryDn, TRIGGER_EXECUTION_SUBENTRIES_AT
);
                         }
                     }
                 }
             }
 
             // Now that the entry has been updated with the operational attributes,
-            // we can update it
+            // we can update it into the add context
             addContext.setEntry( entry );
 
             // Propagate the addition down to the backend.
@@ -992,12 +982,11 @@ public class SubentryInterceptor extends
         Entry entry = deleteContext.getEntry();
 
         // If the entry has a "subentry" Objectclass, we can process the entry.
+        // We first remove the re
         if ( entry.contains( OBJECT_CLASS_AT, SchemaConstants.SUBENTRY_OC ) )
         {
-            next.delete( deleteContext );
-
-            Subentry removedSubentry = subentryCache.removeSubentry( dn );
-
+            Subentry removedSubentry = subentryCache.getSubentry( dn );
+            
             /* ----------------------------------------------------------------
              * Find the baseDn for the subentry and use that to search the tree
              * for all entries included by the subtreeSpecification.  Then we
@@ -1010,10 +999,18 @@ public class SubentryInterceptor extends
             DN baseDn = ( DN ) apDn.clone();
             baseDn.addAll( removedSubentry.getSubtreeSpecification().getBase() );
 
+            // Remove all the references to this removed subentry from all the selected entries
             updateEntries( OperationEnum.REMOVE, deleteContext.getSession(), dn, apDn, removedSubentry.getSubtreeSpecification(),
baseDn, null );
+
+            // Update the cache
+            subentryCache.removeSubentry( dn );
+
+            // Now delete the subentry itself
+            next.delete( deleteContext );
         }
         else
         {
+            // TODO : deal with AP removal.
             next.delete( deleteContext );
         }
     }

Propchange: directory/apacheds/branches/apacheds-subtree/core/src/main/java/org/apache/directory/server/core/subtree/SubentryInterceptor.java
------------------------------------------------------------------------------
--- svn:mergeinfo (added)
+++ svn:mergeinfo Tue Jul 20 16:55:00 2010
@@ -0,0 +1,4 @@
+/directory/apacheds/branches/apacheds-replication/core/src/main/java/org/apache/directory/server/core/subtree/SubentryInterceptor.java:749790-764110
+/directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/subtree/SubentryInterceptor.java:806623-896441
+/directory/apacheds/branches/xdbm-refactoring/core/src/main/java/org/apache/directory/server/core/subtree/SubentryInterceptor.java:945827-946347
+/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/SubentryInterceptor.java:965781



Mime
View raw message