svn commit: r1817643 - /ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/spreadsheetimport/ImportProductServices.java

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

svn commit: r1817643 - /ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/spreadsheetimport/ImportProductServices.java

mbrohl
Author: mbrohl
Date: Sat Dec  9 17:55:14 2017
New Revision: 1817643

URL: http://svn.apache.org/viewvc?rev=1817643&view=rev
Log:
Improved: Fixing defects reported by FindBugs, package
org.apache.ofbiz.product.spreadsheetimport.
(OFBIZ-9784)

Thanks Dennis Balkir for reporting and providing the patch.

Modified:
    ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/spreadsheetimport/ImportProductServices.java

Modified: ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/spreadsheetimport/ImportProductServices.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/spreadsheetimport/ImportProductServices.java?rev=1817643&r1=1817642&r2=1817643&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/spreadsheetimport/ImportProductServices.java (original)
+++ ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/spreadsheetimport/ImportProductServices.java Sat Dec  9 17:55:14 2017
@@ -44,7 +44,7 @@ import org.apache.poi.poifs.filesystem.P
 
 public class ImportProductServices {
 
-    public static String module = ImportProductServices.class.getName();
+    public static final String module = ImportProductServices.class.getName();
     public static final String resource = "ProductUiLabels";
     
     /**
@@ -75,8 +75,12 @@ public class ImportProductServices {
                 File[] files = importDir.listFiles();
                 // loop for all the containing xls file in the spreadsheet
                 // directory
+                if (files == null) {
+                    return ServiceUtil.returnError(UtilProperties.getMessage(resource,
+                            "FileFilesIsNull", locale));
+                }
                 for (int i = 0; i < files.length; i++) {
-                    if (files[i].getName().toUpperCase().endsWith("XLS")) {
+                    if (files[i].getName().toUpperCase(Locale.getDefault()).endsWith("XLS")) {
                         fileItems.add(files[i]);
                     }
                 }
@@ -131,7 +135,7 @@ public class ImportProductServices {
                     // too.
                     boolean productExists = ImportProductHelper.checkProductExists(productId, delegator);
 
-                    if (productId != null && !productId.trim().equalsIgnoreCase("") && !productExists) {
+                    if (!productId.trim().equalsIgnoreCase("") && !productExists) {
                         products.add(ImportProductHelper.prepareProduct(productId));
                         if (quantityOnHand.compareTo(BigDecimal.ZERO) >= 0)
                             inventoryItems.add(ImportProductHelper.prepareInventoryItem(productId, quantityOnHand,
@@ -141,7 +145,7 @@ public class ImportProductServices {
                                     .getNextSeqId("InventoryItem")));
                     }
                     int rowNum = row.getRowNum() + 1;
-                    if (row.toString() != null && !row.toString().trim().equalsIgnoreCase("") && productExists) {
+                    if (!row.toString().trim().equalsIgnoreCase("") && productExists) {
                         Debug.logWarning("Row number " + rowNum + " not imported from " + item.getName(), module);
                     }
                 }