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 2016/11/29 10:07:54 UTC

svn commit: r1771874 - in /directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model: cursor/ entry/ ldif/ message/ name/ schema/registries/ subtree/ url/

Author: elecharny
Date: Tue Nov 29 10:07:54 2016
New Revision: 1771874

URL: http://svn.apache.org/viewvc?rev=1771874&view=rev
Log:
o Fixed Sonarlint warnings

Modified:
    directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/cursor/CursorIterator.java
    directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/Attribute.java
    directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/DefaultEntry.java
    directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifReader.java
    directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifRevertor.java
    directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifUtils.java
    directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/AbstractResultResponse.java
    directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/ReferralImpl.java
    directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/ResultCodeEnum.java
    directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/name/Ava.java
    directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/name/Rdn.java
    directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/OidRegistry.java
    directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/Registries.java
    directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/subtree/BaseSubtreeSpecification.java
    directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/subtree/Subentry.java
    directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/subtree/SubtreeSpecificationChecker.java
    directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/subtree/SubtreeSpecificationModifier.java
    directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/subtree/SubtreeSpecificationParser.java
    directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/url/LdapUrl.java

Modified: directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/cursor/CursorIterator.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/cursor/CursorIterator.java?rev=1771874&r1=1771873&r2=1771874&view=diff
==============================================================================
--- directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/cursor/CursorIterator.java (original)
+++ directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/cursor/CursorIterator.java Tue Nov 29 10:07:54 2016
@@ -81,6 +81,7 @@ public class CursorIterator<E> implement
         {
             E element = cursor.get();
             available = cursor.next();
+            
             return element;
         }
         catch ( Exception e )

Modified: directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/Attribute.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/Attribute.java?rev=1771874&r1=1771873&r2=1771874&view=diff
==============================================================================
--- directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/Attribute.java (original)
+++ directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/Attribute.java Tue Nov 29 10:07:54 2016
@@ -378,7 +378,7 @@ public interface Attribute extends Itera
      * @throws IllegalArgumentException If the ID is empty or null or
      * resolve to an empty value after being trimmed
      */
-    void setUpId( String upId ) throws IllegalArgumentException;
+    void setUpId( String upId );
 
 
     /**

Modified: directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/DefaultEntry.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/DefaultEntry.java?rev=1771874&r1=1771873&r2=1771874&view=diff
==============================================================================
--- directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/DefaultEntry.java (original)
+++ directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/DefaultEntry.java Tue Nov 29 10:07:54 2016
@@ -399,26 +399,13 @@ public final class DefaultEntry implemen
                 .err( I18n.ERR_12087 ) );
         }
 
-        LdifAttributesReader reader = null;
-
-        try
+        try ( LdifAttributesReader reader = new LdifAttributesReader() )
         {
-            reader = new LdifAttributesReader();
-
             return reader.parseEntry( schemaManager, sb.toString() );
         }
-        finally
+        catch ( IOException e )
         {
-            try
-            {
-                if ( reader != null )
-                {
-                    reader.close();
-                }
-            }
-            catch ( IOException e )
-            {
-            }
+            throw new LdapLdifException( "Cannot read an entry" );
         }
     }
 

Modified: directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifReader.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifReader.java?rev=1771874&r1=1771873&r2=1771874&view=diff
==============================================================================
--- directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifReader.java (original)
+++ directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifReader.java Tue Nov 29 10:07:54 2016
@@ -277,35 +277,6 @@ public class LdifReader implements Itera
 
 
     /**
-     * Store the reader and intialize the LdifReader
-     */
-    private void initReader( BufferedReader reader ) throws LdapException
-    {
-        this.reader = reader;
-        init();
-    }
-
-
-    /**
-     * Initialize the LdifReader
-     * 
-     * @throws LdapException If the initialization failed
-     */
-    public void init() throws LdapException
-    {
-        lines = new ArrayList<String>();
-        position = 0;
-        version = DEFAULT_VERSION;
-        containsChanges = false;
-        containsEntries = false;
-
-        // First get the version - if any -
-        version = parseVersion();
-        prefetched = parseEntry();
-    }
-
-
-    /**
      * A constructor which takes a file name. Default charset is used.
      *
      * @param ldifFileName A file name containing ldif formated input
@@ -401,6 +372,35 @@ public class LdifReader implements Itera
 
 
     /**
+     * Store the reader and intialize the LdifReader
+     */
+    private void initReader( BufferedReader reader ) throws LdapException
+    {
+        this.reader = reader;
+        init();
+    }
+
+
+    /**
+     * Initialize the LdifReader
+     * 
+     * @throws LdapException If the initialization failed
+     */
+    public void init() throws LdapException
+    {
+        lines = new ArrayList<>();
+        position = 0;
+        version = DEFAULT_VERSION;
+        containsChanges = false;
+        containsEntries = false;
+
+        // First get the version - if any -
+        version = parseVersion();
+        prefetched = parseEntry();
+    }
+
+
+    /**
      * @return The ldif file version
      */
     public int getVersion()
@@ -691,11 +691,9 @@ public class LdifReader implements Itera
                             else
                             {
                                 byte[] data = new byte[( int ) length];
-                                DataInputStream inf = null;
 
-                                try
+                                try ( DataInputStream inf = new DataInputStream( new FileInputStream( file ) ) )
                                 {
-                                    inf = new DataInputStream( new FileInputStream( file ) );
                                     inf.readFully( data );
 
                                     return getValue( attributeName, data );
@@ -714,23 +712,6 @@ public class LdifReader implements Itera
                                     LOG.error( I18n.err( I18n.ERR_12022_ERROR_READING_FILE, fileName, lineNumber ) );
                                     throw new LdapLdifException( I18n.err( I18n.ERR_12023_ERROR_READING_BAD_URL ), ioe );
                                 }
-                                finally
-                                {
-                                    try
-                                    {
-                                        if ( inf != null )
-                                        {
-                                            inf.close();
-                                        }
-                                    }
-                                    catch ( IOException ioe )
-                                    {
-                                        LOG.error(
-                                            I18n.err( I18n.ERR_12024_CANNOT_CLOSE_FILE, ioe.getMessage(), lineNumber ),
-                                            ioe );
-                                        // Just do nothing ...
-                                    }
-                                }
                             }
                         }
                     }
@@ -985,7 +966,7 @@ public class LdifReader implements Itera
         String attributeType = lowerLine.substring( 0, colonIndex );
 
         // We should *not* have a Dn twice
-        if ( attributeType.equals( "dn" ) )
+        if ( "dn".equals( attributeType ) )
         {
             LOG.error( I18n.err( I18n.ERR_12002_ENTRY_WITH_TWO_DNS, lineNumber ) );
             throw new LdapLdifException( I18n.err( I18n.ERR_12003_LDIF_ENTRY_WITH_TWO_DNS ) );
@@ -1239,7 +1220,7 @@ public class LdifReader implements Itera
                 }
 
                 // We should *not* have a Dn twice
-                if ( attributeType.equalsIgnoreCase( "dn" ) )
+                if ( "dn".equalsIgnoreCase( attributeType ) )
                 {
                     LOG.error( I18n.err( I18n.ERR_12002_ENTRY_WITH_TWO_DNS, lineNumber ) );
                     throw new LdapLdifException( I18n.err( I18n.ERR_12003_LDIF_ENTRY_WITH_TWO_DNS ) );
@@ -1400,7 +1381,7 @@ public class LdifReader implements Itera
      */
     protected LdifEntry parseEntry() throws LdapException
     {
-        if ( ( lines == null ) || ( lines.size() == 0 ) )
+        if ( ( lines == null ) || lines.isEmpty() )
         {
             LOG.debug( "The entry is empty : end of ldif file" );
             return null;
@@ -1590,7 +1571,7 @@ public class LdifReader implements Itera
         // First, read a list of lines
         readLines();
 
-        if ( lines.size() == 0 )
+        if ( lines.isEmpty() )
         {
             LOG.warn( "The ldif file is empty" );
             return ver;
@@ -1634,7 +1615,7 @@ public class LdifReader implements Itera
             lines.remove( 0 );
 
             // and read the next lines if the current buffer is empty
-            if ( lines.size() == 0 )
+            if ( lines.isEmpty() )
             {
                 // include the version line as part of the first entry
                 int tmpEntryLen = entryLen;
@@ -1683,7 +1664,7 @@ public class LdifReader implements Itera
         entryLen = 0;
         entryOffset = offset;
 
-        StringBuffer sb = new StringBuffer();
+        StringBuilder sb = new StringBuilder();
 
         try
         {
@@ -1743,7 +1724,7 @@ public class LdifReader implements Itera
                             lines.add( sb.toString() );
                         }
 
-                        sb = new StringBuffer( line );
+                        sb = new StringBuilder( line );
                         insideComment = false;
                         break;
                 }
@@ -1804,14 +1785,11 @@ public class LdifReader implements Itera
             throw new LdapLdifException( I18n.err( I18n.ERR_12067, fileName ) );
         }
 
-        BufferedReader bufferReader = null;
-
         // Open the file and then get a channel from the stream
-        try
+        try ( FileInputStream fis = new FileInputStream( file );
+            BufferedReader bufferReader = new BufferedReader(
+                new InputStreamReader( fis, Charset.forName( encoding ) ) ) )
         {
-            bufferReader = new BufferedReader(
-                new InputStreamReader( new FileInputStream( file ), Charset.forName( encoding ) ) );
-
             return parseLdif( bufferReader );
         }
         catch ( FileNotFoundException fnfe )
@@ -1823,20 +1801,9 @@ public class LdifReader implements Itera
         {
             throw new LdapLdifException( le.getMessage(), le );
         }
-        finally
+        catch ( IOException ioe )
         {
-            // close the reader
-            try
-            {
-                if ( bufferReader != null )
-                {
-                    bufferReader.close();
-                }
-            }
-            catch ( IOException ioe )
-            {
-                // Nothing to do
-            }
+            throw new LdapLdifException( ioe.getMessage(), ioe );
         }
     }
 
@@ -1854,12 +1821,10 @@ public class LdifReader implements Itera
 
         if ( Strings.isEmpty( ldif ) )
         {
-            return new ArrayList<LdifEntry>();
+            return new ArrayList<>();
         }
 
-        BufferedReader bufferReader = new BufferedReader( new StringReader( ldif ) );
-
-        try
+        try ( BufferedReader bufferReader = new BufferedReader( new StringReader( ldif ) ) )
         {
             List<LdifEntry> entries = parseLdif( bufferReader );
 
@@ -1879,18 +1844,9 @@ public class LdifReader implements Itera
         {
             throw new LdapLdifException( le.getMessage(), le );
         }
-        finally
+        catch ( IOException ioe )
         {
-            // Close the reader
-            try
-            {
-                bufferReader.close();
-            }
-            catch ( IOException ioe )
-            {
-                throw new LdapLdifException( I18n.err( I18n.ERR_12024_CANNOT_CLOSE_FILE ), ioe );
-            }
-
+            throw new LdapLdifException( I18n.err( I18n.ERR_12024_CANNOT_CLOSE_FILE ), ioe );
         }
     }
 
@@ -2017,16 +1973,19 @@ public class LdifReader implements Itera
     /**
      * @return An iterator on the file
      */
+    @Override
     public Iterator<LdifEntry> iterator()
     {
         return new Iterator<LdifEntry>()
         {
+            @Override
             public boolean hasNext()
             {
                 return hasNextInternal();
             }
 
 
+            @Override
             public LdifEntry next()
             {
                 try
@@ -2041,6 +2000,7 @@ public class LdifReader implements Itera
             }
 
 
+            @Override
             public void remove()
             {
                 throw new UnsupportedOperationException();
@@ -2078,7 +2038,7 @@ public class LdifReader implements Itera
     public List<LdifEntry> parseLdif( BufferedReader reader ) throws LdapException
     {
         // Create a list that will contain the read entries
-        List<LdifEntry> entries = new ArrayList<LdifEntry>();
+        List<LdifEntry> entries = new ArrayList<>();
 
         this.reader = reader;
 
@@ -2172,6 +2132,7 @@ public class LdifReader implements Itera
     /**
      * {@inheritDoc}
      */
+    @Override
     public void close() throws IOException
     {
         if ( reader != null )

Modified: directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifRevertor.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifRevertor.java?rev=1771874&r1=1771873&r2=1771874&view=diff
==============================================================================
--- directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifRevertor.java (original)
+++ directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifRevertor.java Tue Nov 29 10:07:54 2016
@@ -470,7 +470,7 @@ public final class LdifRevertor
         newDn = newDn.add( newRdn );
 
         List<LdifEntry> entries = new ArrayList<>( 1 );
-        LdifEntry reverted = new LdifEntry();
+        LdifEntry reverted;
 
         // Start with the cases here
         if ( newRdn.size() == 1 )

Modified: directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifUtils.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifUtils.java?rev=1771874&r1=1771873&r2=1771874&view=diff
==============================================================================
--- directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifUtils.java (original)
+++ directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifUtils.java Tue Nov 29 10:07:54 2016
@@ -276,17 +276,9 @@ public final class LdifUtils
      */
     public static Attributes getJndiAttributesFromLdif( String ldif ) throws LdapLdifException
     {
-        LdifAttributesReader reader;
-
-        try
+        try ( LdifAttributesReader reader = new LdifAttributesReader() )
         {
-            reader = new LdifAttributesReader();
-            
-            Attributes attributes = AttributeUtils.toAttributes( reader.parseEntry( ldif ) );
-
-            reader.close();
-
-            return attributes;
+            return AttributeUtils.toAttributes( reader.parseEntry( ldif ) );
         }
         catch ( IOException ioe )
         {
@@ -761,14 +753,9 @@ public final class LdifUtils
                 .err( I18n.ERR_12087 ) );
         }
 
-        try
+        try ( LdifAttributesReader reader = new LdifAttributesReader() ) 
         {
-            LdifAttributesReader reader = new LdifAttributesReader();
-            Attributes attributes = AttributeUtils.toAttributes( reader.parseEntry( sb.toString() ) );
-    
-            reader.close();
-
-            return attributes;
+            return AttributeUtils.toAttributes( reader.parseEntry( sb.toString() ) );
         }
         catch ( IOException ioe )
         {

Modified: directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/AbstractResultResponse.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/AbstractResultResponse.java?rev=1771874&r1=1771873&r2=1771874&view=diff
==============================================================================
--- directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/AbstractResultResponse.java (original)
+++ directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/AbstractResultResponse.java Tue Nov 29 10:07:54 2016
@@ -112,17 +112,8 @@ public abstract class AbstractResultResp
 
         ResultResponse resp = ( ResultResponse ) obj;
 
-        if ( ldapResult != null && resp.getLdapResult() == null )
-        {
-            return false;
-        }
-
-        if ( ldapResult == null && resp.getLdapResult() != null )
-        {
-            return false;
-        }
-
-        return ( ldapResult == null ) || ( resp.getLdapResult() == null ) || ldapResult.equals( resp.getLdapResult() );
+        return ( ( ldapResult != null ) && ldapResult.equals( resp.getLdapResult() ) ) 
+            || ( resp.getLdapResult() == null );
     }
 
 

Modified: directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/ReferralImpl.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/ReferralImpl.java?rev=1771874&r1=1771873&r2=1771874&view=diff
==============================================================================
--- directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/ReferralImpl.java (original)
+++ directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/ReferralImpl.java Tue Nov 29 10:07:54 2016
@@ -206,7 +206,7 @@ public class ReferralImpl implements Ref
     {
         StringBuilder sb = new StringBuilder();
 
-        if ( ( urls != null ) && !urls.isEmpty() )
+        if ( !urls.isEmpty() )
         {
             sb.append( "            Referrals :\n" );
 

Modified: directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/ResultCodeEnum.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/ResultCodeEnum.java?rev=1771874&r1=1771873&r2=1771874&view=diff
==============================================================================
--- directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/ResultCodeEnum.java (original)
+++ directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/ResultCodeEnum.java Tue Nov 29 10:07:54 2016
@@ -719,38 +719,6 @@ public enum ResultCodeEnum
     /** Stores the description of each element of the enumeration */
     private String message;
 
-
-    /**
-     * Private construct so no other instances can be created other than the
-     * public static constants in this class.
-     * 
-     * @param value the integer value of the enumeration.
-     * @param message the description of the enumeration.
-     */
-    ResultCodeEnum( int value, String message )
-    {
-        this.value = value;
-        this.message = message;
-    }
-
-
-    /**
-     * @return The value associated with the current element.
-     */
-    public int getValue()
-    {
-        return value;
-    }
-
-
-    /**
-     * @return The description associated with the current element.
-     */
-    public String getMessage()
-    {
-        return message;
-    }
-
     private static final Set<ResultCodeEnum> EMPTY_RESULT_CODE_SET = new HashSet<>();
 
     // ------------------------------------------------------------------------
@@ -1273,123 +1241,6 @@ public enum ResultCodeEnum
         EXTENDED_CODES = Collections.unmodifiableSet( set );
     }
 
-
-    /**
-     * @return The integer associated with the result code
-     */
-    public int getResultCode()
-    {
-        return value;
-    }
-
-
-    /**
-     * Gets the ResultCode enum from its integer value
-     * 
-     * @param value the ResultCode numneric value
-     * @return The integer associated with the result code
-     */
-    public static ResultCodeEnum getResultCode( int value )
-    {
-        switch ( value )
-        {
-            case 0:
-                return SUCCESS;
-            case 1:
-                return OPERATIONS_ERROR;
-            case 2:
-                return PROTOCOL_ERROR;
-            case 3:
-                return TIME_LIMIT_EXCEEDED;
-            case 4:
-                return SIZE_LIMIT_EXCEEDED;
-            case 5:
-                return COMPARE_FALSE;
-            case 6:
-                return COMPARE_TRUE;
-            case 7:
-                return AUTH_METHOD_NOT_SUPPORTED;
-            case 8:
-                return STRONG_AUTH_REQUIRED;
-            case 9:
-                return PARTIAL_RESULTS;
-            case 10:
-                return REFERRAL;
-            case 11:
-                return ADMIN_LIMIT_EXCEEDED;
-            case 12:
-                return UNAVAILABLE_CRITICAL_EXTENSION;
-            case 13:
-                return CONFIDENTIALITY_REQUIRED;
-            case 14:
-                return SASL_BIND_IN_PROGRESS;
-            case 16:
-                return NO_SUCH_ATTRIBUTE;
-            case 17:
-                return UNDEFINED_ATTRIBUTE_TYPE;
-            case 18:
-                return INAPPROPRIATE_MATCHING;
-            case 19:
-                return CONSTRAINT_VIOLATION;
-            case 20:
-                return ATTRIBUTE_OR_VALUE_EXISTS;
-            case 21:
-                return INVALID_ATTRIBUTE_SYNTAX;
-            case 32:
-                return NO_SUCH_OBJECT;
-            case 33:
-                return ALIAS_PROBLEM;
-            case 34:
-                return INVALID_DN_SYNTAX;
-            case 35:
-                return UNKNOWN;
-            case 36:
-                return ALIAS_DEREFERENCING_PROBLEM;
-            case 48:
-                return INAPPROPRIATE_AUTHENTICATION;
-            case 49:
-                return INVALID_CREDENTIALS;
-            case 50:
-                return INSUFFICIENT_ACCESS_RIGHTS;
-            case 51:
-                return BUSY;
-            case 52:
-                return UNAVAILABLE;
-            case 53:
-                return UNWILLING_TO_PERFORM;
-            case 54:
-                return LOOP_DETECT;
-            case 64:
-                return NAMING_VIOLATION;
-            case 65:
-                return OBJECT_CLASS_VIOLATION;
-            case 66:
-                return NOT_ALLOWED_ON_NON_LEAF;
-            case 67:
-                return NOT_ALLOWED_ON_RDN;
-            case 68:
-                return ENTRY_ALREADY_EXISTS;
-            case 69:
-                return OBJECT_CLASS_MODS_PROHIBITED;
-            case 71:
-                return AFFECTS_MULTIPLE_DSAS;
-            case 80:
-                return OTHER;
-            case 118:
-                return CANCELED;
-            case 119:
-                return NO_SUCH_OPERATION;
-            case 120:
-                return TOO_LATE;
-            case 121:
-                return CANNOT_CANCEL;
-            case 4096:
-                return E_SYNC_REFRESH_REQUIRED;
-            default:
-                return UNKNOWN;
-        }
-    }
-
     // ------------------------------------------------------------------------
     // Getting Result Code Enumeration Object Using Integer Values
     // ------------------------------------------------------------------------
@@ -1575,6 +1426,155 @@ public enum ResultCodeEnum
     }
 
 
+    /**
+     * Private construct so no other instances can be created other than the
+     * public static constants in this class.
+     * 
+     * @param value the integer value of the enumeration.
+     * @param message the description of the enumeration.
+     */
+    ResultCodeEnum( int value, String message )
+    {
+        this.value = value;
+        this.message = message;
+    }
+
+
+    /**
+     * @return The value associated with the current element.
+     */
+    public int getValue()
+    {
+        return value;
+    }
+
+
+    /**
+     * @return The description associated with the current element.
+     */
+    public String getMessage()
+    {
+        return message;
+    }
+
+
+    /**
+     * @return The integer associated with the result code
+     */
+    public int getResultCode()
+    {
+        return value;
+    }
+
+
+    /**
+     * Gets the ResultCode enum from its integer value
+     * 
+     * @param value the ResultCode numneric value
+     * @return The integer associated with the result code
+     */
+    public static ResultCodeEnum getResultCode( int value )
+    {
+        switch ( value )
+        {
+            case 0:
+                return SUCCESS;
+            case 1:
+                return OPERATIONS_ERROR;
+            case 2:
+                return PROTOCOL_ERROR;
+            case 3:
+                return TIME_LIMIT_EXCEEDED;
+            case 4:
+                return SIZE_LIMIT_EXCEEDED;
+            case 5:
+                return COMPARE_FALSE;
+            case 6:
+                return COMPARE_TRUE;
+            case 7:
+                return AUTH_METHOD_NOT_SUPPORTED;
+            case 8:
+                return STRONG_AUTH_REQUIRED;
+            case 9:
+                return PARTIAL_RESULTS;
+            case 10:
+                return REFERRAL;
+            case 11:
+                return ADMIN_LIMIT_EXCEEDED;
+            case 12:
+                return UNAVAILABLE_CRITICAL_EXTENSION;
+            case 13:
+                return CONFIDENTIALITY_REQUIRED;
+            case 14:
+                return SASL_BIND_IN_PROGRESS;
+            case 16:
+                return NO_SUCH_ATTRIBUTE;
+            case 17:
+                return UNDEFINED_ATTRIBUTE_TYPE;
+            case 18:
+                return INAPPROPRIATE_MATCHING;
+            case 19:
+                return CONSTRAINT_VIOLATION;
+            case 20:
+                return ATTRIBUTE_OR_VALUE_EXISTS;
+            case 21:
+                return INVALID_ATTRIBUTE_SYNTAX;
+            case 32:
+                return NO_SUCH_OBJECT;
+            case 33:
+                return ALIAS_PROBLEM;
+            case 34:
+                return INVALID_DN_SYNTAX;
+            case 35:
+                return UNKNOWN;
+            case 36:
+                return ALIAS_DEREFERENCING_PROBLEM;
+            case 48:
+                return INAPPROPRIATE_AUTHENTICATION;
+            case 49:
+                return INVALID_CREDENTIALS;
+            case 50:
+                return INSUFFICIENT_ACCESS_RIGHTS;
+            case 51:
+                return BUSY;
+            case 52:
+                return UNAVAILABLE;
+            case 53:
+                return UNWILLING_TO_PERFORM;
+            case 54:
+                return LOOP_DETECT;
+            case 64:
+                return NAMING_VIOLATION;
+            case 65:
+                return OBJECT_CLASS_VIOLATION;
+            case 66:
+                return NOT_ALLOWED_ON_NON_LEAF;
+            case 67:
+                return NOT_ALLOWED_ON_RDN;
+            case 68:
+                return ENTRY_ALREADY_EXISTS;
+            case 69:
+                return OBJECT_CLASS_MODS_PROHIBITED;
+            case 71:
+                return AFFECTS_MULTIPLE_DSAS;
+            case 80:
+                return OTHER;
+            case 118:
+                return CANCELED;
+            case 119:
+                return NO_SUCH_OPERATION;
+            case 120:
+                return TOO_LATE;
+            case 121:
+                return CANNOT_CANCEL;
+            case 4096:
+                return E_SYNC_REFRESH_REQUIRED;
+            default:
+                return UNKNOWN;
+        }
+    }
+
+
     /**
      * Takes a guess at the result code to use if it cannot figure it out from
      * known Throwable to result code mappings. Some however are ambiguous

Modified: directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/name/Ava.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/name/Ava.java?rev=1771874&r1=1771873&r2=1771874&view=diff
==============================================================================
--- directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/name/Ava.java (original)
+++ directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/name/Ava.java Tue Nov 29 10:07:54 2016
@@ -1643,16 +1643,6 @@ public class Ava implements Externalizab
             length += 1 + 4 + upTypeBytes.length;
         }
 
-        // The normType
-        /*byte[] normTypeBytes = null;
-
-        if ( normType != null )
-        {
-            normTypeBytes = Strings.getBytesUtf8( normType );
-            length += 1 + 4 + normTypeBytes.length;
-        }
-        */
-
         // Is HR
         length++;
 
@@ -1687,19 +1677,6 @@ public class Ava implements Externalizab
             buffer[pos++] = Serialize.FALSE;
         }
 
-        // Write the normType
-        /*
-        if ( normType != null )
-        {
-            buffer[pos++] = Serialize.TRUE;
-            pos = Serialize.serialize( normTypeBytes, buffer, pos );
-        }
-        else
-        {
-            buffer[pos++] = Serialize.FALSE;
-        }
-        */
-
         // Write the isHR flag
         if ( value.isHumanReadable() )
         {
@@ -1761,19 +1738,6 @@ public class Ava implements Externalizab
             upType = Strings.utf8ToString( upTypeBytes );
         }
 
-        // Read the normType value, if it's not null
-        /*
-        boolean hasNormType = Serialize.deserializeBoolean( buffer, pos );
-        pos++;
-
-        if ( hasNormType )
-        {
-            byte[] normTypeBytes = Serialize.deserializeBytes( buffer, pos );
-            pos += 4 + normTypeBytes.length;
-            normType = Strings.utf8ToString( normTypeBytes );
-        }
-        */
-
         // Update the AtributeType
         if ( schemaManager != null )
         {
@@ -1983,14 +1947,7 @@ public class Ava implements Externalizab
 
         boolean isHR = in.readBoolean();
 
-        if ( isHR )
-        {
-            value = Value.deserialize( attributeType, in );
-        }
-        else
-        {
-            value = Value.deserialize( attributeType, in );
-        }
+        value = Value.deserialize( attributeType, in );
 
         h = in.readInt();
     }

Modified: directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/name/Rdn.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/name/Rdn.java?rev=1771874&r1=1771873&r2=1771874&view=diff
==============================================================================
--- directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/name/Rdn.java (original)
+++ directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/name/Rdn.java Tue Nov 29 10:07:54 2016
@@ -533,7 +533,7 @@ public class Rdn implements Cloneable, E
             avaList = new ArrayList<>();
         }
         
-        if ( avaList.size() == 0 )
+        if ( avaList.isEmpty() )
         {
             avaList.add( newAva );
             return avaList;
@@ -1288,7 +1288,7 @@ public class Rdn implements Cloneable, E
      *         array.
      * @throws IllegalArgumentException When an Illegal value is provided.
      */
-    public static Object unescapeValue( String value ) throws IllegalArgumentException
+    public static Object unescapeValue( String value )
     {
         if ( Strings.isEmpty( value ) )
         {

Modified: directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/OidRegistry.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/OidRegistry.java?rev=1771874&r1=1771873&r2=1771874&view=diff
==============================================================================
--- directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/OidRegistry.java (original)
+++ directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/OidRegistry.java Tue Nov 29 10:07:54 2016
@@ -53,7 +53,7 @@ public class OidRegistry<T extends Schem
     private Map<String, T> byOid = new HashMap<>();
     
     /** A flag indicating that the Registry is relaxed or not */
-    private boolean isRelaxed = Registries.STRICT;;
+    private boolean isRelaxed = Registries.STRICT;
 
 
     /**

Modified: directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/Registries.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/Registries.java?rev=1771874&r1=1771873&r2=1771874&view=diff
==============================================================================
--- directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/Registries.java (original)
+++ directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/Registries.java Tue Nov 29 10:07:54 2016
@@ -1545,17 +1545,13 @@ public class Registries implements Schem
         LOG.debug( "Registering {}:{}", schemaObject.getObjectType(), schemaObject.getOid() );
 
         // Check that the SchemaObject is not already registered
-        // TODO : Check for existing Loadable SchemaObject
-        if ( !( schemaObject instanceof LoadableSchemaObject ) )
+        if ( !( schemaObject instanceof LoadableSchemaObject ) && globalOidRegistry.contains( schemaObject.getOid() ) )
         {
-            if ( globalOidRegistry.contains( schemaObject.getOid() ) )
-            {
-                String msg = I18n.err( I18n.ERR_04301, schemaObject.getObjectType(), schemaObject.getOid() );
-                LOG.error( msg );
-                Throwable error = new LdapUnwillingToPerformException( ResultCodeEnum.UNWILLING_TO_PERFORM, msg );
-                errors.add( error );
-                return;
-            }
+            String msg = I18n.err( I18n.ERR_04301, schemaObject.getObjectType(), schemaObject.getOid() );
+            LOG.error( msg );
+            Throwable error = new LdapUnwillingToPerformException( ResultCodeEnum.UNWILLING_TO_PERFORM, msg );
+            errors.add( error );
+            return;
         }
 
         try
@@ -1760,18 +1756,14 @@ public class Registries implements Schem
         LOG.debug( "Unregistering {}:{}", schemaObject.getObjectType(), schemaObject.getOid() );
 
         // Check that the SchemaObject is present in the registries
-        // TODO : check for an existing Loadable SchemaObject
-        if ( !( schemaObject instanceof LoadableSchemaObject ) )
+        if ( !( schemaObject instanceof LoadableSchemaObject ) && !globalOidRegistry.contains( schemaObject.getOid() ) )
         {
-            if ( !globalOidRegistry.contains( schemaObject.getOid() ) )
-            {
-                String msg = I18n.err( I18n.ERR_04302, schemaObject.getObjectType(), schemaObject.getOid() );
-                LOG.error( msg );
-                throw new LdapUnwillingToPerformException( ResultCodeEnum.UNWILLING_TO_PERFORM, msg );
-            }
+            String msg = I18n.err( I18n.ERR_04302, schemaObject.getObjectType(), schemaObject.getOid() );
+            LOG.error( msg );
+            throw new LdapUnwillingToPerformException( ResultCodeEnum.UNWILLING_TO_PERFORM, msg );
         }
 
-        SchemaObject unregistered = null;
+        SchemaObject unregistered;
 
         // First call the specific registry's register method
         switch ( schemaObject.getObjectType() )

Modified: directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/subtree/BaseSubtreeSpecification.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/subtree/BaseSubtreeSpecification.java?rev=1771874&r1=1771873&r2=1771874&view=diff
==============================================================================
--- directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/subtree/BaseSubtreeSpecification.java (original)
+++ directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/subtree/BaseSubtreeSpecification.java Tue Nov 29 10:07:54 2016
@@ -362,7 +362,6 @@ public class BaseSubtreeSpecification im
         {
             if ( isFirst )
             {
-                isFirst = false;
                 buffer.append( " " );
             }
             else

Modified: directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/subtree/Subentry.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/subtree/Subentry.java?rev=1771874&r1=1771873&r2=1771874&view=diff
==============================================================================
--- directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/subtree/Subentry.java (original)
+++ directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/subtree/Subentry.java Tue Nov 29 10:07:54 2016
@@ -130,6 +130,7 @@ public class Subentry
     /**
      * @see Object#toString()
      */
+    @Override
     public String toString()
     {
         return "Subentry[" + administrativeRoles + ", " + ss + "]";

Modified: directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/subtree/SubtreeSpecificationChecker.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/subtree/SubtreeSpecificationChecker.java?rev=1771874&r1=1771873&r2=1771874&view=diff
==============================================================================
--- directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/subtree/SubtreeSpecificationChecker.java (original)
+++ directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/subtree/SubtreeSpecificationChecker.java Tue Nov 29 10:07:54 2016
@@ -103,17 +103,7 @@ public class SubtreeSpecificationChecker
         {
             this.parser.wrapperEntryPoint();
         }
-        catch ( TokenStreamException e )
-        {
-            String msg = I18n.err( I18n.ERR_04329, spec, e.getLocalizedMessage() );
-            throw new ParseException( msg, 0 );
-        }
-        catch ( RecognitionException e )
-        {
-            String msg = I18n.err( I18n.ERR_04329, spec, e.getLocalizedMessage() );
-            throw new ParseException( msg, e.getColumn() );
-        }
-        catch ( Exception e )
+        catch ( TokenStreamException | RecognitionException e )
         {
             String msg = I18n.err( I18n.ERR_04329, spec, e.getLocalizedMessage() );
             throw new ParseException( msg, 0 );

Modified: directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/subtree/SubtreeSpecificationModifier.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/subtree/SubtreeSpecificationModifier.java?rev=1771874&r1=1771873&r2=1771874&view=diff
==============================================================================
--- directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/subtree/SubtreeSpecificationModifier.java (original)
+++ directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/subtree/SubtreeSpecificationModifier.java Tue Nov 29 10:07:54 2016
@@ -160,8 +160,6 @@ public class SubtreeSpecificationModifie
      * Sets a filter using only assertions on objectClass attributes for subtree
      * refinement.
      * 
-     * TODO: there is a setFilter() method, remove this method?
-     * 
      * @param refinement a filter using only assertions on objectClass attributes for
      *            subtree refinement
      */

Modified: directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/subtree/SubtreeSpecificationParser.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/subtree/SubtreeSpecificationParser.java?rev=1771874&r1=1771873&r2=1771874&view=diff
==============================================================================
--- directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/subtree/SubtreeSpecificationParser.java (original)
+++ directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/subtree/SubtreeSpecificationParser.java Tue Nov 29 10:07:54 2016
@@ -130,17 +130,7 @@ public class SubtreeSpecificationParser
         {
             ss = this.parser.wrapperEntryPoint();
         }
-        catch ( TokenStreamException e )
-        {
-            String msg = I18n.err( I18n.ERR_04329, spec, e.getLocalizedMessage() );
-            throw new ParseException( msg, 0 );
-        }
-        catch ( RecognitionException e )
-        {
-            String msg = I18n.err( I18n.ERR_04329, spec, e.getLocalizedMessage() );
-            throw new ParseException( msg, e.getColumn() );
-        }
-        catch ( Exception e )
+        catch ( TokenStreamException | RecognitionException e )
         {
             String msg = I18n.err( I18n.ERR_04329, spec, e.getLocalizedMessage() );
             throw new ParseException( msg, 0 );

Modified: directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/url/LdapUrl.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/url/LdapUrl.java?rev=1771874&r1=1771873&r2=1771874&view=diff
==============================================================================
--- directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/url/LdapUrl.java (original)
+++ directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/url/LdapUrl.java Tue Nov 29 10:07:54 2016
@@ -798,6 +798,8 @@ public class LdapUrl
                     {
                         return -1;
                     }
+                    
+                    break;
 
                 default:
                     // Wrong char
@@ -878,30 +880,37 @@ public class LdapUrl
     {
         int ipElemValue = 0;
         boolean ipElemSeen = false;
-        boolean hasHeadingZero = false;
+        boolean hasHeadingZeroes = false;
 
         while ( Chars.isDigit( chars, pos ) )
         {
             ipElemSeen = true;
-            ipElemValue = ( ipElemValue * 10 ) + ( chars[pos] - '0' );
-
+            
             if ( chars[pos] == '0' )
             {
-                if ( hasHeadingZero )
+                if ( hasHeadingZeroes )
                 {
                     // Two 0 at the beginning : not allowed
                     return -1;
                 }
                 
-                if ( ipElemValue == 0 )
+                if ( ipElemValue > 0 )
                 {
-                    hasHeadingZero = true;
+                    ipElemValue = ipElemValue * 10;
+                }
+                else
+                { 
+                    hasHeadingZeroes = true;
                 }
             }
+            else
+            {
+                hasHeadingZeroes = false;
+                ipElemValue = ( ipElemValue * 10 ) + ( chars[pos] - '0' );
+            }
 
             if ( ipElemValue > 255 )
             {
-                // We don't allow IPV4 address with values > 255
                 return -1;
             }
 
@@ -911,7 +920,7 @@ public class LdapUrl
         if ( ipElemSeen )
         {
             ipElem[octetNb] = ipElemValue;
-
+    
             return pos;
         }
         else
@@ -1124,11 +1133,7 @@ public class LdapUrl
             String dnStr = new String( chars, pos, end - pos );
             dn = new Dn( decode( dnStr ) );
         }
-        catch ( LdapUriException ue )
-        {
-            return -1;
-        }
-        catch ( LdapInvalidDnException de )
+        catch ( LdapUriException | LdapInvalidDnException e )
         {
             return -1;
         }
@@ -1303,11 +1308,7 @@ public class LdapUrl
             filter = decode( new String( chars, pos, end - pos ) );
             FilterParser.parse( filter );
         }
-        catch ( LdapUriException ue )
-        {
-            return -1;
-        }
-        catch ( ParseException pe )
+        catch ( LdapUriException | ParseException e )
         {
             return -1;
         }