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

{{{



397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
# File 'lib/cpee/implementation_properties.rb', line 397

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