From 814016b2fc2ba551d5d3901c0be5de90f28c2a61 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Tue, 20 Mar 2018 17:35:43 -0300 Subject: [PATCH] IDEMPIERE-3660 Improve Packin - allow application on all tenants / manage properly non-readable zip files --- .../pipo/srv/PipoDictionaryService.java | 4 ++++ .../utils/PackInApplicationActivator.java | 19 ++++++++++++------- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/org.adempiere.pipo/src/org/adempiere/pipo/srv/PipoDictionaryService.java b/org.adempiere.pipo/src/org/adempiere/pipo/srv/PipoDictionaryService.java index 31ad2fcf85..18f79c12d3 100644 --- a/org.adempiere.pipo/src/org/adempiere/pipo/srv/PipoDictionaryService.java +++ b/org.adempiere.pipo/src/org/adempiere/pipo/srv/PipoDictionaryService.java @@ -42,6 +42,10 @@ public class PipoDictionaryService implements IDictionaryService { logger.info("No PackIn Model found"); return; } + if (! packageFile.canRead()) { + logger.severe("Cannot read file " + packageFile.getName()); + return; + } String symbolicName = "org.adempiere.pipo"; if (context != null) symbolicName = context.getBundle().getSymbolicName(); diff --git a/org.adempiere.plugin.utils/src/org/adempiere/plugin/utils/PackInApplicationActivator.java b/org.adempiere.plugin.utils/src/org/adempiere/plugin/utils/PackInApplicationActivator.java index 5158cd9814..1619cf7b6d 100644 --- a/org.adempiere.plugin.utils/src/org/adempiere/plugin/utils/PackInApplicationActivator.java +++ b/org.adempiere.plugin.utils/src/org/adempiere/plugin/utils/PackInApplicationActivator.java @@ -299,7 +299,7 @@ public class PackInApplicationActivator extends AbstractActivator { for (String filePath : filePaths) { File toProcess = new File(filePath.trim()); if (!toProcess.exists()) { - logger.log(Level.SEVERE, filePath + " does not exist"); + addLog(Level.SEVERE, filePath + " does not exist"); continue; } @@ -322,14 +322,14 @@ public class PackInApplicationActivator extends AbstractActivator { } private void processFilePath(File toProcess) { - if (toProcess.isFile()) { + if (toProcess.isFile() && toProcess.canRead()) { if (toProcess.getName().toLowerCase().endsWith(".zip")) filesToProcess.add(toProcess); else { logger.log(Level.SEVERE, toProcess.getName() + " is not a valid .zip file"); return; } - } else if (toProcess.isDirectory()) { + } else if (toProcess.isDirectory() && toProcess.canRead()) { FileFilter filter = new FileFilter() { public boolean accept(File file) { if (file.getName().toUpperCase().endsWith(".ZIP") || file.isDirectory()) @@ -344,17 +344,22 @@ public class PackInApplicationActivator extends AbstractActivator { logger.info("*** Creating list from folder " + toProcess.toString()); found = true; } - if (fileToProcess.isDirectory()) + if (fileToProcess.isDirectory()) { processFilePath(fileToProcess); - else - filesToProcess.add(fileToProcess); + } else { + if (fileToProcess.canRead()) { + filesToProcess.add(fileToProcess); + } else { + addLog(Level.SEVERE, fileToProcess.getName() + " not readable"); + } + } } if (!found) { logger.log(Level.FINE, toProcess.getName() + " does not have .zip files or subfolders"); return; } } else { - logger.log(Level.SEVERE, toProcess.getName() + " not a file or folder"); + addLog(Level.SEVERE, toProcess.getName() + " not a file or folder or not readable"); } }