From 1ef65104c4113a1c6fad7ee93bc9862218a4bc68 Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Mon, 16 Feb 2015 14:10:23 +0000
Subject: [PATCH] AutoRefactor: common code in if else statements
---
opendj-server-legacy/src/main/java/org/opends/server/backends/RootDSEBackend.java | 77 +++++++++++---------------------------
1 files changed, 22 insertions(+), 55 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 3b48f2b..99e3b19 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
@@ -576,61 +576,8 @@
supportedTlsCiphers);
addAttribute(supportedTLSCiphersAttr, dseUserAttrs, dseOperationalAttrs);
- // Add all the standard "static" attributes.
- for (Attribute a : staticDSEAttributes)
- {
- AttributeType type = a.getAttributeType();
-
- if (type.isOperational() && !showAllAttributes)
- {
- List<Attribute> attrs = dseOperationalAttrs.get(type);
- if (attrs == null)
- {
- attrs = new ArrayList<Attribute>();
- dseOperationalAttrs.put(type, attrs);
- }
- attrs.add(a);
- }
- else
- {
- List<Attribute> attrs = dseUserAttrs.get(type);
- if (attrs == null)
- {
- attrs = new ArrayList<Attribute>();
- dseUserAttrs.put(type, attrs);
- }
- attrs.add(a);
- }
- }
-
-
- // Add all the user-defined attributes.
- for (Attribute a : userDefinedAttributes)
- {
- AttributeType type = a.getAttributeType();
-
- if (type.isOperational() && !showAllAttributes)
- {
- List<Attribute> attrs = dseOperationalAttrs.get(type);
- if (attrs == null)
- {
- attrs = new ArrayList<Attribute>();
- dseOperationalAttrs.put(type, attrs);
- }
- attrs.add(a);
- }
- else
- {
- List<Attribute> attrs = dseUserAttrs.get(type);
- if (attrs == null)
- {
- attrs = new ArrayList<Attribute>();
- dseUserAttrs.put(type, attrs);
- }
- attrs.add(a);
- }
- }
-
+ addAll(staticDSEAttributes, dseUserAttrs, dseOperationalAttrs);
+ addAll(userDefinedAttributes, dseUserAttrs, dseOperationalAttrs);
// Construct and return the entry.
Entry e = new Entry(rootDSEDN, dseObjectClasses, dseUserAttrs,
@@ -639,6 +586,26 @@
return e;
}
+ private void addAll(ArrayList<Attribute> attributes,
+ Map<AttributeType, List<Attribute>> userAttrs, Map<AttributeType, List<Attribute>> operationalAttrs)
+ {
+ for (Attribute a : attributes)
+ {
+ AttributeType type = a.getAttributeType();
+
+ final Map<AttributeType, List<Attribute>> attrsMap = type.isOperational() && !showAllAttributes
+ ? operationalAttrs
+ : userAttrs;
+ List<Attribute> attrs = attrsMap.get(type);
+ if (attrs == null)
+ {
+ attrs = new ArrayList<Attribute>();
+ attrsMap.put(type, attrs);
+ }
+ attrs.add(a);
+ }
+ }
+
private void addAttribute(Attribute publicNamingContextAttr,
--
Gitblit v1.10.0