fixed bug 29329: can't download attachments for 2 rows with same name & no ext
authorAsier Lostalé <asier.lostale@openbravo.com>
Wed, 18 Mar 2015 10:50:25 +0100
changeset 26205 e7c1d9e51ba8
parent 26204 f400d595dc52
child 26206 0e985fcaf97d
fixed bug 29329: can't download attachments for 2 rows with same name & no ext

When trying to download at once attachemnts for different records that have the
same name and it does not have extension, it fails.

The problem is in case of duplicated names to be included within the zipped file,
a number is appended to the file name before the extension. Extesion is present
is assumed, failing if not.

Fix: don't assume file name has extension.
src/org/openbravo/erpCommon/businessUtility/TabAttachments.java
--- a/src/org/openbravo/erpCommon/businessUtility/TabAttachments.java	Tue Mar 17 20:08:08 2015 +0100
+++ b/src/org/openbravo/erpCommon/businessUtility/TabAttachments.java	Wed Mar 18 10:50:25 2015 +0100
@@ -304,6 +304,10 @@
         } else {
           int num = writtenFiles.get(file.getName()) + 1;
           int indDot = file.getName().lastIndexOf(".");
+          if (indDot == -1) {
+            // file has no extension
+            indDot = file.getName().length();
+          }
           zipName = file.getName().substring(0, indDot) + " (" + num + ")"
               + file.getName().substring(indDot);
           writtenFiles.put(file.getName(), new Integer(num));