- tags = tags.collect { |k,v| "#{k}=#{v}" }.join(';')
-
- tags = '' unless tags
- if xmlnodeid == nodeid && userid != 0
- if nodeid == 0
- new_node_id = dao.create_node(lat, lon, userid, tags)
- if new_node_id
- puts new_node_id
- exit
- else
- exit HTTP_INTERNAL_SERVER_ERROR
- end
- else
- node = dao.getnode(nodeid)
- if node
- #FIXME: need to check the node hasn't moved too much
- if dao.update_node?(nodeid, userid, lat, lon, tags)
- exit
- else
- exit HTTP_INTERNAL_SERVER_ERROR
- end
- else
- exit HTTP_NOT_FOUND
- end
- end
+ before_filter :authorize
+ after_filter :compress_output
+
+ def create\r
+ response.headers["Content-Type"] = 'text/xml'
+ if request.put?
+ 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