- begin
- relation = Relation.find(params[:id])
-
- if relation.visible
- new_relation = Relation.from_xml(request.raw_post)
-
- if new_relation and new_relation.id == relation.id
- if !new_relation.preconditions_ok?
- render :nothing => true, :status => :precondition_failed
- else
- relation.user_id = @user.id
- relation.tags = new_relation.tags
- relation.members = new_relation.members
- relation.visible = true
-
- if relation.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
- end
+ logger.debug request.raw_post
+
+ relation = Relation.find(params[:id])
+ new_relation = Relation.from_xml(request.raw_post)
+
+ raise OSM::APIBadUserInput, "The id in the url (#{relation.id}) is not the same as provided in the xml (#{new_relation.id})" unless new_relation && new_relation.id == relation.id
+
+ relation.update_from new_relation, current_user
+ render :plain => relation.version.to_s