Class: CPEE::Properties::PostItem

Inherits:
Riddl::Implementation
  • Object
show all
Defined in:
lib/cpee/implementation_properties.rb

Overview

}}}

Instance Method Summary collapse

Instance Method Details

#responseObject

{{{



452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
# File 'lib/cpee/implementation_properties.rb', line 452

def response
  item = @a[0]
  id = @a[1]
  opts = @a[2]
  if opts[:statemachine].readonly? id
    @status = 423
  elsif opts[:statemachine].final? id
    @status = 410
  else
    begin
      doc = XML::Smart::string(@p[0].value.read)
      val = doc.find("/*").map do |ele|
        [ele.qname.name, ele.text]
      end.to_h
      if not CPEE::Persistence::extract_item(id,opts,File.join(@r.first,val.keys.first))
        CPEE::Persistence::set_list(id,opts,item,val)
        Riddl::Parameter::Simple.new('id',val.keys.first)
      else
        @status= 409
      end
    rescue => e
      @status = 400
    end
  end
  nil
end