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:
@@ -28,7 +28,6 @@ feature {NONE} -- Initialization
|
||||
-- Initialize service.
|
||||
do
|
||||
admin_email := parameters.admin_email
|
||||
|
||||
create {NOTIFICATION_SMTP_MAILER} mailer.make (parameters.smtp_server)
|
||||
set_successful
|
||||
end
|
||||
|
||||
@@ -86,13 +86,19 @@ feature -- Access
|
||||
local
|
||||
retried: BOOLEAN
|
||||
f: FILE
|
||||
l_chain: NOTIFICATION_CHAIN_MAILER
|
||||
l_storage_mailer: NOTIFICATION_STORAGE_MAILER
|
||||
l_mailer: detachable NOTIFICATION_MAILER
|
||||
do
|
||||
if not retried 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
|
||||
create {NOTIFICATION_SENDMAIL_MAILER} mailer.make_with_location (l_sendmail)
|
||||
elseif attached text_item ("mailer.output") as l_output then
|
||||
create {NOTIFICATION_SENDMAIL_MAILER} l_mailer.make_with_location (l_sendmail)
|
||||
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
|
||||
f := io.error
|
||||
elseif l_output.is_case_insensitive_equal ("@stdout") then
|
||||
@@ -104,10 +110,18 @@ feature -- Access
|
||||
f.close
|
||||
end
|
||||
end
|
||||
create {NOTIFICATION_STORAGE_MAILER} mailer.make (create {NOTIFICATION_EMAIL_FILE_STORAGE}.make (f))
|
||||
else
|
||||
create {NOTIFICATION_STORAGE_MAILER} mailer.make (create {NOTIFICATION_EMAIL_FILE_STORAGE}.make (io.error))
|
||||
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
|
||||
l_mailer := l_storage_mailer
|
||||
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
|
||||
check valid_mailer: False end
|
||||
-- FIXME: should we report persistent error message? If yes, see how.
|
||||
|
||||
@@ -995,6 +995,7 @@ feature {NONE} -- Execution
|
||||
page: CMS_HTML_PAGE_RESPONSE
|
||||
utf: UTF_CONVERTER
|
||||
h: HTTP_HEADER
|
||||
l_new_location: READABLE_STRING_8
|
||||
do
|
||||
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))
|
||||
@@ -1010,12 +1011,12 @@ feature {NONE} -- Execution
|
||||
if attached redirection as l_location then
|
||||
-- FIXME: find out if this is safe or not.
|
||||
if l_location.has_substring ("://") then
|
||||
-- h.put_location (l_location)
|
||||
response.redirect_now (l_location)
|
||||
l_new_location := l_location
|
||||
else
|
||||
-- h.put_location (request.absolute_url (l_location, Void))
|
||||
response.redirect_now (absolute_url (l_location, Void))
|
||||
l_new_location := absolute_url (l_location, Void)
|
||||
end
|
||||
-- h.put_location (l_new_location)
|
||||
response.redirect_now (l_new_location)
|
||||
else
|
||||
h.put_header_object (header)
|
||||
|
||||
|
||||
@@ -20,9 +20,10 @@ feature -- Generation
|
||||
|
||||
custom_prepare (page: CMS_HTML_PAGE)
|
||||
do
|
||||
set_status_code ({HTTP_STATUS_CODE}.bad_request)
|
||||
page.register_variable (absolute_url (request.percent_encoded_path_info, Void), "request")
|
||||
page.set_status_code ({HTTP_STATUS_CODE}.bad_request)
|
||||
page.register_variable (page.status_code.out, "code")
|
||||
page.set_status_code (status_code)
|
||||
page.register_variable (status_code.out, "code")
|
||||
end
|
||||
|
||||
feature -- Execution
|
||||
|
||||
@@ -20,9 +20,10 @@ feature -- Generation
|
||||
|
||||
custom_prepare (page: CMS_HTML_PAGE)
|
||||
do
|
||||
set_status_code ({HTTP_STATUS_CODE}.forbidden)
|
||||
page.register_variable (absolute_url (request.percent_encoded_path_info, Void), "request")
|
||||
page.set_status_code ({HTTP_STATUS_CODE}.forbidden)
|
||||
page.register_variable (page.status_code.out, "code")
|
||||
page.set_status_code (status_code)
|
||||
page.register_variable (status_code.out, "code")
|
||||
end
|
||||
|
||||
feature -- Execution
|
||||
|
||||
@@ -20,9 +20,10 @@ feature -- Generation
|
||||
|
||||
custom_prepare (page: CMS_HTML_PAGE)
|
||||
do
|
||||
set_status_code ({HTTP_STATUS_CODE}.internal_server_error)
|
||||
page.register_variable (absolute_url (location, Void), "request")
|
||||
page.set_status_code ({HTTP_STATUS_CODE}.internal_server_error)
|
||||
page.register_variable (page.status_code.out, "code")
|
||||
page.set_status_code (status_code)
|
||||
page.register_variable (status_code.out, "code")
|
||||
end
|
||||
|
||||
feature -- Execution
|
||||
|
||||
@@ -20,9 +20,10 @@ feature -- Generation
|
||||
|
||||
custom_prepare (page: CMS_HTML_PAGE)
|
||||
do
|
||||
set_status_code ({HTTP_STATUS_CODE}.not_found)
|
||||
page.register_variable (absolute_url (request.percent_encoded_path_info, Void), "request")
|
||||
page.set_status_code ({HTTP_STATUS_CODE}.not_found)
|
||||
page.register_variable (page.status_code.out, "code")
|
||||
page.set_status_code (status_code)
|
||||
page.register_variable (status_code.out, "code")
|
||||
end
|
||||
|
||||
feature -- Execution
|
||||
|
||||
@@ -20,9 +20,10 @@ feature -- Generation
|
||||
|
||||
custom_prepare (page: CMS_HTML_PAGE)
|
||||
do
|
||||
set_status_code ({HTTP_STATUS_CODE}.not_implemented)
|
||||
page.register_variable (absolute_url (request.percent_encoded_path_info, Void), "request")
|
||||
page.set_status_code ({HTTP_STATUS_CODE}.not_implemented)
|
||||
page.register_variable (page.status_code.out, "code")
|
||||
page.set_status_code (status_code)
|
||||
page.register_variable (status_code.out, "code")
|
||||
end
|
||||
|
||||
feature -- Execution
|
||||
|
||||
Reference in New Issue
Block a user