branch feature/8124-VerifConfigurationSource updated (0b0d2c3 -> 4e94dcf)
This is an automated email from the git hooks/post-receive script. New change to branch feature/8124-VerifConfigurationSource in repository tutti. See https://gitlab.nuiton.org/codelutin/tutti.git from 0b0d2c3 correction car DateFormat n'est pas thread Safe (see #8124). new 56e84cc Ajoutd'un adaptateur Gson pour les form (see #8124). new 19d171b implentation de la fonction destroy du service DataSourceService (see #8124). new 4e94dcf Créer la base local avant de generer son dump initial (see #8124). The 3 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 4e94dcfc2e9269670c90b31360008d83562496a0 Author: Sylvain Bavencoff <bavencoff@codelutin.com> Date: Wed Mar 16 16:50:26 2016 +0100 Créer la base local avant de generer son dump initial (see #8124). commit 19d171b39208b637b5c4d2a91d2cb01b085a727b Author: Sylvain Bavencoff <bavencoff@codelutin.com> Date: Wed Mar 16 15:16:26 2016 +0100 implentation de la fonction destroy du service DataSourceService (see #8124). commit 56e84cc52c8e0e14c044a37dee916213c8330324 Author: Sylvain Bavencoff <bavencoff@codelutin.com> Date: Wed Mar 16 13:50:46 2016 +0100 Ajoutd'un adaptateur Gson pour les form (see #8124). Summary of changes: .../fr/ird/observe/db/ObserveSwingDataSource.java | 3 +- .../java/fr/ird/observe/ui/admin/AdminUIModel.java | 7 +++- .../ird/observe/ui/storage/StorageUIHandler.java | 28 +++++++--------- .../controller/v1/DataSourceServiceController.java | 3 +- .../services/service/DataSourceService.java | 4 ++- ... => DatabaseDestroyNotAuthorizedException.java} | 10 +++--- .../ird/observe/services/dto/gson/FormAdapter.java | 38 ++++++++++++++++++++++ .../services/dto/gson/ObserveDtoGsonSupplier.java | 3 +- .../services/service/DataSourceServiceTopia.java | 31 ++++++++++++++++-- 9 files changed, 98 insertions(+), 29 deletions(-) copy observe-services-api/src/main/java/fr/ird/observe/services/service/{DatabaseConnexionNotAuthorizedException.java => DatabaseDestroyNotAuthorizedException.java} (71%) create mode 100644 observe-services-model/src/main/java/fr/ird/observe/services/dto/gson/FormAdapter.java -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/8124-VerifConfigurationSource in repository tutti. See https://gitlab.nuiton.org/codelutin/tutti.git commit 19d171b39208b637b5c4d2a91d2cb01b085a727b Author: Sylvain Bavencoff <bavencoff@codelutin.com> Date: Wed Mar 16 15:16:26 2016 +0100 implentation de la fonction destroy du service DataSourceService (see #8124). --- .../fr/ird/observe/db/ObserveSwingDataSource.java | 3 +- .../java/fr/ird/observe/ui/admin/AdminUIModel.java | 7 ++- .../controller/v1/DataSourceServiceController.java | 3 +- .../services/service/DataSourceService.java | 4 +- .../DatabaseDestroyNotAuthorizedException.java | 56 ++++++++++++++++++++++ .../services/service/DataSourceServiceTopia.java | 31 +++++++++++- 6 files changed, 98 insertions(+), 6 deletions(-) diff --git a/observe-application-swing/src/main/java/fr/ird/observe/db/ObserveSwingDataSource.java b/observe-application-swing/src/main/java/fr/ird/observe/db/ObserveSwingDataSource.java index 5d475cd..af613a2 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/db/ObserveSwingDataSource.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/db/ObserveSwingDataSource.java @@ -29,6 +29,7 @@ import fr.ird.observe.services.dto.referential.ReferentialReferenceSet; import fr.ird.observe.services.service.BabModelVersionException; import fr.ird.observe.services.service.DataSourceService; import fr.ird.observe.services.service.DatabaseConnexionNotAuthorizedException; +import fr.ird.observe.services.service.DatabaseDestroyNotAuthorizedException; import fr.ird.observe.services.service.DatabaseNotFoundException; import fr.ird.observe.services.service.ObserveReferentialCache; import fr.ird.observe.services.service.ReferentialService; @@ -183,7 +184,7 @@ public class ObserveSwingDataSource extends AbstractSerializableBean implements } - public void destroy() { + public void destroy() throws DatabaseDestroyNotAuthorizedException { checkIsOpen(); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/AdminUIModel.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/AdminUIModel.java index aeca2bb..4d6c174 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/AdminUIModel.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/AdminUIModel.java @@ -37,6 +37,7 @@ import fr.ird.observe.services.dto.longline.TripLonglineDto; import fr.ird.observe.services.dto.seine.TripSeineDto; import fr.ird.observe.services.service.BabModelVersionException; import fr.ird.observe.services.service.DatabaseConnexionNotAuthorizedException; +import fr.ird.observe.services.service.DatabaseDestroyNotAuthorizedException; import fr.ird.observe.services.service.DatabaseNotFoundException; import fr.ird.observe.services.service.actions.validate.ValidateService; import fr.ird.observe.services.service.actions.validate.ValidateServiceUtils; @@ -1383,7 +1384,11 @@ public class AdminUIModel extends WizardExtModel<AdminStep> { if (source != null && source.isOpen()) { if (destroy) { - source.destroy(); + try { + source.destroy(); + } catch (DatabaseDestroyNotAuthorizedException e) { + throw new IllegalStateException("Could not destroy " + source, e); + } } else { source.close(); } diff --git a/observe-application-web/src/main/java/fr/ird/observe/application/web/controller/v1/DataSourceServiceController.java b/observe-application-web/src/main/java/fr/ird/observe/application/web/controller/v1/DataSourceServiceController.java index 0cae570..21706f4 100644 --- a/observe-application-web/src/main/java/fr/ird/observe/application/web/controller/v1/DataSourceServiceController.java +++ b/observe-application-web/src/main/java/fr/ird/observe/application/web/controller/v1/DataSourceServiceController.java @@ -40,6 +40,7 @@ import fr.ird.observe.services.dto.ObserveDbUserDto; import fr.ird.observe.services.service.BabModelVersionException; import fr.ird.observe.services.service.DataSourceService; import fr.ird.observe.services.service.DatabaseConnexionNotAuthorizedException; +import fr.ird.observe.services.service.DatabaseDestroyNotAuthorizedException; import fr.ird.observe.services.service.DatabaseNotFoundException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -111,7 +112,7 @@ public class DataSourceServiceController extends ObserveServiceControllerSupport } @Override - public void destroy() { + public void destroy() throws DatabaseDestroyNotAuthorizedException { getAuthenticatedService().destroy(); } diff --git a/observe-services-api/src/main/java/fr/ird/observe/services/service/DataSourceService.java b/observe-services-api/src/main/java/fr/ird/observe/services/service/DataSourceService.java index 0e1b2e9..6d163d6 100644 --- a/observe-services-api/src/main/java/fr/ird/observe/services/service/DataSourceService.java +++ b/observe-services-api/src/main/java/fr/ird/observe/services/service/DataSourceService.java @@ -65,9 +65,11 @@ public interface DataSourceService extends ObserveService, Closeable { void migrateData(ObserveDataSourceConfiguration dataSourceConfiguration); @Override + @NoDataAccess void close(); - void destroy(); + @NoDataAccess + void destroy() throws DatabaseDestroyNotAuthorizedException; @WriteDataPermission @Write diff --git a/observe-services-api/src/main/java/fr/ird/observe/services/service/DatabaseDestroyNotAuthorizedException.java b/observe-services-api/src/main/java/fr/ird/observe/services/service/DatabaseDestroyNotAuthorizedException.java new file mode 100644 index 0000000..fc378fc --- /dev/null +++ b/observe-services-api/src/main/java/fr/ird/observe/services/service/DatabaseDestroyNotAuthorizedException.java @@ -0,0 +1,56 @@ +package fr.ird.observe.services.service; + +/* + * #%L + * ObServe :: Services API + * %% + * Copyright (C) 2008 - 2015 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% + */ + +import fr.ird.observe.services.configuration.ObserveDataSourceConfiguration; + +/** + * Created on 23/08/15. + * + * @author Tony Chemit - chemit@codelutin.com + */ +public class DatabaseDestroyNotAuthorizedException extends Exception { + + private static final long serialVersionUID = 1L; + + protected final ObserveDataSourceConfiguration dataSourceConfiguration; + + public DatabaseDestroyNotAuthorizedException(ObserveDataSourceConfiguration dataSourceConfiguration) { + this.dataSourceConfiguration = dataSourceConfiguration; + } + public DatabaseDestroyNotAuthorizedException(String message, ObserveDataSourceConfiguration dataSourceConfiguration) { + super(message); + this.dataSourceConfiguration = dataSourceConfiguration; + } + + public DatabaseDestroyNotAuthorizedException(String message, Throwable cause, ObserveDataSourceConfiguration dataSourceConfiguration) { + super(message, cause); + this.dataSourceConfiguration = dataSourceConfiguration; + } + + public DatabaseDestroyNotAuthorizedException(Throwable cause, ObserveDataSourceConfiguration dataSourceConfiguration) { + super(cause); + this.dataSourceConfiguration = dataSourceConfiguration; + } + +} diff --git a/observe-services-topia/src/main/java/fr/ird/observe/services/service/DataSourceServiceTopia.java b/observe-services-topia/src/main/java/fr/ird/observe/services/service/DataSourceServiceTopia.java index 676d7ad..c236a52 100644 --- a/observe-services-topia/src/main/java/fr/ird/observe/services/service/DataSourceServiceTopia.java +++ b/observe-services-topia/src/main/java/fr/ird/observe/services/service/DataSourceServiceTopia.java @@ -309,11 +309,38 @@ public class DataSourceServiceTopia extends ObserveServiceTopia implements DataS } @Override - public void destroy() { + public void destroy() throws DatabaseDestroyNotAuthorizedException { if (log.isTraceEnabled()) { log.trace("destroy()"); } - //TODO + + ObserveDataSourceConfigurationTopiaSupport dataSourceConfiguration = serviceContext.getDataSourceConfiguration(); + + if (! dataSourceConfiguration.isH2Database()) { + + throw new DatabaseDestroyNotAuthorizedException(dataSourceConfiguration); + + } + + Optional<ObserveTopiaApplicationContext> optionalTopiaApplicationContext = ObserveTopiaApplicationContextFactory.getTopiaApplicationContextIfPresent(dataSourceConfiguration); + + if (optionalTopiaApplicationContext.isPresent()) { + + ObserveTopiaApplicationContext topiaApplicationContext = optionalTopiaApplicationContext.get(); + if (log.isInfoEnabled()) { + log.info("Closing topia application context: " + dataSourceConfiguration); + } + topiaApplicationContext.close(); + + } + + ObserveDataSourceConfigurationTopiaH2 dataSourceConfigurationH2 = (ObserveDataSourceConfigurationTopiaH2) dataSourceConfiguration; + + File databaseFile = dataSourceConfigurationH2.getDatabaseFile(); + + if (!databaseFile.delete()) { + throw new IllegalStateException("could not delete " + databaseFile); + } } -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/8124-VerifConfigurationSource in repository tutti. See https://gitlab.nuiton.org/codelutin/tutti.git commit 4e94dcfc2e9269670c90b31360008d83562496a0 Author: Sylvain Bavencoff <bavencoff@codelutin.com> Date: Wed Mar 16 16:50:26 2016 +0100 Créer la base local avant de generer son dump initial (see #8124). --- .../ird/observe/ui/storage/StorageUIHandler.java | 28 +++++++++------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/storage/StorageUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/storage/StorageUIHandler.java index 69808fd..15ab933 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/storage/StorageUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/storage/StorageUIHandler.java @@ -510,6 +510,16 @@ public class StorageUIHandler { observeContext.setDataSource(currentDataSource); observeContext.prepareMainStorage(currentDataSource); + if (model.getDbMode() == DbMode.CREATE_LOCAL) { + + DataSourceCreateConfigurationDto creationConfigurationDto = model.getCreationConfigurationDto(); + + currentDataSource.create(creationConfigurationDto); + } else { + // ouverture du nouveau storage + currentDataSource.open(); + } + if (DbMode.CREATE_LOCAL.equals(model.getDbMode()) && (CreationMode.IMPORT_REMOTE_STORAGE.equals(model.getCreationMode()) || CreationMode.IMPORT_SERVER_STORAGE.equals(model.getCreationMode())) && config.isLocalStorageExist()) { @@ -540,22 +550,6 @@ public class StorageUIHandler { } } - - if (model.getDbMode() == DbMode.CREATE_LOCAL) { - - DataSourceCreateConfigurationDto creationConfigurationDto = model.getCreationConfigurationDto(); - - currentDataSource.create(creationConfigurationDto); - } else { - // ouverture du nouveau storage - currentDataSource.open(); - } - - - - - - if (log.isInfoEnabled()) { log.info(">>> main storage opened " + currentDataSource.getLabel()); } @@ -612,7 +606,7 @@ public class StorageUIHandler { log.debug(dst); } - SqlScriptProducerRequest request = SqlScriptProducerRequest.forH2().addAllData(); + SqlScriptProducerRequest request = SqlScriptProducerRequest.forH2().addSchema().addReferential().addAllData(); byte[] dataDump = dumpProducerService.produceSqlScript(request); try (FileOutputStream outputStream = new FileOutputStream(dst)) { -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
participants (1)
-
codelutin.com scm