# HG changeset patch # User Gernot Belger # Date 1594808675 -7200 # Node ID 9ec4686badae1c765761694b2722d5400cf42dcc # Parent e098fda96a660b865a8079013b9b7c68eb99cbbb# Parent 8e5a8430b89c49a577d643b7142e20e3d172cb82 Mit 3.2.x zusammenführen diff -r e098fda96a66 -r 9ec4686badae .hgtags --- a/.hgtags Fri May 08 18:03:54 2020 +0200 +++ b/.hgtags Wed Jul 15 12:24:35 2020 +0200 @@ -105,3 +105,4 @@ e062d3afd6825e0366f1715b80c60903b1cb11db 3.2.0 d8e3b20e2c93065eee064a8c707344e5bb63f620 3.2.1 de423c2a3c1b8f1b559282b23ff150a6260744f6 3.2.2 +21c89e39ca7243e0d7d5aac423969af6dd563b20 3.2.3 diff -r e098fda96a66 -r 9ec4686badae artifacts/pom-oracle.xml --- a/artifacts/pom-oracle.xml Fri May 08 18:03:54 2020 +0200 +++ b/artifacts/pom-oracle.xml Wed Jul 15 12:24:35 2020 +0200 @@ -21,6 +21,7 @@ 1.7 1.7 + UTF-8 @@ -40,28 +41,28 @@ - + @@ -81,7 +82,7 @@ junit junit - 3.8.1 + 4.13 test @@ -203,14 +204,9 @@ - jboss-repo2 - JBoss repo2 - http://repository.jboss.org/nexus/content/groups/public/ - - gt2.repo GeoTools2 Repository including JTS - http://download.osgeo.org/webdav/geotools + https://repo.osgeo.org/repository/release Hibernate Spatial repo diff -r e098fda96a66 -r 9ec4686badae artifacts/pom.xml --- a/artifacts/pom.xml Fri May 08 18:03:54 2020 +0200 +++ b/artifacts/pom.xml Wed Jul 15 12:24:35 2020 +0200 @@ -21,6 +21,7 @@ 1.7 1.7 + UTF-8 @@ -81,7 +82,7 @@ junit junit - 3.8.1 + 4.13 test @@ -203,14 +204,9 @@ - jboss-repo2 - JBoss repo2 - http://repository.jboss.org/nexus/content/groups/public/ - - gt2.repo GeoTools2 Repository including JTS - http://download.osgeo.org/webdav/geotools + https://repo.osgeo.org/repository/release Hibernate Spatial repo diff -r e098fda96a66 -r 9ec4686badae artifacts/src/main/java/org/dive4elements/river/utils/MapUtils.java --- a/artifacts/src/main/java/org/dive4elements/river/utils/MapUtils.java Fri May 08 18:03:54 2020 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/utils/MapUtils.java Wed Jul 15 12:24:35 2020 +0200 @@ -1,4 +1,4 @@ -/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde +/* Copyright (C) 2011, 2012, 2013, 2020 by Bundesanstalt für Gewässerkunde * Software engineering by Intevation GmbH * * This file is Free Software under the GNU AGPL (>=v3) @@ -8,8 +8,8 @@ package org.dive4elements.river.utils; -import java.util.regex.Matcher; -import java.util.regex.Pattern; +import java.net.URI; +import java.net.URISyntaxException; import org.apache.log4j.Logger; import org.hibernate.impl.SessionFactoryImpl; @@ -21,11 +21,10 @@ { private static final Logger log = Logger.getLogger(MapUtils.class); - public static final Pattern DB_URL_PATTERN = - Pattern.compile("(.*)\\/\\/(.*):([0-9]+)\\/([\\.a-zA-Z0-9_-]+)"); + private static final String JDBC_SCHEME = "^jdbc:"; - public static final Pattern DB_PSQL_URL_PATTERN = - Pattern.compile("(.*)\\/\\/(.*):([0-9]+)\\/([a-zA-Z0-9_-]+)"); + private static final String JDBC_DRV_PATTERN = + JDBC_SCHEME + "(postgresql|oracle:(thin|oci)):.*"; /** * This method returns a connection string for databases used by @@ -41,115 +40,93 @@ String pass = SessionFactoryProvider.getPass(sf); String url = SessionFactoryProvider.getURL(sf); - log.debug("Parse connection url: " + url); + return getConnection(user, pass, url); + } - Matcher m = DB_URL_PATTERN.matcher(url); - if (!m.matches()) { - log.warn("Could not parse Connection string." + - "Try to parse PostgreSQL string."); - // maybe this is a PostgreSQL connection... - return getPostgreSQLConnection(); + public static String getConnection(String user, String pass, String url) { + log.info("Parse connection string: " + url); + + if (!url.matches(JDBC_DRV_PATTERN)) { + log.error("Could not parse connection string: " + + "Not a JDBC URL with PostgreSQL or Oracle driver"); + return null; } - log.debug("Groups for connection string: " + m.groupCount()); - int groups = m.groupCount(); - + URI uri = null; + try { + // Strip JDBC_SCHEME to let the driver be parsed as scheme + uri = new URI(url.replaceFirst(JDBC_SCHEME, "")); + } + catch (URISyntaxException e) { + log.error("Could not parse connection string: " + e.getMessage()); + return null; + } - if (log.isDebugEnabled()) { - for (int i = 0; i <= groups; i++) { - log.debug("Group " + i + ": " + m.group(i)); - } - } + String drv = uri.getScheme(); + log.debug("Driver: " + drv); String connection = null; - - if (RiverUtils.isUsingOracle()) { - if (groups < 4) { - log.warn("Could only partially parse connection string."); + if (drv.equals("oracle")) { + try { + // Work-around the extra colon in the driver part of the scheme + String con = new URI(uri.getSchemeSpecificPart()) + .getSchemeSpecificPart().replaceFirst("^@(//)?", ""); + log.debug("Database specifier: " + con); + connection = user + "/" + pass + "@" + con; + } + catch (URISyntaxException e) { + log.error("Could not parse Oracle connection string: " + + e.getMessage()); return null; } - - String host = m.group(2); - String port = m.group(3); - String backend = m.group(4); - connection = user + "/" + pass - + "@" + host + ":" + port + "/" + backend; } - else { - if (groups < 4) { - log.warn("Could only partially parse connection string."); + else { // assume PostgreSQL + String host = uri.getHost(); + if (host == null && uri.getSchemeSpecificPart().startsWith("//")) { + // invalid hostnames (e.g. containing '_') are not parsed! + log.error("Could not parse PostgreSQL connection string: " + + "invalid host name"); return null; } - - String host = m.group(2); - String port = m.group(3); - String db = m.group(4); - + String db = host == null + ? uri.getSchemeSpecificPart() + : uri.getPath(); + int port = uri.getPort(); connection = createConnectionString(user, pass, host, db, port); } return connection; } - public static String createConnectionString( + private static String createConnectionString( String user, String pass, String host, String db, - String port + int port ) { StringBuilder sb = new StringBuilder(); - sb.append("dbname=").append(db); - sb.append(" host='").append(host).append("'"); + // Required parameters + // defaults to user name in PostgreSQL JDBC: + if (db != null) { + db = db.replaceFirst("/", ""); + } + sb.append("dbname=").append(db == null || db.equals("") ? user : db); sb.append(" user=").append(user); - sb.append(" port=").append(port); + + // Optional parameters + if (host != null) { + sb.append(" host='").append(host).append("'"); + } + if (port != -1) { + sb.append(" port=").append(port); + } // XXX: We need to escape this somehow. sb.append(" password='").append(pass).append("'"); sb.append(" sslmode=disable"); return sb.toString(); } - protected static String getPostgreSQLConnection() { - SessionFactoryImpl sf = (SessionFactoryImpl) - SessionFactoryProvider.getSessionFactory(); - - String user = SessionFactoryProvider.getUser(sf); - String pass = SessionFactoryProvider.getPass(sf); - String url = SessionFactoryProvider.getURL(sf); - - Matcher m = DB_PSQL_URL_PATTERN.matcher(url); - if (!m.matches()) { - log.warn("Could not parse PostgreSQL Connection string."); - return null; - } - - int groups = m.groupCount(); - log.debug("Groups for PostgreSQL connection string: " + groups); - - if (log.isDebugEnabled()) { - for (int i = 0; i <= groups; i++) { - log.debug("Group " + i + ": " + m.group(i)); - } - } - - String connection = null; - - if (groups < 4) { - log.warn("Could only partially parse connection string."); - return null; - } - - String host = m.group(2); - String port = m.group(3); - String db = m.group(4); - - connection = createConnectionString(user, pass, host, db, port); - - log.debug("Created connection: '" + connection + "'"); - - return connection; - } - public static String getConnectionType() { return RiverUtils.isUsingOracle() ? "oraclespatial" : "postgis"; } diff -r e098fda96a66 -r 9ec4686badae artifacts/src/test/java/org/dive4elements/river/utils/MapUtilsTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/artifacts/src/test/java/org/dive4elements/river/utils/MapUtilsTest.java Wed Jul 15 12:24:35 2020 +0200 @@ -0,0 +1,135 @@ +/* Copyright (C) 2020 by Bundesanstalt für Gewässerkunde + * Software engineering by Intevation GmbH + * + * This file is Free Software under the GNU AGPL (>=v3) + * and comes with ABSOLUTELY NO WARRANTY! Check out the + * documentation coming with Dive4Elements River for details. + */ + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + +import org.junit.Test; + +import org.dive4elements.river.utils.MapUtils; + +public class MapUtilsTest { + + private static final String DRV_PG = "jdbc:postgresql:"; + private static final String DRV_ORA = "jdbc:oracle:thin:"; + + private static final String USER = "d4euser"; + private static final String PSWD = "d4epswd"; + private static final String DB = "d4edb"; + private static final String HOST = "d4ehost"; + private static final String PORT = "2345"; + + private static final String PG_CON_SUFFIX = " sslmode=disable"; + + @Test + public void noJDBCURL() { + String con = MapUtils.getConnection(USER, PSWD, "xx"); + assertNull(con); + } + + @Test + public void invalidHostPG() { + String con = MapUtils.getConnection( + USER, PSWD, DRV_PG + "//invalid_host_name/"); + assertNull(con); + } + + @Test + public void localNamedPG() { + String con = MapUtils.getConnection( + USER, PSWD, DRV_PG + DB); + assertEquals( + "dbname=" + DB + + " user=" + USER + + " password='" + PSWD + "'" + PG_CON_SUFFIX, + con); + } + + @Test + public void localUserPG() { + String con = MapUtils.getConnection( + USER, PSWD, DRV_PG + "/"); + assertEquals( + "dbname=" + USER + + " user=" + USER + + " password='" + PSWD + "'" + PG_CON_SUFFIX, + con); + } + + @Test + public void hostNamedPG() { + String con = MapUtils.getConnection( + USER, PSWD, DRV_PG + "//" + HOST + "/" + DB); + assertEquals( + "dbname=" + DB + + " user=" + USER + + " host='" + HOST + "'" + + " password='" + PSWD + "'" + PG_CON_SUFFIX, + con); + } + + @Test + public void hostUserPG() { + String con = MapUtils.getConnection( + USER, PSWD, DRV_PG + "//" + HOST + "/"); + assertEquals( + "dbname=" + USER + + " user=" + USER + + " host='" + HOST + "'" + + " password='" + PSWD + "'" + PG_CON_SUFFIX, + con); + } + + @Test + public void hostPortUserPG() { + String con = MapUtils.getConnection( + USER, PSWD, DRV_PG + "//" + HOST + ":" + PORT + "/"); + assertEquals( + "dbname=" + USER + + " user=" + USER + + " host='" + HOST + "' port=" + PORT + + " password='" + PSWD + "'" + PG_CON_SUFFIX, + con); + } + + @Test + public void hostPortNamedPG() { + String con = MapUtils.getConnection( + USER, PSWD, DRV_PG + "//" + HOST + ":" + PORT + "/" + DB); + assertEquals( + "dbname=" + DB + + " user=" + USER + + " host='" + HOST + "' port=" + PORT + + " password='" + PSWD + "'" + PG_CON_SUFFIX, + con); + } + + @Test + public void serviceNameORA() { + String con = MapUtils.getConnection( + USER, PSWD, DRV_ORA + "@//" + HOST + ":" + PORT + "/" + DB); + assertEquals( + USER + "/" + PSWD + "@" + HOST + ":" + PORT + "/" + DB, + con); + } + + @Test + public void connectDescriptorORA() { + String con = MapUtils.getConnection( + USER, PSWD, DRV_ORA + + "@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=" + + HOST + ")(PORT=" + PORT + "))(CONNECT_DATA=(SERVICE_NAME=" + + DB + ")))"); + assertEquals( + USER + "/" + PSWD + + "@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=" + + HOST + ")(PORT=" + PORT + "))(CONNECT_DATA=(SERVICE_NAME=" + + DB + ")))", + con); + } +} diff -r e098fda96a66 -r 9ec4686badae backend/pom-oracle.xml --- a/backend/pom-oracle.xml Fri May 08 18:03:54 2020 +0200 +++ b/backend/pom-oracle.xml Wed Jul 15 12:24:35 2020 +0200 @@ -23,6 +23,7 @@ 1.7 1.7 + UTF-8 @@ -83,7 +84,6 @@ - @@ -181,15 +180,6 @@ - repository.jboss.org nexus - JBoss Repository - Nexus - http://repository.jboss.org/nexus/content/groups/public/ - - - OSGEO GeoTools repo - http://download.osgeo.org/webdav/geotools - - Hibernate Spatial repo http://www.hibernatespatial.org/repository diff -r e098fda96a66 -r 9ec4686badae backend/pom.xml --- a/backend/pom.xml Fri May 08 18:03:54 2020 +0200 +++ b/backend/pom.xml Wed Jul 15 12:24:35 2020 +0200 @@ -23,6 +23,7 @@ 1.7 1.7 + UTF-8 @@ -194,15 +195,6 @@ - repository.jboss.org nexus - JBoss Repository - Nexus - http://repository.jboss.org/nexus/content/groups/public/ - - - OSGEO GeoTools repo - http://download.osgeo.org/webdav/geotools - - Hibernate Spatial repo http://www.hibernatespatial.org/repository diff -r e098fda96a66 -r 9ec4686badae contrib/make_flys_release/README --- a/contrib/make_flys_release/README Fri May 08 18:03:54 2020 +0200 +++ b/contrib/make_flys_release/README Wed Jul 15 12:24:35 2020 +0200 @@ -4,8 +4,10 @@ verwendet werden oder man ändert die entsprechenden Variablen im Script. Wichtige variablen sind: -FLYS_SOURCE_DIR -DEVELOPER +FLYS_SOURCE_DIR: Pfad ohne Leerzeichen zu existierendem Verzeichnis mit + Repository-Checkouts oder neu anzulegendem Verzeichnis + in das die Quellen ausgecheckt werden. + Wenn nicht gesetzt wird ein temporäres Verzeichnis angelegt. DEFAULT_WD Artefakt-Server-Konfiguration: @@ -45,13 +47,14 @@ sh make_release.sh VERSION von der Konsole gestartet werden. VERSION kann dabei ein Tag oder der Name eines Branches sein. Anschließend werden die Quellen des -dive4elements, des HTTP-Clients und von FLYS über SSH aus dem HG Repository +dive4elements, des HTTP-Clients und von dive4elements-river +über HTTPS aus dem HG Repository ausgecheckt und in FLYS_SOURCE_DIR abgelegt. -Wenn mit der option -t zusätzlich ausgewählt wird diese version zu taggen -muss in der make_flys_release.sh der entsprechende accountname zum pushen -des tags als DEVELOPER angegeben werden. +Wenn mit der option -t zusätzlich ausgewählt wird diese Version zu taggen +muss die Umgebungsvariable USER den entsprechenden Account-Namen zum pushen +des Tags enthalten. Für den Client wird OpenLayers-2.11 heruntergeladen und in den Client verschoben. Zurzeit wird das komplette OpenLayers-2.11 Verzeichnis in den Client diff -r e098fda96a66 -r 9ec4686badae contrib/make_flys_release/make_release.sh --- a/contrib/make_flys_release/make_release.sh Fri May 08 18:03:54 2020 +0200 +++ b/contrib/make_flys_release/make_release.sh Wed Jul 15 12:24:35 2020 +0200 @@ -3,8 +3,9 @@ # # Authors: # Andre Heinecke +# Tom Gottfried # -# Copyright (C) 2011 - 2014 by Bundesanstalt für Gewässerkunde +# Copyright (C) 2011 - 2014, 2020 by Bundesanstalt für Gewässerkunde # Software engineering by Intevation GmbH # # This file is Free Software under the GNU AGPL (>=v3) @@ -14,21 +15,18 @@ set -e LC_ALL=en_US.UTF-8 DEFAULT_WD=/tmp/flys-release -DEVELOPER=aheinecke ARTIFACTS_HG_REPO="https://wald.intevation.org/hg/dive4elements/framework" HTTPCLIIENT_HG_REPO="https://wald.intevation.org/hg/dive4elements/http-client" FLYS_HG_REPO="https://wald.intevation.org/hg/dive4elements/river" REPOS="river http-client framework" -# Do not use spaces in path -FLYS_SOURCE_DIR=/local-vol1/aheinecke/flys-release SCRIPT_DIR=$(readlink -f `dirname $0`) usage(){ cat << EOF -usage: $0 [options] VERSION +usage: $0 [options] TARGET Create a D4E River package @@ -36,11 +34,13 @@ -?, --help Show this message -w The working directory to use (do not use spaces in path) Default: $DEFAULT_WD - -t Tag the current default branch as "VERSION" + -t Tag the selected branch with given name. + Note that \$USER is used as the repository user name + for pushing the tags. -o, --oracle Release is for oracle. Suitable jar-file for JDBC driver has to be given with the environment variable ORACLE_JDBC - VERSION must specify a tag (usually MAYOR.MINOR.PATCH) or a branch name. + TARGET must specify a tag (usually MAYOR.MINOR.PATCH) or a branch name. EOF exit 0 } @@ -58,7 +58,7 @@ # customizable variables ELBE_MODEL_UUID=${ELBE_MODEL_UUID:-1a4825f6-925f-11e3-8165-001f29e71d12} -OPTS=`getopt -o ?w:,t,o \ +OPTS=`getopt -o ?w:,?t:,o \ -l help,oracle \ -n $0 -- "$@"` @@ -78,8 +78,8 @@ BUILD_ORACLE="TRUE" shift;; "-t") - DO_TAG="TRUE" - shift;; + DO_TAG=$2 + shift 2;; *) echo "Unknown Option $1" usage;; @@ -90,7 +90,7 @@ usage fi -VERSION=$1 +TARGET=$1 if [ -z $WORK_DIR ]; then WORK_DIR=$DEFAULT_WD @@ -110,7 +110,8 @@ fi if [ ! -d "$FLYS_SOURCE_DIR" ]; then - mkdir -p $FLYS_SOURCE_DIR + mkdir -p ${FLYS_SOURCE_DIR:=$(mktemp -d)} + echo "Will use source code checkouts in $FLYS_SOURCE_DIR" echo "Cloning sources" cd $FLYS_SOURCE_DIR hg clone $ARTIFACTS_HG_REPO framework @@ -120,47 +121,50 @@ echo "Updating sources / Reverting changes" cd $FLYS_SOURCE_DIR for repo in $REPOS; do - cd $repo && hg purge && hg revert -a && hg pull -u && cd - + cd $repo && hg revert -a && hg pull -u && cd - done; fi -if [ "$DO_TAG" = "TRUE" ]; then - echo "INFO: Tagging version $VERSION" +# Update to current version +for repo in $REPOS; do + cd $repo + if [ -z "`hg tags | sed -n "/$TARGET/p"`" -a -z "`hg branches | sed -n "/$TARGET/p"`" ] + then + echo "WARNING: No tag or branch $TARGET found in repository of $repo!" + echo " Will fallback to 'default'!" + hg up default + else + hg up "$TARGET" + fi + cd $FLYS_SOURCE_DIR +done + +if [ -n "$DO_TAG" ]; then + VERSION=$DO_TAG + echo "INFO: Tagging current branch as $VERSION" for repo in $REPOS; do cd $repo - CHANGESET=$(hg log -l1 |head -1 | awk -F: '{print $3}') + CHANGESET=$(hg parent |head -1 | awk -F: '{print $3}') echo "" echo "Do you really want to tag $repo rev: $CHANGESET as Version $VERSION?" echo "press enter to continue or CTRL+C to abort." echo "" - hg log -l1 + hg log -r $CHANGESET -l1 read OLD_REV=$(cat .hgtags | tail -1 | awk '{print $2}') - hg tag $VERSION -m "Added tag $VERSION for changeset $CHANGESET" - hg push ssh://$DEVELOPER@scm.wald.intevation.org/hg/dive4elements/$repo + hg tag -r $CHANGESET -m "Added tag $VERSION for changeset $CHANGESET" \ + "$VERSION" + hg push ssh://$USER@scm.wald.intevation.org/hg/dive4elements/$repo echo "Changelog for $repo" >> $WORK_DIR/changes_$OLD_REV-$VERSION.txt echo "#############################################################################" \ >> $WORK_DIR/changes_$OLD_REV-$VERSION.txt hg log -r $VERSION:$OLD_REV --style changelog >> $WORK_DIR/changes_$OLD_REV-$VERSION.txt cd $FLYS_SOURCE_DIR done; +else + VERSION=$TARGET fi -# Update to current version -for repo in $REPOS; do - cd $repo - if [ -z "`hg tags | sed -n "/$VERSION/p"`" -a -z "`hg branches | sed -n "/$VERSION/p"`" ] - then - echo "WARNING: No tag or branch $VERSION found in repository of $repo!" - echo " Will fallback to 'default'!" - hg up default - else - hg up "$VERSION" - fi - cd $FLYS_SOURCE_DIR -done - - if [ ! -f "$FLYS_SOURCE_DIR/OpenLayers-2.11.tar.gz" ]; then echo "INFO: download OpenLayers-2.11 for client" cd $FLYS_SOURCE_DIR @@ -207,7 +211,7 @@ cp wsplgen-linux-32bit-static $FLYS_SOURCE_DIR/river/artifacts/bin/wsplgen cd - -if [ "$DO_TAG" = "TRUE" ]; then +if [ -n "$DO_TAG" ]; then echo "INFO: Building packages for publication" cd $FLYS_SOURCE_DIR/river/artifacts mvn package assembly:single @@ -301,10 +305,10 @@ tar cfz flys-$VERSION.tar.gz flys-$VERSION ## -if [ "$DO_TAG" = "TRUE" ]; then +if [ -n "$DO_TAG" ]; then echo "Binary-packages for publication:" echo "_ $WORK_DIR/d4e-river-$VERSION.tar.bz2" echo "_ $WORK_DIR/d4e-river-$VERSION.war" + echo "Changelog: $WORK_DIR/changes_$OLD_REV-$VERSION.txt" fi echo "DONE: $WORK_DIR/flys-$VERSION.tar.gz" -echo "Changelog: $WORK_DIR/changes_$OLD_REV-$VERSION.txt" diff -r e098fda96a66 -r 9ec4686badae gwt-client/pom.xml --- a/gwt-client/pom.xml Fri May 08 18:03:54 2020 +0200 +++ b/gwt-client/pom.xml Wed Jul 15 12:24:35 2020 +0200 @@ -172,6 +172,7 @@ maven-surefire-plugin + 2.22.1 ${project.build.sourceDirectory} @@ -193,6 +194,7 @@ maven-resources-plugin + 3.1.0 compile @@ -214,6 +216,7 @@ maven-clean-plugin + 3.1.0 src/main/webapp/flys @@ -250,17 +253,12 @@ --> - - - - com.smartgwt - SmartGWT - http://www.smartclient.com/maven2 - - - osgeo - Open Source Geospatial Foundation Repository - http://download.osgeo.org/webdav/geotools/ - - + + + + osgeo + Open Source Geospatial Foundation Repository + https://repo.osgeo.org/repository/release + +