Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/survey/PdfSurveyServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/survey/PdfSurveyServices.java?rev=587433&r1=587432&r2=587433&view=diff ============================================================================== --- ofbiz/trunk/applications/content/src/org/ofbiz/content/survey/PdfSurveyServices.java (original) +++ ofbiz/trunk/applications/content/src/org/ofbiz/content/survey/PdfSurveyServices.java Tue Oct 23 02:52:49 2007 @@ -23,6 +23,7 @@ import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; +import java.nio.ByteBuffer; import java.sql.Timestamp; import java.util.ArrayList; import java.util.Date; @@ -42,7 +43,6 @@ import org.ofbiz.entity.GenericDelegator; import org.ofbiz.entity.GenericEntityException; import org.ofbiz.entity.GenericValue; -import org.ofbiz.entity.util.ByteWrapper; import org.ofbiz.entity.util.EntityUtil; import org.ofbiz.service.DispatchContext; import org.ofbiz.service.GenericServiceException; @@ -83,8 +83,8 @@ try { String surveyName = (String) context.get("surveyName"); ByteArrayOutputStream os = new ByteArrayOutputStream(); - ByteWrapper byteWrapper = getInputByteWrapper(context, delegator); - PdfReader pdfReader = new PdfReader(byteWrapper.getBytes()); + ByteBuffer byteBuffer = getInputByteBuffer(context, delegator); + PdfReader pdfReader = new PdfReader(byteBuffer.array()); PdfStamper pdfStamper = new PdfStamper(pdfReader, os); AcroFields acroFields = pdfStamper.getAcroFields(); HashMap acroFieldMap = acroFields.getFields(); @@ -265,8 +265,8 @@ } ByteArrayOutputStream os = new ByteArrayOutputStream(); - ByteWrapper byteWrapper = getInputByteWrapper(context, delegator); - PdfReader r = new PdfReader(byteWrapper.getBytes()); + ByteBuffer byteBuffer = getInputByteBuffer(context, delegator); + PdfReader r = new PdfReader(byteBuffer.array()); PdfStamper s = new PdfStamper(r,os); AcroFields fs = s.getAcroFields(); HashMap hm = fs.getFields(); @@ -323,8 +323,8 @@ try { ByteArrayOutputStream os = new ByteArrayOutputStream(); GenericDelegator delegator = dctx.getDelegator(); - ByteWrapper byteWrapper = getInputByteWrapper(context, delegator); - PdfReader r = new PdfReader(byteWrapper.getBytes()); + ByteBuffer byteBuffer = getInputByteBuffer(context, delegator); + PdfReader r = new PdfReader(byteBuffer.array()); PdfStamper s = new PdfStamper(r,os); AcroFields fs = s.getAcroFields(); HashMap map = fs.getFields(); @@ -367,8 +367,8 @@ GenericDelegator delegator = dctx.getDelegator(); try { Map acroFieldMap = (Map)context.get("acroFieldMap"); - ByteWrapper byteWrapper = getInputByteWrapper(context, delegator); - PdfReader r = new PdfReader(byteWrapper.getBytes()); + ByteBuffer byteBuffer = getInputByteBuffer(context, delegator); + PdfReader r = new PdfReader(byteBuffer.array()); ByteArrayOutputStream baos = new ByteArrayOutputStream(); PdfStamper s = new PdfStamper(r, baos); AcroFields fs = s.getAcroFields(); @@ -405,8 +405,8 @@ s.close(); baos.close(); - ByteWrapper outByteWrapper = new ByteWrapper(baos.toByteArray()); - results.put("outByteWrapper", outByteWrapper); + ByteBuffer outByteBuffer = ByteBuffer.wrap(baos.toByteArray()); + results.put("outByteBuffer", outByteBuffer); } catch(DocumentException e) { System.err.println(e.getMessage()); ServiceUtil.returnError(e.getMessage()); @@ -486,8 +486,8 @@ Paragraph p = new Paragraph(chunk); document.add(p); } - ByteWrapper outByteWrapper = new ByteWrapper(baos.toByteArray()); - results.put("outByteWrapper", outByteWrapper); + ByteBuffer outByteBuffer = ByteBuffer.wrap(baos.toByteArray()); + results.put("outByteBuffer", outByteBuffer); } catch (GenericEntityException e) { System.err.println(e.getMessage()); ServiceUtil.returnError(e.getMessage()); @@ -609,12 +609,12 @@ System.err.println(errMsg); ServiceUtil.returnError(errMsg); } - String pdfFileNameOut = (String)context.get("pdfFileNameOut"); - ByteWrapper outByteWrapper = (ByteWrapper)map.get("outByteWrapper"); - results.put("outByteWrapper", outByteWrapper); + String pdfFileNameOut = (String) context.get("pdfFileNameOut"); + ByteBuffer outByteBuffer = (ByteBuffer) map.get("outByteBuffer"); + results.put("outByteBuffer", outByteBuffer); if (UtilValidate.isNotEmpty(pdfFileNameOut)) { FileOutputStream fos = new FileOutputStream(pdfFileNameOut); - fos.write(outByteWrapper.getBytes()); + fos.write(outByteBuffer.array()); fos.close(); } } catch(FileNotFoundException e) { @@ -631,11 +631,11 @@ return results; } - public static ByteWrapper getInputByteWrapper(Map context, GenericDelegator delegator) throws GeneralException { + public static ByteBuffer getInputByteBuffer(Map context, GenericDelegator delegator) throws GeneralException { - ByteWrapper inputByteWrapper = (ByteWrapper)context.get("inputByteWrapper"); + ByteBuffer inputByteBuffer = (ByteBuffer)context.get("inputByteBuffer"); - if (inputByteWrapper == null) { + if (inputByteBuffer == null) { String pdfFileNameIn = (String)context.get("pdfFileNameIn"); String contentId = (String)context.get("contentId"); if (UtilValidate.isNotEmpty(pdfFileNameIn)) { @@ -644,7 +644,7 @@ int c; ByteArrayOutputStream baos = new ByteArrayOutputStream(); while ((c = fis.read()) != -1) baos.write(c); - inputByteWrapper = new ByteWrapper(baos.toByteArray()); + inputByteBuffer = ByteBuffer.wrap(baos.toByteArray()); } catch(FileNotFoundException e) { throw(new GeneralException(e.getMessage())); } catch(IOException e) { @@ -658,7 +658,7 @@ String rootDir = (String)context.get("rootDir"); GenericValue content = delegator.findByPrimaryKeyCache("Content", UtilMisc.toMap("contentId", contentId)); String dataResourceId = content.getString("dataResourceId"); - inputByteWrapper = DataResourceWorker.getContentAsByteWrapper(delegator, dataResourceId, https, webSiteId, locale, rootDir); + inputByteBuffer = DataResourceWorker.getContentAsByteBuffer(delegator, dataResourceId, https, webSiteId, locale, rootDir); } catch (GenericEntityException e) { throw(new GeneralException(e.getMessage())); } catch (IOException e) { @@ -666,6 +666,6 @@ } } } - return inputByteWrapper; + return inputByteBuffer; } } Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/view/SimpleContentViewHandler.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/view/SimpleContentViewHandler.java?rev=587433&r1=587432&r2=587433&view=diff ============================================================================== --- ofbiz/trunk/applications/content/src/org/ofbiz/content/view/SimpleContentViewHandler.java (original) +++ ofbiz/trunk/applications/content/src/org/ofbiz/content/view/SimpleContentViewHandler.java Tue Oct 23 02:52:49 2007 @@ -20,6 +20,8 @@ import java.io.ByteArrayInputStream; import java.io.IOException; +import java.nio.ByteBuffer; + import javax.servlet.ServletContext; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -35,7 +37,6 @@ import org.ofbiz.base.util.UtilHttp; import org.ofbiz.base.util.UtilValidate; import org.ofbiz.base.util.UtilMisc; -import org.ofbiz.entity.util.ByteWrapper; import org.ofbiz.entity.GenericDelegator; import org.ofbiz.entity.GenericValue; import org.ofbiz.entity.GenericEntityException; @@ -70,7 +71,7 @@ String dataResourceId = request.getParameter("dataResourceId"); String contentRevisionSeqId = request.getParameter("contentRevisionSeqId"); String mimeTypeId = request.getParameter("mimeTypeId"); - ByteWrapper byteWrapper = null; + ByteBuffer byteBuffer = null; Locale locale = UtilHttp.getLocale(request); String rootDir = null; String webSiteId = null; @@ -125,8 +126,8 @@ } } GenericValue dataResource = delegator.findByPrimaryKeyCache("DataResource", UtilMisc.toMap("dataResourceId", dataResourceId)); - byteWrapper = DataResourceWorker.getContentAsByteWrapper(delegator, dataResourceId, https, webSiteId, locale, rootDir); - ByteArrayInputStream bais = new ByteArrayInputStream(byteWrapper.getBytes()); + byteBuffer = DataResourceWorker.getContentAsByteBuffer(delegator, dataResourceId, https, webSiteId, locale, rootDir); + ByteArrayInputStream bais = new ByteArrayInputStream(byteBuffer.array()); // hack for IE and mime types //String userAgent = request.getHeader("User-Agent"); //if (userAgent.indexOf("MSIE") > -1) { @@ -146,7 +147,7 @@ // setup content type String contentType2 = UtilValidate.isNotEmpty(mimeTypeId) ? mimeTypeId + "; charset=" +charset : contentType; - UtilHttp.streamContentToBrowser(response, bais, byteWrapper.getLength(), contentType2); + UtilHttp.streamContentToBrowser(response, bais, byteBuffer.limit(), contentType2); } catch(GenericEntityException e) { throw new ViewHandlerException(e.getMessage()); } catch(IOException e) { Modified: ofbiz/trunk/applications/party/script/org/ofbiz/party/party/PartySimpleEvents.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/script/org/ofbiz/party/party/PartySimpleEvents.xml?rev=587433&r1=587432&r2=587433&view=diff ============================================================================== --- ofbiz/trunk/applications/party/script/org/ofbiz/party/party/PartySimpleEvents.xml (original) +++ ofbiz/trunk/applications/party/script/org/ofbiz/party/party/PartySimpleEvents.xml Tue Oct 23 02:52:49 2007 @@ -84,7 +84,7 @@ </call-class-method> <call-class-method class-name="org.ofbiz.content.layout.LayoutWorker" - method-name="returnByteWrapper" + method-name="returnByteBuffer" ret-field-name="byteWrap" > <field field-name="formInput" type="java.util.Map"/> @@ -111,7 +111,7 @@ </call-class-method> <call-class-method class-name="org.ofbiz.content.layout.LayoutWorker" - method-name="returnByteWrapper" + method-name="returnByteBuffer" ret-field-name="byteWrap" > <field field-name="formInput" type="java.util.Map"/> Modified: ofbiz/trunk/applications/party/servicedef/services.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/servicedef/services.xml?rev=587433&r1=587432&r2=587433&view=diff ============================================================================== --- ofbiz/trunk/applications/party/servicedef/services.xml (original) +++ ofbiz/trunk/applications/party/servicedef/services.xml Tue Oct 23 02:52:49 2007 @@ -40,7 +40,7 @@ <required-permissions join-type="AND"> <check-permission permission="PARTYMGR" action="_CREATE"/> </required-permissions> - <attribute name="uploadedFile" type="org.ofbiz.entity.util.ByteWrapper" mode="IN" optional="false"/> + <attribute name="uploadedFile" type="java.nio.ByteBuffer" mode="IN" optional="false"/> <attribute name="_uploadedFile_fileName" type="String" mode="IN" optional="false"/> <attribute name="_uploadedFile_contentType" type="String" mode="IN" optional="false"/> </service> @@ -684,7 +684,7 @@ location="org/ofbiz/party/party/PartyServices.xml" invoke="createPartyContent" auth="false"> <description>Create Party Associated Content</description> <auto-attributes include="nonpk" mode="IN" optional="true"/> - <attribute name="uploadedFile" type="org.ofbiz.entity.util.ByteWrapper" mode="IN" optional="true"/> + <attribute name="uploadedFile" type="java.nio.ByteBuffer" mode="IN" optional="true"/> <attribute name="_uploadedFile_fileName" type="String" mode="IN" optional="true"/> <attribute name="_uploadedFile_contentType" type="String" mode="IN" optional="false"/> <attribute name="dataCategoryId" type="String" mode="IN" optional="true"/> @@ -698,7 +698,7 @@ <description>Update a Party Content</description> <auto-attributes include="pk" mode="INOUT" optional="false"/> <auto-attributes include="nonpk" mode="IN" optional="true"/> - <attribute name="uploadedFile" type="org.ofbiz.entity.util.ByteWrapper" mode="IN" optional="true"/> + <attribute name="uploadedFile" type="java.nio.ByteBuffer" mode="IN" optional="true"/> <attribute name="_uploadedFile_fileName" type="String" mode="IN" optional="true"/> <attribute name="_uploadedFile_contentType" type="String" mode="IN" optional="false"/> <attribute mode="IN" name="partyId" optional="true" type="String"/> Modified: ofbiz/trunk/applications/party/src/org/ofbiz/party/party/PartyServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/src/org/ofbiz/party/party/PartyServices.java?rev=587433&r1=587432&r2=587433&view=diff ============================================================================== --- ofbiz/trunk/applications/party/src/org/ofbiz/party/party/PartyServices.java (original) +++ ofbiz/trunk/applications/party/src/org/ofbiz/party/party/PartyServices.java Tue Oct 23 02:52:49 2007 @@ -49,7 +49,6 @@ import org.ofbiz.entity.util.EntityListIterator; import org.ofbiz.entity.util.EntityTypeUtil; import org.ofbiz.entity.util.EntityUtil; -import org.ofbiz.entity.util.ByteWrapper; import org.ofbiz.security.Security; import org.ofbiz.service.DispatchContext; import org.ofbiz.service.ModelService; @@ -1613,8 +1612,8 @@ public static Map importAddressMatchMapCsv(DispatchContext dctx, Map context) { GenericDelegator delegator = dctx.getDelegator(); - ByteWrapper file = (ByteWrapper) context.get("uploadedFile"); - String csvFile = new String(file.getBytes()); + byte[] fileBytes = (byte[]) context.get("uploadedFile"); + String csvFile = new String(fileBytes); csvFile = csvFile.replaceAll("\\r", ""); String[] records = csvFile.split("\\n"); Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/promo/PromoServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/promo/PromoServices.java?rev=587433&r1=587432&r2=587433&view=diff ============================================================================== --- ofbiz/trunk/applications/product/src/org/ofbiz/product/promo/PromoServices.java (original) +++ ofbiz/trunk/applications/product/src/org/ofbiz/product/promo/PromoServices.java Tue Oct 23 02:52:49 2007 @@ -31,7 +31,6 @@ import org.ofbiz.entity.condition.EntityConditionList; import org.ofbiz.entity.condition.EntityExpr; import org.ofbiz.entity.condition.EntityOperator; -import org.ofbiz.entity.util.ByteWrapper; import org.ofbiz.entity.util.EntityListIterator; import org.ofbiz.service.*; @@ -114,7 +113,7 @@ LocalDispatcher dispatcher = dctx.getDispatcher(); // check the uploaded file - ByteWrapper wrapper = (ByteWrapper) context.get("uploadedFile"); + byte[] wrapper = (byte[]) context.get("uploadedFile"); if (wrapper == null) { return ServiceUtil.returnError("Uploaded file not valid or corrupted"); } @@ -132,7 +131,7 @@ Map invokeCtx = promoModel.makeValid(context, ModelService.IN_PARAM); // read the bytes into a reader - BufferedReader reader = new BufferedReader(new StringReader(new String(wrapper.getBytes()))); + BufferedReader reader = new BufferedReader(new StringReader(new String(wrapper))); List errors = FastList.newInstance(); int lines = 0; String line; @@ -186,7 +185,7 @@ LocalDispatcher dispatcher = dctx.getDispatcher(); String productPromoCodeId = (String) context.get("productPromoCodeId"); - ByteWrapper wrapper = (ByteWrapper) context.get("uploadedFile"); + byte[] wrapper = (byte[]) context.get("uploadedFile"); GenericValue userLogin = (GenericValue) context.get("userLogin"); if (wrapper == null) { @@ -194,7 +193,7 @@ } // read the bytes into a reader - BufferedReader reader = new BufferedReader(new StringReader(new String(wrapper.getBytes()))); + BufferedReader reader = new BufferedReader(new StringReader(new String(wrapper))); List errors = FastList.newInstance(); int lines = 0; String line; Modified: ofbiz/trunk/framework/common/servicedef/services_test.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/servicedef/services_test.xml?rev=587433&r1=587432&r2=587433&view=diff ============================================================================== --- ofbiz/trunk/framework/common/servicedef/services_test.xml (original) +++ ofbiz/trunk/framework/common/servicedef/services_test.xml Tue Oct 23 02:52:49 2007 @@ -150,19 +150,19 @@ <attribute name="rollback" type="Boolean" mode="IN" optional="true"/> </service> - <service name="byteWrapperTest" engine="java" auth="true" - location="org.ofbiz.common.CommonServices" invoke="byteWrapperTest"> - <description>Test Passing ByteWrapper To Service</description> - <attribute name="byteWrapper1" type="org.ofbiz.entity.util.ByteWrapper" mode="IN" optional="false"/> + <service name="byteBufferTest" engine="java" auth="true" + location="org.ofbiz.common.CommonServices" invoke="byteBufferTest"> + <description>Test Passing ByteBuffer To Service</description> + <attribute name="byteBuffer1" type="java.nio.ByteBuffer" mode="IN" optional="false"/> <attribute name="saveAsFileName1" type="String" mode="IN" optional="false"/> - <attribute name="byteWrapper2" type="org.ofbiz.entity.util.ByteWrapper" mode="IN" optional="false"/> + <attribute name="byteBuffer2" type="java.nio.ByteBuffer" mode="IN" optional="false"/> <attribute name="saveAsFileName2" type="String" mode="IN" optional="false"/> </service> <service name="uploadContentTest" engine="java" auth="true" location="org.ofbiz.common.CommonServices" invoke="uploadTest"> <description>Upload Content Test Service</description> - <attribute name="uploadFile" type="org.ofbiz.entity.util.ByteWrapper" mode="IN" optional="false"/> + <attribute name="uploadFile" type="java.nio.ByteBuffer" mode="IN" optional="false"/> <attribute name="_uploadFile_contentType" type="String" mode="IN" optional="false"/> <attribute name="_uploadFile_fileName" type="String" mode="IN" optional="false"/> </service> Modified: ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonServices.java?rev=587433&r1=587432&r2=587433&view=diff ============================================================================== --- ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonServices.java (original) +++ ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonServices.java Tue Oct 23 02:52:49 2007 @@ -19,6 +19,7 @@ package org.ofbiz.common; import java.io.*; +import java.nio.ByteBuffer; import java.sql.Timestamp; import java.util.*; @@ -35,7 +36,6 @@ import org.ofbiz.entity.GenericValue; import org.ofbiz.entity.model.ModelEntity; import org.ofbiz.entity.transaction.TransactionUtil; -import org.ofbiz.entity.util.ByteWrapper; import org.ofbiz.service.DispatchContext; import org.ofbiz.service.GenericServiceException; import org.ofbiz.service.LocalDispatcher; @@ -330,9 +330,9 @@ return ServiceUtil.returnSuccess(); } - public static Map byteWrapperTest(DispatchContext dctx, Map context) { - ByteWrapper wrapper1 = (ByteWrapper) context.get("byteWrapper1"); - ByteWrapper wrapper2 = (ByteWrapper) context.get("byteWrapper2"); + public static Map byteBufferTest(DispatchContext dctx, Map context) { + ByteBuffer buffer1 = (ByteBuffer) context.get("byteBuffer1"); + ByteBuffer buffer2 = (ByteBuffer) context.get("byteBuffer2"); String fileName1 = (String) context.get("saveAsFileName1"); String fileName2 = (String) context.get("saveAsFileName2"); String ofbizHome = System.getProperty("ofbiz.home"); @@ -342,8 +342,8 @@ try { RandomAccessFile file1 = new RandomAccessFile(outputPath1, "rw"); RandomAccessFile file2 = new RandomAccessFile(outputPath2, "rw"); - file1.write(wrapper1.getBytes()); - file2.write(wrapper2.getBytes()); + file1.write(buffer1.array()); + file2.write(buffer2.array()); } catch (FileNotFoundException e) { Debug.logError(e, module); } catch (IOException e) { @@ -357,12 +357,12 @@ LocalDispatcher dispatcher = dctx.getDispatcher(); GenericValue userLogin = (GenericValue) context.get("userLogin"); - ByteWrapper wrapper = (ByteWrapper) context.get("uploadFile"); + byte[] array = (byte[]) context.get("uploadFile"); String fileName = (String) context.get("_uploadFile_fileName"); String contentType = (String) context.get("_uploadFile_contentType"); Map createCtx = new HashMap(); - createCtx.put("binData", wrapper); + createCtx.put("binData", array); createCtx.put("dataResourceTypeId", "OFBIZ_FILE"); createCtx.put("dataResourceName", fileName); createCtx.put("dataCategoryId", "PERSONAL"); Modified: ofbiz/trunk/framework/entity/fieldtype/fieldtypeadvantage.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/fieldtype/fieldtypeadvantage.xml?rev=587433&r1=587432&r2=587433&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/fieldtype/fieldtypeadvantage.xml (original) +++ ofbiz/trunk/framework/entity/fieldtype/fieldtypeadvantage.xml Tue Oct 23 02:52:49 2007 @@ -25,7 +25,7 @@ <!-- ===================== field-type-def ==================== --> <!-- General Types --> - <field-type-def type="blob" sql-type="Blob" java-type="java.lang.Object"></field-type-def> + <field-type-def type="blob" sql-type="Blob" java-type="java.sql.Blob"></field-type-def> <field-type-def type="date-time" sql-type="TimeStamp" java-type="java.sql.Timestamp"></field-type-def> <field-type-def type="date" sql-type="Date" java-type="java.sql.Date"></field-type-def> Modified: ofbiz/trunk/framework/entity/fieldtype/fieldtypeaxion.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/fieldtype/fieldtypeaxion.xml?rev=587433&r1=587432&r2=587433&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/fieldtype/fieldtypeaxion.xml (original) +++ ofbiz/trunk/framework/entity/fieldtype/fieldtypeaxion.xml Tue Oct 23 02:52:49 2007 @@ -22,7 +22,7 @@ xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/fieldtypemodel.xsd"> <!-- ===================== field-type-def ==================== --> <!-- General Types --> - <field-type-def type="blob" sql-type="BLOB" java-type="java.lang.Object"></field-type-def> + <field-type-def type="blob" sql-type="BLOB" java-type="java.sql.Blob"></field-type-def> <field-type-def type="date-time" sql-type="TIMESTAMP" java-type="java.sql.Timestamp"></field-type-def> <field-type-def type="date" sql-type="DATE" java-type="java.sql.Date"></field-type-def> Modified: ofbiz/trunk/framework/entity/fieldtype/fieldtypecloudscape.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/fieldtype/fieldtypecloudscape.xml?rev=587433&r1=587432&r2=587433&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/fieldtype/fieldtypecloudscape.xml (original) +++ ofbiz/trunk/framework/entity/fieldtype/fieldtypecloudscape.xml Tue Oct 23 02:52:49 2007 @@ -22,7 +22,7 @@ xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/fieldtypemodel.xsd"> <!-- ===================== field-type-def ==================== --> <!-- General Types --> - <field-type-def type="blob" sql-type="LONG VARBINARY" java-type="java.lang.Object"></field-type-def> + <field-type-def type="blob" sql-type="LONG VARBINARY" java-type="java.sql.Blob"></field-type-def> <field-type-def type="date-time" sql-type="DATE" java-type="java.sql.Timestamp"></field-type-def> <field-type-def type="date" sql-type="DATE" java-type="java.sql.Date"></field-type-def> Modified: ofbiz/trunk/framework/entity/fieldtype/fieldtypedaffodil.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/fieldtype/fieldtypedaffodil.xml?rev=587433&r1=587432&r2=587433&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/fieldtype/fieldtypedaffodil.xml (original) +++ ofbiz/trunk/framework/entity/fieldtype/fieldtypedaffodil.xml Tue Oct 23 02:52:49 2007 @@ -22,7 +22,7 @@ xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/fieldtypemodel.xsd"> <!-- ===================== field-type-def ==================== --> <!-- General Types --> - <field-type-def type="blob" sql-type="BLOB" java-type="java.lang.Object"></field-type-def> + <field-type-def type="blob" sql-type="BLOB" java-type="java.sql.Blob"></field-type-def> <field-type-def type="date-time" sql-type="TIMESTAMP" java-type="java.sql.Timestamp"></field-type-def> <field-type-def type="date" sql-type="DATE" java-type="java.sql.Date"></field-type-def> Modified: ofbiz/trunk/framework/entity/fieldtype/fieldtypederby.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/fieldtype/fieldtypederby.xml?rev=587433&r1=587432&r2=587433&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/fieldtype/fieldtypederby.xml (original) +++ ofbiz/trunk/framework/entity/fieldtype/fieldtypederby.xml Tue Oct 23 02:52:49 2007 @@ -21,8 +21,8 @@ <fieldtypemodel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/fieldtypemodel.xsd"> <!-- ===================== field-type-def ==================== --> - <!-- General Types --> - <field-type-def type="blob" sql-type="BLOB" java-type="java.lang.Object"></field-type-def> + <!-- General Types --> + <field-type-def type="blob" sql-type="BLOB" java-type="java.sql.Blob"></field-type-def> <field-type-def type="date-time" sql-type="TIMESTAMP" java-type="java.sql.Timestamp"></field-type-def> <field-type-def type="date" sql-type="DATE" java-type="java.sql.Date"></field-type-def> @@ -50,7 +50,7 @@ <field-type-def type="name" sql-type="VARCHAR(100)" java-type="String"></field-type-def> <field-type-def type="value" sql-type="VARCHAR(255)" java-type="String"></field-type-def> - <!-- Specialized Types --> + <!-- Specialized Types --> <field-type-def type="credit-card-number" sql-type="VARCHAR(255)" java-type="String"><validate method="isAnyCard" /></field-type-def> <field-type-def type="credit-card-date" sql-type="VARCHAR(20)" java-type="String"><validate method="isDateAfterToday" /></field-type-def> <field-type-def type="email" sql-type="VARCHAR(255)" java-type="String"><validate method="isEmail" /></field-type-def> @@ -59,6 +59,4 @@ <field-type-def type="id-long-ne" sql-type="VARCHAR(60)" java-type="String"><validate method="isNotEmpty" /></field-type-def> <field-type-def type="id-vlong-ne" sql-type="VARCHAR(255)" java-type="String"><validate method="isNotEmpty" /></field-type-def> <field-type-def type="tel-number" sql-type="VARCHAR(60)" java-type="String"><validate method="isInternationalPhoneNumber" /></field-type-def> - </fieldtypemodel> - Modified: ofbiz/trunk/framework/entity/fieldtype/fieldtypefirebird.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/fieldtype/fieldtypefirebird.xml?rev=587433&r1=587432&r2=587433&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/fieldtype/fieldtypefirebird.xml (original) +++ ofbiz/trunk/framework/entity/fieldtype/fieldtypefirebird.xml Tue Oct 23 02:52:49 2007 @@ -22,7 +22,7 @@ xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/fieldtypemodel.xsd"> <!-- ===================== field-type-def ==================== --> <!-- General Types --> - <field-type-def type="blob" sql-type="BLOB" java-type="java.lang.Object"></field-type-def> + <field-type-def type="blob" sql-type="BLOB" java-type="java.sql.Blob"></field-type-def> <field-type-def type="date-time" sql-type="TIMESTAMP" java-type="java.sql.Timestamp"></field-type-def> <field-type-def type="date" sql-type="DATE" java-type="java.sql.Date"></field-type-def> Modified: ofbiz/trunk/framework/entity/fieldtype/fieldtypehsql.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/fieldtype/fieldtypehsql.xml?rev=587433&r1=587432&r2=587433&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/fieldtype/fieldtypehsql.xml (original) +++ ofbiz/trunk/framework/entity/fieldtype/fieldtypehsql.xml Tue Oct 23 02:52:49 2007 @@ -21,8 +21,8 @@ <fieldtypemodel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/fieldtypemodel.xsd"> <!-- ===================== field-type-def ==================== --> - <!-- General Types --> - <field-type-def type="blob" sql-type="OBJECT" sql-type-alias="OTHER" java-type="java.lang.Object"></field-type-def> + <!-- General Types --> + <field-type-def type="blob" sql-type="OBJECT" sql-type-alias="OTHER" java-type="java.sql.Blob"></field-type-def> <field-type-def type="date-time" sql-type="TIMESTAMP" java-type="java.sql.Timestamp"></field-type-def> <field-type-def type="date" sql-type="DATE" java-type="java.sql.Date"></field-type-def> @@ -48,7 +48,7 @@ <field-type-def type="name" sql-type="VARCHAR" java-type="String"></field-type-def> <field-type-def type="value" sql-type="VARCHAR" java-type="String"></field-type-def> - <!-- Specialized Types --> + <!-- Specialized Types --> <field-type-def type="credit-card-number" sql-type="VARCHAR" java-type="String"><validate method="isAnyCard" /></field-type-def> <field-type-def type="credit-card-date" sql-type="VARCHAR" java-type="String"><validate method="isDateAfterToday" /></field-type-def> <field-type-def type="email" sql-type="VARCHAR" java-type="String"><validate method="isEmail" /></field-type-def> @@ -57,6 +57,4 @@ <field-type-def type="id-long-ne" sql-type="VARCHAR" java-type="String"><validate method="isNotEmpty" /></field-type-def> <field-type-def type="id-vlong-ne" sql-type="VARCHAR" java-type="String"><validate method="isNotEmpty" /></field-type-def> <field-type-def type="tel-number" sql-type="VARCHAR" java-type="String"><validate method="isInternationalPhoneNumber" /></field-type-def> - </fieldtypemodel> - Modified: ofbiz/trunk/framework/entity/fieldtype/fieldtypemssql.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/fieldtype/fieldtypemssql.xml?rev=587433&r1=587432&r2=587433&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/fieldtype/fieldtypemssql.xml (original) +++ ofbiz/trunk/framework/entity/fieldtype/fieldtypemssql.xml Tue Oct 23 02:52:49 2007 @@ -21,8 +21,8 @@ <fieldtypemodel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/fieldtypemodel.xsd"> <!-- ===================== field-type-def ==================== --> - <!-- General Types --> - <field-type-def type="blob" sql-type="IMAGE" java-type="java.lang.Object"></field-type-def> + <!-- General Types --> + <field-type-def type="blob" sql-type="IMAGE" java-type="java.sql.Blob"></field-type-def> <field-type-def type="date-time" sql-type="DATETIME" java-type="java.sql.Timestamp"></field-type-def> <field-type-def type="date" sql-type="DATETIME" java-type="java.sql.Date"></field-type-def> @@ -48,7 +48,7 @@ <field-type-def type="name" sql-type="VARCHAR(100)" java-type="String"></field-type-def> <field-type-def type="value" sql-type="VARCHAR(255)" java-type="String"></field-type-def> - <!-- Specialized Types --> + <!-- Specialized Types --> <field-type-def type="credit-card-number" sql-type="VARCHAR(255)" java-type="String"><validate method="isAnyCard" /></field-type-def> <field-type-def type="credit-card-date" sql-type="VARCHAR(20)" java-type="String"><validate method="isDateAfterToday" /></field-type-def> <field-type-def type="email" sql-type="VARCHAR(255)" java-type="String"><validate method="isEmail" /></field-type-def> @@ -57,5 +57,4 @@ <field-type-def type="id-long-ne" sql-type="VARCHAR(60)" java-type="String"><validate method="isNotEmpty" /></field-type-def> <field-type-def type="id-vlong-ne" sql-type="VARCHAR(250)" java-type="String"><validate method="isNotEmpty" /></field-type-def> <field-type-def type="tel-number" sql-type="VARCHAR(60)" java-type="String"><validate method="isInternationalPhoneNumber" /></field-type-def> - </fieldtypemodel> Modified: ofbiz/trunk/framework/entity/fieldtype/fieldtypemysql.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/fieldtype/fieldtypemysql.xml?rev=587433&r1=587432&r2=587433&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/fieldtype/fieldtypemysql.xml (original) +++ ofbiz/trunk/framework/entity/fieldtype/fieldtypemysql.xml Tue Oct 23 02:52:49 2007 @@ -21,8 +21,8 @@ <fieldtypemodel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/fieldtypemodel.xsd"> <!-- ===================== field-type-def ==================== --> - <!-- General Types --> - <field-type-def type="blob" sql-type="BLOB" java-type="java.lang.Object"></field-type-def> + <!-- General Types --> + <field-type-def type="blob" sql-type="BLOB" java-type="java.sql.Blob"></field-type-def> <field-type-def type="date-time" sql-type="DATETIME" java-type="java.sql.Timestamp"></field-type-def> <field-type-def type="date" sql-type="DATE" java-type="java.sql.Date"></field-type-def> @@ -48,7 +48,7 @@ <field-type-def type="name" sql-type="VARCHAR(100)" java-type="String"></field-type-def> <field-type-def type="value" sql-type="VARCHAR(255)" java-type="String"></field-type-def> - <!-- Specialized Types --> + <!-- Specialized Types --> <field-type-def type="credit-card-number" sql-type="VARCHAR(255)" java-type="String"><validate method="isAnyCard" /></field-type-def> <field-type-def type="credit-card-date" sql-type="VARCHAR(20)" java-type="String"><validate method="isDateAfterToday" /></field-type-def> <field-type-def type="email" sql-type="VARCHAR(255)" java-type="String"><validate method="isEmail" /></field-type-def> @@ -57,6 +57,4 @@ <field-type-def type="id-long-ne" sql-type="VARCHAR(60)" java-type="String"><validate method="isNotEmpty" /></field-type-def> <field-type-def type="id-vlong-ne" sql-type="VARCHAR(250)" java-type="String"><validate method="isNotEmpty" /></field-type-def> <field-type-def type="tel-number" sql-type="VARCHAR(60)" java-type="String"><validate method="isInternationalPhoneNumber" /></field-type-def> - </fieldtypemodel> - Modified: ofbiz/trunk/framework/entity/fieldtype/fieldtypeoracle.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/fieldtype/fieldtypeoracle.xml?rev=587433&r1=587432&r2=587433&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/fieldtype/fieldtypeoracle.xml (original) +++ ofbiz/trunk/framework/entity/fieldtype/fieldtypeoracle.xml Tue Oct 23 02:52:49 2007 @@ -21,8 +21,8 @@ <fieldtypemodel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/fieldtypemodel.xsd"> <!-- ===================== field-type-def ==================== --> - <!-- General Types --> - <field-type-def type="blob" sql-type="BLOB" java-type="java.lang.Object"></field-type-def> + <!-- General Types --> + <field-type-def type="blob" sql-type="BLOB" java-type="java.sql.Blob"></field-type-def> <field-type-def type="date-time" sql-type="TIMESTAMP" sql-type-alias="TIMESTAMP(6)" java-type="java.sql.Timestamp"></field-type-def> <field-type-def type="date" sql-type="DATE" java-type="java.sql.Date"></field-type-def> @@ -48,7 +48,7 @@ <field-type-def type="name" sql-type="VARCHAR2(100)" java-type="String"></field-type-def> <field-type-def type="value" sql-type="VARCHAR2(255)" java-type="String"></field-type-def> - <!-- Specialized Types --> + <!-- Specialized Types --> <field-type-def type="credit-card-number" sql-type="VARCHAR2(255)" java-type="String"><validate method="isAnyCard" /></field-type-def> <field-type-def type="credit-card-date" sql-type="VARCHAR2(20)" java-type="String"><validate method="isDateAfterToday" /></field-type-def> <field-type-def type="email" sql-type="VARCHAR2(255)" java-type="String"><validate method="isEmail" /></field-type-def> Modified: ofbiz/trunk/framework/entity/fieldtype/fieldtypepostgres.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/fieldtype/fieldtypepostgres.xml?rev=587433&r1=587432&r2=587433&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/fieldtype/fieldtypepostgres.xml (original) +++ ofbiz/trunk/framework/entity/fieldtype/fieldtypepostgres.xml Tue Oct 23 02:52:49 2007 @@ -21,8 +21,8 @@ <fieldtypemodel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/fieldtypemodel.xsd"> <!-- ===================== field-type-def ==================== --> - <!-- General Types --> - <field-type-def type="blob" sql-type="BYTEA" java-type="java.lang.Object"></field-type-def> + <!-- General Types --> + <field-type-def type="blob" sql-type="BYTEA" java-type="java.sql.Blob"></field-type-def> <field-type-def type="date-time" sql-type="TIMESTAMPTZ" java-type="java.sql.Timestamp"></field-type-def> <field-type-def type="date" sql-type="DATE" java-type="java.sql.Date"></field-type-def> @@ -48,7 +48,7 @@ <field-type-def type="name" sql-type="VARCHAR(100)" java-type="String"></field-type-def> <field-type-def type="value" sql-type="VARCHAR(255)" java-type="String"></field-type-def> - <!-- Specialized Types --> + <!-- Specialized Types --> <field-type-def type="credit-card-number" sql-type="VARCHAR(255)" java-type="String"><validate method="isAnyCard" /></field-type-def> <field-type-def type="credit-card-date" sql-type="VARCHAR(20)" java-type="String"><validate method="isDateAfterToday" /></field-type-def> <field-type-def type="email" sql-type="VARCHAR(255)" java-type="String"><validate method="isEmail" /></field-type-def> @@ -57,6 +57,4 @@ <field-type-def type="id-long-ne" sql-type="VARCHAR(60)" java-type="String"><validate method="isNotEmpty" /></field-type-def> <field-type-def type="id-vlong-ne" sql-type="VARCHAR(255)" java-type="String"><validate method="isNotEmpty" /></field-type-def> <field-type-def type="tel-number" sql-type="VARCHAR(60)" java-type="String"><validate method="isInternationalPhoneNumber" /></field-type-def> - </fieldtypemodel> - Modified: ofbiz/trunk/framework/entity/fieldtype/fieldtypesapdb.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/fieldtype/fieldtypesapdb.xml?rev=587433&r1=587432&r2=587433&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/fieldtype/fieldtypesapdb.xml (original) +++ ofbiz/trunk/framework/entity/fieldtype/fieldtypesapdb.xml Tue Oct 23 02:52:49 2007 @@ -22,7 +22,7 @@ xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/fieldtypemodel.xsd"> <!-- ===================== field-type-def ==================== --> <!-- General Types --> - <field-type-def type="blob" sql-type="LONG BYTE" sql-type-alias="LONG BYTE" java-type="java.lang.Object"></field-type-def> + <field-type-def type="blob" sql-type="LONG BYTE" sql-type-alias="LONG BYTE" java-type="java.sql.Blob"></field-type-def> <field-type-def type="date-time" sql-type="TIMESTAMP" java-type="java.sql.Timestamp"></field-type-def> <field-type-def type="date" sql-type="DATE" java-type="java.sql.Date"></field-type-def> Modified: ofbiz/trunk/framework/entity/fieldtype/fieldtypesybase.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/fieldtype/fieldtypesybase.xml?rev=587433&r1=587432&r2=587433&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/fieldtype/fieldtypesybase.xml (original) +++ ofbiz/trunk/framework/entity/fieldtype/fieldtypesybase.xml Tue Oct 23 02:52:49 2007 @@ -22,7 +22,7 @@ xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/fieldtypemodel.xsd"> <!-- ===================== field-type-def ==================== --> <!-- General Types --> - <field-type-def type="blob" sql-type="IMAGE" java-type="java.lang.Object"></field-type-def> + <field-type-def type="blob" sql-type="IMAGE" java-type="java.sql.Blob"></field-type-def> <field-type-def type="date-time" sql-type="DATETIME" java-type="Timestamp"></field-type-def> <field-type-def type="date" sql-type="DATETIME" java-type="java.sql.Date"></field-type-def> Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericEntity.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericEntity.java?rev=587433&r1=587432&r2=587433&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericEntity.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericEntity.java Tue Oct 23 02:52:49 2007 @@ -21,6 +21,8 @@ import java.io.PrintWriter; import java.io.Serializable; import java.math.BigDecimal; +import java.sql.Blob; +import java.sql.SQLException; import java.util.Collection; import java.util.Collections; import java.util.Iterator; @@ -532,7 +534,7 @@ * @param bytes The byte array to be wrapped and set */ public void setBytes(String name, byte[] bytes) { - this.set(name, new ByteWrapper(bytes)); + this.set(name, bytes); } public void setNextSeqId() { @@ -634,12 +636,24 @@ if (value == null) { return null; } - if (value instanceof ByteWrapper) { - ByteWrapper wrapper = (ByteWrapper) value; - return wrapper.getBytes(); + if (value instanceof Blob) { + try { + Blob valueBlob = (Blob) value; + return valueBlob.getBytes(1, (int) valueBlob.length()); + } catch (SQLException e) { + String errMsg = "Error getting byte[] from Blob: " + e.toString(); + Debug.logError(e, errMsg, module); + return null; + } } if (value instanceof byte[]) { return (byte[]) value; + } + if (value instanceof ByteWrapper) { + // NOTE DEJ20071022: the use of ByteWrapper is not recommended and is deprecated, only old data should be stored that way + Debug.logWarning("Found a ByteWrapper object in the database for field [" + this.getEntityName() + "." + name + "]; converting to byte[] and returning, but note that you need to update your database to unwrap these objects for future compatibility", module); + ByteWrapper wrapper = (ByteWrapper) value; + return wrapper.getBytes(); } // uh-oh, this shouldn't happen... throw new IllegalArgumentException("In call to getBytes the value is not a supported type, should be byte[] or ByteWrapper, is: " + value.getClass().getName()); Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/jdbc/SQLProcessor.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/jdbc/SQLProcessor.java?rev=587433&r1=587432&r2=587433&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/jdbc/SQLProcessor.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/jdbc/SQLProcessor.java Tue Oct 23 02:52:49 2007 @@ -737,7 +737,12 @@ if (field != null) { _ps.setBlob(_ind, field); } else { - _ps.setNull(_ind, Types.BLOB); + DatasourceInfo datasourceInfo = EntityConfigUtil.getDatasourceInfo(this.helperName); + if (datasourceInfo.useBinaryTypeForBlob) { + _ps.setNull(_ind, Types.BINARY); + } else { + _ps.setNull(_ind, Types.BLOB); + } } _ind++; } @@ -791,6 +796,28 @@ } } + _ind++; + } + + /** + * Set the next binding variable of the currently active prepared statement + * to write the serialized data of 'field' to a Blob with the given bytes. + * + * @param bytes + * + * @throws SQLException + */ + public void setBytes(byte[] bytes) throws SQLException { + if (bytes != null) { + _ps.setBytes(_ind, bytes); + } else { + DatasourceInfo datasourceInfo = EntityConfigUtil.getDatasourceInfo(this.helperName); + if (datasourceInfo.useBinaryTypeForBlob) { + _ps.setNull(_ind, Types.BINARY); + } else { + _ps.setNull(_ind, Types.BLOB); + } + } _ind++; } Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/jdbc/SqlJdbcUtil.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/jdbc/SqlJdbcUtil.java?rev=587433&r1=587432&r2=587433&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/jdbc/SqlJdbcUtil.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/jdbc/SqlJdbcUtil.java Tue Oct 23 02:52:49 2007 @@ -24,6 +24,7 @@ import java.io.ObjectInputStream; import java.io.Reader; import java.math.BigDecimal; +import java.sql.Blob; import java.sql.ResultSet; import java.sql.ResultSetMetaData; import java.sql.SQLException; @@ -35,6 +36,9 @@ import java.util.Set; import java.util.TreeSet; +import javax.sql.rowset.serial.SerialBlob; +import javax.sql.rowset.serial.SerialClob; + import javolution.util.FastMap; import org.ofbiz.base.util.Debug; @@ -543,51 +547,30 @@ case 11: Object obj = null; - InputStream binaryInput = null; byte[] fieldBytes = rs.getBytes(ind); - if (fieldBytes != null && fieldBytes.length > 0) { - binaryInput = new ByteArrayInputStream(fieldBytes); - } - - if (fieldBytes != null && fieldBytes.length <= 0) { - Debug.logWarning("Got bytes back for Object field with length: " + fieldBytes.length + " while getting value : " + curField.getName() + " [" + curField.getColName() + "] (" + ind + "): ", module); - } - - //alt 1: binaryInput = rs.getBinaryStream(ind); - //alt 2: Blob blobLocator = rs.getBlob(ind); - //if (blobLocator != null) { - // binaryInput = blobLocator.getBinaryStream(); - //} - - if (binaryInput != null) { - ObjectInputStream in = null; - try { - in = new ObjectInputStream(binaryInput); - obj = in.readObject(); - } catch (IOException ex) { - throw new GenericDataSourceException("Unable to read BLOB data from input stream while getting value : " + curField.getName() + " [" + curField.getColName() + "] (" + ind + "): " + ex.toString(), ex); - } catch (ClassNotFoundException ex) { - throw new GenericDataSourceException("Class not found: Unable to cast BLOB data to an Java object while getting value : " + curField.getName() + " [" + curField.getColName() + "] (" + ind + "): " + ex.toString(), ex); - } finally { - if (in != null) { - try { - in.close(); - } catch (IOException e) { - throw new GenericDataSourceException("Unable to close binary input stream while getting value : " + curField.getName() + " [" + curField.getColName() + "] (" + ind + "): " + e.toString(), e); - } - } - } + obj = deserializeField(fieldBytes, ind, curField); + + if (obj != null) { + entity.dangerousSetNoCheckButFast(curField, obj); + } else { + entity.dangerousSetNoCheckButFast(curField, fieldBytes); } - - binaryInput = null; - entity.dangerousSetNoCheckButFast(curField, obj); break; case 12: - entity.dangerousSetNoCheckButFast(curField, rs.getBlob(ind)); + Blob theBlob = new SerialBlob(rs.getBlob(ind)); + + // for backward compatibility, check to see if there is a serialized object and if so return that + Object blobObject = deserializeField(theBlob.getBytes(1, (int) theBlob.length()), ind, curField); + if (blobObject != null) { + entity.dangerousSetNoCheckButFast(curField, blobObject); + } else { + entity.dangerousSetNoCheckButFast(curField, theBlob); + } + break; case 13: - entity.dangerousSetNoCheckButFast(curField, rs.getClob(ind)); + entity.dangerousSetNoCheckButFast(curField, new SerialClob(rs.getClob(ind))); break; case 14: case 15: @@ -655,6 +638,50 @@ throw new GenericDataSourceException("SQL Exception while getting value : " + curField.getName() + " [" + curField.getColName() + "] (" + ind + ")", sqle); } } + + private static Object deserializeField(byte[] fieldBytes, int ind, ModelField curField) throws GenericDataSourceException { + // NOTE DEJ20071022: the following code is to convert the byte[] back into an object; if that fails + //just return the byte[]; this was for the ByteWrapper thing which is now deprecated, so this may + //be removed in the near future to enhance performance + InputStream binaryInput = null; + if (fieldBytes != null && fieldBytes.length > 0) { + binaryInput = new ByteArrayInputStream(fieldBytes); + } + + if (fieldBytes != null && fieldBytes.length <= 0) { + Debug.logWarning("Got bytes back for Object field with length: " + fieldBytes.length + " while getting value : " + curField.getName() + " [" + curField.getColName() + "] (" + ind + "): ", module); + } + + //alt 1: binaryInput = rs.getBinaryStream(ind); + //alt 2: Blob blobLocator = rs.getBlob(ind); + //if (blobLocator != null) { + // binaryInput = blobLocator.getBinaryStream(); + //} + + if (binaryInput != null) { + ObjectInputStream in = null; + try { + in = new ObjectInputStream(binaryInput); + return in.readObject(); + } catch (IOException ex) { + if (Debug.verboseOn()) Debug.logVerbose("Unable to read BLOB data from input stream while getting value : " + curField.getName() + " [" + curField.getColName() + "] (" + ind + "): " + ex.toString(), module); + return null; + } catch (ClassNotFoundException ex) { + if (Debug.verboseOn()) Debug.logVerbose("Class not found: Unable to cast BLOB data to an Java object while getting value: " + curField.getName() + " [" + curField.getColName() + "] (" + ind + "); most likely because it is a straight byte[], so just using the raw bytes" + ex.toString(), module); + return null; + } finally { + if (in != null) { + try { + in.close(); + } catch (IOException e) { + throw new GenericDataSourceException("Unable to close binary input stream while getting value : " + curField.getName() + " [" + curField.getColName() + "] (" + ind + "): " + e.toString(), e); + } + } + } + } + + return null; + } public static void setValue(SQLProcessor sqlP, ModelField modelField, GenericEntity entity, ModelFieldTypeReader modelFieldTypeReader) throws GenericEntityException { Object fieldValue = entity.dangerousGetNoCheckButFast(modelField); @@ -681,8 +708,10 @@ // this is only an info level message because under normal operation for most JDBC // drivers this will be okay, but if not then the JDBC driver will throw an exception // and when lower debug levels are on this should help give more info on what happened - Class fieldClass = fieldValue.getClass(); - String fieldClassName = fieldClass.getName(); + String fieldClassName = fieldValue.getClass().getName(); + if (fieldValue instanceof byte[]) { + fieldClassName = "byte[]"; + } if (Debug.verboseOn()) Debug.logVerbose("type of field " + entityName + "." + modelField.getName() + " is " + fieldClassName + ", was expecting " + mft.getJavaType() + "; this may " + @@ -742,7 +771,11 @@ break; case 12: - sqlP.setValue((java.sql.Blob) fieldValue); + if (fieldValue instanceof byte[]) { + sqlP.setBytes((byte[]) fieldValue); + } else { + sqlP.setValue((java.sql.Blob) fieldValue); + } break; case 13: @@ -795,6 +828,7 @@ fieldTypeMap.put("Object", new Integer(11)); fieldTypeMap.put("java.sql.Blob", new Integer(12)); fieldTypeMap.put("Blob", new Integer(12)); + fieldTypeMap.put("byte[]", new Integer(12)); fieldTypeMap.put("java.sql.Clob", new Integer(13)); fieldTypeMap.put("Clob", new Integer(13)); Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/ByteWrapper.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/ByteWrapper.java?rev=587433&r1=587432&r2=587433&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/ByteWrapper.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/ByteWrapper.java Tue Oct 23 02:52:49 2007 @@ -1,4 +1,4 @@ -/******************************************************************************* +/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -15,15 +15,19 @@ * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. - *******************************************************************************/ + */ package org.ofbiz.entity.util; import java.io.Serializable; /** + * @deprecated + * NOTE DEJ20071022: deprecating this because we want to save the byte[] directly instead of inside a serialized + * object, which makes it hard for other apps to use the data, and causes problems if this object is ever updated + * * A very simple class to wrap a byte array for persistence. */ -public class ByteWrapper implements Comparable<ByteWrapper>, Serializable { +public class ByteWrapper implements Serializable { protected byte[] bytes; protected ByteWrapper() {} @@ -42,29 +46,5 @@ public int getLength() { return bytes.length; - } - - public int compareTo(ByteWrapper other) { - int r = bytes.length - other.bytes.length; - if (r != 0) return r; - int i = 0; - for (i = 0; i < bytes.length; i++) { - r = bytes[i] - other.bytes[i]; - if (r != 0) return r; - } - return 0; - } - - public boolean equals(Object obj) { - if (obj instanceof ByteWrapper) return compareTo((ByteWrapper) obj) == 0; - return false; - } - - public int hashCode() { - int hashCode = 0; - for (byte b: bytes) { - hashCode ^= b; - } - return hashCode; } } Modified: ofbiz/trunk/framework/entityext/servicedef/services.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entityext/servicedef/services.xml?rev=587433&r1=587432&r2=587433&view=diff ============================================================================== --- ofbiz/trunk/framework/entityext/servicedef/services.xml (original) +++ ofbiz/trunk/framework/entityext/servicedef/services.xml Tue Oct 23 02:52:49 2007 @@ -145,6 +145,14 @@ <attribute name="records" type="Integer" mode="OUT" optional="false"/> </service> + <!-- data updates services --> + <service name="unwrapByteWrappers" engine="java" auth="true" transaction-timeout="14400" require-new-transaction="true" + location="org.ofbiz.entityext.data.EntityDataServices" invoke="unwrapByteWrappers"> + <description>Unwrap ByteWrapper Fields for the given entity and field</description> + <attribute name="entityName" type="String" mode="IN" optional="false"/> + <attribute name="fieldName" type="String" mode="IN" optional="false"/> + </service> + <!-- EntitySync Services --> <service name="createEntitySync" default-entity-name="EntitySync" engine="simple" location="org/ofbiz/entityext/synchronization/EntitySyncServices.xml" invoke="createEntitySync" auth="true"> Modified: ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/data/EntityDataServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/data/EntityDataServices.java?rev=587433&r1=587432&r2=587433&view=diff ============================================================================== --- ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/data/EntityDataServices.java (original) +++ ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/data/EntityDataServices.java Tue Oct 23 02:52:49 2007 @@ -24,10 +24,12 @@ import org.ofbiz.service.GenericServiceException; import org.ofbiz.security.Security; import org.ofbiz.entity.GenericDelegator; +import org.ofbiz.entity.GenericEntityException; import org.ofbiz.entity.GenericValue; import org.ofbiz.entity.jdbc.DatabaseUtil; import org.ofbiz.entity.model.ModelEntity; import org.ofbiz.entity.model.ModelField; +import org.ofbiz.entity.util.EntityListIterator; import org.ofbiz.base.util.GeneralException; import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.UtilURL; @@ -444,5 +446,39 @@ Map result = ServiceUtil.returnSuccess(); result.put("messages", messages); return result; + } + + public static Map unwrapByteWrappers(DispatchContext dctx, Map context) { + GenericDelegator delegator = dctx.getDelegator(); + String entityName = (String) context.get("entityName"); + String fieldName = (String) context.get("fieldName"); + + EntityListIterator eli = null; + try { + eli = delegator.findListIteratorByCondition(entityName, null, null, null); + GenericValue currentValue; + while ((currentValue = eli.next()) != null) { + byte[] bytes = currentValue.getBytes(fieldName); + if (bytes != null) { + currentValue.setBytes(fieldName, bytes); + currentValue.store(); + } + } + } catch (GenericEntityException e) { + String errMsg = "Error unwrapping ByteWrapper records: " + e.toString(); + Debug.logError(e, errMsg, module); + return ServiceUtil.returnError(errMsg); + } finally { + if (eli != null) { + try { + eli.close(); + } catch (GenericEntityException e) { + String errMsg = "Error closing EntityListIterator: " + e.toString(); + Debug.logError(e, errMsg, module); + } + } + } + + return ServiceUtil.returnSuccess(); } } Modified: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/ServiceEventHandler.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/ServiceEventHandler.java?rev=587433&r1=587432&r2=587433&view=diff ============================================================================== --- ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/ServiceEventHandler.java (original) +++ ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/ServiceEventHandler.java Tue Oct 23 02:52:49 2007 @@ -19,6 +19,7 @@ package org.ofbiz.webapp.event; import java.io.File; +import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -33,8 +34,9 @@ import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; +import javolution.util.FastMap; + import org.apache.commons.fileupload.FileItem; -import org.apache.commons.fileupload.FileUpload; import org.apache.commons.fileupload.FileUploadException; import org.apache.commons.fileupload.disk.DiskFileItemFactory; import org.apache.commons.fileupload.servlet.ServletFileUpload; @@ -44,7 +46,6 @@ import org.ofbiz.base.util.UtilProperties; import org.ofbiz.base.util.UtilValidate; import org.ofbiz.entity.GenericValue; -import org.ofbiz.entity.util.ByteWrapper; import org.ofbiz.service.DispatchContext; import org.ofbiz.service.GenericServiceException; import org.ofbiz.service.LocalDispatcher; @@ -146,7 +147,7 @@ String encoding = request.getCharacterEncoding(); // check for multipart content types which may have uploaded items boolean isMultiPart = ServletFileUpload.isMultipartContent(request); - Map multiPartMap = new HashMap(); + Map multiPartMap = FastMap.newInstance(); if (isMultiPart) { ServletFileUpload upload = new ServletFileUpload(new DiskFileItemFactory(sizeThreshold, new File(tmpUploadRepository))); if (encoding != null) { @@ -207,7 +208,7 @@ fileName = fileName.substring(lastIndex + 1); } } - multiPartMap.put(fieldName, new ByteWrapper(item.get())); + multiPartMap.put(fieldName, ByteBuffer.wrap(item.get())); multiPartMap.put("_" + fieldName + "_size", new Long(item.getSize())); multiPartMap.put("_" + fieldName + "_fileName", fileName); multiPartMap.put("_" + fieldName + "_contentType", item.getContentType()); Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java?rev=587433&r1=587432&r2=587433&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java Tue Oct 23 02:52:49 2007 @@ -625,8 +625,16 @@ if ((Boolean.TRUE.equals(isError) && !Boolean.FALSE.equals(useRequestParameters)) || (Boolean.TRUE.equals(useRequestParameters))) { //Debug.logInfo("Getting entry, isError true so getting from parameters for field " + this.getName() + " of form " + this.modelForm.getName(), module); Map parameters = (Map) context.get("parameters"); - if (parameters != null && parameters.get(this.getParameterName(context)) != null) { - return (String) parameters.get(this.getParameterName(context)); + String parameterName = this.getParameterName(context); + if (parameters != null && parameters.get(parameterName) != null) { + Object parameterValue = parameters.get(parameterName); + if (parameterValue instanceof String) { + return (String) parameterValue; + } else { + // we might want to do something else here in the future, but for now this is probably best + Debug.logWarning("Found a non-String parameter value for field [" + this.getModelForm().getName() + "." + this.getFieldName() + "]", module); + return defaultValue; + } } else { return defaultValue; } |
Free forum by Nabble | Edit this page |