svn commit: r1345547 - /ofbiz/trunk/applications/product/src/org/ofbiz/product/promo/PromoServices.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1345547 - /ofbiz/trunk/applications/product/src/org/ofbiz/product/promo/PromoServices.java

jleroux@apache.org
Author: jleroux
Date: Sat Jun  2 18:47:41 2012
New Revision: 1345547

URL: http://svn.apache.org/viewvc?rev=1345547&view=rev
Log:
A patch from Nandani Aggarwal "Upload file throws java.lang.ClassCastException: java.nio.HeapByteBuffer" https://issues.apache.org/jira/browse/OFBIZ-4919

While creating Promo under catalog in Admin , we create Promo Code so that party or Email can be attached to Promo and also there we can set expiry date for that Promo.While uploading list of Email Ids for which Promo will be applicable,,i encountered with error : java.lang.ClassCasrrException:java.nio.HeapByteBuffer.
Error can be reproduced by following link :
https://localhost:8443/catalog/control/createBulkProductPromoCodeEmail?productPromoCodeId="Name of : Product Promo Code Id"
Or with help of attached screenshot.


Modified:
    ofbiz/trunk/applications/product/src/org/ofbiz/product/promo/PromoServices.java

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=1345547&r1=1345546&r2=1345547&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 Sat Jun  2 18:47:41 2012
@@ -234,18 +234,21 @@ public class PromoServices {
     }
 
     public static Map<String, Object> importPromoCodeEmailsFromFile(DispatchContext dctx, Map<String, ? extends Object> context) {
-        LocalDispatcher dispatcher = dctx.getDispatcher();
+       LocalDispatcher dispatcher = dctx.getDispatcher();
         String productPromoCodeId = (String) context.get("productPromoCodeId");
-        byte[] wrapper = (byte[]) context.get("uploadedFile");
         GenericValue userLogin = (GenericValue) context.get("userLogin");
         Locale locale = (Locale) context.get("locale");
-
-        if (wrapper == null) {
+      
+        ByteBuffer bytebufferwrapper = (ByteBuffer) context.get("uploadedFile");
+    
+        if (bytebufferwrapper == null) {
             return ServiceUtil.returnError(UtilProperties.getMessage(resource,
                     "ProductPromoCodeImportUploadedFileNotValid", locale));
         }
 
-        // read the bytes into a reader
+        byte[] wrapper =  bytebufferwrapper.array();
+      
+      // read the bytes into a reader
         BufferedReader reader = new BufferedReader(new StringReader(new String(wrapper)));
         List<Object> errors = FastList.newInstance();
         int lines = 0;