This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository tutti. See http://git.codelutin.com/tutti.git commit ff89982658fda3037bf111c8d8ed8de7b4f116ac Author: Tony CHEMIT <chemit@codelutin.com> Date: Wed Jan 28 10:03:58 2015 +0100 description de toutes les mises à jour possibles dans le module updater (pour réutiliser ce code dans le module d'ui) --- .../fr/ifremer/tutti/ui/swing/updater/Module.java | 58 ----------------- .../tutti/ui/swing/updater/UpdateModule.java | 76 ++++++++++++++++++++++ .../fr/ifremer/tutti/ui/swing/updater/Updater.java | 53 ++++++++------- .../ui/swing/updater/UpdaterFileSystemPathes.java | 40 ++++++------ tutti-ui-swing/pom.xml | 1 - 5 files changed, 124 insertions(+), 104 deletions(-) diff --git a/tutti-ui-swing-updater/src/main/java/fr/ifremer/tutti/ui/swing/updater/Module.java b/tutti-ui-swing-updater/src/main/java/fr/ifremer/tutti/ui/swing/updater/Module.java deleted file mode 100644 index 45a4384..0000000 --- a/tutti-ui-swing-updater/src/main/java/fr/ifremer/tutti/ui/swing/updater/Module.java +++ /dev/null @@ -1,58 +0,0 @@ -package fr.ifremer.tutti.ui.swing.updater; - -/* - * #%L - * Tutti :: UI Updater - * $Id:$ - * $HeadURL:$ - * %% - * Copyright (C) 2012 - 2015 Ifremer - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -/** -* Created on 1/26/15. -* -* @author Tony Chemit - chemit@codelutin.com -* @since 3.12 -*/ -public enum Module { - - launcher(true), - jre(true), - - tutti(false), - i18n(false), - help(false), - report(false), - ichtyometer(false); - - private final boolean runtimeModule; - - Module(boolean runtimeModule) { - this.runtimeModule = runtimeModule; - } - - public boolean isRuntimeModule() { - return runtimeModule; - } - - public String getModuleLoggerName() { - String moduleNameStr = String.format("[Module %1$-20s]", name()); - return moduleNameStr; - } -} diff --git a/tutti-ui-swing-updater/src/main/java/fr/ifremer/tutti/ui/swing/updater/UpdateModule.java b/tutti-ui-swing-updater/src/main/java/fr/ifremer/tutti/ui/swing/updater/UpdateModule.java new file mode 100644 index 0000000..9a028aa --- /dev/null +++ b/tutti-ui-swing-updater/src/main/java/fr/ifremer/tutti/ui/swing/updater/UpdateModule.java @@ -0,0 +1,76 @@ +package fr.ifremer.tutti.ui.swing.updater; + +/* + * #%L + * Tutti :: UI Updater + * $Id:$ + * $HeadURL:$ + * %% + * Copyright (C) 2012 - 2015 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +import java.util.HashSet; +import java.util.Set; + +/** + * Created on 1/26/15. + * + * @author Tony Chemit - chemit@codelutin.com + * @since 3.12 + */ +public enum UpdateModule { + + // Application - runtime + launcher(UpdateModuleConfiguration.applicationAndRuntime()), + jre(UpdateModuleConfiguration.applicationAndRuntime()), + + // Application - not runtime + tutti(UpdateModuleConfiguration.applicationAndNotRuntime()), + i18n(UpdateModuleConfiguration.applicationAndNotRuntime()), + help(UpdateModuleConfiguration.applicationAndNotRuntime()), + ichtyometer(UpdateModuleConfiguration.applicationAndNotRuntime()), + + // Data + report(UpdateModuleConfiguration.data(true)), + db(UpdateModuleConfiguration.data(false)); + + private final UpdateModuleConfiguration moduleConfiguration; + + UpdateModule(UpdateModuleConfiguration moduleConfiguration) { + this.moduleConfiguration = moduleConfiguration; + } + + public UpdateModuleConfiguration getModuleConfiguration() { + return moduleConfiguration; + } + + public String getModuleLoggerName() { + String moduleNameStr = String.format("[Module %1$-20s]", name()); + return moduleNameStr; + } + + public static UpdateModule[] getApplicationModules() { + Set<UpdateModule> result = new HashSet<>(); + for (UpdateModule updateModule : values()) { + if (updateModule.getModuleConfiguration().isApplication()) { + result.add(updateModule); + } + } + return result.toArray(new UpdateModule[result.size()]); + } +} diff --git a/tutti-ui-swing-updater/src/main/java/fr/ifremer/tutti/ui/swing/updater/Updater.java b/tutti-ui-swing-updater/src/main/java/fr/ifremer/tutti/ui/swing/updater/Updater.java index 4b8d75f..253acdb 100644 --- a/tutti-ui-swing-updater/src/main/java/fr/ifremer/tutti/ui/swing/updater/Updater.java +++ b/tutti-ui-swing-updater/src/main/java/fr/ifremer/tutti/ui/swing/updater/Updater.java @@ -92,7 +92,7 @@ public class Updater { } else { // update application modules - updateApplicationModules(); + updateNoneRuntimeModules(); // clean files cleanFiles(); @@ -125,11 +125,12 @@ public class Updater { boolean mustUpdateRuntime = false; - for (Module module : Module.values()) { + for (UpdateModule updateModule : UpdateModule.values()) { - if (module.isRuntimeModule()) { + UpdateModuleConfiguration moduleConfiguration = updateModule.getModuleConfiguration(); + if (moduleConfiguration.isManageByUpdater() && moduleConfiguration.isRuntime()) { - boolean updateFound = updateRuntimeModule(module); + boolean updateFound = updateRuntimeModule(updateModule); if (updateFound) { mustUpdateRuntime = true; @@ -163,38 +164,40 @@ public class Updater { } - protected void updateApplicationModules() throws IOException { + protected void updateNoneRuntimeModules() throws IOException { - for (Module module : Module.values()) { + for (UpdateModule updateModule : UpdateModule.values()) { - if (!module.isRuntimeModule()) { + UpdateModuleConfiguration moduleConfiguration = updateModule.getModuleConfiguration(); - updateApplicationModule(module); + if (moduleConfiguration.isManageByUpdater() && !moduleConfiguration.isRuntime()) { + + updateNoneRuntimeModule(updateModule); } } } - protected boolean updateRuntimeModule(Module module) throws IOException { + protected boolean updateRuntimeModule(UpdateModule updateModule) throws IOException { - boolean moduleExist = pathHelper.isModuleExists(module); - boolean updateModuleExist = pathHelper.isUpdateModuleExists(module); + boolean moduleExist = pathHelper.isModuleExists(updateModule); + boolean updateModuleExist = pathHelper.isUpdateModuleExists(updateModule); - String oldVersion = moduleExist ? pathHelper.getModuleVersion(module) : "None"; + String oldVersion = moduleExist ? pathHelper.getModuleVersion(updateModule) : "None"; - String moduleNameStr = module.getModuleLoggerName(); + String moduleNameStr = updateModule.getModuleLoggerName(); System.out.println(String.format("%s Current version: %s", moduleNameStr, oldVersion)); if (updateModuleExist) { - String newVersion = pathHelper.getUpdateModuleVersion(module); + String newVersion = pathHelper.getUpdateModuleVersion(updateModule); System.out.println(String.format("%s New version detected %s", moduleNameStr, newVersion)); // Remove older backup - pathHelper.removeOlderBackup(module); + pathHelper.removeOlderBackup(updateModule); } else { @@ -206,37 +209,37 @@ public class Updater { } - protected void updateApplicationModule(Module module) throws IOException { + protected void updateNoneRuntimeModule(UpdateModule updateModule) throws IOException { - boolean moduleExist = pathHelper.isModuleExists(module); - boolean updateModuleExist = pathHelper.isUpdateModuleExists(module); + boolean moduleExist = pathHelper.isModuleExists(updateModule); + boolean updateModuleExist = pathHelper.isUpdateModuleExists(updateModule); - String oldVersion = moduleExist ? pathHelper.getModuleVersion(module) : "None"; + String oldVersion = moduleExist ? pathHelper.getModuleVersion(updateModule) : "None"; - String moduleNameStr = module.getModuleLoggerName(); + String moduleNameStr = updateModule.getModuleLoggerName(); System.out.println(String.format("%s Current version: %s", moduleNameStr, oldVersion)); if (updateModuleExist) { - String newVersion = pathHelper.getUpdateModuleVersion(module); + String newVersion = pathHelper.getUpdateModuleVersion(updateModule); System.out.println(String.format("%s New version detected %s", moduleNameStr, newVersion)); - pathHelper.removeOlderBackup(module); + pathHelper.removeOlderBackup(updateModule); - Path modulePath = pathHelper.getModulePath(module); + Path modulePath = pathHelper.getModulePath(updateModule); if (moduleExist) { // Backup existing module - pathHelper.backupModule(module, oldVersion); + pathHelper.backupModule(updateModule, oldVersion); } // Installing new module System.out.println(String.format("%s Install new version %s", moduleNameStr, newVersion)); - Path moduleNewPath = pathHelper.getUpdateModulePath(module); + Path moduleNewPath = pathHelper.getUpdateModulePath(updateModule); Files.move(moduleNewPath, modulePath, StandardCopyOption.REPLACE_EXISTING); } else { diff --git a/tutti-ui-swing-updater/src/main/java/fr/ifremer/tutti/ui/swing/updater/UpdaterFileSystemPathes.java b/tutti-ui-swing-updater/src/main/java/fr/ifremer/tutti/ui/swing/updater/UpdaterFileSystemPathes.java index 82f2772..25eafd0 100644 --- a/tutti-ui-swing-updater/src/main/java/fr/ifremer/tutti/ui/swing/updater/UpdaterFileSystemPathes.java +++ b/tutti-ui-swing-updater/src/main/java/fr/ifremer/tutti/ui/swing/updater/UpdaterFileSystemPathes.java @@ -55,43 +55,43 @@ public class UpdaterFileSystemPathes { return updateDirectory; } - public Path getUpdateModulePath(Module module) { - Path modulePath = getUpdateDirectory().resolve(module.name()); + public Path getUpdateModulePath(UpdateModule updateModule) { + Path modulePath = getUpdateDirectory().resolve(updateModule.name()); return modulePath; } - public boolean isUpdateModuleExists(Module module) { + public boolean isUpdateModuleExists(UpdateModule updateModule) { - Path updateModulePath = getUpdateModulePath(module); + Path updateModulePath = getUpdateModulePath(updateModule); boolean isDirectory = Files.isDirectory(updateModulePath); return isDirectory; } - public String getUpdateModuleVersion(Module module) throws IOException { + public String getUpdateModuleVersion(UpdateModule updateModule) throws IOException { - Path updateModulePath = getUpdateModulePath(module); + Path updateModulePath = getUpdateModulePath(updateModule); String version = getVersion(updateModulePath); return version; } - public Path getModulePath(Module module) { - Path modulePath = baseDir.resolve(module.name()); + public Path getModulePath(UpdateModule updateModule) { + Path modulePath = baseDir.resolve(updateModule.name()); return modulePath; } - public boolean isModuleExists(Module module) { + public boolean isModuleExists(UpdateModule updateModule) { - Path modulePath = getModulePath(module); + Path modulePath = getModulePath(updateModule); boolean isDirectory = Files.isDirectory(modulePath); return isDirectory; } - public String getModuleVersion(Module module) throws IOException { + public String getModuleVersion(UpdateModule updateModule) throws IOException { - Path modulePath = getModulePath(module); + Path modulePath = getModulePath(updateModule); String version = getVersion(modulePath); return version; @@ -107,7 +107,7 @@ public class UpdaterFileSystemPathes { public void cleanObsoleteFiles() throws IOException { - Path applicationDirectoryPath = getModulePath(Module.tutti); + Path applicationDirectoryPath = getModulePath(UpdateModule.tutti); if (windowsOS) { @@ -154,29 +154,29 @@ public class UpdaterFileSystemPathes { } - public void removeOlderBackup(Module module) throws IOException { + public void removeOlderBackup(UpdateModule updateModule) throws IOException { - String moduleName = module.name(); + String moduleName = updateModule.name(); Path backupDirectory = getBackupDirectory(); // Remove older backup - System.out.println(String.format("%s Clean backup directory %s", module.getModuleLoggerName(), backupDirectory + File.separator + moduleName + "-*")); + System.out.println(String.format("%s Clean backup directory %s", updateModule.getModuleLoggerName(), backupDirectory + File.separator + moduleName + "-*")); DeleteHelper.deleteDirectories(backupDirectory, moduleName + "-*"); } - public void backupModule(Module module, String version) throws IOException { + public void backupModule(UpdateModule updateModule, String version) throws IOException { - Path modulePath = getModulePath(module); + Path modulePath = getModulePath(updateModule); - String moduleName = module.name(); + String moduleName = updateModule.name(); Path backupDirectory = getBackupDirectory(); Path backupModulePath = backupDirectory.resolve(String.format("%s-%s-%s", moduleName, version, backupDate)); - System.out.println(String.format("%s Backup old version %s to %s", module.getModuleLoggerName(), version, backupModulePath)); + System.out.println(String.format("%s Backup old version %s to %s", updateModule.getModuleLoggerName(), version, backupModulePath)); Files.move(modulePath, backupModulePath); } diff --git a/tutti-ui-swing/pom.xml b/tutti-ui-swing/pom.xml index 0e33be5..cf70c53 100644 --- a/tutti-ui-swing/pom.xml +++ b/tutti-ui-swing/pom.xml @@ -114,7 +114,6 @@ <groupId>${project.groupId}</groupId> <artifactId>tutti-ui-swing-updater</artifactId> <version>${project.version}</version> - <scope>runtime</scope> </dependency> <!-- Adagio --> -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.