branch feature/1221 created (now c452ceb)
This is an automated email from the git hooks/post-receive script. New change to branch feature/1221 in repository lima. See http://git.chorem.org/lima.git at c452ceb fixes #1221 : ne pas traiter l'inmport/export si aucun fichier n'est renvoyé This branch includes the following new commits: new c452ceb fixes #1221 : ne pas traiter l'inmport/export si aucun fichier n'est renvoyé The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit c452ceb176985d8d410098babe1b5ae3818996fa Author: Sylvain Bavencoff <bavencoff@codelutin.com> Date: Tue Mar 31 17:12:08 2015 +0200 fixes #1221 : ne pas traiter l'inmport/export si aucun fichier n'est renvoyé -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/1221 in repository lima. See http://git.chorem.org/lima.git commit c452ceb176985d8d410098babe1b5ae3818996fa Author: Sylvain Bavencoff <bavencoff@codelutin.com> Date: Tue Mar 31 17:12:08 2015 +0200 fixes #1221 : ne pas traiter l'inmport/export si aucun fichier n'est renvoyé --- .../chorem/lima/ui/importexport/ImportExport.java | 59 ++++++++++++---------- 1 file changed, 33 insertions(+), 26 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..e64650a 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,19 +140,21 @@ 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); } - } - processImportExport(verbose, importExportChoice, defaultCharset, exportPath, importUrl); + } } public void processImportExport(final ImportExportEnum importExportChoice, boolean verbose) { @@ -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>.
participants (1)
-
chorem.org scm