From 17ec2cfa9d04e6942a694ab5c3778ac26f17bb35 Mon Sep 17 00:00:00 2001
From: Jean-Noël Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Tue, 19 Apr 2016 12:59:39 +0000
Subject: [PATCH] code cleanup

---
 opendj-server-legacy/src/main/java/org/opends/server/backends/RootDSEBackend.java |   40 ++++------------------------------------
 1 files changed, 4 insertions(+), 36 deletions(-)

diff --git a/opendj-server-legacy/src/main/java/org/opends/server/backends/RootDSEBackend.java b/opendj-server-legacy/src/main/java/org/opends/server/backends/RootDSEBackend.java
index f8feced..d5475a8 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/backends/RootDSEBackend.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/backends/RootDSEBackend.java
@@ -127,8 +127,6 @@
    */
   private ConcurrentHashMap<DN, Backend<?>> subordinateBaseDNs;
 
-
-
   /**
    * Creates a new backend with the provided information.  All backend
    * implementations must implement a default constructor that use
@@ -165,13 +163,11 @@
     userDefinedAttributes = new ArrayList<>();
     addAllUserDefinedAttrs(userDefinedAttributes, configEntry);
 
-
     // Create the set of base DNs that we will handle.  In this case, it's just
     // the root DSE.
     rootDSEDN    = DN.rootDN();
     baseDNs = Collections.singleton(rootDSEDN);
 
-
     // Create the set of subordinate base DNs.  If this is specified in the
     // configuration, then use that set.  Otherwise, use the set of non-private
     // backends defined in the server.
@@ -189,13 +185,13 @@
         for (DN baseDN : subDNs)
         {
           Backend<?> backend = DirectoryServer.getBackend(baseDN);
-          if (backend == null)
+          if (backend != null)
           {
-            logger.warn(WARN_ROOTDSE_NO_BACKEND_FOR_SUBORDINATE_BASE, baseDN);
+            subordinateBaseDNs.put(baseDN, backend);
           }
           else
           {
-            subordinateBaseDNs.put(baseDN, backend);
+            logger.warn(WARN_ROOTDSE_NO_BACKEND_FOR_SUBORDINATE_BASE, baseDN);
           }
         }
       }
@@ -209,12 +205,10 @@
       throw new InitializationException(message, e);
     }
 
-
     // Determine whether all root DSE attributes should be treated as user
     // attributes.
     showAllAttributes = currentConfig.isShowAllAttributes();
 
-
     // Construct the set of "static" attributes that will always be present in
     // the root DSE.
     staticDSEAttributes = new ArrayList<>();
@@ -240,12 +234,10 @@
     }
     dseObjectClasses.put(rootDSEOC, OC_ROOT_DSE);
 
-
     // Set the backend ID for this backend. The identifier needs to be
     // specific enough to avoid conflict with user backend identifiers.
     setBackendID("__root.dse__");
 
-
     // Register as a change listener.
     currentConfig.addChangeListener(this);
   }
@@ -284,8 +276,6 @@
     currentConfig.removeChangeListener(this);
   }
 
-
-
   /**
    * Indicates whether the provided attribute is one that is used in the
    * configuration of this backend.
@@ -392,12 +382,10 @@
       return getRootDSE();
     }
 
-
     // This method should never be used to get anything other than the root DSE.
     // If we got here, then that appears to be the case, so log a message.
     logger.warn(WARN_ROOTDSE_GET_ENTRY_NONROOT, entryDN);
 
-
     // Go ahead and check the subordinate backends to see if we can find the
     // entry there.  Note that in order to avoid potential loop conditions, this
     // will only work if the set of subordinate bases has been explicitly
@@ -413,13 +401,10 @@
       }
     }
 
-
     // If we've gotten here, then we couldn't find the entry so return null.
     return null;
   }
 
-
-
   /**
    * Retrieves the root DSE entry for the Directory Server.
    *
@@ -430,8 +415,6 @@
     return getRootDSE(null);
   }
 
-
-
   /**
    * Retrieves the root DSE entry for the Directory Server.
    *
@@ -489,7 +472,6 @@
         ATTR_SUPPORTED_AUTH_PW_SCHEMES, DirectoryServer.getAuthPasswordStorageSchemes().keySet());
     addAttribute(supportedAuthPWSchemesAttr, dseUserAttrs, dseOperationalAttrs);
 
-
     // Obtain TLS protocol and cipher support.
     Collection<String> supportedTlsProtocols;
     Collection<String> supportedTlsCiphers;
@@ -604,7 +586,6 @@
       return true;
     }
 
-
     // If it was not the null DN, then iterate through the associated
     // subordinate backends to make the determination.
     for (Map.Entry<DN, Backend<?>> entry : getSubordinateBaseDNs().entrySet())
@@ -664,7 +645,6 @@
       throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message);
     }
 
-
     SearchFilter filter = searchOperation.getFilter();
     switch (searchOperation.getScope().asEnum())
     {
@@ -676,7 +656,6 @@
         }
         break;
 
-
       case SINGLE_LEVEL:
         for (Map.Entry<DN, Backend<?>> entry : getSubordinateBaseDNs().entrySet())
         {
@@ -692,7 +671,6 @@
         }
         break;
 
-
       case WHOLE_SUBTREE:
       case SUBORDINATES:
         try
@@ -785,7 +763,7 @@
   public boolean supports(BackendOperation backendOperation)
   {
     // We will only export the DSE entry itself.
-    return backendOperation.equals(BackendOperation.LDIF_EXPORT);
+    return BackendOperation.LDIF_EXPORT.equals(backendOperation);
   }
 
   @Override
@@ -808,7 +786,6 @@
                                    message);
     }
 
-
     // Write the root DSE entry itself to it.  Make sure to close the LDIF
     // writer when we're done.
     try
@@ -872,7 +849,6 @@
   {
     boolean configIsAcceptable = true;
 
-
     try
     {
       Set<DN> subDNs = cfg.getSubordinateBaseDN();
@@ -902,7 +878,6 @@
       configIsAcceptable = false;
     }
 
-
     return configIsAcceptable;
   }
 
@@ -911,7 +886,6 @@
   {
     final ConfigChangeResult ccr = new ConfigChangeResult();
 
-
     // Check to see if we should apply a new set of base DNs.
     ConcurrentHashMap<DN, Backend<?>> subBases;
     try
@@ -952,10 +926,8 @@
       subBases = null;
     }
 
-
     boolean newShowAll = cfg.isShowAllAttributes();
 
-
     // Check to see if there is a new set of user-defined attributes.
     ArrayList<Attribute> userAttrs = new ArrayList<>();
     try
@@ -972,7 +944,6 @@
       ccr.setResultCode(DirectoryServer.getServerErrorResultCode());
     }
 
-
     if (ccr.getResultCode() == ResultCode.SUCCESS)
     {
       subordinateBaseDNs = subBases;
@@ -987,7 +958,6 @@
         ccr.addMessage(INFO_ROOTDSE_USING_NEW_SUBORDINATE_BASE_DNS.get(basesStr));
       }
 
-
       if (showAllAttributes != newShowAll)
       {
         showAllAttributes = newShowAll;
@@ -995,12 +965,10 @@
                 ATTR_ROOTDSE_SHOW_ALL_ATTRIBUTES, showAllAttributes));
       }
 
-
       userDefinedAttributes = userAttrs;
       ccr.addMessage(INFO_ROOTDSE_USING_NEW_USER_ATTRS.get());
     }
 
-
     return ccr;
   }
 }

--
Gitblit v1.10.0