[osmosis] 02/11: Imported Upstream version 0.45

Sebastiaan Couwenberg sebastic at moszumanska.debian.org
Fri May 27 16:15:30 UTC 2016


This is an automated email from the git hooks/post-receive script.

sebastic pushed a commit to branch master
in repository osmosis.

commit 3159dcc74a4018d10a111fd632d85bb25f62f545
Author: Bas Couwenberg <sebastic at xs4all.nl>
Date:   Fri May 27 17:22:42 2016 +0200

    Imported Upstream version 0.45
---
 .gitignore                                         |   3 +-
 build.gradle                                       |   2 +-
 db-server/docker-start.sh                          |  29 ++++++
 gradle.properties                                  |  16 +--
 osmosis-core/build.gradle                          |   2 +-
 .../osmosis/core/database/DatabaseConstants.java   |  10 ++
 .../core/database/DatabaseLoginCredentials.java    |  20 ++++
 .../core/database/DatabaseTaskManagerFactory.java  |   2 +
 osmosis-pgsimple/build.gradle                      |   2 +-
 osmosis-pgsnapshot/build.gradle                    |   2 +-
 .../osmosis/pgsnapshot/common/DatabaseContext.java |   7 ++
 .../osmosis/pgsnapshot/v0_6/PostgreSqlTest.java    |  71 +++++++++++--
 .../template/v0_6/pgsql_with_schema-authfile.txt   |   4 +
 osmosis-replication-http/build.gradle              |   2 +-
 .../v0_6/impl/SequenceClientHandler.java           |   2 +-
 .../v0_6/impl/SequenceServerHandler.java           |  12 +--
 .../osmosis/xml/common/SaxParserFactory.java       | 114 +++++++++++++++++++++
 .../osmosis/xml/v0_6/XmlChangeReader.java          |  79 ++++++--------
 .../openstreetmap/osmosis/xml/v0_6/XmlReader.java  |  49 +++------
 .../osmosis/xml/common/test-unicode-node.osm       |  11 ++
 .../osmosis/xml/common/SaxParserFactoryTest.java   |  23 +++++
 package/bin/osmosis.bat                            |   2 +-
 package/changes.txt                                |   9 ++
 23 files changed, 361 insertions(+), 112 deletions(-)

diff --git a/.gitignore b/.gitignore
index a775aa6..7fb4583 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,4 +3,5 @@
 *.javae
 *.iml
 *.ipr
-*.iws
\ No newline at end of file
+*.iws
+out
diff --git a/build.gradle b/build.gradle
index 2f1f678..0493b24 100644
--- a/build.gradle
+++ b/build.gradle
@@ -40,7 +40,7 @@ configure(javaProjects) {
 	apply plugin: 'maven'
 	apply plugin: 'signing'
 
-	sourceCompatibility = 1.6
+	sourceCompatibility = 1.7
 
 	test {
 		/*
diff --git a/db-server/docker-start.sh b/db-server/docker-start.sh
index d100a82..7461954 100755
--- a/db-server/docker-start.sh
+++ b/db-server/docker-start.sh
@@ -18,10 +18,18 @@ if [ ! "$(ls -A $DATADIR)" ]; then
 	echo "listen_addresses = '*'" >> "${DATADIR}/postgresql.conf"
 	echo "host all osm 0.0.0.0/0 md5" >> "${DATADIR}/pg_hba.conf"
 
+	# Create the pgsimple database owned by osm.
+	su postgres sh -lc "postgres --single -jE" <<-EOSQL
+		CREATE DATABASE pgosmsimp06_test OWNER osm;
+	EOSQL
+
 	# Create the pgsnapshot database owned by osm.
 	su postgres sh -lc "postgres --single -jE" <<-EOSQL
 		CREATE DATABASE pgosmsnap06_test OWNER osm;
 	EOSQL
+	su postgres sh -lc "postgres --single -jE" <<-EOSQL
+		CREATE DATABASE pgosmsnap06_test_with_schema OWNER osm;
+	EOSQL
 
 	# Create the apidb database owned by osm.
 	su postgres sh -lc "postgres --single -jE" <<-EOSQL
@@ -31,6 +39,15 @@ if [ ! "$(ls -A $DATADIR)" ]; then
 	# Start the database server temporarily while we configure the databases.
 	su postgres sh -lc "pg_ctl -w start"
 
+	# Configure the pgosmsimp06_test database as the OSM user.
+	su postgres sh -lc "psql -U osm pgosmsimp06_test" <<-EOSQL
+		CREATE EXTENSION postgis;
+		\i /install/script/pgsimple_schema_0.6.sql
+		\i /install/script/pgsimple_schema_0.6_action.sql
+		\i /install/script/pgsimple_schema_0.6_bbox.sql
+		\i /install/script/pgsimple_schema_0.6_linestring.sql
+	EOSQL
+
 	# Configure the pgosmsnap06_test database as the OSM user.
 	su postgres sh -lc "psql -U osm pgosmsnap06_test" <<-EOSQL
 		CREATE EXTENSION hstore;
@@ -41,6 +58,18 @@ if [ ! "$(ls -A $DATADIR)" ]; then
 		\i /install/script/pgsnapshot_schema_0.6_linestring.sql
 	EOSQL
 
+	# Configure the pgosmsnap06_test_with_schema database as the OSM user.
+	su postgres sh -lc "psql -U osm pgosmsnap06_test_with_schema" <<-EOSQL
+		CREATE SCHEMA test_schema;
+		SET search_path TO test_schema,public;
+		CREATE EXTENSION hstore;
+		CREATE EXTENSION postgis;
+		\i /install/script/pgsnapshot_schema_0.6.sql
+		\i /install/script/pgsnapshot_schema_0.6_action.sql
+		\i /install/script/pgsnapshot_schema_0.6_bbox.sql
+		\i /install/script/pgsnapshot_schema_0.6_linestring.sql
+	EOSQL
+
 	# Configure the api06_test database as the OSM user.
 	su postgres sh -lc "psql -U osm api06_test" <<-EOSQL
 		\i /install/script/contrib/apidb_0.6.sql
diff --git a/gradle.properties b/gradle.properties
index 43bdd27..3ff25ff 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -6,18 +6,18 @@ org.gradle.daemon=true
 # 3rd Party Library Versions
 dependencyVersionClassworlds=2.5.2
 dependencyVersionCommonsCodec=1.10
-dependencyVersionCommonsCompress=1.9
+dependencyVersionCommonsCompress=1.10
 dependencyVersionCommonsDbcp=1.4
 dependencyVersionJpf=1.5
 dependencyVersionJunit=4.12
-dependencyVersionMySql=5.1.35
-dependencyVersionNetty=3.2.10.Final
-dependencyVersionPostGis=1.3.3
-dependencyVersionPostgreSql=9.4-1201-jdbc4
+dependencyVersionMySql=5.1.37
+dependencyVersionNetty=3.10.5.Final
+dependencyVersionPostGis=2.1.7.2
+dependencyVersionPostgreSql=9.4-1204-jdbc4
 dependencyVersionProtobuf=2.6.1
-dependencyVersionSpring=4.1.6.RELEASE
-dependencyVersionWoodstoxCore=4.4.1
-dependencyVersionWoodstoxStax2=3.1.4
+dependencyVersionSpring=4.2.2.RELEASE
+dependencyVersionWoodstoxCore=5.0.1
+dependencyVersionWoodstoxStax2=4.0.0
 # Remaining on 2.9.1 instead of 2.10.0 for now because the newer version
 # depends on org.w3c.dom.ElementTraversal which is not being transitively
 # included. This could be possibly be fixed by including a newer version
diff --git a/osmosis-core/build.gradle b/osmosis-core/build.gradle
index 72e5b4e..abdb0c4 100644
--- a/osmosis-core/build.gradle
+++ b/osmosis-core/build.gradle
@@ -7,7 +7,7 @@ configurations {
 
 dependencies {
     compile group: 'net.sf.jpf', name: 'jpf', version: dependencyVersionJpf
-    compile group: 'org.codehaus.woodstox', name: 'woodstox-core-lgpl', version: dependencyVersionWoodstoxCore
+    compile group: 'com.fasterxml.woodstox', name: 'woodstox-core', version: dependencyVersionWoodstoxCore
     compile group: 'org.codehaus.woodstox', name: 'stax2-api', version: dependencyVersionWoodstoxStax2
     compile group: 'org.apache.commons', name: 'commons-compress', version: dependencyVersionCommonsCompress
     compile group: 'xerces', name: 'xercesImpl', version: dependencyVersionXerces
diff --git a/osmosis-core/src/main/java/org/openstreetmap/osmosis/core/database/DatabaseConstants.java b/osmosis-core/src/main/java/org/openstreetmap/osmosis/core/database/DatabaseConstants.java
index 0774c5a..a906659 100644
--- a/osmosis-core/src/main/java/org/openstreetmap/osmosis/core/database/DatabaseConstants.java
+++ b/osmosis-core/src/main/java/org/openstreetmap/osmosis/core/database/DatabaseConstants.java
@@ -68,6 +68,11 @@ public final class DatabaseConstants {
     public static final String TASK_ARG_PROFILE_SQL = "profileSql";
 
     /**
+     * The task argument for specifying a postgresql schema to uses.
+     */
+    public static final String TASK_ARG_POSTGRES_SCHEMA = "postgresSchema";
+
+    /**
      * The default host for a database connection.
      */
     public static final String TASK_DEFAULT_HOST = "localhost";
@@ -111,4 +116,9 @@ public final class DatabaseConstants {
      * The default value for enabling profile on a database connection.
      */
     public static final boolean TASK_DEFAULT_PROFILE_SQL = false;
+
+    /**
+     * The default value for specifying a postgresql schema.
+     */
+    public static final String TASK_DEFAULT_POSTGRES_SCHEMA = "";
 }
diff --git a/osmosis-core/src/main/java/org/openstreetmap/osmosis/core/database/DatabaseLoginCredentials.java b/osmosis-core/src/main/java/org/openstreetmap/osmosis/core/database/DatabaseLoginCredentials.java
index 1359f70..03ce00c 100644
--- a/osmosis-core/src/main/java/org/openstreetmap/osmosis/core/database/DatabaseLoginCredentials.java
+++ b/osmosis-core/src/main/java/org/openstreetmap/osmosis/core/database/DatabaseLoginCredentials.java
@@ -16,6 +16,7 @@ public class DatabaseLoginCredentials {
     private boolean forceUtf8;
     private boolean profileSql;
     private DatabaseType dbType;
+    private String postgresSchema;
     
     
 	/**
@@ -58,6 +59,7 @@ public class DatabaseLoginCredentials {
         this.forceUtf8 = forceUtf8;
         this.profileSql = profileSql;
         this.dbType = dbType;
+        this.postgresSchema = "";
     }
     
     
@@ -208,4 +210,22 @@ public class DatabaseLoginCredentials {
     public void setDbType(String property) {
         this.dbType = DatabaseType.fromString(property);
     }
+
+    /**
+     * Returns the postgresql schema.
+     * 
+     * @return The postgresql schema.
+     */
+    public String getPostgresSchema() {
+        return postgresSchema;
+    }
+
+    /**
+     * Updates the postgresql schema.
+     * 
+     * @param postgresSchema The new postgresql schema.
+     */
+    public void setPostgresSchema(String postgresSchema) {
+        this.postgresSchema = postgresSchema;
+    }
 }
diff --git a/osmosis-core/src/main/java/org/openstreetmap/osmosis/core/database/DatabaseTaskManagerFactory.java b/osmosis-core/src/main/java/org/openstreetmap/osmosis/core/database/DatabaseTaskManagerFactory.java
index b58f2e8..5797cf2 100644
--- a/osmosis-core/src/main/java/org/openstreetmap/osmosis/core/database/DatabaseTaskManagerFactory.java
+++ b/osmosis-core/src/main/java/org/openstreetmap/osmosis/core/database/DatabaseTaskManagerFactory.java
@@ -55,6 +55,8 @@ public abstract class DatabaseTaskManagerFactory extends TaskManagerFactory {
                 loginCredentials.getProfileSql()));
         loginCredentials.setDbType(getStringArgument(taskConfig, DatabaseConstants.TASK_ARG_DB_TYPE, loginCredentials
 				.getDbType().toString()));
+        loginCredentials.setPostgresSchema(getStringArgument(taskConfig, DatabaseConstants.TASK_ARG_POSTGRES_SCHEMA,
+                loginCredentials.getPostgresSchema().toString()));
 
         return loginCredentials;
     }
diff --git a/osmosis-pgsimple/build.gradle b/osmosis-pgsimple/build.gradle
index 0baac5f..248ac5f 100644
--- a/osmosis-pgsimple/build.gradle
+++ b/osmosis-pgsimple/build.gradle
@@ -5,7 +5,7 @@ configurations {
 
 dependencies {
     compile project(':osmosis-core')
-    compile group: 'org.postgis', name: 'postgis-jdbc', version: dependencyVersionPostGis
+    compile group: 'net.postgis', name: 'postgis-jdbc', version: dependencyVersionPostGis
     compile group: 'org.postgresql', name: 'postgresql', version: dependencyVersionPostgreSql
     testCompile project(':osmosis-dataset')
     testCompile project(':osmosis-testutil')
diff --git a/osmosis-pgsnapshot/build.gradle b/osmosis-pgsnapshot/build.gradle
index 5e84070..d277096 100644
--- a/osmosis-pgsnapshot/build.gradle
+++ b/osmosis-pgsnapshot/build.gradle
@@ -7,7 +7,7 @@ dependencies {
     compile project(':osmosis-core')
     compile project(':osmosis-hstore-jdbc')
     compile group: 'commons-dbcp', name: 'commons-dbcp', version: dependencyVersionCommonsDbcp
-    compile group: 'org.postgis', name: 'postgis-jdbc', version: dependencyVersionPostGis
+    compile group: 'net.postgis', name: 'postgis-jdbc', version: dependencyVersionPostGis
     compile group: 'org.springframework', name: 'spring-jdbc', version: dependencyVersionSpring
     compile group: 'org.postgresql', name: 'postgresql', version: dependencyVersionPostgreSql
     testCompile project(':osmosis-dataset')
diff --git a/osmosis-pgsnapshot/src/main/java/org/openstreetmap/osmosis/pgsnapshot/common/DatabaseContext.java b/osmosis-pgsnapshot/src/main/java/org/openstreetmap/osmosis/pgsnapshot/common/DatabaseContext.java
index 5fd58b5..10b60ac 100644
--- a/osmosis-pgsnapshot/src/main/java/org/openstreetmap/osmosis/pgsnapshot/common/DatabaseContext.java
+++ b/osmosis-pgsnapshot/src/main/java/org/openstreetmap/osmosis/pgsnapshot/common/DatabaseContext.java
@@ -59,6 +59,13 @@ public class DatabaseContext {
     	jdbcTemplate = new JdbcTemplate(dataSource);
     	
     	setStatementFetchSizeForStreaming();
+
+        if (loginCredentials.getPostgresSchema() != "") {
+            // JJ: should prepend to old search_path
+            jdbcTemplate.execute("SELECT set_config('search_path', '"
+                                 + loginCredentials.getPostgresSchema()
+                                 + ",' || current_setting('search_path'), false)");
+        }
     }
 
 
diff --git a/osmosis-pgsnapshot/src/test/java/org/openstreetmap/osmosis/pgsnapshot/v0_6/PostgreSqlTest.java b/osmosis-pgsnapshot/src/test/java/org/openstreetmap/osmosis/pgsnapshot/v0_6/PostgreSqlTest.java
index 4e7dd30..76bbc54 100644
--- a/osmosis-pgsnapshot/src/test/java/org/openstreetmap/osmosis/pgsnapshot/v0_6/PostgreSqlTest.java
+++ b/osmosis-pgsnapshot/src/test/java/org/openstreetmap/osmosis/pgsnapshot/v0_6/PostgreSqlTest.java
@@ -16,8 +16,8 @@ import org.openstreetmap.osmosis.testutil.AbstractDataTest;
  */
 public class PostgreSqlTest extends AbstractDataTest {
 	
-	private File getAuthFile() {
-		return dataUtils.createDataFile("db.pgsql.authfile", "v0_6/pgsql-authfile.txt");
+	private File getAuthFile(String name) {
+		return dataUtils.createDataFile("db.pgsql.authfile", name);
 	}
 	
 	
@@ -35,7 +35,7 @@ public class PostgreSqlTest extends AbstractDataTest {
 		File outputFile;
 		
 		// Generate input files.
-		authFile = getAuthFile();
+		authFile = getAuthFile("v0_6/pgsql-authfile.txt");
 		inputFile = dataUtils.createDataFile("v0_6/db-snapshot.osm");
 		outputFile = dataUtils.newFile();
 		
@@ -93,7 +93,7 @@ public class PostgreSqlTest extends AbstractDataTest {
 		File actualResultFile;
 		
 		// Generate input files.
-		authFile = getAuthFile();
+		authFile = getAuthFile("v0_6/pgsql-authfile.txt");
 		snapshotFile = dataUtils.createDataFile("v0_6/db-snapshot.osm");
 		changesetFile = dataUtils.createDataFile("v0_6/db-changeset.osc");
 		expectedResultFile = dataUtils.createDataFile("v0_6/db-changeset-expected.osm");
@@ -164,7 +164,7 @@ public class PostgreSqlTest extends AbstractDataTest {
 		File actualResultFile;
 		
 		// Generate input files.
-		authFile = getAuthFile();
+		authFile = getAuthFile("v0_6/pgsql-authfile.txt");
 		snapshotFile = dataUtils.createDataFile("v0_6/db-snapshot.osm");
 		expectedResultFile = dataUtils.createDataFile("v0_6/db-dataset-expected.osm");
 		actualResultFile = dataUtils.newFile();
@@ -234,7 +234,7 @@ public class PostgreSqlTest extends AbstractDataTest {
 		File outputFile;
 		
 		// Generate input files.
-		authFile = getAuthFile();
+		authFile = getAuthFile("v0_6/pgsql-authfile.txt");
 		inputFile = dataUtils.createDataFile("v0_6/db-snapshot.osm");
 		outputFile = dataUtils.newFile();
 		
@@ -275,4 +275,63 @@ public class PostgreSqlTest extends AbstractDataTest {
 		// Validate that the output file matches the input file.
 		dataUtils.compareFiles(inputFile, outputFile);
 	}
+
+	/**
+	 * A test loading an osm file into a pgsql database with a schema, then dumping it
+	 * again and verifying that it is identical.
+	 * 
+	 * @throws IOException
+	 *             if any file operations fail.
+	 */
+	@Test
+	public void testLoadAndDumpWithSchema() throws IOException {
+		File authFile;
+		File inputFile;
+		File outputFile;
+
+		// Generate input files.
+		authFile = getAuthFile("v0_6/pgsql_with_schema-authfile.txt");
+		inputFile = dataUtils.createDataFile("v0_6/db-snapshot.osm");
+		outputFile = dataUtils.newFile();
+
+		// Remove all existing data from the database.
+		Osmosis.run(
+			new String [] {
+				"-q",
+				"--truncate-pgsql-0.6",
+				"postgresSchema=test_schema",
+				"authFile=" + authFile.getPath()
+			}
+		);
+
+		// Load the database with a dataset.
+		Osmosis.run(
+			new String [] {
+				"-q",
+				"--read-xml-0.6",
+				inputFile.getPath(),
+				"--write-pgsql-0.6",
+				"postgresSchema=test_schema",
+				"authFile=" + authFile.getPath()
+			}
+		);
+
+		// Dump the database to an osm file.
+		Osmosis.run(
+			new String [] {
+				"-q",
+				"--read-pgsql-0.6",
+				"authFile=" + authFile.getPath(),
+				"postgresSchema=test_schema",
+				"--dataset-dump-0.6",
+				"--tag-sort-0.6",
+				"--write-xml-0.6",
+				outputFile.getPath()
+			}
+		);
+
+		// Validate that the output file matches the input file.
+		dataUtils.compareFiles(inputFile, outputFile);
+	}
+
 }
diff --git a/osmosis-pgsnapshot/src/test/resources/data/template/v0_6/pgsql_with_schema-authfile.txt b/osmosis-pgsnapshot/src/test/resources/data/template/v0_6/pgsql_with_schema-authfile.txt
new file mode 100644
index 0000000..d824913
--- /dev/null
+++ b/osmosis-pgsnapshot/src/test/resources/data/template/v0_6/pgsql_with_schema-authfile.txt
@@ -0,0 +1,4 @@
+host=localhost
+database=pgosmsnap06_test_with_schema
+user=osm
+password=password
diff --git a/osmosis-replication-http/build.gradle b/osmosis-replication-http/build.gradle
index fdf1c6f..1b45ca1 100644
--- a/osmosis-replication-http/build.gradle
+++ b/osmosis-replication-http/build.gradle
@@ -2,6 +2,6 @@ dependencies {
     compile project(':osmosis-core')
     compile project(':osmosis-replication')
     compile project(':osmosis-xml')
-    compile group: 'org.jboss.netty', name: 'netty', version: dependencyVersionNetty
+    compile group: 'io.netty', name: 'netty', version: dependencyVersionNetty
     testCompile project(':osmosis-testutil')
 }
diff --git a/osmosis-replication-http/src/main/java/org/openstreetmap/osmosis/replicationhttp/v0_6/impl/SequenceClientHandler.java b/osmosis-replication-http/src/main/java/org/openstreetmap/osmosis/replicationhttp/v0_6/impl/SequenceClientHandler.java
index ab27a76..7d38ca8 100644
--- a/osmosis-replication-http/src/main/java/org/openstreetmap/osmosis/replicationhttp/v0_6/impl/SequenceClientHandler.java
+++ b/osmosis-replication-http/src/main/java/org/openstreetmap/osmosis/replicationhttp/v0_6/impl/SequenceClientHandler.java
@@ -67,7 +67,7 @@ public abstract class SequenceClientHandler extends SimpleChannelHandler {
 		// Send a request to the server asking for sequence number
 		// notifications.
 		HttpRequest request = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, getRequestUri());
-		request.addHeader("Host", serverHost);
+		request.headers().add("Host", serverHost);
 		Channels.write(ctx, e.getFuture(), request);
 
 		midStream = false;
diff --git a/osmosis-replication-http/src/main/java/org/openstreetmap/osmosis/replicationhttp/v0_6/impl/SequenceServerHandler.java b/osmosis-replication-http/src/main/java/org/openstreetmap/osmosis/replicationhttp/v0_6/impl/SequenceServerHandler.java
index 1f7fe97..508f6ad 100644
--- a/osmosis-replication-http/src/main/java/org/openstreetmap/osmosis/replicationhttp/v0_6/impl/SequenceServerHandler.java
+++ b/osmosis-replication-http/src/main/java/org/openstreetmap/osmosis/replicationhttp/v0_6/impl/SequenceServerHandler.java
@@ -75,7 +75,7 @@ public abstract class SequenceServerHandler extends SimpleChannelHandler {
 	private void writeResourceNotFound(final ChannelHandlerContext ctx, String requestedUri) {
 		// Write the HTTP header to the client.
 		DefaultHttpResponse response = new DefaultHttpResponse(HttpVersion.HTTP_1_0, HttpResponseStatus.NOT_FOUND);
-		response.addHeader("Content-Type", "text/plain");
+		response.headers().add("Content-Type", "text/plain");
 
 		// Send the 404 message to the client.
 		ChannelBuffer buffer = ChannelBuffers.copiedBuffer("The requested resource does not exist: " + requestedUri,
@@ -108,7 +108,7 @@ public abstract class SequenceServerHandler extends SimpleChannelHandler {
 	private void writeResourceGone(final ChannelHandlerContext ctx, String requestedUri) {
 		// Write the HTTP header to the client.
 		DefaultHttpResponse response = new DefaultHttpResponse(HttpVersion.HTTP_1_0, HttpResponseStatus.GONE);
-		response.addHeader("Content-Type", "text/plain");
+		response.headers().add("Content-Type", "text/plain");
 
 		// Send the 410 message to the client.
 		ChannelBuffer buffer = ChannelBuffers.copiedBuffer("The requested resource is no longer available: "
@@ -146,7 +146,7 @@ public abstract class SequenceServerHandler extends SimpleChannelHandler {
 
 		// Write the HTTP header to the client.
 		DefaultHttpResponse response = new DefaultHttpResponse(HttpVersion.HTTP_1_0, HttpResponseStatus.NOT_FOUND);
-		response.addHeader("Content-Type", "text/plain");
+		response.headers().add("Content-Type", "text/plain");
 
 		// Send the 400 message to the client.
 		StringBuilder messageBuilder = new StringBuilder();
@@ -184,7 +184,7 @@ public abstract class SequenceServerHandler extends SimpleChannelHandler {
 
 		// Write the HTTP header to the client.
 		DefaultHttpResponse response = new DefaultHttpResponse(HttpVersion.HTTP_1_0, HttpResponseStatus.OK);
-		response.addHeader("Content-Type", "text/plain");
+		response.headers().add("Content-Type", "text/plain");
 
 		// Send the statistics message to the client.
 		StringBuilder messageBuilder = new StringBuilder();
@@ -227,9 +227,9 @@ public abstract class SequenceServerHandler extends SimpleChannelHandler {
 			String contentType, final long requestedSequenceNumber, final boolean follow) {
 		// Create the HTTP header to send to the client.
 		DefaultHttpResponse response = new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK);
-		response.addHeader("Content-Type", contentType);
+		response.headers().add("Content-Type", contentType);
 		response.setChunked(true);
-		response.addHeader(HttpHeaders.Names.TRANSFER_ENCODING, HttpHeaders.Values.CHUNKED);
+		response.headers().add(HttpHeaders.Names.TRANSFER_ENCODING, HttpHeaders.Values.CHUNKED);
 
 		// Write the header. We must use a new future because the future we've
 		// been passed is for upstream.
diff --git a/osmosis-xml/src/main/java/org/openstreetmap/osmosis/xml/common/SaxParserFactory.java b/osmosis-xml/src/main/java/org/openstreetmap/osmosis/xml/common/SaxParserFactory.java
new file mode 100644
index 0000000..5734574
--- /dev/null
+++ b/osmosis-xml/src/main/java/org/openstreetmap/osmosis/xml/common/SaxParserFactory.java
@@ -0,0 +1,114 @@
+// This software is released into the Public Domain.  See copying.txt for details.
+package org.openstreetmap.osmosis.xml.common;
+
+import org.openstreetmap.osmosis.core.OsmosisRuntimeException;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * SAX parser factory that additionally verifies that the underlying parser is providing correct unicode support for
+ * characters requiring more than 1 UTF-16 character.
+ */
+public final class SaxParserFactory {
+
+    private SaxParserFactory() {
+    }
+
+
+    /**
+     * Creates a new SAX parser.
+     *
+     * @return The newly created SAX parser.
+     */
+    public static SAXParser createParser() {
+        try {
+            return SAXParserFactory.newInstance().newSAXParser();
+
+        } catch (ParserConfigurationException e) {
+            throw new OsmosisRuntimeException("Unable to create SAX Parser.", e);
+        } catch (SAXException e) {
+            throw new OsmosisRuntimeException("Unable to create SAX Parser.", e);
+        }
+    }
+
+
+    /**
+     * Validate SAX parser unicode support.
+     */
+    private static void validate() {
+        try {
+            UnicodeTestHandler unicodeTestHandler = new UnicodeTestHandler();
+
+            SAXParser parser = createParser();
+            InputStream is = SaxParserFactory.class.getResourceAsStream("test-unicode-node.osm");
+            parser.parse(is, unicodeTestHandler);
+            if (!unicodeTestHandler.isCorrect()) {
+                throw new OsmosisRuntimeException(
+                        "SAX Parser doesn't correctly support multi-byte characters,"
+                                + " try including a modern version of Xerces on the classpath.");
+            }
+        } catch (SAXException e) {
+            throw new OsmosisRuntimeException("Unable to create SAX Parser.", e);
+        } catch (IOException e) {
+            throw new OsmosisRuntimeException("Unable to read unicode test file.", e);
+        }
+    }
+
+
+    static {
+        // Trigger validation during class initialisation.
+        validate();
+    }
+
+
+    /**
+     * Looks at the SAX document and validates that the "name" and "name:en" attributes both contain the
+     * correct value.
+     */
+    private static class UnicodeTestHandler extends DefaultHandler {
+        // The expected value of test tags.  These escape sequences represent a single treble-clef which requires
+        // two 16-bit characters.  Represented using escape sequences to prevent accidental munging by dev tools.
+        private static final String NAME_VALUE = "H\uD834\uDD1EM Events";
+        private boolean nameCorrect;
+        private boolean enNameCorrect;
+
+
+        private boolean validateNameValue(Attributes attributes) {
+            return NAME_VALUE.equals(attributes.getValue("v"));
+        }
+
+
+        @Override
+        public void startElement(
+                String uri, String localName, String qName, Attributes attributes) throws SAXException {
+            if ("tag".equals(qName)) {
+                if ("name".equals(attributes.getValue("k"))) {
+                    if (validateNameValue(attributes)) {
+                        nameCorrect = true;
+                    }
+                } else if ("name:en".equals(attributes.getValue("k"))) {
+                    if (validateNameValue(attributes)) {
+                        enNameCorrect = true;
+                    }
+                }
+            }
+        }
+
+
+        /**
+         * Are all fields correct.
+         *
+         * @return True if all correct.
+         */
+        public boolean isCorrect() {
+            return nameCorrect && enNameCorrect;
+        }
+    }
+}
diff --git a/osmosis-xml/src/main/java/org/openstreetmap/osmosis/xml/v0_6/XmlChangeReader.java b/osmosis-xml/src/main/java/org/openstreetmap/osmosis/xml/v0_6/XmlChangeReader.java
index d64e6be..0139da7 100644
--- a/osmosis-xml/src/main/java/org/openstreetmap/osmosis/xml/v0_6/XmlChangeReader.java
+++ b/osmosis-xml/src/main/java/org/openstreetmap/osmosis/xml/v0_6/XmlChangeReader.java
@@ -1,47 +1,45 @@
 // This software is released into the Public Domain.  See copying.txt for details.
 package org.openstreetmap.osmosis.xml.v0_6;
 
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Collections;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.parsers.SAXParser;
-import javax.xml.parsers.SAXParserFactory;
-
 import org.openstreetmap.osmosis.core.OsmosisRuntimeException;
 import org.openstreetmap.osmosis.core.task.v0_6.ChangeSink;
 import org.openstreetmap.osmosis.core.task.v0_6.RunnableChangeSource;
 import org.openstreetmap.osmosis.xml.common.CompressionActivator;
 import org.openstreetmap.osmosis.xml.common.CompressionMethod;
+import org.openstreetmap.osmosis.xml.common.SaxParserFactory;
 import org.openstreetmap.osmosis.xml.v0_6.impl.OsmChangeHandler;
 import org.xml.sax.SAXException;
 import org.xml.sax.SAXParseException;
 
+import javax.xml.parsers.SAXParser;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Collections;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
 
 /**
  * A change source reading from an xml file. The entire contents of the file
  * are read.
- * 
+ *
  * @author Brett Henderson
  */
 public class XmlChangeReader implements RunnableChangeSource {
-	
+
 	private static Logger log = Logger.getLogger(XmlReader.class.getName());
-	
+
 	private ChangeSink changeSink;
 	private File file;
 	private boolean enableDateParsing;
 	private CompressionMethod compressionMethod;
-	
-	
+
+
 	/**
 	 * Creates a new instance.
-	 * 
+	 *
 	 * @param file
 	 *            The file to read.
 	 * @param enableDateParsing
@@ -55,61 +53,44 @@ public class XmlChangeReader implements RunnableChangeSource {
 		this.enableDateParsing = enableDateParsing;
 		this.compressionMethod = compressionMethod;
 	}
-	
-	
+
+
 	/**
 	 * {@inheritDoc}
 	 */
 	public void setChangeSink(ChangeSink changeSink) {
 		this.changeSink = changeSink;
 	}
-	
-	
-	/**
-	 * Creates a new SAX parser.
-	 * 
-	 * @return The newly created SAX parser.
-	 */
-	private SAXParser createParser() {
-		try {
-			return SAXParserFactory.newInstance().newSAXParser();
-			
-		} catch (ParserConfigurationException e) {
-			throw new OsmosisRuntimeException("Unable to create SAX Parser.", e);
-		} catch (SAXException e) {
-			throw new OsmosisRuntimeException("Unable to create SAX Parser.", e);
-		}
-	}
-	
-	
+
+
 	/**
 	 * Reads all data from the file and send it to the sink.
 	 */
 	public void run() {
 		InputStream inputStream = null;
-		
+
 		try {
 			SAXParser parser;
-			
+
 			changeSink.initialize(Collections.<String, Object>emptyMap());
-			
+
 			// make "-" an alias for /dev/stdin
 			if (file.getName().equals("-")) {
 				inputStream = System.in;
 			} else {
 				inputStream = new FileInputStream(file);
 			}
-			
+
 			inputStream =
 				new CompressionActivator(compressionMethod).
 					createCompressionInputStream(inputStream);
-			
-			parser = createParser();
-			
+
+			parser = SaxParserFactory.createParser();
+
 			parser.parse(inputStream, new OsmChangeHandler(changeSink, enableDateParsing));
-			
+
 			changeSink.complete();
-			
+
 		} catch (SAXParseException e) {
 			throw new OsmosisRuntimeException(
 				"Unable to parse xml file " + file
@@ -124,7 +105,7 @@ public class XmlChangeReader implements RunnableChangeSource {
 			throw new OsmosisRuntimeException("Unable to read XML file " + file + ".", e);
 		} finally {
 			changeSink.release();
-			
+
 			if (inputStream != null) {
 				try {
 					inputStream.close();
diff --git a/osmosis-xml/src/main/java/org/openstreetmap/osmosis/xml/v0_6/XmlReader.java b/osmosis-xml/src/main/java/org/openstreetmap/osmosis/xml/v0_6/XmlReader.java
index 6e24c54..3e93fa5 100644
--- a/osmosis-xml/src/main/java/org/openstreetmap/osmosis/xml/v0_6/XmlReader.java
+++ b/osmosis-xml/src/main/java/org/openstreetmap/osmosis/xml/v0_6/XmlReader.java
@@ -1,6 +1,17 @@
 // This software is released into the Public Domain.  See copying.txt for details.
 package org.openstreetmap.osmosis.xml.v0_6;
 
+import org.openstreetmap.osmosis.core.OsmosisRuntimeException;
+import org.openstreetmap.osmosis.core.task.v0_6.RunnableSource;
+import org.openstreetmap.osmosis.core.task.v0_6.Sink;
+import org.openstreetmap.osmosis.xml.common.CompressionActivator;
+import org.openstreetmap.osmosis.xml.common.CompressionMethod;
+import org.openstreetmap.osmosis.xml.common.SaxParserFactory;
+import org.openstreetmap.osmosis.xml.v0_6.impl.OsmHandler;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+
+import javax.xml.parsers.SAXParser;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
@@ -9,20 +20,6 @@ import java.util.Collections;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.parsers.SAXParser;
-import javax.xml.parsers.SAXParserFactory;
-
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-
-import org.openstreetmap.osmosis.core.OsmosisRuntimeException;
-import org.openstreetmap.osmosis.core.task.v0_6.RunnableSource;
-import org.openstreetmap.osmosis.core.task.v0_6.Sink;
-import org.openstreetmap.osmosis.xml.common.CompressionActivator;
-import org.openstreetmap.osmosis.xml.common.CompressionMethod;
-import org.openstreetmap.osmosis.xml.v0_6.impl.OsmHandler;
-
 
 /**
  * An OSM data source reading from an xml file. The entire contents of the file
@@ -67,23 +64,6 @@ public class XmlReader implements RunnableSource {
 	
 	
 	/**
-	 * Creates a new SAX parser.
-	 * 
-	 * @return The newly created SAX parser.
-	 */
-	private SAXParser createParser() {
-		try {
-			return SAXParserFactory.newInstance().newSAXParser();
-			
-		} catch (ParserConfigurationException e) {
-			throw new OsmosisRuntimeException("Unable to create SAX Parser.", e);
-		} catch (SAXException e) {
-			throw new OsmosisRuntimeException("Unable to create SAX Parser.", e);
-		}
-	}
-	
-	
-	/**
 	 * Reads all data from the file and send it to the sink.
 	 */
 	public void run() {
@@ -100,13 +80,12 @@ public class XmlReader implements RunnableSource {
 			} else {
 				inputStream = new FileInputStream(file);
 			}
-			
-			
+
 			inputStream =
 				new CompressionActivator(compressionMethod).
 					createCompressionInputStream(inputStream);
-			
-			parser = createParser();
+
+			parser = SaxParserFactory.createParser();
 			
 			parser.parse(inputStream, new OsmHandler(sink, enableDateParsing));
 			
diff --git a/osmosis-xml/src/main/resources/org/openstreetmap/osmosis/xml/common/test-unicode-node.osm b/osmosis-xml/src/main/resources/org/openstreetmap/osmosis/xml/common/test-unicode-node.osm
new file mode 100644
index 0000000..1a117bb
--- /dev/null
+++ b/osmosis-xml/src/main/resources/org/openstreetmap/osmosis/xml/common/test-unicode-node.osm
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<osm version="0.6" generator="CGImap 0.4.0 (18495 thorn-01.openstreetmap.org)" copyright="OpenStreetMap and contributors" attribution="http://www.openstreetmap.org/copyright" license="http://opendatacommons.org/licenses/odbl/1-0/">
+ <node id="3382756758" visible="true" version="1" changeset="29244040" timestamp="2015-03-04T12:59:17Z" user="Khalfi" uid="2108921" lat="34.0024546" lon="-6.8459973">
+  <tag k="addr:city" v="rabat"/>
+  <tag k="addr:postcode" v="10000"/>
+  <tag k="addr:street" v="Avenue Omar Ibn Khattab"/>
+  <tag k="name" v="H𝄞M Events"/>
+  <tag k="name:en" v="H𝄞M Events"/>
+  <tag k="phone" v="+212 (0) 6 61 33 07 02"/>
+ </node>
+</osm>
diff --git a/osmosis-xml/src/test/java/org/openstreetmap/osmosis/xml/common/SaxParserFactoryTest.java b/osmosis-xml/src/test/java/org/openstreetmap/osmosis/xml/common/SaxParserFactoryTest.java
new file mode 100644
index 0000000..e512b21
--- /dev/null
+++ b/osmosis-xml/src/test/java/org/openstreetmap/osmosis/xml/common/SaxParserFactoryTest.java
@@ -0,0 +1,23 @@
+// This software is released into the Public Domain.  See copying.txt for details.
+package org.openstreetmap.osmosis.xml.common;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import javax.xml.parsers.SAXParser;
+
+/**
+ * Test the SaxParserFactory.
+ *
+ * @author Brett Henderson
+ */
+public class SaxParserFactoryTest {
+    /**
+     * Verify that a parser is successfully created.
+     */
+    @Test
+    public void testCreateParser() {
+        SAXParser parser = SaxParserFactory.createParser();
+        Assert.assertNotNull("Parser was not created", parser);
+    }
+}
diff --git a/package/bin/osmosis.bat b/package/bin/osmosis.bat
index 7f7a773..8e31e00 100644
--- a/package/bin/osmosis.bat
+++ b/package/bin/osmosis.bat
@@ -35,7 +35,7 @@ REM Change back to the original directory
 cd /D %SAVEDIR%
 
 set MAINCLASS=org.codehaus.classworlds.Launcher
-set PLEXUS_CP=%MYAPP_HOME%\lib\default\plexus-classworlds-2.4.jar
+set PLEXUS_CP=%MYAPP_HOME%\lib\default\plexus-classworlds-2.5.2.jar
 SET EXEC="%JAVACMD%" %JAVACMD_OPTIONS% -cp "%PLEXUS_CP%" -Dapp.home="%MYAPP_HOME%" -Dclassworlds.conf="%MYAPP_HOME%\config\plexus.conf" %MAINCLASS%  %OSMOSIS_OPTIONS% %*
 
 %EXEC%
diff --git a/package/changes.txt b/package/changes.txt
index f74e37a..3de6d38 100644
--- a/package/changes.txt
+++ b/package/changes.txt
@@ -1,3 +1,12 @@
+0.45
+Add postgresSchema option to pgsnapshot tasks.
+Verify XML parser on startup to verify support for multi-char unicode characters.
+Upgrade to latest version of Netty.
+Various dependency version updates.
+Fix incorrect plexus classworlds version in Windows launch script.
+Upgrade to PostGIS 2.x library.
+Add tests for pgsimple database.
+
 0.44
 Improve default settings and performance of pgsnapshot load scripts.
 Fix remaining 64-bit id tracking problems.

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/osmosis.git



More information about the Pkg-grass-devel mailing list