From 5cd7bdbbda0fa9f1aa6e12d9171c3811b73feb07 Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Thu, 09 Jul 2015 14:01:31 +0000
Subject: [PATCH] Code cleanup
---
opendj-server-legacy/src/test/java/org/opends/server/plugins/ReferentialIntegrityPluginTestCase.java | 11
opendj-server-legacy/src/main/java/org/opends/server/backends/RootDSEBackend.java | 7
opendj-server-legacy/src/main/java/org/opends/server/core/AddOperationBasis.java | 50 -
opendj-server-legacy/src/test/java/org/opends/server/controls/PersistentSearchControlTest.java | 8
opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendAddOperation.java | 12
opendj-server-legacy/src/main/java/org/opends/server/tools/StopDS.java | 43 -
opendj-server-legacy/src/main/java/org/opends/server/types/Attributes.java | 76 +
opendj-server-legacy/src/test/java/org/opends/server/util/TestAddChangeRecordEntry.java | 9
opendj-server-legacy/src/test/java/org/opends/server/extensions/ExactMatchIdentityMapperTestCase.java | 12
opendj-server-legacy/src/test/java/org/opends/server/core/AddOperationTestCase.java | 98 +-
opendj-server-legacy/src/main/java/org/opends/server/protocols/ldap/SearchResultEntryProtocolOp.java | 14
opendj-server-legacy/src/main/java/org/opends/server/backends/BackupBackend.java | 17
opendj-server-legacy/src/test/java/org/opends/server/replication/UpdateOperationTest.java | 17
opendj-server-legacy/src/test/java/org/opends/server/plugins/ShortCircuitPlugin.java | 12
opendj-server-legacy/src/test/java/org/opends/server/protocols/ldap/TestAddRequestProtocolOp.java | 29
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/datamodel/CustomSearchResult.java | 7
opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/PersistentServerState.java | 18
opendj-server-legacy/src/test/java/org/opends/server/core/AbandonOperationTestCase.java | 20
opendj-server-legacy/src/main/java/org/opends/server/plugins/LastModPlugin.java | 22
opendj-server-legacy/src/main/java/org/opends/server/config/IntegerWithUnitConfigAttribute.java | 46
opendj-server-legacy/src/main/java/org/opends/server/tools/ExportLDIF.java | 29
opendj-server-legacy/src/main/java/org/opends/server/types/AccountStatusNotification.java | 46 -
opendj-server-legacy/src/test/java/org/opends/server/protocols/ldap/TestLDAPFilter.java | 21
opendj-server-legacy/src/test/java/org/opends/server/extensions/CancelExtendedOperationTestCase.java | 20
opendj-server-legacy/src/main/java/org/opends/server/protocols/ldap/LDAPAttribute.java | 12
opendj-server-legacy/src/main/java/org/opends/server/types/Entry.java | 36
opendj-server-legacy/src/test/java/org/opends/server/authorization/dseecompat/AciTestCase.java | 23
opendj-server-legacy/src/main/java/org/opends/server/plugins/EntryUUIDPlugin.java | 11
opendj-server-legacy/src/main/java/org/opends/server/backends/task/Task.java | 19
opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/LDAPReplicationDomain.java | 41 -
opendj-server-legacy/src/test/java/org/opends/server/plugins/DisconnectClientPlugin.java | 21
opendj-server-legacy/src/main/java/org/opends/server/backends/TrustStoreBackend.java | 31
opendj-server-legacy/src/main/java/org/opends/server/config/BooleanConfigAttribute.java | 13
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/ManageTasksPanel.java | 23
opendj-server-legacy/src/main/java/org/opends/server/backends/MonitorBackend.java | 15
opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/PatternRDN.java | 39
opendj-server-legacy/src/main/java/org/opends/server/util/StaticUtils.java | 16
opendj-server-legacy/src/main/java/org/opends/server/config/DNConfigAttribute.java | 30
opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/HistoricalTest.java | 6
opendj-server-legacy/src/main/java/org/opends/server/backends/task/TaskScheduler.java | 11
opendj-server-legacy/src/test/java/org/opends/server/plugins/DelayPreOpPlugin.java | 26
opendj-server-legacy/src/main/java/org/opends/server/util/LDIFReader.java | 7
opendj-server-legacy/src/main/java/org/opends/server/tools/makeldif/TemplateEntry.java | 15
opendj-server-legacy/src/test/java/org/opends/server/plugins/UpdatePreOpPlugin.java | 13
opendj-server-legacy/src/main/java/org/opends/server/types/AttributeBuilder.java | 81 +-
opendj-server-legacy/src/main/java/org/opends/server/backends/SchemaBackend.java | 8
opendj-server-legacy/src/main/java/org/opends/server/tools/dsreplication/PurgeHistoricalScheduleInformation.java | 11
opendj-server-legacy/src/main/java/org/opends/server/tools/tasks/TaskClient.java | 76 -
opendj-server-legacy/src/test/java/org/opends/server/protocols/internal/InternalClientConnectionTestCase.java | 17
opendj-server-legacy/src/main/java/org/opends/server/extensions/PasswordModifyExtendedOperation.java | 10
opendj-server-legacy/src/main/java/org/opends/server/tools/BackUpDB.java | 16
opendj-server-legacy/src/main/java/org/opends/server/crypto/CryptoManagerImpl.java | 34
opendj-server-legacy/src/main/java/org/opends/server/tools/ImportLDIF.java | 24
opendj-server-legacy/src/test/java/org/opends/server/api/PasswordValidatorTestCase.java | 28
opendj-server-legacy/src/main/java/org/opends/server/tasks/TaskUtils.java | 33
opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/ModifyConflictTest.java | 4
opendj-server-legacy/src/test/java/org/opends/server/core/ModifyOperationTestCase.java | 21
opendj-server-legacy/src/main/java/org/opends/server/tools/RebuildIndex.java | 18
opendj-server-legacy/src/test/java/org/opends/server/protocols/jmx/JmxPrivilegeTestCase.java | 11
opendj-server-legacy/src/main/java/org/forgerock/opendj/adapter/server3x/Converters.java | 5
opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/PatternDN.java | 74 +-
opendj-server-legacy/src/test/java/org/opends/server/extensions/WhoAmIExtendedOperationTestCase.java | 11
opendj-server-legacy/src/main/java/org/opends/server/extensions/PasswordPolicyStateExtendedOperation.java | 9
opendj-server-legacy/src/main/java/org/opends/server/monitors/ClientConnectionMonitorProvider.java | 18
opendj-server-legacy/src/main/java/org/opends/server/tools/RestoreDB.java | 10
opendj-server-legacy/src/test/java/org/opends/server/extensions/ErrorLogAccountStatusNotificationHandlerTestCase.java | 81 --
66 files changed, 592 insertions(+), 1,060 deletions(-)
diff --git a/opendj-server-legacy/src/main/java/org/forgerock/opendj/adapter/server3x/Converters.java b/opendj-server-legacy/src/main/java/org/forgerock/opendj/adapter/server3x/Converters.java
index e0abf2a..5923154 100644
--- a/opendj-server-legacy/src/main/java/org/forgerock/opendj/adapter/server3x/Converters.java
+++ b/opendj-server-legacy/src/main/java/org/forgerock/opendj/adapter/server3x/Converters.java
@@ -26,11 +26,11 @@
package org.forgerock.opendj.adapter.server3x;
import static org.forgerock.opendj.ldap.LdapException.*;
+import static org.opends.server.util.CollectionUtils.*;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Collections;
import java.util.List;
import java.util.SortedSet;
import java.util.TreeSet;
@@ -290,8 +290,7 @@
*/
public static org.opends.server.types.RawAttribute to(
final org.forgerock.opendj.ldap.Attribute attribute) {
- ArrayList<ByteString> listAttributeValues = new ArrayList<>(attribute.size());
- Collections.addAll(listAttributeValues, attribute.toArray());
+ ArrayList<ByteString> listAttributeValues = newArrayList(attribute.toArray());
return new LDAPAttribute(attribute.getAttributeDescriptionAsString(), listAttributeValues);
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/datamodel/CustomSearchResult.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/datamodel/CustomSearchResult.java
index a45be55..5bed003 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/datamodel/CustomSearchResult.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/datamodel/CustomSearchResult.java
@@ -26,7 +26,7 @@
*/
package org.opends.guitools.controlpanel.datamodel;
-import static org.opends.server.util.StaticUtils.toLowerCase;
+import static org.opends.server.util.StaticUtils.*;
import java.util.ArrayList;
import java.util.Collections;
@@ -44,11 +44,11 @@
import javax.naming.directory.Attributes;
import javax.naming.directory.SearchResult;
+import org.forgerock.opendj.ldap.ByteString;
import org.opends.guitools.controlpanel.util.Utilities;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.AttributeBuilder;
import org.opends.server.types.AttributeType;
-import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.types.DN;
import org.opends.server.types.Entry;
import org.opends.server.types.ObjectClass;
@@ -340,9 +340,8 @@
}
builder.add(bs);
}
- List<org.opends.server.types.Attribute> attrList = new ArrayList<>(1);
- attrList.add(builder.toAttribute());
+ List<org.opends.server.types.Attribute> attrList = builder.toAttributeList();
if (attrType.isOperational())
{
operationalAttributes.put(attrType, attrList);
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/ManageTasksPanel.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/ManageTasksPanel.java
index 9b08199..39ff64d 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/ManageTasksPanel.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/ManageTasksPanel.java
@@ -29,7 +29,8 @@
import static org.forgerock.util.Utils.*;
import static org.opends.messages.AdminToolMessages.*;
-import static org.opends.server.util.StaticUtils.toLowerCase;
+import static org.opends.server.util.CollectionUtils.*;
+import static org.opends.server.util.StaticUtils.*;
import java.awt.Component;
import java.awt.GridBagConstraints;
@@ -46,9 +47,6 @@
import java.util.Random;
import java.util.Set;
-import org.forgerock.i18n.LocalizableMessage;
-import org.forgerock.i18n.slf4j.LocalizedLogger;
-
import javax.swing.Box;
import javax.swing.JButton;
import javax.swing.JLabel;
@@ -64,6 +62,9 @@
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
+import org.forgerock.i18n.LocalizableMessage;
+import org.forgerock.i18n.slf4j.LocalizedLogger;
+import org.forgerock.opendj.ldap.ByteString;
import org.opends.guitools.controlpanel.datamodel.ControlPanelInfo;
import org.opends.guitools.controlpanel.datamodel.CustomSearchResult;
import org.opends.guitools.controlpanel.datamodel.ServerDescriptor;
@@ -79,7 +80,6 @@
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeBuilder;
import org.opends.server.types.AttributeType;
-import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.types.DN;
import org.opends.server.types.Entry;
import org.opends.server.types.ObjectClass;
@@ -534,9 +534,8 @@
};
for (int j=0; j < attrNames.length; j++)
{
- List<Object> attrValues = new ArrayList<>(1);
- attrValues.add(values[j] + r.nextInt());
- csr.set(attrNames[j], attrValues);
+ Object o = values[j] + r.nextInt();
+ csr.set(attrNames[j], newArrayList(o));
}
try
{
@@ -601,9 +600,8 @@
};
for (int j=0; j < attrNames.length; j++)
{
- List<Object> attrValues = new ArrayList<>(1);
- attrValues.add(values[j]);
- csr.set(attrNames[j], attrValues);
+ Object o = values[j];
+ csr.set(attrNames[j], newArrayList(o));
}
try
{
@@ -717,9 +715,8 @@
}
builder.add(bs);
}
- List<Attribute> attrList = new ArrayList<>(1);
- attrList.add(builder.toAttribute());
+ List<Attribute> attrList = builder.toAttributeList();
if (attrType.isOperational())
{
operationalAttributes.put(attrType, attrList);
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/PatternDN.java b/opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/PatternDN.java
index 881c11a..3eca334 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/PatternDN.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/PatternDN.java
@@ -26,23 +26,22 @@
*/
package org.opends.server.authorization.dseecompat;
-import org.forgerock.i18n.LocalizableMessage;
-
-import org.opends.server.types.*;
-import org.forgerock.opendj.ldap.ResultCode;
-import org.forgerock.opendj.ldap.ByteString;
-import static org.opends.messages.SchemaMessages.*;
import static org.opends.messages.AccessControlMessages.*;
-import static org.opends.server.util.StaticUtils.isDigit;
-import static org.opends.server.util.StaticUtils.isHexDigit;
-import static org.opends.server.util.StaticUtils.hexStringToByteArray;
-import org.forgerock.util.Reject;
-
-import org.forgerock.i18n.slf4j.LocalizedLogger;
+import static org.opends.messages.SchemaMessages.*;
+import static org.opends.server.util.CollectionUtils.*;
+import static org.opends.server.util.StaticUtils.*;
import java.util.ArrayList;
import java.util.List;
+import org.forgerock.i18n.LocalizableMessage;
+import org.forgerock.i18n.slf4j.LocalizedLogger;
+import org.forgerock.opendj.ldap.ByteString;
+import org.forgerock.opendj.ldap.ResultCode;
+import org.forgerock.util.Reject;
+import org.opends.server.types.DN;
+import org.opends.server.types.DirectoryException;
+
/**
* This class is used to encapsulate DN pattern matching using wildcards.
* The following wildcard uses are supported.
@@ -195,19 +194,9 @@
{
if (element[0].matchesRDN(dn.getRDN(pos)))
{
- boolean subMatch = true;
- for (int i=1; i < anyLength; i++)
+ if (subMatch(dn, pos, element, anyLength))
{
- if (!element[i].matchesRDN(dn.getRDN(pos+i)))
- {
- subMatch = false;
- break;
- }
- }
-
- if (subMatch)
- {
- match = subMatch;
+ match = true;
break;
}
}
@@ -248,6 +237,17 @@
}
}
+ private boolean subMatch(DN dn, int pos, PatternRDN[] element, int length)
+ {
+ for (int i = 1; i < length; i++)
+ {
+ if (!element[i].matchesRDN(dn.getRDN(pos + i)))
+ {
+ return false;
+ }
+ }
+ return true;
+ }
/**
* Create a new DN pattern matcher to match a suffix.
@@ -320,8 +320,7 @@
if (pos == length)
{
// This means that the DN was completely comprised of spaces
- // and therefore should be considered the same as a null or
- // empty DN.
+ // and therefore should be considered the same as a null or empty DN.
return new PatternDN(new PatternRDN[0]);
}
else
@@ -331,8 +330,7 @@
}
// We know that it's not an empty DN, so we can do the real
- // processing. Create a loop and iterate through all the RDN
- // components.
+ // processing. Create a loop and iterate through all the RDN components.
rdnLoop:
while (true)
{
@@ -442,8 +440,7 @@
// RDN component and return the DN.
if (pos >= length)
{
- ArrayList<ByteString> arrayList = new ArrayList<>(1);
- arrayList.add(ByteString.empty());
+ ArrayList<ByteString> arrayList = newArrayList(ByteString.empty());
rdnComponents.add(new PatternRDN(name, arrayList, dnString));
break;
}
@@ -466,20 +463,17 @@
// Most likely, we will be at either the end of the RDN
- // component or the end of the DN. If so, then handle that
- // appropriately.
+ // component or the end of the DN. If so, then handle that appropriately.
if (pos >= length)
{
- // We're at the end of the DN string and should have a valid
- // DN so return it.
+ // We're at the end of the DN string and should have a valid DN so return it.
rdnComponents.add(rdn);
break;
}
else if ((c == ',') || (c == ';'))
{
- // We're at the end of the RDN component, so add it to the
- // list, skip over the comma/semicolon, and start on the next
- // component.
+ // We're at the end of the RDN component, so add it to the list,
+ // skip over the comma/semicolon, and start on the next component.
rdnComponents.add(rdn);
pos++;
continue;
@@ -489,8 +483,7 @@
// This should not happen. At any rate, it's an illegal
// character, so throw an exception.
LocalizableMessage message = ERR_ATTR_SYNTAX_DN_INVALID_CHAR.get(dnString, c, pos);
- throw new DirectoryException(ResultCode.INVALID_DN_SYNTAX,
- message);
+ throw new DirectoryException(ResultCode.INVALID_DN_SYNTAX, message);
}
@@ -575,8 +568,7 @@
// the RDN component and return the DN.
if (pos >= length)
{
- ArrayList<ByteString> arrayList = new ArrayList<>(1);
- arrayList.add(ByteString.empty());
+ ArrayList<ByteString> arrayList = newArrayList(ByteString.empty());
rdn.addValue(name, arrayList, dnString);
rdnComponents.add(rdn);
break;
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/PatternRDN.java b/opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/PatternRDN.java
index 2e6eaa8..526a89a 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/PatternRDN.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/PatternRDN.java
@@ -26,11 +26,14 @@
*/
package org.opends.server.authorization.dseecompat;
-import java.util.List;
+import static org.opends.messages.AccessControlMessages.*;
+import static org.opends.server.util.CollectionUtils.*;
+
import java.util.ArrayList;
-import java.util.TreeMap;
-import java.util.Set;
import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+import java.util.TreeMap;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.slf4j.LocalizedLogger;
@@ -41,8 +44,6 @@
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.*;
-import static org.opends.messages.AccessControlMessages.*;
-
/**
* This class is used to match RDN patterns containing wildcards in either
* the attribute types or the attribute values.
@@ -53,19 +54,10 @@
private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
- /**
- * Indicate whether the RDN contains a wildcard in any of its attribute
- * types.
- */
+ /** Indicate whether the RDN contains a wildcard in any of its attribute types. */
private boolean hasTypeWildcard;
-
-
- /**
- * The set of attribute type patterns.
- */
+ /** The set of attribute type patterns. */
private String[] typePatterns;
-
-
/**
* The set of attribute value patterns.
* The value pattern is split into a list according to the positions of any
@@ -75,11 +67,7 @@
* of three elements "", A and "".
*/
private ArrayList<ArrayList<ByteString>> valuePatterns;
-
-
- /**
- * The number of attribute-value pairs in this RDN pattern.
- */
+ /** The number of attribute-value pairs in this RDN pattern. */
private int numValues;
@@ -90,8 +78,7 @@
* @param dnString The DN pattern containing the attribute-value pair.
* @throws DirectoryException If the attribute-value pair is not valid.
*/
- public PatternRDN(String type, ArrayList<ByteString> valuePattern,
- String dnString)
+ public PatternRDN(String type, ArrayList<ByteString> valuePattern, String dnString)
throws DirectoryException
{
// Only Whole-Type wildcards permitted.
@@ -109,8 +96,7 @@
numValues = 1;
typePatterns = new String[] { type };
- valuePatterns = new ArrayList<>(1);
- valuePatterns.add(valuePattern);
+ valuePatterns = newArrayList(valuePattern);
}
@@ -133,8 +119,7 @@
{
LocalizableMessage message =
WARN_PATTERN_DN_TYPE_WILDCARD_IN_MULTIVALUED_RDN.get(dnString);
- throw new DirectoryException(ResultCode.INVALID_DN_SYNTAX,
- message);
+ throw new DirectoryException(ResultCode.INVALID_DN_SYNTAX, message);
}
numValues++;
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 47d92fb..85a51d1 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
@@ -222,9 +222,7 @@
for (int i=0; i < numAVAs; i++)
{
AttributeType attrType = rdn.getAttributeType(i);
- ArrayList<Attribute> attrList = new ArrayList<>(1);
- attrList.add(Attributes.create(attrType, rdn.getAttributeValue(i)));
- userAttrs.put(attrType, attrList);
+ userAttrs.put(attrType, Attributes.createAsList(attrType, rdn.getAttributeValue(i)));
}
backupBaseEntry = new Entry(backupBaseDN, objectClasses, userAttrs, opAttrs);
@@ -649,9 +647,7 @@
for (String s : dependencies) {
builder.add(s);
}
- ArrayList<Attribute> attrList = new ArrayList<>(1);
- attrList.add(builder.toAttribute());
- userAttrs.put(t, attrList);
+ userAttrs.put(t, builder.toAttributeList());
}
byte[] signedHash = backupInfo.getSignedHash();
@@ -679,8 +675,7 @@
private void putByteString(LinkedHashMap<AttributeType, List<Attribute>> userAttrs, String attrName, byte[] value)
{
- AttributeType t;
- t = DirectoryServer.getAttributeType(attrName, true);
+ AttributeType t = DirectoryServer.getAttributeType(attrName, true);
userAttrs.put(t, asList(t, ByteString.wrap(value)));
}
@@ -690,11 +685,9 @@
attrsMap.put(t, asList(t, createBooleanValue(value)));
}
- private ArrayList<Attribute> asList(AttributeType attrType, ByteString value)
+ private List<Attribute> asList(AttributeType attrType, ByteString value)
{
- final ArrayList<Attribute> attrList = new ArrayList<>(1);
- attrList.add(Attributes.create(attrType, value));
- return attrList;
+ return Attributes.createAsList(attrType, value);
}
private DirectoryException newConstraintViolation(LocalizableMessage message)
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/backends/MonitorBackend.java b/opendj-server-legacy/src/main/java/org/opends/server/backends/MonitorBackend.java
index 27803b9..68df4b2 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/backends/MonitorBackend.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/backends/MonitorBackend.java
@@ -30,6 +30,7 @@
import static org.opends.messages.BackendMessages.*;
import static org.opends.messages.ConfigMessages.*;
import static org.opends.server.config.ConfigConstants.*;
+import static org.opends.server.util.CollectionUtils.*;
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
@@ -655,14 +656,7 @@
private void put(final HashMap<AttributeType, List<Attribute>> attrsMap, final Attribute attr)
{
- attrsMap.put(attr.getAttributeType(), toList(attr));
- }
-
- private ArrayList<Attribute> toList(final Attribute attr)
- {
- final ArrayList<Attribute> results = new ArrayList<>(1);
- results.add(attr);
- return results;
+ attrsMap.put(attr.getAttributeType(), newArrayList(attr));
}
/**
@@ -687,8 +681,7 @@
{
final AttributeType attributeType = rdn.getAttributeType(i);
final ByteString value = rdn.getAttributeValue(attributeType);
- final Attribute attr = Attributes.create(attributeType, value);
- monitorUserAttrs.put(attributeType, toList(attr));
+ monitorUserAttrs.put(attributeType, Attributes.createAsList(attributeType, value));
}
}
@@ -783,7 +776,7 @@
final AttributeType rdnType = entryRDN.getAttributeType(0);
final ByteString rdnValue = entryRDN.getAttributeValue(0);
- attrMap.put(rdnType, toList(Attributes.create(rdnType, rdnValue)));
+ attrMap.put(rdnType, Attributes.createAsList(rdnType, rdnValue));
// Take the rest of the information from the monitor data.
for (final Attribute a : monitorAttrs)
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/backends/RootDSEBackend.java b/opendj-server-legacy/src/main/java/org/opends/server/backends/RootDSEBackend.java
index 43135bb..a1d5546 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/backends/RootDSEBackend.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/backends/RootDSEBackend.java
@@ -30,6 +30,7 @@
import static org.opends.messages.BackendMessages.*;
import static org.opends.messages.ConfigMessages.*;
import static org.opends.server.config.ConfigConstants.*;
+import static org.opends.server.util.CollectionUtils.*;
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
@@ -512,8 +513,7 @@
Attribute supportedAuthPWSchemesAttr =
createAttribute(ATTR_SUPPORTED_AUTH_PW_SCHEMES,
ATTR_SUPPORTED_AUTH_PW_SCHEMES_LC, authPWSchemes);
- ArrayList<Attribute> supportedAuthPWSchemesAttrs = new ArrayList<>(1);
- supportedAuthPWSchemesAttrs.add(supportedAuthPWSchemesAttr);
+ ArrayList<Attribute> supportedAuthPWSchemesAttrs = newArrayList(supportedAuthPWSchemesAttr);
if (showAllAttributes
|| !supportedSASLMechAttr.getAttributeType().isOperational())
{
@@ -607,8 +607,7 @@
{
if (!publicNamingContextAttr.isEmpty())
{
- List<Attribute> privateNamingContextAttrs = new ArrayList<>(1);
- privateNamingContextAttrs.add(publicNamingContextAttr);
+ List<Attribute> privateNamingContextAttrs = newArrayList(publicNamingContextAttr);
final AttributeType attrType = publicNamingContextAttr.getAttributeType();
if (showAllAttributes || !attrType.isOperational())
{
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 3cdb273..8656c96 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
@@ -33,6 +33,7 @@
import static org.opends.server.config.ConfigConstants.*;
import static org.opends.server.schema.SchemaConstants.*;
import static org.opends.server.types.CommonSchemaElements.*;
+import static org.opends.server.util.CollectionUtils.*;
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
@@ -782,13 +783,6 @@
}
}
- private ArrayList<Attribute> newArrayList(Attribute a)
- {
- ArrayList<Attribute> attrList = new ArrayList<>(1);
- attrList.add(a);
- return attrList;
- }
-
/** {@inheritDoc} */
@Override
public boolean entryExists(DN entryDN)
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 93e9099..e3ef97f 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
@@ -45,7 +45,6 @@
import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.cert.Certificate;
-import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedHashMap;
@@ -256,10 +255,7 @@
throw new InitializationException(
ERR_TRUSTSTORE_PIN_FILE_EMPTY.get(pinFilePath, configEntryDN));
}
- else
- {
- trustStorePIN = pinStr.toCharArray();
- }
+ trustStorePIN = pinStr.toCharArray();
}
}
}
@@ -271,10 +267,7 @@
throw new InitializationException(
ERR_TRUSTSTORE_PIN_ENVAR_NOT_SET.get(pinProperty, configEntryDN));
}
- else
- {
- trustStorePIN = pinStr.toCharArray();
- }
+ trustStorePIN = pinStr.toCharArray();
}
}
else
@@ -284,10 +277,7 @@
{
throw new InitializationException(ERR_TRUSTSTORE_PIN_PROPERTY_NOT_SET.get(pinProperty, configEntryDN));
}
- else
- {
- trustStorePIN = pinStr.toCharArray();
- }
+ trustStorePIN = pinStr.toCharArray();
}
// Create a certificate manager.
@@ -315,9 +305,7 @@
for (int i=0; i < numAVAs; i++)
{
AttributeType attrType = rdn.getAttributeType(i);
- ArrayList<Attribute> attrList = new ArrayList<>(1);
- attrList.add(Attributes.create(attrType, rdn.getAttributeValue(i)));
- userAttrs.put(attrType, attrList);
+ userAttrs.put(attrType, Attributes.createAsList(attrType, rdn.getAttributeValue(i)));
}
baseEntry = new Entry(baseDN, objectClasses, userAttrs, opAttrs);
@@ -486,14 +474,14 @@
LinkedHashMap<AttributeType,List<Attribute>> opAttrs = new LinkedHashMap<>(0);
LinkedHashMap<AttributeType,List<Attribute>> userAttrs = new LinkedHashMap<>(3);
- userAttrs.put(t, asList(Attributes.create(t, v)));
+ userAttrs.put(t, Attributes.createAsList(t, v));
t = DirectoryServer.getAttributeType(ATTR_CRYPTO_PUBLIC_KEY_CERTIFICATE, true);
AttributeBuilder builder = new AttributeBuilder(t);
builder.setOption("binary");
builder.add(certValue);
- userAttrs.put(t, asList(builder.toAttribute()));
+ userAttrs.put(t, builder.toAttributeList());
Entry e = new Entry(entryDN, ocMap, userAttrs, opAttrs);
@@ -501,13 +489,6 @@
return e;
}
- private ArrayList<Attribute> asList(Attribute create)
- {
- ArrayList<Attribute> attrList = new ArrayList<>(1);
- attrList.add(create);
- return attrList;
- }
-
/** {@inheritDoc} */
@Override
public void addEntry(Entry entry, AddOperation addOperation)
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 ffe5508..37fae35 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
@@ -54,6 +54,7 @@
import static org.opends.messages.BackendMessages.*;
import static org.opends.server.config.ConfigConstants.*;
+import static org.opends.server.util.CollectionUtils.*;
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
@@ -605,9 +606,7 @@
{
this.taskState = taskState;
Attribute attr = Attributes.create(ATTR_TASK_STATE, taskState.toString());
- ArrayList<Attribute> attrList = new ArrayList<>(1);
- attrList.add(attr);
- taskEntry.putAttribute(attr.getAttributeType(), attrList);
+ taskEntry.putAttribute(attr.getAttributeType(), newArrayList(attr));
}
finally
{
@@ -761,11 +760,8 @@
this.actualStartTime = actualStartTime;
Date d = new Date(actualStartTime);
String startTimeStr = StaticUtils.formatDateTimeString(d);
- Attribute attr = Attributes.create(ATTR_TASK_ACTUAL_START_TIME,
- startTimeStr);
- ArrayList<Attribute> attrList = new ArrayList<>(1);
- attrList.add(attr);
- taskEntry.putAttribute(attr.getAttributeType(), attrList);
+ Attribute attr = Attributes.create(ATTR_TASK_ACTUAL_START_TIME, startTimeStr);
+ taskEntry.putAttribute(attr.getAttributeType(), newArrayList(attr));
}
finally
{
@@ -817,11 +813,8 @@
SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT_GMT_TIME);
dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
Date d = new Date(completionTime);
- Attribute attr = Attributes.create(ATTR_TASK_COMPLETION_TIME,
- dateFormat.format(d));
- ArrayList<Attribute> attrList = new ArrayList<>(1);
- attrList.add(attr);
- taskEntry.putAttribute(attr.getAttributeType(), attrList);
+ Attribute attr = Attributes.create(ATTR_TASK_COMPLETION_TIME, dateFormat.format(d));
+ taskEntry.putAttribute(attr.getAttributeType(), newArrayList(attr));
}
finally
{
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 bd334d6..e74b3ee 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
@@ -28,6 +28,7 @@
import static org.opends.messages.BackendMessages.*;
import static org.opends.server.config.ConfigConstants.*;
+import static org.opends.server.util.CollectionUtils.*;
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
@@ -38,16 +39,16 @@
import java.util.concurrent.locks.ReentrantLock;
import org.forgerock.i18n.LocalizableMessage;
+import org.forgerock.i18n.slf4j.LocalizedLogger;
+import org.forgerock.opendj.ldap.ByteString;
+import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.api.AlertGenerator;
import org.opends.server.api.DirectoryThread;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.SearchOperation;
import org.opends.server.core.ServerContext;
-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 org.opends.server.util.LDIFException;
import org.opends.server.util.LDIFReader;
import org.opends.server.util.LDIFWriter;
@@ -199,10 +200,8 @@
}
Attribute attr = Attributes.create(ATTR_TASK_STATE, TaskState.RECURRING.toString());
- ArrayList<Attribute> attrList = new ArrayList<>(1);
- attrList.add(attr);
Entry recurringTaskEntry = recurringTask.getRecurringTaskEntry();
- recurringTaskEntry.putAttribute(attr.getAttributeType(), attrList);
+ recurringTaskEntry.putAttribute(attr.getAttributeType(), newArrayList(attr));
if (scheduleIteration)
{
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/config/BooleanConfigAttribute.java b/opendj-server-legacy/src/main/java/org/opends/server/config/BooleanConfigAttribute.java
index 641f414..c2f9dec 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/config/BooleanConfigAttribute.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/config/BooleanConfigAttribute.java
@@ -28,7 +28,6 @@
import org.forgerock.i18n.LocalizableMessage;
-import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
@@ -44,6 +43,7 @@
import static org.opends.server.config.ConfigConstants.*;
import static org.opends.messages.ConfigMessages.*;
+import static org.opends.server.util.CollectionUtils.*;
import static org.opends.server.util.ServerConstants.*;
/**
@@ -357,7 +357,7 @@
*/
public List<String> activeValuesToStrings()
{
- return asList(String.valueOf(activeValue));
+ return newArrayList(String.valueOf(activeValue));
}
/**
@@ -375,18 +375,11 @@
{
if (hasPendingValues())
{
- return asList(String.valueOf(pendingValue));
+ return newArrayList(String.valueOf(pendingValue));
}
return null;
}
- private List<String> asList(String s)
- {
- ArrayList<String> result = new ArrayList<>(1);
- result.add(s);
- return result;
- }
-
/**
* Retrieves a new configuration attribute of this type that will contain the
* values from the provided attribute.
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/config/DNConfigAttribute.java b/opendj-server-legacy/src/main/java/org/opends/server/config/DNConfigAttribute.java
index e8fcab6..a123a60 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/config/DNConfigAttribute.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/config/DNConfigAttribute.java
@@ -26,7 +26,9 @@
*/
package org.opends.server.config;
-import org.forgerock.i18n.LocalizableMessage;
+import static org.opends.messages.ConfigMessages.*;
+import static org.opends.server.config.ConfigConstants.*;
+import static org.opends.server.util.CollectionUtils.*;
import java.lang.reflect.Array;
import java.util.ArrayList;
@@ -37,13 +39,13 @@
import javax.management.MBeanAttributeInfo;
import javax.management.MBeanParameterInfo;
+import org.forgerock.i18n.LocalizableMessage;
+import org.forgerock.i18n.slf4j.LocalizedLogger;
+import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.schema.Syntax;
import org.opends.server.core.DirectoryServer;
-import org.opends.server.types.*;
-import org.forgerock.opendj.ldap.ByteString;
-import static org.opends.server.config.ConfigConstants.*;
-import org.forgerock.i18n.slf4j.LocalizedLogger;
-import static org.opends.messages.ConfigMessages.*;
+import org.opends.server.types.Attribute;
+import org.opends.server.types.DN;
/**
* This class defines a DN configuration attribute, which can hold zero or more
@@ -125,8 +127,7 @@
}
else
{
- activeValues = new ArrayList<>(1);
- activeValues.add(value);
+ activeValues = newArrayList(value);
}
pendingValues = activeValues;
@@ -354,8 +355,7 @@
if (requiresAdminAction())
{
- pendingValues = new ArrayList<>(1);
- pendingValues.add(value);
+ pendingValues = newArrayList(value);
setPendingValues(getValueSet(value));
}
else
@@ -577,9 +577,7 @@
* @throws ConfigException If an unrecoverable problem occurs while
* performing the conversion.
*/
- public LinkedHashSet<ByteString>
- stringsToValues(List<String> valueStrings,
- boolean allowFailures)
+ public LinkedHashSet<ByteString> stringsToValues(List<String> valueStrings, boolean allowFailures)
throws ConfigException
{
if ((valueStrings == null) || valueStrings.isEmpty())
@@ -709,10 +707,7 @@
}
return valueStrings;
}
- else
- {
- return null;
- }
+ return null;
}
@@ -1243,4 +1238,3 @@
activeValues, pendingValues);
}
}
-
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/config/IntegerWithUnitConfigAttribute.java b/opendj-server-legacy/src/main/java/org/opends/server/config/IntegerWithUnitConfigAttribute.java
index cd2f0ee..f3d34e3 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/config/IntegerWithUnitConfigAttribute.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/config/IntegerWithUnitConfigAttribute.java
@@ -25,11 +25,11 @@
* Portions Copyright 2014-2015 ForgeRock AS
*/
package org.opends.server.config;
-import org.forgerock.i18n.LocalizableMessage;
+import static org.opends.messages.ConfigMessages.*;
+import static org.opends.server.config.ConfigConstants.*;
+import static org.opends.server.util.CollectionUtils.*;
-
-import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashSet;
@@ -39,13 +39,13 @@
import javax.management.MBeanAttributeInfo;
import javax.management.MBeanParameterInfo;
+import org.forgerock.i18n.LocalizableMessage;
+import org.forgerock.i18n.slf4j.LocalizedLogger;
+import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.schema.Syntax;
import org.opends.server.core.DirectoryServer;
-import org.opends.server.types.*;
-import org.forgerock.opendj.ldap.ByteString;
-import static org.opends.server.config.ConfigConstants.*;
-import org.forgerock.i18n.slf4j.LocalizedLogger;
-import static org.opends.messages.ConfigMessages.*;
+import org.opends.server.types.Attribute;
+
/**
* This class defines a configuration attribute that stores both an integer
* value and an associated unit. The unit will contain both a string and a
@@ -295,6 +295,7 @@
*
* @return The name of the data type for this configuration attribute.
*/
+ @Override
public String getDataType()
{
return "IntegerWithUnit";
@@ -307,6 +308,7 @@
*
* @return The attribute syntax for this configuration attribute.
*/
+ @Override
public Syntax getSyntax()
{
return DirectoryServer.getDefaultStringSyntax();
@@ -610,6 +612,7 @@
* configuration attribute. This will not take any action if there are no
* pending values.
*/
+ @Override
public void applyPendingValues()
{
if (! hasPendingValues())
@@ -637,6 +640,7 @@
* @return <CODE>true</CODE> if the provided value is acceptable for use in
* this attribute, or <CODE>false</CODE> if not.
*/
+ @Override
public boolean valueIsAcceptable(ByteString value,
StringBuilder rejectReason)
{
@@ -747,6 +751,7 @@
* @throws ConfigException If an unrecoverable problem occurs while
* performing the conversion.
*/
+ @Override
public LinkedHashSet<ByteString>
stringsToValues(List<String> valueStrings, boolean allowFailures)
throws ConfigException
@@ -837,12 +842,10 @@
* @return The string representations of the set of active values for this
* configuration attribute.
*/
+ @Override
public List<String> activeValuesToStrings()
{
- ArrayList<String> valueStrings = new ArrayList<>(1);
- valueStrings.add(activeIntValue + " " + activeUnit);
-
- return valueStrings;
+ return newArrayList(activeIntValue + " " + activeUnit);
}
@@ -858,18 +861,14 @@
* configuration attribute, or <CODE>null</CODE> if there are no
* pending values.
*/
+ @Override
public List<String> pendingValuesToStrings()
{
if (hasPendingValues())
{
- ArrayList<String> valueStrings = new ArrayList<>(1);
- valueStrings.add(pendingIntValue + " " + pendingUnit);
- return valueStrings;
+ return newArrayList(pendingIntValue + " " + pendingUnit);
}
- else
- {
- return null;
- }
+ return null;
}
@@ -895,6 +894,7 @@
* single-valued and the provided attribute has
* multiple values).
*/
+ @Override
public ConfigAttribute getConfigAttribute(List<Attribute> attributeList)
throws ConfigException
{
@@ -1096,6 +1096,7 @@
* configuration attribute, or <CODE>null</CODE> if it does not have
* any active values.
*/
+ @Override
public javax.management.Attribute toJMXAttribute()
{
return new javax.management.Attribute(getName(),
@@ -1110,6 +1111,7 @@
* configuration attribute, or <CODE>null</CODE> if it does not have
* any active values.
*/
+ @Override
public javax.management.Attribute toJMXAttributePending()
{
return new javax.management.Attribute(getName() + ";"
@@ -1129,6 +1131,7 @@
* The attribute list to which the JMX attribute(s) should
* be added.
*/
+ @Override
public void toJMXAttribute(AttributeList attributeList)
{
String activeValue = activeIntValue + " " + activeUnit;
@@ -1157,6 +1160,7 @@
* @param attributeInfoList The list to which the attribute information
* should be added.
*/
+ @Override
public void toJMXAttributeInfo(List<MBeanAttributeInfo> attributeInfoList)
{
attributeInfoList.add(new MBeanAttributeInfo(getName(),
@@ -1185,6 +1189,7 @@
* @return A JMX <CODE>MBeanParameterInfo</CODE> object that describes this
* configuration attribute.
*/
+ @Override
public MBeanParameterInfo toJMXParameterInfo()
{
return new MBeanParameterInfo(getName(), String.class.getName(),
@@ -1204,6 +1209,7 @@
* acceptable value for this configuration
* attribute.
*/
+ @Override
public void setValue(javax.management.Attribute jmxAttribute)
throws ConfigException
{
@@ -1226,6 +1232,7 @@
*
* @return A duplicate of this configuration attribute.
*/
+ @Override
public ConfigAttribute duplicate()
{
return new IntegerWithUnitConfigAttribute(getName(), getDescription(),
@@ -1236,4 +1243,3 @@
pendingIntValue, pendingUnit);
}
}
-
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/core/AddOperationBasis.java b/opendj-server-legacy/src/main/java/org/opends/server/core/AddOperationBasis.java
index 4c92712..c8c2564 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/core/AddOperationBasis.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/core/AddOperationBasis.java
@@ -46,6 +46,7 @@
import static org.opends.messages.CoreMessages.*;
import static org.opends.server.config.ConfigConstants.*;
import static org.opends.server.loggers.AccessLogger.*;
+import static org.opends.server.util.CollectionUtils.*;
import static org.opends.server.util.StaticUtils.*;
import static org.opends.server.workflowelement.localbackend.LocalBackendWorkflowElement.*;
@@ -160,38 +161,28 @@
rawEntryDN = ByteString.valueOf(entryDN.toString());
+ ArrayList<String> values = new ArrayList<>(objectClasses.values());
rawAttributes = new ArrayList<>();
-
- ArrayList<ByteString> ocValues = new ArrayList<>();
- for (String s : objectClasses.values())
- {
- ocValues.add(ByteString.valueOf(s));
- }
-
- LDAPAttribute ocAttr = new LDAPAttribute(ATTR_OBJECTCLASS, ocValues);
- rawAttributes.add(ocAttr);
-
- for (List<Attribute> attrList : userAttributes.values())
- {
- for (Attribute a : attrList)
- {
- rawAttributes.add(new LDAPAttribute(a));
- }
- }
-
- for (List<Attribute> attrList : operationalAttributes.values())
- {
- for (Attribute a : attrList)
- {
- rawAttributes.add(new LDAPAttribute(a));
- }
- }
+ rawAttributes.add(new LDAPAttribute(ATTR_OBJECTCLASS, values));
+ addAll(rawAttributes, userAttributes);
+ addAll(rawAttributes, operationalAttributes);
responseControls = new ArrayList<>();
proxiedAuthorizationDN = null;
cancelRequest = null;
}
+ private void addAll(List<RawAttribute> rawAttributes, Map<AttributeType, List<Attribute>> attributesToAdd)
+ {
+ for (List<Attribute> attrList : attributesToAdd.values())
+ {
+ for (Attribute a : attrList)
+ {
+ rawAttributes.add(new LDAPAttribute(a));
+ }
+ }
+ }
+
/** {@inheritDoc} */
@Override
public final ByteString getRawEntryDN()
@@ -374,21 +365,16 @@
if (attrs == null)
{
attrs = new ArrayList<>(1);
- attrs.add(attr);
operationalAttributes.put(attrType, attrs);
}
- else
- {
- attrs.add(attr);
- }
+ attrs.add(attr);
}
else
{
List<Attribute> attrs = userAttributes.get(attrType);
if (attrs == null)
{
- attrs = new ArrayList<>(1);
- attrs.add(attr);
+ attrs = newArrayList(attr);
userAttributes.put(attrType, attrs);
}
else
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/crypto/CryptoManagerImpl.java b/opendj-server-legacy/src/main/java/org/opends/server/crypto/CryptoManagerImpl.java
index 55ca6aa..2318dbb 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/crypto/CryptoManagerImpl.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/crypto/CryptoManagerImpl.java
@@ -73,7 +73,6 @@
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.protocols.ldap.ExtendedRequestProtocolOp;
import org.opends.server.protocols.ldap.ExtendedResponseProtocolOp;
import org.opends.server.protocols.ldap.LDAPMessage;
@@ -91,6 +90,8 @@
import static org.opends.messages.CoreMessages.*;
import static org.opends.server.config.ConfigConstants.*;
import static org.opends.server.protocols.internal.InternalClientConnection.*;
+import static org.opends.server.protocols.internal.Requests.*;
+import static org.opends.server.util.CollectionUtils.*;
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
@@ -1101,14 +1102,11 @@
// Write the value to the entry.
InternalClientConnection internalConnection =
InternalClientConnection.getRootConnection();
- List<Modification> modifications = new ArrayList<>(1);
Attribute attribute = Attributes.create(
ConfigConstants.ATTR_CRYPTO_SYMMETRIC_KEY, symmetricKey);
- modifications.add(
+ List<Modification> modifications = newArrayList(
new Modification(ModificationType.ADD, attribute, false));
- ModifyOperation internalModify =
- internalConnection.processModify(entry.getName(),
- modifications);
+ ModifyOperation internalModify = internalConnection.processModify(entry.getName(), modifications);
if (internalModify.getResultCode() != ResultCode.SUCCESS)
{
throw new CryptoManagerException(
@@ -1193,9 +1191,9 @@
isCompromised);
// Write the value to the entry.
- List<Modification> modifications = new ArrayList<>(1);
Attribute attribute = Attributes.create(ATTR_CRYPTO_SYMMETRIC_KEY, symmetricKey);
- modifications.add(new Modification(ModificationType.ADD, attribute, false));
+ List<Modification> modifications = newArrayList(
+ new Modification(ModificationType.ADD, attribute, false));
ModifyOperation internalModify =
getRootConnection().processModify(entry.getName(), modifications);
if (internalModify.getResultCode() != ResultCode.SUCCESS)
@@ -1522,17 +1520,9 @@
}
private static void putSingleValueAttribute(
- Map<AttributeType, List<Attribute>> attrs, AttributeType type,
- String value)
+ Map<AttributeType, List<Attribute>> attrs, AttributeType type, String value)
{
- attrs.put(type, asList(Attributes.create(type, value)));
- }
-
- private static <T> List<T> asList(T element)
- {
- ArrayList<T> attrList = new ArrayList<>(1);
- attrList.add(element);
- return attrList;
+ attrs.put(type, Attributes.createAsList(type, value));
}
/**
@@ -1625,7 +1615,7 @@
LinkedHashMap<AttributeType,List<Attribute>> userAttrs = new LinkedHashMap<>();
// Add the key ID attribute.
- userAttrs.put(attrKeyID, asList(Attributes.create(attrKeyID, distinguishedValue)));
+ userAttrs.put(attrKeyID, Attributes.createAsList(attrKeyID, distinguishedValue));
// Add the transformation name attribute.
putSingleValueAttribute(userAttrs, attrTransformation, keyEntry.getType());
@@ -1658,7 +1648,7 @@
builder.add(symmetricKey);
}
- userAttrs.put(attrSymmetricKey, asList(builder.toAttribute()));
+ userAttrs.put(attrSymmetricKey, builder.toAttributeList());
// Create the entry.
Entry entry = new Entry(entryDN, ocMap, userAttrs, opAttrs);
@@ -2146,7 +2136,7 @@
LinkedHashMap<AttributeType,List<Attribute>> userAttrs = new LinkedHashMap<>();
// Add the key ID attribute.
- userAttrs.put(attrKeyID, asList(Attributes.create(attrKeyID, distinguishedValue)));
+ userAttrs.put(attrKeyID, Attributes.createAsList(attrKeyID, distinguishedValue));
// Add the mac algorithm name attribute.
putSingleValueAttribute(userAttrs, attrMacAlgorithm, keyEntry.getType());
@@ -2176,7 +2166,7 @@
builder.add(symmetricKey);
}
- userAttrs.put(attrSymmetricKey, asList(builder.toAttribute()));
+ userAttrs.put(attrSymmetricKey, builder.toAttributeList());
// Create the entry.
Entry entry = new Entry(entryDN, ocMap, userAttrs, opAttrs);
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/extensions/PasswordModifyExtendedOperation.java b/opendj-server-legacy/src/main/java/org/opends/server/extensions/PasswordModifyExtendedOperation.java
index 99ca485..f9e4ffe 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/extensions/PasswordModifyExtendedOperation.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/extensions/PasswordModifyExtendedOperation.java
@@ -31,6 +31,7 @@
import static org.opends.server.extensions.ExtensionsConstants.*;
import static org.opends.server.protocols.internal.InternalClientConnection.*;
import static org.opends.server.types.AccountStatusNotificationType.*;
+import static org.opends.server.util.CollectionUtils.*;
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
@@ -676,8 +677,7 @@
List<ByteString> encodedPasswords;
if (isPreEncoded)
{
- encodedPasswords = new ArrayList<>(1);
- encodedPasswords.add(newPassword);
+ encodedPasswords = newArrayList(newPassword);
}
else
{
@@ -885,11 +885,9 @@
List<ByteString> currentPasswords = null;
if (oldPassword != null)
{
- currentPasswords = new ArrayList<>(1);
- currentPasswords.add(oldPassword);
+ currentPasswords = newArrayList(oldPassword);
}
- List<ByteString> newPasswords = new ArrayList<>(1);
- newPasswords.add(newPassword);
+ List<ByteString> newPasswords = newArrayList(newPassword);
Map<AccountStatusNotificationProperty, List<String>> notifProperties =
AccountStatusNotification.createProperties(pwPolicyState, false, -1, currentPasswords, newPasswords);
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/extensions/PasswordPolicyStateExtendedOperation.java b/opendj-server-legacy/src/main/java/org/opends/server/extensions/PasswordPolicyStateExtendedOperation.java
index 91871f4..bc22404 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/extensions/PasswordPolicyStateExtendedOperation.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/extensions/PasswordPolicyStateExtendedOperation.java
@@ -59,6 +59,7 @@
import static org.opends.messages.CoreMessages.*;
import static org.opends.messages.ExtensionMessages.*;
+import static org.opends.server.util.CollectionUtils.*;
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
@@ -1307,9 +1308,7 @@
case OP_SET_AUTHENTICATION_FAILURE_TIMES:
if (opValues == null)
{
- ArrayList<Long> valueList = new ArrayList<>(1);
- valueList.add(pwpState.getCurrentTime());
- pwpState.setAuthFailureTimes(valueList);
+ pwpState.setAuthFailureTimes(newArrayList(pwpState.getCurrentTime()));
}
else
{
@@ -1488,9 +1487,7 @@
case OP_SET_GRACE_LOGIN_USE_TIMES:
if (opValues == null)
{
- ArrayList<Long> valueList = new ArrayList<>(1);
- valueList.add(pwpState.getCurrentTime());
- pwpState.setGraceLoginTimes(valueList);
+ pwpState.setGraceLoginTimes(newArrayList(pwpState.getCurrentTime()));
}
else
{
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/monitors/ClientConnectionMonitorProvider.java b/opendj-server-legacy/src/main/java/org/opends/server/monitors/ClientConnectionMonitorProvider.java
index b811e39..08fc046 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/monitors/ClientConnectionMonitorProvider.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/monitors/ClientConnectionMonitorProvider.java
@@ -26,25 +26,21 @@
*/
package org.opends.server.monitors;
-
-
-import java.util.ArrayList;
import java.util.Collection;
+import java.util.List;
import java.util.TreeMap;
+import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.admin.std.server.ClientConnectionMonitorProviderCfg;
import org.opends.server.api.ClientConnection;
import org.opends.server.api.ConnectionHandler;
import org.opends.server.api.MonitorProvider;
-import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeBuilder;
import org.opends.server.types.AttributeType;
import org.opends.server.types.InitializationException;
-
-
/**
* This class defines a Directory Server monitor provider that can be
* used to obtain information about the client connections established
@@ -133,7 +129,7 @@
* is requested.
*/
@Override
- public ArrayList<Attribute> getMonitorData()
+ public List<Attribute> getMonitorData()
{
// Re-order the connections by connection ID.
TreeMap<Long, ClientConnection> connMap = new TreeMap<>();
@@ -162,16 +158,12 @@
}
}
- AttributeType attrType =
- DirectoryServer.getDefaultAttributeType("connection");
+ AttributeType attrType = DirectoryServer.getDefaultAttributeType("connection");
AttributeBuilder builder = new AttributeBuilder(attrType);
for (ClientConnection conn : connMap.values())
{
builder.add(conn.getMonitorSummary());
}
-
- ArrayList<Attribute> attrs = new ArrayList<>(1);
- attrs.add(builder.toAttribute());
- return attrs;
+ return builder.toAttributeList();
}
}
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 d292474..f6f102b 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
@@ -28,7 +28,6 @@
import static org.opends.messages.PluginMessages.*;
-import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
@@ -167,12 +166,9 @@
byte[] dnBytes = entry.getName().toNormalizedByteString().toByteArray();
UUID uuid = UUID.nameUUIDFromBytes(dnBytes);
- Attribute uuidAttr = Attributes.create(entryUUIDType, uuid.toString());
- uuidList = new ArrayList<>(1);
- uuidList.add(uuidAttr);
+ uuidList = Attributes.createAsList(entryUUIDType, uuid.toString());
entry.putAttribute(entryUUIDType, uuidList);
-
// We shouldn't ever need to return a non-success result.
return PluginResult.ImportLDIF.continueEntryProcessing();
}
@@ -198,10 +194,7 @@
// Construct a new random UUID.
UUID uuid = UUID.randomUUID();
- Attribute uuidAttr = Attributes.create(entryUUIDType, uuid.toString());
- uuidList = new ArrayList<>(1);
- uuidList.add(uuidAttr);
-
+ uuidList = Attributes.createAsList(entryUUIDType, uuid.toString());
// Add the attribute to the entry and return.
addOperation.setAttribute(entryUUIDType, uuidList);
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/plugins/LastModPlugin.java b/opendj-server-legacy/src/main/java/org/opends/server/plugins/LastModPlugin.java
index de50419..a5924d9 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/plugins/LastModPlugin.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/plugins/LastModPlugin.java
@@ -26,12 +26,13 @@
*/
package org.opends.server.plugins;
-import java.util.ArrayList;
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.ConfigChangeResult;
+import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ModificationType;
import org.opends.server.admin.server.ConfigurationChangeListener;
@@ -41,8 +42,6 @@
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.types.*;
import org.opends.server.types.operation.PreOperationAddOperation;
import org.opends.server.types.operation.PreOperationModifyDNOperation;
@@ -66,21 +65,16 @@
/** The attribute type for the "createTimestamp" attribute. */
private final AttributeType createTimestampType;
-
/** The attribute type for the "creatorsName" attribute. */
private final AttributeType creatorsNameType;
-
/** The attribute type for the "modifiersName" attribute. */
private final AttributeType modifiersNameType;
-
/** The attribute type for the "modifyTimestamp" attribute. */
private final AttributeType modifyTimestampType;
-
/** The current configuration for this plugin. */
private LastModPluginCfg currentConfig;
-
/**
* Creates a new instance of this Directory Server plugin. Every plugin must
* implement a default constructor (it is the only one that will be used to
@@ -163,20 +157,14 @@
{
builder.add(creatorDN.toString());
}
- Attribute nameAttr = builder.toAttribute();
- ArrayList<Attribute> nameList = new ArrayList<>(1);
- nameList.add(nameAttr);
- addOperation.setAttribute(creatorsNameType, nameList);
+ addOperation.setAttribute(creatorsNameType, builder.toAttributeList());
// Create the attribute list for the createTimestamp attribute.
- Attribute timeAttr = Attributes.create(createTimestampType,
- OP_ATTR_CREATE_TIMESTAMP, getGMTTime());
- ArrayList<Attribute> timeList = new ArrayList<>(1);
- timeList.add(timeAttr);
+ List<Attribute> timeList = Attributes.createAsList(
+ createTimestampType, OP_ATTR_CREATE_TIMESTAMP, getGMTTime());
addOperation.setAttribute(createTimestampType, timeList);
-
// We shouldn't ever need to return a non-success result.
return PluginResult.PreOperation.continueOperationProcessing();
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/protocols/ldap/LDAPAttribute.java b/opendj-server-legacy/src/main/java/org/opends/server/protocols/ldap/LDAPAttribute.java
index d07e732..b9b4a95 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/protocols/ldap/LDAPAttribute.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/protocols/ldap/LDAPAttribute.java
@@ -27,6 +27,7 @@
package org.opends.server.protocols.ldap;
import static org.opends.messages.ProtocolMessages.*;
+import static org.opends.server.util.CollectionUtils.*;
import static org.opends.server.util.ServerConstants.*;
import java.util.ArrayList;
@@ -34,8 +35,11 @@
import java.util.List;
import org.forgerock.i18n.LocalizableMessage;
-import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ByteString;
+import org.opends.server.types.Attribute;
+import org.opends.server.types.AttributeBuilder;
+import org.opends.server.types.LDAPException;
+import org.opends.server.types.RawAttribute;
/**
* This class defines the data structures and methods to use when interacting
@@ -77,8 +81,7 @@
{
this.attributeType = attributeType;
- values = new ArrayList<>(1);
- values.add(ByteString.valueOf(value));
+ values = newArrayList(ByteString.valueOf(value));
}
@@ -93,8 +96,7 @@
{
this.attributeType = attributeType;
- values = new ArrayList<>(1);
- values.add(value);
+ values = newArrayList(value);
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/protocols/ldap/SearchResultEntryProtocolOp.java b/opendj-server-legacy/src/main/java/org/opends/server/protocols/ldap/SearchResultEntryProtocolOp.java
index 064c2c2..9dc313b 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/protocols/ldap/SearchResultEntryProtocolOp.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/protocols/ldap/SearchResultEntryProtocolOp.java
@@ -27,6 +27,7 @@
package org.opends.server.protocols.ldap;
import static org.opends.server.protocols.ldap.LDAPConstants.*;
+import static org.opends.server.util.CollectionUtils.*;
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
@@ -38,12 +39,12 @@
import java.util.List;
import java.util.Map;
-import org.opends.server.core.DirectoryServer;
import org.forgerock.opendj.io.ASN1Writer;
+import org.forgerock.opendj.ldap.ByteString;
+import org.opends.server.core.DirectoryServer;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeBuilder;
import org.opends.server.types.AttributeType;
-import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.types.DN;
import org.opends.server.types.Entry;
import org.opends.server.types.LDAPException;
@@ -573,21 +574,16 @@
if (attrs == null)
{
attrs = new ArrayList<>(1);
- attrs.add(attr);
operationalAttributes.put(attrType, attrs);
}
- else
- {
- attrs.add(attr);
- }
+ attrs.add(attr);
}
else
{
List<Attribute> attrs = userAttributes.get(attrType);
if (attrs == null)
{
- attrs = new ArrayList<>(1);
- attrs.add(attr);
+ attrs = newArrayList(attr);
userAttributes.put(attrType, attrs);
}
else
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 9dc7273..ebf974e 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
@@ -34,6 +34,7 @@
import static org.opends.server.replication.plugin.EntryHistorical.*;
import static org.opends.server.replication.protocol.OperationContext.*;
import static org.opends.server.replication.service.ReplicationMonitor.*;
+import static org.opends.server.util.CollectionUtils.*;
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
@@ -65,9 +66,9 @@
import org.opends.server.admin.std.server.ReplicationDomainCfg;
import org.opends.server.api.AlertGenerator;
import org.opends.server.api.Backend;
+import org.opends.server.api.Backend.BackendOperation;
import org.opends.server.api.DirectoryThread;
import org.opends.server.api.SynchronizationProvider;
-import org.opends.server.api.Backend.BackendOperation;
import org.opends.server.backends.task.Task;
import org.opends.server.core.*;
import org.opends.server.protocols.internal.InternalClientConnection;
@@ -1235,8 +1236,7 @@
// find the attribute/value pair matching the pair in the RDN
{
// Construct and store new attribute list
- newRdnAttrLists.add(
- newList(Attributes.create(attributeType, sameAttrValue)));
+ newRdnAttrLists.add(Attributes.createAsList(attributeType, sameAttrValue));
/*
Store matching attribute type
The mapping will be done using object from rdnAttrTypes as key
@@ -1262,22 +1262,7 @@
return hasSomeAttributesToFilter;
}
- private static <T> ArrayList<T> newList(T elem)
- {
- final ArrayList<T> list = new ArrayList<>(1);
- list.add(elem);
- return list;
- }
-
- private static <T> Set<T> newSet(T elem)
- {
- final Set<T> list = new LinkedHashSet<>(1);
- list.add(elem);
- return list;
- }
-
- private static boolean isMandatoryAttribute(Set<ObjectClass> entryClasses,
- AttributeType attributeType)
+ private static boolean isMandatoryAttribute(Set<ObjectClass> entryClasses, AttributeType attributeType)
{
for (ObjectClass objectClass : entryClasses)
{
@@ -3018,11 +3003,9 @@
private void markConflictEntry(Operation op, DN currentDN, DN conflictDN)
{
// create new internal modify operation and run it.
- AttributeType attrType = DirectoryServer.getAttributeType(DS_SYNC_CONFLICT,
- true);
+ AttributeType attrType = DirectoryServer.getAttributeType(DS_SYNC_CONFLICT, true);
Attribute attr = Attributes.create(attrType, conflictDN.toString());
- List<Modification> mods =
- newList(new Modification(ModificationType.REPLACE, attr));
+ List<Modification> mods = newArrayList(new Modification(ModificationType.REPLACE, attr));
ModifyOperation newOp = new ModifyOperationBasis(
conn, nextOperationID(), nextMessageID(), new ArrayList<Control>(0),
@@ -3202,10 +3185,8 @@
{
// The generationId is stored in the root entry of the domain.
final ByteString asn1BaseDn = ByteString.valueOf(entryDN.toString());
- final ArrayList<ByteString> values =
- newList(ByteString.valueOf(Long.toString(generationId)));
- LDAPAttribute attr = new LDAPAttribute(REPLICATION_GENERATION_ID, values);
+ LDAPAttribute attr = new LDAPAttribute(REPLICATION_GENERATION_ID, Long.toString(generationId));
List<RawModification> mods = new ArrayList<>(1);
mods.add(new LDAPModification(ModificationType.REPLACE, attr));
@@ -3439,7 +3420,7 @@
// baseDN branch is the only one included in the export
LDIFExportConfig exportConfig = new LDIFExportConfig(os);
- exportConfig.setIncludeBranches(newList(getBaseDN()));
+ exportConfig.setIncludeBranches(newArrayList(getBaseDN()));
// For the checksum computing mode, only consider the 'stable' attributes
if (checksumOutput)
@@ -3566,7 +3547,7 @@
}
importConfig = new LDIFImportConfig(input);
- importConfig.setIncludeBranches(newSet(getBaseDN()));
+ importConfig.setIncludeBranches(newLinkedHashSet(getBaseDN()));
importConfig.setAppendToExistingData(false);
importConfig.setSkipDNValidation(true);
// We should not validate schema for replication
@@ -4993,8 +4974,7 @@
entryHist.setPurgeDelay(getHistoricalPurgeDelay());
Attribute attr = entryHist.encodeAndPurge();
count += entryHist.getLastPurgedValuesCount();
- List<Modification> mods =
- newList(new Modification(ModificationType.REPLACE, attr));
+ List<Modification> mods = newArrayList(new Modification(ModificationType.REPLACE, attr));
ModifyOperation newOp = new ModifyOperationBasis(
conn, nextOperationID(), nextMessageID(), new ArrayList<Control>(0),
@@ -5012,5 +4992,4 @@
}
}
}
-
}
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 0193103..5e0aa48 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
@@ -22,17 +22,19 @@
*
*
* Copyright 2006-2010 Sun Microsystems, Inc.
- * Portions Copyright 2012-2014 ForgeRock AS.
+ * Portions Copyright 2012-2015 ForgeRock AS.
*/
package org.opends.server.replication.plugin;
-import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import org.forgerock.i18n.slf4j.LocalizedLogger;
-import org.forgerock.opendj.ldap.*;
+import org.forgerock.opendj.ldap.ByteString;
+import org.forgerock.opendj.ldap.ModificationType;
+import org.forgerock.opendj.ldap.ResultCode;
+import org.forgerock.opendj.ldap.SearchScope;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.ModifyOperationBasis;
import org.opends.server.protocols.internal.InternalSearchOperation;
@@ -41,9 +43,12 @@
import org.opends.server.protocols.ldap.LDAPModification;
import org.opends.server.replication.common.CSN;
import org.opends.server.replication.common.ServerState;
-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.DirectoryException;
+import org.opends.server.types.RawModification;
+import org.opends.server.types.SearchResultEntry;
import static org.opends.messages.ReplicationMessages.*;
import static org.opends.server.protocols.internal.InternalClientConnection.*;
@@ -56,7 +61,6 @@
*/
class PersistentServerState
{
-
private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
private final DN baseDN;
@@ -261,9 +265,7 @@
*/
private ResultCode runUpdateStateEntry(DN serverStateEntryDN)
{
- ArrayList<ByteString> values = state.toASN1ArrayList();
-
- LDAPAttribute attr = new LDAPAttribute(REPLICATION_STATE, values);
+ LDAPAttribute attr = new LDAPAttribute(REPLICATION_STATE, state.toASN1ArrayList());
RawModification mod = new LDAPModification(ModificationType.REPLACE, attr);
ModifyOperationBasis op = new ModifyOperationBasis(getRootConnection(),
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tasks/TaskUtils.java b/opendj-server-legacy/src/main/java/org/opends/server/tasks/TaskUtils.java
index 8926338..32717ed 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tasks/TaskUtils.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tasks/TaskUtils.java
@@ -46,18 +46,19 @@
import org.opends.server.config.StringConfigAttribute;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.ModifyOperation;
-import org.opends.server.protocols.internal.InternalClientConnection;
import org.opends.server.protocols.ldap.LDAPAttribute;
import org.opends.server.protocols.ldap.LDAPModification;
import org.opends.server.types.Attribute;
import org.opends.server.types.DN;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.RawModification;
+import org.opends.server.util.CollectionUtils;
import org.opends.server.util.ServerConstants;
import static org.opends.messages.ConfigMessages.*;
import static org.opends.messages.ToolMessages.*;
import static org.opends.server.config.ConfigConstants.*;
+import static org.opends.server.protocols.internal.InternalClientConnection.*;
import static org.opends.server.util.StaticUtils.*;
/**
@@ -234,21 +235,14 @@
e.getMessageObject(), e);
}
- ArrayList<ByteString> valueList = new ArrayList<>(1);
- valueList.add(ServerConstants.TRUE_VALUE);
- LDAPAttribute a = new LDAPAttribute(ATTR_BACKEND_ENABLED, valueList);
-
+ LDAPAttribute a = new LDAPAttribute(ATTR_BACKEND_ENABLED, ServerConstants.TRUE_VALUE);
LDAPModification m = new LDAPModification(ModificationType.REPLACE, a);
- ArrayList<RawModification> modList = new ArrayList<>(1);
- modList.add(m);
+ ArrayList<RawModification> modList = CollectionUtils.<RawModification> newArrayList(m);
- InternalClientConnection conn =
- InternalClientConnection.getRootConnection();
String backendDNString = configEntryDN.toString();
- ByteString rawEntryDN =
- ByteString.valueOf(backendDNString);
- ModifyOperation internalModify = conn.processModify(rawEntryDN, modList);
+ ByteString rawEntryDN = ByteString.valueOf(backendDNString);
+ ModifyOperation internalModify = getRootConnection().processModify(rawEntryDN, modList);
ResultCode resultCode = internalModify.getResultCode();
if (resultCode != ResultCode.SUCCESS)
@@ -284,21 +278,14 @@
e.getMessageObject(), e);
}
- ArrayList<ByteString> valueList = new ArrayList<>(1);
- valueList.add(ServerConstants.FALSE_VALUE);
- LDAPAttribute a = new LDAPAttribute(ATTR_BACKEND_ENABLED, valueList);
-
+ LDAPAttribute a = new LDAPAttribute(ATTR_BACKEND_ENABLED, ServerConstants.FALSE_VALUE);
LDAPModification m = new LDAPModification(ModificationType.REPLACE, a);
- ArrayList<RawModification> modList = new ArrayList<>(1);
- modList.add(m);
+ ArrayList<RawModification> modList = CollectionUtils.<RawModification> newArrayList(m);
- InternalClientConnection conn =
- InternalClientConnection.getRootConnection();
String backendDNString = configEntryDN.toString();
- ByteString rawEntryDN =
- ByteString.valueOf(backendDNString);
- ModifyOperation internalModify = conn.processModify(rawEntryDN, modList);
+ ByteString rawEntryDN = ByteString.valueOf(backendDNString);
+ ModifyOperation internalModify = getRootConnection().processModify(rawEntryDN, modList);
ResultCode resultCode = internalModify.getResultCode();
if (resultCode != ResultCode.SUCCESS)
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tools/BackUpDB.java b/opendj-server-legacy/src/main/java/org/opends/server/tools/BackUpDB.java
index 26add20..2184b81 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tools/BackUpDB.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tools/BackUpDB.java
@@ -48,7 +48,6 @@
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.util.Utils;
import org.opends.server.admin.std.server.BackendCfg;
import org.opends.server.api.Backend;
@@ -432,12 +431,8 @@
List<String> backendIDs = backendID.getValues();
if (backendIDs != null && !backendIDs.isEmpty()) {
- ArrayList<ByteString> values = new ArrayList<>(backendIDs.size());
- for (String s : backendIDs) {
- values.add(ByteString.valueOf(s));
- }
attributes.add(
- new LDAPAttribute(ATTR_TASK_BACKUP_BACKEND_ID, values));
+ new LDAPAttribute(ATTR_TASK_BACKUP_BACKEND_ID, backendIDs));
}
addIfHasValue(attributes, ATTR_BACKUP_ID, backupIDString);
@@ -448,7 +443,7 @@
private void addIfHasValue(List<RawAttribute> attributes, String attrName, Argument arg)
{
if (hasValueDifferentThanDefaultValue(arg)) {
- attributes.add(new LDAPAttribute(attrName, asList(arg.getValue())));
+ attributes.add(new LDAPAttribute(attrName, arg.getValue()));
}
}
@@ -458,13 +453,6 @@
&& !arg.getValue().equals(arg.getDefaultValue());
}
- private ArrayList<ByteString> asList(String value)
- {
- ArrayList<ByteString> values = new ArrayList<>(1);
- values.add(ByteString.valueOf(value));
- return values;
- }
-
/** {@inheritDoc} */
@Override
public String getTaskObjectclass() {
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tools/ExportLDIF.java b/opendj-server-legacy/src/main/java/org/opends/server/tools/ExportLDIF.java
index a096cf4..1000401 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tools/ExportLDIF.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tools/ExportLDIF.java
@@ -42,7 +42,6 @@
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.std.server.BackendCfg;
import org.opends.server.api.Backend;
import org.opends.server.api.Backend.BackendOperation;
@@ -370,8 +369,8 @@
public void addTaskAttributes(List<RawAttribute> attributes)
{
// Required attributes
- attributes.add(new LDAPAttribute(ATTR_TASK_EXPORT_LDIF_FILE, toByteStrings(ldifFile.getValue())));
- attributes.add(new LDAPAttribute(ATTR_TASK_EXPORT_BACKEND_ID, toByteStrings(backendID.getValue())));
+ attributes.add(new LDAPAttribute(ATTR_TASK_EXPORT_LDIF_FILE, ldifFile.getValue()));
+ attributes.add(new LDAPAttribute(ATTR_TASK_EXPORT_BACKEND_ID, backendID.getValue()));
// Optional attributes
addAttribute(attributes, ATTR_TASK_EXPORT_APPEND_TO_LDIF, appendToLDIF);
@@ -389,8 +388,7 @@
if (excludeOperationalAttrs.isPresent())
{
attributes.add(
- new LDAPAttribute(ATTR_TASK_EXPORT_INCLUDE_OPERATIONAL_ATTRIBUTES,
- toByteStrings("false")));
+ new LDAPAttribute(ATTR_TASK_EXPORT_INCLUDE_OPERATIONAL_ATTRIBUTES, "false"));
}
}
@@ -398,7 +396,7 @@
{
if (arg.getValue() != null && !arg.getValue().equals(arg.getDefaultValue()))
{
- attributes.add(new LDAPAttribute(attrName, toByteStrings(arg.getValue())));
+ attributes.add(new LDAPAttribute(attrName, arg.getValue()));
}
}
@@ -406,27 +404,10 @@
{
if (attrValues != null && !attrValues.isEmpty())
{
- attributes.add(new LDAPAttribute(attrName, toByteStrings(attrValues)));
+ attributes.add(new LDAPAttribute(attrName, attrValues));
}
}
- private ArrayList<ByteString> toByteStrings(String value)
- {
- final ArrayList<ByteString> values = new ArrayList<>(1);
- values.add(ByteString.valueOf(value));
- return values;
- }
-
- private ArrayList<ByteString> toByteStrings(List<String> includeAttributes)
- {
- final ArrayList<ByteString> values = new ArrayList<>(includeAttributes.size());
- for (String includeAttribute : includeAttributes)
- {
- values.add(ByteString.valueOf(includeAttribute));
- }
- return values;
- }
-
/** {@inheritDoc} */
@Override
public String getTaskObjectclass() {
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tools/ImportLDIF.java b/opendj-server-legacy/src/main/java/org/opends/server/tools/ImportLDIF.java
index 620e236..5a0d634 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tools/ImportLDIF.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tools/ImportLDIF.java
@@ -45,7 +45,6 @@
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.BackendCfg;
import org.opends.server.api.Backend;
@@ -547,7 +546,7 @@
{
if (value != null)
{
- attributes.add(new LDAPAttribute(attrName, toByteStrings(value)));
+ attributes.add(new LDAPAttribute(attrName, value));
}
}
@@ -556,7 +555,7 @@
final String value = arg.getValue();
if (value != null && !value.equals(arg.getDefaultValue()))
{
- attributes.add(new LDAPAttribute(attrName, toByteStrings(value)));
+ attributes.add(new LDAPAttribute(attrName, value));
}
}
@@ -564,27 +563,10 @@
{
if (attrValues != null && !attrValues.isEmpty())
{
- attributes.add(new LDAPAttribute(attrName, toByteStrings(attrValues)));
+ attributes.add(new LDAPAttribute(attrName, attrValues));
}
}
- private ArrayList<ByteString> toByteStrings(String value)
- {
- final ArrayList<ByteString> values = new ArrayList<>(1);
- values.add(ByteString.valueOf(value));
- return values;
- }
-
- private ArrayList<ByteString> toByteStrings(List<String> attrValues)
- {
- final ArrayList<ByteString> values = new ArrayList<>(attrValues.size());
- for (String includeBranche : attrValues)
- {
- values.add(ByteString.valueOf(includeBranche));
- }
- return values;
- }
-
/** {@inheritDoc} */
@Override
public String getTaskObjectclass() {
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tools/RebuildIndex.java b/opendj-server-legacy/src/main/java/org/opends/server/tools/RebuildIndex.java
index bedeb45..cee008c 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tools/RebuildIndex.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tools/RebuildIndex.java
@@ -42,7 +42,6 @@
import org.forgerock.i18n.LocalizableMessageDescriptor.Arg1;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.config.server.ConfigException;
-import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.admin.std.server.BackendCfg;
import org.opends.server.api.Backend;
import org.opends.server.api.Backend.BackendOperation;
@@ -767,13 +766,7 @@
// Required attributes
addLdapAttribute(attributes, ATTR_REBUILD_BASE_DN, baseDNString.getValue());
- final List<String> indexes = indexList.getValues();
- final ArrayList<ByteString> values = new ArrayList<>(indexes.size());
- for (final String s : indexes)
- {
- values.add(ByteString.valueOf(s));
- }
- attributes.add(new LDAPAttribute(ATTR_REBUILD_INDEX, values));
+ attributes.add(new LDAPAttribute(ATTR_REBUILD_INDEX, indexList.getValues()));
if (hasNonDefaultValue(tmpDirectory))
{
@@ -798,7 +791,7 @@
private void addLdapAttribute(List<RawAttribute> attributes, String attrType, String attrValue)
{
- attributes.add(new LDAPAttribute(attrType, toByteStrings(attrValue)));
+ attributes.add(new LDAPAttribute(attrType, attrValue));
}
private boolean hasNonDefaultValue(BooleanArgument arg)
@@ -813,13 +806,6 @@
&& !arg.getValue().equals(arg.getDefaultValue());
}
- private ArrayList<ByteString> toByteStrings(String value)
- {
- final ArrayList<ByteString> values = new ArrayList<>(1);
- values.add(ByteString.valueOf(value));
- return values;
- }
-
/** {@inheritDoc} */
@Override
public String getTaskObjectclass()
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tools/RestoreDB.java b/opendj-server-legacy/src/main/java/org/opends/server/tools/RestoreDB.java
index f7987ef..ea91838 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tools/RestoreDB.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tools/RestoreDB.java
@@ -45,7 +45,6 @@
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.std.server.BackendCfg;
import org.opends.server.api.Backend;
import org.opends.server.api.Backend.BackendOperation;
@@ -302,17 +301,10 @@
{
if (arg.getValue() != null && !arg.getValue().equals(arg.getDefaultValue()))
{
- attributes.add(new LDAPAttribute(attrName, toByteStrings(arg.getValue())));
+ attributes.add(new LDAPAttribute(attrName, arg.getValue()));
}
}
- private ArrayList<ByteString> toByteStrings(String value)
- {
- final ArrayList<ByteString> values = new ArrayList<>(1);
- values.add(ByteString.valueOf(value));
- return values;
- }
-
/** {@inheritDoc} */
@Override
public String getTaskObjectclass() {
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tools/StopDS.java b/opendj-server-legacy/src/main/java/org/opends/server/tools/StopDS.java
index d6f0732..a33cc6d 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tools/StopDS.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tools/StopDS.java
@@ -31,6 +31,7 @@
import static org.opends.messages.ToolMessages.*;
import static org.opends.server.config.ConfigConstants.*;
+import static org.opends.server.util.CollectionUtils.*;
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
@@ -618,56 +619,34 @@
SCHEDULED_TASK_BASE_RDN + "," + DN_TASK_ROOT);
ArrayList<RawAttribute> attributes = new ArrayList<>();
-
- ArrayList<ByteString> ocValues = new ArrayList<>(3);
- ocValues.add(ByteString.valueOf("top"));
- ocValues.add(ByteString.valueOf("ds-task"));
- ocValues.add(ByteString.valueOf("ds-task-shutdown"));
- attributes.add(new LDAPAttribute(ATTR_OBJECTCLASS, ocValues));
-
- ArrayList<ByteString> taskIDValues = new ArrayList<>(1);
- taskIDValues.add(ByteString.valueOf(taskID));
- attributes.add(new LDAPAttribute(ATTR_TASK_ID, taskIDValues));
-
- ArrayList<ByteString> classValues = new ArrayList<>(1);
- classValues.add(ByteString.valueOf(ShutdownTask.class.getName()));
- attributes.add(new LDAPAttribute(ATTR_TASK_CLASS, classValues));
-
+ attributes.add(new LDAPAttribute(ATTR_OBJECTCLASS, newArrayList("top", "ds-task", "ds-task-shutdown")));
+ attributes.add(new LDAPAttribute(ATTR_TASK_ID, taskID));
+ attributes.add(new LDAPAttribute(ATTR_TASK_CLASS, ShutdownTask.class.getName()));
if (restart.isPresent())
{
- ArrayList<ByteString> restartValues = new ArrayList<>(1);
- restartValues.add(ByteString.valueOf("true"));
- attributes.add(new LDAPAttribute(ATTR_RESTART_SERVER, restartValues));
+ attributes.add(new LDAPAttribute(ATTR_RESTART_SERVER, "true"));
}
-
if (stopReason.isPresent())
{
- ArrayList<ByteString> stopReasonValues = new ArrayList<>(1);
- stopReasonValues.add(ByteString.valueOf(stopReason.getValue()));
- attributes.add(new LDAPAttribute(ATTR_SHUTDOWN_MESSAGE, stopReasonValues));
+ attributes.add(new LDAPAttribute(ATTR_SHUTDOWN_MESSAGE, stopReason.getValue()));
}
if (stopTime != null)
{
- ArrayList<ByteString> stopTimeValues = new ArrayList<>(1);
-
SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT_GMT_TIME);
dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
- stopTimeValues.add(ByteString.valueOf(dateFormat.format(stopTime)));
- attributes.add(new LDAPAttribute(ATTR_TASK_SCHEDULED_START_TIME,
- stopTimeValues));
+ String stopTimeValues = dateFormat.format(stopTime);
+ attributes.add(new LDAPAttribute(ATTR_TASK_SCHEDULED_START_TIME, stopTimeValues));
}
ArrayList<Control> controls = new ArrayList<>();
if (proxyAuthzID.isPresent())
{
- Control c = new ProxiedAuthV2Control(
- ByteString.valueOf(proxyAuthzID.getValue()));
- controls.add(c);
+ controls.add(new ProxiedAuthV2Control(
+ ByteString.valueOf(proxyAuthzID.getValue())));
}
- AddRequestProtocolOp addRequest = new AddRequestProtocolOp(entryDN,
- attributes);
+ AddRequestProtocolOp addRequest = new AddRequestProtocolOp(entryDN, attributes);
LDAPMessage requestMessage =
new LDAPMessage(nextMessageID.getAndIncrement(), addRequest, controls);
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tools/dsreplication/PurgeHistoricalScheduleInformation.java b/opendj-server-legacy/src/main/java/org/opends/server/tools/dsreplication/PurgeHistoricalScheduleInformation.java
index 4f5953f..d55800e 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tools/dsreplication/PurgeHistoricalScheduleInformation.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tools/dsreplication/PurgeHistoricalScheduleInformation.java
@@ -26,7 +26,6 @@
*/
package org.opends.server.tools.dsreplication;
-import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@@ -35,14 +34,12 @@
import org.opends.server.protocols.ldap.LDAPAttribute;
import org.opends.server.tools.tasks.TaskScheduleInformation;
import org.opends.server.tools.tasks.TaskScheduleUserData;
-import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.types.RawAttribute;
/**
* This is a simple adaptor to create a task schedule information object
* using the data provided by the user. It is used to be able to share some
* code with the {@link TaskTool} class.
- *
*/
public class PurgeHistoricalScheduleInformation
implements TaskScheduleInformation
@@ -68,17 +65,11 @@
/** {@inheritDoc} */
public void addTaskAttributes(List<RawAttribute> attributes)
{
- ArrayList<ByteString> baseDNs = new ArrayList<>();
- for (String baseDN : uData.getBaseDNs())
- {
- baseDNs.add(ByteString.valueOf(baseDN));
- }
attributes.add(new LDAPAttribute(
- ConfigConstants.ATTR_TASK_CONFLICTS_HIST_PURGE_DOMAIN_DN, baseDNs));
+ ConfigConstants.ATTR_TASK_CONFLICTS_HIST_PURGE_DOMAIN_DN, uData.getBaseDNs()));
attributes.add(new LDAPAttribute(
ConfigConstants.ATTR_TASK_CONFLICTS_HIST_PURGE_MAX_DURATION,
Long.toString(uData.getMaximumDuration())));
-
}
/** {@inheritDoc} */
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tools/makeldif/TemplateEntry.java b/opendj-server-legacy/src/main/java/org/opends/server/tools/makeldif/TemplateEntry.java
index c117fc0..6a2a882 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tools/makeldif/TemplateEntry.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tools/makeldif/TemplateEntry.java
@@ -300,7 +300,7 @@
builder.add(v.getValue().toString());
}
- operationalAttributes.put(t, asList(builder));
+ operationalAttributes.put(t, builder.toAttributeList());
}
else
{
@@ -329,14 +329,14 @@
}
}
- userAttributes.put(t, asList(builder));
+ userAttributes.put(t, builder.toAttributeList());
if (urlBuilder != null)
{
- urlAttributes.put(t, asList(urlBuilder));
+ urlAttributes.put(t, urlBuilder.toAttributeList());
}
if (base64Builder != null)
{
- base64Attributes.put(t, asList(base64Builder));
+ base64Attributes.put(t, base64Builder.toAttributeList());
}
}
}
@@ -469,13 +469,6 @@
return attrName;
}
- private ArrayList<Attribute> asList(AttributeBuilder builder)
- {
- ArrayList<Attribute> attrList = new ArrayList<>(1);
- attrList.add(builder.toAttribute());
- return attrList;
- }
-
private boolean contains(List<Attribute> urlAttrList, ByteString v)
{
if (urlAttrList != null)
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tools/tasks/TaskClient.java b/opendj-server-legacy/src/main/java/org/opends/server/tools/tasks/TaskClient.java
index dd7a7dd..4cbd35d 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tools/tasks/TaskClient.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tools/tasks/TaskClient.java
@@ -26,9 +26,9 @@
*/
package org.opends.server.tools.tasks;
+import static org.forgerock.opendj.ldap.ResultCode.*;
import static org.opends.messages.ToolMessages.*;
import static org.opends.server.config.ConfigConstants.*;
-import static org.forgerock.opendj.ldap.ResultCode.*;
import java.io.IOException;
import java.text.SimpleDateFormat;
@@ -41,10 +41,14 @@
import java.util.concurrent.atomic.AtomicInteger;
import org.forgerock.i18n.LocalizableMessage;
+import org.forgerock.opendj.ldap.ByteString;
+import org.forgerock.opendj.ldap.DecodeException;
+import org.forgerock.opendj.ldap.DereferenceAliasesPolicy;
+import org.forgerock.opendj.ldap.ModificationType;
+import org.forgerock.opendj.ldap.SearchScope;
import org.opends.server.backends.task.FailedDependencyAction;
import org.opends.server.backends.task.TaskState;
import org.opends.server.config.ConfigConstants;
-import org.forgerock.opendj.ldap.DecodeException;
import org.opends.server.protocols.ldap.AddRequestProtocolOp;
import org.opends.server.protocols.ldap.AddResponseProtocolOp;
import org.opends.server.protocols.ldap.DeleteRequestProtocolOp;
@@ -62,16 +66,12 @@
import org.opends.server.tools.LDAPConnection;
import org.opends.server.tools.LDAPReader;
import org.opends.server.tools.LDAPWriter;
-import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.types.Control;
-import org.forgerock.opendj.ldap.DereferenceAliasesPolicy;
import org.opends.server.types.Entry;
import org.opends.server.types.LDAPException;
-import org.forgerock.opendj.ldap.ModificationType;
import org.opends.server.types.RawAttribute;
import org.opends.server.types.RawModification;
import org.opends.server.types.SearchResultEntry;
-import org.forgerock.opendj.ldap.SearchScope;
import org.opends.server.util.StaticUtils;
/**
@@ -187,84 +187,58 @@
ArrayList<RawAttribute> attributes = new ArrayList<>();
- ArrayList<ByteString> ocValues = new ArrayList<>(3);
- ocValues.add(ByteString.valueOf("top"));
- ocValues.add(ByteString.valueOf(ConfigConstants.OC_TASK));
-
+ ArrayList<String> ocValues = new ArrayList<>(4);
+ ocValues.add("top");
+ ocValues.add(ConfigConstants.OC_TASK);
if (scheduleRecurring) {
- ocValues.add(ByteString.valueOf(ConfigConstants.OC_RECURRING_TASK));
+ ocValues.add((ConfigConstants.OC_RECURRING_TASK));
}
-
- ocValues.add(ByteString.valueOf(information.getTaskObjectclass()));
+ ocValues.add(information.getTaskObjectclass());
attributes.add(new LDAPAttribute(ATTR_OBJECTCLASS, ocValues));
- ArrayList<ByteString> taskIDValues = new ArrayList<>(1);
- taskIDValues.add(ByteString.valueOf(taskID));
-
if (scheduleRecurring) {
- attributes.add(new LDAPAttribute(ATTR_RECURRING_TASK_ID, taskIDValues));
+ attributes.add(new LDAPAttribute(ATTR_RECURRING_TASK_ID, taskID));
}
- attributes.add(new LDAPAttribute(ATTR_TASK_ID, taskIDValues));
+ attributes.add(new LDAPAttribute(ATTR_TASK_ID, taskID));
- ArrayList<ByteString> classValues = new ArrayList<>(1);
- classValues.add(ByteString.valueOf(information.getTaskClass().getName()));
- attributes.add(new LDAPAttribute(ATTR_TASK_CLASS, classValues));
+ String classValue = information.getTaskClass().getName();
+ attributes.add(new LDAPAttribute(ATTR_TASK_CLASS, classValue));
// add the start time if necessary
Date startDate = information.getStartDateTime();
if (startDate != null) {
String startTimeString = StaticUtils.formatDateTimeString(startDate);
- ArrayList<ByteString> startDateValues = new ArrayList<>(1);
- startDateValues.add(ByteString.valueOf(startTimeString));
- attributes.add(new LDAPAttribute(ATTR_TASK_SCHEDULED_START_TIME, startDateValues));
+ attributes.add(new LDAPAttribute(ATTR_TASK_SCHEDULED_START_TIME, startTimeString));
}
if (scheduleRecurring) {
- ArrayList<ByteString> recurringPatternValues = new ArrayList<>(1);
- recurringPatternValues.add(ByteString.valueOf(
- information.getRecurringDateTime()));
+ String recurringPatternValues = information.getRecurringDateTime();
attributes.add(new LDAPAttribute(ATTR_RECURRING_TASK_SCHEDULE, recurringPatternValues));
}
// add dependency IDs
List<String> dependencyIds = information.getDependencyIds();
if (dependencyIds != null && !dependencyIds.isEmpty()) {
- ArrayList<ByteString> dependencyIdValues = new ArrayList<>(dependencyIds.size());
- for (String dependencyId : dependencyIds) {
- dependencyIdValues.add(ByteString.valueOf(dependencyId));
- }
- attributes.add(new LDAPAttribute(ATTR_TASK_DEPENDENCY_IDS, dependencyIdValues));
+ attributes.add(new LDAPAttribute(ATTR_TASK_DEPENDENCY_IDS, dependencyIds));
// add the dependency action
FailedDependencyAction fda = information.getFailedDependencyAction();
if (fda == null) {
fda = FailedDependencyAction.defaultValue();
}
- ArrayList<ByteString> fdaValues = new ArrayList<>(1);
- fdaValues.add(ByteString.valueOf(fda.name()));
- attributes.add(new LDAPAttribute(ATTR_TASK_FAILED_DEPENDENCY_ACTION, fdaValues));
+ attributes.add(new LDAPAttribute(ATTR_TASK_FAILED_DEPENDENCY_ACTION, fda.name()));
}
// add completion notification email addresses
- List<String> compNotifEmailAddresss =
- information.getNotifyUponCompletionEmailAddresses();
+ List<String> compNotifEmailAddresss = information.getNotifyUponCompletionEmailAddresses();
if (compNotifEmailAddresss != null && !compNotifEmailAddresss.isEmpty()) {
- ArrayList<ByteString> compNotifEmailAddrValues = new ArrayList<>(compNotifEmailAddresss.size());
- for (String emailAddr : compNotifEmailAddresss) {
- compNotifEmailAddrValues.add(ByteString.valueOf(emailAddr));
- }
- attributes.add(new LDAPAttribute(ATTR_TASK_NOTIFY_ON_COMPLETION, compNotifEmailAddrValues));
+ attributes.add(new LDAPAttribute(ATTR_TASK_NOTIFY_ON_COMPLETION, compNotifEmailAddresss));
}
// add error notification email addresses
- List<String> errNotifEmailAddresss =
- information.getNotifyUponErrorEmailAddresses();
+ List<String> errNotifEmailAddresss = information.getNotifyUponErrorEmailAddresses();
if (errNotifEmailAddresss != null && !errNotifEmailAddresss.isEmpty()) {
- ArrayList<ByteString> errNotifEmailAddrValues = new ArrayList<>(errNotifEmailAddresss.size());
- for (String emailAddr : errNotifEmailAddresss) {
- errNotifEmailAddrValues.add(ByteString.valueOf(emailAddr));
- }
- attributes.add(new LDAPAttribute(ATTR_TASK_NOTIFY_ON_ERROR, errNotifEmailAddrValues));
+ attributes.add(new LDAPAttribute(ATTR_TASK_NOTIFY_ON_ERROR, errNotifEmailAddresss));
}
information.addTaskAttributes(attributes);
@@ -452,15 +426,13 @@
ArrayList<RawModification> mods = new ArrayList<>();
- ArrayList<ByteString> values = new ArrayList<>();
String newState;
if (TaskState.isPending(state)) {
newState = TaskState.CANCELED_BEFORE_STARTING.name();
} else {
newState = TaskState.STOPPED_BY_ADMINISTRATOR.name();
}
- values.add(ByteString.valueOf(newState));
- LDAPAttribute attr = new LDAPAttribute(ATTR_TASK_STATE, values);
+ LDAPAttribute attr = new LDAPAttribute(ATTR_TASK_STATE, newState);
mods.add(new LDAPModification(ModificationType.REPLACE, attr));
ModifyRequestProtocolOp modRequest =
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/types/AccountStatusNotification.java b/opendj-server-legacy/src/main/java/org/opends/server/types/AccountStatusNotification.java
index 2404447..1b5d16f 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/types/AccountStatusNotification.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/types/AccountStatusNotification.java
@@ -26,6 +26,10 @@
*/
package org.opends.server.types;
+import static org.opends.server.types.AccountStatusNotificationProperty.*;
+import static org.opends.server.util.CollectionUtils.*;
+import static org.opends.server.util.StaticUtils.*;
+
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
@@ -37,10 +41,6 @@
import org.opends.server.core.PasswordPolicy;
import org.opends.server.core.PasswordPolicyState;
-import static org.opends.server.types.
- AccountStatusNotificationProperty.*;
-import static org.opends.server.util.StaticUtils.*;
-
/**
* This class defines a data type for storing information associated
* with an account status notification.
@@ -234,46 +234,32 @@
HashMap<AccountStatusNotificationProperty,List<String>> props = new HashMap<>(4);
PasswordPolicy policy = pwPolicyState.getAuthenticationPolicy();
-
- ArrayList<String> propList = new ArrayList<>(1);
- propList.add(policy.getDN().toString());
- props.put(PASSWORD_POLICY_DN, propList);
+ props.put(PASSWORD_POLICY_DN, newArrayList(policy.getDN().toString()));
if (tempLocked)
{
long secondsUntilUnlock = policy.getLockoutDuration();
if (secondsUntilUnlock > 0L)
{
- propList = new ArrayList<>(1);
- propList.add(String.valueOf(secondsUntilUnlock));
- props.put(SECONDS_UNTIL_UNLOCK, propList);
+ props.put(SECONDS_UNTIL_UNLOCK, newArrayList(String.valueOf(secondsUntilUnlock)));
- propList = new ArrayList<>(1);
- propList.add(secondsToTimeString(secondsUntilUnlock).toString());
- props.put(TIME_UNTIL_UNLOCK, propList);
+ String string = secondsToTimeString(secondsUntilUnlock).toString();
+ props.put(TIME_UNTIL_UNLOCK, newArrayList(string));
- long unlockTime = System.currentTimeMillis() +
- (1000*secondsUntilUnlock);
- propList = new ArrayList<>(1);
- propList.add(new Date(unlockTime).toString());
- props.put(ACCOUNT_UNLOCK_TIME, propList);
+ long unlockTime = System.currentTimeMillis() + (1000 * secondsUntilUnlock);
+ props.put(ACCOUNT_UNLOCK_TIME, newArrayList(new Date(unlockTime).toString()));
}
}
if (timeToExpiration >= 0)
{
- propList = new ArrayList<>(1);
- propList.add(String.valueOf(timeToExpiration));
- props.put(SECONDS_UNTIL_EXPIRATION, propList);
+ props.put(SECONDS_UNTIL_EXPIRATION, newArrayList(String.valueOf(timeToExpiration)));
- propList = new ArrayList<>(1);
- propList.add(secondsToTimeString(timeToExpiration).toString());
- props.put(TIME_UNTIL_EXPIRATION, propList);
+ String string = secondsToTimeString(timeToExpiration).toString();
+ props.put(TIME_UNTIL_EXPIRATION, newArrayList(string));
- long expTime = System.currentTimeMillis() + (1000*timeToExpiration);
- propList = new ArrayList<>(1);
- propList.add(new Date(expTime).toString());
- props.put(PASSWORD_EXPIRATION_TIME, propList);
+ long expTime = System.currentTimeMillis() + (1000 * timeToExpiration);
+ props.put(PASSWORD_EXPIRATION_TIME, newArrayList(new Date(expTime).toString()));
}
if ((oldPasswords != null) && (! oldPasswords.isEmpty()))
@@ -308,6 +294,7 @@
* @return A string representation of this account status
* notification.
*/
+ @Override
public String toString()
{
return "AccountStatusNotification(type=" +
@@ -315,4 +302,3 @@
",message=" + message + ")";
}
}
-
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/types/AttributeBuilder.java b/opendj-server-legacy/src/main/java/org/opends/server/types/AttributeBuilder.java
index 327420d..0495284 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/types/AttributeBuilder.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/types/AttributeBuilder.java
@@ -42,10 +42,11 @@
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ConditionResult;
import org.forgerock.opendj.ldap.DecodeException;
+import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.forgerock.util.Reject;
import org.forgerock.util.Utils;
-import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.core.DirectoryServer;
+import org.opends.server.util.CollectionUtils;
import static org.opends.server.util.StaticUtils.*;
@@ -479,7 +480,6 @@
{
return true;
}
-
}
@@ -489,7 +489,6 @@
*/
private static final class RealAttributeNoOptions extends RealAttribute
{
-
/**
* Creates a new real attribute that has no options.
*
@@ -558,7 +557,6 @@
{
return (options == null || options.isEmpty());
}
-
}
@@ -569,7 +567,6 @@
private static final class RealAttributeSingleOption
extends RealAttribute
{
-
/** The normalized single option. */
private final String normalizedOption;
@@ -628,7 +625,6 @@
{
return true;
}
-
}
@@ -864,7 +860,6 @@
return 0;
}
}
-
}
/**
@@ -878,7 +873,6 @@
*/
private static final class AttributeValue
{
-
private final AttributeType attributeType;
/** User-provided value. */
@@ -989,7 +983,6 @@
{
return value != null ? value.toString() : "null";
}
-
}
/**
@@ -1038,16 +1031,12 @@
/** The attribute type for this attribute. */
private AttributeType attributeType;
-
/** The name of this attribute as provided by the end user. */
private String name;
-
/** The normalized set of options if there are more than one. */
private SortedSet<String> normalizedOptions;
-
/** The set of options. */
private final SmallSet<String> options = new SmallSet<>();
-
/** The set of attribute values, which are lazily normalized. */
private Set<AttributeValue> values = new SmallSet<>();
@@ -1354,8 +1343,7 @@
* supports attribute value removals via its <code>remove</code>
* method.
*
- * @return An iterator over the attribute values in this attribute
- * builder.
+ * @return An iterator over the attribute values in this attribute builder.
*/
@Override
public Iterator<ByteString> iterator()
@@ -1734,10 +1722,9 @@
*/
boolean isNormalized()
{
- Iterator<AttributeValue> iterator = values.iterator();
- while (iterator.hasNext())
+ for (AttributeValue attrValue : values)
{
- if (iterator.next().isNormalized())
+ if (attrValue.isNormalized())
{
return true;
}
@@ -1746,44 +1733,25 @@
}
/**
- * Returns an attribute representing the content of this attribute
- * builder.
+ * Returns an attribute representing the content of this attribute builder.
* <p>
* For efficiency purposes this method resets the content of this
* attribute builder so that it no longer contains any options or
* values and its attribute type is <code>null</code>.
*
- * @return An attribute representing the content of this attribute
- * builder.
+ * @return An attribute representing the content of this attribute builder.
* @throws IllegalStateException
- * If this attribute builder has an undefined attribute
- * type or name.
+ * If this attribute builder has an undefined attribute type or name.
*/
public Attribute toAttribute() throws IllegalStateException
{
if (attributeType == null)
{
- throw new IllegalStateException(
- "Undefined attribute type or name");
+ throw new IllegalStateException("Undefined attribute type or name");
}
// Now create the appropriate attribute based on the options.
- Attribute attribute;
- switch (options.size())
- {
- case 0:
- attribute = new RealAttributeNoOptions(attributeType, name, values);
- break;
- case 1:
- attribute =
- new RealAttributeSingleOption(attributeType, name, values, options.firstElement);
- break;
- default:
- attribute =
- new RealAttributeManyOptions(attributeType, name, values,
- Collections.unmodifiableSet(options.elements), Collections.unmodifiableSortedSet(normalizedOptions));
- break;
- }
+ Attribute attribute = toAttribute0();
// Reset the state of this builder.
attributeType = null;
@@ -1795,6 +1763,35 @@
return attribute;
}
+ private Attribute toAttribute0()
+ {
+ switch (options.size())
+ {
+ case 0:
+ return new RealAttributeNoOptions(attributeType, name, values);
+ case 1:
+ return new RealAttributeSingleOption(attributeType, name, values, options.firstElement);
+ default:
+ return new RealAttributeManyOptions(attributeType, name, values,
+ Collections.unmodifiableSet(options.elements), Collections.unmodifiableSortedSet(normalizedOptions));
+ }
+ }
+
+ /**
+ * Returns a List with a single attribute representing the content of this attribute builder.
+ * <p>
+ * For efficiency purposes this method resets the content of this
+ * attribute builder so that it no longer contains any options or
+ * values and its attribute type is <code>null</code>.
+ *
+ * @return A List with a single attribute representing the content of this attribute builder.
+ * @throws IllegalStateException
+ * If this attribute builder has an undefined attribute type or name.
+ */
+ public List<Attribute> toAttributeList() throws IllegalStateException
+ {
+ return CollectionUtils.newArrayList(toAttribute());
+ }
/** {@inheritDoc} */
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/types/Attributes.java b/opendj-server-legacy/src/main/java/org/opends/server/types/Attributes.java
index 00a97b9..bc1866b 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/types/Attributes.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/types/Attributes.java
@@ -22,16 +22,18 @@
*
*
* Copyright 2008-2009 Sun Microsystems, Inc.
- * Portions Copyright 2014 ForgeRock AS
+ * Portions Copyright 2014-2015 ForgeRock AS
*/
package org.opends.server.types;
import java.util.Collection;
import java.util.Collections;
+import java.util.List;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.core.DirectoryServer;
+import static org.opends.server.util.CollectionUtils.*;
import static org.opends.server.util.StaticUtils.*;
/**
@@ -60,8 +62,7 @@
{
/**
- * Creates a new single-valued attribute with the specified
- * attribute type and value.
+ * Creates a new single-valued attribute with the specified attribute type and value.
*
* @param attributeType
* The attribute type to use.
@@ -74,11 +75,22 @@
return create(attributeType, attributeType.getNameOrOID(), value);
}
-
+ /**
+ * Creates a new List with a single-valued attribute with the specified attribute type and value.
+ *
+ * @param attributeType
+ * The attribute type to use.
+ * @param value
+ * The attribute value.
+ * @return A new List with a single-valued attribute with the attribute type and value.
+ */
+ public static List<Attribute> createAsList(AttributeType attributeType, ByteString value)
+ {
+ return newArrayList(create(attributeType, value));
+ }
/**
- * Creates a new single-valued attribute with the specified name and
- * value.
+ * Creates a new single-valued attribute with the specified name and value.
*
* @param attributeType
* The attribute type to use.
@@ -86,14 +98,24 @@
* The String representation of the attribute value.
* @return A new attribute with the specified name and value.
*/
- public static Attribute create(AttributeType attributeType,
- String valueString)
+ public static Attribute create(AttributeType attributeType, String valueString)
{
- return create(attributeType, attributeType.getNameOrOID(),
- valueString);
+ return create(attributeType, attributeType.getNameOrOID(), valueString);
}
-
+ /**
+ * Creates a new List with a single-valued attribute with the specified name and value.
+ *
+ * @param attributeType
+ * The attribute type to use.
+ * @param valueString
+ * The String representation of the attribute value.
+ * @return A new List with a attribute with the specified name and value.
+ */
+ public static List<Attribute> createAsList(AttributeType attributeType, String valueString)
+ {
+ return newArrayList(create(attributeType, valueString));
+ }
/**
* Creates a new single-valued attribute with the specified
@@ -107,18 +129,13 @@
* The attribute value.
* @return A new attribute with the attribute type and value.
*/
- public static Attribute create(AttributeType attributeType,
- String name, ByteString value)
+ public static Attribute create(AttributeType attributeType, String name, ByteString value)
{
- return AttributeBuilder.create(attributeType, name, Collections
- .singleton(value));
+ return AttributeBuilder.create(attributeType, name, Collections.singleton(value));
}
-
-
/**
- * Creates a new single-valued attribute with the attribute type and
- * value.
+ * Creates a new single-valued attribute with the attribute type and value.
*
* @param attributeType
* The attribute type to use.
@@ -128,14 +145,27 @@
* The String representation of the attribute value.
* @return A new attribute with the attribute type and value.
*/
- public static Attribute create(AttributeType attributeType,
- String name, String valueString)
+ public static Attribute create(AttributeType attributeType, String name, String valueString)
{
- ByteString value = ByteString.valueOf(valueString);
- return create(attributeType, name, value);
+ return create(attributeType, name, ByteString.valueOf(valueString));
}
+ /**
+ * Creates a new List with a single-valued attribute with the attribute type and value.
+ *
+ * @param attributeType
+ * The attribute type to use.
+ * @param name
+ * The user-provided name for this attribute.
+ * @param valueString
+ * The String representation of the attribute value.
+ * @return A new List with a single-valued attribute with the attribute type and value.
+ */
+ public static List<Attribute> createAsList(AttributeType attributeType, String name, String valueString)
+ {
+ return newArrayList(create(attributeType, name, valueString));
+ }
/**
* Creates a new single-valued attribute with the specified
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 05d57f1..5e3b944 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
@@ -29,6 +29,7 @@
import java.io.BufferedWriter;
import java.io.IOException;
import java.util.*;
+
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.LocalizableMessageBuilder;
import org.forgerock.i18n.LocalizedIllegalArgumentException;
@@ -40,9 +41,9 @@
import org.forgerock.opendj.ldap.DecodeException;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.SearchScope;
+import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.forgerock.opendj.ldap.schema.ObjectClassType;
import org.opends.server.api.CompressedSchema;
-import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.api.ProtocolElement;
import org.opends.server.api.plugin.PluginResult;
import org.opends.server.core.DirectoryServer;
@@ -56,6 +57,7 @@
import static org.opends.messages.CoreMessages.*;
import static org.opends.messages.UtilityMessages.*;
import static org.opends.server.config.ConfigConstants.*;
+import static org.opends.server.util.CollectionUtils.*;
import static org.opends.server.util.LDIFWriter.*;
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
@@ -639,7 +641,7 @@
}
if (attributeType.isObjectClass() && !objectClasses.isEmpty())
{
- return newList(getObjectClassAttribute());
+ return newArrayList(getObjectClassAttribute());
}
return null;
}
@@ -4527,7 +4529,7 @@
}
// We are adding the first attribute with this attribute type.
- putAttributes(attributeType, newList(attribute));
+ putAttributes(attributeType, newArrayList(attribute));
return;
}
@@ -4623,7 +4625,7 @@
objectClassesCopy = new LinkedHashMap<>(0);
// Add empty object class attribute.
- userAttrsCopy.put(ocType, newList(Attributes.empty(ocType)));
+ userAttrsCopy.put(ocType, newArrayList(Attributes.empty(ocType)));
}
else
{
@@ -4633,7 +4635,7 @@
Attribute ocAttr = getObjectClassAttribute();
if (ocAttr != null)
{
- userAttrsCopy.put(ocType, newList(ocAttr));
+ userAttrsCopy.put(ocType, newArrayList(ocAttr));
}
}
@@ -4667,7 +4669,7 @@
if (omitValues)
{
// Add empty object class attribute.
- userAttrsCopy.put(ocType, newList(Attributes.empty(ocType)));
+ userAttrsCopy.put(ocType, newArrayList(Attributes.empty(ocType)));
}
else
{
@@ -4676,7 +4678,7 @@
Attribute ocAttr = getObjectClassAttribute();
if (ocAttr != null)
{
- userAttrsCopy.put(ocType, newList(ocAttr));
+ userAttrsCopy.put(ocType, newArrayList(ocAttr));
}
}
}
@@ -4756,8 +4758,7 @@
{
if (omitValues)
{
- userAttrsCopy.put(ocType, newList(Attributes.empty(ocType,
- attrName)));
+ userAttrsCopy.put(ocType, newArrayList(Attributes.empty(ocType, attrName)));
}
else
{
@@ -4772,7 +4773,7 @@
ocAttr = builder.toAttribute();
}
- userAttrsCopy.put(ocType, newList(ocAttr));
+ userAttrsCopy.put(ocType, newArrayList(ocAttr));
}
}
}
@@ -4805,21 +4806,6 @@
}
/**
- * Returns a new List containing only the supplied element.
- *
- * @param elem
- * the element to add to the list
- * @return a new List containing only the supplied element.
- */
- private List<Attribute> newList(Attribute elem)
- {
- List<Attribute> l = new ArrayList<>(1);
- l.add(elem);
- return l;
- }
-
-
- /**
* Copies the provided list of attributes into the destination
* attribute map according to the provided criteria.
*
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/util/LDIFReader.java b/opendj-server-legacy/src/main/java/org/opends/server/util/LDIFReader.java
index 9d0603e..64f7546 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/util/LDIFReader.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/util/LDIFReader.java
@@ -1454,13 +1454,10 @@
for (String value : objectClasses.values()) {
builder.add(value);
}
- Map<AttributeType, List<Attribute>> attributes =
- toAttributesMap(attrBuilders);
+ Map<AttributeType, List<Attribute>> attributes = toAttributesMap(attrBuilders);
if (attributes.get(ocType) == null)
{
- List<Attribute> ocAttrList = new ArrayList<>(1);
- ocAttrList.add(builder.toAttribute());
- attributes.put(ocType, ocAttrList);
+ attributes.put(ocType, builder.toAttributeList());
}
return new AddChangeRecordEntry(entryDN, attributes);
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/util/StaticUtils.java b/opendj-server-legacy/src/main/java/org/opends/server/util/StaticUtils.java
index cb3879c..39a1d86 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/util/StaticUtils.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/util/StaticUtils.java
@@ -3711,20 +3711,18 @@
AttributeType attrType, String attrName, ByteString attrValue)
{
List<Attribute> attrList = attrs.get(attrType);
- if ((attrList == null) || attrList.isEmpty())
- {
- AttributeBuilder builder = new AttributeBuilder(attrType, attrName);
- builder.add(attrValue);
- attrList = new ArrayList<>(1);
- attrList.add(builder.toAttribute());
- attrs.put(attrType, attrList);
- }
- else
+ if (attrList != null && !attrList.isEmpty())
{
AttributeBuilder builder = new AttributeBuilder(attrList.get(0));
builder.add(attrValue);
attrList.set(0, builder.toAttribute());
}
+ else
+ {
+ AttributeBuilder builder = new AttributeBuilder(attrType, attrName);
+ builder.add(attrValue);
+ attrs.put(attrType, builder.toAttributeList());
+ }
}
/**
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 7f17f0a..7550932 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
@@ -81,6 +81,7 @@
import static org.opends.messages.CoreMessages.*;
import static org.opends.server.config.ConfigConstants.*;
+import static org.opends.server.util.CollectionUtils.*;
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
@@ -885,11 +886,9 @@
// Set the password changed time attribute.
- ArrayList<Attribute> changedTimeList = new ArrayList<>(1);
Attribute changedTime = Attributes.create(
OP_ATTR_PWPOLICY_CHANGED_TIME, TimeThread.getGeneralizedTime());
- changedTimeList.add(changedTime);
- entry.putAttribute(changedTime.getAttributeType(), changedTimeList);
+ entry.putAttribute(changedTime.getAttributeType(), newArrayList(changedTime));
// If we should force change on add, then set the appropriate flag.
@@ -897,11 +896,8 @@
{
addPWPolicyControl(PasswordPolicyErrorType.CHANGE_AFTER_RESET);
- ArrayList<Attribute> resetList = new ArrayList<>(1);
- Attribute reset = Attributes.create(
- OP_ATTR_PWPOLICY_RESET_REQUIRED, "TRUE");
- resetList.add(reset);
- entry.putAttribute(reset.getAttributeType(), resetList);
+ Attribute reset = Attributes.create(OP_ATTR_PWPOLICY_RESET_REQUIRED, "TRUE");
+ entry.putAttribute(reset.getAttributeType(), newArrayList(reset));
}
}
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/api/PasswordValidatorTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/api/PasswordValidatorTestCase.java
index a0e7e8d..02bf681 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/api/PasswordValidatorTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/api/PasswordValidatorTestCase.java
@@ -440,10 +440,8 @@
BindResponseProtocolOp bindResponse = message.getBindResponseProtocolOp();
assertEquals(bindResponse.getResultCode(), 0);
+ LDAPAttribute attr = new LDAPAttribute("userPassword", "newPassword");
ArrayList<RawModification> mods = new ArrayList<>();
- ArrayList<ByteString> values = new ArrayList<>();
- values.add(ByteString.valueOf("newPassword"));
- LDAPAttribute attr = new LDAPAttribute("userPassword", values);
mods.add(new LDAPModification(ModificationType.REPLACE, attr));
ModifyRequestProtocolOp modifyRequest =
@@ -509,9 +507,7 @@
assertEquals(bindResponse.getResultCode(), 0);
ArrayList<RawModification> mods = new ArrayList<>();
- ArrayList<ByteString> values = new ArrayList<>();
- values.add(ByteString.valueOf("newPassword"));
- LDAPAttribute attr = new LDAPAttribute("userPassword", values);
+ LDAPAttribute attr = new LDAPAttribute("userPassword", "newPassword");
mods.add(new LDAPModification(ModificationType.REPLACE, attr));
TestPasswordValidator.setNextReturnValue(false);
@@ -580,15 +576,11 @@
BindResponseProtocolOp bindResponse = message.getBindResponseProtocolOp();
assertEquals(bindResponse.getResultCode(), 0);
+ LDAPAttribute attr = new LDAPAttribute("userPassword", "password");
ArrayList<RawModification> mods = new ArrayList<>();
- ArrayList<ByteString> values = new ArrayList<>();
- values.add(ByteString.valueOf("password"));
- LDAPAttribute attr = new LDAPAttribute("userPassword", values);
mods.add(new LDAPModification(ModificationType.DELETE, attr));
- values = new ArrayList<>();
- values.add(ByteString.valueOf("newPassword"));
- attr = new LDAPAttribute("userPassword", values);
+ attr = new LDAPAttribute("userPassword", "newPassword");
mods.add(new LDAPModification(ModificationType.ADD, attr));
ModifyRequestProtocolOp modifyRequest =
@@ -659,10 +651,8 @@
BindResponseProtocolOp bindResponse = message.getBindResponseProtocolOp();
assertEquals(bindResponse.getResultCode(), 0);
+ LDAPAttribute attr = new LDAPAttribute("userPassword", "newPassword");
ArrayList<RawModification> mods = new ArrayList<>();
- ArrayList<ByteString> values = new ArrayList<>();
- values.add(ByteString.valueOf("newPassword"));
- LDAPAttribute attr = new LDAPAttribute("userPassword", values);
mods.add(new LDAPModification(ModificationType.REPLACE, attr));
ModifyRequestProtocolOp modifyRequest =
@@ -733,15 +723,11 @@
BindResponseProtocolOp bindResponse = message.getBindResponseProtocolOp();
assertEquals(bindResponse.getResultCode(), 0);
+ LDAPAttribute attr = new LDAPAttribute("userPassword", "password");
ArrayList<RawModification> mods = new ArrayList<>();
- ArrayList<ByteString> values = new ArrayList<>();
- values.add(ByteString.valueOf("password"));
- LDAPAttribute attr = new LDAPAttribute("userPassword", values);
mods.add(new LDAPModification(ModificationType.DELETE, attr));
- values = new ArrayList<>();
- values.add(ByteString.valueOf("newPassword"));
- attr = new LDAPAttribute("userPassword", values);
+ attr = new LDAPAttribute("userPassword", "newPassword");
mods.add(new LDAPModification(ModificationType.ADD, attr));
ModifyRequestProtocolOp modifyRequest =
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 de43924..a7adc51 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
@@ -42,19 +42,24 @@
import org.opends.server.TestCaseUtils;
import org.opends.server.config.ConfigConstants;
import org.opends.server.core.DirectoryServer;
-import org.opends.server.protocols.internal.InternalClientConnection;
+import org.opends.server.core.ModifyOperation;
import org.opends.server.protocols.ldap.LDAPResultCode;
import org.opends.server.tools.LDAPDelete;
import org.opends.server.tools.LDAPModify;
import org.opends.server.tools.LDAPPasswordModify;
import org.opends.server.tools.LDAPSearch;
-import org.opends.server.types.*;
+import org.opends.server.types.Attribute;
+import org.opends.server.types.DN;
+import org.opends.server.types.Entry;
+import org.opends.server.types.Modification;
import org.testng.Assert;
import org.testng.Reporter;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
+import static org.opends.server.protocols.internal.InternalClientConnection.*;
+import static org.opends.server.util.CollectionUtils.*;
import static org.opends.server.util.ServerConstants.*;
@SuppressWarnings("javadoc")
@@ -99,17 +104,9 @@
{
Reporter.log("Restoring global ACI attribute: " + globalACIAttribute);
- List<Modification> modifications = new ArrayList<>(1);
- modifications.add(new Modification(ModificationType.REPLACE,
- globalACIAttribute));
- InternalClientConnection conn =
- InternalClientConnection.getRootConnection();
-
- ResultCode rc =
- conn.processModify(DN.valueOf(ACCESS_HANDLER_DN),
- modifications).getResultCode();
- Assert.assertEquals(rc, ResultCode.SUCCESS,
- "Unable to restore global ACI");
+ Modification mod = new Modification(ModificationType.REPLACE,globalACIAttribute);
+ ModifyOperation op = getRootConnection().processModify(DN.valueOf(ACCESS_HANDLER_DN), newArrayList(mod));
+ Assert.assertEquals(op.getResultCode(), ResultCode.SUCCESS, "Unable to restore global ACI");
}
}
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/controls/PersistentSearchControlTest.java b/opendj-server-legacy/src/test/java/org/opends/server/controls/PersistentSearchControlTest.java
index 3daa586..74d3afb 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/controls/PersistentSearchControlTest.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/controls/PersistentSearchControlTest.java
@@ -29,6 +29,7 @@
import static org.assertj.core.api.Assertions.*;
import static org.opends.server.TestCaseUtils.*;
import static org.opends.server.controls.PersistentSearchChangeType.*;
+import static org.opends.server.protocols.internal.InternalClientConnection.*;
import static org.opends.server.protocols.internal.Requests.*;
import static org.opends.server.util.ServerConstants.*;
import static org.testng.Assert.*;
@@ -516,12 +517,9 @@
{
TestCaseUtils.initializeTestBackend(true);
//Modify the configuration to allow only 1 concurrent persistent search.
- InternalClientConnection conn =
- InternalClientConnection.getRootConnection();
+ InternalClientConnection conn = getRootConnection();
- ArrayList<ByteString> values = new ArrayList<>();
- values.add(ByteString.valueOf("1"));
- LDAPAttribute attr = new LDAPAttribute("ds-cfg-max-psearches", values);
+ LDAPAttribute attr = new LDAPAttribute("ds-cfg-max-psearches", "1");
ArrayList<RawModification> mods = new ArrayList<>();
mods.add(new LDAPModification(ModificationType.REPLACE, attr));
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/core/AbandonOperationTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/core/AbandonOperationTestCase.java
index 4776354..0152dab 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/core/AbandonOperationTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/core/AbandonOperationTestCase.java
@@ -48,6 +48,7 @@
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
+import static org.opends.server.util.CollectionUtils.*;
import static org.opends.server.util.ServerConstants.*;
import static org.testng.Assert.*;
@@ -276,19 +277,11 @@
// the delay request control so it won't complete before we can send the
// abandon request.
ArrayList<RawAttribute> attributes = new ArrayList<>();
-
- ArrayList<ByteString> values = new ArrayList<>(2);
- values.add(ByteString.valueOf("top"));
- values.add(ByteString.valueOf("organizationalUnit"));
- attributes.add(new LDAPAttribute("objectClass", values));
-
- values = new ArrayList<>(1);
- values.add(ByteString.valueOf("People"));
- attributes.add(new LDAPAttribute("ou", values));
+ attributes.add(new LDAPAttribute("objectClass", newArrayList("top", "organizationalUnit")));
+ attributes.add(new LDAPAttribute("ou", "People"));
AddRequestProtocolOp addRequest =
- new AddRequestProtocolOp(ByteString.valueOf("ou=People,o=test"),
- attributes);
+ new AddRequestProtocolOp(ByteString.valueOf("ou=People,o=test"), attributes);
message = new LDAPMessage(2, addRequest,
DelayPreOpPlugin.createDelayControlList(5000));
w.writeMessage(message);
@@ -555,12 +548,9 @@
// Create a modify request and send it to the server. Make sure to include
// the delay request control so it won't complete before we can send the
// abandon request.
- ArrayList<ByteString> values = new ArrayList<>(1);
- values.add(ByteString.valueOf("foo"));
-
ArrayList<RawModification> mods = new ArrayList<>(1);
mods.add(new LDAPModification(ModificationType.REPLACE,
- new LDAPAttribute("description", values)));
+ new LDAPAttribute("description", "foo")));
ModifyRequestProtocolOp modifyRequest =
new ModifyRequestProtocolOp(ByteString.valueOf("o=test"), mods);
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 8e03e9a..625c0ad 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
@@ -59,11 +59,11 @@
import org.opends.server.types.DN;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.Entry;
+import org.opends.server.types.LockManager.DNLock;
import org.opends.server.types.ObjectClass;
import org.opends.server.types.Operation;
import org.opends.server.types.RawAttribute;
import org.opends.server.types.WritabilityMode;
-import org.opends.server.types.LockManager.DNLock;
import org.opends.server.util.StaticUtils;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.DataProvider;
@@ -103,8 +103,8 @@
ArrayList<Control> noControls = new ArrayList<>();
ArrayList<RawAttribute> ldapAttrList = newRawAttributes(
- new LDAPAttribute("objectclass", byteStrings("top", "organizationalUnit")),
- new LDAPAttribute("ou", byteStrings("People")));
+ new LDAPAttribute("objectclass", newArrayList("top", "organizationalUnit")),
+ new LDAPAttribute("ou", "People"));
Entry entry = TestCaseUtils.makeEntry(
"dn: ou=People,o=test",
@@ -190,8 +190,8 @@
public void testGetEntryDNInitiallyNull()
{
ArrayList<RawAttribute> ldapAttrList = newRawAttributes(
- new LDAPAttribute("objectclass", byteStrings("top", "organizationalUnit")),
- new LDAPAttribute("ou", byteStrings("People")));
+ new LDAPAttribute("objectclass", newArrayList("top", "organizationalUnit")),
+ new LDAPAttribute("ou", "People"));
AddOperationBasis addOperation =
new AddOperationBasis(getRootConnection(), nextOperationID(), nextMessageID(),
@@ -283,7 +283,7 @@
assertFalse(rawAttrs.isEmpty());
ArrayList<RawAttribute> copiedAttrs = new ArrayList<>(rawAttrs);
- copiedAttrs.add(new LDAPAttribute("description", byteStrings("foo")));
+ copiedAttrs.add(new LDAPAttribute("description", "foo"));
addOperation.setRawAttributes(copiedAttrs);
assertTrue(find(addOperation, "description"));
@@ -530,8 +530,8 @@
TestCaseUtils.initializeTestBackend(true);
ArrayList<RawAttribute> attrs = newRawAttributes(
- new LDAPAttribute("objectClass", byteStrings("top", "organizationalUnit")),
- new LDAPAttribute("ou", byteStrings("People")));
+ new LDAPAttribute("objectClass", newArrayList("top", "organizationalUnit")),
+ new LDAPAttribute("ou", "People"));
AddOperation addOperation = getRootConnection().processAdd("ou=People,o=test", attrs);
assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -574,8 +574,8 @@
TestCaseUtils.initializeTestBackend(true);
ArrayList<RawAttribute> attrs = newRawAttributes(
- new LDAPAttribute("objectClass", byteStrings("top", "organizationalUnit")),
- new LDAPAttribute("ou", byteStrings("People")));
+ new LDAPAttribute("objectClass", newArrayList("top", "organizationalUnit")),
+ new LDAPAttribute("ou", "People"));
AddOperation addOperation = getRootConnection().processAdd("invalid", attrs);
assertNotEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -595,8 +595,8 @@
TestCaseUtils.initializeTestBackend(true);
ArrayList<RawAttribute> attrs = newRawAttributes(
- new LDAPAttribute("objectClass", byteStrings("top", "organization")),
- new LDAPAttribute("o", byteStrings("test")));
+ new LDAPAttribute("objectClass", newArrayList("top", "organization")),
+ new LDAPAttribute("o", "test"));
AddOperation addOperation = getRootConnection().processAdd("o=test", attrs);
assertNotEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -616,8 +616,8 @@
TestCaseUtils.initializeTestBackend(true);
ArrayList<RawAttribute> attrs = newRawAttributes(
- new LDAPAttribute("objectClass", byteStrings("top", "organization")),
- new LDAPAttribute("o", byteStrings("undefined")));
+ new LDAPAttribute("objectClass", newArrayList("top", "organization")),
+ new LDAPAttribute("o", "undefined"));
AddOperation addOperation = getRootConnection().processAdd("o=undefined", attrs);
assertNotEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -637,8 +637,8 @@
TestCaseUtils.initializeTestBackend(true);
ArrayList<RawAttribute> attrs = newRawAttributes(
- new LDAPAttribute("objectClass", byteStrings("top", "organizationalUnit")),
- new LDAPAttribute("ou", byteStrings("People")));
+ new LDAPAttribute("objectClass", newArrayList("top", "organizationalUnit")),
+ new LDAPAttribute("ou", "People"));
AddOperation addOperation = getRootConnection().processAdd("ou=People,o=undefined", attrs);
assertNotEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -657,8 +657,8 @@
TestCaseUtils.initializeTestBackend(true);
ArrayList<RawAttribute> attrs = newRawAttributes(
- new LDAPAttribute("objectClass", byteStrings("top", "organizationalUnit")),
- new LDAPAttribute("ou", byteStrings("People")));
+ new LDAPAttribute("objectClass", newArrayList("top", "organizationalUnit")),
+ new LDAPAttribute("ou", "People"));
AddOperation addOperation = getRootConnection().processAdd("ou=People,o=missing,o=test", attrs);
assertNotEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -685,10 +685,10 @@
bind(r, w);
ArrayList<RawAttribute> attrs = newRawAttributes(
- new LDAPAttribute("objectClass", byteStrings("top", "organizationalUnit")),
- new LDAPAttribute("ou", byteStrings("People")),
- new LDAPAttribute("creatorsName", byteStrings("cn=Directory Manager")),
- new LDAPAttribute("createTimestamp", byteStrings("20060101000000Z")));
+ new LDAPAttribute("objectClass", newArrayList("top", "organizationalUnit")),
+ new LDAPAttribute("ou", "People"),
+ new LDAPAttribute("creatorsName", "cn=Directory Manager"),
+ new LDAPAttribute("createTimestamp", "20060101000000Z"));
long addRequests = ldapStatistics.getAddRequests();
long addResponses = ldapStatistics.getAddResponses();
@@ -713,8 +713,8 @@
TestCaseUtils.initializeTestBackend(true);
ArrayList<RawAttribute> attrs = newRawAttributes(
- new LDAPAttribute("objectClass", byteStrings("top", "undefined")),
- new LDAPAttribute("ou", byteStrings("People")));
+ new LDAPAttribute("objectClass", newArrayList("top", "undefined")),
+ new LDAPAttribute("ou", "People"));
AddOperation addOperation = getRootConnection().processAdd(ByteString.valueOf("ou=People,o=test"), attrs);
assertNotEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -764,10 +764,10 @@
TestCaseUtils.initializeTestBackend(true);
ArrayList<RawAttribute> attrs = newRawAttributes(
- new LDAPAttribute("objectClass", byteStrings("top", "organizationalUnit")),
- new LDAPAttribute("description", byteStrings("foo")),
- new LDAPAttribute("ou", byteStrings("People")),
- new LDAPAttribute("description", byteStrings("bar")));
+ new LDAPAttribute("objectClass", newArrayList("top", "organizationalUnit")),
+ new LDAPAttribute("description", "foo"),
+ new LDAPAttribute("ou", "People"),
+ new LDAPAttribute("description", "bar"));
AddOperation addOperation = getRootConnection().processAdd(ByteString.valueOf("ou=People,o=test"), attrs);
assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -785,10 +785,10 @@
TestCaseUtils.initializeTestBackend(true);
ArrayList<RawAttribute> attrs = newRawAttributes(
- new LDAPAttribute("objectClass", byteStrings("top", "organizationalUnit")),
- new LDAPAttribute("description", byteStrings("foo")),
- new LDAPAttribute("ou", byteStrings("People")),
- new LDAPAttribute("description;lang-en-us", byteStrings("foo")));
+ new LDAPAttribute("objectClass", newArrayList("top", "organizationalUnit")),
+ new LDAPAttribute("description", "foo"),
+ new LDAPAttribute("ou", "People"),
+ new LDAPAttribute("description;lang-en-us", "foo"));
AddOperation addOperation = getRootConnection().processAdd(ByteString.valueOf("ou=People,o=test"), attrs);
assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -808,9 +808,9 @@
TestCaseUtils.initializeTestBackend(true);
ArrayList<RawAttribute> attrs = newRawAttributes(
- new LDAPAttribute("objectClass", byteStrings("top", "organizationalUnit")),
- new LDAPAttribute("ou", byteStrings("People")),
- new LDAPAttribute("description;lang-en-us", byteStrings("foo")));
+ new LDAPAttribute("objectClass", newArrayList("top", "organizationalUnit")),
+ new LDAPAttribute("ou", "People"),
+ new LDAPAttribute("description;lang-en-us", "foo"));
AddOperation addOperation = getRootConnection().processAdd(ByteString.valueOf("ou=People,o=test"), attrs);
assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -862,8 +862,8 @@
TestCaseUtils.initializeTestBackend(true);
ArrayList<RawAttribute> attrs = newRawAttributes(
- new LDAPAttribute("objectClass", byteStrings("top", "ds-root-dse", "extensibleObject")),
- new LDAPAttribute("cn", byteStrings("Root DSE")));
+ new LDAPAttribute("objectClass", newArrayList("top", "ds-root-dse", "extensibleObject")),
+ new LDAPAttribute("cn", "Root DSE"));
AddOperation addOperation =
getRootConnection().processAdd(ByteString.empty(), attrs);
@@ -1290,8 +1290,8 @@
bind(r, w);
ArrayList<RawAttribute> attrs = newRawAttributes(
- new LDAPAttribute("objectClass", byteStrings("top", "organizationalUnit")),
- new LDAPAttribute("ou", byteStrings("People")));
+ new LDAPAttribute("objectClass", newArrayList("top", "organizationalUnit")),
+ new LDAPAttribute("ou", "People"));
DirectoryServer.setWritabilityMode(WritabilityMode.INTERNAL_ONLY);
@@ -1417,8 +1417,8 @@
bind(r, w);
ArrayList<RawAttribute> attrs = newRawAttributes(
- new LDAPAttribute("objectClass", byteStrings("top", "organizationalUnit")),
- new LDAPAttribute("ou", byteStrings("People")));
+ new LDAPAttribute("objectClass", newArrayList("top", "organizationalUnit")),
+ new LDAPAttribute("ou", "People"));
Backend<?> b = DirectoryServer.getBackend(DN.valueOf("o=test"));
b.setWritabilityMode(WritabilityMode.INTERNAL_ONLY);
@@ -1619,8 +1619,8 @@
bind(r, w);
ArrayList<RawAttribute> attrs = newRawAttributes(
- new LDAPAttribute("objectClass", byteStrings("top", "organizationalUnit")),
- new LDAPAttribute("ou", byteStrings("People")));
+ new LDAPAttribute("objectClass", newArrayList("top", "organizationalUnit")),
+ new LDAPAttribute("ou", "People"));
addDisconnect(r, w, attrs, "PreParse");
@@ -1672,8 +1672,8 @@
bind(r, w);
ArrayList<RawAttribute> attrs = newRawAttributes(
- new LDAPAttribute("objectClass", byteStrings("top", "organizationalUnit")),
- new LDAPAttribute("ou", byteStrings("People")));
+ new LDAPAttribute("objectClass", newArrayList("top", "organizationalUnit")),
+ new LDAPAttribute("ou", "People"));
addDisconnect(r, w, attrs, "PreOperation");
@@ -1699,8 +1699,8 @@
bind(r, w);
ArrayList<RawAttribute> attrs = newRawAttributes(
- new LDAPAttribute("objectClass", byteStrings("top", "organizationalUnit")),
- new LDAPAttribute("ou", byteStrings("People")));
+ new LDAPAttribute("objectClass", newArrayList("top", "organizationalUnit")),
+ new LDAPAttribute("ou", "People"));
addDisconnect(r, w, attrs, "PostOperation");
@@ -1726,8 +1726,8 @@
bind(r, w);
ArrayList<RawAttribute> attrs = newRawAttributes(
- new LDAPAttribute("objectClass", byteStrings("top", "organizationalUnit")),
- new LDAPAttribute("ou", byteStrings("People")));
+ new LDAPAttribute("objectClass", newArrayList("top", "organizationalUnit")),
+ new LDAPAttribute("ou", "People"));
writeAddRequest(w, attrs, "PostResponse");
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 9873757..b39ee60 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
@@ -62,11 +62,11 @@
import org.opends.server.types.DN;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.Entry;
+import org.opends.server.types.LockManager.DNLock;
import org.opends.server.types.Modification;
import org.opends.server.types.Operation;
import org.opends.server.types.RawModification;
import org.opends.server.types.WritabilityMode;
-import org.opends.server.types.LockManager.DNLock;
import org.opends.server.util.Base64;
import org.opends.server.util.ServerConstants;
import org.opends.server.util.StaticUtils;
@@ -144,8 +144,8 @@
opList.add(newModifyOperation(null, ByteString.valueOf("o=test"), ldapMods));
opList.add(newModifyOperation(noControls, ByteString.valueOf("o=test"), ldapMods));
- ArrayList<ByteString> values2 = newArrayList(ByteString.valueOf("bar"));
- LDAPAttribute ldapAttr2 = new LDAPAttribute("description", values2);
+ String value2 = "bar";
+ LDAPAttribute ldapAttr2 = new LDAPAttribute("description", value2);
ldapMods = newRawModifications(delete(ldapAttr), add(ldapAttr2));
opList.add(newModifyOperation(null, ByteString.empty(), ldapMods));
@@ -153,7 +153,7 @@
opList.add(newModifyOperation(null, ByteString.valueOf("o=test"), ldapMods));
opList.add(newModifyOperation(noControls, ByteString.valueOf("o=test"), ldapMods));
- ldapAttr2 = new LDAPAttribute("cn", values2);
+ ldapAttr2 = new LDAPAttribute("cn", value2);
ldapMods = newRawModifications(replace(ldapAttr), replace(ldapAttr2));
opList.add(newModifyOperation(null, ByteString.empty(), ldapMods));
@@ -305,15 +305,9 @@
assertNotNull(modifyOperation.getEntryDN());
}
-
private LDAPAttribute newLDAPAttribute(String attributeType, String... valueStrings)
{
- ArrayList<ByteString> values = new ArrayList<>();
- for (String valueStr : valueStrings)
- {
- values.add(ByteString.valueOf(valueStr));
- }
- return new LDAPAttribute(attributeType, values);
+ return new LDAPAttribute(attributeType, newArrayList(valueStrings));
}
/**
@@ -3659,9 +3653,8 @@
"axuJ8LFNbZtsp1ldW3i84+F5+SYT+xI67ZcoAtwx/VFVI9s5I/Gkmu9f9nxjPpK7" +
"1AIUXiE3Qcck";
- ArrayList<ByteString> values = new ArrayList<>();
- values.add(ByteString.wrap(Base64.decode(certificateValue)));
- LDAPAttribute attr = new LDAPAttribute("usercertificate", values);
+ ByteString value = ByteString.wrap(Base64.decode(certificateValue));
+ LDAPAttribute attr = new LDAPAttribute("usercertificate", value);
ModifyOperation modifyOperation = processModify("uid=test.user," + baseDN, add(attr));
assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS);
retrieveSuccessfulOperationElements(modifyOperation);
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/extensions/CancelExtendedOperationTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/extensions/CancelExtendedOperationTestCase.java
index a1cbba5..9d489ee 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/extensions/CancelExtendedOperationTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/extensions/CancelExtendedOperationTestCase.java
@@ -66,6 +66,7 @@
import org.testng.annotations.Test;
import static org.opends.server.protocols.ldap.LDAPConstants.*;
+import static org.opends.server.util.CollectionUtils.*;
import static org.opends.server.util.ServerConstants.*;
import static org.testng.Assert.*;
@@ -125,19 +126,11 @@
// the delay request control so it won't complete before we can send the
// cancel request.
ArrayList<RawAttribute> attributes = new ArrayList<>();
-
- ArrayList<ByteString> values = new ArrayList<>(2);
- values.add(ByteString.valueOf("top"));
- values.add(ByteString.valueOf("organizationalUnit"));
- attributes.add(new LDAPAttribute("objectClass", values));
-
- values = new ArrayList<>(1);
- values.add(ByteString.valueOf("People"));
- attributes.add(new LDAPAttribute("ou", values));
+ attributes.add(new LDAPAttribute("objectClass", newArrayList("top", "organizationalUnit")));
+ attributes.add(new LDAPAttribute("ou", "People"));
AddRequestProtocolOp addRequest =
- new AddRequestProtocolOp(ByteString.valueOf("ou=People,o=test"),
- attributes);
+ new AddRequestProtocolOp(ByteString.valueOf("ou=People,o=test"), attributes);
message = new LDAPMessage(2, addRequest,
DelayPreOpPlugin.createDelayControlList(5000));
w.writeMessage(message);
@@ -457,12 +450,9 @@
// Create a modify request and send it to the server. Make sure to include
// the delay request control so it won't complete before we can send the
// cancel request.
- ArrayList<ByteString> values = new ArrayList<>(1);
- values.add(ByteString.valueOf("foo"));
-
ArrayList<RawModification> mods = new ArrayList<>(1);
mods.add(new LDAPModification(ModificationType.REPLACE,
- new LDAPAttribute("description", values)));
+ new LDAPAttribute("description", "foo")));
ModifyRequestProtocolOp modifyRequest =
new ModifyRequestProtocolOp(ByteString.valueOf("o=test"), mods);
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/extensions/ErrorLogAccountStatusNotificationHandlerTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/extensions/ErrorLogAccountStatusNotificationHandlerTestCase.java
index ba21a23..f4f5c39 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/extensions/ErrorLogAccountStatusNotificationHandlerTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/extensions/ErrorLogAccountStatusNotificationHandlerTestCase.java
@@ -26,28 +26,19 @@
*/
package org.opends.server.extensions;
-
-
-import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.DataProvider;
-import org.testng.annotations.Test;
-
-import org.opends.server.TestCaseUtils;
import org.forgerock.i18n.LocalizableMessage;
+import org.forgerock.opendj.config.server.ConfigException;
+import org.opends.server.TestCaseUtils;
+import org.opends.server.admin.server.AdminTestCaseUtils;
+import org.opends.server.admin.std.meta.ErrorLogAccountStatusNotificationHandlerCfgDefn;
+import org.opends.server.admin.std.server.ErrorLogAccountStatusNotificationHandlerCfg;
import org.opends.server.api.AccountStatusNotificationHandler;
import org.opends.server.api.AuthenticationPolicy;
-import org.opends.server.admin.server.AdminTestCaseUtils;
-import org.opends.server.admin.std.meta.
- ErrorLogAccountStatusNotificationHandlerCfgDefn;
-import org.opends.server.admin.std.server.
- ErrorLogAccountStatusNotificationHandlerCfg;
import org.opends.server.config.ConfigEntry;
-import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.PasswordPolicy;
import org.opends.server.types.AccountStatusNotification;
@@ -56,13 +47,14 @@
import org.opends.server.types.DN;
import org.opends.server.types.Entry;
import org.opends.server.types.InitializationException;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
-import static org.testng.Assert.*;
-
-import static org.opends.server.types.AccountStatusNotificationType.*;
import static org.opends.server.types.AccountStatusNotificationProperty.*;
-
-
+import static org.opends.server.types.AccountStatusNotificationType.*;
+import static org.opends.server.util.CollectionUtils.*;
+import static org.testng.Assert.*;
/**
* A set of test cases for the error log account status notification handler.
@@ -253,57 +245,33 @@
DirectoryServer.getAccountStatusNotificationHandler(handlerDN);
assertNotNull(handler);
- Entry userEntry =
- DirectoryServer.getEntry(DN.valueOf("uid=test.user,o=test"));
-
- PasswordPolicy policy = (PasswordPolicy) AuthenticationPolicy.forUser(
- userEntry, false);
-
+ Entry userEntry = DirectoryServer.getEntry(DN.valueOf("uid=test.user,o=test"));
HashMap<AccountStatusNotificationProperty, List<String>> notificationProperties = new HashMap<>();
- ArrayList<String> propList = new ArrayList<>(1);
- propList.add(policy.getDN().toString());
- notificationProperties.put(PASSWORD_POLICY_DN, propList);
-
+ PasswordPolicy policy = (PasswordPolicy) AuthenticationPolicy.forUser(userEntry, false);
+ notificationProperties.put(PASSWORD_POLICY_DN, newArrayList(policy.getDN().toString()));
if (notificationType == ACCOUNT_TEMPORARILY_LOCKED)
{
- propList = new ArrayList<>(1);
- propList.add("300");
- notificationProperties.put(SECONDS_UNTIL_UNLOCK, propList);
+ notificationProperties.put(SECONDS_UNTIL_UNLOCK, newArrayList("300"));
+ notificationProperties.put(TIME_UNTIL_UNLOCK, newArrayList("5 minutes"));
- propList = new ArrayList<>(1);
- propList.add("5 minutes");
- notificationProperties.put(TIME_UNTIL_UNLOCK, propList);
-
- propList = new ArrayList<>(1);
- propList.add(new Date(System.currentTimeMillis() + 300000L).toString());
- notificationProperties.put(ACCOUNT_UNLOCK_TIME, propList);
+ Date date = new Date(System.currentTimeMillis() + 300000L);
+ notificationProperties.put(ACCOUNT_UNLOCK_TIME, newArrayList(date.toString()));
}
else if (notificationType == PASSWORD_EXPIRING)
{
- propList = new ArrayList<>(1);
- propList.add("86400");
- notificationProperties.put(SECONDS_UNTIL_EXPIRATION, propList);
+ notificationProperties.put(SECONDS_UNTIL_EXPIRATION, newArrayList("86400"));
+ notificationProperties.put(TIME_UNTIL_EXPIRATION, newArrayList("1 day"));
- propList = new ArrayList<>(1);
- propList.add("1 day");
- notificationProperties.put(TIME_UNTIL_EXPIRATION, propList);
-
- propList = new ArrayList<>(1);
- propList.add(new Date(System.currentTimeMillis() + 86400000L).toString());
- notificationProperties.put(PASSWORD_EXPIRATION_TIME, propList);
+ Date date = new Date(System.currentTimeMillis() + 86400000L);
+ notificationProperties.put(PASSWORD_EXPIRATION_TIME, newArrayList(date.toString()));
}
else if ((notificationType == PASSWORD_CHANGED) ||
(notificationType == PASSWORD_RESET))
{
- propList = new ArrayList<>(1);
- propList.add("oldpassword");
- notificationProperties.put(OLD_PASSWORD, propList);
-
- propList = new ArrayList<>(1);
- propList.add("newpassword");
- notificationProperties.put(NEW_PASSWORD, propList);
+ notificationProperties.put(OLD_PASSWORD, newArrayList("oldpassword"));
+ notificationProperties.put(NEW_PASSWORD, newArrayList("newpassword"));
}
@@ -314,4 +282,3 @@
handler.handleStatusNotification(notification);
}
}
-
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/extensions/ExactMatchIdentityMapperTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/extensions/ExactMatchIdentityMapperTestCase.java
index 88755c0..2b2a498 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/extensions/ExactMatchIdentityMapperTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/extensions/ExactMatchIdentityMapperTestCase.java
@@ -963,13 +963,9 @@
throws Exception
{
// Create a modification to remove the match attribute.
- ArrayList<ByteString> values = new ArrayList<>();
- values.add(ByteString.valueOf("undefinedAttribute"));
-
ArrayList<RawModification> mods = new ArrayList<>();
mods.add(new LDAPModification(ModificationType.REPLACE,
- new LDAPAttribute("ds-cfg-match-attribute",
- values)));
+ new LDAPAttribute("ds-cfg-match-attribute", "undefinedAttribute")));
InternalClientConnection conn =
InternalClientConnection.getRootConnection();
String mapperDNString = "cn=Exact Match,cn=Identity Mappers,cn=config";
@@ -991,13 +987,9 @@
throws Exception
{
// Create a modification to remove the match attribute.
- ArrayList<ByteString> values = new ArrayList<>();
- values.add(ByteString.valueOf("invalidDN"));
-
ArrayList<RawModification> mods = new ArrayList<>();
mods.add(new LDAPModification(ModificationType.REPLACE,
- new LDAPAttribute("ds-cfg-match-base-dn",
- values)));
+ new LDAPAttribute("ds-cfg-match-base-dn", "invalidDN")));
InternalClientConnection conn =
InternalClientConnection.getRootConnection();
String mapperDNString = "cn=Exact Match,cn=Identity Mappers,cn=config";
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/extensions/WhoAmIExtendedOperationTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/extensions/WhoAmIExtendedOperationTestCase.java
index c49cebf..a9e2cc4 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/extensions/WhoAmIExtendedOperationTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/extensions/WhoAmIExtendedOperationTestCase.java
@@ -53,6 +53,7 @@
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
+import static org.opends.server.util.CollectionUtils.*;
import static org.opends.server.util.ServerConstants.*;
import static org.testng.Assert.*;
@@ -306,14 +307,8 @@
nextMessageID);
HashMap<String,List<String>> saslProperties = new HashMap<>(2);
-
- ArrayList<String> authIDList = new ArrayList<>(1);
- authIDList.add("dn:uid=proxy.user,o=test");
- saslProperties.put("authID", authIDList);
-
- ArrayList<String> authzIDList = new ArrayList<>(1);
- authzIDList.add("dn:uid=test.user,o=test");
- saslProperties.put("authzID", authzIDList);
+ saslProperties.put("authID", newArrayList("dn:uid=proxy.user,o=test"));
+ saslProperties.put("authzID", newArrayList("dn:uid=test.user,o=test"));
authHandler.doSASLPlain(ByteString.empty(),
ByteString.valueOf("password"), saslProperties,
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/plugins/DelayPreOpPlugin.java b/opendj-server-legacy/src/test/java/org/opends/server/plugins/DelayPreOpPlugin.java
index fdd2eb4..5753743 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/plugins/DelayPreOpPlugin.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/plugins/DelayPreOpPlugin.java
@@ -29,24 +29,26 @@
import java.io.IOException;
-import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import org.forgerock.i18n.LocalizableMessage;
+import org.forgerock.opendj.config.server.ConfigException;
+import org.forgerock.opendj.io.ASN1;
+import org.forgerock.opendj.io.ASN1Reader;
+import org.forgerock.opendj.io.ASN1Writer;
+import org.forgerock.opendj.ldap.ByteString;
+import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.admin.std.server.PluginCfg;
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.ConfigException;
import org.opends.server.controls.ControlDecoder;
-import org.forgerock.opendj.io.ASN1;
-import org.forgerock.opendj.io.ASN1Reader;
-import org.forgerock.opendj.io.ASN1Writer;
-import org.opends.server.types.*;
-import org.forgerock.opendj.ldap.ResultCode;
-import org.forgerock.opendj.ldap.ByteString;
+import org.opends.server.types.CanceledOperationException;
+import org.opends.server.types.Control;
+import org.opends.server.types.DirectoryException;
import org.opends.server.types.operation.*;
+import org.opends.server.util.CollectionUtils;
/**
* This class defines a very simple pre-operation plugin that sleeps for up to
@@ -365,11 +367,7 @@
*/
public static List<Control> createDelayControlList(long delay)
{
- ArrayList<Control> controlList = new ArrayList<>(1);
-
- controlList.add(new DelayRequestControl(false, delay));
-
- return controlList;
+ Control c = new DelayRequestControl(false, delay);
+ return CollectionUtils.newArrayList(c);
}
}
-
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/plugins/DisconnectClientPlugin.java b/opendj-server-legacy/src/test/java/org/opends/server/plugins/DisconnectClientPlugin.java
index 89ccb1e..bf3218c 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/plugins/DisconnectClientPlugin.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/plugins/DisconnectClientPlugin.java
@@ -26,29 +26,26 @@
*/
package org.opends.server.plugins;
-
-
import java.io.IOException;
-import java.util.ArrayList;
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.io.ASN1Writer;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.admin.std.server.PluginCfg;
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.ConfigException;
import org.opends.server.controls.ControlDecoder;
-import org.forgerock.opendj.io.ASN1Writer;
import org.opends.server.types.CanceledOperationException;
import org.opends.server.types.Control;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.DisconnectReason;
import org.opends.server.types.operation.*;
-
+import org.opends.server.util.CollectionUtils;
/**
* This class defines a very simple plugin that terminates the client connection
@@ -690,11 +687,9 @@
}
catch (Exception e)
{
- logger.error(LocalizableMessage.raw("Unable to decode the disconnect client control: " +
- e));
+ logger.error(LocalizableMessage.raw("Unable to decode the disconnect client control: " + e));
}
-
// If we've gotten here, then we shouldn't disconnect the client.
return false;
}
@@ -725,11 +720,7 @@
*/
public static List<Control> createDisconnectControlList(String section)
{
- ArrayList<Control> controlList = new ArrayList<>(1);
-
- controlList.add(new DisconnectClientControl(false, section));
-
- return controlList;
+ Control c = new DisconnectClientControl(false, section);
+ return CollectionUtils.newArrayList(c);
}
}
-
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/plugins/ReferentialIntegrityPluginTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/plugins/ReferentialIntegrityPluginTestCase.java
index 88bc571..7be9c65 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/plugins/ReferentialIntegrityPluginTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/plugins/ReferentialIntegrityPluginTestCase.java
@@ -27,7 +27,6 @@
*/
package org.opends.server.plugins;
-import java.util.ArrayList;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
@@ -62,6 +61,7 @@
import static org.opends.server.protocols.internal.InternalClientConnection.*;
import static org.opends.server.protocols.internal.Requests.*;
+import static org.opends.server.util.CollectionUtils.*;
import static org.testng.Assert.*;
/**
@@ -1116,15 +1116,12 @@
private void deleteSubtree(String... dns) throws Exception
{
- InternalClientConnection conn = getRootConnection();
-
- SubtreeDeleteControl control = new SubtreeDeleteControl(true);
- List<Control> controls = new ArrayList<>(1);
- controls.add(control);
+ Control control = new SubtreeDeleteControl(true);
+ List<Control> controls = newArrayList(control);
for (String dn : dns)
{
- DeleteOperation op = conn.processDelete(DN.valueOf(dn), controls);
+ DeleteOperation op = getRootConnection().processDelete(DN.valueOf(dn), controls);
assertEquals(op.getResultCode(), ResultCode.SUCCESS);
}
}
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/plugins/ShortCircuitPlugin.java b/opendj-server-legacy/src/test/java/org/opends/server/plugins/ShortCircuitPlugin.java
index bed7547..d68253c 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/plugins/ShortCircuitPlugin.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/plugins/ShortCircuitPlugin.java
@@ -28,14 +28,16 @@
+import static org.opends.server.util.CollectionUtils.*;
+
import java.io.IOException;
-import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import org.forgerock.i18n.LocalizableMessage;
+import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.io.ASN1;
import org.forgerock.opendj.io.ASN1Reader;
import org.forgerock.opendj.io.ASN1Writer;
@@ -45,7 +47,6 @@
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.ConfigException;
import org.opends.server.controls.ControlDecoder;
import org.opends.server.types.Control;
import org.opends.server.types.DirectoryException;
@@ -663,12 +664,9 @@
*
* @return A list containing the appropriate short circuit request control.
*/
- public static List<Control> createShortCircuitControlList(int resultCode,
- String section)
+ public static List<Control> createShortCircuitControlList(int resultCode, String section)
{
- ArrayList<Control> controlList = new ArrayList<>(1);
- controlList.add(createShortCircuitControl(resultCode, section));
- return controlList;
+ return newArrayList(createShortCircuitControl(resultCode, section));
}
/** Registered short circuits for operations regardless of controls. */
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/plugins/UpdatePreOpPlugin.java b/opendj-server-legacy/src/test/java/org/opends/server/plugins/UpdatePreOpPlugin.java
index 9680bf9..837bf7a 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/plugins/UpdatePreOpPlugin.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/plugins/UpdatePreOpPlugin.java
@@ -26,16 +26,17 @@
*/
package org.opends.server.plugins;
-
+import static org.opends.server.util.CollectionUtils.*;
import java.util.ArrayList;
import java.util.Set;
+import org.forgerock.i18n.LocalizableMessage;
+import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.admin.std.server.PluginCfg;
import org.opends.server.api.plugin.DirectoryServerPlugin;
-import org.opends.server.api.plugin.PluginType;
import org.opends.server.api.plugin.PluginResult;
-import org.forgerock.opendj.config.server.ConfigException;
+import org.opends.server.api.plugin.PluginType;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.opends.server.types.DirectoryException;
@@ -43,8 +44,6 @@
import org.opends.server.types.ObjectClass;
import org.opends.server.types.operation.PreOperationAddOperation;
import org.opends.server.types.operation.PreOperationModifyOperation;
-import org.forgerock.i18n.LocalizableMessage;
-
/**
* This class defines a pre-operation plugin that can be used in add and modify
@@ -142,9 +141,7 @@
for (Attribute a : setAttributes)
{
- ArrayList<Attribute> attrList = new ArrayList<>(1);
- attrList.add(a);
- addOperation.setAttribute(a.getAttributeType(), attrList);
+ addOperation.setAttribute(a.getAttributeType(), newArrayList(a));
}
for (ObjectClass oc : removeObjectClasses)
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/protocols/internal/InternalClientConnectionTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/protocols/internal/InternalClientConnectionTestCase.java
index fe1e2c0..5633cd6 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/protocols/internal/InternalClientConnectionTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/protocols/internal/InternalClientConnectionTestCase.java
@@ -62,6 +62,7 @@
import static org.opends.server.protocols.internal.InternalClientConnection.*;
import static org.opends.server.protocols.internal.Requests.*;
+import static org.opends.server.util.CollectionUtils.*;
import static org.opends.server.util.ServerConstants.*;
import static org.testng.Assert.*;
@@ -313,15 +314,8 @@
ByteString dn = ByteString.valueOf("cn=test,o=test");
ArrayList<RawAttribute> attrs = new ArrayList<>();
-
- ArrayList<ByteString> values = new ArrayList<>();
- values.add(ByteString.valueOf("top"));
- values.add(ByteString.valueOf("device"));
- attrs.add(new LDAPAttribute("objectClass", values));
-
- values = new ArrayList<>();
- values.add(ByteString.valueOf("test"));
- attrs.add(new LDAPAttribute("cn", values));
+ attrs.add(new LDAPAttribute("objectClass", newArrayList("top", "device")));
+ attrs.add(new LDAPAttribute("cn", "test"));
AddOperation addOperation = getRootConnection().processAdd(dn, attrs);
assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -559,12 +553,9 @@
"objectClass: device",
"cn: test");
- ArrayList<ByteString> values = new ArrayList<>();
- values.add(ByteString.valueOf("This is a test"));
-
ArrayList<RawModification> mods = new ArrayList<>();
mods.add(new LDAPModification(ModificationType.REPLACE,
- new LDAPAttribute("description", values)));
+ new LDAPAttribute("description", "This is a test")));
InternalClientConnection conn = getRootConnection();
ModifyOperation modifyOperation =
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/protocols/jmx/JmxPrivilegeTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/protocols/jmx/JmxPrivilegeTestCase.java
index ae22f89..b82f3c1 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/protocols/jmx/JmxPrivilegeTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/protocols/jmx/JmxPrivilegeTestCase.java
@@ -64,6 +64,7 @@
import static org.opends.messages.ProtocolMessages.*;
import static org.opends.server.protocols.internal.InternalClientConnection.*;
import static org.opends.server.protocols.internal.Requests.*;
+import static org.opends.server.util.CollectionUtils.*;
import static org.testng.Assert.*;
/**
@@ -604,9 +605,8 @@
// Try to modify the entry to add a description.
- ArrayList<Modification> mods = new ArrayList<>(1);
- mods.add(new Modification(ModificationType.REPLACE,
- Attributes.create("description", "foo")));
+ ArrayList<Modification> mods =
+ newArrayList(new Modification(ModificationType.REPLACE, Attributes.create("description", "foo")));
ModifyOperationBasis modifyOperation = new ModifyOperationBasis(conn,
conn.nextOperationID(), conn.nextMessageID(), controls, e.getName(),
@@ -793,9 +793,8 @@
// Try to modify the entry to add a description.
- ArrayList<Modification> mods = new ArrayList<>(1);
- mods.add(new Modification(ModificationType.REPLACE,
- Attributes.create("description", "foo")));
+ ArrayList<Modification> mods =
+ newArrayList(new Modification(ModificationType.REPLACE, Attributes.create("description", "foo")));
ModifyOperationBasis modifyOperation =
new ModifyOperationBasis(conn,
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/protocols/ldap/TestAddRequestProtocolOp.java b/opendj-server-legacy/src/test/java/org/opends/server/protocols/ldap/TestAddRequestProtocolOp.java
index 04902a6..ee00194 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/protocols/ldap/TestAddRequestProtocolOp.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/protocols/ldap/TestAddRequestProtocolOp.java
@@ -50,29 +50,12 @@
*/
public class TestAddRequestProtocolOp extends LdapTestCase
{
- /**
- * The protocol op type for add requests.
- */
+ /** The protocol op type for add requests. */
private static final byte OP_TYPE_ADD_REQUEST = 0x68;
-
-
-
- /**
- * The protocol op type for add responses.
- */
+ /** The protocol op type for add responses. */
private static final byte OP_TYPE_ADD_RESPONSE = 0x69;
-
- /**
- * The DN for add requests in this test case.
- */
- private static final ByteString dn =
- ByteString.valueOf("dc=example,dc=com");
-
- /**
- * The alternative DN for add requests in this test case.
- */
- private static final ByteString dnAlt =
- ByteString.valueOf("dc=sun,dc=com");
+ /** The DN for add requests in this test case. */
+ private static final ByteString dn = ByteString.valueOf("dc=example,dc=com");
/**
* Generate attributes for use in test cases. Attributes will have names
@@ -96,10 +79,10 @@
for (int i = 0; i < numAttributes; i++)
{
- ArrayList<ByteString> values = new ArrayList<>();
+ ArrayList<String> values = new ArrayList<>();
for (int j = 0; j < numValues; j++)
{
- values.add(ByteString.valueOf(prefix + "Value" + i + "." + j));
+ values.add(prefix + "Value" + i + "." + j);
}
attributes.add(new LDAPAttribute("testAttribute" + i, values));
}
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/protocols/ldap/TestLDAPFilter.java b/opendj-server-legacy/src/test/java/org/opends/server/protocols/ldap/TestLDAPFilter.java
index a9cf1f2..e1377d0 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/protocols/ldap/TestLDAPFilter.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/protocols/ldap/TestLDAPFilter.java
@@ -28,17 +28,20 @@
import java.util.ArrayList;
-import org.testng.annotations.DataProvider;
-import org.testng.annotations.Test;
-import org.testng.annotations.BeforeTest;
-import org.opends.server.types.*;
+import org.forgerock.opendj.io.ASN1;
+import org.forgerock.opendj.io.ASN1Reader;
+import org.forgerock.opendj.io.ASN1Writer;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ByteStringBuilder;
import org.opends.server.TestCaseUtils;
-import org.forgerock.opendj.io.ASN1Writer;
-import org.forgerock.opendj.io.ASN1;
-import org.forgerock.opendj.io.ASN1Reader;
+import org.opends.server.types.LDAPException;
+import org.opends.server.types.RawFilter;
+import org.opends.server.types.SearchFilter;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+import static org.opends.server.util.CollectionUtils.*;
import static org.testng.Assert.*;
public class TestLDAPFilter extends LdapTestCase
@@ -91,9 +94,7 @@
LDAPFilter presense = LDAPFilter.createPresenceFilter("login");
ArrayList<ByteString> any = new ArrayList<>(0);
- ArrayList<ByteString> multiAny = new ArrayList<>(1);
- multiAny.add(ByteString.valueOf("\\wid*(get)"));
- multiAny.add(ByteString.valueOf("*"));
+ ArrayList<ByteString> multiAny = newArrayList(ByteString.valueOf("\\wid*(get)"), ByteString.valueOf("*"));
LDAPFilter substring1 = LDAPFilter.createSubstringFilter("givenName",
ByteString.valueOf("\\Jo*()"),
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 3a7d77f..b56d973 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
@@ -56,6 +56,7 @@
import static org.opends.server.TestCaseUtils.*;
import static org.opends.server.protocols.internal.InternalClientConnection.*;
+import static org.opends.server.util.CollectionUtils.*;
import static org.testng.Assert.*;
/**
@@ -479,9 +480,7 @@
// Replay a replace of a value B at time t2 on a second server.
Attribute attr = Attributes.create(attrType, "B");
- Modification mod = new Modification(ModificationType.REPLACE, attr);
- List<Modification> mods = new ArrayList<>(1);
- mods.add(mod);
+ List<Modification> mods = newArrayList(new Modification(ModificationType.REPLACE, attr));
ModifyMsg modMsg = new ModifyMsg(t2, dn1, mods, entryuuid);
broker.publish(modMsg);
@@ -489,9 +488,7 @@
// Replay an add of a value A at time t1 on a first server.
attr = Attributes.create(attrType, "A");
- mod = new Modification(ModificationType.ADD, attr);
- mods = new ArrayList<>(1);
- mods.add(mod);
+ mods = newArrayList(new Modification(ModificationType.ADD, attr));
modMsg = new ModifyMsg(t1, dn1, mods, entryuuid);
broker.publish(modMsg);
@@ -521,9 +518,7 @@
// Replay an delete of attribute displayname at time t2 on a second server.
attr = Attributes.empty(attrType);
- mod = new Modification(ModificationType.DELETE, attr);
- mods = new ArrayList<>(1);
- mods.add(mod);
+ mods = newArrayList(new Modification(ModificationType.DELETE, attr));
modMsg = new ModifyMsg(t2, dn1, mods, entryuuid);
broker.publish(modMsg);
@@ -531,9 +526,7 @@
// Replay a replace of a value A at time t1 on a first server.
attr = Attributes.create(attrType, "A");
- mod = new Modification(ModificationType.REPLACE, attr);
- mods = new ArrayList<>(1);
- mods.add(mod);
+ mods = newArrayList(new Modification(ModificationType.REPLACE, attr));
modMsg = new ModifyMsg(t1, dn1, mods, entryuuid);
broker.publish(modMsg);
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/HistoricalTest.java b/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/HistoricalTest.java
index ac0dfa4..aa76922 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/HistoricalTest.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/HistoricalTest.java
@@ -26,7 +26,6 @@
*/
package org.opends.server.replication.plugin;
-import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
@@ -48,6 +47,7 @@
import static org.forgerock.opendj.ldap.ResultCode.*;
import static org.forgerock.opendj.ldap.SearchScope.*;
import static org.opends.server.TestCaseUtils.*;
+import static org.opends.server.util.CollectionUtils.*;
import static org.testng.Assert.*;
/**
@@ -333,9 +333,7 @@
DN dn, String entryuuid, AttributeType attrType, String newValue)
{
Attribute attr = Attributes.create(attrType.getNormalizedPrimaryName(), newValue);
- Modification mod = new Modification(ModificationType.ADD, attr);
- List<Modification> mods = new ArrayList<>(1);
- mods.add(mod);
+ List<Modification> mods = newArrayList(new Modification(ModificationType.ADD, attr));
broker.publish(new ModifyMsg(changeNum, dn, mods, entryuuid));
}
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 ba4ac5f..45fdf32 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
@@ -1252,9 +1252,7 @@
UUID uuid = UUID.randomUUID();
// Create the att values list
- ArrayList<Attribute> uuidList = new ArrayList<>(1);
- Attribute uuidAttr = Attributes.create(entryuuidAttrType, uuid.toString());
- uuidList.add(uuidAttr);
+ List<Attribute> uuidList = Attributes.createAsList(entryuuidAttrType, uuid.toString());
// Add the uuid in the entry
Map<AttributeType, List<Attribute>> operationalAttributes = entry.getOperationalAttributes();
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/util/TestAddChangeRecordEntry.java b/opendj-server-legacy/src/test/java/org/opends/server/util/TestAddChangeRecordEntry.java
index d795f9d..ff2ee6a 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/util/TestAddChangeRecordEntry.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/util/TestAddChangeRecordEntry.java
@@ -26,7 +26,8 @@
*/
package org.opends.server.util;
-import java.util.ArrayList;
+import static org.opends.server.util.CollectionUtils.*;
+
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
@@ -68,11 +69,9 @@
// start the server.
TestCaseUtils.startServer();
- attributes = new HashMap<>();
attribute = Attributes.create("cn", "hello world");
- ArrayList<Attribute> alist = new ArrayList<>(1);
- alist.add(attribute);
- attributes.put(attribute.getAttributeType(), alist);
+ attributes = new HashMap<>();
+ attributes.put(attribute.getAttributeType(), newArrayList(attribute));
}
/**
--
Gitblit v1.10.0