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
61 node.user_id = @user.id
63 node.save_with_history
64 render :nothing => true
67 render :nothing => true, :status => 410
71 new_node = Node.from_xml(request.raw_post)
74 node.timestamp = Time.now
75 node.user_id = @user.id
77 node.latitude = new_node.latitude
78 node.longitude = new_node.longitude
79 node.tags = new_node.tags
81 if node.id == new_node.id and node.save_with_history
82 render :nothing => true
84 render :nothing => true, :status => 500
87 render :nothing => true, :status => 400 # if we got here the doc didnt parse
95 response.headers["Content-Type"] = 'text/xml'
96 ids = params['nodes'].split(',').collect {|n| n.to_i }
98 nodelist = Node.find(ids)
100 nodelist.each do |node|
101 doc.root << node.to_xml_node
103 render :text => doc.to_s
105 render :nothing => true, :status => 400