66 lines
1.7 KiB
Ruby
66 lines
1.7 KiB
Ruby
class ArtifactsController < ApiController
|
|
|
|
respond_to :json
|
|
|
|
# retrieve all available client downloads
|
|
def client_downloads
|
|
clients = ArtifactUpdate.where("product like '%JamClient%' and environment = '#{ArtifactUpdate::DEFAULT_ENVIRONMENT}'").order(:product)
|
|
|
|
if params[:type]
|
|
cliens = clients.where("product ilike 'JamClient/#{params[:type]}'")
|
|
end
|
|
|
|
result = {}
|
|
|
|
clients.each do |client|
|
|
url = client.determine_url
|
|
if params[:type]
|
|
result[params[:type]] = { :uri => url, :size => client.size, :version => client.version, :md5 => client.sha1}
|
|
else
|
|
result[client.product] = { :uri => url, :size => client.size, :version => client.version, :md5 => client.sha1}
|
|
end
|
|
end
|
|
render :json => result, :status => :ok
|
|
end
|
|
|
|
|
|
def healthcheck
|
|
render :json => {}
|
|
end
|
|
|
|
|
|
def versioncheck
|
|
|
|
# the reported client version
|
|
#client_version = params[:ver]
|
|
|
|
# the name of the client, i.e.JamClient
|
|
product = params[:product]
|
|
|
|
# the os (Win32/MacOSX/Unix)
|
|
os = params[:os]
|
|
|
|
product = "#{product}/#{os}"
|
|
|
|
logger.debug "version check from #{product}"
|
|
|
|
|
|
|
|
unless ArtifactUpdate::PRODUCTS.include? product
|
|
render :json => { :errors => { :product => ['not a valid product'] } }, :status => :unprocessable_entity
|
|
return
|
|
end
|
|
|
|
@artifact = ArtifactUpdate.find_by_product_and_environment(product, ArtifactUpdate::DEFAULT_ENVIRONMENT)
|
|
|
|
if @artifact.nil?
|
|
render :json => {}, :status => :ok
|
|
else
|
|
url = @artifact.determine_url
|
|
render :json => { "version" => @artifact.version, "uri" => url, "sha1" => @artifact.sha1, "size" => @artifact.size }, :status => :ok
|
|
end
|
|
|
|
end
|
|
|
|
end
|