From 5477bab83cd17b1eb8a22a5e003249cca3d98fc2 Mon Sep 17 00:00:00 2001 From: Jocelyn Fiat Date: Fri, 10 Jul 2015 12:20:28 +0200 Subject: [PATCH] Added error handler argument in CMS_STORAGE_BUILDER.storage (...) function. Removed testing purpose code. Update debug module. --- .../src/cms_storage_store_mysql_builder.e | 4 ++- .../src/cms_storage_store_odbc_builder.e | 4 ++- src/configuration/cms_setup.e | 2 +- src/modules/cms_debug_module.e | 9 +++-- src/persistence/cms_storage_builder.e | 5 ++- src/persistence/cms_storage_null_builder.e | 5 ++- src/persistence/sql/cms_storage_sql_builder.e | 34 ++----------------- src/service/cms_api.e | 5 +-- 8 files changed, 25 insertions(+), 43 deletions(-) diff --git a/library/persistence/store_mysql/src/cms_storage_store_mysql_builder.e b/library/persistence/store_mysql/src/cms_storage_store_mysql_builder.e index b3af541..21cdec6 100644 --- a/library/persistence/store_mysql/src/cms_storage_store_mysql_builder.e +++ b/library/persistence/store_mysql/src/cms_storage_store_mysql_builder.e @@ -26,7 +26,7 @@ feature {NONE} -- Initialization feature -- Factory - storage (a_setup: CMS_SETUP): detachable CMS_STORAGE_STORE_MYSQL + storage (a_setup: CMS_SETUP; a_error_handler: ERROR_HANDLER): detachable CMS_STORAGE_STORE_MYSQL local conn: DATABASE_CONNECTION do @@ -40,6 +40,8 @@ feature -- Factory initialize (a_setup, Result) end end + else + a_error_handler.add_custom_error (0, "Could not connect to the MySQL storage", Void) end end end diff --git a/library/persistence/store_odbc/src/cms_storage_store_odbc_builder.e b/library/persistence/store_odbc/src/cms_storage_store_odbc_builder.e index ba65841..80f9630 100644 --- a/library/persistence/store_odbc/src/cms_storage_store_odbc_builder.e +++ b/library/persistence/store_odbc/src/cms_storage_store_odbc_builder.e @@ -26,7 +26,7 @@ feature {NONE} -- Initialization feature -- Factory - storage (a_setup: CMS_SETUP): detachable CMS_STORAGE_STORE_ODBC + storage (a_setup: CMS_SETUP; a_error_handler: ERROR_HANDLER): detachable CMS_STORAGE_STORE_ODBC local s: detachable STRING conn: detachable DATABASE_CONNECTION @@ -53,6 +53,8 @@ feature -- Factory initialize (a_setup, Result) end end + else + a_error_handler.add_custom_error (0, "Could not connect to the ODBC storage", Void) end else -- Wrong mapping between storage name and storage builder! diff --git a/src/configuration/cms_setup.e b/src/configuration/cms_setup.e index a2a6c2f..51e6cbd 100644 --- a/src/configuration/cms_setup.e +++ b/src/configuration/cms_setup.e @@ -145,7 +145,7 @@ feature -- Access: storage attached (create {APPLICATION_JSON_CONFIGURATION_HELPER}).new_database_configuration (environment.application_config_path) as l_database_config and then attached storage_drivers.item (l_database_config.driver) as l_builder then - Result := l_builder.storage (Current) + Result := l_builder.storage (Current, a_error_handler) end else to_implement ("Workaround code, persistence layer does not implement yet this kind of error handling.") diff --git a/src/modules/cms_debug_module.e b/src/modules/cms_debug_module.e index b0938c7..d08987d 100644 --- a/src/modules/cms_debug_module.e +++ b/src/modules/cms_debug_module.e @@ -71,6 +71,7 @@ feature -- Hooks create dbg.make create s.make_empty dbg.append_information_to (a_response.request, a_response.response, s) + append_info_to ("Storage", a_response.api.storage.generator, a_response, s) create b.make ("debug-info", "Debug", s, a_response.formats.plain_text) a_response.add_block (b, "footer") end @@ -102,15 +103,17 @@ feature -- Handler -- append_info_to ("Base url", cms.base_url, r, s) -- append_info_to ("Script url", cms.script_url, r, s) s.append ("
") - append_info_to ("Site dir", api.setup.environment.path.utf_8_name, r, s) + append_info_to ("Site dir", api.site_location.utf_8_name, r, s) append_info_to ("Www dir", api.setup.environment.www_path.utf_8_name, r, s) append_info_to ("Assets dir", api.setup.environment.assets_path.utf_8_name, r, s) append_info_to ("Config dir", api.setup.environment.config_path.utf_8_name, r, s) s.append ("
") append_info_to ("Theme", api.setup.theme_name, r, s) - append_info_to ("Theme location", api.setup.themes_location.utf_8_name, r, s) + append_info_to ("Theme location", api.theme_location.utf_8_name, r, s) s.append ("
") --- append_info_to ("Files location", api...files_location.utf_8_name, r, s) + append_info_to ("Files location", api.files_location.utf_8_name, r, s) + append_info_to ("Modules location", api.modules_location.utf_8_name, r, s) + append_info_to ("Storage", api.storage.generator, r, s) -- s.append ("
") append_info_to ("Url", r.url ("/", Void), r, s) diff --git a/src/persistence/cms_storage_builder.e b/src/persistence/cms_storage_builder.e index 3200547..22460db 100644 --- a/src/persistence/cms_storage_builder.e +++ b/src/persistence/cms_storage_builder.e @@ -11,9 +11,12 @@ deferred class feature -- Factory - storage (a_setup: CMS_SETUP): detachable CMS_STORAGE + storage (a_setup: CMS_SETUP; a_error_handler: ERROR_HANDLER): detachable CMS_STORAGE -- CMS Storage object based on CMS setup `a_setup'. deferred end +note + copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Eiffel Software and others" + license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" end diff --git a/src/persistence/cms_storage_null_builder.e b/src/persistence/cms_storage_null_builder.e index 3bfae86..6dd4780 100644 --- a/src/persistence/cms_storage_null_builder.e +++ b/src/persistence/cms_storage_null_builder.e @@ -14,9 +14,12 @@ inherit feature -- Factory - storage (a_setup: CMS_SETUP): detachable CMS_STORAGE_NULL + storage (a_setup: CMS_SETUP; a_error_handler: ERROR_HANDLER): detachable CMS_STORAGE_NULL do create Result end +note + copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Eiffel Software and others" + license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" end diff --git a/src/persistence/sql/cms_storage_sql_builder.e b/src/persistence/sql/cms_storage_sql_builder.e index cf62f76..d6a674b 100644 --- a/src/persistence/sql/cms_storage_sql_builder.e +++ b/src/persistence/sql/cms_storage_sql_builder.e @@ -59,37 +59,9 @@ feature -- Initialization l_authenticated_role.add_permission ("trash own page") a_storage.save_user_role (l_authenticated_role) - - --|-------------------------------------------|-- - --| For testing purpose, to be removed later. |-- - --|-------------------------------------------|-- - - -- Roles, view role for testing. - create r.make ("view") - r.add_permission ("view any page") - a_storage.save_user_role (r) - - create {ARRAYED_LIST [CMS_USER_ROLE]} l_roles.make (1) - l_roles.force (r) - - create u.make ("auth") - u.set_password ("enticated#") - u.set_email (a_setup.site_email) - u.set_status ({CMS_USER}.active) - a_storage.new_user (u) - - create u.make ("test") - u.set_password ("test#") - u.set_email (a_setup.site_email) - u.set_status ({CMS_USER}.active) - a_storage.new_user (u) - - create u.make ("view") - u.set_password ("only#") - u.set_email (a_setup.site_email) - u.set_status ({CMS_USER}.active) - u.set_roles (l_roles) - a_storage.new_user (u) end +note + copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Eiffel Software and others" + license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" end diff --git a/src/service/cms_api.e b/src/service/cms_api.e index 59f8686..7235519 100644 --- a/src/service/cms_api.e +++ b/src/service/cms_api.e @@ -407,15 +407,12 @@ feature -- Environment/ theme Result := theme_location.extended ("assets") end -feature -- Environment/ module - feature -- Environment/ module module_configuration_by_name (a_module_name: READABLE_STRING_GENERAL; a_name: detachable READABLE_STRING_GENERAL): detachable CONFIG_READER -- Configuration reader for `a_module', and if `a_name' is set, using name `a_name'. local - p, l_path: detachable PATH - l_name: READABLE_STRING_GENERAL + p: detachable PATH do -- Search first in site/config/modules/$module_name/($app|$module_name).(json|ini) -- if none, look as sub configuration if $app /= Void