From 9169bdcd43b26a52701132925fdc8839ae0b01f7 Mon Sep 17 00:00:00 2001 From: jvelilla Date: Wed, 19 Nov 2014 09:22:31 -0300 Subject: [PATCH] Removed shared_error from CMS_API Added Missing theme and Missing tempalte classes. Updated CMS_RESPONSE to handle missing template and send a 503 status code with a raw response. --- library/src/service/cms_api.e | 3 -- library/src/service/filter/cms_error_filter.e | 1 + library/src/service/response/cms_response.e | 5 ++- .../missing_theme/missing_cms_template.e | 42 +++++++++++++++++ .../theme/missing_theme/missing_cms_theme.e | 45 +++++++++++++++++++ 5 files changed, 91 insertions(+), 5 deletions(-) create mode 100644 library/src/theme/missing_theme/missing_cms_template.e create mode 100644 library/src/theme/missing_theme/missing_cms_theme.e diff --git a/library/src/service/cms_api.e b/library/src/service/cms_api.e index 34bec4b..39d8e6e 100644 --- a/library/src/service/cms_api.e +++ b/library/src/service/cms_api.e @@ -8,8 +8,6 @@ class inherit - SHARED_ERROR - REFACTORING_HELPER create @@ -23,7 +21,6 @@ feature -- Initialize setup := a_setup create error_handler.make initialize - set_successful ensure setup_set: setup = a_setup error_handler_set: not error_handler.has_error diff --git a/library/src/service/filter/cms_error_filter.e b/library/src/service/filter/cms_error_filter.e index 2c8c780..ffef78f 100644 --- a/library/src/service/filter/cms_error_filter.e +++ b/library/src/service/filter/cms_error_filter.e @@ -20,6 +20,7 @@ feature -- Basic operations execute (req: WSF_REQUEST; res: WSF_RESPONSE) -- Execute the filter do + fixme ("Check if it's ok to add new fetures CMS_API.has_error:BOOLEAN and CMS_API.error_description.") if not api.error_handler.has_error then log.write_information (generator + ".execute") execute_next (req, res) diff --git a/library/src/service/response/cms_response.e b/library/src/service/response/cms_response.e index 91ee6d0..7cc43f2 100644 --- a/library/src/service/response/cms_response.e +++ b/library/src/service/response/cms_response.e @@ -740,8 +740,9 @@ feature -- Theme if l_info.engine.is_case_insensitive_equal_general ("smarty") then create {SMARTY_CMS_THEME} theme.make (setup, l_info) else - to_implement ("Add a default SMARTY_CMS_THEME") - create {SMARTY_CMS_THEME} theme.make (setup, l_info) + create {MISSING_CMS_THEME} theme.make (setup) + status_code := {HTTP_STATUS_CODE}.service_unavailable + to_implement ("Check how to add the Retry-after, http://tools.ietf.org/html/rfc7231#section-6.6.4 and http://tools.ietf.org/html/rfc7231#section-7.1.3") end end diff --git a/library/src/theme/missing_theme/missing_cms_template.e b/library/src/theme/missing_theme/missing_cms_template.e new file mode 100644 index 0000000..a0d36cb --- /dev/null +++ b/library/src/theme/missing_theme/missing_cms_template.e @@ -0,0 +1,42 @@ +note + description: "Summary description for {MISSING_CMS_TEMPLATE}." + author: "" + date: "$Date$" + revision: "$Revision$" + +class + MISSING_CMS_TEMPLATE + +inherit + + CMS_TEMPLATE + +create + make + +feature {NONE} -- Implementation + + make ( a_theme: MISSING_CMS_THEME) + do + theme := a_theme + end + +feature -- Access + + theme: MISSING_CMS_THEME + + variables: STRING_TABLE [detachable ANY] + do + create Result.make (0) + end + + prepare (page: CMS_HTML_PAGE) + do + end + + to_html (page: CMS_HTML_PAGE): STRING + do + Result := " " + end + +end diff --git a/library/src/theme/missing_theme/missing_cms_theme.e b/library/src/theme/missing_theme/missing_cms_theme.e new file mode 100644 index 0000000..c780854 --- /dev/null +++ b/library/src/theme/missing_theme/missing_cms_theme.e @@ -0,0 +1,45 @@ +note + description: "Describe a missing theme." + date: "$Date$" + revision: "$Revision$" + +class + MISSING_CMS_THEME + +inherit + + CMS_THEME + +create + make + +feature {NONE} -- Initialization + + make (a_setup: like setup) + do + setup := a_setup + ensure + setup_set: setup = a_setup + end + +feature -- Access + + name: STRING = "missing theme" + + regions: ARRAY [STRING] + do + create Result.make_empty + end + + page_template: CMS_TEMPLATE + -- theme template page. + do + create {MISSING_CMS_TEMPLATE} Result.make (Current) + end + + page_html (page: CMS_HTML_PAGE): STRING_8 + do + to_implement ("Add a better response message, maybe using smarty template") + Result := "Service Unavailable" + end +end