lib/fiona7/routers/rest_api.rb in infopark_fiona7-1.2.0.2.3 vs lib/fiona7/routers/rest_api.rb in infopark_fiona7-1.5.2.0.0

- old
+ new

@@ -1,9 +1,12 @@ require "fiona7/controllers/rest_api/obj_controller" require "fiona7/controllers/rest_api/blob_controller" require "fiona7/controllers/rest_api/workspace_controller" +require "fiona7/controllers/rest_api/session_controller" +require "fiona7/controllers/rest_api/error_handler" + class Scrivito::CmsRestApi class << self alias_method :original_task_unaware_request, :task_unaware_request def task_unaware_request(method, resource_path, payload = nil) raise "Unexpected method #{method}" unless [:delete, :get, :post, :put].include?(method) @@ -50,10 +53,13 @@ _, _, workspace_id = *resource_path.split("/") Fiona7::Controllers::RestAPI::WorkspaceController.new.fetch(workspace_id) when /\A\/?workspaces\/[a-zA-Z0-9_-]+\/changes\Z/ _, _, workspace_id,_ = *resource_path.split("/") Fiona7::Controllers::RestAPI::WorkspaceController.new.changes(workspace_id) + when /\A\/?workspaces\/[a-zA-Z0-9_-]+\/objs\/mget+\Z/ + _, _, workspace_id, _, _ = *resource_path.split("/") + Fiona7::Controllers::RestAPI::ObjController.new.fetch_multiple2(workspace_id, payload) when /\A\/?workspaces\/[a-zA-Z0-9_-]+\/objs\/[a-zA-Z0-9_-]+\Z/ _, _, workspace_id, _, obj_id = *resource_path.split("/") Fiona7::Controllers::RestAPI::ObjController.new.fetch_by_id(workspace_id, obj_id) when /\A\/?blobs\/[a-zA-Z0-9_-]+\Z/ _, _, blob_id = *resource_path.split("/") @@ -69,10 +75,12 @@ Fiona7::Controllers::RestAPI::BlobController.new.metadata(blob_id) else original_get(resource_path, payload, options||{}) end end + rescue *Fiona7::ErrorHandler::HANDLED_ERRORS => e + raise Fiona7::ErrorHandler.new(e).sdk_error end alias_method :original_delete, :delete def delete(resource_path, payload = nil, options = nil) @number_of_requests += 1 if resource_path == @count_requests @@ -92,10 +100,12 @@ _, _, workspace_id, _, obj_id = *resource_path.split("/") Fiona7::Controllers::RestAPI::ObjController.new.destroy(workspace_id, obj_id) else original_delete(resource_path, payload, options||{}) end + rescue *Fiona7::ErrorHandler::HANDLED_ERRORS => e + raise Fiona7::ErrorHandler.new(e).sdk_error end alias_method :original_post, :post def post(resource_path, payload, options = nil) @number_of_requests += 1 if resource_path == @count_requests @@ -112,10 +122,12 @@ _, _, workspace_id = *resource_path.split("/") Fiona7::Controllers::RestAPI::ObjController.new.create(workspace_id, payload) else original_post(resource_path, payload, options||{}) end + rescue *Fiona7::ErrorHandler::HANDLED_ERRORS => e + raise Fiona7::ErrorHandler.new(e).sdk_error end alias_method :original_put, :put def put(resource_path, payload, options = nil) @number_of_requests += 1 if resource_path == @count_requests @@ -141,11 +153,16 @@ _, _, workspace_id = *resource_path.split("/") Fiona7::Controllers::RestAPI::WorkspaceController.new.update(workspace_id) when /\A\/?blobs\/[a-zA-Z0-9]+\/copy/ _, _, blob_id, _ = * resource_path.split("/") Fiona7::Controllers::RestAPI::BlobController.new.copy(blob_id, payload) + when /\A\/?sessions\/[a-zA-Z0-9]+/ + _, _, session_id = *resource_path.split("/") + Fiona7::Controllers::RestAPI::SessionController.new.update(session_id, payload) else original_put(resource_path, payload, options||{}) end + rescue *Fiona7::ErrorHandler::HANDLED_ERRORS => e + raise Fiona7::ErrorHandler.new(e).sdk_error end end end