Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe Commits: bba686f2 by Tony CHEMIT at 2018-07-19T11:48:09Z Be able to use server configuration to perform database management - Closes #1034) - - - - - 19 changed files: - client-configuration/src/main/config/Client.ini - client-configuration/src/main/resources/i18n/client-configuration_en_GB.properties - client-configuration/src/main/resources/i18n/client-configuration_es_ES.properties - client-configuration/src/main/resources/i18n/client-configuration_fr_FR.properties - client/src/main/assembly/dist/obstuna-admin/README.txt - + client/src/main/assembly/dist/obstuna-admin/create-server.bat - + client/src/main/assembly/dist/obstuna-admin/create-server.sh - + client/src/main/assembly/dist/obstuna-admin/drop-server.bat - + client/src/main/assembly/dist/obstuna-admin/drop-server.sh - + client/src/main/assembly/dist/obstuna-admin/update-security-server.bat - + client/src/main/assembly/dist/obstuna-admin/update-security-server.sh - + client/src/main/assembly/dist/obstuna-admin/update-server.bat - + client/src/main/assembly/dist/obstuna-admin/update-server.sh - client/src/main/java/fr/ird/observe/client/ObserveCLAction.java - client/src/main/java/fr/ird/observe/client/ui/storage/ObstunaAdminAction.java - client/src/main/java/fr/ird/observe/client/ui/storage/RemoteUILauncher.java - server-configuration/src/main/resources/observeweb-log4j.conf - server/src/main/java/fr/ird/observe/server/controller/v1/DataSourceServiceRestApi.java - services/src/main/java/fr/ird/observe/services/service/DataSourceService.java Changes: ===================================== client-configuration/src/main/config/Client.ini ===================================== @@ -624,6 +624,11 @@ description = observe.action.commandline.launch.obstuna.admin.ui action = "fr.ird.observe.client.ObserveCLAction#launchObstunaAdminUI" aliases = --obstuna-admin +[action serverAdminUi] +description = observe.action.commandline.launch.server.admin.ui +action = "fr.ird.observe.client.ObserveCLAction#launchServerAdminUI" +aliases = --server-admin + [action h2ServerMode] description = observe.action.commandline.launch.h2.server.mode action = "fr.ird.observe.client.ObserveCLAction#launchH2ServerMode" ===================================== client-configuration/src/main/resources/i18n/client-configuration_en_GB.properties ===================================== @@ -7,6 +7,7 @@ observe.action.commandline.help.ui=Show gui help observe.action.commandline.launch.admin.ui=Launch an administration task observe.action.commandline.launch.h2.server.mode=Launch ObServe in server mode observe.action.commandline.launch.obstuna.admin.ui=Launch an adminstration task on obstuna +observe.action.commandline.launch.server.admin.ui=Launch an adminstration task on server observe.action.commandline.use.jmx=Add JMX support observe.config.backup.atClose=Perform a backup of local source when closing application observe.config.backup.delay=Delay in minutes between local data source backup ===================================== client-configuration/src/main/resources/i18n/client-configuration_es_ES.properties ===================================== @@ -7,6 +7,7 @@ observe.action.commandline.help.ui=Mostrar el manual de usuario (modo grafico) observe.action.commandline.launch.admin.ui=Ejecutar una operación de administración observe.action.commandline.launch.h2.server.mode=Ejecutar ObServe en modo servidor observe.action.commandline.launch.obstuna.admin.ui=Ejecutar una operación de administración sobre Obstuna +observe.action.commandline.launch.server.admin.ui=Lancer une opération d'administration sur un serveur \#TODO observe.action.commandline.use.jmx=Mostrar el soporte JMX observe.config.backup.atClose=Realizar una copia de seguridad de la base de datos local al cerrar la aplicación observe.config.backup.delay=Minutos entre cada copia de seguridad de la base de datos local ===================================== client-configuration/src/main/resources/i18n/client-configuration_fr_FR.properties ===================================== @@ -7,6 +7,7 @@ observe.action.commandline.help.ui=Afficher le manuel utilisateur (mode graphiqu observe.action.commandline.launch.admin.ui=Lancer une opération d'administration observe.action.commandline.launch.h2.server.mode=Lancer ObServe en mode serveur observe.action.commandline.launch.obstuna.admin.ui=Lancer une opération d'administration sur Obstuna +observe.action.commandline.launch.server.admin.ui=Lancer une opération d'administration sur un serveur observe.action.commandline.use.jmx=Ajouter le support JMX observe.config.backup.atClose=Effectuer une sauvegarde de la base locale à la fermeture de l'application observe.config.backup.delay=Temps en minutes entre chaque sauvegarde de la base locale ===================================== client/src/main/assembly/dist/obstuna-admin/README.txt ===================================== @@ -6,7 +6,7 @@ Lancer le script (sh) ./createdb/create-ird_obstuna.sh -Puis lancer ObServe en mode création de base obstuna +puis ./create-obstuna.sh @@ -27,8 +27,6 @@ ou Pour mettre à jour la sécurité sur une base obstuna --------------------------------------------------- -Il faut ensuite lancer l'action de mise à jour de base via ObServe : - ./update-security-obstuna.sh ou @@ -43,3 +41,47 @@ Pour vider une base obstuna ou ./drop-obstuna.bat + + +Pour créer une nouvelle base via server +------------------------------------------ + +Lancer le script (sh) + +./createdb/create-ird_obstuna.sh + +puis + +./create-server.sh + +ou + +./create-server.bat + + +Pour mettre à jour une base via serveur +--------------------------------------- + +./update-server.sh + +ou + +./update-server.bat + +Pour mettre à jour la sécurité sur une base via serveur +------------------------------------------------------- + +./update-security-server.sh + +ou + +./update-security-server.bat + +Pour vider une base via serveur +------------------------------- + +./drop-server.sh + +ou + +./drop-server.bat ===================================== client/src/main/assembly/dist/obstuna-admin/create-server.bat ===================================== @@ -0,0 +1,2 @@ + +java -Xmx512M -Xms512M -jar ../${project.build.finalName}.jar --server-admin create \ No newline at end of file ===================================== client/src/main/assembly/dist/obstuna-admin/create-server.sh ===================================== @@ -0,0 +1,28 @@ +### +# #%L +# ObServe :: Admin Client +# +# $Id$ +# $HeadURL$ +# %% +# Copyright (C) 2008 - 2010 IRD, Codelutin, Tony Chemit +# %% +# 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% +### +#!/bin/sh +# Pour créer une nouvelle base obstuna (le schéma sera créer et le référentiel rempli) + +java -Xmx512M -Xms512M -jar ../${project.build.finalName}.jar --server-admin create \ No newline at end of file ===================================== client/src/main/assembly/dist/obstuna-admin/drop-server.bat ===================================== @@ -0,0 +1,2 @@ + +java -Xmx512M -Xms512M -jar ../${project.build.finalName}.jar --server-admin drop \ No newline at end of file ===================================== client/src/main/assembly/dist/obstuna-admin/drop-server.sh ===================================== @@ -0,0 +1,28 @@ +### +# #%L +# ObServe :: Admin Client +# +# $Id$ +# $HeadURL$ +# %% +# Copyright (C) 2008 - 2010 IRD, Codelutin, Tony Chemit +# %% +# 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% +### +#!/bin/sh +# Pour vider une base obstuna (toutes les tables seront supprimées) + +java -Xmx512M -Xms512M -jar ../${project.build.finalName}.jar --server-admin drop \ No newline at end of file ===================================== client/src/main/assembly/dist/obstuna-admin/update-security-server.bat ===================================== @@ -0,0 +1,2 @@ + +java -Xmx512M -Xms512M -jar ../${project.build.finalName}.jar --server-admin security \ No newline at end of file ===================================== client/src/main/assembly/dist/obstuna-admin/update-security-server.sh ===================================== @@ -0,0 +1,28 @@ +### +# #%L +# ObServe :: Admin Client +# +# $Id$ +# $HeadURL$ +# %% +# Copyright (C) 2008 - 2010 IRD, Codelutin, Tony Chemit +# %% +# 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% +### +#!/bin/sh +# Pour mettre à jour la sécurité sur une base postgres + +java -Xmx512M -Xms512M -jar ../${project.build.finalName}.jar --server-admin security \ No newline at end of file ===================================== client/src/main/assembly/dist/obstuna-admin/update-server.bat ===================================== @@ -0,0 +1,2 @@ + +java -Xmx2048M -Xms512M -jar ../${project.build.finalName}.jar --server-admin update \ No newline at end of file ===================================== client/src/main/assembly/dist/obstuna-admin/update-server.sh ===================================== @@ -0,0 +1,28 @@ +### +# #%L +# ObServe :: Admin Client +# +# $Id$ +# $HeadURL$ +# %% +# Copyright (C) 2008 - 2010 IRD, Codelutin, Tony Chemit +# %% +# 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% +### +#!/bin/sh +# Pour mettre à jour une base server (le schéma sera mis à jour si nécessaire) + +java -Xmx1536M -Xms512M -jar ../${project.build.finalName}.jar --server-admin update \ No newline at end of file ===================================== client/src/main/java/fr/ird/observe/client/ObserveCLAction.java ===================================== @@ -176,7 +176,39 @@ public class ObserveCLAction { getConfig().setObstunaCanMigrate(true); } - RemoteUILauncher launcher = operation.newLauncher(context, null); + RemoteUILauncher launcher = operation.newLauncher(context, null, false); + + Runnable runnable = createRunnable(launcher, "start"); + launchAction(t(launcher.getTitle()), runnable); + } + + @SuppressWarnings("unused") + public void launchServerAdminUI(String operationName) throws InterruptedException { + + disableMainUI(); + + EnumSet<ObstunaAdminAction> operations = EnumSet.allOf(ObstunaAdminAction.class); + + ObstunaAdminAction operation = ObstunaAdminAction.valueOfIgnoreCase(operationName); + if (operation == null) { + if (log.isErrorEnabled()) { + log.error(operationName + " is not a known obstuna admin operation."); + log.error("Use one of these ones : " + operations); + } + return; + } + + ObserveSwingApplicationContext context = ObserveSwingApplicationContext.get(); + + // FIXME +// getConfig().setOption(AbstractDataSourceMigration.AUTO_MIGRATE, "false"); + + if (operation == ObstunaAdminAction.UPDATE || + operation == ObstunaAdminAction.CREATE) { + getConfig().setObstunaCanMigrate(true); + } + + RemoteUILauncher launcher = operation.newLauncher(context, null, true); Runnable runnable = createRunnable(launcher, "start"); launchAction(t(launcher.getTitle()), runnable); ===================================== client/src/main/java/fr/ird/observe/client/ui/storage/ObstunaAdminAction.java ===================================== @@ -21,7 +21,6 @@ */ package fr.ird.observe.client.ui.storage; -import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableSet; import fr.ird.observe.client.ObserveSwingApplicationContext; import fr.ird.observe.client.constants.DbMode; @@ -44,6 +43,7 @@ import org.nuiton.jaxx.runtime.JAXXContext; import org.nuiton.version.Version; import java.awt.Window; +import java.util.Objects; import java.util.stream.Collectors; import static org.nuiton.i18n.I18n.t; @@ -64,8 +64,8 @@ public enum ObstunaAdminAction { */ CREATE() { @Override - public RemoteUILauncher newLauncher(JAXXContext context, Window frame) { - return new RemoteUILauncher(this, context, frame, I18nEnumHelper.getLabel(this)) { + public RemoteUILauncher newLauncher(JAXXContext context, Window frame, boolean serverMode) { + return new RemoteUILauncher(this, context, frame, I18nEnumHelper.getLabel(this),serverMode ) { DataSourceCreateConfigurationDto createConfigurationDto; ObserveSwingDataSource dataSource; @@ -83,19 +83,9 @@ public enum ObstunaAdminAction { void checkImportDbVersion(StorageUIModel model, ObserveDataSourceConfiguration dataSourceConfig) throws DatabaseConnexionNotAuthorizedException, DatabaseNotFoundException, BabModelVersionException { - ObserveSwingDataSource importDataSource = ObserveSwingApplicationContext.get().getDataSourcesManager().newDataSource(dataSourceConfig); - - Preconditions.checkState(importDataSource != null, "Can't select data on a null dataSource"); - - try { - - importDataSource.open(); - - model.checkImportDbVersion(importDataSource); - - } finally { - - importDataSource.close(); + try (ObserveSwingDataSource importDataSource = Objects.requireNonNull(ObserveSwingApplicationContext.get().getDataSourcesManager().newDataSource(dataSourceConfig))) { + importDataSource.open(); + model.checkImportDbVersion(importDataSource); } } @@ -189,8 +179,8 @@ public enum ObstunaAdminAction { */ UPDATE() { @Override - public RemoteUILauncher newLauncher(JAXXContext context, Window frame) { - return new RemoteUILauncher(this, context, frame, I18nEnumHelper.getLabel(this)) { + public RemoteUILauncher newLauncher(JAXXContext context, Window frame, boolean serverMode) { + return new RemoteUILauncher(this, context, frame, I18nEnumHelper.getLabel(this),serverMode ) { ObserveSwingDataSource dataSource; ObserveDataSourceInformation dataSourceInformation; @@ -248,8 +238,8 @@ public enum ObstunaAdminAction { */ SECURITY() { @Override - public RemoteUILauncher newLauncher(JAXXContext context, Window frame) { - return new RemoteUILauncher(this, context, frame, I18nEnumHelper.getLabel(this)) { + public RemoteUILauncher newLauncher(JAXXContext context, Window frame, boolean serverMode) { + return new RemoteUILauncher(this, context, frame, I18nEnumHelper.getLabel(this),serverMode ) { ObserveSwingDataSource dataSource; ImmutableSet<ObserveDbUserDto> users; @@ -291,7 +281,7 @@ public enum ObstunaAdminAction { return null; } - public abstract RemoteUILauncher newLauncher(JAXXContext context, Window frame); + public abstract RemoteUILauncher newLauncher(JAXXContext context, Window frame, boolean serverMode); @Override public String toString() { @@ -310,7 +300,6 @@ public enum ObstunaAdminAction { dataSource = ObserveSwingApplicationContext.get().getDataSourcesManager().newDataSource(pgConfig); } else { ObserveDataSourceConfigurationRest restConfig = model.getRestConfig(); - dataSource = ObserveSwingApplicationContext.get().getDataSourcesManager().newDataSource(restConfig); } return dataSource; ===================================== client/src/main/java/fr/ird/observe/client/ui/storage/RemoteUILauncher.java ===================================== @@ -6,15 +6,15 @@ * %% * 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 + * 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 + * + * 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% @@ -43,15 +43,17 @@ public abstract class RemoteUILauncher extends StorageUILauncher { /** Logger */ private static final Log log = LogFactory.getLog(RemoteUILauncher.class); - + private final boolean serverMode; protected ObstunaAdminAction action; public RemoteUILauncher(ObstunaAdminAction action, JAXXContext context, Window frame, - String title) { + String title, + boolean serverMode) { super(context, frame, title); this.action = action; + this.serverMode = serverMode; } @Override @@ -63,7 +65,7 @@ public abstract class RemoteUILauncher extends StorageUILauncher { model.setCanUseLocalService(false); model.setCanUseRemoteService(true); model.setCanUseServerService(true); - model.setDbMode(DbMode.USE_REMOTE); + model.setDbMode(serverMode ? DbMode.USE_SERVER : DbMode.USE_REMOTE); model.setAdminAction(action); List<StorageStep> steps = new ArrayList<>(); ===================================== server-configuration/src/main/resources/observeweb-log4j.conf ===================================== @@ -36,7 +36,8 @@ log4j.appender.file.layout.ConversionPattern=%-5p %d{ISO8601} [%t] %40C{1} :%4L log4j.logger.fr.ird.observe=INFO log4j.logger.fr.ird.observe.client.validators=WARN log4j.logger.io.ultreia=INFO -log4j.logger.org.nuiton.topia.migration=INFO +log4j.logger.org.nuiton.topia.service.sql=INFO +log4j.logger.org.nuiton.topia.service.migration=INFO log4j.logger.org.hibernate.orm.deprecation=ERROR log4j.logger.com.zaxxer.hikari.HikariDataSource=ERROR log4j.logger.com.opensymphony.xwork2.validator.validators=ERROR ===================================== server/src/main/java/fr/ird/observe/server/controller/v1/DataSourceServiceRestApi.java ===================================== @@ -127,7 +127,7 @@ public class DataSourceServiceRestApi extends GeneratedDataSourceServiceRestApi @Override public void migrateData(ObserveDataSourceConfiguration dataSourceConfiguration) { ObserveDataSourceConfiguration dataSourceConfigurationTopia = getTopiaDataSourceConfiguration(dataSourceConfiguration); - getAnonymousService(dataSourceConfigurationTopia).migrateData(dataSourceConfiguration); + getAnonymousService(dataSourceConfigurationTopia).migrateData(dataSourceConfigurationTopia); } protected ObserveDataSourceConfiguration getTopiaDataSourceConfiguration(ObserveDataSourceConfiguration dataSourceConfigurationFromRequest) { ===================================== services/src/main/java/fr/ird/observe/services/service/DataSourceService.java ===================================== @@ -61,7 +61,7 @@ public interface DataSourceService extends ObserveService, Closeable { @Get(addAuthtoken = false) void applySecurity(ObserveDataSourceConfiguration dataSourceConfiguration, ImmutableSet<ObserveDbUserDto> users); - @Get(addAuthtoken = false) + @Get(addAuthtoken = false, timeOut = 1000) void migrateData(ObserveDataSourceConfiguration dataSourceConfiguration); @Get View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/commit/bba686f28ec50a2aa5e6ab55ce53... -- View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/commit/bba686f28ec50a2aa5e6ab55ce53... You're receiving this email because of your account on gitlab.com.
participants (1)
-
Tony CHEMIT