directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1708527 [3/3] - in /directory/apacheds/trunk: core-api/src/main/java/org/apache/directory/server/core/api/authn/ppolicy/ core-api/src/main/java/org/apache/directory/server/core/api/schema/registries/synchronizers/ core-integ/src/main/java/...
Date Tue, 13 Oct 2015 22:17:24 GMT
Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/modifydn/ModifyRdnIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/modifydn/ModifyRdnIT.java?rev=1708527&r1=1708526&r2=1708527&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/modifydn/ModifyRdnIT.java
(original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/modifydn/ModifyRdnIT.java
Tue Oct 13 22:17:22 2015
@@ -28,7 +28,6 @@ import static org.junit.Assert.assertNul
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
-
 import javax.naming.NameNotFoundException;
 import javax.naming.NamingEnumeration;
 import javax.naming.NoPermissionException;
@@ -39,10 +38,10 @@ import javax.naming.directory.SchemaViol
 import javax.naming.directory.SearchControls;
 import javax.naming.directory.SearchResult;
 
-
 import org.apache.directory.api.ldap.model.entry.DefaultEntry;
 import org.apache.directory.api.ldap.model.entry.Entry;
 import org.apache.directory.api.ldap.model.ldif.LdifUtils;
+import org.apache.directory.api.util.Strings;
 import org.apache.directory.ldap.client.api.LdapConnection;
 import org.apache.directory.server.annotations.CreateLdapServer;
 import org.apache.directory.server.annotations.CreateTransport;
@@ -178,6 +177,100 @@ public class ModifyRdnIT extends Abstrac
 
 
     /**
+<<<<<<<
+     * Modify Rdn of an entry, without deleting its old rdn value.
+=======
+     * Modify Rdn of an entry, delete its old rdn value and search before and
+     * after rename.
+     */
+    @Ignore
+    public void testModifyRdnAndDeleteOldWithSearchInBetween() throws Exception
+    {
+        LdapConnection connection = ServerIntegrationUtils.getAdminConnection( getLdapServer()
);
+        // connection.setTimeOut( 0L );
+        connection.loadSchema();
+
+        // Create a person, cn value is rdn
+        String oldCn = "Myra Ellen Amos";
+        String oldRdn = "cn=" + oldCn;
+        String oldDn = oldRdn + ", " + BASE;
+
+        Entry entry = new DefaultEntry( oldDn,
+                "objectClass: top",
+                "objectClass: person",
+                "cn", oldCn,
+                "sn: Amos",
+                "description", oldCn + " is a person." );
+
+        connection.add( entry );
+
+        Entry tori = connection.lookup( oldDn );
+
+        assertNotNull( tori );
+        assertTrue( tori.contains( "cn", "Myra Ellen Amos" ) );
+
+        // now try a search
+        Entry found = null;
+        for ( Entry result : connection.search( BASE, "(sn=amos)", SearchScope.ONELEVEL )
)
+        {
+            if ( found == null )
+            {
+                found = result;
+            }
+            else
+            {
+                fail( "Found too many results" );
+            }
+        }
+        assertNotNull( found );
+        Rdn foundRdn = found.getDn().getRdn();
+        assertEquals( "cn", foundRdn.getType() );
+        assertEquals( oldCn, foundRdn.getValue() );
+
+        // modify Rdn
+        String newCn = "Tori Amos";
+        String newRdn = "cn=" + newCn;
+        String newDn = newRdn + "," + BASE;
+
+        connection.rename( oldDn, newRdn, true );
+
+        // Check, whether old Entry does not exists
+        assertNull( connection.lookup( oldDn ) );
+
+        // Check, whether new Entry exists
+        tori = connection.lookup( newDn );
+        assertNotNull( tori );
+
+        // Check values of cn
+        assertTrue( tori.contains( "cn", newCn ) );
+        assertFalse( tori.contains( "cn", oldCn ) ); // old value is gone
+        assertEquals( 1, tori.get( "cn" ).size() );
+
+        // now try a search
+        found = null;
+        for ( Entry result : connection.search( BASE, "(sn=amos)", SearchScope.ONELEVEL )
)
+        {
+            if ( found == null )
+            {
+                found = result;
+            }
+            else
+            {
+                fail( "Found too many results" );
+            }
+        }
+        assertNotNull( found );
+        foundRdn = found.getDn().getRdn();
+        assertEquals( "cn", foundRdn.getType() );
+        assertEquals( oldCn, foundRdn.getValue() );
+
+        // Remove entry (use new rdn)
+        connection.delete( newDn );
+    }
+
+
+    /**
+>>>>>>>
      * Modify Rdn of an entry, without deleting its old rdn value.
      * 
      * The JNDI property is set with 'False'
@@ -217,7 +310,7 @@ public class ModifyRdnIT extends Abstrac
 
         // Check values of cn
         Attribute cn = tori.getAttributes( "" ).get( "cn" );
-        assertTrue( cn.contains( newCn ) );
+        assertTrue( cn.contains( Strings.toLowerCaseAscii( newCn ) ) );
         assertTrue( cn.contains( oldCn ) ); // old value is still there
         assertEquals( 2, cn.size() );
 
@@ -264,7 +357,7 @@ public class ModifyRdnIT extends Abstrac
 
         // Check values of cn
         Attribute cn = tori.getAttributes( "" ).get( "cn" );
-        assertTrue( cn.contains( newCn ) );
+        assertTrue( cn.contains( Strings.toLowerCaseAscii( newCn ) ) );
         assertTrue( cn.contains( oldCn ) ); // old value is still there
         assertEquals( 2, cn.size() );
 
@@ -319,7 +412,7 @@ public class ModifyRdnIT extends Abstrac
 
         // Check values of cn
         cn = tori.getAttributes( "" ).get( "cn" );
-        assertTrue( cn.contains( newCn ) );
+        assertTrue( cn.contains( Strings.toLowerCaseAscii( newCn ) ) );
         assertTrue( !cn.contains( oldCn ) ); // old value is gone
         assertTrue( cn.contains( alternateCn ) ); // alternate value is still available
         assertEquals( 2, cn.size() );
@@ -370,7 +463,7 @@ public class ModifyRdnIT extends Abstrac
         assertTrue( cn.contains( cnVal ) );
         assertEquals( "Number of cn occurences", 1, cn.size() );
         Attribute sn = tori.getAttributes( "" ).get( "sn" );
-        assertTrue( sn.contains( snVal ) );
+        assertTrue( sn.contains( Strings.toLowerCaseAscii( snVal ) ) );
         assertEquals( "Number of sn occurences", 1, sn.size() );
 
         // Remove entry (use new rdn)
@@ -458,7 +551,7 @@ public class ModifyRdnIT extends Abstrac
 
         // Check values of ou
         Attribute ou = org.getAttributes( "" ).get( "ou" );
-        assertTrue( ou.contains( newOu ) );
+        assertTrue( ou.contains( Strings.toLowerCaseAscii( newOu ) ) );
         assertTrue( !ou.contains( oldOu ) ); // old value is gone
         assertEquals( 1, ou.size() );
 
@@ -614,10 +707,10 @@ public class ModifyRdnIT extends Abstrac
         // Check attributes
         Attribute cnAttr = newCtx.getAttributes( "" ).get( "cn" );
         assertEquals( 1, cnAttr.size() );
-        assertTrue( cnAttr.contains( "Tori Amos" ) );
+        assertTrue( cnAttr.contains( "tori amos" ) );
         Attribute snAttr = newCtx.getAttributes( "" ).get( "sn" );
         assertEquals( 1, snAttr.size() );
-        assertTrue( snAttr.contains( "Amos" ) );
+        assertTrue( snAttr.contains( "amos" ) );
         Attribute descriptionAttr = newCtx.getAttributes( "" ).get( "description" );
         assertEquals( 1, descriptionAttr.size() );
 
@@ -654,10 +747,10 @@ public class ModifyRdnIT extends Abstrac
         // Check attributes
         Attribute cnAttr = newCtx.getAttributes( "" ).get( "cn" );
         assertEquals( 1, cnAttr.size() );
-        assertTrue( cnAttr.contains( "Tori Amos" ) );
+        assertTrue( cnAttr.contains( "tori amos" ) );
         Attribute snAttr = newCtx.getAttributes( "" ).get( "sn" );
         assertEquals( 1, snAttr.size() );
-        assertTrue( snAttr.contains( "Amos" ) );
+        assertTrue( snAttr.contains( "amos" ) );
         Attribute descriptionAttr = newCtx.getAttributes( "" ).get( "description" );
         assertEquals( 1, descriptionAttr.size() );
 
@@ -694,10 +787,10 @@ public class ModifyRdnIT extends Abstrac
         // Check attributes
         Attribute cnAttr = newCtx.getAttributes( "" ).get( "cn" );
         assertEquals( 1, cnAttr.size() );
-        assertTrue( cnAttr.contains( "Tori Amos" ) );
+        assertTrue( cnAttr.contains( "tori amos" ) );
         Attribute snAttr = newCtx.getAttributes( "" ).get( "sn" );
         assertEquals( 1, snAttr.size() );
-        assertTrue( snAttr.contains( "Amos" ) );
+        assertTrue( snAttr.contains( "amos" ) );
         Attribute descriptionAttr = newCtx.getAttributes( "" ).get( "description" );
         assertEquals( 1, descriptionAttr.size() );
 
@@ -734,10 +827,10 @@ public class ModifyRdnIT extends Abstrac
         // Check attributes
         Attribute cnAttr = newCtx.getAttributes( "" ).get( "cn" );
         assertEquals( 1, cnAttr.size() );
-        assertTrue( cnAttr.contains( "Tori Amos" ) );
+        assertTrue( cnAttr.contains( "tori amos" ) );
         Attribute snAttr = newCtx.getAttributes( "" ).get( "sn" );
         assertEquals( 1, snAttr.size() );
-        assertTrue( snAttr.contains( "Amos" ) );
+        assertTrue( snAttr.contains( "amos" ) );
         Attribute descriptionAttr = newCtx.getAttributes( "" ).get( "description" );
         assertNull( descriptionAttr );
 
@@ -780,7 +873,7 @@ public class ModifyRdnIT extends Abstrac
         assertTrue( cnAttr.contains( "Tori Amos" ) );
         Attribute snAttr = newCtx.getAttributes( "" ).get( "sn" );
         assertEquals( 1, snAttr.size() );
-        assertTrue( snAttr.contains( "Amos" ) );
+        assertTrue( snAttr.contains( "amos" ) );
         Attribute descriptionAttr = newCtx.getAttributes( "" ).get( "description" );
         assertEquals( 1, descriptionAttr.size() );
         Attribute telephoneNumberAttr = newCtx.getAttributes( "" ).get( "telephoneNumber"
);
@@ -882,7 +975,7 @@ public class ModifyRdnIT extends Abstrac
         // Check attributes
         Attribute cnAttr = newCtx.getAttributes( "" ).get( "cn" );
         assertEquals( 1, cnAttr.size() );
-        assertTrue( cnAttr.contains( "Tori Amos" ) );
+        assertTrue( cnAttr.contains( "tori amos" ) );
         Attribute snAttr = newCtx.getAttributes( "" ).get( "sn" );
         assertEquals( 1, snAttr.size() );
         assertTrue( snAttr.contains( "Amos" ) );

Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/SearchIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/SearchIT.java?rev=1708527&r1=1708526&r2=1708527&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/SearchIT.java
(original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/SearchIT.java
Tue Oct 13 22:17:22 2015
@@ -463,6 +463,7 @@ public class SearchIT extends AbstractLd
      * Search operation with a base Dn which contains a BER encoded value.
      */
     @Test
+    @Ignore
     public void testSearchWithBackslashEscapedBase() throws Exception
     {
         LdapContext ctx = ( LdapContext ) getWiredContext( getLdapServer() ).lookup( BASE
);
@@ -477,12 +478,13 @@ public class SearchIT extends AbstractLd
 
         // sn=Ferry with BEROctetString values
         String base = "sn=\\46\\65\\72\\72\\79";
-
+        
         try
         {
             // Check entry
             NamingEnumeration<SearchResult> enm = ctx.search( base, filter, sctls );
             assertTrue( enm.hasMore() );
+            
             while ( enm.hasMore() )
             {
                 SearchResult sr = enm.next();
@@ -1493,7 +1495,7 @@ public class SearchIT extends AbstractLd
         attrs.put( "givenName", "Jim" );
         attrs.put( "sn", "Bean" );
         attrs.put( "cn", "jimbean" );
-        attrs.put( "description", "(sex*pis\\tols)" );
+        attrs.put( "description", "(sex*pis\\\\tols)" );
         ctx.createSubcontext( "cn=jimbean", attrs );
 
         SearchControls controls = new SearchControls();

Modified: directory/apacheds/trunk/service/ApacheDS.launch
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/service/ApacheDS.launch?rev=1708527&r1=1708526&r2=1708527&view=diff
==============================================================================
--- directory/apacheds/trunk/service/ApacheDS.launch (original)
+++ directory/apacheds/trunk/service/ApacheDS.launch Tue Oct 13 22:17:22 2015
@@ -10,8 +10,10 @@
 <mapEntry key="[debug]" value="org.eclipse.jdt.launching.localJavaApplication"/>
 <mapEntry key="[run]" value="org.eclipse.jdt.launching.localJavaApplication"/>
 </mapAttribute>
+<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.m2e.launchconfig.classpathProvider"/>
 <stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.apache.directory.server.UberjarMain"/>
 <stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="./target/instance"/>
 <stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="apacheds-service"/>
+<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.m2e.launchconfig.sourcepathProvider"/>
 <stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Dlog4j.configuration=file:./log4j.properties
-Dapacheds.log.dir=./target/instance/log -Dapacheds.controls=org.apache.directory.api.ldap.codec.controls.cascade.CascadeFactory,org.apache.directory.api.ldap.codec.controls.manageDsaIT.ManageDsaITFactory,org.apache.directory.api.ldap.codec.controls.proxiedauthz.ProxiedAuthzFactory,org.apache.directory.api.ldap.codec.controls.search.entryChange.EntryChangeFactory,org.apache.directory.api.ldap.codec.controls.search.pagedSearch.PagedResultsFactory,org.apache.directory.api.ldap.codec.controls.search.persistentSearch.PersistentSearchFactory,org.apache.directory.api.ldap.codec.controls.search.subentries.SubentriesFactory,org.apache.directory.api.ldap.extras.controls.ppolicy_impl.PasswordPolicyFactory,org.apache.directory.api.ldap.extras.controls.syncrepl_impl.SyncDoneValueFactory,org.apache.directory.api.ldap.extras.controls.syncrepl_impl.SyncInfoValueFactory,org.apache.dire
 ctory.api.ldap.extras.controls.syncrepl_impl.SyncRequestValueFactory,org.apache.directory.api.ldap.extras.controls.syncrepl_impl.SyncStateValueFactory,org.apache.directory.api.ldap.extras.controls.ad_impl.AdDirSyncFactory
-Dapacheds.extendedOperations=org.apache.directory.api.ldap.extras.extended.ads_impl.cancel.CancelFactory,org.apache.directory.api.ldap.extras.extended.ads_impl.certGeneration.CertGenerationFactory,org.apache.directory.api.ldap.extras.extended.ads_impl.gracefulShutdown.GracefulShutdownFactory,org.apache.directory.api.ldap.extras.extended.ads_impl.storedProcedure.StoredProcedureFactory,org.apache.directory.api.ldap.extras.extended.ads_impl.gracefulDisconnect.GracefulDisconnectFactory"/>
 </launchConfiguration>

Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/AbstractBTreePartition.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/AbstractBTreePartition.java?rev=1708527&r1=1708526&r2=1708527&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/AbstractBTreePartition.java
(original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/AbstractBTreePartition.java
Tue Oct 13 22:17:22 2015
@@ -2112,6 +2112,12 @@ public abstract class AbstractBTreeParti
     }
 
 
+    /**
+     * This will rename the entry, and deal with the deleteOldRdn flag. If set to true, we
have
+     * to remove the AVA which are not part of the new RDN from the entry.
+     * If this flag is set to false, we have to take care of the special case of an AVA
+     * which attributeType is SINGLE-VALUE : in this case, we remove the old value.
+     */
     private void rename( String oldId, Rdn newRdn, boolean deleteOldRdn, Entry entry ) throws
Exception
     {
         if ( entry == null )
@@ -2130,19 +2136,60 @@ public abstract class AbstractBTreeParti
          * new Rdn attribute we add the index for this attribute value pair.
          * Also we make sure that the presence index shows the existence of the
          * new Rdn attribute within this entry.
+         * Last, not least, if the AttributeType is single value, take care
+         * of removing the old value.
          */
         for ( Ava newAtav : newRdn )
         {
             String newNormType = newAtav.getNormType();
-            Object newNormValue = newAtav.getNormValue().getValue();
+            Object newNormValue = newAtav.getValue().getNormValue();
+            boolean oldRemoved = false;
 
             AttributeType newRdnAttrType = schemaManager.lookupAttributeTypeRegistry( newNormType
);
 
-            entry.add( newRdnAttrType, newAtav.getValue() );
+            if ( newRdnAttrType.isSingleValued() && entry.containsAttribute( newRdnAttrType
) )
+            {
+                Attribute oldAttribute = entry.get( newRdnAttrType );
+                
+                // We have to remove the old attribute value, if we have some
+                entry.removeAttributes( newRdnAttrType );
+                
+                // Deal with the index
+                if ( hasUserIndexOn( newRdnAttrType ) )
+                {
+                    Index<?, String> index = getUserIndex( newRdnAttrType );
+                    ( ( Index ) index ).drop( oldAttribute.get().getNormValue(), id );
+
+                    /*
+                     * If there is no value for id in this index due to our
+                     * drop above we remove the oldRdnAttr from the presence idx
+                     */
+                    if ( null == index.reverseLookup( oldId ) )
+                    {
+                        presenceIdx.drop( newRdnAttrType.getOid(), oldId );
+                    }
+
+                }
+            }
+
+            if ( newRdnAttrType.getSyntax().isHumanReadable() )
+            {
+                entry.add( newRdnAttrType, ( String ) newAtav.getValue().getNormValue() );
+            }
+            else
+            {
+                entry.add( newRdnAttrType, ( byte[] ) newAtav.getValue().getNormValue() );
+            }
 
             if ( hasUserIndexOn( newRdnAttrType ) )
             {
                 Index<?, String> index = getUserIndex( newRdnAttrType );
+                
+                if ( oldRemoved )
+                {
+                    ( ( Index ) index ).drop( newNormValue, oldId );
+                }
+                
                 ( ( Index ) index ).add( newNormValue, oldId );
 
                 // Make sure the altered entry shows the existence of the new attrib
@@ -2192,7 +2239,7 @@ public abstract class AbstractBTreeParti
                 if ( mustRemove )
                 {
                     String oldNormType = oldAtav.getNormType();
-                    String oldNormValue = oldAtav.getNormValue().getString();
+                    String oldNormValue = ( String ) oldAtav.getValue().getNormValue();
                     AttributeType oldRdnAttrType = schemaManager.lookupAttributeTypeRegistry(
oldNormType );
                     entry.remove( oldRdnAttrType, oldNormValue );
 

Modified: directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlPartitionTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlPartitionTest.java?rev=1708527&r1=1708526&r2=1708527&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlPartitionTest.java
(original)
+++ directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlPartitionTest.java
Tue Oct 13 22:17:22 2015
@@ -468,7 +468,7 @@ public class AvlPartitionTest
         String id = partition.getEntryId( dn2 );
         assertNotNull( id );
         Entry entry2 = partition.fetch( id );
-        assertEquals( "Ja+es", entry2.get( "sn" ).getString() );
+        assertEquals( "ja+es", entry2.get( "sn" ).getString() );
         assertEquals( "ja+es", entry2.get( "sn" ).get().getNormValue() );
     }
 



Mime
View raw message