This is an automated email from the git hooks/post-receive script. New commit to branch feature/1176 in repository lima. See http://git.chorem.org/lima.git commit 94b81e09fc6d96b4152ee53a786c7b4f998c5c3a Author: Tony CHEMIT <chemit@codelutin.com> Date: Wed Apr 8 09:30:34 2015 +0200 refs #1221: Erreur à l'annulation des import/export --- .../chorem/lima/ui/importexport/ImportExport.java | 55 ++++++++++++---------- 1 file changed, 31 insertions(+), 24 deletions(-) diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExport.java b/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExport.java index d0c4de2..8ab4506 100644 --- a/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExport.java +++ b/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExport.java @@ -140,15 +140,17 @@ public class ImportExport { final Charset defaultCharset = Charsets.UTF_8; if (Strings.isNullOrEmpty(exportPath) && importUrl == null) { exportPath = chooseFile(importExportChoice.getImportMode(), importExportChoice); - File file = new File(exportPath); - if (file.exists()) { - try { - importUrl = file.toURI().toURL(); - } catch (MalformedURLException e) { - throw new LimaTechnicalException("Can't open file " + exportPath); + if (exportPath != null) { // if null ==> cancel import/export + File file = new File(exportPath); + if (file.exists()) { + try { + importUrl = file.toURI().toURL(); + } catch (MalformedURLException e) { + throw new LimaTechnicalException("Can't open file " + exportPath); + } + } else { + throw new LimaTechnicalException("Can't open file from path" + exportPath); } - } else { - throw new LimaTechnicalException("Can't open file from path" + exportPath); } } processImportExport(verbose, importExportChoice, defaultCharset, exportPath, importUrl); @@ -189,27 +191,32 @@ public class ImportExport { final Charset defaultCharset = Charsets.UTF_8; URL importFileUrl; String importFilePath = chooseFile(importExportChoice.getImportMode(), importExportChoice); - File file = new File(importFilePath); - if (file.exists()) { - try { - importFileUrl = file.toURI().toURL(); - } catch (MalformedURLException e) { - throw new LimaTechnicalException("Can't open file " + importFilePath); + if (importFilePath != null) { // if null ==> cancel import + File file = new File(importFilePath); + if (file.exists()) { + try { + importFileUrl = file.toURI().toURL(); + } catch (MalformedURLException e) { + throw new LimaTechnicalException("Can't open file " + importFilePath); + } + } else { + throw new LimaTechnicalException("Can't open file from path" + importFilePath); } - } else { - throw new LimaTechnicalException("Can't open file from path" + importFilePath); + log.info("Precessing import:" + importFileUrl.getPath() + " " + importFilePath + " " + importFileUrl.getFile()); + processImportExport(verbose, importExportChoice, defaultCharset, null, importFileUrl); } - log.info("Precessing import:" + importFileUrl.getPath() + " " + importFilePath + " " + importFileUrl.getFile()); - processImportExport(verbose, importExportChoice, defaultCharset, null, importFileUrl); } protected void processExport(final ImportExportEnum importExportChoice, boolean verbose) { String exportFilePath = chooseFile(importExportChoice.getImportMode(), importExportChoice); - if (StringUtils.isNotBlank(exportFilePath)) { - log.info("Precessing export:" + exportFilePath); - processImportExport(verbose, importExportChoice, Charsets.UTF_8, exportFilePath, null); - } else { - throw new LimaTechnicalException("Targeted directory can not be found."); + if (exportFilePath != null) { // if null ==> cancel export + File file = new File(exportFilePath); + if (file.exists()) { + log.info("Precessing export:" + exportFilePath); + processImportExport(verbose, importExportChoice, Charsets.UTF_8, exportFilePath, null); + } else { + throw new LimaTechnicalException("Targeted directory can not be found."); + } } } @@ -500,7 +507,7 @@ public class ImportExport { * @return the targeted file path */ public String chooseFile(Boolean importMode, ImportExportEnum importExportMethod) { - String filePath = ""; + String filePath = null; JFileChooser chooser = new JFileChooser(); //Encoding option -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.