Initial Import: Database transaction handling.
Initial Import: Error handling using ewf error library. Added a CMS_ERROR_FILTER as part of registered filters of CMS_SERVICE
This commit is contained in:
@@ -10,6 +10,7 @@
|
|||||||
<library name="http" location="$ISE_LIBRARY\contrib\library\network\protocol\http\http-safe.ecf"/>
|
<library name="http" location="$ISE_LIBRARY\contrib\library\network\protocol\http\http-safe.ecf"/>
|
||||||
<library name="json" location="$ISE_LIBRARY\contrib\library\text\parser\json\library\json-safe.ecf" readonly="false"/>
|
<library name="json" location="$ISE_LIBRARY\contrib\library\text\parser\json\library\json-safe.ecf" readonly="false"/>
|
||||||
<library name="layout" location="..\layout\layout-safe.ecf"/>
|
<library name="layout" location="..\layout\layout-safe.ecf"/>
|
||||||
|
<library name="error" location="$ISE_LIBRARY\contrib\library\utility\general\error\error-safe.ecf"/>
|
||||||
<library name="http_authorization" location="$ISE_LIBRARY\contrib\library\network\authentication\http_authorization\http_authorization-safe.ecf" readonly="false"/>
|
<library name="http_authorization" location="$ISE_LIBRARY\contrib\library\network\authentication\http_authorization\http_authorization-safe.ecf" readonly="false"/>
|
||||||
<library name="persistence_mysql" location="..\persistence\implementation\mysql\persistence_mysql-safe.ecf" readonly="false"/>
|
<library name="persistence_mysql" location="..\persistence\implementation\mysql\persistence_mysql-safe.ecf" readonly="false"/>
|
||||||
<library name="smarty" location="$ISE_LIBRARY\contrib\library\text\template\smarty\smarty-safe.ecf" readonly="false"/>
|
<library name="smarty" location="$ISE_LIBRARY\contrib\library\text\template\smarty\smarty-safe.ecf" readonly="false"/>
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ feature {NONE} -- Initialization
|
|||||||
|
|
||||||
make (a_layout: CMS_LAYOUT)
|
make (a_layout: CMS_LAYOUT)
|
||||||
do
|
do
|
||||||
|
create error_handler.make
|
||||||
layout := a_layout
|
layout := a_layout
|
||||||
create configuration.make (layout)
|
create configuration.make (layout)
|
||||||
initialize
|
initialize
|
||||||
@@ -28,7 +29,6 @@ feature {NONE} -- Initialization
|
|||||||
create modules.make (3)
|
create modules.make (3)
|
||||||
build_api_service
|
build_api_service
|
||||||
build_mailer
|
build_mailer
|
||||||
|
|
||||||
initialize_modules
|
initialize_modules
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -61,7 +61,6 @@ feature {NONE} -- Initialization
|
|||||||
-- m.enable
|
-- m.enable
|
||||||
-- modules.extend (m)
|
-- modules.extend (m)
|
||||||
|
|
||||||
|
|
||||||
create {NODE_MODULE} m.make (Current)
|
create {NODE_MODULE} m.make (Current)
|
||||||
m.enable
|
m.enable
|
||||||
modules.extend (m)
|
modules.extend (m)
|
||||||
@@ -89,7 +88,10 @@ feature -- Access
|
|||||||
build_api_service
|
build_api_service
|
||||||
local
|
local
|
||||||
l_database: DATABASE_CONNECTION
|
l_database: DATABASE_CONNECTION
|
||||||
|
l_retry: BOOLEAN
|
||||||
|
l_message: STRING
|
||||||
do
|
do
|
||||||
|
if not l_retry then
|
||||||
to_implement ("Refactor database setup")
|
to_implement ("Refactor database setup")
|
||||||
if attached (create {JSON_CONFIGURATION}).new_database_configuration (layout.application_config_path) as l_database_config then
|
if attached (create {JSON_CONFIGURATION}).new_database_configuration (layout.application_config_path) as l_database_config then
|
||||||
create {DATABASE_CONNECTION_MYSQL} l_database.login_with_connection_string (l_database_config.connection_string)
|
create {DATABASE_CONNECTION_MYSQL} l_database.login_with_connection_string (l_database_config.connection_string)
|
||||||
@@ -98,6 +100,32 @@ feature -- Access
|
|||||||
create {DATABASE_CONNECTION_NULL} l_database.make_common
|
create {DATABASE_CONNECTION_NULL} l_database.make_common
|
||||||
create api_service.make (create {CMS_STORAGE_NULL})
|
create api_service.make (create {CMS_STORAGE_NULL})
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
to_implement ("Workaround code, persistence layer does not implement yet this kind of error handling.")
|
||||||
|
-- error hanling.
|
||||||
|
create {DATABASE_CONNECTION_NULL} l_database.make_common
|
||||||
|
create api_service.make (create {CMS_STORAGE_NULL})
|
||||||
|
create l_message.make (1024)
|
||||||
|
if attached ((create {EXCEPTION_MANAGER}).last_exception) as l_exception then
|
||||||
|
if attached l_exception.description as l_description then
|
||||||
|
l_message.append (l_description.as_string_32)
|
||||||
|
l_message.append ("%N%N")
|
||||||
|
elseif attached l_exception.trace as l_trace then
|
||||||
|
l_message.append (l_trace)
|
||||||
|
l_message.append ("%N%N")
|
||||||
|
else
|
||||||
|
l_message.append (l_exception.out)
|
||||||
|
l_message.append ("%N%N")
|
||||||
|
end
|
||||||
|
else
|
||||||
|
l_message.append ("The application crash without available information")
|
||||||
|
l_message.append ("%N%N")
|
||||||
|
end
|
||||||
|
error_handler.add_custom_error (0, " Database Connection ", l_message)
|
||||||
|
end
|
||||||
|
rescue
|
||||||
|
l_retry := True
|
||||||
|
retry
|
||||||
end
|
end
|
||||||
|
|
||||||
build_auth_engine
|
build_auth_engine
|
||||||
|
|||||||
@@ -32,6 +32,12 @@ feature -- Access
|
|||||||
deferred
|
deferred
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
feature -- Status Report
|
||||||
|
|
||||||
|
error_handler: ERROR_HANDLER
|
||||||
|
-- Error handler.
|
||||||
|
|
||||||
feature -- Access: Site
|
feature -- Access: Site
|
||||||
|
|
||||||
site_id: READABLE_STRING_8
|
site_id: READABLE_STRING_8
|
||||||
|
|||||||
@@ -165,9 +165,15 @@ feature -- Filters
|
|||||||
do
|
do
|
||||||
log.write_debug (generator + ".create_filter")
|
log.write_debug (generator + ".create_filter")
|
||||||
l_filter := Void
|
l_filter := Void
|
||||||
|
|
||||||
-- Maintenance
|
-- Maintenance
|
||||||
create {WSF_MAINTENANCE_FILTER} f
|
create {WSF_MAINTENANCE_FILTER} f
|
||||||
f.set_next (l_filter)
|
f.set_next (l_filter)
|
||||||
|
l_filter := f
|
||||||
|
|
||||||
|
-- Error Filter
|
||||||
|
create {CMS_ERROR_FILTER} f.make (setup)
|
||||||
|
f.set_next (l_filter)
|
||||||
l_filter := f
|
l_filter := f
|
||||||
|
|
||||||
-- Include filters from modules
|
-- Include filters from modules
|
||||||
|
|||||||
33
cms/src/service/filter/cms_error_filter.e
Normal file
33
cms/src/service/filter/cms_error_filter.e
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
note
|
||||||
|
description: "Summary description for {CMS_ERROR_FILTER}."
|
||||||
|
date: "$Date$"
|
||||||
|
revision: "$Revision$"
|
||||||
|
|
||||||
|
class
|
||||||
|
CMS_ERROR_FILTER
|
||||||
|
|
||||||
|
inherit
|
||||||
|
|
||||||
|
WSF_URI_TEMPLATE_HANDLER
|
||||||
|
CMS_HANDLER
|
||||||
|
WSF_FILTER
|
||||||
|
|
||||||
|
create
|
||||||
|
make
|
||||||
|
|
||||||
|
feature -- Basic operations
|
||||||
|
|
||||||
|
execute (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||||
|
-- Execute the filter
|
||||||
|
do
|
||||||
|
if not setup.error_handler.has_error then
|
||||||
|
log.write_information (generator + ".execute")
|
||||||
|
execute_next (req, res)
|
||||||
|
else
|
||||||
|
log.write_critical (generator + ".execute" + setup.error_handler.as_string_representation )
|
||||||
|
(create {ERROR_500_CMS_RESPONSE}.make (req, res, setup, "master2/error")).execute
|
||||||
|
setup.error_handler.reset
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
@@ -10,7 +10,7 @@ inherit
|
|||||||
|
|
||||||
DATABASE_CONFIG
|
DATABASE_CONFIG
|
||||||
|
|
||||||
SHARED_ERROR
|
SHARED_ERROR_HANDLER
|
||||||
|
|
||||||
feature {NONE} -- Initialization
|
feature {NONE} -- Initialization
|
||||||
|
|
||||||
@@ -72,6 +72,65 @@ feature -- Database Setup
|
|||||||
keep_connection: BOOLEAN
|
keep_connection: BOOLEAN
|
||||||
-- Keep connection alive?
|
-- Keep connection alive?
|
||||||
|
|
||||||
|
feature -- Transactions
|
||||||
|
|
||||||
|
begin_transaction
|
||||||
|
-- Start a transaction which will be terminated by a call to `rollback' or `commit'.
|
||||||
|
local
|
||||||
|
rescued: BOOLEAN
|
||||||
|
do
|
||||||
|
if not rescued then
|
||||||
|
if db_control.is_ok then
|
||||||
|
db_control.begin
|
||||||
|
else
|
||||||
|
database_error_handler.add_database_error (db_control.error_message_32, db_control.error_code)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
rescue
|
||||||
|
rescued := True
|
||||||
|
exception_as_error ((create {EXCEPTION_MANAGER}).last_exception)
|
||||||
|
db_control.reset
|
||||||
|
retry
|
||||||
|
end
|
||||||
|
|
||||||
|
commit
|
||||||
|
-- Commit updates in the database.
|
||||||
|
local
|
||||||
|
rescued: BOOLEAN
|
||||||
|
do
|
||||||
|
if not rescued then
|
||||||
|
if db_control.is_ok then
|
||||||
|
db_control.commit
|
||||||
|
else
|
||||||
|
database_error_handler.add_database_error (db_control.error_message_32, db_control.error_code)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
rescue
|
||||||
|
rescued := True
|
||||||
|
exception_as_error ((create {EXCEPTION_MANAGER}).last_exception)
|
||||||
|
db_control.reset
|
||||||
|
retry
|
||||||
|
end
|
||||||
|
|
||||||
|
rollback
|
||||||
|
-- Rollback updates in the database.
|
||||||
|
local
|
||||||
|
rescued: BOOLEAN
|
||||||
|
do
|
||||||
|
if not rescued then
|
||||||
|
if db_control.is_ok then
|
||||||
|
db_control.rollback
|
||||||
|
else
|
||||||
|
database_error_handler.add_database_error (db_control.error_message_32, db_control.error_code)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
rescue
|
||||||
|
rescued := True
|
||||||
|
exception_as_error ((create {EXCEPTION_MANAGER}).last_exception)
|
||||||
|
db_control.reset
|
||||||
|
retry
|
||||||
|
end
|
||||||
|
|
||||||
feature -- Change Element
|
feature -- Change Element
|
||||||
|
|
||||||
not_keep_connection
|
not_keep_connection
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ deferred class
|
|||||||
|
|
||||||
inherit
|
inherit
|
||||||
|
|
||||||
SHARED_ERROR
|
SHARED_ERROR_HANDLER
|
||||||
|
|
||||||
feature -- Access
|
feature -- Access
|
||||||
|
|
||||||
@@ -42,15 +42,15 @@ feature -- Modifiers
|
|||||||
|
|
||||||
feature -- Functionality Store Procedures
|
feature -- Functionality Store Procedures
|
||||||
|
|
||||||
execute_reader
|
execute_store_reader
|
||||||
-- Execute store.
|
-- Execute a `store' to read data.
|
||||||
require
|
require
|
||||||
store_not_void: store /= void
|
store_not_void: store /= void
|
||||||
deferred
|
deferred
|
||||||
end
|
end
|
||||||
|
|
||||||
execute_writer
|
execute_store_writer
|
||||||
-- Execute store.
|
-- Execute a `store' to write data.
|
||||||
require
|
require
|
||||||
store_not_void: store /= void
|
store_not_void: store /= void
|
||||||
deferred
|
deferred
|
||||||
@@ -59,7 +59,7 @@ feature -- Functionality Store Procedures
|
|||||||
feature -- SQL Queries
|
feature -- SQL Queries
|
||||||
|
|
||||||
execute_query
|
execute_query
|
||||||
-- Execute query.
|
-- Execute sql query, the read data from the database.
|
||||||
require
|
require
|
||||||
query_not_void: query /= void
|
query_not_void: query /= void
|
||||||
deferred
|
deferred
|
||||||
@@ -147,14 +147,49 @@ feature -- Access
|
|||||||
|
|
||||||
feature -- Status Report
|
feature -- Status Report
|
||||||
|
|
||||||
has_error: BOOLEAN
|
|
||||||
-- Is there an error?
|
|
||||||
|
|
||||||
count: INTEGER
|
count: INTEGER
|
||||||
-- Number of rows, last execution.
|
-- Number of rows, last execution.
|
||||||
deferred
|
deferred
|
||||||
end
|
end
|
||||||
|
|
||||||
|
connection: DATABASE_CONNECTION
|
||||||
|
-- Database connection.
|
||||||
|
|
||||||
|
db_control: DB_CONTROL
|
||||||
|
-- Database control.
|
||||||
|
do
|
||||||
|
Result := connection.db_control
|
||||||
|
end
|
||||||
|
|
||||||
|
db_result: detachable DB_RESULT
|
||||||
|
-- Database query result.
|
||||||
|
|
||||||
|
db_selection: detachable DB_SELECTION
|
||||||
|
-- Database selection.
|
||||||
|
|
||||||
|
db_change: detachable DB_CHANGE
|
||||||
|
-- Database modification.
|
||||||
|
|
||||||
|
feature -- Error handling
|
||||||
|
|
||||||
|
check_database_change_error
|
||||||
|
-- Check database error from `db_change'.
|
||||||
|
do
|
||||||
|
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)
|
||||||
|
log.write_error (generator + ".check_database_change_error: " + l_change.error_message_32)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
check_database_selection_error
|
||||||
|
-- Check database error from `db_selection'.
|
||||||
|
do
|
||||||
|
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)
|
||||||
|
log.write_error (generator + ".check_database_selection_error: " + l_selection.error_message_32)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
feature {NODE_DATA_PROVIDER}-- Implementation
|
feature {NODE_DATA_PROVIDER}-- Implementation
|
||||||
|
|
||||||
connect
|
connect
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ feature {NONE} -- Initialization
|
|||||||
do
|
do
|
||||||
connection := a_connection
|
connection := a_connection
|
||||||
create last_query.make_now
|
create last_query.make_now
|
||||||
set_successful
|
|
||||||
ensure
|
ensure
|
||||||
connection_not_void: connection /= Void
|
connection_not_void: connection /= Void
|
||||||
last_query_not_void: last_query /= Void
|
last_query_not_void: last_query /= Void
|
||||||
@@ -29,71 +28,52 @@ feature {NONE} -- Initialization
|
|||||||
|
|
||||||
feature -- Functionality
|
feature -- Functionality
|
||||||
|
|
||||||
execute_reader
|
execute_store_reader
|
||||||
-- Execute stored procedure that returns data.
|
-- Execute stored procedure that returns data.
|
||||||
local
|
local
|
||||||
l_db_selection: DB_SELECTION
|
l_db_selection: DB_SELECTION
|
||||||
l_retried: BOOLEAN
|
l_retried: BOOLEAN
|
||||||
do
|
do
|
||||||
if not l_retried then
|
if not l_retried then
|
||||||
if not keep_connection then
|
|
||||||
connect
|
|
||||||
end
|
|
||||||
|
|
||||||
if attached store as l_store then
|
if attached store as l_store then
|
||||||
create l_db_selection.make
|
create l_db_selection.make
|
||||||
db_selection := l_db_selection
|
db_selection := l_db_selection
|
||||||
items := l_store.execute_reader (l_db_selection)
|
items := l_store.execute_reader (l_db_selection)
|
||||||
|
check_database_selection_error
|
||||||
end
|
end
|
||||||
|
|
||||||
if not keep_connection then
|
|
||||||
disconnect
|
|
||||||
end
|
|
||||||
set_successful
|
|
||||||
log.write_debug ( generator+".execute_reader Successful")
|
log.write_debug ( generator+".execute_reader Successful")
|
||||||
end
|
end
|
||||||
rescue
|
rescue
|
||||||
set_last_error_from_exception ("Store procedure execution")
|
|
||||||
log.write_critical (generator+ ".execute_reader " + last_error_message)
|
|
||||||
if is_connected then
|
|
||||||
disconnect
|
|
||||||
end
|
|
||||||
l_retried := True
|
l_retried := True
|
||||||
|
exception_as_error ((create {EXCEPTION_MANAGER}).last_exception)
|
||||||
|
if attached db_selection as l_selection then
|
||||||
|
l_selection.reset
|
||||||
|
end
|
||||||
retry
|
retry
|
||||||
end
|
end
|
||||||
|
|
||||||
execute_writer
|
execute_store_writer
|
||||||
-- Execute stored procedure that update/add data.
|
-- Execute stored procedure that update/add data.
|
||||||
local
|
local
|
||||||
l_db_change: DB_CHANGE
|
l_db_change: DB_CHANGE
|
||||||
l_retried : BOOLEAN
|
l_retried : BOOLEAN
|
||||||
do
|
do
|
||||||
if not l_retried then
|
if not l_retried then
|
||||||
if not keep_connection and not is_connected then
|
|
||||||
connect
|
|
||||||
end
|
|
||||||
|
|
||||||
if attached store as l_store then
|
if attached store as l_store then
|
||||||
create l_db_change.make
|
create l_db_change.make
|
||||||
db_update := l_db_change
|
db_change := l_db_change
|
||||||
l_store.execute_writer (l_db_change)
|
l_store.execute_writer (l_db_change)
|
||||||
if not l_store.has_error then
|
check_database_change_error
|
||||||
db_control.commit
|
|
||||||
end
|
end
|
||||||
end
|
|
||||||
if not keep_connection then
|
|
||||||
disconnect
|
|
||||||
end
|
|
||||||
set_successful
|
|
||||||
log.write_debug ( generator+".execute_writer Successful")
|
log.write_debug ( generator+".execute_writer Successful")
|
||||||
end
|
end
|
||||||
rescue
|
rescue
|
||||||
set_last_error_from_exception ("Store procedure execution")
|
|
||||||
log.write_critical (generator+ ".execute_writer " + last_error_message)
|
|
||||||
if is_connected then
|
|
||||||
disconnect
|
|
||||||
end
|
|
||||||
l_retried := True
|
l_retried := True
|
||||||
|
exception_as_error ((create {EXCEPTION_MANAGER}).last_exception)
|
||||||
|
if attached db_change as l_change then
|
||||||
|
l_change.reset
|
||||||
|
end
|
||||||
retry
|
retry
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -106,60 +86,43 @@ feature -- SQL Queries
|
|||||||
l_retried: BOOLEAN
|
l_retried: BOOLEAN
|
||||||
do
|
do
|
||||||
if not l_retried then
|
if not l_retried then
|
||||||
if not keep_connection then
|
|
||||||
connect
|
|
||||||
end
|
|
||||||
|
|
||||||
if attached query as l_query then
|
if attached query as l_query then
|
||||||
create l_db_selection.make
|
create l_db_selection.make
|
||||||
db_selection := l_db_selection
|
db_selection := l_db_selection
|
||||||
items := l_query.execute_reader (l_db_selection)
|
items := l_query.execute_reader (l_db_selection)
|
||||||
|
check_database_selection_error
|
||||||
end
|
end
|
||||||
if not keep_connection then
|
|
||||||
disconnect
|
|
||||||
end
|
|
||||||
set_successful
|
|
||||||
end
|
end
|
||||||
rescue
|
rescue
|
||||||
set_last_error_from_exception ("execute_query")
|
|
||||||
log.write_critical (generator+ ".execute_query " + last_error_message)
|
|
||||||
if is_connected then
|
|
||||||
disconnect
|
|
||||||
end
|
|
||||||
l_retried := True
|
l_retried := True
|
||||||
|
exception_as_error ((create {EXCEPTION_MANAGER}).last_exception)
|
||||||
|
if attached db_selection as l_selection then
|
||||||
|
l_selection.reset
|
||||||
|
end
|
||||||
retry
|
retry
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
execute_change
|
execute_change
|
||||||
-- Execute sqlquery that update/add data.
|
-- Execute sql_query that update/add data.
|
||||||
local
|
local
|
||||||
l_db_change: DB_CHANGE
|
l_db_change: DB_CHANGE
|
||||||
l_retried : BOOLEAN
|
l_retried : BOOLEAN
|
||||||
do
|
do
|
||||||
if not l_retried then
|
if not l_retried then
|
||||||
if not keep_connection and not is_connected then
|
|
||||||
connect
|
|
||||||
end
|
|
||||||
|
|
||||||
if attached query as l_query then
|
if attached query as l_query then
|
||||||
create l_db_change.make
|
create l_db_change.make
|
||||||
db_update := l_db_change
|
db_change := l_db_change
|
||||||
l_query.execute_change (l_db_change)
|
l_query.execute_change (l_db_change)
|
||||||
db_control.commit
|
check_database_change_error
|
||||||
end
|
end
|
||||||
if not keep_connection then
|
|
||||||
disconnect
|
|
||||||
end
|
|
||||||
set_successful
|
|
||||||
end
|
end
|
||||||
rescue
|
rescue
|
||||||
set_last_error_from_exception ("Store procedure execution")
|
|
||||||
log.write_critical (generator+ ".execute_writer " + last_error_message)
|
|
||||||
if is_connected then
|
|
||||||
disconnect
|
|
||||||
end
|
|
||||||
l_retried := True
|
l_retried := True
|
||||||
|
exception_as_error ((create {EXCEPTION_MANAGER}).last_exception)
|
||||||
|
if attached db_change as l_change then
|
||||||
|
l_change.reset
|
||||||
|
end
|
||||||
retry
|
retry
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -207,24 +170,6 @@ feature -- Iteration
|
|||||||
|
|
||||||
feature {NONE} -- Implementation
|
feature {NONE} -- Implementation
|
||||||
|
|
||||||
connection: DATABASE_CONNECTION
|
|
||||||
-- Database connection.
|
|
||||||
|
|
||||||
db_control: DB_CONTROL
|
|
||||||
-- Database control.
|
|
||||||
do
|
|
||||||
Result := connection.db_control
|
|
||||||
end
|
|
||||||
|
|
||||||
db_result: detachable DB_RESULT
|
|
||||||
-- Database query result.
|
|
||||||
|
|
||||||
db_selection: detachable DB_SELECTION
|
|
||||||
-- Database selection.
|
|
||||||
|
|
||||||
db_update: detachable DB_CHANGE
|
|
||||||
-- Database modification.
|
|
||||||
|
|
||||||
last_query: DATE_TIME
|
last_query: DATE_TIME
|
||||||
-- Last time when a query was executed.
|
-- Last time when a query was executed.
|
||||||
|
|
||||||
@@ -263,7 +208,7 @@ feature {NONE} -- Implementation
|
|||||||
affected_row_count: INTEGER
|
affected_row_count: INTEGER
|
||||||
-- The number of rows changed, deleted, or inserted by the last statement.
|
-- The number of rows changed, deleted, or inserted by the last statement.
|
||||||
do
|
do
|
||||||
if attached db_update as l_update then
|
if attached db_change as l_update then
|
||||||
Result := l_update.affected_row_count
|
Result := l_update.affected_row_count
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
note
|
note
|
||||||
description: "External iteration cursor for {ESA_DATABASE_HANDLER}"
|
description: "External iteration cursor for {DATABASE_HANDLER}"
|
||||||
date: "$Date: 2014-08-20 15:21:15 -0300 (mi., 20 ago. 2014) $"
|
date: "$Date: 2014-08-20 15:21:15 -0300 (mi., 20 ago. 2014) $"
|
||||||
revision: "$Revision: 95678 $"
|
revision: "$Revision: 95678 $"
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
note
|
||||||
|
description: "Summary description for {DATABASE_NO_CHANGE_ERROR}."
|
||||||
|
author: ""
|
||||||
|
date: "$Date$"
|
||||||
|
revision: "$Revision$"
|
||||||
|
|
||||||
|
class
|
||||||
|
DATABASE_NO_CHANGE_ERROR
|
||||||
|
|
||||||
|
inherit
|
||||||
|
DATABASE_ERROR
|
||||||
|
redefine
|
||||||
|
make_from_message
|
||||||
|
end
|
||||||
|
|
||||||
|
create
|
||||||
|
make_from_message
|
||||||
|
|
||||||
|
feature {NONE} -- Init
|
||||||
|
|
||||||
|
make_from_message (a_m: like message; a_code: like code)
|
||||||
|
-- Create from `a_m'
|
||||||
|
do
|
||||||
|
make (a_code, once "Database No Change Error", a_m)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
@@ -8,14 +8,14 @@ class
|
|||||||
|
|
||||||
inherit
|
inherit
|
||||||
|
|
||||||
SHARED_ERROR
|
SHARED_ERROR_HANDLER
|
||||||
|
|
||||||
REFACTORING_HELPER
|
REFACTORING_HELPER
|
||||||
|
|
||||||
create
|
create
|
||||||
data_reader
|
data_reader
|
||||||
|
|
||||||
feature -- Intialization
|
feature {NONE} -- Intialization
|
||||||
|
|
||||||
data_reader (a_query: STRING; a_parameters: STRING_TABLE [detachable ANY])
|
data_reader (a_query: STRING; a_parameters: STRING_TABLE [detachable ANY])
|
||||||
-- SQL data reader for the query `a_query' with arguments `a_parameters'
|
-- SQL data reader for the query `a_query' with arguments `a_parameters'
|
||||||
@@ -29,6 +29,8 @@ feature -- Intialization
|
|||||||
parameters_set: parameters = a_parameters
|
parameters_set: parameters = a_parameters
|
||||||
end
|
end
|
||||||
|
|
||||||
|
feature -- Execution
|
||||||
|
|
||||||
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 sql query.
|
-- Execute the Current sql query.
|
||||||
do
|
do
|
||||||
@@ -42,7 +44,6 @@ feature -- Intialization
|
|||||||
a_base_selection.load_result
|
a_base_selection.load_result
|
||||||
Result := a_base_selection.container
|
Result := a_base_selection.container
|
||||||
else
|
else
|
||||||
set_last_error (a_base_selection.error_message_32, generator + ".execute_reader" )
|
|
||||||
log.write_error (generator + "." + a_base_selection.error_message_32)
|
log.write_error (generator + "." + a_base_selection.error_message_32)
|
||||||
end
|
end
|
||||||
unset_map_name (a_base_selection)
|
unset_map_name (a_base_selection)
|
||||||
@@ -50,17 +51,12 @@ feature -- Intialization
|
|||||||
end
|
end
|
||||||
|
|
||||||
execute_change (a_base_change: DB_CHANGE)
|
execute_change (a_base_change: DB_CHANGE)
|
||||||
-- Execute the Current sql query .
|
-- Execute the Current sql query to change/update data in the database.
|
||||||
do
|
do
|
||||||
to_implement ("Check test dynamic sequel. to redesign.")
|
to_implement ("Check test dynamic sequel. to redesign.")
|
||||||
set_map_name (a_base_change)
|
set_map_name (a_base_change)
|
||||||
a_base_change.set_query (query)
|
a_base_change.set_query (query)
|
||||||
a_base_change.execute_query
|
a_base_change.execute_query
|
||||||
if a_base_change.is_ok then
|
|
||||||
else
|
|
||||||
set_last_error (a_base_change.error_message_32, generator + ".execute_reader" )
|
|
||||||
log.write_error (generator + "." + a_base_change.error_message_32)
|
|
||||||
end
|
|
||||||
unset_map_name (a_base_change)
|
unset_map_name (a_base_change)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -72,17 +68,6 @@ feature -- Access
|
|||||||
parameters: STRING_TABLE [detachable ANY]
|
parameters: STRING_TABLE [detachable ANY]
|
||||||
-- query parameters.
|
-- query parameters.
|
||||||
|
|
||||||
feature -- Status Report
|
|
||||||
|
|
||||||
has_error: BOOLEAN
|
|
||||||
-- is there an error?
|
|
||||||
|
|
||||||
error_message: detachable STRING_32
|
|
||||||
-- Error message if any.
|
|
||||||
|
|
||||||
error_code: INTEGER
|
|
||||||
-- Error code.
|
|
||||||
|
|
||||||
feature {NONE} -- Implementation
|
feature {NONE} -- Implementation
|
||||||
|
|
||||||
set_map_name (a_base_selection: DB_EXPRESSION)
|
set_map_name (a_base_selection: DB_EXPRESSION)
|
||||||
@@ -140,4 +125,4 @@ feature {NONE} -- Implementation
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
end -- ESA_DATABASE_QUERY
|
end -- DATABASE_QUERY
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
note
|
||||||
|
description: "Error from database"
|
||||||
|
date: "$Date: 2013-08-08 16:39:49 -0300 (ju. 08 de ago. de 2013) $"
|
||||||
|
revision: "$Revision: 195 $"
|
||||||
|
|
||||||
|
class
|
||||||
|
DATABASE_ERROR
|
||||||
|
|
||||||
|
inherit
|
||||||
|
ERROR_CUSTOM
|
||||||
|
|
||||||
|
create
|
||||||
|
make_from_message
|
||||||
|
|
||||||
|
feature {NONE} -- Init
|
||||||
|
|
||||||
|
make_from_message (a_m: like message; a_code: like code)
|
||||||
|
-- Create from `a_m'
|
||||||
|
do
|
||||||
|
make (a_code, once "Database Error", a_m)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
@@ -15,21 +15,21 @@ create
|
|||||||
feature -- Error operation
|
feature -- Error operation
|
||||||
|
|
||||||
add_database_error (a_message: READABLE_STRING_32; a_code: INTEGER)
|
add_database_error (a_message: READABLE_STRING_32; a_code: INTEGER)
|
||||||
-- Add a database error
|
-- Add a database error.
|
||||||
local
|
local
|
||||||
-- l_error: DATABASE_ERROR
|
l_error: DATABASE_ERROR
|
||||||
do
|
do
|
||||||
-- create l_error.make_from_message (a_message, a_code)
|
create l_error.make_from_message (a_message, a_code)
|
||||||
-- add_error (l_error)
|
add_error (l_error)
|
||||||
end
|
end
|
||||||
|
|
||||||
add_database_no_change_error (a_message: READABLE_STRING_32; a_code: INTEGER)
|
add_database_no_change_error (a_message: READABLE_STRING_32; a_code: INTEGER)
|
||||||
-- Add a database error
|
-- Add a database error.
|
||||||
local
|
local
|
||||||
-- l_error: DATABASE_NO_CHANGE_ERROR
|
l_error: DATABASE_NO_CHANGE_ERROR
|
||||||
do
|
do
|
||||||
-- create l_error.make_from_message (a_message, a_code)
|
create l_error.make_from_message (a_message, a_code)
|
||||||
-- add_error (l_error)
|
add_error (l_error)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@@ -6,14 +6,26 @@ note
|
|||||||
class
|
class
|
||||||
SHARED_ERROR_HANDLER
|
SHARED_ERROR_HANDLER
|
||||||
|
|
||||||
|
inherit
|
||||||
|
|
||||||
|
SHARED_LOGGER
|
||||||
|
|
||||||
feature -- Access
|
feature -- Access
|
||||||
|
|
||||||
database_error_handler: DATABASE_ERROR_HANDLER
|
database_error_handler: DATABASE_ERROR_HANDLER
|
||||||
-- Error handler
|
-- Error handler.
|
||||||
once
|
once
|
||||||
create Result.make
|
create Result.make
|
||||||
end
|
end
|
||||||
|
|
||||||
|
feature -- Status Report
|
||||||
|
|
||||||
|
has_error: BOOLEAN
|
||||||
|
-- Has error?
|
||||||
|
do
|
||||||
|
Result := database_error_handler.has_error
|
||||||
|
end
|
||||||
|
|
||||||
feature -- Helper
|
feature -- Helper
|
||||||
|
|
||||||
exception_as_error (a_e: like {EXCEPTION_MANAGER}.last_exception)
|
exception_as_error (a_e: like {EXCEPTION_MANAGER}.last_exception)
|
||||||
@@ -21,6 +21,7 @@ feature {NONE} -- Initialization
|
|||||||
require
|
require
|
||||||
is_connected: a_connection.is_connected
|
is_connected: a_connection.is_connected
|
||||||
do
|
do
|
||||||
|
connection := a_connection
|
||||||
log.write_information (generator+".make_with_database is database connected? "+ a_connection.is_connected.out )
|
log.write_information (generator+".make_with_database is database connected? "+ a_connection.is_connected.out )
|
||||||
create node_provider.make (a_connection)
|
create node_provider.make (a_connection)
|
||||||
create user_provider.make (a_connection)
|
create user_provider.make (a_connection)
|
||||||
@@ -125,11 +126,14 @@ feature -- Change: user
|
|||||||
save_user (a_user: CMS_USER)
|
save_user (a_user: CMS_USER)
|
||||||
-- Add a new user `a_user'.
|
-- Add a new user `a_user'.
|
||||||
do
|
do
|
||||||
|
|
||||||
if
|
if
|
||||||
attached a_user.password as l_password and then
|
attached a_user.password as l_password and then
|
||||||
attached a_user.email as l_email
|
attached a_user.email as l_email
|
||||||
then
|
then
|
||||||
|
connection.begin_transaction
|
||||||
user_provider.new_user (a_user.name, l_password, l_email)
|
user_provider.new_user (a_user.name, l_password, l_email)
|
||||||
|
connection.commit
|
||||||
else
|
else
|
||||||
set_last_error ("User or Password not attached", generator + ".save_user")
|
set_last_error ("User or Password not attached", generator + ".save_user")
|
||||||
end
|
end
|
||||||
@@ -282,4 +286,6 @@ feature {NONE} -- Post process
|
|||||||
user_provider: USER_DATA_PROVIDER
|
user_provider: USER_DATA_PROVIDER
|
||||||
-- User Data provider.
|
-- User Data provider.
|
||||||
|
|
||||||
|
connection: DATABASE_CONNECTION
|
||||||
|
-- Current database connection.
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -34,17 +34,11 @@ feature -- Initialization
|
|||||||
if keep_connection then
|
if keep_connection then
|
||||||
connect
|
connect
|
||||||
end
|
end
|
||||||
set_successful
|
|
||||||
else
|
else
|
||||||
create db_control.make
|
create db_control.make
|
||||||
end
|
end
|
||||||
rescue
|
rescue
|
||||||
create db_control.make
|
exception_as_error ((create {EXCEPTION_MANAGER}).last_exception)
|
||||||
set_last_error_from_exception ("Connection execution")
|
|
||||||
log.write_critical (generator + ".make_common:" + last_error_message)
|
|
||||||
if is_connected then
|
|
||||||
disconnect
|
|
||||||
end
|
|
||||||
l_retried := True
|
l_retried := True
|
||||||
retry
|
retry
|
||||||
end
|
end
|
||||||
@@ -66,17 +60,11 @@ feature -- Initialization
|
|||||||
if keep_connection then
|
if keep_connection then
|
||||||
connect
|
connect
|
||||||
end
|
end
|
||||||
set_successful
|
|
||||||
else
|
else
|
||||||
create db_control.make
|
create db_control.make
|
||||||
end
|
end
|
||||||
rescue
|
rescue
|
||||||
create db_control.make
|
exception_as_error ((create {EXCEPTION_MANAGER}).last_exception)
|
||||||
set_last_error_from_exception ("Connection execution")
|
|
||||||
log.write_critical (generator + ".make_common:" + last_error_message)
|
|
||||||
if is_connected then
|
|
||||||
disconnect
|
|
||||||
end
|
|
||||||
l_retried := True
|
l_retried := True
|
||||||
retry
|
retry
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ feature -- Status Report
|
|||||||
is_successful: BOOLEAN
|
is_successful: BOOLEAN
|
||||||
-- Is the last execution sucessful?
|
-- Is the last execution sucessful?
|
||||||
do
|
do
|
||||||
Result := db_handler.successful
|
|
||||||
end
|
end
|
||||||
|
|
||||||
feature -- Access
|
feature -- Access
|
||||||
@@ -481,13 +480,6 @@ feature {NONE} -- Implementation
|
|||||||
post_execution
|
post_execution
|
||||||
-- Post database execution.
|
-- Post database execution.
|
||||||
do
|
do
|
||||||
if db_handler.successful then
|
|
||||||
set_successful
|
|
||||||
else
|
|
||||||
if attached db_handler.last_error then
|
|
||||||
set_last_error_from_handler (db_handler.last_error)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ feature -- Status Report
|
|||||||
is_successful: BOOLEAN
|
is_successful: BOOLEAN
|
||||||
-- Is the last execution sucessful?
|
-- Is the last execution sucessful?
|
||||||
do
|
do
|
||||||
Result := db_handler.successful
|
-- Result := db_handler.successful
|
||||||
end
|
end
|
||||||
|
|
||||||
has_roles: BOOLEAN
|
has_roles: BOOLEAN
|
||||||
@@ -210,13 +210,7 @@ feature {NONE} -- Implementation
|
|||||||
post_execution
|
post_execution
|
||||||
-- Post database execution.
|
-- Post database execution.
|
||||||
do
|
do
|
||||||
if db_handler.successful then
|
|
||||||
set_successful
|
|
||||||
else
|
|
||||||
if attached db_handler.last_error then
|
|
||||||
set_last_error_from_handler (db_handler.last_error)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ feature -- Status Report
|
|||||||
is_successful: BOOLEAN
|
is_successful: BOOLEAN
|
||||||
-- Is the last execution sucessful?
|
-- Is the last execution sucessful?
|
||||||
do
|
do
|
||||||
Result := db_handler.successful
|
|
||||||
end
|
end
|
||||||
|
|
||||||
has_user: BOOLEAN
|
has_user: BOOLEAN
|
||||||
@@ -311,13 +310,6 @@ feature {NONE} -- Implementation
|
|||||||
post_execution
|
post_execution
|
||||||
-- Post database execution.
|
-- Post database execution.
|
||||||
do
|
do
|
||||||
if db_handler.successful then
|
|
||||||
set_successful
|
|
||||||
else
|
|
||||||
if attached db_handler.last_error then
|
|
||||||
set_last_error_from_handler (db_handler.last_error)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ feature
|
|||||||
do
|
do
|
||||||
create l_parameters.make (0)
|
create l_parameters.make (0)
|
||||||
|
|
||||||
|
a_connection.begin_transaction
|
||||||
|
|
||||||
-- Clean Profiles
|
-- Clean Profiles
|
||||||
db_handler(a_connection).set_query (create {DATABASE_QUERY}.data_reader (Sql_delete_user_profiles, l_parameters))
|
db_handler(a_connection).set_query (create {DATABASE_QUERY}.data_reader (Sql_delete_user_profiles, l_parameters))
|
||||||
@@ -72,6 +73,7 @@ feature
|
|||||||
db_handler(a_connection).set_query (create {DATABASE_QUERY}.data_reader (Rest_profiles_autoincrement, l_parameters))
|
db_handler(a_connection).set_query (create {DATABASE_QUERY}.data_reader (Rest_profiles_autoincrement, l_parameters))
|
||||||
db_handler(a_connection).execute_change
|
db_handler(a_connection).execute_change
|
||||||
|
|
||||||
|
a_connection.commit
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user