org.openstreetmap.josm.gui.io
Class UploadPrimitivesTask

java.lang.Object
  extended by org.openstreetmap.josm.gui.PleaseWaitRunnable
      extended by org.openstreetmap.josm.gui.io.AbstractUploadTask
          extended by org.openstreetmap.josm.gui.io.UploadPrimitivesTask
All Implemented Interfaces:
java.lang.Runnable, ProgressMonitor.CancelListener

public class UploadPrimitivesTask
extends AbstractUploadTask

The task for uploading a collection of primitives


Field Summary
private  Changeset changeset
           
private  java.lang.Exception lastException
           
private  OsmDataLayer layer
           
private  java.util.HashSet<IPrimitive> processedPrimitives
           
private  UploadStrategySpecification strategy
           
private  APIDataSet toUpload
           
private  boolean uploadCanceled
           
private  OsmServerWriter writer
           
 
Fields inherited from class org.openstreetmap.josm.gui.PleaseWaitRunnable
progressMonitor
 
Constructor Summary
UploadPrimitivesTask(UploadStrategySpecification strategy, OsmDataLayer layer, APIDataSet toUpload, Changeset changeset)
          Creates the task
 
Method Summary
protected  MaxChangesetSizeExceededPolicy askMaxChangesetSizeExceedsPolicy()
           
protected  void cancel()
          User pressed cancel button.
protected  void cleanupAfterUpload()
           
protected  void finish()
          Finish up the data work.
protected  void openNewChangeset()
           
protected  void realRun()
          Called in the worker thread to do the actual work.
protected  boolean recoverFromChangesetFullException()
           
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.
 
Methods inherited from class org.openstreetmap.josm.gui.io.AbstractUploadTask
handleFailedUpload, handleGone, handlePreconditionFailed, handleUploadConflict, handleUploadConflictForClosedChangeset, handleUploadConflictForKnownConflict, handleUploadConflictForUnknownConflict, handleUploadPreconditionFailedConflict, synchronizeDataSet, synchronizePrimitive
 
Methods inherited from class org.openstreetmap.josm.gui.PleaseWaitRunnable
afterFinish, canRunInBackground, getProgressMonitor, operationCanceled, run
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

uploadCanceled

private boolean uploadCanceled

lastException

private java.lang.Exception lastException

toUpload

private APIDataSet toUpload

writer

private OsmServerWriter writer

layer

private OsmDataLayer layer

changeset

private Changeset changeset

processedPrimitives

private java.util.HashSet<IPrimitive> processedPrimitives

strategy

private UploadStrategySpecification strategy
Constructor Detail

UploadPrimitivesTask

public UploadPrimitivesTask(UploadStrategySpecification strategy,
                            OsmDataLayer layer,
                            APIDataSet toUpload,
                            Changeset changeset)
Creates the task

Parameters:
strategy - the upload strategy. Must not be null.
layer - the OSM data layer for which data is uploaded. Must not be null.
toUpload - the collection of primitives to upload. Set to the empty collection if null.
changeset - the changeset to use for uploading. Must not be null. changeset.getId() can be 0 in which case the upload task creates a new changeset
Throws:
java.lang.IllegalArgumentException - thrown if layer is null
java.lang.IllegalArgumentException - thrown if toUpload is null
java.lang.IllegalArgumentException - thrown if strategy is null
java.lang.IllegalArgumentException - thrown if changeset is null
Method Detail

askMaxChangesetSizeExceedsPolicy

protected MaxChangesetSizeExceededPolicy askMaxChangesetSizeExceedsPolicy()

openNewChangeset

protected void openNewChangeset()

recoverFromChangesetFullException

protected boolean recoverFromChangesetFullException()

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

cleanupAfterUpload

protected void cleanupAfterUpload()

realRun

protected void realRun()
                throws org.xml.sax.SAXException,
                       java.io.IOException
Description copied from class: PleaseWaitRunnable
Called in the worker thread to do the actual work. When any of the exception is thrown, a message box will be displayed and closeDialog is called. finish() is called in any case.

Specified by:
realRun in class PleaseWaitRunnable
Throws:
org.xml.sax.SAXException
java.io.IOException

finish

protected void finish()
Description copied from class: PleaseWaitRunnable
Finish up the data work. Is guaranteed to be called if realRun is called. Finish is called in the gui thread just after the dialog disappeared.

Specified by:
finish in class PleaseWaitRunnable

cancel

protected void cancel()
Description copied from class: PleaseWaitRunnable
User pressed cancel button.

Specified by:
cancel in class PleaseWaitRunnable


JOSM