Compare commits
1 Commits
master
...
storage_re
| Author | SHA1 | Date | |
|---|---|---|---|
| 4dcc1b0e04 |
@@ -15,7 +15,6 @@
|
||||
<library name="json" location="$ISE_LIBRARY\contrib\library\text\parser\json\library\json-safe.ecf" readonly="false"/>
|
||||
<library name="layout" location=".\library\layout\layout-safe.ecf"/>
|
||||
<library name="model" location=".\library\model\cms_model-safe.ecf" readonly="false"/>
|
||||
<library name="persistence_mysql" location=".\library\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="text_filter" location="$ISE_LIBRARY\unstable\library\text\text_filter\text_filter-safe.ecf"/>
|
||||
<library name="time" location="$ISE_LIBRARY\library\time\time-safe.ecf"/>
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
|
||||
<library name="cms" location="..\..\cms-safe.ecf" readonly="false"/>
|
||||
<library name="cms_demo_module" location="modules\demo\cms_demo_module-safe.ecf" readonly="false"/>
|
||||
<library name="persistence_mysql" location="..\..\library\persistence\implementation\mysql\persistence_mysql-safe.ecf" readonly="false"/>
|
||||
|
||||
<library name="layout" location="..\..\library\layout\layout-safe.ecf" readonly="false"/>
|
||||
<library name="wsf" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\wsf-safe.ecf"/>
|
||||
<library name="wsf_extension" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\wsf_extension-safe.ecf" readonly="false"/>
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
</option>
|
||||
<setting name="console_application" value="true"/>
|
||||
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
|
||||
<library name="cms" location="..\..\..\..\cms-safe.ecf"/>
|
||||
<library name="crypto" location="$ISE_LIBRARY\unstable\library\text\encryption\crypto\crypto-safe.ecf"/>
|
||||
<library name="encoder" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\text\encoder\encoder-safe.ecf"/>
|
||||
<library name="error" location="$ISE_LIBRARY\contrib\library\utility\general\error\error-safe.ecf"/>
|
||||
@@ -23,7 +24,6 @@
|
||||
<exclude>/database/database_connection_odbc.e</exclude>
|
||||
</file_rule>
|
||||
</cluster>
|
||||
<cluster name="interface" location="..\..\interface\" recursive="true"/>
|
||||
<cluster name="persistence_mysql" location=".\src\" recursive="true">
|
||||
<file_rule>
|
||||
<exclude>/EIFGENs$</exclude>
|
||||
|
||||
@@ -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
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
18
library/src/persistence/cms_storage_builder.e
Normal file
18
library/src/persistence/cms_storage_builder.e
Normal file
@@ -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
|
||||
22
library/src/persistence/cms_storage_null_builder.e
Normal file
22
library/src/persistence/cms_storage_null_builder.e
Normal file
@@ -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
|
||||
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user