X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/92b60e19ad1f27ac11c4b6269d5acdfa6cc1cbc4..c2d962b16eb0a68a880326abfbc04d07db230815:/services/api/app/controllers/application_controller.rb diff --git a/services/api/app/controllers/application_controller.rb b/services/api/app/controllers/application_controller.rb index 0c7578a015..c6e7da0e11 100644 --- a/services/api/app/controllers/application_controller.rb +++ b/services/api/app/controllers/application_controller.rb @@ -24,7 +24,7 @@ class ApplicationController < ActionController::Base def show if @object - render json: @object.as_api_response(:superuser) + render json: @object.as_api_response else render_not_found("object not found") end @@ -37,7 +37,9 @@ class ApplicationController < ActionController::Base end def update - attrs_to_update = resource_attrs.reject { |k,v| [:kind,:etag].index k } + attrs_to_update = resource_attrs.reject { |k,v| + [:kind, :etag, :href].index k + } if @object.update_attributes attrs_to_update show else @@ -67,7 +69,7 @@ class ApplicationController < ActionController::Base :with => :render_not_found rescue_from ActionController::UnknownController, :with => :render_not_found - rescue_from ActionController::UnknownAction, + rescue_from AbstractController::ActionNotFound, :with => :render_not_found rescue_from ArvadosModel::PermissionDeniedError, :with => :render_error @@ -81,7 +83,8 @@ class ApplicationController < ActionController::Base else errors = [e.inspect] end - render json: { errors: errors }, status: 422 + status = e.respond_to?(:http_status) ? e.http_status : 422 + render json: { errors: errors }, status: status end def render_not_found(e=ActionController::RoutingError.new("Path not found")) @@ -238,6 +241,7 @@ class ApplicationController < ActionController::Base end def thread_with_auth_info + Thread.current[:api_url_base] = root_url.sub(/\/$/,'') + '/arvados/v1' begin user = nil api_client = nil @@ -324,13 +328,16 @@ class ApplicationController < ActionController::Base def render_list @object_list = { - :kind => "arvados##{resource_name}List", + :kind => "arvados##{(@response_resource_name || resource_name).camelize(:lower)}List", :etag => "", :self_link => "", :next_page_token => "", :next_link => "", - :items => @objects.as_api_response(:superuser) + :items => @objects.as_api_response(nil) } + if @objects.respond_to? :except + @object_list[:items_available] = @objects.except(:limit).count + end render json: @object_list end @@ -351,4 +358,9 @@ class ApplicationController < ActionController::Base order: { type: 'string', required: false } } end + + def client_accepts_plain_text_stream + (request.headers['Accept'].split(' ') & + ['text/plain', '*/*']).count > 0 + end end