sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1731923 - in /sis/branches/JDK8/core: sis-metadata/src/main/java/org/apache/sis/internal/metadata/ sis-metadata/src/main/java/org/apache/sis/internal/metadata/sql/ sis-utility/src/main/java/org/apache/sis/internal/util/ sis-utility/src/mai...
Date Tue, 23 Feb 2016 18:39:54 GMT
Author: desruisseaux
Date: Tue Feb 23 18:39:53 2016
New Revision: 1731923

URL: http://svn.apache.org/viewvc?rev=1731923&view=rev
Log:
Add information about the javax.sql.DataSource to the SpatialMetadata database in the "about"
command.

Modified:
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ServicesForUtility.java
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/sql/ScriptRunner.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/MetadataServices.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/setup/About.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties

Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ServicesForUtility.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ServicesForUtility.java?rev=1731923&r1=1731922&r2=1731923&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ServicesForUtility.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ServicesForUtility.java
[UTF-8] Tue Feb 23 18:39:53 2016
@@ -19,6 +19,7 @@ package org.apache.sis.internal.metadata
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Locale;
+import javax.sql.DataSource;
 import org.opengis.metadata.Identifier;
 import org.opengis.metadata.citation.Role;
 import org.opengis.metadata.citation.Citation;
@@ -27,12 +28,17 @@ import org.opengis.metadata.citation.Res
 import org.apache.sis.internal.simple.CitationConstant;
 import org.apache.sis.internal.util.Constants;
 import org.apache.sis.internal.util.MetadataServices;
+import org.apache.sis.internal.metadata.sql.Initializer;
+import org.apache.sis.internal.system.Loggers;
 import org.apache.sis.metadata.iso.ImmutableIdentifier;
 import org.apache.sis.metadata.iso.citation.Citations;
 import org.apache.sis.metadata.iso.citation.DefaultCitation;
 import org.apache.sis.metadata.iso.citation.DefaultOrganisation;
 import org.apache.sis.metadata.iso.citation.DefaultResponsibility;
+import org.apache.sis.util.logging.Logging;
 import org.apache.sis.util.iso.Types;
+import org.apache.sis.util.Exceptions;
+import org.apache.sis.util.Classes;
 
 import static java.util.Collections.singleton;
 
@@ -219,6 +225,37 @@ public final class ServicesForUtility ex
      */
     @Override
     public String getInformation(final String key, final Locale locale) {
+        switch (key) {
+            case "DataSource": {
+                Object server = null, database = null;
+                try {
+                    final DataSource ds = Initializer.getDataSource();
+                    if (ds != null) {
+                        final Class<?> type = ds.getClass();
+                        database = type.getMethod("getDatabaseName", (Class[]) null).invoke(ds,
(Object[]) null);
+                        server   = type.getMethod("getServerName", (Class[]) null).invoke(ds,
(Object[]) null);
+                    }
+                } catch (NoSuchMethodException e) {
+                    Logging.recoverableException(Logging.getLogger(Loggers.SYSTEM),
+                            MetadataServices.class, "getInformation", e);
+                } catch (Exception e) {
+                    // Leave the message alone if it contains at least 2 words.
+                    String message = Exceptions.getLocalizedMessage(e, locale);
+                    if (message == null || message.indexOf(' ') < 0) {
+                        message = Classes.getShortClassName(e) + ": " + message;
+                    }
+                    return message;
+                }
+                if (database != null) {
+                    if (server != null) {
+                        database = "//" + server + '/' + database;
+                    }
+                    return database.toString();
+                }
+                return null;
+            }
+            // More cases may be added in future SIS versions.
+        }
         return ReferencingServices.getInstance().getInformation(key, locale);
     }
 }

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=1731923&r1=1731922&r2=1731923&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] Tue Feb 23 18:39:53 2016
@@ -344,7 +344,7 @@ public class ScriptRunner implements Aut
     }
 
     /**
-     * Run the script from the given reader. Lines are read and grouped up to the
+     * Runs 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.

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/MetadataServices.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/MetadataServices.java?rev=1731923&r1=1731922&r2=1731923&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/MetadataServices.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/MetadataServices.java
[UTF-8] Tue Feb 23 18:39:53 2016
@@ -120,6 +120,7 @@ public class MetadataServices extends Op
      * <p>Current keys are:</p>
      * <ul>
      *   <li>{@code "EPSG"}: version of EPSG database.</li>
+     *   <li>{@code "DataSource"}: URL to the data source, or error message.</li>
      * </ul>
      *
      * @param  key A key identifying the information to return.

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/setup/About.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/setup/About.java?rev=1731923&r1=1731922&r2=1731923&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/setup/About.java [UTF-8]
(original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/setup/About.java [UTF-8]
Tue Feb 23 18:39:53 2016
@@ -368,19 +368,26 @@ fill:   for (int i=0; ; i++) {
                 }
                 case 14: {
                     if (sections.contains(PATHS)) {
+                        nameKey = Vocabulary.Keys.DataBase;
+                        value = MetadataServices.getInstance().getInformation("DataSource",
locale);
+                    }
+                    break;
+                }
+                case 15: {
+                    if (sections.contains(PATHS)) {
                         nameKey = Vocabulary.Keys.TemporaryFiles;
                         value = getProperty("java.io.tmpdir");
                     }
                     break;
                 }
-                case 15: {
+                case 16: {
                     if (sections.contains(PATHS)) {
                         nameKey = Vocabulary.Keys.JavaHome;
                         value = javaHome = getProperty("java.home");
                     }
                     break;
                 }
-                case 16: {
+                case 17: {
                     newSection = LIBRARIES;
                     if (sections.contains(LIBRARIES)) {
                         nameKey = Vocabulary.Keys.JavaExtensions;
@@ -388,7 +395,7 @@ fill:   for (int i=0; ; i++) {
                     }
                     break;
                 }
-                case 17: {
+                case 18: {
                     if (sections.contains(LIBRARIES)) {
                         nameKey = Vocabulary.Keys.Classpath;
                         value = classpath(getProperty("java.class.path"), false);

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java?rev=1731923&r1=1731922&r2=1731923&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java
[UTF-8] Tue Feb 23 18:39:53 2016
@@ -151,6 +151,11 @@ public final class Vocabulary extends In
         public static final short CycleOmitted = 12;
 
         /**
+         * Database
+         */
+        public static final short DataBase = 96;
+
+        /**
          * Data directory
          */
         public static final short DataDirectory = 88;

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties?rev=1731923&r1=1731922&r2=1731923&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties
[ISO-8859-1] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties
[ISO-8859-1] Tue Feb 23 18:39:53 2016
@@ -33,6 +33,7 @@ Correlation             = Correlation
 CurrentDateTime         = Current date and time
 CurrentDirectory        = Current directory
 CycleOmitted            = Cycle omitted
+DataBase                = Database
 DataDirectory           = Data directory
 DaylightTime            = Daylight time
 DefaultValue            = Default value

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties?rev=1731923&r1=1731922&r2=1731923&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties
[ISO-8859-1] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties
[ISO-8859-1] Tue Feb 23 18:39:53 2016
@@ -40,6 +40,7 @@ Correlation             = Corr\u00e9lati
 CurrentDateTime         = Date et heure courantes
 CurrentDirectory        = R\u00e9pertoire courant
 CycleOmitted            = Cycle omit
+DataBase                = Base de donn\u00e9es
 DataDirectory           = R\u00e9pertoire des donn\u00e9es
 DaylightTime            = Heure normale
 DefaultValue            = Valeur par d\u00e9faut



Mime
View raw message