Updated notification mailer, to always store output messages.

Fixed CMS_RESPONSE, and specific error response, to return expected status code.
This commit is contained in:
2015-09-28 10:47:57 +02:00
parent 7b2e6ab7b4
commit ec53a2682b
8 changed files with 40 additions and 21 deletions
-1
View File
@@ -28,7 +28,6 @@ feature {NONE} -- Initialization
-- Initialize service. -- Initialize service.
do do
admin_email := parameters.admin_email admin_email := parameters.admin_email
create {NOTIFICATION_SMTP_MAILER} mailer.make (parameters.smtp_server) create {NOTIFICATION_SMTP_MAILER} mailer.make (parameters.smtp_server)
set_successful set_successful
end end
+19 -5
View File
@@ -86,13 +86,19 @@ feature -- Access
local local
retried: BOOLEAN retried: BOOLEAN
f: FILE f: FILE
l_chain: NOTIFICATION_CHAIN_MAILER
l_storage_mailer: NOTIFICATION_STORAGE_MAILER
l_mailer: detachable NOTIFICATION_MAILER
do do
if not retried then if not retried then
if attached text_item ("mailer.smtp") as l_smtp then if attached text_item ("mailer.smtp") as l_smtp then
create {NOTIFICATION_SMTP_MAILER} mailer.make (l_smtp) create {NOTIFICATION_SMTP_MAILER} l_mailer.make (l_smtp)
elseif attached text_item ("mailer.sendmail") as l_sendmail then elseif attached text_item ("mailer.sendmail") as l_sendmail then
create {NOTIFICATION_SENDMAIL_MAILER} mailer.make_with_location (l_sendmail) create {NOTIFICATION_SENDMAIL_MAILER} l_mailer.make_with_location (l_sendmail)
elseif attached text_item ("mailer.output") as l_output then end
-- If a mailer.ouput is set, set a notification chain with potential previous mailer
-- and file storage.
if attached text_item ("mailer.output") as l_output then
if l_output.is_case_insensitive_equal ("@stderr") then if l_output.is_case_insensitive_equal ("@stderr") then
f := io.error f := io.error
elseif l_output.is_case_insensitive_equal ("@stdout") then elseif l_output.is_case_insensitive_equal ("@stdout") then
@@ -104,10 +110,18 @@ feature -- Access
f.close f.close
end end
end end
create {NOTIFICATION_STORAGE_MAILER} mailer.make (create {NOTIFICATION_EMAIL_FILE_STORAGE}.make (f)) create {NOTIFICATION_STORAGE_MAILER} l_storage_mailer.make (create {NOTIFICATION_EMAIL_FILE_STORAGE}.make (f))
if l_mailer /= Void then
create l_chain.make (l_mailer)
l_chain.set_next (l_storage_mailer)
l_mailer := l_chain
else else
create {NOTIFICATION_STORAGE_MAILER} mailer.make (create {NOTIFICATION_EMAIL_FILE_STORAGE}.make (io.error)) l_mailer := l_storage_mailer
end end
elseif l_mailer = Void then
create {NOTIFICATION_STORAGE_MAILER} l_mailer.make (create {NOTIFICATION_EMAIL_FILE_STORAGE}.make (io.error))
end
mailer := l_mailer
else else
check valid_mailer: False end check valid_mailer: False end
-- FIXME: should we report persistent error message? If yes, see how. -- FIXME: should we report persistent error message? If yes, see how.
+5 -4
View File
@@ -995,6 +995,7 @@ feature {NONE} -- Execution
page: CMS_HTML_PAGE_RESPONSE page: CMS_HTML_PAGE_RESPONSE
utf: UTF_CONVERTER utf: UTF_CONVERTER
h: HTTP_HEADER h: HTTP_HEADER
l_new_location: READABLE_STRING_8
do do
if attached {READABLE_STRING_GENERAL} values.item ("optional_content_type") as l_type then if attached {READABLE_STRING_GENERAL} values.item ("optional_content_type") as l_type then
create cms_page.make_typed (utf.utf_32_string_to_utf_8_string_8 (l_type)) create cms_page.make_typed (utf.utf_32_string_to_utf_8_string_8 (l_type))
@@ -1010,12 +1011,12 @@ feature {NONE} -- Execution
if attached redirection as l_location then if attached redirection as l_location then
-- FIXME: find out if this is safe or not. -- FIXME: find out if this is safe or not.
if l_location.has_substring ("://") then if l_location.has_substring ("://") then
-- h.put_location (l_location) l_new_location := l_location
response.redirect_now (l_location)
else else
-- h.put_location (request.absolute_url (l_location, Void)) l_new_location := absolute_url (l_location, Void)
response.redirect_now (absolute_url (l_location, Void))
end end
-- h.put_location (l_new_location)
response.redirect_now (l_new_location)
else else
h.put_header_object (header) h.put_header_object (header)
@@ -20,9 +20,10 @@ feature -- Generation
custom_prepare (page: CMS_HTML_PAGE) custom_prepare (page: CMS_HTML_PAGE)
do do
set_status_code ({HTTP_STATUS_CODE}.bad_request)
page.register_variable (absolute_url (request.percent_encoded_path_info, Void), "request") page.register_variable (absolute_url (request.percent_encoded_path_info, Void), "request")
page.set_status_code ({HTTP_STATUS_CODE}.bad_request) page.set_status_code (status_code)
page.register_variable (page.status_code.out, "code") page.register_variable (status_code.out, "code")
end end
feature -- Execution feature -- Execution
@@ -20,9 +20,10 @@ feature -- Generation
custom_prepare (page: CMS_HTML_PAGE) custom_prepare (page: CMS_HTML_PAGE)
do do
set_status_code ({HTTP_STATUS_CODE}.forbidden)
page.register_variable (absolute_url (request.percent_encoded_path_info, Void), "request") page.register_variable (absolute_url (request.percent_encoded_path_info, Void), "request")
page.set_status_code ({HTTP_STATUS_CODE}.forbidden) page.set_status_code (status_code)
page.register_variable (page.status_code.out, "code") page.register_variable (status_code.out, "code")
end end
feature -- Execution feature -- Execution
@@ -20,9 +20,10 @@ feature -- Generation
custom_prepare (page: CMS_HTML_PAGE) custom_prepare (page: CMS_HTML_PAGE)
do do
set_status_code ({HTTP_STATUS_CODE}.internal_server_error)
page.register_variable (absolute_url (location, Void), "request") page.register_variable (absolute_url (location, Void), "request")
page.set_status_code ({HTTP_STATUS_CODE}.internal_server_error) page.set_status_code (status_code)
page.register_variable (page.status_code.out, "code") page.register_variable (status_code.out, "code")
end end
feature -- Execution feature -- Execution
@@ -20,9 +20,10 @@ feature -- Generation
custom_prepare (page: CMS_HTML_PAGE) custom_prepare (page: CMS_HTML_PAGE)
do do
set_status_code ({HTTP_STATUS_CODE}.not_found)
page.register_variable (absolute_url (request.percent_encoded_path_info, Void), "request") page.register_variable (absolute_url (request.percent_encoded_path_info, Void), "request")
page.set_status_code ({HTTP_STATUS_CODE}.not_found) page.set_status_code (status_code)
page.register_variable (page.status_code.out, "code") page.register_variable (status_code.out, "code")
end end
feature -- Execution feature -- Execution
@@ -20,9 +20,10 @@ feature -- Generation
custom_prepare (page: CMS_HTML_PAGE) custom_prepare (page: CMS_HTML_PAGE)
do do
set_status_code ({HTTP_STATUS_CODE}.not_implemented)
page.register_variable (absolute_url (request.percent_encoded_path_info, Void), "request") page.register_variable (absolute_url (request.percent_encoded_path_info, Void), "request")
page.set_status_code ({HTTP_STATUS_CODE}.not_implemented) page.set_status_code (status_code)
page.register_variable (page.status_code.out, "code") page.register_variable (status_code.out, "code")
end end
feature -- Execution feature -- Execution