directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1805441 - /directory/studio/branches/studio-value/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/OpenLdapSchemaLoader.java
Date Fri, 18 Aug 2017 16:04:27 GMT
Author: elecharny
Date: Fri Aug 18 16:04:27 2017
New Revision: 1805441

URL: http://svn.apache.org/viewvc?rev=1805441&view=rev
Log:
o Passed the SchemaLoader as an argument to the DefaultSchema, in order to be able to load
it
o Fixed Sonar warnings
o Used try-with-resource

Modified:
    directory/studio/branches/studio-value/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/OpenLdapSchemaLoader.java

Modified: directory/studio/branches/studio-value/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/OpenLdapSchemaLoader.java
URL: http://svn.apache.org/viewvc/directory/studio/branches/studio-value/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/OpenLdapSchemaLoader.java?rev=1805441&r1=1805440&r2=1805441&view=diff
==============================================================================
--- directory/studio/branches/studio-value/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/OpenLdapSchemaLoader.java
(original)
+++ directory/studio/branches/studio-value/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/OpenLdapSchemaLoader.java
Fri Aug 18 16:04:27 2017
@@ -56,10 +56,10 @@ public class OpenLdapSchemaLoader extend
         Pattern.CASE_INSENSITIVE );
 
     /** The attribute types entries */
-    private List<Entry> attributeTypesEntries = new ArrayList<Entry>();
+    private List<Entry> attributeTypesEntries = new ArrayList<>();
 
     /** The object classes entries */
-    private List<Entry> objectClassesEntries = new ArrayList<Entry>();
+    private List<Entry> objectClassesEntries = new ArrayList<>();
 
 
     /**
@@ -80,9 +80,8 @@ public class OpenLdapSchemaLoader extend
      */
     private void initializeSchema()
     {
-        Schema schema = new DefaultSchema( null, OPENLDAPCONFIG_SCHEMA_NAME );
-        schema.addDependencies( new String[]
-            { "system", "core", "apache" } );
+        Schema schema = new DefaultSchema( this, OPENLDAPCONFIG_SCHEMA_NAME );
+        schema.addDependencies( "system", "core", "apache" );
         schemaMap.put( schema.getSchemaName(), schema );
     }
 
@@ -90,17 +89,14 @@ public class OpenLdapSchemaLoader extend
     /**
      * Initializes the schema objects.
      *
-     * @throws Exception
+     * @throws LdapException If we weren't able to process the LDIF file
+     * @throws IOException If we had an issue reading the ldif file
      */
-    private void initializeSchemaObjects() throws Exception
+    private void initializeSchemaObjects() throws LdapException, IOException
     {
-        LdifReader ldifReader = null;
-
-        try
+        // Reading the schema file
+        try ( LdifReader ldifReader = new LdifReader( OpenLdapSchemaLoader.class.getResourceAsStream(
OPENLDAPCONFIG_SHEMA_LDIF ) ) )
         {
-            // Reading the schema file
-            ldifReader = new LdifReader( OpenLdapSchemaLoader.class.getResourceAsStream(
OPENLDAPCONFIG_SHEMA_LDIF ) );
-
             // Looping on all entries
             while ( ldifReader.hasNext() )
             {
@@ -120,20 +116,13 @@ public class OpenLdapSchemaLoader extend
                 }
             }
         }
-        finally
-        {
-            // Closing the LDIF reader
-            if ( ldifReader != null )
-            {
-                ldifReader.close();
-            }
-        }
     }
 
 
     /**
      * {@inheritDoc}
      */
+    @Override
     public List<Entry> loadAttributeTypes( Schema... schemas ) throws LdapException,
IOException
     {
         // Getting the attribute types from the supertype implementation
@@ -156,6 +145,7 @@ public class OpenLdapSchemaLoader extend
     /**
      * {@inheritDoc}
      */
+    @Override
     public List<Entry> loadObjectClasses( Schema... schemas ) throws LdapException,
IOException
     {
         // Getting the object classes from the supertype implementation



Mime
View raw message