You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2011/11/11 14:15:40 UTC
svn commit: r1200870 [3/3] - in /directory/apacheds/trunk:
interceptor-kerberos/src/main/java/org/apache/directory/server/core/kerberos/
interceptors/admin/src/main/java/org/apache/directory/server/core/admin/
interceptors/authn/src/main/java/org/apach...
Modified: directory/apacheds/trunk/interceptors/schema/src/main/java/org/apache/directory/server/core/schema/SchemaInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/interceptors/schema/src/main/java/org/apache/directory/server/core/schema/SchemaInterceptor.java?rev=1200870&r1=1200869&r2=1200870&view=diff
==============================================================================
--- directory/apacheds/trunk/interceptors/schema/src/main/java/org/apache/directory/server/core/schema/SchemaInterceptor.java (original)
+++ directory/apacheds/trunk/interceptors/schema/src/main/java/org/apache/directory/server/core/schema/SchemaInterceptor.java Fri Nov 11 13:15:39 2011
@@ -369,38 +369,6 @@ public class SchemaInterceptor extends B
}
- public EntryFilteringCursor list( ListOperationContext listContext ) throws LdapException
- {
- EntryFilteringCursor cursor = next( listContext );
- cursor.addEntryFilter( binaryAttributeFilter );
-
- return cursor;
- }
-
-
- /**
- * {@inheritDoc}
- */
- public boolean compare( CompareOperationContext compareContext ) throws LdapException
- {
- if ( IS_DEBUG )
- {
- LOG.debug( "Operation Context: {}", compareContext );
- }
-
- // Check that the requested AT exists
- // complain if we do not recognize the attribute being compared
- if ( !schemaManager.getAttributeTypeRegistry().contains( compareContext.getOid() ) )
- {
- throw new LdapInvalidAttributeTypeException( I18n.err( I18n.ERR_266, compareContext.getOid() ) );
- }
-
- boolean result = next( compareContext );
-
- return result;
- }
-
-
/**
* Remove all unknown attributes from the searchControls, to avoid an exception.
*
@@ -629,122 +597,6 @@ public class SchemaInterceptor extends B
}
- public EntryFilteringCursor search( SearchOperationContext searchContext ) throws LdapException
- {
- Dn base = searchContext.getDn();
- SearchControls searchCtls = searchContext.getSearchControls();
- ExprNode filter = searchContext.getFilter();
-
- // We have to eliminate bad attributes from the request, accordingly
- // to RFC 2251, chap. 4.5.1. Basically, all unknown attributes are removed
- // from the list
- if ( searchCtls.getReturningAttributes() != null )
- {
- filterAttributesToReturn( searchCtls );
- }
-
- // We also have to check the H/R flag for the filter attributes
- checkFilter( filter );
-
- String baseNormForm = ( base.isSchemaAware() ? base.getNormName() : base.getNormName() );
-
- // Deal with the normal case : searching for a normal value (not subSchemaSubEntry)
- if ( !subschemaSubentryDnNorm.equals( baseNormForm ) )
- {
- EntryFilteringCursor cursor = next( searchContext );
-
- if ( searchCtls.getReturningAttributes() != null )
- {
- cursor.addEntryFilter( topFilter );
- return cursor;
- }
-
- for ( EntryFilter ef : filters )
- {
- cursor.addEntryFilter( ef );
- }
-
- return cursor;
- }
-
- // The user was searching into the subSchemaSubEntry
- // This kind of search _must_ be limited to OBJECT scope (the subSchemaSubEntry
- // does not have any sub level)
- if ( searchCtls.getSearchScope() == SearchControls.OBJECT_SCOPE )
- {
- // The filter can be an equality or a presence, but nothing else
- if ( filter instanceof SimpleNode)
- {
- // We should get the value for the filter.
- // only 'top' and 'subSchema' are valid values
- SimpleNode node = ( SimpleNode ) filter;
- String objectClass;
-
- objectClass = node.getValue().getString();
-
- String objectClassOid = null;
-
- if ( schemaManager.getObjectClassRegistry().contains( objectClass ) )
- {
- objectClassOid = schemaManager.lookupObjectClassRegistry( objectClass ).getOid();
- }
- else
- {
- return new BaseEntryFilteringCursor( new EmptyCursor<Entry>(), searchContext );
- }
-
- AttributeType nodeAt = node.getAttributeType();
-
- // see if node attribute is objectClass
- if ( nodeAt.equals( OBJECT_CLASS_AT )
- && ( objectClassOid.equals( SchemaConstants.TOP_OC_OID ) || objectClassOid
- .equals( SchemaConstants.SUBSCHEMA_OC_OID ) ) && ( node instanceof EqualityNode ) )
- {
- // call.setBypass( true );
- Entry serverEntry = SchemaService.getSubschemaEntry( directoryService, searchCtls.getReturningAttributes() );
- serverEntry.setDn( base );
- return new BaseEntryFilteringCursor( new SingletonCursor<Entry>( serverEntry ), searchContext );
- }
- else
- {
- return new BaseEntryFilteringCursor( new EmptyCursor<Entry>(), searchContext );
- }
- }
- else if ( filter instanceof PresenceNode )
- {
- PresenceNode node = ( PresenceNode ) filter;
-
- // see if node attribute is objectClass
- if ( node.getAttributeType().equals( OBJECT_CLASS_AT ) )
- {
- // call.setBypass( true );
- Entry serverEntry = SchemaService.getSubschemaEntry( directoryService, searchCtls.getReturningAttributes() );
- serverEntry.setDn( base );
- EntryFilteringCursor cursor = new BaseEntryFilteringCursor(
- new SingletonCursor<Entry>( serverEntry ), searchContext );
- return cursor;
- }
- }
- }
-
- // In any case not handled previously, just return an empty result
- return new BaseEntryFilteringCursor( new EmptyCursor<Entry>(), searchContext );
- }
-
-
- /**
- * Search for an entry, using its Dn. Binary attributes and ObjectClass attribute are removed.
- */
- public Entry lookup( LookupOperationContext lookupContext ) throws LdapException
- {
- Entry result = next( lookupContext );
-
- filterBinaryAttributes( result );
-
- return result;
- }
-
-
private void getSuperiors( ObjectClass oc, Set<String> ocSeen, List<ObjectClass> result ) throws LdapException
{
for ( ObjectClass parent : oc.getSuperiors() )
@@ -924,63 +776,6 @@ public class SchemaInterceptor extends B
}
- public void rename( RenameOperationContext renameContext ) throws LdapException
- {
- Dn oldDn = renameContext.getDn();
- Rdn newRdn = renameContext.getNewRdn();
- boolean deleteOldRn = renameContext.getDeleteOldRdn();
- Entry entry = ((ClonedServerEntry)renameContext.getEntry()).getClonedEntry();
-
- /*
- * Note: This is only a consistency checks, to the ensure that all
- * mandatory attributes are available after deleting the old Rdn.
- * The real modification is done in the XdbmStore class.
- * - TODO: this check is missing in the moveAndRename() method
- */
- if ( deleteOldRn )
- {
- Rdn oldRdn = oldDn.getRdn();
-
- // Delete the old Rdn means we remove some attributes and values.
- // We must make sure that after this operation all must attributes
- // are still present in the entry.
- for ( Ava atav : oldRdn)
- {
- AttributeType type = schemaManager.lookupAttributeTypeRegistry( atav.getUpType() );
- entry.remove( type, atav.getUpValue() );
- }
-
- // Check that no operational attributes are removed
- for ( Ava atav : oldRdn)
- {
- AttributeType attributeType = schemaManager.lookupAttributeTypeRegistry( atav.getUpType() );
-
- if ( !attributeType.isUserModifiable() )
- {
- throw new LdapNoPermissionException( "Cannot modify the attribute '" + atav.getUpType() + "'" );
- }
- }
- }
-
- for ( Ava atav : newRdn )
- {
- AttributeType type = schemaManager.lookupAttributeTypeRegistry( atav.getUpType() );
-
- if ( !entry.contains( type, atav.getNormValue() ) )
- {
- entry.add( new DefaultAttribute( type, atav.getNormValue() ) );
- }
- }
-
- // Substitute the Rdn and check if the new entry is correct
- entry.setDn( renameContext.getNewDn() );
-
- check( renameContext.getNewDn(), entry );
-
- next( renameContext );
- }
-
-
/**
* Create a new attribute using the given values
*/
@@ -1179,82 +974,24 @@ public class SchemaInterceptor extends B
/**
- * {@inheritDoc}
+ * Filter the attributes by removing the ones which are not allowed
*/
- public void modify( ModifyOperationContext modifyContext ) throws LdapException
+ // This will suppress PMD.EmptyCatchBlock warnings in this method
+ @SuppressWarnings("PMD.EmptyCatchBlock")
+ private void filterAttributeTypes( SearchingOperationContext operation, Entry result )
{
- // A modification on a simple entry will be done in three steps :
- // - get the original entry (it should already been in the context)
- // - apply the modification on it
- // - check that the entry is still correct
- // - add the operational attributes (modifiersName/modifyTimeStamp)
- // - store the modified entry on the backend.
- //
- // A modification done on the schema is a bit different, as there is two more
- // steps
- // - We have to update the registries
- // - We have to modify the ou=schemaModifications entry
- //
-
- // First, check that the entry is either a subschemaSubentry or a schema element.
- // This is the case if it's a child of cn=schema or ou=schema
- Dn dn = modifyContext.getDn();
-
- // Gets the stored entry on which the modification must be applied
- if ( dn.equals( subschemaSubentryDn ) )
+ if ( operation.getReturningAttributes() == null )
{
- LOG.debug( "Modification attempt on schema subentry {}: \n{}", dn, modifyContext );
+ return;
+ }
- // We can get rid of the modifiersName and modifyTimestamp, they are useless.
- List<Modification> mods = modifyContext.getModItems();
- List<Modification> cleanMods = new ArrayList<Modification>();
+ for ( AttributeTypeOptions attrOptions : operation.getReturningAttributes() )
+ {
+ Attribute attribute = result.get( attrOptions.getAttributeType() );
- for ( Modification mod : mods )
+ if ( attrOptions.hasOption() )
{
- AttributeType at = ( ( DefaultModification ) mod ).getAttribute().getAttributeType();
-
- if ( !MODIFIERS_NAME_AT.equals( at ) && !MODIFY_TIMESTAMP_AT.equals( at ) && !ENTRY_CSN_AT.equals( at ) )
- {
- cleanMods.add( mod );
- }
- }
-
- modifyContext.setModItems( cleanMods );
-
- // Now that the entry has been modified, update the SSSE
- schemaSubEntryManager.modifySchemaSubentry( modifyContext, modifyContext
- .hasRequestControl( Cascade.OID ) );
-
- return;
- }
-
- Entry entry = modifyContext.getEntry();
- List<Modification> modifications = modifyContext.getModItems();
- checkModifyEntry( dn, entry, modifications );
-
- next( modifyContext );
- }
-
-
- /**
- * Filter the attributes by removing the ones which are not allowed
- */
- // This will suppress PMD.EmptyCatchBlock warnings in this method
- @SuppressWarnings("PMD.EmptyCatchBlock")
- private void filterAttributeTypes( SearchingOperationContext operation, Entry result )
- {
- if ( operation.getReturningAttributes() == null )
- {
- return;
- }
-
- for ( AttributeTypeOptions attrOptions : operation.getReturningAttributes() )
- {
- Attribute attribute = result.get( attrOptions.getAttributeType() );
-
- if ( attrOptions.hasOption() )
- {
- for ( String option : attrOptions.getOptions() )
+ for ( String option : attrOptions.getOptions() )
{
if ( "binary".equalsIgnoreCase( option ) )
{
@@ -1478,6 +1215,9 @@ public class SchemaInterceptor extends B
/**
* Check that all the attributes exist in the schema for this entry.
*/
+ /**
+ * {@inheritDoc}
+ */
public void add( AddOperationContext addContext ) throws LdapException
{
Dn name = addContext.getDn();
@@ -1538,6 +1278,278 @@ public class SchemaInterceptor extends B
}
+ /**
+ * {@inheritDoc}
+ */
+ public boolean compare( CompareOperationContext compareContext ) throws LdapException
+ {
+ if ( IS_DEBUG )
+ {
+ LOG.debug( "Operation Context: {}", compareContext );
+ }
+
+ // Check that the requested AT exists
+ // complain if we do not recognize the attribute being compared
+ if ( !schemaManager.getAttributeTypeRegistry().contains( compareContext.getOid() ) )
+ {
+ throw new LdapInvalidAttributeTypeException( I18n.err( I18n.ERR_266, compareContext.getOid() ) );
+ }
+
+ boolean result = next( compareContext );
+
+ return result;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public EntryFilteringCursor list( ListOperationContext listContext ) throws LdapException
+ {
+ EntryFilteringCursor cursor = next( listContext );
+ cursor.addEntryFilter( binaryAttributeFilter );
+
+ return cursor;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public Entry lookup( LookupOperationContext lookupContext ) throws LdapException
+ {
+ Entry result = next( lookupContext );
+
+ filterBinaryAttributes( result );
+
+ return result;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void modify( ModifyOperationContext modifyContext ) throws LdapException
+ {
+ // A modification on a simple entry will be done in three steps :
+ // - get the original entry (it should already been in the context)
+ // - apply the modification on it
+ // - check that the entry is still correct
+ // - add the operational attributes (modifiersName/modifyTimeStamp)
+ // - store the modified entry on the backend.
+ //
+ // A modification done on the schema is a bit different, as there is two more
+ // steps
+ // - We have to update the registries
+ // - We have to modify the ou=schemaModifications entry
+ //
+
+ // First, check that the entry is either a subschemaSubentry or a schema element.
+ // This is the case if it's a child of cn=schema or ou=schema
+ Dn dn = modifyContext.getDn();
+
+ // Gets the stored entry on which the modification must be applied
+ if ( dn.equals( subschemaSubentryDn ) )
+ {
+ LOG.debug( "Modification attempt on schema subentry {}: \n{}", dn, modifyContext );
+
+ // We can get rid of the modifiersName and modifyTimestamp, they are useless.
+ List<Modification> mods = modifyContext.getModItems();
+ List<Modification> cleanMods = new ArrayList<Modification>();
+
+ for ( Modification mod : mods )
+ {
+ AttributeType at = ( ( DefaultModification ) mod ).getAttribute().getAttributeType();
+
+ if ( !MODIFIERS_NAME_AT.equals( at ) && !MODIFY_TIMESTAMP_AT.equals( at ) && !ENTRY_CSN_AT.equals( at ) )
+ {
+ cleanMods.add( mod );
+ }
+ }
+
+ modifyContext.setModItems( cleanMods );
+
+ // Now that the entry has been modified, update the SSSE
+ schemaSubEntryManager.modifySchemaSubentry( modifyContext, modifyContext
+ .hasRequestControl( Cascade.OID ) );
+
+ return;
+ }
+
+ Entry entry = modifyContext.getEntry();
+ List<Modification> modifications = modifyContext.getModItems();
+ checkModifyEntry( dn, entry, modifications );
+
+ next( modifyContext );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void rename( RenameOperationContext renameContext ) throws LdapException
+ {
+ Dn oldDn = renameContext.getDn();
+ Rdn newRdn = renameContext.getNewRdn();
+ boolean deleteOldRn = renameContext.getDeleteOldRdn();
+ Entry entry = ((ClonedServerEntry)renameContext.getEntry()).getClonedEntry();
+
+ /*
+ * Note: This is only a consistency checks, to the ensure that all
+ * mandatory attributes are available after deleting the old Rdn.
+ * The real modification is done in the XdbmStore class.
+ * - TODO: this check is missing in the moveAndRename() method
+ */
+ if ( deleteOldRn )
+ {
+ Rdn oldRdn = oldDn.getRdn();
+
+ // Delete the old Rdn means we remove some attributes and values.
+ // We must make sure that after this operation all must attributes
+ // are still present in the entry.
+ for ( Ava atav : oldRdn)
+ {
+ AttributeType type = schemaManager.lookupAttributeTypeRegistry( atav.getUpType() );
+ entry.remove( type, atav.getUpValue() );
+ }
+
+ // Check that no operational attributes are removed
+ for ( Ava atav : oldRdn)
+ {
+ AttributeType attributeType = schemaManager.lookupAttributeTypeRegistry( atav.getUpType() );
+
+ if ( !attributeType.isUserModifiable() )
+ {
+ throw new LdapNoPermissionException( "Cannot modify the attribute '" + atav.getUpType() + "'" );
+ }
+ }
+ }
+
+ for ( Ava atav : newRdn )
+ {
+ AttributeType type = schemaManager.lookupAttributeTypeRegistry( atav.getUpType() );
+
+ if ( !entry.contains( type, atav.getNormValue() ) )
+ {
+ entry.add( new DefaultAttribute( type, atav.getNormValue() ) );
+ }
+ }
+
+ // Substitute the Rdn and check if the new entry is correct
+ entry.setDn( renameContext.getNewDn() );
+
+ check( renameContext.getNewDn(), entry );
+
+ next( renameContext );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public EntryFilteringCursor search( SearchOperationContext searchContext ) throws LdapException
+ {
+ Dn base = searchContext.getDn();
+ SearchControls searchCtls = searchContext.getSearchControls();
+ ExprNode filter = searchContext.getFilter();
+
+ // We have to eliminate bad attributes from the request, accordingly
+ // to RFC 2251, chap. 4.5.1. Basically, all unknown attributes are removed
+ // from the list
+ if ( searchCtls.getReturningAttributes() != null )
+ {
+ filterAttributesToReturn( searchCtls );
+ }
+
+ // We also have to check the H/R flag for the filter attributes
+ checkFilter( filter );
+
+ String baseNormForm = ( base.isSchemaAware() ? base.getNormName() : base.getNormName() );
+
+ // Deal with the normal case : searching for a normal value (not subSchemaSubEntry)
+ if ( !subschemaSubentryDnNorm.equals( baseNormForm ) )
+ {
+ EntryFilteringCursor cursor = next( searchContext );
+
+ if ( searchCtls.getReturningAttributes() != null )
+ {
+ cursor.addEntryFilter( topFilter );
+ return cursor;
+ }
+
+ for ( EntryFilter ef : filters )
+ {
+ cursor.addEntryFilter( ef );
+ }
+
+ return cursor;
+ }
+
+ // The user was searching into the subSchemaSubEntry
+ // This kind of search _must_ be limited to OBJECT scope (the subSchemaSubEntry
+ // does not have any sub level)
+ if ( searchCtls.getSearchScope() == SearchControls.OBJECT_SCOPE )
+ {
+ // The filter can be an equality or a presence, but nothing else
+ if ( filter instanceof SimpleNode)
+ {
+ // We should get the value for the filter.
+ // only 'top' and 'subSchema' are valid values
+ SimpleNode node = ( SimpleNode ) filter;
+ String objectClass;
+
+ objectClass = node.getValue().getString();
+
+ String objectClassOid = null;
+
+ if ( schemaManager.getObjectClassRegistry().contains( objectClass ) )
+ {
+ objectClassOid = schemaManager.lookupObjectClassRegistry( objectClass ).getOid();
+ }
+ else
+ {
+ return new BaseEntryFilteringCursor( new EmptyCursor<Entry>(), searchContext );
+ }
+
+ AttributeType nodeAt = node.getAttributeType();
+
+ // see if node attribute is objectClass
+ if ( nodeAt.equals( OBJECT_CLASS_AT )
+ && ( objectClassOid.equals( SchemaConstants.TOP_OC_OID ) || objectClassOid
+ .equals( SchemaConstants.SUBSCHEMA_OC_OID ) ) && ( node instanceof EqualityNode ) )
+ {
+ // call.setBypass( true );
+ Entry serverEntry = SchemaService.getSubschemaEntry( directoryService, searchCtls.getReturningAttributes() );
+ serverEntry.setDn( base );
+ return new BaseEntryFilteringCursor( new SingletonCursor<Entry>( serverEntry ), searchContext );
+ }
+ else
+ {
+ return new BaseEntryFilteringCursor( new EmptyCursor<Entry>(), searchContext );
+ }
+ }
+ else if ( filter instanceof PresenceNode )
+ {
+ PresenceNode node = ( PresenceNode ) filter;
+
+ // see if node attribute is objectClass
+ if ( node.getAttributeType().equals( OBJECT_CLASS_AT ) )
+ {
+ // call.setBypass( true );
+ Entry serverEntry = SchemaService.getSubschemaEntry( directoryService, searchCtls.getReturningAttributes() );
+ serverEntry.setDn( base );
+ EntryFilteringCursor cursor = new BaseEntryFilteringCursor(
+ new SingletonCursor<Entry>( serverEntry ), searchContext );
+ return cursor;
+ }
+ }
+ }
+
+ // In any case not handled previously, just return an empty result
+ return new BaseEntryFilteringCursor( new EmptyCursor<Entry>(), searchContext );
+ }
+
+
private String getSchemaName( Dn dn ) throws LdapException
{
int size = dn.size();
Modified: directory/apacheds/trunk/interceptors/subtree/src/main/java/org/apache/directory/server/core/subtree/SubentryInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/interceptors/subtree/src/main/java/org/apache/directory/server/core/subtree/SubentryInterceptor.java?rev=1200870&r1=1200869&r2=1200870&view=diff
==============================================================================
--- directory/apacheds/trunk/interceptors/subtree/src/main/java/org/apache/directory/server/core/subtree/SubentryInterceptor.java (original)
+++ directory/apacheds/trunk/interceptors/subtree/src/main/java/org/apache/directory/server/core/subtree/SubentryInterceptor.java Fri Nov 11 13:15:39 2011
@@ -1331,6 +1331,9 @@ public class SubentryInterceptor extends
}
+ /**
+ * {@inheritDoc}
+ */
public void moveAndRename( MoveAndRenameOperationContext moveAndRenameContext ) throws LdapException
{
Dn oldDn = moveAndRenameContext.getDn();
@@ -1423,6 +1426,9 @@ public class SubentryInterceptor extends
}
+ /**
+ * {@inheritDoc}
+ */
public void rename( RenameOperationContext renameContext ) throws LdapException
{
Dn oldDn = renameContext.getDn();
Modified: directory/apacheds/trunk/interceptors/trigger/src/main/java/org/apache/directory/server/core/trigger/TriggerInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/interceptors/trigger/src/main/java/org/apache/directory/server/core/trigger/TriggerInterceptor.java?rev=1200870&r1=1200869&r2=1200870&view=diff
==============================================================================
--- directory/apacheds/trunk/interceptors/trigger/src/main/java/org/apache/directory/server/core/trigger/TriggerInterceptor.java (original)
+++ directory/apacheds/trunk/interceptors/trigger/src/main/java/org/apache/directory/server/core/trigger/TriggerInterceptor.java Fri Nov 11 13:15:39 2011
@@ -112,7 +112,7 @@ public class TriggerInterceptor extends
*/
private void addPrescriptiveTriggerSpecs( OperationContext opContext, List<TriggerSpecification> triggerSpecs,
Dn dn, Entry entry ) throws LdapException
- {
+ {
/*
* If the protected entry is a subentry, then the entry being evaluated
@@ -146,7 +146,7 @@ public class TriggerInterceptor extends
String subentryDn = value.getString();
triggerSpecs.addAll( triggerSpecCache.getSubentryTriggerSpecs( subentryDn ) );
}
- }
+ }
/**
@@ -199,7 +199,7 @@ public class TriggerInterceptor extends
*/
public Map<ActionTime, List<TriggerSpecification>> getActionTimeMappedTriggerSpecsForOperation(
List<TriggerSpecification> triggerSpecs, LdapOperation ldapOperation )
- {
+ {
List<TriggerSpecification> afterTriggerSpecs = new ArrayList<TriggerSpecification>();
Map<ActionTime, List<TriggerSpecification>> triggerSpecMap = new HashMap<ActionTime, List<TriggerSpecification>>();
@@ -221,7 +221,7 @@ public class TriggerInterceptor extends
triggerSpecMap.put( ActionTime.AFTER, afterTriggerSpecs );
return triggerSpecMap;
- }
+ }
////////////////////////////////////////////////////////////////////////////
@@ -257,6 +257,9 @@ public class TriggerInterceptor extends
}
+ /**
+ * {@inheritDoc}
+ */
public void add( AddOperationContext addContext ) throws LdapException
{
Dn name = addContext.getDn();
@@ -292,6 +295,9 @@ public class TriggerInterceptor extends
}
+ /**
+ * {@inheritDoc}
+ */
public void delete( DeleteOperationContext deleteContext ) throws LdapException
{
Dn name = deleteContext.getDn();
@@ -326,6 +332,9 @@ public class TriggerInterceptor extends
}
+ /**
+ * {@inheritDoc}
+ */
public void modify( ModifyOperationContext modifyContext ) throws LdapException
{
// Bypass trigger handling if the service is disabled.
@@ -360,50 +369,84 @@ public class TriggerInterceptor extends
}
- public void rename( RenameOperationContext renameContext ) throws LdapException
+ /**
+ * {@inheritDoc}
+ */
+ public void move( MoveOperationContext moveContext ) throws LdapException
{
- Dn name = renameContext.getDn();
- Rdn newRdn = renameContext.getNewRdn();
- boolean deleteOldRn = renameContext.getDeleteOldRdn();
-
// Bypass trigger handling if the service is disabled.
if ( !enabled )
{
- next( renameContext );
+ next( moveContext );
return;
}
+ Rdn rdn = moveContext.getRdn();
+ Dn dn = moveContext.getDn();
+ Dn newDn = moveContext.getNewDn();
+ Dn oldSuperior = moveContext.getOldSuperior();
+ Dn newSuperior = moveContext.getNewSuperior();
+
// Gather supplementary data.
- Entry renamedEntry = ((ClonedServerEntry)renameContext.getEntry()).getClonedEntry();
+ Entry movedEntry = moveContext.getOriginalEntry();
- // @TODO : To be completely reviewed !!!
- Rdn oldRdn = name.getRdn();
- Dn oldSuperiorDn = name.getParent();
- Dn newSuperiorDn = oldSuperiorDn;
- Dn oldDn = name;
- Dn newDn = name;
- newDn = newDn.add( newRdn );
+ //Rdn newRDN = dn.getRdn();
- StoredProcedureParameterInjector injector = new ModifyDNStoredProcedureParameterInjector( renameContext,
- deleteOldRn, oldRdn, newRdn, oldSuperiorDn, newSuperiorDn, oldDn, newDn);
+ StoredProcedureParameterInjector injector = new ModifyDNStoredProcedureParameterInjector( moveContext, false,
+ rdn, rdn, oldSuperior, newSuperior, dn, newDn );
- // Gather Trigger Specifications which apply to the entry being renamed.
- List<TriggerSpecification> triggerSpecs = new ArrayList<TriggerSpecification>();
- addPrescriptiveTriggerSpecs( renameContext, triggerSpecs, name, renamedEntry );
- addEntryTriggerSpecs( triggerSpecs, renamedEntry );
+ // Gather Trigger Specifications which apply to the entry being exported.
+ List<TriggerSpecification> exportTriggerSpecs = new ArrayList<TriggerSpecification>();
+ addPrescriptiveTriggerSpecs( moveContext, exportTriggerSpecs, dn, movedEntry );
+ addEntryTriggerSpecs( exportTriggerSpecs, movedEntry );
- Map<ActionTime, List<TriggerSpecification>> triggerMap = getActionTimeMappedTriggerSpecsForOperation(
- triggerSpecs, LdapOperation.MODIFYDN_RENAME );
+ // Get the entry again without operational attributes
+ // because access control subentry operational attributes
+ // will not be valid at the new location.
+ // This will certainly be fixed by the SubentryInterceptor,
+ // but after this service.
+ CoreSession session = moveContext.getSession();
+ LookupOperationContext lookupContext = new LookupOperationContext( session, dn, SchemaConstants.ALL_USER_ATTRIBUTES_ARRAY );
- next( renameContext );
- triggerSpecCache.subentryRenamed( name, newDn);
+ Entry importedEntry = directoryService.getPartitionNexus().lookup( lookupContext );
+
+ // As the target entry does not exist yet and so
+ // its subentry operational attributes are not there,
+ // we need to construct an entry to represent it
+ // at least with minimal requirements which are object class
+ // and access control subentry operational attributes.
+ Entry fakeImportedEntry = subentryUtils.getSubentryAttributes( newDn, importedEntry );
+
+ for ( Attribute attribute : importedEntry )
+ {
+ fakeImportedEntry.put( attribute );
+ }
+
+ // Gather Trigger Specifications which apply to the entry being imported.
+ // Note: Entry Trigger Specifications are not valid for Import.
+ List<TriggerSpecification> importTriggerSpecs = new ArrayList<TriggerSpecification>();
+ addPrescriptiveTriggerSpecs( moveContext, importTriggerSpecs, newDn, fakeImportedEntry );
+
+ Map<ActionTime, List<TriggerSpecification>> exportTriggerMap = getActionTimeMappedTriggerSpecsForOperation(
+ exportTriggerSpecs, LdapOperation.MODIFYDN_EXPORT );
+
+ Map<ActionTime, List<TriggerSpecification>> importTriggerMap = getActionTimeMappedTriggerSpecsForOperation(
+ importTriggerSpecs, LdapOperation.MODIFYDN_IMPORT );
+
+ next( moveContext );
+ triggerSpecCache.subentryRenamed( dn, newDn );
// Fire AFTER Triggers.
- List<TriggerSpecification> afterTriggerSpecs = triggerMap.get( ActionTime.AFTER );
- executeTriggers( renameContext, afterTriggerSpecs, injector );
+ List<TriggerSpecification> afterExportTriggerSpecs = exportTriggerMap.get( ActionTime.AFTER );
+ List<TriggerSpecification> afterImportTriggerSpecs = importTriggerMap.get( ActionTime.AFTER );
+ executeTriggers( moveContext, afterExportTriggerSpecs, injector );
+ executeTriggers( moveContext, afterImportTriggerSpecs, injector );
}
+ /**
+ * {@inheritDoc}
+ */
public void moveAndRename( MoveAndRenameOperationContext moveAndRenameContext ) throws LdapException
{
Dn oldDn = moveAndRenameContext.getDn();
@@ -481,75 +524,47 @@ public class TriggerInterceptor extends
/**
* {@inheritDoc}
*/
- public void move( MoveOperationContext moveContext ) throws LdapException
+ public void rename( RenameOperationContext renameContext ) throws LdapException
{
+ Dn name = renameContext.getDn();
+ Rdn newRdn = renameContext.getNewRdn();
+ boolean deleteOldRn = renameContext.getDeleteOldRdn();
+
// Bypass trigger handling if the service is disabled.
if ( !enabled )
{
- next( moveContext );
+ next( renameContext );
return;
}
- Rdn rdn = moveContext.getRdn();
- Dn dn = moveContext.getDn();
- Dn newDn = moveContext.getNewDn();
- Dn oldSuperior = moveContext.getOldSuperior();
- Dn newSuperior = moveContext.getNewSuperior();
-
// Gather supplementary data.
- Entry movedEntry = moveContext.getOriginalEntry();
-
- //Rdn newRDN = dn.getRdn();
-
- StoredProcedureParameterInjector injector = new ModifyDNStoredProcedureParameterInjector( moveContext, false,
- rdn, rdn, oldSuperior, newSuperior, dn, newDn );
-
- // Gather Trigger Specifications which apply to the entry being exported.
- List<TriggerSpecification> exportTriggerSpecs = new ArrayList<TriggerSpecification>();
- addPrescriptiveTriggerSpecs( moveContext, exportTriggerSpecs, dn, movedEntry );
- addEntryTriggerSpecs( exportTriggerSpecs, movedEntry );
-
- // Get the entry again without operational attributes
- // because access control subentry operational attributes
- // will not be valid at the new location.
- // This will certainly be fixed by the SubentryInterceptor,
- // but after this service.
- CoreSession session = moveContext.getSession();
- LookupOperationContext lookupContext = new LookupOperationContext( session, dn, SchemaConstants.ALL_USER_ATTRIBUTES_ARRAY );
-
- Entry importedEntry = directoryService.getPartitionNexus().lookup( lookupContext );
-
- // As the target entry does not exist yet and so
- // its subentry operational attributes are not there,
- // we need to construct an entry to represent it
- // at least with minimal requirements which are object class
- // and access control subentry operational attributes.
- Entry fakeImportedEntry = subentryUtils.getSubentryAttributes( newDn, importedEntry );
+ Entry renamedEntry = ((ClonedServerEntry)renameContext.getEntry()).getClonedEntry();
- for ( Attribute attribute : importedEntry )
- {
- fakeImportedEntry.put( attribute );
- }
+ // @TODO : To be completely reviewed !!!
+ Rdn oldRdn = name.getRdn();
+ Dn oldSuperiorDn = name.getParent();
+ Dn newSuperiorDn = oldSuperiorDn;
+ Dn oldDn = name;
+ Dn newDn = name;
+ newDn = newDn.add( newRdn );
- // Gather Trigger Specifications which apply to the entry being imported.
- // Note: Entry Trigger Specifications are not valid for Import.
- List<TriggerSpecification> importTriggerSpecs = new ArrayList<TriggerSpecification>();
- addPrescriptiveTriggerSpecs( moveContext, importTriggerSpecs, newDn, fakeImportedEntry );
+ StoredProcedureParameterInjector injector = new ModifyDNStoredProcedureParameterInjector( renameContext,
+ deleteOldRn, oldRdn, newRdn, oldSuperiorDn, newSuperiorDn, oldDn, newDn);
- Map<ActionTime, List<TriggerSpecification>> exportTriggerMap = getActionTimeMappedTriggerSpecsForOperation(
- exportTriggerSpecs, LdapOperation.MODIFYDN_EXPORT );
+ // Gather Trigger Specifications which apply to the entry being renamed.
+ List<TriggerSpecification> triggerSpecs = new ArrayList<TriggerSpecification>();
+ addPrescriptiveTriggerSpecs( renameContext, triggerSpecs, name, renamedEntry );
+ addEntryTriggerSpecs( triggerSpecs, renamedEntry );
- Map<ActionTime, List<TriggerSpecification>> importTriggerMap = getActionTimeMappedTriggerSpecsForOperation(
- importTriggerSpecs, LdapOperation.MODIFYDN_IMPORT );
+ Map<ActionTime, List<TriggerSpecification>> triggerMap = getActionTimeMappedTriggerSpecsForOperation(
+ triggerSpecs, LdapOperation.MODIFYDN_RENAME );
- next( moveContext );
- triggerSpecCache.subentryRenamed( dn, newDn );
+ next( renameContext );
+ triggerSpecCache.subentryRenamed( name, newDn);
// Fire AFTER Triggers.
- List<TriggerSpecification> afterExportTriggerSpecs = exportTriggerMap.get( ActionTime.AFTER );
- List<TriggerSpecification> afterImportTriggerSpecs = importTriggerMap.get( ActionTime.AFTER );
- executeTriggers( moveContext, afterExportTriggerSpecs, injector );
- executeTriggers( moveContext, afterImportTriggerSpecs, injector );
+ List<TriggerSpecification> afterTriggerSpecs = triggerMap.get( ActionTime.AFTER );
+ executeTriggers( renameContext, afterTriggerSpecs, injector );
}
@@ -559,7 +574,7 @@ public class TriggerInterceptor extends
private Object executeTriggers( OperationContext opContext, List<TriggerSpecification> triggerSpecs,
StoredProcedureParameterInjector injector ) throws LdapException
- {
+ {
Object result = null;
for ( TriggerSpecification triggerSpec : triggerSpecs )
@@ -580,12 +595,12 @@ public class TriggerInterceptor extends
* can make sense (as in INSTEADOF Search Triggers).
*/
return result;
- }
+ }
private Object executeTrigger( OperationContext opContext, TriggerSpecification tsec,
StoredProcedureParameterInjector injector ) throws LdapException
- {
+ {
List<Object> returnValues = new ArrayList<Object>();
List<SPSpec> spSpecs = tsec.getSPSpecs();
@@ -599,7 +614,7 @@ public class TriggerInterceptor extends
}
return returnValues;
- }
+ }
private Object executeProcedure( OperationContext opContext, String procedure, Object[] values ) throws LdapException