1 class NodeController < ApplicationController
 
   4   before_filter :authorize
 
   5   after_filter :compress_output
 
   8     response.headers["Content-Type"] = 'application/xml'
 
  12         node = Node.from_xml(request.raw_post, true)
 
  14         render :text => "XML didn't parse", :status => 400 # if we got here the doc didnt parse
 
  19         node.user_id = @user.id
 
  21         if node.save_with_history
 
  22           render :text => node.id.to_s
 
  24           render :nothing => true, :status => 500
 
  29         render :nothing => true, :status => 400 # if we got here the doc didnt parse
 
  34     render :nothing => true, :status => 500 # something went very wrong
 
  38     response.headers["Content-Type"] = 'application/xml'
 
  39     unless Node.exists?(params[:id])
 
  40       render :nothing => true, :status => 404
 
  44     node = Node.find(params[:id])
 
  50         render :nothing => true, :status => 500
 
  55         render :nothing => true, :status => 410
 
  59       render :text => node.to_xml.to_s
 
  65         node.save_with_history
 
  66         render :nothing => true
 
  68         render :nothing => true, :status => 410
 
  72       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, :status => 200
 
  84         render :nothing => true, :status => 500
 
  92     response.headers["Content-Type"] = 'application/xml'
 
  93     ids = params['nodes'].split(',').collect {|n| n.to_i }
 
  95       nodelist = Node.find(ids)
 
  97       nodelist.each do |node|
 
  98         doc.root << node.to_xml_node
 
 100       render :text => doc.to_s
 
 102       render :nothing => true, :status => 400