directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From malder...@apache.org
Subject svn commit: r558501 - in /directory/apacheds/trunk/mitosis/src: main/java/org/apache/directory/mitosis/common/ main/java/org/apache/directory/mitosis/operation/ main/java/org/apache/directory/mitosis/service/ test/java/org/apache/directory/mitosis/serv...
Date Sun, 22 Jul 2007 16:07:04 GMT
Author: malderson
Date: Sun Jul 22 09:07:03 2007
New Revision: 558501

URL: http://svn.apache.org/viewvc?view=rev&rev=558501
Log:
Fix for DIRSERVER-1003 - Modifying an entry gives syntax error for 'entryDeleted' attribute.

Modified:
    directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/common/Constants.java
    directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/operation/OperationFactory.java
    directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/ReplicationLogCleanJob.java
    directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/ReplicationService.java
    directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/service/ReplicationServiceITest.java

Modified: directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/common/Constants.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/common/Constants.java?view=diff&rev=558501&r1=558500&r2=558501
==============================================================================
--- directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/common/Constants.java
(original)
+++ directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/common/Constants.java
Sun Jul 22 09:07:03 2007
@@ -57,7 +57,7 @@
     
     /**
      * A {@link SearchResultFilter} that filters out the entries whose
-     * {@link #ENTRY_DELETED} attribute is <tt>true</tt>.
+     * {@link #ENTRY_DELETED} attribute is <tt>TRUE</tt>.
      */
     public static final SearchResultFilter DELETED_ENTRIES_FILTER = new SearchResultFilter()
     {
@@ -67,7 +67,7 @@
             Attributes entry = result.getAttributes();
             Attribute deleted = entry.get( ENTRY_DELETED );
             Object value = deleted == null ? null : deleted.get();
-            return ( value == null || !"true".equalsIgnoreCase( value.toString() ) );
+            return ( value == null || !"TRUE".equalsIgnoreCase( value.toString() ) );
         }
     };
 

Modified: directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/operation/OperationFactory.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/operation/OperationFactory.java?view=diff&rev=558501&r1=558500&r2=558501
==============================================================================
--- directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/operation/OperationFactory.java
(original)
+++ directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/operation/OperationFactory.java
Sun Jul 22 09:07:03 2007
@@ -122,7 +122,7 @@
         entry.remove( Constants.ENTRY_UUID );
         entry.remove( Constants.ENTRY_DELETED );
         entry.put( Constants.ENTRY_UUID, uuidFactory.newInstance().toOctetString() );
-        entry.put( Constants.ENTRY_DELETED, "false" );
+        entry.put( Constants.ENTRY_DELETED, "FALSE" );
 
         // NOTE: We inlined addDefaultOperations() because ApacheDS currently
         // creates an index entry only for ADD operation (and not for
@@ -136,7 +136,7 @@
     /**
      * Creates a new {@link Operation} that performs "delete" operation.
      * The created {@link Operation} doesn't actually delete the entry.
-     * Instead, it sets {@link Constants#ENTRY_DELETED} to "true". 
+     * Instead, it sets {@link Constants#ENTRY_DELETED} to "TRUE". 
      */
     public Operation newDelete( LdapDN normalizedName )
     {
@@ -145,7 +145,7 @@
 
         // Transform into replace operation.
         result.add( new ReplaceAttributeOperation( csn, normalizedName, new AttributeImpl(
Constants.ENTRY_DELETED,
-            "true" ) ) );
+            "TRUE" ) ) );
 
         return addDefaultOperations( result, csn, normalizedName );
     }
@@ -156,7 +156,7 @@
      * 
      * @return a {@link CompositeOperation} that consists of one or more
      * {@link AttributeOperation}s and one additional operation that
-     * sets {@link Constants#ENTRY_DELETED} to "false" to resurrect the
+     * sets {@link Constants#ENTRY_DELETED} to "FALSE" to resurrect the
      * entry the modified attributes belong to.
      */
     public Operation newModify( OperationContext opContext )
@@ -177,7 +177,7 @@
 
         // Resurrect the entry in case it is deleted.
         result.add( new ReplaceAttributeOperation( csn, normalizedName, new AttributeImpl(
Constants.ENTRY_DELETED,
-            "false" ) ) );
+            "FALSE" ) ) );
 
         return addDefaultOperations( result, csn, normalizedName );
     }
@@ -267,7 +267,7 @@
 
             // Delete the old entry
             result.add( new ReplaceAttributeOperation( csn, oldEntryName, new AttributeImpl(
Constants.ENTRY_DELETED,
-                "true" ) ) );
+                "TRUE" ) ) );
 
             // Get the old entry attributes and replace RDN if required
             Attributes entry = sr.getAttributes();
@@ -316,7 +316,7 @@
              * throwing an exception and delete the entry if so and return
              * without throwing an exception.
              */
-            if ( value != null && "true".equalsIgnoreCase( value.toString() ) )
+            if ( value != null && "TRUE".equalsIgnoreCase( value.toString() ) )
             {
                 return;
             }

Modified: directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/ReplicationLogCleanJob.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/ReplicationLogCleanJob.java?view=diff&rev=558501&r1=558500&r2=558501
==============================================================================
--- directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/ReplicationLogCleanJob.java
(original)
+++ directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/ReplicationLogCleanJob.java
Sun Jul 22 09:07:03 2007
@@ -34,7 +34,7 @@
 /**
  * A <a href="http://www.opensymphony.com/quartz/">OpenSymphony Quartz</a>
  * {@link Job} that purges old replication logs and the old entries marked as
- * 'deleted' (i.e. {@link Constants#ENTRY_DELETED} is <tt>true</tt>).  This
+ * 'deleted' (i.e. {@link Constants#ENTRY_DELETED} is <tt>TRUE</tt>).  This
  * {@link Job} just calls {@link ReplicationService#purgeAgedData()} to
  * purge old data. 
  * 

Modified: directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/ReplicationService.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/ReplicationService.java?view=diff&rev=558501&r1=558500&r2=558501
==============================================================================
--- directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/ReplicationService.java
(original)
+++ directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/ReplicationService.java
Sun Jul 22 09:07:03 2007
@@ -122,7 +122,7 @@
  *     valid.  If the local <tt>entryCSN</tt> value is bigger then that of the
  *     incoming operation, it means conflict, and therefore an appropriate
  *     conflict resolution mechanism should get engaged.</li>
- * <li><tt>entryDeleted</tt> - is <tt>true</tt> if and only
if the entry is
+ * <li><tt>entryDeleted</tt> - is <tt>TRUE</tt> if and only
if the entry is
  *     deleted.  The entry is not deleted immediately by a delete operation
  *     because <tt>entryCSN</tt> attribute should be retained for certain
  *     amount of time to determine whether the incoming change log, which
@@ -134,7 +134,7 @@
  *     by calling {@link ReplicationConfiguration#setLogMaxAge(int)}.
  *     Because of this attribute, <tt>lookup</tt> and <tt>search</tt>
  *     operations are overrided to ignore entries with <tt>entryDeleted</tt>
- *     set to <tt>true</tt>.</li>
+ *     set to <tt>TRUE</tt>.</li>
  * </ul>
  * 
  * @author The Apache Directory Project (dev@directory.apache.org)
@@ -277,7 +277,7 @@
 
     /**
      * Purges old replication logs and the old entries marked as 'deleted'
-     * (i.e. {@link Constants#ENTRY_DELETED} is <tt>true</tt>).  This method
+     * (i.e. {@link Constants#ENTRY_DELETED} is <tt>TRUE</tt>).  This method
      * should be called periodically to make sure the size of the DIT and
      * {@link ReplicationStore} increase limitlessly.
      * 
@@ -302,7 +302,7 @@
         try
         {
             filter = parser.parse( "(& (" + ENTRY_CSN_OID + "=<" + purgeCSN.toOctetString()
+ ") (" + ENTRY_DELETED_OID
-                + "=true))" );
+                + "=TRUE))" );
         }
         catch ( IOException e )
         {
@@ -549,6 +549,6 @@
         }
 
         Attribute deleted = entry.get( Constants.ENTRY_DELETED );
-        return ( deleted != null && "true".equalsIgnoreCase( deleted.get().toString()
) );
+        return ( deleted != null && "TRUE".equalsIgnoreCase( deleted.get().toString()
) );
     }
 }

Modified: directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/service/ReplicationServiceITest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/service/ReplicationServiceITest.java?view=diff&rev=558501&r1=558500&r2=558501
==============================================================================
--- directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/service/ReplicationServiceITest.java
(original)
+++ directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/service/ReplicationServiceITest.java
Sun Jul 22 09:07:03 2007
@@ -33,6 +33,8 @@
 import javax.naming.NamingException;
 import javax.naming.directory.Attribute;
 import javax.naming.directory.Attributes;
+import javax.naming.directory.DirContext;
+import javax.naming.directory.ModificationItem;
 import javax.naming.ldap.InitialLdapContext;
 import javax.naming.ldap.LdapContext;
 
@@ -50,7 +52,9 @@
 import org.apache.directory.server.core.configuration.ShutdownConfiguration;
 import org.apache.directory.server.core.jndi.CoreContextFactory;
 import org.apache.directory.shared.ldap.exception.LdapNameNotFoundException;
+import org.apache.directory.shared.ldap.message.AttributeImpl;
 import org.apache.directory.shared.ldap.message.AttributesImpl;
+import org.apache.directory.shared.ldap.message.ModificationItemImpl;
 import org.apache.mina.util.AvailablePortFinder;
 
 /**
@@ -78,6 +82,7 @@
     {
         String dn = "cn=test,ou=system";
         testOneWayBind( dn );
+        testOneWayModify( dn );
         testOneWayUnbind( dn );
     }
     
@@ -143,6 +148,25 @@
         Assert.assertNotNull( ctxA.lookup( dn ) );
         Assert.assertNotNull( ctxB.lookup( dn ) );
         Assert.assertNotNull( ctxC.lookup( dn ) );
+    }
+
+    private void testOneWayModify( String dn ) throws Exception
+    {
+        LdapContext ctxA = getReplicaContext( "A" );
+        LdapContext ctxB = getReplicaContext( "B" );
+        LdapContext ctxC = getReplicaContext( "C" );
+        
+        String newValue = "anything";
+        
+        ctxA.modifyAttributes( dn, new ModificationItem[] {
+            new ModificationItemImpl( DirContext.REPLACE_ATTRIBUTE, new AttributeImpl( "ou",
newValue ))} );
+
+        replicationServices.get( "A" ).replicate();
+        
+        Thread.sleep( 5000 );
+
+        Assert.assertEquals( newValue, getAttributeValue( ctxB, dn, "ou" ) );
+        Assert.assertEquals( newValue, getAttributeValue( ctxC, dn, "ou" ) );
     }
     
     private void testOneWayUnbind( String dn ) throws Exception



Mime
View raw message