Fixed issue 9313. DAL now correctly supports BLOBs.
authorAntonio Moreno <antonio.moreno@openbravo.com>
Fri, 05 Jun 2009 16:24:37 +0200
changeset 3973 b1db7b37413a
parent 3972 03036acb18fe
child 3974 484ba1af6b88
Fixed issue 9313. DAL now correctly supports BLOBs.
src-db/database/lib/dbsourcemanager.jar
src/org/openbravo/dal/xml/ModelXMLConverter.java
src/org/openbravo/dal/xml/XMLTypeConverter.java
Binary file src-db/database/lib/dbsourcemanager.jar has changed
--- a/src/org/openbravo/dal/xml/ModelXMLConverter.java	Thu Jun 04 18:04:44 2009 +0200
+++ b/src/org/openbravo/dal/xml/ModelXMLConverter.java	Fri Jun 05 16:24:37 2009 +0200
@@ -225,6 +225,7 @@
     addSimpleTypeDeclaration(schema, "decimal");
     addSimpleTypeDeclaration(schema, "long");
     addSimpleTypeDeclaration(schema, "float");
+    addSimpleTypeDeclaration(schema, "base64Binary");
   }
 
   private void addSimpleTypeDeclaration(Element schema, String typeName) {
--- a/src/org/openbravo/dal/xml/XMLTypeConverter.java	Thu Jun 04 18:04:44 2009 +0200
+++ b/src/org/openbravo/dal/xml/XMLTypeConverter.java	Fri Jun 05 16:24:37 2009 +0200
@@ -19,12 +19,13 @@
 
 package org.openbravo.dal.xml;
 
+import java.io.UnsupportedEncodingException;
 import java.math.BigDecimal;
 import java.sql.Timestamp;
 import java.text.SimpleDateFormat;
 import java.util.Date;
 
-import org.apache.axis.encoding.Base64;
+import org.apache.commons.codec.binary.Base64;
 import org.openbravo.base.exception.OBException;
 import org.openbravo.base.provider.OBProvider;
 import org.openbravo.base.provider.OBSingleton;
@@ -105,7 +106,12 @@
       return toXML((Boolean) o);
     }
     if (o instanceof byte[]) {
-      return Base64.encode((byte[]) o);
+      try {
+        return new String(Base64.encodeBase64((byte[]) o), "UTF-8");
+      } catch (UnsupportedEncodingException e) {
+        // TODO Auto-generated catch block
+        e.printStackTrace();
+      }
     }
     return o.toString();
     // throw new OBException("Type " + o.getClass().getName() +
@@ -154,7 +160,7 @@
         return (T) new Float(xml);
       }
       if (byte[].class == targetClass) {
-        return (T) Base64.decode(xml);
+        return (T) Base64.decodeBase64(xml.getBytes("UTF-8"));
       }
     } catch (final Exception e) {
       throw new EntityXMLException("Value " + xml + " can not be parsed to an instance of class "
@@ -191,6 +197,9 @@
     if (Float.class == targetClass) {
       return "ob:float";
     }
+    if (byte[].class == targetClass) {
+      return "ob:base64Binary";
+    }
     if (Object.class == targetClass) {
       // TODO catch this
       return "xs:anyType";