You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2008/05/01 02:06:46 UTC
svn commit: r652410 [8/14] - in /directory: apacheds/branches/bigbang/
apacheds/branches/bigbang/apacheds-jdbm/
apacheds/branches/bigbang/apacheds-jdbm/src/
apacheds/branches/bigbang/apacheds-jdbm/src/etc/
apacheds/branches/bigbang/apacheds-jdbm/src/ex...
Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java?rev=652410&r1=652409&r2=652410&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java Wed Apr 30 17:06:41 2008
@@ -67,7 +67,6 @@
import javax.naming.NamingException;
import javax.naming.Reference;
import javax.naming.Referenceable;
-import javax.naming.directory.Attributes;
import javax.naming.directory.DirContext;
import javax.naming.directory.SearchControls;
import javax.naming.event.EventContext;
@@ -116,17 +115,17 @@
/** The Principal associated with this context */
private LdapPrincipal principal;
-
+
/** The request controls to set on operations before performing them */
protected Control[] requestControls = EMPTY_CONTROLS;
-
+
/** The response controls to set after performing operations */
protected Control[] responseControls = EMPTY_CONTROLS;
-
+
/** Connection level controls associated with the session */
protected Control[] connectControls = EMPTY_CONTROLS;
-
+
// ------------------------------------------------------------------------
// Constructors
// ------------------------------------------------------------------------
@@ -145,7 +144,8 @@
* @throws NamingException if the environment parameters are not set
* correctly.
*/
- @SuppressWarnings(value={"unchecked"})
+ @SuppressWarnings(value =
+ { "unchecked" })
protected ServerContext( DirectoryService service, Hashtable<String, Object> env ) throws NamingException
{
this.service = service;
@@ -156,20 +156,20 @@
this.env = env;
LdapJndiProperties props = LdapJndiProperties.getLdapJndiProperties( this.env );
dn = props.getProviderDn();
-
+
// need to issue a bind operation here
- doBindOperation( props.getBindDn(), props.getCredentials(), props.getAuthenticationMechanisms(),
- props.getSaslAuthId() );
-
+ doBindOperation( props.getBindDn(), props.getCredentials(), props.getAuthenticationMechanisms(), props
+ .getSaslAuthId() );
+
registries = service.getRegistries();
- if ( ! nexusProxy.hasEntry( new EntryOperationContext( registries, dn ) ) )
+ if ( !nexusProxy.hasEntry( new EntryOperationContext( registries, dn ) ) )
{
throw new NameNotFoundException( dn + " does not exist" );
}
}
-
-
+
+
/**
* Must be called by all subclasses to initialize the nexus proxy and the
* environment settings to be used by this Context implementation. This
@@ -192,8 +192,8 @@
this.principal = principal;
registries = service.getRegistries();
}
-
-
+
+
// ------------------------------------------------------------------------
// Protected Methods for Control [De]Marshalling
// ------------------------------------------------------------------------
@@ -204,7 +204,6 @@
// context not thread safe.
// ------------------------------------------------------------------------
-
/**
* Used to encapsulate [de]marshalling of controls before and after add operations.
* @param entry
@@ -213,13 +212,10 @@
protected void doAddOperation( LdapDN target, ServerEntry entry ) throws NamingException
{
// setup the op context and populate with request controls
- AddOperationContext opCtx = new AddOperationContext(
- service.getRegistries(),
- target,
- entry );
-
+ AddOperationContext opCtx = new AddOperationContext( service.getRegistries(), entry );
+
opCtx.addRequestControls( requestControls );
-
+
// execute add operation
nexusProxy.add( opCtx );
@@ -227,8 +223,8 @@
requestControls = EMPTY_CONTROLS;
responseControls = opCtx.getResponseControls();
}
-
-
+
+
/**
* Used to encapsulate [de]marshalling of controls before and after delete operations.
* @param target
@@ -238,7 +234,7 @@
// setup the op context and populate with request controls
DeleteOperationContext opCtx = new DeleteOperationContext( registries, target );
opCtx.addRequestControls( requestControls );
-
+
// execute delete operation
nexusProxy.delete( opCtx );
@@ -246,8 +242,8 @@
requestControls = EMPTY_CONTROLS;
responseControls = opCtx.getResponseControls();
}
-
-
+
+
/**
* Used to encapsulate [de]marshalling of controls before and after list operations.
* @param dn
@@ -257,24 +253,24 @@
* @return NamingEnumeration
*/
protected NamingEnumeration<ServerSearchResult> doSearchOperation( LdapDN dn, AliasDerefMode aliasDerefMode,
- ExprNode filter, SearchControls searchControls )
- throws NamingException
+ ExprNode filter, SearchControls searchControls ) throws NamingException
{
// setup the op context and populate with request controls
- SearchOperationContext opCtx = new SearchOperationContext( registries, dn, aliasDerefMode, filter, searchControls );
+ SearchOperationContext opCtx = new SearchOperationContext( registries, dn, aliasDerefMode, filter,
+ searchControls );
opCtx.addRequestControls( requestControls );
-
+
// execute search operation
NamingEnumeration<ServerSearchResult> results = nexusProxy.search( opCtx );
// clear the request controls and set the response controls
requestControls = EMPTY_CONTROLS;
responseControls = opCtx.getResponseControls();
-
+
return results;
}
-
-
+
+
/**
* Used to encapsulate [de]marshalling of controls before and after list operations.
*/
@@ -283,29 +279,29 @@
// setup the op context and populate with request controls
ListOperationContext opCtx = new ListOperationContext( registries, target );
opCtx.addRequestControls( requestControls );
-
+
// execute list operation
NamingEnumeration<ServerSearchResult> results = nexusProxy.list( opCtx );
// clear the request controls and set the response controls
requestControls = EMPTY_CONTROLS;
responseControls = opCtx.getResponseControls();
-
+
return results;
}
-
-
+
+
protected ServerEntry doGetRootDSEOperation( LdapDN target ) throws NamingException
{
GetRootDSEOperationContext opCtx = new GetRootDSEOperationContext( registries, target );
opCtx.addRequestControls( requestControls );
-
+
// do not reset request controls since this is not an external
// operation and not do bother setting the response controls either
return nexusProxy.getRootDSE( opCtx );
}
-
-
+
+
/**
* Used to encapsulate [de]marshalling of controls before and after lookup operations.
*/
@@ -313,7 +309,7 @@
{
// setup the op context and populate with request controls
LookupOperationContext opCtx;
-
+
// execute lookup/getRootDSE operation
opCtx = new LookupOperationContext( registries, target );
opCtx.addRequestControls( requestControls );
@@ -324,8 +320,8 @@
responseControls = opCtx.getResponseControls();
return serverEntry;
}
-
-
+
+
/**
* Used to encapsulate [de]marshalling of controls before and after lookup operations.
*/
@@ -333,7 +329,7 @@
{
// setup the op context and populate with request controls
LookupOperationContext opCtx;
-
+
// execute lookup/getRootDSE operation
opCtx = new LookupOperationContext( registries, target, attrIds );
opCtx.addRequestControls( requestControls );
@@ -342,21 +338,21 @@
// clear the request controls and set the response controls
requestControls = EMPTY_CONTROLS;
responseControls = opCtx.getResponseControls();
-
+
// Now remove the ObjectClass attribute if it has not been requested
if ( ( opCtx.getAttrsId() != null ) && ( opCtx.getAttrsId().size() != 0 ) )
{
- if ( ( serverEntry.get( SchemaConstants.OBJECT_CLASS_AT ) != null ) &&
- (serverEntry.get( SchemaConstants.OBJECT_CLASS_AT ).size() == 0 ) )
+ if ( ( serverEntry.get( SchemaConstants.OBJECT_CLASS_AT ) != null )
+ && ( serverEntry.get( SchemaConstants.OBJECT_CLASS_AT ).size() == 0 ) )
{
- serverEntry.removeAttributes( SchemaConstants.OBJECT_CLASS_AT );
+ serverEntry.removeAttributes( SchemaConstants.OBJECT_CLASS_AT );
}
}
-
+
return serverEntry;
}
-
-
+
+
/**
* Used to encapsulate [de]marshalling of controls before and after bind operations.
*/
@@ -370,27 +366,27 @@
opCtx.setMechanisms( mechanisms );
opCtx.setSaslAuthId( saslAuthId );
opCtx.addRequestControls( requestControls );
-
+
// execute bind operation
- this.nexusProxy.bind( opCtx );
-
+ this.nexusProxy.bind( opCtx );
+
// clear the request controls and set the response controls
requestControls = EMPTY_CONTROLS;
responseControls = opCtx.getResponseControls();
}
-
-
+
+
/**
* Used to encapsulate [de]marshalling of controls before and after moveAndRename operations.
*/
- protected void doMoveAndRenameOperation( LdapDN oldDn, LdapDN parent, String newRdn, boolean delOldDn )
+ protected void doMoveAndRenameOperation( LdapDN oldDn, LdapDN parent, String newRdn, boolean delOldDn )
throws NamingException
{
// setup the op context and populate with request controls
- MoveAndRenameOperationContext opCtx =
- new MoveAndRenameOperationContext( registries, oldDn, parent, new Rdn( newRdn ), delOldDn );
+ MoveAndRenameOperationContext opCtx = new MoveAndRenameOperationContext( registries, oldDn, parent, new Rdn(
+ newRdn ), delOldDn );
opCtx.addRequestControls( requestControls );
-
+
// execute moveAndRename operation
nexusProxy.moveAndRename( opCtx );
@@ -398,8 +394,8 @@
requestControls = EMPTY_CONTROLS;
responseControls = opCtx.getResponseControls();
}
-
-
+
+
/**
* Used to encapsulate [de]marshalling of controls before and after modify operations.
*/
@@ -408,7 +404,7 @@
// setup the op context and populate with request controls
ModifyOperationContext opCtx = new ModifyOperationContext( registries, dn, modifications );
opCtx.addRequestControls( requestControls );
-
+
// execute modify operation
nexusProxy.modify( opCtx );
@@ -416,8 +412,8 @@
requestControls = EMPTY_CONTROLS;
responseControls = opCtx.getResponseControls();
}
-
-
+
+
/**
* Used to encapsulate [de]marshalling of controls before and after moveAndRename operations.
*/
@@ -426,7 +422,7 @@
// setup the op context and populate with request controls
MoveOperationContext opCtx = new MoveOperationContext( registries, oldDn, target );
opCtx.addRequestControls( requestControls );
-
+
// execute move operation
nexusProxy.move( opCtx );
@@ -434,8 +430,8 @@
requestControls = EMPTY_CONTROLS;
responseControls = opCtx.getResponseControls();
}
-
-
+
+
/**
* Used to encapsulate [de]marshalling of controls before and after rename operations.
*/
@@ -444,7 +440,7 @@
// setup the op context and populate with request controls
RenameOperationContext opCtx = new RenameOperationContext( registries, oldDn, new Rdn( newRdn ), delOldRdn );
opCtx.addRequestControls( requestControls );
-
+
// execute rename operation
nexusProxy.rename( opCtx );
@@ -452,13 +448,12 @@
requestControls = EMPTY_CONTROLS;
responseControls = opCtx.getResponseControls();
}
-
-
+
+
// ------------------------------------------------------------------------
// New Impl Specific Public Methods
// ------------------------------------------------------------------------
-
/**
* Gets a handle on the root context of the DIT. The RootDSE as the present user.
*
@@ -466,8 +461,8 @@
* @throws NamingException if this fails
*/
public abstract ServerContext getRootContext() throws NamingException;
-
-
+
+
/**
* Gets the {@link DirectoryService} associated with this context.
*
@@ -602,28 +597,30 @@
LdapDN target = buildTarget( name );
ServerEntry serverEntry = new DefaultServerEntry( registries, target );
serverEntry.add( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC, JavaLdapSupport.JCONTAINER_ATTR );
-
+
// Now add the CN attribute, which is mandatory
Rdn rdn = target.getRdn();
-
+
if ( rdn != null )
{
- if ( SchemaConstants.CN_AT.equals( rdn.getNormType() ) )
+ if ( SchemaConstants.CN_AT.equals( rdn.getNormType() ) )
{
- serverEntry.put( rdn.getUpType(), (String)rdn.getUpValue() );
+ serverEntry.put( rdn.getUpType(), ( String ) rdn.getUpValue() );
}
else
{
// No CN in the rdn, this is an error
- throw new LdapSchemaViolationException( name + " does not contains the mandatory 'cn' attribute for JavaContainer ObjectClass!",
+ throw new LdapSchemaViolationException( name
+ + " does not contains the mandatory 'cn' attribute for JavaContainer ObjectClass!",
ResultCodeEnum.OBJECT_CLASS_VIOLATION );
}
}
else
{
// No CN in the rdn, this is an error
- throw new LdapSchemaViolationException( name + " does not contains the mandatory 'cn' attribute for JavaContainer ObjectClass!",
- ResultCodeEnum.OBJECT_CLASS_VIOLATION);
+ throw new LdapSchemaViolationException( name
+ + " does not contains the mandatory 'cn' attribute for JavaContainer ObjectClass!",
+ ResultCodeEnum.OBJECT_CLASS_VIOLATION );
}
/*
@@ -653,7 +650,7 @@
public void destroySubcontext( Name name ) throws NamingException
{
LdapDN target = buildTarget( name );
-
+
if ( target.size() == 0 )
{
throw new LdapNoPermissionException( "can't delete the rootDSE" );
@@ -671,26 +668,26 @@
bind( new LdapDN( name ), obj );
}
-
+
private void injectRdnAttributeValues( LdapDN target, ServerEntry serverEntry ) throws NamingException
{
// Add all the RDN attributes and their values to this entry
Rdn rdn = target.getRdn( target.size() - 1 );
-
+
if ( rdn.size() == 1 )
{
- serverEntry.put( rdn.getUpType(), (String)rdn.getValue() );
+ serverEntry.put( rdn.getUpType(), ( String ) rdn.getValue() );
}
else
{
- for ( AttributeTypeAndValue atav:rdn )
- {
- serverEntry.put( atav.getUpType(), (String)atav.getNormValue() );
+ for ( AttributeTypeAndValue atav : rdn )
+ {
+ serverEntry.put( atav.getUpType(), ( String ) atav.getNormValue() );
}
}
}
-
+
/**
* @see javax.naming.Context#bind(javax.naming.Name, java.lang.Object)
*/
@@ -700,9 +697,10 @@
DirStateFactory.Result res = DirectoryManager.getStateToBind( obj, name, this, env, null );
LdapDN target = buildTarget( name );
-
+
// let's be sure that the Attributes is case insensitive
- ServerEntry outServerEntry = ServerEntryUtils.toServerEntry( AttributeUtils.toCaseInsensitive( res.getAttributes() ), dn, registries );
+ ServerEntry outServerEntry = ServerEntryUtils.toServerEntry( AttributeUtils.toCaseInsensitive( res
+ .getAttributes() ), target, registries );
if ( outServerEntry != null )
{
@@ -710,16 +708,10 @@
return;
}
- if ( obj instanceof Attributes )
+ if ( obj instanceof ServerEntry )
{
- Attributes attributes = (Attributes)obj;
-
- doAddOperation( target, ServerEntryUtils.toServerEntry( attributes, target, registries ) );
- }
- else if ( obj instanceof ServerEntry )
- {
- doAddOperation( target, (ServerEntry)obj );
- }
+ doAddOperation( target, ( ServerEntry ) obj );
+ }
// Check for Referenceable
else if ( obj instanceof Referenceable )
{
@@ -735,13 +727,13 @@
{
// Serialize and add outAttrs
ServerEntry serverEntry = new DefaultServerEntry( registries, target );
-
+
if ( ( outServerEntry != null ) && ( outServerEntry.size() > 0 ) )
{
- for ( EntryAttribute serverAttribute:outServerEntry )
- {
- serverEntry.put( serverAttribute );
- }
+ for ( EntryAttribute serverAttribute : outServerEntry )
+ {
+ serverEntry.put( serverAttribute );
+ }
}
// Get target and inject all rdn attributes into entry
@@ -754,14 +746,15 @@
else if ( obj instanceof DirContext )
{
// Grab attributes and merge with outAttrs
- ServerEntry serverEntry = ServerEntryUtils.toServerEntry( ((DirContext)obj).getAttributes( "" ), target, registries );
-
+ ServerEntry serverEntry = ServerEntryUtils.toServerEntry( ( ( DirContext ) obj ).getAttributes( "" ),
+ target, registries );
+
if ( ( outServerEntry != null ) && ( outServerEntry.size() > 0 ) )
{
- for ( EntryAttribute serverAttribute:outServerEntry )
- {
- serverEntry.put( serverAttribute );
- }
+ for ( EntryAttribute serverAttribute : outServerEntry )
+ {
+ serverEntry.put( serverAttribute );
+ }
}
injectRdnAttributeValues( target, serverEntry );
@@ -790,7 +783,7 @@
{
LdapDN oldDn = buildTarget( oldName );
LdapDN newDn = buildTarget( newName );
-
+
if ( oldDn.size() == 0 )
{
throw new LdapNoPermissionException( "can't rename the rootDSE" );
@@ -801,7 +794,7 @@
oldBase.remove( oldName.size() - 1 );
LdapDN newBase = ( LdapDN ) newName.clone();
newBase.remove( newName.size() - 1 );
-
+
String newRdn = newName.get( newName.size() - 1 );
String oldRdn = oldName.get( oldName.size() - 1 );
boolean delOldRdn = true;
@@ -813,9 +806,8 @@
if ( null != env.get( DELETE_OLD_RDN_PROP ) )
{
String delOldRdnStr = ( String ) env.get( DELETE_OLD_RDN_PROP );
- delOldRdn = !delOldRdnStr.equalsIgnoreCase( "false" ) &&
- !delOldRdnStr.equalsIgnoreCase( "no" ) &&
- !delOldRdnStr.equals( "0" );
+ delOldRdn = !delOldRdnStr.equalsIgnoreCase( "false" ) && !delOldRdnStr.equalsIgnoreCase( "no" )
+ && !delOldRdnStr.equals( "0" );
}
/*
@@ -834,7 +826,7 @@
{
LdapDN target = ( LdapDN ) newDn.clone();
target.remove( newDn.size() - 1 );
-
+
if ( newRdn.equalsIgnoreCase( oldRdn ) )
{
doMove( oldDn, target );
@@ -862,12 +854,12 @@
public void rebind( Name name, Object obj ) throws NamingException
{
LdapDN target = buildTarget( name );
-
+
if ( nexusProxy.hasEntry( new EntryOperationContext( registries, target ) ) )
{
doDeleteOperation( target );
}
-
+
bind( name, obj );
}
@@ -913,9 +905,9 @@
{
Object obj;
LdapDN target = buildTarget( name );
-
+
ServerEntry serverEntry;
-
+
if ( name.size() == 0 )
{
serverEntry = doGetRootDSEOperation( target );
@@ -927,7 +919,8 @@
try
{
- obj = DirectoryManager.getObjectInstance( null, name, this, env, ServerEntryUtils.toAttributesImpl( serverEntry ) );
+ obj = DirectoryManager.getObjectInstance( null, name, this, env, ServerEntryUtils
+ .toAttributesImpl( serverEntry ) );
}
catch ( Exception e )
{
@@ -1016,7 +1009,8 @@
/**
* @see javax.naming.Context#list(java.lang.String)
*/
- @SuppressWarnings(value={"unchecked"})
+ @SuppressWarnings(value =
+ { "unchecked" })
public NamingEnumeration list( String name ) throws NamingException
{
return list( new LdapDN( name ) );
@@ -1026,7 +1020,8 @@
/**
* @see javax.naming.Context#list(javax.naming.Name)
*/
- @SuppressWarnings(value={"unchecked"})
+ @SuppressWarnings(value =
+ { "unchecked" })
public NamingEnumeration list( Name name ) throws NamingException
{
return ServerEntryUtils.toSearchResultEnum( doListOperation( buildTarget( name ) ) );
@@ -1036,7 +1031,8 @@
/**
* @see javax.naming.Context#listBindings(java.lang.String)
*/
- @SuppressWarnings(value={"unchecked"})
+ @SuppressWarnings(value =
+ { "unchecked" })
public NamingEnumeration listBindings( String name ) throws NamingException
{
return listBindings( new LdapDN( name ) );
@@ -1046,7 +1042,8 @@
/**
* @see javax.naming.Context#listBindings(javax.naming.Name)
*/
- @SuppressWarnings(value={"unchecked"})
+ @SuppressWarnings(value =
+ { "unchecked" })
public NamingEnumeration listBindings( Name name ) throws NamingException
{
// Conduct a special one level search at base for all objects
@@ -1129,8 +1126,8 @@
ExprNode filter = new PresenceNode( SchemaConstants.OBJECT_CLASS_AT );
SearchControls controls = new SearchControls();
controls.setSearchScope( scope );
- ( ( PartitionNexusProxy ) this.nexusProxy ).addNamingListener( this, buildTarget( name ), filter,
- controls, namingListener );
+ ( ( PartitionNexusProxy ) this.nexusProxy ).addNamingListener( this, buildTarget( name ), filter, controls,
+ namingListener );
listeners.add( namingListener );
}
Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/jndi/ServerDirContext.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/jndi/ServerDirContext.java?rev=652410&r1=652409&r2=652410&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/jndi/ServerDirContext.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/jndi/ServerDirContext.java Wed Apr 30 17:06:41 2008
@@ -29,6 +29,8 @@
import org.apache.directory.shared.ldap.constants.SchemaConstants;
import org.apache.directory.shared.ldap.entry.EntryAttribute;
import org.apache.directory.shared.ldap.entry.Modification;
+import org.apache.directory.shared.ldap.entry.client.ClientBinaryValue;
+import org.apache.directory.shared.ldap.entry.client.ClientStringValue;
import org.apache.directory.shared.ldap.filter.AndNode;
import org.apache.directory.shared.ldap.filter.BranchNode;
import org.apache.directory.shared.ldap.filter.EqualityNode;
@@ -88,7 +90,7 @@
* @param env the environment used for this context
* @throws NamingException if something goes wrong
*/
- public ServerDirContext(DirectoryService service, Hashtable<String, Object> env) throws NamingException
+ public ServerDirContext( DirectoryService service, Hashtable<String, Object> env ) throws NamingException
{
super( service, env );
}
@@ -158,6 +160,7 @@
modifyAttributes( new LdapDN( name ), modOp, AttributeUtils.toCaseInsensitive( attrs ) );
}
+
/**
* @see javax.naming.directory.DirContext#modifyAttributes(java.lang.String,
* int, javax.naming.directory.Attributes)
@@ -165,43 +168,45 @@
public void modifyAttributes( Name name, int modOp, Attributes attrs ) throws NamingException
{
List<ModificationItemImpl> modItems = null;
-
+
if ( attrs != null )
{
modItems = new ArrayList<ModificationItemImpl>( attrs.size() );
- NamingEnumeration<? extends Attribute> e = (NamingEnumeration<? extends Attribute>)attrs.getAll();
-
+ NamingEnumeration<? extends Attribute> e = ( NamingEnumeration<? extends Attribute> ) attrs.getAll();
+
while ( e.hasMore() )
{
modItems.add( new ModificationItemImpl( modOp, e.next() ) );
}
}
- List<Modification> newMods = ServerEntryUtils.toServerModification( modItems, registries.getAttributeTypeRegistry() );
+ List<Modification> newMods = ServerEntryUtils.toServerModification( modItems, registries
+ .getAttributeTypeRegistry() );
- if ( name instanceof LdapDN )
- {
+ if ( name instanceof LdapDN )
+ {
doModifyOperation( buildTarget( name ), newMods );
- }
- else
- {
+ }
+ else
+ {
doModifyOperation( buildTarget( new LdapDN( name ) ), newMods );
- }
+ }
}
+
/**
* @see javax.naming.directory.DirContext#modifyAttributes(java.lang.String,
* javax.naming.directory.ModificationItem[])
*/
public void modifyAttributes( String name, ModificationItem[] mods ) throws NamingException
{
- ModificationItemImpl[] newMods = new ModificationItemImpl[ mods.length ];
-
+ ModificationItemImpl[] newMods = new ModificationItemImpl[mods.length];
+
for ( int i = 0; i < mods.length; i++ )
{
newMods[i] = new ModificationItemImpl( mods[i] );
}
-
+
modifyAttributes( new LdapDN( name ), newMods );
}
@@ -222,7 +227,8 @@
*/
public void modifyAttributes( Name name, ModificationItem[] mods ) throws NamingException
{
- List<Modification> newMods = ServerEntryUtils.toServerModification( mods, registries.getAttributeTypeRegistry() );
+ List<Modification> newMods = ServerEntryUtils
+ .toServerModification( mods, registries.getAttributeTypeRegistry() );
doModifyOperation( buildTarget( new LdapDN( name ) ), newMods );
}
@@ -233,7 +239,8 @@
*/
public void modifyAttributes( Name name, List<ModificationItemImpl> mods ) throws NamingException
{
- List<Modification> newMods = ServerEntryUtils.toServerModification( mods, registries.getAttributeTypeRegistry() );
+ List<Modification> newMods = ServerEntryUtils
+ .toServerModification( mods, registries.getAttributeTypeRegistry() );
doModifyOperation( buildTarget( new LdapDN( name ) ), newMods );
}
@@ -269,12 +276,13 @@
LdapDN target = buildTarget( name );
- ServerEntry serverEntry = ServerEntryUtils.toServerEntry( AttributeUtils.toCaseInsensitive( attrs ), target, registries );
-
+ ServerEntry serverEntry = ServerEntryUtils.toServerEntry( AttributeUtils.toCaseInsensitive( attrs ), target,
+ registries );
+
// No object binding so we just add the attributes
if ( null == obj )
{
- ServerEntry clone = ( ServerEntry ) serverEntry.clone();
+ ServerEntry clone = ( ServerEntry ) serverEntry.clone();
doAddOperation( target, clone );
return;
}
@@ -285,14 +293,14 @@
if ( outServerEntry != serverEntry )
{
- ServerEntry clone = ( ServerEntry ) serverEntry.clone();
+ ServerEntry clone = ( ServerEntry ) serverEntry.clone();
- if ( ( outServerEntry != null ) && ( outServerEntry.size() > 0 ) )
+ if ( ( outServerEntry != null ) && ( outServerEntry.size() > 0 ) )
{
- for ( EntryAttribute attribute:outServerEntry )
- {
- clone.put( attribute );
- }
+ for ( EntryAttribute attribute : outServerEntry )
+ {
+ clone.put( attribute );
+ }
}
doAddOperation( target, clone );
@@ -315,15 +323,15 @@
{
// Serialize and add outAttrs
ServerEntry clone = ( ServerEntry ) serverEntry.clone();
-
+
if ( outServerEntry != null && outServerEntry.size() > 0 )
{
- for ( EntryAttribute attribute:outServerEntry )
- {
- clone.put( attribute );
- }
+ for ( EntryAttribute attribute : outServerEntry )
+ {
+ clone.put( attribute );
+ }
}
-
+
// Serialize object into entry attributes and add it.
JavaLdapSupport.serialize( serverEntry, obj, registries );
doAddOperation( target, clone );
@@ -331,16 +339,17 @@
else if ( obj instanceof DirContext )
{
// Grab attributes and merge with outAttrs
- ServerEntry entry = ServerEntryUtils.toServerEntry( ( ( DirContext ) obj ).getAttributes( "" ), target, registries );
-
+ ServerEntry entry = ServerEntryUtils.toServerEntry( ( ( DirContext ) obj ).getAttributes( "" ), target,
+ registries );
+
if ( ( outServerEntry != null ) && ( outServerEntry.size() > 0 ) )
{
- for ( EntryAttribute attribute:outServerEntry )
- {
- entry.put( attribute );
- }
+ for ( EntryAttribute attribute : outServerEntry )
+ {
+ entry.put( attribute );
+ }
}
-
+
doAddOperation( target, entry );
}
else
@@ -367,12 +376,12 @@
public void rebind( Name name, Object obj, Attributes attrs ) throws NamingException
{
LdapDN target = buildTarget( name );
-
+
if ( getNexusProxy().hasEntry( new EntryOperationContext( registries, target ) ) )
{
doDeleteOperation( target );
}
-
+
bind( name, obj, AttributeUtils.toCaseInsensitive( attrs ) );
}
@@ -400,22 +409,22 @@
LdapDN target = buildTarget( name );
Rdn rdn = target.getRdn( target.size() - 1 );
-
- attrs = AttributeUtils.toCaseInsensitive( attrs );
+
+ attrs = AttributeUtils.toCaseInsensitive( attrs );
Attributes attributes = ( Attributes ) attrs.clone();
-
+
if ( rdn.size() == 1 )
{
String rdnAttribute = rdn.getUpType();
- String rdnValue = (String)rdn.getValue();
+ String rdnValue = ( String ) rdn.getValue();
// Add the Rdn attribute
boolean doRdnPut = attributes.get( rdnAttribute ) == null;
doRdnPut = doRdnPut || attributes.get( rdnAttribute ).size() == 0;
-
+
// TODO Fix DIRSERVER-832
doRdnPut = doRdnPut || !attributes.get( rdnAttribute ).contains( rdnValue );
-
+
if ( doRdnPut )
{
attributes.put( rdnAttribute, rdnValue );
@@ -423,17 +432,17 @@
}
else
{
- for ( Iterator<AttributeTypeAndValue> ii = rdn.iterator(); ii.hasNext(); /**/ )
+ for ( Iterator<AttributeTypeAndValue> ii = rdn.iterator(); ii.hasNext(); /**/)
{
AttributeTypeAndValue atav = ii.next();
// Add the Rdn attribute
boolean doRdnPut = attributes.get( atav.getNormType() ) == null;
doRdnPut = doRdnPut || attributes.get( atav.getNormType() ).size() == 0;
-
+
// TODO Fix DIRSERVER-832
doRdnPut = doRdnPut || !attributes.get( atav.getNormType() ).contains( atav.getNormValue() );
-
+
if ( doRdnPut )
{
attributes.put( atav.getNormType(), atav.getNormValue() );
@@ -513,8 +522,8 @@
* @see javax.naming.directory.DirContext#search(java.lang.String,
* javax.naming.directory.Attributes, java.lang.String[])
*/
- public NamingEnumeration<SearchResult> search( String name, Attributes matchingAttributes, String[] attributesToReturn )
- throws NamingException
+ public NamingEnumeration<SearchResult> search( String name, Attributes matchingAttributes,
+ String[] attributesToReturn ) throws NamingException
{
return search( new LdapDN( name ), AttributeUtils.toCaseInsensitive( matchingAttributes ), attributesToReturn );
}
@@ -538,7 +547,7 @@
// If matchingAttributes is null/empty use a match for everything filter
matchingAttributes = AttributeUtils.toCaseInsensitive( matchingAttributes );
-
+
if ( ( null == matchingAttributes ) || ( matchingAttributes.size() <= 0 ) )
{
PresenceNode filter = new PresenceNode( SchemaConstants.OBJECT_CLASS_AT );
@@ -552,26 +561,26 @@
NamingEnumeration<? extends Attribute> list = matchingAttributes.getAll();
Attribute attr = list.next();
list.close();
-
+
if ( attr.size() == 1 )
{
Object value = attr.get();
SimpleNode node;
-
+
if ( value instanceof byte[] )
{
- node = new EqualityNode( attr.getID(), ( byte [] ) value );
+ node = new EqualityNode( attr.getID(), new ClientBinaryValue( ( byte[] ) value ) );
}
- else
+ else
{
- node = new EqualityNode( attr.getID(), ( String ) value );
+ node = new EqualityNode( attr.getID(), new ClientStringValue( ( String ) value ) );
}
AliasDerefMode aliasDerefMode = AliasDerefMode.getEnum( getEnvironment() );
return ServerEntryUtils.toSearchResultEnum( doSearchOperation( target, aliasDerefMode, node, ctls ) );
}
}
-
+
/*
* Go through the set of attributes using each attribute value pair as
* an attribute value assertion within one big AND filter expression.
@@ -608,7 +617,7 @@
// Add simpel AVA node if its value is a String
if ( val instanceof String )
{
- node = new EqualityNode( attr.getID(), ( String ) val );
+ node = new EqualityNode( attr.getID(), new ClientStringValue( ( String ) val ) );
filter.addNode( node );
}
}
@@ -623,7 +632,8 @@
* @see javax.naming.directory.DirContext#search(java.lang.String,
* java.lang.String, javax.naming.directory.SearchControls)
*/
- public NamingEnumeration<SearchResult> search( String name, String filter, SearchControls cons ) throws NamingException
+ public NamingEnumeration<SearchResult> search( String name, String filter, SearchControls cons )
+ throws NamingException
{
return search( new LdapDN( name ), filter, cons );
}
@@ -640,7 +650,8 @@
* @return an enumeration over the SearchResults
* @throws NamingException if there are problems performing the search
*/
- public NamingEnumeration<SearchResult> search( Name name, ExprNode filter, SearchControls cons ) throws NamingException
+ public NamingEnumeration<SearchResult> search( Name name, ExprNode filter, SearchControls cons )
+ throws NamingException
{
LdapDN target = buildTarget( name );
AliasDerefMode aliasDerefMode = AliasDerefMode.getEnum( getEnvironment() );
@@ -652,7 +663,8 @@
* @see javax.naming.directory.DirContext#search(javax.naming.Name,
* java.lang.String, javax.naming.directory.SearchControls)
*/
- public NamingEnumeration<SearchResult> search( Name name, String filter, SearchControls cons ) throws NamingException
+ public NamingEnumeration<SearchResult> search( Name name, String filter, SearchControls cons )
+ throws NamingException
{
ExprNode filterNode;
LdapDN target = buildTarget( name );
@@ -679,8 +691,8 @@
* java.lang.String, java.lang.Object[],
* javax.naming.directory.SearchControls)
*/
- public NamingEnumeration<SearchResult> search( String name, String filterExpr, Object[] filterArgs, SearchControls cons )
- throws NamingException
+ public NamingEnumeration<SearchResult> search( String name, String filterExpr, Object[] filterArgs,
+ SearchControls cons ) throws NamingException
{
return search( new LdapDN( name ), filterExpr, filterArgs, cons );
}
@@ -691,8 +703,8 @@
* java.lang.String, java.lang.Object[],
* javax.naming.directory.SearchControls)
*/
- public NamingEnumeration<SearchResult> search( Name name, String filterExpr, Object[] filterArgs, SearchControls cons )
- throws NamingException
+ public NamingEnumeration<SearchResult> search( Name name, String filterExpr, Object[] filterArgs,
+ SearchControls cons ) throws NamingException
{
int start;
int index;
@@ -754,6 +766,7 @@
return search( name, buf.toString(), cons );
}
+
// ------------------------------------------------------------------------
// EventDirContext implementations
// ------------------------------------------------------------------------
Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/jndi/ServerLdapContext.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/jndi/ServerLdapContext.java?rev=652410&r1=652409&r2=652410&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/jndi/ServerLdapContext.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/jndi/ServerLdapContext.java Wed Apr 30 17:06:41 2008
@@ -22,7 +22,6 @@
import java.util.Hashtable;
-import javax.naming.Context;
import javax.naming.NamingException;
import javax.naming.ldap.Control;
import javax.naming.ldap.ExtendedRequest;
Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/normalization/ExpandingVisitor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/normalization/ExpandingVisitor.java?rev=652410&r1=652409&r2=652410&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/normalization/ExpandingVisitor.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/normalization/ExpandingVisitor.java Wed Apr 30 17:06:41 2008
@@ -50,14 +50,14 @@
public class ExpandingVisitor implements FilterVisitor
{
private final AttributeTypeRegistry attrRegistry;
-
-
+
+
public ExpandingVisitor( AttributeTypeRegistry attrRegistry )
{
this.attrRegistry = attrRegistry;
}
-
-
+
+
public boolean canVisit( ExprNode node )
{
return node instanceof BranchNode;
@@ -76,24 +76,24 @@
}
- public Object visit( ExprNode node )
+ public Object visit( ExprNode node )
{
BranchNode bnode = ( BranchNode ) node;
-
+
// --------------------------------------------------------------------
// we want to check each child leaf node to see if it must be expanded
// children that are branch nodes are recursively visited
// --------------------------------------------------------------------
-
+
final List<ExprNode> children = bnode.getChildren();
int childNumber = 0;
-
- for ( ExprNode child:children )
+
+ for ( ExprNode child : children )
{
if ( child instanceof LeafNode )
{
LeafNode leaf = ( LeafNode ) child;
-
+
try
{
if ( attrRegistry.hasDescendants( leaf.getAttribute() ) )
@@ -104,117 +104,58 @@
BranchNode orNode = new OrNode();
orNode.getChildren().add( leaf );
children.set( childNumber++, orNode );
-
+
// iterate through descendants adding them to the orNode
Iterator<AttributeType> descendants = attrRegistry.descendants( leaf.getAttribute() );
-
+
while ( descendants.hasNext() )
{
LeafNode newLeaf = null;
AttributeType descendant = descendants.next();
-
+
if ( leaf instanceof PresenceNode )
{
newLeaf = new PresenceNode( descendant.getOid() );
}
- else if ( leaf instanceof ApproximateNode )
+ else if ( leaf instanceof ApproximateNode )
{
- ApproximateNode approximateNode = ( ApproximateNode ) leaf;
-
- if ( approximateNode.getValue() instanceof String )
- {
- newLeaf = new ApproximateNode( descendant.getOid(),
- ( String ) approximateNode.getValue() );
- }
- else if ( approximateNode.getValue() instanceof byte[] )
- {
- newLeaf = new ApproximateNode( descendant.getOid(),
- ( byte[] ) approximateNode.getValue() );
- }
- else
- {
- newLeaf = new ApproximateNode( descendant.getOid(),
- approximateNode.getValue().toString() );
- }
+ ApproximateNode approximateNode = ( ApproximateNode ) leaf;
+
+ newLeaf = new ApproximateNode( descendant.getOid(), approximateNode.getValue() );
}
else if ( leaf instanceof EqualityNode )
{
- EqualityNode equalityNode = ( EqualityNode ) leaf;
-
- if ( equalityNode.getValue() instanceof String )
- {
- newLeaf = new EqualityNode( descendant.getOid(),
- ( String ) equalityNode.getValue() );
- }
- else if ( equalityNode.getValue() instanceof byte[] )
- {
- newLeaf = new EqualityNode( descendant.getOid(),
- ( byte[] ) equalityNode.getValue() );
- }
- else
- {
- newLeaf = new EqualityNode( descendant.getOid(),
- equalityNode.getValue().toString() );
- }
+ EqualityNode equalityNode = ( EqualityNode ) leaf;
+
+ newLeaf = new EqualityNode( descendant.getOid(), equalityNode.getValue() );
}
else if ( leaf instanceof GreaterEqNode )
{
- GreaterEqNode greaterEqNode = ( GreaterEqNode ) leaf;
-
- if ( greaterEqNode.getValue() instanceof String )
- {
- newLeaf = new GreaterEqNode( descendant.getOid(),
- ( String ) greaterEqNode.getValue() );
- }
- else if ( greaterEqNode.getValue() instanceof byte[] )
- {
- newLeaf = new GreaterEqNode( descendant.getOid(),
- ( byte[] ) greaterEqNode.getValue() );
- }
- else
- {
- newLeaf = new GreaterEqNode( descendant.getOid(),
- greaterEqNode.getValue().toString() );
- }
+ GreaterEqNode greaterEqNode = ( GreaterEqNode ) leaf;
+
+ newLeaf = new GreaterEqNode( descendant.getOid(), greaterEqNode.getValue() );
}
else if ( leaf instanceof LessEqNode )
{
- LessEqNode lessEqNode = ( LessEqNode ) leaf;
-
- if ( lessEqNode.getValue() instanceof String )
- {
- newLeaf = new LessEqNode( descendant.getOid(),
- ( String ) lessEqNode.getValue() );
- }
- else if ( lessEqNode.getValue() instanceof byte[] )
- {
- newLeaf = new LessEqNode( descendant.getOid(),
- ( byte[] ) lessEqNode.getValue() );
- }
- else
- {
- newLeaf = new LessEqNode( descendant.getOid(),
- lessEqNode.getValue().toString() );
- }
+ LessEqNode lessEqNode = ( LessEqNode ) leaf;
+
+ newLeaf = new LessEqNode( descendant.getOid(), lessEqNode.getValue() );
}
else if ( leaf instanceof ExtensibleNode )
{
ExtensibleNode extensibleNode = ( ExtensibleNode ) leaf;
- newLeaf = new ExtensibleNode( descendant.getOid(),
- extensibleNode.getValue(),
- extensibleNode.getMatchingRuleId(),
- extensibleNode.hasDnAttributes() );
+ newLeaf = new ExtensibleNode( descendant.getOid(), extensibleNode.getValue(),
+ extensibleNode.getMatchingRuleId(), extensibleNode.hasDnAttributes() );
}
else if ( leaf instanceof SubstringNode )
{
SubstringNode substringNode = ( SubstringNode ) leaf;
- newLeaf = new SubstringNode( descendant.getOid(),
- substringNode.getInitial(),
+ newLeaf = new SubstringNode( descendant.getOid(), substringNode.getInitial(),
substringNode.getFinal() );
}
else
{
- throw new IllegalStateException( "Unknown assertion type: " + leaf );
+ throw new IllegalStateException( "Unknown assertion type: " + leaf );
}
orNode.addNode( newLeaf );
@@ -232,7 +173,7 @@
visit( child );
}
} // end for loop
-
+
return null;
}
}
Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/normalization/NormalizationInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/normalization/NormalizationInterceptor.java?rev=652410&r1=652409&r2=652410&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/normalization/NormalizationInterceptor.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/normalization/NormalizationInterceptor.java Wed Apr 30 17:06:41 2008
@@ -90,7 +90,7 @@
OidRegistry oidRegistry = directoryService.getRegistries().getOidRegistry();
attributeRegistry = directoryService.getRegistries().getAttributeTypeRegistry();
NameComponentNormalizer ncn = new ConcreteNameComponentNormalizer( attributeRegistry, oidRegistry );
- normVisitor = new NormalizingVisitor( ncn, oidRegistry );
+ normVisitor = new NormalizingVisitor( ncn, directoryService.getRegistries() );
//expVisitor = new ExpandingVisitor( attributeRegistry );
attrNormalizers = attributeRegistry.getNormalizerMapping();
}
Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/normalization/NormalizingVisitor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/normalization/NormalizingVisitor.java?rev=652410&r1=652409&r2=652410&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/normalization/NormalizingVisitor.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/normalization/NormalizingVisitor.java Wed Apr 30 17:06:41 2008
@@ -20,7 +20,10 @@
package org.apache.directory.server.core.normalization;
-import org.apache.directory.server.schema.registries.OidRegistry;
+import org.apache.directory.server.schema.registries.Registries;
+import org.apache.directory.shared.ldap.entry.Value;
+import org.apache.directory.shared.ldap.entry.client.ClientBinaryValue;
+import org.apache.directory.shared.ldap.entry.client.ClientStringValue;
import org.apache.directory.shared.ldap.filter.AndNode;
import org.apache.directory.shared.ldap.filter.BranchNode;
import org.apache.directory.shared.ldap.filter.ExprNode;
@@ -32,6 +35,8 @@
import org.apache.directory.shared.ldap.filter.SimpleNode;
import org.apache.directory.shared.ldap.filter.SubstringNode;
import org.apache.directory.shared.ldap.name.NameComponentNormalizer;
+import org.apache.directory.shared.ldap.schema.AttributeType;
+import org.apache.directory.shared.ldap.util.StringTools;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -63,53 +68,72 @@
{
/** logger used by this class */
private final static Logger log = LoggerFactory.getLogger( NormalizingVisitor.class );
-
+
/** the name component normalizer used by this visitor */
private final NameComponentNormalizer ncn;
-
- /** the oid registry used to resolve OIDs for attributeType ids */
- private final OidRegistry registry;
+
+ /** the global registries used to resolve OIDs for attributeType ids */
+ private final Registries registries;
- public NormalizingVisitor( NameComponentNormalizer ncn, OidRegistry registry )
+ public NormalizingVisitor( NameComponentNormalizer ncn, Registries registries )
{
this.ncn = ncn;
- this.registry = registry;
+ this.registries = registries;
}
-
+
+
/**
* A private method used to normalize a value
* @return
*/
- private Object normalizeValue( String attribute, Object value )
+ private Value<?> normalizeValue( String attribute, Value<?> value )
{
- try
- {
- Object normalized;
-
- if ( value instanceof String )
- {
- normalized = ncn.normalizeByName( attribute, ( String ) value );
- }
- else if ( value instanceof byte [] )
+ try
+ {
+ Value<?> normalized;
+
+ AttributeType attributeType = registries.getAttributeTypeRegistry().lookup( attribute );
+
+ if ( attributeType.getSyntax().isHumanReadable() )
{
- normalized = ncn.normalizeByName( attribute, ( byte[] ) value );
+ if ( value.isBinary() )
+ {
+ normalized = new ClientStringValue( ( String ) ncn.normalizeByName( attribute, StringTools
+ .utf8ToString( ( byte[] ) value.get() ) ) );
+ }
+ else
+ {
+ normalized = new ClientStringValue( ( String ) ncn.normalizeByName( attribute, ( String ) value
+ .get() ) );
+ }
}
else
{
- normalized = ncn.normalizeByOid( attribute, value.toString() );
+ if ( value.isBinary() )
+ {
+ normalized = new ClientBinaryValue( ( byte[] ) ncn.normalizeByName( attribute, ( byte[] ) value
+ .get() ) );
+ }
+ else
+ {
+ normalized = new ClientBinaryValue( ( byte[] ) ncn.normalizeByName( attribute, ( String ) value
+ .get() ) );
+
+ }
}
-
- return normalized;
- }
- catch ( NamingException ne )
- {
- log.warn( "Failed to normalize filter value: {}", ne.getMessage(), ne );
- return null;
- }
-
+
+ return normalized;
+ }
+ catch ( NamingException ne )
+ {
+ log.warn( "Failed to normalize filter value: {}", ne.getMessage(), ne );
+ return null;
+ }
+
}
-
+
+
/**
* Visit a PresenceNode. If the attribute exists, the node is returned, otherwise
* null is returned.
@@ -118,7 +142,7 @@
{
try
{
- node.setAttribute( registry.getOid( node.getAttribute() ) );
+ node.setAttribute( registries.getOidRegistry().getOid( node.getAttribute() ) );
return node;
}
catch ( NamingException ne )
@@ -128,6 +152,7 @@
}
}
+
/**
* Visit a SimpleNode. If the attribute exists, the node is returned, otherwise
* null is returned. SimpleNodes are :
@@ -145,16 +170,16 @@
return null;
}
- Object normalized = normalizeValue( node.getAttribute(), node.getValue() );
-
+ Value<?> normalized = normalizeValue( node.getAttribute(), node.getValue() );
+
if ( normalized == null )
{
- return null;
+ return null;
}
try
{
- node.setAttribute( registry.getOid( node.getAttribute() ) );
+ node.setAttribute( registries.getOidRegistry().getOid( node.getAttribute() ) );
node.setValue( normalized );
return node;
}
@@ -165,6 +190,7 @@
}
}
+
/**
* Visit a SubstringNode. If the attribute exists, the node is returned, otherwise
* null is returned.
@@ -177,62 +203,79 @@
// with an undefined attributeType for its attribute
if ( !ncn.isDefined( node.getAttribute() ) )
{
- return null;
+ return null;
}
- Object normInitial = null;
-
+ Value<?> normInitial = null;
+
if ( node.getInitial() != null )
{
- normInitial = normalizeValue( node.getAttribute(), node.getInitial() );
-
- if ( normInitial == null )
- {
- return null;
- }
+ normInitial = normalizeValue( node.getAttribute(), new ClientStringValue( node.getInitial() ) );
+
+ if ( normInitial == null )
+ {
+ return null;
+ }
}
-
+
List<String> normAnys = null;
-
+
if ( ( node.getAny() != null ) && ( node.getAny().size() != 0 ) )
{
- normAnys = new ArrayList<String>( node.getAny().size() );
-
- for ( String any:node.getAny() )
- {
- Object normAny = normalizeValue( node.getAttribute(), any );
-
- if ( normAny != null )
- {
- normAnys.add( (String)normAny );
- }
- }
-
- if ( normAnys.size() == 0 )
- {
- return null;
- }
- }
-
- Object normFinal = null;
-
+ normAnys = new ArrayList<String>( node.getAny().size() );
+
+ for ( String any : node.getAny() )
+ {
+ Value<?> normAny = normalizeValue( node.getAttribute(), new ClientStringValue( any ) );
+
+ if ( normAny != null )
+ {
+ normAnys.add( ( String ) normAny.get() );
+ }
+ }
+
+ if ( normAnys.size() == 0 )
+ {
+ return null;
+ }
+ }
+
+ Value<?> normFinal = null;
+
if ( node.getFinal() != null )
{
- normFinal = normalizeValue( node.getAttribute(), node.getFinal() );
-
- if ( normFinal == null )
- {
- return null;
- }
+ normFinal = normalizeValue( node.getAttribute(), new ClientStringValue( node.getFinal() ) );
+
+ if ( normFinal == null )
+ {
+ return null;
+ }
}
-
-
+
try
{
- node.setAttribute( registry.getOid( node.getAttribute() ) );
- node.setInitial( (String)normInitial );
+ node.setAttribute( registries.getOidRegistry().getOid( node.getAttribute() ) );
+
+ if ( normInitial != null )
+ {
+ node.setInitial( ( String ) normInitial.get() );
+ }
+ else
+ {
+ node.setInitial( null );
+ }
+
node.setAny( normAnys );
- node.setFinal( (String)normFinal );
+
+ if ( normFinal != null )
+ {
+ node.setFinal( ( String ) normFinal.get() );
+ }
+ else
+ {
+ node.setFinal( null );
+ }
+
return node;
}
catch ( NamingException ne )
@@ -242,6 +285,7 @@
}
}
+
/**
* Visit a ExtensibleNode. If the attribute exists, the node is returned, otherwise
* null is returned.
@@ -252,7 +296,7 @@
{
try
{
- node.setAttribute( registry.getOid( node.getAttribute() ) );
+ node.setAttribute( registries.getOidRegistry().getOid( node.getAttribute() ) );
return node;
}
catch ( NamingException ne )
@@ -262,6 +306,7 @@
}
}
+
/**
* Visit a BranchNode. BranchNodes are :
* - AndNode
@@ -270,86 +315,86 @@
*/
private ExprNode visitBranchNode( BranchNode node )
{
- // Two differente cases :
- // - AND or OR
- // - NOT
-
- if ( node instanceof NotNode )
- {
- // Manage the NOT
- ExprNode child = node.getFirstChild();
-
- ExprNode result = (ExprNode)visit( child );
-
- if ( result == null )
- {
- return result;
- }
- else if ( result instanceof BranchNode )
- {
- node.setChildren( ((BranchNode)result).getChildren() );
- return node;
- }
- else if ( result instanceof LeafNode )
- {
- List<ExprNode> newChildren = new ArrayList<ExprNode>(1);
- newChildren.add( result );
- node.setChildren( newChildren );
- return node;
- }
- }
- else
- {
- // Manage AND and OR nodes.
- BranchNode branchNode = (BranchNode)node;
+ // Two differente cases :
+ // - AND or OR
+ // - NOT
+
+ if ( node instanceof NotNode )
+ {
+ // Manage the NOT
+ ExprNode child = node.getFirstChild();
+
+ ExprNode result = ( ExprNode ) visit( child );
+
+ if ( result == null )
+ {
+ return result;
+ }
+ else if ( result instanceof BranchNode )
+ {
+ node.setChildren( ( ( BranchNode ) result ).getChildren() );
+ return node;
+ }
+ else if ( result instanceof LeafNode )
+ {
+ List<ExprNode> newChildren = new ArrayList<ExprNode>( 1 );
+ newChildren.add( result );
+ node.setChildren( newChildren );
+ return node;
+ }
+ }
+ else
+ {
+ // Manage AND and OR nodes.
+ BranchNode branchNode = ( BranchNode ) node;
List<ExprNode> children = node.getChildren();
-
- // For AND and OR, we may have more than one children.
- // We may have to remove some of them, so let's create
- // a new handler to store the correct nodes.
- List<ExprNode> newChildren = new ArrayList<ExprNode>(
- children.size() );
-
- // Now, iterate through all the children
- for ( int i = 0; i < children.size(); i++ )
- {
- ExprNode child = children.get( i );
-
- ExprNode result = (ExprNode)visit( child );
-
- if ( result != null )
- {
- // As the node is correct, add it to the children
- // list.
- newChildren.add( result );
- }
- }
-
+
+ // For AND and OR, we may have more than one children.
+ // We may have to remove some of them, so let's create
+ // a new handler to store the correct nodes.
+ List<ExprNode> newChildren = new ArrayList<ExprNode>( children.size() );
+
+ // Now, iterate through all the children
+ for ( int i = 0; i < children.size(); i++ )
+ {
+ ExprNode child = children.get( i );
+
+ ExprNode result = ( ExprNode ) visit( child );
+
+ if ( result != null )
+ {
+ // As the node is correct, add it to the children
+ // list.
+ newChildren.add( result );
+ }
+ }
+
if ( ( branchNode instanceof AndNode ) && ( newChildren.size() != children.size() ) )
{
return null;
}
-
- if ( newChildren.size() == 0 )
- {
- // No more children, return null
- return null;
- }
- else if ( newChildren.size() == 1 )
- {
- // As we only have one child, return it
- // to the caller.
- return newChildren.get( 0 );
- }
- else
- {
- branchNode.setChildren( newChildren );
- }
- }
-
- return node;
+
+ if ( newChildren.size() == 0 )
+ {
+ // No more children, return null
+ return null;
+ }
+ else if ( newChildren.size() == 1 )
+ {
+ // As we only have one child, return it
+ // to the caller.
+ return newChildren.get( 0 );
+ }
+ else
+ {
+ branchNode.setChildren( newChildren );
+ }
+ }
+
+ return node;
}
-
+
+
/**
* Visit the tree, normalizing the leaves and recusrsively visit the branches.
*
@@ -370,41 +415,41 @@
// -------------------------------------------------------------------
// Handle PresenceNodes
// -------------------------------------------------------------------
-
+
if ( node instanceof PresenceNode )
{
- return visitPresenceNode( (PresenceNode)node );
+ return visitPresenceNode( ( PresenceNode ) node );
}
// -------------------------------------------------------------------
// Handle BranchNodes (AndNode, NotNode and OrNode)
// -------------------------------------------------------------------
-
+
else if ( node instanceof BranchNode )
{
- return visitBranchNode( (BranchNode)node );
+ return visitBranchNode( ( BranchNode ) node );
}
// -------------------------------------------------------------------
// Handle SimpleNodes (ApproximateNode, EqualityNode, GreaterEqNode,
// and LesserEqNode)
// -------------------------------------------------------------------
-
+
else if ( node instanceof SimpleNode )
{
- return visitSimpleNode( (SimpleNode)node );
+ return visitSimpleNode( ( SimpleNode ) node );
}
else if ( node instanceof ExtensibleNode )
{
- return visitExtensibleNode( (ExtensibleNode)node );
+ return visitExtensibleNode( ( ExtensibleNode ) node );
}
else if ( node instanceof SubstringNode )
{
- return visitSubstringNode( (SubstringNode)node );
+ return visitSubstringNode( ( SubstringNode ) node );
}
else
{
- return null;
+ return null;
}
}
Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/DefaultPartitionNexus.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/DefaultPartitionNexus.java?rev=652410&r1=652409&r2=652410&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/DefaultPartitionNexus.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/DefaultPartitionNexus.java Wed Apr 30 17:06:41 2008
@@ -26,7 +26,6 @@
import org.apache.directory.server.core.entry.DefaultServerEntry;
import org.apache.directory.server.core.entry.ServerAttribute;
import org.apache.directory.server.core.entry.ServerEntry;
-import org.apache.directory.server.core.entry.ServerEntryUtils;
import org.apache.directory.server.core.entry.ServerSearchResult;
import org.apache.directory.server.core.interceptor.context.AddContextPartitionOperationContext;
import org.apache.directory.server.core.interceptor.context.AddOperationContext;
@@ -88,7 +87,6 @@
import javax.naming.NameNotFoundException;
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
-import javax.naming.directory.Attributes;
import javax.naming.directory.SearchControls;
import javax.naming.ldap.LdapContext;
import java.io.IOException;
@@ -245,17 +243,6 @@
/**
- * Returns root the rootDSE.
- *
- * @return the root entry for the DSA
- */
- public Attributes getContextEntryAttr()
- {
- return null;
- }
-
-
- /**
* Sets root entry for this BTreePartition.
*
* @throws UnsupportedOperationException everytime
@@ -385,10 +372,21 @@
}
else
{
- objectClassAttr.add(
- SchemaConstants.TOP_OC,
- SchemaConstants.ORGANIZATIONAL_UNIT_OC,
- SchemaConstants.EXTENSIBLE_OBJECT_OC );
+ // Feed the contextEntry with the mandatory ObjectClass values, if they are missing.
+ if ( !objectClassAttr.contains( SchemaConstants.TOP_OC ) )
+ {
+ objectClassAttr.add( SchemaConstants.TOP_OC );
+ }
+
+ if ( !objectClassAttr.contains( SchemaConstants.ORGANIZATIONAL_UNIT_OC ) )
+ {
+ objectClassAttr.add( SchemaConstants.ORGANIZATIONAL_UNIT_OC );
+ }
+
+ if ( !objectClassAttr.contains( SchemaConstants.EXTENSIBLE_OBJECT_OC ) )
+ {
+ objectClassAttr.add( SchemaConstants.EXTENSIBLE_OBJECT_OC );
+ }
}
systemEntry.put( SchemaConstants.CREATORS_NAME_AT, ServerDNConstants.ADMIN_SYSTEM_DN );
@@ -650,14 +648,7 @@
if ( ! partition.isInitialized() )
{
- if ( partition.getContextEntry() != null )
- {
- partition.setContextEntry( partition.getContextEntry() );
- }
- else
- {
- partition.setContextEntry( ServerEntryUtils.toServerEntry( partition.getContextEntryAttr(), new LdapDN( partition.getSuffix() ) , registries ) );
- }
+ partition.setContextEntry( partition.getContextEntry() );
partition.init( directoryService );
}
Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/Partition.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/Partition.java?rev=652410&r1=652409&r2=652410&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/Partition.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/Partition.java Wed Apr 30 17:06:41 2008
@@ -40,7 +40,6 @@
import javax.naming.Context;
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
-import javax.naming.directory.Attributes;
/**
@@ -97,14 +96,6 @@
/**
- * Gets the root entry of the partition, the entry for the suffix.
- *
- * @return the entry for the suffix of this Partition.
- */
- Attributes getContextEntryAttr();
-
-
- /**
* Sets the root entry of the partition, the entry for the suffix.
*
* @param contextEntry the entry for the suffix of this Partition.
Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/PartitionNexusProxy.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/PartitionNexusProxy.java?rev=652410&r1=652409&r2=652410&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/PartitionNexusProxy.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/PartitionNexusProxy.java Wed Apr 30 17:06:41 2008
@@ -31,7 +31,6 @@
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
import javax.naming.ServiceUnavailableException;
-import javax.naming.directory.Attributes;
import javax.naming.directory.SearchControls;
import javax.naming.event.EventContext;
import javax.naming.event.NamingListener;
@@ -227,12 +226,6 @@
}
- public Attributes getContextEntryAttr()
- {
- throw new UnsupportedOperationException( "Not supported by PartitionNexusProxy" );
- }
-
-
public void setContextEntry( ServerEntry contextEntry )
{
throw new UnsupportedOperationException( "Not supported by PartitionNexusProxy" );
Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreePartition.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreePartition.java?rev=652410&r1=652409&r2=652410&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreePartition.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreePartition.java Wed Apr 30 17:06:41 2008
@@ -22,7 +22,6 @@
import org.apache.directory.server.core.entry.DefaultServerEntry;
import org.apache.directory.server.core.entry.ServerEntry;
-import org.apache.directory.server.core.entry.ServerEntryUtils;
import org.apache.directory.server.core.entry.ServerSearchResult;
import org.apache.directory.server.core.enumeration.SearchResultEnumeration;
import org.apache.directory.server.core.interceptor.context.AddOperationContext;
@@ -42,12 +41,10 @@
import org.apache.directory.shared.ldap.entry.EntryAttribute;
import org.apache.directory.shared.ldap.exception.LdapContextNotEmptyException;
import org.apache.directory.shared.ldap.exception.LdapNameNotFoundException;
-import org.apache.directory.shared.ldap.message.AttributesImpl;
import org.apache.directory.shared.ldap.name.LdapDN;
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
-import javax.naming.directory.Attributes;
import javax.naming.directory.SearchControls;
import java.util.Collections;
import java.util.HashSet;
@@ -93,9 +90,6 @@
/** The rootDSE context */
protected ServerEntry contextEntry;
- /** The rootDSE context */
- protected Attributes contextEntryAttr;
-
// ------------------------------------------------------------------------
// C O N S T R U C T O R S
@@ -158,24 +152,6 @@
/**
- * Returns root entry for this BTreePartition.
- *
- * @return the root suffix entry for this BTreePartition
- */
- public Attributes getContextEntryAttr()
- {
- if ( contextEntryAttr != null )
- {
- return ( Attributes ) contextEntryAttr.clone();
- }
- else
- {
- return null;
- }
- }
-
-
- /**
* Sets root entry for this BTreePartition.
*
* @param rootEntry the root suffix entry of this BTreePartition
@@ -198,17 +174,6 @@
/**
- * Sets root entry for this BTreePartition.
- *
- * @param rootEntryAttr the root suffix entry of this BTreePartition
- */
- public void setContextEntry( Attributes rootEntryAttr )
- {
- this.contextEntryAttr = ( AttributesImpl ) rootEntryAttr.clone();
- }
-
-
- /**
* Gets the unique identifier for this partition.
*
* @return the unique identifier for this partition
@@ -328,10 +293,7 @@
public ServerEntry lookup( LookupOperationContext opContext ) throws NamingException
{
- ServerEntry entry = ServerEntryUtils.toServerEntry(
- lookup( getEntryId( opContext.getDn().getNormName() ) ),
- opContext.getDn(),
- opContext.getRegistries() );
+ ServerEntry entry = lookup( getEntryId( opContext.getDn().getNormName() ) );
if ( ( opContext.getAttrsId() == null ) || ( opContext.getAttrsId().size() == 0 ) )
{
@@ -381,7 +343,7 @@
public void inspect() throws Exception
{
- PartitionViewer viewer = new PartitionViewer( this );
+ PartitionViewer viewer = new PartitionViewer( this, registries );
viewer.execute();
}
@@ -567,7 +529,7 @@
public abstract String getEntryUpdn( String dn ) throws NamingException;
- public abstract Attributes lookup( Long id ) throws NamingException;
+ public abstract ServerEntry lookup( Long id ) throws NamingException;
public abstract void delete( Long id ) throws NamingException;
@@ -579,7 +541,7 @@
public abstract int getChildCount( Long id ) throws NamingException;
- public abstract Attributes getSuffixEntry() throws NamingException;
+ public abstract ServerEntry getSuffixEntry() throws NamingException;
public abstract void setProperty( String key, String value ) throws NamingException;
@@ -594,7 +556,7 @@
public abstract Iterator<String> getSystemIndices();
- public abstract Attributes getIndices( Long id ) throws NamingException;
+ public abstract ServerEntry getIndices( Long id ) throws NamingException;
/**
Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreeSearchResultEnumeration.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreeSearchResultEnumeration.java?rev=652410&r1=652409&r2=652410&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreeSearchResultEnumeration.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreeSearchResultEnumeration.java Wed Apr 30 17:06:41 2008
@@ -20,18 +20,17 @@
package org.apache.directory.server.core.partition.impl.btree;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.NoSuchElementException;
+import java.util.Set;
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
-import javax.naming.directory.Attribute;
-import javax.naming.directory.Attributes;
import org.apache.directory.server.core.entry.DefaultServerEntry;
import org.apache.directory.server.core.entry.ServerAttribute;
import org.apache.directory.server.core.entry.ServerEntry;
-import org.apache.directory.server.core.entry.ServerEntryUtils;
import org.apache.directory.server.core.entry.ServerSearchResult;
import org.apache.directory.server.core.enumeration.SearchResultEnumeration;
import org.apache.directory.server.schema.registries.Registries;
@@ -110,22 +109,19 @@
public ServerSearchResult next() throws NamingException
{
IndexRecord rec = underlying.next();
- ServerEntry entry;
- String name = partition.getEntryUpdn( (Long)rec.getEntryId() );
- LdapDN dn = new LdapDN( name );
+ ServerEntry entry = rec.getEntry();
- if ( null == rec.getAttributes() )
+ if ( null == entry )
{
- rec.setAttributes( partition.lookup( (Long)rec.getEntryId() ) );
+ entry = partition.lookup( (Long)rec.getEntryId() );
+ rec.setEntry( entry );
+ entry = (ServerEntry)entry.clone();
}
+
+ LdapDN dn = entry.getDn();
- if ( attrIds == null )
+ if ( ( attrIds == null ) || ( attrIdsHasPlus && attrIdsHasStar ) )
{
- entry = ServerEntryUtils.toServerEntry( (Attributes)rec.getAttributes().clone(), dn, registries );
- }
- else if ( attrIdsHasPlus && attrIdsHasStar )
- {
- entry = ServerEntryUtils.toServerEntry( ( Attributes ) rec.getAttributes().clone(), dn, registries );
}
else if ( attrIdsHasPlus )
{
@@ -139,32 +135,27 @@
continue;
}
// there is no attribute by that name in the entry so we continue
- if ( null == rec.getAttributes().get( attrId ) )
+ if ( null == rec.getEntry().get( attrId ) )
{
continue;
}
- ServerAttribute attr = ServerEntryUtils.toServerAttribute( ( Attribute ) rec.getAttributes().get( attrId ).clone(),
- registries.getAttributeTypeRegistry().lookup( attrId ) );
+ ServerAttribute attr = ( ServerAttribute ) rec.getEntry().get( attrId ).clone();
- entry.put( attr );
+ entry.put( attr );
}
// add all operational attributes
- NamingEnumeration<String> list = rec.getAttributes().getIDs();
-
- while ( list.hasMore() )
+ for ( EntryAttribute attribute:rec.getEntry() )
{
- String attrId = list.next();
- AttributeType attrType = registries.getAttributeTypeRegistry().lookup( attrId );
+ AttributeType attrType = ((ServerAttribute)attribute).getAttributeType();
if ( attrType.getUsage() == UsageEnum.USER_APPLICATIONS )
{
continue;
}
- ServerAttribute attr = ServerEntryUtils.toServerAttribute( ( Attribute ) rec.getAttributes().get( attrId ).clone(),
- registries.getAttributeTypeRegistry().lookup( attrId ) );
+ ServerAttribute attr = (ServerAttribute)attribute.clone();
entry.put( attr );
}
}
@@ -180,38 +171,39 @@
continue;
}
// there is no attribute by that name in the entry so we continue
- if ( null == rec.getAttributes().get( attrId ) )
+ if ( null == rec.getEntry().get( attrId ) )
{
continue;
}
// clone attribute to stuff into the new resultant entry
- ServerAttribute attr = ServerEntryUtils.toServerAttribute( ( Attribute ) rec.getAttributes().get( attrId ).clone(),
- registries.getAttributeTypeRegistry().lookup( attrId ) );
+ ServerAttribute attr = ( ServerAttribute ) rec.getEntry().get( attrId ).clone();
entry.put( attr );
}
// add all user attributes
- NamingEnumeration<String> list = rec.getAttributes().getIDs();
-
- while ( list.hasMore() )
+ for ( EntryAttribute attribute:rec.getEntry() )
{
- String attrId = list.next();
- AttributeType attrType = registries.getAttributeTypeRegistry().lookup( attrId );
+ AttributeType attrType = ((ServerAttribute)attribute).getAttributeType();
if ( attrType.getUsage() == UsageEnum.USER_APPLICATIONS )
{
- ServerAttribute attr = ServerEntryUtils.toServerAttribute( ( Attribute ) rec.getAttributes().get( attrId ).clone(),
- registries.getAttributeTypeRegistry().lookup( attrId ) );
+ ServerAttribute attr = ( ServerAttribute ) rec.getEntry().get( attrType ).clone();
entry.put( attr );
}
}
}
else
{
- entry = new DefaultServerEntry( registries, dn );
+ Set<EntryAttribute> entryAttrs = new HashSet<EntryAttribute>();
+
+ for ( EntryAttribute entryAttribute:entry )
+ {
+ entryAttrs.add( entryAttribute );
+ }
+ //entry = new DefaultServerEntry( registries, dn );
- ServerEntry attrs = ServerEntryUtils.toServerEntry( rec.getAttributes(), dn, registries );
+ //ServerEntry attrs = rec.getEntry();
for ( String attrId:attrIds )
{
@@ -220,7 +212,7 @@
break;
}
- EntryAttribute attr = attrs.get( registries.getAttributeTypeRegistry().lookup( attrId ) );
+ EntryAttribute attr = entry.get( registries.getAttributeTypeRegistry().lookup( attrId ) );
// there is no attribute by that name in the entry so we continue
if ( null == attr )
@@ -232,24 +224,32 @@
{
AttributeType atype = descendants.next();
- attr = attrs.get( atype );
+ attr = entry.get( atype );
if ( attr != null )
{
// we may have more than one descendant, like sn and cn
// for name, so add all of them
- entry.put( (ServerAttribute)attr.clone() );
+ //entry.put( (ServerAttribute)attr.clone() );
+ entryAttrs.remove( attr );
}
}
}
else
{
// clone attribute to stuff into the new resultant entry
- entry.put( (ServerAttribute)attr.clone() );
+ //entry.put( (ServerAttribute)attr.clone() );
+ entryAttrs.remove( attr );
}
}
+
+ for ( EntryAttribute entryAttribute:entryAttrs )
+ {
+ entry.remove( entryAttribute );
+ }
}
+
BTreeSearchResult result = new BTreeSearchResult( (Long)rec.getEntryId(), dn, null, entry );
result.setRelative( false );
return result;