Return-Path: Delivered-To: apmail-directory-commits-archive@www.apache.org Received: (qmail 11580 invoked from network); 10 May 2008 16:31:26 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 10 May 2008 16:31:26 -0000 Received: (qmail 96643 invoked by uid 500); 10 May 2008 16:31:28 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 96602 invoked by uid 500); 10 May 2008 16:31:28 -0000 Mailing-List: contact commits-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@directory.apache.org Delivered-To: mailing list commits@directory.apache.org Received: (qmail 96591 invoked by uid 99); 10 May 2008 16:31:28 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 10 May 2008 09:31:28 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 10 May 2008 16:30:37 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 0216A2388A5C; Sat, 10 May 2008 09:30:57 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r655126 [4/9] - in /directory/sandbox/akarasulu/bigbang: apacheds/ apacheds/apacheds-jdbm/ apacheds/apacheds-jdbm/src/ apacheds/apacheds-jdbm/src/etc/ apacheds/apacheds-jdbm/src/examples/ apacheds/apacheds-jdbm/src/main/ apacheds/apacheds-j... Date: Sat, 10 May 2008 16:30:51 -0000 To: commits@directory.apache.org From: akarasulu@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080510163057.0216A2388A5C@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Modified: directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/partition/PartitionNexusProxy.java URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/partition/PartitionNexusProxy.java?rev=655126&r1=655125&r2=655126&view=diff ============================================================================== --- directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/partition/PartitionNexusProxy.java (original) +++ directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/partition/PartitionNexusProxy.java Sat May 10 09:30:45 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; @@ -41,11 +40,14 @@ import org.apache.directory.server.core.authn.AuthenticationInterceptor; import org.apache.directory.server.core.authz.AciAuthorizationInterceptor; import org.apache.directory.server.core.authz.DefaultAuthorizationInterceptor; +import org.apache.directory.server.core.changelog.ChangeLogInterceptor; +import org.apache.directory.server.core.collective.CollectiveAttributeInterceptor; import org.apache.directory.server.core.entry.ServerEntry; import org.apache.directory.server.core.entry.ServerSearchResult; import org.apache.directory.server.core.enumeration.SearchResultFilter; import org.apache.directory.server.core.enumeration.SearchResultFilteringEnumeration; import org.apache.directory.server.core.event.EventInterceptor; +import org.apache.directory.server.core.exception.ExceptionInterceptor; import org.apache.directory.server.core.interceptor.InterceptorChain; import org.apache.directory.server.core.interceptor.context.AddContextPartitionOperationContext; import org.apache.directory.server.core.interceptor.context.AddOperationContext; @@ -80,7 +82,6 @@ import org.apache.directory.shared.ldap.filter.ExprNode; import org.apache.directory.shared.ldap.name.LdapDN; - /** * A decorator that wraps other {@link PartitionNexus} to enable * {@link InterceptorChain} and {@link InvocationStack} support. @@ -107,6 +108,8 @@ * safe to use set of bypass instructions to lookup raw entries excluding operational attributes */ public static final Collection LOOKUP_EXCLUDING_OPR_ATTRS_BYPASS; + + public static final Collection GET_ROOT_DSE_BYPASS; /** * Bypass String to use when ALL interceptors should be skipped @@ -187,6 +190,24 @@ c.add( EventInterceptor.class.getName() ); c.add( TriggerInterceptor.class.getName() ); LOOKUP_EXCLUDING_OPR_ATTRS_BYPASS = Collections.unmodifiableCollection( c ); + + + c = new HashSet(); + c.add( NormalizationInterceptor.class.getName() ); + //c.add( AuthenticationInterceptor.class.getName() ); + c.add( ChangeLogInterceptor.class.getName() ); + c.add( ReferralInterceptor.class.getName() ); + c.add( AciAuthorizationInterceptor.class.getName() ); + c.add( DefaultAuthorizationInterceptor.class.getName() ); + c.add( ExceptionInterceptor.class.getName() ); + c.add( OperationalAttributeInterceptor.class.getName() ); + c.add( SchemaInterceptor.class.getName() ); + c.add( SubentryInterceptor.class.getName() ); + c.add( CollectiveAttributeInterceptor.class.getName() ); + c.add( EventInterceptor.class.getName() ); + c.add( TriggerInterceptor.class.getName() ); + GET_ROOT_DSE_BYPASS = Collections.unmodifiableCollection( c ); + } @@ -227,12 +248,6 @@ } - public Attributes getContextEntryAttr() - { - throw new UnsupportedOperationException( "Not supported by PartitionNexusProxy" ); - } - - public void setContextEntry( ServerEntry contextEntry ) { throw new UnsupportedOperationException( "Not supported by PartitionNexusProxy" ); @@ -323,17 +338,15 @@ public LdapDN getMatchedName( GetMatchedNameOperationContext opContext, Collection bypass ) throws NamingException { ensureStarted(); - InvocationStack stack = InvocationStack.getInstance(); - Object[] args = new Object[] {opContext}; - stack.push( new Invocation( this, caller, "getMatchedName", args, bypass ) ); - + opContext.push( new Invocation( this, caller, "getMatchedName", bypass ) ); + try { return service.getInterceptorChain().getMatchedName( opContext ); } finally { - stack.pop(); + opContext.pop(); } } @@ -347,16 +360,15 @@ public LdapDN getSuffix( GetSuffixOperationContext opContext, Collection bypass ) throws NamingException { ensureStarted(); - InvocationStack stack = InvocationStack.getInstance(); - Object[] args = new Object[] {opContext}; - stack.push( new Invocation( this, caller, "getSuffixDn", args, bypass ) ); + opContext.push( new Invocation( this, caller, "getSuffixDn", bypass ) ); + try { return service.getInterceptorChain().getSuffix( opContext ); } finally { - stack.pop(); + opContext.pop(); } } @@ -370,16 +382,15 @@ public Iterator listSuffixes( ListSuffixOperationContext opContext, Collection bypass ) throws NamingException { ensureStarted(); - InvocationStack stack = InvocationStack.getInstance(); - Object[] args = new Object[] {}; - stack.push( new Invocation( this, caller, "listSuffixes", args, bypass ) ); + opContext.push( new Invocation( this, caller, "listSuffices", bypass ) ); + try { return service.getInterceptorChain().listSuffixes( opContext ); } finally { - stack.pop(); + opContext.pop(); } } @@ -393,16 +404,15 @@ public boolean compare( CompareOperationContext opContext, Collection bypass ) throws NamingException { ensureStarted(); - InvocationStack stack = InvocationStack.getInstance(); - stack.push( new Invocation( this, caller, "compare", new Object[] - {opContext}, bypass ) ); + opContext.push( new Invocation( this, caller, "compare", bypass ) ); + try { return service.getInterceptorChain().compare( opContext ); } finally { - stack.pop(); + opContext.pop(); } } @@ -416,16 +426,15 @@ public void delete( DeleteOperationContext opContext, Collection bypass ) throws NamingException { ensureStarted(); - InvocationStack stack = InvocationStack.getInstance(); - stack.push( new Invocation( this, caller, "delete", new Object[] - {opContext}, bypass ) ); + opContext.push( new Invocation( this, caller, "delete", bypass ) ); + try { service.getInterceptorChain().delete( opContext ); } finally { - stack.pop(); + opContext.pop(); } } @@ -439,16 +448,15 @@ public void add( AddOperationContext opContext, Collection bypass ) throws NamingException { ensureStarted(); - InvocationStack stack = InvocationStack.getInstance(); - stack.push( new Invocation( this, caller, "add", new Object[] - {opContext}, bypass ) ); + opContext.push( new Invocation( this, caller, "add", bypass ) ); + try { service.getInterceptorChain().add( opContext ); } finally { - stack.pop(); + opContext.pop(); } } @@ -462,17 +470,15 @@ public void modify( ModifyOperationContext opContext, Collection bypass ) throws NamingException { ensureStarted(); - InvocationStack stack = InvocationStack.getInstance(); - stack.push( new Invocation( this, caller, "modify", new Object[] - {opContext}, bypass ) ); - + opContext.push( new Invocation( this, caller, "modify", bypass ) ); + try { service.getInterceptorChain().modify( opContext ); } finally { - stack.pop(); + opContext.pop(); } } @@ -487,16 +493,15 @@ throws NamingException { ensureStarted(); - InvocationStack stack = InvocationStack.getInstance(); - stack.push( new Invocation( this, caller, "list", new Object[] - {opContext}, bypass ) ); + opContext.push( new Invocation( this, caller, "list", bypass ) ); + try { return service.getInterceptorChain().list( opContext ); } finally { - stack.pop(); + opContext.pop(); } } @@ -557,16 +562,15 @@ throws NamingException { ensureStarted(); - InvocationStack stack = InvocationStack.getInstance(); - stack.push( new Invocation( this, caller, "search", new Object[] - {opContext}, bypass ) ); + opContext.push( new Invocation( this, caller, "search", bypass ) ); + try { return service.getInterceptorChain().search( opContext ); } finally { - stack.pop(); + opContext.pop(); } } @@ -611,16 +615,15 @@ public ServerEntry lookup( LookupOperationContext opContext, Collection bypass ) throws NamingException { ensureStarted(); - InvocationStack stack = InvocationStack.getInstance(); - stack.push( new Invocation( this, caller, "lookup", new Object[] - {opContext}, bypass ) ); + opContext.push( new Invocation( this, caller, "lookup", bypass ) ); + try { return service.getInterceptorChain().lookup( opContext ); } finally { - stack.pop(); + opContext.pop(); } } @@ -633,16 +636,15 @@ public boolean hasEntry( EntryOperationContext opContext, Collection bypass ) throws NamingException { ensureStarted(); - InvocationStack stack = InvocationStack.getInstance(); - stack.push( new Invocation( this, caller, "hasEntry", new Object[] - {opContext}, bypass ) ); + opContext.push( new Invocation( this, caller, "hasEntry", bypass ) ); + try { return service.getInterceptorChain().hasEntry( opContext ); } finally { - stack.pop(); + opContext.pop(); } } @@ -656,17 +658,15 @@ public void rename( RenameOperationContext opContext, Collection bypass ) throws NamingException { ensureStarted(); - InvocationStack stack = InvocationStack.getInstance(); - Object[] args = new Object[] - {opContext}; - stack.push( new Invocation( this, caller, "rename", args, bypass ) ); + opContext.push( new Invocation( this, caller, "rename", bypass ) ); + try { service.getInterceptorChain().rename( opContext ); } finally { - stack.pop(); + opContext.pop(); } } @@ -680,16 +680,15 @@ public void move( MoveOperationContext opContext, Collection bypass ) throws NamingException { ensureStarted(); - InvocationStack stack = InvocationStack.getInstance(); - stack.push( new Invocation( this, caller, "move", new Object[] - {opContext}, bypass ) ); + opContext.push( new Invocation( this, caller, "move", bypass ) ); + try { service.getInterceptorChain().move( opContext ); } finally { - stack.pop(); + opContext.pop(); } } @@ -704,17 +703,15 @@ throws NamingException { ensureStarted(); - InvocationStack stack = InvocationStack.getInstance(); - Object[] args = new Object[] - {opContext}; - stack.push( new Invocation( this, caller, "moveAndRename", args, bypass ) ); + opContext.push( new Invocation( this, caller, "moveAndRename", bypass ) ); + try { service.getInterceptorChain().moveAndRename( opContext ); } finally { - stack.pop(); + opContext.pop(); } } @@ -729,36 +726,31 @@ throws NamingException { ensureStarted(); - InvocationStack stack = InvocationStack.getInstance(); - Object[] args = new Object[] - {opContext}; - - stack.push( new Invocation( this, caller, "bind", args, bypass ) ); - + opContext.push( new Invocation( this, caller, "bind", bypass ) ); + try { service.getInterceptorChain().bind( opContext ); } finally { - stack.pop(); + opContext.pop(); } } + public void unbind( UnbindOperationContext opContext, Collection bypass ) throws NamingException { ensureStarted(); - InvocationStack stack = InvocationStack.getInstance(); - Object[] args = new Object[] - {opContext}; - stack.push( new Invocation( this, caller, "unbind", args, bypass ) ); + opContext.push( new Invocation( this, caller, "unbind", bypass ) ); + try { service.getInterceptorChain().unbind( opContext ); } finally { - stack.pop(); + opContext.pop(); } } @@ -783,14 +775,14 @@ { if ( ROOT_DSE_ALL == null ) { - ROOT_DSE_ALL = getRootDSE( null, null ); + ROOT_DSE_ALL = getRootDSE( opContext, null ); } } return ROOT_DSE_ALL; } - return getRootDSE( null, null ); + return getRootDSE( opContext, null ); } @@ -798,15 +790,15 @@ throws NamingException { ensureStarted(); - InvocationStack stack = InvocationStack.getInstance(); - stack.push( new Invocation( this, caller, "getRootDSE", null, bypass ) ); + opContext.push( new Invocation( this, caller, "getRootDSE", GET_ROOT_DSE_BYPASS ) ); + try { return service.getInterceptorChain().getRootDSE( opContext ); } finally { - stack.pop(); + opContext.pop(); } } @@ -821,16 +813,15 @@ throws NamingException { ensureStarted(); - InvocationStack stack = InvocationStack.getInstance(); - stack.push( new Invocation( this, caller, "addContextPartition", new Object[] - {opContext}, bypass ) ); + opContext.push( new Invocation( this, caller, "addContextPartition", bypass ) ); + try { service.getInterceptorChain().addContextPartition( opContext ); } finally { - stack.pop(); + opContext.pop(); } } @@ -845,16 +836,15 @@ throws NamingException { ensureStarted(); - InvocationStack stack = InvocationStack.getInstance(); - stack.push( new Invocation( this, caller, "removeContextPartition", new Object[] - {opContext}, bypass ) ); + opContext.push( new Invocation( this, caller, "removeContextPartition", bypass ) ); + try { service.getInterceptorChain().removeContextPartition( opContext ); } finally { - stack.pop(); + opContext.pop(); } } @@ -873,6 +863,13 @@ service.getPartitionNexus().registerSupportedExtensions( extensionOids ); } + + public void registerSupportedSaslMechanisms( Set supportedSaslMechanisms ) throws NamingException + { + service.getPartitionNexus().registerSupportedSaslMechanisms( supportedSaslMechanisms ); + } + + // ----------------------------------------------------------------------- // EventContext and EventDirContext notification methods // ----------------------------------------------------------------------- Modified: directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreePartition.java URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreePartition.java?rev=655126&r1=655125&r2=655126&view=diff ============================================================================== --- directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreePartition.java (original) +++ directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreePartition.java Sat May 10 09:30:45 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; @@ -45,12 +44,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; @@ -96,9 +93,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 @@ -161,24 +155,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 @@ -201,17 +177,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 @@ -331,10 +296,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 ) ) { @@ -384,7 +346,7 @@ public void inspect() throws Exception { - PartitionViewer viewer = new PartitionViewer( this ); + PartitionViewer viewer = new PartitionViewer( this, registries ); viewer.execute(); } @@ -570,7 +532,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; @@ -582,7 +544,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; @@ -597,7 +559,7 @@ public abstract Iterator getSystemIndices(); - public abstract Attributes getIndices( Long id ) throws NamingException; + public abstract ServerEntry getIndices( Long id ) throws NamingException; /** Modified: directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreeSearchResultEnumeration.java URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreeSearchResultEnumeration.java?rev=655126&r1=655125&r2=655126&view=diff ============================================================================== --- directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreeSearchResultEnumeration.java (original) +++ directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreeSearchResultEnumeration.java Sat May 10 09:30:45 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; @@ -112,16 +111,20 @@ public ServerSearchResult next() throws NamingException { IndexEntry rec = underlying.next(); - ServerEntry entry; - String name = partition.getEntryUpdn( (Long)rec.getId() ); + ServerEntry entry = rec.getEntry(); + String name = partition.getEntryUpdn( ( Long )rec.getId() ); LdapDN dn = new LdapDN( name ); - if ( null == rec.getObject() ) + if ( null == entry ) { - rec.setObject( partition.lookup( (Long)rec.getId() ) ); + rec.setObject( partition.lookup( ( Long ) rec.getId() ) ); + rec.setEntry( entry ); + entry = ( ServerEntry ) entry.clone(); } + + LdapDN dn = entry.getDn(); - if ( attrIds == null ) + if ( ( attrIds == null ) || ( attrIdsHasPlus && attrIdsHasStar ) ) { entry = ServerEntryUtils.toServerEntry( ( Attributes ) rec.getObject().clone(), dn, registries ); } @@ -146,26 +149,21 @@ continue; } - ServerAttribute attr = ServerEntryUtils.toServerAttribute( ( Attribute ) rec.getObject().get( attrId ).clone(), - registries.getAttributeTypeRegistry().lookup( attrId ) ); - entry.put( attr ); + ServerAttribute attr = ( ServerAttribute ) rec.getObject().get( attrId ).clone(); + entry.put( attr ); } // add all operational attributes - NamingEnumeration list = rec.getObject().getIDs(); - - while ( list.hasMore() ) + for ( EntryAttribute attribute:rec.getObject() ) { - 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.getObject().get( attrId ).clone(), - registries.getAttributeTypeRegistry().lookup( attrId ) ); + ServerAttribute attr = ( ServerAttribute ) attribute.clone(); entry.put( attr ); } } @@ -187,31 +185,31 @@ } // clone attribute to stuff into the new resultant entry - ServerAttribute attr = ServerEntryUtils.toServerAttribute( ( Attribute ) rec.getObject().get( attrId ).clone(), - registries.getAttributeTypeRegistry().lookup( attrId ) ); + ServerAttribute attr = ( ServerAttribute ) rec.getObject().get( attrId ).clone(); entry.put( attr ); } // add all user attributes - NamingEnumeration list = rec.getObject().getIDs(); - - while ( list.hasMore() ) + for ( EntryAttribute attribute:rec.getObject() ) { - 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.getObject().get( attrId ).clone(), - registries.getAttributeTypeRegistry().lookup( attrId ) ); + ServerAttribute attr = ( ServerAttribute ) rec.getEntry().get( attrType ).clone(); entry.put( attr ); } } } else { - entry = new DefaultServerEntry( registries, dn ); - ServerEntry attrs = ServerEntryUtils.toServerEntry( rec.getObject(), dn, registries ); + Set entryAttrs = new HashSet(); + + for ( EntryAttribute entryAttribute:entry ) + { + entryAttrs.add( entryAttribute ); + } + //entry = new DefaultServerEntry( registries, dn ); for ( String attrId:attrIds ) { @@ -220,7 +218,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,22 +230,29 @@ { 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.getId(), dn, null, entry ); Modified: directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/gui/AddEntryDialog.java URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/gui/AddEntryDialog.java?rev=655126&r1=655125&r2=655126&view=diff ============================================================================== --- directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/gui/AddEntryDialog.java (original) +++ directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/gui/AddEntryDialog.java Sat May 10 09:30:45 2008 @@ -26,7 +26,6 @@ import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; -import javax.naming.directory.Attributes; import javax.swing.DefaultCellEditor; import javax.swing.JButton; import javax.swing.JComboBox; @@ -40,8 +39,10 @@ import javax.swing.JTable; import javax.swing.JTextField; +import org.apache.directory.server.core.entry.DefaultServerEntry; +import org.apache.directory.server.core.entry.ServerEntry; +import org.apache.directory.server.schema.registries.Registries; import org.apache.directory.shared.ldap.constants.SchemaConstants; -import org.apache.directory.shared.ldap.message.AttributesImpl; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -72,7 +73,7 @@ private JButton m_cancelBut = new JButton(); private JPopupMenu m_popup; - private Attributes m_childEntry = new AttributesImpl(); + private ServerEntry childEntry = null; /** @@ -81,10 +82,11 @@ * @param parent the parent frame * @param modal whether or not to go modal on the dialog */ - public AddEntryDialog(Frame parent, boolean modal) + public AddEntryDialog(Frame parent, boolean modal, Registries registries ) { super( parent, modal ); - m_childEntry.put( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC ); + childEntry = new DefaultServerEntry( registries ); + childEntry.put( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC ); initGUI(); } @@ -168,7 +170,7 @@ javax.swing.border.TitledBorder.LEADING, javax.swing.border.TitledBorder.TOP, new java.awt.Font( "SansSerif", 0, 14 ), new java.awt.Color( 60, 60, 60 ) ) ); - m_attrTbl.setModel( new AttributesTableModel( m_childEntry, null, null, true ) ); + m_attrTbl.setModel( new AttributesTableModel( childEntry, null, null, true ) ); // // Build the table's popup menu @@ -279,9 +281,9 @@ } - public Attributes getChildEntry() + public ServerEntry getChildEntry() { - return m_childEntry; + return childEntry; } Modified: directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/gui/AttributesTableModel.java URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/gui/AttributesTableModel.java?rev=655126&r1=655125&r2=655126&view=diff ============================================================================== --- directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/gui/AttributesTableModel.java (original) +++ directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/gui/AttributesTableModel.java Sat May 10 09:30:45 2008 @@ -22,12 +22,12 @@ import java.util.ArrayList; -import javax.naming.NamingEnumeration; -import javax.naming.NamingException; -import javax.naming.directory.Attribute; -import javax.naming.directory.Attributes; import javax.swing.table.AbstractTableModel; +import org.apache.directory.server.core.entry.ServerEntry; +import org.apache.directory.shared.ldap.entry.EntryAttribute; +import org.apache.directory.shared.ldap.entry.Value; + /** * A general purpose table model for entry attributes. @@ -49,7 +49,7 @@ private final transient ArrayList valList; /** the attributes for the entry */ - private final Attributes entry; + private final ServerEntry entry; /** the unique id of the entry */ private final Long id; /** the distinguished name of the entry */ @@ -66,42 +66,32 @@ * @param dn the distinguished name of the entry * @param isMutable whether or not the model can be changed */ - public AttributesTableModel(Attributes entry, Long id, String dn, boolean isMutable) + public AttributesTableModel( ServerEntry entry, Long id, String dn, boolean isMutable) { this.dn = dn; this.id = id; this.entry = entry; this.isMutable = isMutable; - NamingEnumeration list = entry.getIDs(); int rowCount = 0; - while ( list.hasMoreElements() ) + for ( EntryAttribute attribute:entry ) { - String attrId = list.nextElement(); + String attrId = attribute.getId(); rowCount = rowCount + entry.get( attrId ).size(); } keyList = new ArrayList( rowCount ); valList = new ArrayList( rowCount ); - list = this.entry.getIDs(); - while ( list.hasMoreElements() ) + for ( EntryAttribute attribute:entry ) { - String l_key = ( String ) list.nextElement(); - Attribute l_attr = this.entry.get( l_key ); + String key = attribute.getId(); - for ( int ii = 0; ii < l_attr.size(); ii++ ) + for ( Value value:attribute ) { - try - { - keyList.add( l_attr.getID() ); - valList.add( l_attr.get( ii ) ); - } - catch ( NamingException e ) - { - e.printStackTrace(); - } + keyList.add( attribute.getId() ); + valList.add( value.get() ); } } } Modified: directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/gui/EntryNode.java URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/gui/EntryNode.java?rev=655126&r1=655125&r2=655126&view=diff ============================================================================== --- directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/gui/EntryNode.java (original) +++ directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/gui/EntryNode.java Sat May 10 09:30:45 2008 @@ -29,9 +29,9 @@ import javax.naming.NamingEnumeration; import javax.naming.NamingException; -import javax.naming.directory.Attributes; import javax.swing.tree.TreeNode; +import org.apache.directory.server.core.entry.ServerEntry; import org.apache.directory.server.core.partition.impl.btree.BTreePartition; import org.apache.directory.server.xdbm.ForwardIndexEntry; import org.apache.directory.server.xdbm.IndexEntry; @@ -50,18 +50,18 @@ { private final BTreePartition partition; private final EntryNode parent; - private final Attributes entry; + private final ServerEntry entry; private final ArrayList children; private final Long id; - public EntryNode(Long id, EntryNode parent, BTreePartition partition, Attributes entry, Map map) + public EntryNode(Long id, EntryNode parent, BTreePartition partition, ServerEntry entry, Map map) { this( id, parent, partition, entry, map, null, null ); } - public EntryNode( Long id, EntryNode parent, BTreePartition db, Attributes entry, Map map, + public EntryNode( Long id, EntryNode parent, BTreePartition db, ServerEntry entry, Map map, ExprNode exprNode, SearchEngine engine ) { this.partition = db; @@ -105,9 +105,8 @@ { if ( engine.evaluate( exprNode, (Long)rec.getId() ) ) { - Attributes newEntry = db.lookup( (Long)rec.getId() ); - EntryNode child = new EntryNode( (Long)rec.getId(), this, db, newEntry, map, exprNode, - engine ); + ServerEntry newEntry = db.lookup( (Long)rec.getEntryId() ); + EntryNode child = new EntryNode( (Long)rec.getEntryId(), this, db, newEntry, map, exprNode, engine ); children.add( child ); } else @@ -117,15 +116,15 @@ } else { - Attributes newEntry = db.lookup( (Long)rec.getId() ); - EntryNode child = new EntryNode( (Long)rec.getId(), this, db, newEntry, map, exprNode, engine ); + ServerEntry newEntry = db.lookup( (Long)rec.getEntryId() ); + EntryNode child = new EntryNode( (Long)rec.getEntryId(), this, db, newEntry, map, exprNode, engine ); children.add( child ); } } else { - Attributes newEntry = db.lookup( (Long)rec.getId() ); - EntryNode child = new EntryNode( (Long)rec.getId(), this, db, newEntry, map ); + ServerEntry newEntry = db.lookup( (Long)rec.getEntryId() ); + EntryNode child = new EntryNode( (Long)rec.getEntryId(), this, db, newEntry, map ); children.add( child ); } } @@ -211,7 +210,7 @@ } - public Attributes getLdapEntry() + public ServerEntry getLdapEntry() { return entry; } Modified: directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/gui/PartitionFrame.java URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/gui/PartitionFrame.java?rev=655126&r1=655125&r2=655126&view=diff ============================================================================== --- directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/gui/PartitionFrame.java (original) +++ directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/gui/PartitionFrame.java Sat May 10 09:30:45 2008 @@ -36,7 +36,6 @@ import javax.naming.NamingEnumeration; import javax.naming.NamingException; -import javax.naming.directory.Attributes; import javax.naming.directory.SearchControls; import javax.swing.JFileChooser; import javax.swing.JFrame; @@ -67,6 +66,7 @@ import org.apache.directory.server.core.partition.impl.btree.BTreePartition; import org.apache.directory.server.xdbm.Index; import org.apache.directory.server.xdbm.IndexEntry; +import org.apache.directory.server.schema.registries.Registries; import org.apache.directory.shared.ldap.filter.ExprNode; import org.apache.directory.shared.ldap.filter.FilterParser; @@ -117,6 +117,9 @@ private Map nodes; private EntryNode root; + + /** A handle on the global registries */ + private Registries registries; /** * Creates new form JFrame @@ -124,9 +127,10 @@ * @param db the partition to view * @throws NamingException if there are problems accessing the partition */ - public PartitionFrame( BTreePartition db ) throws NamingException + public PartitionFrame( BTreePartition db, Registries registries ) throws NamingException { partition = db; + this.registries = registries; initialize(); buildIndicesMenu( partition ); @@ -377,7 +381,7 @@ return; } - AddEntryDialog dialog = new AddEntryDialog( this, false ); + AddEntryDialog dialog = new AddEntryDialog( this, false, registries ); dialog.setParentDn( parentDn ); centerOnScreen( dialog ); @@ -451,14 +455,14 @@ { LdifEntry entry = ( LdifEntry ) list.next(); String updn = entry.getDn(); - Attributes attrs = entry.getAttributes(); LdapDN ndn = new LdapDN( StringTools.deepTrimToLower( updn ) ); + ServerEntry attrs = ServerEntryUtils.toServerEntry( entry.getAttributes(), ndn, null ); + if ( null == partition.getEntryId( ndn.toString() ) ) { - ServerEntry serverEntry = ServerEntryUtils.toServerEntry( attrs, ndn, null ); - partition.add( new AddOperationContext( null, ndn, serverEntry ) ); + partition.add( new AddOperationContext( null, attrs ) ); load(); } } @@ -852,7 +856,7 @@ } - void displayEntry( Long id, Attributes entry ) throws Exception + void displayEntry( Long id, ServerEntry entry ) throws Exception { String dn = partition.getEntryUpdn( id ); AttributesTableModel model = new AttributesTableModel( entry, id, dn, false ); @@ -870,7 +874,7 @@ // boolean doFiltered = false; nodes = new HashMap(); - Attributes suffix = partition.getSuffixEntry(); + ServerEntry suffix = partition.getSuffixEntry(); Long id = partition.getEntryId( partition.getSuffixDn().toString() ); root = new EntryNode( id, null, partition, suffix, nodes ); Modified: directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/gui/PartitionViewer.java URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/gui/PartitionViewer.java?rev=655126&r1=655125&r2=655126&view=diff ============================================================================== --- directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/gui/PartitionViewer.java (original) +++ directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/gui/PartitionViewer.java Sat May 10 09:30:45 2008 @@ -24,6 +24,7 @@ import java.awt.Toolkit; import org.apache.directory.server.core.partition.impl.btree.BTreePartition; +import org.apache.directory.server.schema.registries.Registries; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -42,11 +43,15 @@ /** A handle on the atomic partition */ private BTreePartition partition; + + /** A handle on the global registries */ + private Registries registries; - public PartitionViewer( BTreePartition db ) + public PartitionViewer( BTreePartition db, Registries registries ) { this.partition = db; + this.registries = registries; } @@ -59,7 +64,7 @@ PartitionFrame frame = null; try { - frame = new PartitionFrame( PartitionViewer.this.partition ); + frame = new PartitionFrame( PartitionViewer.this.partition, registries ); } catch ( NamingException e ) { Modified: directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmPartition.java URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmPartition.java?rev=655126&r1=655125&r2=655126&view=diff ============================================================================== --- directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmPartition.java (original) +++ directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmPartition.java Sat May 10 09:30:45 2008 @@ -21,7 +21,7 @@ import org.apache.directory.server.core.DirectoryService; -import org.apache.directory.server.core.entry.ServerEntryUtils; +import org.apache.directory.server.core.entry.ServerEntry; import org.apache.directory.server.core.interceptor.context.AddOperationContext; import org.apache.directory.server.core.interceptor.context.BindOperationContext; import org.apache.directory.server.core.interceptor.context.ModifyOperationContext; @@ -41,7 +41,6 @@ import javax.naming.NamingEnumeration; import javax.naming.NamingException; -import javax.naming.directory.Attributes; import java.io.File; import java.util.HashSet; @@ -236,7 +235,7 @@ store.setEnableOptimizer( isOptimizerEnabled() ); } - store.init( registries.getOidRegistry(), registries.getAttributeTypeRegistry() ); + store.init( registries ); } @@ -463,11 +462,11 @@ public final void add( AddOperationContext addContext ) throws NamingException { - store.add( addContext.getDn(), ServerEntryUtils.toAttributesImpl( addContext.getEntry() ) ); + store.add( addContext.getDn(), addContext.getEntry() ); } - public final Attributes lookup( Long id ) throws NamingException + public final ServerEntry lookup( Long id ) throws NamingException { return store.lookup( id ); } @@ -502,7 +501,7 @@ } - public final Attributes getSuffixEntry() throws NamingException + public final ServerEntry getSuffixEntry() throws NamingException { return store.getSuffixEntry(); } @@ -520,7 +519,7 @@ } - public final Attributes getIndices( Long id ) throws NamingException + public final ServerEntry getIndices( Long id ) throws NamingException { return store.getIndices( id ); } @@ -539,8 +538,10 @@ public final void moveAndRename( MoveAndRenameOperationContext moveAndRenameContext ) throws NamingException { - store.move( moveAndRenameContext.getDn(), moveAndRenameContext.getParent(), - moveAndRenameContext.getNewRdn(), moveAndRenameContext.getDelOldDn() ); + store.move( moveAndRenameContext.getDn(), + moveAndRenameContext.getParent(), + moveAndRenameContext.getNewRdn(), + moveAndRenameContext.getDelOldDn() ); } Modified: directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/referral/ReferralInterceptor.java URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/referral/ReferralInterceptor.java?rev=655126&r1=655125&r2=655126&view=diff ============================================================================== --- directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/referral/ReferralInterceptor.java (original) +++ directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/referral/ReferralInterceptor.java Sat May 10 09:30:45 2008 @@ -73,6 +73,7 @@ import org.apache.directory.shared.ldap.entry.EntryAttribute; import org.apache.directory.shared.ldap.entry.Modification; import org.apache.directory.shared.ldap.entry.Value; +import org.apache.directory.shared.ldap.entry.client.ClientStringValue; import org.apache.directory.shared.ldap.exception.LdapNamingException; import org.apache.directory.shared.ldap.exception.LdapReferralException; import org.apache.directory.shared.ldap.filter.EqualityNode; @@ -112,17 +113,16 @@ private ReferralLut lut = new ReferralLut(); private PartitionNexus nexus; - + /** The attributeType registry */ private AttributeTypeRegistry atRegistry; - + /** Thre global registries */ private Registries registries; - + /** The OID registry */ private OidRegistry oidRegistry; - static { /* @@ -135,11 +135,11 @@ c.add( ReferralInterceptor.class.getName() ); c.add( AciAuthorizationInterceptor.class.getName() ); c.add( DefaultAuthorizationInterceptor.class.getName() ); -// c.add( ExceptionInterceptor.class.getName() ); + // c.add( ExceptionInterceptor.class.getName() ); c.add( OperationalAttributeInterceptor.class.getName() ); c.add( SchemaInterceptor.class.getName() ); c.add( SubentryInterceptor.class.getName() ); -// c.add( CollectiveAttributeInterceptor.class.getName() ); + // c.add( CollectiveAttributeInterceptor.class.getName() ); c.add( EventInterceptor.class.getName() ); c.add( TriggerInterceptor.class.getName() ); SEARCH_BYPASS = Collections.unmodifiableCollection( c ); @@ -149,21 +149,21 @@ static boolean isReferral( ServerEntry entry ) throws NamingException { EntryAttribute oc = entry.get( SchemaConstants.OBJECT_CLASS_AT ); - + if ( oc == null ) { LOG.warn( "could not find objectClass attribute in entry: " + entry ); return false; } - + if ( oc.contains( SchemaConstants.REFERRAL_OC ) ) { //We have a referral ObjectClass, let's check that the ref is // valid, accordingly to the RFC - + // Get the 'ref' attributeType EntryAttribute refAttr = entry.get( SchemaConstants.REF_AT ); - + if ( refAttr == null ) { // very unlikely, as we have already checked the entry in SchemaInterceptor @@ -171,24 +171,24 @@ LOG.error( message ); throw new NamingException( message ); } - - for ( Value value:refAttr ) + + for ( Value value : refAttr ) { - ServerStringValue ref = (ServerStringValue)value; - + ServerStringValue ref = ( ServerStringValue ) value; + String refVal = ref.get(); - + try { LdapURL ldapUrl = new LdapURL( refVal ); - + // We have a LDAP URL, we have to check that : // - we don't have scope specifier // - we don't have filters // - we don't have attribute description list // - we don't have extensions // - the DN is not empty - + if ( ldapUrl.getScope() != SearchControls.OBJECT_SCOPE ) { // This is the default value if we don't have any scope @@ -198,37 +198,37 @@ LOG.error( message ); throw new NamingException( message ); } - + if ( !StringTools.isEmpty( ldapUrl.getFilter() ) ) { String message = "An LDAPURL should not contains filters"; LOG.error( message ); throw new NamingException( message ); } - + if ( ( ldapUrl.getAttributes() != null ) && ( ldapUrl.getAttributes().size() != 0 ) ) { String message = "An LDAPURL should not contains any description attribute list"; LOG.error( message ); throw new NamingException( message ); } - + if ( ( ldapUrl.getExtensions() != null ) && ( ldapUrl.getExtensions().size() != 0 ) ) { String message = "An LDAPURL should not contains any extension"; LOG.error( message ); throw new NamingException( message ); } - + if ( ( ldapUrl.getCriticalExtensions() != null ) && ( ldapUrl.getCriticalExtensions().size() != 0 ) ) { String message = "An LDAPURL should not contains any critical extension"; LOG.error( message ); throw new NamingException( message ); } - + LdapDN dn = ldapUrl.getDn(); - + if ( ( dn == null ) || dn.isEmpty() ) { String message = "An LDAPURL should contains a non-empty DN"; @@ -242,10 +242,10 @@ // we will just ignore this LdapURL. } } - + return true; } - + return false; } @@ -258,12 +258,12 @@ oidRegistry = registries.getOidRegistry(); Iterator suffixes = nexus.listSuffixes( null ); - + while ( suffixes.hasNext() ) { LdapDN suffix = new LdapDN( suffixes.next() ); - addReferrals( nexus.search( new SearchOperationContext( - registries, suffix, AliasDerefMode.DEREF_ALWAYS, getReferralFilter(), getControls() ) ), suffix ); + addReferrals( nexus.search( new SearchOperationContext( registries, suffix, AliasDerefMode.DEREF_ALWAYS, + getReferralFilter(), getControls() ) ), suffix ); } } @@ -272,10 +272,10 @@ { // handle referral here List list = new ArrayList( refs.size() ); - - for ( Value value:refs ) + + for ( Value value : refs ) { - String val = (String)value.get(); + String val = ( String ) value.get(); // need to add non-ldap URLs as-is if ( !val.startsWith( "ldap" ) ) @@ -297,14 +297,14 @@ LdapDN urlDn = new LdapDN( ldapUrl.getDn().toNormName() ); urlDn.normalize( atRegistry.getNormalizerMapping() ); - + if ( urlDn.equals( farthest ) ) { // according to the protocol there is no need for the dn since it is the same as this request - StringBuilder buf = new StringBuilder(); + StringBuilder buf = new StringBuilder(); buf.append( ldapUrl.getScheme() ); buf.append( ldapUrl.getHost() ); - + if ( ldapUrl.getPort() > 0 ) { buf.append( ":" ); @@ -322,24 +322,24 @@ */ int diff = targetUpdn.size() - farthest.size(); LdapDN extra = new LdapDN(); - + for ( int jj = 0; jj < diff; jj++ ) { extra.add( targetUpdn.get( farthest.size() + jj ) ); } urlDn.addAll( extra ); - + StringBuilder buf = new StringBuilder(); buf.append( ldapUrl.getScheme() ); buf.append( ldapUrl.getHost() ); - + if ( ldapUrl.getPort() > 0 ) { buf.append( ":" ); buf.append( ldapUrl.getPort() ); } - + buf.append( "/" ); buf.append( LdapURL.urlEncode( urlDn.getUpName(), false ) ); list.add( buf.toString() ); @@ -349,7 +349,7 @@ } - public void add(NextInterceptor next, AddOperationContext opContext ) throws NamingException + public void add( NextInterceptor next, AddOperationContext opContext ) throws NamingException { Invocation invocation = InvocationStack.getInstance().peek(); ServerLdapContext caller = ( ServerLdapContext ) invocation.getCaller(); @@ -361,7 +361,7 @@ if ( ( refval == null ) || refval.equals( IGNORE ) ) { next.add( opContext ); - + if ( isReferral( entry ) ) { lut.referralAdded( name ); @@ -370,11 +370,11 @@ else if ( refval.equals( THROW ) ) { LdapDN farthest = lut.getFarthestReferralAncestor( name ); - + if ( farthest == null ) { next.add( opContext ); - + if ( isReferral( entry ) ) { lut.referralAdded( name ); @@ -382,10 +382,9 @@ return; } - ServerEntry referral = invocation.getProxy().lookup( - new LookupOperationContext( registries, farthest ), - PartitionNexusProxy.LOOKUP_BYPASS ); - + ServerEntry referral = invocation.getProxy().lookup( new LookupOperationContext( registries, farthest ), + PartitionNexusProxy.LOOKUP_BYPASS ); + AttributeType refsType = atRegistry.lookup( oidRegistry.getOid( SchemaConstants.REF_AT ) ); EntryAttribute refs = referral.get( refsType ); doReferralException( farthest, new LdapDN( name.getUpName() ), refs ); @@ -404,8 +403,8 @@ public boolean compare( NextInterceptor next, CompareOperationContext opContext ) throws NamingException { - LdapDN name = opContext.getDn(); - + LdapDN name = opContext.getDn(); + Invocation invocation = InvocationStack.getInstance().peek(); ServerLdapContext caller = ( ServerLdapContext ) invocation.getCaller(); String refval = ( String ) caller.getEnvironment().get( Context.REFERRAL ); @@ -419,16 +418,15 @@ if ( refval.equals( THROW ) ) { LdapDN farthest = lut.getFarthestReferralAncestor( name ); - + if ( farthest == null ) { return next.compare( opContext ); } - ServerEntry referral = invocation.getProxy().lookup( - new LookupOperationContext( registries, farthest ), - PartitionNexusProxy.LOOKUP_BYPASS ); - + ServerEntry referral = invocation.getProxy().lookup( new LookupOperationContext( registries, farthest ), + PartitionNexusProxy.LOOKUP_BYPASS ); + EntryAttribute refs = referral.get( SchemaConstants.REF_AT ); doReferralException( farthest, new LdapDN( name.getUpName() ), refs ); @@ -449,7 +447,7 @@ public void delete( NextInterceptor next, DeleteOperationContext opContext ) throws NamingException { - LdapDN name = opContext.getDn(); + LdapDN name = opContext.getDn(); Invocation invocation = InvocationStack.getInstance().peek(); ServerLdapContext caller = ( ServerLdapContext ) invocation.getCaller(); String refval = ( String ) caller.getEnvironment().get( Context.REFERRAL ); @@ -458,38 +456,37 @@ if ( refval == null || refval.equals( IGNORE ) ) { next.delete( opContext ); - + if ( lut.isReferral( name ) ) { lut.referralDeleted( name ); } - + return; } if ( refval.equals( THROW ) ) { LdapDN farthest = lut.getFarthestReferralAncestor( name ); - + if ( farthest == null ) { next.delete( opContext ); - + if ( lut.isReferral( name ) ) { lut.referralDeleted( name ); } - + return; } - ServerEntry referral = invocation.getProxy().lookup( - new LookupOperationContext( registries, farthest ), - PartitionNexusProxy.LOOKUP_BYPASS ); - + ServerEntry referral = invocation.getProxy().lookup( new LookupOperationContext( registries, farthest ), + PartitionNexusProxy.LOOKUP_BYPASS ); + EntryAttribute refs = referral.get( SchemaConstants.REF_AT ); doReferralException( farthest, new LdapDN( name.getUpName() ), refs ); - + } else if ( refval.equals( FOLLOW ) ) { @@ -521,7 +518,7 @@ public void move( NextInterceptor next, MoveOperationContext opContext ) throws NamingException { LdapDN oldName = opContext.getDn(); - + Invocation invocation = InvocationStack.getInstance().peek(); ServerLdapContext caller = ( ServerLdapContext ) invocation.getCaller(); String refval = ( String ) caller.getEnvironment().get( Context.REFERRAL ); @@ -532,12 +529,12 @@ if ( refval == null || refval.equals( IGNORE ) ) { next.move( opContext ); - + if ( lut.isReferral( oldName ) ) { lut.referralChanged( oldName, newName ); } - + return; } @@ -545,24 +542,23 @@ { LdapDN farthestSrc = lut.getFarthestReferralAncestor( oldName ); LdapDN farthestDst = lut.getFarthestReferralAncestor( newName ); // note will not return newName so safe - + if ( farthestSrc == null && farthestDst == null && !lut.isReferral( newName ) ) { next.move( opContext ); - + if ( lut.isReferral( oldName ) ) { lut.referralChanged( oldName, newName ); } - + return; } else if ( farthestSrc != null ) { - ServerEntry referral = invocation.getProxy().lookup( - new LookupOperationContext( registries, farthestSrc ), - PartitionNexusProxy.LOOKUP_BYPASS ); - + ServerEntry referral = invocation.getProxy().lookup( + new LookupOperationContext( registries, farthestSrc ), PartitionNexusProxy.LOOKUP_BYPASS ); + EntryAttribute refs = referral.get( SchemaConstants.REF_AT ); doReferralException( farthestSrc, new LdapDN( oldName.getUpName() ), refs ); } @@ -593,11 +589,10 @@ } - public void moveAndRename( NextInterceptor next, MoveAndRenameOperationContext opContext ) - throws NamingException + public void moveAndRename( NextInterceptor next, MoveAndRenameOperationContext opContext ) throws NamingException { LdapDN oldName = opContext.getDn(); - + Invocation invocation = InvocationStack.getInstance().peek(); ServerLdapContext caller = ( ServerLdapContext ) invocation.getCaller(); String refval = ( String ) caller.getEnvironment().get( Context.REFERRAL ); @@ -608,7 +603,7 @@ if ( refval == null || refval.equals( IGNORE ) ) { next.moveAndRename( opContext ); - + if ( lut.isReferral( oldName ) ) { lut.referralChanged( oldName, newName ); @@ -620,11 +615,11 @@ { LdapDN farthestSrc = lut.getFarthestReferralAncestor( oldName ); LdapDN farthestDst = lut.getFarthestReferralAncestor( newName ); // safe to use - does not return newName - + if ( farthestSrc == null && farthestDst == null && !lut.isReferral( newName ) ) { next.moveAndRename( opContext ); - + if ( lut.isReferral( oldName ) ) { lut.referralChanged( oldName, newName ); @@ -633,13 +628,12 @@ } else if ( farthestSrc != null ) { - ServerEntry referral = invocation.getProxy().lookup( - new LookupOperationContext( registries, farthestSrc ), - PartitionNexusProxy.LOOKUP_BYPASS ); - + ServerEntry referral = invocation.getProxy().lookup( + new LookupOperationContext( registries, farthestSrc ), PartitionNexusProxy.LOOKUP_BYPASS ); + EntryAttribute refs = referral.get( SchemaConstants.REF_AT ); doReferralException( farthestSrc, new LdapDN( oldName.getUpName() ), refs ); - + } else if ( farthestDst != null ) { @@ -668,11 +662,10 @@ } - public void rename( NextInterceptor next, RenameOperationContext opContext ) - throws NamingException + public void rename( NextInterceptor next, RenameOperationContext opContext ) throws NamingException { LdapDN oldName = opContext.getDn(); - + Invocation invocation = InvocationStack.getInstance().peek(); ServerLdapContext caller = ( ServerLdapContext ) invocation.getCaller(); String refval = ( String ) caller.getEnvironment().get( Context.REFERRAL ); @@ -685,12 +678,12 @@ if ( refval == null || refval.equals( IGNORE ) ) { next.rename( opContext ); - + if ( lut.isReferral( oldName ) ) { lut.referralChanged( oldName, newName ); } - + return; } @@ -698,28 +691,27 @@ { LdapDN farthestSrc = lut.getFarthestReferralAncestor( oldName ); LdapDN farthestDst = lut.getFarthestReferralAncestor( newName ); - + if ( farthestSrc == null && farthestDst == null && !lut.isReferral( newName ) ) { next.rename( opContext ); - + if ( lut.isReferral( oldName ) ) { lut.referralChanged( oldName, newName ); } - + return; } - + if ( farthestSrc != null ) { - ServerEntry referral = invocation.getProxy().lookup( - new LookupOperationContext( registries, farthestSrc ), - PartitionNexusProxy.LOOKUP_BYPASS ); - + ServerEntry referral = invocation.getProxy().lookup( + new LookupOperationContext( registries, farthestSrc ), PartitionNexusProxy.LOOKUP_BYPASS ); + EntryAttribute refs = referral.get( SchemaConstants.REF_AT ); doReferralException( farthestSrc, new LdapDN( oldName.getUpName() ), refs ); - + } else if ( farthestDst != null ) { @@ -760,7 +752,8 @@ { if ( mod.getAttribute().getId().equalsIgnoreCase( SchemaConstants.OBJECT_CLASS_AT ) ) { - boolean modsOcHasReferral = ((ServerAttribute)mod.getAttribute()).contains( SchemaConstants.REFERRAL_OC ); + boolean modsOcHasReferral = ( ( ServerAttribute ) mod.getAttribute() ) + .contains( SchemaConstants.REFERRAL_OC ); switch ( mod.getOperation() ) { @@ -768,35 +761,35 @@ * if ADD op where refferal is added to objectClass of a * non-referral entry then we add a new referral to lut */ - case ADD_ATTRIBUTE : + case ADD_ATTRIBUTE: if ( modsOcHasReferral && !isTargetReferral ) { lut.referralAdded( name ); } - + break; - /* - * if REMOVE op where refferal is removed from objectClass of a - * referral entry then we remove the referral from lut - */ - case REMOVE_ATTRIBUTE : + /* + * if REMOVE op where refferal is removed from objectClass of a + * referral entry then we remove the referral from lut + */ + case REMOVE_ATTRIBUTE: if ( modsOcHasReferral && isTargetReferral ) { lut.referralDeleted( name ); } - + break; - /* - * if REPLACE op on referral has new set of OC values which does - * not contain a referral value then we remove the referral from - * the lut - * - * if REPLACE op on non-referral has new set of OC values with - * referral value then we add the new referral to the lut - */ - case REPLACE_ATTRIBUTE : + /* + * if REPLACE op on referral has new set of OC values which does + * not contain a referral value then we remove the referral from + * the lut + * + * if REPLACE op on non-referral has new set of OC values with + * referral value then we add the new referral to the lut + */ + case REPLACE_ATTRIBUTE: if ( isTargetReferral && !modsOcHasReferral ) { lut.referralDeleted( name ); @@ -805,7 +798,7 @@ { lut.referralAdded( name ); } - + break; default: @@ -837,7 +830,7 @@ if ( refval.equals( THROW ) ) { LdapDN farthest = lut.getFarthestReferralAncestor( name ); - + if ( farthest == null ) { next.modify( opContext ); @@ -845,10 +838,9 @@ return; } - ServerEntry referral = invocation.getProxy().lookup( - new LookupOperationContext( registries, farthest ), - PartitionNexusProxy.LOOKUP_BYPASS ); - + ServerEntry referral = invocation.getProxy().lookup( new LookupOperationContext( registries, farthest ), + PartitionNexusProxy.LOOKUP_BYPASS ); + EntryAttribute refs = referral.get( SchemaConstants.REF_AT ); doReferralException( farthest, new LdapDN( name.getUpName() ), refs ); } @@ -866,7 +858,7 @@ static ExprNode getReferralFilter() { - return new EqualityNode( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.REFERRAL_OC ); + return new EqualityNode( SchemaConstants.OBJECT_CLASS_AT, new ClientStringValue( SchemaConstants.REFERRAL_OC ) ); } @@ -879,7 +871,8 @@ } - public void addContextPartition( NextInterceptor next, AddContextPartitionOperationContext opContext ) throws NamingException + public void addContextPartition( NextInterceptor next, AddContextPartitionOperationContext opContext ) + throws NamingException { next.addContextPartition( opContext ); @@ -887,20 +880,22 @@ Partition partition = opContext.getPartition(); LdapDN suffix = partition.getSuffixDn(); Invocation invocation = InvocationStack.getInstance().peek(); - NamingEnumeration list = invocation.getProxy().search( new SearchOperationContext( registries, suffix, - AliasDerefMode.DEREF_ALWAYS, getReferralFilter(), getControls() ), SEARCH_BYPASS ); + NamingEnumeration list = invocation.getProxy().search( + new SearchOperationContext( registries, suffix, AliasDerefMode.DEREF_ALWAYS, getReferralFilter(), + getControls() ), SEARCH_BYPASS ); addReferrals( list, suffix ); } - public void removeContextPartition( NextInterceptor next, RemoveContextPartitionOperationContext opContext ) throws NamingException + public void removeContextPartition( NextInterceptor next, RemoveContextPartitionOperationContext opContext ) + throws NamingException { // remove referrals immediately before removing the partition Invocation invocation = InvocationStack.getInstance().peek(); - NamingEnumeration list = invocation.getProxy().search( + NamingEnumeration list = invocation.getProxy().search( new SearchOperationContext( registries, opContext.getDn(), AliasDerefMode.DEREF_ALWAYS, - getReferralFilter(), getControls() ), SEARCH_BYPASS ); - + getReferralFilter(), getControls() ), SEARCH_BYPASS ); + deleteReferrals( list, opContext.getDn() ); next.removeContextPartition( opContext ); } @@ -909,12 +904,12 @@ private void addReferrals( NamingEnumeration referrals, LdapDN base ) throws NamingException { while ( referrals.hasMore() ) - { - ServerSearchResult r = referrals.next(); + { + ServerSearchResult r = referrals.next(); LdapDN referral; LdapDN result = new LdapDN( r.getDn() ); result.normalize( atRegistry.getNormalizerMapping() ); - + if ( r.isRelative() ) { referral = ( LdapDN ) base.clone(); @@ -931,7 +926,7 @@ { while ( referrals.hasMore() ) { - ServerSearchResult r = referrals.next(); + ServerSearchResult r = referrals.next(); LdapDN referral; LdapDN result = new LdapDN( r.getDn() ); result.normalize( atRegistry.getNormalizerMapping() ); @@ -941,7 +936,7 @@ referral = ( LdapDN ) base.clone(); referral.addAll( result ); } - + // Now, remove the referral from the cache lut.referralDeleted( result ); } @@ -960,10 +955,9 @@ { return next.search( opContext ); } - + LdapDN base = opContext.getDn(); SearchControls controls = opContext.getSearchControls(); - /** * THROW_FINDING_BASE is a special setting which allows for finding base to @@ -974,43 +968,47 @@ { if ( lut.isReferral( base ) ) { - ServerEntry referral = invocation.getProxy().lookup( new LookupOperationContext( registries, base ), PartitionNexusProxy.LOOKUP_BYPASS ); + ServerEntry referral = invocation.getProxy().lookup( new LookupOperationContext( registries, base ), + PartitionNexusProxy.LOOKUP_BYPASS ); EntryAttribute refs = referral.get( SchemaConstants.REF_AT ); doReferralExceptionOnSearchBase( base, refs, controls.getSearchScope() ); } LdapDN farthest = lut.getFarthestReferralAncestor( base ); - + if ( farthest == null ) { return next.search( opContext ); } - ServerEntry referral = invocation.getProxy().lookup( new LookupOperationContext( registries, farthest ), PartitionNexusProxy.LOOKUP_BYPASS ); + ServerEntry referral = invocation.getProxy().lookup( new LookupOperationContext( registries, farthest ), + PartitionNexusProxy.LOOKUP_BYPASS ); EntryAttribute refs = referral.get( SchemaConstants.REF_AT ); doReferralExceptionOnSearchBase( farthest, new LdapDN( base.getUpName() ), refs, controls.getSearchScope() ); throw new IllegalStateException( "Should never get here: shutting up compiler" ); } - + if ( refval.equals( THROW ) ) { if ( lut.isReferral( base ) ) { - ServerEntry referral = invocation.getProxy().lookup( new LookupOperationContext( registries, base ), PartitionNexusProxy.LOOKUP_BYPASS ); + ServerEntry referral = invocation.getProxy().lookup( new LookupOperationContext( registries, base ), + PartitionNexusProxy.LOOKUP_BYPASS ); EntryAttribute refs = referral.get( SchemaConstants.REF_AT ); doReferralExceptionOnSearchBase( base, refs, controls.getSearchScope() ); } LdapDN farthest = lut.getFarthestReferralAncestor( base ); - + if ( farthest == null ) { - SearchResultFilteringEnumeration srfe = - ( SearchResultFilteringEnumeration ) next.search( opContext ); - return new ReferralHandlingEnumeration( srfe, lut, opContext.getRegistries(), nexus, controls.getSearchScope(), true ); + SearchResultFilteringEnumeration srfe = ( SearchResultFilteringEnumeration ) next.search( opContext ); + return new ReferralHandlingEnumeration( srfe, lut, opContext.getRegistries(), nexus, controls + .getSearchScope(), true ); } - ServerEntry referral = invocation.getProxy().lookup( new LookupOperationContext( registries, farthest ), PartitionNexusProxy.LOOKUP_BYPASS ); + ServerEntry referral = invocation.getProxy().lookup( new LookupOperationContext( registries, farthest ), + PartitionNexusProxy.LOOKUP_BYPASS ); EntryAttribute refs = referral.get( SchemaConstants.REF_AT ); doReferralExceptionOnSearchBase( farthest, new LdapDN( base.getUpName() ), refs, controls.getSearchScope() ); throw new IllegalStateException( "Should never get here: shutting up compiler" ); @@ -1040,8 +1038,8 @@ { // handle referral here List list = new ArrayList( refs.size() ); - - for ( Value value:refs ) + + for ( Value value : refs ) { String val = ( String ) value.get(); @@ -1066,31 +1064,31 @@ StringBuilder buf = new StringBuilder(); buf.append( ldapUrl.getScheme() ); buf.append( ldapUrl.getHost() ); - + if ( ldapUrl.getPort() > 0 ) { buf.append( ":" ); buf.append( ldapUrl.getPort() ); } - + buf.append( "/" ); buf.append( LdapURL.urlEncode( ldapUrl.getDn().getUpName(), false ) ); buf.append( "??" ); switch ( scope ) { - case ( SearchControls.SUBTREE_SCOPE ): + case ( SearchControls.SUBTREE_SCOPE ): buf.append( "sub" ); break; - - case ( SearchControls.ONELEVEL_SCOPE ): + + case ( SearchControls.ONELEVEL_SCOPE ): buf.append( "one" ); break; - - case ( SearchControls.OBJECT_SCOPE ): + + case ( SearchControls.OBJECT_SCOPE ): buf.append( "base" ); break; - + default: throw new IllegalStateException( "Unknown recognized search scope: " + scope ); } @@ -1107,8 +1105,8 @@ { // handle referral here List list = new ArrayList( refs.size() ); - - for ( Value value:refs ) + + for ( Value value : refs ) { String val = ( String ) value.get(); @@ -1121,7 +1119,7 @@ // parse the ref value and normalize the DN according to schema LdapURL ldapUrl = new LdapURL(); - + try { ldapUrl.parse( val.toCharArray() ); @@ -1135,52 +1133,53 @@ urlDn.normalize( atRegistry.getNormalizerMapping() ); int diff = targetUpdn.size() - farthest.size(); LdapDN extra = new LdapDN(); - + for ( int jj = 0; jj < diff; jj++ ) { extra.add( targetUpdn.get( farthest.size() + jj ) ); } urlDn.addAll( extra ); - + StringBuilder buf = new StringBuilder(); buf.append( ldapUrl.getScheme() ); buf.append( ldapUrl.getHost() ); - + if ( ldapUrl.getPort() > 0 ) { buf.append( ":" ); buf.append( ldapUrl.getPort() ); } - + buf.append( "/" ); buf.append( LdapURL.urlEncode( urlDn.getUpName(), false ) ); buf.append( "??" ); switch ( scope ) { - case ( SearchControls.SUBTREE_SCOPE ): + case ( SearchControls.SUBTREE_SCOPE ): buf.append( "sub" ); break; - - case ( SearchControls.ONELEVEL_SCOPE ): + + case ( SearchControls.ONELEVEL_SCOPE ): buf.append( "one" ); break; - - case ( SearchControls.OBJECT_SCOPE ): + + case ( SearchControls.OBJECT_SCOPE ): buf.append( "base" ); break; - + default: throw new IllegalStateException( "Unknown recognized search scope: " + scope ); } - + list.add( buf.toString() ); } throw new LdapReferralException( list ); } + /** * Check if the given name is a referral or not. * @@ -1201,6 +1200,7 @@ return lut.isReferral( dn ); } + /** * Check if the given name is a referral or not. * @@ -1210,6 +1210,7 @@ */ public boolean isReferral( LdapDN name ) throws NamingException { - return lut.isReferral( name.isNormalized() ? name : LdapDN.normalize( name, atRegistry.getNormalizerMapping() ) ); + return lut + .isReferral( name.isNormalized() ? name : LdapDN.normalize( name, atRegistry.getNormalizerMapping() ) ); } }