before_filter :authorize
def create
+ response.headers["Content-Type"] = 'application/xml'
if request.put?
- node = Node.from_xml(request.raw_post, true)
+ 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
else
render :nothing => true, :status => 500
end
def rest
+ response.headers["Content-Type"] = 'application/xml'
unless Node.exists?(params[:id])
- render :nothing => true, :status => 400
+ render :nothing => true, :status => 404
return
end
case request.method
when :get
+ unless node
+ render :nothing => true, :status => 500
+ return
+ end
+
+ unless node.visible
+ render :nothing => true, :status => 410
+ return
+ end
+
render :text => node.to_xml.to_s
return
end
end
+
end