Class: CPEE::Properties::PutDescription

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

Overview

}}}

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.set(id, opts, xml) ⇒ Object

{{{



636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
# File 'lib/cpee/implementation_properties.rb', line 636

def self::set(id,opts,xml)
  dslx, dsl, de, ep = transform(
    xml,
    CPEE::Persistence::extract_item(id,opts,'transformation/description'),
    CPEE::Persistence::extract_item(id,opts,'transformation/description/@type'),
    CPEE::Persistence::extract_item(id,opts,'transformation/dataelements'),
    CPEE::Persistence::extract_item(id,opts,'transformation/dataelements/@type'),
    CPEE::Persistence::extract_item(id,opts,'transformation/endpoints'),
    CPEE::Persistence::extract_item(id,opts,'transformation/endpoints/@type'),
    opts
  )
  CPEE::Persistence::set_item(id,opts,'description',
    :description => xml,
    :dslx => dslx,
    :dsl => dsl
  )
  PatchItems::set_hash('dataelements',id,opts,de) unless de.empty?
  PatchItems::set_hash('dataelements',id,opts,ep) unless ep.empty?
end

Instance Method Details

#responseObject



656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
# File 'lib/cpee/implementation_properties.rb', line 656

def response
  id = @a[0]
  opts = @a[1]
  if opts[:statemachine].readonly? id
    @status = 422 # semantic error
  else
    begin
      # force-encoding because johannes managed to sneak in ascii special characters. why the browser is not sanitizing it is beyond me.
      PutDescription::set(id,opts,@p[0].value.read.force_encoding('UTF-8'))
    rescue => e
      puts e.message
      puts e.backtrace
      @status = 400
    end
  end
  nil
end