Return-Path: Delivered-To: apmail-directory-commits-archive@www.apache.org Received: (qmail 66444 invoked from network); 20 Jul 2010 10:07:02 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 20 Jul 2010 10:07:02 -0000 Received: (qmail 85071 invoked by uid 500); 20 Jul 2010 10:07:02 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 84996 invoked by uid 500); 20 Jul 2010 10:07:00 -0000 Mailing-List: contact commits-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@directory.apache.org Delivered-To: mailing list commits@directory.apache.org Received: (qmail 84985 invoked by uid 99); 20 Jul 2010 10:06:59 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 20 Jul 2010 10:06:59 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 20 Jul 2010 10:06:56 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id B7B0323889D7; Tue, 20 Jul 2010 10:05:32 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r965781 - /directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/SubentryInterceptor.java Date: Tue, 20 Jul 2010 10:05:32 -0000 To: commits@directory.apache.org From: elecharny@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100720100532.B7B0323889D7@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: elecharny Date: Tue Jul 20 10:05:32 2010 New Revision: 965781 URL: http://svn.apache.org/viewvc?rev=965781&view=rev Log: o Added logs o Created a helper method o Modified the delete method to delete the subentry after the entries referencing it has been updated Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/SubentryInterceptor.java Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/SubentryInterceptor.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/SubentryInterceptor.java?rev=965781&r1=965780&r2=965781&view=diff ============================================================================== --- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/SubentryInterceptor.java (original) +++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/SubentryInterceptor.java Tue Jul 20 10:05:32 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 ); } }