This is an automated email from the ASF dual-hosted git repository. desruisseaux pushed a commit to branch geoapi-3.1 in repository https://gitbox.apache.org/repos/asf/sis.git
commit 1f1a9766c03e7e543622df53c4cb34b339028229 Merge: f9314a0864 cf8135d4e3 Author: Martin Desruisseaux <martin.desruisse...@geomatys.com> AuthorDate: Sun Oct 6 18:10:27 2024 +0200 Merge branch 'geoapi-4.0' into geoapi-3.1. endorsed/build.gradle.kts | 1 + .../apache/sis/metadata/sql/MetadataSource.java | 3 + .../apache/sis/metadata/sql/privy/Initializer.java | 2 +- .../sis/metadata/sql/privy/ScriptRunner.java | 20 ++---- .../org/apache/sis/util/iso/AbstractFactory.java | 16 +++-- .../sis/referencing/MultiRegisterOperations.java | 12 ++-- .../factory/ConcurrentAuthorityFactory.java | 30 ++------ .../factory/GeodeticAuthorityFactory.java | 16 +++-- .../factory/IdentifiedObjectFinder.java | 2 + .../referencing/factory/IdentifiedObjectSet.java | 7 +- .../factory/MultiAuthoritiesFactory.java | 42 +++++++---- .../referencing/factory/sql/EPSGDataAccess.java | 2 +- .../sis/referencing/factory/sql/EPSGFactory.java | 31 ++++---- .../sis/referencing/factory/sql/EPSGInstaller.java | 19 ++--- .../factory/sql/InstallationScriptProvider.java | 83 +++++++++++++--------- .../sis/referencing/factory/sql/SQLTranslator.java | 15 +++- .../apache/sis/referencing/internal/Resources.java | 6 ++ .../sis/referencing/internal/Resources.properties | 1 + .../referencing/internal/Resources_fr.properties | 1 + .../referencing/internal/ServicesForMetadata.java | 9 ++- .../operation/CoordinateOperationRegistry.java | 13 +++- .../operation/transform/MathTransformBuilder.java | 4 +- .../org/apache/sis/io/wkt/WKTDictionaryTest.java | 41 ++++++----- .../sis/referencing/AuthorityFactoriesTest.java | 15 ++-- .../sis/referencing/EPSGFactoryFallbackTest.java | 3 + .../referencing/factory/AuthorityFactoryMock.java | 10 ++- .../factory/CommonAuthorityFactoryTest.java | 15 +++- .../factory/MultiAuthoritiesFactoryTest.java | 37 ++++++---- .../sis/referencing/factory/TestFactorySource.java | 7 +- .../referencing/factory/sql/EPSGFactoryTest.java | 12 ++-- .../referencing/factory/sql/EPSGInstallerTest.java | 5 +- .../main/org/apache/sis/util/resources/Errors.java | 7 +- .../apache/sis/util/resources/Errors.properties | 1 - .../apache/sis/util/resources/Errors_fr.properties | 1 - .../org/apache/sis/util/resources/Messages.java | 6 ++ .../apache/sis/util/resources/Messages.properties | 1 + .../sis/util/resources/Messages_fr.properties | 1 + geoapi/snapshot | 2 +- incubator/build.gradle.kts | 1 + .../sis/resources/embedded/EmbeddedResources.java | 3 +- 40 files changed, 313 insertions(+), 190 deletions(-) diff --cc endorsed/src/org.apache.sis.metadata/main/org/apache/sis/util/iso/AbstractFactory.java index 11a32493d4,63ffdc7d42..8fc3bb9356 --- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/util/iso/AbstractFactory.java +++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/util/iso/AbstractFactory.java @@@ -21,6 -22,6 +21,9 @@@ import org.opengis.metadata.citation.Ci import org.apache.sis.metadata.simple.SimpleCitation; import org.apache.sis.util.privy.Strings; ++// Specific to the geoapi-3.1 and master branches: ++import org.apache.sis.util.collection.BackingStoreException; ++ /** * Base class of factories provided in the Apache SIS library. @@@ -68,10 -70,15 +71,15 @@@ public abstract class AbstractFactory i @Override public String toString() { final var args = new Object[2]; - Citation c = getVendor(); - if (c != null) { - args[0] = "vendor"; - args[1] = c.getTitle(); + try { + Citation c = getVendor(); + if (c != null) { + args[0] = "vendor"; + args[1] = c.getTitle(); + } - } catch (FactoryException e) { ++ } catch (BackingStoreException e) { + args[0] = "exception"; + args[1] = e.toString(); } return Strings.toString(getClass(), args); } diff --cc endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/ConcurrentAuthorityFactory.java index 2f149df689,3e675a5408..9194cb888e --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/ConcurrentAuthorityFactory.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/ConcurrentAuthorityFactory.java @@@ -63,6 -62,6 +62,9 @@@ import org.apache.sis.system.DelayedRun import org.apache.sis.system.Configuration; import org.apache.sis.system.Shutdown; ++// Specific to the geoapi-3.1 and master branches: ++import org.apache.sis.util.collection.BackingStoreException; ++ /** * A concurrent authority factory that caches all objects created by another factory. @@@ -726,15 -721,13 +724,12 @@@ public abstract class ConcurrentAuthori * </li> * </ul> * - * If this method cannot get a Data Access Object (for example because no database connection is available), - * then this method returns {@code null}. - * * @return the organization responsible for definition of the database, or {@code null} if unavailable. - * @throws FactoryException if an error occurred while creating the Data Access Object (<abbr>DAO</abbr>). */ @Override - public Citation getAuthority() throws FactoryException { + public Citation getAuthority() { Citation c = authority; - if (c == null || c == UNAVAILABLE) try { - if (c == null) { ++ if (c == null) try { final DAO factory = getDataAccess(); try { /* @@@ -745,19 -738,6 +740,8 @@@ } finally { release("getAuthority", Citation.class, null); } + } catch (FactoryException e) { - authority = UNAVAILABLE; - /* - * Use the warning level only on the first failure, then the fine level on all subsequent failures. - * Do not log the stack trace if we failed because of UnavailableFactoryException since it may be - * normal (the EPSG geodetic dataset is optional, even if strongly recommended). - */ - final var record = new LogRecord(c == null ? Level.WARNING : Level.FINE, e.getLocalizedMessage()); - if (!(e instanceof UnavailableFactoryException)) { - record.setThrown(e); - } - Logging.completeAndLog(LOGGER, ConcurrentAuthorityFactory.class, "getAuthority", record); - c = null; ++ throw new BackingStoreException(e); } return c; } diff --cc endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/IdentifiedObjectSet.java index 3abc6e9f4b,818e5379f3..ade10ebfd0 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/IdentifiedObjectSet.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/IdentifiedObjectSet.java @@@ -503,9 -504,16 +504,11 @@@ public class IdentifiedObjectSet<T exte * * @param object the object for which to get the authority code. * @return the authority code of the given identified object. + * @throws BackingStoreException if an error occurred while fetching the authority code. */ protected String getAuthorityCode(final T object) { - final Identifier id = IdentifiedObjects.getIdentifier(object, factory.getAuthority()); - final Citation authority; - try { - authority = factory.getAuthority(); - } catch (FactoryException e) { - throw new BackingStoreException(e); - } ++ final Citation authority = factory.getAuthority(); + final Identifier id = IdentifiedObjects.getIdentifier(object, authority); return (id != null) ? id.getCode() : IdentifiedObjects.getIdentifierOrName(object); } diff --cc endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/MultiAuthoritiesFactory.java index 40e31a1cb6,2a274354f7..82c8a3d171 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/MultiAuthoritiesFactory.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/MultiAuthoritiesFactory.java @@@ -520,12 -525,12 +525,14 @@@ public class MultiAuthoritiesFactory ex * This method delegates to {@link GeodeticAuthorityFactory#getCodeSpaces()} if possible, * or reproduces its default implementation otherwise. */ - private static Set<String> getCodeSpaces(final AuthorityFactory factory) { + private static Set<String> getCodeSpaces(final AuthorityFactory factory) throws FactoryException { if (factory instanceof GeodeticAuthorityFactory) { return ((GeodeticAuthorityFactory) factory).getCodeSpaces(); -- } else { ++ } else try { final String authority = Citations.toCodeSpace(factory.getAuthority()); return (authority != null) ? Set.of(authority) : Set.of(); ++ } catch (BackingStoreException e) { ++ throw e.unwrapOrRethrow(FactoryException.class); } } @@@ -616,12 -628,12 +630,14 @@@ */ if (request.hasVersion()) { factory = factories.get(request.versionOf(null)); -- if (factory != null) { ++ if (factory != null) try { if (request.versionOf(factory.getAuthority()) == request) { // Default factory is for the version that user requested. Cache that finding. return cache(request, factory); } factory = null; ++ } catch (BackingStoreException e) { ++ throw e.unwrapOrRethrow(FactoryException.class); } } /* @@@ -658,7 -670,7 +674,7 @@@ * We have no choice when ignoring the version number causes a conflict, or * when the user asked for a specific version. */ -- if (factory != cached || (request.hasVersion() && request.isSameAuthority(unversioned))) { ++ if (factory != cached || (request.hasVersion() && request.isSameAuthority(unversioned))) try { final AuthorityFactoryIdentifier versioned = unversioned.versionOf(factory.getAuthority()); if (versioned != unversioned) { /* @@@ -681,6 -693,6 +697,8 @@@ if (request.equals(versioned)) { return cached; } ++ } catch (BackingStoreException e) { ++ throw e.unwrapOrRethrow(FactoryException.class); } if (found != null) { return found; diff --cc endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/ServicesForMetadata.java index 9ff0ed9f21,9ff0ed9f21..593283717c --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/ServicesForMetadata.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/ServicesForMetadata.java @@@ -72,6 -72,6 +72,9 @@@ import org.apache.sis.util.logging.Logg // Specific to the geoapi-3.1 and geoapi-4.0 branches: import org.opengis.metadata.Identifier; ++// Specific to the geoapi-3.1 and master branches: ++import org.apache.sis.util.collection.BackingStoreException; ++ /** * Implements the referencing services needed by the {@code org.apache.sis.metadata} module. @@@ -502,7 -502,7 +505,11 @@@ public final class ServicesForMetadata case Constants.EPSG: { final Citation authority; try { -- authority = CRS.getAuthorityFactory(Constants.EPSG).getAuthority(); ++ try { ++ authority = CRS.getAuthorityFactory(Constants.EPSG).getAuthority(); ++ } catch (BackingStoreException e) { ++ throw e.unwrapOrRethrow(FactoryException.class); ++ } } catch (FactoryException e) { final String msg = Exceptions.getLocalizedMessage(e, locale); return (msg != null) ? msg : Classes.getShortClassName(e); diff --cc endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/CoordinateOperationRegistry.java index 0d185e92f5,35a95e6a39..0286e7afa0 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/CoordinateOperationRegistry.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/CoordinateOperationRegistry.java @@@ -273,7 -273,7 +273,11 @@@ class CoordinateOperationRegistry if (registry instanceof GeodeticAuthorityFactory) { codeFinder = ((GeodeticAuthorityFactory) registry).newIdentifiedObjectFinder(); } else try { -- codeFinder = IdentifiedObjects.newFinder(Citations.toCodeSpace(registry.getAuthority())); ++ try { ++ codeFinder = IdentifiedObjects.newFinder(Citations.toCodeSpace(registry.getAuthority())); ++ } catch (BackingStoreException e) { ++ throw e.unwrapOrRethrow(FactoryException.class); ++ } } catch (NoSuchAuthorityFactoryException e) { recoverableException("<init>", e); } @@@ -328,8 -328,8 +332,13 @@@ ? IdentifiedObjectFinder.Domain.EXHAUSTIVE_VALID_DATASET : IdentifiedObjectFinder.Domain.VALID_DATASET); int matchCount = 0; -- final Citation authority = registry.getAuthority(); try { ++ final Citation authority; ++ try { ++ authority = registry.getAuthority(); ++ } catch (BackingStoreException e) { ++ throw e.unwrapOrRethrow(FactoryException.class); ++ } for (final IdentifiedObject candidate : codeFinder.find(crs)) { final Identifier identifier = IdentifiedObjects.getIdentifier(candidate, authority); if (identifier != null) { diff --cc endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/factory/AuthorityFactoryMock.java index daa8d5fa02,0720e17f41..d913f062bc --- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/factory/AuthorityFactoryMock.java +++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/factory/AuthorityFactoryMock.java @@@ -125,10 -126,10 +126,11 @@@ public final class AuthorityFactoryMoc * Returns the geodetic object for the given code. * * @throws NoSuchAuthorityCodeException if the given code is unknown. + * @throws FactoryException if the creation failed for another reason. */ @Override + @SuppressWarnings("removal") - public IdentifiedObject createObject(final String code) throws NoSuchAuthorityCodeException { + public IdentifiedObject createObject(final String code) throws FactoryException { assertFalse(isClosed()); final int n; try { diff --cc geoapi/snapshot index d71280997a,c830770c8c..0172e7599f --- a/geoapi/snapshot +++ b/geoapi/snapshot @@@ -1,1 -1,1 +1,1 @@@ - Subproject commit d71280997a414d08eefa588c12415cef390011e2 -Subproject commit c830770c8c13ea9219a9eefd98cf08e18a01c33c ++Subproject commit 0172e7599f6ae68410cfaba2599e2dee3afec83f