From 22094368c2865dcfb6daf8366425212b721a4657 Mon Sep 17 00:00:00 2001
From: matthew_swift <matthew_swift@localhost>
Date: Thu, 05 Feb 2009 17:42:14 +0000
Subject: [PATCH] Merge ASN1 branch to trunk

---
 opends/src/server/org/opends/server/protocols/ldap/DeleteRequestProtocolOp.java |   79 +++++++--------------------------------
 1 files changed, 14 insertions(+), 65 deletions(-)

diff --git a/opends/src/server/org/opends/server/protocols/ldap/DeleteRequestProtocolOp.java b/opends/src/server/org/opends/server/protocols/ldap/DeleteRequestProtocolOp.java
index 1f7986b..d95b5ae 100644
--- a/opends/src/server/org/opends/server/protocols/ldap/DeleteRequestProtocolOp.java
+++ b/opends/src/server/org/opends/server/protocols/ldap/DeleteRequestProtocolOp.java
@@ -25,22 +25,19 @@
  *      Copyright 2006-2008 Sun Microsystems, Inc.
  */
 package org.opends.server.protocols.ldap;
-import org.opends.messages.Message;
 
 
 
-import org.opends.server.protocols.asn1.ASN1Element;
-import org.opends.server.protocols.asn1.ASN1OctetString;
-import org.opends.server.types.DebugLogLevel;
-import org.opends.server.types.LDAPException;
+import org.opends.server.protocols.asn1.ASN1Writer;
+import org.opends.server.types.ByteString;
 
 import static org.opends.server.loggers.debug.DebugLogger.*;
 import org.opends.server.loggers.debug.DebugTracer;
-import static org.opends.messages.ProtocolMessages.*;
 import static org.opends.server.protocols.ldap.LDAPConstants.*;
-import static org.opends.server.protocols.ldap.LDAPResultCode.*;
 import static org.opends.server.util.ServerConstants.*;
 
+import java.io.IOException;
+
 
 /**
  * This class defines the structures and methods for an LDAP delete request
@@ -55,7 +52,7 @@
   private static final DebugTracer TRACER = getTracer();
 
   // The DN for this delete request.
-  private ASN1OctetString dn;
+  private ByteString dn;
 
 
 
@@ -64,7 +61,7 @@
    *
    * @param  dn  The DN for this delete request protocol op.
    */
-  public DeleteRequestProtocolOp(ASN1OctetString dn)
+  public DeleteRequestProtocolOp(ByteString dn)
   {
     this.dn = dn;
   }
@@ -76,21 +73,20 @@
    *
    * @return  The DN for this delete request.
    */
-  public ASN1OctetString getDN()
+  public ByteString getDN()
   {
     return dn;
   }
 
-
-
   /**
-   * Specifies the DN for this delete request.
+   * Writes this protocol op to an ASN.1 output stream.
    *
-   * @param  dn  The DN for this delete request.
+   * @param stream The ASN.1 output stream to write to.
+   * @throws IOException If a problem occurs while writing to the stream.
    */
-  public void setDN(ASN1OctetString dn)
+  public void write(ASN1Writer stream) throws IOException
   {
-    this.dn = dn;
+    stream.writeOctetString(OP_TYPE_DELETE_REQUEST, dn);
   }
 
 
@@ -118,53 +114,6 @@
   }
 
 
-
-  /**
-   * Encodes this protocol op to an ASN.1 element suitable for including in an
-   * LDAP message.
-   *
-   * @return  The ASN.1 element containing the encoded protocol op.
-   */
-  public ASN1Element encode()
-  {
-    dn.setType(OP_TYPE_DELETE_REQUEST);
-    return dn;
-  }
-
-
-
-  /**
-   * Decodes the provided ASN.1 element as an LDAP delete request protocol op.
-   *
-   * @param  element  The ASN.1 element to be decoded.
-   *
-   * @return  The decoded delete request protocol op.
-   *
-   * @throws  LDAPException  If a problem occurs while decoding the provided
-   *                         ASN.1 element as a delete request protocol op.
-   */
-  public static DeleteRequestProtocolOp decodeDeleteRequest(ASN1Element element)
-         throws LDAPException
-  {
-    try
-    {
-      return new DeleteRequestProtocolOp(element.decodeAsOctetString());
-    }
-    catch (Exception e)
-    {
-      if (debugEnabled())
-      {
-        TRACER.debugCaught(DebugLogLevel.ERROR, e);
-      }
-
-      Message message =
-          ERR_LDAP_DELETE_REQUEST_DECODE_DN.get(String.valueOf(e));
-      throw new LDAPException(PROTOCOL_ERROR, message, e);
-    }
-  }
-
-
-
   /**
    * Appends a string representation of this LDAP protocol op to the provided
    * buffer.
@@ -174,7 +123,7 @@
   public void toString(StringBuilder buffer)
   {
     buffer.append("DeleteRequest(dn=");
-    dn.toString(buffer);
+    buffer.append(dn.toString());
     buffer.append(")");
   }
 
@@ -202,7 +151,7 @@
 
     buffer.append(indentBuf);
     buffer.append("  Entry DN:  ");
-    dn.toString(buffer);
+    buffer.append(dn.toString());
     buffer.append(EOL);
   }
 }

--
Gitblit v1.10.0