Changeset 11618 in josm for trunk/src/org
- Timestamp:
- 2017-02-25T19:59:42+01:00 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/io/UploadPrimitivesTask.java
r11535 r11618 40 40 /** 41 41 * The task for uploading a collection of primitives. 42 * 42 * @since 2599 43 43 */ 44 44 public class UploadPrimitivesTask extends AbstractUploadTask { … … 133 133 case 0: return MaxChangesetSizeExceededPolicy.AUTOMATICALLY_OPEN_NEW_CHANGESETS; 134 134 case 1: return MaxChangesetSizeExceededPolicy.FILL_ONE_CHANGESET_AND_RETURN_TO_UPLOAD_DIALOG; 135 case 2: return MaxChangesetSizeExceededPolicy.ABORT; 136 case JOptionPane.CLOSED_OPTION: return MaxChangesetSizeExceededPolicy.ABORT; 137 } 138 // should not happen 139 return null; 140 } 141 135 case 2: 136 case JOptionPane.CLOSED_OPTION: 137 default: return MaxChangesetSizeExceededPolicy.ABORT; 138 } 139 } 140 141 /** 142 * Opens a new changeset. 143 */ 142 144 protected void openNewChangeset() { 143 145 // make sure the current changeset is removed from the upload dialog. 144 //145 146 ChangesetCache.getInstance().update(changeset); 146 147 Changeset newChangeSet = new Changeset(); … … 149 150 } 150 151 151 protected boolean recoverFromChangesetFullException() {152 protected boolean recoverFromChangesetFullException() throws OsmTransferException { 152 153 if (toUpload.getSize() - processedPrimitives.size() == 0) { 153 154 strategy.setPolicy(MaxChangesetSizeExceededPolicy.ABORT); … … 155 156 } 156 157 if (strategy.getPolicy() == null || strategy.getPolicy().equals(MaxChangesetSizeExceededPolicy.ABORT)) { 157 MaxChangesetSizeExceededPolicy policy = askMaxChangesetSizeExceedsPolicy(); 158 strategy.setPolicy(policy); 158 strategy.setPolicy(askMaxChangesetSizeExceedsPolicy()); 159 159 } 160 160 switch(strategy.getPolicy()) { 161 case ABORT:162 // don't continue - finish() will send the user back to map editing163 //164 return false;165 case FILL_ONE_CHANGESET_AND_RETURN_TO_UPLOAD_DIALOG:166 // don't continue - finish() will send the user back to the upload dialog167 //168 return false;169 161 case AUTOMATICALLY_OPEN_NEW_CHANGESETS: 170 162 // prepare the state of the task for a next iteration in uploading. 171 //163 closeChangesetIfRequired(); 172 164 openNewChangeset(); 173 165 toUpload.removeProcessed(processedPrimitives); 174 166 return true; 175 } 176 // should not happen 177 return false; 167 case ABORT: 168 case FILL_ONE_CHANGESET_AND_RETURN_TO_UPLOAD_DIALOG: 169 default: 170 // don't continue - finish() will send the user back to map editing or upload dialog 171 return false; 172 } 178 173 } 179 174 … … 250 245 251 246 // if we get here we've successfully uploaded the data. Exit the loop. 252 //253 247 break; 254 248 } catch (OsmTransferCanceledException e) { … … 258 252 } catch (OsmApiPrimitiveGoneException e) { 259 253 // try to recover from 410 Gone 260 //261 254 recoverFromGoneOnServer(e, getProgressMonitor()); 262 255 } catch (ChangesetClosedException e) { … … 264 257 processedPrimitives.addAll(writer.getProcessedPrimitives()); // OsmPrimitive in => OsmPrimitive out 265 258 } 266 changeset.setOpen(false);267 259 switch(e.getSource()) { 268 case UNSPECIFIED:269 throw e;270 case UPDATE_CHANGESET:271 // The changeset was closed when we tried to update it. Probably, our272 // local list of open changesets got out of sync with the server state.273 // The user will have to select another open changeset.274 // Rethrow exception - this will be handled later.275 //276 throw e;277 260 case UPLOAD_DATA: 278 261 // Most likely the changeset is full. Try to recover and continue 279 262 // with a new changeset, but let the user decide first (see 280 263 // recoverFromChangesetFullException) 281 //282 264 if (recoverFromChangesetFullException()) { 283 265 continue; … … 285 267 lastException = e; 286 268 break uploadloop; 269 case UNSPECIFIED: 270 case UPDATE_CHANGESET: 271 default: 272 // The changeset was closed when we tried to update it. Probably, our 273 // local list of open changesets got out of sync with the server state. 274 // The user will have to select another open changeset. 275 // Rethrow exception - this will be handled later. 276 changeset.setOpen(false); 277 throw e; 287 278 } 288 279 } finally { … … 296 287 } 297 288 // if required close the changeset 298 // 299 if (strategy.isCloseChangesetAfterUpload() && changeset != null && !changeset.isNew() && changeset.isOpen()) { 300 OsmApi.getOsmApi().closeChangeset(changeset, progressMonitor.createSubTaskMonitor(0, false)); 301 } 289 closeChangesetIfRequired(); 302 290 } catch (OsmTransferException e) { 303 291 if (uploadCanceled) { … … 309 297 if (uploadCanceled && processedPrimitives.isEmpty()) return; 310 298 cleanupAfterUpload(); 299 } 300 301 private void closeChangesetIfRequired() throws OsmTransferException { 302 if (strategy.isCloseChangesetAfterUpload() && changeset != null && !changeset.isNew() && changeset.isOpen()) { 303 OsmApi.getOsmApi().closeChangeset(changeset, progressMonitor.createSubTaskMonitor(0, false)); 304 } 311 305 } 312 306
Note:
See TracChangeset
for help on using the changeset viewer.