Package org.openstreetmap.josm.gui.io
Class UploadPrimitivesTask
java.lang.Object
org.openstreetmap.josm.gui.PleaseWaitRunnable
org.openstreetmap.josm.gui.io.AbstractUploadTask
org.openstreetmap.josm.gui.io.UploadPrimitivesTask
- All Implemented Interfaces:
Runnable,ProgressMonitor.CancelListener
- Direct Known Subclasses:
AsynchronousUploadPrimitivesTask
The task for uploading a collection of primitives.
- Since:
- 2599
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Changesetprivate Exceptionprivate final OsmDataLayerprivate final intInitial number of objects to be uploadedprivate final Set<IPrimitive>private final UploadStrategySpecificationprivate final APIDataSetThe objects to upload.private booleanprivate OsmServerWriterFields inherited from class org.openstreetmap.josm.gui.PleaseWaitRunnable
progressMonitor -
Constructor Summary
ConstructorsConstructorDescriptionUploadPrimitivesTask(UploadStrategySpecification strategy, OsmDataLayer layer, APIDataSet toUpload, Changeset changeset) Creates the task -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcancel()User pressed cancel button.protected voidprivate voidCloses the changeset on the server and locally.private voidprotected voidfinish()Depending on the success of the upload operation and on the policy for multi changeset uploads this will send the user back to the appropriate place in JOSM, either: to an error dialog, to the Upload Dialog, or to map editing.protected booleanHandles a server changeset full response.protected MaxChangesetSizeExceededPolicyPrompt the user about how to proceed.protected voidrealRun()Called in the worker thread to do the actual work.protected voidRetries 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, synchronizePrimitiveMethods inherited from class org.openstreetmap.josm.gui.PleaseWaitRunnable
afterFinish, canRunInBackground, getProgressMonitor, operationCanceled, run
-
Field Details
-
uploadCanceled
-
lastException
-
toUpload
The objects to upload. Successfully uploaded objects are removed. -
writer
-
layer
-
changeset
-
processedPrimitives
-
strategy
-
numObjectsToUpload
Initial number of objects to be uploaded
-
-
Constructor Details
-
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:
IllegalArgumentException- if layer is nullIllegalArgumentException- if toUpload is nullIllegalArgumentException- if strategy is nullIllegalArgumentException- if changeset is null
-
-
Method Details
-
promptUserForPolicy
Prompt the user about how to proceed.- Returns:
- the policy selected by the user
-
handleChangesetFullResponse
Handles a server changeset full response.Handles a server changeset full response by either aborting or opening a new changeset, if the user requested it so.
- Returns:
- true if the upload process should continue with the new changeset, false if the upload should be interrupted
- Throws:
OsmTransferException- "if something goes wrong."
-
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 APImonitor- a progress monitor- Throws:
OsmTransferException- if we can't recover from the exception
-
cleanupAfterUpload
-
realRun
Description copied from class:PleaseWaitRunnableCalled 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:
realRunin classPleaseWaitRunnable
-
closeChangeset
Closes the changeset on the server and locally.- Throws:
OsmTransferException- "if something goes wrong."
-
closeChangesetIfRequired
- Throws:
OsmTransferException
-
finish
Depending on the success of the upload operation and on the policy for multi changeset uploads this will send the user back to the appropriate place in JOSM, either:- to an error dialog,
- to the Upload Dialog, or
- to map editing.
- Specified by:
finishin classPleaseWaitRunnable
-
cancel
Description copied from class:PleaseWaitRunnableUser pressed cancel button.- Specified by:
cancelin classPleaseWaitRunnable
-