IDEMPIERE-3660 Improve Packin - allow application on all tenants / manage properly non-readable zip files

This commit is contained in:
Carlos Ruiz 2018-03-20 17:35:43 -03:00
parent 577859f63e
commit 814016b2fc
2 changed files with 16 additions and 7 deletions

View File

@ -42,6 +42,10 @@ public class PipoDictionaryService implements IDictionaryService {
logger.info("No PackIn Model found"); logger.info("No PackIn Model found");
return; return;
} }
if (! packageFile.canRead()) {
logger.severe("Cannot read file " + packageFile.getName());
return;
}
String symbolicName = "org.adempiere.pipo"; String symbolicName = "org.adempiere.pipo";
if (context != null) if (context != null)
symbolicName = context.getBundle().getSymbolicName(); symbolicName = context.getBundle().getSymbolicName();

View File

@ -299,7 +299,7 @@ public class PackInApplicationActivator extends AbstractActivator {
for (String filePath : filePaths) { for (String filePath : filePaths) {
File toProcess = new File(filePath.trim()); File toProcess = new File(filePath.trim());
if (!toProcess.exists()) { if (!toProcess.exists()) {
logger.log(Level.SEVERE, filePath + " does not exist"); addLog(Level.SEVERE, filePath + " does not exist");
continue; continue;
} }
@ -322,14 +322,14 @@ public class PackInApplicationActivator extends AbstractActivator {
} }
private void processFilePath(File toProcess) { private void processFilePath(File toProcess) {
if (toProcess.isFile()) { if (toProcess.isFile() && toProcess.canRead()) {
if (toProcess.getName().toLowerCase().endsWith(".zip")) if (toProcess.getName().toLowerCase().endsWith(".zip"))
filesToProcess.add(toProcess); filesToProcess.add(toProcess);
else { else {
logger.log(Level.SEVERE, toProcess.getName() + " is not a valid .zip file"); logger.log(Level.SEVERE, toProcess.getName() + " is not a valid .zip file");
return; return;
} }
} else if (toProcess.isDirectory()) { } else if (toProcess.isDirectory() && toProcess.canRead()) {
FileFilter filter = new FileFilter() { FileFilter filter = new FileFilter() {
public boolean accept(File file) { public boolean accept(File file) {
if (file.getName().toUpperCase().endsWith(".ZIP") || file.isDirectory()) 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()); logger.info("*** Creating list from folder " + toProcess.toString());
found = true; found = true;
} }
if (fileToProcess.isDirectory()) if (fileToProcess.isDirectory()) {
processFilePath(fileToProcess); processFilePath(fileToProcess);
else } else {
if (fileToProcess.canRead()) {
filesToProcess.add(fileToProcess); filesToProcess.add(fileToProcess);
} else {
addLog(Level.SEVERE, fileToProcess.getName() + " not readable");
}
}
} }
if (!found) { if (!found) {
logger.log(Level.FINE, toProcess.getName() + " does not have .zip files or subfolders"); logger.log(Level.FINE, toProcess.getName() + " does not have .zip files or subfolders");
return; return;
} }
} else { } 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");
} }
} }