Tony CHEMIT pushed to branch develop-7.x at ultreiaio / ird-observe Commits: 2949efae by tchemit at 2019-09-11T17:12:57Z let's pass if we could not load backups... this should not break application. - - - - - cb633b5e by tchemit at 2019-09-11T17:13:13Z expose clientconfig for tes and use it - - - - - bd3ee115 by tchemit at 2019-09-11T17:13:47Z [LL] Une marée provoque un dépassement mémoire et/ou a un souci de commentaires trop longs - closes #1373 - - - - - 12 changed files: - client-configuration/src/main/java/fr/ird/observe/client/configuration/ClientConfig.java - client-core/src/main/java/fr/ird/observe/client/backup/BackupsManager.java - client-runner/src/test/java/fr/ird/observe/client/simple/longline/LonglineDetailCompositionValidatorServiceTest.java - + persistence/src/main/java/fr/ird/observe/persistence/migration/DataSourceMigrationForVersion_7_2.java - + persistence/src/main/resources/db/migration/7.2/01_fix_trip_longline_comment-H2.sql - + persistence/src/main/resources/db/migration/7.2/01_fix_trip_longline_comment-PG.sql - pom.xml - + test/src/main/resources/db/7.2/dataForTestLongline.sql.gz - + test/src/main/resources/db/7.2/dataForTestSeine.sql.gz - + test/src/main/resources/db/7.2/empty_h2.sql.gz - + test/src/main/resources/db/7.2/empty_pg.sql.gz - + test/src/main/resources/db/7.2/referentiel.sql.gz Changes: ===================================== client-configuration/src/main/java/fr/ird/observe/client/configuration/ClientConfig.java ===================================== @@ -164,7 +164,7 @@ public class ClientConfig extends GeneratedClientConfig implements NavigationTre delegate.setConfigFileName(configFileName); } - static ClientConfig forTest() { + public static ClientConfig forTest() { return new ClientConfig(ApplicationConfigInit.forAllScopesWithout(ApplicationConfigScope.HOME, ApplicationConfigScope.ENV, ApplicationConfigScope.SYSTEM), DEFAULT_OBSERVE_SWING_CONFIGURATION_FILENAME); } ===================================== client-core/src/main/java/fr/ird/observe/client/backup/BackupsManager.java ===================================== @@ -127,35 +127,34 @@ public class BackupsManager implements Closeable { this.backupsPath = backupsPath; this.checkBackups.start(); - try { - List<BackupStorage> backups; - if (Files.exists(storePath)) { - try (BufferedReader reader = Files.newBufferedReader(storePath, StandardCharsets.UTF_8)) { - Type typeOfT = new TypeToken<List<BackupStorage>>() { - }.getType(); - backups = new Gson().fromJson(reader, typeOfT); - log.info(String.format("Loaded %d backups from %s", backups.size(), storePath)); - } - } else { + List<BackupStorage> backups; + if (Files.exists(storePath)) { + try (BufferedReader reader = Files.newBufferedReader(storePath, StandardCharsets.UTF_8)) { + Type typeOfT = new TypeToken<List<BackupStorage>>() { + }.getType(); + backups = new Gson().fromJson(reader, typeOfT); + log.info(String.format("Loaded %d backups from %s", backups.size(), storePath)); + } catch (Exception e) { + log.error("can't load backups...", e); backups = new LinkedList<>(); } + } else { + backups = new LinkedList<>(); + } - Iterator<BackupStorage> iterator = backups.iterator(); - while (iterator.hasNext()) { - BackupStorage backupStorage = iterator.next(); - if (!backupStorage.exists()) { - iterator.remove(); - continue; - } - if (!backupStorage.isVerified()) { - iterator.remove(); - addAutomaticBackup(backupStorage.getFile().toPath()); - } + Iterator<BackupStorage> iterator = backups.iterator(); + while (iterator.hasNext()) { + BackupStorage backupStorage = iterator.next(); + if (!backupStorage.exists()) { + iterator.remove(); + continue; + } + if (!backupStorage.isVerified()) { + iterator.remove(); + addAutomaticBackup(backupStorage.getFile().toPath()); } - this.backups = backups; - } catch (IOException e) { - throw new ObserveSwingTechnicalException("Can't init backups manager", e); } + this.backups = backups; } private List<BackupStorage> discoverAutomaticBackups(Path backupsPath) throws IOException { ===================================== client-runner/src/test/java/fr/ird/observe/client/simple/longline/LonglineDetailCompositionValidatorServiceTest.java ===================================== @@ -71,7 +71,7 @@ public class LonglineDetailCompositionValidatorServiceTest { ObserveSwingApplicationContext.get().close(); } - ClientConfig config = new ClientConfig(); + ClientConfig config = ClientConfig.forTest(); config.initConfig(new ObserveResourceManager().getResource(ObserveResourceManager.Resource.application)); ===================================== persistence/src/main/java/fr/ird/observe/persistence/migration/DataSourceMigrationForVersion_7_2.java ===================================== @@ -0,0 +1,41 @@ +package fr.ird.observe.persistence.migration; + +/*- + * #%L + * ObServe :: Persistence + * %% + * Copyright (C) 2008 - 2019 IRD, Code Lutin, Ultreia.io + * %% + * 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 org.nuiton.topia.service.migration.resources.MigrationVersionResource; +import org.nuiton.topia.service.migration.resources.MigrationVersionResourceExecutor; +import org.nuiton.version.Versions; + +public class DataSourceMigrationForVersion_7_2 extends MigrationVersionResource { + + public DataSourceMigrationForVersion_7_2() { + super(Versions.valueOf("7.2")); + } + + @Override + public void generateSqlScript(MigrationVersionResourceExecutor executor) { + executor.addScript("01", "fix_trip_longline_comment"); + } + +} + ===================================== persistence/src/main/resources/db/migration/7.2/01_fix_trip_longline_comment-H2.sql ===================================== @@ -0,0 +1,25 @@ +--- +-- #%L +-- ObServe :: Persistence +-- %% +-- Copyright (C) 2008 - 2019 IRD, Code Lutin, Ultreia.io +-- %% +-- 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% +--- +ALTER TABLE observe_longline.trip ADD COLUMN comment2 VARCHAR(1025); +UPDATE observe_longline.trip set comment2 = comment; +ALTER TABLE observe_longline.trip DROP COLUMN comment; +ALTER TABLE observe_longline.trip comment2 RENAME TO comment; ===================================== persistence/src/main/resources/db/migration/7.2/01_fix_trip_longline_comment-PG.sql ===================================== @@ -0,0 +1,25 @@ +--- +-- #%L +-- ObServe :: Persistence +-- %% +-- Copyright (C) 2008 - 2019 IRD, Code Lutin, Ultreia.io +-- %% +-- 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% +--- +ALTER TABLE observe_longline.trip ADD COLUMN comment2 VARCHAR(1025); +UPDATE observe_longline.trip set comment2 = comment; +ALTER TABLE observe_longline.trip DROP COLUMN comment CASCADE; +ALTER TABLE observe_longline.trip RENAME comment2 TO comment; ===================================== pom.xml ===================================== @@ -149,7 +149,7 @@ <devMode>true</devMode> <!--persistence model version--> - <observe.model.version>7.1</observe.model.version> + <observe.model.version>7.2</observe.model.version> <!-- build timestamp configuration --> <maven.build.timestamp.format>dd/MM/yyyy HH:mm z</maven.build.timestamp.format> ===================================== test/src/main/resources/db/7.2/dataForTestLongline.sql.gz ===================================== Binary files /dev/null and b/test/src/main/resources/db/7.2/dataForTestLongline.sql.gz differ ===================================== test/src/main/resources/db/7.2/dataForTestSeine.sql.gz ===================================== Binary files /dev/null and b/test/src/main/resources/db/7.2/dataForTestSeine.sql.gz differ ===================================== test/src/main/resources/db/7.2/empty_h2.sql.gz ===================================== Binary files /dev/null and b/test/src/main/resources/db/7.2/empty_h2.sql.gz differ ===================================== test/src/main/resources/db/7.2/empty_pg.sql.gz ===================================== Binary files /dev/null and b/test/src/main/resources/db/7.2/empty_pg.sql.gz differ ===================================== test/src/main/resources/db/7.2/referentiel.sql.gz ===================================== Binary files /dev/null and b/test/src/main/resources/db/7.2/referentiel.sql.gz differ View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/compare/0adde8dcc6128d2f9c0349738b0... -- View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/compare/0adde8dcc6128d2f9c0349738b0... You're receiving this email because of your account on gitlab.com.