Example #1
0
 /**
  * Retries to recover the upload operation from an exception which was thrown because an uploaded
  * primitive was already deleted on the server.
  *
  * @param e the exception throw by the API
  * @param monitor a progress monitor
  * @throws OsmTransferException thrown if we can't recover from the exception
  */
 protected void recoverFromGoneOnServer(OsmApiPrimitiveGoneException e, ProgressMonitor monitor)
     throws OsmTransferException {
   if (!e.isKnownPrimitive()) throw e;
   OsmPrimitive p = layer.data.getPrimitiveById(e.getPrimitiveId(), e.getPrimitiveType());
   if (p == null) throw e;
   if (p.isDeleted()) {
     // we tried to delete an already deleted primitive.
     //
     System.out.println(
         tr(
             "Warning: object ''{0}'' is already deleted on the server. Skipping this object and retrying to upload.",
             p.getDisplayName(DefaultNameFormatter.getInstance())));
     monitor.appendLogMessage(
         tr(
             "Object ''{0}'' is already deleted. Skipping object in upload.",
             p.getDisplayName(DefaultNameFormatter.getInstance())));
     processedPrimitives.addAll(writer.getProcessedPrimitives());
     processedPrimitives.add(p);
     toUpload.removeProcessed(processedPrimitives);
     return;
   }
   // exception was thrown because we tried to *update* an already deleted
   // primitive. We can't resolve this automatically. Re-throw exception,
   // a conflict is going to be created later.
   throw e;
 }
 /**
  * Retries to recover the upload operation from an exception which was thrown because an uploaded
  * primitive was already deleted on the server.
  *
  * @param e the exception throw by the API
  * @param monitor a progress monitor
  * @throws OsmTransferException if we can't recover from the exception
  */
 protected void recoverFromGoneOnServer(OsmApiPrimitiveGoneException e, ProgressMonitor monitor)
     throws OsmTransferException {
   if (!e.isKnownPrimitive()) throw e;
   OsmPrimitive p = layer.data.getPrimitiveById(e.getPrimitiveId(), e.getPrimitiveType());
   if (p == null) throw e;
   if (p.isDeleted()) {
     // we tried to delete an already deleted primitive.
     final String msg;
     final String displayName = p.getDisplayName(DefaultNameFormatter.getInstance());
     if (p instanceof Node) {
       msg = tr("Node ''{0}'' is already deleted. Skipping object in upload.", displayName);
     } else if (p instanceof Way) {
       msg = tr("Way ''{0}'' is already deleted. Skipping object in upload.", displayName);
     } else if (p instanceof Relation) {
       msg = tr("Relation ''{0}'' is already deleted. Skipping object in upload.", displayName);
     } else {
       msg = tr("Object ''{0}'' is already deleted. Skipping object in upload.", displayName);
     }
     monitor.appendLogMessage(msg);
     Main.warn(msg);
     processedPrimitives.addAll(writer.getProcessedPrimitives());
     processedPrimitives.add(p);
     toUpload.removeProcessed(processedPrimitives);
     return;
   }
   // exception was thrown because we tried to *update* an already deleted
   // primitive. We can't resolve this automatically. Re-throw exception,
   // a conflict is going to be created later.
   throw e;
 }