Changeset 2074 in josm for trunk/src/org/openstreetmap/josm/io/OsmApi.java
- Timestamp:
- 2009-09-07T00:01:31+02:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/io/OsmApi.java
r2070 r2074 278 278 } 279 279 280 /** 281 * Creates the changeset to be used for subsequent uploads. 280 281 /** 282 * Creates a new changeset based on the keys in <code>changeset</code> 282 283 * 283 * If changesetProcessingType is {@see ChangesetProcessingType#USE_NEW} creates a new changeset based 284 * on <code>changeset</code>. Otherwise uses the changeset given by {@see OsmApi#getCurrentChangeset()}. 285 * If this changeset is null or has an id of value 0, a new changeset is created too. 286 * 287 * @param changeset the changeset to be used for uploading if <code>changesetProcessingType</code> is 288 * {@see ChangesetProcessingType#USE_NEW} 289 * @param changesetProcessingType how to handel changesets; set to {@see ChangesetProcessingType#USE_NEW} if null 284 * @param changeset the changeset to be used for uploading 290 285 * @param progressMonitor the progress monitor 291 286 * @throws OsmTransferException signifying a non-200 return code, or connection errors 292 287 */ 293 public void createChangeset(Changeset changeset, ChangesetProcessingType changesetProcessingType, ProgressMonitor progressMonitor) throws OsmTransferException { 294 if (changesetProcessingType == null) { 295 changesetProcessingType = ChangesetProcessingType.USE_NEW_AND_CLOSE; 296 } 288 public void createChangeset(Changeset changeset, ProgressMonitor progressMonitor) throws OsmTransferException { 297 289 try { 298 290 progressMonitor.beginTask((tr("Creating changeset..."))); 299 if (changesetProcessingType.isUseNew()) { 300 Properties sysProp = System.getProperties(); 301 Object ua = sysProp.get("http.agent"); 302 changeset.put("created_by", (ua == null) ? "JOSM" : ua.toString()); 303 createPrimitive(changeset, progressMonitor); 304 this.changeset = changeset; 305 progressMonitor.setCustomText((tr("Successfully opened changeset {0}",changeset.getId()))); 306 } else { 307 if (this.changeset == null || this.changeset.getId() == 0) { 308 progressMonitor.setCustomText((tr("No currently open changeset. Opening a new changeset..."))); 309 System.out.println(tr("Warning: could not reuse an existing changeset as requested. Opening a new one.")); 310 Properties sysProp = System.getProperties(); 311 Object ua = sysProp.get("http.agent"); 312 changeset.put("created_by", (ua == null) ? "JOSM" : ua.toString()); 313 createPrimitive(changeset, progressMonitor); 314 this.changeset = changeset; 315 progressMonitor.setCustomText((tr("Successfully opened changeset {0}",this.changeset.getId()))); 316 } else { 317 progressMonitor.setCustomText((tr("Reusing existing changeset {0}", this.changeset.getId()))); 318 } 319 } 291 createPrimitive(changeset, progressMonitor); 292 this.changeset = changeset; 293 progressMonitor.setCustomText((tr("Successfully opened changeset {0}",this.changeset.getId()))); 320 294 } finally { 321 295 progressMonitor.finishTask(); … … 324 298 325 299 /** 326 * Update a changeset on the server.327 * 328 * @param changeset the changeset to update300 * Updates the current changeset with the keys in <code>changesetUpdate</code>. 301 * 302 * @param changesetUpdate the changeset to update 329 303 * @param progressMonitor the progress monitor 330 304 * 331 305 * @throws OsmTransferException if something goes wrong. 332 306 */ 333 public void updateChangeset(Changeset changeset , ProgressMonitor progressMonitor) throws OsmTransferException {307 public void updateChangeset(Changeset changesetUpdate, ProgressMonitor progressMonitor) throws OsmTransferException { 334 308 try { 335 309 progressMonitor.beginTask(tr("Updating changeset...")); 336 310 initialize(progressMonitor); 337 311 if (this.changeset != null && this.changeset.getId() > 0) { 338 if (this.changeset.hasEqualSemanticAttributes(changeset )) {339 progressMonitor.setCustomText(tr("Changeset {0} is unchanged. Skipping update.", changeset .getId()));312 if (this.changeset.hasEqualSemanticAttributes(changesetUpdate)) { 313 progressMonitor.setCustomText(tr("Changeset {0} is unchanged. Skipping update.", changesetUpdate.getId())); 340 314 return; 341 315 } 342 this.changeset.setKeys(changeset .getKeys());343 progressMonitor.setCustomText(tr("Updating changeset {0}...", changeset.getId()));316 this.changeset.setKeys(changesetUpdate.getKeys()); 317 progressMonitor.setCustomText(tr("Updating changeset {0}...", this.changeset.getId())); 344 318 sendRequest( 345 319 "PUT", 346 OsmPrimitiveType.from(changeset ).getAPIName() + "/" +changeset.getId(),347 toXml( changeset, true),320 OsmPrimitiveType.from(changesetUpdate).getAPIName() + "/" + this.changeset.getId(), 321 toXml(this.changeset, true), 348 322 progressMonitor 349 323 ); 350 this.changeset = changeset;351 324 } else 352 325 throw new OsmTransferException(tr("Failed to update changeset. Either there is no current changeset or the id of the current changeset is 0"));
Note:
See TracChangeset
for help on using the changeset viewer.