details: https://code.openbravo.com/erp/devel/pi/rev/b3dfa72fa77f changeset: 26273:b3dfa72fa77f user: Naroa Iriarte <naroa.iriarte <at> openbravo.com> date: Thu Mar 26 13:59:54 2015 +0100 summary: Fixed issue 29427: Modifiying the object of the enum ExportType is allowed.
The problem is that with the method getExportParemeters of the enum class ExportType, it is possible to get those parameters in the Hasmap and after that, modify the object with the method "put". This should not be allowed because this object belongs to an enum and all the instances have to share the same object, we don't want to allow the modification of it. For fixing this, an instance of the hashmap is done for making sure that if this method is called, it is only accessing to the parameters of the current Map instance. details: https://code.openbravo.com/erp/devel/pi/rev/72aaa6991580 changeset: 26274:72aaa6991580 user: Naroa Iriarte <naroa.iriarte <at> openbravo.com> date: Thu Mar 26 11:02:48 2015 +0100 summary: Fixed issue 29412:It is not possible to use the new reporting class everywere. The problem was that calling the methods of the "ExportType" class inside the "ReportingUtils" class from some parts of the code (the old code) was not working properly. The problem was that it was needed to have the AdminMode set to true to access to a table which was accessed in the constructor of the "ExportType" class. The new code has the AdminMode set to true, that is why it works. But in the old code it was not. For fixing this, the AdminMode has been set to true inside the constructor of the "ExportType" class itself. It is needed for the download of the report. Other change that has been made is changing the type of the variable filetype, now it is String. This is for saving memory. It has been taken into account to the fact of having a different type of report in the future. This has been handled with the "fileType = "application/" + extension" code. Now new extensions will be supported. Now whereever one calls those methods, it works properly. diffstat: modules/org.openbravo.client.application/src/org/openbravo/client/application/report/ReportingUtils.java | 21 ++++++++- 1 files changed, 17 insertions(+), 4 deletions(-) diffs (45 lines): diff -r 088b4114ac74 -r 72aaa6991580 modules/org.openbravo.client.application/src/org/openbravo/client/application/report/ReportingUtils.java --- a/modules/org.openbravo.client.application/src/org/openbravo/client/application/report/ReportingUtils.java Thu Mar 26 15:21:18 2015 +0100 +++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/report/ReportingUtils.java Thu Mar 26 11:02:48 2015 +0100 @@ -228,12 +228,22 @@ } }); private final String extension; - private final FileType fileType; + private final String fileType; private final Map<String, Object> params; ExportType(String extension, String strFileTypeId, Map<String, Object> params) { this.extension = extension; - this.fileType = OBDal.getInstance().get(FileType.class, strFileTypeId); + OBContext.setAdminMode(true); + try { + FileType type = OBDal.getInstance().get(FileType.class, strFileTypeId); + if (type != null) { + fileType = type.getFormat(); + } else { + fileType = "application/" + extension; + } + } finally { + OBContext.restorePreviousMode(); + } this.params = params; } @@ -242,11 +252,14 @@ } public String getContentType() { - return fileType.getFormat(); + return fileType; } public Map<String, Object> getExportParameters() { - return params; + // An instance of the Map is done for making sure + // that if this method is called, it is only accessing + // to the parameters of the current Map instance. + return new HashMap<String, Object>(params); } /** ------------------------------------------------------------------------------ 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 [email protected] https://lists.sourceforge.net/lists/listinfo/openbravo-commits
