- require 'xml/libxml'
-
- before_filter :authorize
- after_filter :compress_output
-
- def create\r
- response.headers["Content-Type"] = 'application/xml'
- if request.put?
- node = nil
- begin
- node = Node.from_xml(request.raw_post, true)
- rescue
- render :text => "XML didn't parse", :status => 400 # if we got here the doc didnt parse
- return
- end
-
- if node
- node.user_id = @user.id
- node.visible = 1
- if node.save_with_history
- render :text => node.id.to_s
- else
- render :nothing => true, :status => 500
- end
- return
-
- else
- render :nothing => true, :status => 400 # if we got here the doc didnt parse
- return
- end
- end
+ require "xml/libxml"
+
+ skip_before_action :verify_authenticity_token
+ before_action :authorize, :only => [:create, :update, :delete]
+ before_action :require_allow_write_api, :only => [:create, :update, :delete]
+ before_action :require_public_data, :only => [:create, :update, :delete]
+ before_action :check_api_writable, :only => [:create, :update, :delete]
+ before_action :check_api_readable, :except => [:create, :update, :delete]
+ around_action :api_call_handle_error, :api_call_timeout
+
+ # Create a node from XML.
+ def create
+ assert_method :put
+
+ node = Node.from_xml(request.raw_post, true)