From ed8da8f6a5f83b4322bc4fb86fcb9adbb02c8d88 Mon Sep 17 00:00:00 2001
From: Jean-Noël Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Mon, 04 Apr 2016 13:38:35 +0000
Subject: [PATCH] code cleanup in backends

---
 opendj-server-legacy/src/main/java/org/opends/server/backends/RootDSEBackend.java |    4 +-
 opendj-server-legacy/src/main/java/org/opends/server/backends/SchemaBackend.java  |   15 +++----
 opendj-server-legacy/src/main/java/org/opends/server/backends/MonitorBackend.java |   64 +++++++++++--------------------
 3 files changed, 32 insertions(+), 51 deletions(-)

diff --git a/opendj-server-legacy/src/main/java/org/opends/server/backends/MonitorBackend.java b/opendj-server-legacy/src/main/java/org/opends/server/backends/MonitorBackend.java
index a1f3ba7..630f43c 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/backends/MonitorBackend.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/backends/MonitorBackend.java
@@ -132,30 +132,9 @@
     final ArrayList<Attribute> userAttrs = new ArrayList<>();
     try
     {
-      final Entry configEntry = DirectoryServer
-          .getConfigEntry(configEntryDN);
-      for (final List<Attribute> attrs : configEntry
-          .getUserAttributes().values())
-      {
-        for (final Attribute a : attrs)
-        {
-          if (!isMonitorConfigAttribute(a))
-          {
-            userAttrs.add(a);
-          }
-        }
-      }
-      for (final List<Attribute> attrs : configEntry
-          .getOperationalAttributes().values())
-      {
-        for (final Attribute a : attrs)
-        {
-          if (!isMonitorConfigAttribute(a))
-          {
-            userAttrs.add(a);
-          }
-        }
-      }
+      final Entry configEntry = DirectoryServer.getConfigEntry(configEntryDN);
+      addAllNonMonitorConfigAttributes(userAttrs, configEntry.getUserAttributes().values());
+      addAllNonMonitorConfigAttributes(userAttrs, configEntry.getOperationalAttributes().values());
     }
     catch (final Exception e)
     {
@@ -174,7 +153,20 @@
     return ccr;
   }
 
-  /** {@inheritDoc} */
+  private void addAllNonMonitorConfigAttributes(final List<Attribute> userAttrs, Collection<List<Attribute>> attrbutes)
+  {
+    for (final List<Attribute> attrs : attrbutes)
+    {
+      for (final Attribute a : attrs)
+      {
+        if (!isMonitorConfigAttribute(a))
+        {
+          userAttrs.add(a);
+        }
+      }
+    }
+  }
+
   @Override
   public void configureBackend(final MonitorBackendCfg config, ServerContext serverContext)
       throws ConfigException
@@ -232,16 +224,7 @@
 
   private void addAll(ArrayList<Attribute> attributes, Collection<List<Attribute>> attributesToAdd)
   {
-    for (final List<Attribute> attrs : attributesToAdd)
-    {
-      for (final Attribute a : attrs)
-      {
-        if (!isMonitorConfigAttribute(a))
-        {
-          attributes.add(a);
-        }
-      }
-    }
+    addAllNonMonitorConfigAttributes(attributes, attributesToAdd);
   }
 
   /** {@inheritDoc} */
@@ -840,11 +823,10 @@
   {
     final AttributeType attrType = attribute.getAttributeDescription().getAttributeType();
     return attrType.hasName(ATTR_COMMON_NAME)
-        || attrType.hasName(ATTR_BACKEND_ENABLED.toLowerCase())
-        || attrType.hasName(ATTR_BACKEND_CLASS.toLowerCase())
-        || attrType.hasName(ATTR_BACKEND_BASE_DN.toLowerCase())
-        || attrType.hasName(ATTR_BACKEND_ID.toLowerCase())
-        || attrType.hasName(ATTR_BACKEND_WRITABILITY_MODE.toLowerCase());
+        || attrType.hasName(ATTR_BACKEND_ENABLED)
+        || attrType.hasName(ATTR_BACKEND_CLASS)
+        || attrType.hasName(ATTR_BACKEND_BASE_DN)
+        || attrType.hasName(ATTR_BACKEND_ID)
+        || attrType.hasName(ATTR_BACKEND_WRITABILITY_MODE);
   }
-
 }
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 a054445..9ff98d5 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
@@ -284,8 +284,8 @@
   private boolean isDSEConfigAttribute(Attribute attribute)
   {
     AttributeType attrType = attribute.getAttributeDescription().getAttributeType();
-    return attrType.hasName(ATTR_ROOT_DSE_SUBORDINATE_BASE_DN.toLowerCase())
-        || attrType.hasName(ATTR_ROOTDSE_SHOW_ALL_ATTRIBUTES.toLowerCase())
+    return attrType.hasName(ATTR_ROOT_DSE_SUBORDINATE_BASE_DN)
+        || attrType.hasName(ATTR_ROOTDSE_SHOW_ALL_ATTRIBUTES)
         || attrType.hasName(ATTR_COMMON_NAME);
   }
 
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/backends/SchemaBackend.java b/opendj-server-legacy/src/main/java/org/opends/server/backends/SchemaBackend.java
index a691277..6357e4b 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/backends/SchemaBackend.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/backends/SchemaBackend.java
@@ -456,19 +456,18 @@
   private boolean isSchemaConfigAttribute(Attribute attribute)
   {
     AttributeType attrType = attribute.getAttributeDescription().getAttributeType();
-    return attrType.hasName(ATTR_SCHEMA_ENTRY_DN.toLowerCase()) ||
-        attrType.hasName(ATTR_BACKEND_ENABLED.toLowerCase()) ||
-        attrType.hasName(ATTR_BACKEND_CLASS.toLowerCase()) ||
-        attrType.hasName(ATTR_BACKEND_ID.toLowerCase()) ||
-        attrType.hasName(ATTR_BACKEND_BASE_DN.toLowerCase()) ||
-        attrType.hasName(ATTR_BACKEND_WRITABILITY_MODE.toLowerCase()) ||
-        attrType.hasName(ATTR_SCHEMA_SHOW_ALL_ATTRIBUTES.toLowerCase()) ||
+    return attrType.hasName(ATTR_SCHEMA_ENTRY_DN) ||
+        attrType.hasName(ATTR_BACKEND_ENABLED) ||
+        attrType.hasName(ATTR_BACKEND_CLASS) ||
+        attrType.hasName(ATTR_BACKEND_ID) ||
+        attrType.hasName(ATTR_BACKEND_BASE_DN) ||
+        attrType.hasName(ATTR_BACKEND_WRITABILITY_MODE) ||
+        attrType.hasName(ATTR_SCHEMA_SHOW_ALL_ATTRIBUTES) ||
         attrType.hasName(ATTR_COMMON_NAME) ||
         attrType.hasName(OP_ATTR_CREATORS_NAME_LC) ||
         attrType.hasName(OP_ATTR_CREATE_TIMESTAMP_LC) ||
         attrType.hasName(OP_ATTR_MODIFIERS_NAME_LC) ||
         attrType.hasName(OP_ATTR_MODIFY_TIMESTAMP_LC);
-
   }
 
   @Override

--
Gitblit v1.10.0