directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1051546 - /directory/apacheds/branches/apacheds-AP/core/src/main/java/org/apache/directory/server/core/subtree/SubentryInterceptor.java
Date Tue, 21 Dec 2010 16:34:39 GMT
Author: elecharny
Date: Tue Dec 21 16:34:39 2010
New Revision: 1051546

URL: http://svn.apache.org/viewvc?rev=1051546&view=rev
Log:
When injecting an AP with only an AAP role, create the missing SAP

Modified:
    directory/apacheds/branches/apacheds-AP/core/src/main/java/org/apache/directory/server/core/subtree/SubentryInterceptor.java

Modified: directory/apacheds/branches/apacheds-AP/core/src/main/java/org/apache/directory/server/core/subtree/SubentryInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-AP/core/src/main/java/org/apache/directory/server/core/subtree/SubentryInterceptor.java?rev=1051546&r1=1051545&r2=1051546&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-AP/core/src/main/java/org/apache/directory/server/core/subtree/SubentryInterceptor.java
(original)
+++ directory/apacheds/branches/apacheds-AP/core/src/main/java/org/apache/directory/server/core/subtree/SubentryInterceptor.java
Tue Dec 21 16:34:39 2010
@@ -940,34 +940,61 @@ public class SubentryInterceptor extends
         }
 
         // If we are trying to add an AAP, we have to check that 
-        // all the SAP roles are present 
+        // all the SAP roles are present. If nit, we add them.
+        int nbRoles = adminPoint.size();
+        
         if ( isAutonomousAreaRole( roleStr ) )
         {
-            if ( hasAccessControlSpecificRole( adminPoint ) && hasCollectiveAttributeSpecificRole(
adminPoint )
-                && hasTriggerExecutionSpecificRole( adminPoint ) && hasSubSchemaSpecificRole(
adminPoint ) )
+            nbRoles--;
+            
+            if ( !hasAccessControlSpecificRole( adminPoint ) )
             {
-                // Check thet we don't have any other role : we should have only 5 roles
-                if ( adminPoint.size() != 5 )
-                {
-                    String message = "Cannot add an Autonomous Administrative Point if we
have some IAP roles : "
-                        + adminPoint;
-                    LOG.error( message );
-                    
-                    throw new LdapUnwillingToPerformException( message );
-                }
-                
-                // Fine, we have an AAP and the 4 SAPs
-                return;
+                adminPoint.add( SchemaConstants.ACCESS_CONTROL_SPECIFIC_AREA );
             }
             else
             {
-                // We have some missing SAP : this is not allowed
-                String message = "Cannot add an Autonomous Administrative Point if the other
SAP are not present"
+                nbRoles--;
+            }
+            
+            if ( !hasCollectiveAttributeSpecificRole( adminPoint ) )
+            {
+                adminPoint.add( SchemaConstants.COLLECTIVE_ATTRIBUTE_SPECIFIC_AREA );
+            }
+            else
+            {
+                nbRoles--;
+            }
+            
+            if ( !hasTriggerExecutionSpecificRole( adminPoint ) )
+            {
+                adminPoint.add( SchemaConstants.TRIGGER_EXECUTION_SPECIFIC_AREA );
+            }
+            else
+            {
+                nbRoles--;
+            }
+            
+            if ( !hasSubSchemaSpecificRole( adminPoint ) )
+            {
+                adminPoint.add( SchemaConstants.SUB_SCHEMA_ADMIN_SPECIFIC_AREA );
+            }
+            else
+            {
+                nbRoles--;
+            }
+            
+            if ( nbRoles != 0 )
+            {
+                // Check that we don't have any other role : we should have only 5 roles
max
+                String message = "Cannot add an Autonomous Administrative Point if we have
some IAP roles : "
                     + adminPoint;
                 LOG.error( message );
                 
                 throw new LdapUnwillingToPerformException( message );
             }
+                
+            // Fine, we have an AAP and the 4 SAPs
+            return;
         }
         
         // check that we can't mix Inner and Specific areas
@@ -1534,6 +1561,12 @@ public class SubentryInterceptor extends
     //-------------------------------------------------------------------------------------------
     /**
      * Add a new entry into the DIT. We deal with the Administrative aspects.
+     * We have to manage the three kind of added element :
+     * <ul>
+     * <li>APs</li>
+     * <li>SubEntries</li>
+     * <li>Entries</li>
+     * </ul>
      * 
      * @param next The next {@link Interceptor} in the chain
      * @param addContext The {@link AddOperationContext} instance
@@ -1564,7 +1597,7 @@ public class SubentryInterceptor extends
                 throw new LdapUnwillingToPerformException( message );
             }
 
-            LOG.debug( "Addition of an administrative point at {} for the role {}", dn, adminPointAT
);
+            LOG.debug( "Addition of an administrative point at {} for the roles {}", dn,
adminPointAT );
 
             try
             {



Mime
View raw message