directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1484055 - /directory/shared/trunk/ldap/schema/data/src/main/java/org/apache/directory/api/ldap/schemaextractor/impl/ResourceMap.java
Date Sat, 18 May 2013 04:47:29 GMT
Author: elecharny
Date: Sat May 18 04:47:29 2013
New Revision: 1484055

URL: http://svn.apache.org/r1484055
Log:
o Added some logging when we have errors
o Don't stop on error
(DIRSERVER-1491)

Modified:
    directory/shared/trunk/ldap/schema/data/src/main/java/org/apache/directory/api/ldap/schemaextractor/impl/ResourceMap.java

Modified: directory/shared/trunk/ldap/schema/data/src/main/java/org/apache/directory/api/ldap/schemaextractor/impl/ResourceMap.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/schema/data/src/main/java/org/apache/directory/api/ldap/schemaextractor/impl/ResourceMap.java?rev=1484055&r1=1484054&r2=1484055&view=diff
==============================================================================
--- directory/shared/trunk/ldap/schema/data/src/main/java/org/apache/directory/api/ldap/schemaextractor/impl/ResourceMap.java
(original)
+++ directory/shared/trunk/ldap/schema/data/src/main/java/org/apache/directory/api/ldap/schemaextractor/impl/ResourceMap.java
Sat May 18 04:47:29 2013
@@ -60,7 +60,7 @@ public final class ResourceMap
 
 
     /**
-     * Private contstructor.
+     * Private constructor.
      */
     private ResourceMap()
     {
@@ -88,6 +88,7 @@ public final class ResourceMap
             LOG.debug( "loading from the user provider schema resource {}", schemaResourceLoc
);
 
             File file = new File( schemaResourceLoc );
+
             if ( file.exists() )
             {
                 getResources( retval, schemaResourceLoc, pattern );
@@ -110,10 +111,12 @@ public final class ResourceMap
         String element, Pattern pattern )
     {
         File file = new File( element );
+
         if ( !file.exists() )
         {
             // this may happen if the class path contains an element that doesn't exist
             LOG.debug( "element {} does not exist", element );
+
             return;
         }
 
@@ -195,7 +198,9 @@ public final class ResourceMap
                 }
                 catch ( IOException e )
                 {
-                    throw new Error( e );
+                    LOG.error( "Cannot load file {} : {}", file.getAbsolutePath(), e.getMessage()
);
+
+                    // Continue...
                 }
             }
         }
@@ -208,28 +213,43 @@ public final class ResourceMap
         {
             ClassLoader cl = ResourceMap.class.getClassLoader();
             Enumeration<URL> indexes = cl.getResources( "META-INF/apacheds-schema.index"
);
+
             while ( indexes.hasMoreElements() )
             {
-                URL index = indexes.nextElement();
-                InputStream in = index.openStream();
-                BufferedReader reader = new BufferedReader( new InputStreamReader( in, "UTF-8"
) );
-                String line = reader.readLine();
-                while ( line != null )
+                URL index = null;
+
+                try
                 {
-                    boolean accept = pattern.matcher( line ).matches();
-                    if ( accept )
+                    index = indexes.nextElement();
+                    InputStream in = index.openStream();
+                    BufferedReader reader = new BufferedReader( new InputStreamReader( in,
"UTF-8" ) );
+                    String line = reader.readLine();
+
+                    while ( line != null )
                     {
-                        map.put( line, Boolean.TRUE );
+                        boolean accept = pattern.matcher( line ).matches();
+
+                        if ( accept )
+                        {
+                            map.put( line, Boolean.TRUE );
+                        }
+
+                        line = reader.readLine();
                     }
-                    line = reader.readLine();
+
+                    reader.close();
+                }
+                catch ( IOException ioe )
+                {
+                    LOG.debug( "Cannot load resource {} : {}", index, ioe.getMessage() );
+                    // Continue...
                 }
-                reader.close();
             }
         }
         catch ( IOException e )
         {
+            LOG.debug( "Error while loading  resuce from class loaded : {}", e.getMessage()
);
             throw new Error( e );
         }
     }
-
 }



Mime
View raw message