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 2009/02/23 11:27:10 UTC

svn commit: r746949 - /directory/apacheds/trunk/server-integ/src/main/java/org/apache/directory/server/integ/state/AbstractState.java

Author: elecharny
Date: Mon Feb 23 10:27:09 2009
New Revision: 746949

URL: http://svn.apache.org/viewvc?rev=746949&view=rev
Log:
Added some check to fix DIRSERVER-1313

Modified:
    directory/apacheds/trunk/server-integ/src/main/java/org/apache/directory/server/integ/state/AbstractState.java

Modified: directory/apacheds/trunk/server-integ/src/main/java/org/apache/directory/server/integ/state/AbstractState.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/main/java/org/apache/directory/server/integ/state/AbstractState.java?rev=746949&r1=746948&r2=746949&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/main/java/org/apache/directory/server/integ/state/AbstractState.java (original)
+++ directory/apacheds/trunk/server-integ/src/main/java/org/apache/directory/server/integ/state/AbstractState.java Mon Feb 23 10:27:09 2009
@@ -20,6 +20,7 @@
 
 
 import java.io.File;
+import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.StringReader;
 import java.net.URI;
@@ -190,8 +191,36 @@
             for ( String ldifFile:ldifFiles )
             {
                 String className = settings.getParent().getDescription().getDisplayName();
-                Class<?> clazz = Class.forName( className );
+                
+                if ( className == null )
+                {
+                    String message = "Cannot inject a LDIF file with a null name";
+                    LOG.error( message );
+                    throw new FileNotFoundException( message );
+                }
+                
+                Class<?> clazz = null;
+                
+                try
+                {
+                    clazz = Class.forName( className );
+                }
+                catch ( ClassNotFoundException cnfe )
+                {
+                    String message = "Cannot inject a LDIF file for this class : " + className;
+                    LOG.error( message );
+                    throw new FileNotFoundException( message );
+                }
+                
                 URL url = clazz.getResource( ldifFile );
+
+                if ( url == null )
+                {
+                    String message = "Cannot inject a LDIF for the file " + ldifFile;
+                    LOG.error( message );
+                    throw new FileNotFoundException( message );
+                }
+                
                 URI uri = url.toURI();
                 File file = new File( uri );