+ if !way.preconditions_ok?
+ render :text => "", :status => :precondition_failed
+ else
+ way.user_id = @user.id
+ way.save_with_history!
+
+ render :text => way.id.to_s, :content_type => "text/plain"
+ end
+ else
+ render :nothing => true, :status => :bad_request
+ end
+ else
+ render :nothing => true, :status => :method_not_allowed
+ end
+ end
+
+ def read
+ begin
+ way = Way.find(params[:id])
+
+ if way.visible
+ render :text => way.to_xml.to_s, :content_type => "text/xml"
+ else
+ render :text => "", :status => :gone
+ end
+ rescue ActiveRecord::RecordNotFound
+ render :nothing => true, :status => :not_found
+ end
+ end
+
+ def update
+ 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 :text => "", :status => :precondition_failed
+ else
+ way.user_id = @user.id
+ way.tags = new_way.tags
+ way.nds = new_way.nds
+ way.visible = true
+ way.save_with_history!
+
+ render :nothing => true
+ end
+ else
+ render :nothing => true, :status => :bad_request
+ end
+ else
+ render :text => "", :status => :gone
+ end
+ rescue ActiveRecord::RecordNotFound
+ render :nothing => true, :status => :not_found
+ end
+ end