node = Node.from_xml(request.raw_post, true)
if node
- node.version = 0
+ node.version = 0
node.user_id = @user.id
node.visible = true
node.save_with_history!
new_node = Node.from_xml(request.raw_post)
if new_node and new_node.id == node.id
- node.update_from(new_node, @user)
- render :nothing => true
+ node.update_from(new_node, @user)
+ render :text => node.version.to_s, :content_type => "text/plain"
else
render :nothing => true, :status => :bad_request
end
+ rescue OSM::APIVersionMismatchError => ex
+ render :text => "Version mismatch: Provided " + ex.provided.to_s +
+ ", server had: " + ex.latest.to_s, :status => :bad_request
rescue ActiveRecord::RecordNotFound
render :nothing => true, :status => :not_found
end