directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1445695 - in /directory/apacheds/trunk: interceptors/admin/src/main/java/org/apache/directory/server/core/admin/ xdbm-partition/src/main/java/org/apache/directory/server/xdbm/ xdbm-partition/src/main/java/org/apache/directory/server/xdbm/s...
Date Wed, 13 Feb 2013 15:55:44 GMT
Author: elecharny
Date: Wed Feb 13 15:55:43 2013
New Revision: 1445695

URL: http://svn.apache.org/r1445695
Log:
o Fixed the AdministrativePoint cache update
o Removed the EntryUUID from the list of system index
o Fixed the Presencevaluator.evaluate() method to bypass only the OC, EntryCSN and EntryUUID
index (and not the AdminRole index)

Modified:
    directory/apacheds/trunk/interceptors/admin/src/main/java/org/apache/directory/server/core/admin/AdministrativePointInterceptor.java
    directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/Store.java
    directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/evaluator/PresenceEvaluator.java

Modified: directory/apacheds/trunk/interceptors/admin/src/main/java/org/apache/directory/server/core/admin/AdministrativePointInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/interceptors/admin/src/main/java/org/apache/directory/server/core/admin/AdministrativePointInterceptor.java?rev=1445695&r1=1445694&r2=1445695&view=diff
==============================================================================
--- directory/apacheds/trunk/interceptors/admin/src/main/java/org/apache/directory/server/core/admin/AdministrativePointInterceptor.java
(original)
+++ directory/apacheds/trunk/interceptors/admin/src/main/java/org/apache/directory/server/core/admin/AdministrativePointInterceptor.java
Wed Feb 13 15:55:43 2013
@@ -1326,125 +1326,138 @@ public class AdministrativePointIntercep
         Dn dn = modifyContext.getDn();
         String uuid = modifyContext.getEntry().get( ENTRY_UUID_AT ).getString();
 
-        // Create a clone of the current AdminRole AT
-        Attribute modifiedAdminRole = ( ( ClonedServerEntry ) modifyContext.getEntry() ).getOriginalEntry().get(
-            ADMINISTRATIVE_ROLE_AT );
+        // Check if we are modifying any AdminRole
+        boolean adminRolePresent = false;
 
-        if ( modifiedAdminRole == null )
-        {
-            // Create the attribute
-            modifiedAdminRole = new DefaultAttribute( ADMINISTRATIVE_ROLE_AT );
-        }
-        else
-        {
-            modifiedAdminRole = modifiedAdminRole.clone();
-        }
-
-        // Clone the AP caches before applying modifications to them modify it
-        DnNode<AccessControlAdministrativePoint> acapCacheCopy = directoryService.getAccessControlAPCache().clone();
-        DnNode<CollectiveAttributeAdministrativePoint> caapCacheCopy = directoryService.getCollectiveAttributeAPCache()
-            .clone();
-        DnNode<TriggerExecutionAdministrativePoint> teapCacheCopy = directoryService.getTriggerExecutionAPCache()
-            .clone();
-        DnNode<SubschemaAdministrativePoint> ssapCacheCopy = directoryService.getSubschemaAPCache().clone();
-
-        // Loop on the modification to select the AdministrativeRole and process it :
-        // we will create a new AT containing all the roles after having applied the modifications
-        // on it
         for ( Modification modification : modifications )
         {
-            Attribute attribute = modification.getAttribute();
-
-            // Skip all the attributes but AdministrativeRole
-            if ( attribute.getAttributeType() == ADMINISTRATIVE_ROLE_AT )
+            if ( modification.getAttribute().getAttributeType() == ADMINISTRATIVE_ROLE_AT
)
             {
-                // Ok, we have a modification impacting the administrative role
-                // Apply it to a virtual AdministrativeRole attribute
-                switch ( modification.getOperation() )
-                {
-                    case ADD_ATTRIBUTE:
-                        if ( modifiedAdminRole == null )
-                        {
-                            // Create the attribute
-                            modifiedAdminRole = new DefaultAttribute( ADMINISTRATIVE_ROLE_AT,
attribute.get() );
-                        }
-
-                        for ( Value<?> role : attribute )
-                        {
-                            addRole( role.getString(), dn, uuid, acapCacheCopy, caapCacheCopy,
teapCacheCopy,
-                                ssapCacheCopy );
+                adminRolePresent = true;
+                break;
+            }
+        }
 
-                            // Add the role to the modified attribute
-                            modifiedAdminRole.add( role );
-                        }
+        if ( adminRolePresent )
+        {
+            // We have modified any AdministrativeRole attribute, we can continue
 
-                        break;
+            // Create a clone of the current AdminRole AT
+            Attribute modifiedAdminRole = ( ( ClonedServerEntry ) modifyContext.getEntry()
).getOriginalEntry().get(
+                ADMINISTRATIVE_ROLE_AT );
 
-                    case REMOVE_ATTRIBUTE:
-                        if ( modifiedAdminRole == null )
-                        {
-                            // We can't remove a value when the attribute does not exist.
-                            String msg = "Cannot remove the administrative role, it does
not exist";
-                            LOG.error( msg );
-                            throw new LdapNoSuchAttributeException( msg );
-                        }
+            if ( modifiedAdminRole == null )
+            {
+                // Create the attribute, as it does not already exist in the entry
+                modifiedAdminRole = new DefaultAttribute( ADMINISTRATIVE_ROLE_AT );
+            }
+            else
+            {
+                // We have already an AdminRole AT clone it
+                modifiedAdminRole = modifiedAdminRole.clone();
+            }
 
-                        // It may be a complete removal
-                        if ( attribute.size() == 0 )
-                        {
-                            // Complete removal. Loop on all the existing roles and remove
them
-                            for ( Value<?> role : modifiedAdminRole )
-                            {
-                                //checkDelRole( role, modifiedAdminRole, dn, directoryService.getAdministrativePoints()
);
-                                delRole( role.getString(), dn, uuid, acapCacheCopy, caapCacheCopy,
teapCacheCopy,
-                                    ssapCacheCopy );
-                            }
+            try
+            {
+                // Acquire the lock
+                lockWrite();
 
-                            modifiedAdminRole.clear();
-                            break;
-                        }
+                // Get the AP caches as we will apply modifications to them
+                DnNode<AccessControlAdministrativePoint> acapCache = directoryService.getAccessControlAPCache();
+                DnNode<CollectiveAttributeAdministrativePoint> caapCache = directoryService
+                    .getCollectiveAttributeAPCache();
+                DnNode<TriggerExecutionAdministrativePoint> teapCache = directoryService.getTriggerExecutionAPCache();
+                DnNode<SubschemaAdministrativePoint> ssapCache = directoryService.getSubschemaAPCache();
+
+                // Loop on the modification to select the AdministrativeRole and process
it :
+                // we will create a new AT containing all the roles after having applied
the modifications
+                // on it
+                for ( Modification modification : modifications )
+                {
+                    Attribute attribute = modification.getAttribute();
 
-                        // Now deal with the values to remove
-                        for ( Value<?> value : attribute )
+                    // Skip all the attributes but AdministrativeRole
+                    if ( attribute.getAttributeType() == ADMINISTRATIVE_ROLE_AT )
+                    {
+                        // Ok, we have a modification impacting the administrative role
+                        // Apply it to a virtual AdministrativeRole attribute
+                        switch ( modification.getOperation() )
                         {
-                            if ( !isValidRole( value.getString() ) )
-                            {
-                                // Not a valid role : we will throw an exception
-                                String msg = "Invalid role : " + value.getString();
-                                LOG.error( msg );
-                                throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX,
-                                    msg );
-                            }
-
-                            if ( !modifiedAdminRole.contains( value ) )
-                            {
-                                // We can't remove a value if it does not exist !
-                                String msg = "Cannot remove the administrative role value"
+ value
-                                    + ", it does not exist";
+                            case ADD_ATTRIBUTE:
+                                for ( Value<?> role : attribute )
+                                {
+                                    addRole( role.getString(), dn, uuid, acapCache, caapCache,
teapCache,
+                                        ssapCache );
+
+                                    // Add the role to the modified attribute
+                                    modifiedAdminRole.add( role );
+                                }
+
+                                break;
+
+                            case REMOVE_ATTRIBUTE:
+                                // It may be a complete removal
+                                if ( attribute.size() == 0 )
+                                {
+                                    // Complete removal. Loop on all the existing roles and
remove them
+                                    for ( Value<?> role : modifiedAdminRole )
+                                    {
+                                        //checkDelRole( role, modifiedAdminRole, dn, directoryService.getAdministrativePoints()
);
+                                        delRole( role.getString(), dn, uuid, acapCache, caapCache,
teapCache, ssapCache );
+                                    }
+
+                                    modifiedAdminRole.clear();
+                                    break;
+                                }
+
+                                // Now deal with the values to remove
+                                for ( Value<?> value : attribute )
+                                {
+                                    if ( !isValidRole( value.getString() ) )
+                                    {
+                                        // Not a valid role : we will throw an exception
+                                        String msg = "Invalid role : " + value.getString();
+                                        LOG.error( msg );
+                                        throw new LdapInvalidAttributeValueException(
+                                            ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX,
+                                            msg );
+                                    }
+
+                                    if ( !modifiedAdminRole.contains( value ) )
+                                    {
+                                        // We can't remove a value if it does not exist !
+                                        String msg = "Cannot remove the administrative role
value" + value
+                                            + ", it does not exist";
+                                        LOG.error( msg );
+                                        throw new LdapNoSuchAttributeException( msg );
+                                    }
+
+                                    modifiedAdminRole.remove( value );
+                                    delRole( value.getString(), dn, uuid, acapCache, caapCache,
teapCache, ssapCache );
+
+                                }
+
+                                break;
+
+                            case REPLACE_ATTRIBUTE:
+                                // Not supported
+                                String msg = "Cannot replace an administrative role, the
opertion is not supported";
                                 LOG.error( msg );
-                                throw new LdapNoSuchAttributeException( msg );
-                            }
-
-                            modifiedAdminRole.remove( value );
-                            delRole( value.getString(), dn, uuid, acapCacheCopy, caapCacheCopy,
teapCacheCopy,
-                                ssapCacheCopy );
-
+                                throw new LdapUnwillingToPerformException( msg );
                         }
-
-                        break;
-
-                    case REPLACE_ATTRIBUTE:
-                        // Not supported
-                        String msg = "Cannot replace an administrative role, the opertion
is not supported";
-                        LOG.error( msg );
-                        throw new LdapUnwillingToPerformException( msg );
+                    }
                 }
+
+                // At this point, we have a new AdministrativeRole AT, we need to check that
the 
+                // roles hierarchy is still correct
+                // TODO !!!
+            }
+            finally
+            {
+                unlock();
             }
         }
 
-        // At this point, we have a new AdministrativeRole AT, and we need to get the lists
of
-        // added roles and removed roles, in order to process them
-
         next( modifyContext );
     }
 

Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/Store.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/Store.java?rev=1445695&r1=1445694&r2=1445695&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/Store.java
(original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/Store.java
Wed Feb 13 15:55:43 2013
@@ -97,7 +97,6 @@ public interface Store
             ApacheSchemaConstants.APACHE_ONE_ALIAS_AT_OID,
             ApacheSchemaConstants.APACHE_SUB_ALIAS_AT_OID,
             SchemaConstants.ENTRY_CSN_AT_OID,
-            SchemaConstants.ENTRY_UUID_AT_OID,
             SchemaConstants.OBJECT_CLASS_AT_OID,
             SchemaConstants.ADMINISTRATIVE_ROLE_AT_OID
     };

Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/evaluator/PresenceEvaluator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/evaluator/PresenceEvaluator.java?rev=1445695&r1=1445694&r2=1445695&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/evaluator/PresenceEvaluator.java
(original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/evaluator/PresenceEvaluator.java
Wed Feb 13 15:55:43 2013
@@ -118,8 +118,11 @@ public class PresenceEvaluator implement
     // wrapper or the raw normalized value
     public boolean evaluate( Entry entry ) throws LdapException
     {
-        if ( db.hasSystemIndexOn( attributeType )
-            || ( attributeType.getOid().equals( SchemaConstants.ENTRY_UUID_AT_OID ) ) )
+        String attrOid = attributeType.getOid();
+
+        if ( attrOid.equals( SchemaConstants.OBJECT_CLASS_AT_OID )
+            || attrOid.equals( SchemaConstants.ENTRY_CSN_AT_OID )
+            || attrOid.equals( SchemaConstants.ENTRY_UUID_AT_OID ) )
         {
             // we don't maintain a presence index for objectClass, entryUUID and entryCSN
             // however as every entry has such an attribute this evaluator always evaluates
to true



Mime
View raw message