From 5e0a551935151242e4308053617c2f487a60d5f0 Mon Sep 17 00:00:00 2001
From: Jean-Noël Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Mon, 08 Aug 2016 07:31:26 +0000
Subject: [PATCH] Partial OPENDJ-3106 Migrate Entry

---
 opendj-server-legacy/src/main/java/org/opends/server/backends/TrustStoreBackend.java |   11 +++++------
 1 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/opendj-server-legacy/src/main/java/org/opends/server/backends/TrustStoreBackend.java b/opendj-server-legacy/src/main/java/org/opends/server/backends/TrustStoreBackend.java
index d08db62..88c4c45 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/backends/TrustStoreBackend.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/backends/TrustStoreBackend.java
@@ -63,6 +63,7 @@
 import org.forgerock.opendj.ldap.SearchScope;
 import org.forgerock.opendj.ldap.schema.AttributeType;
 import org.forgerock.opendj.ldap.schema.CoreSchema;
+import org.forgerock.opendj.ldap.schema.ObjectClass;
 import org.forgerock.opendj.server.config.server.TrustStoreBackendCfg;
 import org.forgerock.util.Reject;
 import org.opends.server.api.Backend;
@@ -86,7 +87,6 @@
 import org.opends.server.types.LDIFExportConfig;
 import org.opends.server.types.LDIFImportConfig;
 import org.opends.server.types.LDIFImportResult;
-import org.forgerock.opendj.ldap.schema.ObjectClass;
 import org.opends.server.types.RestoreConfig;
 import org.opends.server.types.SearchFilter;
 import org.opends.server.util.CertificateManager;
@@ -1077,16 +1077,16 @@
       }
       else
       {
-        List<Attribute> certAttrs = entry.getAllAttributes(
-             ATTR_CRYPTO_PUBLIC_KEY_CERTIFICATE);
-        if (certAttrs.isEmpty())
+        Iterator<Attribute> certAttrs = entry.getAllAttributes(ATTR_CRYPTO_PUBLIC_KEY_CERTIFICATE).iterator();
+        if (!certAttrs.hasNext())
         {
           LocalizableMessage message =
                ERR_TRUSTSTORE_ENTRY_MISSING_CERT_ATTR.get(entryDN, ATTR_CRYPTO_PUBLIC_KEY_CERTIFICATE);
           throw new DirectoryException(
                DirectoryServer.getServerErrorResultCode(), message);
         }
-        if (certAttrs.size() != 1)
+        Attribute certAttr = certAttrs.next();
+        if (certAttrs.hasNext())
         {
           LocalizableMessage message =
                ERR_TRUSTSTORE_ENTRY_HAS_MULTIPLE_CERT_ATTRS.get(entryDN, ATTR_CRYPTO_PUBLIC_KEY_CERTIFICATE);
@@ -1094,7 +1094,6 @@
                DirectoryServer.getServerErrorResultCode(), message);
         }
 
-        Attribute certAttr = certAttrs.get(0);
         Iterator<ByteString> i = certAttr.iterator();
 
         if (!i.hasNext())

--
Gitblit v1.10.0