projects
/
arvados.git
/ blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch '1495-crunch-documentation'
[arvados.git]
/
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 d9d7ad864d8641aa621ae5a2c521728072dd924e..434b09572b40b64af026e27a43962b422aeea7c6 100644
(file)
--- 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
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
else
render_not_found("object not found")
end
@@
-37,7
+37,9
@@
class ApplicationController < ActionController::Base
end
def update
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
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
:with => :render_not_found
rescue_from ActionController::UnknownController,
:with => :render_not_found
- rescue_from A
ctionController::UnknownAction
,
+ rescue_from A
bstractController::ActionNotFound
,
:with => :render_not_found
rescue_from ArvadosModel::PermissionDeniedError,
:with => :render_error
:with => :render_not_found
rescue_from ArvadosModel::PermissionDeniedError,
:with => :render_error
@@
-81,7
+83,8
@@
class ApplicationController < ActionController::Base
else
errors = [e.inspect]
end
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"))
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
end
def thread_with_auth_info
+ Thread.current[:api_url_base] = root_url.sub(/\/$/,'') + '/arvados/v1'
begin
user = nil
api_client = nil
begin
user = nil
api_client = nil
@@
-251,7
+255,7
@@
class ApplicationController < ActionController::Base
includes(:api_client, :user).
where('api_token=? and (expires_at is null or expires_at > now())', supplied_token).
first
includes(:api_client, :user).
where('api_token=? and (expires_at is null or expires_at > now())', supplied_token).
first
- if api_client_auth
+ if api_client_auth
.andand.user
session[:user_id] = api_client_auth.user.id
session[:api_client_uuid] = api_client_auth.api_client.andand.uuid
session[:api_client_authorization_id] = api_client_auth.id
session[:user_id] = api_client_auth.user.id
session[:api_client_uuid] = api_client_auth.api_client.andand.uuid
session[:api_client_authorization_id] = api_client_auth.id
@@
-329,7
+333,7
@@
class ApplicationController < ActionController::Base
:self_link => "",
:next_page_token => "",
:next_link => "",
:self_link => "",
:next_page_token => "",
:next_link => "",
- :items => @objects.as_api_response(
:superuser
)
+ :items => @objects.as_api_response(
nil
)
}
render json: @object_list
end
}
render json: @object_list
end
@@
-351,4
+355,9
@@
class ApplicationController < ActionController::Base
order: { type: 'string', required: false }
}
end
order: { type: 'string', required: false }
}
end
+
+ def client_accepts_plain_text_stream
+ (request.headers['Accept'].split(' ') &
+ ['text/plain', '*/*']).count > 0
+ end
end
end