From 5cd7bdbbda0fa9f1aa6e12d9171c3811b73feb07 Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Thu, 09 Jul 2015 14:01:31 +0000
Subject: [PATCH] Code cleanup

---
 opendj-server-legacy/src/main/java/org/opends/server/tasks/TaskUtils.java |   33 ++++++++++-----------------------
 1 files changed, 10 insertions(+), 23 deletions(-)

diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tasks/TaskUtils.java b/opendj-server-legacy/src/main/java/org/opends/server/tasks/TaskUtils.java
index 8926338..32717ed 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tasks/TaskUtils.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tasks/TaskUtils.java
@@ -46,18 +46,19 @@
 import org.opends.server.config.StringConfigAttribute;
 import org.opends.server.core.DirectoryServer;
 import org.opends.server.core.ModifyOperation;
-import org.opends.server.protocols.internal.InternalClientConnection;
 import org.opends.server.protocols.ldap.LDAPAttribute;
 import org.opends.server.protocols.ldap.LDAPModification;
 import org.opends.server.types.Attribute;
 import org.opends.server.types.DN;
 import org.opends.server.types.DirectoryException;
 import org.opends.server.types.RawModification;
+import org.opends.server.util.CollectionUtils;
 import org.opends.server.util.ServerConstants;
 
 import static org.opends.messages.ConfigMessages.*;
 import static org.opends.messages.ToolMessages.*;
 import static org.opends.server.config.ConfigConstants.*;
+import static org.opends.server.protocols.internal.InternalClientConnection.*;
 import static org.opends.server.util.StaticUtils.*;
 
 /**
@@ -234,21 +235,14 @@
                                    e.getMessageObject(), e);
     }
 
-    ArrayList<ByteString> valueList = new ArrayList<>(1);
-    valueList.add(ServerConstants.TRUE_VALUE);
-    LDAPAttribute a = new LDAPAttribute(ATTR_BACKEND_ENABLED, valueList);
-
+    LDAPAttribute a = new LDAPAttribute(ATTR_BACKEND_ENABLED, ServerConstants.TRUE_VALUE);
     LDAPModification m = new LDAPModification(ModificationType.REPLACE, a);
 
-    ArrayList<RawModification> modList = new ArrayList<>(1);
-    modList.add(m);
+    ArrayList<RawModification> modList = CollectionUtils.<RawModification> newArrayList(m);
 
-    InternalClientConnection conn =
-         InternalClientConnection.getRootConnection();
     String backendDNString = configEntryDN.toString();
-    ByteString rawEntryDN =
-        ByteString.valueOf(backendDNString);
-    ModifyOperation internalModify = conn.processModify(rawEntryDN, modList);
+    ByteString rawEntryDN = ByteString.valueOf(backendDNString);
+    ModifyOperation internalModify = getRootConnection().processModify(rawEntryDN, modList);
 
     ResultCode resultCode = internalModify.getResultCode();
     if (resultCode != ResultCode.SUCCESS)
@@ -284,21 +278,14 @@
                                    e.getMessageObject(), e);
     }
 
-    ArrayList<ByteString> valueList = new ArrayList<>(1);
-    valueList.add(ServerConstants.FALSE_VALUE);
-    LDAPAttribute a = new LDAPAttribute(ATTR_BACKEND_ENABLED, valueList);
-
+    LDAPAttribute a = new LDAPAttribute(ATTR_BACKEND_ENABLED, ServerConstants.FALSE_VALUE);
     LDAPModification m = new LDAPModification(ModificationType.REPLACE, a);
 
-    ArrayList<RawModification> modList = new ArrayList<>(1);
-    modList.add(m);
+    ArrayList<RawModification> modList = CollectionUtils.<RawModification> newArrayList(m);
 
-    InternalClientConnection conn =
-         InternalClientConnection.getRootConnection();
     String backendDNString = configEntryDN.toString();
-    ByteString rawEntryDN =
-        ByteString.valueOf(backendDNString);
-    ModifyOperation internalModify = conn.processModify(rawEntryDN, modList);
+    ByteString rawEntryDN = ByteString.valueOf(backendDNString);
+    ModifyOperation internalModify = getRootConnection().processModify(rawEntryDN, modList);
 
     ResultCode resultCode = internalModify.getResultCode();
     if (resultCode != ResultCode.SUCCESS)

--
Gitblit v1.10.0