1 class NodeController < ApplicationController
4 before_filter :authorize
5 after_filter :compress_output
8 response.headers["Content-Type"] = 'text/xml'
10 node = Node.from_xml(request.raw_post, true)
13 node.user_id = @user.id
15 if node.save_with_history
16 render :text => node.id.to_s
18 render :nothing => true, :status => 500
23 render :nothing => true, :status => 400 # if we got here the doc didnt parse
28 render :nothing => true, :status => 500 # something went very wrong
32 response.headers["Content-Type"] = 'text/xml'
33 unless Node.exists?(params[:id])
34 render :nothing => true, :status => 404
38 node = Node.find(params[:id])
44 render :nothing => true, :status => 500
49 render :nothing => true, :status => 410
53 render :text => node.to_xml.to_s
58 if Segment.find(:first, :conditions => [ "visible = 1 and (node_a = ? or node_b = ?)", node.id, node.id])
59 render :nothing => true, :status => HTTP_PRECONDITION_FAILED
62 node.save_with_history
63 render :nothing => true
66 render :nothing => true, :status => 410
70 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
83 render :nothing => true, :status => 500
86 render :nothing => true, :status => 400 # if we got here the doc didnt parse
94 response.headers["Content-Type"] = 'text/xml'
95 ids = params['nodes'].split(',').collect {|n| n.to_i }
97 nodelist = Node.find(ids)
99 nodelist.each do |node|
100 doc.root << node.to_xml_node
102 render :text => doc.to_s
104 render :nothing => true, :status => 400