svn commit: r819275 - /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: r819275 - /ofbiz/trunk/applications/product/src/org/ofbiz/product/promo/PromoServices.java

jleroux@apache.org
Author: jleroux
Date: Sun Sep 27 08:57:11 2009
New Revision: 819275

URL: http://svn.apache.org/viewvc?rev=819275&view=rev
Log:
Fix an issue when importing Promo Codes From File

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=819275&r1=819274&r2=819275&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 Sun Sep 27 08:57:11 2009
@@ -40,6 +40,8 @@
 import java.sql.Timestamp;
 import java.util.List;
 import java.util.Map;
+import java.nio.ByteBuffer;
+import java.nio.charset.Charset;
 
 /**
  * Promotions Services
@@ -112,11 +114,13 @@
         LocalDispatcher dispatcher = dctx.getDispatcher();
 
         // check the uploaded file
-        byte[] wrapper = (byte[]) context.get("uploadedFile");
-        if (wrapper == null) {
+        ByteBuffer fileBytes = (ByteBuffer) context.get("uploadedFile");
+        if (fileBytes == null) {
             return ServiceUtil.returnError("Uploaded file not valid or corrupted");
         }
 
+        String encoding = System.getProperty("file.encoding");
+        String file = Charset.forName(encoding).decode(fileBytes).toString();        
         // get the createProductPromoCode Model
         ModelService promoModel;
         try {
@@ -130,7 +134,7 @@
         Map<String, Object> invokeCtx = promoModel.makeValid(context, ModelService.IN_PARAM);
 
         // read the bytes into a reader
-        BufferedReader reader = new BufferedReader(new StringReader(new String(wrapper)));
+        BufferedReader reader = new BufferedReader(new StringReader(file));
         List<Object> errors = FastList.newInstance();
         int lines = 0;
         String line;