Package org.openstreetmap.josm.gui.io
Class UploadLayerTask
- java.lang.Object
-
- org.openstreetmap.josm.gui.io.AbstractIOTask
-
- org.openstreetmap.josm.gui.io.UploadLayerTask
-
- All Implemented Interfaces:
Runnable
public class UploadLayerTask extends AbstractIOTask
UploadLayerTask uploads the data managed by anOsmDataLayer
asynchronously.ExecutorService executorService = ... UploadLayerTask task = new UploadLayerTask(layer, monitor); Future<?> taskFuture = executorService.submit(task) try { // wait for the task to complete taskFuture.get(); } catch (Exception e) { e.printStackTrace(); }
-
-
Field Summary
Fields Modifier and Type Field Description private Changeset
changeset
private OsmDataLayer
layer
private ProgressMonitor
monitor
private Set<IPrimitive>
processedPrimitives
private UploadStrategySpecification
strategy
private Collection<OsmPrimitive>
toUpload
private OsmServerWriter
writer
-
Constructor Summary
Constructors Constructor Description UploadLayerTask(UploadStrategySpecification strategy, OsmDataLayer layer, ProgressMonitor monitor, Changeset changeset)
Creates the upload task
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
cancel()
Cancel the taskprotected OsmPrimitive
getPrimitive(OsmPrimitiveType type, long id)
protected void
recoverFromGoneOnServer(OsmApiPrimitiveGoneException e)
Retries to recover the upload operation from an exception which was thrown because an uploaded primitive was already deleted on the server.void
run()
-
Methods inherited from class org.openstreetmap.josm.gui.io.AbstractIOTask
getLastException, isCanceled, isFailed, isSuccessful, setCanceled, setFailed, setLastException
-
-
-
-
Field Detail
-
writer
private OsmServerWriter writer
-
layer
private final OsmDataLayer layer
-
monitor
private final ProgressMonitor monitor
-
toUpload
private Collection<OsmPrimitive> toUpload
-
processedPrimitives
private final Set<IPrimitive> processedPrimitives
-
strategy
private final UploadStrategySpecification strategy
-
-
Constructor Detail
-
UploadLayerTask
public UploadLayerTask(UploadStrategySpecification strategy, OsmDataLayer layer, ProgressMonitor monitor, Changeset changeset)
Creates the upload task- Parameters:
strategy
- the upload strategy specificationlayer
- the layer. Must not be null.monitor
- a progress monitor. If monitor is null, usesNullProgressMonitor.INSTANCE
changeset
- the changeset to be used- Throws:
IllegalArgumentException
- if layer is nullIllegalArgumentException
- if strategy is null
-
-
Method Detail
-
getPrimitive
protected OsmPrimitive getPrimitive(OsmPrimitiveType type, long id)
-
recoverFromGoneOnServer
protected void recoverFromGoneOnServer(OsmApiPrimitiveGoneException e) throws OsmTransferException
Retries to recover the upload operation from an exception which was thrown because an uploaded primitive was already deleted on the server.- Parameters:
e
- the exception throw by the API- Throws:
OsmTransferException
- if we can't recover from the exception
-
run
public void run()
-
cancel
public void cancel()
Description copied from class:AbstractIOTask
Cancel the task- Specified by:
cancel
in classAbstractIOTask
-
-