From 6acb5680cc685afc071ca5bcc358d31690bb1786 Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Thu, 13 Feb 2014 10:24:56 +0000
Subject: [PATCH] Code cleanups: - Factorized code - Fixed Sonar violations - Removed duplicated lines reported by Sonar - Applied refactorings suggested by AutoRefactor plugin 

---
 opendj-server/src/main/java/org/forgerock/opendj/server/setup/model/Model.java |   25 +++++++++++++------------
 1 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/opendj-server/src/main/java/org/forgerock/opendj/server/setup/model/Model.java b/opendj-server/src/main/java/org/forgerock/opendj/server/setup/model/Model.java
index e0578e9..b59bbc4 100644
--- a/opendj-server/src/main/java/org/forgerock/opendj/server/setup/model/Model.java
+++ b/opendj-server/src/main/java/org/forgerock/opendj/server/setup/model/Model.java
@@ -91,7 +91,7 @@
      * @return {@code true} if this configuration has a license.
      */
     public boolean hasLicense() {
-        return (this.license != null && !license.isEmpty());
+        return license != null && !license.isEmpty();
     }
 
     /**
@@ -100,7 +100,7 @@
      * @return {@code true} if this configuration is stand alone data store.
      */
     boolean isStandAlone() {
-        return (type == Type.STANDALONE);
+        return type == Type.STANDALONE;
     }
 
     /**
@@ -109,7 +109,7 @@
      * @return {@code true} if this configuration is a first server in a replication topology.
      */
     boolean isFirstInTopology() {
-        return (type == Type.FIRST_IN_TOPOLOGY);
+        return type == Type.FIRST_IN_TOPOLOGY;
     }
 
     /**
@@ -118,7 +118,7 @@
      * @return {@code true} if this configuration is part of a replication topology.
      */
     boolean isPartOfReplicationTopology() {
-        return (type == Type.IN_EXISTING_TOPOLOGY);
+        return type == Type.IN_EXISTING_TOPOLOGY;
     }
 
     /**
@@ -128,7 +128,8 @@
      * @return {@code true} if this configuration has a certificate linked to it.
      */
     boolean isSecure() {
-        return (this.getListenerSettings() != null && this.getListenerSettings().getCertificate() != null);
+        return getListenerSettings() != null
+            && getListenerSettings().getCertificate() != null;
     }
 
     /**
@@ -386,18 +387,18 @@
                 }
             }
         }
-        if (getListenerSettings() == null) {
+        final ListenerSettings settings = getListenerSettings();
+        final DataConfiguration dataConf = getDataConfiguration();
+        if (settings == null) {
             throw new ConfigException(LocalizableMessage.raw("Invalid settings"));
         }
-        if (getDataConfiguration() == null) {
+        if (dataConf == null) {
             throw new ConfigException(LocalizableMessage.raw("Invalid data configuration"));
         }
-        if (getDataConfiguration().isImportLDIF()) {
-            if (getDataConfiguration().getLdifImportDataPath() == null) {
-                throw new ConfigException(LocalizableMessage.raw("Invalid import ldif file."));
-            }
+        if (dataConf.isImportLDIF() && dataConf.getLdifImportDataPath() == null) {
+            throw new ConfigException(LocalizableMessage.raw("Invalid import ldif file."));
         }
-        if (getListenerSettings().getPasswordFile() == null && getListenerSettings().getPassword() == null) {
+        if (settings.getPasswordFile() == null && settings.getPassword() == null) {
             throw new ConfigException(LocalizableMessage.raw("A password must be set for the root DN."));
         }
     }

--
Gitblit v1.10.0