Class: CartridgesController

Inherits:
BaseController show all
Includes:
LegacyBrokerHelper
Defined in:
app/controllers/cartridges_controller.rb

Constant Summary

Constants inherited from BaseController

BaseController::API_VERSION, BaseController::SUPPORTED_API_VERSIONS

Instance Method Summary collapse

Methods included from LegacyBrokerHelper

#get_cached

Methods included from UserActionLogger

#get_action_logger, #log_action

Instance Method Details

#indexObject

GET /cartridges



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'app/controllers/cartridges_controller.rb', line 11

def index
  type = params[:id]
  
  cartridges = Array.new
  if type.nil? or type == "standalone"
    cart_type = "standalone"
    cache_key = "cart_list_#{cart_type}"
    carts = get_cached(cache_key, :expires_in => 21600.seconds) do
      Application.get_available_cartridges(cart_type)
    end
    carts.each do |cart|
      if $requested_api_version >= 1.1
        cartridge = RestCartridge11.new(cart_type, cart, nil, get_url, nil, nolinks)
      else
        cartridge = RestCartridge10.new(cart_type, cart, nil, get_url, nil, nolinks)
      end
      cartridges.push(cartridge)
    end
  end
  
  if type.nil? or type == "embedded"
    cart_type = "embedded"
    cache_key = "cart_list_#{cart_type}"
    carts = get_cached(cache_key, :expires_in => 21600.seconds) do
      Application.get_available_cartridges(cart_type)
    end
    carts.each do |cart|
   if $requested_api_version >= 1.1
        cartridge = RestCartridge11.new(cart_type, cart, nil, get_url, nil, nolinks)
      else
        cartridge = RestCartridge10.new(cart_type, cart, nil, get_url, nil, nolinks)
      end
      cartridges.push(cartridge)
    end
  end
  render_success(:ok, "cartridges", cartridges, "LIST_CARTRIDGES", "List #{type.nil? ? 'all' : type} cartridges") 
end

#showObject



6
7
8
# File 'app/controllers/cartridges_controller.rb', line 6

def show
  index
end