From 14f94c13789b8ace4eae258b5f1d64494518f9c3 Mon Sep 17 00:00:00 2001
From: Jean-Noël Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Mon, 21 Dec 2015 14:04:12 +0000
Subject: [PATCH] Remove null checks on returned values of Entry.get*Attribute*() methods.
---
opendj-server-legacy/src/main/java/org/opends/server/admin/server/ServerManagementContext.java | 17
opendj-server-legacy/src/main/java/org/opends/server/extensions/UserAttributeNotificationMessageTemplateElement.java | 31
opendj-server-legacy/src/main/java/org/opends/server/plugins/PasswordPolicyImportPlugin.java | 18
opendj-server-legacy/src/main/java/org/opends/server/tasks/AddSchemaFileTask.java | 13
opendj-server-legacy/src/test/java/org/opends/server/backends/ChangelogBackendTestCase.java | 2
opendj-server-legacy/src/test/java/org/opends/server/schema/GenericSchemaTestCase.java | 27
opendj-server-legacy/src/main/java/org/opends/server/api/AuthenticationPolicyState.java | 118 +-
opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/EntryHistorical.java | 69
opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendAddOperation.java | 2
opendj-server-legacy/src/test/java/org/opends/server/extensions/SubschemaSubentryVirtualAttributeProviderTestCase.java | 4
opendj-server-legacy/src/test/java/org/opends/server/extensions/PasswordExpirationTimeVirtualAttributeProviderTestCase.java | 1
opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendBindOperation.java | 5
opendj-server-legacy/src/test/java/org/opends/server/core/AddOperationTestCase.java | 15
opendj-server-legacy/src/main/java/org/opends/server/types/SubEntry.java | 124 -
opendj-server-legacy/src/main/java/org/opends/server/core/PasswordPolicyState.java | 255 ++--
opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/AciList.java | 16
opendj-server-legacy/src/main/java/org/opends/server/backends/BackupBackend.java | 41
opendj-server-legacy/src/test/java/org/opends/server/replication/UpdateOperationTest.java | 2
opendj-server-legacy/src/main/java/org/opends/server/tasks/ShutdownTask.java | 4
opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/AciHandler.java | 34
opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/PersistentServerState.java | 6
opendj-server-legacy/src/main/java/org/opends/server/api/AuthenticationPolicy.java | 115 +-
opendj-server-legacy/src/test/java/org/opends/server/plugins/LDAPADListPluginTestCase.java | 12
opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/FractionalLDIFImportPlugin.java | 16
opendj-server-legacy/src/main/java/org/opends/server/admin/AdministrationDataSync.java | 10
opendj-server-legacy/src/main/java/org/opends/server/tasks/SetGenerationIdTask.java | 2
opendj-server-legacy/src/main/java/org/opends/server/extensions/VirtualStaticGroup.java | 55
opendj-server-legacy/src/main/java/org/opends/server/tools/tasks/TaskEntry.java | 11
opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendModifyOperation.java | 7
opendj-server-legacy/src/main/java/org/opends/server/core/SubentryPasswordPolicy.java | 42
opendj-server-legacy/src/main/java/org/opends/server/plugins/ReferentialIntegrityPlugin.java | 25
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/AttributeIndex.java | 14
opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/AttrHistoricalMultipleTest.java | 2
opendj-server-legacy/src/test/java/org/opends/server/extensions/HasSubordinatesVirtualAttributeProviderTestCase.java | 4
opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/NamingConflictTest.java | 5
opendj-server-legacy/src/main/java/org/opends/server/types/Entry.java | 178 --
opendj-server-legacy/src/test/java/org/opends/server/authorization/dseecompat/AciTestCase.java | 5
opendj-server-legacy/src/main/java/org/opends/server/plugins/EntryUUIDPlugin.java | 3
opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/AssuredReplicationPluginTest.java | 2
opendj-server-legacy/src/main/java/org/opends/server/backends/task/Task.java | 10
opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/LDAPReplicationDomain.java | 10
opendj-server-legacy/src/test/java/org/opends/server/extensions/NumSubordinatesVirtualAttributeProviderTestCase.java | 4
opendj-server-legacy/src/test/java/org/opends/server/tools/makeldif/MakeLDIFTestCase.java | 34
opendj-server-legacy/src/main/java/org/opends/server/backends/TrustStoreBackend.java | 4
opendj-server-legacy/src/test/java/org/opends/server/extensions/EntryDNVirtualAttributeProviderTestCase.java | 11
opendj-server-legacy/src/main/java/org/opends/server/plugins/SevenBitCleanPlugin.java | 16
opendj-server-legacy/src/main/java/org/opends/server/api/ClientConnection.java | 62
opendj-server-legacy/src/test/java/org/opends/server/extensions/StructuralObjectClassVirtualAttributeProviderTestCase.java | 4
opendj-server-legacy/src/test/java/org/opends/server/extensions/EntryUUIDVirtualAttributeProviderTestCase.java | 14
opendj-server-legacy/src/test/java/org/opends/server/core/TestModifyDNOperation.java | 5
opendj-server-legacy/src/test/java/org/opends/server/core/SearchOperationTestCase.java | 12
opendj-server-legacy/src/main/java/org/opends/server/core/SchemaConfigManager.java | 7
opendj-server-legacy/src/main/java/org/opends/server/extensions/SMTPAccountStatusNotificationHandler.java | 25
opendj-server-legacy/src/main/java/org/opends/server/backends/task/TaskScheduler.java | 2
opendj-server-legacy/src/main/java/org/opends/server/extensions/DynamicGroup.java | 39
opendj-server-legacy/src/main/java/org/opends/server/tasks/BackupTask.java | 44
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/ModifyEntryTask.java | 9
opendj-server-legacy/src/main/java/org/opends/server/tasks/DisconnectClientTask.java | 67
opendj-server-legacy/src/test/java/org/opends/server/plugins/SambaPasswordPluginTestCase.java | 17
opendj-server-legacy/src/test/java/org/opends/server/tools/LDIFSearchTestCase.java | 81
opendj-server-legacy/src/main/java/org/opends/server/backends/SchemaBackend.java | 62
opendj-server-legacy/src/main/java/org/opends/server/plugins/UniqueAttributePlugin.java | 118 -
opendj-server-legacy/src/main/java/org/opends/server/types/SearchFilter.java | 78
opendj-server-legacy/src/test/java/org/opends/server/core/SubentryManagerTestCase.java | 5
opendj-server-legacy/src/main/java/org/opends/server/config/ConfigEntry.java | 9
opendj-server-legacy/src/test/java/org/opends/server/backends/pluggable/TestDnKeyFormat.java | 8
opendj-server-legacy/src/test/java/org/opends/server/extensions/UserDefinedVirtualAttributeProviderTestCase.java | 26
opendj-server-legacy/src/main/java/org/opends/server/extensions/StaticGroup.java | 32
opendj-server-legacy/src/main/java/org/opends/server/backends/task/RecurringTask.java | 150 -
opendj-server-legacy/src/test/java/org/opends/server/TestCaseUtils.java | 10
opendj-server-legacy/src/test/java/org/opends/server/plugins/LastModPluginTestCase.java | 20
opendj-server-legacy/src/test/java/org/opends/server/extensions/GoverningStructureRuleVirtualAttributeProviderTestCase.java | 4
opendj-server-legacy/src/main/java/org/opends/server/extensions/ExternalSASLMechanismHandler.java | 24
opendj-server-legacy/src/test/java/org/opends/server/plugins/EntryUUIDPluginTestCase.java | 13
opendj-server-legacy/src/main/java/org/opends/server/tasks/TaskUtils.java | 25
opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendCompareOperation.java | 3
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/ViewEntryPanel.java | 34
opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/AttrHistoricalSingleTest.java | 2
opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/FractionalReplicationTest.java | 32
opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/ModifyConflictTest.java | 30
opendj-server-legacy/src/test/java/org/opends/server/core/ModifyOperationTestCase.java | 29
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/VLVIndex.java | 40
opendj-server-legacy/src/main/java/org/opends/server/extensions/LDAPPassThroughAuthenticationPolicyFactory.java | 98 -
opendj-server-legacy/src/test/java/org/opends/server/types/TestEntry.java | 478 +-------
opendj-server-legacy/src/test/java/org/opends/server/tasks/DummyTask.java | 12
opendj-server-legacy/src/main/java/org/opends/server/extensions/AttributeValuePasswordValidator.java | 20
opendj-server-legacy/src/main/java/org/opends/server/crypto/CryptoManagerSync.java | 44
87 files changed, 1,101 insertions(+), 2,094 deletions(-)
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 4deba27..397ec4a 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
@@ -637,14 +637,11 @@
private static boolean find(List<org.opends.server.types.Attribute> attrs, String attrName)
{
- if (attrs != null)
+ for (org.opends.server.types.Attribute attr : attrs)
{
- for (org.opends.server.types.Attribute attr : attrs)
+ if (attr.getNameWithOptions().equalsIgnoreCase(attrName))
{
- if (attr.getNameWithOptions().equalsIgnoreCase(attrName))
- {
- return true;
- }
+ return true;
}
}
return false;
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 1c6b492..fb3561e 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
@@ -44,6 +44,10 @@
import javax.swing.JLabel;
import javax.swing.tree.TreePath;
+import org.forgerock.i18n.LocalizableMessage;
+import org.forgerock.opendj.ldap.ByteString;
+import org.forgerock.opendj.ldap.schema.ObjectClassType;
+import org.forgerock.opendj.ldap.schema.Syntax;
import org.opends.guitools.controlpanel.datamodel.BinaryValue;
import org.opends.guitools.controlpanel.datamodel.CustomSearchResult;
import org.opends.guitools.controlpanel.datamodel.ObjectClassValue;
@@ -52,15 +56,11 @@
import org.opends.guitools.controlpanel.event.LDAPEntryChangedListener;
import org.opends.guitools.controlpanel.ui.nodes.BasicNode;
import org.opends.guitools.controlpanel.util.Utilities;
-import org.forgerock.i18n.LocalizableMessage;
-import org.forgerock.opendj.ldap.schema.Syntax;
import org.opends.server.schema.SchemaConstants;
import org.opends.server.types.AttributeType;
-import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.types.Attributes;
import org.opends.server.types.Entry;
import org.opends.server.types.ObjectClass;
-import org.forgerock.opendj.ldap.schema.ObjectClassType;
import org.opends.server.types.OpenDsException;
import org.opends.server.types.RDN;
import org.opends.server.types.Schema;
@@ -316,26 +316,22 @@
{
String attrName = rdn.getAttributeName(i);
ByteString value = rdn.getAttributeValue(i);
- List<org.opends.server.types.Attribute> attrs =
- entry.getAttribute(attrName.toLowerCase());
+ List<org.opends.server.types.Attribute> attrs = entry.getAttribute(attrName.toLowerCase());
boolean done = false;
- if (attrs != null)
+ for (org.opends.server.types.Attribute attr : attrs)
{
- for (org.opends.server.types.Attribute attr : attrs)
+ if (attr.getNameWithOptions().equals(attrName))
{
- if (attr.getNameWithOptions().equals(attrName))
+ ArrayList<ByteString> newValues = new ArrayList<>();
+ Iterator<ByteString> it = attr.iterator();
+ while (it.hasNext())
{
- ArrayList<ByteString> newValues = new ArrayList<>();
- Iterator<ByteString> it = attr.iterator();
- while (it.hasNext())
- {
- newValues.add(it.next());
- }
- newValues.add(value);
- entry.addAttribute(attr, newValues);
- done = true;
- break;
+ newValues.add(it.next());
}
+ newValues.add(value);
+ entry.addAttribute(attr, newValues);
+ done = true;
+ break;
}
}
if (!done)
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/admin/AdministrationDataSync.java b/opendj-server-legacy/src/main/java/org/opends/server/admin/AdministrationDataSync.java
index d5f5504..99a38c7 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/admin/AdministrationDataSync.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/admin/AdministrationDataSync.java
@@ -26,6 +26,8 @@
*/
package org.opends.server.admin;
+import static org.opends.server.protocols.internal.Requests.*;
+
import java.net.InetAddress;
import java.util.LinkedList;
import java.util.List;
@@ -48,8 +50,6 @@
import org.opends.server.types.Modification;
import org.opends.server.types.SearchResultEntry;
-import static org.opends.server.protocols.internal.Requests.*;
-
/**
* Check if information found in "cn=admin data" is coherent with
* cn=config. If and inconsistency is detected, we log a warning
@@ -259,14 +259,12 @@
AttributeType attrType = DirectoryServer.getAttributeTypeOrDefault(attrName);
List<Attribute> attrs = adminConnectorEntry.getAttribute(attrType);
- if (attrs != null)
+ if (!attrs.isEmpty())
{
// Get the attribute value
return attrs.get(0).iterator().next().toString();
}
-
- // can not happen
- // best effort.
+ // Can not happen. Best effort.
// TODO Log an Error.
return null;
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/admin/server/ServerManagementContext.java b/opendj-server-legacy/src/main/java/org/opends/server/admin/server/ServerManagementContext.java
index 3f74d97..836fc4c 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/admin/server/ServerManagementContext.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/admin/server/ServerManagementContext.java
@@ -44,16 +44,17 @@
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.config.server.ConfigException;
+import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.admin.AbsoluteInheritedDefaultBehaviorProvider;
import org.opends.server.admin.AbstractManagedObjectDefinition;
import org.opends.server.admin.AggregationPropertyDefinition;
import org.opends.server.admin.AliasDefaultBehaviorProvider;
import org.opends.server.admin.Configuration;
import org.opends.server.admin.ConfigurationClient;
-import org.opends.server.admin.PropertyException;
import org.opends.server.admin.DefaultBehaviorProviderVisitor;
import org.opends.server.admin.DefinedDefaultBehaviorProvider;
import org.opends.server.admin.DefinitionDecodingException;
+import org.opends.server.admin.DefinitionDecodingException.Reason;
import org.opends.server.admin.DefinitionResolver;
import org.opends.server.admin.InstantiableRelationDefinition;
import org.opends.server.admin.LDAPProfile;
@@ -61,6 +62,7 @@
import org.opends.server.admin.ManagedObjectPath;
import org.opends.server.admin.PropertyDefinition;
import org.opends.server.admin.PropertyDefinitionVisitor;
+import org.opends.server.admin.PropertyException;
import org.opends.server.admin.PropertyNotFoundException;
import org.opends.server.admin.PropertyOption;
import org.opends.server.admin.Reference;
@@ -68,14 +70,12 @@
import org.opends.server.admin.RelativeInheritedDefaultBehaviorProvider;
import org.opends.server.admin.SetRelationDefinition;
import org.opends.server.admin.UndefinedDefaultBehaviorProvider;
-import org.opends.server.admin.DefinitionDecodingException.Reason;
import org.opends.server.admin.std.meta.RootCfgDefn;
import org.opends.server.admin.std.server.RootCfg;
import org.opends.server.config.ConfigEntry;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
-import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.types.DN;
/**
@@ -871,17 +871,14 @@
// since the attribute should have been defined.
String attrID = LDAPProfile.getInstance().getAttributeName(d, pd);
AttributeType type = DirectoryServer.getAttributeTypeOrDefault(attrID);
- List<Attribute> attributes = configEntry.getEntry().getAttribute(type, true);
+ List<Attribute> attributes = configEntry.getEntry().getAttribute(type);
List<ByteString> results = new LinkedList<>();
- if (attributes != null)
+ for (Attribute a : attributes)
{
- for (Attribute a : attributes)
+ for (ByteString v : a)
{
- for (ByteString v : a)
- {
- results.add(v);
- }
+ results.add(v);
}
}
return results;
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/api/AuthenticationPolicy.java b/opendj-server-legacy/src/main/java/org/opends/server/api/AuthenticationPolicy.java
index f370b8a..5bab56f 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/api/AuthenticationPolicy.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/api/AuthenticationPolicy.java
@@ -75,69 +75,64 @@
// First check to see if the ds-pwp-password-policy-dn is present.
String userDNString = userEntry.getName().toString();
AttributeType type = DirectoryServer.getAttributeTypeOrDefault(OP_ATTR_PWPOLICY_POLICY_DN);
- List<Attribute> attrList = userEntry.getAttribute(type);
-
- if (attrList != null)
+ for (Attribute a : userEntry.getAttribute(type))
{
- for (Attribute a : attrList)
+ if (a.isEmpty())
{
- if (a.isEmpty())
- {
- continue;
- }
-
- ByteString v = a.iterator().next();
- DN subentryDN;
- try
- {
- subentryDN = DN.decode(v);
- }
- catch (Exception e)
- {
- logger.traceException(e);
-
- logger.trace("Could not parse password policy subentry DN %s for user %s",
- v, userDNString, e);
-
- if (useDefaultOnError)
- {
- logger.error(ERR_PWPSTATE_CANNOT_DECODE_SUBENTRY_VALUE_AS_DN,
- v, userDNString, e.getMessage());
- return DirectoryServer.getDefaultPasswordPolicy();
- }
- else
- {
- LocalizableMessage message = ERR_PWPSTATE_CANNOT_DECODE_SUBENTRY_VALUE_AS_DN
- .get(v, userDNString, e.getMessage());
- throw new DirectoryException(ResultCode.INVALID_DN_SYNTAX, message, e);
- }
- }
-
- AuthenticationPolicy policy = DirectoryServer
- .getAuthenticationPolicy(subentryDN);
- if (policy == null)
- {
- logger.trace("Password policy subentry %s for user %s is not defined in the Directory Server.",
- subentryDN, userDNString);
-
- LocalizableMessage message = ERR_PWPSTATE_NO_SUCH_POLICY.get(userDNString, subentryDN);
- if (useDefaultOnError)
- {
- logger.error(message);
- return DirectoryServer.getDefaultPasswordPolicy();
- }
- else
- {
- throw new DirectoryException(
- DirectoryServer.getServerErrorResultCode(), message);
- }
- }
-
- logger.trace("Using password policy subentry %s for user %s.",
- subentryDN, userDNString);
-
- return policy;
+ continue;
}
+
+ ByteString v = a.iterator().next();
+ DN subentryDN;
+ try
+ {
+ subentryDN = DN.decode(v);
+ }
+ catch (Exception e)
+ {
+ logger.traceException(e);
+
+ logger.trace("Could not parse password policy subentry DN %s for user %s",
+ v, userDNString, e);
+
+ if (useDefaultOnError)
+ {
+ logger.error(ERR_PWPSTATE_CANNOT_DECODE_SUBENTRY_VALUE_AS_DN,
+ v, userDNString, e.getMessage());
+ return DirectoryServer.getDefaultPasswordPolicy();
+ }
+ else
+ {
+ LocalizableMessage message = ERR_PWPSTATE_CANNOT_DECODE_SUBENTRY_VALUE_AS_DN
+ .get(v, userDNString, e.getMessage());
+ throw new DirectoryException(ResultCode.INVALID_DN_SYNTAX, message, e);
+ }
+ }
+
+ AuthenticationPolicy policy = DirectoryServer
+ .getAuthenticationPolicy(subentryDN);
+ if (policy == null)
+ {
+ logger.trace("Password policy subentry %s for user %s is not defined in the Directory Server.",
+ subentryDN, userDNString);
+
+ LocalizableMessage message = ERR_PWPSTATE_NO_SUCH_POLICY.get(userDNString, subentryDN);
+ if (useDefaultOnError)
+ {
+ logger.error(message);
+ return DirectoryServer.getDefaultPasswordPolicy();
+ }
+ else
+ {
+ throw new DirectoryException(
+ DirectoryServer.getServerErrorResultCode(), message);
+ }
+ }
+
+ logger.trace("Using password policy subentry %s for user %s.",
+ subentryDN, userDNString);
+
+ return policy;
}
// The ds-pwp-password-policy-dn attribute was not present, so instead
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/api/AuthenticationPolicyState.java b/opendj-server-legacy/src/main/java/org/opends/server/api/AuthenticationPolicyState.java
index e52a97f..15e55fb 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/api/AuthenticationPolicyState.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/api/AuthenticationPolicyState.java
@@ -35,7 +35,10 @@
import org.forgerock.opendj.ldap.GeneralizedTime;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.core.DirectoryServer;
-import org.opends.server.types.*;
+import org.opends.server.types.Attribute;
+import org.opends.server.types.AttributeType;
+import org.opends.server.types.DirectoryException;
+import org.opends.server.types.Entry;
import static org.opends.messages.CoreMessages.*;
import static org.opends.server.config.ConfigConstants.*;
@@ -106,53 +109,47 @@
final AttributeType attributeType) throws DirectoryException
{
final List<Attribute> attrList = entry.getAttribute(attributeType);
- if (attrList != null)
+ for (final Attribute a : attrList)
{
- for (final Attribute a : attrList)
+ if (a.isEmpty())
{
- if (a.isEmpty())
- {
- continue;
- }
+ continue;
+ }
- final String valueString = toLowerCase(a.iterator().next().toString());
-
- if (valueString.equals("true") || valueString.equals("yes")
- || valueString.equals("on") || valueString.equals("1"))
- {
- if (logger.isTraceEnabled())
- {
- logger.trace("Attribute %s resolves to true for user entry %s",
- attributeType.getNameOrOID(), entry.getName());
- }
-
- return ConditionResult.TRUE;
- }
-
- if (valueString.equals("false") || valueString.equals("no")
- || valueString.equals("off") || valueString.equals("0"))
- {
- if (logger.isTraceEnabled())
- {
- logger.trace("Attribute %s resolves to false for user entry %s",
- attributeType.getNameOrOID(), entry.getName());
- }
-
- return ConditionResult.FALSE;
- }
-
+ final String valueString = toLowerCase(a.iterator().next().toString());
+ if (valueString.equals("true") || valueString.equals("yes") || valueString.equals("on")
+ || valueString.equals("1"))
+ {
if (logger.isTraceEnabled())
{
- logger.trace("Unable to resolve value %s for attribute %s "
- + "in user entry %s as a Boolean.", valueString,
+ logger
+ .trace("Attribute %s resolves to true for user entry %s", attributeType.getNameOrOID(), entry.getName());
+ }
+
+ return ConditionResult.TRUE;
+ }
+
+ if (valueString.equals("false") || valueString.equals("no") || valueString.equals("off")
+ || valueString.equals("0"))
+ {
+ if (logger.isTraceEnabled())
+ {
+ logger.trace("Attribute %s resolves to false for user entry %s",
attributeType.getNameOrOID(), entry.getName());
}
- final LocalizableMessage message = ERR_PWPSTATE_CANNOT_DECODE_BOOLEAN
- .get(valueString, attributeType.getNameOrOID(), entry.getName());
- throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
- message);
+ return ConditionResult.FALSE;
}
+
+ if (logger.isTraceEnabled())
+ {
+ logger.trace("Unable to resolve value %s for attribute %s " + "in user entry %s as a Boolean.", valueString,
+ attributeType.getNameOrOID(), entry.getName());
+ }
+
+ final LocalizableMessage message =
+ ERR_PWPSTATE_CANNOT_DECODE_BOOLEAN.get(valueString, attributeType.getNameOrOID(), entry.getName());
+ throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message);
}
if (logger.isTraceEnabled())
@@ -187,33 +184,28 @@
{
long timeValue = -1;
- final List<Attribute> attrList = entry.getAttribute(attributeType);
- if (attrList != null)
+ for (final Attribute a : entry.getAttribute(attributeType))
{
- for (final Attribute a : attrList)
+ if (a.isEmpty())
{
- if (a.isEmpty())
- {
- continue;
- }
-
- final ByteString v = a.iterator().next();
- try
- {
- timeValue = GeneralizedTime.valueOf(v.toString()).getTimeInMillis();
- }
- catch (final Exception e)
- {
- logger.traceException(e, "Unable to decode value %s for attribute %s in user entry %s",
- v, attributeType.getNameOrOID(), entry.getName());
-
- final LocalizableMessage message = ERR_PWPSTATE_CANNOT_DECODE_GENERALIZED_TIME
- .get(v, attributeType.getNameOrOID(), entry.getName(), e);
- throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
- message, e);
- }
- break;
+ continue;
}
+
+ final ByteString v = a.iterator().next();
+ try
+ {
+ timeValue = GeneralizedTime.valueOf(v.toString()).getTimeInMillis();
+ }
+ catch (final Exception e)
+ {
+ logger.traceException(e, "Unable to decode value %s for attribute %s in user entry %s",
+ v, attributeType.getNameOrOID(), entry.getName());
+
+ final LocalizableMessage message = ERR_PWPSTATE_CANNOT_DECODE_GENERALIZED_TIME
+ .get(v, attributeType.getNameOrOID(), entry.getName(), e);
+ throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message, e);
+ }
+ break;
}
if (timeValue == -1 && logger.isTraceEnabled())
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/api/ClientConnection.java b/opendj-server-legacy/src/main/java/org/opends/server/api/ClientConnection.java
index 0f636b4..2b219f9 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/api/ClientConnection.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/api/ClientConnection.java
@@ -1067,48 +1067,42 @@
}
AttributeType privType = DirectoryServer.getAttributeTypeOrNull(OP_ATTR_PRIVILEGE_NAME);
- List<Attribute> attrList = entry.getAttribute(privType);
- if (attrList != null)
+ for (Attribute a : entry.getAttribute(privType))
{
- for (Attribute a : attrList)
+ for (ByteString v : a)
{
- for (ByteString v : a)
+ String privName = toLowerCase(v.toString());
+
+ // If the name of the privilege is prefixed with a minus sign,
+ // then we will take away that privilege from the user.
+ // We'll handle that at the end so that we can make sure it's not added back later.
+ if (privName.startsWith("-"))
{
- String privName = toLowerCase(v.toString());
-
- // If the name of the privilege is prefixed with a minus
- // sign, then we will take away that privilege from the
- // user. We'll handle that at the end so that we can make
- // sure it's not added back later.
- if (privName.startsWith("-"))
+ privName = privName.substring(1);
+ Privilege p = Privilege.privilegeForName(privName);
+ if (p == null)
{
- privName = privName.substring(1);
- Privilege p = Privilege.privilegeForName(privName);
- if (p == null)
- {
- // FIXME -- Generate an administrative alert.
+ // FIXME -- Generate an administrative alert.
- // We don't know what privilege to remove, so we'll
- // remove all of them.
- newPrivileges.clear();
- return newPrivileges;
- }
- else
- {
- removePrivileges.add(p);
- }
+ // We don't know what privilege to remove, so we'll remove all of them.
+ newPrivileges.clear();
+ return newPrivileges;
}
else
{
- Privilege p = Privilege.privilegeForName(privName);
- if (p == null)
- {
- // FIXME -- Generate an administrative alert.
- }
- else
- {
- newPrivileges.add(p);
- }
+ removePrivileges.add(p);
+ }
+ }
+ else
+ {
+ Privilege p = Privilege.privilegeForName(privName);
+ if (p == null)
+ {
+ // FIXME -- Generate an administrative alert.
+ }
+ else
+ {
+ newPrivileges.add(p);
}
}
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/AciHandler.java b/opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/AciHandler.java
index d945761..1d47a29 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/AciHandler.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/AciHandler.java
@@ -717,20 +717,15 @@
&& resourceEntry.hasAttribute(modAttrType))
{
container.setCurrentAttributeType(modAttrType);
- List<Attribute> attrList =
- resourceEntry.getAttribute(modAttrType, modAttr.getOptions());
- if (attrList != null)
+ for (Attribute a : resourceEntry.getAttribute(modAttrType, modAttr.getOptions()))
{
- for (Attribute a : attrList)
+ for (ByteString v : a)
{
- for (ByteString v : a)
+ container.setCurrentAttributeValue(v);
+ container.setRights(ACI_WRITE_DELETE);
+ if (!skipAccessCheck && !accessAllowed(container))
{
- container.setCurrentAttributeValue(v);
- container.setRights(ACI_WRITE_DELETE);
- if (!skipAccessCheck && !accessAllowed(container))
- {
- return false;
- }
+ return false;
}
}
}
@@ -762,20 +757,15 @@
break;
case INCREMENT:
Entry modifiedEntry = operation.getModifiedEntry();
- List<Attribute> modifiedAttrs =
- modifiedEntry.getAttribute(modAttrType, modAttr.getOptions());
- if (modifiedAttrs != null)
+ for (Attribute attr : modifiedEntry.getAttribute(modAttrType, modAttr.getOptions()))
{
- for (Attribute attr : modifiedAttrs)
+ for (ByteString val : attr)
{
- for (ByteString val : attr)
+ container.setCurrentAttributeValue(val);
+ container.setRights(ACI_WRITE_ADD);
+ if (!skipAccessCheck && !accessAllowed(container))
{
- container.setCurrentAttributeValue(val);
- container.setRights(ACI_WRITE_ADD);
- if (!skipAccessCheck && !accessAllowed(container))
- {
- return false;
- }
+ return false;
}
}
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/AciList.java b/opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/AciList.java
index e248604..109de18 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/AciList.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/AciList.java
@@ -27,16 +27,20 @@
package org.opends.server.authorization.dseecompat;
import static org.opends.messages.AccessControlMessages.*;
-import org.forgerock.i18n.slf4j.LocalizedLogger;
import static org.opends.server.authorization.dseecompat.AciHandler.*;
+
import java.util.*;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import org.forgerock.i18n.LocalizableMessage;
+import org.forgerock.i18n.slf4j.LocalizedLogger;
+import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.api.Backend;
import org.opends.server.api.DITCacheMap;
-import org.opends.server.types.*;
-import org.forgerock.opendj.ldap.ByteString;
+import org.opends.server.types.Attribute;
+import org.opends.server.types.DN;
+import org.opends.server.types.Entry;
+import org.opends.server.types.RDN;
/**
* The AciList class performs caching of the ACI attribute values
@@ -246,8 +250,7 @@
DN dn, DN configDN,
List<Attribute> attributeList,
List<LocalizableMessage> failedACIMsgs) {
-
- if (attributeList == null) {
+ if (attributeList.isEmpty()) {
return 0;
}
@@ -306,8 +309,7 @@
//attributes are skipped.
if(hasGlobalAci && oldEntry.getName().equals(configDN)) {
aciList.remove(DN.rootDN());
- List<Attribute> attributeList =
- newEntry.getAttribute(globalAciType);
+ List<Attribute> attributeList = newEntry.getAttribute(globalAciType);
addAciAttributeList(aciList, DN.rootDN(), configDN,
attributeList, failedACIMsgs);
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/backends/BackupBackend.java b/opendj-server-legacy/src/main/java/org/opends/server/backends/BackupBackend.java
index d755361..5285625 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/backends/BackupBackend.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/backends/BackupBackend.java
@@ -399,7 +399,7 @@
AttributeType t =
DirectoryServer.getAttributeTypeOrDefault(ATTR_BACKUP_DIRECTORY_PATH);
List<Attribute> attrList = backupDirEntry.getAttribute(t);
- if (attrList != null && !attrList.isEmpty())
+ if (!attrList.isEmpty())
{
for (ByteString v : attrList.get(0))
{
@@ -851,58 +851,51 @@
private void returnEntries(SearchOperation searchOperation, DN baseDN, SearchFilter filter, List<Attribute> attrList)
{
- if (attrList != null && !attrList.isEmpty())
+ for (ByteString v : attrList.get(0))
{
- for (ByteString v : attrList.get(0))
+ try
{
- try
- {
- File dir = new File(v.toString());
- BackupDirectory backupDirectory = backupDirectories.get(dir).getBackupDirectory();
- AttributeType idType = DirectoryServer.getAttributeTypeOrDefault(ATTR_BACKUP_ID);
+ File dir = new File(v.toString());
+ BackupDirectory backupDirectory = backupDirectories.get(dir).getBackupDirectory();
+ AttributeType idType = DirectoryServer.getAttributeTypeOrDefault(ATTR_BACKUP_ID);
- for (String backupID : backupDirectory.getBackups().keySet())
+ for (String backupID : backupDirectory.getBackups().keySet())
+ {
+ DN backupEntryDN = makeChildDN(baseDN, idType, backupID);
+ Entry backupEntry = getBackupEntry(backupEntryDN);
+ if (filter.matchesEntry(backupEntry))
{
- DN backupEntryDN = makeChildDN(baseDN, idType, backupID);
- Entry backupEntry = getBackupEntry(backupEntryDN);
- if (filter.matchesEntry(backupEntry))
- {
- searchOperation.returnEntry(backupEntry, null);
- }
+ searchOperation.returnEntry(backupEntry, null);
}
}
- catch (Exception e)
- {
- logger.traceException(e);
+ }
+ catch (Exception e)
+ {
+ logger.traceException(e);
- continue;
- }
+ continue;
}
}
}
- /** {@inheritDoc} */
@Override
public Set<String> getSupportedControls()
{
return Collections.emptySet();
}
- /** {@inheritDoc} */
@Override
public Set<String> getSupportedFeatures()
{
return Collections.emptySet();
}
- /** {@inheritDoc} */
@Override
public boolean supports(BackendOperation backendOperation)
{
return false;
}
- /** {@inheritDoc} */
@Override
public void exportLDIF(LDIFExportConfig exportConfig)
throws DirectoryException
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/backends/SchemaBackend.java b/opendj-server-legacy/src/main/java/org/opends/server/backends/SchemaBackend.java
index 90f288c..673f15d 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/backends/SchemaBackend.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/backends/SchemaBackend.java
@@ -3633,49 +3633,43 @@
// loop on the attribute types in the entry just received
// and add them in the existing schema.
- List<Attribute> attrList = newSchemaEntry.getAttribute(attributeAttrType);
Set<String> oidList = new HashSet<>(1000);
- if (attrList != null && !attrList.isEmpty())
+ for (Attribute a : newSchemaEntry.getAttribute(attributeAttrType))
{
- for (Attribute a : attrList)
+ // Look for attribute types that could have been added to the schema
+ // or modified in the schema
+ for (ByteString v : a)
{
- // Look for attribute types that could have been added to the schema
- // or modified in the schema
- for (ByteString v : a)
+ // Parse the attribute type.
+ AttributeType attrType = AttributeTypeSyntax.decodeAttributeType(v, schema, false);
+ String schemaFile = getSchemaFile(attrType);
+ if (CONFIG_SCHEMA_ELEMENTS_FILE.equals(schemaFile))
{
- // Parse the attribute type.
- AttributeType attrType = AttributeTypeSyntax.decodeAttributeType(v, schema, false);
- String schemaFile = getSchemaFile(attrType);
- if (CONFIG_SCHEMA_ELEMENTS_FILE.equals(schemaFile))
- {
- // Don't import the file containing the definitions of the
- // Schema elements used for configuration because these
- // definitions may vary between versions of OpenDJ.
- continue;
- }
+ // Don't import the file containing the definitions of the
+ // Schema elements used for configuration because these
+ // definitions may vary between versions of OpenDJ.
+ continue;
+ }
- oidList.add(attrType.getOID());
- try
+ oidList.add(attrType.getOID());
+ try
+ {
+ // Register this attribute type in the new schema
+ // unless it is already defined with the same syntax.
+ AttributeType oldAttrType = schema.getAttributeType(attrType.getOID());
+ if (oldAttrType == null || !oldAttrType.toString().equals(attrType.toString()))
{
- // Register this attribute type in the new schema
- // unless it is already defined with the same syntax.
- AttributeType oldAttrType =
- schema.getAttributeType(attrType.getOID());
- if (oldAttrType == null ||
- !oldAttrType.toString().equals(attrType.toString()))
+ newSchema.registerAttributeType(attrType, true);
+
+ if (schemaFile != null)
{
- newSchema.registerAttributeType(attrType, true);
-
- if (schemaFile != null)
- {
- modifiedSchemaFiles.add(schemaFile);
- }
+ modifiedSchemaFiles.add(schemaFile);
}
}
- catch (Exception e)
- {
- logger.info(NOTE_SCHEMA_IMPORT_FAILED, attrType, e.getMessage());
- }
+ }
+ catch (Exception e)
+ {
+ logger.info(NOTE_SCHEMA_IMPORT_FAILED, attrType, e.getMessage());
}
}
}
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 1c3173b..0602071 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
@@ -80,8 +80,8 @@
import org.opends.server.core.ServerContext;
import org.opends.server.types.*;
import org.opends.server.util.CertificateManager;
-import org.opends.server.util.SetupUtils;
import org.opends.server.util.Platform.KeyType;
+import org.opends.server.util.SetupUtils;
/**
* This class defines a backend used to provide an LDAP view of public keys
@@ -1225,7 +1225,7 @@
{
List<Attribute> certAttrs = entry.getAttribute(
ATTR_CRYPTO_PUBLIC_KEY_CERTIFICATE);
- if (certAttrs == null)
+ if (certAttrs.isEmpty())
{
LocalizableMessage message =
ERR_TRUSTSTORE_ENTRY_MISSING_CERT_ATTR.get(entryDN, ATTR_CRYPTO_PUBLIC_KEY_CERTIFICATE);
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/AttributeIndex.java b/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/AttributeIndex.java
index 740a4ca..e90309d 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/AttributeIndex.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/AttributeIndex.java
@@ -119,12 +119,6 @@
this.indexer = indexer;
}
- void indexEntry(Entry entry, Set<ByteString> keys)
- {
- List<Attribute> attributes = entry.getAttribute(attributeType, true);
- indexAttribute(attributes, keys);
- }
-
Set<ByteString> indexEntry(Entry entry)
{
final Set<ByteString> keys = new HashSet<>();
@@ -155,13 +149,9 @@
}
}
- private void indexAttribute(List<Attribute> attributes, Set<ByteString> keys)
+ void indexEntry(Entry entry, Set<ByteString> keys)
{
- if (attributes == null)
- {
- return;
- }
- for (Attribute attr : attributes)
+ for (Attribute attr : entry.getAttribute(attributeType))
{
if (!attr.isVirtual())
{
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/VLVIndex.java b/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/VLVIndex.java
index cc2a40e..ec0b7a0 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/VLVIndex.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/VLVIndex.java
@@ -770,34 +770,30 @@
{
final AttributeType attributeType = sortKey.getAttributeType();
final MatchingRule matchingRule = sortKey.getEffectiveOrderingRule();
- final List<Attribute> attrList = entry.getAttribute(attributeType);
ByteString sortValue = null;
- if (attrList != null)
+ for (Attribute a : entry.getAttribute(attributeType))
{
- for (Attribute a : attrList)
+ for (ByteString v : a)
{
- for (ByteString v : a)
+ try
{
- try
+ /*
+ * The RFC states that the lowest value of a multi-valued attribute should be used,
+ * regardless of the sort order.
+ */
+ final ByteString nv = matchingRule.normalizeAttributeValue(v);
+ if (sortValue == null || nv.compareTo(sortValue) < 0)
{
- /*
- * The RFC states that the lowest value of a multi-valued attribute should be used,
- * regardless of the sort order.
- */
- final ByteString nv = matchingRule.normalizeAttributeValue(v);
- if (sortValue == null || nv.compareTo(sortValue) < 0)
- {
- sortValue = nv;
- }
+ sortValue = nv;
}
- catch (final DecodeException e)
- {
- /*
- * This shouldn't happen because the attribute should have already been validated. If
- * it does then treat the value as missing.
- */
- continue;
- }
+ }
+ catch (final DecodeException e)
+ {
+ /*
+ * This shouldn't happen because the attribute should have already been validated.
+ * If it does then treat the value as missing.
+ */
+ continue;
}
}
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/backends/task/RecurringTask.java b/opendj-server-legacy/src/main/java/org/opends/server/backends/task/RecurringTask.java
index f600a91..06bde9f 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/backends/task/RecurringTask.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/backends/task/RecurringTask.java
@@ -36,6 +36,7 @@
import java.util.regex.Pattern;
import org.forgerock.i18n.LocalizableMessage;
+import org.forgerock.i18n.LocalizableMessageDescriptor.Arg1;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ResultCode;
@@ -151,78 +152,16 @@
this.recurringTaskEntryDN = recurringTaskEntry.getName();
// Get the recurring task ID from the entry. If there isn't one, then fail.
- AttributeType attrType = DirectoryServer.getAttributeTypeOrDefault(
- ATTR_RECURRING_TASK_ID.toLowerCase(), ATTR_RECURRING_TASK_ID);
- List<Attribute> attrList = recurringTaskEntry.getAttribute(attrType);
- if (attrList == null || attrList.isEmpty())
- {
- LocalizableMessage message =
- ERR_RECURRINGTASK_NO_ID_ATTRIBUTE.get(ATTR_RECURRING_TASK_ID);
- throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message);
- }
-
- if (attrList.size() > 1)
- {
- LocalizableMessage message =
- ERR_RECURRINGTASK_MULTIPLE_ID_TYPES.get(ATTR_RECURRING_TASK_ID);
- throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message);
- }
-
- Attribute attr = attrList.get(0);
- if (attr.isEmpty())
- {
- LocalizableMessage message = ERR_RECURRINGTASK_NO_ID.get(ATTR_RECURRING_TASK_ID);
- throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message);
- }
-
- Iterator<ByteString> iterator = attr.iterator();
- ByteString value = iterator.next();
- if (iterator.hasNext())
- {
- LocalizableMessage message =
- ERR_RECURRINGTASK_MULTIPLE_ID_VALUES.get(ATTR_RECURRING_TASK_ID);
- throw new DirectoryException(ResultCode.OBJECTCLASS_VIOLATION, message);
- }
-
- recurringTaskID = value.toString();
-
+ Attribute attr = getSingleAttribute(recurringTaskEntry, ATTR_RECURRING_TASK_ID,
+ ERR_RECURRINGTASK_NO_ID_ATTRIBUTE, ERR_RECURRINGTASK_MULTIPLE_ID_TYPES, ERR_RECURRINGTASK_NO_ID);
+ recurringTaskID = getSingleAttributeValue(attr,
+ ResultCode.OBJECTCLASS_VIOLATION, ERR_RECURRINGTASK_MULTIPLE_ID_VALUES, ATTR_RECURRING_TASK_ID);
// Get the schedule for this task.
- attrType = DirectoryServer.getAttributeTypeOrDefault(
- ATTR_RECURRING_TASK_SCHEDULE.toLowerCase(), ATTR_RECURRING_TASK_SCHEDULE);
-
- attrList = recurringTaskEntry.getAttribute(attrType);
- if (attrList == null || attrList.isEmpty())
- {
- LocalizableMessage message = ERR_RECURRINGTASK_NO_SCHEDULE_ATTRIBUTE.get(
- ATTR_RECURRING_TASK_SCHEDULE);
- throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message);
- }
-
- if (attrList.size() > 1)
- {
- LocalizableMessage message = ERR_RECURRINGTASK_MULTIPLE_SCHEDULE_TYPES.get(
- ATTR_RECURRING_TASK_SCHEDULE);
- throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message);
- }
-
- attr = attrList.get(0);
- if (attr.isEmpty())
- {
- LocalizableMessage message = ERR_RECURRINGTASK_NO_SCHEDULE_VALUES.get(
- ATTR_RECURRING_TASK_SCHEDULE);
- throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message);
- }
-
- iterator = attr.iterator();
- value = iterator.next();
- if (iterator.hasNext())
- {
- LocalizableMessage message = ERR_RECURRINGTASK_MULTIPLE_SCHEDULE_VALUES.get(ATTR_RECURRING_TASK_SCHEDULE);
- throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message);
- }
-
- String taskScheduleTab = value.toString();
+ attr = getSingleAttribute(recurringTaskEntry, ATTR_RECURRING_TASK_SCHEDULE,ERR_RECURRINGTASK_NO_SCHEDULE_ATTRIBUTE,
+ ERR_RECURRINGTASK_MULTIPLE_SCHEDULE_TYPES, ERR_RECURRINGTASK_NO_SCHEDULE_VALUES);
+ String taskScheduleTab = getSingleAttributeValue(attr,
+ ResultCode.CONSTRAINT_VIOLATION, ERR_RECURRINGTASK_MULTIPLE_SCHEDULE_VALUES, ATTR_RECURRING_TASK_SCHEDULE);
boolean[][] taskArrays = new boolean[][]{null, null, null, null, null};
@@ -235,37 +174,10 @@
weekdayArray = taskArrays[WEEKDAY_INDEX];
// Get the class name from the entry. If there isn't one, then fail.
- attrType = DirectoryServer.getAttributeTypeOrDefault(ATTR_TASK_CLASS.toLowerCase(), ATTR_TASK_CLASS);
-
- attrList = recurringTaskEntry.getAttribute(attrType);
- if (attrList == null || attrList.isEmpty())
- {
- LocalizableMessage message = ERR_TASKSCHED_NO_CLASS_ATTRIBUTE.get(ATTR_TASK_CLASS);
- throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message);
- }
-
- if (attrList.size() > 1)
- {
- LocalizableMessage message = ERR_TASKSCHED_MULTIPLE_CLASS_TYPES.get(ATTR_TASK_CLASS);
- throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message);
- }
-
- attr = attrList.get(0);
- if (attr.isEmpty())
- {
- LocalizableMessage message = ERR_TASKSCHED_NO_CLASS_VALUES.get(ATTR_TASK_CLASS);
- throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message);
- }
-
- iterator = attr.iterator();
- value = iterator.next();
- if (iterator.hasNext())
- {
- LocalizableMessage message = ERR_TASKSCHED_MULTIPLE_CLASS_VALUES.get(ATTR_TASK_CLASS);
- throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message);
- }
-
- taskClassName = value.toString();
+ attr = getSingleAttribute(recurringTaskEntry, ATTR_TASK_CLASS, ERR_TASKSCHED_NO_CLASS_ATTRIBUTE,
+ ERR_TASKSCHED_MULTIPLE_CLASS_TYPES, ERR_TASKSCHED_NO_CLASS_VALUES);
+ taskClassName = getSingleAttributeValue(attr,
+ ResultCode.CONSTRAINT_VIOLATION, ERR_TASKSCHED_MULTIPLE_CLASS_VALUES, ATTR_TASK_CLASS);
// Make sure that the specified class can be loaded.
@@ -316,6 +228,42 @@
task.initializeTask();
}
+ private String getSingleAttributeValue(Attribute attr, ResultCode erorrRc, Arg1<Object> multipleAttrValueErrorMsg,
+ String attrName) throws DirectoryException
+ {
+ Iterator<ByteString> it = attr.iterator();
+ ByteString value = it.next();
+ if (it.hasNext())
+ {
+ throw new DirectoryException(erorrRc, multipleAttrValueErrorMsg.get(attrName));
+ }
+ return value.toString();
+ }
+
+ private Attribute getSingleAttribute(Entry taskEntry, String attrName, Arg1<Object> noEntryErrorMsg,
+ Arg1<Object> multipleEntriesErrorMsg, Arg1<Object> noAttrValueErrorMsg) throws DirectoryException
+ {
+ AttributeType attrType = DirectoryServer.getAttributeTypeOrDefault(attrName.toLowerCase(), attrName);
+ List<Attribute> attrList = taskEntry.getAttribute(attrType);
+ if (attrList.isEmpty())
+ {
+ LocalizableMessage message = noEntryErrorMsg.get(attrName);
+ throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message);
+ }
+ if (attrList.size() > 1)
+ {
+ LocalizableMessage message = multipleEntriesErrorMsg.get(attrName);
+ throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message);
+ }
+ Attribute attr = attrList.get(0);
+ if (attr.isEmpty())
+ {
+ LocalizableMessage message = noAttrValueErrorMsg.get(attrName);
+ throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message);
+ }
+ return attr;
+ }
+
/**
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/backends/task/Task.java b/opendj-server-legacy/src/main/java/org/opends/server/backends/task/Task.java
index 4132eed..ee72df7 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/backends/task/Task.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/backends/task/Task.java
@@ -312,7 +312,7 @@
throws InitializationException
{
List<Attribute> attrList = taskEntry.getAttribute(attributeName.toLowerCase());
- if (attrList == null || attrList.isEmpty())
+ if (attrList.isEmpty())
{
if (isRequired)
{
@@ -361,7 +361,7 @@
{
LinkedList<String> valueStrings = new LinkedList<>();
List<Attribute> attrList = taskEntry.getAttribute(attributeName.toLowerCase());
- if (attrList == null || attrList.isEmpty())
+ if (attrList.isEmpty())
{
return valueStrings;
}
@@ -848,14 +848,10 @@
final List<Attribute> attrList = taskEntry.getAttribute(type);
ByteString value = ByteString.valueOfUtf8(messageString);
- if (attrList == null)
+ if (attrList.isEmpty())
{
taskEntry.putAttribute(type, newArrayList(Attributes.create(type, value)));
}
- else if (attrList.isEmpty())
- {
- attrList.add(Attributes.create(type, value));
- }
else
{
AttributeBuilder builder = new AttributeBuilder(attrList.get(0));
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/backends/task/TaskScheduler.java b/opendj-server-legacy/src/main/java/org/opends/server/backends/task/TaskScheduler.java
index 357b156..4df3374 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/backends/task/TaskScheduler.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/backends/task/TaskScheduler.java
@@ -1803,7 +1803,7 @@
// Get the name of the class that implements the task logic.
AttributeType attrType = DirectoryServer.getAttributeTypeOrDefault(ATTR_TASK_CLASS.toLowerCase(), ATTR_TASK_CLASS);
List<Attribute> attrList = entry.getAttribute(attrType);
- if (attrList == null || attrList.isEmpty())
+ if (attrList.isEmpty())
{
LocalizableMessage message = ERR_TASKSCHED_NO_CLASS_ATTRIBUTE.get(ATTR_TASK_ID);
throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message);
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/config/ConfigEntry.java b/opendj-server-legacy/src/main/java/org/opends/server/config/ConfigEntry.java
index 2100e95..93cdd80 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/config/ConfigEntry.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/config/ConfigEntry.java
@@ -193,17 +193,12 @@
* interpreted as the specified type of
* configuration attribute.
*/
- public ConfigAttribute getConfigAttribute(ConfigAttribute stub)
- throws ConfigException
+ public ConfigAttribute getConfigAttribute(ConfigAttribute stub) throws ConfigException
{
String attrName = stub.getName();
AttributeType attrType = DirectoryServer.getAttributeTypeOrDefault(attrName.toLowerCase(), attrName);
List<Attribute> attrList = entry.getAttribute(attrType);
- if (attrList != null && !attrList.isEmpty())
- {
- return stub.getConfigAttribute(attrList);
- }
- return null;
+ return !attrList.isEmpty() ? stub.getConfigAttribute(attrList) : null;
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/core/PasswordPolicyState.java b/opendj-server-legacy/src/main/java/org/opends/server/core/PasswordPolicyState.java
index 4cbd014..52d7f5c 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/core/PasswordPolicyState.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/core/PasswordPolicyState.java
@@ -199,15 +199,11 @@
private Attribute getFirstAttributeNotEmpty(AttributeType attributeType)
{
- List<Attribute> attrList = userEntry.getAttribute(attributeType);
- if (attrList != null)
+ for (Attribute a : userEntry.getAttribute(attributeType))
{
- for (Attribute a : attrList)
+ if (!a.isEmpty())
{
- if (!a.isEmpty())
- {
- return a;
- }
+ return a;
}
}
return null;
@@ -227,26 +223,22 @@
{
ArrayList<Long> timeValues = new ArrayList<>();
- List<Attribute> attrList = userEntry.getAttribute(attributeType);
- if (attrList != null)
+ for (Attribute a : userEntry.getAttribute(attributeType))
{
- for (Attribute a : attrList)
+ for (ByteString v : a)
{
- for (ByteString v : a)
+ try
{
- try
- {
- timeValues.add(GeneralizedTime.valueOf(v.toString()).getTimeInMillis());
- }
- catch (Exception e)
- {
- logger.traceException(e, "Unable to decode value %s for attribute %s in user entry %s",
- v, attributeType.getNameOrOID(), userDNString);
+ timeValues.add(GeneralizedTime.valueOf(v.toString()).getTimeInMillis());
+ }
+ catch (Exception e)
+ {
+ logger.traceException(e, "Unable to decode value %s for attribute %s in user entry %s",
+ v, attributeType.getNameOrOID(), userDNString);
- throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
- ERR_PWPSTATE_CANNOT_DECODE_GENERALIZED_TIME.get(v, attributeType.getNameOrOID(), userDNString, e),
- e);
- }
+ throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
+ ERR_PWPSTATE_CANNOT_DECODE_GENERALIZED_TIME.get(v, attributeType.getNameOrOID(), userDNString, e),
+ e);
}
}
}
@@ -1058,64 +1050,59 @@
boolean isGeneralizedTime = SYNTAX_GENERALIZED_TIME_NAME.equals(type.getSyntax().getName());
lastLoginTime = -1;
- List<Attribute> attrList = userEntry.getAttribute(type);
-
- if (attrList != null)
+ for (Attribute a : userEntry.getAttribute(type))
{
- for (Attribute a : attrList)
+ if (a.isEmpty())
{
- if (a.isEmpty())
+ continue;
+ }
+
+ String valueString = a.iterator().next().toString();
+ try
+ {
+ lastLoginTime = parseTime(format, valueString, isGeneralizedTime);
+
+ if (logger.isTraceEnabled())
{
- continue;
+ logger.trace("Returning last login time of %d for user %s, decoded using current last login time format.",
+ lastLoginTime, userDNString);
}
- String valueString = a.iterator().next().toString();
- try
+ return lastLoginTime;
+ }
+ catch (Exception e)
+ {
+ logger.traceException(e);
+
+ // This could mean that the last login time was encoded using a previous format.
+ for (String f : passwordPolicy.getPreviousLastLoginTimeFormats())
{
- lastLoginTime = parseTime(format, valueString, isGeneralizedTime);
-
- if (logger.isTraceEnabled())
+ try
{
- logger.trace("Returning last login time of %d for user %s, decoded using current last login time format.",
- lastLoginTime, userDNString);
- }
+ lastLoginTime = parseTime(f, valueString, isGeneralizedTime);
- return lastLoginTime;
- }
- catch (Exception e)
- {
- logger.traceException(e);
-
- // This could mean that the last login time was encoded using a previous format.
- for (String f : passwordPolicy.getPreviousLastLoginTimeFormats())
- {
- try
+ if (logger.isTraceEnabled())
{
- lastLoginTime = parseTime(f, valueString, isGeneralizedTime);
-
- if (logger.isTraceEnabled())
- {
- logger.trace("Returning last login time of %d for user %s decoded using previous last login time " +
- "format of %s.", lastLoginTime, userDNString, f);
- }
-
- return lastLoginTime;
+ logger.trace("Returning last login time of %d for user %s decoded using previous last login time "
+ + "format of %s.", lastLoginTime, userDNString, f);
}
- catch (Exception e2)
- {
- logger.traceException(e);
- }
+
+ return lastLoginTime;
}
-
- assert lastLoginTime == -1;
- if (logger.isTraceEnabled())
+ catch (Exception e2)
{
- logger.trace("Returning -1 for user %s because the last login time value %s could not be parsed " +
- "using any known format.", userDNString, valueString);
+ logger.traceException(e);
}
-
- return lastLoginTime;
}
+
+ assert lastLoginTime == -1;
+ if (logger.isTraceEnabled())
+ {
+ logger.trace("Returning -1 for user %s because the last login time value %s could not be parsed "
+ + "using any known format.", userDNString, valueString);
+ }
+
+ return lastLoginTime;
}
}
@@ -2119,9 +2106,8 @@
{
LinkedList<ByteString> clearPasswords = new LinkedList<>();
- List<Attribute> attrList = userEntry.getAttribute(passwordPolicy.getPasswordAttribute());
-
- if (attrList == null)
+ final List<Attribute> attrList = userEntry.getAttribute(passwordPolicy.getPasswordAttribute());
+ if (attrList.isEmpty())
{
return clearPasswords;
}
@@ -2179,7 +2165,7 @@
public boolean passwordMatches(ByteString password)
{
List<Attribute> attrList = userEntry.getAttribute(passwordPolicy.getPasswordAttribute());
- if (attrList == null || attrList.isEmpty())
+ if (attrList.isEmpty())
{
if (logger.isTraceEnabled())
{
@@ -2358,13 +2344,9 @@
AttributeType type = passwordPolicy.getPasswordAttribute();
List<Attribute> attrList = userEntry.getAttribute(type);
- if (attrList == null || attrList.isEmpty())
+ if (attrList.isEmpty())
{
- if (logger.isTraceEnabled())
- {
- logger.trace("Doing nothing for entry %s because no password values were found.", userDNString);
- }
-
+ logger.trace("Doing nothing for entry %s because no password values were found.", userDNString);
return;
}
@@ -2597,20 +2579,36 @@
{
TreeMap<Long, ByteString> historyMap = new TreeMap<>();
AttributeType historyType = DirectoryServer.getAttributeTypeOrDefault(OP_ATTR_PWPOLICY_HISTORY_LC);
- List<Attribute> attrList = userEntry.getAttribute(historyType);
- if (attrList != null)
+ for (Attribute a : userEntry.getAttribute(historyType))
{
- for (Attribute a : attrList)
+ for (ByteString v : a)
{
- for (ByteString v : a)
+ String histStr = v.toString();
+ int hashPos = histStr.indexOf('#');
+ if (hashPos <= 0)
{
- String histStr = v.toString();
- int hashPos = histStr.indexOf('#');
- if (hashPos <= 0)
+ logger.trace("Found value %s in the history with no timestamp. Marking it for removal.", histStr);
+
+ if (removeAttrs != null)
+ {
+ removeAttrs.add(Attributes.create(a.getAttributeType(), v));
+ }
+ }
+ else
+ {
+ try
+ {
+ ByteString timeValue = ByteString.valueOfUtf8(histStr.substring(0, hashPos));
+ long timestamp = GeneralizedTimeSyntax.decodeGeneralizedTimeValue(timeValue);
+ historyMap.put(timestamp, v);
+ }
+ catch (Exception e)
{
if (logger.isTraceEnabled())
{
- logger.trace("Found value " + histStr + " in the history with no timestamp. Marking it for removal.");
+ logger.traceException(e);
+ logger.trace("Could not decode the timestamp in history value %s -- %s. Marking it for removal.",
+ histStr, e.getLocalizedMessage());
}
if (removeAttrs != null)
@@ -2618,29 +2616,6 @@
removeAttrs.add(Attributes.create(a.getAttributeType(), v));
}
}
- else
- {
- try
- {
- ByteString timeValue = ByteString.valueOfUtf8(histStr.substring(0, hashPos));
- long timestamp = GeneralizedTimeSyntax.decodeGeneralizedTimeValue(timeValue);
- historyMap.put(timestamp, v);
- }
- catch (Exception e)
- {
- if (logger.isTraceEnabled())
- {
- logger.traceException(e);
- logger.trace("Could not decode the timestamp in history value " + histStr + " -- " + e +
- ". Marking it for removal.");
- }
-
- if (removeAttrs != null)
- {
- removeAttrs.add(Attributes.create(a.getAttributeType(), v));
- }
- }
- }
}
}
}
@@ -2753,44 +2728,41 @@
*/
public void updatePasswordHistory()
{
- List<Attribute> attrList = userEntry.getAttribute(passwordPolicy.getPasswordAttribute());
- if (attrList != null)
+ for (Attribute a : userEntry.getAttribute(passwordPolicy.getPasswordAttribute()))
{
- for (Attribute a : attrList)
+ ByteString insecurePassword = null;
+ for (ByteString v : a)
{
- ByteString insecurePassword = null;
- for (ByteString v : a)
+ try
{
- try
- {
- PasswordStorageScheme<?> scheme = getPasswordStorageScheme(v);
+ PasswordStorageScheme<?> scheme = getPasswordStorageScheme(v);
- if (scheme.isStorageSchemeSecure())
- {
- addPasswordToHistory(v.toString());
- insecurePassword = null;
- // no need to check any more values for this attribute
- break;
- }
- else if (insecurePassword == null)
- {
- insecurePassword = v;
- }
- }
- catch (DirectoryException e)
+ if (scheme.isStorageSchemeSecure())
{
- if (logger.isTraceEnabled())
- {
- logger.trace("Encoded password " + v + " cannot be decoded and cannot be added to history.");
- }
+ addPasswordToHistory(v.toString());
+ insecurePassword = null;
+ // no need to check any more values for this attribute
+ break;
+ }
+ else if (insecurePassword == null)
+ {
+ insecurePassword = v;
}
}
- // If we get here we haven't found a password encoded securely, so we have to use one of the other values.
- if (insecurePassword != null)
+ catch (DirectoryException e)
{
- addPasswordToHistory(insecurePassword.toString());
+ if (logger.isTraceEnabled())
+ {
+ logger.trace("Encoded password " + v + " cannot be decoded and cannot be added to history.");
+ }
}
}
+ // If we get here we haven't found a password encoded securely, so we have to use one of the
+ // other values.
+ if (insecurePassword != null)
+ {
+ addPasswordToHistory(insecurePassword.toString());
+ }
}
}
@@ -2926,18 +2898,13 @@
{
ArrayList<String> historyValues = new ArrayList<>();
AttributeType historyType = DirectoryServer.getAttributeTypeOrDefault(OP_ATTR_PWPOLICY_HISTORY_LC);
- List<Attribute> attrList = userEntry.getAttribute(historyType);
- if (attrList != null)
+ for (Attribute a : userEntry.getAttribute(historyType))
{
- for (Attribute a : attrList)
+ for (ByteString v : a)
{
- for (ByteString v : a)
- {
- historyValues.add(v.toString());
- }
+ historyValues.add(v.toString());
}
}
-
return historyValues.toArray(new String[historyValues.size()]);
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/core/SchemaConfigManager.java b/opendj-server-legacy/src/main/java/org/opends/server/core/SchemaConfigManager.java
index b52c69e..a0464ba 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/core/SchemaConfigManager.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/core/SchemaConfigManager.java
@@ -590,12 +590,9 @@
List<Modification> mods, AttributeType attrType)
{
List<Attribute> attributes = entry.getAttribute(attrType);
- if (attributes != null && !attributes.isEmpty())
+ for (Attribute a : attributes)
{
- for (Attribute a : attributes)
- {
- mods.add(new Modification(ModificationType.ADD, a));
- }
+ mods.add(new Modification(ModificationType.ADD, a));
}
return attributes;
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/core/SubentryPasswordPolicy.java b/opendj-server-legacy/src/main/java/org/opends/server/core/SubentryPasswordPolicy.java
index a7e31dc..204130b 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/core/SubentryPasswordPolicy.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/core/SubentryPasswordPolicy.java
@@ -35,17 +35,17 @@
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.LocalizableMessageBuilder;
-import org.opends.server.admin.std.meta.PasswordPolicyCfgDefn.*;
+import org.forgerock.i18n.slf4j.LocalizedLogger;
+import org.forgerock.opendj.config.server.ConfigException;
+import org.forgerock.opendj.ldap.ByteString;
+import org.forgerock.opendj.ldap.ResultCode;
+import org.opends.server.admin.std.meta.PasswordPolicyCfgDefn.StateUpdateFailurePolicy;
import org.opends.server.admin.std.server.PasswordValidatorCfg;
import org.opends.server.api.AccountStatusNotificationHandler;
import org.opends.server.api.PasswordGenerator;
import org.opends.server.api.PasswordStorageScheme;
import org.opends.server.api.PasswordValidator;
-import org.forgerock.i18n.slf4j.LocalizedLogger;
-import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.types.*;
-import org.forgerock.opendj.ldap.ResultCode;
-import org.forgerock.opendj.ldap.ByteString;
/**
* This class represents subentry password policy based on Password Policy for
@@ -249,21 +249,17 @@
{
AttributeType pwdAttrType =
DirectoryServer.getAttributeTypeOrDefault(PWD_ATTR_VALIDATOR);
- List<Attribute> pwdAttrList = entry.getAttribute(pwdAttrType);
- if (pwdAttrList != null && !pwdAttrList.isEmpty())
+ for (Attribute attr : entry.getAttribute(pwdAttrType))
{
- for (Attribute attr : pwdAttrList)
+ for (ByteString val : attr)
{
- for (ByteString val : attr)
+ DN validatorDN = DN.decode(val);
+ if (DirectoryServer.getPasswordValidator(validatorDN) == null)
{
- DN validatorDN = DN.decode(val);
- if (DirectoryServer.getPasswordValidator(validatorDN) == null)
- {
- throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION,
- ERR_PWPOLICY_UNKNOWN_VALIDATOR.get(this.passwordPolicySubentryDN, validatorDN, PWD_ATTR_VALIDATOR));
- }
- pValidatorNames.add(validatorDN);
+ throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION,
+ ERR_PWPOLICY_UNKNOWN_VALIDATOR.get(this.passwordPolicySubentryDN, validatorDN, PWD_ATTR_VALIDATOR));
}
+ pValidatorNames.add(validatorDN);
}
}
}
@@ -376,42 +372,34 @@
private String getAttrValue(Entry entry, String pwdAttrName)
{
AttributeType pwdAttrType = DirectoryServer.getAttributeTypeOrDefault(pwdAttrName);
- List<Attribute> pwdAttrList = entry.getAttribute(pwdAttrType);
- if (pwdAttrList != null && !pwdAttrList.isEmpty())
+ for (Attribute attr : entry.getAttribute(pwdAttrType))
{
- for (Attribute attr : pwdAttrList)
+ for (ByteString value : attr)
{
- for (ByteString value : attr)
- {
- return value.toString();
- }
+ return value.toString();
}
}
return null;
}
- /** {@inheritDoc} */
@Override
public boolean isAllowExpiredPasswordChanges()
{
return getDefaultPasswordPolicy().isAllowExpiredPasswordChanges();
}
- /** {@inheritDoc} */
@Override
public boolean isAllowMultiplePasswordValues()
{
return getDefaultPasswordPolicy().isAllowMultiplePasswordValues();
}
- /** {@inheritDoc} */
@Override
public boolean isAllowPreEncodedPasswords()
{
return getDefaultPasswordPolicy().isAllowPreEncodedPasswords();
}
- /** {@inheritDoc} */
@Override
public boolean isAllowUserPasswordChanges()
{
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/crypto/CryptoManagerSync.java b/opendj-server-legacy/src/main/java/org/opends/server/crypto/CryptoManagerSync.java
index 3fd5e14..6275c01 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/crypto/CryptoManagerSync.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/crypto/CryptoManagerSync.java
@@ -56,7 +56,6 @@
import org.opends.server.core.AddOperation;
import org.opends.server.core.DeleteOperation;
import org.opends.server.core.DirectoryServer;
-import org.opends.server.protocols.internal.InternalClientConnection;
import org.opends.server.protocols.internal.InternalSearchOperation;
import org.opends.server.protocols.internal.SearchRequest;
import org.opends.server.protocols.ldap.LDAPControl;
@@ -219,8 +218,6 @@
}
}
-
- /** {@inheritDoc} */
@Override
public void performBackendPreInitializationProcessing(Backend<?> backend)
{
@@ -237,7 +234,6 @@
}
}
- /** {@inheritDoc} */
@Override
public void performBackendPostFinalizationProcessing(Backend<?> backend)
{
@@ -366,25 +362,10 @@
List<Attribute> dstList = dstEntry.getAttribute(attrCert);
// Check for changes to the certificate value.
- boolean differ = false;
- if (srcList == null)
+ if (!srcList.equals(dstList))
{
- if (dstList != null)
- {
- differ = true;
- }
- }
- else if (dstList == null
- || srcList.size() != dstList.size()
- || !srcList.equals(dstList))
- {
- differ = true;
- }
-
- if (differ)
- {
- // The trust store backend does not implement modify so we need to
- // delete then add.
+ // The trust store backend does not implement modify so we need to delete then add.
+ // FIXME implement TrustStoreBackend.replaceEntry() as deleteEntry() + addEntry() and stop this madness
DN dstDN = dstEntry.getName();
deleteEntry(dstDN);
addEntry(srcEntry, dstDN);
@@ -398,11 +379,7 @@
*/
private static void deleteEntry(DN dstDN)
{
- InternalClientConnection conn =
- InternalClientConnection.getRootConnection();
-
- DeleteOperation delOperation = conn.processDelete(dstDN);
-
+ DeleteOperation delOperation = getRootConnection().processDelete(dstDN);
if (delOperation.getResultCode() != ResultCode.SUCCESS)
{
logger.debug(INFO_TRUSTSTORESYNC_DELETE_FAILED, dstDN, delOperation.getErrorMessage());
@@ -425,29 +402,24 @@
List<Attribute> attrList;
attrList = srcEntry.getAttribute(attrAlias);
- if (attrList != null)
+ if (!attrList.isEmpty())
{
userAttrs.put(attrAlias, attrList);
}
attrList = srcEntry.getAttribute(attrCert);
- if (attrList != null)
+ if (!attrList.isEmpty())
{
userAttrs.put(attrCert, attrList);
}
Entry addEntry = new Entry(dstDN, ocMap, userAttrs, null);
-
- InternalClientConnection conn =
- InternalClientConnection.getRootConnection();
-
- AddOperation addOperation = conn.processAdd(addEntry);
+ AddOperation addOperation = getRootConnection().processAdd(addEntry);
if (addOperation.getResultCode() != ResultCode.SUCCESS)
{
logger.debug(INFO_TRUSTSTORESYNC_ADD_FAILED, dstDN, addOperation.getErrorMessage());
}
}
- /** {@inheritDoc} */
@Override
public PostResponse doPostResponse(PostResponseAddOperation op)
{
@@ -502,7 +474,6 @@
}
}
- /** {@inheritDoc} */
@Override
public PostResponse doPostResponse(PostResponseDeleteOperation op)
{
@@ -527,7 +498,6 @@
return PostResponse.continueOperationProcessing();
}
- /** {@inheritDoc} */
@Override
public PostResponse doPostResponse(PostResponseModifyOperation op)
{
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/extensions/AttributeValuePasswordValidator.java b/opendj-server-legacy/src/main/java/org/opends/server/extensions/AttributeValuePasswordValidator.java
index 7e23367..aad917e 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/extensions/AttributeValuePasswordValidator.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/extensions/AttributeValuePasswordValidator.java
@@ -135,10 +135,9 @@
AttributeValuePasswordValidatorCfg config = currentConfig;
- // Get the string representation (both forward and reversed) for the
- // password.
- String password = newPassword.toString();
- String reversed = new StringBuilder(password).reverse().toString();
+ // Get the string representation (both forward and reversed) for the password.
+ final String password = newPassword.toString();
+ final String reversed = new StringBuilder(password).reverse().toString();
// Check to see if we should verify the whole password or the substrings.
int minSubstringLength = password.length();
@@ -158,18 +157,11 @@
matchAttributes = userEntry.getUserAttributes().keySet();
}
+ final ByteString vf = ByteString.valueOfUtf8(password);
+ final ByteString vr = ByteString.valueOfUtf8(reversed);
for (AttributeType t : matchAttributes)
{
- List<Attribute> attrList = userEntry.getAttribute(t);
- if (attrList == null || attrList.isEmpty())
- {
- continue;
- }
-
- ByteString vf = ByteString.valueOfUtf8(password);
- ByteString vr = ByteString.valueOfUtf8(reversed);
-
- for (Attribute a : attrList)
+ for (Attribute a : userEntry.getAttribute(t))
{
if (a.contains(vf) ||
(config.isTestReversedPassword() && a.contains(vr)) ||
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/extensions/DynamicGroup.java b/opendj-server-legacy/src/main/java/org/opends/server/extensions/DynamicGroup.java
index 5a26817..2d7adec 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/extensions/DynamicGroup.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/extensions/DynamicGroup.java
@@ -26,8 +26,6 @@
*/
package org.opends.server.extensions;
-
-
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedHashSet;
@@ -35,32 +33,30 @@
import java.util.Set;
import org.forgerock.i18n.LocalizableMessage;
+import org.forgerock.i18n.slf4j.LocalizedLogger;
+import org.forgerock.opendj.config.server.ConfigException;
+import org.forgerock.opendj.ldap.ByteString;
+import org.forgerock.opendj.ldap.SearchScope;
import org.opends.server.admin.std.server.DynamicGroupImplementationCfg;
import org.opends.server.api.Group;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.ServerContext;
-import org.forgerock.opendj.config.server.ConfigException;
-import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
-import org.forgerock.opendj.ldap.ByteString;
+import org.opends.server.types.DN;
import org.opends.server.types.DirectoryConfig;
import org.opends.server.types.DirectoryException;
-import org.opends.server.types.DN;
import org.opends.server.types.Entry;
import org.opends.server.types.InitializationException;
import org.opends.server.types.LDAPURL;
import org.opends.server.types.MemberList;
import org.opends.server.types.ObjectClass;
import org.opends.server.types.SearchFilter;
-import org.forgerock.opendj.ldap.SearchScope;
+import static org.forgerock.util.Reject.*;
import static org.opends.messages.ExtensionMessages.*;
import static org.opends.server.config.ConfigConstants.*;
import static org.opends.server.util.ServerConstants.*;
-import static org.forgerock.util.Reject.*;
-
-
/**
* This class provides a dynamic group implementation, in which
@@ -140,23 +136,18 @@
// out the LDAP URLs that it contains.
LinkedHashSet<LDAPURL> memberURLs = new LinkedHashSet<>();
AttributeType memberURLType = DirectoryServer.getAttributeTypeOrDefault(ATTR_MEMBER_URL_LC);
- List<Attribute> attrList = groupEntry.getAttribute(memberURLType);
- if (attrList != null)
+ for (Attribute a : groupEntry.getAttribute(memberURLType))
{
- for (Attribute a : attrList)
+ for (ByteString v : a)
{
- for (ByteString v : a)
+ try
{
- try
- {
- memberURLs.add(LDAPURL.decode(v.toString(), true));
- }
- catch (DirectoryException de)
- {
- logger.traceException(de);
- logger.error(ERR_DYNAMICGROUP_CANNOT_DECODE_MEMBERURL, v,
- groupEntry.getName(), de.getMessageObject());
- }
+ memberURLs.add(LDAPURL.decode(v.toString(), true));
+ }
+ catch (DirectoryException de)
+ {
+ logger.traceException(de);
+ logger.error(ERR_DYNAMICGROUP_CANNOT_DECODE_MEMBERURL, v, groupEntry.getName(), de.getMessageObject());
}
}
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/extensions/ExternalSASLMechanismHandler.java b/opendj-server-legacy/src/main/java/org/opends/server/extensions/ExternalSASLMechanismHandler.java
index 955a068..d0bd85a 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/extensions/ExternalSASLMechanismHandler.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/extensions/ExternalSASLMechanismHandler.java
@@ -30,21 +30,22 @@
import java.util.List;
import org.forgerock.i18n.LocalizableMessage;
+import org.forgerock.i18n.slf4j.LocalizedLogger;
+import org.forgerock.opendj.config.server.ConfigChangeResult;
+import org.forgerock.opendj.config.server.ConfigException;
+import org.forgerock.opendj.ldap.ByteString;
+import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.admin.server.ConfigurationChangeListener;
import org.opends.server.admin.std.server.ExternalSASLMechanismHandlerCfg;
import org.opends.server.admin.std.server.SASLMechanismHandlerCfg;
import org.opends.server.api.CertificateMapper;
import org.opends.server.api.ClientConnection;
import org.opends.server.api.SASLMechanismHandler;
-import org.forgerock.opendj.config.server.ConfigChangeResult;
-import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.core.BindOperation;
import org.opends.server.core.DirectoryServer;
-import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.opends.server.protocols.ldap.LDAPClientConnection;
import org.opends.server.types.*;
-import org.forgerock.opendj.ldap.ResultCode;
-import org.forgerock.opendj.ldap.ByteString;
+
import static org.opends.messages.ExtensionMessages.*;
import static org.opends.server.config.ConfigConstants.*;
import static org.opends.server.util.ServerConstants.*;
@@ -212,20 +213,17 @@
bindOperation.setAuthFailureReason(message);
return;
}
- else
- {
- bindOperation.setSASLAuthUserEntry(userEntry);
- }
+
+ bindOperation.setSASLAuthUserEntry(userEntry);
// Get the userCertificate attribute from the user's entry for use in the
// validation process.
- List<Attribute> certAttrList =
- userEntry.getAttribute(certificateAttributeType);
+ List<Attribute> certAttrList = userEntry.getAttribute(certificateAttributeType);
switch (validationPolicy)
{
case ALWAYS:
- if (certAttrList == null)
+ if (certAttrList.isEmpty())
{
if (validationPolicy == CertificateValidationPolicy.ALWAYS)
{
@@ -265,7 +263,7 @@
break;
case IFPRESENT:
- if (certAttrList != null)
+ if (!certAttrList.isEmpty())
{
try
{
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/extensions/LDAPPassThroughAuthenticationPolicyFactory.java b/opendj-server-legacy/src/main/java/org/opends/server/extensions/LDAPPassThroughAuthenticationPolicyFactory.java
index d7a2f65..7f9d093 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/extensions/LDAPPassThroughAuthenticationPolicyFactory.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/extensions/LDAPPassThroughAuthenticationPolicyFactory.java
@@ -39,8 +39,11 @@
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.LocalizedIllegalArgumentException;
import org.forgerock.i18n.slf4j.LocalizedLogger;
+import org.forgerock.opendj.config.server.ConfigChangeResult;
+import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.DecodeException;
+import org.forgerock.opendj.ldap.DereferenceAliasesPolicy;
import org.forgerock.opendj.ldap.GeneralizedTime;
import org.forgerock.opendj.ldap.ModificationType;
import org.forgerock.opendj.ldap.ResultCode;
@@ -54,7 +57,6 @@
import org.opends.server.api.DirectoryThread;
import org.opends.server.api.PasswordStorageScheme;
import org.opends.server.api.TrustManagerProvider;
-import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.ModifyOperation;
import org.opends.server.core.ServerContext;
@@ -66,8 +68,6 @@
import org.opends.server.tools.LDAPWriter;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
-import org.forgerock.opendj.config.server.ConfigChangeResult;
-import org.forgerock.opendj.ldap.DereferenceAliasesPolicy;
import org.opends.server.types.DN;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.Entry;
@@ -1611,16 +1611,12 @@
// The bind DN is contained in an attribute in the user's entry.
mapBind: for (final AttributeType at : cfg.getMappedAttribute())
{
- final List<Attribute> attributes = userEntry.getAttribute(at);
- if (attributes != null && !attributes.isEmpty())
+ for (final Attribute attribute : userEntry.getAttribute(at))
{
- for (final Attribute attribute : attributes)
+ if (!attribute.isEmpty())
{
- if (!attribute.isEmpty())
- {
- username = attribute.iterator().next();
- break mapBind;
- }
+ username = attribute.iterator().next();
+ break mapBind;
}
}
}
@@ -1648,16 +1644,11 @@
final LinkedList<SearchFilter> filterComponents = new LinkedList<>();
for (final AttributeType at : cfg.getMappedAttribute())
{
- final List<Attribute> attributes = userEntry.getAttribute(at);
- if (attributes != null && !attributes.isEmpty())
+ for (final Attribute attribute : userEntry.getAttribute(at))
{
- for (final Attribute attribute : attributes)
+ for (final ByteString value : attribute)
{
- for (final ByteString value : attribute)
- {
- filterComponents.add(SearchFilter.createEqualityFilter(at,
- value));
- }
+ filterComponents.add(SearchFilter.createEqualityFilter(at, value));
}
}
}
@@ -1739,10 +1730,8 @@
}
// Now perform the bind.
- Connection connection = null;
- try
+ try (Connection connection = bindFactory.getConnection())
{
- connection = bindFactory.getConnection();
connection.simpleBind(username, password);
// The password matched, so cache it, it will be stored in the
@@ -1767,10 +1756,6 @@
userEntry.getName(), cfg.dn(), e.getMessageObject()), e);
}
}
- finally
- {
- StaticUtils.close(connection);
- }
}
finally
{
@@ -1790,34 +1775,27 @@
// First determine if the cached password time is present and valid.
boolean foundValidCachedPasswordTime = false;
- List<Attribute> cptlist = userEntry
- .getAttribute(cachedPasswordTimeAttribute);
- if (cptlist != null && !cptlist.isEmpty())
+ foundCachedPasswordTime:
+ for (Attribute attribute : userEntry.getAttribute(cachedPasswordTimeAttribute))
{
- foundCachedPasswordTime:
+ // Ignore any attributes with options.
+ if (!attribute.hasOptions())
{
- for (Attribute attribute : cptlist)
+ for (ByteString value : attribute)
{
- // Ignore any attributes with options.
- if (!attribute.hasOptions())
+ try
{
- for (ByteString value : attribute)
- {
- try
- {
- long cachedPasswordTime = GeneralizedTime.valueOf(value.toString()).getTimeInMillis();
- long currentTime = provider.getCurrentTimeMS();
- long expiryTime = cachedPasswordTime + (cfg.getCachedPasswordTTL() * 1000);
- foundValidCachedPasswordTime = expiryTime > currentTime;
- }
- catch (LocalizedIllegalArgumentException e)
- {
- // Fall-through and give up immediately.
- logger.traceException(e);
- }
- break foundCachedPasswordTime;
- }
+ long cachedPasswordTime = GeneralizedTime.valueOf(value.toString()).getTimeInMillis();
+ long currentTime = provider.getCurrentTimeMS();
+ long expiryTime = cachedPasswordTime + (cfg.getCachedPasswordTTL() * 1000);
+ foundValidCachedPasswordTime = expiryTime > currentTime;
}
+ catch (LocalizedIllegalArgumentException e)
+ {
+ // Fall-through and give up immediately.
+ logger.traceException(e);
+ }
+ break foundCachedPasswordTime;
}
}
}
@@ -1831,24 +1809,16 @@
// Next determine if there is a cached password.
ByteString cachedPassword = null;
-
- List<Attribute> cplist = userEntry
- .getAttribute(cachedPasswordAttribute);
- if (cplist != null && !cplist.isEmpty())
+ foundCachedPassword:
+ for (Attribute attribute : userEntry.getAttribute(cachedPasswordAttribute))
{
- foundCachedPassword:
+ // Ignore any attributes with options.
+ if (!attribute.hasOptions())
{
- for (Attribute attribute : cplist)
+ for (ByteString value : attribute)
{
- // Ignore any attributes with options.
- if (!attribute.hasOptions())
- {
- for (ByteString value : attribute)
- {
- cachedPassword = value;
- break foundCachedPassword;
- }
- }
+ cachedPassword = value;
+ break foundCachedPassword;
}
}
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/extensions/SMTPAccountStatusNotificationHandler.java b/opendj-server-legacy/src/main/java/org/opends/server/extensions/SMTPAccountStatusNotificationHandler.java
index c26e056..2eb658e 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/extensions/SMTPAccountStatusNotificationHandler.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/extensions/SMTPAccountStatusNotificationHandler.java
@@ -42,6 +42,7 @@
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.LocalizableMessageBuilder;
import org.forgerock.i18n.slf4j.LocalizedLogger;
+import org.forgerock.opendj.config.server.ConfigChangeResult;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ResultCode;
@@ -56,7 +57,6 @@
import org.opends.server.types.AccountStatusNotificationType;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
-import org.forgerock.opendj.config.server.ConfigChangeResult;
import org.opends.server.types.Entry;
import org.opends.server.types.InitializationException;
import org.opends.server.util.EMailMessage;
@@ -524,21 +524,13 @@
Entry userEntry = notification.getUserEntry();
for (AttributeType t : addressAttrs)
{
- List<Attribute> attrList = userEntry.getAttribute(t);
- if (attrList != null)
+ for (Attribute a : userEntry.getAttribute(t))
{
- for (Attribute a : attrList)
+ for (ByteString v : a)
{
- for (ByteString v : a)
- {
- if (logger.isTraceEnabled())
- {
- logger.trace("Adding end user recipient %s from attr %s",
- v, a.getNameWithOptions());
- }
+ logger.trace("Adding end user recipient %s from attr %s", v, a.getNameWithOptions());
- recipients.add(v.toString());
- }
+ recipients.add(v.toString());
}
}
}
@@ -549,12 +541,7 @@
{
// There are no recipients at all, so there's no point in generating
// the message. Return without doing anything.
- if (logger.isTraceEnabled())
- {
- logger.trace("No end user recipients, and no explicit " +
- "recipients");
- }
-
+ logger.trace("No end user recipients, and no explicit recipients");
return;
}
else
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/extensions/StaticGroup.java b/opendj-server-legacy/src/main/java/org/opends/server/extensions/StaticGroup.java
index cffd849..404610b 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/extensions/StaticGroup.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/extensions/StaticGroup.java
@@ -64,12 +64,12 @@
import org.opends.server.types.Modification;
import org.opends.server.types.SearchFilter;
+import static org.forgerock.util.Reject.*;
import static org.opends.messages.ExtensionMessages.*;
import static org.opends.server.core.DirectoryServer.*;
import static org.opends.server.protocols.internal.InternalClientConnection.*;
import static org.opends.server.util.CollectionUtils.*;
import static org.opends.server.util.ServerConstants.*;
-import static org.forgerock.util.Reject.*;
/**
* A static group implementation, in which the DNs of all members are explicitly
@@ -198,30 +198,24 @@
List<Attribute> memberAttrList = groupEntry.getAttribute(someMemberAttributeType);
int membersCount = 0;
- if (memberAttrList != null)
+ for (Attribute a : memberAttrList)
{
- for (Attribute a : memberAttrList)
- {
- membersCount += a.size();
- }
+ membersCount += a.size();
}
LinkedHashSet<CompactDn> someMemberDNs = new LinkedHashSet<>(membersCount);
- if (memberAttrList != null)
+ for (Attribute a : memberAttrList)
{
- for (Attribute a : memberAttrList)
+ for (ByteString v : a)
{
- for (ByteString v : a)
+ try
{
- try
- {
- someMemberDNs.add(org.forgerock.opendj.ldap.DN.valueOf(v.toString()).compact());
- }
- catch (LocalizedIllegalArgumentException e)
- {
- logger.traceException(e);
- logger.error(ERR_STATICGROUP_CANNOT_DECODE_MEMBER_VALUE_AS_DN, v,
- someMemberAttributeType.getNameOrOID(), groupEntry.getName(), e.getMessageObject());
- }
+ someMemberDNs.add(org.forgerock.opendj.ldap.DN.valueOf(v.toString()).compact());
+ }
+ catch (LocalizedIllegalArgumentException e)
+ {
+ logger.traceException(e);
+ logger.error(ERR_STATICGROUP_CANNOT_DECODE_MEMBER_VALUE_AS_DN,
+ v, someMemberAttributeType.getNameOrOID(), groupEntry.getName(), e.getMessageObject());
}
}
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/extensions/UserAttributeNotificationMessageTemplateElement.java b/opendj-server-legacy/src/main/java/org/opends/server/extensions/UserAttributeNotificationMessageTemplateElement.java
index aa2993d..7622dbb 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/extensions/UserAttributeNotificationMessageTemplateElement.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/extensions/UserAttributeNotificationMessageTemplateElement.java
@@ -26,19 +26,13 @@
*/
package org.opends.server.extensions;
-
-
-import java.util.List;
-
import org.forgerock.i18n.LocalizableMessageBuilder;
+import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.types.AccountStatusNotification;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
-import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.types.Entry;
-
-
/**
* This class implements a notification message template element that will
* generate a value that is the value of a specified attribute from the target
@@ -50,39 +44,28 @@
/** The attribute type for which to obtain the value. */
private AttributeType attributeType;
-
-
/**
* Creates a new user DN notification message template element.
*
* @param attributeType The attribute type for which to obtain the value.
*/
- public UserAttributeNotificationMessageTemplateElement(AttributeType
- attributeType)
+ public UserAttributeNotificationMessageTemplateElement(AttributeType attributeType)
{
this.attributeType = attributeType;
}
-
-
- /** {@inheritDoc} */
+ @Override
public void generateValue(LocalizableMessageBuilder buffer,
AccountStatusNotification notification)
{
Entry userEntry = notification.getUserEntry();
-
- List<Attribute> attrList = userEntry.getAttribute(attributeType);
- if (attrList != null)
+ for (Attribute a : userEntry.getAttribute(attributeType))
{
- for (Attribute a : attrList)
+ for (ByteString v : a)
{
- for (ByteString v : a)
- {
- buffer.append(v);
- return;
- }
+ buffer.append(v);
+ return;
}
}
}
}
-
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/extensions/VirtualStaticGroup.java b/opendj-server-legacy/src/main/java/org/opends/server/extensions/VirtualStaticGroup.java
index ad78277..4e75bf9 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/extensions/VirtualStaticGroup.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/extensions/VirtualStaticGroup.java
@@ -26,38 +26,34 @@
*/
package org.opends.server.extensions;
-
-
import java.util.Collections;
import java.util.List;
import java.util.Set;
import org.forgerock.i18n.LocalizableMessage;
+import org.forgerock.i18n.slf4j.LocalizedLogger;
+import org.forgerock.opendj.config.server.ConfigException;
+import org.forgerock.opendj.ldap.ByteString;
+import org.forgerock.opendj.ldap.ResultCode;
+import org.forgerock.opendj.ldap.SearchScope;
import org.opends.server.admin.std.server.VirtualStaticGroupImplementationCfg;
import org.opends.server.api.Group;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.ServerContext;
-import org.forgerock.opendj.config.server.ConfigException;
-import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
-import org.forgerock.opendj.ldap.ByteString;
-import org.opends.server.types.DirectoryException;
import org.opends.server.types.DN;
+import org.opends.server.types.DirectoryException;
import org.opends.server.types.Entry;
import org.opends.server.types.InitializationException;
import org.opends.server.types.MemberList;
import org.opends.server.types.ObjectClass;
-import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.types.SearchFilter;
-import org.forgerock.opendj.ldap.SearchScope;
+import static org.forgerock.util.Reject.*;
import static org.opends.messages.ExtensionMessages.*;
import static org.opends.server.config.ConfigConstants.*;
import static org.opends.server.util.ServerConstants.*;
-import static org.forgerock.util.Reject.*;
-
-
/**
* This class provides a virtual static group implementation, in which
@@ -133,32 +129,27 @@
// Get the target group DN attribute from the entry, if there is one.
DN targetDN = null;
AttributeType targetType = DirectoryServer.getAttributeTypeOrDefault(ATTR_TARGET_GROUP_DN);
- List<Attribute> attrList = groupEntry.getAttribute(targetType);
- if (attrList != null)
+ for (Attribute a : groupEntry.getAttribute(targetType))
{
- for (Attribute a : attrList)
+ for (ByteString v : a)
{
- for (ByteString v : a)
+ if (targetDN != null)
{
- if (targetDN != null)
- {
- LocalizableMessage message = ERR_VIRTUAL_STATIC_GROUP_MULTIPLE_TARGETS.get(groupEntry.getName());
- throw new DirectoryException(ResultCode.OBJECTCLASS_VIOLATION, message);
- }
+ LocalizableMessage message = ERR_VIRTUAL_STATIC_GROUP_MULTIPLE_TARGETS.get(groupEntry.getName());
+ throw new DirectoryException(ResultCode.OBJECTCLASS_VIOLATION, message);
+ }
- try
- {
- targetDN = DN.decode(v);
- }
- catch (DirectoryException de)
- {
- logger.traceException(de);
+ try
+ {
+ targetDN = DN.decode(v);
+ }
+ catch (DirectoryException de)
+ {
+ logger.traceException(de);
- LocalizableMessage message = ERR_VIRTUAL_STATIC_GROUP_CANNOT_DECODE_TARGET.
- get(v, groupEntry.getName(), de.getMessageObject());
- throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
- message, de);
- }
+ LocalizableMessage message = ERR_VIRTUAL_STATIC_GROUP_CANNOT_DECODE_TARGET.
+ get(v, groupEntry.getName(), de.getMessageObject());
+ throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message, de);
}
}
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/plugins/EntryUUIDPlugin.java b/opendj-server-legacy/src/main/java/org/opends/server/plugins/EntryUUIDPlugin.java
index 4a4d47d..f6b4627 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/plugins/EntryUUIDPlugin.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/plugins/EntryUUIDPlugin.java
@@ -147,7 +147,6 @@
- /** {@inheritDoc} */
@Override
public final PluginResult.ImportLDIF
doLDIFImport(LDIFImportConfig importConfig, Entry entry)
@@ -155,7 +154,7 @@
// See if the entry being imported already contains an entryUUID attribute.
// If so, then leave it alone.
List<Attribute> uuidList = entry.getAttribute(entryUUIDType);
- if (uuidList != null)
+ if (!uuidList.isEmpty())
{
return PluginResult.ImportLDIF.continueEntryProcessing();
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/plugins/PasswordPolicyImportPlugin.java b/opendj-server-legacy/src/main/java/org/opends/server/plugins/PasswordPolicyImportPlugin.java
index b634ac9..ed68a00 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/plugins/PasswordPolicyImportPlugin.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/plugins/PasswordPolicyImportPlugin.java
@@ -38,6 +38,11 @@
import java.util.Set;
import org.forgerock.i18n.LocalizableMessage;
+import org.forgerock.i18n.slf4j.LocalizedLogger;
+import org.forgerock.opendj.config.server.ConfigChangeResult;
+import org.forgerock.opendj.config.server.ConfigException;
+import org.forgerock.opendj.ldap.ByteString;
+import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.admin.server.ConfigurationChangeListener;
import org.opends.server.admin.std.meta.PluginCfgDefn;
import org.opends.server.admin.std.server.PasswordPolicyImportPluginCfg;
@@ -49,17 +54,12 @@
import org.opends.server.api.plugin.DirectoryServerPlugin;
import org.opends.server.api.plugin.PluginResult;
import org.opends.server.api.plugin.PluginType;
-import org.forgerock.opendj.config.server.ConfigChangeResult;
-import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.PasswordPolicy;
import org.opends.server.core.SubentryPasswordPolicy;
-import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.opends.server.schema.AuthPasswordSyntax;
import org.opends.server.schema.UserPasswordSyntax;
import org.opends.server.types.*;
-import org.forgerock.opendj.ldap.ResultCode;
-import org.forgerock.opendj.ldap.ByteString;
/**
* This class implements a Directory Server plugin that performs various
@@ -330,7 +330,7 @@
// See if the entry explicitly states the password policy that it should
// use. If so, then only use it to perform the encoding.
List<Attribute> attrList = entry.getAttribute(customPolicyAttribute);
- if (attrList != null)
+ if (!attrList.isEmpty())
{
DN policyDN = null;
PasswordPolicy policy = null;
@@ -369,7 +369,7 @@
if (schemes != null)
{
attrList = entry.getAttribute(policy.getPasswordAttribute());
- if (attrList == null)
+ if (attrList.isEmpty())
{
return PluginResult.ImportLDIF.continueEntryProcessing();
}
@@ -455,7 +455,7 @@
for (AttributeType t : authPasswordTypes)
{
attrList = entry.getAttribute(t);
- if (attrList == null || attrList.isEmpty())
+ if (attrList.isEmpty())
{
continue;
}
@@ -505,7 +505,7 @@
for (AttributeType t : userPasswordTypes)
{
attrList = entry.getAttribute(t);
- if (attrList == null || attrList.isEmpty())
+ if (attrList.isEmpty())
{
continue;
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/plugins/ReferentialIntegrityPlugin.java b/opendj-server-legacy/src/main/java/org/opends/server/plugins/ReferentialIntegrityPlugin.java
index daac73e..a83d606 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/plugins/ReferentialIntegrityPlugin.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/plugins/ReferentialIntegrityPlugin.java
@@ -1107,14 +1107,10 @@
return PluginResult.PreOperation.continueOperationProcessing();
}
- /** {@inheritDoc} */
@Override
- public PluginResult.PreOperation doPreOperation(
- PreOperationAddOperation addOperation)
+ public PluginResult.PreOperation doPreOperation(PreOperationAddOperation addOperation)
{
- /* Skip the integrity checks if the enforcing is not enabled.
- */
-
+ // Skip the integrity checks if the enforcing is not enabled.
if (!currentConfiguration.isCheckReferences())
{
return PluginResult.PreOperation.continueOperationProcessing();
@@ -1122,9 +1118,7 @@
final Entry entry = addOperation.getEntryToAdd();
- /* Make sure the entry belongs to one of the configured naming
- * contexts.
- */
+ // Make sure the entry belongs to one of the configured naming contexts.
DN entryDN = entry.getName();
DN entryBaseDN = getEntryBaseDN(entryDN);
if (entryBaseDN == null)
@@ -1135,20 +1129,13 @@
for (AttributeType attrType : attributeTypes)
{
final List<Attribute> attrs = entry.getAttribute(attrType, false);
-
- if (attrs != null)
+ PluginResult.PreOperation result = isIntegrityMaintained(attrs, entryDN, entryBaseDN);
+ if (result.getResultCode() != ResultCode.SUCCESS)
{
- PluginResult.PreOperation result =
- isIntegrityMaintained(attrs, entryDN, entryBaseDN);
- if (result.getResultCode() != ResultCode.SUCCESS)
- {
- return result;
- }
+ return result;
}
}
- /* If we reahed this point, everything is fine.
- */
return PluginResult.PreOperation.continueOperationProcessing();
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/plugins/SevenBitCleanPlugin.java b/opendj-server-legacy/src/main/java/org/opends/server/plugins/SevenBitCleanPlugin.java
index fbf597d..7d72fef 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/plugins/SevenBitCleanPlugin.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/plugins/SevenBitCleanPlugin.java
@@ -140,19 +140,15 @@
// Make sure all configured attributes have clean values.
for (AttributeType t : config.getAttributeType())
{
- List<Attribute> attrList = entry.getAttribute(t);
- if (attrList != null)
+ for (Attribute a : entry.getAttribute(t))
{
- for (Attribute a : attrList)
+ for (ByteString v : a)
{
- for (ByteString v : a)
+ if (!is7BitClean(v))
{
- if (!is7BitClean(v))
- {
- LocalizableMessage rejectMessage =
- ERR_PLUGIN_7BIT_IMPORT_ATTR_NOT_CLEAN.get(a.getNameWithOptions());
- return PluginResult.ImportLDIF.stopEntryProcessing(rejectMessage);
- }
+ LocalizableMessage rejectMessage =
+ ERR_PLUGIN_7BIT_IMPORT_ATTR_NOT_CLEAN.get(a.getNameWithOptions());
+ return PluginResult.ImportLDIF.stopEntryProcessing(rejectMessage);
}
}
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/plugins/UniqueAttributePlugin.java b/opendj-server-legacy/src/main/java/org/opends/server/plugins/UniqueAttributePlugin.java
index 0ade8cd..30c10aa 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/plugins/UniqueAttributePlugin.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/plugins/UniqueAttributePlugin.java
@@ -42,20 +42,22 @@
import org.opends.server.admin.std.server.UniqueAttributePluginCfg;
import org.opends.server.api.AlertGenerator;
import org.opends.server.api.Backend;
-import org.opends.server.api.plugin.*;
+import org.opends.server.api.plugin.DirectoryServerPlugin;
+import org.opends.server.api.plugin.PluginResult;
import org.opends.server.api.plugin.PluginResult.PostOperation;
import org.opends.server.api.plugin.PluginResult.PreOperation;
+import org.opends.server.api.plugin.PluginType;
import org.opends.server.core.DirectoryServer;
import org.opends.server.protocols.internal.InternalClientConnection;
import org.opends.server.protocols.internal.InternalSearchOperation;
import org.opends.server.protocols.internal.SearchRequest;
-import static org.opends.server.protocols.internal.Requests.*;
import org.opends.server.schema.SchemaConstants;
import org.opends.server.types.*;
import org.opends.server.types.operation.*;
import static org.opends.messages.PluginMessages.*;
import static org.opends.server.protocols.internal.InternalClientConnection.*;
+import static org.opends.server.protocols.internal.Requests.*;
import static org.opends.server.util.ServerConstants.*;
/**
@@ -189,19 +191,14 @@
List<ByteString> recordedValues = new LinkedList<>();
for (AttributeType t : config.getType())
{
- List<Attribute> attrList = entry.getAttribute(t);
- if (attrList != null)
+ for (Attribute a : entry.getAttribute(t))
{
- for (Attribute a : attrList)
+ for (ByteString v : a)
{
- for (ByteString v : a)
+ PreOperation stop = checkUniqueness(entryDN, t, v, baseDNs, recordedValues, config);
+ if (stop != null)
{
- PreOperation stop =
- checkUniqueness(entryDN, t, v, baseDNs, recordedValues, config);
- if (stop != null)
- {
- return stop;
- }
+ return stop;
}
}
}
@@ -254,28 +251,20 @@
break;
case INCREMENT:
- // We could calculate the new value, but we'll just take it from the
- // updated entry.
- List<Attribute> attrList =
- modifyOperation.getModifiedEntry().getAttribute(t,
- a.getOptions());
- if (attrList != null)
+ // We could calculate the new value, but we'll just take it from the updated entry.
+ for (Attribute updatedAttr : modifyOperation.getModifiedEntry().getAttribute(t, a.getOptions()))
{
- for (Attribute updatedAttr : attrList)
+ if (! updatedAttr.optionsEqual(a.getOptions()))
{
- if (! updatedAttr.optionsEqual(a.getOptions()))
- {
- continue;
- }
+ continue;
+ }
- for (ByteString v : updatedAttr)
+ for (ByteString v : updatedAttr)
+ {
+ PreOperation stop = checkUniqueness(entryDN, t, v, baseDNs, recordedValues, config);
+ if (stop != null)
{
- PreOperation stop = checkUniqueness(
- entryDN, t, v, baseDNs, recordedValues, config);
- if (stop != null)
- {
- return stop;
- }
+ return stop;
}
}
}
@@ -402,16 +391,11 @@
DN entryDN = entry.getName();
for (AttributeType t : config.getType())
{
- List<Attribute> attrList = entry.getAttribute(t);
- if (attrList != null)
+ for (Attribute a : entry.getAttribute(t))
{
- for (Attribute a : attrList)
+ for (ByteString v : a)
{
- for (ByteString v : a)
- {
- sendAlertForUnresolvedConflict(addOperation, entryDN, entryDN, t,
- v, baseDNs, config);
- }
+ sendAlertForUnresolvedConflict(addOperation, entryDN, entryDN, t, v, baseDNs, config);
}
}
}
@@ -456,25 +440,18 @@
break;
case INCREMENT:
- // We could calculate the new value, but we'll just take it from the
- // updated entry.
- List<Attribute> attrList =
- modifyOperation.getModifiedEntry().getAttribute(t,
- a.getOptions());
- if (attrList != null)
+ // We could calculate the new value, but we'll just take it from the updated entry.
+ for (Attribute updatedAttr : modifyOperation.getModifiedEntry().getAttribute(t, a.getOptions()))
{
- for (Attribute updatedAttr : attrList)
+ if (! updatedAttr.optionsEqual(a.getOptions()))
{
- if (! updatedAttr.optionsEqual(a.getOptions()))
- {
- continue;
- }
+ continue;
+ }
- for (ByteString v : updatedAttr)
- {
- sendAlertForUnresolvedConflict(modifyOperation, entryDN,
- entryDN, t, v, baseDNs, config);
- }
+ for (ByteString v : updatedAttr)
+ {
+ sendAlertForUnresolvedConflict(modifyOperation, entryDN,
+ entryDN, t, v, baseDNs, config);
}
}
break;
@@ -803,15 +780,11 @@
//Remove the attribute value from the map.
for (AttributeType t : config.getType())
{
- List<Attribute> attrList = entry.getAttribute(t);
- if (attrList != null)
+ for (Attribute a : entry.getAttribute(t))
{
- for (Attribute a : attrList)
+ for (ByteString v : a)
{
- for (ByteString v : a)
- {
- uniqueAttrValue2Dn.remove(v);
- }
+ uniqueAttrValue2Dn.remove(v);
}
}
}
@@ -858,24 +831,17 @@
break;
case INCREMENT:
- // We could calculate the new value, but we'll just take it from the
- // updated entry.
- List<Attribute> attrList =
- modifyOperation.getModifiedEntry().getAttribute(t,
- a.getOptions());
- if (attrList != null)
+ // We could calculate the new value, but we'll just take it from the updated entry.
+ for (Attribute updatedAttr : modifyOperation.getModifiedEntry().getAttribute(t, a.getOptions()))
{
- for (Attribute updatedAttr : attrList)
+ if (!updatedAttr.optionsEqual(a.getOptions()))
{
- if (! updatedAttr.optionsEqual(a.getOptions()))
- {
- continue;
- }
+ continue;
+ }
- for (ByteString v : updatedAttr)
- {
- uniqueAttrValue2Dn.remove(v);
- }
+ for (ByteString v : updatedAttr)
+ {
+ uniqueAttrValue2Dn.remove(v);
}
}
break;
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/EntryHistorical.java b/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/EntryHistorical.java
index 9b5e326..cabb3df 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/EntryHistorical.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/EntryHistorical.java
@@ -518,7 +518,7 @@
// Now we'll build the Historical object we want to construct
final EntryHistorical newHistorical = new EntryHistorical();
- if (histAttrWithOptionsFromEntry == null)
+ if (histAttrWithOptionsFromEntry.isEmpty())
{
// No historical attribute in the entry, return empty object
return newHistorical;
@@ -607,48 +607,43 @@
public static Iterable<FakeOperation> generateFakeOperations(Entry entry)
{
TreeMap<CSN, FakeOperation> operations = new TreeMap<>();
- List<Attribute> attrs = getHistoricalAttr(entry);
- if (attrs != null)
+ for (Attribute attr : getHistoricalAttr(entry))
{
- for (Attribute attr : attrs)
+ for (ByteString val : attr)
{
- for (ByteString val : attr)
+ HistoricalAttributeValue histVal = new HistoricalAttributeValue(val.toString());
+ if (histVal.isADDOperation())
{
- HistoricalAttributeValue histVal = new HistoricalAttributeValue(val.toString());
- if (histVal.isADDOperation())
+ // Found some historical information indicating that this entry was just added.
+ // Create the corresponding ADD operation.
+ operations.put(histVal.getCSN(), new FakeAddOperation(histVal.getCSN(), entry));
+ }
+ else if (histVal.isMODDNOperation())
+ {
+ // Found some historical information indicating that this entry was just renamed.
+ // Create the corresponding ADD operation.
+ operations.put(histVal.getCSN(), new FakeModdnOperation(histVal.getCSN(), entry));
+ }
+ else
+ {
+ // Found some historical information for modify operation.
+ // Generate the corresponding ModifyOperation or update
+ // the already generated Operation if it can be found.
+ CSN csn = histVal.getCSN();
+ Modification mod = histVal.generateMod();
+ FakeOperation fakeOperation = operations.get(csn);
+
+ if (fakeOperation instanceof FakeModifyOperation)
{
- // Found some historical information indicating that this entry was just added.
- // Create the corresponding ADD operation.
- operations.put(histVal.getCSN(), new FakeAddOperation(histVal.getCSN(), entry));
- }
- else if (histVal.isMODDNOperation())
- {
- // Found some historical information indicating that this entry was just renamed.
- // Create the corresponding ADD operation.
- operations.put(histVal.getCSN(), new FakeModdnOperation(histVal.getCSN(), entry));
+ FakeModifyOperation modifyFakeOperation = (FakeModifyOperation) fakeOperation;
+ modifyFakeOperation.addModification(mod);
}
else
{
- // Found some historical information for modify operation.
- // Generate the corresponding ModifyOperation or update
- // the already generated Operation if it can be found.
- CSN csn = histVal.getCSN();
- Modification mod = histVal.generateMod();
- FakeOperation fakeOperation = operations.get(csn);
-
- if (fakeOperation instanceof FakeModifyOperation)
- {
- FakeModifyOperation modifyFakeOperation = (FakeModifyOperation) fakeOperation;
- modifyFakeOperation.addModification(mod);
- }
- else
- {
- String uuidString = getEntryUUID(entry);
- FakeModifyOperation modifyFakeOperation =
- new FakeModifyOperation(entry.getName(), csn, uuidString);
- modifyFakeOperation.addModification(mod);
- operations.put(histVal.getCSN(), modifyFakeOperation);
- }
+ String uuidString = getEntryUUID(entry);
+ FakeModifyOperation modifyFakeOperation = new FakeModifyOperation(entry.getName(), csn, uuidString);
+ modifyFakeOperation.addModification(mod);
+ operations.put(histVal.getCSN(), modifyFakeOperation);
}
}
}
@@ -747,7 +742,7 @@
*/
private static String extractEntryUUID(List<Attribute> entryUUIDAttributes, DN entryDN)
{
- if (entryUUIDAttributes != null)
+ if (!entryUUIDAttributes.isEmpty())
{
Attribute uuidAttr = entryUUIDAttributes.get(0);
if (!uuidAttr.isEmpty())
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/FractionalLDIFImportPlugin.java b/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/FractionalLDIFImportPlugin.java
index ff39129..248ed02 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/FractionalLDIFImportPlugin.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/FractionalLDIFImportPlugin.java
@@ -29,6 +29,9 @@
import java.util.*;
import org.forgerock.i18n.LocalizableMessage;
+import org.forgerock.opendj.config.server.ConfigChangeResult;
+import org.forgerock.opendj.config.server.ConfigException;
+import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.util.Utils;
import org.opends.server.admin.server.ConfigurationChangeListener;
import org.opends.server.admin.server.ServerManagementContext;
@@ -36,12 +39,11 @@
import org.opends.server.api.plugin.DirectoryServerPlugin;
import org.opends.server.api.plugin.PluginResult;
import org.opends.server.api.plugin.PluginType;
-import org.forgerock.opendj.config.server.ConfigChangeResult;
-import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.core.DirectoryServer;
-import org.opends.server.replication.plugin.LDAPReplicationDomain.*;
+import org.opends.server.replication.plugin.LDAPReplicationDomain.AttributeValueStringIterator;
+import org.opends.server.replication.plugin.LDAPReplicationDomain.FractionalConfig;
import org.opends.server.types.*;
-import org.forgerock.opendj.ldap.ByteString;
+
import static org.opends.messages.ReplicationMessages.*;
import static org.opends.server.replication.plugin.LDAPReplicationDomain.*;
@@ -404,11 +406,7 @@
{
AttributeType attrType = DirectoryServer.getAttributeTypeOrNull(attributeName);
List<Attribute> inclAttrs = entry.getAttribute(attrType);
- if (inclAttrs != null)
- {
- return inclAttrs.get(0);
- }
- return null;
+ return !inclAttrs.isEmpty() ? inclAttrs.get(0) : null;
}
/**
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/LDAPReplicationDomain.java b/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/LDAPReplicationDomain.java
index 752aba2..24946b6 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/LDAPReplicationDomain.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/LDAPReplicationDomain.java
@@ -64,13 +64,13 @@
import org.opends.server.admin.std.meta.ReplicationDomainCfgDefn.IsolationPolicy;
import org.opends.server.admin.std.server.ExternalChangelogDomainCfg;
import org.opends.server.admin.std.server.ReplicationDomainCfg;
-import org.opends.server.api.DirectoryThread;
-import org.opends.server.api.SynchronizationProvider;
import org.opends.server.api.AlertGenerator;
import org.opends.server.api.Backend;
import org.opends.server.api.Backend.BackendOperation;
import org.opends.server.api.BackendInitializationListener;
+import org.opends.server.api.DirectoryThread;
import org.opends.server.api.ServerShutdownListener;
+import org.opends.server.api.SynchronizationProvider;
import org.opends.server.backends.task.Task;
import org.opends.server.core.*;
import org.opends.server.protocols.internal.InternalClientConnection;
@@ -706,7 +706,7 @@
{
AttributeType synchronizationGenIDType = DirectoryServer.getAttributeTypeOrNull(REPLICATION_GENERATION_ID);
List<Attribute> attrs = resultEntry.getAttribute(synchronizationGenIDType);
- if (attrs != null)
+ if (!attrs.isEmpty())
{
Attribute attr = attrs.get(0);
if (attr.size() == 1)
@@ -727,7 +727,7 @@
{
AttributeType attrType = DirectoryServer.getAttributeTypeOrNull(attrName);
List<Attribute> exclAttrs = resultEntry.getAttribute(attrType);
- if (exclAttrs != null)
+ if (!exclAttrs.isEmpty())
{
Attribute exclAttr = exclAttrs.get(0);
if (exclAttr != null)
@@ -3278,7 +3278,7 @@
{
AttributeType synchronizationGenIDType = DirectoryServer.getAttributeTypeOrNull(REPLICATION_GENERATION_ID);
List<Attribute> attrs = resultEntry.getAttribute(synchronizationGenIDType);
- if (attrs != null)
+ if (!attrs.isEmpty())
{
Attribute attr = attrs.get(0);
if (attr.size()>1)
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/PersistentServerState.java b/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/PersistentServerState.java
index a9d1f93..e48d0d3 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/PersistentServerState.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/PersistentServerState.java
@@ -215,14 +215,14 @@
/**
* Update this ServerState from the provided entry.
*
- * @param resultEntry The entry that should be used to update this
- * ServerState.
+ * @param resultEntry
+ * The entry that should be used to update this ServerState.
*/
private void updateStateFromEntry(SearchResultEntry resultEntry)
{
AttributeType synchronizationStateType = DirectoryServer.getAttributeTypeOrNull(REPLICATION_STATE);
List<Attribute> attrs = resultEntry.getAttribute(synchronizationStateType);
- if (attrs != null)
+ if (!attrs.isEmpty())
{
for (ByteString value : attrs.get(0))
{
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tasks/AddSchemaFileTask.java b/opendj-server-legacy/src/main/java/org/opends/server/tasks/AddSchemaFileTask.java
index 225417b..c231f7d 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tasks/AddSchemaFileTask.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tasks/AddSchemaFileTask.java
@@ -32,24 +32,23 @@
import java.util.TreeSet;
import org.forgerock.i18n.LocalizableMessage;
+import org.forgerock.i18n.slf4j.LocalizedLogger;
+import org.forgerock.opendj.config.server.ConfigException;
+import org.forgerock.opendj.ldap.ByteString;
+import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.admin.std.server.SynchronizationProviderCfg;
import org.opends.server.api.ClientConnection;
import org.opends.server.api.SynchronizationProvider;
import org.opends.server.backends.task.Task;
import org.opends.server.backends.task.TaskState;
-import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.SchemaConfigManager;
-import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.opends.server.types.*;
import org.opends.server.types.LockManager.DNLock;
-import org.forgerock.opendj.ldap.ByteString;
-import org.forgerock.opendj.ldap.ResultCode;
import static org.opends.messages.TaskMessages.*;
import static org.opends.server.config.ConfigConstants.*;
-import static org.opends.server.core.DirectoryServer.getSchemaDN;
-import static org.opends.server.core.DirectoryServer.getServerErrorResultCode;
+import static org.opends.server.core.DirectoryServer.*;
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
@@ -95,7 +94,7 @@
Entry taskEntry = getTaskEntry();
AttributeType attrType = DirectoryServer.getAttributeTypeOrDefault(ATTR_TASK_ADDSCHEMAFILE_FILENAME);
List<Attribute> attrList = taskEntry.getAttribute(attrType);
- if (attrList == null || attrList.isEmpty())
+ if (attrList.isEmpty())
{
LocalizableMessage message = ERR_TASK_ADDSCHEMAFILE_NO_FILENAME.get(
ATTR_TASK_ADDSCHEMAFILE_FILENAME, taskEntry.getName());
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tasks/BackupTask.java b/opendj-server-legacy/src/main/java/org/opends/server/tasks/BackupTask.java
index e2318e5..6f69ab6 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tasks/BackupTask.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tasks/BackupTask.java
@@ -57,7 +57,6 @@
import org.opends.server.config.ConfigEntry;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.LockFileManager;
-import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.opends.server.types.BackupConfig;
import org.opends.server.types.BackupDirectory;
@@ -160,44 +159,23 @@
AttributeType typeBackupDirectory = getAttributeTypeOrDefault(ATTR_BACKUP_DIRECTORY_PATH);
AttributeType typeIncrementalBaseID = getAttributeTypeOrDefault(ATTR_TASK_BACKUP_INCREMENTAL_BASE_ID);
+ backUpAll = TaskUtils.getBoolean(taskEntry.getAttribute(typeBackupAll), false);
+ compress = TaskUtils.getBoolean(taskEntry.getAttribute(typeCompress), false);
+ encrypt = TaskUtils.getBoolean(taskEntry.getAttribute(typeEncrypt), false);
+ hash = TaskUtils.getBoolean(taskEntry.getAttribute(typeHash), false);
+ incremental = TaskUtils.getBoolean(taskEntry.getAttribute(typeIncremental), false);
+ signHash = TaskUtils.getBoolean(taskEntry.getAttribute(typeSignHash), false);
+ backendIDList = TaskUtils.getMultiValueString(taskEntry.getAttribute(typeBackendID));
+ backupID = TaskUtils.getSingleValueString(taskEntry.getAttribute(typeBackupID));
- List<Attribute> attrList;
-
- attrList = taskEntry.getAttribute(typeBackupAll);
- backUpAll = TaskUtils.getBoolean(attrList, false);
-
- attrList = taskEntry.getAttribute(typeCompress);
- compress = TaskUtils.getBoolean(attrList, false);
-
- attrList = taskEntry.getAttribute(typeEncrypt);
- encrypt = TaskUtils.getBoolean(attrList, false);
-
- attrList = taskEntry.getAttribute(typeHash);
- hash = TaskUtils.getBoolean(attrList, false);
-
- attrList = taskEntry.getAttribute(typeIncremental);
- incremental = TaskUtils.getBoolean(attrList, false);
-
- attrList = taskEntry.getAttribute(typeSignHash);
- signHash = TaskUtils.getBoolean(attrList, false);
-
- attrList = taskEntry.getAttribute(typeBackendID);
- backendIDList = TaskUtils.getMultiValueString(attrList);
-
- attrList = taskEntry.getAttribute(typeBackupID);
- backupID = TaskUtils.getSingleValueString(attrList);
-
- attrList = taskEntry.getAttribute(typeBackupDirectory);
- String backupDirectoryPath = TaskUtils.getSingleValueString(attrList);
+ String backupDirectoryPath = TaskUtils.getSingleValueString(taskEntry.getAttribute(typeBackupDirectory));
backupDirectory = new File(backupDirectoryPath);
if (! backupDirectory.isAbsolute())
{
- backupDirectory =
- new File(DirectoryServer.getInstanceRoot(), backupDirectoryPath);
+ backupDirectory = new File(DirectoryServer.getInstanceRoot(), backupDirectoryPath);
}
- attrList = taskEntry.getAttribute(typeIncrementalBaseID);
- incrementalBase = TaskUtils.getSingleValueString(attrList);
+ incrementalBase = TaskUtils.getSingleValueString(taskEntry.getAttribute(typeIncrementalBaseID));
configEntries = TaskUtils.getBackendConfigEntries();
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tasks/DisconnectClientTask.java b/opendj-server-legacy/src/main/java/org/opends/server/tasks/DisconnectClientTask.java
index 7aeee51..f91716b 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tasks/DisconnectClientTask.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tasks/DisconnectClientTask.java
@@ -30,8 +30,6 @@
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
-import java.util.List;
-
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.ldap.ByteString;
@@ -106,22 +104,18 @@
private long getConnectionID(Entry taskEntry) throws DirectoryException
{
final AttributeType attrType = DirectoryServer.getAttributeTypeOrDefault(ATTR_TASK_DISCONNECT_CONN_ID);
- final List<Attribute> attrList = taskEntry.getAttribute(attrType);
- if (attrList != null)
+ for (Attribute a : taskEntry.getAttribute(attrType))
{
- for (Attribute a : attrList)
+ for (ByteString v : a)
{
- for (ByteString v : a)
+ try
{
- try
- {
- return Long.parseLong(v.toString());
- }
- catch (Exception e)
- {
- LocalizableMessage message = ERR_TASK_DISCONNECT_INVALID_CONN_ID.get(v);
- throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message, e);
- }
+ return Long.parseLong(v.toString());
+ }
+ catch (Exception e)
+ {
+ LocalizableMessage message = ERR_TASK_DISCONNECT_INVALID_CONN_ID.get(v);
+ throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message, e);
}
}
}
@@ -131,27 +125,23 @@
private boolean mustNotifyClient(Entry taskEntry) throws DirectoryException
{
final AttributeType attrType = DirectoryServer.getAttributeTypeOrDefault(ATTR_TASK_DISCONNECT_NOTIFY_CLIENT);
- final List<Attribute> attrList = taskEntry.getAttribute(attrType);
- if (attrList != null)
+ for (Attribute a : taskEntry.getAttribute(attrType))
{
- for (Attribute a : attrList)
+ for (ByteString v : a)
{
- for (ByteString v : a)
+ final String stringValue = toLowerCase(v.toString());
+ if ("true".equals(stringValue))
{
- final String stringValue = toLowerCase(v.toString());
- if ("true".equals(stringValue))
- {
- return true;
- }
- else if ("false".equals(stringValue))
- {
- return false;
- }
- else
- {
- LocalizableMessage message = ERR_TASK_DISCONNECT_INVALID_NOTIFY_CLIENT.get(stringValue);
- throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message);
- }
+ return true;
+ }
+ else if ("false".equals(stringValue))
+ {
+ return false;
+ }
+ else
+ {
+ LocalizableMessage message = ERR_TASK_DISCONNECT_INVALID_NOTIFY_CLIENT.get(stringValue);
+ throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message);
}
}
}
@@ -161,21 +151,16 @@
private LocalizableMessage getDisconnectMessage(Entry taskEntry)
{
AttributeType attrType = DirectoryServer.getAttributeTypeOrDefault(ATTR_TASK_DISCONNECT_MESSAGE);
- List<Attribute> attrList = taskEntry.getAttribute(attrType);
- if (attrList != null)
+ for (Attribute a : taskEntry.getAttribute(attrType))
{
- for (Attribute a : attrList)
+ for (ByteString v : a)
{
- for (ByteString v : a)
- {
- return LocalizableMessage.raw(v.toString());
- }
+ return LocalizableMessage.raw(v.toString());
}
}
return INFO_TASK_DISCONNECT_GENERIC_MESSAGE.get();
}
- /** {@inheritDoc} */
@Override
protected TaskState runTask()
{
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tasks/SetGenerationIdTask.java b/opendj-server-legacy/src/main/java/org/opends/server/tasks/SetGenerationIdTask.java
index 9e4ee3a..92fecb2 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tasks/SetGenerationIdTask.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tasks/SetGenerationIdTask.java
@@ -79,7 +79,7 @@
// Retrieves the eventual generation-ID
AttributeType typeNewValue = getAttributeTypeOrDefault(ATTR_TASK_SET_GENERATION_ID_NEW_VALUE);
List<Attribute> attrList = taskEntry.getAttribute(typeNewValue);
- if (attrList != null && !attrList.isEmpty())
+ if (!attrList.isEmpty())
{
try
{
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tasks/ShutdownTask.java b/opendj-server-legacy/src/main/java/org/opends/server/tasks/ShutdownTask.java
index fec4bdc..ad37e96 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tasks/ShutdownTask.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tasks/ShutdownTask.java
@@ -96,7 +96,7 @@
AttributeType attrType = DirectoryServer.getAttributeTypeOrDefault(ATTR_SHUTDOWN_MESSAGE);
List<Attribute> attrList = taskEntry.getAttribute(attrType);
- if (attrList != null && !attrList.isEmpty())
+ if (!attrList.isEmpty())
{
Attribute attr = attrList.get(0);
if (!attr.isEmpty())
@@ -109,7 +109,7 @@
attrType = DirectoryServer.getAttributeTypeOrDefault(ATTR_RESTART_SERVER);
attrList = taskEntry.getAttribute(attrType);
- if (attrList != null && !attrList.isEmpty())
+ if (!attrList.isEmpty())
{
Attribute attr = attrList.get(0);
if (!attr.isEmpty())
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 33306a2..5611b3c 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
@@ -167,10 +167,7 @@
{
continue;
}
- else
- {
- backendID = idAttr.activeValue();
- }
+ backendID = idAttr.activeValue();
}
catch (org.opends.server.config.ConfigException ce)
{
@@ -196,7 +193,7 @@
* @return The configuration entry of the backend, or null if it could not
* be found.
*/
- public static BackendCfg getConfigEntry(Backend backend)
+ public static BackendCfg getConfigEntry(Backend<?> backend)
{
RootCfg root = ServerManagementContext.getInstance().
getRootConfiguration();
@@ -262,8 +259,7 @@
* @param backendID Identifies the backend to be disabled.
* @throws DirectoryException If the internal modify operation failed.
*/
- public static void disableBackend(String backendID)
- throws DirectoryException
+ public static void disableBackend(String backendID) throws DirectoryException
{
DN configEntryDN;
RootCfg root = ServerManagementContext.getInstance().getRootConfiguration();
@@ -312,11 +308,6 @@
public static boolean getBoolean(List<Attribute> attrList,
boolean defaultValue)
{
- if (attrList == null || attrList.isEmpty())
- {
- return defaultValue;
- }
-
for (Attribute a : attrList)
{
for (ByteString v : a)
@@ -351,8 +342,7 @@
public static ArrayList<String> getMultiValueString(List<Attribute> attrList)
{
ArrayList<String> valueStrings = new ArrayList<>();
-
- if (attrList != null && !attrList.isEmpty())
+ if (!attrList.isEmpty())
{
Attribute attr = attrList.get(0);
if (!attr.isEmpty())
@@ -378,7 +368,7 @@
*/
public static String getSingleValueString(List<Attribute> attrList)
{
- if (attrList != null && !attrList.isEmpty())
+ if (!attrList.isEmpty())
{
Attribute attr = attrList.get(0);
if (!attr.isEmpty())
@@ -401,10 +391,9 @@
* @return The integer value of the attribute, or the provided default value
* if there is no value.
*/
- public static int getSingleValueInteger(List<Attribute> attrList,
- int defaultValue)
+ public static int getSingleValueInteger(List<Attribute> attrList, int defaultValue)
{
- if (attrList != null && !attrList.isEmpty())
+ if (!attrList.isEmpty())
{
Attribute attr = attrList.get(0);
if (!attr.isEmpty())
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tools/tasks/TaskEntry.java b/opendj-server-legacy/src/main/java/org/opends/server/tools/tasks/TaskEntry.java
index c9b9ca4..6e2e119 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tools/tasks/TaskEntry.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tools/tasks/TaskEntry.java
@@ -431,7 +431,7 @@
private String getSingleStringValue(Entry entry, String attrName) {
List<Attribute> attrList = entry.getAttribute(attrName);
- if (attrList != null && attrList.size() == 1) {
+ if (attrList.size() == 1) {
Attribute attr = attrList.get(0);
if (!attr.isEmpty()) {
return attr.iterator().next().toString();
@@ -442,12 +442,9 @@
private List<String> getMultiStringValue(Entry entry, String attrName) {
List<String> valuesList = new ArrayList<>();
- List<Attribute> attrList = entry.getAttribute(attrName);
- if (attrList != null) {
- for (Attribute attr : attrList) {
- for (ByteString value : attr) {
- valuesList.add(value.toString());
- }
+ for (Attribute attr : entry.getAttribute(attrName)) {
+ for (ByteString value : attr) {
+ valuesList.add(value.toString());
}
}
return valuesList;
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/types/Entry.java b/opendj-server-legacy/src/main/java/org/opends/server/types/Entry.java
index 3a404d0..ab594ea 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/types/Entry.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/types/Entry.java
@@ -464,8 +464,7 @@
if (!includeSubordinates)
{
// It's possible that there could be an attribute without any
- // values, which we should treat as not having the requested
- // attribute.
+ // values, which we should treat as not having the requested attribute.
Attribute attribute = getExactAttribute(attributeType, options);
return attribute != null && !attribute.isEmpty();
}
@@ -477,8 +476,7 @@
for (Attribute attribute : attributes)
{
// It's possible that there could be an attribute without any
- // values, which we should treat as not having the requested
- // attribute.
+ // values, which we should treat as not having the requested attribute.
if (!attribute.isEmpty() && attribute.hasAllOptions(options))
{
return true;
@@ -576,7 +574,7 @@
* @param attributeType
* The attribute type to retrieve.
* @return The requested attribute element(s) for the specified
- * attribute type, or <CODE>null</CODE> if the specified
+ * attribute type, or an empty list if the specified
* attribute type is not present in this entry.
*/
public List<Attribute> getAttribute(AttributeType attributeType)
@@ -597,7 +595,7 @@
* being retrieved.
*
* @return The requested attribute element(s) for the specified
- * attribute type, or <CODE>null</CODE> if the specified
+ * attribute type, or an empty list if the specified
* attribute type is not present in this entry.
*/
public List<Attribute> getAttribute(AttributeType attributeType,
@@ -615,11 +613,7 @@
addAllIfNotNull(attributes, operationalAttributes.get(at));
}
- if (!attributes.isEmpty())
- {
- return attributes;
- }
- return null;
+ return attributes;
}
List<Attribute> attributes = userAttributes.get(attributeType);
@@ -636,7 +630,7 @@
{
return newArrayList(getObjectClassAttribute());
}
- return null;
+ return Collections.emptyList();
}
/**
@@ -675,7 +669,7 @@
* formatted in all lowercase characters.
*
* @return The requested attribute element(s) for the specified
- * attribute type, or <CODE>null</CODE> if the specified
+ * attribute type, or an empty list if the specified
* attribute type is not present in this entry.
*/
public List<Attribute> getAttribute(String lowerName)
@@ -701,7 +695,7 @@
{
return newLinkedList(getObjectClassAttribute());
}
- return null;
+ return Collections.emptyList();
}
/**
@@ -716,40 +710,15 @@
* include in matching elements.
*
* @return The requested attribute element(s) for the specified
- * attribute type, or <CODE>null</CODE> if the specified
+ * attribute type, or an empty list if the specified
* attribute type is not present in this entry with the
* provided set of options.
*/
public List<Attribute> getAttribute(AttributeType attributeType,
Set<String> options)
{
- return getAttribute(attributeType, true, options);
- }
-
- /**
- * Retrieves the requested attribute element(s) for the specified
- * attribute type. The list returned may include multiple elements
- * if the same attribute exists in the entry multiple times with
- * different sets of options.
- *
- * @param attributeType The attribute type to retrieve.
- * @param includeSubordinates Whether to include any subordinate
- * attributes of the attribute type
- * being retrieved.
- * @param options The set of attribute options to
- * include in matching elements.
- *
- * @return The requested attribute element(s) for the specified
- * attribute type, or <CODE>null</CODE> if the specified
- * attribute type is not present in this entry with the
- * provided set of options.
- */
- public List<Attribute> getAttribute(AttributeType attributeType,
- boolean includeSubordinates,
- Set<String> options)
- {
List<Attribute> attributes = new LinkedList<>();
- if (includeSubordinates && attributeType.mayHaveSubordinateTypes())
+ if (attributeType.mayHaveSubordinateTypes())
{
addAllIfNotNull(attributes, userAttributes.get(attributeType));
addAllIfNotNull(attributes, operationalAttributes.get(attributeType));
@@ -775,7 +744,7 @@
attributes.add(getObjectClassAttribute());
return attributes;
}
- return null;
+ return Collections.emptyList();
}
}
attributes.addAll(attrs);
@@ -783,65 +752,9 @@
onlyKeepAttributesWithAllOptions(attributes, options);
- if (!attributes.isEmpty())
- {
- return attributes;
- }
- return null;
+ return attributes;
}
-
-
- /**
- * Retrieves the requested attribute element(s) for the attribute
- * with the specified name or OID and set of options. The list
- * returned may include multiple elements if the same attribute
- * exists in the entry multiple times with different sets of
- * matching options.
- * <BR><BR>
- * Note that this method should only be used in cases in which the
- * Directory Server schema has no reference of an attribute type
- * with the specified name. It is not as accurate or efficient as
- * the version of this method that takes an
- * <CODE>AttributeType</CODE> argument.
- *
- * @param lowerName The name or OID of the attribute to return,
- * formatted in all lowercase characters.
- * @param options The set of attribute options to include in
- * matching elements.
- *
- * @return The requested attribute element(s) for the specified
- * attribute type, or <CODE>null</CODE> if the specified
- * attribute type is not present in this entry.
- */
- public List<Attribute> getAttribute(String lowerName,
- Set<String> options)
- {
- for (AttributeType attr : userAttributes.keySet())
- {
- if (attr.hasNameOrOID(lowerName))
- {
- return getAttribute(attr, options);
- }
- }
-
- for (AttributeType attr : operationalAttributes.keySet())
- {
- if (attr.hasNameOrOID(lowerName))
- {
- return getAttribute(attr, options);
- }
- }
-
- if (lowerName.equals(OBJECTCLASS_ATTRIBUTE_TYPE_NAME) &&
- (options == null || options.isEmpty()))
- {
- return newLinkedList(getObjectClassAttribute());
- }
- return null;
- }
-
-
/**
* Returns a parser for the named attribute contained in this entry.
* <p>
@@ -861,8 +774,7 @@
throws LocalizedIllegalArgumentException, NullPointerException
{
final List<Attribute> attribute = getAttribute(attributeDescription);
- boolean notEmpty = attribute != null && !attribute.isEmpty();
- return AttributeParser.parseAttribute(notEmpty ? attribute.get(0) : null);
+ return AttributeParser.parseAttribute(!attribute.isEmpty() ? attribute.get(0) : null);
}
@@ -892,7 +804,7 @@
* @param attributeType The attribute type to retrieve.
*
* @return The requested attribute element(s) for the specified
- * attribute type, or <CODE>null</CODE> if there is no such
+ * attribute type, or an empty list if there is no such
* user attribute.
*/
public List<Attribute> getUserAttribute(AttributeType attributeType)
@@ -920,39 +832,15 @@
{
addAllIfNotNull(attributes, attrs.get(at));
}
-
- if (!attributes.isEmpty())
- {
- return attributes;
- }
- return null;
+ return attributes;
}
- return attrs.get(attributeType);
+ List<Attribute> results = attrs.get(attributeType);
+ return results != null ? results : Collections.<Attribute> emptyList();
}
/**
- * Retrieves the requested user attribute element(s) for the
- * specified attribute type. The list returned may include multiple
- * elements if the same attribute exists in the entry multiple times
- * with different sets of options.
- *
- * @param attributeType The attribute type to retrieve.
- * @param options The set of attribute options to include in
- * matching elements.
- *
- * @return The requested attribute element(s) for the specified
- * attribute type, or <CODE>null</CODE> if there is no such
- * user attribute with the specified set of options.
- */
- public List<Attribute> getUserAttribute(AttributeType attributeType,
- Set<String> options)
- {
- return getAttribute(attributeType, options, userAttributes);
- }
-
- /**
* Returns the List of attributes for a given attribute type having all the
* required options.
*
@@ -979,12 +867,7 @@
}
onlyKeepAttributesWithAllOptions(attributes, options);
-
- if (!attributes.isEmpty())
- {
- return attributes;
- }
- return null;
+ return attributes;
}
/**
@@ -1056,7 +939,7 @@
* @param attributeType The attribute type to retrieve.
*
* @return The requested attribute element(s) for the specified
- * attribute type, or <CODE>null</CODE> if there is no such
+ * attribute type, or an empty list if there is no such
* operational attribute.
*/
public List<Attribute> getOperationalAttribute(AttributeType attributeType)
@@ -1078,7 +961,7 @@
* matching elements.
*
* @return The requested attribute element(s) for the specified
- * attribute type, or <CODE>null</CODE> if there is no such
+ * attribute type, or an empty list if there is no such
* operational attribute with the specified set of options.
*/
public List<Attribute> getOperationalAttribute(
@@ -1441,16 +1324,9 @@
* @return <CODE>true</CODE> if this entry contains the specified
* attribute value, or <CODE>false</CODE> if it does not.
*/
- public boolean hasValue(AttributeType attributeType,
- Set<String> options, ByteString value)
+ public boolean hasValue(AttributeType attributeType, Set<String> options, ByteString value)
{
- List<Attribute> attrList = getAttribute(attributeType, true);
- if (attrList == null || attrList.isEmpty())
- {
- return false;
- }
-
- for (Attribute a : attrList)
+ for (Attribute a : getAttribute(attributeType))
{
if (a.optionsEqual(options) && a.contains(value))
{
@@ -3005,8 +2881,7 @@
try
{
DN inheritFromDN = null;
- for (Attribute attr : getAttribute(
- subEntry.getInheritFromDNType()))
+ for (Attribute attr : getAttribute(subEntry.getInheritFromDNType()))
{
for (ByteString value : attr)
{
@@ -3041,8 +2916,7 @@
{
try
{
- for (Attribute attr : getAttribute(
- subEntry.getInheritFromRDNAttrType()))
+ for (Attribute attr : getAttribute(subEntry.getInheritFromRDNAttrType()))
{
inheritFromDN = subEntry.getInheritFromBaseDN();
for (ByteString value : attr)
@@ -4726,7 +4600,7 @@
else
{
List<Attribute> attrList = getUserAttribute(attrType);
- if (attrList != null)
+ if (!attrList.isEmpty())
{
mergeAttributeLists(attrList, userAttrsCopy, attrType,
attrName, options, omitValues, omitReal, omitVirtual);
@@ -4734,7 +4608,7 @@
else
{
attrList = getOperationalAttribute(attrType);
- if (attrList != null)
+ if (!attrList.isEmpty())
{
mergeAttributeLists(attrList, operationalAttrsCopy,
attrType, attrName, options, omitValues, omitReal,
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/types/SearchFilter.java b/opendj-server-legacy/src/main/java/org/opends/server/types/SearchFilter.java
index fe7ba7c..014a85e 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/types/SearchFilter.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/types/SearchFilter.java
@@ -2637,9 +2637,8 @@
}
// See if the entry has an attribute with the requested type.
- List<Attribute> attrs = entry.getAttribute(attributeType,
- attributeOptions);
- if (attrs == null || attrs.isEmpty())
+ List<Attribute> attrs = entry.getAttribute(attributeType, attributeOptions);
+ if (attrs.isEmpty())
{
if (logger.isTraceEnabled())
{
@@ -2743,7 +2742,7 @@
// See if the entry has an attribute with the requested type.
List<Attribute> attrs = entry.getAttribute(attributeType, attributeOptions);
- if (attrs == null || attrs.isEmpty())
+ if (attrs.isEmpty())
{
if (logger.isTraceEnabled())
{
@@ -2844,7 +2843,7 @@
// See if the entry has an attribute with the requested type.
List<Attribute> attrs = entry.getAttribute(attributeType, attributeOptions);
- if (attrs == null || attrs.isEmpty())
+ if (attrs.isEmpty())
{
if (logger.isTraceEnabled())
{
@@ -2857,8 +2856,7 @@
return ConditionResult.FALSE;
}
- // Iterate through all the attributes and see if we can find a
- // match.
+ // Iterate through all the attributes and see if we can find a match.
ConditionResult result = ConditionResult.FALSE;
for (Attribute a : attrs)
{
@@ -2942,9 +2940,8 @@
}
// See if the entry has an attribute with the requested type.
- List<Attribute> attrs =
- entry.getAttribute(attributeType, attributeOptions);
- if (attrs == null || attrs.isEmpty())
+ List<Attribute> attrs = entry.getAttribute(attributeType, attributeOptions);
+ if (attrs.isEmpty())
{
if (logger.isTraceEnabled())
{
@@ -3087,9 +3084,8 @@
}
// See if the entry has an attribute with the requested type.
- List<Attribute> attrs =
- entry.getAttribute(attributeType, attributeOptions);
- if (attrs == null || attrs.isEmpty())
+ List<Attribute> attrs = entry.getAttribute(attributeType, attributeOptions);
+ if (attrs.isEmpty())
{
if (logger.isTraceEnabled())
{
@@ -3390,45 +3386,37 @@
}
else
{
- List<Attribute> attrList = entry.getAttribute(attributeType,
- attributeOptions);
- if (attrList != null)
+ for (Attribute a : entry.getAttribute(attributeType, attributeOptions))
{
- for (Attribute a : attrList)
+ for (ByteString v : a)
{
- for (ByteString v : a)
+ try
{
- try
+ ByteString nv = matchingRule.normalizeAttributeValue(v);
+ ConditionResult r = assertion.matches(nv);
+ switch (r)
{
- ByteString nv = matchingRule.normalizeAttributeValue(v);
- ConditionResult r = assertion.matches(nv);
- switch (r)
- {
- case TRUE:
- return ConditionResult.TRUE;
- case FALSE:
- break;
- case UNDEFINED:
- result = ConditionResult.UNDEFINED;
- break;
- default:
- LocalizableMessage message =
- ERR_SEARCH_FILTER_INVALID_RESULT_TYPE.
- get(entry.getName(), completeFilter, r);
- throw new DirectoryException(
- ResultCode.PROTOCOL_ERROR, message);
- }
- }
- catch (Exception e)
- {
- logger.traceException(e);
-
- // We couldn't normalize one of the values. If we don't
- // find a definite match, then we should return
- // undefined.
+ case TRUE:
+ return ConditionResult.TRUE;
+ case FALSE:
+ break;
+ case UNDEFINED:
result = ConditionResult.UNDEFINED;
+ break;
+ default:
+ LocalizableMessage message =
+ ERR_SEARCH_FILTER_INVALID_RESULT_TYPE.get(entry.getName(), completeFilter, r);
+ throw new DirectoryException(ResultCode.PROTOCOL_ERROR, message);
}
}
+ catch (Exception e)
+ {
+ logger.traceException(e);
+
+ // We couldn't normalize one of the values.
+ // If we don't find a definite match, then we should return undefined.
+ result = ConditionResult.UNDEFINED;
+ }
}
}
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/types/SubEntry.java b/opendj-server-legacy/src/main/java/org/opends/server/types/SubEntry.java
index ca7599f..c0e0b66 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/types/SubEntry.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/types/SubEntry.java
@@ -190,34 +190,29 @@
String specString = null;
boolean isValidSpec = true;
AttributeType specAttrType = DirectoryServer.getAttributeTypeOrDefault(ATTR_SUBTREE_SPEC_LC);
- List<Attribute> specAttrList = entry.getAttribute(specAttrType);
- if (specAttrList != null)
+ for (Attribute attr : entry.getAttribute(specAttrType))
{
- for (Attribute attr : specAttrList)
+ for (ByteString value : attr)
{
- for (ByteString value : attr)
+ specString = value.toString();
+ try
{
- specString = value.toString();
- try
- {
- this.subTreeSpec = SubtreeSpecification.valueOf(
- entry.getName().parent(), specString);
- isValidSpec = true;
- }
- catch (DirectoryException de)
- {
- isValidSpec = false;
- }
- if (this.subTreeSpec != null)
- {
- break;
- }
+ this.subTreeSpec = SubtreeSpecification.valueOf(entry.getName().parent(), specString);
+ isValidSpec = true;
+ }
+ catch (DirectoryException de)
+ {
+ isValidSpec = false;
}
if (this.subTreeSpec != null)
{
break;
}
}
+ if (this.subTreeSpec != null)
+ {
+ break;
+ }
}
// Check that the subtree spec is flagged as valid. If it is not
@@ -288,78 +283,55 @@
{
if (this.isInheritedFromDNCollective)
{
- List<Attribute> attrList = entry.getAttribute(
- ATTR_INHERIT_COLLECTIVE_FROM_DN);
- if (attrList != null && !attrList.isEmpty())
+ for (Attribute attr : entry.getAttribute(ATTR_INHERIT_COLLECTIVE_FROM_DN))
{
- for (Attribute attr : attrList)
+ for (ByteString value : attr)
{
- for (ByteString value : attr)
- {
- this.inheritFromDNType = DirectoryServer.getAttributeTypeOrDefault(value.toString().toLowerCase());
- this.inheritFromDNAttrValue = value;
- break;
- }
+ this.inheritFromDNType = DirectoryServer.getAttributeTypeOrDefault(value.toString().toLowerCase());
+ this.inheritFromDNAttrValue = value;
+ break;
}
}
}
if (this.isInheritedFromRDNCollective)
{
- List<Attribute> attrList = entry.getAttribute(ATTR_INHERIT_COLLECTIVE_FROM_RDN);
- if (attrList != null && !attrList.isEmpty())
+ for (Attribute attr : entry.getAttribute(ATTR_INHERIT_COLLECTIVE_FROM_RDN))
{
- for (Attribute attr : attrList)
+ for (ByteString value : attr)
{
- for (ByteString value : attr)
- {
- this.inheritFromRDNAttrType = DirectoryServer.getAttributeTypeOrDefault(value.toString().toLowerCase());
- this.inheritFromRDNAttrValue = value;
- break;
- }
+ this.inheritFromRDNAttrType = DirectoryServer.getAttributeTypeOrDefault(value.toString().toLowerCase());
+ this.inheritFromRDNAttrValue = value;
+ break;
}
}
- attrList = entry.getAttribute(ATTR_INHERIT_COLLECTIVE_FROM_RDN_TYPE);
- if (attrList != null && !attrList.isEmpty())
+ for (Attribute attr : entry.getAttribute(ATTR_INHERIT_COLLECTIVE_FROM_RDN_TYPE))
{
- for (Attribute attr : attrList)
+ for (ByteString value : attr)
{
- for (ByteString value : attr)
- {
- this.inheritFromRDNType = DirectoryServer.getAttributeTypeOrDefault(value.toString().toLowerCase());
- break;
- }
+ this.inheritFromRDNType = DirectoryServer.getAttributeTypeOrDefault(value.toString().toLowerCase());
+ break;
}
}
- attrList = entry.getAttribute(ATTR_INHERIT_COLLECTIVE_FROM_BASE);
- if (attrList != null && !attrList.isEmpty())
+ for (Attribute attr : entry.getAttribute(ATTR_INHERIT_COLLECTIVE_FROM_BASE))
{
- for (Attribute attr : attrList)
+ for (ByteString value : attr)
{
- for (ByteString value : attr)
- {
- // Has to have a parent since subentry itself
- // cannot be a suffix entry within the server.
- this.inheritFromBaseDN = getDN().parent().child(DN.decode(value));
- break;
- }
+ // Has to have a parent since subentry itself
+ // cannot be a suffix entry within the server.
+ this.inheritFromBaseDN = getDN().parent().child(DN.decode(value));
+ break;
}
}
}
- List<Attribute> attrList = entry.getAttribute(
- ATTR_INHERIT_COLLECTIVE_ATTR);
- if (attrList != null && !attrList.isEmpty())
+ for (Attribute attr : entry.getAttribute(ATTR_INHERIT_COLLECTIVE_ATTR))
{
- for (Attribute attr : attrList)
+ for (ByteString value : attr)
{
- for (ByteString value : attr)
- {
- CollectiveVirtualAttribute collectiveAttr =
- new CollectiveVirtualAttribute(
- Attributes.empty(value.toString()));
- this.collectiveAttributes.add(collectiveAttr);
- }
+ CollectiveVirtualAttribute collectiveAttr =
+ new CollectiveVirtualAttribute(Attributes.empty(value.toString()));
+ this.collectiveAttributes.add(collectiveAttr);
}
}
}
@@ -367,22 +339,16 @@
// Establish collective attribute conflict behavior.
if (this.isCollective || this.isInheritedCollective)
{
- List<Attribute> attrList = entry.getAttribute(
- ATTR_COLLECTIVE_CONFLICT_BEHAVIOR);
- if (attrList != null && !attrList.isEmpty())
+ for (Attribute attr : entry.getAttribute(ATTR_COLLECTIVE_CONFLICT_BEHAVIOR))
{
- for (Attribute attr : attrList)
+ for (ByteString value : attr)
{
- for (ByteString value : attr)
+ for (CollectiveConflictBehavior behavior : CollectiveConflictBehavior.values())
{
- for (CollectiveConflictBehavior behavior :
- CollectiveConflictBehavior.values())
+ if (behavior.toString().equals(value.toString()))
{
- if (behavior.toString().equals(value.toString()))
- {
- this.conflictBehavior = behavior;
- break;
- }
+ this.conflictBehavior = behavior;
+ break;
}
}
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendAddOperation.java b/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendAddOperation.java
index 521143d..5e9f6f7 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendAddOperation.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendAddOperation.java
@@ -703,7 +703,7 @@
// See if a password was specified.
AttributeType passwordAttribute = passwordPolicy.getPasswordAttribute();
List<Attribute> attrList = entry.getAttribute(passwordAttribute);
- if (attrList == null || attrList.isEmpty())
+ if (attrList.isEmpty())
{
// The entry doesn't have a password, so no action is required.
return;
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendBindOperation.java b/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendBindOperation.java
index 573980f..4304ca1 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendBindOperation.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendBindOperation.java
@@ -420,8 +420,7 @@
PasswordPolicy policy = pwPolicyState.getAuthenticationPolicy();
AttributeType pwType = policy.getPasswordAttribute();
- List<Attribute> pwAttr = userEntry.getAttribute(pwType);
- if (pwAttr == null || pwAttr.isEmpty())
+ if (userEntry.getAttribute(pwType).isEmpty())
{
throw new DirectoryException(ResultCode.INVALID_CREDENTIALS,
ERR_BIND_OPERATION_NO_PASSWORD.get());
@@ -1026,7 +1025,7 @@
{
AttributeType attrType = DirectoryServer.getAttributeTypeOrDefault(attributeTypeName);
List<Attribute> attrList = userEntry.getAttribute(attrType);
- if (attrList != null && attrList.size() == 1)
+ if (attrList.size() == 1)
{
Attribute a = attrList.get(0);
if (a.size() == 1)
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendCompareOperation.java b/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendCompareOperation.java
index cb18057..ff3e065 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendCompareOperation.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendCompareOperation.java
@@ -25,6 +25,7 @@
* Portions Copyright 2011-2015 ForgeRock AS
*/
package org.opends.server.workflowelement.localbackend;
+
import java.util.List;
import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -235,7 +236,7 @@
// Actually perform the compare operation.
List<Attribute> attrList = entry.getAttribute(attrType, options);
- if (attrList == null || attrList.isEmpty())
+ if (attrList.isEmpty())
{
setResultCode(ResultCode.NO_SUCH_ATTRIBUTE);
Arg2<Object, Object> errorMsg = options == null
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendModifyOperation.java b/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendModifyOperation.java
index 12c4d2f..6c97923 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendModifyOperation.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendModifyOperation.java
@@ -1072,7 +1072,7 @@
// We still need to check if the pre-encoded password matches
// an existing value, to decrease the number of passwords.
List<Attribute> attrList = currentEntry.getAttribute(pwAttr.getAttributeType());
- if (attrList == null || attrList.isEmpty())
+ if (attrList.isEmpty())
{
throw new DirectoryException(ResultCode.NO_SUCH_ATTRIBUTE, ERR_MODIFY_NO_EXISTING_VALUES.get());
}
@@ -1085,10 +1085,9 @@
else
{
List<Attribute> attrList = currentEntry.getAttribute(pwAttr.getAttributeType());
- if (attrList == null || attrList.isEmpty())
+ if (attrList.isEmpty())
{
- throw new DirectoryException(ResultCode.NO_SUCH_ATTRIBUTE,
- ERR_MODIFY_NO_EXISTING_VALUES.get());
+ throw new DirectoryException(ResultCode.NO_SUCH_ATTRIBUTE, ERR_MODIFY_NO_EXISTING_VALUES.get());
}
if (addIfAttributeValueExistsNoPreEncodedPassword(builder, attrList, v))
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/TestCaseUtils.java b/opendj-server-legacy/src/test/java/org/opends/server/TestCaseUtils.java
index 8b2f89f..17dcce4 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/TestCaseUtils.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/TestCaseUtils.java
@@ -1845,15 +1845,11 @@
public static HashSet<PluginType> getPluginTypes(Entry e)
{
HashSet<PluginType> pluginTypes = new HashSet<>();
- List<Attribute> attrList = e.getAttribute("ds-cfg-plugin-type");
- if (attrList != null)
+ for (Attribute a : e.getAttribute("ds-cfg-plugin-type"))
{
- for (Attribute a : attrList)
+ for (ByteString v : a)
{
- for (ByteString v : a)
- {
- pluginTypes.add(PluginType.forName(v.toString().toLowerCase()));
- }
+ pluginTypes.add(PluginType.forName(v.toString().toLowerCase()));
}
}
return pluginTypes;
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/authorization/dseecompat/AciTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/authorization/dseecompat/AciTestCase.java
index 4d6bc19..183cec8 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/authorization/dseecompat/AciTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/authorization/dseecompat/AciTestCase.java
@@ -79,9 +79,8 @@
// Save Global ACI.
Entry e = DirectoryServer.getEntry(DN.valueOf(ACCESS_HANDLER_DN));
- List<Attribute> attrs =
- e.getAttribute(ConfigConstants.ATTR_AUTHZ_GLOBAL_ACI);
- if (attrs != null && !attrs.isEmpty())
+ List<Attribute> attrs = e.getAttribute(ConfigConstants.ATTR_AUTHZ_GLOBAL_ACI);
+ if (!attrs.isEmpty())
{
Reporter.log("Saved global ACI attribute");
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/backends/ChangelogBackendTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/backends/ChangelogBackendTestCase.java
index 21ee482..e21aaca 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/backends/ChangelogBackendTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/backends/ChangelogBackendTestCase.java
@@ -1491,7 +1491,7 @@
private static String getAttributeValue(Entry entry, String attrName)
{
List<Attribute> attrs = entry.getAttribute(attrName.toLowerCase());
- if (attrs == null)
+ if (attrs.isEmpty())
{
return null;
}
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/backends/pluggable/TestDnKeyFormat.java b/opendj-server-legacy/src/test/java/org/opends/server/backends/pluggable/TestDnKeyFormat.java
index f476567..923e33d 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/backends/pluggable/TestDnKeyFormat.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/backends/pluggable/TestDnKeyFormat.java
@@ -390,13 +390,10 @@
}
// check the user attributes were not changed
- for (AttributeType attrType : entryBefore.getUserAttributes()
- .keySet()) {
+ for (AttributeType attrType : entryBefore.getUserAttributes().keySet()) {
List<Attribute> listBefore = entryBefore.getAttribute(attrType);
List<Attribute> listAfter = entryAfter.getAttribute(attrType);
-
- assertNotNull(listAfter);
- assertEquals(listBefore.size(), listAfter.size());
+ assertThat(listBefore).hasSameSizeAs(listAfter);
for (Attribute attrBefore : listBefore) {
boolean found = false;
@@ -404,7 +401,6 @@
for (Attribute attrAfter : listAfter) {
if (attrAfter.optionsEqual(attrBefore.getOptions())) {
// Found the corresponding attribute
-
assertEquals(attrBefore, attrAfter);
found = true;
}
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/core/AddOperationTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/core/AddOperationTestCase.java
index 55e88a9..a133969 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/core/AddOperationTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/core/AddOperationTestCase.java
@@ -68,6 +68,7 @@
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
+import static org.assertj.core.api.Assertions.*;
import static org.opends.server.TestCaseUtils.*;
import static org.opends.server.protocols.internal.InternalClientConnection.*;
import static org.opends.server.protocols.ldap.LDAPConstants.*;
@@ -402,7 +403,6 @@
Entry e = DirectoryServer.getEntry(DN.valueOf("ou=People,o=test"));
List<Attribute> attrList = e.getAttribute(a.getAttributeType());
- assertNotNull(attrList);
assertFalse(attrList.isEmpty());
boolean foundFoo = false;
@@ -455,9 +455,7 @@
retrieveCompletedOperationElements(addOperation);
Entry e = DirectoryServer.getEntry(DN.valueOf("ou=People,o=test"));
- List<Attribute> attrList = e.getAttribute(a.getAttributeType());
- assertNotNull(attrList);
- assertFalse(attrList.isEmpty());
+ assertThat(e.getAttribute(a.getAttributeType())).isNotEmpty();
UpdatePreOpPlugin.reset();
}
@@ -491,8 +489,7 @@
retrieveCompletedOperationElements(addOperation);
Entry e = DirectoryServer.getEntry(DN.valueOf("ou=People,o=test"));
- List<Attribute> attrList = e.getAttribute(attrType);
- assertNull(attrList);
+ assertThat(e.getAttribute(attrType)).isEmpty();
UpdatePreOpPlugin.reset();
}
@@ -889,7 +886,7 @@
Entry e = DirectoryServer.getEntry(DN.valueOf("ou=People,o=test"));
List<Attribute> attrList = e.getAttribute("ou");
- assertNotNull(attrList);
+ assertThat(attrList).isNotEmpty();
}
@@ -944,9 +941,7 @@
retrieveCompletedOperationElements(addOperation);
Entry e = DirectoryServer.getEntry(DN.valueOf("uid=test.user,o=test"));
- List<Attribute> attrList =
- e.getAttribute(DirectoryServer.getObjectClassAttributeType());
- assertNotNull(attrList);
+ List<Attribute> attrList = e.getAttribute(DirectoryServer.getObjectClassAttributeType());
boolean found = false;
for (Attribute a : attrList)
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/core/ModifyOperationTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/core/ModifyOperationTestCase.java
index d53421a..7edb9e5 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/core/ModifyOperationTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/core/ModifyOperationTestCase.java
@@ -77,6 +77,7 @@
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
+import static org.assertj.core.api.Assertions.*;
import static org.opends.server.TestCaseUtils.*;
import static org.opends.server.protocols.internal.InternalClientConnection.*;
import static org.opends.server.protocols.internal.Requests.*;
@@ -435,7 +436,7 @@
public void testGetAndAddModifications() throws Exception
{
Entry e = DirectoryServer.getEntry(DN.valueOf("o=test"));
- assertNull(e.getAttribute(DirectoryServer.getAttributeTypeOrDefault("description")));
+ assertThat(e.getAttribute(DirectoryServer.getAttributeTypeOrDefault("description"))).isEmpty();
UpdatePreOpPlugin.reset();
UpdatePreOpPlugin.addModification(
@@ -453,7 +454,7 @@
retrieveSuccessfulOperationElements(modifyOperation);
e = DirectoryServer.getEntry(DN.valueOf("o=test"));
- assertNotNull(e.getAttribute(DirectoryServer.getAttributeTypeOrDefault("description")));
+ assertThat(e.getAttribute(DirectoryServer.getAttributeTypeOrDefault("description"))).isNotEmpty();
UpdatePreOpPlugin.reset();
}
@@ -552,7 +553,7 @@
public void testSuccessAddAttribute() throws Exception
{
Entry e = DirectoryServer.getEntry(DN.valueOf("o=test"));
- assertNull(e.getAttribute(DirectoryServer.getAttributeTypeOrDefault("description")));
+ assertThat(e.getAttribute(DirectoryServer.getAttributeTypeOrDefault("description"))).isEmpty();
LDAPAttribute attr = newLDAPAttribute("description", "foo");
ModifyOperation modifyOperation = processModify("o=test", replace(attr));
@@ -560,7 +561,7 @@
retrieveSuccessfulOperationElements(modifyOperation);
e = DirectoryServer.getEntry(DN.valueOf("o=test"));
- assertNotNull(e.getAttribute(DirectoryServer.getAttributeTypeOrDefault("description")));
+ assertThat(e.getAttribute(DirectoryServer.getAttributeTypeOrDefault("description"))).isNotEmpty();
}
@@ -576,8 +577,7 @@
{
Entry e = DirectoryServer.getEntry(DN.valueOf("o=test"));
- List<Attribute> attrList =
- e.getAttribute(DirectoryServer.getAttributeTypeOrDefault("o"));
+ List<Attribute> attrList = e.getAttribute(DirectoryServer.getAttributeTypeOrDefault("o"));
assertEquals(countValues(attrList), 1);
LDAPAttribute attr = newLDAPAttribute("o", "test2");
@@ -604,8 +604,7 @@
{
Entry e = DirectoryServer.getEntry(DN.valueOf(baseDN));
- List<Attribute> attrList =
- e.getAttribute(DirectoryServer.getAttributeTypeOrDefault("o"));
+ List<Attribute> attrList = e.getAttribute(DirectoryServer.getAttributeTypeOrDefault("o"));
assertEquals(countValues(attrList), 1);
LDAPAttribute attr = newLDAPAttribute("o;lang-en-us", "test");
@@ -1879,7 +1878,6 @@
Entry e = DirectoryServer.getEntry(DN.valueOf("uid=test.user," + baseDN));
List<Attribute> attrList =
e.getAttribute(DirectoryServer.getAttributeTypeOrDefault("employeenumber"));
- assertNotNull(attrList);
assertIntegerValueExists(attrList, 2);
}
@@ -1918,7 +1916,6 @@
Entry e = DirectoryServer.getEntry(DN.valueOf("uid=test.user," + baseDN));
List<Attribute> attrList =
e.getAttribute(DirectoryServer.getAttributeTypeOrDefault("employeenumber"));
- assertNotNull(attrList);
assertIntegerValueExists(attrList, 11);
}
@@ -1957,7 +1954,6 @@
Entry e = DirectoryServer.getEntry(DN.valueOf("uid=test.user," + baseDN));
List<Attribute> attrList =
e.getAttribute(DirectoryServer.getAttributeTypeOrDefault("employeenumber"));
- assertNotNull(attrList);
assertIntegerValueExists(attrList, 0);
}
@@ -3423,7 +3419,6 @@
List<Attribute> attrList =
e.getAttribute(DirectoryServer.getAttributeTypeOrDefault("userpassword"));
- assertNotNull(attrList);
String passwd = null;
for (Attribute a : attrList)
@@ -3490,7 +3485,6 @@
e = DirectoryServer.getEntry(DN.valueOf("cn=Test User,o=test"));
List<Attribute> attrList = e.getAttribute("userpassword");
- assertNotNull(attrList);
assertEquals(attrList.size(), 1);
assertFalse(attrList.get(0).hasOptions());
assertEquals(attrList.get(0).size(), 1);
@@ -3531,7 +3525,6 @@
e = DirectoryServer.getEntry(DN.valueOf("cn=Test User,o=test"));
List<Attribute> attrList = e.getAttribute("userpassword");
- assertNotNull(attrList);
assertEquals(attrList.size(), 1);
assertFalse(attrList.get(0).hasOptions());
assertEquals(attrList.get(0).size(), 1);
@@ -3568,7 +3561,6 @@
Entry e = DirectoryServer.getEntry(DN.valueOf("cn=Test User,o=test"));
List<Attribute> attrList = e.getAttribute("userpassword");
- assertNotNull(attrList);
assertEquals(attrList.size(), 1);
assertFalse(attrList.get(0).hasOptions());
assertEquals(attrList.get(0).size(), 1);
@@ -3605,7 +3597,6 @@
Entry e = DirectoryServer.getEntry(DN.valueOf("cn=Test User,o=test"));
List<Attribute> attrList = e.getAttribute("userpassword");
- assertNotNull(attrList);
assertEquals(attrList.size(), 1);
assertFalse(attrList.get(0).hasOptions());
assertEquals(attrList.get(0).size(), 1);
@@ -3660,10 +3651,8 @@
retrieveSuccessfulOperationElements(modifyOperation);
Entry e = DirectoryServer.getEntry(DN.valueOf("uid=test.user," + baseDN));
- List<Attribute> attrList =
- e.getAttribute(DirectoryServer.getAttributeTypeOrDefault("usercertificate"));
- assertNotNull(attrList);
- assertEquals(attrList.size(), 1);
+ List<Attribute> attrList = e.getAttribute(DirectoryServer.getAttributeTypeOrDefault("usercertificate"));
+ assertThat(attrList).hasSize(1);
Attribute a = attrList.get(0);
assertTrue(a.hasOption("binary"));
assertEquals(a.size(), 1);
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/core/SearchOperationTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/core/SearchOperationTestCase.java
index 2be4616..6abe5af 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/core/SearchOperationTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/core/SearchOperationTestCase.java
@@ -988,14 +988,14 @@
if (stripVirtualAttributes)
{
- if (attrList != null)
+ if (!attrList.isEmpty())
{
messages.add("Unexpected virtual attribute: " + attrType);
}
}
else if (filterType == AttributeFilterType.DEFAULT)
{
- if (attrList != null)
+ if (!attrList.isEmpty())
{
messages.add("Unexpected operational attribute: " + attrType);
}
@@ -1003,14 +1003,14 @@
else if ("ismemberof".equals(attrType))
{
// isMemberOf should never be returned as user is not in any groups.
- if (attrList != null)
+ if (!attrList.isEmpty())
{
messages.add("Unexpected isMemberOf attribute");
}
}
else
{
- if (attrList == null)
+ if (attrList.isEmpty())
{
messages.add("Missing virtual attribute: " + attrType);
}
@@ -1045,14 +1045,14 @@
if (stripRealAttributes)
{
- if (attrList != null)
+ if (!attrList.isEmpty())
{
messages.add("Unexpected real attribute: " + attrType);
}
}
else
{
- if (attrList == null)
+ if (attrList.isEmpty())
{
messages.add("Missing real attribute: " + attrType);
}
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/core/SubentryManagerTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/core/SubentryManagerTestCase.java
index 2ef5d34..4f503c1 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/core/SubentryManagerTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/core/SubentryManagerTestCase.java
@@ -239,15 +239,14 @@
assertNotNull(e);
List<Attribute> description = e.getAttribute("description");
- assertNull(description);
+ assertThat(description).isEmpty();
// Collective user will inherit the collective description attribute.
e = DirectoryServer.getEntry(DN.valueOf("uid=collective user,ou=people,o=test"));
assertNotNull(e);
description = e.getAttribute("description");
- assertNotNull(description);
- assertEquals(description.size(), 1);
+ assertThat(description).hasSize(1);
Attribute attribute = description.get(0);
assertEquals(attribute.size(), 1);
assertFalse(attribute.hasOptions());
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/core/TestModifyDNOperation.java b/opendj-server-legacy/src/test/java/org/opends/server/core/TestModifyDNOperation.java
index 2de167e..895fa19 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/core/TestModifyDNOperation.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/core/TestModifyDNOperation.java
@@ -69,6 +69,7 @@
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
+import static org.assertj.core.api.Assertions.*;
import static org.forgerock.opendj.ldap.ResultCode.*;
import static org.opends.server.protocols.internal.InternalClientConnection.*;
import static org.opends.server.util.ServerConstants.*;
@@ -432,7 +433,7 @@
{
AttributeType at = DirectoryServer.getAttributeTypeOrNull(attrName);
List<Attribute> attrList = newEntry.getAttribute(at);
- assertEquals(attrList.size(), 1);
+ assertThat(attrList).hasSize(1);
// Because deleteOldRDN is true, the values from RDN and the entry have to be identical
ByteString valueFromEntry = attrList.get(0).iterator().next();
@@ -561,7 +562,7 @@
runModifyDNOperation(oldEntryDN, "cn=Aaccf Amar Test", true, "dc=example,dc=com");
assertSuccess(modifyDNOperation);
Entry entry = assertCnAttrValues(newEntryDN, oldEntryDN);
- assertNull(entry.getAttribute("uid"));
+ assertThat(entry.getAttribute("uid")).isEmpty();
examineCompletedOPNoExtraPluginCounts(modifyDNOperation);
InvocationCounterPlugin.resetAllCounters();
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/extensions/EntryDNVirtualAttributeProviderTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/extensions/EntryDNVirtualAttributeProviderTestCase.java
index 6d5c1e5..fb1f769 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/extensions/EntryDNVirtualAttributeProviderTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/extensions/EntryDNVirtualAttributeProviderTestCase.java
@@ -40,12 +40,18 @@
import org.opends.server.protocols.internal.InternalSearchOperation;
import org.opends.server.protocols.internal.SearchRequest;
import org.opends.server.protocols.ldap.LDAPControl;
-import org.opends.server.types.*;
+import org.opends.server.types.Attribute;
+import org.opends.server.types.AttributeType;
+import org.opends.server.types.DN;
+import org.opends.server.types.Entry;
+import org.opends.server.types.SearchFilter;
+import org.opends.server.types.VirtualAttributeRule;
import org.opends.server.workflowelement.localbackend.LocalBackendSearchOperation;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
+import static org.assertj.core.api.Assertions.*;
import static org.opends.server.protocols.internal.InternalClientConnection.*;
import static org.opends.server.protocols.internal.Requests.*;
import static org.opends.server.util.CollectionUtils.*;
@@ -128,8 +134,7 @@
assertTrue(e.hasAttribute(entryDNType));
List<Attribute> attrList = e.getAttribute(entryDNType);
- assertNotNull(attrList);
- assertFalse(attrList.isEmpty());
+ assertThat(attrList).isNotEmpty();
for (Attribute a : attrList)
{
assertFalse(a.isEmpty());
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/extensions/EntryUUIDVirtualAttributeProviderTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/extensions/EntryUUIDVirtualAttributeProviderTestCase.java
index 417a51f..3916712 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/extensions/EntryUUIDVirtualAttributeProviderTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/extensions/EntryUUIDVirtualAttributeProviderTestCase.java
@@ -38,11 +38,17 @@
import org.opends.server.protocols.internal.InternalSearchOperation;
import org.opends.server.protocols.internal.SearchRequest;
import org.opends.server.protocols.ldap.LDAPControl;
-import org.opends.server.types.*;
+import org.opends.server.types.Attribute;
+import org.opends.server.types.AttributeType;
+import org.opends.server.types.DN;
+import org.opends.server.types.Entry;
+import org.opends.server.types.SearchFilter;
+import org.opends.server.types.VirtualAttributeRule;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
+import static org.assertj.core.api.Assertions.*;
import static org.opends.server.protocols.internal.InternalClientConnection.*;
import static org.opends.server.protocols.internal.Requests.*;
import static org.opends.server.util.ServerConstants.*;
@@ -123,8 +129,7 @@
assertTrue(e.hasAttribute(entryUUIDType));
List<Attribute> attrList = e.getAttribute(entryUUIDType);
- assertNotNull(attrList);
- assertFalse(attrList.isEmpty());
+ assertThat(attrList).isNotEmpty();
for (Attribute a : attrList)
{
assertFalse(a.isEmpty());
@@ -159,8 +164,7 @@
assertTrue(e.hasAttribute(entryUUIDType));
List<Attribute> attrList = e.getAttribute(entryUUIDType);
- assertNotNull(attrList);
- assertFalse(attrList.isEmpty());
+ assertThat(attrList).isNotEmpty();
for (Attribute a : attrList)
{
assertFalse(a.isEmpty());
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/extensions/GoverningStructureRuleVirtualAttributeProviderTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/extensions/GoverningStructureRuleVirtualAttributeProviderTestCase.java
index d87761f..eebf3c3 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/extensions/GoverningStructureRuleVirtualAttributeProviderTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/extensions/GoverningStructureRuleVirtualAttributeProviderTestCase.java
@@ -50,6 +50,7 @@
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
+import static org.assertj.core.api.Assertions.*;
import static org.opends.server.protocols.internal.InternalClientConnection.*;
import static org.opends.server.protocols.internal.Requests.*;
import static org.opends.server.util.ServerConstants.*;
@@ -184,8 +185,7 @@
assertTrue(e.hasAttribute(governingStructureRuleType));
List<Attribute> attrList = e.getAttribute(governingStructureRuleType);
- assertNotNull(attrList);
- assertFalse(attrList.isEmpty());
+ assertThat(attrList).isNotEmpty();
for (Attribute a : attrList)
{
assertFalse(a.isEmpty());
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/extensions/HasSubordinatesVirtualAttributeProviderTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/extensions/HasSubordinatesVirtualAttributeProviderTestCase.java
index c096f7d..59a8eed 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/extensions/HasSubordinatesVirtualAttributeProviderTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/extensions/HasSubordinatesVirtualAttributeProviderTestCase.java
@@ -46,6 +46,7 @@
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
+import static org.assertj.core.api.Assertions.*;
import static org.opends.server.protocols.internal.InternalClientConnection.*;
import static org.opends.server.protocols.internal.Requests.*;
import static org.opends.server.util.ServerConstants.*;
@@ -222,8 +223,7 @@
assertTrue(e.hasAttribute(hasSubordinatesType));
List<Attribute> attrList = e.getAttribute(hasSubordinatesType);
- assertNotNull(attrList);
- assertFalse(attrList.isEmpty());
+ assertThat(attrList).isNotEmpty();
for (Attribute a : attrList)
{
assertFalse(a.isEmpty());
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/extensions/NumSubordinatesVirtualAttributeProviderTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/extensions/NumSubordinatesVirtualAttributeProviderTestCase.java
index ec63963..d986f3c 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/extensions/NumSubordinatesVirtualAttributeProviderTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/extensions/NumSubordinatesVirtualAttributeProviderTestCase.java
@@ -44,6 +44,7 @@
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
+import static org.assertj.core.api.Assertions.*;
import static org.opends.server.protocols.internal.InternalClientConnection.*;
import static org.opends.server.protocols.internal.Requests.*;
import static org.opends.server.util.ServerConstants.*;
@@ -220,8 +221,7 @@
assertTrue(e.hasAttribute(numSubordinatesType));
List<Attribute> attrList = e.getAttribute(numSubordinatesType);
- assertNotNull(attrList);
- assertFalse(attrList.isEmpty());
+ assertThat(attrList).isNotEmpty();
for (Attribute a : attrList)
{
assertFalse(a.isEmpty());
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/extensions/PasswordExpirationTimeVirtualAttributeProviderTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/extensions/PasswordExpirationTimeVirtualAttributeProviderTestCase.java
index 879bf75..e300c43 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/extensions/PasswordExpirationTimeVirtualAttributeProviderTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/extensions/PasswordExpirationTimeVirtualAttributeProviderTestCase.java
@@ -215,7 +215,6 @@
assertNotNull(entry);
List<Attribute> attrs = entry.getAttribute(attributeName);
- assertNotNull(attrs);
assertEquals(attrs.size(), 1);
Attribute attr = attrs.get(0);
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/extensions/StructuralObjectClassVirtualAttributeProviderTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/extensions/StructuralObjectClassVirtualAttributeProviderTestCase.java
index 01f32d3..e80b829 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/extensions/StructuralObjectClassVirtualAttributeProviderTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/extensions/StructuralObjectClassVirtualAttributeProviderTestCase.java
@@ -47,6 +47,7 @@
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
+import static org.assertj.core.api.Assertions.*;
import static org.opends.server.protocols.internal.InternalClientConnection.*;
import static org.opends.server.protocols.internal.Requests.*;
import static org.opends.server.util.ServerConstants.*;
@@ -150,8 +151,7 @@
assertTrue(e.hasAttribute(structuralObjectClassType));
List<Attribute> attrList = e.getAttribute(structuralObjectClassType);
- assertNotNull(attrList);
- assertFalse(attrList.isEmpty());
+ assertThat(attrList).isNotEmpty();
for (Attribute a : attrList)
{
assertFalse(a.isEmpty());
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/extensions/SubschemaSubentryVirtualAttributeProviderTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/extensions/SubschemaSubentryVirtualAttributeProviderTestCase.java
index 346b865..f850466 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/extensions/SubschemaSubentryVirtualAttributeProviderTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/extensions/SubschemaSubentryVirtualAttributeProviderTestCase.java
@@ -47,6 +47,7 @@
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
+import static org.assertj.core.api.Assertions.*;
import static org.opends.server.protocols.internal.InternalClientConnection.*;
import static org.opends.server.protocols.internal.Requests.*;
import static org.opends.server.util.ServerConstants.*;
@@ -128,8 +129,7 @@
assertTrue(e.hasAttribute(subschemaSubentryType));
List<Attribute> attrList = e.getAttribute(subschemaSubentryType);
- assertNotNull(attrList);
- assertFalse(attrList.isEmpty());
+ assertThat(attrList).isNotEmpty();
for (Attribute a : attrList)
{
assertFalse(a.isEmpty());
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/extensions/UserDefinedVirtualAttributeProviderTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/extensions/UserDefinedVirtualAttributeProviderTestCase.java
index 8b791ec..d4714c3 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/extensions/UserDefinedVirtualAttributeProviderTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/extensions/UserDefinedVirtualAttributeProviderTestCase.java
@@ -246,10 +246,7 @@
final SearchRequest request = newSearchRequest(DN.valueOf(userDN), SearchScope.BASE_OBJECT);
InternalSearchOperation searchOperation = conn.processSearch(request);
- List<Attribute> attrList =
- searchOperation.getSearchEntries().get(0).getAttribute(
- descriptionType);
- assertNotNull(attrList);
+ List<Attribute> attrList = searchOperation.getSearchEntries().get(0).getAttribute(descriptionType);
assertEquals(attrList.size(), 1);
Attribute attr = attrList.get(0);
@@ -314,10 +311,7 @@
final SearchRequest request = newSearchRequest(DN.valueOf(userDN), SearchScope.BASE_OBJECT);
InternalSearchOperation searchOperation = conn.processSearch(request);
- List<Attribute> attrList =
- searchOperation.getSearchEntries().get(0).getAttribute(
- descriptionType);
- assertNotNull(attrList);
+ List<Attribute> attrList = searchOperation.getSearchEntries().get(0).getAttribute(descriptionType);
assertEquals(attrList.size(), 1);
Attribute attr = attrList.get(0);
@@ -383,10 +377,7 @@
final SearchRequest request = newSearchRequest(DN.valueOf(userDN), SearchScope.BASE_OBJECT);
InternalSearchOperation searchOperation = conn.processSearch(request);
- List<Attribute> attrList =
- searchOperation.getSearchEntries().get(0).getAttribute(
- descriptionType);
- assertNotNull(attrList);
+ List<Attribute> attrList = searchOperation.getSearchEntries().get(0).getAttribute(descriptionType);
assertEquals(attrList.size(), 1);
Attribute attr = attrList.get(0);
@@ -451,10 +442,7 @@
final SearchRequest request = newSearchRequest(DN.valueOf(userDN), SearchScope.BASE_OBJECT);
InternalSearchOperation searchOperation = conn.processSearch(request);
- List<Attribute> attrList =
- searchOperation.getSearchEntries().get(0).getAttribute(
- descriptionType);
- assertNotNull(attrList);
+ List<Attribute> attrList = searchOperation.getSearchEntries().get(0).getAttribute(descriptionType);
assertEquals(attrList.size(), 1);
Attribute attr = attrList.get(0);
@@ -518,10 +506,7 @@
final SearchRequest request = newSearchRequest(DN.valueOf(userDN), SearchScope.BASE_OBJECT);
InternalSearchOperation searchOperation = conn.processSearch(request);
- List<Attribute> attrList =
- searchOperation.getSearchEntries().get(0).getAttribute(
- descriptionType);
- assertNotNull(attrList);
+ List<Attribute> attrList = searchOperation.getSearchEntries().get(0).getAttribute(descriptionType);
assertEquals(attrList.size(), 1);
Attribute a = attrList.get(0);
@@ -595,7 +580,6 @@
InternalSearchOperation searchOperation = conn.processSearch(request);
List<Attribute> attrList = searchOperation.getSearchEntries().get(0).getAttribute(descriptionType);
- assertNotNull(attrList);
assertEquals(attrList.size(), 1);
Attribute a = attrList.get(0);
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/plugins/EntryUUIDPluginTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/plugins/EntryUUIDPluginTestCase.java
index 0f1a3e8..ccf090d 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/plugins/EntryUUIDPluginTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/plugins/EntryUUIDPluginTestCase.java
@@ -26,7 +26,7 @@
*/
package org.opends.server.plugins;
-
+import static org.assertj.core.api.Assertions.*;
import java.io.ByteArrayInputStream;
import java.util.ArrayList;
@@ -49,8 +49,6 @@
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
-import static org.testng.Assert.*;
-
/**
* This class defines a set of tests for the
* org.opends.server.plugins.EntryUUIDPlugin class.
@@ -274,7 +272,7 @@
DirectoryServer.getPluginConfigManager().getRegisteredPlugin(dn);
plugin.doLDIFImport(importConfig, e);
- assertNotNull(e.getAttribute("entryuuid"));
+ assertThat(e.getAttribute("entryuuid")).isNotEmpty();
}
@@ -315,7 +313,7 @@
DirectoryServer.getPluginConfigManager().getRegisteredPlugin(dn);
plugin.doLDIFImport(importConfig, e);
- assertNotNull(e.getAttribute("entryuuid"));
+ assertThat(e.getAttribute("entryuuid")).isNotEmpty();
}
@@ -334,7 +332,7 @@
"objectClass: top",
"objectClass: device",
"cn: test");
- assertNotNull(e.getAttribute("entryuuid"));
+ assertThat(e.getAttribute("entryuuid")).isNotEmpty();
}
@@ -356,7 +354,6 @@
"objectClass: device",
"cn: test",
"entryUUID: " + UUID.randomUUID());
- assertNotNull(e.getAttribute("entryuuid"));
+ assertThat(e.getAttribute("entryuuid")).isNotEmpty();
}
}
-
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/plugins/LDAPADListPluginTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/plugins/LDAPADListPluginTestCase.java
index c9eb3e7..2f713bd 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/plugins/LDAPADListPluginTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/plugins/LDAPADListPluginTestCase.java
@@ -26,6 +26,11 @@
*/
package org.opends.server.plugins;
+import static org.assertj.core.api.Assertions.*;
+import static org.opends.server.protocols.internal.InternalClientConnection.*;
+import static org.opends.server.protocols.internal.Requests.*;
+import static org.testng.Assert.*;
+
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
@@ -46,10 +51,6 @@
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
-import static org.opends.server.protocols.internal.InternalClientConnection.*;
-import static org.opends.server.protocols.internal.Requests.*;
-import static org.testng.Assert.*;
-
/**
* This class defines a set of tests for the
* org.opends.server.plugins.LDAPADListPlugin class.
@@ -280,7 +281,6 @@
assertFalse(searchOperation.getSearchEntries().isEmpty());
Entry e = searchOperation.getSearchEntries().get(0);
- assertNotNull(e.getAttribute("o"));
+ assertThat(e.getAttribute("o")).isNotEmpty();
}
}
-
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/plugins/LastModPluginTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/plugins/LastModPluginTestCase.java
index 07ab0e7..81f6e2d 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/plugins/LastModPluginTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/plugins/LastModPluginTestCase.java
@@ -26,6 +26,10 @@
*/
package org.opends.server.plugins;
+import static org.assertj.core.api.Assertions.*;
+import static org.opends.server.protocols.internal.InternalClientConnection.*;
+import static org.testng.Assert.*;
+
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
@@ -53,9 +57,6 @@
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
-import static org.opends.server.protocols.internal.InternalClientConnection.*;
-import static org.testng.Assert.*;
-
/**
* This class defines a set of tests for the
* org.opends.server.plugins.LastModPlugin class.
@@ -285,8 +286,8 @@
"objectClass: top",
"objectClass: device",
"cn: test");
- assertNotNull(e.getAttribute("creatorsname"));
- assertNotNull(e.getAttribute("createtimestamp"));
+ assertThat(e.getAttribute("creatorsname")).isNotEmpty();
+ assertThat(e.getAttribute("createtimestamp")).isNotEmpty();
}
@@ -314,8 +315,8 @@
Entry e = DirectoryConfig.getEntry(DN.valueOf("o=test"));
assertNotNull(e);
- assertNotNull(e.getAttribute("modifiersname"));
- assertNotNull(e.getAttribute("modifytimestamp"));
+ assertThat(e.getAttribute("modifiersname")).isNotEmpty();
+ assertThat(e.getAttribute("modifytimestamp")).isNotEmpty();
}
@@ -341,8 +342,7 @@
e = DirectoryConfig.getEntry(DN.valueOf("cn=test2,o=test"));
assertNotNull(e);
- assertNotNull(e.getAttribute("modifiersname"));
- assertNotNull(e.getAttribute("modifytimestamp"));
+ assertThat(e.getAttribute("modifiersname")).isNotEmpty();
+ assertThat(e.getAttribute("modifytimestamp")).isNotEmpty();
}
}
-
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/plugins/SambaPasswordPluginTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/plugins/SambaPasswordPluginTestCase.java
index e074e8e..c4c422c 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/plugins/SambaPasswordPluginTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/plugins/SambaPasswordPluginTestCase.java
@@ -26,6 +26,7 @@
*/
package org.opends.server.plugins;
+import static org.assertj.core.api.Assertions.*;
import static org.opends.server.protocols.internal.InternalClientConnection.*;
import static org.opends.server.util.CollectionUtils.*;
import static org.opends.server.util.StaticUtils.*;
@@ -240,7 +241,6 @@
assertNotNull(entry);
List<Attribute> sambaAttribute = entry.getAttribute("sambantpassword");
- assertNotNull(sambaAttribute);
boolean foundNTPassword = false;
for (Attribute a : sambaAttribute)
{
@@ -253,7 +253,6 @@
assertTrue(foundNTPassword, "NT password not found in test entry");
sambaAttribute = entry.getAttribute("sambalmpassword");
- assertNotNull(sambaAttribute);
boolean foundLMPassword = false;
for (Attribute a : sambaAttribute)
{
@@ -346,8 +345,8 @@
Entry entry = DirectoryServer.getEntry(testEntry.getName());
assertNotNull(entry);
- assertNull(entry.getAttribute("sambantpassword"));
- assertNull(entry.getAttribute("sambalmpassword"));
+ assertThat(entry.getAttribute("sambantpassword")).isEmpty();
+ assertThat(entry.getAttribute("sambalmpassword")).isEmpty();
TestCaseUtils.deleteEntry(entry);
}
@@ -546,14 +545,8 @@
Entry entry = DirectoryServer.getEntry(testEntry.getName());
assertNotNull(entry);
-
- List<Attribute> sambaAttribute = entry.getAttribute("sambantpassword");
-
- assertNull(sambaAttribute);
-
- sambaAttribute = entry.getAttribute("sambalmpassword");
-
- assertNull(sambaAttribute);
+ assertThat(entry.getAttribute("sambantpassword")).isEmpty();
+ assertThat(entry.getAttribute("sambalmpassword")).isEmpty();
TestCaseUtils.deleteEntry(entry);
}
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/replication/UpdateOperationTest.java b/opendj-server-legacy/src/test/java/org/opends/server/replication/UpdateOperationTest.java
index c8e9306..a615d4d 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/replication/UpdateOperationTest.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/replication/UpdateOperationTest.java
@@ -1080,7 +1080,7 @@
*/
private boolean assertConflictAttributeExists(Entry entry)
{
- return entry.getAttribute("ds-sync-confict") != null;
+ return !entry.getAttribute("ds-sync-confict").isEmpty();
}
@DataProvider(name="assured")
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/AssuredReplicationPluginTest.java b/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/AssuredReplicationPluginTest.java
index 86ae1e1..d469f42 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/AssuredReplicationPluginTest.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/AssuredReplicationPluginTest.java
@@ -1463,7 +1463,7 @@
}
List<Attribute> attrs = entry.getAttribute(assuredAttr);
- if (attrs == null || attrs.isEmpty())
+ if (attrs.isEmpty())
{
return Collections.emptyMap();
}
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/AttrHistoricalMultipleTest.java b/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/AttrHistoricalMultipleTest.java
index 520fd4b..5b27a08 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/AttrHistoricalMultipleTest.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/AttrHistoricalMultipleTest.java
@@ -441,7 +441,7 @@
private List<ByteString> getValues(List<Attribute> attributes)
{
- if (attributes != null)
+ if (!attributes.isEmpty())
{
assertThat(attributes).hasSize(1);
return getValues(attributes.get(0));
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/AttrHistoricalSingleTest.java b/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/AttrHistoricalSingleTest.java
index 7c834cf..cec073d 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/AttrHistoricalSingleTest.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/AttrHistoricalSingleTest.java
@@ -368,7 +368,7 @@
private ByteString getActualValue(List<Attribute> attributes)
{
- if (attributes != null)
+ if (!attributes.isEmpty())
{
assertThat(attributes).hasSize(1);
Attribute attribute = attributes.get(0);
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/FractionalReplicationTest.java b/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/FractionalReplicationTest.java
index d279a51..fbe6bf3 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/FractionalReplicationTest.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/FractionalReplicationTest.java
@@ -50,6 +50,8 @@
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
+import static org.testng.Assert.fail;
+import static org.assertj.core.api.Assertions.*;
import static org.opends.server.TestCaseUtils.*;
import static org.opends.server.util.CollectionUtils.*;
import static org.testng.Assert.*;
@@ -547,9 +549,8 @@
AttributeType synchronizationGenIDType =
DirectoryServer.getAttributeTypeOrNull(REPLICATION_GENERATION_ID);
- List<Attribute> attrs =
- resultEntry.getAttribute(synchronizationGenIDType);
- if (attrs != null)
+ List<Attribute> attrs = resultEntry.getAttribute(synchronizationGenIDType);
+ if (!attrs.isEmpty())
{
Attribute attr = attrs.get(0);
if (attr.size() == 1)
@@ -774,24 +775,17 @@
* Check that the provided entry has a single value attribute which has the
* expected attribute value
*/
- private static void checkEntryAttributeValue(Entry entry, String attributeName,
- String attributeValue)
+ private static void checkEntryAttributeValue(Entry entry, String attributeName, String attributeValue)
{
List<Attribute> attrs = entry.getAttribute(attributeName.toLowerCase());
- assertNotNull(attrs, "Was expecting attribute " + attributeName + "=" +
- attributeValue + " but got no attribute");
- assertEquals(attrs.size(), 1);
+ assertThat(attrs).as("Was expecting attribute " + attributeName + "=" + attributeValue).hasSize(1);
Attribute attr = attrs.get(0);
- assertNotNull(attr);
Iterator<ByteString> attrValues = attr.iterator();
- assertNotNull(attrValues);
assertTrue(attrValues.hasNext());
ByteString attrValue = attrValues.next();
- assertNotNull(attrValue);
assertFalse(attrValues.hasNext());
assertEquals(attrValue.toString(), attributeValue, "Was expecting attribute " +
attributeName + "=" + attributeValue + " but got value: " + attrValue);
-
}
/**
@@ -1472,17 +1466,14 @@
replicationDomain.publish(modDnMsg);
- /*
- * check that entry has been renamed and has only attribute left in the
- * new RDN
- */
+ // check that entry has been renamed and has only attribute left in the new RDN
newEntry = getEntry(newEntryDn, TIMEOUT, true);
assertNotNull(newEntry);
assertEquals(newEntryDn, newEntry.getName());
objectClass = DirectoryServer.getObjectClass("inetOrgPerson".toLowerCase());
assertTrue(newEntry.hasObjectClass(objectClass));
checkEntryAttributeValue(newEntry, "displayName", "ValueToBeKept");
- assertNull(newEntry.getAttribute("description"));
+ assertThat(newEntry.getAttribute("description")).isEmpty();
}
finally
{
@@ -1553,17 +1544,14 @@
replicationDomain.publish(modDnMsg);
- /*
- * check that entry has been renamed and has only attribute left in the
- * new RDN
- */
+ // check that entry has been renamed and has only attribute left in the * new RDN
newEntry = getEntry(newEntryDn, TIMEOUT, true);
assertNotNull(newEntry);
assertEquals(newEntryDn, newEntry.getName());
objectClass = DirectoryServer.getObjectClass("inetOrgPerson".toLowerCase());
assertTrue(newEntry.hasObjectClass(objectClass));
checkEntryAttributeValue(newEntry, "displayName", "ValueToBeKept");
- assertNull(newEntry.getAttribute("description"));
+ assertThat(newEntry.getAttribute("description")).isEmpty();
}
finally
{
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/ModifyConflictTest.java b/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/ModifyConflictTest.java
index 4c2a84c..db48a96 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/ModifyConflictTest.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/ModifyConflictTest.java
@@ -1244,8 +1244,7 @@
testModify(entry, hist, 1, true, newModification(DELETE, DISPLAYNAME, "aValue"));
// The entry should have no value
- List<Attribute> attrs = entry.getAttribute(DISPLAYNAME);
- assertNull(attrs);
+ assertThat(entry.getAttribute(DISPLAYNAME)).isEmpty();
}
/**
@@ -1275,8 +1274,7 @@
assertEquals(hist.encodeAndPurge(), attr);
// The entry should have no value
- List<Attribute> attrs = entry.getAttribute(DISPLAYNAME);
- assertNull(attrs);
+ assertThat(entry.getAttribute(DISPLAYNAME)).isEmpty();
}
/**
@@ -1318,8 +1316,7 @@
assertEquals(hist.encodeAndPurge(), attrDel);
// The entry should have no value
- List<Attribute> attrs = entry.getAttribute(DISPLAYNAME);
- assertNull(attrs);
+ assertThat(entry.getAttribute(DISPLAYNAME)).isEmpty();
}
/**
@@ -1364,8 +1361,7 @@
// The entry should have no value
List<Attribute> attrs = entry.getAttribute(DESCRIPTION);
- attr = Attributes.create(DESCRIPTION, "value2", "value3", "value4");
- assertEquals(attrs.get(0), attr);
+ assertEquals(attrs.get(0), Attributes.create(DESCRIPTION, "value2", "value3", "value4"));
}
/**
@@ -1412,8 +1408,7 @@
// The entry should have no value
List<Attribute> attrs = entry.getAttribute(DESCRIPTION);
- attr = Attributes.create(DESCRIPTION, "value3", "value4");
- assertEquals(attrs.get(0), attr);
+ assertEquals(attrs.get(0), Attributes.create(DESCRIPTION, "value3", "value4"));
}
/**
@@ -1455,8 +1450,7 @@
assertEquals(hist.encodeAndPurge(), attrDel);
// The entry should have no value
- List<Attribute> attrs = entry.getAttribute(DISPLAYNAME);
- assertNull(attrs);
+ assertThat(entry.getAttribute(DISPLAYNAME)).isEmpty();
}
/**
@@ -1486,8 +1480,7 @@
assertEquals(hist.encodeAndPurge(), attr);
// The entry should have no value
- List<Attribute> attrs = entry.getAttribute(DISPLAYNAME);
- assertNull(attrs);
+ assertThat(entry.getAttribute(DISPLAYNAME)).isEmpty();
}
/**
@@ -1517,8 +1510,7 @@
assertEquals(hist.encodeAndPurge(), attr);
// The entry should have no value
- List<Attribute> attrs = entry.getAttribute(DISPLAYNAME);
- assertNull(attrs);
+ assertThat(entry.getAttribute(DISPLAYNAME)).isEmpty();
}
/**
@@ -1557,8 +1549,7 @@
assertEquals(hist.encodeAndPurge(), attrDel);
// The entry should have no value
- List<Attribute> attrs = entry.getAttribute(DISPLAYNAME);
- assertNull(attrs);
+ assertThat(entry.getAttribute(DISPLAYNAME)).isEmpty();
}
/**
@@ -1597,8 +1588,7 @@
assertEquals(hist.encodeAndPurge(), attrDel);
// The entry should have no value
- List<Attribute> attrs = entry.getAttribute(DISPLAYNAME);
- assertNull(attrs);
+ assertThat(entry.getAttribute(DISPLAYNAME)).isEmpty();
}
/**
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/NamingConflictTest.java b/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/NamingConflictTest.java
index b614b9a..d7f4e82 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/NamingConflictTest.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/NamingConflictTest.java
@@ -50,6 +50,7 @@
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
+import static org.assertj.core.api.Assertions.*;
import static org.opends.server.TestCaseUtils.*;
import static org.opends.server.core.DirectoryServer.*;
import static org.opends.server.protocols.internal.InternalClientConnection.*;
@@ -158,7 +159,7 @@
assertEquals(getEntryUUID(resultEntry.getName()),
"c9cb8c3c-615a-4122-865d-50323aaaed48",
"The wrong entry has been renamed");
- assertNull(resultEntry.getAttribute(LDAPReplicationDomain.DS_SYNC_CONFLICT));
+ assertThat(resultEntry.getAttribute(LDAPReplicationDomain.DS_SYNC_CONFLICT)).isEmpty();
}
private AddMsg addMsg(Entry entry, CSN csn, String parentUUID, String childUUID)
@@ -199,7 +200,7 @@
assertEquals(getEntryUUID(resultEntry.getName()),
"c9cb8c3c-615a-4122-865d-50323aaaed48",
"The wrong entry has been renamed");
- assertNull(resultEntry.getAttribute(LDAPReplicationDomain.DS_SYNC_CONFLICT));
+ assertThat(resultEntry.getAttribute(LDAPReplicationDomain.DS_SYNC_CONFLICT)).isEmpty();
}
private Entry createAndAddEntry(String commonName) throws Exception
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/schema/GenericSchemaTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/schema/GenericSchemaTestCase.java
index 92408a3..0da929f 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/schema/GenericSchemaTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/schema/GenericSchemaTestCase.java
@@ -27,35 +27,29 @@
*/
package org.opends.server.schema;
-
-
import java.io.File;
import java.util.List;
-import java.util.TreeSet;
import java.util.StringTokenizer;
+import java.util.TreeSet;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-import org.opends.server.TestCaseUtils;
-import org.forgerock.opendj.ldap.schema.Syntax;
+import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.schema.MatchingRule;
+import org.forgerock.opendj.ldap.schema.Syntax;
+import org.opends.server.TestCaseUtils;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
-import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.types.Entry;
import org.opends.server.types.LDIFImportConfig;
import org.opends.server.types.NameForm;
import org.opends.server.types.ObjectClass;
import org.opends.server.types.Schema;
import org.opends.server.util.LDIFReader;
-
-import static org.testng.Assert.*;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
import static org.opends.server.util.ServerConstants.*;
-
-
+import static org.testng.Assert.*;
/**
* This class defines a set of generic tests that may be used to examine the
@@ -69,6 +63,7 @@
*
* @throws Exception If an unexpected problem occurs.
*/
+ @Override
@BeforeClass
public void setUp()
throws Exception
@@ -185,7 +180,7 @@
AttributeType attrType = DirectoryServer.getAttributeTypeOrNull("attributetypes");
assertNotNull(attrType);
List<Attribute> attrList = e.getAttribute(attrType);
- if (attrList == null)
+ if (attrList.isEmpty())
{
// No attribute types in the schema file. This is OK.
continue;
@@ -260,7 +255,7 @@
AttributeType attrType = DirectoryServer.getAttributeTypeOrNull("objectclasses");
assertNotNull(attrType);
List<Attribute> attrList = e.getAttribute(attrType);
- if (attrList == null)
+ if (attrList.isEmpty())
{
// No attribute types in the schema file. This is OK.
continue;
@@ -334,7 +329,7 @@
AttributeType attrType = DirectoryServer.getAttributeTypeOrNull("nameforms");
assertNotNull(attrType);
List<Attribute> attrList = e.getAttribute(attrType);
- if (attrList == null)
+ if (attrList.isEmpty())
{
// No attribute types in the schema file. This is OK.
continue;
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/tasks/DummyTask.java b/opendj-server-legacy/src/test/java/org/opends/server/tasks/DummyTask.java
index 04a2f4b..fc02ed3 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/tasks/DummyTask.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/tasks/DummyTask.java
@@ -58,7 +58,6 @@
return LocalizableMessage.raw("Dummy");
}
- /** {@inheritDoc} */
@Override
public void initializeTask()
throws DirectoryException
@@ -69,16 +68,11 @@
Entry taskEntry = getTaskEntry();
if (taskEntry != null)
{
- List<Attribute> attrList =
- taskEntry.getAttribute("ds-task-dummy-sleep-time");
- if (attrList != null)
+ for (Attribute a : taskEntry.getAttribute("ds-task-dummy-sleep-time"))
{
- for (Attribute a : attrList)
+ for (ByteString v : a)
{
- for (ByteString v : a)
- {
- sleepTime = Long.parseLong(v.toString());
- }
+ sleepTime = Long.parseLong(v.toString());
}
}
}
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/tools/LDIFSearchTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/tools/LDIFSearchTestCase.java
index 50946d5..37f5546 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/tools/LDIFSearchTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/tools/LDIFSearchTestCase.java
@@ -27,22 +27,25 @@
package org.opends.server.tools;
+import static org.assertj.core.api.Assertions.*;
+import static org.testng.Assert.*;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.PrintStream;
+
+import org.opends.server.TestCaseUtils;
+import org.opends.server.types.Entry;
+import org.opends.server.types.LDIFImportConfig;
+import org.opends.server.util.LDIFException;
+import org.opends.server.util.LDIFReader;
+import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
-import org.testng.annotations.AfterClass;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertNull;
-import static org.testng.Assert.assertEquals;
-import org.opends.server.TestCaseUtils;
-import org.opends.server.types.LDIFImportConfig;
-import org.opends.server.types.Entry;
-import org.opends.server.util.LDIFReader;
-import java.io.*;
-
-/**
- * LDIFSearch test cases.
- */
+/** LDIFSearch test cases. */
+@SuppressWarnings("javadoc")
public class LDIFSearchTestCase extends ToolsTestCase {
@@ -117,12 +120,8 @@
"*", "+"
};
assertEquals(LDIFSearch.mainSearch(args, false, System.out, System.err), 0);
- LDIFImportConfig ldifConfig = new LDIFImportConfig(outLdifFilePath);
- ldifConfig.setValidateSchema(false);
- LDIFReader reader = new LDIFReader(ldifConfig);
- Entry e=reader.readEntry();
- reader.close();
- assertNotNull(e.getAttribute("objectclass"));
+ Entry e = readEntry();
+ assertThat(e.getAttribute("objectclass")).isNotEmpty();
}
/**
@@ -131,7 +130,7 @@
*
* @throws Exception The objectclass attribute is returned.
*/
- @Test
+ @Test
public void testLDIFSearchOpsOnly() throws Exception {
String[] args =
{
@@ -143,12 +142,8 @@
"+"
};
assertEquals(LDIFSearch.mainSearch(args, false, System.out, System.err), 0);
- LDIFImportConfig ldifConfig = new LDIFImportConfig(outLdifFilePath);
- ldifConfig.setValidateSchema(false);
- LDIFReader reader = new LDIFReader(ldifConfig);
- Entry e=reader.readEntry();
- reader.close();
- assertNull(e.getAttribute("objectclass"));
+ Entry e = readEntry();
+ assertThat(e.getAttribute("objectclass")).isEmpty();
}
/**
@@ -170,14 +165,21 @@
"+", "mail", "uid"
};
assertEquals(LDIFSearch.mainSearch(args, false, System.out, System.err), 0);
+ Entry e = readEntry();
+ assertThat(e.getAttribute("objectclass")).isEmpty();
+ assertThat(e.getAttribute("mail")).isNotEmpty();
+ assertThat(e.getAttribute("uid")).isNotEmpty();
+ }
+
+
+ private Entry readEntry() throws IOException, LDIFException
+ {
LDIFImportConfig ldifConfig = new LDIFImportConfig(outLdifFilePath);
ldifConfig.setValidateSchema(false);
- LDIFReader reader = new LDIFReader(ldifConfig);
- Entry e=reader.readEntry();
- reader.close();
- assertNull(e.getAttribute("objectclass"));
- assertNotNull(e.getAttribute("mail"));
- assertNotNull(e.getAttribute("uid"));
+ try (LDIFReader reader = new LDIFReader(ldifConfig))
+ {
+ return reader.readEntry();
+ }
}
/**
@@ -187,8 +189,7 @@
* @throws Exception The objectclass attribute is returned or one of the
* specified attributes is not returned.
*/
-
- @Test
+ @Test
public void testLDIFSearchAttrsOnly() throws Exception {
String[] args =
@@ -201,13 +202,9 @@
"mail", "uid"
};
assertEquals(LDIFSearch.mainSearch(args, false, System.out, System.err), 0);
- LDIFImportConfig ldifConfig = new LDIFImportConfig(outLdifFilePath);
- ldifConfig.setValidateSchema(false);
- LDIFReader reader = new LDIFReader(ldifConfig);
- Entry e=reader.readEntry();
- reader.close();
- assertNull(e.getAttribute("objectclass"));
- assertNotNull(e.getAttribute("mail"));
- assertNotNull(e.getAttribute("uid"));
+ Entry e = readEntry();
+ assertThat(e.getAttribute("objectclass")).isEmpty();
+ assertThat(e.getAttribute("mail")).isNotEmpty();
+ assertThat(e.getAttribute("uid")).isNotEmpty();
}
}
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/tools/makeldif/MakeLDIFTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/tools/makeldif/MakeLDIFTestCase.java
index debf7f2..3485de1 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/tools/makeldif/MakeLDIFTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/tools/makeldif/MakeLDIFTestCase.java
@@ -26,8 +26,8 @@
*/
package org.opends.server.tools.makeldif;
-
import java.io.File;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@@ -37,6 +37,7 @@
import org.opends.server.tasks.LdifFileWriter;
import org.opends.server.tools.ToolsTestCase;
import org.opends.server.types.*;
+import org.opends.server.util.LDIFException;
import org.opends.server.util.LDIFReader;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
@@ -45,7 +46,6 @@
import static org.testng.Assert.*;
import static org.opends.messages.ToolMessages.*;
-
/**
* A set of test cases for the MakeLDIF tool.
*/
@@ -324,14 +324,7 @@
LdifFileWriter.makeLdif(outLdifFilePath, resourcePath, lines);
- LDIFImportConfig ldifConfig = new LDIFImportConfig(outLdifFilePath);
- ldifConfig.setValidateSchema(false);
- LDIFReader reader = new LDIFReader(ldifConfig);
- Entry top = reader.readEntry();
- Entry e = reader.readEntry();
- reader.close();
-
- assertNotNull(top);
+ Entry e = readEntry(outLdifFilePath);
assertNotNull(e);
List<Attribute> attrs = e.getAttribute(attrName);
assertFalse(attrs.isEmpty());
@@ -340,6 +333,17 @@
assertEquals(a, expectedRes);
}
+ private Entry readEntry(String outLdifFilePath) throws IOException, LDIFException
+ {
+ LDIFImportConfig ldifConfig = new LDIFImportConfig(outLdifFilePath);
+ ldifConfig.setValidateSchema(false);
+ try (LDIFReader reader = new LDIFReader(ldifConfig))
+ {
+ assertNotNull(reader.readEntry());
+ return reader.readEntry();
+ }
+ }
+
/**
* Test for escaped characters in templates, check LDIF output when
* the templates combines escaped characters and variables.
@@ -370,14 +374,7 @@
LdifFileWriter.makeLdif(outLdifFilePath, resourcePath, lines);
- LDIFImportConfig ldifConfig = new LDIFImportConfig(outLdifFilePath);
- ldifConfig.setValidateSchema(false);
- LDIFReader reader = new LDIFReader(ldifConfig);
- Entry top = reader.readEntry();
- Entry e = reader.readEntry();
- reader.close();
-
- assertNotNull(top);
+ Entry e = readEntry(outLdifFilePath);
assertNotNull(e);
List<Attribute> attrs = e.getAttribute("cn");
assertFalse(attrs.isEmpty());
@@ -386,4 +383,3 @@
"cn value doesn't match the expected value");
}
}
-
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/types/TestEntry.java b/opendj-server-legacy/src/test/java/org/opends/server/types/TestEntry.java
index f2e6cb3..51f404e 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/types/TestEntry.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/types/TestEntry.java
@@ -26,6 +26,10 @@
*/
package org.opends.server.types;
+import static org.assertj.core.api.Assertions.*;
+import static org.opends.server.util.CollectionUtils.*;
+import static org.testng.Assert.*;
+
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashSet;
@@ -42,14 +46,12 @@
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
-import static org.opends.server.util.CollectionUtils.*;
-import static org.testng.Assert.*;
-
/**
* This class defines a set of tests for the {@link Entry} class.
* <p>
* At the moment this test suite only tests the parseAttribute method.
*/
+@SuppressWarnings("javadoc")
public final class TestEntry extends TypesTestCase {
/**
@@ -474,220 +476,56 @@
AttributeType uidType = DirectoryServer.getAttributeTypeOrNull("uid");
AttributeType mnType = DirectoryServer.getAttributeTypeOrNull("modifiersname");
- List<Attribute> attrs = e.getAttribute(ocType);
- assertNotNull(attrs);
- assertEquals(attrs.size(), 1);
+ assertThat(e.getAttribute(ocType)).hasSize(1);
+ assertThat(e.getAttribute(cnType)).hasSize(2);
+ assertThat(e.getAttribute(nameType)).hasSize(6);
- attrs = e.getAttribute(cnType);
- assertNotNull(attrs);
- assertEquals(attrs.size(), 2);
-
- attrs = e.getAttribute(nameType);
- assertNotNull(attrs);
- assertEquals(attrs.size(), 6);
-
- attrs = e.getAttribute(nameType, false);
- assertNull(attrs);
-
- attrs = e.getAttribute(uidType);
- assertNull(attrs);
-
- attrs = e.getAttribute(mnType);
- assertNotNull(attrs);
- assertEquals(attrs.size(), 1);
-
-
- attrs = e.getAttribute("objectclass");
- assertNotNull(attrs);
- assertEquals(attrs.size(), 1);
-
- attrs = e.getAttribute("cn");
- assertNotNull(attrs);
- assertEquals(attrs.size(), 2);
-
- attrs = e.getAttribute("uid");
- assertNull(attrs);
-
- attrs = e.getAttribute("modifiersname");
- assertNotNull(attrs);
- assertEquals(attrs.size(), 1);
-
+ assertThat(e.getAttribute(nameType, false)).isEmpty();
+ assertThat(e.getAttribute(uidType)).isEmpty();
+ assertThat(e.getAttribute(mnType)).hasSize(1);
+ assertThat(e.getAttribute("objectclass")).hasSize(1);
+ assertThat(e.getAttribute("cn")).hasSize(2);
+ assertThat(e.getAttribute("uid")).isEmpty();
+ assertThat(e.getAttribute("modifiersname")).hasSize(1);
LinkedHashSet<String> options = null;
- attrs = e.getAttribute(ocType, options);
- assertNotNull(attrs);
- assertEquals(attrs.size(), 1);
+ assertThat(e.getAttribute(ocType, options)).hasSize(1);
+ assertThat(e.getAttribute(cnType, options)).hasSize(2);
+ assertThat(e.getAttribute(nameType, options)).hasSize(6);
- attrs = e.getAttribute(cnType, options);
- assertNotNull(attrs);
- assertEquals(attrs.size(), 2);
-
- attrs = e.getAttribute(nameType, options);
- assertNotNull(attrs);
- assertEquals(attrs.size(), 6);
-
- attrs = e.getAttribute(nameType, false, options);
- assertNull(attrs);
-
- attrs = e.getAttribute(uidType, options);
- assertNull(attrs);
-
- attrs = e.getAttribute(mnType, options);
- assertNotNull(attrs);
- assertEquals(attrs.size(), 1);
-
-
- attrs = e.getAttribute("objectclass", options);
- assertNotNull(attrs);
- assertEquals(attrs.size(), 1);
-
- attrs = e.getAttribute("cn", options);
- assertNotNull(attrs);
- assertEquals(attrs.size(), 2);
-
- attrs = e.getAttribute("uid", options);
- assertNull(attrs);
-
- attrs = e.getAttribute("modifiersname", options);
- assertNotNull(attrs);
- assertEquals(attrs.size(), 1);
-
+ assertThat(e.getAttribute(uidType, options)).isEmpty();
+ assertThat(e.getAttribute(mnType, options)).hasSize(1);
options = new LinkedHashSet<>();
- attrs = e.getAttribute(ocType, options);
- assertNotNull(attrs);
- assertEquals(attrs.size(), 1);
+ assertThat(e.getAttribute(ocType, options)).hasSize(1);
+ assertThat(e.getAttribute(cnType, options)).hasSize(2);
+ assertThat(e.getAttribute(nameType, options)).hasSize(6);
- attrs = e.getAttribute(cnType, options);
- assertNotNull(attrs);
- assertEquals(attrs.size(), 2);
-
- attrs = e.getAttribute(nameType, options);
- assertNotNull(attrs);
- assertEquals(attrs.size(), 6);
-
- attrs = e.getAttribute(nameType, false, options);
- assertNull(attrs);
-
- attrs = e.getAttribute(uidType, options);
- assertNull(attrs);
-
- attrs = e.getAttribute(mnType, options);
- assertNotNull(attrs);
- assertEquals(attrs.size(), 1);
-
-
- attrs = e.getAttribute("objectclass", options);
- assertNotNull(attrs);
- assertEquals(attrs.size(), 1);
-
- attrs = e.getAttribute("cn", options);
- assertNotNull(attrs);
- assertEquals(attrs.size(), 2);
-
- attrs = e.getAttribute("uid", options);
- assertNull(attrs);
-
- attrs = e.getAttribute("modifiersname", options);
- assertNotNull(attrs);
- assertEquals(attrs.size(), 1);
-
+ assertThat(e.getAttribute(uidType, options)).isEmpty();
+ assertThat(e.getAttribute(mnType, options)).hasSize(1);
options.add("lang-en-US");
- attrs = e.getAttribute(ocType, options);
- assertNull(attrs);
+ assertThat(e.getAttribute(ocType, options)).isEmpty();
+ assertThat(e.getAttribute(cnType, options)).hasSize(1);
+ assertThat(e.getAttribute(nameType, options)).hasSize(3);
- attrs = e.getAttribute(cnType, options);
- assertNotNull(attrs);
- assertEquals(attrs.size(), 1);
-
- attrs = e.getAttribute(nameType, options);
- assertNotNull(attrs);
- assertEquals(attrs.size(), 3);
-
- attrs = e.getAttribute(nameType, false, options);
- assertNull(attrs);
-
- attrs = e.getAttribute(uidType, options);
- assertNull(attrs);
-
- attrs = e.getAttribute(mnType, options);
- assertNull(attrs);
-
-
- attrs = e.getAttribute("objectclass", options);
- assertNull(attrs);
-
- attrs = e.getAttribute("cn", options);
- assertNotNull(attrs);
- assertEquals(attrs.size(), 1);
-
- attrs = e.getAttribute("uid", options);
- assertNull(attrs);
-
- attrs = e.getAttribute("modifiersname", options);
- assertNull(attrs);
-
+ assertThat(e.getAttribute(uidType, options)).isEmpty();
+ assertThat(e.getAttribute(mnType, options)).isEmpty();
options.add("lang-en-GB");
- attrs = e.getAttribute(ocType, options);
- assertNull(attrs);
-
- attrs = e.getAttribute(cnType, options);
- assertNull(attrs);
-
- attrs = e.getAttribute(nameType, options);
- assertNull(attrs);
-
- attrs = e.getAttribute(uidType, options);
- assertNull(attrs);
-
- attrs = e.getAttribute(mnType, options);
- assertNull(attrs);
-
-
- attrs = e.getAttribute("objectclass", options);
- assertNull(attrs);
-
- attrs = e.getAttribute("cn", options);
- assertNull(attrs);
-
- attrs = e.getAttribute("uid", options);
- assertNull(attrs);
-
- attrs = e.getAttribute("modifiersname", options);
- assertNull(attrs);
-
+ assertThat(e.getAttribute(ocType, options)).isEmpty();
+ assertThat(e.getAttribute(cnType, options)).isEmpty();
+ assertThat(e.getAttribute(nameType, options)).isEmpty();
+ assertThat(e.getAttribute(uidType, options)).isEmpty();
+ assertThat(e.getAttribute(mnType, options)).isEmpty();
options.clear();
options.add("lang-en-GB");
- attrs = e.getAttribute(ocType, options);
- assertNull(attrs);
-
- attrs = e.getAttribute(cnType, options);
- assertNull(attrs);
-
- attrs = e.getAttribute(nameType, options);
- assertNull(attrs);
-
- attrs = e.getAttribute(uidType, options);
- assertNull(attrs);
-
- attrs = e.getAttribute(mnType, options);
- assertNull(attrs);
-
-
- attrs = e.getAttribute("objectclass", options);
- assertNull(attrs);
-
- attrs = e.getAttribute("cn", options);
- assertNull(attrs);
-
- attrs = e.getAttribute("uid", options);
- assertNull(attrs);
-
- attrs = e.getAttribute("modifiersname", options);
- assertNull(attrs);
+ assertThat(e.getAttribute(ocType, options)).isEmpty();
+ assertThat(e.getAttribute(cnType, options)).isEmpty();
+ assertThat(e.getAttribute(nameType, options)).isEmpty();
+ assertThat(e.getAttribute(uidType, options)).isEmpty();
+ assertThat(e.getAttribute(mnType, options)).isEmpty();
}
@@ -729,114 +567,11 @@
AttributeType uidType = DirectoryServer.getAttributeTypeOrNull("uid");
AttributeType mnType = DirectoryServer.getAttributeTypeOrNull("modifiersname");
- List<Attribute> attrs = e.getUserAttribute(ocType);
- assertNull(attrs);
-
- attrs = e.getUserAttribute(cnType);
- assertNotNull(attrs);
- assertEquals(attrs.size(), 2);
-
- attrs = e.getUserAttribute(nameType);
- assertNotNull(attrs);
- assertEquals(attrs.size(), 6);
-
- attrs = e.getUserAttribute(uidType);
- assertNull(attrs);
-
- attrs = e.getUserAttribute(mnType);
- assertNull(attrs);
-
-
- LinkedHashSet<String> options = null;
- attrs = e.getUserAttribute(ocType, options);
- assertNull(attrs);
-
- attrs = e.getUserAttribute(cnType, options);
- assertNotNull(attrs);
- assertEquals(attrs.size(), 2);
-
- attrs = e.getUserAttribute(nameType, options);
- assertNotNull(attrs);
- assertEquals(attrs.size(), 6);
-
- attrs = e.getUserAttribute(uidType, options);
- assertNull(attrs);
-
- attrs = e.getUserAttribute(mnType, options);
- assertNull(attrs);
-
-
- options = new LinkedHashSet<>();
- attrs = e.getUserAttribute(ocType, options);
- assertNull(attrs);
-
- attrs = e.getUserAttribute(cnType, options);
- assertNotNull(attrs);
- assertEquals(attrs.size(), 2);
-
- attrs = e.getUserAttribute(nameType, options);
- assertNotNull(attrs);
- assertEquals(attrs.size(), 6);
-
- attrs = e.getUserAttribute(uidType, options);
- assertNull(attrs);
-
- attrs = e.getUserAttribute(mnType, options);
- assertNull(attrs);
-
-
- options.add("lang-en-US");
- attrs = e.getUserAttribute(ocType, options);
- assertNull(attrs);
-
- attrs = e.getUserAttribute(cnType, options);
- assertNotNull(attrs);
- assertEquals(attrs.size(), 1);
-
- attrs = e.getUserAttribute(nameType, options);
- assertNotNull(attrs);
- assertEquals(attrs.size(), 3);
-
- attrs = e.getUserAttribute(uidType, options);
- assertNull(attrs);
-
- attrs = e.getUserAttribute(mnType, options);
- assertNull(attrs);
-
-
- options.add("lang-en-GB");
- attrs = e.getUserAttribute(ocType, options);
- assertNull(attrs);
-
- attrs = e.getUserAttribute(cnType, options);
- assertNull(attrs);
-
- attrs = e.getUserAttribute(nameType, options);
- assertNull(attrs);
-
- attrs = e.getUserAttribute(uidType, options);
- assertNull(attrs);
-
- attrs = e.getUserAttribute(mnType, options);
- assertNull(attrs);
-
-
- options.clear();
- options.add("lang-en-GB");
- attrs = e.getUserAttribute(ocType, options);
- assertNull(attrs);
-
- attrs = e.getUserAttribute(cnType, options);
- assertNull(attrs);
-
- attrs = e.getUserAttribute(nameType, options);
- assertNull(attrs);
-
- attrs = e.getUserAttribute(uidType, options);
- assertNull(attrs);
-
- attrs = e.getUserAttribute(mnType, options);
- assertNull(attrs);
+ assertThat(e.getUserAttribute(ocType)).isEmpty();
+ assertThat(e.getUserAttribute(cnType)).hasSize(2);
+ assertThat(e.getUserAttribute(nameType)).hasSize(6);
+ assertThat(e.getUserAttribute(uidType)).isEmpty();
+ assertThat(e.getUserAttribute(mnType)).isEmpty();
}
@@ -878,109 +613,46 @@
AttributeType uidType = DirectoryServer.getAttributeTypeOrNull("uid");
AttributeType mnType = DirectoryServer.getAttributeTypeOrNull("modifiersname");
- List<Attribute> attrs = e.getOperationalAttribute(ocType);
- assertNull(attrs);
-
- attrs = e.getOperationalAttribute(cnType);
- assertNull(attrs);
-
- attrs = e.getOperationalAttribute(nameType);
- assertNull(attrs);
-
- attrs = e.getOperationalAttribute(uidType);
- assertNull(attrs);
-
- attrs = e.getOperationalAttribute(mnType);
- assertNotNull(attrs);
- assertEquals(attrs.size(), 1);
-
+ assertThat(e.getOperationalAttribute(ocType)).isEmpty();
+ assertThat(e.getOperationalAttribute(cnType)).isEmpty();
+ assertThat(e.getOperationalAttribute(nameType)).isEmpty();
+ assertThat(e.getOperationalAttribute(uidType)).isEmpty();
+ assertThat(e.getOperationalAttribute(mnType)).hasSize(1);
LinkedHashSet<String> options = null;
- attrs = e.getOperationalAttribute(ocType, options);
- assertNull(attrs);
-
- attrs = e.getOperationalAttribute(cnType, options);
- assertNull(attrs);
-
- attrs = e.getOperationalAttribute(nameType, options);
- assertNull(attrs);
-
- attrs = e.getOperationalAttribute(uidType, options);
- assertNull(attrs);
-
- attrs = e.getOperationalAttribute(mnType, options);
- assertNotNull(attrs);
- assertEquals(attrs.size(), 1);
-
+ assertThat(e.getOperationalAttribute(ocType, options)).isEmpty();
+ assertThat(e.getOperationalAttribute(cnType, options)).isEmpty();
+ assertThat(e.getOperationalAttribute(nameType, options)).isEmpty();
+ assertThat(e.getOperationalAttribute(uidType, options)).isEmpty();
+ assertThat(e.getOperationalAttribute(mnType, options)).hasSize(1);
options = new LinkedHashSet<>();
- attrs = e.getOperationalAttribute(ocType, options);
- assertNull(attrs);
-
- attrs = e.getOperationalAttribute(cnType, options);
- assertNull(attrs);
-
- attrs = e.getOperationalAttribute(nameType, options);
- assertNull(attrs);
-
- attrs = e.getOperationalAttribute(uidType, options);
- assertNull(attrs);
-
- attrs = e.getOperationalAttribute(mnType, options);
- assertNotNull(attrs);
- assertEquals(attrs.size(), 1);
-
+ assertThat(e.getOperationalAttribute(ocType, options)).isEmpty();
+ assertThat(e.getOperationalAttribute(cnType, options)).isEmpty();
+ assertThat(e.getOperationalAttribute(nameType, options)).isEmpty();
+ assertThat(e.getOperationalAttribute(uidType, options)).isEmpty();
+ assertThat(e.getOperationalAttribute(mnType, options)).hasSize(1);
options.add("lang-en-US");
- attrs = e.getOperationalAttribute(ocType, options);
- assertNull(attrs);
-
- attrs = e.getOperationalAttribute(cnType, options);
- assertNull(attrs);
-
- attrs = e.getOperationalAttribute(nameType, options);
- assertNull(attrs);
-
- attrs = e.getOperationalAttribute(uidType, options);
- assertNull(attrs);
-
- attrs = e.getOperationalAttribute(mnType, options);
- assertNull(attrs);
-
+ assertThat(e.getOperationalAttribute(ocType, options)).isEmpty();
+ assertThat(e.getOperationalAttribute(cnType, options)).isEmpty();
+ assertThat(e.getOperationalAttribute(nameType, options)).isEmpty();
+ assertThat(e.getOperationalAttribute(uidType, options)).isEmpty();
+ assertThat(e.getOperationalAttribute(mnType, options)).isEmpty();
options.add("lang-en-GB");
- attrs = e.getOperationalAttribute(ocType, options);
- assertNull(attrs);
-
- attrs = e.getOperationalAttribute(cnType, options);
- assertNull(attrs);
-
- attrs = e.getOperationalAttribute(nameType, options);
- assertNull(attrs);
-
- attrs = e.getOperationalAttribute(uidType, options);
- assertNull(attrs);
-
- attrs = e.getOperationalAttribute(mnType, options);
- assertNull(attrs);
-
+ assertThat(e.getOperationalAttribute(ocType, options)).isEmpty();
+ assertThat(e.getOperationalAttribute(cnType, options)).isEmpty();
+ assertThat(e.getOperationalAttribute(nameType, options)).isEmpty();
+ assertThat(e.getOperationalAttribute(uidType, options)).isEmpty();
+ assertThat(e.getOperationalAttribute(mnType, options)).isEmpty();
options.clear();
options.add("lang-en-GB");
- attrs = e.getOperationalAttribute(ocType, options);
- assertNull(attrs);
-
- attrs = e.getOperationalAttribute(cnType, options);
- assertNull(attrs);
-
- attrs = e.getOperationalAttribute(nameType, options);
- assertNull(attrs);
-
- attrs = e.getOperationalAttribute(uidType, options);
- assertNull(attrs);
-
- attrs = e.getOperationalAttribute(mnType, options);
- assertNull(attrs);
+ assertThat(e.getOperationalAttribute(ocType, options)).isEmpty();
+ assertThat(e.getOperationalAttribute(cnType, options)).isEmpty();
+ assertThat(e.getOperationalAttribute(nameType, options)).isEmpty();
+ assertThat(e.getOperationalAttribute(uidType, options)).isEmpty();
+ assertThat(e.getOperationalAttribute(mnType, options)).isEmpty();
}
}
-
--
Gitblit v1.10.0