1 class NodeController < ApplicationController
4 before_filter :authorize
7 response.headers["Content-Type"] = 'application/xml'
11 node = Node.from_xml(request.raw_post, true)
13 render :text => "XML didn't parse", :status => 400 # if we got here the doc didnt parse
18 node.user_id = @user.id
20 if node.save_with_history
21 render :text => node.id
23 render :nothing => true, :status => 500
28 render :nothing => true, :status => 400 # if we got here the doc didnt parse
33 render :nothing => true, :status => 500 # something went very wrong
37 response.headers["Content-Type"] = 'application/xml'
38 unless Node.exists?(params[:id])
39 render :nothing => true, :status => 404
43 node = Node.find(params[:id])
49 render :nothing => true, :status => 500
54 render :nothing => true, :status => 410
58 render :text => node.to_xml.to_s
64 node.save_with_history
65 render :nothing => true
67 render :nothing => true, :status => 410
71 new_node = Node.from_xml(request.raw_post)
73 node.timestamp = Time.now
74 node.user_id = @user.id
76 node.latitude = new_node.latitude
77 node.longitude = new_node.longitude
78 node.tags = new_node.tags
80 if node.id == new_node.id and node.save_with_history
81 render :nothing => true, :status => 200
83 render :nothing => true, :status => 500
91 response.headers["Content-Type"] = 'application/xml'
92 ids = params['nodes'].split(',').collect {|n| n.to_i }
94 nodelist = Node.find(ids)
96 nodelist.each do |node|
97 doc.root << node.to_xml_node
99 render :text => doc.to_s
101 render :nothing => true, :status => 400