From 92dc4718cdde8ca11939ee21c7dfc199dcab2fbe Mon Sep 17 00:00:00 2001
From: Jean-Noël Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Mon, 08 Feb 2016 13:15:22 +0000
Subject: [PATCH] AttributeType to AttributeDescription in CompareOperationBasis
---
opendj-server-legacy/src/main/java/org/opends/server/protocols/internal/InternalClientConnection.java | 156 +++++++++++-------------------
opendj-server-legacy/src/test/java/org/opends/server/protocols/internal/InternalClientConnectionTestCase.java | 46 +--------
opendj-server-legacy/src/test/java/org/opends/server/protocols/jmx/JmxPrivilegeTestCase.java | 5
opendj-server-legacy/src/main/java/org/opends/server/core/CompareOperationBasis.java | 22 ---
opendj-server-legacy/src/test/java/org/opends/server/types/PrivilegeTestCase.java | 13 +-
5 files changed, 75 insertions(+), 167 deletions(-)
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/core/CompareOperationBasis.java b/opendj-server-legacy/src/main/java/org/opends/server/core/CompareOperationBasis.java
index 623ea50..2d4c355 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/core/CompareOperationBasis.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/core/CompareOperationBasis.java
@@ -35,7 +35,6 @@
import org.forgerock.opendj.ldap.AttributeDescription;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ResultCode;
-import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.api.ClientConnection;
import org.opends.server.types.AbstractOperation;
import org.opends.server.types.CancelResult;
@@ -138,37 +137,35 @@
* operation is associated.
* @param requestControls The set of controls included in the request.
* @param entryDN The entry DN for this compare operation.
- * @param attributeType The attribute type for this compare operation.
+ * @param attributeDescription The attribute description for this compare operation.
* @param assertionValue The assertion value for the compare operation.
*/
public CompareOperationBasis(
ClientConnection clientConnection, long operationID,
int messageID, List<Control> requestControls,
- DN entryDN, AttributeType attributeType,
+ DN entryDN, AttributeDescription attributeDescription,
ByteString assertionValue)
{
super(clientConnection, operationID, messageID, requestControls);
this.entryDN = entryDN;
- this.attributeDescription = AttributeDescription.create(attributeType);
+ this.attributeDescription = attributeDescription;
this.assertionValue = assertionValue;
responseControls = new ArrayList<>();
rawEntryDN = ByteString.valueOfUtf8(entryDN.toString());
- rawAttributeType = attributeType.getNameOrOID();
+ rawAttributeType = attributeDescription.toString();
cancelRequest = null;
proxiedAuthorizationDN = null;
}
- /** {@inheritDoc} */
@Override
public final ByteString getRawEntryDN()
{
return rawEntryDN;
}
- /** {@inheritDoc} */
@Override
public final void setRawEntryDN(ByteString rawEntryDN)
{
@@ -177,7 +174,6 @@
entryDN = null;
}
- /** {@inheritDoc} */
@Override
public final DN getEntryDN()
{
@@ -197,7 +193,6 @@
return entryDN;
}
- /** {@inheritDoc} */
@Override
public final String getRawAttributeType()
{
@@ -256,14 +251,12 @@
return assertionValue;
}
- /** {@inheritDoc} */
@Override
public final void setAssertionValue(ByteString assertionValue)
{
this.assertionValue = assertionValue;
}
- /** {@inheritDoc} */
@Override
public final OperationType getOperationType()
{
@@ -288,36 +281,30 @@
return proxiedAuthorizationDN;
}
- /** {@inheritDoc} */
@Override
public void setProxiedAuthorizationDN(DN proxiedAuthorizationDN)
{
this.proxiedAuthorizationDN = proxiedAuthorizationDN;
}
- /** {@inheritDoc} */
@Override
public final List<Control> getResponseControls()
{
return responseControls;
}
- /** {@inheritDoc} */
@Override
public final void addResponseControl(Control control)
{
responseControls.add(control);
}
- /** {@inheritDoc} */
@Override
public final void removeResponseControl(Control control)
{
responseControls.remove(control);
}
-
-
/**
* Performs the work of actually processing this operation. This
* should include all processing for the operation, including
@@ -459,7 +446,6 @@
appendErrorMessage(ERR_COMPARE_NO_SUCH_ENTRY.get(getEntryDN()));
}
- /** {@inheritDoc} */
@Override
public final void toString(StringBuilder buffer)
{
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 8d585aa..54b1cf0 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
@@ -27,19 +27,60 @@
package org.opends.server.protocols.internal;
import java.net.InetAddress;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.slf4j.LocalizedLogger;
+import org.forgerock.opendj.ldap.AttributeDescription;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ResultCode;
+import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.api.ClientConnection;
import org.opends.server.api.ConnectionHandler;
-import org.opends.server.core.*;
-import org.forgerock.opendj.ldap.schema.AttributeType;
-import org.opends.server.types.*;
+import org.opends.server.core.AddOperation;
+import org.opends.server.core.AddOperationBasis;
+import org.opends.server.core.BindOperation;
+import org.opends.server.core.BindOperationBasis;
+import org.opends.server.core.CompareOperation;
+import org.opends.server.core.CompareOperationBasis;
+import org.opends.server.core.DeleteOperation;
+import org.opends.server.core.DeleteOperationBasis;
+import org.opends.server.core.DirectoryServer;
+import org.opends.server.core.ExtendedOperation;
+import org.opends.server.core.ExtendedOperationBasis;
+import org.opends.server.core.ModifyDNOperation;
+import org.opends.server.core.ModifyDNOperationBasis;
+import org.opends.server.core.ModifyOperation;
+import org.opends.server.core.ModifyOperationBasis;
+import org.opends.server.core.SearchOperation;
+import org.opends.server.types.Attribute;
+import org.opends.server.types.AttributeBuilder;
+import org.opends.server.types.Attributes;
+import org.opends.server.types.AuthenticationInfo;
+import org.opends.server.types.CancelRequest;
+import org.opends.server.types.CancelResult;
+import org.opends.server.types.Control;
+import org.opends.server.types.DN;
+import org.opends.server.types.DirectoryException;
+import org.opends.server.types.DisconnectReason;
+import org.opends.server.types.Entry;
+import org.opends.server.types.IntermediateResponse;
+import org.opends.server.types.Modification;
+import org.opends.server.types.ObjectClass;
+import org.opends.server.types.Operation;
+import org.opends.server.types.Privilege;
+import org.opends.server.types.RDN;
+import org.opends.server.types.RawAttribute;
+import org.opends.server.types.RawModification;
+import org.opends.server.types.SearchResultEntry;
+import org.opends.server.types.SearchResultReference;
import org.opends.server.util.AddChangeRecordEntry;
import org.opends.server.util.DeleteChangeRecordEntry;
import org.opends.server.util.ModifyChangeRecordEntry;
@@ -1142,59 +1183,6 @@
ByteString.valueOfUtf8(assertionValue), null);
}
-
-
- /**
- * Processes an internal compare operation with the provided
- * information.
- *
- * @param rawEntryDN The entry DN for the compare operation.
- * @param attributeType The attribute type for the compare
- * operation.
- * @param assertionValue The assertion value for the compare
- * operation.
- * @param controls The set of controls to include in the
- * request.
- *
- * @return A reference to the compare operation that was processed
- * and contains information about the result of the
- * processing.
- */
- public CompareOperation processCompare(String rawEntryDN,
- String attributeType,
- String assertionValue,
- List<Control> controls)
- {
- return processCompare(ByteString.valueOfUtf8(rawEntryDN), attributeType,
- ByteString.valueOfUtf8(assertionValue), controls);
- }
-
-
-
- /**
- * Processes an internal compare operation with the provided
- * information.
- *
- * @param rawEntryDN The entry DN for the compare operation.
- * @param attributeType The attribute type for the compare
- * operation.
- * @param assertionValue The assertion value for the compare
- * operation.
- *
- * @return A reference to the compare operation that was processed
- * and contains information about the result of the
- * processing.
- */
- public CompareOperation processCompare(ByteString rawEntryDN,
- String attributeType,
- ByteString assertionValue)
- {
- return processCompare(rawEntryDN, attributeType, assertionValue,
- null);
- }
-
-
-
/**
* Processes an internal compare operation with the provided
* information.
@@ -1226,57 +1214,29 @@
return compareOperation;
}
-
-
/**
- * Processes an internal compare operation with the provided
- * information.
+ * Processes an internal compare operation with the provided information.
*
- * @param entryDN The entry DN for the compare operation.
- * @param attributeType The attribute type for the compare
- * operation.
- * @param assertionValue The assertion value for the compare
- * operation.
- *
- * @return A reference to the compare operation that was processed
- * and contains information about the result of the
- * processing.
+ * @param entryDN
+ * The entry DN for the compare operation.
+ * @param attributeDescription
+ * The attribute description for the compare operation.
+ * @param assertionValue
+ * The assertion value for the compare operation.
+ * @param controls
+ * The set of controls to include in the request.
+ * @return A reference to the compare operation that was processed and contains information about
+ * the result of the processing.
*/
public CompareOperation processCompare(DN entryDN,
- AttributeType attributeType,
- ByteString assertionValue)
- {
- return processCompare(entryDN, attributeType, assertionValue,
- null);
- }
-
-
-
- /**
- * Processes an internal compare operation with the provided
- * information.
- *
- * @param entryDN The entry DN for the compare operation.
- * @param attributeType The attribute type for the compare
- * operation.
- * @param assertionValue The assertion value for the compare
- * operation.
- * @param controls The set of controls to include in the
- * request.
- *
- * @return A reference to the compare operation that was processed
- * and contains information about the result of the
- * processing.
- */
- public CompareOperation processCompare(DN entryDN,
- AttributeType attributeType,
+ AttributeDescription attributeDescription,
ByteString assertionValue,
List<Control> controls)
{
CompareOperationBasis compareOperation =
new CompareOperationBasis(this, nextOperationID(),
nextMessageID(), controls, entryDN,
- attributeType, assertionValue);
+ attributeDescription, assertionValue);
compareOperation.setInternalOperation(true);
compareOperation.run();
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 52a8576..633e01f 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
@@ -420,60 +420,24 @@
assertEquals(bindOperation.getResultCode(), ResultCode.SUCCESS);
}
-
-
/**
- * Tests the first <CODE>processCompare</CODE> method, which takes raw
- * arguments.
+ * Tests the first <CODE>processCompare</CODE> method, which takes raw arguments.
*
- * @throws Exception If an unexpected problem occurs.
+ * @throws Exception
+ * If an unexpected problem occurs.
*/
@Test
- public void testProcessCompare1()
- throws Exception
+ public void testProcessCompare() throws Exception
{
TestCaseUtils.initializeTestBackend(true);
TestCaseUtils.addEntry("dn: cn=test,o=test",
"objectClass: top",
"objectClass: device",
"cn: test");
-
-
- InternalClientConnection conn = getRootConnection();
- CompareOperation compareOperation =
- conn.processCompare(ByteString.valueOfUtf8("cn=test,o=test"), "cn",
- ByteString.valueOfUtf8("test"));
+ CompareOperation compareOperation = getRootConnection().processCompare("cn=test,o=test", "cn", "test");
assertEquals(compareOperation.getResultCode(), ResultCode.COMPARE_TRUE);
}
-
-
- /**
- * Tests the second <CODE>processCompare</CODE> method, which takes processed
- * arguments.
- *
- * @throws Exception If an unexpected problem occurs.
- */
- @Test
- public void testProcessCompare2()
- throws Exception
- {
- TestCaseUtils.initializeTestBackend(true);
- TestCaseUtils.addEntry("dn: cn=test,o=test",
- "objectClass: top",
- "objectClass: device",
- "cn: test");
-
- InternalClientConnection conn = getRootConnection();
- CompareOperation compareOperation =
- conn.processCompare(DN.valueOf("cn=test,o=test"),
- DirectoryServer.getAttributeType("cn"),
- ByteString.valueOfUtf8("test"));
- assertEquals(compareOperation.getResultCode(), ResultCode.COMPARE_TRUE);
- }
-
-
-
/**
* Tests the first <CODE>processDelete</CODE> method, which takes raw
* arguments.
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 08cde7a..193765d 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
@@ -33,6 +33,7 @@
import java.util.HashMap;
import org.forgerock.i18n.LocalizableMessage;
+import org.forgerock.opendj.ldap.AttributeDescription;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ModificationType;
import org.forgerock.opendj.ldap.ResultCode;
@@ -586,7 +587,7 @@
// Test a compare operation against the PWReset Target user.
CompareOperationBasis compareOp = new CompareOperationBasis(
conn, conn.nextOperationID(), conn.nextMessageID(), controls,
- targetDN, DirectoryServer.getAttributeType("cn"),
+ targetDN, AttributeDescription.valueOf("cn"),
ByteString.valueOfUtf8("PWReset Target"));
assertSuccess(hasProxyPrivilege, compareOp);
@@ -699,7 +700,7 @@
// Test a compare operation against the PWReset Target user.
CompareOperationBasis compareOp = new CompareOperationBasis(
conn, conn.nextOperationID(), conn.nextMessageID(), controls,
- targetDN, DirectoryServer.getAttributeType("cn"),
+ targetDN, AttributeDescription.valueOf("cn"),
ByteString.valueOfUtf8("PWReset Target"));
assertSuccess(hasProxyPrivilege, compareOp);
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/types/PrivilegeTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/types/PrivilegeTestCase.java
index 32a46f5..f12ec09 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/types/PrivilegeTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/types/PrivilegeTestCase.java
@@ -39,11 +39,11 @@
import java.util.UUID;
import java.util.concurrent.CopyOnWriteArraySet;
+import org.forgerock.opendj.ldap.AttributeDescription;
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.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.TestCaseUtils;
import org.opends.server.admin.std.meta.GlobalCfgDefn.DisabledPrivilege;
import org.opends.server.admin.std.meta.RootDNCfgDefn;
@@ -446,9 +446,7 @@
{
assertEquals(conn.hasPrivilege(Privilege.CONFIG_READ, null), hasPrivilege);
- AttributeType cnAttrType = DirectoryServer.getAttributeType("cn");
- CompareOperation compareOperation = conn.processCompare(
- DN.valueOf("cn=config"), cnAttrType, ByteString.valueOfUtf8("config"));
+ CompareOperation compareOperation = conn.processCompare("cn=config", "cn", "config");
if (hasPrivilege)
{
assertEquals(compareOperation.getResultCode(), COMPARE_TRUE);
@@ -1286,8 +1284,7 @@
// Test a compare operation against the PWReset Target user.
CompareOperation compareOperation = new CompareOperationBasis(conn,
nextOperationID(), nextMessageID(),
- controls, targetDN,
- DirectoryServer.getAttributeType("cn"),
+ controls, targetDN, AttributeDescription.valueOf("cn"),
ByteString.valueOfUtf8("PWReset Target"));
compareOperation.run();
if (hasProxyPrivilege)
@@ -1433,8 +1430,8 @@
// Test a compare operation against the PWReset Target user.
CompareOperation compareOperation = new CompareOperationBasis(conn, nextOperationID(),
nextMessageID(), controls, targetDN,
- DirectoryServer.getAttributeType("cn"),
- ByteString.valueOfUtf8("PWReset Target"));
+ AttributeDescription.valueOf("cn"),
+ ByteString.valueOfUtf8("PWReset Target"));
compareOperation.run();
if (hasProxyPrivilege)
{
--
Gitblit v1.10.0