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/25 17:53:21 UTC
svn commit: r1771363 [1/2] - in
/directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client:
api/ api/callback/ api/future/ api/search/ template/ template/exception/
Author: elecharny
Date: Fri Nov 25 17:53:20 2016
New Revision: 1771363
URL: http://svn.apache.org/viewvc?rev=1771363&view=rev
Log:
Fixed SonarLint warnings
Modified:
directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/AbstractLdapConnection.java
directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/AbstractPoolableLdapConnectionFactory.java
directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/DefaultLdapConnectionValidator.java
directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/DefaultSchemaLoader.java
directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/EntryCursorImpl.java
directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/Krb5LoginConfiguration.java
directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapConnection.java
directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapConnectionPool.java
directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapConnectionWrapper.java
directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java
directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdifAnonymizer.java
directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LookupLdapConnectionValidator.java
directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/MonitoringLdapConnection.java
directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/NoVerificationTrustManager.java
directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/SaslDigestMd5Request.java
directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/SaslGssApiRequest.java
directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/SaslRequest.java
directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/SearchCursorImpl.java
directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/ValidatingPoolableLdapConnectionFactory.java
directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/callback/SaslCallbackHandler.java
directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/future/AddFuture.java
directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/future/BindFuture.java
directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/future/CompareFuture.java
directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/future/DeleteFuture.java
directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/future/ExtendedFuture.java
directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/future/ModifyDnFuture.java
directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/future/ModifyFuture.java
directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/future/ResponseFuture.java
directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/future/SearchFuture.java
directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/search/Filter.java
directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/search/SetOfFiltersFilter.java
directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/search/SubstringFilter.java
directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/template/LdapConnectionTemplate.java
directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/template/exception/LdapRequestUnsuccessfulException.java
Modified: directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/AbstractLdapConnection.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/AbstractLdapConnection.java?rev=1771363&r1=1771362&r2=1771363&view=diff
==============================================================================
--- directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/AbstractLdapConnection.java (original)
+++ directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/AbstractLdapConnection.java Fri Nov 25 17:53:20 2016
@@ -78,6 +78,7 @@ public abstract class AbstractLdapConnec
/**
* {@inheritDoc}
*/
+ @Override
public void bind( Dn name ) throws LdapException
{
byte[] credBytes = Strings.EMPTY_BYTES;
@@ -95,6 +96,7 @@ public abstract class AbstractLdapConnec
/**
* {@inheritDoc}
*/
+ @Override
public void bind( String name ) throws LdapException
{
LOG.debug( "Bind request : {}", name );
@@ -106,6 +108,7 @@ public abstract class AbstractLdapConnec
/**
* {@inheritDoc}
*/
+ @Override
public void bind( String name, String credentials ) throws LdapException
{
bind( new Dn( schemaManager, name ), credentials );
@@ -115,9 +118,10 @@ public abstract class AbstractLdapConnec
/**
* {@inheritDoc}
*/
+ @Override
public void bind( Dn name, String credentials ) throws LdapException
{
- byte[] credBytes = ( credentials == null ? Strings.EMPTY_BYTES : Strings.getBytesUtf8( credentials ) );
+ byte[] credBytes = credentials == null ? Strings.EMPTY_BYTES : Strings.getBytesUtf8( credentials );
BindRequest bindRequest = new BindRequestImpl();
bindRequest.setDn( name );
Modified: directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/AbstractPoolableLdapConnectionFactory.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/AbstractPoolableLdapConnectionFactory.java?rev=1771363&r1=1771362&r2=1771363&view=diff
==============================================================================
--- directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/AbstractPoolableLdapConnectionFactory.java (original)
+++ directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/AbstractPoolableLdapConnectionFactory.java Fri Nov 25 17:53:20 2016
@@ -51,6 +51,7 @@ public abstract class AbstractPoolableLd
*
* There is nothing to do to activate a connection.
*/
+ @Override
public void activateObject( LdapConnection connection ) throws LdapException
{
LOG.debug( "Activating {}", connection );
@@ -68,6 +69,7 @@ public abstract class AbstractPoolableLd
* Destroying a connection will unbind it which will result on a shutdown
* of teh underlying protocol.
*/
+ @Override
public void destroyObject( LdapConnection connection ) throws LdapException
{
LOG.debug( "Destroying {}", connection );
@@ -104,6 +106,7 @@ public abstract class AbstractPoolableLd
*
* @throws LdapException If unable to connect.
*/
+ @Override
public LdapConnection makeObject() throws LdapException
{
LOG.debug( "Creating a LDAP connection" );
@@ -136,6 +139,7 @@ public abstract class AbstractPoolableLd
*
* @throws LdapException If unable to reconfigure and rebind.
*/
+ @Override
public void passivateObject( LdapConnection connection ) throws LdapException
{
LOG.debug( "Passivating {}", connection );
@@ -167,6 +171,7 @@ public abstract class AbstractPoolableLd
*
* Validating a connection is done by checking the connection status.
*/
+ @Override
public boolean validateObject( LdapConnection connection )
{
LOG.debug( "Validating {}", connection );
Modified: directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/DefaultLdapConnectionValidator.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/DefaultLdapConnectionValidator.java?rev=1771363&r1=1771362&r2=1771363&view=diff
==============================================================================
--- directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/DefaultLdapConnectionValidator.java (original)
+++ directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/DefaultLdapConnectionValidator.java Fri Nov 25 17:53:20 2016
@@ -34,6 +34,7 @@ public final class DefaultLdapConnection
* @param connection The connection to validate
* @return True, if the connection is still valid
*/
+ @Override
public boolean validate( LdapConnection connection )
{
return connection.isConnected() && connection.isAuthenticated();
Modified: directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/DefaultSchemaLoader.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/DefaultSchemaLoader.java?rev=1771363&r1=1771362&r2=1771363&view=diff
==============================================================================
--- directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/DefaultSchemaLoader.java (original)
+++ directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/DefaultSchemaLoader.java Fri Nov 25 17:53:20 2016
@@ -118,6 +118,28 @@ public class DefaultSchemaLoader extends
/**
+ * Creates a new instance of NetworkSchemaLoader.
+ *
+ * @param connection the LDAP connection
+ * @param subschemaSubentryDn The SubschemaSubentry
+ * @throws LdapException if the connection is not authenticated or if there are any problems
+ * while loading the schema entries
+ */
+ public DefaultSchemaLoader( LdapConnection connection, Dn subschemaSubentryDn ) throws LdapException
+ {
+ if ( !connection.isAuthenticated() )
+ {
+ throw new IllegalArgumentException( "connection is not authenticated" );
+ }
+
+ this.connection = connection;
+ this.subschemaSubentryDn = subschemaSubentryDn;
+
+ loadSchemas();
+ }
+
+
+ /**
* Creates a new instance of DefaultSchemaLoader.
*
* @param connection the LDAP connection
@@ -235,28 +257,6 @@ public class DefaultSchemaLoader extends
/**
- * Creates a new instance of NetworkSchemaLoader.
- *
- * @param connection the LDAP connection
- * @param subschemaSubentryDn The SubschemaSubentry
- * @throws Exception if the connection is not authenticated or if there are any problems
- * while loading the schema entries
- */
- public DefaultSchemaLoader( LdapConnection connection, Dn subschemaSubentryDn ) throws Exception
- {
- if ( !connection.isAuthenticated() )
- {
- throw new IllegalArgumentException( "connection is not authenticated" );
- }
-
- this.connection = connection;
- this.subschemaSubentryDn = subschemaSubentryDn;
-
- loadSchemas();
- }
-
-
- /**
* Load all the schemas.
*
* @param subschemaSubentryDn
@@ -638,7 +638,7 @@ public class DefaultSchemaLoader extends
private void updateSchemas( SchemaObject schemaObject )
{
String schemaName = schemaObject.getSchemaName();
- Schema schema = null;
+ Schema schema;
if ( Strings.isEmpty( schemaName ) || Strings.equals( "null", schemaName ) )
{
@@ -665,9 +665,10 @@ public class DefaultSchemaLoader extends
/**
* {@inheritDoc}
*/
+ @Override
public List<Entry> loadAttributeTypes( Schema... schemas ) throws LdapException, IOException
{
- List<Entry> attributeTypeEntries = new ArrayList<Entry>();
+ List<Entry> attributeTypeEntries = new ArrayList<>();
if ( schemas == null )
{
@@ -702,9 +703,10 @@ public class DefaultSchemaLoader extends
/**
* {@inheritDoc}
*/
+ @Override
public List<Entry> loadComparators( Schema... schemas ) throws LdapException, IOException
{
- List<Entry> comparatorEntries = new ArrayList<Entry>();
+ List<Entry> comparatorEntries = new ArrayList<>();
if ( schemas == null )
{
@@ -736,9 +738,10 @@ public class DefaultSchemaLoader extends
/**
* {@inheritDoc}
*/
+ @Override
public List<Entry> loadDitContentRules( Schema... schemas ) throws LdapException, IOException
{
- List<Entry> ditContentRuleEntries = new ArrayList<Entry>();
+ List<Entry> ditContentRuleEntries = new ArrayList<>();
if ( schemas == null )
{
@@ -773,9 +776,10 @@ public class DefaultSchemaLoader extends
/**
* {@inheritDoc}
*/
+ @Override
public List<Entry> loadDitStructureRules( Schema... schemas ) throws LdapException, IOException
{
- List<Entry> ditStructureRuleEntries = new ArrayList<Entry>();
+ List<Entry> ditStructureRuleEntries = new ArrayList<>();
if ( schemas == null )
{
@@ -810,9 +814,10 @@ public class DefaultSchemaLoader extends
/**
* {@inheritDoc}
*/
+ @Override
public List<Entry> loadMatchingRuleUses( Schema... schemas ) throws LdapException, IOException
{
- List<Entry> matchingRuleUseEntries = new ArrayList<Entry>();
+ List<Entry> matchingRuleUseEntries = new ArrayList<>();
if ( schemas == null )
{
@@ -847,9 +852,10 @@ public class DefaultSchemaLoader extends
/**
* {@inheritDoc}
*/
+ @Override
public List<Entry> loadMatchingRules( Schema... schemas ) throws LdapException, IOException
{
- List<Entry> matchingRuleEntries = new ArrayList<Entry>();
+ List<Entry> matchingRuleEntries = new ArrayList<>();
if ( schemas == null )
{
@@ -884,9 +890,10 @@ public class DefaultSchemaLoader extends
/**
* {@inheritDoc}
*/
+ @Override
public List<Entry> loadNameForms( Schema... schemas ) throws LdapException, IOException
{
- List<Entry> nameFormEntries = new ArrayList<Entry>();
+ List<Entry> nameFormEntries = new ArrayList<>();
if ( schemas == null )
{
@@ -921,9 +928,10 @@ public class DefaultSchemaLoader extends
/**
* {@inheritDoc}
*/
+ @Override
public List<Entry> loadNormalizers( Schema... schemas ) throws LdapException, IOException
{
- List<Entry> normalizerEntries = new ArrayList<Entry>();
+ List<Entry> normalizerEntries = new ArrayList<>();
if ( schemas == null )
{
@@ -955,9 +963,10 @@ public class DefaultSchemaLoader extends
/**
* {@inheritDoc}
*/
+ @Override
public List<Entry> loadObjectClasses( Schema... schemas ) throws LdapException, IOException
{
- List<Entry> objectClassEntries = new ArrayList<Entry>();
+ List<Entry> objectClassEntries = new ArrayList<>();
if ( schemas == null )
{
@@ -992,9 +1001,10 @@ public class DefaultSchemaLoader extends
/**
* {@inheritDoc}
*/
+ @Override
public List<Entry> loadSyntaxCheckers( Schema... schemas ) throws LdapException, IOException
{
- List<Entry> syntaxCheckerEntries = new ArrayList<Entry>();
+ List<Entry> syntaxCheckerEntries = new ArrayList<>();
if ( schemas == null )
{
@@ -1026,9 +1036,10 @@ public class DefaultSchemaLoader extends
/**
* {@inheritDoc}
*/
+ @Override
public List<Entry> loadSyntaxes( Schema... schemas ) throws LdapException, IOException
{
- List<Entry> syntaxEntries = new ArrayList<Entry>();
+ List<Entry> syntaxEntries = new ArrayList<>();
if ( schemas == null )
{
Modified: directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/EntryCursorImpl.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/EntryCursorImpl.java?rev=1771363&r1=1771362&r2=1771363&view=diff
==============================================================================
--- directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/EntryCursorImpl.java (original)
+++ directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/EntryCursorImpl.java Fri Nov 25 17:53:20 2016
@@ -87,6 +87,7 @@ public class EntryCursorImpl extends Abs
/**
* {@inheritDoc}
*/
+ @Override
public boolean next() throws LdapException, CursorException
{
if ( !searchCursor.next() )
@@ -144,6 +145,7 @@ public class EntryCursorImpl extends Abs
/**
* {@inheritDoc}
*/
+ @Override
public Entry get() throws CursorException
{
if ( !searchCursor.available() )
@@ -183,6 +185,7 @@ public class EntryCursorImpl extends Abs
/**
* {@inheritDoc}
*/
+ @Override
public SearchResultDone getSearchResultDone()
{
return searchCursor.getSearchResultDone();
@@ -192,6 +195,7 @@ public class EntryCursorImpl extends Abs
/**
* {@inheritDoc}
*/
+ @Override
public boolean available()
{
return searchCursor.available();
@@ -234,6 +238,7 @@ public class EntryCursorImpl extends Abs
* This operation is not supported in SearchCursor.
* {@inheritDoc}
*/
+ @Override
public void after( Entry element ) throws LdapException, CursorException
{
throw new UnsupportedOperationException( I18n.err( I18n.ERR_02014_UNSUPPORTED_OPERATION, getClass().getName()
@@ -245,6 +250,7 @@ public class EntryCursorImpl extends Abs
* This operation is not supported in SearchCursor.
* {@inheritDoc}
*/
+ @Override
public void afterLast() throws LdapException, CursorException
{
throw new UnsupportedOperationException( I18n.err( I18n.ERR_02014_UNSUPPORTED_OPERATION, getClass().getName()
@@ -256,6 +262,7 @@ public class EntryCursorImpl extends Abs
* This operation is not supported in SearchCursor.
* {@inheritDoc}
*/
+ @Override
public void before( Entry element ) throws LdapException, CursorException
{
throw new UnsupportedOperationException( I18n.err( I18n.ERR_02014_UNSUPPORTED_OPERATION, getClass().getName()
@@ -267,6 +274,7 @@ public class EntryCursorImpl extends Abs
* This operation is not supported in SearchCursor.
* {@inheritDoc}
*/
+ @Override
public void beforeFirst() throws LdapException, CursorException
{
throw new UnsupportedOperationException( I18n.err( I18n.ERR_02014_UNSUPPORTED_OPERATION, getClass().getName()
@@ -278,6 +286,7 @@ public class EntryCursorImpl extends Abs
* This operation is not supported in SearchCursor.
* {@inheritDoc}
*/
+ @Override
public boolean first() throws LdapException, CursorException
{
throw new UnsupportedOperationException( I18n.err( I18n.ERR_02014_UNSUPPORTED_OPERATION, getClass().getName()
@@ -289,6 +298,7 @@ public class EntryCursorImpl extends Abs
* This operation is not supported in SearchCursor.
* {@inheritDoc}
*/
+ @Override
public boolean last() throws LdapException, CursorException
{
throw new UnsupportedOperationException( I18n.err( I18n.ERR_02014_UNSUPPORTED_OPERATION, getClass().getName()
@@ -300,6 +310,7 @@ public class EntryCursorImpl extends Abs
* This operation is not supported in SearchCursor.
* {@inheritDoc}
*/
+ @Override
public boolean previous() throws LdapException, CursorException
{
throw new UnsupportedOperationException( I18n.err( I18n.ERR_02014_UNSUPPORTED_OPERATION, getClass().getName()
@@ -310,6 +321,7 @@ public class EntryCursorImpl extends Abs
/**
* {@inheritDoc}
*/
+ @Override
public int getMessageId()
{
return messageId;
Modified: directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/Krb5LoginConfiguration.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/Krb5LoginConfiguration.java?rev=1771363&r1=1771362&r2=1771363&view=diff
==============================================================================
--- directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/Krb5LoginConfiguration.java (original)
+++ directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/Krb5LoginConfiguration.java Fri Nov 25 17:53:20 2016
@@ -44,7 +44,7 @@ public class Krb5LoginConfiguration exte
{
String loginModule = "com.sun.security.auth.module.Krb5LoginModule";
- HashMap<String, Object> options = new HashMap<String, Object>();
+ HashMap<String, Object> options = new HashMap<>();
// TODO: this only works for Sun JVM
options.put( "refreshKrb5Config", "true" );
@@ -60,6 +60,7 @@ public class Krb5LoginConfiguration exte
* @param applicationName the application name
* @return the configuration entry
*/
+ @Override
public AppConfigurationEntry[] getAppConfigurationEntry( String applicationName )
{
// We will ignore the applicationName, since we want all apps to use Kerberos V5
@@ -70,6 +71,7 @@ public class Krb5LoginConfiguration exte
/**
* Interface method for reloading the configuration. We don't need this.
*/
+ @Override
public void refresh()
{
// Right now this is a load once scheme and we will not implement the refresh method
Modified: directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapConnection.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapConnection.java?rev=1771363&r1=1771362&r2=1771363&view=diff
==============================================================================
--- directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapConnection.java (original)
+++ directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapConnection.java Fri Nov 25 17:53:20 2016
@@ -100,6 +100,7 @@ public interface LdapConnection extends
*
* @throws IOException if some I/O error occurs
*/
+ @Override
void close() throws IOException;
@@ -840,6 +841,7 @@ public interface LdapConnection extends
* @return true if there is a non-null future exists, false otherwise
* @deprecated Use {@link #isRequestCompleted(int)}
*/
+ @Deprecated
boolean doesFutureExistFor( int messageId );
Modified: directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapConnectionPool.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapConnectionPool.java?rev=1771363&r1=1771362&r2=1771363&view=diff
==============================================================================
--- directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapConnectionPool.java (original)
+++ directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapConnectionPool.java Fri Nov 25 17:53:20 2016
@@ -123,13 +123,9 @@ public class LdapConnectionPool extends
connection = super.borrowObject();
LOG.trace( "borrowed connection {}", connection );
}
- catch ( LdapException e )
+ catch ( LdapException | RuntimeException e )
{
- throw ( e );
- }
- catch ( RuntimeException e )
- {
- throw ( e );
+ throw e;
}
catch ( Exception e )
{
@@ -169,13 +165,9 @@ public class LdapConnectionPool extends
super.returnObject( connection );
LOG.trace( "returned connection {}", connection );
}
- catch ( LdapException e )
- {
- throw ( e );
- }
- catch ( RuntimeException e )
+ catch ( LdapException | RuntimeException e )
{
- throw ( e );
+ throw e;
}
catch ( Exception e )
{
Modified: directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapConnectionWrapper.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapConnectionWrapper.java?rev=1771363&r1=1771362&r2=1771363&view=diff
==============================================================================
--- directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapConnectionWrapper.java (original)
+++ directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapConnectionWrapper.java Fri Nov 25 17:53:20 2016
@@ -65,9 +65,15 @@ import org.apache.directory.api.ldap.mod
*/
public class LdapConnectionWrapper implements LdapConnection, Wrapper<LdapConnection>
{
+ /** The wrapped connection */
protected LdapConnection connection;
+ /**
+ * Creates a new LdapConnectionWrapper instance
+ *
+ * @param connection The wrapped connection
+ */
protected LdapConnectionWrapper( LdapConnection connection )
{
this.connection = connection;
@@ -77,12 +83,16 @@ public class LdapConnectionWrapper imple
/**
* {@inheritDoc}
*/
+ @Override
public LdapConnection wrapped()
{
return connection;
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public boolean isConnected()
{
@@ -90,6 +100,9 @@ public class LdapConnectionWrapper imple
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public boolean isAuthenticated()
{
@@ -97,6 +110,9 @@ public class LdapConnectionWrapper imple
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public boolean connect() throws LdapException
{
@@ -104,6 +120,9 @@ public class LdapConnectionWrapper imple
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void close() throws IOException
{
@@ -111,6 +130,9 @@ public class LdapConnectionWrapper imple
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void add( Entry entry ) throws LdapException
{
@@ -118,6 +140,9 @@ public class LdapConnectionWrapper imple
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public AddResponse add( AddRequest addRequest ) throws LdapException
{
@@ -125,6 +150,9 @@ public class LdapConnectionWrapper imple
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void abandon( int messageId )
{
@@ -132,6 +160,9 @@ public class LdapConnectionWrapper imple
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void abandon( AbandonRequest abandonRequest )
{
@@ -139,6 +170,9 @@ public class LdapConnectionWrapper imple
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void bind() throws LdapException
{
@@ -146,6 +180,9 @@ public class LdapConnectionWrapper imple
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void anonymousBind() throws LdapException
{
@@ -153,6 +190,9 @@ public class LdapConnectionWrapper imple
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void bind( String name ) throws LdapException
{
@@ -160,6 +200,9 @@ public class LdapConnectionWrapper imple
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void bind( String name, String credentials ) throws LdapException
{
@@ -167,6 +210,9 @@ public class LdapConnectionWrapper imple
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void bind( Dn name ) throws LdapException
{
@@ -174,6 +220,9 @@ public class LdapConnectionWrapper imple
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void bind( Dn name, String credentials ) throws LdapException
{
@@ -181,6 +230,9 @@ public class LdapConnectionWrapper imple
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public BindResponse bind( BindRequest bindRequest ) throws LdapException
{
@@ -188,6 +240,9 @@ public class LdapConnectionWrapper imple
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public EntryCursor search( Dn baseDn, String filter, SearchScope scope, String... attributes )
throws LdapException
@@ -196,6 +251,9 @@ public class LdapConnectionWrapper imple
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public EntryCursor search( String baseDn, String filter, SearchScope scope, String... attributes )
throws LdapException
@@ -204,6 +262,9 @@ public class LdapConnectionWrapper imple
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public SearchCursor search( SearchRequest searchRequest ) throws LdapException
{
@@ -211,6 +272,9 @@ public class LdapConnectionWrapper imple
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void unBind() throws LdapException
{
@@ -218,6 +282,9 @@ public class LdapConnectionWrapper imple
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void setTimeOut( long timeOut )
{
@@ -225,6 +292,9 @@ public class LdapConnectionWrapper imple
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void modify( Dn dn, Modification... modifications ) throws LdapException
{
@@ -232,6 +302,9 @@ public class LdapConnectionWrapper imple
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void modify( String dn, Modification... modifications ) throws LdapException
{
@@ -239,6 +312,9 @@ public class LdapConnectionWrapper imple
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void modify( Entry entry, ModificationOperation modOp ) throws LdapException
{
@@ -246,6 +322,9 @@ public class LdapConnectionWrapper imple
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public ModifyResponse modify( ModifyRequest modRequest ) throws LdapException
{
@@ -253,6 +332,9 @@ public class LdapConnectionWrapper imple
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void rename( String entryDn, String newRdn ) throws LdapException
{
@@ -260,6 +342,9 @@ public class LdapConnectionWrapper imple
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void rename( Dn entryDn, Rdn newRdn ) throws LdapException
{
@@ -267,6 +352,9 @@ public class LdapConnectionWrapper imple
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void rename( String entryDn, String newRdn, boolean deleteOldRdn ) throws LdapException
{
@@ -274,6 +362,9 @@ public class LdapConnectionWrapper imple
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void rename( Dn entryDn, Rdn newRdn, boolean deleteOldRdn ) throws LdapException
{
@@ -281,6 +372,9 @@ public class LdapConnectionWrapper imple
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void move( String entryDn, String newSuperiorDn ) throws LdapException
{
@@ -288,6 +382,9 @@ public class LdapConnectionWrapper imple
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void move( Dn entryDn, Dn newSuperiorDn ) throws LdapException
{
@@ -295,6 +392,9 @@ public class LdapConnectionWrapper imple
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void moveAndRename( Dn entryDn, Dn newDn ) throws LdapException
{
@@ -302,6 +402,9 @@ public class LdapConnectionWrapper imple
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void moveAndRename( String entryDn, String newDn ) throws LdapException
{
@@ -309,6 +412,9 @@ public class LdapConnectionWrapper imple
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void moveAndRename( Dn entryDn, Dn newDn, boolean deleteOldRdn ) throws LdapException
{
@@ -316,6 +422,9 @@ public class LdapConnectionWrapper imple
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void moveAndRename( String entryDn, String newDn, boolean deleteOldRdn ) throws LdapException
{
@@ -323,6 +432,9 @@ public class LdapConnectionWrapper imple
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public ModifyDnResponse modifyDn( ModifyDnRequest modDnRequest ) throws LdapException
{
@@ -330,6 +442,9 @@ public class LdapConnectionWrapper imple
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void delete( String dn ) throws LdapException
{
@@ -337,6 +452,9 @@ public class LdapConnectionWrapper imple
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void delete( Dn dn ) throws LdapException
{
@@ -344,6 +462,9 @@ public class LdapConnectionWrapper imple
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public DeleteResponse delete( DeleteRequest deleteRequest ) throws LdapException
{
@@ -351,6 +472,9 @@ public class LdapConnectionWrapper imple
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public boolean compare( String dn, String attributeName, String value ) throws LdapException
{
@@ -358,6 +482,9 @@ public class LdapConnectionWrapper imple
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public boolean compare( String dn, String attributeName, byte[] value ) throws LdapException
{
@@ -365,6 +492,9 @@ public class LdapConnectionWrapper imple
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public boolean compare( String dn, String attributeName, Value<?> value ) throws LdapException
{
@@ -372,6 +502,9 @@ public class LdapConnectionWrapper imple
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public boolean compare( Dn dn, String attributeName, String value ) throws LdapException
{
@@ -379,6 +512,9 @@ public class LdapConnectionWrapper imple
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public boolean compare( Dn dn, String attributeName, byte[] value ) throws LdapException
{
@@ -386,6 +522,9 @@ public class LdapConnectionWrapper imple
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public boolean compare( Dn dn, String attributeName, Value<?> value ) throws LdapException
{
@@ -393,6 +532,9 @@ public class LdapConnectionWrapper imple
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public CompareResponse compare( CompareRequest compareRequest ) throws LdapException
{
@@ -400,6 +542,9 @@ public class LdapConnectionWrapper imple
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public ExtendedResponse extended( String oid ) throws LdapException
{
@@ -407,6 +552,9 @@ public class LdapConnectionWrapper imple
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public ExtendedResponse extended( String oid, byte[] value ) throws LdapException
{
@@ -414,6 +562,9 @@ public class LdapConnectionWrapper imple
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public ExtendedResponse extended( Oid oid ) throws LdapException
{
@@ -421,6 +572,9 @@ public class LdapConnectionWrapper imple
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public ExtendedResponse extended( Oid oid, byte[] value ) throws LdapException
{
@@ -428,6 +582,9 @@ public class LdapConnectionWrapper imple
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public ExtendedResponse extended( ExtendedRequest extendedRequest ) throws LdapException
{
@@ -435,6 +592,9 @@ public class LdapConnectionWrapper imple
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public boolean exists( String dn ) throws LdapException
{
@@ -442,6 +602,9 @@ public class LdapConnectionWrapper imple
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public boolean exists( Dn dn ) throws LdapException
{
@@ -449,6 +612,9 @@ public class LdapConnectionWrapper imple
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public Entry getRootDse() throws LdapException
{
@@ -456,6 +622,9 @@ public class LdapConnectionWrapper imple
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public Entry getRootDse( String... attributes ) throws LdapException
{
@@ -463,6 +632,9 @@ public class LdapConnectionWrapper imple
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public Entry lookup( Dn dn ) throws LdapException
{
@@ -470,6 +642,9 @@ public class LdapConnectionWrapper imple
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public Entry lookup( String dn ) throws LdapException
{
@@ -477,6 +652,9 @@ public class LdapConnectionWrapper imple
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public Entry lookup( Dn dn, String... attributes ) throws LdapException
{
@@ -484,6 +662,9 @@ public class LdapConnectionWrapper imple
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public Entry lookup( Dn dn, Control[] controls, String... attributes ) throws LdapException
{
@@ -491,6 +672,9 @@ public class LdapConnectionWrapper imple
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public Entry lookup( String dn, String... attributes ) throws LdapException
{
@@ -498,6 +682,9 @@ public class LdapConnectionWrapper imple
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public Entry lookup( String dn, Control[] controls, String... attributes ) throws LdapException
{
@@ -505,6 +692,9 @@ public class LdapConnectionWrapper imple
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public boolean isControlSupported( String controlOID ) throws LdapException
{
@@ -512,6 +702,9 @@ public class LdapConnectionWrapper imple
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public List<String> getSupportedControls() throws LdapException
{
@@ -519,6 +712,9 @@ public class LdapConnectionWrapper imple
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void loadSchema() throws LdapException
{
@@ -526,6 +722,9 @@ public class LdapConnectionWrapper imple
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public SchemaManager getSchemaManager()
{
@@ -533,6 +732,9 @@ public class LdapConnectionWrapper imple
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public LdapApiService getCodecService()
{
@@ -540,6 +742,9 @@ public class LdapConnectionWrapper imple
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public boolean isRequestCompleted( int messageId )
{
@@ -547,13 +752,19 @@ public class LdapConnectionWrapper imple
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public boolean doesFutureExistFor( int messageId )
{
- return connection.doesFutureExistFor( messageId );
+ return connection.isRequestCompleted( messageId );
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public BinaryAttributeDetector getBinaryAttributeDetector()
{
@@ -561,6 +772,9 @@ public class LdapConnectionWrapper imple
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void setBinaryAttributeDetector( BinaryAttributeDetector binaryAttributeDetecter )
{
@@ -568,6 +782,9 @@ public class LdapConnectionWrapper imple
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void setSchemaManager( SchemaManager schemaManager )
{
Modified: directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java?rev=1771363&r1=1771362&r2=1771363&view=diff
==============================================================================
--- directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java (original)
+++ directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java Fri Nov 25 17:53:20 2016
@@ -39,9 +39,7 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.locks.ReentrantLock;
@@ -56,7 +54,6 @@ import org.apache.directory.api.asn1.Dec
import org.apache.directory.api.asn1.util.Oid;
import org.apache.directory.api.ldap.codec.api.BinaryAttributeDetector;
import org.apache.directory.api.ldap.codec.api.DefaultConfigurableBinaryAttributeDetector;
-import org.apache.directory.api.ldap.codec.api.ExtendedResponseDecorator;
import org.apache.directory.api.ldap.codec.api.LdapApiService;
import org.apache.directory.api.ldap.codec.api.LdapApiServiceFactory;
import org.apache.directory.api.ldap.codec.api.LdapDecoder;
@@ -210,7 +207,7 @@ public class LdapNetworkConnection exten
private IoSession ldapSession;
/** a map to hold the ResponseFutures for all operations */
- private Map<Integer, ResponseFuture<? extends Response>> futureMap = new ConcurrentHashMap<Integer, ResponseFuture<? extends Response>>();
+ private Map<Integer, ResponseFuture<? extends Response>> futureMap = new ConcurrentHashMap<>();
/** list of controls supported by the server */
private List<String> supportedControls;
@@ -243,114 +240,8 @@ public class LdapNetworkConnection exten
static final String TIME_OUT_ERROR = "TimeOut occurred";
static final String NO_RESPONSE_ERROR = "The response queue has been emptied, no response was found.";
-
-
- //--------------------------- Helper methods ---------------------------//
- /**
- * {@inheritDoc}
- */
- public boolean isConnected()
- {
- return ( ldapSession != null ) && connected.get() && !ldapSession.isClosing();
- }
-
-
- /**
- * {@inheritDoc}
- */
- public boolean isAuthenticated()
- {
- return isConnected() && authenticated.get();
- }
-
-
- /**
- * Check that a session is valid, ie we can send requests to the
- * server
- *
- * @throws Exception If the session is not valid
- */
- private void checkSession() throws InvalidConnectionException
- {
- if ( ldapSession == null )
- {
- throw new InvalidConnectionException( "Cannot connect on the server, the connection is null" );
- }
-
- if ( !connected.get() )
- {
- throw new InvalidConnectionException( "Cannot connect on the server, the connection is invalid" );
- }
- }
-
-
- private void addToFutureMap( int messageId, ResponseFuture<? extends Response> future )
- {
- LOG.debug( "Adding <" + messageId + ", " + future.getClass().getName() + ">" );
- futureMap.put( messageId, future );
- }
-
-
- private ResponseFuture<? extends Response> getFromFutureMap( int messageId )
- {
- ResponseFuture<? extends Response> future = futureMap.remove( messageId );
-
- if ( future != null )
- {
- LOG.debug( "Removing <" + messageId + ", " + future.getClass().getName() + ">" );
- }
-
- return future;
- }
-
-
- private ResponseFuture<? extends Response> peekFromFutureMap( int messageId )
- {
- ResponseFuture<? extends Response> future = futureMap.get( messageId );
-
- // future can be null if there was a abandon operation on that messageId
- if ( future != null )
- {
- LOG.debug( "Getting <" + messageId + ", " + future.getClass().getName() + ">" );
- }
-
- return future;
- }
-
-
- /**
- * Get the largest timeout from the search time limit and the connection
- * timeout.
- *
- * @param connectionTimoutInMS Connection timeout
- * @param searchTimeLimitInSeconds Search timeout
- * @return The largest timeout
- */
- public long getTimeout( long connectionTimoutInMS, int searchTimeLimitInSeconds )
- {
- if ( searchTimeLimitInSeconds < 0 )
- {
- return connectionTimoutInMS;
- }
- else if ( searchTimeLimitInSeconds == 0 )
- {
- if ( config.getTimeout() == 0 )
- {
- return Long.MAX_VALUE;
- }
- else
- {
- return config.getTimeout();
- }
- }
- else
- {
- long searchTimeLimitInMS = searchTimeLimitInSeconds * 1000L;
- return Math.max( searchTimeLimitInMS, connectionTimoutInMS );
- }
- }
-
-
+
+
//------------------------- The constructors --------------------------//
/**
* Create a new instance of a LdapConnection on localhost,
@@ -485,6 +376,114 @@ public class LdapNetworkConnection exten
}
+ //--------------------------- Helper methods ---------------------------//
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean isConnected()
+ {
+ return ( ldapSession != null ) && connected.get() && !ldapSession.isClosing();
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean isAuthenticated()
+ {
+ return isConnected() && authenticated.get();
+ }
+
+
+ /**
+ * Check that a session is valid, ie we can send requests to the
+ * server
+ *
+ * @throws Exception If the session is not valid
+ */
+ private void checkSession() throws InvalidConnectionException
+ {
+ if ( ldapSession == null )
+ {
+ throw new InvalidConnectionException( "Cannot connect on the server, the connection is null" );
+ }
+
+ if ( !connected.get() )
+ {
+ throw new InvalidConnectionException( "Cannot connect on the server, the connection is invalid" );
+ }
+ }
+
+
+ private void addToFutureMap( int messageId, ResponseFuture<? extends Response> future )
+ {
+ LOG.debug( "Adding <" + messageId + ", " + future.getClass().getName() + ">" );
+ futureMap.put( messageId, future );
+ }
+
+
+ private ResponseFuture<? extends Response> getFromFutureMap( int messageId )
+ {
+ ResponseFuture<? extends Response> future = futureMap.remove( messageId );
+
+ if ( future != null )
+ {
+ LOG.debug( "Removing <" + messageId + ", " + future.getClass().getName() + ">" );
+ }
+
+ return future;
+ }
+
+
+ private ResponseFuture<? extends Response> peekFromFutureMap( int messageId )
+ {
+ ResponseFuture<? extends Response> future = futureMap.get( messageId );
+
+ // future can be null if there was a abandon operation on that messageId
+ if ( future != null )
+ {
+ LOG.debug( "Getting <" + messageId + ", " + future.getClass().getName() + ">" );
+ }
+
+ return future;
+ }
+
+
+ /**
+ * Get the largest timeout from the search time limit and the connection
+ * timeout.
+ *
+ * @param connectionTimoutInMS Connection timeout
+ * @param searchTimeLimitInSeconds Search timeout
+ * @return The largest timeout
+ */
+ public long getTimeout( long connectionTimoutInMS, int searchTimeLimitInSeconds )
+ {
+ if ( searchTimeLimitInSeconds < 0 )
+ {
+ return connectionTimoutInMS;
+ }
+ else if ( searchTimeLimitInSeconds == 0 )
+ {
+ if ( config.getTimeout() == 0 )
+ {
+ return Long.MAX_VALUE;
+ }
+ else
+ {
+ return config.getTimeout();
+ }
+ }
+ else
+ {
+ long searchTimeLimitInMS = searchTimeLimitInSeconds * 1000L;
+ return Math.max( searchTimeLimitInMS, connectionTimoutInMS );
+ }
+ }
+
+
private static LdapConnectionConfig buildConfig( String server, int port, boolean useSsl )
{
LdapConnectionConfig config = new LdapConnectionConfig();
@@ -558,6 +557,7 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
+ @Override
public boolean connect() throws LdapException
{
if ( ( ldapSession != null ) && connected.get() )
@@ -616,7 +616,6 @@ public class LdapNetworkConnection exten
// No need to wait
// We know that there was a permanent error such as "connection refused".
LOG.debug( "------>> Connection error: {}", connectionFuture.getException().getMessage() );
- break;
}
LOG.debug( "------>> Cannot get the connection... Retrying" );
@@ -635,10 +634,6 @@ public class LdapNetworkConnection exten
throw new LdapOtherException( e.getMessage(), e );
}
}
- else
- {
- break;
- }
}
}
}
@@ -693,14 +688,16 @@ public class LdapNetworkConnection exten
// Add a listener to close the session in the session.
closeFuture.addListener( new IoFutureListener<IoFuture>()
{
+ @Override
public void operationComplete( IoFuture future )
{
// Process all the waiting operations and cancel them
LOG.debug( "received a NoD, closing everything" );
- for ( int messageId : futureMap.keySet() )
+ for ( Map.Entry<Integer, ResponseFuture<? extends Response>> entry : futureMap.entrySet() )
{
- ResponseFuture<?> responseFuture = futureMap.get( messageId );
+ int messageId = entry.getKey();
+ ResponseFuture<?> responseFuture = entry.getValue();
LOG.debug( "closing {}", responseFuture );
responseFuture.cancel();
@@ -740,10 +737,6 @@ public class LdapNetworkConnection exten
( ( SearchFuture ) responseFuture ).set( SearchNoDResponse.PROTOCOLERROR );
}
}
- catch ( ExecutionException e )
- {
- LOG.error( "Error while processing the NoD for {}", responseFuture );
- }
catch ( InterruptedException e )
{
LOG.error( "Error while processing the NoD for {}", responseFuture );
@@ -797,12 +790,13 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
+ @Override
public void close() throws IOException
{
// Close the session
if ( ( ldapSession != null ) && connected.get() )
{
- ldapSession.close( true );
+ ldapSession.closeNow();
}
connected.set( false );
@@ -835,6 +829,7 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
+ @Override
public void add( Entry entry ) throws LdapException
{
if ( entry == null )
@@ -856,6 +851,7 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
+ @Override
public AddFuture addAsync( Entry entry ) throws LdapException
{
if ( entry == null )
@@ -875,6 +871,7 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
+ @Override
public AddResponse add( AddRequest addRequest ) throws LdapException
{
if ( addRequest == null )
@@ -920,18 +917,6 @@ public class LdapNetworkConnection exten
return addResponse;
}
- catch ( TimeoutException te )
- {
- // Send an abandon request
- if ( !addFuture.isCancelled() )
- {
- abandon( addRequest.getMessageId() );
- }
-
- // We didn't received anything : this is an error
- LOG.error( "Add failed : timeout occurred" );
- throw new LdapException( TIME_OUT_ERROR, te );
- }
catch ( Exception ie )
{
// Catch all other exceptions
@@ -951,6 +936,7 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
+ @Override
public AddFuture addAsync( AddRequest addRequest ) throws LdapException
{
if ( addRequest == null )
@@ -988,6 +974,7 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
+ @Override
public void abandon( int messageId )
{
if ( messageId < 0 )
@@ -1007,6 +994,7 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
+ @Override
public void abandon( AbandonRequest abandonRequest )
{
if ( abandonRequest == null )
@@ -1060,6 +1048,7 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
+ @Override
public void bind() throws LdapException
{
LOG.debug( "Bind request" );
@@ -1076,6 +1065,7 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
+ @Override
public void anonymousBind() throws LdapException
{
LOG.debug( "Anonymous Bind request" );
@@ -1092,6 +1082,7 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
+ @Override
public BindFuture bindAsync() throws LdapException
{
LOG.debug( "Asynchronous Bind request" );
@@ -1106,6 +1097,7 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
+ @Override
public BindFuture anonymousBindAsync() throws LdapException
{
LOG.debug( "Anonymous asynchronous Bind request" );
@@ -1139,6 +1131,7 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
+ @Override
public BindFuture bindAsync( String name, String credentials ) throws LdapException
{
LOG.debug( "Bind request : {}", name );
@@ -1179,6 +1172,7 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
+ @Override
public BindFuture bindAsync( Dn name, String credentials ) throws LdapException
{
LOG.debug( "Bind request : {}", name );
@@ -1200,6 +1194,7 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
+ @Override
public BindResponse bind( BindRequest bindRequest ) throws LdapException
{
if ( bindRequest == null )
@@ -1240,12 +1235,6 @@ public class LdapNetworkConnection exten
return bindResponse;
}
- catch ( TimeoutException te )
- {
- // We didn't received anything : this is an error
- LOG.error( "Bind failed : timeout occurred" );
- throw new LdapException( TIME_OUT_ERROR, te );
- }
catch ( Exception ie )
{
// Catch all other exceptions
@@ -1276,6 +1265,7 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
+ @Override
public BindFuture bindAsync( BindRequest bindRequest ) throws LdapException
{
if ( bindRequest == null )
@@ -1382,12 +1372,6 @@ public class LdapNetworkConnection exten
return bindResponse;
}
- catch ( TimeoutException te )
- {
- // We didn't received anything : this is an error
- LOG.error( "Bind failed : timeout occurred" );
- throw new LdapException( TIME_OUT_ERROR, te );
- }
catch ( Exception ie )
{
// Catch all other exceptions
@@ -1445,12 +1429,6 @@ public class LdapNetworkConnection exten
return bindResponse;
}
- catch ( TimeoutException te )
- {
- // We didn't received anything : this is an error
- LOG.error( "Bind failed : timeout occurred" );
- throw new LdapException( TIME_OUT_ERROR, te );
- }
catch ( Exception ie )
{
// Catch all other exceptions
@@ -1522,12 +1500,6 @@ public class LdapNetworkConnection exten
return bindResponse;
}
- catch ( TimeoutException te )
- {
- // We didn't received anything : this is an error
- LOG.error( "Bind failed : timeout occurred" );
- throw new LdapException( TIME_OUT_ERROR, te );
- }
catch ( Exception ie )
{
// Catch all other exceptions
@@ -1585,12 +1557,6 @@ public class LdapNetworkConnection exten
return bindResponse;
}
- catch ( TimeoutException te )
- {
- // We didn't received anything : this is an error
- LOG.error( "Bind failed : timeout occurred" );
- throw new LdapException( TIME_OUT_ERROR, te );
- }
catch ( Exception ie )
{
// Catch all other exceptions
@@ -1660,6 +1626,7 @@ public class LdapNetworkConnection exten
final SaslGssApiRequest requetFinal = request;
return ( BindFuture ) Subject.doAs( loginContext.getSubject(), new PrivilegedExceptionAction<Object>()
{
+ @Override
public Object run() throws Exception
{
return bindSasl( requetFinal );
@@ -1676,6 +1643,7 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
+ @Override
public EntryCursor search( Dn baseDn, String filter, SearchScope scope, String... attributes )
throws LdapException
{
@@ -1702,6 +1670,7 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
+ @Override
public EntryCursor search( String baseDn, String filter, SearchScope scope, String... attributes )
throws LdapException
{
@@ -1712,6 +1681,7 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
+ @Override
public SearchFuture searchAsync( Dn baseDn, String filter, SearchScope scope, String... attributes )
throws LdapException
{
@@ -1732,6 +1702,7 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
+ @Override
public SearchFuture searchAsync( String baseDn, String filter, SearchScope scope, String... attributes )
throws LdapException
{
@@ -1742,6 +1713,7 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
+ @Override
public SearchFuture searchAsync( SearchRequest searchRequest ) throws LdapException
{
if ( searchRequest == null )
@@ -1793,6 +1765,7 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
+ @Override
public SearchCursor search( SearchRequest searchRequest ) throws LdapException
{
if ( searchRequest == null )
@@ -1816,6 +1789,7 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
+ @Override
public void unBind() throws LdapException
{
// If the session has not been establish, or is closed, we get out immediately
@@ -1835,9 +1809,7 @@ public class LdapNetworkConnection exten
// Use this for logging instead: WriteFuture unbindFuture = ldapSession.write( unbindRequest );
WriteFuture unbindFuture = ldapSession.write( unbindRequest );
- //LOG.debug( "waiting for unbindFuture" );
unbindFuture.awaitUninterruptibly( timeout );
- //LOG.debug( "unbindFuture done" );
authenticated.set( false );
@@ -1857,8 +1829,8 @@ public class LdapNetworkConnection exten
}
catch ( IOException e )
{
- // TODO Auto-generated catch block
- e.printStackTrace();
+ LOG.error( e.getMessage() );
+ throw new LdapException( e.getMessage() );
}
connected.set( false );
@@ -1885,6 +1857,7 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
+ @Override
public void setTimeOut( long timeout )
{
if ( timeout <= 0 )
@@ -1926,7 +1899,7 @@ public class LdapNetworkConnection exten
}
}
- session.close( true );
+ session.closeNow();
}
@@ -1980,7 +1953,7 @@ public class LdapNetworkConnection exten
if ( isNoD )
{
// close the session
- session.close( true );
+ session.closeNow();
return;
}
@@ -2131,7 +2104,7 @@ public class LdapNetworkConnection exten
break;
case INTERMEDIATE_RESPONSE:
- IntermediateResponse intermediateResponse = null;
+ IntermediateResponse intermediateResponse;
if ( responseFuture instanceof SearchFuture )
{
@@ -2287,6 +2260,7 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
+ @Override
public void modify( Entry entry, ModificationOperation modOp ) throws LdapException
{
if ( entry == null )
@@ -2314,6 +2288,7 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
+ @Override
public void modify( Dn dn, Modification... modifications ) throws LdapException
{
if ( dn == null )
@@ -2346,6 +2321,7 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
+ @Override
public void modify( String dn, Modification... modifications ) throws LdapException
{
modify( new Dn( dn ), modifications );
@@ -2355,6 +2331,7 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
+ @Override
public ModifyResponse modify( ModifyRequest modRequest ) throws LdapException
{
if ( modRequest == null )
@@ -2399,18 +2376,6 @@ public class LdapNetworkConnection exten
return modifyResponse;
}
- catch ( TimeoutException te )
- {
- // Send an abandon request
- if ( !modifyFuture.isCancelled() )
- {
- abandon( modRequest.getMessageId() );
- }
-
- // We didn't received anything : this is an error
- LOG.error( "Modify failed : timeout occurred" );
- throw new LdapException( TIME_OUT_ERROR, te );
- }
catch ( Exception ie )
{
// Catch all other exceptions
@@ -2430,6 +2395,7 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
+ @Override
public ModifyFuture modifyAsync( ModifyRequest modRequest ) throws LdapException
{
if ( modRequest == null )
@@ -2465,6 +2431,7 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
+ @Override
public void rename( String entryDn, String newRdn ) throws LdapException
{
rename( entryDn, newRdn, true );
@@ -2474,6 +2441,7 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
+ @Override
public void rename( Dn entryDn, Rdn newRdn ) throws LdapException
{
rename( entryDn, newRdn, true );
@@ -2483,6 +2451,7 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
+ @Override
public void rename( String entryDn, String newRdn, boolean deleteOldRdn ) throws LdapException
{
if ( entryDn == null )
@@ -2514,6 +2483,7 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
+ @Override
public void rename( Dn entryDn, Rdn newRdn, boolean deleteOldRdn ) throws LdapException
{
if ( entryDn == null )
@@ -2544,6 +2514,7 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
+ @Override
public void move( String entryDn, String newSuperiorDn ) throws LdapException
{
if ( entryDn == null )
@@ -2575,6 +2546,7 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
+ @Override
public void move( Dn entryDn, Dn newSuperiorDn ) throws LdapException
{
if ( entryDn == null )
@@ -2595,7 +2567,6 @@ public class LdapNetworkConnection exten
modDnRequest.setName( entryDn );
modDnRequest.setNewSuperior( newSuperiorDn );
- //TODO not setting the below value is resulting in error
modDnRequest.setNewRdn( entryDn.getRdn() );
ModifyDnResponse modifyDnResponse = modifyDn( modDnRequest );
@@ -2607,6 +2578,7 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
+ @Override
public void moveAndRename( Dn entryDn, Dn newDn ) throws LdapException
{
moveAndRename( entryDn, newDn, true );
@@ -2616,6 +2588,7 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
+ @Override
public void moveAndRename( String entryDn, String newDn ) throws LdapException
{
moveAndRename( new Dn( entryDn ), new Dn( newDn ), true );
@@ -2625,6 +2598,7 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
+ @Override
public void moveAndRename( Dn entryDn, Dn newDn, boolean deleteOldRdn ) throws LdapException
{
// Check the parameters first
@@ -2675,6 +2649,7 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
+ @Override
public void moveAndRename( String entryDn, String newDn, boolean deleteOldRdn ) throws LdapException
{
moveAndRename( new Dn( entryDn ), new Dn( newDn ), true );
@@ -2684,6 +2659,7 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
+ @Override
public ModifyDnResponse modifyDn( ModifyDnRequest modDnRequest ) throws LdapException
{
if ( modDnRequest == null )
@@ -2722,18 +2698,6 @@ public class LdapNetworkConnection exten
return modifyDnResponse;
}
- catch ( TimeoutException te )
- {
- // Send an abandon request
- if ( !modifyDnFuture.isCancelled() )
- {
- abandon( modDnRequest.getMessageId() );
- }
-
- // We didn't received anything : this is an error
- LOG.error( "Modify failed : timeout occurred" );
- throw new LdapException( TIME_OUT_ERROR, te );
- }
catch ( Exception ie )
{
// Catch all other exceptions
@@ -2753,6 +2717,7 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
+ @Override
public ModifyDnFuture modifyDnAsync( ModifyDnRequest modDnRequest ) throws LdapException
{
if ( modDnRequest == null )
@@ -2795,6 +2760,7 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
+ @Override
public void delete( String dn ) throws LdapException
{
delete( new Dn( dn ) );
@@ -2804,6 +2770,7 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
+ @Override
public void delete( Dn dn ) throws LdapException
{
DeleteRequest deleteRequest = new DeleteRequestImpl();
@@ -2885,6 +2852,7 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
+ @Override
public DeleteResponse delete( DeleteRequest deleteRequest ) throws LdapException
{
if ( deleteRequest == null )
@@ -2923,18 +2891,6 @@ public class LdapNetworkConnection exten
return delResponse;
}
- catch ( TimeoutException te )
- {
- // Send an abandon request
- if ( !deleteFuture.isCancelled() )
- {
- abandon( deleteRequest.getMessageId() );
- }
-
- // We didn't received anything : this is an error
- LOG.error( "Del failed : timeout occurred" );
- throw new LdapException( TIME_OUT_ERROR, te );
- }
catch ( Exception ie )
{
// Catch all other exceptions
@@ -2954,6 +2910,7 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
+ @Override
public DeleteFuture deleteAsync( DeleteRequest deleteRequest ) throws LdapException
{
if ( deleteRequest == null )
@@ -2990,6 +2947,7 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
+ @Override
public boolean compare( String dn, String attributeName, String value ) throws LdapException
{
return compare( new Dn( dn ), attributeName, value );
@@ -2999,6 +2957,7 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
+ @Override
public boolean compare( String dn, String attributeName, byte[] value ) throws LdapException
{
return compare( new Dn( dn ), attributeName, value );
@@ -3008,6 +2967,7 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
+ @Override
public boolean compare( String dn, String attributeName, Value<?> value ) throws LdapException
{
return compare( new Dn( dn ), attributeName, value );
@@ -3017,6 +2977,7 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
+ @Override
public boolean compare( Dn dn, String attributeName, String value ) throws LdapException
{
CompareRequest compareRequest = new CompareRequestImpl();
@@ -3033,6 +2994,7 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
+ @Override
public boolean compare( Dn dn, String attributeName, byte[] value ) throws LdapException
{
CompareRequest compareRequest = new CompareRequestImpl();
@@ -3049,6 +3011,7 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
+ @Override
public boolean compare( Dn dn, String attributeName, Value<?> value ) throws LdapException
{
CompareRequest compareRequest = new CompareRequestImpl();
@@ -3073,6 +3036,7 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
+ @Override
public CompareResponse compare( CompareRequest compareRequest ) throws LdapException
{
if ( compareRequest == null )
@@ -3111,18 +3075,6 @@ public class LdapNetworkConnection exten
return compareResponse;
}
- catch ( TimeoutException te )
- {
- // Send an abandon request
- if ( !compareFuture.isCancelled() )
- {
- abandon( compareRequest.getMessageId() );
- }
-
- // We didn't received anything : this is an error
- LOG.error( "Compare failed : timeout occurred" );
- throw new LdapException( TIME_OUT_ERROR, te );
- }
catch ( Exception ie )
{
// Catch all other exceptions
@@ -3142,6 +3094,7 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
+ @Override
public CompareFuture compareAsync( CompareRequest compareRequest ) throws LdapException
{
if ( compareRequest == null )
@@ -3178,6 +3131,7 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
+ @Override
public ExtendedResponse extended( String oid ) throws LdapException
{
return extended( oid, null );
@@ -3187,6 +3141,7 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
+ @Override
public ExtendedResponse extended( String oid, byte[] value ) throws LdapException
{
try
@@ -3205,6 +3160,7 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
+ @Override
public ExtendedResponse extended( Oid oid ) throws LdapException
{
return extended( oid, null );
@@ -3214,6 +3170,7 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
+ @Override
public ExtendedResponse extended( Oid oid, byte[] value ) throws LdapException
{
ExtendedRequest extendedRequest =
@@ -3225,6 +3182,7 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
+ @Override
public ExtendedResponse extended( ExtendedRequest extendedRequest ) throws LdapException
{
if ( extendedRequest == null )
@@ -3269,21 +3227,7 @@ public class LdapNetworkConnection exten
}
// Decode the payload now
- ExtendedResponseDecorator<?> decoratedResponse = codec.decorate( response );
-
- return decoratedResponse;
- }
- catch ( TimeoutException te )
- {
- // Send an abandon request
- if ( !extendedFuture.isCancelled() )
- {
- abandon( extendedRequest.getMessageId() );
- }
-
- // We didn't received anything : this is an error
- LOG.error( "Extended failed : timeout occurred" );
- throw new LdapException( TIME_OUT_ERROR, te );
+ return codec.decorate( response );
}
catch ( Exception ie )
{
@@ -3304,6 +3248,7 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
+ @Override
public ExtendedFuture extendedAsync( ExtendedRequest extendedRequest ) throws LdapException
{
if ( extendedRequest == null )
@@ -3332,6 +3277,7 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
+ @Override
public boolean exists( String dn ) throws LdapException
{
return exists( new Dn( dn ) );
@@ -3341,6 +3287,7 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
+ @Override
public boolean exists( Dn dn ) throws LdapException
{
try
@@ -3364,6 +3311,7 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
+ @Override
public Entry getRootDse() throws LdapException
{
return lookup( Dn.ROOT_DSE, SchemaConstants.ALL_USER_ATTRIBUTES_ARRAY );
@@ -3373,6 +3321,7 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
+ @Override
public Entry getRootDse( String... attributes ) throws LdapException
{
return lookup( Dn.ROOT_DSE, attributes );
@@ -3382,6 +3331,7 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
+ @Override
public Entry lookup( Dn dn ) throws LdapException
{
return lookup( dn, SchemaConstants.ALL_USER_ATTRIBUTES_ARRAY );
@@ -3391,6 +3341,7 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
+ @Override
public Entry lookup( String dn ) throws LdapException
{
return lookup( dn, SchemaConstants.ALL_USER_ATTRIBUTES_ARRAY );
@@ -3400,6 +3351,7 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
+ @Override
public Entry lookup( Dn dn, String... attributes ) throws LdapException
{
return lookup( dn, null, attributes );
@@ -3409,6 +3361,7 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
+ @Override
public Entry lookup( Dn dn, Control[] controls, String... attributes ) throws LdapException
{
Entry entry = null;
@@ -3463,6 +3416,7 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
+ @Override
public Entry lookup( String dn, String... attributes ) throws LdapException
{
return lookup( new Dn( dn ), null, attributes );
@@ -3472,6 +3426,7 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
+ @Override
public Entry lookup( String dn, Control[] controls, String... attributes ) throws LdapException
{
return lookup( new Dn( dn ), controls, attributes );
@@ -3481,6 +3436,7 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
+ @Override
public boolean isControlSupported( String controlOID ) throws LdapException
{
return getSupportedControls().contains( controlOID );
@@ -3490,6 +3446,7 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
+ @Override
public List<String> getSupportedControls() throws LdapException
{
if ( supportedControls != null )
@@ -3502,7 +3459,7 @@ public class LdapNetworkConnection exten
fetchRootDSE();
}
- supportedControls = new ArrayList<String>();
+ supportedControls = new ArrayList<>();
Attribute attr = rootDse.get( SchemaConstants.SUPPORTED_CONTROL_AT );
@@ -3531,6 +3488,7 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
+ @Override
public void loadSchema() throws LdapException
{
loadSchema( new DefaultSchemaLoader( this ) );
@@ -3540,6 +3498,7 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
+ @Override
public void loadSchemaRelaxed() throws LdapException
{
loadSchema( new DefaultSchemaLoader( this, true ) );
@@ -3602,13 +3561,18 @@ public class LdapNetworkConnection exten
{
loadSchema();
}
+
+ if ( schemaManager == null )
+ {
+ throw new LdapException( "Cannot load the schema" );
+ }
OpenLdapSchemaParser olsp = new OpenLdapSchemaParser();
olsp.setQuirksMode( true );
olsp.parse( schemaFile );
Registries registries = schemaManager.getRegistries();
- List<Throwable> errors = new ArrayList<Throwable>();
+ List<Throwable> errors = new ArrayList<>();
for ( AttributeType atType : olsp.getAttributeTypes() )
{
@@ -3646,6 +3610,7 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
+ @Override
public LdapApiService getCodecService()
{
return codec;
@@ -3655,6 +3620,7 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
+ @Override
public SchemaManager getSchemaManager()
{
return schemaManager;
@@ -3716,6 +3682,7 @@ public class LdapNetworkConnection exten
*
* @return the configuration of the connection
*/
+ @Override
public LdapConnectionConfig getConfig()
{
return config;
@@ -3765,6 +3732,7 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
+ @Override
public boolean doesFutureExistFor( int messageId )
{
ResponseFuture<?> responseFuture = futureMap.get( messageId );
@@ -3775,6 +3743,7 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
+ @Override
public boolean isRequestCompleted( int messageId )
{
ResponseFuture<?> responseFuture = futureMap.get( messageId );
@@ -3792,7 +3761,7 @@ public class LdapNetworkConnection exten
{
if ( conCloseListeners == null )
{
- conCloseListeners = new ArrayList<ConnectionClosedEventListener>();
+ conCloseListeners = new ArrayList<>();
}
conCloseListeners.add( ccListener );
@@ -3802,9 +3771,10 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
+ @Override
public void inputClosed( IoSession session ) throws Exception
{
- session.close( true );
+ session.closeNow();
}
@@ -3814,12 +3784,12 @@ public class LdapNetworkConnection exten
*
* @param session the newly created session
*/
+ @Override
public void sessionCreated( IoSession session ) throws Exception
{
// Last, store the message container
LdapMessageContainer<? extends MessageDecorator<Message>> ldapMessageContainer =
- new LdapMessageContainer<MessageDecorator<Message>>(
- codec, config.getBinaryAttributeDetector() );
+ new LdapMessageContainer<>( codec, config.getBinaryAttributeDetector() );
session.setAttribute( LdapDecoder.MESSAGE_CONTAINER_ATTR, ldapMessageContainer );
}
@@ -3837,7 +3807,7 @@ public class LdapNetworkConnection exten
return;
}
- ldapSession.close( true );
+ ldapSession.closeNow();
connected.set( false );
// Reset the messageId
messageId.set( 0 );
@@ -4008,12 +3978,12 @@ public class LdapNetworkConnection exten
try
{
- BindResponse bindResponse = null;
- byte[] response = null;
- ResultCodeEnum result = null;
+ BindResponse bindResponse;
+ byte[] response;
+ ResultCodeEnum result;
// Creating a map for SASL properties
- Map<String, Object> properties = new HashMap<String, Object>();
+ Map<String, Object> properties = new HashMap<>();
// Quality of Protection SASL property
if ( saslRequest.getQualityOfProtection() != null )
@@ -4145,7 +4115,7 @@ public class LdapNetworkConnection exten
}
catch ( Exception e )
{
- e.printStackTrace();
+ LOG.error( e.getMessage() );
throw new LdapException( e );
}
}
@@ -4264,6 +4234,7 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
+ @Override
public BinaryAttributeDetector getBinaryAttributeDetector()
{
if ( config != null )
@@ -4280,6 +4251,7 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
+ @Override
public void setBinaryAttributeDetector( BinaryAttributeDetector binaryAttributeDetector )
{
if ( config != null )