From d366a5db9c1477c823758862268dd493dbbcc936 Mon Sep 17 00:00:00 2001
From: Jean-Noël Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Tue, 07 Jun 2016 13:49:03 +0000
Subject: [PATCH] OPENDJ-3037 inlined DirectoryServer.getTopObjectClass() and getObjectClassAttributeType()
---
opendj-server-legacy/src/test/java/org/opends/server/replication/protocol/ProtocolCompatibilityTest.java | 40 +---
opendj-server-legacy/src/main/java/org/opends/server/core/DirectoryServer.java | 23 --
opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/AciEffectiveRights.java | 5
opendj-server-legacy/src/main/java/org/opends/server/core/SearchOperationBasis.java | 6
opendj-server-legacy/src/main/java/org/opends/server/util/StaticUtils.java | 4
opendj-server-legacy/src/test/java/org/opends/server/util/TestLDIFReader.java | 95 ++++------
opendj-server-legacy/src/main/java/org/opends/server/util/LDIFReader.java | 3
opendj-server-legacy/src/test/java/org/opends/server/core/AddOperationTestCase.java | 3
opendj-server-legacy/src/main/java/org/opends/server/backends/SchemaBackend.java | 5
opendj-server-legacy/src/main/java/org/opends/server/types/LDAPURL.java | 5
opendj-server-legacy/src/main/java/org/opends/server/backends/BackupBackend.java | 8
opendj-server-legacy/src/main/java/org/opends/server/tools/LDIFDiff.java | 85 ++++-----
opendj-server-legacy/src/main/java/org/opends/server/tools/makeldif/Branch.java | 10
opendj-server-legacy/src/main/java/org/opends/server/protocols/internal/InternalClientConnection.java | 3
opendj-server-legacy/src/main/java/org/opends/server/crypto/CryptoManagerImpl.java | 9
opendj-server-legacy/src/main/java/org/opends/server/backends/NullBackend.java | 4
opendj-server-legacy/src/test/java/org/opends/server/replication/protocol/SynchronizationMsgTest.java | 41 ++--
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/NewObjectClassPanel.java | 4
opendj-server-legacy/src/main/java/org/opends/server/replication/protocol/AddMsg.java | 18 +
opendj-server-legacy/src/test/java/org/opends/server/core/ModifyOperationTestCase.java | 33 +-
opendj-server-legacy/src/test/java/org/opends/server/types/TestEntry.java | 82 ++++----
opendj-server-legacy/src/main/java/org/opends/server/types/Entry.java | 5
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/components/SuperiorObjectClassesEditor.java | 3
opendj-server-legacy/src/main/java/org/opends/server/backends/TrustStoreBackend.java | 5
opendj-server-legacy/src/test/java/org/opends/server/core/SubtreeSpecificationTestCase.java | 31 +--
opendj-server-legacy/src/main/java/org/opends/server/crypto/CryptoManagerSync.java | 3
26 files changed, 236 insertions(+), 297 deletions(-)
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/NewObjectClassPanel.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/NewObjectClassPanel.java
index 99601c3..7be86bc 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/NewObjectClassPanel.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/NewObjectClassPanel.java
@@ -50,6 +50,7 @@
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.LocalizableMessageBuilder;
import org.forgerock.opendj.ldap.schema.AttributeType;
+import org.forgerock.opendj.ldap.schema.CoreSchema;
import org.forgerock.opendj.ldap.schema.ObjectClass;
import org.forgerock.opendj.ldap.schema.ObjectClassType;
import org.forgerock.opendj.ldap.schema.SchemaBuilder;
@@ -324,8 +325,7 @@
oid.setText("");
description.setText("");
aliases.setText("");
- superiors.setSelectedSuperiors(
- Collections.singleton(schema.getObjectClass("top")));
+ superiors.setSelectedSuperiors(Collections.singleton(CoreSchema.getTopObjectClass()));
attributes.getAvailableListModel().addAll(
attributes.getSelectedListModel1().getData());
attributes.getAvailableListModel().addAll(
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/components/SuperiorObjectClassesEditor.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/components/SuperiorObjectClassesEditor.java
index e1e0503..f43bf86 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/components/SuperiorObjectClassesEditor.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/components/SuperiorObjectClassesEditor.java
@@ -40,6 +40,7 @@
import javax.swing.JLabel;
import javax.swing.JPanel;
+import org.forgerock.opendj.ldap.schema.CoreSchema;
import org.forgerock.opendj.ldap.schema.ObjectClass;
import org.opends.guitools.controlpanel.event.SuperiorObjectClassesChangedEvent;
import org.opends.guitools.controlpanel.event.SuperiorObjectClassesChangedListener;
@@ -275,7 +276,7 @@
if (this.schema == null)
{
- singleSuperior.setSelectedItem(schema.getObjectClass("top"));
+ singleSuperior.setSelectedItem(CoreSchema.getTopObjectClass());
}
this.schema = schema;
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/AciEffectiveRights.java b/opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/AciEffectiveRights.java
index ac2b3f1..dce1d03 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/AciEffectiveRights.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/AciEffectiveRights.java
@@ -24,6 +24,7 @@
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.schema.AttributeType;
+import org.forgerock.opendj.ldap.schema.CoreSchema;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.Attribute;
import org.opends.server.types.Attributes;
@@ -234,9 +235,7 @@
// Check for shorthands for user attributes "*" or operational "+".
if ("*".equals(a))
{
- // Add objectclass.
- AttributeType ocType = DirectoryServer.getObjectClassAttributeType();
- nonRightsAttrs.add(ocType);
+ nonRightsAttrs.add(CoreSchema.getObjectClassAttributeType());
nonRightsAttrs.addAll(e.getUserAttributes().keySet());
}
else if ("+".equals(a))
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 ab076b9..bd20ef3 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
@@ -46,6 +46,7 @@
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.SearchScope;
import org.forgerock.opendj.ldap.schema.AttributeType;
+import org.forgerock.opendj.ldap.schema.CoreSchema;
import org.forgerock.opendj.server.config.server.BackupBackendCfg;
import org.opends.server.api.Backend;
import org.opends.server.core.AddOperation;
@@ -211,7 +212,7 @@
// Construct the backup base entry.
LinkedHashMap<ObjectClass,String> objectClasses = new LinkedHashMap<>(2);
- objectClasses.put(DirectoryServer.getTopObjectClass(), OC_TOP);
+ objectClasses.put(CoreSchema.getTopObjectClass(), OC_TOP);
objectClasses.put(DirectoryServer.getObjectClass(OC_UNTYPED_OBJECT_LC), OC_UNTYPED_OBJECT);
LinkedHashMap<AttributeType,List<Attribute>> opAttrs = new LinkedHashMap<>(0);
@@ -501,8 +502,7 @@
// Construct the backup directory entry to return.
LinkedHashMap<ObjectClass,String> ocMap = new LinkedHashMap<>(2);
- ocMap.put(DirectoryServer.getTopObjectClass(), OC_TOP);
-
+ ocMap.put(CoreSchema.getTopObjectClass(), OC_TOP);
ocMap.put(DirectoryServer.getObjectClass(OC_BACKUP_DIRECTORY), OC_BACKUP_DIRECTORY);
LinkedHashMap<AttributeType,List<Attribute>> opAttrs = new LinkedHashMap<>(0);
@@ -578,7 +578,7 @@
// Construct the backup entry to return.
LinkedHashMap<ObjectClass, String> ocMap = new LinkedHashMap<>(3);
- ocMap.put(DirectoryServer.getTopObjectClass(), OC_TOP);
+ ocMap.put(CoreSchema.getTopObjectClass(), OC_TOP);
ocMap.put(DirectoryServer.getObjectClass(OC_BACKUP_INFO), OC_BACKUP_INFO);
ocMap.put(DirectoryServer.getObjectClass(OC_EXTENSIBLE_OBJECT_LC), OC_EXTENSIBLE_OBJECT);
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/backends/NullBackend.java b/opendj-server-legacy/src/main/java/org/opends/server/backends/NullBackend.java
index afb92e7..b530bff 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/backends/NullBackend.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/backends/NullBackend.java
@@ -33,6 +33,7 @@
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.SearchScope;
import org.forgerock.opendj.ldap.schema.AttributeType;
+import org.forgerock.opendj.ldap.schema.CoreSchema;
import org.forgerock.opendj.ldap.schema.ObjectClass;
import org.forgerock.opendj.server.config.server.BackendCfg;
import org.opends.server.api.Backend;
@@ -143,8 +144,7 @@
// Initialize null entry object classes.
objectClasses = new HashMap<>();
-
- objectClasses.put(DirectoryServer.getTopObjectClass(), "top");
+ objectClasses.put(CoreSchema.getTopObjectClass(), OC_TOP);
String nulOCName = "nullbackendobject";
ObjectClass nulOC = DirectoryServer.getObjectClass(nulOCName);
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 cb3ceb9..772d6c2 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
@@ -62,6 +62,7 @@
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.SearchScope;
import org.forgerock.opendj.ldap.schema.AttributeType;
+import org.forgerock.opendj.ldap.schema.CoreSchema;
import org.forgerock.opendj.ldap.schema.DITContentRule;
import org.forgerock.opendj.ldap.schema.DITStructureRule;
import org.forgerock.opendj.ldap.schema.MatchingRule;
@@ -239,7 +240,7 @@
// Construct the set of objectclasses to include in the schema entry.
schemaObjectClasses = new LinkedHashMap<>(3);
- schemaObjectClasses.put(DirectoryServer.getTopObjectClass(), OC_TOP);
+ schemaObjectClasses.put(CoreSchema.getTopObjectClass(), OC_TOP);
schemaObjectClasses.put(DirectoryServer.getObjectClass(OC_LDAP_SUBENTRY_LC), OC_LDAP_SUBENTRY);
schemaObjectClasses.put(DirectoryServer.getObjectClass(OC_SUBSCHEMA), OC_SUBSCHEMA);
@@ -2201,7 +2202,7 @@
private Entry createEmptySchemaEntry()
{
Map<ObjectClass,String> objectClasses = new LinkedHashMap<>();
- objectClasses.put(DirectoryServer.getTopObjectClass(), OC_TOP);
+ objectClasses.put(CoreSchema.getTopObjectClass(), OC_TOP);
objectClasses.put(DirectoryServer.getObjectClass(OC_LDAP_SUBENTRY_LC), OC_LDAP_SUBENTRY);
objectClasses.put(DirectoryServer.getObjectClass(OC_SUBSCHEMA), OC_SUBSCHEMA);
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 481fd60..b66f09e 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
@@ -62,6 +62,7 @@
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.SearchScope;
import org.forgerock.opendj.ldap.schema.AttributeType;
+import org.forgerock.opendj.ldap.schema.CoreSchema;
import org.forgerock.opendj.server.config.server.TrustStoreBackendCfg;
import org.forgerock.util.Reject;
import org.opends.server.api.Backend;
@@ -189,7 +190,7 @@
// Construct the trust store base entry.
LinkedHashMap<ObjectClass,String> objectClasses = new LinkedHashMap<>(2);
- objectClasses.put(DirectoryServer.getTopObjectClass(), OC_TOP);
+ objectClasses.put(CoreSchema.getTopObjectClass(), OC_TOP);
objectClasses.put(DirectoryServer.getObjectClass("ds-cfg-branch"), "ds-cfg-branch");
LinkedHashMap<AttributeType,List<Attribute>> userAttrs = new LinkedHashMap<>(1);
@@ -413,7 +414,7 @@
// Construct the certificate entry to return.
LinkedHashMap<ObjectClass,String> ocMap = new LinkedHashMap<>(2);
- ocMap.put(DirectoryServer.getTopObjectClass(), OC_TOP);
+ ocMap.put(CoreSchema.getTopObjectClass(), OC_TOP);
ocMap.put(DirectoryServer.getObjectClass(OC_CRYPTO_INSTANCE_KEY), OC_CRYPTO_INSTANCE_KEY);
LinkedHashMap<AttributeType,List<Attribute>> opAttrs = new LinkedHashMap<>(0);
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/core/DirectoryServer.java b/opendj-server-legacy/src/main/java/org/opends/server/core/DirectoryServer.java
index 7258fa2..3a3ac42 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/core/DirectoryServer.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/core/DirectoryServer.java
@@ -22,7 +22,6 @@
import static org.opends.messages.CoreMessages.*;
import static org.opends.messages.ToolMessages.*;
import static org.opends.server.config.ConfigConstants.*;
-import static org.opends.server.schema.SchemaConstants.*;
import static org.opends.server.tools.ConfigureWindowsService.*;
import static org.opends.server.util.CollectionUtils.*;
import static org.opends.server.util.DynamicConstants.*;
@@ -2292,18 +2291,6 @@
}
/**
- * Retrieves the "top" objectClass, which should be the topmost objectclass in
- * the inheritance chain for most other objectclasses. If no such objectclass
- * could be found, then one will be constructed.
- *
- * @return The "top" objectClass.
- */
- public static ObjectClass getTopObjectClass()
- {
- return directoryServer.schema.getObjectClass(TOP_OBJECTCLASS_NAME);
- }
-
- /**
* Retrieves the attribute type for the provided name or OID. It can optionally return a generated
* placeholder version if the requested attribute type is not defined in the schema.
*
@@ -2335,16 +2322,6 @@
}
/**
- * Retrieves the attribute type for the "objectClass" attribute.
- *
- * @return The attribute type for the "objectClass" attribute.
- */
- public static AttributeType getObjectClassAttributeType()
- {
- return directoryServer.schema.getAttributeType(OBJECTCLASS_ATTRIBUTE_TYPE_NAME);
- }
-
- /**
* Retrieves the set of virtual attribute rules registered with the Directory
* Server.
*
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/core/SearchOperationBasis.java b/opendj-server-legacy/src/main/java/org/opends/server/core/SearchOperationBasis.java
index 879a62f..977c50f 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/core/SearchOperationBasis.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/core/SearchOperationBasis.java
@@ -32,6 +32,7 @@
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.SearchScope;
import org.forgerock.opendj.ldap.schema.AttributeType;
+import org.forgerock.opendj.ldap.schema.CoreSchema;
import org.opends.server.api.AccessControlHandler;
import org.opends.server.api.AuthenticationPolicyState;
import org.opends.server.api.ClientConnection;
@@ -583,9 +584,8 @@
// NOTE: the objectClass attribute is also present and must be
// dealt with later.
- AttributeType attrType = DirectoryServer.getObjectClassAttributeType();
- Iterator<String> ocIterator =
- filteredEntry.getObjectClasses().values().iterator();
+ AttributeType attrType = CoreSchema.getObjectClassAttributeType();
+ Iterator<String> ocIterator = filteredEntry.getObjectClasses().values().iterator();
while (ocIterator.hasNext())
{
ByteString ocName = ByteString.valueOfUtf8(ocIterator.next());
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 69f7c75..eccbdf3 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,6 +73,7 @@
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.SearchScope;
import org.forgerock.opendj.ldap.schema.AttributeType;
+import org.forgerock.opendj.ldap.schema.CoreSchema;
import org.forgerock.util.Reject;
import org.opends.admin.ads.ADSContext;
import org.forgerock.opendj.config.server.ConfigurationChangeListener;
@@ -538,7 +539,7 @@
}
final Entry entry = new Entry(entryDN, null, null, null);
- entry.addObjectClass(DirectoryServer.getTopObjectClass());
+ entry.addObjectClass(CoreSchema.getTopObjectClass());
entry.addObjectClass(ocCertRequest);
AddOperation addOperation = icc.processAdd(entry);
if (ResultCode.SUCCESS != addOperation.getResultCode()) {
@@ -637,7 +638,7 @@
final InternalSearchOperation searchOp = icc.processSearch(request);
if (searchOp.getSearchEntries().isEmpty()) {
final Entry entry = new Entry(entryDN, null, null, null);
- entry.addObjectClass(DirectoryServer.getTopObjectClass());
+ entry.addObjectClass(CoreSchema.getTopObjectClass());
entry.addObjectClass(ocInstanceKey);
// Add the key ID attribute.
@@ -1581,7 +1582,7 @@
// Set the entry object classes.
LinkedHashMap<ObjectClass,String> ocMap = new LinkedHashMap<>(2);
- ocMap.put(DirectoryServer.getTopObjectClass(), OC_TOP);
+ ocMap.put(CoreSchema.getTopObjectClass(), OC_TOP);
ocMap.put(ocCipherKey, OC_CRYPTO_CIPHER_KEY);
// Create the user attributes.
@@ -2051,7 +2052,7 @@
// Set the entry object classes.
LinkedHashMap<ObjectClass,String> ocMap = new LinkedHashMap<>(2);
- ocMap.put(DirectoryServer.getTopObjectClass(), OC_TOP);
+ ocMap.put(CoreSchema.getTopObjectClass(), OC_TOP);
ocMap.put(ocMacKey, OC_CRYPTO_MAC_KEY);
// Create the user attributes.
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/crypto/CryptoManagerSync.java b/opendj-server-legacy/src/main/java/org/opends/server/crypto/CryptoManagerSync.java
index d2f1fa1..983f297 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/crypto/CryptoManagerSync.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/crypto/CryptoManagerSync.java
@@ -39,6 +39,7 @@
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.SearchScope;
import org.forgerock.opendj.ldap.schema.AttributeType;
+import org.forgerock.opendj.ldap.schema.CoreSchema;
import org.opends.admin.ads.ADSContext;
import org.opends.server.api.Backend;
import org.opends.server.api.BackendInitializationListener;
@@ -373,7 +374,7 @@
private void addEntry(Entry srcEntry, DN dstDN)
{
Map<ObjectClass, String> ocMap = new LinkedHashMap<>(2);
- ocMap.put(DirectoryServer.getTopObjectClass(), OC_TOP);
+ ocMap.put(CoreSchema.getTopObjectClass(), OC_TOP);
ocMap.put(ocInstanceKey, OC_CRYPTO_INSTANCE_KEY);
Map<AttributeType, List<Attribute>> userAttrs = new HashMap<>();
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/protocols/internal/InternalClientConnection.java b/opendj-server-legacy/src/main/java/org/opends/server/protocols/internal/InternalClientConnection.java
index 36bf28d..b1f64a1 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/protocols/internal/InternalClientConnection.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/protocols/internal/InternalClientConnection.java
@@ -44,6 +44,7 @@
import org.forgerock.opendj.ldap.requests.ModifyDNRequest;
import org.forgerock.opendj.ldap.requests.ModifyRequest;
import org.forgerock.opendj.ldap.schema.AttributeType;
+import org.forgerock.opendj.ldap.schema.CoreSchema;
import org.opends.server.api.ClientConnection;
import org.opends.server.api.ConnectionHandler;
import org.opends.server.core.AddOperation;
@@ -152,7 +153,7 @@
try
{
LinkedHashMap<ObjectClass,String> objectClasses = new LinkedHashMap<>();
- put(objectClasses, DirectoryServer.getTopObjectClass());
+ put(objectClasses, CoreSchema.getTopObjectClass());
put(objectClasses, DirectoryServer.getObjectClass(OC_PERSON));
put(objectClasses, DirectoryServer.getObjectClass(OC_ROOT_DN));
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/replication/protocol/AddMsg.java b/opendj-server-legacy/src/main/java/org/opends/server/replication/protocol/AddMsg.java
index baac982..b0bc3df 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/replication/protocol/AddMsg.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/replication/protocol/AddMsg.java
@@ -16,6 +16,9 @@
*/
package org.opends.server.replication.protocol;
+import static org.forgerock.opendj.ldap.schema.CoreSchema.*;
+import static org.opends.server.replication.protocol.OperationContext.*;
+
import java.util.Collection;
import java.util.List;
import java.util.Map;
@@ -27,20 +30,20 @@
import org.forgerock.opendj.ldap.ByteStringBuilder;
import org.forgerock.opendj.ldap.DN;
import org.forgerock.opendj.ldap.DecodeException;
+import org.forgerock.opendj.ldap.schema.AttributeType;
+import org.forgerock.opendj.ldap.schema.ObjectClass;
import org.opends.server.core.AddOperation;
import org.opends.server.core.AddOperationBasis;
-import org.opends.server.core.DirectoryServer;
import org.opends.server.protocols.internal.InternalClientConnection;
import org.opends.server.protocols.ldap.LDAPAttribute;
import org.opends.server.replication.common.CSN;
import org.opends.server.replication.plugin.EntryHistorical;
-import org.forgerock.opendj.ldap.schema.AttributeType;
-import org.forgerock.opendj.ldap.schema.ObjectClass;
-import org.opends.server.types.*;
+import org.opends.server.types.Attribute;
+import org.opends.server.types.AttributeBuilder;
+import org.opends.server.types.LDAPException;
+import org.opends.server.types.RawAttribute;
import org.opends.server.types.operation.PostOperationAddOperation;
-import static org.opends.server.replication.protocol.OperationContext.*;
-
/**
* This class is used to exchange Add operation between LDAP servers
* and replication servers.
@@ -223,8 +226,7 @@
try
{
// Encode the object classes (SET OF LDAPString).
- AttributeBuilder builder = new AttributeBuilder(
- DirectoryServer.getObjectClassAttributeType());
+ AttributeBuilder builder = new AttributeBuilder(getObjectClassAttributeType());
builder.addAllStrings(objectClasses.values());
new LDAPAttribute(builder.toAttribute()).write(writer);
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tools/LDIFDiff.java b/opendj-server-legacy/src/main/java/org/opends/server/tools/LDIFDiff.java
index 629180f..28053e4 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tools/LDIFDiff.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tools/LDIFDiff.java
@@ -16,6 +16,16 @@
*/
package org.opends.server.tools;
+import static com.forgerock.opendj.cli.CommonArguments.*;
+import static com.forgerock.opendj.cli.Utils.*;
+
+import static org.forgerock.opendj.ldap.ModificationType.*;
+import static org.forgerock.opendj.ldap.schema.CoreSchema.*;
+import static org.opends.messages.ToolMessages.*;
+import static org.opends.server.protocols.ldap.LDAPResultCode.*;
+import static org.opends.server.util.CollectionUtils.*;
+import static org.opends.server.util.ServerConstants.*;
+
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
@@ -34,8 +44,8 @@
import org.forgerock.i18n.LocalizedIllegalArgumentException;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.DN;
-import org.forgerock.opendj.ldap.ModificationType;
import org.forgerock.opendj.ldap.schema.AttributeType;
+import org.forgerock.opendj.ldap.schema.ObjectClass;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.DirectoryServer.DirectoryServerVersionHandler;
import org.opends.server.loggers.JDKLogging;
@@ -47,7 +57,6 @@
import org.opends.server.types.LDIFImportConfig;
import org.opends.server.types.Modification;
import org.opends.server.types.NullOutputStream;
-import org.forgerock.opendj.ldap.schema.ObjectClass;
import org.opends.server.util.LDIFReader;
import org.opends.server.util.LDIFWriter;
import org.opends.server.util.StaticUtils;
@@ -57,14 +66,6 @@
import com.forgerock.opendj.cli.BooleanArgument;
import com.forgerock.opendj.cli.StringArgument;
-import static com.forgerock.opendj.cli.Utils.*;
-import static com.forgerock.opendj.cli.CommonArguments.*;
-
-import static org.opends.messages.ToolMessages.*;
-import static org.opends.server.protocols.ldap.LDAPResultCode.*;
-import static org.opends.server.util.CollectionUtils.*;
-import static org.opends.server.util.ServerConstants.*;
-
/**
* This class provides a program that may be used to determine the differences
* between two LDIF files, generating the output in LDIF change format. There
@@ -755,29 +756,13 @@
if (!sourceClasses.isEmpty())
{
// Whatever is left must have been deleted.
- AttributeType attrType = DirectoryServer.getObjectClassAttributeType();
- AttributeBuilder builder = new AttributeBuilder(attrType);
- for (ObjectClass oc : sourceClasses)
- {
- builder.add(oc.getNameOrOID());
- }
-
- modifications.add(new Modification(ModificationType.DELETE, builder
- .toAttribute()));
+ modifications.add(new Modification(DELETE, toObjectClassAttribute(sourceClasses)));
}
if (! targetClasses.isEmpty())
{
// Whatever is left must have been added.
- AttributeType attrType = DirectoryServer.getObjectClassAttributeType();
- AttributeBuilder builder = new AttributeBuilder(attrType);
- for (ObjectClass oc : targetClasses)
- {
- builder.add(oc.getNameOrOID());
- }
-
- modifications.add(new Modification(ModificationType.ADD, builder
- .toAttribute()));
+ modifications.add(new Modification(ADD, toObjectClassAttribute(targetClasses)));
}
@@ -798,7 +783,7 @@
// value individually.
for (Attribute a : sourceAttrs)
{
- modifications.add(new Modification(ModificationType.DELETE, a));
+ modifications.add(new Modification(DELETE, a));
}
}
else
@@ -824,28 +809,22 @@
if (targetAttr == null)
{
- // The attribute doesn't exist in the target list, so it has been
- // deleted.
- modifications.add(new Modification(ModificationType.DELETE,
- sourceAttr));
+ // The attribute doesn't exist in the target list, so it has been deleted.
+ modifications.add(new Modification(DELETE, sourceAttr));
}
else
{
// Compare the values.
- AttributeBuilder addedValuesBuilder = new AttributeBuilder(targetAttr);
- addedValuesBuilder.removeAll(sourceAttr);
- Attribute addedValues = addedValuesBuilder.toAttribute();
+ Attribute addedValues = minusAttribute(targetAttr, sourceAttr);
if (!addedValues.isEmpty())
{
- modifications.add(new Modification(ModificationType.ADD, addedValues));
+ modifications.add(new Modification(ADD, addedValues));
}
- AttributeBuilder deletedValuesBuilder = new AttributeBuilder(sourceAttr);
- deletedValuesBuilder.removeAll(targetAttr);
- Attribute deletedValues = deletedValuesBuilder.toAttribute();
+ Attribute deletedValues = minusAttribute(sourceAttr, targetAttr);
if (!deletedValues.isEmpty())
{
- modifications.add(new Modification(ModificationType.DELETE, deletedValues));
+ modifications.add(new Modification(DELETE, deletedValues));
}
}
}
@@ -854,7 +833,7 @@
// Any remaining target attributes have been added.
for (Attribute targetAttr: targetAttrs)
{
- modifications.add(new Modification(ModificationType.ADD, targetAttr));
+ modifications.add(new Modification(ADD, targetAttr));
}
}
}
@@ -862,10 +841,9 @@
// Any remaining target attribute types have been added.
for (AttributeType type : targetEntry.getUserAttributes().keySet())
{
- List<Attribute> targetAttrs = targetEntry.getUserAttribute(type);
- for (Attribute a : targetAttrs)
+ for (Attribute a : targetEntry.getUserAttribute(type))
{
- modifications.add(new Modification(ModificationType.ADD, a));
+ modifications.add(new Modification(ADD, a));
}
}
@@ -921,4 +899,21 @@
return true;
}
+
+ private static Attribute toObjectClassAttribute(Collection<ObjectClass> objectClasses)
+ {
+ AttributeBuilder builder = new AttributeBuilder(getObjectClassAttributeType());
+ for (ObjectClass oc : objectClasses)
+ {
+ builder.add(oc.getNameOrOID());
+ }
+ return builder.toAttribute();
+ }
+
+ private static Attribute minusAttribute(Attribute sourceAttr, Attribute removeAttr)
+ {
+ AttributeBuilder builder = new AttributeBuilder(sourceAttr);
+ builder.removeAll(removeAttr);
+ return builder.toAttribute();
+ }
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tools/makeldif/Branch.java b/opendj-server-legacy/src/main/java/org/opends/server/tools/makeldif/Branch.java
index ed28d1c..fdd739d 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tools/makeldif/Branch.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tools/makeldif/Branch.java
@@ -28,7 +28,7 @@
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.DN;
import org.forgerock.opendj.ldap.schema.AttributeType;
-import org.opends.server.core.DirectoryServer;
+import org.forgerock.opendj.ldap.schema.CoreSchema;
import org.opends.server.types.Attribute;
import org.opends.server.types.Entry;
@@ -110,13 +110,9 @@
String[] valueStrings = new String[] { ocName };
Tag[] tags = new Tag[1];
tags[0] = new StaticTextTag();
- tags[0].initializeForBranch(templateFile, this, valueStrings, 0,
- warnings);
+ tags[0].initializeForBranch(templateFile, this, valueStrings, 0, warnings);
- TemplateLine l =
- new TemplateLine(DirectoryServer.getObjectClassAttributeType(), 0,
- tags);
- lineList.add(l);
+ lineList.add(new TemplateLine(CoreSchema.getObjectClassAttributeType(), 0, tags));
}
catch (Exception e)
{
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 387944d..6a34ada 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
@@ -46,6 +46,7 @@
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.SearchScope;
import org.forgerock.opendj.ldap.schema.AttributeType;
+import org.forgerock.opendj.ldap.schema.CoreSchema;
import org.forgerock.opendj.ldap.schema.DITContentRule;
import org.forgerock.opendj.ldap.schema.DITStructureRule;
import org.forgerock.opendj.ldap.schema.MatchingRule;
@@ -370,7 +371,7 @@
if(objectClassAttribute == null)
{
- AttributeBuilder builder = new AttributeBuilder(DirectoryServer.getObjectClassAttributeType());
+ AttributeBuilder builder = new AttributeBuilder(CoreSchema.getObjectClassAttributeType());
builder.addAllStrings(objectClasses.values());
objectClassAttribute = builder.toAttribute();
}
@@ -4261,7 +4262,7 @@
public Entry filterEntry(Set<String> attrNameList,
boolean omitValues, boolean omitReal, boolean omitVirtual)
{
- final AttributeType ocType = DirectoryServer.getObjectClassAttributeType();
+ final AttributeType ocType = CoreSchema.getObjectClassAttributeType();
Map<ObjectClass, String> objectClassesCopy;
Map<AttributeType, List<Attribute>> userAttrsCopy;
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/types/LDAPURL.java b/opendj-server-legacy/src/main/java/org/opends/server/types/LDAPURL.java
index 84f95a0..8b4c50a 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/types/LDAPURL.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/types/LDAPURL.java
@@ -29,7 +29,7 @@
import org.forgerock.opendj.ldap.DN;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.SearchScope;
-import org.opends.server.core.DirectoryServer;
+import org.forgerock.opendj.ldap.schema.CoreSchema;
import static org.forgerock.opendj.ldap.ResultCode.*;
import static org.opends.messages.UtilityMessages.*;
@@ -62,8 +62,7 @@
SearchScope.BASE_OBJECT;
/** The default search filter that will be used if none is provided. */
public static final SearchFilter DEFAULT_SEARCH_FILTER =
- SearchFilter.createPresenceFilter(
- DirectoryServer.getObjectClassAttributeType());
+ SearchFilter.createPresenceFilter(CoreSchema.getObjectClassAttributeType());
/** The host for this LDAP URL. */
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 ac07c9c..d7e826e 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
@@ -45,6 +45,7 @@
import org.forgerock.opendj.ldap.ModificationType;
import org.forgerock.opendj.ldap.RDN;
import org.forgerock.opendj.ldap.schema.AttributeType;
+import org.forgerock.opendj.ldap.schema.CoreSchema;
import org.opends.server.api.plugin.PluginResult;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.PluginConfigManager;
@@ -1313,7 +1314,7 @@
}
// Reconstruct the object class attribute.
- AttributeType ocType = DirectoryServer.getObjectClassAttributeType();
+ AttributeType ocType = CoreSchema.getObjectClassAttributeType();
AttributeBuilder builder = new AttributeBuilder(ocType);
builder.addAllStrings(objectClasses.values());
Map<AttributeType, List<Attribute>> attributes = toAttributesMap(attrBuilders);
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 c91329c..7bbb3cf 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
@@ -57,6 +57,7 @@
import org.forgerock.opendj.ldap.DN;
import org.forgerock.opendj.ldap.RDN;
import org.forgerock.opendj.ldap.schema.AttributeType;
+import org.forgerock.opendj.ldap.schema.CoreSchema;
import org.forgerock.util.Reject;
import org.opends.messages.ToolMessages;
import org.opends.server.core.DirectoryServer;
@@ -1952,8 +1953,7 @@
// Get the top and untypedObject classes to include in the entry.
LinkedHashMap<ObjectClass,String> objectClasses = new LinkedHashMap<>(3);
-
- objectClasses.put(DirectoryServer.getTopObjectClass(), OC_TOP);
+ objectClasses.put(CoreSchema.getTopObjectClass(), OC_TOP);
objectClasses.put(structuralClass, structuralClass.getNameOrOID());
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 89e304a..c3cc9a6 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
@@ -35,6 +35,7 @@
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.requests.AddRequest;
import org.forgerock.opendj.ldap.schema.AttributeType;
+import org.forgerock.opendj.ldap.schema.CoreSchema;
import org.forgerock.opendj.ldap.schema.ObjectClass;
import org.opends.server.TestCaseUtils;
import org.opends.server.api.Backend;
@@ -845,7 +846,7 @@
retrieveCompletedOperationElements(addOperation);
Entry e = DirectoryServer.getEntry(DN.valueOf("uid=test.user,o=test"));
- List<Attribute> attrList = e.getAttribute(DirectoryServer.getObjectClassAttributeType());
+ List<Attribute> attrList = e.getAttribute(CoreSchema.getObjectClassAttributeType());
assertTrue(findAttributeValueIgnoreCase(attrList, "top"));
}
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 4d54a6a..5e884d3 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
@@ -16,6 +16,19 @@
*/
package org.opends.server.core;
+import static org.assertj.core.api.Assertions.*;
+import static org.forgerock.opendj.ldap.ModificationType.*;
+import static org.forgerock.opendj.ldap.controls.GenericControl.*;
+import static org.forgerock.opendj.ldap.requests.Requests.*;
+import static org.forgerock.opendj.ldap.schema.CoreSchema.*;
+import static org.opends.server.TestCaseUtils.*;
+import static org.opends.server.protocols.internal.InternalClientConnection.*;
+import static org.opends.server.protocols.internal.Requests.newSearchRequest;
+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.*;
+
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -62,18 +75,6 @@
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
-import static org.assertj.core.api.Assertions.*;
-import static org.forgerock.opendj.ldap.ModificationType.*;
-import static org.forgerock.opendj.ldap.controls.GenericControl.*;
-import static org.forgerock.opendj.ldap.requests.Requests.*;
-import static org.opends.server.TestCaseUtils.*;
-import static org.opends.server.protocols.internal.InternalClientConnection.*;
-import static org.opends.server.protocols.internal.Requests.*;
-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.*;
-
/**
* A set of test cases for modify operations.
*/
@@ -2159,11 +2160,11 @@
retrieveSuccessfulOperationElements(modifyOperation);
Entry e = DirectoryServer.getEntry(DN.valueOf("uid=test.user," + baseDN));
- assertTrue(e.hasObjectClass(DirectoryServer.getObjectClass("extensibleobject")));
+ assertTrue(e.hasObjectClass(getExtensibleObjectObjectClass()));
assertTrue(e.hasObjectClass(DirectoryServer.getObjectClass("inetOrgPerson")));
- assertTrue(e.hasObjectClass(DirectoryServer.getObjectClass("organizationalPerson")));
- assertTrue(e.hasObjectClass(DirectoryServer.getObjectClass("person")));
- assertTrue(e.hasObjectClass(DirectoryServer.getObjectClass("top")));
+ assertTrue(e.hasObjectClass(getOrganizationalPersonObjectClass()));
+ assertTrue(e.hasObjectClass(getPersonObjectClass()));
+ assertTrue(e.hasObjectClass(getTopObjectClass()));
assertEquals(e.getUserAttributes().size(), 8, "Incorrect number of user attributes");
}
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/core/SubtreeSpecificationTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/core/SubtreeSpecificationTestCase.java
index fb388e4..574d845 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/core/SubtreeSpecificationTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/core/SubtreeSpecificationTestCase.java
@@ -16,19 +16,19 @@
*/
package org.opends.server.core;
+import static org.forgerock.opendj.ldap.schema.CoreSchema.*;
+import static org.opends.server.util.CollectionUtils.*;
+
import java.util.HashMap;
-import java.util.HashSet;
import java.util.Set;
-import org.opends.server.TestCaseUtils;
import org.forgerock.opendj.ldap.DN;
-import org.opends.server.types.Entry;
import org.forgerock.opendj.ldap.schema.ObjectClass;
+import org.opends.server.TestCaseUtils;
+import org.opends.server.types.Entry;
import org.testng.annotations.BeforeClass;
-/**
- * An abstract base class for all subtree specification tests.
- */
+/** An abstract base class for all subtree specification tests. */
public abstract class SubtreeSpecificationTestCase extends CoreTestCase {
/** Cached set of entry object classes. */
private Set<ObjectClass> objectClasses;
@@ -43,8 +43,8 @@
* The entry's object classes.
* @return The created entry.
*/
- protected final Entry createEntry(DN entryDN,
- Set<ObjectClass> objectClasses) {
+ protected final Entry createEntry(DN entryDN, Set<ObjectClass> objectClasses)
+ {
HashMap<ObjectClass, String> map = new HashMap<>();
for (ObjectClass oc : objectClasses) {
@@ -67,20 +67,7 @@
// This test suite depends on having the schema available, so we'll start the server.
TestCaseUtils.startServer();
- // Retrieve required object classes.
- objectClasses = new HashSet<>();
-
- ObjectClass oc = DirectoryServer.getObjectClass("top");
- if (oc.isPlaceHolder()) {
- throw new RuntimeException("Unable to resolve object class top");
- }
- objectClasses.add(oc);
-
- oc = DirectoryServer.getObjectClass("person");
- if (oc.isPlaceHolder()) {
- throw new RuntimeException("Unable to resolve object class person");
- }
- objectClasses.add(oc);
+ objectClasses = newHashSet(getTopObjectClass(), getPersonObjectClass());
}
/**
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/replication/protocol/ProtocolCompatibilityTest.java b/opendj-server-legacy/src/test/java/org/opends/server/replication/protocol/ProtocolCompatibilityTest.java
index 863ebe0..ff4f6ba 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/replication/protocol/ProtocolCompatibilityTest.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/replication/protocol/ProtocolCompatibilityTest.java
@@ -16,9 +16,18 @@
*/
package org.opends.server.replication.protocol;
+import static org.assertj.core.api.Assertions.*;
+import static org.forgerock.opendj.ldap.schema.CoreSchema.*;
+import static org.opends.messages.ReplicationMessages.*;
+import static org.opends.server.replication.common.AssuredMode.*;
+import static org.opends.server.replication.protocol.OperationContext.*;
+import static org.opends.server.replication.protocol.ProtocolVersion.*;
+import static org.opends.server.util.CollectionUtils.*;
+import static org.opends.server.util.StaticUtils.*;
+import static org.testng.Assert.*;
+
import java.math.BigInteger;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -44,7 +53,6 @@
import org.opends.server.types.Attributes;
import org.opends.server.types.LDAPException;
import org.opends.server.types.Modification;
-import org.forgerock.opendj.ldap.schema.ObjectClass;
import org.opends.server.types.Operation;
import org.opends.server.types.RawAttribute;
import org.opends.server.util.TimeThread;
@@ -53,15 +61,6 @@
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
-import static org.assertj.core.api.Assertions.*;
-import static org.opends.messages.ReplicationMessages.*;
-import static org.opends.server.replication.common.AssuredMode.*;
-import static org.opends.server.replication.protocol.OperationContext.*;
-import static org.opends.server.replication.protocol.ProtocolVersion.*;
-import static org.opends.server.util.CollectionUtils.*;
-import static org.opends.server.util.StaticUtils.*;
-import static org.testng.Assert.*;
-
/**
* Test the conversions between the various protocol versions.
*/
@@ -197,22 +196,9 @@
final DN dn = DN.valueOf(rawDN);
// Create VLAST message
- Attribute objectClass = Attributes.create(DirectoryServer
- .getObjectClassAttributeType(), "organization");
- HashMap<ObjectClass, String> objectClassList = new HashMap<>();
- objectClassList.put(DirectoryServer.getObjectClass("organization"),
- "organization");
-
- Attribute attr = Attributes.create("o", "com");
- List<Attribute> userAttributes = newArrayList(attr);
- HashMap<AttributeType, List<Attribute>> userAttList = new HashMap<>();
- userAttList.put(attr.getAttributeDescription().getAttributeType(), userAttributes);
-
-
- attr = Attributes.create("creatorsName", "dc=creator");
- List<Attribute> operationalAttributes = newArrayList(attr);
- HashMap<AttributeType, List<Attribute>> opList = new HashMap<>();
- opList.put(attr.getAttributeDescription().getAttributeType(), operationalAttributes);
+ Attribute objectClass = Attributes.create(getObjectClassAttributeType(), "organization");
+ List<Attribute> userAttributes = newArrayList(Attributes.create("o", "com"));
+ List<Attribute> operationalAttributes = newArrayList(Attributes.create("creatorsName", "dc=creator"));
CSN csn = new CSN(TimeThread.getTime(), 123, 45);
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/replication/protocol/SynchronizationMsgTest.java b/opendj-server-legacy/src/test/java/org/opends/server/replication/protocol/SynchronizationMsgTest.java
index 99ef5ae..96dee00 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/replication/protocol/SynchronizationMsgTest.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/replication/protocol/SynchronizationMsgTest.java
@@ -16,6 +16,17 @@
*/
package org.opends.server.replication.protocol;
+import static org.forgerock.opendj.ldap.requests.Requests.*;
+import static org.forgerock.opendj.ldap.schema.CoreSchema.*;
+import static org.opends.server.TestCaseUtils.*;
+import static org.opends.server.protocols.internal.InternalClientConnection.*;
+import static org.opends.server.replication.common.AssuredMode.*;
+import static org.opends.server.replication.protocol.OperationContext.*;
+import static org.opends.server.replication.protocol.ProtocolVersion.*;
+import static org.opends.server.util.CollectionUtils.*;
+import static org.opends.server.util.StaticUtils.*;
+import static org.testng.Assert.*;
+
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -30,6 +41,7 @@
import org.forgerock.opendj.ldap.ModificationType;
import org.forgerock.opendj.ldap.requests.ModifyDNRequest;
import org.forgerock.opendj.ldap.schema.AttributeType;
+import org.forgerock.opendj.ldap.schema.ObjectClass;
import org.opends.server.controls.SubtreeDeleteControl;
import org.opends.server.core.AddOperation;
import org.opends.server.core.AddOperationBasis;
@@ -52,7 +64,6 @@
import org.opends.server.types.Attributes;
import org.opends.server.types.LDAPException;
import org.opends.server.types.Modification;
-import org.forgerock.opendj.ldap.schema.ObjectClass;
import org.opends.server.types.RawAttribute;
import org.opends.server.util.TimeThread;
import org.opends.server.workflowelement.localbackend.LocalBackendAddOperation;
@@ -63,16 +74,6 @@
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
-import static org.forgerock.opendj.ldap.requests.Requests.*;
-import static org.opends.server.TestCaseUtils.*;
-import static org.opends.server.protocols.internal.InternalClientConnection.*;
-import static org.opends.server.replication.common.AssuredMode.*;
-import static org.opends.server.replication.protocol.OperationContext.*;
-import static org.opends.server.replication.protocol.ProtocolVersion.*;
-import static org.opends.server.util.CollectionUtils.*;
-import static org.opends.server.util.StaticUtils.*;
-import static org.testng.Assert.*;
-
/**
* Test the constructors, encoders and decoders of the replication protocol
* PDUs classes (message classes).
@@ -454,21 +455,18 @@
{
final DN dn = DN.valueOf(rawDN);
- Attribute objectClass = Attributes.create(DirectoryServer
- .getObjectClassAttributeType(), "organization");
+ Attribute objectClass = Attributes.create(getObjectClassAttributeType(), "organization");
Map<ObjectClass, String> objectClassList = new HashMap<>();
- objectClassList.put(DirectoryServer.getObjectClass("organization"), "organization");
+ objectClassList.put(getOrganizationObjectClass(), "organization");
Attribute attr = Attributes.create("o", "com");
List<Attribute> userAttributes = newArrayList(attr);
- Map<AttributeType, List<Attribute>> userAttList = new HashMap<>();
- userAttList.put(attr.getAttributeDescription().getAttributeType(), userAttributes);
+ Map<AttributeType, List<Attribute>> userAttList = addAttribute(attr, userAttributes);
attr = Attributes.create("creatorsname", "dc=creator");
List<Attribute> operationalAttributes = newArrayList(attr);
- Map<AttributeType, List<Attribute>> opList = new HashMap<>();
- opList.put(attr.getAttributeDescription().getAttributeType(), operationalAttributes);
+ Map<AttributeType, List<Attribute>> opList = addAttribute(attr, operationalAttributes);
CSN csn = new CSN(TimeThread.getTime(), 123, 45);
@@ -541,6 +539,13 @@
assertEquals(msg.getCSN(), updateMsg.getCSN());
}
+ private Map<AttributeType, List<Attribute>> addAttribute(Attribute attr, List<Attribute> userAttributes)
+ {
+ Map<AttributeType, List<Attribute>> userAttList = new HashMap<>();
+ userAttList.put(attr.getAttributeDescription().getAttributeType(), userAttributes);
+ return userAttList;
+ }
+
private void assertAttributesEqual(List<RawAttribute> actualAttrs,
List<Attribute> expectedAttrs) throws LDAPException
{
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/types/TestEntry.java b/opendj-server-legacy/src/test/java/org/opends/server/types/TestEntry.java
index 40baa9b..26f31eb 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/types/TestEntry.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/types/TestEntry.java
@@ -17,6 +17,7 @@
package org.opends.server.types;
import static org.assertj.core.api.Assertions.*;
+import static org.forgerock.opendj.ldap.schema.CoreSchema.*;
import static org.opends.server.util.CollectionUtils.*;
import static org.testng.Assert.*;
@@ -33,6 +34,7 @@
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.DN;
import org.forgerock.opendj.ldap.schema.AttributeType;
+import org.forgerock.opendj.ldap.schema.CoreSchema;
import org.forgerock.opendj.ldap.schema.ObjectClass;
import org.opends.server.TestCaseUtils;
import org.opends.server.core.DirectoryServer;
@@ -75,13 +77,8 @@
DN entryDN = DN.valueOf("dc=example, dc=com");
// Get default object classes.
- ObjectClass top = DirectoryServer.getTopObjectClass();
- ObjectClass extensible = DirectoryServer.getObjectClass("extensibleobject");
- if (extensible.isPlaceHolder()) {
- throw new RuntimeException(
- "Unable to resolve object class extensibleObject");
- }
-
+ ObjectClass top = CoreSchema.getTopObjectClass();
+ ObjectClass extensible = CoreSchema.getExtensibleObjectObjectClass();
HashMap<ObjectClass, String> objectClasses = new HashMap<>();
objectClasses.put(top, top.getNameOrOID());
objectClasses.put(extensible, extensible.getNameOrOID());
@@ -113,7 +110,7 @@
*/
@Test
public void testParseAttributeNotFound() throws Exception {
- AttributeType type1 = DirectoryServer.getAttributeType("description");
+ AttributeType type1 = getDescriptionAttributeType();
AttributeType type2 = DirectoryServer.getAttributeType("inheritable");
Entry entry = createTestEntry(type1, "hello world");
@@ -169,17 +166,16 @@
@Test
public void testParseAttributesInteger() throws Exception
{
- AttributeType type = DirectoryServer.getAttributeType("supportedldapversion");
+ AttributeType type = getSupportedLDAPVersionAttributeType();
String[] values = new String[] { "-4", "-2", "0", "1", "3" };
- HashSet<Integer> expected = new HashSet<>();
+ HashSet<Integer> expected = newHashSet();
for (String value : values) {
expected.add(Integer.valueOf(value));
}
Entry entry = createTestEntry(type, values);
- Set<Integer> result =
- entry.parseAttribute("supportedldapversion").asSetOfInteger();
+ Set<Integer> result = entry.parseAttribute("supportedldapversion").asSetOfInteger();
Assertions.assertThat(result).isEqualTo(expected);
}
@@ -192,7 +188,7 @@
@Test(expectedExceptions = LocalizedIllegalArgumentException.class)
public void testParseAttributeIntegerBad() throws Exception
{
- AttributeType type = DirectoryServer.getAttributeType("supportedldapversion");
+ AttributeType type = getSupportedLDAPVersionAttributeType();
String[] values = new String[] { "-4", "-2", "xxx", "1", "3" };
Entry entry = createTestEntry(type, values);
@@ -272,11 +268,11 @@
assertTrue(e.conformsToSchema(null, false, false, false,
new LocalizableMessageBuilder()));
- AttributeType ocType = DirectoryServer.getAttributeType("objectclass");
- AttributeType cnType = DirectoryServer.getAttributeType("cn");
- AttributeType nameType = DirectoryServer.getAttributeType("name");
- AttributeType uidType = DirectoryServer.getAttributeType("uid");
- AttributeType mnType = DirectoryServer.getAttributeType("modifiersname");
+ AttributeType ocType = getObjectClassAttributeType();
+ AttributeType cnType = getCNAttributeType();
+ AttributeType nameType = getNameAttributeType();
+ AttributeType uidType = getUIDAttributeType();
+ AttributeType mnType = getModifiersNameAttributeType();
assertTrue(e.hasAttribute(ocType));
assertTrue(e.hasAttribute(cnType));
@@ -360,11 +356,11 @@
assertTrue(e.conformsToSchema(null, false, false, false,
new LocalizableMessageBuilder()));
- AttributeType ocType = DirectoryServer.getAttributeType("objectclass");
- AttributeType cnType = DirectoryServer.getAttributeType("cn");
- AttributeType nameType = DirectoryServer.getAttributeType("name");
- AttributeType uidType = DirectoryServer.getAttributeType("uid");
- AttributeType mnType = DirectoryServer.getAttributeType("modifiersname");
+ AttributeType ocType = getObjectClassAttributeType();
+ AttributeType cnType = getCNAttributeType();
+ AttributeType nameType = getNameAttributeType();
+ AttributeType uidType = getUIDAttributeType();
+ AttributeType mnType = getModifiersNameAttributeType();
assertFalse(e.hasUserAttribute(ocType));
assertTrue(e.hasUserAttribute(cnType));
@@ -406,11 +402,11 @@
assertTrue(e.conformsToSchema(null, false, false, false,
new LocalizableMessageBuilder()));
- AttributeType ocType = DirectoryServer.getAttributeType("objectclass");
- AttributeType cnType = DirectoryServer.getAttributeType("cn");
- AttributeType nameType = DirectoryServer.getAttributeType("name");
- AttributeType uidType = DirectoryServer.getAttributeType("uid");
- AttributeType mnType = DirectoryServer.getAttributeType("modifiersname");
+ AttributeType ocType = getObjectClassAttributeType();
+ AttributeType cnType = getCNAttributeType();
+ AttributeType nameType = getNameAttributeType();
+ AttributeType uidType = getUIDAttributeType();
+ AttributeType mnType = getModifiersNameAttributeType();
assertFalse(e.hasOperationalAttribute(ocType));
assertFalse(e.hasOperationalAttribute(cnType));
@@ -452,11 +448,11 @@
assertTrue(e.conformsToSchema(null, false, false, false,
new LocalizableMessageBuilder()));
- AttributeType ocType = DirectoryServer.getAttributeType("objectclass");
- AttributeType cnType = DirectoryServer.getAttributeType("cn");
- AttributeType nameType = DirectoryServer.getAttributeType("name");
- AttributeType uidType = DirectoryServer.getAttributeType("uid");
- AttributeType mnType = DirectoryServer.getAttributeType("modifiersname");
+ AttributeType ocType = getObjectClassAttributeType();
+ AttributeType cnType = getCNAttributeType();
+ AttributeType nameType = getNameAttributeType();
+ AttributeType uidType = getUIDAttributeType();
+ AttributeType mnType = getModifiersNameAttributeType();
assertThat(e.getAttribute(ocType)).hasSize(1);
assertThat(e.getAttribute(cnType)).hasSize(2);
@@ -543,11 +539,11 @@
assertTrue(e.conformsToSchema(null, false, false, false,
new LocalizableMessageBuilder()));
- AttributeType ocType = DirectoryServer.getAttributeType("objectclass");
- AttributeType cnType = DirectoryServer.getAttributeType("cn");
- AttributeType nameType = DirectoryServer.getAttributeType("name");
- AttributeType uidType = DirectoryServer.getAttributeType("uid");
- AttributeType mnType = DirectoryServer.getAttributeType("modifiersname");
+ AttributeType ocType = getObjectClassAttributeType();
+ AttributeType cnType = getCNAttributeType();
+ AttributeType nameType = getNameAttributeType();
+ AttributeType uidType = getUIDAttributeType();
+ AttributeType mnType = getModifiersNameAttributeType();
assertThat(e.getUserAttribute(ocType)).isEmpty();
assertThat(e.getUserAttribute(cnType)).hasSize(2);
@@ -589,11 +585,11 @@
assertTrue(e.conformsToSchema(null, false, false, false,
new LocalizableMessageBuilder()));
- AttributeType ocType = DirectoryServer.getAttributeType("objectclass");
- AttributeType cnType = DirectoryServer.getAttributeType("cn");
- AttributeType nameType = DirectoryServer.getAttributeType("name");
- AttributeType uidType = DirectoryServer.getAttributeType("uid");
- AttributeType mnType = DirectoryServer.getAttributeType("modifiersname");
+ AttributeType ocType = getObjectClassAttributeType();
+ AttributeType cnType = getCNAttributeType();
+ AttributeType nameType = getNameAttributeType();
+ AttributeType uidType = getUIDAttributeType();
+ AttributeType mnType = getModifiersNameAttributeType();
assertThat(e.getOperationalAttribute(ocType)).isEmpty();
assertThat(e.getOperationalAttribute(cnType)).isEmpty();
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/util/TestLDIFReader.java b/opendj-server-legacy/src/test/java/org/opends/server/util/TestLDIFReader.java
index 87b9f49..4b7a63a 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/util/TestLDIFReader.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/util/TestLDIFReader.java
@@ -16,6 +16,8 @@
*/
package org.opends.server.util;
+import static org.forgerock.opendj.ldap.schema.CoreSchema.*;
+
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileOutputStream;
@@ -26,19 +28,17 @@
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.opendj.ldap.ByteString;
+import org.forgerock.opendj.ldap.DN;
import org.forgerock.opendj.ldap.ModificationType;
-import org.forgerock.opendj.ldap.schema.AttributeType;
+import org.forgerock.opendj.ldap.RDN;
import org.opends.server.TestCaseUtils;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeBuilder;
import org.opends.server.types.Attributes;
-import org.forgerock.opendj.ldap.DN;
import org.opends.server.types.Entry;
import org.opends.server.types.LDIFImportConfig;
import org.opends.server.types.Modification;
-import org.forgerock.opendj.ldap.schema.ObjectClass;
-import org.forgerock.opendj.ldap.RDN;
import org.opends.server.types.RawModification;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
@@ -51,22 +51,6 @@
* {@link org.opends.server.util.LDIFReader} class.
*/
public final class TestLDIFReader extends UtilTestCase {
- /** Top object class. */
- private ObjectClass OC_TOP;
- /** Person object class. */
- private ObjectClass OC_PERSON;
-
- /** Object class attribute type. */
- private AttributeType AT_OC;
- /** Common name attribute type. */
- private AttributeType AT_CN;
- /** Surname attribute type. */
- private AttributeType AT_SN;
- /** Description attribute type. */
- private AttributeType AT_DESCR;
- /** Telephone number attribute type. */
- private AttributeType AT_TELN;
-
/** Temporary file containing an attribute value. */
private File TEMP_FILE;
@@ -167,20 +151,8 @@
*/
@BeforeClass
public void setUp() throws Exception {
- // This test suite depends on having the schema available, so we'll
- // start the server.
TestCaseUtils.startServer();
- // Initialize schema bits.
- OC_TOP = DirectoryServer.getTopObjectClass();
- OC_PERSON = DirectoryServer.getObjectClass("person");
-
- AT_OC = DirectoryServer.getObjectClassAttributeType();
- AT_CN = DirectoryServer.getAttributeType("cn");
- AT_SN = DirectoryServer.getAttributeType("sn");
- AT_DESCR = DirectoryServer.getAttributeType("description");
- AT_TELN = DirectoryServer.getAttributeType("telephonenumber");
-
// Create a temporary file containing an attribute value.
TEMP_FILE = File.createTempFile("tmp", "txt");
try (OutputStream out = new FileOutputStream(TEMP_FILE)) {
@@ -283,19 +255,24 @@
*/
@Test(dependsOnMethods = { "testReadEntryEmptyStream" })
public void testReadEntrySingle() throws Exception {
- final String ldifString = "dn: cn=john, dc=foo, dc=com\n"
- + "objectClass: top\n" + "objectClass: person\n" + "cn: john\n"
+ // @formatter:off
+ final String ldifString =
+ "dn: cn=john, dc=foo, dc=com\n"
+ + "objectClass: top\n"
+ + "objectClass: person\n"
+ + "cn: john\n"
+ "sn: smith\n";
+ // @formatter:on
try (LDIFReader reader = createLDIFReader(ldifString)) {
Entry entry = reader.readEntry();
Assert.assertNotNull(entry);
Assert.assertEquals(entry.getName(), DN.valueOf("cn=john, dc=foo, dc=com"));
- Assert.assertTrue(entry.hasObjectClass(OC_TOP));
- Assert.assertTrue(entry.hasObjectClass(OC_PERSON));
- Assert.assertTrue(entry.hasValue(AT_CN, ByteString.valueOfUtf8("john")));
- Assert.assertTrue(entry.hasValue(AT_SN, ByteString.valueOfUtf8("smith")));
+ Assert.assertTrue(entry.hasObjectClass(getTopObjectClass()));
+ Assert.assertTrue(entry.hasObjectClass(getPersonObjectClass()));
+ Assert.assertTrue(entry.hasValue(getCNAttributeType(), ByteString.valueOfUtf8("john")));
+ Assert.assertTrue(entry.hasValue(getSNAttributeType(), ByteString.valueOfUtf8("smith")));
Assert.assertNull(reader.readEntry());
@@ -322,7 +299,7 @@
try (LDIFReader reader = createLDIFReader(ldifString)) {
Entry entry = reader.readEntry();
Assert.assertNotNull(entry);
- Assert.assertTrue(entry.hasValue(AT_DESCR, ByteString.valueOfUtf8("once upon a time in the west")));
+ Assert.assertTrue(entry.hasValue(getDescriptionAttributeType(), ByteString.valueOfUtf8("once upon a time in the west")));
}
}
@@ -342,7 +319,7 @@
try (LDIFReader reader = createLDIFReader(ldifString)) {
Entry entry = reader.readEntry();
Assert.assertNotNull(entry);
- Assert.assertTrue(entry.hasValue(AT_DESCR, ByteString.valueOfUtf8("once upon a time in the west")));
+ Assert.assertTrue(entry.hasValue(getDescriptionAttributeType(), ByteString.valueOfUtf8("once upon a time in the west")));
}
}
@@ -354,11 +331,21 @@
*/
@Test(dependsOnMethods = { "testReadEntrySingle" })
public void testReadEntryMultiple() throws Exception {
- final String ldifString = "dn: cn=john, dc=foo, dc=com\n"
- + "objectClass: top\n" + "objectClass: person\n" + "cn: john\n"
- + "sn: smith\n" + "\n" + "dn: cn=anne, dc=foo, dc=com\n"
- + "objectClass: top\n" + "objectClass: person\n" + "cn: anne\n"
- + "sn: other\n" + "\n";
+ // @formatter:off
+ final String ldifString =
+ "dn: cn=john, dc=foo, dc=com\n"
+ + "objectClass: top\n"
+ + "objectClass: person\n"
+ + "cn: john\n"
+ + "sn: smith\n"
+ + "\n"
+ + "dn: cn=anne, dc=foo, dc=com\n"
+ + "objectClass: top\n"
+ + "objectClass: person\n"
+ + "cn: anne\n"
+ + "sn: other\n"
+ + "\n";
+ // @formatter:on
try (LDIFReader reader = createLDIFReader(ldifString)) {
reader.readEntry();
@@ -367,10 +354,10 @@
Assert.assertNotNull(entry);
Assert.assertEquals(entry.getName(), DN.valueOf("cn=anne, dc=foo, dc=com"));
- Assert.assertTrue(entry.hasObjectClass(OC_TOP));
- Assert.assertTrue(entry.hasObjectClass(OC_PERSON));
- Assert.assertTrue(entry.hasValue(AT_CN, ByteString.valueOfUtf8("anne")));
- Assert.assertTrue(entry.hasValue(AT_SN, ByteString.valueOfUtf8("other")));
+ Assert.assertTrue(entry.hasObjectClass(getTopObjectClass()));
+ Assert.assertTrue(entry.hasObjectClass(getPersonObjectClass()));
+ Assert.assertTrue(entry.hasValue(getCNAttributeType(), ByteString.valueOfUtf8("anne")));
+ Assert.assertTrue(entry.hasValue(getSNAttributeType(), ByteString.valueOfUtf8("other")));
Assert.assertNull(reader.readEntry());
@@ -410,7 +397,7 @@
Assert.assertEquals(add.getDN(), dn);
List<Attribute> attrs = new ArrayList<>();
- AttributeBuilder builder = new AttributeBuilder(AT_OC);
+ AttributeBuilder builder = new AttributeBuilder(getObjectClassAttributeType());
builder.add("top");
builder.add("person");
builder.add("organizationalPerson");
@@ -481,14 +468,14 @@
mod = i.next().toModification();
Assert.assertEquals(mod.getModificationType(),
ModificationType.DELETE);
- attr = Attributes.empty(AT_DESCR);
+ attr = Attributes.empty(getDescriptionAttributeType());
Assert.assertEquals(mod.getAttribute(), attr);
Assert.assertTrue(i.hasNext());
mod = i.next().toModification();
Assert.assertEquals(mod.getModificationType(),
ModificationType.REPLACE);
- builder = new AttributeBuilder(AT_TELN);
+ builder = new AttributeBuilder(getTelephoneNumberAttributeType());
builder.add("+1 408 555 1234");
builder.add("+1 408 555 5678");
Assert.assertEquals(mod.getAttribute(), builder.toAttribute());
@@ -531,7 +518,7 @@
mod = i.next().toModification();
Assert.assertEquals(mod.getModificationType(),
ModificationType.DELETE);
- attr = Attributes.empty(AT_DESCR);
+ attr = Attributes.empty(getDescriptionAttributeType());
Assert.assertEquals(mod.getAttribute(), attr);
// Change record #8.
@@ -548,7 +535,7 @@
mod = i.next().toModification();
Assert.assertEquals(mod.getModificationType(),
ModificationType.DELETE);
- attr = Attributes.empty(AT_DESCR);
+ attr = Attributes.empty(getDescriptionAttributeType());
Assert.assertEquals(mod.getAttribute(), attr);
Assert.assertFalse(i.hasNext());
--
Gitblit v1.10.0