You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ak...@apache.org on 2008/06/02 16:00:26 UTC
svn commit: r662440 [6/8] - in /directory:
apacheds/branches/bigbang/core-integ/src/main/java/org/apache/directory/server/core/integ/
apacheds/branches/bigbang/core-integ/src/test/java/org/apache/directory/server/core/authn/
apacheds/branches/bigbang/c...
Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/schema/SchemaOperationControl.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/schema/SchemaOperationControl.java?rev=662440&r1=662439&r2=662440&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/schema/SchemaOperationControl.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/schema/SchemaOperationControl.java Mon Jun 2 07:00:23 2008
@@ -34,15 +34,19 @@
import org.apache.directory.server.core.authz.AciAuthorizationInterceptor;
import org.apache.directory.server.core.authz.DefaultAuthorizationInterceptor;
import org.apache.directory.server.core.collective.CollectiveAttributeInterceptor;
+import org.apache.directory.server.core.entry.ClonedServerEntry;
import org.apache.directory.server.core.entry.DefaultServerAttribute;
import org.apache.directory.server.core.entry.ServerEntry;
import org.apache.directory.server.core.entry.ServerAttribute;
import org.apache.directory.server.core.entry.ServerModification;
import org.apache.directory.server.core.exception.ExceptionInterceptor;
+import org.apache.directory.server.core.interceptor.context.AddOperationContext;
+import org.apache.directory.server.core.interceptor.context.DeleteOperationContext;
import org.apache.directory.server.core.interceptor.context.ModifyOperationContext;
-import org.apache.directory.server.core.invocation.Invocation;
-import org.apache.directory.server.core.invocation.InvocationStack;
-import org.apache.directory.server.core.jndi.ServerLdapContext;
+import org.apache.directory.server.core.interceptor.context.MoveAndRenameOperationContext;
+import org.apache.directory.server.core.interceptor.context.MoveOperationContext;
+import org.apache.directory.server.core.interceptor.context.OperationContext;
+import org.apache.directory.server.core.interceptor.context.RenameOperationContext;
import org.apache.directory.server.core.normalization.NormalizationInterceptor;
import org.apache.directory.server.core.referral.ReferralInterceptor;
import org.apache.directory.server.schema.registries.AttributeTypeRegistry;
@@ -60,7 +64,6 @@
import org.apache.directory.shared.ldap.exception.LdapOperationNotSupportedException;
import org.apache.directory.shared.ldap.message.ResultCodeEnum;
import org.apache.directory.shared.ldap.name.LdapDN;
-import org.apache.directory.shared.ldap.name.Rdn;
import org.apache.directory.shared.ldap.schema.AttributeType;
import org.apache.directory.shared.ldap.schema.DITContentRule;
import org.apache.directory.shared.ldap.schema.DITStructureRule;
@@ -287,9 +290,9 @@
}
- public void add( LdapDN name, ServerEntry entry ) throws Exception
+ public void add( AddOperationContext opContext ) throws Exception
{
- EntryAttribute oc = entry.get( objectClassAT );
+ EntryAttribute oc = opContext.getEntry().get( objectClassAT );
for ( Value<?> value:oc )
{
@@ -299,29 +302,29 @@
if ( objectClass2handlerMap.containsKey( oid ) )
{
SchemaChangeHandler handler = objectClass2handlerMap.get( oid );
- handler.add( name, entry );
- updateSchemaModificationAttributes();
+ handler.add( opContext.getDn(), opContext.getEntry() );
+ updateSchemaModificationAttributes( opContext );
return;
}
}
if ( oc.contains( MetaSchemaConstants.META_SCHEMA_OC ) )
{
- metaSchemaHandler.add( name, entry );
- updateSchemaModificationAttributes();
+ metaSchemaHandler.add( opContext.getDn(), opContext.getEntry() );
+ updateSchemaModificationAttributes( opContext );
return;
}
if ( oc.contains( SchemaConstants.ORGANIZATIONAL_UNIT_OC ) )
{
- if ( name.size() != 3 )
+ if ( opContext.getDn().size() != 3 )
{
throw new LdapInvalidNameException(
"Schema entity containers of objectClass organizationalUnit should be 3 name components in length.",
ResultCodeEnum.NAMING_VIOLATION );
}
- String ouValue = ( String ) name.getRdn().getValue();
+ String ouValue = ( String ) opContext.getDn().getRdn().getValue();
ouValue = ouValue.trim().toLowerCase();
if ( ! VALID_OU_VALUES.contains( ouValue ) )
{
@@ -336,7 +339,8 @@
}
- public void delete( LdapDN name, ServerEntry entry, boolean doCascadeDelete ) throws Exception
+ public void delete( DeleteOperationContext opContext, ClonedServerEntry entry, boolean doCascadeDelete )
+ throws Exception
{
EntryAttribute oc = entry.get( objectClassAT );
@@ -347,29 +351,29 @@
if ( objectClass2handlerMap.containsKey( oid ) )
{
SchemaChangeHandler handler = objectClass2handlerMap.get( oid );
- handler.delete( name, entry, doCascadeDelete );
- updateSchemaModificationAttributes();
+ handler.delete( opContext.getDn(), entry, doCascadeDelete );
+ updateSchemaModificationAttributes( opContext );
return;
}
}
if ( oc.contains( MetaSchemaConstants.META_SCHEMA_OC ) )
{
- metaSchemaHandler.delete( name, entry, doCascadeDelete );
- updateSchemaModificationAttributes();
+ metaSchemaHandler.delete( opContext.getDn(), entry, doCascadeDelete );
+ updateSchemaModificationAttributes( opContext );
return;
}
if ( oc.contains( SchemaConstants.ORGANIZATIONAL_UNIT_OC ) )
{
- if ( name.size() != 3 )
+ if ( opContext.getDn().size() != 3 )
{
throw new LdapNamingException(
"Only schema entity containers of objectClass organizationalUnit with 3 name components in length" +
" can be deleted.", ResultCodeEnum.UNWILLING_TO_PERFORM );
}
- String ouValue = ( String ) name.getRdn().getValue();
+ String ouValue = ( String ) opContext.getDn().getRdn().getValue();
ouValue = ouValue.trim().toLowerCase();
if ( ! VALID_OU_VALUES.contains( ouValue ) )
{
@@ -384,8 +388,8 @@
}
- public void modify( LdapDN name, ModificationOperation modOp, ServerEntry mods, ServerEntry entry,
- ServerEntry targetEntry, boolean cascade ) throws Exception
+ public void modify( ModifyOperationContext opContext, ModificationOperation modOp, ServerEntry mods,
+ ServerEntry entry, ServerEntry targetEntry, boolean cascade ) throws Exception
{
EntryAttribute oc = entry.get( objectClassAT );
@@ -396,16 +400,16 @@
if ( objectClass2handlerMap.containsKey( oid ) )
{
SchemaChangeHandler handler = objectClass2handlerMap.get( oid );
- handler.modify( name, modOp, mods, entry, targetEntry, cascade );
- updateSchemaModificationAttributes();
+ handler.modify( opContext.getDn(), modOp, mods, entry, targetEntry, cascade );
+ updateSchemaModificationAttributes( opContext );
return;
}
}
if ( oc.contains( MetaSchemaConstants.META_SCHEMA_OC ) )
{
- metaSchemaHandler.modify( name, modOp, mods, entry, targetEntry, cascade );
- updateSchemaModificationAttributes();
+ metaSchemaHandler.modify( opContext.getDn(), modOp, mods, entry, targetEntry, cascade );
+ updateSchemaModificationAttributes( opContext );
return;
}
@@ -413,8 +417,8 @@
}
- public void modify( LdapDN name, List<Modification> mods, ServerEntry entry, ServerEntry targetEntry,
- boolean doCascadeModify ) throws Exception
+ public void modify( ModifyOperationContext opContext, ServerEntry entry,
+ ServerEntry targetEntry, boolean doCascadeModify ) throws Exception
{
EntryAttribute oc = entry.get( objectClassAT );
@@ -425,26 +429,26 @@
if ( objectClass2handlerMap.containsKey( oid ) )
{
SchemaChangeHandler handler = objectClass2handlerMap.get( oid );
- handler.modify( name, mods, entry, targetEntry, doCascadeModify );
- updateSchemaModificationAttributes();
+ handler.modify( opContext.getDn(), opContext.getModItems(), entry, targetEntry, doCascadeModify );
+ updateSchemaModificationAttributes( opContext );
return;
}
}
if ( oc.contains( MetaSchemaConstants.META_SCHEMA_OC ) )
{
- metaSchemaHandler.modify( name, mods, entry, targetEntry, doCascadeModify );
- updateSchemaModificationAttributes();
+ metaSchemaHandler.modify( opContext.getDn(), opContext.getModItems(), entry, targetEntry, doCascadeModify );
+ updateSchemaModificationAttributes( opContext );
return;
}
- LOG.error( String.format( "Unwilling to perform modify on %s:\n\nEntry:\n%s\n\nModifications:\n%s", name,
- entry, mods ) );
+ LOG.error( String.format( "Unwilling to perform modify on %s:\n\nEntry:\n%s\n\nModifications:\n%s",
+ opContext.getDn(), entry, opContext.getModItems() ) );
throw new LdapOperationNotSupportedException( ResultCodeEnum.UNWILLING_TO_PERFORM );
}
- public void modifyRn( LdapDN name, Rdn newRdn, boolean deleteOldRn, ServerEntry entry, boolean doCascadeModify )
+ public void modifyRn( RenameOperationContext opContext, ServerEntry entry, boolean doCascadeModify )
throws Exception
{
EntryAttribute oc = entry.get( objectClassAT );
@@ -456,16 +460,16 @@
if ( objectClass2handlerMap.containsKey( oid ) )
{
SchemaChangeHandler handler = objectClass2handlerMap.get( oid );
- handler.rename( name, entry, newRdn, doCascadeModify );
- updateSchemaModificationAttributes();
+ handler.rename( opContext.getDn(), entry, opContext.getNewRdn(), doCascadeModify );
+ updateSchemaModificationAttributes( opContext );
return;
}
}
if ( oc.contains( MetaSchemaConstants.META_SCHEMA_OC ) )
{
- metaSchemaHandler.rename( name, entry, newRdn, doCascadeModify );
- updateSchemaModificationAttributes();
+ metaSchemaHandler.rename( opContext.getDn(), entry, opContext.getNewRdn(), doCascadeModify );
+ updateSchemaModificationAttributes( opContext );
return;
}
@@ -473,8 +477,7 @@
}
- public void replace( LdapDN oriChildName, LdapDN newParentName, ServerEntry entry,
- boolean cascade ) throws Exception
+ public void replace( MoveOperationContext opContext, ServerEntry entry, boolean cascade ) throws Exception
{
EntryAttribute oc = entry.get( objectClassAT );
@@ -485,16 +488,16 @@
if ( objectClass2handlerMap.containsKey( oid ) )
{
SchemaChangeHandler handler = objectClass2handlerMap.get( oid );
- handler.replace( oriChildName, newParentName, entry, cascade );
- updateSchemaModificationAttributes();
+ handler.replace( opContext.getDn(), opContext.getParent(), entry, cascade );
+ updateSchemaModificationAttributes( opContext );
return;
}
}
if ( oc.contains( MetaSchemaConstants.META_SCHEMA_OC ) )
{
- metaSchemaHandler.replace( oriChildName, newParentName, entry, cascade );
- updateSchemaModificationAttributes();
+ metaSchemaHandler.replace( opContext.getDn(), opContext.getParent(), entry, cascade );
+ updateSchemaModificationAttributes( opContext );
return;
}
@@ -502,8 +505,7 @@
}
- public void move( LdapDN oriChildName, LdapDN newParentName, Rdn newRn, boolean deleteOldRn,
- ServerEntry entry, boolean cascade ) throws Exception
+ public void move( MoveAndRenameOperationContext opContext, ServerEntry entry, boolean cascade ) throws Exception
{
EntryAttribute oc = entry.get( objectClassAT );
@@ -514,16 +516,18 @@
if ( objectClass2handlerMap.containsKey( oid ) )
{
SchemaChangeHandler handler = objectClass2handlerMap.get( oid );
- handler.move( oriChildName, newParentName, newRn, deleteOldRn, entry, cascade );
- updateSchemaModificationAttributes();
+ handler.move( opContext.getDn(), opContext.getParent(), opContext.getNewRdn(),
+ opContext.getDelOldDn(), entry, cascade );
+ updateSchemaModificationAttributes( opContext );
return;
}
}
if ( oc.contains( MetaSchemaConstants.META_SCHEMA_OC ) )
{
- metaSchemaHandler.move( oriChildName, newParentName, newRn, deleteOldRn, entry, cascade );
- updateSchemaModificationAttributes();
+ metaSchemaHandler.move( opContext.getDn(), opContext.getParent(), opContext.getNewRdn(),
+ opContext.getDelOldDn(), entry, cascade );
+ updateSchemaModificationAttributes( opContext );
return;
}
@@ -544,10 +548,10 @@
* to effect all dependents on the changed entity
* @throws NamingException if the operation fails
*/
- public void modifySchemaSubentry( LdapDN name, List<Modification> mods, ServerEntry subentry,
- ServerEntry targetSubentry, boolean doCascadeModify ) throws Exception
+ public void modifySchemaSubentry( ModifyOperationContext opContext,
+ ServerEntry subentry, ServerEntry targetSubentry, boolean doCascadeModify ) throws Exception
{
- for ( Modification mod : mods )
+ for ( Modification mod : opContext.getModItems() )
{
String opAttrOid = registries.getOidRegistry().getOid( mod.getAttribute().getId() );
@@ -557,11 +561,11 @@
{
case ADD_ATTRIBUTE :
- modifyAddOperation( opAttrOid, serverAttribute, doCascadeModify );
+ modifyAddOperation( opContext, opAttrOid, serverAttribute, doCascadeModify );
break;
case REMOVE_ATTRIBUTE :
- modifyRemoveOperation( opAttrOid, serverAttribute, doCascadeModify );
+ modifyRemoveOperation( opContext, opAttrOid, serverAttribute, doCascadeModify );
break;
case REPLACE_ATTRIBUTE :
@@ -577,9 +581,9 @@
}
}
- if ( mods.size() > 0 )
+ if ( opContext.getModItems().size() > 0 )
{
- updateSchemaModificationAttributes();
+ updateSchemaModificationAttributes( opContext );
}
}
@@ -598,8 +602,8 @@
* to effect all dependents on the changed entity
* @throws NamingException if the modify fails
*/
- public void modifySchemaSubentry( LdapDN name, int modOp, ServerEntry mods, ServerEntry subentry,
- ServerEntry targetSubentry, boolean doCascadeModify ) throws Exception
+ public void modifySchemaSubentry( ModifyOperationContext opContext, LdapDN name, int modOp, ServerEntry mods,
+ ServerEntry subentry, ServerEntry targetSubentry, boolean doCascadeModify ) throws Exception
{
Set<AttributeType> attributeTypes = mods.getAttributeTypes();
@@ -608,7 +612,7 @@
case( DirContext.ADD_ATTRIBUTE ):
for ( AttributeType attributeType:attributeTypes )
{
- modifyAddOperation( attributeType.getOid(),
+ modifyAddOperation( opContext, attributeType.getOid(),
mods.get( attributeType ), doCascadeModify );
}
@@ -617,7 +621,7 @@
case( DirContext.REMOVE_ATTRIBUTE ):
for ( AttributeType attributeType:attributeTypes )
{
- modifyRemoveOperation( attributeType.getOid(),
+ modifyRemoveOperation( opContext, attributeType.getOid(),
mods.get( attributeType ), doCascadeModify );
}
@@ -635,7 +639,7 @@
throw new IllegalStateException( "Undefined modify operation: " + modOp );
}
- updateSchemaModificationAttributes();
+ updateSchemaModificationAttributes( opContext );
}
@@ -660,8 +664,8 @@
* @throws NamingException if there are problems updating the registries and the
* schema partition
*/
- private void modifyRemoveOperation( String opAttrOid, EntryAttribute mods, boolean doCascadeModify )
- throws Exception
+ private void modifyRemoveOperation( ModifyOperationContext opContext, String opAttrOid,
+ EntryAttribute mods, boolean doCascadeModify ) throws Exception
{
int index = opAttr2handlerIndex.get( opAttrOid );
SchemaChangeHandler handler = opAttr2handlerMap.get( opAttrOid );
@@ -675,7 +679,7 @@
for ( ComparatorDescription comparatorDescription : comparatorDescriptions )
{
comparatorHandler.delete( comparatorDescription.getNumericOid(), doCascadeModify );
- subentryModifier.delete( registries, comparatorDescription );
+ subentryModifier.delete( opContext, comparatorDescription );
}
break;
case( NORMALIZER_INDEX ):
@@ -685,7 +689,7 @@
for ( NormalizerDescription normalizerDescription : normalizerDescriptions )
{
normalizerHandler.delete( normalizerDescription.getNumericOid(), doCascadeModify );
- subentryModifier.delete( registries, normalizerDescription );
+ subentryModifier.delete( opContext, normalizerDescription );
}
break;
case( SYNTAX_CHECKER_INDEX ):
@@ -695,7 +699,7 @@
for ( SyntaxCheckerDescription syntaxCheckerDescription : syntaxCheckerDescriptions )
{
syntaxCheckerHandler.delete( syntaxCheckerDescription.getNumericOid(), doCascadeModify );
- subentryModifier.delete( registries, syntaxCheckerDescription );
+ subentryModifier.delete( opContext, syntaxCheckerDescription );
}
break;
case( SYNTAX_INDEX ):
@@ -705,7 +709,7 @@
for ( Syntax syntax : syntaxes )
{
syntaxHandler.delete( syntax, doCascadeModify );
- subentryModifier.deleteSchemaObject( registries, syntax );
+ subentryModifier.deleteSchemaObject( opContext, syntax );
}
break;
case( MATCHING_RULE_INDEX ):
@@ -715,7 +719,7 @@
for ( MatchingRule mr : mrs )
{
matchingRuleHandler.delete( mr, doCascadeModify );
- subentryModifier.deleteSchemaObject( registries, mr );
+ subentryModifier.deleteSchemaObject( opContext, mr );
}
break;
case( ATTRIBUTE_TYPE_INDEX ):
@@ -725,7 +729,7 @@
for ( AttributeType at : ats )
{
atHandler.delete( at, doCascadeModify );
- subentryModifier.deleteSchemaObject( registries, at );
+ subentryModifier.deleteSchemaObject( opContext, at );
}
break;
case( OBJECT_CLASS_INDEX ):
@@ -735,7 +739,7 @@
for ( ObjectClass oc : ocs )
{
ocHandler.delete( oc, doCascadeModify );
- subentryModifier.deleteSchemaObject( registries, oc );
+ subentryModifier.deleteSchemaObject( opContext, oc );
}
break;
case( MATCHING_RULE_USE_INDEX ):
@@ -745,7 +749,7 @@
for ( MatchingRuleUse mru : mrus )
{
mruHandler.delete( mru, doCascadeModify );
- subentryModifier.deleteSchemaObject( registries, mru );
+ subentryModifier.deleteSchemaObject( opContext, mru );
}
break;
case( DIT_STRUCTURE_RULE_INDEX ):
@@ -755,7 +759,7 @@
for ( DITStructureRule dsr : dsrs )
{
dsrHandler.delete( dsr, doCascadeModify );
- subentryModifier.deleteSchemaObject( registries, dsr );
+ subentryModifier.deleteSchemaObject( opContext, dsr );
}
break;
case( DIT_CONTENT_RULE_INDEX ):
@@ -765,7 +769,7 @@
for ( DITContentRule dcr : dcrs )
{
dcrHandler.delete( dcr, doCascadeModify );
- subentryModifier.deleteSchemaObject( registries, dcr );
+ subentryModifier.deleteSchemaObject( opContext, dcr );
}
break;
case( NAME_FORM_INDEX ):
@@ -775,7 +779,7 @@
for ( NameForm nf : nfs )
{
nfHandler.delete( nf, doCascadeModify );
- subentryModifier.deleteSchemaObject( registries, nf );
+ subentryModifier.deleteSchemaObject( opContext, nf );
}
break;
default:
@@ -794,7 +798,8 @@
* @throws NamingException if there are problems updating the registries and the
* schema partition
*/
- private void modifyAddOperation( String opAttrOid, EntryAttribute mods, boolean doCascadeModify ) throws Exception
+ private void modifyAddOperation( ModifyOperationContext opContext, String opAttrOid,
+ EntryAttribute mods, boolean doCascadeModify ) throws Exception
{
if ( doCascadeModify )
{
@@ -813,7 +818,7 @@
for ( ComparatorDescription comparatorDescription : comparatorDescriptions )
{
comparatorHandler.add( comparatorDescription );
- subentryModifier.add( registries, comparatorDescription );
+ subentryModifier.add( opContext, comparatorDescription );
}
break;
case( NORMALIZER_INDEX ):
@@ -823,7 +828,7 @@
for ( NormalizerDescription normalizerDescription : normalizerDescriptions )
{
normalizerHandler.add( normalizerDescription );
- subentryModifier.add( registries, normalizerDescription );
+ subentryModifier.add( opContext, normalizerDescription );
}
break;
case( SYNTAX_CHECKER_INDEX ):
@@ -833,7 +838,7 @@
for ( SyntaxCheckerDescription syntaxCheckerDescription : syntaxCheckerDescriptions )
{
syntaxCheckerHandler.add( syntaxCheckerDescription );
- subentryModifier.add( registries, syntaxCheckerDescription );
+ subentryModifier.add( opContext, syntaxCheckerDescription );
}
break;
case( SYNTAX_INDEX ):
@@ -843,7 +848,7 @@
for ( Syntax syntax : syntaxes )
{
syntaxHandler.add( syntax );
- subentryModifier.addSchemaObject( registries, syntax );
+ subentryModifier.addSchemaObject( opContext, syntax );
}
break;
case( MATCHING_RULE_INDEX ):
@@ -853,7 +858,7 @@
for ( MatchingRule mr : mrs )
{
matchingRuleHandler.add( mr );
- subentryModifier.addSchemaObject( registries, mr );
+ subentryModifier.addSchemaObject( opContext, mr );
}
break;
case( ATTRIBUTE_TYPE_INDEX ):
@@ -863,7 +868,7 @@
for ( AttributeType at : ats )
{
atHandler.add( at );
- subentryModifier.addSchemaObject( registries, at );
+ subentryModifier.addSchemaObject( opContext, at );
}
break;
case( OBJECT_CLASS_INDEX ):
@@ -873,7 +878,7 @@
for ( ObjectClass oc : ocs )
{
ocHandler.add( oc );
- subentryModifier.addSchemaObject( registries, oc );
+ subentryModifier.addSchemaObject( opContext, oc );
}
break;
case( MATCHING_RULE_USE_INDEX ):
@@ -883,7 +888,7 @@
for ( MatchingRuleUse mru : mrus )
{
mruHandler.add( mru );
- subentryModifier.addSchemaObject( registries, mru );
+ subentryModifier.addSchemaObject( opContext, mru );
}
break;
case( DIT_STRUCTURE_RULE_INDEX ):
@@ -893,7 +898,7 @@
for ( DITStructureRule dsr : dsrs )
{
dsrHandler.add( dsr );
- subentryModifier.addSchemaObject( registries, dsr );
+ subentryModifier.addSchemaObject( opContext, dsr );
}
break;
case( DIT_CONTENT_RULE_INDEX ):
@@ -903,7 +908,7 @@
for ( DITContentRule dcr : dcrs )
{
dcrHandler.add( dcr );
- subentryModifier.addSchemaObject( registries, dcr );
+ subentryModifier.addSchemaObject( opContext, dcr );
}
break;
case( NAME_FORM_INDEX ):
@@ -913,7 +918,7 @@
for ( NameForm nf : nfs )
{
nfHandler.add( nf );
- subentryModifier.addSchemaObject( registries, nf );
+ subentryModifier.addSchemaObject( opContext, nf );
}
break;
default:
@@ -933,11 +938,9 @@
*
* @throws NamingException if the update fails
*/
- private void updateSchemaModificationAttributes() throws Exception
+ private void updateSchemaModificationAttributes( OperationContext opContext ) throws Exception
{
- Invocation invocation = InvocationStack.getInstance().peek();
- ServerLdapContext ctx = ( ServerLdapContext ) invocation.getCaller();
- String modifiersName = ctx.getPrincipal().getJndiName().getNormName();
+ String modifiersName = opContext.getSession().getEffectivePrincipal().getJndiName().getNormName();
String modifyTimestamp = DateUtils.getGeneralizedTime();
List<Modification> mods = new ArrayList<Modification>( 2 );
@@ -957,7 +960,8 @@
LdapDN name = new LdapDN( "cn=schemaModifications,ou=schema" );
name.normalize( registries.getAttributeTypeRegistry().getNormalizerMapping() );
- invocation.getProxy().modify( new ModifyOperationContext( registries, name, mods, true ),
- SCHEMA_MODIFICATION_ATTRIBUTES_UPDATE_BYPASS );
+ ModifyOperationContext modifyContext = new ModifyOperationContext( opContext.getSession(), name, mods, true );
+ modifyContext.setByPassed( SCHEMA_MODIFICATION_ATTRIBUTES_UPDATE_BYPASS );
+ opContext.getSession().getDirectoryService().getOperationManager().modify( modifyContext );
}
}
Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/schema/SchemaPartitionDao.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/schema/SchemaPartitionDao.java?rev=662440&r1=662439&r2=662440&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/schema/SchemaPartitionDao.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/schema/SchemaPartitionDao.java Mon Jun 2 07:00:23 2008
@@ -51,11 +51,13 @@
import org.apache.directory.shared.ldap.filter.ExprNode;
import org.apache.directory.shared.ldap.filter.OrNode;
import org.apache.directory.shared.ldap.filter.PresenceNode;
+import org.apache.directory.shared.ldap.filter.SearchScope;
import org.apache.directory.shared.ldap.filter.SimpleNode;
import org.apache.directory.shared.ldap.message.AliasDerefMode;
import org.apache.directory.shared.ldap.name.LdapDN;
import org.apache.directory.shared.ldap.name.Rdn;
import org.apache.directory.shared.ldap.schema.AttributeType;
+import org.apache.directory.shared.ldap.schema.AttributeTypeOptions;
import org.apache.directory.shared.ldap.schema.MatchingRule;
import org.apache.directory.shared.ldap.schema.ObjectClass;
import org.apache.directory.shared.ldap.schema.syntax.NumericOidSyntaxChecker;
@@ -92,11 +94,10 @@
private final Logger LOG = LoggerFactory.getLogger( getClass() );
private static final NumericOidSyntaxChecker NUMERIC_OID_CHECKER = new NumericOidSyntaxChecker();
private static final String[] SCHEMA_ATTRIBUTES = new String[]
- { SchemaConstants.CREATORS_NAME_AT, "m-dependencies", SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.CN_AT,
- "m-disabled" };
+ { SchemaConstants.CREATORS_NAME_AT_OID, "m-dependencies", SchemaConstants.OBJECT_CLASS_AT_OID,
+ SchemaConstants.CN_AT_OID, "m-disabled" };
private final Partition partition;
- private final Registries registries;
private final SchemaEntityFactory factory;
private final OidRegistry oidRegistry;
private final AttributeTypeRegistry attrRegistry;
@@ -117,6 +118,7 @@
private final String M_SUP_OBJECT_CLASS_OID;
private final String M_DEPENDENCIES_OID;
+ private final Set<AttributeTypeOptions> schemaAttributesToReturn = new HashSet<AttributeTypeOptions>();
private final AttributeType disabledAttributeType;
@@ -130,7 +132,6 @@
public SchemaPartitionDao( Partition partition, Registries registries ) throws Exception
{
this.partition = partition;
- this.registries = registries;
this.factory = new SchemaEntityFactory( registries );
this.oidRegistry = registries.getOidRegistry();
this.attrRegistry = registries.getAttributeTypeRegistry();
@@ -151,6 +152,12 @@
this.M_OC_OID = oidRegistry.getOid( MetaSchemaConstants.M_OC_AT );
this.M_SUP_OBJECT_CLASS_OID = oidRegistry.getOid( MetaSchemaConstants.M_SUP_OBJECT_CLASS_AT );
this.M_DEPENDENCIES_OID = oidRegistry.getOid( MetaSchemaConstants.M_DEPENDENCIES_AT );
+
+ for ( String attrId : SCHEMA_ATTRIBUTES )
+ {
+ AttributeTypeOptions ato = new AttributeTypeOptions( attrRegistry.lookup( attrId ) );
+ schemaAttributesToReturn.add( ato );
+ }
}
@@ -191,11 +198,13 @@
base.normalize( attrRegistry.getNormalizerMapping() );
ExprNode filter = new EqualityNode<String>( oidRegistry.getOid( SchemaConstants.OBJECT_CLASS_AT ),
new ClientStringValue( MetaSchemaConstants.META_SCHEMA_OC ) );
- SearchControls searchControls = new SearchControls();
- searchControls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
- searchControls.setReturningAttributes( SCHEMA_ATTRIBUTES );
- return partition.search( new SearchOperationContext( registries, base, AliasDerefMode.DEREF_ALWAYS, filter,
- searchControls ) );
+
+ SearchOperationContext searchContext = new SearchOperationContext( null );
+ searchContext.setDn( base );
+ searchContext.setScope( SearchScope.ONELEVEL );
+ searchContext.setReturningAttributes( schemaAttributesToReturn );
+ searchContext.setFilter( filter );
+ return partition.search( searchContext );
}
@@ -203,7 +212,7 @@
{
LdapDN dn = new LdapDN( "cn=" + schemaName + ",ou=schema" );
dn.normalize( attrRegistry.getNormalizerMapping() );
- return factory.getSchema( partition.lookup( new LookupOperationContext( registries, dn ) ) );
+ return factory.getSchema( partition.lookup( new LookupOperationContext( null, dn ) ) );
}
@@ -228,7 +237,7 @@
try
{
- cursor = partition.search( new SearchOperationContext( registries, partition.getSuffixDn(),
+ cursor = partition.search( new SearchOperationContext( null, partition.getSuffixDn(),
AliasDerefMode.DEREF_ALWAYS, filter, searchControls ) );
if ( !cursor.next() )
@@ -274,7 +283,7 @@
try
{
- cursor = partition.search( new SearchOperationContext( registries, partition.getSuffixDn(),
+ cursor = partition.search( new SearchOperationContext( null, partition.getSuffixDn(),
AliasDerefMode.DEREF_ALWAYS, filter, searchControls ) );
if ( !cursor.next() )
@@ -320,7 +329,7 @@
try
{
- cursor = partition.search( new SearchOperationContext( registries, partition.getSuffixDn(),
+ cursor = partition.search( new SearchOperationContext( null, partition.getSuffixDn(),
AliasDerefMode.DEREF_ALWAYS, filter, searchControls ) );
if ( !cursor.next() )
@@ -366,7 +375,7 @@
try
{
- cursor = partition.search( new SearchOperationContext( registries, partition.getSuffixDn(),
+ cursor = partition.search( new SearchOperationContext( null, partition.getSuffixDn(),
AliasDerefMode.DEREF_ALWAYS, filter, searchControls ) );
if ( !cursor.next() )
@@ -412,7 +421,7 @@
try
{
- cursor = partition.search( new SearchOperationContext( registries, partition.getSuffixDn(),
+ cursor = partition.search( new SearchOperationContext( null, partition.getSuffixDn(),
AliasDerefMode.DEREF_ALWAYS, filter, searchControls ) );
if ( !cursor.next() )
@@ -508,7 +517,7 @@
try
{
- cursor = partition.search( new SearchOperationContext( registries, partition.getSuffixDn(),
+ cursor = partition.search( new SearchOperationContext( null, partition.getSuffixDn(),
AliasDerefMode.DEREF_ALWAYS, filter, searchControls ) );
if ( !cursor.next() )
@@ -569,7 +578,7 @@
{
LdapDN dn = new LdapDN( "cn=" + schemaName + ",ou=schema" );
dn.normalize( attrRegistry.getNormalizerMapping() );
- ServerEntry entry = partition.lookup( new LookupOperationContext( registries, dn ) );
+ ServerEntry entry = partition.lookup( new LookupOperationContext( null, dn ) );
EntryAttribute disabledAttr = entry.get( disabledAttributeType );
List<Modification> mods = new ArrayList<Modification>( 3 );
@@ -597,7 +606,7 @@
SchemaConstants.MODIFY_TIMESTAMP_AT, attrRegistry.lookup( SchemaConstants.MODIFY_TIMESTAMP_AT ), DateUtils
.getGeneralizedTime() ) ) );
- partition.modify( new ModifyOperationContext( registries, dn, mods ) );
+ partition.modify( new ModifyOperationContext( null, dn, mods ) );
}
@@ -630,7 +639,7 @@
try
{
- cursor = partition.search( new SearchOperationContext( registries, partition.getSuffixDn(),
+ cursor = partition.search( new SearchOperationContext( null, partition.getSuffixDn(),
AliasDerefMode.DEREF_ALWAYS, filter, searchControls ) );
while ( cursor.next() )
@@ -681,7 +690,7 @@
try
{
- cursor = partition.search( new SearchOperationContext( registries, partition.getSuffixDn(),
+ cursor = partition.search( new SearchOperationContext( null, partition.getSuffixDn(),
AliasDerefMode.DEREF_ALWAYS, filter, searchControls ) );
while ( cursor.next() )
@@ -710,7 +719,7 @@
// (& (m-oid=*) (m-name=*) )
filter.addNode( new PresenceNode( M_OID_OID ) );
filter.addNode( new PresenceNode( M_NAME_OID ) );
- return partition.search( new SearchOperationContext( registries, partition.getSuffixDn(),
+ return partition.search( new SearchOperationContext( null, partition.getSuffixDn(),
AliasDerefMode.DEREF_ALWAYS, filter, searchControls ) );
}
@@ -758,7 +767,7 @@
try
{
- cursor = partition.search( new SearchOperationContext( registries, partition.getSuffixDn(),
+ cursor = partition.search( new SearchOperationContext( null, partition.getSuffixDn(),
AliasDerefMode.DEREF_ALWAYS, filter, searchControls ) );
while ( cursor.next() )
@@ -807,7 +816,7 @@
try
{
- cursor = partition.search( new SearchOperationContext( registries, partition.getSuffixDn(),
+ cursor = partition.search( new SearchOperationContext( null, partition.getSuffixDn(),
AliasDerefMode.DEREF_ALWAYS, filter, searchControls ) );
while ( cursor.next() )
@@ -850,7 +859,7 @@
try
{
- cursor = partition.search( new SearchOperationContext( registries, partition.getSuffixDn(),
+ cursor = partition.search( new SearchOperationContext( null, partition.getSuffixDn(),
AliasDerefMode.DEREF_ALWAYS, filter, searchControls ) );
while ( cursor.next() )
@@ -930,7 +939,7 @@
try
{
- cursor = partition.search( new SearchOperationContext( registries, partition.getSuffixDn(),
+ cursor = partition.search( new SearchOperationContext( null, partition.getSuffixDn(),
AliasDerefMode.DEREF_ALWAYS, filter, searchControls ) );
while ( cursor.next() )
Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java?rev=662440&r1=662439&r2=662440&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java Mon Jun 2 07:00:23 2008
@@ -385,10 +385,10 @@
if ( schemaSubentry == null )
{
generateSchemaSubentry( schemaPartition.lookup(
- new LookupOperationContext( registries, schemaModificationAttributesDN ) ) );
+ new LookupOperationContext( null, schemaModificationAttributesDN ) ) );
}
- return (ServerEntry)schemaSubentry.clone();
+ return ( ServerEntry ) schemaSubentry.clone();
}
@@ -403,7 +403,7 @@
if ( schemaSubentry == null )
{
generateSchemaSubentry( schemaPartition.lookup(
- new LookupOperationContext( registries, schemaModificationAttributesDN ) ) );
+ new LookupOperationContext( null, schemaModificationAttributesDN ) ) );
}
return ( ServerEntry ) schemaSubentry.clone();
@@ -435,7 +435,8 @@
// Check if we need an update by looking at timestamps on disk
// ---------------------------------------------------------------
- ServerEntry mods = schemaPartition.lookup( new LookupOperationContext( registries, schemaModificationAttributesDN ) );
+ ServerEntry mods =
+ schemaPartition.lookup( new LookupOperationContext( null, schemaModificationAttributesDN ) );
// @todo enable this optimization at some point but for now it
// is causing some problems so I will just turn it off
// Attribute modifyTimeDisk = mods.get( SchemaConstants.MODIFY_TIMESTAMP_AT );
Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/schema/SchemaSubentryModifier.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/schema/SchemaSubentryModifier.java?rev=662440&r1=662439&r2=662440&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/schema/SchemaSubentryModifier.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/schema/SchemaSubentryModifier.java Mon Jun 2 07:00:23 2008
@@ -19,6 +19,7 @@
*/
package org.apache.directory.server.core.schema;
+
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
@@ -36,11 +37,9 @@
import org.apache.directory.server.core.exception.ExceptionInterceptor;
import org.apache.directory.server.core.interceptor.context.AddOperationContext;
import org.apache.directory.server.core.interceptor.context.DeleteOperationContext;
-import org.apache.directory.server.core.invocation.InvocationStack;
-import org.apache.directory.server.core.partition.PartitionNexusProxy;
+import org.apache.directory.server.core.interceptor.context.OperationContext;
import org.apache.directory.server.core.referral.ReferralInterceptor;
import org.apache.directory.server.schema.bootstrap.Schema;
-import org.apache.directory.server.schema.registries.Registries;
import org.apache.directory.server.utils.AttributesFactory;
import org.apache.directory.shared.ldap.constants.SchemaConstants;
import org.apache.directory.shared.ldap.message.AttributesImpl;
@@ -143,69 +142,106 @@
}
- public void addSchemaObject( Registries registries, SchemaObject obj ) throws Exception
+ public void add( OperationContext opContext, ComparatorDescription comparatorDescription ) throws Exception
+ {
+ String schemaName = getSchema( comparatorDescription );
+ LdapDN dn = new LdapDN( "m-oid=" + comparatorDescription.getNumericOid() + ",ou=comparators,cn="
+ + schemaName + ",ou=schema" );
+ Attributes attrs = getAttributes( comparatorDescription );
+ ServerEntry entry = ServerEntryUtils.toServerEntry( attrs, dn,
+ opContext.getSession().getDirectoryService().getRegistries() );
+
+ AddOperationContext addContext = new AddOperationContext( opContext.getSession(), dn, entry, true );
+ addContext.setByPassed( BYPASS );
+ opContext.getSession().getDirectoryService().getOperationManager().add( addContext );
+ }
+
+
+ public void add( OperationContext opContext, NormalizerDescription normalizerDescription ) throws Exception
+ {
+ String schemaName = getSchema( normalizerDescription );
+ LdapDN dn = new LdapDN( "m-oid=" + normalizerDescription.getNumericOid() + ",ou=normalizers,cn="
+ + schemaName + ",ou=schema" );
+ Attributes attrs = getAttributes( normalizerDescription );
+ ServerEntry entry = ServerEntryUtils.toServerEntry( attrs, dn,
+ opContext.getSession().getDirectoryService().getRegistries() );
+
+ AddOperationContext addContext = new AddOperationContext( opContext.getSession(), dn, entry, true );
+ addContext.setByPassed( BYPASS );
+ opContext.getSession().getDirectoryService().getOperationManager().add( addContext );
+ }
+
+
+ public void add( OperationContext opContext, SyntaxCheckerDescription syntaxCheckerDescription ) throws Exception
+ {
+ String schemaName = getSchema( syntaxCheckerDescription );
+ LdapDN dn = new LdapDN( "m-oid=" + syntaxCheckerDescription.getNumericOid() + ",ou=syntaxCheckers,cn="
+ + schemaName + ",ou=schema" );
+ Attributes attrs = getAttributes( syntaxCheckerDescription );
+ ServerEntry entry = ServerEntryUtils.toServerEntry( attrs, dn,
+ opContext.getSession().getDirectoryService().getRegistries() );
+ AddOperationContext addContext = new AddOperationContext( opContext.getSession(), dn, entry, true );
+ addContext.setByPassed( BYPASS );
+ opContext.getSession().getDirectoryService().getOperationManager().add( addContext );
+ }
+
+
+ public void addSchemaObject( OperationContext opContext, SchemaObject obj ) throws Exception
{
- PartitionNexusProxy proxy = InvocationStack.getInstance().peek().getProxy();
Schema schema = dao.getSchema( obj.getSchema() );
LdapDN dn = getDn( obj );
- ServerEntry entry = factory.getAttributes( obj, schema, registries );
+ ServerEntry entry = factory.getAttributes( obj, schema,
+ opContext.getSession().getDirectoryService().getRegistries() );
entry.setDn( dn );
- proxy.add( new AddOperationContext( registries, dn, entry, true ), BYPASS );
+ AddOperationContext addContext = new AddOperationContext( opContext.getSession(), dn, entry, true );
+ addContext.setByPassed( BYPASS );
+ opContext.getSession().getDirectoryService().getOperationManager().add( addContext );
}
- public void deleteSchemaObject( Registries registries, SchemaObject obj ) throws Exception
+ public void deleteSchemaObject( OperationContext opContext, SchemaObject obj ) throws Exception
{
- PartitionNexusProxy proxy = InvocationStack.getInstance().peek().getProxy();
LdapDN dn = getDn( obj );
- proxy.delete( new DeleteOperationContext( registries, dn, true ), BYPASS );
+ DeleteOperationContext delContext = new DeleteOperationContext( opContext.getSession(), dn, true );
+ delContext.setByPassed( BYPASS );
+ opContext.getSession().getDirectoryService().getOperationManager().delete( delContext );
}
- public void delete( Registries registries, NormalizerDescription normalizerDescription ) throws Exception
+ public void delete( OperationContext opContext, NormalizerDescription normalizerDescription ) throws Exception
{
String schemaName = getSchema( normalizerDescription );
- PartitionNexusProxy proxy = InvocationStack.getInstance().peek().getProxy();
LdapDN dn = new LdapDN( "m-oid=" + normalizerDescription.getNumericOid() + ",ou=normalizers,cn="
+ schemaName + ",ou=schema" );
- proxy.delete( new DeleteOperationContext( registries, dn, true ), BYPASS );
+ DeleteOperationContext delContext = new DeleteOperationContext( opContext.getSession(), dn, true );
+ delContext.setByPassed( BYPASS );
+ opContext.getSession().getDirectoryService().getOperationManager().delete( delContext );
}
- public void delete( Registries registries, SyntaxCheckerDescription syntaxCheckerDescription ) throws Exception
+ public void delete( OperationContext opContext, SyntaxCheckerDescription syntaxCheckerDescription ) throws Exception
{
String schemaName = getSchema( syntaxCheckerDescription );
- PartitionNexusProxy proxy = InvocationStack.getInstance().peek().getProxy();
LdapDN dn = new LdapDN( "m-oid=" + syntaxCheckerDescription.getNumericOid() + ",ou=syntaxCheckers,cn="
+ schemaName + ",ou=schema" );
- proxy.delete( new DeleteOperationContext( registries, dn, true ), BYPASS );
+ DeleteOperationContext delContext = new DeleteOperationContext( opContext.getSession(), dn, true );
+ delContext.setByPassed( BYPASS );
+ opContext.getSession().getDirectoryService().getOperationManager().delete( delContext );
}
- public void delete( Registries registries, ComparatorDescription comparatorDescription ) throws Exception
+ public void delete( OperationContext opContext, ComparatorDescription comparatorDescription ) throws Exception
{
String schemaName = getSchema( comparatorDescription );
- PartitionNexusProxy proxy = InvocationStack.getInstance().peek().getProxy();
LdapDN dn = new LdapDN( "m-oid=" + comparatorDescription.getNumericOid() + ",ou=comparators,cn="
+ schemaName + ",ou=schema" );
- proxy.delete( new DeleteOperationContext( registries, dn, true ), BYPASS );
+ DeleteOperationContext delContext = new DeleteOperationContext( opContext.getSession(), dn, true );
+ delContext.setByPassed( BYPASS );
+ opContext.getSession().getDirectoryService().getOperationManager().delete( delContext );
}
- public void add( Registries registries, ComparatorDescription comparatorDescription ) throws Exception
- {
- String schemaName = getSchema( comparatorDescription );
- PartitionNexusProxy proxy = InvocationStack.getInstance().peek().getProxy();
- LdapDN dn = new LdapDN( "m-oid=" + comparatorDescription.getNumericOid() + ",ou=comparators,cn="
- + schemaName + ",ou=schema" );
- Attributes attrs = getAttributes( comparatorDescription );
- ServerEntry entry = ServerEntryUtils.toServerEntry( attrs, dn, registries );
-
- proxy.add( new AddOperationContext( registries, dn, entry, true ), BYPASS );
- }
-
-
private Attributes getAttributes( ComparatorDescription comparatorDescription )
{
AttributesImpl attributes = new AttributesImpl( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC, true );
@@ -229,19 +265,6 @@
}
- public void add( Registries registries, NormalizerDescription normalizerDescription ) throws Exception
- {
- String schemaName = getSchema( normalizerDescription );
- PartitionNexusProxy proxy = InvocationStack.getInstance().peek().getProxy();
- LdapDN dn = new LdapDN( "m-oid=" + normalizerDescription.getNumericOid() + ",ou=normalizers,cn="
- + schemaName + ",ou=schema" );
- Attributes attrs = getAttributes( normalizerDescription );
- ServerEntry entry = ServerEntryUtils.toServerEntry( attrs, dn, registries );
-
- proxy.add( new AddOperationContext( registries, dn, entry, true ), BYPASS );
- }
-
-
private Attributes getAttributes( NormalizerDescription normalizerDescription )
{
AttributesImpl attributes = new AttributesImpl( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC, true );
@@ -265,18 +288,6 @@
}
- public void add( Registries registries, SyntaxCheckerDescription syntaxCheckerDescription ) throws Exception
- {
- String schemaName = getSchema( syntaxCheckerDescription );
- PartitionNexusProxy proxy = InvocationStack.getInstance().peek().getProxy();
- LdapDN dn = new LdapDN( "m-oid=" + syntaxCheckerDescription.getNumericOid() + ",ou=syntaxCheckers,cn="
- + schemaName + ",ou=schema" );
- Attributes attrs = getAttributes( syntaxCheckerDescription );
- ServerEntry entry = ServerEntryUtils.toServerEntry( attrs, dn, registries );
- proxy.add( new AddOperationContext( registries, dn, entry, true ), BYPASS );
- }
-
-
private String getSchema( AbstractSchemaDescription desc )
{
if ( desc.getExtensions().containsKey( MetaSchemaConstants.X_SCHEMA ) )
Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/security/CoreKeyStoreSpi.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/security/CoreKeyStoreSpi.java?rev=662440&r1=662439&r2=662440&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/security/CoreKeyStoreSpi.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/security/CoreKeyStoreSpi.java Mon Jun 2 07:00:23 2008
@@ -35,14 +35,12 @@
import java.util.Date;
import java.util.Enumeration;
-import javax.naming.directory.Attributes;
-
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.NotImplementedException;
+import org.apache.directory.server.core.CoreSession;
import org.apache.directory.server.core.DirectoryService;
import org.apache.directory.server.core.authn.LdapPrincipal;
import org.apache.directory.server.core.entry.ServerEntry;
-import org.apache.directory.server.core.entry.ServerEntryUtils;
import org.apache.directory.server.core.partition.PartitionNexus;
import org.apache.directory.shared.ldap.constants.AuthenticationLevel;
import org.apache.directory.shared.ldap.name.LdapDN;
@@ -82,8 +80,8 @@
{
LdapDN adminDn = PartitionNexus.getAdminName();
LdapPrincipal principal = new LdapPrincipal( adminDn, AuthenticationLevel.SIMPLE );
- Attributes attrs = directoryService.getJndiContext( principal ).getAttributes( adminDn );
- return ServerEntryUtils.toServerEntry( attrs, adminDn, directoryService.getRegistries() );
+ CoreSession session = directoryService.getSession( principal );
+ return session.lookup( adminDn );
}
Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/sp/StoredProcEngine.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/sp/StoredProcEngine.java?rev=662440&r1=662439&r2=662440&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/sp/StoredProcEngine.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/sp/StoredProcEngine.java Mon Jun 2 07:00:23 2008
@@ -17,13 +17,10 @@
* under the License.
*
*/
-
-
package org.apache.directory.server.core.sp;
-import javax.naming.NamingException;
-import javax.naming.ldap.LdapContext;
+import org.apache.directory.server.core.CoreSession;
import org.apache.directory.server.core.entry.ServerEntry;
@@ -55,12 +52,11 @@
/**
* Invokes the stored procedure handled by the engine.
*
- * @param rootDSE A handle on Root DSE to invoke the stored procedure over.
* @param fullSPName A fully qualified name of the stored procedure including its unit name.
* @param spArgs A list or arguments to be passed to the stored procedure. It should be an empty array if there aren't any parameters defined.
* @return The value obtained from invoked procedure. The client should know what will return exactly so that it can downcast to the appropriate type.
* @throws NamingException If an error occurs during invocation.
*/
- public Object invokeProcedure( LdapContext rootDSE, String fullSPName, Object[] spArgs ) throws NamingException;
+ public Object invokeProcedure( CoreSession session, String fullSPName, Object[] spArgs ) throws Exception;
}
Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/sp/StoredProcExecutionManager.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/sp/StoredProcExecutionManager.java?rev=662440&r1=662439&r2=662440&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/sp/StoredProcExecutionManager.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/sp/StoredProcExecutionManager.java Mon Jun 2 07:00:23 2008
@@ -17,23 +17,30 @@
* under the License.
*
*/
-
-
package org.apache.directory.server.core.sp;
+import org.apache.directory.server.core.CoreSession;
+import org.apache.directory.server.core.entry.ClonedServerEntry;
import org.apache.directory.server.core.entry.ServerEntry;
-import org.apache.directory.server.core.entry.ServerEntryUtils;
-import org.apache.directory.server.schema.registries.Registries;
+import org.apache.directory.server.core.entry.ServerStringValue;
+import org.apache.directory.server.core.filtering.EntryFilteringCursor;
import org.apache.directory.shared.ldap.constants.SchemaConstants;
+import org.apache.directory.shared.ldap.filter.EqualityNode;
+import org.apache.directory.shared.ldap.filter.ExprNode;
+import org.apache.directory.shared.ldap.filter.SearchScope;
+import org.apache.directory.shared.ldap.message.AliasDerefMode;
import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.shared.ldap.schema.AttributeType;
+import org.apache.directory.shared.ldap.schema.AttributeTypeOptions;
-import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
import javax.naming.directory.SearchControls;
-import javax.naming.directory.SearchResult;
-import javax.naming.ldap.LdapContext;
+
+import java.util.Collections;
import java.util.List;
+import java.util.Set;
+
/**
* A Factory type class which holds a registry of supported {@link StoredProcEngineConfig}s. A container reference
@@ -44,6 +51,7 @@
*/
public class StoredProcExecutionManager
{
+ private final static Set<AttributeTypeOptions> EMPTY_ATTRIBS = Collections.emptySet();
private final String storedProcContainer;
@@ -71,15 +79,27 @@
* @return The entry associated with the SP Unit.
* @throws NamingException If the unit cannot be located or any other error occurs.
*/
- public ServerEntry findStoredProcUnit( LdapContext rootDSE, String fullSPName, Registries registries ) throws NamingException
+ public ServerEntry findStoredProcUnit( CoreSession session, String fullSPName ) throws Exception
{
SearchControls controls = new SearchControls();
controls.setReturningAttributes( SchemaConstants.ALL_USER_ATTRIBUTES_ARRAY );
controls.setSearchScope( SearchControls.SUBTREE_SCOPE );
String spUnitName = StoredProcUtils.extractStoredProcUnitName( fullSPName );
- String filter = "(storedProcUnitName=" + spUnitName + ")";
- NamingEnumeration<SearchResult> results = rootDSE.search( storedProcContainer, filter, controls );
- return ServerEntryUtils.toServerEntry( results.nextElement().getAttributes(), LdapDN.EMPTY_LDAPDN, registries );
+
+ AttributeType at = session.getDirectoryService()
+ .getRegistries().getAttributeTypeRegistry().lookup( "storedProcUnitName" );
+ ExprNode filter = new EqualityNode<String>( "storedProcUnitName", new ServerStringValue( at, spUnitName ) );
+ LdapDN dn = new LdapDN( storedProcContainer );
+ EntryFilteringCursor results = session.search( dn, SearchScope.SUBTREE, filter,
+ AliasDerefMode.DEREF_ALWAYS, EMPTY_ATTRIBS );
+ if ( results.first() )
+ {
+ ClonedServerEntry entry = results.get();
+ results.close();
+ return entry;
+ }
+
+ return null;
}
Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/sp/java/JavaStoredProcEngine.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/sp/java/JavaStoredProcEngine.java?rev=662440&r1=662439&r2=662440&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/sp/java/JavaStoredProcEngine.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/sp/java/JavaStoredProcEngine.java Mon Jun 2 07:00:23 2008
@@ -28,9 +28,8 @@
import java.util.List;
import javax.naming.NamingException;
-import javax.naming.ldap.LdapContext;
-import org.apache.directory.server.core.entry.ServerAttribute;
+import org.apache.directory.server.core.CoreSession;
import org.apache.directory.server.core.entry.ServerEntry;
import org.apache.directory.server.core.sp.StoredProcEngine;
import org.apache.directory.server.core.sp.StoredProcUtils;
@@ -53,9 +52,9 @@
/* (non-Javadoc)
- * @see org.apache.directory.server.core.sp.StoredProcEngine#invokeProcedure(javax.naming.ldap.LdapContext, java.lang.String, java.lang.Object[])
+ * @see org.apache.directory.server.core.sp.StoredProcEngine#invokeProcedure(OperationContext, String, Object[])
*/
- public Object invokeProcedure( LdapContext rootCtx, String fullSPName, Object[] spArgs ) throws NamingException
+ public Object invokeProcedure( CoreSession session, String fullSPName, Object[] spArgs ) throws Exception
{
EntryAttribute javaByteCode = spUnit.get( "javaByteCode" );
String spName = StoredProcUtils.extractStoredProcName( fullSPName );
Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/subtree/SubentryInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/subtree/SubentryInterceptor.java?rev=662440&r1=662439&r2=662440&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/subtree/SubentryInterceptor.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/subtree/SubentryInterceptor.java Mon Jun 2 07:00:23 2008
@@ -23,7 +23,11 @@
import org.apache.directory.server.core.interceptor.BaseInterceptor;
import org.apache.directory.server.constants.ApacheSchemaConstants;
+import org.apache.directory.server.constants.ServerDNConstants;
+import org.apache.directory.server.core.CoreSession;
+import org.apache.directory.server.core.DefaultCoreSession;
import org.apache.directory.server.core.DirectoryService;
+import org.apache.directory.server.core.authn.LdapPrincipal;
import org.apache.directory.server.core.entry.ClonedServerEntry;
import org.apache.directory.server.core.entry.DefaultServerAttribute;
import org.apache.directory.server.core.entry.DefaultServerEntry;
@@ -40,15 +44,15 @@
import org.apache.directory.server.core.interceptor.context.ModifyOperationContext;
import org.apache.directory.server.core.interceptor.context.MoveAndRenameOperationContext;
import org.apache.directory.server.core.interceptor.context.MoveOperationContext;
+import org.apache.directory.server.core.interceptor.context.OperationContext;
import org.apache.directory.server.core.interceptor.context.RenameOperationContext;
import org.apache.directory.server.core.interceptor.context.SearchOperationContext;
import org.apache.directory.server.core.interceptor.context.SearchingOperationContext;
-import org.apache.directory.server.core.invocation.Invocation;
-import org.apache.directory.server.core.invocation.InvocationStack;
import org.apache.directory.server.core.partition.PartitionNexus;
import org.apache.directory.server.schema.registries.AttributeTypeRegistry;
import org.apache.directory.server.schema.registries.OidRegistry;
import org.apache.directory.server.schema.registries.Registries;
+import org.apache.directory.shared.ldap.constants.AuthenticationLevel;
import org.apache.directory.shared.ldap.constants.SchemaConstants;
import org.apache.directory.shared.ldap.entry.EntryAttribute;
import org.apache.directory.shared.ldap.entry.Modification;
@@ -76,8 +80,6 @@
import javax.naming.Name;
import javax.naming.directory.SearchControls;
-import javax.naming.ldap.Control;
-import javax.naming.ldap.LdapContext;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
@@ -170,7 +172,12 @@
//suffix = LdapDN.normalize( suffix, registry.getNormalizerMapping() );
suffix.normalize( atRegistry.getNormalizerMapping() );
- EntryFilteringCursor subentries = nexus.search( new SearchOperationContext( registries,
+ LdapDN adminDn = new LdapDN( ServerDNConstants.ADMIN_SYSTEM_DN_NORMALIZED );
+ adminDn.normalize( registries.getAttributeTypeRegistry().getNormalizerMapping() );
+ CoreSession adminSession = new DefaultCoreSession(
+ new LdapPrincipal( adminDn, AuthenticationLevel.STRONG ), directoryService );
+
+ EntryFilteringCursor subentries = nexus.search( new SearchOperationContext( adminSession,
suffix, AliasDerefMode.NEVER_DEREF_ALIASES, filter, controls ) );
while ( subentries.next() )
@@ -238,13 +245,13 @@
// Methods/Code dealing with Subentry Visibility
// -----------------------------------------------------------------------
+
public EntryFilteringCursor list( NextInterceptor nextInterceptor, ListOperationContext opContext )
throws Exception
{
EntryFilteringCursor cursor = nextInterceptor.list( opContext );
- Invocation invocation = InvocationStack.getInstance().peek();
- if ( !isSubentryVisible( invocation ) )
+ if ( !isSubentryVisible( opContext ) )
{
cursor.addEntryFilter( new HideSubentriesFilter() );
}
@@ -257,7 +264,6 @@
throws Exception
{
EntryFilteringCursor cursor = nextInterceptor.search( opContext );
- Invocation invocation = InvocationStack.getInstance().peek();
// object scope searches by default return subentries
if ( opContext.getScope() == SearchScope.OBJECT )
@@ -266,7 +272,7 @@
}
// for subtree and one level scope we filter
- if ( !isSubentryVisible( invocation ) )
+ if ( !isSubentryVisible( opContext ) )
{
cursor.addEntryFilter( new HideSubentriesFilter() );
}
@@ -287,24 +293,18 @@
* @return true if subentries should be visible, false otherwise
* @throws Exception if there are problems accessing request controls
*/
- private boolean isSubentryVisible( Invocation invocation ) throws Exception
+ private boolean isSubentryVisible( OperationContext opContext ) throws Exception
{
- Control[] reqControls = ( ( LdapContext ) invocation.getCaller() ).getRequestControls();
-
- if ( reqControls == null || reqControls.length <= 0 )
+ if ( opContext.hasRequestControls() )
{
return false;
}
- // check all request controls to see if subentry control is present
- for ( Control reqControl : reqControls )
+ // found the subentry request control so we return its value
+ if ( opContext.hasRequestControl( SUBENTRY_CONTROL ) )
{
- // found the subentry request control so we return its value
- if ( reqControl.getID().equals( SUBENTRY_CONTROL ) )
- {
- SubentriesControl subentriesControl = ( SubentriesControl ) reqControl;
- return subentriesControl.isVisible();
- }
+ SubentriesControl subentriesControl = ( SubentriesControl ) opContext.getRequestControl( SUBENTRY_CONTROL );
+ return subentriesControl.isVisible();
}
return false;
@@ -414,7 +414,7 @@
// get the name of the administrative point and its administrativeRole attributes
LdapDN apName = ( LdapDN ) name.clone();
apName.remove( name.size() - 1 );
- ServerEntry ap = nexus.lookup( new LookupOperationContext( registries, apName ) );
+ ServerEntry ap = nexus.lookup( new LookupOperationContext( addContext.getSession(), apName ) );
EntryAttribute administrativeRole = ap.get( "administrativeRole" );
// check that administrativeRole has something valid in it for us
@@ -480,7 +480,7 @@
controls.setReturningAttributes( new String[]
{ SchemaConstants.ALL_OPERATIONAL_ATTRIBUTES, SchemaConstants.ALL_USER_ATTRIBUTES } );
- EntryFilteringCursor subentries = nexus.search( new SearchOperationContext( registries,
+ EntryFilteringCursor subentries = nexus.search( new SearchOperationContext( addContext.getSession(),
baseDn, AliasDerefMode.NEVER_DEREF_ALIASES, filter, controls ) );
while ( subentries.next() )
@@ -491,8 +491,8 @@
if ( evaluator.evaluate( ss, apName, dn, candidate ) )
{
- nexus.modify( new ModifyOperationContext( registries, dn, getOperationalModsForAdd( candidate,
- operational ) ) );
+ nexus.modify( new ModifyOperationContext( addContext.getSession(), dn,
+ getOperationalModsForAdd( candidate, operational ) ) );
}
}
@@ -587,7 +587,7 @@
public void delete( NextInterceptor next, DeleteOperationContext opContext ) throws Exception
{
LdapDN name = opContext.getDn();
- ServerEntry entry = nexus.lookup( new LookupOperationContext( registries, name ) );
+ ServerEntry entry = nexus.lookup( new LookupOperationContext( opContext.getSession(), name ) );
EntryAttribute objectClasses = entry.get( objectClassType );
if ( objectClasses.contains( SchemaConstants.SUBENTRY_OC ) )
@@ -614,7 +614,7 @@
controls.setReturningAttributes( new String[]
{ SchemaConstants.ALL_OPERATIONAL_ATTRIBUTES, SchemaConstants.ALL_USER_ATTRIBUTES } );
- EntryFilteringCursor subentries = nexus.search( new SearchOperationContext( registries,
+ EntryFilteringCursor subentries = nexus.search( new SearchOperationContext( opContext.getSession(),
baseDn, AliasDerefMode.NEVER_DEREF_ALIASES, filter, controls ) );
while ( subentries.next() )
@@ -625,8 +625,8 @@
if ( evaluator.evaluate( ss, apName, dn, candidate ) )
{
- nexus.modify( new ModifyOperationContext( registries, dn, getOperationalModsForRemove( name,
- candidate ) ) );
+ nexus.modify( new ModifyOperationContext( opContext.getSession(), dn,
+ getOperationalModsForRemove( name, candidate ) ) );
}
}
}
@@ -650,12 +650,12 @@
* are, false otherwise
* @throws Exception if there are errors while searching the directory
*/
- private boolean hasAdministrativeDescendant( LdapDN name ) throws Exception
+ private boolean hasAdministrativeDescendant( OperationContext opContext, LdapDN name ) throws Exception
{
ExprNode filter = new PresenceNode( "administrativeRole" );
SearchControls controls = new SearchControls();
controls.setSearchScope( SearchControls.SUBTREE_SCOPE );
- EntryFilteringCursor aps = nexus.search( new SearchOperationContext( registries, name,
+ EntryFilteringCursor aps = nexus.search( new SearchOperationContext( opContext.getSession(), name,
AliasDerefMode.NEVER_DEREF_ALIASES, filter, controls ) );
if ( aps.next() )
@@ -746,7 +746,7 @@
{
LdapDN name = opContext.getDn();
- ServerEntry entry = nexus.lookup( new LookupOperationContext( registries, name ) );
+ ServerEntry entry = nexus.lookup( new LookupOperationContext( opContext.getSession(), name ) );
EntryAttribute objectClasses = entry.get( objectClassType );
@@ -773,7 +773,7 @@
controls.setSearchScope( SearchControls.SUBTREE_SCOPE );
controls.setReturningAttributes( new String[]
{ SchemaConstants.ALL_OPERATIONAL_ATTRIBUTES, SchemaConstants.ALL_USER_ATTRIBUTES } );
- EntryFilteringCursor subentries = nexus.search( new SearchOperationContext( registries,
+ EntryFilteringCursor subentries = nexus.search( new SearchOperationContext( opContext.getSession(),
baseDn, AliasDerefMode.NEVER_DEREF_ALIASES, filter, controls ) );
while ( subentries.next() )
@@ -785,14 +785,14 @@
if ( evaluator.evaluate( ss, apName, dn, candidate ) )
{
- nexus.modify( new ModifyOperationContext( registries, dn, getOperationalModsForReplace( name,
- newName, subentry, candidate ) ) );
+ nexus.modify( new ModifyOperationContext( opContext.getSession(), dn,
+ getOperationalModsForReplace( name, newName, subentry, candidate ) ) );
}
}
}
else
{
- if ( hasAdministrativeDescendant( name ) )
+ if ( hasAdministrativeDescendant( opContext, name ) )
{
String msg = "Will not allow rename operation on entries with administrative descendants.";
LOG.warn( msg );
@@ -811,7 +811,7 @@
if ( mods.size() > 0 )
{
- nexus.modify( new ModifyOperationContext( registries, newName, mods ) );
+ nexus.modify( new ModifyOperationContext( opContext.getSession(), newName, mods ) );
}
}
}
@@ -822,7 +822,7 @@
LdapDN oriChildName = opContext.getDn();
LdapDN parent = opContext.getParent();
- ServerEntry entry = nexus.lookup( new LookupOperationContext( registries, oriChildName ) );
+ ServerEntry entry = nexus.lookup( new LookupOperationContext( opContext.getSession(), oriChildName ) );
EntryAttribute objectClasses = entry.get( objectClassType );
@@ -850,7 +850,7 @@
controls.setSearchScope( SearchControls.SUBTREE_SCOPE );
controls.setReturningAttributes( new String[]
{ SchemaConstants.ALL_OPERATIONAL_ATTRIBUTES, SchemaConstants.ALL_USER_ATTRIBUTES } );
- EntryFilteringCursor subentries = nexus.search( new SearchOperationContext( registries,
+ EntryFilteringCursor subentries = nexus.search( new SearchOperationContext( opContext.getSession(),
baseDn, AliasDerefMode.NEVER_DEREF_ALIASES, filter, controls ) );
while ( subentries.next() )
@@ -861,14 +861,14 @@
if ( evaluator.evaluate( ss, apName, dn, candidate ) )
{
- nexus.modify( new ModifyOperationContext( registries, dn, getOperationalModsForReplace(
- oriChildName, newName, subentry, candidate ) ) );
+ nexus.modify( new ModifyOperationContext( opContext.getSession(), dn,
+ getOperationalModsForReplace( oriChildName, newName, subentry, candidate ) ) );
}
}
}
else
{
- if ( hasAdministrativeDescendant( oriChildName ) )
+ if ( hasAdministrativeDescendant( opContext, oriChildName ) )
{
String msg = "Will not allow rename operation on entries with administrative descendants.";
LOG.warn( msg );
@@ -886,7 +886,7 @@
if ( mods.size() > 0 )
{
- nexus.modify( new ModifyOperationContext( registries, newName, mods ) );
+ nexus.modify( new ModifyOperationContext( opContext.getSession(), newName, mods ) );
}
}
}
@@ -897,7 +897,7 @@
LdapDN oriChildName = opContext.getDn();
LdapDN newParentName = opContext.getParent();
- ServerEntry entry = nexus.lookup( new LookupOperationContext( registries, oriChildName ) );
+ ServerEntry entry = nexus.lookup( new LookupOperationContext( opContext.getSession(), oriChildName ) );
EntryAttribute objectClasses = entry.get( SchemaConstants.OBJECT_CLASS_AT );
@@ -924,7 +924,7 @@
controls.setSearchScope( SearchControls.SUBTREE_SCOPE );
controls.setReturningAttributes( new String[]
{ SchemaConstants.ALL_OPERATIONAL_ATTRIBUTES, SchemaConstants.ALL_USER_ATTRIBUTES } );
- EntryFilteringCursor subentries = nexus.search( new SearchOperationContext( registries,
+ EntryFilteringCursor subentries = nexus.search( new SearchOperationContext( opContext.getSession(),
baseDn, AliasDerefMode.NEVER_DEREF_ALIASES, filter, controls ) );
while ( subentries.next() )
@@ -935,14 +935,14 @@
if ( evaluator.evaluate( ss, apName, dn, candidate ) )
{
- nexus.modify( new ModifyOperationContext( registries, dn, getOperationalModsForReplace(
- oriChildName, newName, subentry, candidate ) ) );
+ nexus.modify( new ModifyOperationContext( opContext.getSession(), dn,
+ getOperationalModsForReplace( oriChildName, newName, subentry, candidate ) ) );
}
}
}
else
{
- if ( hasAdministrativeDescendant( oriChildName ) )
+ if ( hasAdministrativeDescendant( opContext, oriChildName ) )
{
String msg = "Will not allow rename operation on entries with administrative descendants.";
LOG.warn( msg );
@@ -959,7 +959,7 @@
if ( mods.size() > 0 )
{
- nexus.modify( new ModifyOperationContext( registries, newName, mods ) );
+ nexus.modify( new ModifyOperationContext( opContext.getSession(), newName, mods ) );
}
}
}
@@ -1013,7 +1013,7 @@
LdapDN name = opContext.getDn();
List<Modification> mods = opContext.getModItems();
- ServerEntry entry = nexus.lookup( new LookupOperationContext( registries, name ) );
+ ServerEntry entry = nexus.lookup( new LookupOperationContext( opContext.getSession(), name ) );
ServerEntry oldEntry = ( ServerEntry ) entry.clone();
EntryAttribute objectClasses = entry.get( objectClassType );
@@ -1058,7 +1058,7 @@
controls.setSearchScope( SearchControls.SUBTREE_SCOPE );
controls.setReturningAttributes( new String[]
{ SchemaConstants.ALL_OPERATIONAL_ATTRIBUTES, SchemaConstants.ALL_USER_ATTRIBUTES } );
- EntryFilteringCursor subentries = nexus.search( new SearchOperationContext( registries,
+ EntryFilteringCursor subentries = nexus.search( new SearchOperationContext( opContext.getSession(),
oldBaseDn, AliasDerefMode.NEVER_DEREF_ALIASES, filter, controls ) );
while ( subentries.next() )
@@ -1069,8 +1069,8 @@
if ( evaluator.evaluate( ssOld, apName, dn, candidate ) )
{
- nexus.modify( new ModifyOperationContext( registries, dn, getOperationalModsForRemove( name,
- candidate ) ) );
+ nexus.modify( new ModifyOperationContext( opContext.getSession(), dn,
+ getOperationalModsForRemove( name, candidate ) ) );
}
}
@@ -1079,7 +1079,7 @@
ServerEntry operational = getSubentryOperatationalAttributes( name, subentry );
LdapDN newBaseDn = ( LdapDN ) apName.clone();
newBaseDn.addAll( ssNew.getBase() );
- subentries = nexus.search( new SearchOperationContext( registries, newBaseDn,
+ subentries = nexus.search( new SearchOperationContext( opContext.getSession(), newBaseDn,
AliasDerefMode.NEVER_DEREF_ALIASES, filter, controls ) );
while ( subentries.next() )
@@ -1090,8 +1090,8 @@
if ( evaluator.evaluate( ssNew, apName, dn, candidate ) )
{
- nexus.modify( new ModifyOperationContext( registries, dn, getOperationalModsForAdd( candidate,
- operational ) ) );
+ nexus.modify( new ModifyOperationContext( opContext.getSession(), dn,
+ getOperationalModsForAdd( candidate, operational ) ) );
}
}
}
@@ -1101,13 +1101,13 @@
if ( !objectClasses.contains( SchemaConstants.SUBENTRY_OC ) )
{
- ServerEntry newEntry = nexus.lookup( new LookupOperationContext( registries, name ) );
+ ServerEntry newEntry = nexus.lookup( new LookupOperationContext( opContext.getSession(), name ) );
List<Modification> subentriesOpAttrMods = getModsOnEntryModification( name, oldEntry, newEntry );
if ( subentriesOpAttrMods.size() > 0 )
{
- nexus.modify( new ModifyOperationContext( registries, name, subentriesOpAttrMods ) );
+ nexus.modify( new ModifyOperationContext( opContext.getSession(), name, subentriesOpAttrMods ) );
}
}
}
Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/trigger/AbstractStoredProcedureParameterInjector.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/trigger/AbstractStoredProcedureParameterInjector.java?rev=662440&r1=662439&r2=662440&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/trigger/AbstractStoredProcedureParameterInjector.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/trigger/AbstractStoredProcedureParameterInjector.java Mon Jun 2 07:00:23 2008
@@ -17,9 +17,9 @@
* under the License.
*
*/
-
package org.apache.directory.server.core.trigger;
+
import java.security.Principal;
import java.util.ArrayList;
import java.util.HashMap;
@@ -30,50 +30,56 @@
import javax.naming.Name;
import javax.naming.NamingException;
-import org.apache.directory.server.core.invocation.Invocation;
-import org.apache.directory.server.core.jndi.ServerContext;
-import org.apache.directory.server.core.jndi.ServerLdapContext;
-import org.apache.directory.server.schema.registries.Registries;
+import org.apache.directory.server.core.interceptor.context.LookupOperationContext;
+import org.apache.directory.server.core.interceptor.context.OperationContext;
import org.apache.directory.shared.ldap.name.LdapDN;
import org.apache.directory.shared.ldap.trigger.StoredProcedureParameter;
import org.apache.directory.shared.ldap.trigger.StoredProcedureParameter.Generic_LDAP_CONTEXT;
+
public abstract class AbstractStoredProcedureParameterInjector implements StoredProcedureParameterInjector
{
- private Invocation invocation;
+ private OperationContext opContext;
private Map<Class<?>, MicroInjector> injectors;
- public AbstractStoredProcedureParameterInjector( Invocation invocation )
+
+ public AbstractStoredProcedureParameterInjector( OperationContext opContext )
{
- this.invocation = invocation;
+ this.opContext = opContext;
injectors = new HashMap<Class<?>, MicroInjector>();
injectors.put( StoredProcedureParameter.Generic_OPERATION_PRINCIPAL.class, $operationPrincipalInjector );
injectors.put( StoredProcedureParameter.Generic_LDAP_CONTEXT.class, $ldapContextInjector );
}
+
protected Name getOperationPrincipal() throws NamingException
{
- Principal principal = ( ( ServerContext ) invocation.getCaller() ).getPrincipal();
+ Principal principal = opContext.getSession().getEffectivePrincipal();
Name userName = new LdapDN( principal.getName() );
return userName;
}
+
protected Map<Class<?>, MicroInjector> getInjectors()
{
return injectors;
}
- public Invocation getInvocation()
+
+ public OperationContext getOperationContext()
{
- return invocation;
+ return opContext;
}
- public void setInvocation( Invocation invocation )
+
+ public void setOperationContext( OperationContext invocation )
{
- this.invocation = invocation;
+ this.opContext = invocation;
}
- public final List<Object> getArgumentsToInject( Registries registries, List<StoredProcedureParameter> parameterList ) throws Exception
+
+ public final List<Object> getArgumentsToInject( OperationContext opContext,
+ List<StoredProcedureParameter> parameterList ) throws Exception
{
List<Object> arguments = new ArrayList<Object>();
@@ -83,28 +89,30 @@
{
StoredProcedureParameter spParameter = it.next();
MicroInjector injector = injectors.get( spParameter.getClass() );
- arguments.add( injector.inject( registries, spParameter ) );
+ arguments.add( injector.inject( opContext, spParameter ) );
}
return arguments;
}
+
MicroInjector $operationPrincipalInjector = new MicroInjector()
{
- public Object inject( Registries registries, StoredProcedureParameter param ) throws NamingException
+ public Object inject( OperationContext opContext, StoredProcedureParameter param ) throws Exception
{
return getOperationPrincipal();
}
};
+
MicroInjector $ldapContextInjector = new MicroInjector()
{
- public Object inject( Registries registries, StoredProcedureParameter param ) throws NamingException
+ public Object inject( OperationContext opContext, StoredProcedureParameter param ) throws Exception
{
Generic_LDAP_CONTEXT ldapCtxParam = ( Generic_LDAP_CONTEXT ) param;
LdapDN ldapCtxName = ldapCtxParam.getCtxName();
- return ( ( ServerLdapContext ) ( ( ServerLdapContext ) invocation.getCaller() ).getRootContext()).lookup( ldapCtxName );
+ LookupOperationContext lookupContext = new LookupOperationContext( opContext.getSession(), ldapCtxName );
+ return opContext.getSession().getDirectoryService().getOperationManager().lookup( lookupContext );
}
};
-
}