Author: jleroux
Date: Sun Jun 22 09:52:04 2014
New Revision: 1604558
URL:
http://svn.apache.org/r1604558Log:
"Applied fix from trunk for revision: 1604554"
------------------------------------------------------------------------
r1604554 | jleroux | 2014-06-22 11:18:39 +0200 (dim. 22 juin 2014) | 7 lignes
A proposed fix by chunlinyao for "checkExistsImage method in ImageManagementServices" at
https://issues.apache.org/jira/browse/OFBIZ-5658I think indexOf(".") in these code should be lastIndexOf(".").
From CATALOG -> Image Management -> Upload view. upload some Images it will call this method. This method is intended to add (count) to the image name, when the file name was already exist. I debugged in it, the imagePath was the absolute path of the image file. So If any parent folder name contains "." , it will not works correctly.
chunlinyao's Note: And after review the whole ImageManagementServices.java file. I found it use static variables (ex. imageCount imagePath). It is not thread safe.
------------------------------------------------------------------------
Modified:
ofbiz/branches/release11.04/ (props changed)
ofbiz/branches/release11.04/applications/product/src/org/ofbiz/product/imagemanagement/ImageManagementServices.java
Propchange: ofbiz/branches/release11.04/
------------------------------------------------------------------------------
Merged /ofbiz/trunk:r1604554
Modified: ofbiz/branches/release11.04/applications/product/src/org/ofbiz/product/imagemanagement/ImageManagementServices.java
URL:
http://svn.apache.org/viewvc/ofbiz/branches/release11.04/applications/product/src/org/ofbiz/product/imagemanagement/ImageManagementServices.java?rev=1604558&r1=1604557&r2=1604558&view=diff==============================================================================
--- ofbiz/branches/release11.04/applications/product/src/org/ofbiz/product/imagemanagement/ImageManagementServices.java (original)
+++ ofbiz/branches/release11.04/applications/product/src/org/ofbiz/product/imagemanagement/ImageManagementServices.java Sun Jun 22 09:52:04 2014
@@ -795,8 +795,8 @@ public class ImageManagementServices {
return file;
}
imageCount++;
- String filePath = imagePath.substring(0, imagePath.indexOf("."));
- String type = imagePath.substring(imagePath.indexOf(".") + 1);
+ String filePath = imagePath.substring(0, imagePath.lastIndexOf("."));
+ String type = imagePath.substring(imagePath.lastIndexOf(".") + 1);
file = new File(filePath + "(" + imageCount + ")." + type);
return checkExistsImage(file);
}