Package org.openstreetmap.josm.io
Class OsmServerWriter
java.lang.Object
org.openstreetmap.josm.io.OsmServerWriter
Class that uploads all changes to the osm server.
This is done like this: - All objects with id = 0 are uploaded as new, except
those in deleted, which are ignored - All objects in deleted list are
deleted. - All remaining objects with modified flag set are updated.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final OsmApiprivate booleanprivate static List<OsmServerWritePostprocessor>private Collection<OsmPrimitive>This list contains all successfully processed objects.private long -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcancel()Cancel operation.voidCalls all registered upload postprocessors.Replies the collection of successfully processed primitives(package private) voidmakeApiRequest(OsmPrimitive osm, ProgressMonitor progressMonitor) static voidRegisters a post-processor.protected StringtimeLeft(int progress, int listSize) static voidUnregisters a post-processor.protected voiduploadChangesAsDiffUpload(Collection<? extends OsmPrimitive> primitives, ProgressMonitor progressMonitor) Upload all changes in one diff uploadprotected voiduploadChangesInChunks(Collection<? extends OsmPrimitive> primitives, ProgressMonitor progressMonitor, int chunkSize) Upload all changes in one diff uploadprotected voiduploadChangesIndividually(Collection<? extends OsmPrimitive> primitives, ProgressMonitor progressMonitor) Uploads the changes individually.voiduploadOsm(UploadStrategySpecification strategy, Collection<? extends OsmPrimitive> primitives, Changeset changeset, ProgressMonitor monitor) Send the dataset to the server.
-
Field Details
-
processed
This list contains all successfully processed objects. The caller of upload* has to check this after the call and update its dataset. If a server connection error occurs, this may contain fewer entries than where passed in the list to upload*. -
postprocessors
-
api
-
canceled
-
uploadStartTime
-
-
Constructor Details
-
OsmServerWriter
public OsmServerWriter()
-
-
Method Details
-
registerPostprocessor
Registers a post-processor.- Parameters:
pp- post-processor to register
-
unregisterPostprocessor
Unregisters a post-processor.- Parameters:
pp- post-processor to unregister
-
timeLeft
-
uploadChangesIndividually
protected void uploadChangesIndividually(Collection<? extends OsmPrimitive> primitives, ProgressMonitor progressMonitor) throws OsmTransferException Uploads the changes individually. Invokes one API call per uploaded primitive.- Parameters:
primitives- the collection of primitives to uploadprogressMonitor- the progress monitor- Throws:
OsmTransferException- if an exception occurs
-
uploadChangesAsDiffUpload
protected void uploadChangesAsDiffUpload(Collection<? extends OsmPrimitive> primitives, ProgressMonitor progressMonitor) throws OsmTransferException Upload all changes in one diff upload- Parameters:
primitives- the collection of primitives to uploadprogressMonitor- the progress monitor- Throws:
OsmTransferException- if an exception occurs
-
uploadChangesInChunks
protected void uploadChangesInChunks(Collection<? extends OsmPrimitive> primitives, ProgressMonitor progressMonitor, int chunkSize) throws OsmTransferException Upload all changes in one diff upload- Parameters:
primitives- the collection of primitives to uploadprogressMonitor- the progress monitorchunkSize- the size of the individual upload chunks. > 0 required.- Throws:
IllegalArgumentException- if chunkSize <= 0OsmTransferException- if an exception occurs
-
uploadOsm
public void uploadOsm(UploadStrategySpecification strategy, Collection<? extends OsmPrimitive> primitives, Changeset changeset, ProgressMonitor monitor) throws OsmTransferException Send the dataset to the server.- Parameters:
strategy- the upload strategy. Must not be null.primitives- list of objects to sendchangeset- the changeset the data is uploaded to. Must not be null.monitor- the progress monitor. If null, assumesNullProgressMonitor.INSTANCE- Throws:
IllegalArgumentException- if changeset is nullIllegalArgumentException- if strategy is nullOsmTransferException- if something goes wrong
-
makeApiRequest
- Throws:
OsmTransferException
-
cancel
Cancel operation. -
getProcessedPrimitives
Replies the collection of successfully processed primitives- Returns:
- the collection of successfully processed primitives
-
executePostprocessors
Calls all registered upload postprocessors.- Parameters:
pm- progress monitor
-