From 401925979dc16f74f794ddd4941f74d0cef770db Mon Sep 17 00:00:00 2001
From: fdorson <fdorson@localhost>
Date: Tue, 07 Jul 2009 13:21:10 +0000
Subject: [PATCH] Fix for issue #4095 : Add getters methods to LDAPUpdateMsg

---
 opends/src/server/org/opends/server/replication/protocol/ModifyCommonMsg.java |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 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 fddd078..edf8877 100644
--- a/opends/src/server/org/opends/server/replication/protocol/ModifyCommonMsg.java
+++ b/opends/src/server/org/opends/server/replication/protocol/ModifyCommonMsg.java
@@ -26,9 +26,12 @@
  */
 package org.opends.server.replication.protocol;
 
+import java.util.ArrayList;
 import java.util.List;
 
 import org.opends.server.protocols.asn1.ASN1;
+import org.opends.server.protocols.asn1.ASN1Exception;
+import org.opends.server.protocols.asn1.ASN1Reader;
 import org.opends.server.protocols.asn1.ASN1Writer;
 import org.opends.server.protocols.ldap.LDAPAttribute;
 import org.opends.server.protocols.ldap.LDAPModification;
@@ -38,6 +41,7 @@
 import org.opends.server.types.AttributeType;
 import org.opends.server.types.AttributeUsage;
 import org.opends.server.types.ByteStringBuilder;
+import org.opends.server.types.LDAPException;
 import org.opends.server.types.Modification;
 
 /**
@@ -97,6 +101,24 @@
   }
 
   /**
+   * Get the Modifications associated to the UpdateMsg to the provided value.
+   * @throws LDAPException In case of LDAP decoding exception
+   * @throws ASN1Exception In case of ASN1 decoding exception
+   * @return the list of modifications
+   */
+  public List<Modification> getMods() throws ASN1Exception, LDAPException
+  {
+    List<Modification> mods = new ArrayList<Modification>();
+
+    ASN1Reader reader = ASN1.getReader(encodedMods);
+
+    while (reader.hasNextElement())
+      mods.add((LDAPModification.decode(reader)).toModification());
+
+    return mods;
+  }
+
+  /**
    * Encode an ArrayList of Modification into a byte[] suitable
    * for storage in a database or send on the network.
    *

--
Gitblit v1.10.0