sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1729687 - in /sis/branches/JDK8/core: sis-metadata/src/main/java/org/apache/sis/internal/metadata/sql/ sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/ sis-referencing/src/main/resources/org/ sis-referencing/src/main/r...
Date Wed, 10 Feb 2016 18:54:32 GMT
Author: desruisseaux
Date: Wed Feb 10 18:54:32 2016
New Revision: 1729687

URL: http://svn.apache.org/viewvc?rev=1729687&view=rev
Log:
Define an InstallationScriptProvider that users can override for specifying where to get the EPSG's SQL scripts.
The intend is to allow user to solve the licensing issue as they see fit, and reduce the need for Apache SIS to
bundle the SQL script themselves (or at least make a little bit easier for the users to plugin their own copy of
the scripts).

Added:
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/InstallationScriptProvider.java   (with props)
    sis/branches/JDK8/core/sis-referencing/src/main/resources/org/
    sis/branches/JDK8/core/sis-referencing/src/main/resources/org/apache/
    sis/branches/JDK8/core/sis-referencing/src/main/resources/org/apache/sis/
    sis/branches/JDK8/core/sis-referencing/src/main/resources/org/apache/sis/referencing/
    sis/branches/JDK8/core/sis-referencing/src/main/resources/org/apache/sis/referencing/factory/
    sis/branches/JDK8/core/sis-referencing/src/main/resources/org/apache/sis/referencing/factory/sql/
    sis/branches/JDK8/core/sis-referencing/src/main/resources/org/apache/sis/referencing/factory/sql/EPSG.sql   (with props)
Modified:
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/sql/ScriptRunner.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGFactory.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGInstaller.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/package-info.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGDataFormatter.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGInstallerTest.java

Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/sql/ScriptRunner.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/sql/ScriptRunner.java?rev=1729687&r1=1729686&r2=1729687&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/sql/ScriptRunner.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/sql/ScriptRunner.java [UTF-8] Wed Feb 10 18:54:32 2016
@@ -21,8 +21,7 @@ import java.util.HashMap;
 import java.util.Locale;
 import java.io.EOFException;
 import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
+import java.io.BufferedReader;
 import java.io.LineNumberReader;
 import java.io.StringReader;
 import java.sql.Statement;
@@ -97,12 +96,6 @@ public class ScriptRunner implements Aut
     private static final String ESCAPE = "$BODY$";
 
     /**
-     * The character encoding of SQL scripts. Typical values are {@code "UTF-8"} or {@code "ISO-8859-1"}.
-     * For SQL scripts provided by the EPSG, the encoding shall be {@code "ISO-8859-1"}.
-     */
-    private final String encoding;
-
-    /**
      * The presumed dialect spoken by the database.
      */
     private final Dialect dialect;
@@ -229,17 +222,13 @@ public class ScriptRunner implements Aut
      * </ul>
      *
      * @param connection        The connection to the database.
-     * @param encoding          The encoding of SQL scripts. Typical values are {@code "UTF-8"} or {@code "ISO-8859-1"}.
-     *                          For SQL scripts provided by the EPSG authority, the encoding shall be {@code "ISO-8859-1"}.
      * @param maxRowsPerInsert  Maximum number of rows per {@code "INSERT INTO"} statement.
      * @throws SQLException if an error occurred while creating a SQL statement.
      */
-    protected ScriptRunner(final Connection connection, final String encoding, int maxRowsPerInsert) throws SQLException {
+    protected ScriptRunner(final Connection connection, int maxRowsPerInsert) throws SQLException {
         ArgumentChecks.ensureNonNull("connection", connection);
-        ArgumentChecks.ensureNonNull("encoding", encoding);
         ArgumentChecks.ensurePositive("maxRowsPerInsert", maxRowsPerInsert);
         final DatabaseMetaData metadata = connection.getMetaData();
-        this.encoding           = encoding;
         this.dialect            = Dialect.guess(metadata);
         this.identifierQuote    = metadata.getIdentifierQuoteString();
         this.isSchemaSupported  = metadata.supportsSchemasInTableDefinitions() &&
@@ -351,39 +340,22 @@ public class ScriptRunner implements Aut
      * @throws SQLException if an error occurred while executing a SQL statement.
      */
     public final int run(final String statement) throws IOException, SQLException {
-        return run(new LineNumberReader(new StringReader(statement)));
-    }
-
-    /**
-     * Runs the SQL script from the given input stream, which will be closed.
-     * Lines are read and grouped up to the terminal {@value #END_OF_STATEMENT} character, then sent to the database.
-     *
-     * @param  filename Name of the SQL script being executed. This is used only for error reporting.
-     * @param  in The stream to read. <strong>This stream will be closed</strong> at the end.
-     * @return The number of rows added or modified as a result of the script execution.
-     * @throws IOException if an error occurred while reading the input.
-     * @throws SQLException if an error occurred while executing a SQL statement.
-     */
-    public final int run(final String filename, final InputStream in) throws IOException, SQLException {
-        currentFile = filename;
-        final int count;
-        try (LineNumberReader reader = new LineNumberReader(new InputStreamReader(in, encoding))) {
-            count = run(reader);
-        }
-        currentFile = null;
-        return count;
+        return run(null, new LineNumberReader(new StringReader(statement)));
     }
 
     /**
      * Run the script from the given reader. Lines are read and grouped up to the
      * terminal {@value #END_OF_STATEMENT} character, then sent to the database.
      *
+     * @param  filename Name of the SQL script being executed. This is used only for error reporting.
      * @param  in The stream to read. It is caller's responsibility to close this reader.
      * @return The number of rows added or modified as a result of the script execution.
      * @throws IOException if an error occurred while reading the input.
      * @throws SQLException if an error occurred while executing a SQL statement.
      */
-    private int run(final LineNumberReader in) throws IOException, SQLException {
+    public final int run(final String filename, final BufferedReader in) throws IOException, SQLException {
+        currentFile = filename;
+        currentLine = 0;
         int     statementCount     = 0;         // For informative purpose only.
         int     posOpeningQuote    = -1;        // -1 if we are not inside a text.
         boolean isInsideIdentifier = false;
@@ -398,7 +370,9 @@ public class ScriptRunner implements Aut
                 if (s >= line.length() || line.regionMatches(s, COMMENT, 0, COMMENT.length())) {
                     continue;
                 }
-                currentLine = in.getLineNumber();
+                if (in instanceof LineNumberReader) {
+                    currentLine = ((LineNumberReader) in).getLineNumber();
+                }
             } else {
                 buffer.append('\n');
             }
@@ -532,6 +506,7 @@ parseLine:  while (pos < length) {
         if (!line.isEmpty() && !line.startsWith(COMMENT)) {
             throw new EOFException(Errors.format(Errors.Keys.UnexpectedEndOfString_1, line));
         }
+        currentFile = null;
         return statementCount;
     }
 
@@ -642,7 +617,8 @@ parseLine:  while (pos < length) {
     public String status(final Locale locale) {
         String position = null;
         if (currentFile != null) {
-            position = Errors.getResources(locale).getString(Errors.Keys.ErrorInFileAtLine_2, currentFile, currentLine);
+            position = Errors.getResources(locale).getString(Errors.Keys.ErrorInFileAtLine_2, currentFile,
+                    (currentLine != 0) ? currentLine : '?');
         }
         if (currentSQL != null) {
             final StringBuilder buffer = new StringBuilder();

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGFactory.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGFactory.java?rev=1729687&r1=1729686&r2=1729687&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGFactory.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGFactory.java [UTF-8] Wed Feb 10 18:54:32 2016
@@ -44,10 +44,6 @@ import org.apache.sis.referencing.factor
 import org.apache.sis.referencing.factory.UnavailableFactoryException;
 import org.apache.sis.util.ArgumentChecks;
 import org.apache.sis.util.Localized;
-import org.apache.sis.util.ObjectConverters;
-
-// Branch-dependent imports
-import java.nio.file.Path;
 
 
 /**
@@ -152,10 +148,10 @@ public class EPSGFactory extends Concurr
     private final String schema;
 
     /**
-     * The path where to search for EPSG definition files if {@code EPSGFactory} needs to create the database,
-     * or {@code null} for searching in the {@linkplain Class#getResource(String) resources} instead.
+     * A provider of SQL scripts to use if {@code EPSGFactory} needs to create the database,
+     * or {@code null} for the default mechanism.
      */
-    private final Path scriptDirectory;
+    private final InstallationScriptProvider scriptProvider;
 
     /**
      * The translator from the SQL statements using MS-Access dialect to SQL statements using the dialect
@@ -219,9 +215,9 @@ public class EPSGFactory extends Concurr
      *   <td>{@link String}</td>
      *   <td>The database schema that contains the EPSG tables (see {@linkplain #install install}).</td>
      *  </tr><tr>
-     *   <td>{@code scriptDirectory}</td>
-     *   <td>{@link java.nio.file.Path}, {@link java.io.File} or {@link java.net.URL}</td>
-     *   <td>The directory that contains the EPSG definition files (see {@linkplain #install install}).</td>
+     *   <td>{@code scriptProvider}</td>
+     *   <td>{@link InstallationScriptProvider}</td>
+     *   <td>A provider of SQL scripts to use if {@code EPSGFactory} needs to create the database.</td>
      *  </tr><tr>
      *   <td>{@code locale}</td>
      *   <td>{@link Locale}</td>
@@ -250,11 +246,11 @@ public class EPSGFactory extends Concurr
         if (properties == null) {
             properties = Collections.emptyMap();
         }
-        DataSource ds   = (DataSource) properties.get("dataSource");
-        Locale locale   = ObjectConverters.convert(properties.get("locale"),  Locale.class);
-        schema          = ObjectConverters.convert(properties.get("schema"),  String.class);
-        catalog         = ObjectConverters.convert(properties.get("catalog"), String.class);
-        scriptDirectory = ObjectConverters.convert(properties.get("scriptDirectory"), Path.class);
+        DataSource ds  = (DataSource)                 properties.get("dataSource");
+        Locale locale  = (Locale)                     properties.get("locale");
+        schema         = (String)                     properties.get("schema");
+        catalog        = (String)                     properties.get("catalog");
+        scriptProvider = (InstallationScriptProvider) properties.get("scriptProvider");
         if (locale == null) {
             locale = Locale.getDefault(Locale.Category.DISPLAY);
         }
@@ -334,14 +330,11 @@ public class EPSGFactory extends Concurr
      *     schemas in table definitions} or in {@linkplain DatabaseMetaData#supportsSchemasInDataManipulation()
      *     data manipulation}, then this property is ignored.</li>
      *
-     *   <li><b>{@code scriptDirectory}:</b><br>
-     *     a {@link java.nio.file.Path}, {@link java.io.File} or {@link java.net.URL} to a directory containing
-     *     the SQL scripts to execute. If non-null, that directory shall contain at least files matching the
-     *     {@code *Tables*.sql}, {@code *Data*.sql} and {@code *FKeys*.sql} patterns (those files are provided by EPSG).
-     *     Files matching the {@code *Patches*.sql}, {@code *Indexes*.sql} and {@code *Grant*.sql} patterns
-     *     (provided by Apache SIS) are optional but recommended.
-     *     If no directory is specified, then this method will search for resources provided by the
-     *     {@code geotk-epsg.jar} bundle.</li>
+     *   <li><b>{@code scriptProvider}:</b><br>
+     *     an {@link InstallationScriptProvider} giving the SQL scripts to execute for creating the EPSG database.
+     *     If no provider is specified, then this method will search for
+     *     {@code "EPSG_Tables.sql"}, {@code "EPSG_Data.sql"} and {@code "EPSG_FKeys.sql"} files in the
+     *     {@code $SIS_DATA/Databases/ExternalSources} directory.</li>
      * </ul>
      *
      * <p><b>Legal constraint:</b>
@@ -369,7 +362,7 @@ public class EPSGFactory extends Concurr
                         installer.prependNamespace(catalog);
                     }
                 }
-                installer.run(scriptDirectory);
+                installer.run(scriptProvider);
                 success = true;
             } finally {
                 if (ac) {

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGInstaller.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGInstaller.java?rev=1729687&r1=1729686&r2=1729687&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGInstaller.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGInstaller.java [UTF-8] Wed Feb 10 18:54:32 2016
@@ -27,22 +27,16 @@ import java.util.logging.Level;
 import java.util.logging.LogRecord;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
-import java.io.FileNotFoundException;
-import java.io.InputStream;
+import java.io.BufferedReader;
 import org.apache.sis.util.StringBuilders;
 import org.apache.sis.internal.metadata.sql.ScriptRunner;
 import org.apache.sis.internal.system.Loggers;
 import org.apache.sis.internal.util.Constants;
 import org.apache.sis.util.CharSequences;
-import org.apache.sis.util.resources.Errors;
 import org.apache.sis.util.resources.Messages;
 import org.apache.sis.util.logging.Logging;
 import org.apache.sis.util.logging.PerformanceLevel;
 
-// Branch-specific imports
-import java.nio.file.Files;
-import java.nio.file.Path;
-
 
 /**
  * Runs the SQL scripts for creating an EPSG database.
@@ -54,19 +48,6 @@ import java.nio.file.Path;
  */
 final class EPSGInstaller extends ScriptRunner {
     /**
-     * The embedded SQL scripts to execute for creating the EPSG database, in that order.
-     * The {@code ".sql"} suffix is omitted. The {@code "Grant"} script must be last.
-     */
-    private static final String[] SCRIPTS = {
-        "Tables", "Data", "Patches", "FKeys", "Indexes", "Grant"         // "Grant" must be last.
-    };
-
-    /**
-     * The encoding used in the SQL scripts.
-     */
-    static final String ENCODING = "ISO-8859-1";
-
-    /**
      * The pattern for an {@code "UPDATE … SET … REPLACE"} instruction.
      * Example:
      *
@@ -99,7 +80,7 @@ final class EPSGInstaller extends Script
      * @throws SQLException if an error occurred while executing a SQL statement.
      */
     public EPSGInstaller(final Connection connection) throws SQLException {
-        super(connection, ENCODING, 100);
+        super(connection, 100);
         boolean isReplaceSupported = false;
         final DatabaseMetaData metadata = connection.getMetaData();
         final String functions = metadata.getStringFunctions();
@@ -219,6 +200,9 @@ final class EPSGInstaller extends Script
         if (CharSequences.equalsIgnoreCase(sql, "COMMIT")) {
             return 0;
         }
+        if (!isGrantOnTableSupported && CharSequences.regionMatches(sql, 0, "GRANT")) {
+            return 0;
+        }
         if (statementToSkip != null && statementToSkip.reset(sql).matches()) {
             return 0;
         }
@@ -229,47 +213,23 @@ final class EPSGInstaller extends Script
     }
 
     /**
-     * Processes to the creation of the EPSG database using the files in the given directory.
-     * The given directory should contain at least files similar to the following ones
-     * (files without {@code ".sql"} extension are ignored):
-     *
-     * <ul>
-     *   <li>{@code EPSG_v8_18.mdb_Tables_PostgreSQL.sql}</li>
-     *   <li>{@code EPSG_v6_18.mdb_Data_PostgreSQL.sql}</li>
-     *   <li>{@code EPSG_v6_18.mdb_FKeys_PostgreSQL.sql}</li>
-     *   <li>Optional but recommended: {@code EPSG_v6_18.mdb_Indexes_PostgreSQL.sql}.</li>
-     * </ul>
-     *
-     * The suffix may be different (for example {@code "_MySQL.sql"} instead of {@code "_PostgreSQL.sql"})
-     * and the version number may be different.
-     *
-     * <p>If the given directory is {@code null}, then the scripts will be read from the resources.
-     * If no resources is found, then an exception will be thrown.
+     * Processes to the creation of the EPSG database using the SQL scripts from the given provider.
      *
      * @throws IOException if an error occurred while reading an input.
      * @throws SQLException if an error occurred while executing a SQL statement.
      */
-    public void run(final Path scriptDirectory) throws SQLException, IOException {
+    public void run(InstallationScriptProvider scriptProvider) throws SQLException, IOException {
         long time = System.nanoTime();
         log(Messages.getResources(null).getLogRecord(Level.INFO, Messages.Keys.CreatingSchema_2, Constants.EPSG, getURL()));
-        int numScripts = SCRIPTS.length;
-        if (!isGrantOnTableSupported) {
-            numScripts--;
+        if (scriptProvider == null) {
+            scriptProvider = new InstallationScriptProvider.Default();
         }
+        final String[] scripts = scriptProvider.getScriptNames();
         int numRows = 0;
-        for (int i=0; i<numScripts; i++) {
-            final String script = SCRIPTS[i] + ".sql";
-            final InputStream in;
-            if (scriptDirectory != null) {
-                in = Files.newInputStream(scriptDirectory.resolve(script));
-            } else {
-                in = EPSGInstaller.class.getResourceAsStream(script);
-                if (in == null) {
-                    throw new FileNotFoundException(Errors.format(Errors.Keys.FileNotFound_1, script));
-                }
+        for (int i=0; i<scripts.length; i++) {
+            try (BufferedReader in = scriptProvider.getScriptContent(i)) {
+                numRows += run(scripts[i], in);
             }
-            numRows += run(script, in);
-            // The stream will be closed by the run method.
         }
         time = System.nanoTime() - time;
         log(Messages.getResources(null).getLogRecord(

Added: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/InstallationScriptProvider.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/InstallationScriptProvider.java?rev=1729687&view=auto
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/InstallationScriptProvider.java (added)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/InstallationScriptProvider.java [UTF-8] Wed Feb 10 18:54:32 2016
@@ -0,0 +1,298 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.referencing.factory.sql;
+
+import java.sql.Connection;
+import java.io.BufferedReader;
+import java.io.LineNumberReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.IOException;
+import java.io.FileNotFoundException;
+import java.nio.charset.Charset;
+import org.opengis.util.InternationalString;
+import org.apache.sis.internal.util.Constants;
+import org.apache.sis.util.resources.Errors;
+import org.apache.sis.util.ArgumentChecks;
+import org.apache.sis.internal.system.DataDirectory;
+
+// Branch-dependent imports
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+
+
+/**
+ * Provides SQL scripts needed for creating a copy of the EPSG dataset. This interface allows Apache SIS
+ * users to bundle the EPSG dataset in their own product for automatic installation when first needed.
+ * That dataset is not included directly in Apache SIS for
+ * <a href="https://issues.apache.org/jira/browse/LEGAL-183">licensing reasons</a>.
+ *
+ * <p>Implementations of this interface can be declared in the following file for automatic discovery
+ * by {@link EPSGFactory} (see {@link java.util.ServiceLoader} for more information):</p>
+ *
+ * {@preformat text
+ *     META-INF/services/org.apache.sis.referencing.factory.sql.InstallationScriptProvider
+ * }
+ *
+ * <div class="section">How this interface is used</div>
+ * The first time that an {@link EPSGDataAccess} needs to be instantiated, {@link EPSGFactory} verifies if the
+ * EPSG database exists.  If it does not, then the {@link EPSGFactory#install(Connection)} method searches for
+ * the first {@code InstallationScriptProvider} instance for which {@link #getAuthority} returns {@code "EPSG"}.
+ * The {@linkplain #getLicense license} may be shown to the user if the application allows that (for example when
+ * running as a {@linkplain org.apache.sis.console console application}). If the installation process is allowed
+ * to continue, it will iterate over all readers provided by {@link #getScriptContent(int)} and execute the SQL
+ * statements (not necessarily verbatim; the installation process may adapt to the target database).
+ *
+ * @author  Martin Desruisseaux (Geomatys)
+ * @since   0.7
+ * @version 0.7
+ * @module
+ */
+public abstract class InstallationScriptProvider {
+    /**
+     * A sentinel value for the content of the script to execute after the official EPSG scripts.
+     * This is an Apache SIS build-in script for creating indexes or performing any other manipulation
+     * that help SIS to use the EPSG dataset. Those indexes are not required for proper working of
+     * {@link EPSGFactory}, but can significantly improve performances.
+     */
+    protected static final String POST_CREATE = "(post create)";
+
+    /**
+     * The names of the SQL scripts to read.
+     */
+    private final String[] names;
+
+    /**
+     * Creates a new provider which will read script files of the given names in that order.
+     * The given names are often filenames, but not necessarily
+     * (it is okay to use those names only as labels).
+     *
+     * <p>For the EPSG dataset, the {@code names} argument is usually
+     * (potentially completed with EPSG dataset version and database software name):</p>
+     *
+     * <blockquote><code>
+     *   "EPSG_Tables.sql", "EPSG_Data.sql", "EPSG_FKeys.sql", {@linkplain #POST_CREATE}
+     * </code></blockquote>
+     *
+     * @param names Names of the SQL scripts to read.
+     *
+     * @see #getScriptNames()
+     * @see #open(String)
+     */
+    protected InstallationScriptProvider(final String... names) {
+        ArgumentChecks.ensureNonNull("filenames", names);
+        this.names = names;
+    }
+
+    /**
+     * Returns the identifier of the dataset installed by the SQL scripts, or {@code "unavailable"}
+     * if the SQL scripts are not available.
+     *
+     * <p>Currently, the only allowed return values are {@code "EPSG"} and {@code "unavailable"}.
+     * This list may be expanded in future SIS versions if more authorities are supported.</p>
+     *
+     * @return {@code "EPSG"} if the SQL scripts for installing the EPSG dataset are available,
+     *         or {@code "unavailable"} otherwise.
+     */
+    public abstract String getAuthority();
+
+    /**
+     * Returns the terms of use of the dataset, or {@code null} if presumed already accepted.
+     * The terms of use can be returned in either plain text or HTML.
+     *
+     * <p>For the EPSG dataset, this method should return the content of the
+     * <a href="http://www.epsg.org/TermsOfUse">http://www.epsg.org/TermsOfUse</a> page.</p>
+     *
+     * @param  mimeType Either {@code "text/plain"} or {@code "text/html"}.
+     * @return The terms of use in plain text or HTML, or {@code null} if the license is presumed already accepted.
+     * @throws IOException if an error occurred while reading the license file.
+     */
+    public abstract InternationalString getLicense(String mimeType) throws IOException;
+
+    /**
+     * Returns the names of all SQL scripts to execute.
+     * Those names are often filenames, but not necessarily (they may be just labels).
+     *
+     * @return The names of all SQL scripts to execute.
+     */
+    public String[] getScriptNames() {
+        return names.clone();
+    }
+
+    /**
+     * Returns a reader for the SQL script at the given index. Contents may be read from files in a local directory,
+     * or from resources in a JAR file, or from entries in a ZIP file, or any other means at implementor choice.
+     * The {@link BufferedReader} instances shall be closed by the caller.
+     *
+     * <div class="section">EPSG case</div>
+     * In the EPSG dataset case, the iterator should return {@code BufferedReader} instances for the following files
+     * (replace {@code <version>} by the EPSG version number and {@code <product>} by the target database) in same order.
+     * The first 3 files can be downloaded from <a href="http://www.epsg.org/">http://www.epsg.org/</a>.
+     * The fourth file is provided by Apache SIS.
+     *
+     * <ol>
+     *   <li>Content of {@code "EPSG_<version>.mdb_Tables_<product>.sql"}, a data definition script that create empty tables.</li>
+     *   <li>Content of {@code "EPSG_<version>.mdb_Data_<product>.sql"}, a data manipulation script that populate the tables.</li>
+     *   <li>Content of {@code "EPSG_<version>.mdb_FKeys_<product>.sql"}, a data definition script that create foreigner key constraints.</li>
+     *   <li>Content of {@link #POST_CREATE}, a data definition and data control script that create indexes and set permissions.</li>
+     * </ol>
+     *
+     * Implementors are free to return a different set of scripts with equivalent content.
+     *
+     * <div class="section">Default implementation</div>
+     * The default implementation invokes {@link #open(String)} – except for {@link #POST_CREATE} in which case
+     * an Apache SIS build-in script is used – and wrap the result in a {@link LineNumberReader}.
+     *
+     * @param  index Index of the SQL script to read, from 0 inclusive to
+     *         <code>{@linkplain #getScriptNames()}.length</code> exclusive.
+     * @return A reader for the content of SQL script to execute.
+     * @throws IOException if an error occurred while creating the reader.
+     */
+    public BufferedReader getScriptContent(final int index) throws IOException {
+        ArgumentChecks.ensureValidIndex(names.length, index);
+        final String authority = getAuthority();
+        if (!Constants.EPSG.equals(authority)) {
+            throw new IllegalStateException(Errors.format(Errors.Keys.UnknownAuthority_1, authority));
+        }
+        String name = names[index];
+        final Charset charset;
+        final InputStream in;
+        if (POST_CREATE.equals(name)) {
+            name = authority.concat(".sql");
+            in = InstallationScriptProvider.class.getResourceAsStream(name);
+            charset = StandardCharsets.UTF_8;
+        } else {
+            in = open(name);
+            charset = StandardCharsets.ISO_8859_1;
+        }
+        if (in == null) {
+            throw new FileNotFoundException(Errors.format(Errors.Keys.FileNotFound_1, name));
+        }
+        return new LineNumberReader(new InputStreamReader(in, charset));
+    }
+
+    /**
+     * Opens the input stream for the SQL script of the given name.
+     * This method is invoked by the default implementation of {@link #getScriptContent(int)}
+     * for all scripts except {@link #POST_CREATE}.
+     *
+     * <div class="note"><b>Examples:</b>
+     * If this {@code InstallationScriptProvider} instance gets the SQL scripts from files in a well-known directory
+     * and if the names given at {@linkplain #InstallationScriptProvider(String...) construction time} are the
+     * filenames in that directory, then this method can be implemented as below:
+     *
+     * {@preformat java
+     *    protected InputStream open(String name) throws IOException {
+     *        return Files.newInputStream(directory.resolve(name));
+     *    }
+     * }
+     *
+     * If this {@code InstallationScriptProvider} instance rather gets the SQL scripts from resources bundled
+     * in the same JAR files than and in the same package, then this method can be implemented as below:
+     *
+     * {@preformat java
+     *    protected InputStream open(String name) {
+     *        return MyClass.getResourceAsStream(name);
+     *    }
+     * }
+     * </div>
+     *
+     * @param  name Name of the script file to open.
+     * @return An input stream opened of the given script file.
+     * @throws IOException if an error occurred while opening the file.
+     */
+    protected abstract InputStream open(final String name) throws IOException;
+
+
+
+
+    /**
+     * The default implementation which use the scripts in the {@code $SIS_DATA/Databases/ExternalSources}
+     * directory, if present. This class expects the files to have those exact names:
+     *
+     * <ul>
+     *   <li>{@code EPSG_Tables.sql}</li>
+     *   <li>{@code EPSG_Data.sql}</li>
+     *   <li>{@code EPSG_FKeys.sql}</li>
+     * </ul>
+     *
+     * @author  Martin Desruisseaux (Geomatys)
+     * @since   0.7
+     * @version 0.7
+     * @module
+     */
+    static final class Default extends InstallationScriptProvider {
+        /**
+         * The directory containing the scripts, or {@code null} if it does not exist.
+         */
+        private final Path directory;
+
+        /**
+         * Creates a default provider.
+         */
+        public Default() {
+            super("EPSG_Tables.sql",
+                  "EPSG_Data.sql",
+                  "EPSG_FKeys.sql",
+                  POST_CREATE);
+
+            Path dir = DataDirectory.DATABASES.getDirectory();
+            if (dir != null) {
+                dir = dir.resolve("ExternalSources");
+                if (!Files.isRegularFile(dir.resolve("EPSG_Tables.sql"))) {
+                    dir = null;
+                }
+            }
+            directory = dir;
+        }
+
+        /**
+         * Returns {@code "EPSG"} if the scripts exist in the {@code ExternalSources} subdirectory,
+         * or {@code "unavailable"} otherwise.
+         *
+         * @return {@code "EPSG"} if the SQL scripts for installing the EPSG dataset are available,
+         *         or {@code "unavailable"} otherwise.
+         */
+        @Override
+        public String getAuthority() {
+            return (directory != null) ? Constants.EPSG : "unavailable";
+        }
+
+        /**
+         * Returns {@code null} since the user is presumed to have downloaded the files himself.
+         *
+         * @return The terms of use in plain text or HTML, or {@code null} if the license is presumed already accepted.
+         */
+        @Override
+        public InternationalString getLicense(String mimeType) {
+            return null;
+        }
+
+        /**
+         * Opens the input stream for the SQL script of the given name.
+         *
+         * @param  name Name of the script file to open.
+         * @return An input stream opened of the given script file.
+         * @throws IOException if an error occurred while opening the file.
+         */
+        @Override
+        protected InputStream open(final String name) throws IOException {
+            return Files.newInputStream(directory.resolve(name));
+        }
+    }
+}

Propchange: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/InstallationScriptProvider.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/InstallationScriptProvider.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain;charset=UTF-8

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/package-info.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/package-info.java?rev=1729687&r1=1729686&r2=1729687&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/package-info.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/package-info.java [UTF-8] Wed Feb 10 18:54:32 2016
@@ -16,9 +16,12 @@
  */
 
 /**
- * Factories for geodetic objects defined in a SQL database.
+ * Factories for geodetic objects defined in a SQL database, typically the EPSG dataset.
  * The main class in this package is {@link org.apache.sis.referencing.factory.sql.EPSGFactory},
  * which requires a {@link javax.sql.DataSource} providing connections to an EPSG database.
+ *
+ *
+ * <div class="section">Connection to the database</div>
  * By default Apache SIS used Apache Derby (a.k.a. JavaDB), but the database can also be PostgreSQL or MS-Access.
  * The connection is obtained by the first of the following data sources which is found:
  *
@@ -44,17 +47,20 @@
  * For example the two following method calls fetch the same object:
  *
  * <ul>
- *   <li>{@code createProjectedCRS("NTF (Paris) / Lambert zone II")}</li>
  *   <li>{@code createProjectedCRS("27572")}</li>
+ *   <li>{@code createProjectedCRS("NTF (Paris) / Lambert zone II")}</li>
  * </ul>
  *
- * However names may be ambiguous since the same name may be used for more than one object.
+ * <div class="note"><b>Note:</b> names may be ambiguous since the same name may be used for more than one object.
  * This is the case of <cite>"WGS 84"</cite> for example. If such an ambiguity is found, an exception will be thrown.
+ * For more determinism, the numerical codes are preferred.</div>
+ *
  *
- * <p>When an error is discovered in a Coordinate Reference System (CRS) definition, the EPSG group does not apply the
+ * <div class="section">How deprecated entries are handled</div>
+ * When an error is discovered in a Coordinate Reference System (CRS) definition, the EPSG group does not apply the
  * correction directly on the erroneous object (unless the correction is very minor).
  * Instead, the erroneous object is deprecated and a new one is created.
- * Apache SIS handles deprecated objects as below:</p>
+ * Apache SIS handles deprecated objects as below:
  *
  * <ul>
  *   <li>Deprecated objects are not listed in the collection returned by the

Added: sis/branches/JDK8/core/sis-referencing/src/main/resources/org/apache/sis/referencing/factory/sql/EPSG.sql
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/resources/org/apache/sis/referencing/factory/sql/EPSG.sql?rev=1729687&view=auto
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/resources/org/apache/sis/referencing/factory/sql/EPSG.sql (added)
+++ sis/branches/JDK8/core/sis-referencing/src/main/resources/org/apache/sis/referencing/factory/sql/EPSG.sql [UTF-8] Wed Feb 10 18:54:32 2016
@@ -0,0 +1,101 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+
+
+--
+-- For the "Scale factor at natural origin" parameter (EPSG:8805), replace the wrong "m" units (EPSG:9001)
+-- by the dimensionless unit (EPSG:9201). This change is a no-op on version 8.8 of EPSG dataset, but was
+-- affecting the following deprecated CRS in version 7.9:
+--
+--   * EPSG:3143    Fiji 1986 / Fiji Map Grid
+--   * EPSG:3774    NAD27 / Alberta 3TM ref merid 120 W
+--   * EPSG:3778    NAD83 / Alberta 3TM ref merid 120 W
+--   * EPSG:3782    NAD83(CSRS) / Alberta 3TM ref merid 120 W
+--
+UPDATE epsg_coordoperationparamvalue SET uom_code = 9201 WHERE parameter_code = 8805 AND uom_code = 9001;
+
+--
+-- Additional indexes for the EPSG database. Those indexes are not declared
+-- in the SQL scripts distributed by EPSG. They are not required for proper
+-- working of the EPSG factory, but can significantly improve performances.
+--
+
+-----------------------------------------------------------------------------
+-- Indexes for queries used by EPSGDataAccess.createFoo(epsgcode) methods. --
+-- Indexed fields are numeric values used mainly in equality comparisons.  --
+-----------------------------------------------------------------------------
+CREATE INDEX ix_alias_object_code                ON epsg_alias                     (object_code);
+CREATE INDEX ix_crs_datum_code                   ON epsg_coordinatereferencesystem (datum_code);
+CREATE INDEX ix_crs_projection_code              ON epsg_coordinatereferencesystem (projection_conv_code);
+CREATE INDEX ix_coordinate_axis_code             ON epsg_coordinateaxis            (coord_axis_code);
+CREATE INDEX ix_coordinate_axis_sys_code         ON epsg_coordinateaxis            (coord_sys_code);
+CREATE INDEX ix_coordinate_operation_crs         ON epsg_coordoperation            (source_crs_code, target_crs_code);
+CREATE INDEX ix_coordinate_operation_method_code ON epsg_coordoperation            (coord_op_method_code);
+CREATE INDEX ix_parameter_usage_method_code      ON epsg_coordoperationparamusage  (coord_op_method_code);
+CREATE INDEX ix_parameter_values                 ON epsg_coordoperationparamvalue  (coord_op_code, coord_op_method_code);
+CREATE INDEX ix_parameter_value_code             ON epsg_coordoperationparamvalue  (parameter_code);
+CREATE INDEX ix_path_concat_operation_code       ON epsg_coordoperationpath        (concat_operation_code);
+CREATE INDEX ix_supersession_object_code         ON epsg_supersession              (object_code);
+
+
+-----------------------------------------------------------------------------
+-- Indexes for queries used by EPSGDataAccess.createFoo(epsgcode) methods. --
+-- Indexed fields are numeric values used in ORDER BY clauses.             --
+-----------------------------------------------------------------------------
+CREATE INDEX ix_coordinate_axis_order            ON epsg_coordinateaxis           (coord_axis_order);
+CREATE INDEX ix_coordinate_operation_accuracy    ON epsg_coordoperation           (coord_op_accuracy);
+CREATE INDEX ix_parameter_order                  ON epsg_coordoperationparamusage (sort_order);
+CREATE INDEX ix_path_concat_operation_step       ON epsg_coordoperationpath       (op_path_step);
+CREATE INDEX ix_supersession_object_year         ON epsg_supersession             (supersession_year);
+CREATE INDEX ix_version_history_date             ON epsg_versionhistory           (version_date);
+
+
+-----------------------------------------------------------------------------
+-- Indexes on the object names for finding an EPSG code from a name.       --
+-----------------------------------------------------------------------------
+CREATE INDEX ix_name_crs            ON epsg_coordinatereferencesystem (coord_ref_sys_name);
+CREATE INDEX ix_name_cs             ON epsg_coordinatesystem          (coord_sys_name);
+CREATE INDEX ix_name_axis           ON epsg_coordinateaxisname        (coord_axis_name);
+CREATE INDEX ix_name_datum          ON epsg_datum                     (datum_name);
+CREATE INDEX ix_name_ellipsoid      ON epsg_ellipsoid                 (ellipsoid_name);
+CREATE INDEX ix_name_prime_meridian ON epsg_primemeridian             (prime_meridian_name);
+CREATE INDEX ix_name_coord_op       ON epsg_coordoperation            (coord_op_name);
+CREATE INDEX ix_name_method         ON epsg_coordoperationmethod      (coord_op_method_name);
+CREATE INDEX ix_name_parameter      ON epsg_coordoperationparam       (parameter_name);
+CREATE INDEX ix_name_unit           ON epsg_unitofmeasure             (unit_of_meas_name);
+
+
+-----------------------------------------------------------------------------
+-- Indexes used by EPSGDataAccess.Finder for reverse operation.            --
+-----------------------------------------------------------------------------
+CREATE INDEX ix_major_ellipsoid ON epsg_ellipsoid                 (semi_major_axis);
+CREATE INDEX ix_geogcrs_crs     ON epsg_coordinatereferencesystem (source_geogcrs_code);
+CREATE INDEX ix_ellipsoid_datum ON epsg_datum                     (ellipsoid_code);
+
+
+-----------------------------------------------------------------------------
+-- Grants read permission to all tables in the EPSG schema.                --
+-----------------------------------------------------------------------------
+GRANT SELECT ON TABLE epsg_alias TO PUBLIC;
+GRANT SELECT ON TABLE epsg_area TO PUBLIC;
+GRANT SELECT ON TABLE epsg_coordinateaxis TO PUBLIC;
+GRANT SELECT ON TABLE epsg_coordinateaxisname TO PUBLIC;
+GRANT SELECT ON TABLE epsg_coordoperation TO PUBLIC;
+GRANT SELECT ON TABLE epsg_coordoperationmethod TO PUBLIC;
+GRANT SELECT ON TABLE epsg_coordoperationparam TO PUBLIC;
+GRANT SELECT ON TABLE epsg_coordoperationparamusage TO PUBLIC;
+GRANT SELECT ON TABLE epsg_coordoperationparamvalue TO PUBLIC;
+GRANT SELECT ON TABLE epsg_coordoperationpath TO PUBLIC;
+GRANT SELECT ON TABLE epsg_coordinatereferencesystem TO PUBLIC;
+GRANT SELECT ON TABLE epsg_coordinatesystem TO PUBLIC;
+GRANT SELECT ON TABLE epsg_datum TO PUBLIC;
+GRANT SELECT ON TABLE epsg_ellipsoid TO PUBLIC;
+GRANT SELECT ON TABLE epsg_namingsystem TO PUBLIC;
+GRANT SELECT ON TABLE epsg_primemeridian TO PUBLIC;
+GRANT SELECT ON TABLE epsg_supersession TO PUBLIC;
+GRANT SELECT ON TABLE epsg_unitofmeasure TO PUBLIC;
+GRANT SELECT ON TABLE epsg_versionhistory TO PUBLIC;
+GRANT SELECT ON TABLE epsg_change TO PUBLIC;
+GRANT SELECT ON TABLE epsg_deprecation TO PUBLIC;

Propchange: sis/branches/JDK8/core/sis-referencing/src/main/resources/org/apache/sis/referencing/factory/sql/EPSG.sql
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sis/branches/JDK8/core/sis-referencing/src/main/resources/org/apache/sis/referencing/factory/sql/EPSG.sql
------------------------------------------------------------------------------
    svn:mime-type = text/plain;charset=UTF-8

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGDataFormatter.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGDataFormatter.java?rev=1729687&r1=1729686&r2=1729687&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGDataFormatter.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGDataFormatter.java [UTF-8] Wed Feb 10 18:54:32 2016
@@ -21,10 +21,11 @@ import java.util.HashMap;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
+import java.io.LineNumberReader;
+import java.io.InputStreamReader;
 import java.io.Writer;
 import java.io.BufferedWriter;
 import java.io.OutputStreamWriter;
-import java.io.InputStream;
 import java.io.IOException;
 import java.sql.Connection;
 import java.sql.SQLException;
@@ -35,6 +36,9 @@ import org.apache.sis.util.CharSequences
 import org.apache.sis.internal.metadata.sql.ScriptRunner;
 import org.apache.sis.internal.metadata.sql.TestDatabase;
 
+// Branch-dependent imports
+import java.nio.charset.StandardCharsets;
+
 
 /**
  * Rewrites the {@code INSERT TO ...} statements in a SQL script in a more compact form.
@@ -182,7 +186,7 @@ public final class EPSGDataFormatter ext
      * @throws SQLException if an error occurred while fetching metadata.
      */
     private EPSGDataFormatter(final Connection c) throws SQLException {
-        super(c, EPSGInstaller.ENCODING, Integer.MAX_VALUE);
+        super(c, Integer.MAX_VALUE);
         numBooleanColumnsForTables = new HashMap<>();
         numBooleanColumnsForTables.put("epsg_alias",                     0);
         numBooleanColumnsForTables.put("epsg_area",                      1);
@@ -231,8 +235,10 @@ public final class EPSGDataFormatter ext
         if (inputFile.equals(outputFile)) {
             throw new IllegalArgumentException("Input and output files are the same.");
         }
-        out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outputFile), EPSGInstaller.ENCODING));
-        try (final InputStream in = new FileInputStream(inputFile)) {
+        out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outputFile), StandardCharsets.ISO_8859_1));
+        try (final LineNumberReader in = new LineNumberReader(
+                new InputStreamReader(new FileInputStream(inputFile), StandardCharsets.ISO_8859_1)))
+        {
             run(inputFile.getName(), in);
         } finally {
             out.close();

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGInstallerTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGInstallerTest.java?rev=1729687&r1=1729686&r2=1729687&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGInstallerTest.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGInstallerTest.java [UTF-8] Wed Feb 10 18:54:32 2016
@@ -47,9 +47,6 @@ import org.junit.Test;
 import static org.junit.Assert.*;
 import static org.junit.Assume.*;
 
-// Branch-dependent imports
-import java.nio.file.Path;
-
 
 /**
  * Tests {@link EPSGInstaller} indirectly, through {@link EPSGFactory#install(Connection)}.
@@ -119,11 +116,9 @@ public final strictfp class EPSGInstalle
      */
     @Test
     public void testCreationOnDerby() throws Exception {
-        assumeTrue("Slow test skipped in non-extensive test mode.", RUN_EXTENSIVE_TESTS);
-        final Path scripts = TestDatabase.directory("ExternalSources");
         final DataSource ds = TestDatabase.create("test");
         try {
-            createAndTest(ds, scripts);
+            createAndTest(ds);
         } finally {
             TestDatabase.drop(ds);
         }
@@ -144,11 +139,10 @@ public final strictfp class EPSGInstalle
     @Test
     @Ignore("Skipped for protecting java.util.logging configuration against changes.")
     public void testCreationOnHSQLDB() throws Exception {
-        final Path scripts = TestDatabase.directory("ExternalSources");
         final DataSource ds = (DataSource) Class.forName("org.hsqldb.jdbc.JDBCDataSource").newInstance();
         ds.getClass().getMethod("setURL", String.class).invoke(ds, "jdbc:hsqldb:mem:test");
         try {
-            createAndTest(ds, scripts);
+            createAndTest(ds);
         } finally {
             try (Connection c = ds.getConnection(); Statement s = c.createStatement()) {
                 s.execute("SHUTDOWN");
@@ -162,11 +156,14 @@ public final strictfp class EPSGInstalle
      * Requests the "WGS84" and the "WGS72 / UTM zone 15N" coordinate reference systems from the EPSG database
      * at the given {@code DataSource}. Those requests should trig the creation of the EPSG database.
      */
-    private void createAndTest(final DataSource ds, final Path scripts) throws SQLException, FactoryException {
+    private void createAndTest(final DataSource ds) throws SQLException, FactoryException {
         listener.maximumLogCount = 100;
+        final InstallationScriptProvider scriptProvider = new InstallationScriptProvider.Default();
+        assumeTrue(scriptProvider.getAuthority().equals("EPSG"));
+
         final Map<String,Object> properties = new HashMap<>();
         assertNull(properties.put("dataSource", ds));
-        assertNull(properties.put("scriptDirectory", scripts));
+        assertNull(properties.put("scriptProvider", scriptProvider));
         assertEquals("Should not contain EPSG tables before we created them.", 0, countCRSTables(ds));
         assertEquals("Should not yet have logged anything at this point.", 100, listener.maximumLogCount);
         try (EPSGFactory factory = new EPSGFactory(properties)) {



Mime
View raw message