directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject [directory-studio] branch master updated: Rename variables and methods to clarify if timeout is in seconds or milliseconds
Date Sun, 11 Nov 2018 13:27:57 GMT
This is an automated email from the ASF dual-hosted git repository.

seelmann pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/directory-studio.git


The following commit(s) were added to refs/heads/master by this push:
     new ed7afe2  Rename variables and methods to clarify if timeout is in seconds or milliseconds
ed7afe2 is described below

commit ed7afe2a434d993790c88686a728735a7f0d7c5c
Author: Stefan Seelmann <mail@stefan-seelmann.de>
AuthorDate: Sun Nov 11 14:27:22 2018 +0100

    Rename variables and methods to clarify if timeout is in seconds or milliseconds
---
 .../studio/connection/core/Connection.java         | 18 ++++++------
 .../connection/core/ConnectionParameter.java       | 23 ++++++++--------
 .../studio/connection/core/io/ConnectionIO.java    |  4 +--
 .../core/io/api/DirectoryApiConnectionWrapper.java |  8 +++---
 .../core/io/jndi/JNDIConnectionWrapper.java        |  8 +++---
 .../ui/widgets/NetworkParameterPage.java           | 32 +++++++++++-----------
 6 files changed, 47 insertions(+), 46 deletions(-)

diff --git a/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/Connection.java
b/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/Connection.java
index 40c27b4..958ffec 100644
--- a/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/Connection.java
+++ b/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/Connection.java
@@ -209,7 +209,7 @@ public class Connection implements ConnectionPropertyPageProvider, IAdaptable
     {
         ConnectionParameter cp = new ConnectionParameter( getName(), getHost(), getPort(),
getEncryptionMethod(),
             getNetworkProvider(), getAuthMethod(), getBindPrincipal(), getBindPassword(),
getSaslRealm(), isReadOnly(),
-            getConnectionParameter().getExtendedProperties() , getTimeout() );
+            getConnectionParameter().getExtendedProperties() , getTimeoutMillis() );
 
         return new Connection( cp );
     }
@@ -534,13 +534,13 @@ public class Connection implements ConnectionPropertyPageProvider, IAdaptable
 
 
     /**
-     * Gets the timeout.
+     * Gets the timeout in milliseconds.
      * 
-     * @return the timeout
+     * @return the timeout in milliseconds
      */
-    public long getTimeout()
+    public long getTimeoutMillis()
     {
-        return connectionParameter.getTimeout();
+        return connectionParameter.getTimeoutMillis();
     }
 
 
@@ -653,13 +653,13 @@ public class Connection implements ConnectionPropertyPageProvider, IAdaptable
 
     
     /**
-     * Sets the timeout.
+     * Sets the timeout in milliseconds.
      * 
-     * @param timeout the timeout
+     * @param timeoutMillis the timeout in milliseconds
      */
-    public void setTimeout( long timeout )
+    public void setTimeoutMillis( long timeoutMillis )
     {
-        connectionParameter.setTimeout( timeout );
+        connectionParameter.setTimeoutMillis( timeoutMillis );
         ConnectionEventRegistry.fireConnectionUpdated( this, this );
     }
 
diff --git a/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/ConnectionParameter.java
b/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/ConnectionParameter.java
index 59838a8..44007f8 100644
--- a/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/ConnectionParameter.java
+++ b/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/ConnectionParameter.java
@@ -193,7 +193,7 @@ public class ConnectionParameter
     private Map<String, String> extendedProperties;
     
     /** The connection timeout. Default to 30 seconds */
-    private long timeout = 30000L;
+    private long timeoutMillis = 30000L;
 
 
     /**
@@ -218,10 +218,11 @@ public class ConnectionParameter
      * @param saslRealm the SASL realm
      * @param isReadOnly the read only flag
      * @param extendedProperties the extended properties
+     * @param timeoutMillis the timeout in milliseconds
      */
     public ConnectionParameter( String name, String host, int port, EncryptionMethod encryptionMethod,
         NetworkProvider networkProvider, AuthenticationMethod authMethod, String bindPrincipal,
String bindPassword,
-        String saslRealm, boolean isReadOnly, Map<String, String> extendedProperties,
long timeout )
+        String saslRealm, boolean isReadOnly, Map<String, String> extendedProperties,
long timeoutMillis )
     {
         this.id = createId();
         this.name = name;
@@ -241,7 +242,7 @@ public class ConnectionParameter
             this.extendedProperties.putAll( extendedProperties );
         }
 
-        this.timeout = timeout;
+        this.timeoutMillis = timeoutMillis;
     }
 
 
@@ -851,24 +852,24 @@ public class ConnectionParameter
 
 
     /**
-     * Gets the timeout.
+     * Gets the timeout in milliseconds.
      * 
-     * @return the timeout
+     * @return the timeout in milliseconds
      */
-    public long getTimeout()
+    public long getTimeoutMillis()
     {
-        return timeout;
+        return timeoutMillis;
     }
 
 
     /**
-     * Sets the timeout.
+     * Sets the timeout in milliseconds.
      * 
-     * @param timeout the timeout
+     * @param timeoutMillis the timeout in milliseconds
      */
-    public void setTimeout( long timeout )
+    public void setTimeoutMillis( long timeoutMillis )
     {
-        this.timeout = timeout;
+        this.timeoutMillis = timeoutMillis;
     }
 
 
diff --git a/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/ConnectionIO.java
b/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/ConnectionIO.java
index fdf2496..a8caabb 100644
--- a/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/ConnectionIO.java
+++ b/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/ConnectionIO.java
@@ -188,7 +188,7 @@ public class ConnectionIO
         {
             try
             {
-                connection.setTimeout( Long.parseLong( timeoutAttribute.getValue() ) );
+                connection.setTimeoutMillis( Long.parseLong( timeoutAttribute.getValue()
) );
             }
             catch ( NumberFormatException e )
             {
@@ -540,7 +540,7 @@ public class ConnectionIO
         connectionElement.addAttribute( READ_ONLY_TAG, Boolean.toString( connection.isReadOnly()
) ); //$NON-NLS-1$
         
         // Connection timeout
-        connectionElement.addAttribute( TIMEOUT_TAG, Long.toString( connection.getTimeout()
) ); //$NON-NLS-1$
+        connectionElement.addAttribute( TIMEOUT_TAG, Long.toString( connection.getTimeoutMillis()
) ); //$NON-NLS-1$
 
         // Extended Properties
         Element extendedPropertiesElement = connectionElement.addElement( EXTENDED_PROPERTIES_TAG
);
diff --git a/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/api/DirectoryApiConnectionWrapper.java
b/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/api/DirectoryApiConnectionWrapper.java
index 1f91969..ec81e6e 100644
--- a/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/api/DirectoryApiConnectionWrapper.java
+++ b/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/api/DirectoryApiConnectionWrapper.java
@@ -188,14 +188,14 @@ public class DirectoryApiConnectionWrapper implements ConnectionWrapper
         ldapConnectionConfig.setLdapHost( connection.getHost() );
         ldapConnectionConfig.setLdapPort( connection.getPort() );
         
-        long timeout = connection.getTimeout();
+        long timeoutMillis = connection.getTimeoutMillis();
         
-        if ( timeout < 0 ) 
+        if ( timeoutMillis < 0 )
         {
-            timeout = 30000L;
+            timeoutMillis = 30000L;
         }
         
-        ldapConnectionConfig.setTimeout( timeout );
+        ldapConnectionConfig.setTimeout( timeoutMillis );
         
         binaryAttributeDetector = new DefaultConfigurableBinaryAttributeDetector();
         ldapConnectionConfig.setBinaryAttributeDetector( binaryAttributeDetector );
diff --git a/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/JNDIConnectionWrapper.java
b/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/JNDIConnectionWrapper.java
index 5c961d9..fac60e7 100644
--- a/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/JNDIConnectionWrapper.java
+++ b/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/JNDIConnectionWrapper.java
@@ -825,7 +825,7 @@ public class JNDIConnectionWrapper implements ConnectionWrapper
         // setup connection parameters
         String host = connection.getConnectionParameter().getHost();
         int port = connection.getConnectionParameter().getPort();
-        long timeout = connection.getConnectionParameter().getTimeout();
+        long timeoutMillis = connection.getConnectionParameter().getTimeoutMillis();
 
         useLdaps = connection.getConnectionParameter().getEncryptionMethod() == ConnectionParameter.EncryptionMethod.LDAPS;
         useStartTLS = connection.getConnectionParameter().getEncryptionMethod() == ConnectionParameter.EncryptionMethod.START_TLS;
@@ -845,11 +845,11 @@ public class JNDIConnectionWrapper implements ConnectionWrapper
          */
         if ( !useLdaps )
         {
-            if ( timeout < 0 )
+            if ( timeoutMillis < 0 )
             {
-                timeout = 0;
+                timeoutMillis = 0;
             }
-            environment.put( COM_SUN_JNDI_LDAP_CONNECT_TIMEOUT, Long.toString( timeout )
); //$NON-NLS-1$
+            environment.put( COM_SUN_JNDI_LDAP_CONNECT_TIMEOUT, Long.toString( timeoutMillis
) ); //$NON-NLS-1$
         }
 
         environment.put( COM_SUN_JNDI_DNS_TIMEOUT_INITIAL, "2000" ); //$NON-NLS-1$
diff --git a/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/NetworkParameterPage.java
b/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/NetworkParameterPage.java
index 7e3092e..61a24da 100644
--- a/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/NetworkParameterPage.java
+++ b/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/NetworkParameterPage.java
@@ -136,7 +136,7 @@ public class NetworkParameterPage extends AbstractConnectionParameterPage
     private Button readOnlyConnectionCheckbox;
 
     /** A timeout for the connection. Default to 30s */
-    private Text timeoutText;
+    private Text timeoutSecondsText;
 
     /**
      * A listener for the Link data widget. It will open the CertificateValidationPreference
dialog.
@@ -191,21 +191,21 @@ public class NetworkParameterPage extends AbstractConnectionParameterPage
 
 
     /**
-     * Gets the timeout
+     * Gets the timeout in seconds.
      *
-     * @return The tiemout
+     * @return The timeout in seconds
      */
-    private int getTimeout()
+    private int getTimeoutSeconds()
     {
-        String timeoutString = timeoutText.getText();
+        String timeoutSecondsString = timeoutSecondsText.getText();
 
-        if ( Strings.isEmpty( timeoutString ) )
+        if ( Strings.isEmpty( timeoutSecondsString ) )
         {
             return 30;
         }
         else
         {
-            return Integer.parseInt( timeoutString );
+            return Integer.parseInt( timeoutSecondsString );
         }
     }
 
@@ -310,8 +310,8 @@ public class NetworkParameterPage extends AbstractConnectionParameterPage
 
         // The timeout
         BaseWidgetUtils.createLabel( groupComposite, Messages.getString( "NetworkParameterPage.Timeout"
), 2 ); //$NON-NLS-1$
-        timeoutText = BaseWidgetUtils.createText( groupComposite, "30", 1 ); //$NON-NLS-1$
-        timeoutText.setTextLimit( 7 );
+        timeoutSecondsText = BaseWidgetUtils.createText( groupComposite, "30", 1 ); //$NON-NLS-1$
+        timeoutSecondsText.setTextLimit( 7 );
 
         String[] encMethods = new String[]
             {
@@ -406,9 +406,9 @@ public class NetworkParameterPage extends AbstractConnectionParameterPage
             message = Messages.getString( "NetworkParameterPage.PleaseEnterConnectionName"
); //$NON-NLS-1$
         }
 
-        if ( Strings.isEmpty( timeoutText.getText() ) ) //$NON-NLS-1$
+        if ( Strings.isEmpty( timeoutSecondsText.getText() ) ) //$NON-NLS-1$
         {
-            timeoutText.setText( "30" );
+            timeoutSecondsText.setText( "30" );
         }
 
         if ( ConnectionCorePlugin.getDefault().getConnectionManager().getConnectionByName(
nameText.getText() ) != null
@@ -448,7 +448,7 @@ public class NetworkParameterPage extends AbstractConnectionParameterPage
             || networkProviderCombo.getItemCount() < 2 ? 0
                 : 1 );
         readOnlyConnectionCheckbox.setSelection( parameter.isReadOnly() );
-        timeoutText.setText( Long.toString( parameter.getTimeout() / 1000L ) );
+        timeoutSecondsText.setText( Long.toString( parameter.getTimeoutMillis() / 1000L )
);
 
     }
 
@@ -531,9 +531,9 @@ public class NetworkParameterPage extends AbstractConnectionParameterPage
         } );
 
         // The timeout events
-        timeoutText.addModifyListener( event -> connectionPageModified() );
+        timeoutSecondsText.addModifyListener( event -> connectionPageModified() );
 
-        timeoutText.addVerifyListener( event -> {
+        timeoutSecondsText.addVerifyListener( event -> {
             if ( !event.text.matches( "[0-9]*" ) ) //$NON-NLS-1$
             {
                 event.doit = false;
@@ -554,7 +554,7 @@ public class NetworkParameterPage extends AbstractConnectionParameterPage
         parameter.setEncryptionMethod( getEncyrptionMethod() );
         parameter.setNetworkProvider( getNetworkProvider() );
         parameter.setReadOnly( isReadOnly() );
-        parameter.setTimeout( getTimeout() * 1000L );
+        parameter.setTimeoutMillis( getTimeoutSeconds() * 1000L );
     }
 
 
@@ -602,7 +602,7 @@ public class NetworkParameterPage extends AbstractConnectionParameterPage
             || ( connectionParameter.getEncryptionMethod() != getEncyrptionMethod() )
             || ( connectionParameter.getNetworkProvider() != getNetworkProvider() )
             || ( connectionParameter.isReadOnly() != isReadOnly() )
-            || ( connectionParameter.getTimeout() != getTimeout() );
+            || ( connectionParameter.getTimeoutMillis() != getTimeoutSeconds() * 1000L );
     }
 
 


Mime
View raw message