[ARVADOS] updated: 99832dd9fc3773bb3d0cf6dc0b1a2c79ef209fbb

git at public.curoverse.com git at public.curoverse.com
Thu Jun 26 16:35:26 EDT 2014


Summary of changes:
 .../app/controllers/application_controller.rb      |  6 ++-
 apps/workbench/app/models/arvados_api_client.rb    | 60 ++++++++++++----------
 apps/workbench/app/views/application/404.html.erb  |  5 +-
 3 files changed, 41 insertions(+), 30 deletions(-)

       via  99832dd9fc3773bb3d0cf6dc0b1a2c79ef209fbb (commit)
       via  f70cea39d9fd451d33731eb22cbace637bbb0a7b (commit)
       via  6b9324b90def26487ec57ee22fbd249a41a2c871 (commit)
       via  7ff482005f3715c3ca71b5a66c996c2ce45d3242 (commit)
      from  7067c9a96ac36a7bb28d9efc45c70167d8761676 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 99832dd9fc3773bb3d0cf6dc0b1a2c79ef209fbb
Author: Brett Smith <brett at curoverse.com>
Date:   Thu Jun 26 16:36:16 2014 -0400

    2891: Workbench current_user copes when API server is unreachable.

diff --git a/apps/workbench/app/controllers/application_controller.rb b/apps/workbench/app/controllers/application_controller.rb
index 533163a..d2fe528 100644
--- a/apps/workbench/app/controllers/application_controller.rb
+++ b/apps/workbench/app/controllers/application_controller.rb
@@ -273,7 +273,11 @@ class ApplicationController < ActionController::Base
   def current_user
     return Thread.current[:user] if Thread.current[:user]
 
-    if Thread.current[:arvados_api_token]
+    if User.columns.empty?
+      # We can't even get the discovery document from the API server.
+      # We're not going to be able to instantiate any user object.
+      nil
+    elsif Thread.current[:arvados_api_token]
       if session[:user]
         if session[:user][:is_active] != true
           Thread.current[:user] = User.current

commit f70cea39d9fd451d33731eb22cbace637bbb0a7b
Author: Brett Smith <brett at curoverse.com>
Date:   Thu Jun 26 16:35:30 2014 -0400

    2891: Workbench converts API HTTP errors to API exceptions.

diff --git a/apps/workbench/app/models/arvados_api_client.rb b/apps/workbench/app/models/arvados_api_client.rb
index f36627f..9f34a29 100644
--- a/apps/workbench/app/models/arvados_api_client.rb
+++ b/apps/workbench/app/models/arvados_api_client.rb
@@ -12,6 +12,13 @@ class ArvadosApiClient
     end
   end
 
+  class NoApiResponseException < ApiError
+    def initialize(request_url, exception)
+      @api_response_s = exception.to_s
+      super(request_url,
+            "#{exception.class.to_s} error connecting to API server")
+    end
+  end
 
   class InvalidApiResponseException < ApiError
     def initialize(request_url, api_response)
@@ -115,9 +122,11 @@ class ArvadosApiClient
 
     profile_checkpoint { "Prepare request #{url} #{query[:uuid]} #{query[:where]} #{query[:filters]}" }
     msg = @client_mtx.synchronize do
-      @api_client.post(url,
-                       query,
-                       header: header)
+      begin
+        @api_client.post(url, query, header: header)
+      rescue => exception
+        raise NoApiResponseException.new(url, exception)
+      end
     end
     profile_checkpoint 'API transaction'
 

commit 6b9324b90def26487ec57ee22fbd249a41a2c871
Author: Brett Smith <brett at curoverse.com>
Date:   Thu Jun 26 16:06:35 2014 -0400

    2891: Fixup 7610ed34: Reorganize ApiError exceptions.

diff --git a/apps/workbench/app/models/arvados_api_client.rb b/apps/workbench/app/models/arvados_api_client.rb
index a079f56..f36627f 100644
--- a/apps/workbench/app/models/arvados_api_client.rb
+++ b/apps/workbench/app/models/arvados_api_client.rb
@@ -5,43 +5,40 @@ class ArvadosApiClient
   class ApiError < StandardError
     attr_reader :api_response, :api_response_s, :api_status, :request_url
 
-    def initialize(request_url, api_response)
+    def initialize(request_url, errmsg)
       @request_url = request_url
-      @api_status = api_response.status_code
-      @api_response_s = api_response.content
-      @api_response = parse_response
-      super("#{error_message} [API: #{@api_status}]")
+      @api_response ||= {}
+      super(errmsg)
     end
+  end
 
-    protected
 
-    def parse_response
-      Oj.load(@api_response_s, :symbol_keys => true)
+  class InvalidApiResponseException < ApiError
+    def initialize(request_url, api_response)
+      @api_status = api_response.status_code
+      @api_response_s = api_response.content
+      super(request_url, "Unparseable response from API server")
     end
+  end
 
-    def error_message
+  class ApiErrorResponseException < ApiError
+    def initialize(request_url, api_response)
+      @api_status = api_response.status_code
+      @api_response_s = api_response.content
+      @api_response = Oj.load(@api_response_s, :symbol_keys => true)
       errors = @api_response[:errors]
       if errors.respond_to?(:join)
-        errors.join("\n\n")
+        errors = errors.join("\n\n")
       else
-        errors.to_s
+        errors = errors.to_s
       end
+      super(request_url, "#{errors} [API: #{@api_status}]")
     end
   end
 
-  class InvalidApiResponseException < ApiError
-    def parse_response
-      {}  # We already know it's not parseable.
-    end
-
-    def error_message
-      "Unparseable response from API server"
-    end
-  end
-
-  class AccessForbiddenException < ApiError; end
-  class NotFoundException < ApiError; end
-  class NotLoggedInException < ApiError; end
+  class AccessForbiddenException < ApiErrorResponseException; end
+  class NotFoundException < ApiErrorResponseException; end
+  class NotLoggedInException < ApiErrorResponseException; end
 
   ERROR_CODE_CLASSES = {
     401 => NotLoggedInException,

commit 7ff482005f3715c3ca71b5a66c996c2ce45d3242
Author: Brett Smith <brett at curoverse.com>
Date:   Thu Jun 26 15:18:44 2014 -0400

    2891: Fixup 57d48418: Fix index link generation.

diff --git a/apps/workbench/app/views/application/404.html.erb b/apps/workbench/app/views/application/404.html.erb
index 658271f..8141039 100644
--- a/apps/workbench/app/views/application/404.html.erb
+++ b/apps/workbench/app/views/application/404.html.erb
@@ -3,9 +3,10 @@
 <p>The item you requested was not found.
 
 <% if params[:uuid] and (model_class = resource_class_for_uuid(params[:uuid]))
-     then class_name = model_class.to_s.pluralize.downcase %>
+     then class_name = model_class.to_s.underscore.pluralize %>
 Perhaps you'd like to
-<%= link_to("browse all #{class_name}", send("#{class_name}_path".to_sym)) %>?
+<%= link_to("browse all #{class_name.humanize(capitalize: false)}",
+            send("#{class_name}_path".to_sym)) %>?
 <% end %>
 
 </p>

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list