Merge branch 'jocelyn-jfiat'
This commit is contained in:
@@ -1,10 +1,13 @@
|
|||||||
{
|
{
|
||||||
"database": {
|
"database": {
|
||||||
"datasource": {
|
"datasource": {
|
||||||
"driver": "MySQL",
|
"driver": "sqlite",
|
||||||
"environment": "development"
|
"environment": "sqlite"
|
||||||
},
|
},
|
||||||
"environments": {
|
"environments": {
|
||||||
|
"sqlite": {
|
||||||
|
"connection_string":"Driver=SQLite3 ODBC Driver;Database=./site/database.sqlite;LongNames=0;Timeout=1000;NoTXN=0;SyncPragma=NORMAL;StepAPI=0;"
|
||||||
|
},
|
||||||
"test": {
|
"test": {
|
||||||
"connection_string":"Server=localhost;Port=3306;Database=cms_dev;Uid=root;Pwd=;"
|
"connection_string":"Server=localhost;Port=3306;Database=cms_dev;Uid=root;Pwd=;"
|
||||||
},
|
},
|
||||||
@@ -29,4 +32,4 @@
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ feature {NONE} -- Launch operation
|
|||||||
l_message: STRING
|
l_message: STRING
|
||||||
do
|
do
|
||||||
if not l_retry then
|
if not l_retry then
|
||||||
log.write_debug (generator + ".launch")
|
write_debug_log (generator + ".launch")
|
||||||
launcher.launch (a_service, opts)
|
launcher.launch (a_service, opts)
|
||||||
else
|
else
|
||||||
-- error hanling.
|
-- error hanling.
|
||||||
@@ -92,7 +92,7 @@ feature {NONE} -- Launch operation
|
|||||||
l_message.append ("%N%N")
|
l_message.append ("%N%N")
|
||||||
end
|
end
|
||||||
-- send email shutdown
|
-- send email shutdown
|
||||||
log.write_debug (generator + ".launch shutdown")
|
write_debug_log (generator + ".launch shutdown")
|
||||||
end
|
end
|
||||||
rescue
|
rescue
|
||||||
l_retry := True
|
l_retry := True
|
||||||
@@ -111,7 +111,7 @@ feature -- CMS Initialization
|
|||||||
create layout.make_default
|
create layout.make_default
|
||||||
end
|
end
|
||||||
initialize_logger (layout)
|
initialize_logger (layout)
|
||||||
log.write_debug (generator + ".cms_setup based directory %"" + utf.escaped_utf_32_string_to_utf_8_string_8 (layout.path.name) + "%"")
|
write_debug_log (generator + ".cms_setup based directory %"" + utf.escaped_utf_32_string_to_utf_8_string_8 (layout.path.name) + "%"")
|
||||||
create Result.make (layout)
|
create Result.make (layout)
|
||||||
setup_storage (Result)
|
setup_storage (Result)
|
||||||
end
|
end
|
||||||
@@ -121,7 +121,7 @@ feature -- CMS Initialization
|
|||||||
cms: CMS_SERVICE
|
cms: CMS_SERVICE
|
||||||
api: CMS_API
|
api: CMS_API
|
||||||
do
|
do
|
||||||
log.write_debug (generator + ".initialize_cms")
|
write_debug_log (generator + ".initialize_cms")
|
||||||
setup_modules (a_setup)
|
setup_modules (a_setup)
|
||||||
create api.make (a_setup)
|
create api.make (a_setup)
|
||||||
create cms.make (api)
|
create cms.make (api)
|
||||||
|
|||||||
@@ -56,10 +56,10 @@ feature -- Element Settings
|
|||||||
l_message.append ("An unknown exception was raised.")
|
l_message.append ("An unknown exception was raised.")
|
||||||
end
|
end
|
||||||
set_last_error (l_message, a_location)
|
set_last_error (l_message, a_location)
|
||||||
log.write_critical (generator + ".set_last_error_from_exception " + l_message)
|
write_critical_log (generator + ".set_last_error_from_exception " + l_message)
|
||||||
else
|
else
|
||||||
set_last_error ("Generic error", "")
|
set_last_error ("Generic error", "")
|
||||||
log.write_critical (generator + ".set_last_error_from_exception Generic Error")
|
write_critical_log (generator + ".set_last_error_from_exception Generic Error")
|
||||||
end
|
end
|
||||||
rescue
|
rescue
|
||||||
l_retried := True
|
l_retried := True
|
||||||
@@ -75,7 +75,7 @@ feature -- Element Settings
|
|||||||
attached_location: a_location /= Void
|
attached_location: a_location /= Void
|
||||||
do
|
do
|
||||||
create last_error.make (a_message, a_location)
|
create last_error.make (a_message, a_location)
|
||||||
log.write_critical (generator + ".set_last_error " + a_message)
|
write_critical_log (generator + ".set_last_error " + a_message)
|
||||||
successful := False
|
successful := False
|
||||||
ensure
|
ensure
|
||||||
last_error_set: attached last_error
|
last_error_set: attached last_error
|
||||||
@@ -103,6 +103,6 @@ feature -- Element Settings
|
|||||||
successful: successful
|
successful: successful
|
||||||
end
|
end
|
||||||
note
|
note
|
||||||
copyright: "2011-2014, Javier Velilla, Jocelyn Fiat, Eiffel Software and others"
|
copyright: "2011-2015, Javier Velilla, Jocelyn Fiat, Eiffel Software and others"
|
||||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||||
end
|
end
|
||||||
|
|||||||
172
library/layout/src/logger/logger.e
Normal file
172
library/layout/src/logger/logger.e
Normal file
@@ -0,0 +1,172 @@
|
|||||||
|
note
|
||||||
|
description: "Summary description for {LOGGER}."
|
||||||
|
author: ""
|
||||||
|
date: "$Date$"
|
||||||
|
revision: "$Revision$"
|
||||||
|
|
||||||
|
class
|
||||||
|
LOGGER
|
||||||
|
|
||||||
|
inherit
|
||||||
|
ANY
|
||||||
|
|
||||||
|
LOG_PRIORITY_CONSTANTS
|
||||||
|
export
|
||||||
|
{NONE} all
|
||||||
|
end
|
||||||
|
|
||||||
|
SHARED_EXECUTION_ENVIRONMENT
|
||||||
|
export
|
||||||
|
{NONE} all
|
||||||
|
end
|
||||||
|
|
||||||
|
create
|
||||||
|
make,
|
||||||
|
make_with_layout
|
||||||
|
|
||||||
|
feature {NONE} -- Initialization
|
||||||
|
|
||||||
|
make
|
||||||
|
do
|
||||||
|
create log.make
|
||||||
|
end
|
||||||
|
|
||||||
|
make_with_layout (app: APPLICATION_LAYOUT)
|
||||||
|
do
|
||||||
|
make
|
||||||
|
apply_layout (app)
|
||||||
|
end
|
||||||
|
|
||||||
|
feature -- Change
|
||||||
|
|
||||||
|
apply_layout (app: APPLICATION_LAYOUT)
|
||||||
|
do
|
||||||
|
initialize_logger (app, log)
|
||||||
|
end
|
||||||
|
|
||||||
|
feature {NONE} -- Internal
|
||||||
|
|
||||||
|
log: LOGGING_FACILITY
|
||||||
|
|
||||||
|
feature -- Logging
|
||||||
|
|
||||||
|
put_information (a_message: separate READABLE_STRING_8)
|
||||||
|
do
|
||||||
|
log.write_information (create {STRING}.make_from_separate (a_message))
|
||||||
|
end
|
||||||
|
|
||||||
|
put_error (a_message: separate READABLE_STRING_8)
|
||||||
|
do
|
||||||
|
log.write_error (create {STRING}.make_from_separate (a_message))
|
||||||
|
end
|
||||||
|
|
||||||
|
put_warning (a_message: separate READABLE_STRING_8)
|
||||||
|
do
|
||||||
|
log.write_warning (create {STRING}.make_from_separate (a_message))
|
||||||
|
end
|
||||||
|
|
||||||
|
put_critical (a_message: separate READABLE_STRING_8)
|
||||||
|
do
|
||||||
|
log.write_critical (create {STRING}.make_from_separate (a_message))
|
||||||
|
end
|
||||||
|
|
||||||
|
put_alert (a_message: separate READABLE_STRING_8)
|
||||||
|
do
|
||||||
|
log.write_alert (create {STRING}.make_from_separate (a_message))
|
||||||
|
end
|
||||||
|
|
||||||
|
put_debug (a_message: separate READABLE_STRING_8)
|
||||||
|
do
|
||||||
|
log.write_debug (create {STRING}.make_from_separate (a_message))
|
||||||
|
end
|
||||||
|
|
||||||
|
feature {NONE} -- Implementation
|
||||||
|
|
||||||
|
initialize_logger (app: APPLICATION_LAYOUT; a_log: like log)
|
||||||
|
local
|
||||||
|
l_log_writer_file: LOG_ROLLING_WRITER_FILE
|
||||||
|
l_log_writer: LOG_WRITER
|
||||||
|
l_logs_path: detachable PATH
|
||||||
|
l_logger_config: LOGGER_CONFIGURATION
|
||||||
|
ut: FILE_UTILITIES
|
||||||
|
do
|
||||||
|
l_logger_config := new_logger_level_configuration (app.application_config_path)
|
||||||
|
l_logs_path := l_logger_config.location
|
||||||
|
if l_logs_path = Void then
|
||||||
|
l_logs_path := app.logs_path
|
||||||
|
end
|
||||||
|
if ut.directory_path_exists (l_logs_path) then
|
||||||
|
create l_log_writer_file.make_at_location (l_logs_path.extended (app.name).appended_with_extension ("log"))
|
||||||
|
l_log_writer_file.set_max_file_size ({NATURAL_64} 1024 * 1204)
|
||||||
|
l_log_writer_file.set_max_backup_count (l_logger_config.backup_count)
|
||||||
|
l_log_writer := l_log_writer_file
|
||||||
|
else
|
||||||
|
-- Should we create the directory anyway ?
|
||||||
|
create {LOG_WRITER_NULL} l_log_writer
|
||||||
|
end
|
||||||
|
set_logger_level (l_log_writer, l_logger_config.level)
|
||||||
|
a_log.register_log_writer (l_log_writer)
|
||||||
|
end
|
||||||
|
|
||||||
|
set_logger_level (a_log_writer: LOG_WRITER; a_priority: INTEGER)
|
||||||
|
-- Setup the logger level based on `a_priority'
|
||||||
|
do
|
||||||
|
if a_priority = log_debug then
|
||||||
|
a_log_writer.enable_debug_log_level
|
||||||
|
elseif a_priority = Log_emergency then
|
||||||
|
a_log_writer.enable_emergency_log_level
|
||||||
|
elseif a_priority = Log_alert then
|
||||||
|
a_log_writer.enable_alert_log_level
|
||||||
|
elseif a_priority = Log_critical then
|
||||||
|
a_log_writer.enable_critical_log_level
|
||||||
|
elseif a_priority = Log_error then
|
||||||
|
a_log_writer.enable_error_log_level
|
||||||
|
elseif a_priority = Log_warning then
|
||||||
|
a_log_writer.enable_warning_log_level
|
||||||
|
elseif a_priority = Log_notice then
|
||||||
|
a_log_writer.enable_notice_log_level
|
||||||
|
elseif a_priority = Log_information then
|
||||||
|
a_log_writer.enable_information_log_level
|
||||||
|
else
|
||||||
|
a_log_writer.enable_unkno_log_level
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
new_logger_level_configuration (a_path: PATH): LOGGER_CONFIGURATION
|
||||||
|
-- Retrieve a new logger level configuration.
|
||||||
|
-- By default, level is set to `DEBUG'.
|
||||||
|
local
|
||||||
|
l_parser: JSON_PARSER
|
||||||
|
ut: FILE_UTILITIES
|
||||||
|
do
|
||||||
|
create Result
|
||||||
|
if
|
||||||
|
ut.file_path_exists (a_path) and then
|
||||||
|
attached (create {JSON_FILE_READER}).read_json_from (a_path.name) as json_file
|
||||||
|
then
|
||||||
|
create l_parser.make_with_string (json_file)
|
||||||
|
l_parser.parse_content
|
||||||
|
if
|
||||||
|
l_parser.is_valid and then
|
||||||
|
attached l_parser.parsed_json_object as jv and then
|
||||||
|
attached {JSON_OBJECT} jv.item ("logger") as l_logger
|
||||||
|
then
|
||||||
|
if attached {JSON_STRING} l_logger.item ("location") as l_location then
|
||||||
|
Result.set_location_with_string (l_location.item)
|
||||||
|
end
|
||||||
|
if attached {JSON_STRING} l_logger.item ("backup_count") as l_count then
|
||||||
|
if l_count.item.is_natural then
|
||||||
|
Result.set_backup_count (l_count.item.to_natural)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if attached {JSON_STRING} l_logger.item ("level") as l_level then
|
||||||
|
Result.set_level (l_level.item)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
note
|
||||||
|
copyright: "2011-2015, Javier Velilla, Jocelyn Fiat, Eiffel Software and others"
|
||||||
|
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||||
|
end
|
||||||
@@ -67,7 +67,6 @@ feature -- Output
|
|||||||
rescue
|
rescue
|
||||||
l_retry := True
|
l_retry := True
|
||||||
retry
|
retry
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
write_emergency (msg: STRING)
|
write_emergency (msg: STRING)
|
||||||
@@ -135,6 +134,6 @@ feature -- Output
|
|||||||
retry
|
retry
|
||||||
end
|
end
|
||||||
note
|
note
|
||||||
copyright: "2011-2014, Javier Velilla, Jocelyn Fiat, Eiffel Software and others"
|
copyright: "2011-2015, Javier Velilla, Jocelyn Fiat, Eiffel Software and others"
|
||||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -13,100 +13,103 @@ inherit
|
|||||||
|
|
||||||
feature -- Logger
|
feature -- Logger
|
||||||
|
|
||||||
log: LOGGING_FACILITY
|
logger: separate LOGGER
|
||||||
-- `log' facility (once per process)
|
-- `log' facility (once per process)
|
||||||
-- that could be shared between threads
|
-- that could be shared between threads
|
||||||
-- without reinitializing it.
|
-- without reinitializing it.
|
||||||
once ("PROCESS")
|
do
|
||||||
create Result.make
|
Result := logger_cell_item (logger_cell)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
logger_cell: separate CELL [separate LOGGER]
|
||||||
|
once ("PROCESS")
|
||||||
|
create Result.put (create {separate LOGGER}.make)
|
||||||
|
end
|
||||||
|
|
||||||
|
logger_cell_item (a_cell: like logger_cell): separate LOGGER
|
||||||
|
do
|
||||||
|
Result := a_cell.item
|
||||||
|
end
|
||||||
|
|
||||||
|
feature -- Logging
|
||||||
|
|
||||||
|
write_debug_log (m: READABLE_STRING_8)
|
||||||
|
do
|
||||||
|
write_debug_log_to (m, logger)
|
||||||
|
end
|
||||||
|
|
||||||
|
write_information_log (m: READABLE_STRING_8)
|
||||||
|
do
|
||||||
|
write_information_log_to (m, logger)
|
||||||
|
end
|
||||||
|
|
||||||
|
write_warning_log (m: READABLE_STRING_8)
|
||||||
|
do
|
||||||
|
write_warning_log_to (m, logger)
|
||||||
|
end
|
||||||
|
|
||||||
|
write_error_log (m: READABLE_STRING_8)
|
||||||
|
do
|
||||||
|
write_error_log_to (m, logger)
|
||||||
|
end
|
||||||
|
|
||||||
|
write_critical_log (m: READABLE_STRING_8)
|
||||||
|
do
|
||||||
|
write_critical_log_to (m, logger)
|
||||||
|
end
|
||||||
|
|
||||||
|
write_alert_log (m: READABLE_STRING_8)
|
||||||
|
do
|
||||||
|
write_alert_log_to (m, logger)
|
||||||
|
end
|
||||||
|
|
||||||
|
feature {NONE} -- Logger: separate implementation
|
||||||
|
|
||||||
|
write_debug_log_to (m: READABLE_STRING_8; a_log: like logger)
|
||||||
|
do
|
||||||
|
a_log.put_debug (m)
|
||||||
|
end
|
||||||
|
|
||||||
|
write_information_log_to (m: READABLE_STRING_8; a_log: like logger)
|
||||||
|
do
|
||||||
|
a_log.put_information (m)
|
||||||
|
end
|
||||||
|
|
||||||
|
write_warning_log_to (m: READABLE_STRING_8; a_log: like logger)
|
||||||
|
do
|
||||||
|
a_log.put_warning (m)
|
||||||
|
end
|
||||||
|
|
||||||
|
write_error_log_to (m: READABLE_STRING_8; a_log: like logger)
|
||||||
|
do
|
||||||
|
a_log.put_error (m)
|
||||||
|
end
|
||||||
|
|
||||||
|
write_critical_log_to (m: READABLE_STRING_8; a_log: like logger)
|
||||||
|
do
|
||||||
|
a_log.put_critical (m)
|
||||||
|
end
|
||||||
|
|
||||||
|
write_alert_log_to (m: READABLE_STRING_8; a_log: like logger)
|
||||||
|
do
|
||||||
|
a_log.put_alert (m)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
feature {NONE} -- Implementation
|
feature {NONE} -- Implementation
|
||||||
|
|
||||||
initialize_logger (app: APPLICATION_LAYOUT)
|
initialize_logger (app: APPLICATION_LAYOUT)
|
||||||
local
|
local
|
||||||
l_log_writer_file: LOG_ROLLING_WRITER_FILE
|
l_logger: LOGGER
|
||||||
l_log_writer: LOG_WRITER
|
|
||||||
l_logs_path: detachable PATH
|
|
||||||
l_logger_config: LOGGER_CONFIGURATION
|
|
||||||
ut: FILE_UTILITIES
|
|
||||||
do
|
do
|
||||||
l_logger_config := new_logger_level_configuration (app.application_config_path)
|
create l_logger.make_with_layout (app)
|
||||||
l_logs_path := l_logger_config.location
|
set_logger_to (l_logger, logger_cell)
|
||||||
if l_logs_path = Void then
|
|
||||||
l_logs_path := app.logs_path
|
|
||||||
end
|
|
||||||
if ut.directory_path_exists (l_logs_path) then
|
|
||||||
create l_log_writer_file.make_at_location (l_logs_path.extended (app.name).appended_with_extension ("log"))
|
|
||||||
l_log_writer_file.set_max_file_size ({NATURAL_64} 1024 * 1204)
|
|
||||||
l_log_writer_file.set_max_backup_count (l_logger_config.backup_count)
|
|
||||||
l_log_writer := l_log_writer_file
|
|
||||||
else
|
|
||||||
-- Should we create the directory anyway ?
|
|
||||||
create {LOG_WRITER_NULL} l_log_writer
|
|
||||||
end
|
|
||||||
set_logger_level (l_log_writer, l_logger_config.level)
|
|
||||||
log.register_log_writer (l_log_writer)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
set_logger_level (a_log_writer: LOG_WRITER; a_priority: INTEGER)
|
set_logger_to (a_logger: separate LOGGER; a_cell: like logger_cell)
|
||||||
-- Setup the logger level based on `a_priority'
|
|
||||||
do
|
do
|
||||||
if a_priority = log_debug then
|
a_cell.replace (a_logger)
|
||||||
a_log_writer.enable_debug_log_level
|
|
||||||
elseif a_priority = Log_emergency then
|
|
||||||
a_log_writer.enable_emergency_log_level
|
|
||||||
elseif a_priority = Log_alert then
|
|
||||||
a_log_writer.enable_alert_log_level
|
|
||||||
elseif a_priority = Log_critical then
|
|
||||||
a_log_writer.enable_critical_log_level
|
|
||||||
elseif a_priority = Log_error then
|
|
||||||
a_log_writer.enable_error_log_level
|
|
||||||
elseif a_priority = Log_warning then
|
|
||||||
a_log_writer.enable_warning_log_level
|
|
||||||
elseif a_priority = Log_notice then
|
|
||||||
a_log_writer.enable_notice_log_level
|
|
||||||
elseif a_priority = Log_information then
|
|
||||||
a_log_writer.enable_information_log_level
|
|
||||||
else
|
|
||||||
a_log_writer.enable_unkno_log_level
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
new_logger_level_configuration (a_path: PATH): LOGGER_CONFIGURATION
|
|
||||||
-- Retrieve a new logger level configuration.
|
|
||||||
-- By default, level is set to `DEBUG'.
|
|
||||||
local
|
|
||||||
l_parser: JSON_PARSER
|
|
||||||
ut: FILE_UTILITIES
|
|
||||||
do
|
|
||||||
create Result
|
|
||||||
if
|
|
||||||
ut.file_path_exists (a_path) and then
|
|
||||||
attached (create {JSON_FILE_READER}).read_json_from (a_path.name) as json_file
|
|
||||||
then
|
|
||||||
create l_parser.make_with_string (json_file)
|
|
||||||
l_parser.parse_content
|
|
||||||
if
|
|
||||||
l_parser.is_valid and then
|
|
||||||
attached l_parser.parsed_json_object as jv and then
|
|
||||||
attached {JSON_OBJECT} jv.item ("logger") as l_logger
|
|
||||||
then
|
|
||||||
if attached {JSON_STRING} l_logger.item ("location") as l_location then
|
|
||||||
Result.set_location_with_string (l_location.item)
|
|
||||||
end
|
|
||||||
if attached {JSON_STRING} l_logger.item ("backup_count") as l_count then
|
|
||||||
if l_count.item.is_natural then
|
|
||||||
Result.set_backup_count (l_count.item.to_natural)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if attached {JSON_STRING} l_logger.item ("level") as l_level then
|
|
||||||
Result.set_level (l_level.item)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
note
|
note
|
||||||
copyright: "2011-2015, Javier Velilla, Jocelyn Fiat, Eiffel Software and others"
|
copyright: "2011-2015, Javier Velilla, Jocelyn Fiat, Eiffel Software and others"
|
||||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||||
|
|||||||
@@ -14,10 +14,17 @@ inherit
|
|||||||
REFACTORING_HELPER
|
REFACTORING_HELPER
|
||||||
|
|
||||||
create
|
create
|
||||||
make
|
make,
|
||||||
|
make_empty
|
||||||
|
|
||||||
feature{NONE} -- Initialization
|
feature{NONE} -- Initialization
|
||||||
|
|
||||||
|
make_empty
|
||||||
|
-- Create empty node.
|
||||||
|
do
|
||||||
|
make ({STRING_32} "", {STRING_32} "", {STRING_32} "")
|
||||||
|
end
|
||||||
|
|
||||||
make (a_content: READABLE_STRING_32; a_summary: READABLE_STRING_32; a_title: READABLE_STRING_32)
|
make (a_content: READABLE_STRING_32; a_summary: READABLE_STRING_32; a_title: READABLE_STRING_32)
|
||||||
-- Create current node with `a_content', `a_summary' and `a_title'.
|
-- Create current node with `a_content', `a_summary' and `a_title'.
|
||||||
local
|
local
|
||||||
@@ -83,9 +90,6 @@ feature -- Access
|
|||||||
author: detachable CMS_USER
|
author: detachable CMS_USER
|
||||||
-- Author of current node.
|
-- Author of current node.
|
||||||
|
|
||||||
-- collaborators: detachable LIST[CMS_USER]
|
|
||||||
-- -- Users contributed to current Node.
|
|
||||||
|
|
||||||
feature -- status report
|
feature -- status report
|
||||||
|
|
||||||
has_id: BOOLEAN
|
has_id: BOOLEAN
|
||||||
@@ -191,6 +195,6 @@ feature -- Element change
|
|||||||
-- end
|
-- end
|
||||||
|
|
||||||
note
|
note
|
||||||
copyright: "2011-2014, Javier Velilla, Jocelyn Fiat, Eiffel Software and others"
|
copyright: "2011-2015, Javier Velilla, Jocelyn Fiat, Eiffel Software and others"
|
||||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ feature {NONE} -- Initialization
|
|||||||
is_connected: a_connection.is_connected
|
is_connected: a_connection.is_connected
|
||||||
do
|
do
|
||||||
connection := a_connection
|
connection := a_connection
|
||||||
log.write_information (generator + ".make - is database connected? "+ a_connection.is_connected.out )
|
write_information_log (generator + ".make - is database connected? "+ a_connection.is_connected.out )
|
||||||
|
|
||||||
create {DATABASE_HANDLER_IMPL} db_handler.make (a_connection)
|
create {DATABASE_HANDLER_IMPL} db_handler.make (a_connection)
|
||||||
|
|
||||||
@@ -50,7 +50,7 @@ feature -- Query
|
|||||||
do
|
do
|
||||||
error_handler.append (db_handler.database_error_handler)
|
error_handler.append (db_handler.database_error_handler)
|
||||||
if error_handler.has_error then
|
if error_handler.has_error then
|
||||||
log.write_critical (generator + ".post_execution " + error_handler.as_string_representation)
|
write_critical_log (generator + ".post_execution " + error_handler.as_string_representation)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ feature -- Initialization
|
|||||||
rescue
|
rescue
|
||||||
create db_control.make
|
create db_control.make
|
||||||
-- set_last_error_from_exception ("Connection execution")
|
-- set_last_error_from_exception ("Connection execution")
|
||||||
-- log.write_critical (generator + ".make_common:" + last_error_message)
|
-- write_critical_log (generator + ".make_common:" + last_error_message)
|
||||||
if is_connected then
|
if is_connected then
|
||||||
disconnect
|
disconnect
|
||||||
end
|
end
|
||||||
@@ -73,7 +73,7 @@ feature -- Initialization
|
|||||||
rescue
|
rescue
|
||||||
create db_control.make
|
create db_control.make
|
||||||
-- set_last_error_from_exception ("Connection execution")
|
-- set_last_error_from_exception ("Connection execution")
|
||||||
-- log.write_critical (generator + ".make_common:" + last_error_message)
|
-- write_critical_log (generator + ".make_common:" + last_error_message)
|
||||||
if is_connected then
|
if is_connected then
|
||||||
disconnect
|
disconnect
|
||||||
end
|
end
|
||||||
@@ -103,20 +103,20 @@ feature -- Initialization
|
|||||||
login_with_connection_string (a_string: STRING)
|
login_with_connection_string (a_string: STRING)
|
||||||
-- Login with `a_connection_string'and immediately connect to database.
|
-- Login with `a_connection_string'and immediately connect to database.
|
||||||
do
|
do
|
||||||
log.write_debug (generator +".login_with_connection_string")
|
write_debug_log (generator +".login_with_connection_string")
|
||||||
create db_application.login_with_connection_string (a_string)
|
create db_application.login_with_connection_string (a_string)
|
||||||
create database_error_handler.make
|
create database_error_handler.make
|
||||||
db_application.set_base
|
db_application.set_base
|
||||||
create db_control.make
|
create db_control.make
|
||||||
log.write_debug (generator +".login_with_connection_string, is_keep_connection? "+ is_keep_connection.out )
|
write_debug_log (generator +".login_with_connection_string, is_keep_connection? "+ is_keep_connection.out )
|
||||||
keep_connection := is_keep_connection
|
keep_connection := is_keep_connection
|
||||||
if keep_connection then
|
if keep_connection then
|
||||||
connect
|
connect
|
||||||
if not db_control.is_ok then
|
if not db_control.is_ok then
|
||||||
log.write_critical (generator +".login_with_connection_string:"+ db_control.error_code.out )
|
write_critical_log (generator +".login_with_connection_string:"+ db_control.error_code.out )
|
||||||
log.write_critical (generator +".login_with_connection_string:"+ db_control.error_message_32 )
|
write_critical_log (generator +".login_with_connection_string:"+ db_control.error_message_32 )
|
||||||
end
|
end
|
||||||
log.write_debug (generator +".login_with_connection_string, After connect, is_connected? "+ is_connected.out)
|
write_debug_log (generator +".login_with_connection_string, After connect, is_connected? "+ is_connected.out)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -177,7 +177,7 @@ feature -- Error handling
|
|||||||
do
|
do
|
||||||
if attached db_change as l_change and then not l_change.is_ok then
|
if attached db_change as l_change and then not l_change.is_ok then
|
||||||
database_error_handler.add_database_error (l_change.error_message_32, l_change.error_code)
|
database_error_handler.add_database_error (l_change.error_message_32, l_change.error_code)
|
||||||
log.write_error (generator + ".check_database_change_error: " + l_change.error_message_32)
|
write_error_log (generator + ".check_database_change_error: " + l_change.error_message_32)
|
||||||
l_change.reset
|
l_change.reset
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -187,7 +187,7 @@ feature -- Error handling
|
|||||||
do
|
do
|
||||||
if attached db_selection as l_selection and then not l_selection.is_ok then
|
if attached db_selection as l_selection and then not l_selection.is_ok then
|
||||||
database_error_handler.add_database_error (l_selection.error_message_32, l_selection.error_code)
|
database_error_handler.add_database_error (l_selection.error_message_32, l_selection.error_code)
|
||||||
log.write_error (generator + ".check_database_selection_error: " + l_selection.error_message_32)
|
write_error_log (generator + ".check_database_selection_error: " + l_selection.error_message_32)
|
||||||
l_selection.reset
|
l_selection.reset
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ feature -- Functionality
|
|||||||
items := l_store.execute_reader (l_db_selection)
|
items := l_store.execute_reader (l_db_selection)
|
||||||
check_database_selection_error
|
check_database_selection_error
|
||||||
end
|
end
|
||||||
log.write_debug ( generator+".execute_reader Successful")
|
write_debug_log ( generator+".execute_reader Successful")
|
||||||
end
|
end
|
||||||
rescue
|
rescue
|
||||||
l_retried := True
|
l_retried := True
|
||||||
@@ -69,7 +69,7 @@ feature -- Functionality
|
|||||||
l_store.execute_writer (l_db_change)
|
l_store.execute_writer (l_db_change)
|
||||||
check_database_change_error
|
check_database_change_error
|
||||||
end
|
end
|
||||||
log.write_debug ( generator+".execute_writer Successful")
|
write_debug_log ( generator+".execute_writer Successful")
|
||||||
end
|
end
|
||||||
rescue
|
rescue
|
||||||
l_retried := True
|
l_retried := True
|
||||||
|
|||||||
@@ -19,8 +19,8 @@ feature {NONE} -- Intialization
|
|||||||
data_reader (a_query: STRING; a_parameters: like parameters)
|
data_reader (a_query: STRING; a_parameters: like parameters)
|
||||||
-- SQL data reader for the query `a_query' with arguments `a_parameters'
|
-- SQL data reader for the query `a_query' with arguments `a_parameters'
|
||||||
do
|
do
|
||||||
log.write_information (generator + ".data_reader" + " execute query: " + a_query)
|
write_information_log (generator + ".data_reader" + " execute query: " + a_query)
|
||||||
log.write_debug (generator + ".data_reader" + " arguments:" + log_parameters (a_parameters))
|
write_debug_log (generator + ".data_reader" + " arguments:" + log_parameters (a_parameters))
|
||||||
query := a_query
|
query := a_query
|
||||||
parameters := a_parameters
|
parameters := a_parameters
|
||||||
ensure
|
ensure
|
||||||
@@ -43,7 +43,7 @@ feature -- Execution
|
|||||||
a_base_selection.load_result
|
a_base_selection.load_result
|
||||||
Result := a_base_selection.container
|
Result := a_base_selection.container
|
||||||
else
|
else
|
||||||
log.write_error (generator + "." + a_base_selection.error_message_32)
|
write_error_log (generator + "." + a_base_selection.error_message_32)
|
||||||
end
|
end
|
||||||
unset_map_name (a_base_selection)
|
unset_map_name (a_base_selection)
|
||||||
a_base_selection.terminate
|
a_base_selection.terminate
|
||||||
|
|||||||
@@ -20,8 +20,8 @@ feature -- Intialization
|
|||||||
local
|
local
|
||||||
l_retried: BOOLEAN
|
l_retried: BOOLEAN
|
||||||
do
|
do
|
||||||
log.write_information (generator + ".data_reader" + " execute store procedure: " + a_sp)
|
write_information_log (generator + ".data_reader" + " execute store procedure: " + a_sp)
|
||||||
log.write_debug (generator + ".data_reader" + " arguments:" + log_parameters (a_parameters))
|
write_debug_log (generator + ".data_reader" + " arguments:" + log_parameters (a_parameters))
|
||||||
if not l_retried then
|
if not l_retried then
|
||||||
stored_procedure := a_sp
|
stored_procedure := a_sp
|
||||||
parameters := a_parameters
|
parameters := a_parameters
|
||||||
@@ -33,14 +33,14 @@ feature -- Intialization
|
|||||||
if proc.exists then
|
if proc.exists then
|
||||||
if proc.text_32 /= Void then
|
if proc.text_32 /= Void then
|
||||||
debug
|
debug
|
||||||
log.write_debug ( generator + ".data_reader: " + proc.text_32)
|
write_debug_log ( generator + ".data_reader: " + proc.text_32)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
has_error := True
|
has_error := True
|
||||||
error_message := proc.error_message_32
|
error_message := proc.error_message_32
|
||||||
error_code := proc.error_code
|
error_code := proc.error_code
|
||||||
log.write_error (generator + ".data_witer message:" + proc.error_message_32 + " code:" + proc.error_code.out)
|
write_error_log (generator + ".data_witer message:" + proc.error_message_32 + " code:" + proc.error_code.out)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
stored_procedure := a_sp
|
stored_procedure := a_sp
|
||||||
@@ -49,7 +49,7 @@ feature -- Intialization
|
|||||||
end
|
end
|
||||||
rescue
|
rescue
|
||||||
set_last_error_from_exception ("SQL execution")
|
set_last_error_from_exception ("SQL execution")
|
||||||
log.write_critical (generator+ ".data_reader " + last_error_message)
|
write_critical_log (generator+ ".data_reader " + last_error_message)
|
||||||
l_retried := True
|
l_retried := True
|
||||||
retry
|
retry
|
||||||
end
|
end
|
||||||
@@ -59,8 +59,8 @@ feature -- Intialization
|
|||||||
local
|
local
|
||||||
l_retried: BOOLEAN
|
l_retried: BOOLEAN
|
||||||
do
|
do
|
||||||
log.write_information (generator + ".data_reader" + " execute store procedure: " + a_sp)
|
write_information_log (generator + ".data_reader" + " execute store procedure: " + a_sp)
|
||||||
log.write_debug (generator + ".data_reader" + " arguments:" + log_parameters (a_parameters))
|
write_debug_log (generator + ".data_reader" + " arguments:" + log_parameters (a_parameters))
|
||||||
if not l_retried then
|
if not l_retried then
|
||||||
stored_procedure := a_sp
|
stored_procedure := a_sp
|
||||||
parameters := a_parameters
|
parameters := a_parameters
|
||||||
@@ -70,14 +70,14 @@ feature -- Intialization
|
|||||||
if proc.exists then
|
if proc.exists then
|
||||||
if proc.text_32 /= Void then
|
if proc.text_32 /= Void then
|
||||||
debug
|
debug
|
||||||
log.write_debug ( generator + ".data_writer: " + proc.text_32)
|
write_debug_log ( generator + ".data_writer: " + proc.text_32)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
has_error := True
|
has_error := True
|
||||||
error_message := proc.error_message_32
|
error_message := proc.error_message_32
|
||||||
error_code := proc.error_code
|
error_code := proc.error_code
|
||||||
log.write_error (generator + ".data_witer message:" + proc.error_message_32 + " code:" + proc.error_code.out)
|
write_error_log (generator + ".data_witer message:" + proc.error_message_32 + " code:" + proc.error_code.out)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
stored_procedure := a_sp
|
stored_procedure := a_sp
|
||||||
@@ -86,12 +86,11 @@ feature -- Intialization
|
|||||||
end
|
end
|
||||||
rescue
|
rescue
|
||||||
set_last_error_from_exception ("SQL execution")
|
set_last_error_from_exception ("SQL execution")
|
||||||
log.write_critical (generator+ ".data_reader " + last_error_message)
|
write_critical_log (generator+ ".data_reader " + last_error_message)
|
||||||
l_retried := True
|
l_retried := True
|
||||||
retry
|
retry
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
execute_reader (a_base_selection: DB_SELECTION): detachable LIST [DB_RESULT]
|
execute_reader (a_base_selection: DB_SELECTION): detachable LIST [DB_RESULT]
|
||||||
-- Execute the Current store procedure.
|
-- Execute the Current store procedure.
|
||||||
do
|
do
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ feature -- Access: iterator
|
|||||||
l_parameters: STRING_TABLE [ANY]
|
l_parameters: STRING_TABLE [ANY]
|
||||||
do
|
do
|
||||||
error_handler.reset
|
error_handler.reset
|
||||||
log.write_information (generator + ".nodes_iterator")
|
write_information_log (generator + ".nodes_iterator")
|
||||||
create l_parameters.make (0)
|
create l_parameters.make (0)
|
||||||
sql_query (select_nodes, l_parameters)
|
sql_query (select_nodes, l_parameters)
|
||||||
create Result.make (db_handler, agent fetch_node)
|
create Result.make (db_handler, agent fetch_node)
|
||||||
@@ -61,7 +61,7 @@ feature -- Access: iterator
|
|||||||
do
|
do
|
||||||
-- FIXME: check implementation...
|
-- FIXME: check implementation...
|
||||||
error_handler.reset
|
error_handler.reset
|
||||||
log.write_information (generator + ".recent_nodes_iterator")
|
write_information_log (generator + ".recent_nodes_iterator")
|
||||||
create l_parameters.make (2)
|
create l_parameters.make (2)
|
||||||
l_parameters.put (a_rows, "rows")
|
l_parameters.put (a_rows, "rows")
|
||||||
l_parameters.put (a_lower, "offset")
|
l_parameters.put (a_lower, "offset")
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
note
|
note
|
||||||
description: "This module allows the use of HTTP Basic Authentication to restrict access by looking up users in the given providers."
|
description: "[
|
||||||
|
This module allows the use of HTTP Basic Authentication to restrict access
|
||||||
|
by looking up users in the given providers.
|
||||||
|
]"
|
||||||
date: "$Date: 2015-02-09 22:29:56 +0100 (lun., 09 févr. 2015) $"
|
date: "$Date: 2015-02-09 22:29:56 +0100 (lun., 09 févr. 2015) $"
|
||||||
revision: "$Revision: 96596 $"
|
revision: "$Revision: 96596 $"
|
||||||
|
|
||||||
@@ -82,7 +85,7 @@ feature -- Hooks configuration
|
|||||||
-- Module hooks configuration.
|
-- Module hooks configuration.
|
||||||
do
|
do
|
||||||
-- a_response.subscribe_to_block_hook (Current)
|
-- a_response.subscribe_to_block_hook (Current)
|
||||||
end
|
end
|
||||||
|
|
||||||
feature -- Hooks
|
feature -- Hooks
|
||||||
|
|
||||||
@@ -107,9 +110,9 @@ feature -- Hooks
|
|||||||
lnk: CMS_LOCAL_LINK
|
lnk: CMS_LOCAL_LINK
|
||||||
do
|
do
|
||||||
if attached a_response.current_user (a_response.request) as u then
|
if attached a_response.current_user (a_response.request) as u then
|
||||||
create lnk.make ("Logout", "/basic_auth_logoff")
|
create lnk.make (u.name + " (Logout)", "/basic_auth_logoff?destination=" + a_response.request.request_uri)
|
||||||
else
|
else
|
||||||
create lnk.make ("Login", "/basic_auth_login")
|
create lnk.make ("Login", "/basic_auth_login?destination=" + a_response.request.request_uri)
|
||||||
end
|
end
|
||||||
-- if not a_menu_system.primary_menu.has (lnk) then
|
-- if not a_menu_system.primary_menu.has (lnk) then
|
||||||
lnk.set_weight (99)
|
lnk.set_weight (99)
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ feature -- Basic operations
|
|||||||
execute_next (req, res)
|
execute_next (req, res)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
api.logger.put_error (generator + ".execute Not valid", Void)
|
api.logger.put_debug (generator + ".execute without authentication", Void)
|
||||||
execute_next (req, res)
|
execute_next (req, res)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -50,11 +50,21 @@ feature -- HTTP Methods
|
|||||||
do
|
do
|
||||||
api.logger.put_information (generator + ".do_get Processing basic auth login", Void)
|
api.logger.put_information (generator + ".do_get Processing basic auth login", Void)
|
||||||
if attached {STRING_32} current_user_name (req) as l_user then
|
if attached {STRING_32} current_user_name (req) as l_user then
|
||||||
(create {CMS_GENERIC_RESPONSE}).new_response_redirect (req, res, req.absolute_script_url("/"))
|
if attached {WSF_STRING} req.query_parameter ("destination") as l_uri then
|
||||||
|
redirect_to (req.absolute_script_url (l_uri.url_encoded_value), res)
|
||||||
|
else
|
||||||
|
redirect_to (req.absolute_script_url ("/"), res)
|
||||||
|
end
|
||||||
else
|
else
|
||||||
(create {CMS_GENERIC_RESPONSE}).new_response_authenticate (req, res)
|
send_basic_authentication_challenge (Void, res)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
feature -- Helpers
|
||||||
|
|
||||||
|
send_basic_authentication_challenge (a_realm: detachable READABLE_STRING_8; res: WSF_RESPONSE)
|
||||||
|
do
|
||||||
|
res.send (create {CMS_UNAUTHORIZED_RESPONSE_MESSAGE}.make_with_basic_auth_challenge (a_realm))
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -45,13 +45,29 @@ feature -- HTTP Methods
|
|||||||
-- <Precursor>
|
-- <Precursor>
|
||||||
local
|
local
|
||||||
l_page: CMS_RESPONSE
|
l_page: CMS_RESPONSE
|
||||||
|
l_url: STRING
|
||||||
|
i: INTEGER
|
||||||
do
|
do
|
||||||
api.logger.put_information (generator + ".do_get Processing basic auth logoff", Void)
|
api.logger.put_information (generator + ".do_get Processing basic auth logoff", Void)
|
||||||
if attached req.query_parameter ("prompt") as l_prompt then
|
if attached req.query_parameter ("prompt") as l_prompt then
|
||||||
(create {CMS_GENERIC_RESPONSE}).new_response_unauthorized (req, res)
|
unset_current_user (req)
|
||||||
|
send_access_denied (res)
|
||||||
else
|
else
|
||||||
create {GENERIC_VIEW_CMS_RESPONSE} l_page.make (req, res, api)
|
create {GENERIC_VIEW_CMS_RESPONSE} l_page.make (req, res, api)
|
||||||
l_page.set_status_code ({HTTP_STATUS_CODE}.unauthorized)
|
unset_current_user (req)
|
||||||
|
l_page.set_status_code ({HTTP_STATUS_CODE}.found) -- Note: can not use {HTTP_STATUS_CODE}.unauthorized for redirection
|
||||||
|
if attached {WSF_STRING} req.query_parameter ("destination") as l_uri then
|
||||||
|
l_url := req.absolute_script_url (l_uri.url_encoded_value)
|
||||||
|
else
|
||||||
|
l_url := req.absolute_script_url ("")
|
||||||
|
end
|
||||||
|
i := l_url.substring_index ("://", 1)
|
||||||
|
if i > 0 then
|
||||||
|
-- Note: this is a hack to have the logout effective on various browser
|
||||||
|
-- (firefox requires this).
|
||||||
|
l_url.replace_substring ("://_logout_basic_auth_@", i, i + 2)
|
||||||
|
end
|
||||||
|
l_page.set_redirection (l_url)
|
||||||
l_page.execute
|
l_page.execute
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ feature -- HTTP Methods
|
|||||||
(create {INTERNAL_SERVER_ERROR_CMS_RESPONSE}.make (req, res, api)).execute
|
(create {INTERNAL_SERVER_ERROR_CMS_RESPONSE}.make (req, res, api)).execute
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
(create {CMS_GENERIC_RESPONSE}).new_response_unauthorized (req, res)
|
send_access_denied (res)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -102,7 +102,7 @@ feature -- HTTP Methods
|
|||||||
(create {INTERNAL_SERVER_ERROR_CMS_RESPONSE}.make (req, res, api)).execute
|
(create {INTERNAL_SERVER_ERROR_CMS_RESPONSE}.make (req, res, api)).execute
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
(create {CMS_GENERIC_RESPONSE}).new_response_unauthorized (req, res)
|
send_access_denied (res)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -118,7 +118,7 @@ feature -- HTTP Methods
|
|||||||
u_node := extract_data_form (req)
|
u_node := extract_data_form (req)
|
||||||
u_node.set_id (l_id.value.to_integer_64)
|
u_node.set_id (l_id.value.to_integer_64)
|
||||||
node_api.update_node_content (l_user.id, u_node.id, u_node.content)
|
node_api.update_node_content (l_user.id, u_node.id, u_node.content)
|
||||||
(create {CMS_GENERIC_RESPONSE}).new_response_redirect (req, res, req.absolute_script_url (""))
|
redirect_to (req.absolute_script_url (""), res)
|
||||||
else
|
else
|
||||||
do_error (req, res, l_id)
|
do_error (req, res, l_id)
|
||||||
end
|
end
|
||||||
@@ -126,7 +126,7 @@ feature -- HTTP Methods
|
|||||||
(create {INTERNAL_SERVER_ERROR_CMS_RESPONSE}.make (req, res, api)).execute
|
(create {INTERNAL_SERVER_ERROR_CMS_RESPONSE}.make (req, res, api)).execute
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
(create {CMS_GENERIC_RESPONSE}).new_response_unauthorized (req, res)
|
send_access_denied (res)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
feature -- Error
|
feature -- Error
|
||||||
|
|||||||
@@ -111,10 +111,10 @@ feature -- HTTP Methods
|
|||||||
update_node_from_data_form (req, u_node)
|
update_node_from_data_form (req, u_node)
|
||||||
u_node.set_author (l_user)
|
u_node.set_author (l_user)
|
||||||
node_api.new_node (u_node)
|
node_api.new_node (u_node)
|
||||||
(create {CMS_GENERIC_RESPONSE}).new_response_redirect (req, res, req.absolute_script_url (""))
|
redirect_to (req.absolute_script_url (""), res)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
(create {CMS_GENERIC_RESPONSE}).new_response_unauthorized (req, res)
|
send_access_denied (res)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -131,7 +131,7 @@ feature -- HTTP Methods
|
|||||||
update_node_from_data_form (req, l_node)
|
update_node_from_data_form (req, l_node)
|
||||||
l_node.set_author (l_user)
|
l_node.set_author (l_user)
|
||||||
node_api.update_node (l_node)
|
node_api.update_node (l_node)
|
||||||
(create {CMS_GENERIC_RESPONSE}).new_response_redirect (req, res, req.absolute_script_url (""))
|
redirect_to (req.absolute_script_url (""), res)
|
||||||
else
|
else
|
||||||
do_error (req, res, l_id)
|
do_error (req, res, l_id)
|
||||||
end
|
end
|
||||||
@@ -139,7 +139,7 @@ feature -- HTTP Methods
|
|||||||
(create {INTERNAL_SERVER_ERROR_CMS_RESPONSE}.make (req, res, api)).execute
|
(create {INTERNAL_SERVER_ERROR_CMS_RESPONSE}.make (req, res, api)).execute
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
(create {CMS_GENERIC_RESPONSE}).new_response_unauthorized (req, res)
|
send_access_denied (res)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -153,7 +153,7 @@ feature -- HTTP Methods
|
|||||||
attached node_api.node (l_id.integer_value) as l_node
|
attached node_api.node (l_id.integer_value) as l_node
|
||||||
then
|
then
|
||||||
node_api.delete_node (l_node)
|
node_api.delete_node (l_node)
|
||||||
(create {CMS_GENERIC_RESPONSE}).new_response_redirect (req, res, req.absolute_script_url (""))
|
res.send (create {CMS_REDIRECTION_RESPONSE_MESSAGE}.make (req.absolute_script_url ("")))
|
||||||
else
|
else
|
||||||
do_error (req, res, l_id)
|
do_error (req, res, l_id)
|
||||||
end
|
end
|
||||||
@@ -161,7 +161,7 @@ feature -- HTTP Methods
|
|||||||
(create {INTERNAL_SERVER_ERROR_CMS_RESPONSE}.make (req, res, api)).execute
|
(create {INTERNAL_SERVER_ERROR_CMS_RESPONSE}.make (req, res, api)).execute
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
(create {CMS_GENERIC_RESPONSE}).new_response_unauthorized (req, res)
|
send_access_denied (res)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -196,7 +196,7 @@ feature {NONE} -- Node
|
|||||||
create {GENERIC_VIEW_CMS_RESPONSE} l_page.make (req, res, api)
|
create {GENERIC_VIEW_CMS_RESPONSE} l_page.make (req, res, api)
|
||||||
l_page.execute
|
l_page.execute
|
||||||
else
|
else
|
||||||
(create {CMS_GENERIC_RESPONSE}).new_response_unauthorized (req, res)
|
send_access_denied (res)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ feature -- HTTP Methods
|
|||||||
(create {INTERNAL_SERVER_ERROR_CMS_RESPONSE}.make (req, res, api)).execute
|
(create {INTERNAL_SERVER_ERROR_CMS_RESPONSE}.make (req, res, api)).execute
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
(create {CMS_GENERIC_RESPONSE}).new_response_unauthorized (req, res)
|
send_access_denied (res)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -102,7 +102,7 @@ feature -- HTTP Methods
|
|||||||
(create {INTERNAL_SERVER_ERROR_CMS_RESPONSE}.make (req, res, api)).execute
|
(create {INTERNAL_SERVER_ERROR_CMS_RESPONSE}.make (req, res, api)).execute
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
(create {CMS_GENERIC_RESPONSE}).new_response_unauthorized (req, res)
|
send_access_denied (res)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -117,7 +117,7 @@ feature -- HTTP Methods
|
|||||||
u_node := extract_data_form (req)
|
u_node := extract_data_form (req)
|
||||||
u_node.set_id (l_id.value.to_integer_64)
|
u_node.set_id (l_id.value.to_integer_64)
|
||||||
node_api.update_node_summary (l_user.id,u_node.id, u_node.summary)
|
node_api.update_node_summary (l_user.id,u_node.id, u_node.summary)
|
||||||
(create {CMS_GENERIC_RESPONSE}).new_response_redirect (req, res, req.absolute_script_url (""))
|
redirect_to (req.absolute_script_url (""), res)
|
||||||
else
|
else
|
||||||
do_error (req, res, l_id)
|
do_error (req, res, l_id)
|
||||||
end
|
end
|
||||||
@@ -125,7 +125,7 @@ feature -- HTTP Methods
|
|||||||
(create {INTERNAL_SERVER_ERROR_CMS_RESPONSE}.make (req, res, api)).execute
|
(create {INTERNAL_SERVER_ERROR_CMS_RESPONSE}.make (req, res, api)).execute
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
(create {CMS_GENERIC_RESPONSE}).new_response_unauthorized (req, res)
|
send_access_denied (res)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ feature -- HTTP Methods
|
|||||||
(create {INTERNAL_SERVER_ERROR_CMS_RESPONSE}.make (req, res, api)).execute
|
(create {INTERNAL_SERVER_ERROR_CMS_RESPONSE}.make (req, res, api)).execute
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
(create {CMS_GENERIC_RESPONSE}).new_response_unauthorized (req, res)
|
send_access_denied (res)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -101,7 +101,7 @@ feature -- HTTP Methods
|
|||||||
(create {INTERNAL_SERVER_ERROR_CMS_RESPONSE}.make (req, res, api)).execute
|
(create {INTERNAL_SERVER_ERROR_CMS_RESPONSE}.make (req, res, api)).execute
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
(create {CMS_GENERIC_RESPONSE}).new_response_unauthorized (req, res)
|
send_access_denied (res)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -117,7 +117,7 @@ feature -- HTTP Methods
|
|||||||
u_node := extract_data_form (req)
|
u_node := extract_data_form (req)
|
||||||
u_node.set_id (l_id.value.to_integer_64)
|
u_node.set_id (l_id.value.to_integer_64)
|
||||||
node_api.update_node_title (l_user.id, u_node.id, u_node.title)
|
node_api.update_node_title (l_user.id, u_node.id, u_node.title)
|
||||||
(create {CMS_GENERIC_RESPONSE}).new_response_redirect (req, res, req.absolute_script_url (""))
|
redirect_to (req.absolute_script_url (""), res)
|
||||||
else
|
else
|
||||||
do_error (req, res, l_id)
|
do_error (req, res, l_id)
|
||||||
end
|
end
|
||||||
@@ -125,7 +125,7 @@ feature -- HTTP Methods
|
|||||||
(create {INTERNAL_SERVER_ERROR_CMS_RESPONSE}.make (req, res, api)).execute
|
(create {INTERNAL_SERVER_ERROR_CMS_RESPONSE}.make (req, res, api)).execute
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
(create {CMS_GENERIC_RESPONSE}).new_response_unauthorized (req, res)
|
send_access_denied (res)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
note
|
note
|
||||||
description: "Summary description for {NODES_HANDLER}."
|
description: "Request handler related to /nodes."
|
||||||
date: "$Date: 2015-02-13 13:08:13 +0100 (ven., 13 févr. 2015) $"
|
date: "$Date: 2015-02-13 13:08:13 +0100 (ven., 13 févr. 2015) $"
|
||||||
revision: "$Revision: 96616 $"
|
revision: "$Revision: 96616 $"
|
||||||
|
|
||||||
@@ -38,12 +38,40 @@ feature -- HTTP Methods
|
|||||||
-- <Precursor>
|
-- <Precursor>
|
||||||
local
|
local
|
||||||
l_page: CMS_RESPONSE
|
l_page: CMS_RESPONSE
|
||||||
|
s: STRING
|
||||||
|
l_user: CMS_USER
|
||||||
|
l_node: CMS_NODE
|
||||||
do
|
do
|
||||||
-- At the moment the template is hardcoded, but we can
|
-- At the moment the template is hardcoded, but we can
|
||||||
-- get them from the configuration file and load them into
|
-- get them from the configuration file and load them into
|
||||||
-- the setup class.
|
-- the setup class.
|
||||||
|
|
||||||
create {GENERIC_VIEW_CMS_RESPONSE} l_page.make (req, res, api)
|
create {GENERIC_VIEW_CMS_RESPONSE} l_page.make (req, res, api)
|
||||||
l_page.add_variable (node_api.nodes, "nodes")
|
l_page.add_variable (node_api.nodes, "nodes")
|
||||||
|
|
||||||
|
|
||||||
|
-- NOTE: for development purposes we have the following hardcode output.
|
||||||
|
create s.make_from_string ("<p>Nodes:</p>")
|
||||||
|
if attached node_api.nodes as lst then
|
||||||
|
across
|
||||||
|
lst as ic
|
||||||
|
loop
|
||||||
|
s.append ("<li>")
|
||||||
|
s.append ("<a href=%"")
|
||||||
|
s.append (req.script_url ("/node/" + ic.item.id.out))
|
||||||
|
s.append ("%">")
|
||||||
|
s.append (api.html_encoded (ic.item.title))
|
||||||
|
s.append (" (")
|
||||||
|
s.append (ic.item.id.out)
|
||||||
|
s.append (")")
|
||||||
|
s.append ("</a>")
|
||||||
|
s.append ("</li>%N")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
l_page.set_main_content (s)
|
||||||
|
l_page.add_block (create {CMS_CONTENT_BLOCK}.make ("nodes_warning", Void, "/nodes/ is not yet fully implemented<br/>", Void), "highlighted")
|
||||||
l_page.execute
|
l_page.execute
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ feature {NONE} -- Implementation: routes
|
|||||||
l_methods.enable_put
|
l_methods.enable_put
|
||||||
l_methods.enable_delete
|
l_methods.enable_delete
|
||||||
a_router.handle_with_request_methods ("/node/{id}", l_node_handler, l_methods)
|
a_router.handle_with_request_methods ("/node/{id}", l_node_handler, l_methods)
|
||||||
a_router.handle_with_request_methods ("/nodes/", create {WSF_URI_AGENT_HANDLER}.make (agent do_get_nodes (?,?, a_api, a_node_api)), a_router.methods_get)
|
-- a_router.handle_with_request_methods ("/nodes/", create {WSF_URI_AGENT_HANDLER}.make (agent do_get_nodes (?,?, a_api, a_node_api)), a_router.methods_get)
|
||||||
end
|
end
|
||||||
|
|
||||||
configure_api_nodes (a_api: CMS_API; a_node_api: CMS_NODE_API; a_router: WSF_ROUTER)
|
configure_api_nodes (a_api: CMS_API; a_node_api: CMS_NODE_API; a_router: WSF_ROUTER)
|
||||||
@@ -97,7 +97,7 @@ feature {NONE} -- Implementation: routes
|
|||||||
l_methods.enable_get
|
l_methods.enable_get
|
||||||
l_methods.enable_post
|
l_methods.enable_post
|
||||||
l_methods.enable_put
|
l_methods.enable_put
|
||||||
a_router.handle_with_request_methods ("/node/{id}/summary", l_report_handler, l_methods)
|
a_router.handle_with_request_methods ("/node/{id}/field/summary", l_report_handler, l_methods)
|
||||||
end
|
end
|
||||||
|
|
||||||
configure_api_node_title (a_api: CMS_API; a_node_api: CMS_NODE_API; a_router: WSF_ROUTER)
|
configure_api_node_title (a_api: CMS_API; a_node_api: CMS_NODE_API; a_router: WSF_ROUTER)
|
||||||
@@ -110,7 +110,7 @@ feature {NONE} -- Implementation: routes
|
|||||||
l_methods.enable_get
|
l_methods.enable_get
|
||||||
l_methods.enable_post
|
l_methods.enable_post
|
||||||
l_methods.enable_put
|
l_methods.enable_put
|
||||||
a_router.handle_with_request_methods ("/node/{id}/title", l_report_handler, l_methods)
|
a_router.handle_with_request_methods ("/node/{id}/field/title", l_report_handler, l_methods)
|
||||||
end
|
end
|
||||||
|
|
||||||
configure_api_node_content (a_api: CMS_API; a_node_api: CMS_NODE_API; a_router: WSF_ROUTER)
|
configure_api_node_content (a_api: CMS_API; a_node_api: CMS_NODE_API; a_router: WSF_ROUTER)
|
||||||
@@ -123,7 +123,7 @@ feature {NONE} -- Implementation: routes
|
|||||||
l_methods.enable_get
|
l_methods.enable_get
|
||||||
l_methods.enable_post
|
l_methods.enable_post
|
||||||
l_methods.enable_put
|
l_methods.enable_put
|
||||||
a_router.handle_with_request_methods ("/node/{id}/content", l_report_handler, l_methods)
|
a_router.handle_with_request_methods ("/node/{id}/field/content", l_report_handler, l_methods)
|
||||||
end
|
end
|
||||||
|
|
||||||
feature -- Hooks
|
feature -- Hooks
|
||||||
@@ -156,48 +156,4 @@ feature -- Hooks
|
|||||||
a_menu_system.primary_menu.extend (lnk)
|
a_menu_system.primary_menu.extend (lnk)
|
||||||
end
|
end
|
||||||
|
|
||||||
feature -- Handler
|
|
||||||
|
|
||||||
do_get_nodes (req: WSF_REQUEST; res: WSF_RESPONSE; a_api: CMS_API; a_node_api: CMS_NODE_API)
|
|
||||||
local
|
|
||||||
r: CMS_RESPONSE
|
|
||||||
s: STRING
|
|
||||||
l_user: CMS_USER
|
|
||||||
l_node: CMS_NODE
|
|
||||||
do
|
|
||||||
create {GENERIC_VIEW_CMS_RESPONSE} r.make (req, res, a_api)
|
|
||||||
|
|
||||||
if attached a_api.user_api.user_by_name ("foo") as u then
|
|
||||||
l_user := u
|
|
||||||
else
|
|
||||||
create l_user.make ("foo")
|
|
||||||
l_user.set_password ("foobar#")
|
|
||||||
l_user.set_email ("test@example.com")
|
|
||||||
a_api.user_api.new_user (l_user)
|
|
||||||
end
|
|
||||||
if a_node_api.nodes_count = 0 then
|
|
||||||
create l_node.make ({STRING_32} "This is a content", {STRING_32} "And a summary", {STRING_32} "Nice title")
|
|
||||||
l_node.set_author (l_user)
|
|
||||||
a_node_api.new_node (l_node)
|
|
||||||
end
|
|
||||||
|
|
||||||
create s.make_from_string ("<p>Nodes:</p>")
|
|
||||||
if attached a_node_api.nodes as lst then
|
|
||||||
across
|
|
||||||
lst as ic
|
|
||||||
loop
|
|
||||||
s.append ("<li>")
|
|
||||||
s.append (a_api.html_encoded (ic.item.title))
|
|
||||||
s.append (" (")
|
|
||||||
s.append (ic.item.id.out)
|
|
||||||
s.append (")")
|
|
||||||
s.append ("</li>%N")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
r.set_main_content (s)
|
|
||||||
r.add_block (create {CMS_CONTENT_BLOCK}.make ("nodes_warning", Void, "/nodes/ is not yet fully implemented<br/>", Void), "highlighted")
|
|
||||||
r.execute
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ feature -- Access: user
|
|||||||
|
|
||||||
users: LIST [CMS_USER]
|
users: LIST [CMS_USER]
|
||||||
do
|
do
|
||||||
create {ARRAYED_LIST[CMS_USER]} Result.make (0)
|
create {ARRAYED_LIST [CMS_USER]} Result.make (0)
|
||||||
end
|
end
|
||||||
|
|
||||||
user_by_id (a_id: like {CMS_USER}.id): detachable CMS_USER
|
user_by_id (a_id: like {CMS_USER}.id): detachable CMS_USER
|
||||||
@@ -70,16 +70,16 @@ feature -- Access: user
|
|||||||
|
|
||||||
feature -- User Nodes
|
feature -- User Nodes
|
||||||
|
|
||||||
user_collaborator_nodes (a_id: like {CMS_USER}.id): LIST[CMS_NODE]
|
user_collaborator_nodes (a_id: like {CMS_USER}.id): LIST [CMS_NODE]
|
||||||
-- Possible list of nodes where the user identified by `a_id', is a collaborator.
|
-- Possible list of nodes where the user identified by `a_id', is a collaborator.
|
||||||
do
|
do
|
||||||
create {ARRAYED_LIST[CMS_NODE]} Result.make (0)
|
create {ARRAYED_LIST [CMS_NODE]} Result.make (0)
|
||||||
end
|
end
|
||||||
|
|
||||||
user_author_nodes (a_id: like {CMS_USER}.id): LIST[CMS_NODE]
|
user_author_nodes (a_id: like {CMS_USER}.id): LIST [CMS_NODE]
|
||||||
-- Possible list of nodes where the user identified by `a_id', is the author.
|
-- Possible list of nodes where the user identified by `a_id', is the author.
|
||||||
do
|
do
|
||||||
create {ARRAYED_LIST[CMS_NODE]} Result.make (0)
|
create {ARRAYED_LIST [CMS_NODE]} Result.make (0)
|
||||||
end
|
end
|
||||||
|
|
||||||
feature -- Change: user
|
feature -- Change: user
|
||||||
@@ -87,6 +87,7 @@ feature -- Change: user
|
|||||||
new_user (a_user: CMS_USER)
|
new_user (a_user: CMS_USER)
|
||||||
-- Add a new user `a_user'.
|
-- Add a new user `a_user'.
|
||||||
do
|
do
|
||||||
|
a_user.set_id (1)
|
||||||
end
|
end
|
||||||
|
|
||||||
update_user (a_user: CMS_USER)
|
update_user (a_user: CMS_USER)
|
||||||
@@ -102,10 +103,9 @@ feature -- Access: roles and permissions
|
|||||||
|
|
||||||
user_roles: LIST [CMS_USER_ROLE]
|
user_roles: LIST [CMS_USER_ROLE]
|
||||||
do
|
do
|
||||||
create {ARRAYED_LIST[CMS_USER_ROLE]} Result.make (0)
|
create {ARRAYED_LIST [CMS_USER_ROLE]} Result.make (0)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
feature -- Change: roles and permissions
|
feature -- Change: roles and permissions
|
||||||
|
|
||||||
save_user_role (a_user_role: CMS_USER_ROLE)
|
save_user_role (a_user_role: CMS_USER_ROLE)
|
||||||
@@ -122,13 +122,13 @@ feature -- Access: node
|
|||||||
nodes: LIST[CMS_NODE]
|
nodes: LIST[CMS_NODE]
|
||||||
-- List of nodes.
|
-- List of nodes.
|
||||||
do
|
do
|
||||||
create {ARRAYED_LIST[CMS_NODE]} Result.make (0)
|
create {ARRAYED_LIST [CMS_NODE]} Result.make (0)
|
||||||
end
|
end
|
||||||
|
|
||||||
recent_nodes (a_lower: INTEGER; a_count: INTEGER): LIST [CMS_NODE]
|
recent_nodes (a_lower: INTEGER; a_count: INTEGER): LIST [CMS_NODE]
|
||||||
-- List of the `a_count' most recent nodes, starting from `a_lower'.
|
-- List of the `a_count' most recent nodes, starting from `a_lower'.
|
||||||
do
|
do
|
||||||
create {ARRAYED_LIST[CMS_NODE]} Result.make (0)
|
create {ARRAYED_LIST [CMS_NODE]} Result.make (0)
|
||||||
end
|
end
|
||||||
|
|
||||||
node_by_id (a_id: INTEGER_64): detachable CMS_NODE
|
node_by_id (a_id: INTEGER_64): detachable CMS_NODE
|
||||||
@@ -144,7 +144,7 @@ feature -- Access: node
|
|||||||
node_collaborators (a_id: like {CMS_NODE}.id): LIST [CMS_USER]
|
node_collaborators (a_id: like {CMS_NODE}.id): LIST [CMS_USER]
|
||||||
-- Possible list of node's collaborator.
|
-- Possible list of node's collaborator.
|
||||||
do
|
do
|
||||||
create {ARRAYED_LIST[CMS_USER]} Result.make (0)
|
create {ARRAYED_LIST [CMS_USER]} Result.make (0)
|
||||||
end
|
end
|
||||||
|
|
||||||
feature -- Node
|
feature -- Node
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ feature -- Access
|
|||||||
-- Number of items nodes.
|
-- Number of items nodes.
|
||||||
do
|
do
|
||||||
error_handler.reset
|
error_handler.reset
|
||||||
log.write_information (generator + ".nodes_count")
|
write_information_log (generator + ".nodes_count")
|
||||||
sql_query (select_nodes_count, Void)
|
sql_query (select_nodes_count, Void)
|
||||||
if sql_rows_count = 1 then
|
if sql_rows_count = 1 then
|
||||||
Result := sql_read_integer_64 (1)
|
Result := sql_read_integer_64 (1)
|
||||||
@@ -35,7 +35,7 @@ feature -- Access
|
|||||||
create {ARRAYED_LIST [CMS_NODE]} Result.make (0)
|
create {ARRAYED_LIST [CMS_NODE]} Result.make (0)
|
||||||
|
|
||||||
error_handler.reset
|
error_handler.reset
|
||||||
log.write_information (generator + ".nodes")
|
write_information_log (generator + ".nodes")
|
||||||
|
|
||||||
from
|
from
|
||||||
sql_query (select_nodes, Void)
|
sql_query (select_nodes, Void)
|
||||||
@@ -58,7 +58,7 @@ feature -- Access
|
|||||||
create {ARRAYED_LIST [CMS_NODE]} Result.make (0)
|
create {ARRAYED_LIST [CMS_NODE]} Result.make (0)
|
||||||
|
|
||||||
error_handler.reset
|
error_handler.reset
|
||||||
log.write_information (generator + ".nodes")
|
write_information_log (generator + ".nodes")
|
||||||
|
|
||||||
from
|
from
|
||||||
create l_parameters.make (2)
|
create l_parameters.make (2)
|
||||||
@@ -82,7 +82,7 @@ feature -- Access
|
|||||||
l_parameters: STRING_TABLE [ANY]
|
l_parameters: STRING_TABLE [ANY]
|
||||||
do
|
do
|
||||||
error_handler.reset
|
error_handler.reset
|
||||||
log.write_information (generator + ".node")
|
write_information_log (generator + ".node")
|
||||||
create l_parameters.make (1)
|
create l_parameters.make (1)
|
||||||
l_parameters.put (a_id,"id")
|
l_parameters.put (a_id,"id")
|
||||||
sql_query (select_node_by_id, l_parameters)
|
sql_query (select_node_by_id, l_parameters)
|
||||||
@@ -97,7 +97,7 @@ feature -- Access
|
|||||||
l_parameters: STRING_TABLE [ANY]
|
l_parameters: STRING_TABLE [ANY]
|
||||||
do
|
do
|
||||||
error_handler.reset
|
error_handler.reset
|
||||||
log.write_information (generator + ".node_author")
|
write_information_log (generator + ".node_author")
|
||||||
create l_parameters.make (1)
|
create l_parameters.make (1)
|
||||||
l_parameters.put (a_id, "node_id")
|
l_parameters.put (a_id, "node_id")
|
||||||
sql_query (select_node_author, l_parameters)
|
sql_query (select_node_author, l_parameters)
|
||||||
@@ -110,7 +110,7 @@ feature -- Access
|
|||||||
-- Last insert node id.
|
-- Last insert node id.
|
||||||
do
|
do
|
||||||
error_handler.reset
|
error_handler.reset
|
||||||
log.write_information (generator + ".last_inserted_node_id")
|
write_information_log (generator + ".last_inserted_node_id")
|
||||||
sql_query (Sql_last_insert_node_id, Void)
|
sql_query (Sql_last_insert_node_id, Void)
|
||||||
if sql_rows_count = 1 then
|
if sql_rows_count = 1 then
|
||||||
Result := sql_read_integer_64 (1)
|
Result := sql_read_integer_64 (1)
|
||||||
@@ -126,7 +126,7 @@ feature -- Change: Node
|
|||||||
do
|
do
|
||||||
-- New node
|
-- New node
|
||||||
error_handler.reset
|
error_handler.reset
|
||||||
log.write_information (generator + ".new_node")
|
write_information_log (generator + ".new_node")
|
||||||
create l_parameters.make (7)
|
create l_parameters.make (7)
|
||||||
l_parameters.put (a_node.title, "title")
|
l_parameters.put (a_node.title, "title")
|
||||||
l_parameters.put (a_node.summary, "summary")
|
l_parameters.put (a_node.summary, "summary")
|
||||||
@@ -153,7 +153,7 @@ feature -- Change: Node
|
|||||||
local
|
local
|
||||||
l_parameters: STRING_TABLE [ANY]
|
l_parameters: STRING_TABLE [ANY]
|
||||||
do
|
do
|
||||||
log.write_information (generator + ".delete_node")
|
write_information_log (generator + ".delete_node")
|
||||||
|
|
||||||
error_handler.reset
|
error_handler.reset
|
||||||
create l_parameters.make (1)
|
create l_parameters.make (1)
|
||||||
@@ -169,7 +169,7 @@ feature -- Change: Node
|
|||||||
do
|
do
|
||||||
create now.make_now_utc
|
create now.make_now_utc
|
||||||
error_handler.reset
|
error_handler.reset
|
||||||
log.write_information (generator + ".update_node")
|
write_information_log (generator + ".update_node")
|
||||||
create l_parameters.make (7)
|
create l_parameters.make (7)
|
||||||
l_parameters.put (a_node.title, "title")
|
l_parameters.put (a_node.title, "title")
|
||||||
l_parameters.put (a_node.summary, "summary")
|
l_parameters.put (a_node.summary, "summary")
|
||||||
@@ -195,7 +195,7 @@ feature -- Change: Node
|
|||||||
do
|
do
|
||||||
-- FIXME: unused a_user_id !
|
-- FIXME: unused a_user_id !
|
||||||
error_handler.reset
|
error_handler.reset
|
||||||
log.write_information (generator + ".update_node_title")
|
write_information_log (generator + ".update_node_title")
|
||||||
create l_parameters.make (3)
|
create l_parameters.make (3)
|
||||||
l_parameters.put (a_title, "title")
|
l_parameters.put (a_title, "title")
|
||||||
l_parameters.put (create {DATE_TIME}.make_now_utc, "changed")
|
l_parameters.put (create {DATE_TIME}.make_now_utc, "changed")
|
||||||
@@ -210,7 +210,7 @@ feature -- Change: Node
|
|||||||
do
|
do
|
||||||
-- FIXME: unused a_user_id !
|
-- FIXME: unused a_user_id !
|
||||||
error_handler.reset
|
error_handler.reset
|
||||||
log.write_information (generator + ".update_node_summary")
|
write_information_log (generator + ".update_node_summary")
|
||||||
create l_parameters.make (3)
|
create l_parameters.make (3)
|
||||||
l_parameters.put (a_summary, "summary")
|
l_parameters.put (a_summary, "summary")
|
||||||
l_parameters.put (create {DATE_TIME}.make_now_utc, "changed")
|
l_parameters.put (create {DATE_TIME}.make_now_utc, "changed")
|
||||||
@@ -225,7 +225,7 @@ feature -- Change: Node
|
|||||||
do
|
do
|
||||||
-- FIXME: unused a_user_id !
|
-- FIXME: unused a_user_id !
|
||||||
error_handler.reset
|
error_handler.reset
|
||||||
log.write_information (generator + ".update_node_content")
|
write_information_log (generator + ".update_node_content")
|
||||||
create l_parameters.make (3)
|
create l_parameters.make (3)
|
||||||
l_parameters.put (a_content, "content")
|
l_parameters.put (a_content, "content")
|
||||||
l_parameters.put (create {DATE_TIME}.make_now_utc, "changed")
|
l_parameters.put (create {DATE_TIME}.make_now_utc, "changed")
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ feature -- Access: user
|
|||||||
-- Number of items users.
|
-- Number of items users.
|
||||||
do
|
do
|
||||||
error_handler.reset
|
error_handler.reset
|
||||||
log.write_information (generator + ".user_count")
|
write_information_log (generator + ".user_count")
|
||||||
|
|
||||||
sql_query (select_users_count, Void)
|
sql_query (select_users_count, Void)
|
||||||
if sql_rows_count = 1 then
|
if sql_rows_count = 1 then
|
||||||
@@ -41,7 +41,7 @@ feature -- Access: user
|
|||||||
create {ARRAYED_LIST [CMS_USER]} Result.make (0)
|
create {ARRAYED_LIST [CMS_USER]} Result.make (0)
|
||||||
|
|
||||||
error_handler.reset
|
error_handler.reset
|
||||||
log.write_information (generator + ".all_users")
|
write_information_log (generator + ".all_users")
|
||||||
|
|
||||||
from
|
from
|
||||||
sql_query (select_users, Void)
|
sql_query (select_users, Void)
|
||||||
@@ -62,7 +62,7 @@ feature -- Access: user
|
|||||||
l_parameters: STRING_TABLE [detachable ANY]
|
l_parameters: STRING_TABLE [detachable ANY]
|
||||||
do
|
do
|
||||||
error_handler.reset
|
error_handler.reset
|
||||||
log.write_information (generator + ".user")
|
write_information_log (generator + ".user")
|
||||||
create l_parameters.make (1)
|
create l_parameters.make (1)
|
||||||
l_parameters.put (a_id, "uid")
|
l_parameters.put (a_id, "uid")
|
||||||
sql_query (select_user_by_id, l_parameters)
|
sql_query (select_user_by_id, l_parameters)
|
||||||
@@ -79,7 +79,7 @@ feature -- Access: user
|
|||||||
l_parameters: STRING_TABLE [detachable ANY]
|
l_parameters: STRING_TABLE [detachable ANY]
|
||||||
do
|
do
|
||||||
error_handler.reset
|
error_handler.reset
|
||||||
log.write_information (generator + ".user_by_name")
|
write_information_log (generator + ".user_by_name")
|
||||||
create l_parameters.make (1)
|
create l_parameters.make (1)
|
||||||
l_parameters.put (a_name, "name")
|
l_parameters.put (a_name, "name")
|
||||||
sql_query (select_user_by_name, l_parameters)
|
sql_query (select_user_by_name, l_parameters)
|
||||||
@@ -96,7 +96,7 @@ feature -- Access: user
|
|||||||
l_parameters: STRING_TABLE [detachable ANY]
|
l_parameters: STRING_TABLE [detachable ANY]
|
||||||
do
|
do
|
||||||
error_handler.reset
|
error_handler.reset
|
||||||
log.write_information (generator + ".user_by_email")
|
write_information_log (generator + ".user_by_email")
|
||||||
create l_parameters.make (1)
|
create l_parameters.make (1)
|
||||||
l_parameters.put (a_email, "email")
|
l_parameters.put (a_email, "email")
|
||||||
sql_query (select_user_by_email, l_parameters)
|
sql_query (select_user_by_email, l_parameters)
|
||||||
@@ -120,10 +120,10 @@ feature -- Access: user
|
|||||||
then
|
then
|
||||||
Result := True
|
Result := True
|
||||||
else
|
else
|
||||||
log.write_information (generator + ".is_valid_credential User: wrong username or password" )
|
write_information_log (generator + ".is_valid_credential User: wrong username or password" )
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
log.write_information (generator + ".is_valid_credential User:" + l_auth_login + "does not exist" )
|
write_information_log (generator + ".is_valid_credential User:" + l_auth_login + "does not exist" )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -148,7 +148,7 @@ feature -- Change: user
|
|||||||
l_password_salt := l_security.salt
|
l_password_salt := l_security.salt
|
||||||
l_password_hash := l_security.password_hash (l_password, l_password_salt)
|
l_password_hash := l_security.password_hash (l_password, l_password_salt)
|
||||||
|
|
||||||
log.write_information (generator + ".new_user")
|
write_information_log (generator + ".new_user")
|
||||||
create l_parameters.make (4)
|
create l_parameters.make (4)
|
||||||
l_parameters.put (a_user.name, "name")
|
l_parameters.put (a_user.name, "name")
|
||||||
l_parameters.put (l_password_hash, "password")
|
l_parameters.put (l_password_hash, "password")
|
||||||
@@ -189,7 +189,7 @@ feature -- Change: user
|
|||||||
l_password_hash /= Void and l_password_salt /= Void and
|
l_password_hash /= Void and l_password_salt /= Void and
|
||||||
attached a_user.email as l_email
|
attached a_user.email as l_email
|
||||||
then
|
then
|
||||||
log.write_information (generator + ".update_user")
|
write_information_log (generator + ".update_user")
|
||||||
create l_parameters.make (6)
|
create l_parameters.make (6)
|
||||||
l_parameters.put (a_user.id, "uid")
|
l_parameters.put (a_user.id, "uid")
|
||||||
l_parameters.put (a_user.name, "name")
|
l_parameters.put (a_user.name, "name")
|
||||||
@@ -233,7 +233,7 @@ feature {NONE} -- Implementation
|
|||||||
l_parameters: STRING_TABLE [detachable ANY]
|
l_parameters: STRING_TABLE [detachable ANY]
|
||||||
do
|
do
|
||||||
error_handler.reset
|
error_handler.reset
|
||||||
log.write_information (generator + ".user_salt")
|
write_information_log (generator + ".user_salt")
|
||||||
create l_parameters.make (1)
|
create l_parameters.make (1)
|
||||||
l_parameters.put (a_username, "name")
|
l_parameters.put (a_username, "name")
|
||||||
sql_query (select_salt_by_username, l_parameters)
|
sql_query (select_salt_by_username, l_parameters)
|
||||||
@@ -282,7 +282,7 @@ feature {NONE} -- Implementation
|
|||||||
-- Last insert user id.
|
-- Last insert user id.
|
||||||
do
|
do
|
||||||
error_handler.reset
|
error_handler.reset
|
||||||
log.write_information (generator + ".last_inserted_user_id")
|
write_information_log (generator + ".last_inserted_user_id")
|
||||||
sql_query (Sql_last_insert_user_id, Void)
|
sql_query (Sql_last_insert_user_id, Void)
|
||||||
if sql_rows_count = 1 then
|
if sql_rows_count = 1 then
|
||||||
Result := sql_read_integer_64 (1)
|
Result := sql_read_integer_64 (1)
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ feature -- Access
|
|||||||
-- Logger
|
-- Logger
|
||||||
|
|
||||||
storage: CMS_STORAGE
|
storage: CMS_STORAGE
|
||||||
-- Persistence storage.
|
-- Default persistence storage.
|
||||||
|
|
||||||
feature -- Status Report
|
feature -- Status Report
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
note
|
note
|
||||||
description: "Summary description for {CMS_HANDLER}."
|
description: "[
|
||||||
author: ""
|
Common interface for request handler specific to the CMS component.
|
||||||
|
]"
|
||||||
date: "$Date: 2015-02-13 13:08:13 +0100 (ven., 13 févr. 2015) $"
|
date: "$Date: 2015-02-13 13:08:13 +0100 (ven., 13 févr. 2015) $"
|
||||||
revision: "$Revision: 96616 $"
|
revision: "$Revision: 96616 $"
|
||||||
|
|
||||||
@@ -26,4 +27,19 @@ feature -- API Service
|
|||||||
|
|
||||||
api: CMS_API
|
api: CMS_API
|
||||||
|
|
||||||
|
feature -- Response helpers
|
||||||
|
|
||||||
|
redirect_to (a_location: READABLE_STRING_8; res: WSF_RESPONSE)
|
||||||
|
-- Send via `res' a redirection message for location `a_location'.
|
||||||
|
do
|
||||||
|
res.redirect_now (a_location)
|
||||||
|
-- res.send (create {CMS_REDIRECTION_RESPONSE_MESSAGE}.make (a_location))
|
||||||
|
end
|
||||||
|
|
||||||
|
send_access_denied (res: WSF_RESPONSE)
|
||||||
|
-- Send via `res' an access denied response.
|
||||||
|
do
|
||||||
|
res.send (create {CMS_FORBIDDEN_RESPONSE_MESSAGE}.make)
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -11,9 +11,6 @@ inherit
|
|||||||
CMS_LOGGER
|
CMS_LOGGER
|
||||||
|
|
||||||
SHARED_LOGGER
|
SHARED_LOGGER
|
||||||
rename
|
|
||||||
log as log_facility
|
|
||||||
end
|
|
||||||
|
|
||||||
create
|
create
|
||||||
make
|
make
|
||||||
@@ -29,32 +26,32 @@ feature -- Logging
|
|||||||
|
|
||||||
put_information (a_message: READABLE_STRING_8; a_data: detachable ANY)
|
put_information (a_message: READABLE_STRING_8; a_data: detachable ANY)
|
||||||
do
|
do
|
||||||
log_facility.write_information (log_message (a_message, a_data))
|
write_information_log (log_message (a_message, a_data))
|
||||||
end
|
end
|
||||||
|
|
||||||
put_error (a_message: READABLE_STRING_8; a_data: detachable ANY)
|
put_error (a_message: READABLE_STRING_8; a_data: detachable ANY)
|
||||||
do
|
do
|
||||||
log_facility.write_error (log_message (a_message, a_data))
|
write_error_log (log_message (a_message, a_data))
|
||||||
end
|
end
|
||||||
|
|
||||||
put_warning (a_message: READABLE_STRING_8; a_data: detachable ANY)
|
put_warning (a_message: READABLE_STRING_8; a_data: detachable ANY)
|
||||||
do
|
do
|
||||||
log_facility.write_warning (log_message (a_message, a_data))
|
write_warning_log (log_message (a_message, a_data))
|
||||||
end
|
end
|
||||||
|
|
||||||
put_critical (a_message: READABLE_STRING_8; a_data: detachable ANY)
|
put_critical (a_message: READABLE_STRING_8; a_data: detachable ANY)
|
||||||
do
|
do
|
||||||
log_facility.write_critical (log_message (a_message, a_data))
|
write_critical_log (log_message (a_message, a_data))
|
||||||
end
|
end
|
||||||
|
|
||||||
put_alert (a_message: READABLE_STRING_8; a_data: detachable ANY)
|
put_alert (a_message: READABLE_STRING_8; a_data: detachable ANY)
|
||||||
do
|
do
|
||||||
log_facility.write_alert (log_message (a_message, a_data))
|
write_alert_log (log_message (a_message, a_data))
|
||||||
end
|
end
|
||||||
|
|
||||||
put_debug (a_message: READABLE_STRING_8; a_data: detachable ANY)
|
put_debug (a_message: READABLE_STRING_8; a_data: detachable ANY)
|
||||||
do
|
do
|
||||||
log_facility.write_debug (log_message (a_message, a_data))
|
write_debug_log (log_message (a_message, a_data))
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
note
|
note
|
||||||
description: "Summary description for {CMS_REQUEST_UTIL}."
|
description: "Set of helper features related to CMS Request needs."
|
||||||
author: ""
|
|
||||||
date: "$Date: 2015-02-13 13:08:13 +0100 (ven., 13 févr. 2015) $"
|
date: "$Date: 2015-02-13 13:08:13 +0100 (ven., 13 févr. 2015) $"
|
||||||
revision: "$Revision: 96616 $"
|
revision: "$Revision: 96616 $"
|
||||||
|
|
||||||
@@ -29,7 +28,7 @@ feature -- User
|
|||||||
note
|
note
|
||||||
EIS: "eiffel:?class=AUTHENTICATION_FILTER&feature=execute"
|
EIS: "eiffel:?class=AUTHENTICATION_FILTER&feature=execute"
|
||||||
do
|
do
|
||||||
if attached {CMS_USER} req.execution_variable ("_cms_active_user_") as l_user then
|
if attached {CMS_USER} req.execution_variable (current_user_execution_variable_name) as l_user then
|
||||||
Result := l_user
|
Result := l_user
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -40,14 +39,27 @@ feature -- Change
|
|||||||
-- Set `a_user' as `current_user'.
|
-- Set `a_user' as `current_user'.
|
||||||
do
|
do
|
||||||
if a_user = Void then
|
if a_user = Void then
|
||||||
req.unset_execution_variable ("_cms_active_user_")
|
req.unset_execution_variable (current_user_execution_variable_name)
|
||||||
else
|
else
|
||||||
req.set_execution_variable ("_cms_active_user_", a_user)
|
req.set_execution_variable (current_user_execution_variable_name, a_user)
|
||||||
end
|
end
|
||||||
ensure
|
ensure
|
||||||
user_set: current_user (req) ~ a_user
|
user_set: current_user (req) ~ a_user
|
||||||
end
|
end
|
||||||
|
|
||||||
|
unset_current_user (req: WSF_REQUEST)
|
||||||
|
-- Unset current user.
|
||||||
|
do
|
||||||
|
req.unset_execution_variable (current_user_execution_variable_name)
|
||||||
|
ensure
|
||||||
|
user_unset: current_user (req) = Void
|
||||||
|
end
|
||||||
|
|
||||||
|
feature {NONE} -- Implementation: current user
|
||||||
|
|
||||||
|
current_user_execution_variable_name: STRING = "_cms_active_user_"
|
||||||
|
-- Execution variable name used to keep current user data.
|
||||||
|
|
||||||
feature -- Media Type
|
feature -- Media Type
|
||||||
|
|
||||||
current_media_type (req: WSF_REQUEST): detachable READABLE_STRING_32
|
current_media_type (req: WSF_REQUEST): detachable READABLE_STRING_32
|
||||||
|
|||||||
25
src/service/response/cms_forbidden_response_message.e
Normal file
25
src/service/response/cms_forbidden_response_message.e
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
note
|
||||||
|
description: "[
|
||||||
|
Message response to notify a forbidden access.
|
||||||
|
]"
|
||||||
|
date: "$Date$"
|
||||||
|
revision: "$Revision$"
|
||||||
|
|
||||||
|
class
|
||||||
|
CMS_FORBIDDEN_RESPONSE_MESSAGE
|
||||||
|
|
||||||
|
inherit
|
||||||
|
CMS_RESPONSE_MESSAGE
|
||||||
|
|
||||||
|
create
|
||||||
|
make
|
||||||
|
|
||||||
|
feature {NONE} -- Initialization
|
||||||
|
|
||||||
|
make
|
||||||
|
do
|
||||||
|
initialize
|
||||||
|
status_code := {HTTP_STATUS_CODE}.forbidden
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
@@ -1,61 +0,0 @@
|
|||||||
note
|
|
||||||
description: "Summary description for {CMS_GENERIC_RESPONSE}."
|
|
||||||
date: "$Date: 2014-11-13 16:23:47 +0100 (jeu., 13 nov. 2014) $"
|
|
||||||
revision: "$Revision: 96085 $"
|
|
||||||
|
|
||||||
class
|
|
||||||
CMS_GENERIC_RESPONSE
|
|
||||||
|
|
||||||
feature -- Responses
|
|
||||||
|
|
||||||
new_response_redirect (req: WSF_REQUEST; res: WSF_RESPONSE; a_location: READABLE_STRING_32)
|
|
||||||
-- Redirect to `a_location'
|
|
||||||
local
|
|
||||||
h: HTTP_HEADER
|
|
||||||
do
|
|
||||||
create h.make
|
|
||||||
h.put_content_type_text_html
|
|
||||||
h.put_current_date
|
|
||||||
h.put_location (a_location)
|
|
||||||
res.set_status_code ({HTTP_STATUS_CODE}.see_other)
|
|
||||||
res.put_header_text (h.string)
|
|
||||||
end
|
|
||||||
|
|
||||||
new_response_authenticate (req: WSF_REQUEST; res: WSF_RESPONSE)
|
|
||||||
-- Handle authenticate.
|
|
||||||
local
|
|
||||||
h: HTTP_HEADER
|
|
||||||
do
|
|
||||||
create h.make
|
|
||||||
h.put_content_type_text_html
|
|
||||||
h.put_current_date
|
|
||||||
h.put_header_key_value ({HTTP_HEADER_NAMES}.header_www_authenticate, "Basic realm=%"CMSRoc-User%"")
|
|
||||||
res.set_status_code ({HTTP_STATUS_CODE}.unauthorized)
|
|
||||||
res.put_header_text (h.string)
|
|
||||||
end
|
|
||||||
|
|
||||||
new_response_denied (req: WSF_REQUEST; res: WSF_RESPONSE)
|
|
||||||
-- Handle access denied.
|
|
||||||
local
|
|
||||||
h: HTTP_HEADER
|
|
||||||
do
|
|
||||||
create h.make
|
|
||||||
h.put_content_type_text_html
|
|
||||||
h.put_current_date
|
|
||||||
res.set_status_code ({HTTP_STATUS_CODE}.unauthorized)
|
|
||||||
res.put_header_text (h.string)
|
|
||||||
end
|
|
||||||
|
|
||||||
new_response_unauthorized (req: WSF_REQUEST; res: WSF_RESPONSE)
|
|
||||||
-- Handle not authorized.
|
|
||||||
local
|
|
||||||
h: HTTP_HEADER
|
|
||||||
do
|
|
||||||
create h.make
|
|
||||||
h.put_content_type_text_html
|
|
||||||
h.put_current_date
|
|
||||||
res.set_status_code ({HTTP_STATUS_CODE}.forbidden)
|
|
||||||
res.put_header_text (h.string)
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
26
src/service/response/cms_redirection_response_message.e
Normal file
26
src/service/response/cms_redirection_response_message.e
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
note
|
||||||
|
description: "[
|
||||||
|
Message response to redirect client to new location.
|
||||||
|
]"
|
||||||
|
date: "$Date$"
|
||||||
|
revision: "$Revision$"
|
||||||
|
|
||||||
|
class
|
||||||
|
CMS_REDIRECTION_RESPONSE_MESSAGE
|
||||||
|
|
||||||
|
inherit
|
||||||
|
CMS_RESPONSE_MESSAGE
|
||||||
|
|
||||||
|
create
|
||||||
|
make
|
||||||
|
|
||||||
|
feature {NONE} -- Initialization
|
||||||
|
|
||||||
|
make (a_location: READABLE_STRING_8)
|
||||||
|
do
|
||||||
|
initialize
|
||||||
|
status_code := {HTTP_STATUS_CODE}.see_other
|
||||||
|
header.put_location (a_location)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
@@ -1,5 +1,8 @@
|
|||||||
note
|
note
|
||||||
description: "Generic CMS Response.It builds the content to get process to render the output"
|
description: "[
|
||||||
|
Generic CMS Response.
|
||||||
|
It builds the content to get process to render the output.
|
||||||
|
]"
|
||||||
date: "$Date: 2015-02-16 20:14:19 +0100 (lun., 16 févr. 2015) $"
|
date: "$Date: 2015-02-16 20:14:19 +0100 (lun., 16 févr. 2015) $"
|
||||||
revision: "$Revision: 96643 $"
|
revision: "$Revision: 96643 $"
|
||||||
|
|
||||||
@@ -79,6 +82,9 @@ feature -- Access
|
|||||||
additional_page_head_lines: detachable LIST [READABLE_STRING_8]
|
additional_page_head_lines: detachable LIST [READABLE_STRING_8]
|
||||||
-- HTML>head>...extra lines
|
-- HTML>head>...extra lines
|
||||||
|
|
||||||
|
redirection: detachable READABLE_STRING_8
|
||||||
|
-- Location for eventual redirection.
|
||||||
|
|
||||||
feature -- Module
|
feature -- Module
|
||||||
|
|
||||||
module_resource_path (a_module: CMS_MODULE; a_resource: PATH): detachable PATH
|
module_resource_path (a_module: CMS_MODULE; a_resource: PATH): detachable PATH
|
||||||
@@ -239,6 +245,11 @@ feature -- Element change
|
|||||||
values.remove (k)
|
values.remove (k)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
set_redirection (a_location: READABLE_STRING_8)
|
||||||
|
-- Set `redirection' to `a_location'.
|
||||||
|
do
|
||||||
|
redirection := a_location
|
||||||
|
end
|
||||||
|
|
||||||
feature -- Logging
|
feature -- Logging
|
||||||
|
|
||||||
@@ -247,7 +258,7 @@ feature -- Logging
|
|||||||
-- l_log: CMS_LOG
|
-- l_log: CMS_LOG
|
||||||
do
|
do
|
||||||
debug
|
debug
|
||||||
to_implement ("Add implemenatation")
|
to_implement ("Add implementation")
|
||||||
end
|
end
|
||||||
-- create l_log.make (a_category, a_message, a_level, Void)
|
-- create l_log.make (a_category, a_message, a_level, Void)
|
||||||
-- if a_link /= Void then
|
-- if a_link /= Void then
|
||||||
@@ -964,8 +975,7 @@ feature -- Generation
|
|||||||
feature -- Custom Variables
|
feature -- Custom Variables
|
||||||
|
|
||||||
variables: detachable STRING_TABLE[ANY]
|
variables: detachable STRING_TABLE[ANY]
|
||||||
-- Custom variables to feed the templates.
|
-- Custom variables to feed the templates.
|
||||||
|
|
||||||
|
|
||||||
feature -- Element change: Add custom variables.
|
feature -- Element change: Add custom variables.
|
||||||
|
|
||||||
@@ -981,7 +991,6 @@ feature -- Element change: Add custom variables.
|
|||||||
l_variables.force (a_element, a_key)
|
l_variables.force (a_element, a_key)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
feature -- Execution
|
feature -- Execution
|
||||||
|
|
||||||
execute
|
execute
|
||||||
@@ -1006,6 +1015,7 @@ feature {NONE} -- Execution
|
|||||||
cms_page: CMS_HTML_PAGE
|
cms_page: CMS_HTML_PAGE
|
||||||
page: CMS_HTML_PAGE_RESPONSE
|
page: CMS_HTML_PAGE_RESPONSE
|
||||||
utf: UTF_CONVERTER
|
utf: UTF_CONVERTER
|
||||||
|
h: HTTP_HEADER
|
||||||
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))
|
||||||
@@ -1015,8 +1025,13 @@ feature {NONE} -- Execution
|
|||||||
prepare (cms_page)
|
prepare (cms_page)
|
||||||
create page.make (theme.page_html (cms_page))
|
create page.make (theme.page_html (cms_page))
|
||||||
page.set_status_code (status_code)
|
page.set_status_code (status_code)
|
||||||
page.header.put_content_length (page.html.count)
|
h := page.header
|
||||||
page.header.put_current_date
|
h.put_content_length (page.html.count)
|
||||||
|
h.put_current_date
|
||||||
|
h.put_header_object (header)
|
||||||
|
if attached redirection as l_location then
|
||||||
|
h.put_location (l_location)
|
||||||
|
end
|
||||||
response.send (page)
|
response.send (page)
|
||||||
on_terminated
|
on_terminated
|
||||||
end
|
end
|
||||||
|
|||||||
53
src/service/response/cms_response_message.e
Normal file
53
src/service/response/cms_response_message.e
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
note
|
||||||
|
description: "Response message interface specific to the CMS component."
|
||||||
|
date: "$Date$"
|
||||||
|
revision: "$Revision$"
|
||||||
|
|
||||||
|
deferred class
|
||||||
|
CMS_RESPONSE_MESSAGE
|
||||||
|
|
||||||
|
inherit
|
||||||
|
WSF_RESPONSE_MESSAGE
|
||||||
|
|
||||||
|
feature {NONE} -- Initialization
|
||||||
|
|
||||||
|
initialize
|
||||||
|
do
|
||||||
|
status_code := {HTTP_STATUS_CODE}.ok
|
||||||
|
create header.make_with_count (2)
|
||||||
|
header.put_current_date
|
||||||
|
header.put_content_type_text_html
|
||||||
|
end
|
||||||
|
|
||||||
|
feature -- Access
|
||||||
|
|
||||||
|
status_code: INTEGER
|
||||||
|
-- Status code for the response.
|
||||||
|
|
||||||
|
header: HTTP_HEADER
|
||||||
|
-- Header associated with the response.
|
||||||
|
|
||||||
|
feature {WSF_RESPONSE} -- Output
|
||||||
|
|
||||||
|
send_to (res: WSF_RESPONSE)
|
||||||
|
-- <Precursor>
|
||||||
|
do
|
||||||
|
res.set_status_code (status_code)
|
||||||
|
|
||||||
|
send_header_to (res)
|
||||||
|
send_payload_to (res)
|
||||||
|
end
|
||||||
|
|
||||||
|
send_header_to (res: WSF_RESPONSE)
|
||||||
|
-- Send header to response `res'.
|
||||||
|
do
|
||||||
|
res.put_header_lines (header)
|
||||||
|
end
|
||||||
|
|
||||||
|
send_payload_to (res: WSF_RESPONSE)
|
||||||
|
-- Send payload data to response `res'.
|
||||||
|
do
|
||||||
|
-- Nothing by default
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
43
src/service/response/cms_unauthorized_response_message.e
Normal file
43
src/service/response/cms_unauthorized_response_message.e
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
note
|
||||||
|
description: "[
|
||||||
|
Message response to notify an unauthorized access.
|
||||||
|
]"
|
||||||
|
date: "$Date$"
|
||||||
|
revision: "$Revision$"
|
||||||
|
|
||||||
|
class
|
||||||
|
CMS_UNAUTHORIZED_RESPONSE_MESSAGE
|
||||||
|
|
||||||
|
inherit
|
||||||
|
CMS_RESPONSE_MESSAGE
|
||||||
|
|
||||||
|
create
|
||||||
|
make,
|
||||||
|
make_with_basic_auth_challenge
|
||||||
|
|
||||||
|
feature {NONE} -- Initialization
|
||||||
|
|
||||||
|
make
|
||||||
|
do
|
||||||
|
initialize
|
||||||
|
status_code := {HTTP_STATUS_CODE}.unauthorized
|
||||||
|
end
|
||||||
|
|
||||||
|
make_with_basic_auth_challenge (a_realm: detachable READABLE_STRING_8)
|
||||||
|
local
|
||||||
|
l_realm: READABLE_STRING_8
|
||||||
|
do
|
||||||
|
make
|
||||||
|
if a_realm /= Void then
|
||||||
|
l_realm := a_realm
|
||||||
|
else
|
||||||
|
l_realm := default_realm
|
||||||
|
end
|
||||||
|
header.put_header_key_value ({HTTP_HEADER_NAMES}.header_www_authenticate, "Basic realm=%""+ l_realm +"%"")
|
||||||
|
end
|
||||||
|
|
||||||
|
feature -- Access
|
||||||
|
|
||||||
|
default_realm: STRING = "CMS-User credential"
|
||||||
|
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user