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/replication/protocol/ModifyCommonMsg.java |   23 ++++++++++++++++-------
 1 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/opends/src/server/org/opends/server/replication/protocol/ModifyCommonMsg.java b/opends/src/server/org/opends/server/replication/protocol/ModifyCommonMsg.java
index 0339bd7..fddd078 100644
--- a/opends/src/server/org/opends/server/replication/protocol/ModifyCommonMsg.java
+++ b/opends/src/server/org/opends/server/replication/protocol/ModifyCommonMsg.java
@@ -22,13 +22,14 @@
  * CDDL HEADER END
  *
  *
- *      Copyright 2008 Sun Microsystems, Inc.
+ *      Copyright 2009 Sun Microsystems, Inc.
  */
 package org.opends.server.replication.protocol;
 
-import java.util.ArrayList;
 import java.util.List;
-import org.opends.server.protocols.asn1.ASN1Element;
+
+import org.opends.server.protocols.asn1.ASN1;
+import org.opends.server.protocols.asn1.ASN1Writer;
 import org.opends.server.protocols.ldap.LDAPAttribute;
 import org.opends.server.protocols.ldap.LDAPModification;
 import org.opends.server.replication.common.ChangeNumber;
@@ -36,6 +37,7 @@
 import org.opends.server.types.Attribute;
 import org.opends.server.types.AttributeType;
 import org.opends.server.types.AttributeUsage;
+import org.opends.server.types.ByteStringBuilder;
 import org.opends.server.types.Modification;
 
 /**
@@ -106,9 +108,9 @@
     if ((mods == null) || (mods.size() == 0))
       return new byte[0];
 
-    ArrayList<ASN1Element> modsASN1;
+    ByteStringBuilder byteBuilder = new ByteStringBuilder();
+    ASN1Writer writer = ASN1.getWriter(byteBuilder);
 
-    modsASN1 = new ArrayList<ASN1Element>(mods.size());
     for (Modification mod : mods)
     {
       Attribute attr = mod.getAttribute();
@@ -127,11 +129,18 @@
       {
         LDAPModification ldapmod = new LDAPModification(
           mod.getModificationType(), new LDAPAttribute(mod.getAttribute()));
-        modsASN1.add(ldapmod.encode());
+        try
+        {
+          ldapmod.write(writer);
+        }
+        catch(Exception e)
+        {
+          // DO SOMETHING
+        }
       }
     }
 
-    return ASN1Element.encodeValue(modsASN1);
+    return byteBuilder.toByteArray();
   }
 
 }

--
Gitblit v1.10.0