From 2a6a436cf43f43eeb25210a5c72301a932598d1c Mon Sep 17 00:00:00 2001
From: Jean-Noël Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Fri, 05 Aug 2016 10:14:28 +0000
Subject: [PATCH] Partial OPENDJ-3106 Migrate Entry

---
 opendj-server-legacy/src/main/java/org/opends/server/tools/makeldif/Branch.java |   67 ++++++++++++---------------------
 1 files changed, 24 insertions(+), 43 deletions(-)

diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tools/makeldif/Branch.java b/opendj-server-legacy/src/main/java/org/opends/server/tools/makeldif/Branch.java
index fdd739d..c2037ec 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tools/makeldif/Branch.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tools/makeldif/Branch.java
@@ -121,54 +121,35 @@
       }
     }
 
-    for (List<Attribute> attrList : entry.getUserAttributes().values())
-    {
-      for (Attribute a : attrList)
-      {
-        for (ByteString v : a)
-        {
-          try
-          {
-            String[] valueStrings = new String[] { v.toString() };
-            Tag[] tags = new Tag[] { new StaticTextTag() };
-            tags[0].initializeForBranch(templateFile, this, valueStrings, 0, warnings);
-            lineList.add(new TemplateLine(a.getAttributeDescription().getAttributeType(), 0, tags));
-          }
-          catch (Exception e)
-          {
-            // This should never happen.
-            e.printStackTrace();
-          }
-        }
-      }
-    }
-
-    for (List<Attribute> attrList : entry.getOperationalAttributes().values())
-    {
-      for (Attribute a : attrList)
-      {
-        for (ByteString v : a)
-        {
-          try
-          {
-            String[] valueStrings = new String[] { v.toString() };
-            Tag[] tags = new Tag[] { new StaticTextTag() };
-            tags[0].initializeForBranch(templateFile, this, valueStrings, 0, warnings);
-            lineList.add(new TemplateLine(a.getAttributeDescription().getAttributeType(), 0, tags));
-          }
-          catch (Exception e)
-          {
-            // This should never happen.
-            e.printStackTrace();
-          }
-        }
-      }
-    }
+    addLines(lineList, entry.getAllAttributes(), templateFile, warnings);
 
     rdnLines = new TemplateLine[lineList.size()];
     lineList.toArray(rdnLines);
   }
 
+  private void addLines(List<TemplateLine> lineList, Iterable<Attribute> attrs, TemplateFile templateFile,
+      List<LocalizableMessage> warnings)
+  {
+    for (Attribute a : attrs)
+    {
+      for (ByteString v : a)
+      {
+        try
+        {
+          String[] valueStrings = new String[] { v.toString() };
+          Tag[] tags = new Tag[] { new StaticTextTag() };
+          tags[0].initializeForBranch(templateFile, this, valueStrings, 0, warnings);
+          lineList.add(new TemplateLine(a.getAttributeDescription().getAttributeType(), 0, tags));
+        }
+        catch (Exception e)
+        {
+          // This should never happen.
+          e.printStackTrace();
+        }
+      }
+    }
+  }
+
 
 
   /**

--
Gitblit v1.10.0