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

{{{



417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
# File 'lib/cpee/implementation_properties.rb', line 417

def response
  item = @a[0]
  id = @a[1]
  opts = @a[2]
  if opts[:statemachine].readonly? id
    @status = 423
  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