sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1722827 - 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-utility/src/main/java/org/apache/sis/util/resources/
Date Mon, 04 Jan 2016 10:19:08 GMT
Author: desruisseaux
Date: Mon Jan  4 10:19:07 2016
New Revision: 1722827

URL: http://svn.apache.org/viewvc?rev=1722827&view=rev
Log:
Detect sooner (at EPSGFactory construction time) when no EPSG database is available.

Modified:
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/sql/Initializer.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGFactory.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages.properties
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages_fr.properties

Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/sql/Initializer.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/sql/Initializer.java?rev=1722827&r1=1722826&r2=1722827&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/sql/Initializer.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/sql/Initializer.java
[UTF-8] Mon Jan  4 10:19:07 2016
@@ -16,6 +16,7 @@
  */
 package org.apache.sis.internal.metadata.sql;
 
+import java.util.Locale;
 import java.net.URL;
 import java.net.URLClassLoader;
 import java.util.ServiceLoader;
@@ -32,6 +33,7 @@ import javax.naming.NameNotFoundExceptio
 import org.apache.sis.internal.system.DataDirectory;
 import org.apache.sis.internal.system.Shutdown;
 import org.apache.sis.internal.system.Loggers;
+import org.apache.sis.util.resources.Messages;
 import org.apache.sis.util.logging.Logging;
 
 // Branch-dependent imports
@@ -99,9 +101,10 @@ public abstract class Initializer {
      *       creation since we are in the directory managed by SIS.</li>
      *   <li>If the {@code derby.system.home} property is defined, the data source
for {@code jdbc:derby:SpatialMetadata}.
      *       This database will <strong>not</strong> be created if it does not
exist.</li>
+     *   <li>Otherwise (no JNDI, no environment variable, no Derby property set), {@code
null}.</li>
      * </ol>
      *
-     * @return The data source for the {@code $SIS_DATA/Databases/SpatialMetadata} or equivalent
database.
+     * @return The data source for the {@code $SIS_DATA/Databases/SpatialMetadata} or equivalent
database, or {@code null} if none.
      * @throws javax.naming.NamingException     if an error occurred while fetching the data
source from a JNDI context.
      * @throws java.net.MalformedURLException   if an error occurred while converting the
{@code derby.jar} file to URL.
      * @throws java.lang.ClassNotFoundException if {@code derby.jar} has not been found on
the JDK installation directory.
@@ -131,6 +134,26 @@ public abstract class Initializer {
     }
 
     /**
+     * Returns a message for unspecified data source. The message will depend on whether
a JNDI context exists or not.
+     * This message can be used for constructing an exception when {@link #getDataSource()}
returned {@code null}.
+     *
+     * @param locale The locale for the message to produce, or {@code null} for the default
one.
+     * @return Message for unspecified data source.
+     */
+    public static String unspecified(final Locale locale) {
+        final short key;
+        final String value;
+        if (NamingManager.hasInitialContextFactoryBuilder()) {
+            key = Messages.Keys.JNDINotSpecified_1;
+            value = "jdbc/" + DATABASE;
+        } else {
+            key = Messages.Keys.DataDirectoryNotSpecified_1;
+            value = DataDirectory.ENV;
+        }
+        return Messages.getResources(locale).getString(key, value);
+    }
+
+    /**
      * Creates a data source for a Derby database at the given {@code $SIS_DATA/Databases/SpatialMetadata}
location.
      * If the database does not exist, it will be created.
      *

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java?rev=1722827&r1=1722826&r2=1722827&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java
[UTF-8] Mon Jan  4 10:19:07 2016
@@ -923,6 +923,8 @@ addURIs:    for (int i=0; ; i++) {
         }
         if (replacedBy == null) {
             replacedBy = '(' + Vocabulary.getResources(locale).getString(Vocabulary.Keys.None).toLowerCase(locale)
+ ')';
+        } else {
+            replacedBy = replacedBy.toString();
         }
         /*
          * Try to infer the method name from the table name. For example if the deprecated
code was found in

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=1722827&r1=1722826&r2=1722827&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] Mon Jan  4 10:19:07 2016
@@ -150,6 +150,9 @@ public class EPSGFactory extends Concurr
             this.dataSource = dataSource;
         } else try {
             this.dataSource = Initializer.getDataSource();
+            if (this.dataSource == null) {
+                throw new UnavailableFactoryException(Initializer.unspecified(null));
+            }
         } catch (Exception e) {
             throw new UnavailableFactoryException(e.getLocalizedMessage(), e);
         }

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages.java?rev=1722827&r1=1722826&r2=1722827&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages.java
[UTF-8] Mon Jan  4 10:19:07 2016
@@ -166,6 +166,11 @@ public final class Messages extends Inde
         public static final short IncompleteParsing_1 = 14;
 
         /**
+         * No object associated to the “{0}” JNDI name.
+         */
+        public static final short JNDINotSpecified_1 = 32;
+
+        /**
          * Loading datum shift file “{0}”.
          */
         public static final short LoadingDatumShiftFile_1 = 27;

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages.properties?rev=1722827&r1=1722826&r2=1722827&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages.properties
[ISO-8859-1] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages.properties
[ISO-8859-1] Mon Jan  4 10:19:07 2016
@@ -35,6 +35,7 @@ DiscardedExclusiveProperty_2    = Proper
 IgnoredPropertiesAfterFirst_1   = Ignored properties after the first occurrence of \u2018{0}\u2019.
 IgnoredPropertyAssociatedTo_1   = Ignored property associated to \u2018{0}\u2019.
 IncompleteParsing_1             = Parsing of \u201c{0}\u201d done, but some elements were
ignored.
+JNDINotSpecified_1              = No object associated to the \u201c{0}\u201d JNDI name.
 LoadingDatumShiftFile_1         = Loading datum shift file \u201c{0}\u201d.
 LocalesDiscarded                = Text were discarded for some locales.
 OptionalModuleNotFound_1        = Optional module \u201c{0}\u201d requested but not found.

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages_fr.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages_fr.properties?rev=1722827&r1=1722826&r2=1722827&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages_fr.properties
[ISO-8859-1] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages_fr.properties
[ISO-8859-1] Mon Jan  4 10:19:07 2016
@@ -42,6 +42,7 @@ DiscardedExclusiveProperty_2    = La pro
 IgnoredPropertiesAfterFirst_1   = Des propri\u00e9t\u00e9s ont \u00e9t\u00e9 ignor\u00e9es
apr\u00e8s la premi\u00e8re occurrence de \u2018{0}\u2019.
 IgnoredPropertyAssociatedTo_1   = Une propri\u00e9t\u00e9 associ\u00e9e \u00e0 \u2018{0}\u2019
a \u00e9t\u00e9 ignor\u00e9e.
 IncompleteParsing_1             = La lecture de \u00ab\u202f{0}\u202f\u00bb a \u00e9t\u00e9
faite, mais en ignorant certains \u00e9l\u00e9ments.
+JNDINotSpecified_1              = Aucun objet n\u2019est associ\u00e9 au nom JNDI \u00ab\u202f{0}\u202f\u00bb.
 LoadingDatumShiftFile_1         = Chargement du fichier de changement de r\u00e9f\u00e9rentiel
\u00ab\u202f{0}\u202f\u00bb.
 LocalesDiscarded                = Des textes ont \u00e9t\u00e9 ignor\u00e9s pour certaines
langues.
 OptionalModuleNotFound_1        = Le module optionnel \u00ab\u202f{0}\u202f\u00bb a \u00e9t\u00e9
demand\u00e9 mais n\u2019a pas \u00e9t\u00e9 trouv\u00e9.



Mime
View raw message