def read
if(location =~ /ecogrid/)
uri = URI.parse(PATH_TO_METACAT)
uri.query = "action=read&qformat=xml&docid=#{docid}"
http = Net::HTTP.start(uri.host, uri.port)
http.request_get(uri.to_s) do |response|
if(response.content_type == 'text/xml')
doc = REXML::Document.new(response.read_body)
if(doc.root.name == 'error')
raise doc.root.text
else
raise "Unrecognized response from metacat at #{PATH_TO_METACAT}"
end
elsif(response.content_type == 'text/plain')
response.read_body do |f|
yield f
end
else
raise "Unrecognized content type \"#{response.content_type}\" " +
"from metacat at #{PATH_TO_METACAT}"
end
end
elsif(location =~ /http/)
uri = URI.parse(location)
http = Net::HTTP.start(uri.host, uri.port)
http.request_get(uri.to_s) do |response|
response.read_body do |f|
yield f
end
end
else
raise 'Unknown location for dataTable'
end
end