Class: CPEE::Instantiation::InstantiateXML

Inherits:
Riddl::Implementation
  • Object
show all
Includes:
Helpers
Defined in:
lib/cpee-instantiation/instantiation.rb

Overview

}}}

Instance Method Summary collapse

Methods included from Helpers

#add_to_testset, #augment_testset, #handle_attributes, #handle_data, #handle_endpoints

Instance Method Details

#responseObject



294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
# File 'lib/cpee-instantiation/instantiation.rb', line 294

def response
  cpee     = @h['X_CPEE'] || @a[0]
  behavior = @a[1] ? 'fork_ready' : @p[0].value
  data     = @a[1] ? 0 : 1
  selfurl  = @a[2]
  cblist   = @a[3]
  tdoc = if @p[data].additional =~ /base64/
    Base64.decode64(@p[data].value.read)
  else
    @p[data].value.read
  end

  tdoc = augment_testset(tdoc,@p)
  if (instance, uuid = load_testset(tdoc,cpee)).first == -1
    @status = 500
  else
    EM.defer do
      handle_waiting cpee, instance, uuid, behavior, selfurl, cblist
      handle_starting cpee, instance, behavior
    end

    send = {
      'CPEE-INSTANCE' => instance,
      'CPEE-INSTANCE-URL' => File.join(cpee,instance),
      'CPEE-INSTANCE-UUID' => uuid,
      'CPEE-BEHAVIOR' => behavior
    }
    if @p[0].value =~ /^wait/
      @headers << Riddl::Header.new('CPEE-CALLBACK','true')
    end
    Riddl::Parameter::Complex.new('instance','application/json',JSON::generate(send))
  end
end