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:
java.lang.Runnable
public class UploadLayerTask extends AbstractIOTask
UploadLayerTask uploads the data managed by anOsmDataLayerasynchronously.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 Changesetchangesetprivate OsmDataLayerlayerprivate ProgressMonitormonitorprivate java.util.Set<IPrimitive>processedPrimitivesprivate UploadStrategySpecificationstrategyprivate java.util.Collection<OsmPrimitive>toUploadprivate OsmServerWriterwriter
-
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 voidcancel()Cancel the taskprotected OsmPrimitivegetPrimitive(OsmPrimitiveType type, long id)protected voidrecoverFromGoneOnServer(OsmApiPrimitiveGoneException e)Retries to recover the upload operation from an exception which was thrown because an uploaded primitive was already deleted on the server.voidrun()-
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 java.util.Collection<OsmPrimitive> toUpload
-
processedPrimitives
private final java.util.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.INSTANCEchangeset- the changeset to be used- Throws:
java.lang.IllegalArgumentException- if layer is nulljava.lang.IllegalArgumentException- 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:AbstractIOTaskCancel the task- Specified by:
cancelin classAbstractIOTask
-
-