From 9d0cd2315ad10d4afce13c8865bd2e16a68b2b71 Mon Sep 17 00:00:00 2001
From: Jean-Noël Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Thu, 04 Aug 2016 15:06:12 +0000
Subject: [PATCH] remove CustomSearchResult, replaced by SDK's Entry

---
 opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/LDAPEntryReader.java        |   13 +-
 opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/BrowseEntriesPanel.java       |    4 
 opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/DuplicateEntryPanel.java      |   12 -
 opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/ManageTasksPanel.java         |   21 +--
 opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/LDIFViewEntryPanel.java       |   27 +---
 opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/TableViewEntryPanel.java      |   21 +-
 opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/ViewEntryPanel.java           |   18 +-
 opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/DeleteEntryTask.java        |    5 
 opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/Utilities.java              |    6 
 opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/browser/BrowserController.java   |   26 ----
 opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/ModifyEntryTask.java        |   15 +-
 /dev/null                                                                                            |  120 --------------------
 opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/LDAPEntryPanel.java           |   13 -
 opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/event/EntryReadEvent.java        |   11 -
 opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/SimplifiedViewEntryPanel.java |   36 ++---
 15 files changed, 86 insertions(+), 262 deletions(-)

diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/browser/BrowserController.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/browser/BrowserController.java
index 9d9f7a7..81cc654 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/browser/BrowserController.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/browser/BrowserController.java
@@ -52,7 +52,6 @@
 import org.forgerock.opendj.ldap.responses.SearchResultEntry;
 import org.opends.admin.ads.ADSContext;
 import org.opends.admin.ads.util.ConnectionWrapper;
-import org.opends.guitools.controlpanel.datamodel.CustomSearchResult;
 import org.opends.guitools.controlpanel.datamodel.ServerDescriptor;
 import org.opends.guitools.controlpanel.event.BrowserEvent;
 import org.opends.guitools.controlpanel.event.BrowserEventListener;
@@ -1780,18 +1779,6 @@
     return getNumSubOrdinates(entry) > 0;
   }
 
-  /**
-   * Get the value of the numSubordinates attribute.
-   * If numSubordinates is not present, returns 0.
-   * @param entry the entry to analyze.
-   * @return the value of the numSubordinates attribute.  0 if the attribute
-   * could not be found.
-   */
-  private static int getNumSubOrdinates(CustomSearchResult entry)
-  {
-    return getNumSubOrdinates(entry.getSdkEntry());
-  }
-
   private static int toInt(String v)
   {
     if (v == null)
@@ -1809,19 +1796,6 @@
   }
 
   /**
-   * Returns whether the entry has subordinates or not.  It uses an algorithm
-   * based in hasSubordinates and numSubordinates attributes.
-   * @param entry the entry to analyze.
-   * @return {@code true} if the entry has subordinates according to the values
-   * of hasSubordinates and numSubordinates, returns {@code false} if none of
-   * the attributes could be found.
-   */
-  public static boolean getHasSubOrdinates(CustomSearchResult entry)
-  {
-    return getHasSubOrdinates(entry.getSdkEntry());
-  }
-
-  /**
    * Returns the value of the 'ref' attribute.
    * {@code null} if the attribute is not present.
    * @param entry the entry to analyze.
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/datamodel/CustomSearchResult.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/datamodel/CustomSearchResult.java
deleted file mode 100644
index 16df5a0..0000000
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/datamodel/CustomSearchResult.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * The contents of this file are subject to the terms of the Common Development and
- * Distribution License (the License). You may not use this file except in compliance with the
- * License.
- *
- * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
- * specific language governing permission and limitations under the License.
- *
- * When distributing Covered Software, include this CDDL Header Notice in each file and include
- * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
- * Header, with the fields enclosed by brackets [] replaced by your own identifying
- * information: "Portions Copyright [year] [name of copyright owner]".
- *
- * Copyright 2008-2010 Sun Microsystems, Inc.
- * Portions Copyright 2011-2016 ForgeRock AS.
- */
-package org.opends.guitools.controlpanel.datamodel;
-
-import javax.naming.NamingException;
-
-import org.forgerock.opendj.ldap.Attribute;
-import org.forgerock.opendj.ldap.AttributeDescription;
-import org.forgerock.opendj.ldap.DN;
-import org.forgerock.opendj.ldap.Entry;
-import org.forgerock.opendj.ldap.LinkedHashMapEntry;
-import org.forgerock.opendj.ldap.responses.SearchResultEntry;
-
-/**
- * This is a commodity class used to wrap the SearchResult class of JNDI.
- * Basically it retrieves all the attributes and values on the SearchResult and
- * calculates its DN.  Using it we avoid having to handle the NamingException
- * exceptions that most of the methods in SearchResult throw.
- */
-public class CustomSearchResult implements Comparable<CustomSearchResult>
-{
-  private final Entry entry;
-
-  /**
-   * Constructor of an empty search result.  This constructor is used by the
-   * LDAP entry editor which 'build' their own CustomSearchResult.  The entry
-   * editors use some methods that require CustomSearchResult.
-   * @param name the dn of the entry.
-   */
-  public CustomSearchResult(DN name)
-  {
-    this.entry = new LinkedHashMapEntry(name);
-  }
-
-  /**
-   * Constructor of a search result using a SearchResult as basis.
-   * @param sr the SearchResult.
-   * @throws NamingException if there is an error retrieving the attribute values.
-   */
-  public CustomSearchResult(SearchResultEntry sr) throws NamingException
-  {
-    this.entry = sr;
-  }
-
-  /**
-   * Returns the DN of the entry.
-   * @return the DN of the entry.
-   */
-  public DN getName()
-  {
-    return entry.getName();
-  }
-
-  public Attribute getAttribute(AttributeDescription attributeDescription)
-  {
-    return entry.getAttribute(attributeDescription);
-  }
-
-  public Attribute getAttribute(String attributeDescription)
-  {
-    return entry.getAttribute(attributeDescription);
-  }
-
-  public Iterable<Attribute> getAllAttributes()
-  {
-    return entry.getAllAttributes();
-  }
-
-  public Entry getSdkEntry()
-  {
-    return entry;
-  }
-
-  @Override
-  public int compareTo(CustomSearchResult o) {
-    if (this.equals(o))
-    {
-      return 0;
-    }
-    return toString().compareTo(o.toString());
-  }
-
-  @Override
-  public boolean equals(Object o)
-  {
-    if (o == this)
-    {
-      return true;
-    }
-    if (o instanceof CustomSearchResult)
-    {
-      return entry.equals(((CustomSearchResult)o).entry);
-    }
-    return false;
-  }
-
-  @Override
-  public String toString() {
-    return entry.toString();
-  }
-
-  @Override
-  public int hashCode() {
-    return entry.hashCode();
-  }
-}
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/event/EntryReadEvent.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/event/EntryReadEvent.java
index e710e5e..d16a343 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/event/EntryReadEvent.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/event/EntryReadEvent.java
@@ -12,28 +12,27 @@
  * information: "Portions Copyright [year] [name of copyright owner]".
  *
  * Copyright 2008 Sun Microsystems, Inc.
+ * Portions Copyright 2016 ForgeRock AS.
  */
-
 package org.opends.guitools.controlpanel.event;
 
-import org.opends.guitools.controlpanel.datamodel.CustomSearchResult;
+import org.forgerock.opendj.ldap.Entry;
 
 /**
  * The class used to notify that a new entry has been successfully read.  Used
  * in the LDAP entry browser.
- *
  */
 public class EntryReadEvent
 {
   private Object source;
-  private CustomSearchResult sr;
+  private Entry sr;
 
   /**
    * The event constructor.
    * @param source the source of the event.
    * @param sr the search result containing the entry that was read.
    */
-  public EntryReadEvent(Object source, CustomSearchResult sr)
+  public EntryReadEvent(Object source, Entry sr)
   {
     this.source = source;
     this.sr = sr;
@@ -52,7 +51,7 @@
    * Returns the search result containing the entry that was read.
    * @return the search result containing the entry that was read.
    */
-  public CustomSearchResult getSearchResult()
+  public Entry getSearchResult()
   {
     return sr;
   }
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/DeleteEntryTask.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/DeleteEntryTask.java
index 3646b7f..04584e2 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/DeleteEntryTask.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/DeleteEntryTask.java
@@ -14,7 +14,6 @@
  * Copyright 2008-2010 Sun Microsystems, Inc.
  * Portions Copyright 2013-2016 ForgeRock AS.
  */
-
 package org.opends.guitools.controlpanel.task;
 
 import static org.forgerock.opendj.ldap.SearchScope.*;
@@ -51,7 +50,6 @@
 import org.opends.guitools.controlpanel.datamodel.BackendDescriptor;
 import org.opends.guitools.controlpanel.datamodel.BaseDNDescriptor;
 import org.opends.guitools.controlpanel.datamodel.ControlPanelInfo;
-import org.opends.guitools.controlpanel.datamodel.CustomSearchResult;
 import org.opends.guitools.controlpanel.ui.ColorAndFontConstants;
 import org.opends.guitools.controlpanel.ui.ProgressDialog;
 import org.opends.guitools.controlpanel.ui.nodes.BasicNode;
@@ -322,8 +320,7 @@
         SearchResultEntry sr = entryDNs.readEntry();
         if (!sr.getName().equals(""))
         {
-          CustomSearchResult res = new CustomSearchResult(sr);
-          deleteSubtreeRecursively(conn, res.getName(), null, toNotify);
+          deleteSubtreeRecursively(conn, sr.getName(), null, toNotify);
         }
       }
     }
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/ModifyEntryTask.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/ModifyEntryTask.java
index 4b5a030..7b87777 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/ModifyEntryTask.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/ModifyEntryTask.java
@@ -47,7 +47,6 @@
 import org.opends.guitools.controlpanel.datamodel.BaseDNDescriptor;
 import org.opends.guitools.controlpanel.datamodel.CannotRenameException;
 import org.opends.guitools.controlpanel.datamodel.ControlPanelInfo;
-import org.opends.guitools.controlpanel.datamodel.CustomSearchResult;
 import org.opends.guitools.controlpanel.ui.ColorAndFontConstants;
 import org.opends.guitools.controlpanel.ui.ProgressDialog;
 import org.opends.guitools.controlpanel.ui.StatusGenericPanel;
@@ -64,7 +63,7 @@
   private Set<String> backendSet;
   private boolean mustRename;
   private boolean hasModifications;
-  private CustomSearchResult oldEntry;
+  private org.forgerock.opendj.ldap.Entry oldEntry;
   private DN oldDn;
   private ArrayList<ModificationItem> modifications;
   private ModificationItem passwordModification;
@@ -84,7 +83,7 @@
    * want to modify.
    */
   public ModifyEntryTask(ControlPanelInfo info, ProgressDialog dlg,
-      Entry newEntry, CustomSearchResult oldEntry,
+      Entry newEntry, org.forgerock.opendj.ldap.Entry oldEntry,
       BrowserController controller, TreePath path)
   {
     super(info, dlg);
@@ -323,9 +322,9 @@
    * @throws NamingException if an error performing the modification occurs.
    */
   private void modifyAndRename(ConnectionWrapper conn, final DN oldDN,
-  CustomSearchResult originalEntry, final Entry newEntry,
-  final ArrayList<ModificationItem> originalMods)
-  throws CannotRenameException, NamingException
+      org.forgerock.opendj.ldap.Entry originalEntry,
+      final Entry newEntry, final ArrayList<ModificationItem> originalMods)
+      throws CannotRenameException, NamingException
   {
     RDN oldRDN = oldDN.rdn();
     RDN newRDN = newEntry.getName().rdn();
@@ -450,7 +449,7 @@
     return false;
   }
 
-  private boolean entryContainsRdnTypes(CustomSearchResult entry, RDN rdn)
+  private boolean entryContainsRdnTypes(org.forgerock.opendj.ldap.Entry entry, RDN rdn)
   {
     for (AVA ava : rdn)
     {
@@ -471,7 +470,7 @@
    * @return the modifications to apply between two entries.
    */
   public static ArrayList<ModificationItem> getModifications(Entry newEntry,
-      CustomSearchResult oldEntry, ControlPanelInfo info) {
+      org.forgerock.opendj.ldap.Entry oldEntry, ControlPanelInfo info) {
     ArrayList<ModificationItem> modifications = new ArrayList<>();
     Schema schema = info.getServerDescriptor().getSchema();
 
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/BrowseEntriesPanel.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/BrowseEntriesPanel.java
index 91e59a2..bfded4b 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/BrowseEntriesPanel.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/BrowseEntriesPanel.java
@@ -63,12 +63,12 @@
 
 import org.forgerock.i18n.LocalizableMessage;
 import org.forgerock.opendj.ldap.DN;
+import org.forgerock.opendj.ldap.Entry;
 import org.forgerock.opendj.ldap.schema.AttributeType;
 import org.forgerock.opendj.ldap.schema.ObjectClass;
 import org.opends.admin.ads.util.ConnectionWrapper;
 import org.opends.guitools.controlpanel.browser.NodeRefresher;
 import org.opends.guitools.controlpanel.datamodel.ControlPanelInfo;
-import org.opends.guitools.controlpanel.datamodel.CustomSearchResult;
 import org.opends.guitools.controlpanel.datamodel.ServerDescriptor;
 import org.opends.guitools.controlpanel.event.ConfigurationChangeEvent;
 import org.opends.guitools.controlpanel.event.EntryReadErrorEvent;
@@ -580,7 +580,7 @@
       entryReaderThread = new Thread(new Runnable()
       {
         LDAPEntryReader reader;
-        CustomSearchResult sr;
+        Entry sr;
         Throwable t;
         @Override
         public void run()
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/DuplicateEntryPanel.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/DuplicateEntryPanel.java
index cc575a0..917ece8 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/DuplicateEntryPanel.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/DuplicateEntryPanel.java
@@ -43,9 +43,9 @@
 import org.forgerock.opendj.ldap.AttributeDescription;
 import org.forgerock.opendj.ldap.ByteString;
 import org.forgerock.opendj.ldap.DN;
+import org.forgerock.opendj.ldap.Entry;
 import org.opends.admin.ads.util.ConnectionWrapper;
 import org.opends.guitools.controlpanel.browser.BrowserController;
-import org.opends.guitools.controlpanel.datamodel.CustomSearchResult;
 import org.opends.guitools.controlpanel.ui.nodes.BasicNode;
 import org.opends.guitools.controlpanel.util.BackgroundTask;
 import org.opends.guitools.controlpanel.util.LDAPEntryReader;
@@ -71,7 +71,7 @@
   private GenericDialog browseDlg;
   private LDAPEntrySelectionPanel browsePanel;
 
-  private CustomSearchResult entryToDuplicate;
+  private Entry entryToDuplicate;
   private String rdnAttribute;
 
   /** Default constructor. */
@@ -444,11 +444,10 @@
   private void readEntry(final BasicNode node)
   {
     final long t1 = System.currentTimeMillis();
-    BackgroundTask<CustomSearchResult> task =
-      new BackgroundTask<CustomSearchResult>()
+    BackgroundTask<Entry> task = new BackgroundTask<Entry>()
     {
       @Override
-      public CustomSearchResult processBackgroundTask() throws Throwable
+      public Entry processBackgroundTask() throws Throwable
       {
         ConnectionWrapper conn = controller.findConnectionForDisplayedEntry(node);
         LDAPEntryReader reader = new LDAPEntryReader(node.getDN(), conn);
@@ -457,8 +456,7 @@
       }
 
       @Override
-      public void backgroundTaskCompleted(CustomSearchResult sr,
-          Throwable throwable)
+      public void backgroundTaskCompleted(Entry sr, Throwable throwable)
       {
         if (throwable != null)
         {
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/LDAPEntryPanel.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/LDAPEntryPanel.java
index c487457..61609f2 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/LDAPEntryPanel.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/LDAPEntryPanel.java
@@ -37,10 +37,10 @@
 
 import org.forgerock.i18n.LocalizableMessage;
 import org.forgerock.opendj.ldap.DN;
+import org.forgerock.opendj.ldap.Entry;
 import org.opends.guitools.controlpanel.browser.BasicNodeError;
 import org.opends.guitools.controlpanel.browser.BrowserController;
 import org.opends.guitools.controlpanel.datamodel.ControlPanelInfo;
-import org.opends.guitools.controlpanel.datamodel.CustomSearchResult;
 import org.opends.guitools.controlpanel.datamodel.ServerDescriptor;
 import org.opends.guitools.controlpanel.event.ConfigurationChangeEvent;
 import org.opends.guitools.controlpanel.event.EntryReadErrorEvent;
@@ -53,7 +53,6 @@
 import org.opends.guitools.controlpanel.task.Task;
 import org.opends.guitools.controlpanel.util.Utilities;
 import org.opends.server.config.ConfigConstants;
-import org.opends.server.types.Entry;
 import org.opends.server.types.OpenDsException;
 import org.opends.server.util.ServerConstants;
 
@@ -74,7 +73,7 @@
 
   private ViewEntryPanel displayedEntryPanel;
 
-  private CustomSearchResult searchResult;
+  private Entry searchResult;
   private BrowserController controller;
   private TreePath treePath;
 
@@ -247,8 +246,7 @@
    * @param searchResult the search result corresponding to the selected node.
    * @param treePath the tree path of the selected node.
    */
-  private void updateEntryView(CustomSearchResult searchResult,
-      TreePath treePath)
+  private void updateEntryView(Entry searchResult, TreePath treePath)
   {
     boolean isReadOnly = isReadOnly(searchResult.getName());
     boolean canDelete = canDelete(searchResult.getName());
@@ -499,9 +497,8 @@
           Utilities.getFrame(this),
           INFO_CTRL_PANEL_MODIFYING_ENTRY_CHANGES_TITLE.get(), getInfo());
       dlg.setModal(modal);
-      Entry entry = displayedEntryPanel.getEntry();
-      newTask = new ModifyEntryTask(getInfo(), dlg, entry,
-            searchResult, controller, treePath);
+      org.opends.server.types.Entry entry = displayedEntryPanel.getEntry();
+      newTask = new ModifyEntryTask(getInfo(), dlg, entry, searchResult, controller, treePath);
       for (Task task : getInfo().getTasks())
       {
         task.canLaunch(newTask, errors);
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/LDIFViewEntryPanel.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/LDIFViewEntryPanel.java
index 8c2529f..a6919e0 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/LDIFViewEntryPanel.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/LDIFViewEntryPanel.java
@@ -36,10 +36,9 @@
 import org.forgerock.i18n.LocalizableMessage;
 import org.forgerock.opendj.ldap.Attribute;
 import org.forgerock.opendj.ldap.ByteString;
-import org.opends.guitools.controlpanel.datamodel.CustomSearchResult;
+import org.forgerock.opendj.ldap.Entry;
 import org.opends.guitools.controlpanel.task.OfflineUpdateException;
 import org.opends.guitools.controlpanel.util.Utilities;
-import org.opends.server.types.Entry;
 import org.opends.server.types.LDIFImportConfig;
 import org.opends.server.types.OpenDsException;
 import org.opends.server.util.Base64;
@@ -76,7 +75,7 @@
   private JScrollPane readOnlyScroll;
   private JTextArea editableAttributes;
   private JTextArea readOnlyAttributes;
-  private CustomSearchResult searchResult;
+  private Entry searchResult;
 
   /** Default constructor. */
   public LDIFViewEntryPanel()
@@ -151,7 +150,7 @@
   }
 
   @Override
-  public void update(CustomSearchResult sr, boolean isReadOnly, TreePath path)
+  public void update(Entry sr, boolean isReadOnly, TreePath path)
   {
     boolean sameEntry = false;
     if (searchResult != null && sr != null)
@@ -261,16 +260,13 @@
   }
 
   @Override
-  public Entry getEntry() throws OpenDsException
+  public org.opends.server.types.Entry getEntry() throws OpenDsException
   {
-    LDIFImportConfig ldifImportConfig = null;
-    try
+    String ldif = getLDIF();
+    try (LDIFImportConfig ldifImportConfig = new LDIFImportConfig(new StringReader(ldif));
+        LDIFReader reader = new LDIFReader(ldifImportConfig))
     {
-      String ldif = getLDIF();
-
-      ldifImportConfig = new LDIFImportConfig(new StringReader(ldif));
-      LDIFReader reader = new LDIFReader(ldifImportConfig);
-      Entry entry = reader.readEntry(checkSchema());
+      org.opends.server.types.Entry entry = reader.readEntry(checkSchema());
       addValuesInRDN(entry);
       return entry;
     }
@@ -279,13 +275,6 @@
       throw new OfflineUpdateException(
           ERR_CTRL_PANEL_ERROR_CHECKING_ENTRY.get(ioe), ioe);
     }
-    finally
-    {
-      if (ldifImportConfig != null)
-      {
-        ldifImportConfig.close();
-      }
-    }
   }
 
   /**
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/ManageTasksPanel.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/ManageTasksPanel.java
index 964a9b2..0b5479a 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/ManageTasksPanel.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/ManageTasksPanel.java
@@ -51,11 +51,10 @@
 import org.forgerock.i18n.LocalizableMessage;
 import org.forgerock.i18n.slf4j.LocalizedLogger;
 import org.forgerock.opendj.adapter.server3x.Converters;
-import org.forgerock.opendj.ldap.DN;
 import org.forgerock.opendj.ldap.Entry;
 import org.forgerock.opendj.ldap.LinkedAttribute;
+import org.forgerock.opendj.ldap.LinkedHashMapEntry;
 import org.opends.guitools.controlpanel.datamodel.ControlPanelInfo;
-import org.opends.guitools.controlpanel.datamodel.CustomSearchResult;
 import org.opends.guitools.controlpanel.datamodel.ServerDescriptor;
 import org.opends.guitools.controlpanel.datamodel.TaskTableModel;
 import org.opends.guitools.controlpanel.event.ConfigurationChangeEvent;
@@ -459,7 +458,7 @@
     int numberTasks = r.nextInt(10);
     for (int i= 0; i<numberTasks; i++)
     {
-      CustomSearchResult csr = new CustomSearchResult(DN.valueOf("cn=mytask" + i + ",cn=tasks"));
+      Entry csr = new LinkedHashMapEntry("cn=mytask" + i + ",cn=tasks");
       String p = "ds-task-";
       String[] attrNames =
       {
@@ -499,13 +498,12 @@
       {
         final LinkedAttribute attr = new LinkedAttribute(attrNames[j]);
         attr.add(values[j] + r.nextInt());
-        Entry entry = csr.getSdkEntry();
-        entry.removeAttribute(attr.getAttributeDescription());
-        entry.addAttribute(attr);
+        csr.removeAttribute(attr.getAttributeDescription());
+        csr.addAttribute(attr);
       }
       try
       {
-        list.add(new TaskEntry(Converters.to(csr.getSdkEntry())));
+        list.add(new TaskEntry(Converters.to(csr)));
       }
       catch (Throwable t)
       {
@@ -525,7 +523,7 @@
     Set<TaskEntry> list = new HashSet<>();
     for (int i= 0; i<10; i++)
     {
-      CustomSearchResult csr = new CustomSearchResult(DN.valueOf("cn=mytask" + i + ",cn=tasks"));
+      Entry csr = new LinkedHashMapEntry("cn=mytask" + i + ",cn=tasks");
       String p = "ds-task-";
       String[] attrNames =
       {
@@ -565,13 +563,12 @@
       {
         final LinkedAttribute attr = new LinkedAttribute(attrNames[j]);
         attr.add(values[j]);
-        Entry entry = csr.getSdkEntry();
-        entry.removeAttribute(attr.getAttributeDescription());
-        entry.addAttribute(attr);
+        csr.removeAttribute(attr.getAttributeDescription());
+        csr.addAttribute(attr);
       }
       try
       {
-        list.add(new TaskEntry(Converters.to(csr.getSdkEntry())));
+        list.add(new TaskEntry(Converters.to(csr)));
       }
       catch (Throwable t)
       {
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/SimplifiedViewEntryPanel.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/SimplifiedViewEntryPanel.java
index 9351e6e..a664d7d 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/SimplifiedViewEntryPanel.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/SimplifiedViewEntryPanel.java
@@ -77,14 +77,15 @@
 import org.forgerock.opendj.ldap.AttributeDescription;
 import org.forgerock.opendj.ldap.ByteString;
 import org.forgerock.opendj.ldap.DN;
+import org.forgerock.opendj.ldap.Entry;
 import org.forgerock.opendj.ldap.LinkedAttribute;
+import org.forgerock.opendj.ldap.LinkedHashMapEntry;
 import org.forgerock.opendj.ldap.RDN;
 import org.forgerock.opendj.ldap.schema.AttributeType;
 import org.forgerock.opendj.ldap.schema.ObjectClass;
 import org.forgerock.opendj.ldap.schema.Syntax;
 import org.opends.guitools.controlpanel.datamodel.BinaryValue;
 import org.opends.guitools.controlpanel.datamodel.CheckEntrySyntaxException;
-import org.opends.guitools.controlpanel.datamodel.CustomSearchResult;
 import org.opends.guitools.controlpanel.datamodel.ObjectClassValue;
 import org.opends.guitools.controlpanel.event.ScrollPaneBorderListener;
 import org.opends.guitools.controlpanel.task.OnlineUpdateException;
@@ -94,7 +95,6 @@
 import org.opends.guitools.controlpanel.ui.nodes.DndBrowserNodes;
 import org.opends.guitools.controlpanel.util.Utilities;
 import org.opends.server.schema.SchemaConstants;
-import org.opends.server.types.Entry;
 import org.opends.server.types.LDIFImportConfig;
 import org.opends.server.types.OpenDsException;
 import org.opends.server.types.Schema;
@@ -123,7 +123,7 @@
 
   private final Map<String, List<String>> lastUserPasswords = new HashMap<>();
 
-  private CustomSearchResult searchResult;
+  private Entry searchResult;
   private boolean isReadOnly;
   private TreePath treePath;
   private JScrollPane scrollAttributes;
@@ -406,7 +406,7 @@
   }
 
   @Override
-  public void update(CustomSearchResult sr, boolean isReadOnly, TreePath path)
+  public void update(Entry sr, boolean isReadOnly, TreePath path)
   {
     boolean sameEntry = false;
     if (searchResult != null && sr != null)
@@ -614,7 +614,7 @@
     return GridBagConstraints.WEST;
   }
 
-  private JLabel getLabelForAttribute(String attrName, CustomSearchResult sr)
+  private JLabel getLabelForAttribute(String attrName, Entry sr)
   {
     int index = attrName.indexOf(";");
     String basicAttrName;
@@ -666,12 +666,12 @@
     return Utilities.createPrimaryLabel(l.toMessage());
   }
 
-  private LinkedHashSet<AttributeDescription> getSortedAttributes(CustomSearchResult sr, boolean isReadOnly)
+  private LinkedHashSet<AttributeDescription> getSortedAttributes(Entry sr, boolean isReadOnly)
   {
     // Get all attributes that the entry can have
     List<AttributeDescription> entryAttrs = new ArrayList<>();
     List<String> attrsWithNoOptions = new ArrayList<>();
-    for (Attribute attr : sr.getSdkEntry().getAllAttributes())
+    for (Attribute attr : sr.getAllAttributes())
     {
       AttributeDescription attrDesc = attr.getAttributeDescription();
       entryAttrs.add(attrDesc);
@@ -1139,7 +1139,7 @@
     return false;
   }
 
-  private boolean isRequired(AttributeDescription attrDesc, CustomSearchResult sr)
+  private boolean isRequired(AttributeDescription attrDesc, Entry sr)
   {
     Schema schema = getInfo().getServerDescriptor().getSchema();
     if (schema != null)
@@ -1167,7 +1167,7 @@
   }
 
   @Override
-  public Entry getEntry() throws OpenDsException
+  public org.opends.server.types.Entry getEntry() throws OpenDsException
   {
     final List<LocalizableMessage> errors = new ArrayList<>();
 
@@ -1219,7 +1219,7 @@
     try (LDIFImportConfig ldifImportConfig = new LDIFImportConfig(new StringReader(ldif));
         LDIFReader reader = new LDIFReader(ldifImportConfig))
     {
-      final Entry entry = reader.readEntry(checkSchema());
+      final org.opends.server.types.Entry entry = reader.readEntry(checkSchema());
       addValuesInRDN(entry);
       return entry;
     }
@@ -1337,7 +1337,7 @@
     return sb.toString();
   }
 
-  private boolean isAttrName(String attrName, CustomSearchResult sr)
+  private boolean isAttrName(String attrName, Entry sr)
   {
     for (ByteString ocName : sr.getAttribute(OBJECTCLASS_ATTRIBUTE_TYPE_NAME))
     {
@@ -1591,8 +1591,8 @@
 
   private void updatePanel(ObjectClassValue newValue)
   {
-    CustomSearchResult oldResult = searchResult;
-    CustomSearchResult newResult = new CustomSearchResult(searchResult.getName());
+    Entry oldResult = searchResult;
+    Entry newResult = new LinkedHashMapEntry(searchResult.getName());
 
     for (String attrName : schemaReadOnlyAttributesLowerCase)
     {
@@ -1600,9 +1600,8 @@
       if (attr != null && !attr.isEmpty())
       {
         final Attribute newAttr = new LinkedAttribute(attr);
-        org.forgerock.opendj.ldap.Entry entry = newResult.getSdkEntry();
-        entry.removeAttribute(newAttr.getAttributeDescription());
-        entry.addAttribute(newAttr);
+        newResult.removeAttribute(newAttr.getAttributeDescription());
+        newResult.addAttribute(newAttr);
       }
     }
     ignoreEntryChangeEvents = true;
@@ -1654,9 +1653,8 @@
             Attribute oldValues = searchResult.getAttribute(attrName);
             final Attribute newAttr =
                 oldValues != null ? new LinkedAttribute(oldValues) : new LinkedAttribute(attrName);
-            org.forgerock.opendj.ldap.Entry entry = newResult.getSdkEntry();
-            entry.removeAttribute(newAttr.getAttributeDescription());
-            entry.addAttribute(newAttr);
+            newResult.removeAttribute(newAttr.getAttributeDescription());
+            newResult.addAttribute(newAttr);
           }
           else
           {
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/TableViewEntryPanel.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/TableViewEntryPanel.java
index 4eee0ac..6e7f1dd 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/TableViewEntryPanel.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/TableViewEntryPanel.java
@@ -51,19 +51,19 @@
 import org.forgerock.opendj.ldap.AttributeDescription;
 import org.forgerock.opendj.ldap.ByteString;
 import org.forgerock.opendj.ldap.DN;
+import org.forgerock.opendj.ldap.Entry;
 import org.forgerock.opendj.ldap.LinkedAttribute;
+import org.forgerock.opendj.ldap.LinkedHashMapEntry;
 import org.forgerock.opendj.ldap.RDN;
 import org.forgerock.opendj.ldap.schema.AttributeType;
 import org.forgerock.opendj.ldap.schema.ObjectClass;
 import org.opends.guitools.controlpanel.datamodel.BinaryValue;
-import org.opends.guitools.controlpanel.datamodel.CustomSearchResult;
 import org.opends.guitools.controlpanel.datamodel.ObjectClassValue;
 import org.opends.guitools.controlpanel.datamodel.SortableTableModel;
 import org.opends.guitools.controlpanel.task.OnlineUpdateException;
 import org.opends.guitools.controlpanel.ui.renderer.AttributeCellEditor;
 import org.opends.guitools.controlpanel.ui.renderer.LDAPEntryTableCellRenderer;
 import org.opends.guitools.controlpanel.util.Utilities;
-import org.opends.server.types.Entry;
 import org.opends.server.types.LDIFImportConfig;
 import org.opends.server.types.OpenDsException;
 import org.opends.server.types.Schema;
@@ -74,7 +74,7 @@
 class TableViewEntryPanel extends ViewEntryPanel
 {
   private static final long serialVersionUID = 2135331526526472175L;
-  private CustomSearchResult searchResult;
+  private Entry searchResult;
   private LDAPEntryTableModel tableModel;
   private LDAPEntryTableCellRenderer renderer;
   private JTable table;
@@ -158,7 +158,7 @@
   }
 
   @Override
-  public void update(CustomSearchResult sr, boolean isReadOnly, TreePath path)
+  public void update(Entry sr, boolean isReadOnly, TreePath path)
   {
     boolean sameEntry = false;
     if (searchResult != null && sr != null)
@@ -200,7 +200,7 @@
   }
 
   @Override
-  public Entry getEntry() throws OpenDsException
+  public org.opends.server.types.Entry getEntry() throws OpenDsException
   {
     if (SwingUtilities.isEventDispatchThread())
     {
@@ -228,7 +228,7 @@
     try (LDIFImportConfig ldifImportConfig = new LDIFImportConfig(new StringReader(ldif));
         LDIFReader reader = new LDIFReader(ldifImportConfig))
     {
-      Entry entry = reader.readEntry(checkSchema());
+      org.opends.server.types.Entry entry = reader.readEntry(checkSchema());
       addValuesInRDN(entry);
       return entry;
     }
@@ -717,8 +717,8 @@
 
     private void updateObjectClass(ObjectClassValue newValue)
     {
-      CustomSearchResult oldResult = searchResult;
-      CustomSearchResult newResult = new CustomSearchResult(searchResult.getName());
+      Entry oldResult = searchResult;
+      Entry newResult = new LinkedHashMapEntry(searchResult.getName());
 
       for (String attrName : schemaReadOnlyAttributesLowerCase)
       {
@@ -726,9 +726,8 @@
         if (attr != null && !attr.isEmpty())
         {
           final Attribute newAttr = new LinkedAttribute(attr);
-          org.forgerock.opendj.ldap.Entry entry = newResult.getSdkEntry();
-          entry.removeAttribute(newAttr.getAttributeDescription());
-          entry.addAttribute(newAttr);
+          newResult.removeAttribute(newAttr.getAttributeDescription());
+          newResult.addAttribute(newAttr);
         }
       }
       ignoreEntryChangeEvents = true;
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/ViewEntryPanel.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/ViewEntryPanel.java
index 7804754..1a40f1a 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/ViewEntryPanel.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/ViewEntryPanel.java
@@ -40,12 +40,12 @@
 import org.forgerock.opendj.ldap.AttributeDescription;
 import org.forgerock.opendj.ldap.ByteString;
 import org.forgerock.opendj.ldap.DN;
+import org.forgerock.opendj.ldap.Entry;
 import org.forgerock.opendj.ldap.LinkedAttribute;
 import org.forgerock.opendj.ldap.schema.AttributeType;
 import org.forgerock.opendj.ldap.schema.ObjectClass;
 import org.forgerock.opendj.ldap.schema.ObjectClassType;
 import org.opends.guitools.controlpanel.datamodel.BinaryValue;
-import org.opends.guitools.controlpanel.datamodel.CustomSearchResult;
 import org.opends.guitools.controlpanel.datamodel.ObjectClassValue;
 import org.opends.guitools.controlpanel.event.ConfigurationChangeEvent;
 import org.opends.guitools.controlpanel.event.LDAPEntryChangedEvent;
@@ -54,7 +54,6 @@
 import org.opends.guitools.controlpanel.util.Utilities;
 import org.opends.server.schema.SchemaConstants;
 import org.opends.server.types.Attributes;
-import org.opends.server.types.Entry;
 import org.opends.server.types.OpenDsException;
 import org.opends.server.types.Schema;
 import org.opends.server.util.Base64;
@@ -94,7 +93,7 @@
    * @throws OpenDsException if the entry cannot be generated (in particular if
    * the user provided invalid data).
    */
-  public abstract Entry getEntry() throws OpenDsException;
+  public abstract org.opends.server.types.Entry getEntry() throws OpenDsException;
 
   /**
    * Updates the contents of the panel.
@@ -102,7 +101,7 @@
    * @param isReadOnly whether the entry is read-only or not.
    * @param path the tree path associated with the entry in the tree.
    */
-  public abstract void update(CustomSearchResult sr, boolean isReadOnly, TreePath path);
+  public abstract void update(Entry sr, boolean isReadOnly, TreePath path);
 
   /**
    * Adds a title panel to the container.
@@ -182,7 +181,7 @@
    * @param path the path to the node of the entry selected in the tree.  Used
    * to display the same icon as in the tree.
    */
-  protected void updateTitle(CustomSearchResult sr, TreePath path)
+  protected void updateTitle(Entry sr, TreePath path)
   {
     final DN dn = sr.getName();
     if (dn != null && dn.size() > 0)
@@ -275,7 +274,7 @@
    * Adds the values in the RDN to the entry definition.
    * @param entry the entry to be updated.
    */
-  protected void addValuesInRDN(Entry entry)
+  protected void addValuesInRDN(org.opends.server.types.Entry entry)
   {
     // Add the values in the RDN if they are not there
     for (AVA ava : entry.getName().rdn())
@@ -441,7 +440,7 @@
    * @param sr the search result to be updated.
    * @param attrName the attribute name.
    */
-  protected void setValues(CustomSearchResult sr, String attrName)
+  protected void setValues(Entry sr, String attrName)
   {
     List<Object> values = getValues(attrName);
     final LinkedAttribute attr = new LinkedAttribute(attrName);
@@ -486,9 +485,8 @@
     }
     if (!attr.isEmpty())
     {
-      org.forgerock.opendj.ldap.Entry entry = sr.getSdkEntry();
-      entry.removeAttribute(attr.getAttributeDescription());
-      entry.addAttribute(attr);
+      sr.removeAttribute(attr.getAttributeDescription());
+      sr.addAttribute(attr);
     }
   }
 
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/LDAPEntryReader.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/LDAPEntryReader.java
index 5f5445f..999b805 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/LDAPEntryReader.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/LDAPEntryReader.java
@@ -23,12 +23,12 @@
 import java.util.Set;
 
 import org.forgerock.opendj.ldap.DN;
+import org.forgerock.opendj.ldap.Entry;
 import org.forgerock.opendj.ldap.Filter;
 import org.forgerock.opendj.ldap.requests.Requests;
 import org.forgerock.opendj.ldap.requests.SearchRequest;
 import org.forgerock.opendj.ldap.responses.SearchResultEntry;
 import org.opends.admin.ads.util.ConnectionWrapper;
-import org.opends.guitools.controlpanel.datamodel.CustomSearchResult;
 import org.opends.guitools.controlpanel.event.EntryReadErrorEvent;
 import org.opends.guitools.controlpanel.event.EntryReadEvent;
 import org.opends.guitools.controlpanel.event.EntryReadListener;
@@ -38,7 +38,7 @@
  * entries browser.  When the entry is read it notifies to the EntryReadListener
  * objects that have been registered.
  */
-public class LDAPEntryReader extends BackgroundTask<CustomSearchResult>
+public class LDAPEntryReader extends BackgroundTask<Entry>
 {
   private final DN dn;
   private final ConnectionWrapper conn;
@@ -59,7 +59,7 @@
   }
 
   @Override
-  public CustomSearchResult processBackgroundTask() throws Throwable
+  public Entry processBackgroundTask() throws Throwable
   {
     isOver = false;
     final Filter filter = Filter.valueOf("(|(objectclass=*)(objectclass=ldapsubentry))");
@@ -69,12 +69,11 @@
     {
       isOver = true;
     }
-    return new CustomSearchResult(sr);
+    return sr;
   }
 
   @Override
-  public void backgroundTaskCompleted(CustomSearchResult sr,
-      Throwable throwable)
+  public void backgroundTaskCompleted(Entry sr, Throwable throwable)
   {
     if (!isInterrupted() && isNotifyListeners())
     {
@@ -127,7 +126,7 @@
    * Notifies listeners that a new entry was read.
    * @param sr the new entry in form of CustomSearchResult.
    */
-  private void notifyListeners(CustomSearchResult sr)
+  private void notifyListeners(Entry sr)
   {
     EntryReadEvent ev = new EntryReadEvent(this, sr);
     for (EntryReadListener listener : listeners)
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/Utilities.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/Utilities.java
index 3274251..6749125 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/Utilities.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/Utilities.java
@@ -98,6 +98,7 @@
 import org.forgerock.opendj.ldap.AttributeDescription;
 import org.forgerock.opendj.ldap.ByteString;
 import org.forgerock.opendj.ldap.DN;
+import org.forgerock.opendj.ldap.Entry;
 import org.forgerock.opendj.ldap.requests.SearchRequest;
 import org.forgerock.opendj.ldap.responses.SearchResultEntry;
 import org.forgerock.opendj.ldap.schema.AttributeType;
@@ -113,7 +114,6 @@
 import org.opends.guitools.controlpanel.datamodel.CategorizedComboBoxElement;
 import org.opends.guitools.controlpanel.datamodel.ConfigReadException;
 import org.opends.guitools.controlpanel.datamodel.ControlPanelInfo;
-import org.opends.guitools.controlpanel.datamodel.CustomSearchResult;
 import org.opends.guitools.controlpanel.datamodel.MonitoringAttributes;
 import org.opends.guitools.controlpanel.datamodel.SortableTableModel;
 import org.opends.guitools.controlpanel.datamodel.VLVIndexDescriptor;
@@ -2263,7 +2263,7 @@
   public static void deleteConfigSubtree(ConfigurationHandler confHandler, DN dn)
   throws OpenDsException, ConfigException
   {
-    org.forgerock.opendj.ldap.Entry confEntry = confHandler.getEntry(dn);
+    Entry confEntry = confHandler.getEntry(dn);
     if (confEntry != null)
     {
       // Copy the values to avoid problems with this recursive method.
@@ -2416,7 +2416,7 @@
    * @return the first value as a String for a given attribute in the provided
    *         entry.
    */
-  public static String getFirstValueAsString(CustomSearchResult sr, String attrName)
+  public static String getFirstValueAsString(Entry sr, String attrName)
   {
     if (sr != null)
     {

--
Gitblit v1.10.0