directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1149581 - in /directory/apacheds/trunk: core-api/src/main/java/org/apache/directory/server/core/partition/ ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/ ldif-partition/src/test/java/org/apache/directory/serv...
Date Fri, 22 Jul 2011 12:09:11 GMT
Author: elecharny
Date: Fri Jul 22 12:09:09 2011
New Revision: 1149581

URL: http://svn.apache.org/viewvc?rev=1149581&view=rev
Log:
o Removed the ContextEntry field from AbstractPartition : it's useless
o Added some missing Javadoc

Modified:
    directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/partition/AbstractPartition.java
    directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/partition/Partition.java
    directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/LdifPartition.java
    directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/SingleFileLdifPartition.java
    directory/apacheds/trunk/ldif-partition/src/test/java/org/apache/directory/server/core/partition/LdifPartitionTest.java
    directory/apacheds/trunk/ldif-partition/src/test/java/org/apache/directory/server/core/partition/SingleFileLdifPartitionTest.java
    directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/ReadOnlyConfigurationPartition.java
    directory/apacheds/trunk/service-builder/src/main/java/org/apache/directory/server/config/ServiceBuilder.java

Modified: directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/partition/AbstractPartition.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/partition/AbstractPartition.java?rev=1149581&r1=1149580&r2=1149581&view=diff
==============================================================================
--- directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/partition/AbstractPartition.java
(original)
+++ directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/partition/AbstractPartition.java
Fri Jul 22 12:09:09 2011
@@ -26,7 +26,6 @@ import java.io.OutputStream;
 import javax.naming.InvalidNameException;
 
 import org.apache.directory.server.i18n.I18n;
-import org.apache.directory.shared.ldap.model.entry.Entry;
 import org.apache.directory.shared.ldap.model.exception.LdapException;
 import org.apache.directory.shared.ldap.model.exception.LdapInvalidDnException;
 import org.apache.directory.shared.ldap.model.exception.LdapOtherException;
@@ -50,25 +49,14 @@ public abstract class AbstractPartition 
     /** The SchemaManager instance */
     protected SchemaManager schemaManager;
     
-    /** The partition ContextEntry */
-    protected Entry contextEntry;
-
     /** The partition ID */
     protected String id;
     
     /** The root Dn for this partition */
     protected Dn suffixDn;
 
-    protected AbstractPartition()
-    {
-    }
-    
-    
     /**
-     * Sets up (<tt>directoryService</tt> and calls {@link #doInit()} where you
have to put your
-     * initialization code in.  {@link #isInitialized()} will return <tt>true</tt>
if
-     * {@link #doInit()} returns without any errors.  {@link #destroy()} is called automatically
-     * as a clean-up process if {@link #doInit()} throws an exception.
+     * {@inheritDoc}
      */
     public void initialize( ) throws LdapException
     {
@@ -102,7 +90,6 @@ public abstract class AbstractPartition 
             }
         }
     }
-    
 
 
     /**
@@ -137,7 +124,7 @@ public abstract class AbstractPartition 
 
 
     /**
-     * Returns <tt>true</tt> if this context partition is initialized successfully.
+     * {@inheritDoc}
      */
     public final boolean isInitialized()
     {
@@ -208,24 +195,6 @@ public abstract class AbstractPartition 
     
     
     /**
-     * @return the contextEntry
-     */
-    public Entry getContextEntry()
-    {
-        return contextEntry;
-    }
-
-
-    /**
-     * @param contextEntry the contextEntry to set
-     */
-    public void setContextEntry( Entry contextEntry )
-    {
-        this.contextEntry = contextEntry;
-    }
-    
-    
-    /**
      * {@inheritDoc}
      */
     public void dumpIndex( OutputStream stream, String name ) throws IOException

Modified: directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/partition/Partition.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/partition/Partition.java?rev=1149581&r1=1149580&r2=1149581&view=diff
==============================================================================
--- directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/partition/Partition.java
(original)
+++ directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/partition/Partition.java
Fri Jul 22 12:09:09 2011
@@ -94,7 +94,9 @@ public interface Partition
     // -----------------------------------------------------------------------
 
     /**
-     * Initializes this partition.
+     * Initializes this partition. {@link #isInitialized()} will return <tt>true</tt>
if
+     * {@link #doInit()} returns without any errors.  {@link #destroy()} is called automatically
+     * as a clean-up process if {@link #doInit()} throws an exception.
      *
      * @throws Exception if initialization fails in any way
      */

Modified: directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/LdifPartition.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/LdifPartition.java?rev=1149581&r1=1149580&r2=1149581&view=diff
==============================================================================
--- directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/LdifPartition.java
(original)
+++ directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/LdifPartition.java
Fri Jul 22 12:09:09 2011
@@ -43,7 +43,6 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.model.exception.LdapException;
 import org.apache.directory.shared.ldap.model.exception.LdapInvalidDnException;
 import org.apache.directory.shared.ldap.model.exception.LdapOperationException;
-import org.apache.directory.shared.ldap.model.ldif.LdapLdifException;
 import org.apache.directory.shared.ldap.model.ldif.LdifEntry;
 import org.apache.directory.shared.ldap.model.ldif.LdifReader;
 import org.apache.directory.shared.ldap.model.ldif.LdifUtils;
@@ -180,36 +179,27 @@ public class LdifPartition extends Abstr
     
                 LOG.info( "ldif file doesn't exist {}, creating it.", contextEntryFile.getAbsolutePath()
);
     
-                if ( contextEntry == null )
+                if ( contextEntryFile.exists() )
                 {
-                    if ( contextEntryFile.exists() )
+                    LdifReader reader = new LdifReader( contextEntryFile );
+                    Entry contextEntry = new DefaultEntry( schemaManager, reader.next().getEntry()
);
+                    reader.close();
+                    
+                    if ( contextEntry.get( SchemaConstants.ENTRY_CSN_AT ) == null )
                     {
-                        LdifReader reader = new LdifReader( contextEntryFile );
-                        contextEntry = new DefaultEntry( schemaManager, reader.next().getEntry()
);
-                        reader.close();
+                        contextEntry.add( SchemaConstants.ENTRY_CSN_AT, defaultCSNFactory.newInstance().toString()
);
                     }
-                    else
+        
+                    if ( contextEntry.get( SchemaConstants.ENTRY_UUID_AT ) == null )
                     {
-                        // No context entry and no LDIF file exists.
-                        // Skip initialization of context entry here, it will be added later.
-                        return;
+                        String uuid = UUID.randomUUID().toString();
+                        contextEntry.add( SchemaConstants.ENTRY_UUID_AT, uuid );
                     }
+        
+                    // And add this entry to the underlying partition
+                    AddOperationContext addContext = new AddOperationContext( null, contextEntry
);
+                    add( addContext );
                 }
-    
-                if ( contextEntry.get( SchemaConstants.ENTRY_CSN_AT ) == null )
-                {
-                    contextEntry.add( SchemaConstants.ENTRY_CSN_AT, defaultCSNFactory.newInstance().toString()
);
-                }
-    
-                if ( contextEntry.get( SchemaConstants.ENTRY_UUID_AT ) == null )
-                {
-                    String uuid = UUID.randomUUID().toString();
-                    contextEntry.add( SchemaConstants.ENTRY_UUID_AT, uuid );
-                }
-    
-                // And add this entry to the underlying partition
-                AddOperationContext addContext = new AddOperationContext( null, contextEntry
);
-                add( addContext );
             }
         }
     }
@@ -728,32 +718,4 @@ public class LdifPartition extends Abstr
             return file.delete();
         }
     }
-
-
-    /**
-     * @param contextEntry the contextEntry to set
-     */
-    public void setContextEntry( String contextEntry ) throws LdapLdifException
-    {
-        LdifReader ldifReader = new LdifReader();
-        List<LdifEntry> entries = ldifReader.parseLdif( contextEntry );
-
-        try
-        {
-            ldifReader.close();
-        }
-        catch ( IOException ioe )
-        {
-            // What can we do here ???
-        }
-
-        try
-        { 
-            this.contextEntry = new DefaultEntry( schemaManager, entries.get( 0 ).getEntry()
);
-        }
-        catch ( LdapException le )
-        {
-            throw new LdapLdifException( le.getMessage(), le );
-        }
-    }
 }
\ No newline at end of file

Modified: directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/SingleFileLdifPartition.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/SingleFileLdifPartition.java?rev=1149581&r1=1149580&r2=1149581&view=diff
==============================================================================
--- directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/SingleFileLdifPartition.java
(original)
+++ directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/SingleFileLdifPartition.java
Fri Jul 22 12:09:09 2011
@@ -146,7 +146,7 @@ public class SingleFileLdifPartition ext
 
         LdifEntry ldifEntry = itr.next();
 
-        contextEntry = new DefaultEntry( schemaManager, ldifEntry.getEntry() );
+        Entry contextEntry = new DefaultEntry( schemaManager, ldifEntry.getEntry() );
 
         if ( suffixDn.equals( contextEntry.getDn() ) )
         {
@@ -188,16 +188,6 @@ public class SingleFileLdifPartition ext
         {
             super.add( addContext );
 
-            if ( contextEntry == null )
-            {
-                Entry entry = addContext.getEntry();
-
-                if ( entry.getDn().equals( suffixDn ) )
-                {
-                    contextEntry = entry;
-                }
-            }
-
             dirty = true;
             rewritePartitionData();
         }
@@ -304,7 +294,6 @@ public class SingleFileLdifPartition ext
 
                 if( suffixId == null )
                 {
-                    contextEntry = null;
                     return;
                 }
                 

Modified: directory/apacheds/trunk/ldif-partition/src/test/java/org/apache/directory/server/core/partition/LdifPartitionTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldif-partition/src/test/java/org/apache/directory/server/core/partition/LdifPartitionTest.java?rev=1149581&r1=1149580&r2=1149581&view=diff
==============================================================================
--- directory/apacheds/trunk/ldif-partition/src/test/java/org/apache/directory/server/core/partition/LdifPartitionTest.java
(original)
+++ directory/apacheds/trunk/ldif-partition/src/test/java/org/apache/directory/server/core/partition/LdifPartitionTest.java
Fri Jul 22 12:09:09 2011
@@ -125,12 +125,6 @@ public class LdifPartitionTest
     @Before
     public void createStore() throws Exception
     {
-        String contextEntry =
-            "dn: ou=test, ou=system\n" +
-                "objectclass: organizationalUnit\n" +
-                "objectclass: top\n" +
-                "ou: test";
-
         // setup the working directory for the store
         wkdir = folder.newFile( "db" );
         wkdir = folder.getRoot();
@@ -143,8 +137,15 @@ public class LdifPartitionTest
         partition.setSchemaManager( schemaManager );
         partition.setPartitionPath( wkdir.toURI() );
 
-        partition.setContextEntry( contextEntry );
         partition.initialize();
+        
+        Entry entry = createEntry( "ou=test, ou=system" );
+        
+        entry.put( "objectClass", "top", "organizationalUnit" );
+        entry.put(  "cn", "test" );
+        
+        AddOperationContext addContext = new AddOperationContext( null, entry );
+        partition.add( addContext );
 
         LOG.debug( "Created new LDIF partition" );
     }

Modified: directory/apacheds/trunk/ldif-partition/src/test/java/org/apache/directory/server/core/partition/SingleFileLdifPartitionTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldif-partition/src/test/java/org/apache/directory/server/core/partition/SingleFileLdifPartitionTest.java?rev=1149581&r1=1149580&r2=1149581&view=diff
==============================================================================
--- directory/apacheds/trunk/ldif-partition/src/test/java/org/apache/directory/server/core/partition/SingleFileLdifPartitionTest.java
(original)
+++ directory/apacheds/trunk/ldif-partition/src/test/java/org/apache/directory/server/core/partition/SingleFileLdifPartitionTest.java
Fri Jul 22 12:09:09 2011
@@ -555,7 +555,6 @@ public class SingleFileLdifPartitionTest
         RandomAccessFile file = new RandomAccessFile( new File( partition.getPartitionPath()
), "r" );
 
         assertEquals( 0L, file.length() );
-        assertNull( partition.getContextEntry() );
 
         addCtx = new AddOperationContext( mockSession );
         addCtx.setEntry( contextEntry );

Modified: directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/ReadOnlyConfigurationPartition.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/ReadOnlyConfigurationPartition.java?rev=1149581&r1=1149580&r2=1149581&view=diff
==============================================================================
--- directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/ReadOnlyConfigurationPartition.java
(original)
+++ directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/ReadOnlyConfigurationPartition.java
Fri Jul 22 12:09:09 2011
@@ -116,7 +116,7 @@ public class ReadOnlyConfigurationPartit
 
             // Getting the context entry
             LdifEntry ldifEntry = itr.next();
-            contextEntry = new DefaultEntry( schemaManager, ldifEntry.getEntry() );
+            Entry contextEntry = new DefaultEntry( schemaManager, ldifEntry.getEntry() );
 
             // Checking the context entry
             if ( suffixDn.equals( contextEntry.getDn() ) )

Modified: directory/apacheds/trunk/service-builder/src/main/java/org/apache/directory/server/config/ServiceBuilder.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/service-builder/src/main/java/org/apache/directory/server/config/ServiceBuilder.java?rev=1149581&r1=1149580&r2=1149581&view=diff
==============================================================================
--- directory/apacheds/trunk/service-builder/src/main/java/org/apache/directory/server/config/ServiceBuilder.java
(original)
+++ directory/apacheds/trunk/service-builder/src/main/java/org/apache/directory/server/config/ServiceBuilder.java
Fri Jul 22 12:09:09 2011
@@ -1176,7 +1176,6 @@ public class ServiceBuilder
                 if ( ( entries != null ) && ( entries.size() > 0 ) )
                 {
                     LdifEntry entry = entries.get( 0 );
-                    jdbmPartition.setContextEntry( entry.getEntry() );
                 }
             }
             catch ( LdapLdifException lle )



Mime
View raw message