Author: elecharny
Date: Tue Apr 10 06:01:46 2007
New Revision: 527121
URL: http://svn.apache.org/viewvc?view=rev&rev=527121
Log:
The add, modify, delete and compare operations now use a ServiceContext parameter
Modified:
directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/AbstractPartition.java
directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/DefaultPartitionNexus.java
directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/Partition.java
directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/PartitionNexus.java
directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/PartitionNexusProxy.java
directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreePartition.java
Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/AbstractPartition.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/AbstractPartition.java?view=diff&rev=527121&r1=527120&r2=527121
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/AbstractPartition.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/AbstractPartition.java
Tue Apr 10 06:01:46 2007
@@ -32,8 +32,8 @@
import org.apache.directory.server.core.DirectoryServiceConfiguration;
import org.apache.directory.server.core.configuration.PartitionConfiguration;
-import org.apache.directory.server.core.interceptor.context.EntryServiceContext;
import org.apache.directory.server.core.interceptor.context.LookupServiceContext;
+import org.apache.directory.server.core.interceptor.context.ModifyServiceContext;
import org.apache.directory.server.core.interceptor.context.ServiceContext;
import org.apache.directory.shared.ldap.message.ModificationItemImpl;
import org.apache.directory.shared.ldap.name.LdapDN;
@@ -224,10 +224,15 @@
* Please override this method if there is more effactive way for your
* implementation.
*/
- public void modify( LdapDN name, int modOp, Attributes mods ) throws NamingException
+ public void modify( ServiceContext modifyContext ) throws NamingException
{
+ ModifyServiceContext ctx = (ModifyServiceContext)modifyContext;
+ int modOp = ctx.getModOp();
+ Attributes mods = ctx.getMods();
+
List<ModificationItemImpl> items = new ArrayList<ModificationItemImpl>(
mods.size() );
NamingEnumeration e = mods.getAll();
+
while ( e.hasMore() )
{
items.add( new ModificationItemImpl( modOp, ( Attribute ) e.next() ) );
@@ -235,7 +240,7 @@
ModificationItemImpl[] itemsArray = new ModificationItemImpl[items.size()];
itemsArray = items.toArray( itemsArray );
- modify( name, itemsArray );
+ modify( ctx.getDn(), itemsArray );
}
Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/DefaultPartitionNexus.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/DefaultPartitionNexus.java?view=diff&rev=527121&r1=527120&r2=527121
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/DefaultPartitionNexus.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/DefaultPartitionNexus.java
Tue Apr 10 06:01:46 2007
@@ -44,11 +44,10 @@
import org.apache.directory.server.core.DirectoryServiceConfiguration;
import org.apache.directory.server.core.configuration.PartitionConfiguration;
-import org.apache.directory.server.core.interceptor.context.BindServiceContext;
+import org.apache.directory.server.core.interceptor.context.CompareServiceContext;
import org.apache.directory.server.core.interceptor.context.EntryServiceContext;
import org.apache.directory.server.core.interceptor.context.LookupServiceContext;
import org.apache.directory.server.core.interceptor.context.ServiceContext;
-import org.apache.directory.server.core.interceptor.context.UnbindServiceContext;
import org.apache.directory.server.core.partition.impl.btree.MutableBTreePartitionConfiguration;
import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmPartition;
import org.apache.directory.server.schema.registries.AttributeTypeRegistry;
@@ -464,20 +463,22 @@
// ContextPartitionNexus Method Implementations
// ------------------------------------------------------------------------
- public boolean compare( LdapDN name, String oid, Object value ) throws NamingException
+ public boolean compare( ServiceContext compareContext ) throws NamingException
{
- Partition partition = getBackend( name );
+ Partition partition = getBackend( compareContext.getDn() );
AttributeTypeRegistry registry = factoryCfg.getRegistries().getAttributeTypeRegistry();
+
+ CompareServiceContext ctx = (CompareServiceContext)compareContext;
// complain if we do not recognize the attribute being compared
- if ( !registry.hasAttributeType( oid ) )
+ if ( !registry.hasAttributeType( ctx.getOid() ) )
{
- throw new LdapInvalidAttributeIdentifierException( oid + " not found within the
attributeType registry" );
+ throw new LdapInvalidAttributeIdentifierException( ctx.getOid() + " not found
within the attributeType registry" );
}
- AttributeType attrType = registry.lookup( oid );
+ AttributeType attrType = registry.lookup( ctx.getOid() );
- Attribute attr = partition.lookup( new LookupServiceContext( name ) ).get( attrType.getName()
);
+ Attribute attr = partition.lookup( new LookupServiceContext( ctx.getDn() ) ).get(
attrType.getName() );
// complain if the attribute being compared does not exist in the entry
if ( attr == null )
@@ -486,7 +487,7 @@
}
// see first if simple match without normalization succeeds
- if ( attr.contains( value ) )
+ if ( attr.contains( ctx.getValue() ) )
{
return true;
}
@@ -499,11 +500,12 @@
* through all values looking for a match.
*/
Normalizer normalizer = attrType.getEquality().getNormalizer();
- Object reqVal = normalizer.normalize( value );
+ Object reqVal = normalizer.normalize( ctx.getValue() );
for ( int ii = 0; ii < attr.size(); ii++ )
{
Object attrValObj = normalizer.normalize( attr.get( ii ) );
+
if ( attrValObj instanceof String )
{
String attrVal = ( String ) attrValObj;
@@ -681,10 +683,10 @@
/**
* @see Partition#delete(org.apache.directory.shared.ldap.name.LdapDN)
*/
- public void delete( LdapDN dn ) throws NamingException
+ public void delete( ServiceContext deleteContext ) throws NamingException
{
- Partition backend = getBackend( dn );
- backend.delete( dn );
+ Partition backend = getBackend( deleteContext.getDn() );
+ backend.delete( deleteContext );
}
@@ -695,22 +697,22 @@
* here so backend implementors do not have to worry about performing these
* kinds of checks.
*
- * @see Partition#add(org.apache.directory.shared.ldap.name.LdapDN,javax.naming.directory.Attributes)
+ * @see Partition#add( ServiceContext )
*/
- public void add( LdapDN dn, Attributes entry ) throws NamingException
+ public void add( ServiceContext addContext ) throws NamingException
{
- Partition backend = getBackend( dn );
- backend.add( dn, entry );
+ Partition backend = getBackend( addContext.getDn() );
+ backend.add( addContext );
}
/**
* @see Partition#modify(org.apache.directory.shared.ldap.name.LdapDN,int,javax.naming.directory.Attributes)
*/
- public void modify( LdapDN dn, int modOp, Attributes mods ) throws NamingException
+ public void modify( ServiceContext modifyContext ) throws NamingException
{
- Partition backend = getBackend( dn );
- backend.modify( dn, modOp, mods );
+ Partition backend = getBackend( modifyContext.getDn() );
+ backend.modify( modifyContext );
}
Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/Partition.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/Partition.java?view=diff&rev=527121&r1=527120&r2=527121
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/Partition.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/Partition.java
Tue Apr 10 06:01:46 2007
@@ -106,40 +106,37 @@
* Deletes a leaf entry from this ContextPartition: non-leaf entries cannot be
* deleted until this operation has been applied to their children.
*
- * @param name the normalized distinguished/absolute name of the entry to
+ * @param deleteContext the context of the entry to
* delete from this ContextPartition.
* @throws NamingException if there are any problems
*/
- void delete( LdapDN name ) throws NamingException;
+ void delete( ServiceContext deleteContext ) throws NamingException;
/**
* Adds an entry to this ContextPartition.
*
- * @param name
- * @param entry the entry to add to this ContextPartition
+ * @param addContext the context used to add and entry to this ContextPartition
* @throws NamingException if there are any problems
*/
- void add( LdapDN name, Attributes entry ) throws NamingException;
+ void add( ServiceContext addContext ) throws NamingException;
/**
* Modifies an entry by adding, removing or replacing a set of attributes.
*
- * @param name the normalized distinguished/absolute name of the entry to
- * modify
- * @param modOp the modification operation to perform on the entry which
- * is one of constants specified by the DirContext interface:
+ * @param modifyContext The contetx containin the modification operation
+ * to perform on the entry which is one of constants specified by the
+ * DirContext interface:
* <code>ADD_ATTRIBUTE, REMOVE_ATTRIBUTE, REPLACE_ATTRIBUTE</code>.
- * @param attributes the attributes and their values used to affect the
- * modification with.
+ *
* @throws NamingException if there are any problems
* @see javax.naming.directory.DirContext
* @see javax.naming.directory.DirContext#ADD_ATTRIBUTE
* @see javax.naming.directory.DirContext#REMOVE_ATTRIBUTE
* @see javax.naming.directory.DirContext#REPLACE_ATTRIBUTE
*/
- void modify( LdapDN name, int modOp, Attributes attributes ) throws NamingException;
+ void modify( ServiceContext modifyContext ) throws NamingException;
/**
Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/PartitionNexus.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/PartitionNexus.java?view=diff&rev=527121&r1=527120&r2=527121
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/PartitionNexus.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/PartitionNexus.java
Tue Apr 10 06:01:46 2007
@@ -31,6 +31,7 @@
import javax.naming.ldap.LdapContext;
import org.apache.directory.server.core.configuration.PartitionConfiguration;
+import org.apache.directory.server.core.interceptor.context.ServiceContext;
import org.apache.directory.shared.ldap.constants.SchemaConstants;
import org.apache.directory.shared.ldap.name.LdapDN;
import org.apache.directory.shared.ldap.schema.NoOpNormalizer;
@@ -188,13 +189,11 @@
* Performs a comparison check to see if an attribute of an entry has
* a specified value.
*
- * @param name the normalized name of the entry
- * @param oid the attribute being compared
- * @param value the value the attribute is compared to
+ * @param compareContext the context used to compare
* @return true if the entry contains an attribute with the value, false otherwise
* @throws NamingException if there is a problem accessing the entry and its values
*/
- public abstract boolean compare( LdapDN name, String oid, Object value ) throws NamingException;
+ public abstract boolean compare( ServiceContext compareContext ) throws NamingException;
public abstract void addContextPartition( PartitionConfiguration config ) throws NamingException;
Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/PartitionNexusProxy.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/PartitionNexusProxy.java?view=diff&rev=527121&r1=527120&r2=527121
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/PartitionNexusProxy.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/PartitionNexusProxy.java
Tue Apr 10 06:01:46 2007
@@ -47,6 +47,7 @@
import org.apache.directory.server.core.enumeration.SearchResultFilteringEnumeration;
import org.apache.directory.server.core.event.EventService;
import org.apache.directory.server.core.interceptor.InterceptorChain;
+import org.apache.directory.server.core.interceptor.context.ModifyServiceContext;
import org.apache.directory.server.core.interceptor.context.ServiceContext;
import org.apache.directory.server.core.invocation.Invocation;
import org.apache.directory.server.core.invocation.InvocationStack;
@@ -276,21 +277,21 @@
}
- public boolean compare( LdapDN name, String oid, Object value ) throws NamingException
+ public boolean compare( ServiceContext compareContext ) throws NamingException
{
- return compare( name, oid, value, null );
+ return compare( compareContext, null );
}
- public boolean compare( LdapDN name, String oid, Object value, Collection bypass ) throws
NamingException
+ public boolean compare( ServiceContext compareContext, Collection bypass ) throws NamingException
{
ensureStarted();
InvocationStack stack = InvocationStack.getInstance();
stack.push( new Invocation( this, caller, "compare", new Object[]
- { name, oid, value }, bypass ) );
+ { compareContext }, bypass ) );
try
{
- return this.configuration.getInterceptorChain().compare( name, oid, value );
+ return this.configuration.getInterceptorChain().compare( compareContext );
}
finally
{
@@ -299,21 +300,21 @@
}
- public void delete( LdapDN name ) throws NamingException
+ public void delete( ServiceContext deleteContext ) throws NamingException
{
- delete( name, null );
+ delete( deleteContext, null );
}
- public void delete( LdapDN name, Collection bypass ) throws NamingException
+ public void delete( ServiceContext deleteContext, Collection bypass ) throws NamingException
{
ensureStarted();
InvocationStack stack = InvocationStack.getInstance();
stack.push( new Invocation( this, caller, "delete", new Object[]
- { name }, bypass ) );
+ { deleteContext }, bypass ) );
try
{
- this.configuration.getInterceptorChain().delete( name );
+ this.configuration.getInterceptorChain().delete( deleteContext );
}
finally
{
@@ -322,21 +323,21 @@
}
- public void add( LdapDN normName, Attributes entry ) throws NamingException
+ public void add( ServiceContext addContext ) throws NamingException
{
- add( normName, entry, null );
+ add( addContext, null );
}
- public void add( LdapDN normName, Attributes entry, Collection bypass ) throws NamingException
+ public void add( ServiceContext addContext, Collection bypass ) throws NamingException
{
ensureStarted();
InvocationStack stack = InvocationStack.getInstance();
stack.push( new Invocation( this, caller, "add", new Object[]
- { normName, entry }, bypass ) );
+ { addContext }, bypass ) );
try
{
- this.configuration.getInterceptorChain().add( normName, entry );
+ this.configuration.getInterceptorChain().add( addContext );
}
finally
{
@@ -345,38 +346,43 @@
}
- public void modify( LdapDN name, int modOp, Attributes mods ) throws NamingException
+ public void modify( ServiceContext modifyContext ) throws NamingException
{
- modify( name, modOp, mods, null );
+ modify( modifyContext, null );
}
- public void modify( LdapDN name, int modOp, Attributes mods, Collection bypass ) throws
NamingException
+ public void modify( ServiceContext modifyContext, Collection bypass ) throws NamingException
{
ensureStarted();
InvocationStack stack = InvocationStack.getInstance();
Integer modOpObj;
+
+ int modOp = ((ModifyServiceContext)modifyContext).getModOp();
switch ( modOp )
{
case ( DirContext.ADD_ATTRIBUTE ):
modOpObj = ADD_MODOP;
break;
+
case ( DirContext.REMOVE_ATTRIBUTE ):
modOpObj = REMOVE_MODOP;
break;
+
case ( DirContext.REPLACE_ATTRIBUTE ):
modOpObj = REPLACE_MODOP;
break;
+
default:
throw new IllegalArgumentException( "bad modification operation value: "
+ modOp );
}
stack.push( new Invocation( this, caller, "modify", new Object[]
- { name, modOpObj, mods }, bypass ) );
+ { modifyContext }, bypass ) );
try
{
- this.configuration.getInterceptorChain().modify( name, modOp, mods );
+ this.configuration.getInterceptorChain().modify( modifyContext );
}
finally
{
Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreePartition.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreePartition.java?view=diff&rev=527121&r1=527120&r2=527121
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreePartition.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreePartition.java
Tue Apr 10 06:01:46 2007
@@ -34,7 +34,7 @@
import org.apache.directory.server.core.DirectoryServiceConfiguration;
import org.apache.directory.server.core.configuration.PartitionConfiguration;
import org.apache.directory.server.core.enumeration.SearchResultEnumeration;
-import org.apache.directory.server.core.interceptor.context.EntryServiceContext;
+import org.apache.directory.server.core.interceptor.context.AddServiceContext;
import org.apache.directory.server.core.interceptor.context.LookupServiceContext;
import org.apache.directory.server.core.interceptor.context.ServiceContext;
import org.apache.directory.server.core.partition.Partition;
@@ -330,7 +330,7 @@
{
LdapDN dn = new LdapDN( suffix );
LdapDN normalizedSuffix = LdapDN.normalize( dn, attributeTypeRegistry.getNormalizerMapping()
);
- add( normalizedSuffix, entry );
+ add( new AddServiceContext( normalizedSuffix, entry ) );
}
}
@@ -382,8 +382,10 @@
// ContextPartition Interface Method Implementations
// ------------------------------------------------------------------------
- public void delete( LdapDN dn ) throws NamingException
+ public void delete( ServiceContext deleteContext ) throws NamingException
{
+ LdapDN dn = deleteContext.getDn();
+
Long id = getEntryId( dn.toString() );
// don't continue if id is null
@@ -404,10 +406,10 @@
}
- public abstract void add(LdapDN dn, Attributes entry) throws NamingException;
+ public abstract void add( ServiceContext addContext ) throws NamingException;
- public abstract void modify( LdapDN dn, int modOp, Attributes mods ) throws NamingException;
+ public abstract void modify( ServiceContext modifyContext ) throws NamingException;
public abstract void modify( LdapDN dn, ModificationItemImpl[] mods ) throws NamingException;
|