class Asperalm::Fasp::HttpGW

executes a local “ascp”, connects mgt port, equivalent of “Fasp Manager”

Public Class Methods

new(params) click to toggle source
Calls superclass method
# File lib/asperalm/fasp/http_gw.rb, line 69
def initialize(params)
  raise "params must be Hash" unless params.is_a?(Hash)
  params=params.symbolize_keys
  raise "must have only one param: url" unless params.keys.eql?([:url])
  super()
  @gw_api=Rest.new({:base_url => params[:url]})
  api_info = @gw_api.read('info')[:data]
  Log.log.info("#{api_info}")
end

Public Instance Methods

shutdown() click to toggle source

terminates monitor thread

# File lib/asperalm/fasp/http_gw.rb, line 61
def shutdown
end
start_transfer(transfer_spec,options={}) click to toggle source

start FASP transfer based on transfer spec (hash table) note that it is asynchronous HTTP download only supports file list

# File lib/asperalm/fasp/http_gw.rb, line 14
def start_transfer(transfer_spec,options={})
  raise "GW URL must be set" unless !@gw_api.nil?
  raise "option: must be hash (or nil)" unless options.is_a?(Hash)
  raise "paths: must be Array" unless transfer_spec['paths'].is_a?(Array)
  case transfer_spec['direction']
  when 'send'
    # this is a websocket
    raise "error, not implemented"
  when 'receive'
    transfer_spec['zip_required']||=false
    transfer_spec['authentication']||='token'
    transfer_spec['source_root']||='/'
    # is normally provided by application, like package name
    if !transfer_spec.has_key?('download_name')
      # by default it is the name of first file
      dname=File.basename(transfer_spec['paths'].first['source'])
      # we remove extension
      dname=dname.gsub(/\.@gw_api.*$/,'')
      # ands add indication of number of files if there is more than one
      if transfer_spec['paths'].length > 1
        dname=dname+" #{transfer_spec['paths'].length} Files"
      end
      transfer_spec['download_name']=dname
    end
    creation=@gw_api.create('download',{'transfer_spec'=>transfer_spec})[:data]
    transfer_uuid=creation['url'].split('/').last
    if transfer_spec['zip_required'] or transfer_spec['paths'].length > 1
      # it is a zip file if zip is required or there is more than 1 file
      file_dest=transfer_spec['download_name']+'.zip'
    else
      # it is a plain file if we don't require zip and there is only one file
      file_dest=File.basename(transfer_spec['paths'].first['source'])
    end
    file_dest=File.join(transfer_spec['destination_root'],file_dest)
    @gw_api.call({:operation=>'GET',:subpath=>"download/#{transfer_uuid}",:save_to_file=>file_dest})
  else
    raise "error"
  end
end
url=(api_url) click to toggle source
# File lib/asperalm/fasp/http_gw.rb, line 64
def url=(api_url)
end
wait_for_transfers_completion() click to toggle source

wait for completion of all jobs started @return list of :success or error message

# File lib/asperalm/fasp/http_gw.rb, line 56
def wait_for_transfers_completion
  return [:success]
end