[Git][debian-gis-team/osmosis][buster-backports] 6 commits: New upstream version 0.47.4

Bas Couwenberg gitlab at salsa.debian.org
Mon Apr 13 04:46:35 BST 2020



Bas Couwenberg pushed to branch buster-backports at Debian GIS Project / osmosis


Commits:
ea0afe68 by Bas Couwenberg at 2020-04-08T05:57:40+02:00
New upstream version 0.47.4
- - - - -
1fc99eda by Bas Couwenberg at 2020-04-08T05:57:44+02:00
Update upstream source from tag 'upstream/0.47.4'

Update to upstream version '0.47.4'
with Debian dir b3810efd6b6b56e243b41dc13174fc45664585b5
- - - - -
e2bcf7d3 by Bas Couwenberg at 2020-04-08T05:57:58+02:00
New upstream release.

- - - - -
b8e7f993 by Bas Couwenberg at 2020-04-08T05:59:30+02:00
Set distribution to unstable.

- - - - -
c6648eef by Bas Couwenberg at 2020-04-13T05:36:58+02:00
Merge tag 'debian/0.47.4-1' into buster-backports

releasing package osmosis version 0.47.4-1

- - - - -
3af7b739 by Bas Couwenberg at 2020-04-13T05:37:06+02:00
Rebuild for buster-backports.

- - - - -


16 changed files:

- debian/changelog
- osmosis-replication/src/main/java/org/openstreetmap/osmosis/replication/v0_6/IntervalDownloaderFactory.java
- osmosis-replication/src/main/java/org/openstreetmap/osmosis/replication/v0_6/IntervalDownloaderInitializerFactory.java
- osmosis-replication/src/main/java/org/openstreetmap/osmosis/replication/v0_6/ReplicationDownloaderFactory.java
- osmosis-replication/src/main/java/org/openstreetmap/osmosis/replication/v0_6/ReplicationDownloaderInitializerFactory.java
- osmosis-replication/src/main/java/org/openstreetmap/osmosis/replication/v0_6/ReplicationFileMergerFactory.java
- osmosis-replication/src/main/java/org/openstreetmap/osmosis/replication/v0_6/ReplicationFileMergerInitializerFactory.java
- osmosis-replication/src/main/java/org/openstreetmap/osmosis/replication/v0_6/ReplicationLagReaderFactory.java
- osmosis-replication/src/main/java/org/openstreetmap/osmosis/replication/v0_6/ReplicationToChangeWriterFactory.java
- osmosis-replication/src/main/java/org/openstreetmap/osmosis/replication/v0_6/ReplicationWriterFactory.java
- + osmosis-replication/src/main/java/org/openstreetmap/osmosis/replication/v0_6/WorkingTaskManagerFactory.java
- osmosis-xml/src/main/java/org/openstreetmap/osmosis/xml/v0_6/FastXmlReader.java
- osmosis-xml/src/main/java/org/openstreetmap/osmosis/xml/v0_6/XmlChangeReader.java
- osmosis-xml/src/main/java/org/openstreetmap/osmosis/xml/v0_6/XmlReader.java
- + osmosis-xml/src/main/java/org/openstreetmap/osmosis/xml/v0_6/impl/BaseXMLReader.java
- package/changes.txt


Changes:

=====================================
debian/changelog
=====================================
@@ -1,3 +1,15 @@
+osmosis (0.47.4-1~bpo10+1) buster-backports; urgency=medium
+
+  * Rebuild for buster-backports.
+
+ -- Bas Couwenberg <sebastic at debian.org>  Mon, 13 Apr 2020 05:37:01 +0200
+
+osmosis (0.47.4-1) unstable; urgency=medium
+
+  * New upstream release.
+
+ -- Bas Couwenberg <sebastic at debian.org>  Wed, 08 Apr 2020 05:59:22 +0200
+
 osmosis (0.47.3-1~bpo10+1) buster-backports; urgency=medium
 
   * Rebuild for buster-backports.


=====================================
osmosis-replication/src/main/java/org/openstreetmap/osmosis/replication/v0_6/IntervalDownloaderFactory.java
=====================================
@@ -1,47 +1,27 @@
 // This software is released into the Public Domain.  See copying.txt for details.
 package org.openstreetmap.osmosis.replication.v0_6;
 
-import java.io.File;
-
 import org.openstreetmap.osmosis.core.pipeline.common.TaskConfiguration;
 import org.openstreetmap.osmosis.core.pipeline.common.TaskManager;
-import org.openstreetmap.osmosis.core.pipeline.common.TaskManagerFactory;
 import org.openstreetmap.osmosis.core.pipeline.v0_6.RunnableChangeSourceManager;
 
-
 /**
  * The task manager factory for a change downloader.
  * 
  * @author Brett Henderson
  */
-public class IntervalDownloaderFactory extends TaskManagerFactory {
-	private static final String ARG_WORKING_DIRECTORY = "workingDirectory";
-	private static final String DEFAULT_WORKING_DIRECTORY = "./";
-	
+public class IntervalDownloaderFactory extends WorkingTaskManagerFactory {
 	
 	/**
 	 * {@inheritDoc}
 	 */
 	@Override
 	protected TaskManager createTaskManagerImpl(TaskConfiguration taskConfig) {
-		String workingDirectoryString;
-		File workingDirectory;
-		
-		// Get the task arguments.
-		workingDirectoryString = getStringArgument(
-			taskConfig,
-			ARG_WORKING_DIRECTORY,
-			getDefaultStringArgument(taskConfig, DEFAULT_WORKING_DIRECTORY)
-		);
-		
-		// Convert argument strings to strongly typed objects.
-		workingDirectory = new File(workingDirectoryString);
-		
 		return new RunnableChangeSourceManager(
 			taskConfig.getId(),
 			new IntervalDownloader(
 				taskConfig.getId(),
-				workingDirectory
+				this.getWorkingDirectory(taskConfig)
 			),
 			taskConfig.getPipeArgs()
 		);


=====================================
osmosis-replication/src/main/java/org/openstreetmap/osmosis/replication/v0_6/IntervalDownloaderInitializerFactory.java
=====================================
@@ -1,51 +1,34 @@
 // This software is released into the Public Domain.  See copying.txt for details.
 package org.openstreetmap.osmosis.replication.v0_6;
 
-import java.io.File;
 import java.util.Date;
 import java.util.TimeZone;
 
 import org.openstreetmap.osmosis.core.pipeline.common.RunnableTaskManager;
 import org.openstreetmap.osmosis.core.pipeline.common.TaskConfiguration;
 import org.openstreetmap.osmosis.core.pipeline.common.TaskManager;
-import org.openstreetmap.osmosis.core.pipeline.common.TaskManagerFactory;
-
 
 /**
  * The task manager factory for a change download initializer.
  * 
  * @author Brett Henderson
  */
-public class IntervalDownloaderInitializerFactory extends TaskManagerFactory {
-	private static final String ARG_WORKING_DIRECTORY = "workingDirectory";
+public class IntervalDownloaderInitializerFactory extends WorkingTaskManagerFactory {
 	private static final String ARG_INITIAL_DATE = "initialDate";
-	private static final String DEFAULT_WORKING_DIRECTORY = "./";
-	
-	
+    
 	/**
 	 * {@inheritDoc}
 	 */
 	@Override
 	protected TaskManager createTaskManagerImpl(TaskConfiguration taskConfig) {
-		String workingDirectoryString;
 		Date initialDate;
-		File workingDirectory;
-		
 		// Get the task arguments.
-		workingDirectoryString = getStringArgument(
-			taskConfig,
-			ARG_WORKING_DIRECTORY,
-			getDefaultStringArgument(taskConfig, DEFAULT_WORKING_DIRECTORY)
-		);
 		initialDate = getDateArgument(taskConfig, ARG_INITIAL_DATE, TimeZone.getTimeZone("UTC"));
 		
-		// Convert argument strings to strongly typed objects.
-		workingDirectory = new File(workingDirectoryString);
-		
 		return new RunnableTaskManager(
 			taskConfig.getId(),
 			new IntervalDownloaderInitializer(
-				workingDirectory,
+				this.getWorkingDirectory(taskConfig),
 				initialDate
 			),
 			taskConfig.getPipeArgs()


=====================================
osmosis-replication/src/main/java/org/openstreetmap/osmosis/replication/v0_6/ReplicationDownloaderFactory.java
=====================================
@@ -1,44 +1,24 @@
 // This software is released into the Public Domain.  See copying.txt for details.
 package org.openstreetmap.osmosis.replication.v0_6;
 
-import java.io.File;
-
 import org.openstreetmap.osmosis.core.pipeline.common.TaskConfiguration;
 import org.openstreetmap.osmosis.core.pipeline.common.TaskManager;
-import org.openstreetmap.osmosis.core.pipeline.common.TaskManagerFactory;
 import org.openstreetmap.osmosis.core.pipeline.v0_6.RunnableChangeSourceManager;
 
-
 /**
  * The task manager factory for a replication file downloader.
  */
-public class ReplicationDownloaderFactory extends TaskManagerFactory {
-	private static final String ARG_WORKING_DIRECTORY = "workingDirectory";
-	private static final String DEFAULT_WORKING_DIRECTORY = "./";
-	
+public class ReplicationDownloaderFactory extends WorkingTaskManagerFactory {
 	
 	/**
 	 * {@inheritDoc}
 	 */
 	@Override
 	protected TaskManager createTaskManagerImpl(TaskConfiguration taskConfig) {
-		String workingDirectoryString;
-		File workingDirectory;
-		
-		// Get the task arguments.
-		workingDirectoryString = getStringArgument(
-			taskConfig,
-			ARG_WORKING_DIRECTORY,
-			getDefaultStringArgument(taskConfig, DEFAULT_WORKING_DIRECTORY)
-		);
-		
-		// Convert argument strings to strongly typed objects.
-		workingDirectory = new File(workingDirectoryString);
-		
 		return new RunnableChangeSourceManager(
 			taskConfig.getId(),
 			new ReplicationDownloader(
-				workingDirectory
+				this.getWorkingDirectory(taskConfig)
 			),
 			taskConfig.getPipeArgs()
 		);


=====================================
osmosis-replication/src/main/java/org/openstreetmap/osmosis/replication/v0_6/ReplicationDownloaderInitializerFactory.java
=====================================
@@ -1,44 +1,24 @@
 // This software is released into the Public Domain.  See copying.txt for details.
 package org.openstreetmap.osmosis.replication.v0_6;
 
-import java.io.File;
-
 import org.openstreetmap.osmosis.core.pipeline.common.RunnableTaskManager;
 import org.openstreetmap.osmosis.core.pipeline.common.TaskConfiguration;
 import org.openstreetmap.osmosis.core.pipeline.common.TaskManager;
-import org.openstreetmap.osmosis.core.pipeline.common.TaskManagerFactory;
-
 
 /**
  * The task manager factory for a replication file download initializer.
  */
-public class ReplicationDownloaderInitializerFactory extends TaskManagerFactory {
-	private static final String ARG_WORKING_DIRECTORY = "workingDirectory";
-	private static final String DEFAULT_WORKING_DIRECTORY = "./";
-	
+public class ReplicationDownloaderInitializerFactory extends WorkingTaskManagerFactory {
 	
 	/**
 	 * {@inheritDoc}
 	 */
 	@Override
 	protected TaskManager createTaskManagerImpl(TaskConfiguration taskConfig) {
-		String workingDirectoryString;
-		File workingDirectory;
-		
-		// Get the task arguments.
-		workingDirectoryString = getStringArgument(
-			taskConfig,
-			ARG_WORKING_DIRECTORY,
-			getDefaultStringArgument(taskConfig, DEFAULT_WORKING_DIRECTORY)
-		);
-		
-		// Convert argument strings to strongly typed objects.
-		workingDirectory = new File(workingDirectoryString);
-		
 		return new RunnableTaskManager(
 			taskConfig.getId(),
 			new ReplicationDownloaderInitializer(
-				workingDirectory
+				this.getWorkingDirectory(taskConfig)
 			),
 			taskConfig.getPipeArgs()
 		);


=====================================
osmosis-replication/src/main/java/org/openstreetmap/osmosis/replication/v0_6/ReplicationFileMergerFactory.java
=====================================
@@ -1,44 +1,25 @@
 // This software is released into the Public Domain.  See copying.txt for details.
 package org.openstreetmap.osmosis.replication.v0_6;
 
-import java.io.File;
-
 import org.openstreetmap.osmosis.core.pipeline.common.RunnableTaskManager;
 import org.openstreetmap.osmosis.core.pipeline.common.TaskConfiguration;
 import org.openstreetmap.osmosis.core.pipeline.common.TaskManager;
-import org.openstreetmap.osmosis.core.pipeline.common.TaskManagerFactory;
 
 
 /**
  * The task manager factory for a replication file merger.
  */
-public class ReplicationFileMergerFactory extends TaskManagerFactory {
-	private static final String ARG_WORKING_DIRECTORY = "workingDirectory";
-	private static final String DEFAULT_WORKING_DIRECTORY = "./";
-	
+public class ReplicationFileMergerFactory extends WorkingTaskManagerFactory {
 	
 	/**
 	 * {@inheritDoc}
 	 */
 	@Override
 	protected TaskManager createTaskManagerImpl(TaskConfiguration taskConfig) {
-		String workingDirectoryString;
-		File workingDirectory;
-		
-		// Get the task arguments.
-		workingDirectoryString = getStringArgument(
-			taskConfig,
-			ARG_WORKING_DIRECTORY,
-			getDefaultStringArgument(taskConfig, DEFAULT_WORKING_DIRECTORY)
-		);
-		
-		// Convert argument strings to strongly typed objects.
-		workingDirectory = new File(workingDirectoryString);
-		
 		return new RunnableTaskManager(
 			taskConfig.getId(),
 			new ReplicationFileMerger(
-				workingDirectory
+				this.getWorkingDirectory(taskConfig)
 			),
 			taskConfig.getPipeArgs()
 		);


=====================================
osmosis-replication/src/main/java/org/openstreetmap/osmosis/replication/v0_6/ReplicationFileMergerInitializerFactory.java
=====================================
@@ -1,44 +1,24 @@
 // This software is released into the Public Domain.  See copying.txt for details.
 package org.openstreetmap.osmosis.replication.v0_6;
 
-import java.io.File;
-
 import org.openstreetmap.osmosis.core.pipeline.common.RunnableTaskManager;
 import org.openstreetmap.osmosis.core.pipeline.common.TaskConfiguration;
 import org.openstreetmap.osmosis.core.pipeline.common.TaskManager;
-import org.openstreetmap.osmosis.core.pipeline.common.TaskManagerFactory;
-
 
 /**
  * The task manager factory for a replication file merger initializer.
  */
-public class ReplicationFileMergerInitializerFactory extends TaskManagerFactory {
-	private static final String ARG_WORKING_DIRECTORY = "workingDirectory";
-	private static final String DEFAULT_WORKING_DIRECTORY = "./";
-	
+public class ReplicationFileMergerInitializerFactory extends WorkingTaskManagerFactory {
 	
 	/**
 	 * {@inheritDoc}
 	 */
 	@Override
 	protected TaskManager createTaskManagerImpl(TaskConfiguration taskConfig) {
-		String workingDirectoryString;
-		File workingDirectory;
-		
-		// Get the task arguments.
-		workingDirectoryString = getStringArgument(
-			taskConfig,
-			ARG_WORKING_DIRECTORY,
-			getDefaultStringArgument(taskConfig, DEFAULT_WORKING_DIRECTORY)
-		);
-		
-		// Convert argument strings to strongly typed objects.
-		workingDirectory = new File(workingDirectoryString);
-		
 		return new RunnableTaskManager(
 			taskConfig.getId(),
 			new ReplicationFileMergerInitializer(
-				workingDirectory
+				this.getWorkingDirectory(taskConfig)
 			),
 			taskConfig.getPipeArgs()
 		);


=====================================
osmosis-replication/src/main/java/org/openstreetmap/osmosis/replication/v0_6/ReplicationLagReaderFactory.java
=====================================
@@ -1,54 +1,35 @@
 // This software is released into the Public Domain.  See copying.txt for details.
 package org.openstreetmap.osmosis.replication.v0_6;
 
-import java.io.File;
-
 import org.openstreetmap.osmosis.core.pipeline.common.RunnableTaskManager;
 import org.openstreetmap.osmosis.core.pipeline.common.TaskConfiguration;
 import org.openstreetmap.osmosis.core.pipeline.common.TaskManager;
-import org.openstreetmap.osmosis.core.pipeline.common.TaskManagerFactory;
-
 
 /**
  * The task manager factory for a replication lag reader.
  * 
  * @author Peter Koerner
  */
-public class ReplicationLagReaderFactory extends TaskManagerFactory {
+public class ReplicationLagReaderFactory extends WorkingTaskManagerFactory {
 	private static final String ARG_HUMAN_READABLE = "humanReadable";
 	private static final boolean DEFAULT_HUMAN_READABLE = false;
-	private static final String ARG_WORKING_DIRECTORY = "workingDirectory";
-	private static final String DEFAULT_WORKING_DIRECTORY = "./";
-	
 	
 	/**
 	 * {@inheritDoc}
 	 */
 	@Override
 	protected TaskManager createTaskManagerImpl(TaskConfiguration taskConfig) {
-		String workingDirectoryString;
 		boolean humanReadableFlag;
-		File workingDirectory;
-		
-		// Get the task arguments.
-		workingDirectoryString = getStringArgument(
-			taskConfig,
-			ARG_WORKING_DIRECTORY,
-			getDefaultStringArgument(taskConfig, DEFAULT_WORKING_DIRECTORY)
-		);
 		humanReadableFlag = getBooleanArgument(
 			taskConfig,
 			ARG_HUMAN_READABLE, 
 			DEFAULT_HUMAN_READABLE
 		);
 		
-		// Convert argument strings to strongly typed objects.
-		workingDirectory = new File(workingDirectoryString);
-		
 		return new RunnableTaskManager(
 			taskConfig.getId(),
 			new ReplicationLagReader(
-				workingDirectory, 
+				this.getWorkingDirectory(taskConfig), 
 				humanReadableFlag
 			),
 			taskConfig.getPipeArgs()


=====================================
osmosis-replication/src/main/java/org/openstreetmap/osmosis/replication/v0_6/ReplicationToChangeWriterFactory.java
=====================================
@@ -1,40 +1,23 @@
 // This software is released into the Public Domain.  See copying.txt for details.
 package org.openstreetmap.osmosis.replication.v0_6;
 
-import java.io.File;
-
 import org.openstreetmap.osmosis.core.pipeline.common.TaskConfiguration;
 import org.openstreetmap.osmosis.core.pipeline.common.TaskManager;
-import org.openstreetmap.osmosis.core.pipeline.common.TaskManagerFactory;
 import org.openstreetmap.osmosis.core.pipeline.v0_6.ChangeSinkChangeSourceManager;
 
-
 /**
  * The task manager factory for a replication to change writer.
  */
-public class ReplicationToChangeWriterFactory extends TaskManagerFactory {
-	private static final String ARG_WORKING_DIRECTORY = "workingDirectory";
-	private static final String DEFAULT_WORKING_DIRECTORY = "./";
-
+public class ReplicationToChangeWriterFactory extends WorkingTaskManagerFactory {
 
 	/**
 	 * {@inheritDoc}
 	 */
 	@Override
 	protected TaskManager createTaskManagerImpl(TaskConfiguration taskConfig) {
-		String workingDirectoryString;
-		File workingDirectory;
-
-		// Get the task arguments.
-		workingDirectoryString = getStringArgument(taskConfig, ARG_WORKING_DIRECTORY,
-				getDefaultStringArgument(taskConfig, DEFAULT_WORKING_DIRECTORY));
-
-		// Convert argument strings to strongly typed objects.
-		workingDirectory = new File(workingDirectoryString);
-
 		return new ChangeSinkChangeSourceManager(
 				taskConfig.getId(),
-				new ReplicationToChangeWriter(workingDirectory),
+				new ReplicationToChangeWriter(this.getWorkingDirectory(taskConfig)),
 				taskConfig.getPipeArgs());
 	}
 }


=====================================
osmosis-replication/src/main/java/org/openstreetmap/osmosis/replication/v0_6/ReplicationWriterFactory.java
=====================================
@@ -1,40 +1,24 @@
 // This software is released into the Public Domain.  See copying.txt for details.
 package org.openstreetmap.osmosis.replication.v0_6;
 
-import java.io.File;
-
 import org.openstreetmap.osmosis.core.pipeline.common.TaskConfiguration;
 import org.openstreetmap.osmosis.core.pipeline.common.TaskManager;
-import org.openstreetmap.osmosis.core.pipeline.common.TaskManagerFactory;
 import org.openstreetmap.osmosis.core.pipeline.v0_6.ChangeSinkManager;
 
 
 /**
  * The task manager factory for a replication file downloader.
  */
-public class ReplicationWriterFactory extends TaskManagerFactory {
-	private static final String ARG_WORKING_DIRECTORY = "workingDirectory";
-	private static final String DEFAULT_WORKING_DIRECTORY = "./";
-
+public class ReplicationWriterFactory extends WorkingTaskManagerFactory {
 
 	/**
 	 * {@inheritDoc}
 	 */
 	@Override
 	protected TaskManager createTaskManagerImpl(TaskConfiguration taskConfig) {
-		String workingDirectoryString;
-		File workingDirectory;
-
-		// Get the task arguments.
-		workingDirectoryString = getStringArgument(taskConfig, ARG_WORKING_DIRECTORY,
-				getDefaultStringArgument(taskConfig, DEFAULT_WORKING_DIRECTORY));
-
-		// Convert argument strings to strongly typed objects.
-		workingDirectory = new File(workingDirectoryString);
-
 		return new ChangeSinkManager(
 				taskConfig.getId(),
-				new ReplicationWriter(workingDirectory),
+				new ReplicationWriter(this.getWorkingDirectory(taskConfig)),
 				taskConfig.getPipeArgs());
 	}
 }


=====================================
osmosis-replication/src/main/java/org/openstreetmap/osmosis/replication/v0_6/WorkingTaskManagerFactory.java
=====================================
@@ -0,0 +1,31 @@
+// This software is released into the Public Domain.  See copying.txt for details.
+package org.openstreetmap.osmosis.replication.v0_6;
+
+ import java.io.File;
+
+ import org.openstreetmap.osmosis.core.pipeline.common.TaskConfiguration;
+import org.openstreetmap.osmosis.core.pipeline.common.TaskManagerFactory;
+
+ /**
+ * Base Factory for the replication classes, specifically for the working directory argument.
+ *
+ * @author mcuthbert
+ */
+public abstract class WorkingTaskManagerFactory extends TaskManagerFactory {
+    private static final String ARG_WORKING_DIRECTORY = "workingDirectory";
+    private static final String DEFAULT_WORKING_DIRECTORY = "./";
+
+     /**
+     * Gets the current working directory for the task.
+     *
+     * @param taskConfig {@link TaskConfiguration}
+     * @return {@link File}
+     */
+    protected File getWorkingDirectory(final TaskConfiguration taskConfig) {
+        return new File(this.getStringArgument(
+                taskConfig,
+                ARG_WORKING_DIRECTORY,
+                getDefaultStringArgument(taskConfig, DEFAULT_WORKING_DIRECTORY)
+        ));
+    }
+}


=====================================
osmosis-xml/src/main/java/org/openstreetmap/osmosis/xml/v0_6/FastXmlReader.java
=====================================
@@ -2,23 +2,22 @@
 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.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamReader;
 
-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.BaseXMLReader;
 import org.openstreetmap.osmosis.xml.v0_6.impl.FastXmlParser;
-
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
 
 /**
  * An OSM data source reading from an xml file. The entire contents of the file
@@ -27,90 +26,58 @@ import org.openstreetmap.osmosis.xml.v0_6.impl.FastXmlParser;
  * @author Jiri Clement
  * @author Brett Henderson
  */
-public class FastXmlReader implements RunnableSource {
-		
-		private static Logger log = Logger.getLogger(FastXmlReader.class.getName());
-		
-		private Sink sink;
-		private final File file;
-		private final boolean enableDateParsing;
-		private final CompressionMethod compressionMethod;
-		
+public class FastXmlReader extends BaseXMLReader implements RunnableSource {
+	private Sink sink;
 		
-		/**
-		 * Creates a new instance.
-		 * 
-		 * @param file
-		 *            The file to read.
-		 * @param enableDateParsing
-		 *            If true, dates will be parsed from xml data, else the current
-		 *            date will be used thus saving parsing time.
-		 * @param compressionMethod
-		 *            Specifies the compression method to employ.
-		 */
-		public FastXmlReader(File file, boolean enableDateParsing, CompressionMethod compressionMethod) {
-			this.file = file;
-			this.enableDateParsing = enableDateParsing;
-			this.compressionMethod = compressionMethod;
-		}
+	/**
+     * Creates a new instance.
+	 * 
+	 * @param file
+	 *            The file to read.
+	 * @param enableDateParsing
+	 *            If true, dates will be parsed from xml data, else the current
+     *            date will be used thus saving parsing time.
+     * @param compressionMethod
+	 *            Specifies the compression method to employ.
+	 */
+	public FastXmlReader(File file, boolean enableDateParsing, CompressionMethod compressionMethod) {
+        super(file, enableDateParsing, compressionMethod);
+	}
 		
+	/**
+	 * {@inheritDoc}
+	 */
+	public void setSink(Sink sink) {
+		this.sink = sink;
+	}
 		
-		/**
-		 * {@inheritDoc}
-		 */
-		public void setSink(Sink sink) {
-			this.sink = sink;
-		}
-		
-				
-		
-		/**
-		 * Reads all data from the file and send it to the sink.
-		 */
-		public void run() {
-			InputStream inputStream = null;
-			FastXmlParser parser = null;
-			
-			try {
-				sink.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);
-				
-		        XMLInputFactory factory = XMLInputFactory.newInstance();
-		        factory.setProperty(XMLInputFactory.IS_COALESCING, false);
-		        factory.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, false);
-		        factory.setProperty(XMLInputFactory.IS_VALIDATING, false);
-		        XMLStreamReader xpp = factory.createXMLStreamReader(inputStream);
-				
-				parser = new FastXmlParser(sink, xpp, enableDateParsing);
-				
-				parser.readOsm();
-				
-				sink.complete();
-				
-			} catch (Exception e) {
-				throw new OsmosisRuntimeException("Unable to read XML file " + file + ".", e);
-			} finally {
-				sink.close();
-				
-				if (inputStream != null) {
-					try {
-						inputStream.close();
-					} catch (IOException e) {
-						log.log(Level.SEVERE, "Unable to close input stream.", e);
-					}
-					inputStream = null;
-				}
-			}
-		}
+	/**
+	 * Reads all data from the file and send it to the sink.
+	 */
+	public void run() {
+        try {
+            this.sink.initialize(Collections.emptyMap());
+            this.handleXML(null);
+            this.sink.complete();
+        } finally {
+            this.sink.close();
+        }
+	}
+
+    @Override
+    protected void parseXML(InputStream stream, DefaultHandler handler)
+                    throws SAXException, IOException {
+        try {
+            final XMLInputFactory factory = XMLInputFactory.newInstance();
+            factory.setProperty(XMLInputFactory.IS_COALESCING, false);
+            factory.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, false);
+            factory.setProperty(XMLInputFactory.IS_VALIDATING, false);
+            final XMLStreamReader xpp = factory.createXMLStreamReader(stream);
+
+            final FastXmlParser parser = new FastXmlParser(this.sink, xpp, this.isEnableDateParsing());
+            parser.readOsm();
+        } catch (final XMLStreamException e) {
+            throw new SAXException(e);
+        }
+    }
 }


=====================================
osmosis-xml/src/main/java/org/openstreetmap/osmosis/xml/v0_6/XmlChangeReader.java
=====================================
@@ -1,25 +1,15 @@
 // 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.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.BaseXMLReader;
 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
@@ -27,15 +17,8 @@ import java.util.logging.Logger;
  *
  * @author Brett Henderson
  */
-public class XmlChangeReader implements RunnableChangeSource {
-
-	private static Logger log = Logger.getLogger(XmlReader.class.getName());
-
+public class XmlChangeReader extends BaseXMLReader implements RunnableChangeSource {
 	private ChangeSink changeSink;
-	private File file;
-	private boolean enableDateParsing;
-	private CompressionMethod compressionMethod;
-
 
 	/**
 	 * Creates a new instance.
@@ -49,12 +32,9 @@ public class XmlChangeReader implements RunnableChangeSource {
 	 *            Specifies the compression method to employ.
 	 */
 	public XmlChangeReader(File file, boolean enableDateParsing, CompressionMethod compressionMethod) {
-		this.file = file;
-		this.enableDateParsing = enableDateParsing;
-		this.compressionMethod = compressionMethod;
+        super(file, enableDateParsing, compressionMethod);
 	}
 
-
 	/**
 	 * {@inheritDoc}
 	 */
@@ -62,58 +42,16 @@ public class XmlChangeReader implements RunnableChangeSource {
 		this.changeSink = changeSink;
 	}
 
-
 	/**
 	 * 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 = SaxParserFactory.createParser();
-
-			parser.parse(inputStream, new OsmChangeHandler(changeSink, enableDateParsing));
-
-			changeSink.complete();
-
-		} catch (SAXParseException e) {
-			throw new OsmosisRuntimeException(
-				"Unable to parse xml file " + file
-				+ ".  publicId=(" + e.getPublicId()
-				+ "), systemId=(" + e.getSystemId()
-				+ "), lineNumber=" + e.getLineNumber()
-				+ ", columnNumber=" + e.getColumnNumber() + ".",
-				e);
-		} catch (SAXException e) {
-			throw new OsmosisRuntimeException("Unable to parse XML.", e);
-		} catch (IOException e) {
-			throw new OsmosisRuntimeException("Unable to read XML file " + file + ".", e);
+            this.changeSink.initialize(Collections.emptyMap());
+            this.handleXML(new OsmChangeHandler(this.changeSink, this.isEnableDateParsing()));
+            this.changeSink.complete();    
 		} finally {
-			changeSink.close();
-
-			if (inputStream != null) {
-				try {
-					inputStream.close();
-				} catch (IOException e) {
-					log.log(Level.SEVERE, "Unable to close input stream.", e);
-				}
-				inputStream = null;
-			}
-		}
+            this.changeSink.close();
+        }
 	}
 }


=====================================
osmosis-xml/src/main/java/org/openstreetmap/osmosis/xml/v0_6/XmlReader.java
=====================================
@@ -1,24 +1,15 @@
 // 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.BaseXMLReader;
 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;
-import java.io.InputStream;
 import java.util.Collections;
-import java.util.logging.Level;
-import java.util.logging.Logger;
 
 
 /**
@@ -27,15 +18,8 @@ import java.util.logging.Logger;
  * 
  * @author Brett Henderson
  */
-public class XmlReader implements RunnableSource {
-	
-	private static Logger log = Logger.getLogger(XmlReader.class.getName());
-	
+public class XmlReader extends BaseXMLReader implements RunnableSource {
 	private Sink sink;
-	private File file;
-	private boolean enableDateParsing;
-	private CompressionMethod compressionMethod;
-	
 	
 	/**
 	 * Creates a new instance.
@@ -49,12 +33,9 @@ public class XmlReader implements RunnableSource {
 	 *            Specifies the compression method to employ.
 	 */
 	public XmlReader(File file, boolean enableDateParsing, CompressionMethod compressionMethod) {
-		this.file = file;
-		this.enableDateParsing = enableDateParsing;
-		this.compressionMethod = compressionMethod;
+        super(file, enableDateParsing, compressionMethod);
 	}
 	
-	
 	/**
 	 * {@inheritDoc}
 	 */
@@ -62,58 +43,16 @@ public class XmlReader implements RunnableSource {
 		this.sink = sink;
 	}
 	
-	
 	/**
 	 * Reads all data from the file and send it to the sink.
 	 */
 	public void run() {
-		InputStream inputStream = null;
-		
 		try {
-			SAXParser parser;
-			
-			sink.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 = SaxParserFactory.createParser();
-			
-			parser.parse(inputStream, new OsmHandler(sink, enableDateParsing));
-			
-			sink.complete();
-			
-		} catch (SAXParseException e) {
-			throw new OsmosisRuntimeException(
-				"Unable to parse xml file " + file
-				+ ".  publicId=(" + e.getPublicId()
-				+ "), systemId=(" + e.getSystemId()
-				+ "), lineNumber=" + e.getLineNumber()
-				+ ", columnNumber=" + e.getColumnNumber() + ".",
-				e);
-		} catch (SAXException e) {
-			throw new OsmosisRuntimeException("Unable to parse XML.", e);
-		} catch (IOException e) {
-			throw new OsmosisRuntimeException("Unable to read XML file " + file + ".", e);
+            this.sink.initialize(Collections.emptyMap());
+            this.handleXML(new OsmHandler(this.sink, this.isEnableDateParsing()));
+            this.sink.complete();
 		} finally {
-			sink.close();
-			
-			if (inputStream != null) {
-				try {
-					inputStream.close();
-				} catch (IOException e) {
-					log.log(Level.SEVERE, "Unable to close input stream.", e);
-				}
-				inputStream = null;
-			}
+            this.sink.close();
 		}
 	}
 }


=====================================
osmosis-xml/src/main/java/org/openstreetmap/osmosis/xml/v0_6/impl/BaseXMLReader.java
=====================================
@@ -0,0 +1,140 @@
+// This software is released into the Public Domain.  See copying.txt for details.
+package org.openstreetmap.osmosis.xml.v0_6.impl;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.zip.GZIPInputStream;
+
+import javax.xml.parsers.SAXParser;
+
+import org.openstreetmap.osmosis.core.OsmosisRuntimeException;
+import org.openstreetmap.osmosis.xml.common.CompressionActivator;
+import org.openstreetmap.osmosis.xml.common.CompressionMethod;
+import org.openstreetmap.osmosis.xml.common.SaxParserFactory;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+import org.xml.sax.helpers.DefaultHandler;
+
+ /**
+ * Handles common functionality used by XML readers.
+ *
+ * @author mcuthbert
+ */
+public abstract class BaseXMLReader {
+    private final File file;
+    private final boolean enableDateParsing;
+    private final CompressionMethod method;
+
+     /**
+     * Default Constructor.
+     *
+     * @param file File to parse
+     * @param enableDateParsing whether to enable date parsing or not
+     * @param method The compression method if any
+     */
+    public BaseXMLReader(final File file, final boolean enableDateParsing, final CompressionMethod method) {
+        this.file = file;
+        this.enableDateParsing = enableDateParsing;
+        this.method = method;
+    }
+
+     /**
+     * Returns whether this object enables date parsing or not.
+     *
+     * @return true or false
+     */
+    public boolean isEnableDateParsing() {
+        return this.enableDateParsing;
+    }
+
+     /**
+     * Function to parse xml, this default function just uses the SAXParser.
+     *
+     * @param stream InputStream for the XML
+     * @param handler A handler for the XML
+     * @throws SAXException If there is any exceptions while parsing the XML
+     * @throws IOException If there is any issues with the input stream
+     */
+    protected void parseXML(final InputStream stream, final DefaultHandler handler)
+            throws SAXException, IOException {
+        final SAXParser parser = SaxParserFactory.createParser();
+        parser.parse(stream, handler);
+    }
+
+     /**
+     * Function to handle the XML for the sub classes.
+     *
+     * @param handler A {@link DefaultHandler}
+     */
+    protected void handleXML(final DefaultHandler handler) {
+        try (InputStream stream = this.getInputStream()) {
+            try (InputStream compressionStream = new CompressionActivator(this.method)
+                    .createCompressionInputStream(stream)) {
+                this.parseXML(compressionStream, handler);
+            }
+        } catch (final SAXParseException e) {
+            // if we get a sax parse failure, there is a good chance it may be this one:
+            // Caused by: org.xml.sax.SAXParseException;
+            // lineNumber: ?; columnNumber: ?; Invalid byte 2 of 4-byte UTF-8 sequence.
+            // This can be solved by unzipping the contents to a temporary file and then parsing from there.
+            this.unzipParse(handler);
+        } catch (SAXException e) {
+            throw new OsmosisRuntimeException("Unable to parse XML.", e);
+        } catch (IOException e) {
+            throw new OsmosisRuntimeException("Unable to read XML file " + this.file + ".", e);
+        }
+    }
+
+     private void unzipParse(final DefaultHandler handler) {
+        File tempFile;
+        try {
+            tempFile = File.createTempFile(this.getTempFilePrefix(), null);
+        } catch (final IOException e) {
+            throw new OsmosisRuntimeException("Failed to create temporary file.", e);
+        }
+
+         try (InputStream fis = this.getInputStream();
+                GZIPInputStream gzipStream = new GZIPInputStream(fis);
+                FileOutputStream fos = new FileOutputStream(tempFile)) {
+            final byte[] buffer = new byte[1024];
+            int length;
+            while ((length = gzipStream.read(buffer)) > 0) {
+                fos.write(buffer, 0, length);
+            }
+        } catch (IOException e) {
+            throw new OsmosisRuntimeException("Unable to unzip gz file " + this.file + ".", e);
+        }
+
+         try (InputStream unzippedStream = new FileInputStream(tempFile)) {
+            this.parseXML(unzippedStream, handler);
+        } catch (final SAXParseException e) {
+            throw new OsmosisRuntimeException(
+                "Unable to parse xml file " + this.file
+                        + ".  publicId=(" + e.getPublicId()
+                        + "), systemId=(" + e.getSystemId()
+                        + "), lineNumber=" + e.getLineNumber()
+                        + ", columnNumber=" + e.getColumnNumber() + ".",
+                e);
+        } catch (SAXException e) {
+            throw new OsmosisRuntimeException("Unable to parse XML.", e);
+        } catch (IOException e) {
+            throw new OsmosisRuntimeException("Unable to read XML file " + this.file + ".", e);
+        }
+    }
+
+     private InputStream getInputStream() throws FileNotFoundException {
+        if (this.file.getName().equals("-")) {
+            return System.in;
+        } else {
+            return new FileInputStream(this.file);
+        }
+    }
+
+     private String getTempFilePrefix() {
+        return this.file.getName() + "_" + System.currentTimeMillis();
+    }
+}


=====================================
package/changes.txt
=====================================
@@ -1,3 +1,6 @@
+0.47.4 (2020-04-07)
+Refactored with BaseXMLReader and WorkingTaskManagerFactory classes (#60)
+
 0.47.3 (2020-03-24)
 Updated protobuf package to 3.11.4 (#58)
 Replaced custom MultiMemberGZIPInputStream with java.util.zip.GZIPInputStream (#59)



View it on GitLab: https://salsa.debian.org/debian-gis-team/osmosis/-/compare/0c23ccf1c69d985dc987cfd449d9b80a0ee1100a...3af7b7398bc6bc01308ca956dc850f2ff1ad3e54

-- 
View it on GitLab: https://salsa.debian.org/debian-gis-team/osmosis/-/compare/0c23ccf1c69d985dc987cfd449d9b80a0ee1100a...3af7b7398bc6bc01308ca956dc850f2ff1ad3e54
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-grass-devel/attachments/20200413/96566285/attachment-0001.html>


More information about the Pkg-grass-devel mailing list