details: https://code.openbravo.com/erp/devel/pi/rev/7b67971d79d2 changeset: 26200:7b67971d79d2 user: Asier Lostalé <asier.lostale <at> openbravo.com> date: Wed Mar 18 09:08:59 2015 +0100 summary: fixed bug 29313: attachment download of different records at once fails
It generated an invalid zip file. The problem was it tried to find the attachment directory based on the whole list of ids to download instead of splitting it. details: https://code.openbravo.com/erp/devel/pi/rev/bb2fdcffc429 changeset: 26201:bb2fdcffc429 user: Asier Lostalé <asier.lostale <at> openbravo.com> date: Wed Mar 18 09:10:10 2015 +0100 summary: related to bug 29313: code cleanup removed unneeded code details: https://code.openbravo.com/erp/devel/pi/rev/fe1d0d1cf4ba changeset: 26202:fe1d0d1cf4ba user: Asier Lostalé <asier.lostale <at> openbravo.com> date: Wed Mar 18 09:26:06 2015 +0100 summary: fixed bug 29326: multi record attachment download does not check org access When downloading attachemnts from different records at once, attachment's record's organization was not checked to be accessible. The problem was it tried to get a single record with id as concatenation of all ids. The fix iterates over all the records and check org access for each of them individually. diffstat: src/org/openbravo/erpCommon/businessUtility/TabAttachments.java | 14 +++++----- 1 files changed, 7 insertions(+), 7 deletions(-) diffs (39 lines): diff -r be3f7a8bed0a -r fe1d0d1cf4ba src/org/openbravo/erpCommon/businessUtility/TabAttachments.java --- a/src/org/openbravo/erpCommon/businessUtility/TabAttachments.java Tue Mar 17 23:03:03 2015 +0000 +++ b/src/org/openbravo/erpCommon/businessUtility/TabAttachments.java Wed Mar 18 09:26:06 2015 +0100 @@ -270,16 +270,17 @@ try { String tabId = vars.getStringParameter("tabId"); String recordIds = vars.getStringParameter("recordIds"); - String buttonId = vars.getStringParameter("buttonId"); Tab tab = OBDal.getInstance().get(Tab.class, tabId); String tableId = (String) DalUtil.getId(tab.getTable()); // Checks if the user has readable access to the record where the file is attached Entity entity = ModelProvider.getInstance().getEntityByTableId(tableId); if (entity != null) { - Object object = OBDal.getInstance().get(entity.getMappingClass(), recordIds); - if (object instanceof OrganizationEnabled) { - SecurityChecker.getInstance().checkReadableAccess((OrganizationEnabled) object); + for (String recordId : recordIds.split(",")) { + Object object = OBDal.getInstance().get(entity.getMappingClass(), recordId); + if (object instanceof OrganizationEnabled) { + SecurityChecker.getInstance().checkReadableAccess((OrganizationEnabled) object); + } } } @@ -290,11 +291,10 @@ response.setContentType("application/zip"); response.setHeader("Content-Disposition", "attachment; filename=attachments.zip"); final ZipOutputStream dest = new ZipOutputStream(response.getOutputStream()); - attachmentFiles.list().toArray(); HashMap<String, Integer> writtenFiles = new HashMap<String, Integer>(); for (Attachment attachmentFile : attachmentFiles.list()) { - String attachmentDirectory = TabAttachments.getAttachmentDirectory(tableId, recordIds, - attachmentFile.getName()); + String attachmentDirectory = TabAttachments.getAttachmentDirectory(tableId, + attachmentFile.getRecord(), attachmentFile.getName()); final File file = new File(globalParameters.strFTPDirectory + "/" + attachmentDirectory, attachmentFile.getName()); String zipName = ""; ------------------------------------------------------------------------------ Dive into the World of Parallel Programming The Go Parallel Website, sponsored by Intel and developed in partnership with Slashdot Media, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials and more. Take a look and join the conversation now. http://goparallel.sourceforge.net/ _______________________________________________ Openbravo-commits mailing list Openbravo-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbravo-commits