sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject [sis] 03/03: Initial Windows batch script for launching the application.
Date Thu, 13 Aug 2020 23:59:32 GMT
This is an automated email from the ASF dual-hosted git repository.

desruisseaux pushed a commit to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git

commit 42b1726538d57d1f6ccc19b54d10f6886f964567
Author: Martin Desruisseaux <martin.desruisseaux@geomatys.com>
AuthorDate: Fri Aug 14 01:57:46 2020 +0200

    Initial Windows batch script for launching the application.
---
 application/sis-javafx/src/main/artifact/bin/sisfx |  4 +--
 .../sis-javafx/src/main/artifact/bin/sisfx.bat     | 36 ++++++++++++++++++++++
 .../sis-javafx/src/main/artifact/conf/setenv.bat   |  2 ++
 .../org/apache/sis/internal/setup/FXFinder.java    |  8 +++--
 .../sis/internal/setup/LoggingConfiguration.java   | 11 ++++---
 .../referencing/factory/sql/EPSGDataAccess.java    |  6 ++--
 6 files changed, 57 insertions(+), 10 deletions(-)

diff --git a/application/sis-javafx/src/main/artifact/bin/sisfx b/application/sis-javafx/src/main/artifact/bin/sisfx
index a13852b..4f13a6b 100755
--- a/application/sis-javafx/src/main/artifact/bin/sisfx
+++ b/application/sis-javafx/src/main/artifact/bin/sisfx
@@ -20,7 +20,7 @@ set -o errexit
 
 BASE_DIR="`readlink --canonicalize-existing $0`"
 BASE_DIR="`dirname $BASE_DIR`/.."
-source $BASE_DIR/conf/setenv.sh
+source "$BASE_DIR/conf/setenv.sh"
 
 if [ -z "$PATH_TO_FX" ]
 then
@@ -29,7 +29,7 @@ then
     then
         exit
     fi
-    source $BASE_DIR/conf/setenv.sh
+    source "$BASE_DIR/conf/setenv.sh"
 fi
 
 SIS_DATA="${SIS_DATA:-$BASE_DIR/data}"
diff --git a/application/sis-javafx/src/main/artifact/bin/sisfx.bat b/application/sis-javafx/src/main/artifact/bin/sisfx.bat
new file mode 100644
index 0000000..92a5f0f
--- /dev/null
+++ b/application/sis-javafx/src/main/artifact/bin/sisfx.bat
@@ -0,0 +1,36 @@
+@echo off
+
+REM Licensed to the Apache Software Foundation (ASF) under one or more
+REM contributor license agreements.  See the NOTICE file distributed with
+REM this work for additional information regarding copyright ownership.
+REM The ASF licenses this file to you under the Apache License, Version 2.0
+REM (the "License"); you may not use this file except in compliance with the
+REM License.  You may obtain a copy of the License at
+REM
+REM    http://www.apache.org/licenses/LICENSE-2.0
+REM
+REM Unless required by applicable law or agreed to in writing, software
+REM distributed under the License is distributed on an "AS IS" BASIS,
+REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+REM See the License for the specific language governing permissions and
+REM limitations under the License.
+
+
+SET BASE_DIR=%~dp0\..
+CALL "%BASE_DIR%\conf\setenv.bat"
+SET SIS_DATA=%BASE_DIR%\data
+
+IF "%PATH_TO_FX%"=="" (
+    java --class-path "%BASE_DIR%\lib\*" org.apache.sis.internal.setup.FXFinder "%BASE_DIR%\conf\setenv.bat"
+    if %ERRORLEVEL% GEQ 1 EXIT /B 1
+    CALL "%BASE_DIR%\conf\setenv.bat"
+)
+
+java -splash:"%BASE_DIR%\lib\logo.jpg"^
+ --add-modules javafx.graphics,javafx.controls^
+ --module-path "%PATH_TO_FX%"^
+ --class-path "%BASE_DIR%\lib\*"^
+ -Djava.util.logging.config.class=org.apache.sis.internal.setup.LoggingConfiguration^
+ -Djava.util.logging.config.file="%BASE_DIR%\conf\logging.properties"^
+ -Dderby.stream.error.file="%BASE_DIR%\log\derby.log"^
+ org.apache.sis.gui.DataViewer %SIS_OPTS%
diff --git a/application/sis-javafx/src/main/artifact/conf/setenv.bat b/application/sis-javafx/src/main/artifact/conf/setenv.bat
new file mode 100644
index 0000000..9825bd1
--- /dev/null
+++ b/application/sis-javafx/src/main/artifact/conf/setenv.bat
@@ -0,0 +1,2 @@
+REM Environment variables required for SIS execution.
+REM Contents may be added at Apache SIS setup time.
diff --git a/application/sis-javafx/src/main/java/org/apache/sis/internal/setup/FXFinder.java
b/application/sis-javafx/src/main/java/org/apache/sis/internal/setup/FXFinder.java
index 708af4c..ba91b5b 100644
--- a/application/sis-javafx/src/main/java/org/apache/sis/internal/setup/FXFinder.java
+++ b/application/sis-javafx/src/main/java/org/apache/sis/internal/setup/FXFinder.java
@@ -157,11 +157,15 @@ public final class FXFinder {
      * @param  dir     directory selected by user.
      */
     private static void setDirectory(final Path setenv, final File dir) throws IOException
{
+        String command = "PATH_TO_FX";
+        if (setenv.getFileName().toString().endsWith(".bat")) {
+            command = "SET " + command;                             // Microsoft Windows
syntax.
+        }
         final ArrayList<String> content = new ArrayList<>();
         int insertAt = -1;
         for (String line : Files.readAllLines(setenv)) {
             line = line.trim();
-            if (line.startsWith("PATH_TO_FX")) {
+            if (line.startsWith(command)) {
                 insertAt = content.size();
             } else {
                 content.add(line);
@@ -170,7 +174,7 @@ public final class FXFinder {
         if (insertAt < 0) {
             insertAt = content.size();
         }
-        content.add(insertAt, "PATH_TO_FX=" + dir);
+        content.add(insertAt, command + '=' + dir);
         Files.write(setenv, content, StandardOpenOption.WRITE, StandardOpenOption.TRUNCATE_EXISTING);
     }
 }
diff --git a/application/sis-javafx/src/main/java/org/apache/sis/internal/setup/LoggingConfiguration.java
b/application/sis-javafx/src/main/java/org/apache/sis/internal/setup/LoggingConfiguration.java
index 3601b33..0af0f66 100644
--- a/application/sis-javafx/src/main/java/org/apache/sis/internal/setup/LoggingConfiguration.java
+++ b/application/sis-javafx/src/main/java/org/apache/sis/internal/setup/LoggingConfiguration.java
@@ -19,6 +19,7 @@ package org.apache.sis.internal.setup;
 import java.util.logging.LogManager;
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
+import java.io.File;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
@@ -67,11 +68,13 @@ public final class LoggingConfiguration {
                     if (line.startsWith(PROPERTY)) {
                         final int i = buffer.indexOf(PATTERN, base + PROPERTY.length());
                         if (i >= 0) {
-                            Path replacement = path;
-                            for (int j=Math.min(replacement.getNameCount(), 2); --j >=
0;) {
-                                replacement = replacement.getParent();
+                            Path parent = path;
+                            for (int j=Math.min(parent.getNameCount(), 2); --j >= 0;)
{
+                                parent = parent.getParent();
                             }
-                            buffer.replace(i, i + PATTERN.length(), replacement.toString());
+                            String replacement = parent.toString();
+                            replacement = replacement.replace(File.separatorChar, '/');
+                            buffer.replace(i, i + PATTERN.length(), replacement);
                         }
                     }
                 }
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java
b/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java
index e2f26ba..87931ed 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java
@@ -449,7 +449,7 @@ public class EPSGDataAccess extends GeodeticAuthorityFactory implements
CRSAutho
             }
             /*
              * Add some hard-coded links to EPSG resources, and finally add the JDBC driver
name and version number.
-             * The list last OnlineResource looks like:
+             * The last OnlineResource looks like:
              *
              *    Linkage:      jdbc:derby:/my/path/to/SIS_DATA/Databases/SpatialMetadata
              *    Function:     Connection
@@ -480,7 +480,9 @@ addURIs:    for (int i=0; ; i++) {
                 try {
                     r.setLinkage(new URI(url));
                 } catch (URISyntaxException exception) {
-                    unexpectedException("getAuthority", exception);
+                    // May happen if there is spaces in the URI.
+                    Logging.recoverableException(Logging.getLogger(Loggers.CRS_FACTORY),
+                                                 EPSGDataAccess.class, "getAuthority", exception);
                 }
                 r.setFunction(function);
                 r.setDescription(description);


Mime
View raw message