org.openstreetmap.josm.gui.io
Class UploadLayerTask

java.lang.Object
  extended by org.openstreetmap.josm.gui.io.AbstractIOTask
      extended by org.openstreetmap.josm.gui.io.UploadLayerTask
All Implemented Interfaces:
java.lang.Runnable

 class UploadLayerTask
extends AbstractIOTask
implements java.lang.Runnable

UploadLayerTask uploads the data managed by an OsmDataLayer asynchronously.

     ExecutorService executorService = ...
     UploadLayerTask task = new UploadLayerTask(layer, monitor);
     Future taskFuture = executorServce.submit(task)
     try {
        // wait for the task to complete
        taskFuture.get();
     } catch(Exception e) {
        e.printStackTracek();
     }
 


Field Summary
private  Changeset changeset
           
private  OsmDataLayer layer
           
private  ProgressMonitor monitor
           
private  java.util.HashSet<IPrimitive> processedPrimitives
           
private  UploadStrategySpecification strategy
           
private  java.util.Collection<OsmPrimitive> toUpload
           
private  OsmServerWriter writer
           
 
Constructor Summary
UploadLayerTask(UploadStrategySpecification strategy, OsmDataLayer layer, ProgressMonitor monitor, Changeset changeset)
          Creates the upload task
 
Method Summary
 void cancel()
          Cancel the task
protected  OsmPrimitive getPrimitive(OsmPrimitiveType type, long id)
           
protected  void recoverFromGoneOnServer(OsmApiPrimitiveGoneException e, ProgressMonitor monitor)
          Retries to recover the upload operation from an exception which was thrown because an uploaded primitive was already deleted on the server.
 void run()
          Runs the task
 
Methods inherited from class org.openstreetmap.josm.gui.io.AbstractIOTask
getLastException, isCanceled, isFailed, isSuccessful, setCanceled, setFailed, setLastException
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

writer

private OsmServerWriter writer

layer

private OsmDataLayer layer

monitor

private ProgressMonitor monitor

changeset

private Changeset changeset

toUpload

private java.util.Collection<OsmPrimitive> toUpload

processedPrimitives

private java.util.HashSet<IPrimitive> processedPrimitives

strategy

private UploadStrategySpecification strategy
Constructor Detail

UploadLayerTask

public UploadLayerTask(UploadStrategySpecification strategy,
                       OsmDataLayer layer,
                       ProgressMonitor monitor,
                       Changeset changeset)
Creates the upload task

Parameters:
strategy - the upload strategy specification
layer - the layer. Must not be null.
monitor - a progress monitor. If monitor is null, uses NullProgressMonitor.INSTANCE
changeset - the changeset to be used
Throws:
java.lang.IllegalArgumentException - thrown, if layer is null
java.lang.IllegalArgumentException - thrown if strategy is null
Method Detail

getPrimitive

protected OsmPrimitive getPrimitive(OsmPrimitiveType type,
                                    long id)

recoverFromGoneOnServer

protected void recoverFromGoneOnServer(OsmApiPrimitiveGoneException e,
                                       ProgressMonitor monitor)
                                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
monitor - a progress monitor
Throws:
OsmTransferException - thrown if we can't recover from the exception

run

public void run()
Description copied from class: AbstractIOTask
Runs the task

Specified by:
run in interface java.lang.Runnable
Specified by:
run in class AbstractIOTask

cancel

public void cancel()
Description copied from class: AbstractIOTask
Cancel the task

Specified by:
cancel in class AbstractIOTask


JOSM