- begin
- way = Way.find(params[:id])
-
- if way.visible
- new_way = Way.from_xml(request.raw_post)
-
- if new_way and new_way.id == way.id
- if !new_way.preconditions_ok?
- render :nothing => true, :status => :precondition_failed
- else
- way.user_id = @user.id
- way.tags = new_way.tags
- way.segs = new_way.segs
- way.visible = true
-
- if way.save_with_history
- render :nothing => true
- else
- render :nothing => true, :status => :internal_server_error
- end
- end
- else
- render :nothing => true, :status => :bad_request
- end
- else
- render :nothing => true, :status => :gone
- end
- rescue ActiveRecord::RecordNotFound
- render :nothing => true, :status => :not_found
- rescue
- render :nothing => true, :status => :internal_server_error
+ way = Way.find(params[:id])
+ new_way = Way.from_xml(request.raw_post)
+
+ unless new_way && new_way.id == way.id
+ fail OSM::APIBadUserInput.new("The id in the url (#{way.id}) is not the same as provided in the xml (#{new_way.id})")