diff --git a/cms-safe.ecf b/cms-safe.ecf
index 03e697d..0c11bd8 100644
--- a/cms-safe.ecf
+++ b/cms-safe.ecf
@@ -15,7 +15,6 @@
-
diff --git a/examples/demo/demo-safe.ecf b/examples/demo/demo-safe.ecf
index e09123b..19227ff 100644
--- a/examples/demo/demo-safe.ecf
+++ b/examples/demo/demo-safe.ecf
@@ -12,6 +12,8 @@
+
+
diff --git a/examples/demo/site/config/cms.ini b/examples/demo/site/config/cms.ini
index 05a3774..f434169 100644
--- a/examples/demo/site/config/cms.ini
+++ b/examples/demo/site/config/cms.ini
@@ -1,6 +1,11 @@
-engine=smarty
-site.name=EWF Web CMS
-site.email=your@email.com
-var-dir=var
-files-dir=files
+[layout]
+root-dir=site/www
+themes-dir=site/themes
+
+[site]
+name=Eiffel CMS
+email=your@email.com
theme=bootstrap
+
+[misc]
+smtp=localhost
diff --git a/examples/demo/src/ewf_roc_server.e b/examples/demo/src/ewf_roc_server.e
index 3fb8aca..7c47c72 100644
--- a/examples/demo/src/ewf_roc_server.e
+++ b/examples/demo/src/ewf_roc_server.e
@@ -147,6 +147,8 @@ feature -- CMS setup
debug ("refactor_fixme")
to_implement ("To implement custom storage")
end
+ a_setup.storage_drivers.force (create {CMS_STORAGE_MYSQL_BUILDER}.make, "mysql")
end
+
end
diff --git a/library/layout/src/logger/shared_logger.e b/library/layout/src/logger/shared_logger.e
index 9f6996f..ed0051e 100644
--- a/library/layout/src/logger/shared_logger.e
+++ b/library/layout/src/logger/shared_logger.e
@@ -1,7 +1,7 @@
note
description: "Provides logger information"
- date: "$Date: 2014-08-20 15:21:15 -0300 (mi., 20 ago. 2014) $"
- revision: "$Revision: 95678 $"
+ date: "$Date: 2015-01-15 00:00:58 +0100 (jeu., 15 janv. 2015) $"
+ revision: "$Revision: 96461 $"
class
SHARED_LOGGER
@@ -29,7 +29,7 @@ feature -- Logger
create l_environment
if attached separate_character_option_value ('d') as l_dir then
l_path := create {PATH}.make_from_string (l_dir)
- create l_log_writer.make_at_location (l_path.extended ("..").appended ("\api.log"))
+ create l_log_writer.make_at_location (l_path.extended ("logs").appended ("\api.log"))
else
l_path := create {PATH}.make_current
create l_log_writer.make_at_location (l_path.extended("api.log"))
@@ -107,6 +107,6 @@ feature {NONE} -- JSON
end
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)"
end
diff --git a/library/persistence/implementation/common/database/database_handler.e b/library/persistence/implementation/common/database/database_handler.e
index 3517ff3..02fdb7b 100644
--- a/library/persistence/implementation/common/database/database_handler.e
+++ b/library/persistence/implementation/common/database/database_handler.e
@@ -45,14 +45,14 @@ feature -- Functionality Store Procedures
execute_store_reader
-- Execute a `store' to read data.
require
- store_not_void: store /= void
+ store_not_void: store /= Void
deferred
end
execute_store_writer
-- Execute a `store' to write data.
require
- store_not_void: store /= void
+ store_not_void: store /= Void
deferred
end
@@ -61,14 +61,14 @@ feature -- SQL Queries
execute_query
-- Execute sql query, the read data from the database.
require
- query_not_void: query /= void
+ query_not_void: query /= Void
deferred
end
execute_change
-- Execute sql query that update/add data.
require
- query_not_void: query /= void
+ query_not_void: query /= Void
deferred
end
diff --git a/library/persistence/implementation/mysql/persistence_mysql-safe.ecf b/library/persistence/implementation/mysql/persistence_mysql-safe.ecf
index 218e80c..d5cef36 100644
--- a/library/persistence/implementation/mysql/persistence_mysql-safe.ecf
+++ b/library/persistence/implementation/mysql/persistence_mysql-safe.ecf
@@ -7,6 +7,7 @@
+
@@ -23,7 +24,6 @@
/database/database_connection_odbc.e
-
/EIFGENs$
diff --git a/library/persistence/implementation/mysql/src/cms_storage_mysql_builder.e b/library/persistence/implementation/mysql/src/cms_storage_mysql_builder.e
new file mode 100644
index 0000000..b651db3
--- /dev/null
+++ b/library/persistence/implementation/mysql/src/cms_storage_mysql_builder.e
@@ -0,0 +1,35 @@
+note
+ description: "[
+ Objects that ...
+ ]"
+ author: "$Author$"
+ date: "$Date$"
+ revision: "$Revision$"
+
+class
+ CMS_STORAGE_MYSQL_BUILDER
+
+inherit
+ CMS_STORAGE_BUILDER
+
+create
+ make
+
+feature {NONE} -- Initialization
+
+ make
+ -- Initialize `Current'.
+ do
+ end
+
+feature -- Factory
+
+ storage (a_setup: CMS_SETUP): detachable CMS_STORAGE_MYSQL
+ do
+ if attached (create {APPLICATION_JSON_CONFIGURATION_HELPER}).new_database_configuration (a_setup.layout.application_config_path) as l_database_config then
+ create Result.make (create {DATABASE_CONNECTION_MYSQL}.login_with_connection_string (l_database_config.connection_string))
+ end
+ end
+
+
+end
diff --git a/library/src/configuration/cms_default_setup.e b/library/src/configuration/cms_default_setup.e
index cad0c09..d73a4f6 100644
--- a/library/src/configuration/cms_default_setup.e
+++ b/library/src/configuration/cms_default_setup.e
@@ -31,7 +31,10 @@ feature {NONE} -- Initialization
do
configure
create modules.make (3)
+ create storage_drivers.make (2)
+
build_mailer
+ initialize_storages
initialize_modules
end
@@ -72,6 +75,12 @@ feature {NONE} -- Initialization
compute_theme_assets_location
end
+ initialize_storages
+ -- Initialize storages
+ do
+ storage_drivers.force (create {CMS_STORAGE_NULL_BUILDER}, "null")
+ end
+
initialize_modules
-- Intialize core modules.
local
@@ -144,6 +153,11 @@ feature -- Access
to_implement ("Not implemented mailer")
end
+feature -- Access: storage
+
+ storage_drivers: STRING_TABLE [CMS_STORAGE_BUILDER]
+ -- Precursor
+
feature -- Element change
register_module (m: CMS_MODULE)
diff --git a/library/src/configuration/cms_setup.e b/library/src/configuration/cms_setup.e
index e1218e6..8a0383e 100644
--- a/library/src/configuration/cms_setup.e
+++ b/library/src/configuration/cms_setup.e
@@ -6,6 +6,9 @@ note
deferred class
CMS_SETUP
+inherit
+ REFACTORING_HELPER
+
feature -- Access
layout: CMS_LAYOUT
@@ -88,7 +91,6 @@ feature -- Query
deferred
end
-
feature -- Access: Theme
themes_location: PATH
@@ -109,6 +111,54 @@ feature -- Access: Theme
theme_name: READABLE_STRING_32
-- theme name.
+feature -- Access: storage
+
+ storage_drivers: STRING_TABLE [CMS_STORAGE_BUILDER]
+ deferred
+ end
+
+ storage (a_error_handler: ERROR_HANDLER): detachable CMS_STORAGE
+ local
+ retried: BOOLEAN
+ l_message: STRING
+ do
+ if not retried then
+ to_implement ("Refactor database setup")
+ if
+ attached (create {APPLICATION_JSON_CONFIGURATION_HELPER}).new_database_configuration (layout.application_config_path) as l_database_config and then
+ attached storage_drivers.item (l_database_config.driver) as l_builder
+ then
+ Result := l_builder.storage (Current)
+ else
+ create {CMS_STORAGE_NULL} Result
+ end
+ else
+ to_implement ("Workaround code, persistence layer does not implement yet this kind of error handling.")
+ -- error hanling.
+ create {CMS_STORAGE_NULL} Result
+ 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
+ a_error_handler.add_custom_error (0, " Database Connection ", l_message)
+ end
+ rescue
+ retried := True
+ retry
+ end
+
feature -- Element change
register_module (m: CMS_MODULE)
diff --git a/library/persistence/interface/cms_storage.e b/library/src/persistence/cms_storage.e
similarity index 100%
rename from library/persistence/interface/cms_storage.e
rename to library/src/persistence/cms_storage.e
diff --git a/library/src/persistence/cms_storage_builder.e b/library/src/persistence/cms_storage_builder.e
new file mode 100644
index 0000000..5880d55
--- /dev/null
+++ b/library/src/persistence/cms_storage_builder.e
@@ -0,0 +1,18 @@
+note
+ description: "[
+ Objects that ...
+ ]"
+ author: "$Author$"
+ date: "$Date$"
+ revision: "$Revision$"
+
+deferred class
+ CMS_STORAGE_BUILDER
+
+feature -- Factory
+
+ storage (a_setup: CMS_SETUP): detachable CMS_STORAGE
+ deferred
+ end
+
+end
diff --git a/library/persistence/implementation/common/cms_storage_null.e b/library/src/persistence/cms_storage_null.e
similarity index 100%
rename from library/persistence/implementation/common/cms_storage_null.e
rename to library/src/persistence/cms_storage_null.e
diff --git a/library/src/persistence/cms_storage_null_builder.e b/library/src/persistence/cms_storage_null_builder.e
new file mode 100644
index 0000000..633084f
--- /dev/null
+++ b/library/src/persistence/cms_storage_null_builder.e
@@ -0,0 +1,22 @@
+note
+ description: "[
+ Objects that ...
+ ]"
+ author: "$Author$"
+ date: "$Date$"
+ revision: "$Revision$"
+
+class
+ CMS_STORAGE_NULL_BUILDER
+
+inherit
+ CMS_STORAGE_BUILDER
+
+feature -- Factory
+
+ storage (a_setup: CMS_SETUP): detachable CMS_STORAGE_NULL
+ do
+ create Result
+ end
+
+end
diff --git a/library/src/service/cms_api.e b/library/src/service/cms_api.e
index 7476eb4..c6abbe0 100644
--- a/library/src/service/cms_api.e
+++ b/library/src/service/cms_api.e
@@ -31,46 +31,13 @@ feature -- Initialize
initialize
-- Initialize the persitent layer.
- local
- l_database: DATABASE_CONNECTION
- retried: BOOLEAN
- l_message: STRING
do
- if not retried then
- to_implement ("Refactor database setup")
- if attached (create {APPLICATION_JSON_CONFIGURATION_HELPER}).new_database_configuration (setup.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 {CMS_STORAGE_MYSQL} storage.make (l_database)
- else
- create {DATABASE_CONNECTION_NULL} l_database.make_common
- create {CMS_STORAGE_NULL} storage
- end
+ to_implement ("Refactor database setup")
+ if attached setup.storage (error_handler) as l_storage then
+ storage := l_storage
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 {CMS_STORAGE_NULL} storage
- 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
- retried := True
- retry
end
feature -- Access: Error
@@ -110,7 +77,7 @@ feature -- Status Report
feature -- Access: Node
- nodes: LIST[CMS_NODE]
+ nodes: LIST [CMS_NODE]
-- List of nodes.
do
debug ("refactor_fixme")