Commit 7cfc2018 authored by Roque's avatar Roque

workaround to keep backward compatibility

parent db891b8b
......@@ -148,7 +148,7 @@ module Embulk
@logger.error(data_stream_count["error_message"], print=TRUE)
@logger.abortExecution()
end
data_stream_list = @wendelin.getDataStreamList(@data_set, data_stream_count["result"], @batch_size)
data_stream_list = @wendelin.getDataStreamList(@data_set, data_stream_count["result"], @batch_size)
if data_stream_list["status_code"] == 0
task['data_streams'] = data_stream_list["result"]
else
......
......@@ -185,11 +185,15 @@ class WendelinClient
end
def getDataStreamList(data_set_reference, data_stream_count, batch_size)
#keep backward compatibility
if data_stream_count = -1
return getDataStreams(data_set_reference)
end
data_stream_list = []
total_batches = data_stream_count/batch_size.ceil()
if total_batches > 4
puts
@logger.warn("Due to its size, the remote file list will be fetch in batches. This could take some minutes.", print=TRUE)
@logger.info("Due to its size, the remote file list will be fetch in batches. This could take some minutes.", print=TRUE)
end
nbatch = 0
while nbatch <= total_batches
......@@ -234,19 +238,24 @@ class WendelinClient
return {'status_code': 0, 'result': []}
end
def getDataStreamCount(data_set_reference)
uri = URI(URI.escape("#{@erp5_url}ERP5Site_getDataStreamCount?data_set_reference=#{data_set_reference}"))
response = handleRequest(uri)
if response["success"] == FALSE
@logger.abortExecution()
#keep backward compatibiliy if script doesn't exist in wendelin instance
if response["message"] == 404
@logger.info("Continue with backward compatibility...", print=TRUE)
return {"status_code"=>0, "result"=>-1}
else
@logger.abortExecution()
end
end
str = response["message"]
if not str.nil?
str.gsub!(/(\,)(\S)/, "\\1 \\2")
return YAML::load(str)
end
return {'status_code': 0, 'result': 0}
return {"status_code"=>0, "result"=>0}
end
private
......@@ -300,6 +309,8 @@ class WendelinClient
elsif res.code == '400'
@logger.error(HTTP_MESSAGE_400, print=TRUE)
@logger.abortExecution()
elsif res.code == '404'
return {"success"=>FALSE, "message"=>404}
else
@logger.error(HTTP_MESSAGE_OTHER, print=TRUE)
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment