JAMES-1960 Extract default configuration values in constants

Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/642be79f
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/642be79f
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/642be79f

Branch: refs/heads/master
Commit: 642be79f3f8e702db50c63c58add7128075a0aba
Parents: 3dfb05f
Author: benwa <btell...@linagora.com>
Authored: Mon Mar 13 15:24:00 2017 +0700
Committer: benwa <btell...@linagora.com>
Committed: Wed Mar 15 09:02:31 2017 +0700

----------------------------------------------------------------------
 .../modules/server/WebAdminServerModule.java    | 30 +++++++++++---------
 1 file changed, 17 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/642be79f/server/container/guice/protocols/webadmin/src/main/java/org/apache/james/modules/server/WebAdminServerModule.java
----------------------------------------------------------------------
diff --git 
a/server/container/guice/protocols/webadmin/src/main/java/org/apache/james/modules/server/WebAdminServerModule.java
 
b/server/container/guice/protocols/webadmin/src/main/java/org/apache/james/modules/server/WebAdminServerModule.java
index 1532471..c100dcb 100644
--- 
a/server/container/guice/protocols/webadmin/src/main/java/org/apache/james/modules/server/WebAdminServerModule.java
+++ 
b/server/container/guice/protocols/webadmin/src/main/java/org/apache/james/modules/server/WebAdminServerModule.java
@@ -56,7 +56,15 @@ import com.google.inject.multibindings.Multibinder;
 
 public class WebAdminServerModule extends AbstractModule {
 
-    public static final boolean DEFAULT_JWT_DISABLED = false;
+    private static final boolean DEFAULT_JWT_DISABLED = false;
+    private static final boolean DEFAULT_DISABLED = false;
+    private static final String DEFAULT_NO_CORS_ORIGIN = null;
+    private static final boolean DEFAULT_CORS_DISABLED = false;
+    private static final String DEFAULT_NO_KEYSTORE = null;
+    private static final boolean DEFAULT_HTTPS_DISABLED = false;
+    private static final String DEFAULT_NO_PASSWORD = null;
+    private static final String DEFAULT_NO_TRUST_KEYSTORE = null;
+    private static final String DEFAULT_NO_TRUST_PASSWORD = null;
 
     @Override
     protected void configure() {
@@ -77,11 +85,11 @@ public class WebAdminServerModule extends AbstractModule {
         try {
             PropertiesConfiguration configurationFile = 
propertiesProvider.getConfiguration("webadmin");
             return WebAdminConfiguration.builder()
-                .enable(configurationFile.getBoolean("enabled", false))
+                .enable(configurationFile.getBoolean("enabled", 
DEFAULT_DISABLED))
                 .port(new FixedPort(configurationFile.getInt("port", 
WebAdminServer.DEFAULT_PORT)))
                 .https(readHttpsConfiguration(configurationFile))
-                .enableCORS(configurationFile.getBoolean("cors.enable", false))
-                .urlCORSOrigin(configurationFile.getString("cors.origin", 
null))
+                .enableCORS(configurationFile.getBoolean("cors.enable", 
DEFAULT_CORS_DISABLED))
+                .urlCORSOrigin(configurationFile.getString("cors.origin", 
DEFAULT_NO_CORS_ORIGIN))
                 .build();
         } catch (FileNotFoundException e) {
             return WebAdminConfiguration.builder()
@@ -105,14 +113,14 @@ public class WebAdminServerModule extends AbstractModule {
     }
 
     private HttpsConfiguration readHttpsConfiguration(PropertiesConfiguration 
configurationFile) {
-        boolean enabled = configurationFile.getBoolean("https.enabled", 
DEFAULT_HTTPS_DISABLED());
+        boolean enabled = configurationFile.getBoolean("https.enabled", 
DEFAULT_HTTPS_DISABLED);
         if (enabled) {
             return HttpsConfiguration.builder()
                 .enabled()
-                .raw(configurationFile.getString("https.keystore", null),
-                    configurationFile.getString("https.password", null),
-                    configurationFile.getString("https.trust.keystore", null),
-                    configurationFile.getString("https.trust.password", null))
+                .raw(configurationFile.getString("https.keystore", 
DEFAULT_NO_KEYSTORE),
+                    configurationFile.getString("https.password", 
DEFAULT_NO_PASSWORD),
+                    configurationFile.getString("https.trust.keystore", 
DEFAULT_NO_TRUST_KEYSTORE),
+                    configurationFile.getString("https.trust.password", 
DEFAULT_NO_TRUST_PASSWORD))
                 .build();
         }
         return HttpsConfiguration.builder()
@@ -120,10 +128,6 @@ public class WebAdminServerModule extends AbstractModule {
             .build();
     }
 
-    private boolean DEFAULT_HTTPS_DISABLED() {
-        return false;
-    }
-
     @Singleton
     public static class WebAdminServerModuleConfigurationPerformer implements 
ConfigurationPerformer {
 


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org
For additional commands, e-mail: server-dev-h...@james.apache.org

Reply via email to