1 class ConfigsController < ApplicationController
3 before_filter :authentication
4 before_filter :add_cookie_header # only for anonymous participants
15 unless Mime::Type.lookup(request.headers["CONTENT_TYPE"]) =~ "application/json"
16 raise Ecs::InvalidMimetypeException, "Please provide \"Content-Type:\" header. Data format has to be in JSON (application/json)"
19 config= ActiveSupport::JSON.decode request.raw_post
21 if config["participant_events"] == true
22 @participant.events_= true
24 @participant.events_= false
25 end unless config["participant_events"].nil?
27 if config["selfrouting"] == true
28 @participant.community_selfrouting= true
30 @participant.community_selfrouting= false
31 end unless config["selfrouting"].nil?
35 #rescue ActiveSupport::OkJson::Error
36 rescue Ecs::InvalidMimetypeException
38 rescue ActiveRecord::RecordInvalid
39 raise Ecs::InvalidMessageException, "Data could not be saved (ConfigsController#create)."
41 raise Ecs::InvalidMessageException, "You have provided invalid JSON data (ConfigsController#create)."
49 res_ev={};Ressource.all.each {|r| res_ev["/#{r.namespace}/#{r.ressource}"] = r.events}
52 :participant_events => @participant.events?,
53 :resource_events => res_ev,
54 :selfrouting => @participant.community_selfrouting
56 respond_to do |format|
57 format.json { render :json => JSON.pretty_generate(config) + "\r\n" }
58 format.xml { render :xml => config }