Modify

Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#7257 closed defect (fixed)

[Patch] Provide an option to automatically download elements after a reference error

Reported by: landwirt@… Owned by: team
Priority: normal Milestone:
Component: Core Version: latest
Keywords: Cc:

Description

If an upload fails because a deleted element (way or node) is still referred by another element, JOSM just shows a dialog with IDs and tells the user to manually load the element or elements, remove the references and upload again.
The user has to transcribe the numbers from the dialog, start Ctrl-Shift-O, enter the numbers there and then start download. Couldn't that be done automatically with a "Download now"-button next to the "Ok"-button?

Attachments (1)

7257.patch (30.3 KB) - added by simon04 8 years ago.

Download all attachments as: .zip

Change History (16)

comment:1 Changed 8 years ago by simon04

Type: enhancementdefect

In fact, This feature does already exist, but seems to be broken:

In case of a reference error, the error text returned by the server is something like

Precondition failed: Node 942963039 is still used by ways 80894467.

In AbstractUploadTask.handlePreconditionFailed (introduced in r2599) the following pattern is used to match such messages. Obviously, it does not match as the plural "s" of "ways" is missing. Thus, no help is provided for fixing this error.

Precondition failed: Node (\\d+) is still used by way (\\d+).

However, in ExceptionUtil.explainPreconditionFailed (introduced in r2246), again, a pattern is used to match this error message. In this case, the pattern is the following. It matches "ways" instead of "way", and a list of way ids separated by a ",".

Precondition failed: Node (\\d+) is still used by ways (\\d+(?:,\\d+)*)\\.

I'd like to refrain from quick fixes and would like to know whether there is any reason to keep this duplication. Perhaps/hopefully, someone with a better understanding of the OSM API implementation can take a look at it.

comment:2 Changed 8 years ago by stoecker

The second should match this text, except if there is a Java-related formatting bug of the regexp (I never get the Java escaping properly) or maybe ".*" is messing at start and end of regexp. I would change "ways" to "ways?", which would also catch the text without "s" and drop the first check.

Gubaer did write a lot of duplicated code instead of writing proper reusable interfaces. So unifying the server check codes where necessary would be fine.

comment:3 Changed 8 years ago by simon04

Is there a public test/development OSM API available? I'd like to avoid testing against the main database.


Furthermore, the following two cases are currently not handled:

  • When a node is still member of a relation: Node #{id} is still used by relation #{relation.id}.
  • When a way is still member of a relation: Way #{id} still used by relation #{relation.id}.

Changed 8 years ago by simon04

Attachment: 7257.patch added

comment:5 Changed 8 years ago by simon04

Summary: Provide an option to automatically download elements after a reference error[Patch] Provide an option to automatically download elements after a reference error

Patch attached:

Please test + review!

comment:6 Changed 8 years ago by skyper

Does this also work for #4093 ?

comment:7 Changed 8 years ago by simon04

It should, yes.

comment:8 Changed 8 years ago by bastiK

@simon04: I think you are on your own here, just commit and see what happens. ;)

comment:9 Changed 8 years ago by simon04

So, no one is really interested in touching the API implementation? :-)

I'll commit the patch, and then let's see …

comment:10 Changed 8 years ago by simon04

Resolution: fixed
Status: newclosed

In [4816/josm]:

fix #7257, fix #4093 - Provide an option to automatically download elements after a reference error

comment:11 Changed 8 years ago by landwirt@…

"node still used by way" worked fine.

But then I got

Repository Root: http://josm.openstreetmap.de/svn
Build-Date: 2012-01-19 02:33:08
Last Changed Author: bastiK
Revision: 4818
Repository UUID: 0c6e7542-c601-0410-84e7-c038aed88b3b
URL: http://josm.openstreetmap.de/svn/trunk
Last Changed Date: 2012-01-18 20:43:48 +0100 (Wed, 18 Jan 2012)
Last Changed Rev: 4818

Identification: JOSM/1.5 (4818 en)
Memory Usage: 1527 MB / 1527 MB (727 MB allocated, but free)
Java version: 1.6.0_27, Sun Microsystems Inc., Java HotSpot(TM) 64-Bit Server VM
Operating system: Windows 7
Dataset consistency test: No problems found

Plugin: DirectUpload (27355)
Plugin: PicLayer (27403)
Plugin: editgpx (27289)
Plugin: licensechange (27472)
Plugin: openvisible (27289)
Plugin: plastic_laf (26605)
Plugin: reverter (27393)
Plugin: turnrestrictions (27355)
Plugin: utilsplugin2 (27426)

java.lang.reflect.InvocationTargetException
	at java.awt.EventQueue.invokeAndWait(Unknown Source)
	at org.openstreetmap.josm.gui.PleaseWaitRunnable.doRealRun(PleaseWaitRunnable.java:87)
	at org.openstreetmap.josm.gui.PleaseWaitRunnable.run(PleaseWaitRunnable.java:137)
	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NumberFormatException: For input string: "96242297,99924613"
	at java.lang.NumberFormatException.forInputString(Unknown Source)
	at java.lang.Long.parseLong(Unknown Source)
	at java.lang.Long.parseLong(Unknown Source)
	at org.openstreetmap.josm.tools.ExceptionUtil.parsePreconditionFailed(ExceptionUtil.java:93)
	at org.openstreetmap.josm.gui.io.AbstractUploadTask.handlePreconditionFailed(AbstractUploadTask.java:277)
	at org.openstreetmap.josm.gui.io.AbstractUploadTask.handleFailedUpload(AbstractUploadTask.java:331)
	at org.openstreetmap.josm.gui.io.UploadPrimitivesTask$2.run(UploadPrimitivesTask.java:343)
	at org.openstreetmap.josm.gui.io.UploadPrimitivesTask.finish(UploadPrimitivesTask.java:348)
	at org.openstreetmap.josm.gui.PleaseWaitRunnable$1.run(PleaseWaitRunnable.java:89)
	at java.awt.event.InvocationEvent.dispatch(Unknown Source)
	at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
	at java.awt.EventQueue.access$000(Unknown Source)
	at java.awt.EventQueue$1.run(Unknown Source)
	at java.awt.EventQueue$1.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.Dialog$1.run(Unknown Source)
	at java.awt.Dialog$3.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.awt.Dialog.show(Unknown Source)
	at java.awt.Component.show(Unknown Source)
	at java.awt.Component.setVisible(Unknown Source)
	at java.awt.Window.setVisible(Unknown Source)
	at java.awt.Dialog.setVisible(Unknown Source)
	at org.openstreetmap.josm.gui.progress.PleaseWaitProgressMonitor$4.run(PleaseWaitProgressMonitor.java:170)
	at java.awt.event.InvocationEvent.dispatch(Unknown Source)
	at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
	at java.awt.EventQueue.access$000(Unknown Source)
	at java.awt.EventQueue$1.run(Unknown Source)
	at java.awt.EventQueue$1.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)

comment:12 Changed 8 years ago by anonymous

Forgot the error

Error header: Precondition failed: Node 1115583206 is still used by ways 96242297,99924613.

comment:13 Changed 8 years ago by simon04

In [4821/josm]:

fix #7257 - NumberFormatException

comment:14 Changed 8 years ago by simon04

Sorry … I used the wrong string for parsing the ids.

comment:15 Changed 8 years ago by stoecker

You added a lot of impossible combinations: Nodes can't reference any other element. Ways can't reference ways or relations.

Please remove these, as they make no sense and I nearly twisted my brain in translating them :-)

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain team.
as The resolution will be set.
The resolution will be deleted.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.