From 13b2bf635a2195f2079c9d4afa8aad7db15736bf Mon Sep 17 00:00:00 2001
From: Chris Ridd <chris.ridd@forgerock.com>
Date: Mon, 22 Oct 2012 08:37:31 +0000
Subject: [PATCH] Fix OPENDJ-622 DSML ExtendedRequest text requestValues don't work

---
 opends/src/dsml/org/opends/dsml/protocol/DSMLExtendedOperation.java |   17 ++++++++++++++++-
 1 files changed, 16 insertions(+), 1 deletions(-)

diff --git a/opends/src/dsml/org/opends/dsml/protocol/DSMLExtendedOperation.java b/opends/src/dsml/org/opends/dsml/protocol/DSMLExtendedOperation.java
index 67b09a4..560ed5b 100644
--- a/opends/src/dsml/org/opends/dsml/protocol/DSMLExtendedOperation.java
+++ b/opends/src/dsml/org/opends/dsml/protocol/DSMLExtendedOperation.java
@@ -41,6 +41,7 @@
 import org.opends.server.types.ByteString;
 import org.opends.server.types.LDAPException;
 
+import org.w3c.dom.Element;
 
 
 /**
@@ -91,13 +92,27 @@
     // value is optional in the request
     if (value != null)
     {
+      /*
+       * The processing of the value is tricky, because the schema defines
+       * the requestValue with type="xsd:anyType".
+       *
+       * Consequently if we have:
+       * <requestValue xsi:type="xsd:base64Binary">(base64)</requestValue>
+       * then JAXB returns us a byte [] containing the decoded data.
+       */
       if (value instanceof byte [])
       {
         asnValue = ByteString.wrap((byte [])value);
       }
       else
       {
-        asnValue = ByteString.valueOf(value.toString());
+        /*
+         * On the other hand if we have:
+         * <requestValue>arbitrary text</requestValue>
+         * then we get an Element which we have to extract the text from.
+         */
+        Element content = (Element)value;
+        asnValue = ByteString.valueOf(content.getTextContent());
       }
     }
 

--
Gitblit v1.10.0