Class: DbmsServicesController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/dbms_services_controller.rb

Constant Summary collapse

APP_CONFIG =

Load configuration items (MANDATORY, must be included)

HashWithIndifferentAccess.new(YAML.load(File.read(File.expand_path('../../../config/dbms/dbms_config.yml', __FILE__))))

Instance Method Summary collapse

Instance Method Details

#executeObject

Controller Actions



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/controllers/dbms_services_controller.rb', line 7

def execute
  SymmetricEncryption.load!

  begin
    serviceObj = Metadata.find_by_key(params[:key])

    if (!serviceObj.nil?)
      serviceValueObj = ActiveSupport::JSON.decode(SymmetricEncryption.decrypt(serviceObj.value))

      if (serviceValueObj['enabled'] == true)
        resultSet = Database.connection.select_all(serviceValueObj['sql'])

        render :json => {:status => "success", :data => resultSet}
      else
        raise "service unavailable"
      end
    else
      raise "data unavailable"
    end

  rescue Exception => ex
    render :json => {:status => "failure", :message => ex.message, :data => []}
  end
end