You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2011/07/07 00:10:02 UTC

svn commit: r1143581 - in /directory: apacheds/trunk/i18n/src/main/java/org/apache/directory/server/i18n/ apacheds/trunk/i18n/src/main/resources/org/apache/directory/server/i18n/ apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/x...

Author: elecharny
Date: Wed Jul  6 22:10:02 2011
New Revision: 1143581

URL: http://svn.apache.org/viewvc?rev=1143581&view=rev
Log:
o Fixed some small issues in AbstractStore.add method
o Fixed some error code
o Modified the way the buffer is dumped in the LdapDecoder

Modified:
    directory/apacheds/trunk/i18n/src/main/java/org/apache/directory/server/i18n/I18n.java
    directory/apacheds/trunk/i18n/src/main/resources/org/apache/directory/server/i18n/errors.properties
    directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/AbstractStore.java
    directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/api/LdapDecoder.java

Modified: directory/apacheds/trunk/i18n/src/main/java/org/apache/directory/server/i18n/I18n.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/i18n/src/main/java/org/apache/directory/server/i18n/I18n.java?rev=1143581&r1=1143580&r2=1143581&view=diff
==============================================================================
--- directory/apacheds/trunk/i18n/src/main/java/org/apache/directory/server/i18n/I18n.java (original)
+++ directory/apacheds/trunk/i18n/src/main/java/org/apache/directory/server/i18n/I18n.java Wed Jul  6 22:10:02 2011
@@ -249,7 +249,7 @@ public enum I18n
     ERR_213("ERR_213"),
     ERR_214("ERR_214"),
     ERR_215("ERR_215"),
-    ERR_216("ERR_216"),
+    ERR_216_ID_FOR_PARENT_NOT_FOUND("ERR_216_ID_FOR_PARENT_NOT_FOUND"),
     ERR_217("ERR_217"),
     ERR_218("ERR_218"),
     ERR_219("ERR_219"),

Modified: directory/apacheds/trunk/i18n/src/main/resources/org/apache/directory/server/i18n/errors.properties
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/i18n/src/main/resources/org/apache/directory/server/i18n/errors.properties?rev=1143581&r1=1143580&r2=1143581&view=diff
==============================================================================
--- directory/apacheds/trunk/i18n/src/main/resources/org/apache/directory/server/i18n/errors.properties (original)
+++ directory/apacheds/trunk/i18n/src/main/resources/org/apache/directory/server/i18n/errors.properties Wed Jul  6 22:10:02 2011
@@ -237,7 +237,7 @@ ERR_212=No Normalizer present for attrib
 ERR_213=in memory index cannot store the data on disk
 ERR_214=in memory index doesn''t support explicit caching
 ERR_215=Cannot store a ClonedServerEntry
-ERR_216=Id for parent ''{0}'' not found!
+ERR_216_ID_FOR_PARENT_NOT_FOUND=Id for parent ''{0}'' not found!
 ERR_217=Entry {0} contains no objectClass attribute: {1}
 ERR_218=Not a normalized name: {0}
 ERR_219=Entry {0} contains no entryCsn attribute: {1}

Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/AbstractStore.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/AbstractStore.java?rev=1143581&r1=1143580&r2=1143581&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/AbstractStore.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/AbstractStore.java Wed Jul  6 22:10:02 2011
@@ -843,14 +843,22 @@ public abstract class AbstractStore<E, I
 
         return cursor;
     }
-
-
+    
+    
     /**
      * {@inheritDoc}
      * 
      * Adding an entryinvolve may steps :
-     * - fist we must check if the entry exists or not (note that it should probably
-     * be checked higher, but not sure)
+     * - first we must check if the entry exists or not
+     * - then we must get a new ID for the added entry
+     * - update the RDN index
+     * - update the oneLevel index
+     * - update the subLevel index
+     * - update the ObjectClass index
+     * - update the entryCsn index
+     * - update the entryUuid index
+     * - update the user's index
+     * 
      * TODO : We should be able to revert all the changes made to index
      * if something went wrong. Also the index should auto-repair : if
      * an entry does not exist in the Master table, then the index must be updated to reflect this.
@@ -868,7 +876,7 @@ public abstract class AbstractStore<E, I
             throw ne;
         }
 
-        ID parentId;
+        ID parentId = null;
 
         //
         // Suffix entry cannot have a parent since it is the root so it is
@@ -888,26 +896,24 @@ public abstract class AbstractStore<E, I
             parentDn = entryDn.getParent();
             parentId = getEntryId( parentDn );
             
-            if ( parentId == null )
-            {
-                parentId = getEntryId( parentDn );
-            }
-            
             key = new ParentIdAndRdn<ID>( parentId, entryDn.getRdn() );
         }
 
         // don't keep going if we cannot find the parent Id
         if ( parentId == null )
         {
-            throw new LdapNoSuchObjectException( I18n.err( I18n.ERR_216, parentDn ) );
+            throw new LdapNoSuchObjectException( I18n.err( I18n.ERR_216_ID_FOR_PARENT_NOT_FOUND, parentDn ) );
         }
-
+        
+        // Get a new ID for the added entry
         ID id = master.getNextId( entry );
 
+        // Update the RDN index
         rdnIdx.add( key, id );
 
+        // Update the ObjectClass index
         Attribute objectClass = entry.get( OBJECT_CLASS_AT );
-
+        
         if ( objectClass == null )
         {
             String msg = I18n.err( I18n.ERR_217, entryDn.getName(), entry );
@@ -917,9 +923,6 @@ public abstract class AbstractStore<E, I
             throw e;
         }
 
-        // Start adding the system userIndices
-        // Why bother doing a lookup if this is not an alias.
-        // First, the ObjectClass index
         for ( Value<?> value : objectClass )
         {
             objectClassIdx.add( value.getString(), id );
@@ -931,12 +934,20 @@ public abstract class AbstractStore<E, I
             addAliasIndices( id, entryDn, aliasAttr.getString() );
         }
 
-        if ( !Character.isDigit( entryDn.getNormName().charAt( 0 ) ) )
+        // Update the OneLevel index
+        oneLevelIdx.add( parentId, id );
+
+        // Update the SubLevel index
+        ID tempId = parentId;
+
+        while ( ( tempId != null ) && ( !tempId.equals( getRootId() ) ) && ( !tempId.equals( getSuffixId() ) ) )
         {
-            throw new IllegalStateException( I18n.err( I18n.ERR_218, entryDn.getNormName() ) );
+            subLevelIdx.add( tempId, id );
+            tempId = getParentId( tempId );
         }
 
-        oneLevelIdx.add( parentId, id );
+        // making entry an ancestor/descendent of itself in sublevel index
+        subLevelIdx.add( id, id );
 
         // Update the EntryCsn index
         Attribute entryCsn = entry.get( ENTRY_CSN_AT );
@@ -960,17 +971,6 @@ public abstract class AbstractStore<E, I
 
         entryUuidIdx.add( entryUuid.getString(), id );
 
-        ID tempId = parentId;
-
-        while ( ( tempId != null ) && ( !tempId.equals( getRootId() ) ) && ( !tempId.equals( getSuffixId() ) ) )
-        {
-            subLevelIdx.add( tempId, id );
-            tempId = getParentId( tempId );
-        }
-
-        // making entry an ancestor/descendent of itself in sublevel index
-        subLevelIdx.add( id, id );
-
         // Now work on the user defined userIndices
         for ( Attribute attribute : entry )
         {
@@ -993,8 +993,10 @@ public abstract class AbstractStore<E, I
             }
         }
 
+        // Add the parentId in the entry
         entry.put( SchemaConstants.ENTRY_PARENT_ID_AT, parentId.toString() );
         
+        // And finally add the entry into the master table
         master.put( id, entry );
 
         if ( isSyncOnWrite.get() )

Modified: directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/api/LdapDecoder.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/api/LdapDecoder.java?rev=1143581&r1=1143580&r2=1143581&view=diff
==============================================================================
--- directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/api/LdapDecoder.java (original)
+++ directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/api/LdapDecoder.java Wed Jul  6 22:10:02 2011
@@ -128,14 +128,11 @@ public class LdapDecoder
         {
             try
             {
-                asn1Decoder.decode( buffer, messageContainer );
-
                 if ( IS_DEBUG )
                 {
                     LOG.debug( "Decoding the PDU : " );
 
-                    int size = buffer.position();
-                    buffer.reset();
+                    int size = buffer.limit();
                     int position = buffer.position();
                     int pduLength = size - position;
 
@@ -153,9 +150,11 @@ public class LdapDecoder
                     {
                         LOG.debug( Strings.dumpBytes(array) );
                     }
+
+                    buffer.reset();
                 }
 
-                buffer.mark();
+                asn1Decoder.decode( buffer, messageContainer );
 
                 if ( messageContainer.getState() == TLVStateEnum.PDU_DECODED )
                 {