From f2160f4bd1c8ac67e5a86a6710d431e8932877f9 Mon Sep 17 00:00:00 2001
From: matthew_swift <matthew_swift@localhost>
Date: Fri, 28 May 2010 11:47:51 +0000
Subject: [PATCH] Synchronize SDK on java.net with internal repository.
---
sdk/src/org/opends/sdk/requests/GenericExtendedRequestImpl.java | 175 +++++++++++++++++++++++++++++++++++++---------------------
1 files changed, 112 insertions(+), 63 deletions(-)
diff --git a/sdk/src/org/opends/sdk/requests/GenericExtendedRequestImpl.java b/sdk/src/org/opends/sdk/requests/GenericExtendedRequestImpl.java
index f48fdc4..cb3321d 100644
--- a/sdk/src/org/opends/sdk/requests/GenericExtendedRequestImpl.java
+++ b/sdk/src/org/opends/sdk/requests/GenericExtendedRequestImpl.java
@@ -31,11 +31,15 @@
import org.opends.sdk.ByteString;
import org.opends.sdk.DecodeException;
+import org.opends.sdk.DecodeOptions;
import org.opends.sdk.ResultCode;
-import org.opends.sdk.extensions.ExtendedOperation;
+import org.opends.sdk.controls.Control;
+import org.opends.sdk.responses.ExtendedResult;
+import org.opends.sdk.responses.ExtendedResultDecoder;
import org.opends.sdk.responses.GenericExtendedResult;
import org.opends.sdk.responses.Responses;
+import com.sun.opends.sdk.util.StaticUtils;
import com.sun.opends.sdk.util.Validator;
@@ -43,52 +47,81 @@
/**
* Generic extended request implementation.
*/
-final class GenericExtendedRequestImpl
- extends
+final class GenericExtendedRequestImpl extends
AbstractExtendedRequest<GenericExtendedRequest, GenericExtendedResult>
implements GenericExtendedRequest
{
- /**
- * Generic extended operation singleton.
- */
- private static final class Operation implements
- ExtendedOperation<GenericExtendedRequest, GenericExtendedResult>
+
+ static final class RequestDecoder implements
+ ExtendedRequestDecoder<GenericExtendedRequest, GenericExtendedResult>
{
-
- public GenericExtendedRequest decodeRequest(String requestName,
- ByteString requestValue) throws DecodeException
- {
- return Requests.newGenericExtendedRequest(requestName,
- requestValue);
- }
-
-
-
- public GenericExtendedResult decodeResponse(ResultCode resultCode,
- String matchedDN, String diagnosticMessage)
- {
- return Responses.newGenericExtendedResult(resultCode)
- .setMatchedDN(matchedDN).setDiagnosticMessage(
- diagnosticMessage);
- }
-
-
-
- public GenericExtendedResult decodeResponse(ResultCode resultCode,
- String matchedDN, String diagnosticMessage,
- String responseName, ByteString responseValue)
+ public GenericExtendedRequest decodeExtendedRequest(
+ final ExtendedRequest<?> request, final DecodeOptions options)
throws DecodeException
{
- return Responses.newGenericExtendedResult(resultCode)
- .setMatchedDN(matchedDN).setDiagnosticMessage(
- diagnosticMessage).setResponseName(responseName)
- .setResponseValue(responseValue);
+ if (request instanceof GenericExtendedRequest)
+ {
+ return (GenericExtendedRequest) request;
+ }
+ else
+ {
+ final GenericExtendedRequest newRequest = new GenericExtendedRequestImpl(
+ request.getOID(), request.getValue());
+
+ for (final Control control : request.getControls())
+ {
+ newRequest.addControl(control);
+ }
+
+ return newRequest;
+ }
}
}
- private static final Operation OPERATION = new Operation();
+ private static final class GenericExtendedResultDecoder implements
+ ExtendedResultDecoder<GenericExtendedResult>
+ {
+
+ public GenericExtendedResult adaptExtendedErrorResult(
+ final ResultCode resultCode, final String matchedDN,
+ final String diagnosticMessage)
+ {
+ return Responses.newGenericExtendedResult(resultCode).setMatchedDN(
+ matchedDN).setDiagnosticMessage(diagnosticMessage);
+ }
+
+
+
+ public GenericExtendedResult decodeExtendedResult(
+ final ExtendedResult result, final DecodeOptions options)
+ throws DecodeException
+ {
+ if (result instanceof GenericExtendedResult)
+ {
+ return (GenericExtendedResult) result;
+ }
+ else
+ {
+ final GenericExtendedResult newResult = Responses
+ .newGenericExtendedResult(result.getResultCode()).setMatchedDN(
+ result.getMatchedDN()).setDiagnosticMessage(
+ result.getDiagnosticMessage()).setOID(result.getOID())
+ .setValue(result.getValue());
+ for (final Control control : result.getControls())
+ {
+ newResult.addControl(control);
+ }
+ return newResult;
+ }
+ }
+ }
+
+
+
+ private static final GenericExtendedResultDecoder RESULT_DECODER =
+ new GenericExtendedResultDecoder();
private ByteString requestValue = ByteString.empty();
@@ -97,21 +130,20 @@
/**
- * Creates a new generic extended request using the provided name and
- * optional value.
- *
+ * Creates a new generic extended request using the provided name and optional
+ * value.
+ *
* @param requestName
- * The dotted-decimal representation of the unique OID
- * corresponding to this extended request.
+ * The dotted-decimal representation of the unique OID corresponding
+ * to this extended request.
* @param requestValue
- * The content of this generic extended request in a form
- * defined by the extended operation, or {@code null} if
- * there is no content.
+ * The content of this generic extended request in a form defined by
+ * the extended operation, or {@code null} if there is no content.
* @throws NullPointerException
* If {@code requestName} was {@code null}.
*/
- GenericExtendedRequestImpl(String requestName, ByteString requestValue)
- throws NullPointerException
+ GenericExtendedRequestImpl(final String requestName,
+ final ByteString requestValue) throws NullPointerException
{
this.requestName = requestName;
this.requestValue = requestValue;
@@ -122,17 +154,8 @@
/**
* {@inheritDoc}
*/
- public ExtendedOperation<GenericExtendedRequest, GenericExtendedResult> getExtendedOperation()
- {
- return OPERATION;
- }
-
-
-
- /**
- * {@inheritDoc}
- */
- public String getRequestName()
+ @Override
+ public String getOID()
{
return requestName;
}
@@ -142,7 +165,19 @@
/**
* {@inheritDoc}
*/
- public ByteString getRequestValue()
+ @Override
+ public ExtendedResultDecoder<GenericExtendedResult> getResultDecoder()
+ {
+ return RESULT_DECODER;
+ }
+
+
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public ByteString getValue()
{
return requestValue;
}
@@ -152,7 +187,18 @@
/**
* {@inheritDoc}
*/
- public GenericExtendedRequest setRequestName(String oid)
+ @Override
+ public boolean hasValue()
+ {
+ return requestValue != null;
+ }
+
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public GenericExtendedRequest setOID(final String oid)
throws UnsupportedOperationException, NullPointerException
{
Validator.ensureNotNull(oid);
@@ -165,7 +211,7 @@
/**
* {@inheritDoc}
*/
- public GenericExtendedRequest setRequestValue(ByteString bytes)
+ public GenericExtendedRequest setValue(final ByteString bytes)
throws UnsupportedOperationException
{
this.requestValue = bytes;
@@ -182,9 +228,12 @@
{
final StringBuilder builder = new StringBuilder();
builder.append("GenericExtendedRequest(requestName=");
- builder.append(getRequestName());
- builder.append(", requestValue=");
- builder.append(getRequestValue());
+ builder.append(getOID());
+ if (hasValue())
+ {
+ builder.append(", requestValue=");
+ StaticUtils.toHexPlusAscii(getValue(), builder, 4);
+ }
builder.append(", controls=");
builder.append(getControls());
builder.append(")");
--
Gitblit v1.10.0