Changeset 2569 in josm for trunk/src/org/openstreetmap/josm/io/OsmApi.java
- Timestamp:
- 2009-12-04T15:53:55+01:00 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/io/OsmApi.java
r2512 r2569 145 145 146 146 /** 147 * Returns true if the negotiated version supports diff uploads.148 * @return true if the negotiated version supports diff uploads149 */150 public boolean hasSupportForDiffUploads() {151 return ((version != null) && (version.compareTo("0.6")>=0));152 }153 154 /**155 147 * Initializes this component by negotiating a protocol version with the server. 156 148 * … … 168 160 if (capabilities.supportsVersion("0.6")) { 169 161 version = "0.6"; 170 } else if (capabilities.supportsVersion("0.5")) {171 version = "0.5";172 162 } else { 173 163 System.err.println(tr("This version of JOSM is incompatible with the configured server.")); 174 System.err.println(tr("It supports protocol version s 0.5 and0.6, while the server says it supports {0} to {1}.",164 System.err.println(tr("It supports protocol version 0.6, while the server says it supports {0} to {1}.", 175 165 capabilities.get("version", "minimum"), capabilities.get("version", "maximum"))); 176 166 initialized = false; … … 256 246 257 247 /** 258 * Modifies an OSM primitive on the server. For protocols greater than 0.5, 259 * the OsmPrimitive object passed in is modified by giving it the server-assigned 260 * version. 261 * 262 * @param osm the primitive. Must not be null 248 * Modifies an OSM primitive on the server. 249 * 250 * @param osm the primitive. Must not be null. 251 * @param monitor the progress monitor 263 252 * @throws OsmTransferException if something goes wrong 264 253 */ … … 268 257 ensureValidChangeset(); 269 258 initialize(monitor); 270 if (version.equals("0.5")) { 271 // legacy mode does not return the new object version. 272 sendRequest("PUT", OsmPrimitiveType.from(osm).getAPIName()+"/" + osm.getId(), toXml(osm, true),monitor); 273 } else { 274 // normal mode (0.6 and up) returns new object version. 275 ret = sendRequest("PUT", OsmPrimitiveType.from(osm).getAPIName()+"/" + osm.getId(), toXml(osm, true), monitor); 276 osm.setOsmId(osm.getId(), Integer.parseInt(ret.trim())); 277 } 259 // normal mode (0.6 and up) returns new object version. 260 ret = sendRequest("PUT", OsmPrimitiveType.from(osm).getAPIName()+"/" + osm.getId(), toXml(osm, true), monitor); 261 osm.setOsmId(osm.getId(), Integer.parseInt(ret.trim())); 278 262 } catch(NumberFormatException e) { 279 263 throw new OsmTransferException(tr("Unexpected format of new version of modified primitive ''{0}''. Got ''{1}''.", osm.getId(), ret)); … … 359 343 ); 360 344 } catch(OsmApiException e) { 361 if (e.getResponseCode() == HttpURLConnection.HTTP_CONFLICT )362 throw new ChangesetClosedException(e.getErrorHeader() );345 if (e.getResponseCode() == HttpURLConnection.HTTP_CONFLICT && ChangesetClosedException.errorHeaderMatchesPattern(e.getErrorHeader())) 346 throw new ChangesetClosedException(e.getErrorHeader(), ChangesetClosedException.Source.UPDATE_CHANGESET); 363 347 throw e; 364 348 } finally { … … 569 553 case HttpURLConnection.HTTP_GONE: 570 554 throw new OsmApiPrimitiveGoneException(errorHeader, errorBody); 555 case HttpURLConnection.HTTP_CONFLICT: 556 if (ChangesetClosedException.errorHeaderMatchesPattern(errorHeader)) 557 throw new ChangesetClosedException(errorBody, ChangesetClosedException.Source.UPLOAD_DATA); 558 else 559 throw new OsmApiException(retCode, errorHeader, errorBody); 571 560 default: 572 561 throw new OsmApiException(retCode, errorHeader, errorBody); … … 642 631 this.changeset = changeset; 643 632 } 644 645 633 }
Note:
See TracChangeset
for help on using the changeset viewer.