Package org.openstreetmap.josm.gui.io
Class AbstractUploadTask
- java.lang.Object
-
- org.openstreetmap.josm.gui.PleaseWaitRunnable
-
- org.openstreetmap.josm.gui.io.AbstractUploadTask
-
- All Implemented Interfaces:
java.lang.Runnable,ProgressMonitor.CancelListener
- Direct Known Subclasses:
UploadPrimitivesTask
public abstract class AbstractUploadTask extends PleaseWaitRunnable
Abstract base class for the task of uploading primitives via OSM API.Mainly handles conflicts and certain error situations.
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.StringCANCELprivate static java.lang.StringCANCEL_TRprivate static java.lang.StringUPDATE_DATA-
Fields inherited from class org.openstreetmap.josm.gui.PleaseWaitRunnable
progressMonitor
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractUploadTask(java.lang.String title)Constructs a newAbstractUploadTask.protectedAbstractUploadTask(java.lang.String title, boolean ignoreException)Constructs a newAbstractUploadTask.protectedAbstractUploadTask(java.lang.String title, ProgressMonitor progressMonitor, boolean ignoreException)Constructs a newAbstractUploadTask.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidhandleFailedUpload(java.lang.Exception e)error handler for any exception thrown during uploadprotected voidhandleGone(OsmApiPrimitiveGoneException e)Handles an error which is caused by a delete request for an already deletedOsmPrimitiveon the server, i.e.protected voidhandlePreconditionFailed(OsmApiException e)handles an precondition failed conflict, i.e.protected voidhandleUploadConflict(OsmApiException e)handles an upload conflict, i.e.protected voidhandleUploadConflictForClosedChangeset(long changesetId, java.time.Instant d)Handles the case that a conflict was detected while uploading where we don't know whatOsmPrimitiveactually caused the conflict (for whatever reason)protected voidhandleUploadConflictForKnownConflict(OsmPrimitiveType primitiveType, long id, java.lang.String serverVersion, java.lang.String myVersion)Handles the case that a conflict in a specificOsmPrimitivewas detected while uploadingprotected voidhandleUploadConflictForUnknownConflict()Handles the case that a conflict was detected while uploading where we don't know whatOsmPrimitiveactually caused the conflict (for whatever reason)protected voidhandleUploadPreconditionFailedConflict(OsmApiException e, Pair<OsmPrimitive,java.util.Collection<OsmPrimitive>> conflict)Handles the case where deleting a node failed because it is still in use in a non-deleted way on the server.protected voidsynchronizeDataSet()Synchronizes the local state of the dataset with the state on the server.protected voidsynchronizePrimitive(OsmPrimitiveType type, long id)Synchronizes the local state of anOsmPrimitivewith its state on the server.-
Methods inherited from class org.openstreetmap.josm.gui.PleaseWaitRunnable
afterFinish, cancel, canRunInBackground, finish, getProgressMonitor, operationCanceled, realRun, run
-
-
-
-
Field Detail
-
CANCEL_TR
private static final java.lang.String CANCEL_TR
-
CANCEL
private static final java.lang.String CANCEL
- See Also:
- Constant Field Values
-
UPDATE_DATA
private static final java.lang.String UPDATE_DATA
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AbstractUploadTask
protected AbstractUploadTask(java.lang.String title, boolean ignoreException)
Constructs a newAbstractUploadTask.- Parameters:
title- message for the userignoreException- If true, exception will be silently ignored. If false then exception will be handled by showing a dialog. When this runnable is executed using executor framework then use false unless you read result of task (because exception will get lost if you don't)
-
AbstractUploadTask
protected AbstractUploadTask(java.lang.String title, ProgressMonitor progressMonitor, boolean ignoreException)
Constructs a newAbstractUploadTask.- Parameters:
title- message for the userprogressMonitor- progress monitorignoreException- If true, exception will be silently ignored. If false then exception will be handled by showing a dialog. When this runnable is executed using executor framework then use false unless you read result of task (because exception will get lost if you don't)
-
AbstractUploadTask
protected AbstractUploadTask(java.lang.String title)
Constructs a newAbstractUploadTask.- Parameters:
title- message for the user
-
-
Method Detail
-
synchronizePrimitive
protected void synchronizePrimitive(OsmPrimitiveType type, long id)
Synchronizes the local state of anOsmPrimitivewith its state on the server. The method uses an individual GET for the primitive.- Parameters:
type- the primitive typeid- the primitive ID
-
synchronizeDataSet
protected void synchronizeDataSet()
Synchronizes the local state of the dataset with the state on the server.Reuses the functionality of
UpdateDataAction.
-
handleUploadConflictForKnownConflict
protected void handleUploadConflictForKnownConflict(OsmPrimitiveType primitiveType, long id, java.lang.String serverVersion, java.lang.String myVersion)
Handles the case that a conflict in a specificOsmPrimitivewas detected while uploading- Parameters:
primitiveType- the type of the primitive, eithernode,wayorrelationid- the id of the primitiveserverVersion- the version of the primitive on the servermyVersion- the version of the primitive in the local dataset
-
handleUploadConflictForUnknownConflict
protected void handleUploadConflictForUnknownConflict()
Handles the case that a conflict was detected while uploading where we don't know whatOsmPrimitiveactually caused the conflict (for whatever reason)
-
handleUploadConflictForClosedChangeset
protected void handleUploadConflictForClosedChangeset(long changesetId, java.time.Instant d)
Handles the case that a conflict was detected while uploading where we don't know whatOsmPrimitiveactually caused the conflict (for whatever reason)- Parameters:
changesetId- changeset IDd- changeset date
-
handleUploadPreconditionFailedConflict
protected void handleUploadPreconditionFailedConflict(OsmApiException e, Pair<OsmPrimitive,java.util.Collection<OsmPrimitive>> conflict)
Handles the case where deleting a node failed because it is still in use in a non-deleted way on the server.- Parameters:
e- exceptionconflict- conflict
-
handleUploadConflict
protected void handleUploadConflict(OsmApiException e)
handles an upload conflict, i.e. an error indicated by a HTTP return code 409.- Parameters:
e- the exception
-
handlePreconditionFailed
protected void handlePreconditionFailed(OsmApiException e)
handles an precondition failed conflict, i.e. an error indicated by a HTTP return code 412.- Parameters:
e- the exception
-
handleGone
protected void handleGone(OsmApiPrimitiveGoneException e)
Handles an error which is caused by a delete request for an already deletedOsmPrimitiveon the server, i.e. a HTTP response code of 410. Note that an update on an already deleted object results in a 409, not a 410.- Parameters:
e- the exception
-
handleFailedUpload
protected void handleFailedUpload(java.lang.Exception e)
error handler for any exception thrown during upload- Parameters:
e- the exception
-
-